All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: nop-phy: Enable reset-gpios support
@ 2021-12-22 14:04 Adam Ford
  2022-01-14 19:36 ` Tom Rini
  2022-01-15 12:38 ` Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Adam Ford @ 2021-12-22 14:04 UTC (permalink / raw)
  To: u-boot; +Cc: marex, Adam Ford

Some usb-nop-xceiv devices use a gpio to put them in and
out of reset.  Add a reset function to put them into that
state.  This is similar to how Linux handles the
usb-nop-xceiv driver.

Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/drivers/phy/nop-phy.c b/drivers/phy/nop-phy.c
index 9f12ebc062..be993a764f 100644
--- a/drivers/phy/nop-phy.c
+++ b/drivers/phy/nop-phy.c
@@ -10,11 +10,24 @@
 #include <dm/device.h>
 #include <dm/device_compat.h>
 #include <generic-phy.h>
+#include <asm-generic/gpio.h>
 
 struct nop_phy_priv {
 	struct clk_bulk bulk;
+	struct gpio_desc reset_gpio;
 };
 
+static int nop_phy_reset(struct phy *phy)
+{
+	struct nop_phy_priv *priv = dev_get_priv(phy->dev);
+
+	/* Return if there is no gpio since it's optional */
+	if (!dm_gpio_is_valid(&priv->reset_gpio))
+		return 0;
+
+	return dm_gpio_set_value(&priv->reset_gpio, false);
+}
+
 static int nop_phy_init(struct phy *phy)
 {
 	struct nop_phy_priv *priv = dev_get_priv(phy->dev);
@@ -22,7 +35,12 @@ static int nop_phy_init(struct phy *phy)
 	if (CONFIG_IS_ENABLED(CLK))
 		return clk_enable_bulk(&priv->bulk);
 
-	return 0;
+	/* Return if there is no gpio since it's optional */
+	if (!dm_gpio_is_valid(&priv->reset_gpio))
+		return 0;
+
+	/* If there is a reset gpio, take it out of reset */
+	return dm_gpio_set_value(&priv->reset_gpio, true);
 }
 
 static int nop_phy_probe(struct udevice *dev)
@@ -38,6 +56,12 @@ static int nop_phy_probe(struct udevice *dev)
 		}
 	}
 
+	ret = gpio_request_by_name(dev, "reset-gpios", 0,
+				   &priv->reset_gpio,
+				   GPIOD_IS_OUT);
+	if (ret != -ENOENT)
+		return ret;
+
 	return 0;
 }
 
@@ -49,6 +73,7 @@ static const struct udevice_id nop_phy_ids[] = {
 
 static struct phy_ops nop_phy_ops = {
 	.init = nop_phy_init,
+	.reset = nop_phy_reset,
 };
 
 U_BOOT_DRIVER(nop_phy) = {
-- 
2.32.0


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

* Re: [PATCH] phy: nop-phy: Enable reset-gpios support
  2021-12-22 14:04 [PATCH] phy: nop-phy: Enable reset-gpios support Adam Ford
@ 2022-01-14 19:36 ` Tom Rini
  2022-01-14 20:15   ` Adam Ford
  2022-01-15 12:38 ` Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Rini @ 2022-01-14 19:36 UTC (permalink / raw)
  To: Adam Ford; +Cc: u-boot, marex

[-- Attachment #1: Type: text/plain, Size: 2999 bytes --]

On Wed, Dec 22, 2021 at 08:04:30AM -0600, Adam Ford wrote:

> Some usb-nop-xceiv devices use a gpio to put them in and
> out of reset.  Add a reset function to put them into that
> state.  This is similar to how Linux handles the
> usb-nop-xceiv driver.
> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/drivers/phy/nop-phy.c b/drivers/phy/nop-phy.c
> index 9f12ebc062..be993a764f 100644
> --- a/drivers/phy/nop-phy.c
> +++ b/drivers/phy/nop-phy.c
> @@ -10,11 +10,24 @@
>  #include <dm/device.h>
>  #include <dm/device_compat.h>
>  #include <generic-phy.h>
> +#include <asm-generic/gpio.h>
>  
>  struct nop_phy_priv {
>  	struct clk_bulk bulk;
> +	struct gpio_desc reset_gpio;
>  };
>  
> +static int nop_phy_reset(struct phy *phy)
> +{
> +	struct nop_phy_priv *priv = dev_get_priv(phy->dev);
> +
> +	/* Return if there is no gpio since it's optional */
> +	if (!dm_gpio_is_valid(&priv->reset_gpio))
> +		return 0;
> +
> +	return dm_gpio_set_value(&priv->reset_gpio, false);
> +}
> +
>  static int nop_phy_init(struct phy *phy)
>  {
>  	struct nop_phy_priv *priv = dev_get_priv(phy->dev);
> @@ -22,7 +35,12 @@ static int nop_phy_init(struct phy *phy)
>  	if (CONFIG_IS_ENABLED(CLK))
>  		return clk_enable_bulk(&priv->bulk);
>  
> -	return 0;
> +	/* Return if there is no gpio since it's optional */
> +	if (!dm_gpio_is_valid(&priv->reset_gpio))
> +		return 0;
> +
> +	/* If there is a reset gpio, take it out of reset */
> +	return dm_gpio_set_value(&priv->reset_gpio, true);
>  }
>  
>  static int nop_phy_probe(struct udevice *dev)
> @@ -38,6 +56,12 @@ static int nop_phy_probe(struct udevice *dev)
>  		}
>  	}
>  
> +	ret = gpio_request_by_name(dev, "reset-gpios", 0,
> +				   &priv->reset_gpio,
> +				   GPIOD_IS_OUT);
> +	if (ret != -ENOENT)
> +		return ret;
> +
>  	return 0;
>  }
>  
> @@ -49,6 +73,7 @@ static const struct udevice_id nop_phy_ids[] = {
>  
>  static struct phy_ops nop_phy_ops = {
>  	.init = nop_phy_init,
> +	.reset = nop_phy_reset,
>  };
>  
>  U_BOOT_DRIVER(nop_phy) = {

This breaks:
k2e_evm k2e_hs_evm k2g_evm k2g_hs_evm k2hk_evm k2hk_hs_evm k2l_evm
k2l_hs_evm
with:
       arm:  +   k2g_hs_evm
+(k2g_hs_evm) arm-linux-gnueabi-ld.bfd: drivers/phy/nop-phy.o: in function `nop_phy_reset':
+(k2g_hs_evm) drivers/phy/nop-phy.c:28: undefined reference to `dm_gpio_set_value'
+(k2g_hs_evm) arm-linux-gnueabi-ld.bfd: drivers/phy/nop-phy.o: in function `nop_phy_init':
+(k2g_hs_evm) drivers/phy/nop-phy.c:43: undefined reference to `dm_gpio_set_value'
+(k2g_hs_evm) arm-linux-gnueabi-ld.bfd: drivers/phy/nop-phy.o: in function `nop_phy_probe':
+(k2g_hs_evm) drivers/phy/nop-phy.c:59: undefined reference to `gpio_request_by_name'
+(k2g_hs_evm) make[1]: *** [Makefile:1799: u-boot] Error 1
+(k2g_hs_evm) make: *** [Makefile:177: sub-make] Error 2

And yes, DM_GPIO is not set on these boards, so likely some of the
above needs to be #ifdef'd.  Thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH] phy: nop-phy: Enable reset-gpios support
  2022-01-14 19:36 ` Tom Rini
@ 2022-01-14 20:15   ` Adam Ford
  0 siblings, 0 replies; 4+ messages in thread
From: Adam Ford @ 2022-01-14 20:15 UTC (permalink / raw)
  To: Tom Rini; +Cc: U-Boot Mailing List, Marek Vasut

On Fri, Jan 14, 2022 at 1:36 PM Tom Rini <trini@konsulko.com> wrote:
>
> On Wed, Dec 22, 2021 at 08:04:30AM -0600, Adam Ford wrote:
>
> > Some usb-nop-xceiv devices use a gpio to put them in and
> > out of reset.  Add a reset function to put them into that
> > state.  This is similar to how Linux handles the
> > usb-nop-xceiv driver.
> >
> > Signed-off-by: Adam Ford <aford173@gmail.com>
> >
> > diff --git a/drivers/phy/nop-phy.c b/drivers/phy/nop-phy.c
> > index 9f12ebc062..be993a764f 100644
> > --- a/drivers/phy/nop-phy.c
> > +++ b/drivers/phy/nop-phy.c
> > @@ -10,11 +10,24 @@
> >  #include <dm/device.h>
> >  #include <dm/device_compat.h>
> >  #include <generic-phy.h>
> > +#include <asm-generic/gpio.h>
> >
> >  struct nop_phy_priv {
> >       struct clk_bulk bulk;
> > +     struct gpio_desc reset_gpio;
> >  };
> >
> > +static int nop_phy_reset(struct phy *phy)
> > +{
> > +     struct nop_phy_priv *priv = dev_get_priv(phy->dev);
> > +
> > +     /* Return if there is no gpio since it's optional */
> > +     if (!dm_gpio_is_valid(&priv->reset_gpio))
> > +             return 0;
> > +
> > +     return dm_gpio_set_value(&priv->reset_gpio, false);
> > +}
> > +
> >  static int nop_phy_init(struct phy *phy)
> >  {
> >       struct nop_phy_priv *priv = dev_get_priv(phy->dev);
> > @@ -22,7 +35,12 @@ static int nop_phy_init(struct phy *phy)
> >       if (CONFIG_IS_ENABLED(CLK))
> >               return clk_enable_bulk(&priv->bulk);
> >
> > -     return 0;
> > +     /* Return if there is no gpio since it's optional */
> > +     if (!dm_gpio_is_valid(&priv->reset_gpio))
> > +             return 0;
> > +
> > +     /* If there is a reset gpio, take it out of reset */
> > +     return dm_gpio_set_value(&priv->reset_gpio, true);
> >  }
> >
> >  static int nop_phy_probe(struct udevice *dev)
> > @@ -38,6 +56,12 @@ static int nop_phy_probe(struct udevice *dev)
> >               }
> >       }
> >
> > +     ret = gpio_request_by_name(dev, "reset-gpios", 0,
> > +                                &priv->reset_gpio,
> > +                                GPIOD_IS_OUT);
> > +     if (ret != -ENOENT)
> > +             return ret;
> > +
> >       return 0;
> >  }
> >
> > @@ -49,6 +73,7 @@ static const struct udevice_id nop_phy_ids[] = {
> >
> >  static struct phy_ops nop_phy_ops = {
> >       .init = nop_phy_init,
> > +     .reset = nop_phy_reset,
> >  };
> >
> >  U_BOOT_DRIVER(nop_phy) = {
>
> This breaks:
> k2e_evm k2e_hs_evm k2g_evm k2g_hs_evm k2hk_evm k2hk_hs_evm k2l_evm
> k2l_hs_evm
> with:
>        arm:  +   k2g_hs_evm
> +(k2g_hs_evm) arm-linux-gnueabi-ld.bfd: drivers/phy/nop-phy.o: in function `nop_phy_reset':
> +(k2g_hs_evm) drivers/phy/nop-phy.c:28: undefined reference to `dm_gpio_set_value'
> +(k2g_hs_evm) arm-linux-gnueabi-ld.bfd: drivers/phy/nop-phy.o: in function `nop_phy_init':
> +(k2g_hs_evm) drivers/phy/nop-phy.c:43: undefined reference to `dm_gpio_set_value'
> +(k2g_hs_evm) arm-linux-gnueabi-ld.bfd: drivers/phy/nop-phy.o: in function `nop_phy_probe':
> +(k2g_hs_evm) drivers/phy/nop-phy.c:59: undefined reference to `gpio_request_by_name'
> +(k2g_hs_evm) make[1]: *** [Makefile:1799: u-boot] Error 1
> +(k2g_hs_evm) make: *** [Makefile:177: sub-make] Error 2
>
> And yes, DM_GPIO is not set on these boards, so likely some of the
> above needs to be #ifdef'd.  Thanks!


I'll do a V2 with the new functions encapsulated with an ifdef so it
hopefully won't break boards.

adam
>
> --
> Tom

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

* Re: [PATCH] phy: nop-phy: Enable reset-gpios support
  2021-12-22 14:04 [PATCH] phy: nop-phy: Enable reset-gpios support Adam Ford
  2022-01-14 19:36 ` Tom Rini
@ 2022-01-15 12:38 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2022-01-15 12:38 UTC (permalink / raw)
  To: Adam Ford; +Cc: u-boot, marex

[-- Attachment #1: Type: text/plain, Size: 467 bytes --]

On Wed, Dec 22, 2021 at 08:04:30AM -0600, Adam Ford wrote:

> Some usb-nop-xceiv devices use a gpio to put them in and
> out of reset.  Add a reset function to put them into that
> state.  This is similar to how Linux handles the
> usb-nop-xceiv driver.
> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/drivers/phy/nop-phy.c b/drivers/phy/nop-phy.c
> index 9f12ebc062..be993a764f 100644

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2022-01-15 12:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22 14:04 [PATCH] phy: nop-phy: Enable reset-gpios support Adam Ford
2022-01-14 19:36 ` Tom Rini
2022-01-14 20:15   ` Adam Ford
2022-01-15 12:38 ` Tom Rini

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.