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

Configure Feed

Select the types of activity you want to include in your feed.

ata: pata_ep93xx: add device tree support

- add OF ID match table
- drop platform DMA and filters
- change DMA setup to OF, so we can defer probe

Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Tested-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Acked-by: Damien Le Moal <dlemoal@kernel.org>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Nikita Shubin and committed by
Arnd Bergmann
9963113e f4da2b60

+42 -38
+42 -38
drivers/ata/pata_ep93xx.c
··· 44 44 #include <linux/delay.h> 45 45 #include <linux/dmaengine.h> 46 46 #include <linux/ktime.h> 47 + #include <linux/mod_devicetable.h> 47 48 48 - #include <linux/platform_data/dma-ep93xx.h> 49 49 #include <linux/soc/cirrus/ep93xx.h> 50 50 51 51 #define DRV_NAME "ep93xx-ide" ··· 126 126 }; 127 127 128 128 struct ep93xx_pata_data { 129 - const struct platform_device *pdev; 129 + struct platform_device *pdev; 130 130 void __iomem *ide_base; 131 131 struct ata_timing t; 132 132 bool iordy; ··· 135 135 unsigned long udma_out_phys; 136 136 137 137 struct dma_chan *dma_rx_channel; 138 - struct ep93xx_dma_data dma_rx_data; 139 138 struct dma_chan *dma_tx_channel; 140 - struct ep93xx_dma_data dma_tx_data; 141 139 }; 142 140 143 141 static void ep93xx_pata_clear_regs(void __iomem *base) ··· 635 637 } 636 638 } 637 639 638 - static bool ep93xx_pata_dma_filter(struct dma_chan *chan, void *filter_param) 640 + static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data) 639 641 { 640 - if (ep93xx_dma_chan_is_m2p(chan)) 641 - return false; 642 - 643 - chan->private = filter_param; 644 - return true; 645 - } 646 - 647 - static void ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data) 648 - { 649 - const struct platform_device *pdev = drv_data->pdev; 642 + struct platform_device *pdev = drv_data->pdev; 643 + struct device *dev = &pdev->dev; 650 644 dma_cap_mask_t mask; 651 645 struct dma_slave_config conf; 646 + int ret; 652 647 653 648 dma_cap_zero(mask); 654 649 dma_cap_set(DMA_SLAVE, mask); ··· 651 660 * to request only one channel, and reprogram it's direction at 652 661 * start of new transfer. 653 662 */ 654 - drv_data->dma_rx_data.port = EP93XX_DMA_IDE; 655 - drv_data->dma_rx_data.direction = DMA_DEV_TO_MEM; 656 - drv_data->dma_rx_data.name = "ep93xx-pata-rx"; 657 - drv_data->dma_rx_channel = dma_request_channel(mask, 658 - ep93xx_pata_dma_filter, &drv_data->dma_rx_data); 659 - if (!drv_data->dma_rx_channel) 660 - return; 663 + drv_data->dma_rx_channel = dma_request_chan(dev, "rx"); 664 + if (IS_ERR(drv_data->dma_rx_channel)) 665 + return dev_err_probe(dev, PTR_ERR(drv_data->dma_rx_channel), 666 + "rx DMA setup failed\n"); 661 667 662 - drv_data->dma_tx_data.port = EP93XX_DMA_IDE; 663 - drv_data->dma_tx_data.direction = DMA_MEM_TO_DEV; 664 - drv_data->dma_tx_data.name = "ep93xx-pata-tx"; 665 - drv_data->dma_tx_channel = dma_request_channel(mask, 666 - ep93xx_pata_dma_filter, &drv_data->dma_tx_data); 667 - if (!drv_data->dma_tx_channel) { 668 - dma_release_channel(drv_data->dma_rx_channel); 669 - return; 668 + drv_data->dma_tx_channel = dma_request_chan(&pdev->dev, "tx"); 669 + if (IS_ERR(drv_data->dma_tx_channel)) { 670 + ret = dev_err_probe(dev, PTR_ERR(drv_data->dma_tx_channel), 671 + "tx DMA setup failed\n"); 672 + goto fail_release_rx; 670 673 } 671 674 672 675 /* Configure receive channel direction and source address */ ··· 668 683 conf.direction = DMA_DEV_TO_MEM; 669 684 conf.src_addr = drv_data->udma_in_phys; 670 685 conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 671 - if (dmaengine_slave_config(drv_data->dma_rx_channel, &conf)) { 672 - dev_err(&pdev->dev, "failed to configure rx dma channel\n"); 673 - ep93xx_pata_release_dma(drv_data); 674 - return; 686 + ret = dmaengine_slave_config(drv_data->dma_rx_channel, &conf); 687 + if (ret) { 688 + dev_err_probe(dev, ret, "failed to configure rx dma channel"); 689 + goto fail_release_dma; 675 690 } 676 691 677 692 /* Configure transmit channel direction and destination address */ ··· 679 694 conf.direction = DMA_MEM_TO_DEV; 680 695 conf.dst_addr = drv_data->udma_out_phys; 681 696 conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 682 - if (dmaengine_slave_config(drv_data->dma_tx_channel, &conf)) { 683 - dev_err(&pdev->dev, "failed to configure tx dma channel\n"); 684 - ep93xx_pata_release_dma(drv_data); 697 + ret = dmaengine_slave_config(drv_data->dma_tx_channel, &conf); 698 + if (ret) { 699 + dev_err_probe(dev, ret, "failed to configure tx dma channel"); 700 + goto fail_release_dma; 685 701 } 702 + 703 + return 0; 704 + 705 + fail_release_rx: 706 + dma_release_channel(drv_data->dma_rx_channel); 707 + fail_release_dma: 708 + ep93xx_pata_release_dma(drv_data); 709 + 710 + return ret; 686 711 } 687 712 688 713 static void ep93xx_pata_dma_start(struct ata_queued_cmd *qc) ··· 949 954 drv_data->ide_base = ide_base; 950 955 drv_data->udma_in_phys = mem_res->start + IDEUDMADATAIN; 951 956 drv_data->udma_out_phys = mem_res->start + IDEUDMADATAOUT; 952 - ep93xx_pata_dma_init(drv_data); 957 + err = ep93xx_pata_dma_init(drv_data); 958 + if (err) 959 + return err; 953 960 954 961 /* allocate host */ 955 962 host = ata_host_alloc(&pdev->dev, 1); ··· 1018 1021 ep93xx_ide_release_gpio(pdev); 1019 1022 } 1020 1023 1024 + static const struct of_device_id ep93xx_pata_of_ids[] = { 1025 + { .compatible = "cirrus,ep9312-pata" }, 1026 + { /* sentinel */ } 1027 + }; 1028 + MODULE_DEVICE_TABLE(of, ep93xx_pata_of_ids); 1029 + 1021 1030 static struct platform_driver ep93xx_pata_platform_driver = { 1022 1031 .driver = { 1023 1032 .name = DRV_NAME, 1033 + .of_match_table = ep93xx_pata_of_ids, 1024 1034 }, 1025 1035 .probe = ep93xx_pata_probe, 1026 1036 .remove_new = ep93xx_pata_remove,