Enable PCIe1 xHCI on Qualcomm QCS6490 RB3 Gen2
Subsystems (9)
cover Enable PCIe1 xHCI on Qualcomm QCS6490 RB3 Gen2
This series enables PCIe1 (RC1) on the QCS6490/Kodiak RB3 Gen2 so that the Renesas uPD720201 xHCI controller behind the on-board QPS615 PCIe switch can be used from U-Boot.
PCIe controller (patches 1-3):
- Add inbound iATU window support to the DesignWare common code and use it in pcie_dw_qcom, sized from "dma-ranges". Without an enabled inbound window the RC drops endpoint Memory Read/Write TLPs, which shows up as a Completion Timeout at the requester.
- Program the PARF DBI/ATU base address registers, as Linux does in qcom_pcie_configure_dbi_atu_base().
SoC support (patches 4-6):
- Add a no-op gate for GCC_PCIE_1_PIPE_CLK_SRC on sc7280.
- Add SM8250/Kodiak Gen3x2 QMP PCIe PHY support.
- Add the PM7250B GPIO compatible string.
Board and IOMMU (patches 7-9):
- Sequence the QPS615 switch and xHCI power/reset GPIOs on every boot from qcom_board_init(). A static gpio-hog only drives its level once and cannot re-assert across a warm reboot, since the PMIC rails stay powered.
- Resolve PCI stream IDs for devices without an ofnode via the bridge's iommu-map, and stop qcom-hyp-smmu from disabling stream classification at EL2, as firmware turns unclaimed streams into FAULT streams regardless of exception level.
- Enable the PCI, DesignWare/Qualcomm PCIe and QMP PCIe PHY options in qcom_defconfig. Also, enable qcom_board_init() override for QCS6490 / RB3 Gen 2 platform in qcm6490_defconfig.
Senthilkumar (9):
pci: dwc: add inbound ATU window support
pci: pcie_dw_qcom: configure an inbound iATU window
pci: pcie_dw_qcom: program PARF DBI/ATU base address registers
clk: qcom: sc7280: add GCC_PCIE_1_PIPE_CLK_SRC no-op gate
phy: qcom-qmp-pcie: add SM8250/Kodiak Gen3x2 PHY support
gpio: qcom_spmi: add pm7250b/pm8350c compatible strings
arm: mach-snapdragon: add QCS6490 PCIe1 power/reset sequencing
iommu: add PCI stream-ID resolution for devices without an ofnode
configs: qcom_defconfig: enable PCIe1 RC/PHY and qcom_board_init
override for QCS6490
arch/arm/mach-snapdragon/Kconfig | 9 + arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/qcs6490_pcie_init.c | 178 ++++++++++++++++++ configs/qcm6490_defconfig | 1 + configs/qcom_defconfig | 7 + drivers/clk/qcom/clock-sc7280.c | 5 + drivers/gpio/qcom_spmi_gpio.c | 1 + drivers/iommu/iommu-uclass.c | 78 +++++--- drivers/iommu/qcom-hyp-smmu.c | 27 +-- drivers/pci/pcie_dw_common.c | 59 ++++++ drivers/pci/pcie_dw_common.h | 23 +++ drivers/pci/pcie_dw_qcom.c | 62 ++++-- drivers/phy/qcom/phy-qcom-qmp-pcie.c | 187 ++++++++++++++++++- include/dm/device.h | 7 + 14 files changed, 588 insertions(+), 57 deletions(-) create mode 100644 arch/arm/mach-snapdragon/qcs6490_pcie_init.c
base-commit: 3973f3c4d24df75ca90d7c0a9f03e5e5c9b48f32
Signature · 2 lines
Best Regards Sumit Singh Dhami
PATCH 1/9 pci: dwc: add inbound ATU window support
From: Senthilkumar <[email protected]>
Only outbound ATU window programming is supported. Without an enabled inbound window covering an endpoint's DMA range, the RC drops incoming Memory Read/Write TLPs, which surfaces as a Completion Timeout at the requester with no error logged at the RC.
Add pcie_dw_prog_inbound_atu_unroll() to configure an inbound ATU window, mapping a PCIe bus address range to an AXI/host target address.
--- drivers/pci/pcie_dw_common.c | 59 ++++++++++++++++++++++++++++++++++++ drivers/pci/pcie_dw_common.h | 23 ++++++++++++++ 2 files changed, 82 insertions(+)
drivers/pci/pcie_dw_common.c +59 -0
@@ -144,6 +144,65 @@ int pcie_dw_prog_outbound_atu_unroll(struct pcie_dw *pci, int index,return -1 ; } +static void dw_pcie_writel_ib_unroll (struct pcie_dw *pci,u32 index,u32 reg, +u32 val) +{ +u32 offset =PCIE_GET_ATU_INB_UNR_REG_OFFSET (index); +void __iomem *base = pci->atu_base; + +writel (val, base + offset + reg); +} + +static u32 dw_pcie_readl_ib_unroll (struct pcie_dw *pci,u32 index,u32 reg) +{ +u32 offset =PCIE_GET_ATU_INB_UNR_REG_OFFSET (index); +void __iomem *base = pci->atu_base; + +return readl (base + offset + reg); +} + +int pcie_dw_prog_inbound_atu_unroll (struct pcie_dw *pci,int index,int type, +u64 pci_addr,u64 cpu_addr,u64 size) +{ +u32 retries, val; + +dev_dbg (pci->dev, +"inbound ATU: index=%d type=%d pci_addr=%#llx cpu_addr=%#llx size=%#llx\n" , + index, type, pci_addr, cpu_addr, size); + +/* PCIe bus address range that this window matches on */ +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_LOWER_BASE , +lower_32_bits (pci_addr)); +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_UPPER_BASE , +upper_32_bits (pci_addr)); +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_LIMIT , +lower_32_bits (pci_addr + size -1 )); +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_UPPER_LIMIT , +upper_32_bits (pci_addr + size -1 )); + +/* AXI/host target address to translate matching accesses to */ +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_LOWER_TARGET , +lower_32_bits (cpu_addr)); +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET , +upper_32_bits (cpu_addr)); + +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , type); +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL2 , +PCIE_ATU_ENABLE ); + +for (retries =0 ; retries <LINK_WAIT_MAX_IATU_RETRIES ; retries++) { + val =dw_pcie_readl_ib_unroll (pci, index, +PCIE_ATU_UNR_REGION_CTRL2 ); +if (val &PCIE_ATU_ENABLE ) +return 0 ; + +udelay (LINK_WAIT_IATU ); + } +dev_err (pci->dev,"inbound iATU is not being enabled\n" ); + +return -1 ; +} +/** * set_cfg_address() - Configure the PCIe controller config space access *
drivers/pci/pcie_dw_common.h +23 -0
@@ -48,6 +48,8 @@/* Register address builder */ #define PCIE_GET_ATU_OUTB_UNR_REG_OFFSET (region) ((region) << 9) +/* Inbound iATU region n is at outbound offset | 0x100 */ +#define PCIE_GET_ATU_INB_UNR_REG_OFFSET (region) (((region) << 9) | 0x100)/* Parameters for the waiting for iATU enabled routine */ #define LINK_WAIT_MAX_IATU_RETRIES 5
@@ -142,6 +144,27 @@ void dw_pcie_link_set_max_link_width(struct pcie_dw *pci, u32 num_lanes);int pcie_dw_prog_outbound_atu_unroll (struct pcie_dw *pci,int index,int type,u64 cpu_addr,u64 pci_addr,u32 size); +/** +* pcie_dw_prog_inbound_atu_unroll() - Configure inbound ATU window +* +* @pci: Pointer to the PCI controller state +* @index: ATU region index +* @type: ATU access type (PCIE_ATU_TYPE_MEM for memory) +* @pci_addr: PCIe bus address (what the endpoint sends as the DMA address) +* @cpu_addr: AXI/host address to translate to +* @size: Size of the translation window in bytes +* +* Configure an inbound ATU window so that DMA reads/writes from PCIe +* endpoints to host memory are forwarded to the AXI fabric. Without at +* least one enabled inbound window covering the endpoint's DMA address +* range, the RC drops incoming Memory Read/Write TLPs silently, which +* shows up as a Completion Timeout at the requester. +* +* Return: 0 on success, -1 on timeout waiting for enable +*/ +int pcie_dw_prog_inbound_atu_unroll (struct pcie_dw *pci,int index,int type, +u64 pci_addr,u64 cpu_addr,u64 size); +int pcie_dw_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size);
Signature · 1 line
2.55.0
Re: [PATCH v1 1/9] pci: dwc: add inbound ATU window support
Quoted 119 lines · Sumit Singh Dhami
From: Senthilkumar <[email protected]>
Only outbound ATU window programming is supported. Without an enabled inbound window covering an endpoint's DMA range, the RC drops incoming Memory Read/Write TLPs, which surfaces as a Completion Timeout at the requester with no error logged at the RC.
Add
pcie_dw_prog_inbound_atu_unroll()to configure an inbound ATU window, mapping a PCIe bus address range to an AXI/host target address.Signed-off-by Senthilkumar <[email protected]>Signed-off-by Sumit Singh Dhami <[email protected]>--- drivers/pci/pcie_dw_common.c | 59 ++++++++++++++++++++++++++++++++++++ drivers/pci/pcie_dw_common.h | 23 ++++++++++++++ 2 files changed, 82 insertions(+)drivers/pci/pcie_dw_common.c +59
-0@@ -144,6 +144,65 @@ int pcie_dw_prog_outbound_atu_unroll(struct pcie_dw *pci, int index,return -1 ; } +static void dw_pcie_writel_ib_unroll (struct pcie_dw *pci,u32 index,u32 reg, +u32 val) +{ +u32 offset =PCIE_GET_ATU_INB_UNR_REG_OFFSET (index); +void __iomem *base = pci->atu_base; + +writel (val, base + offset + reg); +} + +static u32 dw_pcie_readl_ib_unroll (struct pcie_dw *pci,u32 index,u32 reg) +{ +u32 offset =PCIE_GET_ATU_INB_UNR_REG_OFFSET (index); +void __iomem *base = pci->atu_base; + +return readl (base + offset + reg); +} + +int pcie_dw_prog_inbound_atu_unroll (struct pcie_dw *pci,int index,int type, +u64 pci_addr,u64 cpu_addr,u64 size) +{ +u32 retries, val; + +dev_dbg (pci->dev, +"inbound ATU: index=%d type=%d pci_addr=%#llx cpu_addr=%#llx size=%#llx\n" , + index, type, pci_addr, cpu_addr, size); + +/* PCIe bus address range that this window matches on */ +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_LOWER_BASE , +lower_32_bits (pci_addr)); +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_UPPER_BASE , +upper_32_bits (pci_addr)); +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_LIMIT , +lower_32_bits (pci_addr + size -1 )); +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_UPPER_LIMIT , +upper_32_bits (pci_addr + size -1 )); + +/* AXI/host target address to translate matching accesses to */ +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_LOWER_TARGET , +lower_32_bits (cpu_addr)); +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET , +upper_32_bits (cpu_addr)); + +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , type); +dw_pcie_writel_ib_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL2 , +PCIE_ATU_ENABLE ); + +for (retries =0 ; retries <LINK_WAIT_MAX_IATU_RETRIES ; retries++) { + val =dw_pcie_readl_ib_unroll (pci, index, +PCIE_ATU_UNR_REGION_CTRL2 ); +if (val &PCIE_ATU_ENABLE ) +return 0 ; + +udelay (LINK_WAIT_IATU ); + } +dev_err (pci->dev,"inbound iATU is not being enabled\n" ); + +return -1 ; +} +/** * set_cfg_address() - Configure the PCIe controller config space access * drivers/pci/pcie_dw_common.h +16
-0@@ -48,6 +48,8 @@/* Register address builder */ #define PCIE_GET_ATU_OUTB_UNR_REG_OFFSET (region) ((region) << 9) +/* Inbound iATU region n is at outbound offset | 0x100 */ +#define PCIE_GET_ATU_INB_UNR_REG_OFFSET (region) (((region) << 9) | 0x100)/* Parameters for the waiting for iATU enabled routine */ #define LINK_WAIT_MAX_IATU_RETRIES 5@@ -142,6 +144,27 @@ void dw_pcie_link_set_max_link_width(struct pcie_dw *pci, u32 num_lanes);int pcie_dw_prog_outbound_atu_unroll (struct pcie_dw *pci,int index,int type,u64 cpu_addr,u64 pci_addr,u32 size); +/** +* pcie_dw_prog_inbound_atu_unroll() - Configure inbound ATU window +* +* @pci: Pointer to the PCI controller state +* @index: ATU region index +* @type: ATU access type (PCIE_ATU_TYPE_MEM for memory) +* @pci_addr: PCIe bus address (what the endpoint sends as the DMA address) +* @cpu_addr: AXI/host address to translate to +* @size: Size of the translation window in bytes +* +* Configure an inbound ATU window so that DMA reads/writes from PCIe +* endpoints to host memory are forwarded to the AXI fabric. Without at +* least one enabled inbound window covering the endpoint's DMA address +* range, the RC drops incoming Memory Read/Write TLPs silently, which
drivers/pci/pcie_dw_common.h void dw_pcie_link_set_max_link_width(struct pcie_dw *pci, u32 num_lanes); · line 170
Quoted 10 lines
drivers/pci/pcie_dw_common.h +7
-0+* shows up as a Completion Timeout at the requester. +* +* Return: 0 on success, -1 on timeout waiting for enable +*/ +int pcie_dw_prog_inbound_atu_unroll (struct pcie_dw *pci,int index,int type, +u64 pci_addr,u64 cpu_addr,u64 size); +int pcie_dw_read_config (const struct udevice *bus,pci_dev_t bdf,uint offset,ulong *valuep,enum pci_size_t size);
Thanks,
Neil
PATCH 2/9 pci: pcie_dw_qcom: configure an inbound iATU window
In reply to Sumit Singh DhamiFrom: Senthilkumar <[email protected]>
The RC leaves every inbound window disabled, so inbound Memory Read/Write TLPs from endpoints are dropped, resulting in a Completion Timeout.
Configure an inbound iATU window via pcie_dw_prog_inbound_atu_unroll(), sized from "dma-ranges" (via dev_get_dma_range(), which also picks up an ancestor node's dma-ranges). Fall back to a conservative 4GB identity window with a warning if no dma-ranges is found.
--- drivers/pci/pcie_dw_qcom.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-)
drivers/pci/pcie_dw_qcom.c +30 -6
@@ -17,6 +17,7 @@#include <linux/delay.h> #include <linux/log2.h> #include <linux/bitfield.h> +#include <linux/sizes.h> #include "pcie_dw_common.h"
@@ -484,6 +485,9 @@ static int qcom_pcie_probe(struct udevice *dev)struct qcom_pcie *priv =dev_get_priv (dev);struct udevice *ctlr =pci_get_controller (dev);struct pci_controller *hose =dev_get_uclass_priv (ctlr); +phys_addr_t cpu_addr; +dma_addr_t bus_addr; +u64 size;int ret =0 ; priv->dw.first_busno =dev_seq (dev);
@@ -507,12 +511,32 @@ static int qcom_pcie_probe(struct udevice *dev)else printf ("PCIE-%d: Link up timeout\n" ,dev_seq (dev)); -return pcie_dw_prog_outbound_atu_unroll (&priv->dw, -PCIE_ATU_REGION_INDEX0 , -PCIE_ATU_TYPE_MEM , - priv->dw.mem.phys_start, - priv->dw.mem.bus_start, - priv->dw.mem.size); + ret =pcie_dw_prog_outbound_atu_unroll (&priv->dw, +PCIE_ATU_REGION_INDEX0 , +PCIE_ATU_TYPE_MEM , + priv->dw.mem.phys_start, + priv->dw.mem.bus_start, + priv->dw.mem.size); +if (ret) +return ret; + +/* Size the inbound window from "dma-ranges" so PCIe endpoints can DMA to host memory */ + ret =dev_get_dma_range (dev, &cpu_addr, &bus_addr, &size); +if (ret) { +dev_warn (dev,"no dma-ranges found, assuming identity map over 4GB\n" ); + cpu_addr =0 ; + bus_addr =0 ; + size =SZ_4G ; + } + + ret =pcie_dw_prog_inbound_atu_unroll (&priv->dw, +PCIE_ATU_REGION_INDEX0 , +PCIE_ATU_TYPE_MEM , + bus_addr, cpu_addr, size); +if (ret) +dev_warn (dev,"failed to configure inbound iATU (%d)\n" , ret); + +return 0 ; }static const struct dm_pci_ops qcom_pcie_ops = {
Signature · 1 line
2.55.0
Re: [PATCH v1 2/9] pci: pcie_dw_qcom: configure an inbound iATU window
Quoted 68 lines · Sumit Singh Dhami
From: Senthilkumar <[email protected]>
The RC leaves every inbound window disabled, so inbound Memory Read/Write TLPs from endpoints are dropped, resulting in a Completion Timeout.
Configure an inbound iATU window via
pcie_dw_prog_inbound_atu_unroll(), sized from "dma-ranges" (viadev_get_dma_range(), which also picks up an ancestor node's dma-ranges). Fall back to a conservative 4GB identity window with a warning if no dma-ranges is found.Signed-off-by Senthilkumar <[email protected]>Signed-off-by Sumit Singh Dhami <[email protected]>--- drivers/pci/pcie_dw_qcom.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-)drivers/pci/pcie_dw_qcom.c +23
-6@@ -17,6 +17,7 @@#include <linux/delay.h> #include <linux/log2.h> #include <linux/bitfield.h> +#include <linux/sizes.h> #include "pcie_dw_common.h" @@ -484,6 +485,9 @@ static int qcom_pcie_probe(struct udevice *dev)struct qcom_pcie *priv =dev_get_priv (dev);struct udevice *ctlr =pci_get_controller (dev);struct pci_controller *hose =dev_get_uclass_priv (ctlr); +phys_addr_t cpu_addr; +dma_addr_t bus_addr; +u64 size;int ret =0 ; priv->dw.first_busno =dev_seq (dev);@@ -507,12 +511,32 @@ static int qcom_pcie_probe(struct udevice *dev)else printf ("PCIE-%d: Link up timeout\n" ,dev_seq (dev)); -return pcie_dw_prog_outbound_atu_unroll (&priv->dw, -PCIE_ATU_REGION_INDEX0 , -PCIE_ATU_TYPE_MEM , - priv->dw.mem.phys_start, - priv->dw.mem.bus_start, - priv->dw.mem.size); + ret =pcie_dw_prog_outbound_atu_unroll (&priv->dw, +PCIE_ATU_REGION_INDEX0 , +PCIE_ATU_TYPE_MEM , + priv->dw.mem.phys_start, + priv->dw.mem.bus_start, + priv->dw.mem.size); +if (ret) +return ret; + +/* Size the inbound window from "dma-ranges" so PCIe endpoints can DMA to host memory */ + ret =dev_get_dma_range (dev, &cpu_addr, &bus_addr, &size); +if (ret) { +dev_warn (dev,"no dma-ranges found, assuming identity map over 4GB\n" ); + cpu_addr =0 ; + bus_addr =0 ; + size =SZ_4G ; + } + + ret = pcie_dw_prog_inbound_atu_unroll(&priv->dw,
drivers/pci/pcie_dw_qcom.c static int qcom_pcie_probe(struct udevice *dev) · line 542
Quoted 10 lines
drivers/pci/pcie_dw_qcom.c +7
-0+PCIE_ATU_REGION_INDEX0 , +PCIE_ATU_TYPE_MEM , + bus_addr, cpu_addr, size); +if (ret) +dev_warn (dev,"failed to configure inbound iATU (%d)\n" , ret); + +return 0 ; }static const struct dm_pci_ops qcom_pcie_ops = {
Thanks,
Neil
PATCH 3/9 pci: pcie_dw_qcom: program PARF DBI/ATU base address registers
In reply to Sumit Singh DhamiFrom: Senthilkumar <[email protected]>
The V2 DBI/ATU base address and slave-address-space-size PARF registers remain unprogrammed and retain their hardware-reset default of 0.
Program these registers so the RC's internal routing logic knows the location of its DBI/ATU register blocks, matching Linux's qcom_pcie_configure_dbi_atu_base() implementation for
IP revision 1_9_0.
Also, remove the unused legacy PARF_DBI_BASE_ADDR and PARF_SLV_ADDR_SPACE_SIZE which are not required for IP revision 1_9_0.
--- drivers/pci/pcie_dw_qcom.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
drivers/pci/pcie_dw_qcom.c +20 -6
@@ -17,6 +17,7 @@#include <linux/delay.h> #include <linux/log2.h> #include <linux/bitfield.h> +#include <linux/kernel.h> #include <linux/sizes.h> #include "pcie_dw_common.h"
@@ -49,7 +50,6 @@ struct qcom_pcie {#define PARF_PHY_CTRL 0x40#define PARF_PHY_REFCLK 0x4c#define PARF_CONFIG_BITS 0x50 -#define PARF_DBI_BASE_ADDR 0x168#define PARF_MHI_CLOCK_RESET_CTRL 0x174#define PARF_AXI_MSTR_WR_ADDR_HALT 0x178#define PARF_AXI_MSTR_WR_ADDR_HALT_V2 0x1a8
@@ -57,7 +57,12 @@ struct qcom_pcie {#define PARF_LTSSM 0x1b0#define PARF_SID_OFFSET 0x234#define PARF_BDF_TRANSLATE_CFG 0x24c -#define PARF_SLV_ADDR_SPACE_SIZE 0x358 +#define PARF_DBI_BASE_ADDR_V2 0x350 +#define PARF_DBI_BASE_ADDR_V2_HI 0x354 +#define PARF_SLV_ADDR_SPACE_SIZE_V2 0x358 +#define PARF_SLV_ADDR_SPACE_SIZE_V2_HI 0x35c +#define PARF_ATU_BASE_ADDR 0x634 +#define PARF_ATU_BASE_ADDR_HI 0x638#define PARF_DEVICE_TYPE 0x1000#define PARF_BDF_TO_SID_TABLE_N 0x2000
@@ -111,8 +116,8 @@ struct qcom_pcie {/* PARF_CONFIG_BITS register fields */ #define PHY_RX0_EQ (x) FIELD_PREP(GENMASK(26, 24), x) -/* PARF_SLV_ADDR_SPACE_SIZE register value */ -#define SLV_ADDR_SPACE_SZ 0x10000000 +/* PARF_SLV_ADDR_SPACE_SIZE_V2/_HI register value (64-bit pair, matches Linux) */ +#define SLV_ADDR_SPACE_SZ_V2_HI 0x80000000/* PARF_MHI_CLOCK_RESET_CTRL register fields */ #define AHB_CLK_EN BIT(0)
@@ -298,6 +303,7 @@ static int qcom_pcie_init_port(struct udevice *dev)struct qcom_pcie *priv =dev_get_priv (dev);int vreg, ret;u32 val; +u64 dbi_phys, atu_phys;dm_gpio_set_value (&priv->rst_gpio,1 );udelay (PERST_DELAY_US );
@@ -346,8 +352,16 @@ static int qcom_pcie_init_port(struct udevice *dev) val &= ~PHY_TEST_PWR_DOWN ;writel (val, priv->parf +PARF_PHY_CTRL ); -/* change DBI base address */ -writel (0 , priv->parf +PARF_DBI_BASE_ADDR ); +/* Tell the RC where its DBI/ATU blocks live, and size the slave address space */ + dbi_phys = (u64 )(uintptr_t )priv->dw.dbi_base; + atu_phys = (u64 )(uintptr_t )priv->dw.atu_base; + +writel (lower_32_bits (dbi_phys), priv->parf +PARF_DBI_BASE_ADDR_V2 ); +writel (upper_32_bits (dbi_phys), priv->parf +PARF_DBI_BASE_ADDR_V2_HI ); +writel (lower_32_bits (atu_phys), priv->parf +PARF_ATU_BASE_ADDR ); +writel (upper_32_bits (atu_phys), priv->parf +PARF_ATU_BASE_ADDR_HI ); +writel (0x0 , priv->parf +PARF_SLV_ADDR_SPACE_SIZE_V2 ); +writel (SLV_ADDR_SPACE_SZ_V2_HI , priv->parf +PARF_SLV_ADDR_SPACE_SIZE_V2_HI );/* MAC PHY_POWERDOWN MUX DISABLE */ val =readl (priv->parf +PARF_SYS_CTRL );
Signature · 1 line
2.55.0
Re: [PATCH v1 3/9] pci: pcie_dw_qcom: program PARF DBI/ATU base address registers
Quoted 82 lines · Sumit Singh Dhami
From: Senthilkumar <[email protected]>
The V2 DBI/ATU base address and slave-address-space-size PARF registers remain unprogrammed and retain their hardware-reset default of 0.
Program these registers so the RC's internal routing logic knows the location of its DBI/ATU register blocks, matching Linux's
qcom_pcie_configure_dbi_atu_base()implementation for
IP revision 1_9_0.Also, remove the unused legacy
PARF_DBI_BASE_ADDRandPARF_SLV_ADDR_SPACE_SIZEwhich are not required for IP revision 1_9_0.Signed-off-by Senthilkumar <[email protected]>Signed-off-by Sumit Singh Dhami <[email protected]>--- drivers/pci/pcie_dw_qcom.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)drivers/pci/pcie_dw_qcom.c +13
-6@@ -17,6 +17,7 @@#include <linux/delay.h> #include <linux/log2.h> #include <linux/bitfield.h> +#include <linux/kernel.h> #include <linux/sizes.h> #include "pcie_dw_common.h" @@ -49,7 +50,6 @@ struct qcom_pcie {#define PARF_PHY_CTRL 0x40#define PARF_PHY_REFCLK 0x4c#define PARF_CONFIG_BITS 0x50 -#define PARF_DBI_BASE_ADDR 0x168#define PARF_MHI_CLOCK_RESET_CTRL 0x174#define PARF_AXI_MSTR_WR_ADDR_HALT 0x178#define PARF_AXI_MSTR_WR_ADDR_HALT_V2 0x1a8@@ -57,7 +57,12 @@ struct qcom_pcie {#define PARF_LTSSM 0x1b0#define PARF_SID_OFFSET 0x234#define PARF_BDF_TRANSLATE_CFG 0x24c -#define PARF_SLV_ADDR_SPACE_SIZE 0x358 +#define PARF_DBI_BASE_ADDR_V2 0x350 +#define PARF_DBI_BASE_ADDR_V2_HI 0x354 +#define PARF_SLV_ADDR_SPACE_SIZE_V2 0x358 +#define PARF_SLV_ADDR_SPACE_SIZE_V2_HI 0x35c +#define PARF_ATU_BASE_ADDR 0x634 +#define PARF_ATU_BASE_ADDR_HI 0x638#define PARF_DEVICE_TYPE 0x1000#define PARF_BDF_TO_SID_TABLE_N 0x2000@@ -111,8 +116,8 @@ struct qcom_pcie {/* PARF_CONFIG_BITS register fields */ #define PHY_RX0_EQ (x) FIELD_PREP(GENMASK(26, 24), x) -/* PARF_SLV_ADDR_SPACE_SIZE register value */ -#define SLV_ADDR_SPACE_SZ 0x10000000 +/* PARF_SLV_ADDR_SPACE_SIZE_V2/_HI register value (64-bit pair, matches Linux) */ +#define SLV_ADDR_SPACE_SZ_V2_HI 0x80000000/* PARF_MHI_CLOCK_RESET_CTRL register fields */ #define AHB_CLK_EN BIT(0)@@ -298,6 +303,7 @@ static int qcom_pcie_init_port(struct udevice *dev)struct qcom_pcie *priv =dev_get_priv (dev);int vreg, ret;u32 val; +u64 dbi_phys, atu_phys;dm_gpio_set_value (&priv->rst_gpio,1 );udelay (PERST_DELAY_US );@@ -346,8 +352,16 @@ static int qcom_pcie_init_port(struct udevice *dev) val &= ~PHY_TEST_PWR_DOWN ;writel (val, priv->parf +PARF_PHY_CTRL ); -/* change DBI base address */ -writel (0 , priv->parf +PARF_DBI_BASE_ADDR ); +/* Tell the RC where its DBI/ATU blocks live, and size the slave address space */ + dbi_phys = (u64 )(uintptr_t )priv->dw.dbi_base; + atu_phys = (u64 )(uintptr_t )priv->dw.atu_base;
drivers/pci/pcie_dw_qcom.c static int qcom_pcie_init_port(struct udevice *dev) · line 367
Quoted 10 lines
drivers/pci/pcie_dw_qcom.c +7
-0+ +writel (lower_32_bits (dbi_phys), priv->parf +PARF_DBI_BASE_ADDR_V2 ); +writel (upper_32_bits (dbi_phys), priv->parf +PARF_DBI_BASE_ADDR_V2_HI ); +writel (lower_32_bits (atu_phys), priv->parf +PARF_ATU_BASE_ADDR ); +writel (upper_32_bits (atu_phys), priv->parf +PARF_ATU_BASE_ADDR_HI ); +writel (0x0 , priv->parf +PARF_SLV_ADDR_SPACE_SIZE_V2 ); +writel (SLV_ADDR_SPACE_SZ_V2_HI , priv->parf +PARF_SLV_ADDR_SPACE_SIZE_V2_HI );/* MAC PHY_POWERDOWN MUX DISABLE */ val =readl (priv->parf +PARF_SYS_CTRL );
Thanks,
Neil
PATCH 4/9 clk: qcom: sc7280: add GCC_PCIE_1_PIPE_CLK_SRC no-op gate
In reply to Sumit Singh DhamiFrom: Senthilkumar <[email protected]>
GCC_PCIE_1_PIPE_CLK_SRC (ID 56) has no gate entry, so clk_get_bulk()/clk_enable_bulk() fail with "unknown clock ID 56" for any consumer listing it in "clocks".
The mux it represents is actually configured by clk_phy_mux_enable() as a side effect of enabling GCC_PCIE_1_PIPE_CLK, so register it as a no-op gate.
--- drivers/clk/qcom/clock-sc7280.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/clk/qcom/clock-sc7280.c +5 -0
@@ -206,6 +206,11 @@ static const struct gate_clk sc7280_clks[] = {GATE_CLK_POLLED (GCC_PCIE_CLKREF_EN ,0x8c004 ,BIT (0 ),0x8c004 ),GATE_CLK (GCC_PCIE_1_PIPE_CLK ,0x52000 ,BIT (30 )), +/* +* No-op gate: actual mux config is done by clk_phy_mux_enable() +* when GCC_PCIE_1_PIPE_CLK is enabled. +*/ +GATE_CLK (GCC_PCIE_1_PIPE_CLK_SRC ,PCIE_1_PIPE_CLK_PHY_MUX ,0 ),GATE_CLK (GCC_PCIE_1_AUX_CLK ,0x52000 ,BIT (29 )),GATE_CLK (GCC_PCIE_1_CFG_AHB_CLK ,0x52000 ,BIT (28 )), GATE_CLK(GCC_PCIE_1_MSTR_AXI_CLK, 0x52000, BIT(27)),
Signature · 1 line
2.55.0
[email protected]
reviewerRe: [PATCH v1 4/9] clk: qcom: sc7280: add GCC_PCIE_1_PIPE_CLK_SRC no-op gate
Quoted 22 lines · Sumit Singh Dhami
From: Senthilkumar <[email protected]>
GCC_PCIE_1_PIPE_CLK_SRC(ID 56) has no gate entry, so clk_get_bulk()/clk_enable_bulk() fail with "unknown clock ID 56" for any consumer listing it in "clocks".The mux it represents is actually configured by
clk_phy_mux_enable()as a side effect of enablingGCC_PCIE_1_PIPE_CLK, so register it as a no-op gate.Signed-off-by Senthilkumar <[email protected]>Signed-off-by Sumit Singh Dhami <[email protected]>--- drivers/clk/qcom/clock-sc7280.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/clk/qcom/clock-sc7280.c +0
-0@@ -206,6 +206,11 @@ static const struct gate_clk sc7280_clks[] = { GATE_CLK_POLLED(GCC_PCIE_CLKREF_EN, 0x8c004, BIT(0), 0x8c004),
drivers/clk/qcom/clock-sc7280.c static const struct gate_clk sc7280_clks[] = { · line 216
Quoted 10 lines
drivers/clk/qcom/clock-sc7280.c +5
-0GATE_CLK (GCC_PCIE_1_PIPE_CLK ,0x52000 ,BIT (30 )), +/* +* No-op gate: actual mux config is done by clk_phy_mux_enable() +* when GCC_PCIE_1_PIPE_CLK is enabled. +*/ +GATE_CLK (GCC_PCIE_1_PIPE_CLK_SRC ,PCIE_1_PIPE_CLK_PHY_MUX ,0 ),GATE_CLK (GCC_PCIE_1_AUX_CLK ,0x52000 ,BIT (29 )),GATE_CLK (GCC_PCIE_1_CFG_AHB_CLK ,0x52000 ,BIT (28 )), GATE_CLK(GCC_PCIE_1_MSTR_AXI_CLK, 0x52000, BIT(27)),
Instead add early check in sc7280_enable for GCC_PCIE_1_PIPE_CLK_SRC which just returns 0.
Neil
PATCH 5/9 phy: qcom-qmp-pcie: add SM8250/Kodiak Gen3x2 PHY support
In reply to Sumit Singh DhamiFrom: Senthilkumar <[email protected]>
There is no QMP PCIe PHY config for SM8250-family SoCs such as Kodiak (QCM6490), so PCIe1 (RC1) cannot be brought up. Also, qmp_pcie_clk_init() only tolerate a missing "ref" clock, but some SM8250-family DTS files (e.g. Kodiak) name the rchng-equivalent clock "refgen" instead, failing clock init outright.
Add the SM8250-family Gen3x2 PHY register-init tables and a new qcom,sm8250-qmp-gen3x2-pcie-phy compatible and tolerate a missing "rchng" clock the same way "ref" is tolerated.
--- drivers/phy/qcom/phy-qcom-qmp-pcie.c | 187 ++++++++++++++++++++++++++- 1 file changed, 184 insertions(+), 3 deletions(-)
drivers/phy/qcom/phy-qcom-qmp-pcie.c +184 -3
@@ -24,7 +24,11 @@#include "phy-qcom-qmp.h" #include "phy-qcom-qmp-pcs-misc-v3.h" +#include "phy-qcom-qmp-pcs-pcie-v4.h" +#include "phy-qcom-qmp-pcs-v4.h" #include "phy-qcom-qmp-pcs-v5.h" +#include "phy-qcom-qmp-qserdes-com-v4.h" +#include "phy-qcom-qmp-qserdes-txrx-v4.h" #include "phy-qcom-qmp-pcs-v6.h" #include "phy-qcom-qmp-pcs-v6_20.h" #include "phy-qcom-qmp-pcs-pcie-v6.h"
@@ -89,6 +93,13 @@ enum qphy_reg_layout {QPHY_LAYOUT_SIZE }; +static const unsigned int pciephy_v4_regs_layout[QPHY_LAYOUT_SIZE ] = { + [QPHY_SW_RESET ] =QPHY_V4_PCS_SW_RESET , + [QPHY_START_CTRL ] =QPHY_V4_PCS_START_CONTROL , + [QPHY_PCS_STATUS ] =QPHY_V4_PCS_PCS_STATUS1 , + [QPHY_PCS_POWER_DOWN_CONTROL ] =QPHY_V4_PCS_POWER_DOWN_CONTROL , +}; +static const unsigned int pciephy_v5_regs_layout[QPHY_LAYOUT_SIZE ] = { [QPHY_SW_RESET ] =QPHY_V5_PCS_SW_RESET , [QPHY_START_CTRL ] =QPHY_V5_PCS_START_CONTROL ,
@@ -103,6 +114,120 @@ static const unsigned int pciephy_v6_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_POWER_DOWN_CONTROL] = QPHY_V6_PCS_POWER_DOWN_CONTROL, }; +/* +* SM8250 / Kodiak (QCM6490) Gen3x2 PCIe PHY init tables. +* Ported from kernel drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +* (sm8250_qmp_pcie_serdes_tbl / sm8250_qmp_gen3x2_pcie_* tables). +* Compatible string: "qcom,sm8250-qmp-gen3x2-pcie-phy" +*/ +static const struct qmp_pcie_init_tbl sm8250_qmp_pcie_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SYSCLK_EN_SEL ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CLK_SELECT ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CORECLK_DIV_MODE1 ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_IVCO ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP_EN ,0x42 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE1_MODE0 ,0x24 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE2_MODE1 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE1_MODE1 ,0xb4 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE_MAP ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL ,0x11 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DEC_START_MODE0 ,0x82 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START3_MODE0 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START2_MODE0 ,0x55 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START1_MODE0 ,0x55 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP2_MODE0 ,0x1a ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP1_MODE0 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DEC_START_MODE1 ,0x68 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START3_MODE1 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START2_MODE1 ,0xaa ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START1_MODE1 ,0xab ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP2_MODE1 ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP1_MODE1 ,0x14 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_HSCLK_SEL ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CP_CTRL_MODE0 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_RCTRL_MODE0 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_CCTRL_MODE0 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CP_CTRL_MODE1 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_RCTRL_MODE1 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_CCTRL_MODE1 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0 ,0x1e ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0 ,0xca ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1 ,0x18 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1 ,0xa2 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_EN_CENTER ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_PER1 ,0x31 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_PER2 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0 ,0xde ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1 ,0x4c ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CLK_ENABLE1 ,0x90 ), +}; + +static const struct qmp_pcie_init_tbl sm8250_qmp_gen3x2_pcie_tx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V4_TX_RCV_DETECT_LVL_2 ,0x12 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_LANE_MODE_1 ,0x35 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX ,0x11 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_PI_QEC_CTRL ,0x20 ), +}; + +static const struct qmp_pcie_init_tbl sm8250_qmp_gen3x2_pcie_rx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_FO_GAIN ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_SO_GAIN ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_GM_CAL ,0x1b ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW ,0xc0 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE ,0x30 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_VGA_CAL_CNTRL1 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_VGA_CAL_CNTRL2 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE ,0x7f ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_PI_CONTROLS ,0x70 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2 ,0x0e ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3 ,0x4a ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4 ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_SIGDET_CNTRL ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_SIGDET_ENABLES ,0x1c ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL ,0x1e ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 ,0x17 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_10_LOW ,0xd4 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_10_HIGH ,0x54 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_10_HIGH2 ,0xdb ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_10_HIGH3 ,0x3b ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_10_HIGH4 ,0x31 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_LOW ,0x24 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_00_HIGH2 ,0xff ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_00_HIGH3 ,0x7f ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_DCC_CTRL1 ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH ,0xe4 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH2 ,0xec ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH3 ,0x3b ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH4 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_00_LOW ,0xbf ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_00_HIGH4 ,0x15 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET ,0x38 ), +}; + +static const struct qmp_pcie_init_tbl sm8250_qmp_gen3x2_pcie_pcs_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L ,0x01 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_RX_SIGDET_LVL ,0x77 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_RATE_SLEW_CNTRL1 ,0x0b ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_REFGEN_REQ_CONFIG1 ,0x05 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_EQ_CONFIG2 ,0x0f ), +}; + +static const struct qmp_pcie_init_tbl sm8250_qmp_gen3x2_pcie_pcs_misc_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS ,0x00 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L ,0x01 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L ,0x01 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_PRESET_P6_P7_PRE ,0x33 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_PRESET_P10_PRE ,0x00 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_PRESET_P10_POST ,0x58 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE ,0xc1 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2 ,0x0d ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4 ,0x07 ), +}; +static const struct qmp_pcie_init_tbl sm8550_qmp_gen3x2_pcie_serdes_tbl[] = {QMP_PHY_INIT_CFG (QSERDES_V6_COM_SSC_EN_CENTER ,0x01 ),QMP_PHY_INIT_CFG (QSERDES_V6_COM_SSC_PER1 ,0x62 ),
@@ -639,6 +764,21 @@ static const char * const sdm845_pciephy_reset_l[] = { "phy", }; +/* +* SM8250 / Kodiak (QCM6490) Gen3x2 PCIe PHY register offsets. +* serdes=0x0000, tx=0x0200, rx=0x0400, tx2=0x0600, rx2=0x0800, +* pcs=0x0a00, pcs_misc=0x0e00 — fits within the 0x1000 reg window. +*/ +static const struct qmp_pcie_offsets qmp_pcie_offsets_v4x2 = { + .serdes =0 , + .pcs =0x0a00 , + .pcs_misc =0x0e00 , + .tx =0x0200 , + .rx =0x0400 , + .tx2 =0x0600 , + .rx2 =0x0800 , +}; +static const struct qmp_pcie_offsets qmp_pcie_offsets_v5 = { .serdes =0 , .pcs =0x0200 ,
@@ -660,6 +800,37 @@ static const struct qmp_pcie_offsets qmp_pcie_offsets_v6_20 = { .ln_shrd = 0x0e00, }; +/* +* SM8250 / Kodiak (QCM6490) Gen3x2 PCIe PHY config (pcie1, x2 lanes). +* Compatible string: "qcom,sm8250-qmp-gen3x2-pcie-phy" +*/ +static const struct qmp_pcie_cfg sm8250_qmp_gen3x2_pciephy_cfg = { + .lanes =2 , + + .offsets = &qmp_pcie_offsets_v4x2, + + .tbls = { + .serdes = sm8250_qmp_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sm8250_qmp_pcie_serdes_tbl), + .tx = sm8250_qmp_gen3x2_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_tx_tbl), + .rx = sm8250_qmp_gen3x2_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_rx_tbl), + .pcs = sm8250_qmp_gen3x2_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_pcs_tbl), + .pcs_misc = sm8250_qmp_gen3x2_pcie_pcs_misc_tbl, + .pcs_misc_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_pcs_misc_tbl), + }, + .reset_list = sdm845_pciephy_reset_l, + .num_resets =ARRAY_SIZE (sdm845_pciephy_reset_l), + .vreg_list = qmp_phy_vreg_l, + .num_vregs =ARRAY_SIZE (qmp_phy_vreg_l), + .regs = pciephy_v4_regs_layout, + + .pwrdn_ctrl =SW_PWRDN |REFCLK_DRV_DSBL , + .phy_status =PHYSTATUS , +}; +static const struct qmp_pcie_cfg sm8550_qmp_gen3x2_pciephy_cfg = { .lanes =2 ,
@@ -873,8 +1044,10 @@ static int qmp_pcie_power_on(struct phy *phy) } ret =qmp_pcie_do_reset (qmp); -if (ret) +if (ret) { +dev_err (phy->dev,"qmp_pcie_do_reset failed: %d\n" , ret);return ret; + }for (i =0 ; i < qmp->clk_count; i++) { ret =clk_enable (&qmp->clks[i]);
@@ -902,6 +1075,7 @@ static int qmp_pcie_power_on(struct phy *phy) status = pcs + cfg->regs[QPHY_PCS_STATUS ]; mask = cfg->phy_status; + ret =readl_poll_timeout (status, val, !(val & mask),PHY_INIT_COMPLETE_TIMEOUT );if (ret) {dev_err (phy->dev,"phy initialization timed-out\n" );
@@ -998,8 +1172,12 @@ static int qmp_pcie_clk_init(struct udevice *dev, struct qmp_pcie_priv *qmp)for (i =0 ; i < num; i++) { ret =clk_get_by_name (dev, qmp_pciephy_clk_l[i], &qmp->clks[i]); -/* Ignore failure to get ref clock */ -if (ret &&strcmp (qmp_pciephy_clk_l[i],"ref" ) !=0 ) { +/* +* "ref" is always optional. Kodiak/SM8250 DTS also uses +* "refgen" instead of "rchng", so ignore that too. +*/ +if (ret &&strcmp (qmp_pciephy_clk_l[i],"ref" ) !=0 && +strcmp (qmp_pciephy_clk_l[i],"rchng" ) !=0 ) {dev_err (dev,"failed to get clock %d\n" , i); goto clk_get_err; }
@@ -1097,6 +1275,9 @@ static struct phy_ops qmp_pcie_ops = {static const struct udevice_id qmp_pcie_ids[] = { { + .compatible ="qcom,sm8250-qmp-gen3x2-pcie-phy" , + .data = (ulong)&sm8250_qmp_gen3x2_pciephy_cfg, + }, { .compatible ="qcom,sm8550-qmp-gen3x2-pcie-phy" , .data = (ulong)&sm8550_qmp_gen3x2_pciephy_cfg, }, {
Signature · 1 line
2.55.0
Re: [PATCH v1 5/9] phy: qcom-qmp-pcie: add SM8250/Kodiak Gen3x2 PHY support
Quoted 251 lines · Sumit Singh Dhami
From: Senthilkumar <[email protected]>
There is no QMP PCIe PHY config for SM8250-family SoCs such as Kodiak (QCM6490), so PCIe1 (RC1) cannot be brought up. Also,
qmp_pcie_clk_init()only tolerate a missing "ref" clock, but some SM8250-family DTS files (e.g. Kodiak) name the rchng-equivalent clock "refgen" instead, failing clock init outright.Add the SM8250-family Gen3x2 PHY register-init tables and a new qcom,sm8250-qmp-gen3x2-pcie-phy compatible and tolerate a missing "rchng" clock the same way "ref" is tolerated.
Signed-off-by Senthilkumar <[email protected]>Signed-off-by Sumit Singh Dhami <[email protected]>--- drivers/phy/qcom/phy-qcom-qmp-pcie.c | 187 ++++++++++++++++++++++++++- 1 file changed, 184 insertions(+), 3 deletions(-)drivers/phy/qcom/phy-qcom-qmp-pcie.c +175
-1@@ -24,7 +24,11 @@#include "phy-qcom-qmp.h" #include "phy-qcom-qmp-pcs-misc-v3.h" +#include "phy-qcom-qmp-pcs-pcie-v4.h" +#include "phy-qcom-qmp-pcs-v4.h" #include "phy-qcom-qmp-pcs-v5.h" +#include "phy-qcom-qmp-qserdes-com-v4.h" +#include "phy-qcom-qmp-qserdes-txrx-v4.h" #include "phy-qcom-qmp-pcs-v6.h" #include "phy-qcom-qmp-pcs-v6_20.h" #include "phy-qcom-qmp-pcs-pcie-v6.h" @@ -89,6 +93,13 @@ enum qphy_reg_layout {QPHY_LAYOUT_SIZE }; +static const unsigned int pciephy_v4_regs_layout[QPHY_LAYOUT_SIZE ] = { + [QPHY_SW_RESET ] =QPHY_V4_PCS_SW_RESET , + [QPHY_START_CTRL ] =QPHY_V4_PCS_START_CONTROL , + [QPHY_PCS_STATUS ] =QPHY_V4_PCS_PCS_STATUS1 , + [QPHY_PCS_POWER_DOWN_CONTROL ] =QPHY_V4_PCS_POWER_DOWN_CONTROL , +}; +static const unsigned int pciephy_v5_regs_layout[QPHY_LAYOUT_SIZE ] = { [QPHY_SW_RESET ] =QPHY_V5_PCS_SW_RESET , [QPHY_START_CTRL ] =QPHY_V5_PCS_START_CONTROL ,@@ -103,6 +114,120 @@ static const unsigned int pciephy_v6_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_POWER_DOWN_CONTROL] = QPHY_V6_PCS_POWER_DOWN_CONTROL, }; +/* +* SM8250 / Kodiak (QCM6490) Gen3x2 PCIe PHY init tables. +* Ported from kernel drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +* (sm8250_qmp_pcie_serdes_tbl / sm8250_qmp_gen3x2_pcie_* tables). +* Compatible string: "qcom,sm8250-qmp-gen3x2-pcie-phy" +*/ +static const struct qmp_pcie_init_tbl sm8250_qmp_pcie_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SYSCLK_EN_SEL ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CLK_SELECT ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CORECLK_DIV_MODE1 ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_IVCO ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP_EN ,0x42 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE1_MODE0 ,0x24 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE2_MODE1 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE1_MODE1 ,0xb4 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE_MAP ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL ,0x11 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DEC_START_MODE0 ,0x82 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START3_MODE0 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START2_MODE0 ,0x55 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START1_MODE0 ,0x55 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP2_MODE0 ,0x1a ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP1_MODE0 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DEC_START_MODE1 ,0x68 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START3_MODE1 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START2_MODE1 ,0xaa ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START1_MODE1 ,0xab ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP2_MODE1 ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP1_MODE1 ,0x14 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_HSCLK_SEL ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CP_CTRL_MODE0 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_RCTRL_MODE0 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_CCTRL_MODE0 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CP_CTRL_MODE1 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_RCTRL_MODE1 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_CCTRL_MODE1 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0 ,0x1e ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0 ,0xca ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE1 ,0x18 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE1 ,0xa2 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_EN_CENTER ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_PER1 ,0x31 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_PER2 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0 ,0xde ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_STEP_SIZE1_MODE1 ,0x4c ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_STEP_SIZE2_MODE1 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CLK_ENABLE1 ,0x90 ), +}; + +static const struct qmp_pcie_init_tbl sm8250_qmp_gen3x2_pcie_tx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V4_TX_RCV_DETECT_LVL_2 ,0x12 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_LANE_MODE_1 ,0x35 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX ,0x11 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_PI_QEC_CTRL ,0x20 ), +}; + +static const struct qmp_pcie_init_tbl sm8250_qmp_gen3x2_pcie_rx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_FO_GAIN ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_SO_GAIN ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_GM_CAL ,0x1b ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW ,0xc0 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_AUX_DATA_TCOARSE_TFINE ,0x30 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_VGA_CAL_CNTRL1 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_VGA_CAL_CNTRL2 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE ,0x7f ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_PI_CONTROLS ,0x70 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2 ,0x0e ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3 ,0x4a ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4 ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_SIGDET_CNTRL ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_SIGDET_ENABLES ,0x1c ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL ,0x1e ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 ,0x17 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_10_LOW ,0xd4 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_10_HIGH ,0x54 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_10_HIGH2 ,0xdb ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_10_HIGH3 ,0x3b ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_10_HIGH4 ,0x31 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_LOW ,0x24 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_00_HIGH2 ,0xff ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_00_HIGH3 ,0x7f ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_DCC_CTRL1 ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH ,0xe4 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH2 ,0xec ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH3 ,0x3b ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH4 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL1 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_00_LOW ,0xbf ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_00_HIGH4 ,0x15 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET ,0x38 ), +}; + +static const struct qmp_pcie_init_tbl sm8250_qmp_gen3x2_pcie_pcs_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V4_PCS_P2U3_WAKEUP_DLY_TIME_AUXCLK_L ,0x01 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_RX_SIGDET_LVL ,0x77 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_RATE_SLEW_CNTRL1 ,0x0b ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_REFGEN_REQ_CONFIG1 ,0x05 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_EQ_CONFIG2 ,0x0f ), +}; + +static const struct qmp_pcie_init_tbl sm8250_qmp_gen3x2_pcie_pcs_misc_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_OSC_DTCT_ACTIONS ,0x00 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L ,0x01 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L ,0x01 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_PRESET_P6_P7_PRE ,0x33 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_PRESET_P10_PRE ,0x00 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_PRESET_P10_POST ,0x58 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_ENDPOINT_REFCLK_DRIVE ,0xc1 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG2 ,0x0d ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCIE_POWER_STATE_CONFIG4 ,0x07 ), +}; +static const struct qmp_pcie_init_tbl sm8550_qmp_gen3x2_pcie_serdes_tbl[] = {QMP_PHY_INIT_CFG (QSERDES_V6_COM_SSC_EN_CENTER ,0x01 ),QMP_PHY_INIT_CFG (QSERDES_V6_COM_SSC_PER1 ,0x62 ),@@ -639,6 +764,21 @@ static const char * const sdm845_pciephy_reset_l[] = { "phy", }; +/* +* SM8250 / Kodiak (QCM6490) Gen3x2 PCIe PHY register offsets. +* serdes=0x0000, tx=0x0200, rx=0x0400, tx2=0x0600, rx2=0x0800, +* pcs=0x0a00, pcs_misc=0x0e00 — fits within the 0x1000 reg window. +*/ +static const struct qmp_pcie_offsets qmp_pcie_offsets_v4x2 = { + .serdes =0 , + .pcs =0x0a00 , + .pcs_misc =0x0e00 , + .tx =0x0200 , + .rx =0x0400 , + .tx2 =0x0600 , + .rx2 =0x0800 , +}; +static const struct qmp_pcie_offsets qmp_pcie_offsets_v5 = { .serdes =0 , .pcs =0x0200 ,@@ -660,6 +800,37 @@ static const struct qmp_pcie_offsets qmp_pcie_offsets_v6_20 = { .ln_shrd = 0x0e00, }; +/* +* SM8250 / Kodiak (QCM6490) Gen3x2 PCIe PHY config (pcie1, x2 lanes). +* Compatible string: "qcom,sm8250-qmp-gen3x2-pcie-phy" +*/ +static const struct qmp_pcie_cfg sm8250_qmp_gen3x2_pciephy_cfg = { + .lanes =2 , + + .offsets = &qmp_pcie_offsets_v4x2, + + .tbls = { + .serdes = sm8250_qmp_pcie_serdes_tbl, + .serdes_num =ARRAY_SIZE (sm8250_qmp_pcie_serdes_tbl), + .tx = sm8250_qmp_gen3x2_pcie_tx_tbl, + .tx_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_tx_tbl), + .rx = sm8250_qmp_gen3x2_pcie_rx_tbl, + .rx_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_rx_tbl), + .pcs = sm8250_qmp_gen3x2_pcie_pcs_tbl, + .pcs_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_pcs_tbl), + .pcs_misc = sm8250_qmp_gen3x2_pcie_pcs_misc_tbl, + .pcs_misc_num =ARRAY_SIZE (sm8250_qmp_gen3x2_pcie_pcs_misc_tbl), + }, + .reset_list = sdm845_pciephy_reset_l, + .num_resets =ARRAY_SIZE (sdm845_pciephy_reset_l), + .vreg_list = qmp_phy_vreg_l, + .num_vregs =ARRAY_SIZE (qmp_phy_vreg_l), + .regs = pciephy_v4_regs_layout, + + .pwrdn_ctrl =SW_PWRDN |REFCLK_DRV_DSBL , + .phy_status =PHYSTATUS , +}; +static const struct qmp_pcie_cfg sm8550_qmp_gen3x2_pciephy_cfg = { .lanes =2 ,@@ -873,8 +1044,10 @@ static int qmp_pcie_power_on(struct phy *phy) } ret =qmp_pcie_do_reset (qmp); -if (ret) +if (ret) { +dev_err (phy->dev,"qmp_pcie_do_reset failed: %d\n" , ret);return ret; + }for (i =0 ; i < qmp->clk_count; i++) { ret =clk_enable (&qmp->clks[i]);@@ -902,6 +1075,7 @@ static int qmp_pcie_power_on(struct phy *phy) status = pcs + cfg->regs[QPHY_PCS_STATUS ]; mask = cfg->phy_status; + ret =readl_poll_timeout (status, val, !(val & mask),PHY_INIT_COMPLETE_TIMEOUT );if (ret) {dev_err (phy->dev,"phy initialization timed-out\n" );@@ -998,8 +1172,12 @@ static int qmp_pcie_clk_init(struct udevice *dev, struct qmp_pcie_priv *qmp)
drivers/phy/qcom/phy-qcom-qmp-pcie.c static int qmp_pcie_clk_init(struct udevice *dev, struct qmp_pcie_priv *qmp) · line 1180
Quoted 10 lines
drivers/phy/qcom/phy-qcom-qmp-pcie.c +6
-2for (i =0 ; i < num; i++) { ret =clk_get_by_name (dev, qmp_pciephy_clk_l[i], &qmp->clks[i]); -/* Ignore failure to get ref clock */ -if (ret &&strcmp (qmp_pciephy_clk_l[i],"ref" ) !=0 ) { +/* +* "ref" is always optional. Kodiak/SM8250 DTS also uses +* "refgen" instead of "rchng", so ignore that too. +*/ +if (ret &&strcmp (qmp_pciephy_clk_l[i],"ref" ) !=0 && +strcmp (qmp_pciephy_clk_l[i],"rchng" ) !=0 ) {
Perhaps add a table with all the possible ref clk names to ignore ?
drivers/phy/qcom/phy-qcom-qmp-pcie.c static struct phy_ops qmp_pcie_ops = { · line 1283
Quoted 13 lines
drivers/phy/qcom/phy-qcom-qmp-pcie.c +3
-0dev_err (dev,"failed to get clock %d\n" , i); goto clk_get_err; }@@ -1097,6 +1275,9 @@ static struct phy_ops qmp_pcie_ops = {static const struct udevice_id qmp_pcie_ids[] = { { + .compatible ="qcom,sm8250-qmp-gen3x2-pcie-phy" , + .data = (ulong)&sm8250_qmp_gen3x2_pciephy_cfg, + }, { .compatible ="qcom,sm8550-qmp-gen3x2-pcie-phy" , .data = (ulong)&sm8550_qmp_gen3x2_pciephy_cfg, }, {
Anyway, it's still fine:
Thanks,
Neil
PATCH 6/9 gpio: qcom_spmi: add pm7250b/pm8350c compatible strings
In reply to Sumit Singh DhamiFrom: Senthilkumar <[email protected]>
Add the missing compatible strings for the PM7250B and PM8350C SPMI PMIC GPIO controllers, needed to bind against DTS nodes that use these PMICs' GPIOs.
--- drivers/gpio/qcom_spmi_gpio.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/qcom_spmi_gpio.c +1 -0
@@ -746,6 +746,7 @@ static const struct udevice_id qcom_spmi_pmic_gpio_ids[] = { { .compatible = "qcom,pm6150l-gpio" }, { .compatible = "qcom,pm6350-gpio" }, { .compatible = "qcom,pm660l-gpio" }, + { .compatible = "qcom,pm7250b-gpio" }, { .compatible = "qcom,pm7325-gpio" }, { .compatible = "qcom,pm7550-gpio" }, { .compatible = "qcom,pm8150l-gpio" },
Signature · 1 line
2.55.0
Re: [PATCH v1 6/9] gpio: qcom_spmi: add pm7250b/pm8350c compatible strings
Quoted 17 lines · Sumit Singh Dhami
From: Senthilkumar <[email protected]>
Add the missing compatible strings for the PM7250B and PM8350C SPMI PMIC GPIO controllers, needed to bind against DTS nodes that use these PMICs' GPIOs.
Signed-off-by Senthilkumar <[email protected]>Signed-off-by Sumit Singh Dhami <[email protected]>--- drivers/gpio/qcom_spmi_gpio.c | 1 + 1 file changed, 1 insertion(+)drivers/gpio/qcom_spmi_gpio.c +0
-0
drivers/gpio/qcom_spmi_gpio.c static const struct udevice_id qcom_spmi_pmic_gpio_ids[] = { · line 752
Quoted 7 lines
drivers/gpio/qcom_spmi_gpio.c +1
-0@@ -746,6 +746,7 @@ static const struct udevice_id qcom_spmi_pmic_gpio_ids[] = { { .compatible = "qcom,pm6150l-gpio" }, { .compatible = "qcom,pm6350-gpio" }, { .compatible = "qcom,pm660l-gpio" }, + { .compatible = "qcom,pm7250b-gpio" }, { .compatible = "qcom,pm7325-gpio" }, { .compatible = "qcom,pm7550-gpio" }, { .compatible = "qcom,pm8150l-gpio" },
Thanks,
Neil
PATCH 7/9 arm: mach-snapdragon: add QCS6490 PCIe1 power/reset sequencing
In reply to Sumit Singh DhamiFrom: Senthilkumar <[email protected]>
The QPS615 PCIe switch and downstream Renesas uPD720201 xHCI controller on QCS6490/RB3 Gen2 need their reset and power-enable lines sequenced before PCIe enumeration. A static DT gpio-hog only drives a fixed level once at probe, so it cannot re-assert again on a warm reboot while the PMIC rails stay powered.
Add a qcom_board_init() override that drives these reset/power-enable GPIOs directly via the DM GPIO API, issuing a real assert-hold-deassert pulse on every boot.
Gate the override behind the CONFIG_QCS6490_PCIE_INIT option.
--- arch/arm/mach-snapdragon/Kconfig | 9 + arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/qcs6490_pcie_init.c | 178 +++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 arch/arm/mach-snapdragon/qcs6490_pcie_init.c
arch/arm/mach-snapdragon/Kconfig +9 -0
@@ -59,6 +59,15 @@ config QCOM_GENERATE_MBN New platforms can be added to tools/qcom/mkmbn/mkmbn.py if they aren't already supported. +config QCS6490_PCIE_INIT + bool "QCS6490 RB3 Gen2 PCIe1 power/reset sequencing" + depends on DM_GPIO + help + Drive the PCIe1 downstream power-enable and reset GPIOs for the + QPS615 PCIe switch and Renesas uPD720201 xHCI controller on + QCS6490/RB3 Gen2 during board init. This overrides the weak + qcom_board_init() in QCS6490. + choice prompt "Qualcomm boot0.h workaround" optional
arch/arm/mach-snapdragon/Makefile +1 -0
@@ -9,6 +9,7 @@ ifeq ($(CONFIG_SPL_BUILD),y) obj-y += board_spl.o else obj-y += board.o +obj-$(CONFIG_QCS6490_PCIE_INIT) += qcs6490_pcie_init.o obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += capsule_update.o endif
arch/arm/mach-snapdragon/qcs6490_pcie_init.c new file +178 -0
178 lines not on this page · raw message
Signature · 1 line
2.55.0
Casey Connolly
NAKRe: [PATCH v1 7/9] arm: mach-snapdragon: add QCS6490 PCIe1 power/reset sequencing
Quoted 11 lines · Sumit Singh Dhami
From: Senthilkumar <[email protected]>
The QPS615 PCIe switch and downstream Renesas uPD720201 xHCI controller on QCS6490/RB3 Gen2 need their reset and power-enable lines sequenced before PCIe enumeration. A static DT gpio-hog only drives a fixed level once at probe, so it cannot re-assert again on a warm reboot while the PMIC rails stay powered.
Add a
qcom_board_init()override that drives these reset/power-enable GPIOs directly via the DM GPIO API, issuing a real assert-hold-deassert pulse on every boot.
NAK, we have a driver model for a reason, use it. Please also write commit messages/comments by hand, this is a lot of words that say basically nothing about this patch.
Quoted 228 lines
Gate the override behind the
CONFIG_QCS6490_PCIE_INIToption.Signed-off-by Senthilkumar <[email protected]>Signed-off-by Sumit Singh Dhami <[email protected]>--- arch/arm/mach-snapdragon/Kconfig | 9 + arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/qcs6490_pcie_init.c | 178 +++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 arch/arm/mach-snapdragon/qcs6490_pcie_init.carch/arm/mach-snapdragon/Kconfig +9
-0@@ -59,6 +59,15 @@ config QCOM_GENERATE_MBN New platforms can be added to tools/qcom/mkmbn/mkmbn.py if they aren't already supported. +config QCS6490_PCIE_INIT + bool "QCS6490 RB3 Gen2 PCIe1 power/reset sequencing" + depends on DM_GPIO + help + Drive the PCIe1 downstream power-enable and reset GPIOs for the + QPS615 PCIe switch and Renesas uPD720201 xHCI controller on + QCS6490/RB3 Gen2 during board init. This overrides the weak + qcom_board_init() in QCS6490. + choice prompt "Qualcomm boot0.h workaround" optionalarch/arm/mach-snapdragon/Makefile +1
-0@@ -9,6 +9,7 @@ ifeq ($(CONFIG_SPL_BUILD),y) obj-y += board_spl.o else obj-y += board.o +obj-$(CONFIG_QCS6490_PCIE_INIT) += qcs6490_pcie_init.o obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += capsule_update.o endifarch/arm/mach-snapdragon/qcs6490_pcie_init.c new file +178
-0@@ -0,0 +1,178 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* QCS6490 / RB3 Gen2 PCIe power/reset initialization. +* +* Drives the PCIe1 (RC1) downstream power-enable and reset lines for the +* QPS615 PCIe switch and the Renesas uPD720201 xHCI controller directly +* via the DM GPIO API, issuing a real assert -> hold -> deassert pulse +* on every boot (see commit message for why a DT gpio-hog is not enough). +* +* Hardware topology (pcie1, RC1, x2 lanes): +* Kodiak PCIe RC1 -> QPS615 PCIe switch -> Renesas uPD720201 xHCI +* +* Power/reset lines: +* QPS615 switch: +* vdd_ntn_0p9/vdd_ntn_1p8 - regulator-fixed nodes, self-enabled via DT +* resx - PM8350C GPIO 1, active-low reset +* +* Renesas uPD720201 xHCI (downstream of the switch): +* vreg_pcie0_3p3 - PM7250B GPIO 1 output-high -> 3.3V supply enable +* vreg_pcie0_1p05 - PM7250B GPIO 4 output-high -> 1.05V supply enable +* hub_rst - PM8350C GPIO 4, active-low reset +* +* Copyright (c) Qualcomm Technologies, Inc. All rights reserved. +*/ + +#include <asm/gpio.h> +#include <dm.h> +#include <dm/uclass.h> +#include <linux/delay.h> +#include <log.h> + +/* +* PM8350C/PM7250B PMIC GPIO numbers used here are 1-based in the DT; the +* DM GPIO offset within the qcom_spmi_pmic_gpio device is 0-based. +*/ +#define PM8350C_RESX_OFFSET 0/* gpio1: QPS615 resx */ +#define PM8350C_HUB_RST_OFFSET 3/* gpio4: Renesas hub reset */ +#define PM7250B_PCIE0_3P3_OFFSET 0/* gpio1: 3.3V enable */ +#define PM7250B_PCIE0_1P05_OFFSET 3/* gpio4: 1.05V enable */ + +/* Settle delays, matching the fixed regulators' own ramp delays */ +#define PCIE0_3P3_RAMP_US 4300 +#define PCIE0_1P05_RAMP_US 10000 +#define RESET_HOLD_MS 15/* reset-low hold through rail ramp */ +#define PCIE_POWER_SETTLE_MS 15/* margin after resets deasserted */ + +/** +* pmic_gpio_get_desc() - Build a gpio_desc for a PMIC GPIO offset and request it +* +* @gpio_dev: PMIC GPIO uclass device (e.g. resolved via pmic_gpio_uclass_get()) +* @offset: 0-based GPIO offset within @gpio_dev +* @label: descriptive label for the request +* @desc: returned descriptor +* +* Return: 0 on success, negative on error +*/ +static int pmic_gpio_get_desc (struct udevice *gpio_dev,uint offset, +const char *label,struct gpio_desc *desc) +{ + desc->dev = gpio_dev; + desc->offset = offset; + desc->flags =0 ; + +return dm_gpio_request (desc, label); +} + +/** +* pmic_gpio_drive() - Configure a PMIC GPIO as output and drive it high/low +*/ +static int pmic_gpio_drive (struct gpio_desc *desc,int value) +{ +ulong flags =GPIOD_IS_OUT | (value ?GPIOD_IS_OUT_ACTIVE :0 ); +int ret; + + ret =dm_gpio_set_dir_flags (desc, flags); +if (ret) +return ret; + +return dm_gpio_set_value (desc, value); +} + +/** +* pmic_gpio_uclass_get() - Find a PMIC GPIO controller by its DT compatible +* +* pm8350c_gpios/pm7250b_gpios are DT phandle labels, not U-Boot device +* names (the device name comes from the DT node name, e.g. "gpio@8800"), +* so uclass_get_device_by_name() cannot find them. Look up by compatible +* string instead, which is unique per PMIC on this board. +*/ +static int pmic_gpio_uclass_get (const char *compat,struct udevice **devp) +{ +ofnode node; + + node =ofnode_by_compatible (ofnode_null (), compat); +if (!ofnode_valid (node)) +return -ENODEV ; + +return uclass_get_device_by_ofnode (UCLASS_GPIO , node, devp); +} + +/** +* qcs6490_pcie_power_init() - Sequence PCIe1 downstream power and resets +* +* Assert both resets low first, enable the Renesas power rails, hold the +* resets through the rail ramp-up + settle time, then deassert both. +* Runs unconditionally on every boot (cold or warm). +* +* Return: 0 on success (non-fatal if a PMIC GPIO bus is not found) +*/ +static int qcs6490_pcie_power_init (void ) +{ +struct udevice *pm8350c_gpio, *pm7250b_gpio; +struct gpio_desc resx, hub_rst, pcie0_3p3, pcie0_1p05; +int ret; + + ret =pmic_gpio_uclass_get ("qcom,pm8350c-gpio" , &pm8350c_gpio); +if (ret) { +log_warning ("pm8350c_gpios not found (%d), skipping PCIe power init\n" , + ret); +return 0 ;/* non-fatal */ + } + + ret =pmic_gpio_uclass_get ("qcom,pm7250b-gpio" , &pm7250b_gpio); +if (ret) { +log_warning ("pm7250b_gpios not found (%d), skipping PCIe power init\n" , + ret); +return 0 ;/* non-fatal */ + } + +if (pmic_gpio_get_desc (pm8350c_gpio,PM8350C_RESX_OFFSET , +"qps615-resx" , &resx) || +pmic_gpio_get_desc (pm8350c_gpio,PM8350C_HUB_RST_OFFSET , +"renesas-hub-reset" , &hub_rst) || +pmic_gpio_get_desc (pm7250b_gpio,PM7250B_PCIE0_3P3_OFFSET , +"vreg-pcie0-3p3-en" , &pcie0_3p3) || +pmic_gpio_get_desc (pm7250b_gpio,PM7250B_PCIE0_1P05_OFFSET , +"vreg-pcie0-1p05-en" , &pcie0_1p05)) { +log_warning ("failed to request PCIe power/reset GPIOs\n" ); +return 0 ;/* non-fatal */ + } + +/* Assert both resets low before touching power rails */ +pmic_gpio_drive (&resx,0 ); +pmic_gpio_drive (&hub_rst,0 ); + +/* Renesas xHCI 3.3V */ +pmic_gpio_drive (&pcie0_3p3,1 ); +udelay (PCIE0_3P3_RAMP_US ); + +/* Renesas xHCI 1.05V */ +pmic_gpio_drive (&pcie0_1p05,1 ); +udelay (PCIE0_1P05_RAMP_US ); + +/* Hold resets asserted through the rail ramp-up */ +mdelay (RESET_HOLD_MS ); + +/* Deassert both resets (active-low -> drive high) */ +pmic_gpio_drive (&resx,1 ); +pmic_gpio_drive (&hub_rst,1 ); + +mdelay (PCIE_POWER_SETTLE_MS ); + +return 0 ; +} + +/** +* qcom_board_init() - QCS6490 / RB3 Gen2 board-specific initialization +* +* Overrides the empty __weak qcom_board_init() in mach-snapdragon/board.c. +* Sequences PCIe1 downstream power/reset so RC1 enumeration works reliably +* on both cold boot and warm reboot. +*/ +void qcom_board_init (void ) +{ +if (ofnode_device_is_compatible (ofnode_root (),"qcom,qcm6490" ) || +ofnode_device_is_compatible (ofnode_root (),"qcom,qcs6490" )) +qcs6490_pcie_power_init (); +}
Signature · 1 line
// Casey (she/her)
PATCH 8/9 iommu: add PCI stream-ID resolution for devices without an ofnode
In reply to Sumit Singh DhamiFrom: Senthilkumar <[email protected]>
dev_iommu_enable() returns early for any device without an ofnode, making the dev_pci_iommu_enable() PCI iommu-map fallback unreachable. That fallback also only resolve which IOMMU a device belongs to, not its stream ID, so ops->connect() has no ID to classify the device with. Separately, qcom-hyp-smmu.c disables stream classification at EL2, but firmware converts an unclaimed stream to a FAULT stream regardless of the CPU's exception level, blocking DMA for downstream PCIe/UFS masters.
Restructure dev_iommu_enable() to fall through to the PCI iommu-map path when there is no ofnode. Extend dev_pci_iommu_enable() to resolve and store the stream ID in the new pci_iommu_sid field and call ops->connect(). Wire this field to get_stream_id(), and drop the EL2 self-disable.
--- drivers/iommu/iommu-uclass.c | 78 +++++++++++++++++++++-------------- drivers/iommu/qcom-hyp-smmu.c | 27 +++++++----- include/dm/device.h | 7 ++++ 3 files changed, 70 insertions(+), 42 deletions(-)
drivers/iommu/iommu-uclass.c +47 -31
@@ -18,8 +18,9 @@ static int dev_pci_iommu_enable(struct udevice *dev) {struct udevice *parent = dev->parent;struct udevice *dev_iommu; +const struct iommu_ops *ops;u32 *iommu_map; -u32 iommu_map_mask, length, phandle, rid, rid_base; +u32 iommu_map_mask, length, phandle, rid, rid_base, iommu_base;int i, count, len, ret;while (parent) {
@@ -50,6 +51,7 @@ static int dev_pci_iommu_enable(struct udevice *dev)for (i =0 ; i < count; i +=4 ) { rid_base = iommu_map[i]; phandle = iommu_map[i +1 ]; + iommu_base = iommu_map[i +2 ]; length = iommu_map[i +3 ];if (rid < rid_base || rid >= rid_base + length)
@@ -64,6 +66,18 @@ static int dev_pci_iommu_enable(struct udevice *dev)return ret; } dev->iommu = dev_iommu; + dev->pci_iommu_sid = iommu_base + (rid - rid_base); + + ops =device_get_ops (dev->iommu); +if (ops && ops->connect) { + ret = ops->connect (dev); +if (ret) { +log_err ("%s: Failed to connect '%s' to IOMMU '%s': %d\n" , + __func__, dev->name, dev->iommu->name, ret); +free (iommu_map); +return ret; + } + }break ; }
@@ -79,41 +93,43 @@ int dev_iommu_enable(struct udevice *dev)const struct iommu_ops *ops;int i, count, ret =0 ; -if (!dev_has_ofnode (dev)) -return 0 ; - - count =dev_count_phandle_with_args (dev,"iommus" , -"#iommu-cells" ,0 ); -for (i =0 ; i < count; i++) { - ret =dev_read_phandle_with_args (dev,"iommus" , -"#iommu-cells" ,0 , i, &args); -if (ret) { -log_err ("%s: Failed to parse 'iommus' property for '%s': %d\n" , - __func__, dev->name, ret); -return ret; - } - - ret =uclass_get_device_by_ofnode (UCLASS_IOMMU , args.node, - &dev_iommu); -if (ret) { -log_err ("%s: Failed to find IOMMU device for '%s': %d\n" , - __func__, dev->name, ret); -return ret; - } - dev->iommu = dev_iommu; - -if (dev->parent && dev->parent->iommu == dev_iommu) -continue ; +if (dev_has_ofnode (dev)) { + count =dev_count_phandle_with_args (dev,"iommus" , +"#iommu-cells" ,0 ); +for (i =0 ; i < count; i++) { + ret =dev_read_phandle_with_args (dev,"iommus" , +"#iommu-cells" ,0 , i, + &args); +if (ret) { +log_err ("%s: Failed to parse 'iommus' property for '%s': %d\n" , + __func__, dev->name, ret); +return ret; + } - ops =device_get_ops (dev->iommu); -if (ops && ops->connect) { - ret = ops->connect (dev); + ret =uclass_get_device_by_ofnode (UCLASS_IOMMU , args.node, + &dev_iommu);if (ret) { -log_err ("%s: Failed to connect '%s' to IOMMU '%s': %d\n" , - __func__, dev->name, dev->iommu->name, ret); +log_err ("%s: Failed to find IOMMU device for '%s': %d\n" , + __func__, dev->name, ret);return ret; } + dev->iommu = dev_iommu; + +if (dev->parent && dev->parent->iommu == dev_iommu) +continue ; + + ops =device_get_ops (dev->iommu); +if (ops && ops->connect) { + ret = ops->connect (dev); +if (ret) { +log_err ("%s: Failed to connect '%s' to IOMMU '%s': %d\n" , + __func__, dev->name, dev->iommu->name, ret); +return ret; + } + } } + }else { + count =-1 ; }#if CONFIG_IS_ENABLED (PCI )
drivers/iommu/qcom-hyp-smmu.c +16 -11
@@ -7,7 +7,6 @@*/ #include <log.h> -#include <cpu_func.h> #include <dm.h> #include <iommu.h> #include <linux/bitfield.h>
@@ -92,8 +91,6 @@ struct qcom_smmu_priv {phys_addr_t base;struct list_head devices;struct udevice *dev; -/* SMMU is not needed when running in EL2 */ -bool disable;/* Read-once config */ int num_cb;
@@ -132,12 +129,25 @@ struct mmu_dev {static int get_stream_id (struct udevice *dev) { -ofnode node =dev_ofnode (dev); +ofnode node;struct ofnode_phandle_args args; -int count =ofnode_parse_phandle_with_args (node,"iommus" , -"#iommu-cells" ,0 ,0 , &args); +int count; + +if (!dev_has_ofnode (dev)) +return dev->pci_iommu_sid; + + node =dev_ofnode (dev); + count =ofnode_parse_phandle_with_args (node,"iommus" , +"#iommu-cells" ,0 ,0 , &args);if (count <0 ) { +/* +* No "iommus" property of its own: PCI endpoint resolved +* via an ancestor's iommu-map property instead. +*/ +if (device_is_on_pci_bus (dev)) +return dev->pci_iommu_sid; +printf ("Error: %s: iommus property not found or wrong number of cells\n" , __func__);return -EINVAL ;
@@ -280,9 +290,6 @@ static int qcom_smmu_connect(struct udevice *dev)if (WARN_ON (!priv))return -EINVAL ; -if (priv->disable) -return 0 ; - mdev =alloc_dev (dev);if (IS_ERR (mdev) &&PTR_ERR (mdev) != -EEXIST ) { printf("%s: %s Couldn't create mmu context\n", __func__,
@@ -354,8 +361,6 @@ static int qcom_smmu_probe(struct udevice *dev) priv->base =dev_read_addr (dev);INIT_LIST_HEAD (&priv->devices); - priv->disable =current_el () >1 ; -/* Read SMMU config */ val =gr0_readl (priv,ARM_SMMU_GR0_ID0 ); priv->num_smr =FIELD_GET (ARM_SMMU_ID0_NUMSMRG , val);
include/dm/device.h +7 -0
@@ -203,6 +203,13 @@ struct udevice {#endif #if CONFIG_IS_ENABLED (IOMMU )struct udevice *iommu; +/* +* Stream ID resolved from a PCI iommu-map property, for devices +* that have no ofnode of their own to carry an "iommus" property +* (e.g. dynamically enumerated PCI endpoints). Valid only when +* iommu is set and the device has no "iommus" property of its own. +*/ +u32 pci_iommu_sid;#endif };
Signature · 1 line
2.55.0
[email protected]
reviewerRe: [PATCH v1 8/9] iommu: add PCI stream-ID resolution for devices without an ofnode
Quoted 10 lines · Sumit Singh Dhami
From: Senthilkumar <[email protected]>
dev_iommu_enable()returns early for any device without an ofnode, making thedev_pci_iommu_enable()PCI iommu-map fallback unreachable. That fallback also only resolve which IOMMU a device belongs to, not its stream ID, soops->connect()has no ID to classify the device with. Separately,qcom-hyp-smmu.cdisables stream classification at EL2, but firmware converts an unclaimed stream to a FAULT stream regardless of the CPU's exception level, blocking DMA for downstream PCIe/UFS masters.
Quoted 5 lines
Restructure
dev_iommu_enable()to fall through to the PCI iommu-map path when there is no ofnode. Extenddev_pci_iommu_enable()to resolve and store the stream ID in the newpci_iommu_sidfield and callops->connect(). Wire this field toget_stream_id(), and drop the EL2 self-disable.
I think it would be preferable to either:
- add the sid as a parameter of ops->connect()
or
- add a new ops->connect_pci(u32 sid) dedicated to PCIe endpoints if you don't want to touch the other IOMMU controller drivers.
I don't think it's a good idea to polute struct udevice with the pci sid.
And then please split out the qcom-hyp-smmu into a separate change, first adding the connect_pci() and then enabling for EL2.
FYI I have a similar changeset in dev:
https://gitlab.com/superna9999/u-boot/-/commit/f08275fa955106deb3a03eac8f735919a824dc15
https://gitlab.com/superna9999/u-boot/-/commit/6b381f8a17e75c19044eb52a4e6b29fcde4e9a43
https://gitlab.com/superna9999/u-boot/-/commit/5b248f5d32cd742029d5eda9cea07de98d153a0a
which is functionally similar.
Thanks,
Neil
Quoted 212 lines
Signed-off-by Senthilkumar <[email protected]>Signed-off-by Sumit Singh Dhami <[email protected]>--- drivers/iommu/iommu-uclass.c | 78 +++++++++++++++++++++-------------- drivers/iommu/qcom-hyp-smmu.c | 27 +++++++----- include/dm/device.h | 7 ++++ 3 files changed, 70 insertions(+), 42 deletions(-)drivers/iommu/iommu-uclass.c +47
-31@@ -18,8 +18,9 @@ static int dev_pci_iommu_enable(struct udevice *dev) {struct udevice *parent = dev->parent;struct udevice *dev_iommu; +const struct iommu_ops *ops;u32 *iommu_map; -u32 iommu_map_mask, length, phandle, rid, rid_base; +u32 iommu_map_mask, length, phandle, rid, rid_base, iommu_base;int i, count, len, ret;while (parent) {@@ -50,6 +51,7 @@ static int dev_pci_iommu_enable(struct udevice *dev)for (i =0 ; i < count; i +=4 ) { rid_base = iommu_map[i]; phandle = iommu_map[i +1 ]; + iommu_base = iommu_map[i +2 ]; length = iommu_map[i +3 ];if (rid < rid_base || rid >= rid_base + length)@@ -64,6 +66,18 @@ static int dev_pci_iommu_enable(struct udevice *dev)return ret; } dev->iommu = dev_iommu; + dev->pci_iommu_sid = iommu_base + (rid - rid_base); + + ops =device_get_ops (dev->iommu); +if (ops && ops->connect) { + ret = ops->connect (dev); +if (ret) { +log_err ("%s: Failed to connect '%s' to IOMMU '%s': %d\n" , + __func__, dev->name, dev->iommu->name, ret); +free (iommu_map); +return ret; + } + }break ; }@@ -79,41 +93,43 @@ int dev_iommu_enable(struct udevice *dev)const struct iommu_ops *ops;int i, count, ret =0 ; -if (!dev_has_ofnode (dev)) -return 0 ; - - count =dev_count_phandle_with_args (dev,"iommus" , -"#iommu-cells" ,0 ); -for (i =0 ; i < count; i++) { - ret =dev_read_phandle_with_args (dev,"iommus" , -"#iommu-cells" ,0 , i, &args); -if (ret) { -log_err ("%s: Failed to parse 'iommus' property for '%s': %d\n" , - __func__, dev->name, ret); -return ret; - } - - ret =uclass_get_device_by_ofnode (UCLASS_IOMMU , args.node, - &dev_iommu); -if (ret) { -log_err ("%s: Failed to find IOMMU device for '%s': %d\n" , - __func__, dev->name, ret); -return ret; - } - dev->iommu = dev_iommu; - -if (dev->parent && dev->parent->iommu == dev_iommu) -continue ; +if (dev_has_ofnode (dev)) { + count =dev_count_phandle_with_args (dev,"iommus" , +"#iommu-cells" ,0 ); +for (i =0 ; i < count; i++) { + ret =dev_read_phandle_with_args (dev,"iommus" , +"#iommu-cells" ,0 , i, + &args); +if (ret) { +log_err ("%s: Failed to parse 'iommus' property for '%s': %d\n" , + __func__, dev->name, ret); +return ret; + } - ops =device_get_ops (dev->iommu); -if (ops && ops->connect) { - ret = ops->connect (dev); + ret =uclass_get_device_by_ofnode (UCLASS_IOMMU , args.node, + &dev_iommu);if (ret) { -log_err ("%s: Failed to connect '%s' to IOMMU '%s': %d\n" , - __func__, dev->name, dev->iommu->name, ret); +log_err ("%s: Failed to find IOMMU device for '%s': %d\n" , + __func__, dev->name, ret);return ret; } + dev->iommu = dev_iommu; + +if (dev->parent && dev->parent->iommu == dev_iommu) +continue ; + + ops =device_get_ops (dev->iommu); +if (ops && ops->connect) { + ret = ops->connect (dev); +if (ret) { +log_err ("%s: Failed to connect '%s' to IOMMU '%s': %d\n" , + __func__, dev->name, dev->iommu->name, ret); +return ret; + } + } } + }else { + count =-1 ; }#if CONFIG_IS_ENABLED (PCI )drivers/iommu/qcom-hyp-smmu.c +16
-11@@ -7,7 +7,6 @@*/ #include <log.h> -#include <cpu_func.h> #include <dm.h> #include <iommu.h> #include <linux/bitfield.h> @@ -92,8 +91,6 @@ struct qcom_smmu_priv {phys_addr_t base;struct list_head devices;struct udevice *dev; -/* SMMU is not needed when running in EL2 */ -bool disable;/* Read-once config */ int num_cb;@@ -132,12 +129,25 @@ struct mmu_dev {static int get_stream_id (struct udevice *dev) { -ofnode node =dev_ofnode (dev); +ofnode node;struct ofnode_phandle_args args; -int count =ofnode_parse_phandle_with_args (node,"iommus" , -"#iommu-cells" ,0 ,0 , &args); +int count; + +if (!dev_has_ofnode (dev)) +return dev->pci_iommu_sid; + + node =dev_ofnode (dev); + count =ofnode_parse_phandle_with_args (node,"iommus" , +"#iommu-cells" ,0 ,0 , &args);if (count <0 ) { +/* +* No "iommus" property of its own: PCI endpoint resolved +* via an ancestor's iommu-map property instead. +*/ +if (device_is_on_pci_bus (dev)) +return dev->pci_iommu_sid; +printf ("Error: %s: iommus property not found or wrong number of cells\n" , __func__);return -EINVAL ;@@ -280,9 +290,6 @@ static int qcom_smmu_connect(struct udevice *dev)if (WARN_ON (!priv))return -EINVAL ; -if (priv->disable) -return 0 ; - mdev =alloc_dev (dev);if (IS_ERR (mdev) &&PTR_ERR (mdev) != -EEXIST ) { printf("%s: %s Couldn't create mmu context\n", __func__,@@ -354,8 +361,6 @@ static int qcom_smmu_probe(struct udevice *dev) priv->base =dev_read_addr (dev);INIT_LIST_HEAD (&priv->devices); - priv->disable =current_el () >1 ; -/* Read SMMU config */ val =gr0_readl (priv,ARM_SMMU_GR0_ID0 ); priv->num_smr =FIELD_GET (ARM_SMMU_ID0_NUMSMRG , val);include/dm/device.h +7
-0@@ -203,6 +203,13 @@ struct udevice {#endif #if CONFIG_IS_ENABLED (IOMMU )struct udevice *iommu; +/* +* Stream ID resolved from a PCI iommu-map property, for devices +* that have no ofnode of their own to carry an "iommus" property +* (e.g. dynamically enumerated PCI endpoints). Valid only when +* iommu is set and the device has no "iommus" property of its own. +*/ +u32 pci_iommu_sid;#endif };
PATCH 9/9 configs: qcom_defconfig: enable PCIe1 RC/PHY and qcom_board_init override for QCS6490
In reply to Sumit Singh DhamiFrom: Senthilkumar <[email protected]>
Enable the generic PCI subsystem, the PCI command, and the Qualcomm DesignWare PCIe controller and QMP PCIe PHY drivers needed to bring up PCIe1 (RC1), which on RB3 Gen2 connects to a QPS615 PCIe switch.
Also, enable QCS6490_PCIE_INIT to override the __weak qcom_board_init() in mach-snapdragon/board.c for QCS6490 / RB3 Gen2 platform.
--- configs/qcm6490_defconfig | 1 + configs/qcom_defconfig | 7 +++++++ 2 files changed, 8 insertions(+)
configs/qcm6490_defconfig +1 -0
@@ -16,6 +16,7 @@ CONFIG_DEFAULT_DEVICE_TREE="qcom/qcs6490-rb3gen2" CONFIG_FASTBOOT_BUF_ADDR=0xd8800000 CONFIG_PHY_QCOM_QMP_COMBO=y +CONFIG_QCS6490_PCIE_INIT=y CONFIG_FASTBOOT_FLASH_BLOCK=y CONFIG_FASTBOOT_FLASH_BLOCK_INTERFACE_NAME="scsi"
configs/qcom_defconfig +7 -0
@@ -111,7 +111,12 @@ CONFIG_DWC_ETH_QOS_QCOM=y CONFIG_RGMII=y CONFIG_PHY_MICREL=y CONFIG_PHY_MICREL_KSZ90X1=y +CONFIG_PCI=y +CONFIG_PCI_PNP=y +CONFIG_CMD_PCI=y +CONFIG_PCIE_DW_QCOM=y CONFIG_PHY=y +CONFIG_PHY_QCOM_QMP_PCIE=y CONFIG_PHY_QCOM_QMP_COMBO=y CONFIG_PHY_QCOM_QMP_UFS=y CONFIG_PHY_QCOM_QUSB2=y
@@ -143,6 +148,8 @@ CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_GADGET=y +CONFIG_USB_HOST_ETHER=y +CONFIG_USB_ETHER_ASIX88179=y CONFIG_UFS=y CONFIG_UFS_QCOM=y CONFIG_VIDEO=y
Signature · 1 line
2.55.0