Skip to contentSkip to conversation

Add support for ThunderX 88xx SoC family

PATCH Superseded Sergey Temerkhanov 2 participants 15 messages Sep 25, 2015 – Sep 28, 2015

Subsystems (2)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover Add support for ThunderX 88xx SoC family

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

This is the version 6 of the series I posted at
http://lists.denx.de/pipermail/u-boot/2015-September/227088.html
http://lists.denx.de/pipermail/u-boot/2015-August/224324.html
http://lists.denx.de/pipermail/u-boot/2015-August/223618.html

Changes in v6:
- Fixed lack of protection in global_data.h
- Changed the 'PL0X_PREINITIALIZED' flag to the 'skip-init' bool
- Added /chosen node
- Added 'u-boot,skip-init' property to the FDT

Changes in v5:
- Allow setting of different memory attributes in the memory map
- Added OF control support
- Added FDT for ThunderX 88xx series
- Added CONFIG_OF_CONTROL support
- Changed memory attributes
- Moved dram_init() from a separate file to thunderx.c

Changes in v4:
- Use ALIGN macro for address alignment
- Document FW calls
- Fixed build warnings
- Moved to DM_SERIAL
- Moved CONFIG_SYS_PROMPT to configs/thunderx_88xx_defconfig
- Added proper DM_SERIAL definitions

Changes in v3:
- Reduced code duplication
- Renamed CONFIG_SYS_PTL1_BITS to CONFIG_SYS_PTL2_BITS
- Moved 'reset_sctrl' call to the 'reset' label
- Rebased to the actual upstream tree
- Documented newly added config options
- Fixed clobber lists (thanks to Corey)
- Added __used keyword
- Fixed formatting
- Added MAINTAINERS
- Moved command definitions to defconfig

Changes in v2:
- Changed code licensing
- Completed the patchset

Sergey Temerkhanov (9):
armv8: Add read_mpidr() function
armv8: New MMU setup code allowing to use 48+ bits PA/VA
armv8: Add Secure Monitor/Hypervisor Call (SMC/HVC) infrastructure
armv8: Add psci.h from the Linux kernel
arm: serial: Add ability to use pre-initialized UARTs
armv8: cavium: Add the device tree for ThunderX
armv8: cavium: Add ThunderX 88xx board definition
armv8: cavium: Add an implementation of ATF calling functions
armv8: cavium: Get DRAM size from ATF

 arch/arm/Kconfig                          |   7 +
 arch/arm/cpu/armv8/Makefile               |   1 +
 arch/arm/cpu/armv8/cache_v8.c             |  79 +++++++
 arch/arm/cpu/armv8/fwcall.c               |  75 ++++++
 arch/arm/cpu/armv8/start.S                |  36 +++
 arch/arm/dts/Makefile                     |   1 +
 arch/arm/dts/thunderx-88xx.dts            |  31 +++
 arch/arm/dts/thunderx-88xx.dtsi           | 363 ++++++++++++++++++++++++++++++
 arch/arm/include/asm/armv8/mmu.h          |  82 ++++++-
 arch/arm/include/asm/global_data.h        |   3 +
 arch/arm/include/asm/system.h             |  39 ++++
 arch/arm/lib/board.c                      |   6 +-
 board/cavium/thunderx/Kconfig             |  19 ++
 board/cavium/thunderx/MAINTAINERS         |   6 +
 board/cavium/thunderx/Makefile            |   8 +
 board/cavium/thunderx/atf.c               | 312 +++++++++++++++++++++++++
 board/cavium/thunderx/thunderx.c          | 102 +++++++++
 configs/thunderx_88xx_defconfig           |  29 +++
 doc/README.arm64                          |  35 ++-
 doc/device-tree-bindings/serial/pl01x.txt |   3 +
 drivers/serial/serial_pl01x.c             |  14 +-
 include/cavium/atf.h                      |  22 ++
 include/cavium/atf_part.h                 |  26 +++
 include/cavium/thunderx_svc.h             |  67 ++++++
 include/configs/thunderx_88xx.h           | 148 ++++++++++++
 include/dm/platform_data/serial_pl01x.h   |   2 +
 include/linux/psci.h                      |  90 ++++++++
 27 files changed, 1586 insertions(+), 20 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/fwcall.c
 create mode 100644 arch/arm/dts/thunderx-88xx.dts
 create mode 100644 arch/arm/dts/thunderx-88xx.dtsi
 create mode 100644 board/cavium/thunderx/Kconfig
 create mode 100644 board/cavium/thunderx/MAINTAINERS
 create mode 100644 board/cavium/thunderx/Makefile
 create mode 100644 board/cavium/thunderx/atf.c
 create mode 100644 board/cavium/thunderx/thunderx.c
 create mode 100644 configs/thunderx_88xx_defconfig
 create mode 100644 include/cavium/atf.h
 create mode 100644 include/cavium/atf_part.h
 create mode 100644 include/cavium/thunderx_svc.h
 create mode 100644 include/configs/thunderx_88xx.h
 create mode 100644 include/linux/psci.h
Signature · 1 line
2.2.0
#1 lore raw

PATCH v6 1/9 armv8: Add read_mpidr() function

This patch adds the read_mpidr() function which returns the MPIDR_EL1 register value

---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/include/asm/system.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/include/asm/system.h +11 -0
index 868ea54..323c43e 100644
@@ -71,6 +71,17 @@ static inline void set_sctlr(unsigned int val)
 	asm volatile("isb");
 }
 
+static inline unsigned long read_mpidr(void)
+{
+	unsigned long val;
+
+	asm volatile("mrs %0, mpidr_el1" : "=r" (val));
+
+	return val;
+}
+
+#define BSP_COREID	0
+
 void __asm_flush_dcache_all(void);
 void __asm_invalidate_dcache_all(void);
 void __asm_flush_dcache_range(u64 start, u64 end);
Signature · 1 line
2.2.0
#2 lore raw

PATCH v6 2/9 armv8: New MMU setup code allowing to use 48+ bits PA/VA

In reply to 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.

---

Changes in v6:
- Fixed lack of protection in global_data.h

Changes in v5:
- Allow setting of different memory attributes in the memory map

Changes in v4:
- Use ALIGN macro for address alignment

Changes in v3:
- Reduced code duplication
- Renamed CONFIG_SYS_PTL1_BITS to CONFIG_SYS_PTL2_BITS
- Moved 'reset_sctrl' call to the 'reset' label
- Rebased to the actual upstream tree
- Documented newly added config options

Changes in v2:
- Changed code licensing
- Completed the patchset

 arch/arm/cpu/armv8/cache_v8.c      | 79 ++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/armv8/start.S         | 36 +++++++++++++++++
 arch/arm/include/asm/armv8/mmu.h   | 82 +++++++++++++++++++++++++++++++++++---
 arch/arm/include/asm/global_data.h |  3 ++
 arch/arm/include/asm/system.h      |  7 ++++
 arch/arm/lib/board.c               |  6 ++-
 doc/README.arm64                   | 35 +++++++++++++---
 7 files changed, 234 insertions(+), 14 deletions(-)
arch/arm/cpu/armv8/cache_v8.c +79 -0
index 6bde1cf..989b17e 100644
@@ -12,6 +12,69 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifndef CONFIG_SYS_DCACHE_OFF
+
+#ifdef CONFIG_SYS_FULL_VA
+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_attrs)
+{
+	u64 *pmd = (u64 *)ptl1;
+	u64 value;
+
+	value = address | PTL2_TYPE_BLOCK | PTL2_BLOCK_AF;
+	value |= memory_attrs;
+	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] = ALIGN(gd->arch.pmd_addr[l1_e],
+						0x10000UL);
+	}
+
+	/* Setup the page tables */
+	for (l1_e = 0; l1_e < PTL1_ENTRIES; l1_e++) {
+		if (mem_map[pmd].base ==
+			(uintptr_t)l1_e << PTL2_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);
+		}
+	}
+}
+
+#else
+
 inline void set_pgtable_section(u64 *page_table, u64 index, u64 section,
 			 u64 memory_type, u64 share)
 {
@@ -31,13 +94,25 @@ inline void set_pgtable_table(u64 *page_table, u64 index, u64 *table_addr)
 	page_table[index] = value;
 }
 
+#endif
+
+
 /* to activate the MMU we need to set up virtual memory */
 static void mmu_setup(void)
 {
+#ifndef CONFIG_SYS_FULL_VA
 	bd_t *bd = gd->bd;
 	u64 *page_table = (u64 *)gd->arch.tlb_addr, i, j;
+#endif
 	int el;
 
+#ifdef CONFIG_SYS_FULL_VA
+	unsigned long coreid = read_mpidr() & CONFIG_COREID_MASK;
+
+	/* Set up page tables only on BSP */
+	if (coreid == BSP_COREID)
+		setup_pgtables();
+#else
 	/* Setup an identity-mapping for all spaces */
 	for (i = 0; i < (PGTABLE_SIZE >> 3); i++) {
 		set_pgtable_section(page_table, i, i << SECTION_SHIFT,
@@ -55,6 +130,7 @@ static void mmu_setup(void)
 		}
 	}
 
+#endif
 	/* load TTBR0 */
 	el = current_el();
 	if (el == 1) {
@@ -154,6 +230,7 @@ u64 *__weak arch_get_page_table(void) {
 	return NULL;
 }
 
+#ifndef CONFIG_SYS_FULL_VA
 void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
 				     enum dcache_option option)
 {
@@ -179,6 +256,8 @@ void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
 	flush_dcache_range(start, end);
 	asm volatile("dsb sy");
 }
+#endif
+
 #else	/* CONFIG_SYS_DCACHE_OFF */
 
 void invalidate_dcache_all(void)
arch/arm/cpu/armv8/start.S +36 -0
index da45d98..2ee60d6 100644
@@ -43,6 +43,9 @@ _bss_end_ofs:
 	.quad	__bss_end - _start
 
 reset:
+#ifdef CONFIG_SYS_RESET_SCTRL
+	bl reset_sctrl
+#endif
 	/*
 	 * Could be EL3/EL2/EL1, Initial State:
 	 * Little Endian, MMU Disabled, i/dCache Disabled
@@ -99,6 +102,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 +76 -6

141 lines not on this page · raw message

arch/arm/include/asm/global_data.h +3 -0
index 4e3ea55..4d5c976 100644
@@ -38,6 +38,9 @@ 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;
+#if defined(CONFIG_SYS_FULL_VA)
+	unsigned long pmd_addr[CONFIG_SYS_PTL1_ENTRIES];
+#endif
 	unsigned long tlb_size;
 #endif
 
arch/arm/include/asm/system.h +7 -0
index 323c43e..9288541 100644
@@ -14,7 +14,12 @@
 #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
+
 /* 2MB granularity */
 #define MMU_SECTION_SHIFT	21
 
@@ -147,7 +152,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 37ea6e9..0c9c66a 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);
doc/README.arm64 +29 -6
index 75586db..f32108f 100644
@@ -36,11 +36,34 @@ Notes
 6. CONFIG_ARM64 instead of CONFIG_ARMV8 is used to distinguish aarch64 and
    aarch32 specific codes.
 
+7. CONFIG_SYS_FULL_VA is used to enable 2-level page tables. For cores
+   supporting 64k pages it allows usage of full 48+ virtual/physical addresses
+
+   Enabling this option requires the following ones to be defined:
+       - CONFIG_SYS_MEM_MAP - an array of 'struct mm_region' describing the
+         system memory map (start, length, attributes)
+       - CONFIG_SYS_MEM_MAP_SIZE - number of entries in CONFIG_SYS_MEM_MAP
+       - CONFIG_SYS_PTL1_ENTRIES - number of 1st level page table entries
+       - CONFIG_SYS_PTL2_ENTRIES - number of 1nd level page table entries
+         for the largest CONFIG_SYS_MEM_MAP entry
+       - CONFIG_COREID_MASK - the mask value used to get the core from the
+         MPIDR_EL1 register
+       - CONFIG_SYS_PTL2_BITS - number of bits addressed by the 2nd level
+         page tables
+       - CONFIG_SYS_BLOCK_SHIFT - number of bits addressed by a single block
+         entry from L2 page tables
+       - CONFIG_SYS_PGTABLE_SIZE - total size of the page table
+       - CONFIG_SYS_TCR_EL{1,2,3}_IPS_BITS - the IPS field of the TCR_EL{1,2,3}
+
+
+
+
 Contributor
 ===========
-   Tom Rini       <[email protected]>
-   Scott Wood     <[email protected]>
-   York Sun       <[email protected]>
-   Simon Glass    <[email protected]>
-   Sharma Bhupesh <[email protected]>
-   Rob Herring    <[email protected]>
+   Tom Rini            <[email protected]>
+   Scott Wood          <[email protected]>
+   York Sun            <[email protected]>
+   Simon Glass         <[email protected]>
+   Sharma Bhupesh      <[email protected]>
+   Rob Herring         <[email protected]>
+   Sergey Temerkhanov  <[email protected]>
Signature · 1 line
2.2.0
#3 lore raw

PATCH v6 3/9 armv8: Add Secure Monitor/Hypervisor Call (SMC/HVC) infrastructure

In reply to Sergey Temerkhanov

This commit adds functions issuing calls to secure monitor or hypervisore. This allows using services such as Power State Coordination Interface (PSCI) provided by firmware, e.g. ARM Trusted Firmware (ATF)

The SMC call can destroy all registers declared temporary by the calling conventions. The clobber list is "x0..x17" because of this

---

Changes in v6: None
Changes in v5: None
Changes in v4:
- Document FW calls

Changes in v3:
- Fixed clobber lists (thanks to Corey)

Changes in v2: None

 arch/arm/cpu/armv8/Makefile   |  1 +
 arch/arm/cpu/armv8/fwcall.c   | 75 +++++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/system.h | 21 ++++++++++++
 3 files changed, 97 insertions(+)
 create mode 100644 arch/arm/cpu/armv8/fwcall.c
arch/arm/cpu/armv8/Makefile +1 -0
index adb11b3..7579ea7 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_ARCH_ZYNQMP) += zynqmp/
arch/arm/cpu/armv8/fwcall.c new file +75 -0

75 lines not on this page · raw message

arch/arm/include/asm/system.h +21 -0
index 9288541..f3e2d1b 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
 
 /*
@@ -104,6 +107,24 @@ void smp_kick_all_cpus(void);
 
 void flush_l3_cache(void);
 
+/*
+ *Issue a hypervisor call in accordance with ARM "SMC Calling convention",
+ * DEN0028A
+ *
+ * @args: input and output arguments
+ *
+ */
+void hvc_call(struct pt_regs *args);
+
+/*
+ *Issue a secure monitor call in accordance with ARM "SMC Calling convention",
+ * DEN0028A
+ *
+ * @args: input and output arguments
+ *
+ */
+void smc_call(struct pt_regs *args);
+
 #endif	/* __ASSEMBLY__ */
 
 #else /* CONFIG_ARM64 */
Signature · 1 line
2.2.0
#4 lore raw

PATCH v6 4/9 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

---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 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.2.0
#5 lore raw

PATCH v6 5/9 arm: serial: 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

---

Changes in v6:
- Changed the 'PL0X_PREINITIALIZED' flag to the 'skip-init' bool

Changes in v5:
- Added OF control support

Changes in v4:
- Fixed build warnings
- Moved to DM_SERIAL

Changes in v3:
- Added __used keyword

Changes in v2: None

 doc/device-tree-bindings/serial/pl01x.txt |  3 +++
 drivers/serial/serial_pl01x.c             | 14 ++++++++------
 include/dm/platform_data/serial_pl01x.h   |  2 ++
 3 files changed, 13 insertions(+), 6 deletions(-)
doc/device-tree-bindings/serial/pl01x.txt +3 -0
index 61c27d1..0591497 100644
@@ -5,3 +5,6 @@ Required properties:
 - reg: exactly one register range with length 0x1000
 - clock: input clock frequency for the UART (used to calculate the baud
   rate divisor)
+
+Optional properties:
+- u-boot,skip-init: skip UART initialization at start.
drivers/serial/serial_pl01x.c +8 -6
index 3a5c1d0..de9f642 100644
@@ -103,7 +103,7 @@ static int pl011_set_line_control(struct pl01x_regs *regs)
 }
 
 static int pl01x_generic_setbrg(struct pl01x_regs *regs, enum pl01x_type type,
-				int clock, int baudrate)
+				       int clock, int baudrate)
 {
 	switch (type) {
 	case TYPE_PL010: {
@@ -273,7 +273,6 @@ __weak struct serial_device *default_serial_console(void)
 #endif /* nCONFIG_DM_SERIAL */
 
 #ifdef CONFIG_DM_SERIAL
-
 struct pl01x_priv {
 	struct pl01x_regs *regs;
 	enum pl01x_type type;
@@ -284,9 +283,9 @@ static int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
 	struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
 	struct pl01x_priv *priv = dev_get_priv(dev);
 
-	pl01x_generic_setbrg(priv->regs, priv->type, plat->clock, baudrate);
-
-	return 0;
+	return plat->skip_init ? 0 :
+		pl01x_generic_setbrg(priv->regs, priv->type,
+				     plat->clock, baudrate);
 }
 
 static int pl01x_serial_probe(struct udevice *dev)
@@ -296,7 +295,8 @@ static int pl01x_serial_probe(struct udevice *dev)
 
 	priv->regs = (struct pl01x_regs *)plat->base;
 	priv->type = plat->type;
-	return pl01x_generic_serial_init(priv->regs, priv->type);
+	return plat->skip_init ? 0 :
+		pl01x_generic_serial_init(priv->regs, priv->type);
 }
 
 static int pl01x_serial_getc(struct udevice *dev)
@@ -350,6 +350,8 @@ static int pl01x_serial_ofdata_to_platdata(struct udevice *dev)
 	plat->base = addr;
 	plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1);
 	plat->type = dev_get_driver_data(dev);
+	plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+					  "uboot,skip-init");
 	return 0;
 }
 #endif
include/dm/platform_data/serial_pl01x.h +2 -0
index 5e068f3..10e9572 100644
@@ -17,11 +17,13 @@ enum pl01x_type {
  * @base: Register base address
  * @type: Port type
  * @clock: Input clock rate, used for calculating the baud rate divisor
+ * @flags: Port flags
  */
 struct pl01x_serial_platdata {
 	unsigned long base;
 	enum pl01x_type type;
 	unsigned int clock;
+	bool skip_init;
 };
 
 #endif
Signature · 1 line
2.2.0
#6 lore raw

PATCH v6 6/9 armv8: cavium: Add the device tree for ThunderX

In reply to Sergey Temerkhanov

This commit adds the FDT for the ThunderX family of SoCs

---

Changes in v6:
- Added /chosen node

Changes in v5:
- Added FDT for ThunderX 88xx series

Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/dts/Makefile           |   1 +
 arch/arm/dts/thunderx-88xx.dts  |  31 ++++
 arch/arm/dts/thunderx-88xx.dtsi | 363 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 395 insertions(+)
 create mode 100644 arch/arm/dts/thunderx-88xx.dts
 create mode 100644 arch/arm/dts/thunderx-88xx.dtsi
arch/arm/dts/Makefile +1 -0
index 5f10243..ef123c50 100644
@@ -61,6 +61,7 @@ dtb-$(CONFIG_ARCH_ZYNQ) += zynq-zc702.dtb \
 	zynq-zc770-xm012.dtb \
 	zynq-zc770-xm013.dtb
 dtb-$(CONFIG_AM33XX) += am335x-boneblack.dtb am335x-evm.dtb
+dtb-$(CONFIG_THUNDERX) += thunderx-88xx.dtb
 
 dtb-$(CONFIG_ARCH_SOCFPGA) +=				\
 	socfpga_arria5_socdk.dtb			\
arch/arm/dts/thunderx-88xx.dts new file +31 -0
new file mode 100644
index 0000000..08f2678
@@ -0,0 +1,31 @@
+/*
+ * Cavium Thunder DTS file - Thunder board description
+ *
+ * Copyright (C) 2014, Cavium Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+ or X11
+ *
+ */
+
+/dts-v1/;
+
+/include/ "thunderx-88xx.dtsi"
+
+/ {
+	model = "Cavium ThunderX CN88XX board";
+	compatible = "cavium,thunder-88xx";
+
+	aliases {
+		serial0 = &uaa0;
+		serial1 = &uaa1;
+	};
+
+	chosen {
+                stdout-path = &uaa0;
+        };
+
+	memory at 00000000 {
+		device_type = "memory";
+		reg = <0x0 0x00000000 0x0 0x80000000>;
+	};
+};
arch/arm/dts/thunderx-88xx.dtsi new file +363 -0

363 lines not on this page · raw message

Signature · 1 line
2.2.0
#7 lore raw

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

In reply to Sergey Temerkhanov

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

---

Changes in v6:
- Added 'u-boot,skip-init' property to the FDT

Changes in v5:
- Added CONFIG_OF_CONTROL support
- Changed memory attributes

Changes in v4:
- Moved CONFIG_SYS_PROMPT to configs/thunderx_88xx_defconfig
- Added proper DM_SERIAL definitions

Changes in v3:
- Fixed formatting
- Added MAINTAINERS
- Moved command definitions to defconfig

Changes in v2: None

 arch/arm/Kconfig                  |   7 ++
 arch/arm/dts/thunderx-88xx.dtsi   |   4 +-
 board/cavium/thunderx/Kconfig     |  19 +++++
 board/cavium/thunderx/MAINTAINERS |   6 ++
 board/cavium/thunderx/Makefile    |   8 +++
 board/cavium/thunderx/thunderx.c  |  75 ++++++++++++++++++++
 configs/thunderx_88xx_defconfig   |  29 ++++++++
 include/configs/thunderx_88xx.h   | 146 ++++++++++++++++++++++++++++++++++++++
 8 files changed, 292 insertions(+), 2 deletions(-)
 create mode 100644 board/cavium/thunderx/Kconfig
 create mode 100644 board/cavium/thunderx/MAINTAINERS
 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 +7 -0
index c4371c7..66625c3 100644
@@ -651,6 +651,10 @@ config ARCH_ROCKCHIP
 	select CPU_V7
 	select DM
 
+config TARGET_THUNDERX_88XX
+	bool "Support ThunderX 88xx"
+	select OF_CONTROL
+
 endchoice
 
 source "arch/arm/mach-at91/Kconfig"
@@ -781,6 +785,9 @@ source "board/technologic/ts4800/Kconfig"
 source "board/vscom/baltos/Kconfig"
 source "board/woodburn/Kconfig"
 source "board/work-microwave/work_92105/Kconfig"
+source "board/xaeniax/Kconfig"
+source "board/zipitz2/Kconfig"
+source "board/cavium/thunderx/Kconfig"
 
 source "arch/arm/Kconfig.debug"
 
arch/arm/dts/thunderx-88xx.dtsi +2 -2
index 086652f..56c0d6e 100644
@@ -348,7 +348,7 @@
 			interrupts = <1 21 4>;
 			clocks = <&refclk50mhz>;
 			clock-names = "apb_pclk";
-			flags = <1>;
+			u-boot,skip-init;
 		};
 
 		uaa1: serial at 87e0,25000000 {
@@ -357,7 +357,7 @@
 			interrupts = <1 22 4>;
 			clocks = <&refclk50mhz>;
 			clock-names = "apb_pclk";
-			flags = <1>;
+			u-boot,skip-init;
 		};
 	};
 };
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/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..c84d3b5
@@ -0,0 +1,6 @@
+THUNDERX BOARD
+M:	Sergey Temerkhanov <[email protected]>
+S:	Maintained
+F:	board/cavium/thunderx/
+F:	include/configs/thunderx_88xx.h
+F:	configs/thunderx_88xx_defconfig
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 +75 -0

75 lines not on this page · raw message

configs/thunderx_88xx_defconfig new file +29 -0
new file mode 100644
index 0000000..554686f
@@ -0,0 +1,29 @@
+CONFIG_SYS_EXTRA_OPTIONS="ARM64"
+CONFIG_ARM=y
+CONFIG_TARGET_THUNDERX_88XX=y
+CONFIG_SYS_PROMPT="ThunderX_88XX> "
+
+CONFIG_DM=y
+CONFIG_DM_SERIAL=y
+CONFIG_DM_STDIO=y
+CONFIG_DEFAULT_DEVICE_TREE="thunderx-88xx"
+
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_BDI=y
+CONFIG_CMD_DIAG=y
+CONFIG_CMD_ENV=y
+CONFIG_CMD_IMI=y
+CONFIG_CMD_MEMORY=y
+CONFIG_CMD_RUN=y
+CONFIG_CMD_BOOTD=y
+CONFIG_CMD_ECHO=y
+CONFIG_CMD_SOURCE=y
+
+CONFIG_CMD_LOADB=y
+CONFIG_CMD_LOADS=y
+CONFIG_CMD_SAVES=y
+
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_IMLS is not set
+
+CONFIG_CMD_ATF=y
include/configs/thunderx_88xx.h new file +146 -0

146 lines not on this page · raw message

Signature · 1 line
2.2.0
#8 lore raw

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

Quoted 4 lines · Sergey Temerkhanov

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

[snip]

Quoted 1 line
 configs/thunderx_88xx_defconfig   |  29 ++++++++

This is not the output of 'savedefconfig' which is how I found the ATF problem. Please use 'savedefconfig' to generate this config, thanks.

Also, the new entry in arch/arm/Kconfig should be added alphabetically and should not re-add deleted boards back in :)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150928/4501ea5f/attachment.sig>
#9 lore raw

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

Quoted 11 lines · Tom Rini
Quoted 4 lines · Sergey Temerkhanov

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

[snip]

Quoted 1 line
 configs/thunderx_88xx_defconfig   |  29 ++++++++

This is not the output of 'savedefconfig' which is how I found the ATF problem. Please use 'savedefconfig' to generate this config, thanks.

OK, thanks for the tip

Quoted 3 lines

Also, the new entry in arch/arm/Kconfig should be added alphabetically and should not re-add deleted boards back in :)

Must be some rebasing/merging residue.

Quoted 3 lines

--
Tom

Regards,
Sergey

#10 lore raw

PATCH v6 8/9 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

---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 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 36c2244..2104504 100644
@@ -28,6 +28,8 @@
 
 #define CONFIG_SYS_FULL_VA
 
+#define CONFIG_SYS_LOWMEM_BASE		MEM_BASE
+
 #define CONFIG_SYS_MEM_MAP		{{0x000000000000UL, 0x40000000000UL, \
 					  PTL2_MEMTYPE(MT_NORMAL) |	     \
 					  PTL2_BLOCK_NON_SHARE},	     \
Signature · 1 line
2.2.0
#11 lore raw

PATCH v6 8/9 armv8: cavium: Add an implementation of ATF calling functions

Quoted 5 lines · Sergey Temerkhanov

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

OK, problem:

Quoted 142 lines
board/cavium/thunderx/atf.c new file +142 -0
+#ifdef CONFIG_CMD_ATF
+
+static void atf_print_ver(void)
+{
+	struct pt_regs regs;
+	regs.regs[0] = ARM_STD_SVC_VERSION;
+
+	smc_call(&regs);
+
+	printf("ARM Std FW version: %ld.%ld\n", regs.regs[0], regs.regs[1]);
+
+	regs.regs[0] = THUNDERX_SVC_VERSION;
+
+	smc_call(&regs);
+
+	printf("ThunderX OEM ver: %ld.%ld\n", regs.regs[0], regs.regs[1]);
+}
+
+static void atf_print_uid(void)
+{
+}
+
+static void atf_print_part_table(void)
+{
+	size_t pcount;
+	unsigned long i;
+	int ret;
+	char *ptype;
+
+	struct storage_partition *part = (void *)CONFIG_SYS_LOWMEM_BASE;
+
+	pcount = atf_get_pcount();
+
+	printf("Partition count: %lu\n\n", pcount);
+	printf("%10s %10s %10s\n", "Type", "Size", "Offset");
+
+	for (i = 0; i < pcount; i++) {
+		ret = atf_get_part(part, i);
+
+		if (ret < 0) {
+			printf("Uknown error while reading partition: %d\n",
+			       ret);
+			return;
+		}
+
+		switch (part->type) {
+		case PARTITION_NBL1FW_REST:
+			ptype = "NBL1FW";
+			break;
+		case PARTITION_BL2_BL31:
+			ptype = "BL2_BL31";
+			break;
+		case PARTITION_UBOOT:
+			ptype = "BOOTLDR";
+			break;
+		case PARTITION_KERNEL:
+			ptype = "KERNEL";
+			break;
+		case PARTITION_DEVICE_TREE:
+			ptype = "DEVTREE";
+			break;
+		default:
+			ptype = "UNKNOWN";
+		}
+		printf("%10s %10d %10lx\n", ptype, part->size, part->offset);
+	}
+}
+
+int do_atf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	ssize_t ret;
+	size_t size, offset;
+	void *buffer = 0;
+	unsigned int index, node;
+	char str[4 * sizeof(uint64_t)];
+
+	if ((argc == 5) && !strcmp(argv[1], "readmmc")) {
+		buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+		offset = simple_strtoul(argv[3], NULL, 10);
+		size = simple_strtoul(argv[4], NULL, 10);
+
+		ret = atf_read_mmc(offset, buffer, size);
+	} else if ((argc == 5) && !strcmp(argv[1], "readnor")) {
+		buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+		offset = simple_strtoul(argv[3], NULL, 10);
+		size = simple_strtoul(argv[4], NULL, 10);
+
+		ret = atf_read_nor(offset, buffer, size);
+	} else if ((argc == 5) && !strcmp(argv[1], "writemmc")) {
+		buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+		offset = simple_strtoul(argv[3], NULL, 10);
+		size = simple_strtoul(argv[4], NULL, 10);
+
+		ret = atf_write_mmc(offset, buffer, size);
+	} else if ((argc == 5) && !strcmp(argv[1], "writenor")) {
+		buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+		offset = simple_strtoul(argv[3], NULL, 10);
+		size = simple_strtoul(argv[4], NULL, 10);
+
+		ret = atf_write_nor(offset, buffer, size);
+	} else if ((argc == 2) && !strcmp(argv[1], "part")) {
+		atf_print_part_table();
+	} else if ((argc == 4) && !strcmp(argv[1], "erasenor")) {
+		offset = simple_strtoul(argv[2], NULL, 10);
+		size = simple_strtoul(argv[3], NULL, 10);
+
+		ret = atf_erase_nor(offset, size);
+	} else if ((argc == 2) && !strcmp(argv[1], "envcount")) {
+		ret = atf_env_count();
+		printf("Number of environment strings: %zd\n", ret);
+	} else if ((argc == 3) && !strcmp(argv[1], "envstring")) {
+		index = simple_strtoul(argv[2], NULL, 10);
+		ret = atf_env_string(index, str);
+		if (ret > 0)
+			printf("Environment string %d: %s\n", index, str);
+		else
+			printf("Return code: %zd\n", ret);
+	} else if ((argc == 3) && !strcmp(argv[1], "dramsize")) {
+		node = simple_strtoul(argv[2], NULL, 10);
+		ret = atf_dram_size(node);
+		printf("DRAM size: %zd Mbytes\n", ret >> 20);
+	} else if ((argc == 2) && !strcmp(argv[1], "nodes")) {
+		ret = atf_node_count();
+		printf("Nodes count: %zd\n", ret);
+	} else if ((argc == 2) && !strcmp(argv[1], "ver")) {
+		atf_print_ver();
+	} else if ((argc == 2) && !strcmp(argv[1], "uid")) {
+		atf_print_uid();
+	} else {
+		return CMD_RET_USAGE;
+	}
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	atf,   10,   1,     do_atf,
+	"issue calls to ATF",
+	"\t readmmc addr offset size - read MMC card\n"
+	"\t readnor addr offset size - read NOR flash\n"
+	"\t writemmc addr offset size - write MMC card\n"
+	"\t writenor addr offset size - write NOR flash\n"

board/cavium/thunderx/atf.c line 312

Quoted 10 lines
board/cavium/thunderx/atf.c new file +10 -0
+	"\t erasenor offset size - erase NOR flash\n"
+	"\t nodes - number of nodes\n"
+	"\t dramsize node - size of DRAM attached to node\n"
+	"\t envcount - number of environment strings\n"
+	"\t envstring index - print the environment string\n"
+	"\t part - print MMC partition table\n"
+	"\t ver - print ATF call set versions\n"
+);
+
+#endif

But you don't add a Kconfig entry for CMD_ATF anywhere and you just set it in the Kconfig defconfig file for the board and it will then be dropped out upon reading because there's no Kconfig entry for it, so this code is never built in. Please fix.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150928/a0393554/attachment.sig>
#12 lore raw

PATCH v6 8/9 armv8: cavium: Add an implementation of ATF calling functions

Quoted 159 lines · Tom Rini
Quoted 5 lines · Sergey Temerkhanov

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

OK, problem:

Quoted 149 lines
board/cavium/thunderx/atf.c new file +149 -0
+#ifdef CONFIG_CMD_ATF
+
+static void atf_print_ver(void)
+{
+     struct pt_regs regs;
+     regs.regs[0] = ARM_STD_SVC_VERSION;
+
+     smc_call(&regs);
+
+     printf("ARM Std FW version: %ld.%ld\n", regs.regs[0], regs.regs[1]);
+
+     regs.regs[0] = THUNDERX_SVC_VERSION;
+
+     smc_call(&regs);
+
+     printf("ThunderX OEM ver: %ld.%ld\n", regs.regs[0], regs.regs[1]);
+}
+
+static void atf_print_uid(void)
+{
+}
+
+static void atf_print_part_table(void)
+{
+     size_t pcount;
+     unsigned long i;
+     int ret;
+     char *ptype;
+
+     struct storage_partition *part = (void *)CONFIG_SYS_LOWMEM_BASE;
+
+     pcount = atf_get_pcount();
+
+     printf("Partition count: %lu\n\n", pcount);
+     printf("%10s %10s %10s\n", "Type", "Size", "Offset");
+
+     for (i = 0; i < pcount; i++) {
+             ret = atf_get_part(part, i);
+
+             if (ret < 0) {
+                     printf("Uknown error while reading partition: %d\n",
+                            ret);
+                     return;
+             }
+
+             switch (part->type) {
+             case PARTITION_NBL1FW_REST:
+                     ptype = "NBL1FW";
+                     break;
+             case PARTITION_BL2_BL31:
+                     ptype = "BL2_BL31";
+                     break;
+             case PARTITION_UBOOT:
+                     ptype = "BOOTLDR";
+                     break;
+             case PARTITION_KERNEL:
+                     ptype = "KERNEL";
+                     break;
+             case PARTITION_DEVICE_TREE:
+                     ptype = "DEVTREE";
+                     break;
+             default:
+                     ptype = "UNKNOWN";
+             }
+             printf("%10s %10d %10lx\n", ptype, part->size, part->offset);
+     }
+}
+
+int do_atf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+     ssize_t ret;
+     size_t size, offset;
+     void *buffer = 0;
+     unsigned int index, node;
+     char str[4 * sizeof(uint64_t)];
+
+     if ((argc == 5) && !strcmp(argv[1], "readmmc")) {
+             buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+             offset = simple_strtoul(argv[3], NULL, 10);
+             size = simple_strtoul(argv[4], NULL, 10);
+
+             ret = atf_read_mmc(offset, buffer, size);
+     } else if ((argc == 5) && !strcmp(argv[1], "readnor")) {
+             buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+             offset = simple_strtoul(argv[3], NULL, 10);
+             size = simple_strtoul(argv[4], NULL, 10);
+
+             ret = atf_read_nor(offset, buffer, size);
+     } else if ((argc == 5) && !strcmp(argv[1], "writemmc")) {
+             buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+             offset = simple_strtoul(argv[3], NULL, 10);
+             size = simple_strtoul(argv[4], NULL, 10);
+
+             ret = atf_write_mmc(offset, buffer, size);
+     } else if ((argc == 5) && !strcmp(argv[1], "writenor")) {
+             buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+             offset = simple_strtoul(argv[3], NULL, 10);
+             size = simple_strtoul(argv[4], NULL, 10);
+
+             ret = atf_write_nor(offset, buffer, size);
+     } else if ((argc == 2) && !strcmp(argv[1], "part")) {
+             atf_print_part_table();
+     } else if ((argc == 4) && !strcmp(argv[1], "erasenor")) {
+             offset = simple_strtoul(argv[2], NULL, 10);
+             size = simple_strtoul(argv[3], NULL, 10);
+
+             ret = atf_erase_nor(offset, size);
+     } else if ((argc == 2) && !strcmp(argv[1], "envcount")) {
+             ret = atf_env_count();
+             printf("Number of environment strings: %zd\n", ret);
+     } else if ((argc == 3) && !strcmp(argv[1], "envstring")) {
+             index = simple_strtoul(argv[2], NULL, 10);
+             ret = atf_env_string(index, str);
+             if (ret > 0)
+                     printf("Environment string %d: %s\n", index, str);
+             else
+                     printf("Return code: %zd\n", ret);
+     } else if ((argc == 3) && !strcmp(argv[1], "dramsize")) {
+             node = simple_strtoul(argv[2], NULL, 10);
+             ret = atf_dram_size(node);
+             printf("DRAM size: %zd Mbytes\n", ret >> 20);
+     } else if ((argc == 2) && !strcmp(argv[1], "nodes")) {
+             ret = atf_node_count();
+             printf("Nodes count: %zd\n", ret);
+     } else if ((argc == 2) && !strcmp(argv[1], "ver")) {
+             atf_print_ver();
+     } else if ((argc == 2) && !strcmp(argv[1], "uid")) {
+             atf_print_uid();
+     } else {
+             return CMD_RET_USAGE;
+     }
+
+     return 0;
+}
+
+U_BOOT_CMD(
+     atf,   10,   1,     do_atf,
+     "issue calls to ATF",
+     "\t readmmc addr offset size - read MMC card\n"
+     "\t readnor addr offset size - read NOR flash\n"
+     "\t writemmc addr offset size - write MMC card\n"
+     "\t writenor addr offset size - write NOR flash\n"
+     "\t erasenor offset size - erase NOR flash\n"
+     "\t nodes - number of nodes\n"
+     "\t dramsize node - size of DRAM attached to node\n"
+     "\t envcount - number of environment strings\n"
+     "\t envstring index - print the environment string\n"
+     "\t part - print MMC partition table\n"
+     "\t ver - print ATF call set versions\n"
Quoted 8 lines

board/cavium/thunderx/atf.c line 312

Quoted 3 lines
board/cavium/thunderx/atf.c new file +3 -0
+);
+
+#endif

But you don't add a Kconfig entry for CMD_ATF anywhere and you just set it in the Kconfig defconfig file for the board and it will then be dropped out upon reading because there's no Kconfig entry for it, so this code is never built in. Please fix.

I've fixed this. Do I submit v7 or just this one along with 7/9?

Quoted 3 lines

--
Tom

Regards,
Sergey

#13 lore raw

PATCH v6 8/9 armv8: cavium: Add an implementation of ATF calling functions

Quoted 169 lines · Sergei Temerkhanov
Quoted 159 lines · Tom Rini
Quoted 5 lines · Sergey Temerkhanov

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

OK, problem:

Quoted 149 lines
board/cavium/thunderx/atf.c new file +149 -0
+#ifdef CONFIG_CMD_ATF
+
+static void atf_print_ver(void)
+{
+     struct pt_regs regs;
+     regs.regs[0] = ARM_STD_SVC_VERSION;
+
+     smc_call(&regs);
+
+     printf("ARM Std FW version: %ld.%ld\n", regs.regs[0], regs.regs[1]);
+
+     regs.regs[0] = THUNDERX_SVC_VERSION;
+
+     smc_call(&regs);
+
+     printf("ThunderX OEM ver: %ld.%ld\n", regs.regs[0], regs.regs[1]);
+}
+
+static void atf_print_uid(void)
+{
+}
+
+static void atf_print_part_table(void)
+{
+     size_t pcount;
+     unsigned long i;
+     int ret;
+     char *ptype;
+
+     struct storage_partition *part = (void *)CONFIG_SYS_LOWMEM_BASE;
+
+     pcount = atf_get_pcount();
+
+     printf("Partition count: %lu\n\n", pcount);
+     printf("%10s %10s %10s\n", "Type", "Size", "Offset");
+
+     for (i = 0; i < pcount; i++) {
+             ret = atf_get_part(part, i);
+
+             if (ret < 0) {
+                     printf("Uknown error while reading partition: %d\n",
+                            ret);
+                     return;
+             }
+
+             switch (part->type) {
+             case PARTITION_NBL1FW_REST:
+                     ptype = "NBL1FW";
+                     break;
+             case PARTITION_BL2_BL31:
+                     ptype = "BL2_BL31";
+                     break;
+             case PARTITION_UBOOT:
+                     ptype = "BOOTLDR";
+                     break;
+             case PARTITION_KERNEL:
+                     ptype = "KERNEL";
+                     break;
+             case PARTITION_DEVICE_TREE:
+                     ptype = "DEVTREE";
+                     break;
+             default:
+                     ptype = "UNKNOWN";
+             }
+             printf("%10s %10d %10lx\n", ptype, part->size, part->offset);
+     }
+}
+
+int do_atf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+     ssize_t ret;
+     size_t size, offset;
+     void *buffer = 0;
+     unsigned int index, node;
+     char str[4 * sizeof(uint64_t)];
+
+     if ((argc == 5) && !strcmp(argv[1], "readmmc")) {
+             buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+             offset = simple_strtoul(argv[3], NULL, 10);
+             size = simple_strtoul(argv[4], NULL, 10);
+
+             ret = atf_read_mmc(offset, buffer, size);
+     } else if ((argc == 5) && !strcmp(argv[1], "readnor")) {
+             buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+             offset = simple_strtoul(argv[3], NULL, 10);
+             size = simple_strtoul(argv[4], NULL, 10);
+
+             ret = atf_read_nor(offset, buffer, size);
+     } else if ((argc == 5) && !strcmp(argv[1], "writemmc")) {
+             buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+             offset = simple_strtoul(argv[3], NULL, 10);
+             size = simple_strtoul(argv[4], NULL, 10);
+
+             ret = atf_write_mmc(offset, buffer, size);
+     } else if ((argc == 5) && !strcmp(argv[1], "writenor")) {
+             buffer = (void *)simple_strtoul(argv[2], NULL, 16);
+             offset = simple_strtoul(argv[3], NULL, 10);
+             size = simple_strtoul(argv[4], NULL, 10);
+
+             ret = atf_write_nor(offset, buffer, size);
+     } else if ((argc == 2) && !strcmp(argv[1], "part")) {
+             atf_print_part_table();
+     } else if ((argc == 4) && !strcmp(argv[1], "erasenor")) {
+             offset = simple_strtoul(argv[2], NULL, 10);
+             size = simple_strtoul(argv[3], NULL, 10);
+
+             ret = atf_erase_nor(offset, size);
+     } else if ((argc == 2) && !strcmp(argv[1], "envcount")) {
+             ret = atf_env_count();
+             printf("Number of environment strings: %zd\n", ret);
+     } else if ((argc == 3) && !strcmp(argv[1], "envstring")) {
+             index = simple_strtoul(argv[2], NULL, 10);
+             ret = atf_env_string(index, str);
+             if (ret > 0)
+                     printf("Environment string %d: %s\n", index, str);
+             else
+                     printf("Return code: %zd\n", ret);
+     } else if ((argc == 3) && !strcmp(argv[1], "dramsize")) {
+             node = simple_strtoul(argv[2], NULL, 10);
+             ret = atf_dram_size(node);
+             printf("DRAM size: %zd Mbytes\n", ret >> 20);
+     } else if ((argc == 2) && !strcmp(argv[1], "nodes")) {
+             ret = atf_node_count();
+             printf("Nodes count: %zd\n", ret);
+     } else if ((argc == 2) && !strcmp(argv[1], "ver")) {
+             atf_print_ver();
+     } else if ((argc == 2) && !strcmp(argv[1], "uid")) {
+             atf_print_uid();
+     } else {
+             return CMD_RET_USAGE;
+     }
+
+     return 0;
+}
+
+U_BOOT_CMD(
+     atf,   10,   1,     do_atf,
+     "issue calls to ATF",
+     "\t readmmc addr offset size - read MMC card\n"
+     "\t readnor addr offset size - read NOR flash\n"
+     "\t writemmc addr offset size - write MMC card\n"
+     "\t writenor addr offset size - write NOR flash\n"
+     "\t erasenor offset size - erase NOR flash\n"
+     "\t nodes - number of nodes\n"
+     "\t dramsize node - size of DRAM attached to node\n"
+     "\t envcount - number of environment strings\n"
+     "\t envstring index - print the environment string\n"
+     "\t part - print MMC partition table\n"
+     "\t ver - print ATF call set versions\n"
Quoted 8 lines

board/cavium/thunderx/atf.c line 312

Quoted 3 lines
board/cavium/thunderx/atf.c new file +3 -0
+);
+
+#endif

But you don't add a Kconfig entry for CMD_ATF anywhere and you just set it in the Kconfig defconfig file for the board and it will then be dropped out upon reading because there's no Kconfig entry for it, so this code is never built in. Please fix.

Quoted 1 line

I've fixed this. Do I submit v7 or just this one along with 7/9?

Please do a v7 and give it a quick boot test too, arch/arm/lib/board.c is gone now :)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150928/d73e28c3/attachment.sig>
#14 lore raw

PATCH v6 9/9 armv8: cavium: Get DRAM size from ATF

In reply to Sergey Temerkhanov

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

---

Changes in v6: None
Changes in v5:
- Moved dram_init() from a separate file to thunderx.c

Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/cavium/thunderx/thunderx.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
board/cavium/thunderx/thunderx.c +27 -0
index 486374e..b926767 100644
@@ -9,6 +9,8 @@
 #include <errno.h>
 #include <linux/compiler.h>
 
+#include <cavium/atf.h>
+
 #if !CONFIG_IS_ENABLED(OF_CONTROL)
 #include <dm/platdata.h>
 #include <dm/platform_data/serial_pl01x.h>
@@ -50,6 +52,31 @@ int timer_init(void)
 	return 0;
 }
 
+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 specific reset that is system reset.
  */
Signature · 1 line
2.2.0