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>
This commit is contained in:
Sean Rhodes 2024-06-27 12:20:18 +01:00
commit e1fcb2db78
18 changed files with 64 additions and 0 deletions

View file

@ -64,6 +64,12 @@ config EC_STARLABS_MAX_CHARGE
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

View file

@ -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

View file

@ -69,6 +69,7 @@ static void merlin_init(struct device *dev)
* trackpad_state
* kbl_brightness
* kbl_state
* charging_speed
*/
/*
@ -240,6 +241,28 @@ static void merlin_init(struct device *dev)
*/
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 = {

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -29,6 +29,7 @@ config BOARD_STARLABS_LABTOP_KBL
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 @@ config BOARD_STARLABS_STARBOOK_TGL
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 @@ config BOARD_STARLABS_STARBOOK_ADL_COMMON
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

View file

@ -20,6 +20,7 @@ card_reader=Enable
# EC
kbl_timeout=30 seconds
fn_ctrl_swap=Disable
charging_speed=0.5C
# Functions
fn_lock_state=0x1
trackpad_state=0x1

View file

@ -40,6 +40,7 @@ entries
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 @@ enumerations
10 2 High
10 3 On
11 0 1.0C
11 1 0.5C
11 2 0.2C
# -----------------------------------------------------------------
checksums

View file

@ -8,6 +8,7 @@ config BOARD_STARLABS_STARFIGHTER_SERIES
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

View file

@ -16,6 +16,7 @@ pci_hot_plug=Disable
# EC
kbl_timeout=30 seconds
fn_ctrl_swap=Disable
charging_speed=0.5C
# southbridge
power_on_after_fail=Disable
# Functions

View file

@ -36,6 +36,7 @@ entries
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 @@ enumerations
10 2 High
10 3 On
11 0 1.0C
11 1 0.5C
11 2 0.2C
# -----------------------------------------------------------------
checksums

View file

@ -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

View file

@ -13,3 +13,5 @@ wireless=Enable
webcam=Enable
camera=Enable
microphone=Enable
# EC
charging_speed=0.5C

View file

@ -33,6 +33,7 @@ entries
# 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 @@ enumerations
6 1 80%
6 2 60%
7 0 1.0C
7 1 0.5C
7 2 0.2C
# -----------------------------------------------------------------
checksums