Skip to contentSkip to conversation

mmc: sophgo: milkv_duo: Add SD card support for Milk-V Duo board

PATCH In review Kongyang Liu 2 participants 7 messages Mar 9, 2024 – Mar 12, 2024

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

v2 cover mmc: sophgo: milkv_duo: Add SD card support for Milk-V Duo board

This series add sdhci driver for cv1800b SoC and enable SD card support for Sophgo Milk-V Duo board.

Changes in v2:
- Refactored and simplified some of the code.
- Sync device tree with ptaches from Linux kernel

Kongyang Liu (3):
mmc: cv1800b: Add sdhci driver support for cv1800b SoC
riscv: dts: sophgo: Add clk node and sdhci node
configs: milkv_duo: Add SD card configs

 arch/riscv/dts/cv1800b-milkv-duo.dts |   8 ++
 arch/riscv/dts/cv1800b.dtsi          |   4 +
 arch/riscv/dts/cv18xx.dtsi           |  22 +++++
 configs/milkv_duo_defconfig          |  10 +++
 drivers/mmc/Kconfig                  |  13 +++
 drivers/mmc/Makefile                 |   1 +
 drivers/mmc/cv1800b_sdhci.c          | 116 +++++++++++++++++++++++++++
 7 files changed, 174 insertions(+)
 create mode 100644 drivers/mmc/cv1800b_sdhci.c
Signature · 1 line
2.41.0
#1 lore raw

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

Add sdhci driver for cv1800b SoC.

---

Changes in v2:
- Refactored and simplified some of the code.

 drivers/mmc/Kconfig         |  13 ++++
 drivers/mmc/Makefile        |   1 +
 drivers/mmc/cv1800b_sdhci.c | 116 ++++++++++++++++++++++++++++++++++++
 3 files changed, 130 insertions(+)
 create mode 100644 drivers/mmc/cv1800b_sdhci.c
drivers/mmc/Kconfig +13 -0
index cef05790dd..f7fe6d1042 100644
@@ -568,6 +568,19 @@ config MMC_SDHCI_CADENCE
 
 	  If unsure, say N.
 
+config MMC_SDHCI_CV1800B
+	bool "SDHCI support for the CV1800B SD/SDIO/eMMC controller"
+	depends on BLK && DM_MMC
+	depends on MMC_SDHCI
+	depends on OF_CONTROL
+	help
+	  This selects the CV1800B SD/SDIO/eMMC driver.
+
+	  If you have a controller with this interface,
+	  say Y here.
+
+	  If unsure, say N.
+
 config MMC_SDHCI_AM654
 	bool "SDHCI Controller on TI's Am654 devices"
 	depends on ARCH_K3
drivers/mmc/Makefile +1 -0
index e9cf1fcc64..3374321e29 100644
@@ -60,6 +60,7 @@ obj-$(CONFIG_MMC_SDHCI_ATMEL)		+= atmel_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_BCM2835)		+= bcm2835_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_BCMSTB)		+= bcmstb_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_CADENCE)		+= sdhci-cadence.o
+obj-$(CONFIG_MMC_SDHCI_CV1800B)		+= cv1800b_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_AM654)		+= am654_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_IPROC)		+= iproc_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_KONA)		+= kona_sdhci.o
drivers/mmc/cv1800b_sdhci.c new file +116 -0

116 lines not on this page · raw message

Signature · 1 line
2.41.0
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] mmc: cv1800b: Add sdhci driver support for cv1800b SoC

Quoted 5 lines · Kongyang Liu

Add sdhci driver for cv1800b SoC.

---

Quoted 8 lines

Changes in v2:
- Refactored and simplified some of the code.

 drivers/mmc/Kconfig         |  13 ++++
 drivers/mmc/Makefile        |   1 +
 drivers/mmc/cv1800b_sdhci.c | 116 ++++++++++++++++++++++++++++++++++++
 3 files changed, 130 insertions(+)
 create mode 100644 drivers/mmc/cv1800b_sdhci.c
#3 lore raw

PATCH v2 2/3 riscv: dts: sophgo: Add clk node and sdhci node

In reply to Kongyang Liu

Add clk node and sdhci node for cv18xx SoCs according to patches from Linux kernel.

clk: https://lore.kernel.org/all/IA1PR20MB4953F9AD6792013B54636F05BB4F2@IA1PR20MB4953.namprd20.prod.outlook.com/
sdhci: https://lore.kernel.org/all/[email protected]/

---

Changes in v2:
- Sync device tree with ptaches from Linux kernel

 arch/riscv/dts/cv1800b-milkv-duo.dts |  8 ++++++++
 arch/riscv/dts/cv1800b.dtsi          |  4 ++++
 arch/riscv/dts/cv18xx.dtsi           | 22 ++++++++++++++++++++++
 3 files changed, 34 insertions(+)
arch/riscv/dts/cv1800b-milkv-duo.dts +8 -0
index 3af9e34b3b..94e64ddce8 100644
@@ -33,6 +33,14 @@
 	clock-frequency = <25000000>;
 };
 
+&sdhci0 {
+	status = "okay";
+	bus-width = <4>;
+	no-1-8-v;
+	no-mmc;
+	no-sdio;
+};
+
 &uart0 {
 	status = "okay";
 };
arch/riscv/dts/cv1800b.dtsi +4 -0
index 165e9e320a..baf641829e 100644
@@ -16,3 +16,7 @@
 &clint {
 	compatible = "sophgo,cv1800b-clint", "thead,c900-clint";
 };
+
+&clk {
+	compatible = "sophgo,cv1800-clk";
+};
arch/riscv/dts/cv18xx.dtsi +22 -0
index 2d6f4a4b1e..ec99c4deeb 100644
@@ -45,6 +45,13 @@
 		#clock-cells = <0>;
 	};
 
+	sdhci_clk: sdhci-clock {
+		compatible = "fixed-clock";
+		clock-frequency = <375000000>;
+		clock-output-names = "sdhci_clk";
+		#clock-cells = <0>;
+	};
+
 	soc {
 		compatible = "simple-bus";
 		interrupt-parent = <&plic>;
@@ -53,6 +60,12 @@
 		dma-noncoherent;
 		ranges;
 
+		clk: clock-controller@3002000 {
+			reg = <0x03002000 0x1000>;
+			clocks = <&osc>;
+			#clock-cells = <1>;
+		};
+
 		gpio0: gpio@3020000 {
 			compatible = "snps,dw-apb-gpio";
 			reg = <0x3020000 0x1000>;
@@ -175,6 +188,15 @@
 			status = "disabled";
 		};
 
+		sdhci0: mmc@4310000 {
+			compatible = "sophgo,cv1800b-dwcmshc";
+			reg = <0x4310000 0x1000>;
+			interrupts = <36 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&sdhci_clk>;
+			clock-names = "core";
+			status = "disabled";
+		};
+
 		plic: interrupt-controller@70000000 {
 			reg = <0x70000000 0x4000000>;
 			interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>;
Signature · 1 line
2.41.0
Reviewed-by on v2 2/3
#4 lore raw

Re: [PATCH v2 2/3] riscv: dts: sophgo: Add clk node and sdhci node

Quoted 9 lines · Kongyang Liu

Add clk node and sdhci node for cv18xx SoCs according to patches from Linux kernel.

clk: https://lore.kernel.org/all/IA1PR20MB4953F9AD6792013B54636F05BB4F2@IA1PR20MB4953.namprd20.prod.outlook.com/
sdhci: https://lore.kernel.org/all/[email protected]/

---

Quoted 7 lines

Changes in v2:
- Sync device tree with ptaches from Linux kernel

 arch/riscv/dts/cv1800b-milkv-duo.dts |  8 ++++++++
 arch/riscv/dts/cv1800b.dtsi          |  4 ++++
 arch/riscv/dts/cv18xx.dtsi           | 22 ++++++++++++++++++++++
 3 files changed, 34 insertions(+)
#5 lore raw

PATCH v2 3/3 configs: milkv_duo: Add SD card configs

In reply to Kongyang Liu

Add configs related to sdhci and mmc for Sophgo Milk-V Duo board

---

(no changes since v1)

 configs/milkv_duo_defconfig | 10 ++++++++++
 1 file changed, 10 insertions(+)
configs/milkv_duo_defconfig +10 -0
index 548adf174c..e8413d7aa9 100644
@@ -17,6 +17,16 @@ CONFIG_SYS_CBSIZE=512
 CONFIG_SYS_PBSIZE=544
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="milkv_duo# "
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
 CONFIG_ENV_OVERWRITE=y
+CONFIG_MMC=y
+CONFIG_MMC_IO_VOLTAGE=y
+CONFIG_MMC_UHS_SUPPORT=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_ADMA=y
+CONFIG_MMC_SDHCI_CV1800B=y
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
Signature · 1 line
2.41.0