Sean Rhodes has submitted this change. ( https://review.coreboot.org/c/coreboot/+/84633?usp=email )
Change subject: ec/starlabs/merlin: Add support for setting the charging speed ......................................................................
ec/starlabs/merlin: Add support for setting the charging speed
Allow boards that use the merlin EC to configure the charging speed, as all versions of the merlin EC support this.
All coreboot does it write a value to the EC RAM and the EC will handle the rest.
Change-Id: I46faa540530c5bd7f5473021561380213158152e Signed-off-by: Sean Rhodes sean@starlabs.systems Reviewed-on: https://review.coreboot.org/c/coreboot/+/84633 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Matt DeVillier matt.devillier@gmail.com --- M src/ec/starlabs/merlin/Kconfig M src/ec/starlabs/merlin/ec.h M src/ec/starlabs/merlin/ite.c M src/ec/starlabs/merlin/variants/apl/ecdefs.h M src/ec/starlabs/merlin/variants/cezanne/ecdefs.h M src/ec/starlabs/merlin/variants/glk/ecdefs.h M src/ec/starlabs/merlin/variants/glkr/ecdefs.h M src/ec/starlabs/merlin/variants/kbl/ecdefs.h M src/ec/starlabs/merlin/variants/merlin/ecdefs.h M src/mainboard/starlabs/starbook/Kconfig M src/mainboard/starlabs/starbook/cmos.default M src/mainboard/starlabs/starbook/cmos.layout M src/mainboard/starlabs/starfighter/Kconfig M src/mainboard/starlabs/starfighter/cmos.default M src/mainboard/starlabs/starfighter/cmos.layout M src/mainboard/starlabs/starlite_adl/Kconfig M src/mainboard/starlabs/starlite_adl/cmos.default M src/mainboard/starlabs/starlite_adl/cmos.layout 18 files changed, 64 insertions(+), 0 deletions(-)
Approvals: Matt DeVillier: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/src/ec/starlabs/merlin/Kconfig b/src/ec/starlabs/merlin/Kconfig index 9f05991..fd8000e 100644 --- a/src/ec/starlabs/merlin/Kconfig +++ b/src/ec/starlabs/merlin/Kconfig @@ -64,6 +64,12 @@ help Select if the mainboard supports limiting the maximum charge of the battery.
+config EC_STARLABS_CHARGING_SPEED + bool "Enable setting the charging speed" + depends on EC_STARLABS_MERLIN + help + Select if the mainboard supports configuring the charging speed. + config EC_STARLABS_MERLIN bool "Use open-source Merlin EC Firmware" default n diff --git a/src/ec/starlabs/merlin/ec.h b/src/ec/starlabs/merlin/ec.h index ca1d081..728f255 100644 --- a/src/ec/starlabs/merlin/ec.h +++ b/src/ec/starlabs/merlin/ec.h @@ -98,6 +98,11 @@ #define KBL_DISABLED 0x00 #define KBL_ENABLED 0xdd
+/* Charging Speed */ +#define SPEED_1_0C 0x00 +#define SPEED_0_5C 0x01 +#define SPEED_0_2C 0x02 + uint16_t ec_get_version(void);
#endif diff --git a/src/ec/starlabs/merlin/ite.c b/src/ec/starlabs/merlin/ite.c index 2f8bced..03b3a96 100644 --- a/src/ec/starlabs/merlin/ite.c +++ b/src/ec/starlabs/merlin/ite.c @@ -69,6 +69,7 @@ * trackpad_state * kbl_brightness * kbl_state + * charging_speed */
/* @@ -240,6 +241,28 @@ */
ec_write(ECRAM_KBL_STATE, KBL_ENABLED); + + /* + * Charging Speed + * + * Setting: charging_speed + * + * Values: 1.0C, 0.5C, 0.2C + * Default: 0.5C + * + */ + const uint8_t charging_speed[] = { + SPEED_1_0C, + SPEED_0_5C, + SPEED_0_2C + }; + + if (CONFIG(EC_STARLABS_CHARGING_SPEED)) + ec_write(ECRAM_CHARGING_SPEED, + get_ec_value_from_option("charging_speed", + SPEED_0_5C, + charging_speed, + ARRAY_SIZE(charging_speed))); }
static struct device_operations ops = { diff --git a/src/ec/starlabs/merlin/variants/apl/ecdefs.h b/src/ec/starlabs/merlin/variants/apl/ecdefs.h index cca0bdc..a7a0c75 100644 --- a/src/ec/starlabs/merlin/variants/apl/ecdefs.h +++ b/src/ec/starlabs/merlin/variants/apl/ecdefs.h @@ -20,5 +20,6 @@ #define ECRAM_MAX_CHARGE dead_code_t(uint8_t) #define ECRAM_FAN_MODE dead_code_t(uint8_t) #define ECRAM_FAST_CHARGE dead_code_t(uint8_t) +#define ECRAM_CHARGING_SPEED dead_code_t(uint8_t)
#endif diff --git a/src/ec/starlabs/merlin/variants/cezanne/ecdefs.h b/src/ec/starlabs/merlin/variants/cezanne/ecdefs.h index 6942c39..aa75e28 100644 --- a/src/ec/starlabs/merlin/variants/cezanne/ecdefs.h +++ b/src/ec/starlabs/merlin/variants/cezanne/ecdefs.h @@ -23,5 +23,6 @@ #define ECRAM_KBL_BRIGHTNESS 0x36 #define ECRAM_FN_LOCK_STATE 0x70 #define ECRAM_FAST_CHARGE dead_code_t(uint8_t) +#define ECRAM_CHARGING_SPEED dead_code_t(uint8_t)
#endif diff --git a/src/ec/starlabs/merlin/variants/glk/ecdefs.h b/src/ec/starlabs/merlin/variants/glk/ecdefs.h index 8130bd17..9037904 100644 --- a/src/ec/starlabs/merlin/variants/glk/ecdefs.h +++ b/src/ec/starlabs/merlin/variants/glk/ecdefs.h @@ -20,5 +20,6 @@ #define ECRAM_MAX_CHARGE dead_code_t(uint8_t) #define ECRAM_FAN_MODE dead_code_t(uint8_t) #define ECRAM_FAST_CHARGE dead_code_t(uint8_t) +#define ECRAM_CHARGING_SPEED dead_code_t(uint8_t)
#endif diff --git a/src/ec/starlabs/merlin/variants/glkr/ecdefs.h b/src/ec/starlabs/merlin/variants/glkr/ecdefs.h index 038c378..9c3daa0 100644 --- a/src/ec/starlabs/merlin/variants/glkr/ecdefs.h +++ b/src/ec/starlabs/merlin/variants/glkr/ecdefs.h @@ -23,5 +23,6 @@ #define ECRAM_MAX_CHARGE dead_code_t(uint8_t) #define ECRAM_FAN_MODE dead_code_t(uint8_t) #define ECRAM_FAST_CHARGE 0x18 +#define ECRAM_CHARGING_SPEED dead_code_t(uint8_t)
#endif diff --git a/src/ec/starlabs/merlin/variants/kbl/ecdefs.h b/src/ec/starlabs/merlin/variants/kbl/ecdefs.h index 5ba8ad6..d15a6ad8 100644 --- a/src/ec/starlabs/merlin/variants/kbl/ecdefs.h +++ b/src/ec/starlabs/merlin/variants/kbl/ecdefs.h @@ -20,5 +20,6 @@ #define ECRAM_FN_CTRL_REVERSE 0x43 #define ECRAM_MAX_CHARGE dead_code_t(uint8_t) #define ECRAM_FAST_CHARGE dead_code_t(uint8_t) +#define ECRAM_CHARGING_SPEED dead_code_t(uint8_t)
#endif diff --git a/src/ec/starlabs/merlin/variants/merlin/ecdefs.h b/src/ec/starlabs/merlin/variants/merlin/ecdefs.h index 8127027..37b0562 100644 --- a/src/ec/starlabs/merlin/variants/merlin/ecdefs.h +++ b/src/ec/starlabs/merlin/variants/merlin/ecdefs.h @@ -20,5 +20,6 @@ #define ECRAM_MAX_CHARGE 0x1a #define ECRAM_FAN_MODE 0x1b #define ECRAM_FAST_CHARGE dead_code_t(uint8_t) +#define ECRAM_CHARGING_SPEED 0x1d
#endif diff --git a/src/mainboard/starlabs/starbook/Kconfig b/src/mainboard/starlabs/starbook/Kconfig index 6ba3d6e..f3dd24a 100644 --- a/src/mainboard/starlabs/starbook/Kconfig +++ b/src/mainboard/starlabs/starbook/Kconfig @@ -29,6 +29,7 @@ config BOARD_STARLABS_LABTOP_CML select BOARD_ROMSIZE_KB_16384 select BOARD_STARLABS_STARBOOK_SERIES + select EC_STARLABS_CHARGING_SPEED select EC_STARLABS_KBL_LEVELS select EC_STARLABS_MAX_CHARGE select EC_STARLABS_MERLIN @@ -45,6 +46,7 @@ select BOARD_STARLABS_STARBOOK_SERIES select DRIVERS_INTEL_PMC select DRIVERS_INTEL_USB4_RETIMER + select EC_STARLABS_CHARGING_SPEED select EC_STARLABS_KBL_LEVELS select EC_STARLABS_MAX_CHARGE select EC_STARLABS_MERLIN @@ -62,6 +64,7 @@ select BOARD_ROMSIZE_KB_32768 select BOARD_STARLABS_STARBOOK_SERIES select DRIVERS_INTEL_PMC + select EC_STARLABS_CHARGING_SPEED select EC_STARLABS_KBL_LEVELS select EC_STARLABS_MAX_CHARGE select EC_STARLABS_MERLIN diff --git a/src/mainboard/starlabs/starbook/cmos.default b/src/mainboard/starlabs/starbook/cmos.default index b4ae84c..d5f195e 100644 --- a/src/mainboard/starlabs/starbook/cmos.default +++ b/src/mainboard/starlabs/starbook/cmos.default @@ -20,6 +20,7 @@ # EC kbl_timeout=30 seconds fn_ctrl_swap=Disable +charging_speed=0.5C # Functions fn_lock_state=0x1 trackpad_state=0x1 diff --git a/src/mainboard/starlabs/starbook/cmos.layout b/src/mainboard/starlabs/starbook/cmos.layout index e403211..fad4032 100644 --- a/src/mainboard/starlabs/starbook/cmos.layout +++ b/src/mainboard/starlabs/starbook/cmos.layout @@ -40,6 +40,7 @@ 608 1 e 1 fn_ctrl_swap 616 2 e 8 max_charge 624 2 e 9 fan_mode +632 2 e 11 charging_speed
# coreboot config options: check sums 984 16 h 0 check_sum @@ -102,6 +103,10 @@ 10 2 High 10 3 On
+11 0 1.0C +11 1 0.5C +11 2 0.2C + # ----------------------------------------------------------------- checksums
diff --git a/src/mainboard/starlabs/starfighter/Kconfig b/src/mainboard/starlabs/starfighter/Kconfig index b3ee347..7fd6c29 100644 --- a/src/mainboard/starlabs/starfighter/Kconfig +++ b/src/mainboard/starlabs/starfighter/Kconfig @@ -8,6 +8,7 @@ select DRIVERS_I2C_HID select EC_STARLABS_FAN select EC_STARLABS_ITE + select EC_STARLABS_CHARGING_SPEED select EC_STARLABS_KBL_LEVELS select EC_STARLABS_MAX_CHARGE select EC_STARLABS_MERLIN diff --git a/src/mainboard/starlabs/starfighter/cmos.default b/src/mainboard/starlabs/starfighter/cmos.default index 88cd178..7d0d447 100644 --- a/src/mainboard/starlabs/starfighter/cmos.default +++ b/src/mainboard/starlabs/starfighter/cmos.default @@ -16,6 +16,7 @@ # EC kbl_timeout=30 seconds fn_ctrl_swap=Disable +charging_speed=0.5C # southbridge power_on_after_fail=Disable # Functions diff --git a/src/mainboard/starlabs/starfighter/cmos.layout b/src/mainboard/starlabs/starfighter/cmos.layout index cdda7da..affe40f 100644 --- a/src/mainboard/starlabs/starfighter/cmos.layout +++ b/src/mainboard/starlabs/starfighter/cmos.layout @@ -36,6 +36,7 @@ 608 1 e 1 fn_ctrl_swap 616 2 e 8 max_charge 624 2 e 9 fan_mode +632 2 e 11 charging_speed
# coreboot config options: southbridge 800 2 e 6 power_on_after_fail @@ -101,6 +102,10 @@ 10 2 High 10 3 On
+11 0 1.0C +11 1 0.5C +11 2 0.2C + # ----------------------------------------------------------------- checksums
diff --git a/src/mainboard/starlabs/starlite_adl/Kconfig b/src/mainboard/starlabs/starlite_adl/Kconfig index fe07f16..5c3ff34 100644 --- a/src/mainboard/starlabs/starlite_adl/Kconfig +++ b/src/mainboard/starlabs/starlite_adl/Kconfig @@ -1,6 +1,7 @@ config BOARD_STARLABS_STARLITE_SERIES def_bool n select DRIVERS_I2C_HID + select EC_STARLABS_CHARGING_SPEED select EC_STARLABS_ITE select EC_STARLABS_MAX_CHARGE select EC_STARLABS_MERLIN diff --git a/src/mainboard/starlabs/starlite_adl/cmos.default b/src/mainboard/starlabs/starlite_adl/cmos.default index c2c7adf..a850e85 100644 --- a/src/mainboard/starlabs/starlite_adl/cmos.default +++ b/src/mainboard/starlabs/starlite_adl/cmos.default @@ -13,3 +13,5 @@ webcam=Enable camera=Enable microphone=Enable +# EC +charging_speed=0.5C diff --git a/src/mainboard/starlabs/starlite_adl/cmos.layout b/src/mainboard/starlabs/starlite_adl/cmos.layout index 2f2ef41..6ca539d 100644 --- a/src/mainboard/starlabs/starlite_adl/cmos.layout +++ b/src/mainboard/starlabs/starlite_adl/cmos.layout @@ -33,6 +33,7 @@
# coreboot config options: EC 600 2 e 6 max_charge +608 2 e 11 charging_speed
# coreboot config options: check sums 984 16 h 0 check_sum @@ -72,6 +73,10 @@ 6 1 80% 6 2 60%
+7 0 1.0C +7 1 0.5C +7 2 0.2C + # ----------------------------------------------------------------- checksums