diff mbox series

[2/6] ARM: kirkwood: SBx81LIFKW: update for DM_GPIO

Message ID 20220804090629.75183-3-judge.packham@gmail.com
State Accepted
Commit 923d0a899344350ad3e1f53f95b3f9aa85307b2e
Delegated to: Stefan Roese
Headers show
Series SBx81LIFKW/SBx81LIFXCAT disable KIRKWOOD_GPIO | expand

Commit Message

Chris Packham Aug. 4, 2022, 9:06 a.m. UTC
Update mv88e61xx_hw_reset() to use the DM_GPIO API to toggle the reset
line for the linkstreet switch.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---

 board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

Comments

Stefan Roese Aug. 5, 2022, 10:47 a.m. UTC | #1
On 04.08.22 11:06, Chris Packham wrote:
> Update mv88e61xx_hw_reset() to use the DM_GPIO API to toggle the reset
> line for the linkstreet switch.
> 
> Signed-off-by: Chris Packham <judge.packham@gmail.com>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
> 
>   board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c | 21 ++++++++++++++++-----
>   1 file changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c b/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
> index feb8b6b83f00..e0a7f3fa89f0 100644
> --- a/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
> +++ b/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
> @@ -17,7 +17,8 @@
>   #include <asm/arch/cpu.h>
>   #include <asm/arch/soc.h>
>   #include <asm/arch/mpp.h>
> -#include <asm/arch/gpio.h>
> +#include <asm-generic/gpio.h>
> +#include <dm.h>
>   
>   /* Note: GPIO differences between specific boards
>    *
> @@ -37,8 +38,6 @@
>   #define SBX81LIFKW_OE_VAL_LOW	 (BIT(31) | BIT(30) | BIT(28) | BIT(27))
>   #define SBX81LIFKW_OE_VAL_HIGH	 (BIT(0) | BIT(1))
>   
> -#define MV88E6097_RESET		27
> -
>   DECLARE_GLOBAL_DATA_PTR;
>   
>   int board_early_init_f(void)
> @@ -143,11 +142,23 @@ void reset_phy(void)
>   #ifdef CONFIG_MV88E61XX_SWITCH
>   int mv88e61xx_hw_reset(struct phy_device *phydev)
>   {
> +	struct gpio_desc desc;
> +	int ret;
> +
> +	ret = dm_gpio_lookup_name("mvebu0_27", &desc);
> +	if (ret)
> +		return ret;
> +
> +	ret = dm_gpio_request(&desc, "linkstreet_rst");
> +	if (ret)
> +		return ret;
> +
>   	/* Ensure the 88e6097 gets at least 10ms Reset
>   	 */
> -	kw_gpio_set_value(MV88E6097_RESET, 0);
> +	dm_gpio_set_dir_flags(&desc, GPIOD_IS_OUT);
> +	dm_gpio_set_value(&desc, 0);
>   	mdelay(20);
> -	kw_gpio_set_value(MV88E6097_RESET, 1);
> +	dm_gpio_set_value(&desc, 1);
>   	mdelay(20);
>   
>   	phydev->advertising = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full;

Viele Grüße,
Stefan Roese
diff mbox series

Patch

diff --git a/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c b/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
index feb8b6b83f00..e0a7f3fa89f0 100644
--- a/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
+++ b/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
@@ -17,7 +17,8 @@ 
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
-#include <asm/arch/gpio.h>
+#include <asm-generic/gpio.h>
+#include <dm.h>
 
 /* Note: GPIO differences between specific boards
  *
@@ -37,8 +38,6 @@ 
 #define SBX81LIFKW_OE_VAL_LOW	 (BIT(31) | BIT(30) | BIT(28) | BIT(27))
 #define SBX81LIFKW_OE_VAL_HIGH	 (BIT(0) | BIT(1))
 
-#define MV88E6097_RESET		27
-
 DECLARE_GLOBAL_DATA_PTR;
 
 int board_early_init_f(void)
@@ -143,11 +142,23 @@  void reset_phy(void)
 #ifdef CONFIG_MV88E61XX_SWITCH
 int mv88e61xx_hw_reset(struct phy_device *phydev)
 {
+	struct gpio_desc desc;
+	int ret;
+
+	ret = dm_gpio_lookup_name("mvebu0_27", &desc);
+	if (ret)
+		return ret;
+
+	ret = dm_gpio_request(&desc, "linkstreet_rst");
+	if (ret)
+		return ret;
+
 	/* Ensure the 88e6097 gets at least 10ms Reset
 	 */
-	kw_gpio_set_value(MV88E6097_RESET, 0);
+	dm_gpio_set_dir_flags(&desc, GPIOD_IS_OUT);
+	dm_gpio_set_value(&desc, 0);
 	mdelay(20);
-	kw_gpio_set_value(MV88E6097_RESET, 1);
+	dm_gpio_set_value(&desc, 1);
 	mdelay(20);
 
 	phydev->advertising = ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full;