aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2013-04-19 16:50:41 -0400
committerArnd Bergmann <arnd@arndb.de>2013-04-19 16:50:52 -0400
commitf54ae513d3d39b60bcc2ef446f1219f501d859bf (patch)
treea60c22feaee5265fa9b017bc504793ae1b531972 /drivers
parent1b361942b53c33f38d55065c13785aadb5103a18 (diff)
parente34d3865ee4a71195f91b23fd09e2619a5f727d3 (diff)
Merge branch 'spear/dwdma' into late/cleanup
This is a series originally prepared for inclusion in 3.9, which did not work out because of dependencies on the dmaengine driver. All the changes for the dmaengine code are merged in 3.9 now, so we can finally do the switchover and remove the now unnecessary dma definitions for spear13xx from the platform code. The dma platform_data actually made up the majority of the spear13xx platform code overall, so moving that into device tree files makes the code substantially smaller. * spear/dwdma: ata: arasan: remove the need for platform_data ARM: SPEAr13xx: Pass generic DW DMAC platform data from DT serial: pl011: use generic DMA slave configuration if possible spi: pl022: use generic DMA slave configuration if possible Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/pata_arasan_cf.c37
-rw-r--r--drivers/spi/spi-pl022.c43
-rw-r--r--drivers/tty/serial/amba-pl011.c62
3 files changed, 97 insertions, 45 deletions
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index 405022d302c3..7638121cb5d1 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -209,8 +209,6 @@ struct arasan_cf_dev {
209 struct dma_chan *dma_chan; 209 struct dma_chan *dma_chan;
210 /* Mask for DMA transfers */ 210 /* Mask for DMA transfers */
211 dma_cap_mask_t mask; 211 dma_cap_mask_t mask;
212 /* dma channel private data */
213 void *dma_priv;
214 /* DMA transfer work */ 212 /* DMA transfer work */
215 struct work_struct work; 213 struct work_struct work;
216 /* DMA delayed finish work */ 214 /* DMA delayed finish work */
@@ -308,6 +306,7 @@ static void cf_card_detect(struct arasan_cf_dev *acdev, bool hotplugged)
308static int cf_init(struct arasan_cf_dev *acdev) 306static int cf_init(struct arasan_cf_dev *acdev)
309{ 307{
310 struct arasan_cf_pdata *pdata = dev_get_platdata(acdev->host->dev); 308 struct arasan_cf_pdata *pdata = dev_get_platdata(acdev->host->dev);
309 unsigned int if_clk;
311 unsigned long flags; 310 unsigned long flags;
312 int ret = 0; 311 int ret = 0;
313 312
@@ -325,8 +324,12 @@ static int cf_init(struct arasan_cf_dev *acdev)
325 324
326 spin_lock_irqsave(&acdev->host->lock, flags); 325 spin_lock_irqsave(&acdev->host->lock, flags);
327 /* configure CF interface clock */ 326 /* configure CF interface clock */
328 writel((pdata->cf_if_clk <= CF_IF_CLK_200M) ? pdata->cf_if_clk : 327 /* TODO: read from device tree */
329 CF_IF_CLK_166M, acdev->vbase + CLK_CFG); 328 if_clk = CF_IF_CLK_166M;
329 if (pdata && pdata->cf_if_clk <= CF_IF_CLK_200M)
330 if_clk = pdata->cf_if_clk;
331
332 writel(if_clk, acdev->vbase + CLK_CFG);
330 333
331 writel(TRUE_IDE_MODE | CFHOST_ENB, acdev->vbase + OP_MODE); 334 writel(TRUE_IDE_MODE | CFHOST_ENB, acdev->vbase + OP_MODE);
332 cf_interrupt_enable(acdev, CARD_DETECT_IRQ, 1); 335 cf_interrupt_enable(acdev, CARD_DETECT_IRQ, 1);
@@ -357,12 +360,6 @@ static void dma_callback(void *dev)
357 complete(&acdev->dma_completion); 360 complete(&acdev->dma_completion);
358} 361}
359 362
360static bool filter(struct dma_chan *chan, void *slave)
361{
362 chan->private = slave;
363 return true;
364}
365
366static inline void dma_complete(struct arasan_cf_dev *acdev) 363static inline void dma_complete(struct arasan_cf_dev *acdev)
367{ 364{
368 struct ata_queued_cmd *qc = acdev->qc; 365 struct ata_queued_cmd *qc = acdev->qc;
@@ -530,8 +527,7 @@ static void data_xfer(struct work_struct *work)
530 527
531 /* request dma channels */ 528 /* request dma channels */
532 /* dma_request_channel may sleep, so calling from process context */ 529 /* dma_request_channel may sleep, so calling from process context */
533 acdev->dma_chan = dma_request_channel(acdev->mask, filter, 530 acdev->dma_chan = dma_request_slave_channel(acdev->host->dev, "data");
534 acdev->dma_priv);
535 if (!acdev->dma_chan) { 531 if (!acdev->dma_chan) {
536 dev_err(acdev->host->dev, "Unable to get dma_chan\n"); 532 dev_err(acdev->host->dev, "Unable to get dma_chan\n");
537 goto chan_request_fail; 533 goto chan_request_fail;
@@ -798,6 +794,7 @@ static int arasan_cf_probe(struct platform_device *pdev)
798 struct ata_host *host; 794 struct ata_host *host;
799 struct ata_port *ap; 795 struct ata_port *ap;
800 struct resource *res; 796 struct resource *res;
797 u32 quirk;
801 irq_handler_t irq_handler = NULL; 798 irq_handler_t irq_handler = NULL;
802 int ret = 0; 799 int ret = 0;
803 800
@@ -817,12 +814,17 @@ static int arasan_cf_probe(struct platform_device *pdev)
817 return -ENOMEM; 814 return -ENOMEM;
818 } 815 }
819 816
817 if (pdata)
818 quirk = pdata->quirk;
819 else
820 quirk = CF_BROKEN_UDMA; /* as it is on spear1340 */
821
820 /* if irq is 0, support only PIO */ 822 /* if irq is 0, support only PIO */
821 acdev->irq = platform_get_irq(pdev, 0); 823 acdev->irq = platform_get_irq(pdev, 0);
822 if (acdev->irq) 824 if (acdev->irq)
823 irq_handler = arasan_cf_interrupt; 825 irq_handler = arasan_cf_interrupt;
824 else 826 else
825 pdata->quirk |= CF_BROKEN_MWDMA | CF_BROKEN_UDMA; 827 quirk |= CF_BROKEN_MWDMA | CF_BROKEN_UDMA;
826 828
827 acdev->pbase = res->start; 829 acdev->pbase = res->start;
828 acdev->vbase = devm_ioremap_nocache(&pdev->dev, res->start, 830 acdev->vbase = devm_ioremap_nocache(&pdev->dev, res->start,
@@ -859,17 +861,16 @@ static int arasan_cf_probe(struct platform_device *pdev)
859 INIT_WORK(&acdev->work, data_xfer); 861 INIT_WORK(&acdev->work, data_xfer);
860 INIT_DELAYED_WORK(&acdev->dwork, delayed_finish); 862 INIT_DELAYED_WORK(&acdev->dwork, delayed_finish);
861 dma_cap_set(DMA_MEMCPY, acdev->mask); 863 dma_cap_set(DMA_MEMCPY, acdev->mask);
862 acdev->dma_priv = pdata->dma_priv;
863 864
864 /* Handle platform specific quirks */ 865 /* Handle platform specific quirks */
865 if (pdata->quirk) { 866 if (quirk) {
866 if (pdata->quirk & CF_BROKEN_PIO) { 867 if (quirk & CF_BROKEN_PIO) {
867 ap->ops->set_piomode = NULL; 868 ap->ops->set_piomode = NULL;
868 ap->pio_mask = 0; 869 ap->pio_mask = 0;
869 } 870 }
870 if (pdata->quirk & CF_BROKEN_MWDMA) 871 if (quirk & CF_BROKEN_MWDMA)
871 ap->mwdma_mask = 0; 872 ap->mwdma_mask = 0;
872 if (pdata->quirk & CF_BROKEN_UDMA) 873 if (quirk & CF_BROKEN_UDMA)
873 ap->udma_mask = 0; 874 ap->udma_mask = 0;
874 } 875 }
875 ap->flags |= ATA_FLAG_PIO_POLLING | ATA_FLAG_NO_ATAPI; 876 ap->flags |= ATA_FLAG_PIO_POLLING | ATA_FLAG_NO_ATAPI;
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index b0fe393c882c..371cc66f1a0e 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1139,6 +1139,35 @@ err_no_rxchan:
1139 return -ENODEV; 1139 return -ENODEV;
1140} 1140}
1141 1141
1142static int pl022_dma_autoprobe(struct pl022 *pl022)
1143{
1144 struct device *dev = &pl022->adev->dev;
1145
1146 /* automatically configure DMA channels from platform, normally using DT */
1147 pl022->dma_rx_channel = dma_request_slave_channel(dev, "rx");
1148 if (!pl022->dma_rx_channel)
1149 goto err_no_rxchan;
1150
1151 pl022->dma_tx_channel = dma_request_slave_channel(dev, "tx");
1152 if (!pl022->dma_tx_channel)
1153 goto err_no_txchan;
1154
1155 pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
1156 if (!pl022->dummypage)
1157 goto err_no_dummypage;
1158
1159 return 0;
1160
1161err_no_dummypage:
1162 dma_release_channel(pl022->dma_tx_channel);
1163 pl022->dma_tx_channel = NULL;
1164err_no_txchan:
1165 dma_release_channel(pl022->dma_rx_channel);
1166 pl022->dma_rx_channel = NULL;
1167err_no_rxchan:
1168 return -ENODEV;
1169}
1170
1142static void terminate_dma(struct pl022 *pl022) 1171static void terminate_dma(struct pl022 *pl022)
1143{ 1172{
1144 struct dma_chan *rxchan = pl022->dma_rx_channel; 1173 struct dma_chan *rxchan = pl022->dma_rx_channel;
@@ -1167,6 +1196,11 @@ static inline int configure_dma(struct pl022 *pl022)
1167 return -ENODEV; 1196 return -ENODEV;
1168} 1197}
1169 1198
1199static inline int pl022_dma_autoprobe(struct pl022 *pl022)
1200{
1201 return 0;
1202}
1203
1170static inline int pl022_dma_probe(struct pl022 *pl022) 1204static inline int pl022_dma_probe(struct pl022 *pl022)
1171{ 1205{
1172 return 0; 1206 return 0;
@@ -2226,8 +2260,13 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
2226 goto err_no_irq; 2260 goto err_no_irq;
2227 } 2261 }
2228 2262
2229 /* Get DMA channels */ 2263 /* Get DMA channels, try autoconfiguration first */
2230 if (platform_info->enable_dma) { 2264 status = pl022_dma_autoprobe(pl022);
2265
2266 /* If that failed, use channels from platform_info */
2267 if (status == 0)
2268 platform_info->enable_dma = 1;
2269 else if (platform_info->enable_dma) {
2231 status = pl022_dma_probe(pl022); 2270 status = pl022_dma_probe(pl022);
2232 if (status != 0) 2271 if (status != 0)
2233 platform_info->enable_dma = 0; 2272 platform_info->enable_dma = 0;
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 3ea5408fcbeb..c25b00ef9dbb 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -245,7 +245,7 @@ static void pl011_sgbuf_free(struct dma_chan *chan, struct pl011_sgbuf *sg,
245 } 245 }
246} 246}
247 247
248static void pl011_dma_probe_initcall(struct uart_amba_port *uap) 248static void pl011_dma_probe_initcall(struct device *dev, struct uart_amba_port *uap)
249{ 249{
250 /* DMA is the sole user of the platform data right now */ 250 /* DMA is the sole user of the platform data right now */
251 struct amba_pl011_data *plat = uap->port.dev->platform_data; 251 struct amba_pl011_data *plat = uap->port.dev->platform_data;
@@ -259,20 +259,25 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap)
259 struct dma_chan *chan; 259 struct dma_chan *chan;
260 dma_cap_mask_t mask; 260 dma_cap_mask_t mask;
261 261
262 /* We need platform data */ 262 chan = dma_request_slave_channel(dev, "tx");
263 if (!plat || !plat->dma_filter) {
264 dev_info(uap->port.dev, "no DMA platform data\n");
265 return;
266 }
267 263
268 /* Try to acquire a generic DMA engine slave TX channel */
269 dma_cap_zero(mask);
270 dma_cap_set(DMA_SLAVE, mask);
271
272 chan = dma_request_channel(mask, plat->dma_filter, plat->dma_tx_param);
273 if (!chan) { 264 if (!chan) {
274 dev_err(uap->port.dev, "no TX DMA channel!\n"); 265 /* We need platform data */
275 return; 266 if (!plat || !plat->dma_filter) {
267 dev_info(uap->port.dev, "no DMA platform data\n");
268 return;
269 }
270
271 /* Try to acquire a generic DMA engine slave TX channel */
272 dma_cap_zero(mask);
273 dma_cap_set(DMA_SLAVE, mask);
274
275 chan = dma_request_channel(mask, plat->dma_filter,
276 plat->dma_tx_param);
277 if (!chan) {
278 dev_err(uap->port.dev, "no TX DMA channel!\n");
279 return;
280 }
276 } 281 }
277 282
278 dmaengine_slave_config(chan, &tx_conf); 283 dmaengine_slave_config(chan, &tx_conf);
@@ -282,7 +287,18 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap)
282 dma_chan_name(uap->dmatx.chan)); 287 dma_chan_name(uap->dmatx.chan));
283 288
284 /* Optionally make use of an RX channel as well */ 289 /* Optionally make use of an RX channel as well */
285 if (plat->dma_rx_param) { 290 chan = dma_request_slave_channel(dev, "rx");
291
292 if (!chan && plat->dma_rx_param) {
293 chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param);
294
295 if (!chan) {
296 dev_err(uap->port.dev, "no RX DMA channel!\n");
297 return;
298 }
299 }
300
301 if (chan) {
286 struct dma_slave_config rx_conf = { 302 struct dma_slave_config rx_conf = {
287 .src_addr = uap->port.mapbase + UART01x_DR, 303 .src_addr = uap->port.mapbase + UART01x_DR,
288 .src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, 304 .src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE,
@@ -291,12 +307,6 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap)
291 .device_fc = false, 307 .device_fc = false,
292 }; 308 };
293 309
294 chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param);
295 if (!chan) {
296 dev_err(uap->port.dev, "no RX DMA channel!\n");
297 return;
298 }
299
300 dmaengine_slave_config(chan, &rx_conf); 310 dmaengine_slave_config(chan, &rx_conf);
301 uap->dmarx.chan = chan; 311 uap->dmarx.chan = chan;
302 312
@@ -315,6 +325,7 @@ static void pl011_dma_probe_initcall(struct uart_amba_port *uap)
315struct dma_uap { 325struct dma_uap {
316 struct list_head node; 326 struct list_head node;
317 struct uart_amba_port *uap; 327 struct uart_amba_port *uap;
328 struct device *dev;
318}; 329};
319 330
320static LIST_HEAD(pl011_dma_uarts); 331static LIST_HEAD(pl011_dma_uarts);
@@ -325,7 +336,7 @@ static int __init pl011_dma_initcall(void)
325 336
326 list_for_each_safe(node, tmp, &pl011_dma_uarts) { 337 list_for_each_safe(node, tmp, &pl011_dma_uarts) {
327 struct dma_uap *dmau = list_entry(node, struct dma_uap, node); 338 struct dma_uap *dmau = list_entry(node, struct dma_uap, node);
328 pl011_dma_probe_initcall(dmau->uap); 339 pl011_dma_probe_initcall(dmau->dev, dmau->uap);
329 list_del(node); 340 list_del(node);
330 kfree(dmau); 341 kfree(dmau);
331 } 342 }
@@ -334,18 +345,19 @@ static int __init pl011_dma_initcall(void)
334 345
335device_initcall(pl011_dma_initcall); 346device_initcall(pl011_dma_initcall);
336 347
337static void pl011_dma_probe(struct uart_amba_port *uap) 348static void pl011_dma_probe(struct device *dev, struct uart_amba_port *uap)
338{ 349{
339 struct dma_uap *dmau = kzalloc(sizeof(struct dma_uap), GFP_KERNEL); 350 struct dma_uap *dmau = kzalloc(sizeof(struct dma_uap), GFP_KERNEL);
340 if (dmau) { 351 if (dmau) {
341 dmau->uap = uap; 352 dmau->uap = uap;
353 dmau->dev = dev;
342 list_add_tail(&dmau->node, &pl011_dma_uarts); 354 list_add_tail(&dmau->node, &pl011_dma_uarts);
343 } 355 }
344} 356}
345#else 357#else
346static void pl011_dma_probe(struct uart_amba_port *uap) 358static void pl011_dma_probe(struct device *dev, struct uart_amba_port *uap)
347{ 359{
348 pl011_dma_probe_initcall(uap); 360 pl011_dma_probe_initcall(dev, uap);
349} 361}
350#endif 362#endif
351 363
@@ -2020,7 +2032,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
2020 uap->port.ops = &amba_pl011_pops; 2032 uap->port.ops = &amba_pl011_pops;
2021 uap->port.flags = UPF_BOOT_AUTOCONF; 2033 uap->port.flags = UPF_BOOT_AUTOCONF;
2022 uap->port.line = i; 2034 uap->port.line = i;
2023 pl011_dma_probe(uap); 2035 pl011_dma_probe(&dev->dev, uap);
2024 2036
2025 /* Ensure interrupts from this UART are masked and cleared */ 2037 /* Ensure interrupts from this UART are masked and cleared */
2026 writew(0, uap->port.membase + UART011_IMSC); 2038 writew(0, uap->port.membase + UART011_IMSC);