Skip to contentSkip to conversation

PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver

PATCH Applied Sergio Paracuellos 4 participants 18 messages Sep 22, 2021 – Oct 26, 2021

Subsystems (8)
lore
Share & tools
lore

Sergio Paracuellos

author maintainer
#0 lore raw

v3 cover PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver

MediaTek MT7621 PCIe subsys supports single Root complex (RC) with 3 Root Ports. Each Root Ports supports a Gen1 1-lane Link. Topology is as follows:

                          MT7621 PCIe HOST Topology

                                   .-------.
                                   |       |
                                   |  CPU  |
                                   |       |
                                   '-------'
                                       |
                                       |
                                       |
                                       v
                              .------------------.
                  .-----------|  HOST/PCI Bridge |------------.
                  |           '------------------'            |     Type1 
         BUS0     |                     |                     |    Access 
                  v                     v                     v    On Bus0
          .-------------.        .-------------.       .-------------.
          | VIRTUAL P2P |        | VIRTUAL P2P |       | VIRTUAL P2P |
          |    BUS0     |        |    BUS0     |       |    BUS0     |
          |    DEV0     |        |    DEV1     |       |    DEV2     |
          '-------------'        '-------------'       '-------------'
    Type0        |          Type0       |         Type0       |
   Access   BUS1 |         Access   BUS2|        Access   BUS3|
   On Bus1       v         On Bus2      v        On Bus3      v
           .----------.           .----------.          .----------.
           | Device 0 |           | Device 0 |          | Device 0 |
           |  Func 0  |           |  Func 0  |          |  Func 0  |
           '----------'           '----------'          '----------'

This driver has been very long time in staging and I have been cleaning it from its first versions where there was code kaos and PCI_LEGACY support. Original code came probably from openWRT based on mediatek's SDK code. There is no documentation at all about the mt7621 PCI subsystem.
I have been cleaning it targeting mt7621 SoC which is the one I use in my GNUBee PC1 board and HiLink HLK-MT7621A evaluation board.

Now I think is clean enough to be moved into 'drivers/pci/controller'. This driver is mips/ralink architecture and need 'mips_cps_numiocu()' to properly configure iocu regions for mips.

This driver also uses already mainlined pci phy driver located in 'drivers/phy/ralink/phy-mt7621-pci.c'. There are two instances of the phy being the first one dual ported for pci0 and pci1, and the second one not dual ported dedicated to pci2. Because of writing twice some phy registers of the dual-ported one sometimes become in not confident boot cycles we have to take care of this when device link is checked here in controller driver. We power on the dual ported-phy if there is something connected in pcie0 or pcie1. In the same manner we have to properly disable it only if nothing is connected in of both pcie0 and pcie1 slots.

This changes are rebased on the top of staging-next branch of staging tree for a clean git mv since last changes are always in that tree. Since this a git mv as I was told to do, include link to the last code here [0].

Changes in v3:
- Add Rob's Reviewed-by for the bindings.
- Avoid custom 'of_pci_range_to_resource' in driver side since PCI core APIs has been changed to properly support this architecture.
- Kconfig:
- Change from 'bool' to 'tristate'.
- Add phy's selection 'select PHY_MT7621_PCI'.
- Move PCI_DRIVERS_GENERIC selection to 'arch/mips' since its mips internal stuff (change requested by Lorenzo in v2 review of this series).

Changes in v2:
- Make one commit moving driver directly from staging into 'drivers/pci/controllers' instead of two commits making one add and a later remove.
- Update binding documentation moving 'clocks', 'resets' and 'phys' properties to child root bridge nodes.
- Update code to properly be able to use new bindings.
- Kconfig: add || (MIPS && COMPILE_TEST).
- Use {read/write}_relaxed versions.
- Use 'PCI_BASE_ADDRESS_0' instead of a custom definition.
- Avoid to set 'PCI_COMMAND_MASTER' and re-do functions 'mt7621_pcie_enable_ports' and 'mt7621_pcie_enable_port'.

Thanks in advance for your time.

Best regards,
Sergio Paracuellos

[0]: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/mt7621-pci/pci-mt7621.c?h=staging-testing
Sergio Paracuellos (3):
dt-bindings: mt7621-pci: PCIe binding documentation for MT7621 SoCs
PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver
MAINTAINERS: add myself as maintainer of the MT7621 PCI controller
driver

 .../bindings/pci/mediatek,mt7621-pci.yaml     | 142 ++++++++++++++++++
 MAINTAINERS                                   |   6 +
 arch/mips/ralink/Kconfig                      |   3 +-
 drivers/pci/controller/Kconfig                |   8 +
 drivers/pci/controller/Makefile               |   1 +
 .../controller}/pci-mt7621.c                  |   0
 drivers/staging/Kconfig                       |   2 -
 drivers/staging/Makefile                      |   1 -
 drivers/staging/mt7621-pci/Kconfig            |   8 -
 drivers/staging/mt7621-pci/Makefile           |   2 -
 drivers/staging/mt7621-pci/TODO               |   4 -
 .../mt7621-pci/mediatek,mt7621-pci.txt        | 104 -------------
 12 files changed, 159 insertions(+), 122 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml
 rename drivers/{staging/mt7621-pci => pci/controller}/pci-mt7621.c (100%)
 delete mode 100644 drivers/staging/mt7621-pci/Kconfig
 delete mode 100644 drivers/staging/mt7621-pci/Makefile
 delete mode 100644 drivers/staging/mt7621-pci/TODO
 delete mode 100644 drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH v3 1/3 dt-bindings: mt7621-pci: PCIe binding documentation for MT7621 SoCs

Add device tree binding documentation for PCIe in MT7621 SoCs.

---
 .../bindings/pci/mediatek,mt7621-pci.yaml     | 142 ++++++++++++++++++
 1 file changed, 142 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml
Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml new file +142 -0
new file mode 100644
index 000000000000..d7359d0ee935
@@ -0,0 +1,142 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pci/mediatek,mt7621-pci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT7621 PCIe controller
+
+maintainers:
+  - Sergio Paracuellos <[email protected]>
+
+description: |+
+  MediaTek MT7621 PCIe subsys supports single Root complex (RC)
+  with 3 Root Ports. Each Root Ports supports a Gen1 1-lane Link
+
+allOf:
+  - $ref: /schemas/pci/pci-bus.yaml#
+
+properties:
+  compatible:
+    const: mediatek,mt7621-pci
+
+  reg:
+    items:
+      - description: host-pci bridge registers
+      - description: pcie port 0 RC control registers
+      - description: pcie port 1 RC control registers
+      - description: pcie port 2 RC control registers
+
+  ranges:
+    maxItems: 2
+
+patternProperties:
+  'pcie@[0-2],0':
+    type: object
+    $ref: /schemas/pci/pci-bus.yaml#
+
+    properties:
+      resets:
+        maxItems: 1
+
+      clocks:
+        maxItems: 1
+
+      phys:
+        maxItems: 1
+
+    required:
+      - "#interrupt-cells"
+      - interrupt-map-mask
+      - interrupt-map
+      - resets
+      - clocks
+      - phys
+      - phy-names
+      - ranges
+
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - ranges
+  - "#interrupt-cells"
+  - interrupt-map-mask
+  - interrupt-map
+  - reset-gpios
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/mips-gic.h>
+
+    pcie: pcie@1e140000 {
+        compatible = "mediatek,mt7621-pci";
+        reg = <0x1e140000 0x100>,
+              <0x1e142000 0x100>,
+              <0x1e143000 0x100>,
+              <0x1e144000 0x100>;
+
+        #address-cells = <3>;
+        #size-cells = <2>;
+        pinctrl-names = "default";
+        pinctrl-0 = <&pcie_pins>;
+        device_type = "pci";
+        ranges = <0x02000000 0 0x60000000 0x60000000 0 0x10000000>,  /* pci memory */
+                 <0x01000000 0 0x1e160000 0x1e160000 0 0x00010000>;  /* io space */
+        #interrupt-cells = <1>;
+        interrupt-map-mask = <0xF800 0 0 0>;
+        interrupt-map = <0x0000 0 0 0 &gic GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH>,
+                        <0x0800 0 0 0 &gic GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH>,
+                        <0x1000 0 0 0 &gic GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>;
+        reset-gpios = <&gpio 19 GPIO_ACTIVE_LOW>;
+
+        pcie@0,0 {
+            reg = <0x0000 0 0 0 0>;
+            #address-cells = <3>;
+            #size-cells = <2>;
+            device_type = "pci";
+            #interrupt-cells = <1>;
+            interrupt-map-mask = <0 0 0 0>;
+            interrupt-map = <0 0 0 0 &gic GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH>;
+            resets = <&rstctrl 24>;
+            clocks = <&clkctrl 24>;
+            phys = <&pcie0_phy 1>;
+            phy-names = "pcie-phy0";
+            ranges;
+        };
+
+        pcie@1,0 {
+            reg = <0x0800 0 0 0 0>;
+            #address-cells = <3>;
+            #size-cells = <2>;
+            device_type = "pci";
+            #interrupt-cells = <1>;
+            interrupt-map-mask = <0 0 0 0>;
+            interrupt-map = <0 0 0 0 &gic GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH>;
+            resets = <&rstctrl 25>;
+            clocks = <&clkctrl 25>;
+            phys = <&pcie0_phy 1>;
+            phy-names = "pcie-phy1";
+            ranges;
+        };
+
+        pcie@2,0 {
+            reg = <0x1000 0 0 0 0>;
+            #address-cells = <3>;
+            #size-cells = <2>;
+            device_type = "pci";
+            #interrupt-cells = <1>;
+            interrupt-map-mask = <0 0 0 0>;
+            interrupt-map = <0 0 0 0 &gic GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>;
+            resets = <&rstctrl 26>;
+            clocks = <&clkctrl 26>;
+            phys = <&pcie2_phy 0>;
+            phy-names = "pcie-phy2";
+            ranges;
+        };
+    };
+...
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH v3 2/3 PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver

In reply to Sergio Paracuellos

Add driver for the PCIe controller of the MT7621 SoC.

---
 arch/mips/ralink/Kconfig                      |   3 +-
 drivers/pci/controller/Kconfig                |   8 ++
 drivers/pci/controller/Makefile               |   1 +
 .../controller}/pci-mt7621.c                  |   0
 drivers/staging/Kconfig                       |   2 -
 drivers/staging/Makefile                      |   1 -
 drivers/staging/mt7621-pci/Kconfig            |   8 --
 drivers/staging/mt7621-pci/Makefile           |   2 -
 drivers/staging/mt7621-pci/TODO               |   4 -
 .../mt7621-pci/mediatek,mt7621-pci.txt        | 104 ------------------
 10 files changed, 11 insertions(+), 122 deletions(-)
 rename drivers/{staging/mt7621-pci => pci/controller}/pci-mt7621.c (100%)
 delete mode 100644 drivers/staging/mt7621-pci/Kconfig
 delete mode 100644 drivers/staging/mt7621-pci/Makefile
 delete mode 100644 drivers/staging/mt7621-pci/TODO
 delete mode 100644 drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt
arch/mips/ralink/Kconfig +2 -1
index c800bf5559b5..120adad51d6a 100644
@@ -51,7 +51,8 @@ choice
 		select SYS_SUPPORTS_HIGHMEM
 		select MIPS_GIC
 		select CLKSRC_MIPS_GIC
-		select HAVE_PCI if PCI_MT7621
+		select HAVE_PCI
+		select PCI_DRIVERS_GENERIC
 		select SOC_BUS
 endchoice
 
drivers/pci/controller/Kconfig +8 -0
index 326f7d13024f..b76404be0360 100644
@@ -312,6 +312,14 @@ config PCIE_HISI_ERR
 	  Say Y here if you want error handling support
 	  for the PCIe controller's errors on HiSilicon HIP SoCs
 
+config PCI_MT7621
+	tristate "MediaTek MT7621 PCI Controller"
+	depends on (RALINK && SOC_MT7621) || (MIPS && COMPILE_TEST)
+	select PHY_MT7621_PCI
+	default SOC_MT7621
+	help
+	  This selects a driver for the MediaTek MT7621 PCI Controller.
+
 source "drivers/pci/controller/dwc/Kconfig"
 source "drivers/pci/controller/mobiveil/Kconfig"
 source "drivers/pci/controller/cadence/Kconfig"
drivers/pci/controller/Makefile +1 -0
index aaf30b3dcc14..f42a566353cb 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_VMD) += vmd.o
 obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o
 obj-$(CONFIG_PCI_LOONGSON) += pci-loongson.o
 obj-$(CONFIG_PCIE_HISI_ERR) += pcie-hisi-error.o
+obj-$(CONFIG_PCI_MT7621) += pci-mt7621.o
 # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
 obj-y				+= dwc/
 obj-y				+= mobiveil/
drivers/pci/controller/pci-mt7621.c renamed from drivers/staging/mt7621-pci/pci-mt7621.c +0 -0
similarity index 100%
rename from drivers/staging/mt7621-pci/pci-mt7621.c
rename to drivers/pci/controller/pci-mt7621.c
drivers/staging/Kconfig +0 -2
index e03627ad4460..59af251e7576 100644
@@ -86,8 +86,6 @@ source "drivers/staging/vc04_services/Kconfig"
 
 source "drivers/staging/pi433/Kconfig"
 
-source "drivers/staging/mt7621-pci/Kconfig"
-
 source "drivers/staging/mt7621-dma/Kconfig"
 
 source "drivers/staging/ralink-gdma/Kconfig"
drivers/staging/Makefile +0 -1
index c7f8d8d8dd11..76f413470bc8 100644
@@ -33,7 +33,6 @@ obj-$(CONFIG_KS7010)		+= ks7010/
 obj-$(CONFIG_GREYBUS)		+= greybus/
 obj-$(CONFIG_BCM2835_VCHIQ)	+= vc04_services/
 obj-$(CONFIG_PI433)		+= pi433/
-obj-$(CONFIG_PCI_MT7621)	+= mt7621-pci/
 obj-$(CONFIG_SOC_MT7621)	+= mt7621-dma/
 obj-$(CONFIG_DMA_RALINK)	+= ralink-gdma/
 obj-$(CONFIG_SOC_MT7621)	+= mt7621-dts/
drivers/staging/mt7621-pci/Kconfig deleted +0 -8
deleted file mode 100644
index ce58042f2f21..000000000000
@@ -1,8 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-config PCI_MT7621
-	tristate "MediaTek MT7621 PCI Controller"
-	depends on RALINK
-	select PCI_DRIVERS_GENERIC
-	help
-	  This selects a driver for the MediaTek MT7621 PCI Controller.
-
drivers/staging/mt7621-pci/Makefile deleted +0 -2
deleted file mode 100644
index f4e651cf7ce3..000000000000
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_PCI_MT7621)       += pci-mt7621.o
drivers/staging/mt7621-pci/TODO deleted +0 -4
deleted file mode 100644
index d674a9ac85c1..000000000000
@@ -1,4 +0,0 @@
-
-- general code review and cleanup
-
-Cc: NeilBrown <[email protected]>
drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt deleted +0 -104

104 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw
Quoted 41 lines · Sergio Paracuellos

Add driver for the PCIe controller of the MT7621 SoC.

---
 arch/mips/ralink/Kconfig                      |   3 +-
 drivers/pci/controller/Kconfig                |   8 ++
 drivers/pci/controller/Makefile               |   1 +
 .../controller}/pci-mt7621.c                  |   0
 drivers/staging/Kconfig                       |   2 -
 drivers/staging/Makefile                      |   1 -
 drivers/staging/mt7621-pci/Kconfig            |   8 --
 drivers/staging/mt7621-pci/Makefile           |   2 -
 drivers/staging/mt7621-pci/TODO               |   4 -
 .../mt7621-pci/mediatek,mt7621-pci.txt        | 104 ------------------
 10 files changed, 11 insertions(+), 122 deletions(-)
 rename drivers/{staging/mt7621-pci => pci/controller}/pci-mt7621.c (100%)
 delete mode 100644 drivers/staging/mt7621-pci/Kconfig
 delete mode 100644 drivers/staging/mt7621-pci/Makefile
 delete mode 100644 drivers/staging/mt7621-pci/TODO
 delete mode 100644 drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt
arch/mips/ralink/Kconfig +2 -1
index c800bf5559b5..120adad51d6a 100644
@@ -51,7 +51,8 @@ choice
 		select SYS_SUPPORTS_HIGHMEM
 		select MIPS_GIC
 		select CLKSRC_MIPS_GIC
-		select HAVE_PCI if PCI_MT7621
+		select HAVE_PCI
+		select PCI_DRIVERS_GENERIC
 		select SOC_BUS
 endchoice
 
drivers/pci/controller/Kconfig +0 -0
index 326f7d13024f..b76404be0360 100644

drivers/pci/controller/Kconfig config PCIE_HISI_ERR · line 317

Quoted 6 lines
drivers/pci/controller/Kconfig +3 -0
@@ -312,6 +312,14 @@ config PCIE_HISI_ERR
 	  Say Y here if you want error handling support
 	  for the PCIe controller's errors on HiSilicon HIP SoCs
 
+config PCI_MT7621
+	tristate "MediaTek MT7621 PCI Controller"
+	depends on (RALINK && SOC_MT7621) || (MIPS && COMPILE_TEST)

- Is there a chance we can remove the MIPS dependency from the COMPILE_TEST conditional ?
- I am not a big fan of "SOC_XXX" config options dependencies, actually there is none in pci/controller. Is there a way to remove it ?

Lorenzo

Quoted 194 lines
drivers/pci/controller/Kconfig +5 -0
+	select PHY_MT7621_PCI
+	default SOC_MT7621
+	help
+	  This selects a driver for the MediaTek MT7621 PCI Controller.
+
 source "drivers/pci/controller/dwc/Kconfig"
 source "drivers/pci/controller/mobiveil/Kconfig"
 source "drivers/pci/controller/cadence/Kconfig"
drivers/pci/controller/Makefile +1 -0
index aaf30b3dcc14..f42a566353cb 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_VMD) += vmd.o
 obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o
 obj-$(CONFIG_PCI_LOONGSON) += pci-loongson.o
 obj-$(CONFIG_PCIE_HISI_ERR) += pcie-hisi-error.o
+obj-$(CONFIG_PCI_MT7621) += pci-mt7621.o
 # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
 obj-y				+= dwc/
 obj-y				+= mobiveil/
drivers/pci/controller/pci-mt7621.c renamed from drivers/staging/mt7621-pci/pci-mt7621.c +0 -0
similarity index 100%
rename from drivers/staging/mt7621-pci/pci-mt7621.c
rename to drivers/pci/controller/pci-mt7621.c
drivers/staging/Kconfig +0 -2
index e03627ad4460..59af251e7576 100644
@@ -86,8 +86,6 @@ source "drivers/staging/vc04_services/Kconfig"
 
 source "drivers/staging/pi433/Kconfig"
 
-source "drivers/staging/mt7621-pci/Kconfig"
-
 source "drivers/staging/mt7621-dma/Kconfig"
 
 source "drivers/staging/ralink-gdma/Kconfig"
drivers/staging/Makefile +0 -1
index c7f8d8d8dd11..76f413470bc8 100644
@@ -33,7 +33,6 @@ obj-$(CONFIG_KS7010)		+= ks7010/
 obj-$(CONFIG_GREYBUS)		+= greybus/
 obj-$(CONFIG_BCM2835_VCHIQ)	+= vc04_services/
 obj-$(CONFIG_PI433)		+= pi433/
-obj-$(CONFIG_PCI_MT7621)	+= mt7621-pci/
 obj-$(CONFIG_SOC_MT7621)	+= mt7621-dma/
 obj-$(CONFIG_DMA_RALINK)	+= ralink-gdma/
 obj-$(CONFIG_SOC_MT7621)	+= mt7621-dts/
drivers/staging/mt7621-pci/Kconfig deleted +0 -8
deleted file mode 100644
index ce58042f2f21..000000000000
@@ -1,8 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-config PCI_MT7621
-	tristate "MediaTek MT7621 PCI Controller"
-	depends on RALINK
-	select PCI_DRIVERS_GENERIC
-	help
-	  This selects a driver for the MediaTek MT7621 PCI Controller.
-
drivers/staging/mt7621-pci/Makefile deleted +0 -2
deleted file mode 100644
index f4e651cf7ce3..000000000000
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_PCI_MT7621)       += pci-mt7621.o
drivers/staging/mt7621-pci/TODO deleted +0 -4
deleted file mode 100644
index d674a9ac85c1..000000000000
@@ -1,4 +0,0 @@
-
-- general code review and cleanup
-
-Cc: NeilBrown <[email protected]>
drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt deleted +0 -104
deleted file mode 100644
index 327a68267309..000000000000
@@ -1,104 +0,0 @@
-MediaTek MT7621 PCIe controller
-
-Required properties:
-- compatible: "mediatek,mt7621-pci"
-- device_type: Must be "pci"
-- reg: Base addresses and lengths of the PCIe subsys and root ports.
-- bus-range: Range of bus numbers associated with this controller.
-- #address-cells: Address representation for root ports (must be 3)
-- pinctrl-names : The pin control state names.
-- pinctrl-0: The "default" pinctrl state.
-- #size-cells: Size representation for root ports (must be 2)
-- ranges: Ranges for the PCI memory and I/O regions.
-- #interrupt-cells: Must be 1
-- interrupt-map-mask and interrupt-map: Standard PCI IRQ mapping properties.
-  Please refer to the standard PCI bus binding document for a more detailed
-  explanation.
-- status: either "disabled" or "okay".
-- resets: Must contain an entry for each entry in reset-names.
-  See ../reset/reset.txt for details.
-- reset-names: Must be "pcie0", "pcie1", "pcieN"... based on the number of
-  root ports.
-- clocks: Must contain an entry for each entry in clock-names.
-  See ../clocks/clock-bindings.txt for details.
-- clock-names: Must be "pcie0", "pcie1", "pcieN"... based on the number of
-  root ports.
-- reset-gpios: GPIO specs for the reset pins.
-
-In addition, the device tree node must have sub-nodes describing each PCIe port
-interface, having the following mandatory properties:
-
-Required properties:
-- reg: Only the first four bytes are used to refer to the correct bus number
-      and device number.
-- #address-cells: Must be 3
-- #size-cells: Must be 2
-- ranges: Sub-ranges distributed from the PCIe controller node. An empty
-  property is sufficient.
-- bus-range: Range of bus numbers associated with this port.
-
-Example for MT7621:
-
-	pcie: pcie@1e140000 {
-		compatible = "mediatek,mt7621-pci";
-        reg = <0x1e140000 0x100    /* host-pci bridge registers */
-               0x1e142000 0x100    /* pcie port 0 RC control registers */
-               0x1e143000 0x100    /* pcie port 1 RC control registers */
-               0x1e144000 0x100>;  /* pcie port 2 RC control registers */
-
-		#address-cells = <3>;
-		#size-cells = <2>;
-
-		pinctrl-names = "default";
-		pinctrl-0 = <&pcie_pins>;
-
-		device_type = "pci";
-
-		bus-range = <0 255>;
-		ranges = <
-			0x02000000 0 0x00000000 0x60000000 0 0x10000000 /* pci memory */
-			0x01000000 0 0x00000000 0x1e160000 0 0x00010000 /* io space */
-		>;
-
-		#interrupt-cells = <1>;
-		interrupt-map-mask = <0xF0000 0 0 1>;
-		interrupt-map = <0x10000 0 0 1 &gic GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH>,
-				<0x20000 0 0 1 &gic GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH>,
-				<0x30000 0 0 1 &gic GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>;
-
-		status = "disabled";
-
-		resets = <&rstctrl 24 &rstctrl 25 &rstctrl 26>;
-		reset-names = "pcie0", "pcie1", "pcie2";
-		clocks = <&clkctrl 24 &clkctrl 25 &clkctrl 26>;
-		clock-names = "pcie0", "pcie1", "pcie2";
-
-		reset-gpios = <&gpio 19 GPIO_ACTIVE_LOW>,
-				<&gpio 8 GPIO_ACTIVE_LOW>,
-				<&gpio 7 GPIO_ACTIVE_LOW>;
-
-		pcie@0,0 {
-			reg = <0x0000 0 0 0 0>;
-			#address-cells = <3>;
-			#size-cells = <2>;
-			ranges;
-			bus-range = <0x00 0xff>;
-		};
-
-		pcie@1,0 {
-			reg = <0x0800 0 0 0 0>;
-			#address-cells = <3>;
-			#size-cells = <2>;
-			ranges;
-			bus-range = <0x00 0xff>;
-		};
-
-		pcie@2,0 {
-			reg = <0x1000 0 0 0 0>;
-			#address-cells = <3>;
-			#size-cells = <2>;
-			ranges;
-			bus-range = <0x00 0xff>;
-		};
-	};
-
Signature · 1 line
2.25.1
author maintainer
#4 lore raw

Hi Lorenzo,

Thanks for the review. See my comments below.

Quoted 46 lines · Lorenzo Pieralisi
Quoted 44 lines · Sergio Paracuellos

Add driver for the PCIe controller of the MT7621 SoC.

---
 arch/mips/ralink/Kconfig                      |   3 +-
 drivers/pci/controller/Kconfig                |   8 ++
 drivers/pci/controller/Makefile               |   1 +
 .../controller}/pci-mt7621.c                  |   0
 drivers/staging/Kconfig                       |   2 -
 drivers/staging/Makefile                      |   1 -
 drivers/staging/mt7621-pci/Kconfig            |   8 --
 drivers/staging/mt7621-pci/Makefile           |   2 -
 drivers/staging/mt7621-pci/TODO               |   4 -
 .../mt7621-pci/mediatek,mt7621-pci.txt        | 104 ------------------
 10 files changed, 11 insertions(+), 122 deletions(-)
 rename drivers/{staging/mt7621-pci => pci/controller}/pci-mt7621.c (100%)
 delete mode 100644 drivers/staging/mt7621-pci/Kconfig
 delete mode 100644 drivers/staging/mt7621-pci/Makefile
 delete mode 100644 drivers/staging/mt7621-pci/TODO
 delete mode 100644 drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt
arch/mips/ralink/Kconfig +2 -1
index c800bf5559b5..120adad51d6a 100644
@@ -51,7 +51,8 @@ choice
              select SYS_SUPPORTS_HIGHMEM
              select MIPS_GIC
              select CLKSRC_MIPS_GIC
-             select HAVE_PCI if PCI_MT7621
+             select HAVE_PCI
+             select PCI_DRIVERS_GENERIC
              select SOC_BUS
 endchoice
 
drivers/pci/controller/Kconfig +0 -0
index 326f7d13024f..b76404be0360 100644
@@ -312,6 +312,14 @@ config PCIE_HISI_ERR
        Say Y here if you want error handling support
        for the PCIe controller's errors on HiSilicon HIP SoCs
 
Quoted 6 lines

drivers/pci/controller/Kconfig config PCIE_HISI_ERR · line 317

Quoted 3 lines
drivers/pci/controller/Kconfig +3 -0
+config PCI_MT7621
+     tristate "MediaTek MT7621 PCI Controller"
+     depends on (RALINK && SOC_MT7621) || (MIPS && COMPILE_TEST)

- Is there a chance we can remove the MIPS dependency from the COMPILE_TEST conditional ?

Driver make use of the following functions to properly configure MIPS IO coherency regions for used pci addresses:
- 'mips_cps_numiocu()'
- 'write_gcr_reg1_base()'
- 'write_gcr_reg1_mask()'

Without configuring this, the PCI subsystem won't work. These three are a MIPS thing and we want at the very least to make COMPILE_TEST available for MIPS. To avoid this I guess we will need stubs for all the other architectures and I am not really sure it is really worthly and makes sense.

Quoted 2 lines

- I am not a big fan of "SOC_XXX" config options dependencies, actually there is none in pci/controller. Is there a way to remove it ?

I am not a Kconfig expert, so I am not sure :). This PCI driver needs only to be available for MIPS RALINK architecture for MT7621 SoCs and ideally enabled by default for SOC_MT7621. So I don't know if just doing the following is enough:

config PCI_MT7621

    tristate "MediaTek MT7621 PCI Controller"
    depends on RALINK || (MIPS && COMPILE_TEST)
    select PHY_MT7621_PCI
    default SOC_MT7621
    help
        This selects a driver for the MediaTek MT7621 PCI Controller.

Thanks in advance for clarification.

Best regards,
Sergio Paracuellos

Quoted 197 lines

Lorenzo

Quoted 194 lines
drivers/pci/controller/Kconfig +5 -0
+     select PHY_MT7621_PCI
+     default SOC_MT7621
+     help
+       This selects a driver for the MediaTek MT7621 PCI Controller.
+
 source "drivers/pci/controller/dwc/Kconfig"
 source "drivers/pci/controller/mobiveil/Kconfig"
 source "drivers/pci/controller/cadence/Kconfig"
drivers/pci/controller/Makefile +1 -0
index aaf30b3dcc14..f42a566353cb 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_VMD) += vmd.o
 obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o
 obj-$(CONFIG_PCI_LOONGSON) += pci-loongson.o
 obj-$(CONFIG_PCIE_HISI_ERR) += pcie-hisi-error.o
+obj-$(CONFIG_PCI_MT7621) += pci-mt7621.o
 # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
 obj-y                                += dwc/
 obj-y                                += mobiveil/
drivers/pci/controller/pci-mt7621.c renamed from drivers/staging/mt7621-pci/pci-mt7621.c +0 -0
similarity index 100%
rename from drivers/staging/mt7621-pci/pci-mt7621.c
rename to drivers/pci/controller/pci-mt7621.c
drivers/staging/Kconfig +0 -2
index e03627ad4460..59af251e7576 100644
@@ -86,8 +86,6 @@ source "drivers/staging/vc04_services/Kconfig"
 
 source "drivers/staging/pi433/Kconfig"
 
-source "drivers/staging/mt7621-pci/Kconfig"
-
 source "drivers/staging/mt7621-dma/Kconfig"
 
 source "drivers/staging/ralink-gdma/Kconfig"
drivers/staging/Makefile +0 -1
index c7f8d8d8dd11..76f413470bc8 100644
@@ -33,7 +33,6 @@ obj-$(CONFIG_KS7010)                += ks7010/
 obj-$(CONFIG_GREYBUS)                += greybus/
 obj-$(CONFIG_BCM2835_VCHIQ)  += vc04_services/
 obj-$(CONFIG_PI433)          += pi433/
-obj-$(CONFIG_PCI_MT7621)     += mt7621-pci/
 obj-$(CONFIG_SOC_MT7621)     += mt7621-dma/
 obj-$(CONFIG_DMA_RALINK)     += ralink-gdma/
 obj-$(CONFIG_SOC_MT7621)     += mt7621-dts/
drivers/staging/mt7621-pci/Kconfig deleted +0 -8
deleted file mode 100644
index ce58042f2f21..000000000000
@@ -1,8 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-config PCI_MT7621
-     tristate "MediaTek MT7621 PCI Controller"
-     depends on RALINK
-     select PCI_DRIVERS_GENERIC
-     help
-       This selects a driver for the MediaTek MT7621 PCI Controller.
-
drivers/staging/mt7621-pci/Makefile deleted +0 -2
deleted file mode 100644
index f4e651cf7ce3..000000000000
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_PCI_MT7621)       += pci-mt7621.o
drivers/staging/mt7621-pci/TODO deleted +0 -4
deleted file mode 100644
index d674a9ac85c1..000000000000
@@ -1,4 +0,0 @@
-
-- general code review and cleanup
-
-Cc: NeilBrown <[email protected]>
drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt deleted +0 -105
deleted file mode 100644
index 327a68267309..000000000000
@@ -1,104 +0,0 @@
-MediaTek MT7621 PCIe controller
-
-Required properties:
-- compatible: "mediatek,mt7621-pci"
-- device_type: Must be "pci"
-- reg: Base addresses and lengths of the PCIe subsys and root ports.
-- bus-range: Range of bus numbers associated with this controller.
-- #address-cells: Address representation for root ports (must be 3)
-- pinctrl-names : The pin control state names.
-- pinctrl-0: The "default" pinctrl state.
-- #size-cells: Size representation for root ports (must be 2)
-- ranges: Ranges for the PCI memory and I/O regions.
-- #interrupt-cells: Must be 1
-- interrupt-map-mask and interrupt-map: Standard PCI IRQ mapping properties.
-  Please refer to the standard PCI bus binding document for a more detailed
-  explanation.
-- status: either "disabled" or "okay".
-- resets: Must contain an entry for each entry in reset-names.
-  See ../reset/reset.txt for details.
-- reset-names: Must be "pcie0", "pcie1", "pcieN"... based on the number of
-  root ports.
-- clocks: Must contain an entry for each entry in clock-names.
-  See ../clocks/clock-bindings.txt for details.
-- clock-names: Must be "pcie0", "pcie1", "pcieN"... based on the number of
-  root ports.
-- reset-gpios: GPIO specs for the reset pins.
-
-In addition, the device tree node must have sub-nodes describing each PCIe port
-interface, having the following mandatory properties:
-
-Required properties:
-- reg: Only the first four bytes are used to refer to the correct bus number
-      and device number.
-- #address-cells: Must be 3
-- #size-cells: Must be 2
-- ranges: Sub-ranges distributed from the PCIe controller node. An empty
-  property is sufficient.
-- bus-range: Range of bus numbers associated with this port.
-
-Example for MT7621:
-
-     pcie: pcie@1e140000 {
-             compatible = "mediatek,mt7621-pci";
-        reg = <0x1e140000 0x100    /* host-pci bridge registers */
-               0x1e142000 0x100    /* pcie port 0 RC control registers */
-               0x1e143000 0x100    /* pcie port 1 RC control registers */
-               0x1e144000 0x100>;  /* pcie port 2 RC control registers */
-
-             #address-cells = <3>;
-             #size-cells = <2>;
-
-             pinctrl-names = "default";
-             pinctrl-0 = <&pcie_pins>;
-
-             device_type = "pci";
-
-             bus-range = <0 255>;
-             ranges = <
-                     0x02000000 0 0x00000000 0x60000000 0 0x10000000 /* pci memory */
-                     0x01000000 0 0x00000000 0x1e160000 0 0x00010000 /* io space */
-             >;
-
-             #interrupt-cells = <1>;
-             interrupt-map-mask = <0xF0000 0 0 1>;
-             interrupt-map = <0x10000 0 0 1 &gic GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH>,
-                             <0x20000 0 0 1 &gic GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH>,
-                             <0x30000 0 0 1 &gic GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>;
-
-             status = "disabled";
-
-             resets = <&rstctrl 24 &rstctrl 25 &rstctrl 26>;
-             reset-names = "pcie0", "pcie1", "pcie2";
-             clocks = <&clkctrl 24 &clkctrl 25 &clkctrl 26>;
-             clock-names = "pcie0", "pcie1", "pcie2";
-
-             reset-gpios = <&gpio 19 GPIO_ACTIVE_LOW>,
-                             <&gpio 8 GPIO_ACTIVE_LOW>,
-                             <&gpio 7 GPIO_ACTIVE_LOW>;
-
-             pcie@0,0 {
-                     reg = <0x0000 0 0 0 0>;
-                     #address-cells = <3>;
-                     #size-cells = <2>;
-                     ranges;
-                     bus-range = <0x00 0xff>;
-             };
-
-             pcie@1,0 {
-                     reg = <0x0800 0 0 0 0>;
-                     #address-cells = <3>;
-                     #size-cells = <2>;
-                     ranges;
-                     bus-range = <0x00 0xff>;
-             };
-
-             pcie@2,0 {
-                     reg = <0x1000 0 0 0 0>;
-                     #address-cells = <3>;
-                     #size-cells = <2>;
-                     ranges;
-                     bus-range = <0x00 0xff>;
-             };
-     };
-
--

2.25.1

author maintainer
#5 lore raw

PATCH v3 3/3 MAINTAINERS: add myself as maintainer of the MT7621 PCI controller driver

In reply to Sergio Paracuellos

Add myself as maintainer of the PCie Controlller driver for MT7621 SoCs.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index eeb4c70b3d5b..a7f0cbad7ac5 100644
@@ -11842,6 +11842,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/i2c/i2c-mt7621.txt
 F:	drivers/i2c/busses/i2c-mt7621.c
 
+MEDIATEK MT7621 PCI CONTROLLER DRIVER
+M:	Sergio Paracuellos <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml
+F:	drivers/pci/controller/pci-mt7621.c
+
 MEDIATEK MT7621 PHY PCI DRIVER
 M:	Sergio Paracuellos <[email protected]>
 S:	Maintained
Signature · 1 line
2.25.1
#6 lore raw

Re: [PATCH v3 3/3] MAINTAINERS: add myself as maintainer of the MT7621 PCI controller driver

Quoted 1 line · Sergio Paracuellos

Add myself as maintainer of the PCie Controlller driver for

PCIe Controller. :-)

Quoted 3 lines

MT7621 SoCs.

[...]

MBR, Sergei

author maintainer
#7 lore raw

Re: [PATCH v3 3/3] MAINTAINERS: add myself as maintainer of the MT7621 PCI controller driver

Hi Sergei,

Quoted 6 lines · Sergei Shtylyov
Quoted 1 line · Sergio Paracuellos

Add myself as maintainer of the PCie Controlller driver for

PCIe Controller. :-)

Ups, true :) I will send v4 with this fixed if more changes are needed.

Best regards,
Sergio Paracuellos

Quoted 8 lines
Quoted 4 lines

MT7621 SoCs.

[...]

MBR, Sergei

#8 lore raw
In reply to Sergio Paracuellos
Quoted 8 lines · Sergio Paracuellos

MediaTek MT7621 PCIe subsys supports single Root complex (RC) with 3 Root Ports. Each Root Ports supports a Gen1 1-lane Link. Topology is as follows:

MT7621 PCIe HOST Topology

[...]

Applied to pci/mt7621, thanks!

[1/3] dt-bindings: mt7621-pci: PCIe binding documentation for MT7621 SoCs

      https://git.kernel.org/lpieralisi/pci/c/e5bc5605e7
[2/3] PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver
      https://git.kernel.org/lpieralisi/pci/c/5797a2b2bc
[3/3] MAINTAINERS: add myself as maintainer of the MT7621 PCI controller driver
      https://git.kernel.org/lpieralisi/pci/c/eb1d7d438c

Thanks,
Lorenzo

author maintainer
#9 lore raw
Quoted 14 lines · Lorenzo Pieralisi
Quoted 8 lines · Sergio Paracuellos

MediaTek MT7621 PCIe subsys supports single Root complex (RC) with 3 Root Ports. Each Root Ports supports a Gen1 1-lane Link. Topology is as follows:

MT7621 PCIe HOST Topology

[...]

Applied to pci/mt7621, thanks!

[1/3] dt-bindings: mt7621-pci: PCIe binding documentation for MT7621 SoCs

Quoted 8 lines
      https://git.kernel.org/lpieralisi/pci/c/e5bc5605e7
[2/3] PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver
      https://git.kernel.org/lpieralisi/pci/c/5797a2b2bc
[3/3] MAINTAINERS: add myself as maintainer of the MT7621 PCI controller driver
      https://git.kernel.org/lpieralisi/pci/c/eb1d7d438c

Thanks,
Lorenzo

Thanks, Lorenzo.

Best regards,
Sergio Paracuellos

#10 lore raw
In reply to Lorenzo Pieralisi
Quoted 10 lines · Lorenzo Pieralisi
Quoted 8 lines · Sergio Paracuellos

MediaTek MT7621 PCIe subsys supports single Root complex (RC) with 3 Root Ports. Each Root Ports supports a Gen1 1-lane Link. Topology is as follows:

MT7621 PCIe HOST Topology

[...]

Quoted 8 lines

Applied to pci/mt7621, thanks!

[1/3] dt-bindings: mt7621-pci: PCIe binding documentation for MT7621 SoCs

      https://git.kernel.org/lpieralisi/pci/c/e5bc5605e7
[2/3] PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver
      https://git.kernel.org/lpieralisi/pci/c/5797a2b2bc
[3/3] MAINTAINERS: add myself as maintainer of the MT7621 PCI controller driver
      https://git.kernel.org/lpieralisi/pci/c/eb1d7d438c

Since this is a PCIe (not conventional PCI) controller, I vote for renaming these from:

PCI_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml drivers/pci/controller/pci-mt7621.c

to:

PCIE_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pcie.yaml drivers/pci/controller/pcie-mt7621.c

We have a mix of these, with many of the early PCIe drivers being named "pci", but I think that was my mistake and there's no reason to continue it.

I can do this locally unless somebody objects.

author maintainer
#11 lore raw

Hi Bjorn,

Quoted 30 lines · Bjorn Helgaas
Quoted 10 lines · Lorenzo Pieralisi
Quoted 8 lines · Sergio Paracuellos

MediaTek MT7621 PCIe subsys supports single Root complex (RC) with 3 Root Ports. Each Root Ports supports a Gen1 1-lane Link. Topology is as follows:

MT7621 PCIe HOST Topology

[...]

Quoted 8 lines

Applied to pci/mt7621, thanks!

[1/3] dt-bindings: mt7621-pci: PCIe binding documentation for MT7621 SoCs

      https://git.kernel.org/lpieralisi/pci/c/e5bc5605e7
[2/3] PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver
      https://git.kernel.org/lpieralisi/pci/c/5797a2b2bc
[3/3] MAINTAINERS: add myself as maintainer of the MT7621 PCI controller driver
      https://git.kernel.org/lpieralisi/pci/c/eb1d7d438c

Since this is a PCIe (not conventional PCI) controller, I vote for renaming these from:

PCI_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml drivers/pci/controller/pci-mt7621.c

to:

Quoted 7 lines

PCIE_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pcie.yaml drivers/pci/controller/pcie-mt7621.c

We have a mix of these, with many of the early PCIe drivers being named "pci", but I think that was my mistake and there's no reason to continue it.

I see.

Quoted 2 lines

I can do this locally unless somebody objects.

I have no problem at all. Only one question. Do you mean to change compatible string also, or only the name of the file? Let me know if I have to do anything.

Thanks,
Sergio Paracuellos

#12 lore raw
Quoted 18 lines · Sergio Paracuellos
Quoted 9 lines · Bjorn Helgaas

Since this is a PCIe (not conventional PCI) controller, I vote for renaming these from:

PCI_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml drivers/pci/controller/pci-mt7621.c

to:

Quoted 7 lines

PCIE_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pcie.yaml drivers/pci/controller/pcie-mt7621.c

We have a mix of these, with many of the early PCIe drivers being named "pci", but I think that was my mistake and there's no reason to continue it.

Quoted 8 lines

I see.

Quoted 2 lines

I can do this locally unless somebody objects.

I have no problem at all. Only one question. Do you mean to change compatible string also, or only the name of the file? Let me know if I have to do anything.

I didn't change the compatible string, to avoid a DT incompatibility. But I *did* change the Kconfig symbol to PCIE_MT7621, which could require changes to out-of-tree .configs. I'm open to suggestions either way for both things.

author maintainer
#13 lore raw
Quoted 25 lines · Bjorn Helgaas
Quoted 23 lines · Sergio Paracuellos
Quoted 9 lines · Bjorn Helgaas

Since this is a PCIe (not conventional PCI) controller, I vote for renaming these from:

PCI_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml drivers/pci/controller/pci-mt7621.c

to:

Quoted 7 lines

PCIE_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pcie.yaml drivers/pci/controller/pcie-mt7621.c

We have a mix of these, with many of the early PCIe drivers being named "pci", but I think that was my mistake and there's no reason to continue it.

I see.

Quoted 2 lines

I can do this locally unless somebody objects.

Quoted 8 lines
Quoted 3 lines

I have no problem at all. Only one question. Do you mean to change compatible string also, or only the name of the file? Let me know if I have to do anything.

I didn't change the compatible string, to avoid a DT incompatibility. But I *did* change the Kconfig symbol to PCIE_MT7621, which could require changes to out-of-tree .configs. I'm open to suggestions either way for both things.

IMHO, I do think we should not worry about out-of-tree stuff at all. If the correct way to define the Kconfig symbol or the compatible string is to change them, just do that. MT7621 SoC is extensively used by openWRT community. As far as I have seen until now, the way of doing things there is to take the latest long term kernel (now they are using 5.4 as stable and 5.10 as testing kernel), apply a bunch of patches they have and do a complete build of both kernel, device tree and rootfs. So I guess it is not a big problem if we also change compatible string since when an update is performed for a device all of the stuff is just replaced. Maybe I am wrong and John has a different opinion... John, any comments on this?

Best regards,
Sergio Paracuellos

#14 lore raw
Quoted 30 lines · Sergio Paracuellos
Quoted 29 lines · Bjorn Helgaas
Quoted 26 lines · Sergio Paracuellos
Quoted 9 lines · Bjorn Helgaas

Since this is a PCIe (not conventional PCI) controller, I vote for renaming these from:

PCI_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml drivers/pci/controller/pci-mt7621.c

to:

Quoted 7 lines

PCIE_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pcie.yaml drivers/pci/controller/pcie-mt7621.c

We have a mix of these, with many of the early PCIe drivers being named "pci", but I think that was my mistake and there's no reason to continue it.

I see.

Quoted 2 lines

I can do this locally unless somebody objects.

I have no problem at all. Only one question. Do you mean to change compatible string also, or only the name of the file? Let me know if I have to do anything.

Quoted 6 lines
Quoted 4 lines

I didn't change the compatible string, to avoid a DT incompatibility. But I *did* change the Kconfig symbol to PCIE_MT7621, which could require changes to out-of-tree .configs. I'm open to suggestions either way for both things.

IMHO, I do think we should not worry about out-of-tree stuff at all.

For Kconfig I tend to agree. For DT I see some "bindings" in the staging tree are being deleted and published as official DT bindings with this patchset but I believe we still have to keep the compatible string backward compatibility regardless because there may be firmware out there using it.

Rob, what's the standard policy that should be used in this case ?

Thanks,
Lorenzo

Quoted 13 lines

If the correct way to define the Kconfig symbol or the compatible string is to change them, just do that. MT7621 SoC is extensively used by openWRT community. As far as I have seen until now, the way of doing things there is to take the latest long term kernel (now they are using 5.4 as stable and 5.10 as testing kernel), apply a bunch of patches they have and do a complete build of both kernel, device tree and rootfs. So I guess it is not a big problem if we also change compatible string since when an update is performed for a device all of the stuff is just replaced. Maybe I am wrong and John has a different opinion... John, any comments on this?

Best regards,
Sergio Paracuellos

author maintainer
#15 lore raw
Quoted 37 lines · Lorenzo Pieralisi
Quoted 35 lines · Sergio Paracuellos
Quoted 33 lines · Bjorn Helgaas
Quoted 18 lines · Sergio Paracuellos
Quoted 9 lines · Bjorn Helgaas

Since this is a PCIe (not conventional PCI) controller, I vote for renaming these from:

PCI_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml drivers/pci/controller/pci-mt7621.c

to:

Quoted 7 lines

PCIE_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pcie.yaml drivers/pci/controller/pcie-mt7621.c

We have a mix of these, with many of the early PCIe drivers being named "pci", but I think that was my mistake and there's no reason to continue it.

Quoted 8 lines

I see.

Quoted 2 lines

I can do this locally unless somebody objects.

I have no problem at all. Only one question. Do you mean to change compatible string also, or only the name of the file? Let me know if I have to do anything.

I didn't change the compatible string, to avoid a DT incompatibility. But I *did* change the Kconfig symbol to PCIE_MT7621, which could require changes to out-of-tree .configs. I'm open to suggestions either way for both things.

Quoted 7 lines
Quoted 1 line

IMHO, I do think we should not worry about out-of-tree stuff at all.

For Kconfig I tend to agree. For DT I see some "bindings" in the staging tree are being deleted and published as official DT bindings with this patchset but I believe we still have to keep the compatible string backward compatibility regardless because there may be firmware out there using it.

The bindings txt file removed in staging with this patchset was also added by me three years ago[0], and has been changing until the YAML bindings are reviewed by Rob and driver updated accordly in this patchset.
OpenWRT maintains its own file[1] which I don't know is updated or not according to the one in staging which I am pretending to properly mainline for 5.17. But yes, I agree there might be firmware out there using current compatible string.

[0]: Commit 5451e22618b8 ("staging: mt7621-pci: dt-bindings: add dt bindings for mt7621 pcie controller")
[1]: https://github.com/openwrt/openwrt/blob/master/target/linux/ramips/dts/mt7621.dtsi

Best regards,
Sergio Paracuellos

Quoted 19 lines

Rob, what's the standard policy that should be used in this case ?

Thanks,
Lorenzo

Quoted 13 lines

If the correct way to define the Kconfig symbol or the compatible string is to change them, just do that. MT7621 SoC is extensively used by openWRT community. As far as I have seen until now, the way of doing things there is to take the latest long term kernel (now they are using 5.4 as stable and 5.10 as testing kernel), apply a bunch of patches they have and do a complete build of both kernel, device tree and rootfs. So I guess it is not a big problem if we also change compatible string since when an update is performed for a device all of the stuff is just replaced. Maybe I am wrong and John has a different opinion... John, any comments on this?

Best regards,
Sergio Paracuellos

#16 lore raw
Quoted 52 lines · Sergio Paracuellos
Quoted 36 lines · Lorenzo Pieralisi
Quoted 34 lines · Sergio Paracuellos
Quoted 32 lines · Bjorn Helgaas
Quoted 18 lines · Sergio Paracuellos
Quoted 9 lines · Bjorn Helgaas

Since this is a PCIe (not conventional PCI) controller, I vote for renaming these from:

PCI_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml drivers/pci/controller/pci-mt7621.c

to:

Quoted 7 lines

PCIE_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pcie.yaml drivers/pci/controller/pcie-mt7621.c

We have a mix of these, with many of the early PCIe drivers being named "pci", but I think that was my mistake and there's no reason to continue it.

Quoted 7 lines

I see.

Quoted 1 line

I can do this locally unless somebody objects.

I have no problem at all. Only one question. Do you mean to change compatible string also, or only the name of the file? Let me know if I have to do anything.

I didn't change the compatible string, to avoid a DT incompatibility. But I *did* change the Kconfig symbol to PCIE_MT7621, which could require changes to out-of-tree .configs. I'm open to suggestions either way for both things.

Quoted 8 lines
Quoted 2 lines

IMHO, I do think we should not worry about out-of-tree stuff at all.

For Kconfig I tend to agree. For DT I see some "bindings" in the staging tree are being deleted and published as official DT bindings with this patchset but I believe we still have to keep the compatible string backward compatibility regardless because there may be firmware out there using it.

The bindings txt file removed in staging with this patchset was also added by me three years ago[0], and has been changing until the YAML bindings are reviewed by Rob and driver updated accordly in this patchset.

Quoted 8 lines

OpenWRT maintains its own file[1] which I don't know is updated or not according to the one in staging which I am pretending to properly mainline for 5.17. But yes, I agree there might be firmware out there using current compatible string.

[0]: Commit 5451e22618b8 ("staging: mt7621-pci: dt-bindings: add dt bindings for mt7621 pcie controller")
[1]: https://github.com/openwrt/openwrt/blob/master/target/linux/ramips/dts/mt7621.dtsi

OK, for now I left my rework as-is:

- changed CONFIG_PCI_MT7621 to CONFIG_PCIE_MT7621
- renamed mediatek,mt7621-pci.yaml to mediatek,mt7621-pcie.yaml
- renamed pci-mt7621.c to pcie-mt7621.c
- kept DT compatible string "mediatek,mt7621-pci" in .yaml and .c

I reason that the Kconfig and filename changes only affect people building kernels or DTs, but a compatible string change would force a DT update to be synchronized with a kernel update.

Happy to change this if necessary.

Bjorn

author maintainer
#17 lore raw
Quoted 65 lines · Bjorn Helgaas
Quoted 52 lines · Sergio Paracuellos
Quoted 36 lines · Lorenzo Pieralisi
Quoted 34 lines · Sergio Paracuellos
Quoted 32 lines · Bjorn Helgaas
Quoted 18 lines · Sergio Paracuellos
Quoted 9 lines · Bjorn Helgaas

Since this is a PCIe (not conventional PCI) controller, I vote for renaming these from:

PCI_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pci.yaml drivers/pci/controller/pci-mt7621.c

to:

Quoted 7 lines

PCIE_MT7621 Documentation/devicetree/bindings/pci/mediatek,mt7621-pcie.yaml drivers/pci/controller/pcie-mt7621.c

We have a mix of these, with many of the early PCIe drivers being named "pci", but I think that was my mistake and there's no reason to continue it.

Quoted 7 lines

I see.

Quoted 1 line

I can do this locally unless somebody objects.

I have no problem at all. Only one question. Do you mean to change compatible string also, or only the name of the file? Let me know if I have to do anything.

I didn't change the compatible string, to avoid a DT incompatibility. But I *did* change the Kconfig symbol to PCIE_MT7621, which could require changes to out-of-tree .configs. I'm open to suggestions either way for both things.

Quoted 8 lines
Quoted 2 lines

IMHO, I do think we should not worry about out-of-tree stuff at all.

For Kconfig I tend to agree. For DT I see some "bindings" in the staging tree are being deleted and published as official DT bindings with this patchset but I believe we still have to keep the compatible string backward compatibility regardless because there may be firmware out there using it.

The bindings txt file removed in staging with this patchset was also added by me three years ago[0], and has been changing until the YAML bindings are reviewed by Rob and driver updated accordly in this patchset.

Quoted 8 lines

OpenWRT maintains its own file[1] which I don't know is updated or not according to the one in staging which I am pretending to properly mainline for 5.17. But yes, I agree there might be firmware out there using current compatible string.

[0]: Commit 5451e22618b8 ("staging: mt7621-pci: dt-bindings: add dt bindings for mt7621 pcie controller")
[1]: https://github.com/openwrt/openwrt/blob/master/target/linux/ramips/dts/mt7621.dtsi

OK, for now I left my rework as-is:

Quoted 8 lines

- changed CONFIG_PCI_MT7621 to CONFIG_PCIE_MT7621
- renamed mediatek,mt7621-pci.yaml to mediatek,mt7621-pcie.yaml
- renamed pci-mt7621.c to pcie-mt7621.c
- kept DT compatible string "mediatek,mt7621-pci" in .yaml and .c

I reason that the Kconfig and filename changes only affect people building kernels or DTs, but a compatible string change would force a DT update to be synchronized with a kernel update.

This is all ok for me, Bjorn. Thanks for doing this. I guess even if we don't force people to a DT update to synchronize things, since bindings have been changed until they have been approved, I guess most people must upgrade from early not approved DT early versions in any case. But in any case I guess that maintaining the compatible string is the safest thing to do.

Quoted 2 lines

Happy to change this if necessary.

Best regards,
Sergio Paracuellos

Quoted 2 lines

Bjorn