Skip to contentSkip to conversation

PCI: Add new Unisoc PCIe driver

PATCH Superseded Hongtao Wu 2 participants 4 messages Sep 8, 2020

Subsystems (4)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Hongtao Wu

author
#0 lore raw

v2 cover PCI: Add new Unisoc PCIe driver

From: Billows Wu <[email protected]>

This series adds PCIe controller driver for Unisoc SoCs. This controller is based on DesignWare PCIe IP.

Changes from v1:
1) Test this patch on top of Rob Herring's 40 part series of DWC clean-ups:
https://lore.kernel.org/linux-pci/[email protected]/

2) Delete empty function

3) Document property "sprd,pcie-poweron-syscons" and 'sprd,pcie-poweroff-syscons'

4) Delete runtime suspend/resume function

5) Add COMPILE_TEST which CONFIG_PCIE_SPRD depends on

Billows Wu (2):
dt-bindings: PCI: sprd: Document Unisoc PCIe RC host controller
PCI: sprd: Add support for Unisoc SoCs' PCIe controller

 .../devicetree/bindings/pci/sprd-pcie.yaml         | 101 +++++++++
 drivers/pci/controller/dwc/Kconfig                 |  13 ++
 drivers/pci/controller/dwc/Makefile                |   1 +
 drivers/pci/controller/dwc/pcie-sprd.c             | 231 +++++++++++++++++++++
 4 files changed, 346 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/sprd-pcie.yaml
 create mode 100644 drivers/pci/controller/dwc/pcie-sprd.c
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/2 dt-bindings: PCI: sprd: Document Unisoc PCIe RC host controller

From: Billows Wu <[email protected]>

This series adds PCIe bindings for Unisoc SoCs.
This controller is based on Designware PCIe IP.

---
 .../devicetree/bindings/pci/sprd-pcie.yaml         | 101 +++++++++++++++++++++
 1 file changed, 101 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/sprd-pcie.yaml
Documentation/devicetree/bindings/pci/sprd-pcie.yaml new file +101 -0
new file mode 100644
index 0000000..40c2408
@@ -0,0 +1,101 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pci/sprd-pcie.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SoC PCIe Host Controller Device Tree Bindings
+
+maintainers:
+  - Billows Wu <[email protected]>
+
+allOf:
+  - $ref: /schemas/pci/pci-bus.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: sprd,pcie-rc
+
+  reg:
+    minItems: 2
+    items:
+      - description: Controller control and status registers.
+      - description: PCIe configuration registers.
+
+  reg-names:
+    items:
+      - const: dbi
+      - const: config
+
+  ranges:
+    maxItems: 2
+
+  num-lanes:
+    maximum: 1
+    description: Number of lanes to use for this port.
+
+  interrupts:
+    minItems: 1
+    description: Builtin MSI controller and PCIe host controller.
+
+  interrupt-names:
+    items:
+      - const: msi
+
+  sprd-pcie-poweron-syscons:
+    minItems: 1
+    description: Global register.
+      The first value is the phandle to the global registers required to
+      confige PCIe phy, clock and so on.
+      The second value is the global register type which indicates whether it
+      is a set/clear register or not.
+      The third value is the time to delay after the global register is set or
+      cleared.
+      The fourth value is the global register address.
+      The fifth value is the the mask value that the global register must
+      be operate.
+      The sixth value is the value that will be set to the global register.
+      Note that Some Unisoc global registers have not been upstreamed.
+      The global register and its mask can't be found in linux kernel,
+      so we use an offset address and a number to instead them.
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - num-lanes
+  - ranges
+  - interrupts
+  - interrupt-names
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    ipa {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        pcie0: pcie@2b100000 {
+            compatible = "sprd,pcie-rc";
+            reg = <0x0 0x2b100000 0x0 0x2000>,
+                  <0x2 0x00000000 0x0 0x2000>;
+            reg-names = "dbi", "config";
+            #address-cells = <3>;
+            #size-cells = <2>;
+            device_type = "pci";
+            ranges = <0x01000000 0x0 0x00000000 0x2 0x00002000 0x0 0x00010000>,
+                     <0x03000000 0x0 0x10000000 0x2 0x10000000 0x1 0xefffffff>;
+            num-lanes = <1>;
+            interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
+            interrupt-names = "msi";
+
+            sprd,pcie-poweron-syscons =
+                <&ap_ipa_ahb_regs 0 0 0x0000 0x40 0x40>,
+                <&ap_ipa_ahb_regs 0 0 0x0000 0x20 0x20>;
+            sprd,pcie-poweroff-syscons =
+                <&ap_ipa_ahb_regs 0 0 0x0000 0x20 0x0>,
+                <&ap_ipa_ahb_regs 0 0 0x0000 0x40 0x0>;
+        };
+    };

--
2.7.4

author
#2 lore raw

PATCH v2 2/2 PCI: sprd: Add support for Unisoc SoCs' PCIe controller

In reply to Hongtao Wu

From: Billows Wu <[email protected]>

This series adds PCIe controller driver for Unisoc SoCs. This controller is based on DesignWare PCIe IP.

---
 drivers/pci/controller/dwc/Kconfig     |  13 ++
 drivers/pci/controller/dwc/Makefile    |   1 +
 drivers/pci/controller/dwc/pcie-sprd.c | 231 +++++++++++++++++++++++++++++++++
 3 files changed, 245 insertions(+)
 create mode 100644 drivers/pci/controller/dwc/pcie-sprd.c
drivers/pci/controller/dwc/Kconfig +13 -0
index 044a376..14e8ed9 100644
@@ -311,4 +311,17 @@ config PCIE_AL
 	  required only for DT-based platforms. ACPI platforms with the
 	  Annapurna Labs PCIe controller don't need to enable this.
 
+
+config PCIE_SPRD
+	tristate "Unisoc PCIe controller - RC mode"
+	depends on ARCH_SPRD || COMPILE_TEST
+	depends on PCI_MSI_IRQ_DOMAIN
+	select PCIE_DW_HOST
+	help
+	  Unisoc PCIe controller uses the Designware core. It can be configured
+	  as an Endpoint (EP) or a Root complex (RC). In order to enable RC
+	  mode, PCIE_SPRD must be selected.
+	  Say Y or M here if you want to PCIe RC controller support on Unisoc
+	  SoCs.
+
 endmenu
drivers/pci/controller/dwc/Makefile +1 -0
index a751553..eb546e9 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_PCI_MESON) += pci-meson.o
 obj-$(CONFIG_PCIE_TEGRA194) += pcie-tegra194.o
 obj-$(CONFIG_PCIE_UNIPHIER) += pcie-uniphier.o
 obj-$(CONFIG_PCIE_UNIPHIER_EP) += pcie-uniphier-ep.o
+obj-$(CONFIG_PCIE_SPRD) += pcie-sprd.o
 
 # The following drivers are for devices that use the generic ACPI
 # pci_root.c driver but don't support standard ECAM config access.
drivers/pci/controller/dwc/pcie-sprd.c new file +231 -0

231 lines not on this page · raw message

--
2.7.4

#3 lore raw

Re: [PATCH v2 2/2] PCI: sprd: Add support for Unisoc SoCs' PCIe controller

Quoted 6 lines · Hongtao Wu

From: Billows Wu <[email protected]>

This series adds PCIe controller driver for Unisoc SoCs. This controller is based on DesignWare PCIe IP.

Last signed-off must be from developer submitting the patch, i.e.,
Hongtao Wu; see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst#n560

drivers/pci/controller/dwc/Kconfig config PCIE_AL · line 316

Quoted 2 lines
drivers/pci/controller/dwc/Kconfig +2 -0
+config PCIE_SPRD
+	tristate "Unisoc PCIe controller - RC mode"

s/RC mode/Host mode/ to follow convention of other drivers.

drivers/pci/controller/dwc/Kconfig config PCIE_AL · line 321

Quoted 5 lines
drivers/pci/controller/dwc/Kconfig +5 -0
+	depends on ARCH_SPRD || COMPILE_TEST
+	depends on PCI_MSI_IRQ_DOMAIN
+	select PCIE_DW_HOST
+	help
+	  Unisoc PCIe controller uses the Designware core. It can be configured

s/Designware/DesignWare/

drivers/pci/controller/dwc/Kconfig config PCIE_AL

Quoted 6 lines
drivers/pci/controller/dwc/Kconfig +5 -0
+	  as an Endpoint (EP) or a Root complex (RC). In order to enable RC
+	  mode, PCIE_SPRD must be selected.
+	  Say Y or M here if you want to PCIe RC controller support on Unisoc
+	  SoCs.
 
+		dev_dbg(&pdev->dev,

dev_dbg(dev, ...

Quoted 2 lines
drivers/pci/controller/dwc/pcie-sprd.c new file +2 -0
+			"%2d:reg[0x%8x] mask[0x%8x] val[0x%8x] result[0x%8x]\n",
+			i, reg, mask, val, tmp_val);