1#ifndef _MATRIX_KEYPAD_H
2#define _MATRIX_KEYPAD_H
3
4#include <linux/types.h>
5#include <linux/input.h>
6#include <linux/of.h>
7
8#define MATRIX_MAX_ROWS 32
9#define MATRIX_MAX_COLS 32
10
11#define KEY(row, col, val) ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
12 (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
13 ((val) & 0xffff))
14
15#define KEY_ROW(k) (((k) >> 24) & 0xff)
16#define KEY_COL(k) (((k) >> 16) & 0xff)
17#define KEY_VAL(k) ((k) & 0xffff)
18
19#define MATRIX_SCAN_CODE(row, col, row_shift) (((row) << (row_shift)) + (col))
20
21
22
23
24
25
26
27
28
29
30struct matrix_keymap_data {
31 const uint32_t *keymap;
32 unsigned int keymap_size;
33};
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56struct matrix_keypad_platform_data {
57 const struct matrix_keymap_data *keymap_data;
58
59 const unsigned int *row_gpios;
60 const unsigned int *col_gpios;
61
62 unsigned int num_row_gpios;
63 unsigned int num_col_gpios;
64
65 unsigned int col_scan_delay_us;
66
67
68 unsigned int debounce_ms;
69
70 unsigned int clustered_irq;
71 unsigned int clustered_irq_flags;
72
73 bool active_low;
74 bool wakeup;
75 bool no_autorepeat;
76};
77
78int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
79 const char *keymap_name,
80 unsigned int rows, unsigned int cols,
81 unsigned short *keymap,
82 struct input_dev *input_dev);
83
84#ifdef CONFIG_OF
85
86
87
88
89
90
91
92
93int matrix_keypad_parse_of_params(struct device *dev,
94 unsigned int *rows, unsigned int *cols);
95#else
96static inline int matrix_keypad_parse_of_params(struct device *dev,
97 unsigned int *rows, unsigned int *cols)
98{
99 return -ENOSYS;
100}
101#endif
102
103#endif
104