From 51b1fc6e3929229e997fe16aa8f653bfcd112eeb Mon Sep 17 00:00:00 2001 From: Mathew King Date: Mon, 4 Nov 2019 12:29:41 -0700 Subject: mb/g/drallion: Consolidate 360 sensor board detection Create a single function to determine if the 360 sensor board is present on a device. BUG=b:143701965 TEST='emerge-drallion coreboot' Change-Id: I4100a9fdcfe6b7134fb238cb291cb5b0af4ec169 Signed-off-by: Mathew King Reviewed-on: https://review.coreboot.org/c/coreboot/+/36617 Tested-by: build bot (Jenkins) Reviewed-by: EricR Lai --- src/mainboard/google/drallion/variants/drallion/gpio.c | 9 ++------- .../google/drallion/variants/drallion/include/variant/variant.h | 9 +++++++++ src/mainboard/google/drallion/variants/drallion/sku.c | 6 ++---- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mainboard/google/drallion/variants/drallion/gpio.c b/src/mainboard/google/drallion/variants/drallion/gpio.c index 5657eeaae1..086dca0265 100644 --- a/src/mainboard/google/drallion/variants/drallion/gpio.c +++ b/src/mainboard/google/drallion/variants/drallion/gpio.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -274,17 +275,11 @@ const struct cros_gpio *variant_cros_gpios(size_t *num) return cros_gpios; } -static int is_ish_device_enabled(void) -{ - gpio_input(SENSOR_DET_360); - return gpio_get(SENSOR_DET_360) == 0; -} - void variant_mainboard_post_init_params(FSPM_UPD *mupd) { FSP_M_CONFIG *fsp_m_cfg = &mupd->FspmConfig; if (fsp_m_cfg->PchIshEnable) - fsp_m_cfg->PchIshEnable = is_ish_device_enabled(); + fsp_m_cfg->PchIshEnable = has_360_sensor_board(); /* * Disable memory channel by HW strap pin, HW default is enable diff --git a/src/mainboard/google/drallion/variants/drallion/include/variant/variant.h b/src/mainboard/google/drallion/variants/drallion/include/variant/variant.h index 508654faa5..bf08ec30dc 100644 --- a/src/mainboard/google/drallion/variants/drallion/include/variant/variant.h +++ b/src/mainboard/google/drallion/variants/drallion/include/variant/variant.h @@ -16,6 +16,9 @@ #ifndef VARIANT_H #define VARIANT_H +#include +#include + /* Need to update for Drallion with right SKU IDs*/ typedef struct { int id; @@ -36,4 +39,10 @@ const static sku_info skus[] = { /* Return memory SKU for the variant */ int variant_memory_sku(void); +/* Check if the device has a 360 sensor board present */ +static inline int has_360_sensor_board(void) +{ + return gpio_get(SENSOR_DET_360) == 0; +} + #endif diff --git a/src/mainboard/google/drallion/variants/drallion/sku.c b/src/mainboard/google/drallion/variants/drallion/sku.c index 72776299b0..736a14579a 100644 --- a/src/mainboard/google/drallion/variants/drallion/sku.c +++ b/src/mainboard/google/drallion/variants/drallion/sku.c @@ -14,15 +14,13 @@ */ #include -#include #include +#include #include -#include -#include static const uint32_t get_sku_index(void) { - return (gpio_get(SENSOR_DET_360) | (wilco_ec_signed_fw() << 1)); + return ((!has_360_sensor_board()) | (wilco_ec_signed_fw() << 1)); } uint32_t sku_id(void) -- cgit v1.2.3