summaryrefslogtreecommitdiff
path: root/src/mainboard/google/octopus/mainboard.c
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2018-08-08 13:30:44 -0700
committerFurquan Shaikh <furquan@google.com>2018-08-12 17:57:51 +0000
commit617fcf393446ab7e1ed311146c145dd654d29c60 (patch)
tree58f4a29eafc1d15eb59731d9c3edaeecec1efb35 /src/mainboard/google/octopus/mainboard.c
parent6cf9402ebb70090fe820f06e52436b899d9c8dec (diff)
mb/google/octopus: Dynamically disable CNVi/PCIe device
This change checks to see if CNVi module is out of reset: 1. If yes, then PCIe device for WiFi is disabled. 2. If no, then CNVi device is disabled. BUG=b:112371978 Change-Id: I6e6cf2e646c897df017913056db87ac0cffa1a8e Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/27961 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Justin TerAvest <teravest@chromium.org>
Diffstat (limited to 'src/mainboard/google/octopus/mainboard.c')
-rw-r--r--src/mainboard/google/octopus/mainboard.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mainboard/google/octopus/mainboard.c b/src/mainboard/google/octopus/mainboard.c
index 5c10d94672..61baa33f4b 100644
--- a/src/mainboard/google/octopus/mainboard.c
+++ b/src/mainboard/google/octopus/mainboard.c
@@ -19,6 +19,8 @@
#include <compiler.h>
#include <console/console.h>
#include <device/device.h>
+#include <device/pci_def.h>
+#include <device/pci_ops.h>
#include <ec/google/chromeec/ec.h>
#include <ec/ec.h>
#include <nhlt.h>
@@ -26,11 +28,28 @@
#include <soc/cpu.h>
#include <soc/gpio.h>
#include <soc/nhlt.h>
+#include <soc/pci_devs.h>
+#include <stdint.h>
#include <string.h>
#include <vendorcode/google/chromeos/chromeos.h>
#include <variant/ec.h>
#include <variant/gpio.h>
+static bool is_cnvi_held_in_reset(void)
+{
+ struct device *dev = dev_find_slot(0, PCH_DEVFN_CNVI);
+ uint32_t reg = pci_read_config32(dev, PCI_VENDOR_ID);
+
+ /*
+ * If vendor/device ID for CNVi reads as 0xffffffff, then it is safe to
+ * assume that it is being held in reset.
+ */
+ if (reg == 0xffffffff)
+ return true;
+
+ return false;
+}
+
static void mainboard_init(void *chip_info)
{
int boardid;
@@ -122,8 +141,30 @@ void __weak variant_update_devtree(struct device *dev)
/* Place holder for common updates. */
}
+/*
+ * Check if CNVi PCI device is released from reset. If yes, then the system is
+ * booting with CNVi module. In this case, the PCIe device for WiFi needs to
+ * be disabled. If CNVi device is held in reset, then disable it.
+ */
+static void wifi_device_update(void)
+{
+ struct device *dev;
+ unsigned int devfn;
+
+ if (is_cnvi_held_in_reset())
+ devfn = PCH_DEVFN_CNVI;
+ else
+ devfn = PCH_DEVFN_PCIE1;
+
+ dev = dev_find_slot(0, devfn);
+ dev->enabled = 0;
+}
+
void mainboard_devtree_update(struct device *dev)
{
+ /* Apply common devtree updates. */
+ wifi_device_update();
+
/* Defer to variant for board-specific updates. */
variant_update_devtree(dev);
}