mmc: sdhci: update timeout clock setting if SDCLK is used
PATCH RESEND v4 1/2 mmc: sdhci: update timeout clock setting if SDCLK is used
1. If SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK is selected, getting timeout through register or callback function is useless. So skip current redundant code.
2. If SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK is selected, host uses SDCLK instead of TMCLK for data timeouts. So host->timeout_clk and mmc->max_discard_to should be updated accordingly when SDCLK changed.
3. If callback function get_timeout_clock is used, the timeout clock will be returned directly and no need to multiply by the timeout clock unit read from register.
--- drivers/mmc/host/sdhci.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-)
drivers/mmc/host/sdhci.c +27 -16
@@ -1082,6 +1082,11 @@ static void sdhci_finish_command(struct sdhci_host *host) } } +static inline void sdhci_set_max_discard_to (struct sdhci_host *host) +{ + host->mmc->max_discard_to = (1 <<27 ) / host->timeout_clk; +} +static void sdhci_set_clock (struct sdhci_host *host,unsigned int clock) {int div =0 ;/* Initialized for compiler warning */
@@ -1094,6 +1099,12 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) host->mmc->actual_clock =0 ; +if ((host->quirks &SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK ) && clock) { +/* The lowest permitted timeout clock frequency is 1Khz */ + host->timeout_clk =DIV_ROUND_UP (clock,1000 ); +sdhci_set_max_discard_to (host); + } +if (host->ops->set_clock) { host->ops->set_clock (host, clock);if (host->quirks &SDHCI_QUIRK_NONSTANDARD_CLOCK )
@@ -2828,25 +2839,25 @@ int sdhci_add_host(struct sdhci_host *host) }else mmc->f_min = host->max_clk /SDHCI_MAX_DIV_SPEC_200 ; - host->timeout_clk = - (caps[0 ] &SDHCI_TIMEOUT_CLK_MASK ) >>SDHCI_TIMEOUT_CLK_SHIFT ; -if (host->timeout_clk ==0 ) { -if (host->ops->get_timeout_clock) { - host->timeout_clk = host->ops->get_timeout_clock (host); - }else if (!(host->quirks & -SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK )) { -pr_err ("%s: Hardware doesn't specify timeout clock " -"frequency.\n" ,mmc_hostname (mmc)); -return -ENODEV ; +if (!(host->quirks &SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK )) { + host->timeout_clk = (caps[0 ] &SDHCI_TIMEOUT_CLK_MASK ) >> +SDHCI_TIMEOUT_CLK_SHIFT ; +if (host->timeout_clk ==0 ) { +if (host->ops->get_timeout_clock) { + host->timeout_clk = + host->ops->get_timeout_clock (host); + } +if (host->timeout_clk ==0 ) { +pr_err ("%s: Hardware doesn't specify timeout " +"clock frequency.\n" ,mmc_hostname (mmc)); +return -ENODEV ; + } + }else if (caps[0 ] &SDHCI_TIMEOUT_CLK_UNIT ) { + host->timeout_clk *=1000 ; } +sdhci_set_max_discard_to (host); } -if (caps[0 ] &SDHCI_TIMEOUT_CLK_UNIT ) - host->timeout_clk *=1000 ; - -if (host->quirks &SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK ) - host->timeout_clk = mmc->f_max /1000 ; - mmc->max_discard_to = (1 <<27 ) / host->timeout_clk; mmc->caps |=MMC_CAP_SDIO_IRQ |MMC_CAP_ERASE |MMC_CAP_CMD23 ;
Signature · 1 line
1.7.9.5
PATCH RESEND v4 2/2 mmc: sdhci-pxav3: controller should use SDCLK for timeout caculation
--- drivers/mmc/host/sdhci-pxav3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-pxav3.c +1 -1
@@ -259,7 +259,7 @@ static int sdhci_pxav3_probe(struct platform_device *pdev) pltfm_host->clk = clk;clk_prepare_enable (clk); - host->quirks =SDHCI_QUIRK_BROKEN_TIMEOUT_VAL + host->quirks =SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC |SDHCI_QUIRK_32BIT_ADMA_SIZE |SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN ;
Signature · 1 line
1.7.9.5
Is there any feedback about this patch?
We also need this patch.
Regards
Haijun.
Quoted 104 lines
-----Original Message-----
From: Kevin Liu [mailto:[email protected]]
Sent: Friday, January 25, 2013 7:35 PM
To: [email protected]; Chris Ball; Andy Shevchenko; Ulf Hansson
Cc: Nicolas Pitre; Adrian Hunter; Philip Rakity; Aaron Lu; Shawn Guo; Johan Rudholm; Daniel Drake; Guennadi Liakhovetski; Huang Changming- R66093; Alexander Stein; Girish K S; Zhang Haijun-B42677; Viresh Kumar; Heiko Stuebner; Thomas Abraham; Chander Kashyap; Jaehoon Chung; Sebastian Hesselbarth; Zhangfei Gao; Haojian Zhuang; Chao Xie; Kevin Liu; Kevin Liu
Subject: [PATCH RESEND v4 1/2] mmc: sdhci: update timeout clock setting if SDCLK is used1. If
SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLKis selected, getting timeout through register or callback function is useless. So skip current redundant code.
2. IfSDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLKis selected, host uses SDCLK instead of TMCLK for data timeouts. Sohost->timeout_clkand mmc-Quoted 1 line
max_discard_toshould be updated accordingly when SDCLK changed.3. If callback function
get_timeout_clockis used, the timeout clock will be returned directly and no need to multiply by the timeout clock unit read from register.Signed-off-by Kevin Liu <[email protected]>Acked-by Andy Shevchenko <[email protected]>--- drivers/mmc/host/sdhci.c | 43 +++++++++++++++++++++++++++------------- --- 1 file changed, 27 insertions(+), 16 deletions(-)drivers/mmc/host/sdhci.c index renamed from drivers/mmc/host/sdhci.c +0
-004af0fd..c31c30e 100644
drivers/mmc/host/sdhci.c +4
-0@@ -1082,6 +1082,11 @@ static void sdhci_finish_command(struct sdhci_host *host) } } +static inline void sdhci_set_max_discard_to (struct sdhci_host *host) { + host->mmc->max_discard_to = (1 <<27 ) / host->timeout_clk; } +static void sdhci_set_clock (struct sdhci_host *host,unsigned int clock) { int div = 0; /* Initialized for compiler warning */ @@ -1094,6 +1099,12 @@ static void sdhci_set_clock(struct sdhci_host *host, unsignedint clock)
drivers/mmc/host/sdhci.c +1
-0host->mmc->actual_clock =0 ; +if ((host->quirks &SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK ) && clock){
drivers/mmc/host/sdhci.c +22
-17+/* The lowest permitted timeout clock frequency is 1Khz */ + host->timeout_clk =DIV_ROUND_UP (clock,1000 ); +sdhci_set_max_discard_to (host); + } +if (host->ops->set_clock) { host->ops->set_clock (host, clock); if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) @@ -2828,25 +2839,25 @@ int sdhci_add_host(struct sdhci_host *host) }else mmc->f_min = host->max_clk /SDHCI_MAX_DIV_SPEC_200 ; - host->timeout_clk = - (caps[0 ] &SDHCI_TIMEOUT_CLK_MASK ) >>SDHCI_TIMEOUT_CLK_SHIFT ; -if (host->timeout_clk ==0 ) { -if (host->ops->get_timeout_clock) { - host->timeout_clk = host->ops->get_timeout_clock (host); - }else if (!(host->quirks & -SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK )) { -pr_err ("%s: Hardware doesn't specify timeout clock " -"frequency.\n" ,mmc_hostname (mmc)); -return -ENODEV ; +if (!(host->quirks &SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK )) { + host->timeout_clk = (caps[0 ] &SDHCI_TIMEOUT_CLK_MASK ) >> +SDHCI_TIMEOUT_CLK_SHIFT ; +if (host->timeout_clk ==0 ) { +if (host->ops->get_timeout_clock) { + host->timeout_clk = + host->ops->get_timeout_clock (host); + } +if (host->timeout_clk ==0 ) { +pr_err ("%s: Hardware doesn't specify timeout " +"clock frequency.\n" ,mmc_hostname (mmc)); +return -ENODEV ; + } + }else if (caps[0 ] &SDHCI_TIMEOUT_CLK_UNIT ) { + host->timeout_clk *=1000 ; } +sdhci_set_max_discard_to (host); } -if (caps[0 ] &SDHCI_TIMEOUT_CLK_UNIT ) - host->timeout_clk *=1000 ; - -if (host->quirks &SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK ) - host->timeout_clk = mmc->f_max /1000 ; - mmc->max_discard_to = (1 <<27 ) / host->timeout_clk; mmc->caps |=MMC_CAP_SDIO_IRQ |MMC_CAP_ERASE |MMC_CAP_CMD23 ; --1.7.9.5