Skip to contentSkip to conversation

Added 64-bit MMIO accessors for ARMv8

PATCH Superseded York Sun 3 participants 9 messages Jun 20, 2014 – Jun 23, 2014

Subsystems (5)

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

York Sun

author
#0 lore raw

PATCH v8 1/5 Added 64-bit MMIO accessors for ARMv8

From: "J. German Rivera" <[email protected]>

This is needed for accessing peripherals with 64-bit MMIO registers, from ARMv8 processors.

---
Change log
v8: no change
v7: no change
v6: no change
v5: no change
v4: no change
v3: no change

 arch/arm/include/asm/io.h |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/include/asm/io.h +8 -0
index 6a1f05a..95528dd 100644
@@ -70,10 +70,12 @@ static inline phys_addr_t virt_to_phys(void * vaddr)
 #define __arch_getb(a)			(*(volatile unsigned char *)(a))
 #define __arch_getw(a)			(*(volatile unsigned short *)(a))
 #define __arch_getl(a)			(*(volatile unsigned int *)(a))
+#define __arch_getq(a)			(*(volatile unsigned long long *)(a))
 
 #define __arch_putb(v,a)		(*(volatile unsigned char *)(a) = (v))
 #define __arch_putw(v,a)		(*(volatile unsigned short *)(a) = (v))
 #define __arch_putl(v,a)		(*(volatile unsigned int *)(a) = (v))
+#define __arch_putq(v,a)		(*(volatile unsigned long long *)(a) = (v))
 
 extern inline void __raw_writesb(unsigned long addr, const void *data,
 				 int bytelen)
@@ -123,10 +125,12 @@ extern inline void __raw_readsl(unsigned long addr, void *data, int longlen)
 #define __raw_writeb(v,a)	__arch_putb(v,a)
 #define __raw_writew(v,a)	__arch_putw(v,a)
 #define __raw_writel(v,a)	__arch_putl(v,a)
+#define __raw_writeq(v,a)	__arch_putq(v,a)
 
 #define __raw_readb(a)		__arch_getb(a)
 #define __raw_readw(a)		__arch_getw(a)
 #define __raw_readl(a)		__arch_getl(a)
+#define __raw_readq(a)		__arch_getq(a)
 
 /*
  * TODO: The kernel offers some more advanced versions of barriers, it might
@@ -139,10 +143,12 @@ extern inline void __raw_readsl(unsigned long addr, void *data, int longlen)
 #define writeb(v,c)	({ u8  __v = v; __iowmb(); __arch_putb(__v,c); __v; })
 #define writew(v,c)	({ u16 __v = v; __iowmb(); __arch_putw(__v,c); __v; })
 #define writel(v,c)	({ u32 __v = v; __iowmb(); __arch_putl(__v,c); __v; })
+#define writeq(v,c)	({ u64 __v = v; __iowmb(); __arch_putq(__v,c); __v; })
 
 #define readb(c)	({ u8  __v = __arch_getb(c); __iormb(); __v; })
 #define readw(c)	({ u16 __v = __arch_getw(c); __iormb(); __v; })
 #define readl(c)	({ u32 __v = __arch_getl(c); __iormb(); __v; })
+#define readq(c)	({ u64 __v = __arch_getq(c); __iormb(); __v; })
 
 /*
  * The compiler seems to be incapable of optimising constants
@@ -168,9 +174,11 @@ extern inline void __raw_readsl(unsigned long addr, void *data, int longlen)
 #define out_arch(type,endian,a,v)	__raw_write##type(cpu_to_##endian(v),a)
 #define in_arch(type,endian,a)		endian##_to_cpu(__raw_read##type(a))
 
+#define out_le64(a,v)	out_arch(q,le64,a,v)
 #define out_le32(a,v)	out_arch(l,le32,a,v)
 #define out_le16(a,v)	out_arch(w,le16,a,v)
 
+#define in_le64(a)	in_arch(q,le64,a)
 #define in_le32(a)	in_arch(l,le32,a)
 #define in_le16(a)	in_arch(w,le16,a)
 
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v8 2/5 ARMv8: Adjust MMU setup

Make MMU function reusable. Platform code can setup its own MMU tables.

---
Change log
v8: no change
v7: no change
v6: Modified from v4. Add "dsb sy" before setting MMU registers and add "isb" after.
v5: Drop the addition of inline function set_pgtable_section() from v4
It is only used twice and causes confusion.
v4: new patch, splitted from v3 2/4
Revise set_pgtable_section() to be reused by platform MMU code
Add inline function set_ttbr_tcr_mair() to be used by this and platform mmu code

 arch/arm/cpu/armv8/cache_v8.c    |   50 +++++++++++++++-----------------------
 arch/arm/include/asm/armv8/mmu.h |   24 ++++++++++++++++++
 2 files changed, 44 insertions(+), 30 deletions(-)
arch/arm/cpu/armv8/cache_v8.c +20 -30
index a96ecda..af3c494 100644
@@ -12,15 +12,14 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifndef CONFIG_SYS_DCACHE_OFF
-
-static void set_pgtable_section(u64 section, u64 memory_type)
+void set_pgtable_section(u64 *page_table, u64 index, u64 section,
+			 u64 memory_type)
 {
-	u64 *page_table = (u64 *)gd->arch.tlb_addr;
 	u64 value;
 
-	value = (section << SECTION_SHIFT) | PMD_TYPE_SECT | PMD_SECT_AF;
+	value = section | PMD_TYPE_SECT | PMD_SECT_AF;
 	value |= PMD_ATTRINDX(memory_type);
-	page_table[section] = value;
+	page_table[index] = value;
 }
 
 /* to activate the MMU we need to set up virtual memory */
@@ -28,10 +27,13 @@ static void mmu_setup(void)
 {
 	int i, j, el;
 	bd_t *bd = gd->bd;
+	u64 *page_table = (u64 *)gd->arch.tlb_addr;
 
 	/* Setup an identity-mapping for all spaces */
-	for (i = 0; i < (PGTABLE_SIZE >> 3); i++)
-		set_pgtable_section(i, MT_DEVICE_NGNRNE);
+	for (i = 0; i < (PGTABLE_SIZE >> 3); i++) {
+		set_pgtable_section(page_table, i, i << SECTION_SHIFT,
+				    MT_DEVICE_NGNRNE);
+	}
 
 	/* Setup an identity-mapping for all RAM space */
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
@@ -39,38 +41,26 @@ static void mmu_setup(void)
 		ulong end = bd->bi_dram[i].start + bd->bi_dram[i].size;
 		for (j = start >> SECTION_SHIFT;
 		     j < end >> SECTION_SHIFT; j++) {
-			set_pgtable_section(j, MT_NORMAL);
+			set_pgtable_section(page_table, j, j << SECTION_SHIFT,
+					    MT_NORMAL);
 		}
 	}
 
 	/* load TTBR0 */
 	el = current_el();
 	if (el == 1) {
-		asm volatile("msr ttbr0_el1, %0"
-			     : : "r" (gd->arch.tlb_addr) : "memory");
-		asm volatile("msr tcr_el1, %0"
-			     : : "r" (TCR_FLAGS | TCR_EL1_IPS_BITS)
-			     : "memory");
-		asm volatile("msr mair_el1, %0"
-			     : : "r" (MEMORY_ATTRIBUTES) : "memory");
+		set_ttbr_tcr_mair(el, gd->arch.tlb_addr,
+				  TCR_FLAGS | TCR_EL1_IPS_BITS,
+				  MEMORY_ATTRIBUTES);
 	} else if (el == 2) {
-		asm volatile("msr ttbr0_el2, %0"
-			     : : "r" (gd->arch.tlb_addr) : "memory");
-		asm volatile("msr tcr_el2, %0"
-			     : : "r" (TCR_FLAGS | TCR_EL2_IPS_BITS)
-			     : "memory");
-		asm volatile("msr mair_el2, %0"
-			     : : "r" (MEMORY_ATTRIBUTES) : "memory");
+		set_ttbr_tcr_mair(el, gd->arch.tlb_addr,
+				  TCR_FLAGS | TCR_EL2_IPS_BITS,
+				  MEMORY_ATTRIBUTES);
 	} else {
-		asm volatile("msr ttbr0_el3, %0"
-			     : : "r" (gd->arch.tlb_addr) : "memory");
-		asm volatile("msr tcr_el3, %0"
-			     : : "r" (TCR_FLAGS | TCR_EL2_IPS_BITS)
-			     : "memory");
-		asm volatile("msr mair_el3, %0"
-			     : : "r" (MEMORY_ATTRIBUTES) : "memory");
+		set_ttbr_tcr_mair(el, gd->arch.tlb_addr,
+				  TCR_FLAGS | TCR_EL3_IPS_BITS,
+				  MEMORY_ATTRIBUTES);
 	}
-
 	/* enable the mmu */
 	set_sctlr(get_sctlr() | CR_M);
 }
arch/arm/include/asm/armv8/mmu.h +24 -0
index 1193e76..4b7b67b 100644
@@ -108,4 +108,28 @@
 				TCR_IRGN_WBWA |		\
 				TCR_T0SZ(VA_BITS))
 
+#ifndef __ASSEMBLY__
+void set_pgtable_section(u64 *page_table, u64 index,
+			 u64 section, u64 memory_type);
+static inline void set_ttbr_tcr_mair(int el, u64 table, u64 tcr, u64 attr)
+{
+	asm volatile("dsb sy");
+	if (el == 1) {
+		asm volatile("msr ttbr0_el1, %0" : : "r" (table) : "memory");
+		asm volatile("msr tcr_el1, %0" : : "r" (tcr) : "memory");
+		asm volatile("msr mair_el1, %0" : : "r" (attr) : "memory");
+	} else if (el == 2) {
+		asm volatile("msr ttbr0_el2, %0" : : "r" (table) : "memory");
+		asm volatile("msr tcr_el2, %0" : : "r" (tcr) : "memory");
+		asm volatile("msr mair_el2, %0" : : "r" (attr) : "memory");
+	} else if (el == 3) {
+		asm volatile("msr ttbr0_el3, %0" : : "r" (table) : "memory");
+		asm volatile("msr tcr_el3, %0" : : "r" (tcr) : "memory");
+		asm volatile("msr mair_el3, %0" : : "r" (attr) : "memory");
+	} else {
+		hang();
+	}
+	asm volatile("isb");
+}
+#endif
 #endif /* _ASM_ARMV8_MMU_H_ */
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH v8 3/5 ARMv8/FSL_LSCH3: Add FSL_LSCH3 SoC

In reply to York Sun

Freescale LayerScape with Chassis Generation 3 is a set of SoCs with ARMv8 cores and 3rd generation of Chassis. We use different MMU setup to support memory map and cache attribute for these SoCs. MMU and cache are enabled very early to bootst performance, especially for early development on emulators. After u-boot relocates to DDR, a new MMU table with QBMan cache access is created in DDR. SMMU pagesize is set in SMMU_sACR register. Both DDR3 and DDR4 are supported.

---
v8: Fix a comment in lowlevel.S
v7: Move "dsb sy" and "isb" out of each EL level.
Move flusing final MMU table before setting TTBR.
v6: Add "dsb sy" before setting TTBR and add "isb" after.
v5: Revise the 2nd MMU table code to use the same macros
Only change TTBR to point to new MMU table without rewriting MAIR, TCR

v4: Slit ARMv8 MMU change to another patch, v4 2/5
Add more comment for final MMU table setup Remove mmu.h added in v3 and v2
Remove GICv2 macro testing in lowlevel.S Rename function init_type() to initiator_type() Use ARMv8 generic timer code

v3: Remove blank lines at the of files
Fix cluster PLL GSR register for accessing beyond array size Update final MMU table to support QBMan memory with cache Set SMMU pagesize in SMMU_sACR register in lowlevel init. Add DDR4 support
Remove forcing L3 cache flusing
Update GICv3 redistributor base address
Some of these changes are caused by model change.

 arch/arm/cpu/armv8/cache_v8.c                     |    7 +-
 arch/arm/cpu/armv8/fsl-lsch3/Makefile             |    9 +
 arch/arm/cpu/armv8/fsl-lsch3/README               |   10 +
 arch/arm/cpu/armv8/fsl-lsch3/cpu.c                |  425 +++++++++++++++++++++
 arch/arm/cpu/armv8/fsl-lsch3/cpu.h                |    7 +
 arch/arm/cpu/armv8/fsl-lsch3/lowlevel.S           |   65 ++++
 arch/arm/cpu/armv8/fsl-lsch3/speed.c              |  176 +++++++++
 arch/arm/cpu/armv8/fsl-lsch3/speed.h              |    7 +
 arch/arm/include/asm/arch-fsl-lsch3/clock.h       |   23 ++
 arch/arm/include/asm/arch-fsl-lsch3/config.h      |   65 ++++
 arch/arm/include/asm/arch-fsl-lsch3/gpio.h        |    9 +
 arch/arm/include/asm/arch-fsl-lsch3/immap_lsch3.h |  116 ++++++
 arch/arm/include/asm/arch-fsl-lsch3/imx-regs.h    |   13 +
 arch/arm/include/asm/config.h                     |    4 +
 arch/arm/include/asm/system.h                     |    2 +
 drivers/i2c/mxc_i2c.c                             |    5 +
 include/common.h                                  |    5 +-
 17 files changed, 944 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/fsl-lsch3/Makefile
 create mode 100644 arch/arm/cpu/armv8/fsl-lsch3/README
 create mode 100644 arch/arm/cpu/armv8/fsl-lsch3/cpu.c
 create mode 100644 arch/arm/cpu/armv8/fsl-lsch3/cpu.h
 create mode 100644 arch/arm/cpu/armv8/fsl-lsch3/lowlevel.S
 create mode 100644 arch/arm/cpu/armv8/fsl-lsch3/speed.c
 create mode 100644 arch/arm/cpu/armv8/fsl-lsch3/speed.h
 create mode 100644 arch/arm/include/asm/arch-fsl-lsch3/clock.h
 create mode 100644 arch/arm/include/asm/arch-fsl-lsch3/config.h
 create mode 100644 arch/arm/include/asm/arch-fsl-lsch3/gpio.h
 create mode 100644 arch/arm/include/asm/arch-fsl-lsch3/immap_lsch3.h
 create mode 100644 arch/arm/include/asm/arch-fsl-lsch3/imx-regs.h
arch/arm/cpu/armv8/cache_v8.c +6 -1
index af3c494..9dbcdf2 100644
@@ -73,12 +73,17 @@ void invalidate_dcache_all(void)
 	__asm_invalidate_dcache_all();
 }
 
+void __weak flush_l3_cache(void)
+{
+}
+
 /*
  * Performs a clean & invalidation of the entire data cache at all levels
  */
 void flush_dcache_all(void)
 {
 	__asm_flush_dcache_all();
+	flush_l3_cache();
 }
 
 /*
@@ -211,7 +216,7 @@ void invalidate_icache_all(void)
  * Enable dCache & iCache, whether cache is actually enabled
  * depend on CONFIG_SYS_DCACHE_OFF and CONFIG_SYS_ICACHE_OFF
  */
-void enable_caches(void)
+void __weak enable_caches(void)
 {
 	icache_enable();
 	dcache_enable();
arch/arm/cpu/armv8/fsl-lsch3/Makefile new file +9 -0
new file mode 100644
index 0000000..9249537
@@ -0,0 +1,9 @@
+#
+# Copyright 2014, Freescale Semiconductor
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y += cpu.o
+obj-y += lowlevel.o
+obj-y += speed.o
arch/arm/cpu/armv8/fsl-lsch3/README new file +10 -0
new file mode 100644
index 0000000..de34a91
@@ -0,0 +1,10 @@
+#
+# Copyright 2014 Freescale Semiconductor
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+
+Freescale LayerScape with Chassis Generation 3
+
+This architecture supports Freescale ARMv8 SoCs with Chassis generation 3,
+for example LS2100A.
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +425 -0

425 lines not on this page · raw message

arch/arm/cpu/armv8/fsl-lsch3/cpu.h new file +7 -0
new file mode 100644
index 0000000..28544d7
@@ -0,0 +1,7 @@
+/*
+ * Copyright 2014, Freescale Semiconductor
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+int fsl_qoriq_core_to_cluster(unsigned int core);
arch/arm/cpu/armv8/fsl-lsch3/lowlevel.S new file +65 -0

65 lines not on this page · raw message

arch/arm/cpu/armv8/fsl-lsch3/speed.c new file +176 -0

176 lines not on this page · raw message

arch/arm/cpu/armv8/fsl-lsch3/speed.h new file +7 -0
new file mode 100644
index 0000000..15af5b9
@@ -0,0 +1,7 @@
+/*
+ * Copyright 2014, Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+void get_sys_info(struct sys_info *sys_info);
arch/arm/include/asm/arch-fsl-lsch3/clock.h new file +23 -0
new file mode 100644
index 0000000..831af0b
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#ifndef __ASM_ARCH_FSL_LSCH3_CLOCK_H_
+#define __ASM_ARCH_FSL_LSCH3_CLOCK_H_
+
+#include <common.h>
+
+enum mxc_clock {
+	MXC_ARM_CLK = 0,
+	MXC_BUS_CLK,
+	MXC_UART_CLK,
+	MXC_ESDHC_CLK,
+	MXC_I2C_CLK,
+};
+
+unsigned int mxc_get_clock(enum mxc_clock clk);
+
+#endif /* __ASM_ARCH_FSL_LSCH3_CLOCK_H_ */
arch/arm/include/asm/arch-fsl-lsch3/config.h new file +65 -0

65 lines not on this page · raw message

arch/arm/include/asm/arch-fsl-lsch3/gpio.h new file +9 -0
new file mode 100644
index 0000000..f23a78c
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2014, Freescale Semiconductor
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _ASM_ARMV8_FSL_LSCH3_GPIO_H_
+#define _ASM_ARMV8_FSL_LSCH3_GPIO_H_
+#endif	/* _ASM_ARMV8_FSL_LSCH3_GPIO_H_ */
arch/arm/include/asm/arch-fsl-lsch3/immap_lsch3.h new file +116 -0

116 lines not on this page · raw message

arch/arm/include/asm/arch-fsl-lsch3/imx-regs.h new file +13 -0
new file mode 100644
index 0000000..8f00535
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#ifndef __ASM_ARCH_FSL_LSCH3_IMX_REGS_H_
+#define __ASM_ARCH_FSL_LSCH3_IMX_REGS_H_
+
+#define I2C_QUIRK_REG	/* enable 8-bit driver */
+
+#endif /* __ASM_ARCH_FSL_LSCH3_IMX_REGS_H_ */
arch/arm/include/asm/config.h +4 -0
index 2a20a77..d3433da 100644
@@ -17,4 +17,8 @@
 #define CONFIG_STATIC_RELA
 #endif
 
+#ifdef CONFIG_FSL_LSCH3
+#include <asm/arch-fsl-lsch3/config.h>
+#endif
+
 #endif
arch/arm/include/asm/system.h +2 -0
index 74ee9a4..d51ba66 100644
@@ -78,6 +78,8 @@ void gic_send_sgi(unsigned long sgino);
 void wait_for_wakeup(void);
 void smp_kick_all_cpus(void);
 
+void flush_l3_cache(void);
+
 #endif	/* __ASSEMBLY__ */
 
 #else /* CONFIG_ARM64 */
drivers/i2c/mxc_i2c.c +5 -0
index 48468d7..c14797c 100644
@@ -429,6 +429,11 @@ static void * const i2c_bases[] = {
 	(void *)I2C3_BASE_ADDR
 #elif defined(CONFIG_VF610)
 	(void *)I2C0_BASE_ADDR
+#elif defined(CONFIG_FSL_LSCH3)
+	(void *)I2C1_BASE_ADDR,
+	(void *)I2C2_BASE_ADDR,
+	(void *)I2C3_BASE_ADDR,
+	(void *)I2C4_BASE_ADDR
 #else
 #error "architecture not supported"
 #endif
include/common.h +2 -3
index cc74633..2e5a6d3 100644
@@ -687,9 +687,6 @@ ulong get_PERCLK3(void);
 ulong	get_bus_freq  (ulong);
 int get_serial_clock(void);
 
-#if defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx)
-ulong get_ddr_freq(ulong);
-#endif
 #if defined(CONFIG_MPC85xx)
 typedef MPC85xx_SYS_INFO sys_info_t;
 void	get_sys_info  ( sys_info_t * );
@@ -705,6 +702,8 @@ static inline ulong get_ddr_freq(ulong dummy)
 {
 	return get_bus_freq(dummy);
 }
+#else
+ulong get_ddr_freq(ulong);
 #endif
 
 #if defined(CONFIG_4xx)
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH v8 4/5 armv8/fsl-lsch3: Add support to load and start MC Firmware

In reply to York Sun

From: "J. German Rivera" <[email protected]>

Adding support to load and start the Layerscape Management Complex (MC) firmware. First, the MC GCR register is set to 0 to reset all cores. MC firmware and DPL images are copied from their location in NOR flash to DDR. MC registers are updated with the location of these images. Deasserting the reset bit of MC GCR register releases core 0 to run. Core 1 will be released by MC firmware. Stop bits are not touched for this step. U-boot waits for MC until it boots up. In case of a failure, device tree is updated accordingly. The MC firmware image uses FIT format.

---
v8: no change
v7: no change
v6: no change
v5: Fix a typo in commit message "supoort"
Fix variable declaration cause by squashing patches
v4: no change
v3: Add error detection and update device tree if failure
Revise loading address to avoid overlap
Use FIT image for the firmware
Remove blank lines at the end of files

 README                             |   27 ++++
 arch/arm/cpu/armv8/fsl-lsch3/cpu.c |   11 ++
 drivers/net/Makefile               |    1 +
 drivers/net/fsl_mc/Makefile        |    8 ++
 drivers/net/fsl_mc/mc.c            |  272 ++++++++++++++++++++++++++++++++++++
 include/fdt_support.h              |   14 +-
 include/fsl_mc.h                   |   59 ++++++++
 7 files changed, 389 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/fsl_mc/Makefile
 create mode 100644 drivers/net/fsl_mc/mc.c
 create mode 100644 include/fsl_mc.h
README +27 -0
index 7129df8..9470c30 100644
@@ -4653,6 +4653,33 @@ within that device.
 	window->master inbound window->master LAW->the ucode address in
 	master's memory space.
 
+Freescale Layerscape Management Complex Firmware Support:
+---------------------------------------------------------
+The Freescale Layerscape Management Complex (MC) supports the loading of
+"firmware".
+This firmware often needs to be loaded during U-Boot booting, so macros
+are used to identify the storage device (NOR flash, SPI, etc) and the address
+within that device.
+
+- CONFIG_FSL_MC_ENET
+	Enable the MC driver for Layerscape SoCs.
+
+- CONFIG_SYS_LS_MC_FW_ADDR
+	The address in the storage device where the firmware is located.  The
+	meaning of this address depends on which CONFIG_SYS_LS_MC_FW_IN_xxx macro
+	is also specified.
+
+- CONFIG_SYS_LS_MC_FW_LENGTH
+	The maximum possible size of the firmware.  The firmware binary format
+	has a field that specifies the actual size of the firmware, but it
+	might not be possible to read any part of the firmware unless some
+	local storage is allocated to hold the entire firmware first.
+
+- CONFIG_SYS_LS_MC_FW_IN_NOR
+	Specifies that MC firmware is located in NOR flash, mapped as
+	normal addressable memory via the LBC. CONFIG_SYS_LS_MC_FW_ADDR is the
+	virtual address in NOR flash.
+
 Building the Software:
 ======================
 
arch/arm/cpu/armv8/fsl-lsch3/cpu.c +11 -0
index 46965f0..c129d03 100644
@@ -12,6 +12,7 @@
 #include <asm/arch-fsl-lsch3/immap_lsch3.h>
 #include "cpu.h"
 #include "speed.h"
+#include <fsl_mc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -423,3 +424,13 @@ int print_cpuinfo(void)
 	return 0;
 }
 #endif
+
+int cpu_eth_init(bd_t *bis)
+{
+	int error = 0;
+
+#ifdef CONFIG_FSL_MC_ENET
+	error = mc_init(bis);
+#endif
+	return error;
+}
drivers/net/Makefile +1 -0
index 6005f7e..6226cb2 100644
@@ -64,3 +64,4 @@ obj-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o
 obj-$(CONFIG_XILINX_LL_TEMAC) += xilinx_ll_temac.o xilinx_ll_temac_mdio.o \
 		xilinx_ll_temac_fifo.o xilinx_ll_temac_sdma.o
 obj-$(CONFIG_ZYNQ_GEM) += zynq_gem.o
+obj-$(CONFIG_FSL_MC_ENET) += fsl_mc/
drivers/net/fsl_mc/Makefile new file +8 -0
new file mode 100644
index 0000000..4834086
@@ -0,0 +1,8 @@
+#
+# Copyright 2014 Freescale Semiconductor, Inc.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+# Layerscape MC driver
+obj-y += mc.o
drivers/net/fsl_mc/mc.c new file +272 -0

272 lines not on this page · raw message

include/fdt_support.h +11 -3
index ae010bb..f928306 100644
@@ -113,17 +113,25 @@ static inline int fdt_status_disabled(void *fdt, int nodeoffset)
 {
 	return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_DISABLED, 0);
 }
+static inline int fdt_status_fail(void *fdt, int nodeoffset)
+{
+	return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_FAIL, 0);
+}
 
-int fdt_set_status_by_alias(void *fdt, const char* alias,
+int fdt_set_status_by_alias(void *fdt, const char *alias,
 			    enum fdt_status status, unsigned int error_code);
-static inline int fdt_status_okay_by_alias(void *fdt, const char* alias)
+static inline int fdt_status_okay_by_alias(void *fdt, const char *alias)
 {
 	return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_OKAY, 0);
 }
-static inline int fdt_status_disabled_by_alias(void *fdt, const char* alias)
+static inline int fdt_status_disabled_by_alias(void *fdt, const char *alias)
 {
 	return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_DISABLED, 0);
 }
+static inline int fdt_status_fail_by_alias(void *fdt, const char *alias)
+{
+	return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_FAIL, 0);
+}
 
 #endif /* ifdef CONFIG_OF_LIBFDT */
 
include/fsl_mc.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v8 4/5 armv8/fsl-lsch3: Add support to load and start MC Firmware

Hi York,

Quoted 38 lines · York Sun

From: "J. German Rivera" <[email protected]>

Adding support to load and start the Layerscape Management Complex (MC) firmware. First, the MC GCR register is set to 0 to reset all cores. MC firmware and DPL images are copied from their location in NOR flash to DDR. MC registers are updated with the location of these images. Deasserting the reset bit of MC GCR register releases core 0 to run. Core 1 will be released by MC firmware. Stop bits are not touched for this step. U-boot waits for MC until it boots up. In case of a failure, device tree is updated accordingly. The MC firmware image uses FIT format.

drivers/net/fsl_mc/mc.c new file +26 -0
+int parse_mc_firmware_fit_image(const void **raw_image_addr,
+				size_t *raw_image_size)
+{
+	int format;
+	void *fit_hdr;
+	int node_offset;
+	const void *data;
+	size_t size;
+	const char *uname = "firmware";
+
+	/* Check if the image is in NOR flash*/
+#ifdef CONFIG_SYS_LS_MC_FW_IN_NOR
+	fit_hdr = (void *)CONFIG_SYS_LS_MC_FW_ADDR;
+#else
+#error "No CONFIG_SYS_LS_MC_FW_IN_xxx defined"
+#endif
+
+	/* Check if Image is in FIT format */
+	format = genimg_get_format(fit_hdr);
+
+	if (format != IMAGE_FORMAT_FIT) {
+		debug("Not a FIT image\n");
+		return 1;
+	}
+
+	if (!fit_check_format(fit_hdr)) {

drivers/net/fsl_mc/mc.c line 67

Quoted 10 lines
drivers/net/fsl_mc/mc.c new file +10 -0
+		debug("Bad FIT image format\n");
+		return 1;
+	}
+
+	/* Find node offset of MC Firmware image */
+	if (uname == NULL) {
+		debug("FIT subimage unit name not provided");
+		return 1;
+	}
+

I don't see how uname can ever be NULL here, since it is assigned above.

Regards,
Jeroen

author
#5 lore raw

PATCH v8 4/5 armv8/fsl-lsch3: Add support to load and start MC Firmware

Quoted 46 lines · Jeroen Hofstee

Hi York,

Quoted 43 lines · York Sun

From: "J. German Rivera" <[email protected]>

Adding support to load and start the Layerscape Management Complex (MC) firmware. First, the MC GCR register is set to 0 to reset all cores. MC firmware and DPL images are copied from their location in NOR flash to DDR. MC registers are updated with the location of these images. Deasserting the reset bit of MC GCR register releases core 0 to run. Core 1 will be released by MC firmware. Stop bits are not touched for this step. U-boot waits for MC until it boots up. In case of a failure, device tree is updated accordingly. The MC firmware image uses FIT format.

drivers/net/fsl_mc/mc.c new file +31 -0
+int parse_mc_firmware_fit_image(const void **raw_image_addr,
+				size_t *raw_image_size)
+{
+	int format;
+	void *fit_hdr;
+	int node_offset;
+	const void *data;
+	size_t size;
+	const char *uname = "firmware";
+
+	/* Check if the image is in NOR flash*/
+#ifdef CONFIG_SYS_LS_MC_FW_IN_NOR
+	fit_hdr = (void *)CONFIG_SYS_LS_MC_FW_ADDR;
+#else
+#error "No CONFIG_SYS_LS_MC_FW_IN_xxx defined"
+#endif
+
+	/* Check if Image is in FIT format */
+	format = genimg_get_format(fit_hdr);
+
+	if (format != IMAGE_FORMAT_FIT) {
+		debug("Not a FIT image\n");
+		return 1;
+	}
+
+	if (!fit_check_format(fit_hdr)) {
+		debug("Bad FIT image format\n");
+		return 1;
+	}
+
+	/* Find node offset of MC Firmware image */
Quoted 9 lines

drivers/net/fsl_mc/mc.c line 67

Quoted 5 lines
drivers/net/fsl_mc/mc.c new file +5 -0
+	if (uname == NULL) {
+		debug("FIT subimage unit name not provided");
+		return 1;
+	}
+

I don't see how uname can ever be NULL here, since it is assigned above.

Good question. I think German has a plan to use different name. I will let him comment.

York

#6 lore raw

PATCH v8 4/5 armv8/fsl-lsch3: Add support to load and start MC Firmware

The "uname == NULL" check can be removed.

Thanks,

German
________________________________________
From: Sun York-R58495
Sent: Friday, June 20, 2014 3:38 PM
To: Jeroen Hofstee; Rivera Jose-B46482
Cc: albert.u.boot at aribaud.net; Kanetkar Shruti-B44454; u-boot at lists.denx.de
Subject: Re: [U-Boot] [Patch v8 4/5] armv8/fsl-lsch3: Add support to load and start MC Firmware

Quoted 46 lines · Jeroen Hofstee

Hi York,

Quoted 43 lines · York Sun

From: "J. German Rivera" <[email protected]>

Adding support to load and start the Layerscape Management Complex (MC) firmware. First, the MC GCR register is set to 0 to reset all cores. MC firmware and DPL images are copied from their location in NOR flash to DDR. MC registers are updated with the location of these images. Deasserting the reset bit of MC GCR register releases core 0 to run. Core 1 will be released by MC firmware. Stop bits are not touched for this step. U-boot waits for MC until it boots up. In case of a failure, device tree is updated accordingly. The MC firmware image uses FIT format.

drivers/net/fsl_mc/mc.c new file +31 -0
+int parse_mc_firmware_fit_image(const void **raw_image_addr,
+                            size_t *raw_image_size)
+{
+    int format;
+    void *fit_hdr;
+    int node_offset;
+    const void *data;
+    size_t size;
+    const char *uname = "firmware";
+
+    /* Check if the image is in NOR flash*/
+#ifdef CONFIG_SYS_LS_MC_FW_IN_NOR
+    fit_hdr = (void *)CONFIG_SYS_LS_MC_FW_ADDR;
+#else
+#error "No CONFIG_SYS_LS_MC_FW_IN_xxx defined"
+#endif
+
+    /* Check if Image is in FIT format */
+    format = genimg_get_format(fit_hdr);
+
+    if (format != IMAGE_FORMAT_FIT) {
+            debug("Not a FIT image\n");
+            return 1;
+    }
+
+    if (!fit_check_format(fit_hdr)) {
+            debug("Bad FIT image format\n");
+            return 1;
+    }
+
+    /* Find node offset of MC Firmware image */
Quoted 9 lines

drivers/net/fsl_mc/mc.c line 67

Quoted 5 lines
drivers/net/fsl_mc/mc.c new file +5 -0
+    if (uname == NULL) {
+            debug("FIT subimage unit name not provided");
+            return 1;
+    }
+

I don't see how uname can ever be NULL here, since it is assigned above.

Good question. I think German has a plan to use different name. I will let him comment.

York

author
#7 lore raw

PATCH v8 4/5 armv8/fsl-lsch3: Add support to load and start MC Firmware

In this case, I will have to send a new version to get rid of this check.

York

Quoted 74 lines · On 06/23/2014 01:50 PM, Rivera Jose-B46482 wrote:

The "uname == NULL" check can be removed.

Thanks,

German
________________________________________
From: Sun York-R58495
Sent: Friday, June 20, 2014 3:38 PM
To: Jeroen Hofstee; Rivera Jose-B46482
Cc: albert.u.boot at aribaud.net; Kanetkar Shruti-B44454; u-boot at lists.denx.de
Subject: Re: [U-Boot] [Patch v8 4/5] armv8/fsl-lsch3: Add support to load and start MC Firmware

Quoted 46 lines · Jeroen Hofstee

Hi York,

Quoted 43 lines · York Sun

From: "J. German Rivera" <[email protected]>

Adding support to load and start the Layerscape Management Complex (MC) firmware. First, the MC GCR register is set to 0 to reset all cores. MC firmware and DPL images are copied from their location in NOR flash to DDR. MC registers are updated with the location of these images. Deasserting the reset bit of MC GCR register releases core 0 to run. Core 1 will be released by MC firmware. Stop bits are not touched for this step. U-boot waits for MC until it boots up. In case of a failure, device tree is updated accordingly. The MC firmware image uses FIT format.

drivers/net/fsl_mc/mc.c new file +31 -0
+int parse_mc_firmware_fit_image(const void **raw_image_addr,
+                            size_t *raw_image_size)
+{
+    int format;
+    void *fit_hdr;
+    int node_offset;
+    const void *data;
+    size_t size;
+    const char *uname = "firmware";
+
+    /* Check if the image is in NOR flash*/
+#ifdef CONFIG_SYS_LS_MC_FW_IN_NOR
+    fit_hdr = (void *)CONFIG_SYS_LS_MC_FW_ADDR;
+#else
+#error "No CONFIG_SYS_LS_MC_FW_IN_xxx defined"
+#endif
+
+    /* Check if Image is in FIT format */
+    format = genimg_get_format(fit_hdr);
+
+    if (format != IMAGE_FORMAT_FIT) {
+            debug("Not a FIT image\n");
+            return 1;
+    }
+
+    if (!fit_check_format(fit_hdr)) {
+            debug("Bad FIT image format\n");
+            return 1;
+    }
+
+    /* Find node offset of MC Firmware image */
Quoted 9 lines

drivers/net/fsl_mc/mc.c line 67

Quoted 5 lines
drivers/net/fsl_mc/mc.c new file +5 -0
+    if (uname == NULL) {
+            debug("FIT subimage unit name not provided");
+            return 1;
+    }
+

I don't see how uname can ever be NULL here, since it is assigned above.

Good question. I think German has a plan to use different name. I will let him comment.

York

author
#8 lore raw

PATCH v8 5/5 ARMv8/ls2085a_emu: Add LS2085A emulator and simulator board support

In reply to York Sun

LS2085A is an ARMv8 implementation. This adds board support for emulator and simulator:
Two DDR controllers
UART2 is used as the console
IFC timing is tightened for speedy booting
Support DDR3 and DDR4 as separated targets
Management Complex (MC) is enabled
Support for GIC 500 (based on GICv3 arch)

---
v8: Rename ls2100a to ls2085a according to latest SoC name.
Add "support for GIC 500" in commit message.
v7: no change
v6: no change
v5: no change
v4: no change
v3: Add support for DDR4 target and simulator target
Squash Manage complex patch (previous 5/5) into this
Reserve last 512MB memory for MC use
Change MC firmware location in NOR flash
Fix UART clock source speed
Update IFC address mux
Use generic board
Disable DDR memory beyound 39 physical address space due to Linux limitation

 arch/arm/cpu/armv8/fsl-lsch3/README          |    2 +-
 arch/arm/include/asm/arch-fsl-lsch3/config.h |    2 +-
 board/freescale/ls2085a/Makefile             |    8 +
 board/freescale/ls2085a/README               |   16 ++
 board/freescale/{t4rdb => ls2085a}/ddr.c     |   89 ++++++++--
 board/freescale/ls2085a/ddr.h                |   57 +++++++
 board/freescale/ls2085a/ls2085a.c            |  100 ++++++++++++
 boards.cfg                                   |    3 +
 include/configs/ls2085a_common.h             |  226 ++++++++++++++++++++++++++
 include/configs/ls2085a_emu.h                |   19 +++
 include/configs/ls2085a_simu.h               |   16 ++
 11 files changed, 520 insertions(+), 18 deletions(-)
 create mode 100644 board/freescale/ls2085a/Makefile
 create mode 100644 board/freescale/ls2085a/README
 copy board/freescale/{t4rdb => ls2085a}/ddr.c (53%)
 create mode 100644 board/freescale/ls2085a/ddr.h
 create mode 100644 board/freescale/ls2085a/ls2085a.c
 create mode 100644 include/configs/ls2085a_common.h
 create mode 100644 include/configs/ls2085a_emu.h
 create mode 100644 include/configs/ls2085a_simu.h
arch/arm/cpu/armv8/fsl-lsch3/README +1 -1
index de34a91..cc47466 100644
@@ -7,4 +7,4 @@
 Freescale LayerScape with Chassis Generation 3
 
 This architecture supports Freescale ARMv8 SoCs with Chassis generation 3,
-for example LS2100A.
+for example LS2085A.
arch/arm/include/asm/arch-fsl-lsch3/config.h +1 -1
index c987a19..c1c718e 100644
@@ -53,7 +53,7 @@
 /* IFC */
 #define CONFIG_SYS_FSL_IFC_LE
 
-#ifdef CONFIG_LS2100A
+#ifdef CONFIG_LS2085A
 #define CONFIG_MAX_CPUS				16
 #define CONFIG_SYS_FSL_IFC_BANK_COUNT		8
 #define CONFIG_NUM_DDR_CONTROLLERS		2
board/freescale/ls2085a/Makefile new file +8 -0
new file mode 100644
index 0000000..701b35c
@@ -0,0 +1,8 @@
+#
+# Copyright 2014 Freescale Semiconductor
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y += ls2085a.o
+obj-y += ddr.o
board/freescale/ls2085a/README new file +16 -0
new file mode 100644
index 0000000..b7023e1
@@ -0,0 +1,16 @@
+Freescale ls2085a_emu
+
+This is a emulator target with limited peripherals.
+
+Memory map from core's view
+
+0x00_0000_0000 .. 0x00_000F_FFFF	Boot Rom
+0x00_0100_0000 .. 0x00_0FFF_FFFF	CCSR
+0x00_1800_0000 .. 0x00_181F_FFFF	OCRAM
+0x00_3000_0000 .. 0x00_3FFF_FFFF	IFC region #1
+0x00_8000_0000 .. 0x00_FFFF_FFFF	DDR region #1
+0x05_1000_0000 .. 0x05_FFFF_FFFF	IFC region #2
+0x80_8000_0000 .. 0xFF_FFFF_FFFF	DDR region #2
+
+Other addresses are either reserved, or not used directly by u-boot.
+This list should be updated when more addresses are used.
board/freescale/ls2085a/ddr.c renamed from board/freescale/t4rdb/ddr.c +73 -16

144 lines not on this page · raw message

board/freescale/ls2085a/ddr.h new file +57 -0

57 lines not on this page · raw message

board/freescale/ls2085a/ls2085a.c new file +100 -0

100 lines not on this page · raw message

boards.cfg +3 -0
index 947f2bc..1ceacc2 100644
@@ -44,6 +44,9 @@
 ###########################################################################################################
 
 Active  aarch64     armv8          -           armltd          vexpress64          vexpress_aemv8a                       vexpress_aemv8a:ARM64                                                                                                             David Feng <[email protected]>
+Active  aarch64     armv8          fsl-lsch3   freescale       ls2085a             ls2085a_emu                          ls2085a_emu:ARM64,EMU                                                                                                             York Sun <[email protected]>
+Active  aarch64     armv8          fsl-lsch3   freescale       ls2085a             ls2085a_emu_D4                       ls2085a_emu:ARM64,EMU,SYS_FSL_DDR4                                                                                                York Sun <[email protected]>
+Active  aarch64     armv8          fsl-lsch3   freescale       ls2085a             ls2085a_simu                         ls2085a_simu:ARM64,SIMU                                                                                                           York Sun <[email protected]>
 Active  arc         arc700         -           synopsys        -                   axs101                                -                                                                                                                                 Alexey Brodkin <[email protected]>
 Active  arc         arc700         -           synopsys        <none>              arcangel4                             -                                                                                                                                 Alexey Brodkin <[email protected]>
 Active  arc         arc700         -           synopsys        <none>              arcangel4-be                          -                                                                                                                                 Alexey Brodkin <[email protected]>
include/configs/ls2085a_common.h new file +226 -0

226 lines not on this page · raw message

include/configs/ls2085a_emu.h new file +19 -0
new file mode 100644
index 0000000..a5cea63
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2014 Freescale Semiconductor
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __LS2_EMU_H
+#define __LS2_EMU_H
+
+#include "ls2085a_common.h"
+
+#define CONFIG_DDR_SPD
+#define CONFIG_SYS_FSL_DDR_EMU		/* Support emulator */
+#define SPD_EEPROM_ADDRESS1	0x51
+#define SPD_EEPROM_ADDRESS2	0x52
+#define SPD_EEPROM_ADDRESS	SPD_EEPROM_ADDRESS1
+#define CONFIG_SYS_SPD_BUS_NUM	1	/* SPD on I2C bus 1 */
+
+#endif /* __LS2_EMU_H */
include/configs/ls2085a_simu.h new file +16 -0
new file mode 100644
index 0000000..46d47b0
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2014 Freescale Semiconductor
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __LS2_SIMU_H
+#define __LS2_SIMU_H
+
+#include "ls2085a_common.h"
+
+/* SMSC 91C111 ethernet configuration */
+#define CONFIG_SMC91111
+#define CONFIG_SMC91111_BASE	(0x2210000)
+
+#endif /* __LS2_SIMU_H */
Signature · 1 line
1.7.9.5