cvmx-helper-board.h revision 210284
1/***********************license start***************
2 *  Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
3 *  reserved.
4 *
5 *
6 *  Redistribution and use in source and binary forms, with or without
7 *  modification, are permitted provided that the following conditions are
8 *  met:
9 *
10 *      * Redistributions of source code must retain the above copyright
11 *        notice, this list of conditions and the following disclaimer.
12 *
13 *      * Redistributions in binary form must reproduce the above
14 *        copyright notice, this list of conditions and the following
15 *        disclaimer in the documentation and/or other materials provided
16 *        with the distribution.
17 *
18 *      * Neither the name of Cavium Networks nor the names of
19 *        its contributors may be used to endorse or promote products
20 *        derived from this software without specific prior written
21 *        permission.
22 *
23 *  TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24 *  AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25 *  OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26 *  RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27 *  REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28 *  DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29 *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30 *  PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31 *  POSSESSION OR CORRESPONDENCE TO DESCRIPTION.  THE ENTIRE RISK ARISING OUT
32 *  OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
33 *
34 *
35 *  For any questions regarding licensing please contact marketing@caviumnetworks.com
36 *
37 ***********************license end**************************************/
38
39
40
41
42
43
44/**
45 * @file
46 *
47 * Helper functions to abstract board specific data about
48 * network ports from the rest of the cvmx-helper files.
49 *
50 * <hr>$Revision: 41946 $<hr>
51 */
52#ifndef __CVMX_HELPER_BOARD_H__
53#define __CVMX_HELPER_BOARD_H__
54
55#ifdef	__cplusplus
56extern "C" {
57#endif
58
59
60typedef enum {
61    USB_CLOCK_TYPE_REF_12,
62    USB_CLOCK_TYPE_REF_24,
63    USB_CLOCK_TYPE_REF_48,
64    USB_CLOCK_TYPE_CRYSTAL_12,
65} cvmx_helper_board_usb_clock_types_t;
66
67typedef enum {
68    set_phy_link_flags_autoneg                  = 0x1,
69    set_phy_link_flags_flow_control_dont_touch  = 0x0 << 1,
70    set_phy_link_flags_flow_control_enable      = 0x1 << 1,
71    set_phy_link_flags_flow_control_disable     = 0x2 << 1,
72    set_phy_link_flags_flow_control_mask        = 0x3 << 1,  /* Mask for 2 bit wide flow control field */
73} cvmx_helper_board_set_phy_link_flags_types_t;
74
75
76/**
77 * cvmx_override_board_link_get(int ipd_port) is a function
78 * pointer. It is meant to allow customization of the process of
79 * talking to a PHY to determine link speed. It is called every
80 * time a PHY must be polled for link status. Users should set
81 * this pointer to a function before calling any cvmx-helper
82 * operations.
83 */
84extern cvmx_helper_link_info_t (*cvmx_override_board_link_get)(int ipd_port);
85
86/**
87 * Return the MII PHY address associated with the given IPD
88 * port. A result of -1 means there isn't a MII capable PHY
89 * connected to this port. On chips supporting multiple MII
90 * busses the bus number is encoded in bits <15:8>.
91 *
92 * This function must be modifed for every new Octeon board.
93 * Internally it uses switch statements based on the cvmx_sysinfo
94 * data to determine board types and revisions. It relys on the
95 * fact that every Octeon board receives a unique board type
96 * enumeration from the bootloader.
97 *
98 * @param ipd_port Octeon IPD port to get the MII address for.
99 *
100 * @return MII PHY address and bus number or -1.
101 */
102extern int cvmx_helper_board_get_mii_address(int ipd_port);
103
104/**
105 * This function as a board specific method of changing the PHY
106 * speed, duplex, and autonegotiation. This programs the PHY and
107 * not Octeon. This can be used to force Octeon's links to
108 * specific settings.
109 *
110 * @param phy_addr  The address of the PHY to program
111 * @param link_flags
112 *                  Flags to control autonegotiation.  Bit 0 is autonegotiation
113 *                  enable/disable to maintain backware compatability.
114 * @param link_info Link speed to program. If the speed is zero and autonegotiation
115 *                  is enabled, all possible negotiation speeds are advertised.
116 *
117 * @return Zero on success, negative on failure
118 */
119int cvmx_helper_board_link_set_phy(int phy_addr, cvmx_helper_board_set_phy_link_flags_types_t link_flags,
120                                   cvmx_helper_link_info_t link_info);
121
122/**
123 * @INTERNAL
124 * This function is the board specific method of determining an
125 * ethernet ports link speed. Most Octeon boards have Marvell PHYs
126 * and are handled by the fall through case. This function must be
127 * updated for boards that don't have the normal Marvell PHYs.
128 *
129 * This function must be modifed for every new Octeon board.
130 * Internally it uses switch statements based on the cvmx_sysinfo
131 * data to determine board types and revisions. It relys on the
132 * fact that every Octeon board receives a unique board type
133 * enumeration from the bootloader.
134 *
135 * @param ipd_port IPD input port associated with the port we want to get link
136 *                 status for.
137 *
138 * @return The ports link status. If the link isn't fully resolved, this must
139 *         return zero.
140 */
141extern cvmx_helper_link_info_t __cvmx_helper_board_link_get(int ipd_port);
142
143/**
144 * @INTERNAL
145 * This function is called by cvmx_helper_interface_probe() after it
146 * determines the number of ports Octeon can support on a specific
147 * interface. This function is the per board location to override
148 * this value. It is called with the number of ports Octeon might
149 * support and should return the number of actual ports on the
150 * board.
151 *
152 * This function must be modifed for every new Octeon board.
153 * Internally it uses switch statements based on the cvmx_sysinfo
154 * data to determine board types and revisions. It relys on the
155 * fact that every Octeon board receives a unique board type
156 * enumeration from the bootloader.
157 *
158 * @param interface Interface to probe
159 * @param supported_ports
160 *                  Number of ports Octeon supports.
161 *
162 * @return Number of ports the actual board supports. Many times this will
163 *         simple be "support_ports".
164 */
165extern int __cvmx_helper_board_interface_probe(int interface, int supported_ports);
166
167/**
168 * @INTERNAL
169 * Enable packet input/output from the hardware. This function is
170 * called after by cvmx_helper_packet_hardware_enable() to
171 * perform board specific initialization. For most boards
172 * nothing is needed.
173 *
174 * @param interface Interface to enable
175 *
176 * @return Zero on success, negative on failure
177 */
178extern int __cvmx_helper_board_hardware_enable(int interface);
179
180
181
182
183/**
184 * @INTERNAL
185 * Gets the clock type used for the USB block based on board type.
186 * Used by the USB code for auto configuration of clock type.
187 *
188 * @return USB clock type enumeration
189 */
190cvmx_helper_board_usb_clock_types_t __cvmx_helper_board_usb_get_clock_type(void);
191
192
193/**
194 * @INTERNAL
195 * Adjusts the number of available USB ports on Octeon based on board
196 * specifics.
197 *
198 * @param supported_ports expected number of ports based on chip type;
199 *
200 *
201 * @return number of available usb ports, based on board specifics.
202 *         Return value is supported_ports if function does not
203 *         override.
204 */
205int __cvmx_helper_board_usb_get_num_ports(int supported_ports);
206
207#ifdef	__cplusplus
208}
209#endif
210
211#endif  /* __CVMX_HELPER_BOARD_H__ */
212