From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DBBBC07E97 for ; Sat, 3 Jul 2021 19:59:25 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B710661357 for ; Sat, 3 Jul 2021 19:59:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B710661357 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7740582A15; Sat, 3 Jul 2021 21:59:05 +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=1625342345; bh=z2eXpk3eQTdIfLLSx7SN2XBDfxEPoL1IDnKxjiVDetg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SwSPNCAFD/pJ9iiP3xWTrUO/OLRwn1jv1hODiU20xlq9MZjrLY/IVkTD5IFehiISJ ByOcPeqQwP1fy/M1Vc47HohkM+vLZL/Z5nxBdvaDu6SICF4ObkFuW0fsW338Xkm+Jz g+Xwg9A4o8RJM72P+BwE+CvpZx7+HSULWtTJpO3qB11uafOppJYsTwuLLm8rAYuwk5 10WI1YGBtNnaoV1BM8V6UKxAyJahyV49rGR9r/bpcmORhfMIBKN+hBdZUwQrDtdc0Y Zi+8c86V9y5ncxcyDCjou1Ybta6if5zwnJrn8SHIsAhX3WgdH4D5XoOLWZStFhBbxv gz+JHrpVaq/5g== Received: from localhost.localdomain (unknown [IPv6:2804:14c:485:504a:abf0:6b86:fce4:4efb]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: festevam@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 699D182A01; Sat, 3 Jul 2021 21:58:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1625342342; bh=z2eXpk3eQTdIfLLSx7SN2XBDfxEPoL1IDnKxjiVDetg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OFftsjdl/kMB/gVsNpPPdOukAXHb4jrS9Fu/Xwur3yqSIWtopzHBNK2KVbT5C6nB6 dXrNpMRYhPhkVsagFnhkO0rAkGeyq/iLImuKXpudiObs/PdwgiJDzbPe5a1dVu7Gvb PyRkdwkl5FfnQeft7VKbCuYm9v8PYa+rDujdMSRc4nyugNbHJyQ96UYPritRk+XH5Q obXpGUEnmsUdfEbNIS+OWO5xOW2/TtlN7+7O3vxTh3TBYdRV1h+Oxx7hHZFSKsSM7O J9zW0D9PRa+QbGZ7kx/Lv2jsAjEUCmXfAqJZOezoRfg/b3JV6/4lUiulXeXUjUmFnp DxPByg2p2piIg== From: Fabio Estevam To: sbabic@denx.de Cc: marex@denx.de, u-boot@lists.denx.de, frieder.schrempf@kontron.de, tharvey@gateworks.com, uboot-imx@nxp.com, Fabio Estevam Subject: [PATCH 3/8] usb: ehci-mx6: move mode set/detect to probe Date: Sat, 3 Jul 2021 16:58:32 -0300 Message-Id: <20210703195837.28153-4-festevam@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210703195837.28153-1-festevam@denx.de> References: <20210703195837.28153-1-festevam@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.103.2 at phobos.denx.de X-Virus-Status: Clean From: Tim Harvey There is no need to set and/or detect mode in of_to_plat and accessing phy registers at that point before device power domain and clock are enabled will cause hangs on platforms such as IMX8M Mini. Move the mode set/detect from of_to_plat into the probe and remove the unnecessary of_to_plat. Signed-off-by: Tim Harvey Signed-off-by: Fabio Estevam --- drivers/usb/host/ehci-mx6.c | 42 ++++++++++++++----------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index c3e4170513ec..ff23a5e35e64 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -539,28 +539,6 @@ static int ehci_usb_phy_mode(struct udevice *dev) return 0; } -static int ehci_usb_of_to_plat(struct udevice *dev) -{ - struct usb_plat *plat = dev_get_plat(dev); - enum usb_dr_mode dr_mode; - - dr_mode = usb_get_dr_mode(dev_ofnode(dev)); - - switch (dr_mode) { - case USB_DR_MODE_HOST: - plat->init_type = USB_INIT_HOST; - break; - case USB_DR_MODE_PERIPHERAL: - plat->init_type = USB_INIT_DEVICE; - break; - case USB_DR_MODE_OTG: - case USB_DR_MODE_UNKNOWN: - return ehci_usb_phy_mode(dev); - }; - - return 0; -} - static int mx6_parse_dt_addrs(struct udevice *dev) { #if !defined(CONFIG_PHY) @@ -622,7 +600,6 @@ static int ehci_usb_probe(struct udevice *dev) struct usb_plat *plat = dev_get_plat(dev); struct usb_ehci *ehci = dev_read_addr_ptr(dev); struct ehci_mx6_priv_data *priv = dev_get_priv(dev); - enum usb_init_type type = plat->init_type; struct ehci_hccr *hccr; struct ehci_hcor *hcor; int ret; @@ -640,7 +617,6 @@ static int ehci_usb_probe(struct udevice *dev) return ret; priv->ehci = ehci; - priv->init_type = type; #if CONFIG_IS_ENABLED(CLK) ret = clk_get_by_index(dev, 0, &priv->clk); @@ -656,6 +632,21 @@ static int ehci_usb_probe(struct udevice *dev) mdelay(1); #endif + switch (usb_get_dr_mode(dev_ofnode(dev))) { + case USB_DR_MODE_HOST: + plat->init_type = USB_INIT_HOST; + break; + case USB_DR_MODE_PERIPHERAL: + plat->init_type = USB_INIT_DEVICE; + break; + case USB_DR_MODE_OTG: + case USB_DR_MODE_UNKNOWN: + ret = ehci_usb_phy_mode(dev); + if (ret) + return ret; + }; + priv->init_type = plat->init_type; + #if CONFIG_IS_ENABLED(DM_REGULATOR) ret = device_get_supply_regulator(dev, "vbus-supply", &priv->vbus_supply); @@ -679,7 +670,7 @@ static int ehci_usb_probe(struct udevice *dev) #if CONFIG_IS_ENABLED(DM_REGULATOR) if (priv->vbus_supply) { ret = regulator_set_enable(priv->vbus_supply, - (type == USB_INIT_DEVICE) ? + (priv->init_type == USB_INIT_DEVICE) ? false : true); if (ret && ret != -ENOSYS) { printf("Error enabling VBUS supply (ret=%i)\n", ret); @@ -764,7 +755,6 @@ U_BOOT_DRIVER(usb_mx6) = { .name = "ehci_mx6", .id = UCLASS_USB, .of_match = mx6_usb_ids, - .of_to_plat = ehci_usb_of_to_plat, .probe = ehci_usb_probe, .remove = ehci_usb_remove, .ops = &ehci_usb_ops, -- 2.25.1