From patchwork Thu Jul 23 08:26:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 499247 X-Patchwork-Delegate: prafulla@marvell.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id A1799140D19 for ; Thu, 23 Jul 2015 18:26:41 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 150054B958; Thu, 23 Jul 2015 10:26:35 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8M2RxRKErqiJ; Thu, 23 Jul 2015 10:26:34 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 677514B950; Thu, 23 Jul 2015 10:26:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 65C2F4B93A for ; Thu, 23 Jul 2015 10:26:24 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 21fkYbeXdEBU for ; Thu, 23 Jul 2015 10:26:24 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mo4-p04-ob.smtp.rzone.de (mo4-p04-ob.smtp.rzone.de [81.169.146.176]) by theia.denx.de (Postfix) with ESMTPS id 29F7F4B939 for ; Thu, 23 Jul 2015 10:26:22 +0200 (CEST) X-RZG-CLASS-ID: mo04 X-RZG-AUTH: :IW0NeWC7b/q2i6W/qstXb1SBUuFnrGohfvxEndrDXKjzPMsB3oimjD61I4fPQhgcxmga7w== Received: from stefan-work.domain_not_set.invalid (b9168f96.cgn.dg-w.de [185.22.143.150]) by post.strato.de (RZmta 37.8 SBL|AUTH) with ESMTPA id e03bd1r6N8QLKMT; Thu, 23 Jul 2015 10:26:21 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Date: Thu, 23 Jul 2015 10:26:19 +0200 Message-Id: <1437639980-16286-9-git-send-email-sr@denx.de> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1437639980-16286-1-git-send-email-sr@denx.de> References: <1437639980-16286-1-git-send-email-sr@denx.de> Cc: Marek Vasut , Luka Perkov Subject: [U-Boot] [PATCH 09/10] arm: mvebu: Enable USB EHCI support on Armada XP X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" This patch enables the USB EHCI support for the Marvell Armada XP (AXP) SoCs. In compatism to the Armada 38x (A38x), the AXP needs to configure the USB PLL and the USB PHY's specifically in U-Boot. The A38x has done this already in the bin_hdr (SPL U-Boot). Without this, accessing the controller registers in U-Boot or Linux will hang the CPU. Additionally, the AXP uses a different USB EHCI base address. This patch also takes care of this by runtime SoC detection in the Marvell EHCI driver. Signed-off-by: Stefan Roese Signed-off-by: Anton Schubert Cc: Marek Vasut Cc: Luka Perkov --- arch/arm/mach-mvebu/cpu.c | 58 ++++++++++++++++++++++++++++++++++ arch/arm/mach-mvebu/include/mach/soc.h | 1 + drivers/usb/host/ehci-marvell.c | 9 +++++- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c index bde3990..0a31b85 100644 --- a/arch/arm/mach-mvebu/cpu.c +++ b/arch/arm/mach-mvebu/cpu.c @@ -179,6 +179,61 @@ static void set_cbar(u32 addr) asm("mcr p15, 4, %0, c15, c0" : : "r" (addr)); } +#define MV_USB_PHY_BASE (MVEBU_AXP_USB_BASE + 0x800) +#define MV_USB_PHY_PLL_REG(reg) (MV_USB_PHY_BASE | ((reg & 0xF) << 2)) +#define MV_USB_X3_BASE(addr) (MVEBU_AXP_USB_BASE | BIT(11) | \ + (((addr) & 0xF) << 6)) +#define MV_USB_X3_PHY_CHANNEL(dev, reg) (MV_USB_X3_BASE(dev + 1) | \ + ((reg & 0xF) << 2)) + +static void setup_usb_phys(void) +{ + u32 val; + int dev; + + /* + * USB PLL init + */ + + /* Setup PLL frequency */ + val = readl(MV_USB_PHY_PLL_REG(1)); + val &= ~(0x3FF); + val |= 0x605; /* USB REF frequency = 25 MHz */ + writel(val, MV_USB_PHY_PLL_REG(1)); + + /* Power up PLL and PHY channel */ + val = readl(MV_USB_PHY_PLL_REG(2)); + val |= BIT(9); + writel(val, MV_USB_PHY_PLL_REG(2)); + + /* Assert VCOCAL_START */ + val = readl(MV_USB_PHY_PLL_REG(1)); + val |= BIT(21); + writel(val, MV_USB_PHY_PLL_REG(1)); + + mdelay(1); + + /* + * USB PHY init (change from defaults) specific for 40nm (78X30 78X60) + */ + + for (dev = 0; dev < 3; dev++) { + val = readl(MV_USB_X3_PHY_CHANNEL(dev, 3)); + val |= BIT(15); + writel(val, MV_USB_X3_PHY_CHANNEL(dev, 3)); + + /* Assert REG_RCAL_START in Channel REG 1 */ + val = readl(MV_USB_X3_PHY_CHANNEL(dev, 1)); + val |= BIT(12); + writel(val, MV_USB_X3_PHY_CHANNEL(dev, 1)); + + udelay(40); + + val = readl(MV_USB_X3_PHY_CHANNEL(dev, 1)); + val &= ~BIT(12); + writel(val, MV_USB_X3_PHY_CHANNEL(dev, 1)); + } +} int arch_cpu_init(void) { @@ -249,6 +304,9 @@ int arch_cpu_init(void) reg |= GE0_PUP_EN | GE1_PUP_EN | LCD_PUP_EN | NAND_PUP_EN | SPI_PUP_EN; writel(reg, ARMADA_XP_PUP_ENABLE); + + /* Configure USB PLL and PHYs on AXP */ + setup_usb_phys(); } /* Enable NAND and NAND arbiter */ diff --git a/arch/arm/mach-mvebu/include/mach/soc.h b/arch/arm/mach-mvebu/include/mach/soc.h index 6115d6e..a8a6b27 100644 --- a/arch/arm/mach-mvebu/include/mach/soc.h +++ b/arch/arm/mach-mvebu/include/mach/soc.h @@ -65,6 +65,7 @@ #define MVEBU_EGIGA2_BASE (MVEBU_REGISTER(0x30000)) #define MVEBU_EGIGA3_BASE (MVEBU_REGISTER(0x34000)) #define MVEBU_REG_PCIE_BASE (MVEBU_REGISTER(0x40000)) +#define MVEBU_AXP_USB_BASE (MVEBU_REGISTER(0x50000)) #define MVEBU_USB20_BASE (MVEBU_REGISTER(0x58000)) #define MVEBU_EGIGA0_BASE (MVEBU_REGISTER(0x70000)) #define MVEBU_EGIGA1_BASE (MVEBU_REGISTER(0x74000)) diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c index 03c489c..826e7f7 100644 --- a/drivers/usb/host/ehci-marvell.c +++ b/drivers/usb/host/ehci-marvell.c @@ -33,7 +33,14 @@ DECLARE_GLOBAL_DATA_PTR; */ #ifdef CONFIG_ARMADA_XP -#define MVUSB0_BASE MVEBU_USB20_BASE +/* + * Armada XP and Armada 38x have different base addresses for + * the USB 2.0 EHCI host controller. So we need to provide + * a mechnism to support both here. + */ +#define MVUSB0_BASE \ + (mvebu_soc_family() == MVEBU_SOC_A38X ? \ + MVEBU_USB20_BASE : MVEBU_AXP_USB_BASE) /* * Once all the older Marvell SoC's (Orion, Kirkwood) are converted