diff options
author | Che-Liang Chiou <clchiou@chromium.org> | 2011-08-11 17:44:23 +0800 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-29 10:59:28 -0700 |
commit | effbbd5f6438a1bbb40601b052f9291b249f81fc (patch) | |
tree | ecec231a0b35d5f26e1ce9c4b7e4dc16a67ad110 /include/fdt_decode.h | |
parent | c3a491a2ba4d15e787c3ce8e8ab54b49d3e6e079 (diff) |
fdt: expose GPIO decoder to public interface
fdt_decode module is able to decode GPIO configurations (GPIO number,
I/O direction, and polarity). But the GPIO decoder was kept private to
fdt_decode module because GPIOs were generally used to control a larger
device (LCD, for example) and so considering a single GPIO in isolation
usually did not make much sense.
However, we are aware that there are cases that a GPIO is not a part of
any other larger device, but a standalone prober of hardware status. In
these cases, decoding a single GPIO does make sense. Thus, we expose the
GPIO decoder to public interface.
As this patch only changes functions from static to non-static and
function names, I only tested it builds or not.
BUG=none
TEST=build for Aebl successfully
Change-Id: Ic5f19b64f0cf3f64c56adead7c57e480ef24cab8
Reviewed-on: http://gerrit.chromium.org/gerrit/5725
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/fdt_decode.h')
-rw-r--r-- | include/fdt_decode.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/fdt_decode.h b/include/fdt_decode.h index 3ca140bb46..28776d0580 100644 --- a/include/fdt_decode.h +++ b/include/fdt_decode.h @@ -314,6 +314,34 @@ int fdt_decode_next_alias(const void *blob, const char *name, int fdt_decode_get_spi_switch(const void *blob, struct fdt_spi_uart *config); /** + * Decode a single GPIOs from an FDT. + * + * @param blob FDT blob to use + * @param node Node to look at + * @param property Node property name + * @param gpio gpio elements to fill from FDT + * @return 0 if ok, -FDT_ERR_MISSING if the property is missing. + */ +int fdt_decode_gpio(const void *blob, int node, const char *property, + struct fdt_gpio_state *gpio); + +/** + * Decode a list of GPIOs from an FDT. This creates a list of GPIOs with no + * terminating item. + * + * @param blob FDT blob to use + * @param node Node to look at + * @param property Node property name + * @param gpio Array of gpio elements to fill from FDT. This will be + * untouched if either 0 or an error is returned + * @param max_count Maximum number of elements allowed + * @return number of GPIOs read if ok, -FDT_ERR_BADLAYOUT if max_count would + * be exceeded, or -FDT_ERR_MISSING if the property is missing. + */ +int fdt_decode_gpios(const void *blob, int node, const char *property, + struct fdt_gpio_state *gpio, int max_count); + +/** * Set up a GPIO pin according to the provided gpio. This sets it to either * input or output. If an output, then the defined value is assigned. * |