diff options
author | Andrew Jeffery <andrew@aj.id.au> | 2022-01-31 13:54:05 +1030 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-04-08 15:17:23 -0400 |
commit | 34be6968c3570d8e03fcafcd60c02f315b8f4602 (patch) | |
tree | fcf1c015718882b32986a9f650867b6eb4f28722 /include | |
parent | 965b989fb6cfdca194a65b7bf1f41483afbc2fd0 (diff) |
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] https://github.com/devicetree-org/dt-schema/blob/3c35bfee83c2e38e2ae7af5f83eb89ca94a521e8/dtschema/schemas/gpio/gpio.yaml#L17
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/gpio.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index adc19e9765..81f63f06f1 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -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 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 * |