[PATCH] phy: nop-phy: Enable reset-gpios support

Tom Rini trini at konsulko.com
Fri Jan 14 20:36:38 CET 2022


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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20220114/be4f904b/attachment.sig>


More information about the U-Boot mailing list