Skip to contentSkip to conversation

Add StarFive JH7110 PCIe drvier support

PATCH Superseded Minda Chen 1 participant 5 messages Feb 23, 2023

Subsystems (3)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Minda Chen

author
#0 lore raw

cover Add StarFive JH7110 PCIe drvier support

This patchset needs to apply after patchset in [1]. These PCIe series patches are based on the JH7110 RISC-V SoC and VisionFive V2 board.

The PCIe driver depends on gpio, pinctrl, clk and reset driver to do init. The PCIe dts configuation includes all these setting.

The PCIe drivers codes has been tested on the VisionFive V2 boards. The test devices includes M.2 NVMe SSD and Realtek 8169 Ethernet adapter.

Mason Huo (4):
starfive: pci: Add StarFive JH7110 pcie driver
clk: starfive: Add PCIe clocks for PCIe controller
configs: starfive-jh7110: Add support for PCIe host driver
riscv: dts: starfive: Enable PCIe host controller

The JH7110 minimal system patchset upstream is in progress. PCIe driver patches is based on this patchset.

The JH7110 minimal system patchset details are listed in [1].

[1] https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

For more JH7110 and visionFive v2 information and support, you can visit RVspace wiki[2].

[2] https://wiki.rvspace.org/

 arch/riscv/dts/jh7110.dtsi              |  79 ++++
 arch/riscv/dts/starfive_visionfive2.dts | 104 +++++
 configs/starfive_visionfive2_defconfig  |   9 +
 drivers/clk/starfive/clk-jh7110.c       |  27 ++
 drivers/pci/Kconfig                     |  11 +
 drivers/pci/Makefile                    |   1 +
 drivers/pci/pcie_starfive_jh7110.c      | 482 ++++++++++++++++++++++++
 7 files changed, 713 insertions(+)
 create mode 100644 drivers/pci/pcie_starfive_jh7110.c
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 2/4 clk: starfive: Add PCIe clocks for PCIe controller

From: Mason Huo <[email protected]>

Add the stg clocks for StarFive JH7110 PCIe controller.

---
 drivers/clk/starfive/clk-jh7110.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/clk/starfive/clk-jh7110.c +27 -0
index a904852cab..7cfed7b847 100644
@@ -305,6 +305,10 @@ static int jh7110_syscrg_init(struct udevice *dev)
 	clk_dm(JH7110_SYSCLK_AON_APB,
 	       starfive_clk_fix_factor(priv->reg,
 				       "aon_apb", "apb_bus_func", 1, 1));
+	clk_dm(JH7110_SYSCLK_NOCSTG_BUS,
+	       starfive_clk_divider(priv->reg,
+				    "nocstg_bus", "bus_root",
+				    OFFSET(JH7110_SYSCLK_NOCSTG_BUS), 3));
 	clk_dm(JH7110_SYSCLK_QSPI_AHB,
 	       starfive_clk_gate(priv->reg,
 				 "qspi_ahb", "ahb1",
@@ -342,6 +346,11 @@ static int jh7110_syscrg_init(struct udevice *dev)
 	       starfive_clk_divider(priv->reg,
 				    "usb_125m", "gmacusb_root",
 				    OFFSET(JH7110_SYSCLK_USB_125M), 4));
+	clk_dm(JH7110_SYSCLK_NOC_BUS_STG_AXI,
+	       starfive_clk_gate(priv->reg,
+				 "noc_bus_stg_axi",
+				 "nocstg_bus",
+				  OFFSET(JH7110_SYSCLK_NOC_BUS_STG_AXI)));
 	clk_dm(JH7110_SYSCLK_GMAC1_AHB,
 	       starfive_clk_gate(priv->reg,
 				 "gmac1_ahb", "ahb0",
@@ -512,6 +521,24 @@ static int jh7110_stgcrg_init(struct udevice *dev)
 	clk_dm(JH7110_STGCLK_USB_REFCLK,
 	       starfive_clk_divider(priv->reg, "usb_refclk", "osc",
 				    STGOFFSET(JH7110_STGCLK_USB_REFCLK), 2));
+	clk_dm(JH7110_STGCLK_PCIE0_TL,
+	       starfive_clk_gate(priv->reg, "pcie0_tl", "stg_axiahb",
+				 STGOFFSET(JH7110_STGCLK_PCIE0_TL)));
+	clk_dm(JH7110_STGCLK_PCIE0_AXI,
+	       starfive_clk_gate(priv->reg, "pcie0_axi_mst0", "stg_axiahb",
+				 STGOFFSET(JH7110_STGCLK_PCIE0_AXI)));
+	clk_dm(JH7110_STGCLK_PCIE0_APB,
+	       starfive_clk_gate(priv->reg, "pcie0_apb", "stg_apb",
+				 STGOFFSET(JH7110_STGCLK_PCIE0_APB)));
+	clk_dm(JH7110_STGCLK_PCIE1_TL,
+	       starfive_clk_gate(priv->reg, "pcie1_tl", "stg_axiahb",
+				 STGOFFSET(JH7110_STGCLK_PCIE1_TL)));
+	clk_dm(JH7110_STGCLK_PCIE1_AXI,
+	       starfive_clk_gate(priv->reg, "pcie1_axi_mst0", "stg_axiahb",
+				 STGOFFSET(JH7110_STGCLK_PCIE1_AXI)));
+	clk_dm(JH7110_STGCLK_PCIE1_APB,
+	       starfive_clk_gate(priv->reg, "pcie1_apb", "stg_apb",
+				 STGOFFSET(JH7110_STGCLK_PCIE1_APB)));
 	return 0;
 }
 
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/4 starfive: pci: Add StarFive JH7110 pcie driver

In reply to Minda Chen

From: Mason Huo <[email protected]>

Add pcie driver for StarFive JH7110, the driver depends on starfive gpio, pinctrl, clk and reset driver to do init.

Several devices are tested:
a) M.2 NVMe SSD
b) Realtek 8169 Ethernet adapter.

---
 drivers/pci/Kconfig                |  11 +
 drivers/pci/Makefile               |   1 +
 drivers/pci/pcie_starfive_jh7110.c | 482 +++++++++++++++++++++++++++++
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/pci/pcie_starfive_jh7110.c
drivers/pci/Kconfig +11 -0
index a3b662fb13..da9290204b 100644
@@ -365,4 +365,15 @@ config PCIE_UNIPHIER
 	  Say Y here if you want to enable PCIe controller support on
 	  UniPhier SoCs.
 
+config PCIE_STARFIVE_JH7110
+	bool "Enable Starfive JH7110 PCIe driver"
+	depends on STARFIVE_JH7110
+	depends on PINCTRL_STARFIVE_JH7110
+	depends on CLK_JH7110
+	depends on RESET_JH7110
+	default y
+	help
+	  Say Y here if you want to enable PCIe controller support on
+	  StarFive JH7110 SoC.
+
 endif
drivers/pci/Makefile +1 -0
index dd1ad91ced..92a92409ab 100644
@@ -49,3 +49,4 @@ obj-$(CONFIG_PCI_OCTEONTX) += pci_octeontx.o
 obj-$(CONFIG_PCIE_OCTEON) += pcie_octeon.o
 obj-$(CONFIG_PCIE_DW_SIFIVE) += pcie_dw_sifive.o
 obj-$(CONFIG_PCIE_UNIPHIER) += pcie_uniphier.o
+obj-$(CONFIG_PCIE_STARFIVE_JH7110) += pcie_starfive_jh7110.o
drivers/pci/pcie_starfive_jh7110.c new file +482 -0

482 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#4 lore raw

PATCH 4/4 riscv: dts: starfive: Enable PCIe host controller

In reply to Minda Chen

From: Mason Huo <[email protected]>

Enable and add pinctrl configuration for PCIe host controller. Also add JH7110 stg syscon configuration.

---
 arch/riscv/dts/jh7110.dtsi              |  79 ++++++++++++++++++
 arch/riscv/dts/starfive_visionfive2.dts | 104 ++++++++++++++++++++++++
 2 files changed, 183 insertions(+)
arch/riscv/dts/jh7110.dtsi +79 -0
index 49d34b85af..6f37d107e3 100644
@@ -493,5 +493,84 @@
 			#address-cells = <1>;
 			#size-cells = <0>;
 		};
+
+		pcie0: pcie@2B000000 {
+			compatible = "starfive,jh7110-pcie";
+			#address-cells = <3>;
+			#size-cells = <2>;
+			#interrupt-cells = <1>;
+			reg = <0x0 0x2B000000 0x0 0x1000000>,
+			      <0x9 0x40000000 0x0 0x10000000>;
+			reg-names = "reg", "config";
+			device_type = "pci";
+			starfive,stg-syscon = <&stg_syscon 0xc0 0xc4 0x130>;
+			bus-range = <0x0 0xff>;
+			ranges = <0x82000000  0x0 0x30000000  0x0 0x30000000 0x0 0x08000000>,
+				<0xc3000000  0x9 0x00000000  0x9 0x00000000 0x0 0x40000000>;
+			msi-parent = <&plic>;
+			interrupts = <56>;
+			interrupt-controller;
+			interrupt-names = "msi";
+			interrupt-parent = <&plic>;
+			interrupt-map-mask = <0x0 0x0 0x0 0x7>;
+			interrupt-map = <0x0 0x0 0x0 0x1 &plic 0x1>,
+					<0x0 0x0 0x0 0x2 &plic 0x2>,
+					<0x0 0x0 0x0 0x3 &plic 0x3>,
+					<0x0 0x0 0x0 0x4 &plic 0x4>;
+			resets = <&stgcrg JH7110_STGRST_PCIE0_MST0>,
+				 <&stgcrg JH7110_STGRST_PCIE0_SLV0>,
+				 <&stgcrg JH7110_STGRST_PCIE0_SLV>,
+				 <&stgcrg JH7110_STGRST_PCIE0_BRG>,
+				 <&stgcrg JH7110_STGRST_PCIE0_CORE>,
+				 <&stgcrg JH7110_STGRST_PCIE0_APB>;
+			reset-names = "rst_mst0", "rst_slv0", "rst_slv",
+				      "rst_brg", "rst_core", "rst_apb";
+			clocks = <&syscrg JH7110_SYSCLK_NOC_BUS_STG_AXI>,
+				 <&stgcrg JH7110_STGCLK_PCIE0_TL>,
+				 <&stgcrg JH7110_STGCLK_PCIE0_AXI>,
+				 <&stgcrg JH7110_STGCLK_PCIE0_APB>;
+			clock-names = "noc", "tl", "axi_mst0", "apb";
+			status = "disabled";
+		};
+
+		pcie1: pcie@2C000000 {
+			compatible = "starfive,jh7110-pcie";
+			#address-cells = <3>;
+			#size-cells = <2>;
+			#interrupt-cells = <1>;
+			reg = <0x0 0x2C000000 0x0 0x1000000>,
+			      <0x9 0xc0000000 0x0 0x10000000>;
+			reg-names = "reg", "config";
+			device_type = "pci";
+			starfive,stg-syscon = <&stg_syscon 0x270 0x274 0x2e0>;
+			bus-range = <0x0 0xff>;
+			ranges = <0x82000000  0x0 0x38000000  0x0 0x38000000 0x0 0x08000000>,
+				<0xc3000000  0x9 0x80000000  0x9 0x80000000 0x0 0x40000000>;
+			msi-parent = <&plic>;
+			interrupts = <57>;
+			interrupt-controller;
+			interrupt-names = "msi";
+			interrupt-parent = <&plic>;
+			interrupt-map-mask = <0x0 0x0 0x0 0x7>;
+			interrupt-map = <0x0 0x0 0x0 0x1 &plic 0x1>,
+					<0x0 0x0 0x0 0x2 &plic 0x2>,
+					<0x0 0x0 0x0 0x3 &plic 0x3>,
+					<0x0 0x0 0x0 0x4 &plic 0x4>;
+			resets = <&stgcrg JH7110_STGRST_PCIE1_MST0>,
+				 <&stgcrg JH7110_STGRST_PCIE1_SLV0>,
+				 <&stgcrg JH7110_STGRST_PCIE1_SLV>,
+				 <&stgcrg JH7110_STGRST_PCIE1_BRG>,
+				 <&stgcrg JH7110_STGRST_PCIE1_CORE>,
+				 <&stgcrg JH7110_STGRST_PCIE1_APB>;
+			reset-names = "rst_mst0", "rst_slv0", "rst_slv",
+				      "rst_brg", "rst_core", "rst_apb";
+			clocks = <&syscrg JH7110_SYSCLK_NOC_BUS_STG_AXI>,
+				 <&stgcrg JH7110_STGCLK_PCIE1_TL>,
+				 <&stgcrg JH7110_STGCLK_PCIE1_AXI>,
+				 <&stgcrg JH7110_STGCLK_PCIE1_APB>;
+			clock-names = "noc", "tl", "axi_mst0", "apb";
+			status = "disabled";
+		};
+
 	};
 };
arch/riscv/dts/starfive_visionfive2.dts +104 -0

122 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#3 lore raw

PATCH 3/4 configs: starfive-jh7110: Add support for PCIe host driver

In reply to Minda Chen

From: Mason Huo <[email protected]>

also add the nvme driver and rtl8169 support.

---
 configs/starfive_visionfive2_defconfig | 9 +++++++++
 1 file changed, 9 insertions(+)
configs/starfive_visionfive2_defconfig +9 -0
index 54ae6b2a43..8e38201858 100644
@@ -11,6 +11,7 @@ CONFIG_SPL=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 CONFIG_SYS_LOAD_ADDR=0x82000000
+CONFIG_SYS_PCI_64BIT=y
 CONFIG_TARGET_STARFIVE_VISIONFIVE2=y
 CONFIG_SPL_OPENSBI_LOAD_ADDR=0x40000000
 CONFIG_ARCH_RV64I=y
@@ -45,8 +46,11 @@ CONFIG_SYS_CBSIZE=256
 CONFIG_SYS_PBSIZE=276
 CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_PCI=y
 CONFIG_CMD_TFTPPUT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_REGMAP=y
+CONFIG_SYSCON=y
 CONFIG_SPL_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_CCF=y
 CONFIG_CLK_COMPOSITE_CCF=y
@@ -61,6 +65,11 @@ CONFIG_SPI_FLASH_EON=y
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_ISSI=y
 CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_RTL8169=y
+CONFIG_NVME_PCI=y
+CONFIG_PCI=y
+CONFIG_DM_PCI_COMPAT=y
+CONFIG_PCI_REGION_MULTI_ENTRY=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
 CONFIG_PINCTRL_STARFIVE=y
Signature · 1 line
2.17.1