@@ -1441,60 +1441,6 @@ static irqreturn_t atmci_detect_interrupt(int irq, void *dev_id)
14411441 return IRQ_HANDLED ;
14421442}
14431443
1444- #ifdef CONFIG_MMC_ATMELMCI_DMA
1445-
1446- static inline struct atmel_mci *
1447- dma_client_to_atmel_mci (struct dma_client * client )
1448- {
1449- return container_of (client , struct atmel_mci , dma .client );
1450- }
1451-
1452- static enum dma_state_client atmci_dma_event (struct dma_client * client ,
1453- struct dma_chan * chan , enum dma_state state )
1454- {
1455- struct atmel_mci * host ;
1456- enum dma_state_client ret = DMA_NAK ;
1457-
1458- host = dma_client_to_atmel_mci (client );
1459-
1460- switch (state ) {
1461- case DMA_RESOURCE_AVAILABLE :
1462- spin_lock_bh (& host -> lock );
1463- if (!host -> dma .chan ) {
1464- host -> dma .chan = chan ;
1465- ret = DMA_ACK ;
1466- }
1467- spin_unlock_bh (& host -> lock );
1468-
1469- if (ret == DMA_ACK )
1470- dev_info (& host -> pdev -> dev ,
1471- "Using %s for DMA transfers\n" ,
1472- chan -> dev .bus_id );
1473- break ;
1474-
1475- case DMA_RESOURCE_REMOVED :
1476- spin_lock_bh (& host -> lock );
1477- if (host -> dma .chan == chan ) {
1478- host -> dma .chan = NULL ;
1479- ret = DMA_ACK ;
1480- }
1481- spin_unlock_bh (& host -> lock );
1482-
1483- if (ret == DMA_ACK )
1484- dev_info (& host -> pdev -> dev ,
1485- "Lost %s, falling back to PIO\n" ,
1486- chan -> dev .bus_id );
1487- break ;
1488-
1489- default :
1490- break ;
1491- }
1492-
1493-
1494- return ret ;
1495- }
1496- #endif /* CONFIG_MMC_ATMELMCI_DMA */
1497-
14981444static int __init atmci_init_slot (struct atmel_mci * host ,
14991445 struct mci_slot_pdata * slot_data , unsigned int id ,
15001446 u32 sdc_reg )
@@ -1598,6 +1544,18 @@ static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
15981544 mmc_free_host (slot -> mmc );
15991545}
16001546
1547+ #ifdef CONFIG_MMC_ATMELMCI_DMA
1548+ static enum dma_state_client filter (struct dma_chan * chan , void * slave )
1549+ {
1550+ struct dw_dma_slave * dws = slave ;
1551+
1552+ if (dws -> dma_dev == chan -> device -> dev )
1553+ return DMA_ACK ;
1554+ else
1555+ return DMA_DUP ;
1556+ }
1557+ #endif
1558+
16011559static int __init atmci_probe (struct platform_device * pdev )
16021560{
16031561 struct mci_platform_data * pdata ;
@@ -1650,22 +1608,20 @@ static int __init atmci_probe(struct platform_device *pdev)
16501608 goto err_request_irq ;
16511609
16521610#ifdef CONFIG_MMC_ATMELMCI_DMA
1653- if (pdata -> dma_slave ) {
1654- struct dma_slave * slave = pdata -> dma_slave ;
1611+ if (pdata -> dma_slave .dma_dev ) {
1612+ struct dw_dma_slave * dws = & pdata -> dma_slave ;
1613+ dma_cap_mask_t mask ;
16551614
1656- slave -> tx_reg = regs -> start + MCI_TDR ;
1657- slave -> rx_reg = regs -> start + MCI_RDR ;
1615+ dws -> tx_reg = regs -> start + MCI_TDR ;
1616+ dws -> rx_reg = regs -> start + MCI_RDR ;
16581617
16591618 /* Try to grab a DMA channel */
1660- host -> dma .client .event_callback = atmci_dma_event ;
1661- dma_cap_set (DMA_SLAVE , host -> dma .client .cap_mask );
1662- host -> dma .client .slave = slave ;
1663-
1664- dma_async_client_register (& host -> dma .client );
1665- dma_async_client_chan_request (& host -> dma .client );
1666- } else {
1667- dev_notice (& pdev -> dev , "DMA not available, using PIO\n" );
1619+ dma_cap_zero (mask );
1620+ dma_cap_set (DMA_SLAVE , mask );
1621+ host -> dma .chan = dma_request_channel (mask , filter , dws );
16681622 }
1623+ if (!host -> dma .chan )
1624+ dev_notice (& pdev -> dev , "DMA not available, using PIO\n" );
16691625#endif /* CONFIG_MMC_ATMELMCI_DMA */
16701626
16711627 platform_set_drvdata (pdev , host );
@@ -1697,8 +1653,8 @@ static int __init atmci_probe(struct platform_device *pdev)
16971653
16981654err_init_slot :
16991655#ifdef CONFIG_MMC_ATMELMCI_DMA
1700- if (pdata -> dma_slave )
1701- dma_async_client_unregister ( & host -> dma .client );
1656+ if (host -> dma . chan )
1657+ dma_release_channel ( host -> dma .chan );
17021658#endif
17031659 free_irq (irq , host );
17041660err_request_irq :
@@ -1729,8 +1685,8 @@ static int __exit atmci_remove(struct platform_device *pdev)
17291685 clk_disable (host -> mck );
17301686
17311687#ifdef CONFIG_MMC_ATMELMCI_DMA
1732- if (host -> dma .client . slave )
1733- dma_async_client_unregister ( & host -> dma .client );
1688+ if (host -> dma .chan )
1689+ dma_release_channel ( host -> dma .chan );
17341690#endif
17351691
17361692 free_irq (platform_get_irq (pdev , 0 ), host );
@@ -1759,7 +1715,7 @@ static void __exit atmci_exit(void)
17591715 platform_driver_unregister (& atmci_driver );
17601716}
17611717
1762- module_init (atmci_init );
1718+ late_initcall (atmci_init ); /* try to load after dma driver when built-in */
17631719module_exit (atmci_exit );
17641720
17651721MODULE_DESCRIPTION ("Atmel Multimedia Card Interface driver" );
0 commit comments