X60/T60: Add option to enable/disable bluetooth
[coreboot.git] / src / ec / lenovo / h8 / h8.c
index 560c39cb872d6ae216a5a19d68aa393ed30cf47a..ecd34b2fe7bfa6ca5b865c7836dcb86510c6e174 100644 (file)
 #include "chip.h"
 #include <pc80/mc146818rtc.h>
 
+static void h8_bluetooth_enable(int on)
+{
+       if (on)
+               ec_set_bit(0x3a, 4);
+       else
+               ec_clr_bit(0x3a, 4);
+}
+
 void h8_trackpoint_enable(int on)
 {
        ec_write(H8_TRACKPOINT_CTRL,
@@ -63,12 +71,12 @@ static void h8_log_ec_version(void)
               fwvh >> 4, fwvh & 0x0f, fwvl >> 4, 0x41 + (fwvl & 0xf));
 }
 
-void h8_set_audio_mute(int on)
+void h8_set_audio_mute(int mute)
 {
-       if (on)
-               ec_clr_bit(0x3a, 0);
+       if (mute)
+               ec_set_bit(0x3a, 0);
        else
-               ec_set_bit(0x3a, 1);
+               ec_clr_bit(0x3a, 0);
 }
 
 void h8_enable_event(int event)
@@ -104,7 +112,7 @@ int h8_ultrabay_device_present(void)
 static void h8_enable(device_t dev)
 {
        struct ec_lenovo_h8_config *conf = dev->chip_info;
-       u8 val;
+       u8 val, tmp;
 
        h8_log_ec_version();
 
@@ -142,6 +150,16 @@ static void h8_enable(device_t dev)
        if (!get_option(&val, "volume"))
                ec_write(H8_VOLUME_CONTROL, val);
 
+
+       if (!get_option(&val, "bluetooth"))
+               h8_bluetooth_enable(val);
+
+       if (!get_option(&val, "first_battery")) {
+               tmp = ec_read(H8_CONFIG3);
+               tmp &= ~(1 << 4);
+               tmp |= (val & 1)<< 4;
+               ec_write(H8_CONFIG3, tmp);
+       }
        h8_set_audio_mute(0);
 }