mmc: sdhci-of-aspeed: Fixes for AST2600 eMMC
Subsystems (5)
cover mmc: sdhci-of-aspeed: Fixes for AST2600 eMMC
Hello,
This series enables the eMMC onboard the AST2600 EVB. There's currently a limitation of running it at 52MHz, I'm still investigating that. Reads and writes are both functional.
The two critical patches (3/5 and 4/5) are on the linux-mmc list and can be found here:
https://patchwork.ozlabs.org/project/linux-aspeed/list/?series=128207&state=%2A&archive=both
Cheers,
Andrew
Andrew Jeffery (4):
mmc: sdhci-of-aspeed: Drop redundant assignment to host->clock
mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock()
mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK
ARM: dts: ast2600-evb: eMMC configuration
Wei Yongjun (1):
mmc: sdhci-of-aspeed: Fix return value check in aspeed_sdc_probe()
arch/arm/boot/dts/aspeed-ast2600-evb.dts | 8 ++++++- arch/arm/boot/dts/aspeed-g6.dtsi | 4 ++-- drivers/mmc/host/sdhci-of-aspeed.c | 28 ++++++++++++++++-------- 3 files changed, 28 insertions(+), 12 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/5 mmc: sdhci-of-aspeed: Fix return value check in aspeed_sdc_probe()
From: Wei Yongjun <[email protected]>
In case of error, the function of_platform_device_create() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.
--- drivers/mmc/host/sdhci-of-aspeed.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-aspeed.c +2 -2
@@ -261,9 +261,9 @@ static int aspeed_sdc_probe(struct platform_device *pdev)struct platform_device *cpdev; cpdev =of_platform_device_create (child,NULL , &pdev->dev); -if (IS_ERR (cpdev)) { +if (!cpdev) {of_node_put (child); - ret =PTR_ERR (cpdev); + ret = -ENODEV ; goto err_clk; } }
Signature · 1 line
2.20.1
Re: [PATCH linux dev-5.2 1/5] mmc: sdhci-of-aspeed: Fix return value check in aspeed_sdc_probe()
Quoted 7 lines · Andrew Jeffery
From: Wei Yongjun <[email protected]>
In case of error, the function
of_platform_device_create()returns NULL pointer notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.
Quoted 5 lines
Signed-off-by Wei Yongjun <[email protected]>Reviewed-by Andrew Jeffery <[email protected]>Signed-off-by Ulf Hansson <[email protected]>(cherry picked from commit 7b7de08a14b59d45cc4720bfb21732063ccfc8f6)Signed-off-by Andrew Jeffery <[email protected]>
PATCH 2/5 mmc: sdhci-of-aspeed: Drop redundant assignment to host->clock
In reply to Andrew Jefferyhost->clock is already managed by sdhci_set_ios().
--- drivers/mmc/host/sdhci-of-aspeed.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/mmc/host/sdhci-of-aspeed.c +1 -4
@@ -61,7 +61,7 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)sdhci_writew (host,0 ,SDHCI_CLOCK_CONTROL );if (clock ==0 ) - goto out; +return ;for (div =1 ; div <256 ; div *=2 ) {if ((host->max_clk / div) <= clock)
@@ -72,9 +72,6 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) clk = div <<SDHCI_DIVIDER_SHIFT ;sdhci_enable_clk (host, clk); - -out: - host->clock = clock; }static void aspeed_sdhci_set_bus_width (struct sdhci_host *host,int width)
Signature · 1 line
2.20.1
Re: [PATCH linux dev-5.2 2/5] mmc: sdhci-of-aspeed: Drop redundant assignment to host->clock
Quoted 5 lines · Andrew Jeffery
host->clockis already managed bysdhci_set_ios().Suggested-by Ulf Hansson <[email protected]>Signed-off-by Andrew Jeffery <[email protected]>
I assume this went upstream with a fixes tag?
Cheers,
Joel
Re: [PATCH linux dev-5.2 2/5] mmc: sdhci-of-aspeed: Drop redundant assignment to host->clock
Quoted 11 lines · Joel Stanley
Quoted 5 lines · Andrew Jeffery
host->clockis already managed bysdhci_set_ios().Suggested-by Ulf Hansson <[email protected]>Signed-off-by Andrew Jeffery <[email protected]>Reviewed-by Joel Stanley <[email protected]>I assume this went upstream with a fixes tag?
I haven't sent it yet, was waiting for Adrian to review my v1 upstream before sending a v2 with this patch included.
Not sure it needs a fixes tag, but there's no reason it shouldn't have one either. It's just a code cleanup, it doesn't fix a bug.
Andrew
PATCH 3/5 mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock()
In reply to Andrew JefferyThe early-exit didn't seem to matter on the AST2500, but on the AST2600 the SD clock genuinely may not be running on entry to aspeed_sdhci_set_clock(). Remove the early exit to ensure we always run sdhci_enable_clk().
--- drivers/mmc/host/sdhci-of-aspeed.c | 3 --- 1 file changed, 3 deletions(-)
drivers/mmc/host/sdhci-of-aspeed.c +0 -3
@@ -55,9 +55,6 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)int div;u16 clk; -if (clock == host->clock) -return ; -sdhci_writew (host,0 ,SDHCI_CLOCK_CONTROL );if (clock ==0 )
Signature · 1 line
2.20.1
Re: [PATCH linux dev-5.2 3/5] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock()
Quoted 7 lines · Andrew Jeffery
The early-exit didn't seem to matter on the AST2500, but on the AST2600 the SD clock genuinely may not be running on entry to
aspeed_sdhci_set_clock(). Remove the early exit to ensure we always runsdhci_enable_clk().Signed-off-by Andrew Jeffery <[email protected]>
I don't quite understand what this was doing in the original patch. The fix is good though, I tested it.
Quoted 21 lines
--- drivers/mmc/host/sdhci-of-aspeed.c | 3 --- 1 file changed, 3 deletions(-)drivers/mmc/host/sdhci-of-aspeed.c +0
-4@@ -55,9 +55,6 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)int div;u16 clk; -if (clock == host->clock) -return ; -sdhci_writew (host,0 ,SDHCI_CLOCK_CONTROL );if (clock ==0 ) --2.20.1
Re: [PATCH linux dev-5.2 3/5] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock()
Quoted 11 lines · Joel Stanley
Quoted 7 lines · Andrew Jeffery
The early-exit didn't seem to matter on the AST2500, but on the AST2600 the SD clock genuinely may not be running on entry to
aspeed_sdhci_set_clock(). Remove the early exit to ensure we always runsdhci_enable_clk().Signed-off-by Andrew Jeffery <[email protected]>I don't quite understand what this was doing in the original patch. The fix is good though, I tested it.
What do you mean? You already had questions about it? Would have been nice to pipe up at the time if so :D
Quoted 2 lines
Tested-by Joel Stanley <[email protected]>
Thanks,
Andrew
PATCH 4/5 mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK
In reply to Andrew JefferyAdd a get_max_clock() handler to sdhci-of-aspeed to report f_max as the maximum clock rate if it is set. This enables artificial limitation of the bus speed via max-frequency in the devicetree for e.g. the AST2600 evaluation board where I am seeing errors at 200MHz.
--- drivers/mmc/host/sdhci-of-aspeed.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-of-aspeed.c +18 -2
@@ -52,16 +52,24 @@ static void aspeed_sdc_configure_8bit_mode(struct aspeed_sdc *sdc,static void aspeed_sdhci_set_clock (struct sdhci_host *host,unsigned int clock) { +struct sdhci_pltfm_host *pltfm_host; +unsigned long parent;int div;u16 clk; + pltfm_host =sdhci_priv (host); + parent =clk_get_rate (pltfm_host->clk); +sdhci_writew (host,0 ,SDHCI_CLOCK_CONTROL );if (clock ==0 )return ; +if (WARN_ON (clock > host->max_clk)) + clock = host->max_clk; +for (div =1 ; div <256 ; div *=2 ) { -if ((host->max_clk / div) <= clock) +if ((parent / div) <= clock)break ; } div >>=1 ;
@@ -71,6 +79,14 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock)sdhci_enable_clk (host, clk); } +static unsigned int aspeed_sdhci_get_max_clock (struct sdhci_host *host) +{ +if (host->mmc->f_max) +return host->mmc->f_max; + +return sdhci_pltfm_clk_get_max_clock (host); +} +static void aspeed_sdhci_set_bus_width (struct sdhci_host *host,int width) {struct sdhci_pltfm_host *pltfm_priv;
@@ -97,7 +113,7 @@ static void aspeed_sdhci_set_bus_width(struct sdhci_host *host, int width)static const struct sdhci_ops aspeed_sdhci_ops = { .set_clock = aspeed_sdhci_set_clock, - .get_max_clock = sdhci_pltfm_clk_get_max_clock, + .get_max_clock = aspeed_sdhci_get_max_clock, .set_bus_width = aspeed_sdhci_set_bus_width, .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, .reset = sdhci_reset,
Signature · 1 line
2.20.1
Re: [PATCH linux dev-5.2 4/5] mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK
Quoted 7 lines · Andrew Jeffery
Add a
get_max_clock()handler to sdhci-of-aspeed to reportf_maxas the maximum clock rate if it is set. This enables artificial limitation of the bus speed via max-frequency in the devicetree for e.g. the AST2600 evaluation board where I am seeing errors at 200MHz.Signed-off-by Andrew Jeffery <[email protected]>
PATCH 5/5 ARM: dts: ast2600-evb: eMMC configuration
In reply to Andrew JefferyEnable the eMMC controller and limit it to 52MHz to avoid the host controller reporting error conditions.
--- arch/arm/boot/dts/aspeed-ast2600-evb.dts | 8 +++++++- arch/arm/boot/dts/aspeed-g6.dtsi | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-)
arch/arm/boot/dts/aspeed-ast2600-evb.dts +7 -1
@@ -39,8 +39,14 @@ phy-handle = <ðphy1>; }; +&emmc_controller { + status = "okay"; +}; + &emmc { - status = "disabled"; + non-removable; + bus-width = <4>; + max-frequency = <52000000>; }; &fsim0 {
arch/arm/boot/dts/aspeed-g6.dtsi +2 -2
@@ -235,7 +235,7 @@ }; }; - emmc: sdc@1e750000 { + emmc_controller: sdc@1e750000 { compatible = "aspeed,ast2600-sd-controller"; reg = <0x1e750000 0x100>; #address-cells = <1>;
@@ -244,7 +244,7 @@ clocks = <&syscon ASPEED_CLK_GATE_EMMCCLK>; status = "disabled"; - sdhci@1e750100 { + emmc: sdhci@1e750100 { compatible = "aspeed,ast2600-sdhci"; reg = <0x100 0x100>; sdhci,auto-cmd12;
Signature · 1 line
2.20.1
Re: [PATCH linux dev-5.2 5/5] ARM: dts: ast2600-evb: eMMC configuration
Quoted 5 lines · Andrew Jeffery
Enable the eMMC controller and limit it to 52MHz to avoid the host controller reporting error conditions.
Signed-off-by Andrew Jeffery <[email protected]>
Naming is hard :/
Quoted 50 lines
--- arch/arm/boot/dts/aspeed-ast2600-evb.dts | 8 +++++++- arch/arm/boot/dts/aspeed-g6.dtsi | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-)arch/arm/boot/dts/aspeed-ast2600-evb.dts +7
-1@@ -39,8 +39,14 @@ phy-handle = <ðphy1>; }; +&emmc_controller { + status = "okay"; +}; + &emmc { - status = "disabled"; + non-removable; + bus-width = <4>; + max-frequency = <52000000>; }; &fsim0 {arch/arm/boot/dts/aspeed-g6.dtsi +2
-3@@ -235,7 +235,7 @@ }; }; - emmc: sdc@1e750000 { + emmc_controller: sdc@1e750000 { compatible = "aspeed,ast2600-sd-controller"; reg = <0x1e750000 0x100>; #address-cells = <1>;@@ -244,7 +244,7 @@ clocks = <&syscon ASPEED_CLK_GATE_EMMCCLK>; status = "disabled"; - sdhci@1e750100 { + emmc: sdhci@1e750100 { compatible = "aspeed,ast2600-sdhci"; reg = <0x100 0x100>; sdhci,auto-cmd12; --2.20.1