xref: /rk3399_rockchip-uboot/include/key.h (revision 2e40c2c11f0d1e8bad5bb55706ee814183cfa21f)
1 /*
2  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #ifndef _KEY_H_
8 #define _KEY_H_
9 
10 #include <linux/input.h>
11 
12 #define KEY_LONG_DOWN_MS	2000
13 
14 enum key_state {
15 	KEY_PRESS_NONE,
16 	KEY_PRESS_UP,
17 	KEY_PRESS_DOWN,
18 	KEY_PRESS_LONG_DOWN,
19 	KEY_NOT_EXIST,
20 };
21 
22 struct dm_key_ops {
23 	const char *name;
24 	int (*read)(struct udevice *dev, int code);
25 };
26 
27 struct input_key {
28 	const char *name;
29 	u32 code;
30 	u32 channel;
31 	u32 value;
32 	u32 margin;
33 	u32 vref;
34 	int flag;
35 
36 	u32 irq;
37 	u64 up_t;
38 	u64 down_t;
39 };
40 
41 uint64_t key_get_timer(uint64_t base);
42 int platform_key_read(int code);
43 
44 /* General interface for adc or gpio interrupt key event parse */
45 int key_parse_gpio_event(struct input_key *key);
46 int key_parse_adc_event(struct input_key *key, unsigned int adcval);
47 
48 #endif
49