From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- roms/u-boot/drivers/button/button-uclass.c | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 roms/u-boot/drivers/button/button-uclass.c (limited to 'roms/u-boot/drivers/button/button-uclass.c') diff --git a/roms/u-boot/drivers/button/button-uclass.c b/roms/u-boot/drivers/button/button-uclass.c new file mode 100644 index 000000000..e06d3eb7d --- /dev/null +++ b/roms/u-boot/drivers/button/button-uclass.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 Philippe Reynes + * + * Based on led-uclass.c + */ + +#include +#include +#include +#include + +int button_get_by_label(const char *label, struct udevice **devp) +{ + struct udevice *dev; + struct uclass *uc; + + uclass_id_foreach_dev(UCLASS_BUTTON, dev, uc) { + struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev); + + /* Ignore the top-level button node */ + if (uc_plat->label && !strcmp(label, uc_plat->label)) + return uclass_get_device_tail(dev, 0, devp); + } + + return -ENODEV; +} + +enum button_state_t button_get_state(struct udevice *dev) +{ + struct button_ops *ops = button_get_ops(dev); + + if (!ops->get_state) + return -ENOSYS; + + return ops->get_state(dev); +} + +UCLASS_DRIVER(button) = { + .id = UCLASS_BUTTON, + .name = "button", + .per_device_plat_auto = sizeof(struct button_uc_plat), +}; -- cgit