u-boot/lib
Simon Glass ed3ee5cd06 fdt: Add basic support for decoding GPIO definitions
This adds some support into fdtdec for reading GPIO definitions from
the fdt. We permit up to FDT_GPIO_MAX GPIOs in the system. Each GPIO
is of the form:

gpio-function-name = <phandle gpio_num flags>;

where:

phandle is a pointer to the GPIO node
gpio_num is the number of the GPIO (0 to 223)
flags is a flag, as follows:

   bit    meaning
   0      0=polarity normal, 1=active low (inverted)

An example is:

enable-propounder-gpios = <&gpio 43 0>;

which means that GPIO 43 is used to enable the propounder (setting the
GPIO high), or that you can detect that the propounder is enabled by
checking if the GPIO is high (the fdt does not indicate input/output).

Two main functions are provided:

fdtdec_decode_gpio() reads a GPIO property from an fdt node and decodes it
into a structure.

fdtdec_setup_gpio() sets up the GPIO by calling gpio_request for you.

Both functions can cope with the property being missing, which is taken to
mean that that GPIO function is not available or is not needed.

[For reference, from Stephen Warren <swarren@nvidia.com>. It may be that
we add this extra complexity later if needed:

The correct way to parse such a GPIO property in general is:

* Read the first cell.
* Find the node referenced by the phandle (the controller).
* Ensure property gpio-controller is present in the controller node.
* Read property #gpio-cells from the controller node.
* Extract #gpio-cells from the original property.
* Keep processing more cells from the original property; there may be
multiple GPIOs listed.

According to the binding documentation in the Linux kernel, Samsung
Exynos4 doesn't use this format, and while all other chips do have a
flags cell, about 50% of the controllers indicate the cell is unused.
]

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Warren <twarren@nvidia.com>
2012-03-29 08:12:47 +02:00
..
libfdt libfdt: Implement property iteration functions 2011-07-14 21:10:34 -04:00
lzma GCC4.6: Squash warnings in LzmaTools.c 2011-10-27 23:54:08 +02:00
lzo GCC4.6: Squash warning in lzo1x_decompress.c 2011-10-01 23:34:38 +02:00
zlib zlib: Fix integer cast of pointer 2011-10-28 00:33:38 +02:00
addr_map.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
asm-offsets.c Small coding style fix in lib/asm-offsets.c 2011-01-17 22:55:58 +01:00
bch.c nand: Merge BCH code from Linux nand driver 2012-01-26 16:09:02 -06:00
bzlib.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
bzlib_crctable.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
bzlib_decompress.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
bzlib_huffman.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
bzlib_private.h Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
bzlib_randtable.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
circbuf.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
crc7.c lib: add crc7 from Linux 2011-01-18 23:38:08 +01:00
crc16.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
crc32.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
ctype.c ctype: constify lookup table 2010-11-28 21:58:29 +01:00
display_options.c unify version_string 2011-07-28 17:22:53 +02:00
div64.c Move arch/ppc to arch/powerpc 2010-04-21 23:42:38 +02:00
errno.c Add basic errno support. 2010-09-19 19:29:47 +02:00
fdtdec.c fdt: Add basic support for decoding GPIO definitions 2012-03-29 08:12:47 +02:00
fdtdec_test.c fdt: Add tests for fdtdec 2012-03-29 08:12:47 +02:00
gunzip.c Fix gunzip to work for any gziped uImage size 2011-04-12 22:58:30 +02:00
hashtable.c sandbox: Fix warnings in hashtable.c 2011-11-22 08:40:05 +01:00
ldiv.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
lmb.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
Makefile fdt: Add tests for fdtdec 2012-03-29 08:12:47 +02:00
md5.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
net_utils.c string_to_ip: constify "s" arg 2010-11-28 21:56:39 +01:00
qsort.c Include common.h in qsort.c to fix build warning 2011-12-07 08:39:54 +01:00
rbtree.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
sha1.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
sha256.c Rename lib_generic/ to lib/ 2010-04-13 09:13:04 +02:00
string.c nand: Sanitize ONFI strings. 2012-01-26 16:09:02 -06:00
strmhz.c strmhz: Make hz unsigned to support greater than 2146 MHz clock 2011-03-22 23:34:36 +01:00
time.c bootstage: Define an optional microsecond timer 2012-03-18 21:33:53 +01:00
uuid.c lib: add uuid_str_to_bin for use with bootp and PXE uuid 2011-10-17 22:25:35 +02:00
vsprintf.c vsprintf: Move function documentation into header file 2011-12-17 23:34:01 +01:00