lib/gpio: add pullup & pulldown gpio_base2_value() variants

Provide common implementations for gpio_base2_value() variants
which configure the gpio for internal pullups and pulldowns.

BUG=chrome-os-partner:54949
BRANCH=None
TEST=Built and used on reef for memory config.

Change-Id: I9be8813328e99d28eb4145501450caab25d51f37
Signed-off-by: Aaron Durbin <adurbin@chromuim.org>
Reviewed-on: https://review.coreboot.org/15557
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Aaron Durbin 2016-07-06 22:37:10 -05:00
parent 85d8027628
commit f41ac2298e
2 changed files with 36 additions and 4 deletions

View File

@ -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]. * gpio[]: pin positions to read. gpio[0] is less significant than gpio[1].
* num_gpio: number of pins to read. * 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_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 * Read the value presented by the set of GPIOs, when each pin is interpreted

View File

@ -19,13 +19,10 @@
#include <delay.h> #include <delay.h>
#include <gpio.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; int i, result = 0;
for (i = 0; i < num_gpio; i++)
gpio_input(gpio[i]);
/* Wait until signals become stable */ /* Wait until signals become stable */
udelay(10); udelay(10);
@ -35,6 +32,36 @@ int gpio_base2_value(gpio_t gpio[], int num_gpio)
return result; 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) int _gpio_base3_value(gpio_t gpio[], int num_gpio, int binary_first)
{ {
/* /*