1
2 #ifndef _MATRIX_KEYPAD_H
3 #define _MATRIX_KEYPAD_H
4
5 #include <linux/types.h>
6 #include <linux/input.h>
7 #include <linux/of.h>
8
9 #define MATRIX_MAX_ROWS 32
10 #define MATRIX_MAX_COLS 32
11
12 #define KEY(row, col, val) ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
13 (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
14 ((val) & 0xffff))
15
16 #define KEY_ROW(k) (((k) >> 24) & 0xff)
17 #define KEY_COL(k) (((k) >> 16) & 0xff)
18 #define KEY_VAL(k) ((k) & 0xffff)
19
20 #define MATRIX_SCAN_CODE(row, col, row_shift) (((row) << (row_shift)) + (col))
21
22
23
24
25
26
27
28
29
30
31 struct matrix_keymap_data {
32 const uint32_t *keymap;
33 unsigned int keymap_size;
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 struct matrix_keypad_platform_data {
60 const struct matrix_keymap_data *keymap_data;
61
62 const unsigned int *row_gpios;
63 const unsigned int *col_gpios;
64
65 unsigned int num_row_gpios;
66 unsigned int num_col_gpios;
67
68 unsigned int col_scan_delay_us;
69
70
71 unsigned int debounce_ms;
72
73 unsigned int clustered_irq;
74 unsigned int clustered_irq_flags;
75
76 bool active_low;
77 bool wakeup;
78 bool no_autorepeat;
79 bool drive_inactive_cols;
80 };
81
82 int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
83 const char *keymap_name,
84 unsigned int rows, unsigned int cols,
85 unsigned short *keymap,
86 struct input_dev *input_dev);
87 int matrix_keypad_parse_properties(struct device *dev,
88 unsigned int *rows, unsigned int *cols);
89
90 #define matrix_keypad_parse_of_params matrix_keypad_parse_properties
91
92 #endif