input: gpio-keys: add support for disable button from DT
Subsystems (3)
PATCH 1/2 input: gpio-keys: add support for disable button from DT
Add support to disable the button from DT via status property if given button is not supporting on given platforms.
This will help to re-use the existing dtsi file with status enable/disable across platforms.
--- drivers/input/keyboard/gpio_keys.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/input/keyboard/gpio_keys.c +8 -0
@@ -632,6 +632,14 @@ gpio_keys_get_devtree_pdata(struct device *dev)for_each_child_of_node (node, pp) {enum of_gpio_flags flags; +/* Ignore the button if status of node is disabled */ + error =of_device_is_available (pp); +if (!error) { +dev_info (dev,"Button %s is ignored\n" , pp->name); + pdata->nbuttons--; +continue ; + } + button = &pdata->buttons[i++]; button->gpio =of_get_gpio_flags (pp,0 , &flags);
Signature · 1 line
2.1.4
PATCH 2/2 input: gpio-keys: add support to name the gpio-keys
Add support from DT to name the gpio-keys driver to have desired key name for this input system.
This helps userspace code to get name and perform proper event to key mapping in some of cases. In android, the user space map the key code to application code using key character layout and for this it uses the name of input system.
--- Documentation/devicetree/bindings/input/gpio-keys.txt | 1 + drivers/input/keyboard/gpio_keys.c | 2 ++ 2 files changed, 3 insertions(+)
Documentation/devicetree/bindings/input/gpio-keys.txt +1 -0
@@ -4,6 +4,7 @@ Required properties: - compatible = "gpio-keys"; Optional properties: + - gpio-keys,name: String, name of the gpio-keys input system. - autorepeat: Boolean, Enable auto repeat feature of Linux input subsystem.
drivers/input/keyboard/gpio_keys.c +2 -0
@@ -628,6 +628,8 @@ gpio_keys_get_devtree_pdata(struct device *dev) pdata->rep = !!of_get_property (node,"autorepeat" ,NULL ); +of_property_read_string (node,"gpio-keys,name" , &pdata->name); + i =0 ;for_each_child_of_node (node, pp) {enum of_gpio_flags flags;
Signature · 1 line
2.1.4
Rob Herring
maintainerRe: [PATCH 2/2] input: gpio-keys: add support to name the gpio-keys
Quoted 8 lines · Laxman Dewangan
Add support from DT to name the gpio-keys driver to have desired key name for this input system.
This helps userspace code to get name and perform proper event to key mapping in some of cases. In android, the user space map the key code to application code using key character layout and for this it uses the name of input system.
Why is specifying the key code not enough?
Quoted 11 lines
Signed-off-by Laxman Dewangan <[email protected]>--- Documentation/devicetree/bindings/input/gpio-keys.txt | 1 + drivers/input/keyboard/gpio_keys.c | 2 ++ 2 files changed, 3 insertions(+)Documentation/devicetree/bindings/input/gpio-keys.txt +0
-0
Documentation/devicetree/bindings/input/gpio-keys.txt Required properties: · line 7
Quoted 4 lines
Documentation/devicetree/bindings/input/gpio-keys.txt +1
-0@@ -4,6 +4,7 @@ Required properties: - compatible = "gpio-keys"; Optional properties: + - gpio-keys,name: String, name of the gpio-keys input system.
gpio-keys is not a vendor.
Would "label" work for you instead?
Either way, I'm concerned this doesn't work for other key bindings which have multiple keys.
Quoted 3 lines
Documentation/devicetree/bindings/input/gpio-keys.txt +0
-0- autorepeat: Boolean, Enable auto repeat feature of Linux input subsystem.
Re: [PATCH 2/2] input: gpio-keys: add support to name the gpio-keys
Quoted 10 lines · Rob Herring
Quoted 8 lines · Laxman Dewangan
Add support from DT to name the gpio-keys driver to have desired key name for this input system.
This helps userspace code to get name and perform proper event to key mapping in some of cases. In android, the user space map the key code to application code using key character layout and for this it uses the name of input system.
Why is specifying the key code not enough?
This is the name for input system instead of individual keys.
In android system, the key mapping is done in user space. By having name offers to specifying the customized key character layout instead of generic one form android which is fall-back.
Quoted 14 lines
Quoted 14 lines
Signed-off-by Laxman Dewangan <[email protected]>--- Documentation/devicetree/bindings/input/gpio-keys.txt | 1 + drivers/input/keyboard/gpio_keys.c | 2 ++ 2 files changed, 3 insertions(+)Documentation/devicetree/bindings/input/gpio-keys.txt +0
-0@@ -4,6 +4,7 @@ Required properties: - compatible = "gpio-keys";
Quoted 5 lines
Documentation/devicetree/bindings/input/gpio-keys.txt Required properties: · line 7
Quoted 2 lines
Documentation/devicetree/bindings/input/gpio-keys.txt +1
-0Optional properties: + - gpio-keys,name: String, name of the gpio-keys input system.gpio-keys is not a vendor.
Would "label" work for you instead?
"label" means node name?
Quoted 5 lines
Either way, I'm concerned this doesn't work for other key bindings which have multiple keys.
This is not for the individual keys, its for input system like /sys/class/input/input0/name.
Rob Herring
maintainerRe: [PATCH 2/2] input: gpio-keys: add support to name the gpio-keys
Quoted 14 lines · Laxman Dewangan
Quoted 12 lines · Rob Herring
Quoted 9 lines · Laxman Dewangan
Add support from DT to name the gpio-keys driver to have desired key name for this input system.
This helps userspace code to get name and perform proper event to key mapping in some of cases. In android, the user space map the key code to application code using key character layout and for this it uses the name of input system.
Quoted 7 lines
Quoted 1 line
Why is specifying the key code not enough?
This is the name for input system instead of individual keys. In android system, the key mapping is done in user space. By having name offers to specifying the customized key character layout instead of generic one form android which is fall-back.
Okay, got it.
Quoted 18 lines
Quoted 18 lines
Quoted 12 lines
Signed-off-by Laxman Dewangan <[email protected]>--- Documentation/devicetree/bindings/input/gpio-keys.txt | 1 + drivers/input/keyboard/gpio_keys.c | 2 ++ 2 files changed, 3 insertions(+)Documentation/devicetree/bindings/input/gpio-keys.txt +0
-0Documentation/devicetree/bindings/input/gpio-keys.txt Required properties: · line 6
Quoted 3 lines
Documentation/devicetree/bindings/input/gpio-keys.txt +1
-0@@ -4,6 +4,7 @@ Required properties: - compatible = "gpio-keys"; Optional properties: + - gpio-keys,name: String, name of the gpio-keys input system.gpio-keys is not a vendor.
Quoted 4 lines
Quoted 1 line
Would "label" work for you instead?
"label" means node name?
No, the standard label property. See gpio-leds for an example.
Quoted 7 lines
Quoted 4 lines
Either way, I'm concerned this doesn't work for other key bindings which have multiple keys.
This is not for the individual keys, its for input system like
/sys/class/input/input0/name.
So label is exactly for this purpose of defining user meaningful names.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] input: gpio-keys: add support to name the gpio-keys
Quoted 6 lines · Rob Herring
Quoted 2 lines · Laxman Dewangan
Quoted 1 line · Rob Herring
On Tue, Jan 12, 2016 at 05:02:50PM +0530, Laxman Dewangan wrote:
So label is exactly for this purpose of defining user meaningful names.
Yes, I can use the label for name. I will update the patch.
Just for understanding, is "label" is better property name to pass the specific name?
Re: [PATCH 2/2] input: gpio-keys: add support to name the gpio-keys
Quoted 9 lines · Laxman Dewangan
Quoted 6 lines · Rob Herring
Quoted 4 lines · Laxman Dewangan
Quoted 2 lines · Rob Herring
On Tue, Jan 12, 2016 at 05:02:50PM +0530, Laxman Dewangan wrote:
Quoted 6 lines
Quoted 2 lines
So label is exactly for this purpose of defining user meaningful names.
Yes, I can use the label for name. I will update the patch.
Just for understanding, is "label" is better property name to pass the specific name?
Yes, look at this fromarch/arm64/boot/dts/arm/juno-motherboard.dtsi:
gpio_keys {
compatible = "gpio-keys";
#address-cells = <1>;
#size-cells = <0>;
button@1 {
debounce_interval = <50>;
wakeup-source;
linux,code = <116>;
label = "POWER";
gpios = <&iofpga_gpio0 0 0x4>;
};
button@2 {
debounce_interval = <50>;
wakeup-source;
linux,code = <102>;
label = "HOME";
gpios = <&iofpga_gpio0 1 0x4>;
};(...)
Currently these names (POWER, HOME etc) appear nicely in /proc/interrupts, so I guess the same should be used for input?
Yours,
Linus Walleij
Dmitry Torokhov
maintainerQuoted 16 lines · Laxman Dewangan
Add support to disable the button from DT via status property if given button is not supporting on given platforms.
This will help to re-use the existing dtsi file with status enable/disable across platforms.
Signed-off-by Laxman Dewangan <[email protected]>--- drivers/input/keyboard/gpio_keys.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/input/keyboard/gpio_keys.c +0
-0
drivers/input/keyboard/gpio_keys.c gpio_keys_get_devtree_pdata(struct device *dev) · line 638
Quoted 7 lines
drivers/input/keyboard/gpio_keys.c +4
-0@@ -632,6 +632,14 @@ gpio_keys_get_devtree_pdata(struct device *dev)for_each_child_of_node (node, pp) {enum of_gpio_flags flags; +/* Ignore the button if status of node is disabled */ + error =of_device_is_available (pp); +if (!error) { +dev_info (dev,"Button %s is ignored\n" , pp->name);
I'd rather have it as dev_dbg() please.
Quoted 10 lines
drivers/input/keyboard/gpio_keys.c +4
-0+ pdata->nbuttons--; +continue ; + } + button = &pdata->buttons[i++]; button->gpio =of_get_gpio_flags (pp,0 , &flags);Signature · 1 line
2.1.4
Signature · 1 line
Dmitry