diff options
author | Julius Werner <jwerner@chromium.org> | 2014-09-24 15:40:49 -0700 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-04-10 11:57:33 +0200 |
commit | eaa9c4596b083ee1d1a48c5e7632abdb5b7e5297 (patch) | |
tree | d3294fcdf788dbd85f84e4fc2806d1443cf575f7 /src/mainboard/google/storm | |
parent | e9e0eec4faa46ff3879c3350000c4a20b9053270 (diff) |
gpio: Extend common GPIO header, simplify function names
We've had gpiolib.h which defines a few common GPIO access functions for
a while, but it wasn't really complete. This patch adds the missing
gpio_output() function, and also renames the unwieldy
gpio_get_in_value() and gpio_set_out_value() to the much easier to
handle gpio_get() and gpio_set(). The header is renamed to the simpler
gpio.h while we're at it (there was never really anything "lib" about
it, and it was presumably just chosen due to the IPQ806x include/
conflict problem that is now resolved).
It also moves the definition of gpio_t into SoC-specific code, so that
different implementations are free to encode their platform-specific
GPIO parameters in those 4 bytes in the most convenient way (such as the
rk3288 with a bitfield struct). Every SoC intending to use this common
API should supply a <soc/gpio.h> that typedefs gpio_t to a type at most
4 bytes in length. Files accessing the API only need to include <gpio.h>
which may pull in additional things (like a gpio_t creation macro) from
<soc/gpio.h> on its own.
For now the API is still only used on non-x86 SoCs. Whether it makes
sense to expand it to x86 as well should be separately evaluated at a
later point (by someone who understands those systems better). Also,
Exynos retains its old, incompatible GPIO API even though it would be a
prime candidate, because it's currently just not worth the effort.
BUG=None
TEST=Compiled on Daisy, Peach_Pit, Nyan_Blaze, Rush_Ryu, Storm and
Veyron_Pinky.
Change-Id: Ieee77373c2bd13d07ece26fa7f8b08be324842fe
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 9e04902ada56b929e3829f2c3b4aeb618682096e
Original-Change-Id: I6c1e7d1e154d9b02288aabedb397e21e1aadfa15
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/220975
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/9400
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/mainboard/google/storm')
-rw-r--r-- | src/mainboard/google/storm/boardid.c | 9 | ||||
-rw-r--r-- | src/mainboard/google/storm/cdp.c | 2 | ||||
-rw-r--r-- | src/mainboard/google/storm/mainboard.c | 13 |
3 files changed, 11 insertions, 13 deletions
diff --git a/src/mainboard/google/storm/boardid.c b/src/mainboard/google/storm/boardid.c index a8dd84439b..878598bf92 100644 --- a/src/mainboard/google/storm/boardid.c +++ b/src/mainboard/google/storm/boardid.c @@ -18,15 +18,15 @@ */ #include <boardid.h> -#include <gpiolib.h> +#include <gpio.h> #include <console/console.h> #include <stdlib.h> /* * Storm boards dedicate to the board ID three GPIOs in tertiary mode: 29, 30 * and 68. On proto0 GPIO68 is used and tied low, so it reads as 'zero' by - * gpio_get_in_tristate_values(), whereas the other two pins are not connected - * and read as 'two'. This results in gpio_get_in_tristate_values() returning + * gpio_get_tristates(), whereas the other two pins are not connected + * and read as 'two'. This results in gpio_get_tristates() returning * 8 on proto0. * * Three tertitiary signals could represent 27 different values. To make @@ -45,8 +45,7 @@ static uint8_t get_board_id(void) gpio_t hw_rev_gpios[] = {29, 30, 68}; int offset = 19; - bid = gpio_get_in_tristate_values(hw_rev_gpios, - ARRAY_SIZE(hw_rev_gpios), 1); + bid = gpio_get_tristates(hw_rev_gpios, ARRAY_SIZE(hw_rev_gpios), 1); bid = (bid + offset) % 27; printk(BIOS_INFO, "Board ID %d\n", bid); diff --git a/src/mainboard/google/storm/cdp.c b/src/mainboard/google/storm/cdp.c index 7e1aeb66ad..78edb26048 100644 --- a/src/mainboard/google/storm/cdp.c +++ b/src/mainboard/google/storm/cdp.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2012 - 2013 The Linux Foundation. All rights reserved.* */ -#include <soc/gpio.h> +#include <gpio.h> #include <soc/cdp.h> #include <types.h> diff --git a/src/mainboard/google/storm/mainboard.c b/src/mainboard/google/storm/mainboard.c index 552f968609..59e7ce7764 100644 --- a/src/mainboard/google/storm/mainboard.c +++ b/src/mainboard/google/storm/mainboard.c @@ -23,9 +23,8 @@ #include <console/console.h> #include <delay.h> #include <device/device.h> -#include <gpiolib.h> +#include <gpio.h> #include <soc/clock.h> -#include <soc/gpio.h> #include <soc/usb.h> #include <string.h> #include <symbols.h> @@ -46,7 +45,7 @@ static void setup_usb(void) #if !CONFIG_BOARD_VARIANT_AP148 gpio_tlmm_config_set(USB_ENABLE_GPIO, FUNC_SEL_GPIO, GPIO_PULL_UP, GPIO_10MA, GPIO_ENABLE); - gpio_set_out_value(USB_ENABLE_GPIO, 1); + gpio_set(USB_ENABLE_GPIO, 1); #endif usb_clock_config(); @@ -86,9 +85,9 @@ static void setup_tpm(void) * make it twice as long. If the output was driven low originally, the * reset pulse will be even longer. */ - gpio_set_out_value(TPM_RESET_GPIO, 0); + gpio_set(TPM_RESET_GPIO, 0); udelay(160); - gpio_set_out_value(TPM_RESET_GPIO, 1); + gpio_set(TPM_RESET_GPIO, 1); } #define SW_RESET_GPIO 26 @@ -106,7 +105,7 @@ static void deassert_sw_reset(void) gpio_tlmm_config_set(SW_RESET_GPIO, FUNC_SEL_GPIO, GPIO_PULL_UP, GPIO_4MA, GPIO_ENABLE); - gpio_set_out_value(SW_RESET_GPIO, 0); + gpio_set(SW_RESET_GPIO, 0); } static void mainboard_init(device_t dev) @@ -148,7 +147,7 @@ static int read_gpio(gpio_t gpio_num) gpio_tlmm_config_set(gpio_num, GPIO_FUNC_DISABLE, GPIO_NO_PULL, GPIO_2MA, GPIO_DISABLE); udelay(10); /* Should be enough to settle. */ - return gpio_get_in_value(gpio_num); + return gpio_get(gpio_num); } void fill_lb_gpios(struct lb_gpios *gpios) |