mmc: tegra: Add and use tegra_sdhci_get_max_clock()
Subsystems (3)
PATCH 1/1 mmc: tegra: Add and use tegra_sdhci_get_max_clock()
Implement and use tegra_sdhci_get_max_clock() which returns the true maximum host clock rate. The issue with tegra_sdhci_get_max_clock() is that it returns the current clock rate of the host instead of the maximum one, which can lead to unnecessarily small clock rates.
This differs from the previous implementation of tegra_sdhci_get_max_clock() in that it doesn't divide the result by two.
--- drivers/mmc/host/sdhci-tegra.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-tegra.c +9 -2
@@ -235,6 +235,13 @@ static void tegra_sdhci_set_uhs_signaling(struct sdhci_host *host,sdhci_set_uhs_signaling (host, timing); } +static unsigned int tegra_sdhci_get_max_clock (struct sdhci_host *host) +{ +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); + +return clk_round_rate (pltfm_host->clk,UINT_MAX ); +} +static void tegra_sdhci_set_tap (struct sdhci_host *host,unsigned int tap) {u32 reg;
@@ -299,7 +306,7 @@ static const struct sdhci_ops tegra_sdhci_ops = { .platform_execute_tuning = tegra_sdhci_execute_tuning, .set_uhs_signaling = tegra_sdhci_set_uhs_signaling, .voltage_switch = tegra_sdhci_voltage_switch, - .get_max_clock = sdhci_pltfm_clk_get_max_clock, + .get_max_clock = tegra_sdhci_get_max_clock, };static const struct sdhci_pltfm_data sdhci_tegra20_pdata = {
@@ -356,7 +363,7 @@ static const struct sdhci_ops tegra114_sdhci_ops = { .platform_execute_tuning = tegra_sdhci_execute_tuning, .set_uhs_signaling = tegra_sdhci_set_uhs_signaling, .voltage_switch = tegra_sdhci_voltage_switch, - .get_max_clock = sdhci_pltfm_clk_get_max_clock, + .get_max_clock = tegra_sdhci_get_max_clock, };static const struct sdhci_pltfm_data sdhci_tegra114_pdata = {
Signature · 1 line
2.7.4
Jon Hunter
maintainerQuoted 2 lines · Aapo Vienamo
Implement and use
tegra_sdhci_get_max_clock()which returns the true maximum host clock rate. The issue withtegra_sdhci_get_max_clock()is
Don't you mean sdhci_pltfm_clk_get_max_clock above? Does this function need fixing then? Or at least should there be another variant added because there is nothing Tegra specific we are doing below?
Quoted 5 lines
that it returns the current clock rate of the host instead of the maximum one, which can lead to unnecessarily small clock rates.
This differs from the previous implementation of
tegra_sdhci_get_max_clock()in that it doesn't divide the result by two.
Why?
Fixes tag?
Cheers
Jon
Signature · 1 line
nvpublic
Quoted 7 lines · On Fri, 13 Jul 2018 15:01:21 +0100 Jon Hunter <[email protected]> wrote:
Quoted 2 lines · Aapo Vienamo
Implement and use
tegra_sdhci_get_max_clock()which returns the true maximum host clock rate. The issue withtegra_sdhci_get_max_clock()isDon't you mean
sdhci_pltfm_clk_get_max_clockabove? Does this function need fixing then? Or at least should there be another variant added because there is nothing Tegra specific we are doing below?
There are several drivers which use sdhci_pltfm_clk_get_max_clock() in its current state and changing it could have unforeseen side-effects on drivers which I'm unable to test. Adding another variant of sdhci_pltfm_clk_get_max_clock() would probably be a more feasible approach.
Quoted 7 lines
Quoted 5 lines
that it returns the current clock rate of the host instead of the maximum one, which can lead to unnecessarily small clock rates.
This differs from the previous implementation of
tegra_sdhci_get_max_clock()in that it doesn't divide the result by two.Why?
As far as I can tell the original tegra_sdhci_get_max_clock() was implemented this way in order to force sdhci_calc_clk() to always set the SDHCI clock divider to two on sdhci_set_clock(). The requirement to configure the SDHCI divider to two is specific to DDR50/52 modes on Tegra.
The .get_max_clock() callback retuning half of the actual maximum will result in HS200 and HS400 modes not being able to run at full speed. Another mechanism to enforce the divider requirement has to be figured out in order to enable DDR50/52 modes on Tegra SoCs.
-Aapo
Jon Hunter
maintainerOn 13/07/18 16:39, Aapo Vienamo wrote:
...
Quoted 14 lines
Quoted 7 lines
Quoted 5 lines
that it returns the current clock rate of the host instead of the maximum one, which can lead to unnecessarily small clock rates.
This differs from the previous implementation of
tegra_sdhci_get_max_clock()in that it doesn't divide the result by two.Why?
As far as I can tell the original
tegra_sdhci_get_max_clock()was implemented this way in order to forcesdhci_calc_clk()to always set the SDHCI clock divider to two onsdhci_set_clock(). The requirement to configure the SDHCI divider to two is specific to DDR50/52 modes on Tegra.
Quoted 4 lines
The .get_max_clock() callback retuning half of the actual maximum will result in HS200 and HS400 modes not being able to run at full speed. Another mechanism to enforce the divider requirement has to be figured out in order to enable DDR50/52 modes on Tegra SoCs.
OK, thanks. Ah I see Stefan's patch for doubling the clock. OK so that's fine.
Cheers
Jon
Signature · 1 line
nvpublic
Quoted 11 lines · Aapo Vienamo
Implement and use
tegra_sdhci_get_max_clock()which returns the true maximum host clock rate. The issue withtegra_sdhci_get_max_clock()is
that it returns the current clock rate of the host instead of the maximum one, which can lead to unnecessarily small clock rates.This differs from the previous implementation of
tegra_sdhci_get_max_clock()in that it doesn't divide the result by two.Signed-off-by Aapo Vienamo <[email protected]>
The whole series stress-tested on various Apalis T30 as well as Colibri T30 modules:
Quoted 44 lines
--- drivers/mmc/host/sdhci-tegra.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci- renamed from drivers/mmc/host/sdhci-tegra.c +0
-0
tegra.c
index 28b98e2..ddf00166 100644drivers/mmc/host/sdhci-tegra.c +7
-0@@ -235,6 +235,13 @@ static void tegra_sdhci_set_uhs_signaling(structsdhci_host *host,sdhci_set_uhs_signaling (host ,timing ); } +static unsigned int tegra_sdhci_get_max_clock (struct sdhci_host *host) +{ +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); + +return clk_round_rate (pltfm_host->clk,UINT_MAX ); +} + static void tegra_sdhci_set_tap(struct sdhci_host *host, unsignedint tap)
{drivers/mmc/host/sdhci-tegra.c +2
-2u32 reg;@@ -299,7 +306,7 @@ static const struct sdhci_ops tegra_sdhci_ops = { .platform_execute_tuning = tegra_sdhci_execute_tuning, .set_uhs_signaling = tegra_sdhci_set_uhs_signaling, .voltage_switch = tegra_sdhci_voltage_switch, - .get_max_clock = sdhci_pltfm_clk_get_max_clock, + .get_max_clock = tegra_sdhci_get_max_clock, };static const struct sdhci_pltfm_data sdhci_tegra20_pdata = {@@ -356,7 +363,7 @@ static const struct sdhci_ops tegra114_sdhci_ops = { .platform_execute_tuning = tegra_sdhci_execute_tuning, .set_uhs_signaling = tegra_sdhci_set_uhs_signaling, .voltage_switch = tegra_sdhci_voltage_switch, - .get_max_clock = sdhci_pltfm_clk_get_max_clock, + .get_max_clock = tegra_sdhci_get_max_clock, };
Quoted 1 line
static const struct
sdhci_pltfm_datasdhci_tegra114_pdata= {
Works quite nicely on today's next together with Stefan's patch set [1]:
root@apalis-t30:~# cat /sys/kernel/debug/mmc1/ios clock: 52000000 Hz actual clock: 51000000 Hz vdd: 21 (3.3 ~ 3.4 V) bus mode: 2 (push-pull) chip select: 0 (don't care) power mode: 2 (on) bus width: 3 (8 bits) timing spec: 8 (mmc DDR52) signal voltage: 1 (1.80 V) driver type: 0 (driver type B) root@apalis-t30:~# hdparm -t /dev/mmcblk1
/dev/mmcblk1:
Timing buffered disk reads: 236 MB in 3.01 seconds = 78.42 MB/sec
root@colibri-t30:~# cat /sys/kernel/debug/mmc0/ios clock: 52000000 Hz actual clock: 51000000 Hz vdd: 21 (3.3 ~ 3.4 V) bus mode: 2 (push-pull) chip select: 0 (don't care) power mode: 2 (on) bus width: 3 (8 bits) timing spec: 8 (mmc DDR52) signal voltage: 1 (1.80 V) driver type: 0 (driver type B) root@colibri-t30:~# hdparm -t /dev/mmcblk0
/dev/mmcblk0:
Timing buffered disk reads: 168 MB in 3.00 seconds = 55.99 MB/sec
Ulf Hansson
Applied+Stefan
Quoted 9 lines · Aapo Vienamo
Implement and use
tegra_sdhci_get_max_clock()which returns the true maximum host clock rate. The issue withtegra_sdhci_get_max_clock()is that it returns the current clock rate of the host instead of the maximum one, which can lead to unnecessarily small clock rates.This differs from the previous implementation of
tegra_sdhci_get_max_clock()in that it doesn't divide the result by two.Signed-off-by Aapo Vienamo <[email protected]>
Thanks, applied for next!
I realize there are some discussions and tests going on in regards to the changes for tegra driver. However, I decided to apply all pending patches from Stefan and you, to get them tested in next for a while to see how it plays.
Please tell if you want me to drop some changes - or if you prefer to send patches on top to fix further related issues.
Kind regards
Uffe
Quoted 43 lines
--- drivers/mmc/host/sdhci-tegra.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci-tegra.c +9
-3@@ -235,6 +235,13 @@ static void tegra_sdhci_set_uhs_signaling(struct sdhci_host *host,sdhci_set_uhs_signaling (host, timing); } +static unsigned int tegra_sdhci_get_max_clock (struct sdhci_host *host) +{ +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); + +return clk_round_rate (pltfm_host->clk,UINT_MAX ); +} +static void tegra_sdhci_set_tap (struct sdhci_host *host,unsigned int tap) {u32 reg;@@ -299,7 +306,7 @@ static const struct sdhci_ops tegra_sdhci_ops = { .platform_execute_tuning = tegra_sdhci_execute_tuning, .set_uhs_signaling = tegra_sdhci_set_uhs_signaling, .voltage_switch = tegra_sdhci_voltage_switch, - .get_max_clock = sdhci_pltfm_clk_get_max_clock, + .get_max_clock = tegra_sdhci_get_max_clock, };static const struct sdhci_pltfm_data sdhci_tegra20_pdata = {@@ -356,7 +363,7 @@ static const struct sdhci_ops tegra114_sdhci_ops = { .platform_execute_tuning = tegra_sdhci_execute_tuning, .set_uhs_signaling = tegra_sdhci_set_uhs_signaling, .voltage_switch = tegra_sdhci_voltage_switch, - .get_max_clock = sdhci_pltfm_clk_get_max_clock, + .get_max_clock = tegra_sdhci_get_max_clock, };static const struct sdhci_pltfm_data sdhci_tegra114_pdata = { --2.7.4