mmc: matsushita-common: Special case only select registers in 16bit
PATCH 1/5 mmc: matsushita-common: Special case only select registers in 16bit
There are only a few registerse used in the 16bit mode which are 32bit internally. Special-case only those in the IO accessors and always write both halves. Any other register access is protected from accidentally overwriting neighboring register.
--- drivers/mmc/matsushita-common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/matsushita-common.c +3 -1
@@ -68,7 +68,9 @@ void matsu_sd_writel(struct matsu_sd_priv *priv,writel (val, priv->regbase + (reg <<1 ));if (priv->caps &MATSU_SD_CAP_16BIT ) {writew (val &0xffff , priv->regbase + (reg >>1 )); -if (val >>16 ) +if (reg ==MATSU_SD_INFO1 || reg ==MATSU_SD_INFO1_MASK || + reg ==MATSU_SD_INFO2 || reg ==MATSU_SD_INFO2_MASK || + reg ==MATSU_SD_ARG )writew (val >>16 , priv->regbase + (reg >>1 ) +2 ); }else writel (val, priv->regbase + reg);
Signature · 1 line
2.16.2
PATCH 2/5 mmc: matsushita-common: Correctly set mode in 16bit
The HOST_MODE register must be set to 0 when the IP is operated in 16bit mode, otherwise 16bit access to the data FIFO may fail.
--- drivers/mmc/matsushita-common.c | 2 -- 1 file changed, 2 deletions(-)
drivers/mmc/matsushita-common.c +0 -2
@@ -688,8 +688,6 @@ static void matsu_sd_host_init(struct matsu_sd_priv *priv)*/ if (priv->version >=0x10 )matsu_sd_writel (priv,0x101 ,MATSU_SD_HOST_MODE ); -else if (priv->caps &MATSU_SD_CAP_16BIT ) -matsu_sd_writel (priv,0x1 ,MATSU_SD_HOST_MODE );else matsu_sd_writel (priv,0x0 ,MATSU_SD_HOST_MODE );
Signature · 1 line
2.16.2
PATCH 3/5 mmc: matsushita-common: Wait for command completion
In reply to Marek VasutMake sure to wait for the command to complete altogether, including the trailing 8 clock cycles. This prevents the driver for accidentally writing the CMD register too fast before the previous command fully completed.
--- drivers/mmc/matsushita-common.c | 2 ++ drivers/mmc/matsushita-common.h | 1 + 2 files changed, 3 insertions(+)
drivers/mmc/matsushita-common.c +2 -0
@@ -498,6 +498,8 @@ int matsu_sd_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,return ret; } +matsu_sd_wait_for_irq (dev,MATSU_SD_INFO2 ,MATSU_SD_INFO2_SCLKDIVEN ); +return ret; }
drivers/mmc/matsushita-common.h +1 -0
@@ -38,6 +38,7 @@#define MATSU_SD_INFO2 0x03c/* IRQ status 2 */ #define MATSU_SD_INFO2_ERR_ILA BIT(15)/* illegal access err */ #define MATSU_SD_INFO2_CBSY BIT(14)/* command busy */ +#define MATSU_SD_INFO2_SCLKDIVEN BIT(13)/* command setting reg ena */ #define MATSU_SD_INFO2_BWE BIT(9)/* write buffer ready */ #define MATSU_SD_INFO2_BRE BIT(8)/* read buffer ready */ #define MATSU_SD_INFO2_DAT0 BIT(7)/* SDDAT0 */
Signature · 1 line
2.16.2
PATCH 4/5 mmc: matsushita-common: Add missing else
In reply to Marek VasutFix minor rebase omission, the else was missing which triggered two accesses to the register on 64bit variant of the IP.
--- drivers/mmc/matsushita-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/matsushita-common.c +1 -1
@@ -66,7 +66,7 @@ void matsu_sd_writel(struct matsu_sd_priv *priv, {if (priv->caps &MATSU_SD_CAP_64BIT )writel (val, priv->regbase + (reg <<1 )); -if (priv->caps &MATSU_SD_CAP_16BIT ) { +else if (priv->caps &MATSU_SD_CAP_16BIT ) {writew (val &0xffff , priv->regbase + (reg >>1 )); if (reg == MATSU_SD_INFO1 || reg == MATSU_SD_INFO1_MASK || reg == MATSU_SD_INFO2 || reg == MATSU_SD_INFO2_MASK ||
Signature · 1 line
2.16.2
PATCH 5/5 mmc: renesas-sdhi: Wait after reconfiguring pins
In reply to Marek VasutThe IP requires some time to recuperate after the IO pin properties were changed. Add a delay to assure this.
--- drivers/mmc/renesas-sdhi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/renesas-sdhi.c +3 -0
@@ -289,6 +289,9 @@ out:static int renesas_sdhi_set_ios (struct udevice *dev) {int ret =matsu_sd_set_ios (dev); + +mdelay (10 ); +#if CONFIG_IS_ENABLED (MMC_HS200_SUPPORT )struct matsu_sd_priv *priv =dev_get_priv (dev);
Signature · 1 line
2.16.2