dm: button: add an uclass for button
PATCH v3 1/8 dm: button: add an uclass for button
Add a new uclass for button that implements two functions:
- button_get_by_label
- button_get_status
---
Changelog:
v3:
- no change
v2:
- re-order include
- use uclass_id_foreach_dev
- add comments to enum button_state_t
drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/button/Kconfig | 12 +++++++++ drivers/button/Makefile | 5 ++++ drivers/button/button-uclass.c | 43 ++++++++++++++++++++++++++++++ include/button.h | 59 ++++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + 7 files changed, 123 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
drivers/Kconfig +2 -0
@@ -16,6 +16,8 @@ source "drivers/block/Kconfig" source "drivers/bootcount/Kconfig" +source "drivers/button/Kconfig" + source "drivers/cache/Kconfig" source "drivers/clk/Kconfig"
drivers/Makefile +1 -0
@@ -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/
drivers/button/Kconfig new file +12 -0
@@ -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
drivers/button/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Philippe Reynes <[email protected]> + +obj-$(CONFIG_BUTTON) += button-uclass.o
drivers/button/button-uclass.c new file +43 -0
43 lines not on this page · raw message
include/button.h new file +59 -0
59 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -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 */
Signature · 1 line
2.7.4
PATCH v3 2/8 dm: button: add a driver for button driven by gpio
Add a simple driver which allows use of buttons attached to GPIOs.
---
Changelog:
v3:
- change compatible to gpio-keys and gpio-keys-polled (feedback from Neil Armstrong)
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 | 112 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 drivers/button/button-gpio.c
drivers/button/Kconfig +9 -0
@@ -9,4 +9,13 @@ 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 + 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
drivers/button/Makefile +1 -0
@@ -3,3 +3,4 @@ # Copyright (C) 2020 Philippe Reynes <[email protected]> obj-$(CONFIG_BUTTON) += button-uclass.o +obj-$(CONFIG_BUTTON_GPIO) += button-gpio.o
drivers/button/button-gpio.c new file +112 -0
112 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 2/8 dm: button: add a driver for button driven by gpio
Add a simple driver which allows use of buttons attached to GPIOs.
---
Changelog:
v3:
- change compatible to gpio-keys and gpio-keys-polled (feedback from Neil Armstrong)
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 | 112 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 drivers/button/button-gpio.c
Applied to u-boot-dm, thanks!
PATCH v3 3/8 cmd: button: add a new 'button' command
In reply to Philippe ReynesAdds a command 'button' that provides the list of buttons supported by the board, and the state of a button.
---
Changelog:
v3:
- no change
v2
- no change
cmd/Kconfig | 11 ++++++++ cmd/Makefile | 1 + cmd/button.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 cmd/button.c
cmd/Kconfig +11 -0
@@ -1679,6 +1679,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 <label>'. + Any button drivers can be controlled with this command, e.g. + button_gpio. + config CMD_CACHE bool "icache or dcache" help
cmd/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_CMD_BOOTSTAGE) += bootstage.o obj-$(CONFIG_CMD_BOOTZ) += bootz.o obj-$(CONFIG_CMD_BOOTI) += booti.o obj-$(CONFIG_CMD_BTRFS) += btrfs.o +obj-$(CONFIG_CMD_BUTTON) += button.o obj-$(CONFIG_CMD_CACHE) += cache.o obj-$(CONFIG_CMD_CBFS) += cbfs.o obj-$(CONFIG_CMD_CLK) += clk.o
cmd/button.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 3/8 cmd: button: add a new 'button' command
Adds a command 'button' that provides the list of buttons supported by the board, and the state of a button.
---
Changelog:
v3:
- no change
v2
- no change
cmd/Kconfig | 11 ++++++++ cmd/Makefile | 1 + cmd/button.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 cmd/button.c
Applied to u-boot-dm, thanks!
PATCH v3 4/8 sandbox: dtsi: add buttons
In reply to Philippe ReynesAdds two buttons on sandbox so button framework may be tested.
---
Changelog:
v3:
- update comptatible to "gpio-keys"
v2:
- no change
arch/sandbox/dts/sandbox.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/sandbox/dts/sandbox.dtsi +14 -0
@@ -15,6 +15,20 @@ #sound-dai-cells = <1>; }; + buttons { + compatible = "gpio-keys"; + + summer { + gpios = <&gpio_a 3 0>; + label = "summer"; + }; + + christmas { + gpios = <&gpio_a 4 0>; + label = "christmas"; + }; + }; + gpio_a: gpios at 0 { u-boot,dm-pre-reloc; gpio-controller;
Signature · 1 line
2.7.4
PATCH v3 4/8 sandbox: dtsi: add buttons
Adds two buttons on sandbox so button framework may be tested.
---
Changelog:
v3:
- update comptatible to "gpio-keys"
v2:
- no change
arch/sandbox/dts/sandbox.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Applied to u-boot-dm, thanks!
PATCH v3 5/8 sandbox64: enable button
In reply to Philippe ReynesEnable the support of button (driver and command) on sandbox64.
---
Changelog:
v3:
- no change
v2:
- no change
configs/sandbox64_defconfig | 2 ++ 1 file changed, 2 insertions(+)
configs/sandbox64_defconfig +2 -0
@@ -92,6 +92,8 @@ CONFIG_ADC=y CONFIG_ADC_SANDBOX=y CONFIG_AXI=y CONFIG_AXI_SANDBOX=y +CONFIG_BUTTON=y +CONFIG_BUTTON_GPIO=y CONFIG_CLK=y CONFIG_CPU=y CONFIG_DM_DEMO=y
Signature · 1 line
2.7.4
PATCH v3 5/8 sandbox64: enable button
Enable the support of button (driver and command) on sandbox64.
---
Changelog:
v3:
- no change
v2:
- no change
configs/sandbox64_defconfig | 2 ++ 1 file changed, 2 insertions(+)
Applied to u-boot-dm, thanks!
PATCH v3 6/8 sandbox: enable button
In reply to Philippe ReynesEnable the support of button (driver and command) on sandbox.
---
Changelog:
v3:
- no change
v2:
- no change
configs/sandbox_defconfig | 2 ++ 1 file changed, 2 insertions(+)
configs/sandbox_defconfig +2 -0
@@ -106,6 +106,8 @@ CONFIG_AXI_SANDBOX=y CONFIG_BOOTCOUNT_LIMIT=y CONFIG_DM_BOOTCOUNT=y CONFIG_DM_BOOTCOUNT_RTC=y +CONFIG_BUTTON=y +CONFIG_BUTTON_GPIO=y CONFIG_CLK=y CONFIG_CLK_COMPOSITE_CCF=y CONFIG_SANDBOX_CLK_CCF=y
Signature · 1 line
2.7.4
PATCH v3 6/8 sandbox: enable button
Enable the support of button (driver and command) on sandbox.
---
Changelog:
v3:
- no change
v2:
- no change
configs/sandbox_defconfig | 2 ++ 1 file changed, 2 insertions(+)
Applied to u-boot-dm, thanks!
PATCH v3 7/8 test/py: add tests for the button commands
In reply to Philippe ReynesAdds tests for the button commands.
---
Changelog:
v3:
- update compatible to "gpio-keys"
v2:
- no change (button uclass test is added in another commit
arch/sandbox/dts/test.dts | 14 ++++++++++++++ test/py/tests/test_button.py | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/py/tests/test_button.py
arch/sandbox/dts/test.dts +14 -0
@@ -51,6 +51,20 @@ #sound-dai-cells = <1>; }; + buttons { + compatible = "gpio-keys"; + + summer { + gpios = <&gpio_a 3 0>; + label = "summer"; + }; + + christmas { + gpios = <&gpio_a 4 0>; + label = "christmas"; + }; + }; + cros_ec: cros-ec { reg = <0 0>; compatible = "google,cros-ec-sandbox";
test/py/tests/test_button.py new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0+ + +import pytest + + at pytest.mark.boardspec('sandbox') + at pytest.mark.buildconfigspec('cmd_button') +def test_button_exit_statuses(u_boot_console): + """Test that non-input button commands correctly return the command + success/failure status.""" + + expected_response = 'rc:0' + response = u_boot_console.run_command('button list; echo rc:$?') + assert(expected_response in response) + response = u_boot_console.run_command('button summer; echo rc:$?') + assert(expected_response in response) + + expected_response = 'rc:1' + response = u_boot_console.run_command('button nonexistent-button; echo rc:$?') + assert(expected_response in response)
Signature · 1 line
2.7.4
PATCH v3 7/8 test/py: add tests for the button commands
Adds tests for the button commands.
---
Changelog:
v3:
- update compatible to "gpio-keys"
v2:
- no change (button uclass test is added in another commit
arch/sandbox/dts/test.dts | 14 ++++++++++++++ test/py/tests/test_button.py | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/py/tests/test_button.py
Applied to u-boot-dm, thanks!
PATCH v3 8/8 test: dm: add a test for class button
In reply to Philippe ReynesAdd a test to confirm that we can read button state using the button-gpio driver.
---
Changelog:
v3:
- no change
v2:
- new commit in the serie
test/dm/Makefile | 1 + test/dm/button.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 test/dm/button.c
test/dm/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_ACPIGEN) += acpi_dp.o obj-$(CONFIG_SOUND) += audio.o obj-$(CONFIG_BLK) += blk.o obj-$(CONFIG_BOARD) += board.o +obj-$(CONFIG_BUTTON) += button.o obj-$(CONFIG_DM_BOOTCOUNT) += bootcount.o obj-$(CONFIG_CLK) += clk.o clk_ccf.o obj-$(CONFIG_DEVRES) += devres.o
test/dm/button.c new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 8/8 test: dm: add a test for class button
Quoted 12 lines · Philippe Reynes
Add a test to confirm that we can read button state using the button-gpio driver.
Signed-off-by Philippe Reynes <[email protected]>---
Changelog:
v3:
- no change
v2:
- new commit in the serie
Quoted 5 lines
test/dm/Makefile | 1 + test/dm/button.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 test/dm/button.c
PATCH v3 1/8 dm: button: add an uclass for button
In reply to Philippe ReynesAdd a new uclass for button that implements two functions:
- button_get_by_label
- button_get_status
---
Changelog:
v3:
- no change
v2:
- re-order include
- use uclass_id_foreach_dev
- add comments to enum button_state_t
drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/button/Kconfig | 12 +++++++++ drivers/button/Makefile | 5 ++++ drivers/button/button-uclass.c | 43 ++++++++++++++++++++++++++++++ include/button.h | 59 ++++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + 7 files changed, 123 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
Applied to u-boot-dm, thanks!
A message that is not in the archive (sent off-list or not yet received): CAPnjgZ3=0cQAf3+u7JjVxWOfyoXb4_COjTnSUY9o9oY9DKc=5Q@mail.gmail.com
PATCH v3 8/8 test: dm: add a test for class button
Quoted 12 lines · Philippe Reynes
Add a test to confirm that we can read button state using the button-gpio driver.
Signed-off-by Philippe Reynes <[email protected]>---
Changelog:
v3:
- no change
v2:
- new commit in the serie
Quoted 5 lines
test/dm/Makefile | 1 + test/dm/button.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 test/dm/button.c
Applied to u-boot-dm, thanks!