1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30#ifndef _OMAP3_SPI_H_
31#define _OMAP3_SPI_H_
32
33#define OMAP3_MCSPI1_BASE 0x48098000
34#define OMAP3_MCSPI2_BASE 0x4809A000
35#define OMAP3_MCSPI3_BASE 0x480B8000
36#define OMAP3_MCSPI4_BASE 0x480BA000
37
38#define OMAP3_MCSPI_MAX_FREQ 48000000
39
40
41struct mcspi_channel {
42 unsigned int chconf;
43 unsigned int chstat;
44 unsigned int chctrl;
45 unsigned int tx;
46 unsigned int rx;
47};
48
49struct mcspi {
50 unsigned char res1[0x10];
51 unsigned int sysconfig;
52 unsigned int sysstatus;
53 unsigned int irqstatus;
54 unsigned int irqenable;
55 unsigned int wakeupenable;
56 unsigned int syst;
57 unsigned int modulctrl;
58 struct mcspi_channel channel[4];
59
60
61
62};
63
64
65#define OMAP3_MCSPI_SYSCONFIG_SMARTIDLE (2 << 3)
66#define OMAP3_MCSPI_SYSCONFIG_ENAWAKEUP (1 << 2)
67#define OMAP3_MCSPI_SYSCONFIG_AUTOIDLE (1 << 0)
68#define OMAP3_MCSPI_SYSCONFIG_SOFTRESET (1 << 1)
69
70#define OMAP3_MCSPI_SYSSTATUS_RESETDONE (1 << 0)
71
72#define OMAP3_MCSPI_MODULCTRL_SINGLE (1 << 0)
73#define OMAP3_MCSPI_MODULCTRL_MS (1 << 2)
74#define OMAP3_MCSPI_MODULCTRL_STEST (1 << 3)
75
76#define OMAP3_MCSPI_CHCONF_PHA (1 << 0)
77#define OMAP3_MCSPI_CHCONF_POL (1 << 1)
78#define OMAP3_MCSPI_CHCONF_CLKD_MASK (0x0f << 2)
79#define OMAP3_MCSPI_CHCONF_EPOL (1 << 6)
80#define OMAP3_MCSPI_CHCONF_WL_MASK (0x1f << 7)
81#define OMAP3_MCSPI_CHCONF_TRM_RX_ONLY (0x01 << 12)
82#define OMAP3_MCSPI_CHCONF_TRM_TX_ONLY (0x02 << 12)
83#define OMAP3_MCSPI_CHCONF_TRM_MASK (0x03 << 12)
84#define OMAP3_MCSPI_CHCONF_DMAW (1 << 14)
85#define OMAP3_MCSPI_CHCONF_DMAR (1 << 15)
86#define OMAP3_MCSPI_CHCONF_DPE0 (1 << 16)
87#define OMAP3_MCSPI_CHCONF_DPE1 (1 << 17)
88#define OMAP3_MCSPI_CHCONF_IS (1 << 18)
89#define OMAP3_MCSPI_CHCONF_TURBO (1 << 19)
90#define OMAP3_MCSPI_CHCONF_FORCE (1 << 20)
91
92#define OMAP3_MCSPI_CHSTAT_RXS (1 << 0)
93#define OMAP3_MCSPI_CHSTAT_TXS (1 << 1)
94#define OMAP3_MCSPI_CHSTAT_EOT (1 << 2)
95
96#define OMAP3_MCSPI_CHCTRL_EN (1 << 0)
97
98#define OMAP3_MCSPI_WAKEUPENABLE_WKEN (1 << 0)
99
100struct omap3_spi_slave {
101 struct spi_slave slave;
102 struct mcspi *regs;
103 unsigned int freq;
104 unsigned int mode;
105};
106
107static inline struct omap3_spi_slave *to_omap3_spi(struct spi_slave *slave)
108{
109 return container_of(slave, struct omap3_spi_slave, slave);
110}
111
112int omap3_spi_txrx(struct spi_slave *slave, unsigned int len, const u8 *txp,
113 u8 *rxp, unsigned long flags);
114int omap3_spi_write(struct spi_slave *slave, unsigned int len, const u8 *txp,
115 unsigned long flags);
116int omap3_spi_read(struct spi_slave *slave, unsigned int len, u8 *rxp,
117 unsigned long flags);
118
119#endif
120