blob: 7e4360dff9ef7869653fdfb772e50ecb7e2188c3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#ifndef __KEYS_M7X_H__
#define __KEYS_M7X_H__
#include <linux/irq.h>
#include <linux/sched.h>
#include <linux/pm.h>
#include <linux/slab.h>
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <linux/delay.h>
#include <linux/gpio_keys.h>
#include <linux/gpio.h>
#include <linux/of_platform.h>
#include <linux/of_gpio.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include <mach/mt_reg_base.h>
#include <mach/eint.h>
#include <mach/irqs.h>
#include <mach/sync_write.h>
/*kpd.h file path: mediatek/kernel/include/linux */
#include <linux/kpd.h>
#include "cust_gpio_usage.h"
#include "cust_kpd.h"
#include "cust_eint.h"
/*
* DELAYED_WORK: use delay work
* KEYPAD_DEBUG: contrl log print
* KEY_HALL_DEBUG: contrl sysfs show key_hall_press
*/
#define DELAYED_WORK
#define KEYPAD_DEBUG
#define KEY_HALL_DEBUG
/*
* Redefine hall pin
* According to DCT config, modify them.
*/
/* Pin */
#define M7X_HALL_KEY_GPIO GPIO_HALL_SWITH_EINT_PIN
/* EINT mode */
#define M7X_HALL_KEY_PIN_EINT_MODE GPIO_HALL_SWITH_EINT_PIN_M_EINT
/* IRQ num */
#define M7X_HALL_IRQ_NUM CUST_EINT_HALL_INT_NUM
/* IRQ type */
#define M7X_HALL_IRQ_TYPE CUST_EINT_HALL_INT_TYPE
/* IRQ debounce */
#define M7X_HALL_IRQ_DEBOUNCE_CN CUST_EINT_HALL_INT_DEBOUNCE_CN
#define RELEASED (0)
#define PRESSED (1)
#define CLOSED (2)
#define REMOVED (3)
#define FALLING MT_EINT_POL_NEG
#define RISING MT_EINT_POL_POS
#define LOW MT_EINT_POL_NEG
#define HIGH MT_EINT_POL_POS
typedef enum {
GPIO_HALL = 0,
GPIO_MAX
} GPIO_INDEX;
struct gpio_button_data {
const struct gpio_keys_button *button;
struct input_dev *input;
struct timer_list timer;
struct work_struct work;
#ifdef DELAYED_WORK
struct delayed_work delayed_work;
#endif
unsigned int timer_debounce; /* in msecs */
unsigned int irq;
spinlock_t lock;
struct mutex key_mutex;
bool disabled;
atomic_t key_pressed;
};
struct gpio_keys_drvdata {
struct input_dev *input;
struct mutex disable_lock;
unsigned int n_buttons;
int (*enable)(struct device *dev);
void (*disable)(struct device *dev);
struct gpio_button_data data[0];
};
extern unsigned int mt_eint_get_polarity(unsigned int eint_num);
void set_gpio_bdata(struct gpio_button_data *bdata, GPIO_INDEX which_gpio);
void meizu_hall_init(void);
void m7x_gpio_keys_init(void);
#endif /* __KEYS_M7X_H__ */
|