Added 64-bit MMIO accessors for ARMv8
Subsystems (5)
PATCH v6 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
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
@@ -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
PATCH v6 2/5 ARMv8: Adjust MMU setup
Make MMU function reusable. Platform code can setup its own MMU tables.
---
Change log
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
@@ -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 ) { - asmvolatile ("msr ttbr0_el1, %0" - : :"r" (gd->arch.tlb_addr) :"memory" ); - asmvolatile ("msr tcr_el1, %0" - : :"r" (TCR_FLAGS |TCR_EL1_IPS_BITS ) - :"memory" ); - asmvolatile ("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 ) { - asmvolatile ("msr ttbr0_el2, %0" - : :"r" (gd->arch.tlb_addr) :"memory" ); - asmvolatile ("msr tcr_el2, %0" - : :"r" (TCR_FLAGS |TCR_EL2_IPS_BITS ) - :"memory" ); - asmvolatile ("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 { - asmvolatile ("msr ttbr0_el3, %0" - : :"r" (gd->arch.tlb_addr) :"memory" ); - asmvolatile ("msr tcr_el3, %0" - : :"r" (TCR_FLAGS |TCR_EL2_IPS_BITS ) - :"memory" ); - asmvolatile ("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
@@ -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) +{ + asmvolatile ("dsb sy" ); +if (el ==1 ) { + asmvolatile ("msr ttbr0_el1, %0" : :"r" (table) :"memory" ); + asmvolatile ("msr tcr_el1, %0" : :"r" (tcr) :"memory" ); + asmvolatile ("msr mair_el1, %0" : :"r" (attr) :"memory" ); + }else if (el ==2 ) { + asmvolatile ("msr ttbr0_el2, %0" : :"r" (table) :"memory" ); + asmvolatile ("msr tcr_el2, %0" : :"r" (tcr) :"memory" ); + asmvolatile ("msr mair_el2, %0" : :"r" (attr) :"memory" ); + }else if (el ==3 ) { + asmvolatile ("msr ttbr0_el3, %0" : :"r" (table) :"memory" ); + asmvolatile ("msr tcr_el3, %0" : :"r" (tcr) :"memory" ); + asmvolatile ("msr mair_el3, %0" : :"r" (attr) :"memory" ); + }else { +hang (); + } + asmvolatile ("isb" ); +} +#endif #endif /* _ASM_ARMV8_MMU_H_ */
Signature · 1 line
1.7.9.5
PATCH v6 3/5 ARMv8/FSL_LSCH3: Add FSL_LSCH3 SoC
In reply to York SunFreescale 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.
---
Change log
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 | 420 +++++++++++++++++++++ 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, 939 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
@@ -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
@@ -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
@@ -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 +420 -0
420 lines not on this page · raw message
arch/arm/cpu/armv8/fsl-lsch3/cpu.h new file +7 -0
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -693,9 +693,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 * );
@@ -711,6 +708,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
PATCH v6 4/5 armv8/fsl-lsch3: Add support to load and start MC Firmware
In reply to York SunFrom: "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.
---
Change log
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
@@ -4640,6 +4640,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
@@ -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 ;
@@ -418,3 +419,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
@@ -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
@@ -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
@@ -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
PATCH v6 5/5 ARMv8/ls2100a_emu: Add LS2100A emulator and simulator board support
In reply to York SunLS2100A 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
---
Change log
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
board/freescale/ls2100a/Makefile | 8 ++ board/freescale/ls2100a/README | 16 +++ board/freescale/ls2100a/ddr.c | 175 ++++++++++++++++++++++++++++ board/freescale/ls2100a/ddr.h | 57 ++++++++++ board/freescale/ls2100a/ls2100a.c | 100 ++++++++++++++++ boards.cfg | 3 + include/configs/ls2100a_common.h | 226 +++++++++++++++++++++++++++++++++++++ include/configs/ls2100a_emu.h | 19 ++++ include/configs/ls2100a_simu.h | 16 +++ 9 files changed, 620 insertions(+) create mode 100644 board/freescale/ls2100a/Makefile create mode 100644 board/freescale/ls2100a/README create mode 100644 board/freescale/ls2100a/ddr.c create mode 100644 board/freescale/ls2100a/ddr.h create mode 100644 board/freescale/ls2100a/ls2100a.c create mode 100644 include/configs/ls2100a_common.h create mode 100644 include/configs/ls2100a_emu.h create mode 100644 include/configs/ls2100a_simu.h
board/freescale/ls2100a/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Copyright 2014 Freescale Semiconductor +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += ls2100a.o +obj-y += ddr.o
board/freescale/ls2100a/README new file +16 -0
@@ -0,0 +1,16 @@ +Freescale ls2100a_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/ls2100a/ddr.c new file +175 -0
175 lines not on this page · raw message
board/freescale/ls2100a/ddr.h new file +57 -0
57 lines not on this page · raw message
board/freescale/ls2100a/ls2100a.c new file +100 -0
100 lines not on this page · raw message
boards.cfg +3 -0
@@ -44,6 +44,9 @@ ########################################################################################################### Active aarch64 armv8 - armltd vexpress64 vexpress_aemv8a vexpress_aemv8a:ARM64 David Feng <[email protected]> +Active aarch64 armv8 fsl-lsch3 freescale ls2100a ls2100a_emu ls2100a_emu:ARM64,EMU York Sun <[email protected]> +Active aarch64 armv8 fsl-lsch3 freescale ls2100a ls2100a_emu_D4 ls2100a_emu:ARM64,EMU,SYS_FSL_DDR4 York Sun <[email protected]> +Active aarch64 armv8 fsl-lsch3 freescale ls2100a ls2100a_simu ls2100a_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/ls2100a_common.h new file +226 -0
226 lines not on this page · raw message
include/configs/ls2100a_emu.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Copyright 2014 Freescale Semiconductor +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __LS2_EMU_H +#define __LS2_EMU_H + +#include "ls2100a_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/ls2100a_simu.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (C) 2014 Freescale Semiconductor +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __LS2_SIMU_H +#define __LS2_SIMU_H + +#include "ls2100a_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
PATCH v6 3/5 ARMv8/FSL_LSCH3: Add FSL_LSCH3 SoC
In reply to York SunHi York,
Apologies for the late reply on this.
I'm somewhat concerned regarding the issues you're seeing with cacheable page table walks, but I'll ignore that for the moment so we can get the ordering of maintenance sorted.
Quoted 12 lines · 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_sACRregister. Both DDR3 and DDR4 are supported.Signed-off-by York Sun <[email protected]>Signed-off-by Varun Sethi <[email protected]>Signed-off-by Arnab Basu <[email protected]>---
[...]
arch/arm/cpu/armv8/fsl-lsch3/cpu.c line 205
Quoted 2 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +2
-0+/* point TTBR to the new table */ + el =current_el ();
Could we not place a dsb() here...
arch/arm/cpu/armv8/fsl-lsch3/cpu.c line 217
Quoted 12 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +12
-0+if (el ==1 ) { + asmvolatile ("dsb sy;msr ttbr0_el1, %0;isb" + : :"r" ((u64 )level0_table) :"memory" ); + }else if (el ==2 ) { + asmvolatile ("dsb sy;msr ttbr0_el2, %0;isb" + : :"r" ((u64 )level0_table) :"memory" ); + }else if (el ==3 ) { + asmvolatile ("dsb sy;msr ttbr0_el3, %0;isb" + : :"r" ((u64 )level0_table) :"memory" ); + }else { +hang (); + }
...and an isb() here?
It would save duplicating them for each EL.
arch/arm/cpu/armv8/fsl-lsch3/cpu.c line 228
Quoted 11 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +11
-0+/* +* MMU is already enabled, just need to invalidate TLB to load the +* new table. The new table is compatible with the current table, if +* MMU somehow walks through the new table before invalidation TLB, +* it still works. So we don't need to turn off MMU here. +*/ +} + +int arch_cpu_init (void ) +{ +icache_enable ();
Just to check: the icache is clean/invalid at this point?
Quoted 6 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +6
-0+__asm_invalidate_dcache_all (); +__asm_invalidate_tlb_all (); +early_mmu_setup (); +set_sctlr (get_sctlr () |CR_C ); +return 0 ; +}
[...]
arch/arm/cpu/armv8/fsl-lsch3/cpu.c line 300
Quoted 12 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +12
-0+/* +* This function is called from lib/board.c. +* It recreates MMU table in main memory. MMU and d-cache are enabled earlier. +* There is no need to disable d-cache for this operation. +*/ +void enable_caches (void ) +{ +final_mmu_setup (); +flush_dcache_range (gd->arch.tlb_addr, + gd->arch.tlb_addr + gd->arch.tlb_size); +__asm_invalidate_tlb_all (); +}
This looks wrong, given your previous comments that you couldn't get the MMU to lookup from the cache.
In final_mmu_setup() you pointed the TTBR0_ELx to the new tables, but at that point the tables aren't guaranteed to be in memory, because they haven't been flushed. The MMU can start fetching the garbage from memory immediately, and things might go wrong before __asm_invalidate_tlb_all() blows away the garbage the MMU read from memory (for instance, the mapping covering the enable_caches function might get replaced by garbage).
If the page table walks are non-cacheable, you need to flush the tables to memory before programming the relevant TTBR.
Thanks,
Mark.
PATCH v6 3/5 ARMv8/FSL_LSCH3: Add FSL_LSCH3 SoC
Quoted 42 lines · Mark Rutland
Hi York,
Apologies for the late reply on this.
I'm somewhat concerned regarding the issues you're seeing with cacheable page table walks, but I'll ignore that for the moment so we can get the ordering of maintenance sorted.
Quoted 12 lines · 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_sACRregister. Both DDR3 and DDR4 are supported.Signed-off-by York Sun <[email protected]>Signed-off-by Varun Sethi <[email protected]>Signed-off-by Arnab Basu <[email protected]>---
[...]
arch/arm/cpu/armv8/fsl-lsch3/cpu.c line 205
Quoted 2 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +2
-0+/* point TTBR to the new table */ + el =current_el ();Could we not place a
dsb()here...arch/arm/cpu/armv8/fsl-lsch3/cpu.c line 217
Quoted 12 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +12
-0+if (el ==1 ) { + asmvolatile ("dsb sy;msr ttbr0_el1, %0;isb" + : :"r" ((u64 )level0_table) :"memory" ); + }else if (el ==2 ) { + asmvolatile ("dsb sy;msr ttbr0_el2, %0;isb" + : :"r" ((u64 )level0_table) :"memory" ); + }else if (el ==3 ) { + asmvolatile ("dsb sy;msr ttbr0_el3, %0;isb" + : :"r" ((u64 )level0_table) :"memory" ); + }else { +hang (); + }
Quoted 3 lines
...and an
isb()here?It would save duplicating them for each EL.
Sure. I can move them out.
Quoted 14 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c line 228
Quoted 12 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +11
-0+/* +* MMU is already enabled, just need to invalidate TLB to load the +* new table. The new table is compatible with the current table, if +* MMU somehow walks through the new table before invalidation TLB, +* it still works. So we don't need to turn off MMU here. +*/ +} + +int arch_cpu_init (void ) +{ +icache_enable ();Just to check: the icache is clean/invalid at this point?
It is not, but it is done first thing inside icache_enable().
Quoted 34 lines
Quoted 7 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +6
-0+__asm_invalidate_dcache_all (); +__asm_invalidate_tlb_all (); +early_mmu_setup (); +set_sctlr (get_sctlr () |CR_C ); +return 0 ; +}[...]
arch/arm/cpu/armv8/fsl-lsch3/cpu.c line 300
Quoted 12 lines
arch/arm/cpu/armv8/fsl-lsch3/cpu.c new file +12
-0+/* +* This function is called from lib/board.c. +* It recreates MMU table in main memory. MMU and d-cache are enabled earlier. +* There is no need to disable d-cache for this operation. +*/ +void enable_caches (void ) +{ +final_mmu_setup (); +flush_dcache_range (gd->arch.tlb_addr, + gd->arch.tlb_addr + gd->arch.tlb_size); +__asm_invalidate_tlb_all (); +}This looks wrong, given your previous comments that you couldn't get the MMU to lookup from the cache.
In
final_mmu_setup()you pointed theTTBR0_ELxto the new tables, but at that point the tables aren't guaranteed to be in memory, because they haven't been flushed. The MMU can start fetching the garbage from memory immediately, and things might go wrong before__asm_invalidate_tlb_all()blows away the garbage the MMU read from memory (for instance, the mapping covering theenable_cachesfunction might get replaced by garbage).
Quoted 3 lines
If the page table walks are non-cacheable, you need to flush the tables to memory before programming the relevant TTBR.
Agreed here. I will move the flushing before setting TTBR.
Thanks for review. v7 patch is coming after I verify all the changes.
York