diff options
author | Adam Ford <aford173@gmail.com> | 2022-01-17 17:45:59 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-01-21 15:12:29 -0500 |
commit | 43415520026cc91cf3cd89d5d1604d1b4003abf9 (patch) | |
tree | f781c269fec5675f8e66b7084cb4671e3e9d52bd | |
parent | f8d6b788a9e88802c84f24ae2c51125ef81a4aec (diff) | |
download | u-boot-WIP/2022-01-21-assorted-fixes-and-updates.zip u-boot-WIP/2022-01-21-assorted-fixes-and-updates.tar.gz u-boot-WIP/2022-01-21-assorted-fixes-and-updates.tar.bz2 |
phy: nop-phy: Enable reset-gpios supportWIP/2022-01-21-assorted-fixes-and-updates
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>
-rw-r--r-- | drivers/phy/nop-phy.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/drivers/phy/nop-phy.c b/drivers/phy/nop-phy.c index 9f12ebc..2be3d40 100644 --- a/drivers/phy/nop-phy.c +++ b/drivers/phy/nop-phy.c @@ -10,17 +10,47 @@ #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; +#if CONFIG_IS_ENABLED(DM_GPIO) + struct gpio_desc reset_gpio; +#endif }; +#if CONFIG_IS_ENABLED(DM_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); +} +#endif + static int nop_phy_init(struct phy *phy) { struct nop_phy_priv *priv = dev_get_priv(phy->dev); + int ret = 0; + + if (CONFIG_IS_ENABLED(CLK)) { + ret = clk_enable_bulk(&priv->bulk); + if (ret) + return ret; + } - if (CONFIG_IS_ENABLED(CLK)) - return clk_enable_bulk(&priv->bulk); + if (CONFIG_IS_ENABLED(DM_GPIO)) { + ret = nop_phy_reset(phy); + if (ret) { + if (CONFIG_IS_ENABLED(CLK)) + clk_disable_bulk(&priv->bulk); + return ret; + } + } return 0; } @@ -38,6 +68,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 +85,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) = { |