[coreboot-gerrit] Change in coreboot[master]: soc/intel/common/block/gpio: Add API for gpio_configure_pads_with_ove...

Furquan Shaikh (Code Review) gerrit at coreboot.org
Wed Jul 25 23:35:54 CEST 2018


Furquan Shaikh has uploaded this change for review. ( https://review.coreboot.org/27640


Change subject: soc/intel/common/block/gpio: Add API for gpio_configure_pads_with_override
......................................................................

soc/intel/common/block/gpio: Add API for gpio_configure_pads_with_override

This function adds support for gpio_configure_pads_with_override
which:
1. Takes as input two GPIO tables -- base config table and override
config table
2. Configures each pad in base config by first checking if there is a
config available for the pad in override config table. If yes, then
uses the one from override config table. Else, uses the base config to
configure the pad.

This is done to allow sharing of GPIO tables across baseboard-variants
for various boards i.e. Each board can have a base config table which
is provided by the baseboard and an optional override config table
that can be provided by a variant to configure certain GPIOs
differently. It is helpful when the variant GPIO diff list is not very
huge compared to the baseboard.

BUG=b:111743717
TEST=Verified that the GPIO config for phaser is same with and without
this change.

Change-Id: I1c5dc72c8368957201ab53d2e8398ff861341a4c
Signed-off-by: Furquan Shaikh <furquan at google.com>
---
M src/soc/intel/common/block/gpio/gpio.c
M src/soc/intel/common/block/include/intelblocks/gpio.h
2 files changed, 52 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/40/27640/1

diff --git a/src/soc/intel/common/block/gpio/gpio.c b/src/soc/intel/common/block/gpio/gpio.c
index 50a3a02..931fb7f 100644
--- a/src/soc/intel/common/block/gpio/gpio.c
+++ b/src/soc/intel/common/block/gpio/gpio.c
@@ -288,6 +288,43 @@
 		gpio_configure_pad(cfg + i);
 }
 
+/*
+ * This functions checks to see if there is an override config present for the
+ * provided pad_config. If no override config is present, then the input config
+ * is returned. Else, it returns the override config.
+ */
+static const struct pad_config *gpio_get_config(const struct pad_config *c,
+				const struct pad_config *override_cfg_table,
+				size_t num)
+{
+	size_t i;
+
+	if (override_cfg_table == NULL)
+		return c;
+
+	for (i = 0; i < num; i++) {
+		if (c->pad == override_cfg_table[i].pad)
+			return override_cfg_table + i;
+	}
+
+	return c;
+}
+
+void gpio_configure_pads_with_override(const struct pad_config *base_cfg,
+					size_t base_num_pads,
+					const struct pad_config *override_cfg,
+					size_t override_num_pads)
+{
+	size_t i;
+	const struct pad_config *c;
+
+	for (i = 0; i < base_num_pads; i++) {
+		c = gpio_get_config(base_cfg + i, override_cfg,
+				override_num_pads);
+		gpio_configure_pad(c);
+	}
+}
+
 void *gpio_dwx_address(const gpio_t pad)
 {
 	/* Calculate Address of DW0 register for given GPIO
diff --git a/src/soc/intel/common/block/include/intelblocks/gpio.h b/src/soc/intel/common/block/include/intelblocks/gpio.h
index 625ebef..4e26db3 100644
--- a/src/soc/intel/common/block/include/intelblocks/gpio.h
+++ b/src/soc/intel/common/block/include/intelblocks/gpio.h
@@ -133,6 +133,21 @@
 void gpio_configure_pads(const struct pad_config *cfg, size_t num_pads);
 
 /*
+ * gpio_configure_pads_with_override accepts as input two GPIO tables:
+ * 1. Base config
+ * 2. Override config
+ *
+ * This function configures raw pads in base config and applies override in
+ * override config if any. Thus, for every GPIO_x in base config, this function
+ * looks up the GPIO in override config and if it is present there, then applies
+ * the configuration from override config.
+ */
+void gpio_configure_pads_with_override(const struct pad_config *base_cfg,
+					size_t base_num_pads,
+					const struct pad_config *override_cfg,
+					size_t override_num_pads);
+
+/*
  * Calculate Address of DW0 register for given GPIO
  */
 void *gpio_dwx_address(const gpio_t pad);

-- 
To view, visit https://review.coreboot.org/27640
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c5dc72c8368957201ab53d2e8398ff861341a4c
Gerrit-Change-Number: 27640
Gerrit-PatchSet: 1
Gerrit-Owner: Furquan Shaikh <furquan at google.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180725/c3cca9f6/attachment-0001.html>


More information about the coreboot-gerrit mailing list