[coreboot-gerrit] New patch to review for coreboot: ec/lenovo/h8: move charge priority into own function

Alexander Couzens (lynxis@fe80.eu) gerrit at coreboot.org
Sun Oct 16 07:48:27 CEST 2016


Alexander Couzens (lynxis at fe80.eu) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17035

-gerrit

commit 985b9cee82bc3181cdaf2453f2780091837ddc6d
Author: Alexander Couzens <lynxis at fe80.eu>
Date:   Sun Oct 16 06:55:19 2016 +0200

    ec/lenovo/h8: move charge priority into own function
    
    Change-Id: I53c7cffd0f32f9babc5fb70d5a2440a7d3377602
    Signed-off-by: Alexander Couzens <lynxis at fe80.eu>
---
 src/ec/lenovo/h8/h8.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c
index 943bdd4..bbcbfd0 100644
--- a/src/ec/lenovo/h8/h8.c
+++ b/src/ec/lenovo/h8/h8.c
@@ -79,6 +79,22 @@ 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)
+{
+	if (PRIMARY_BATTERY)
+		ec_set_bit(0x0, 4);
+	else
+		ec_clr_bit(0x0, 4);
+}
+
 static void h8_sticky_fn(int on)
 {
 	if (on)
@@ -287,12 +303,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)



More information about the coreboot-gerrit mailing list