|
15 | 15 | #include <linux/irqchip/chained_irq.h>
|
16 | 16 | #include <linux/irqdomain.h>
|
17 | 17 | #include <linux/mfd/syscon.h>
|
| 18 | +#include <linux/module.h> |
18 | 19 | #include <linux/of.h>
|
19 | 20 | #include <linux/pci.h>
|
20 | 21 | #include <linux/platform_device.h>
|
|
27 | 28 | #define cdns_pcie_to_rc(p) container_of(p, struct cdns_pcie_rc, pcie)
|
28 | 29 |
|
29 | 30 | #define ENABLE_REG_SYS_2 0x108
|
| 31 | +#define ENABLE_CLR_REG_SYS_2 0x308 |
30 | 32 | #define STATUS_REG_SYS_2 0x508
|
31 | 33 | #define STATUS_CLR_REG_SYS_2 0x708
|
32 | 34 | #define LINK_DOWN BIT(1)
|
@@ -116,6 +118,15 @@ static irqreturn_t j721e_pcie_link_irq_handler(int irq, void *priv)
|
116 | 118 | return IRQ_HANDLED;
|
117 | 119 | }
|
118 | 120 |
|
| 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 | + |
119 | 130 | static void j721e_pcie_config_link_irq(struct j721e_pcie *pcie)
|
120 | 131 | {
|
121 | 132 | u32 reg;
|
@@ -633,9 +644,22 @@ static void j721e_pcie_remove(struct platform_device *pdev)
|
633 | 644 | struct j721e_pcie *pcie = platform_get_drvdata(pdev);
|
634 | 645 | struct cdns_pcie *cdns_pcie = pcie->cdns_pcie;
|
635 | 646 | 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); |
636 | 659 |
|
637 | 660 | clk_disable_unprepare(pcie->refclk);
|
638 | 661 | cdns_pcie_disable_phy(cdns_pcie);
|
| 662 | + j721e_pcie_disable_link_irq(pcie); |
639 | 663 | pm_runtime_put(dev);
|
640 | 664 | pm_runtime_disable(dev);
|
641 | 665 | }
|
@@ -730,4 +754,8 @@ static struct platform_driver j721e_pcie_driver = {
|
730 | 754 | .pm = pm_sleep_ptr(&j721e_pcie_pm_ops),
|
731 | 755 | },
|
732 | 756 | };
|
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