diff --git a/src/mainboard/clevo/adl-p/ramstage.c b/src/mainboard/clevo/adl-p/ramstage.c index 19815e72d6..988365885c 100644 --- a/src/mainboard/clevo/adl-p/ramstage.c +++ b/src/mainboard/clevo/adl-p/ramstage.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -#include +#include #include #include #include @@ -9,23 +9,8 @@ #include #include #include -#include #include -#include - -struct fan_point { - uint8_t temp; - uint8_t duty; -} __packed; - -struct fan_curve { - struct fan_point point1; - struct fan_point point2; - struct fan_point point3; - struct fan_point point4; -} __packed; - struct smfi_cmd_set_fan_curve { uint8_t fan; struct fan_curve curve; @@ -45,21 +30,6 @@ struct fan_curve fan_curve_performance = { { .temp = 85, .duty = 100} }; -#define FAN_CURVE_OPTION_SILENT 0 -#define FAN_CURVE_OPTION_PERFORMANCE 1 - -#define FAN_CURVE_OPTION_DEFAULT FAN_CURVE_OPTION_SILENT - -#define SLEEP_TYPE_OPTION_S0IX 0 -#define SLEEP_TYPE_OPTION_S3 1 - -#define CAMERA_ENABLED_OPTION 1 -#define CAMERA_DISABLED_OPTION 0 - -#define CAMERA_ENABLEMENT_DEFAULT CAMERA_ENABLED_OPTION - -#define SLEEP_TYPE_OPTION_DEFAULT SLEEP_TYPE_OPTION_S0IX - const char *smbios_system_sku(void) { return "Not Applicable"; @@ -78,28 +48,9 @@ smbios_wakeup_type smbios_system_wakeup_type(void) static void set_fan_curve(void) { int i; - uint8_t selection = FAN_CURVE_OPTION_DEFAULT; + uint8_t selection = get_fan_curve_option(); struct smfi_cmd_set_fan_curve cmd; -#if CONFIG(DRIVERS_EFI_VARIABLE_STORE) - struct region_device rdev; - enum cb_err ret; - uint32_t size; - - const EFI_GUID dasharo_system_features_guid = { - 0xd15b327e, 0xff2d, 0x4fc1, { 0xab, 0xf6, 0xc1, 0x2b, 0xd0, 0x8c, 0x13, 0x59 } - }; - - if (smmstore_lookup_region(&rdev)) - goto efi_err; - - size = sizeof(selection); - ret = efi_fv_get_option(&rdev, &dasharo_system_features_guid, "FanCurveOption", &selection, &size); - if (ret != CB_SUCCESS) - printk(BIOS_DEBUG, "fan: failed to read curve selection from EFI vars, using board default\n"); -efi_err: -#endif - switch (selection) { case FAN_CURVE_OPTION_SILENT: cmd.curve = fan_curve_silent; @@ -120,59 +71,11 @@ efi_err: static void set_camera_enablement(void) { - bool enabled = CAMERA_ENABLEMENT_DEFAULT; + bool enabled = get_camera_option(); -#if CONFIG(DRIVERS_EFI_VARIABLE_STORE) - struct region_device rdev; - enum cb_err ret; - uint32_t size; - - const EFI_GUID dasharo_system_features_guid = { - 0xd15b327e, 0xff2d, 0x4fc1, { 0xab, 0xf6, 0xc1, 0x2b, 0xd0, 0x8c, 0x13, 0x59 } - }; - - if (smmstore_lookup_region(&rdev)) - goto efi_err; - - size = sizeof(enabled); - ret = efi_fv_get_option(&rdev, &dasharo_system_features_guid, "EnableCamera", &enabled, &size); - - if (ret != CB_SUCCESS) { - printk(BIOS_DEBUG, "camera: failed to read camera enablement status from EFI vars, using board default\n"); - goto efi_err; - } - -efi_err: -#endif system76_ec_smfi_cmd(CMD_CAMERA_ENABLEMENT_SET, sizeof(enabled) / sizeof(uint8_t), (uint8_t *)&enabled); } -static uint8_t get_sleep_type_option(void) -{ - uint8_t sleep_type = SLEEP_TYPE_OPTION_DEFAULT; - -#if CONFIG(DRIVERS_EFI_VARIABLE_STORE) - struct region_device rdev; - enum cb_err ret; - uint32_t size; - - const EFI_GUID dasharo_system_features_guid = { - 0xd15b327e, 0xff2d, 0x4fc1, { 0xab, 0xf6, 0xc1, 0x2b, 0xd0, 0x8c, 0x13, 0x59 } - }; - - if (smmstore_lookup_region(&rdev)) - goto efi_err; - - size = sizeof(sleep_type); - ret = efi_fv_get_option(&rdev, &dasharo_system_features_guid, "SleepType", - &sleep_type, &size); - if (ret != CB_SUCCESS) - printk(BIOS_DEBUG, "Failed to read sleep type from EFI vars, using S0ix\n"); -efi_err: -#endif - return sleep_type; -} - static void mainboard_init(void *chip_info) { mainboard_configure_gpios(); @@ -325,11 +228,8 @@ void mainboard_silicon_init_params(FSP_S_CONFIG *params) void mainboard_update_soc_chip_config(struct soc_intel_alderlake_config *config) { - if (get_sleep_type_option() == SLEEP_TYPE_OPTION_S3) { + if (get_sleep_type_option() == SLEEP_TYPE_OPTION_S3) config->s0ix_enable = 0; - config->tcss_d3_cold_disable = 1; - } else { + else config->s0ix_enable = 1; - config->tcss_d3_cold_disable = 0; - } } diff --git a/src/mainboard/clevo/tgl-u/ramstage.c b/src/mainboard/clevo/tgl-u/ramstage.c index 4df2128cd1..1b64e0ca63 100644 --- a/src/mainboard/clevo/tgl-u/ramstage.c +++ b/src/mainboard/clevo/tgl-u/ramstage.c @@ -1,32 +1,17 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include #include -#include #include #include #include #include #include #include -#include #include #include #include -#include - -struct fan_point { - uint8_t temp; - uint8_t duty; -} __packed; - -struct fan_curve { - struct fan_point point1; - struct fan_point point2; - struct fan_point point3; - struct fan_point point4; -} __packed; - struct smfi_cmd_set_fan_curve { uint8_t fan; struct fan_curve curve; @@ -46,16 +31,6 @@ struct fan_curve fan_curve_performance = { { .temp = 85, .duty = 100} }; -#define FAN_CURVE_OPTION_SILENT 0 -#define FAN_CURVE_OPTION_PERFORMANCE 1 - -#define FAN_CURVE_OPTION_DEFAULT FAN_CURVE_OPTION_SILENT - -#define CAMERA_ENABLED_OPTION 1 -#define CAMERA_DISABLED_OPTION 0 - -#define CAMERA_ENABLEMENT_DEFAULT CAMERA_ENABLED_OPTION - const char *smbios_system_sku(void) { return "Not Applicable"; @@ -77,28 +52,9 @@ void mainboard_silicon_init_params(FSP_S_CONFIG *params) static void set_fan_curve(void) { int i; - uint8_t selection = FAN_CURVE_OPTION_DEFAULT; + uint8_t selection = get_fan_curve_option(); struct smfi_cmd_set_fan_curve cmd; -#if CONFIG(DRIVERS_EFI_VARIABLE_STORE) - struct region_device rdev; - enum cb_err ret; - uint32_t size; - - const EFI_GUID dasharo_system_features_guid = { - 0xd15b327e, 0xff2d, 0x4fc1, { 0xab, 0xf6, 0xc1, 0x2b, 0xd0, 0x8c, 0x13, 0x59 } - }; - - if (smmstore_lookup_region(&rdev)) - goto efi_err; - - size = sizeof(selection); - ret = efi_fv_get_option(&rdev, &dasharo_system_features_guid, "FanCurveOption", &selection, &size); - if (ret != CB_SUCCESS) - printk(BIOS_DEBUG, "fan: failed to read curve selection from EFI vars, using board default\n"); -efi_err: -#endif - switch (selection) { case FAN_CURVE_OPTION_SILENT: cmd.curve = fan_curve_silent; @@ -119,30 +75,8 @@ efi_err: static void set_camera_enablement(void) { - bool enabled = CAMERA_ENABLEMENT_DEFAULT; + bool enabled = get_camera_option(); -#if CONFIG(DRIVERS_EFI_VARIABLE_STORE) - struct region_device rdev; - enum cb_err ret; - uint32_t size; - - const EFI_GUID dasharo_system_features_guid = { - 0xd15b327e, 0xff2d, 0x4fc1, { 0xab, 0xf6, 0xc1, 0x2b, 0xd0, 0x8c, 0x13, 0x59 } - }; - - if (smmstore_lookup_region(&rdev)) - goto efi_err; - - size = sizeof(enabled); - ret = efi_fv_get_option(&rdev, &dasharo_system_features_guid, "EnableCamera", &enabled, &size); - - if (ret != CB_SUCCESS) { - printk(BIOS_DEBUG, "camera: failed to read camera enablement status from EFI vars, using board default\n"); - goto efi_err; - } - -efi_err: -#endif system76_ec_smfi_cmd(CMD_CAMERA_ENABLEMENT_SET, sizeof(enabled) / sizeof(uint8_t), (uint8_t *)&enabled); } @@ -232,6 +166,14 @@ static void mainboard_final(void *chip_info) vboot_clear_recovery_request(); } +void mainboard_update_soc_chip_config(struct soc_intel_tigerlake_config *config) +{ + if (get_sleep_type_option() == SLEEP_TYPE_OPTION_S3) + config->s0ix_enable = 0; + else + config->s0ix_enable = 1; +} + struct chip_operations mainboard_ops = { .enable_dev = mainboard_enable, .init = init_mainboard, diff --git a/src/vendorcode/dasharo/include/dasharo/options.h b/src/vendorcode/dasharo/include/dasharo/options.h index 10c204e0a4..ff60a18b63 100644 --- a/src/vendorcode/dasharo/include/dasharo/options.h +++ b/src/vendorcode/dasharo/include/dasharo/options.h @@ -3,11 +3,25 @@ #ifndef DASHARO_OPTIONS_H #define DASHARO_OPTIONS_H +#include #include #define SLEEP_TYPE_OPTION_S0IX 0 #define SLEEP_TYPE_OPTION_S3 1 +#define FAN_CURVE_OPTION_SILENT 0 +#define FAN_CURVE_OPTION_PERFORMANCE 1 + +#define FAN_CURVE_OPTION_DEFAULT FAN_CURVE_OPTION_SILENT + +#define SLEEP_TYPE_OPTION_S0IX 0 +#define SLEEP_TYPE_OPTION_S3 1 + +#define CAMERA_ENABLED_OPTION 1 +#define CAMERA_DISABLED_OPTION 0 + +#define CAMERA_ENABLEMENT_DEFAULT CAMERA_ENABLED_OPTION + enum cse_disable_mode { ME_MODE_ENABLE = 0, ME_MODE_DISABLE_HECI = 1, @@ -19,6 +33,18 @@ struct watchdog_config { uint16_t wdt_timeout; } __packed; +struct fan_point { + uint8_t temp; + uint8_t duty; +} __packed; + +struct fan_curve { + struct fan_point point1; + struct fan_point point2; + struct fan_point point3; + struct fan_point point4; +} __packed; + /* Looks up "power_on_after_fail" option and Dasharo/"PowerFailureState" * variable. * @@ -102,4 +128,23 @@ bool get_ps2_option(void); */ uint8_t get_sleep_type_option(void); +/* Looks Dasharo/"FanCurveOption" variable to check which fan curve EC should + * apply. + * + * + * Result: + * - 0 - Silent profile + * - 1 - Performance profile + */ +uint8_t get_fan_curve_option(void); + +/* Looks Dasharo/"EnableCamera" variable to checkif camera USB port should be + * emabled. + * + * Result: + * - true - camera enabled + * - false - camera disabled + */ +bool get_camera_option(void); + #endif /* DASHARO_OPTIONS_H */ diff --git a/src/vendorcode/dasharo/options.c b/src/vendorcode/dasharo/options.c index de9e17d930..66667254ca 100644 --- a/src/vendorcode/dasharo/options.c +++ b/src/vendorcode/dasharo/options.c @@ -195,3 +195,24 @@ uint8_t get_sleep_type_option(void) return sleep_type; } + + +uint8_t get_fan_curve_option(void) +{ + uint8_t fan_curve = FAN_CURVE_OPTION_SILENT; + + if (CONFIG(DRIVERS_EFI_VARIABLE_STORE)) + read_u8_var("FanCurveOption", &fan_curve); + + return fan_curve; +} + +bool get_camera_option(void) +{ + bool cam_en = CAMERA_ENABLED_OPTION; + + if (CONFIG(DRIVERS_EFI_VARIABLE_STORE)) + read_bool_var("EnableCamera", &cam_en); + + return cam_en; +}