From patchwork Fri Jan 5 16:15:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 123540 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1001168qgn; Fri, 5 Jan 2018 08:17:50 -0800 (PST) X-Google-Smtp-Source: ACJfBouK5bRfEmB1KxIqZbZ1FENSAMhSvpJlg6t3WGze+0FHcaSxqlf5NA0NhFnBA9pl53fHhaOj X-Received: by 10.80.177.178 with SMTP id m47mr4830627edd.261.1515169070031; Fri, 05 Jan 2018 08:17:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515169070; cv=none; d=google.com; s=arc-20160816; b=ea/OCoaoVJblrCXjkAnCrN4MdR2MpKpwTuv+BGWzBI1BhHc1bWO8espi49VOF5BrRz RtRE4fw9ydDPC7He73oXgc+C83Y0gzunRSaq7LIt9HnrW9yC4CJqGS4A1pxuNBudVHZI URgwbDGNvlJV+ZAh90p9NV6kk9fYMkkAq6Ssr5uPYQgSg9CtR0L/N/Dicplzdcb2/zTJ NWfW6QsJv5uK0emthokrKMf3hi0RZcYrJWE6TQJY34Ck20m4UKuxBP3wuRHoQ/AkIjOa KybFbnEGjDhXHoIs36bE4bO31SfB4JDtPjVn5SKGXeCSaAwPExqm7lGefyIM3qNy8uiB FoSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=rDzzPpe+2lRfCFMxbhb1uPnnb6ckejKYMbH1SW3kX+I=; b=ZLPjlYOuOjosLBCBIzyZHLAe36gfc9AWCrYMY+QhHtcr+ittr630Tog6ScBy61DAzb 14CmKlTGLHDHIQbJvjlFo9HIxZql2vXcil86hXhopQyyYLnAeRSwZXqoNaanu1++EMfm 8WDqMm2HWesV0m/v0imZvQBmAwres297avAA1oDx03QLHhJ53LpSpxdRw3IxQ4ui09p1 fJAEiZdIJilhdNNogBn2zxGiAVNYTh7SZt2pR5m8aI7bm87xZeJBkg0jNAEw8/G4YQZ/ UxXBYnI4jCtwBz5YEXj9OZ+SrF+ZLhXCTd31//IEGRU8jnrBrVeJdr9HOH5az4R3kfGw 5gCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=E5aJ46Lu; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id y1si1849142edl.361.2018.01.05.08.17.49; Fri, 05 Jan 2018 08:17:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=E5aJ46Lu; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 8BC24C21EC8; Fri, 5 Jan 2018 16:17:00 +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=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 ED22EC21E67; Fri, 5 Jan 2018 16:16:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 17920C21DA2; Fri, 5 Jan 2018 16:16:45 +0000 (UTC) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by lists.denx.de (Postfix) with ESMTPS id DD628C21E88 for ; Fri, 5 Jan 2018 16:16:40 +0000 (UTC) Received: by mail-pf0-f194.google.com with SMTP id v26so2353748pfl.7 for ; Fri, 05 Jan 2018 08:16:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F533tfAJ6xYs6goCVvocOaf3r3E7do2cYZw5whOpi/M=; b=E5aJ46LuKbhqrCcszibw0Zfu2O/dO5UCTem+UjMHAVSNdCj7anLASRK/595vmC6jbt fj0b4xWCK8mNU6Ug4K8jUBksmcSNJ6/5hdZ2jULwitVVKsw/gV0RwXXStDtueFOIgoLF PtST4fmoMOAJ1mvKA5lCF9nSZT7GKBolF/wYI= 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:in-reply-to :references; bh=F533tfAJ6xYs6goCVvocOaf3r3E7do2cYZw5whOpi/M=; b=RbYDPELMukhbewXribAr6Da+LSkFADlqq+NJGMzRHIx9oqdwLIuGN/UVPyN/m1EWae ZxpM+FG+JnIbf4Irm1CsmEGNosz02MWPMrdR2Ja1BjgX4AHaDDwoPy24XJuXGvZodIlA Z289Dwh1M3HZHKnQKbPLVnSS7Bw+r/isj0xkjklM1NidSXSDrdrRuebmfvfYvwfVFgoR JSB2W8gzfGtC/AggJBd/9gCC0r+PWpPw3qRxJw4SCgZntMfnZxmXuOBYsFTOYYQ7wgTV 7h5yVU8+SuQDRZzspUQqVRfXvxK1viJYW33GrS8gr5ENiBPDwfE3AfnWG6ajP9XugwNx 6YZQ== X-Gm-Message-State: AKGB3mLDsxLFJDu5xNJI8SsAwJzhWezqhr6B4+4E0ruCxAE9Te8ksZPI Q002L01gH1nLlvPOnF7PSg15RcufjKk= X-Received: by 10.101.100.202 with SMTP id t10mr3006402pgv.21.1515168999516; Fri, 05 Jan 2018 08:16:39 -0800 (PST) Received: from localhost.localdomain (61-216-91-114.HINET-IP.hinet.net. [61.216.91.114]) by smtp.gmail.com with ESMTPSA id k80sm14337459pfh.30.2018.01.05.08.16.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jan 2018 08:16:38 -0800 (PST) From: Jun Nie To: jagannadh.teki@gmail.com, wens@csie.org, maxime.ripard@free-electrons.com, hdegoede@redhat.com Date: Sat, 6 Jan 2018 00:15:55 +0800 Message-Id: <1515168960-18960-4-git-send-email-jun.nie@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1515168960-18960-1-git-send-email-jun.nie@linaro.org> References: <1515168960-18960-1-git-send-email-jun.nie@linaro.org> Cc: u-boot@lists.denx.de Subject: [U-Boot] [[PATCH v2] 3/8] sunxi: Fix USB PHY index for H3/H5/A64 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: Chen-Yu Tsai On the new chips such as H3, H5, and A64, the USB OTG controller is paired with a set of proper EHCI/OHCI USB hosts. To enable these hosts, the USB PHY index count has to be reworked to start from this pair. This patch reworks the USB clock gate and reset indices, and how the USB host is mapped to a USB phy, for the newer chips. Signed-off-by: Chen-Yu Tsai --- arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 30 +++++++++++++-------------- drivers/usb/host/ehci-sunxi.c | 9 +++++++- drivers/usb/host/ohci-sunxi.c | 9 +++++++- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h index d328df9..2c82d0a 100644 --- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h +++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h @@ -270,17 +270,18 @@ struct sunxi_ccm_reg { #define AXI_GATE_OFFSET_DRAM 0 /* ahb_gate0 offsets */ +#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I) +#define AHB_GATE_OFFSET_USB_OHCI3 31 +#define AHB_GATE_OFFSET_USB_OHCI2 30 +#define AHB_GATE_OFFSET_USB_OHCI1 29 +#define AHB_GATE_OFFSET_USB_OHCI0 28 +#define AHB_GATE_OFFSET_USB_EHCI3 27 +#define AHB_GATE_OFFSET_USB_EHCI2 26 +#define AHB_GATE_OFFSET_USB_EHCI1 25 +#define AHB_GATE_OFFSET_USB_EHCI0 24 +#else #define AHB_GATE_OFFSET_USB_OHCI1 30 #define AHB_GATE_OFFSET_USB_OHCI0 29 -#ifdef CONFIG_MACH_SUNXI_H3_H5 -/* - * These are EHCI1 - EHCI3 in the datasheet (EHCI0 is for the OTG) we call - * them 0 - 2 like they were called on older SoCs. - */ -#define AHB_GATE_OFFSET_USB_EHCI2 27 -#define AHB_GATE_OFFSET_USB_EHCI1 26 -#define AHB_GATE_OFFSET_USB_EHCI0 25 -#else #define AHB_GATE_OFFSET_USB_EHCI1 27 #define AHB_GATE_OFFSET_USB_EHCI0 26 #endif @@ -339,13 +340,10 @@ struct sunxi_ccm_reg { #define CCM_USB_CTRL_PHY2_CLK (0x1 << 10) #define CCM_USB_CTRL_PHY3_CLK (0x1 << 11) #ifdef CONFIG_MACH_SUNXI_H3_H5 -/* - * These are OHCI1 - OHCI3 in the datasheet (OHCI0 is for the OTG) we call - * them 0 - 2 like they were called on older SoCs. - */ -#define CCM_USB_CTRL_OHCI0_CLK (0x1 << 17) -#define CCM_USB_CTRL_OHCI1_CLK (0x1 << 18) -#define CCM_USB_CTRL_OHCI2_CLK (0x1 << 19) +#define CCM_USB_CTRL_OHCI0_CLK (0x1 << 16) +#define CCM_USB_CTRL_OHCI1_CLK (0x1 << 17) +#define CCM_USB_CTRL_OHCI2_CLK (0x1 << 18) +#define CCM_USB_CTRL_OHCI3_CLK (0x1 << 19) #else #define CCM_USB_CTRL_OHCI0_CLK (0x1 << 16) #define CCM_USB_CTRL_OHCI1_CLK (0x1 << 17) diff --git a/drivers/usb/host/ehci-sunxi.c b/drivers/usb/host/ehci-sunxi.c index 6ecb7c4..f40228e 100644 --- a/drivers/usb/host/ehci-sunxi.c +++ b/drivers/usb/host/ehci-sunxi.c @@ -48,10 +48,17 @@ static int ehci_usb_probe(struct udevice *dev) #if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I) extra_ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_OHCI0; #endif +#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I) + /* Newer chips have a EHCI/OHCI host pair for OTG host mode */ + priv->phy_index = ((uintptr_t)hccr - SUNXI_USB0_BASE) / BASE_DIST; +#else priv->phy_index = ((uintptr_t)hccr - SUNXI_USB1_BASE) / BASE_DIST; +#endif priv->ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST; extra_ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST; - priv->phy_index++; /* Non otg phys start at 1 */ +#if !defined(CONFIG_MACH_SUNXI_H3_H5) && !defined(CONFIG_MACH_SUN50I) + priv->phy_index++; /* older chips do not have EHCI with OTG */ +#endif setbits_le32(&ccm->ahb_gate0, priv->ahb_gate_mask | extra_ahb_gate_mask); diff --git a/drivers/usb/host/ohci-sunxi.c b/drivers/usb/host/ohci-sunxi.c index 133774f..4b8a403 100644 --- a/drivers/usb/host/ohci-sunxi.c +++ b/drivers/usb/host/ohci-sunxi.c @@ -51,11 +51,18 @@ static int ohci_usb_probe(struct udevice *dev) extra_ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_EHCI0; #endif priv->usb_gate_mask = CCM_USB_CTRL_OHCI0_CLK; +#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I) + /* Newer chips have a EHCI/OHCI host pair for OTG host mode */ + priv->phy_index = ((uintptr_t)regs - (SUNXI_USB0_BASE + 0x400)) / BASE_DIST; +#else priv->phy_index = ((uintptr_t)regs - (SUNXI_USB1_BASE + 0x400)) / BASE_DIST; +#endif priv->ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST; extra_ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST; priv->usb_gate_mask <<= priv->phy_index; - priv->phy_index++; /* Non otg phys start at 1 */ +#if !defined(CONFIG_MACH_SUNXI_H3_H5) && !defined(CONFIG_MACH_SUN50I) + priv->phy_index++; /* older chips do not have OHCI with OTG */ +#endif setbits_le32(&ccm->ahb_gate0, priv->ahb_gate_mask | extra_ahb_gate_mask);