Jon Murphy has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/74591 )
Change subject: soc/amd/common: Update GPIO macros ......................................................................
soc/amd/common: Update GPIO macros
Update GPIO macros to accommodate multiple levels of indirection with GPIO naming. This will allow individual programs to #define net/signal names to GPIO_NN names for use in their own development. Enabling projects to rename their own GPIOs to nets will hopefully make the code more readable and obvious, and prevent translation mistakes in reading GPIO numbers from schematics.
BUG=b:278969100, b:278968729 TEST=builds
Change-Id: I918d659eecf2076ed9089218177874ed2c9023b3 Signed-off-by: Jon Murphy jpmurphy@google.com --- M src/soc/amd/common/block/include/amdblocks/gpio_defs.h 1 file changed, 39 insertions(+), 12 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/91/74591/1
diff --git a/src/soc/amd/common/block/include/amdblocks/gpio_defs.h b/src/soc/amd/common/block/include/amdblocks/gpio_defs.h index c5aa3f1..819461f 100644 --- a/src/soc/amd/common/block/include/amdblocks/gpio_defs.h +++ b/src/soc/amd/common/block/include/amdblocks/gpio_defs.h @@ -205,64 +205,71 @@ #define PAD_WAKE_ENABLE(__wake) GPIO_WAKE_ ## __wake #define PAD_DEBOUNCE_CONFIG(__deb) GPIO_DEB_ ## __deb
+#define CREATE_FUNC(pin, func) CREATE_FUNC_INNER(pin, func) +#define CREATE_FUNC_INNER(pin, func) GPIO_ ## pin ## _IOMUX_ ## func + /* Native function pad configuration with PAD_PULL */ #define PAD_NF(pin, func, pull) \ - PAD_CFG_STRUCT(pin, pin ## _IOMUX_ ## func, PAD_PULL(pull)) + PAD_CFG_STRUCT(pin, CREATE_FUNC(pin, func), PAD_PULL(pull))
/* Native function pad configuration with PAD_OUTPUT */ #define PAD_NFO(pin, func, direction) \ - PAD_CFG_STRUCT(pin, pin ## _IOMUX_ ## func, PAD_OUTPUT(direction)) + PAD_CFG_STRUCT(pin, CREATE_FUNC(pin, func), PAD_OUTPUT(direction)) + +/* Native function pad configuration with PAD_OUTPUT from named GPIO */ +#define PAD_NFO_NAMED(pin, func, direction) \ + PAD_CFG_STRUCT(pin, CREATE_FUNC(pin, func), PAD_OUTPUT(direction))
/* General purpose input pad configuration */ #define PAD_GPI(pin, pull) \ - PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, PAD_PULL(pull)) + PAD_CFG_STRUCT(pin, CREATE_FUNC(pin, GPIOxx), PAD_PULL(pull))
/* General purpose output pad configuration */ #define PAD_GPO(pin, direction) \ - PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, PAD_OUTPUT(direction)) + PAD_CFG_STRUCT(pin, CREATE_FUNC(pin, GPIOxx), PAD_OUTPUT(direction))
/* Legacy interrupt pad configuration */ #define PAD_INT(pin, pull, trigger, action) \ - PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \ + PAD_CFG_STRUCT(pin, CREATE_FUNC(pin, GPIOxx), \ PAD_PULL(pull) | PAD_TRIGGER(trigger) | PAD_INT_ENABLE(action))
/* SCI pad configuration */ #define PAD_SCI(pin, pull, trigger) \ - PAD_CFG_STRUCT_FLAGS(pin, pin ## _IOMUX_GPIOxx, \ + PAD_CFG_STRUCT_FLAGS(pin, CREATE_FUNC(pin, GPIOxx), \ PAD_PULL(pull) | PAD_TRIGGER(LEVEL_HIGH), \ PAD_FLAG_EVENT_TRIGGER(trigger) | GPIO_FLAG_SCI)
/* SMI pad configuration */ #define PAD_SMI(pin, pull, trigger) \ - PAD_CFG_STRUCT_FLAGS(pin, pin ## _IOMUX_GPIOxx, \ + PAD_CFG_STRUCT_FLAGS(pin, CREATE_FUNC(pin, GPIOxx), \ PAD_PULL(pull) | PAD_TRIGGER(LEVEL_HIGH), \ PAD_FLAG_EVENT_TRIGGER(trigger) | GPIO_FLAG_SMI)
/* Native function + SCI pad configuration */ #define PAD_NF_SCI(pin, func, pull, trigger) \ - PAD_CFG_STRUCT_FLAGS(pin, pin ## _IOMUX_ ## func, \ + PAD_CFG_STRUCT_FLAGS(pin, CREATE_FUNC(pin, func), \ PAD_PULL(pull), \ PAD_FLAG_EVENT_TRIGGER(trigger) | GPIO_FLAG_SCI)
/* WAKE pad configuration */ #define PAD_WAKE(pin, pull, trigger, type) \ - PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \ + PAD_CFG_STRUCT(pin, CREATE_FUNC(pin, GPIOxx), \ PAD_PULL(pull) | PAD_TRIGGER(trigger) | PAD_WAKE_ENABLE(type))
/* pin debounce configuration */ #define PAD_DEBOUNCE(pin, pull, type, time) \ - PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \ + PAD_CFG_STRUCT(pin, CREATE_FUNC(pin, GPIOxx), \ PAD_PULL(pull) | PAD_DEBOUNCE_CONFIG(type) | PAD_DEBOUNCE_CONFIG(time))
/* Wake + debounce configuration */ #define PAD_WAKE_DEBOUNCE(pin, pull, trigger, waketype, debtype, time) \ - PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, \ + PAD_CFG_STRUCT(pin, CREATE_FUNC(pin, GPIOxx), \ PAD_PULL(pull) | PAD_TRIGGER(trigger) | PAD_WAKE_ENABLE(waketype) | \ PAD_DEBOUNCE_CONFIG(debtype) | PAD_DEBOUNCE_CONFIG(time))
/* No-connect pad - configured as input with PULL_DOWN */ #define PAD_NC(pin) \ - PAD_CFG_STRUCT(pin, pin ## _IOMUX_GPIOxx, PAD_PULL(PULL_DOWN)) + PAD_CFG_STRUCT(pin, CREATE_FUNC(pin, GPIOxx), PAD_PULL(PULL_DOWN))
#define GEVENT_0 0 #define GEVENT_1 1