summaryrefslogtreecommitdiff
path: root/drivers/phy/nop-phy.c
diff options
context:
space:
mode:
authorAdam Ford <aford173@gmail.com>2022-01-29 16:27:47 +0300
committerTom Rini <trini@konsulko.com>2022-02-11 19:29:23 +0300
commit3970c82a60857b72afcb676697caf9c979dab946 (patch)
tree72ec1fdc61954af03dc1710374785f3931f763bb /drivers/phy/nop-phy.c
parent07c79dd5fdeaefb39c9e7a97f3b66de63109a18d (diff)
downloadu-boot-3970c82a60857b72afcb676697caf9c979dab946.tar.xz
phy: nop-phy: Enable reset-gpios support
Some usb-nop-xceiv devices use a gpio take them 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>
Diffstat (limited to 'drivers/phy/nop-phy.c')
-rw-r--r--drivers/phy/nop-phy.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/drivers/phy/nop-phy.c b/drivers/phy/nop-phy.c
index 9f12ebc062..b08eedd4d4 100644
--- a/drivers/phy/nop-phy.c
+++ b/drivers/phy/nop-phy.c
@@ -10,25 +10,54 @@
#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))
- return clk_enable_bulk(&priv->bulk);
+ if (CONFIG_IS_ENABLED(CLK)) {
+ ret = clk_enable_bulk(&priv->bulk);
+ if (ret)
+ return ret;
+ }
+#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;
+ }
+#endif
return 0;
}
static int nop_phy_probe(struct udevice *dev)
{
struct nop_phy_priv *priv = dev_get_priv(dev);
- int ret;
+ int ret = 0;
if (CONFIG_IS_ENABLED(CLK)) {
ret = clk_get_bulk(dev, &priv->bulk);
@@ -37,6 +66,13 @@ static int nop_phy_probe(struct udevice *dev)
return ret;
}
}
+#if CONFIG_IS_ENABLED(DM_GPIO)
+ ret = gpio_request_by_name(dev, "reset-gpios", 0,
+ &priv->reset_gpio,
+ GPIOD_IS_OUT);
+#endif
+ if (ret != -ENOENT)
+ return ret;
return 0;
}
@@ -49,6 +85,9 @@ static const struct udevice_id nop_phy_ids[] = {
static struct phy_ops nop_phy_ops = {
.init = nop_phy_init,
+#if CONFIG_IS_ENABLED(DM_GPIO)
+ .reset = nop_phy_reset,
+#endif
};
U_BOOT_DRIVER(nop_phy) = {