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

TOMOYO Linux Cross Reference
Linux/arch/mips/cavium-octeon/executive/cvmx-helper-spi.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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

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


  1 /***********************license start*********      1 /***********************license start***************
  2  * Author: Cavium Networks                          2  * Author: Cavium Networks
  3  *                                                  3  *
  4  * Contact: support@caviumnetworks.com              4  * Contact: support@caviumnetworks.com
  5  * This file is part of the OCTEON SDK              5  * This file is part of the OCTEON SDK
  6  *                                                  6  *
  7  * Copyright (C) 2003-2018 Cavium, Inc.             7  * Copyright (C) 2003-2018 Cavium, Inc.
  8  *                                                  8  *
  9  * This file is free software; you can redistr      9  * This file is free software; you can redistribute it and/or modify
 10  * it under the terms of the GNU General Publi     10  * it under the terms of the GNU General Public License, Version 2, as
 11  * published by the Free Software Foundation.      11  * published by the Free Software Foundation.
 12  *                                                 12  *
 13  * This file is distributed in the hope that i     13  * This file is distributed in the hope that it will be useful, but
 14  * AS-IS and WITHOUT ANY WARRANTY; without eve     14  * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
 15  * of MERCHANTABILITY or FITNESS FOR A PARTICU     15  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
 16  * NONINFRINGEMENT.  See the GNU General Publi     16  * NONINFRINGEMENT.  See the GNU General Public License for more
 17  * details.                                        17  * details.
 18  *                                                 18  *
 19  * You should have received a copy of the GNU      19  * You should have received a copy of the GNU General Public License
 20  * along with this file; if not, write to the      20  * along with this file; if not, write to the Free Software
 21  * Foundation, Inc., 51 Franklin St, Fifth Flo     21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 22  * or visit http://www.gnu.org/licenses/.          22  * or visit http://www.gnu.org/licenses/.
 23  *                                                 23  *
 24  * This file may also be available under a dif     24  * This file may also be available under a different license from Cavium.
 25  * Contact Cavium Networks for more informatio     25  * Contact Cavium Networks for more information
 26  ***********************license end***********     26  ***********************license end**************************************/
 27                                                    27 
 28 /*                                                 28 /*
 29  * Functions for SPI initialization, configura     29  * Functions for SPI initialization, configuration,
 30  * and monitoring.                                 30  * and monitoring.
 31  */                                                31  */
 32 #include <asm/octeon/octeon.h>                     32 #include <asm/octeon/octeon.h>
 33                                                    33 
 34 #include <asm/octeon/cvmx-config.h>                34 #include <asm/octeon/cvmx-config.h>
 35 #include <asm/octeon/cvmx-spi.h>                   35 #include <asm/octeon/cvmx-spi.h>
 36 #include <asm/octeon/cvmx-helper.h>                36 #include <asm/octeon/cvmx-helper.h>
 37                                                    37 
 38 #include <asm/octeon/cvmx-pip-defs.h>              38 #include <asm/octeon/cvmx-pip-defs.h>
 39 #include <asm/octeon/cvmx-pko-defs.h>              39 #include <asm/octeon/cvmx-pko-defs.h>
 40 #include <asm/octeon/cvmx-spxx-defs.h>             40 #include <asm/octeon/cvmx-spxx-defs.h>
 41 #include <asm/octeon/cvmx-stxx-defs.h>             41 #include <asm/octeon/cvmx-stxx-defs.h>
 42                                                    42 
 43 /*                                                 43 /*
 44  * CVMX_HELPER_SPI_TIMEOUT is used to determin     44  * CVMX_HELPER_SPI_TIMEOUT is used to determine how long the SPI
 45  * initialization routines wait for SPI traini     45  * initialization routines wait for SPI training. You can override the
 46  * value using executive-config.h if necessary     46  * value using executive-config.h if necessary.
 47  */                                                47  */
 48 #ifndef CVMX_HELPER_SPI_TIMEOUT                    48 #ifndef CVMX_HELPER_SPI_TIMEOUT
 49 #define CVMX_HELPER_SPI_TIMEOUT 10                 49 #define CVMX_HELPER_SPI_TIMEOUT 10
 50 #endif                                             50 #endif
 51                                                    51 
 52 int __cvmx_helper_spi_enumerate(int interface)     52 int __cvmx_helper_spi_enumerate(int interface)
 53 {                                                  53 {
 54         if ((cvmx_sysinfo_get()->board_type !=     54         if ((cvmx_sysinfo_get()->board_type != CVMX_BOARD_TYPE_SIM) &&
 55             cvmx_spi4000_is_present(interface)     55             cvmx_spi4000_is_present(interface)) {
 56                 return 10;                         56                 return 10;
 57         } else {                                   57         } else {
 58                 return 16;                         58                 return 16;
 59         }                                          59         }
 60 }                                                  60 }
 61                                                    61 
 62 /**                                                62 /**
 63  * Probe a SPI interface and determine the num     63  * Probe a SPI interface and determine the number of ports
 64  * connected to it. The SPI interface should s     64  * connected to it. The SPI interface should still be down after
 65  * this call.                                      65  * this call.
 66  *                                                 66  *
 67  * @interface: Interface to probe                  67  * @interface: Interface to probe
 68  *                                                 68  *
 69  * Returns Number of ports on the interface. Z     69  * Returns Number of ports on the interface. Zero to disable.
 70  */                                                70  */
 71 int __cvmx_helper_spi_probe(int interface)         71 int __cvmx_helper_spi_probe(int interface)
 72 {                                                  72 {
 73         int num_ports = 0;                         73         int num_ports = 0;
 74                                                    74 
 75         if ((cvmx_sysinfo_get()->board_type !=     75         if ((cvmx_sysinfo_get()->board_type != CVMX_BOARD_TYPE_SIM) &&
 76             cvmx_spi4000_is_present(interface)     76             cvmx_spi4000_is_present(interface)) {
 77                 num_ports = 10;                    77                 num_ports = 10;
 78         } else {                                   78         } else {
 79                 union cvmx_pko_reg_crc_enable      79                 union cvmx_pko_reg_crc_enable enable;
 80                 num_ports = 16;                    80                 num_ports = 16;
 81                 /*                                 81                 /*
 82                  * Unlike the SPI4000, most SP     82                  * Unlike the SPI4000, most SPI devices don't
 83                  * automatically put on the L2     83                  * automatically put on the L2 CRC. For everything
 84                  * except for the SPI4000 have     84                  * except for the SPI4000 have PKO append the L2 CRC
 85                  * to the packet.                  85                  * to the packet.
 86                  */                                86                  */
 87                 enable.u64 = cvmx_read_csr(CVM     87                 enable.u64 = cvmx_read_csr(CVMX_PKO_REG_CRC_ENABLE);
 88                 enable.s.enable |= 0xffff << (     88                 enable.s.enable |= 0xffff << (interface * 16);
 89                 cvmx_write_csr(CVMX_PKO_REG_CR     89                 cvmx_write_csr(CVMX_PKO_REG_CRC_ENABLE, enable.u64);
 90         }                                          90         }
 91         __cvmx_helper_setup_gmx(interface, num     91         __cvmx_helper_setup_gmx(interface, num_ports);
 92         return num_ports;                          92         return num_ports;
 93 }                                                  93 }
 94                                                    94 
 95 /**                                                95 /**
 96  * Bringup and enable a SPI interface. After t     96  * Bringup and enable a SPI interface. After this call packet I/O
 97  * should be fully functional. This is called      97  * should be fully functional. This is called with IPD enabled but
 98  * PKO disabled.                                   98  * PKO disabled.
 99  *                                                 99  *
100  * @interface: Interface to bring up              100  * @interface: Interface to bring up
101  *                                                101  *
102  * Returns Zero on success, negative on failur    102  * Returns Zero on success, negative on failure
103  */                                               103  */
104 int __cvmx_helper_spi_enable(int interface)       104 int __cvmx_helper_spi_enable(int interface)
105 {                                                 105 {
106         /*                                        106         /*
107          * Normally the ethernet L2 CRC is che    107          * Normally the ethernet L2 CRC is checked and stripped in the
108          * GMX block.  When you are using SPI,    108          * GMX block.  When you are using SPI, this isn' the case and
109          * IPD needs to check the L2 CRC.         109          * IPD needs to check the L2 CRC.
110          */                                       110          */
111         int num_ports = cvmx_helper_ports_on_i    111         int num_ports = cvmx_helper_ports_on_interface(interface);
112         int ipd_port;                             112         int ipd_port;
113         for (ipd_port = interface * 16; ipd_po    113         for (ipd_port = interface * 16; ipd_port < interface * 16 + num_ports;
114              ipd_port++) {                        114              ipd_port++) {
115                 union cvmx_pip_prt_cfgx port_c    115                 union cvmx_pip_prt_cfgx port_config;
116                 port_config.u64 = cvmx_read_cs    116                 port_config.u64 = cvmx_read_csr(CVMX_PIP_PRT_CFGX(ipd_port));
117                 port_config.s.crc_en = 1;         117                 port_config.s.crc_en = 1;
118                 cvmx_write_csr(CVMX_PIP_PRT_CF    118                 cvmx_write_csr(CVMX_PIP_PRT_CFGX(ipd_port), port_config.u64);
119         }                                         119         }
120                                                   120 
121         if (cvmx_sysinfo_get()->board_type !=     121         if (cvmx_sysinfo_get()->board_type != CVMX_BOARD_TYPE_SIM) {
122                 cvmx_spi_start_interface(inter    122                 cvmx_spi_start_interface(interface, CVMX_SPI_MODE_DUPLEX,
123                                          CVMX_    123                                          CVMX_HELPER_SPI_TIMEOUT, num_ports);
124                 if (cvmx_spi4000_is_present(in    124                 if (cvmx_spi4000_is_present(interface))
125                         cvmx_spi4000_initializ    125                         cvmx_spi4000_initialize(interface);
126         }                                         126         }
127         __cvmx_interrupt_spxx_int_msk_enable(i    127         __cvmx_interrupt_spxx_int_msk_enable(interface);
128         __cvmx_interrupt_stxx_int_msk_enable(i    128         __cvmx_interrupt_stxx_int_msk_enable(interface);
129         __cvmx_interrupt_gmxx_enable(interface    129         __cvmx_interrupt_gmxx_enable(interface);
130         return 0;                                 130         return 0;
131 }                                                 131 }
132                                                   132 
133 /**                                               133 /**
134  * Return the link state of an IPD/PKO port as    134  * Return the link state of an IPD/PKO port as returned by
135  * auto negotiation. The result of this functi    135  * auto negotiation. The result of this function may not match
136  * Octeon's link config if auto negotiation ha    136  * Octeon's link config if auto negotiation has changed since
137  * the last call to cvmx_helper_link_set().       137  * the last call to cvmx_helper_link_set().
138  *                                                138  *
139  * @ipd_port: IPD/PKO port to query               139  * @ipd_port: IPD/PKO port to query
140  *                                                140  *
141  * Returns Link state                             141  * Returns Link state
142  */                                               142  */
143 union cvmx_helper_link_info __cvmx_helper_spi_    143 union cvmx_helper_link_info __cvmx_helper_spi_link_get(int ipd_port)
144 {                                                 144 {
145         union cvmx_helper_link_info result;       145         union cvmx_helper_link_info result;
146         int interface = cvmx_helper_get_interf    146         int interface = cvmx_helper_get_interface_num(ipd_port);
147         int index = cvmx_helper_get_interface_    147         int index = cvmx_helper_get_interface_index_num(ipd_port);
148         result.u64 = 0;                           148         result.u64 = 0;
149                                                   149 
150         if (cvmx_sysinfo_get()->board_type ==     150         if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_SIM) {
151                 /* The simulator gives you a s    151                 /* The simulator gives you a simulated full duplex link */
152                 result.s.link_up = 1;             152                 result.s.link_up = 1;
153                 result.s.full_duplex = 1;         153                 result.s.full_duplex = 1;
154                 result.s.speed = 10000;           154                 result.s.speed = 10000;
155         } else if (cvmx_spi4000_is_present(int    155         } else if (cvmx_spi4000_is_present(interface)) {
156                 union cvmx_gmxx_rxx_rx_inbnd i    156                 union cvmx_gmxx_rxx_rx_inbnd inband =
157                     cvmx_spi4000_check_speed(i    157                     cvmx_spi4000_check_speed(interface, index);
158                 result.s.link_up = inband.s.st    158                 result.s.link_up = inband.s.status;
159                 result.s.full_duplex = inband.    159                 result.s.full_duplex = inband.s.duplex;
160                 switch (inband.s.speed) {         160                 switch (inband.s.speed) {
161                 case 0: /* 10 Mbps */             161                 case 0: /* 10 Mbps */
162                         result.s.speed = 10;      162                         result.s.speed = 10;
163                         break;                    163                         break;
164                 case 1: /* 100 Mbps */            164                 case 1: /* 100 Mbps */
165                         result.s.speed = 100;     165                         result.s.speed = 100;
166                         break;                    166                         break;
167                 case 2: /* 1 Gbps */              167                 case 2: /* 1 Gbps */
168                         result.s.speed = 1000;    168                         result.s.speed = 1000;
169                         break;                    169                         break;
170                 case 3: /* Illegal */             170                 case 3: /* Illegal */
171                         result.s.speed = 0;       171                         result.s.speed = 0;
172                         result.s.link_up = 0;     172                         result.s.link_up = 0;
173                         break;                    173                         break;
174                 }                                 174                 }
175         } else {                                  175         } else {
176                 /* For generic SPI we can't de    176                 /* For generic SPI we can't determine the link, just return some
177                    sane results */                177                    sane results */
178                 result.s.link_up = 1;             178                 result.s.link_up = 1;
179                 result.s.full_duplex = 1;         179                 result.s.full_duplex = 1;
180                 result.s.speed = 10000;           180                 result.s.speed = 10000;
181         }                                         181         }
182         return result;                            182         return result;
183 }                                                 183 }
184                                                   184 
185 /**                                               185 /**
186  * Configure an IPD/PKO port for the specified    186  * Configure an IPD/PKO port for the specified link state. This
187  * function does not influence auto negotiatio    187  * function does not influence auto negotiation at the PHY level.
188  * The passed link state must always match the    188  * The passed link state must always match the link state returned
189  * by cvmx_helper_link_get().                     189  * by cvmx_helper_link_get().
190  *                                                190  *
191  * @ipd_port:  IPD/PKO port to configure          191  * @ipd_port:  IPD/PKO port to configure
192  * @link_info: The new link state                 192  * @link_info: The new link state
193  *                                                193  *
194  * Returns Zero on success, negative on failur    194  * Returns Zero on success, negative on failure
195  */                                               195  */
196 int __cvmx_helper_spi_link_set(int ipd_port, u    196 int __cvmx_helper_spi_link_set(int ipd_port, union cvmx_helper_link_info link_info)
197 {                                                 197 {
198         /* Nothing to do. If we have a SPI4000    198         /* Nothing to do. If we have a SPI4000 then the setup was already performed
199            by cvmx_spi4000_check_speed(). If n    199            by cvmx_spi4000_check_speed(). If not then there isn't any link
200            info */                                200            info */
201         return 0;                                 201         return 0;
202 }                                                 202 }
203                                                   203 

~ [ 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