[coreboot-gerrit] Change in coreboot[master]: ec/lenovo/h8: Add WWAN detection support

Patrick Rudolph (Code Review) gerrit at coreboot.org
Sun Aug 13 17:41:31 CEST 2017


Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/20983


Change subject: ec/lenovo/h8: Add WWAN detection support
......................................................................

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 at das-labor.org>
---
M src/ec/lenovo/h8/Makefile.inc
M src/ec/lenovo/h8/chip.h
M src/ec/lenovo/h8/h8.c
M src/ec/lenovo/h8/h8.h
A src/ec/lenovo/h8/wwan.c
5 files changed, 77 insertions(+), 12 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/83/20983/1

diff --git a/src/ec/lenovo/h8/Makefile.inc b/src/ec/lenovo/h8/Makefile.inc
index e989dee..a02543a 100644
--- a/src/ec/lenovo/h8/Makefile.inc
+++ b/src/ec/lenovo/h8/Makefile.inc
@@ -2,6 +2,7 @@
 
 ramstage-y += h8.c
 ramstage-y += bluetooth.c
+ramstage-y += wwan.c
 smm-y += smm.c
 
 endif
diff --git a/src/ec/lenovo/h8/chip.h b/src/ec/lenovo/h8/chip.h
index d62312d..25512bc 100644
--- a/src/ec/lenovo/h8/chip.h
+++ b/src/ec/lenovo/h8/chip.h
@@ -47,9 +47,13 @@
 	u8 has_power_management_beeps;
 	u8 has_uwb;
 	u8 has_bdc_detection;
+	u8 has_wwan_detection;
 
 	u8 bdc_gpio_num;
 	u8 bdc_gpio_lvl;
+
+	u8 wwan_gpio_num;
+	u8 wwan_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 6f14953..882ac02 100644
--- a/src/ec/lenovo/h8/h8.c
+++ b/src/ec/lenovo/h8/h8.c
@@ -44,15 +44,6 @@
 		ec_clr_bit(0x3a, 5);
 }
 
-/* Controls radio-off pin in WWAN MiniPCIe slot.  */
-static void h8_wwan_enable(int on)
-{
-	if (on)
-		ec_set_bit(0x3a, 6);
-	else
-		ec_clr_bit(0x3a, 6);
-}
-
 /* Controls radio-off pin in UWB MiniPCIe slot.  */
 static void h8_uwb_enable(int on)
 {
@@ -283,9 +274,7 @@
 	val = h8_has_bdc(dev) && h8_bluetooth_nv_enable();
 	h8_bluetooth_enable(val);
 
-	if (get_option(&val, "wwan") != CB_SUCCESS)
-		val = 1;
-
+	val = h8_has_wwan(dev) && h8_wwan_nv_enable();
 	h8_wwan_enable(val);
 
 	if (conf->has_uwb) {
diff --git a/src/ec/lenovo/h8/h8.h b/src/ec/lenovo/h8/h8.h
index 8786fb3..4175463 100644
--- a/src/ec/lenovo/h8/h8.h
+++ b/src/ec/lenovo/h8/h8.h
@@ -35,6 +35,10 @@
 bool h8_bluetooth_nv_enable(void);
 bool h8_has_bdc(struct device *dev);
 
+void h8_wwan_enable(int on);
+bool h8_wwan_nv_enable(void);
+bool h8_has_wwan(struct device *dev);
+
 /* EC registers */
 #define H8_CONFIG0 0x00
 #define H8_CONFIG0_EVENTS_ENABLE	0x02
diff --git a/src/ec/lenovo/h8/wwan.c b/src/ec/lenovo/h8/wwan.c
new file mode 100644
index 0000000..cf3c8f7
--- /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 at 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;
+}

-- 
To view, visit https://review.coreboot.org/20983
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie53275b384c85df8adf71fe79b3d54211c868756
Gerrit-Change-Number: 20983
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <siro at das-labor.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170813/b344eb36/attachment.html>


More information about the coreboot-gerrit mailing list