Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cvmx-spi.h
Go to the documentation of this file.
1 /***********************license start***************
2  * Author: Cavium Networks
3  *
4  * Contact: [email protected]
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 
36 
37 /* CSR typedefs have been moved to cvmx-csr-*.h */
38 
39 typedef enum {
45 
47 typedef struct {
49  int (*reset_cb) (int interface, cvmx_spi_mode_t mode);
50 
52  int (*calendar_setup_cb) (int interface, cvmx_spi_mode_t mode,
53  int num_ports);
54 
56  int (*clock_detect_cb) (int interface, cvmx_spi_mode_t mode,
57  int timeout);
58 
60  int (*training_cb) (int interface, cvmx_spi_mode_t mode, int timeout);
61 
63  int (*calendar_sync_cb) (int interface, cvmx_spi_mode_t mode,
64  int timeout);
65 
67  int (*interface_up_cb) (int interface, cvmx_spi_mode_t mode);
68 
70 
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 
98  int timeout, int num_ports);
99 
114  int timeout);
115 
123 static inline int cvmx_spi4000_is_present(int interface)
124 {
125  return 0;
126 }
127 
133 static inline int cvmx_spi4000_initialize(int interface)
134 {
135  return 0;
136 }
137 
145 static inline union cvmx_gmxx_rxx_rx_inbnd cvmx_spi4000_check_speed(
146  int interface,
147  int port)
148 {
150  r.u64 = 0;
151  return r;
152 }
153 
161 extern void cvmx_spi_get_callbacks(cvmx_spi_callbacks_t *callbacks);
162 
168 extern void cvmx_spi_set_callbacks(cvmx_spi_callbacks_t *new_callbacks);
169 
184 
201  int num_ports);
202 
218  int timeout);
219 
235  int timeout);
236 
252  int timeout);
253 
268 
269 #endif /* __CVMX_SPI_H__ */