• 周五. 5月 2nd, 2025

rockchip — adc button / key dts配置

3月 20, 2020

关键词: rockchip; adc key;rockchip,key; button;

rockchip — key dts配置

1、adc button/key简介:

使用ADC的值,来识别不同的按键的按下和弹起,即为adc button/key.

2、属性值配置:

 - compatible: "rockchip,key"
 - io-channels: 指定ADC的通道;

每个按键都是以一个子节点的形式表示,每个子节点的属性值配置如下:
    - label: 描述key的名称;
    - linux,code: 该按下时发送的Keycode
    - rockchip,adc_value: 该按下时ADC的采样值;
3、实例:

Example:

#include <dt-bindings/input/input.h>

	rk_key: rockchip-key {
		compatible = "rockchip,key";
		status = "okay";

		io-channels = <&saradc 1>;

		vol-up-key {
			linux,code = <115>;
			label = "volume up";
			rockchip,adc_value = <1>;
		};

		vol-down-key {
			linux,code = <114>;
			label = "volume down";
			rockchip,adc_value = <170>;
		};

		power-key {
			gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
			linux,code = <116>;
			pinctrl-names = "default";
			pinctrl-0 = <&pwrbtn>;
			label = "power";
			gpio-key,wakeup;
		};

		menu-key {
			linux,code = <59>;
			label = "menu";
			rockchip,adc_value = <355>;
		};

		home-key {
			linux,code = <102>;
			label = "home";
			rockchip,adc_value = <746>;
		};

		back-key {
			linux,code = <158>;
			label = "back";
			rockchip,adc_value = <560>;
		};

		camera-key {
			linux,code = <212>;
			label = "camera";
			rockchip,adc_value = <450>;
		};
	};