Nick Vaccaro has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/74841 )
Change subject: soc/intel/common/gpio: Add open-drain GPIO macros ......................................................................
soc/intel/common/gpio: Add open-drain GPIO macros
Add PAD_CFG_OD_GPI, PAD_CFG_OD_GPI_LOCK, PAD_CFG_OD_GPO, and PAD_CFG_OD_GPO_LOCK macros to support open-drain signals.
BUG=b:278732600 BRANCH=firmware-brya-14505.B TEST=None
Change-Id: I8ca9915c7574e741c20af2e8dc91f6a07f7c0d26 Signed-off-by: Nick Vaccaro nvaccaro@google.com --- M src/include/gpio.h M src/soc/intel/common/block/gpio/gpio.c M src/soc/intel/common/block/include/intelblocks/gpio_defs.h 3 files changed, 80 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/74841/1
diff --git a/src/include/gpio.h b/src/include/gpio.h index 9fe854b..c42b5b5 100644 --- a/src/include/gpio.h +++ b/src/include/gpio.h @@ -14,6 +14,8 @@
/* The following functions must be implemented by SoC/board code. */ int gpio_get(gpio_t gpio); +void gpio_od_set(gpio_t gpio, int value); +void gpio_set_HiZ(gpio_t gpio_num); int gpio_tx_get(gpio_t gpio); void gpio_set(gpio_t gpio, int value); void gpio_input_pulldown(gpio_t gpio); diff --git a/src/soc/intel/common/block/gpio/gpio.c b/src/soc/intel/common/block/gpio/gpio.c index facc1fe..ff3dfb5 100644 --- a/src/soc/intel/common/block/gpio/gpio.c +++ b/src/soc/intel/common/block/gpio/gpio.c @@ -713,6 +713,29 @@ return gpio_lock_pads(&pads, 1); }
+/* gpio_od_set(): use for open-drain output gpios */ +void gpio_od_set(gpio_t gpio_num, int value) +{ + const struct pad_community *comm = gpio_get_community(gpio_num); + uint16_t config_offset; + + config_offset = pad_config_offset(comm, gpio_num); + pcr_rmw32(comm->port, config_offset, + ~(PAD_CFG0_TX_STATE & PAD_CFG0_TX_DISABLE), + (!!value & PAD_CFG0_TX_STATE)); +} + +/* gpio_od_set(): use for set an open-drain output gpio to hi-z */ +void gpio_set_HiZ(gpio_t gpio_num) +{ + const struct pad_community *comm = gpio_get_community(gpio_num); + uint16_t config_offset; + + config_offset = pad_config_offset(comm, gpio_num); + pcr_rmw32(comm->port, config_offset, + ~PAD_CFG0_TX_DISABLE, PAD_CFG0_TX_DISABLE); +} + void gpio_set(gpio_t gpio_num, int value) { const struct pad_community *comm = gpio_get_community(gpio_num); diff --git a/src/soc/intel/common/block/include/intelblocks/gpio_defs.h b/src/soc/intel/common/block/include/intelblocks/gpio_defs.h index 654d6f2..83391b3 100644 --- a/src/soc/intel/common/block/include/intelblocks/gpio_defs.h +++ b/src/soc/intel/common/block/include/intelblocks/gpio_defs.h @@ -265,6 +265,44 @@ PAD_RESET(rst) | PAD_FUNC(func) | PAD_CFG0_NAFVWE_ENABLE,\ PAD_PULL(pull) | PAD_IOSSTATE(TxLASTRxE))
+/* + * General purpose input for open drain + * enable RX, no pullup/down + * during standby: Hi-Z, Rx driving 1 back to its controller internally + */ +#define PAD_CFG_OD_GPI(pad, rst) \ + _PAD_CFG_STRUCT(pad, \ + PAD_FUNC(GPIO) | PAD_RESET(rst) | \ + PAD_TRIG(OFF) | PAD_BUF(TX_DISABLE), \ + PAD_PULL(NONE) | PAD_IOSSTATE(HIZCRx1)) + +/* + * General purpose input with lock for open drain + * enable RX, no pullup/down + * during standby: Hi-Z, Rx driving 1 back to its controller internally + */ +#define PAD_CFG_OD_GPI_LOCK(pad, lock_action) \ + _PAD_CFG_STRUCT_LOCK(pad, \ + PAD_FUNC(GPIO) | PAD_RESET(PWROK) | \ + PAD_TRIG(OFF) | PAD_BUF(TX_DISABLE), \ + PAD_PULL(NONE) | PAD_IOSSTATE(HIZCRx1), \ + PAD_LOCK(lock_action)) + +/* General purpose output for open drain, no pullup/down. */ +#define PAD_CFG_OD_GPO(pad, rst) \ + _PAD_CFG_STRUCT(pad, \ + PAD_FUNC(GPIO) | PAD_RESET(rst) | \ + PAD_TRIG(OFF) | PAD_BUF(TX_RX_DISABLE), \ + PAD_PULL(NONE) | PAD_IOSSTATE(HIZCRx1)) + +/* General purpose output with lock for open drain, no pullup/down. */ +#define PAD_CFG_OD_GPO_LOCK(pad, lock_action) \ + _PAD_CFG_STRUCT_LOCK(pad, \ + PAD_FUNC(GPIO) | PAD_RESET(PWROK) | \ + PAD_TRIG(OFF) | PAD_BUF(TX_RX_DISABLE), \ + PAD_PULL(NONE) | PAD_IOSSTATE(HIZCRx1), \ + PAD_LOCK(lock_action)) + /* General purpose output, no pullup/down. */ #define PAD_CFG_GPO(pad, val, rst) \ _PAD_CFG_STRUCT(pad, \