aboutsummaryrefslogtreecommitdiff
path: root/src/ec/lenovo/h8/wwan.c
diff options
context:
space:
mode:
authorPatrick Rudolph <siro@das-labor.org>2017-08-13 12:09:54 +0200
committerAlexander Couzens <lynxis@fe80.eu>2017-09-11 23:15:47 +0000
commitb8e325a7140020caf7f0f3bc82a1606c9fa4d15e (patch)
treefdc0cdd6ba2ff31447bb1bdd7f8758c2f533d462 /src/ec/lenovo/h8/wwan.c
parentb77eec82f36206c69b7c6be7c9a2fcadebca756a (diff)
ec/lenovo/h8: Add WWAN detection support
* Add support for detecting WWAN. * Allows to turn off power to WWAN if no card is installed. Add the following devicetree values: * has_wwan_detection Set to one to indicate that the following register are sane. * wwan_gpio_num SB GPIO num to read. * wwan_gpio_lvl SB GPIO level for card to be present (usually zero). Don't enable WWAN power if no card is detected. As there are no devicetree values yet, the new code doesn't have any effect. Change-Id: Ie53275b384c85df8adf71fe79b3d54211c868756 Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/20983 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Alexander Couzens <lynxis@fe80.eu>
Diffstat (limited to 'src/ec/lenovo/h8/wwan.c')
-rw-r--r--src/ec/lenovo/h8/wwan.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/ec/lenovo/h8/wwan.c b/src/ec/lenovo/h8/wwan.c
new file mode 100644
index 0000000000..cf3c8f7cf0
--- /dev/null
+++ b/src/ec/lenovo/h8/wwan.c
@@ -0,0 +1,67 @@
+/*
+ * 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 radio-off pin in WWAN MiniPCIe slot. */
+void h8_wwan_enable(int on)
+{
+ if (on)
+ ec_set_bit(0x3a, 6);
+ else
+ ec_clr_bit(0x3a, 6);
+}
+
+/*
+ * Detect WWAN on supported MBs.
+ */
+bool h8_has_wwan(struct device *dev)
+{
+ struct ec_lenovo_h8_config *conf = dev->chip_info;
+
+ if (!conf->has_wwan_detection) {
+ printk(BIOS_INFO, "H8: WWAN detection not implemented. "
+ "Assuming WWAN installed\n");
+ return true;
+ }
+
+ if (get_gpio(conf->wwan_gpio_num) == conf->wwan_gpio_lvl) {
+ printk(BIOS_INFO, "H8: WWAN installed\n");
+ return true;
+ }
+
+ printk(BIOS_INFO, "H8: WWAN not installed\n");
+ return false;
+}
+
+/*
+ * Return WWAN NVRAM setting.
+ */
+bool h8_wwan_nv_enable(void)
+{
+ u8 val;
+
+ if (get_option(&val, "wwan") != CB_SUCCESS)
+ return true;
+
+ return val;
+}