4444#include <linux/delay.h>
4545#include <linux/dmaengine.h>
4646#include <linux/ktime.h>
47+ #include <linux/mod_devicetable.h>
4748
48- #include <linux/platform_data/dma-ep93xx.h>
4949#include <linux/soc/cirrus/ep93xx.h>
5050
5151#define DRV_NAME "ep93xx-ide"
@@ -126,7 +126,7 @@ enum {
126126};
127127
128128struct ep93xx_pata_data {
129- const struct platform_device * pdev ;
129+ struct platform_device * pdev ;
130130 void __iomem * ide_base ;
131131 struct ata_timing t ;
132132 bool iordy ;
@@ -135,9 +135,7 @@ struct ep93xx_pata_data {
135135 unsigned long udma_out_phys ;
136136
137137 struct dma_chan * dma_rx_channel ;
138- struct ep93xx_dma_data dma_rx_data ;
139138 struct dma_chan * dma_tx_channel ;
140- struct ep93xx_dma_data dma_tx_data ;
141139};
142140
143141static void ep93xx_pata_clear_regs (void __iomem * base )
@@ -637,20 +635,13 @@ static void ep93xx_pata_release_dma(struct ep93xx_pata_data *drv_data)
637635 }
638636}
639637
640- static bool ep93xx_pata_dma_filter (struct dma_chan * chan , void * filter_param )
638+ static int ep93xx_pata_dma_init (struct ep93xx_pata_data * drv_data )
641639{
642- if (ep93xx_dma_chan_is_m2p (chan ))
643- return false;
644-
645- chan -> private = filter_param ;
646- return true;
647- }
648-
649- static void ep93xx_pata_dma_init (struct ep93xx_pata_data * drv_data )
650- {
651- const struct platform_device * pdev = drv_data -> pdev ;
640+ struct platform_device * pdev = drv_data -> pdev ;
641+ struct device * dev = & pdev -> dev ;
652642 dma_cap_mask_t mask ;
653643 struct dma_slave_config conf ;
644+ int ret ;
654645
655646 dma_cap_zero (mask );
656647 dma_cap_set (DMA_SLAVE , mask );
@@ -660,44 +651,48 @@ static void ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data)
660651 * to request only one channel, and reprogram it's direction at
661652 * start of new transfer.
662653 */
663- drv_data -> dma_rx_data .port = EP93XX_DMA_IDE ;
664- drv_data -> dma_rx_data .direction = DMA_DEV_TO_MEM ;
665- drv_data -> dma_rx_data .name = "ep93xx-pata-rx" ;
666- drv_data -> dma_rx_channel = dma_request_channel (mask ,
667- ep93xx_pata_dma_filter , & drv_data -> dma_rx_data );
668- if (!drv_data -> dma_rx_channel )
669- return ;
670-
671- drv_data -> dma_tx_data .port = EP93XX_DMA_IDE ;
672- drv_data -> dma_tx_data .direction = DMA_MEM_TO_DEV ;
673- drv_data -> dma_tx_data .name = "ep93xx-pata-tx" ;
674- drv_data -> dma_tx_channel = dma_request_channel (mask ,
675- ep93xx_pata_dma_filter , & drv_data -> dma_tx_data );
676- if (!drv_data -> dma_tx_channel ) {
677- dma_release_channel (drv_data -> dma_rx_channel );
678- return ;
654+ drv_data -> dma_rx_channel = dma_request_chan (dev , "rx" );
655+ if (IS_ERR (drv_data -> dma_rx_channel ))
656+ return dev_err_probe (dev , PTR_ERR (drv_data -> dma_rx_channel ),
657+ "rx DMA setup failed\n" );
658+
659+ drv_data -> dma_tx_channel = dma_request_chan (& pdev -> dev , "tx" );
660+ if (IS_ERR (drv_data -> dma_tx_channel )) {
661+ ret = dev_err_probe (dev , PTR_ERR (drv_data -> dma_tx_channel ),
662+ "tx DMA setup failed\n" );
663+ goto fail_release_rx ;
679664 }
680665
681666 /* Configure receive channel direction and source address */
682667 memset (& conf , 0 , sizeof (conf ));
683668 conf .direction = DMA_DEV_TO_MEM ;
684669 conf .src_addr = drv_data -> udma_in_phys ;
685670 conf .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES ;
686- if ( dmaengine_slave_config (drv_data -> dma_rx_channel , & conf )) {
687- dev_err ( & pdev -> dev , "failed to configure rx dma channel\n" );
688- ep93xx_pata_release_dma ( drv_data );
689- return ;
671+ ret = dmaengine_slave_config (drv_data -> dma_rx_channel , & conf );
672+ if ( ret ) {
673+ dev_err_probe ( dev , ret , "failed to configure rx dma channel" );
674+ goto fail_release_dma ;
690675 }
691676
692677 /* Configure transmit channel direction and destination address */
693678 memset (& conf , 0 , sizeof (conf ));
694679 conf .direction = DMA_MEM_TO_DEV ;
695680 conf .dst_addr = drv_data -> udma_out_phys ;
696681 conf .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES ;
697- if (dmaengine_slave_config (drv_data -> dma_tx_channel , & conf )) {
698- dev_err (& pdev -> dev , "failed to configure tx dma channel\n" );
699- ep93xx_pata_release_dma (drv_data );
682+ ret = dmaengine_slave_config (drv_data -> dma_tx_channel , & conf );
683+ if (ret ) {
684+ dev_err_probe (dev , ret , "failed to configure tx dma channel" );
685+ goto fail_release_dma ;
700686 }
687+
688+ return 0 ;
689+
690+ fail_release_rx :
691+ dma_release_channel (drv_data -> dma_rx_channel );
692+ fail_release_dma :
693+ ep93xx_pata_release_dma (drv_data );
694+
695+ return ret ;
701696}
702697
703698static void ep93xx_pata_dma_start (struct ata_queued_cmd * qc )
@@ -954,7 +949,9 @@ static int ep93xx_pata_probe(struct platform_device *pdev)
954949 drv_data -> ide_base = ide_base ;
955950 drv_data -> udma_in_phys = mem_res -> start + IDEUDMADATAIN ;
956951 drv_data -> udma_out_phys = mem_res -> start + IDEUDMADATAOUT ;
957- ep93xx_pata_dma_init (drv_data );
952+ err = ep93xx_pata_dma_init (drv_data );
953+ if (err )
954+ return err ;
958955
959956 /* allocate host */
960957 host = ata_host_alloc (& pdev -> dev , 1 );
@@ -1021,9 +1018,16 @@ static void ep93xx_pata_remove(struct platform_device *pdev)
10211018 ep93xx_ide_release_gpio (pdev );
10221019}
10231020
1021+ static const struct of_device_id ep93xx_pata_of_ids [] = {
1022+ { .compatible = "cirrus,ep9312-pata" },
1023+ { /* sentinel */ }
1024+ };
1025+ MODULE_DEVICE_TABLE (of , ep93xx_pata_of_ids );
1026+
10241027static struct platform_driver ep93xx_pata_platform_driver = {
10251028 .driver = {
10261029 .name = DRV_NAME ,
1030+ .of_match_table = ep93xx_pata_of_ids ,
10271031 },
10281032 .probe = ep93xx_pata_probe ,
10291033 .remove_new = ep93xx_pata_remove ,
0 commit comments