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 * This file contains defines for the SPI inte 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-*. 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 init 47 typedef struct { 48 /** Called to reset SPI4 DLL */ 49 int (*reset_cb) (int interface, cvmx_s 50 51 /** Called to setup calendar */ 52 int (*calendar_setup_cb) (int interfac 53 int num_port 54 55 /** Called for Tx and Rx clock detection * 56 int (*clock_detect_cb) (int interface, 57 int timeout); 58 59 /** Called to perform link training */ 60 int (*training_cb) (int interface, cvm 61 62 /** Called for calendar data synchronizati 63 int (*calendar_sync_cb) (int interface 64 int timeout); 65 66 /** Called when interface is up */ 67 int (*interface_up_cb) (int interface, 68 69 } cvmx_spi_callbacks_t; 70 71 /** 72 * Return true if the supplied interface is co 73 * 74 * @interface: Interface to check 75 * Returns True if interface is SPI 76 */ 77 static inline int cvmx_spi_is_spi_interface(in 78 { 79 uint64_t gmxState = cvmx_read_csr(CVMX 80 return (gmxState & 0x2) && (gmxState & 81 } 82 83 /** 84 * Initialize and start the SPI interface. 85 * 86 * @interface: The identifier of the packet in 87 * use as a SPI interface. 88 * @mode: The operating mode for the SPI 89 * can operate as a full dupl 90 * active) or as a halfplex ( 91 * active or the Rx data path 92 * @timeout: Timeout to wait for clock synch 93 * @num_ports: Number of SPI ports to configur 94 * 95 * Returns Zero on success, negative of failur 96 */ 97 extern int cvmx_spi_start_interface(int interf 98 int timeou 99 100 /** 101 * This routine restarts the SPI interface aft 102 * with its corespondant system. 103 * 104 * @interface: The identifier of the packet in 105 * use as a SPI interface. 106 * @mode: The operating mode for the SPI 107 * can operate as a full dupl 108 * active) or as a halfplex ( 109 * active or the Rx data path 110 * @timeout: Timeout to wait for clock synch 111 * Returns Zero on success, negative of failur 112 */ 113 extern int cvmx_spi_restart_interface(int inte 114 int time 115 116 /** 117 * Return non-zero if the SPI interface has a 118 * 119 * @interface: SPI interface the SPI4000 is co 120 * 121 * Returns 122 */ 123 static inline int cvmx_spi4000_is_present(int 124 { 125 return 0; 126 } 127 128 /** 129 * Initialize the SPI4000 for use 130 * 131 * @interface: SPI interface the SPI4000 is co 132 */ 133 static inline int cvmx_spi4000_initialize(int 134 { 135 return 0; 136 } 137 138 /** 139 * Poll all the SPI4000 port and check its spe 140 * 141 * @interface: Interface the SPI4000 is on 142 * @port: Port to poll (0-9) 143 * Returns Status of the port. 0=down. All oth 144 */ 145 static inline union cvmx_gmxx_rxx_rx_inbnd cvm 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 struc 158 * 159 * Returns Pointer to cvmx_spi_callbacks_t str 160 */ 161 extern void cvmx_spi_get_callbacks(cvmx_spi_ca 162 163 /** 164 * Set new SPI4 initialization callbacks 165 * 166 * @new_callbacks: Pointer to an updated call 167 */ 168 extern void cvmx_spi_set_callbacks(cvmx_spi_ca 169 170 /** 171 * Callback to perform SPI4 reset 172 * 173 * @interface: The identifier of the packet in 174 * use as a SPI interface. 175 * @mode: The operating mode for the SPI 176 * can operate as a full dupl 177 * active) or as a halfplex ( 178 * active or the Rx data path 179 * 180 * Returns Zero on success, non-zero error cod 181 * SPI initialization to abort) 182 */ 183 extern int cvmx_spi_reset_cb(int interface, cv 184 185 /** 186 * Callback to setup calendar and miscellaneou 187 * detection 188 * 189 * @interface: The identifier of the packet in 190 * use as a SPI interface. 191 * @mode: The operating mode for the SPI 192 * can operate as a full dupl 193 * active) or as a halfplex ( 194 * active or the Rx data path 195 * @num_ports: Number of ports to configure on 196 * 197 * Returns Zero on success, non-zero error cod 198 * SPI initialization to abort) 199 */ 200 extern int cvmx_spi_calendar_setup_cb(int inte 201 int num_ 202 203 /** 204 * Callback to perform clock detection 205 * 206 * @interface: The identifier of the packet in 207 * use as a SPI interface. 208 * @mode: The operating mode for the SPI 209 * can operate as a full dupl 210 * active) or as a halfplex ( 211 * active or the Rx data path 212 * @timeout: Timeout to wait for clock synch 213 * 214 * Returns Zero on success, non-zero error cod 215 * SPI initialization to abort) 216 */ 217 extern int cvmx_spi_clock_detect_cb(int interf 218 int timeou 219 220 /** 221 * Callback to perform link training 222 * 223 * @interface: The identifier of the packet in 224 * use as a SPI interface. 225 * @mode: The operating mode for the SPI 226 * can operate as a full dupl 227 * active) or as a halfplex ( 228 * active or the Rx data path 229 * @timeout: Timeout to wait for link to be 230 * 231 * Returns Zero on success, non-zero error cod 232 * SPI initialization to abort) 233 */ 234 extern int cvmx_spi_training_cb(int interface, 235 int timeout); 236 237 /** 238 * Callback to perform calendar data synchroni 239 * 240 * @interface: The identifier of the packet in 241 * use as a SPI interface. 242 * @mode: The operating mode for the SPI 243 * can operate as a full dupl 244 * active) or as a halfplex ( 245 * active or the Rx data path 246 * @timeout: Timeout to wait for calendar da 247 * 248 * Returns Zero on success, non-zero error cod 249 * SPI initialization to abort) 250 */ 251 extern int cvmx_spi_calendar_sync_cb(int inter 252 int timeo 253 254 /** 255 * Callback to handle interface up 256 * 257 * @interface: The identifier of the packet in 258 * use as a SPI interface. 259 * @mode: The operating mode for the SPI 260 * can operate as a full dupl 261 * active) or as a halfplex ( 262 * active or the Rx data path 263 * 264 * Returns Zero on success, non-zero error cod 265 * SPI initialization to abort) 266 */ 267 extern int cvmx_spi_interface_up_cb(int interf 268 269 #endif /* __CVMX_SPI_H__ */ 270
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.