<p>Justin TerAvest has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/28071">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">mb/google/octopus/var/bobba: Update GPIO config for bobba bid >= 1<br><br>This change updates GPIO configuration for bobba boards with id >= 1<br>This follows the same model as fleex:<br>a. Dynamically update touchscreen power enable GPIO in devicetree.<br>b. Provide default and bid0 tables for GPIO configuration in ramstage.<br>c. Configure WLAN enable GPIO differently in bootblock based on<br>boardid.<br><br>BUG=b:112354568<br>TEST=Built firmware for bobba<br><br>Change-Id: Id4ee4a1815e16ddfe60ed268688a8aaf4fb75579<br>Signed-off-by: Justin TerAvest <teravest@chromium.org><br>---<br>A src/mainboard/google/octopus/variants/bobba/Makefile.inc<br>A src/mainboard/google/octopus/variants/bobba/gpio.c<br>A src/mainboard/google/octopus/variants/bobba/variant.c<br>3 files changed, 172 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/71/28071/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/mainboard/google/octopus/variants/bobba/Makefile.inc b/src/mainboard/google/octopus/variants/bobba/Makefile.inc</span><br><span>new file mode 100644</span><br><span>index 0000000..d54ed40</span><br><span>--- /dev/null</span><br><span>+++ b/src/mainboard/google/octopus/variants/bobba/Makefile.inc</span><br><span>@@ -0,0 +1,4 @@</span><br><span style="color: hsl(120, 100%, 40%);">+bootblock-y += gpio.c</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ramstage-y += variant.c</span><br><span style="color: hsl(120, 100%, 40%);">+ramstage-y += gpio.c</span><br><span>diff --git a/src/mainboard/google/octopus/variants/bobba/gpio.c b/src/mainboard/google/octopus/variants/bobba/gpio.c</span><br><span>new file mode 100644</span><br><span>index 0000000..4b9b7b2</span><br><span>--- /dev/null</span><br><span>+++ b/src/mainboard/google/octopus/variants/bobba/gpio.c</span><br><span>@@ -0,0 +1,95 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright 2018 Google LLC.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</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%);">+#include <baseboard/gpio.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <baseboard/variants.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <boardid.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <gpio.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <soc/gpio.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static const struct pad_config default_override_table[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+   PAD_NC(GPIO_104, UP_20K),</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* CAM_SOC_EC_SYNC */</span><br><span style="color: hsl(120, 100%, 40%);">+ PAD_CFG_GPI_APIC_IOS(GPIO_134, NONE, DEEP, EDGE_SINGLE, INVERT, TxDRxE,</span><br><span style="color: hsl(120, 100%, 40%);">+                            DISPUPD),</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      /* EN_PP3300_TOUCHSCREEN */</span><br><span style="color: hsl(120, 100%, 40%);">+   PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_146, 0, DEEP, NONE, Tx0RxDCRx0,</span><br><span style="color: hsl(120, 100%, 40%);">+                                  DISPUPD),</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      /* EN_PP3300_WLAN_L */</span><br><span style="color: hsl(120, 100%, 40%);">+        PAD_CFG_GPO(GPIO_178, 0, DEEP),</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%);">+const struct pad_config *variant_override_gpio_table(size_t *num)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   const struct pad_config *c;</span><br><span style="color: hsl(120, 100%, 40%);">+   switch (board_id()) {</span><br><span style="color: hsl(120, 100%, 40%);">+ case 0:</span><br><span style="color: hsl(120, 100%, 40%);">+       case UNDEFINED_STRAPPING_ID:</span><br><span style="color: hsl(120, 100%, 40%);">+          *num = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+             break;</span><br><span style="color: hsl(120, 100%, 40%);">+        default:</span><br><span style="color: hsl(120, 100%, 40%);">+              c = default_override_table;</span><br><span style="color: hsl(120, 100%, 40%);">+           *num = ARRAY_SIZE(default_override_table);</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     return c;</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%);">+/* GPIOs needed prior to ramstage. */</span><br><span style="color: hsl(120, 100%, 40%);">+static const struct pad_config early_gpio_table[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+  /* PCH_WP_OD */</span><br><span style="color: hsl(120, 100%, 40%);">+       PAD_CFG_GPI(GPIO_190, NONE, DEEP),</span><br><span style="color: hsl(120, 100%, 40%);">+    /* H1_PCH_INT_ODL */</span><br><span style="color: hsl(120, 100%, 40%);">+  PAD_CFG_GPI_APIC_IOS(GPIO_63, NONE, DEEP, EDGE_SINGLE, INVERT, TxDRxE,</span><br><span style="color: hsl(120, 100%, 40%);">+                             DISPUPD),</span><br><span style="color: hsl(120, 100%, 40%);">+        /* H1_SLAVE_SPI_CLK_R */</span><br><span style="color: hsl(120, 100%, 40%);">+      PAD_CFG_NF(GPIO_79, NONE, DEEP, NF1),</span><br><span style="color: hsl(120, 100%, 40%);">+ /* H1_SLAVE_SPI_CS_L_R */</span><br><span style="color: hsl(120, 100%, 40%);">+     PAD_CFG_NF(GPIO_80, NONE, DEEP, NF1),</span><br><span style="color: hsl(120, 100%, 40%);">+ /* H1_SLAVE_SPI_MISO */</span><br><span style="color: hsl(120, 100%, 40%);">+       PAD_CFG_NF(GPIO_82, NONE, DEEP, NF1),</span><br><span style="color: hsl(120, 100%, 40%);">+ /* H1_SLAVE_SPI_MOSI_R */</span><br><span style="color: hsl(120, 100%, 40%);">+     PAD_CFG_NF(GPIO_83, NONE, DEEP, NF1),</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       /* WLAN_PE_RST */</span><br><span style="color: hsl(120, 100%, 40%);">+     PAD_CFG_GPO(GPIO_164, 0, DEEP),</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%);">+     * ESPI_IO1 acts as ALERT# (which is open-drain) and requies a weak</span><br><span style="color: hsl(120, 100%, 40%);">+    * pull-up for proper operation. Since there is no external pull present</span><br><span style="color: hsl(120, 100%, 40%);">+       * on this platform, configure an internal weak pull-up.</span><br><span style="color: hsl(120, 100%, 40%);">+       */</span><br><span style="color: hsl(120, 100%, 40%);">+   PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_151, UP_20K, DEEP, NF2, HIZCRx1,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 ENPU),</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%);">+const struct pad_config *variant_early_gpio_table(size_t *num)</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%);">+     * This is a hack to configure EN_PP3300_WLAN based on board id. Once</span><br><span style="color: hsl(120, 100%, 40%);">+  * board id 0 is deprecated, we can get rid of this.</span><br><span style="color: hsl(120, 100%, 40%);">+   */</span><br><span style="color: hsl(120, 100%, 40%);">+   uint32_t bid = board_id();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if (bid == UNDEFINED_STRAPPING_ID || bid < 1)</span><br><span style="color: hsl(120, 100%, 40%);">+              gpio_output(GPIO_178, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+     else</span><br><span style="color: hsl(120, 100%, 40%);">+          gpio_output(GPIO_178, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   *num = ARRAY_SIZE(early_gpio_table);</span><br><span style="color: hsl(120, 100%, 40%);">+  return early_gpio_table;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/mainboard/google/octopus/variants/bobba/variant.c b/src/mainboard/google/octopus/variants/bobba/variant.c</span><br><span>new file mode 100644</span><br><span>index 0000000..1ead5e2</span><br><span>--- /dev/null</span><br><span>+++ b/src/mainboard/google/octopus/variants/bobba/variant.c</span><br><span>@@ -0,0 +1,73 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright 2018 Google LLC.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</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%);">+#include <arch/acpi_device.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <baseboard/variants.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <boardid.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <device/device.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <drivers/i2c/generic/chip.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <drivers/i2c/hid/chip.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <soc/gpio.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <soc/pci_devs.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <string.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+extern struct chip_operations drivers_i2c_generic_ops;</span><br><span style="color: hsl(120, 100%, 40%);">+extern struct chip_operations drivers_i2c_hid_ops;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void variant_update_devtree(struct device *dev)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   uint32_t bid;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct device *touchscreen_i2c_host;</span><br><span style="color: hsl(120, 100%, 40%);">+  struct device *child;</span><br><span style="color: hsl(120, 100%, 40%);">+ const struct bus *children_bus;</span><br><span style="color: hsl(120, 100%, 40%);">+       static const struct acpi_gpio new_enable_gpio =</span><br><span style="color: hsl(120, 100%, 40%);">+               ACPI_GPIO_OUTPUT_ACTIVE_HIGH(GPIO_146);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     bid = board_id();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* Nothing to update. */</span><br><span style="color: hsl(120, 100%, 40%);">+      if (bid == UNDEFINED_STRAPPING_ID || bid < 1)</span><br><span style="color: hsl(120, 100%, 40%);">+              return;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     touchscreen_i2c_host = dev_find_slot(0, PCH_DEVFN_I2C7);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    if (touchscreen_i2c_host == NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+             return;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     children_bus = touchscreen_i2c_host->link_list;</span><br><span style="color: hsl(120, 100%, 40%);">+    child = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       /* Find all children on bus to update touchscreen enable gpio. */</span><br><span style="color: hsl(120, 100%, 40%);">+     while ((child = dev_bus_each_child(children_bus, child)) != NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+           struct drivers_i2c_generic_config *cfg;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+             /* No configration to change. */</span><br><span style="color: hsl(120, 100%, 40%);">+              if (child->chip_info == NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+                      continue;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           if (child->chip_ops == &drivers_i2c_generic_ops)</span><br><span style="color: hsl(120, 100%, 40%);">+                       cfg = child->chip_info;</span><br><span style="color: hsl(120, 100%, 40%);">+            else if (child->chip_ops == &drivers_i2c_hid_ops) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    struct drivers_i2c_hid_config *hid_cfg;</span><br><span style="color: hsl(120, 100%, 40%);">+                       hid_cfg = child->chip_info;</span><br><span style="color: hsl(120, 100%, 40%);">+                        cfg = &hid_cfg->generic;</span><br><span style="color: hsl(120, 100%, 40%);">+               } else</span><br><span style="color: hsl(120, 100%, 40%);">+                        continue;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           /* Update the enable gpio. */</span><br><span style="color: hsl(120, 100%, 40%);">+         memcpy(&cfg->enable_gpio, &new_enable_gpio,</span><br><span style="color: hsl(120, 100%, 40%);">+                        sizeof(new_enable_gpio));</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/28071">change 28071</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/28071"/><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: Id4ee4a1815e16ddfe60ed268688a8aaf4fb75579 </div>
<div style="display:none"> Gerrit-Change-Number: 28071 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Justin TerAvest <teravest@chromium.org> </div>