2 * sifive System-on-Chip general purpose input/output register definition
4 * Copyright 2019 AdaCore
6 * Base on nrf51_gpio.c:
8 * Copyright 2018 Steffen Görtz <contrib@steffen-goertz.de>
10 * This code is licensed under the GPL version 2 or later. See
11 * the COPYING file in the top-level directory.
16 #include "hw/sysbus.h"
17 #define TYPE_SIFIVE_GPIO "sifive_soc.gpio"
18 #define SIFIVE_GPIO(obj) OBJECT_CHECK(SIFIVEGPIOState, (obj), TYPE_SIFIVE_GPIO)
20 #define SIFIVE_GPIO_PINS 32
22 #define SIFIVE_GPIO_SIZE 0x100
24 #define SIFIVE_GPIO_REG_VALUE 0x000
25 #define SIFIVE_GPIO_REG_INPUT_EN 0x004
26 #define SIFIVE_GPIO_REG_OUTPUT_EN 0x008
27 #define SIFIVE_GPIO_REG_PORT 0x00C
28 #define SIFIVE_GPIO_REG_PUE 0x010
29 #define SIFIVE_GPIO_REG_DS 0x014
30 #define SIFIVE_GPIO_REG_RISE_IE 0x018
31 #define SIFIVE_GPIO_REG_RISE_IP 0x01C
32 #define SIFIVE_GPIO_REG_FALL_IE 0x020
33 #define SIFIVE_GPIO_REG_FALL_IP 0x024
34 #define SIFIVE_GPIO_REG_HIGH_IE 0x028
35 #define SIFIVE_GPIO_REG_HIGH_IP 0x02C
36 #define SIFIVE_GPIO_REG_LOW_IE 0x030
37 #define SIFIVE_GPIO_REG_LOW_IP 0x034
38 #define SIFIVE_GPIO_REG_IOF_EN 0x038
39 #define SIFIVE_GPIO_REG_IOF_SEL 0x03C
40 #define SIFIVE_GPIO_REG_OUT_XOR 0x040
42 typedef struct SIFIVEGPIOState
{
43 SysBusDevice parent_obj
;
47 qemu_irq irq
[SIFIVE_GPIO_PINS
];
48 qemu_irq output
[SIFIVE_GPIO_PINS
];
50 uint32_t value
; /* Actual value of the pin */
53 uint32_t port
; /* Pin value requested by the user */