Skip to contentSkip to conversation

Add StarFive JH7110 PCIe drvier support

PATCH Superseded Minda Chen 3 participants 10 messages Jul 20, 2023 – Jul 25, 2023

Subsystems (3)
lore
Share & tools
lore

Minda Chen

author
#0 lore raw

v7 cover Add StarFive JH7110 PCIe drvier support

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.

patch1 is for fixing the compile error in designware_i2c_pci.c while enable designware i2c and PCI.

previous patch version

v1: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v2: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v3: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v4: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v5: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v6: https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

changes
v7
Add patch1 to fix compiling error while enable PCI. patch 2 and patch 3 rebase to latest mainline codes.

v6
patch 3
1. Change one VisionFive2 config file.
patch 4
1. remove the pcie interrupt-controller. interrupts setting revert to origin.

setting.
v5
patch 2
1. split PLDA controller driver codes to pcie_plda_common.c
2. correct the codes of record secondary number.
patch 4
1. change the pcie dtsi config. make them the same with kernel.

v4
patch 2
1. Remove the IDS_REVISION_ID macros.
2. Replace sec_busno to first_busno in starfive_pcie
3. Remove starfive_pcie_off_conf function.
4. Replace "imply" to "depends on" in PCIe Kconfig. 5 .Check sec_busno in starfive_pcie_addr_valid.

v3
patch 2
1. remove the read vendor ID delay
2. remove starfive_pcie_hide_rc_bar function. do not hide host
bridge BAR write.
3. Using PCIE_ECAM_OFFSET and PCI_CLASS_BRIDGE_PCI_NORMAL macros.
4. Add comments for bus and address limitation reason in function starfive_pcie_addr_valid
5. Change the multiple line comments in Line 373
6. Using gpio_request_by_name to get PCIe reset gpio,and using dm_gpio_set_value set GPIO value.
patch 3
1. support PCIeboth 12a and 13b vf2 board.
patch 4
1. reset dts change to reset-gpio.

v2
1. remove clock commit. The pcie clocks change has been includeded in [1].
2. Using GENMASK marco1 in patch1.
3. remove the syscon dts node in patch3. The syscon dts dts node has been included in [1].

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

Minda Chen (1):
i2c: designware: Add CONFIG_ACPIGEN limitation to designware_i2c_pci.c

 .../dts/jh7110-starfive-visionfive-2.dtsi     |  11 +
 arch/riscv/dts/jh7110.dtsi                    |  74 ++++
 configs/starfive_visionfive2_defconfig        |   8 +
 drivers/i2c/Makefile                          |   2 +
 drivers/pci/Kconfig                           |  13 +
 drivers/pci/Makefile                          |   2 +
 drivers/pci/pcie_plda_common.c                | 116 +++++++
 drivers/pci/pcie_plda_common.h                | 118 +++++++
 drivers/pci/pcie_starfive_jh7110.c            | 317 ++++++++++++++++++
 9 files changed, 661 insertions(+)
 create mode 100644 drivers/pci/pcie_plda_common.c
 create mode 100644 drivers/pci/pcie_plda_common.h
 create mode 100644 drivers/pci/pcie_starfive_jh7110.c

base-commit: e6e67bb9e0a40f3eb3c87d16935192821987c3e0

Signature · 1 line
2.17.1
author
#6 lore raw

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

From: Mason Huo <[email protected]>

Add PCIe host driver and nvme driver in configure file.

---
 configs/starfive_visionfive2_defconfig | 8 ++++++++
 1 file changed, 8 insertions(+)
configs/starfive_visionfive2_defconfig +8 -0
index 570a1f53a1..59e39c6f9b 100644
@@ -19,6 +19,8 @@ CONFIG_SPL=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 CONFIG_SYS_LOAD_ADDR=0x82000000
+CONFIG_SYS_PCI_64BIT=y
+CONFIG_PCI=y
 CONFIG_TARGET_STARFIVE_VISIONFIVE2=y
 CONFIG_SPL_OPENSBI_LOAD_ADDR=0x40000000
 CONFIG_ARCH_RV64I=y
@@ -62,6 +64,7 @@ CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=4
 CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=5
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_PCI=y
 CONFIG_CMD_TFTPPUT=y
 CONFIG_OF_BOARD=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
@@ -92,6 +95,11 @@ CONFIG_DWC_ETH_QOS=y
 CONFIG_DWC_ETH_QOS_STARFIVE=y
 CONFIG_RGMII=y
 CONFIG_RMII=y
+CONFIG_NVME_PCI=y
+CONFIG_DM_PCI_COMPAT=y
+# CONFIG_PCI_PNP is not set
+CONFIG_PCI_REGION_MULTI_ENTRY=y
+CONFIG_PCIE_STARFIVE_JH7110=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
 CONFIG_SPL_PINCTRL=y
Signature · 1 line
2.17.1
author
#8 lore raw

PATCH v7 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.

---
 .../dts/jh7110-starfive-visionfive-2.dtsi     | 11 +++
 arch/riscv/dts/jh7110.dtsi                    | 74 +++++++++++++++++++
 2 files changed, 85 insertions(+)
arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi +11 -0
index 710b082766..54a147c7d0 100644
@@ -7,6 +7,7 @@
 
 #include "jh7110.dtsi"
 #include <dt-bindings/pinctrl/pinctrl-starfive-jh7110.h>
+#include <dt-bindings/gpio/gpio.h>
 / {
 	aliases {
 		serial0 = &uart0;
@@ -308,6 +309,16 @@
 	};
 };
 
+&pcie0 {
+	reset-gpios = <&sysgpio 26 GPIO_ACTIVE_LOW>;
+	status = "disabled";
+};
+
+&pcie1 {
+	reset-gpios = <&sysgpio 28 GPIO_ACTIVE_LOW>;
+	status = "okay";
+};
+
 &syscrg {
 	assigned-clocks = <&syscrg JH7110_SYSCLK_CPU_ROOT>,
 			  <&syscrg JH7110_SYSCLK_BUS_ROOT>,
arch/riscv/dts/jh7110.dtsi +74 -0

79 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v7 1/4 i2c: designware: Add CONFIG_ACPIGEN limitation to designware_i2c_pci.c

In reply to Minda Chen

As the designware_i2c_pci.c uses ACPI APIs, If some SoCs (StarFive JH7110) contain designware i2c and PCI but do not use ACPI, This file will be can't be compiled. So add ACPIGEN to designware_i2c_pci.c

---
 drivers/i2c/Makefile | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/Makefile +2 -0
index 99545df2e5..92b1ec6bc3 100644
@@ -18,9 +18,11 @@ obj-$(CONFIG_SYS_I2C_CADENCE) += i2c-cdns.o
 obj-$(CONFIG_SYS_I2C_CA) += i2c-cortina.o
 obj-$(CONFIG_SYS_I2C_DAVINCI) += davinci_i2c.o
 obj-$(CONFIG_SYS_I2C_DW) += designware_i2c.o
+ifdef CONFIG_ACPIGEN
 ifdef CONFIG_PCI
 obj-$(CONFIG_SYS_I2C_DW) += designware_i2c_pci.o
 endif
+endif
 obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
 obj-$(CONFIG_SYS_I2C_IHS) += ihs_i2c.o
 obj-$(CONFIG_SYS_I2C_INTEL) += intel_i2c.o
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v7 2/4 starfive: pci: Add StarFive JH7110 pcie driver

In reply to Minda Chen

From: Mason Huo <[email protected]>

Add pcie driver for StarFive JH7110, Also add PLDA PCIe controller common driver functions.

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

---
 drivers/pci/Kconfig                |  13 ++
 drivers/pci/Makefile               |   2 +
 drivers/pci/pcie_plda_common.c     | 116 +++++++++++
 drivers/pci/pcie_plda_common.h     | 118 +++++++++++
 drivers/pci/pcie_starfive_jh7110.c | 317 +++++++++++++++++++++++++++++
 5 files changed, 566 insertions(+)
 create mode 100644 drivers/pci/pcie_plda_common.c
 create mode 100644 drivers/pci/pcie_plda_common.h
 create mode 100644 drivers/pci/pcie_starfive_jh7110.c
drivers/pci/Kconfig +13 -0
index 84a2ae951f..fa21d60ce9 100644
@@ -387,4 +387,17 @@ config PCIE_XILINX_NWL
 	 Say 'Y' here if you want support for Xilinx / AMD NWL PCIe
 	 controller as Root Port.
 
+config PCIE_PLDA_COMMON
+	bool
+
+config PCIE_STARFIVE_JH7110
+	bool "Enable Starfive JH7110 PCIe driver"
+	select PCIE_PLDA_COMMON
+	imply STARFIVE_JH7110
+	imply CLK_JH7110
+	imply RESET_JH7110
+	help
+	  Say Y here if you want to enable PLDA XpressRich PCIe controller
+	  support on StarFive JH7110 SoC.
+
 endif
drivers/pci/Makefile +2 -0
index 11f60c6991..a712a317a3 100644
@@ -50,3 +50,5 @@ 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_XILINX_NWL) += pcie-xilinx-nwl.o
+obj-$(CONFIG_PCIE_PLDA_COMMON) += pcie_plda_common.o
+obj-$(CONFIG_PCIE_STARFIVE_JH7110) += pcie_starfive_jh7110.o
drivers/pci/pcie_plda_common.c new file +116 -0

116 lines not on this page · raw message

drivers/pci/pcie_plda_common.h new file +118 -0

118 lines not on this page · raw message

drivers/pci/pcie_starfive_jh7110.c new file +317 -0

317 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v7 1/4] i2c: designware: Add CONFIG_ACPIGEN limitation to designware_i2c_pci.c

In reply to Minda Chen

Hi,

Quoted 16 lines · Minda Chen

As the designware_i2c_pci.c uses ACPI APIs, If some SoCs (StarFive JH7110) contain designware i2c and PCI but do not use ACPI, This file will be can't be compiled. So add ACPIGEN to designware_i2c_pci.c

---
 drivers/i2c/Makefile | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/Makefile +0 -0
index 99545df2e5..92b1ec6bc3 100644

drivers/i2c/Makefile obj-$(CONFIG_SYS_I2C_CADENCE) += i2c-cdns.o · line 21

Quoted 4 lines
drivers/i2c/Makefile +1 -0
@@ -18,9 +18,11 @@ obj-$(CONFIG_SYS_I2C_CADENCE) += i2c-cdns.o
 obj-$(CONFIG_SYS_I2C_CA) += i2c-cortina.o
 obj-$(CONFIG_SYS_I2C_DAVINCI) += davinci_i2c.o
 obj-$(CONFIG_SYS_I2C_DW) += designware_i2c.o
+ifdef CONFIG_ACPIGEN

You should use Kconfig to see SYS_I2C_DW depends on ACPIGEN. You might need a separate I2C_DW_PCI Kconfig.

But that sounds bad to me. Why does it have to generate ACPI tables? It should work fine without that.

Quoted 10 lines
drivers/i2c/Makefile +1 -1
 ifdef CONFIG_PCI
 obj-$(CONFIG_SYS_I2C_DW) += designware_i2c_pci.o
 endif
+endif
 obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
 obj-$(CONFIG_SYS_I2C_IHS) += ihs_i2c.o
 obj-$(CONFIG_SYS_I2C_INTEL) += intel_i2c.o
--

2.17.1

Regards,
Simon

author
#3 lore raw

Re: [PATCH v7 1/4] i2c: designware: Add CONFIG_ACPIGEN limitation to designware_i2c_pci.c

Quoted 14 lines · Simon Glass

Hi,

Quoted 11 lines · Minda Chen

As the designware_i2c_pci.c uses ACPI APIs, If some SoCs (StarFive JH7110) contain designware i2c and PCI but do not use ACPI, This file will be can't be compiled. So add ACPIGEN to designware_i2c_pci.c

---
 drivers/i2c/Makefile | 2 ++
 1 file changed, 2 insertions(+)
Quoted 13 lines

drivers/i2c/Makefile obj-$(CONFIG_SYS_I2C_CADENCE) += i2c-cdns.o · line 21

Quoted 9 lines
drivers/i2c/Makefile +1 -0
index 99545df2e5..92b1ec6bc3 100644
@@ -18,9 +18,11 @@ obj-$(CONFIG_SYS_I2C_CADENCE) += i2c-cdns.o
 obj-$(CONFIG_SYS_I2C_CA) += i2c-cortina.o
 obj-$(CONFIG_SYS_I2C_DAVINCI) += davinci_i2c.o
 obj-$(CONFIG_SYS_I2C_DW) += designware_i2c.o
+ifdef CONFIG_ACPIGEN

You should use Kconfig to see SYS_I2C_DW depends on ACPIGEN. You might need a separate I2C_DW_PCI Kconfig.

I think so.

I can add Kconfig like this.
config SYS_I2C_DW_PCI
bool "Designware PCI I2C Controller"
depends on SYS_I2C_DW && PCI && APIGEN
default y

Quoted 3 lines

But that sounds bad to me. Why does it have to generate ACPI tables? It should work fine without that.

designware_i2c_pci.c contain ACPI and lpss related codes.

Quoted 13 lines
Quoted 10 lines
drivers/i2c/Makefile +1 -1
 ifdef CONFIG_PCI
 obj-$(CONFIG_SYS_I2C_DW) += designware_i2c_pci.o
 endif
+endif
 obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
 obj-$(CONFIG_SYS_I2C_IHS) += ihs_i2c.o
 obj-$(CONFIG_SYS_I2C_INTEL) += intel_i2c.o
--

2.17.1

Regards,
Simon

Reviewed-by on v7 2/4
#5 lore raw

Re: [PATCH v7 2/4] starfive: pci: Add StarFive JH7110 pcie driver

In reply to Minda Chen
Quoted 12 lines · Minda Chen

From: Mason Huo <[email protected]>

Add pcie driver for StarFive JH7110, Also add PLDA PCIe controller common driver functions.

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

Quoted 10 lines
---
 drivers/pci/Kconfig                |  13 ++
 drivers/pci/Makefile               |   2 +
 drivers/pci/pcie_plda_common.c     | 116 +++++++++++
 drivers/pci/pcie_plda_common.h     | 118 +++++++++++
 drivers/pci/pcie_starfive_jh7110.c | 317 +++++++++++++++++++++++++++++
 5 files changed, 566 insertions(+)
 create mode 100644 drivers/pci/pcie_plda_common.c
 create mode 100644 drivers/pci/pcie_plda_common.h
 create mode 100644 drivers/pci/pcie_starfive_jh7110.c
Reviewed-by on v7 3/4
#7 lore raw

Re: [PATCH v7 3/4] configs: starfive-jh7110: Add support for PCIe host driver

In reply to Minda Chen
Quoted 9 lines · Minda Chen

From: Mason Huo <[email protected]>

Add PCIe host driver and nvme driver in configure file.

---
 configs/starfive_visionfive2_defconfig | 8 ++++++++
 1 file changed, 8 insertions(+)
Reviewed-by on v7 4/4
#9 lore raw

Re: [PATCH v7 4/4] riscv: dts: starfive: Enable PCIe host controller

In reply to Minda Chen
Quoted 10 lines · Minda Chen

From: Mason Huo <[email protected]>

Enable and add pinctrl configuration for PCIe host controller.

---
 .../dts/jh7110-starfive-visionfive-2.dtsi     | 11 +++
 arch/riscv/dts/jh7110.dtsi                    | 74 +++++++++++++++++++
 2 files changed, 85 insertions(+)