ec/starlabs/merlin: Add support for enabling fast charge

The Lite Mk IV's can enable fast charging, with support up to 100W
via USB-C PD 3.0.

The default for this is disabled, as it can reduce battery life
span. This patch adds the option to enable fast charging, by
writing 0x01 to 0x18 in the EC space.

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Change-Id: Ie01eb59d3f41b242190973fd9c58b1494320c12a
Reviewed-on: https://review.coreboot.org/c/coreboot/+/66298
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Sean Rhodes 2022-07-31 17:35:28 +01:00 committed by Martin Roth
parent 47ee85f4d5
commit 8de7c01e8b
12 changed files with 50 additions and 0 deletions

View File

@ -50,6 +50,13 @@ config EC_STARLABS_FAN
help
Select if the mainboard has a fan.
config EC_STARLABS_FAST_CHARGE
bool
default n
depends on EC_STARLABS_NUVOTON
help
Select if the mainboard supports fast charging.
config EC_STARLABS_MAX_CHARGE
bool
default n

View File

@ -71,6 +71,10 @@
#define CHARGE_80 0xbb
#define CHARGE_60 0xaa
/* Fast Charge Setting */
#define CHARGE_RATE_NORMAL 0x00
#define CHARGE_RATE_FAST 0x01
/* Fan Mode Setting */
#define FAN_NORMAL 0x00
#define FAN_AGGRESSIVE 0xbb

View File

@ -136,6 +136,27 @@ static void merlin_init(struct device *dev)
max_charge,
ARRAY_SIZE(max_charge)));
/*
* Fast Charge
*
* Setting: fast_charge
*
* Values: Normal, Fast
* Default: Normal
*
*/
const uint8_t fast_charge[] = {
CHARGE_RATE_NORMAL,
CHARGE_RATE_FAST
};
if (CONFIG(EC_STARLABS_FAST_CHARGE))
ec_write(ECRAM_FAST_CHARGE,
get_ec_value_from_option("fast_charge",
0,
fast_charge,
ARRAY_SIZE(fast_charge)));
/*
* Fan Mode
*

View File

@ -22,5 +22,6 @@
#define ECRAM_FN_CTRL_REVERSE 0x2d
#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)
#endif

View File

@ -1,5 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <assert.h>
#include <stdint.h>
/*
* EC communication interface for ITE Embedded Controller
*/
@ -19,5 +22,6 @@
#define ECRAM_FN_CTRL_REVERSE 0x22
#define ECRAM_MAX_CHARGE 0x23
#define ECRAM_FAN_MODE 0x24
#define ECRAM_FAST_CHARGE dead_code_t(uint8_t)
#endif

View File

@ -1,5 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <assert.h>
#include <stdint.h>
/*
* EC communication interface for ITE Embedded Controller
*/
@ -19,5 +22,6 @@
#define ECRAM_KBL_STATE 0x18
#define ECRAM_KBL_BRIGHTNESS 0x19
#define ECRAM_FN_LOCK_STATE 0x2c
#define ECRAM_FAST_CHARGE dead_code_t(uint8_t)
#endif

View File

@ -22,5 +22,6 @@
#define ECRAM_FN_CTRL_REVERSE 0x2d
#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)
#endif

View File

@ -22,5 +22,6 @@
#define ECRAM_FN_CTRL_REVERSE 0x13
#define ECRAM_MAX_CHARGE dead_code_t(uint8_t)
#define ECRAM_FAN_MODE dead_code_t(uint8_t)
#define ECRAM_FAST_CHARGE 0x18
#endif

View File

@ -26,6 +26,7 @@ Field (ECF2, ByteAcc, Lock, Preserve)
FLKE, 8, // Function Lock State
KLSE, 8, // Keyboard Backlight State
KLBE, 8, // Keyboard Backlight Brightness
FSCH, 8, // Fast Charge
Offset(0x20),
RCMD, 8, // Send EC command

View File

@ -22,5 +22,6 @@
#define ECRAM_FAN_MODE 0x42
#define ECRAM_FN_CTRL_REVERSE 0x43
#define ECRAM_MAX_CHARGE dead_code_t(uint8_t)
#define ECRAM_FAST_CHARGE dead_code_t(uint8_t)
#endif

View File

@ -19,5 +19,6 @@
#define ECRAM_KBL_TIMEOUT 0x35
#define ECRAM_FAN_MODE 0x50
#define ECRAM_MAX_CHARGE 0x51
#define ECRAM_FAST_CHARGE 0x52
#endif

View File

@ -1,5 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <assert.h>
#include <stdint.h>
/*
* EC communication interface for ITE Embedded Controller
*/
@ -19,5 +22,6 @@
#define ECRAM_FN_CTRL_REVERSE 0x17
#define ECRAM_MAX_CHARGE 0x1a
#define ECRAM_FAN_MODE 0x1b
#define ECRAM_FAST_CHARGE dead_code_t(uint8_t)
#endif