[U-Boot] [PATCH v12 8/8] arm: faraday: add faraday virtual machine support

Kuo-Jung Su dantesu at gmail.com
Tue Apr 1 10:46:59 CEST 2014


From: Kuo-Jung Su <dantesu at faraday-tech.com>

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

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 at faraday-tech.com>
CC: Albert Aribaud <albert.u.boot at aribaud.net>
---
Changes for v12:
	- Add Linux legacy clock framework support (no common clock).
	- Drop board_early_init_f()
	- Coding style cleanup

Changes for v11:
	- Fix boards.cfg (due to commit 3fa67050)
	- Rename <asm/sizes.h> to <linux/sizes.h> (due to commit 1ace4022)
	- Directly specify the timer object in 'arch/arm/cpu/faraday/fvm/Makefile'
	  instead of using CONFIG_FTTMR010 in 'arch/arm/cpu/faraday/Makefile'

Changes for v10:
	- Nothing updates

Changes for v9:
	- Initial commit

 arch/arm/cpu/faraday/fvm/Makefile        |    8 ++++
 arch/arm/cpu/faraday/fvm/clock.c         |   70 +++++++++++++++++++++++++++
 arch/arm/cpu/faraday/fvm/core.c          |   20 ++++++++
 arch/arm/cpu/faraday/fvm/core.h          |   14 ++++++
 arch/arm/include/asm/arch-fvm/clkdev.h   |   20 ++++++++
 arch/arm/include/asm/arch-fvm/hardware.h |   76 ++++++++++++++++++++++++++++++
 board/faraday/fvm/Makefile               |    9 ++++
 board/faraday/fvm/board.c                |   65 +++++++++++++++++++++++++
 board/faraday/fvm/lowlevel_init.S        |   15 ++++++
 boards.cfg                               |    1 +
 include/configs/fvm.h                    |   68 ++++++++++++++++++++++++++
 11 files changed, 366 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/fvm/Makefile
 create mode 100644 arch/arm/cpu/faraday/fvm/clock.c
 create mode 100644 arch/arm/cpu/faraday/fvm/core.c
 create mode 100644 arch/arm/cpu/faraday/fvm/core.h
 create mode 100644 arch/arm/include/asm/arch-fvm/clkdev.h
 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/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..5836aff
--- /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 := core.o clock.o
diff --git a/arch/arm/cpu/faraday/fvm/clock.c b/arch/arm/cpu/faraday/fvm/clock.c
new file mode 100644
index 0000000..d90bc57
--- /dev/null
+++ b/arch/arm/cpu/faraday/fvm/clock.c
@@ -0,0 +1,70 @@
+/*
+ * (C) Copyright 2013
+ * Faraday Technology Corporation. <http://www.faraday-tech.com/>
+ * Kuo-Jung Su <dantesu at gmail.com>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+
+#ifndef CONFIG_PLATFORM_SCLK
+#define CONFIG_PLATFORM_SCLK    50000000 /* 50 MHz */
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static ulong clk_get_hclk(void)
+{
+	return CONFIG_PLATFORM_SCLK;
+}
+
+static ulong clk_get_pclk(void)
+{
+	return CONFIG_PLATFORM_SCLK;
+}
+
+static ulong clk_get_cpu(void)
+{
+	return CONFIG_PLATFORM_SCLK;
+}
+
+static struct clk clk_ahb = {
+	.ops = {
+		.get_rate = clk_get_hclk,
+	},
+};
+
+static struct clk clk_apb = {
+	.ops = {
+		.get_rate = clk_get_pclk,
+	},
+};
+
+static struct clk clk_cpu = {
+	.ops = {
+		.get_rate = clk_get_cpu,
+	},
+};
+
+static struct clk_lookup clk_table[] = {
+	CLKDEV_INIT(NULL, "AHB", &clk_ahb),
+	CLKDEV_INIT(NULL, "APB", &clk_apb),
+	CLKDEV_INIT(NULL, "CPU", &clk_cpu),
+	CLKDEV_INIT(NULL, "TMR", &clk_apb),
+	CLKDEV_INIT(NULL, "I2C", &clk_apb),
+	CLKDEV_INIT(NULL, "SPI", &clk_apb),
+	CLKDEV_INIT(NULL, "SSP", &clk_apb),
+	CLKDEV_INIT(NULL, "MMC", &clk_ahb),
+	CLKDEV_INIT(NULL, "SDC", &clk_ahb),
+};
+
+void clock_init(void)
+{
+	clkdev_add_table(clk_table, ARRAY_SIZE(clk_table));
+
+	gd->arch.timer_rate_hz = clk_get_rate(clk_get_sys(NULL, "TMR"));
+}
diff --git a/arch/arm/cpu/faraday/fvm/core.c b/arch/arm/cpu/faraday/fvm/core.c
new file mode 100644
index 0000000..318fe72
--- /dev/null
+++ b/arch/arm/cpu/faraday/fvm/core.c
@@ -0,0 +1,20 @@
+/*
+ * (C) Copyright 2013
+ * Faraday Technology Corporation. <http://www.faraday-tech.com/>
+ * Kuo-Jung Su <dantesu at gmail.com>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include "core.h"
+
+/*
+ * This arch_cpu_init() overrides the weak function
+ * in "arch/arm/lib/board.c".
+ */
+int arch_cpu_init(void)
+{
+	clock_init();
+	return 0;
+}
diff --git a/arch/arm/cpu/faraday/fvm/core.h b/arch/arm/cpu/faraday/fvm/core.h
new file mode 100644
index 0000000..937c780
--- /dev/null
+++ b/arch/arm/cpu/faraday/fvm/core.h
@@ -0,0 +1,14 @@
+/*
+ * (C) Copyright 2013
+ * Faraday Technology Corporation. <http://www.faraday-tech.com/>
+ * Kuo-Jung Su <dantesu at gmail.com>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#ifndef __FVM_CORE_H
+#define __FVM_CORE_H
+
+void clock_init(void);
+
+#endif
diff --git a/arch/arm/include/asm/arch-fvm/clkdev.h b/arch/arm/include/asm/arch-fvm/clkdev.h
new file mode 100644
index 0000000..912b46a
--- /dev/null
+++ b/arch/arm/include/asm/arch-fvm/clkdev.h
@@ -0,0 +1,20 @@
+/*
+ * (C) Copyright 2013 Faraday Technology
+ * Dante Su <dantesu at faraday-tech.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __ASM_ARCH_CLKDEV_H
+#define __ASM_ARCH_CLKDEV_H
+
+#include <faraday/clkdev.h>
+
+struct clk {
+	struct faraday_clk_ops ops;
+};
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+#endif /* __ASM_ARCH_CLKDEV_H */
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..dd04ced
--- /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 at gmail.com>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#ifndef __ASM_ARCH_HARDWARE_H
+#define __ASM_ARCH_HARDWARE_H
+
+#include <linux/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..920ce43
--- /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
+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..6b7f4f4
--- /dev/null
+++ b/board/faraday/fvm/board.c
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright 2013
+ * Faraday Technology Corporation. <http://www.faraday-tech.com/>
+ * Kuo-Jung Su <dantesu at 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_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)
+{
+	int ret = 0;
+#ifdef CONFIG_FTMAC110
+	uchar eth_addr[6];
+
+	if (!eth_getenv_enetaddr("ethaddr", eth_addr)) {
+		printf("WARNING: 'ethaddr' is a random default\n");
+		eth_random_enetaddr(eth_addr);
+		eth_setenv_enetaddr("ethaddr", eth_addr);
+	}
+
+	ret = ftmac110_initialize(bd);
+#endif
+
+	return ret;
+}
+
+int board_mmc_init(bd_t *bis)
+{
+	int ret = 0;
+
+#ifdef CONFIG_FTSDC021
+	ret = ftsdc021_sdhci_init(0);
+#endif
+
+	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 at 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 49c4f85..824d1d0 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -391,6 +391,7 @@ Active  arm         armv7:arm720t  tegra30     avionic-design  tec-ng
 Active  arm         armv7:arm720t  tegra30     nvidia          beaver              beaver                               -                                                                                                                                 Tom Warren <twarren at nvidia.com>:Stephen Warren <swarren at nvidia.com>
 Active  arm         armv7:arm720t  tegra30     nvidia          cardhu              cardhu                               -                                                                                                                                 Tom Warren <twarren at nvidia.com>
 Active  arm         faraday        a369        faraday         a369evb             a369evb                              a369                                                                                                                              Kuo-Jung Su <dantesu at gmail.com>
+Active  arm         faraday        fvm         faraday         -                   fvm                                  -                                                                                                                                 Kuo-Jung Su <dantesu at gmail.com>
 Active  arm         pxa            -           -               -                   balloon3                             -                                                                                                                                 Marek Vasut <marek.vasut at gmail.com>
 Active  arm         pxa            -           -               -                   h2200                                -                                                                                                                                 Lukasz Dalek <luk0104 at gmail.com>
 Active  arm         pxa            -           -               -                   palmld                               -                                                                                                                                 Marek Vasut <marek.vasut at gmail.com>
diff --git a/include/configs/fvm.h b/include/configs/fvm.h
new file mode 100644
index 0000000..ffd44fc
--- /dev/null
+++ b/include/configs/fvm.h
@@ -0,0 +1,68 @@
+/*
+ * (C) Copyright 2013
+ * Faraday Technology Corporation. <http://www.faraday-tech.com/>
+ * Kuo-Jung Su <dantesu at 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"
+
+/* Platform specific extra environment variables */
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	/* Ethernet default configuration */ \
+	"ipaddr=10.0.0.199\0" \
+	"serverip=10.0.0.128\0" \
+	"netmask=255.255.255.0\0"
+
+#endif /* EOF */
--
1.7.9.5



More information about the U-Boot mailing list