public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 09/10] arm: mvebu: Enable USB EHCI support on Armada XP
Date: Thu, 23 Jul 2015 10:38:42 +0200	[thread overview]
Message-ID: <201507231038.43024.marex@denx.de> (raw)
In-Reply-To: <1437639980-16286-9-git-send-email-sr@denx.de>

On Thursday, July 23, 2015 at 10:26:19 AM, Stefan Roese wrote:
> 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 <sr@denx.de>
> Signed-off-by: Anton Schubert <anton.schubert@gmx.de>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Luka Perkov <luka.perkov@sartura.hr>
> ---
>  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))

(reg) in the macro please.

> +#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))

Same here.

> +
> +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));

Please use clrsetbits_le32() and friends :)

> +	/* 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))

The () around MVEBU_REGISTER() shouldn't be needed btw ;-)

  reply	other threads:[~2015-07-23  8:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23  8:26 [U-Boot] [PATCH 01/10] arm: marvell: Increase MAXARGS to 32 Stefan Roese
2015-07-23  8:26 ` [U-Boot] [PATCH 02/10] arm: mvebu: Change MBUS base addresses and sizes Stefan Roese
2015-07-23  8:26 ` [U-Boot] [PATCH 03/10] arm: mvebu: Setup the MBUS bridge registers Stefan Roese
2015-07-23  8:26 ` [U-Boot] [PATCH 04/10] arm: mvebu: Flush caches and disable MMU only on A38x Stefan Roese
2015-07-23  8:26 ` [U-Boot] [PATCH 05/10] arm: mvebu: Disable MBUS error propagation Stefan Roese
2015-07-23  8:26 ` [U-Boot] [PATCH 06/10] mtd: nand: Add mvebu (PXA / AXP / A38x) NAND device driver Stefan Roese
2015-07-23  8:26 ` [U-Boot] [PATCH 07/10] arm: mvebu: Enable NAND controller on MVEBU SoC's Stefan Roese
2015-07-23  8:26 ` [U-Boot] [PATCH 08/10] arm: mvebu: Enable NAND on db-mv784mp-gp Stefan Roese
2015-07-23  8:26 ` [U-Boot] [PATCH 09/10] arm: mvebu: Enable USB EHCI support on Armada XP Stefan Roese
2015-07-23  8:38   ` Marek Vasut [this message]
2015-07-23  8:26 ` [U-Boot] [PATCH 10/10] arm: mvebu: db-mv785mp-gp: Add USB/EHCI support Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201507231038.43024.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox