3 * System emulation for the Samsung SMDK2410
5 * Copyright 2006, 2008 Daniel Silverstone and Vincent Sanders
7 * This file is under the terms of the GNU General Public
11 #include "qemu/osdep.h"
13 #include "hw/arm/arm.h"
14 #include "hw/boards.h"
15 #include "hw/devices.h"
16 #include "hw/loader.h" /* load_image_targphys */
17 #include "hw/s3c2410x.h"
18 #include "hw/i2c/smbus.h"
19 #include "exec/address-spaces.h" /* get_system_memory */
20 #include "sysemu/blockdev.h" /* drive_get */
21 #include "sysemu/sysemu.h"
24 #define BIOS_FILENAME "smdk2410.bin"
29 unsigned char cpld_ctrl2
;
37 #define SMDK2410_NOR_BASE CPU_S3C2410X_CS0
38 #define SMDK2410_NOR_SIZE 16 * MiB / BIT
39 #define SMDK2410_BOARD_ID 193
41 static struct arm_boot_info smdk2410_binfo
= {
42 .board_id
= SMDK2410_BOARD_ID
,
43 .ram_size
= 0x10000000, /* 256MB */
46 static void smdk2410_init(MachineState
*machine
)
52 /* ensure memory is limited to 256MB */
53 if (machine
->ram_size
> (256 * MiB
)) {
54 machine
->ram_size
= 256 * MiB
;
56 ram_size
= machine
->ram_size
;
58 /* allocate storage for board state */
59 stcb
= g_new0(SMDK2410State
, 1);
61 /* initialise CPU and memory */
62 stcb
->soc
= s3c2410x_init(ram_size
);
64 /* Register the NOR flash ROM */
65 memory_region_init_ram(&stcb
->flash
, NULL
,
66 "smdk2410.flash", SMDK2410_NOR_SIZE
);
67 memory_region_set_readonly(&stcb
->flash
, true);
68 memory_region_add_subregion(get_system_memory(),
69 SMDK2410_NOR_BASE
, &stcb
->flash
);
71 /* initialise board informations */
72 smdk2410_binfo
.ram_size
= ram_size
;
73 smdk2410_binfo
.kernel_filename
= machine
->kernel_filename
;
74 smdk2410_binfo
.kernel_cmdline
= machine
->kernel_cmdline
;
75 smdk2410_binfo
.initrd_filename
= machine
->initrd_filename
;
76 smdk2410_binfo
.nb_cpus
= 1;
77 smdk2410_binfo
.loader_start
= SMDK2410_NOR_BASE
;
79 if (machine
->kernel_filename
== NULL
) {
80 /* No kernel given so try and acquire a bootloader */
81 char *filename
= qemu_find_file(QEMU_FILE_TYPE_BIOS
, BIOS_FILENAME
);
83 ret
= load_image_targphys(filename
, smdk2410_binfo
.loader_start
,
88 "qemu: warning, could not load SMDK2410 BIOS from %s\n",
93 "qemu: info, loaded SMDK2410 BIOS %d bytes from %s\n",
99 "qemu: warning, could not load SMDK2410 BIOS from %s\n",
104 smdk2410_binfo
.loader_start
= CPU_S3C2410X_DRAM
;
105 arm_load_kernel(stcb
->soc
->cpu
, &smdk2410_binfo
);
108 /* Setup initial (reset) program counter */
109 stcb
->soc
->cpu
->env
.regs
[15] = smdk2410_binfo
.loader_start
;
111 /* Attach some NAND devices */
112 stcb
->nand
[0] = NULL
;
113 stcb
->nand
[1] = NULL
;
114 dinfo
= drive_get(IF_MTD
, 0, 0);
116 stcb
->nand
[2] = NULL
;
118 stcb
->nand
[2] = nand_init(NULL
, 0xEC, 0x79); /* 128MiB small-page */
122 static void smdk2410_machine_init(MachineClass
*mc
)
124 mc
->desc
= "Samsung SMDK2410 (S3C2410A, ARM920T)";
125 mc
->init
= smdk2410_init
;
129 DEFINE_MACHINE("smdk2410", smdk2410_machine_init
)