Skip to contentSkip to conversation

Add support to build pci-j721e as a kernel module

PATCH New Achal Verma 1 participant 3 messages May 13, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Add support to build pci-j721e as a kernel module

J721e PCie driver is not required during linux boot, thus it should be build as a loadable kernel module. This series add support to build pci-j721e driver and pcie-cadence library as lodable modules.

Changes from v1:
* Reword subject line to use PCI in place of PCIe to maintain consistency with older commit messages.
* Fix word wrapping in commit message to 75 columns and add newline between paragraphs.
* Drop PATCH 3 (defconfig changes) from v1 and will repost it separately.

Achal Verma (1):
PCI: j721e: Add support to build pci-j721e as a kernel module

Kishon Vijay Abraham I (1):
PCI: cadence: Add support to build pcie-cadence library as a kernel
module.

 drivers/pci/controller/cadence/Kconfig        |  12 +-
 drivers/pci/controller/cadence/Makefile       |   2 +
 drivers/pci/controller/cadence/pci-j721e-ep.c | 130 +++++++
 .../pci/controller/cadence/pci-j721e-host.c   | 204 +++++++++++
 drivers/pci/controller/cadence/pci-j721e.c    | 343 +-----------------
 drivers/pci/controller/cadence/pci-j721e.h    |  88 +++++
 .../pci/controller/cadence/pcie-cadence-ep.c  |   4 +
 .../controller/cadence/pcie-cadence-host.c    |   5 +
 drivers/pci/controller/cadence/pcie-cadence.c |   9 +
 drivers/pci/controller/cadence/pcie-cadence.h |   4 +-
 10 files changed, 466 insertions(+), 335 deletions(-)
 create mode 100644 drivers/pci/controller/cadence/pci-j721e-ep.c
 create mode 100644 drivers/pci/controller/cadence/pci-j721e-host.c
 create mode 100644 drivers/pci/controller/cadence/pci-j721e.h
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/2 PCI: cadence: Add support to build pcie-cadence library as a kernel module.

From: Kishon Vijay Abraham I <[email protected]>

Cadence PCIe controller driver can be build as kernel built-in driver only, which is not required since its not required at boot time. Thus, this change adds support to build Cadence PCIe driver as kernel module as well.

---
 drivers/pci/controller/cadence/Kconfig             | 6 +++---
 drivers/pci/controller/cadence/pcie-cadence-ep.c   | 4 ++++
 drivers/pci/controller/cadence/pcie-cadence-host.c | 5 +++++
 drivers/pci/controller/cadence/pcie-cadence.c      | 9 +++++++++
 drivers/pci/controller/cadence/pcie-cadence.h      | 4 ++--
 5 files changed, 23 insertions(+), 5 deletions(-)
drivers/pci/controller/cadence/Kconfig +3 -3
index 291d12711363..abc245dbedab 100644
@@ -4,16 +4,16 @@ menu "Cadence-based PCIe controllers"
 	depends on PCI
 
 config PCIE_CADENCE
-	bool
+	tristate
 
 config PCIE_CADENCE_HOST
-	bool
+	tristate
 	depends on OF
 	select IRQ_DOMAIN
 	select PCIE_CADENCE
 
 config PCIE_CADENCE_EP
-	bool
+	tristate
 	depends on OF
 	depends on PCI_ENDPOINT
 	select PCIE_CADENCE
drivers/pci/controller/cadence/pcie-cadence-ep.c +4 -0
index b8b655d4047e..598b2b9c5969 100644
@@ -5,6 +5,7 @@
 
 #include <linux/delay.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/pci-epc.h>
 #include <linux/platform_device.h>
@@ -741,3 +742,6 @@ int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep)
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(cdns_pcie_ep_setup);
+
+MODULE_LICENSE("GPL v2");
drivers/pci/controller/cadence/pcie-cadence-host.c +5 -0
index 940c7dd701d6..84754c63df34 100644
@@ -5,6 +5,7 @@
 
 #include <linux/delay.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/list_sort.h>
 #include <linux/of_address.h>
 #include <linux/of_pci.h>
@@ -70,6 +71,7 @@ void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn,
 
 	return rc->cfg_base + (where & 0xfff);
 }
+EXPORT_SYMBOL_GPL(cdns_pci_map_bus);
 
 static struct pci_ops cdns_pcie_host_ops = {
 	.map_bus	= cdns_pci_map_bus,
@@ -542,3 +544,6 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(cdns_pcie_host_setup);
+
+MODULE_LICENSE("GPL v2");
drivers/pci/controller/cadence/pcie-cadence.c +9 -0
index 13c4032ca379..8e3a86578284 100644
@@ -4,6 +4,7 @@
 // Author: Cyrille Pitchen <[email protected]>
 
 #include <linux/kernel.h>
+#include <linux/module.h>
 
 #include "pcie-cadence.h"
 
@@ -22,6 +23,7 @@ void cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie)
 
 	cdns_pcie_writel(pcie, CDNS_PCIE_LTSSM_CONTROL_CAP, ltssm_control_cap);
 }
+EXPORT_SYMBOL_GPL(cdns_pcie_detect_quiet_min_delay_set);
 
 void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 busnr, u8 fn,
 				   u32 r, bool is_io,
@@ -99,6 +101,7 @@ void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 busnr, u8 fn,
 	cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r), addr0);
 	cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r), addr1);
 }
+EXPORT_SYMBOL_GPL(cdns_pcie_set_outbound_region);
 
 void cdns_pcie_set_outbound_region_for_normal_msg(struct cdns_pcie *pcie,
 						  u8 busnr, u8 fn,
@@ -133,6 +136,7 @@ void cdns_pcie_set_outbound_region_for_normal_msg(struct cdns_pcie *pcie,
 	cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r), addr0);
 	cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r), addr1);
 }
+EXPORT_SYMBOL_GPL(cdns_pcie_set_outbound_region_for_normal_msg);
 
 void cdns_pcie_reset_outbound_region(struct cdns_pcie *pcie, u32 r)
 {
@@ -145,6 +149,7 @@ void cdns_pcie_reset_outbound_region(struct cdns_pcie *pcie, u32 r)
 	cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r), 0);
 	cdns_pcie_writel(pcie, CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r), 0);
 }
+EXPORT_SYMBOL_GPL(cdns_pcie_reset_outbound_region);
 
 void cdns_pcie_disable_phy(struct cdns_pcie *pcie)
 {
@@ -155,6 +160,7 @@ void cdns_pcie_disable_phy(struct cdns_pcie *pcie)
 		phy_exit(pcie->phy[i]);
 	}
 }
+EXPORT_SYMBOL_GPL(cdns_pcie_disable_phy);
 
 int cdns_pcie_enable_phy(struct cdns_pcie *pcie)
 {
@@ -242,6 +248,7 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(cdns_pcie_init_phy);
 
 static int cdns_pcie_suspend_noirq(struct device *dev)
 {
@@ -270,3 +277,5 @@ const struct dev_pm_ops cdns_pcie_pm_ops = {
 	NOIRQ_SYSTEM_SLEEP_PM_OPS(cdns_pcie_suspend_noirq,
 				  cdns_pcie_resume_noirq)
 };
+
+MODULE_LICENSE("GPL v2");
drivers/pci/controller/cadence/pcie-cadence.h +2 -2
index 190786e47df9..65b330c28299 100644
@@ -514,7 +514,7 @@ static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie)
 	return true;
 }
 
-#ifdef CONFIG_PCIE_CADENCE_HOST
+#if IS_ENABLED(CONFIG_PCIE_CADENCE_HOST)
 int cdns_pcie_host_setup(struct cdns_pcie_rc *rc);
 void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn,
 			       int where);
@@ -531,7 +531,7 @@ static inline void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int d
 }
 #endif
 
-#ifdef CONFIG_PCIE_CADENCE_EP
+#if IS_ENABLED(CONFIG_PCIE_CADENCE_EP)
 int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep);
 #else
 static inline int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep)
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/2 PCI: j721e: Add support to build pci-j721e as a kernel module

In reply to Achal Verma

pci-j721e driver can be build as a in-built kernel driver only, which is not required as it is not used during boot time in most cases. This change add support to build pci-j721e as a kernel loadable module.

J721e PCIe controller can work in both host mode and end-point mode. In order to enable host mode driver and endpoint driver to be built independently either as built-in or kernel module, the pcie-j721e.c driver is refactored into following components:

1) pci-j721e-host.c: Driver used when PCIe controller has to be initialized in host mode.

2) pci-j721e-ep.c: Driver used when PCIe controller has to be initialized in endpoint mode.

3) pci-j721e.c: contains common code required in both modes.

---
 drivers/pci/controller/cadence/Kconfig        |   6 +-
 drivers/pci/controller/cadence/Makefile       |   2 +
 drivers/pci/controller/cadence/pci-j721e-ep.c | 130 +++++++
 .../pci/controller/cadence/pci-j721e-host.c   | 204 +++++++++++
 drivers/pci/controller/cadence/pci-j721e.c    | 343 +-----------------
 drivers/pci/controller/cadence/pci-j721e.h    |  88 +++++
 6 files changed, 443 insertions(+), 330 deletions(-)
 create mode 100644 drivers/pci/controller/cadence/pci-j721e-ep.c
 create mode 100644 drivers/pci/controller/cadence/pci-j721e-host.c
 create mode 100644 drivers/pci/controller/cadence/pci-j721e.h
drivers/pci/controller/cadence/Kconfig +3 -3
index abc245dbedab..936335483b76 100644
@@ -43,10 +43,10 @@ config PCIE_CADENCE_PLAT_EP
 	  different vendors SoCs.
 
 config PCI_J721E
-	bool
+	tristate
 
 config PCI_J721E_HOST
-	bool "TI J721E PCIe controller (host mode)"
+	tristate "TI J721E PCIe platform host controller"
 	depends on OF
 	select PCIE_CADENCE_HOST
 	select PCI_J721E
@@ -56,7 +56,7 @@ config PCI_J721E_HOST
 	  core.
 
 config PCI_J721E_EP
-	bool "TI J721E PCIe controller (endpoint mode)"
+	tristate "TI J721E PCIe platform endpoint controller"
 	depends on OF
 	depends on PCI_ENDPOINT
 	select PCIE_CADENCE_EP
drivers/pci/controller/cadence/Makefile +2 -0
index 9bac5fb2f13d..d49709870102 100644
@@ -4,3 +4,5 @@ obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.o
 obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep.o
 obj-$(CONFIG_PCIE_CADENCE_PLAT) += pcie-cadence-plat.o
 obj-$(CONFIG_PCI_J721E) += pci-j721e.o
+obj-$(CONFIG_PCI_J721E_HOST) += pci-j721e-host.o
+obj-$(CONFIG_PCI_J721E_EP) += pci-j721e-ep.o
drivers/pci/controller/cadence/pci-j721e-ep.c new file +130 -0

130 lines not on this page · raw message

drivers/pci/controller/cadence/pci-j721e-host.c new file +204 -0

204 lines not on this page · raw message

drivers/pci/controller/cadence/pci-j721e.c +16 -327

408 lines not on this page · raw message

drivers/pci/controller/cadence/pci-j721e.h new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
2.25.1