|
1 // This component and the accompanying materials are made available |
|
2 // under the terms of the License "Eclipse Public License v1.0" |
|
3 // which accompanies this distribution, and is available |
|
4 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
5 // |
|
6 // Initial Contributors: |
|
7 // lukasz.forynski@gmail.com |
|
8 // |
|
9 // Contributors: |
|
10 // |
|
11 // |
|
12 // Description: |
|
13 // omap3530/omap3530_drivers/spi/omap3530_spi.h |
|
14 // |
|
15 // This file contains definitions to internal SPI implementation and register definitions |
|
16 // It is not intended to be exported - SPI registers must not be modified from outside of |
|
17 // the driver! |
|
18 // |
|
19 |
|
20 #ifndef __OMAP3530_SPI_H__ |
|
21 #define __OMAP3530_SPI_H__ |
|
22 |
|
23 #include <assp/omap3530_assp/omap3530_scm.h> |
|
24 #include <assp/omap3530_assp/omap3530_gpio.h> |
|
25 |
|
26 #define BIT_MASK(shift,len) (((1u << (len)) - 1) << (shift)) |
|
27 #define GET_BITS(w,shift,len) (((w) >> (shift)) & ((1 << (len)) - 1)) |
|
28 #define SET_BITS(w,set,shift,len) ((w) &= ~BIT_MASK(shift, len), (w) |= ((set) << (shift))) |
|
29 |
|
30 // Device Instance Summary |
|
31 const TUint MCSPI1_phys = 0x48098000; // 4Kbytes |
|
32 const TUint MCSPI2_phys = 0x4809A000; // 4Kbytes |
|
33 const TUint MCSPI3_phys = 0x480B8000; // 4Kbytes |
|
34 const TUint MCSPI4_phys = 0x480BA000; // 4Kbytes |
|
35 |
|
36 const TUint MCSPI1 = Omap3530HwBase::TVirtual<MCSPI1_phys>::Value; |
|
37 const TUint MCSPI2 = Omap3530HwBase::TVirtual<MCSPI2_phys>::Value; |
|
38 const TUint MCSPI3 = Omap3530HwBase::TVirtual<MCSPI3_phys>::Value; |
|
39 const TUint MCSPI4 = Omap3530HwBase::TVirtual<MCSPI4_phys>::Value; |
|
40 |
|
41 // map of SPI base addresses.. |
|
42 const TUint KMcSpiRegBase[] = |
|
43 { |
|
44 Omap3530HwBase::TVirtual<MCSPI1_phys>::Value, //McSPI module 1 |
|
45 Omap3530HwBase::TVirtual<MCSPI2_phys>::Value, //McSPI module 2 |
|
46 Omap3530HwBase::TVirtual<MCSPI3_phys>::Value, //McSPI module 3 |
|
47 Omap3530HwBase::TVirtual<MCSPI4_phys>::Value //McSPI module 4 |
|
48 }; |
|
49 |
|
50 //.. and IRQ lines for SPI channels |
|
51 const TUint KMcSpiIrqId[] = |
|
52 { |
|
53 EOmap3530_IRQ65_SPI1_IRQ, //McSPI module 1 |
|
54 EOmap3530_IRQ66_SPI2_IRQ, //McSPI module 2 |
|
55 EOmap3530_IRQ91_SPI3_IRQ, //McSPI module 3 |
|
56 EOmap3530_IRQ48_SPI4_IRQ //McSPI module 4 |
|
57 }; |
|
58 |
|
59 // available channels per module i.e. number of 'slave select' inputs/outpus signals / addresses |
|
60 // per module. |
|
61 const TUint KMcSpiNumSupportedSlaves[] = |
|
62 { |
|
63 4, // slave address range: 0 - 3 |
|
64 2, // slave address range: 0 - 1 |
|
65 6, // slave address range: 0 - 5 (0,1: pin option 0; 2,3: pin option 1; 4,5: pin option 2) |
|
66 1 // slave address range: 0 only |
|
67 }; |
|
68 |
|
69 |
|
70 //--------------------------------------------------------------- |
|
71 // MCSPI Registers offsets and bits definitions |
|
72 //---------------------------------- |
|
73 // MCSPI_REVISION |
|
74 //---------------------------------- |
|
75 const TUint MCSPI_REVISION = 0x00; |
|
76 |
|
77 |
|
78 //---------------------------------- |
|
79 // MCSPI_SYSCONFIG |
|
80 //---------------------------------- |
|
81 const TUint MCSPI_SYSCONFIG = 0x10; |
|
82 |
|
83 // 9:8 CLOCKACTIVITY Clocks activity during wake up mode period |
|
84 //0x0: Interface and Functional clocks may be switched off. |
|
85 //0x1: Interface clock is maintained. Functional clock may be switched off. |
|
86 //0x2: Functional clock is maintained. Interface clock may be switched off. |
|
87 //0x3: Interface and Functional clocks are maintained. |
|
88 const TUint MCSPI_SYSCONFIG_CLOCKACTIVITY_ALL_OFF = 0 << 8; |
|
89 const TUint MCSPI_SYSCONFIG_CLOCKACTIVITY_INT_ON_FUN_OFF = 1 << 8; |
|
90 const TUint MCSPI_SYSCONFIG_CLOCKACTIVITY_INT_OFF_FUN_ON = 2 << 8; |
|
91 const TUint MCSPI_SYSCONFIG_CLOCKACTIVITY_ALL_ON = 3 << 8; |
|
92 |
|
93 // 4:3 SIDLEMODE Power management |
|
94 const TUint MCSPI_SYSCONFIG_SIDLEMODE_ALWAYS = 0 << 3; |
|
95 const TUint MCSPI_SYSCONFIG_SIDLEMODE_IGNORE = 1 << 3; |
|
96 const TUint MCSPI_SYSCONFIG_SIDLEMODE_COND = 2 << 3; |
|
97 const TUint MCSPI_SYSCONFIG_ENAWAKEUP = 1 << 2; // 0x1: Wake-up capability enabled |
|
98 const TUint MCSPI_SYSCONFIG_SOFTRESET = 1 << 1; // Software reset. Read always returns 0. |
|
99 const TUint MCSPI_SYSCONFIG_AUTOIDLE = 1 << 0; // Internal interface Clock gating strategy |
|
100 |
|
101 |
|
102 //---------------------------------- |
|
103 // MCSPI_SYSSTATUS |
|
104 //---------------------------------- |
|
105 const TUint MCSPI_SYSSTATUS = 0x14; |
|
106 const TUint MCSPI_SYSSTATUS_RESETDONE = 1 << 0; |
|
107 |
|
108 |
|
109 //---------------------------------- |
|
110 // MCSPI_IRQSTATUS |
|
111 //---------------------------------- |
|
112 const TUint MCSPI_IRQSTATUS = 0x18; // for each bit- write 0x1: reset status, Read 0x1: Event is pending. |
|
113 const TUint MCSPI_IRQSTATUS_EOW = 1 << 17; // End of word count event when a channel is enabled using |
|
114 const TUint MCSPI_IRQSTATUS_WKS = 1 << 16; // Wake-up event in slave mode when an active control signal is detected |
|
115 const TUint MCSPI_IRQSTATUS_RX3_FULL = 1 << 14; // MCSPI_RX3 register is full (only when channel 3 is enabled) |
|
116 const TUint MCSPI_IRQSTATUS_TX3_UDERFLOW = 1 << 13; // MCSPI_TX3 register underflow (only when channel 3 is enabled)(1) |
|
117 const TUint MCSPI_IRQSTATUS_TX3_EMPTY = 1 << 12; // MCSPI_TX3 register is empty (only when channel 3 is enabled)(2) |
|
118 const TUint MCSPI_IRQSTATUS_RX2_FULL = 1 << 10; // MCSPI_RX2 register full (only when channel 2 is enabled) |
|
119 const TUint MCSPI_IRQSTATUS_TX2_UNDERFLOW = 1 << 9; // MCSPI_TX2 register underflow (only when channel 2 is enabled)(1) |
|
120 const TUint MCSPI_IRQSTATUS_TX2_EMPTY = 1 << 8; // MCSPI_TX2 register empty (only when channel 2 is enabled)(2) |
|
121 const TUint MCSPI_IRQSTATUS_RX1_FULL = 1 << 6; // MCSPI_RX1 register full (only when channel 1 is enabled) |
|
122 const TUint MCSPI_IRQSTATUS_TX1_UNDERFLOW = 1 << 5; // MCSPI_TX1 register underflow (only when channel 1 is enabled)(1) |
|
123 const TUint MCSPI_IRQSTATUS_TX1_EMPTY = 1 << 4; // MCSPI_TX1 register empty (only when channel 1 is enabled)(3) |
|
124 const TUint MCSPI_IRQSTATUS_RX0_OVERFLOW = 1 << 3; // MCSPI_RX0 register overflow (only in slave mode) |
|
125 const TUint MCSPI_IRQSTATUS_RX0_FULL = 1 << 2; // MCSPI_RX0 register full (only when channel 0 is enabled) |
|
126 const TUint MCSPI_IRQSTATUS_TX0_UNDERFLOW = 1 << 1; // MCSPI_TX0 register underflow (only when channel 0 is |
|
127 const TUint MCSPI_IRQSTATUS_TX0_EMPTY = 1 << 0; // MCSPI_TX0 register empty (only when channel 0 is enabled)(3) |
|
128 |
|
129 //---------------------------------- |
|
130 // MCSPI_IRQENABLE |
|
131 //---------------------------------- |
|
132 //0x0: Interrupt disabled |
|
133 //0x1: Interrupt enabled |
|
134 const TUint MCSPI_IRQENABLE = 0x1C; |
|
135 const TUint MCSPI_IRQENABLE_EOWKE = 1 << 17; // End of Word count Interrupt Enable. |
|
136 const TUint MCSPI_IRQENABLE_WKE = 1 << 16; // Wake-up event interrupt enable in slave mode when an |
|
137 const TUint MCSPI_IRQENABLE_RX3_FULL = 1 << 14; // MCSPI_RX3 register full interrupt enable (channel 3) |
|
138 const TUint MCSPI_IRQENABLE_TX3_UNDERFLOW = 1 << 13; // MCSPI_TX3 register underflow interrupt enable (channel 3) |
|
139 const TUint MCSPI_IRQENABLE_TX3_EMPTY = 1 << 12; // MCSPI_TX3 register empty interrupt enable (channel 3) |
|
140 const TUint MCSPI_IRQENABLE_RX2_FULL = 1 << 10; // MCSPI_RX2 register full interrupt enable (channel 2) |
|
141 const TUint MCSPI_IRQENABLE_TX2_UNDERFLOW = 1 << 9; // MCSPI_TX2 register underflow interrupt enable (channel 2) |
|
142 const TUint MCSPI_IRQENABLE_TX2_EMPTY = 1 << 8; // MCSPI_TX2 register empty interrupt enable (channel 2) |
|
143 const TUint MCSPI_IRQENABLE_RX1_FULL = 1 << 6; // MCSPI_RX1 register full interrupt enable (channel 1) |
|
144 const TUint MCSPI_IRQENABLE_TX1_UNDERFLOW = 1 << 5; // MCSPI_TX1 register underflow interrupt enable (channel 1) |
|
145 const TUint MCSPI_IRQENABLE_TX1_EMPTY = 1 << 4; // MCSPI_TX1 register empty interrupt enable (channel 1) |
|
146 const TUint MCSPI_IRQENABLE_RX0_OVERFLOW = 1 << 3; // MCSPI_RX0 register overflow interrupt enable (channel 0) (only Slave) |
|
147 const TUint MCSPI_IRQENABLE_RX0_FULL = 1 << 2; // MCSPI_RX0 register full interrupt enable (channel 0) |
|
148 const TUint MCSPI_IRQENABLE_TX0_UNDERFLOW = 1 << 1; // MCSPI_TX0 register underflow interrupt enable (channel 0) |
|
149 const TUint MCSPI_IRQENABLE_TX0_EMPTY = 1 << 0; // MCSPI_TX0 register empty interrupt enable (channel 0) |
|
150 |
|
151 // macros to get these flags depending on the channel number..and ommited ENABLE |
|
152 // - as they are the same for MCSPI_IRQSTATUS register |
|
153 #define MCSPI_IRQ_RX_OVERFLOW MCSPI_IRQENABLE_RX0_OVERFLOW // Channel 0 only / slave mode only |
|
154 #define MCSPI_IRQ_RX_FULL(chan) (MCSPI_IRQENABLE_RX0_FULL << ((chan)*4)) |
|
155 #define MCSPI_IRQ_TX_UNDERFLOW(chan) (MCSPI_IRQENABLE_TX0_UNDERFLOW << ((chan)*4)) |
|
156 #define MCSPI_IRQ_TX_EMPTY(chan) (MCSPI_IRQENABLE_TX0_EMPTY << ((chan)*4)) |
|
157 |
|
158 |
|
159 //---------------------------------- |
|
160 // MCSPI_WAKEUPENABL |
|
161 //---------------------------------- |
|
162 const TUint MCSPI_WAKEUPENABL = 0x20; |
|
163 const TUint MCSPI_WAKEUPENABL_WKEN = 1 << 0; //0x1: The event is allowed to wake-up the system |
|
164 |
|
165 |
|
166 //---------------------------------- |
|
167 // MCSPI_SYST |
|
168 //---------------------------------- |
|
169 const TUint MCSPI_SYST = 0x24; |
|
170 const TUint MCSPI_SYST_SSB = 1 << 11; // Set status bit: 0x1: Force to 1 all status bits of MCSPI_ IRQSTATUS |
|
171 const TUint MCSPI_SYST_SPIENDIR = 1 << 10; // spim_cs and spim_clk direction: 0x0: Output (as in master mode), 0x1: Input (as in slave mode) |
|
172 const TUint MCSPI_SYST_SPIDATDIR1 = 1 << 9; // SPIDAT[1] (spim_simo) direction- 0x0: Output, 0x1: Input |
|
173 const TUint MCSPI_SYST_SPIDATDIR0 = 1 << 8; // Set the direction of the SPIDAT[0] (spim_somi) RW 0 |
|
174 const TUint MCSPI_SYST_WAKD = 1 << 7; // SWAKEUP output 0x0: The pin is driven low, 0x1: The pin is driven high. |
|
175 const TUint MCSPI_SYST_SPICLK = 1 << 6; // spim_clk line (signal data value) RW 0 |
|
176 const TUint MCSPI_SYST_SPIDAT_1 = 1 << 5; // spim_somi line (signal data value) RW 0 |
|
177 const TUint MCSPI_SYST_SPIDAT_0 = 1 << 4; // spim_simo line (signal data value) |
|
178 const TUint MCSPI_SYST_SPIEN_3 = 1 << 3; // spim_cs3 line (signal data value) RW 0 |
|
179 const TUint MCSPI_SYST_SPIEN_2 = 1 << 2; // spim_cs2 line (signal data value) RW 0 |
|
180 const TUint MCSPI_SYST_SPIEN_1 = 1 << 1; // spim_cs1 line (signal data value) RW 0 |
|
181 const TUint MCSPI_SYST_SPIEN_0 = 1 << 0; // spim_cs0 line (signal data value) RW 0 |
|
182 |
|
183 |
|
184 //---------------------------------- |
|
185 // MCSPI_MODULCTRL |
|
186 //---------------------------------- |
|
187 const TUint MCSPI_MODULCTRL = 0x28; |
|
188 const TUint MCSPI_MODULCTRL_SYSTEM_TEST = 1 << 3; // 0x0: Functional mode, 0x1: System test mode (SYSTEST) |
|
189 const TUint MCSPI_MODULCTRL_MS_SLAVE = 1 << 2; // Master / Slave mode 0x0: Master, 0x1: Slave |
|
190 const TUint MCSPI_MODULCTRL_MS_MASTER = 0; // this is spurious definition -> not to write '0' magic number -defined this.. |
|
191 const TUint MCSPI_MODULCTRL_SINGLE = 1 << 0; // Single forced channel/multichannel (master mode only) |
|
192 // MCSPI_CHxCONF_FORCE bit has to be set in this mode, TURBO cleared (recomended) |
|
193 |
|
194 |
|
195 //---------------------------------- |
|
196 // MCSPI_CHxCONF - channel config |
|
197 //---------------------------------- |
|
198 // x = 0 to 3 for MCSPI1. |
|
199 // x = 0 to 1 for MCSPI2 and MCSPI3. |
|
200 // x = 0 for MCSPI4. |
|
201 #define MCSPI_CHxCONF(x) (0x2C + 0x14 * (x)) |
|
202 const TUint MCSPI_CHxCONF_CLKG = 1 << 29; // Clock divider granularity. |
|
203 const TUint MCSPI_CHxCONF_FFER = 1 << 28; // FIFO enabled for Receive. |
|
204 const TUint MCSPI_CHxCONF_FFEW = 1 << 27; // FIFO enabled for Transmit. Only one channel can have this bit field set. |
|
205 |
|
206 // [26:25] TCS Chip select time control |
|
207 // Defines the number of interface clock cycles between CS toggling and first (or last) edge of SPI clock. |
|
208 const TUint MCSPI_CHxCONF_TCS_0_5 = 0 << 25; // 0x0: 0.5 clock cycle |
|
209 const TUint MCSPI_CHxCONF_TCS_1_5 = 1 << 25; // 0x1: 1.5 clock cycles |
|
210 const TUint MCSPI_CHxCONF_TCS_2_5 = 2 << 25; // 0x2: 2.5 clock cycles |
|
211 const TUint MCSPI_CHxCONF_TCS_3_5 = 3 << 25; // 0x3: 3.5 clock cycles |
|
212 const TUint MCSPI_CHxCONF_TCS_SHIFT = 25; |
|
213 const TUint KMaxTransactionWaitTime = 3; |
|
214 |
|
215 const TUint MCSPI_CHxCONF_SBPOL = 1 << 24; // Start bit polarity (0: spi word is command, 1: spi word is data) |
|
216 const TUint MCSPI_CHxCONF_SBE = 1 << 23; // Start bit enable - 0x1: Start bit D/CX added before transfer. |
|
217 const TUint MCSPI_CHxCONF_FORCE = 1 << 20; // Manual spim_csx assertion to keep spim_csx active between SPI words. |
|
218 // (single channel master mode only)- MCSPI_MODULCTRL_SINGLE has to be set |
|
219 const TUint MCSPI_CHxCONF_TURBO = 1 << 19; // Turbo mode |
|
220 const TUint MCSPI_CHxCONF_IS = 1 << 18; // Input select- 0x0: (spim_somi), 0x1: (spim_simo) selected for reception |
|
221 const TUint MCSPI_CHxCONF_DPE1 = 1 << 17; // Transmission enable for data line 1 (spim_simo) RW 0x1 |
|
222 const TUint MCSPI_CHxCONF_DPE0 = 1 << 16; // Transmission enable for data line 0 (spim_somi) |
|
223 const TUint MCSPI_CHxCONF_DMAR = 1 << 15; // DMA Read request |
|
224 const TUint MCSPI_CHxCONF_DMAW = 1 << 14; // DMA Write request. |
|
225 |
|
226 // 13:12 TRM Transmit/receive modes |
|
227 const TUint MCSPI_CHxCONF_TRM_TRANSMIT_RECEIVE = 0 << 12; |
|
228 const TUint MCSPI_CHxCONF_TRM_RECEIVE_ONLY = 1 << 12; |
|
229 const TUint MCSPI_CHxCONF_TRM_TRANSMIT_ONLY = 2 << 12; |
|
230 // these are to be cleared in the register |
|
231 const TUint MCSPI_CHxCONF_TRM_NO_TRANSMIT = 1 << 12; |
|
232 const TUint MCSPI_CHxCONF_TRM_NO_RECEIVE = 2 << 12; |
|
233 |
|
234 |
|
235 // 11:7 WL SPI word length0 |
|
236 // values:<0-3> reserved, allowed:<4-31> => word_size = value + 1 (i.e. for 4: word size = 5) |
|
237 const TInt KMinSpiWordWidth = 5; |
|
238 const TUint MCSPI_CHxCONF_WL_OFFSET = 7; |
|
239 #define MCSPI_CHxCONF_WL(x) ( (((x) - 1) & BIT_MASK(0, 5)) << MCSPI_CHxCONF_WL_OFFSET ) |
|
240 |
|
241 const TUint MCSPI_CHxCONF_EPOL_LOW = 1 << 6; // spim_csx polarity 0x0: active high, 0x1: active low |
|
242 |
|
243 // A programmable clock divider divides the SPI reference clock |
|
244 //5:2 CLKD Frequency divider for spim_clk (for master device only) |
|
245 const TUint MCSPI_CHxCONF_CLKD_48M = 0x0 << 2; //0x0: 1 = 48 MHz |
|
246 const TUint MCSPI_CHxCONF_CLKD_24M = 0x1 << 2; //0x1: 2 = 24 MHz |
|
247 const TUint MCSPI_CHxCONF_CLKD_12M = 0x2 << 2; //0x2: 4 = 12 MHz |
|
248 const TUint MCSPI_CHxCONF_CLKD_6M = 0x3 << 2; //0x3: 8 = 6 MHz |
|
249 const TUint MCSPI_CHxCONF_CLKD_3M = 0x4 << 2; //0x4: 16 = 3 MHz |
|
250 const TUint MCSPI_CHxCONF_CLKD_1500k = 0x5 << 2; //0x5: 32 = 1.5 MHz |
|
251 const TUint MCSPI_CHxCONF_CLKD_750k = 0x6 << 2; //0x6: 64 = 750 kHz |
|
252 const TUint MCSPI_CHxCONF_CLKD_375k = 0x7 << 2; //0x7: 128 = 375 kHz |
|
253 const TUint MCSPI_CHxCONF_CLKD_187k = 0x8 << 2; //0x8: 256 = 187.5 kHz |
|
254 const TUint MCSPI_CHxCONF_CLKD_93k = 0x9 << 2; //0x9: 512 = 93.75 kHz |
|
255 const TUint MCSPI_CHxCONF_CLKD_46k = 0xA << 2; //0xA: 1024 = 46.875 kHz |
|
256 const TUint MCSPI_CHxCONF_CLKD_23k = 0xB << 2; //0xB: 2048 = 23.437,5 kHz |
|
257 const TUint MCSPI_CHxCONF_CLKD_11k = 0xC << 2; //0xC: 4096 = 11.718,75 kHz |
|
258 const TUint MCSPI_K48MHz = 48000000; |
|
259 |
|
260 const TUint MCSPI_CHxCONF_POL = 1 << 1; // spim_clk polarity 0x0: active high, 0x1: active low |
|
261 const TUint MCSPI_CHxCONF_PHA = 1 << 0; // spim_clk phase |
|
262 // 0x0: Data are latched on odd-numbered edges of spim_clk. |
|
263 // 0x1: Data are latched on even-numbered edges of spim_clk. |
|
264 |
|
265 |
|
266 //---------------------------------- |
|
267 // MCSPI_CHxSTAT |
|
268 //---------------------------------- |
|
269 // x = 0 to 3 for MCSPI1. |
|
270 // x = 0 to 1 for MCSPI2 and MCSPI3. |
|
271 // x = 0 for MCSPI4. |
|
272 #define MCSPI_CHxSTAT(x) (0x30 + 0x14 * (x)) |
|
273 const TUint MCSPI_CHxSTAT_RXFFF = 1 << 6; // Channel x FIFO Receive Buffer Full |
|
274 const TUint MCSPI_CHxSTAT_RXFFE = 1 << 5; // Channel x FIFO Receive Buffer Empty |
|
275 const TUint MCSPI_CHxSTAT_TXFFF = 1 << 4; // Channel x FIFO Transmit Buffer Full |
|
276 const TUint MCSPI_CHxSTAT_TXFFE = 1 << 3; // Channel x FIFO Transmit Buffer Empty |
|
277 const TUint MCSPI_CHxSTAT_EOT = 1 << 2; // Channel x end-of-transfer status. |
|
278 const TUint MCSPI_CHxSTAT_TXS = 1 << 1; // Channel x MCSPI_TXx register status R 0x0 |
|
279 const TUint MCSPI_CHxSTAT_RXS = 1 << 0; // Channel x MCSPI_RXx register status R 0x0 |
|
280 |
|
281 |
|
282 //---------------------------------- |
|
283 // MCSPI_CHxCTRL |
|
284 //---------------------------------- |
|
285 // x = 0 to 3 for MCSPI1. |
|
286 // x = 0 to 1 for MCSPI2 and MCSPI3. |
|
287 // x = 0 for MCSPI4. |
|
288 #define MCSPI_CHxCTRL(x) (0x34 + 0x14 * (x)) |
|
289 //15:8 EXTCLK Clock ratio extension: This register is used to concatenate with RW 0x00 |
|
290 const TUint MCSPI_CHxCTRL_EXTCLK_1 = 0x00 << 8; //0x0: Clock ratio is CLKD + 1 |
|
291 const TUint MCSPI_CHxCTRL_EXTCLK_1_16 = 0x01 << 8; //0x1: Clock ratio is CLKD + 1 + 16 |
|
292 const TUint MCSPI_CHxCTRL_EXTCLK_1_4080 = 0xff << 8; //0xFF: Clock ratio is CLKD + 1 + 4080 |
|
293 const TUint MCSPI_CHxCTRL_EN = 0x01 << 0; // Channel enable |
|
294 |
|
295 |
|
296 //---------------------------------- |
|
297 // MCSPI_TXx - Channel x Data to transmit |
|
298 //---------------------------------- |
|
299 // x = 0 to 3 for MCSPI1. |
|
300 // x = 0 to 1 for MCSPI2 and MCSPI3. |
|
301 // x = 0 for MCSPI4. |
|
302 #define MCSPI_TXx(x) (0x38 + 0x14 * (x)) // Channel x Data to transmit |
|
303 |
|
304 |
|
305 //---------------------------------- |
|
306 // MCSPI_RXx - Channel x Received Data |
|
307 //---------------------------------- |
|
308 // x = 0 to 3 for MCSPI1. |
|
309 // x = 0 to 1 for MCSPI2 and MCSPI3. |
|
310 // x = 0 for MCSPI4. |
|
311 #define MCSPI_RXx(x) (0x3C + 0x14 * (x)) // Channel x Received Data |
|
312 |
|
313 |
|
314 //---------------------------------- |
|
315 // MCSPI_XFERLEVEL |
|
316 //---------------------------------- |
|
317 const TUint MCSPI_XFERLEVEL = 0x7C; |
|
318 const TUint MCSPI_XFERLEVEL_WCNT_OFFSET = 16; // [31:16] WCNT Spi word counter -> how many bytes are transfered to FIFO before tx is enabled |
|
319 const TUint MCSPI_XFERLEVEL_AFL_OFFSET = 8; // 13:8 AFL Buffer Almost Full. 0x0: One byte , 0x1: 2 bytes, x3E: 63 bytes.. etc |
|
320 const TUint MCSPI_XFERLEVEL_AEL_OFFSET = 0; // 5:0 AEL Buffer Almost Empty (threshold?) 0x0: One byte. 0x1: 2 bytes.. |
|
321 |
|
322 #define MCSPI_XFERLEVEL_WCNT(x) ((x) << MCSPI_XFERLEVEL_WCNT_OFFSET) |
|
323 #define MCSPI_XFERLEVEL_AFL(x) (((x) << MCSPI_XFERLEVEL_AFL_OFFSET)) |
|
324 #define MCSPI_XFERLEVEL_AEL(x) (((x) << MCSPI_XFERLEVEL_AEL_OFFSET)) |
|
325 |
|
326 |
|
327 //---------------------------------- |
|
328 // PAD (PIN) configuration for SPI |
|
329 //---------------------------------- |
|
330 const TUint KMaxSpiChannelsPerModule = 4; // there are max 4 channels (McSPI 1) |
|
331 |
|
332 struct TPinConfig |
|
333 { |
|
334 TLinAddr iAddress; |
|
335 SCM::TLowerHigherWord iMswLsw; |
|
336 TUint8 iPinNumber; |
|
337 TUint16 iFlags; |
|
338 }; |
|
339 |
|
340 struct TSpiPinConfig |
|
341 { |
|
342 TPinConfig iClk; |
|
343 TPinConfig iSimo; |
|
344 TPinConfig iSomi; |
|
345 TPinConfig iCs[KMaxSpiChannelsPerModule]; |
|
346 }; |
|
347 |
|
348 const TSpiPinConfig TSpiPinConfigMcSpi1 = |
|
349 { |
|
350 {CONTROL_PADCONF_MCSPI1_CLK, SCM::ELsw, 171, SCM::EMode0 | SCM::EInputEnable}, // mcspi1_clk |
|
351 {CONTROL_PADCONF_MCSPI1_CLK, SCM::EMsw, 172, SCM::EMode0 | SCM::EInputEnable}, // mcspi1_simo |
|
352 {CONTROL_PADCONF_MCSPI1_SOMI, SCM::ELsw, 173, SCM::EMode0 | SCM::EInputEnable}, // mcspi1_somi |
|
353 { |
|
354 {CONTROL_PADCONF_MCSPI1_SOMI, SCM::EMsw, 174, SCM::EMode0}, // mcspi1_cs0 |
|
355 {CONTROL_PADCONF_MCSPI1_CS1, SCM::ELsw, 175, SCM::EMode0}, // mcspi1_cs1 |
|
356 {CONTROL_PADCONF_MCSPI1_CS1, SCM::EMsw, 176, SCM::EMode0}, // mcspi1_cs2 |
|
357 {CONTROL_PADCONF_MCSPI1_CS3, SCM::ELsw, 177, SCM::EMode0}, // mcspi1_cs3 |
|
358 } |
|
359 }; |
|
360 |
|
361 const TSpiPinConfig TSpiPinConfigMcSpi2 = |
|
362 { |
|
363 {CONTROL_PADCONF_MCSPI1_CS3, SCM::EMsw, 178, SCM::EMode0 | SCM::EInputEnable}, // mcspi2_clk |
|
364 {CONTROL_PADCONF_MCSPI2_SIMO, SCM::ELsw, 179, SCM::EMode0 | SCM::EInputEnable}, // mcspi2_simo |
|
365 {CONTROL_PADCONF_MCSPI2_SIMO, SCM::EMsw, 180, SCM::EMode0 | SCM::EInputEnable}, // mcspi2_somi |
|
366 { |
|
367 {CONTROL_PADCONF_MCSPI2_CS0, SCM::ELsw, 181, SCM::EMode0}, // mcspi2_cs0 |
|
368 {CONTROL_PADCONF_MCSPI2_CS0, SCM::EMsw, 182, SCM::EMode0}, // mcspi2_cs1 |
|
369 {0, SCM::ELsw, 0, 0}, // not supported |
|
370 {0, SCM::ELsw, 0, 0}, // not supported |
|
371 } |
|
372 }; |
|
373 |
|
374 // McSPI3 supports 3 different pin routing settings |
|
375 const TSpiPinConfig TSpiPinConfigMcSpi3_0 = |
|
376 { |
|
377 {CONTROL_PADCONF_MMC2_CLK, SCM::ELsw, 130, SCM::EMode1 | SCM::EInputEnable}, // mcspi3_clk |
|
378 {CONTROL_PADCONF_MMC2_CLK, SCM::EMsw, 131, SCM::EMode1 | SCM::EInputEnable}, // mcspi3_simo |
|
379 {CONTROL_PADCONF_MMC2_DAT0, SCM::ELsw, 132, SCM::EMode1 | SCM::EInputEnable}, // mcspi3_somi |
|
380 { |
|
381 {CONTROL_PADCONF_MMC2_DAT2, SCM::EMsw, 135, SCM::EMode1}, // mcspi3_cs0 |
|
382 {CONTROL_PADCONF_MMC2_DAT2, SCM::ELsw, 134, SCM::EMode1}, // mcspi3_cs1 |
|
383 {0, SCM::ELsw, 0, 0}, // not supported |
|
384 {0, SCM::ELsw, 0, 0}, // not supported |
|
385 } |
|
386 }; |
|
387 |
|
388 const TSpiPinConfig TSpiPinConfigMcSpi3_1 = |
|
389 { |
|
390 {CONTROL_PADCONF_DSS_DATA18, SCM::ELsw, 88, SCM::EMode2 | SCM::EInputEnable}, // mcspi3_clk |
|
391 {CONTROL_PADCONF_DSS_DATA18, SCM::EMsw, 89, SCM::EMode2 | SCM::EInputEnable}, // mcspi3_simo |
|
392 {CONTROL_PADCONF_DSS_DATA20, SCM::ELsw, 90, SCM::EMode2 | SCM::EInputEnable}, // mcspi3_somi |
|
393 { |
|
394 {CONTROL_PADCONF_DSS_DATA20, SCM::EMsw, 91, SCM::EMode2}, // mcspi3_cs0 |
|
395 {CONTROL_PADCONF_DSS_DATA22, SCM::ELsw, 92, SCM::EMode2}, // mcspi3_cs1 |
|
396 {0, SCM::ELsw, 0, 0}, // not supported |
|
397 {0, SCM::ELsw, 0, 0}, // not supported |
|
398 } |
|
399 }; |
|
400 |
|
401 const TSpiPinConfig TSpiPinConfigMcSpi3_2 = |
|
402 { |
|
403 {CONTROL_PADCONF_ETK_D2, SCM::EMsw, 17, SCM::EMode1 | SCM::EInputEnable}, // mcspi3_clk |
|
404 {CONTROL_PADCONF_ETK_D0, SCM::ELsw, 14, SCM::EMode1 | SCM::EInputEnable}, // mcspi3_simo |
|
405 {CONTROL_PADCONF_ETK_D0, SCM::EMsw, 15, SCM::EMode1 | SCM::EInputEnable}, // mcspi3_somi |
|
406 { |
|
407 {CONTROL_PADCONF_ETK_D2, SCM::ELsw, 16, SCM::EMode1}, // mcspi3_cs0 |
|
408 {CONTROL_PADCONF_ETK_D6, SCM::EMsw, 21, SCM::EMode1}, // mcspi3_cs1 |
|
409 {0, SCM::ELsw, 0, 0}, // not supported |
|
410 {0, SCM::ELsw, 0, 0}, // not supported |
|
411 } |
|
412 }; |
|
413 |
|
414 const TSpiPinConfig TSpiPinConfigMcSpi4 = |
|
415 { |
|
416 {CONTROL_PADCONF_MCBSP1_CLKR, SCM::ELsw, 156, SCM::EMode1 | SCM::EInputEnable}, // mcspi4_clk |
|
417 {CONTROL_PADCONF_MCBSP1_DX, SCM::ELsw, 158, SCM::EMode1 | SCM::EInputEnable}, // mcspi4_simo |
|
418 {CONTROL_PADCONF_MCBSP1_DX, SCM::EMsw, 159, SCM::EMode1 | SCM::EInputEnable}, // mcspi4_somi |
|
419 { |
|
420 {CONTROL_PADCONF_MCBSP_CLKS, SCM::EMsw, 161, SCM::EMode1}, // mcspi3_cs0 |
|
421 {0, SCM::ELsw, 0, 0}, // not supported |
|
422 {0, SCM::ELsw, 0, 0}, // not supported |
|
423 {0, SCM::ELsw, 0, 0}, // not supported |
|
424 } |
|
425 }; |
|
426 |
|
427 const TSpiPinConfig ModulePinConfig[] = |
|
428 { |
|
429 TSpiPinConfigMcSpi1, |
|
430 TSpiPinConfigMcSpi2, |
|
431 TSpiPinConfigMcSpi3_0, // (default mode for McSPI3 - SPI addresses: 0 and 1) |
|
432 TSpiPinConfigMcSpi4, |
|
433 TSpiPinConfigMcSpi3_1, // other pin mode for McSPI3.. (spi addresses: 2 and 3) |
|
434 TSpiPinConfigMcSpi3_2 // other pin mode for McSPI3.. (spi addresses: 4 and 5) |
|
435 }; |
|
436 |
|
437 |
|
438 #include "omap3530_spi.inl" |
|
439 |
|
440 |
|
441 #endif /* __OMAP3530_SPI_H__ */ |