All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drivers: phy: qcom: ipq806x-usb: convert to BITFIELD macro
@ 2022-01-17  0:26 ` Ansuel Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-01-17  0:26 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I, Vinod Koul,
	linux-arm-msm, linux-phy, linux-kernel
  Cc: Ansuel Smith

Convert some define to BITFIELD macro to tidy things up.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
index bfff0c8c9130..6788e0e8272a 100644
--- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
+++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
@@ -10,6 +10,7 @@
 #include <linux/delay.h>
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
+#include <linux/bitfield.h>
 
 /* USB QSCRATCH Hardware registers */
 #define QSCRATCH_GENERAL_CFG		(0x08)
@@ -74,20 +75,20 @@
 		 PHY_PARAM_CTRL1_LOS_BIAS_MASK)
 
 #define PHY_PARAM_CTRL1_TX_FULL_SWING(x)	\
-		(((x) << 20) & PHY_PARAM_CTRL1_TX_FULL_SWING_MASK)
+		FIELD_PREP(PHY_PARAM_CTRL1_TX_FULL_SWING_MASK, (x))
 #define PHY_PARAM_CTRL1_TX_DEEMPH_6DB(x)	\
-		(((x) << 14) & PHY_PARAM_CTRL1_TX_DEEMPH_6DB_MASK)
+		FIELD_PREP(PHY_PARAM_CTRL1_TX_DEEMPH_6DB_MASK, (x))
 #define PHY_PARAM_CTRL1_TX_DEEMPH_3_5DB(x)	\
-		(((x) <<  8) & PHY_PARAM_CTRL1_TX_DEEMPH_3_5DB_MASK)
+		FIELD_PREP(PHY_PARAM_CTRL1_TX_DEEMPH_3_5DB_MASK, x)
 #define PHY_PARAM_CTRL1_LOS_BIAS(x)	\
-		(((x) <<  3) & PHY_PARAM_CTRL1_LOS_BIAS_MASK)
+		FIELD_PREP(PHY_PARAM_CTRL1_LOS_BIAS_MASK, (x))
 
 /* RX OVRD IN HI bits */
 #define RX_OVRD_IN_HI_RX_RESET_OVRD		BIT(13)
 #define RX_OVRD_IN_HI_RX_RX_RESET		BIT(12)
 #define RX_OVRD_IN_HI_RX_EQ_OVRD		BIT(11)
 #define RX_OVRD_IN_HI_RX_EQ_MASK		GENMASK(10, 7)
-#define RX_OVRD_IN_HI_RX_EQ(x)			((x) << 8)
+#define RX_OVRD_IN_HI_RX_EQ(x)			FIELD_PREP(RX_OVRD_IN_HI_RX_EQ_MASK, (x))
 #define RX_OVRD_IN_HI_RX_EQ_EN_OVRD		BIT(7)
 #define RX_OVRD_IN_HI_RX_EQ_EN			BIT(6)
 #define RX_OVRD_IN_HI_RX_LOS_FILTER_OVRD	BIT(5)
-- 
2.33.1


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

* [PATCH 1/2] drivers: phy: qcom: ipq806x-usb: convert to BITFIELD macro
@ 2022-01-17  0:26 ` Ansuel Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-01-17  0:26 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I, Vinod Koul,
	linux-arm-msm, linux-phy, linux-kernel
  Cc: Ansuel Smith

Convert some define to BITFIELD macro to tidy things up.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
index bfff0c8c9130..6788e0e8272a 100644
--- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
+++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
@@ -10,6 +10,7 @@
 #include <linux/delay.h>
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
+#include <linux/bitfield.h>
 
 /* USB QSCRATCH Hardware registers */
 #define QSCRATCH_GENERAL_CFG		(0x08)
@@ -74,20 +75,20 @@
 		 PHY_PARAM_CTRL1_LOS_BIAS_MASK)
 
 #define PHY_PARAM_CTRL1_TX_FULL_SWING(x)	\
-		(((x) << 20) & PHY_PARAM_CTRL1_TX_FULL_SWING_MASK)
+		FIELD_PREP(PHY_PARAM_CTRL1_TX_FULL_SWING_MASK, (x))
 #define PHY_PARAM_CTRL1_TX_DEEMPH_6DB(x)	\
-		(((x) << 14) & PHY_PARAM_CTRL1_TX_DEEMPH_6DB_MASK)
+		FIELD_PREP(PHY_PARAM_CTRL1_TX_DEEMPH_6DB_MASK, (x))
 #define PHY_PARAM_CTRL1_TX_DEEMPH_3_5DB(x)	\
-		(((x) <<  8) & PHY_PARAM_CTRL1_TX_DEEMPH_3_5DB_MASK)
+		FIELD_PREP(PHY_PARAM_CTRL1_TX_DEEMPH_3_5DB_MASK, x)
 #define PHY_PARAM_CTRL1_LOS_BIAS(x)	\
-		(((x) <<  3) & PHY_PARAM_CTRL1_LOS_BIAS_MASK)
+		FIELD_PREP(PHY_PARAM_CTRL1_LOS_BIAS_MASK, (x))
 
 /* RX OVRD IN HI bits */
 #define RX_OVRD_IN_HI_RX_RESET_OVRD		BIT(13)
 #define RX_OVRD_IN_HI_RX_RX_RESET		BIT(12)
 #define RX_OVRD_IN_HI_RX_EQ_OVRD		BIT(11)
 #define RX_OVRD_IN_HI_RX_EQ_MASK		GENMASK(10, 7)
-#define RX_OVRD_IN_HI_RX_EQ(x)			((x) << 8)
+#define RX_OVRD_IN_HI_RX_EQ(x)			FIELD_PREP(RX_OVRD_IN_HI_RX_EQ_MASK, (x))
 #define RX_OVRD_IN_HI_RX_EQ_EN_OVRD		BIT(7)
 #define RX_OVRD_IN_HI_RX_EQ_EN			BIT(6)
 #define RX_OVRD_IN_HI_RX_LOS_FILTER_OVRD	BIT(5)
-- 
2.33.1


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

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

* [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
  2022-01-17  0:26 ` Ansuel Smith
@ 2022-01-17  0:26   ` Ansuel Smith
  -1 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-01-17  0:26 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I, Vinod Koul,
	linux-arm-msm, linux-phy, linux-kernel
  Cc: Ansuel Smith

Convert latch function to readl pool macro to tidy things up.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
index 6788e0e8272a..ab2d1431546d 100644
--- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
+++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
@@ -112,6 +112,9 @@
 #define SS_CR_READ_REG				BIT(0)
 #define SS_CR_WRITE_REG				BIT(0)
 
+#define LATCH_SLEEP				40
+#define LATCH_TIMEOUT				100
+
 struct usb_phy {
 	void __iomem		*base;
 	struct device		*dev;
@@ -156,19 +159,9 @@ static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3,
 
 static int wait_for_latch(void __iomem *addr)
 {
-	u32 retry = 10;
-
-	while (true) {
-		if (!readl(addr))
-			break;
-
-		if (--retry == 0)
-			return -ETIMEDOUT;
-
-		usleep_range(10, 20);
-	}
+	u32 val;
 
-	return 0;
+	return readl_poll_timeout(addr, val, !val, LATCH_SLEEP, LATCH_TIMEOUT);
 }
 
 /**
-- 
2.33.1


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

* [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
@ 2022-01-17  0:26   ` Ansuel Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-01-17  0:26 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I, Vinod Koul,
	linux-arm-msm, linux-phy, linux-kernel
  Cc: Ansuel Smith

Convert latch function to readl pool macro to tidy things up.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
index 6788e0e8272a..ab2d1431546d 100644
--- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
+++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
@@ -112,6 +112,9 @@
 #define SS_CR_READ_REG				BIT(0)
 #define SS_CR_WRITE_REG				BIT(0)
 
+#define LATCH_SLEEP				40
+#define LATCH_TIMEOUT				100
+
 struct usb_phy {
 	void __iomem		*base;
 	struct device		*dev;
@@ -156,19 +159,9 @@ static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3,
 
 static int wait_for_latch(void __iomem *addr)
 {
-	u32 retry = 10;
-
-	while (true) {
-		if (!readl(addr))
-			break;
-
-		if (--retry == 0)
-			return -ETIMEDOUT;
-
-		usleep_range(10, 20);
-	}
+	u32 val;
 
-	return 0;
+	return readl_poll_timeout(addr, val, !val, LATCH_SLEEP, LATCH_TIMEOUT);
 }
 
 /**
-- 
2.33.1


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

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

* Re: [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
  2022-01-17  0:26   ` Ansuel Smith
@ 2022-01-23 11:52     ` Vinod Koul
  -1 siblings, 0 replies; 12+ messages in thread
From: Vinod Koul @ 2022-01-23 11:52 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I,
	linux-arm-msm, linux-phy, linux-kernel

On 17-01-22, 01:26, Ansuel Smith wrote:
> Convert latch function to readl pool macro to tidy things up.
> 
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
>  drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> index 6788e0e8272a..ab2d1431546d 100644
> --- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> +++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> @@ -112,6 +112,9 @@
>  #define SS_CR_READ_REG				BIT(0)
>  #define SS_CR_WRITE_REG				BIT(0)
>  
> +#define LATCH_SLEEP				40
> +#define LATCH_TIMEOUT				100
> +
>  struct usb_phy {
>  	void __iomem		*base;
>  	struct device		*dev;
> @@ -156,19 +159,9 @@ static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3,
>  
>  static int wait_for_latch(void __iomem *addr)
>  {
> -	u32 retry = 10;
> -
> -	while (true) {
> -		if (!readl(addr))
> -			break;

we break if read returns non zero value...

Do you know what is the value expected?

> -
> -		if (--retry == 0)
> -			return -ETIMEDOUT;
> -
> -		usleep_range(10, 20);
> -	}
> +	u32 val;

Okay this contains garbage..
>  
> -	return 0;
> +	return readl_poll_timeout(addr, val, !val, LATCH_SLEEP, LATCH_TIMEOUT);

and we are waiting for it read a garbage value!


-- 
~Vinod

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

* Re: [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
@ 2022-01-23 11:52     ` Vinod Koul
  0 siblings, 0 replies; 12+ messages in thread
From: Vinod Koul @ 2022-01-23 11:52 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I,
	linux-arm-msm, linux-phy, linux-kernel

On 17-01-22, 01:26, Ansuel Smith wrote:
> Convert latch function to readl pool macro to tidy things up.
> 
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
>  drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> index 6788e0e8272a..ab2d1431546d 100644
> --- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> +++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> @@ -112,6 +112,9 @@
>  #define SS_CR_READ_REG				BIT(0)
>  #define SS_CR_WRITE_REG				BIT(0)
>  
> +#define LATCH_SLEEP				40
> +#define LATCH_TIMEOUT				100
> +
>  struct usb_phy {
>  	void __iomem		*base;
>  	struct device		*dev;
> @@ -156,19 +159,9 @@ static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3,
>  
>  static int wait_for_latch(void __iomem *addr)
>  {
> -	u32 retry = 10;
> -
> -	while (true) {
> -		if (!readl(addr))
> -			break;

we break if read returns non zero value...

Do you know what is the value expected?

> -
> -		if (--retry == 0)
> -			return -ETIMEDOUT;
> -
> -		usleep_range(10, 20);
> -	}
> +	u32 val;

Okay this contains garbage..
>  
> -	return 0;
> +	return readl_poll_timeout(addr, val, !val, LATCH_SLEEP, LATCH_TIMEOUT);

and we are waiting for it read a garbage value!


-- 
~Vinod

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

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

* Re: [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
  2022-01-23 11:52     ` Vinod Koul
@ 2022-01-23 14:46       ` Ansuel Smith
  -1 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-01-23 14:46 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I,
	linux-arm-msm, linux-phy, linux-kernel

On Sun, Jan 23, 2022 at 05:22:18PM +0530, Vinod Koul wrote:
> On 17-01-22, 01:26, Ansuel Smith wrote:
> > Convert latch function to readl pool macro to tidy things up.
> > 
> > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > ---
> >  drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------
> >  1 file changed, 5 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > index 6788e0e8272a..ab2d1431546d 100644
> > --- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > +++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > @@ -112,6 +112,9 @@
> >  #define SS_CR_READ_REG				BIT(0)
> >  #define SS_CR_WRITE_REG				BIT(0)
> >  
> > +#define LATCH_SLEEP				40
> > +#define LATCH_TIMEOUT				100
> > +
> >  struct usb_phy {
> >  	void __iomem		*base;
> >  	struct device		*dev;
> > @@ -156,19 +159,9 @@ static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3,
> >  
> >  static int wait_for_latch(void __iomem *addr)
> >  {
> > -	u32 retry = 10;
> > -
> > -	while (true) {
> > -		if (!readl(addr))
> > -			break;
> 
> we break if read returns non zero value...
> 
> Do you know what is the value expected?
>

If I understand the logic here, we write a value and we wait for it to
get applied. To confirm that we execute a writel and then we readl the
same address until it does return a value. That is the way used to
understand that the write process has finished and that the value has
been applied/we can write again.

> > -
> > -		if (--retry == 0)
> > -			return -ETIMEDOUT;
> > -
> > -		usleep_range(10, 20);
> > -	}
> > +	u32 val;
> 
> Okay this contains garbage..

I think I didn't understand, val value will get replaced by readl in
the pool_timeout function.

> >  
> > -	return 0;
> > +	return readl_poll_timeout(addr, val, !val, LATCH_SLEEP, LATCH_TIMEOUT);
> 
> and we are waiting for it read a garbage value!
> 

Again could be very confused and wrong but the pool_timeout macro does
the exact same thing of the wait_for_latch function with th only
difference of handling the sleep differently. We put in val the return
of readl and the break condition as !val. Or I didn't understand the
concern about garbage value.

> 
> -- 
> ~Vinod

-- 
	Ansuel

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

* Re: [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
@ 2022-01-23 14:46       ` Ansuel Smith
  0 siblings, 0 replies; 12+ messages in thread
From: Ansuel Smith @ 2022-01-23 14:46 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I,
	linux-arm-msm, linux-phy, linux-kernel

On Sun, Jan 23, 2022 at 05:22:18PM +0530, Vinod Koul wrote:
> On 17-01-22, 01:26, Ansuel Smith wrote:
> > Convert latch function to readl pool macro to tidy things up.
> > 
> > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > ---
> >  drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------
> >  1 file changed, 5 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > index 6788e0e8272a..ab2d1431546d 100644
> > --- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > +++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > @@ -112,6 +112,9 @@
> >  #define SS_CR_READ_REG				BIT(0)
> >  #define SS_CR_WRITE_REG				BIT(0)
> >  
> > +#define LATCH_SLEEP				40
> > +#define LATCH_TIMEOUT				100
> > +
> >  struct usb_phy {
> >  	void __iomem		*base;
> >  	struct device		*dev;
> > @@ -156,19 +159,9 @@ static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3,
> >  
> >  static int wait_for_latch(void __iomem *addr)
> >  {
> > -	u32 retry = 10;
> > -
> > -	while (true) {
> > -		if (!readl(addr))
> > -			break;
> 
> we break if read returns non zero value...
> 
> Do you know what is the value expected?
>

If I understand the logic here, we write a value and we wait for it to
get applied. To confirm that we execute a writel and then we readl the
same address until it does return a value. That is the way used to
understand that the write process has finished and that the value has
been applied/we can write again.

> > -
> > -		if (--retry == 0)
> > -			return -ETIMEDOUT;
> > -
> > -		usleep_range(10, 20);
> > -	}
> > +	u32 val;
> 
> Okay this contains garbage..

I think I didn't understand, val value will get replaced by readl in
the pool_timeout function.

> >  
> > -	return 0;
> > +	return readl_poll_timeout(addr, val, !val, LATCH_SLEEP, LATCH_TIMEOUT);
> 
> and we are waiting for it read a garbage value!
> 

Again could be very confused and wrong but the pool_timeout macro does
the exact same thing of the wait_for_latch function with th only
difference of handling the sleep differently. We put in val the return
of readl and the break condition as !val. Or I didn't understand the
concern about garbage value.

> 
> -- 
> ~Vinod

-- 
	Ansuel

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

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

* Re: [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
  2022-01-23 14:46       ` Ansuel Smith
@ 2022-01-24  4:27         ` Vinod Koul
  -1 siblings, 0 replies; 12+ messages in thread
From: Vinod Koul @ 2022-01-24  4:27 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I,
	linux-arm-msm, linux-phy, linux-kernel

On 23-01-22, 15:46, Ansuel Smith wrote:
> On Sun, Jan 23, 2022 at 05:22:18PM +0530, Vinod Koul wrote:
> > On 17-01-22, 01:26, Ansuel Smith wrote:
> > > Convert latch function to readl pool macro to tidy things up.
> > > 
> > > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > > ---
> > >  drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------
> > >  1 file changed, 5 insertions(+), 12 deletions(-)
> > > 
> > > diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > > index 6788e0e8272a..ab2d1431546d 100644
> > > --- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > > +++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > > @@ -112,6 +112,9 @@
> > >  #define SS_CR_READ_REG				BIT(0)
> > >  #define SS_CR_WRITE_REG				BIT(0)
> > >  
> > > +#define LATCH_SLEEP				40
> > > +#define LATCH_TIMEOUT				100
> > > +
> > >  struct usb_phy {
> > >  	void __iomem		*base;
> > >  	struct device		*dev;
> > > @@ -156,19 +159,9 @@ static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3,
> > >  
> > >  static int wait_for_latch(void __iomem *addr)
> > >  {
> > > -	u32 retry = 10;
> > > -
> > > -	while (true) {
> > > -		if (!readl(addr))
> > > -			break;
> > 
> > we break if read returns non zero value...
> > 
> > Do you know what is the value expected?
> >
> 
> If I understand the logic here, we write a value and we wait for it to
> get applied. To confirm that we execute a writel and then we readl the
> same address until it does return a value. That is the way used to
> understand that the write process has finished and that the value has
> been applied/we can write again.
> 
> > > -
> > > -		if (--retry == 0)
> > > -			return -ETIMEDOUT;
> > > -
> > > -		usleep_range(10, 20);
> > > -	}
> > > +	u32 val;
> > 
> > Okay this contains garbage..
> 
> I think I didn't understand, val value will get replaced by readl in
> the pool_timeout function.
> 
> > >  
> > > -	return 0;
> > > +	return readl_poll_timeout(addr, val, !val, LATCH_SLEEP, LATCH_TIMEOUT);
> > 
> > and we are waiting for it read a garbage value!
> > 
> 
> Again could be very confused and wrong but the pool_timeout macro does
> the exact same thing of the wait_for_latch function with th only
> difference of handling the sleep differently. We put in val the return
> of readl and the break condition as !val. Or I didn't understand the
> concern about garbage value.

Sorry I read the readl_poll_timeout wrongly, this seems correct, I will
pick these now.

-- 
~Vinod

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

* Re: [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
@ 2022-01-24  4:27         ` Vinod Koul
  0 siblings, 0 replies; 12+ messages in thread
From: Vinod Koul @ 2022-01-24  4:27 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I,
	linux-arm-msm, linux-phy, linux-kernel

On 23-01-22, 15:46, Ansuel Smith wrote:
> On Sun, Jan 23, 2022 at 05:22:18PM +0530, Vinod Koul wrote:
> > On 17-01-22, 01:26, Ansuel Smith wrote:
> > > Convert latch function to readl pool macro to tidy things up.
> > > 
> > > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > > ---
> > >  drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------
> > >  1 file changed, 5 insertions(+), 12 deletions(-)
> > > 
> > > diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > > index 6788e0e8272a..ab2d1431546d 100644
> > > --- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > > +++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> > > @@ -112,6 +112,9 @@
> > >  #define SS_CR_READ_REG				BIT(0)
> > >  #define SS_CR_WRITE_REG				BIT(0)
> > >  
> > > +#define LATCH_SLEEP				40
> > > +#define LATCH_TIMEOUT				100
> > > +
> > >  struct usb_phy {
> > >  	void __iomem		*base;
> > >  	struct device		*dev;
> > > @@ -156,19 +159,9 @@ static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3,
> > >  
> > >  static int wait_for_latch(void __iomem *addr)
> > >  {
> > > -	u32 retry = 10;
> > > -
> > > -	while (true) {
> > > -		if (!readl(addr))
> > > -			break;
> > 
> > we break if read returns non zero value...
> > 
> > Do you know what is the value expected?
> >
> 
> If I understand the logic here, we write a value and we wait for it to
> get applied. To confirm that we execute a writel and then we readl the
> same address until it does return a value. That is the way used to
> understand that the write process has finished and that the value has
> been applied/we can write again.
> 
> > > -
> > > -		if (--retry == 0)
> > > -			return -ETIMEDOUT;
> > > -
> > > -		usleep_range(10, 20);
> > > -	}
> > > +	u32 val;
> > 
> > Okay this contains garbage..
> 
> I think I didn't understand, val value will get replaced by readl in
> the pool_timeout function.
> 
> > >  
> > > -	return 0;
> > > +	return readl_poll_timeout(addr, val, !val, LATCH_SLEEP, LATCH_TIMEOUT);
> > 
> > and we are waiting for it read a garbage value!
> > 
> 
> Again could be very confused and wrong but the pool_timeout macro does
> the exact same thing of the wait_for_latch function with th only
> difference of handling the sleep differently. We put in val the return
> of readl and the break condition as !val. Or I didn't understand the
> concern about garbage value.

Sorry I read the readl_poll_timeout wrongly, this seems correct, I will
pick these now.

-- 
~Vinod

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

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

* Re: [PATCH 1/2] drivers: phy: qcom: ipq806x-usb: convert to BITFIELD macro
  2022-01-17  0:26 ` Ansuel Smith
@ 2022-01-24  4:28   ` Vinod Koul
  -1 siblings, 0 replies; 12+ messages in thread
From: Vinod Koul @ 2022-01-24  4:28 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I,
	linux-arm-msm, linux-phy, linux-kernel

On 17-01-22, 01:26, Ansuel Smith wrote:
> Convert some define to BITFIELD macro to tidy things up.

Applied both, thanks

-- 
~Vinod

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

* Re: [PATCH 1/2] drivers: phy: qcom: ipq806x-usb: convert to BITFIELD macro
@ 2022-01-24  4:28   ` Vinod Koul
  0 siblings, 0 replies; 12+ messages in thread
From: Vinod Koul @ 2022-01-24  4:28 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: Andy Gross, Bjorn Andersson, Kishon Vijay Abraham I,
	linux-arm-msm, linux-phy, linux-kernel

On 17-01-22, 01:26, Ansuel Smith wrote:
> Convert some define to BITFIELD macro to tidy things up.

Applied both, thanks

-- 
~Vinod

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

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

end of thread, other threads:[~2022-01-24  4:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17  0:26 [PATCH 1/2] drivers: phy: qcom: ipq806x-usb: convert to BITFIELD macro Ansuel Smith
2022-01-17  0:26 ` Ansuel Smith
2022-01-17  0:26 ` [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro Ansuel Smith
2022-01-17  0:26   ` Ansuel Smith
2022-01-23 11:52   ` Vinod Koul
2022-01-23 11:52     ` Vinod Koul
2022-01-23 14:46     ` Ansuel Smith
2022-01-23 14:46       ` Ansuel Smith
2022-01-24  4:27       ` Vinod Koul
2022-01-24  4:27         ` Vinod Koul
2022-01-24  4:28 ` [PATCH 1/2] drivers: phy: qcom: ipq806x-usb: convert to BITFIELD macro Vinod Koul
2022-01-24  4:28   ` Vinod Koul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.