Skip to contentSkip to conversation

phy: mediatek: Add PCIe PHY driver

PATCH Superseded Jianjun Wang 2 participants 5 messages Apr 22, 2022 – May 5, 2022

Subsystems (4)

v7 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v7 cover phy: mediatek: Add PCIe PHY driver

These series patches add support for PCIe PHY driver on MediaTek chipsets.

Changes in v7:
1. Add bitfield.h header to fix the build error on non-arm64 platforms.

Changes in v6:
1. Remove unnecessary header files;
2. Use FILELD_PREP in bitfield.h to set value.

Changes in v5:
1. Fix typo in kerneldoc: "eFues" => "eFuse".

Changes in v4:
1. Fix no return when calling dev_err_probe.

Changes in v3:
1. Add introductions for structure members;
2. Add SoC dependent data;
3. Dynamically allocate efuse data;
4. Check return value if it's an -EPROBE_DEFER.

Changes in v2:
1. Add specific compatible name;
2. Read NVMEM data at probe time;
3. Fix typos.

Jianjun Wang (2):
dt-bindings: phy: mediatek: Add YAML schema for PCIe PHY
phy: mediatek: Add PCIe PHY driver

 .../bindings/phy/mediatek,pcie-phy.yaml       |  75 +++++
 drivers/phy/mediatek/Kconfig                  |  11 +
 drivers/phy/mediatek/Makefile                 |   1 +
 drivers/phy/mediatek/phy-mtk-pcie.c           | 267 ++++++++++++++++++
 4 files changed, 354 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/mediatek,pcie-phy.yaml
 create mode 100644 drivers/phy/mediatek/phy-mtk-pcie.c
Signature · 7 lines
2.18.0


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#1 lore raw

PATCH v7 1/2 dt-bindings: phy: mediatek: Add YAML schema for PCIe PHY

Add YAML schema documentation for PCIe PHY on MediaTek chipsets.

---
 .../bindings/phy/mediatek,pcie-phy.yaml       | 75 +++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/mediatek,pcie-phy.yaml
Documentation/devicetree/bindings/phy/mediatek,pcie-phy.yaml new file +75 -0
new file mode 100644
index 000000000000..422750cc4121
@@ -0,0 +1,75 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/mediatek,pcie-phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek PCIe PHY
+
+maintainers:
+  - Jianjun Wang <[email protected]>
+
+description: |
+  The PCIe PHY supports physical layer functionality for PCIe Gen3 port.
+
+properties:
+  compatible:
+    const: mediatek,mt8195-pcie-phy
+
+  reg:
+    maxItems: 1
+
+  reg-names:
+    items:
+      - const: sif
+
+  "#phy-cells":
+    const: 0
+
+  nvmem-cells:
+    maxItems: 7
+    description:
+      Phandles to nvmem cell that contains the efuse data, if unspecified,
+      default value is used.
+
+  nvmem-cell-names:
+    items:
+      - const: glb_intr
+      - const: tx_ln0_pmos
+      - const: tx_ln0_nmos
+      - const: rx_ln0
+      - const: tx_ln1_pmos
+      - const: tx_ln1_nmos
+      - const: rx_ln1
+
+  power-domains:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    phy@11e80000 {
+        compatible = "mediatek,mt8195-pcie-phy";
+        #phy-cells = <0>;
+        reg = <0x11e80000 0x10000>;
+        reg-names = "sif";
+        nvmem-cells = <&pciephy_glb_intr>,
+                      <&pciephy_tx_ln0_pmos>,
+                      <&pciephy_tx_ln0_nmos>,
+                      <&pciephy_rx_ln0>,
+                      <&pciephy_tx_ln1_pmos>,
+                      <&pciephy_tx_ln1_nmos>,
+                      <&pciephy_rx_ln1>;
+        nvmem-cell-names = "glb_intr", "tx_ln0_pmos",
+                           "tx_ln0_nmos", "rx_ln0",
+                           "tx_ln1_pmos", "tx_ln1_nmos",
+                           "rx_ln1";
+        power-domains = <&spm 2>;
+    };
Signature · 1 line
2.18.0
#2 lore raw

PATCH v7 2/2 phy: mediatek: Add PCIe PHY driver

In reply to Jianjun Wang

Add PCIe GEN3 PHY driver support on MediaTek chipsets.

---
 drivers/phy/mediatek/Kconfig        |  11 ++
 drivers/phy/mediatek/Makefile       |   1 +
 drivers/phy/mediatek/phy-mtk-pcie.c | 267 ++++++++++++++++++++++++++++
 3 files changed, 279 insertions(+)
 create mode 100644 drivers/phy/mediatek/phy-mtk-pcie.c
drivers/phy/mediatek/Kconfig +11 -0
index 55f8e6c048ab..387ed1b3f2cc 100644
@@ -55,3 +55,14 @@ config PHY_MTK_MIPI_DSI
 	select GENERIC_PHY
 	help
 	  Support MIPI DSI for Mediatek SoCs.
+
+config PHY_MTK_PCIE
+	tristate "MediaTek PCIe-PHY Driver"
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	depends on OF
+	select GENERIC_PHY
+	help
+	  Say 'Y' here to add support for MediaTek PCIe PHY driver.
+	  This driver create the basic PHY instance and provides initialize
+	  callback for PCIe GEN3 port, it supports software efuse
+	  initialization.
drivers/phy/mediatek/Makefile +1 -0
index ace660fbed3a..788c13147f63 100644
@@ -6,6 +6,7 @@
 obj-$(CONFIG_PHY_MTK_TPHY)		+= phy-mtk-tphy.o
 obj-$(CONFIG_PHY_MTK_UFS)		+= phy-mtk-ufs.o
 obj-$(CONFIG_PHY_MTK_XSPHY)		+= phy-mtk-xsphy.o
+obj-$(CONFIG_PHY_MTK_PCIE)		+= phy-mtk-pcie.o
 
 phy-mtk-hdmi-drv-y			:= phy-mtk-hdmi.o
 phy-mtk-hdmi-drv-y			+= phy-mtk-hdmi-mt2701.o
drivers/phy/mediatek/phy-mtk-pcie.c new file +267 -0

267 lines not on this page · raw message

Signature · 1 line
2.18.0
#3 lore raw

Il 22/04/22 16:23, Jianjun Wang ha scritto:

Quoted 3 lines

Add PCIe GEN3 PHY driver support on MediaTek chipsets.

Hello Jianjun,
there's only one last bit to fix, check below:

Quoted 7 lines
---
  drivers/phy/mediatek/Kconfig        |  11 ++
  drivers/phy/mediatek/Makefile       |   1 +
  drivers/phy/mediatek/phy-mtk-pcie.c | 267 ++++++++++++++++++++++++++++
  3 files changed, 279 insertions(+)

create mode 100644 drivers/phy/mediatek/phy-mtk-pcie.c

..snip..

drivers/phy/mediatek/phy-mtk-pcie.c line 174

Quoted 8 lines
drivers/phy/mediatek/phy-mtk-pcie.c new file +8 -0
+static int mtk_pcie_read_efuse(struct mtk_pcie_phy *pcie_phy)
+{
+	struct device *dev = pcie_phy->dev;
+	bool nvmem_enabled;
+	int ret, i;
+
+	/* nvmem data is optional */
+	nvmem_enabled = device_property_read_bool(dev, "nvmem-cells");

device_property_read_bool() returns device_property_present().

I would prefer that, instead, you call the latter:

	nvmem_enabled = device_property_present(dev, "nvmem-cells");

It's the same, yes, but this will increase human readability, as the function name clearly states the intention here.

Thanks,
Angelo

#4 lore raw

Hi Angelo,

Quoted 30 lines · AngeloGioacchino Del Regno

Il 22/04/22 16:23, Jianjun Wang ha scritto:

Quoted 3 lines

Add PCIe GEN3 PHY driver support on MediaTek chipsets.

Hello Jianjun,
there's only one last bit to fix, check below:

Quoted 8 lines
---
  drivers/phy/mediatek/Kconfig        |  11 ++
  drivers/phy/mediatek/Makefile       |   1 +
  drivers/phy/mediatek/phy-mtk-pcie.c | 267
++++++++++++++++++++++++++++
  3 files changed, 279 insertions(+)

create mode 100644 drivers/phy/mediatek/phy-mtk-pcie.c

..snip..

drivers/phy/mediatek/phy-mtk-pcie.c line 174

Quoted 8 lines
drivers/phy/mediatek/phy-mtk-pcie.c new file +8 -0
+static int mtk_pcie_read_efuse(struct mtk_pcie_phy *pcie_phy)
+{
+	struct device *dev = pcie_phy->dev;
+	bool nvmem_enabled;
+	int ret, i;
+
+	/* nvmem data is optional */
+	nvmem_enabled = device_property_read_bool(dev, "nvmem-cells");

device_property_read_bool() returns device_property_present().

Quoted 7 lines

I would prefer that, instead, you call the latter:

	nvmem_enabled = device_property_present(dev, "nvmem-cells");

It's the same, yes, but this will increase human readability, as the function
name clearly states the intention here.

Thanks for your review and sorry for the late response, I'll replace it with 'device_property_present' in the next version.

Thanks.

Quoted 4 lines

Thanks,
Angelo