* [PATCH V2] phy: nop-phy: Enable reset-gpios support
@ 2022-01-17 23:45 Adam Ford
2022-01-21 21:18 ` Tom Rini
0 siblings, 1 reply; 3+ messages in thread
From: Adam Ford @ 2022-01-17 23:45 UTC (permalink / raw)
To: u-boot; +Cc: marex, trini, aford, 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>
---
V2: Only use the GPIO functions when DM_GPIO is enabled
Add error handling so if the GPIO fails, it will shutdown
the clocks and return with the error code.
Call nop_phy_reset() instead of repeating the same code.
diff --git a/drivers/phy/nop-phy.c b/drivers/phy/nop-phy.c
index 9f12ebc062..2be3d4039b 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) = {
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2] phy: nop-phy: Enable reset-gpios support
2022-01-17 23:45 [PATCH V2] phy: nop-phy: Enable reset-gpios support Adam Ford
@ 2022-01-21 21:18 ` Tom Rini
2022-01-22 17:47 ` Adam Ford
0 siblings, 1 reply; 3+ messages in thread
From: Tom Rini @ 2022-01-21 21:18 UTC (permalink / raw)
To: Adam Ford; +Cc: u-boot, marex, aford
[-- Attachment #1: Type: text/plain, Size: 773 bytes --]
On Mon, Jan 17, 2022 at 05:45:59PM -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>
> ---
> V2: Only use the GPIO functions when DM_GPIO is enabled
> Add error handling so if the GPIO fails, it will shutdown
> the clocks and return with the error code.
> Call nop_phy_reset() instead of repeating the same code.
drivers/phy/nop-phy.c:47:23: error: implicit declaration of function
'nop_phy_reset'; did you mean 'nop_phy_init'?
[-Werror=implicit-function-declaration]
is what I get now on those platforms.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V2] phy: nop-phy: Enable reset-gpios support
2022-01-21 21:18 ` Tom Rini
@ 2022-01-22 17:47 ` Adam Ford
0 siblings, 0 replies; 3+ messages in thread
From: Adam Ford @ 2022-01-22 17:47 UTC (permalink / raw)
To: Tom Rini; +Cc: U-Boot Mailing List, Marek Vasut, Adam Ford-BE
On Fri, Jan 21, 2022 at 3:18 PM Tom Rini <trini@konsulko.com> wrote:
>
> On Mon, Jan 17, 2022 at 05:45:59PM -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>
> > ---
> > V2: Only use the GPIO functions when DM_GPIO is enabled
> > Add error handling so if the GPIO fails, it will shutdown
> > the clocks and return with the error code.
> > Call nop_phy_reset() instead of repeating the same code.
>
> drivers/phy/nop-phy.c:47:23: error: implicit declaration of function
> 'nop_phy_reset'; did you mean 'nop_phy_init'?
> [-Werror=implicit-function-declaration]
> is what I get now on those platforms.
I apparently forgot to encapsulate the nop_phy_ops reference to the
new function in an if-def. I'll send a V3 shortly.
adam
>
> --
> Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-22 17:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17 23:45 [PATCH V2] phy: nop-phy: Enable reset-gpios support Adam Ford
2022-01-21 21:18 ` Tom Rini
2022-01-22 17:47 ` Adam Ford
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.