From 617fcf393446ab7e1ed311146c145dd654d29c60 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Wed, 8 Aug 2018 13:30:44 -0700 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/27961 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Justin TerAvest --- src/mainboard/google/octopus/mainboard.c | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) 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 #include #include +#include +#include #include #include #include @@ -26,11 +28,28 @@ #include #include #include +#include +#include #include #include #include #include +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); }