pci: Add support for Qualcomm PCIe controller
cover pci: Add support for Qualcomm PCIe controller
Add support for the DWC PCIe controllers found on the Qualcomm SoCs, it requires introducing pcie_dw_find_capability() to properly configure the Host controller capabilities.
---
Neil Armstrong (2):
pci: pcie_dw_common: introduce pcie_dw_find_capability()
pci: Add support for Qualcomm PCIe controller
drivers/pci/Kconfig | 8 + drivers/pci/Makefile | 1 + drivers/pci/pcie_dw_common.c | 42 ++++ drivers/pci/pcie_dw_common.h | 2 + drivers/pci/pcie_dw_qcom.c | 571 +++++++++++++++++++++++++++++++++++++++++++ include/pci.h | 4 + 6 files changed, 628 insertions(+)
---
base-commit: 7fe55182d9263a62e18b450c97bdf0b8031e5667
change-id: 20241125-topic-pcie-controller-cf11210bf5b3
Best regards,
Signature · 1 line
Neil Armstrong <[email protected]>
PATCH 1/2 pci: pcie_dw_common: introduce pcie_dw_find_capability()
Add PCIe config space capability search function specific for the host controller, which are bridges *to* PCI devices but are not PCI devices themselves.
--- drivers/pci/pcie_dw_common.c | 42 ++++++++++++++++++++++++++++++++++++++++++ drivers/pci/pcie_dw_common.h | 2 ++ 2 files changed, 44 insertions(+)
drivers/pci/pcie_dw_common.c +42 -0
@@ -267,6 +267,48 @@ int pcie_dw_write_config(struct udevice *bus, pci_dev_t bdf, pcie->io.bus_start, pcie->io.size); } +/* +* These interfaces resemble the pci_find_*capability() interfaces, but these +* are for configuring host controllers, which are bridges *to* PCI devices but +* are not PCI devices themselves. +*/ +static u8 pcie_dw_find_next_cap (struct pcie_dw *pci,u8 cap_ptr,u8 cap) +{ +u8 cap_id, next_cap_ptr; +u32 val; +u16 reg; + +if (!cap_ptr) +return 0 ; + + val =readl (pci->dbi_base + (cap_ptr & ~0x3 )); + reg =pci_conv_32_to_size (val, cap_ptr,2 ); + cap_id = (reg &0x00ff ); + +if (cap_id >PCI_CAP_ID_MAX ) +return 0 ; + +if (cap_id == cap) +return cap_ptr; + + next_cap_ptr = (reg &0xff00 ) >>8 ; +return pcie_dw_find_next_cap (pci, next_cap_ptr, cap); +} + +u8 pcie_dw_find_capability (struct pcie_dw *pci,u8 cap) +{ +u8 next_cap_ptr; +u32 val; +u16 reg; + + val =readl (pci->dbi_base + (PCI_CAPABILITY_LIST & ~0x3 )); + reg =pci_conv_32_to_size (val,PCI_CAPABILITY_LIST ,2 ); + + next_cap_ptr = (reg &0x00ff ); + +return pcie_dw_find_next_cap (pci, next_cap_ptr, cap); +} +/** * pcie_dw_setup_host() - Setup the PCIe controller for RC opertaion *
drivers/pci/pcie_dw_common.h +2 -0
@@ -139,6 +139,8 @@ int pcie_dw_read_config(const struct udevice *bus, pci_dev_t bdf, uint offset, uint pcie_dw_write_config (struct udevice *bus,pci_dev_t bdf,uint offset,ulong value,enum pci_size_t size); +u8 pcie_dw_find_capability (struct pcie_dw *pci,u8 cap); +static inline void dw_pcie_dbi_write_enable (struct pcie_dw *pci,bool en) {u32 val;
Signature · 1 line
2.34.1
PATCH 2/2 pci: Add support for Qualcomm PCIe controller
In reply to Neil ArmstrongAdd support for the PCIe busses on Qualcomm platforms, by using the pcie_dw_common infrastructure.
The driver is based on the Linux driver but only supporting the "1_9_0" and compatible platforms like:
- sa8540p
- sc7280
- sc8180x
- sc8280xp
- sdm845
- sdx55
- sm8150
- sm8250
- sm8350
- sm8450
- sm8550
- sm8650
- x1e80100
But it has only been tested on:
- sc7280
- sm8550
- sm8650
- x1e80100
It supports setting the IOMMU SID table for supported platforms.
--- drivers/pci/Kconfig | 8 + drivers/pci/Makefile | 1 + drivers/pci/pcie_dw_qcom.c | 571 +++++++++++++++++++++++++++++++++++++++++++++ include/pci.h | 4 + 4 files changed, 584 insertions(+)
drivers/pci/Kconfig +8 -0
@@ -371,6 +371,14 @@ config PCIE_DW_MESON Say Y here if you want to enable DW PCIe controller support on Amlogic SoCs. +config PCIE_DW_QCOM + bool "Qualcomm DesignWare based PCIe controller" + depends on ARCH_SNAPDRAGON + select PCIE_DW_COMMON + help + Say Y here if you want to enable DW PCIe controller support on + Qualcomm SoCs. + config PCIE_ROCKCHIP bool "Enable Rockchip PCIe driver" depends on ARCH_ROCKCHIP
drivers/pci/Makefile +1 -0
@@ -47,6 +47,7 @@ obj-$(CONFIG_PCIE_MEDIATEK_GEN3) += pcie_mediatek_gen3.o obj-$(CONFIG_PCIE_ROCKCHIP) += pcie_rockchip.o obj-$(CONFIG_PCIE_DW_ROCKCHIP) += pcie_dw_rockchip.o obj-$(CONFIG_PCIE_DW_MESON) += pcie_dw_meson.o +obj-$(CONFIG_PCIE_DW_QCOM) += pcie_dw_qcom.o obj-$(CONFIG_PCI_BRCMSTB) += pcie_brcmstb.o obj-$(CONFIG_PCI_OCTEONTX) += pci_octeontx.o obj-$(CONFIG_PCIE_OCTEON) += pcie_octeon.o
drivers/pci/pcie_dw_qcom.c new file +571 -0
571 lines not on this page · raw message
include/pci.h +4 -0
@@ -390,6 +390,9 @@#define PCI_EXP_LNKCAP_SLS_5_0GB 0x00000002/* LNKCAP2 SLS Vector bit 1 */ #define PCI_EXP_LNKCAP_SLS_8_0GB 0x00000003/* LNKCAP2 SLS Vector bit 2 */ #define PCI_EXP_LNKCAP_MLW 0x000003f0/* Maximum Link Width */ +#define PCI_EXP_LNKCAP_ASPMS 0x00000c00/* ASPM Support */ +#define PCI_EXP_LNKCAP_ASPM_L0S 0x00000400/* ASPM L0s Support */ +#define PCI_EXP_LNKCAP_ASPM_L1 0x00000800/* ASPM L1 Support */ #define PCI_EXP_LNKCAP_DLLLARC 0x00100000/* Data Link Layer Link Active Reporting Capable */ #define PCI_EXP_LNKCTL 16/* Link Control */ #define PCI_EXP_LNKCTL_RL 0x0020/* Retrain Link */
@@ -404,6 +407,7 @@#define PCI_EXP_LNKSTA_DLLLA 0x2000/* Data Link Layer Link Active */ #define PCI_EXP_LNKSTA_LBMS 0x4000/* Link Bandwidth Management Status */ #define PCI_EXP_SLTCAP 20/* Slot Capabilities */ +#define PCI_EXP_SLTCAP_HPC 0x00000040/* Hot-Plug Capable */ #define PCI_EXP_SLTCAP_PSN 0xfff80000/* Physical Slot Number */ #define PCI_EXP_RTCTL 28/* Root Control */ #define PCI_EXP_RTCTL_CRSSVE 0x0010/* CRS Software Visibility Enable */
Signature · 1 line
2.34.1
Caleb Connolly
AppliedQuoted 6 lines · Neil Armstrong
Add support for the DWC PCIe controllers found on the Qualcomm SoCs, it requires introducing
pcie_dw_find_capability()to properly configure the Host controller capabilities.
Applied, thanks!
[1/2] pci: pcie_dw_common: introduce pcie_dw_find_capability()
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/aeeebdadc56e
[2/2] pci: Add support for Qualcomm PCIe controller
https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/5b7ec7fb4437
Best regards,
Signature · 1 line
// Caleb (they/them)