ACPI: thinkpad-acpi: add development version tag
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / octeon / cvmx-spi.h
blobe814648953a5194d1ef5d0da09f8cf951bedbefc
1 /***********************license start***************
2 * Author: Cavium Networks
4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK
7 * Copyright (c) 2003-2008 Cavium Networks
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.
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.
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/.
24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information
26 ***********************license end**************************************/
30 * This file contains defines for the SPI interface
32 #ifndef __CVMX_SPI_H__
33 #define __CVMX_SPI_H__
35 #include "cvmx-gmxx-defs.h"
37 /* CSR typedefs have been moved to cvmx-csr-*.h */
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;
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);
51 /** Called to setup calendar */
52 int (*calendar_setup_cb) (int interface, cvmx_spi_mode_t mode,
53 int num_ports);
55 /** Called for Tx and Rx clock detection */
56 int (*clock_detect_cb) (int interface, cvmx_spi_mode_t mode,
57 int timeout);
59 /** Called to perform link training */
60 int (*training_cb) (int interface, cvmx_spi_mode_t mode, int timeout);
62 /** Called for calendar data synchronization */
63 int (*calendar_sync_cb) (int interface, cvmx_spi_mode_t mode,
64 int timeout);
66 /** Called when interface is up */
67 int (*interface_up_cb) (int interface, cvmx_spi_mode_t mode);
69 } cvmx_spi_callbacks_t;
71 /**
72 * Return true if the supplied interface is configured for SPI
74 * @interface: Interface to check
75 * Returns True if interface is SPI
77 static inline int cvmx_spi_is_spi_interface(int interface)
79 uint64_t gmxState = cvmx_read_csr(CVMX_GMXX_INF_MODE(interface));
80 return (gmxState & 0x2) && (gmxState & 0x1);
83 /**
84 * Initialize and start the SPI interface.
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
95 * Returns Zero on success, negative of failure.
97 extern int cvmx_spi_start_interface(int interface, cvmx_spi_mode_t mode,
98 int timeout, int num_ports);
101 * This routine restarts the SPI interface after it has lost synchronization
102 * with its corespondant system.
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.
113 extern int cvmx_spi_restart_interface(int interface, cvmx_spi_mode_t mode,
114 int timeout);
117 * Return non-zero if the SPI interface has a SPI4000 attached
119 * @interface: SPI interface the SPI4000 is connected to
121 * Returns
123 static inline int cvmx_spi4000_is_present(int interface)
125 return 0;
129 * Initialize the SPI4000 for use
131 * @interface: SPI interface the SPI4000 is connected to
133 static inline int cvmx_spi4000_initialize(int interface)
135 return 0;
139 * Poll all the SPI4000 port and check its speed
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.
145 static inline union cvmx_gmxx_rxx_rx_inbnd cvmx_spi4000_check_speed(
146 int interface,
147 int port)
149 union cvmx_gmxx_rxx_rx_inbnd r;
150 r.u64 = 0;
151 return r;
155 * Get current SPI4 initialization callbacks
157 * @callbacks: Pointer to the callbacks structure.to fill
159 * Returns Pointer to cvmx_spi_callbacks_t structure.
161 extern void cvmx_spi_get_callbacks(cvmx_spi_callbacks_t *callbacks);
164 * Set new SPI4 initialization callbacks
166 * @new_callbacks: Pointer to an updated callbacks structure.
168 extern void cvmx_spi_set_callbacks(cvmx_spi_callbacks_t *new_callbacks);
171 * Callback to perform SPI4 reset
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).
180 * Returns Zero on success, non-zero error code on failure (will cause
181 * SPI initialization to abort)
183 extern int cvmx_spi_reset_cb(int interface, cvmx_spi_mode_t mode);
186 * Callback to setup calendar and miscellaneous settings before clock
187 * detection
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
197 * Returns Zero on success, non-zero error code on failure (will cause
198 * SPI initialization to abort)
200 extern int cvmx_spi_calendar_setup_cb(int interface, cvmx_spi_mode_t mode,
201 int num_ports);
204 * Callback to perform clock detection
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
214 * Returns Zero on success, non-zero error code on failure (will cause
215 * SPI initialization to abort)
217 extern int cvmx_spi_clock_detect_cb(int interface, cvmx_spi_mode_t mode,
218 int timeout);
221 * Callback to perform link training
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)
231 * Returns Zero on success, non-zero error code on failure (will cause
232 * SPI initialization to abort)
234 extern int cvmx_spi_training_cb(int interface, cvmx_spi_mode_t mode,
235 int timeout);
238 * Callback to perform calendar data synchronization
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
248 * Returns Zero on success, non-zero error code on failure (will cause
249 * SPI initialization to abort)
251 extern int cvmx_spi_calendar_sync_cb(int interface, cvmx_spi_mode_t mode,
252 int timeout);
255 * Callback to handle interface up
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).
264 * Returns Zero on success, non-zero error code on failure (will cause
265 * SPI initialization to abort)
267 extern int cvmx_spi_interface_up_cb(int interface, cvmx_spi_mode_t mode);
269 #endif /* __CVMX_SPI_H__ */