drivers: phy: qcom: ipq806x-usb: convert to BITFIELD macro
Subsystems (2)
PATCH 1/2 drivers: phy: qcom: ipq806x-usb: convert to BITFIELD macro
Convert some define to BITFIELD macro to tidy things up.
--- drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +6 -5
@@ -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)
Signature · 7 lines
2.33.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 2/2 drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
Convert latch function to readl pool macro to tidy things up.
--- drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +5 -12
@@ -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 ); }/**
Signature · 7 lines
2.33.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Vinod Koul
maintainerRe: [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
Quoted 22 lines · Ansuel Smith
Convert latch function to readl pool macro to tidy things up.
Signed-off-by Ansuel Smith <[email protected]>--- drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +3
-0@@ -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;
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3, · line 163
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +0
-5@@ -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?
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3, · line 162
Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +1
-6- -if (--retry ==0 ) -return -ETIMEDOUT ; - -usleep_range (10 ,20 ); - } +u32 val;
Okay this contains garbage..
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3, · line 164
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +1
-1-return 0 ; +return readl_poll_timeout (addr, val, !val,LATCH_SLEEP ,LATCH_TIMEOUT );
and we are waiting for it read a garbage value!
Signature · 1 line
~Vinod
Re: [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
Quoted 34 lines · Vinod Koul
Quoted 22 lines · Ansuel Smith
Convert latch function to readl pool macro to tidy things up.
Signed-off-by Ansuel Smith <[email protected]>--- drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +3
-0@@ -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;drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3, · line 163
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +0
-5@@ -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...
Quoted 2 lines
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.
Quoted 9 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3, · line 162
Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +1
-6- -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.
Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3, · line 164
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +1
-1-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.
Quoted 3 lines
Signature · 2 lines
-- ~Vinod
Signature · 6 lines
Ansuel -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Vinod Koul
maintainerRe: [PATCH 2/2] drivers: phy: qcom: ipq806x-usb: conver latch function to pool macro
Quoted 64 lines · Ansuel Smith
Quoted 34 lines · Vinod Koul
Quoted 22 lines · Ansuel Smith
Convert latch function to readl pool macro to tidy things up.
Signed-off-by Ansuel Smith <[email protected]>--- drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +3
-0@@ -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;drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3, · line 163
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +0
-5@@ -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...
Quoted 2 lines
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.
Quoted 9 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3, · line 162
Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +1
-6- -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_timeoutfunction.Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3, · line 164
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c +1
-1-return 0 ; +return readl_poll_timeout (addr, val, !val,LATCH_SLEEP ,LATCH_TIMEOUT );and we are waiting for it read a garbage value!
Quoted 5 lines
Again could be very confused and wrong but the
pool_timeoutmacro does the exact same thing of thewait_for_latchfunction 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.
Signature · 1 line
~Vinod
Quoted 1 line · Ansuel Smith
Convert some define to BITFIELD macro to tidy things up.
Applied both, thanks
Signature · 1 line
~Vinod