summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gpio.h5
-rw-r--r--src/lib/gpio.c35
2 files changed, 36 insertions, 4 deletions
diff --git a/src/include/gpio.h b/src/include/gpio.h
index 69a0828f58..3a8951ca73 100644
--- a/src/include/gpio.h
+++ b/src/include/gpio.h
@@ -56,8 +56,13 @@ uint16_t gpio_acpi_pin(gpio_t gpio);
*
* gpio[]: pin positions to read. gpio[0] is less significant than gpio[1].
* num_gpio: number of pins to read.
+ *
+ * There are also pulldown and pullup variants which default each gpio to
+ * be configured with an internal pulldown and pullup, respectively.
*/
int gpio_base2_value(gpio_t gpio[], int num_gpio);
+int gpio_pulldown_base2_value(gpio_t gpio[], int num_gpio);
+int gpio_pullup_base2_value(gpio_t gpio[], int num_gpio);
/*
* Read the value presented by the set of GPIOs, when each pin is interpreted
diff --git a/src/lib/gpio.c b/src/lib/gpio.c
index 81d6f6bbad..03cc455a70 100644
--- a/src/lib/gpio.c
+++ b/src/lib/gpio.c
@@ -19,13 +19,10 @@
#include <delay.h>
#include <gpio.h>
-int gpio_base2_value(gpio_t gpio[], int num_gpio)
+static int _gpio_base2_value(gpio_t gpio[], int num_gpio)
{
int i, result = 0;
- for (i = 0; i < num_gpio; i++)
- gpio_input(gpio[i]);
-
/* Wait until signals become stable */
udelay(10);
@@ -35,6 +32,36 @@ int gpio_base2_value(gpio_t gpio[], int num_gpio)
return result;
}
+int gpio_base2_value(gpio_t gpio[], int num_gpio)
+{
+ int i;
+
+ for (i = 0; i < num_gpio; i++)
+ gpio_input(gpio[i]);
+
+ return _gpio_base2_value(gpio, num_gpio);
+}
+
+int gpio_pulldown_base2_value(gpio_t gpio[], int num_gpio)
+{
+ int i;
+
+ for (i = 0; i < num_gpio; i++)
+ gpio_input_pulldown(gpio[i]);
+
+ return _gpio_base2_value(gpio, num_gpio);
+}
+
+int gpio_pullup_base2_value(gpio_t gpio[], int num_gpio)
+{
+ int i;
+
+ for (i = 0; i < num_gpio; i++)
+ gpio_input_pullup(gpio[i]);
+
+ return _gpio_base2_value(gpio, num_gpio);
+}
+
int _gpio_base3_value(gpio_t gpio[], int num_gpio, int binary_first)
{
/*