Skip to content

Commit 5603731

Browse files
tasaitostorulf
authored andcommitted
mmc: tmio: fix access width of Block Count Register
In R-Car Gen2 or later, the maximum number of transfer blocks are changed from 0xFFFF to 0xFFFFFFFF. Therefore, Block Count Register should use iowrite32(). If another system (U-boot, Hypervisor OS, etc) uses bit[31:16], this value will not be cleared. So, SD/MMC card initialization fails. So, check for the bigger register and use apropriate write. Also, mark the register as extended on Gen2. Signed-off-by: Takeshi Saito <takeshi.saito.xv@renesas.com> [wsa: use max_blk_count in if(), add Gen2, update commit message] Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Cc: stable@kernel.org Reviewed-by: Simon Horman <horms+renesas@verge.net.au> [Ulf: Fixed build error] Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 5c27ff5 commit 5603731

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

drivers/mmc/host/renesas_sdhi_sys_dmac.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = {
6565
.scc_offset = 0x0300,
6666
.taps = rcar_gen2_scc_taps,
6767
.taps_num = ARRAY_SIZE(rcar_gen2_scc_taps),
68+
.max_blk_count = 0xffffffff,
6869
};
6970

7071
/* Definitions for sampling clocks */

drivers/mmc/host/tmio_mmc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ static inline void sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host,
277277
iowrite16(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
278278
}
279279

280+
static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr, u32 val)
281+
{
282+
iowrite32(val, host->ctl + (addr << host->bus_shift));
283+
}
284+
280285
static inline void sd_ctrl_write32_rep(struct tmio_mmc_host *host, int addr,
281286
const u32 *buf, int count)
282287
{

drivers/mmc/host/tmio_mmc_core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <linux/regulator/consumer.h>
4444
#include <linux/mmc/sdio.h>
4545
#include <linux/scatterlist.h>
46+
#include <linux/sizes.h>
4647
#include <linux/spinlock.h>
4748
#include <linux/swiotlb.h>
4849
#include <linux/workqueue.h>
@@ -703,7 +704,10 @@ static int tmio_mmc_start_data(struct tmio_mmc_host *host,
703704

704705
/* Set transfer length / blocksize */
705706
sd_ctrl_write16(host, CTL_SD_XFER_LEN, data->blksz);
706-
sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks);
707+
if (host->mmc->max_blk_count >= SZ_64K)
708+
sd_ctrl_write32(host, CTL_XFER_BLK_COUNT, data->blocks);
709+
else
710+
sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks);
707711

708712
tmio_mmc_start_dma(host, data);
709713

0 commit comments

Comments
 (0)