* [PATCH V6 1/4] mmc: sdhci-msm: Enable tuning for SDR50 mode for SD card
2025-09-08 10:41 [PATCH V6 0/4] Add level shifter support for qualcomm SOC's Sarthak Garg
@ 2025-09-08 10:41 ` Sarthak Garg
2025-09-08 10:41 ` [PATCH V6 2/4] dt-bindings: mmc: controller: Add max-sd-hs-hz property Sarthak Garg
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Sarthak Garg @ 2025-09-08 10:41 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio, Adrian Hunter
Cc: linux-mmc, devicetree, linux-kernel, linux-arm-msm, quic_nguyenb,
quic_rampraka, quic_pragalla, quic_sayalil, quic_nitirawa,
quic_bhaskarv, kernel, Sarthak Garg
For Qualcomm SoCs which needs level shifter for SD card, extra delay is
seen on receiver data path.
To compensate this delay enable tuning for SDR50 mode for targets which
has level shifter. SDHCI_SDR50_NEEDS_TUNING caps will be set for targets
with level shifter on Qualcomm SOC's.
Signed-off-by: Sarthak Garg <quic_sartgarg@quicinc.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---
drivers/mmc/host/sdhci-msm.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 66c0d1ba2a33..bf91cb96a0ea 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -81,6 +81,7 @@
#define CORE_IO_PAD_PWR_SWITCH_EN BIT(15)
#define CORE_IO_PAD_PWR_SWITCH BIT(16)
#define CORE_HC_SELECT_IN_EN BIT(18)
+#define CORE_HC_SELECT_IN_SDR50 (4 << 19)
#define CORE_HC_SELECT_IN_HS400 (6 << 19)
#define CORE_HC_SELECT_IN_MASK (7 << 19)
@@ -1133,6 +1134,10 @@ static bool sdhci_msm_is_tuning_needed(struct sdhci_host *host)
{
struct mmc_ios *ios = &host->mmc->ios;
+ if (ios->timing == MMC_TIMING_UHS_SDR50 &&
+ host->flags & SDHCI_SDR50_NEEDS_TUNING)
+ return true;
+
/*
* Tuning is required for SDR104, HS200 and HS400 cards and
* if clock frequency is greater than 100MHz in these modes.
@@ -1201,6 +1206,8 @@ static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode)
struct mmc_ios ios = host->mmc->ios;
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
+ const struct sdhci_msm_offset *msm_offset = msm_host->offset;
+ u32 config;
if (!sdhci_msm_is_tuning_needed(host)) {
msm_host->use_cdr = false;
@@ -1217,6 +1224,14 @@ static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode)
*/
msm_host->tuning_done = 0;
+ if (ios.timing == MMC_TIMING_UHS_SDR50 &&
+ host->flags & SDHCI_SDR50_NEEDS_TUNING) {
+ config = readl_relaxed(host->ioaddr + msm_offset->core_vendor_spec);
+ config &= ~CORE_HC_SELECT_IN_MASK;
+ config |= CORE_HC_SELECT_IN_EN | CORE_HC_SELECT_IN_SDR50;
+ writel_relaxed(config, host->ioaddr + msm_offset->core_vendor_spec);
+ }
+
/*
* For HS400 tuning in HS200 timing requires:
* - select MCLK/2 in VENDOR_SPEC
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH V6 2/4] dt-bindings: mmc: controller: Add max-sd-hs-hz property
2025-09-08 10:41 [PATCH V6 0/4] Add level shifter support for qualcomm SOC's Sarthak Garg
2025-09-08 10:41 ` [PATCH V6 1/4] mmc: sdhci-msm: Enable tuning for SDR50 mode for SD card Sarthak Garg
@ 2025-09-08 10:41 ` Sarthak Garg
2025-09-09 7:00 ` Krzysztof Kozlowski
2025-09-08 10:41 ` [PATCH V6 3/4] mmc: core: Introduce a new flag max-sd-hs-hz Sarthak Garg
` (3 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Sarthak Garg @ 2025-09-08 10:41 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio, Adrian Hunter
Cc: linux-mmc, devicetree, linux-kernel, linux-arm-msm, quic_nguyenb,
quic_rampraka, quic_pragalla, quic_sayalil, quic_nitirawa,
quic_bhaskarv, kernel, Sarthak Garg
Introduce a new optional device tree property max-sd-hs-hz to
limit the maximum frequency (in Hz) used for SD cards operating in
High-Speed (HS) mode due to any board electrical limitations.
Signed-off-by: Sarthak Garg <quic_sartgarg@quicinc.com>
---
.../devicetree/bindings/mmc/mmc-controller-common.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/devicetree/bindings/mmc/mmc-controller-common.yaml b/Documentation/devicetree/bindings/mmc/mmc-controller-common.yaml
index 9a7235439759..7414d5522dfe 100644
--- a/Documentation/devicetree/bindings/mmc/mmc-controller-common.yaml
+++ b/Documentation/devicetree/bindings/mmc/mmc-controller-common.yaml
@@ -93,6 +93,14 @@ properties:
minimum: 400000
maximum: 384000000
+ max-sd-hs-hz:
+ description: |
+ Maximum frequency (in Hz) to be used for SD cards operating in
+ High-Speed (HS) mode.
+ minimum: 400000
+ maximum: 50000000
+ default: 50000000
+
disable-wp:
$ref: /schemas/types.yaml#/definitions/flag
description:
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH V6 2/4] dt-bindings: mmc: controller: Add max-sd-hs-hz property
2025-09-08 10:41 ` [PATCH V6 2/4] dt-bindings: mmc: controller: Add max-sd-hs-hz property Sarthak Garg
@ 2025-09-09 7:00 ` Krzysztof Kozlowski
0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-09 7:00 UTC (permalink / raw)
To: Sarthak Garg
Cc: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio, Adrian Hunter, linux-mmc,
devicetree, linux-kernel, linux-arm-msm, quic_nguyenb,
quic_rampraka, quic_pragalla, quic_sayalil, quic_nitirawa,
quic_bhaskarv, kernel
On Mon, Sep 08, 2025 at 04:11:20PM +0530, Sarthak Garg wrote:
> Introduce a new optional device tree property max-sd-hs-hz to
> limit the maximum frequency (in Hz) used for SD cards operating in
> High-Speed (HS) mode due to any board electrical limitations.
>
> Signed-off-by: Sarthak Garg <quic_sartgarg@quicinc.com>
> ---
> .../devicetree/bindings/mmc/mmc-controller-common.yaml | 8 ++++++++
> 1 file changed, 8 insertions(+)
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V6 3/4] mmc: core: Introduce a new flag max-sd-hs-hz
2025-09-08 10:41 [PATCH V6 0/4] Add level shifter support for qualcomm SOC's Sarthak Garg
2025-09-08 10:41 ` [PATCH V6 1/4] mmc: sdhci-msm: Enable tuning for SDR50 mode for SD card Sarthak Garg
2025-09-08 10:41 ` [PATCH V6 2/4] dt-bindings: mmc: controller: Add max-sd-hs-hz property Sarthak Garg
@ 2025-09-08 10:41 ` Sarthak Garg
2025-09-08 10:41 ` [PATCH V6 4/4] arm64: dts: qcom: sm8550: Limit max SD HS mode frequency by default Sarthak Garg
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Sarthak Garg @ 2025-09-08 10:41 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio, Adrian Hunter
Cc: linux-mmc, devicetree, linux-kernel, linux-arm-msm, quic_nguyenb,
quic_rampraka, quic_pragalla, quic_sayalil, quic_nitirawa,
quic_bhaskarv, kernel, Sarthak Garg
Introduce a new device tree flag to cap the maximum High-Speed (HS)
mode frequency for SD cards, accommodating board-specific
electrical limitations which cannot support the default 50Mhz HS
frequency and others.
Signed-off-by: Sarthak Garg <quic_sartgarg@quicinc.com>
---
drivers/mmc/core/host.c | 2 ++
drivers/mmc/core/sd.c | 2 +-
include/linux/mmc/host.h | 1 +
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index dacb5bd9bb71..3fe6ae56a6ae 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -302,6 +302,8 @@ int mmc_of_parse(struct mmc_host *host)
/* f_max is obtained from the optional "max-frequency" property */
device_property_read_u32(dev, "max-frequency", &host->f_max);
+ device_property_read_u32(dev, "max-sd-hs-hz", &host->max_sd_hs_hz);
+
/*
* Configure CD and WP pins. They are both by default active low to
* match the SDHCI spec. If GPIOs are provided for CD and / or WP, the
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index ec02067f03c5..67cd63004829 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -359,7 +359,7 @@ static int mmc_read_switch(struct mmc_card *card)
}
if (status[13] & SD_MODE_HIGH_SPEED)
- card->sw_caps.hs_max_dtr = HIGH_SPEED_MAX_DTR;
+ card->sw_caps.hs_max_dtr = card->host->max_sd_hs_hz ?: HIGH_SPEED_MAX_DTR;
if (card->scr.sda_spec3) {
card->sw_caps.sd3_bus_mode = status[13];
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 68f09a955a90..a698b4b02d95 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -565,6 +565,7 @@ struct mmc_host {
int hsq_depth;
u32 err_stats[MMC_ERR_MAX];
+ unsigned int max_sd_hs_hz;
unsigned long private[] ____cacheline_aligned;
};
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH V6 4/4] arm64: dts: qcom: sm8550: Limit max SD HS mode frequency by default
2025-09-08 10:41 [PATCH V6 0/4] Add level shifter support for qualcomm SOC's Sarthak Garg
` (2 preceding siblings ...)
2025-09-08 10:41 ` [PATCH V6 3/4] mmc: core: Introduce a new flag max-sd-hs-hz Sarthak Garg
@ 2025-09-08 10:41 ` Sarthak Garg
2025-09-09 7:01 ` Krzysztof Kozlowski
2025-09-12 13:34 ` [PATCH V6 0/4] Add level shifter support for qualcomm SOC's Ulf Hansson
2025-10-30 16:25 ` (subset) " Bjorn Andersson
5 siblings, 1 reply; 9+ messages in thread
From: Sarthak Garg @ 2025-09-08 10:41 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio, Adrian Hunter
Cc: linux-mmc, devicetree, linux-kernel, linux-arm-msm, quic_nguyenb,
quic_rampraka, quic_pragalla, quic_sayalil, quic_nitirawa,
quic_bhaskarv, kernel, Sarthak Garg
Due to an implementation detail in this SoC, additional passive
electrical components are required to achieve the maximum rated speed
of the SD controller when paired with a High-Speed SD Card. Without
them, the clock frequency must be limited to 37.5 MHz for link stability.
Because the reference design does not contain these components, most
(derivative) boards do not have them either. To accommodate for that,
apply the frequency limit by default and delegate lifting it to the
odd boards that do contain the necessary onboard hardware.
Signed-off-by: Sarthak Garg <quic_sartgarg@quicinc.com>
---
arch/arm64/boot/dts/qcom/sm8550.dtsi | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/boot/dts/qcom/sm8550.dtsi b/arch/arm64/boot/dts/qcom/sm8550.dtsi
index 82cabf777cd2..3692a3a49634 100644
--- a/arch/arm64/boot/dts/qcom/sm8550.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8550.dtsi
@@ -3189,6 +3189,7 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
&config_noc SLAVE_SDCC_2 QCOM_ICC_TAG_ACTIVE_ONLY>;
interconnect-names = "sdhc-ddr", "cpu-sdhc";
bus-width = <4>;
+ max-sd-hs-hz = <37500000>;
dma-coherent;
/* Forbid SDR104/SDR50 - broken hw! */
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH V6 4/4] arm64: dts: qcom: sm8550: Limit max SD HS mode frequency by default
2025-09-08 10:41 ` [PATCH V6 4/4] arm64: dts: qcom: sm8550: Limit max SD HS mode frequency by default Sarthak Garg
@ 2025-09-09 7:01 ` Krzysztof Kozlowski
0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-09 7:01 UTC (permalink / raw)
To: Sarthak Garg
Cc: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio, Adrian Hunter, linux-mmc,
devicetree, linux-kernel, linux-arm-msm, quic_nguyenb,
quic_rampraka, quic_pragalla, quic_sayalil, quic_nitirawa,
quic_bhaskarv, kernel
On Mon, Sep 08, 2025 at 04:11:22PM +0530, Sarthak Garg wrote:
> Due to an implementation detail in this SoC, additional passive
> electrical components are required to achieve the maximum rated speed
> of the SD controller when paired with a High-Speed SD Card. Without
> them, the clock frequency must be limited to 37.5 MHz for link stability.
>
> Because the reference design does not contain these components, most
> (derivative) boards do not have them either. To accommodate for that,
> apply the frequency limit by default and delegate lifting it to the
> odd boards that do contain the necessary onboard hardware.
>
> Signed-off-by: Sarthak Garg <quic_sartgarg@quicinc.com>
> ---
> arch/arm64/boot/dts/qcom/sm8550.dtsi | 1 +
> 1 file changed, 1 insertion(+)
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH V6 0/4] Add level shifter support for qualcomm SOC's.
2025-09-08 10:41 [PATCH V6 0/4] Add level shifter support for qualcomm SOC's Sarthak Garg
` (3 preceding siblings ...)
2025-09-08 10:41 ` [PATCH V6 4/4] arm64: dts: qcom: sm8550: Limit max SD HS mode frequency by default Sarthak Garg
@ 2025-09-12 13:34 ` Ulf Hansson
2025-10-30 16:25 ` (subset) " Bjorn Andersson
5 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2025-09-12 13:34 UTC (permalink / raw)
To: Sarthak Garg
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
Konrad Dybcio, Adrian Hunter, linux-mmc, devicetree,
linux-kernel, linux-arm-msm, quic_nguyenb, quic_rampraka,
quic_pragalla, quic_sayalil, quic_nitirawa, quic_bhaskarv,
kernel
On Mon, 8 Sept 2025 at 12:41, Sarthak Garg <quic_sartgarg@quicinc.com> wrote:
>
> Add level shifter support for qualcomm SOC's.
>
> - Changed from v5
> - As suggested by Krzysztof Kozlowski reintroduced minimum/maximum
> in dt bindings and avoid repeating constraints in free form
> text.
> - As suggested by Krzysztof Kozlowski/Konrad Dybcio update commit
> message reflecting discussions and previous disagreements.
>
> - Changed from v4
> - As suggested by Krzysztof Kozlowski Renamed the property from
> `max-sd-hs-frequency` to `max-sd-hs-hz` for clarity.
> - As suggested by Krzysztof Kozlowski remove min/max constraints
> and add default: 50000000 in dt-bindings.
> - As suggested by Konrad Dybcio moved max-sd-hs-hz property in the
> SoC dtsi.
> - Retained sdhci-caps-mask in sm8550.dtsi for now and will revisit
> its removal for future targets after thorough validation and testing
> from the beginning.
>
> - Changed from v3
> - As suggested by Krzysztof Kozlowski moved the property from the
> SoC-level DTS to the board-level DTS.
> - Revised the commit messages to clearly explain its board-specific.
>
> - Changed from v2
> - As suggested by Konrad Dybcio and Ulf Hansson redesigned logic
> to introduce a new DT property max-sd-hs-frequency and override
> the hs_max_dtr accordingly in sd.c file.
>
> - Changed from v1
> - As suggested by Krzysztof Kozlowski redesigned logic to use
> compatible property for adding this level shifter support.
> - Addressed Adrian Hunter comments on V1 with resepect to
> checkpatch.
> - Cleared the bits first and then set bits in
> sdhci_msm_execute_tuning as suggested by Adrian Hunter.
> - Upated the if condition logic in msm_set_clock_rate_for_bus_mode
> as suggested by Adrian Hunter.
>
> Sarthak Garg (4):
> mmc: sdhci-msm: Enable tuning for SDR50 mode for SD card
> dt-bindings: mmc: controller: Add max-sd-hs-hz property
> mmc: core: Introduce a new flag max-sd-hs-hz
> arm64: dts: qcom: sm8550: Limit max SD HS mode frequency by default
>
> .../bindings/mmc/mmc-controller-common.yaml | 8 ++++++++
> arch/arm64/boot/dts/qcom/sm8550.dtsi | 1 +
> drivers/mmc/core/host.c | 2 ++
> drivers/mmc/core/sd.c | 2 +-
> drivers/mmc/host/sdhci-msm.c | 15 +++++++++++++++
> include/linux/mmc/host.h | 1 +
> 6 files changed, 28 insertions(+), 1 deletion(-)
>
> --
> 2.34.1
>
Patch 1 -> 3, applied for next, thanks!
Note that, I took the liberty of amending patch3 to change the
declaration of "max_sd_hs_hz" to an u32, rather than an unsigned int.
Kind regards
Uffe
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: (subset) [PATCH V6 0/4] Add level shifter support for qualcomm SOC's.
2025-09-08 10:41 [PATCH V6 0/4] Add level shifter support for qualcomm SOC's Sarthak Garg
` (4 preceding siblings ...)
2025-09-12 13:34 ` [PATCH V6 0/4] Add level shifter support for qualcomm SOC's Ulf Hansson
@ 2025-10-30 16:25 ` Bjorn Andersson
5 siblings, 0 replies; 9+ messages in thread
From: Bjorn Andersson @ 2025-10-30 16:25 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Konrad Dybcio, Adrian Hunter, Sarthak Garg
Cc: linux-mmc, devicetree, linux-kernel, linux-arm-msm, quic_nguyenb,
quic_rampraka, quic_pragalla, quic_sayalil, quic_nitirawa,
quic_bhaskarv, kernel
On Mon, 08 Sep 2025 16:11:18 +0530, Sarthak Garg wrote:
> Add level shifter support for qualcomm SOC's.
>
> - Changed from v5
> - As suggested by Krzysztof Kozlowski reintroduced minimum/maximum
> in dt bindings and avoid repeating constraints in free form
> text.
> - As suggested by Krzysztof Kozlowski/Konrad Dybcio update commit
> message reflecting discussions and previous disagreements.
>
> [...]
Applied, thanks!
[4/4] arm64: dts: qcom: sm8550: Limit max SD HS mode frequency by default
commit: c3398456f6f6121e79f6c3d9bff00076cf7a3521
Best regards,
--
Bjorn Andersson <andersson@kernel.org>
^ permalink raw reply [flat|nested] 9+ messages in thread