soc/intel/common/gpio: Add function to read GPIO TX value

This function reads out the current value set to output for a GPIO pin.

Ex: GPP_E0 is set to output
int e0_val;
e0_val = gpio_tx_get(GPP_E0);

Signed-off-by: Cliff Huang <cliff.huang@intel.com>
Change-Id: Ib02b9ab50d378eb163d91aed1576428b49cec2cf
Reviewed-on: https://review.coreboot.org/c/coreboot/+/72127
Reviewed-by: Anil Kumar K <anil.kumar.k@intel.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Bora Guvendik <bora.guvendik@intel.com>
This commit is contained in:
Cliff Huang 2023-01-19 21:38:56 -08:00 committed by Felix Held
parent 92c920b730
commit 546e093543
2 changed files with 13 additions and 0 deletions

View File

@ -14,6 +14,7 @@ _Static_assert(sizeof(gpio_t) <= sizeof(u32), "gpio_t doesn't fit in lb_gpio");
/* The following functions must be implemented by SoC/board code. */
int gpio_get(gpio_t gpio);
int gpio_tx_get(gpio_t gpio);
void gpio_set(gpio_t gpio, int value);
void gpio_input_pulldown(gpio_t gpio);
void gpio_input_pullup(gpio_t gpio);

View File

@ -523,6 +523,18 @@ int gpio_get(gpio_t gpio_num)
return !!(reg & PAD_CFG0_RX_STATE);
}
int gpio_tx_get(gpio_t gpio_num)
{
const struct pad_community *comm = gpio_get_community(gpio_num);
uint16_t config_offset;
uint32_t reg;
config_offset = pad_config_offset(comm, gpio_num);
reg = pcr_read32(comm->port, config_offset);
return !!(reg & PAD_CFG0_TX_STATE);
}
static void
gpio_pad_config_lock_using_sbi(const struct gpio_lock_config *pad_info,
uint8_t pid, uint16_t offset, const uint32_t bit_mask)