From f5658cf1a56d48683dc63b5998523e2e21169d10 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Tue, 3 Aug 2021 03:15:27 +0200 Subject: [PATCH] soc/amd/common: move GPIO ACPIMMIO access functions to gpio_banks block Since the raw GPIO MMIO register access is now only used inside the gpio_banks block, the gpio_read32 and gpio_write32 functions can be moved to that block to reduce the visibility and enforce the usage of the functions provided by the gpio_banks block. The iomux_read8 and iomux_write8 functions can't be easily moved to the gpio_banks block, since it's also used in the pre-SOC AMD chipsets that use the ACPIMMIO access functions directly. Signed-off-by: Felix Held Change-Id: Ia0d6dea72c6bebbbe6ce545bedfc74f91e0042c4 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56781 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth Reviewed-by: Jason Glenesk --- src/soc/amd/common/block/gpio_banks/gpio.c | 16 ++++++++++++++++ .../common/block/include/amdblocks/acpimmio.h | 17 ----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/soc/amd/common/block/gpio_banks/gpio.c b/src/soc/amd/common/block/gpio_banks/gpio.c index 018c61430e..fbeb38f717 100644 --- a/src/soc/amd/common/block/gpio_banks/gpio.c +++ b/src/soc/amd/common/block/gpio_banks/gpio.c @@ -15,6 +15,22 @@ #include #include +/* MMIO access of new-style GPIO bank configuration registers */ +static inline void *gpio_ctrl_ptr(uint8_t gpio_num) +{ + return acpimmio_gpio0 + gpio_num * sizeof(uint32_t); +} + +static inline uint32_t gpio_read32(uint8_t gpio_num) +{ + return read32(gpio_ctrl_ptr(gpio_num)); +} + +static inline void gpio_write32(uint8_t gpio_num, uint32_t value) +{ + write32(gpio_ctrl_ptr(gpio_num), value); +} + static int get_gpio_gevent(gpio_t gpio, const struct soc_amd_event *table, size_t items) { diff --git a/src/soc/amd/common/block/include/amdblocks/acpimmio.h b/src/soc/amd/common/block/include/amdblocks/acpimmio.h index 9c007e7668..bf84a2564e 100644 --- a/src/soc/amd/common/block/include/amdblocks/acpimmio.h +++ b/src/soc/amd/common/block/include/amdblocks/acpimmio.h @@ -325,23 +325,6 @@ static inline void gpio_100_write8(uint8_t reg, uint8_t value) write8(acpimmio_gpio_100 + reg, value); } -/* New GPIO banks configuration registers */ - -static inline void *gpio_ctrl_ptr(uint8_t gpio_num) -{ - return acpimmio_gpio0 + gpio_num * sizeof(uint32_t); -} - -static inline uint32_t gpio_read32(uint8_t gpio_num) -{ - return read32(gpio_ctrl_ptr(gpio_num)); -} - -static inline void gpio_write32(uint8_t gpio_num, uint32_t value) -{ - write32(gpio_ctrl_ptr(gpio_num), value); -} - static inline uint8_t xhci_pm_read8(uint8_t reg) { return read8(acpimmio_xhci_pm + reg);