Skip to contentSkip to conversation

arm: marvell: Increase MAXARGS to 32

PATCH New Stefan Roese 2 participants 11 messages Jul 23, 2015

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

PATCH 1/10 arm: marvell: Increase MAXARGS to 32

This makes more complex U-Boot scripts possible.

---
 include/configs/mv-common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/configs/mv-common.h +1 -1
index b654fff..b90de14 100644
@@ -95,7 +95,7 @@
 #define CONFIG_SYS_MEMTEST_START 0x00800000	/* 8M */
 #define CONFIG_SYS_MEMTEST_END	0x00ffffff	/*(_16M -1) */
 #define CONFIG_SYS_RESET_ADDRESS 0xffff0000	/* Rst Vector Adr */
-#define CONFIG_SYS_MAXARGS	16	/* max number of command args */
+#define CONFIG_SYS_MAXARGS	32	/* max number of command args */
 
 /* ====> Include platform Common Definitions */
 #include <asm/arch/config.h>
Signature · 1 line
2.4.6
#1 lore raw

PATCH 2/10 arm: mvebu: Change MBUS base addresses and sizes

This patch changes the MBUS base addresses and sizes to use more generic names and also adds defines for the sizes. It also moves the base address to higher addresses.

---
 arch/arm/mach-mvebu/cpu.c              | 14 ++++++++------
 arch/arm/mach-mvebu/include/mach/cpu.h | 12 ++++++++----
 2 files changed, 16 insertions(+), 10 deletions(-)
arch/arm/mach-mvebu/cpu.c +8 -6
index 9496d5f..7335620 100644
@@ -19,18 +19,20 @@
 
 static struct mbus_win windows[] = {
 	/* PCIE MEM address space */
-	{ DEFADR_PCI_MEM, 256 << 20, CPU_TARGET_PCIE13, CPU_ATTR_PCIE_MEM },
+	{ MBUS_PCI_MEM_BASE, MBUS_PCI_MEM_SIZE,
+	  CPU_TARGET_PCIE13, CPU_ATTR_PCIE_MEM },
 
 	/* PCIE IO address space */
-	{ DEFADR_PCI_IO, 64 << 10, CPU_TARGET_PCIE13, CPU_ATTR_PCIE_IO },
+	{ MBUS_PCI_IO_BASE, MBUS_PCI_IO_SIZE,
+	  CPU_TARGET_PCIE13, CPU_ATTR_PCIE_IO },
 
 	/* SPI */
-	{ DEFADR_SPIF, 8 << 20, CPU_TARGET_DEVICEBUS_BOOTROM_SPI,
-	  CPU_ATTR_SPIFLASH },
+	{ MBUS_SPI_BASE, MBUS_SPI_SIZE,
+	  CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_SPIFLASH },
 
 	/* NOR */
-	{ DEFADR_BOOTROM, 8 << 20, CPU_TARGET_DEVICEBUS_BOOTROM_SPI,
-	  CPU_ATTR_BOOTROM },
+	{ MBUS_BOOTROM_BASE, MBUS_BOOTROM_SIZE,
+	  CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_BOOTROM },
 };
 
 void reset_cpu(unsigned long ignored)
arch/arm/mach-mvebu/include/mach/cpu.h +8 -4
index 8bcdef6..674fdaa 100644
@@ -65,10 +65,14 @@ enum {
 /*
  * Default Device Address MAP BAR values
  */
-#define DEFADR_PCI_MEM		0x90000000
-#define DEFADR_PCI_IO		0xC0000000
-#define DEFADR_SPIF		0xF4000000
-#define DEFADR_BOOTROM		0xF8000000
+#define MBUS_PCI_MEM_BASE	0xE8000000
+#define MBUS_PCI_MEM_SIZE	(128 << 20)
+#define MBUS_PCI_IO_BASE	0xF1100000
+#define MBUS_PCI_IO_SIZE	(64 << 10)
+#define MBUS_SPI_BASE		0xF4000000
+#define MBUS_SPI_SIZE		(8 << 20)
+#define MBUS_BOOTROM_BASE	0xF8000000
+#define MBUS_BOOTROM_SIZE	(8 << 20)
 
 struct mbus_win {
 	u32 base;
Signature · 1 line
2.4.6
#2 lore raw

PATCH 3/10 arm: mvebu: Setup the MBUS bridge registers

In reply to Stefan Roese

With this patch, the MBUS bridge registers (base and size) are configured upon each call to mbus_dt_setup_win(). This is needed, since the board code can also call this function in later boot stages. As done in the maxbcm board.

This is needed to fix a problem with the secondary CPU's not booting in Linux on AXP.

Cc Peter Morrow <[email protected]>
Cc Luka Perkov <[email protected]>
---
 arch/arm/mach-mvebu/include/mach/soc.h |  3 ++
 arch/arm/mach-mvebu/mbus.c             | 55 ++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
arch/arm/mach-mvebu/include/mach/soc.h +3 -0
index 125b5f2..71254c5 100644
@@ -66,6 +66,9 @@
 #define MVEBU_SATA0_BASE	(MVEBU_REGISTER(0xa8000))
 #define MVEBU_SDIO_BASE		(MVEBU_REGISTER(0xd8000))
 
+#define MBUS_BRIDGE_WIN_CTRL_REG (MVEBU_REGISTER(0x20250))
+#define MBUS_BRIDGE_WIN_BASE_REG (MVEBU_REGISTER(0x20254))
+
 #define SDRAM_MAX_CS		4
 #define SDRAM_ADDR_MASK		0xFF000000
 
arch/arm/mach-mvebu/mbus.c +55 -0

73 lines not on this page · raw message

Signature · 1 line
2.4.6
#3 lore raw

PATCH 4/10 arm: mvebu: Flush caches and disable MMU only on A38x

In reply to Stefan Roese

Only with disabled MMU its possible to switch the base register address on Armada 38x. Without this the SDRAM located at >= 0x4000.0000 is also not accessible, as its still locked to cache.

So to fully release / unlock this area from cache, we need to first flush all caches, then disable the MMU and disable the L2 cache.

On Armada XP this does not seem to be needed. Even worse, with this code added, I sometimes see strange input charactes loss from the console.

---
 arch/arm/mach-mvebu/cpu.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
arch/arm/mach-mvebu/cpu.c +19 -7
index 7335620..23c2a97 100644
@@ -183,13 +183,25 @@ static void set_cbar(u32 addr)
 int arch_cpu_init(void)
 {
 #ifndef CONFIG_SPL_BUILD
-	/*
-	 * Only with disabled MMU its possible to switch the base
-	 * register address on Armada 38x. Without this the SDRAM
-	 * located at >= 0x4000.0000 is also not accessible, as its
-	 * still locked to cache.
-	 */
-	mmu_disable();
+	if (mvebu_soc_family() == MVEBU_SOC_A38X) {
+		struct pl310_regs *const pl310 =
+			(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
+
+		/*
+		 * Only with disabled MMU its possible to switch the base
+		 * register address on Armada 38x. Without this the SDRAM
+		 * located at >= 0x4000.0000 is also not accessible, as its
+		 * still locked to cache.
+		 *
+		 * So to fully release / unlock this area from cache, we need
+		 * to first flush all caches, then disable the MMU and
+		 * disable the L2 cache.
+		 */
+		icache_disable();
+		dcache_disable();
+		mmu_disable();
+		clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
+	}
 #endif
 
 	/* Linux expects the internal registers to be at 0xf1000000 */
Signature · 1 line
2.4.6
#4 lore raw

PATCH 5/10 arm: mvebu: Disable MBUS error propagation

In reply to Stefan Roese

Accessing MBUS windows not backed-up by e.g. PCIe devices will hang the SoC. Disable MBUS error propagation back to CPU allows to read 0xffffffff instead of hanging the SoC.

---
 arch/arm/mach-mvebu/cpu.c              | 7 +++++++
 arch/arm/mach-mvebu/include/mach/soc.h | 3 +++
 2 files changed, 10 insertions(+)
arch/arm/mach-mvebu/cpu.c +7 -0
index 23c2a97..451f308 100644
@@ -182,6 +182,8 @@ static void set_cbar(u32 addr)
 
 int arch_cpu_init(void)
 {
+	u32 reg;
+
 #ifndef CONFIG_SPL_BUILD
 	if (mvebu_soc_family() == MVEBU_SOC_A38X) {
 		struct pl310_regs *const pl310 =
@@ -241,6 +243,11 @@ int arch_cpu_init(void)
 	 */
 	mvebu_mbus_probe(windows, ARRAY_SIZE(windows));
 
+	/* Disable MBUS error propagation */
+	reg = readl(SOC_COHERENCY_FABRIC_CTRL_REG);
+	reg &= ~MBUS_ERR_PROP_EN;
+	writel(reg, SOC_COHERENCY_FABRIC_CTRL_REG);
+
 	return 0;
 }
 #endif /* CONFIG_ARCH_CPU_INIT */
arch/arm/mach-mvebu/include/mach/soc.h +3 -0
index 71254c5..a29e5dc 100644
@@ -66,6 +66,9 @@
 #define MVEBU_SATA0_BASE	(MVEBU_REGISTER(0xa8000))
 #define MVEBU_SDIO_BASE		(MVEBU_REGISTER(0xd8000))
 
+#define SOC_COHERENCY_FABRIC_CTRL_REG	(MVEBU_REGISTER(0x20200))
+#define MBUS_ERR_PROP_EN	(1 << 8)
+
 #define MBUS_BRIDGE_WIN_CTRL_REG (MVEBU_REGISTER(0x20250))
 #define MBUS_BRIDGE_WIN_BASE_REG (MVEBU_REGISTER(0x20254))
 
Signature · 1 line
2.4.6
#5 lore raw

PATCH 6/10 mtd: nand: Add mvebu (PXA / AXP / A38x) NAND device driver

In reply to Stefan Roese

Cloned from the Linux driver v4.2.0-rc2. Plus some patches from Antoine Tenart enabling controller initialization and ONFI timing support:

http://lists.infradead.org/pipermail/linux-mtd/2015-July/060197.html

Please note that this driver needs the Linux NAND subsystem sync to v4.1 from Scott to be applied:

https://www.mail-archive.com/u-boot at lists.denx.de/msg175762.html

Otherwise it will not compile.

Tested on the Marvell Armada XP DB-MV784MP-GP eval board.

Cc Antoine Tenart <[email protected]>
Cc Ezeguil Garcia <[email protected]>
Cc Luka Perkov <[email protected]>
Cc Scott Wood <[email protected]>
---
 drivers/mtd/nand/Kconfig       |    7 +
 drivers/mtd/nand/Makefile      |    1 +
 drivers/mtd/nand/pxa3xx_nand.c | 1621 ++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/pxa3xx_nand.h |   64 ++
 4 files changed, 1693 insertions(+)
 create mode 100644 drivers/mtd/nand/pxa3xx_nand.c
 create mode 100644 drivers/mtd/nand/pxa3xx_nand.h
drivers/mtd/nand/Kconfig +7 -0
index 3024357..6fd2a34 100644
@@ -56,6 +56,13 @@ config SYS_NAND_VF610_NFC_60_ECC_BYTES
 
 endchoice
 
+config NAND_PXA3XX
+	bool "Support for NAND on PXA3xx and Armada 370/XP/38x"
+	select SYS_NAND_SELF_INIT
+	help
+	  This enables the driver for the NAND flash device found on
+	  PXA3xx processors (NFCv1) and also on Armada 370/XP (NFCv2).
+
 comment "Generic NAND options"
 
 # Enhance depends when converting drivers to Kconfig which use this config
drivers/mtd/nand/Makefile +1 -0
index 347ea62..c777a58 100644
@@ -59,6 +59,7 @@ obj-$(CONFIG_NAND_MXC) += mxc_nand.o
 obj-$(CONFIG_NAND_MXS) += mxs_nand.o
 obj-$(CONFIG_NAND_NDFC) += ndfc.o
 obj-$(CONFIG_NAND_NOMADIK) += nomadik.o
+obj-$(CONFIG_NAND_PXA3XX) += pxa3xx_nand.o
 obj-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o
 obj-$(CONFIG_NAND_SPEAR) += spr_nand.o
 obj-$(CONFIG_TEGRA_NAND) += tegra_nand.o
drivers/mtd/nand/pxa3xx_nand.c new file +1621 -0

1,621 lines not on this page · raw message

drivers/mtd/nand/pxa3xx_nand.h new file +64 -0

64 lines not on this page · raw message

Signature · 1 line
2.4.6
#6 lore raw

PATCH 7/10 arm: mvebu: Enable NAND controller on MVEBU SoC's

In reply to Stefan Roese

This patch enables the NAND controller on the Armada XP/38x and provides a new function that returns the NAND controller input clock. This function will be used by the MVEBU NAND driver.

As part of this patch, the multiple BIT macro definitions are moved to a common place in soc.h.

Cc Peter Morrow <[email protected]>
Cc Luka Perkov <[email protected]>
---
 arch/arm/mach-mvebu/cpu.c                   | 20 ++++++++++++++++++++
 arch/arm/mach-mvebu/include/mach/cpu.h      |  1 +
 arch/arm/mach-mvebu/include/mach/soc.h      | 22 ++++++++++++++++++++++
 arch/arm/mach-mvebu/mbus.c                  |  2 --
 board/Marvell/db-88f6820-gp/db-88f6820-gp.c |  2 --
 board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c |  2 --
 drivers/net/mvneta.c                        |  1 -
 7 files changed, 43 insertions(+), 7 deletions(-)
arch/arm/mach-mvebu/cpu.c +20 -0
index 451f308..bde3990 100644
@@ -243,6 +243,19 @@ int arch_cpu_init(void)
 	 */
 	mvebu_mbus_probe(windows, ARRAY_SIZE(windows));
 
+	if (mvebu_soc_family() == MVEBU_SOC_AXP) {
+		/* Enable GBE0, GBE1, LCD and NFC PUP */
+		reg = readl(ARMADA_XP_PUP_ENABLE);
+		reg |= GE0_PUP_EN | GE1_PUP_EN | LCD_PUP_EN |
+			NAND_PUP_EN | SPI_PUP_EN;
+		writel(reg, ARMADA_XP_PUP_ENABLE);
+	}
+
+	/* Enable NAND and NAND arbiter */
+	reg = readl(MVEBU_SOC_DEV_MUX_REG);
+	reg |= NAND_EN | NAND_ARBITER_EN;
+	writel(reg, MVEBU_SOC_DEV_MUX_REG);
+
 	/* Disable MBUS error propagation */
 	reg = readl(SOC_COHERENCY_FABRIC_CTRL_REG);
 	reg &= ~MBUS_ERR_PROP_EN;
@@ -252,6 +265,13 @@ int arch_cpu_init(void)
 }
 #endif /* CONFIG_ARCH_CPU_INIT */
 
+u32 mvebu_get_nand_clock(void)
+{
+	return CONFIG_SYS_MVEBU_PLL_CLOCK /
+		((readl(MVEBU_CORE_DIV_CLK_CTRL(1)) &
+		  NAND_ECC_DIVCKL_RATIO_MASK) >> NAND_ECC_DIVCKL_RATIO_OFFS);
+}
+
 /*
  * SOC specific misc init
  */
arch/arm/mach-mvebu/include/mach/cpu.h +1 -0
index 674fdaa..6fa4173 100644
@@ -117,6 +117,7 @@ unsigned int mvebu_sdram_bs(enum memory_bank bank);
 void mvebu_sdram_size_adjust(enum memory_bank bank);
 int mvebu_mbus_probe(struct mbus_win windows[], int count);
 int mvebu_soc_family(void);
+u32 mvebu_get_nand_clock(void);
 
 int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks);
 
arch/arm/mach-mvebu/include/mach/soc.h +22 -0
index a29e5dc..6115d6e 100644
@@ -11,6 +11,8 @@
 #ifndef _MVEBU_SOC_H
 #define _MVEBU_SOC_H
 
+#define BIT(x)			(1 << (x))
+
 #define SOC_MV78460_ID		0x7846
 #define SOC_88F6810_ID		0x6810
 #define SOC_88F6820_ID		0x6820
@@ -25,6 +27,9 @@
 #define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 #endif
 
+/* Armada XP PLL frequency (used for NAND clock generation) */
+#define CONFIG_SYS_MVEBU_PLL_CLOCK	2000000000
+
 /* SOC specific definations */
 #define INTREG_BASE		0xd0000000
 #define INTREG_BASE_ADDR_REG	(INTREG_BASE + 0x20080)
@@ -53,6 +58,7 @@
 #define MVEBU_GPIO1_BASE	(MVEBU_REGISTER(0x18140))
 #define MVEBU_GPIO2_BASE	(MVEBU_REGISTER(0x18180))
 #define MVEBU_SYSTEM_REG_BASE	(MVEBU_REGISTER(0x18200))
+#define MVEBU_CLOCK_BASE	(MVEBU_REGISTER(0x18700))
 #define MVEBU_CPU_WIN_BASE	(MVEBU_REGISTER(0x20000))
 #define MVEBU_SDRAM_BASE	(MVEBU_REGISTER(0x20180))
 #define MVEBU_TIMER_BASE	(MVEBU_REGISTER(0x20300))
@@ -64,6 +70,7 @@
 #define MVEBU_EGIGA1_BASE	(MVEBU_REGISTER(0x74000))
 #define MVEBU_AXP_SATA_BASE	(MVEBU_REGISTER(0xa0000))
 #define MVEBU_SATA0_BASE	(MVEBU_REGISTER(0xa8000))
+#define MVEBU_NAND_BASE		(MVEBU_REGISTER(0xd0000))
 #define MVEBU_SDIO_BASE		(MVEBU_REGISTER(0xd8000))
 
 #define SOC_COHERENCY_FABRIC_CTRL_REG	(MVEBU_REGISTER(0x20200))
@@ -72,6 +79,21 @@
 #define MBUS_BRIDGE_WIN_CTRL_REG (MVEBU_REGISTER(0x20250))
 #define MBUS_BRIDGE_WIN_BASE_REG (MVEBU_REGISTER(0x20254))
 
+#define MVEBU_SOC_DEV_MUX_REG	(MVEBU_SYSTEM_REG_BASE + 0x08)
+#define NAND_EN			BIT(0)
+#define NAND_ARBITER_EN		BIT(27)
+
+#define ARMADA_XP_PUP_ENABLE	(MVEBU_SYSTEM_REG_BASE + 0x44c)
+#define GE0_PUP_EN		BIT(0)
+#define GE1_PUP_EN		BIT(1)
+#define LCD_PUP_EN		BIT(2)
+#define NAND_PUP_EN		BIT(4)
+#define SPI_PUP_EN		BIT(5)
+
+#define MVEBU_CORE_DIV_CLK_CTRL(i)	(MVEBU_CLOCK_BASE + ((i) * 0x8))
+#define NAND_ECC_DIVCKL_RATIO_OFFS	8
+#define NAND_ECC_DIVCKL_RATIO_MASK	(0x3F << NAND_ECC_DIVCKL_RATIO_OFFS)
+
 #define SDRAM_MAX_CS		4
 #define SDRAM_ADDR_MASK		0xFF000000
 
arch/arm/mach-mvebu/mbus.c +0 -2
index 71fa693..771cce6 100644
@@ -55,8 +55,6 @@
 #include <linux/compat.h>
 #include <linux/mbus.h>
 
-#define BIT(nr)			(1UL << (nr))
-
 /* DDR target is the same on all platforms */
 #define TARGET_DDR		0
 
board/Marvell/db-88f6820-gp/db-88f6820-gp.c +0 -2
index e661fa1..0eb17f6 100644
@@ -15,8 +15,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define BIT(nr)				(1UL << (nr))
-
 #define ETH_PHY_CTRL_REG		0
 #define ETH_PHY_CTRL_POWER_DOWN_BIT	11
 #define ETH_PHY_CTRL_POWER_DOWN_MASK	(1 << ETH_PHY_CTRL_POWER_DOWN_BIT)
board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c +0 -2
index 00ca878..78c7b7e 100644
@@ -12,8 +12,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define BIT(nr)				(1UL << (nr))
-
 #define ETH_PHY_CTRL_REG		0
 #define ETH_PHY_CTRL_POWER_DOWN_BIT	11
 #define ETH_PHY_CTRL_POWER_DOWN_MASK	(1 << ETH_PHY_CTRL_POWER_DOWN_BIT)
drivers/net/mvneta.c +0 -1
index efaae16..38ad14e 100644
@@ -41,7 +41,6 @@
 	printf(fmt, ##args)
 
 #define CONFIG_NR_CPUS		1
-#define BIT(nr)			(1UL << (nr))
 #define ETH_HLEN		14	/* Total octets in header */
 
 /* 2(HW hdr) 14(MAC hdr) 4(CRC) 32(extra for cache prefetch) */
Signature · 1 line
2.4.6
#7 lore raw

PATCH 8/10 arm: mvebu: Enable NAND on db-mv784mp-gp

In reply to Stefan Roese

This patch enables NAND support on the Marvell Armada XP DB-MV784MP-GP eval board.

Cc Peter Morrow <[email protected]>
Cc Luka Perkov <[email protected]>
---
 configs/db-mv784mp-gp_defconfig | 1 +
 include/configs/db-mv784mp-gp.h | 5 +++++
 2 files changed, 6 insertions(+)
configs/db-mv784mp-gp_defconfig +1 -0
index d11377f..c9859a8 100644
@@ -4,4 +4,5 @@ CONFIG_SPL=y
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_NAND_PXA3XX=y
 CONFIG_SPI_FLASH=y
include/configs/db-mv784mp-gp.h +5 -0
index 41e6fdc..6629fae 100644
@@ -28,6 +28,7 @@
 #define CONFIG_CMD_ENV
 #define CONFIG_CMD_I2C
 #define CONFIG_CMD_IDE
+#define CONFIG_CMD_NAND
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_SF
 #define CONFIG_CMD_SPI
@@ -89,6 +90,10 @@
 #define CONFIG_DOS_PARTITION
 #endif /* CONFIG_CMD_IDE */
 
+/* NAND */
+#define CONFIG_SYS_NAND_USE_FLASH_BBT
+#define CONFIG_SYS_NAND_ONFI_DETECTION
+
 /*
  * mv-common.h should be defined after CMD configs since it used them
  * to enable certain macros
Signature · 1 line
2.4.6
#8 lore raw

PATCH 9/10 arm: mvebu: Enable USB EHCI support on Armada XP

In reply to Stefan Roese

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.

---
 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(-)
arch/arm/mach-mvebu/cpu.c +58 -0
index bde3990..0a31b85 100644
@@ -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 */
arch/arm/mach-mvebu/include/mach/soc.h +1 -0
index 6115d6e..a8a6b27 100644
@@ -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))
drivers/usb/host/ehci-marvell.c +8 -1
index 03c489c..826e7f7 100644
@@ -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
Signature · 1 line
2.4.6
#10 lore raw

PATCH 10/10 arm: mvebu: db-mv785mp-gp: Add USB/EHCI support

In reply to Stefan Roese

This patch enabled the USB/EHCI support for the Marvell DB-MV784MP-GP Armada XP eval board.

Cc Anton Schubert <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Luka Perkov <[email protected]>
---
 include/configs/db-mv784mp-gp.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/configs/db-mv784mp-gp.h +7 -0
index 6629fae..6cddbda 100644
@@ -34,6 +34,7 @@
 #define CONFIG_CMD_SPI
 #define CONFIG_CMD_TFTPPUT
 #define CONFIG_CMD_TIME
+#define CONFIG_CMD_USB
 
 /* I2C */
 #define CONFIG_SYS_I2C
@@ -42,6 +43,12 @@
 #define CONFIG_SYS_I2C_SLAVE		0x0
 #define CONFIG_SYS_I2C_SPEED		100000
 
+/* USB/EHCI configuration */
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_EHCI_MARVELL
+#define CONFIG_EHCI_IS_TDI
+
 /* SPI NOR flash default params, used by sf commands */
 #define CONFIG_SF_DEFAULT_SPEED		1000000
 #define CONFIG_SF_DEFAULT_MODE		SPI_MODE_3
Signature · 1 line
2.4.6
#9 lore raw

PATCH 9/10 arm: mvebu: Enable USB EHCI support on Armada XP

In reply to Stefan Roese
Quoted 26 lines · Stefan Roese

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.

---
 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(-)
arch/arm/mach-mvebu/cpu.c +0 -0
index bde3990..0a31b85 100644

arch/arm/mach-mvebu/cpu.c static void set_cbar(u32 addr) · line 183

Quoted 5 lines
arch/arm/mach-mvebu/cpu.c +2 -0
@@ -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.

arch/arm/mach-mvebu/cpu.c static void set_cbar(u32 addr) · line 187

Quoted 4 lines
arch/arm/mach-mvebu/cpu.c +4 -0
+#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.

Quoted 5 lines
arch/arm/mach-mvebu/cpu.c +5 -0
+
+static void setup_usb_phys(void)
+{
+	u32 val;
+	int dev;

arch/arm/mach-mvebu/cpu.c static void set_cbar(u32 addr) · line 202

Quoted 10 lines
arch/arm/mach-mvebu/cpu.c +10 -0
+
+	/*
+	 * 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 :)

Quoted 51 lines
arch/arm/mach-mvebu/cpu.c +36 -0
+	/* 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 */
(quoted diff) +0 -0

b/arch/arm/mach-mvebu/include/mach/soc.h index 6115d6e..a8a6b27 100644

arch/arm/mach-mvebu/include/mach/soc.h line 71

Quoted 7 lines
arch/arm/mach-mvebu/include/mach/soc.h +1 -0
@@ -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 ;-)