
Hi Mario,
On 26 April 2016 at 08:08, Mario Six mario.six@gdsys.cc wrote:
Signed-off-by: Mario Six mario.six@gdsys.cc
Please always add a commit message.
drivers/gpio/gpio-uclass.c | 30 ++++++++++++++++++++++++++++++ include/asm-generic/gpio.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+)
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index b58d4e6..16b9648 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -352,6 +352,36 @@ int dm_gpio_set_value(const struct gpio_desc *desc, int value) return 0; }
+int dm_gpio_get_open_drain(struct gpio_desc *desc) +{
struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
int ret;
ret = check_reserved(desc, "get_open_drain");
if (ret)
return ret;
if (ops->set_open_drain)
return ops->get_open_drain(desc->dev, desc->offset);
else
return 0;
-ENOSYS seems better here
+}
+int dm_gpio_set_open_drain(struct gpio_desc *desc, int value) +{
struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
int ret;
ret = check_reserved(desc, "set_open_drain");
if (ret)
return ret;
if (ops->set_open_drain)
ops->set_open_drain(desc->dev, desc->offset, value);
Check return value
return 0;
-ENOSYS here I think, or are you trying to suppress it?
+}
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 68b5f0b..ba65080 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -241,6 +241,8 @@ 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 (*get_open_drain)(struct udevice *dev, unsigned offset);
int (*set_open_drain)(struct udevice *dev, unsigned offset, int value); /** * get_function() Get the GPIO function *
@@ -541,6 +543,33 @@ int dm_gpio_get_value(const struct gpio_desc *desc); int dm_gpio_set_value(const struct gpio_desc *desc, int value);
/**
- dm_gpio_get_open_drain() - Check if open-drain-mode of a GPIO is active
- This checks if open-drain-mode for a GPIO is enabled or not. This method is
- optional; if the driver does not support it, nothing happens when the method
- is called.
Can you include a brief description of what open drain is?
- @desc: GPIO description containing device, offset and flags,
previously returned by gpio_request_by_name()
- @return Value of open drain mode for GPIO (0 for inactive, 1 for active) or
-ve on error
- */
+int dm_gpio_get_open_drain(struct gpio_desc *desc);
+/**
- dm_gpio_set_open_drain() - Switch open-drain-mode of a GPIO on or off
- This enables or disables open-drain-mode for a GPIO. This method is
- optional; if the driver does not support it, nothing happens when the method
- is called.
- @desc: GPIO description containing device, offset and flags,
previously returned by gpio_request_by_name()
- @return 0 if OK, -ve on error
- */
+int dm_gpio_set_open_drain(struct gpio_desc *desc, int value);
+/**
- dm_gpio_set_dir() - Set the direction for a GPIO
- This sets up the direction according tot the provided flags. It will do
-- 2.7.0.GIT
Regards, Simon