2012-02-16 10:56:05 +01:00
|
|
|
/*
|
|
|
|
* Samsung exynos4 SoC based boards emulation
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
|
|
|
|
* Maksim Kozlov <m.kozlov@samsung.com>
|
|
|
|
* Evgeny Voevodin <e.voevodin@samsung.com>
|
|
|
|
* Igor Mitsyanko <i.mitsyanko@samsung.com>
|
|
|
|
*
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-12-17 18:20:04 +01:00
|
|
|
#include "sysemu/sysemu.h"
|
2013-07-29 18:29:54 +02:00
|
|
|
#include "sysemu/qtest.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/sysbus.h"
|
2012-10-24 08:43:34 +02:00
|
|
|
#include "net/net.h"
|
2013-04-09 16:26:55 +02:00
|
|
|
#include "hw/arm/arm.h"
|
2012-12-17 18:19:49 +01:00
|
|
|
#include "exec/address-spaces.h"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/arm/exynos4210.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/boards.h"
|
2012-02-16 10:56:05 +01:00
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
|
|
|
|
//#define DEBUG
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#undef PRINT_DEBUG
|
|
|
|
#define PRINT_DEBUG(fmt, args...) \
|
|
|
|
do { \
|
|
|
|
fprintf(stderr, " [%s:%d] "fmt, __func__, __LINE__, ##args); \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define PRINT_DEBUG(fmt, args...) do {} while (0)
|
|
|
|
#endif
|
|
|
|
|
2012-02-16 10:56:06 +01:00
|
|
|
#define SMDK_LAN9118_BASE_ADDR 0x05000000
|
|
|
|
|
2012-02-16 10:56:05 +01:00
|
|
|
typedef enum Exynos4BoardType {
|
|
|
|
EXYNOS4_BOARD_NURI,
|
|
|
|
EXYNOS4_BOARD_SMDKC210,
|
|
|
|
EXYNOS4_NUM_OF_BOARDS
|
|
|
|
} Exynos4BoardType;
|
|
|
|
|
|
|
|
static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = {
|
|
|
|
[EXYNOS4_BOARD_NURI] = 0xD33,
|
|
|
|
[EXYNOS4_BOARD_SMDKC210] = 0xB16,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS] = {
|
|
|
|
[EXYNOS4_BOARD_NURI] = EXYNOS4210_SECOND_CPU_BOOTREG,
|
|
|
|
[EXYNOS4_BOARD_SMDKC210] = EXYNOS4210_SECOND_CPU_BOOTREG,
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = {
|
|
|
|
[EXYNOS4_BOARD_NURI] = 0x40000000,
|
|
|
|
[EXYNOS4_BOARD_SMDKC210] = 0x40000000,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct arm_boot_info exynos4_board_binfo = {
|
|
|
|
.loader_start = EXYNOS4210_BASE_BOOT_ADDR,
|
|
|
|
.smp_loader_start = EXYNOS4210_SMP_BOOT_ADDR,
|
|
|
|
.nb_cpus = EXYNOS4210_NCPUS,
|
2012-04-13 13:39:06 +02:00
|
|
|
.write_secondary_boot = exynos4210_write_secondary,
|
2012-02-16 10:56:05 +01:00
|
|
|
};
|
|
|
|
|
2012-02-16 10:56:06 +01:00
|
|
|
static void lan9215_init(uint32_t base, qemu_irq irq)
|
|
|
|
{
|
|
|
|
DeviceState *dev;
|
|
|
|
SysBusDevice *s;
|
|
|
|
|
|
|
|
/* This should be a 9215 but the 9118 is close enough */
|
2012-07-24 17:35:11 +02:00
|
|
|
if (nd_table[0].used) {
|
2012-02-16 10:56:06 +01:00
|
|
|
qemu_check_nic_model(&nd_table[0], "lan9118");
|
|
|
|
dev = qdev_create(NULL, "lan9118");
|
|
|
|
qdev_set_nic_properties(dev, &nd_table[0]);
|
|
|
|
qdev_prop_set_uint32(dev, "mode_16bit", 1);
|
|
|
|
qdev_init_nofail(dev);
|
2013-01-20 02:47:33 +01:00
|
|
|
s = SYS_BUS_DEVICE(dev);
|
2012-02-16 10:56:06 +01:00
|
|
|
sysbus_mmio_map(s, 0, base);
|
|
|
|
sysbus_connect_irq(s, 0, irq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-07 16:42:57 +02:00
|
|
|
static Exynos4210State *exynos4_boards_init_common(MachineState *machine,
|
2012-10-30 08:45:08 +01:00
|
|
|
Exynos4BoardType board_type)
|
2012-02-16 10:56:05 +01:00
|
|
|
{
|
2015-09-04 20:37:04 +02:00
|
|
|
MachineClass *mc = MACHINE_GET_CLASS(machine);
|
|
|
|
|
2013-07-29 18:29:54 +02:00
|
|
|
if (smp_cpus != EXYNOS4210_NCPUS && !qtest_enabled()) {
|
2012-02-16 10:56:05 +01:00
|
|
|
fprintf(stderr, "%s board supports only %d CPU cores. Ignoring smp_cpus"
|
|
|
|
" value.\n",
|
2015-09-04 20:37:04 +02:00
|
|
|
mc->name, EXYNOS4210_NCPUS);
|
2012-02-16 10:56:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type];
|
|
|
|
exynos4_board_binfo.board_id = exynos4_board_id[board_type];
|
|
|
|
exynos4_board_binfo.smp_bootreg_addr =
|
|
|
|
exynos4_board_smp_bootreg_addr[board_type];
|
2014-05-07 16:42:57 +02:00
|
|
|
exynos4_board_binfo.kernel_filename = machine->kernel_filename;
|
|
|
|
exynos4_board_binfo.initrd_filename = machine->initrd_filename;
|
|
|
|
exynos4_board_binfo.kernel_cmdline = machine->kernel_cmdline;
|
2012-02-16 10:56:09 +01:00
|
|
|
exynos4_board_binfo.gic_cpu_if_addr =
|
|
|
|
EXYNOS4210_SMP_PRIVATE_BASE_ADDR + 0x100;
|
2012-02-16 10:56:05 +01:00
|
|
|
|
|
|
|
PRINT_DEBUG("\n ram_size: %luMiB [0x%08lx]\n"
|
|
|
|
" kernel_filename: %s\n"
|
|
|
|
" kernel_cmdline: %s\n"
|
|
|
|
" initrd_filename: %s\n",
|
|
|
|
exynos4_board_ram_size[board_type] / 1048576,
|
|
|
|
exynos4_board_ram_size[board_type],
|
2014-05-07 16:42:57 +02:00
|
|
|
machine->kernel_filename,
|
|
|
|
machine->kernel_cmdline,
|
|
|
|
machine->initrd_filename);
|
2012-02-16 10:56:05 +01:00
|
|
|
|
|
|
|
return exynos4210_init(get_system_memory(),
|
|
|
|
exynos4_board_ram_size[board_type]);
|
|
|
|
}
|
|
|
|
|
2014-05-07 16:42:57 +02:00
|
|
|
static void nuri_init(MachineState *machine)
|
2012-02-16 10:56:05 +01:00
|
|
|
{
|
2014-05-07 16:42:57 +02:00
|
|
|
exynos4_boards_init_common(machine, EXYNOS4_BOARD_NURI);
|
2012-02-16 10:56:05 +01:00
|
|
|
|
2013-05-29 22:29:20 +02:00
|
|
|
arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo);
|
2012-02-16 10:56:05 +01:00
|
|
|
}
|
|
|
|
|
2014-05-07 16:42:57 +02:00
|
|
|
static void smdkc210_init(MachineState *machine)
|
2012-02-16 10:56:05 +01:00
|
|
|
{
|
2014-05-07 16:42:57 +02:00
|
|
|
Exynos4210State *s = exynos4_boards_init_common(machine,
|
2012-10-30 08:45:08 +01:00
|
|
|
EXYNOS4_BOARD_SMDKC210);
|
2012-02-16 10:56:05 +01:00
|
|
|
|
2012-02-16 10:56:06 +01:00
|
|
|
lan9215_init(SMDK_LAN9118_BASE_ADDR,
|
|
|
|
qemu_irq_invert(s->irq_table[exynos4210_get_irq(37, 1)]));
|
2013-05-29 22:29:20 +02:00
|
|
|
arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo);
|
2012-02-16 10:56:05 +01:00
|
|
|
}
|
|
|
|
|
2015-09-19 10:49:44 +02:00
|
|
|
static void nuri_class_init(ObjectClass *oc, void *data)
|
2015-09-04 20:37:08 +02:00
|
|
|
{
|
2015-09-19 10:49:44 +02:00
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
|
|
|
|
2015-09-04 20:37:08 +02:00
|
|
|
mc->desc = "Samsung NURI board (Exynos4210)";
|
|
|
|
mc->init = nuri_init;
|
|
|
|
mc->max_cpus = EXYNOS4210_NCPUS;
|
|
|
|
}
|
2015-09-04 20:37:05 +02:00
|
|
|
|
2015-09-19 10:49:44 +02:00
|
|
|
static const TypeInfo nuri_type = {
|
|
|
|
.name = MACHINE_TYPE_NAME("nuri"),
|
|
|
|
.parent = TYPE_MACHINE,
|
|
|
|
.class_init = nuri_class_init,
|
|
|
|
};
|
2012-02-16 10:56:05 +01:00
|
|
|
|
2015-09-19 10:49:44 +02:00
|
|
|
static void smdkc210_class_init(ObjectClass *oc, void *data)
|
2012-02-16 10:56:05 +01:00
|
|
|
{
|
2015-09-19 10:49:44 +02:00
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
|
|
|
|
2015-09-04 20:37:08 +02:00
|
|
|
mc->desc = "Samsung SMDKC210 board (Exynos4210)";
|
|
|
|
mc->init = smdkc210_init;
|
|
|
|
mc->max_cpus = EXYNOS4210_NCPUS;
|
2012-02-16 10:56:05 +01:00
|
|
|
}
|
|
|
|
|
2015-09-19 10:49:44 +02:00
|
|
|
static const TypeInfo smdkc210_type = {
|
|
|
|
.name = MACHINE_TYPE_NAME("smdkc210"),
|
|
|
|
.parent = TYPE_MACHINE,
|
|
|
|
.class_init = smdkc210_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void exynos4_machines_init(void)
|
|
|
|
{
|
|
|
|
type_register_static(&nuri_type);
|
|
|
|
type_register_static(&smdkc210_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
machine_init(exynos4_machines_init)
|