Hello Julius Werner, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/23812
to look at the new patch set (#3).
Change subject: mb/emulation/qemu-armv8: Add new board for ARMv8
......................................................................
mb/emulation/qemu-armv8: Add new board for ARMv8
Ported the ARMv7 board to ARMv8.
Added custom bootblock, as the memory mapped NOR flash shouldn't be
written to. The bootblock relocates itself to SRAM.
Tested on QEMU:
qemu-system-aarch64 -M vexpress-a9 -cpu cortex-a53 -m 1024 \
-bios build/coreboot.rom -nographic
Change-Id: Ib4f2fd43afb855c2ae5760d9ee6ae1478b09104c
Signed-off-by: Patrick Rudolph <patrick.rudolph(a)9elements.com>
---
M src/cpu/armltd/Kconfig
M src/cpu/armltd/Makefile.inc
A src/cpu/armltd/cortex-a53/Kconfig
A src/mainboard/emulation/qemu-armv8/Kconfig
A src/mainboard/emulation/qemu-armv8/Kconfig.name
A src/mainboard/emulation/qemu-armv8/Makefile.inc
A src/mainboard/emulation/qemu-armv8/board_info.txt
A src/mainboard/emulation/qemu-armv8/bootblock_custom.S
A src/mainboard/emulation/qemu-armv8/cbmem.c
A src/mainboard/emulation/qemu-armv8/devicetree.cb
A src/mainboard/emulation/qemu-armv8/mainboard.c
A src/mainboard/emulation/qemu-armv8/mainboard.h
A src/mainboard/emulation/qemu-armv8/media.c
A src/mainboard/emulation/qemu-armv8/memlayout.ld
A src/mainboard/emulation/qemu-armv8/memorymap.h
A src/mainboard/emulation/qemu-armv8/mmio.c
A src/mainboard/emulation/qemu-armv8/romstage.c
A src/mainboard/emulation/qemu-armv8/timer.c
18 files changed, 544 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/23812/3
--
To view, visit https://review.coreboot.org/23812
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib4f2fd43afb855c2ae5760d9ee6ae1478b09104c
Gerrit-Change-Number: 23812
Gerrit-PatchSet: 3
Gerrit-Owner: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/23812 )
Change subject: mb/emulation/qemu-armv8: Add new board for ARMv8
......................................................................
Patch Set 2: Verified-1
Build Failed
https://qa.coreboot.org/job/coreboot-gerrit/67678/ : FAILURE
https://qa.coreboot.org/job/coreboot-checkpatch/22182/ : SUCCESS
--
To view, visit https://review.coreboot.org/23812
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib4f2fd43afb855c2ae5760d9ee6ae1478b09104c
Gerrit-Change-Number: 23812
Gerrit-PatchSet: 2
Gerrit-Owner: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Mon, 19 Feb 2018 13:31:24 +0000
Gerrit-HasComments: No
Gerrit-HasLabels: Yes
Hello Julius Werner, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/23812
to look at the new patch set (#2).
Change subject: mb/emulation/qemu-armv8: Add new board for ARMv8
......................................................................
mb/emulation/qemu-armv8: Add new board for ARMv8
Ported the ARMv7 board to ARMv8.
Added custom bootblock, as the memory mapped NOR flash shouldn't be
written to. The bootblock relocates itself to SRAM.
Tested on QEMU:
qemu-system-aarch64 -M vexpress-a9 -cpu cortex-a53 -m 1024 \
-bios build/coreboot.rom -nographic
Change-Id: Ib4f2fd43afb855c2ae5760d9ee6ae1478b09104c
Signed-off-by: Patrick Rudolph <patrick.rudolph(a)9elements.com>
---
M src/cpu/armltd/Kconfig
M src/cpu/armltd/Makefile.inc
A src/cpu/armltd/cortex-a53/Kconfig
A src/mainboard/emulation/qemu-armv8/Kconfig
A src/mainboard/emulation/qemu-armv8/Kconfig.name
A src/mainboard/emulation/qemu-armv8/Makefile.inc
A src/mainboard/emulation/qemu-armv8/board_info.txt
A src/mainboard/emulation/qemu-armv8/bootblock_custom.S
A src/mainboard/emulation/qemu-armv8/cbmem.c
A src/mainboard/emulation/qemu-armv8/devicetree.cb
A src/mainboard/emulation/qemu-armv8/mainboard.c
A src/mainboard/emulation/qemu-armv8/mainboard.h
A src/mainboard/emulation/qemu-armv8/media.c
A src/mainboard/emulation/qemu-armv8/memlayout.ld
A src/mainboard/emulation/qemu-armv8/memorymap.h
A src/mainboard/emulation/qemu-armv8/mmio.c
A src/mainboard/emulation/qemu-armv8/romstage.c
A src/mainboard/emulation/qemu-armv8/timer.c
18 files changed, 545 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/23812/2
--
To view, visit https://review.coreboot.org/23812
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib4f2fd43afb855c2ae5760d9ee6ae1478b09104c
Gerrit-Change-Number: 23812
Gerrit-PatchSet: 2
Gerrit-Owner: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/23812
Change subject: mb/emulation/qemu-armv8: Add new board for ARMv8
......................................................................
mb/emulation/qemu-armv8: Add new board for ARMv8
Ported the ARMv7 board to ARMv8.
Added custom bootblock, as the memory mapped NOR flash shouldn't be
written to. The bootblock relocates itself to SRAM.
Tested on QEMU:
qemu-system-aarch64 -M vexpress-a9 -cpu cortex-a53 -m 1024 \
-bios build/coreboot.rom -nographic
Change-Id: Ib4f2fd43afb855c2ae5760d9ee6ae1478b09104c
Signed-off-by: Patrick Rudolph <patrick.rudolph(a)9elements.com>
---
M src/cpu/armltd/Kconfig
M src/cpu/armltd/Makefile.inc
A src/cpu/armltd/cortex-a53/Kconfig
A src/mainboard/emulation/qemu-armv8/Kconfig
A src/mainboard/emulation/qemu-armv8/Kconfig.name
A src/mainboard/emulation/qemu-armv8/Makefile.inc
A src/mainboard/emulation/qemu-armv8/board_info.txt
A src/mainboard/emulation/qemu-armv8/bootblock_custom.S
A src/mainboard/emulation/qemu-armv8/cbmem.c
A src/mainboard/emulation/qemu-armv8/devicetree.cb
A src/mainboard/emulation/qemu-armv8/mainboard.c
A src/mainboard/emulation/qemu-armv8/mainboard.h
A src/mainboard/emulation/qemu-armv8/media.c
A src/mainboard/emulation/qemu-armv8/memlayout.ld
A src/mainboard/emulation/qemu-armv8/memorymap.h
A src/mainboard/emulation/qemu-armv8/mmio.c
A src/mainboard/emulation/qemu-armv8/romstage.c
A src/mainboard/emulation/qemu-armv8/timer.c
18 files changed, 546 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/23812/1
diff --git a/src/cpu/armltd/Kconfig b/src/cpu/armltd/Kconfig
index af0c5c5..fc01735 100644
--- a/src/cpu/armltd/Kconfig
+++ b/src/cpu/armltd/Kconfig
@@ -1 +1,2 @@
source src/cpu/armltd/cortex-a9/Kconfig
+source src/cpu/armltd/cortex-a53/Kconfig
diff --git a/src/cpu/armltd/Makefile.inc b/src/cpu/armltd/Makefile.inc
index 014742f..cd6acf1 100644
--- a/src/cpu/armltd/Makefile.inc
+++ b/src/cpu/armltd/Makefile.inc
@@ -1 +1,2 @@
subdirs-$(CONFIG_CPU_ARMLTD_CORTEX_A9) += cortex-a9
+subdirs-$(CONFIG_CPU_ARMLTD_CORTEX_A53) += cortex-a53
diff --git a/src/cpu/armltd/cortex-a53/Kconfig b/src/cpu/armltd/cortex-a53/Kconfig
new file mode 100644
index 0000000..67d6476
--- /dev/null
+++ b/src/cpu/armltd/cortex-a53/Kconfig
@@ -0,0 +1,12 @@
+config CPU_ARMLTD_CORTEX_A53
+ bool
+ select ARCH_ARMV8_1
+ select ARCH_BOOTBLOCK_ARMV8_64
+ select ARCH_RAMSTAGE_ARMV8_64
+ select ARCH_ROMSTAGE_ARMV8_64
+ select ARCH_VERSTAGE_ARMV8_64
+ default n
+
+if CPU_ARMLTD_CORTEX_A53
+
+endif
diff --git a/src/mainboard/emulation/qemu-armv8/Kconfig b/src/mainboard/emulation/qemu-armv8/Kconfig
new file mode 100644
index 0000000..00c02e0
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/Kconfig
@@ -0,0 +1,55 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2013 Google Inc.
+##
+## This software is licensed under the terms of the GNU General Public
+## License version 2, as published by the Free Software Foundation, and
+## may be copied, distributed, and modified under those terms.
+##
+## 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.
+
+# Emulation for ARM Ltd Versatile Express Cortex-A53
+# http://www.arm.com/products/tools/development-boards/versatile-express
+
+# To execute, do:
+# export QEMU_AUDIO_DRV = none
+# qemu-system-aarch64 -M vexpress-a9 -cpu cortex-a53 -m 1024 -bios build/coreboot.rom -nographic
+
+if BOARD_EMULATION_QEMU_ARMV8
+
+config BOARD_SPECIFIC_OPTIONS # dummy
+ def_bool y
+ select CPU_ARMLTD_CORTEX_A53
+ select DRIVERS_UART_PL011
+ select BOOTBLOCK_CONSOLE
+ select CONSOLE_SERIAL
+ select MAINBOARD_HAS_NATIVE_VGA_INIT
+ select MAINBOARD_FORCE_NATIVE_VGA_INIT
+ select HAVE_LINEAR_FRAMEBUFFER
+ select BOARD_ROMSIZE_KB_4096
+ select BOOT_DEVICE_NOT_SPI_FLASH
+ select BOOTBLOCK_CUSTOM
+ select DRIVERS_ARM_SP804
+ select GENERIC_UDELAY
+
+config MAINBOARD_DIR
+ string
+ default emulation/qemu-armv8
+
+config MAINBOARD_PART_NUMBER
+ string
+ default "QEMU ARMv8"
+
+config MAX_CPUS
+ int
+ default 2
+
+config MAINBOARD_VENDOR
+ string
+ default "ARM Ltd."
+
+endif # BOARD_EMULATION_QEMU_ARMV8
diff --git a/src/mainboard/emulation/qemu-armv8/Kconfig.name b/src/mainboard/emulation/qemu-armv8/Kconfig.name
new file mode 100644
index 0000000..ed1c343
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/Kconfig.name
@@ -0,0 +1,2 @@
+config BOARD_EMULATION_QEMU_ARMV8
+ bool "QEMU armv8 (vexpress-a9)"
diff --git a/src/mainboard/emulation/qemu-armv8/Makefile.inc b/src/mainboard/emulation/qemu-armv8/Makefile.inc
new file mode 100644
index 0000000..ccbd3de
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/Makefile.inc
@@ -0,0 +1,38 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2013 Google Inc.
+##
+## This software is licensed under the terms of the GNU General Public
+## License version 2, as published by the Free Software Foundation, and
+## may be copied, distributed, and modified under those terms.
+##
+## 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.
+
+romstage-y += romstage.c
+
+romstage-y += cbmem.c
+ramstage-y += cbmem.c
+
+bootblock-y += media.c
+romstage-y += media.c
+ramstage-y += media.c
+
+bootblock-y += timer.c
+romstage-y += timer.c
+ramstage-y += timer.c
+
+bootblock-y += mmio.c
+romstage-y += mmio.c
+ramstage-y += mmio.c
+
+bootblock-y += memlayout.ld
+romstage-y += memlayout.ld
+ramstage-y += memlayout.ld
+
+bootblock-y += bootblock_custom.S
+bootblock-y += ../../../lib/bootblock.c
+
diff --git a/src/mainboard/emulation/qemu-armv8/board_info.txt b/src/mainboard/emulation/qemu-armv8/board_info.txt
new file mode 100644
index 0000000..0301be5
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/board_info.txt
@@ -0,0 +1,3 @@
+Board name: QEMU armv8 (vexpress-a9)
+Category: emulation
+Board URL: http://wiki.qemu.org/Main_Page
diff --git a/src/mainboard/emulation/qemu-armv8/bootblock_custom.S b/src/mainboard/emulation/qemu-armv8/bootblock_custom.S
new file mode 100644
index 0000000..1c1230d
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/bootblock_custom.S
@@ -0,0 +1,61 @@
+/*
+ * Early initialization code for aarch64 (a.k.a. armv8)
+ *
+ * Copyright 2018-present Facebook, Inc.
+ *
+ * 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; version 2 of
+ * the License.
+ *
+ * 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.
+ */
+
+#include <arch/asm.h>
+#include "memorymap.h"
+
+ENTRY(_start)
+ .org 0
+ ic ialluis
+
+relocate:
+ /* Get code position */
+ mov x1, #VEXPRESS_NORFLASH_START
+ mov x0, #VEXPRESS_SRAM_START
+
+ /* FIXME: Don't hardcode bootblock length */
+ mov x2, #0x10000
+ b copy_code
+
+.align 7
+copy_code:
+ ldp q0, q1, [x1], 32 /* Load 32 bytes */
+ subs w2, w2, 32 /* Subtract 32 from length, setting flags */
+ stp q0, q1, [x0], 32 /* Store 32 bytes */
+ b.gt copy_code /* Repeat if length is still positive */
+ dmb sy
+
+ /* Load the actual location we're suppose to be at */
+ adr x0, after_relocate /* Relative address */
+ adr x1, _start /* Relative address */
+ sub x0, x0, x1 /* This only works if _start is suppose to be zero */
+
+ mov x1, #VEXPRESS_SRAM_START
+ add x0, x1, x0
+ br x0
+
+after_relocate:
+ bl start
+ENDPROC(_start)
+
+ENTRY(start)
+
+ bl arm64_init_cpu
+
+ /* Call C entry */
+ bl main
+
+ENDPROC(start)
diff --git a/src/mainboard/emulation/qemu-armv8/cbmem.c b/src/mainboard/emulation/qemu-armv8/cbmem.c
new file mode 100644
index 0000000..e35e016
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/cbmem.c
@@ -0,0 +1,69 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Vladimir Serbinenko <phcoder(a)gmail.com>
+ * Copyright 2018-present Facebook, Inc.
+ *
+ * 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; version 2 of the License.
+ *
+ * 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.
+ */
+
+#include <stddef.h>
+#include <cbmem.h>
+#include <symbols.h>
+#include <arch/io.h>
+#include "mainboard.h"
+#include "memorymap.h"
+
+#define PATTERN1 0x55
+#define PATTERN2 0xaa
+
+/* Returns 1 if mebibyte mb is present and 0 otherwise. */
+static int probe_mb(int mb)
+{
+ char *ptr = (char *) VEXPRESS_DRAM_START + (mb << 20) + 0xfffff;
+ char old;
+ if (ptr < (char *) &_eprogram) {
+ /* Don't probe below _end to avoid accidentally clobering
+ oneself. */
+ return 1;
+ }
+
+ old = read8(ptr);
+ write8(ptr, PATTERN1);
+ if (read8(ptr) != PATTERN1)
+ return 0;
+ write8(ptr, PATTERN2);
+ if (read8(ptr) != PATTERN2)
+ return 0;
+ write8(ptr, old);
+ return 1;
+}
+
+int probe_ramsize(void)
+{
+ int i;
+ int discovered = 0;
+ static int saved_result;
+ if (saved_result)
+ return saved_result;
+ /* Compact binary search. */
+ /* 1 GiB is the largest supported RAM by this machine. */
+ for (i = 9; i >= 0; i--)
+ if (probe_mb(discovered | (1 << i)))
+ discovered |= (1 << i);
+ discovered++;
+ saved_result = discovered;
+ return discovered;
+}
+
+void *cbmem_top(void)
+{
+ return _dram + (probe_ramsize() << 20);
+}
diff --git a/src/mainboard/emulation/qemu-armv8/devicetree.cb b/src/mainboard/emulation/qemu-armv8/devicetree.cb
new file mode 100644
index 0000000..19a9bad
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/devicetree.cb
@@ -0,0 +1,20 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2013 Google, Inc.
+##
+## This software is licensed under the terms of the GNU General Public
+## License version 2, as published by the Free Software Foundation, and
+## may be copied, distributed, and modified under those terms.
+##
+## 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.
+
+# TODO fill with Versatile Express board data in QEMU.
+chip cpu/armltd/cortex-a53
+ chip drivers/generic/generic # I2C0 controller
+ device i2c 6 on end # Fake component for testing
+ end
+end
diff --git a/src/mainboard/emulation/qemu-armv8/mainboard.c b/src/mainboard/emulation/qemu-armv8/mainboard.c
new file mode 100644
index 0000000..c53aec9
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/mainboard.c
@@ -0,0 +1,72 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Vladimir Serbinenko <phcoder(a)gmail.com>
+ * Copyright 2018-present Facebook, Inc.
+ *
+ * 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; version 2 or, at your option, any later
+ * version of the License.
+ *
+ * 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.
+ */
+
+#include <console/console.h>
+#include <device/device.h>
+#include <cbmem.h>
+#include <string.h>
+#include <halt.h>
+#include "mainboard.h"
+#include "memorymap.h"
+#include <edid.h>
+#include <arch/io.h>
+
+static void init_gfx(void)
+{
+ uint32_t *pl111;
+ struct edid edid;
+ /* width is at most 4096 */
+ /* height is at most 1024 */
+ int width = 800, height = 600;
+ uint32_t framebuffer = VEXPRESS_FRAMEBUFFER_START;
+ pl111 = (uint32_t *) VEXPRESS_PL111;
+ write32(pl111, (width / 4) - 4);
+ write32(pl111 + 1, height - 1);
+ /* registers 2, 3 and 5 are ignored by qemu. Set them correctly if
+ we ever go for real hw. */
+ /* framebuffer adress offset. Has to be in vram. */
+ write32(pl111 + 4, framebuffer);
+ write32(pl111 + 7, 0);
+ write32(pl111 + 10, 0xff);
+ write32(pl111 + 6, (5 << 1) | 0x801);
+
+ edid.framebuffer_bits_per_pixel = 32;
+ edid.bytes_per_line = width * 4;
+ edid.x_resolution = width;
+ edid.y_resolution = height;
+
+ set_vbe_mode_info_valid(&edid, framebuffer);
+}
+
+static void mainboard_enable(device_t dev)
+{
+ int discovered;
+ if (!dev) {
+ printk(BIOS_EMERG, "No dev0; die\n");
+ halt();
+ }
+
+ discovered = probe_ramsize();
+ printk(BIOS_DEBUG, "%d MiB of RAM discovered\n", discovered);
+ ram_resource(dev, 0, VEXPRESS_DRAM_START >> 10, discovered << 10);
+ cbmem_recovery(0);
+ init_gfx();
+}
+
+struct chip_operations mainboard_ops = {
+ .enable_dev = mainboard_enable,
+};
diff --git a/src/mainboard/emulation/qemu-armv8/mainboard.h b/src/mainboard/emulation/qemu-armv8/mainboard.h
new file mode 100644
index 0000000..ce46f17
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/mainboard.h
@@ -0,0 +1,24 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Vladimir Serbinenko <phcoder(a)gmail.com>
+ * Copyright 2018-present Facebook, Inc.
+ *
+ * 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; version 2 or, at your option, any later
+ * version of the License.
+ *
+ * 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.
+ */
+
+#ifndef QEMU_ARMV8_MAINBOARD_H
+#define QEMU_ARMV8_MAINBOARD_H
+
+/* Returns RAM size in mebibytes. */
+int probe_ramsize(void);
+
+#endif
diff --git a/src/mainboard/emulation/qemu-armv8/media.c b/src/mainboard/emulation/qemu-armv8/media.c
new file mode 100644
index 0000000..be1ca4b
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/media.c
@@ -0,0 +1,26 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, Inc.
+ * Copyright 2018-present Facebook, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+#include <boot_device.h>
+#include "memorymap.h"
+
+/* Maps directly to NOR flash up to ROM size. */
+static const struct mem_region_device boot_dev =
+ MEM_REGION_DEV_RO_INIT((void *)VEXPRESS_NORFLASH_START, CONFIG_ROM_SIZE);
+
+const struct region_device *boot_device_ro(void)
+{
+ return &boot_dev.rdev;
+}
diff --git a/src/mainboard/emulation/qemu-armv8/memlayout.ld b/src/mainboard/emulation/qemu-armv8/memlayout.ld
new file mode 100644
index 0000000..9c3351f
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/memlayout.ld
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2014 Google Inc.
+ *
+ * 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; version 2 of the License.
+ *
+ * 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.
+ */
+
+#include <memlayout.h>
+
+#include <arch/header.ld>
+#include "memorymap.h"
+
+/*
+ * This map is designed to work with new qemu vexpress memory layout and
+ * with -bios option which neatly puts coreboot into flash and so payloads
+ * can find CBFS and we don't risk overwriting CBFS.
+ *
+ * Prior to Jul 2014 qemu aliased 0 to begining of RAM instead of flash
+ * and -bios was unusable as $pc pointed to 0 which was zero-filled as a
+ * workaround we suggested using -kernel but this still had all the issues
+ * of having fake-ROM in RAM. In fact it was even worse as fake ROM ends
+ * up exactly at addresses needed to load Linux.
+ */
+SECTIONS
+{
+ SRAM_START(VEXPRESS_SRAM_START)
+ BOOTBLOCK(VEXPRESS_SRAM_START, 64K)
+ SRAM_END(VEXPRESS_SRAM_START + 0x200000)
+
+ DRAM_START(VEXPRESS_DRAM_START)
+ STACK(VEXPRESS_DRAM_START, 64K)
+ ROMSTAGE(VEXPRESS_DRAM_START + 0x10000, 128K)
+ RAMSTAGE(VEXPRESS_DRAM_START + 0x30000, 16M)
+}
diff --git a/src/mainboard/emulation/qemu-armv8/memorymap.h b/src/mainboard/emulation/qemu-armv8/memorymap.h
new file mode 100644
index 0000000..f9a9ef3
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/memorymap.h
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018-present Facebook, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+#ifndef QEMU_ARMV8_MEMORYMAP_H_
+#define QEMU_ARMV8_MEMORYMAP_H_
+
+/*
+ * Memory map for qemu vexpress-a9 since
+ * 6ec1588e09770ac7e9c60194faff6101111fc7f0 (Jul 2014):
+ */
+
+#define VEXPRESS_NORFLASH_START (0x00000000)
+#define VEXPRESS_UART0_IO_ADDRESS (0x10009000)
+#define VEXPRESS_TIMER01 (0x10011000)
+#define VEXPRESS_PL111 (0x10020000)
+#define VEXPRESS_SRAM_START (0x48000000)
+#define VEXPRESS_FRAMEBUFFER_START (0x4c000000)
+#define VEXPRESS_DRAM_START (0x60000000)
+
+
+#endif /* QEMU_ARMV8_MEMORYMAP_H_ */
diff --git a/src/mainboard/emulation/qemu-armv8/mmio.c b/src/mainboard/emulation/qemu-armv8/mmio.c
new file mode 100644
index 0000000..8d3eaef
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/mmio.c
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Vladimir Serbinenko <phcoder(a)gmail.com>
+ * Copyright 2018-present Facebook, Inc.
+ *
+ * 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; version 2 or, at your option, any later
+ * version of the License.
+ *
+ * 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.
+ */
+#include <console/uart.h>
+#include <drivers/arm/sp804/sp804.h>
+#include "memorymap.h"
+
+uintptr_t uart_platform_base(int idx)
+{
+ if (idx == 0)
+ return VEXPRESS_UART0_IO_ADDRESS;
+
+ return 0;
+}
+
+uintptr_t timer_platform_baseptr(const size_t idx)
+{
+ if (idx == 0)
+ return VEXPRESS_TIMER01;
+
+ return 0;
+}
diff --git a/src/mainboard/emulation/qemu-armv8/romstage.c b/src/mainboard/emulation/qemu-armv8/romstage.c
new file mode 100644
index 0000000..b6314ccd
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/romstage.c
@@ -0,0 +1,23 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#include <console/console.h>
+#include <program_loading.h>
+
+void main(void)
+{
+ console_init();
+ run_ramstage();
+}
diff --git a/src/mainboard/emulation/qemu-armv8/timer.c b/src/mainboard/emulation/qemu-armv8/timer.c
new file mode 100644
index 0000000..8163200
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/timer.c
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, Inc.
+ * Copyright 2018-present Facebook, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#include <drivers/arm/sp804/sp804.h>
+#include <delay.h>
+#include <timer.h>
+
+void init_timer(void)
+{
+ sp804_init(0);
+}
+
+void timer_monotonic_get(struct mono_time *mt)
+{
+ /* QEMU's timer runs at 1MHz, no need to change the raw value */
+ mono_time_set_usecs(mt, sp804_timer_raw_value(0));
+}
--
To view, visit https://review.coreboot.org/23812
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib4f2fd43afb855c2ae5760d9ee6ae1478b09104c
Gerrit-Change-Number: 23812
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/23811
Change subject: drivers/arm: Add driver for SP804 timer
......................................................................
drivers/arm: Add driver for SP804 timer
Add a new driver for SP804 timers.
Make use of it in mb/emulation/qemu-armv7.
Tested on qemu-system-arm.
Change-Id: I742335014d415e97a20f8b7ccf66e5262a80149d
Signed-off-by: Patrick Rudolph <patrick.rudolph(a)9elements.com>
---
A src/drivers/arm/sp804/Kconfig
A src/drivers/arm/sp804/Makefile.inc
A src/drivers/arm/sp804/sp804.c
A src/drivers/arm/sp804/sp804.h
M src/mainboard/emulation/qemu-armv7/Kconfig
M src/mainboard/emulation/qemu-armv7/mmio.c
M src/mainboard/emulation/qemu-armv7/timer.c
7 files changed, 126 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/11/23811/1
diff --git a/src/drivers/arm/sp804/Kconfig b/src/drivers/arm/sp804/Kconfig
new file mode 100644
index 0000000..17d3c87
--- /dev/null
+++ b/src/drivers/arm/sp804/Kconfig
@@ -0,0 +1,4 @@
+config DRIVERS_ARM_SP804
+ bool
+ default n
+ select HAVE_MONOTONIC_TIMER
diff --git a/src/drivers/arm/sp804/Makefile.inc b/src/drivers/arm/sp804/Makefile.inc
new file mode 100644
index 0000000..56bb97f
--- /dev/null
+++ b/src/drivers/arm/sp804/Makefile.inc
@@ -0,0 +1,4 @@
+bootblock-$(CONFIG_DRIVERS_ARM_SP804) += sp804.c
+ramstage-$(CONFIG_DRIVERS_ARM_SP804) += sp804.c
+romstage-$(CONFIG_DRIVERS_ARM_SP804) += sp804.c
+verstage-$(CONFIG_DRIVERS_ARM_SP804) += sp804.c
diff --git a/src/drivers/arm/sp804/sp804.c b/src/drivers/arm/sp804/sp804.c
new file mode 100644
index 0000000..ed0dcc6
--- /dev/null
+++ b/src/drivers/arm/sp804/sp804.c
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018-present Facebook, Inc.
+ *
+ * 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; version 2 or, at your option, any later
+ * version of the License.
+ *
+ * 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.
+ */
+#include <types.h>
+#include <drivers/arm/sp804/sp804.h>
+#include <arch/io.h>
+#include <stdint.h>
+
+union sp804_timer_control {
+ u8 u;
+ struct {
+ u8 oneshot : 1;
+ u8 mode32bit : 1;
+ u8 div : 2;
+ u8 : 1;
+ u8 ie : 1;
+ u8 periodic : 1;
+ u8 enable : 1;
+ } s;
+};
+
+struct sp804_timer {
+ u32 load;
+ u32 value;
+ union sp804_timer_control control;
+};
+
+void sp804_init(const size_t idx)
+{
+ struct sp804_timer *regs = (void *)timer_platform_baseptr(idx);
+ union sp804_timer_control control;
+
+ control.u = 0;
+ write32(®s->control, control.u);
+
+ /* Counter decrements, initialize with max. value */
+ write32(®s->load, UINT32_MAX);
+ write32(®s->value, UINT32_MAX);
+
+ /* Enable 32bit mode, no prescaler */
+ control.s.mode32bit = 1;
+ control.s.div = 0;
+ control.s.enable = 1;
+ write32(®s->control, control.u);
+
+}
+
+u32 sp804_timer_raw_value(const size_t idx)
+{
+ struct sp804_timer *regs =
+ (void *)timer_platform_baseptr(idx);
+
+ /* Counter decrements, need to subtract initial value */
+ return UINT32_MAX - read32(®s->value);
+}
diff --git a/src/drivers/arm/sp804/sp804.h b/src/drivers/arm/sp804/sp804.h
new file mode 100644
index 0000000..0625a4a
--- /dev/null
+++ b/src/drivers/arm/sp804/sp804.h
@@ -0,0 +1,25 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018-present Facebook, Inc.
+ *
+ * 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; version 2 or, at your option, any later
+ * version of the License.
+ *
+ * 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.
+ */
+#include <types.h>
+
+#ifndef ARM_SP804_TABLES_H
+#define ARM_SP804_TABLES_H
+
+void sp804_init(const size_t idx);
+uintptr_t timer_platform_baseptr(const size_t idx);
+u32 sp804_timer_raw_value(const size_t idx);
+
+#endif
diff --git a/src/mainboard/emulation/qemu-armv7/Kconfig b/src/mainboard/emulation/qemu-armv7/Kconfig
index 74e0163..bdd3189 100644
--- a/src/mainboard/emulation/qemu-armv7/Kconfig
+++ b/src/mainboard/emulation/qemu-armv7/Kconfig
@@ -35,6 +35,8 @@
select ARCH_RAMSTAGE_ARMV7
select BOARD_ROMSIZE_KB_4096
select BOOT_DEVICE_NOT_SPI_FLASH
+ select DRIVERS_ARM_SP804
+ select GENERIC_UDELAY
config MAINBOARD_DIR
string
diff --git a/src/mainboard/emulation/qemu-armv7/mmio.c b/src/mainboard/emulation/qemu-armv7/mmio.c
index 00a20a2..9981c15 100644
--- a/src/mainboard/emulation/qemu-armv7/mmio.c
+++ b/src/mainboard/emulation/qemu-armv7/mmio.c
@@ -12,10 +12,23 @@
*/
#include <console/uart.h>
+#include <drivers/arm/sp804/sp804.h>
#define VEXPRESS_UART0_IO_ADDRESS (0x10009000)
+#define VEXPRESS_TIMER01 (0x10011000)
uintptr_t uart_platform_base(int idx)
{
- return VEXPRESS_UART0_IO_ADDRESS;
+ if (idx == 0)
+ return VEXPRESS_UART0_IO_ADDRESS;
+
+ return 0;
+}
+
+uintptr_t timer_platform_baseptr(const size_t idx)
+{
+ if (idx == 0)
+ return VEXPRESS_TIMER01;
+
+ return 0;
}
diff --git a/src/mainboard/emulation/qemu-armv7/timer.c b/src/mainboard/emulation/qemu-armv7/timer.c
index b479d42..8163200 100644
--- a/src/mainboard/emulation/qemu-armv7/timer.c
+++ b/src/mainboard/emulation/qemu-armv7/timer.c
@@ -2,6 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2013 Google, Inc.
+ * Copyright 2018-present Facebook, Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -13,14 +14,17 @@
* GNU General Public License for more details.
*/
-void udelay(unsigned int n);
-void udelay(unsigned int n)
+#include <drivers/arm/sp804/sp804.h>
+#include <delay.h>
+#include <timer.h>
+
+void init_timer(void)
{
- /* TODO provide delay here. */
+ sp804_init(0);
}
-int init_timer(void);
-int init_timer(void)
+void timer_monotonic_get(struct mono_time *mt)
{
- return 0;
+ /* QEMU's timer runs at 1MHz, no need to change the raw value */
+ mono_time_set_usecs(mt, sp804_timer_raw_value(0));
}
--
To view, visit https://review.coreboot.org/23811
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I742335014d415e97a20f8b7ccf66e5262a80149d
Gerrit-Change-Number: 23811
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <patrick.rudolph(a)9elements.com>