linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: phy-mtk-tphy: add the property about force_vbus
@ 2020-04-17  5:23 Macpaul Lin
  2020-04-17  5:23 ` [PATCH 2/2] phy: phy-mtk-tphy: introduce force_vbus for u2 phy Macpaul Lin
  2020-04-29 21:30 ` [PATCH 1/2] dt-bindings: phy-mtk-tphy: add the property about force_vbus Rob Herring
  0 siblings, 2 replies; 4+ messages in thread
From: Macpaul Lin @ 2020-04-17  5:23 UTC (permalink / raw)
  To: Min Guo, Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring,
	Matthias Brugger, linux-arm-kernel, linux-mediatek, linux-kernel,
	devicetree
  Cc: Mediatek WSD Upstream, Macpaul Lin, Macpaul Lin

For some platforms, they don't have vbus pin connection between usb's phy
and mac. Hence we need to control force_vbus related registers to keep
hardware works normal.
This patch add the required bool property force_vbus.

Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
---
 Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt b/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt
index dd75b676b71d..6b49b651becc 100644
--- a/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt
+++ b/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt
@@ -37,6 +37,9 @@ Optional properties (controller (parent) node):
 		  calibrate
  - mediatek,src-coef	: coefficient for slew rate calibrate, depends on
 		  SoC process
+ - force_vbus	: if the platform has no vbus connection between phy and mac,
+		  (force_vbus mode), then this property should be exist.
+		  Otherwise not to add this property.
 
 Required properties (port (child) node):
 - reg		: address and length of the register set for the port.
-- 
2.18.0

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

* [PATCH 2/2] phy: phy-mtk-tphy: introduce force_vbus for u2 phy
  2020-04-17  5:23 [PATCH 1/2] dt-bindings: phy-mtk-tphy: add the property about force_vbus Macpaul Lin
@ 2020-04-17  5:23 ` Macpaul Lin
  2020-04-17  5:34   ` Chunfeng Yun
  2020-04-29 21:30 ` [PATCH 1/2] dt-bindings: phy-mtk-tphy: add the property about force_vbus Rob Herring
  1 sibling, 1 reply; 4+ messages in thread
From: Macpaul Lin @ 2020-04-17  5:23 UTC (permalink / raw)
  To: Min Guo, Chunfeng Yun, Kishon Vijay Abraham I, Rob Herring,
	Matthias Brugger, linux-arm-kernel, linux-mediatek, linux-kernel,
	devicetree
  Cc: Mediatek WSD Upstream, Macpaul Lin, Macpaul Lin

For some platforms, they don't have vbus pin connection between usb phy and
mac. Hence we need to control force_vbus related registers to keep hardware
works normal.
This patch add corresponding behavior of force vbus in u2 phy related
functions.

Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
---
 drivers/phy/mediatek/phy-mtk-tphy.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index cdbcc49f7115..46f0fea175e5 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -99,6 +99,7 @@
 
 #define U3P_U2PHYDTM1		0x06C
 #define P2C_RG_UART_EN			BIT(16)
+#define P2C_FORCE_VBUSVALID		BIT(13)
 #define P2C_FORCE_IDDIG		BIT(9)
 #define P2C_RG_VBUSVALID		BIT(5)
 #define P2C_RG_SESSEND			BIT(4)
@@ -318,6 +319,7 @@ struct mtk_tphy {
 	int nphys;
 	int src_ref_clk; /* MHZ, reference clock for slew rate calibrate */
 	int src_coef; /* coefficient for slew rate calibrate */
+	bool force_vbus;
 };
 
 static void hs_slew_rate_calibrate(struct mtk_tphy *tphy,
@@ -611,13 +613,20 @@ static void u2_phy_instance_set_mode(struct mtk_tphy *tphy,
 	switch (mode) {
 	case PHY_MODE_USB_DEVICE:
 		tmp |= P2C_FORCE_IDDIG | P2C_RG_IDDIG;
+		if (tphy->force_vbus)
+			tmp |= P2C_RG_VBUSVALID | P2C_FORCE_VBUSVALID;
 		break;
 	case PHY_MODE_USB_HOST:
 		tmp |= P2C_FORCE_IDDIG;
-		tmp &= ~P2C_RG_IDDIG;
+		if (tphy->force_vbus)
+			tmp &= ~(P2C_RG_VBUSVALID | P2C_FORCE_VBUSVALID);
+		else
+			tmp &= ~P2C_RG_IDDIG;
 		break;
 	case PHY_MODE_USB_OTG:
 		tmp &= ~(P2C_FORCE_IDDIG | P2C_RG_IDDIG);
+		if (tphy->force_vbus)
+			tmp &= ~(P2C_RG_VBUSVALID | P2C_FORCE_VBUSVALID);
 		break;
 	default:
 		return;
@@ -1187,6 +1196,11 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 			retval = PTR_ERR(instance->da_ref_clk);
 			goto put_child;
 		}
+
+		/*
+		 * On some platform, vbus is dis-connected between PHY and MAC.
+		 */
+		tphy->force_vbus = device_property_read_bool(dev, "force_vbus");
 	}
 
 	provider = devm_of_phy_provider_register(dev, mtk_phy_xlate);
-- 
2.18.0

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

* Re: [PATCH 2/2] phy: phy-mtk-tphy: introduce force_vbus for u2 phy
  2020-04-17  5:23 ` [PATCH 2/2] phy: phy-mtk-tphy: introduce force_vbus for u2 phy Macpaul Lin
@ 2020-04-17  5:34   ` Chunfeng Yun
  0 siblings, 0 replies; 4+ messages in thread
From: Chunfeng Yun @ 2020-04-17  5:34 UTC (permalink / raw)
  To: Macpaul Lin
  Cc: Min Guo, Kishon Vijay Abraham I, Rob Herring, Matthias Brugger,
	linux-arm-kernel, linux-mediatek, linux-kernel, devicetree,
	Mediatek WSD Upstream, Macpaul Lin

Hi Macpaul,

On Fri, 2020-04-17 at 13:23 +0800, Macpaul Lin wrote:
> For some platforms, they don't have vbus pin connection between usb phy and
> mac. Hence we need to control force_vbus related registers to keep hardware
> works normal.
> This patch add corresponding behavior of force vbus in u2 phy related
> functions.
> 
> Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
NACK, I tried to support it early, but found this will cause some issue
for SS/SSP device only mode, so please abandon this patch, thanks


> ---
>  drivers/phy/mediatek/phy-mtk-tphy.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
> index cdbcc49f7115..46f0fea175e5 100644
> --- a/drivers/phy/mediatek/phy-mtk-tphy.c
> +++ b/drivers/phy/mediatek/phy-mtk-tphy.c
> @@ -99,6 +99,7 @@
>  
>  #define U3P_U2PHYDTM1		0x06C
>  #define P2C_RG_UART_EN			BIT(16)
> +#define P2C_FORCE_VBUSVALID		BIT(13)
>  #define P2C_FORCE_IDDIG		BIT(9)
>  #define P2C_RG_VBUSVALID		BIT(5)
>  #define P2C_RG_SESSEND			BIT(4)
> @@ -318,6 +319,7 @@ struct mtk_tphy {
>  	int nphys;
>  	int src_ref_clk; /* MHZ, reference clock for slew rate calibrate */
>  	int src_coef; /* coefficient for slew rate calibrate */
> +	bool force_vbus;
>  };
>  
>  static void hs_slew_rate_calibrate(struct mtk_tphy *tphy,
> @@ -611,13 +613,20 @@ static void u2_phy_instance_set_mode(struct mtk_tphy *tphy,
>  	switch (mode) {
>  	case PHY_MODE_USB_DEVICE:
>  		tmp |= P2C_FORCE_IDDIG | P2C_RG_IDDIG;
> +		if (tphy->force_vbus)
> +			tmp |= P2C_RG_VBUSVALID | P2C_FORCE_VBUSVALID;
>  		break;
>  	case PHY_MODE_USB_HOST:
>  		tmp |= P2C_FORCE_IDDIG;
> -		tmp &= ~P2C_RG_IDDIG;
> +		if (tphy->force_vbus)
> +			tmp &= ~(P2C_RG_VBUSVALID | P2C_FORCE_VBUSVALID);
> +		else
> +			tmp &= ~P2C_RG_IDDIG;
>  		break;
>  	case PHY_MODE_USB_OTG:
>  		tmp &= ~(P2C_FORCE_IDDIG | P2C_RG_IDDIG);
> +		if (tphy->force_vbus)
> +			tmp &= ~(P2C_RG_VBUSVALID | P2C_FORCE_VBUSVALID);
>  		break;
>  	default:
>  		return;
> @@ -1187,6 +1196,11 @@ static int mtk_tphy_probe(struct platform_device *pdev)
>  			retval = PTR_ERR(instance->da_ref_clk);
>  			goto put_child;
>  		}
> +
> +		/*
> +		 * On some platform, vbus is dis-connected between PHY and MAC.
> +		 */
> +		tphy->force_vbus = device_property_read_bool(dev, "force_vbus");
>  	}
>  
>  	provider = devm_of_phy_provider_register(dev, mtk_phy_xlate);


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

* Re: [PATCH 1/2] dt-bindings: phy-mtk-tphy: add the property about force_vbus
  2020-04-17  5:23 [PATCH 1/2] dt-bindings: phy-mtk-tphy: add the property about force_vbus Macpaul Lin
  2020-04-17  5:23 ` [PATCH 2/2] phy: phy-mtk-tphy: introduce force_vbus for u2 phy Macpaul Lin
@ 2020-04-29 21:30 ` Rob Herring
  1 sibling, 0 replies; 4+ messages in thread
From: Rob Herring @ 2020-04-29 21:30 UTC (permalink / raw)
  To: Macpaul Lin
  Cc: Min Guo, Chunfeng Yun, Kishon Vijay Abraham I, Matthias Brugger,
	linux-arm-kernel, linux-mediatek, linux-kernel, devicetree,
	Mediatek WSD Upstream, Macpaul Lin

On Fri, Apr 17, 2020 at 01:23:05PM +0800, Macpaul Lin wrote:
> For some platforms, they don't have vbus pin connection between usb's phy
> and mac. Hence we need to control force_vbus related registers to keep
> hardware works normal.
> This patch add the required bool property force_vbus.
> 
> Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
> ---
>  Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt b/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt
> index dd75b676b71d..6b49b651becc 100644
> --- a/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt
> +++ b/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt
> @@ -37,6 +37,9 @@ Optional properties (controller (parent) node):
>  		  calibrate
>   - mediatek,src-coef	: coefficient for slew rate calibrate, depends on
>  		  SoC process
> + - force_vbus	: if the platform has no vbus connection between phy and mac,

mediatek,force-vbus

This is board specific? If SoC specific, you should drop and imply this 
from the compatible string.

> +		  (force_vbus mode), then this property should be exist.
> +		  Otherwise not to add this property.
>  
>  Required properties (port (child) node):
>  - reg		: address and length of the register set for the port.
> -- 
> 2.18.0

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

end of thread, other threads:[~2020-04-29 21:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17  5:23 [PATCH 1/2] dt-bindings: phy-mtk-tphy: add the property about force_vbus Macpaul Lin
2020-04-17  5:23 ` [PATCH 2/2] phy: phy-mtk-tphy: introduce force_vbus for u2 phy Macpaul Lin
2020-04-17  5:34   ` Chunfeng Yun
2020-04-29 21:30 ` [PATCH 1/2] dt-bindings: phy-mtk-tphy: add the property about force_vbus Rob Herring

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).