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 work is licensed under the terms of the GNU GPL, version 2 or later.
9  * See the COPYING file in the top-level directory.
10  */
11 
12 #ifndef BCM2835_PERIPHERALS_H
13 #define BCM2835_PERIPHERALS_H
14 
15 #include "hw/sysbus.h"
16 #include "hw/char/pl011.h"
17 #include "hw/char/bcm2835_aux.h"
18 #include "hw/display/bcm2835_fb.h"
19 #include "hw/dma/bcm2835_dma.h"
20 #include "hw/or-irq.h"
21 #include "hw/intc/bcm2835_ic.h"
22 #include "hw/misc/bcm2835_property.h"
23 #include "hw/misc/bcm2835_rng.h"
24 #include "hw/misc/bcm2835_mbox.h"
25 #include "hw/misc/bcm2835_mphi.h"
26 #include "hw/misc/bcm2835_thermal.h"
27 #include "hw/misc/bcm2835_cprman.h"
28 #include "hw/misc/bcm2835_powermgt.h"
29 #include "hw/sd/sdhci.h"
30 #include "hw/sd/bcm2835_sdhost.h"
31 #include "hw/gpio/bcm2835_gpio.h"
32 #include "hw/timer/bcm2835_systmr.h"
33 #include "hw/usb/hcd-dwc2.h"
34 #include "hw/ssi/bcm2835_spi.h"
35 #include "hw/misc/unimp.h"
36 #include "qom/object.h"
37 
38 #define TYPE_BCM_SOC_PERIPHERALS_BASE "bcm-soc-peripherals-base"
39 OBJECT_DECLARE_TYPE(BCMSocPeripheralBaseState, BCMSocPeripheralBaseClass,
40                     BCM_SOC_PERIPHERALS_BASE)
41 #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals"
42 OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PeripheralState, BCM2835_PERIPHERALS)
43 
44 struct BCMSocPeripheralBaseState {
45     /*< private >*/
46     SysBusDevice parent_obj;
47     /*< public >*/
48 
49     MemoryRegion peri_mr, peri_mr_alias, gpu_bus_mr, mbox_mr;
50     MemoryRegion ram_alias[4];
51     qemu_irq irq, fiq;
52 
53     BCM2835SystemTimerState systmr;
54     BCM2835MphiState mphi;
55     UnimplementedDeviceState txp;
56     UnimplementedDeviceState armtmr;
57     BCM2835PowerMgtState powermgt;
58     BCM2835CprmanState cprman;
59     PL011State uart0;
60     BCM2835AuxState aux;
61     BCM2835FBState fb;
62     BCM2835DMAState dma;
63     OrIRQState orgated_dma_irq;
64     BCM2835ICState ic;
65     BCM2835PropertyState property;
66     BCM2835MboxState mboxes;
67     SDHCIState sdhci;
68     BCM2835SDHostState sdhost;
69     UnimplementedDeviceState i2s;
70     BCM2835SPIState spi[1];
71     UnimplementedDeviceState i2c[3];
72     UnimplementedDeviceState otp;
73     UnimplementedDeviceState dbus;
74     UnimplementedDeviceState ave0;
75     UnimplementedDeviceState v3d;
76     UnimplementedDeviceState bscsl;
77     UnimplementedDeviceState smi;
78     DWC2State dwc2;
79     UnimplementedDeviceState sdramc;
80 };
81 
82 struct BCMSocPeripheralBaseClass {
83     /*< private >*/
84     SysBusDeviceClass parent_class;
85     /*< public >*/
86     uint64_t peri_size; /* Peripheral range size */
87 };
88 
89 struct BCM2835PeripheralState {
90     /*< private >*/
91     BCMSocPeripheralBaseState parent_obj;
92     /*< public >*/
93     BCM2835RngState rng;
94     Bcm2835ThermalState thermal;
95     BCM2835GpioState gpio;
96 };
97 
98 void create_unimp(BCMSocPeripheralBaseState *ps,
99                   UnimplementedDeviceState *uds,
100                   const char *name, hwaddr ofs, hwaddr size);
101 void bcm_soc_peripherals_common_realize(DeviceState *dev, Error **errp);
102 
103 #endif /* BCM2835_PERIPHERALS_H */
104