{ec,mb}/starlabs: Consolidate EC-related CFR options in ec directory

Move all of the EC-related CFR options into a header in the ec
directory, so it can be reused across multiple boards.

TEST=build/boot starlabs/starbook_mtl,starlite_adl and verify CFR
options work properly.

Change-Id: I831559184de917b32e4993e8e34ffbc7b7e883e4
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86318
Reviewed-by: Sean Rhodes <sean@starlabs.systems>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Matt DeVillier 2025-02-07 12:24:33 -06:00 committed by Sean Rhodes
commit 773a405b7b
5 changed files with 118 additions and 227 deletions

View file

@ -0,0 +1,114 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* CFR enums and structs which are used to control EC settings.
*/
#include <drivers/option/cfr_frontend.h>
#include "ec.h"
/*
* Keyboard Backlight Timeout
*/
static const struct sm_object kbl_timeout = SM_DECLARE_ENUM({
.opt_name = "kbl_timeout",
.ui_name = "Keyboard Backlight Timeout",
.ui_helptext = "Set the amount of time before the keyboard backlight turns off"
" when un-used",
.default_value = 0,
.values = (struct sm_enum_value[]) {
{ "30 seconds", 0 },
{ "1 minute", 1 },
{ "3 minutes", 2 },
{ "5 minutes", 3 },
{ "Never", 4 },
SM_ENUM_VALUE_END },
});
/*
* Function-Control Swap
*/
static const struct sm_object fn_ctrl_swap = SM_DECLARE_BOOL({
.opt_name = "fn_ctrl_swap",
.ui_name = "Fn Ctrl Reverse",
.ui_helptext = "Swap the functions of the [Fn] and [Ctrl] keys",
.default_value = false,
});
/*
* Maximum Battery Charge Level
*/
static const struct sm_object max_charge = SM_DECLARE_ENUM({
.opt_name = "max_charge",
.ui_name = "Maximum Charge Level",
.ui_helptext = "Set the maximum level the battery will charge to.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "100%", 0 },
{ "80%", 1 },
{ "60%", 2 },
SM_ENUM_VALUE_END },
});
/*
* Fan Mode
*/
static const struct sm_object fan_mode = SM_DECLARE_ENUM({
.opt_name = "fan_mode",
.ui_name = "Fan Mode",
.ui_helptext = "Adjust the fan curve to prioritize performance or noise levels.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "Normal", 0 },
{ "Aggressive", 1 },
{ "Quiet", 2 },
{ "Disabled", 3 },
SM_ENUM_VALUE_END },
});
/*
* Charging Speed
*/
static const struct sm_object charging_speed = SM_DECLARE_ENUM({
.opt_name = "charging_speed",
.ui_name = "Charging Speed",
.ui_helptext = "Set the maximum speed to charge the battery. Charging faster"
" will increase heat and battery wear.",
.default_value = 1,
.values = (const struct sm_enum_value[]) {
{ "1.0C", 0 },
{ "0.5C", 1 },
{ "0.2C", 2 },
SM_ENUM_VALUE_END },
});
/*
* Lid Switch
*/
static const struct sm_object lid_switch = SM_DECLARE_ENUM({
.opt_name = "lid_switch",
.ui_name = "Lid Switch",
.ui_helptext = "Configure what opening or closing the lid will do.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "Normal", 0 },
{ "Sleep Only", 1 },
{ "Disabled", 2 },
SM_ENUM_VALUE_END },
});
/*
* Power LED Brightness
*/
static const struct sm_object power_led = SM_DECLARE_ENUM({
.opt_name = "power_led",
.ui_name = "Power LED Brightness",
.ui_helptext = "Control the maximum brightness of the power LED",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "Normal", 0 },
{ "Reduced", 1 },
SM_ENUM_VALUE_END,
},
});

View file

@ -3,6 +3,7 @@
#include <boot/coreboot_tables.h>
#include <commonlib/coreboot_tables.h>
#include <drivers/option/cfr_frontend.h>
#include <ec/starlabs/merlin/cfr.h>
#include <inttypes.h>
#include <intelblocks/pcie_rp.h>
#include <string.h>
@ -54,28 +55,6 @@ static const struct sm_object fast_charge = SM_DECLARE_BOOL({
});
#endif
static const struct sm_object fn_ctrl_swap = SM_DECLARE_BOOL({
.opt_name = "fn_ctrl_swap",
.ui_name = "Fn Ctrl Reverse",
.ui_helptext = "Swap the functions of the [Fn] and [Ctrl] keys",
.default_value = false,
});
static const struct sm_object kbl_timeout = SM_DECLARE_ENUM({
.opt_name = "kbl_timeout",
.ui_name = "Keyboard Backlight Timeout",
.ui_helptext = "Set the amount of time before the keyboard backlight turns off"
" when un-used",
.default_value = 0,
.values = (struct sm_enum_value[]) {
{ "30 seconds", 0 },
{ "1 minute", 1 },
{ "3 minutes", 2 },
{ "5 minutes", 3 },
{ "Never", 4 },
SM_ENUM_VALUE_END },
});
static const struct sm_object power_on_after_fail = SM_DECLARE_BOOL({
.opt_name = "power_on_after_fail",
.ui_name = "Power on after failure",

View file

@ -3,6 +3,7 @@
#include <boot/coreboot_tables.h>
#include <commonlib/coreboot_tables.h>
#include <drivers/option/cfr_frontend.h>
#include <ec/starlabs/merlin/cfr.h>
#include <inttypes.h>
#include <intelblocks/pcie_rp.h>
#include <string.h>
@ -27,21 +28,6 @@ static const struct sm_object card_reader = SM_DECLARE_BOOL({
.default_value = true,
});
#if CONFIG(EC_STARLABS_CHARGING_SPEED)
static const struct sm_object charging_speed = SM_DECLARE_ENUM({
.opt_name = "charging_speed",
.ui_name = "Charging Speed",
.ui_helptext = "Set the maximum speed to charge the battery. Charging faster"
" will increase heat and battery wear.",
.default_value = 1,
.values = (const struct sm_enum_value[]) {
{ "1.0C", 0 },
{ "0.5C", 1 },
{ "0.2C", 2 },
SM_ENUM_VALUE_END },
});
#endif
static const struct sm_object debug_level = SM_DECLARE_ENUM({
.opt_name = "debug_level",
.ui_name = "Debug Level",
@ -60,19 +46,6 @@ static const struct sm_object debug_level = SM_DECLARE_ENUM({
SM_ENUM_VALUE_END },
});
static const struct sm_object fan_mode = SM_DECLARE_ENUM({
.opt_name = "fan_mode",
.ui_name = "Fan Mode",
.ui_helptext = "Adjust the fan curve to prioritize performance or noise levels.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "Normal", 0 },
{ "Aggressive", 1 },
{ "Quiet", 2 },
{ "Disabled", 3 },
SM_ENUM_VALUE_END },
});
#if CONFIG(BOARD_STARLABS_STARBOOK_ADL) || CONFIG(BOARD_STARLABS_STARBOOK_RPL)
static const struct sm_object fingerprint_reader = SM_DECLARE_BOOL({
.opt_name = "fingerprint_reader",
@ -82,13 +55,6 @@ static const struct sm_object fingerprint_reader = SM_DECLARE_BOOL({
});
#endif
static const struct sm_object fn_ctrl_swap = SM_DECLARE_BOOL({
.opt_name = "fn_ctrl_swap",
.ui_name = "Fn Ctrl Reverse",
.ui_helptext = "Swap the functions of the [Fn] and [Ctrl] keys",
.default_value = false,
});
#if CONFIG(SOC_INTEL_TIGERLAKE) || CONFIG(SOC_INTEL_ALDERLAKE) || CONFIG(SOC_INTEL_RAPTORLAKE)
static const struct sm_object gna = SM_DECLARE_BOOL({
.opt_name = "gna",
@ -107,47 +73,6 @@ static const struct sm_object hyper_threading = SM_DECLARE_BOOL({
});
#endif
static const struct sm_object kbl_timeout = SM_DECLARE_ENUM({
.opt_name = "kbl_timeout",
.ui_name = "Keyboard Backlight Timeout",
.ui_helptext = "Set the amount of time before the keyboard backlight turns off"
" when un-used",
.default_value = 0,
.values = (struct sm_enum_value[]) {
{ "30 seconds", 0 },
{ "1 minute", 1 },
{ "3 minutes", 2 },
{ "5 minutes", 3 },
{ "Never", 4 },
SM_ENUM_VALUE_END },
});
#if CONFIG(EC_STARLABS_LID_SWITCH)
static const struct sm_object lid_switch = SM_DECLARE_ENUM({
.opt_name = "lid_switch",
.ui_name = "Lid Switch",
.ui_helptext = "Configure what opening or closing the lid will do.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "Normal", 0 },
{ "Sleep Only", 1 },
{ "Disabled", 2 },
SM_ENUM_VALUE_END },
});
#endif
static const struct sm_object max_charge = SM_DECLARE_ENUM({
.opt_name = "max_charge",
.ui_name = "Maximum Charge Level",
.ui_helptext = "Set the maximum level the battery will charge to.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "100%", 0 },
{ "80%", 1 },
{ "60%", 2 },
SM_ENUM_VALUE_END },
});
static const struct sm_object me_state = SM_DECLARE_ENUM({
.opt_name = "me_state",
.ui_name = "Intel Management Engine",

View file

@ -3,6 +3,7 @@
#include <boot/coreboot_tables.h>
#include <commonlib/coreboot_tables.h>
#include <drivers/option/cfr_frontend.h>
#include <ec/starlabs/merlin/cfr.h>
#include <inttypes.h>
#include <intelblocks/pcie_rp.h>
#include <string.h>
@ -20,21 +21,6 @@ static const struct sm_object boot_option = SM_DECLARE_ENUM({
SM_ENUM_VALUE_END },
});
#if CONFIG(EC_STARLABS_CHARGING_SPEED)
static const struct sm_object charging_speed = SM_DECLARE_ENUM({
.opt_name = "charging_speed",
.ui_name = "Charging Speed",
.ui_helptext = "Set the maximum speed to charge the battery. Charging faster"
" will increase heat and battery wear.",
.default_value = 1,
.values = (const struct sm_enum_value[]) {
{ "1.0C", 0 },
{ "0.5C", 1 },
{ "0.2C", 2 },
SM_ENUM_VALUE_END },
});
#endif
static const struct sm_object debug_level = SM_DECLARE_ENUM({
.opt_name = "debug_level",
.ui_name = "Debug Level",
@ -53,26 +39,6 @@ static const struct sm_object debug_level = SM_DECLARE_ENUM({
SM_ENUM_VALUE_END },
});
static const struct sm_object fan_mode = SM_DECLARE_ENUM({
.opt_name = "fan_mode",
.ui_name = "Fan Mode",
.ui_helptext = "Adjust the fan curve to prioritize performance or noise levels.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "Normal", 0 },
{ "Aggressive", 1 },
{ "Quiet", 2 },
{ "Disabled", 3 },
SM_ENUM_VALUE_END },
});
static const struct sm_object fn_ctrl_swap = SM_DECLARE_BOOL({
.opt_name = "fn_ctrl_swap",
.ui_name = "Fn Ctrl Reverse",
.ui_helptext = "Swap the functions of the [Fn] and [Ctrl] keys",
.default_value = false,
});
#if CONFIG(SOC_INTEL_TIGERLAKE) || CONFIG(SOC_INTEL_ALDERLAKE) || CONFIG(SOC_INTEL_RAPTORLAKE)
static const struct sm_object gna = SM_DECLARE_BOOL({
.opt_name = "gna",
@ -89,47 +55,6 @@ static const struct sm_object hyper_threading = SM_DECLARE_BOOL({
.default_value = true,
});
static const struct sm_object kbl_timeout = SM_DECLARE_ENUM({
.opt_name = "kbl_timeout",
.ui_name = "Keyboard Backlight Timeout",
.ui_helptext = "Set the amount of time before the keyboard backlight turns off"
" when un-used",
.default_value = 0,
.values = (struct sm_enum_value[]) {
{ "30 seconds", 0 },
{ "1 minute", 1 },
{ "3 minutes", 2 },
{ "5 minutes", 3 },
{ "Never", 4 },
SM_ENUM_VALUE_END },
});
#if CONFIG(EC_STARLABS_LID_SWITCH)
static const struct sm_object lid_switch = SM_DECLARE_ENUM({
.opt_name = "lid_switch",
.ui_name = "Lid Switch",
.ui_helptext = "Configure what opening or closing the lid will do.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "Normal", 0 },
{ "Sleep Only", 1 },
{ "Disabled", 2 },
SM_ENUM_VALUE_END },
});
#endif
static const struct sm_object max_charge = SM_DECLARE_ENUM({
.opt_name = "max_charge",
.ui_name = "Maximum Charge Level",
.ui_helptext = "Set the maximum level the battery will charge to.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "100%", 0 },
{ "80%", 1 },
{ "60%", 2 },
SM_ENUM_VALUE_END },
});
static const struct sm_object me_state = SM_DECLARE_ENUM({
.opt_name = "me_state",
.ui_name = "Intel Management Engine",

View file

@ -3,6 +3,7 @@
#include <boot/coreboot_tables.h>
#include <commonlib/coreboot_tables.h>
#include <drivers/option/cfr_frontend.h>
#include <ec/starlabs/merlin/cfr.h>
#include <inttypes.h>
#include <intelblocks/pcie_rp.h>
#include <string.h>
@ -27,21 +28,6 @@ static const struct sm_object boot_option = SM_DECLARE_ENUM({
SM_ENUM_VALUE_END },
});
#if CONFIG(EC_STARLABS_CHARGING_SPEED)
static const struct sm_object charging_speed = SM_DECLARE_ENUM({
.opt_name = "charging_speed",
.ui_name = "Charging Speed",
.ui_helptext = "Set the maximum speed to charge the battery. Charging faster"
" will increase heat and battery wear.",
.default_value = 1,
.values = (const struct sm_enum_value[]) {
{ "1.0C", 0 },
{ "0.5C", 1 },
{ "0.2C", 2 },
SM_ENUM_VALUE_END },
});
#endif
static const struct sm_object debug_level = SM_DECLARE_ENUM({
.opt_name = "debug_level",
.ui_name = "Debug Level",
@ -69,32 +55,6 @@ static const struct sm_object gna = SM_DECLARE_BOOL({
});
#endif
#if CONFIG(EC_STARLABS_LID_SWITCH)
static const struct sm_object lid_switch = SM_DECLARE_ENUM({
.opt_name = "lid_switch",
.ui_name = "Lid Switch",
.ui_helptext = "Configure what opening or closing the lid will do.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "Normal", 0 },
{ "Sleep Only", 1 },
{ "Disabled", 2 },
SM_ENUM_VALUE_END },
});
#endif
static const struct sm_object max_charge = SM_DECLARE_ENUM({
.opt_name = "max_charge",
.ui_name = "Maximum Charge Level",
.ui_helptext = "Set the maximum level the battery will charge to.",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "100%", 0 },
{ "80%", 1 },
{ "60%", 2 },
SM_ENUM_VALUE_END },
});
static const struct sm_object me_state = SM_DECLARE_ENUM({
.opt_name = "me_state",
.ui_name = "Intel Management Engine",
@ -194,18 +154,6 @@ static const struct sm_object pciexp_l1ss = SM_DECLARE_ENUM({
});
#endif
static const struct sm_object power_led = SM_DECLARE_ENUM({
.opt_name = "power_led",
.ui_name = "Power LED Brightness",
.ui_helptext = "Control the maximum brightness of the power LED",
.default_value = 0,
.values = (const struct sm_enum_value[]) {
{ "Normal", 0 },
{ "Reduced", 1 },
SM_ENUM_VALUE_END,
},
});
static const struct sm_object reboot_counter = SM_DECLARE_NUMBER({
.opt_name = "reboot_counter",
.ui_name = "Reboot Counter",