Add Aspeed GPIO controller model
cover Add Aspeed GPIO controller model
Rebased on Peter's target-arm.next branch.
v2: Addressed Andrew's feedback, added debounce regs, renamed get/set to read/write to minimise confusion with a 'set' of registers.
Rashmica Gupta (2):
hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500
aspeed: add a GPIO controller to the SoC
hw/arm/aspeed_soc.c | 17 + hw/gpio/Makefile.objs | 1 + hw/gpio/aspeed_gpio.c | 891 ++++++++++++++++++++++++++++++++++ include/hw/arm/aspeed_soc.h | 3 + include/hw/gpio/aspeed_gpio.h | 92 ++++ 5 files changed, 1004 insertions(+) create mode 100644 hw/gpio/aspeed_gpio.c create mode 100644 include/hw/gpio/aspeed_gpio.h
Signature · 1 line
2.20.1
PATCH 1/2 hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500
GPIO pins are arranged in groups of 8 pins labeled A,B,..,Y,Z,AA,AB,AC. (Note that the ast2400 controller only goes up to group AB). A set has four groups (except set AC which only has one) and is referred to by the groups it is composed of (eg ABCD,EFGH,...,YZAAAB). Each set is accessed and controlled by a bank of 14 registers.
These registers operate on a per pin level where each bit in the register corresponds to a pin, except for the command source registers. The command source registers operate on a per group level where bits 24, 16, 8 and 0 correspond to each group in the set.
eg. registers for set ABCD:
|D7...D0|C7...C0|B7...B0|A7...A0| <- GPIOs |31...24|23...16|15....8|7.....0| <- bit position
Note that there are a couple of groups that only have 4 pins.
There are two ways that this model deviates from the behaviour of the actual controller:
(1) The only control source driving the GPIO pins in the model is the ARM model (as there currently aren't models for the LPC or Coprocessor).
(2) None of the registers in the model are reset tolerant (needs integration with the watchdog).
--- hw/gpio/Makefile.objs | 1 + hw/gpio/aspeed_gpio.c | 891 ++++++++++++++++++++++++++++++++++ include/hw/gpio/aspeed_gpio.h | 92 ++++ 3 files changed, 984 insertions(+) create mode 100644 hw/gpio/aspeed_gpio.c create mode 100644 include/hw/gpio/aspeed_gpio.h
hw/gpio/Makefile.objs +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_OMAP) += omap_gpio.o obj-$(CONFIG_IMX) += imx_gpio.o obj-$(CONFIG_RASPI) += bcm2835_gpio.o obj-$(CONFIG_NRF51_SOC) += nrf51_gpio.o +obj-$(CONFIG_ASPEED_SOC) += aspeed_gpio.o
hw/gpio/aspeed_gpio.c new file +891 -0
891 lines not on this page · raw message
include/hw/gpio/aspeed_gpio.h new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 2/2 aspeed: add a GPIO controller to the SoC
In reply to Rashmica Gupta--- hw/arm/aspeed_soc.c | 17 +++++++++++++++++ include/hw/arm/aspeed_soc.h | 3 +++ 2 files changed, 20 insertions(+)
hw/arm/aspeed_soc.c +17 -0
@@ -124,6 +124,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .spis_num = 1, .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, + .gpio_typename = "aspeed.gpio-ast2400", .wdts_num = 2, .irqmap = aspeed_soc_ast2400_irqmap, .memmap = aspeed_soc_ast2400_memmap,
@@ -136,6 +137,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .spis_num = 1, .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, + .gpio_typename = "aspeed.gpio-ast2400", .wdts_num = 2, .irqmap = aspeed_soc_ast2400_irqmap, .memmap = aspeed_soc_ast2400_memmap,
@@ -148,6 +150,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .spis_num = 1, .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, + .gpio_typename = "aspeed.gpio-ast2400", .wdts_num = 2, .irqmap = aspeed_soc_ast2400_irqmap, .memmap = aspeed_soc_ast2400_memmap,
@@ -160,6 +163,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .spis_num = 2, .fmc_typename = "aspeed.smc.ast2500-fmc", .spi_typename = aspeed_soc_ast2500_typenames, + .gpio_typename = "aspeed.gpio-ast2500", .wdts_num = 3, .irqmap = aspeed_soc_ast2500_irqmap, .memmap = aspeed_soc_ast2500_memmap,
@@ -246,6 +250,9 @@ static void aspeed_soc_init(Object *obj)sysbus_init_child_obj (obj,"xdma" ,OBJECT (&s->xdma),sizeof (s->xdma),TYPE_ASPEED_XDMA ); + +sysbus_init_child_obj (obj,"gpio" ,OBJECT (&s->gpio),sizeof (s->gpio), + sc->info->gpio_typename); }static void aspeed_soc_realize (DeviceState *dev,Error **errp)
@@ -425,6 +432,16 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) sc->info->memmap[ASPEED_XDMA]);sysbus_connect_irq (SYS_BUS_DEVICE (&s->xdma),0 ,aspeed_soc_get_irq (s,ASPEED_XDMA )); + +/* GPIO */ +object_property_set_bool (OBJECT (&s->gpio), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->gpio),0 , sc->info->memmap[ASPEED_GPIO ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->gpio),0 , +aspeed_soc_get_irq (s,ASPEED_GPIO )); }static Property aspeed_soc_properties[] = {DEFINE_PROP_UINT32 ("num-cpus" , AspeedSoCState, num_cpus,0 ),
include/hw/arm/aspeed_soc.h +3 -0
@@ -22,6 +22,7 @@#include "hw/ssi/aspeed_smc.h" #include "hw/watchdog/wdt_aspeed.h" #include "hw/net/ftgmac100.h" +#include "hw/gpio/aspeed_gpio.h" #define ASPEED_SPIS_NUM 2#define ASPEED_WDTS_NUM 3
@@ -47,6 +48,7 @@ typedef struct AspeedSoCState {AspeedSDMCState sdmc;AspeedWDTState wdt[ASPEED_WDTS_NUM ];FTGMAC100State ftgmac100[ASPEED_MACS_NUM ]; +AspeedGPIOState gpio; } AspeedSoCState;#define TYPE_ASPEED_SOC "aspeed-soc"
@@ -60,6 +62,7 @@ typedef struct AspeedSoCInfo {int spis_num;const char *fmc_typename;const char **spi_typename; +const char *gpio_typename;int wdts_num;const int *irqmap;const hwaddr *memmap;
Signature · 1 line
2.20.1
Doh! Forgot the v2 tag!
Quoted 20 lines · Rashmica Gupta
Rebased on Peter's target-arm.next branch.
v2: Addressed Andrew's feedback, added debounce regs, renamed get/set to
read/write to minimise confusion with a 'set' of registers.Rashmica Gupta (2):
hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500
aspeed: add a GPIO controller to the SoChw/arm/aspeed_soc.c | 17 + hw/gpio/Makefile.objs | 1 + hw/gpio/aspeed_gpio.c | 891 ++++++++++++++++++++++++++++++++++ include/hw/arm/aspeed_soc.h | 3 + include/hw/gpio/aspeed_gpio.h | 92 ++++ 5 files changed, 1004 insertions(+) create mode 100644 hw/gpio/aspeed_gpio.c create mode 100644 include/hw/gpio/aspeed_gpio.h