From patchwork Fri Apr 2 12:48:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1461678 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=Noph24YL; 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 4FBfzx21ZTz9sV5 for ; Fri, 2 Apr 2021 23:50:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 546D28179F; Fri, 2 Apr 2021 14:48:53 +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=1617367733; bh=lD0n1HoXDFM/oWrPXDn2wwI/fve6+V/pm/74/F2cLN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Noph24YLAvB2AiLdTO9qfz5NWUtkKEWWVQJifPHA5pai0MF2KJS1jjt5gE2Y82dLu l3wMgvngnnvISSgP4BErkSl2Dk+ykDKkr8heXRomxBpmxvvqj6apy6EY20QZnyWhuM T3mP26AMFpVeBGjOWhI6eQa07jFR1UZ1GJyMhAi/KeE37Xde4GNsOCn9gawJ0Yi4/6 VU/TkQ0k/m0/APzzQdSDt/jroutBThPyDtVnHVSsZaEiB+P7aSq8cPQrr9L9SglSfw Wz0GRu+hBdCRJ+396zEcgZkCOAUOdzhKEmG7r+0SlirS5MvYwE/3Y/XoM47PzuivPM BHmciz1yYwAXA== Received: by phobos.denx.de (Postfix, from userid 109) id 9D03A81742; Fri, 2 Apr 2021 14:48:47 +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,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) (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 B07A6816A4 for ; Fri, 2 Apr 2021 14:48:44 +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 4FBfxS3bTWz1qtPq; Fri, 2 Apr 2021 14:48:44 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4FBfxS3Hqsz1r18L; Fri, 2 Apr 2021 14:48:44 +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 3F5uMj9c6joO; Fri, 2 Apr 2021 14:48:43 +0200 (CEST) X-Auth-Info: 7D/fNHRkgmJqd1CWo8APt4e5tlEgTTiAOBjqsRRouXE= 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:43 +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 12/19] usb: ehci-mx6: Pass PHY address to usb_*_phy*() Date: Fri, 2 Apr 2021 14:48:05 +0200 Message-Id: <20210402124812.186761-12-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 Instead of passing ad-hoc index to USB PHY handling functions and then try and figure out the PHY address, pass in the PHY address itself. For DM case, this address comes easily from DT. For non-DM case, the previous method is still present, however the non-DM case will soon be removed. 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 | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index b195ba4c89b..800a25d1d9d 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -94,14 +94,8 @@ static const unsigned phy_bases[] = { #endif }; -static void usb_internal_phy_clock_gate(int index, int on) +static void usb_internal_phy_clock_gate(void __iomem *phy_reg, int on) { - void __iomem *phy_reg; - - if (index >= ARRAY_SIZE(phy_bases)) - return; - - phy_reg = (void __iomem *)phy_bases[index]; phy_reg += on ? USBPHY_CTRL_CLR : USBPHY_CTRL_SET; writel(USBPHY_CTRL_CLKGATE, phy_reg); } @@ -166,17 +160,12 @@ static void usb_power_config(int index) } /* Return 0 : host node, <>0 : device mode */ -static int usb_phy_enable(int index, struct usb_ehci *ehci) +static int usb_phy_enable(struct usb_ehci *ehci, void __iomem *phy_reg) { - void __iomem *phy_reg; void __iomem *phy_ctrl; void __iomem *usb_cmd; int ret; - if (index >= ARRAY_SIZE(phy_bases)) - return 0; - - phy_reg = (void __iomem *)phy_bases[index]; phy_ctrl = (void __iomem *)(phy_reg + USBPHY_CTRL); usb_cmd = (void __iomem *)&ehci->usbcmd; @@ -368,8 +357,10 @@ int ehci_hcd_init(int index, enum usb_init_type init, usb_oc_config(index); #if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP) - usb_internal_phy_clock_gate(index, 1); - usb_phy_enable(index, ehci); + if (index < ARRAY_SIZE(phy_bases)) { + usb_internal_phy_clock_gate((void __iomem *)phy_bases[index], 1); + usb_phy_enable(ehci, (void __iomem *)phy_bases[index]); + } #endif type = board_usb_phy_mode(index); @@ -427,8 +418,8 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev) usb_oc_config(priv->portnr); #if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP) - usb_internal_phy_clock_gate(priv->portnr, 1); - usb_phy_enable(priv->portnr, ehci); + usb_internal_phy_clock_gate(priv->phy_addr, 1); + usb_phy_enable(ehci, priv->phy_addr); #endif #if CONFIG_IS_ENABLED(DM_REGULATOR) @@ -672,8 +663,8 @@ static int ehci_usb_probe(struct udevice *dev) usb_oc_config(priv->portnr); #if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP) - usb_internal_phy_clock_gate(priv->portnr, 1); - usb_phy_enable(priv->portnr, ehci); + usb_internal_phy_clock_gate(priv->phy_addr, 1); + usb_phy_enable(ehci, priv->phy_addr); #endif #if CONFIG_IS_ENABLED(DM_REGULATOR)