mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-06-09 23:36:03 +09:00
gpio: add ops to set dir flags
Add the ops for GPIO driver set_dir_flags() to set the dir flags. The user can update the direction and configuration of each GPIO with a only call to dm_gpio_set_dir_flags() or dm_gpio_set_dir() and respecting the configuration provided by device tree (saved in desc->flags). When these optional ops are absent, the gpio uclass use the mandatory ops (direction_output, direction_input, get_value) and desc->flags to manage only the main dir flags: - GPIOD_IS_IN - GPIOD_IS_OUT - GPIOD_IS_OUT_ACTIVE - GPIOD_ACTIVE_LOW Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
d2c07e56ab
commit
8fd9daf036
|
@ -572,11 +572,16 @@ static int _dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & GPIOD_IS_OUT) {
|
/* GPIOD_ are directly managed by driver in set_dir_flags*/
|
||||||
ret = ops->direction_output(dev, desc->offset,
|
if (ops->set_dir_flags) {
|
||||||
GPIOD_FLAGS_OUTPUT(flags));
|
ret = ops->set_dir_flags(dev, desc->offset, flags);
|
||||||
} else if (flags & GPIOD_IS_IN) {
|
} else {
|
||||||
ret = ops->direction_input(dev, desc->offset);
|
if (flags & GPIOD_IS_OUT) {
|
||||||
|
ret = ops->direction_output(dev, desc->offset,
|
||||||
|
GPIOD_FLAGS_OUTPUT(flags));
|
||||||
|
} else if (flags & GPIOD_IS_IN) {
|
||||||
|
ret = ops->direction_input(dev, desc->offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1146,6 +1151,8 @@ static int gpio_post_bind(struct udevice *dev)
|
||||||
ops->get_function += gd->reloc_off;
|
ops->get_function += gd->reloc_off;
|
||||||
if (ops->xlate)
|
if (ops->xlate)
|
||||||
ops->xlate += gd->reloc_off;
|
ops->xlate += gd->reloc_off;
|
||||||
|
if (ops->set_dir_flags)
|
||||||
|
ops->set_dir_flags += gd->reloc_off;
|
||||||
if (ops->get_dir_flags)
|
if (ops->get_dir_flags)
|
||||||
ops->get_dir_flags += gd->reloc_off;
|
ops->get_dir_flags += gd->reloc_off;
|
||||||
|
|
||||||
|
|
|
@ -298,6 +298,22 @@ struct dm_gpio_ops {
|
||||||
int (*xlate)(struct udevice *dev, struct gpio_desc *desc,
|
int (*xlate)(struct udevice *dev, struct gpio_desc *desc,
|
||||||
struct ofnode_phandle_args *args);
|
struct ofnode_phandle_args *args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set_dir_flags() - Set GPIO dir flags
|
||||||
|
*
|
||||||
|
* This function should set up the GPIO configuration according to the
|
||||||
|
* information provide by the direction flags bitfield.
|
||||||
|
*
|
||||||
|
* This method is optional.
|
||||||
|
*
|
||||||
|
* @dev: GPIO device
|
||||||
|
* @offset: GPIO offset within that device
|
||||||
|
* @flags: GPIO configuration to use
|
||||||
|
* @return 0 if OK, -ve on error
|
||||||
|
*/
|
||||||
|
int (*set_dir_flags)(struct udevice *dev, unsigned int offset,
|
||||||
|
ulong flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_dir_flags() - Get GPIO dir flags
|
* get_dir_flags() - Get GPIO dir flags
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user