1af866496SDavid Daney /***********************license start*************** 2af866496SDavid Daney * Author: Cavium Networks 3af866496SDavid Daney * 4af866496SDavid Daney * Contact: support@caviumnetworks.com 5af866496SDavid Daney * This file is part of the OCTEON SDK 6af866496SDavid Daney * 7af866496SDavid Daney * Copyright (c) 2003-2008 Cavium Networks 8af866496SDavid Daney * 9af866496SDavid Daney * This file is free software; you can redistribute it and/or modify 10af866496SDavid Daney * it under the terms of the GNU General Public License, Version 2, as 11af866496SDavid Daney * published by the Free Software Foundation. 12af866496SDavid Daney * 13af866496SDavid Daney * This file is distributed in the hope that it will be useful, but 14af866496SDavid Daney * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty 15af866496SDavid Daney * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or 16af866496SDavid Daney * NONINFRINGEMENT. See the GNU General Public License for more 17af866496SDavid Daney * details. 18af866496SDavid Daney * 19af866496SDavid Daney * You should have received a copy of the GNU General Public License 20af866496SDavid Daney * along with this file; if not, write to the Free Software 21af866496SDavid Daney * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22af866496SDavid Daney * or visit http://www.gnu.org/licenses/. 23af866496SDavid Daney * 24af866496SDavid Daney * This file may also be available under a different license from Cavium. 25af866496SDavid Daney * Contact Cavium Networks for more information 26af866496SDavid Daney ***********************license end**************************************/ 27af866496SDavid Daney 28af866496SDavid Daney /* 29af866496SDavid Daney * 30af866496SDavid Daney * Helper functions for common, but complicated tasks. 31af866496SDavid Daney * 32af866496SDavid Daney */ 33af866496SDavid Daney 34af866496SDavid Daney #ifndef __CVMX_HELPER_H__ 35af866496SDavid Daney #define __CVMX_HELPER_H__ 36af866496SDavid Daney 37a1ce3928SDavid Howells #include <asm/octeon/cvmx-config.h> 38a1ce3928SDavid Howells #include <asm/octeon/cvmx-fpa.h> 39a1ce3928SDavid Howells #include <asm/octeon/cvmx-wqe.h> 40af866496SDavid Daney 41af866496SDavid Daney typedef enum { 42af866496SDavid Daney CVMX_HELPER_INTERFACE_MODE_DISABLED, 43af866496SDavid Daney CVMX_HELPER_INTERFACE_MODE_RGMII, 44af866496SDavid Daney CVMX_HELPER_INTERFACE_MODE_GMII, 45af866496SDavid Daney CVMX_HELPER_INTERFACE_MODE_SPI, 46af866496SDavid Daney CVMX_HELPER_INTERFACE_MODE_PCIE, 47af866496SDavid Daney CVMX_HELPER_INTERFACE_MODE_XAUI, 48af866496SDavid Daney CVMX_HELPER_INTERFACE_MODE_SGMII, 49af866496SDavid Daney CVMX_HELPER_INTERFACE_MODE_PICMG, 50af866496SDavid Daney CVMX_HELPER_INTERFACE_MODE_NPI, 51af866496SDavid Daney CVMX_HELPER_INTERFACE_MODE_LOOP, 52af866496SDavid Daney } cvmx_helper_interface_mode_t; 53af866496SDavid Daney 54*f7d2bdcbSChris Packham union cvmx_helper_link_info { 55af866496SDavid Daney uint64_t u64; 56af866496SDavid Daney struct { 57af866496SDavid Daney uint64_t reserved_20_63:44; 58af866496SDavid Daney uint64_t link_up:1; /**< Is the physical link up? */ 59af866496SDavid Daney uint64_t full_duplex:1; /**< 1 if the link is full duplex */ 60af866496SDavid Daney uint64_t speed:18; /**< Speed of the link in Mbps */ 61af866496SDavid Daney } s; 62*f7d2bdcbSChris Packham }; 63af866496SDavid Daney 64af866496SDavid Daney #include <asm/octeon/cvmx-helper-errata.h> 65a1ce3928SDavid Howells #include <asm/octeon/cvmx-helper-loop.h> 66a1ce3928SDavid Howells #include <asm/octeon/cvmx-helper-npi.h> 67a1ce3928SDavid Howells #include <asm/octeon/cvmx-helper-rgmii.h> 68a1ce3928SDavid Howells #include <asm/octeon/cvmx-helper-sgmii.h> 69a1ce3928SDavid Howells #include <asm/octeon/cvmx-helper-spi.h> 70a1ce3928SDavid Howells #include <asm/octeon/cvmx-helper-util.h> 71a1ce3928SDavid Howells #include <asm/octeon/cvmx-helper-xaui.h> 72af866496SDavid Daney 73af866496SDavid Daney /** 74af866496SDavid Daney * This function enables the IPD and also enables the packet interfaces. 75af866496SDavid Daney * The packet interfaces (RGMII and SPI) must be enabled after the 76af866496SDavid Daney * IPD. This should be called by the user program after any additional 77af866496SDavid Daney * IPD configuration changes are made if CVMX_HELPER_ENABLE_IPD 78af866496SDavid Daney * is not set in the executive-config.h file. 79af866496SDavid Daney * 80af866496SDavid Daney * Returns 0 on success 81af866496SDavid Daney * -1 on failure 82af866496SDavid Daney */ 83af866496SDavid Daney extern int cvmx_helper_ipd_and_packet_input_enable(void); 84af866496SDavid Daney 85af866496SDavid Daney /** 86af866496SDavid Daney * Initialize the PIP, IPD, and PKO hardware to support 87af866496SDavid Daney * simple priority based queues for the ethernet ports. Each 88af866496SDavid Daney * port is configured with a number of priority queues based 89af866496SDavid Daney * on CVMX_PKO_QUEUES_PER_PORT_* where each queue is lower 90af866496SDavid Daney * priority than the previous. 91af866496SDavid Daney * 92af866496SDavid Daney * Returns Zero on success, non-zero on failure 93af866496SDavid Daney */ 94af866496SDavid Daney extern int cvmx_helper_initialize_packet_io_global(void); 95af866496SDavid Daney 96af866496SDavid Daney /** 97af866496SDavid Daney * Returns the number of ports on the given interface. 98af866496SDavid Daney * The interface must be initialized before the port count 99af866496SDavid Daney * can be returned. 100af866496SDavid Daney * 101af866496SDavid Daney * @interface: Which interface to return port count for. 102af866496SDavid Daney * 103af866496SDavid Daney * Returns Port count for interface 104af866496SDavid Daney * -1 for uninitialized interface 105af866496SDavid Daney */ 106af866496SDavid Daney extern int cvmx_helper_ports_on_interface(int interface); 107af866496SDavid Daney 108af866496SDavid Daney /** 109af866496SDavid Daney * Return the number of interfaces the chip has. Each interface 110af866496SDavid Daney * may have multiple ports. Most chips support two interfaces, 111af866496SDavid Daney * but the CNX0XX and CNX1XX are exceptions. These only support 112af866496SDavid Daney * one interface. 113af866496SDavid Daney * 114af866496SDavid Daney * Returns Number of interfaces on chip 115af866496SDavid Daney */ 116af866496SDavid Daney extern int cvmx_helper_get_number_of_interfaces(void); 117af866496SDavid Daney 118af866496SDavid Daney /** 119af866496SDavid Daney * Get the operating mode of an interface. Depending on the Octeon 120af866496SDavid Daney * chip and configuration, this function returns an enumeration 121af866496SDavid Daney * of the type of packet I/O supported by an interface. 122af866496SDavid Daney * 123af866496SDavid Daney * @interface: Interface to probe 124af866496SDavid Daney * 125af866496SDavid Daney * Returns Mode of the interface. Unknown or unsupported interfaces return 126af866496SDavid Daney * DISABLED. 127af866496SDavid Daney */ 128af866496SDavid Daney extern cvmx_helper_interface_mode_t cvmx_helper_interface_get_mode(int 129af866496SDavid Daney interface); 130af866496SDavid Daney 131af866496SDavid Daney /** 132af866496SDavid Daney * Return the link state of an IPD/PKO port as returned by 133af866496SDavid Daney * auto negotiation. The result of this function may not match 134af866496SDavid Daney * Octeon's link config if auto negotiation has changed since 135af866496SDavid Daney * the last call to cvmx_helper_link_set(). 136af866496SDavid Daney * 137af866496SDavid Daney * @ipd_port: IPD/PKO port to query 138af866496SDavid Daney * 139af866496SDavid Daney * Returns Link state 140af866496SDavid Daney */ 141*f7d2bdcbSChris Packham extern union cvmx_helper_link_info cvmx_helper_link_get(int ipd_port); 142af866496SDavid Daney 143af866496SDavid Daney /** 144af866496SDavid Daney * Configure an IPD/PKO port for the specified link state. This 145af866496SDavid Daney * function does not influence auto negotiation at the PHY level. 146af866496SDavid Daney * The passed link state must always match the link state returned 1472b58a76eSAaro Koskinen * by cvmx_helper_link_get(). 148af866496SDavid Daney * 149af866496SDavid Daney * @ipd_port: IPD/PKO port to configure 150af866496SDavid Daney * @link_info: The new link state 151af866496SDavid Daney * 152af866496SDavid Daney * Returns Zero on success, negative on failure 153af866496SDavid Daney */ 154af866496SDavid Daney extern int cvmx_helper_link_set(int ipd_port, 155*f7d2bdcbSChris Packham union cvmx_helper_link_info link_info); 156af866496SDavid Daney 157af866496SDavid Daney /** 158af866496SDavid Daney * This function probes an interface to determine the actual 159af866496SDavid Daney * number of hardware ports connected to it. It doesn't setup the 160af866496SDavid Daney * ports or enable them. The main goal here is to set the global 161af866496SDavid Daney * interface_port_count[interface] correctly. Hardware setup of the 162af866496SDavid Daney * ports will be performed later. 163af866496SDavid Daney * 164af866496SDavid Daney * @interface: Interface to probe 165af866496SDavid Daney * 166af866496SDavid Daney * Returns Zero on success, negative on failure 167af866496SDavid Daney */ 168af866496SDavid Daney extern int cvmx_helper_interface_probe(int interface); 16937d3bfd9SDavid Daney extern int cvmx_helper_interface_enumerate(int interface); 170af866496SDavid Daney 171af866496SDavid Daney #endif /* __CVMX_HELPER_H__ */ 172