aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/amba/bus.c348
-rw-r--r--drivers/char/hw_random/nomadik-rng.c2
-rw-r--r--drivers/dma/amba-pl08x.c2
-rw-r--r--drivers/dma/pl330.c2
-rw-r--r--drivers/gpio/pl061.c2
-rw-r--r--drivers/input/serio/ambakmi.c3
-rw-r--r--drivers/mmc/host/mmci.c348
-rw-r--r--drivers/mmc/host/mmci.h15
-rw-r--r--drivers/rtc/rtc-pl030.c2
-rw-r--r--drivers/rtc/rtc-pl031.c2
-rw-r--r--drivers/spi/amba-pl022.c2
-rw-r--r--drivers/tty/serial/amba-pl010.c2
-rw-r--r--drivers/tty/serial/amba-pl011.c2
-rw-r--r--drivers/video/amba-clcd.c2
-rw-r--r--drivers/watchdog/sp805_wdt.c2
15 files changed, 650 insertions, 86 deletions
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index e7df019d29d4..6d2bb2524b6e 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -13,16 +13,17 @@
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/pm.h>
17#include <linux/pm_runtime.h>
16#include <linux/amba/bus.h> 18#include <linux/amba/bus.h>
17 19
18#include <asm/irq.h> 20#include <asm/irq.h>
19#include <asm/sizes.h> 21#include <asm/sizes.h>
20 22
21#define to_amba_device(d) container_of(d, struct amba_device, dev)
22#define to_amba_driver(d) container_of(d, struct amba_driver, drv) 23#define to_amba_driver(d) container_of(d, struct amba_driver, drv)
23 24
24static struct amba_id * 25static const struct amba_id *
25amba_lookup(struct amba_id *table, struct amba_device *dev) 26amba_lookup(const struct amba_id *table, struct amba_device *dev)
26{ 27{
27 int ret = 0; 28 int ret = 0;
28 29
@@ -57,26 +58,6 @@ static int amba_uevent(struct device *dev, struct kobj_uevent_env *env)
57#define amba_uevent NULL 58#define amba_uevent NULL
58#endif 59#endif
59 60
60static int amba_suspend(struct device *dev, pm_message_t state)
61{
62 struct amba_driver *drv = to_amba_driver(dev->driver);
63 int ret = 0;
64
65 if (dev->driver && drv->suspend)
66 ret = drv->suspend(to_amba_device(dev), state);
67 return ret;
68}
69
70static int amba_resume(struct device *dev)
71{
72 struct amba_driver *drv = to_amba_driver(dev->driver);
73 int ret = 0;
74
75 if (dev->driver && drv->resume)
76 ret = drv->resume(to_amba_device(dev));
77 return ret;
78}
79
80#define amba_attr_func(name,fmt,arg...) \ 61#define amba_attr_func(name,fmt,arg...) \
81static ssize_t name##_show(struct device *_dev, \ 62static ssize_t name##_show(struct device *_dev, \
82 struct device_attribute *attr, char *buf) \ 63 struct device_attribute *attr, char *buf) \
@@ -102,17 +83,330 @@ static struct device_attribute amba_dev_attrs[] = {
102 __ATTR_NULL, 83 __ATTR_NULL,
103}; 84};
104 85
86#ifdef CONFIG_PM_SLEEP
87
88static int amba_legacy_suspend(struct device *dev, pm_message_t mesg)
89{
90 struct amba_driver *adrv = to_amba_driver(dev->driver);
91 struct amba_device *adev = to_amba_device(dev);
92 int ret = 0;
93
94 if (dev->driver && adrv->suspend)
95 ret = adrv->suspend(adev, mesg);
96
97 return ret;
98}
99
100static int amba_legacy_resume(struct device *dev)
101{
102 struct amba_driver *adrv = to_amba_driver(dev->driver);
103 struct amba_device *adev = to_amba_device(dev);
104 int ret = 0;
105
106 if (dev->driver && adrv->resume)
107 ret = adrv->resume(adev);
108
109 return ret;
110}
111
112static int amba_pm_prepare(struct device *dev)
113{
114 struct device_driver *drv = dev->driver;
115 int ret = 0;
116
117 if (drv && drv->pm && drv->pm->prepare)
118 ret = drv->pm->prepare(dev);
119
120 return ret;
121}
122
123static void amba_pm_complete(struct device *dev)
124{
125 struct device_driver *drv = dev->driver;
126
127 if (drv && drv->pm && drv->pm->complete)
128 drv->pm->complete(dev);
129}
130
131#else /* !CONFIG_PM_SLEEP */
132
133#define amba_pm_prepare NULL
134#define amba_pm_complete NULL
135
136#endif /* !CONFIG_PM_SLEEP */
137
138#ifdef CONFIG_SUSPEND
139
140static int amba_pm_suspend(struct device *dev)
141{
142 struct device_driver *drv = dev->driver;
143 int ret = 0;
144
145 if (!drv)
146 return 0;
147
148 if (drv->pm) {
149 if (drv->pm->suspend)
150 ret = drv->pm->suspend(dev);
151 } else {
152 ret = amba_legacy_suspend(dev, PMSG_SUSPEND);
153 }
154
155 return ret;
156}
157
158static int amba_pm_suspend_noirq(struct device *dev)
159{
160 struct device_driver *drv = dev->driver;
161 int ret = 0;
162
163 if (!drv)
164 return 0;
165
166 if (drv->pm) {
167 if (drv->pm->suspend_noirq)
168 ret = drv->pm->suspend_noirq(dev);
169 }
170
171 return ret;
172}
173
174static int amba_pm_resume(struct device *dev)
175{
176 struct device_driver *drv = dev->driver;
177 int ret = 0;
178
179 if (!drv)
180 return 0;
181
182 if (drv->pm) {
183 if (drv->pm->resume)
184 ret = drv->pm->resume(dev);
185 } else {
186 ret = amba_legacy_resume(dev);
187 }
188
189 return ret;
190}
191
192static int amba_pm_resume_noirq(struct device *dev)
193{
194 struct device_driver *drv = dev->driver;
195 int ret = 0;
196
197 if (!drv)
198 return 0;
199
200 if (drv->pm) {
201 if (drv->pm->resume_noirq)
202 ret = drv->pm->resume_noirq(dev);
203 }
204
205 return ret;
206}
207
208#else /* !CONFIG_SUSPEND */
209
210#define amba_pm_suspend NULL
211#define amba_pm_resume NULL
212#define amba_pm_suspend_noirq NULL
213#define amba_pm_resume_noirq NULL
214
215#endif /* !CONFIG_SUSPEND */
216
217#ifdef CONFIG_HIBERNATION
218
219static int amba_pm_freeze(struct device *dev)
220{
221 struct device_driver *drv = dev->driver;
222 int ret = 0;
223
224 if (!drv)
225 return 0;
226
227 if (drv->pm) {
228 if (drv->pm->freeze)
229 ret = drv->pm->freeze(dev);
230 } else {
231 ret = amba_legacy_suspend(dev, PMSG_FREEZE);
232 }
233
234 return ret;
235}
236
237static int amba_pm_freeze_noirq(struct device *dev)
238{
239 struct device_driver *drv = dev->driver;
240 int ret = 0;
241
242 if (!drv)
243 return 0;
244
245 if (drv->pm) {
246 if (drv->pm->freeze_noirq)
247 ret = drv->pm->freeze_noirq(dev);
248 }
249
250 return ret;
251}
252
253static int amba_pm_thaw(struct device *dev)
254{
255 struct device_driver *drv = dev->driver;
256 int ret = 0;
257
258 if (!drv)
259 return 0;
260
261 if (drv->pm) {
262 if (drv->pm->thaw)
263 ret = drv->pm->thaw(dev);
264 } else {
265 ret = amba_legacy_resume(dev);
266 }
267
268 return ret;
269}
270
271static int amba_pm_thaw_noirq(struct device *dev)
272{
273 struct device_driver *drv = dev->driver;
274 int ret = 0;
275
276 if (!drv)
277 return 0;
278
279 if (drv->pm) {
280 if (drv->pm->thaw_noirq)
281 ret = drv->pm->thaw_noirq(dev);
282 }
283
284 return ret;
285}
286
287static int amba_pm_poweroff(struct device *dev)
288{
289 struct device_driver *drv = dev->driver;
290 int ret = 0;
291
292 if (!drv)
293 return 0;
294
295 if (drv->pm) {
296 if (drv->pm->poweroff)
297 ret = drv->pm->poweroff(dev);
298 } else {
299 ret = amba_legacy_suspend(dev, PMSG_HIBERNATE);
300 }
301
302 return ret;
303}
304
305static int amba_pm_poweroff_noirq(struct device *dev)
306{
307 struct device_driver *drv = dev->driver;
308 int ret = 0;
309
310 if (!drv)
311 return 0;
312
313 if (drv->pm) {
314 if (drv->pm->poweroff_noirq)
315 ret = drv->pm->poweroff_noirq(dev);
316 }
317
318 return ret;
319}
320
321static int amba_pm_restore(struct device *dev)
322{
323 struct device_driver *drv = dev->driver;
324 int ret = 0;
325
326 if (!drv)
327 return 0;
328
329 if (drv->pm) {
330 if (drv->pm->restore)
331 ret = drv->pm->restore(dev);
332 } else {
333 ret = amba_legacy_resume(dev);
334 }
335
336 return ret;
337}
338
339static int amba_pm_restore_noirq(struct device *dev)
340{
341 struct device_driver *drv = dev->driver;
342 int ret = 0;
343
344 if (!drv)
345 return 0;
346
347 if (drv->pm) {
348 if (drv->pm->restore_noirq)
349 ret = drv->pm->restore_noirq(dev);
350 }
351
352 return ret;
353}
354
355#else /* !CONFIG_HIBERNATION */
356
357#define amba_pm_freeze NULL
358#define amba_pm_thaw NULL
359#define amba_pm_poweroff NULL
360#define amba_pm_restore NULL
361#define amba_pm_freeze_noirq NULL
362#define amba_pm_thaw_noirq NULL
363#define amba_pm_poweroff_noirq NULL
364#define amba_pm_restore_noirq NULL
365
366#endif /* !CONFIG_HIBERNATION */
367
368#ifdef CONFIG_PM
369
370static const struct dev_pm_ops amba_pm = {
371 .prepare = amba_pm_prepare,
372 .complete = amba_pm_complete,
373 .suspend = amba_pm_suspend,
374 .resume = amba_pm_resume,
375 .freeze = amba_pm_freeze,
376 .thaw = amba_pm_thaw,
377 .poweroff = amba_pm_poweroff,
378 .restore = amba_pm_restore,
379 .suspend_noirq = amba_pm_suspend_noirq,
380 .resume_noirq = amba_pm_resume_noirq,
381 .freeze_noirq = amba_pm_freeze_noirq,
382 .thaw_noirq = amba_pm_thaw_noirq,
383 .poweroff_noirq = amba_pm_poweroff_noirq,
384 .restore_noirq = amba_pm_restore_noirq,
385 SET_RUNTIME_PM_OPS(
386 pm_generic_runtime_suspend,
387 pm_generic_runtime_resume,
388 pm_generic_runtime_idle
389 )
390};
391
392#define AMBA_PM (&amba_pm)
393
394#else /* !CONFIG_PM */
395
396#define AMBA_PM NULL
397
398#endif /* !CONFIG_PM */
399
105/* 400/*
106 * Primecells are part of the Advanced Microcontroller Bus Architecture, 401 * Primecells are part of the Advanced Microcontroller Bus Architecture,
107 * so we call the bus "amba". 402 * so we call the bus "amba".
108 */ 403 */
109static struct bus_type amba_bustype = { 404struct bus_type amba_bustype = {
110 .name = "amba", 405 .name = "amba",
111 .dev_attrs = amba_dev_attrs, 406 .dev_attrs = amba_dev_attrs,
112 .match = amba_match, 407 .match = amba_match,
113 .uevent = amba_uevent, 408 .uevent = amba_uevent,
114 .suspend = amba_suspend, 409 .pm = AMBA_PM,
115 .resume = amba_resume,
116}; 410};
117 411
118static int __init amba_init(void) 412static int __init amba_init(void)
@@ -188,7 +482,7 @@ static int amba_probe(struct device *dev)
188{ 482{
189 struct amba_device *pcdev = to_amba_device(dev); 483 struct amba_device *pcdev = to_amba_device(dev);
190 struct amba_driver *pcdrv = to_amba_driver(dev->driver); 484 struct amba_driver *pcdrv = to_amba_driver(dev->driver);
191 struct amba_id *id = amba_lookup(pcdrv->id_table, pcdev); 485 const struct amba_id *id = amba_lookup(pcdrv->id_table, pcdev);
192 int ret; 486 int ret;
193 487
194 do { 488 do {
diff --git a/drivers/char/hw_random/nomadik-rng.c b/drivers/char/hw_random/nomadik-rng.c
index a348c7e9aa0b..dd1d143eb8ea 100644
--- a/drivers/char/hw_random/nomadik-rng.c
+++ b/drivers/char/hw_random/nomadik-rng.c
@@ -39,7 +39,7 @@ static struct hwrng nmk_rng = {
39 .read = nmk_rng_read, 39 .read = nmk_rng_read,
40}; 40};
41 41
42static int nmk_rng_probe(struct amba_device *dev, struct amba_id *id) 42static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id)
43{ 43{
44 void __iomem *base; 44 void __iomem *base;
45 int ret; 45 int ret;
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index 07bca4970e50..e6d7228b1479 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -1845,7 +1845,7 @@ static inline void init_pl08x_debugfs(struct pl08x_driver_data *pl08x)
1845} 1845}
1846#endif 1846#endif
1847 1847
1848static int pl08x_probe(struct amba_device *adev, struct amba_id *id) 1848static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
1849{ 1849{
1850 struct pl08x_driver_data *pl08x; 1850 struct pl08x_driver_data *pl08x;
1851 const struct vendor_data *vd = id->data; 1851 const struct vendor_data *vd = id->data;
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 7c50f6dfd3f4..6abe1ec1f2ce 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -657,7 +657,7 @@ static irqreturn_t pl330_irq_handler(int irq, void *data)
657} 657}
658 658
659static int __devinit 659static int __devinit
660pl330_probe(struct amba_device *adev, struct amba_id *id) 660pl330_probe(struct amba_device *adev, const struct amba_id *id)
661{ 661{
662 struct dma_pl330_platdata *pdat; 662 struct dma_pl330_platdata *pdat;
663 struct dma_pl330_dmac *pdmac; 663 struct dma_pl330_dmac *pdmac;
diff --git a/drivers/gpio/pl061.c b/drivers/gpio/pl061.c
index 2975d22daffe..838ddbdf90cc 100644
--- a/drivers/gpio/pl061.c
+++ b/drivers/gpio/pl061.c
@@ -232,7 +232,7 @@ static void pl061_irq_handler(unsigned irq, struct irq_desc *desc)
232 desc->irq_data.chip->irq_unmask(&desc->irq_data); 232 desc->irq_data.chip->irq_unmask(&desc->irq_data);
233} 233}
234 234
235static int pl061_probe(struct amba_device *dev, struct amba_id *id) 235static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
236{ 236{
237 struct pl061_platform_data *pdata; 237 struct pl061_platform_data *pdata;
238 struct pl061_gpio *chip; 238 struct pl061_gpio *chip;
diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c
index 92563a681d65..12abc50508e5 100644
--- a/drivers/input/serio/ambakmi.c
+++ b/drivers/input/serio/ambakmi.c
@@ -107,7 +107,8 @@ static void amba_kmi_close(struct serio *io)
107 clk_disable(kmi->clk); 107 clk_disable(kmi->clk);
108} 108}
109 109
110static int __devinit amba_kmi_probe(struct amba_device *dev, struct amba_id *id) 110static int __devinit amba_kmi_probe(struct amba_device *dev,
111 const struct amba_id *id)
111{ 112{
112 struct amba_kmi_port *kmi; 113 struct amba_kmi_port *kmi;
113 struct serio *io; 114 struct serio *io;
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 2d6de3e03e2d..5bbb87d10251 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -2,7 +2,7 @@
2 * linux/drivers/mmc/host/mmci.c - ARM PrimeCell MMCI PL180/1 driver 2 * linux/drivers/mmc/host/mmci.c - ARM PrimeCell MMCI PL180/1 driver
3 * 3 *
4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved. 4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
5 * Copyright (C) 2010 ST-Ericsson AB. 5 * Copyright (C) 2010 ST-Ericsson SA
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
@@ -25,8 +25,10 @@
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/scatterlist.h> 26#include <linux/scatterlist.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/amba/mmci.h>
29#include <linux/regulator/consumer.h> 28#include <linux/regulator/consumer.h>
29#include <linux/dmaengine.h>
30#include <linux/dma-mapping.h>
31#include <linux/amba/mmci.h>
30 32
31#include <asm/div64.h> 33#include <asm/div64.h>
32#include <asm/io.h> 34#include <asm/io.h>
@@ -142,9 +144,6 @@ mmci_request_end(struct mmci_host *host, struct mmc_request *mrq)
142 host->mrq = NULL; 144 host->mrq = NULL;
143 host->cmd = NULL; 145 host->cmd = NULL;
144 146
145 if (mrq->data)
146 mrq->data->bytes_xfered = host->data_xfered;
147
148 /* 147 /*
149 * Need to drop the host lock here; mmc_request_done may call 148 * Need to drop the host lock here; mmc_request_done may call
150 * back into the driver... 149 * back into the driver...
@@ -189,6 +188,248 @@ static void mmci_init_sg(struct mmci_host *host, struct mmc_data *data)
189 sg_miter_start(&host->sg_miter, data->sg, data->sg_len, flags); 188 sg_miter_start(&host->sg_miter, data->sg, data->sg_len, flags);
190} 189}
191 190
191/*
192 * All the DMA operation mode stuff goes inside this ifdef.
193 * This assumes that you have a generic DMA device interface,
194 * no custom DMA interfaces are supported.
195 */
196#ifdef CONFIG_DMA_ENGINE
197static void __devinit mmci_dma_setup(struct mmci_host *host)
198{
199 struct mmci_platform_data *plat = host->plat;
200 const char *rxname, *txname;
201 dma_cap_mask_t mask;
202
203 if (!plat || !plat->dma_filter) {
204 dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
205 return;
206 }
207
208 /* Try to acquire a generic DMA engine slave channel */
209 dma_cap_zero(mask);
210 dma_cap_set(DMA_SLAVE, mask);
211
212 /*
213 * If only an RX channel is specified, the driver will
214 * attempt to use it bidirectionally, however if it is
215 * is specified but cannot be located, DMA will be disabled.
216 */
217 if (plat->dma_rx_param) {
218 host->dma_rx_channel = dma_request_channel(mask,
219 plat->dma_filter,
220 plat->dma_rx_param);
221 /* E.g if no DMA hardware is present */
222 if (!host->dma_rx_channel)
223 dev_err(mmc_dev(host->mmc), "no RX DMA channel\n");
224 }
225
226 if (plat->dma_tx_param) {
227 host->dma_tx_channel = dma_request_channel(mask,
228 plat->dma_filter,
229 plat->dma_tx_param);
230 if (!host->dma_tx_channel)
231 dev_warn(mmc_dev(host->mmc), "no TX DMA channel\n");
232 } else {
233 host->dma_tx_channel = host->dma_rx_channel;
234 }
235
236 if (host->dma_rx_channel)
237 rxname = dma_chan_name(host->dma_rx_channel);
238 else
239 rxname = "none";
240
241 if (host->dma_tx_channel)
242 txname = dma_chan_name(host->dma_tx_channel);
243 else
244 txname = "none";
245
246 dev_info(mmc_dev(host->mmc), "DMA channels RX %s, TX %s\n",
247 rxname, txname);
248
249 /*
250 * Limit the maximum segment size in any SG entry according to
251 * the parameters of the DMA engine device.
252 */
253 if (host->dma_tx_channel) {
254 struct device *dev = host->dma_tx_channel->device->dev;
255 unsigned int max_seg_size = dma_get_max_seg_size(dev);
256
257 if (max_seg_size < host->mmc->max_seg_size)
258 host->mmc->max_seg_size = max_seg_size;
259 }
260 if (host->dma_rx_channel) {
261 struct device *dev = host->dma_rx_channel->device->dev;
262 unsigned int max_seg_size = dma_get_max_seg_size(dev);
263
264 if (max_seg_size < host->mmc->max_seg_size)
265 host->mmc->max_seg_size = max_seg_size;
266 }
267}
268
269/*
270 * This is used in __devinit or __devexit so inline it
271 * so it can be discarded.
272 */
273static inline void mmci_dma_release(struct mmci_host *host)
274{
275 struct mmci_platform_data *plat = host->plat;
276
277 if (host->dma_rx_channel)
278 dma_release_channel(host->dma_rx_channel);
279 if (host->dma_tx_channel && plat->dma_tx_param)
280 dma_release_channel(host->dma_tx_channel);
281 host->dma_rx_channel = host->dma_tx_channel = NULL;
282}
283
284static void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data)
285{
286 struct dma_chan *chan = host->dma_current;
287 enum dma_data_direction dir;
288 u32 status;
289 int i;
290
291 /* Wait up to 1ms for the DMA to complete */
292 for (i = 0; ; i++) {
293 status = readl(host->base + MMCISTATUS);
294 if (!(status & MCI_RXDATAAVLBLMASK) || i >= 100)
295 break;
296 udelay(10);
297 }
298
299 /*
300 * Check to see whether we still have some data left in the FIFO -
301 * this catches DMA controllers which are unable to monitor the
302 * DMALBREQ and DMALSREQ signals while allowing us to DMA to non-
303 * contiguous buffers. On TX, we'll get a FIFO underrun error.
304 */
305 if (status & MCI_RXDATAAVLBLMASK) {
306 dmaengine_terminate_all(chan);
307 if (!data->error)
308 data->error = -EIO;
309 }
310
311 if (data->flags & MMC_DATA_WRITE) {
312 dir = DMA_TO_DEVICE;
313 } else {
314 dir = DMA_FROM_DEVICE;
315 }
316
317 dma_unmap_sg(chan->device->dev, data->sg, data->sg_len, dir);
318
319 /*
320 * Use of DMA with scatter-gather is impossible.
321 * Give up with DMA and switch back to PIO mode.
322 */
323 if (status & MCI_RXDATAAVLBLMASK) {
324 dev_err(mmc_dev(host->mmc), "buggy DMA detected. Taking evasive action.\n");
325 mmci_dma_release(host);
326 }
327}
328
329static void mmci_dma_data_error(struct mmci_host *host)
330{
331 dev_err(mmc_dev(host->mmc), "error during DMA transfer!\n");
332 dmaengine_terminate_all(host->dma_current);
333}
334
335static int mmci_dma_start_data(struct mmci_host *host, unsigned int datactrl)
336{
337 struct variant_data *variant = host->variant;
338 struct dma_slave_config conf = {
339 .src_addr = host->phybase + MMCIFIFO,
340 .dst_addr = host->phybase + MMCIFIFO,
341 .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
342 .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
343 .src_maxburst = variant->fifohalfsize >> 2, /* # of words */
344 .dst_maxburst = variant->fifohalfsize >> 2, /* # of words */
345 };
346 struct mmc_data *data = host->data;
347 struct dma_chan *chan;
348 struct dma_device *device;
349 struct dma_async_tx_descriptor *desc;
350 int nr_sg;
351
352 host->dma_current = NULL;
353
354 if (data->flags & MMC_DATA_READ) {
355 conf.direction = DMA_FROM_DEVICE;
356 chan = host->dma_rx_channel;
357 } else {
358 conf.direction = DMA_TO_DEVICE;
359 chan = host->dma_tx_channel;
360 }
361
362 /* If there's no DMA channel, fall back to PIO */
363 if (!chan)
364 return -EINVAL;
365
366 /* If less than or equal to the fifo size, don't bother with DMA */
367 if (host->size <= variant->fifosize)
368 return -EINVAL;
369
370 device = chan->device;
371 nr_sg = dma_map_sg(device->dev, data->sg, data->sg_len, conf.direction);
372 if (nr_sg == 0)
373 return -EINVAL;
374
375 dmaengine_slave_config(chan, &conf);
376 desc = device->device_prep_slave_sg(chan, data->sg, nr_sg,
377 conf.direction, DMA_CTRL_ACK);
378 if (!desc)
379 goto unmap_exit;
380
381 /* Okay, go for it. */
382 host->dma_current = chan;
383
384 dev_vdbg(mmc_dev(host->mmc),
385 "Submit MMCI DMA job, sglen %d blksz %04x blks %04x flags %08x\n",
386 data->sg_len, data->blksz, data->blocks, data->flags);
387 dmaengine_submit(desc);
388 dma_async_issue_pending(chan);
389
390 datactrl |= MCI_DPSM_DMAENABLE;
391
392 /* Trigger the DMA transfer */
393 writel(datactrl, host->base + MMCIDATACTRL);
394
395 /*
396 * Let the MMCI say when the data is ended and it's time
397 * to fire next DMA request. When that happens, MMCI will
398 * call mmci_data_end()
399 */
400 writel(readl(host->base + MMCIMASK0) | MCI_DATAENDMASK,
401 host->base + MMCIMASK0);
402 return 0;
403
404unmap_exit:
405 dmaengine_terminate_all(chan);
406 dma_unmap_sg(device->dev, data->sg, data->sg_len, conf.direction);
407 return -ENOMEM;
408}
409#else
410/* Blank functions if the DMA engine is not available */
411static inline void mmci_dma_setup(struct mmci_host *host)
412{
413}
414
415static inline void mmci_dma_release(struct mmci_host *host)
416{
417}
418
419static inline void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data)
420{
421}
422
423static inline void mmci_dma_data_error(struct mmci_host *host)
424{
425}
426
427static inline int mmci_dma_start_data(struct mmci_host *host, unsigned int datactrl)
428{
429 return -ENOSYS;
430}
431#endif
432
192static void mmci_start_data(struct mmci_host *host, struct mmc_data *data) 433static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
193{ 434{
194 struct variant_data *variant = host->variant; 435 struct variant_data *variant = host->variant;
@@ -202,9 +443,7 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
202 443
203 host->data = data; 444 host->data = data;
204 host->size = data->blksz * data->blocks; 445 host->size = data->blksz * data->blocks;
205 host->data_xfered = 0; 446 data->bytes_xfered = 0;
206
207 mmci_init_sg(host, data);
208 447
209 clks = (unsigned long long)data->timeout_ns * host->cclk; 448 clks = (unsigned long long)data->timeout_ns * host->cclk;
210 do_div(clks, 1000000000UL); 449 do_div(clks, 1000000000UL);
@@ -219,15 +458,29 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
219 BUG_ON(1 << blksz_bits != data->blksz); 458 BUG_ON(1 << blksz_bits != data->blksz);
220 459
221 datactrl = MCI_DPSM_ENABLE | blksz_bits << 4; 460 datactrl = MCI_DPSM_ENABLE | blksz_bits << 4;
222 if (data->flags & MMC_DATA_READ) { 461
462 if (data->flags & MMC_DATA_READ)
223 datactrl |= MCI_DPSM_DIRECTION; 463 datactrl |= MCI_DPSM_DIRECTION;
464
465 /*
466 * Attempt to use DMA operation mode, if this
467 * should fail, fall back to PIO mode
468 */
469 if (!mmci_dma_start_data(host, datactrl))
470 return;
471
472 /* IRQ mode, map the SG list for CPU reading/writing */
473 mmci_init_sg(host, data);
474
475 if (data->flags & MMC_DATA_READ) {
224 irqmask = MCI_RXFIFOHALFFULLMASK; 476 irqmask = MCI_RXFIFOHALFFULLMASK;
225 477
226 /* 478 /*
227 * If we have less than a FIFOSIZE of bytes to transfer, 479 * If we have less than the fifo 'half-full' threshold to
228 * trigger a PIO interrupt as soon as any data is available. 480 * transfer, trigger a PIO interrupt as soon as any data
481 * is available.
229 */ 482 */
230 if (host->size < variant->fifosize) 483 if (host->size < variant->fifohalfsize)
231 irqmask |= MCI_RXDATAAVLBLMASK; 484 irqmask |= MCI_RXDATAAVLBLMASK;
232 } else { 485 } else {
233 /* 486 /*
@@ -283,49 +536,51 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
283 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) { 536 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
284 u32 remain, success; 537 u32 remain, success;
285 538
286 /* Calculate how far we are into the transfer */ 539 /* Terminate the DMA transfer */
540 if (dma_inprogress(host))
541 mmci_dma_data_error(host);
542
543 /*
544 * Calculate how far we are into the transfer. Note that
545 * the data counter gives the number of bytes transferred
546 * on the MMC bus, not on the host side. On reads, this
547 * can be as much as a FIFO-worth of data ahead. This
548 * matters for FIFO overruns only.
549 */
287 remain = readl(host->base + MMCIDATACNT); 550 remain = readl(host->base + MMCIDATACNT);
288 success = data->blksz * data->blocks - remain; 551 success = data->blksz * data->blocks - remain;
289 552
290 dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status); 553 dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ, status 0x%08x at 0x%08x\n",
554 status, success);
291 if (status & MCI_DATACRCFAIL) { 555 if (status & MCI_DATACRCFAIL) {
292 /* Last block was not successful */ 556 /* Last block was not successful */
293 host->data_xfered = round_down(success - 1, data->blksz); 557 success -= 1;
294 data->error = -EILSEQ; 558 data->error = -EILSEQ;
295 } else if (status & MCI_DATATIMEOUT) { 559 } else if (status & MCI_DATATIMEOUT) {
296 host->data_xfered = round_down(success, data->blksz);
297 data->error = -ETIMEDOUT; 560 data->error = -ETIMEDOUT;
298 } else if (status & (MCI_TXUNDERRUN|MCI_RXOVERRUN)) { 561 } else if (status & MCI_TXUNDERRUN) {
299 host->data_xfered = round_down(success, data->blksz); 562 data->error = -EIO;
563 } else if (status & MCI_RXOVERRUN) {
564 if (success > host->variant->fifosize)
565 success -= host->variant->fifosize;
566 else
567 success = 0;
300 data->error = -EIO; 568 data->error = -EIO;
301 } 569 }
302 570 data->bytes_xfered = round_down(success, data->blksz);
303 /*
304 * We hit an error condition. Ensure that any data
305 * partially written to a page is properly coherent.
306 */
307 if (data->flags & MMC_DATA_READ) {
308 struct sg_mapping_iter *sg_miter = &host->sg_miter;
309 unsigned long flags;
310
311 local_irq_save(flags);
312 if (sg_miter_next(sg_miter)) {
313 flush_dcache_page(sg_miter->page);
314 sg_miter_stop(sg_miter);
315 }
316 local_irq_restore(flags);
317 }
318 } 571 }
319 572
320 if (status & MCI_DATABLOCKEND) 573 if (status & MCI_DATABLOCKEND)
321 dev_err(mmc_dev(host->mmc), "stray MCI_DATABLOCKEND interrupt\n"); 574 dev_err(mmc_dev(host->mmc), "stray MCI_DATABLOCKEND interrupt\n");
322 575
323 if (status & MCI_DATAEND || data->error) { 576 if (status & MCI_DATAEND || data->error) {
577 if (dma_inprogress(host))
578 mmci_dma_unmap(host, data);
324 mmci_stop_data(host); 579 mmci_stop_data(host);
325 580
326 if (!data->error) 581 if (!data->error)
327 /* The error clause is handled above, success! */ 582 /* The error clause is handled above, success! */
328 host->data_xfered += data->blksz * data->blocks; 583 data->bytes_xfered = data->blksz * data->blocks;
329 584
330 if (!data->stop) { 585 if (!data->stop) {
331 mmci_request_end(host, data->mrq); 586 mmci_request_end(host, data->mrq);
@@ -498,9 +753,6 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id)
498 if (remain) 753 if (remain)
499 break; 754 break;
500 755
501 if (status & MCI_RXACTIVE)
502 flush_dcache_page(sg_miter->page);
503
504 status = readl(base + MMCISTATUS); 756 status = readl(base + MMCISTATUS);
505 } while (1); 757 } while (1);
506 758
@@ -509,10 +761,10 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id)
509 local_irq_restore(flags); 761 local_irq_restore(flags);
510 762
511 /* 763 /*
512 * If we're nearing the end of the read, switch to 764 * If we have less than the fifo 'half-full' threshold to transfer,
513 * "any data available" mode. 765 * trigger a PIO interrupt as soon as any data is available.
514 */ 766 */
515 if (status & MCI_RXACTIVE && host->size < variant->fifosize) 767 if (status & MCI_RXACTIVE && host->size < variant->fifohalfsize)
516 mmci_set_mask1(host, MCI_RXDATAAVLBLMASK); 768 mmci_set_mask1(host, MCI_RXDATAAVLBLMASK);
517 769
518 /* 770 /*
@@ -713,7 +965,8 @@ static const struct mmc_host_ops mmci_ops = {
713 .get_cd = mmci_get_cd, 965 .get_cd = mmci_get_cd,
714}; 966};
715 967
716static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id) 968static int __devinit mmci_probe(struct amba_device *dev,
969 const struct amba_id *id)
717{ 970{
718 struct mmci_platform_data *plat = dev->dev.platform_data; 971 struct mmci_platform_data *plat = dev->dev.platform_data;
719 struct variant_data *variant = id->data; 972 struct variant_data *variant = id->data;
@@ -776,6 +1029,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
776 dev_dbg(mmc_dev(mmc), "eventual mclk rate: %u Hz\n", 1029 dev_dbg(mmc_dev(mmc), "eventual mclk rate: %u Hz\n",
777 host->mclk); 1030 host->mclk);
778 } 1031 }
1032 host->phybase = dev->res.start;
779 host->base = ioremap(dev->res.start, resource_size(&dev->res)); 1033 host->base = ioremap(dev->res.start, resource_size(&dev->res));
780 if (!host->base) { 1034 if (!host->base) {
781 ret = -ENOMEM; 1035 ret = -ENOMEM;
@@ -903,9 +1157,12 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
903 1157
904 amba_set_drvdata(dev, mmc); 1158 amba_set_drvdata(dev, mmc);
905 1159
906 dev_info(&dev->dev, "%s: PL%03x rev%u at 0x%08llx irq %d,%d\n", 1160 dev_info(&dev->dev, "%s: PL%03x manf %x rev%u at 0x%08llx irq %d,%d (pio)\n",
907 mmc_hostname(mmc), amba_part(dev), amba_rev(dev), 1161 mmc_hostname(mmc), amba_part(dev), amba_manf(dev),
908 (unsigned long long)dev->res.start, dev->irq[0], dev->irq[1]); 1162 amba_rev(dev), (unsigned long long)dev->res.start,
1163 dev->irq[0], dev->irq[1]);
1164
1165 mmci_dma_setup(host);
909 1166
910 mmc_add_host(mmc); 1167 mmc_add_host(mmc);
911 1168
@@ -952,6 +1209,7 @@ static int __devexit mmci_remove(struct amba_device *dev)
952 writel(0, host->base + MMCICOMMAND); 1209 writel(0, host->base + MMCICOMMAND);
953 writel(0, host->base + MMCIDATACTRL); 1210 writel(0, host->base + MMCIDATACTRL);
954 1211
1212 mmci_dma_release(host);
955 free_irq(dev->irq[0], host); 1213 free_irq(dev->irq[0], host);
956 if (!host->singleirq) 1214 if (!host->singleirq)
957 free_irq(dev->irq[1], host); 1215 free_irq(dev->irq[1], host);
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index c1df7b82d36c..ec9a7bc6d0df 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -148,8 +148,10 @@
148 148
149struct clk; 149struct clk;
150struct variant_data; 150struct variant_data;
151struct dma_chan;
151 152
152struct mmci_host { 153struct mmci_host {
154 phys_addr_t phybase;
153 void __iomem *base; 155 void __iomem *base;
154 struct mmc_request *mrq; 156 struct mmc_request *mrq;
155 struct mmc_command *cmd; 157 struct mmc_command *cmd;
@@ -161,8 +163,6 @@ struct mmci_host {
161 int gpio_cd_irq; 163 int gpio_cd_irq;
162 bool singleirq; 164 bool singleirq;
163 165
164 unsigned int data_xfered;
165
166 spinlock_t lock; 166 spinlock_t lock;
167 167
168 unsigned int mclk; 168 unsigned int mclk;
@@ -181,5 +181,16 @@ struct mmci_host {
181 struct sg_mapping_iter sg_miter; 181 struct sg_mapping_iter sg_miter;
182 unsigned int size; 182 unsigned int size;
183 struct regulator *vcc; 183 struct regulator *vcc;
184
185#ifdef CONFIG_DMA_ENGINE
186 /* DMA stuff */
187 struct dma_chan *dma_current;
188 struct dma_chan *dma_rx_channel;
189 struct dma_chan *dma_tx_channel;
190
191#define dma_inprogress(host) ((host)->dma_current)
192#else
193#define dma_inprogress(host) (0)
194#endif
184}; 195};
185 196
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index bbdb2f02798a..baff724cd40f 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -103,7 +103,7 @@ static const struct rtc_class_ops pl030_ops = {
103 .set_alarm = pl030_set_alarm, 103 .set_alarm = pl030_set_alarm,
104}; 104};
105 105
106static int pl030_probe(struct amba_device *dev, struct amba_id *id) 106static int pl030_probe(struct amba_device *dev, const struct amba_id *id)
107{ 107{
108 struct pl030_rtc *rtc; 108 struct pl030_rtc *rtc;
109 int ret; 109 int ret;
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index b7a6690e5b35..6568f4b37e19 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -358,7 +358,7 @@ static int pl031_remove(struct amba_device *adev)
358 return 0; 358 return 0;
359} 359}
360 360
361static int pl031_probe(struct amba_device *adev, struct amba_id *id) 361static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
362{ 362{
363 int ret; 363 int ret;
364 struct pl031_local *ldata; 364 struct pl031_local *ldata;
diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
index 71a1219a995d..95e58c70a2c9 100644
--- a/drivers/spi/amba-pl022.c
+++ b/drivers/spi/amba-pl022.c
@@ -2021,7 +2021,7 @@ static void pl022_cleanup(struct spi_device *spi)
2021 2021
2022 2022
2023static int __devinit 2023static int __devinit
2024pl022_probe(struct amba_device *adev, struct amba_id *id) 2024pl022_probe(struct amba_device *adev, const struct amba_id *id)
2025{ 2025{
2026 struct device *dev = &adev->dev; 2026 struct device *dev = &adev->dev;
2027 struct pl022_ssp_controller *platform_info = adev->dev.platform_data; 2027 struct pl022_ssp_controller *platform_info = adev->dev.platform_data;
diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index 2904aa044126..d742dd2c525c 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -676,7 +676,7 @@ static struct uart_driver amba_reg = {
676 .cons = AMBA_CONSOLE, 676 .cons = AMBA_CONSOLE,
677}; 677};
678 678
679static int pl010_probe(struct amba_device *dev, struct amba_id *id) 679static int pl010_probe(struct amba_device *dev, const struct amba_id *id)
680{ 680{
681 struct uart_amba_port *uap; 681 struct uart_amba_port *uap;
682 void __iomem *base; 682 void __iomem *base;
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index faa16ee6b022..57731e870085 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1738,7 +1738,7 @@ static struct uart_driver amba_reg = {
1738 .cons = AMBA_CONSOLE, 1738 .cons = AMBA_CONSOLE,
1739}; 1739};
1740 1740
1741static int pl011_probe(struct amba_device *dev, struct amba_id *id) 1741static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1742{ 1742{
1743 struct uart_amba_port *uap; 1743 struct uart_amba_port *uap;
1744 struct vendor_data *vendor = id->data; 1744 struct vendor_data *vendor = id->data;
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index 1c2c68356ea7..013c8ce57205 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -461,7 +461,7 @@ static int clcdfb_register(struct clcd_fb *fb)
461 return ret; 461 return ret;
462} 462}
463 463
464static int clcdfb_probe(struct amba_device *dev, struct amba_id *id) 464static int clcdfb_probe(struct amba_device *dev, const struct amba_id *id)
465{ 465{
466 struct clcd_board *board = dev->dev.platform_data; 466 struct clcd_board *board = dev->dev.platform_data;
467 struct clcd_fb *fb; 467 struct clcd_fb *fb;
diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c
index 9127eda2145b..0a0efe713bc8 100644
--- a/drivers/watchdog/sp805_wdt.c
+++ b/drivers/watchdog/sp805_wdt.c
@@ -278,7 +278,7 @@ static struct miscdevice sp805_wdt_miscdev = {
278}; 278};
279 279
280static int __devinit 280static int __devinit
281sp805_wdt_probe(struct amba_device *adev, struct amba_id *id) 281sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id)
282{ 282{
283 int ret = 0; 283 int ret = 0;
284 284