xref: /openbmc/qemu/hw/arm/collie.c (revision a68694cd)
1 /*
2  * SA-1110-based Sharp Zaurus SL-5500 platform.
3  *
4  * Copyright (C) 2011 Dmitry Eremin-Solenikov
5  *
6  * This code is licensed under GNU GPL v2.
7  *
8  * Contributions after 2012-01-13 are licensed under the terms of the
9  * GNU GPL, version 2 or (at your option) any later version.
10  */
11 #include "qemu/osdep.h"
12 #include "qemu/units.h"
13 #include "qemu/cutils.h"
14 #include "hw/sysbus.h"
15 #include "hw/boards.h"
16 #include "strongarm.h"
17 #include "hw/arm/boot.h"
18 #include "hw/block/flash.h"
19 #include "exec/address-spaces.h"
20 #include "cpu.h"
21 #include "qom/object.h"
22 
23 struct CollieMachineState {
24     MachineState parent;
25 
26     StrongARMState *sa1110;
27 };
28 typedef struct CollieMachineState CollieMachineState;
29 
30 #define TYPE_COLLIE_MACHINE MACHINE_TYPE_NAME("collie")
31 DECLARE_INSTANCE_CHECKER(CollieMachineState, COLLIE_MACHINE,
32                          TYPE_COLLIE_MACHINE)
33 
34 static struct arm_boot_info collie_binfo = {
35     .loader_start = SA_SDCS0,
36     .ram_size = 0x20000000,
37 };
38 
39 static void collie_init(MachineState *machine)
40 {
41     DriveInfo *dinfo;
42     MachineClass *mc = MACHINE_GET_CLASS(machine);
43     CollieMachineState *cms = COLLIE_MACHINE(machine);
44 
45     if (machine->ram_size != mc->default_ram_size) {
46         char *sz = size_to_str(mc->default_ram_size);
47         error_report("Invalid RAM size, should be %s", sz);
48         g_free(sz);
49         exit(EXIT_FAILURE);
50     }
51 
52     cms->sa1110 = sa1110_init(machine->cpu_type);
53 
54     memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);
55 
56     dinfo = drive_get(IF_PFLASH, 0, 0);
57     pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000,
58                     dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
59                     64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
60 
61     dinfo = drive_get(IF_PFLASH, 0, 1);
62     pflash_cfi01_register(SA_CS1, "collie.fl2", 0x02000000,
63                     dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
64                     64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
65 
66     sysbus_create_simple("scoop", 0x40800000, NULL);
67 
68     collie_binfo.board_id = 0x208;
69     arm_load_kernel(cms->sa1110->cpu, machine, &collie_binfo);
70 }
71 
72 static void collie_machine_class_init(ObjectClass *oc, void *data)
73 {
74     MachineClass *mc = MACHINE_CLASS(oc);
75 
76     mc->desc = "Sharp SL-5500 (Collie) PDA (SA-1110)";
77     mc->init = collie_init;
78     mc->ignore_memory_transaction_failures = true;
79     mc->default_cpu_type = ARM_CPU_TYPE_NAME("sa1110");
80     mc->default_ram_size = 0x20000000;
81     mc->default_ram_id = "strongarm.sdram";
82 }
83 
84 static const TypeInfo collie_machine_typeinfo = {
85     .name = TYPE_COLLIE_MACHINE,
86     .parent = TYPE_MACHINE,
87     .class_init = collie_machine_class_init,
88     .instance_size = sizeof(CollieMachineState),
89 };
90 
91 static void collie_machine_register_types(void)
92 {
93     type_register_static(&collie_machine_typeinfo);
94 }
95 type_init(collie_machine_register_types);
96