Lines Matching +full:spi +full:- +full:mode

7  * Copyright (c) 2003-2008 Cavium Networks
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 * Support library for the SPI
34 #include <asm/octeon/cvmx-config.h>
36 #include <asm/octeon/cvmx-pko.h>
37 #include <asm/octeon/cvmx-spi.h>
39 #include <asm/octeon/cvmx-spxx-defs.h>
40 #include <asm/octeon/cvmx-stxx-defs.h>
41 #include <asm/octeon/cvmx-srxx-defs.h>
92 * Initialize and start the SPI interface.
95 * use as a SPI interface.
96 * @mode: The operating mode for the SPI interface. The interface
101 * @num_ports: Number of SPI ports to configure
105 int cvmx_spi_start_interface(int interface, cvmx_spi_mode_t mode, int timeout, in cvmx_spi_start_interface() argument
108 int res = -1; in cvmx_spi_start_interface()
114 INVOKE_CB(cvmx_spi_callbacks.reset_cb, interface, mode); in cvmx_spi_start_interface()
117 INVOKE_CB(cvmx_spi_callbacks.calendar_setup_cb, interface, mode, in cvmx_spi_start_interface()
121 INVOKE_CB(cvmx_spi_callbacks.clock_detect_cb, interface, mode, timeout); in cvmx_spi_start_interface()
124 INVOKE_CB(cvmx_spi_callbacks.training_cb, interface, mode, timeout); in cvmx_spi_start_interface()
127 INVOKE_CB(cvmx_spi_callbacks.calendar_sync_cb, interface, mode, in cvmx_spi_start_interface()
131 INVOKE_CB(cvmx_spi_callbacks.interface_up_cb, interface, mode); in cvmx_spi_start_interface()
137 * This routine restarts the SPI interface after it has lost synchronization
141 * use as a SPI interface.
142 * @mode: The operating mode for the SPI interface. The interface
150 int cvmx_spi_restart_interface(int interface, cvmx_spi_mode_t mode, int timeout) in cvmx_spi_restart_interface() argument
152 int res = -1; in cvmx_spi_restart_interface()
157 cvmx_dprintf("SPI%d: Restart %s\n", interface, modes[mode]); in cvmx_spi_restart_interface()
160 INVOKE_CB(cvmx_spi_callbacks.reset_cb, interface, mode); in cvmx_spi_restart_interface()
166 INVOKE_CB(cvmx_spi_callbacks.clock_detect_cb, interface, mode, timeout); in cvmx_spi_restart_interface()
169 INVOKE_CB(cvmx_spi_callbacks.training_cb, interface, mode, timeout); in cvmx_spi_restart_interface()
172 INVOKE_CB(cvmx_spi_callbacks.calendar_sync_cb, interface, mode, in cvmx_spi_restart_interface()
176 INVOKE_CB(cvmx_spi_callbacks.interface_up_cb, interface, mode); in cvmx_spi_restart_interface()
186 * use as a SPI interface.
187 * @mode: The operating mode for the SPI interface. The interface
192 * Returns Zero on success, non-zero error code on failure (will cause
193 * SPI initialization to abort)
195 int cvmx_spi_reset_cb(int interface, cvmx_spi_mode_t mode) in cvmx_spi_reset_cb() argument
204 uint64_t MS = cvmx_sysinfo_get()->cpu_clock_hz / 1000; in cvmx_spi_reset_cb()
206 /* Disable SPI error events while we run BIST */ in cvmx_spi_reset_cb()
212 /* Run BIST in the SPI interface */ in cvmx_spi_reset_cb()
222 ("ERROR SPI%d: BIST failed on receive datapath FIFO\n", in cvmx_spi_reset_cb()
225 cvmx_dprintf("ERROR SPI%d: BIST failed on RX calendar table\n", in cvmx_spi_reset_cb()
228 cvmx_dprintf("ERROR SPI%d: BIST failed on TX calendar table\n", in cvmx_spi_reset_cb()
301 * use as a SPI interface.
302 * @mode: The operating mode for the SPI interface. The interface
306 * @num_ports: Number of ports to configure on SPI
308 * Returns Zero on success, non-zero error code on failure (will cause
309 * SPI initialization to abort)
311 int cvmx_spi_calendar_setup_cb(int interface, cvmx_spi_mode_t mode, in cvmx_spi_calendar_setup_cb() argument
316 if (mode & CVMX_SPI_MODE_RX_HALFPLEX) { in cvmx_spi_calendar_setup_cb()
322 srxx_com_ctl.s.prts = num_ports - 1; in cvmx_spi_calendar_setup_cb()
350 if (mode & CVMX_SPI_MODE_TX_HALFPLEX) { in cvmx_spi_calendar_setup_cb()
420 * use as a SPI interface.
421 * @mode: The operating mode for the SPI interface. The interface
427 * Returns Zero on success, non-zero error code on failure (will cause
428 * SPI initialization to abort)
430 int cvmx_spi_clock_detect_cb(int interface, cvmx_spi_mode_t mode, int timeout) in cvmx_spi_clock_detect_cb() argument
435 uint64_t MS = cvmx_sysinfo_get()->cpu_clock_hz / 1000; in cvmx_spi_clock_detect_cb()
438 * Regardless of operating mode, both Tx and Rx clocks must be in cvmx_spi_clock_detect_cb()
439 * present for the SPI interface to operate. in cvmx_spi_clock_detect_cb()
441 cvmx_dprintf("SPI%d: Waiting to see TsClk...\n", interface); in cvmx_spi_clock_detect_cb()
455 clock_transitions--; in cvmx_spi_clock_detect_cb()
461 cvmx_dprintf("SPI%d: Timeout\n", interface); in cvmx_spi_clock_detect_cb()
462 return -1; in cvmx_spi_clock_detect_cb()
466 cvmx_dprintf("SPI%d: Waiting to see RsClk...\n", interface); in cvmx_spi_clock_detect_cb()
480 clock_transitions--; in cvmx_spi_clock_detect_cb()
486 cvmx_dprintf("SPI%d: Timeout\n", interface); in cvmx_spi_clock_detect_cb()
487 return -1; in cvmx_spi_clock_detect_cb()
498 * use as a SPI interface.
499 * @mode: The operating mode for the SPI interface. The interface
505 * Returns Zero on success, non-zero error code on failure (will cause
506 * SPI initialization to abort)
508 int cvmx_spi_training_cb(int interface, cvmx_spi_mode_t mode, int timeout) in cvmx_spi_training_cb() argument
512 uint64_t MS = cvmx_sysinfo_get()->cpu_clock_hz / 1000; in cvmx_spi_training_cb()
516 /* SRX0 & STX0 Inf0 Links are configured - begin training */ in cvmx_spi_training_cb()
538 cvmx_dprintf("SPI%d: Waiting for training\n", interface); in cvmx_spi_training_cb()
550 rx_training_needed--; in cvmx_spi_training_cb()
555 cvmx_dprintf("SPI%d: Timeout\n", interface); in cvmx_spi_training_cb()
556 return -1; in cvmx_spi_training_cb()
567 * use as a SPI interface.
568 * @mode: The operating mode for the SPI interface. The interface
574 * Returns Zero on success, non-zero error code on failure (will cause
575 * SPI initialization to abort)
577 int cvmx_spi_calendar_sync_cb(int interface, cvmx_spi_mode_t mode, int timeout) in cvmx_spi_calendar_sync_cb() argument
579 uint64_t MS = cvmx_sysinfo_get()->cpu_clock_hz / 1000; in cvmx_spi_calendar_sync_cb()
580 if (mode & CVMX_SPI_MODE_RX_HALFPLEX) { in cvmx_spi_calendar_sync_cb()
584 ("SPI%d: Rx is synchronized, start sending calendar data\n", in cvmx_spi_calendar_sync_cb()
592 if (mode & CVMX_SPI_MODE_TX_HALFPLEX) { in cvmx_spi_calendar_sync_cb()
604 cvmx_dprintf("SPI%d: Waiting to sync on STX[%d] STAT\n", in cvmx_spi_calendar_sync_cb()
607 /* SPX0_CLK_STAT - SPX0_CLK_STAT[STXCAL] should be 1 (bit10) */ in cvmx_spi_calendar_sync_cb()
611 cvmx_dprintf("SPI%d: Timeout\n", interface); in cvmx_spi_calendar_sync_cb()
612 return -1; in cvmx_spi_calendar_sync_cb()
624 * use as a SPI interface.
625 * @mode: The operating mode for the SPI interface. The interface
630 * Returns Zero on success, non-zero error code on failure (will cause
631 * SPI initialization to abort)
633 int cvmx_spi_interface_up_cb(int interface, cvmx_spi_mode_t mode) in cvmx_spi_interface_up_cb() argument
639 if (mode & CVMX_SPI_MODE_RX_HALFPLEX) { in cvmx_spi_interface_up_cb()
644 cvmx_dprintf("SPI%d: Rx is now up\n", interface); in cvmx_spi_interface_up_cb()
647 if (mode & CVMX_SPI_MODE_TX_HALFPLEX) { in cvmx_spi_interface_up_cb()
652 cvmx_dprintf("SPI%d: Tx is now up\n", interface); in cvmx_spi_interface_up_cb()
660 gmxx_rxx_frm_max.s.len = 64 * 1024 - 4; in cvmx_spi_interface_up_cb()
664 gmxx_rxx_jabber.s.cnt = 64 * 1024 - 4; in cvmx_spi_interface_up_cb()