mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mmc: spacemit: Introduce tx delay DT property
@ 2026-11-25 23:04 Yixun Lan
  2026-11-25 23:04 ` [PATCH v2 1/2] dt-bindings: mmc: spacemit,sdhci: Add tx delay property Yixun Lan
  2026-11-25 23:04 ` [PATCH v2 2/2] mmc: sdhci-of-k1: Add TX tuning parameter Yixun Lan
  0 siblings, 2 replies; 3+ messages in thread
From: Yixun Lan @ 2026-11-25 23:04 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Adrian Hunter
  Cc: Long Wan, linux-mmc, devicetree, linux-riscv, spacemit,
	linux-kernel, Yixun Lan, Conor Dooley

In this series, we try to introduce a tx delay property for SpacemiT
SDHCI driver, which used to configure the step count of TX delay line,
it is needed due to varous hardware layout has different tuning settings.

Signed-off-by: Yixun Lan <dlan@kernel.org>
---
Changes in v2:
- drop the idea of introducing a vendor clock-frequency property
- use type of uint8 for tx delay property, and adjust code accordingly
- collect ACK tag
- Link to v1: https://patch.msgid.link/20260902-07-k3-sdhci-dts-v1-0-4e7909cf4233@kernel.org

---
Long Wan (2):
      dt-bindings: mmc: spacemit,sdhci: Add tx delay property
      mmc: sdhci-of-k1: Add TX tuning parameter

 .../devicetree/bindings/mmc/spacemit,sdhci.yaml     |  9 +++++++++
 drivers/mmc/host/sdhci-of-k1.c                      | 21 +++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260901-07-k3-sdhci-dts-579b17b1e205

Best regards,
--  
Yixun Lan <dlan@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/2] dt-bindings: mmc: spacemit,sdhci: Add tx delay property
  2026-11-25 23:04 [PATCH v2 0/2] mmc: spacemit: Introduce tx delay DT property Yixun Lan
@ 2026-11-25 23:04 ` Yixun Lan
  2026-11-25 23:04 ` [PATCH v2 2/2] mmc: sdhci-of-k1: Add TX tuning parameter Yixun Lan
  1 sibling, 0 replies; 3+ messages in thread
From: Yixun Lan @ 2026-11-25 23:04 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Adrian Hunter
  Cc: Long Wan, linux-mmc, devicetree, linux-riscv, spacemit,
	linux-kernel, Yixun Lan, Conor Dooley

From: Long Wan <long.wan@linux.spacemit.com>

Introduce a vendor specific property to configure the step count of TX
delay line which should be applied before RX tuning, compensating for
board level trace differences. The TX delay line result comes from test
out of real board which vary from different hardware layout.

Signed-off-by: Long Wan <long.wan@linux.spacemit.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Yixun Lan <dlan@kernel.org>
---
 Documentation/devicetree/bindings/mmc/spacemit,sdhci.yaml | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/spacemit,sdhci.yaml b/Documentation/devicetree/bindings/mmc/spacemit,sdhci.yaml
index 34d202af909f..7df48fedc982 100644
--- a/Documentation/devicetree/bindings/mmc/spacemit,sdhci.yaml
+++ b/Documentation/devicetree/bindings/mmc/spacemit,sdhci.yaml
@@ -56,6 +56,15 @@ properties:
   pinctrl-1:
     description: Optional pinctrl state for 1.8V UHS operation with "uhs" name
 
+  spacemit,tx-delay:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    default: 127
+    description:
+      TX delay line setting applied before RX tuning, compensating for
+      board level trace differences. This is a delay line step count with
+      no fixed time-per-step conversion; determined empirically per board
+      specific, used on SD/SDIO hosts.
+
 required:
   - compatible
   - reg

-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] mmc: sdhci-of-k1: Add TX tuning parameter
  2026-11-25 23:04 [PATCH v2 0/2] mmc: spacemit: Introduce tx delay DT property Yixun Lan
  2026-11-25 23:04 ` [PATCH v2 1/2] dt-bindings: mmc: spacemit,sdhci: Add tx delay property Yixun Lan
@ 2026-11-25 23:04 ` Yixun Lan
  1 sibling, 0 replies; 3+ messages in thread
From: Yixun Lan @ 2026-11-25 23:04 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Adrian Hunter
  Cc: Long Wan, linux-mmc, devicetree, linux-riscv, spacemit,
	linux-kernel, Yixun Lan

From: Long Wan <long.wan@linux.spacemit.com>

Instead of setting the TX delay code via hardcoded parameter, configuring
it via device tree property, which make it able to adapt according to
board specific tuning requirement.

Signed-off-by: Long Wan <long.wan@linux.spacemit.com>
Signed-off-by: Yixun Lan <dlan@kernel.org>
---
 drivers/mmc/host/sdhci-of-k1.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-k1.c b/drivers/mmc/host/sdhci-of-k1.c
index 37b0911e7cf2..ee613e1417fa 100644
--- a/drivers/mmc/host/sdhci-of-k1.c
+++ b/drivers/mmc/host/sdhci-of-k1.c
@@ -97,6 +97,7 @@ struct spacemit_sdhci_host {
 	struct pinctrl *pinctrl;
 	struct pinctrl_state *pinctrl_default;
 	struct pinctrl_state *pinctrl_uhs;
+	u8 tx_delaycode;
 };
 
 /* All helper functions will update clr/set while preserve rest bits */
@@ -278,12 +279,15 @@ static int spacemit_sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
 		return 0;
 
 	if (mmc->caps2 & MMC_CAP2_NO_MMC) {
+		struct spacemit_sdhci_host *sdhst;
+
+		sdhst = sdhci_pltfm_priv(sdhci_priv(host));
 		spacemit_sdhci_set_tx_dline_reg(host, SPACEMIT_TX_TUNING_DLINE_REG);
-		spacemit_sdhci_set_tx_delay(host, SPACEMIT_TX_TUNING_DELAYCODE);
+		spacemit_sdhci_set_tx_delay(host, sdhst->tx_delaycode);
 		spacemit_sdhci_tx_tuning_prepare(host);
 
 		dev_dbg(mmc_dev(host->mmc), "TX tuning: dline_reg=%d, delaycode=%d\n",
-			SPACEMIT_TX_TUNING_DLINE_REG, SPACEMIT_TX_TUNING_DELAYCODE);
+			SPACEMIT_TX_TUNING_DLINE_REG, sdhst->tx_delaycode);
 	}
 
 	spacemit_sdhci_prepare_tuning(host);
@@ -491,6 +495,17 @@ static inline void spacemit_sdhci_get_pins(struct device *dev,
 		sdhst->pinctrl_default, sdhst->pinctrl_uhs);
 }
 
+static void spacemit_sdhci_get_tuning_params(struct device *dev,
+					     struct sdhci_pltfm_host *pltfm_host)
+{
+	struct spacemit_sdhci_host *sdhst = sdhci_pltfm_priv(pltfm_host);
+
+	sdhst->tx_delaycode = SPACEMIT_TX_TUNING_DELAYCODE;
+
+	/* Override if valid from DT property */
+	device_property_read_u8(dev, "spacemit,tx-delay", &sdhst->tx_delaycode);
+}
+
 static const struct sdhci_ops spacemit_sdhci_ops = {
 	.get_max_clock		= spacemit_sdhci_clk_get_max_clock,
 	.reset			= spacemit_sdhci_reset,
@@ -566,6 +581,8 @@ static int spacemit_sdhci_probe(struct platform_device *pdev)
 
 	spacemit_sdhci_get_pins(dev, pltfm_host);
 
+	spacemit_sdhci_get_tuning_params(dev, pltfm_host);
+
 	host->mmc_host_ops.start_signal_voltage_switch = spacemit_sdhci_start_signal_voltage_switch;
 
 	ret = spacemit_sdhci_get_clocks(dev, pltfm_host);

-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-25 23:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 23:04 [PATCH v2 0/2] mmc: spacemit: Introduce tx delay DT property Yixun Lan
2026-11-25 23:04 ` [PATCH v2 1/2] dt-bindings: mmc: spacemit,sdhci: Add tx delay property Yixun Lan
2026-11-25 23:04 ` [PATCH v2 2/2] mmc: sdhci-of-k1: Add TX tuning parameter Yixun Lan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®