From: David Feng <feng...@phytium.com.cn>

This patch provide u-boot with arm64 support. Currently, it works on
Foundation Model for armv8 or Fast Model for armv8.

Signed-off-by: David Feng <feng...@phytium.com.cn>
---
Changes for v2:
    - fix EXPORT_FUNC macro to use register x9 according to "Scott Wood" mail
    - redefine some copyright text
    - add declaration of cache related functions, remove some compiler warnnings

 board/armltd/dts/vexpress64.dts      |  215 ++++++++++++++++++++++++++++++++++
 board/armltd/vexpress64/Makefile     |   43 +++++++
 board/armltd/vexpress64/vexpress64.c |   63 ++++++++++
 boards.cfg                           |    1 +
 include/configs/vexpress_aemv8a.h    |  200 +++++++++++++++++++++++++++++++
 5 files changed, 522 insertions(+)
 create mode 100644 board/armltd/dts/vexpress64.dts
 create mode 100644 board/armltd/vexpress64/Makefile
 create mode 100644 board/armltd/vexpress64/vexpress64.c
 create mode 100644 include/configs/vexpress_aemv8a.h

diff --git a/board/armltd/dts/vexpress64.dts b/board/armltd/dts/vexpress64.dts
new file mode 100644
index 0000000..3814e01
--- /dev/null
+++ b/board/armltd/dts/vexpress64.dts
@@ -0,0 +1,215 @@
+/*
+ * ARM Ltd. Fast Models
+ *
+ * Architecture Envelope Model (AEM) ARMv8-A
+ * ARMAEMv8AMPCT
+ *
+ * RTSM_VE_AEMv8A.lisa
+ */
+
+/dts-v1/;
+
+/memreserve/ 0x80000000 0x00010000;
+
+/ {
+       /* boot configurations for u-boot */
+       config {
+               /*bootdelay = <1>;*/
+               kernel-offset = <0x100000>;
+               rootdisk-offset = <0x800000>;
+               bootcmd = "bootm 0x100000 0x800000:0x2000000";
+       };
+};
+
+/ {
+       model = "RTSM_VE_AEMv8A";
+       compatible = "arm,rtsm_ve,aemv8a", "arm,vexpress";
+       interrupt-parent = <&gic>;
+       #address-cells = <2>;
+       #size-cells = <2>;
+
+       /* chosen */
+       /* generated by u-boot */
+
+
+       aliases {
+               serial0 = &v2m_serial0;
+               serial1 = &v2m_serial1;
+               serial2 = &v2m_serial2;
+               serial3 = &v2m_serial3;
+       };
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               cpu@0 {
+                       device_type = "cpu";
+                       compatible = "arm,armv8";
+                       reg = <0>;
+                       enable-method = "spin-table";
+                       cpu-release-addr = <0x0 0x8000fff8>;
+               };
+               cpu@1 {
+                       device_type = "cpu";
+                       compatible = "arm,armv8";
+                       reg = <1>;
+                       enable-method = "spin-table";
+                       cpu-release-addr = <0x0 0x8000fff8>;
+               };
+               cpu@2 {
+                       device_type = "cpu";
+                       compatible = "arm,armv8";
+                       reg = <2>;
+                       enable-method = "spin-table";
+                       cpu-release-addr = <0x0 0x8000fff8>;
+               };
+               cpu@3 {
+                       device_type = "cpu";
+                       compatible = "arm,armv8";
+                       reg = <3>;
+                       enable-method = "spin-table";
+                       cpu-release-addr = <0x0 0x8000fff8>;
+               };
+       };
+
+       memory@80000000 {
+               device_type = "memory";
+               reg = <0x00000000 0x80000000 0 0x80000000>,
+                     <0x00000008 0x80000000 0 0x80000000>;
+       };
+
+       gic: interrupt-controller@2c001000 {
+               compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic";
+               #interrupt-cells = <3>;
+               #address-cells = <0>;
+               interrupt-controller;
+               reg = <0x0 0x2c001000 0 0x1000>,
+                     <0x0 0x2c002000 0 0x1000>,
+                     <0x0 0x2c004000 0 0x2000>,
+                     <0x0 0x2c006000 0 0x2000>;
+               interrupts = <1 9 0xf04>;
+       };
+
+       timer {
+               compatible = "arm,armv8-timer";
+               interrupts = <1 13 0xff01>,
+                            <1 14 0xff01>,
+                            <1 11 0xff01>,
+                            <1 10 0xff01>;
+               clock-frequency = <100000000>;
+       };
+
+       pmu {
+               compatible = "arm,armv8-pmuv3";
+               interrupts = <0 60 4>,
+                            <0 61 4>,
+                            <0 62 4>,
+                            <0 63 4>;
+       };
+
+       smb {
+               compatible = "simple-bus";
+
+               #address-cells = <2>;
+               #size-cells = <1>;
+               ranges = <0 0 0 0x08000000 0x04000000>,
+                        <1 0 0 0x14000000 0x04000000>,
+                        <2 0 0 0x18000000 0x04000000>,
+                        <3 0 0 0x1c000000 0x04000000>,
+                        <4 0 0 0x0c000000 0x04000000>,
+                        <5 0 0 0x10000000 0x04000000>;
+
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 63>;
+               interrupt-map = <0 0  0 &gic 0  0 4>,
+                               <0 0  1 &gic 0  1 4>,
+                               <0 0  2 &gic 0  2 4>,
+                               <0 0  3 &gic 0  3 4>,
+                               <0 0  4 &gic 0  4 4>,
+                               <0 0  5 &gic 0  5 4>,
+                               <0 0  6 &gic 0  6 4>,
+                               <0 0  7 &gic 0  7 4>,
+                               <0 0  8 &gic 0  8 4>,
+                               <0 0  9 &gic 0  9 4>,
+                               <0 0 10 &gic 0 10 4>,
+                               <0 0 11 &gic 0 11 4>,
+                               <0 0 12 &gic 0 12 4>,
+                               <0 0 13 &gic 0 13 4>,
+                               <0 0 14 &gic 0 14 4>,
+                               <0 0 15 &gic 0 15 4>,
+                               <0 0 16 &gic 0 16 4>,
+                               <0 0 17 &gic 0 17 4>,
+                               <0 0 18 &gic 0 18 4>,
+                               <0 0 19 &gic 0 19 4>,
+                               <0 0 20 &gic 0 20 4>,
+                               <0 0 21 &gic 0 21 4>,
+                               <0 0 22 &gic 0 22 4>,
+                               <0 0 23 &gic 0 23 4>,
+                               <0 0 24 &gic 0 24 4>,
+                               <0 0 25 &gic 0 25 4>,
+                               <0 0 26 &gic 0 26 4>,
+                               <0 0 27 &gic 0 27 4>,
+                               <0 0 28 &gic 0 28 4>,
+                               <0 0 29 &gic 0 29 4>,
+                               <0 0 30 &gic 0 30 4>,
+                               <0 0 31 &gic 0 31 4>,
+                               <0 0 32 &gic 0 32 4>,
+                               <0 0 33 &gic 0 33 4>,
+                               <0 0 34 &gic 0 34 4>,
+                               <0 0 35 &gic 0 35 4>,
+                               <0 0 36 &gic 0 36 4>,
+                               <0 0 37 &gic 0 37 4>,
+                               <0 0 38 &gic 0 38 4>,
+                               <0 0 39 &gic 0 39 4>,
+                               <0 0 40 &gic 0 40 4>,
+                               <0 0 41 &gic 0 41 4>,
+                               <0 0 42 &gic 0 42 4>;
+
+               /include/ "aemv8a.dtsi"
+       };
+
+       panels {
+               panel@0 {
+                       compatible      = "panel";
+                       mode            = "VGA";
+                       refresh         = <60>;
+                       xres            = <640>;
+                       yres            = <480>;
+                       pixclock        = <39721>;
+                       left_margin     = <40>;
+                       right_margin    = <24>;
+                       upper_margin    = <32>;
+                       lower_margin    = <11>;
+                       hsync_len       = <96>;
+                       vsync_len       = <2>;
+                       sync            = <0>;
+                       vmode           = "FB_VMODE_NONINTERLACED";
+                       tim2            = "TIM2_BCD", "TIM2_IPC";
+                       cntl            = "CNTL_LCDTFT", "CNTL_BGR", 
"CNTL_LCDVCOMP(1)";
+                       caps            = "CLCD_CAP_5551", "CLCD_CAP_565", 
"CLCD_CAP_888";
+                       bpp             = <16>;
+               };
+
+               panel@1 {
+                       compatible      = "panel";
+                       mode            = "XVGA";
+                       refresh         = <60>;
+                       xres            = <1024>;
+                       yres            = <768>;
+                       pixclock        = <15748>;
+                       left_margin     = <152>;
+                       right_margin    = <48>;
+                       upper_margin    = <23>;
+                       lower_margin    = <3>;
+                       hsync_len       = <104>;
+                       vsync_len       = <4>;
+                       sync            = <0>;
+                       vmode           = "FB_VMODE_NONINTERLACED";
+                       tim2            = "TIM2_BCD", "TIM2_IPC";
+                       cntl            = "CNTL_LCDTFT", "CNTL_BGR", 
"CNTL_LCDVCOMP(1)";
+                       caps            = "CLCD_CAP_5551", "CLCD_CAP_565", 
"CLCD_CAP_888";
+                       bpp             = <16>;
+               };
+       };
+};
diff --git a/board/armltd/vexpress64/Makefile b/board/armltd/vexpress64/Makefile
new file mode 100644
index 0000000..77f0c3f
--- /dev/null
+++ b/board/armltd/vexpress64/Makefile
@@ -0,0 +1,43 @@
+#
+# (C) Copyright 2000-2004
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB    = $(obj)lib$(BOARD).o
+
+COBJS  := vexpress64.o
+
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):        $(obj).depend $(OBJS)
+       $(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/armltd/vexpress64/vexpress64.c 
b/board/armltd/vexpress64/vexpress64.c
new file mode 100644
index 0000000..b86736d
--- /dev/null
+++ b/board/armltd/vexpress64/vexpress64.c
@@ -0,0 +1,63 @@
+/*
+ * (C) Copyright 2013
+ * Phytium Technology, <www.phytium.com.cn>
+ * David Feng, feng...@phytium.com.cn
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <common.h>
+#include <malloc.h>
+#include <errno.h>
+#include <netdev.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * Board specific reset that is system reset.
+ */
+void reset_cpu(ulong addr)
+{
+}
+
+/*
+ * Default implementation of gpio related functiuons
+ * Real implementation should be in gpio driver.
+ * fdtdec.c need this function, but currenty no gpio driver defined
+ */
+int __gpio_get_value(unsigned gpio)
+{
+       return 0;
+}
+int gpio_get_value(unsigned gpio)
+       __attribute__((weak, alias("__gpio_get_value")));
+
+void __gpio_set_value(unsigned gpio, int vlaue)
+{
+       return;
+}
+void gpio_set_value(unsigned gpio, int vlaue)
+       __attribute__((weak, alias("__gpio_set_value")));
+
+void __gpio_request(unsigned gpio, const char *label)
+{
+       return;
+}
+void gpio_request(unsigned gpio, const char *label)
+       __attribute__((weak, alias("__gpio_request")));
diff --git a/boards.cfg b/boards.cfg
index 944ed4c..561b0d6 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -1182,5 +1182,6 @@ gr_ep2s60                    sparc       leon3       -    
               gaisler
 grsim                        sparc       leon3       -                   
gaisler
 gr_xc3s_1500                 sparc       leon3       -                   
gaisler
 coreboot-x86                 x86         x86        coreboot            
chromebook-x86 coreboot    coreboot:SYS_TEXT_BASE=0x01110000
+vexpress_aemv8a              arm64       armv8       vexpress64          armltd
 # Target                     ARCH        CPU         Board name          
Vendor                SoC         Options
 
########################################################################################################################
diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
new file mode 100644
index 0000000..d920333
--- /dev/null
+++ b/include/configs/vexpress_aemv8a.h
@@ -0,0 +1,200 @@
+/*
+ * Configuration for Versatile Express. Parts were derived from other ARM
+ *   configurations.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __VEXPRESS_AEMV8A_H
+#define __VEXPRESS_AEMV8A_H
+
+#define DEBUG
+
+#define CONFIG_SYS_NO_FLASH
+
+#define CONFIG_SUPPORT_RAW_INITRD
+
+#define CONFIG_SKIP_LOWLEVEL_INIT
+
+/* Cache Definitions */
+//#define CONFIG_SYS_DCACHE_OFF
+//#define CONFIG_SYS_ICACHE_OFF
+
+#define CONFIG_IDENT_STRING            " vexpress_aemv8a"
+#define CONFIG_BOOTP_VCI_STRING        "U-boot.armv8.vexpress_aemv8a"
+
+/* Link Definitions */
+#define CONFIG_SYS_TEXT_BASE           0x80000000
+#define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_SDRAM_BASE + 0x400000)
+
+/* Flat Device Tree Definitions */
+#define CONFIG_OF_EMBED
+#define CONFIG_OF_CONTROL
+#define CONFIG_OF_LIBFDT
+
+#define CONFIG_DEFAULT_DEVICE_TREE     vexpress64
+
+/* SMP Definitions */
+#define SECONDARY_CPU_MAILBOX          0x8000fff8
+
+/* CS register bases for the original memory map. */
+#define V2M_PA_CS0                     0x00000000
+#define V2M_PA_CS1                     0x14000000
+#define V2M_PA_CS2                     0x18000000
+#define V2M_PA_CS3                     0x1c000000
+#define V2M_PA_CS4                     0x0c000000
+#define V2M_PA_CS5                     0x10000000
+
+#define V2M_PERIPH_OFFSET(x)           (x << 16)
+#define V2M_SYSREGS                    (V2M_PA_CS3 + V2M_PERIPH_OFFSET(1))
+#define V2M_SYSCTL                     (V2M_PA_CS3 + V2M_PERIPH_OFFSET(2))
+#define V2M_SERIAL_BUS_PCI             (V2M_PA_CS3 + V2M_PERIPH_OFFSET(3))
+
+#define V2M_BASE                       0x80000000
+
+/*
+ * Physical addresses, offset from V2M_PA_CS0-3
+ */
+#define V2M_NOR0                       (V2M_PA_CS0)
+#define V2M_NOR1                       (V2M_PA_CS4)
+#define V2M_SRAM                       (V2M_PA_CS1)
+
+/* Common peripherals relative to CS7. */
+#define V2M_AACI                       (V2M_PA_CS3 + V2M_PERIPH_OFFSET(4))
+#define V2M_MMCI                       (V2M_PA_CS3 + V2M_PERIPH_OFFSET(5))
+#define V2M_KMI0                       (V2M_PA_CS3 + V2M_PERIPH_OFFSET(6))
+#define V2M_KMI1                       (V2M_PA_CS3 + V2M_PERIPH_OFFSET(7))
+
+#define V2M_UART0                      (V2M_PA_CS3 + V2M_PERIPH_OFFSET(9))
+#define V2M_UART1                      (V2M_PA_CS3 + V2M_PERIPH_OFFSET(10))
+#define V2M_UART2                      (V2M_PA_CS3 + V2M_PERIPH_OFFSET(11))
+#define V2M_UART3                      (V2M_PA_CS3 + V2M_PERIPH_OFFSET(12))
+
+#define V2M_WDT                                (V2M_PA_CS3 + 
V2M_PERIPH_OFFSET(15))
+
+#define V2M_TIMER01                    (V2M_PA_CS3 + V2M_PERIPH_OFFSET(17))
+#define V2M_TIMER23                    (V2M_PA_CS3 + V2M_PERIPH_OFFSET(18))
+
+#define V2M_SERIAL_BUS_DVI             (V2M_PA_CS3 + V2M_PERIPH_OFFSET(22))
+#define V2M_RTC                                (V2M_PA_CS3 + 
V2M_PERIPH_OFFSET(23))
+
+#define V2M_CF                         (V2M_PA_CS3 + V2M_PERIPH_OFFSET(26))
+
+#define V2M_CLCD                       (V2M_PA_CS3 + V2M_PERIPH_OFFSET(31))
+
+/* System register offsets. */
+#define V2M_SYS_CFGDATA                        (V2M_SYSREGS + 0x0a0)
+#define V2M_SYS_CFGCTRL                        (V2M_SYSREGS + 0x0a4)
+#define V2M_SYS_CFGSTAT                        (V2M_SYSREGS + 0x0a8)
+
+/* Generic Timer Definitions */
+#define CONFIG_SYS_CNTFRQ              (0x1800000)     /* 24MHz */
+
+/* Generic Interrupt Controller Definitions */
+#define GIC_DIST_BASE                  (0x2C001000)
+#define GIC_CPU_BASE                   (0x2C002000)
+
+#define CONFIG_SYS_MEMTEST_START       V2M_BASE
+#define CONFIG_SYS_MEMTEST_END         (V2M_BASE + 0x80000000)
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN          (CONFIG_ENV_SIZE + 128 * 1024)
+
+/* PL011 Serial Configuration */
+#define CONFIG_PL011_SERIAL
+#define CONFIG_PL011_CLOCK             24000000
+#define CONFIG_PL01x_PORTS             {(void *)CONFIG_SYS_SERIAL0, \
+                                        (void *)CONFIG_SYS_SERIAL1}
+#define CONFIG_CONS_INDEX              0
+
+#define CONFIG_BAUDRATE                        115200
+#define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200 }
+#define CONFIG_SYS_SERIAL0             V2M_UART0
+#define CONFIG_SYS_SERIAL1             V2M_UART1
+
+/* Command line configuration */
+#define CONFIG_MENU
+//#define CONFIG_MENU_SHOW
+#define CONFIG_CMD_CACHE
+#define CONFIG_CMD_BDI
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_PXE
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_FLASH
+#define CONFIG_CMD_IMI
+#define CONFIG_CMD_MEMORY
+#define CONFIG_CMD_MII
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_BOOTD
+#define CONFIG_CMD_ECHO
+#define CONFIG_CMD_SOURCE
+#define CONFIG_CMD_FAT
+#define CONFIG_DOS_PARTITION
+
+/* BOOTP options */
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_BOOTPATH
+#define CONFIG_BOOTP_GATEWAY
+#define CONFIG_BOOTP_HOSTNAME
+#define CONFIG_BOOTP_PXE
+#define CONFIG_BOOTP_PXE_CLIENTARCH    0x100
+
+/* Miscellaneous configurable options */
+#define CONFIG_SYS_LOAD_ADDR           (V2M_BASE + 0x10000000) /* load address 
*/
+
+/* Physical Memory Map */
+#define CONFIG_NR_DRAM_BANKS           1
+#define PHYS_SDRAM_1                   (V2M_BASE)      /* SDRAM Bank #1 */
+#define PHYS_SDRAM_1_SIZE              0x80000000      /* 2048 MB */
+#define CONFIG_SYS_SDRAM_BASE          PHYS_SDRAM_1
+
+
+/* Initial environment variables */
+#define CONFIG_EXTRA_ENV_SETTINGS      \
+                                       "loadaddr=0x80100000\0"         \
+                                       "kernel_addr=0x100000\0"        \
+                                       "ramdisk_addr=0x800000\0"       \
+                                       "ramdisk_size=0x2000000\0"      \
+                                       "fdt_high=0xa0000000\0"         \
+                                       "console=ttyAMA0,38400n8\0"
+
+#define CONFIG_BOOTARGS                        "console=ttyAMA0 root=/dev/ram0"
+#define CONFIG_BOOTCOMMAND             "bootm $kernel_addr 
$ramdisk_addr:$ramdisk_size"
+#define CONFIG_BOOTDELAY               -1
+
+/* Store environment at top of flash */
+#define CONFIG_ENV_IS_NOWHERE          1
+#define CONFIG_ENV_SIZE                        0x1000
+
+/* Monitor Command Prompt */
+#define CONFIG_SYS_CBSIZE              512     /* Console I/O Buffer Size */
+#define CONFIG_SYS_PROMPT              "VExpress# "
+#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + \
+                                       sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_PROMPT_HUSH_PS2     "> "
+#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE /* Boot args buffer */
+#define CONFIG_SYS_LONGHELP
+#define CONFIG_CMDLINE_EDITING         1
+#define CONFIG_SYS_MAXARGS             64      /* max command args */
+
+#endif /* __VEXPRESS_AEMV8A_H */
-- 
1.7.9.5


_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to