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 DB02FC433F5 for ; Sun, 6 Feb 2022 21:59:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 99B3583059; Sun, 6 Feb 2022 22:59:26 +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=1644184766; bh=4bFx/jpH88zM2a3lxyEVPtWjCedragsWzQQOpdswM5E=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ox+fmDTCS11NrfOq9PnA1ATC8SERI81gMutyGSmcMor4PNd6SAuAVQ4qBXbNFrntV CdDHGIs4ykt8h6j0vn4wpcRziPzgh650xmU08xezqvEW2GT/bILACj40wIB9wfb9p1 2sKLlXViE8mEM9ZAMaImPXOEYwpnAhnvIB3vEKZZr9DEx56Zbiw/ZCNUByvj7HQopH t5I92d1x6t/A0FRQdRLt9F1ZuWGLi1dMQufGcG63uJpuzdFKhkynAHKjHBpBDcsr+T PgYXOs+X1YEGJvqHVdqh4c4qmRtlQLS02JkSKLeYFL2++PlBxKgRvOnNNt3Vk7miHP 7Npe+xUrT7RZw== 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 10C578192A; Sun, 6 Feb 2022 22:59:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1644184765; bh=4bFx/jpH88zM2a3lxyEVPtWjCedragsWzQQOpdswM5E=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=A3vs+9KUZ88PORt3Z2qha4EiApYHigipqraYachatLYkPhXIhAccoxRnzC4jAQGsH xGXCzvTdI9DzjGz0lJCTT30Aq52y7ep1pmUu5RLcY8uS3/RrppN0fI9p94huZQe63t rrNOhxuwZg4XRXb7C8EMTPZ8Yh8AxxVV63sIJcZ4itnEycLHZ2jz5Q7gfu3rBCCBZg qyiVBCto/QbewX531pN3RJCyO4iI4vKk0URaq8AhRWI53gI+D3cBx1Zbkc6RnTUUfx Oqb21H9KQBQ6i26SgoMEr0f6+1flXQ0tMOfV3qKGqpaSWe7bFJxx4MDYkOIza+H4Hm MxM6k31d/Y8nQ== Message-ID: Date: Sun, 6 Feb 2022 22:59:24 +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 , u-boot@lists.denx.de Cc: marcel.ziswiler@toradex.com, festevam@gmail.com, tharvey@gateworks.com, aford@beaconembedded.com References: <20220203212011.829122-1-aford173@gmail.com> From: Marek Vasut In-Reply-To: <20220203212011.829122-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.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/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. 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.