<p>Furquan Shaikh has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/27640">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">soc/intel/common/block/gpio: Add API for gpio_configure_pads_with_override<br><br>This function adds support for gpio_configure_pads_with_override<br>which:<br>1. Takes as input two GPIO tables -- base config table and override<br>config table<br>2. Configures each pad in base config by first checking if there is a<br>config available for the pad in override config table. If yes, then<br>uses the one from override config table. Else, uses the base config to<br>configure the pad.<br><br>This is done to allow sharing of GPIO tables across baseboard-variants<br>for various boards i.e. Each board can have a base config table which<br>is provided by the baseboard and an optional override config table<br>that can be provided by a variant to configure certain GPIOs<br>differently. It is helpful when the variant GPIO diff list is not very<br>huge compared to the baseboard.<br><br>BUG=b:111743717<br>TEST=Verified that the GPIO config for phaser is same with and without<br>this change.<br><br>Change-Id: I1c5dc72c8368957201ab53d2e8398ff861341a4c<br>Signed-off-by: Furquan Shaikh <furquan@google.com><br>---<br>M src/soc/intel/common/block/gpio/gpio.c<br>M src/soc/intel/common/block/include/intelblocks/gpio.h<br>2 files changed, 52 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/40/27640/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/soc/intel/common/block/gpio/gpio.c b/src/soc/intel/common/block/gpio/gpio.c</span><br><span>index 50a3a02..931fb7f 100644</span><br><span>--- a/src/soc/intel/common/block/gpio/gpio.c</span><br><span>+++ b/src/soc/intel/common/block/gpio/gpio.c</span><br><span>@@ -288,6 +288,43 @@</span><br><span>               gpio_configure_pad(cfg + i);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This functions checks to see if there is an override config present for the</span><br><span style="color: hsl(120, 100%, 40%);">+ * provided pad_config. If no override config is present, then the input config</span><br><span style="color: hsl(120, 100%, 40%);">+ * is returned. Else, it returns the override config.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static const struct pad_config *gpio_get_config(const struct pad_config *c,</span><br><span style="color: hsl(120, 100%, 40%);">+                           const struct pad_config *override_cfg_table,</span><br><span style="color: hsl(120, 100%, 40%);">+                          size_t num)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        size_t i;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (override_cfg_table == NULL)</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%);">+   for (i = 0; i < num; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+                if (c->pad == override_cfg_table[i].pad)</span><br><span style="color: hsl(120, 100%, 40%);">+                   return override_cfg_table + i;</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%);">+   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%);">+void gpio_configure_pads_with_override(const struct pad_config *base_cfg,</span><br><span style="color: hsl(120, 100%, 40%);">+                                     size_t base_num_pads,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 const struct pad_config *override_cfg,</span><br><span style="color: hsl(120, 100%, 40%);">+                                        size_t override_num_pads)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  size_t i;</span><br><span style="color: hsl(120, 100%, 40%);">+     const struct pad_config *c;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ for (i = 0; i < base_num_pads; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+              c = gpio_get_config(base_cfg + i, override_cfg,</span><br><span style="color: hsl(120, 100%, 40%);">+                               override_num_pads);</span><br><span style="color: hsl(120, 100%, 40%);">+           gpio_configure_pad(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%);">+</span><br><span> void *gpio_dwx_address(const gpio_t pad)</span><br><span> {</span><br><span>      /* Calculate Address of DW0 register for given GPIO</span><br><span>diff --git a/src/soc/intel/common/block/include/intelblocks/gpio.h b/src/soc/intel/common/block/include/intelblocks/gpio.h</span><br><span>index 625ebef..4e26db3 100644</span><br><span>--- a/src/soc/intel/common/block/include/intelblocks/gpio.h</span><br><span>+++ b/src/soc/intel/common/block/include/intelblocks/gpio.h</span><br><span>@@ -133,6 +133,21 @@</span><br><span> void gpio_configure_pads(const struct pad_config *cfg, size_t num_pads);</span><br><span> </span><br><span> /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * gpio_configure_pads_with_override accepts as input two GPIO tables:</span><br><span style="color: hsl(120, 100%, 40%);">+ * 1. Base config</span><br><span style="color: hsl(120, 100%, 40%);">+ * 2. Override config</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This function configures raw pads in base config and applies override in</span><br><span style="color: hsl(120, 100%, 40%);">+ * override config if any. Thus, for every GPIO_x in base config, this function</span><br><span style="color: hsl(120, 100%, 40%);">+ * looks up the GPIO in override config and if it is present there, then applies</span><br><span style="color: hsl(120, 100%, 40%);">+ * the configuration from override config.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void gpio_configure_pads_with_override(const struct pad_config *base_cfg,</span><br><span style="color: hsl(120, 100%, 40%);">+                                   size_t base_num_pads,</span><br><span style="color: hsl(120, 100%, 40%);">+                                 const struct pad_config *override_cfg,</span><br><span style="color: hsl(120, 100%, 40%);">+                                        size_t override_num_pads);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span>  * Calculate Address of DW0 register for given GPIO</span><br><span>  */</span><br><span> void *gpio_dwx_address(const gpio_t pad);</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/27640">change 27640</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/27640"/><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: I1c5dc72c8368957201ab53d2e8398ff861341a4c </div>
<div style="display:none"> Gerrit-Change-Number: 27640 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Furquan Shaikh <furquan@google.com> </div>