<p>Furquan Shaikh has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/27961">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">mb/google/octopus: Dynamically disable CNVi/PCIe device<br><br>This change checks to see if CNVi module is out of reset:<br>1. If yes, then PCIe device for WiFi is disabled.<br>2. If no, then CNVi device is disabled.<br><br>BUG=b:112371978<br><br>Change-Id: I6e6cf2e646c897df017913056db87ac0cffa1a8e<br>Signed-off-by: Furquan Shaikh <furquan@google.com><br>---<br>M src/mainboard/google/octopus/mainboard.c<br>1 file changed, 28 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/27961/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/mainboard/google/octopus/mainboard.c b/src/mainboard/google/octopus/mainboard.c</span><br><span>index 5c10d94..344596f 100644</span><br><span>--- a/src/mainboard/google/octopus/mainboard.c</span><br><span>+++ b/src/mainboard/google/octopus/mainboard.c</span><br><span>@@ -19,6 +19,8 @@</span><br><span> #include <compiler.h></span><br><span> #include <console/console.h></span><br><span> #include <device/device.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <device/pci_def.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <device/pci_ops.h></span><br><span> #include <ec/google/chromeec/ec.h></span><br><span> #include <ec/ec.h></span><br><span> #include <nhlt.h></span><br><span>@@ -26,6 +28,7 @@</span><br><span> #include <soc/cpu.h></span><br><span> #include <soc/gpio.h></span><br><span> #include <soc/nhlt.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <soc/pci_devs.h></span><br><span> #include <string.h></span><br><span> #include <vendorcode/google/chromeos/chromeos.h></span><br><span> #include <variant/ec.h></span><br><span>@@ -122,8 +125,33 @@</span><br><span>   /* Place holder for common updates. */</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Check if CNVi PCI device is released from reset. If yes, then the system is</span><br><span style="color: hsl(120, 100%, 40%);">+ * booting with CNVi module. In this case, the PCIe device for WiFi needs to</span><br><span style="color: hsl(120, 100%, 40%);">+ * be disabled. If CNVi device is held in reset, then disable it.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static void wifi_device_update(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    struct device *dev = dev_find_slot(0, PCH_DEVFN_CNVI);</span><br><span style="color: hsl(120, 100%, 40%);">+        uint32_t reg = pci_read_config32(dev, PCI_VENDOR_ID);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * If vendor/device ID for CNVi reads as 0xffffffff, then it is safe to</span><br><span style="color: hsl(120, 100%, 40%);">+        * assume that it is being held in reset.</span><br><span style="color: hsl(120, 100%, 40%);">+      */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (reg == 0xffffffff)</span><br><span style="color: hsl(120, 100%, 40%);">+                dev->enabled = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+  else {</span><br><span style="color: hsl(120, 100%, 40%);">+                dev = dev_find_slot(0, PCH_DEVFN_PCIE1);</span><br><span style="color: hsl(120, 100%, 40%);">+              dev->enabled = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> void mainboard_devtree_update(struct device *dev)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+      /* Apply common devtree updates. */</span><br><span style="color: hsl(120, 100%, 40%);">+   wifi_device_update();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>      /* Defer to variant for board-specific updates. */</span><br><span>   variant_update_devtree(dev);</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/27961">change 27961</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/27961"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I6e6cf2e646c897df017913056db87ac0cffa1a8e </div>
<div style="display:none"> Gerrit-Change-Number: 27961 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Furquan Shaikh <furquan@google.com> </div>