All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: cv1800b_sdhci: configure SDHCI PHY
@ 2026-09-07 14:54 Andrei Lalaev
  2026-09-07 18:08 ` Yao Zi
  0 siblings, 1 reply; 5+ messages in thread
From: Andrei Lalaev @ 2026-09-07 14:54 UTC (permalink / raw)
  To: Leo Yu-Chi Liang, Kongyang Liu, u-boot
  Cc: Peng Fan, Jaehoon Chung, Tom Rini, Hiago De Franco, Andrei Lalaev

Some samples of the Milk-V Duo and Duo 256M have issues with SD card
communication. As a result, the SD card is not detected, or the correct
mode is not selected.

Configure SDHCI PHY in the same way as in downstream, to ensure
that the PHY is initialized properly.

Fixes: eb36f28ff721 ("mmc: cv1800b: Add sdhci driver support for cv1800b SoC")
Signed-off-by: Andrei Lalaev <andrey.lalaev@gmail.com>
Link: https://lore.kernel.org/u-boot/20260822091510.3253162-1-andrey.lalaev@gmail.com/
---
 drivers/mmc/cv1800b_sdhci.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/mmc/cv1800b_sdhci.c b/drivers/mmc/cv1800b_sdhci.c
index b756649f90f3..5c129682daba 100644
--- a/drivers/mmc/cv1800b_sdhci.c
+++ b/drivers/mmc/cv1800b_sdhci.c
@@ -8,11 +8,17 @@
 #include <sdhci.h>
 #include <linux/delay.h>
 
+#define CV18XX_SDHCI_MSHC_CTRL  0x200
+#define CV18XX_SDHCI_PHY_CONFIG 0x24c
 #define SDHCI_PHY_TX_RX_DLY  0x240
 #define MMC_MAX_CLOCK        375000000
 #define TUNE_MAX_PHCODE      128
 
 #define PHY_TX_SRC_INVERT  BIT(8)
+#define PHY_RX_SRC_INVERT  BIT(24)
+
+#define CV18XX_LATANCY_1T BIT(1)
+#define CV18XX_PHY_TX_BPS BIT(0)
 
 struct cv1800b_sdhci_plat {
 	struct mmc_config cfg;
@@ -64,10 +70,29 @@ static int cv1800b_execute_tuning(struct mmc *mmc, u8 opcode)
 }
 #endif
 
+static int cv1800b_deferred_probe(struct sdhci_host *host)
+{
+	u32 val;
+
+	val = sdhci_readl(host, CV18XX_SDHCI_MSHC_CTRL);
+	val |= CV18XX_LATANCY_1T;
+	sdhci_writel(host, val, CV18XX_SDHCI_MSHC_CTRL);
+
+	val = sdhci_readl(host, CV18XX_SDHCI_PHY_CONFIG);
+	val |= CV18XX_PHY_TX_BPS;
+	sdhci_writel(host, val, CV18XX_SDHCI_PHY_CONFIG);
+
+	val = PHY_TX_SRC_INVERT | PHY_RX_SRC_INVERT;
+	sdhci_writel(host, val, SDHCI_PHY_TX_RX_DLY);
+
+	return 0;
+}
+
 const struct sdhci_ops cv1800b_sdhci_sd_ops = {
 #if CONFIG_IS_ENABLED(MMC_SUPPORTS_TUNING)
 	.platform_execute_tuning = cv1800b_execute_tuning,
 #endif
+	.deferred_probe = cv1800b_deferred_probe,
 };
 
 static int cv1800b_sdhci_bind(struct udevice *dev)

---
base-commit: 509312dc5386ff4c5adabf53a573abca0aac4ce5
change-id: 20260907-milkv-duo-sdhci-configure-aa9790c73d0b

Best regards,
--  
Andrei Lalaev <andrey.lalaev@gmail.com>


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

end of thread, other threads:[~2026-09-08 21:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-07 14:54 [PATCH] mmc: cv1800b_sdhci: configure SDHCI PHY Andrei Lalaev
2026-09-07 18:08 ` Yao Zi
2026-09-07 18:44   ` Andrei Lalaev
2026-09-08 15:27     ` Andrei Lalaev
2026-09-08 21:02       ` Yao Zi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.