From patchwork Thu Oct 10 13:09:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 1174539 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="V3Xr7Gcq"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46prz06skHz9sPJ for ; Fri, 11 Oct 2019 00:09:48 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6491BC21DF8; Thu, 10 Oct 2019 13:09:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5846BC21C38; Thu, 10 Oct 2019 13:09:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8BC4DC21C38; Thu, 10 Oct 2019 13:09:39 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by lists.denx.de (Postfix) with ESMTPS id 360D8C21C2C for ; Thu, 10 Oct 2019 13:09:39 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id v17so6725972wml.4 for ; Thu, 10 Oct 2019 06:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=B2mo7WSJHKghEwhkwfy+z7e072qzpTXyAroPfb4Z/MY=; b=V3Xr7GcqL3UrTw6YPVvxzNF8lJ/rcuSSz/X1u3LiD5I9qzG5rc9HJR8SCt7s0E9g4w jecklnr12NXmCBhcBIDbGqxlYwVDxKKY0+iz7jlfG6zAnMLT9t/TktR8kiSToVVl0mts cWc1UMsRLJo/CQl6DdbhUVRVCb/tFDgZlu/KPiV7SZYmmDznqxUPlHk9YWgcHAXlbdie GqtY17WCP4qn2EkofnU3iym82EVEpXja5Jvehk6W8FztCaGlkykG8Fb4KPxfbGQJniVF dmSKq0yi9twgzFpTKgJvrSe0s1H+xziSPV4tJwMxZH8eHTCQPzPDra+8ilX7KGQz9j6/ 7fng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=B2mo7WSJHKghEwhkwfy+z7e072qzpTXyAroPfb4Z/MY=; b=XwsNNtvLL708vHa5gB+9KsrmXEqVe2pIhAyxKaH773nFtSkhiRCKtapjmxAzDU/cM+ IdXDeg5R39dPISu804rc/pkoFNDn9pn9EHPGgsJMAwZFmQli51Gf2ooAW0YZuQGC7T5u E8KxhoHqKGik7LZlSUoO2G7cWhk+85qW1rdcMSxLzfPR+bIx7xqMrMrV3d3GziRdczI6 2A7oJqyzY4bU7WREbHiJ1Pd2J2RhLdR/i+LO8cDqiDKomeZgemDCK8wQAwpAtPjNiF4k c1QzFd+6yxy91I0VZH6w7qx7VLLB4MdLvypHGgyBXXNolTTh9Y/U85bLUDvRtkWkhPnA idHA== X-Gm-Message-State: APjAAAXEyvCuJjcqG67QIs4ukEkTf5XlQvpD3jwzU55VsC+ct9reGa8q f0LezJ84QWYKEPwqnZxrr826KNnqQOI= X-Google-Smtp-Source: APXvYqy8aeoOfcA3CsCubV83W0UqbpzwErkViAS3ekyzCQWhIzj2sfL+yhd2njn3BqmJU11551+ubg== X-Received: by 2002:a1c:968b:: with SMTP id y133mr7584875wmd.141.1570712978383; Thu, 10 Oct 2019 06:09:38 -0700 (PDT) Received: from localhost ([194.105.145.90]) by smtp.gmail.com with ESMTPSA id w7sm5541012wmd.22.2019.10.10.06.09.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 06:09:37 -0700 (PDT) From: Igor Opaniuk To: u-boot@lists.denx.de Date: Thu, 10 Oct 2019 16:09:35 +0300 Message-Id: <20191010130935.13792-1-igor.opaniuk@gmail.com> X-Mailer: git-send-email 2.17.1 Cc: Marek Vasut , Marcel Ziswiler , Sven Schwermer , Vagrant Cascadian , Igor Opaniuk , Ludwig Zenz , Max Krummenacher Subject: [U-Boot] [PATCH v2] usb: ehci-mx6: Fix bus enumeration for iMX7 SoCs X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Igor Opaniuk This fixes the issues with calculation of controller indexes in ehci_usb_bind() for iMX7, as USB controllers on iMX7 SoCs aren't placed next to each other, and their addresses incremented by 0x10000. Example of USB nodes for iMX7S/D: usbotg1: usb@30b10000 { compatible = "fsl,imx7d-usb", "fsl,imx27-usb"; reg = <0x30b10000 0x200>; ^^^^^^^^^^ .... usbotg2: usb@30b20000 { compatible = "fsl,imx7d-usb", "fsl,imx27-usb"; reg = <0x30b20000 0x200>; ^^^^^^^^^^ .... usbh: usb@30b30000 { compatible = "fsl,imx7d-usb", "fsl,imx27-usb"; reg = <0x30b30000 0x200>; ^^^^^^^^^^ .... Which was leading to usb enumeration issues: Colibri iMX7 # usb start starting USB... Bus usb@30b10000: USB EHCI 1.00 Bus usb@30b20000: probe failed, error -22 scanning bus usb@30b10000 for devices... 1 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Fixes: 501547cec1("usb: ehci-mx6: Fix bus enumeration for DM case") Signed-off-by: Igor Opaniuk Acked-by: Marcel Ziswiler --- v2: - removed ifdefs and used runtime check of SoC drivers/usb/host/ehci-mx6.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index e9e6ed596d..7d46091f94 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -513,10 +513,11 @@ static int ehci_usb_bind(struct udevice *dev) * from which it derives offsets in the PHY and ANATOP register sets. * * Here we attempt to calculate these indexes from DT information as - * well as we can. The USB controllers on all existing iMX6/iMX7 SoCs - * are placed next to each other, at addresses incremented by 0x200. - * Thus, the index is derived from the multiple of 0x200 offset from - * the first controller address. + * well as we can. The USB controllers on all existing iMX6 SoCs + * are placed next to each other, at addresses incremented by 0x200, + * and iMX7 their addresses are shifted by 0x10000. + * Thus, the index is derived from the multiple of 0x200 (0x10000 for + * iMX7) offset from the first controller address. * * However, to complete conversion of this driver to DT probing, the * following has to be done: @@ -531,10 +532,10 @@ static int ehci_usb_bind(struct udevice *dev) * With these changes in place, the ad-hoc indexing goes away and * the driver is fully converted to DT probing. */ - fdt_size_t size; - fdt_addr_t addr = devfdt_get_addr_size_index(dev, 0, &size); + u32 controller_spacing = is_mx7() ? 0x10000 : 0x200; + fdt_addr_t addr = devfdt_get_addr_index(dev, 0); - dev->req_seq = (addr - USB_BASE_ADDR) / size; + dev->req_seq = (addr - USB_BASE_ADDR) / controller_spacing; return 0; }