[PATCH 1/3] phy: phy-mtk-tphy: use auto instead of force to bypass utmi signals

Subsystems: arm/mediatek usb3 phy driver, generic phy framework, the rest

STALE3244d

3 messages, 1 author, 2017-10-26 · open the first message on its own page

[PATCH 1/3] phy: phy-mtk-tphy: use auto instead of force to bypass utmi signals

From: Chunfeng Yun <chunfeng.yun@mediatek.com>
Date: 2017-10-26 12:50:49

When system is running, if usb2 phy is forced to bypass utmi signals,
all PLL will be turned off, and it can't detect device connection
anymore, so replace force mode with auto mode which can bypass utmi
signals automatically if no device attached for normal flow.
But keep the force mode to fix RX sensitivity degradation issue.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/mediatek/phy-mtk-tphy.c |   19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index 402385f..54cc44b 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -440,9 +440,9 @@ static void u2_phy_instance_init(struct mtk_tphy *tphy,
 	u32 index = instance->index;
 	u32 tmp;
 
-	/* switch to USB function. (system register, force ip into usb mode) */
+	/* switch to USB function, and enable usb pll */
 	tmp = readl(com + U3P_U2PHYDTM0);
-	tmp &= ~P2C_FORCE_UART_EN;
+	tmp &= ~(P2C_FORCE_UART_EN | P2C_FORCE_SUSPENDM);
 	tmp |= P2C_RG_XCVRSEL_VAL(1) | P2C_RG_DATAIN_VAL(0);
 	writel(tmp, com + U3P_U2PHYDTM0);
 
@@ -502,10 +502,8 @@ static void u2_phy_instance_power_on(struct mtk_tphy *tphy,
 	u32 index = instance->index;
 	u32 tmp;
 
-	/* (force_suspendm=0) (let suspendm=1, enable usb 480MHz pll) */
 	tmp = readl(com + U3P_U2PHYDTM0);
-	tmp &= ~(P2C_FORCE_SUSPENDM | P2C_RG_XCVRSEL);
-	tmp &= ~(P2C_RG_DATAIN | P2C_DTM0_PART_MASK);
+	tmp &= ~(P2C_RG_XCVRSEL | P2C_RG_DATAIN | P2C_DTM0_PART_MASK);
 	writel(tmp, com + U3P_U2PHYDTM0);
 
 	/* OTG Enable */
@@ -540,7 +538,6 @@ static void u2_phy_instance_power_off(struct mtk_tphy *tphy,
 
 	tmp = readl(com + U3P_U2PHYDTM0);
 	tmp &= ~(P2C_RG_XCVRSEL | P2C_RG_DATAIN);
-	tmp |= P2C_FORCE_SUSPENDM;
 	writel(tmp, com + U3P_U2PHYDTM0);
 
 	/* OTG Disable */
@@ -548,18 +545,16 @@ static void u2_phy_instance_power_off(struct mtk_tphy *tphy,
 	tmp &= ~PA6_RG_U2_OTG_VBUSCMP_EN;
 	writel(tmp, com + U3P_USBPHYACR6);
 
-	/* let suspendm=0, set utmi into analog power down */
-	tmp = readl(com + U3P_U2PHYDTM0);
-	tmp &= ~P2C_RG_SUSPENDM;
-	writel(tmp, com + U3P_U2PHYDTM0);
-	udelay(1);
-
 	tmp = readl(com + U3P_U2PHYDTM1);
 	tmp &= ~(P2C_RG_VBUSVALID | P2C_RG_AVALID);
 	tmp |= P2C_RG_SESSEND;
 	writel(tmp, com + U3P_U2PHYDTM1);
 
 	if (tphy->pdata->avoid_rx_sen_degradation && index) {
+		tmp = readl(com + U3P_U2PHYDTM0);
+		tmp &= ~(P2C_RG_SUSPENDM | P2C_FORCE_SUSPENDM);
+		writel(tmp, com + U3P_U2PHYDTM0);
+
 		tmp = readl(com + U3D_U2PHYDCR0);
 		tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON;
 		writel(tmp, com + U3D_U2PHYDCR0);
-- 
1.7.9.5

[PATCH 2/3] phy: phy-mtk-tphy: use of_device_get_match_data()

From: Chunfeng Yun <chunfeng.yun@mediatek.com>
Date: 2017-10-26 12:50:52

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/mediatek/phy-mtk-tphy.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index 54cc44b..cdd33bf 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -20,6 +20,7 @@
 #include <linux/iopoll.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>
 
@@ -995,7 +996,6 @@ static struct phy *mtk_phy_xlate(struct device *dev,
 
 static int mtk_tphy_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
 	struct device_node *child_np;
@@ -1005,15 +1005,14 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 	struct resource res;
 	int port, retval;
 
-	match = of_match_node(mtk_tphy_id_table, pdev->dev.of_node);
-	if (!match)
-		return -EINVAL;
-
 	tphy = devm_kzalloc(dev, sizeof(*tphy), GFP_KERNEL);
 	if (!tphy)
 		return -ENOMEM;
 
-	tphy->pdata = match->data;
+	tphy->pdata = of_device_get_match_data(dev);
+	if (!tphy->pdata)
+		return -EINVAL;
+
 	tphy->nphys = of_get_child_count(np);
 	tphy->phys = devm_kcalloc(dev, tphy->nphys,
 				       sizeof(*tphy->phys), GFP_KERNEL);
-- 
1.7.9.5

[PATCH 3/3] phy: phy-mtk-tphy: fix alignment warning

From: Chunfeng Yun <chunfeng.yun@mediatek.com>
Date: 2017-10-26 12:50:57

Fix alignment warning by checkpatch.pl with --strict

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/mediatek/Kconfig        |    8 ++++----
 drivers/phy/mediatek/phy-mtk-tphy.c |   24 ++++++++++++------------
 2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/phy/mediatek/Kconfig b/drivers/phy/mediatek/Kconfig
index 88ab4e2..fb4bcd9 100644
--- a/drivers/phy/mediatek/Kconfig
+++ b/drivers/phy/mediatek/Kconfig
@@ -8,7 +8,7 @@ config PHY_MTK_TPHY
     help
       Say 'Y' here to add support for MediaTek T-PHY driver,
       it supports multiple usb2.0, usb3.0 ports, PCIe and
-	  SATA, and meanwhile supports two version T-PHY which have
-	  different banks layout, the T-PHY with shared banks between
-	  multi-ports is first version, otherwise is second veriosn,
-	  so you can easily distinguish them by banks layout.
+      SATA, and meanwhile supports two version T-PHY which have
+      different banks layout, the T-PHY with shared banks between
+      multi-ports is first version, otherwise is second veriosn,
+      so you can easily distinguish them by banks layout.
diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index cdd33bf..02b00b7 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -309,7 +309,7 @@ struct mtk_tphy {
 };
 
 static void hs_slew_rate_calibrate(struct mtk_tphy *tphy,
-	struct mtk_phy_instance *instance)
+				   struct mtk_phy_instance *instance)
 {
 	struct u2phy_banks *u2_banks = &instance->u2_banks;
 	void __iomem *fmreg = u2_banks->fmreg;
@@ -384,7 +384,7 @@ static void hs_slew_rate_calibrate(struct mtk_tphy *tphy,
 }
 
 static void u3_phy_instance_init(struct mtk_tphy *tphy,
-	struct mtk_phy_instance *instance)
+				 struct mtk_phy_instance *instance)
 {
 	struct u3phy_banks *u3_banks = &instance->u3_banks;
 	u32 tmp;
@@ -434,7 +434,7 @@ static void u3_phy_instance_init(struct mtk_tphy *tphy,
 }
 
 static void u2_phy_instance_init(struct mtk_tphy *tphy,
-	struct mtk_phy_instance *instance)
+				 struct mtk_phy_instance *instance)
 {
 	struct u2phy_banks *u2_banks = &instance->u2_banks;
 	void __iomem *com = u2_banks->com;
@@ -496,7 +496,7 @@ static void u2_phy_instance_init(struct mtk_tphy *tphy,
 }
 
 static void u2_phy_instance_power_on(struct mtk_tphy *tphy,
-	struct mtk_phy_instance *instance)
+				     struct mtk_phy_instance *instance)
 {
 	struct u2phy_banks *u2_banks = &instance->u2_banks;
 	void __iomem *com = u2_banks->com;
@@ -530,7 +530,7 @@ static void u2_phy_instance_power_on(struct mtk_tphy *tphy,
 }
 
 static void u2_phy_instance_power_off(struct mtk_tphy *tphy,
-	struct mtk_phy_instance *instance)
+				      struct mtk_phy_instance *instance)
 {
 	struct u2phy_banks *u2_banks = &instance->u2_banks;
 	void __iomem *com = u2_banks->com;
@@ -565,7 +565,7 @@ static void u2_phy_instance_power_off(struct mtk_tphy *tphy,
 }
 
 static void u2_phy_instance_exit(struct mtk_tphy *tphy,
-	struct mtk_phy_instance *instance)
+				 struct mtk_phy_instance *instance)
 {
 	struct u2phy_banks *u2_banks = &instance->u2_banks;
 	void __iomem *com = u2_banks->com;
@@ -609,7 +609,7 @@ static void u2_phy_instance_set_mode(struct mtk_tphy *tphy,
 }
 
 static void pcie_phy_instance_init(struct mtk_tphy *tphy,
-	struct mtk_phy_instance *instance)
+				   struct mtk_phy_instance *instance)
 {
 	struct u3phy_banks *u3_banks = &instance->u3_banks;
 	u32 tmp;
@@ -682,7 +682,7 @@ static void pcie_phy_instance_init(struct mtk_tphy *tphy,
 }
 
 static void pcie_phy_instance_power_on(struct mtk_tphy *tphy,
-	struct mtk_phy_instance *instance)
+				       struct mtk_phy_instance *instance)
 {
 	struct u3phy_banks *bank = &instance->u3_banks;
 	u32 tmp;
@@ -698,7 +698,7 @@ static void pcie_phy_instance_power_on(struct mtk_tphy *tphy,
 }
 
 static void pcie_phy_instance_power_off(struct mtk_tphy *tphy,
-	struct mtk_phy_instance *instance)
+					struct mtk_phy_instance *instance)
 
 {
 	struct u3phy_banks *bank = &instance->u3_banks;
@@ -714,7 +714,7 @@ static void pcie_phy_instance_power_off(struct mtk_tphy *tphy,
 }
 
 static void sata_phy_instance_init(struct mtk_tphy *tphy,
-	struct mtk_phy_instance *instance)
+				   struct mtk_phy_instance *instance)
 {
 	struct u3phy_banks *u3_banks = &instance->u3_banks;
 	void __iomem *phyd = u3_banks->phyd;
@@ -916,7 +916,7 @@ static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode)
 }
 
 static struct phy *mtk_phy_xlate(struct device *dev,
-					struct of_phandle_args *args)
+				 struct of_phandle_args *args)
 {
 	struct mtk_tphy *tphy = dev_get_drvdata(dev);
 	struct mtk_phy_instance *instance = NULL;
@@ -1015,7 +1015,7 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 
 	tphy->nphys = of_get_child_count(np);
 	tphy->phys = devm_kcalloc(dev, tphy->nphys,
-				       sizeof(*tphy->phys), GFP_KERNEL);
+				  sizeof(*tphy->phys), GFP_KERNEL);
 	if (!tphy->phys)
 		return -ENOMEM;
 
-- 
1.7.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help