From patchwork Fri May 20 08:26:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommaso Merciai X-Patchwork-Id: 1970 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id CA9843F039 for ; Fri, 20 May 2022 10:26:30 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id s9-20020aa7c549000000b0042ab6ab62f0sf5182334edr.14 for ; Fri, 20 May 2022 01:26:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1653035190; cv=pass; d=google.com; s=arc-20160816; b=yhLtbnNKAaQ3/Oo9IDFB4WLbBktx5LtebXhdvt4zVni8kIKSRsnaUrZqMmCkQRwrzL LkqT68kTu/uvH7DoEdjtgBeGjCUIL/3ROEzoIn3Pkl3zTaU8RfCAmQ0S2IU+lT01uSBU CmBkwDU9STS0/Nnkt28Ko1TpD6Uve1FGN1DR44WMVa0K+OLZIE7tOiA5YnjKOhyqGGYR gUioF5d5VQGBIRqJ9YLpA8nGudL6AapDb1hxKDaCcDKTslT2kwm2iDPN5uoInt5YAah8 A72LLfcTkyQYe5fNyMTgG4zLLMgtngCbDE0ZdpZn3CDDeX1805P40c1zceEf5UdoOvQw PXZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=YwgjA0YJfzby9ew3dpBe5MSY30kYTaBST7IF5i3isT4=; b=R195FP6UlOpvMIDLsydLIl1rOJSrojfOQW3Dr0/qalxE+jmNXWyNO2zvLQC9QR/jEv FlZl/w5VLGyySjEkeb6FCY+Hh7yXMzJ15X8ccIt7J2iHVhWZpxx2ZfzEDVaWkZ2NQ8Ej xd1fCVKZljceaoQHWuVEL9h+pgDt0S2C0dkPzGBckGJ5vEBGB6Ijehs5YhITYDRnS6YR cntyUTzSGb9bv0V3Z3MWyb+80WjEnNulS9W0soo8UAf5kFIol+Ce3XXcK8oJAUgTpcbl QCr3vdV0GSsw9jl/J+iWVzYiOCtVfByE3lmZQ6ipYNEjoJPXd6GAWxf3u70rZPFf/WMH Kqxg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=YXX8zGMs; spf=pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tommaso.merciai@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=YwgjA0YJfzby9ew3dpBe5MSY30kYTaBST7IF5i3isT4=; b=fjxWoFrfShF2EQrzQghx56+Jvm1sAYKuLTEdrU29T9nV37RQFqcz+tnZ+zOQXrXdee bGstse/r57jxXjGGqJMzJO64plHBeqcnqXVQwJ2X6dmaxWpYZh9me+MxVpplGgu0Mndi dCZLopIMG84xx5qYLQLiEZAspPoQT1DyuDNrE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=YwgjA0YJfzby9ew3dpBe5MSY30kYTaBST7IF5i3isT4=; b=Rchv2h/GTZnTV7BspSWu2YSBgsVZLwyS9dzi+SbRNrb6VUbKwMjsdADwOJkQcyr65S dvm2GEEf79IPWRvh/KtRnjLHAVNTLx0TaCHRR4yox206bw46jL4arNDZQiSnGURwIQxf nMAxvH9/ewdF5NbCHN05ywP/x/aYzd7rPO5FyFNZ7lKaZIW0ohtNVwUp4pHaPBUaSqqI pyNEQ5p9SoLoap3mWVlbR5ZWSQmhQLt88mOwBgg+fgYQpy1HipijKN8+FjUki4uMWFlD MOddWTJ97KX8gjq0YchgCSrtrrRSgHbqb9O5errtoVBD5eTGAPwmZix5bQOkYQ73C8Ug duUQ== X-Gm-Message-State: AOAM533LjZRlq66khv3qpe5SoPo6rMvx2vDRahUZk4fD44Z6c4WD19CV CAuXP3J3VVIvWQfJdl4kLsOhMX4J X-Google-Smtp-Source: ABdhPJx/GHPSiTXmUxoc9hC814OpMNElUq+C809IJbThLxhHJiKbBsaraXAqPE+uKIumWxPQrpAaaQ== X-Received: by 2002:aa7:dd48:0:b0:42a:f46f:6b0d with SMTP id o8-20020aa7dd48000000b0042af46f6b0dmr9116473edw.406.1653035190529; Fri, 20 May 2022 01:26:30 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:5415:b0:42b:305b:5501 with SMTP id ev21-20020a056402541500b0042b305b5501ls389180edb.0.gmail; Fri, 20 May 2022 01:26:29 -0700 (PDT) X-Received: by 2002:a05:6402:3047:b0:42a:fbe9:4509 with SMTP id bs7-20020a056402304700b0042afbe94509mr8157711edb.159.1653035189578; Fri, 20 May 2022 01:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653035189; cv=none; d=google.com; s=arc-20160816; b=dPyav39gi1jIO0dIPmgUbYWZR67sV6OAL8hYICBSl/zfrubyARh23fJ2CdI8yQu2/m KK4z87hHIjWb6y+slbu9eijUkYqxr7ryz0ZQc4cNmtllZ1wyP0F4owj0I9AyBSguQip3 zaA8P8EZuqmZH+dJ/wb3B4h5XX3Js+mxicbqrjxjg4YDMRP5msxzD8lQIQf6VbngHhWp vQvHMvbrqKktKbba8gPl5Z7X9Yerqx9KiIRM6gBMOb0RYWtXs1KzXaibsdF04IcEXRUu R/WbfUFTrNPbVKvSxFy/Galt0Qzm2s6+OSBp9x8y14LRhaArnE5Ec5ldWhs3QvTjQVyU yJ8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=hAHSsNvUqbNUYQ0Y8NZEjI+qsjsGuEZqaEMymiT7LZA=; b=QS38d5dQ0tfgs2BP6ddROb4/9GMN3mnpcQBjGPFmcKzZgaDV5disahVV1aKWMuyggb rfL1e8MnNYyhl44bdB1RyWHmiHvG6hbbAvAx0yUxbgFdb0N5EAAgEjNJJXwXscMJPg+e FQ78m4c20U7QkZWguWrsM3Muh3jVvJ8GiwQ7zx112ShBBbhWbZTTR2+3IqBU5wfT6EIF F99vhtWmXWm/jwUZBM1dVhjVmLZP4cgogUd3TbX3BtQGJn0wXz1DPeZAg+92Gk0X9LD/ KUOXiIOIdgtn6jK77aTDzPp9YeqAzVpM/JVZdYCMc22TvdF6PKVbiQebyId6Rh+k9uwd RubQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=YXX8zGMs; spf=pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tommaso.merciai@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 26-20020a170906025a00b006e84005c098sor3752170ejl.17.2022.05.20.01.26.29 for (Google Transport Security); Fri, 20 May 2022 01:26:29 -0700 (PDT) Received-SPF: pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:3e0e:b0:6fe:b42f:db81 with SMTP id hp14-20020a1709073e0e00b006feb42fdb81mr640408ejc.516.1653035189129; Fri, 20 May 2022 01:26:29 -0700 (PDT) Received: from tom-ThinkPad-T14s-Gen-2i.station (net-188-217-53-154.cust.vodafonedsl.it. [188.217.53.154]) by smtp.gmail.com with ESMTPSA id el9-20020a170907284900b006f3ef214e55sm2896544ejc.187.2022.05.20.01.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 01:26:28 -0700 (PDT) From: Tommaso Merciai To: Cc: linux-amarula@amarulasolutions.com, Tommaso Merciai , Tim Harvey , Fabio Estevam Subject: [PATCH 4/8] usb: ehci-mx6: move mode set/detect to probe Date: Fri, 20 May 2022 10:26:19 +0200 Message-Id: <20220520082623.1788887-5-tommaso.merciai@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520082623.1788887-1-tommaso.merciai@amarulasolutions.com> References: <20220520082623.1788887-1-tommaso.merciai@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: tommaso.merciai@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=YXX8zGMs; spf=pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tommaso.merciai@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Signed-off-by: Tommaso Merciai --- drivers/usb/host/ehci-mx6.c | 49 ++++++++++--------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 060b02accc..1b6dc19a01 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -559,27 +559,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; - default: - plat->init_type = USB_INIT_UNKNOWN; - }; - - return 0; -} - static int mx6_parse_dt_addrs(struct udevice *dev) { #if !defined(CONFIG_PHY) @@ -641,7 +620,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; @@ -659,7 +637,6 @@ static int ehci_usb_probe(struct udevice *dev) return ret; priv->ehci = ehci; - priv->init_type = type; priv->phy_type = usb_get_phy_mode(dev_ofnode(dev)); #if CONFIG_IS_ENABLED(CLK) @@ -676,19 +653,20 @@ static int ehci_usb_probe(struct udevice *dev) mdelay(1); #endif - /* - * If the device tree didn't specify host or device, - * the default is USB_INIT_UNKNOWN, so we need to check - * the register. For imx8mm and imx8mn, the clocks need to be - * running first, so we defer the check until they are. - */ - if (priv->init_type == USB_INIT_UNKNOWN) { + 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) - goto err_clk; - else - priv->init_type = plat->init_type; - } + return ret; + }; + priv->init_type = plat->init_type; #if CONFIG_IS_ENABLED(DM_REGULATOR) ret = device_get_supply_regulator(dev, "vbus-supply", @@ -713,7 +691,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); @@ -798,7 +776,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,