xref: /rk3399_rockchip-uboot/include/key.h (revision d5f538dc02e53c7267fcd4a914104071fca889b5)
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 <dt-bindings/input/linux-event-codes.h>
11 
12 #define KEY_LONG_DOWN_MS	2000
13 
14 enum key_state {
15 	KEY_PRESS_NONE,	/* press without release */
16 	KEY_PRESS_DOWN,	/* press -> release */
17 	KEY_PRESS_LONG_DOWN,
18 	KEY_NOT_EXIST,
19 };
20 
21 struct dm_key_ops {
22 	const char *name;
23 	int (*read)(struct udevice *dev, int code);
24 };
25 
26 struct input_key {
27 	const char *name;
28 	u32 code;
29 	u32 channel;
30 	u32 value;
31 	u32 margin;
32 	u32 vref;
33 	int flag;
34 
35 	u32 irq;
36 	u64 up_t;
37 	u64 down_t;
38 };
39 
40 uint64_t key_get_timer(uint64_t base);
41 int platform_key_read(int code);
42 
43 /* General interface for adc or gpio interrupt key event parse */
44 int key_parse_gpio_event(struct input_key *key);
45 int key_parse_adc_event(struct input_key *key, unsigned int adcval);
46 
47 #endif
48