soc/intel/common/gpio: Fix cosmetic issue with `gpio_lock_pads`

This patch replaces hardcoded `4` (next offset Tx state) with
`sizeof(uint32_t)` for calculating 'Tx state offset'.

Also, add checks to detect the specific GPIO lock action between
`LOCK_CONFIG` or 'LOCK_TX'.

Signed-off-by: Subrata Banik <subratabanik@google.com>
Change-Id: Iff712b16808e0bc99c575bb2426a4f84b89fdb73
Reviewed-on: https://review.coreboot.org/c/coreboot/+/60994
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Maulik V Vaghela <maulik.v.vaghela@intel.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: EricR Lai <ericr_lai@compal.corp-partner.google.com>
This commit is contained in:
Subrata Banik 2022-01-11 12:20:24 +05:30
parent 878d3723fb
commit 7788513667
1 changed files with 4 additions and 3 deletions

View File

@ -520,13 +520,14 @@ int gpio_lock_pads(const struct gpio_lock_config *pad_list, const size_t count)
__func__, pad);
continue;
}
/* PADCFGLOCK and PADCFGLOCKTX registers for each community are contiguous */
offset += gpio_group_index_scaled(comm, rel_pad, 2 * sizeof(uint32_t));
data = gpio_bitmask_within_group(comm, rel_pad);
msg.pid = comm->port;
msg.offset = offset;
if (action & GPIO_LOCK_CONFIG) {
if ((action & GPIO_LOCK_CONFIG) == GPIO_LOCK_CONFIG) {
if (CONFIG(DEBUG_GPIO))
printk(BIOS_INFO, "%s: Locking pad %d configuration\n",
__func__, pad);
@ -537,11 +538,11 @@ int gpio_lock_pads(const struct gpio_lock_config *pad_list, const size_t count)
}
}
if (action & GPIO_LOCK_TX) {
if ((action & GPIO_LOCK_TX) == GPIO_LOCK_TX) {
if (CONFIG(DEBUG_GPIO))
printk(BIOS_INFO, "%s: Locking pad %d TX state\n",
__func__, pad);
msg.offset += 4;
msg.offset += sizeof(uint32_t);
status = pcr_execute_sideband_msg(&msg, &data, &response);
if ((err = sideband_msg_err(status, response)) != 0) {
err_response = err;