From a58d99575e0791b665a190dba5f07ac2eed35b9f Mon Sep 17 00:00:00 2001 From: Sean Rhodes Date: Wed, 29 Oct 2025 21:17:28 +0000 Subject: [PATCH] mb/starlabs/*: Move CFR object defs to common directory Move all of the CFR object definitons to the common directory to reduce duplicated code. Change-Id: I02d486563a01738335a9f1a20b5fcad2b96d6498 Signed-off-by: Sean Rhodes Reviewed-on: https://review.coreboot.org/c/coreboot/+/89809 Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) --- src/mainboard/starlabs/byte_adl/cfr.c | 45 +------ src/mainboard/starlabs/common/Makefile.mk | 3 +- src/mainboard/starlabs/common/cfr/Makefile.mk | 4 + src/mainboard/starlabs/common/cfr/cfr.c | 11 ++ .../{starbook => common/include/common}/cfr.h | 120 +++++++++++------- src/mainboard/starlabs/lite/cfr.c | 58 +-------- src/mainboard/starlabs/starbook/cfr.c | 2 +- src/mainboard/starlabs/starfighter/cfr.c | 72 +---------- src/mainboard/starlabs/starlite_adl/cfr.c | 114 +---------------- 9 files changed, 99 insertions(+), 330 deletions(-) create mode 100644 src/mainboard/starlabs/common/cfr/Makefile.mk create mode 100644 src/mainboard/starlabs/common/cfr/cfr.c rename src/mainboard/starlabs/{starbook => common/include/common}/cfr.h (75%) diff --git a/src/mainboard/starlabs/byte_adl/cfr.c b/src/mainboard/starlabs/byte_adl/cfr.c index 530821bd34..30b44971e7 100644 --- a/src/mainboard/starlabs/byte_adl/cfr.c +++ b/src/mainboard/starlabs/byte_adl/cfr.c @@ -6,50 +6,7 @@ #include #include #include - -static const struct sm_object gna = SM_DECLARE_BOOL({ - .opt_name = "gna", - .ui_name = "Gaussian & Neural Accelerator", - .ui_helptext = "Enable or Disable the Gaussian & Neural Accelerator", - .default_value = false, -}); - -static const struct sm_object power_profile = SM_DECLARE_ENUM({ - .opt_name = "power_profile", - .ui_name = "Power Profile", - .ui_helptext = "Select whether to maximize performance, battery life or both.", - .default_value = 1, - .values = (const struct sm_enum_value[]) { - { "Power Saver", PP_POWER_SAVER }, - { "Balanced", PP_BALANCED }, - { "Performance", PP_PERFORMANCE }, - SM_ENUM_VALUE_END }, -}); - -static const struct sm_object vtd = SM_DECLARE_BOOL({ - .opt_name = "vtd", - .ui_name = "VT-d", - .ui_helptext = "Enable or disable Intel VT-d (virtualization)", - .default_value = true, -}); - -static const struct sm_object bluetooth_rtd3 = SM_DECLARE_BOOL({ - .opt_name = "bluetooth_rtd3", - .ui_name = "Bluetooth Runtime-D3", - .ui_helptext = "Enable or disable Bluetooth power optimization.\n" - "Recommended to disable when booting Windows.", - .default_value = true, -}); - -static const struct sm_object s0ix_enable = SM_DECLARE_BOOL({ - .opt_name = "s0ix_enable", - .ui_name = "Modern Standby (S0ix)", - .ui_helptext = "Enabled: Use S0ix for device sleep.\n" - "Disabled: Use ACPI S3 for device sleep.\n" - "Requires Intel ME to be enabled.\n" - "Recommended: Enabled when booting Windows, disabled otherwise.", - .default_value = false, -}); +#include static struct sm_obj_form performance = { .ui_name = "Performance", diff --git a/src/mainboard/starlabs/common/Makefile.mk b/src/mainboard/starlabs/common/Makefile.mk index ba007bfa25..966914673d 100644 --- a/src/mainboard/starlabs/common/Makefile.mk +++ b/src/mainboard/starlabs/common/Makefile.mk @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only -subdirs-$(CONFIG_VENDOR_STARLABS) += smbios +subdirs-$(CONFIG_VENDOR_STARLABS) += cfr subdirs-$(CONFIG_VENDOR_STARLABS) += pin_mux +subdirs-$(CONFIG_VENDOR_STARLABS) += smbios CPPFLAGS_common += -I$(src)/mainboard/starlabs/common/include diff --git a/src/mainboard/starlabs/common/cfr/Makefile.mk b/src/mainboard/starlabs/common/cfr/Makefile.mk new file mode 100644 index 0000000000..00b8b806b3 --- /dev/null +++ b/src/mainboard/starlabs/common/cfr/Makefile.mk @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +CPPFLAGS_common += -I$(src)/mainboard/starlabs/common/cfr +ramstage-y += cfr.c diff --git a/src/mainboard/starlabs/common/cfr/cfr.c b/src/mainboard/starlabs/common/cfr/cfr.c new file mode 100644 index 0000000000..ebf5ffc7ce --- /dev/null +++ b/src/mainboard/starlabs/common/cfr/cfr.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include + +void __weak cfr_card_reader_update(const struct sm_object *obj, + struct sm_object *new_obj) +{ + (void)obj; + (void)new_obj; +} diff --git a/src/mainboard/starlabs/starbook/cfr.h b/src/mainboard/starlabs/common/include/common/cfr.h similarity index 75% rename from src/mainboard/starlabs/starbook/cfr.h rename to src/mainboard/starlabs/common/include/common/cfr.h index 7062fd436e..969efa2b19 100644 --- a/src/mainboard/starlabs/starbook/cfr.h +++ b/src/mainboard/starlabs/common/include/common/cfr.h @@ -1,17 +1,41 @@ /* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef _STARBOOK_CFR_H_ -#define _STARBOOK_CFR_H_ +#ifndef _STARLABS_CMN_CFR_H_ +#define _STARLABS_CMN_CFR_H_ #include #include +void cfr_card_reader_update(const struct sm_object *obj, struct sm_object *new_obj); + +static const struct sm_object accelerometer = SM_DECLARE_BOOL({ + .opt_name = "accelerometer", + .ui_name = "Accelerometer", + .ui_helptext = "Enable or disable the built-in accelerometer", + .default_value = true, +}); + +static const struct sm_object bluetooth_rtd3 = SM_DECLARE_BOOL({ + .opt_name = "bluetooth_rtd3", + .ui_name = "Bluetooth Runtime-D3", + .ui_helptext = "Enable or disable Bluetooth power optimization.\n" + "Recommended to disable when booting Windows.", + .default_value = true, +}); + static const struct sm_object card_reader = SM_DECLARE_BOOL({ .opt_name = "card_reader", .ui_name = "Card Reader", .ui_helptext = "Enable or disable the built-in card reader", .default_value = true, +}, WITH_CALLBACK(cfr_card_reader_update)); + +static const struct sm_object display_native_res = SM_DECLARE_BOOL({ + .opt_name = "display_native_res", + .ui_name = "Display: Use Native Resolution", + .ui_helptext = "Enabled: use the native panel resolution at boot.\n" + "Disabled: use a fixed/scaled video mode at boot.", + .default_value = false, }); static const struct sm_object fingerprint_reader = SM_DECLARE_BOOL({ @@ -35,16 +59,19 @@ static const struct sm_object hyper_threading = SM_DECLARE_BOOL({ .default_value = true, }); -static const struct sm_object power_profile = SM_DECLARE_ENUM({ - .opt_name = "power_profile", - .ui_name = "Power Profile", - .ui_helptext = "Select whether to maximize performance, battery life or both.", +static const struct sm_object memory_speed = SM_DECLARE_ENUM({ + .opt_name = "memory_speed", + .ui_name = "Memory Speed", + .ui_helptext = "Configure the speed that the memory will run at. " + "Higher speeds produce more heat and consume more power " + "but provide higher performance.", .default_value = 1, .values = (const struct sm_enum_value[]) { - { "Power Saver", PP_POWER_SAVER }, - { "Balanced", PP_BALANCED }, - { "Performance", PP_PERFORMANCE }, - SM_ENUM_VALUE_END }, + { "5500MT/s", 0 }, + { "6400MT/s", 1 }, + { "7500MT/s", 2 }, + SM_ENUM_VALUE_END, + }, }); static const struct sm_object microphone = SM_DECLARE_BOOL({ @@ -62,6 +89,28 @@ static const struct sm_object pci_hot_plug = SM_DECLARE_BOOL({ .default_value = false, }); +static const struct sm_object power_profile = SM_DECLARE_ENUM({ + .opt_name = "power_profile", + .ui_name = "Power Profile", + .ui_helptext = "Select whether to maximize performance, battery life or both.", + .default_value = 1, + .values = (const struct sm_enum_value[]) { + { "Power Saver", PP_POWER_SAVER }, + { "Balanced", PP_BALANCED }, + { "Performance", PP_PERFORMANCE }, + SM_ENUM_VALUE_END }, +}); + +static const struct sm_object s0ix_enable = SM_DECLARE_BOOL({ + .opt_name = "s0ix_enable", + .ui_name = "Modern Standby (S0ix)", + .ui_helptext = "Enabled: Use S0ix for device sleep.\n" + "Disabled: Use ACPI S3 for device sleep.\n" + "Requires Intel ME to be enabled.\n" + "Recommended: Enabled when booting Windows, disabled otherwise.", + .default_value = false, +}); + static const struct sm_object thunderbolt = SM_DECLARE_BOOL({ .opt_name = "thunderbolt", .ui_name = "Thunderbolt", @@ -69,6 +118,13 @@ static const struct sm_object thunderbolt = SM_DECLARE_BOOL({ .default_value = true, }); +static const struct sm_object touchscreen = SM_DECLARE_BOOL({ + .opt_name = "touchscreen", + .ui_name = "Touchscreen", + .ui_helptext = "Enable or disable the built-in touch-screen", + .default_value = true, +}); + static const struct sm_object vpu = SM_DECLARE_BOOL({ .opt_name = "vpu", .ui_name = "VPU", @@ -76,6 +132,13 @@ static const struct sm_object vpu = SM_DECLARE_BOOL({ .default_value = false, }); +static const struct sm_object vtd = SM_DECLARE_BOOL({ + .opt_name = "vtd", + .ui_name = "VT-d", + .ui_helptext = "Enable or disable Intel VT-d (virtualization)", + .default_value = true, +}); + static const struct sm_object webcam = SM_DECLARE_BOOL({ .opt_name = "webcam", .ui_name = "Webcam", @@ -90,37 +153,4 @@ static const struct sm_object wireless = SM_DECLARE_BOOL({ .default_value = true, }); -static const struct sm_object vtd = SM_DECLARE_BOOL({ - .opt_name = "vtd", - .ui_name = "VT-d", - .ui_helptext = "Enable or disable Intel VT-d (virtualization)", - .default_value = true, -}); - -static const struct sm_object bluetooth_rtd3 = SM_DECLARE_BOOL({ - .opt_name = "bluetooth_rtd3", - .ui_name = "Bluetooth Runtime-D3", - .ui_helptext = "Enable or disable Bluetooth power optimization.\n" - "Recommended to disable when booting Windows.", - .default_value = true, -}); - -static const struct sm_object display_native_res = SM_DECLARE_BOOL({ - .opt_name = "display_native_res", - .ui_name = "Display: Use Native Resolution", - .ui_helptext = "Enabled: use the native panel resolution at boot.\n" - "Disabled: use a fixed/scaled video mode at boot.", - .default_value = false, -}); - -static const struct sm_object s0ix_enable = SM_DECLARE_BOOL({ - .opt_name = "s0ix_enable", - .ui_name = "Modern Standby (S0ix)", - .ui_helptext = "Enabled: Use S0ix for device sleep.\n" - "Disabled: Use ACPI S3 for device sleep.\n" - "Requires Intel ME to be enabled.\n" - "Recommended: Enabled when booting Windows, disabled otherwise.", - .default_value = false, -}); - -#endif /* _STARBOOK_CFR_H_ */ +#endif /* _STARLABS_CMN_CFR_H_ */ diff --git a/src/mainboard/starlabs/lite/cfr.c b/src/mainboard/starlabs/lite/cfr.c index 4049531081..3f17350189 100644 --- a/src/mainboard/starlabs/lite/cfr.c +++ b/src/mainboard/starlabs/lite/cfr.c @@ -6,63 +6,7 @@ #include #include #include - -static const struct sm_object card_reader = SM_DECLARE_BOOL({ - .opt_name = "card_reader", - .ui_name = "Card Reader", - .ui_helptext = "Enable or disable the built-in card reader", - .default_value = true, -}); - -static const struct sm_object power_profile = SM_DECLARE_ENUM({ - .opt_name = "power_profile", - .ui_name = "Power Profile", - .ui_helptext = "Select whether to maximize performance, battery life or both.", - .default_value = 1, - .values = (const struct sm_enum_value[]) { - { "Power Saver", PP_POWER_SAVER }, - { "Balanced", PP_BALANCED }, - { "Performance", PP_PERFORMANCE }, - SM_ENUM_VALUE_END }, -}); - -static const struct sm_object microphone = SM_DECLARE_BOOL({ - .opt_name = "microphone", - .ui_name = "Microphone", - .ui_helptext = "Enable or disable the built-in microphone", - .default_value = true, -}); - -static const struct sm_object webcam = SM_DECLARE_BOOL({ - .opt_name = "webcam", - .ui_name = "Webcam", - .ui_helptext = "Enable or disable the built-in webcam", - .default_value = true, -}); - -static const struct sm_object wireless = SM_DECLARE_BOOL({ - .opt_name = "wireless", - .ui_name = "Wireless", - .ui_helptext = "Enable or disable the built-in wireless card", - .default_value = true, -}); - -static const struct sm_object vtd = SM_DECLARE_BOOL({ - .opt_name = "vtd", - .ui_name = "VT-d", - .ui_helptext = "Enable or disable Intel VT-d (virtualization)", - .default_value = true, -}); - -static const struct sm_object s0ix_enable = SM_DECLARE_BOOL({ - .opt_name = "s0ix_enable", - .ui_name = "Modern Standby (S0ix)", - .ui_helptext = "Enabled: Use S0ix for device sleep.\n" - "Disabled: Use ACPI S3 for device sleep.\n" - "Requires Intel ME to be enabled.\n" - "Recommended: Enabled when booting Windows, disabled otherwise.", - .default_value = false, -}); +#include static struct sm_obj_form performance = { .ui_name = "Performance", diff --git a/src/mainboard/starlabs/starbook/cfr.c b/src/mainboard/starlabs/starbook/cfr.c index fb3605cfdd..cf7f22170f 100644 --- a/src/mainboard/starlabs/starbook/cfr.c +++ b/src/mainboard/starlabs/starbook/cfr.c @@ -5,7 +5,7 @@ #include #include #include -#include "cfr.h" +#include static struct sm_obj_form performance = { .ui_name = "Performance", diff --git a/src/mainboard/starlabs/starfighter/cfr.c b/src/mainboard/starlabs/starfighter/cfr.c index d54ff0de07..89f8811bb0 100644 --- a/src/mainboard/starlabs/starfighter/cfr.c +++ b/src/mainboard/starlabs/starfighter/cfr.c @@ -6,77 +6,7 @@ #include #include #include - -#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", - .ui_name = "Gaussian & Neural Accelerator", - .ui_helptext = "Enable or Disable the Gaussian & Neural Accelerator", - .default_value = false, -}); -#endif - -static const struct sm_object hyper_threading = SM_DECLARE_BOOL({ - .opt_name = "hyper_threading", - .ui_name = "Hyper-Threading", - .ui_helptext = "Enable or disable Hyper-Threading", - .default_value = true, -}); - - -static const struct sm_object power_profile = SM_DECLARE_ENUM({ - .opt_name = "power_profile", - .ui_name = "Power Profile", - .ui_helptext = "Select whether to maximize performance, battery life or both.", - .default_value = 1, - .values = (const struct sm_enum_value[]) { - { "Power Saver", PP_POWER_SAVER }, - { "Balanced", PP_BALANCED }, - { "Performance", PP_PERFORMANCE }, - SM_ENUM_VALUE_END }, -}); - -#if CONFIG(DRIVERS_INTEL_USB4_RETIMER) -static const struct sm_object thunderbolt = SM_DECLARE_BOOL({ - .opt_name = "thunderbolt", - .ui_name = "Thunderbolt", - .ui_helptext = "Enable or disable Thunderbolt support", - .default_value = true, -}); -#endif - -static const struct sm_object vtd = SM_DECLARE_BOOL({ - .opt_name = "vtd", - .ui_name = "VT-d", - .ui_helptext = "Enable or disable Intel VT-d (virtualization)", - .default_value = true, -}); - -static const struct sm_object bluetooth_rtd3 = SM_DECLARE_BOOL({ - .opt_name = "bluetooth_rtd3", - .ui_name = "Bluetooth Runtime-D3", - .ui_helptext = "Enable or disable Bluetooth power optimization.\n" - "Recommended to disable when booting Windows.", - .default_value = true, -}); - -static const struct sm_object display_native_res = SM_DECLARE_BOOL({ - .opt_name = "display_native_res", - .ui_name = "Display: Use Native Resolution", - .ui_helptext = "Enabled: use the native panel resolution at boot.\n" - "Disabled: use a fixed/scaled video mode at boot.", - .default_value = false, -}); - -static const struct sm_object s0ix_enable = SM_DECLARE_BOOL({ - .opt_name = "s0ix_enable", - .ui_name = "Modern Standby (S0ix)", - .ui_helptext = "Enabled: Use S0ix for device sleep.\n" - "Disabled: Use ACPI S3 for device sleep.\n" - "Requires Intel ME to be enabled.\n" - "Recommended: Enabled when booting Windows, disabled otherwise.", - .default_value = false, -}); +#include static struct sm_obj_form performance = { .ui_name = "Performance", diff --git a/src/mainboard/starlabs/starlite_adl/cfr.c b/src/mainboard/starlabs/starlite_adl/cfr.c index a7ebe498aa..defa0ec1b1 100644 --- a/src/mainboard/starlabs/starlite_adl/cfr.c +++ b/src/mainboard/starlabs/starlite_adl/cfr.c @@ -9,124 +9,16 @@ #include #include #include +#include -static const struct sm_object accelerometer = SM_DECLARE_BOOL({ - .opt_name = "accelerometer", - .ui_name = "Accelerometer", - .ui_helptext = "Enable or disable the built-in accelerometer", - .default_value = true, -}); - -static void update_card_reader(const struct sm_object *obj, struct sm_object *new) +void cfr_card_reader_update(const struct sm_object *obj, struct sm_object *new_obj) { struct device *mxc_accel = DEV_PTR(mxc6655); if (!i2c_dev_detect(i2c_busdev(mxc_accel), mxc_accel->path.i2c.device)) - new->sm_bool.flags = CFR_OPTFLAG_SUPPRESS; + new_obj->sm_bool.flags = CFR_OPTFLAG_SUPPRESS; } -static const struct sm_object card_reader = SM_DECLARE_BOOL({ - .opt_name = "card_reader", - .ui_name = "Card Reader", - .ui_helptext = "Enable or disable the built-in card reader", - .default_value = true, -}, WITH_CALLBACK(update_card_reader)); - -#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", - .ui_name = "Gaussian & Neural Accelerator", - .ui_helptext = "Enable or Disable the Gaussian & Neural Accelerator", - .default_value = false, -}); -#endif - -static const struct sm_object memory_speed = SM_DECLARE_ENUM({ - .opt_name = "memory_speed", - .ui_name = "Memory Speed", - .ui_helptext = "Configure the speed that the memory will run at. Higher speeds produce more heat and consume more power but provide higher performance.", - .default_value = 1, - .values = (const struct sm_enum_value[]) { - { "5500MT/s", 0 }, - { "6400MT/s", 1 }, - { "7500MT/s", 2 }, - SM_ENUM_VALUE_END, - } -}); - -static const struct sm_object power_profile = SM_DECLARE_ENUM({ - .opt_name = "power_profile", - .ui_name = "Power Profile", - .ui_helptext = "Select whether to maximize performance, battery life or both.", - .default_value = 1, - .values = (const struct sm_enum_value[]) { - { "Power Saver", PP_POWER_SAVER }, - { "Balanced", PP_BALANCED }, - { "Performance", PP_PERFORMANCE }, - SM_ENUM_VALUE_END }, -}); - -static const struct sm_object microphone = SM_DECLARE_BOOL({ - .opt_name = "microphone", - .ui_name = "Microphone", - .ui_helptext = "Enable or disable the built-in microphone", - .default_value = true, -}); - -static const struct sm_object touchscreen = SM_DECLARE_BOOL({ - .opt_name = "touchscreen", - .ui_name = "Touchscreen", - .ui_helptext = "Enable or disable the built-in touch-screen", - .default_value = true, -}); - -static const struct sm_object webcam = SM_DECLARE_BOOL({ - .opt_name = "webcam", - .ui_name = "Webcam", - .ui_helptext = "Enable or disable the built-in webcam", - .default_value = true, -}); - -static const struct sm_object wireless = SM_DECLARE_BOOL({ - .opt_name = "wireless", - .ui_name = "Wireless", - .ui_helptext = "Enable or disable the built-in wireless card", - .default_value = true, -}); - -static const struct sm_object vtd = SM_DECLARE_BOOL({ - .opt_name = "vtd", - .ui_name = "VT-d", - .ui_helptext = "Enable or disable Intel VT-d (virtualization)", - .default_value = true, -}); - -static const struct sm_object bluetooth_rtd3 = SM_DECLARE_BOOL({ - .opt_name = "bluetooth_rtd3", - .ui_name = "Bluetooth Runtime-D3", - .ui_helptext = "Enable or disable Bluetooth power optimization.\n" - "Recommended to disable when booting Windows.", - .default_value = true, -}); - -static const struct sm_object display_native_res = SM_DECLARE_BOOL({ - .opt_name = "display_native_res", - .ui_name = "Display: Use Native Resolution", - .ui_helptext = "Enabled: use the native panel resolution at boot.\n" - "Disabled: use a fixed/scaled video mode at boot.", - .default_value = false, -}); - -static const struct sm_object s0ix_enable = SM_DECLARE_BOOL({ - .opt_name = "s0ix_enable", - .ui_name = "Modern Standby (S0ix)", - .ui_helptext = "Enabled: Use S0ix for device sleep.\n" - "Disabled: Use ACPI S3 for device sleep.\n" - "Requires Intel ME to be enabled.\n" - "Recommended: Enabled when booting Windows, disabled otherwise.", - .default_value = false, -}); - static struct sm_obj_form performance = { .ui_name = "Performance", .obj_list = (const struct sm_object *[]) {