phy: samsung: Use readl_poll_timeout function
Subsystems (2)
PATCH 1/1 phy: samsung: Use readl_poll_timeout function
User readl_poll_timeout function instead of open
coded handling in crport_handshake function.
--- drivers/phy/samsung/phy-exynos5-usbdrd.c | 37 +++++++++--------------- 1 file changed, 13 insertions(+), 24 deletions(-)
drivers/phy/samsung/phy-exynos5-usbdrd.c +13 -24
@@ -16,6 +16,7 @@#include <linux/of.h> #include <linux/of_address.h> #include <linux/of_device.h> +#include <linux/iopoll.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/mutex.h>
@@ -556,40 +557,28 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy)static int crport_handshake (struct exynos5_usbdrd_phy *phy_drd,u32 val,u32 cmd) { -u32 usec =100 ; +u32 timeout_us =1000 , sleep_us =10 ;unsigned int result; +int err;writel (val | cmd, phy_drd->reg_phy +EXYNOS5_DRD_PHYREG0 ); -do { - result =readl (phy_drd->reg_phy +EXYNOS5_DRD_PHYREG1 ); -if (result &PHYREG1_CR_ACK ) -break ; - -udelay (1 ); - }while (usec-- >0 ); - -if (!usec) { -dev_err (phy_drd->dev, -"CRPORT handshake timeout1 (0x%08x)\n" , val); + err =readl_poll_timeout (phy_drd->reg_phy +EXYNOS5_DRD_PHYREG1 , + result, (result &PHYREG1_CR_ACK ), sleep_us, timeout_us); +if (err) { +dev_err (phy_drd->dev,"CRPORT handshake timeout1 (0x%08x)\n" , val);return -ETIME ; } - usec =100 ; + timeout_us =1000 ; + sleep_us =10 ;writel (val, phy_drd->reg_phy +EXYNOS5_DRD_PHYREG0 ); -do { - result =readl (phy_drd->reg_phy +EXYNOS5_DRD_PHYREG1 ); -if (!(result &PHYREG1_CR_ACK )) -break ; - -udelay (1 ); - }while (usec-- >0 ); - -if (!usec) { -dev_err (phy_drd->dev, -"CRPORT handshake timeout2 (0x%08x)\n" , val); + err =readl_poll_timeout (phy_drd->reg_phy +EXYNOS5_DRD_PHYREG1 , + result, !(result &PHYREG1_CR_ACK ), sleep_us, timeout_us); +if (err) { +dev_err (phy_drd->dev,"CRPORT handshake timeout2 (0x%08x)\n" , val);return -ETIME ; }
Signature · 1 line
2.27.0
Krzysztof Kozlowski
maintainerQuoted 21 lines · Anand Moon
User
readl_poll_timeoutfunction instead of open
coded handling incrport_handshakefunction.Signed-off-by Anand Moon <[email protected]>--- drivers/phy/samsung/phy-exynos5-usbdrd.c | 37 +++++++++--------------- 1 file changed, 13 insertions(+), 24 deletions(-)drivers/phy/samsung/phy-exynos5-usbdrd.c +1
-0@@ -16,6 +16,7 @@#include <linux/of.h> #include <linux/of_address.h> #include <linux/of_device.h> +#include <linux/iopoll.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/mutex.h>
drivers/phy/samsung/phy-exynos5-usbdrd.c static int exynos5_usbdrd_phy_power_off(struct phy *phy) · line 561
Quoted 6 lines
drivers/phy/samsung/phy-exynos5-usbdrd.c +1
-1@@ -556,40 +557,28 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy)static int crport_handshake (struct exynos5_usbdrd_phy *phy_drd,u32 val,u32 cmd) { -u32 usec =100 ; +u32 timeout_us =1000 , sleep_us =10 ;unsigned int result;
You silently (without mentioning in commit msg and explaining why) changed both the sleep time and total timeout.
Nope, please explain why you chosen such values and change them in separate patch.
Quoted 15 lines
drivers/phy/samsung/phy-exynos5-usbdrd.c +1
-11+int err;writel (val | cmd, phy_drd->reg_phy +EXYNOS5_DRD_PHYREG0 ); -do { - result =readl (phy_drd->reg_phy +EXYNOS5_DRD_PHYREG1 ); -if (result &PHYREG1_CR_ACK ) -break ; - -udelay (1 ); - }while (usec-- >0 ); - -if (!usec) { -dev_err (phy_drd->dev, -"CRPORT handshake timeout1 (0x%08x)\n" , val);
drivers/phy/samsung/phy-exynos5-usbdrd.c static int exynos5_usbdrd_phy_power_off(struct phy *phy) · line 574
Quoted 10 lines
drivers/phy/samsung/phy-exynos5-usbdrd.c +6
-1+ err =readl_poll_timeout (phy_drd->reg_phy +EXYNOS5_DRD_PHYREG1 , + result, (result &PHYREG1_CR_ACK ), sleep_us, timeout_us); +if (err) { +dev_err (phy_drd->dev,"CRPORT handshake timeout1 (0x%08x)\n" , val);return -ETIME ; } - usec =100 ; + timeout_us =1000 ; + sleep_us =10 ;
The same.
Best regards,
Krzysztof
hi Krzysztof,
Quoted 24 lines · Krzysztof Kozlowski
Quoted 22 lines · Anand Moon
User
readl_poll_timeoutfunction instead of open
coded handling incrport_handshakefunction.Signed-off-by Anand Moon <[email protected]>--- drivers/phy/samsung/phy-exynos5-usbdrd.c | 37 +++++++++--------------- 1 file changed, 13 insertions(+), 24 deletions(-)drivers/phy/samsung/phy-exynos5-usbdrd.c +1
-0@@ -16,6 +16,7 @@#include <linux/of.h> #include <linux/of_address.h> #include <linux/of_device.h> +#include <linux/iopoll.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/mutex.h> @@ -556,40 +557,28 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy) static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd,
Quoted 9 lines
drivers/phy/samsung/phy-exynos5-usbdrd.c static int exynos5_usbdrd_phy_power_off(struct phy *phy) · line 561
Quoted 5 lines
drivers/phy/samsung/phy-exynos5-usbdrd.c +1
-1u32 val, u32 cmd) { -u32 usec =100 ; +u32 timeout_us =1000 , sleep_us =10 ;unsigned int result;You silently (without mentioning in commit msg and explaining why) changed both the sleep time and total timeout.
Ok I will stick with the original default value.
timeout_us = 100, sleep_us = 1;
Quoted 2 lines
Nope, please explain why you chosen such values and change them in separate patch..
I choose these values following Alim Akhtar's UFS PHY patches.
Quoted 23 lines
Quoted 23 lines
drivers/phy/samsung/phy-exynos5-usbdrd.c +5
-11+int err;writel (val | cmd, phy_drd->reg_phy +EXYNOS5_DRD_PHYREG0 ); -do { - result =readl (phy_drd->reg_phy +EXYNOS5_DRD_PHYREG1 ); -if (result &PHYREG1_CR_ACK ) -break ; - -udelay (1 ); - }while (usec-- >0 ); - -if (!usec) { -dev_err (phy_drd->dev, -"CRPORT handshake timeout1 (0x%08x)\n" , val); + err =readl_poll_timeout (phy_drd->reg_phy +EXYNOS5_DRD_PHYREG1 , + result, (result &PHYREG1_CR_ACK ), sleep_us, timeout_us); +if (err) { +dev_err (phy_drd->dev,"CRPORT handshake timeout1 (0x%08x)\n" , val);return -ETIME ; }
Quoted 9 lines
drivers/phy/samsung/phy-exynos5-usbdrd.c static int exynos5_usbdrd_phy_power_off(struct phy *phy) · line 574
Quoted 3 lines
drivers/phy/samsung/phy-exynos5-usbdrd.c +2
-1- usec =100 ; + timeout_us =1000 ; + sleep_us =10 ;The same.
Best regards,
Krzysztof
Best regards,
-Anand