root/arch/mips/include/asm/octeon/cvmx-spi.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. cvmx_spi_is_spi_interface
  2. cvmx_spi4000_is_present
  3. cvmx_spi4000_initialize
  4. cvmx_spi4000_check_speed

   1 /***********************license start***************
   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 redistribute it and/or modify
  10  * it under the terms of the GNU General Public License, Version 2, as
  11  * published by the Free Software Foundation.
  12  *
  13  * This file is distributed in the hope that it will be useful, but
  14  * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16  * NONINFRINGEMENT.  See the GNU General Public License for more
  17  * details.
  18  *
  19  * You should have received a copy of the GNU General Public License
  20  * along with this file; if not, write to the Free Software
  21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22  * or visit http://www.gnu.org/licenses/.
  23  *
  24  * This file may also be available under a different license from Cavium.
  25  * Contact Cavium Networks for more information
  26  ***********************license end**************************************/
  27 
  28 /*
  29  *
  30  * This file contains defines for the SPI interface
  31  */
  32 #ifndef __CVMX_SPI_H__
  33 #define __CVMX_SPI_H__
  34 
  35 #include <asm/octeon/cvmx-gmxx-defs.h>
  36 
  37 /* CSR typedefs have been moved to cvmx-csr-*.h */
  38 
  39 typedef enum {
  40         CVMX_SPI_MODE_UNKNOWN = 0,
  41         CVMX_SPI_MODE_TX_HALFPLEX = 1,
  42         CVMX_SPI_MODE_RX_HALFPLEX = 2,
  43         CVMX_SPI_MODE_DUPLEX = 3
  44 } cvmx_spi_mode_t;
  45 
  46 /** Callbacks structure to customize SPI4 initialization sequence */
  47 typedef struct {
  48     /** Called to reset SPI4 DLL */
  49         int (*reset_cb) (int interface, cvmx_spi_mode_t mode);
  50 
  51     /** Called to setup calendar */
  52         int (*calendar_setup_cb) (int interface, cvmx_spi_mode_t mode,
  53                                   int num_ports);
  54 
  55     /** Called for Tx and Rx clock detection */
  56         int (*clock_detect_cb) (int interface, cvmx_spi_mode_t mode,
  57                                 int timeout);
  58 
  59     /** Called to perform link training */
  60         int (*training_cb) (int interface, cvmx_spi_mode_t mode, int timeout);
  61 
  62     /** Called for calendar data synchronization */
  63         int (*calendar_sync_cb) (int interface, cvmx_spi_mode_t mode,
  64                                  int timeout);
  65 
  66     /** Called when interface is up */
  67         int (*interface_up_cb) (int interface, cvmx_spi_mode_t mode);
  68 
  69 } cvmx_spi_callbacks_t;
  70 
  71 /**
  72  * Return true if the supplied interface is configured for SPI
  73  *
  74  * @interface: Interface to check
  75  * Returns True if interface is SPI
  76  */
  77 static inline int cvmx_spi_is_spi_interface(int interface)
  78 {
  79         uint64_t gmxState = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface));
  80         return (gmxState & 0x2) && (gmxState & 0x1);
  81 }
  82 
  83 /**
  84  * Initialize and start the SPI interface.
  85  *
  86  * @interface: The identifier of the packet interface to configure and
  87  *                  use as a SPI interface.
  88  * @mode:      The operating mode for the SPI interface. The interface
  89  *                  can operate as a full duplex (both Tx and Rx data paths
  90  *                  active) or as a halfplex (either the Tx data path is
  91  *                  active or the Rx data path is active, but not both).
  92  * @timeout:   Timeout to wait for clock synchronization in seconds
  93  * @num_ports: Number of SPI ports to configure
  94  *
  95  * Returns Zero on success, negative of failure.
  96  */
  97 extern int cvmx_spi_start_interface(int interface, cvmx_spi_mode_t mode,
  98                                     int timeout, int num_ports);
  99 
 100 /**
 101  * This routine restarts the SPI interface after it has lost synchronization
 102  * with its corespondant system.
 103  *
 104  * @interface: The identifier of the packet interface to configure and
 105  *                  use as a SPI interface.
 106  * @mode:      The operating mode for the SPI interface. The interface
 107  *                  can operate as a full duplex (both Tx and Rx data paths
 108  *                  active) or as a halfplex (either the Tx data path is
 109  *                  active or the Rx data path is active, but not both).
 110  * @timeout:   Timeout to wait for clock synchronization in seconds
 111  * Returns Zero on success, negative of failure.
 112  */
 113 extern int cvmx_spi_restart_interface(int interface, cvmx_spi_mode_t mode,
 114                                       int timeout);
 115 
 116 /**
 117  * Return non-zero if the SPI interface has a SPI4000 attached
 118  *
 119  * @interface: SPI interface the SPI4000 is connected to
 120  *
 121  * Returns
 122  */
 123 static inline int cvmx_spi4000_is_present(int interface)
 124 {
 125         return 0;
 126 }
 127 
 128 /**
 129  * Initialize the SPI4000 for use
 130  *
 131  * @interface: SPI interface the SPI4000 is connected to
 132  */
 133 static inline int cvmx_spi4000_initialize(int interface)
 134 {
 135         return 0;
 136 }
 137 
 138 /**
 139  * Poll all the SPI4000 port and check its speed
 140  *
 141  * @interface: Interface the SPI4000 is on
 142  * @port:      Port to poll (0-9)
 143  * Returns Status of the port. 0=down. All other values the port is up.
 144  */
 145 static inline union cvmx_gmxx_rxx_rx_inbnd cvmx_spi4000_check_speed(
 146         int interface,
 147         int port)
 148 {
 149         union cvmx_gmxx_rxx_rx_inbnd r;
 150         r.u64 = 0;
 151         return r;
 152 }
 153 
 154 /**
 155  * Get current SPI4 initialization callbacks
 156  *
 157  * @callbacks:  Pointer to the callbacks structure.to fill
 158  *
 159  * Returns Pointer to cvmx_spi_callbacks_t structure.
 160  */
 161 extern void cvmx_spi_get_callbacks(cvmx_spi_callbacks_t *callbacks);
 162 
 163 /**
 164  * Set new SPI4 initialization callbacks
 165  *
 166  * @new_callbacks:  Pointer to an updated callbacks structure.
 167  */
 168 extern void cvmx_spi_set_callbacks(cvmx_spi_callbacks_t *new_callbacks);
 169 
 170 /**
 171  * Callback to perform SPI4 reset
 172  *
 173  * @interface: The identifier of the packet interface to configure and
 174  *                  use as a SPI interface.
 175  * @mode:      The operating mode for the SPI interface. The interface
 176  *                  can operate as a full duplex (both Tx and Rx data paths
 177  *                  active) or as a halfplex (either the Tx data path is
 178  *                  active or the Rx data path is active, but not both).
 179  *
 180  * Returns Zero on success, non-zero error code on failure (will cause
 181  * SPI initialization to abort)
 182  */
 183 extern int cvmx_spi_reset_cb(int interface, cvmx_spi_mode_t mode);
 184 
 185 /**
 186  * Callback to setup calendar and miscellaneous settings before clock
 187  * detection
 188  *
 189  * @interface: The identifier of the packet interface to configure and
 190  *                  use as a SPI interface.
 191  * @mode:      The operating mode for the SPI interface. The interface
 192  *                  can operate as a full duplex (both Tx and Rx data paths
 193  *                  active) or as a halfplex (either the Tx data path is
 194  *                  active or the Rx data path is active, but not both).
 195  * @num_ports: Number of ports to configure on SPI
 196  *
 197  * Returns Zero on success, non-zero error code on failure (will cause
 198  * SPI initialization to abort)
 199  */
 200 extern int cvmx_spi_calendar_setup_cb(int interface, cvmx_spi_mode_t mode,
 201                                       int num_ports);
 202 
 203 /**
 204  * Callback to perform clock detection
 205  *
 206  * @interface: The identifier of the packet interface to configure and
 207  *                  use as a SPI interface.
 208  * @mode:      The operating mode for the SPI interface. The interface
 209  *                  can operate as a full duplex (both Tx and Rx data paths
 210  *                  active) or as a halfplex (either the Tx data path is
 211  *                  active or the Rx data path is active, but not both).
 212  * @timeout:   Timeout to wait for clock synchronization in seconds
 213  *
 214  * Returns Zero on success, non-zero error code on failure (will cause
 215  * SPI initialization to abort)
 216  */
 217 extern int cvmx_spi_clock_detect_cb(int interface, cvmx_spi_mode_t mode,
 218                                     int timeout);
 219 
 220 /**
 221  * Callback to perform link training
 222  *
 223  * @interface: The identifier of the packet interface to configure and
 224  *                  use as a SPI interface.
 225  * @mode:      The operating mode for the SPI interface. The interface
 226  *                  can operate as a full duplex (both Tx and Rx data paths
 227  *                  active) or as a halfplex (either the Tx data path is
 228  *                  active or the Rx data path is active, but not both).
 229  * @timeout:   Timeout to wait for link to be trained (in seconds)
 230  *
 231  * Returns Zero on success, non-zero error code on failure (will cause
 232  * SPI initialization to abort)
 233  */
 234 extern int cvmx_spi_training_cb(int interface, cvmx_spi_mode_t mode,
 235                                 int timeout);
 236 
 237 /**
 238  * Callback to perform calendar data synchronization
 239  *
 240  * @interface: The identifier of the packet interface to configure and
 241  *                  use as a SPI interface.
 242  * @mode:      The operating mode for the SPI interface. The interface
 243  *                  can operate as a full duplex (both Tx and Rx data paths
 244  *                  active) or as a halfplex (either the Tx data path is
 245  *                  active or the Rx data path is active, but not both).
 246  * @timeout:   Timeout to wait for calendar data in seconds
 247  *
 248  * Returns Zero on success, non-zero error code on failure (will cause
 249  * SPI initialization to abort)
 250  */
 251 extern int cvmx_spi_calendar_sync_cb(int interface, cvmx_spi_mode_t mode,
 252                                      int timeout);
 253 
 254 /**
 255  * Callback to handle interface up
 256  *
 257  * @interface: The identifier of the packet interface to configure and
 258  *                  use as a SPI interface.
 259  * @mode:      The operating mode for the SPI interface. The interface
 260  *                  can operate as a full duplex (both Tx and Rx data paths
 261  *                  active) or as a halfplex (either the Tx data path is
 262  *                  active or the Rx data path is active, but not both).
 263  *
 264  * Returns Zero on success, non-zero error code on failure (will cause
 265  * SPI initialization to abort)
 266  */
 267 extern int cvmx_spi_interface_up_cb(int interface, cvmx_spi_mode_t mode);
 268 
 269 #endif /* __CVMX_SPI_H__ */

/* [<][>][^][v][top][bottom][index][help] */