From patchwork Mon Jul 13 12:56:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe REYNES X-Patchwork-Id: 1327949 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=softathome.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B53Yl3s8lz9sQt for ; Mon, 13 Jul 2020 22:56:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AE9FB80404; Mon, 13 Jul 2020 14:56:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id A360B819A0; Mon, 13 Jul 2020 14:56:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from vrout30.yaziba.net (vrout30-bl2.yaziba.net [185.56.204.57]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AC6F480404 for ; Mon, 13 Jul 2020 14:56:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=philippe.reynes@softathome.com Received: from mtaout20.int.yaziba.net (mtaout20.int.yaziba.net [10.4.20.37]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout30.yaziba.net (mx10.yaziba.net) with ESMTPS id DFB8852010; Mon, 13 Jul 2020 14:56:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mtaout20.int.yaziba.net (Postfix) with ESMTP id 01FBB160324; Mon, 13 Jul 2020 14:56:15 +0200 (CEST) Received: from mtaout20.int.yaziba.net ([127.0.0.1]) by localhost (mtaout20.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id yJ3FQPPfg-94; Mon, 13 Jul 2020 14:56:14 +0200 (CEST) Received: from sahnlpt0333.softathome.com (lfbn-idf3-1-660-251.w86-252.abo.wanadoo.fr [86.252.230.251]) by mtaout20.int.yaziba.net (Postfix) with ESMTPSA id D6E77160308; Mon, 13 Jul 2020 14:56:14 +0200 (CEST) From: Philippe Reynes To: sjg@chromium.org Cc: u-boot@lists.denx.de, Philippe Reynes Subject: [PATCH 1/7] dm: button: add an uclass for button Date: Mon, 13 Jul 2020 14:56:06 +0200 Message-Id: <1594644972-2588-1-git-send-email-philippe.reynes@softathome.com> X-Mailer: git-send-email 2.7.4 X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: 0 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgeduiedrvdekgdehlecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofestddtredtredttdenucfhrhhomheprfhhihhlihhpphgvucftvgihnhgvshcuoehphhhilhhiphhpvgdrrhgvhihnvghssehsohhfthgrthhhohhmvgdrtghomheqnecuggftrfgrthhtvghrnhepuefgleejvdetgeevveejheeujeevtdefteevffeivdelgedtiefhleekgfdtffeknecukfhppeekiedrvdehvddrvdeftddrvdehudenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Add a new uclass for button that implements two functions: - button_get_by_label - button_get_status Signed-off-by: Philippe Reynes Reviewed-by: Simon Glass --- drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/button/Kconfig | 12 ++++++++++ drivers/button/Makefile | 5 ++++ drivers/button/button-uclass.c | 47 +++++++++++++++++++++++++++++++++++++ include/button.h | 53 ++++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + 7 files changed, 121 insertions(+) create mode 100644 drivers/button/Kconfig create mode 100644 drivers/button/Makefile create mode 100644 drivers/button/button-uclass.c create mode 100644 include/button.h diff --git a/drivers/Kconfig b/drivers/Kconfig index e34a227..3cb05aa 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -14,6 +14,8 @@ source "drivers/block/Kconfig" source "drivers/bootcount/Kconfig" +source "drivers/button/Kconfig" + source "drivers/cache/Kconfig" source "drivers/clk/Kconfig" diff --git a/drivers/Makefile b/drivers/Makefile index 94e8c5d..727a713 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0+ +obj-$(CONFIG_$(SPL_TPL_)BUTTON) += button/ obj-$(CONFIG_$(SPL_TPL_)CACHE) += cache/ obj-$(CONFIG_$(SPL_TPL_)CLK) += clk/ obj-$(CONFIG_$(SPL_TPL_)DM) += core/ diff --git a/drivers/button/Kconfig b/drivers/button/Kconfig new file mode 100644 index 0000000..8301858 --- /dev/null +++ b/drivers/button/Kconfig @@ -0,0 +1,12 @@ +menu "Button Support" + +config BUTTON + bool "Enable button support" + depends on DM + help + Many boards have buttons which can be used to change behaviour (reset, ...). + U-Boot provides a uclass API to implement this feature. Button drivers + can provide access to board-specific buttons. Use of the device tree + for configuration is encouraged. + +endmenu diff --git a/drivers/button/Makefile b/drivers/button/Makefile new file mode 100644 index 0000000..0b4c128 --- /dev/null +++ b/drivers/button/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Philippe Reynes + +obj-$(CONFIG_BUTTON) += button-uclass.o diff --git a/drivers/button/button-uclass.c b/drivers/button/button-uclass.c new file mode 100644 index 0000000..d6cda78 --- /dev/null +++ b/drivers/button/button-uclass.c @@ -0,0 +1,47 @@ +// 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; + int ret; + + ret = uclass_get(UCLASS_BUTTON, &uc); + if (ret) + return ret; + uclass_foreach_dev(dev, uc) { + struct button_uc_plat *uc_plat = dev_get_uclass_platdata(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_platdata_auto_alloc_size = sizeof(struct button_uc_plat), +}; diff --git a/include/button.h b/include/button.h new file mode 100644 index 0000000..333fc23 --- /dev/null +++ b/include/button.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2020 Philippe Reynes + */ + +#ifndef __BUTTON_H +#define __BUTTON_H + +/** + * struct button_uc_plat - Platform data the uclass stores about each device + * + * @label: Button label + */ +struct button_uc_plat { + const char *label; +}; + +enum button_state_t { + BUTTON_OFF = 0, + BUTTON_ON = 1, + BUTTON_COUNT, +}; + +struct button_ops { + /** + * get_state() - get the state of a button + * + * @dev: button device to change + * @return button state button_state_t, or -ve on error + */ + enum button_state_t (*get_state)(struct udevice *dev); +}; + +#define button_get_ops(dev) ((struct button_ops *)(dev)->driver->ops) + +/** + * button_get_by_label() - Find a button device by label + * + * @label: button label to look up + * @devp: Returns the associated device, if found + * @return 0 if found, -ENODEV if not found, other -ve on error + */ +int button_get_by_label(const char *label, struct udevice **devp); + +/** + * button_get_state() - get the state of a button + * + * @dev: button device to change + * @return button state button_state_t, or -ve on error + */ +enum button_state_t button_get_state(struct udevice *dev); + +#endif diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 7837d45..85c7149 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -38,6 +38,7 @@ enum uclass_id { UCLASS_BLK, /* Block device */ UCLASS_BOARD, /* Device information from hardware */ UCLASS_BOOTCOUNT, /* Bootcount backing store */ + UCLASS_BUTTON, /* Button */ UCLASS_CACHE, /* Cache controller */ UCLASS_CLK, /* Clock source, e.g. used by peripherals */ UCLASS_CPU, /* CPU, typically part of an SoC */ From patchwork Mon Jul 13 12:56:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe REYNES X-Patchwork-Id: 1327950 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=softathome.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B53Yy0N7Kz9sQt for ; Mon, 13 Jul 2020 22:56:38 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F327981671; Mon, 13 Jul 2020 14:56:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id EDC7481B7D; Mon, 13 Jul 2020 14:56:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from vrout30.yaziba.net (vrout30-bl2.yaziba.net [185.56.204.57]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A53108006D for ; Mon, 13 Jul 2020 14:56:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=philippe.reynes@softathome.com Received: from mtaout20.int.yaziba.net (mtaout20.int.yaziba.net [10.4.20.37]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout30.yaziba.net (mx10.yaziba.net) with ESMTPS id 062F05201D; Mon, 13 Jul 2020 14:56:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mtaout20.int.yaziba.net (Postfix) with ESMTP id 1E4A0160326; Mon, 13 Jul 2020 14:56:15 +0200 (CEST) Received: from mtaout20.int.yaziba.net ([127.0.0.1]) by localhost (mtaout20.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qQVc9fR8chRR; Mon, 13 Jul 2020 14:56:15 +0200 (CEST) Received: from sahnlpt0333.softathome.com (lfbn-idf3-1-660-251.w86-252.abo.wanadoo.fr [86.252.230.251]) by mtaout20.int.yaziba.net (Postfix) with ESMTPSA id EA8AF160323; Mon, 13 Jul 2020 14:56:14 +0200 (CEST) From: Philippe Reynes To: sjg@chromium.org Cc: u-boot@lists.denx.de, Philippe Reynes Subject: [PATCH 2/7] dm: button: add a driver for button driven by gpio Date: Mon, 13 Jul 2020 14:56:07 +0200 Message-Id: <1594644972-2588-2-git-send-email-philippe.reynes@softathome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594644972-2588-1-git-send-email-philippe.reynes@softathome.com> References: <1594644972-2588-1-git-send-email-philippe.reynes@softathome.com> X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: 0 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgeduiedrvdekgdehlecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhestddtredtredttdenucfhrhhomheprfhhihhlihhpphgvucftvgihnhgvshcuoehphhhilhhiphhpvgdrrhgvhihnvghssehsohhfthgrthhhohhmvgdrtghomheqnecuggftrfgrthhtvghrnhepgeefvdefledtffdujeetteeiieeltedtieeuvddtleffiedujedvheeljeejhfelnecukfhppeekiedrvdehvddrvdeftddrvdehudenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Add a simple driver which allows use of buttons attached to GPIOs. Signed-off-by: Philippe Reynes Reviewed-by: Simon Glass --- drivers/button/Kconfig | 10 ++++ drivers/button/Makefile | 1 + drivers/button/button-gpio.c | 111 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 drivers/button/button-gpio.c diff --git a/drivers/button/Kconfig b/drivers/button/Kconfig index 8301858..7de1a97 100644 --- a/drivers/button/Kconfig +++ b/drivers/button/Kconfig @@ -9,4 +9,14 @@ config BUTTON can provide access to board-specific buttons. Use of the device tree for configuration is encouraged. +config BUTTON_GPIO + bool "Button gpio" + depends on BUTTON + default n + help + Enable support for buttons which are connected to GPIO lines. These + GPIOs may be on the SoC or some other device which provides GPIOs. + The GPIO driver must used driver model. Buttons are configured using + the device tree. + endmenu diff --git a/drivers/button/Makefile b/drivers/button/Makefile index 0b4c128..fcc10eb 100644 --- a/drivers/button/Makefile +++ b/drivers/button/Makefile @@ -3,3 +3,4 @@ # Copyright (C) 2020 Philippe Reynes obj-$(CONFIG_BUTTON) += button-uclass.o +obj-$(CONFIG_BUTTON_GPIO) += button-gpio.o diff --git a/drivers/button/button-gpio.c b/drivers/button/button-gpio.c new file mode 100644 index 0000000..6ad0094 --- /dev/null +++ b/drivers/button/button-gpio.c @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 Philippe Reynes + */ + +#include +#include +#include +#include +#include +#include +#include + +struct button_gpio_priv { + struct gpio_desc gpio; +}; + +static enum button_state_t button_gpio_get_state(struct udevice *dev) +{ + struct button_gpio_priv *priv = dev_get_priv(dev); + int ret; + + if (!dm_gpio_is_valid(&priv->gpio)) + return -EREMOTEIO; + ret = dm_gpio_get_value(&priv->gpio); + if (ret < 0) + return ret; + + return ret ? BUTTON_ON : BUTTON_OFF; +} + +static int button_gpio_probe(struct udevice *dev) +{ + struct button_uc_plat *uc_plat = dev_get_uclass_platdata(dev); + struct button_gpio_priv *priv = dev_get_priv(dev); + int ret; + + /* Ignore the top-level button node */ + if (!uc_plat->label) + return 0; + + ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_IN); + if (ret) + return ret; + + return 0; +} + +static int button_gpio_remove(struct udevice *dev) +{ + /* + * The GPIO driver may have already been removed. We will need to + * address this more generally. + */ + if (IS_ENABLED(CONFIG_SANDBOX)) { + struct button_gpio_priv *priv = dev_get_priv(dev); + + if (dm_gpio_is_valid(&priv->gpio)) + dm_gpio_free(dev, &priv->gpio); + } + + return 0; +} + +static int button_gpio_bind(struct udevice *parent) +{ + struct udevice *dev; + ofnode node; + int ret; + + dev_for_each_subnode(node, parent) { + struct button_uc_plat *uc_plat; + const char *label; + + label = ofnode_read_string(node, "label"); + if (!label) { + debug("%s: node %s has no label\n", __func__, + ofnode_get_name(node)); + return -EINVAL; + } + ret = device_bind_driver_to_node(parent, "button_gpio", + ofnode_get_name(node), + node, &dev); + if (ret) + return ret; + uc_plat = dev_get_uclass_platdata(dev); + uc_plat->label = label; + } + + return 0; +} + +static const struct button_ops button_gpio_ops = { + .get_state = button_gpio_get_state, +}; + +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, +}; From patchwork Mon Jul 13 12:56:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe REYNES X-Patchwork-Id: 1327951 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=softathome.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B53ZB5QBRz9sRN for ; Mon, 13 Jul 2020 22:56:50 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E55D781B94; Mon, 13 Jul 2020 14:56:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id B8DDE81B80; Mon, 13 Jul 2020 14:56:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from vrout30.yaziba.net (vrout30-bl2.yaziba.net [185.56.204.57]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3764B80422 for ; Mon, 13 Jul 2020 14:56:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=philippe.reynes@softathome.com Received: from mtaout20.int.yaziba.net (mtaout20.int.yaziba.net [10.4.20.37]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout30.yaziba.net (mx10.yaziba.net) with ESMTPS id 0B3E952020; Mon, 13 Jul 2020 14:56:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mtaout20.int.yaziba.net (Postfix) with ESMTP id 2283A160327; Mon, 13 Jul 2020 14:56:15 +0200 (CEST) Received: from mtaout20.int.yaziba.net ([127.0.0.1]) by localhost (mtaout20.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id lxiGjL5tZ3Bl; Mon, 13 Jul 2020 14:56:15 +0200 (CEST) Received: from sahnlpt0333.softathome.com (lfbn-idf3-1-660-251.w86-252.abo.wanadoo.fr [86.252.230.251]) by mtaout20.int.yaziba.net (Postfix) with ESMTPSA id 069E6160325; Mon, 13 Jul 2020 14:56:15 +0200 (CEST) From: Philippe Reynes To: sjg@chromium.org Cc: u-boot@lists.denx.de, Philippe Reynes Subject: [PATCH 3/7] cmd: button: add a new 'button' command Date: Mon, 13 Jul 2020 14:56:08 +0200 Message-Id: <1594644972-2588-3-git-send-email-philippe.reynes@softathome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594644972-2588-1-git-send-email-philippe.reynes@softathome.com> References: <1594644972-2588-1-git-send-email-philippe.reynes@softathome.com> X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: 0 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgeduiedrvdekgdehlecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhestddtredtredttdenucfhrhhomheprfhhihhlihhpphgvucftvgihnhgvshcuoehphhhilhhiphhpvgdrrhgvhihnvghssehsohhfthgrthhhohhmvgdrtghomheqnecuggftrfgrthhtvghrnhepgeefvdefledtffdujeetteeiieeltedtieeuvddtleffiedujedvheeljeejhfelnecukfhppeekiedrvdehvddrvdeftddrvdehudenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Adds a command 'button' that provides the list of buttons supported by the board, and the state of a button. Signed-off-by: Philippe Reynes Reviewed-by: Simon Glass --- cmd/Kconfig | 11 ++++++++ cmd/Makefile | 1 + cmd/button.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 cmd/button.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 192b3b2..750d26a 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1664,6 +1664,17 @@ config CMD_BLOCK_CACHE during development, but also allows the cache to be disabled when it might hurt performance (e.g. when using the ums command). +config CMD_BUTTON + bool "button" + depends on BUTTON + default y if BUTTON + help + Enable the 'button' command which allows to get the status of + buttons supported by the board. The buttonss can be listed with + 'button list' and state can be known with 'button