]> Git Repo - qemu.git/blame - hw/arm/exynos4_boards.c
hw/arm/virt: move VirtMachineState/Class to virt.h
[qemu.git] / hw / arm / exynos4_boards.c
CommitLineData
0caa7113
EV
1/*
2 * Samsung exynos4 SoC based boards emulation
3 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
5 * Maksim Kozlov <[email protected]>
6 * Evgeny Voevodin <[email protected]>
7 * Igor Mitsyanko <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
12b16722 24#include "qemu/osdep.h"
4771d756
PB
25#include "qemu-common.h"
26#include "cpu.h"
9c17d615 27#include "sysemu/sysemu.h"
4bd2f93f 28#include "sysemu/qtest.h"
83c9f4ca 29#include "hw/sysbus.h"
1422e32d 30#include "net/net.h"
bd2be150 31#include "hw/arm/arm.h"
022c62cb 32#include "exec/address-spaces.h"
0d09e41a 33#include "hw/arm/exynos4210.h"
83c9f4ca 34#include "hw/boards.h"
0caa7113
EV
35
36#undef DEBUG
37
38//#define DEBUG
39
40#ifdef DEBUG
41 #undef PRINT_DEBUG
42 #define PRINT_DEBUG(fmt, args...) \
43 do { \
44 fprintf(stderr, " [%s:%d] "fmt, __func__, __LINE__, ##args); \
45 } while (0)
46#else
47 #define PRINT_DEBUG(fmt, args...) do {} while (0)
48#endif
49
2c2c6496
EV
50#define SMDK_LAN9118_BASE_ADDR 0x05000000
51
0caa7113
EV
52typedef enum Exynos4BoardType {
53 EXYNOS4_BOARD_NURI,
54 EXYNOS4_BOARD_SMDKC210,
55 EXYNOS4_NUM_OF_BOARDS
56} Exynos4BoardType;
57
58static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = {
59 [EXYNOS4_BOARD_NURI] = 0xD33,
60 [EXYNOS4_BOARD_SMDKC210] = 0xB16,
61};
62
63static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS] = {
64 [EXYNOS4_BOARD_NURI] = EXYNOS4210_SECOND_CPU_BOOTREG,
65 [EXYNOS4_BOARD_SMDKC210] = EXYNOS4210_SECOND_CPU_BOOTREG,
66};
67
68static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = {
69 [EXYNOS4_BOARD_NURI] = 0x40000000,
70 [EXYNOS4_BOARD_SMDKC210] = 0x40000000,
71};
72
73static struct arm_boot_info exynos4_board_binfo = {
74 .loader_start = EXYNOS4210_BASE_BOOT_ADDR,
75 .smp_loader_start = EXYNOS4210_SMP_BOOT_ADDR,
76 .nb_cpus = EXYNOS4210_NCPUS,
3f088e36 77 .write_secondary_boot = exynos4210_write_secondary,
0caa7113
EV
78};
79
2c2c6496
EV
80static void lan9215_init(uint32_t base, qemu_irq irq)
81{
82 DeviceState *dev;
83 SysBusDevice *s;
84
85 /* This should be a 9215 but the 9118 is close enough */
a005d073 86 if (nd_table[0].used) {
2c2c6496
EV
87 qemu_check_nic_model(&nd_table[0], "lan9118");
88 dev = qdev_create(NULL, "lan9118");
89 qdev_set_nic_properties(dev, &nd_table[0]);
90 qdev_prop_set_uint32(dev, "mode_16bit", 1);
91 qdev_init_nofail(dev);
1356b98d 92 s = SYS_BUS_DEVICE(dev);
2c2c6496
EV
93 sysbus_mmio_map(s, 0, base);
94 sysbus_connect_irq(s, 0, irq);
95 }
96}
97
3ef96221 98static Exynos4210State *exynos4_boards_init_common(MachineState *machine,
7f0f7740 99 Exynos4BoardType board_type)
0caa7113 100{
ca177760
EH
101 MachineClass *mc = MACHINE_GET_CLASS(machine);
102
4bd2f93f 103 if (smp_cpus != EXYNOS4210_NCPUS && !qtest_enabled()) {
0caa7113
EV
104 fprintf(stderr, "%s board supports only %d CPU cores. Ignoring smp_cpus"
105 " value.\n",
ca177760 106 mc->name, EXYNOS4210_NCPUS);
0caa7113
EV
107 }
108
109 exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type];
110 exynos4_board_binfo.board_id = exynos4_board_id[board_type];
111 exynos4_board_binfo.smp_bootreg_addr =
112 exynos4_board_smp_bootreg_addr[board_type];
3ef96221
MA
113 exynos4_board_binfo.kernel_filename = machine->kernel_filename;
114 exynos4_board_binfo.initrd_filename = machine->initrd_filename;
115 exynos4_board_binfo.kernel_cmdline = machine->kernel_cmdline;
96eacf64
PM
116 exynos4_board_binfo.gic_cpu_if_addr =
117 EXYNOS4210_SMP_PRIVATE_BASE_ADDR + 0x100;
0caa7113
EV
118
119 PRINT_DEBUG("\n ram_size: %luMiB [0x%08lx]\n"
120 " kernel_filename: %s\n"
121 " kernel_cmdline: %s\n"
122 " initrd_filename: %s\n",
123 exynos4_board_ram_size[board_type] / 1048576,
124 exynos4_board_ram_size[board_type],
3ef96221
MA
125 machine->kernel_filename,
126 machine->kernel_cmdline,
127 machine->initrd_filename);
0caa7113
EV
128
129 return exynos4210_init(get_system_memory(),
130 exynos4_board_ram_size[board_type]);
131}
132
3ef96221 133static void nuri_init(MachineState *machine)
0caa7113 134{
3ef96221 135 exynos4_boards_init_common(machine, EXYNOS4_BOARD_NURI);
0caa7113 136
182735ef 137 arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo);
0caa7113
EV
138}
139
3ef96221 140static void smdkc210_init(MachineState *machine)
0caa7113 141{
3ef96221 142 Exynos4210State *s = exynos4_boards_init_common(machine,
7f0f7740 143 EXYNOS4_BOARD_SMDKC210);
0caa7113 144
2c2c6496
EV
145 lan9215_init(SMDK_LAN9118_BASE_ADDR,
146 qemu_irq_invert(s->irq_table[exynos4210_get_irq(37, 1)]));
182735ef 147 arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo);
0caa7113
EV
148}
149
8a661aea 150static void nuri_class_init(ObjectClass *oc, void *data)
e264d29d 151{
8a661aea
AF
152 MachineClass *mc = MACHINE_CLASS(oc);
153
e264d29d
EH
154 mc->desc = "Samsung NURI board (Exynos4210)";
155 mc->init = nuri_init;
156 mc->max_cpus = EXYNOS4210_NCPUS;
157}
97c6671c 158
8a661aea
AF
159static const TypeInfo nuri_type = {
160 .name = MACHINE_TYPE_NAME("nuri"),
161 .parent = TYPE_MACHINE,
162 .class_init = nuri_class_init,
163};
0caa7113 164
8a661aea 165static void smdkc210_class_init(ObjectClass *oc, void *data)
0caa7113 166{
8a661aea
AF
167 MachineClass *mc = MACHINE_CLASS(oc);
168
e264d29d
EH
169 mc->desc = "Samsung SMDKC210 board (Exynos4210)";
170 mc->init = smdkc210_init;
171 mc->max_cpus = EXYNOS4210_NCPUS;
0caa7113
EV
172}
173
8a661aea
AF
174static const TypeInfo smdkc210_type = {
175 .name = MACHINE_TYPE_NAME("smdkc210"),
176 .parent = TYPE_MACHINE,
177 .class_init = smdkc210_class_init,
178};
179
180static void exynos4_machines_init(void)
181{
182 type_register_static(&nuri_type);
183 type_register_static(&smdkc210_type);
184}
185
0e6aac87 186type_init(exynos4_machines_init)
This page took 0.337516 seconds and 4 git commands to generate.