LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg
@ 2021-08-17  9:19 Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 2/9] phy: phy-mtk-tphy: use clock bulk to get clocks Chunfeng Yun
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Chunfeng Yun @ 2021-08-17  9:19 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, linux-arm-kernel,
	linux-mediatek, linux-phy, devicetree, linux-kernel, dri-devel,
	Stanley Chu

Add support type switch by pericfg register between USB3, PCIe,
SATA, SGMII, this is used to replace the way through efuse or
jumper.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: no changes
v2: add reviewed-by Rob
---
 .../devicetree/bindings/phy/mediatek,tphy.yaml   | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml b/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
index 838852cb8527..9e6c0f43f1c6 100644
--- a/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
+++ b/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
@@ -201,6 +201,22 @@ patternProperties:
           Specify the flag to enable BC1.2 if support it
         type: boolean
 
+      mediatek,syscon-type:
+        $ref: /schemas/types.yaml#/definitions/phandle-array
+        maxItems: 1
+        description:
+          A phandle to syscon used to access the register of type switch,
+          the field should always be 3 cells long.
+        items:
+          items:
+            - description:
+                The first cell represents a phandle to syscon
+            - description:
+                The second cell represents the register offset
+            - description:
+                The third cell represents the index of config segment
+              enum: [0, 1, 2, 3]
+
     required:
       - reg
       - "#phy-cells"
-- 
2.18.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 2/9] phy: phy-mtk-tphy: use clock bulk to get clocks
  2021-08-17  9:19 [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Chunfeng Yun
@ 2021-08-17  9:19 ` Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 3/9] phy: phy-mtk-tphy: support type switch by pericfg Chunfeng Yun
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2021-08-17  9:19 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, linux-arm-kernel,
	linux-mediatek, linux-phy, devicetree, linux-kernel, dri-devel,
	Stanley Chu

Use clock bulk helpers to get/enable/disable clocks

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2~3: no changes
---
 drivers/phy/mediatek/phy-mtk-tphy.c | 43 +++++++++--------------------
 1 file changed, 13 insertions(+), 30 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index 33000b38fd1b..3259210f08a1 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -280,6 +280,8 @@
 #define RG_CDR_BIRLTD0_GEN3_MSK		GENMASK(4, 0)
 #define RG_CDR_BIRLTD0_GEN3_VAL(x)	(0x1f & (x))
 
+#define TPHY_CLKS_CNT	2
+
 enum mtk_phy_version {
 	MTK_PHY_V1 = 1,
 	MTK_PHY_V2,
@@ -318,8 +320,7 @@ struct mtk_phy_instance {
 		struct u2phy_banks u2_banks;
 		struct u3phy_banks u3_banks;
 	};
-	struct clk *ref_clk;	/* reference clock of (digital) phy */
-	struct clk *da_ref_clk;	/* reference clock of analog phy */
+	struct clk_bulk_data clks[TPHY_CLKS_CNT];
 	u32 index;
 	u8 type;
 	int eye_src;
@@ -974,18 +975,9 @@ static int mtk_phy_init(struct phy *phy)
 	struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent);
 	int ret;
 
-	ret = clk_prepare_enable(instance->ref_clk);
-	if (ret) {
-		dev_err(tphy->dev, "failed to enable ref_clk\n");
+	ret = clk_bulk_prepare_enable(TPHY_CLKS_CNT, instance->clks);
+	if (ret)
 		return ret;
-	}
-
-	ret = clk_prepare_enable(instance->da_ref_clk);
-	if (ret) {
-		dev_err(tphy->dev, "failed to enable da_ref\n");
-		clk_disable_unprepare(instance->ref_clk);
-		return ret;
-	}
 
 	switch (instance->type) {
 	case PHY_TYPE_USB2:
@@ -1003,8 +995,7 @@ static int mtk_phy_init(struct phy *phy)
 		break;
 	default:
 		dev_err(tphy->dev, "incompatible PHY type\n");
-		clk_disable_unprepare(instance->ref_clk);
-		clk_disable_unprepare(instance->da_ref_clk);
+		clk_bulk_disable_unprepare(TPHY_CLKS_CNT, instance->clks);
 		return -EINVAL;
 	}
 
@@ -1047,8 +1038,7 @@ static int mtk_phy_exit(struct phy *phy)
 	if (instance->type == PHY_TYPE_USB2)
 		u2_phy_instance_exit(tphy, instance);
 
-	clk_disable_unprepare(instance->ref_clk);
-	clk_disable_unprepare(instance->da_ref_clk);
+	clk_bulk_disable_unprepare(TPHY_CLKS_CNT, instance->clks);
 	return 0;
 }
 
@@ -1211,6 +1201,7 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 	port = 0;
 	for_each_child_of_node(np, child_np) {
 		struct mtk_phy_instance *instance;
+		struct clk_bulk_data *clks;
 		struct phy *phy;
 
 		instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL);
@@ -1247,20 +1238,12 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 		phy_set_drvdata(phy, instance);
 		port++;
 
-		instance->ref_clk = devm_clk_get_optional(&phy->dev, "ref");
-		if (IS_ERR(instance->ref_clk)) {
-			dev_err(dev, "failed to get ref_clk(id-%d)\n", port);
-			retval = PTR_ERR(instance->ref_clk);
+		clks = instance->clks;
+		clks[0].id = "ref";     /* digital (& analog) clock */
+		clks[1].id = "da_ref";  /* analog clock */
+		retval = devm_clk_bulk_get_optional(&phy->dev, TPHY_CLKS_CNT, clks);
+		if (retval)
 			goto put_child;
-		}
-
-		instance->da_ref_clk =
-			devm_clk_get_optional(&phy->dev, "da_ref");
-		if (IS_ERR(instance->da_ref_clk)) {
-			dev_err(dev, "failed to get da_ref_clk(id-%d)\n", port);
-			retval = PTR_ERR(instance->da_ref_clk);
-			goto put_child;
-		}
 	}
 
 	provider = devm_of_phy_provider_register(dev, mtk_phy_xlate);
-- 
2.18.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 3/9] phy: phy-mtk-tphy: support type switch by pericfg
  2021-08-17  9:19 [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 2/9] phy: phy-mtk-tphy: use clock bulk to get clocks Chunfeng Yun
@ 2021-08-17  9:19 ` Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 4/9] phy: phy-mtk-tphy: print error log using child device Chunfeng Yun
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2021-08-17  9:19 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, linux-arm-kernel,
	linux-mediatek, linux-phy, devicetree, linux-kernel, dri-devel,
	Stanley Chu

Add support type switch between USB3, PCIe, SATA and SGMII by
pericfg register, this is used to take the place of efuse or
jumper.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2~3: no changes
---
 drivers/phy/mediatek/phy-mtk-tphy.c | 84 ++++++++++++++++++++++++++++-
 1 file changed, 82 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index 3259210f08a1..a6502058a1a5 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -10,11 +10,13 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
+#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/regmap.h>
 
 /* version V1 sub-banks offset base address */
 /* banks shared by multiple phys */
@@ -280,6 +282,14 @@
 #define RG_CDR_BIRLTD0_GEN3_MSK		GENMASK(4, 0)
 #define RG_CDR_BIRLTD0_GEN3_VAL(x)	(0x1f & (x))
 
+/* PHY switch between pcie/usb3/sgmii/sata */
+#define USB_PHY_SWITCH_CTRL	0x0
+#define RG_PHY_SW_TYPE		GENMASK(3, 0)
+#define RG_PHY_SW_PCIE		0x0
+#define RG_PHY_SW_USB3		0x1
+#define RG_PHY_SW_SGMII		0x2
+#define RG_PHY_SW_SATA		0x3
+
 #define TPHY_CLKS_CNT	2
 
 enum mtk_phy_version {
@@ -322,7 +332,10 @@ struct mtk_phy_instance {
 	};
 	struct clk_bulk_data clks[TPHY_CLKS_CNT];
 	u32 index;
-	u8 type;
+	u32 type;
+	struct regmap *type_sw;
+	u32 type_sw_reg;
+	u32 type_sw_index;
 	int eye_src;
 	int eye_vrt;
 	int eye_term;
@@ -969,6 +982,64 @@ static void u2_phy_props_set(struct mtk_tphy *tphy,
 	}
 }
 
+/* type switch for usb3/pcie/sgmii/sata */
+static int phy_type_syscon_get(struct mtk_phy_instance *instance,
+			       struct device_node *dn)
+{
+	struct of_phandle_args args;
+	int ret;
+
+	/* type switch function is optional */
+	if (!of_property_read_bool(dn, "mediatek,syscon-type"))
+		return 0;
+
+	ret = of_parse_phandle_with_fixed_args(dn, "mediatek,syscon-type",
+					       2, 0, &args);
+	if (ret)
+		return ret;
+
+	instance->type_sw_reg = args.args[0];
+	instance->type_sw_index = args.args[1] & 0x3; /* <=3 */
+	instance->type_sw = syscon_node_to_regmap(args.np);
+	of_node_put(args.np);
+	dev_info(&instance->phy->dev, "type_sw - reg %#x, index %d\n",
+		 instance->type_sw_reg, instance->type_sw_index);
+
+	return PTR_ERR_OR_ZERO(instance->type_sw);
+}
+
+static int phy_type_set(struct mtk_phy_instance *instance)
+{
+	int type;
+	u32 mask;
+
+	if (!instance->type_sw)
+		return 0;
+
+	switch (instance->type) {
+	case PHY_TYPE_USB3:
+		type = RG_PHY_SW_USB3;
+		break;
+	case PHY_TYPE_PCIE:
+		type = RG_PHY_SW_PCIE;
+		break;
+	case PHY_TYPE_SGMII:
+		type = RG_PHY_SW_SGMII;
+		break;
+	case PHY_TYPE_SATA:
+		type = RG_PHY_SW_SATA;
+		break;
+	case PHY_TYPE_USB2:
+	default:
+		return 0;
+	}
+
+	mask = RG_PHY_SW_TYPE << (instance->type_sw_index * BITS_PER_BYTE);
+	regmap_update_bits(instance->type_sw, instance->type_sw_reg, mask, type);
+
+	return 0;
+}
+
 static int mtk_phy_init(struct phy *phy)
 {
 	struct mtk_phy_instance *instance = phy_get_drvdata(phy);
@@ -993,6 +1064,9 @@ static int mtk_phy_init(struct phy *phy)
 	case PHY_TYPE_SATA:
 		sata_phy_instance_init(tphy, instance);
 		break;
+	case PHY_TYPE_SGMII:
+		/* nothing to do, only used to set type */
+		break;
 	default:
 		dev_err(tphy->dev, "incompatible PHY type\n");
 		clk_bulk_disable_unprepare(TPHY_CLKS_CNT, instance->clks);
@@ -1081,7 +1155,8 @@ static struct phy *mtk_phy_xlate(struct device *dev,
 	if (!(instance->type == PHY_TYPE_USB2 ||
 	      instance->type == PHY_TYPE_USB3 ||
 	      instance->type == PHY_TYPE_PCIE ||
-	      instance->type == PHY_TYPE_SATA)) {
+	      instance->type == PHY_TYPE_SATA ||
+	      instance->type == PHY_TYPE_SGMII)) {
 		dev_err(dev, "unsupported device type: %d\n", instance->type);
 		return ERR_PTR(-EINVAL);
 	}
@@ -1100,6 +1175,7 @@ static struct phy *mtk_phy_xlate(struct device *dev,
 	}
 
 	phy_parse_property(tphy, instance);
+	phy_type_set(instance);
 
 	return instance->phy;
 }
@@ -1244,6 +1320,10 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 		retval = devm_clk_bulk_get_optional(&phy->dev, TPHY_CLKS_CNT, clks);
 		if (retval)
 			goto put_child;
+
+		retval = phy_type_syscon_get(instance, child_np);
+		if (retval)
+			goto put_child;
 	}
 
 	provider = devm_of_phy_provider_register(dev, mtk_phy_xlate);
-- 
2.18.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 4/9] phy: phy-mtk-tphy: print error log using child device
  2021-08-17  9:19 [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 2/9] phy: phy-mtk-tphy: use clock bulk to get clocks Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 3/9] phy: phy-mtk-tphy: support type switch by pericfg Chunfeng Yun
@ 2021-08-17  9:19 ` Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 5/9] phy: phy-mtk-tphy: remove error log of ioremap failure Chunfeng Yun
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2021-08-17  9:19 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, linux-arm-kernel,
	linux-mediatek, linux-phy, devicetree, linux-kernel, dri-devel,
	Stanley Chu

Print error log using child devices instead of parent device.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2~3: no changes
---
 drivers/phy/mediatek/phy-mtk-tphy.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index a6502058a1a5..9d4b34298137 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -1278,6 +1278,7 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 	for_each_child_of_node(np, child_np) {
 		struct mtk_phy_instance *instance;
 		struct clk_bulk_data *clks;
+		struct device *subdev;
 		struct phy *phy;
 
 		instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL);
@@ -1295,16 +1296,17 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 			goto put_child;
 		}
 
+		subdev = &phy->dev;
 		retval = of_address_to_resource(child_np, 0, &res);
 		if (retval) {
-			dev_err(dev, "failed to get address resource(id-%d)\n",
+			dev_err(subdev, "failed to get address resource(id-%d)\n",
 				port);
 			goto put_child;
 		}
 
-		instance->port_base = devm_ioremap_resource(&phy->dev, &res);
+		instance->port_base = devm_ioremap_resource(subdev, &res);
 		if (IS_ERR(instance->port_base)) {
-			dev_err(dev, "failed to remap phy regs\n");
+			dev_err(subdev, "failed to remap phy regs\n");
 			retval = PTR_ERR(instance->port_base);
 			goto put_child;
 		}
@@ -1317,7 +1319,7 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 		clks = instance->clks;
 		clks[0].id = "ref";     /* digital (& analog) clock */
 		clks[1].id = "da_ref";  /* analog clock */
-		retval = devm_clk_bulk_get_optional(&phy->dev, TPHY_CLKS_CNT, clks);
+		retval = devm_clk_bulk_get_optional(subdev, TPHY_CLKS_CNT, clks);
 		if (retval)
 			goto put_child;
 
-- 
2.18.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 5/9] phy: phy-mtk-tphy: remove error log of ioremap failure
  2021-08-17  9:19 [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Chunfeng Yun
                   ` (2 preceding siblings ...)
  2021-08-17  9:19 ` [PATCH v3 4/9] phy: phy-mtk-tphy: print error log using child device Chunfeng Yun
@ 2021-08-17  9:19 ` Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 6/9] phy: phy-mtk-ufs: use clock bulk to get clocks Chunfeng Yun
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2021-08-17  9:19 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, linux-arm-kernel,
	linux-mediatek, linux-phy, devicetree, linux-kernel, dri-devel,
	Stanley Chu

devm_ioremap_resource() will print log if error happens.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2~3: no changes
---
 drivers/phy/mediatek/phy-mtk-tphy.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index 9d4b34298137..cdcef865fe9e 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -1306,7 +1306,6 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 
 		instance->port_base = devm_ioremap_resource(subdev, &res);
 		if (IS_ERR(instance->port_base)) {
-			dev_err(subdev, "failed to remap phy regs\n");
 			retval = PTR_ERR(instance->port_base);
 			goto put_child;
 		}
-- 
2.18.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 6/9] phy: phy-mtk-ufs: use clock bulk to get clocks
  2021-08-17  9:19 [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Chunfeng Yun
                   ` (3 preceding siblings ...)
  2021-08-17  9:19 ` [PATCH v3 5/9] phy: phy-mtk-tphy: remove error log of ioremap failure Chunfeng Yun
@ 2021-08-17  9:19 ` Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 7/9] phy: phy-mtk-hdmi: convert to devm_platform_ioremap_resource Chunfeng Yun
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2021-08-17  9:19 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, linux-arm-kernel,
	linux-mediatek, linux-phy, devicetree, linux-kernel, dri-devel,
	Stanley Chu

Use clock bulk helpers to get/enable/disable clocks

Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: add reviewed-by Stanley
v2: no changes
---
 drivers/phy/mediatek/phy-mtk-ufs.c | 44 ++++++++----------------------
 1 file changed, 11 insertions(+), 33 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-ufs.c b/drivers/phy/mediatek/phy-mtk-ufs.c
index 769b00b038d8..a6af06941203 100644
--- a/drivers/phy/mediatek/phy-mtk-ufs.c
+++ b/drivers/phy/mediatek/phy-mtk-ufs.c
@@ -31,11 +31,12 @@
 #define FRC_CDR_ISO_EN              BIT(19)
 #define CDR_ISO_EN                  BIT(20)
 
+#define UFSPHY_CLKS_CNT    2
+
 struct ufs_mtk_phy {
 	struct device *dev;
 	void __iomem *mmio;
-	struct clk *mp_clk;
-	struct clk *unipro_clk;
+	struct clk_bulk_data clks[UFSPHY_CLKS_CNT];
 };
 
 static inline u32 mphy_readl(struct ufs_mtk_phy *phy, u32 reg)
@@ -74,20 +75,11 @@ static struct ufs_mtk_phy *get_ufs_mtk_phy(struct phy *generic_phy)
 static int ufs_mtk_phy_clk_init(struct ufs_mtk_phy *phy)
 {
 	struct device *dev = phy->dev;
+	struct clk_bulk_data *clks = phy->clks;
 
-	phy->unipro_clk = devm_clk_get(dev, "unipro");
-	if (IS_ERR(phy->unipro_clk)) {
-		dev_err(dev, "failed to get clock: unipro");
-		return PTR_ERR(phy->unipro_clk);
-	}
-
-	phy->mp_clk = devm_clk_get(dev, "mp");
-	if (IS_ERR(phy->mp_clk)) {
-		dev_err(dev, "failed to get clock: mp");
-		return PTR_ERR(phy->mp_clk);
-	}
-
-	return 0;
+	clks[0].id = "unipro";
+	clks[1].id = "mp";
+	return devm_clk_bulk_get(dev, UFSPHY_CLKS_CNT, clks);
 }
 
 static void ufs_mtk_phy_set_active(struct ufs_mtk_phy *phy)
@@ -150,26 +142,13 @@ static int ufs_mtk_phy_power_on(struct phy *generic_phy)
 	struct ufs_mtk_phy *phy = get_ufs_mtk_phy(generic_phy);
 	int ret;
 
-	ret = clk_prepare_enable(phy->unipro_clk);
-	if (ret) {
-		dev_err(phy->dev, "unipro_clk enable failed %d\n", ret);
-		goto out;
-	}
-
-	ret = clk_prepare_enable(phy->mp_clk);
-	if (ret) {
-		dev_err(phy->dev, "mp_clk enable failed %d\n", ret);
-		goto out_unprepare_unipro_clk;
-	}
+	ret = clk_bulk_prepare_enable(UFSPHY_CLKS_CNT, phy->clks);
+	if (ret)
+		return ret;
 
 	ufs_mtk_phy_set_active(phy);
 
 	return 0;
-
-out_unprepare_unipro_clk:
-	clk_disable_unprepare(phy->unipro_clk);
-out:
-	return ret;
 }
 
 static int ufs_mtk_phy_power_off(struct phy *generic_phy)
@@ -178,8 +157,7 @@ static int ufs_mtk_phy_power_off(struct phy *generic_phy)
 
 	ufs_mtk_phy_set_deep_hibern(phy);
 
-	clk_disable_unprepare(phy->unipro_clk);
-	clk_disable_unprepare(phy->mp_clk);
+	clk_bulk_disable_unprepare(UFSPHY_CLKS_CNT, phy->clks);
 
 	return 0;
 }
-- 
2.18.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 7/9] phy: phy-mtk-hdmi: convert to devm_platform_ioremap_resource
  2021-08-17  9:19 [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Chunfeng Yun
                   ` (4 preceding siblings ...)
  2021-08-17  9:19 ` [PATCH v3 6/9] phy: phy-mtk-ufs: use clock bulk to get clocks Chunfeng Yun
@ 2021-08-17  9:19 ` Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 8/9] phy: phy-mtk-mipi-dsi: remove dummy assignment of error number Chunfeng Yun
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2021-08-17  9:19 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, linux-arm-kernel,
	linux-mediatek, linux-phy, devicetree, linux-kernel, dri-devel,
	Stanley Chu

Use devm_platform_ioremap_resource to simplify code

Acked-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: no changes
v2: add acked-by CK
---
 drivers/phy/mediatek/phy-mtk-hdmi.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c b/drivers/phy/mediatek/phy-mtk-hdmi.c
index 8ad8f717ef43..5fb4217fb8e0 100644
--- a/drivers/phy/mediatek/phy-mtk-hdmi.c
+++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
@@ -100,7 +100,6 @@ static int mtk_hdmi_phy_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct mtk_hdmi_phy *hdmi_phy;
-	struct resource *mem;
 	struct clk *ref_clk;
 	const char *ref_clk_name;
 	struct clk_init_data clk_init = {
@@ -116,11 +115,9 @@ static int mtk_hdmi_phy_probe(struct platform_device *pdev)
 	if (!hdmi_phy)
 		return -ENOMEM;
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	hdmi_phy->regs = devm_ioremap_resource(dev, mem);
-	if (IS_ERR(hdmi_phy->regs)) {
+	hdmi_phy->regs = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(hdmi_phy->regs))
 		return PTR_ERR(hdmi_phy->regs);
-	}
 
 	ref_clk = devm_clk_get(dev, "pll_ref");
 	if (IS_ERR(ref_clk)) {
-- 
2.18.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 8/9] phy: phy-mtk-mipi-dsi: remove dummy assignment of error number
  2021-08-17  9:19 [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Chunfeng Yun
                   ` (5 preceding siblings ...)
  2021-08-17  9:19 ` [PATCH v3 7/9] phy: phy-mtk-hdmi: convert to devm_platform_ioremap_resource Chunfeng Yun
@ 2021-08-17  9:19 ` Chunfeng Yun
  2021-08-17  9:19 ` [PATCH v3 9/9] phy: phy-mtk-mipi-dsi: convert to devm_platform_ioremap_resource Chunfeng Yun
  2021-08-17 10:22 ` [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Vinod Koul
  8 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2021-08-17  9:19 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, linux-arm-kernel,
	linux-mediatek, linux-phy, devicetree, linux-kernel, dri-devel,
	Stanley Chu

Return the error number directly without assignment

Acked-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: no changes
v2: add acked-by CK
---
 drivers/phy/mediatek/phy-mtk-mipi-dsi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
index 01cf31633019..61c942fbf4a1 100644
--- a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
+++ b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
@@ -203,10 +203,8 @@ static int mtk_mipi_tx_probe(struct platform_device *pdev)
 	phy_set_drvdata(phy, mipi_tx);
 
 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
-	if (IS_ERR(phy_provider)) {
-		ret = PTR_ERR(phy_provider);
-		return ret;
-	}
+	if (IS_ERR(phy_provider))
+		return PTR_ERR(phy_provider);
 
 	mipi_tx->dev = dev;
 
-- 
2.18.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 9/9] phy: phy-mtk-mipi-dsi: convert to devm_platform_ioremap_resource
  2021-08-17  9:19 [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Chunfeng Yun
                   ` (6 preceding siblings ...)
  2021-08-17  9:19 ` [PATCH v3 8/9] phy: phy-mtk-mipi-dsi: remove dummy assignment of error number Chunfeng Yun
@ 2021-08-17  9:19 ` Chunfeng Yun
  2021-08-17 10:22 ` [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Vinod Koul
  8 siblings, 0 replies; 10+ messages in thread
From: Chunfeng Yun @ 2021-08-17  9:19 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, linux-arm-kernel,
	linux-mediatek, linux-phy, devicetree, linux-kernel, dri-devel,
	Stanley Chu

Use devm_platform_ioremap_resource to simplify code

Acked-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: no changes
v2: add acked-by CK
---
 drivers/phy/mediatek/phy-mtk-mipi-dsi.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
index 61c942fbf4a1..28ad9403c441 100644
--- a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
+++ b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
@@ -130,7 +130,6 @@ static int mtk_mipi_tx_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct mtk_mipi_tx *mipi_tx;
-	struct resource *mem;
 	const char *ref_clk_name;
 	struct clk *ref_clk;
 	struct clk_init_data clk_init = {
@@ -148,11 +147,9 @@ static int mtk_mipi_tx_probe(struct platform_device *pdev)
 
 	mipi_tx->driver_data = of_device_get_match_data(dev);
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	mipi_tx->regs = devm_ioremap_resource(dev, mem);
-	if (IS_ERR(mipi_tx->regs)) {
+	mipi_tx->regs = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(mipi_tx->regs))
 		return PTR_ERR(mipi_tx->regs);
-	}
 
 	ref_clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(ref_clk)) {
-- 
2.18.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg
  2021-08-17  9:19 [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Chunfeng Yun
                   ` (7 preceding siblings ...)
  2021-08-17  9:19 ` [PATCH v3 9/9] phy: phy-mtk-mipi-dsi: convert to devm_platform_ioremap_resource Chunfeng Yun
@ 2021-08-17 10:22 ` Vinod Koul
  8 siblings, 0 replies; 10+ messages in thread
From: Vinod Koul @ 2021-08-17 10:22 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Kishon Vijay Abraham I, Rob Herring, Chun-Kuang Hu,
	Philipp Zabel, Matthias Brugger, linux-arm-kernel,
	linux-mediatek, linux-phy, devicetree, linux-kernel, dri-devel,
	Stanley Chu

On 17-08-21, 17:19, Chunfeng Yun wrote:
> Add support type switch by pericfg register between USB3, PCIe,
> SATA, SGMII, this is used to replace the way through efuse or
> jumper.

Applied all, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-08-17 10:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17  9:19 [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Chunfeng Yun
2021-08-17  9:19 ` [PATCH v3 2/9] phy: phy-mtk-tphy: use clock bulk to get clocks Chunfeng Yun
2021-08-17  9:19 ` [PATCH v3 3/9] phy: phy-mtk-tphy: support type switch by pericfg Chunfeng Yun
2021-08-17  9:19 ` [PATCH v3 4/9] phy: phy-mtk-tphy: print error log using child device Chunfeng Yun
2021-08-17  9:19 ` [PATCH v3 5/9] phy: phy-mtk-tphy: remove error log of ioremap failure Chunfeng Yun
2021-08-17  9:19 ` [PATCH v3 6/9] phy: phy-mtk-ufs: use clock bulk to get clocks Chunfeng Yun
2021-08-17  9:19 ` [PATCH v3 7/9] phy: phy-mtk-hdmi: convert to devm_platform_ioremap_resource Chunfeng Yun
2021-08-17  9:19 ` [PATCH v3 8/9] phy: phy-mtk-mipi-dsi: remove dummy assignment of error number Chunfeng Yun
2021-08-17  9:19 ` [PATCH v3 9/9] phy: phy-mtk-mipi-dsi: convert to devm_platform_ioremap_resource Chunfeng Yun
2021-08-17 10:22 ` [PATCH v3 1/9] dt-bindings: phy: mediatek: tphy: support type switch by pericfg Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).