Skip to contentSkip to conversation

phy: mediatek: Add PCIe PHY driver

PATCH Superseded Jianjun Wang 2 participants 5 messages Mar 23, 2022 – Mar 26, 2022

Subsystems (4)

v4 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v4 cover phy: mediatek: Add PCIe PHY driver

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

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           | 272 ++++++++++++++++++
 4 files changed, 359 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/mediatek,pcie-phy.yaml
 create mode 100644 drivers/phy/mediatek/phy-mtk-pcie.c
Signature · 1 line
2.18.0
#1 lore raw

PATCH v4 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 · 7 lines
2.18.0


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

PATCH v4 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 | 272 ++++++++++++++++++++++++++++
 3 files changed, 284 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 +272 -0

272 lines not on this page · raw message

Signature · 1 line
2.18.0
maintainer Reviewed-by on v4 2/2
#3 lore raw

Il 23/03/22 07:56, Jianjun Wang ha scritto:

Quoted 10 lines

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 | 272 ++++++++++++++++++++++++++++
  3 files changed, 284 insertions(+)

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

..snip..

Quoted 6 lines
drivers/phy/mediatek/phy-mtk-pcie.c new file +0 -0
new file mode 100644
index 000000000000..44a2ad8d324e
@@ -0,0 +1,272 @@

..snip..

Quoted 9 lines

+/**
+ * struct mtk_pcie_phy - PCIe phy driver main structure
+ * @dev: pointer to device
+ * @phy: pointer to generic phy
+ * @sif_base: IO mapped register base address of system interface
+ * @data: pointer to SoC dependent data
+ * @sw_efuse_en: software eFuse enable status
+ * @efuse_glb_intr: internal resistor selection of TX bias current data
+ * @efuse: pointer to eFues data for each lane

Oops! There's a typo! "eFues" => "eFuse"

After fixing this typo,

P.S.: Many thanks for the kerneldoc documentation!!!!

Quoted 11 lines

+ */

drivers/phy/mediatek/phy-mtk-pcie.c new file +10 -0
+struct mtk_pcie_phy {
+	struct device *dev;
+	struct phy *phy;
+	void __iomem *sif_base;
+	const struct mtk_pcie_phy_data *data;
+
+	bool sw_efuse_en;
+	u32 efuse_glb_intr;
+	struct mtk_pcie_lane_efuse *efuse;
+};
#4 lore raw
Quoted 36 lines · AngeloGioacchino Del Regno

Il 23/03/22 07:56, Jianjun Wang ha scritto:

Quoted 11 lines

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 | 272
++++++++++++++++++++++++++++
  3 files changed, 284 insertions(+)

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

..snip..

Quoted 7 lines
drivers/phy/mediatek/phy-mtk-pcie.c new file +0 -0
new file mode 100644
index 000000000000..44a2ad8d324e
@@ -0,0 +1,272 @@

..snip..

Quoted 10 lines

+/**
+ * struct mtk_pcie_phy - PCIe phy driver main structure
+ * @dev: pointer to device
+ * @phy: pointer to generic phy
+ * @sif_base: IO mapped register base address of system interface
+ * @data: pointer to SoC dependent data
+ * @sw_efuse_en: software eFuse enable status
+ * @efuse_glb_intr: internal resistor selection of TX bias current data
+ * @efuse: pointer to eFues data for each lane

Quoted 6 lines

Oops! There's a typo! "eFues" => "eFuse"

After fixing this typo,

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

Thanks!

Quoted 16 lines

P.S.: Many thanks for the kerneldoc documentation!!!!

Quoted 11 lines

+ */

drivers/phy/mediatek/phy-mtk-pcie.c new file +10 -0
+struct mtk_pcie_phy {
+	struct device *dev;
+	struct phy *phy;
+	void __iomem *sif_base;
+	const struct mtk_pcie_phy_data *data;
+
+	bool sw_efuse_en;
+	u32 efuse_glb_intr;
+	struct mtk_pcie_lane_efuse *efuse;
+};