* [PATCH 0/2] phy: amlogic: meson8b-usb2: two small cleanup patches
@ 2024-12-31 19:17 Martin Blumenstingl
2024-12-31 19:17 ` [PATCH 1/2] phy: amlogic: meson8b-usb2: Use FIELD_PREP instead of _SHIFT macros Martin Blumenstingl
2024-12-31 19:17 ` [PATCH 2/2] phy: amlogic: meson8b-usb2: Use the regmap_{clear,set}_bits helpers Martin Blumenstingl
0 siblings, 2 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2024-12-31 19:17 UTC (permalink / raw)
To: linux-amlogic, linux-phy
Cc: linux-arm-kernel, linux-kernel, vkoul, kishon, Martin Blumenstingl
Hello,
this series includes two small cleanups for the phy-meson8b-usb2
driver. There are no functional changes.
Martin Blumenstingl (2):
phy: amlogic: meson8b-usb2: Use FIELD_PREP instead of _SHIFT macros
phy: amlogic: meson8b-usb2: Use the regmap_{clear,set}_bits helpers
drivers/phy/amlogic/phy-meson8b-usb2.c | 35 +++++++++++---------------
1 file changed, 14 insertions(+), 21 deletions(-)
--
2.47.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] phy: amlogic: meson8b-usb2: Use FIELD_PREP instead of _SHIFT macros
2024-12-31 19:17 [PATCH 0/2] phy: amlogic: meson8b-usb2: two small cleanup patches Martin Blumenstingl
@ 2024-12-31 19:17 ` Martin Blumenstingl
2025-01-02 9:40 ` neil.armstrong
2024-12-31 19:17 ` [PATCH 2/2] phy: amlogic: meson8b-usb2: Use the regmap_{clear,set}_bits helpers Martin Blumenstingl
1 sibling, 1 reply; 5+ messages in thread
From: Martin Blumenstingl @ 2024-12-31 19:17 UTC (permalink / raw)
To: linux-amlogic, linux-phy
Cc: linux-arm-kernel, linux-kernel, vkoul, kishon, Martin Blumenstingl
This simplifies the code by re-using the FIELD_PREP helper. No
functional changes inteded.
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
drivers/phy/amlogic/phy-meson8b-usb2.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
index d63147c41b8c..d9c761b7c15c 100644
--- a/drivers/phy/amlogic/phy-meson8b-usb2.c
+++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
@@ -5,6 +5,7 @@
* Copyright (C) 2016 Martin Blumenstingl <martin.blumenstingl@googlemail.com>
*/
+#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/io.h>
@@ -39,9 +40,7 @@
#define REG_CTRL_TX_BITSTUFF_ENN BIT(18)
#define REG_CTRL_COMMON_ON BIT(19)
#define REG_CTRL_REF_CLK_SEL_MASK GENMASK(21, 20)
- #define REG_CTRL_REF_CLK_SEL_SHIFT 20
#define REG_CTRL_FSEL_MASK GENMASK(24, 22)
- #define REG_CTRL_FSEL_SHIFT 22
#define REG_CTRL_PORT_RESET BIT(25)
#define REG_CTRL_THREAD_ID_MASK GENMASK(31, 26)
@@ -170,10 +169,10 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
REG_CONFIG_CLK_32k_ALTSEL);
regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_REF_CLK_SEL_MASK,
- 0x2 << REG_CTRL_REF_CLK_SEL_SHIFT);
+ FIELD_PREP(REG_CTRL_REF_CLK_SEL_MASK, 0x2));
regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_FSEL_MASK,
- 0x5 << REG_CTRL_FSEL_SHIFT);
+ FIELD_PREP(REG_CTRL_FSEL_MASK, 0x5));
/* reset the PHY */
regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET,
--
2.47.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] phy: amlogic: meson8b-usb2: Use the regmap_{clear,set}_bits helpers
2024-12-31 19:17 [PATCH 0/2] phy: amlogic: meson8b-usb2: two small cleanup patches Martin Blumenstingl
2024-12-31 19:17 ` [PATCH 1/2] phy: amlogic: meson8b-usb2: Use FIELD_PREP instead of _SHIFT macros Martin Blumenstingl
@ 2024-12-31 19:17 ` Martin Blumenstingl
2025-01-02 9:41 ` neil.armstrong
1 sibling, 1 reply; 5+ messages in thread
From: Martin Blumenstingl @ 2024-12-31 19:17 UTC (permalink / raw)
To: linux-amlogic, linux-phy
Cc: linux-arm-kernel, linux-kernel, vkoul, kishon, Martin Blumenstingl
These require less code, reduce the chance of typos and overall make the
intent clearer. No functional changes.
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
drivers/phy/amlogic/phy-meson8b-usb2.c | 28 ++++++++++----------------
1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
index d9c761b7c15c..a553231a9f7c 100644
--- a/drivers/phy/amlogic/phy-meson8b-usb2.c
+++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
@@ -165,8 +165,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
return ret;
}
- regmap_update_bits(priv->regmap, REG_CONFIG, REG_CONFIG_CLK_32k_ALTSEL,
- REG_CONFIG_CLK_32k_ALTSEL);
+ regmap_set_bits(priv->regmap, REG_CONFIG, REG_CONFIG_CLK_32k_ALTSEL);
regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_REF_CLK_SEL_MASK,
FIELD_PREP(REG_CTRL_REF_CLK_SEL_MASK, 0x2));
@@ -175,23 +174,20 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
FIELD_PREP(REG_CTRL_FSEL_MASK, 0x5));
/* reset the PHY */
- regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET,
- REG_CTRL_POWER_ON_RESET);
+ regmap_set_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET);
udelay(RESET_COMPLETE_TIME);
- regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET, 0);
+ regmap_clear_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET);
udelay(RESET_COMPLETE_TIME);
- regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_SOF_TOGGLE_OUT,
- REG_CTRL_SOF_TOGGLE_OUT);
+ regmap_set_bits(priv->regmap, REG_CTRL, REG_CTRL_SOF_TOGGLE_OUT);
if (priv->dr_mode == USB_DR_MODE_HOST) {
- regmap_update_bits(priv->regmap, REG_DBG_UART,
- REG_DBG_UART_SET_IDDQ, 0);
+ regmap_clear_bits(priv->regmap, REG_DBG_UART,
+ REG_DBG_UART_SET_IDDQ);
if (priv->match->host_enable_aca) {
- regmap_update_bits(priv->regmap, REG_ADP_BC,
- REG_ADP_BC_ACA_ENABLE,
- REG_ADP_BC_ACA_ENABLE);
+ regmap_set_bits(priv->regmap, REG_ADP_BC,
+ REG_ADP_BC_ACA_ENABLE);
udelay(ACA_ENABLE_COMPLETE_TIME);
@@ -214,17 +210,15 @@ static int phy_meson8b_usb2_power_off(struct phy *phy)
struct phy_meson8b_usb2_priv *priv = phy_get_drvdata(phy);
if (priv->dr_mode == USB_DR_MODE_HOST)
- regmap_update_bits(priv->regmap, REG_DBG_UART,
- REG_DBG_UART_SET_IDDQ,
- REG_DBG_UART_SET_IDDQ);
+ regmap_set_bits(priv->regmap, REG_DBG_UART,
+ REG_DBG_UART_SET_IDDQ);
clk_disable_unprepare(priv->clk_usb);
clk_disable_unprepare(priv->clk_usb_general);
reset_control_rearm(priv->reset);
/* power off the PHY by putting it into reset mode */
- regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET,
- REG_CTRL_POWER_ON_RESET);
+ regmap_set_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET);
return 0;
}
--
2.47.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] phy: amlogic: meson8b-usb2: Use FIELD_PREP instead of _SHIFT macros
2024-12-31 19:17 ` [PATCH 1/2] phy: amlogic: meson8b-usb2: Use FIELD_PREP instead of _SHIFT macros Martin Blumenstingl
@ 2025-01-02 9:40 ` neil.armstrong
0 siblings, 0 replies; 5+ messages in thread
From: neil.armstrong @ 2025-01-02 9:40 UTC (permalink / raw)
To: Martin Blumenstingl, linux-amlogic, linux-phy
Cc: linux-arm-kernel, linux-kernel, vkoul, kishon
On 31/12/2024 20:17, Martin Blumenstingl wrote:
> This simplifies the code by re-using the FIELD_PREP helper. No
> functional changes inteded.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> drivers/phy/amlogic/phy-meson8b-usb2.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
> index d63147c41b8c..d9c761b7c15c 100644
> --- a/drivers/phy/amlogic/phy-meson8b-usb2.c
> +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
> @@ -5,6 +5,7 @@
> * Copyright (C) 2016 Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> */
>
> +#include <linux/bitfield.h>
> #include <linux/clk.h>
> #include <linux/delay.h>
> #include <linux/io.h>
> @@ -39,9 +40,7 @@
> #define REG_CTRL_TX_BITSTUFF_ENN BIT(18)
> #define REG_CTRL_COMMON_ON BIT(19)
> #define REG_CTRL_REF_CLK_SEL_MASK GENMASK(21, 20)
> - #define REG_CTRL_REF_CLK_SEL_SHIFT 20
> #define REG_CTRL_FSEL_MASK GENMASK(24, 22)
> - #define REG_CTRL_FSEL_SHIFT 22
> #define REG_CTRL_PORT_RESET BIT(25)
> #define REG_CTRL_THREAD_ID_MASK GENMASK(31, 26)
>
> @@ -170,10 +169,10 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
> REG_CONFIG_CLK_32k_ALTSEL);
>
> regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_REF_CLK_SEL_MASK,
> - 0x2 << REG_CTRL_REF_CLK_SEL_SHIFT);
> + FIELD_PREP(REG_CTRL_REF_CLK_SEL_MASK, 0x2));
>
> regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_FSEL_MASK,
> - 0x5 << REG_CTRL_FSEL_SHIFT);
> + FIELD_PREP(REG_CTRL_FSEL_MASK, 0x5));
>
> /* reset the PHY */
> regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET,
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] phy: amlogic: meson8b-usb2: Use the regmap_{clear,set}_bits helpers
2024-12-31 19:17 ` [PATCH 2/2] phy: amlogic: meson8b-usb2: Use the regmap_{clear,set}_bits helpers Martin Blumenstingl
@ 2025-01-02 9:41 ` neil.armstrong
0 siblings, 0 replies; 5+ messages in thread
From: neil.armstrong @ 2025-01-02 9:41 UTC (permalink / raw)
To: Martin Blumenstingl, linux-amlogic, linux-phy
Cc: linux-arm-kernel, linux-kernel, vkoul, kishon
On 31/12/2024 20:17, Martin Blumenstingl wrote:
> These require less code, reduce the chance of typos and overall make the
> intent clearer. No functional changes.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> drivers/phy/amlogic/phy-meson8b-usb2.c | 28 ++++++++++----------------
> 1 file changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
> index d9c761b7c15c..a553231a9f7c 100644
> --- a/drivers/phy/amlogic/phy-meson8b-usb2.c
> +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
> @@ -165,8 +165,7 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
> return ret;
> }
>
> - regmap_update_bits(priv->regmap, REG_CONFIG, REG_CONFIG_CLK_32k_ALTSEL,
> - REG_CONFIG_CLK_32k_ALTSEL);
> + regmap_set_bits(priv->regmap, REG_CONFIG, REG_CONFIG_CLK_32k_ALTSEL);
>
> regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_REF_CLK_SEL_MASK,
> FIELD_PREP(REG_CTRL_REF_CLK_SEL_MASK, 0x2));
> @@ -175,23 +174,20 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
> FIELD_PREP(REG_CTRL_FSEL_MASK, 0x5));
>
> /* reset the PHY */
> - regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET,
> - REG_CTRL_POWER_ON_RESET);
> + regmap_set_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET);
> udelay(RESET_COMPLETE_TIME);
> - regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET, 0);
> + regmap_clear_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET);
> udelay(RESET_COMPLETE_TIME);
>
> - regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_SOF_TOGGLE_OUT,
> - REG_CTRL_SOF_TOGGLE_OUT);
> + regmap_set_bits(priv->regmap, REG_CTRL, REG_CTRL_SOF_TOGGLE_OUT);
>
> if (priv->dr_mode == USB_DR_MODE_HOST) {
> - regmap_update_bits(priv->regmap, REG_DBG_UART,
> - REG_DBG_UART_SET_IDDQ, 0);
> + regmap_clear_bits(priv->regmap, REG_DBG_UART,
> + REG_DBG_UART_SET_IDDQ);
>
> if (priv->match->host_enable_aca) {
> - regmap_update_bits(priv->regmap, REG_ADP_BC,
> - REG_ADP_BC_ACA_ENABLE,
> - REG_ADP_BC_ACA_ENABLE);
> + regmap_set_bits(priv->regmap, REG_ADP_BC,
> + REG_ADP_BC_ACA_ENABLE);
>
> udelay(ACA_ENABLE_COMPLETE_TIME);
>
> @@ -214,17 +210,15 @@ static int phy_meson8b_usb2_power_off(struct phy *phy)
> struct phy_meson8b_usb2_priv *priv = phy_get_drvdata(phy);
>
> if (priv->dr_mode == USB_DR_MODE_HOST)
> - regmap_update_bits(priv->regmap, REG_DBG_UART,
> - REG_DBG_UART_SET_IDDQ,
> - REG_DBG_UART_SET_IDDQ);
> + regmap_set_bits(priv->regmap, REG_DBG_UART,
> + REG_DBG_UART_SET_IDDQ);
>
> clk_disable_unprepare(priv->clk_usb);
> clk_disable_unprepare(priv->clk_usb_general);
> reset_control_rearm(priv->reset);
>
> /* power off the PHY by putting it into reset mode */
> - regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET,
> - REG_CTRL_POWER_ON_RESET);
> + regmap_set_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET);
>
> return 0;
> }
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-01-02 9:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-31 19:17 [PATCH 0/2] phy: amlogic: meson8b-usb2: two small cleanup patches Martin Blumenstingl
2024-12-31 19:17 ` [PATCH 1/2] phy: amlogic: meson8b-usb2: Use FIELD_PREP instead of _SHIFT macros Martin Blumenstingl
2025-01-02 9:40 ` neil.armstrong
2024-12-31 19:17 ` [PATCH 2/2] phy: amlogic: meson8b-usb2: Use the regmap_{clear,set}_bits helpers Martin Blumenstingl
2025-01-02 9:41 ` neil.armstrong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®