diff options
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/atmel-mci-regs.h | 14 | ||||
-rw-r--r-- | drivers/mmc/host/atmel-mci.c | 8 |
2 files changed, 19 insertions, 3 deletions
diff --git a/drivers/mmc/host/atmel-mci-regs.h b/drivers/mmc/host/atmel-mci-regs.h index 787aba1682b..ab56f7db531 100644 --- a/drivers/mmc/host/atmel-mci-regs.h +++ b/drivers/mmc/host/atmel-mci-regs.h | |||
@@ -140,4 +140,18 @@ | |||
140 | #define atmci_writel(port,reg,value) \ | 140 | #define atmci_writel(port,reg,value) \ |
141 | __raw_writel((value), (port)->regs + reg) | 141 | __raw_writel((value), (port)->regs + reg) |
142 | 142 | ||
143 | /* | ||
144 | * Fix sconfig's burst size according to atmel MCI. We need to convert them as: | ||
145 | * 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3. | ||
146 | * | ||
147 | * This can be done by finding most significant bit set. | ||
148 | */ | ||
149 | static inline unsigned int atmci_convert_chksize(unsigned int maxburst) | ||
150 | { | ||
151 | if (maxburst > 1) | ||
152 | return fls(maxburst) - 2; | ||
153 | else | ||
154 | return 0; | ||
155 | } | ||
156 | |||
143 | #endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */ | 157 | #endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */ |
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index 456c077455c..f2c115e0643 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c | |||
@@ -910,6 +910,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) | |||
910 | enum dma_data_direction direction; | 910 | enum dma_data_direction direction; |
911 | enum dma_transfer_direction slave_dirn; | 911 | enum dma_transfer_direction slave_dirn; |
912 | unsigned int sglen; | 912 | unsigned int sglen; |
913 | u32 maxburst; | ||
913 | u32 iflags; | 914 | u32 iflags; |
914 | 915 | ||
915 | data->error = -EINPROGRESS; | 916 | data->error = -EINPROGRESS; |
@@ -943,17 +944,18 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) | |||
943 | if (!chan) | 944 | if (!chan) |
944 | return -ENODEV; | 945 | return -ENODEV; |
945 | 946 | ||
946 | if (host->caps.has_dma) | ||
947 | atmci_writel(host, ATMCI_DMA, ATMCI_DMA_CHKSIZE(3) | ATMCI_DMAEN); | ||
948 | |||
949 | if (data->flags & MMC_DATA_READ) { | 947 | if (data->flags & MMC_DATA_READ) { |
950 | direction = DMA_FROM_DEVICE; | 948 | direction = DMA_FROM_DEVICE; |
951 | host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM; | 949 | host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM; |
950 | maxburst = atmci_convert_chksize(host->dma_conf.src_maxburst); | ||
952 | } else { | 951 | } else { |
953 | direction = DMA_TO_DEVICE; | 952 | direction = DMA_TO_DEVICE; |
954 | host->dma_conf.direction = slave_dirn = DMA_MEM_TO_DEV; | 953 | host->dma_conf.direction = slave_dirn = DMA_MEM_TO_DEV; |
954 | maxburst = atmci_convert_chksize(host->dma_conf.dst_maxburst); | ||
955 | } | 955 | } |
956 | 956 | ||
957 | atmci_writel(host, ATMCI_DMA, ATMCI_DMA_CHKSIZE(maxburst) | ATMCI_DMAEN); | ||
958 | |||
957 | sglen = dma_map_sg(chan->device->dev, data->sg, | 959 | sglen = dma_map_sg(chan->device->dev, data->sg, |
958 | data->sg_len, direction); | 960 | data->sg_len, direction); |
959 | 961 | ||