[U-Boot] [PATCH V2 1/4] dm: gpio: extend gpio api by dm_gpio_set_pull()

Przemyslaw Marczak p.marczak at samsung.com
Wed Feb 18 11:51:03 CET 2015


This commits extends:
- dm gpio ops by: 'set_pull' call
- dm gpio uclass by: dm_gpio_set_pull() function

The pull modes are defined by proper enum and can be:
- UP
- DOWN
- NONE
- UNKNOWN

Signed-off-by: Przemyslaw Marczak <p.marczak at samsung.com>
CC: Simon Glass <sjg at chromium.org>
Reviewed-by: Simon Glass <sjg at chromium.org>

---
Changes v2:
- add enum with gpio pull mode
---
 drivers/gpio/gpio-uclass.c | 11 +++++++++++
 include/asm-generic/gpio.h | 22 ++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index a69bbd2..10f600b 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -321,6 +321,17 @@ int dm_gpio_set_value(struct gpio_desc *desc, int value)
 	return 0;
 }
 
+int dm_gpio_set_pull(struct gpio_desc *desc, int pull)
+{
+	int ret;
+
+	ret = check_reserved(desc, "set_pull");
+	if (ret)
+		return ret;
+
+	return gpio_get_ops(desc->dev)->set_pull(desc->dev, desc->offset, pull);
+}
+
 int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
 {
 	struct udevice *dev = desc->dev;
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 3b96b82..b353f80 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -108,6 +108,16 @@ enum gpio_func_t {
 	GPIOF_COUNT,
 };
 
+/* State of a GPIO pull */
+enum gpio_pull_t {
+	GPIOP_DOWN = 0,
+	GPIOP_UP,
+	GPIOP_NONE,
+	GPIOP_UNKNOWN,
+
+	GPIOP_COUNT,
+};
+
 struct udevice;
 
 struct gpio_desc {
@@ -241,6 +251,7 @@ struct dm_gpio_ops {
 				int value);
 	int (*get_value)(struct udevice *dev, unsigned offset);
 	int (*set_value)(struct udevice *dev, unsigned offset, int value);
+	int (*set_pull)(struct udevice *dev, unsigned offset, int pull);
 	/**
 	 * get_function() Get the GPIO function
 	 *
@@ -479,6 +490,7 @@ int gpio_free_list_nodev(struct gpio_desc *desc, int count);
 
 /**
  * dm_gpio_get_value() - Get the value of a GPIO
+
  *
  * This is the driver model version of the existing gpio_get_value() function
  * and should be used instead of that.
@@ -495,6 +507,16 @@ int dm_gpio_get_value(struct gpio_desc *desc);
 int dm_gpio_set_value(struct gpio_desc *desc, int value);
 
 /**
+ * dm_gpio_set_pull() - Set the pull-up/down value of a GPIO
+ *
+ * @desc:	GPIO description containing device, offset and flags,
+ *		previously returned by gpio_request_by_name()
+ * @pull:	GPIO pull value - one of enum gpio_pull_t
+ * @return 0 on success or -ve on error
+*/
+int dm_gpio_set_pull(struct gpio_desc *desc, int pull);
+
+/**
  * dm_gpio_set_dir() - Set the direction for a GPIO
  *
  * This sets up the direction according tot the provided flags. It will do
-- 
1.9.1



More information about the U-Boot mailing list