pci_endpoint: pci_cdns_ti_ep: Enable PCIe Endpoint mode in J784S4 SoC
authorHrushikesh Salunke <h-salunke@ti.com>
Thu, 23 Oct 2025 11:46:03 +0000 (17:16 +0530)
committerTom Rini <trini@konsulko.com>
Fri, 7 Nov 2025 22:08:49 +0000 (16:08 -0600)
TI's J784S4 SoC has two instances of PCIe Controller namely PCIe0 and
PCIe1 which are Cadence PCIe Controllers. Add support to configure PCIe
instances in Endpoint mode of operation.

While at it disable all endpoint functions except function 0 during
probe to prevent the Root Complex from enumerating unconfigured
functions. This ensures only  properly configured endpoint functions
are visible to the host and avoids enumeration issues with
multi-function devices.

Signed-off-by: Hrushikesh Salunke <h-salunke@ti.com>
drivers/pci_endpoint/pcie_cdns_ti_ep.c

index dd3dc93..021bd73 100644 (file)
@@ -275,9 +275,11 @@ static int pcie_cdns_ti_ep_probe(struct udevice *dev)
        struct pcie_cdns_ti_ep *pcie = dev_get_priv(dev);
        struct pcie_cdns_ti_ep_data *data;
        struct power_domain pci_pwrdmn;
+       struct cdns_pcie pcie_dev;
        struct clk *clk;
        int ret;
 
+       pcie_dev.reg_base = pcie->reg_base;
        pcie->dev = dev;
        data = (struct pcie_cdns_ti_ep_data *)dev_get_driver_data(dev);
        if (!data)
@@ -328,6 +330,13 @@ static int pcie_cdns_ti_ep_probe(struct udevice *dev)
                return ret;
        }
 
+       /*
+        * Disable all the functions except function 0 (anyway BIT(0) is
+        * hardwired to 1). This is required to avoid RC from enumerating
+        * those functions which are not even configured.
+        */
+       cdns_pcie_writel(&pcie_dev, CDNS_PCIE_LM_EP_FUNC_CFG, BIT(0));
+
        return 0;
 }
 
@@ -389,11 +398,19 @@ static const struct pcie_cdns_ti_ep_data am64_pcie_ep_data = {
        .max_lanes = 1,
 };
 
+static const struct pcie_cdns_ti_ep_data j784s4_pcie_ep_data = {
+       .max_lanes = 4,
+};
+
 static const struct udevice_id pcie_cdns_ti_ep_ids[] = {
        {
                .compatible = "ti,am64-pcie-ep",
                .data = (ulong)&am64_pcie_ep_data,
        },
+       {
+               .compatible = "ti,j784s4-pcie-ep",
+               .data = (ulong)&j784s4_pcie_ep_data,
+       },
        {},
 };