summaryrefslogtreecommitdiff
path: root/src/ec/lenovo
diff options
context:
space:
mode:
authorPatrick Rudolph <siro@das-labor.org>2017-05-21 08:49:44 +0200
committerMartin Roth <martinroth@google.com>2017-09-06 04:14:25 +0000
commit1194aa8d08938411b3f13ba540dbba97ac58fa13 (patch)
treefeee754ec1c333e905f7ee2aceec8b22f3a53778 /src/ec/lenovo
parent746241f114e851623d2031959a99b06a5102708b (diff)
downloadcoreboot-1194aa8d08938411b3f13ba540dbba97ac58fa13.tar.xz
ec/lenovo/h8: Add BDC detection support
* Add support for detecting BDC. * Allows to turn off power to BDC if no card is installed. * Should fix https://ticket.coreboot.org/issues/99 . Add the following devicetree values: * has_bdc_detection Set to one to indicate that the following register are sane. * bdc_gpio_num SB GPIO num to read. * bdc_gpio_lvl SB GPIO level for card to be present (usually zero). Don't enable BDC power if no card is detected. As there are no devicetree values yet, the new code doesn't have any effect. Change-Id: I506de2eca4b820e6d82de6b2c48a5440462e1db5 Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/19809 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Alexander Couzens <lynxis@fe80.eu>
Diffstat (limited to 'src/ec/lenovo')
-rw-r--r--src/ec/lenovo/h8/Makefile.inc1
-rw-r--r--src/ec/lenovo/h8/bluetooth.c69
-rw-r--r--src/ec/lenovo/h8/chip.h4
-rw-r--r--src/ec/lenovo/h8/h8.c11
-rw-r--r--src/ec/lenovo/h8/h8.h5
5 files changed, 80 insertions, 10 deletions
diff --git a/src/ec/lenovo/h8/Makefile.inc b/src/ec/lenovo/h8/Makefile.inc
index c37a6e1bf7..18aca17fbf 100644
--- a/src/ec/lenovo/h8/Makefile.inc
+++ b/src/ec/lenovo/h8/Makefile.inc
@@ -6,6 +6,7 @@ ramstage-y += panic.c
endif
ramstage-y += h8.c
+ramstage-y += bluetooth.c
smm-y += smm.c
endif
diff --git a/src/ec/lenovo/h8/bluetooth.c b/src/ec/lenovo/h8/bluetooth.c
new file mode 100644
index 0000000000..c3a2555780
--- /dev/null
+++ b/src/ec/lenovo/h8/bluetooth.c
@@ -0,0 +1,69 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2017 Patrick Rudolph <siro@das-labor.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <southbridge/intel/common/gpio.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <ec/acpi/ec.h>
+#include <option.h>
+
+#include "h8.h"
+#include "chip.h"
+
+/*
+ * Controls BDC (Bluetooth daughter card) power.
+ */
+void h8_bluetooth_enable(int on)
+{
+ if (on)
+ ec_set_bit(0x3a, 4);
+ else
+ ec_clr_bit(0x3a, 4);
+}
+
+/*
+ * Detect BDC on supported MBs.
+ */
+bool h8_has_bdc(struct device *dev)
+{
+ struct ec_lenovo_h8_config *conf = dev->chip_info;
+
+ if (!conf->has_bdc_detection) {
+ printk(BIOS_INFO, "H8: BDC detection not implemented. "
+ "Assuming BDC installed\n");
+ return true;
+ }
+
+ if (get_gpio(conf->bdc_gpio_num) == conf->bdc_gpio_lvl) {
+ printk(BIOS_INFO, "H8: BDC installed\n");
+ return true;
+ }
+
+ printk(BIOS_INFO, "H8: BDC not installed\n");
+ return false;
+}
+
+/*
+ * Return BDC NVRAM setting.
+ */
+bool h8_bluetooth_nv_enable(void)
+{
+ u8 val;
+
+ if (get_option(&val, "bluetooth") != CB_SUCCESS)
+ return true;
+
+ return val;
+}
diff --git a/src/ec/lenovo/h8/chip.h b/src/ec/lenovo/h8/chip.h
index bb6eb052a9..d62312d197 100644
--- a/src/ec/lenovo/h8/chip.h
+++ b/src/ec/lenovo/h8/chip.h
@@ -46,6 +46,10 @@ struct ec_lenovo_h8_config {
u8 has_keyboard_backlight;
u8 has_power_management_beeps;
u8 has_uwb;
+ u8 has_bdc_detection;
+
+ u8 bdc_gpio_num;
+ u8 bdc_gpio_lvl;
};
#endif /* EC_LENOVO_H8EC_CHIP_H */
diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c
index 5ea4a2cbec..6f14953ced 100644
--- a/src/ec/lenovo/h8/h8.c
+++ b/src/ec/lenovo/h8/h8.c
@@ -28,14 +28,6 @@
#include "h8.h"
#include "chip.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,
@@ -288,8 +280,7 @@ static void h8_enable(struct device *dev)
if (get_option(&val, "volume") == CB_SUCCESS && !acpi_is_wakeup_s3())
ec_write(H8_VOLUME_CONTROL, val);
- if (get_option(&val, "bluetooth") != CB_SUCCESS)
- val = 1;
+ val = h8_has_bdc(dev) && h8_bluetooth_nv_enable();
h8_bluetooth_enable(val);
if (get_option(&val, "wwan") != CB_SUCCESS)
diff --git a/src/ec/lenovo/h8/h8.h b/src/ec/lenovo/h8/h8.h
index 9d4b186e46..4b7d3a036b 100644
--- a/src/ec/lenovo/h8/h8.h
+++ b/src/ec/lenovo/h8/h8.h
@@ -17,6 +17,7 @@
#define EC_LENOVO_H8_H
#include <stdint.h>
+#include <device/device.h>
void h8_trackpoint_enable(int on);
void h8_wlan_enable(int on);
@@ -30,6 +31,10 @@ void h8_usb_always_on(void);
void h8_mainboard_init_dock (void);
+void h8_bluetooth_enable(int on);
+bool h8_bluetooth_nv_enable(void);
+bool h8_has_bdc(struct device *dev);
+
/* EC registers */
#define H8_CONFIG0 0x00
#define H8_CONFIG0_EVENTS_ENABLE 0x02