aboutsummaryrefslogtreecommitdiff
path: root/src/soc/intel/common/block
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc/intel/common/block')
-rw-r--r--src/soc/intel/common/block/gpio/Makefile.inc2
-rw-r--r--src/soc/intel/common/block/gpio/gpio.c1
-rw-r--r--src/soc/intel/common/block/gpio/gpio_dev.c28
-rw-r--r--src/soc/intel/common/block/include/intelblocks/gpio.h7
4 files changed, 38 insertions, 0 deletions
diff --git a/src/soc/intel/common/block/gpio/Makefile.inc b/src/soc/intel/common/block/gpio/Makefile.inc
index b0ffee308a..0379e92250 100644
--- a/src/soc/intel/common/block/gpio/Makefile.inc
+++ b/src/soc/intel/common/block/gpio/Makefile.inc
@@ -3,3 +3,5 @@ ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GPIO) += gpio.c
romstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GPIO) += gpio.c
smm-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GPIO) += gpio.c
verstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GPIO) += gpio.c
+
+ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GPIO) += gpio_dev.c
diff --git a/src/soc/intel/common/block/gpio/gpio.c b/src/soc/intel/common/block/gpio/gpio.c
index fb9287c1f7..28e78fb366 100644
--- a/src/soc/intel/common/block/gpio/gpio.c
+++ b/src/soc/intel/common/block/gpio/gpio.c
@@ -2,6 +2,7 @@
#include <assert.h>
#include <console/console.h>
+#include <device/device.h>
#include <intelblocks/gpio.h>
#include <gpio.h>
#include <intelblocks/itss.h>
diff --git a/src/soc/intel/common/block/gpio/gpio_dev.c b/src/soc/intel/common/block/gpio/gpio_dev.c
new file mode 100644
index 0000000000..c47d3a28ff
--- /dev/null
+++ b/src/soc/intel/common/block/gpio/gpio_dev.c
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include <assert.h>
+#include <device/device.h>
+#include <device/gpio.h>
+#include <intelblocks/gpio.h>
+#include <gpio.h>
+
+static struct gpio_operations gpio_ops = {
+ .get = gpio_get,
+ .set = gpio_set,
+ .input_pulldown = gpio_input_pulldown,
+ .input_pullup = gpio_input_pullup,
+ .input = gpio_input,
+ .output = gpio_output,
+};
+
+static struct device_operations block_gpio_ops = {
+ .read_resources = noop_read_resources,
+ .set_resources = noop_set_resources,
+ .ops_gpio = &gpio_ops,
+};
+
+void block_gpio_enable(struct device *dev)
+{
+ assert(dev->path.type == DEVICE_PATH_GPIO);
+ dev->ops = &block_gpio_ops;
+}
diff --git a/src/soc/intel/common/block/include/intelblocks/gpio.h b/src/soc/intel/common/block/include/intelblocks/gpio.h
index 173a383f1e..4c29a0c5ba 100644
--- a/src/soc/intel/common/block/include/intelblocks/gpio.h
+++ b/src/soc/intel/common/block/include/intelblocks/gpio.h
@@ -25,6 +25,7 @@
#ifndef __ACPI__
#include <types.h>
+#include <device/device.h>
/*
* GPIO numbers may not be contiguous and instead will have a different
@@ -222,5 +223,11 @@ void gpi_clear_int_cfg(void);
/* The function performs GPIO Power Management programming. */
void gpio_pm_configure(const uint8_t *misccfg_pm_values, size_t num);
+/*
+ * Set gpio ops of the device to gpio block ops.
+ * Shall be called by all SoCs that use intelblocks/gpio.
+ */
+void block_gpio_enable(struct device *dev);
+
#endif
#endif /* _SOC_INTELBLOCKS_GPIO_H_ */