From patchwork Fri Apr 2 12:48:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1461676 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=PeEVwdkD; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FBfzW5bpSz9sV5 for ; Fri, 2 Apr 2021 23:50:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9E05B81718; Fri, 2 Apr 2021 14:48:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1617367730; bh=wDOJ+IvOHT+j+c+wmHAB/AJl42m1LMi7tctFoTbF6lQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PeEVwdkDcBJ1bLLtl3a187jNu6IhAYXUffU1/x8HYSqBFxctH2/i0Js8jCz5AxI+E BSr+62ugGyvzy4KSzQMTrddmRpSzc5tCixHkCsSOT9iugmW9U/aR6GKr6JvAxq6GG+ RvdZU7Xu2rc2yKQpdsnqh2OwRzvG5zK/F3QjwRwd8eEdWApFSC3RoiuMlDUiXA/quB cp40H7rIFnnkw4KNnyNrZRx+uPDxz7aNf0OSrkG7tI1Z50JxP1ILxkYMdxjSUdqzBm 2O7HurjvN7tuhrRP9gXgwbFKZD0+eepOX3/Jkho1b9qIdanjhuHA5TkqydGi60KGMs 9EQ2tionA+15Q== Received: by phobos.denx.de (Postfix, from userid 109) id 22F6D816AE; Fri, 2 Apr 2021 14:48:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2E8F781660 for ; Fri, 2 Apr 2021 14:48:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=marex@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4FBfxP6pZxz1s2CP; Fri, 2 Apr 2021 14:48:41 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4FBfxP6YRyz1r18L; Fri, 2 Apr 2021 14:48:41 +0200 (CEST) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 7l8kxVXpsbNs; Fri, 2 Apr 2021 14:48:40 +0200 (CEST) X-Auth-Info: 0l0wAuTtSVLM5/GWYwUsPC1wR8ix//FQcfLC81INX5w= Received: from tr.lan (ip-89-176-112-137.net.upcbroadband.cz [89.176.112.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 2 Apr 2021 14:48:40 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fabio Estevam , Peng Fan , Stefano Babic , Ye Li , uboot-imx Subject: [PATCH 10/19] usb: ehci-mx6: Parse USB PHY and MISC offsets from DT Date: Fri, 2 Apr 2021 14:48:03 +0200 Message-Id: <20210402124812.186761-10-marex@denx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210402124812.186761-1-marex@denx.de> References: <20210402124812.186761-1-marex@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean 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 Cc: Fabio Estevam Cc: Peng Fan Cc: Stefano Babic Cc: Ye Li Cc: uboot-imx --- drivers/usb/host/ehci-mx6.c | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index b0703502db0..008dca9bae7 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -417,6 +417,12 @@ struct ehci_mx6_priv_data { struct clk clk; enum usb_init_type init_type; int portnr; +#if !defined(CONFIG_PHY) + /* Legacy iMX6/iMX7/iMX7ULP compat, they do not use PHY framework yet */ + void __iomem *phy_addr; + void __iomem *misc_addr; + void __iomem *anatop_addr; +#endif }; static int mx6_init_after_reset(struct ehci_ctrl *dev) @@ -571,6 +577,55 @@ static int ehci_usb_bind(struct udevice *dev) return 0; } +static int mx6_parse_dt_addrs(struct udevice *dev) +{ +#if !defined(CONFIG_PHY) + /* + * Parse USB PHY/MISC/ANATOP addresses out of DT on platforms + * which do not use PHY framework yet, that is MX6/MX7/MX7ULP. + */ + struct ehci_mx6_priv_data *priv = dev_get_priv(dev); + int phy_off, misc_off, anatop_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) + 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_MX6) + /* 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 +#endif + return 0; +} + static int ehci_usb_probe(struct udevice *dev) { struct usb_plat *plat = dev_get_plat(dev); @@ -589,6 +644,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;