]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/contrib/octeon-sdk/cvmx-helper-board.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / contrib / octeon-sdk / cvmx-helper-board.h
1 /***********************license start***************
2  * Copyright (c) 2003-2010  Cavium Inc. (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 Inc. 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  * This Software, including technical data, may be subject to U.S. export  control
24  * laws, including the U.S. Export Administration Act and its  associated
25  * regulations, and may be subject to export or import  regulations in other
26  * countries.
27
28  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29  * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30  * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31  * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32  * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33  * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34  * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35  * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36  * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37  * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38  ***********************license end**************************************/
39
40
41
42
43
44
45
46 /**
47  * @file
48  *
49  * Helper functions to abstract board specific data about
50  * network ports from the rest of the cvmx-helper files.
51  *
52  * <hr>$Revision: 70030 $<hr>
53  */
54 #ifndef __CVMX_HELPER_BOARD_H__
55 #define __CVMX_HELPER_BOARD_H__
56
57 #ifdef  __cplusplus
58 extern "C" {
59 #endif
60
61
62 typedef enum {
63     USB_CLOCK_TYPE_REF_12,
64     USB_CLOCK_TYPE_REF_24,
65     USB_CLOCK_TYPE_REF_48,
66     USB_CLOCK_TYPE_CRYSTAL_12,
67 } cvmx_helper_board_usb_clock_types_t;
68
69 typedef enum {
70     BROADCOM_GENERIC_PHY,
71     MARVELL_GENERIC_PHY,
72 } cvmx_phy_type_t;
73
74 typedef enum {
75     set_phy_link_flags_autoneg                  = 0x1,
76     set_phy_link_flags_flow_control_dont_touch  = 0x0 << 1,
77     set_phy_link_flags_flow_control_enable      = 0x1 << 1,
78     set_phy_link_flags_flow_control_disable     = 0x2 << 1,
79     set_phy_link_flags_flow_control_mask        = 0x3 << 1,  /* Mask for 2 bit wide flow control field */
80 } cvmx_helper_board_set_phy_link_flags_types_t;
81
82
83 /* Fake IPD port, the RGMII/MII interface may use different PHY, use this
84    macro to return appropriate MIX address to read the PHY. */
85 #define CVMX_HELPER_BOARD_MGMT_IPD_PORT     -10
86
87 /**
88  * cvmx_override_board_link_get(int ipd_port) is a function
89  * pointer. It is meant to allow customization of the process of
90  * talking to a PHY to determine link speed. It is called every
91  * time a PHY must be polled for link status. Users should set
92  * this pointer to a function before calling any cvmx-helper
93  * operations.
94  */
95 extern cvmx_helper_link_info_t (*cvmx_override_board_link_get)(int ipd_port);
96
97 /**
98  * Return the MII PHY address associated with the given IPD
99  * port. A result of -1 means there isn't a MII capable PHY
100  * connected to this port. On chips supporting multiple MII
101  * busses the bus number is encoded in bits <15:8>.
102  *
103  * This function must be modified for every new Octeon board.
104  * Internally it uses switch statements based on the cvmx_sysinfo
105  * data to determine board types and revisions. It relies on the
106  * fact that every Octeon board receives a unique board type
107  * enumeration from the bootloader.
108  *
109  * @param ipd_port Octeon IPD port to get the MII address for.
110  *
111  * @return MII PHY address and bus number or -1.
112  */
113 extern int cvmx_helper_board_get_mii_address(int ipd_port);
114
115 /**
116  * This function as a board specific method of changing the PHY
117  * speed, duplex, and autonegotiation. This programs the PHY and
118  * not Octeon. This can be used to force Octeon's links to
119  * specific settings.
120  *
121  * @param phy_addr  The address of the PHY to program
122  * @param link_flags
123  *                  Flags to control autonegotiation.  Bit 0 is autonegotiation
124  *                  enable/disable to maintain backward compatibility.
125  * @param link_info Link speed to program. If the speed is zero and autonegotiation
126  *                  is enabled, all possible negotiation speeds are advertised.
127  *
128  * @return Zero on success, negative on failure
129  */
130 int cvmx_helper_board_link_set_phy(int phy_addr, cvmx_helper_board_set_phy_link_flags_types_t link_flags,
131                                    cvmx_helper_link_info_t link_info);
132
133 /**
134  * @INTERNAL
135  * This function is the board specific method of determining an
136  * ethernet ports link speed. Most Octeon boards have Marvell PHYs
137  * and are handled by the fall through case. This function must be
138  * updated for boards that don't have the normal Marvell PHYs.
139  *
140  * This function must be modified for every new Octeon board.
141  * Internally it uses switch statements based on the cvmx_sysinfo
142  * data to determine board types and revisions. It relies on the
143  * fact that every Octeon board receives a unique board type
144  * enumeration from the bootloader.
145  *
146  * @param ipd_port IPD input port associated with the port we want to get link
147  *                 status for.
148  *
149  * @return The ports link status. If the link isn't fully resolved, this must
150  *         return zero.
151  */
152 extern cvmx_helper_link_info_t __cvmx_helper_board_link_get(int ipd_port);
153
154 /**
155  * @INTERNAL
156  * This function is called by cvmx_helper_interface_probe() after it
157  * determines the number of ports Octeon can support on a specific
158  * interface. This function is the per board location to override
159  * this value. It is called with the number of ports Octeon might
160  * support and should return the number of actual ports on the
161  * board.
162  *
163  * This function must be modified for every new Octeon board.
164  * Internally it uses switch statements based on the cvmx_sysinfo
165  * data to determine board types and revisions. It relies on the
166  * fact that every Octeon board receives a unique board type
167  * enumeration from the bootloader.
168  *
169  * @param interface Interface to probe
170  * @param supported_ports
171  *                  Number of ports Octeon supports.
172  *
173  * @return Number of ports the actual board supports. Many times this will
174  *         simple be "support_ports".
175  */
176 extern int __cvmx_helper_board_interface_probe(int interface, int supported_ports);
177
178 /**
179  * @INTERNAL
180  * Enable packet input/output from the hardware. This function is
181  * called after by cvmx_helper_packet_hardware_enable() to
182  * perform board specific initialization. For most boards
183  * nothing is needed.
184  *
185  * @param interface Interface to enable
186  *
187  * @return Zero on success, negative on failure
188  */
189 extern int __cvmx_helper_board_hardware_enable(int interface);
190
191
192
193
194 /**
195  * @INTERNAL
196  * Gets the clock type used for the USB block based on board type.
197  * Used by the USB code for auto configuration of clock type.
198  *
199  * @return USB clock type enumeration
200  */
201 cvmx_helper_board_usb_clock_types_t __cvmx_helper_board_usb_get_clock_type(void);
202
203
204 /**
205  * @INTERNAL
206  * Adjusts the number of available USB ports on Octeon based on board
207  * specifics.
208  *
209  * @param supported_ports expected number of ports based on chip type;
210  *
211  *
212  * @return number of available usb ports, based on board specifics.
213  *         Return value is supported_ports if function does not
214  *         override.
215  */
216 int __cvmx_helper_board_usb_get_num_ports(int supported_ports);
217
218 #ifdef  __cplusplus
219 }
220 #endif
221
222 #endif  /* __CVMX_HELPER_BOARD_H__ */