From 55bed620a4487fbc5db3dfe8175dff9960b96e9f Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Mon, 21 Jul 2025 08:11:03 +0200 Subject: [PATCH] mb/dell: Use gpio_base2_value Instead of open coding what gpio_base2_value() does use the function to get the GPIO states of the ID pins. Change-Id: Ib09993998f7e8ee2a7e5295f49ed14058a095eb0 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/88505 Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- src/mainboard/dell/optiplex_9020/mainboard.c | 4 ++-- .../dell/snb_ivb_workstations/mainboard.c | 17 +++++++---------- .../dell/snb_ivb_workstations/sch5545_ec.c | 7 +++---- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/mainboard/dell/optiplex_9020/mainboard.c b/src/mainboard/dell/optiplex_9020/mainboard.c index 733efbb729..f4451aafd9 100644 --- a/src/mainboard/dell/optiplex_9020/mainboard.c +++ b/src/mainboard/dell/optiplex_9020/mainboard.c @@ -269,8 +269,8 @@ static uint8_t get_chassis_type(void) uint8_t gpio_chassis_type; // Read chassis type from GPIO - gpio_chassis_type = gpio_get(70) << 3 | gpio_get(38) << 2 | - gpio_get(17) << 1 | gpio_get(1); + const gpio_t chassis_id_pins[] = {1, 17, 38, 70}; + gpio_chassis_type = gpio_base2_value(chassis_id_pins, ARRAY_SIZE(chassis_id_pins)); printk(BIOS_DEBUG, "GPIO chassis type = %#x\n", gpio_chassis_type); diff --git a/src/mainboard/dell/snb_ivb_workstations/mainboard.c b/src/mainboard/dell/snb_ivb_workstations/mainboard.c index 2c09e683dd..9a46d152a4 100644 --- a/src/mainboard/dell/snb_ivb_workstations/mainboard.c +++ b/src/mainboard/dell/snb_ivb_workstations/mainboard.c @@ -56,10 +56,9 @@ static void mainboard_enable(struct device *dev) GMA_INT15_PANEL_FIT_DEFAULT, GMA_INT15_BOOT_DISPLAY_DEFAULT, 0); - pin_sts = gpio_get(GPIO_CHASSIS_ID0); - pin_sts |= gpio_get(GPIO_CHASSIS_ID1) << 1; - pin_sts |= gpio_get(GPIO_CHASSIS_ID2) << 2; - pin_sts |= gpio_get(GPIO_FRONT_PANEL_CHASSIS_DET_L) << 3; + const gpio_t chassis_id_pins[] = {GPIO_CHASSIS_ID0, GPIO_CHASSIS_ID1, + GPIO_CHASSIS_ID2, GPIO_FRONT_PANEL_CHASSIS_DET_L}; + pin_sts = gpio_base2_value(chassis_id_pins, ARRAY_SIZE(chassis_id_pins)); printk(BIOS_DEBUG, "Chassis type: "); switch (pin_sts) { @@ -88,15 +87,13 @@ static void mainboard_enable(struct device *dev) break; } - pin_sts = gpio_get(GPIO_BOARD_REV0); - pin_sts |= gpio_get(GPIO_BOARD_REV1) << 1; - pin_sts |= gpio_get(GPIO_BOARD_REV2) << 2; + const gpio_t board_id_pins[] = {GPIO_BOARD_REV0, GPIO_BOARD_REV1, GPIO_BOARD_REV2}; + pin_sts = gpio_base2_value(board_id_pins, ARRAY_SIZE(board_id_pins)); printk(BIOS_DEBUG, "Board revision: %d\n", pin_sts); - pin_sts = gpio_get(GPIO_SKU0); - pin_sts |= gpio_get(GPIO_SKU1) << 1; - pin_sts |= gpio_get(GPIO_SKU2) << 2; + const gpio_t sku_id_pins[] = {GPIO_SKU0, GPIO_SKU1, GPIO_SKU2}; + pin_sts = gpio_base2_value(sku_id_pins, ARRAY_SIZE(sku_id_pins)); printk(BIOS_DEBUG, "SKU ID is %d:", pin_sts); switch (pin_sts) { diff --git a/src/mainboard/dell/snb_ivb_workstations/sch5545_ec.c b/src/mainboard/dell/snb_ivb_workstations/sch5545_ec.c index a32c0fc937..2e9476d435 100644 --- a/src/mainboard/dell/snb_ivb_workstations/sch5545_ec.c +++ b/src/mainboard/dell/snb_ivb_workstations/sch5545_ec.c @@ -300,10 +300,9 @@ static uint8_t get_chassis_type(void) { uint8_t chassis_id; - chassis_id = gpio_get(GPIO_CHASSIS_ID0); - chassis_id |= gpio_get(GPIO_CHASSIS_ID1) << 1; - chassis_id |= gpio_get(GPIO_CHASSIS_ID2) << 2; - chassis_id |= gpio_get(GPIO_FRONT_PANEL_CHASSIS_DET_L) << 3; + const gpio_t chassis_id_pins[] = {GPIO_CHASSIS_ID0, GPIO_CHASSIS_ID1, + GPIO_CHASSIS_ID2, GPIO_FRONT_PANEL_CHASSIS_DET_L}; + chassis_id = gpio_base2_value(chassis_id_pins, ARRAY_SIZE(chassis_id_pins)); /* This mapping will determine which EC init sequence to use */ switch (chassis_id) {