mmc: mtk-sd: reduce CIT for better performance
Subsystems (4)
PATCH v4 1/1 mmc: mtk-sd: reduce CIT for better performance
CQHCI_SSC1 indicates to CQE the polling period to use when using periodic SEND_QUEUE_STATUS(CMD13) polling.
Since MSDC CQE uses msdc_hclk as ITCFVAL, so driver should use hclk frequency to get the actual time.
The default value 0x1000 that corresponds to 150us for MediaTek SoCs, let's decrease it to 0x40 that corresponds to 2.35us, which can improve the performance of some eMMC devices.
--- drivers/mmc/host/cqhci.h | 1 + drivers/mmc/host/mtk-sd.c | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
drivers/mmc/host/cqhci.h +1 -0
@@ -23,6 +23,7 @@/* capabilities */ #define CQHCI_CAP 0x04#define CQHCI_CAP_CS 0x10000000/* Crypto Support */ +#define CQHCI_CAP_ITCFMUL (x) (((x) & GENMASK(15, 12)) >> 12)/* configuration */ #define CQHCI_CFG 0x08
drivers/mmc/host/mtk-sd.c +45 -0
72 lines not on this page · raw message
Signature · 1 line
2.25.1
AngeloGioacchino Del Regno
maintainerIl 05/06/23 14:14, Wenbin Mei ha scritto:
Quoted 9 lines
CQHCI_SSC1indicates to CQE the polling period to use when using periodicSEND_QUEUE_STATUS(CMD13)polling.
Since MSDC CQE usesmsdc_hclkas ITCFVAL, so driver should use hclk frequency to get the actual time.
The default value0x1000that corresponds to 150us for MediaTek SoCs, let's decrease it to0x40that corresponds to 2.35us, which can improve the performance of some eMMC devices.Signed-off-by Wenbin Mei <[email protected]>
You haven't addressed all my comments. Is there any reason for that?
Regards,
Angelo
Quoted 97 lines
--- drivers/mmc/host/cqhci.h | 1 + drivers/mmc/host/mtk-sd.c | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)drivers/mmc/host/cqhci.h +1
-0@@ -23,6 +23,7 @@/* capabilities */ #define CQHCI_CAP 0x04#define CQHCI_CAP_CS 0x10000000/* Crypto Support */ +#define CQHCI_CAP_ITCFMUL (x) (((x) & GENMASK(15, 12)) >> 12)/* configuration */ #define CQHCI_CFG 0x08drivers/mmc/host/mtk-sd.c +45
-0@@ -473,6 +473,7 @@ struct msdc_host {struct msdc_tune_para def_tune_para;/* default tune setting */ struct msdc_tune_para saved_tune_para;/* tune result of CMD21/CMD19 */ struct cqhci_host *cq_host; +u32 cq_ssc1_time; };static const struct mtk_mmc_compatible mt2701_compat = {@@ -2450,9 +2451,48 @@ static void msdc_hs400_enhanced_strobe(struct mmc_host *mmc, } } +static void msdc_cqe_cit_cal (struct msdc_host *host,u64 timer_ns) +{ +struct mmc_host *mmc =mmc_from_priv (host); +struct cqhci_host *cq_host = mmc->cqe_private; +u8 itcfmul; +u64 hclk_freq; +u64 value; + +/* Since MSDC CQE uses msdc_hclk as ITCFVAL, so driver should use hclk +* frequency to get the actual time for CIT. +*/ + hclk_freq =clk_get_rate (host->h_clk); + itcfmul =CQHCI_CAP_ITCFMUL (cqhci_readl (cq_host,CQHCI_CAP )); +switch (itcfmul) { +case 0x0 : +do_div (hclk_freq,1000 ); +break ; +case 0x1 : +do_div (hclk_freq,100 ); +break ; +case 0x2 : +do_div (hclk_freq,10 ); +break ; +case 0x3 : +break ; +case 0x4 : + hclk_freq = hclk_freq *10 ; +break ; +default : + host->cq_ssc1_time =0x40 ; +return ; + } + + value = hclk_freq * timer_ns; +do_div (value,1000000000 ); + host->cq_ssc1_time = value; +} +static void msdc_cqe_enable (struct mmc_host *mmc) {struct msdc_host *host =mmc_priv (mmc); +struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel (MSDC_INT_CMDQ , host->base +MSDC_INTEN );@@ -2462,6 +2502,9 @@ static void msdc_cqe_enable(struct mmc_host *mmc)msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* Set the send status command idle timer */ +cqhci_writel (cq_host, host->cq_ssc1_time,CQHCI_SSC1 ); }static void msdc_cqe_disable (struct mmc_host *mmc,bool recovery)@@ -2803,6 +2846,8 @@ static int msdc_drv_probe(struct platform_device *pdev)/* cqhci 16bit length */ /* 0 size, means 65536 so we don't have to -1 here */ mmc->max_seg_size =64 *1024 ; +/* Reduce CIT to 0x40 that corresponds to 2.35us */ +msdc_cqe_cit_cal (host,2350 ); } ret = devm_request_irq(&pdev->dev, host->irq, msdc_irq,
Quoted 10 lines · AngeloGioacchino Del Regno
External email : Please do not click links or open attachments until you have verified the sender or the content.
Il 05/06/23 14:14, Wenbin Mei ha scritto:Quoted 1 line
CQHCI_SSC1indicates to CQE the polling period to use when usingperiodic
Quoted 4 lines
SEND_QUEUE_STATUS(CMD13)polling.
Since MSDC CQE usesmsdc_hclkas ITCFVAL, so driver should use hclk frequency to get the actual time.
The default value0x1000that corresponds to 150us for MediaTek
Quoted 9 lines
SoCs, let's
Quoted 1 line
decrease it to
0x40that corresponds to 2.35us, which can improvethe
Quoted 3 lines
performance of some eMMC devices.
Signed-off-by Wenbin Mei <[email protected]>You haven't addressed all my comments. Is there any reason for that?
Sorry for the trouble.
Reply to your previous comment here:msdc_hclk clock is critical for MSDC CQE, if msdc_hclk is not present, it will not go here, because it will return earlier as below(msdc_drv_probe() function):
...
ret = msdc_of_clock_parse(pdev, host); // hclk not present, return err
if (ret)
goto host_free;
...
if (mmc->caps2 & MMC_CAPS_CQE) {
...
msdc_cqe_cit_cal(host, 2350);
}so I remove the else case for msdc_cqe_cit_cal() function.
Any questions please free to talk and many thanks.
Begards,
Wenbin
Quoted 107 lines
Regards,
AngeloQuoted 3 lines
--- drivers/mmc/host/cqhci.h | 1 + drivers/mmc/host/mtk-sd.c | 45+++++++++++++++++++++++++++++++++++++++
Quoted 19 lines
2 files changed, 46 insertions(+)drivers/mmc/host/cqhci.h +1
-0@@ -23,6 +23,7 @@/* capabilities */ #define CQHCI_CAP0x04#define CQHCI_CAP_CS0x10000000/* Crypto Support */ +#define CQHCI_CAP_ITCFMUL (x)(((x) & GENMASK(15, 12)) >> 12)/* configuration */ #define CQHCI_CFG0x08drivers/mmc/host/mtk-sd.c +0
-0drivers/mmc/host/mtk-sd.c struct msdc_host { · line 474
Quoted 2 lines
drivers/mmc/host/mtk-sd.c +0
-0@@ -473,6 +473,7 @@ struct msdc_host {struct msdc_tune_para def_tune_para;/* default tune setting */ struct msdc_tune_para saved_tune_para;/* tune result of CMD21/CMD19 */
drivers/mmc/host/mtk-sd.c static void
Quoted 6 lines
drivers/mmc/host/mtk-sd.c +1
-0struct cqhci_host *cq_host; +u32 cq_ssc1_time; };static const struct mtk_mmc_compatible mt2701_compat = {@@ -2450,9 +2451,48 @@ static voidmsdc_hs400_enhanced_strobe(struct
mmc_host*mmc,drivers/mmc/host/mtk-sd.c static void msdc_hs400_enhanced_strobe(struct mmc_host *mmc,
Quoted 12 lines
drivers/mmc/host/mtk-sd.c +9
-0} } +static void msdc_cqe_cit_cal (struct msdc_host *host,u64 timer_ns) +{ +struct mmc_host *mmc =mmc_from_priv (host); +struct cqhci_host *cq_host = mmc->cqe_private; +u8 itcfmul; +u64 hclk_freq; +u64 value; + +/* Since MSDC CQE uses msdc_hclk as ITCFVAL, so driver should use hclk
drivers/mmc/host/mtk-sd.c static void msdc_cqe_enable(struct mmc_host
Quoted 37 lines
drivers/mmc/host/mtk-sd.c +30
-0+* frequency to get the actual time for CIT. +*/ +hclk_freq =clk_get_rate (host->h_clk); +itcfmul =CQHCI_CAP_ITCFMUL (cqhci_readl (cq_host,CQHCI_CAP )); +switch (itcfmul) { +case 0x0 : +do_div (hclk_freq,1000 ); +break ; +case 0x1 : +do_div (hclk_freq,100 ); +break ; +case 0x2 : +do_div (hclk_freq,10 ); +break ; +case 0x3 : +break ; +case 0x4 : +hclk_freq = hclk_freq *10 ; +break ; +default : +host->cq_ssc1_time =0x40 ; +return ; +} + +value = hclk_freq * timer_ns; +do_div (value,1000000000 ); +host->cq_ssc1_time = value; +} +static void msdc_cqe_enable (struct mmc_host *mmc) {struct msdc_host *host =mmc_priv (mmc); +struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel (MSDC_INT_CMDQ , host->base +MSDC_INTEN );@@ -2462,6 +2502,9 @@ static void msdc_cqe_enable(struct mmc_host*mmc)
drivers/mmc/host/mtk-sd.c static int msdc_drv_probe(struct
Quoted 10 lines
drivers/mmc/host/mtk-sd.c +3
-0msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* Set the send status command idle timer */ +cqhci_writel (cq_host, host->cq_ssc1_time,CQHCI_SSC1 ); }static void msdc_cqe_disable (struct mmc_host *mmc,bool recovery)@@ -2803,6 +2846,8 @@ static int msdc_drv_probe(struct
platform_device*pdev)Quoted 8 lines
drivers/mmc/host/mtk-sd.c +2
-0/* cqhci 16bit length */ /* 0 size, means 65536 so we don't have to -1 here */ mmc->max_seg_size =64 *1024 ; +/* Reduce CIT to 0x40 that corresponds to 2.35us */ +msdc_cqe_cit_cal (host,2350 ); } ret = devm_request_irq(&pdev->dev, host->irq, msdc_irq,
Quoted 7 lines · Wenbin Mei
CQHCI_SSC1indicates to CQE the polling period to use when using periodicSEND_QUEUE_STATUS(CMD13)polling.
Since MSDC CQE usesmsdc_hclkas ITCFVAL, so driver should use hclk frequency to get the actual time.
The default value0x1000that corresponds to 150us for MediaTek SoCs, let's decrease it to0x40that corresponds to 2.35us, which can improve the performance of some eMMC devices.
Hi,
- Can you add the version change log and the link to the previous patch version (at least) please ?
- On which board(s) did you test this patch please ?
Signature · 2 lines
Regards, Alexandre
Quoted 13 lines · Alexandre Mergnat
External email : Please do not click links or open attachments until you have verified the sender or the content.
Quoted 1 line · Wenbin Mei
CQHCI_SSC1indicates to CQE the polling period to use when usingperiodic
Quoted 4 lines
SEND_QUEUE_STATUS(CMD13)polling.
Since MSDC CQE usesmsdc_hclkas ITCFVAL, so driver should use hclk frequency to get the actual time.
The default value0x1000that corresponds to 150us for MediaTekSoCs, let's
Quoted 1 line
decrease it to
0x40that corresponds to 2.35us, which can improvethe
Quoted 9 lines
Quoted 1 line
performance of some eMMC devices.
Hi,
- Can you add the version change log and the link to the previous patch version (at least) please ?
- On which board(s) did you test this patch please ?
Thanks for your reminder.
I will add the version change log and the link.
We test this patch on our demo board.
Begards,
Wenbin
Quoted 4 lines
Signature · 2 lines
Regards, Alexandre
AngeloGioacchino Del Regno
maintainerIl 05/06/23 14:14, Wenbin Mei ha scritto:
Quoted 43 lines
CQHCI_SSC1indicates to CQE the polling period to use when using periodicSEND_QUEUE_STATUS(CMD13)polling.
Since MSDC CQE usesmsdc_hclkas ITCFVAL, so driver should use hclk frequency to get the actual time.
The default value0x1000that corresponds to 150us for MediaTek SoCs, let's decrease it to0x40that corresponds to 2.35us, which can improve the performance of some eMMC devices.Signed-off-by Wenbin Mei <[email protected]>--- drivers/mmc/host/cqhci.h | 1 + drivers/mmc/host/mtk-sd.c | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)drivers/mmc/host/cqhci.h +1
-0@@ -23,6 +23,7 @@/* capabilities */ #define CQHCI_CAP 0x04#define CQHCI_CAP_CS 0x10000000/* Crypto Support */ +#define CQHCI_CAP_ITCFMUL (x) (((x) & GENMASK(15, 12)) >> 12)/* configuration */ #define CQHCI_CFG 0x08drivers/mmc/host/mtk-sd.c +2
-0@@ -473,6 +473,7 @@ struct msdc_host {struct msdc_tune_para def_tune_para;/* default tune setting */ struct msdc_tune_para saved_tune_para;/* tune result of CMD21/CMD19 */ struct cqhci_host *cq_host; +u32 cq_ssc1_time; };static const struct mtk_mmc_compatible mt2701_compat = {@@ -2450,9 +2451,48 @@ static void msdc_hs400_enhanced_strobe(struct mmc_host *mmc, } } +static void msdc_cqe_cit_cal (struct msdc_host *host,u64 timer_ns)
drivers/mmc/host/mtk-sd.c static void msdc_hs400_enhanced_strobe(struct mmc_host *mmc, · line 2464
Quoted 10 lines
drivers/mmc/host/mtk-sd.c +10
-0+{ +struct mmc_host *mmc =mmc_from_priv (host); +struct cqhci_host *cq_host = mmc->cqe_private; +u8 itcfmul; +u64 hclk_freq; +u64 value; + +/* Since MSDC CQE uses msdc_hclk as ITCFVAL, so driver should use hclk +* frequency to get the actual time for CIT. +*/
/*
* On MediaTek SoCs the MSDC controller's CQE uses msdc_hclk as ITCFVAL
* so we multiply/divide the HCLK frequency by ITCFMUL to calculate the
* Send Status Command Idle Timer (CIT) value.
*/
The proposed comment increases readability.
Cheers,
Angelo
Quoted 74 lines · AngeloGioacchino Del Regno
External email : Please do not click links or open attachments until you have verified the sender or the content.
Il 05/06/23 14:14, Wenbin Mei ha scritto:Quoted 1 line
CQHCI_SSC1indicates to CQE the polling period to use when usingperiodic
Quoted 4 lines
SEND_QUEUE_STATUS(CMD13)polling.
Since MSDC CQE usesmsdc_hclkas ITCFVAL, so driver should use hclk frequency to get the actual time.
The default value0x1000that corresponds to 150us for MediaTekSoCs, let's
Quoted 1 line
decrease it to
0x40that corresponds to 2.35us, which can improvethe
Quoted 6 lines
performance of some eMMC devices.
Signed-off-by Wenbin Mei <[email protected]>--- drivers/mmc/host/cqhci.h | 1 + drivers/mmc/host/mtk-sd.c | 45+++++++++++++++++++++++++++++++++++++++
Quoted 19 lines
2 files changed, 46 insertions(+)drivers/mmc/host/cqhci.h +1
-0@@ -23,6 +23,7 @@/* capabilities */ #define CQHCI_CAP0x04#define CQHCI_CAP_CS0x10000000/* Crypto Support */ +#define CQHCI_CAP_ITCFMUL (x)(((x) & GENMASK(15, 12)) >> 12)/* configuration */ #define CQHCI_CFG0x08drivers/mmc/host/mtk-sd.c +0
-0drivers/mmc/host/mtk-sd.c struct msdc_host { · line 474
Quoted 2 lines
drivers/mmc/host/mtk-sd.c +0
-0@@ -473,6 +473,7 @@ struct msdc_host {struct msdc_tune_para def_tune_para;/* default tune setting */ struct msdc_tune_para saved_tune_para;/* tune result of CMD21/CMD19 */
drivers/mmc/host/mtk-sd.c static void
Quoted 6 lines
drivers/mmc/host/mtk-sd.c +1
-0struct cqhci_host *cq_host; +u32 cq_ssc1_time; };static const struct mtk_mmc_compatible mt2701_compat = {@@ -2450,9 +2451,48 @@ static voidmsdc_hs400_enhanced_strobe(struct
mmc_host*mmc,drivers/mmc/host/mtk-sd.c static void msdc_hs400_enhanced_strobe(struct mmc_host *mmc,
Quoted 12 lines
drivers/mmc/host/mtk-sd.c +9
-0} } +static void msdc_cqe_cit_cal (struct msdc_host *host,u64 timer_ns) +{ +struct mmc_host *mmc =mmc_from_priv (host); +struct cqhci_host *cq_host = mmc->cqe_private; +u8 itcfmul; +u64 hclk_freq; +u64 value; + +/* Since MSDC CQE uses msdc_hclk as ITCFVAL, so driver should use hclk
drivers/mmc/host/mtk-sd.c static void msdc_hs400_enhanced_strobe(struct mmc_host *mmc, · line 2464
Quoted 2 lines
drivers/mmc/host/mtk-sd.c +2
-0+* frequency to get the actual time for CIT. +*/ /*
* On MediaTek SoCs the MSDC controller's CQE usesmsdc_hclkas
ITCFVAL
* so we multiply/divide the HCLK frequency by ITCFMUL to
calculate the
* Send Status Command Idle Timer (CIT) value.
*/
Quoted 2 lines
The proposed comment increases readability.
Thanks for your review.
I will change it in the next version.
Begards,
Wenbin
Quoted 2 lines
Cheers,
Angelo
Adrian Hunter
maintainerQuoted 19 lines · Wenbin Mei
CQHCI_SSC1indicates to CQE the polling period to use when using periodicSEND_QUEUE_STATUS(CMD13)polling.
Since MSDC CQE usesmsdc_hclkas ITCFVAL, so driver should use hclk frequency to get the actual time.
The default value0x1000that corresponds to 150us for MediaTek SoCs, let's decrease it to0x40that corresponds to 2.35us, which can improve the performance of some eMMC devices.Signed-off-by Wenbin Mei <[email protected]>--- drivers/mmc/host/cqhci.h | 1 + drivers/mmc/host/mtk-sd.c | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)drivers/mmc/host/cqhci.h +0
-0
drivers/mmc/host/cqhci.h line 26
Quoted 4 lines
drivers/mmc/host/cqhci.h +1
-0@@ -23,6 +23,7 @@/* capabilities */ #define CQHCI_CAP 0x04#define CQHCI_CAP_CS 0x10000000/* Crypto Support */ +#define CQHCI_CAP_ITCFMUL (x) (((x) & GENMASK(15, 12)) >> 12)
Let's not open code FIELD_GET, perhaps
#define CQHCI_CAP_ITCFMUL GENMASK(15, 12)
#define CQHCI_ITCFMUL(x) FIELD_GET(CQHCI_CAP_ITCFMUL,(x))
Quoted 65 lines
drivers/mmc/host/cqhci.h +0
-0/* configuration */ #define CQHCI_CFG 0x08drivers/mmc/host/mtk-sd.c +40
-0@@ -473,6 +473,7 @@ struct msdc_host {struct msdc_tune_para def_tune_para;/* default tune setting */ struct msdc_tune_para saved_tune_para;/* tune result of CMD21/CMD19 */ struct cqhci_host *cq_host; +u32 cq_ssc1_time; };static const struct mtk_mmc_compatible mt2701_compat = {@@ -2450,9 +2451,48 @@ static void msdc_hs400_enhanced_strobe(struct mmc_host *mmc, } } +static void msdc_cqe_cit_cal (struct msdc_host *host,u64 timer_ns) +{ +struct mmc_host *mmc =mmc_from_priv (host); +struct cqhci_host *cq_host = mmc->cqe_private; +u8 itcfmul; +u64 hclk_freq; +u64 value; + +/* Since MSDC CQE uses msdc_hclk as ITCFVAL, so driver should use hclk +* frequency to get the actual time for CIT. +*/ + hclk_freq =clk_get_rate (host->h_clk); + itcfmul =CQHCI_CAP_ITCFMUL (cqhci_readl (cq_host,CQHCI_CAP )); +switch (itcfmul) { +case 0x0 : +do_div (hclk_freq,1000 ); +break ; +case 0x1 : +do_div (hclk_freq,100 ); +break ; +case 0x2 : +do_div (hclk_freq,10 ); +break ; +case 0x3 : +break ; +case 0x4 : + hclk_freq = hclk_freq *10 ; +break ; +default : + host->cq_ssc1_time =0x40 ; +return ; + } + + value = hclk_freq * timer_ns; +do_div (value,1000000000 ); + host->cq_ssc1_time = value; +} +static void msdc_cqe_enable (struct mmc_host *mmc) {struct msdc_host *host =mmc_priv (mmc); +struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel (MSDC_INT_CMDQ , host->base +MSDC_INTEN );
drivers/mmc/host/mtk-sd.c static void msdc_cqe_enable(struct mmc_host *mmc) · line 2507
Quoted 6 lines
drivers/mmc/host/mtk-sd.c +3
-0@@ -2462,6 +2502,9 @@ static void msdc_cqe_enable(struct mmc_host *mmc)msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* Set the send status command idle timer */ +cqhci_writel (cq_host, host->cq_ssc1_time,CQHCI_SSC1 );
What about Send Status Command Block Counter (CBC) bits 19:16 ?
Quoted 12 lines
drivers/mmc/host/mtk-sd.c +2
-0}static void msdc_cqe_disable (struct mmc_host *mmc,bool recovery)@@ -2803,6 +2846,8 @@ static int msdc_drv_probe(struct platform_device *pdev)/* cqhci 16bit length */ /* 0 size, means 65536 so we don't have to -1 here */ mmc->max_seg_size =64 *1024 ; +/* Reduce CIT to 0x40 that corresponds to 2.35us */ +msdc_cqe_cit_cal (host,2350 ); } ret = devm_request_irq(&pdev->dev, host->irq, msdc_irq,
Quoted 34 lines · Adrian Hunter
External email : Please do not click links or open attachments until you have verified the sender or the content.
Quoted 1 line · Wenbin Mei
CQHCI_SSC1indicates to CQE the polling period to use when usingperiodic
Quoted 4 lines
SEND_QUEUE_STATUS(CMD13)polling.
Since MSDC CQE usesmsdc_hclkas ITCFVAL, so driver should use hclk frequency to get the actual time.
The default value0x1000that corresponds to 150us for MediaTekSoCs, let's
Quoted 1 line
decrease it to
0x40that corresponds to 2.35us, which can improvethe
Quoted 6 lines
performance of some eMMC devices.
Signed-off-by Wenbin Mei <[email protected]>--- drivers/mmc/host/cqhci.h | 1 + drivers/mmc/host/mtk-sd.c | 45+++++++++++++++++++++++++++++++++++++++
drivers/mmc/host/cqhci.h line 26
Quoted 11 lines
2 files changed, 46 insertions(+)drivers/mmc/host/cqhci.h +1
-0@@ -23,6 +23,7 @@/* capabilities */ #define CQHCI_CAP0x04#define CQHCI_CAP_CS0x10000000/* Crypto Support */ +#define CQHCI_CAP_ITCFMUL (x)(((x) & GENMASK(15, 12)) >> 12)Let's not open code
FIELD_GET, perhaps
Quoted 4 lines
#define
CQHCI_CAP_ITCFMULGENMASK(15, 12)#define CQHCI_ITCFMUL(x)FIELD_GET(CQHCI_CAP_ITCFMUL,(x))
Okay. I will change it.
Quoted 69 lines
drivers/mmc/host/mtk-sd.c struct msdc_host { · line 474
Quoted 10 lines
drivers/mmc/host/cqhci.h +0
-0/* configuration */ #define CQHCI_CFG0x08drivers/mmc/host/mtk-sd.c +0
-0@@ -473,6 +473,7 @@ struct msdc_host {struct msdc_tune_para def_tune_para;/* default tune setting */ struct msdc_tune_para saved_tune_para;/* tune result of CMD21/CMD19 */
drivers/mmc/host/mtk-sd.c static void
Quoted 6 lines
drivers/mmc/host/mtk-sd.c +1
-0struct cqhci_host *cq_host; +u32 cq_ssc1_time; };static const struct mtk_mmc_compatible mt2701_compat = {@@ -2450,9 +2451,48 @@ static voidmsdc_hs400_enhanced_strobe(struct
mmc_host*mmc,drivers/mmc/host/mtk-sd.c static void msdc_hs400_enhanced_strobe(struct mmc_host *mmc,
Quoted 12 lines
drivers/mmc/host/mtk-sd.c +9
-0} } +static void msdc_cqe_cit_cal (struct msdc_host *host,u64 timer_ns) +{ +struct mmc_host *mmc =mmc_from_priv (host); +struct cqhci_host *cq_host = mmc->cqe_private; +u8 itcfmul; +u64 hclk_freq; +u64 value; + +/* Since MSDC CQE uses msdc_hclk as ITCFVAL, so driver should use hclk
drivers/mmc/host/mtk-sd.c static void msdc_cqe_enable(struct mmc_host
Quoted 37 lines
drivers/mmc/host/mtk-sd.c +30
-0+* frequency to get the actual time for CIT. +*/ +hclk_freq =clk_get_rate (host->h_clk); +itcfmul =CQHCI_CAP_ITCFMUL (cqhci_readl (cq_host,CQHCI_CAP )); +switch (itcfmul) { +case 0x0 : +do_div (hclk_freq,1000 ); +break ; +case 0x1 : +do_div (hclk_freq,100 ); +break ; +case 0x2 : +do_div (hclk_freq,10 ); +break ; +case 0x3 : +break ; +case 0x4 : +hclk_freq = hclk_freq *10 ; +break ; +default : +host->cq_ssc1_time =0x40 ; +return ; +} + +value = hclk_freq * timer_ns; +do_div (value,1000000000 ); +host->cq_ssc1_time = value; +} +static void msdc_cqe_enable (struct mmc_host *mmc) {struct msdc_host *host =mmc_priv (mmc); +struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel (MSDC_INT_CMDQ , host->base +MSDC_INTEN );@@ -2462,6 +2502,9 @@ static void msdc_cqe_enable(struct mmc_host*mmc)
Quoted 9 lines
drivers/mmc/host/mtk-sd.c static void msdc_cqe_enable(struct mmc_host *mmc) · line 2507
Quoted 6 lines
drivers/mmc/host/mtk-sd.c +3
-0msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* Set the send status command idle timer */ +cqhci_writel (cq_host, host->cq_ssc1_time,CQHCI_SSC1 );What about Send Status Command Block Counter (CBC) bits 19:16 ?
MSDC controller does not support this feature.
Quoted 14 lines
drivers/mmc/host/mtk-sd.c static int msdc_drv_probe(struct
Quoted 4 lines
drivers/mmc/host/mtk-sd.c +0
-0}static void msdc_cqe_disable (struct mmc_host *mmc,bool recovery)@@ -2803,6 +2846,8 @@ static int msdc_drv_probe(struct
platform_device*pdev)Quoted 8 lines
drivers/mmc/host/mtk-sd.c +2
-0/* cqhci 16bit length */ /* 0 size, means 65536 so we don't have to -1 here */ mmc->max_seg_size =64 *1024 ; +/* Reduce CIT to 0x40 that corresponds to 2.35us */ +msdc_cqe_cit_cal (host,2350 ); } ret = devm_request_irq(&pdev->dev, host->irq, msdc_irq,