aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorludovic.desroches@atmel.com <ludovic.desroches@atmel.com>2015-11-23 10:27:32 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2015-12-22 05:32:11 -0500
commit447dc0d20a69ebd59f335a096528634a40ea55c0 (patch)
tree63255c00a88d5a0874dbaec603a6aff711f8a651 /drivers/mmc
parenta1904f3cb6a881c6d3b6fa9427e0058e9ac23af6 (diff)
mmc: atmel-mci: atmci_convert_chksize depends on controller version
The atmci_convert_chksize() function is no more valid for controller version 0x600 due to the introduction of '2 data' chunk size. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/atmel-mci.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 9f3bb611000f..a36ebdae2388 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -180,20 +180,6 @@
180# define ATMCI_PDC_CONNECTED 1 180# define ATMCI_PDC_CONNECTED 1
181#endif 181#endif
182 182
183/*
184 * Fix sconfig's burst size according to atmel MCI. We need to convert them as:
185 * 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3.
186 *
187 * This can be done by finding most significant bit set.
188 */
189static inline unsigned int atmci_convert_chksize(unsigned int maxburst)
190{
191 if (maxburst > 1)
192 return fls(maxburst) - 2;
193 else
194 return 0;
195}
196
197#define AUTOSUSPEND_DELAY 50 183#define AUTOSUSPEND_DELAY 50
198 184
199#define ATMCI_DATA_ERROR_FLAGS (ATMCI_DCRCE | ATMCI_DTOE | ATMCI_OVRE | ATMCI_UNRE) 185#define ATMCI_DATA_ERROR_FLAGS (ATMCI_DCRCE | ATMCI_DTOE | ATMCI_OVRE | ATMCI_UNRE)
@@ -732,6 +718,29 @@ static inline unsigned int atmci_get_version(struct atmel_mci *host)
732 return atmci_readl(host, ATMCI_VERSION) & 0x00000fff; 718 return atmci_readl(host, ATMCI_VERSION) & 0x00000fff;
733} 719}
734 720
721/*
722 * Fix sconfig's burst size according to atmel MCI. We need to convert them as:
723 * 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3.
724 * With version 0x600, we need to convert them as: 1 -> 0, 2 -> 1, 4 -> 2,
725 * 8 -> 3, 16 -> 4.
726 *
727 * This can be done by finding most significant bit set.
728 */
729static inline unsigned int atmci_convert_chksize(struct atmel_mci *host,
730 unsigned int maxburst)
731{
732 unsigned int version = atmci_get_version(host);
733 unsigned int offset = 2;
734
735 if (version >= 0x600)
736 offset = 1;
737
738 if (maxburst > 1)
739 return fls(maxburst) - offset;
740 else
741 return 0;
742}
743
735static void atmci_timeout_timer(unsigned long data) 744static void atmci_timeout_timer(unsigned long data)
736{ 745{
737 struct atmel_mci *host; 746 struct atmel_mci *host;
@@ -1182,11 +1191,13 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
1182 if (data->flags & MMC_DATA_READ) { 1191 if (data->flags & MMC_DATA_READ) {
1183 direction = DMA_FROM_DEVICE; 1192 direction = DMA_FROM_DEVICE;
1184 host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM; 1193 host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM;
1185 maxburst = atmci_convert_chksize(host->dma_conf.src_maxburst); 1194 maxburst = atmci_convert_chksize(host,
1195 host->dma_conf.src_maxburst);
1186 } else { 1196 } else {
1187 direction = DMA_TO_DEVICE; 1197 direction = DMA_TO_DEVICE;
1188 host->dma_conf.direction = slave_dirn = DMA_MEM_TO_DEV; 1198 host->dma_conf.direction = slave_dirn = DMA_MEM_TO_DEV;
1189 maxburst = atmci_convert_chksize(host->dma_conf.dst_maxburst); 1199 maxburst = atmci_convert_chksize(host,
1200 host->dma_conf.dst_maxburst);
1190 } 1201 }
1191 1202
1192 if (host->caps.has_dma_conf_reg) 1203 if (host->caps.has_dma_conf_reg)