aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/mcbsp.c
diff options
context:
space:
mode:
authorJanusz Krzysztofik <jkrzyszt@tis.icnet.pl>2010-02-15 13:03:32 -0500
committerTony Lindgren <tony@atomide.com>2010-02-15 13:03:32 -0500
commit8ea3200f1de1c3d8f3c884a704107fb1e7449547 (patch)
tree1e45b8796a5cefdc6b79bfe0f40ea69fa628a19b /arch/arm/plat-omap/mcbsp.c
parent14f796375b5c2bcc27986de12b6f769ec3827f36 (diff)
omap: McBSP: Modify macros/functions API for easy cache access
OMAP_MCBSP_READ()/_WRITE() macros and omap_mcbsp_read()/_write() functions accept McBSP register base address as an argument. In order to support caching, that must be replaced with an address of the omap_mcbsp structure that would provide addresses for both register AND cache access. Since OMAP_ prefix seems obvious in macro names, drop it off in order to minimize line wrapping throughout the file. Tested on OMAP1510 based Amstrad Delta using linux-omap for-next, commit fb7380d70e041e4b3892f6b19dff7efb609d15a4 (2.6.33-rc3+ dated 2010-01-11). Compile-tested with omap_3430sdp_defconfig. Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Acked-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Acked-by: Jarkko Nikula <jhnikula@gmail.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/plat-omap/mcbsp.c')
-rw-r--r--arch/arm/plat-omap/mcbsp.c281
1 files changed, 125 insertions, 156 deletions
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index eaaf53bb8395..f8245f25825b 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -30,26 +30,26 @@
30struct omap_mcbsp **mcbsp_ptr; 30struct omap_mcbsp **mcbsp_ptr;
31int omap_mcbsp_count; 31int omap_mcbsp_count;
32 32
33void omap_mcbsp_write(void __iomem *io_base, u16 reg, u32 val) 33void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
34{ 34{
35 if (cpu_class_is_omap1() || cpu_is_omap2420()) 35 if (cpu_class_is_omap1() || cpu_is_omap2420())
36 __raw_writew((u16)val, io_base + reg); 36 __raw_writew((u16)val, mcbsp->io_base + reg);
37 else 37 else
38 __raw_writel(val, io_base + reg); 38 __raw_writel(val, mcbsp->io_base + reg);
39} 39}
40 40
41int omap_mcbsp_read(void __iomem *io_base, u16 reg) 41int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg)
42{ 42{
43 if (cpu_class_is_omap1() || cpu_is_omap2420()) 43 if (cpu_class_is_omap1() || cpu_is_omap2420())
44 return __raw_readw(io_base + reg); 44 return __raw_readw(mcbsp->io_base + reg);
45 else 45 else
46 return __raw_readl(io_base + reg); 46 return __raw_readl(mcbsp->io_base + reg);
47} 47}
48 48
49#define OMAP_MCBSP_READ(base, reg) \ 49#define MCBSP_READ(mcbsp, reg) \
50 omap_mcbsp_read(base, OMAP_MCBSP_REG_##reg) 50 omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg)
51#define OMAP_MCBSP_WRITE(base, reg, val) \ 51#define MCBSP_WRITE(mcbsp, reg, val) \
52 omap_mcbsp_write(base, OMAP_MCBSP_REG_##reg, val) 52 omap_mcbsp_write(mcbsp, OMAP_MCBSP_REG_##reg, val)
53 53
54#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count) 54#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
55#define id_to_mcbsp_ptr(id) mcbsp_ptr[id]; 55#define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
@@ -60,31 +60,31 @@ static void omap_mcbsp_dump_reg(u8 id)
60 60
61 dev_dbg(mcbsp->dev, "**** McBSP%d regs ****\n", mcbsp->id); 61 dev_dbg(mcbsp->dev, "**** McBSP%d regs ****\n", mcbsp->id);
62 dev_dbg(mcbsp->dev, "DRR2: 0x%04x\n", 62 dev_dbg(mcbsp->dev, "DRR2: 0x%04x\n",
63 OMAP_MCBSP_READ(mcbsp->io_base, DRR2)); 63 MCBSP_READ(mcbsp, DRR2));
64 dev_dbg(mcbsp->dev, "DRR1: 0x%04x\n", 64 dev_dbg(mcbsp->dev, "DRR1: 0x%04x\n",
65 OMAP_MCBSP_READ(mcbsp->io_base, DRR1)); 65 MCBSP_READ(mcbsp, DRR1));
66 dev_dbg(mcbsp->dev, "DXR2: 0x%04x\n", 66 dev_dbg(mcbsp->dev, "DXR2: 0x%04x\n",
67 OMAP_MCBSP_READ(mcbsp->io_base, DXR2)); 67 MCBSP_READ(mcbsp, DXR2));
68 dev_dbg(mcbsp->dev, "DXR1: 0x%04x\n", 68 dev_dbg(mcbsp->dev, "DXR1: 0x%04x\n",
69 OMAP_MCBSP_READ(mcbsp->io_base, DXR1)); 69 MCBSP_READ(mcbsp, DXR1));
70 dev_dbg(mcbsp->dev, "SPCR2: 0x%04x\n", 70 dev_dbg(mcbsp->dev, "SPCR2: 0x%04x\n",
71 OMAP_MCBSP_READ(mcbsp->io_base, SPCR2)); 71 MCBSP_READ(mcbsp, SPCR2));
72 dev_dbg(mcbsp->dev, "SPCR1: 0x%04x\n", 72 dev_dbg(mcbsp->dev, "SPCR1: 0x%04x\n",
73 OMAP_MCBSP_READ(mcbsp->io_base, SPCR1)); 73 MCBSP_READ(mcbsp, SPCR1));
74 dev_dbg(mcbsp->dev, "RCR2: 0x%04x\n", 74 dev_dbg(mcbsp->dev, "RCR2: 0x%04x\n",
75 OMAP_MCBSP_READ(mcbsp->io_base, RCR2)); 75 MCBSP_READ(mcbsp, RCR2));
76 dev_dbg(mcbsp->dev, "RCR1: 0x%04x\n", 76 dev_dbg(mcbsp->dev, "RCR1: 0x%04x\n",
77 OMAP_MCBSP_READ(mcbsp->io_base, RCR1)); 77 MCBSP_READ(mcbsp, RCR1));
78 dev_dbg(mcbsp->dev, "XCR2: 0x%04x\n", 78 dev_dbg(mcbsp->dev, "XCR2: 0x%04x\n",
79 OMAP_MCBSP_READ(mcbsp->io_base, XCR2)); 79 MCBSP_READ(mcbsp, XCR2));
80 dev_dbg(mcbsp->dev, "XCR1: 0x%04x\n", 80 dev_dbg(mcbsp->dev, "XCR1: 0x%04x\n",
81 OMAP_MCBSP_READ(mcbsp->io_base, XCR1)); 81 MCBSP_READ(mcbsp, XCR1));
82 dev_dbg(mcbsp->dev, "SRGR2: 0x%04x\n", 82 dev_dbg(mcbsp->dev, "SRGR2: 0x%04x\n",
83 OMAP_MCBSP_READ(mcbsp->io_base, SRGR2)); 83 MCBSP_READ(mcbsp, SRGR2));
84 dev_dbg(mcbsp->dev, "SRGR1: 0x%04x\n", 84 dev_dbg(mcbsp->dev, "SRGR1: 0x%04x\n",
85 OMAP_MCBSP_READ(mcbsp->io_base, SRGR1)); 85 MCBSP_READ(mcbsp, SRGR1));
86 dev_dbg(mcbsp->dev, "PCR0: 0x%04x\n", 86 dev_dbg(mcbsp->dev, "PCR0: 0x%04x\n",
87 OMAP_MCBSP_READ(mcbsp->io_base, PCR0)); 87 MCBSP_READ(mcbsp, PCR0));
88 dev_dbg(mcbsp->dev, "***********************\n"); 88 dev_dbg(mcbsp->dev, "***********************\n");
89} 89}
90 90
@@ -93,15 +93,14 @@ static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id)
93 struct omap_mcbsp *mcbsp_tx = dev_id; 93 struct omap_mcbsp *mcbsp_tx = dev_id;
94 u16 irqst_spcr2; 94 u16 irqst_spcr2;
95 95
96 irqst_spcr2 = OMAP_MCBSP_READ(mcbsp_tx->io_base, SPCR2); 96 irqst_spcr2 = MCBSP_READ(mcbsp_tx, SPCR2);
97 dev_dbg(mcbsp_tx->dev, "TX IRQ callback : 0x%x\n", irqst_spcr2); 97 dev_dbg(mcbsp_tx->dev, "TX IRQ callback : 0x%x\n", irqst_spcr2);
98 98
99 if (irqst_spcr2 & XSYNC_ERR) { 99 if (irqst_spcr2 & XSYNC_ERR) {
100 dev_err(mcbsp_tx->dev, "TX Frame Sync Error! : 0x%x\n", 100 dev_err(mcbsp_tx->dev, "TX Frame Sync Error! : 0x%x\n",
101 irqst_spcr2); 101 irqst_spcr2);
102 /* Writing zero to XSYNC_ERR clears the IRQ */ 102 /* Writing zero to XSYNC_ERR clears the IRQ */
103 OMAP_MCBSP_WRITE(mcbsp_tx->io_base, SPCR2, 103 MCBSP_WRITE(mcbsp_tx, SPCR2, irqst_spcr2 & ~(XSYNC_ERR));
104 irqst_spcr2 & ~(XSYNC_ERR));
105 } else { 104 } else {
106 complete(&mcbsp_tx->tx_irq_completion); 105 complete(&mcbsp_tx->tx_irq_completion);
107 } 106 }
@@ -114,15 +113,14 @@ static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id)
114 struct omap_mcbsp *mcbsp_rx = dev_id; 113 struct omap_mcbsp *mcbsp_rx = dev_id;
115 u16 irqst_spcr1; 114 u16 irqst_spcr1;
116 115
117 irqst_spcr1 = OMAP_MCBSP_READ(mcbsp_rx->io_base, SPCR1); 116 irqst_spcr1 = MCBSP_READ(mcbsp_rx, SPCR1);
118 dev_dbg(mcbsp_rx->dev, "RX IRQ callback : 0x%x\n", irqst_spcr1); 117 dev_dbg(mcbsp_rx->dev, "RX IRQ callback : 0x%x\n", irqst_spcr1);
119 118
120 if (irqst_spcr1 & RSYNC_ERR) { 119 if (irqst_spcr1 & RSYNC_ERR) {
121 dev_err(mcbsp_rx->dev, "RX Frame Sync Error! : 0x%x\n", 120 dev_err(mcbsp_rx->dev, "RX Frame Sync Error! : 0x%x\n",
122 irqst_spcr1); 121 irqst_spcr1);
123 /* Writing zero to RSYNC_ERR clears the IRQ */ 122 /* Writing zero to RSYNC_ERR clears the IRQ */
124 OMAP_MCBSP_WRITE(mcbsp_rx->io_base, SPCR1, 123 MCBSP_WRITE(mcbsp_rx, SPCR1, irqst_spcr1 & ~(RSYNC_ERR));
125 irqst_spcr1 & ~(RSYNC_ERR));
126 } else { 124 } else {
127 complete(&mcbsp_rx->tx_irq_completion); 125 complete(&mcbsp_rx->tx_irq_completion);
128 } 126 }
@@ -135,7 +133,7 @@ static void omap_mcbsp_tx_dma_callback(int lch, u16 ch_status, void *data)
135 struct omap_mcbsp *mcbsp_dma_tx = data; 133 struct omap_mcbsp *mcbsp_dma_tx = data;
136 134
137 dev_dbg(mcbsp_dma_tx->dev, "TX DMA callback : 0x%x\n", 135 dev_dbg(mcbsp_dma_tx->dev, "TX DMA callback : 0x%x\n",
138 OMAP_MCBSP_READ(mcbsp_dma_tx->io_base, SPCR2)); 136 MCBSP_READ(mcbsp_dma_tx, SPCR2));
139 137
140 /* We can free the channels */ 138 /* We can free the channels */
141 omap_free_dma(mcbsp_dma_tx->dma_tx_lch); 139 omap_free_dma(mcbsp_dma_tx->dma_tx_lch);
@@ -149,7 +147,7 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
149 struct omap_mcbsp *mcbsp_dma_rx = data; 147 struct omap_mcbsp *mcbsp_dma_rx = data;
150 148
151 dev_dbg(mcbsp_dma_rx->dev, "RX DMA callback : 0x%x\n", 149 dev_dbg(mcbsp_dma_rx->dev, "RX DMA callback : 0x%x\n",
152 OMAP_MCBSP_READ(mcbsp_dma_rx->io_base, SPCR2)); 150 MCBSP_READ(mcbsp_dma_rx, SPCR2));
153 151
154 /* We can free the channels */ 152 /* We can free the channels */
155 omap_free_dma(mcbsp_dma_rx->dma_rx_lch); 153 omap_free_dma(mcbsp_dma_rx->dma_rx_lch);
@@ -167,7 +165,6 @@ static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
167void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config) 165void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
168{ 166{
169 struct omap_mcbsp *mcbsp; 167 struct omap_mcbsp *mcbsp;
170 void __iomem *io_base;
171 168
172 if (!omap_mcbsp_check_valid_id(id)) { 169 if (!omap_mcbsp_check_valid_id(id)) {
173 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 170 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
@@ -175,25 +172,24 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
175 } 172 }
176 mcbsp = id_to_mcbsp_ptr(id); 173 mcbsp = id_to_mcbsp_ptr(id);
177 174
178 io_base = mcbsp->io_base;
179 dev_dbg(mcbsp->dev, "Configuring McBSP%d phys_base: 0x%08lx\n", 175 dev_dbg(mcbsp->dev, "Configuring McBSP%d phys_base: 0x%08lx\n",
180 mcbsp->id, mcbsp->phys_base); 176 mcbsp->id, mcbsp->phys_base);
181 177
182 /* We write the given config */ 178 /* We write the given config */
183 OMAP_MCBSP_WRITE(io_base, SPCR2, config->spcr2); 179 MCBSP_WRITE(mcbsp, SPCR2, config->spcr2);
184 OMAP_MCBSP_WRITE(io_base, SPCR1, config->spcr1); 180 MCBSP_WRITE(mcbsp, SPCR1, config->spcr1);
185 OMAP_MCBSP_WRITE(io_base, RCR2, config->rcr2); 181 MCBSP_WRITE(mcbsp, RCR2, config->rcr2);
186 OMAP_MCBSP_WRITE(io_base, RCR1, config->rcr1); 182 MCBSP_WRITE(mcbsp, RCR1, config->rcr1);
187 OMAP_MCBSP_WRITE(io_base, XCR2, config->xcr2); 183 MCBSP_WRITE(mcbsp, XCR2, config->xcr2);
188 OMAP_MCBSP_WRITE(io_base, XCR1, config->xcr1); 184 MCBSP_WRITE(mcbsp, XCR1, config->xcr1);
189 OMAP_MCBSP_WRITE(io_base, SRGR2, config->srgr2); 185 MCBSP_WRITE(mcbsp, SRGR2, config->srgr2);
190 OMAP_MCBSP_WRITE(io_base, SRGR1, config->srgr1); 186 MCBSP_WRITE(mcbsp, SRGR1, config->srgr1);
191 OMAP_MCBSP_WRITE(io_base, MCR2, config->mcr2); 187 MCBSP_WRITE(mcbsp, MCR2, config->mcr2);
192 OMAP_MCBSP_WRITE(io_base, MCR1, config->mcr1); 188 MCBSP_WRITE(mcbsp, MCR1, config->mcr1);
193 OMAP_MCBSP_WRITE(io_base, PCR0, config->pcr0); 189 MCBSP_WRITE(mcbsp, PCR0, config->pcr0);
194 if (cpu_is_omap2430() || cpu_is_omap34xx() || cpu_is_omap44xx()) { 190 if (cpu_is_omap2430() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
195 OMAP_MCBSP_WRITE(io_base, XCCR, config->xccr); 191 MCBSP_WRITE(mcbsp, XCCR, config->xccr);
196 OMAP_MCBSP_WRITE(io_base, RCCR, config->rccr); 192 MCBSP_WRITE(mcbsp, RCCR, config->rccr);
197 } 193 }
198} 194}
199EXPORT_SYMBOL(omap_mcbsp_config); 195EXPORT_SYMBOL(omap_mcbsp_config);
@@ -207,7 +203,6 @@ EXPORT_SYMBOL(omap_mcbsp_config);
207void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold) 203void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold)
208{ 204{
209 struct omap_mcbsp *mcbsp; 205 struct omap_mcbsp *mcbsp;
210 void __iomem *io_base;
211 206
212 if (!cpu_is_omap34xx()) 207 if (!cpu_is_omap34xx())
213 return; 208 return;
@@ -217,9 +212,8 @@ void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold)
217 return; 212 return;
218 } 213 }
219 mcbsp = id_to_mcbsp_ptr(id); 214 mcbsp = id_to_mcbsp_ptr(id);
220 io_base = mcbsp->io_base;
221 215
222 OMAP_MCBSP_WRITE(io_base, THRSH2, threshold); 216 MCBSP_WRITE(mcbsp, THRSH2, threshold);
223} 217}
224EXPORT_SYMBOL(omap_mcbsp_set_tx_threshold); 218EXPORT_SYMBOL(omap_mcbsp_set_tx_threshold);
225 219
@@ -231,7 +225,6 @@ EXPORT_SYMBOL(omap_mcbsp_set_tx_threshold);
231void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold) 225void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold)
232{ 226{
233 struct omap_mcbsp *mcbsp; 227 struct omap_mcbsp *mcbsp;
234 void __iomem *io_base;
235 228
236 if (!cpu_is_omap34xx()) 229 if (!cpu_is_omap34xx())
237 return; 230 return;
@@ -241,9 +234,8 @@ void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold)
241 return; 234 return;
242 } 235 }
243 mcbsp = id_to_mcbsp_ptr(id); 236 mcbsp = id_to_mcbsp_ptr(id);
244 io_base = mcbsp->io_base;
245 237
246 OMAP_MCBSP_WRITE(io_base, THRSH1, threshold); 238 MCBSP_WRITE(mcbsp, THRSH1, threshold);
247} 239}
248EXPORT_SYMBOL(omap_mcbsp_set_rx_threshold); 240EXPORT_SYMBOL(omap_mcbsp_set_rx_threshold);
249 241
@@ -313,19 +305,18 @@ static inline void omap34xx_mcbsp_request(struct omap_mcbsp *mcbsp)
313 if (cpu_is_omap34xx()) { 305 if (cpu_is_omap34xx()) {
314 u16 syscon; 306 u16 syscon;
315 307
316 syscon = OMAP_MCBSP_READ(mcbsp->io_base, SYSCON); 308 syscon = MCBSP_READ(mcbsp, SYSCON);
317 syscon &= ~(ENAWAKEUP | SIDLEMODE(0x03) | CLOCKACTIVITY(0x03)); 309 syscon &= ~(ENAWAKEUP | SIDLEMODE(0x03) | CLOCKACTIVITY(0x03));
318 310
319 if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) { 311 if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) {
320 syscon |= (ENAWAKEUP | SIDLEMODE(0x02) | 312 syscon |= (ENAWAKEUP | SIDLEMODE(0x02) |
321 CLOCKACTIVITY(0x02)); 313 CLOCKACTIVITY(0x02));
322 OMAP_MCBSP_WRITE(mcbsp->io_base, WAKEUPEN, 314 MCBSP_WRITE(mcbsp, WAKEUPEN, XRDYEN | RRDYEN);
323 XRDYEN | RRDYEN);
324 } else { 315 } else {
325 syscon |= SIDLEMODE(0x01); 316 syscon |= SIDLEMODE(0x01);
326 } 317 }
327 318
328 OMAP_MCBSP_WRITE(mcbsp->io_base, SYSCON, syscon); 319 MCBSP_WRITE(mcbsp, SYSCON, syscon);
329 } 320 }
330} 321}
331 322
@@ -337,7 +328,7 @@ static inline void omap34xx_mcbsp_free(struct omap_mcbsp *mcbsp)
337 if (cpu_is_omap34xx()) { 328 if (cpu_is_omap34xx()) {
338 u16 syscon; 329 u16 syscon;
339 330
340 syscon = OMAP_MCBSP_READ(mcbsp->io_base, SYSCON); 331 syscon = MCBSP_READ(mcbsp, SYSCON);
341 syscon &= ~(ENAWAKEUP | SIDLEMODE(0x03) | CLOCKACTIVITY(0x03)); 332 syscon &= ~(ENAWAKEUP | SIDLEMODE(0x03) | CLOCKACTIVITY(0x03));
342 /* 333 /*
343 * HW bug workaround - If no_idle mode is taken, we need to 334 * HW bug workaround - If no_idle mode is taken, we need to
@@ -345,12 +336,12 @@ static inline void omap34xx_mcbsp_free(struct omap_mcbsp *mcbsp)
345 * device will not hit retention anymore. 336 * device will not hit retention anymore.
346 */ 337 */
347 syscon |= SIDLEMODE(0x02); 338 syscon |= SIDLEMODE(0x02);
348 OMAP_MCBSP_WRITE(mcbsp->io_base, SYSCON, syscon); 339 MCBSP_WRITE(mcbsp, SYSCON, syscon);
349 340
350 syscon &= ~(SIDLEMODE(0x03)); 341 syscon &= ~(SIDLEMODE(0x03));
351 OMAP_MCBSP_WRITE(mcbsp->io_base, SYSCON, syscon); 342 MCBSP_WRITE(mcbsp, SYSCON, syscon);
352 343
353 OMAP_MCBSP_WRITE(mcbsp->io_base, WAKEUPEN, 0); 344 MCBSP_WRITE(mcbsp, WAKEUPEN, 0);
354 } 345 }
355} 346}
356#else 347#else
@@ -424,8 +415,8 @@ int omap_mcbsp_request(unsigned int id)
424 * Make sure that transmitter, receiver and sample-rate generator are 415 * Make sure that transmitter, receiver and sample-rate generator are
425 * not running before activating IRQs. 416 * not running before activating IRQs.
426 */ 417 */
427 OMAP_MCBSP_WRITE(mcbsp->io_base, SPCR1, 0); 418 MCBSP_WRITE(mcbsp, SPCR1, 0);
428 OMAP_MCBSP_WRITE(mcbsp->io_base, SPCR2, 0); 419 MCBSP_WRITE(mcbsp, SPCR2, 0);
429 420
430 if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) { 421 if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
431 /* We need to get IRQs here */ 422 /* We need to get IRQs here */
@@ -515,7 +506,6 @@ EXPORT_SYMBOL(omap_mcbsp_free);
515void omap_mcbsp_start(unsigned int id, int tx, int rx) 506void omap_mcbsp_start(unsigned int id, int tx, int rx)
516{ 507{
517 struct omap_mcbsp *mcbsp; 508 struct omap_mcbsp *mcbsp;
518 void __iomem *io_base;
519 int idle; 509 int idle;
520 u16 w; 510 u16 w;
521 511
@@ -524,28 +514,26 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx)
524 return; 514 return;
525 } 515 }
526 mcbsp = id_to_mcbsp_ptr(id); 516 mcbsp = id_to_mcbsp_ptr(id);
527 io_base = mcbsp->io_base;
528 517
529 mcbsp->rx_word_length = (OMAP_MCBSP_READ(io_base, RCR1) >> 5) & 0x7; 518 mcbsp->rx_word_length = (MCBSP_READ(mcbsp, RCR1) >> 5) & 0x7;
530 mcbsp->tx_word_length = (OMAP_MCBSP_READ(io_base, XCR1) >> 5) & 0x7; 519 mcbsp->tx_word_length = (MCBSP_READ(mcbsp, XCR1) >> 5) & 0x7;
531 520
532 idle = !((OMAP_MCBSP_READ(io_base, SPCR2) | 521 idle = !((MCBSP_READ(mcbsp, SPCR2) | MCBSP_READ(mcbsp, SPCR1)) & 1);
533 OMAP_MCBSP_READ(io_base, SPCR1)) & 1);
534 522
535 if (idle) { 523 if (idle) {
536 /* Start the sample generator */ 524 /* Start the sample generator */
537 w = OMAP_MCBSP_READ(io_base, SPCR2); 525 w = MCBSP_READ(mcbsp, SPCR2);
538 OMAP_MCBSP_WRITE(io_base, SPCR2, w | (1 << 6)); 526 MCBSP_WRITE(mcbsp, SPCR2, w | (1 << 6));
539 } 527 }
540 528
541 /* Enable transmitter and receiver */ 529 /* Enable transmitter and receiver */
542 tx &= 1; 530 tx &= 1;
543 w = OMAP_MCBSP_READ(io_base, SPCR2); 531 w = MCBSP_READ(mcbsp, SPCR2);
544 OMAP_MCBSP_WRITE(io_base, SPCR2, w | tx); 532 MCBSP_WRITE(mcbsp, SPCR2, w | tx);
545 533
546 rx &= 1; 534 rx &= 1;
547 w = OMAP_MCBSP_READ(io_base, SPCR1); 535 w = MCBSP_READ(mcbsp, SPCR1);
548 OMAP_MCBSP_WRITE(io_base, SPCR1, w | rx); 536 MCBSP_WRITE(mcbsp, SPCR1, w | rx);
549 537
550 /* 538 /*
551 * Worst case: CLKSRG*2 = 8000khz: (1/8000) * 2 * 2 usec 539 * Worst case: CLKSRG*2 = 8000khz: (1/8000) * 2 * 2 usec
@@ -557,18 +545,18 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx)
557 545
558 if (idle) { 546 if (idle) {
559 /* Start frame sync */ 547 /* Start frame sync */
560 w = OMAP_MCBSP_READ(io_base, SPCR2); 548 w = MCBSP_READ(mcbsp, SPCR2);
561 OMAP_MCBSP_WRITE(io_base, SPCR2, w | (1 << 7)); 549 MCBSP_WRITE(mcbsp, SPCR2, w | (1 << 7));
562 } 550 }
563 551
564 if (cpu_is_omap2430() || cpu_is_omap34xx()) { 552 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
565 /* Release the transmitter and receiver */ 553 /* Release the transmitter and receiver */
566 w = OMAP_MCBSP_READ(io_base, XCCR); 554 w = MCBSP_READ(mcbsp, XCCR);
567 w &= ~(tx ? XDISABLE : 0); 555 w &= ~(tx ? XDISABLE : 0);
568 OMAP_MCBSP_WRITE(io_base, XCCR, w); 556 MCBSP_WRITE(mcbsp, XCCR, w);
569 w = OMAP_MCBSP_READ(io_base, RCCR); 557 w = MCBSP_READ(mcbsp, RCCR);
570 w &= ~(rx ? RDISABLE : 0); 558 w &= ~(rx ? RDISABLE : 0);
571 OMAP_MCBSP_WRITE(io_base, RCCR, w); 559 MCBSP_WRITE(mcbsp, RCCR, w);
572 } 560 }
573 561
574 /* Dump McBSP Regs */ 562 /* Dump McBSP Regs */
@@ -579,7 +567,6 @@ EXPORT_SYMBOL(omap_mcbsp_start);
579void omap_mcbsp_stop(unsigned int id, int tx, int rx) 567void omap_mcbsp_stop(unsigned int id, int tx, int rx)
580{ 568{
581 struct omap_mcbsp *mcbsp; 569 struct omap_mcbsp *mcbsp;
582 void __iomem *io_base;
583 int idle; 570 int idle;
584 u16 w; 571 u16 w;
585 572
@@ -589,35 +576,33 @@ void omap_mcbsp_stop(unsigned int id, int tx, int rx)
589 } 576 }
590 577
591 mcbsp = id_to_mcbsp_ptr(id); 578 mcbsp = id_to_mcbsp_ptr(id);
592 io_base = mcbsp->io_base;
593 579
594 /* Reset transmitter */ 580 /* Reset transmitter */
595 tx &= 1; 581 tx &= 1;
596 if (cpu_is_omap2430() || cpu_is_omap34xx()) { 582 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
597 w = OMAP_MCBSP_READ(io_base, XCCR); 583 w = MCBSP_READ(mcbsp, XCCR);
598 w |= (tx ? XDISABLE : 0); 584 w |= (tx ? XDISABLE : 0);
599 OMAP_MCBSP_WRITE(io_base, XCCR, w); 585 MCBSP_WRITE(mcbsp, XCCR, w);
600 } 586 }
601 w = OMAP_MCBSP_READ(io_base, SPCR2); 587 w = MCBSP_READ(mcbsp, SPCR2);
602 OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~tx); 588 MCBSP_WRITE(mcbsp, SPCR2, w & ~tx);
603 589
604 /* Reset receiver */ 590 /* Reset receiver */
605 rx &= 1; 591 rx &= 1;
606 if (cpu_is_omap2430() || cpu_is_omap34xx()) { 592 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
607 w = OMAP_MCBSP_READ(io_base, RCCR); 593 w = MCBSP_READ(mcbsp, RCCR);
608 w |= (rx ? RDISABLE : 0); 594 w |= (rx ? RDISABLE : 0);
609 OMAP_MCBSP_WRITE(io_base, RCCR, w); 595 MCBSP_WRITE(mcbsp, RCCR, w);
610 } 596 }
611 w = OMAP_MCBSP_READ(io_base, SPCR1); 597 w = MCBSP_READ(mcbsp, SPCR1);
612 OMAP_MCBSP_WRITE(io_base, SPCR1, w & ~rx); 598 MCBSP_WRITE(mcbsp, SPCR1, w & ~rx);
613 599
614 idle = !((OMAP_MCBSP_READ(io_base, SPCR2) | 600 idle = !((MCBSP_READ(mcbsp, SPCR2) | MCBSP_READ(mcbsp, SPCR1)) & 1);
615 OMAP_MCBSP_READ(io_base, SPCR1)) & 1);
616 601
617 if (idle) { 602 if (idle) {
618 /* Reset the sample rate generator */ 603 /* Reset the sample rate generator */
619 w = OMAP_MCBSP_READ(io_base, SPCR2); 604 w = MCBSP_READ(mcbsp, SPCR2);
620 OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1 << 6)); 605 MCBSP_WRITE(mcbsp, SPCR2, w & ~(1 << 6));
621 } 606 }
622} 607}
623EXPORT_SYMBOL(omap_mcbsp_stop); 608EXPORT_SYMBOL(omap_mcbsp_stop);
@@ -626,7 +611,6 @@ EXPORT_SYMBOL(omap_mcbsp_stop);
626int omap_mcbsp_pollwrite(unsigned int id, u16 buf) 611int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
627{ 612{
628 struct omap_mcbsp *mcbsp; 613 struct omap_mcbsp *mcbsp;
629 void __iomem *base;
630 614
631 if (!omap_mcbsp_check_valid_id(id)) { 615 if (!omap_mcbsp_check_valid_id(id)) {
632 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 616 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
@@ -634,28 +618,25 @@ int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
634 } 618 }
635 619
636 mcbsp = id_to_mcbsp_ptr(id); 620 mcbsp = id_to_mcbsp_ptr(id);
637 base = mcbsp->io_base;
638 621
639 OMAP_MCBSP_WRITE(base, DXR1, buf); 622 MCBSP_WRITE(mcbsp, DXR1, buf);
640 /* if frame sync error - clear the error */ 623 /* if frame sync error - clear the error */
641 if (OMAP_MCBSP_READ(base, SPCR2) & XSYNC_ERR) { 624 if (MCBSP_READ(mcbsp, SPCR2) & XSYNC_ERR) {
642 /* clear error */ 625 /* clear error */
643 OMAP_MCBSP_WRITE(base, SPCR2, 626 MCBSP_WRITE(mcbsp, SPCR2,
644 OMAP_MCBSP_READ(base, SPCR2) & (~XSYNC_ERR)); 627 MCBSP_READ(mcbsp, SPCR2) & (~XSYNC_ERR));
645 /* resend */ 628 /* resend */
646 return -1; 629 return -1;
647 } else { 630 } else {
648 /* wait for transmit confirmation */ 631 /* wait for transmit confirmation */
649 int attemps = 0; 632 int attemps = 0;
650 while (!(OMAP_MCBSP_READ(base, SPCR2) & XRDY)) { 633 while (!(MCBSP_READ(mcbsp, SPCR2) & XRDY)) {
651 if (attemps++ > 1000) { 634 if (attemps++ > 1000) {
652 OMAP_MCBSP_WRITE(base, SPCR2, 635 MCBSP_WRITE(mcbsp, SPCR2,
653 OMAP_MCBSP_READ(base, SPCR2) & 636 MCBSP_READ(mcbsp, SPCR2) & (~XRST));
654 (~XRST));
655 udelay(10); 637 udelay(10);
656 OMAP_MCBSP_WRITE(base, SPCR2, 638 MCBSP_WRITE(mcbsp, SPCR2,
657 OMAP_MCBSP_READ(base, SPCR2) | 639 MCBSP_READ(mcbsp, SPCR2) | (XRST));
658 (XRST));
659 udelay(10); 640 udelay(10);
660 dev_err(mcbsp->dev, "Could not write to" 641 dev_err(mcbsp->dev, "Could not write to"
661 " McBSP%d Register\n", mcbsp->id); 642 " McBSP%d Register\n", mcbsp->id);
@@ -671,7 +652,6 @@ EXPORT_SYMBOL(omap_mcbsp_pollwrite);
671int omap_mcbsp_pollread(unsigned int id, u16 *buf) 652int omap_mcbsp_pollread(unsigned int id, u16 *buf)
672{ 653{
673 struct omap_mcbsp *mcbsp; 654 struct omap_mcbsp *mcbsp;
674 void __iomem *base;
675 655
676 if (!omap_mcbsp_check_valid_id(id)) { 656 if (!omap_mcbsp_check_valid_id(id)) {
677 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 657 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
@@ -679,26 +659,23 @@ int omap_mcbsp_pollread(unsigned int id, u16 *buf)
679 } 659 }
680 mcbsp = id_to_mcbsp_ptr(id); 660 mcbsp = id_to_mcbsp_ptr(id);
681 661
682 base = mcbsp->io_base;
683 /* if frame sync error - clear the error */ 662 /* if frame sync error - clear the error */
684 if (OMAP_MCBSP_READ(base, SPCR1) & RSYNC_ERR) { 663 if (MCBSP_READ(mcbsp, SPCR1) & RSYNC_ERR) {
685 /* clear error */ 664 /* clear error */
686 OMAP_MCBSP_WRITE(base, SPCR1, 665 MCBSP_WRITE(mcbsp, SPCR1,
687 OMAP_MCBSP_READ(base, SPCR1) & (~RSYNC_ERR)); 666 MCBSP_READ(mcbsp, SPCR1) & (~RSYNC_ERR));
688 /* resend */ 667 /* resend */
689 return -1; 668 return -1;
690 } else { 669 } else {
691 /* wait for recieve confirmation */ 670 /* wait for recieve confirmation */
692 int attemps = 0; 671 int attemps = 0;
693 while (!(OMAP_MCBSP_READ(base, SPCR1) & RRDY)) { 672 while (!(MCBSP_READ(mcbsp, SPCR1) & RRDY)) {
694 if (attemps++ > 1000) { 673 if (attemps++ > 1000) {
695 OMAP_MCBSP_WRITE(base, SPCR1, 674 MCBSP_WRITE(mcbsp, SPCR1,
696 OMAP_MCBSP_READ(base, SPCR1) & 675 MCBSP_READ(mcbsp, SPCR1) & (~RRST));
697 (~RRST));
698 udelay(10); 676 udelay(10);
699 OMAP_MCBSP_WRITE(base, SPCR1, 677 MCBSP_WRITE(mcbsp, SPCR1,
700 OMAP_MCBSP_READ(base, SPCR1) | 678 MCBSP_READ(mcbsp, SPCR1) | (RRST));
701 (RRST));
702 udelay(10); 679 udelay(10);
703 dev_err(mcbsp->dev, "Could not read from" 680 dev_err(mcbsp->dev, "Could not read from"
704 " McBSP%d Register\n", mcbsp->id); 681 " McBSP%d Register\n", mcbsp->id);
@@ -706,7 +683,7 @@ int omap_mcbsp_pollread(unsigned int id, u16 *buf)
706 } 683 }
707 } 684 }
708 } 685 }
709 *buf = OMAP_MCBSP_READ(base, DRR1); 686 *buf = MCBSP_READ(mcbsp, DRR1);
710 687
711 return 0; 688 return 0;
712} 689}
@@ -718,7 +695,6 @@ EXPORT_SYMBOL(omap_mcbsp_pollread);
718void omap_mcbsp_xmit_word(unsigned int id, u32 word) 695void omap_mcbsp_xmit_word(unsigned int id, u32 word)
719{ 696{
720 struct omap_mcbsp *mcbsp; 697 struct omap_mcbsp *mcbsp;
721 void __iomem *io_base;
722 omap_mcbsp_word_length word_length; 698 omap_mcbsp_word_length word_length;
723 699
724 if (!omap_mcbsp_check_valid_id(id)) { 700 if (!omap_mcbsp_check_valid_id(id)) {
@@ -727,21 +703,19 @@ void omap_mcbsp_xmit_word(unsigned int id, u32 word)
727 } 703 }
728 704
729 mcbsp = id_to_mcbsp_ptr(id); 705 mcbsp = id_to_mcbsp_ptr(id);
730 io_base = mcbsp->io_base;
731 word_length = mcbsp->tx_word_length; 706 word_length = mcbsp->tx_word_length;
732 707
733 wait_for_completion(&mcbsp->tx_irq_completion); 708 wait_for_completion(&mcbsp->tx_irq_completion);
734 709
735 if (word_length > OMAP_MCBSP_WORD_16) 710 if (word_length > OMAP_MCBSP_WORD_16)
736 OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16); 711 MCBSP_WRITE(mcbsp, DXR2, word >> 16);
737 OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff); 712 MCBSP_WRITE(mcbsp, DXR1, word & 0xffff);
738} 713}
739EXPORT_SYMBOL(omap_mcbsp_xmit_word); 714EXPORT_SYMBOL(omap_mcbsp_xmit_word);
740 715
741u32 omap_mcbsp_recv_word(unsigned int id) 716u32 omap_mcbsp_recv_word(unsigned int id)
742{ 717{
743 struct omap_mcbsp *mcbsp; 718 struct omap_mcbsp *mcbsp;
744 void __iomem *io_base;
745 u16 word_lsb, word_msb = 0; 719 u16 word_lsb, word_msb = 0;
746 omap_mcbsp_word_length word_length; 720 omap_mcbsp_word_length word_length;
747 721
@@ -752,13 +726,12 @@ u32 omap_mcbsp_recv_word(unsigned int id)
752 mcbsp = id_to_mcbsp_ptr(id); 726 mcbsp = id_to_mcbsp_ptr(id);
753 727
754 word_length = mcbsp->rx_word_length; 728 word_length = mcbsp->rx_word_length;
755 io_base = mcbsp->io_base;
756 729
757 wait_for_completion(&mcbsp->rx_irq_completion); 730 wait_for_completion(&mcbsp->rx_irq_completion);
758 731
759 if (word_length > OMAP_MCBSP_WORD_16) 732 if (word_length > OMAP_MCBSP_WORD_16)
760 word_msb = OMAP_MCBSP_READ(io_base, DRR2); 733 word_msb = MCBSP_READ(mcbsp, DRR2);
761 word_lsb = OMAP_MCBSP_READ(io_base, DRR1); 734 word_lsb = MCBSP_READ(mcbsp, DRR1);
762 735
763 return (word_lsb | (word_msb << 16)); 736 return (word_lsb | (word_msb << 16));
764} 737}
@@ -767,7 +740,6 @@ EXPORT_SYMBOL(omap_mcbsp_recv_word);
767int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word) 740int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
768{ 741{
769 struct omap_mcbsp *mcbsp; 742 struct omap_mcbsp *mcbsp;
770 void __iomem *io_base;
771 omap_mcbsp_word_length tx_word_length; 743 omap_mcbsp_word_length tx_word_length;
772 omap_mcbsp_word_length rx_word_length; 744 omap_mcbsp_word_length rx_word_length;
773 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0; 745 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0;
@@ -777,7 +749,6 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
777 return -ENODEV; 749 return -ENODEV;
778 } 750 }
779 mcbsp = id_to_mcbsp_ptr(id); 751 mcbsp = id_to_mcbsp_ptr(id);
780 io_base = mcbsp->io_base;
781 tx_word_length = mcbsp->tx_word_length; 752 tx_word_length = mcbsp->tx_word_length;
782 rx_word_length = mcbsp->rx_word_length; 753 rx_word_length = mcbsp->rx_word_length;
783 754
@@ -785,14 +756,14 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
785 return -EINVAL; 756 return -EINVAL;
786 757
787 /* First we wait for the transmitter to be ready */ 758 /* First we wait for the transmitter to be ready */
788 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2); 759 spcr2 = MCBSP_READ(mcbsp, SPCR2);
789 while (!(spcr2 & XRDY)) { 760 while (!(spcr2 & XRDY)) {
790 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2); 761 spcr2 = MCBSP_READ(mcbsp, SPCR2);
791 if (attempts++ > 1000) { 762 if (attempts++ > 1000) {
792 /* We must reset the transmitter */ 763 /* We must reset the transmitter */
793 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 & (~XRST)); 764 MCBSP_WRITE(mcbsp, SPCR2, spcr2 & (~XRST));
794 udelay(10); 765 udelay(10);
795 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST); 766 MCBSP_WRITE(mcbsp, SPCR2, spcr2 | XRST);
796 udelay(10); 767 udelay(10);
797 dev_err(mcbsp->dev, "McBSP%d transmitter not " 768 dev_err(mcbsp->dev, "McBSP%d transmitter not "
798 "ready\n", mcbsp->id); 769 "ready\n", mcbsp->id);
@@ -802,18 +773,18 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
802 773
803 /* Now we can push the data */ 774 /* Now we can push the data */
804 if (tx_word_length > OMAP_MCBSP_WORD_16) 775 if (tx_word_length > OMAP_MCBSP_WORD_16)
805 OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16); 776 MCBSP_WRITE(mcbsp, DXR2, word >> 16);
806 OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff); 777 MCBSP_WRITE(mcbsp, DXR1, word & 0xffff);
807 778
808 /* We wait for the receiver to be ready */ 779 /* We wait for the receiver to be ready */
809 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1); 780 spcr1 = MCBSP_READ(mcbsp, SPCR1);
810 while (!(spcr1 & RRDY)) { 781 while (!(spcr1 & RRDY)) {
811 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1); 782 spcr1 = MCBSP_READ(mcbsp, SPCR1);
812 if (attempts++ > 1000) { 783 if (attempts++ > 1000) {
813 /* We must reset the receiver */ 784 /* We must reset the receiver */
814 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 & (~RRST)); 785 MCBSP_WRITE(mcbsp, SPCR1, spcr1 & (~RRST));
815 udelay(10); 786 udelay(10);
816 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST); 787 MCBSP_WRITE(mcbsp, SPCR1, spcr1 | RRST);
817 udelay(10); 788 udelay(10);
818 dev_err(mcbsp->dev, "McBSP%d receiver not " 789 dev_err(mcbsp->dev, "McBSP%d receiver not "
819 "ready\n", mcbsp->id); 790 "ready\n", mcbsp->id);
@@ -823,8 +794,8 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
823 794
824 /* Receiver is ready, let's read the dummy data */ 795 /* Receiver is ready, let's read the dummy data */
825 if (rx_word_length > OMAP_MCBSP_WORD_16) 796 if (rx_word_length > OMAP_MCBSP_WORD_16)
826 word_msb = OMAP_MCBSP_READ(io_base, DRR2); 797 word_msb = MCBSP_READ(mcbsp, DRR2);
827 word_lsb = OMAP_MCBSP_READ(io_base, DRR1); 798 word_lsb = MCBSP_READ(mcbsp, DRR1);
828 799
829 return 0; 800 return 0;
830} 801}
@@ -834,7 +805,6 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
834{ 805{
835 struct omap_mcbsp *mcbsp; 806 struct omap_mcbsp *mcbsp;
836 u32 clock_word = 0; 807 u32 clock_word = 0;
837 void __iomem *io_base;
838 omap_mcbsp_word_length tx_word_length; 808 omap_mcbsp_word_length tx_word_length;
839 omap_mcbsp_word_length rx_word_length; 809 omap_mcbsp_word_length rx_word_length;
840 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0; 810 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0;
@@ -845,7 +815,6 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
845 } 815 }
846 816
847 mcbsp = id_to_mcbsp_ptr(id); 817 mcbsp = id_to_mcbsp_ptr(id);
848 io_base = mcbsp->io_base;
849 818
850 tx_word_length = mcbsp->tx_word_length; 819 tx_word_length = mcbsp->tx_word_length;
851 rx_word_length = mcbsp->rx_word_length; 820 rx_word_length = mcbsp->rx_word_length;
@@ -854,14 +823,14 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
854 return -EINVAL; 823 return -EINVAL;
855 824
856 /* First we wait for the transmitter to be ready */ 825 /* First we wait for the transmitter to be ready */
857 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2); 826 spcr2 = MCBSP_READ(mcbsp, SPCR2);
858 while (!(spcr2 & XRDY)) { 827 while (!(spcr2 & XRDY)) {
859 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2); 828 spcr2 = MCBSP_READ(mcbsp, SPCR2);
860 if (attempts++ > 1000) { 829 if (attempts++ > 1000) {
861 /* We must reset the transmitter */ 830 /* We must reset the transmitter */
862 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 & (~XRST)); 831 MCBSP_WRITE(mcbsp, SPCR2, spcr2 & (~XRST));
863 udelay(10); 832 udelay(10);
864 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST); 833 MCBSP_WRITE(mcbsp, SPCR2, spcr2 | XRST);
865 udelay(10); 834 udelay(10);
866 dev_err(mcbsp->dev, "McBSP%d transmitter not " 835 dev_err(mcbsp->dev, "McBSP%d transmitter not "
867 "ready\n", mcbsp->id); 836 "ready\n", mcbsp->id);
@@ -871,18 +840,18 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
871 840
872 /* We first need to enable the bus clock */ 841 /* We first need to enable the bus clock */
873 if (tx_word_length > OMAP_MCBSP_WORD_16) 842 if (tx_word_length > OMAP_MCBSP_WORD_16)
874 OMAP_MCBSP_WRITE(io_base, DXR2, clock_word >> 16); 843 MCBSP_WRITE(mcbsp, DXR2, clock_word >> 16);
875 OMAP_MCBSP_WRITE(io_base, DXR1, clock_word & 0xffff); 844 MCBSP_WRITE(mcbsp, DXR1, clock_word & 0xffff);
876 845
877 /* We wait for the receiver to be ready */ 846 /* We wait for the receiver to be ready */
878 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1); 847 spcr1 = MCBSP_READ(mcbsp, SPCR1);
879 while (!(spcr1 & RRDY)) { 848 while (!(spcr1 & RRDY)) {
880 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1); 849 spcr1 = MCBSP_READ(mcbsp, SPCR1);
881 if (attempts++ > 1000) { 850 if (attempts++ > 1000) {
882 /* We must reset the receiver */ 851 /* We must reset the receiver */
883 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 & (~RRST)); 852 MCBSP_WRITE(mcbsp, SPCR1, spcr1 & (~RRST));
884 udelay(10); 853 udelay(10);
885 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST); 854 MCBSP_WRITE(mcbsp, SPCR1, spcr1 | RRST);
886 udelay(10); 855 udelay(10);
887 dev_err(mcbsp->dev, "McBSP%d receiver not " 856 dev_err(mcbsp->dev, "McBSP%d receiver not "
888 "ready\n", mcbsp->id); 857 "ready\n", mcbsp->id);
@@ -892,8 +861,8 @@ int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
892 861
893 /* Receiver is ready, there is something for us */ 862 /* Receiver is ready, there is something for us */
894 if (rx_word_length > OMAP_MCBSP_WORD_16) 863 if (rx_word_length > OMAP_MCBSP_WORD_16)
895 word_msb = OMAP_MCBSP_READ(io_base, DRR2); 864 word_msb = MCBSP_READ(mcbsp, DRR2);
896 word_lsb = OMAP_MCBSP_READ(io_base, DRR1); 865 word_lsb = MCBSP_READ(mcbsp, DRR1);
897 866
898 word[0] = (word_lsb | (word_msb << 16)); 867 word[0] = (word_lsb | (word_msb << 16));
899 868