diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2016-10-16 06:55:19 +0200 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2016-11-02 18:12:55 +0100 |
commit | c5a6fb805265f53917eef9748dfa8e39f0697b8c (patch) | |
tree | 0b900dff13aa2c97428f1c6d2bd870ae1ebfe75f /src/ec/lenovo | |
parent | f3f4bea6b53cd21823a196096cca4bcb31be4b73 (diff) |
ec/lenovo/h8: move charge priority into own function
Change-Id: I53c7cffd0f32f9babc5fb70d5a2440a7d3377602
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
Reviewed-on: https://review.coreboot.org/17035
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/ec/lenovo')
-rw-r--r-- | src/ec/lenovo/h8/h8.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c index 933a6de4ed..84766d000e 100644 --- a/src/ec/lenovo/h8/h8.c +++ b/src/ec/lenovo/h8/h8.c @@ -79,6 +79,24 @@ static void h8_fn_ctrl_swap(int on) ec_clr_bit(0xce, 4); } +enum battery { + SECONDARY_BATTERY = 0, + PRIMARY_BATTERY = 1, +}; + +/* h8 charge priority. Defines if primary or secondary + * battery is charged first. + * Because NVRAM is complete the otherway around as this register, + * it's inverted by if + */ +static void h8_charge_priority(enum battery battery) +{ + if (battery == PRIMARY_BATTERY) + ec_clr_bit(0x0, 4); + else + ec_set_bit(0x0, 4); +} + static void h8_sticky_fn(int on) { if (on) @@ -187,7 +205,7 @@ struct device_operations h8_dev_ops = { static void h8_enable(struct device *dev) { struct ec_lenovo_h8_config *conf = dev->chip_info; - u8 val, tmp; + u8 val; u8 beepmask0, beepmask1, config1; dev->ops = &h8_dev_ops; @@ -287,12 +305,9 @@ static void h8_enable(struct device *dev) h8_sticky_fn(val); if (get_option(&val, "first_battery") != CB_SUCCESS) - val = 1; + val = PRIMARY_BATTERY; + h8_charge_priority(val); - tmp = ec_read(H8_CONFIG3); - tmp &= ~(1 << 4); - tmp |= (val & 1) << 4; - ec_write(H8_CONFIG3, tmp); h8_set_audio_mute(0); #if !IS_ENABLED(CONFIG_H8_DOCK_EARLY_INIT) |