[U-Boot] [PATCH v9 7/7] arm: faraday: add Faraday Virtual Machine support

Kuo-Jung Su
2014-01-16T08:31:56Z

Faraday Virtual Machine (FVM) is a QEMU based emulator
which is designed for early stage software development
(e.g., IPL, SPL).

Please check the link bellow for details:
https://github.com/dantesu1218/qemu/blob/qemu-1.5.1/hw/arm/faraday_fvm.c

Signed-off-by: Kuo-Jung Su <dantesu@faraday-tech.com>
CC: Albert Aribaud <albert.u.boot@aribaud.net>
---
Changes for v9:
- Initial commit

arch/arm/cpu/faraday/fvm/Makefile | 8 ++++
arch/arm/include/asm/arch-fvm/hardware.h | 76 ++++++++++++++++++++++++++++++
board/faraday/fvm/Makefile | 9 ++++
board/faraday/fvm/board.c | 60 +++++++++++++++++++++++
board/faraday/fvm/clock.c | 49 +++++++++++++++++++
board/faraday/fvm/lowlevel_init.S | 15 ++++++
boards.cfg | 1 +
include/configs/fvm.h | 61 ++++++++++++++++++++++++
8 files changed, 279 insertions(+)
create mode 100644 arch/arm/cpu/faraday/fvm/Makefile
create mode 100644 arch/arm/include/asm/arch-fvm/hardware.h
create mode 100644 board/faraday/fvm/Makefile
create mode 100644 board/faraday/fvm/board.c
create mode 100644 board/faraday/fvm/clock.c
create mode 100644 board/faraday/fvm/lowlevel_init.S
create mode 100644 include/configs/fvm.h

diff --git a/arch/arm/cpu/faraday/fvm/Makefile b/arch/arm/cpu/faraday/fvm/Makefile
new file mode 100644
index 0000000..1081c06
--- /dev/null
+++ b/arch/arm/cpu/faraday/fvm/Makefile
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2000-2003
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-y :=
diff --git a/arch/arm/include/asm/arch-fvm/hardware.h b/arch/arm/include/asm/arch-fvm/hardware.h
new file mode 100644
index 0000000..e362984
--- /dev/null
+++ b/arch/arm/include/asm/arch-fvm/hardware.h
@@ -0,0 +1,76 @@
+/*
+ * arch/arm/include/asm/arch-fvm/hardware.h
+ *
+ * (C) Copyright 2013
+ * Faraday Technology Corporation. <http://www.faraday-tech.com/>
+ * Kuo-Jung Su <dantesu@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __ASM_ARCH_HARDWARE_H
+#define __ASM_ARCH_HARDWARE_H
+
+#include <asm/sizes.h>
+
+#define CONFIG_DRAM_BASE 0x10000000
+
+#define CONFIG_SRAM_BASE 0xA0000000
+#define CONFIG_SRAM_SIZE 0x00020000
+
+#define CONFIG_SYSC_BASE 0x90f00000
+#define CONFIG_SYSC_IRQ 15
+
+#define CONFIG_FTINTC030_BASE 0x91000000
+
+#define CONFIG_FTTMR010_BASE 0x90200000
+#define CONFIG_FTTMR010_IRQ 1
+
+#define CONFIG_FTUART010_BASE0 0x90000000
+#define CONFIG_FTUART010_IRQ0 2
+#define CONFIG_FTUART010_BASE1 0x90100000
+#define CONFIG_FTUART010_IRQ1 3
+#define CONFIG_FTUART010_BASE CONFIG_FTUART010_BASE0
+
+#define CONFIG_DDRC_BASE 0x90300000
+
+#define CONFIG_FTI2C010_BASE 0x90400000
+#define CONFIG_FTI2C010_IRQ 4
+
+#define CONFIG_FTSSP010_BASE 0x90500000
+#define CONFIG_FTSSP010_IRQ 5
+
+#define CONFIG_FTWDT010_BASE 0x90600000
+#define CONFIG_FTWDT010_IRQ 6
+
+#define CONFIG_FTRTC011_BASE 0x90700000
+#define CONFIG_FTRTC011_IRQ 7
+
+#define CONFIG_FTTSC010_BASE 0x90800000
+#define CONFIG_FTTSC010_IRQ 8
+
+#define CONFIG_FTAPBBRG020_BASE 0x91100000
+#define CONFIG_FTAPBBRG020_IRQ 16
+
+#define CONFIG_FTDMAC020_BASE 0x91200000
+#define CONFIG_FTDMAC020_IRQ 17
+
+#define CONFIG_FTMAC110_BASE 0x91300000
+#define CONFIG_FTMAC110_IRQ 18
+
+#define CONFIG_FTSPI020_BASE 0x91400000
+#define CONFIG_FTSPI020_IRQ 19
+
+#define CONFIG_FTNANDC021_BASE 0x91500000
+#define CONFIG_FTNANDC021_IRQ 20
+
+#define CONFIG_FTSDC021_BASE 0x91600000
+#define CONFIG_FTSDC021_IRQ 21
+
+#define CONFIG_FOTG210_BASE 0x91700000
+#define CONFIG_FOTG210_IRQ 22
+
+#define CONFIG_FTLCDC200_BASE 0x91800000
+#define CONFIG_FTLCDC200_IRQ 23
+
+#endif /* EOF */
diff --git a/board/faraday/fvm/Makefile b/board/faraday/fvm/Makefile
new file mode 100644
index 0000000..42fef70
--- /dev/null
+++ b/board/faraday/fvm/Makefile
@@ -0,0 +1,9 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-y := board.o clock.o
+obj-y += lowlevel_init.o
diff --git a/board/faraday/fvm/board.c b/board/faraday/fvm/board.c
new file mode 100644
index 0000000..6c2b03a
--- /dev/null
+++ b/board/faraday/fvm/board.c
@@ -0,0 +1,60 @@
+/*
+ * (C) Copyright 2013
+ * Faraday Technology Corporation. <http://www.faraday-tech.com/>
+ * Kuo-Jung Su <dantesu@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <linux/err.h>
+#include <asm/io.h>
+#include <spi.h>
+#include <netdev.h>
+#include <malloc.h>
+
+#include <faraday/ftsdc021.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * Miscellaneous platform dependent initialisations
+ */
+int board_early_init_f(void)
+{
+ gd->arch.timer_rate_hz = clk_get_rate("APB");
+ return 0;
+}
+
+int board_init(void)
+{
+ gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
+ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
+ return 0;
+}
+
+int dram_init(void)
+{
+ gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+ gd->bd->bi_dram[0].size = CONFIG_SYS_SDRAM_SIZE;
+ gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
+ return 0;
+}
+
+int board_eth_init(bd_t *bd)
+{
+#ifdef CONFIG_FTMAC110
+ return ftmac110_initialize(bd);
+#else
+ return 0;
+#endif
+}
+
+int board_mmc_init(bd_t *bis)
+{
+#ifdef CONFIG_FTSDC021
+ return ftsdc021_sdhci_init(0);
+#else
+ return 0;
+#endif
+}
diff --git a/board/faraday/fvm/clock.c b/board/faraday/fvm/clock.c
new file mode 100644
index 0000000..f5a759d
--- /dev/null
+++ b/board/faraday/fvm/clock.c
@@ -0,0 +1,49 @@
+/*
+ * (C) Copyright 2013
+ * Faraday Technology Corporation. <http://www.faraday-tech.com/tw/>
+ * Kuo-Jung Su <dantesu@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static inline ulong clk_get_rate_ahb(void)
+{
+ return 50000000; /* 50MHz */
+}
+
+static inline ulong clk_get_rate_apb(void)
+{
+ return 50000000; /* 50MHz */
+}
+
+static inline ulong clk_get_rate_cpu(void)
+{
+ return 50000000; /* 50MHz */
+}
+
+ulong clk_get_rate(const char *id)
+{
+ ulong ret = 0;
+
+ if (!strcmp(id, "AHB"))
+ ret = clk_get_rate_ahb();
+ else if (!strcmp(id, "APB"))
+ ret = clk_get_rate_apb();
+ else if (!strcmp(id, "CPU"))
+ ret = clk_get_rate_cpu();
+ else if (!strcmp(id, "I2C"))
+ ret = clk_get_rate_apb();
+ else if (!strcmp(id, "SSP"))
+ ret = clk_get_rate_apb();
+ else if (!strcmp(id, "SPI"))
+ ret = clk_get_rate_ahb();
+ else if (!strcmp(id, "MMC") || !strcmp(id, "SDC"))
+ ret = clk_get_rate_ahb();
+
+ return ret;
+}
diff --git a/board/faraday/fvm/lowlevel_init.S b/board/faraday/fvm/lowlevel_init.S
new file mode 100644
index 0000000..cbc006d
--- /dev/null
+++ b/board/faraday/fvm/lowlevel_init.S
@@ -0,0 +1,15 @@
+/*
+ * (C) Copyright 2013
+ * Faraday Technology Corporation. <http://www.faraday-tech.com/tw/>
+ * Kuo-Jung Su <dantesu@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <config.h>
+#include <version.h>
+
+/* Set up the platform, once the cpu has been initialized */
+.globl lowlevel_init
+lowlevel_init:
+ mov pc,lr
diff --git a/boards.cfg b/boards.cfg
index a998452..089f539 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -60,6 +60,7 @@ Active arm arm920t - armltd integrator
Active arm arm920t - armltd integrator integratorcp_cm920t integratorcp:CM920T Linus Walleij <linus.walleij@linaro.org>
Active arm arm920t a320 faraday - a320evb - Po-Yu Chuang <ratbert@faraday-tech.com>
Active arm faraday a369 faraday a369evb a369evb a369 Kuo-Jung Su <dantesu@gmail.com>
+Active arm faraday fvm faraday - fvm - Kuo-Jung Su <dantesu@gmail.com>
Active arm arm920t at91 atmel at91rm9200ek at91rm9200ek at91rm9200ek Andreas Bie?mann <andreas.devel@gmail.com>
Active arm arm920t at91 atmel at91rm9200ek at91rm9200ek_ram at91rm9200ek:RAMBOOT Andreas Bie?mann <andreas.devel@gmail.com>
Active arm arm920t at91 BuS eb_cpux9k2 eb_cpux9k2 eb_cpux9k2 Jens Scharsig <esw@bus-elektronik.de>
diff --git a/include/configs/fvm.h b/include/configs/fvm.h
new file mode 100644
index 0000000..10522b2
--- /dev/null
+++ b/include/configs/fvm.h
@@ -0,0 +1,61 @@
+/*
+ * (C) Copyright 2013
+ * Faraday Technology Corporation. <http://www.faraday-tech.com/>
+ * Kuo-Jung Su <dantesu@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#include <asm/hardware.h>
+
+/* Disable MMU/D-CACHE */
+#define CONFIG_SYS_DCACHE_OFF
+
+/* Memory Configuration */
+#define CONFIG_NR_DRAM_BANKS 1
+#define CONFIG_SYS_SDRAM_BASE 0x10000000
+#define CONFIG_SYS_SDRAM_SIZE SZ_256M
+
+#define CONFIG_SYS_MALLOC_LEN SZ_2M
+#define CONFIG_SYS_TEXT_BASE 0x10800000
+
+/* Timer */
+#define CONFIG_FTTMR010
+
+/* Serial (UART) */
+#define CONFIG_FTUART010
+#define CONFIG_FTUART010_CLK 18432000
+#define CONFIG_BAUDRATE 38400
+
+/* NIC */
+#define CONFIG_FTMAC110
+
+/* I2C */
+#define CONFIG_FTI2C010
+#define CONFIG_ENV_EEPROM_IS_ON_I2C
+
+/* MMC/SD */
+#define CONFIG_FTSDC021
+
+/* NOR flash */
+#define PHYS_FLASH_SIZE SZ_64M
+#define CONFIG_SYS_FLASH_BASE 0x80000000
+#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT
+#define CONFIG_SYS_MAX_FLASH_BANKS 1
+#define CONFIG_SYS_MAX_FLASH_SECT 1024
+
+/* USB */
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 1
+#define CONFIG_USB_EHCI_BASE_LIST { CONFIG_FOTG210_BASE }
+
+/* Environment */
+#define CONFIG_ENV_IS_NOWHERE
+#define CONFIG_ENV_SIZE SZ_64K
+
+/* Faraday common configuration */
+#include "faraday-common.h"
+
+#endif /* EOF */
--
1.7.9.5