mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-13 20:36:02 +01:00
gpio: Add gpio_request_by_line_name()
Add support for the upstream gpio-line-names property already described
in the common GPIO binding document[1]. The ability to search for a line
name allows boards to lift the implementation of common GPIO behaviours
away from specific line indexes on a GPIO controller.
[1] 3c35bfee83/dtschema/schemas/gpio/gpio.yaml (L17)
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
This commit is contained in:
parent
965b989fb6
commit
34be6968c3
@ -1187,6 +1187,32 @@ int gpio_request_by_name(struct udevice *dev, const char *list_name, int index,
|
|||||||
index, desc, flags, index > 0, NULL);
|
index, desc, flags, index > 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gpio_request_by_line_name(struct udevice *dev, const char *line_name,
|
||||||
|
struct gpio_desc *desc, int flags)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = dev_read_stringlist_search(dev, "gpio-line-names", line_name);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
desc->dev = dev;
|
||||||
|
desc->offset = ret;
|
||||||
|
desc->flags = 0;
|
||||||
|
|
||||||
|
ret = dm_gpio_request(desc, line_name);
|
||||||
|
if (ret) {
|
||||||
|
debug("%s: dm_gpio_requestf failed\n", __func__);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = dm_gpio_set_dir_flags(desc, flags | desc->flags);
|
||||||
|
if (ret)
|
||||||
|
debug("%s: dm_gpio_set_dir failed\n", __func__);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int gpio_request_list_by_name_nodev(ofnode node, const char *list_name,
|
int gpio_request_list_by_name_nodev(ofnode node, const char *list_name,
|
||||||
struct gpio_desc *desc, int max_count,
|
struct gpio_desc *desc, int max_count,
|
||||||
int flags)
|
int flags)
|
||||||
|
@ -579,6 +579,25 @@ int gpio_claim_vector(const int *gpio_num_array, const char *fmt);
|
|||||||
int gpio_request_by_name(struct udevice *dev, const char *list_name,
|
int gpio_request_by_name(struct udevice *dev, const char *list_name,
|
||||||
int index, struct gpio_desc *desc, int flags);
|
int index, struct gpio_desc *desc, int flags);
|
||||||
|
|
||||||
|
/* gpio_request_by_line_name - Locate and request a GPIO by line name
|
||||||
|
*
|
||||||
|
* Request a GPIO using the offset of the provided line name in the
|
||||||
|
* gpio-line-names property found in the OF node of the GPIO udevice.
|
||||||
|
*
|
||||||
|
* This allows boards to implement common behaviours using GPIOs while not
|
||||||
|
* requiring specific GPIO offsets be used.
|
||||||
|
*
|
||||||
|
* @dev: An instance of a GPIO controller udevice
|
||||||
|
* @line_name: The name of the GPIO (e.g. "bmc-secure-boot")
|
||||||
|
* @desc: A GPIO descriptor that is populated with the requested GPIO
|
||||||
|
* upon return
|
||||||
|
* @flags: The GPIO settings apply to the request
|
||||||
|
* @return 0 if the named line was found and requested successfully, or a
|
||||||
|
* negative error code if the GPIO cannot be found or the request failed.
|
||||||
|
*/
|
||||||
|
int gpio_request_by_line_name(struct udevice *dev, const char *line_name,
|
||||||
|
struct gpio_desc *desc, int flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gpio_request_list_by_name() - Request a list of GPIOs
|
* gpio_request_list_by_name() - Request a list of GPIOs
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user