soc/amd/common/gpio: Add new helper macro PAD_CFG_STRUCT_FLAGS

`flags` field of soc_amd_gpio structure is set only for SCI and SMI
configurations. This change adds a new helper macro
PAD_CFG_STRUCT_FLAGS that allows setting of all soc_amd_gpio members
including `flags` field. This can be used directly by PAD_SCI and
PAD_SMI. For all other pad configurations, PAD_CFG_STRUCT macro uses
PAD_CFG_STRUCT_FLAGS with flags set to 0. This allows dropping of
redundant parameter 0 for flags for all other pad configurations.

BUG=b:159944426

Change-Id: I835b62f5502375ffc4215548b51338a67546d699
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/42876
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Furquan Shaikh 2020-06-27 16:30:18 -07:00
parent 10185866f0
commit e9fe3661b3
1 changed files with 17 additions and 17 deletions

View File

@ -249,14 +249,17 @@ static inline bool is_gpio_event_active_low(uint32_t flags)
* debounce_time the debounce time * debounce_time the debounce time
*/ */
#define PAD_CFG_STRUCT(__pin, __function, __control, __flags) \ #define PAD_CFG_STRUCT_FLAGS(__pin, __function, __control, __flags) \
{ \ { \
.gpio = __pin, \ .gpio = __pin, \
.function = __function, \ .function = __function, \
.control = __control, \ .control = __control, \
.flags = __flags, \ .flags = __flags, \
} }
#define PAD_CFG_STRUCT(__pin, __function, __control) \
PAD_CFG_STRUCT_FLAGS(__pin, __function, __control, 0)
#define PAD_PULL(__pull) GPIO_PULL_ ## __pull #define PAD_PULL(__pull) GPIO_PULL_ ## __pull
#define PAD_OUTPUT(__dir) GPIO_OUTPUT_OUT_ ## __dir #define PAD_OUTPUT(__dir) GPIO_OUTPUT_OUT_ ## __dir
#define PAD_TRIGGER(__trig) GPIO_TRIGGER_ ## __trig #define PAD_TRIGGER(__trig) GPIO_TRIGGER_ ## __trig
@ -267,45 +270,42 @@ static inline bool is_gpio_event_active_low(uint32_t flags)
/* Native function pad configuration */ /* Native function pad configuration */
#define PAD_NF(pin, func, pull) \ #define PAD_NF(pin, func, pull) \
PAD_CFG_STRUCT(pin, pin ## _IOMUX_ ## func, PAD_PULL(pull), 0) PAD_CFG_STRUCT(pin, pin ## _IOMUX_ ## func, PAD_PULL(pull))
/* General purpose input pad configuration */ /* General purpose input pad configuration */
#define PAD_GPI(pin, pull) \ #define PAD_GPI(pin, pull) \
PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, PAD_PULL(pull), 0) PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, PAD_PULL(pull))
/* General purpose output pad configuration */ /* General purpose output pad configuration */
#define PAD_GPO(pin, direction) \ #define PAD_GPO(pin, direction) \
PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, PAD_OUTPUT(direction), 0) PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, PAD_OUTPUT(direction))
/* Legacy interrupt pad configuration */ /* Legacy interrupt pad configuration */
#define PAD_INT(pin, pull, trigger, action) \ #define PAD_INT(pin, pull, trigger, action) \
PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \ PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \
PAD_PULL(pull) | PAD_TRIGGER(trigger) | PAD_INT_ENABLE(action), \ PAD_PULL(pull) | PAD_TRIGGER(trigger) | PAD_INT_ENABLE(action))
0)
/* SCI pad configuration */ /* SCI pad configuration */
#define PAD_SCI(pin, pull, trigger) \ #define PAD_SCI(pin, pull, trigger) \
PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \ PAD_CFG_STRUCT_FLAGS(pin, pin ## _IOMUX_GPIOxx, \
PAD_PULL(pull) | PAD_TRIGGER(LEVEL_HIGH), \ PAD_PULL(pull) | PAD_TRIGGER(LEVEL_HIGH), \
PAD_FLAG_EVENT_TRIGGER(trigger) | GPIO_FLAG_SCI) PAD_FLAG_EVENT_TRIGGER(trigger) | GPIO_FLAG_SCI)
/* SMI pad configuration */ /* SMI pad configuration */
#define PAD_SMI(pin, pull, trigger) \ #define PAD_SMI(pin, pull, trigger) \
PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \ PAD_CFG_STRUCT_FLAGS(pin, pin ## _IOMUX_GPIOxx, \
PAD_PULL(pull) | PAD_TRIGGER(LEVEL_HIGH), \ PAD_PULL(pull) | PAD_TRIGGER(LEVEL_HIGH), \
PAD_FLAG_EVENT_TRIGGER(trigger) | GPIO_FLAG_SMI) PAD_FLAG_EVENT_TRIGGER(trigger) | GPIO_FLAG_SMI)
/* WAKE pad configuration */ /* WAKE pad configuration */
#define PAD_WAKE(pin, pull, trigger, type) \ #define PAD_WAKE(pin, pull, trigger, type) \
PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \ PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \
PAD_PULL(pull) | PAD_TRIGGER(trigger) | PAD_WAKE_ENABLE(type), \ PAD_PULL(pull) | PAD_TRIGGER(trigger) | PAD_WAKE_ENABLE(type))
0)
/* pin debounce configuration */ /* pin debounce configuration */
#define PAD_DEBOUNCE(pin, pull, type, time) \ #define PAD_DEBOUNCE(pin, pull, type, time) \
PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \ PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \
PAD_PULL(pull) | PAD_DEBOUNCE_CONFIG(type) | PAD_DEBOUNCE_CONFIG(time), \ PAD_PULL(pull) | PAD_DEBOUNCE_CONFIG(type) | PAD_DEBOUNCE_CONFIG(time))
0)
typedef uint32_t gpio_t; typedef uint32_t gpio_t;