@@ -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;
@@ -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