~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/cavium-octeon/executive/cvmx-helper-board.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/mips/cavium-octeon/executive/cvmx-helper-board.c (Architecture m68k) and /arch/sparc/cavium-octeon/executive/cvmx-helper-board.c (Architecture sparc)


  1 /***********************license start*********      1 
  2  * Author: Cavium Networks                        
  3  *                                                
  4  * Contact: support@caviumnetworks.com            
  5  * This file is part of the OCTEON SDK            
  6  *                                                
  7  * Copyright (c) 2003-2008 Cavium Networks        
  8  *                                                
  9  * This file is free software; you can redistr    
 10  * it under the terms of the GNU General Publi    
 11  * published by the Free Software Foundation.     
 12  *                                                
 13  * This file is distributed in the hope that i    
 14  * AS-IS and WITHOUT ANY WARRANTY; without eve    
 15  * of MERCHANTABILITY or FITNESS FOR A PARTICU    
 16  * NONINFRINGEMENT.  See the GNU General Publi    
 17  * details.                                       
 18  *                                                
 19  * You should have received a copy of the GNU     
 20  * along with this file; if not, write to the     
 21  * Foundation, Inc., 51 Franklin St, Fifth Flo    
 22  * or visit http://www.gnu.org/licenses/.         
 23  *                                                
 24  * This file may also be available under a dif    
 25  * Contact Cavium Networks for more informatio    
 26  ***********************license end***********    
 27                                                   
 28 /*                                                
 29  *                                                
 30  * Helper functions to abstract board specific    
 31  * network ports from the rest of the cvmx-hel    
 32  */                                               
 33                                                   
 34 #include <linux/bug.h>                            
 35 #include <asm/octeon/octeon.h>                    
 36 #include <asm/octeon/cvmx-bootinfo.h>             
 37                                                   
 38 #include <asm/octeon/cvmx-config.h>               
 39                                                   
 40 #include <asm/octeon/cvmx-helper.h>               
 41 #include <asm/octeon/cvmx-helper-util.h>          
 42 #include <asm/octeon/cvmx-helper-board.h>         
 43                                                   
 44 #include <asm/octeon/cvmx-gmxx-defs.h>            
 45 #include <asm/octeon/cvmx-asxx-defs.h>            
 46                                                   
 47 /*                                                
 48  * Return the MII PHY address associated with     
 49  * port. A result of -1 means there isn't a MI    
 50  * connected to this port. On chips supporting    
 51  * busses the bus number is encoded in bits <1    
 52  *                                                
 53  * This function must be modified for every ne    
 54  * Internally it uses switch statements based     
 55  * data to determine board types and revisions    
 56  * fact that every Octeon board receives a uni    
 57  * enumeration from the bootloader.               
 58  *                                                
 59  * @ipd_port: Octeon IPD port to get the MII a    
 60  *                                                
 61  * Returns MII PHY address and bus number or -    
 62  */                                               
 63 int cvmx_helper_board_get_mii_address(int ipd_    
 64 {                                                 
 65         switch (cvmx_sysinfo_get()->board_type    
 66         case CVMX_BOARD_TYPE_SIM:                 
 67                 /* Simulator doesn't have MII     
 68                 return -1;                        
 69         case CVMX_BOARD_TYPE_EBT3000:             
 70         case CVMX_BOARD_TYPE_EBT5800:             
 71         case CVMX_BOARD_TYPE_THUNDER:             
 72         case CVMX_BOARD_TYPE_NICPRO2:             
 73                 /* Interface 0 is SPI4, interf    
 74                 if ((ipd_port >= 16) && (ipd_p    
 75                         return ipd_port - 16;     
 76                 else                              
 77                         return -1;                
 78         case CVMX_BOARD_TYPE_KODAMA:              
 79         case CVMX_BOARD_TYPE_EBH3100:             
 80         case CVMX_BOARD_TYPE_HIKARI:              
 81         case CVMX_BOARD_TYPE_CN3010_EVB_HS5:      
 82         case CVMX_BOARD_TYPE_CN3005_EVB_HS5:      
 83         case CVMX_BOARD_TYPE_CN3020_EVB_HS5:      
 84                 /*                                
 85                  * Port 0 is WAN connected to     
 86                  * connected to a switch          
 87                  */                               
 88                 if (ipd_port == 0)                
 89                         return 4;                 
 90                 else if (ipd_port == 1)           
 91                         return 9;                 
 92                 else                              
 93                         return -1;                
 94         case CVMX_BOARD_TYPE_NAC38:               
 95                 /* Board has 8 RGMII ports PHY    
 96                 if ((ipd_port >= 0) && (ipd_po    
 97                         return ipd_port;          
 98                 else if ((ipd_port >= 16) && (    
 99                         return ipd_port - 16 +    
100                 else                              
101                         return -1;                
102         case CVMX_BOARD_TYPE_EBH3000:             
103                 /* Board has dual SPI4 and no     
104                 return -1;                        
105         case CVMX_BOARD_TYPE_EBH5200:             
106         case CVMX_BOARD_TYPE_EBH5201:             
107         case CVMX_BOARD_TYPE_EBT5200:             
108                 /* Board has 2 management port    
109                 if ((ipd_port >= CVMX_HELPER_B    
110                     (ipd_port < (CVMX_HELPER_B    
111                         return ipd_port - CVMX    
112                 /*                                
113                  * Board has 4 SGMII ports. Th    
114                  * ports MII0 = 0, MII1 = 1, S    
115                  */                               
116                 if ((ipd_port >= 0) && (ipd_po    
117                         return ipd_port + 2;      
118                 else                              
119                         return -1;                
120         case CVMX_BOARD_TYPE_EBH5600:             
121         case CVMX_BOARD_TYPE_EBH5601:             
122         case CVMX_BOARD_TYPE_EBH5610:             
123                 /* Board has 1 management port    
124                 if (ipd_port == CVMX_HELPER_BO    
125                         return 0;                 
126                 /*                                
127                  * Board has 8 SGMII ports. 4     
128                  * to a switch, and 2 loop to     
129                  */                               
130                 if ((ipd_port >= 0) && (ipd_po    
131                         return ipd_port + 1;      
132                 else                              
133                         return -1;                
134         case CVMX_BOARD_TYPE_CUST_NB5:            
135                 if (ipd_port == 2)                
136                         return 4;                 
137                 else                              
138                         return -1;                
139         case CVMX_BOARD_TYPE_NIC_XLE_4G:          
140                 /* Board has 4 SGMII ports. co    
141                 if ((ipd_port >= 16) && (ipd_p    
142                         return ipd_port - 16 +    
143                 else                              
144                         return -1;                
145         case CVMX_BOARD_TYPE_NIC_XLE_10G:         
146         case CVMX_BOARD_TYPE_NIC10E:              
147                 return -1;                        
148         case CVMX_BOARD_TYPE_NIC4E:               
149                 if (ipd_port >= 0 && ipd_port     
150                         return (ipd_port + 0x1    
151                 else                              
152                         return -1;                
153         case CVMX_BOARD_TYPE_NIC2E:               
154                 if (ipd_port >= 0 && ipd_port     
155                         return ipd_port + 1;      
156                 else                              
157                         return -1;                
158         case CVMX_BOARD_TYPE_BBGW_REF:            
159                 /*                                
160                  * No PHYs are connected to Oc    
161                  * through switch.                
162                  */                               
163                 return -1;                        
164                                                   
165         case CVMX_BOARD_TYPE_CUST_WSX16:          
166                 if (ipd_port >= 0 && ipd_port     
167                         return ipd_port;          
168                 else if (ipd_port >= 16 && ipd    
169                         return ipd_port - 16 +    
170                 else                              
171                         return -1;                
172         case CVMX_BOARD_TYPE_UBNT_E100:           
173                 if (ipd_port >= 0 && ipd_port     
174                         return 7 - ipd_port;      
175                 else                              
176                         return -1;                
177         case CVMX_BOARD_TYPE_KONTRON_S1901:       
178                 if (ipd_port == CVMX_HELPER_BO    
179                         return 1;                 
180                 else                              
181                         return -1;                
182                                                   
183         }                                         
184                                                   
185         /* Some unknown board. Somebody forgot    
186         cvmx_dprintf                              
187             ("cvmx_helper_board_get_mii_addres    
188              cvmx_sysinfo_get()->board_type);     
189         return -1;                                
190 }                                                 
191                                                   
192 /*                                                
193  * This function is the board specific method     
194  * ethernet ports link speed. Most Octeon boar    
195  * and are handled by the fall through case. T    
196  * updated for boards that don't have the norm    
197  *                                                
198  * This function must be modified for every ne    
199  * Internally it uses switch statements based     
200  * data to determine board types and revisions    
201  * fact that every Octeon board receives a uni    
202  * enumeration from the bootloader.               
203  *                                                
204  * @ipd_port: IPD input port associated with t    
205  *                 status for.                    
206  *                                                
207  * Returns The ports link status. If the link     
208  *         return zero.                           
209  */                                               
210 union cvmx_helper_link_info __cvmx_helper_boar    
211 {                                                 
212         union cvmx_helper_link_info result;       
213                                                   
214         WARN_ONCE(!octeon_is_simulation(),        
215              "Using deprecated link status - p    
216                                                   
217         /* Unless we fix it later, all links a    
218         result.u64 = 0;                           
219                                                   
220         if (octeon_is_simulation()) {             
221                 /* The simulator gives you a s    
222                 result.s.link_up = 1;             
223                 result.s.full_duplex = 1;         
224                 result.s.speed = 1000;            
225                 return result;                    
226         }                                         
227                                                   
228         if (OCTEON_IS_MODEL(OCTEON_CN3XXX)        
229                    || OCTEON_IS_MODEL(OCTEON_C    
230                    || OCTEON_IS_MODEL(OCTEON_C    
231                 /*                                
232                  * We don't have a PHY address    
233                  * in-band status. It is reall    
234                  * not supporting in-band stat    
235                  * here. Reading broken in-ban    
236                  * things                         
237                  */                               
238                 union cvmx_gmxx_rxx_rx_inbnd i    
239                 int interface = cvmx_helper_ge    
240                 int index = cvmx_helper_get_in    
241                 inband_status.u64 =               
242                     cvmx_read_csr(CVMX_GMXX_RX    
243                                                   
244                 result.s.link_up = inband_stat    
245                 result.s.full_duplex = inband_    
246                 switch (inband_status.s.speed)    
247                 case 0: /* 10 Mbps */             
248                         result.s.speed = 10;      
249                         break;                    
250                 case 1: /* 100 Mbps */            
251                         result.s.speed = 100;     
252                         break;                    
253                 case 2: /* 1 Gbps */              
254                         result.s.speed = 1000;    
255                         break;                    
256                 case 3: /* Illegal */             
257                         result.u64 = 0;           
258                         break;                    
259                 }                                 
260         } else {                                  
261                 /*                                
262                  * We don't have a PHY address    
263                  * in-band status. There is no    
264                  * link speed. Return down ass    
265                  * wired                          
266                  */                               
267                 result.u64 = 0;                   
268         }                                         
269                                                   
270         /* If link is down, return all fields     
271         if (!result.s.link_up)                    
272                 result.u64 = 0;                   
273                                                   
274         return result;                            
275 }                                                 
276                                                   
277 /*                                                
278  * This function is called by cvmx_helper_inte    
279  * determines the number of ports Octeon can s    
280  * interface. This function is the per board l    
281  * this value. It is called with the number of    
282  * support and should return the number of act    
283  * board.                                         
284  *                                                
285  * This function must be modified for every ne    
286  * Internally it uses switch statements based     
287  * data to determine board types and revisions    
288  * fact that every Octeon board receives a uni    
289  * enumeration from the bootloader.               
290  *                                                
291  * @interface: Interface to probe                 
292  * @supported_ports:                              
293  *                  Number of ports Octeon sup    
294  *                                                
295  * Returns Number of ports the actual board su    
296  *         simple be "support_ports".             
297  */                                               
298 int __cvmx_helper_board_interface_probe(int in    
299 {                                                 
300         switch (cvmx_sysinfo_get()->board_type    
301         case CVMX_BOARD_TYPE_CN3005_EVB_HS5:      
302                 if (interface == 0)               
303                         return 2;                 
304                 break;                            
305         case CVMX_BOARD_TYPE_BBGW_REF:            
306                 if (interface == 0)               
307                         return 2;                 
308                 break;                            
309         case CVMX_BOARD_TYPE_NIC_XLE_4G:          
310                 if (interface == 0)               
311                         return 0;                 
312                 break;                            
313                 /* The 2nd interface on the EB    
314                    which we don't support. Dis    
315         case CVMX_BOARD_TYPE_EBH5600:             
316                 if (interface == 1)               
317                         return 0;                 
318                 break;                            
319         }                                         
320         return supported_ports;                   
321 }                                                 
322                                                   
323 /*                                                
324  * Get the clock type used for the USB block b    
325  * Used by the USB code for auto configuration    
326  *                                                
327  * Return USB clock type enumeration              
328  */                                               
329 enum cvmx_helper_board_usb_clock_types __cvmx_    
330 {                                                 
331         switch (cvmx_sysinfo_get()->board_type    
332         case CVMX_BOARD_TYPE_BBGW_REF:            
333         case CVMX_BOARD_TYPE_LANAI2_A:            
334         case CVMX_BOARD_TYPE_LANAI2_U:            
335         case CVMX_BOARD_TYPE_LANAI2_G:            
336         case CVMX_BOARD_TYPE_NIC10E_66:           
337         case CVMX_BOARD_TYPE_UBNT_E100:           
338                 return USB_CLOCK_TYPE_CRYSTAL_    
339         case CVMX_BOARD_TYPE_NIC10E:              
340                 return USB_CLOCK_TYPE_REF_12;     
341         default:                                  
342                 break;                            
343         }                                         
344         /* Most boards except NIC10e use a 12M    
345         if (OCTEON_IS_OCTEON2())                  
346                 return USB_CLOCK_TYPE_CRYSTAL_    
347         return USB_CLOCK_TYPE_REF_48;             
348 }                                                 
349                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php