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 24 #include "sysemu.h" 25 #include "sysbus.h" 26 #include "arm-misc.h" 27 #include "exec-memory.h" 28 #include "exynos4210.h" 29 #include "boards.h" 30 31 #undef DEBUG 32 33 //#define DEBUG 34 35 #ifdef DEBUG 36 #undef PRINT_DEBUG 37 #define PRINT_DEBUG(fmt, args...) \ 38 do { \ 39 fprintf(stderr, " [%s:%d] "fmt, __func__, __LINE__, ##args); \ 40 } while (0) 41 #else 42 #define PRINT_DEBUG(fmt, args...) do {} while (0) 43 #endif 44 45 typedef enum Exynos4BoardType { 46 EXYNOS4_BOARD_NURI, 47 EXYNOS4_BOARD_SMDKC210, 48 EXYNOS4_NUM_OF_BOARDS 49 } Exynos4BoardType; 50 51 static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = { 52 [EXYNOS4_BOARD_NURI] = 0xD33, 53 [EXYNOS4_BOARD_SMDKC210] = 0xB16, 54 }; 55 56 static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS] = { 57 [EXYNOS4_BOARD_NURI] = EXYNOS4210_SECOND_CPU_BOOTREG, 58 [EXYNOS4_BOARD_SMDKC210] = EXYNOS4210_SECOND_CPU_BOOTREG, 59 }; 60 61 static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = { 62 [EXYNOS4_BOARD_NURI] = 0x40000000, 63 [EXYNOS4_BOARD_SMDKC210] = 0x40000000, 64 }; 65 66 static struct arm_boot_info exynos4_board_binfo = { 67 .loader_start = EXYNOS4210_BASE_BOOT_ADDR, 68 .smp_loader_start = EXYNOS4210_SMP_BOOT_ADDR, 69 .nb_cpus = EXYNOS4210_NCPUS, 70 }; 71 72 static QEMUMachine exynos4_machines[EXYNOS4_NUM_OF_BOARDS]; 73 74 static Exynos4210State *exynos4_boards_init_common( 75 const char *kernel_filename, 76 const char *kernel_cmdline, 77 const char *initrd_filename, 78 Exynos4BoardType board_type) 79 { 80 if (smp_cpus != EXYNOS4210_NCPUS) { 81 fprintf(stderr, "%s board supports only %d CPU cores. Ignoring smp_cpus" 82 " value.\n", 83 exynos4_machines[board_type].name, 84 exynos4_machines[board_type].max_cpus); 85 } 86 87 exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type]; 88 exynos4_board_binfo.board_id = exynos4_board_id[board_type]; 89 exynos4_board_binfo.smp_bootreg_addr = 90 exynos4_board_smp_bootreg_addr[board_type]; 91 exynos4_board_binfo.kernel_filename = kernel_filename; 92 exynos4_board_binfo.initrd_filename = initrd_filename; 93 exynos4_board_binfo.kernel_cmdline = kernel_cmdline; 94 exynos4_board_binfo.smp_priv_base = EXYNOS4210_SMP_PRIVATE_BASE_ADDR; 95 96 PRINT_DEBUG("\n ram_size: %luMiB [0x%08lx]\n" 97 " kernel_filename: %s\n" 98 " kernel_cmdline: %s\n" 99 " initrd_filename: %s\n", 100 exynos4_board_ram_size[board_type] / 1048576, 101 exynos4_board_ram_size[board_type], 102 kernel_filename, 103 kernel_cmdline, 104 initrd_filename); 105 106 return exynos4210_init(get_system_memory(), 107 exynos4_board_ram_size[board_type]); 108 } 109 110 static void nuri_init(ram_addr_t ram_size, 111 const char *boot_device, 112 const char *kernel_filename, const char *kernel_cmdline, 113 const char *initrd_filename, const char *cpu_model) 114 { 115 exynos4_boards_init_common(kernel_filename, kernel_cmdline, 116 initrd_filename, EXYNOS4_BOARD_NURI); 117 118 arm_load_kernel(first_cpu, &exynos4_board_binfo); 119 } 120 121 static void smdkc210_init(ram_addr_t ram_size, 122 const char *boot_device, 123 const char *kernel_filename, const char *kernel_cmdline, 124 const char *initrd_filename, const char *cpu_model) 125 { 126 exynos4_boards_init_common(kernel_filename, kernel_cmdline, 127 initrd_filename, EXYNOS4_BOARD_SMDKC210); 128 129 arm_load_kernel(first_cpu, &exynos4_board_binfo); 130 } 131 132 static QEMUMachine exynos4_machines[EXYNOS4_NUM_OF_BOARDS] = { 133 [EXYNOS4_BOARD_NURI] = { 134 .name = "nuri", 135 .desc = "Samsung NURI board (Exynos4210)", 136 .init = nuri_init, 137 .max_cpus = EXYNOS4210_NCPUS, 138 }, 139 [EXYNOS4_BOARD_SMDKC210] = { 140 .name = "smdkc210", 141 .desc = "Samsung SMDKC210 board (Exynos4210)", 142 .init = smdkc210_init, 143 .max_cpus = EXYNOS4210_NCPUS, 144 }, 145 }; 146 147 static void exynos4_machine_init(void) 148 { 149 qemu_register_machine(&exynos4_machines[EXYNOS4_BOARD_NURI]); 150 qemu_register_machine(&exynos4_machines[EXYNOS4_BOARD_SMDKC210]); 151 } 152 153 machine_init(exynos4_machine_init); 154