]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/asm-arm/arch-mx23/spi.h
imported Ka-Ro specific additions to U-Boot 2009.08 for TX28
[karo-tx-uboot.git] / include / asm-arm / arch-mx23 / spi.h
1 /*
2  * Copyright (C) 2008 Embedded Alley Solutions Inc.
3  *
4  * (C) Copyright 2009-2010 Freescale Semiconductor, Inc.
5  *
6  * SSP/SPI driver
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22 #ifndef SPI_H
23 #define SPI_H
24
25 #include <config.h>
26 #include <common.h>
27 #include <asm/arch/ssp.h>
28
29 /*
30  * Flags to set SPI mode
31  */
32 #define SPI_PHASE       0x1 /* Set phase to 1 */
33 #define SPI_POLARITY    0x2 /* Set polarity to 1 */
34
35 /* Various flags to control SPI transfers */
36 #define SPI_START       0x1     /* Lock CS signal */
37 #define SPI_STOP        0x2     /* Unlock CS signal */
38
39 /*
40  * Init SSPx interface, must be called first
41  */
42 void spi_init(void);
43
44 /*
45  * Set phase, polarity and CS number (SS0, SS1, SS2)
46  */
47 void spi_set_cfg(unsigned int bus, unsigned int cs, unsigned long mode);
48
49
50 /*
51  * Send @rx_len bytes from @dout, then receive @rx_len bytes
52  * saving them to @din
53  */
54 void spi_txrx(const char *dout, unsigned int tx_len, char *din,
55                unsigned int rx_len, unsigned long flags);
56
57
58 /* Lock/unlock SPI bus */
59 static inline void spi_lock(void)
60 {
61         disable_interrupts();
62 }
63
64 static inline void spi_unlock(void)
65 {
66         enable_interrupts();
67 }
68
69 #endif /* SPI_H */