From c6f5b05cf383bd66c1f9e168394c7c0d86080a60 Mon Sep 17 00:00:00 2001 From: Anil Kumar Date: Thu, 26 Mar 2020 16:35:23 -0700 Subject: mb/google/deltaur: Return SKU ID info For Deltaur and Deltan variants return proper SKU ID based on EC firmware type and sensor detect GPIO value BUG=b:152544516 TEST=make build successful for deltan Change-Id: I20a497739e5062400b093648c3a634203dec6105 Signed-off-by: Anil Kumar Reviewed-on: https://review.coreboot.org/c/coreboot/+/39868 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: EricR Lai --- .../google/deltaur/variants/baseboard/Makefile.inc | 1 + .../google/deltaur/variants/baseboard/gpio.c | 5 +++++ .../baseboard/include/baseboard/variants.h | 9 ++++++++ .../google/deltaur/variants/baseboard/sku.c | 26 ++++++++++++++++++++++ .../variants/deltan/include/variant/variant.h | 25 +++++++++++++++++++++ .../google/deltaur/variants/deltaur/gpio.c | 8 +++++++ .../variants/deltaur/include/variant/variant.h | 26 ++++++++++++++++++++++ 7 files changed, 100 insertions(+) create mode 100644 src/mainboard/google/deltaur/variants/baseboard/sku.c create mode 100644 src/mainboard/google/deltaur/variants/deltan/include/variant/variant.h create mode 100644 src/mainboard/google/deltaur/variants/deltaur/include/variant/variant.h diff --git a/src/mainboard/google/deltaur/variants/baseboard/Makefile.inc b/src/mainboard/google/deltaur/variants/baseboard/Makefile.inc index 937cb4628f..277b75ab27 100644 --- a/src/mainboard/google/deltaur/variants/baseboard/Makefile.inc +++ b/src/mainboard/google/deltaur/variants/baseboard/Makefile.inc @@ -7,5 +7,6 @@ bootblock-y += gpio.c ramstage-y += gpio.c +ramstage-y += sku.c verstage-y += gpio.c diff --git a/src/mainboard/google/deltaur/variants/baseboard/gpio.c b/src/mainboard/google/deltaur/variants/baseboard/gpio.c index a67dd8cb4c..46a5cdd79d 100644 --- a/src/mainboard/google/deltaur/variants/baseboard/gpio.c +++ b/src/mainboard/google/deltaur/variants/baseboard/gpio.c @@ -468,3 +468,8 @@ const struct pad_config *__weak variant_early_gpio_table(size_t *num) *num = ARRAY_SIZE(early_gpio_table); return early_gpio_table; } + +int __weak has_360_sensor_board(void) +{ + return 0; +} diff --git a/src/mainboard/google/deltaur/variants/baseboard/include/baseboard/variants.h b/src/mainboard/google/deltaur/variants/baseboard/include/baseboard/variants.h index a1f1b22ec1..332a2c6ea3 100644 --- a/src/mainboard/google/deltaur/variants/baseboard/include/baseboard/variants.h +++ b/src/mainboard/google/deltaur/variants/baseboard/include/baseboard/variants.h @@ -25,4 +25,13 @@ const struct cros_gpio *variant_cros_gpios(size_t *num); const struct lpddr4x_cfg *variant_memory_params(void); void variant_memory_init(FSP_M_CONFIG *mem_cfg); +/* SKU ID structure */ +typedef struct { + int id; + const char *name; +} sku_info; + +/* Check if the device has a 360 sensor board present */ +int has_360_sensor_board(void); + #endif /* __BASEBOARD_VARIANTS_H__ */ diff --git a/src/mainboard/google/deltaur/variants/baseboard/sku.c b/src/mainboard/google/deltaur/variants/baseboard/sku.c new file mode 100644 index 0000000000..8465e64137 --- /dev/null +++ b/src/mainboard/google/deltaur/variants/baseboard/sku.c @@ -0,0 +1,26 @@ +/* + * This file is part of the coreboot project. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include +#include +#include + +static const uint32_t get_sku_index(void) +{ + return ((!has_360_sensor_board()) | (wilco_ec_signed_fw() << 1)); +} + +const uint32_t sku_id(void) +{ + return skus[get_sku_index()].id; +} + +const char *smbios_system_sku(void) +{ + return skus[get_sku_index()].name; +} diff --git a/src/mainboard/google/deltaur/variants/deltan/include/variant/variant.h b/src/mainboard/google/deltaur/variants/deltan/include/variant/variant.h new file mode 100644 index 0000000000..be4c970959 --- /dev/null +++ b/src/mainboard/google/deltaur/variants/deltan/include/variant/variant.h @@ -0,0 +1,25 @@ +/* + * This file is part of the coreboot project. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef VARIANT_H +#define VARIANT_H + +#include +#include +#include + +const static sku_info skus[] = { + /* Deltan 360 - invalid configuration */ + { .id = -1, .name = "sku_invalid" }, + /* Deltan */ + { .id = 1, .name = "sku1" }, + /* Deltan 360 signed - invalid configuration */ + { .id = -1, .name = "sku_invalid" }, + /* Deltan signed */ + { .id = 2, .name = "sku2" }, +}; + +#endif diff --git a/src/mainboard/google/deltaur/variants/deltaur/gpio.c b/src/mainboard/google/deltaur/variants/deltaur/gpio.c index 30315bbc2e..02cb127504 100644 --- a/src/mainboard/google/deltaur/variants/deltaur/gpio.c +++ b/src/mainboard/google/deltaur/variants/deltaur/gpio.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include /* Pad configuration in ramstage */ static const struct pad_config gpio_table[] = { @@ -29,3 +31,9 @@ const struct pad_config *variant_early_gpio_table(size_t *num) *num = ARRAY_SIZE(early_gpio_table); return early_gpio_table; } + +/* Check if the device has a 360 sensor board present */ +int has_360_sensor_board(void) +{ + return gpio_get(SENSOR_DET_360) == 0; +} diff --git a/src/mainboard/google/deltaur/variants/deltaur/include/variant/variant.h b/src/mainboard/google/deltaur/variants/deltaur/include/variant/variant.h new file mode 100644 index 0000000000..8a5e3a83a8 --- /dev/null +++ b/src/mainboard/google/deltaur/variants/deltaur/include/variant/variant.h @@ -0,0 +1,26 @@ +/* + * This file is part of the coreboot project. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef VARIANT_H +#define VARIANT_H + +#include + +/* TODO b/153027724: Sensor detection pin */ +#define SENSOR_DET_360 GPP_C10 + +const static sku_info skus[] = { + /* Deltaur 360 */ + { .id = 1, .name = "sku1" }, + /* Deltaur */ + { .id = 2, .name = "sku2" }, + /* Deltaur 360 signed */ + { .id = 3, .name = "sku3" }, + /* Deltaur signed */ + { .id = 4, .name = "sku4" }, +}; + +#endif -- cgit v1.2.3