mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 08:42:12 +02:00
dm: gpio: Add methods for open drain setting
Certain GPIO devices have the capability to switch their GPIOs into open-drain mode, that is, instead of actively driving the output (Push-pull output), the pin is connected to the collector (for a NPN transistor) or the drain (for a MOSFET) of a transistor, respectively. The pin then either forms an open circuit or a connection to ground, depending on the state of the transistor. This patch adds functions to the GPIO uclass to switch GPIOs to open-drain mode on devices that support it. Signed-off-by: Mario Six <mario.six@gdsys.cc> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: York Sun <york.sun@nxp.com>
This commit is contained in:
committed by
York Sun
parent
07d31f8f98
commit
53ecdfb920
@@ -367,6 +367,38 @@ 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 -ENOSYS;
|
||||
}
|
||||
|
||||
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)
|
||||
ret = ops->set_open_drain(desc->dev, desc->offset, value);
|
||||
else
|
||||
return 0; /* feature not supported -> ignore setting */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
|
||||
{
|
||||
struct udevice *dev = desc->dev;
|
||||
|
Reference in New Issue
Block a user