Skip to contentSkip to conversation

Add Cavium ThunderX support

PATCH New Sergey Temerkhanov 3 participants 13 messages Apr 16, 2015 – Jul 2, 2015

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/7 armv8:New MMU setup code allowing to set up 2-level page tables

This patch adds code which sets up 2-level page tables on ARM64 thus extending available VA space. CPUs implementing 64k translation granule are able to use direct PA-VA mapping of the whole 48 bit address space.
It also adds the ability to reset the SCTRL register at the very beginning of execution to avoid interference from stale mappings set up by early firmware/loaders/etc.

---
 arch/arm/cpu/armv8/cache_v8.c      | 95 ++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/armv8/start.S         | 36 +++++++++++++++
 arch/arm/include/asm/armv8/mmu.h   | 79 ++++++++++++++++++++++++++++---
 arch/arm/include/asm/global_data.h |  1 +
 arch/arm/include/asm/system.h      |  6 +++
 arch/arm/lib/board.c               |  6 ++-
 6 files changed, 215 insertions(+), 8 deletions(-)
arch/arm/cpu/armv8/cache_v8.c +95 -0
index c5ec529..1264caa 100644
@@ -12,6 +12,8 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifndef CONFIG_SYS_DCACHE_OFF
+
+#ifndef CONFIG_SYS_FULL_VA
 void set_pgtable_section(u64 *page_table, u64 index, u64 section,
 			 u64 memory_type)
 {
@@ -65,6 +67,99 @@ static void mmu_setup(void)
 	set_sctlr(get_sctlr() | CR_M);
 }
 
+#else
+
+static void set_ptl1_entry(u64 index, u64 ptl2_entry)
+{
+	u64 *pgd = (u64 *)gd->arch.tlb_addr;
+	u64 value;
+
+	value = ptl2_entry | PTL1_TYPE_TABLE;
+	pgd[index] = value;
+}
+
+static void set_ptl2_block(u64 ptl1, u64 bfn, u64 address, u64 memory_type)
+{
+	u64 *pmd = (u64 *)ptl1;
+	u64 value;
+
+	value = address | PTL2_TYPE_BLOCK | PTL2_BLOCK_AF;
+	value |= PMD_ATTRINDX(memory_type);
+	pmd[bfn] = value;
+}
+
+static struct mm_region mem_map[] = CONFIG_SYS_MEM_MAP;
+
+#define PTL1_ENTRIES CONFIG_SYS_PTL1_ENTRIES
+#define PTL2_ENTRIES CONFIG_SYS_PTL2_ENTRIES
+
+static void setup_pgtables(void)
+{
+	int l1_e, l2_e;
+	unsigned long pmd = 0;
+	unsigned long address;
+
+	/* Setup the PMD pointers */
+	for (l1_e = 0; l1_e < CONFIG_SYS_MEM_MAP_SIZE; l1_e++) {
+		gd->arch.pmd_addr[l1_e] = gd->arch.tlb_addr +
+						PTL1_ENTRIES * sizeof(u64);
+		gd->arch.pmd_addr[l1_e] += PTL2_ENTRIES * sizeof(u64) * l1_e;
+		gd->arch.pmd_addr[l1_e] += 0xffffUL;
+		gd->arch.pmd_addr[l1_e] &= ~0xffffUL;
+	}
+
+/* Setup the page tables */
+	for (l1_e = 0; l1_e < PTL1_ENTRIES; l1_e++) {
+		if (mem_map[pmd].base ==
+			(uintptr_t)l1_e << PTL1_BITS) {
+			set_ptl1_entry(l1_e, gd->arch.pmd_addr[pmd]);
+
+			for (l2_e = 0; l2_e < PTL2_ENTRIES; l2_e++) {
+				address = mem_map[pmd].base
+					+ (uintptr_t)l2_e * BLOCK_SIZE;
+				set_ptl2_block(gd->arch.pmd_addr[pmd], l2_e,
+					       address, mem_map[pmd].attrs);
+		}
+
+		pmd++;
+	} else {
+		set_ptl1_entry(l1_e, 0);
+	}
+}
+}
+
+/* to activate the MMU we need to set up page tables */
+static void mmu_setup(void)
+{
+	int el;
+	unsigned long coreid = read_mpidr() & CONFIG_COREID_MASK;
+
+	/* Set up page tables only on BSP */
+	if (coreid == BSP_COREID)
+		setup_pgtables();
+
+	/* load TTBR0 */
+	el = current_el();
+
+	if (el == 1) {
+		set_ttbr_tcr_mair(el, gd->arch.tlb_addr,
+				  TCR_FLAGS | TCR_EL1_IPS_BITS,
+				  MEMORY_ATTRIBUTES);
+	} else if (el == 2) {
+		set_ttbr_tcr_mair(el, gd->arch.tlb_addr,
+				  TCR_FLAGS | TCR_EL2_IPS_BITS,
+				  MEMORY_ATTRIBUTES);
+	} else {
+		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);
+}
+
+#endif
+
 /*
  * Performs a invalidation of the entire data cache at all levels
  */
arch/arm/cpu/armv8/start.S +36 -0
index e5f2766..ea686de 100644
@@ -19,6 +19,9 @@
 
 .globl	_start
 _start:
+#ifdef CONFIG_SYS_RESET_SCTRL
+	bl	reset_sctrl
+#endif
 	b	reset
 
 	.align 3
@@ -97,6 +100,39 @@ master_cpu:
 
 	bl	_main
 
+#ifdef CONFIG_SYS_RESET_SCTRL
+reset_sctrl:
+	switch_el x1, 3f, 2f, 1f
+3:
+	mrs	x0, sctlr_el3
+	b	0f
+2:
+	mrs	x0, sctlr_el2
+	b	0f
+1:
+	mrs	x0, sctlr_el1
+
+0:
+	ldr	x1, =0xfdfffffa
+	and	x0, x0, x1
+
+	switch_el x1, 6f, 5f, 4f
+6:
+	msr	sctlr_el3, x0
+	b	7f
+5:
+	msr	sctlr_el2, x0
+	b	7f
+4:
+	msr	sctlr_el1, x0
+
+7:
+	dsb	sy
+	isb
+	b	__asm_invalidate_tlb_all
+	ret
+#endif
+
 /*-----------------------------------------------------------------------*/
 
 WEAK(apply_core_errata)
arch/arm/include/asm/armv8/mmu.h +73 -6

134 lines not on this page · raw message

arch/arm/include/asm/global_data.h +1 -0
index bb24f33..963c99a 100644
@@ -42,6 +42,7 @@ struct arch_global_data {
 	unsigned long long timer_reset_value;
 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
 	unsigned long tlb_addr;
+	unsigned long pmd_addr[CONFIG_SYS_PTL1_ENTRIES];
 	unsigned long tlb_size;
 #endif
 
arch/arm/include/asm/system.h +6 -0
index 2a5bed2..b778a6c 100644
@@ -14,7 +14,11 @@
 #define CR_WXN		(1 << 19)	/* Write Permision Imply XN	*/
 #define CR_EE		(1 << 25)	/* Exception (Big) Endian	*/
 
+#ifndef CONFIG_SYS_FULL_VA
 #define PGTABLE_SIZE	(0x10000)
+#else
+#define PGTABLE_SIZE	CONFIG_SYS_PGTABLE_SIZE
+#endif
 
 #ifndef __ASSEMBLY__
 
@@ -129,7 +133,9 @@ void flush_l3_cache(void);
 #define CR_AFE	(1 << 29)	/* Access flag enable			*/
 #define CR_TE	(1 << 30)	/* Thumb exception enable		*/
 
+#ifndef PGTABLE_SIZE
 #define PGTABLE_SIZE		(4096 * 4)
+#endif
 
 /*
  * This is used to ensure the compiler did actually allocate the register we
arch/arm/lib/board.c +4 -2
index f606255..cb874ba 100644
@@ -327,10 +327,12 @@ void board_init_f(ulong bootflag)
 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
 	/* reserve TLB table */
 	gd->arch.tlb_size = PGTABLE_SIZE;
-	addr -= gd->arch.tlb_size;
+	gd->arch.tlb_size += 0xffff;
+	gd->arch.tlb_size &= ~(0x10000 - 1);
 
-	/* round down to next 64 kB limit */
+	addr -= gd->arch.tlb_size;
 	addr &= ~(0x10000 - 1);
+	/* round down to next 64 kB limit */
 
 	gd->arch.tlb_addr = addr;
 	debug("TLB table from %08lx to %08lx\n", addr, addr + gd->arch.tlb_size);
Signature · 1 line
2.1.4
#2 lore raw

PATCH 1/7 armv8:New MMU setup code allowing to set up 2-level page tables

Hello Sergey,

Quoted 10 lines · Sergey Temerkhanov

This patch adds code which sets up 2-level page tables on ARM64 thus extending available VA space. CPUs implementing 64k translation granule are able to use direct PA-VA mapping of the whole 48 bit address space.
It also adds the ability to reset the SCTRL register at the very beginning of execution to avoid interference from stale mappings set up by early firmware/loaders/etc.

Quoted 8 lines
---
 arch/arm/cpu/armv8/cache_v8.c      | 95 ++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/armv8/start.S         | 36 +++++++++++++++
 arch/arm/include/asm/armv8/mmu.h   | 79 ++++++++++++++++++++++++++++---
 arch/arm/include/asm/global_data.h |  1 +
 arch/arm/include/asm/system.h      |  6 +++
 arch/arm/lib/board.c               |  6 ++-
 6 files changed, 215 insertions(+), 8 deletions(-)

This is actually a v2 if the 3-patch series which you posted prevously, right? If so, then next time please tag the series accordingly ("v2", "V3" etc).

arch/arm/cpu/armv8/cache_v8.c line 16

Quoted 10 lines
arch/arm/cpu/armv8/cache_v8.c +2 -0
index c5ec529..1264caa 100644
@@ -12,6 +12,8 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifndef CONFIG_SYS_DCACHE_OFF
+
+#ifndef CONFIG_SYS_FULL_VA

CONFIG_SYS_FULL_VA does not exist yet, so it is introduced in this patch. Therefore it should be described somewhere, e.g. in doc/README.arm64, so that readers of the code can refer to the description if they need to.

arch/arm/cpu/armv8/cache_v8.c static void mmu_setup(void) · line 112

Quoted 5 lines
arch/arm/cpu/armv8/cache_v8.c +4 -0
+	/* Setup the PMD pointers */
+	for (l1_e = 0; l1_e < CONFIG_SYS_MEM_MAP_SIZE; l1_e++) {
 
+/* Setup the page tables */
+	for (l1_e = 0; l1_e < PTL1_ENTRIES; l1_e++) {

Real nitpicking here, but why is the comment not aligned@the same column as the code after it?

arch/arm/cpu/armv8/cache_v8.c

Quoted 6 lines

.globl _start
_start:

arch/arm/cpu/armv8/cache_v8.c +3 -0
+#ifdef CONFIG_SYS_RESET_SCTRL
+	bl	reset_sctrl
+#endif
 	b	reset

Er, no. The _start symbol branches to the reset label. If you really need to call something early after start of execution, you do it a bit later, but not here.

Amicalement,

Signature · 1 line
Albert.
#3 lore raw

PATCH 2/7 armv8:Add SMC calls infrastructure

In reply to Sergey Temerkhanov

This commit adds functions issuing calls to firmware. This allows to use services such as PSCI provided by firmware, e.g. ATF

---
 arch/arm/cpu/armv8/Makefile   |  1 +
 arch/arm/cpu/armv8/fwcall.c   | 79 +++++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/system.h |  8 +++++
 3 files changed, 88 insertions(+)
 create mode 100644 arch/arm/cpu/armv8/fwcall.c
arch/arm/cpu/armv8/Makefile +1 -0
index dee5e25..208d012 100644
@@ -14,6 +14,7 @@ obj-y	+= exceptions.o
 obj-y	+= cache.o
 obj-y	+= tlb.o
 obj-y	+= transition.o
+obj-y	+= fwcall.o
 
 obj-$(CONFIG_FSL_LSCH3) += fsl-lsch3/
 obj-$(CONFIG_TARGET_XILINX_ZYNQMP) += zynqmp/
arch/arm/cpu/armv8/fwcall.c new file +79 -0

79 lines not on this page · raw message

arch/arm/include/asm/system.h +8 -0
index b778a6c..aac15cc 100644
@@ -1,6 +1,9 @@
 #ifndef __ASM_ARM_SYSTEM_H
 #define __ASM_ARM_SYSTEM_H
 
+#include <common.h>
+#include <linux/compiler.h>
+
 #ifdef CONFIG_ARM64
 
 /*
@@ -85,6 +88,11 @@ void smp_kick_all_cpus(void);
 
 void flush_l3_cache(void);
 
+#define __asmeq(x, y)  ".ifnc " x "," y " ; .err ; .endif\n\t"
+
+void hvc_call(struct pt_regs *args);
+void smc_call(struct pt_regs *args);
+
 #endif	/* __ASSEMBLY__ */
 
 #else /* CONFIG_ARM64 */
Signature · 1 line
2.1.4
#4 lore raw

PATCH 3/7 armv8:Add psci.h from the Linux kernel

In reply to Sergey Temerkhanov

This commit adds the psci.h header file from Linux kernel which contains definitions related to the PSCI interface provided by firmware

---
 include/linux/psci.h | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)
 create mode 100644 include/linux/psci.h
include/linux/psci.h new file +90 -0
new file mode 100644
index 0000000..310d83e
@@ -0,0 +1,90 @@
+/*
+ * ARM Power State and Coordination Interface (PSCI) header
+ *
+ * This header holds common PSCI defines and macros shared
+ * by: ARM kernel, ARM64 kernel, KVM ARM/ARM64 and user space.
+ *
+ * Copyright (C) 2014 Linaro Ltd.
+ * Author: Anup Patel <[email protected]>
+ */
+
+#ifndef _UAPI_LINUX_PSCI_H
+#define _UAPI_LINUX_PSCI_H
+
+/*
+ * PSCI v0.1 interface
+ *
+ * The PSCI v0.1 function numbers are implementation defined.
+ *
+ * Only PSCI return values such as: SUCCESS, NOT_SUPPORTED,
+ * INVALID_PARAMS, and DENIED defined below are applicable
+ * to PSCI v0.1.
+ */
+
+/* PSCI v0.2 interface */
+#define PSCI_0_2_FN_BASE			0x84000000
+#define PSCI_0_2_FN(n)				(PSCI_0_2_FN_BASE + (n))
+#define PSCI_0_2_64BIT				0x40000000
+#define PSCI_0_2_FN64_BASE			\
+					(PSCI_0_2_FN_BASE + PSCI_0_2_64BIT)
+#define PSCI_0_2_FN64(n)			(PSCI_0_2_FN64_BASE + (n))
+
+#define PSCI_0_2_FN_PSCI_VERSION		PSCI_0_2_FN(0)
+#define PSCI_0_2_FN_CPU_SUSPEND			PSCI_0_2_FN(1)
+#define PSCI_0_2_FN_CPU_OFF			PSCI_0_2_FN(2)
+#define PSCI_0_2_FN_CPU_ON			PSCI_0_2_FN(3)
+#define PSCI_0_2_FN_AFFINITY_INFO		PSCI_0_2_FN(4)
+#define PSCI_0_2_FN_MIGRATE			PSCI_0_2_FN(5)
+#define PSCI_0_2_FN_MIGRATE_INFO_TYPE		PSCI_0_2_FN(6)
+#define PSCI_0_2_FN_MIGRATE_INFO_UP_CPU		PSCI_0_2_FN(7)
+#define PSCI_0_2_FN_SYSTEM_OFF			PSCI_0_2_FN(8)
+#define PSCI_0_2_FN_SYSTEM_RESET		PSCI_0_2_FN(9)
+
+#define PSCI_0_2_FN64_CPU_SUSPEND		PSCI_0_2_FN64(1)
+#define PSCI_0_2_FN64_CPU_ON			PSCI_0_2_FN64(3)
+#define PSCI_0_2_FN64_AFFINITY_INFO		PSCI_0_2_FN64(4)
+#define PSCI_0_2_FN64_MIGRATE			PSCI_0_2_FN64(5)
+#define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU	PSCI_0_2_FN64(7)
+
+/* PSCI v0.2 power state encoding for CPU_SUSPEND function */
+#define PSCI_0_2_POWER_STATE_ID_MASK		0xffff
+#define PSCI_0_2_POWER_STATE_ID_SHIFT		0
+#define PSCI_0_2_POWER_STATE_TYPE_SHIFT		16
+#define PSCI_0_2_POWER_STATE_TYPE_MASK		\
+				(0x1 << PSCI_0_2_POWER_STATE_TYPE_SHIFT)
+#define PSCI_0_2_POWER_STATE_AFFL_SHIFT		24
+#define PSCI_0_2_POWER_STATE_AFFL_MASK		\
+				(0x3 << PSCI_0_2_POWER_STATE_AFFL_SHIFT)
+
+/* PSCI v0.2 affinity level state returned by AFFINITY_INFO */
+#define PSCI_0_2_AFFINITY_LEVEL_ON		0
+#define PSCI_0_2_AFFINITY_LEVEL_OFF		1
+#define PSCI_0_2_AFFINITY_LEVEL_ON_PENDING	2
+
+/* PSCI v0.2 multicore support in Trusted OS returned by MIGRATE_INFO_TYPE */
+#define PSCI_0_2_TOS_UP_MIGRATE			0
+#define PSCI_0_2_TOS_UP_NO_MIGRATE		1
+#define PSCI_0_2_TOS_MP				2
+
+/* PSCI version decoding (independent of PSCI version) */
+#define PSCI_VERSION_MAJOR_SHIFT		16
+#define PSCI_VERSION_MINOR_MASK			\
+		((1U << PSCI_VERSION_MAJOR_SHIFT) - 1)
+#define PSCI_VERSION_MAJOR_MASK			~PSCI_VERSION_MINOR_MASK
+#define PSCI_VERSION_MAJOR(ver)			\
+		(((ver) & PSCI_VERSION_MAJOR_MASK) >> PSCI_VERSION_MAJOR_SHIFT)
+#define PSCI_VERSION_MINOR(ver)			\
+		((ver) & PSCI_VERSION_MINOR_MASK)
+
+/* PSCI return values (inclusive of all PSCI versions) */
+#define PSCI_RET_SUCCESS			0
+#define PSCI_RET_NOT_SUPPORTED			-1
+#define PSCI_RET_INVALID_PARAMS			-2
+#define PSCI_RET_DENIED				-3
+#define PSCI_RET_ALREADY_ON			-4
+#define PSCI_RET_ON_PENDING			-5
+#define PSCI_RET_INTERNAL_FAILURE		-6
+#define PSCI_RET_NOT_PRESENT			-7
+#define PSCI_RET_DISABLED			-8
+
+#endif /* _UAPI_LINUX_PSCI_H */
Signature · 1 line
2.1.4
#5 lore raw

PATCH 4/7 arm: uart: Add ability to use pre-initialized UARTs

In reply to Sergey Temerkhanov

On some systems, UART initialization is performed before running U-Boot. This commit allows to skip UART re-initializaion on those systems

---
 drivers/serial/serial_pl01x.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/serial/serial_pl01x.c +3 -1
index 75eb6bd..be9a14a 100644
@@ -69,7 +69,7 @@ static int pl01x_tstc(struct pl01x_regs *regs)
 	return !(readl(&regs->fr) & UART_PL01x_FR_RXFE);
 }
 
-static int pl01x_generic_serial_init(struct pl01x_regs *regs,
+static __used int pl01x_generic_serial_init(struct pl01x_regs *regs,
 				     enum pl01x_type type)
 {
 	switch (type) {
@@ -204,7 +204,9 @@ static void pl01x_serial_init_baud(int baudrate)
 #endif
 	base_regs = (struct pl01x_regs *)port[CONFIG_CONS_INDEX];
 
+#ifndef CONFIG_PL010_SERIAL_PREINIT
 	pl01x_generic_serial_init(base_regs, pl01x_type);
+#endif
 	pl01x_generic_setbrg(base_regs, pl01x_type, clock, baudrate);
 }
 
Signature · 1 line
2.1.4
#6 lore raw

PATCH 4/7 arm: uart: Add ability to use pre-initialized UARTs

Hello Sergey,

Quoted 10 lines · Sergey Temerkhanov

On some systems, UART initialization is performed before running U-Boot. This commit allows to skip UART re-initializaion on those systems

---
 drivers/serial/serial_pl01x.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

+#ifndef CONFIG_PL010_SERIAL_PREINIT

This configuration option is new; please add a description of it somewhere in a README.* under doc/.

Amicalement,

Signature · 1 line
Albert.
#7 lore raw

PATCH 5/7 armv8: cavium: Add ThunderX 88xx board definition

In reply to Sergey Temerkhanov

This commit adds basic Cavium ThunderX 88xx board definitions and support.

---
 arch/arm/Kconfig                 |   4 +
 board/cavium/thunderx/Kconfig    |  19 +++++
 board/cavium/thunderx/Makefile   |   8 ++
 board/cavium/thunderx/thunderx.c |  59 +++++++++++++
 configs/thunderx_88xx_defconfig  |   3 +
 include/configs/thunderx_88xx.h  | 173 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 266 insertions(+)
 create mode 100644 board/cavium/thunderx/Kconfig
 create mode 100644 board/cavium/thunderx/Makefile
 create mode 100644 board/cavium/thunderx/thunderx.c
 create mode 100644 configs/thunderx_88xx_defconfig
 create mode 100644 include/configs/thunderx_88xx.h
arch/arm/Kconfig +4 -0
index 7ed0e20..858a15a 100644
@@ -727,6 +727,9 @@ config ARCH_UNIPHIER
 	select SPL
 	select OF_CONTROL
 
+config TARGET_THUNDERX_88XX
+	bool "Support ThunderX 88xx"
+
 endchoice
 
 source "arch/arm/mach-at91/Kconfig"
@@ -887,6 +890,7 @@ source "board/work-microwave/work_92105/Kconfig"
 source "board/xaeniax/Kconfig"
 source "board/xilinx/zynqmp/Kconfig"
 source "board/zipitz2/Kconfig"
+source "board/cavium/thunderx/Kconfig"
 
 source "arch/arm/Kconfig.debug"
 
board/cavium/thunderx/Kconfig new file +19 -0
new file mode 100644
index 0000000..3e62abf
@@ -0,0 +1,19 @@
+if TARGET_THUNDERX_88XX
+
+config SYS_CPU
+	string
+	default "armv8"
+
+config SYS_BOARD
+	string
+	default "thunderx"
+
+config SYS_VENDOR
+	string
+	default "cavium"
+
+config SYS_CONFIG_NAME
+	string
+	default "thunderx_88xx"
+
+endif
board/cavium/thunderx/Makefile new file +8 -0
new file mode 100644
index 0000000..306044a
@@ -0,0 +1,8 @@
+#
+#
+# (C) Copyright 2014, Cavium Inc.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y	:= thunderx.o
board/cavium/thunderx/thunderx.c new file +59 -0

59 lines not on this page · raw message

configs/thunderx_88xx_defconfig new file +3 -0
new file mode 100644
index 0000000..79fa65a
@@ -0,0 +1,3 @@
+CONFIG_SYS_EXTRA_OPTIONS="ARM64"
+CONFIG_ARM=y
+CONFIG_TARGET_THUNDERX_88XX=y
include/configs/thunderx_88xx.h new file +173 -0

173 lines not on this page · raw message

Signature · 1 line
2.1.4
#8 lore raw

PATCH 5/7 armv8: cavium: Add ThunderX 88xx board definition

Hello Sergey,

Quoted 4 lines · Sergey Temerkhanov

This commit adds basic Cavium ThunderX 88xx board definitions and support.

Quoted 13 lines
---
 arch/arm/Kconfig                 |   4 +
 board/cavium/thunderx/Kconfig    |  19 +++++
 board/cavium/thunderx/Makefile   |   8 ++
 board/cavium/thunderx/thunderx.c |  59 +++++++++++++
 configs/thunderx_88xx_defconfig  |   3 +
 include/configs/thunderx_88xx.h  | 173 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 266 insertions(+)
 create mode 100644 board/cavium/thunderx/Kconfig
 create mode 100644 board/cavium/thunderx/Makefile
 create mode 100644 board/cavium/thunderx/thunderx.c
 create mode 100644 configs/thunderx_88xx_defconfig
 create mode 100644 include/configs/thunderx_88xx.h

There should also be a board/cavium/thunderx/MAINTAINERS file.

Amicalement,

Signature · 1 line
Albert.
#9 lore raw

PATCH 6/7 armv8: cavium: Add an implementation of ATF calling functions

In reply to Sergey Temerkhanov

This commit adds functions issuing calls to the product-specific ATF services

---
 board/cavium/thunderx/Makefile  |   2 +-
 board/cavium/thunderx/atf.c     | 312 ++++++++++++++++++++++++++++++++++++++++
 include/cavium/atf.h            |  22 +++
 include/cavium/atf_part.h       |  26 ++++
 include/cavium/thunderx_svc.h   |  67 +++++++++
 include/configs/thunderx_88xx.h |   2 +
 6 files changed, 430 insertions(+), 1 deletion(-)
 create mode 100644 board/cavium/thunderx/atf.c
 create mode 100644 include/cavium/atf.h
 create mode 100644 include/cavium/atf_part.h
 create mode 100644 include/cavium/thunderx_svc.h
board/cavium/thunderx/Makefile +1 -1
index 306044a..c78c414 100644
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-y	:= thunderx.o
+obj-y	:= thunderx.o atf.o
board/cavium/thunderx/atf.c new file +312 -0

312 lines not on this page · raw message

include/cavium/atf.h new file +22 -0
new file mode 100644
index 0000000..0a53c2f
@@ -0,0 +1,22 @@
+/**
+ * (C) Copyright 2014, Cavium Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+**/
+#ifndef __ATF_H__
+#define __ATF_H__
+#include <cavium/atf_part.h>
+
+ssize_t atf_read_mmc(uintptr_t offset, void *buffer, size_t size);
+ssize_t atf_read_nor(uintptr_t offset, void *buffer, size_t size);
+ssize_t atf_get_pcount(void);
+ssize_t atf_get_part(struct storage_partition *part, unsigned int index);
+ssize_t atf_erase_nor(uintptr_t offset, size_t size);
+ssize_t atf_write_nor(uintptr_t offset, const void *buffer, size_t size);
+ssize_t atf_write_mmc(uintptr_t offset, const void *buffer, size_t size);
+ssize_t atf_dram_size(unsigned int node);
+ssize_t atf_node_count(void);
+ssize_t atf_env_count(void);
+ssize_t atf_env_string(size_t index, char *str);
+
+#endif
include/cavium/atf_part.h new file +26 -0
new file mode 100644
index 0000000..182f6f4
@@ -0,0 +1,26 @@
+/**
+ * (C) Copyright 2014, Cavium Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+**/
+
+#ifndef __ATF_PART_H__
+#define __ATF_PART_H__
+
+struct storage_partition {
+	unsigned int type;
+	unsigned int size;
+	unsigned long offset;
+};
+
+enum {
+	PARTITION_NBL1FW_REST = 0,
+	PARTITION_BL2_BL31 = 1,
+	PARTITION_UBOOT = 2,
+	PARTITION_UEFI = 2,
+	PARTITION_KERNEL = 3,
+	PARTITION_DEVICE_TREE = 4,
+	PARTITION_LAST,
+};
+
+#endif
include/cavium/thunderx_svc.h new file +67 -0

67 lines not on this page · raw message

include/configs/thunderx_88xx.h +2 -0
index d5f5a6c..2a307da 100644
@@ -31,6 +31,8 @@
 
 #define MEM_BASE			0x00500000
 
+#define CONFIG_SYS_LOWMEM_BASE		MEM_BASE
+
 #define CONFIG_SYS_MEM_MAP		{{0x000000000000UL, 0x40000000000UL, \
 					  MT_NORMAL}, \
 					 {0x800000000000UL, 0x40000000000UL, \
Signature · 1 line
2.1.4
#10 lore raw

PATCH 7/7 armv8: cavium: Get DRAM size from ATF

In reply to Sergey Temerkhanov

Change the dram_init() function on ThunderXto query ATF services for the real installed DRAM size

---
 board/cavium/thunderx/Makefile   |  2 +-
 board/cavium/thunderx/dram.c     | 35 +++++++++++++++++++++++++++++++++++
 board/cavium/thunderx/thunderx.c | 12 ------------
 3 files changed, 36 insertions(+), 13 deletions(-)
 create mode 100644 board/cavium/thunderx/dram.c
board/cavium/thunderx/Makefile +1 -1
index c78c414..9200dd6 100644
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-y	:= thunderx.o atf.o
+obj-y	:= thunderx.o atf.o dram.o
board/cavium/thunderx/dram.c new file +35 -0
new file mode 100644
index 0000000..858699d
@@ -0,0 +1,35 @@
+/**
+ * (C) Copyright 2014, Cavium Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+**/
+
+#include <common.h>
+#include <cavium/atf.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int dram_init(void)
+{
+	ssize_t node_count = atf_node_count();
+	ssize_t dram_size;
+	int node;
+
+	printf("Initializing\nNodes in system: %zd\n", node_count);
+
+	gd->ram_size = 0;
+
+	for (node = 0; node < node_count; node++) {
+		dram_size = atf_dram_size(node);
+		printf("Node %d: %zd MBytes of DRAM\n", node, dram_size >> 20);
+		gd->ram_size += dram_size;
+	}
+
+	gd->ram_size -= MEM_BASE;
+
+	*(unsigned long *)CPU_RELEASE_ADDR = 0;
+
+	puts("DRAM size:");
+
+	return 0;
+}
board/cavium/thunderx/thunderx.c +0 -12
index 5a5e259..a5cf7c5 100644
@@ -16,18 +16,6 @@ int board_init(void)
 	return 0;
 }
 
-int dram_init(void)
-{
-	/*
-	 * Clear spin table so that secondary processors
-	 * observe the correct value after waken up from wfe.
-	 */
-	*(unsigned long *)CPU_RELEASE_ADDR = 0;
-
-	gd->ram_size = PHYS_SDRAM_1_SIZE;
-	return 0;
-}
-
 int timer_init(void)
 {
 	return 0;
Signature · 1 line
2.1.4
#11 lore raw

cover Add Cavium ThunderX support

In reply to Sergey Temerkhanov
Quoted 2 lines · Sergey Temerkhanov

This patch series adds support for Cavium ThunderX 88xx SoC family
(http://www.cavium.com/ThunderX_ARM_Processors.html).

Wrong cover-letter, please use the proper git command to produce the cover-letter,
that should be easier when we send mail back up-on applied patches in summary.

Suggestions: Use patman useful tool or refer this link [1] for more info

[1] http://www.denx.de/wiki/U-Boot/Patches

thanks!

Signature · 2 lines
Jagan Teki,
Openedev.
#12 lore raw

cover Add Cavium ThunderX support

Can you send the series again on top of latest code base, looks some duplicate code not feasible to review.

Quoted 16 lines · Jagan Teki
Quoted 2 lines · Sergey Temerkhanov

This patch series adds support for Cavium ThunderX 88xx SoC family
(http://www.cavium.com/ThunderX_ARM_Processors.html).

Wrong cover-letter, please use the proper git command to produce the cover-letter,
that should be easier when we send mail back up-on applied patches in summary.

Suggestions: Use patman useful tool or refer this link [1] for more info

[1] http://www.denx.de/wiki/U-Boot/Patches

thanks!
--
Jagan Teki,
Openedev.

Signature · 2 lines
Jagan Teki,
Openedev.