All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH V2 13/24] usb: ehci-mx6: Parse USB PHY and MISC offsets from DT
Date: Sun, 11 Apr 2021 18:28:50 +0200	[thread overview]
Message-ID: <20210411162901.7238-13-marex@denx.de> (raw)
In-Reply-To: <20210411162901.7238-1-marex@denx.de>

In case DM and OF controler is enabled, but PHY support is disabled,
parse USB PHY and MISC component addresses from DT manually. Those
component addresses will be used in subsequent patches to access the
ANATOP, PHY and MISC registers matching the controller and thus get
rid of the ad-hoc controller sequence number mapping.

Fixes: 4de51cc25b5 ("usb: ehci-mx6: Drop assignment of sequence number")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Ye Li <ye.li@nxp.com>
Cc: uboot-imx <uboot-imx@nxp.com>
---
V2: - Move anatop_off variable inside if defined(CONFIG_MX6) to avoid
      warning, that the variable is defined and not used on !MX6
    - Parse PHY and USBMISC addresses unconditionally, with or without
      CONFIG_PHY enabled or disabled
---
 drivers/usb/host/ehci-mx6.c | 55 +++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 915b25a618..164054eaf8 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -417,6 +417,9 @@ struct ehci_mx6_priv_data {
 	struct clk clk;
 	enum usb_init_type init_type;
 	int portnr;
+	void __iomem *phy_addr;
+	void __iomem *misc_addr;
+	void __iomem *anatop_addr;
 };
 
 static int mx6_init_after_reset(struct ehci_ctrl *dev)
@@ -571,6 +574,54 @@ static int ehci_usb_bind(struct udevice *dev)
 	return 0;
 }
 
+static int mx6_parse_dt_addrs(struct udevice *dev)
+{
+	struct ehci_mx6_priv_data *priv = dev_get_priv(dev);
+	int phy_off, misc_off;
+	const void *blob = gd->fdt_blob;
+	int offset = dev_of_offset(dev);
+	void *__iomem addr;
+
+	phy_off = fdtdec_lookup_phandle(blob, offset, "fsl,usbphy");
+	if (phy_off < 0) {
+		phy_off = fdtdec_lookup_phandle(blob, offset, "phys");
+		if (phy_off < 0)
+			return -EINVAL;
+	}
+
+	misc_off = fdtdec_lookup_phandle(blob, offset, "fsl,usbmisc");
+	if (misc_off < 0)
+		return -EINVAL;
+
+	addr = (void __iomem *)fdtdec_get_addr(blob, phy_off, "reg");
+	if ((fdt_addr_t)addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	priv->phy_addr = addr;
+
+	addr = (void __iomem *)fdtdec_get_addr(blob, misc_off, "reg");
+	if ((fdt_addr_t)addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	priv->misc_addr = addr;
+
+#if !defined(CONFIG_PHY) && defined(CONFIG_MX6)
+	int anatop_off;
+
+	/* Resolve ANATOP offset through USB PHY node */
+	anatop_off = fdtdec_lookup_phandle(blob, phy_off, "fsl,anatop");
+	if (anatop_off < 0)
+		return -EINVAL;
+
+	addr = (void __iomem *)fdtdec_get_addr(blob, anatop_off, "reg");
+	if ((fdt_addr_t)addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	priv->anatop_addr = addr;
+#endif
+	return 0;
+}
+
 static int ehci_usb_probe(struct udevice *dev)
 {
 	struct usb_plat *plat = dev_get_plat(dev);
@@ -589,6 +640,10 @@ static int ehci_usb_probe(struct udevice *dev)
 		}
 	}
 
+	ret = mx6_parse_dt_addrs(dev);
+	if (ret)
+		return ret;
+
 	priv->ehci = ehci;
 	priv->portnr = dev_seq(dev);
 	priv->init_type = type;
-- 
2.30.2

  parent reply	other threads:[~2021-04-11 16:28 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-11 16:28 [PATCH V2 01/24] phy: nop-phy: Add standard usb-nop-xceiv compat string Marek Vasut
2021-04-11 16:28 ` [PATCH V2 02/24] arc: emsdp/iotdk: Use standard compatible string for USB no-op PHY Marek Vasut
2021-04-11 16:28 ` [PATCH V2 03/24] ARM: dts: k2g-evm: " Marek Vasut
2021-04-11 16:28 ` [PATCH V2 04/24] ARM: dts: imx8mm: Replace deprecated fsl, usbphy DT props with phys Marek Vasut
2021-04-11 16:28 ` [PATCH V2 05/24] ARM: dts: imx8mn: " Marek Vasut
2021-04-11 16:28 ` [PATCH V2 06/24] ARM: dts: imx8mm: Add power domain nodes Marek Vasut
2021-04-11 16:28 ` [PATCH V2 07/24] ARM: dts: imx8mn: " Marek Vasut
2021-04-11 16:28 ` [PATCH V2 08/24] imx: power-domain: Add fsl, imx8mm-gpc compatible string Marek Vasut
2021-04-12  2:02   ` Jaehoon Chung
2021-04-11 16:28 ` [PATCH V2 09/24] imx: power-domain: Add fsl, imx8mn-gpc " Marek Vasut
2021-04-12  2:02   ` Jaehoon Chung
2021-04-11 16:28 ` [PATCH V2 10/24] usb: ehci-mx6: Turn off Vbus on probe failure Marek Vasut
2021-04-11 16:28 ` [PATCH V2 11/24] usb: ehci-mx6: Add DM clock support Marek Vasut
2021-04-11 16:28 ` [PATCH V2 12/24] usb: ehci-mx6: Unify USBNC registers Marek Vasut
2021-04-11 16:28 ` Marek Vasut [this message]
2021-04-11 16:28 ` [PATCH V2 14/24] usb: ehci-mx6: Split ehci_mx6_common_init() Marek Vasut
2021-04-11 16:28 ` [PATCH V2 15/24] usb: ehci-mx6: Pass PHY address to usb_*_phy*() Marek Vasut
2021-04-11 16:28 ` [PATCH V2 16/24] usb: ehci-mx6: Split usb_power_config() Marek Vasut
2021-04-11 16:28 ` [PATCH V2 17/24] usb: ehci-mx6: Pass MISC address to usb_oc_config() Marek Vasut
2021-04-11 16:28 ` [PATCH V2 18/24] usb: ehci-mx6: Use portnr from DT in DM case Marek Vasut
2021-04-11 16:28 ` [PATCH V2 19/24] usb: ehci-mx6: Add generic EHCI PHY support Marek Vasut
2021-04-11 16:28 ` [PATCH V2 20/24] usb: ehci-mx6: Set default CONFIG_MXC_USB_PORTSC if not defined Marek Vasut
2021-04-11 16:28 ` [PATCH V2 21/24] usb: ehci-mx6: Add fsl,imx7d-usb compatible string Marek Vasut
2021-04-11 16:28 ` [PATCH V2 22/24] usb: ehci-mx6: Fix aarch64 build warnings Marek Vasut
2021-04-11 16:29 ` [PATCH V2 23/24] usb: ehci-mx6: Add iMX8M support Marek Vasut
2021-04-11 16:29 ` [PATCH V2 24/24] ARM: imx8m: verdin-imx8mm: Enable USB Host support Marek Vasut
2021-04-20  0:33   ` Tim Harvey
2021-04-22 10:34     ` Ying-Chun Liu
2021-04-22 15:19       ` Tim Harvey
2021-04-22 19:16     ` Marek Vasut
2021-04-23 15:04       ` Tim Harvey
2021-04-23 15:21         ` Marek Vasut
2021-04-27  0:01           ` Tim Harvey
2021-04-27  0:35             ` Marek Vasut
2021-04-27 15:50               ` Tim Harvey
2021-04-28 21:56                 ` Adam Ford
2021-04-23 22:05 ` [PATCH V2 01/24] phy: nop-phy: Add standard usb-nop-xceiv compat string Sean Anderson

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=20210411162901.7238-13-marex@denx.de \
    --to=marex@denx.de \
    --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.