mmc: dw_mmc: Support setting f_min from host drivers
authorPeter Geis <pgwipeout@gmail.com>
Sat, 5 Mar 2022 21:58:34 +0000 (16:58 -0500)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 7 Mar 2022 11:56:38 +0000 (12:56 +0100)
Host drivers may not be able to support frequencies as low as dw-mmc
supports. Unfortunately f_min isn't available when the drv_data->init
function is called, as the mmc_host struct hasn't been set up yet.

Support the host drivers saving the requested minimum frequency, so we
can later set f_min when it is available.

Signed-off-by: Peter Geis <pgwipeout@gmail.com>
Link: https://lore.kernel.org/r/20220305215835.2210388-2-pgwipeout@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/dw_mmc.c
drivers/mmc/host/dw_mmc.h

index 3420a7a..06dc56c 100644 (file)
@@ -2898,7 +2898,12 @@ static int dw_mci_init_slot_caps(struct dw_mci_slot *slot)
        if (host->pdata->caps2)
                mmc->caps2 = host->pdata->caps2;
 
-       mmc->f_min = DW_MCI_FREQ_MIN;
+       /* if host has set a minimum_freq, we should respect it */
+       if (host->minimum_speed)
+               mmc->f_min = host->minimum_speed;
+       else
+               mmc->f_min = DW_MCI_FREQ_MIN;
+
        if (!mmc->f_max)
                mmc->f_max = DW_MCI_FREQ_MAX;
 
index 7f1e386..4ed81f9 100644 (file)
@@ -99,6 +99,7 @@ struct dw_mci_dma_slave {
  * @bus_hz: The rate of @mck in Hz. This forms the basis for MMC bus
  *     rate and timeout calculations.
  * @current_speed: Configured rate of the controller.
+ * @minimum_speed: Stored minimum rate of the controller.
  * @fifoth_val: The value of FIFOTH register.
  * @verid: Denote Version ID.
  * @dev: Device associated with the MMC controller.
@@ -201,6 +202,7 @@ struct dw_mci {
 
        u32                     bus_hz;
        u32                     current_speed;
+       u32                     minimum_speed;
        u32                     fifoth_val;
        u16                     verid;
        struct device           *dev;