bcm2836.c (3d260cf3c6375c641106c71dd6cf9b638b73847b) | bcm2836.c (926dcdf073a2f9cf8f8d4d71b35110544dae2b40) |
---|---|
1/* 2 * Raspberry Pi emulation (c) 2012 Gregory Estrade 3 * Upstreaming code cleanup [including bcm2835_*] (c) 2013 Jan Petrous 4 * 5 * Rasperry Pi 2 emulation and refactoring Copyright (c) 2015, Microsoft 6 * Written by Andrew Baumann 7 * 8 * This code is licensed under the GNU GPLv2 and later. --- 11 unchanged lines hidden (view full) --- 20/* Peripheral base address seen by the CPU */ 21#define BCM2836_PERI_BASE 0x3F000000 22 23/* "QA7" (Pi2) interrupt controller and mailboxes etc. */ 24#define BCM2836_CONTROL_BASE 0x40000000 25 26static void bcm2836_init(Object *obj) 27{ | 1/* 2 * Raspberry Pi emulation (c) 2012 Gregory Estrade 3 * Upstreaming code cleanup [including bcm2835_*] (c) 2013 Jan Petrous 4 * 5 * Rasperry Pi 2 emulation and refactoring Copyright (c) 2015, Microsoft 6 * Written by Andrew Baumann 7 * 8 * This code is licensed under the GNU GPLv2 and later. --- 11 unchanged lines hidden (view full) --- 20/* Peripheral base address seen by the CPU */ 21#define BCM2836_PERI_BASE 0x3F000000 22 23/* "QA7" (Pi2) interrupt controller and mailboxes etc. */ 24#define BCM2836_CONTROL_BASE 0x40000000 25 26static void bcm2836_init(Object *obj) 27{ |
28 BCM2836State *s = BCM2836(obj); | 28 BCM283XState *s = BCM283X(obj); |
29 30 object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL); 31 object_property_add_child(obj, "control", OBJECT(&s->control), NULL); 32 qdev_set_parent_bus(DEVICE(&s->control), sysbus_get_default()); 33 34 object_initialize(&s->peripherals, sizeof(s->peripherals), 35 TYPE_BCM2835_PERIPHERALS); 36 object_property_add_child(obj, "peripherals", OBJECT(&s->peripherals), 37 &error_abort); 38 object_property_add_alias(obj, "board-rev", OBJECT(&s->peripherals), 39 "board-rev", &error_abort); 40 object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals), 41 "vcram-size", &error_abort); 42 qdev_set_parent_bus(DEVICE(&s->peripherals), sysbus_get_default()); 43} 44 45static void bcm2836_realize(DeviceState *dev, Error **errp) 46{ | 29 30 object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL); 31 object_property_add_child(obj, "control", OBJECT(&s->control), NULL); 32 qdev_set_parent_bus(DEVICE(&s->control), sysbus_get_default()); 33 34 object_initialize(&s->peripherals, sizeof(s->peripherals), 35 TYPE_BCM2835_PERIPHERALS); 36 object_property_add_child(obj, "peripherals", OBJECT(&s->peripherals), 37 &error_abort); 38 object_property_add_alias(obj, "board-rev", OBJECT(&s->peripherals), 39 "board-rev", &error_abort); 40 object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals), 41 "vcram-size", &error_abort); 42 qdev_set_parent_bus(DEVICE(&s->peripherals), sysbus_get_default()); 43} 44 45static void bcm2836_realize(DeviceState *dev, Error **errp) 46{ |
47 BCM2836State *s = BCM2836(dev); | 47 BCM283XState *s = BCM283X(dev); |
48 Object *obj; 49 Error *err = NULL; 50 int n; 51 52 /* common peripherals from bcm2835 */ 53 54 obj = OBJECT(dev); | 48 Object *obj; 49 Error *err = NULL; 50 int n; 51 52 /* common peripherals from bcm2835 */ 53 54 obj = OBJECT(dev); |
55 for (n = 0; n < BCM2836_NCPUS; n++) { | 55 for (n = 0; n < BCM283X_NCPUS; n++) { |
56 object_initialize(&s->cpus[n], sizeof(s->cpus[n]), 57 s->cpu_type); 58 object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), 59 &error_abort); 60 } 61 62 obj = object_property_get_link(OBJECT(dev), "ram", &err); 63 if (obj == NULL) { --- 33 unchanged lines hidden (view full) --- 97 98 sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, BCM2836_CONTROL_BASE); 99 100 sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0, 101 qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-irq", 0)); 102 sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1, 103 qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); 104 | 56 object_initialize(&s->cpus[n], sizeof(s->cpus[n]), 57 s->cpu_type); 58 object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), 59 &error_abort); 60 } 61 62 obj = object_property_get_link(OBJECT(dev), "ram", &err); 63 if (obj == NULL) { --- 33 unchanged lines hidden (view full) --- 97 98 sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, BCM2836_CONTROL_BASE); 99 100 sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0, 101 qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-irq", 0)); 102 sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1, 103 qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); 104 |
105 for (n = 0; n < BCM2836_NCPUS; n++) { | 105 for (n = 0; n < BCM283X_NCPUS; n++) { |
106 /* Mirror bcm2836, which has clusterid set to 0xf 107 * TODO: this should be converted to a property of ARM_CPU 108 */ 109 s->cpus[n].mp_affinity = 0xF00 | n; 110 111 /* set periphbase/CBAR value for CPU-local registers */ 112 object_property_set_int(OBJECT(&s->cpus[n]), 113 BCM2836_PERI_BASE + MCORE_OFFSET, --- 31 unchanged lines hidden (view full) --- 145 qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_HYP, 146 qdev_get_gpio_in_named(DEVICE(&s->control), "cnthpirq", n)); 147 qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_SEC, 148 qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq", n)); 149 } 150} 151 152static Property bcm2836_props[] = { | 106 /* Mirror bcm2836, which has clusterid set to 0xf 107 * TODO: this should be converted to a property of ARM_CPU 108 */ 109 s->cpus[n].mp_affinity = 0xF00 | n; 110 111 /* set periphbase/CBAR value for CPU-local registers */ 112 object_property_set_int(OBJECT(&s->cpus[n]), 113 BCM2836_PERI_BASE + MCORE_OFFSET, --- 31 unchanged lines hidden (view full) --- 145 qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_HYP, 146 qdev_get_gpio_in_named(DEVICE(&s->control), "cnthpirq", n)); 147 qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_SEC, 148 qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq", n)); 149 } 150} 151 152static Property bcm2836_props[] = { |
153 DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type), 154 DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS), | 153 DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type), 154 DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, 155 BCM283X_NCPUS), |
155 DEFINE_PROP_END_OF_LIST() 156}; 157 158static void bcm2836_class_init(ObjectClass *oc, void *data) 159{ 160 DeviceClass *dc = DEVICE_CLASS(oc); 161 162 dc->props = bcm2836_props; 163 dc->realize = bcm2836_realize; 164} 165 166static const TypeInfo bcm2836_type_info = { | 156 DEFINE_PROP_END_OF_LIST() 157}; 158 159static void bcm2836_class_init(ObjectClass *oc, void *data) 160{ 161 DeviceClass *dc = DEVICE_CLASS(oc); 162 163 dc->props = bcm2836_props; 164 dc->realize = bcm2836_realize; 165} 166 167static const TypeInfo bcm2836_type_info = { |
167 .name = TYPE_BCM2836, | 168 .name = TYPE_BCM283X, |
168 .parent = TYPE_DEVICE, | 169 .parent = TYPE_DEVICE, |
169 .instance_size = sizeof(BCM2836State), | 170 .instance_size = sizeof(BCM283XState), |
170 .instance_init = bcm2836_init, 171 .class_init = bcm2836_class_init, 172}; 173 174static void bcm2836_register_types(void) 175{ 176 type_register_static(&bcm2836_type_info); 177} 178 179type_init(bcm2836_register_types) | 171 .instance_init = bcm2836_init, 172 .class_init = bcm2836_class_init, 173}; 174 175static void bcm2836_register_types(void) 176{ 177 type_register_static(&bcm2836_type_info); 178} 179 180type_init(bcm2836_register_types) |