Skip to content

Commit a2790bf

Browse files
PCI: j721e: Add support to build as a loadable module
The 'pci-j721e.c' driver is the application/glue/wrapper driver for the Cadence PCIe Controllers on TI SoCs. Implement support for building it as a loadable module. Signed-off-by: Siddharth Vadapalli <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 3a4b05c commit a2790bf

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

drivers/pci/controller/cadence/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ config PCIE_CADENCE_PLAT_EP
4343
different vendors SoCs.
4444

4545
config PCI_J721E
46-
bool
46+
tristate
4747

4848
config PCI_J721E_HOST
49-
bool "TI J721E PCIe controller (host mode)"
49+
tristate "TI J721E PCIe controller (host mode)"
5050
depends on ARCH_K3 || COMPILE_TEST
5151
depends on OF
5252
select PCIE_CADENCE_HOST
@@ -57,7 +57,7 @@ config PCI_J721E_HOST
5757
core.
5858

5959
config PCI_J721E_EP
60-
bool "TI J721E PCIe controller (endpoint mode)"
60+
tristate "TI J721E PCIe controller (endpoint mode)"
6161
depends on ARCH_K3 || COMPILE_TEST
6262
depends on OF
6363
depends on PCI_ENDPOINT

drivers/pci/controller/cadence/pci-j721e.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/irqchip/chained_irq.h>
1616
#include <linux/irqdomain.h>
1717
#include <linux/mfd/syscon.h>
18+
#include <linux/module.h>
1819
#include <linux/of.h>
1920
#include <linux/pci.h>
2021
#include <linux/platform_device.h>
@@ -27,6 +28,7 @@
2728
#define cdns_pcie_to_rc(p) container_of(p, struct cdns_pcie_rc, pcie)
2829

2930
#define ENABLE_REG_SYS_2 0x108
31+
#define ENABLE_CLR_REG_SYS_2 0x308
3032
#define STATUS_REG_SYS_2 0x508
3133
#define STATUS_CLR_REG_SYS_2 0x708
3234
#define LINK_DOWN BIT(1)
@@ -116,6 +118,15 @@ static irqreturn_t j721e_pcie_link_irq_handler(int irq, void *priv)
116118
return IRQ_HANDLED;
117119
}
118120

121+
static void j721e_pcie_disable_link_irq(struct j721e_pcie *pcie)
122+
{
123+
u32 reg;
124+
125+
reg = j721e_pcie_intd_readl(pcie, ENABLE_CLR_REG_SYS_2);
126+
reg |= pcie->linkdown_irq_regfield;
127+
j721e_pcie_intd_writel(pcie, ENABLE_CLR_REG_SYS_2, reg);
128+
}
129+
119130
static void j721e_pcie_config_link_irq(struct j721e_pcie *pcie)
120131
{
121132
u32 reg;
@@ -633,9 +644,22 @@ static void j721e_pcie_remove(struct platform_device *pdev)
633644
struct j721e_pcie *pcie = platform_get_drvdata(pdev);
634645
struct cdns_pcie *cdns_pcie = pcie->cdns_pcie;
635646
struct device *dev = &pdev->dev;
647+
struct cdns_pcie_ep *ep;
648+
struct cdns_pcie_rc *rc;
649+
650+
if (pcie->mode == PCI_MODE_RC) {
651+
rc = container_of(cdns_pcie, struct cdns_pcie_rc, pcie);
652+
cdns_pcie_host_disable(rc);
653+
} else {
654+
ep = container_of(cdns_pcie, struct cdns_pcie_ep, pcie);
655+
cdns_pcie_ep_disable(ep);
656+
}
657+
658+
gpiod_set_value_cansleep(pcie->reset_gpio, 0);
636659

637660
clk_disable_unprepare(pcie->refclk);
638661
cdns_pcie_disable_phy(cdns_pcie);
662+
j721e_pcie_disable_link_irq(pcie);
639663
pm_runtime_put(dev);
640664
pm_runtime_disable(dev);
641665
}
@@ -730,4 +754,8 @@ static struct platform_driver j721e_pcie_driver = {
730754
.pm = pm_sleep_ptr(&j721e_pcie_pm_ops),
731755
},
732756
};
733-
builtin_platform_driver(j721e_pcie_driver);
757+
module_platform_driver(j721e_pcie_driver);
758+
759+
MODULE_LICENSE("GPL");
760+
MODULE_DESCRIPTION("PCIe controller driver for TI's J721E and related SoCs");
761+
MODULE_AUTHOR("Kishon Vijay Abraham I <[email protected]>");

0 commit comments

Comments
 (0)