Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ata: arasan: remove the need for platform_data

This adds a complete DT binding for the arasan device driver. There is
currently only one user, which is the spear13xx platform, so we don't
actually have to parse all the properties until another user comes in,
but this does use the generic DMA binding to find the DMA channel.

The patch is untested so far and is part of a series to convert
the spear platform over to use the generic DMA binding, so it
should stay with the rest of the series.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Viresh Kumar <viresh.linux@linaro.org>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: devicetree-discuss@lists.ozlabs.org

+41 -20
+22
Documentation/devicetree/bindings/ata/pata-arasan.txt
··· 6 6 - interrupt-parent: Should be the phandle for the interrupt controller 7 7 that services interrupts for this device 8 8 - interrupt: Should contain the CF interrupt number 9 + - clock-frequency: Interface clock rate, in Hz, one of 10 + 25000000 11 + 33000000 12 + 40000000 13 + 50000000 14 + 66000000 15 + 75000000 16 + 100000000 17 + 125000000 18 + 150000000 19 + 166000000 20 + 200000000 21 + 22 + Optional properties: 23 + - arasan,broken-udma: if present, UDMA mode is unusable 24 + - arasan,broken-mwdma: if present, MWDMA mode is unusable 25 + - arasan,broken-pio: if present, PIO mode is unusable 26 + - dmas: one DMA channel, as described in bindings/dma/dma.txt 27 + required unless both UDMA and MWDMA mode are broken 28 + - dma-names: the corresponding channel name, must be "data" 9 29 10 30 Example: 11 31 ··· 34 14 reg = <0xfc000000 0x1000>; 35 15 interrupt-parent = <&vic1>; 36 16 interrupts = <12>; 17 + dmas = <&dma-controller 23>; 18 + dma-names = "data"; 37 19 };
+19 -18
drivers/ata/pata_arasan_cf.c
··· 209 209 struct dma_chan *dma_chan; 210 210 /* Mask for DMA transfers */ 211 211 dma_cap_mask_t mask; 212 - /* dma channel private data */ 213 - void *dma_priv; 214 212 /* DMA transfer work */ 215 213 struct work_struct work; 216 214 /* DMA delayed finish work */ ··· 306 308 static int cf_init(struct arasan_cf_dev *acdev) 307 309 { 308 310 struct arasan_cf_pdata *pdata = dev_get_platdata(acdev->host->dev); 311 + unsigned int if_clk; 309 312 unsigned long flags; 310 313 int ret = 0; 311 314 ··· 324 325 325 326 spin_lock_irqsave(&acdev->host->lock, flags); 326 327 /* configure CF interface clock */ 327 - writel((pdata->cf_if_clk <= CF_IF_CLK_200M) ? pdata->cf_if_clk : 328 - CF_IF_CLK_166M, acdev->vbase + CLK_CFG); 328 + /* TODO: read from device tree */ 329 + if_clk = CF_IF_CLK_166M; 330 + if (pdata && pdata->cf_if_clk <= CF_IF_CLK_200M) 331 + if_clk = pdata->cf_if_clk; 332 + 333 + writel(if_clk, acdev->vbase + CLK_CFG); 329 334 330 335 writel(TRUE_IDE_MODE | CFHOST_ENB, acdev->vbase + OP_MODE); 331 336 cf_interrupt_enable(acdev, CARD_DETECT_IRQ, 1); ··· 358 355 struct arasan_cf_dev *acdev = (struct arasan_cf_dev *) dev; 359 356 360 357 complete(&acdev->dma_completion); 361 - } 362 - 363 - static bool filter(struct dma_chan *chan, void *slave) 364 - { 365 - chan->private = slave; 366 - return true; 367 358 } 368 359 369 360 static inline void dma_complete(struct arasan_cf_dev *acdev) ··· 527 530 528 531 /* request dma channels */ 529 532 /* dma_request_channel may sleep, so calling from process context */ 530 - acdev->dma_chan = dma_request_channel(acdev->mask, filter, 531 - acdev->dma_priv); 533 + acdev->dma_chan = dma_request_slave_channel(acdev->host->dev, "data"); 532 534 if (!acdev->dma_chan) { 533 535 dev_err(acdev->host->dev, "Unable to get dma_chan\n"); 534 536 goto chan_request_fail; ··· 794 798 struct ata_host *host; 795 799 struct ata_port *ap; 796 800 struct resource *res; 801 + u32 quirk; 797 802 irq_handler_t irq_handler = NULL; 798 803 int ret = 0; 799 804 ··· 814 817 return -ENOMEM; 815 818 } 816 819 820 + if (pdata) 821 + quirk = pdata->quirk; 822 + else 823 + quirk = CF_BROKEN_UDMA; /* as it is on spear1340 */ 824 + 817 825 /* if irq is 0, support only PIO */ 818 826 acdev->irq = platform_get_irq(pdev, 0); 819 827 if (acdev->irq) 820 828 irq_handler = arasan_cf_interrupt; 821 829 else 822 - pdata->quirk |= CF_BROKEN_MWDMA | CF_BROKEN_UDMA; 830 + quirk |= CF_BROKEN_MWDMA | CF_BROKEN_UDMA; 823 831 824 832 acdev->pbase = res->start; 825 833 acdev->vbase = devm_ioremap_nocache(&pdev->dev, res->start, ··· 861 859 INIT_WORK(&acdev->work, data_xfer); 862 860 INIT_DELAYED_WORK(&acdev->dwork, delayed_finish); 863 861 dma_cap_set(DMA_MEMCPY, acdev->mask); 864 - acdev->dma_priv = pdata->dma_priv; 865 862 866 863 /* Handle platform specific quirks */ 867 - if (pdata->quirk) { 868 - if (pdata->quirk & CF_BROKEN_PIO) { 864 + if (quirk) { 865 + if (quirk & CF_BROKEN_PIO) { 869 866 ap->ops->set_piomode = NULL; 870 867 ap->pio_mask = 0; 871 868 } 872 - if (pdata->quirk & CF_BROKEN_MWDMA) 869 + if (quirk & CF_BROKEN_MWDMA) 873 870 ap->mwdma_mask = 0; 874 - if (pdata->quirk & CF_BROKEN_UDMA) 871 + if (quirk & CF_BROKEN_UDMA) 875 872 ap->udma_mask = 0; 876 873 } 877 874 ap->flags |= ATA_FLAG_PIO_POLLING | ATA_FLAG_NO_ATAPI;
-2
include/linux/pata_arasan_cf_data.h
··· 37 37 #define CF_BROKEN_PIO (1) 38 38 #define CF_BROKEN_MWDMA (1 << 1) 39 39 #define CF_BROKEN_UDMA (1 << 2) 40 - /* This is platform specific data for the DMA controller */ 41 - void *dma_priv; 42 40 }; 43 41 44 42 static inline void