xref: /openbmc/qemu/include/hw/gpio/bcm2838_gpio.h (revision b54a9a56)
1 /*
2  * Raspberry Pi (BCM2838) GPIO Controller
3  * This implementation is based on bcm2835_gpio (hw/gpio/bcm2835_gpio.c)
4  *
5  * Copyright (c) 2022 Auriga LLC
6  *
7  * Authors:
8  *  Lotosh, Aleksey <aleksey.lotosh@auriga.com>
9  *
10  * This work is licensed under the terms of the GNU GPL, version 2 or later.
11  * See the COPYING file in the top-level directory.
12  */
13 
14 #ifndef BCM2838_GPIO_H
15 #define BCM2838_GPIO_H
16 
17 #include "hw/sd/sd.h"
18 #include "hw/sysbus.h"
19 #include "qom/object.h"
20 
21 #define TYPE_BCM2838_GPIO "bcm2838-gpio"
22 OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GpioState, BCM2838_GPIO)
23 
24 #define BCM2838_GPIO_REGS_SIZE 0x1000
25 #define BCM2838_GPIO_NUM       58
26 #define GPIO_PUP_PDN_CNTRL_NUM 4
27 
28 struct BCM2838GpioState {
29     SysBusDevice parent_obj;
30 
31     MemoryRegion iomem;
32 
33     /* SDBus selector */
34     SDBus sdbus;
35     SDBus *sdbus_sdhci;
36     SDBus *sdbus_sdhost;
37 
38     uint8_t fsel[BCM2838_GPIO_NUM];
39     uint32_t lev0, lev1;
40     uint8_t sd_fsel;
41     qemu_irq out[BCM2838_GPIO_NUM];
42     uint32_t pup_cntrl_reg[GPIO_PUP_PDN_CNTRL_NUM];
43 };
44 
45 #endif
46