From cae53bea52f794e7e4986f07e63066ed845cabee Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sun, 19 Oct 2025 17:33:46 -0500 Subject: [PATCH] ec/google/chromeec: Add CFR options for keyboard backlight and fan control Create a new header with CFR objects for keyboard backlight and automatic fan control, which mainboards can include in their setup menus in order to expose the options. The visibility of the options are controlled by callbacks which test for device presence. Change-Id: I2386b527f65b2e3b4ca43b9b65b69040abee00ad Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/89831 Tested-by: build bot (Jenkins) Reviewed-by: Maximilian Brune --- src/ec/google/chromeec/cfr.h | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/ec/google/chromeec/cfr.h diff --git a/src/ec/google/chromeec/cfr.h b/src/ec/google/chromeec/cfr.h new file mode 100644 index 0000000000..980ac120c4 --- /dev/null +++ b/src/ec/google/chromeec/cfr.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * CFR enums and structs which are used to control EC settings. + */ + +#ifndef _CHROMEEC_CFR_H_ +#define _CHROMEEC_CFR_H_ + +#include +#include "ec.h" + +static void update_fan_control(const struct sm_object *obj, struct sm_object *new) +{ + if (!CONFIG(EC_GOOGLE_CHROMEEC_AUTO_FAN_CTRL) && !google_chromeec_has_fan()) { + new->sm_bool.flags = CFR_OPTFLAG_SUPPRESS; + new->sm_bool.default_value = 0; + } +} + +static const struct sm_object auto_fan_control = SM_DECLARE_ENUM({ + .opt_name = "auto_fan_control", + .ui_name = "Automatic Fan Control", + .ui_helptext = "Enable or disable automatic fan control.", + .default_value = CONFIG(EC_GOOGLE_CHROMEEC_AUTO_FAN_CTRL), + .values = (struct sm_enum_value[]) { + { "Enabled", 1 }, + { "Disabled", 0 }, + SM_ENUM_VALUE_END, + }, +}, WITH_CALLBACK(update_fan_control)); + +static const struct sm_enum_value ec_backlight_values[] = { + { "0%", 0 }, + { "25%", 25 }, + { "50%", 50 }, + { "100%", 100 }, + SM_ENUM_VALUE_END, +}; + +static void update_kb_backlight(const struct sm_object *obj, struct sm_object *new) +{ + if (!google_chromeec_has_kbbacklight()) { + new->sm_bool.flags = CFR_OPTFLAG_SUPPRESS; + new->sm_bool.default_value = -1; + } +} + +static const struct sm_object ec_kb_backlight = SM_DECLARE_ENUM({ + .opt_name = "ec_kb_backlight", + .ui_name = "Keyboard Backlight Level At Boot", + .ui_helptext = "Specify the level the keyboard backlight should be at boot." + " Set to 0% to disable the backlight.", + .default_value = 50, + .values = ec_backlight_values, +}, WITH_CALLBACK(update_kb_backlight)); + +#endif /* _CHROMEEC_CFR_H_ */