Skip to contentSkip to conversation

This patch series adds support for Cavium ThunderX 88xx SoC family

PATCH Superseded Sergey Temerkhanov 3 participants 12 messages Aug 13, 2015 – Aug 14, 2015

Subsystems (2)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover This patch series adds support for Cavium ThunderX 88xx SoC family

(http://cavium.com/ThunderX_ARM_Processors.html)

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 (8):
armv8: Add read_mpidr() function
armv8: New MMU setup code allowing to use 48+ bits PA/VA
armv8: Add SMC calls infrastructure
armv8: Add psci.h from the Linux kernel
arm: serial: Add ability to use pre-initialized UARTs
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                   |   4 +
 arch/arm/cpu/armv8/Makefile        |   1 +
 arch/arm/cpu/armv8/cache_v8.c      |  80 +++++++++-
 arch/arm/cpu/armv8/fwcall.c        |  77 +++++++++
 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      |  26 ++++
 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/dram.c       |  35 +++++
 board/cavium/thunderx/thunderx.c   |  47 ++++++
 configs/thunderx_88xx_defconfig    |  24 +++
 doc/README.arm64                   |  35 ++++-
 drivers/serial/serial_pl01x.c      |   9 +-
 include/cavium/atf.h               |  22 +++
 include/cavium/atf_part.h          |  26 ++++
 include/cavium/thunderx_svc.h      |  67 ++++++++
 include/configs/thunderx_88xx.h    | 156 +++++++++++++++++++
 include/linux/psci.h               |  90 +++++++++++
 23 files changed, 1148 insertions(+), 18 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/fwcall.c
 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/dram.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 v3 1/8 armv8: Add read_mpidr() function

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

---

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
#3 lore raw

PATCH v3 2/8 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 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      | 80 +++++++++++++++++++++++++++++++++++++-
 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      |  7 ++++
 arch/arm/lib/board.c               |  6 ++-
 doc/README.arm64                   | 35 ++++++++++++++---
 7 files changed, 229 insertions(+), 15 deletions(-)
arch/arm/cpu/armv8/cache_v8.c +79 -1
index c22f7b6..00778f2 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_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 << 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
+
 void set_pgtable_section(u64 *page_table, u64 index, u64 section,
 			 u64 memory_type)
 {
@@ -22,13 +85,25 @@ void set_pgtable_section(u64 *page_table, u64 index, u64 section,
 	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,
@@ -45,7 +120,7 @@ static void mmu_setup(void)
 					    MT_NORMAL);
 		}
 	}
-
+#endif
 	/* load TTBR0 */
 	el = current_el();
 	if (el == 1) {
@@ -145,6 +220,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)
 {
@@ -170,6 +246,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 e70bed4..a7dfe23 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
@@ -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 4e3ea55..723539c 100644
@@ -38,6 +38,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 +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
#4 lore raw

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

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.

Hi!

[...]

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

Quoted 13 lines
arch/arm/cpu/armv8/cache_v8.c +13 -0
+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;

Is this an attempt for roundup() ? See include/linux/kernel.h for that macro. Maybe you can even use round_up(), bit that has some limitations, so be careful.

Quoted 27 lines
arch/arm/cpu/armv8/cache_v8.c +24 -0
+	}
+
+	/* 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
+
 void set_pgtable_section(u64 *page_table, u64 index, u64 section,
 			 u64 memory_type)
 {

[...]

#5 lore raw

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

Quoted 1 line

Is this an attempt for roundup() ?

One might say so. The code is intended to get the 2nd level pagetable address 16 bit aligned (HW requirement)

Quoted 2 lines

See include/linux/kernel.h for that macro.
Maybe you can even use round_up(), bit that has some limitations, so be

careful.

IMO, round_up() is a bit overkill for this.

Regards,
Sergey

Quoted 68 lines · Marek Vasut
Quoted 5 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

Quoted 5 lines

of execution to avoid interference from stale mappings set up by early firmware/loaders/etc.

Hi!

[...]

arch/arm/cpu/armv8/cache_v8.c

Quoted 11 lines
arch/arm/cpu/armv8/cache_v8.c +11 -0
+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;

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

Quoted 2 lines
arch/arm/cpu/armv8/cache_v8.c +2 -0
+             gd->arch.pmd_addr[l1_e] += 0xffffUL;
+             gd->arch.pmd_addr[l1_e] &= ~0xffffUL;

Is this an attempt for roundup() ? See include/linux/kernel.h for that macro.
Maybe you can even use round_up(), bit that has some limitations, so be careful.

arch/arm/cpu/armv8/cache_v8.c

Quoted 12 lines
arch/arm/cpu/armv8/cache_v8.c +12 -0
+     }
+
+     /* 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,

Quoted 1 line

+ address,

mem_map[pmd].attrs);

Quoted 14 lines
arch/arm/cpu/armv8/cache_v8.c +11 -0
+                     }
+
+                     pmd++;
+             } else {
+                     set_ptl1_entry(l1_e, 0);
+             }
+     }
+}
+
+#else
+
 void set_pgtable_section(u64 *page_table, u64 index, u64 section,
                       u64 memory_type)
 {

[...]

#6 lore raw

PATCH v3 3/8 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

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

---

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   | 77 +++++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/system.h |  8 +++++
 3 files changed, 86 insertions(+)
 create mode 100644 arch/arm/cpu/armv8/fwcall.c
arch/arm/cpu/armv8/Makefile +1 -0
index 6466ebb..39a6ce7 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 +77 -0

77 lines not on this page · raw message

arch/arm/include/asm/system.h +8 -0
index 9288541..a4cefda 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,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.2.0
#7 lore raw

PATCH v3 4/8 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 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
#8 lore raw

PATCH v3 5/8 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 v3:
- Added __used keyword

Changes in v2: None

 drivers/serial/serial_pl01x.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/serial/serial_pl01x.c +6 -3
index ad503af..f40c3ac 100644
@@ -71,7 +71,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) {
@@ -124,8 +124,9 @@ static int pl011_set_line_control(struct pl01x_regs *regs)
 	return 0;
 }
 
-static int pl01x_generic_setbrg(struct pl01x_regs *regs, enum pl01x_type type,
-				int clock, int baudrate)
+static int __used pl01x_generic_setbrg(struct pl01x_regs *regs,
+				       enum pl01x_type type,
+				       int clock, int baudrate)
 {
 	switch (type) {
 	case TYPE_PL010: {
@@ -215,8 +216,10 @@ 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);
 	pl01x_generic_setbrg(base_regs, pl01x_type, clock, baudrate);
+#endif
 }
 
 /*
Signature · 1 line
2.2.0
#9 lore raw

PATCH v3 6/8 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 v3:
- Fixed formatting
- Added MAINTAINERS
- Moved command definitions to defconfig

Changes in v2: None

 arch/arm/Kconfig                  |   4 +
 board/cavium/thunderx/Kconfig     |  19 +++++
 board/cavium/thunderx/MAINTAINERS |   6 ++
 board/cavium/thunderx/Makefile    |   8 ++
 board/cavium/thunderx/thunderx.c  |  59 +++++++++++++++
 configs/thunderx_88xx_defconfig   |  24 ++++++
 include/configs/thunderx_88xx.h   | 154 ++++++++++++++++++++++++++++++++++++++
 7 files changed, 274 insertions(+)
 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 +4 -0
index 8b8269f..0c9f939 100644
@@ -815,6 +815,9 @@ config TARGET_STM32F429_DISCOVERY
 	bool "Support STM32F429 Discovery"
 	select CPU_V7M
 
+config TARGET_THUNDERX_88XX
+	bool "Support ThunderX 88xx"
+
 endchoice
 
 source "arch/arm/mach-at91/Kconfig"
@@ -984,6 +987,7 @@ 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"
 
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 +59 -0

59 lines not on this page · raw message

configs/thunderx_88xx_defconfig new file +24 -0
new file mode 100644
index 0000000..b17329a
@@ -0,0 +1,24 @@
+CONFIG_SYS_EXTRA_OPTIONS="ARM64"
+CONFIG_ARM=y
+CONFIG_TARGET_THUNDERX_88XX=y
+
+
+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 +154 -0

154 lines not on this page · raw message

Signature · 1 line
2.2.0
#10 lore raw

PATCH v3 7/8 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 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 98609b7..91d9f46 100644
@@ -32,6 +32,8 @@
 
 #define CONFIG_SYS_FULL_VA
 
+#define CONFIG_SYS_LOWMEM_BASE		MEM_BASE
+
 #define CONFIG_SYS_MEM_MAP		{{0x000000000000UL, 0x40000000000UL, \
 					  MT_NORMAL}, \
 					 {0x800000000000UL, 0x40000000000UL, \
Signature · 1 line
2.2.0
#11 lore raw

PATCH v3 8/8 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 v3: None
Changes in v2: None

 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.2.0