Skip to contentSkip to conversation

mmc: snps_sdhci: Add sdhci driver support for TH1520 SoC

PATCH New [email protected] 1 participant 3 messages Dec 11, 2024

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

PATCH v2 1/3 mmc: snps_sdhci: Add sdhci driver support for TH1520 SoC

From: Maksim Kiselev <[email protected]>

Add support for DesignWare SDHCI host controller on Alibaba TH1520 SoC

---
Changes for v2:
- re-use phy init code
- drop CONFIG_ prefix from CONFIG_MMC_SDHCI_ADMA_HELPERS
- rework clock handling

 drivers/mmc/Kconfig      |  12 ++
 drivers/mmc/Makefile     |   1 +
 drivers/mmc/snps_sdhci.c | 444 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 457 insertions(+)
 create mode 100644 drivers/mmc/snps_sdhci.c
drivers/mmc/Kconfig +12 -0
index 38817622fc..f4fdf15242 100644
@@ -732,6 +732,18 @@ config MMC_SDHCI_S5P
 
 	  If unsure, say N.
 
+config MMC_SDHCI_SNPS
+	bool "Synopsys DesignWare SDHCI controller"
+	depends on MMC_SDHCI
+	depends on DM_MMC
+	help
+	  Support for DesignWare SDHCI host controller on Alibaba TH1520 SoC.
+	  This is a highly configurable and programmable, high performance
+	  Mobile Storage Host Controller (MSHC) with AXI as the bus interface
+	  for data transfer.
+
+	  If unsure, say N.
+
 config MMC_SDHCI_STI
 	bool "SDHCI support for STMicroelectronics SoC"
 	depends on MMC_SDHCI && OF_CONTROL
drivers/mmc/Makefile +1 -0
index 868f3090ff..90e76f9076 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_MMC_SDHCI_NPCM)            += npcm_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_PIC32)		+= pic32_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_ROCKCHIP)	+= rockchip_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_S5P)		+= s5p_sdhci.o
+obj-$(CONFIG_MMC_SDHCI_SNPS)		+= snps_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_STI)		+= sti_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_TANGIER)		+= tangier_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_TEGRA)		+= tegra_mmc.o
drivers/mmc/snps_sdhci.c new file +444 -0

444 lines not on this page · raw message

Signature · 1 line
2.45.2
#1 lore raw

PATCH v2 2/3 riscv: dts: t-head: Add sdhci and emmc nodes

From: Maksim Kiselev <[email protected]>

Add SDHCI and EMMC controlles nodes on TH-1520 SoC. And enable them for Lichee module 4A.

---
 arch/riscv/dts/th1520-lichee-module-4a.dtsi | 18 +++++++++++
 arch/riscv/dts/th1520.dtsi                  | 34 +++++++++++++++++++++
 2 files changed, 52 insertions(+)
arch/riscv/dts/th1520-lichee-module-4a.dtsi +18 -0
index dc00e3dfa0..86a81bdcf7 100644
@@ -32,3 +32,21 @@
 &uart_sclk {
 	clock-frequency = <100000000>;
 };
+
+&emmc {
+	bus-width = <8>;
+	max-frequency = <198000000>;
+	mmc-ddr-1_8v;
+	mmc-hs400-1_8v;
+	mmc-hs400-enhanced-strobe;
+	non-removable;
+	no-sdio;
+	no-sd;
+	status = "okay";
+};
+
+&sdio0 {
+	bus-width = <4>;
+	max-frequency = <198000000>;
+	status = "okay";
+};
arch/riscv/dts/th1520.dtsi +34 -0
index d68c446a6b..9378de89c5 100644
@@ -141,6 +141,13 @@
 		#clock-cells = <0>;
 	};
 
+	sdhci_clk: sdhci-clock {
+		compatible = "fixed-clock";
+		clock-frequency = <198000000>;
+		clock-output-names = "sdhci_clk";
+		#clock-cells = <0>;
+	};
+
 	soc {
 		compatible = "simple-bus";
 		interrupt-parent = <&plic>;
@@ -206,6 +213,33 @@
 			status = "disabled";
 		};
 
+		emmc: mmc@ffe7080000 {
+			compatible = "thead,th1520-dwcmshc";
+			reg = <0xff 0xe7080000 0x0 0x10000>;
+			interrupts = <62 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&sdhci_clk>;
+			clock-names = "core";
+			status = "disabled";
+		};
+
+		sdio0: mmc@ffe7090000 {
+			compatible = "thead,th1520-dwcmshc";
+			reg = <0xff 0xe7090000 0x0 0x10000>;
+			interrupts = <64 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&sdhci_clk>;
+			clock-names = "core";
+			status = "disabled";
+		};
+
+		sdio1: mmc@ffe70a0000 {
+			compatible = "thead,th1520-dwcmshc";
+			reg = <0xff 0xe70a0000 0x0 0x10000>;
+			interrupts = <71 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&sdhci_clk>;
+			clock-names = "core";
+			status = "disabled";
+		};
+
 		uart1: serial@ffe7f00000 {
 			compatible = "snps,dw-apb-uart";
 			reg = <0xff 0xe7f00000 0x0 0x100>;
Signature · 1 line
2.45.2
#2 lore raw

PATCH v2 3/3 configs: th1520_lpi4a: enable mmc controller support

In reply to [email protected]

From: Maksim Kiselev <[email protected]>

Enable driver for DesignWare MSHC. TH1520 supports all speed modes up to HS400ES and UHS SDR105.

Also enable ADMA and mmc command.

---
 configs/th1520_lpi4a_defconfig | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
configs/th1520_lpi4a_defconfig +10 -1
index 3b6ff62ee1..d13c97463a 100644
@@ -54,6 +54,8 @@ CONFIG_CMD_BOOTMENU=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_MMC_SPEED_MODE_SET=y
 # CONFIG_CMD_ITEST is not set
 # CONFIG_CMD_SOURCE is not set
 # CONFIG_CMD_SETEXPR is not set
@@ -66,7 +68,14 @@ CONFIG_NO_NET=y
 CONFIG_DWAPB_GPIO=y
 # CONFIG_I2C is not set
 # CONFIG_INPUT is not set
-# CONFIG_DM_MMC is not set
+CONFIG_MMC=y
+CONFIG_MMC_IO_VOLTAGE=y
+CONFIG_MMC_UHS_SUPPORT=y
+CONFIG_MMC_HS400_ES_SUPPORT=y
+CONFIG_MMC_HS400_SUPPORT=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_ADMA=y
+CONFIG_MMC_SDHCI_SNPS=y
 # CONFIG_MTD is not set
 # CONFIG_POWER is not set
 CONFIG_SYS_NS16550=y
Signature · 1 line
2.45.2