Skip to contentSkip to conversation

mmc: Add quirk to disable PWREN for dw_mmc

PATCH In review David Hewitt 2 participants 2 messages Jul 10, 2023 – Oct 31, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 mmc: Add quirk to disable PWREN for dw_mmc

This is required for correct booting of the PINE64 PineTab2. If PWREN is pulled high on this device, the SD card cannot be detected.

This is required in other PINE64 devices (e.g. Quartz64 Model A) too.

See commit ba33172a36f298641f51a5e6b855c3e89e3f5d3e in
https://github.com/CounterPillow/u-boot-quartz64

Cc Simon Glass <[email protected]>
Cc Philipp Tomsich <[email protected]>
Cc Kever Yang <[email protected]>
Cc Peng Fan <[email protected]>
Cc Jaehoon Chung <[email protected]>

---
Changes for v2:
- Removed an unrelated change

 drivers/mmc/dw_mmc.c          | 3 ++-
 drivers/mmc/rockchip_dw_mmc.c | 3 +++
 include/dwmmc.h               | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/mmc/dw_mmc.c +2 -1
index 5085a3b491..cb1d99132f 100644
@@ -530,7 +530,8 @@ static int dwmci_init(struct mmc *mmc)
 	if (host->board_init)
 		host->board_init(host);
 
-	dwmci_writel(host, DWMCI_PWREN, 1);
+	if (!(host->quirks & DWMCI_QUIRK_DISABLE_PWREN))
+		dwmci_writel(host, DWMCI_PWREN, 1);
 
 	if (!dwmci_wait_reset(host, DWMCI_RESET_ALL)) {
 		debug("%s[%d] Fail-reset!!\n", __func__, __LINE__);
drivers/mmc/rockchip_dw_mmc.c +3 -0
index 72c820ee63..af6ac59a46 100644
@@ -78,6 +78,9 @@ static int rockchip_dwmmc_of_to_plat(struct udevice *dev)
 	else
 		host->dev_index = 1;
 
+	if (dev_read_bool(dev, "rockchip,disable-pwren-quirk"))
+		host->quirks |= DWMCI_QUIRK_DISABLE_PWREN;
+
 	priv->fifo_depth = dev_read_u32_default(dev, "fifo-depth", 0);
 
 	if (priv->fifo_depth < 0)
include/dwmmc.h +1 -0
index 136a95b8cd..98aebb46f1 100644
@@ -141,6 +141,7 @@
 
 /* quirks */
 #define DWMCI_QUIRK_DISABLE_SMU		(1 << 0)
+#define DWMCI_QUIRK_DISABLE_PWREN	(1 << 1)
 
 /**
  * struct dwmci_host - Information about a designware MMC host
Signature · 1 line
2.34.1
Reviewed-by on v2 2/2
#1 lore raw
Quoted 8 lines · David Hewitt

This is required for correct booting of the PINE64 PineTab2. If PWREN is pulled high on this device, the SD card cannot be detected.

This is required in other PINE64 devices (e.g. Quartz64 Model A) too.

See commit ba33172a36f298641f51a5e6b855c3e89e3f5d3e in
https://github.com/CounterPillow/u-boot-quartz64

Quoted 6 lines
Cc Simon Glass <[email protected]>
Cc Philipp Tomsich <[email protected]>
Cc Kever Yang <[email protected]>
Cc Peng Fan <[email protected]>
Cc Jaehoon Chung <[email protected]>

Best Regards,
Jaehoon Chung

Quoted 49 lines

---
Changes for v2:
- Removed an unrelated change

 drivers/mmc/dw_mmc.c          | 3 ++-
 drivers/mmc/rockchip_dw_mmc.c | 3 +++
 include/dwmmc.h               | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/mmc/dw_mmc.c +2 -1
index 5085a3b491..cb1d99132f 100644
@@ -530,7 +530,8 @@ static int dwmci_init(struct mmc *mmc)
 	if (host->board_init)
 		host->board_init(host);
 
-	dwmci_writel(host, DWMCI_PWREN, 1);
+	if (!(host->quirks & DWMCI_QUIRK_DISABLE_PWREN))
+		dwmci_writel(host, DWMCI_PWREN, 1);
 
 	if (!dwmci_wait_reset(host, DWMCI_RESET_ALL)) {
 		debug("%s[%d] Fail-reset!!\n", __func__, __LINE__);
drivers/mmc/rockchip_dw_mmc.c +3 -0
index 72c820ee63..af6ac59a46 100644
@@ -78,6 +78,9 @@ static int rockchip_dwmmc_of_to_plat(struct udevice *dev)
 	else
 		host->dev_index = 1;
 
+	if (dev_read_bool(dev, "rockchip,disable-pwren-quirk"))
+		host->quirks |= DWMCI_QUIRK_DISABLE_PWREN;
+
 	priv->fifo_depth = dev_read_u32_default(dev, "fifo-depth", 0);
 
 	if (priv->fifo_depth < 0)
include/dwmmc.h +1 -0
index 136a95b8cd..98aebb46f1 100644
@@ -141,6 +141,7 @@
 
 /* quirks */
 #define DWMCI_QUIRK_DISABLE_SMU		(1 << 0)
+#define DWMCI_QUIRK_DISABLE_PWREN	(1 << 1)
 
 /**
  * struct dwmci_host - Information about a designware MMC host