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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 652A8C433EF for ; Wed, 22 Dec 2021 19:31:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A33C3830F5; Wed, 22 Dec 2021 20:31:36 +0100 (CET) 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=1640201497; bh=XgK1s3D+Yx1aCgHSr9AlGQDFa5449hiPqP7fUEdxdEA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NM8X4s4EDZYOe8nmwO3hWEIMFVD4gvIAM63bUhB1yaQ3KIY6MinGFDhU5F3ry560x EW8uckc5maIrFjxYUH0u10i2j3cbM/OT1GEofzbX+pY389UD1ttqTxrJg48V7JZfZt piXFNmbAFPhhWuF//HG526WriaqsItyGPwNItWZAbEtoPyjpRrMeDc4US86uw+CbnR uKRpUebM9FFJh6Wja9HRzGtmuw5FOI/mMTN93cp94Q+XxY8qx8sxaLW+A4YhgWH22g z/uv4uk8UFPZW9lQDtr/5z6TrK4NNcxcnrbSDqLaE6nm4B/+5prk2q7gK/JLTQV3Av DwGtd5wmbksDQ== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id A71BD82EBB; Wed, 22 Dec 2021 20:31:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1640201494; bh=XgK1s3D+Yx1aCgHSr9AlGQDFa5449hiPqP7fUEdxdEA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ajkXudvIk0516s0Y/p7nT/Mn30Qqc4vRDUReTrn3uZMhxLr9K7S9Wibxb38GfQA2t SoKZqFE+TfCWucKZ7feVjQtTkpGKZveLdl/rz4ReL0Y++vss41EjNAmiE+dQ0rJfDv XitlU+EiUXJy5DrFX9LkhaZI0gqTGDB92q/XW6g+aH1HvK23cUdexD6LKTrEfff+78 Y1ahft2vO5IrZZugZ59B2T8K+GYZqV+WjmPxO5XDQx4pBKxlcfq7OOXucChZjGVm/Z EwbWA+JlP2fm9H9YnG94w89kS9znX+qZ+CA/Z1Rd6z39ybl0pYj/5ZSQNYUO2UpCBY aDi9HlcqLa5mA== Message-ID: <5f1065a7-4b91-961f-4baf-78b784ff24bc@denx.de> Date: Wed, 22 Dec 2021 20:31:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] usb: ehci-mx6: Enable OTG detection on imx8mm and imx8mn Content-Language: en-US To: Adam Ford , u-boot@lists.denx.de Cc: festevam@denx.de, Simon Glass References: <20211222125213.124677-1-aford173@gmail.com> From: Marek Vasut In-Reply-To: <20211222125213.124677-1-aford173@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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 On 12/22/21 13:52, Adam Ford wrote: > The imx8mm and imx8mn appear compatible with imx7d-usb > flags in the OTG driver. If the dr_mode is defined as > host or peripheral, the device appears to operate correctly, > however the auto host/peripheral detection results in an error. > > Simply adding checks in ehci_usb_phy_mode for 8mm and > 8mn in ehci_usb_phy_mode is not enough, because ehci_usb_of_to_plat > is run before the clock is enabled which results in a hang. > > Enable the USB clock in ehci_usb_of_to_plat and add checks in > ehci_usb_phy_mode for 8mm and 8mn to enable auto detection of > the OTG mode on i.MX8M Mini and Nano. I was under the impression that of_to_plat() was meant to parse DT into driver local data, so frobbing with clock there could be a problem, right ? +CC Simon. > diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c > index 1bd6147c76..fa0798171b 100644 > --- a/drivers/usb/host/ehci-mx6.c > +++ b/drivers/usb/host/ehci-mx6.c > @@ -543,7 +543,7 @@ static int ehci_usb_phy_mode(struct udevice *dev) > plat->init_type = USB_INIT_DEVICE; > else > plat->init_type = USB_INIT_HOST; > - } else if (is_mx7()) { > + } else if (is_mx7() || is_imx8mm() || is_imx8mn()) { > phy_status = (void __iomem *)(addr + > USBNC_PHY_STATUS_OFFSET); > val = readl(phy_status); > @@ -561,11 +561,30 @@ static int ehci_usb_phy_mode(struct udevice *dev) > > static int ehci_usb_of_to_plat(struct udevice *dev) > { > +#if CONFIG_IS_ENABLED(CLK) > + int ret = 0; > + struct ehci_mx6_priv_data *priv = dev_get_priv(dev); > + > + ret = clk_get_by_index(dev, 0, &priv->clk); > + if (ret < 0) > + return ret; > + > + ret = clk_enable(&priv->clk); > + if (ret) > + return ret; > +#endif > + > struct usb_plat *plat = dev_get_plat(dev); > enum usb_dr_mode dr_mode; > > dr_mode = usb_get_dr_mode(dev_ofnode(dev)); > > +#if CONFIG_IS_ENABLED(CLK) > + ret = clk_disable(&priv->clk); > + if (ret) > + return ret; > +#endif > + > switch (dr_mode) { > case USB_DR_MODE_HOST: > plat->init_type = USB_INIT_HOST;