[PATCH v2 2/8] dm: button: add a driver for button driven by gpio

Neil Armstrong narmstrong at baylibre.com
Tue Jul 21 16:39:42 CEST 2020


On 17/07/2020 14:22, Philippe Reynes wrote:
> Add a simple driver which allows use of buttons attached to GPIOs.
> 
> Reviewed-by: Simon Glass <sjg at chromium.org>
> Signed-off-by: Philippe Reynes <philippe.reynes at softathome.com>
> ---
> Changelog:
> v2:
> - remove useless default in Kconfig
> - re-order include
> - fix condition in button_gpio_remove
> 
>  drivers/button/Kconfig       |   9 ++++
>  drivers/button/Makefile      |   1 +
>  drivers/button/button-gpio.c | 111 +++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 121 insertions(+)
>  create mode 100644 drivers/button/button-gpio.c
> 

[...]

> +
> +static const struct udevice_id button_gpio_ids[] = {
> +	{ .compatible = "button-gpio" },
> +	{ }
> +};
> +
> +U_BOOT_DRIVER(button_gpio) = {
> +	.name		= "button_gpio",
> +	.id		= UCLASS_BUTTON,
> +	.of_match	= button_gpio_ids,
> +	.ops		= &button_gpio_ops,
> +	.priv_auto_alloc_size = sizeof(struct button_gpio_priv),
> +	.bind		= button_gpio_bind,
> +	.probe		= button_gpio_probe,
> +	.remove		= button_gpio_remove,
> +};
> 

Can't you use the gpio-keys/gpio-keys-polled compatible instead of inventing a bindings ?

Neil


More information about the U-Boot mailing list