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,7 +126,7 @@ enum {
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,9 +135,7 @@ struct ep93xx_pata_data {
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 )
@@ -637,20 +635,13 @@ static void ep93xx_pata_release_dma(struct ep93xx_pata_data *drv_data)
637
635
}
638
636
}
639
637
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 )
641
639
{
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 ;
652
642
dma_cap_mask_t mask ;
653
643
struct dma_slave_config conf ;
644
+ int ret ;
654
645
655
646
dma_cap_zero (mask );
656
647
dma_cap_set (DMA_SLAVE , mask );
@@ -660,44 +651,48 @@ static void ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data)
660
651
* to request only one channel, and reprogram it's direction at
661
652
* start of new transfer.
662
653
*/
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 ;
679
664
}
680
665
681
666
/* Configure receive channel direction and source address */
682
667
memset (& conf , 0 , sizeof (conf ));
683
668
conf .direction = DMA_DEV_TO_MEM ;
684
669
conf .src_addr = drv_data -> udma_in_phys ;
685
670
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 ;
690
675
}
691
676
692
677
/* Configure transmit channel direction and destination address */
693
678
memset (& conf , 0 , sizeof (conf ));
694
679
conf .direction = DMA_MEM_TO_DEV ;
695
680
conf .dst_addr = drv_data -> udma_out_phys ;
696
681
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 ;
700
686
}
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 ;
701
696
}
702
697
703
698
static void ep93xx_pata_dma_start (struct ata_queued_cmd * qc )
@@ -954,7 +949,9 @@ static int ep93xx_pata_probe(struct platform_device *pdev)
954
949
drv_data -> ide_base = ide_base ;
955
950
drv_data -> udma_in_phys = mem_res -> start + IDEUDMADATAIN ;
956
951
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 ;
958
955
959
956
/* allocate host */
960
957
host = ata_host_alloc (& pdev -> dev , 1 );
@@ -1021,9 +1018,16 @@ static void ep93xx_pata_remove(struct platform_device *pdev)
1021
1018
ep93xx_ide_release_gpio (pdev );
1022
1019
}
1023
1020
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
+
1024
1027
static struct platform_driver ep93xx_pata_platform_driver = {
1025
1028
.driver = {
1026
1029
.name = DRV_NAME ,
1030
+ .of_match_table = ep93xx_pata_of_ids ,
1027
1031
},
1028
1032
.probe = ep93xx_pata_probe ,
1029
1033
.remove_new = ep93xx_pata_remove ,
0 commit comments