Message ID | 637b9bea4c28a0eeacf754d2930596b8e6673808.1585827904.git.mirq-linux@rere.qmqm.pl (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | SDHCI clock handling fixes and cleanups | expand |
On 2/04/20 2:54 pm, Michał Mirosław wrote: > Move clock frequency limit for SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN where > it belongs. Did you consider getting rid of SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN and handling it in sdhci-of-arasan instead? > > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> > --- > drivers/mmc/host/sdhci-of-arasan.c | 7 ++++--- > drivers/mmc/host/sdhci.c | 3 +-- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c > index d4905c106c06..5e3b9131a631 100644 > --- a/drivers/mmc/host/sdhci-of-arasan.c > +++ b/drivers/mmc/host/sdhci-of-arasan.c > @@ -339,7 +339,6 @@ static const struct sdhci_pltfm_data sdhci_arasan_pdata = { > .ops = &sdhci_arasan_ops, > .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, > .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | > - SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN | > SDHCI_QUIRK2_STOP_WITH_TC, > }; > > @@ -410,8 +409,7 @@ static const struct sdhci_ops sdhci_arasan_cqe_ops = { > static const struct sdhci_pltfm_data sdhci_arasan_cqe_pdata = { > .ops = &sdhci_arasan_cqe_ops, > .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, > - .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | > - SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN, > + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, > }; > > static struct sdhci_arasan_of_data sdhci_arasan_rk3399_data = { > @@ -1155,6 +1153,9 @@ static int sdhci_arasan_add_host(struct sdhci_arasan_data *sdhci_arasan) > bool dma64; > int ret; > > + if (sdhci_pltfm_clk_get_max_clock(host) <= 25000000) > + host->quirks2 |= SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN; > + > if (!sdhci_arasan->has_cqe) > return sdhci_add_host(host); > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index a043bf5e3565..ed88ac4e4cf3 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -1809,8 +1809,7 @@ u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock, > /* Version 3.00 divisors must be a multiple of 2. */ > if (host->max_clk <= clock) { > div = 1; > - if ((host->quirks2 & SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN) > - && host->max_clk <= 25000000) > + if (host->quirks2 & SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN) > div = 2; > } else { > for (div = 2; div < SDHCI_MAX_DIV_SPEC_300; >
On Wed, Apr 15, 2020 at 04:16:04PM +0300, Adrian Hunter wrote: > On 2/04/20 2:54 pm, Michał Mirosław wrote: > > Move clock frequency limit for SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN where > > it belongs. > > Did you consider getting rid of SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN and > handling it in sdhci-of-arasan instead? I'm expecting to use this quirk for DDR mode support in other host drivers, but I can't test this, yet. Best Regards, Michał Mirosław
On 15/04/20 7:16 pm, Michał Mirosław wrote: > On Wed, Apr 15, 2020 at 04:16:04PM +0300, Adrian Hunter wrote: >> On 2/04/20 2:54 pm, Michał Mirosław wrote: >>> Move clock frequency limit for SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN where >>> it belongs. >> >> Did you consider getting rid of SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN and >> handling it in sdhci-of-arasan instead? > > I'm expecting to use this quirk for DDR mode support in other host drivers, > but I can't test this, yet. I didn't mean get rid of the functionality. I meant implement it in sdhci-of-arasan. In general we want to reduce the quirks in sdhci.c and implement them instead in vendor drivers.
diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c index d4905c106c06..5e3b9131a631 100644 --- a/drivers/mmc/host/sdhci-of-arasan.c +++ b/drivers/mmc/host/sdhci-of-arasan.c @@ -339,7 +339,6 @@ static const struct sdhci_pltfm_data sdhci_arasan_pdata = { .ops = &sdhci_arasan_ops, .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | - SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN | SDHCI_QUIRK2_STOP_WITH_TC, }; @@ -410,8 +409,7 @@ static const struct sdhci_ops sdhci_arasan_cqe_ops = { static const struct sdhci_pltfm_data sdhci_arasan_cqe_pdata = { .ops = &sdhci_arasan_cqe_ops, .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, - .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | - SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN, + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, }; static struct sdhci_arasan_of_data sdhci_arasan_rk3399_data = { @@ -1155,6 +1153,9 @@ static int sdhci_arasan_add_host(struct sdhci_arasan_data *sdhci_arasan) bool dma64; int ret; + if (sdhci_pltfm_clk_get_max_clock(host) <= 25000000) + host->quirks2 |= SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN; + if (!sdhci_arasan->has_cqe) return sdhci_add_host(host); diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index a043bf5e3565..ed88ac4e4cf3 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1809,8 +1809,7 @@ u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock, /* Version 3.00 divisors must be a multiple of 2. */ if (host->max_clk <= clock) { div = 1; - if ((host->quirks2 & SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN) - && host->max_clk <= 25000000) + if (host->quirks2 & SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN) div = 2; } else { for (div = 2; div < SDHCI_MAX_DIV_SPEC_300;
Move clock frequency limit for SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN where it belongs. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> --- drivers/mmc/host/sdhci-of-arasan.c | 7 ++++--- drivers/mmc/host/sdhci.c | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-)