* [PATCH 0/2] mmc: sdhci-of-aspeed: Fixes for AST2600 eMMC support @ 2019-08-30 7:46 Andrew Jeffery 2019-08-30 7:46 ` [PATCH 1/2] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock() Andrew Jeffery 2019-08-30 7:46 ` [PATCH 2/2] mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK Andrew Jeffery 0 siblings, 2 replies; 6+ messages in thread From: Andrew Jeffery @ 2019-08-30 7:46 UTC (permalink / raw) To: linux-mmc Cc: ulf.hansson, linux-aspeed, Andrew Jeffery, openbmc, ryanchen.aspeed, adrian.hunter, linux-kernel, joel, linux-arm-kernel Hello, The ASPEED SDHCI driver patches sent previously were based on testing on the AST2500. The SD controllers in the 2500 and 2600 had the same register layout according to the documentation, so we added the necessary devicetree compatible string at the same time. Now that I've got access to 2600 hardware with an eMMC chip I have a couple of patches that are fixes enabling support for it. I don't think the first patch is too controversial - in some cases we weren't ensuring the clock was enabled before returning from the set_clock() callback. I'm a bit unsure about the second patch though which enables use of max-frequency in the devicetree, it feels a bit hacky so I'm looking for any suggestions on the approach. Please review! Andrew Andrew Jeffery (2): mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock() mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK drivers/mmc/host/sdhci-of-aspeed.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock() 2019-08-30 7:46 [PATCH 0/2] mmc: sdhci-of-aspeed: Fixes for AST2600 eMMC support Andrew Jeffery @ 2019-08-30 7:46 ` Andrew Jeffery 2019-08-30 8:01 ` Ulf Hansson 2019-08-30 7:46 ` [PATCH 2/2] mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK Andrew Jeffery 1 sibling, 1 reply; 6+ messages in thread From: Andrew Jeffery @ 2019-08-30 7:46 UTC (permalink / raw) To: linux-mmc Cc: ulf.hansson, linux-aspeed, Andrew Jeffery, openbmc, ryanchen.aspeed, adrian.hunter, linux-kernel, joel, linux-arm-kernel 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 run sdhci_enable_clk(). Signed-off-by: Andrew Jeffery <andrew@aj.id.au> --- drivers/mmc/host/sdhci-of-aspeed.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c index d5acb5afc50f..a9175ca85696 100644 --- a/drivers/mmc/host/sdhci-of-aspeed.c +++ b/drivers/mmc/host/sdhci-of-aspeed.c @@ -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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock() 2019-08-30 7:46 ` [PATCH 1/2] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock() Andrew Jeffery @ 2019-08-30 8:01 ` Ulf Hansson 2019-08-30 8:07 ` Andrew Jeffery 0 siblings, 1 reply; 6+ messages in thread From: Ulf Hansson @ 2019-08-30 8:01 UTC (permalink / raw) To: Andrew Jeffery Cc: linux-aspeed, linux-mmc@vger.kernel.org, openbmc, Ryan Chen, Adrian Hunter, Linux Kernel Mailing List, Joel Stanley, Linux ARM On Fri, 30 Aug 2019 at 09:46, Andrew Jeffery <andrew@aj.id.au> wrote: > > 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 run > sdhci_enable_clk(). > > Signed-off-by: Andrew Jeffery <andrew@aj.id.au> > --- > drivers/mmc/host/sdhci-of-aspeed.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c > index d5acb5afc50f..a9175ca85696 100644 > --- a/drivers/mmc/host/sdhci-of-aspeed.c > +++ b/drivers/mmc/host/sdhci-of-aspeed.c > @@ -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 > Further down in aspeed_sdhci_set_clock() you should probably also remove the assignment of host->clock = clock, as that is already managed by sdhci_set_ios(). Kind regards Uffe _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock() 2019-08-30 8:01 ` Ulf Hansson @ 2019-08-30 8:07 ` Andrew Jeffery 2019-08-30 8:29 ` Ulf Hansson 0 siblings, 1 reply; 6+ messages in thread From: Andrew Jeffery @ 2019-08-30 8:07 UTC (permalink / raw) To: Ulf Hansson Cc: linux-aspeed, linux-mmc, openbmc, Ryan Chen, Adrian Hunter, Linux Kernel Mailing List, Joel Stanley, Linux ARM On Fri, 30 Aug 2019, at 17:31, Ulf Hansson wrote: > On Fri, 30 Aug 2019 at 09:46, Andrew Jeffery <andrew@aj.id.au> wrote: > > > > 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 run > > sdhci_enable_clk(). > > > > Signed-off-by: Andrew Jeffery <andrew@aj.id.au> > > --- > > drivers/mmc/host/sdhci-of-aspeed.c | 3 --- > > 1 file changed, 3 deletions(-) > > > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c > > index d5acb5afc50f..a9175ca85696 100644 > > --- a/drivers/mmc/host/sdhci-of-aspeed.c > > +++ b/drivers/mmc/host/sdhci-of-aspeed.c > > @@ -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 > > > > Further down in aspeed_sdhci_set_clock() you should probably also > remove the assignment of host->clock = clock, as that is already > managed by sdhci_set_ios(). Ah, I'll fix that in a v2 once I have your thoughts on patch 2/2. Thanks for the lightning quick feedback! Andrew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock() 2019-08-30 8:07 ` Andrew Jeffery @ 2019-08-30 8:29 ` Ulf Hansson 0 siblings, 0 replies; 6+ messages in thread From: Ulf Hansson @ 2019-08-30 8:29 UTC (permalink / raw) To: Andrew Jeffery Cc: linux-aspeed, linux-mmc, openbmc, Ryan Chen, Adrian Hunter, Linux Kernel Mailing List, Joel Stanley, Linux ARM On Fri, 30 Aug 2019 at 10:07, Andrew Jeffery <andrew@aj.id.au> wrote: > > > > On Fri, 30 Aug 2019, at 17:31, Ulf Hansson wrote: > > On Fri, 30 Aug 2019 at 09:46, Andrew Jeffery <andrew@aj.id.au> wrote: > > > > > > 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 run > > > sdhci_enable_clk(). > > > > > > Signed-off-by: Andrew Jeffery <andrew@aj.id.au> > > > --- > > > drivers/mmc/host/sdhci-of-aspeed.c | 3 --- > > > 1 file changed, 3 deletions(-) > > > > > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c > > > index d5acb5afc50f..a9175ca85696 100644 > > > --- a/drivers/mmc/host/sdhci-of-aspeed.c > > > +++ b/drivers/mmc/host/sdhci-of-aspeed.c > > > @@ -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 > > > > > > > Further down in aspeed_sdhci_set_clock() you should probably also > > remove the assignment of host->clock = clock, as that is already > > managed by sdhci_set_ios(). > > Ah, I'll fix that in a v2 once I have your thoughts on patch 2/2. I leave this one to Adrian to comment on, as he knows this better than me. [...] Kind regards Uffe _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK 2019-08-30 7:46 [PATCH 0/2] mmc: sdhci-of-aspeed: Fixes for AST2600 eMMC support Andrew Jeffery 2019-08-30 7:46 ` [PATCH 1/2] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock() Andrew Jeffery @ 2019-08-30 7:46 ` Andrew Jeffery 1 sibling, 0 replies; 6+ messages in thread From: Andrew Jeffery @ 2019-08-30 7:46 UTC (permalink / raw) To: linux-mmc Cc: ulf.hansson, linux-aspeed, Andrew Jeffery, openbmc, ryanchen.aspeed, adrian.hunter, linux-kernel, joel, linux-arm-kernel Add 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. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> --- drivers/mmc/host/sdhci-of-aspeed.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c index a9175ca85696..5cc00abcd71f 100644 --- a/drivers/mmc/host/sdhci-of-aspeed.c +++ b/drivers/mmc/host/sdhci-of-aspeed.c @@ -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) goto out; + 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; @@ -74,6 +82,14 @@ static void aspeed_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) host->clock = clock; } +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; @@ -100,7 +116,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, -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-08-30 8:29 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-08-30 7:46 [PATCH 0/2] mmc: sdhci-of-aspeed: Fixes for AST2600 eMMC support Andrew Jeffery 2019-08-30 7:46 ` [PATCH 1/2] mmc: sdhci-of-aspeed: Uphold clocks-on post-condition of set_clock() Andrew Jeffery 2019-08-30 8:01 ` Ulf Hansson 2019-08-30 8:07 ` Andrew Jeffery 2019-08-30 8:29 ` Ulf Hansson 2019-08-30 7:46 ` [PATCH 2/2] mmc: sdhci-of-aspeed: Allow max-frequency limitation of SDCLK Andrew Jeffery
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox