lkml.org 
[lkml]   [2019]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 67/78] mmc: tmio: fix access width of Block Count Register
    Date
    4.19-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Takeshi Saito <takeshi.saito.xv@renesas.com>

    commit 5603731a15ef9ca317c122cc8c959f1dee1798b4 upstream.

    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>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/mmc/host/renesas_sdhi_sys_dmac.c | 1 +
    drivers/mmc/host/tmio_mmc.h | 5 +++++
    drivers/mmc/host/tmio_mmc_core.c | 6 +++++-
    3 files changed, 11 insertions(+), 1 deletion(-)

    --- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c
    +++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c
    @@ -68,6 +68,7 @@ static const struct renesas_sdhi_of_data
    .scc_offset = 0x0300,
    .taps = rcar_gen2_scc_taps,
    .taps_num = ARRAY_SIZE(rcar_gen2_scc_taps),
    + .max_blk_count = 0xffffffff,
    };

    /* Definitions for sampling clocks */
    --- a/drivers/mmc/host/tmio_mmc.h
    +++ b/drivers/mmc/host/tmio_mmc.h
    @@ -279,6 +279,11 @@ static inline void sd_ctrl_write32_as_16
    iowrite16(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
    }

    +static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr, u32 val)
    +{
    + iowrite32(val, host->ctl + (addr << host->bus_shift));
    +}
    +
    static inline void sd_ctrl_write32_rep(struct tmio_mmc_host *host, int addr,
    const u32 *buf, int count)
    {
    --- a/drivers/mmc/host/tmio_mmc_core.c
    +++ b/drivers/mmc/host/tmio_mmc_core.c
    @@ -46,6 +46,7 @@
    #include <linux/regulator/consumer.h>
    #include <linux/mmc/sdio.h>
    #include <linux/scatterlist.h>
    +#include <linux/sizes.h>
    #include <linux/spinlock.h>
    #include <linux/swiotlb.h>
    #include <linux/workqueue.h>
    @@ -777,7 +778,10 @@ static int tmio_mmc_start_data(struct tm

    /* Set transfer length / blocksize */
    sd_ctrl_write16(host, CTL_SD_XFER_LEN, data->blksz);
    - sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks);
    + if (host->mmc->max_blk_count >= SZ_64K)
    + sd_ctrl_write32(host, CTL_XFER_BLK_COUNT, data->blocks);
    + else
    + sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks);

    tmio_mmc_start_dma(host, data);


    \
     
     \ /
      Last update: 2019-03-04 09:42    [W:7.738 / U:0.112 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site