All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Ford <aford173@gmail.com>
To: u-boot@lists.denx.de
Cc: lokeshvutla@ti.com, marex@denx.de, sjg@chromium.org,
	woods.technical@gmail.com, Adam Ford <aford173@gmail.com>
Subject: [RFC 2/3] phy: nop-phy: Enable reset-gpios support
Date: Sun,  3 Oct 2021 19:24:06 -0500	[thread overview]
Message-ID: <20211004002407.464910-2-aford173@gmail.com> (raw)
In-Reply-To: <20211004002407.464910-1-aford173@gmail.com>

Some usb-nop-xceiv devices use a gpio to put them
in reset.  Add a reset function to put them into that
state, and have the init function take them out of reset

Signed-off-by: Adam Ford <aford173@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) = {
-- 
2.25.1


  reply	other threads:[~2021-10-04  0:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04  0:24 [RFC 1/3] usb: ehci-omap: Remove dead code Adam Ford
2021-10-04  0:24 ` Adam Ford [this message]
2021-10-04  0:24 ` [RFC 3/3] usb: ehci-omap: Enable phy drivers to enable/reset phy Adam Ford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211004002407.464910-2-aford173@gmail.com \
    --to=aford173@gmail.com \
    --cc=lokeshvutla@ti.com \
    --cc=marex@denx.de \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=woods.technical@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.