Allwinner A10 GPIO support
Subsystems (2)
v3 cover Allwinner A10 GPIO support
This patch series introduces GPIO support for Allwinner A10 and Cubieboard.
The support is focused on input/output and interrupt functionality. The qtest suite is also updated with tests for implemented functionality.
---
Changes in v3:
- replaced forward declarations of gpio_is_input and int_ctl_cfg with
definitions
- updated use of extract32 for int_cfg_n to use full stride INT_CFG_IRQ_STRIDE
- replaced custom bit manipulation with deposit32
- updated output GPIO line handling to have same behavior when lines are
configured as input as when they are assigned to special function
- removed update of outbound gpio lines in the reset function
- improved test organization with common add_test function, as suggested
- removed leftover comments
- minor style fixes
- Link to v2: https://lore.kernel.org/qemu-devel/[email protected]
Changes in v2:
- allwinner-gpio-test: Added test for interrupt triggered on both rising
and falling edge
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]
---
Strahinja Jankovic (3):
hw/gpio: Allwinner A10 GPIO emulation
hw/arm: Add GPIO to Allwinner A10 model
tests/qtest: Allwinner GPIO tests
MAINTAINERS | 3 + docs/system/arm/cubieboard.rst | 1 + hw/arm/Kconfig | 1 + hw/arm/allwinner-a10.c | 8 + hw/gpio/Kconfig | 3 + hw/gpio/allwinner-gpio.c | 449 ++++++++++++++++++++++++++++ hw/gpio/meson.build | 1 + hw/gpio/trace-events | 6 + include/hw/arm/allwinner-a10.h | 2 + include/hw/gpio/allwinner-gpio-regs.h | 227 +++++++++++++++ include/hw/gpio/allwinner-gpio.h | 41 +++ tests/qtest/allwinner-gpio-test.c | 535 ++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 3 +- 13 files changed, 1279 insertions(+), 1 deletion(-)
---
base-commit: d43c2d5f89db70359a7b3a7e2ad7098fcc0165ef
change-id: 20260818-allwinner-gpio-6ea84117df94
Best regards,
Signature · 1 line
Strahinja Jankovic <[email protected]>
PATCH v3 1/3 hw/gpio: Allwinner A10 GPIO emulation
This patch implements Allwinner A10 GPIO peripheral emulation.
The emulation focuses on input/output and interrupt functionality, whereas the drive and pull up/down functionality is not emulated.
--- MAINTAINERS | 2 + hw/gpio/Kconfig | 3 + hw/gpio/allwinner-gpio.c | 449 ++++++++++++++++++++++++++++++++++ hw/gpio/meson.build | 1 + hw/gpio/trace-events | 6 + include/hw/gpio/allwinner-gpio-regs.h | 227 +++++++++++++++++ include/hw/gpio/allwinner-gpio.h | 41 ++++ 7 files changed, 729 insertions(+)
MAINTAINERS +2 -0
@@ -746,6 +746,8 @@ F: include/hw/*/allwinner* F: hw/arm/cubieboard.c F: docs/system/arm/cubieboard.rst F: hw/misc/axp2xx.c +F: hw/gpio/allwinner-gpio.c +F: include/hw/gpio/allwinner-gpio* F: tests/functional/arm/test_cubieboard.py Allwinner-h3
hw/gpio/Kconfig +3 -0
@@ -33,3 +33,6 @@ config ZAURUS_SCOOP config CADENCE_GPIO bool + +config ALLWINNER_GPIO + bool
hw/gpio/allwinner-gpio.c new file +449 -0
449 lines not on this page · raw message
hw/gpio/meson.build +1 -0
@@ -20,3 +20,4 @@ system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_sgpio.c')) system_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c')) system_ss.add(when: 'CONFIG_PCF8574', if_true: files('pcf8574.c')) system_ss.add(when: 'CONFIG_CADENCE_GPIO', if_true: files('cadence_gpio.c')) +system_ss.add(when: 'CONFIG_ALLWINNER_GPIO', if_true: files('allwinner-gpio.c'))
hw/gpio/trace-events +6 -0
@@ -51,3 +51,9 @@ stm32l4x5_gpio_pins(char *gpio, uint16_t disconnected, uint16_t high) "GPIO%s di cdns_gpio_read(const char *path, uint64_t offset, uint32_t value) "%s:reg[0x%04" PRIx64 "] -> 0x%" PRIx32 cdns_gpio_write(const char *path, uint64_t offset, uint64_t value) "%s:reg[0x%04" PRIx64 "] <- 0x%04" PRIx64 cdns_gpio_set(const char *path, int line, int level) "%s:[%d] <- %d" + +# allwinner_gpio.c +allwinner_gpio_set(const char *port, int line, int level) "[%s:%d] <- %d" +allwinner_gpio_read(const char *reg, uint32_t value) "[%s] -> 0x%" PRIx32 +allwinner_gpio_write(const char *reg, uint32_t value) "[%s] <- 0x%" PRIx32 +allwinner_gpio_out_pin(const char *reg, uint32_t pin, uint32_t value) "[%s.%d] <- 0x%" PRIx32
include/hw/gpio/allwinner-gpio-regs.h new file +227 -0
227 lines not on this page · raw message
include/hw/gpio/allwinner-gpio.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.55.0
Re: [PATCH v3 1/3] hw/gpio: Allwinner A10 GPIO emulation
Quoted 8 lines · Strahinja Jankovic
This patch implements Allwinner A10 GPIO peripheral emulation.
The emulation focuses on input/output and interrupt functionality, whereas the drive and pull up/down functionality is not emulated.
Signed-off-by Strahinja Jankovic <[email protected]>
hw/gpio/allwinner-gpio.c line 262
Quoted 6 lines
hw/gpio/allwinner-gpio.c new file +6
-0+static inline void allwinner_gpio_update_all_output_lines (AWGPIOState *s) +{ +for (int port =0 ; port <AW_GPIO_PORTS_NUM ; port++) { +port_update_output_lines (s, port); + } +}
This doesn't compile on clang because this function has no callers:
../../hw/gpio/allwinner-gpio.c:257:20: error: unused function 'allwinner_gpio_update_all_output_lines' [-Werror,-Wunused-function]
257 | static inline voidallwinner_gpio_update_all_output_lines(AWGPIOState *s)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Should it be being called somewhere, or is it just a leftover from an earlier revision of the series?
thanks
-- PMM
Re: [PATCH v3 1/3] hw/gpio: Allwinner A10 GPIO emulation
Quoted 24 lines · Peter Maydell
Quoted 9 lines · Strahinja Jankovic
This patch implements Allwinner A10 GPIO peripheral emulation.
The emulation focuses on input/output and interrupt functionality, whereas the drive and pull up/down functionality is not emulated.
Signed-off-by Strahinja Jankovic <[email protected]>+static inline void allwinner_gpio_update_all_output_lines(AWGPIOState
*s)
hw/gpio/allwinner-gpio.c line 262
Quoted 5 lines
hw/gpio/allwinner-gpio.c new file +5
-0+{ +for (int port =0 ; port <AW_GPIO_PORTS_NUM ; port++) { +port_update_output_lines (s, port); + } +}This doesn't compile on clang because this function has no callers:
../../hw/gpio/allwinner-gpio.c:257:20: error: unused function 'allwinner_gpio_update_all_output_lines' [-Werror,-Wunused-function]
257 | static inline voidallwinner_gpio_update_all_output_lines(AWGPIOState *s)
Quoted 6 lines
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1 error generated.
Should it be being called somewhere, or is it just a leftover from an earlier revision of the series?
Correct, it was used only in the reset function, but I removed the call after your comment that
the reset function should not update outbound gpio lines.
I will remove this function in the next revision.
Best regards,
Strahinja
Quoted 4 lines
thanks
-- PMM
PATCH v3 2/3 hw/arm: Add GPIO to Allwinner A10 model
In reply to Strahinja JankovicThe Allwinner A10 GPIO is added to the Allwinner A10 description, so it is available when Cubieboard is emulated.
Update the documentation for Cubieboard to indicate GPIO availability.
--- docs/system/arm/cubieboard.rst | 1 + hw/arm/Kconfig | 1 + hw/arm/allwinner-a10.c | 8 ++++++++ include/hw/arm/allwinner-a10.h | 2 ++ 4 files changed, 12 insertions(+)
docs/system/arm/cubieboard.rst +1 -0
@@ -12,6 +12,7 @@ Emulated devices: - RTC - EMAC - SDHCI +- GPIO - USB controller - SATA controller - TWI (I2C) controller
hw/arm/Kconfig +1 -0
@@ -295,6 +295,7 @@ config ALLWINNER_A10 select ALLWINNER_EMAC select ALLWINNER_I2C select ALLWINNER_A10_SPI + select ALLWINNER_GPIO select AXP2XX_PMU select SERIAL_MM select UNIMP
hw/arm/allwinner-a10.c +8 -0
@@ -41,6 +41,7 @@#define AW_A10_EHCI_BASE 0x01c14000#define AW_A10_OHCI_BASE 0x01c14400#define AW_A10_SATA_BASE 0x01c18000 +#define AW_A10_GPIO_BASE 0x01c20800#define AW_A10_WDT_BASE 0x01c20c90#define AW_A10_RTC_BASE 0x01c20d00#define AW_A10_I2C0_BASE 0x01c2ac00
@@ -83,6 +84,8 @@ static void aw_a10_init(Object *obj)object_initialize_child (obj,"spi0" , &s->spi0,TYPE_AW_A10_SPI ); +object_initialize_child (obj,"gpio" , &s->gpio,TYPE_AW_GPIO ); +for (size_t i =0 ; i <AW_A10_NUM_USB ; i++) {object_initialize_child (obj,"ehci[*]" , &s->ehci[i],TYPE_PLATFORM_EHCI );
@@ -203,6 +206,11 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->spi0),0 ,AW_A10_SPI0_BASE );sysbus_connect_irq (SYS_BUS_DEVICE (&s->spi0),0 ,qdev_get_gpio_in (dev,10 )); +/* GPIO */ +sysbus_realize (SYS_BUS_DEVICE (&s->gpio), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->gpio),0 ,AW_A10_GPIO_BASE ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->gpio),0 ,qdev_get_gpio_in (dev,28 )); +/* WDT */ sysbus_realize (SYS_BUS_DEVICE (&s->wdt), &error_fatal);sysbus_mmio_map_overlap (SYS_BUS_DEVICE (&s->wdt),0 ,AW_A10_WDT_BASE ,1 );
include/hw/arm/allwinner-a10.h +2 -0
@@ -13,6 +13,7 @@#include "hw/misc/allwinner-a10-dramc.h" #include "hw/i2c/allwinner-i2c.h" #include "hw/ssi/allwinner-a10-spi.h" +#include "hw/gpio/allwinner-gpio.h" #include "hw/watchdog/allwinner-wdt.h" #include "system/block-backend.h"
@@ -42,6 +43,7 @@ struct AwA10State {AwSdHostState mmc0;AWI2CState i2c0;AWA10SPIState spi0; +AWGPIOState gpio;AwRtcState rtc;AwWdtState wdt;MemoryRegion sram_a;
Signature · 1 line
2.55.0
PATCH v3 3/3 tests/qtest: Allwinner GPIO tests
In reply to Strahinja JankovicAdd Allwinner GPIO set of qtests to validate functionality. Tests cover input and output port setting, as well as interrupt functionality.
--- MAINTAINERS | 1 + tests/qtest/allwinner-gpio-test.c | 535 ++++++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 3 +- 3 files changed, 538 insertions(+), 1 deletion(-)
MAINTAINERS +1 -0
@@ -749,6 +749,7 @@ F: hw/misc/axp2xx.c F: hw/gpio/allwinner-gpio.c F: include/hw/gpio/allwinner-gpio* F: tests/functional/arm/test_cubieboard.py +F: tests/qtest/allwinner-gpio-test.c Allwinner-h3 M: Niek Linnenbank <[email protected]>
tests/qtest/allwinner-gpio-test.c new file +535 -0
535 lines not on this page · raw message
tests/qtest/meson.build +2 -1
@@ -268,7 +268,8 @@ qtests_arm = \ (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') and config_all_devices.has_key('CONFIG_DM163')? ['dm163-test'] : []) + \ ['arm-cpu-features', - 'boot-serial-test'] + 'boot-serial-test'] + \ + (config_all_devices.has_key('CONFIG_ALLWINNER_A10')? ['allwinner-gpio-test'] : []) # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional qtests_aarch64 = \
Signature · 1 line
2.55.0
Re: [PATCH v3 3/3] tests/qtest: Allwinner GPIO tests
Quoted 6 lines · Strahinja Jankovic
Add Allwinner GPIO set of qtests to validate functionality. Tests cover input and output port setting, as well as interrupt functionality.
Signed-off-by Strahinja Jankovic <[email protected]>
thanks
-- PMM