diff options
| author | Veerabhadrarao Badiganti <vbadigan@codeaurora.org> | 2017-05-30 20:44:06 +0530 |
|---|---|---|
| committer | Veerabhadrarao Badiganti <vbadigan@codeaurora.org> | 2017-06-02 23:20:33 +0530 |
| commit | 1cc23bd6d0b49f12807c07a41cd4eb88bcc3738b (patch) | |
| tree | 04fa3aa19361f2e5f8f80ca07988c78abf34dfcc | |
| parent | 70bc2b791f1b2f801331b6764fd9566c61588f1b (diff) | |
mmc: core: Initialize the devfreq table with default frequencies
Initialize the clock scaling frequency table with the platform specific
frequencies while preparing it. So that the frequencies supported by
the card can be compared against the frequencies supported by the
platform and then the table can be updated with the optimal frequencies
to match with both card and platform.
Without resetting these values to default values, this table contains
the frequencies updated for the last used card. These old values would
be used instead of platform-specific values to compare against the
frequencies of the newly inserted card. This can result in limiting
the max frequency to a lower frequency than what actually card can support.
Say if an high-speed card is used first and then a ultra-high-speed card,
the max scaling frequency would get set to the max of high-speed card
instead of max of the ultra-high-speed card.
Change-Id: I09a36e36c189e1d1fc317d798a0e3ff899f4e560
Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
| -rw-r--r-- | drivers/mmc/core/core.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 63f7bf87843f..c23f3c3ec864 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -616,17 +616,39 @@ static int mmc_devfreq_create_freq_table(struct mmc_host *host) host->card->clk_scaling_lowest, host->card->clk_scaling_highest); + /* + * Create the frequency table and initialize it with default values. + * Initialize it with platform specific frequencies if the frequency + * table supplied by platform driver is present, otherwise initialize + * it with min and max frequencies supported by the card. + */ if (!clk_scaling->freq_table) { - pr_debug("%s: no frequency table defined - setting default\n", - mmc_hostname(host)); + if (clk_scaling->pltfm_freq_table_sz) + clk_scaling->freq_table_sz = + clk_scaling->pltfm_freq_table_sz; + else + clk_scaling->freq_table_sz = 2; + clk_scaling->freq_table = kzalloc( - 2*sizeof(*(clk_scaling->freq_table)), GFP_KERNEL); + (clk_scaling->freq_table_sz * + sizeof(*(clk_scaling->freq_table))), GFP_KERNEL); if (!clk_scaling->freq_table) return -ENOMEM; - clk_scaling->freq_table[0] = host->card->clk_scaling_lowest; - clk_scaling->freq_table[1] = host->card->clk_scaling_highest; - clk_scaling->freq_table_sz = 2; - goto out; + + if (clk_scaling->pltfm_freq_table) { + memcpy(clk_scaling->freq_table, + clk_scaling->pltfm_freq_table, + (clk_scaling->pltfm_freq_table_sz * + sizeof(*(clk_scaling->pltfm_freq_table)))); + } else { + pr_debug("%s: no frequency table defined - setting default\n", + mmc_hostname(host)); + clk_scaling->freq_table[0] = + host->card->clk_scaling_lowest; + clk_scaling->freq_table[1] = + host->card->clk_scaling_highest; + goto out; + } } if (host->card->clk_scaling_lowest > @@ -895,6 +917,10 @@ int mmc_exit_clk_scaling(struct mmc_host *host) host->clk_scaling.devfreq = NULL; atomic_set(&host->clk_scaling.devfreq_abort, 1); + + kfree(host->clk_scaling.freq_table); + host->clk_scaling.freq_table = NULL; + pr_debug("%s: devfreq was removed\n", mmc_hostname(host)); return 0; |
