Skip to contentSkip to conversation

PCI: mediatek: Add new generation controller support

PATCH Superseded Jianjun Wang 3 participants 8 messages Sep 27, 2020 – Nov 3, 2020

Subsystems (5)

v3 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v3 cover PCI: mediatek: Add new generation controller support

These series patches add pcie-mediatek-gen3.c and dt-bindings file to support new generation PCIe controller.

Changes in v3:
1. Remove standard property in binding document
2. Return error number when get_optional* API throws an error
3. Use the bulk clk APIs

Changes in v2:
1. Fix the typo of dt-bindings patch
2. Remove the unnecessary properties in binding document
3. dispos the irq mappings of msi top domain when irq teardown

Jianjun Wang (3):
dt-bindings: PCI: mediatek: Add YAML schema
PCI: mediatek: Add new generation controller support
MAINTAINERS: update entry for MediaTek PCIe controller

 .../bindings/pci/mediatek-pcie-gen3.yaml      |  126 ++
 MAINTAINERS                                   |    1 +
 drivers/pci/controller/Kconfig                |   14 +
 drivers/pci/controller/Makefile               |    1 +
 drivers/pci/controller/pcie-mediatek-gen3.c   | 1024 +++++++++++++++++
 5 files changed, 1166 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml
 create mode 100644 drivers/pci/controller/pcie-mediatek-gen3.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/3 dt-bindings: PCI: mediatek: Add YAML schema

Add YAML schemas documentation for Gen3 PCIe controller on MediaTek SoCs.

---
 .../bindings/pci/mediatek-pcie-gen3.yaml      | 126 ++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml
Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml new file +126 -0
new file mode 100644
index 000000000000..c7b5dd132ebd
@@ -0,0 +1,126 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pci/mediatek-pcie-gen3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Gen3 PCIe controller on MediaTek SoCs
+
+maintainers:
+  - Jianjun Wang <[email protected]>
+
+allOf:
+  - $ref: /schemas/pci/pci-bus.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - const: mediatek,mt8192-pcie
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  ranges:
+    minItems: 1
+    maxItems: 8
+
+  resets:
+    minItems: 1
+    maxItems: 2
+
+  reset-names:
+    anyOf:
+      - const: mac-rst
+      - const: phy-rst
+
+  clocks:
+    maxItems: 5
+
+  assigned-clocks:
+    maxItems: 1
+
+  assigned-clock-parents:
+    maxItems: 1
+
+  phys:
+    maxItems: 1
+
+  '#interrupt-cells':
+    const: 1
+
+  interrupt-controller:
+    description: Interrupt controller node for handling legacy PCI interrupts.
+    type: object
+    properties:
+      '#address-cells':
+        const: 0
+      '#interrupt-cells':
+        const: 1
+      interrupt-controller: true
+
+    required:
+      - '#address-cells'
+      - '#interrupt-cells'
+      - interrupt-controller
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - ranges
+  - clocks
+  - '#interrupt-cells'
+  - interrupt-controller
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    bus {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        pcie: pcie@11230000 {
+            compatible = "mediatek,mt8192-pcie";
+            device_type = "pci";
+            #address-cells = <3>;
+            #size-cells = <2>;
+            reg = <0x00 0x11230000 0x00 0x4000>;
+            reg-names = "pcie-mac";
+            interrupts = <GIC_SPI 251 IRQ_TYPE_LEVEL_HIGH 0>;
+            bus-range = <0x00 0xff>;
+            ranges = <0x82000000 0x00 0x12000000 0x00 0x12000000 0x00 0x1000000>;
+            clocks = <&infracfg 40>,
+                     <&infracfg 43>,
+                     <&infracfg 97>,
+                     <&infracfg 99>,
+                     <&infracfg 111>;
+            assigned-clocks = <&topckgen 50>;
+            assigned-clock-parents = <&topckgen 91>;
+
+            phys = <&pciephy>;
+            phy-names = "pcie-phy";
+            resets = <&infracfg_rst 0>;
+            reset-names = "phy-rst";
+
+            #interrupt-cells = <1>;
+            interrupt-map-mask = <0 0 0 0x7>;
+            interrupt-map = <0 0 0 1 &pcie_intc 0>,
+                            <0 0 0 2 &pcie_intc 1>,
+                            <0 0 0 3 &pcie_intc 2>,
+                            <0 0 0 4 &pcie_intc 3>;
+            pcie_intc: interrupt-controller {
+                      #address-cells = <0>;
+                      #interrupt-cells = <1>;
+                      interrupt-controller;
+            };
+        };
+    };
Signature · 1 line
2.25.1
#7 lore raw

PATCH v3 3/3 MAINTAINERS: update entry for MediaTek PCIe controller

In reply to Jianjun Wang

Add maintainer for MediaTek PCIe controller driver.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index deaafb617361..5c6110468526 100644
@@ -13459,6 +13459,7 @@ F:	drivers/pci/controller/dwc/pcie-histb.c
 
 PCIE DRIVER FOR MEDIATEK
 M:	Ryder Lee <[email protected]>
+M:	Jianjun Wang <[email protected]>
 L:	[email protected]
 L:	[email protected]
 S:	Supported
Signature · 1 line
2.25.1
#4 lore raw

PATCH v3 2/3 PCI: mediatek: Add new generation controller support

In reply to Jianjun Wang

MediaTek's PCIe host controller has three generation HWs, the new generation HW is an individual bridge, it supoorts Gen3 speed and up to 256 MSI interrupt numbers for multi-function devices.

Add support for new Gen3 controller which can be found on MT8192.

---
 drivers/pci/controller/Kconfig              |   14 +
 drivers/pci/controller/Makefile             |    1 +
 drivers/pci/controller/pcie-mediatek-gen3.c | 1024 +++++++++++++++++++
 3 files changed, 1039 insertions(+)
 create mode 100644 drivers/pci/controller/pcie-mediatek-gen3.c
drivers/pci/controller/Kconfig +14 -0
index f18c3725ef80..83daa772595b 100644
@@ -239,6 +239,20 @@ config PCIE_MEDIATEK
 	  Say Y here if you want to enable PCIe controller support on
 	  MediaTek SoCs.
 
+config PCIE_MEDIATEK_GEN3
+	tristate "MediaTek GEN3 PCIe controller"
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	depends on OF
+	depends on PCI_MSI_IRQ_DOMAIN
+	help
+	  Adds support for PCIe Gen3 MAC controller for MediaTek SoCs.
+	  This PCIe controller provides the capable of Gen3, Gen2 and
+	  Gen1 speed, and support up to 256 MSI interrupt numbers for
+	  multi-function devices.
+
+	  Say Y here if you want to enable Gen3 PCIe controller support on
+	  MediaTek SoCs.
+
 config PCIE_TANGO_SMP8759
 	bool "Tango SMP8759 PCIe controller (DANGEROUS)"
 	depends on ARCH_TANGO && PCI_MSI && OF
drivers/pci/controller/Makefile +1 -0
index bcdbf49ab1e4..9c1b96777597 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_PCIE_ROCKCHIP) += pcie-rockchip.o
 obj-$(CONFIG_PCIE_ROCKCHIP_EP) += pcie-rockchip-ep.o
 obj-$(CONFIG_PCIE_ROCKCHIP_HOST) += pcie-rockchip-host.o
 obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o
+obj-$(CONFIG_PCIE_MEDIATEK_GEN3) += pcie-mediatek-gen3.o
 obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o
 obj-$(CONFIG_VMD) += vmd.o
 obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o
drivers/pci/controller/pcie-mediatek-gen3.c new file +1024 -0

1,024 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

Re: [v3,1/3] dt-bindings: PCI: mediatek: Add YAML schema

In reply to Jianjun Wang
Quoted 43 lines · Jianjun Wang

Add YAML schemas documentation for Gen3 PCIe controller on MediaTek SoCs.

---
 .../bindings/pci/mediatek-pcie-gen3.yaml      | 126 ++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml
Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml new file +27 -0
new file mode 100644
index 000000000000..c7b5dd132ebd
@@ -0,0 +1,126 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pci/mediatek-pcie-gen3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Gen3 PCIe controller on MediaTek SoCs
+
+maintainers:
+  - Jianjun Wang <[email protected]>
+
+allOf:
+  - $ref: /schemas/pci/pci-bus.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - const: mediatek,mt8192-pcie
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  ranges:
+    minItems: 1

Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml line 37

Quoted 10 lines
Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml new file +10 -0
+    maxItems: 8
+
+  resets:
+    minItems: 1
+    maxItems: 2
+
+  reset-names:
+    anyOf:
+      - const: mac-rst
+      - const: phy-rst

The "-rst" suffix seems redundant. Unless these are exactly the names used in the documentation, I'd just call them "mac" and "phy".

regards
Philipp

#5 lore raw
In reply to Jianjun Wang

Hi Jianjun,

Quoted 15 lines · Jianjun Wang

MediaTek's PCIe host controller has three generation HWs, the new generation HW is an individual bridge, it supoorts Gen3 speed and up to 256 MSI interrupt numbers for multi-function devices.

Add support for new Gen3 controller which can be found on MT8192.

---
 drivers/pci/controller/Kconfig              |   14 +
 drivers/pci/controller/Makefile             |    1 +
 drivers/pci/controller/pcie-mediatek-gen3.c | 1024 +++++++++++++++++++
 3 files changed, 1039 insertions(+)
 create mode 100644 drivers/pci/controller/pcie-mediatek-gen3.c

[...]

Quoted 6 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +0 -0
new file mode 100644
index 000000000000..ad69c789b24d
@@ -0,0 +1,1024 @@

[...]

drivers/pci/controller/pcie-mediatek-gen3.c line 775

Quoted 11 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +11 -0
+static int mtk_pcie_power_up(struct mtk_pcie_port *port)
+{
+	struct device *dev = port->dev;
+	int err;
+
+	port->phy_reset = devm_reset_control_get_optional_exclusive(dev,
+								    "phy-rst");
+	if (IS_ERR(port->phy_reset))
+		return PTR_ERR(port->phy_reset);
+
+	reset_control_deassert(port->phy_reset);

In general, it is better to request all required resources before starting to activate the hardware.

drivers/pci/controller/pcie-mediatek-gen3.c line 780

Quoted 5 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +5 -0
+
+	/* PHY power on and enable pipe clock */
+	port->phy = devm_phy_optional_get(dev, "pcie-phy");
+	if (IS_ERR(port->phy))
+		return PTR_ERR(port->phy);

For example, if the PHY driver is not loaded yet and this returns -EPROBE_DEFER, it was not useful to take the PHY out of reset above. Also, phy-rst is kept deasserted if this fails.

drivers/pci/controller/pcie-mediatek-gen3.c line 785

Quoted 5 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +5 -0
+
+	err = phy_init(port->phy);
+	if (err) {
+		dev_notice(dev, "failed to initialize pcie phy\n");
+		return err;

phy-rst is kept deasserted if this fails.

drivers/pci/controller/pcie-mediatek-gen3.c line 797

Quoted 12 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +12 -0
+	}
+
+	err = phy_power_on(port->phy);
+	if (err) {
+		dev_notice(dev, "failed to power on pcie phy\n");
+		goto err_phy_on;
+	}
+
+	port->mac_reset = devm_reset_control_get_optional_exclusive(dev,
+								    "mac-rst");
+	if (IS_ERR(port->mac_reset))
+		return PTR_ERR(port->mac_reset);

The PHY is not powered down if this fails.

Quoted 23 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +23 -0
+
+	reset_control_deassert(port->mac_reset);
+
+	/* MAC power on and enable transaction layer clocks */
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);
+
+	err = mtk_pcie_clk_init(port);
+	if (err) {
+		dev_notice(dev, "clock init failed\n");
+		goto err_clk_init;
+	}
+
+	return 0;
+
+err_clk_init:
+	pm_runtime_put_sync(dev);
+	pm_runtime_disable(dev);
+	reset_control_assert(port->mac_reset);
+	phy_power_off(port->phy);
+err_phy_on:
+	phy_exit(port->phy);
+	reset_control_assert(port->phy_reset);

drivers/pci/controller/pcie-mediatek-gen3.c line 830

Quoted 10 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +10 -0
+
+	return -EBUSY;
+}
+
+static void mtk_pcie_power_down(struct mtk_pcie_port *port)
+{
+	phy_power_off(port->phy);
+	phy_exit(port->phy);
+
+	clk_bulk_disable_unprepare(port->num_clks, port->clks);

In the power-up sequence clocks are enabled last, but here they are not disabled before the PHY is powered off. Is this on purpose?

drivers/pci/controller/pcie-mediatek-gen3.c line 833

Quoted 3 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +3 -0
+
+	pm_runtime_put_sync(port->dev);
+	pm_runtime_disable(port->dev);

In the power-up error path, PHY and controller resets are asserted again, but here they are kept deasserted. Should they be asserted here as well?

regards
Philipp

maintainer
#3 lore raw

Re: [v3,1/3] dt-bindings: PCI: mediatek: Add YAML schema

In reply to Jianjun Wang
Quoted 24 lines · Jianjun Wang

Add YAML schemas documentation for Gen3 PCIe controller on MediaTek SoCs.

---
 .../bindings/pci/mediatek-pcie-gen3.yaml      | 126 ++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml
Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml new file +8 -0
new file mode 100644
index 000000000000..c7b5dd132ebd
@@ -0,0 +1,126 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pci/mediatek-pcie-gen3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Gen3 PCIe controller on MediaTek SoCs
+

Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml line 18

Quoted 10 lines
Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml new file +10 -0
+maintainers:
+  - Jianjun Wang <[email protected]>
+
+allOf:
+  - $ref: /schemas/pci/pci-bus.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - const: mediatek,mt8192-pcie

Don't need 'oneOf' with only 1 entry.

Quoted 12 lines
Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml new file +12 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  ranges:
+    minItems: 1
+    maxItems: 8
+
+  resets:

Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml line 40

Quoted 10 lines
Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml new file +10 -0
+    minItems: 1
+    maxItems: 2
+
+  reset-names:
+    anyOf:
+      - const: mac-rst
+      - const: phy-rst
+
+  clocks:
+    maxItems: 5

Need to define what the clocks are and order.

Quoted 88 lines
Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml new file +86 -0
+
+  assigned-clocks:
+    maxItems: 1
+
+  assigned-clock-parents:
+    maxItems: 1
+
+  phys:
+    maxItems: 1
+
+  '#interrupt-cells':
+    const: 1
+
+  interrupt-controller:
+    description: Interrupt controller node for handling legacy PCI interrupts.
+    type: object
+    properties:
+      '#address-cells':
+        const: 0
+      '#interrupt-cells':
+        const: 1
+      interrupt-controller: true
+
+    required:
+      - '#address-cells'
+      - '#interrupt-cells'
+      - interrupt-controller
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - ranges
+  - clocks
+  - '#interrupt-cells'
+  - interrupt-controller
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    bus {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        pcie: pcie@11230000 {
+            compatible = "mediatek,mt8192-pcie";
+            device_type = "pci";
+            #address-cells = <3>;
+            #size-cells = <2>;
+            reg = <0x00 0x11230000 0x00 0x4000>;
+            reg-names = "pcie-mac";
+            interrupts = <GIC_SPI 251 IRQ_TYPE_LEVEL_HIGH 0>;
+            bus-range = <0x00 0xff>;
+            ranges = <0x82000000 0x00 0x12000000 0x00 0x12000000 0x00 0x1000000>;
+            clocks = <&infracfg 40>,
+                     <&infracfg 43>,
+                     <&infracfg 97>,
+                     <&infracfg 99>,
+                     <&infracfg 111>;
+            assigned-clocks = <&topckgen 50>;
+            assigned-clock-parents = <&topckgen 91>;
+
+            phys = <&pciephy>;
+            phy-names = "pcie-phy";
+            resets = <&infracfg_rst 0>;
+            reset-names = "phy-rst";
+
+            #interrupt-cells = <1>;
+            interrupt-map-mask = <0 0 0 0x7>;
+            interrupt-map = <0 0 0 1 &pcie_intc 0>,
+                            <0 0 0 2 &pcie_intc 1>,
+                            <0 0 0 3 &pcie_intc 2>,
+                            <0 0 0 4 &pcie_intc 3>;
+            pcie_intc: interrupt-controller {
+                      #address-cells = <0>;
+                      #interrupt-cells = <1>;
+                      interrupt-controller;
+            };
+        };
+    };
Signature · 1 line
2.25.1
#6 lore raw
In reply to Philipp Zabel
Quoted 119 lines · Philipp Zabel

Hi Jianjun,

Quoted 15 lines · Jianjun Wang

MediaTek's PCIe host controller has three generation HWs, the new generation HW is an individual bridge, it supoorts Gen3 speed and up to 256 MSI interrupt numbers for multi-function devices.

Add support for new Gen3 controller which can be found on MT8192.

---
 drivers/pci/controller/Kconfig              |   14 +
 drivers/pci/controller/Makefile             |    1 +
 drivers/pci/controller/pcie-mediatek-gen3.c | 1024 +++++++++++++++++++
 3 files changed, 1039 insertions(+)
 create mode 100644 drivers/pci/controller/pcie-mediatek-gen3.c

[...]

Quoted 6 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +0 -0
new file mode 100644
index 000000000000..ad69c789b24d
@@ -0,0 +1,1024 @@

[...]

drivers/pci/controller/pcie-mediatek-gen3.c line 775

Quoted 11 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +11 -0
+static int mtk_pcie_power_up(struct mtk_pcie_port *port)
+{
+	struct device *dev = port->dev;
+	int err;
+
+	port->phy_reset = devm_reset_control_get_optional_exclusive(dev,
+								    "phy-rst");
+	if (IS_ERR(port->phy_reset))
+		return PTR_ERR(port->phy_reset);
+
+	reset_control_deassert(port->phy_reset);

In general, it is better to request all required resources before starting to activate the hardware.

drivers/pci/controller/pcie-mediatek-gen3.c line 780

Quoted 5 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +5 -0
+
+	/* PHY power on and enable pipe clock */
+	port->phy = devm_phy_optional_get(dev, "pcie-phy");
+	if (IS_ERR(port->phy))
+		return PTR_ERR(port->phy);

For example, if the PHY driver is not loaded yet and this returns -EPROBE_DEFER, it was not useful to take the PHY out of reset above. Also, phy-rst is kept deasserted if this fails.

drivers/pci/controller/pcie-mediatek-gen3.c line 785

Quoted 5 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +5 -0
+
+	err = phy_init(port->phy);
+	if (err) {
+		dev_notice(dev, "failed to initialize pcie phy\n");
+		return err;

phy-rst is kept deasserted if this fails.

drivers/pci/controller/pcie-mediatek-gen3.c line 797

Quoted 12 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +12 -0
+	}
+
+	err = phy_power_on(port->phy);
+	if (err) {
+		dev_notice(dev, "failed to power on pcie phy\n");
+		goto err_phy_on;
+	}
+
+	port->mac_reset = devm_reset_control_get_optional_exclusive(dev,
+								    "mac-rst");
+	if (IS_ERR(port->mac_reset))
+		return PTR_ERR(port->mac_reset);

The PHY is not powered down if this fails.

Quoted 23 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +23 -0
+
+	reset_control_deassert(port->mac_reset);
+
+	/* MAC power on and enable transaction layer clocks */
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);
+
+	err = mtk_pcie_clk_init(port);
+	if (err) {
+		dev_notice(dev, "clock init failed\n");
+		goto err_clk_init;
+	}
+
+	return 0;
+
+err_clk_init:
+	pm_runtime_put_sync(dev);
+	pm_runtime_disable(dev);
+	reset_control_assert(port->mac_reset);
+	phy_power_off(port->phy);
+err_phy_on:
+	phy_exit(port->phy);
+	reset_control_assert(port->phy_reset);

drivers/pci/controller/pcie-mediatek-gen3.c line 830

Quoted 10 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +10 -0
+
+	return -EBUSY;
+}
+
+static void mtk_pcie_power_down(struct mtk_pcie_port *port)
+{
+	phy_power_off(port->phy);
+	phy_exit(port->phy);
+
+	clk_bulk_disable_unprepare(port->num_clks, port->clks);

In the power-up sequence clocks are enabled last, but here they are not disabled before the PHY is powered off. Is this on purpose?

drivers/pci/controller/pcie-mediatek-gen3.c line 833

Quoted 3 lines
drivers/pci/controller/pcie-mediatek-gen3.c new file +3 -0
+
+	pm_runtime_put_sync(port->dev);
+	pm_runtime_disable(port->dev);

In the power-up error path, PHY and controller resets are asserted again, but here they are kept deasserted. Should they be asserted here as well?

Quoted 2 lines

regards
Philipp

Hi Philipp,

Sorry for the late responding and thanks for your review, I will fix it in the next version.

Thanks.