summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Gilmore <dennis@ausil.us>2014-04-26 23:38:57 -0500
committerDennis Gilmore <dennis@ausil.us>2014-04-26 23:38:57 -0500
commit3ed96a195bb01a2b94be3324f8060195a7feb1b0 (patch)
tree690d48e843aae9fbc013a2991dfcd379eebfaa85
parent1619496436087ded318042cbc8c1a5b0513c2b7f (diff)
downloaduboot-tools-3ed96a195bb01a2b94be3324f8060195a7feb1b0.tar.gz
uboot-tools-3ed96a195bb01a2b94be3324f8060195a7feb1b0.tar.xz
uboot-tools-3ed96a195bb01a2b94be3324f8060195a7feb1b0.zip
add hyp support to cubietruck image
- enables kvm support
-rw-r--r--0039-sunxi-fix-SRAM_B-SRAM_D-memory-map.patch31
-rw-r--r--0040-sunxi-add-hyp-support-on-sun7i.patch227
-rw-r--r--uboot-tools.spec10
3 files changed, 267 insertions, 1 deletions
diff --git a/0039-sunxi-fix-SRAM_B-SRAM_D-memory-map.patch b/0039-sunxi-fix-SRAM_B-SRAM_D-memory-map.patch
new file mode 100644
index 0000000..1bb004d
--- /dev/null
+++ b/0039-sunxi-fix-SRAM_B-SRAM_D-memory-map.patch
@@ -0,0 +1,31 @@
+From 007880c8871c9d7a87fa61017c5ce3f7040c38bb Mon Sep 17 00:00:00 2001
+From: Marc Zyngier <marc.zyngier@arm.com>
+Date: Sat, 7 Dec 2013 11:19:16 +0000
+Subject: [PATCH 39/40] sunxi: fix SRAM_B/SRAM_D memory map
+
+Move the B and D SRAM bank to their actual location (or at least
+where the documentation pretends they are).
+
+Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
+---
+ arch/arm/include/asm/arch-sunxi/cpu.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/arch/arm/include/asm/arch-sunxi/cpu.h b/arch/arm/include/asm/arch-sunxi/cpu.h
+index 7400559..a987e51d 100644
+--- a/arch/arm/include/asm/arch-sunxi/cpu.h
++++ b/arch/arm/include/asm/arch-sunxi/cpu.h
+@@ -15,8 +15,8 @@
+ #define SUNXI_SRAM_A2_BASE 0x00004000 /* 16 kiB */
+ #define SUNXI_SRAM_A3_BASE 0x00008000 /* 13 kiB */
+ #define SUNXI_SRAM_A4_BASE 0x0000b400 /* 3 kiB */
+-#define SUNXI_SRAM_D_BASE 0x01c00000
+-#define SUNXI_SRAM_B_BASE 0x01c00000 /* 64 kiB (secure) */
++#define SUNXI_SRAM_D_BASE 0x00010000 /* 4 kiB */
++#define SUNXI_SRAM_B_BASE 0x00020000 /* 64 kiB (secure) */
+
+ #define SUNXI_SRAMC_BASE 0x01c00000
+ #define SUNXI_DRAMC_BASE 0x01c01000
+--
+1.9.0
+
diff --git a/0040-sunxi-add-hyp-support-on-sun7i.patch b/0040-sunxi-add-hyp-support-on-sun7i.patch
new file mode 100644
index 0000000..532cfe0
--- /dev/null
+++ b/0040-sunxi-add-hyp-support-on-sun7i.patch
@@ -0,0 +1,227 @@
+From 1c257eac296e162e8c445796ef1bfb3e4095d7ba Mon Sep 17 00:00:00 2001
+From: Dennis Gilmore <dennis@ausil.us>
+Date: Sat, 26 Apr 2014 23:35:09 -0500
+Subject: [PATCH 40/40] sunxi: add hyp support on sun7i roll 2 patches sent
+ upstream into one
+
+sunxi: HYP/non-sec: add sun7i PSCI backend
+
+So far, only supporting the CPU_ON method.
+Other functions can be added later.
+
+Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
+
+sunxi: HYP/non-sec: configure CNTFRQ on all CPUs
+
+CNTFRQ needs to be properly configured on all CPUs. Otherwise,
+virtual machines hoping to find valuable information on secondary
+CPUs will be disapointed...
+
+Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
+---
+ arch/arm/cpu/armv7/sunxi/Makefile | 3 +
+ arch/arm/cpu/armv7/sunxi/psci.S | 162 ++++++++++++++++++++++++++++++++++++++
+ include/configs/sun7i.h | 7 ++
+ 3 files changed, 172 insertions(+)
+ create mode 100644 arch/arm/cpu/armv7/sunxi/psci.S
+
+diff --git a/arch/arm/cpu/armv7/sunxi/Makefile b/arch/arm/cpu/armv7/sunxi/Makefile
+index a64bfa1..03e49ca 100644
+--- a/arch/arm/cpu/armv7/sunxi/Makefile
++++ b/arch/arm/cpu/armv7/sunxi/Makefile
+@@ -23,3 +23,6 @@ ifdef CONFIG_SPL_FEL
+ obj-y += start.o
+ endif
+ endif
++ifdef CONFIG_ARMV7_PSCI
++obj-y += psci.o
++endif
+diff --git a/arch/arm/cpu/armv7/sunxi/psci.S b/arch/arm/cpu/armv7/sunxi/psci.S
+new file mode 100644
+index 0000000..0084c81
+--- /dev/null
++++ b/arch/arm/cpu/armv7/sunxi/psci.S
+@@ -0,0 +1,162 @@
++/*
++ * Copyright (C) 2013 - ARM Ltd
++ * Author: Marc Zyngier <marc.zyngier@arm.com>
++ *
++ * Based on code by Carl van Schaik <carl@ok-labs.com>.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include <config.h>
++#include <asm/psci.h>
++#include <asm/arch/cpu.h>
++
++/*
++ * Memory layout:
++ *
++ * SECURE_RAM to text_end :
++ * ._secure_text section
++ * text_end to ALIGN_PAGE(text_end):
++ * nothing
++ * ALIGN_PAGE(text_end) to ALIGN_PAGE(text_end) + 0x1000)
++ * 1kB of stack per CPU (4 CPUs max).
++ */
++
++ .pushsection ._secure.text, "ax"
++
++ .arch_extension sec
++
++#define ONE_MS (CONFIG_SYS_CLK_FREQ / 1000)
++#define TEN_MS (10 * ONE_MS)
++
++.macro timer_wait reg, ticks
++ @ Program CNTP_TVAL
++ movw \reg, #(\ticks & 0xffff)
++ movt \reg, #(\ticks >> 16)
++ mcr p15, 0, \reg, c14, c2, 0
++ isb
++ @ Enable physical timer, mask interrupt
++ mov \reg, #3
++ mcr p15, 0, \reg, c14, c2, 1
++ @ Poll physical timer until ISTATUS is on
++1: isb
++ mrc p15, 0, \reg, c14, c2, 1
++ ands \reg, \reg, #4
++ bne 1b
++ @ Disable timer
++ mov \reg, #0
++ mcr p15, 0, \reg, c14, c2, 1
++ isb
++.endm
++
++.globl psci_arch_init
++psci_arch_init:
++ mrc p15, 0, r5, c1, c1, 0 @ Read SCR
++ bic r5, r5, #1 @ Secure mode
++ mcr p15, 0, r5, c1, c1, 0 @ Write SCR
++ isb
++
++ mrc p15, 0, r4, c0, c0, 5 @ MPIDR
++ and r4, r4, #3 @ cpu number in cluster
++ mov r5, #400 @ 1kB of stack per CPU
++ mul r4, r4, r5
++
++ adr r5, text_end @ end of text
++ add r5, r5, #0x2000 @ Skip two pages
++ lsr r5, r5, #12 @ Align to start of page
++ lsl r5, r5, #12
++ sub sp, r5, r4 @ here's our stack!
++
++ bx lr
++
++ @ r1 = target CPU
++ @ r2 = target PC
++.globl psci_cpu_on
++psci_cpu_on:
++ adr r0, _target_pc
++ str r2, [r0]
++ dsb
++
++ movw r0, #(SUNXI_CPUCFG_BASE & 0xffff)
++ movt r0, #(SUNXI_CPUCFG_BASE >> 16)
++
++ @ CPU mask
++ and r1, r1, #3 @ only care about first cluster
++ mov r4, #1
++ lsl r4, r4, r1
++
++ adr r6, _sunxi_cpu_entry
++ str r6, [r0, #0x1a4] @ PRIVATE_REG (boot vector)
++
++ @ Assert reset on target CPU
++ mov r6, #0
++ lsl r5, r1, #6 @ 64 bytes per CPU
++ add r5, r5, #0x40 @ Offset from base
++ add r5, r5, r0 @ CPU control block
++ str r6, [r5] @ Reset CPU
++
++ @ l1 invalidate
++ ldr r6, [r0, #0x184]
++ bic r6, r6, r4
++ str r6, [r0, #0x184]
++
++ @ Lock CPU
++ ldr r6, [r0, #0x1e4]
++ bic r6, r6, r4
++ str r6, [r0, #0x1e4]
++
++ @ Release power clamp
++ movw r6, #0x1ff
++ movt r6, #0
++1: lsrs r6, r6, #1
++ str r6, [r0, #0x1b0]
++ bne 1b
++
++ timer_wait r1, TEN_MS
++
++ @ Clear power gating
++ ldr r6, [r0, #0x1b4]
++ bic r6, r6, #1
++ str r6, [r0, #0x1b4]
++
++ @ Deassert reset on target CPU
++ mov r6, #3
++ str r6, [r5]
++
++ @ Unlock CPU
++ ldr r6, [r0, #0x1e4]
++ orr r6, r6, r4
++ str r6, [r0, #0x1e4]
++
++ mov r0, #ARM_PSCI_RET_SUCCESS @ Return PSCI_RET_SUCCESS
++ mov pc, lr
++
++_target_pc:
++ .word 0
++
++_sunxi_cpu_entry:
++ @ Set SMP bit
++ mrc p15, 0, r0, c1, c0, 1
++ orr r0, r0, #0x40
++ mcr p15, 0, r0, c1, c0, 1
++ isb
++
++ bl _nonsec_init
++ bl psci_arch_init
++
++ adr r0, _target_pc
++ ldr r0, [r0]
++ b _do_nonsec_entry
++
++text_end:
++ .popsection
+diff --git a/include/configs/sun7i.h b/include/configs/sun7i.h
+index 9b693f7..f82431c 100644
+--- a/include/configs/sun7i.h
++++ b/include/configs/sun7i.h
+@@ -16,6 +16,13 @@
+
+ #define CONFIG_SYS_PROMPT "sun7i# "
+
++#define CONFIG_ARMV7_VIRT 1
++#define CONFIG_ARMV7_NONSEC 1
++#define CONFIG_ARMV7_PSCI 1
++#define CONFIG_ARMV7_PSCI_NR_CPUS 2
++#define CONFIG_ARMV7_SECURE_BASE SUNXI_SRAM_B_BASE
++#define CONFIG_SYS_CLK_FREQ 24000000
++
+ /*
+ * Include common sunxi configuration where most the settings are
+ */
+--
+1.9.0
+
diff --git a/uboot-tools.spec b/uboot-tools.spec
index abef4e7..bdfb639 100644
--- a/uboot-tools.spec
+++ b/uboot-tools.spec
@@ -2,7 +2,7 @@
Name: uboot-tools
Version: 2014.04
-Release: 3%{?candidate:.%{candidate}}%{?dist}
+Release: 4%{?candidate:.%{candidate}}%{?dist}
Summary: U-Boot utilities
Group: Development/Tools
@@ -50,6 +50,8 @@ Patch44: 0035-ARM-convert-arch_fixup_memory_node-to-a-generic-FDT-.patch
Patch45: 0036-ARM-HYP-non-sec-PSCI-emit-DT-nodes.patch
Patch46: 0037-PXE-syslinux-implenets-some-keywords-found-in-config.patch
Patch47: 0038-PXE-distros-implementing-syslinux-will-be-using-raw-.patch
+Patch48: 0039-sunxi-fix-SRAM_B-SRAM_D-memory-map.patch
+Patch49: 0040-sunxi-add-hyp-support-on-sun7i.patch
%ifnarch %{arm}
BuildRequires: gcc-arm-linux-gnu
@@ -154,6 +156,8 @@ u-boot bootloader binaries for armv7 boards
%patch45 -p1
%patch46 -p1
%patch47 -p1
+%patch48 -p1
+%patch49 -p1
mkdir builds
# convert fedora logo to bmp for use in u-boot
@@ -410,6 +414,10 @@ rm -rf $RPM_BUILD_ROOT
%endif
%changelog
+* Sat Apr 26 2014 Dennis Gilmore <dennis@ausil.us> - 2014.04-4
+- add hyp support to cubietruck image
+- enables kvm support
+
* Thu Apr 24 2014 Dennis Gilmore <dennis@ausil.us> - 2014.04-3
- add cubietruck u-boot image