All of lore.kernel.org
 help / color / mirror / Atom feed
From: patrice.chotard at st.com <patrice.chotard@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v5 08/11] usb: host: ehci-generic: add generic PHY support
Date: Thu, 1 Jun 2017 13:36:19 +0200	[thread overview]
Message-ID: <1496316982-16572-9-git-send-email-patrice.chotard@st.com> (raw)
In-Reply-To: <1496316982-16572-1-git-send-email-patrice.chotard@st.com>

From: Patrice Chotard <patrice.chotard@st.com>

Extend ehci-generic driver with generic PHY framework

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
v5: 	_ none

v4:     _ use generic_phy_valid() before generic_phy_exit() call

v3:     _ test return value on generic_phy_get_by_index() and
          generic_phy_init()
 drivers/usb/host/ehci-generic.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 1250d59..2b8f342 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -6,6 +6,8 @@
 
 #include <common.h>
 #include <clk.h>
+#include <fdtdec.h>
+#include <generic-phy.h>
 #include <reset.h>
 #include <asm/io.h>
 #include <dm.h>
@@ -20,6 +22,7 @@ struct generic_ehci {
 	struct ehci_ctrl ctrl;
 	struct clk *clocks;
 	struct reset_ctl *resets;
+	struct phy phy;
 	int clock_count;
 	int reset_count;
 };
@@ -87,6 +90,21 @@ static int ehci_usb_probe(struct udevice *dev)
 			reset_free(&priv->resets[i]);
 		}
 	}
+
+	err = generic_phy_get_by_index(dev, 0, &priv->phy);
+	if (err) {
+		if (err != -ENOENT) {
+			error("failed to get usb phy\n");
+			goto reset_err;
+		}
+	} else {
+		err = generic_phy_init(&priv->phy);
+		if (err) {
+			error("failed to init usb phy\n");
+			goto reset_err;
+		}
+	}
+
 	hccr = map_physmem(devfdt_get_addr(dev), 0x100, MAP_NOCACHE);
 	hcor = (struct ehci_hcor *)((uintptr_t)hccr +
 				    HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
@@ -95,6 +113,12 @@ static int ehci_usb_probe(struct udevice *dev)
 	if (!err)
 		return err;
 
+	if (generic_phy_valid(&priv->phy)) {
+		ret = generic_phy_exit(&priv->phy);
+		if (ret)
+			return ret;
+	}
+
 reset_err:
 	ret = reset_assert_all(priv->resets, priv->reset_count);
 	if (ret)
@@ -116,6 +140,12 @@ static int ehci_usb_remove(struct udevice *dev)
 	if (ret)
 		return ret;
 
+	if (generic_phy_valid(&priv->phy)) {
+		ret = generic_phy_exit(&priv->phy);
+		if (ret)
+			return ret;
+	}
+
 	ret =  reset_assert_all(priv->resets, priv->reset_count);
 	if (ret)
 		return ret;
-- 
1.9.1

  parent reply	other threads:[~2017-06-01 11:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01 11:36 [U-Boot] [PATCH v5 00/11] usb: Extend ehci and ohci generic drivers patrice.chotard at st.com
2017-06-01 11:36 ` [U-Boot] [PATCH v5 01/11] reset: add reset_request() patrice.chotard at st.com
2017-06-01 11:36 ` [U-Boot] [PATCH v5 02/11] reset: add reset_count() patrice.chotard at st.com
2017-06-02  2:56   ` Simon Glass
2017-06-03  6:02   ` Marek Vasut
2017-06-05  9:34     ` Patrice CHOTARD
2017-06-05 11:18       ` Marek Vasut
2017-06-06 21:08         ` Simon Glass
2017-06-12  7:27           ` Patrice CHOTARD
2017-06-12  7:51             ` Patrice CHOTARD
2017-06-12 23:51               ` Simon Glass
2017-06-12  7:52             ` Patrice CHOTARD
2017-06-01 11:36 ` [U-Boot] [PATCH v5 03/11] reset: add reset_assert_all() patrice.chotard at st.com
2017-06-01 11:36 ` [U-Boot] [PATCH v5 04/11] clk: add clk_count() patrice.chotard at st.com
2017-06-02  2:56   ` Simon Glass
2017-06-01 11:36 ` [U-Boot] [PATCH v5 05/11] clk: add clk_disable_all() patrice.chotard at st.com
2017-06-02  2:56   ` Simon Glass
2017-06-01 11:36 ` [U-Boot] [PATCH v5 06/11] usb: host: ehci-generic: replace printf() by error() patrice.chotard at st.com
2017-06-01 11:36 ` [U-Boot] [PATCH v5 07/11] usb: host: ehci-generic: add error path and .remove callback patrice.chotard at st.com
2017-06-01 11:36 ` patrice.chotard at st.com [this message]
2017-06-01 11:36 ` [U-Boot] [PATCH v5 09/11] usb: host: ohci-generic: add CLOCK support patrice.chotard at st.com
2017-06-01 11:36 ` [U-Boot] [PATCH v5 10/11] usb: host: ohci-generic: add RESET support patrice.chotard at st.com
2017-06-01 11:36 ` [U-Boot] [PATCH v5 11/11] usb: host: ohci-generic: add generic PHY support patrice.chotard at st.com

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=1496316982-16572-9-git-send-email-patrice.chotard@st.com \
    --to=patrice.chotard@st.com \
    --cc=u-boot@lists.denx.de \
    /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.