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 BC138C433EF for ; Mon, 7 Feb 2022 08:47:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F31F983C79; Mon, 7 Feb 2022 09:47:18 +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=1644223639; bh=T5XZugaKqpbMzI3tHfz4AgGTJm+94bHQqvtEwslEyD4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Tn2FHc6FtJ4n9hz3dFsQ9mCdysl3sv2r+hatmmVQ1D6YRMv7FwY3pDoa5p1vPgg44 ovAf3NjxFV7ev6g2u9Edj8es4lrIxd2cK+KMW7HlPMdfSc6BCi+Bt1f0lK0iFx9zOB h8/I4JuQfDJGmzyk5Fj/UUP23dN+OGJBX9AWTpHWlwbKiqz3ahrF9MNZdmtv+1jtc0 N0/Rcfw4n+uChRa7RvgWjUv8is9oyZRnxB3ETx+u6fZtQiHQ2UP4Uvjl9RvsmAgU3a IuLN8XqpQGiO0v5uIj/TkNl+QqRRw1e5QmL3yUP9CLNFJRJ1awuNWLzlCYQTxIRj3U e2lCtE6b0Z+xg== 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 8118583C4E; Mon, 7 Feb 2022 09:47:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1644223637; bh=T5XZugaKqpbMzI3tHfz4AgGTJm+94bHQqvtEwslEyD4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=SKYcfi72NbNI4rGwDKze8aBqYTa0oM5zl3nU+JOEgPJm7bDhVCRpNtVHiFvKG8ADL kekMLUaPJ6IPLrF3g1Z0NLXfrxj6J3zQ1noRRcq4fqVoMjQkSt+CUWOHJJrh/3usEi wg0zRbvZTcmjtHzGTtBphq5GBP4uLZqygO5uO/tzJ7MlaJ7q1NTXBqHhnlOGAFzyKA nljz9zGwl7GeHVX+xc3wbcCMBFHu2CJSdHyxJ0qaeiA4wMUn+xtkDuOfMY4/3ZIpYb y8sBGZXxNVHmZYQw4WUXz/8UdRufvwPXbvGQrVVYpPbyYIUEr6E4uyQJEftGOAe9KP RaWHQNWlvuDYw== Message-ID: <4d7f31dc-38d8-ac48-3fa9-e11f7223fb2b@denx.de> Date: Mon, 7 Feb 2022 09:47:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH V4] usb: ehci-mx6: Enable OTG detection on imx8mm and imx8mn Content-Language: en-US To: Adam Ford Cc: U-Boot Mailing List , Marcel Ziswiler , Fabio Estevam , Tim Harvey , Adam Ford-BE References: <20220203212011.829122-1-aford173@gmail.com> From: Marek Vasut In-Reply-To: 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.39 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.5 at phobos.denx.de X-Virus-Status: Clean On 2/7/22 01:51, Adam Ford wrote: > On Sun, Feb 6, 2022 at 3:59 PM Marek Vasut wrote: >> >> On 2/3/22 22:20, 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. >>> >>> The solution isn't just adding checks for imx8mm and imx8mn to >>> the check for imx7, because the USB clock needs to be running >>> to read from the USBNC_PHY_STATUS_OFFSET register or it will hang. >>> >>> Marek requested that I not enable the clocks in ehci_usb_of_to_plat, >>> so I modified that function to return an unknown state if the >>> device tree does not explicitly state whether it is a host >>> or a peripheral. >>> >>> When the driver probes, it looks to see if it's in the unknown >>> state, and only then will it read the register to auto-detect. >>> >>> Signed-off-by: Adam Ford >>> Tested-by: Tim Harvey >>> --- >>> V4: Fix 'err_clk' reference, so it is not encapsulated in >>> an ifdef making it available at all times. >>> V3: Keep ehci_usb_of_to_plat but add the ability to return >>> and unknown state instead of reading the register. >>> If the probe determines the states is unknown, it will >>> query the register after the clocks have been enabled. >>> Because of the slight behavior change, I removed any >>> review or tested tags. >>> >>> V2: Rename ehci_usb_of_to_plat to ehci_usb_dr_mode and call it >>> from the probe after t >>> >>> diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c >>> index 1bd6147c76..060b02accc 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); >> >> Is the USB GPCv2 power domain always ON at this point ? If it isn't, >> then this access will lock up the whole SoC. > > The GPCv2 needs to be enabled if USB is going to be used, but I would > expect that to happen even without this patch. I ran into that during > my early testing. > >> >> You can check that easily by adding printf() into >> drivers/power/domain/imx8m-power-domain.c imx8m_power_domain_on() , and >> verify that printf() prints something before this ehci_usb_phy_mode() >> code is called. > > I added a printf to show when a power domain is enabled. It does > appear that power domains for HSIO, USBOTG1 and USBOTG2 are all > enabled before the scan on the respective USB bus happens, so I think > we're safe from hanging. Isn't the ehci_usb_of_to_plat() called way before you even initiate the scan, somewhere during U-Boot startup ? So no, you might end up hanging the hardware ? (you can verify that by adding more printf()s)