summaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorEric Nelson <eric@nelint.com>2016-04-24 16:32:40 -0700
committerSimon Glass <sjg@chromium.org>2016-05-17 09:54:43 -0600
commit6c880b7719d73dc4bf4bf828b6341e086e6f5eb6 (patch)
tree986f58750ecdee418484d05add68300556df3e1c /include/asm-generic
parentc0c62d923344d5a68f43259282e68a827318db01 (diff)
downloadblackbird-obmc-uboot-6c880b7719d73dc4bf4bf828b6341e086e6f5eb6.tar.gz
blackbird-obmc-uboot-6c880b7719d73dc4bf4bf828b6341e086e6f5eb6.zip
dm: gpio: add a default gpio xlate routine
Many drivers use a common form of offset + flags for device tree nodes. e.g.: <&gpio1 2 GPIO_ACTIVE_LOW> This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine. This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers. Signed-off-by: Eric Nelson <eric@nelint.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/gpio.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 68b5f0b3c2..2500c10450 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -207,6 +207,16 @@ int gpio_requestf(unsigned gpio, const char *fmt, ...)
struct fdtdec_phandle_args;
/**
+ * gpio_xlate_offs_flags() - implementation for common use of dm_gpio_ops.xlate
+ *
+ * This routine sets the offset field to args[0] and the flags field to
+ * GPIOD_ACTIVE_LOW if the GPIO_ACTIVE_LOW flag is present in args[1].
+ *
+ */
+int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,
+ struct fdtdec_phandle_args *args);
+
+/**
* struct struct dm_gpio_ops - Driver model GPIO operations
*
* Refer to functions above for description. These function largely copy
@@ -258,12 +268,11 @@ struct dm_gpio_ops {
*
* @desc->dev to @dev
* @desc->flags to 0
- * @desc->offset to the value of the first argument in args, if any,
- * otherwise -1 (which is invalid)
+ * @desc->offset to 0
*
- * This method is optional so if the above defaults suit it can be
- * omitted. Typical behaviour is to set up the GPIOD_ACTIVE_LOW flag
- * in desc->flags.
+ * This method is optional and defaults to gpio_xlate_offs_flags,
+ * which will parse offset and the GPIO_ACTIVE_LOW flag in the first
+ * two arguments.
*
* Note that @dev is passed in as a parameter to follow driver model
* uclass conventions, even though it is already available as
OpenPOWER on IntegriCloud