Qualcomm platform adds keys to input system through GPIO keys

Add a new key to the input system, you can use GPIO keys directly, GPIO keys driver related code has been implemented, we can achieve this function only through simple configuration.

dtsi add

Find GPIO ﹣ keys, and add the corresponding keys, as follows: talkback ﹣ sq, which mainly needs to be configured as follows

gpios, corresponding to pins in the schematic

Linux, input type, the type of reported event. Here we select 1 (EV_KEY) key event, which is defined in input-event-codes.h

linux,code, code of reported events

	gpio_keys {
		compatible = "gpio-keys";
		input-name = "gpio-keys";
		pinctrl-names = "tlmm_gpio_key_active","tlmm_gpio_key_suspend";
		pinctrl-0 = <&gpio_key_active>;
		pinctrl-1 = <&gpio_key_suspend>;

		vol_down {
			label = "vol_down";
			gpios = <&msm_gpio 91 0x1>;
			linux,input-type = <1>;
			linux,code = <114>;
			gpio-key,wakeup;
			debounce-interval = <15>;
		};
        talkback_sq {
			label = "talkback_sq";
			gpios = <&msm_gpio 28 0x1>;
			linux,input-type = <1>;
			linux,code = <188>;
			gpio-key,wakeup;
			debounce-interval = <15>;
		};
	};

pinctrl add

Add the corresponding GPIO to gpio_key

		tlmm_gpio_key {
			gpio_key_active: gpio_key_active {
				mux {
					pins = "gpio90", "gpio91", "gpio92", "gpio95"/*, "gpio28"*/;
					function = "gpio";
				};

				config {
					pins = "gpio90", "gpio91", "gpio92", "gpio95"/*, "gpio28"*/;
					drive-strength = <2>;
					bias-pull-up;
				};
			};

			gpio_key_suspend: gpio_key_suspend {
				mux {
					pins = "gpio90", "gpio91", "gpio92", "gpio95"/*, "gpio28"*/;
					function = "gpio";
				};

				config {
					pins = "gpio90", "gpio91", "gpio92", "gpio95"/*, "gpio28"*/;
					drive-strength = <2>;
					bias-pull-up;
				};
			};
		};

Configure kl file

Edit gpio-keys.kl

Keywords: Linux

Added by benyamin on Sat, 04 Jan 2020 04:22:45 +0200