Peter Marheine has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/51508 )
Change subject: mb/google/zork: support reading SSFC fields ......................................................................
mb/google/zork: support reading SSFC fields
Firmware needs to change behavior for auto-mode speaker amplifiers as indicated by SSFC, so implement support for reading that from CBI.
Signed-off-by: Peter Marheine pmarheine@chromium.org Change-Id: Ie5f644d70f43fc99af290a6a21cd427de8da0913 --- M src/mainboard/google/zork/variants/baseboard/Makefile.inc A src/mainboard/google/zork/variants/baseboard/cbi_ssfc.c A src/mainboard/google/zork/variants/baseboard/include/baseboard/cbi_ssfc.h 3 files changed, 55 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/08/51508/1
diff --git a/src/mainboard/google/zork/variants/baseboard/Makefile.inc b/src/mainboard/google/zork/variants/baseboard/Makefile.inc index 2764a89..cb510ed 100644 --- a/src/mainboard/google/zork/variants/baseboard/Makefile.inc +++ b/src/mainboard/google/zork/variants/baseboard/Makefile.inc @@ -2,17 +2,20 @@
bootblock-y += gpio_baseboard_common.c bootblock-y += helpers.c +bootblock-y += cbi_ssfc.c bootblock-$(CONFIG_BOARD_GOOGLE_BASEBOARD_TREMBYLE) += gpio_baseboard_trembyle.c bootblock-$(CONFIG_BOARD_GOOGLE_BASEBOARD_DALBOZ) += gpio_baseboard_dalboz.c
verstage-y += gpio_baseboard_common.c verstage-y += helpers.c +verstage-y += cbi_ssfc.c verstage-$(CONFIG_BOARD_GOOGLE_BASEBOARD_TREMBYLE) += gpio_baseboard_trembyle.c verstage-$(CONFIG_BOARD_GOOGLE_BASEBOARD_DALBOZ) += gpio_baseboard_dalboz.c verstage-y += tpm_tis.c
romstage-y += gpio_baseboard_common.c romstage-y += helpers.c +romstage-y += cbi_ssfc.c romstage-$(CONFIG_BOARD_GOOGLE_BASEBOARD_TREMBYLE) += gpio_baseboard_trembyle.c romstage-$(CONFIG_BOARD_GOOGLE_BASEBOARD_DALBOZ) += gpio_baseboard_dalboz.c romstage-y += tpm_tis.c @@ -23,6 +26,7 @@ ramstage-$(CONFIG_BOARD_GOOGLE_BASEBOARD_DALBOZ) += gpio_baseboard_dalboz.c ramstage-$(CONFIG_BOARD_GOOGLE_BASEBOARD_DALBOZ) += fsps_baseboard_dalboz.c ramstage-y += helpers.c +ramstage-y += cbi_ssfc.c ramstage-y += tpm_tis.c ramstage-y += ramstage_common.c
diff --git a/src/mainboard/google/zork/variants/baseboard/cbi_ssfc.c b/src/mainboard/google/zork/variants/baseboard/cbi_ssfc.c new file mode 100644 index 0000000..8666bf5 --- /dev/null +++ b/src/mainboard/google/zork/variants/baseboard/cbi_ssfc.c @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <console/console.h> +#include <ec/google/chromeec/ec.h> + +#include <baseboard/cbi_ssfc.h> + +static uint32_t get_ssfc(void) +{ + static uint32_t value; + static bool read_once = false; + + if (!read_once) { + /* Errors will read the (safe) default value of all zero */ + if (google_chromeec_cbi_get_ssfc(&value) != 0) + printk(BIOS_INFO, + "SSFC is unset in CBI; assuming default"); + read_once = true; + } + return value; +} + +enum ec_ssfc_spkr_auto_mode ssfc_get_spkr_auto_mode(void) +{ + return (get_ssfc() & SSFC_SPKR_AUTO_MODE_MASK) + >> SSFC_SPKR_AUTO_MODE_OFFSET; +} diff --git a/src/mainboard/google/zork/variants/baseboard/include/baseboard/cbi_ssfc.h b/src/mainboard/google/zork/variants/baseboard/include/baseboard/cbi_ssfc.h new file mode 100644 index 0000000..0d08617 --- /dev/null +++ b/src/mainboard/google/zork/variants/baseboard/include/baseboard/cbi_ssfc.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef MAINBOARD_SSFC_H +#define MAINBOARD_SSFC_H + +enum ec_ssfc_base_gyro_sensor { + SSFC_BASE_GYRO_NONE = 0, + SSFC_BASE_GYRO_BMI160 = 1, + SSFC_BASE_GYRO_LSM6DSM = 2, + SSFC_BASE_GYRO_ICM426XX = 3, +}; +#define SSFC_BASE_GYRO_OFFSET 0 +#define SSFC_BASE_GYRO_MASK (0x07 << SSFC_BASE_GYRO_OFFSET) + +enum ec_ssfc_spkr_auto_mode { + SSFC_SPKR_AUTO_MODE_OFF = 0, + SSFC_SPKR_AUTO_MODE_ON = 1, +}; +#define SSFC_SPKR_AUTO_MODE_OFFSET 3 +#define SSFC_SPKR_AUTO_MODE_MASK (1 << SSFC_SPKR_AUTO_MODE_OFFSET) + +enum ec_ssfc_spkr_auto_mode ssfc_get_spkr_auto_mode(void); + +#endif