linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property
@ 2023-05-10 14:05 Frank Li
  2023-05-10 14:05 ` [PATCH v3 2/2] dt-bindings: phy: cdns,salvo: add property cdns,usb2-disconnect-threshold-microvolt Frank Li
  2023-05-16 13:17 ` [PATCH v3 1/2] phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property Vinod Koul
  0 siblings, 2 replies; 5+ messages in thread
From: Frank Li @ 2023-05-10 14:05 UTC (permalink / raw)
  To: vkoul, kishon, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
	kernel, linux-phy, devicetree, linux-kernel, linux-arm-kernel,
	imx, fushi.peng

Add cdns,usb2-disconnect-threshold-microvolt property to address fake USB
disconnection issue during enumeration or suspend state for difference
platform.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Change from v2 to v3
- add cdns prefix
Change from v1 to v2
- remove empty change before #include 
- Remove dts change from patch

 drivers/phy/cadence/phy-cadence-salvo.c | 29 +++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/phy/cadence/phy-cadence-salvo.c b/drivers/phy/cadence/phy-cadence-salvo.c
index 23be27a747a9..ab7eca515059 100644
--- a/drivers/phy/cadence/phy-cadence-salvo.c
+++ b/drivers/phy/cadence/phy-cadence-salvo.c
@@ -6,6 +6,7 @@
  * Copyright (c) 2019-2020 NXP
  */
 
+#include <linux/bitfield.h>
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -91,9 +92,19 @@
 
 /* USB2 PHY register definition */
 #define UTMI_REG15				0xaf
+#define UTMI_AFE_RX_REG0			0x0d
 #define UTMI_AFE_RX_REG5			0x12
 #define UTMI_AFE_BC_REG4			0x29
 
+/* Align UTMI_AFE_RX_REG0 bit[7:6] define */
+enum usb2_disconn_threshold {
+	USB2_DISCONN_THRESHOLD_575 = 0x0,
+	USB2_DISCONN_THRESHOLD_610 = 0x1,
+	USB2_DISCONN_THRESHOLD_645 = 0x3,
+};
+
+#define RX_USB2_DISCONN_MASK			GENMASK(7, 6)
+
 /* TB_ADDR_TX_RCVDETSC_CTRL */
 #define RXDET_IN_P3_32KHZ			BIT(0)
 /*
@@ -125,6 +136,7 @@ struct cdns_salvo_phy {
 	struct clk *clk;
 	void __iomem *base;
 	struct cdns_salvo_data *data;
+	enum usb2_disconn_threshold usb2_disconn;
 };
 
 static const struct of_device_id cdns_salvo_phy_of_match[];
@@ -261,6 +273,12 @@ static int cdns_salvo_phy_init(struct phy *phy)
 
 	cdns_salvo_write(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_RX_REG5,
 			 0x5);
+
+	value = cdns_salvo_read(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_RX_REG0);
+	value &= ~RX_USB2_DISCONN_MASK;
+	value = FIELD_PREP(RX_USB2_DISCONN_MASK, salvo_phy->usb2_disconn);
+	cdns_salvo_write(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_RX_REG0, value);
+
 	udelay(10);
 
 	clk_disable_unprepare(salvo_phy->clk);
@@ -315,6 +333,7 @@ static int cdns_salvo_phy_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct cdns_salvo_phy *salvo_phy;
 	struct cdns_salvo_data *data;
+	u32 val;
 
 	data = (struct cdns_salvo_data *)of_device_get_match_data(dev);
 	salvo_phy = devm_kzalloc(dev, sizeof(*salvo_phy), GFP_KERNEL);
@@ -326,6 +345,16 @@ static int cdns_salvo_phy_probe(struct platform_device *pdev)
 	if (IS_ERR(salvo_phy->clk))
 		return PTR_ERR(salvo_phy->clk);
 
+	if (of_property_read_u32(dev->of_node, "cdns,usb2-disconnect-threshold-microvolt", &val))
+		val = 575;
+
+	if (val < 610)
+		salvo_phy->usb2_disconn = USB2_DISCONN_THRESHOLD_575;
+	else if (val < 645)
+		salvo_phy->usb2_disconn = USB2_DISCONN_THRESHOLD_610;
+	else
+		salvo_phy->usb2_disconn = USB2_DISCONN_THRESHOLD_645;
+
 	salvo_phy->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(salvo_phy->base))
 		return PTR_ERR(salvo_phy->base);
-- 
2.34.1


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* [PATCH v3 2/2] dt-bindings: phy: cdns,salvo: add property cdns,usb2-disconnect-threshold-microvolt
  2023-05-10 14:05 [PATCH v3 1/2] phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property Frank Li
@ 2023-05-10 14:05 ` Frank Li
  2023-05-11  9:23   ` Krzysztof Kozlowski
  2023-05-16 13:17 ` [PATCH v3 1/2] phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property Vinod Koul
  1 sibling, 1 reply; 5+ messages in thread
From: Frank Li @ 2023-05-10 14:05 UTC (permalink / raw)
  To: vkoul, kishon, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
	kernel, linux-phy, devicetree, linux-kernel, linux-arm-kernel,
	imx, fushi.peng

Add cdns,usb2-disconnect-threshold-microvolt property to address fake USB
disconnection issue during enumeration or suspend state for difference
platform.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Change from v2 to v3
- add prefix cdns
Change from v1 to V2:
- fixed subject
- fixed dt-binding-check warning

 Documentation/devicetree/bindings/phy/cdns,salvo-phy.yaml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/cdns,salvo-phy.yaml b/Documentation/devicetree/bindings/phy/cdns,salvo-phy.yaml
index 3a07285b5470..ea41f35c6444 100644
--- a/Documentation/devicetree/bindings/phy/cdns,salvo-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/cdns,salvo-phy.yaml
@@ -31,6 +31,12 @@ properties:
   "#phy-cells":
     const: 0
 
+  cdns,usb2-disconnect-threshold-microvolt:
+    description: The microvolt threshold value utilized for detecting
+      USB disconnection event.
+    enum: [575, 610, 645]
+    default: 575
+
 required:
   - compatible
   - reg
-- 
2.34.1


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* Re: [PATCH v3 2/2] dt-bindings: phy: cdns,salvo: add property cdns,usb2-disconnect-threshold-microvolt
  2023-05-10 14:05 ` [PATCH v3 2/2] dt-bindings: phy: cdns,salvo: add property cdns,usb2-disconnect-threshold-microvolt Frank Li
@ 2023-05-11  9:23   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-11  9:23 UTC (permalink / raw)
  To: Frank Li, vkoul, kishon, robh+dt, krzysztof.kozlowski+dt,
	shawnguo, s.hauer, kernel, linux-phy, devicetree, linux-kernel,
	linux-arm-kernel, imx, fushi.peng

On 10/05/2023 16:05, Frank Li wrote:
> Add cdns,usb2-disconnect-threshold-microvolt property to address fake USB
> disconnection issue during enumeration or suspend state for difference
> platform.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* Re: [PATCH v3 1/2] phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property
  2023-05-10 14:05 [PATCH v3 1/2] phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property Frank Li
  2023-05-10 14:05 ` [PATCH v3 2/2] dt-bindings: phy: cdns,salvo: add property cdns,usb2-disconnect-threshold-microvolt Frank Li
@ 2023-05-16 13:17 ` Vinod Koul
  2023-05-16 14:38   ` [EXT] " Frank Li
  1 sibling, 1 reply; 5+ messages in thread
From: Vinod Koul @ 2023-05-16 13:17 UTC (permalink / raw)
  To: Frank Li
  Cc: kishon, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
	kernel, linux-phy, devicetree, linux-kernel, linux-arm-kernel,
	imx, fushi.peng

On 10-05-23, 10:05, Frank Li wrote:
> Add cdns,usb2-disconnect-threshold-microvolt property to address fake USB
> disconnection issue during enumeration or suspend state for difference
> platform.

This fails to apply for me on phy/next. What tree was this based on?

> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> Change from v2 to v3
> - add cdns prefix
> Change from v1 to v2
> - remove empty change before #include 
> - Remove dts change from patch
> 
>  drivers/phy/cadence/phy-cadence-salvo.c | 29 +++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/phy/cadence/phy-cadence-salvo.c b/drivers/phy/cadence/phy-cadence-salvo.c
> index 23be27a747a9..ab7eca515059 100644
> --- a/drivers/phy/cadence/phy-cadence-salvo.c
> +++ b/drivers/phy/cadence/phy-cadence-salvo.c
> @@ -6,6 +6,7 @@
>   * Copyright (c) 2019-2020 NXP
>   */
>  
> +#include <linux/bitfield.h>
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> @@ -91,9 +92,19 @@
>  
>  /* USB2 PHY register definition */
>  #define UTMI_REG15				0xaf
> +#define UTMI_AFE_RX_REG0			0x0d
>  #define UTMI_AFE_RX_REG5			0x12
>  #define UTMI_AFE_BC_REG4			0x29
>  
> +/* Align UTMI_AFE_RX_REG0 bit[7:6] define */
> +enum usb2_disconn_threshold {
> +	USB2_DISCONN_THRESHOLD_575 = 0x0,
> +	USB2_DISCONN_THRESHOLD_610 = 0x1,
> +	USB2_DISCONN_THRESHOLD_645 = 0x3,
> +};
> +
> +#define RX_USB2_DISCONN_MASK			GENMASK(7, 6)
> +
>  /* TB_ADDR_TX_RCVDETSC_CTRL */
>  #define RXDET_IN_P3_32KHZ			BIT(0)
>  /*
> @@ -125,6 +136,7 @@ struct cdns_salvo_phy {
>  	struct clk *clk;
>  	void __iomem *base;
>  	struct cdns_salvo_data *data;
> +	enum usb2_disconn_threshold usb2_disconn;
>  };
>  
>  static const struct of_device_id cdns_salvo_phy_of_match[];
> @@ -261,6 +273,12 @@ static int cdns_salvo_phy_init(struct phy *phy)
>  
>  	cdns_salvo_write(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_RX_REG5,
>  			 0x5);
> +
> +	value = cdns_salvo_read(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_RX_REG0);
> +	value &= ~RX_USB2_DISCONN_MASK;
> +	value = FIELD_PREP(RX_USB2_DISCONN_MASK, salvo_phy->usb2_disconn);
> +	cdns_salvo_write(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_RX_REG0, value);
> +
>  	udelay(10);
>  
>  	clk_disable_unprepare(salvo_phy->clk);
> @@ -315,6 +333,7 @@ static int cdns_salvo_phy_probe(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct cdns_salvo_phy *salvo_phy;
>  	struct cdns_salvo_data *data;
> +	u32 val;
>  
>  	data = (struct cdns_salvo_data *)of_device_get_match_data(dev);
>  	salvo_phy = devm_kzalloc(dev, sizeof(*salvo_phy), GFP_KERNEL);
> @@ -326,6 +345,16 @@ static int cdns_salvo_phy_probe(struct platform_device *pdev)
>  	if (IS_ERR(salvo_phy->clk))
>  		return PTR_ERR(salvo_phy->clk);
>  
> +	if (of_property_read_u32(dev->of_node, "cdns,usb2-disconnect-threshold-microvolt", &val))
> +		val = 575;
> +
> +	if (val < 610)
> +		salvo_phy->usb2_disconn = USB2_DISCONN_THRESHOLD_575;
> +	else if (val < 645)
> +		salvo_phy->usb2_disconn = USB2_DISCONN_THRESHOLD_610;
> +	else
> +		salvo_phy->usb2_disconn = USB2_DISCONN_THRESHOLD_645;
> +
>  	salvo_phy->base = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(salvo_phy->base))
>  		return PTR_ERR(salvo_phy->base);
> -- 
> 2.34.1
> 
> 
> -- 
> linux-phy mailing list
> linux-phy@lists.infradead.org
> https://lists.infradead.org/mailman/listinfo/linux-phy

-- 
~Vinod

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

* RE: [EXT] Re: [PATCH v3 1/2] phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property
  2023-05-16 13:17 ` [PATCH v3 1/2] phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property Vinod Koul
@ 2023-05-16 14:38   ` Frank Li
  0 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2023-05-16 14:38 UTC (permalink / raw)
  To: Vinod Koul
  Cc: kishon@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
	F.S. Peng

> On 10-05-23, 10:05, Frank Li wrote:
> > Add cdns,usb2-disconnect-threshold-microvolt property to address fake
> USB
> > disconnection issue during enumeration or suspend state for difference
> > platform.
> 
> This fails to apply for me on phy/next. What tree was this based on?
> 

Sorry, let me rebase it to latest phy/next.

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

end of thread, other threads:[~2023-05-16 14:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-10 14:05 [PATCH v3 1/2] phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property Frank Li
2023-05-10 14:05 ` [PATCH v3 2/2] dt-bindings: phy: cdns,salvo: add property cdns,usb2-disconnect-threshold-microvolt Frank Li
2023-05-11  9:23   ` Krzysztof Kozlowski
2023-05-16 13:17 ` [PATCH v3 1/2] phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property Vinod Koul
2023-05-16 14:38   ` [EXT] " Frank Li

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