]>
Commit | Line | Data |
---|---|---|
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 <m.kozlov@samsung.com> | |
6 | * Evgeny Voevodin <e.voevodin@samsung.com> | |
7 | * Igor Mitsyanko <i.mitsyanko@samsung.com> | |
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" |
9c17d615 | 25 | #include "sysemu/sysemu.h" |
4bd2f93f | 26 | #include "sysemu/qtest.h" |
83c9f4ca | 27 | #include "hw/sysbus.h" |
1422e32d | 28 | #include "net/net.h" |
bd2be150 | 29 | #include "hw/arm/arm.h" |
022c62cb | 30 | #include "exec/address-spaces.h" |
0d09e41a | 31 | #include "hw/arm/exynos4210.h" |
83c9f4ca | 32 | #include "hw/boards.h" |
0caa7113 EV |
33 | |
34 | #undef DEBUG | |
35 | ||
36 | //#define DEBUG | |
37 | ||
38 | #ifdef DEBUG | |
39 | #undef PRINT_DEBUG | |
40 | #define PRINT_DEBUG(fmt, args...) \ | |
41 | do { \ | |
42 | fprintf(stderr, " [%s:%d] "fmt, __func__, __LINE__, ##args); \ | |
43 | } while (0) | |
44 | #else | |
45 | #define PRINT_DEBUG(fmt, args...) do {} while (0) | |
46 | #endif | |
47 | ||
2c2c6496 EV |
48 | #define SMDK_LAN9118_BASE_ADDR 0x05000000 |
49 | ||
0caa7113 EV |
50 | typedef enum Exynos4BoardType { |
51 | EXYNOS4_BOARD_NURI, | |
52 | EXYNOS4_BOARD_SMDKC210, | |
53 | EXYNOS4_NUM_OF_BOARDS | |
54 | } Exynos4BoardType; | |
55 | ||
56 | static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = { | |
57 | [EXYNOS4_BOARD_NURI] = 0xD33, | |
58 | [EXYNOS4_BOARD_SMDKC210] = 0xB16, | |
59 | }; | |
60 | ||
61 | static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS] = { | |
62 | [EXYNOS4_BOARD_NURI] = EXYNOS4210_SECOND_CPU_BOOTREG, | |
63 | [EXYNOS4_BOARD_SMDKC210] = EXYNOS4210_SECOND_CPU_BOOTREG, | |
64 | }; | |
65 | ||
66 | static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = { | |
67 | [EXYNOS4_BOARD_NURI] = 0x40000000, | |
68 | [EXYNOS4_BOARD_SMDKC210] = 0x40000000, | |
69 | }; | |
70 | ||
71 | static struct arm_boot_info exynos4_board_binfo = { | |
72 | .loader_start = EXYNOS4210_BASE_BOOT_ADDR, | |
73 | .smp_loader_start = EXYNOS4210_SMP_BOOT_ADDR, | |
74 | .nb_cpus = EXYNOS4210_NCPUS, | |
3f088e36 | 75 | .write_secondary_boot = exynos4210_write_secondary, |
0caa7113 EV |
76 | }; |
77 | ||
2c2c6496 EV |
78 | static void lan9215_init(uint32_t base, qemu_irq irq) |
79 | { | |
80 | DeviceState *dev; | |
81 | SysBusDevice *s; | |
82 | ||
83 | /* This should be a 9215 but the 9118 is close enough */ | |
a005d073 | 84 | if (nd_table[0].used) { |
2c2c6496 EV |
85 | qemu_check_nic_model(&nd_table[0], "lan9118"); |
86 | dev = qdev_create(NULL, "lan9118"); | |
87 | qdev_set_nic_properties(dev, &nd_table[0]); | |
88 | qdev_prop_set_uint32(dev, "mode_16bit", 1); | |
89 | qdev_init_nofail(dev); | |
1356b98d | 90 | s = SYS_BUS_DEVICE(dev); |
2c2c6496 EV |
91 | sysbus_mmio_map(s, 0, base); |
92 | sysbus_connect_irq(s, 0, irq); | |
93 | } | |
94 | } | |
95 | ||
3ef96221 | 96 | static Exynos4210State *exynos4_boards_init_common(MachineState *machine, |
7f0f7740 | 97 | Exynos4BoardType board_type) |
0caa7113 | 98 | { |
ca177760 EH |
99 | MachineClass *mc = MACHINE_GET_CLASS(machine); |
100 | ||
4bd2f93f | 101 | if (smp_cpus != EXYNOS4210_NCPUS && !qtest_enabled()) { |
0caa7113 EV |
102 | fprintf(stderr, "%s board supports only %d CPU cores. Ignoring smp_cpus" |
103 | " value.\n", | |
ca177760 | 104 | mc->name, EXYNOS4210_NCPUS); |
0caa7113 EV |
105 | } |
106 | ||
107 | exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type]; | |
108 | exynos4_board_binfo.board_id = exynos4_board_id[board_type]; | |
109 | exynos4_board_binfo.smp_bootreg_addr = | |
110 | exynos4_board_smp_bootreg_addr[board_type]; | |
3ef96221 MA |
111 | exynos4_board_binfo.kernel_filename = machine->kernel_filename; |
112 | exynos4_board_binfo.initrd_filename = machine->initrd_filename; | |
113 | exynos4_board_binfo.kernel_cmdline = machine->kernel_cmdline; | |
96eacf64 PM |
114 | exynos4_board_binfo.gic_cpu_if_addr = |
115 | EXYNOS4210_SMP_PRIVATE_BASE_ADDR + 0x100; | |
0caa7113 EV |
116 | |
117 | PRINT_DEBUG("\n ram_size: %luMiB [0x%08lx]\n" | |
118 | " kernel_filename: %s\n" | |
119 | " kernel_cmdline: %s\n" | |
120 | " initrd_filename: %s\n", | |
121 | exynos4_board_ram_size[board_type] / 1048576, | |
122 | exynos4_board_ram_size[board_type], | |
3ef96221 MA |
123 | machine->kernel_filename, |
124 | machine->kernel_cmdline, | |
125 | machine->initrd_filename); | |
0caa7113 EV |
126 | |
127 | return exynos4210_init(get_system_memory(), | |
128 | exynos4_board_ram_size[board_type]); | |
129 | } | |
130 | ||
3ef96221 | 131 | static void nuri_init(MachineState *machine) |
0caa7113 | 132 | { |
3ef96221 | 133 | exynos4_boards_init_common(machine, EXYNOS4_BOARD_NURI); |
0caa7113 | 134 | |
182735ef | 135 | arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo); |
0caa7113 EV |
136 | } |
137 | ||
3ef96221 | 138 | static void smdkc210_init(MachineState *machine) |
0caa7113 | 139 | { |
3ef96221 | 140 | Exynos4210State *s = exynos4_boards_init_common(machine, |
7f0f7740 | 141 | EXYNOS4_BOARD_SMDKC210); |
0caa7113 | 142 | |
2c2c6496 EV |
143 | lan9215_init(SMDK_LAN9118_BASE_ADDR, |
144 | qemu_irq_invert(s->irq_table[exynos4210_get_irq(37, 1)])); | |
182735ef | 145 | arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo); |
0caa7113 EV |
146 | } |
147 | ||
8a661aea | 148 | static void nuri_class_init(ObjectClass *oc, void *data) |
e264d29d | 149 | { |
8a661aea AF |
150 | MachineClass *mc = MACHINE_CLASS(oc); |
151 | ||
e264d29d EH |
152 | mc->desc = "Samsung NURI board (Exynos4210)"; |
153 | mc->init = nuri_init; | |
154 | mc->max_cpus = EXYNOS4210_NCPUS; | |
155 | } | |
97c6671c | 156 | |
8a661aea AF |
157 | static const TypeInfo nuri_type = { |
158 | .name = MACHINE_TYPE_NAME("nuri"), | |
159 | .parent = TYPE_MACHINE, | |
160 | .class_init = nuri_class_init, | |
161 | }; | |
0caa7113 | 162 | |
8a661aea | 163 | static void smdkc210_class_init(ObjectClass *oc, void *data) |
0caa7113 | 164 | { |
8a661aea AF |
165 | MachineClass *mc = MACHINE_CLASS(oc); |
166 | ||
e264d29d EH |
167 | mc->desc = "Samsung SMDKC210 board (Exynos4210)"; |
168 | mc->init = smdkc210_init; | |
169 | mc->max_cpus = EXYNOS4210_NCPUS; | |
0caa7113 EV |
170 | } |
171 | ||
8a661aea AF |
172 | static const TypeInfo smdkc210_type = { |
173 | .name = MACHINE_TYPE_NAME("smdkc210"), | |
174 | .parent = TYPE_MACHINE, | |
175 | .class_init = smdkc210_class_init, | |
176 | }; | |
177 | ||
178 | static void exynos4_machines_init(void) | |
179 | { | |
180 | type_register_static(&nuri_type); | |
181 | type_register_static(&smdkc210_type); | |
182 | } | |
183 | ||
184 | machine_init(exynos4_machines_init) |