aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2014-09-10 03:23:24 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2014-09-19 14:36:15 -0400
commitb9bd7ff8069a7125da897de657da421c497d4f15 (patch)
tree32e6f0a4ae9fee954c2dfb48370bdc69445e75d6 /drivers/mmc
parent5e1344eb3f4804d2d50195e197fcbcdbd60ad049 (diff)
mmc: tmio: enable odd number size access
Current tmio is using sd_ctrl_read16/write16_rep() for data transfer. It works if transfer size was even number, but, last 1 byte will be ignored if transfer size was odd number. This patch adds new tmio_mmc_transfer_data() and solve this issue. Tested-by: Shinobu Uehara <shinobu.uehara.xc@renesas.com> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/tmio_mmc_pio.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index ff5ff0f725c9..692e578cf4d7 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -376,6 +376,40 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command
376 return 0; 376 return 0;
377} 377}
378 378
379static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
380 unsigned short *buf,
381 unsigned int count)
382{
383 int is_read = host->data->flags & MMC_DATA_READ;
384 u8 *buf8;
385
386 /*
387 * Transfer the data
388 */
389 if (is_read)
390 sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
391 else
392 sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
393
394 /* if count was even number */
395 if (!(count & 0x1))
396 return;
397
398 /* if count was odd number */
399 buf8 = (u8 *)(buf + (count >> 1));
400
401 /*
402 * FIXME
403 *
404 * driver and this function are assuming that
405 * it is used as little endian
406 */
407 if (is_read)
408 *buf8 = sd_ctrl_read16(host, CTL_SD_DATA_PORT) & 0xff;
409 else
410 sd_ctrl_write16(host, CTL_SD_DATA_PORT, *buf8);
411}
412
379/* 413/*
380 * This chip always returns (at least?) as much data as you ask for. 414 * This chip always returns (at least?) as much data as you ask for.
381 * I'm unsure what happens if you ask for less than a block. This should be 415 * I'm unsure what happens if you ask for less than a block. This should be
@@ -408,10 +442,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
408 count, host->sg_off, data->flags); 442 count, host->sg_off, data->flags);
409 443
410 /* Transfer the data */ 444 /* Transfer the data */
411 if (data->flags & MMC_DATA_READ) 445 tmio_mmc_transfer_data(host, buf, count);
412 sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
413 else
414 sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
415 446
416 host->sg_off += count; 447 host->sg_off += count;
417 448