[U-Boot] [PATCH 1/3] mmc: add the MMC_CLK_ENABLE/DISABLE macro in mmc.h

mmc_set_clock() function has the disable argument as bool type. When mmc_set_clock is called, it might be passed to "true" or "false". But it's too confusion whether clock is enabled or disabled with only "true" and "false". To prevent the confusion, replace to MMC_CLK_ENABLE/DISABLE macro from true/false.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- drivers/mmc/fsl_esdhc.c | 2 +- drivers/mmc/meson_gx_mmc.c | 2 +- drivers/mmc/mmc.c | 18 ++++++++++-------- include/mmc.h | 3 +++ 4 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index 8d1e2f8a01..a8e94a1dd4 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -674,7 +674,7 @@ static int esdhc_init_common(struct fsl_esdhc_priv *priv, struct mmc *mmc) #endif
/* Set the initial clock speed */ - mmc_set_clock(mmc, 400000, false); + mmc_set_clock(mmc, 400000, MMC_CLK_ENABLE);
/* Disable the BRR and BWR bits in IRQSTAT */ esdhc_clrbits32(®s->irqstaten, IRQSTATEN_BRR | IRQSTATEN_BWR); diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c index a2cd5d3a44..3cd934634d 100644 --- a/drivers/mmc/meson_gx_mmc.c +++ b/drivers/mmc/meson_gx_mmc.c @@ -250,7 +250,7 @@ static int meson_mmc_probe(struct udevice *dev) mmc->priv = pdata; upriv->mmc = mmc;
- mmc_set_clock(mmc, cfg->f_min, false); + mmc_set_clock(mmc, cfg->f_min, MMC_CLK_ENABLE);
/* reset all status bits */ meson_write(mmc, STATUS_MASK, MESON_SD_EMMC_STATUS); diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 255310a8e6..c6475974cc 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -535,7 +535,7 @@ static int mmc_switch_voltage(struct mmc *mmc, int signal_voltage) * During a signal voltage level switch, the clock must be gated * for 5 ms according to the SD spec */ - mmc_set_clock(mmc, mmc->clock, true); + mmc_set_clock(mmc, mmc->clock, MMC_CLK_DISABLE);
err = mmc_set_signal_voltage(mmc, signal_voltage); if (err) @@ -543,7 +543,7 @@ static int mmc_switch_voltage(struct mmc *mmc, int signal_voltage)
/* Keep clock gated for at least 10 ms, though spec only says 5 ms */ mdelay(10); - mmc_set_clock(mmc, mmc->clock, false); + mmc_set_clock(mmc, mmc->clock, MMC_CLK_ENABLE);
/* * Failure to switch is indicated by the card holding @@ -1678,7 +1678,8 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
/* configure the bus mode (host) */ mmc_select_mode(mmc, mwt->mode); - mmc_set_clock(mmc, mmc->tran_speed, false); + mmc_set_clock(mmc, mmc->tran_speed, + MMC_CLK_ENABLE);
#ifdef MMC_SUPPORTS_TUNING /* execute tuning if needed */ @@ -1703,7 +1704,8 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps) error: /* revert to a safer bus speed */ mmc_select_mode(mmc, SD_LEGACY); - mmc_set_clock(mmc, mmc->tran_speed, false); + mmc_set_clock(mmc, mmc->tran_speed, + MMC_CLK_ENABLE); } } } @@ -1864,7 +1866,7 @@ static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps) return -ENOTSUPP; }
- mmc_set_clock(mmc, mmc->legacy_speed, false); + mmc_set_clock(mmc, mmc->legacy_speed, MMC_CLK_ENABLE);
for_each_mmc_mode_by_pref(card_caps, mwt) { for_each_supported_width(card_caps & mwt->widths, @@ -1907,7 +1909,7 @@ static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps)
/* configure the bus mode (host) */ mmc_select_mode(mmc, mwt->mode); - mmc_set_clock(mmc, mmc->tran_speed, false); + mmc_set_clock(mmc, mmc->tran_speed, MMC_CLK_ENABLE); #ifdef MMC_SUPPORTS_TUNING
/* execute tuning if needed */ @@ -2431,7 +2433,7 @@ static void mmc_set_initial_state(struct mmc *mmc)
mmc_select_mode(mmc, MMC_LEGACY); mmc_set_bus_width(mmc, 1); - mmc_set_clock(mmc, 0, false); + mmc_set_clock(mmc, 0, MMC_CLK_ENABLE); }
static int mmc_power_on(struct mmc *mmc) @@ -2451,7 +2453,7 @@ static int mmc_power_on(struct mmc *mmc)
static int mmc_power_off(struct mmc *mmc) { - mmc_set_clock(mmc, 0, true); + mmc_set_clock(mmc, 0, MMC_CLK_DISABLE); #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR) if (mmc->vmmc_supply) { int ret = regulator_set_enable(mmc->vmmc_supply, false); diff --git a/include/mmc.h b/include/mmc.h index a46eaed746..5ab5a0a77a 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -707,6 +707,9 @@ int mmc_voltage_to_mv(enum mmc_voltage voltage); */ int mmc_set_clock(struct mmc *mmc, uint clock, bool disable);
+#define MMC_CLK_ENABLE false +#define MMC_CLK_DISABLE true + struct mmc *find_mmc_device(int dev_num); int mmc_set_dev(int dev_num); void print_mmc_devices(char separator);

Add the debug message for checking the mmc clock status. It's helpful to debug the controlling clock.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- drivers/mmc/mmc.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index c6475974cc..13b3a893d8 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1512,6 +1512,8 @@ int mmc_set_clock(struct mmc *mmc, uint clock, bool disable) mmc->clock = clock; mmc->clk_disable = disable;
+ debug("clock is %s (%dHz)\n", disable ? "disabled" : "enabled", clock); + return mmc_set_ios(mmc); }

Hi,
On 01/26/2018 07:25 PM, Jaehoon Chung wrote:
Add the debug message for checking the mmc clock status. It's helpful to debug the controlling clock.
Will resend the patch. Because Masahiro sent the patch as "mmc: use pr_* log functions". So i will follow his patch. Will use the pr_* log function instead of debug.
Best Regards, Jaehoon Chung
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com
drivers/mmc/mmc.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index c6475974cc..13b3a893d8 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1512,6 +1512,8 @@ int mmc_set_clock(struct mmc *mmc, uint clock, bool disable) mmc->clock = clock; mmc->clk_disable = disable;
- debug("clock is %s (%dHz)\n", disable ? "disabled" : "enabled", clock);
- return mmc_set_ios(mmc);
}

Add the MMC_TRACE config in Kconfig.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- drivers/mmc/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index bc29611d78..d4da7c1728 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -123,6 +123,14 @@ config MMC_VERBOSE Enable the output of more information about the card such as the operating mode.
+config MMC_TRACE + bool "MMC debugging" + default n + help + This is an option for use by developer. Enable MMC core debugging. + + If you need to see the MMC core message, say Y. + config SPL_MMC_TINY bool "Tiny MMC framework in SPL" help
participants (1)
-
Jaehoon Chung