6464#define AU1XMMC_DESCRIPTOR_COUNT 1
6565
6666/* max DMA seg size: 64KB on Au1100, 4MB on Au1200 */
67- #ifdef CONFIG_SOC_AU1100
68- #define AU1XMMC_DESCRIPTOR_SIZE 0x0000ffff
69- #else /* Au1200 */
70- #define AU1XMMC_DESCRIPTOR_SIZE 0x003fffff
71- #endif
67+ #define AU1100_MMC_DESCRIPTOR_SIZE 0x0000ffff
68+ #define AU1200_MMC_DESCRIPTOR_SIZE 0x003fffff
7269
7370#define AU1XMMC_OCR (MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30 | \
7471 MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 | \
@@ -127,6 +124,7 @@ struct au1xmmc_host {
127124#define HOST_F_XMIT 0x0001
128125#define HOST_F_RECV 0x0002
129126#define HOST_F_DMA 0x0010
127+ #define HOST_F_DBDMA 0x0020
130128#define HOST_F_ACTIVE 0x0100
131129#define HOST_F_STOP 0x1000
132130
@@ -151,6 +149,16 @@ struct au1xmmc_host {
151149#define DMA_CHANNEL (h ) \
152150 (((h)->flags & HOST_F_XMIT) ? (h)->tx_chan : (h)->rx_chan)
153151
152+ static inline int has_dbdma (void )
153+ {
154+ switch (alchemy_get_cputype ()) {
155+ case ALCHEMY_CPU_AU1200 :
156+ return 1 ;
157+ default :
158+ return 0 ;
159+ }
160+ }
161+
154162static inline void IRQ_ON (struct au1xmmc_host * host , u32 mask )
155163{
156164 u32 val = au_readl (HOST_CONFIG (host ));
@@ -353,14 +361,12 @@ static void au1xmmc_data_complete(struct au1xmmc_host *host, u32 status)
353361 data -> bytes_xfered = 0 ;
354362
355363 if (!data -> error ) {
356- if (host -> flags & HOST_F_DMA ) {
357- #ifdef CONFIG_SOC_AU1200 /* DBDMA */
364+ if (host -> flags & (HOST_F_DMA | HOST_F_DBDMA )) {
358365 u32 chan = DMA_CHANNEL (host );
359366
360367 chan_tab_t * c = * ((chan_tab_t * * )chan );
361368 au1x_dma_chan_t * cp = c -> chan_ptr ;
362369 data -> bytes_xfered = cp -> ddma_bytecnt ;
363- #endif
364370 } else
365371 data -> bytes_xfered =
366372 (data -> blocks * data -> blksz ) - host -> pio .len ;
@@ -570,11 +576,10 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
570576
571577 host -> status = HOST_S_DATA ;
572578
573- if (host -> flags & HOST_F_DMA ) {
574- #ifdef CONFIG_SOC_AU1200 /* DBDMA */
579+ if ((host -> flags & (HOST_F_DMA | HOST_F_DBDMA ))) {
575580 u32 channel = DMA_CHANNEL (host );
576581
577- /* Start the DMA as soon as the buffer gets something in it */
582+ /* Start the DBDMA as soon as the buffer gets something in it */
578583
579584 if (host -> flags & HOST_F_RECV ) {
580585 u32 mask = SD_STATUS_DB | SD_STATUS_NE ;
@@ -584,7 +589,6 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
584589 }
585590
586591 au1xxx_dbdma_start (channel );
587- #endif
588592 }
589593}
590594
@@ -633,8 +637,7 @@ static int au1xmmc_prepare_data(struct au1xmmc_host *host,
633637
634638 au_writel (data -> blksz - 1 , HOST_BLKSIZE (host ));
635639
636- if (host -> flags & HOST_F_DMA ) {
637- #ifdef CONFIG_SOC_AU1200 /* DBDMA */
640+ if (host -> flags & (HOST_F_DMA | HOST_F_DBDMA )) {
638641 int i ;
639642 u32 channel = DMA_CHANNEL (host );
640643
@@ -663,7 +666,6 @@ static int au1xmmc_prepare_data(struct au1xmmc_host *host,
663666
664667 datalen -= len ;
665668 }
666- #endif
667669 } else {
668670 host -> pio .index = 0 ;
669671 host -> pio .offset = 0 ;
@@ -838,7 +840,6 @@ static irqreturn_t au1xmmc_irq(int irq, void *dev_id)
838840 return IRQ_HANDLED ;
839841}
840842
841- #ifdef CONFIG_SOC_AU1200
842843/* 8bit memory DMA device */
843844static dbdev_tab_t au1xmmc_mem_dbdev = {
844845 .dev_id = DSCR_CMD0_ALWAYS ,
@@ -905,7 +906,7 @@ static int au1xmmc_dbdma_init(struct au1xmmc_host *host)
905906 au1xxx_dbdma_ring_alloc (host -> rx_chan , AU1XMMC_DESCRIPTOR_COUNT );
906907
907908 /* DBDMA is good to go */
908- host -> flags |= HOST_F_DMA ;
909+ host -> flags |= HOST_F_DMA | HOST_F_DBDMA ;
909910
910911 return 0 ;
911912}
@@ -918,7 +919,6 @@ static void au1xmmc_dbdma_shutdown(struct au1xmmc_host *host)
918919 au1xxx_dbdma_chan_free (host -> rx_chan );
919920 }
920921}
921- #endif
922922
923923static void au1xmmc_enable_sdio_irq (struct mmc_host * mmc , int en )
924924{
@@ -997,8 +997,16 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev)
997997 mmc -> f_min = 450000 ;
998998 mmc -> f_max = 24000000 ;
999999
1000- mmc -> max_seg_size = AU1XMMC_DESCRIPTOR_SIZE ;
1001- mmc -> max_segs = AU1XMMC_DESCRIPTOR_COUNT ;
1000+ switch (alchemy_get_cputype ()) {
1001+ case ALCHEMY_CPU_AU1100 :
1002+ mmc -> max_seg_size = AU1100_MMC_DESCRIPTOR_SIZE ;
1003+ mmc -> max_segs = AU1XMMC_DESCRIPTOR_COUNT ;
1004+ break ;
1005+ case ALCHEMY_CPU_AU1200 :
1006+ mmc -> max_seg_size = AU1200_MMC_DESCRIPTOR_SIZE ;
1007+ mmc -> max_segs = AU1XMMC_DESCRIPTOR_COUNT ;
1008+ break ;
1009+ }
10021010
10031011 mmc -> max_blk_size = 2048 ;
10041012 mmc -> max_blk_count = 512 ;
@@ -1028,11 +1036,12 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev)
10281036 tasklet_init (& host -> finish_task , au1xmmc_tasklet_finish ,
10291037 (unsigned long )host );
10301038
1031- #ifdef CONFIG_SOC_AU1200
1032- ret = au1xmmc_dbdma_init (host );
1033- if (ret )
1034- printk (KERN_INFO DRIVER_NAME ": DBDMA init failed; using PIO\n" );
1035- #endif
1039+ if (has_dbdma ()) {
1040+ ret = au1xmmc_dbdma_init (host );
1041+ if (ret )
1042+ printk (KERN_INFO DRIVER_NAME ": DBDMA init failed; "
1043+ "using PIO\n" );
1044+ }
10361045
10371046#ifdef CONFIG_LEDS_CLASS
10381047 if (host -> platdata && host -> platdata -> led ) {
@@ -1073,9 +1082,8 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev)
10731082 au_writel (0 , HOST_CONFIG2 (host ));
10741083 au_sync ();
10751084
1076- #ifdef CONFIG_SOC_AU1200
1077- au1xmmc_dbdma_shutdown (host );
1078- #endif
1085+ if (host -> flags & HOST_F_DBDMA )
1086+ au1xmmc_dbdma_shutdown (host );
10791087
10801088 tasklet_kill (& host -> data_task );
10811089 tasklet_kill (& host -> finish_task );
@@ -1120,9 +1128,9 @@ static int __devexit au1xmmc_remove(struct platform_device *pdev)
11201128 tasklet_kill (& host -> data_task );
11211129 tasklet_kill (& host -> finish_task );
11221130
1123- #ifdef CONFIG_SOC_AU1200
1124- au1xmmc_dbdma_shutdown (host );
1125- #endif
1131+ if ( host -> flags & HOST_F_DBDMA )
1132+ au1xmmc_dbdma_shutdown (host );
1133+
11261134 au1xmmc_set_power (host , 0 );
11271135
11281136 free_irq (host -> irq , host );
@@ -1181,24 +1189,23 @@ static struct platform_driver au1xmmc_driver = {
11811189
11821190static int __init au1xmmc_init (void )
11831191{
1184- #ifdef CONFIG_SOC_AU1200
1185- /* DSCR_CMD0_ALWAYS has a stride of 32 bits, we need a stride
1186- * of 8 bits. And since devices are shared, we need to create
1187- * our own to avoid freaking out other devices.
1188- */
1189- memid = au1xxx_ddma_add_device (& au1xmmc_mem_dbdev );
1190- if (!memid )
1191- printk (KERN_ERR "au1xmmc: cannot add memory dbdma dev \n" );
1192- #endif
1192+ if ( has_dbdma ()) {
1193+ /* DSCR_CMD0_ALWAYS has a stride of 32 bits, we need a stride
1194+ * of 8 bits. And since devices are shared, we need to create
1195+ * our own to avoid freaking out other devices.
1196+ */
1197+ memid = au1xxx_ddma_add_device (& au1xmmc_mem_dbdev );
1198+ if (!memid )
1199+ printk (KERN_ERR "au1xmmc: cannot add memory dbdma\n" );
1200+ }
11931201 return platform_driver_register (& au1xmmc_driver );
11941202}
11951203
11961204static void __exit au1xmmc_exit (void )
11971205{
1198- #ifdef CONFIG_SOC_AU1200
1199- if (memid )
1206+ if (has_dbdma () && memid )
12001207 au1xxx_ddma_del_device (memid );
1201- #endif
1208+
12021209 platform_driver_unregister (& au1xmmc_driver );
12031210}
12041211
0 commit comments