phy: nop-phy: Enable reset-gpios support
PATCH 1/1 phy: nop-phy: Enable reset-gpios support
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.
drivers/phy/nop-phy.c +26 -1
@@ -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) = {
Signature · 1 line
2.32.0
Quoted 64 lines · 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 <[email protected]>drivers/phy/nop-phy.c +25
-1@@ -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 ; }
drivers/phy/nop-phy.c static const struct udevice_id nop_phy_ids[] = { · line 79
Quoted 7 lines
drivers/phy/nop-phy.c +1
-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!
Signature · 1 line
Tom
Quoted 89 lines · Tom Rini
Quoted 64 lines · 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 <[email protected]>drivers/phy/nop-phy.c +25
-1@@ -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 ; }drivers/phy/nop-phy.c static const struct udevice_id nop_phy_ids[] = { · line 79
Quoted 7 lines
drivers/phy/nop-phy.c +1
-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_evmk2e_hs_evmk2g_evmk2g_hs_evmk2hk_evmk2hk_hs_evmk2l_evmk2l_hs_evm
with:
arm: +k2g_hs_evm(quoted diff) +8
-0+(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
Quoted 2 lines
And yes,
DM_GPIOis 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
Quoted 3 lines
--
Tom
drivers/phy/nop-phy.c
Quoted 9 lines · 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 <[email protected]>drivers/phy/nop-phy.c +0
-0
Applied to u-boot/master, thanks!
Signature · 1 line
Tom