diff options
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r-- | drivers/input/keyboard/Kconfig | 21 | ||||
-rw-r--r-- | drivers/input/keyboard/Makefile | 2 | ||||
-rw-r--r-- | drivers/input/keyboard/atkbd.c | 6 | ||||
-rw-r--r-- | drivers/input/keyboard/bcm-keypad.c | 458 | ||||
-rw-r--r-- | drivers/input/keyboard/cros_ec_keyb.c | 2 | ||||
-rw-r--r-- | drivers/input/keyboard/ipaq-micro-keys.c | 168 | ||||
-rw-r--r-- | drivers/input/keyboard/tc3589x-keypad.c | 33 |
7 files changed, 682 insertions, 8 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index a89ba7cb96f1..106fbac7f8c5 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -588,6 +588,16 @@ config KEYBOARD_DAVINCI | |||
588 | To compile this driver as a module, choose M here: the | 588 | To compile this driver as a module, choose M here: the |
589 | module will be called davinci_keyscan. | 589 | module will be called davinci_keyscan. |
590 | 590 | ||
591 | config KEYBOARD_IPAQ_MICRO | ||
592 | tristate "Buttons on Micro SoC (iPaq h3100,h3600,h3700)" | ||
593 | depends on MFD_IPAQ_MICRO | ||
594 | help | ||
595 | Say Y to enable support for the buttons attached to | ||
596 | Micro peripheral controller on iPAQ h3100/h3600/h3700 | ||
597 | |||
598 | To compile this driver as a module, choose M here: the | ||
599 | module will be called ipaq-micro-keys. | ||
600 | |||
591 | config KEYBOARD_OMAP | 601 | config KEYBOARD_OMAP |
592 | tristate "TI OMAP keypad support" | 602 | tristate "TI OMAP keypad support" |
593 | depends on ARCH_OMAP1 | 603 | depends on ARCH_OMAP1 |
@@ -686,4 +696,15 @@ config KEYBOARD_CAP11XX | |||
686 | To compile this driver as a module, choose M here: the | 696 | To compile this driver as a module, choose M here: the |
687 | module will be called cap11xx. | 697 | module will be called cap11xx. |
688 | 698 | ||
699 | config KEYBOARD_BCM | ||
700 | tristate "Broadcom keypad driver" | ||
701 | depends on OF && HAVE_CLK | ||
702 | select INPUT_MATRIXKMAP | ||
703 | default ARCH_BCM_CYGNUS | ||
704 | help | ||
705 | Say Y here if you want to use Broadcom keypad. | ||
706 | |||
707 | To compile this driver as a module, choose M here: the | ||
708 | module will be called bcm-keypad. | ||
709 | |||
689 | endif | 710 | endif |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 470767884bd8..df28d5553c05 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -10,6 +10,7 @@ obj-$(CONFIG_KEYBOARD_ADP5589) += adp5589-keys.o | |||
10 | obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o | 10 | obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o |
11 | obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o | 11 | obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o |
12 | obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o | 12 | obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o |
13 | obj-$(CONFIG_KEYBOARD_BCM) += bcm-keypad.o | ||
13 | obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o | 14 | obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o |
14 | obj-$(CONFIG_KEYBOARD_CAP11XX) += cap11xx.o | 15 | obj-$(CONFIG_KEYBOARD_CAP11XX) += cap11xx.o |
15 | obj-$(CONFIG_KEYBOARD_CLPS711X) += clps711x-keypad.o | 16 | obj-$(CONFIG_KEYBOARD_CLPS711X) += clps711x-keypad.o |
@@ -23,6 +24,7 @@ obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o | |||
23 | obj-$(CONFIG_KEYBOARD_TCA8418) += tca8418_keypad.o | 24 | obj-$(CONFIG_KEYBOARD_TCA8418) += tca8418_keypad.o |
24 | obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o | 25 | obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o |
25 | obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o | 26 | obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o |
27 | obj-$(CONFIG_KEYBOARD_IPAQ_MICRO) += ipaq-micro-keys.o | ||
26 | obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o | 28 | obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o |
27 | obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o | 29 | obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o |
28 | obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o | 30 | obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o |
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 387c51f4b4e4..ec876b5b1382 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c | |||
@@ -1653,6 +1653,12 @@ static int __init atkbd_deactivate_fixup(const struct dmi_system_id *id) | |||
1653 | return 1; | 1653 | return 1; |
1654 | } | 1654 | } |
1655 | 1655 | ||
1656 | /* | ||
1657 | * NOTE: do not add any more "force release" quirks to this table. The | ||
1658 | * task of adjusting list of keys that should be "released" automatically | ||
1659 | * by the driver is now delegated to userspace tools, such as udev, so | ||
1660 | * submit such quirks there. | ||
1661 | */ | ||
1656 | static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = { | 1662 | static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = { |
1657 | { | 1663 | { |
1658 | .matches = { | 1664 | .matches = { |
diff --git a/drivers/input/keyboard/bcm-keypad.c b/drivers/input/keyboard/bcm-keypad.c new file mode 100644 index 000000000000..86a8b723ae15 --- /dev/null +++ b/drivers/input/keyboard/bcm-keypad.c | |||
@@ -0,0 +1,458 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Broadcom Corporation | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation version 2. | ||
7 | * | ||
8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
9 | * kind, whether express or implied; without even the implied warranty | ||
10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #include <linux/bitops.h> | ||
15 | #include <linux/clk.h> | ||
16 | #include <linux/gfp.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/input.h> | ||
19 | #include <linux/input/matrix_keypad.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/of.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <linux/stddef.h> | ||
25 | #include <linux/types.h> | ||
26 | |||
27 | #define DEFAULT_CLK_HZ 31250 | ||
28 | #define MAX_ROWS 8 | ||
29 | #define MAX_COLS 8 | ||
30 | |||
31 | /* Register/field definitions */ | ||
32 | #define KPCR_OFFSET 0x00000080 | ||
33 | #define KPCR_MODE 0x00000002 | ||
34 | #define KPCR_MODE_SHIFT 1 | ||
35 | #define KPCR_MODE_MASK 1 | ||
36 | #define KPCR_ENABLE 0x00000001 | ||
37 | #define KPCR_STATUSFILTERENABLE 0x00008000 | ||
38 | #define KPCR_STATUSFILTERTYPE_SHIFT 12 | ||
39 | #define KPCR_COLFILTERENABLE 0x00000800 | ||
40 | #define KPCR_COLFILTERTYPE_SHIFT 8 | ||
41 | #define KPCR_ROWWIDTH_SHIFT 20 | ||
42 | #define KPCR_COLUMNWIDTH_SHIFT 16 | ||
43 | |||
44 | #define KPIOR_OFFSET 0x00000084 | ||
45 | #define KPIOR_ROWOCONTRL_SHIFT 24 | ||
46 | #define KPIOR_ROWOCONTRL_MASK 0xFF000000 | ||
47 | #define KPIOR_COLUMNOCONTRL_SHIFT 16 | ||
48 | #define KPIOR_COLUMNOCONTRL_MASK 0x00FF0000 | ||
49 | #define KPIOR_COLUMN_IO_DATA_SHIFT 0 | ||
50 | |||
51 | #define KPEMR0_OFFSET 0x00000090 | ||
52 | #define KPEMR1_OFFSET 0x00000094 | ||
53 | #define KPEMR2_OFFSET 0x00000098 | ||
54 | #define KPEMR3_OFFSET 0x0000009C | ||
55 | #define KPEMR_EDGETYPE_BOTH 3 | ||
56 | |||
57 | #define KPSSR0_OFFSET 0x000000A0 | ||
58 | #define KPSSR1_OFFSET 0x000000A4 | ||
59 | #define KPSSRN_OFFSET(reg_n) (KPSSR0_OFFSET + 4 * (reg_n)) | ||
60 | #define KPIMR0_OFFSET 0x000000B0 | ||
61 | #define KPIMR1_OFFSET 0x000000B4 | ||
62 | #define KPICR0_OFFSET 0x000000B8 | ||
63 | #define KPICR1_OFFSET 0x000000BC | ||
64 | #define KPICRN_OFFSET(reg_n) (KPICR0_OFFSET + 4 * (reg_n)) | ||
65 | #define KPISR0_OFFSET 0x000000C0 | ||
66 | #define KPISR1_OFFSET 0x000000C4 | ||
67 | |||
68 | #define KPCR_STATUSFILTERTYPE_MAX 7 | ||
69 | #define KPCR_COLFILTERTYPE_MAX 7 | ||
70 | |||
71 | /* Macros to determine the row/column from a bit that is set in SSR0/1. */ | ||
72 | #define BIT_TO_ROW_SSRN(bit_nr, reg_n) (((bit_nr) >> 3) + 4 * (reg_n)) | ||
73 | #define BIT_TO_COL(bit_nr) ((bit_nr) % 8) | ||
74 | |||
75 | /* Structure representing various run-time entities */ | ||
76 | struct bcm_kp { | ||
77 | void __iomem *base; | ||
78 | int irq; | ||
79 | struct clk *clk; | ||
80 | struct input_dev *input_dev; | ||
81 | unsigned long last_state[2]; | ||
82 | unsigned int n_rows; | ||
83 | unsigned int n_cols; | ||
84 | u32 kpcr; | ||
85 | u32 kpior; | ||
86 | u32 kpemr; | ||
87 | u32 imr0_val; | ||
88 | u32 imr1_val; | ||
89 | }; | ||
90 | |||
91 | /* | ||
92 | * Returns the keycode from the input device keymap given the row and | ||
93 | * column. | ||
94 | */ | ||
95 | static int bcm_kp_get_keycode(struct bcm_kp *kp, int row, int col) | ||
96 | { | ||
97 | unsigned int row_shift = get_count_order(kp->n_cols); | ||
98 | unsigned short *keymap = kp->input_dev->keycode; | ||
99 | |||
100 | return keymap[MATRIX_SCAN_CODE(row, col, row_shift)]; | ||
101 | } | ||
102 | |||
103 | static void bcm_kp_report_keys(struct bcm_kp *kp, int reg_num, int pull_mode) | ||
104 | { | ||
105 | unsigned long state, change; | ||
106 | int bit_nr; | ||
107 | int key_press; | ||
108 | int row, col; | ||
109 | unsigned int keycode; | ||
110 | |||
111 | /* Clear interrupts */ | ||
112 | writel(0xFFFFFFFF, kp->base + KPICRN_OFFSET(reg_num)); | ||
113 | |||
114 | state = readl(kp->base + KPSSRN_OFFSET(reg_num)); | ||
115 | change = kp->last_state[reg_num] ^ state; | ||
116 | kp->last_state[reg_num] = state; | ||
117 | |||
118 | for_each_set_bit(bit_nr, &change, BITS_PER_LONG) { | ||
119 | key_press = state & BIT(bit_nr); | ||
120 | /* The meaning of SSR register depends on pull mode. */ | ||
121 | key_press = pull_mode ? !key_press : key_press; | ||
122 | row = BIT_TO_ROW_SSRN(bit_nr, reg_num); | ||
123 | col = BIT_TO_COL(bit_nr); | ||
124 | keycode = bcm_kp_get_keycode(kp, row, col); | ||
125 | input_report_key(kp->input_dev, keycode, key_press); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | static irqreturn_t bcm_kp_isr_thread(int irq, void *dev_id) | ||
130 | { | ||
131 | struct bcm_kp *kp = dev_id; | ||
132 | int pull_mode = (kp->kpcr >> KPCR_MODE_SHIFT) & KPCR_MODE_MASK; | ||
133 | int reg_num; | ||
134 | |||
135 | for (reg_num = 0; reg_num <= 1; reg_num++) | ||
136 | bcm_kp_report_keys(kp, reg_num, pull_mode); | ||
137 | |||
138 | input_sync(kp->input_dev); | ||
139 | |||
140 | return IRQ_HANDLED; | ||
141 | } | ||
142 | |||
143 | static int bcm_kp_start(struct bcm_kp *kp) | ||
144 | { | ||
145 | int error; | ||
146 | |||
147 | if (kp->clk) { | ||
148 | error = clk_prepare_enable(kp->clk); | ||
149 | if (error) | ||
150 | return error; | ||
151 | } | ||
152 | |||
153 | writel(kp->kpior, kp->base + KPIOR_OFFSET); | ||
154 | |||
155 | writel(kp->imr0_val, kp->base + KPIMR0_OFFSET); | ||
156 | writel(kp->imr1_val, kp->base + KPIMR1_OFFSET); | ||
157 | |||
158 | writel(kp->kpemr, kp->base + KPEMR0_OFFSET); | ||
159 | writel(kp->kpemr, kp->base + KPEMR1_OFFSET); | ||
160 | writel(kp->kpemr, kp->base + KPEMR2_OFFSET); | ||
161 | writel(kp->kpemr, kp->base + KPEMR3_OFFSET); | ||
162 | |||
163 | writel(0xFFFFFFFF, kp->base + KPICR0_OFFSET); | ||
164 | writel(0xFFFFFFFF, kp->base + KPICR1_OFFSET); | ||
165 | |||
166 | kp->last_state[0] = readl(kp->base + KPSSR0_OFFSET); | ||
167 | kp->last_state[0] = readl(kp->base + KPSSR1_OFFSET); | ||
168 | |||
169 | writel(kp->kpcr | KPCR_ENABLE, kp->base + KPCR_OFFSET); | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | static void bcm_kp_stop(const struct bcm_kp *kp) | ||
175 | { | ||
176 | u32 val; | ||
177 | |||
178 | val = readl(kp->base + KPCR_OFFSET); | ||
179 | val &= ~KPCR_ENABLE; | ||
180 | writel(0, kp->base + KPCR_OFFSET); | ||
181 | writel(0, kp->base + KPIMR0_OFFSET); | ||
182 | writel(0, kp->base + KPIMR1_OFFSET); | ||
183 | writel(0xFFFFFFFF, kp->base + KPICR0_OFFSET); | ||
184 | writel(0xFFFFFFFF, kp->base + KPICR1_OFFSET); | ||
185 | |||
186 | if (kp->clk) | ||
187 | clk_disable_unprepare(kp->clk); | ||
188 | } | ||
189 | |||
190 | static int bcm_kp_open(struct input_dev *dev) | ||
191 | { | ||
192 | struct bcm_kp *kp = input_get_drvdata(dev); | ||
193 | |||
194 | return bcm_kp_start(kp); | ||
195 | } | ||
196 | |||
197 | static void bcm_kp_close(struct input_dev *dev) | ||
198 | { | ||
199 | struct bcm_kp *kp = input_get_drvdata(dev); | ||
200 | |||
201 | bcm_kp_stop(kp); | ||
202 | } | ||
203 | |||
204 | static int bcm_kp_matrix_key_parse_dt(struct bcm_kp *kp) | ||
205 | { | ||
206 | struct device *dev = kp->input_dev->dev.parent; | ||
207 | struct device_node *np = dev->of_node; | ||
208 | int error; | ||
209 | unsigned int dt_val; | ||
210 | unsigned int i; | ||
211 | unsigned int num_rows, col_mask, rows_set; | ||
212 | |||
213 | /* Initialize the KPCR Keypad Configuration Register */ | ||
214 | kp->kpcr = KPCR_STATUSFILTERENABLE | KPCR_COLFILTERENABLE; | ||
215 | |||
216 | error = matrix_keypad_parse_of_params(dev, &kp->n_rows, &kp->n_cols); | ||
217 | if (error) { | ||
218 | dev_err(dev, "failed to parse kp params\n"); | ||
219 | return error; | ||
220 | } | ||
221 | |||
222 | /* Set row width for the ASIC block. */ | ||
223 | kp->kpcr |= (kp->n_rows - 1) << KPCR_ROWWIDTH_SHIFT; | ||
224 | |||
225 | /* Set column width for the ASIC block. */ | ||
226 | kp->kpcr |= (kp->n_cols - 1) << KPCR_COLUMNWIDTH_SHIFT; | ||
227 | |||
228 | /* Configure the IMR registers */ | ||
229 | |||
230 | /* | ||
231 | * IMR registers contain interrupt enable bits for 8x8 matrix | ||
232 | * IMR0 register format: <row3> <row2> <row1> <row0> | ||
233 | * IMR1 register format: <row7> <row6> <row5> <row4> | ||
234 | */ | ||
235 | col_mask = (1 << (kp->n_cols)) - 1; | ||
236 | num_rows = kp->n_rows; | ||
237 | |||
238 | /* Set column bits in rows 0 to 3 in IMR0 */ | ||
239 | kp->imr0_val = col_mask; | ||
240 | |||
241 | rows_set = 1; | ||
242 | while (--num_rows && rows_set++ < 4) | ||
243 | kp->imr0_val |= kp->imr0_val << MAX_COLS; | ||
244 | |||
245 | /* Set column bits in rows 4 to 7 in IMR1 */ | ||
246 | kp->imr1_val = 0; | ||
247 | if (num_rows) { | ||
248 | kp->imr1_val = col_mask; | ||
249 | while (--num_rows) | ||
250 | kp->imr1_val |= kp->imr1_val << MAX_COLS; | ||
251 | } | ||
252 | |||
253 | /* Initialize the KPEMR Keypress Edge Mode Registers */ | ||
254 | /* Trigger on both edges */ | ||
255 | kp->kpemr = 0; | ||
256 | for (i = 0; i <= 30; i += 2) | ||
257 | kp->kpemr |= (KPEMR_EDGETYPE_BOTH << i); | ||
258 | |||
259 | /* | ||
260 | * Obtain the Status filter debounce value and verify against the | ||
261 | * possible values specified in the DT binding. | ||
262 | */ | ||
263 | of_property_read_u32(np, "status-debounce-filter-period", &dt_val); | ||
264 | |||
265 | if (dt_val > KPCR_STATUSFILTERTYPE_MAX) { | ||
266 | dev_err(dev, "Invalid Status filter debounce value %d\n", | ||
267 | dt_val); | ||
268 | return -EINVAL; | ||
269 | } | ||
270 | |||
271 | kp->kpcr |= dt_val << KPCR_STATUSFILTERTYPE_SHIFT; | ||
272 | |||
273 | /* | ||
274 | * Obtain the Column filter debounce value and verify against the | ||
275 | * possible values specified in the DT binding. | ||
276 | */ | ||
277 | of_property_read_u32(np, "col-debounce-filter-period", &dt_val); | ||
278 | |||
279 | if (dt_val > KPCR_COLFILTERTYPE_MAX) { | ||
280 | dev_err(dev, "Invalid Column filter debounce value %d\n", | ||
281 | dt_val); | ||
282 | return -EINVAL; | ||
283 | } | ||
284 | |||
285 | kp->kpcr |= dt_val << KPCR_COLFILTERTYPE_SHIFT; | ||
286 | |||
287 | /* | ||
288 | * Determine between the row and column, | ||
289 | * which should be configured as output. | ||
290 | */ | ||
291 | if (of_property_read_bool(np, "row-output-enabled")) { | ||
292 | /* | ||
293 | * Set RowOContrl or ColumnOContrl in KPIOR | ||
294 | * to the number of pins to drive as outputs | ||
295 | */ | ||
296 | kp->kpior = ((1 << kp->n_rows) - 1) << | ||
297 | KPIOR_ROWOCONTRL_SHIFT; | ||
298 | } else { | ||
299 | kp->kpior = ((1 << kp->n_cols) - 1) << | ||
300 | KPIOR_COLUMNOCONTRL_SHIFT; | ||
301 | } | ||
302 | |||
303 | /* | ||
304 | * Determine if the scan pull up needs to be enabled | ||
305 | */ | ||
306 | if (of_property_read_bool(np, "pull-up-enabled")) | ||
307 | kp->kpcr |= KPCR_MODE; | ||
308 | |||
309 | dev_dbg(dev, "n_rows=%d n_col=%d kpcr=%x kpior=%x kpemr=%x\n", | ||
310 | kp->n_rows, kp->n_cols, | ||
311 | kp->kpcr, kp->kpior, kp->kpemr); | ||
312 | |||
313 | return 0; | ||
314 | } | ||
315 | |||
316 | |||
317 | static int bcm_kp_probe(struct platform_device *pdev) | ||
318 | { | ||
319 | struct bcm_kp *kp; | ||
320 | struct input_dev *input_dev; | ||
321 | struct resource *res; | ||
322 | int error; | ||
323 | |||
324 | kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL); | ||
325 | if (!kp) | ||
326 | return -ENOMEM; | ||
327 | |||
328 | input_dev = devm_input_allocate_device(&pdev->dev); | ||
329 | if (!input_dev) { | ||
330 | dev_err(&pdev->dev, "failed to allocate the input device\n"); | ||
331 | return -ENOMEM; | ||
332 | } | ||
333 | |||
334 | __set_bit(EV_KEY, input_dev->evbit); | ||
335 | |||
336 | /* Enable auto repeat feature of Linux input subsystem */ | ||
337 | if (of_property_read_bool(pdev->dev.of_node, "autorepeat")) | ||
338 | __set_bit(EV_REP, input_dev->evbit); | ||
339 | |||
340 | input_dev->name = pdev->name; | ||
341 | input_dev->phys = "keypad/input0"; | ||
342 | input_dev->dev.parent = &pdev->dev; | ||
343 | input_dev->open = bcm_kp_open; | ||
344 | input_dev->close = bcm_kp_close; | ||
345 | |||
346 | input_dev->id.bustype = BUS_HOST; | ||
347 | input_dev->id.vendor = 0x0001; | ||
348 | input_dev->id.product = 0x0001; | ||
349 | input_dev->id.version = 0x0100; | ||
350 | |||
351 | input_set_drvdata(input_dev, kp); | ||
352 | |||
353 | kp->input_dev = input_dev; | ||
354 | |||
355 | platform_set_drvdata(pdev, kp); | ||
356 | |||
357 | error = bcm_kp_matrix_key_parse_dt(kp); | ||
358 | if (error) | ||
359 | return error; | ||
360 | |||
361 | error = matrix_keypad_build_keymap(NULL, NULL, | ||
362 | kp->n_rows, kp->n_cols, | ||
363 | NULL, input_dev); | ||
364 | if (error) { | ||
365 | dev_err(&pdev->dev, "failed to build keymap\n"); | ||
366 | return error; | ||
367 | } | ||
368 | |||
369 | /* Get the KEYPAD base address */ | ||
370 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
371 | if (!res) { | ||
372 | dev_err(&pdev->dev, "Missing keypad base address resource\n"); | ||
373 | return -ENODEV; | ||
374 | } | ||
375 | |||
376 | kp->base = devm_ioremap_resource(&pdev->dev, res); | ||
377 | if (IS_ERR(kp->base)) | ||
378 | return PTR_ERR(kp->base); | ||
379 | |||
380 | /* Enable clock */ | ||
381 | kp->clk = devm_clk_get(&pdev->dev, "peri_clk"); | ||
382 | if (IS_ERR(kp->clk)) { | ||
383 | error = PTR_ERR(kp->clk); | ||
384 | if (error != -ENOENT) { | ||
385 | if (error != -EPROBE_DEFER) | ||
386 | dev_err(&pdev->dev, "Failed to get clock\n"); | ||
387 | return error; | ||
388 | } | ||
389 | dev_dbg(&pdev->dev, | ||
390 | "No clock specified. Assuming it's enabled\n"); | ||
391 | kp->clk = NULL; | ||
392 | } else { | ||
393 | unsigned int desired_rate; | ||
394 | long actual_rate; | ||
395 | |||
396 | error = of_property_read_u32(pdev->dev.of_node, | ||
397 | "clock-frequency", &desired_rate); | ||
398 | if (error < 0) | ||
399 | desired_rate = DEFAULT_CLK_HZ; | ||
400 | |||
401 | actual_rate = clk_round_rate(kp->clk, desired_rate); | ||
402 | if (actual_rate <= 0) | ||
403 | return -EINVAL; | ||
404 | |||
405 | error = clk_set_rate(kp->clk, actual_rate); | ||
406 | if (error) | ||
407 | return error; | ||
408 | |||
409 | error = clk_prepare_enable(kp->clk); | ||
410 | if (error) | ||
411 | return error; | ||
412 | } | ||
413 | |||
414 | /* Put the kp into a known sane state */ | ||
415 | bcm_kp_stop(kp); | ||
416 | |||
417 | kp->irq = platform_get_irq(pdev, 0); | ||
418 | if (kp->irq < 0) { | ||
419 | dev_err(&pdev->dev, "no IRQ specified\n"); | ||
420 | return -EINVAL; | ||
421 | } | ||
422 | |||
423 | error = devm_request_threaded_irq(&pdev->dev, kp->irq, | ||
424 | NULL, bcm_kp_isr_thread, | ||
425 | IRQF_ONESHOT, pdev->name, kp); | ||
426 | if (error) { | ||
427 | dev_err(&pdev->dev, "failed to request IRQ\n"); | ||
428 | return error; | ||
429 | } | ||
430 | |||
431 | error = input_register_device(input_dev); | ||
432 | if (error) { | ||
433 | dev_err(&pdev->dev, "failed to register input device\n"); | ||
434 | return error; | ||
435 | } | ||
436 | |||
437 | return 0; | ||
438 | } | ||
439 | |||
440 | static const struct of_device_id bcm_kp_of_match[] = { | ||
441 | { .compatible = "brcm,bcm-keypad" }, | ||
442 | { }, | ||
443 | }; | ||
444 | MODULE_DEVICE_TABLE(of, bcm_kp_of_match); | ||
445 | |||
446 | static struct platform_driver bcm_kp_device_driver = { | ||
447 | .probe = bcm_kp_probe, | ||
448 | .driver = { | ||
449 | .name = "bcm-keypad", | ||
450 | .of_match_table = of_match_ptr(bcm_kp_of_match), | ||
451 | } | ||
452 | }; | ||
453 | |||
454 | module_platform_driver(bcm_kp_device_driver); | ||
455 | |||
456 | MODULE_AUTHOR("Broadcom Corporation"); | ||
457 | MODULE_DESCRIPTION("BCM Keypad Driver"); | ||
458 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c index ffa989f2c785..64b9b59ad4cb 100644 --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c | |||
@@ -338,7 +338,7 @@ static int cros_ec_keyb_resume(struct device *dev) | |||
338 | * wake source (e.g. the lid is open and the user might press a key to | 338 | * wake source (e.g. the lid is open and the user might press a key to |
339 | * wake) then the key scan buffer should be preserved. | 339 | * wake) then the key scan buffer should be preserved. |
340 | */ | 340 | */ |
341 | if (ckdev->ec->was_wake_device) | 341 | if (!ckdev->ec->was_wake_device) |
342 | cros_ec_keyb_clear_keyboard(ckdev); | 342 | cros_ec_keyb_clear_keyboard(ckdev); |
343 | 343 | ||
344 | return 0; | 344 | return 0; |
diff --git a/drivers/input/keyboard/ipaq-micro-keys.c b/drivers/input/keyboard/ipaq-micro-keys.c new file mode 100644 index 000000000000..602900d1f937 --- /dev/null +++ b/drivers/input/keyboard/ipaq-micro-keys.c | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License version 2 as | ||
4 | * published by the Free Software Foundation. | ||
5 | * | ||
6 | * h3600 atmel micro companion support, key subdevice | ||
7 | * based on previous kernel 2.4 version | ||
8 | * Author : Alessandro Gardich <gremlin@gremlin.it> | ||
9 | * Author : Linus Walleij <linus.walleij@linaro.org> | ||
10 | * | ||
11 | */ | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/fs.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/sched.h> | ||
17 | #include <linux/pm.h> | ||
18 | #include <linux/sysctl.h> | ||
19 | #include <linux/proc_fs.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/input.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <linux/mfd/ipaq-micro.h> | ||
25 | |||
26 | struct ipaq_micro_keys { | ||
27 | struct ipaq_micro *micro; | ||
28 | struct input_dev *input; | ||
29 | u16 *codes; | ||
30 | }; | ||
31 | |||
32 | static const u16 micro_keycodes[] = { | ||
33 | KEY_RECORD, /* 1: Record button */ | ||
34 | KEY_CALENDAR, /* 2: Calendar */ | ||
35 | KEY_ADDRESSBOOK, /* 3: Contacts (looks like Outlook) */ | ||
36 | KEY_MAIL, /* 4: Envelope (Q on older iPAQs) */ | ||
37 | KEY_HOMEPAGE, /* 5: Start (looks like swoopy arrow) */ | ||
38 | KEY_UP, /* 6: Up */ | ||
39 | KEY_RIGHT, /* 7: Right */ | ||
40 | KEY_LEFT, /* 8: Left */ | ||
41 | KEY_DOWN, /* 9: Down */ | ||
42 | }; | ||
43 | |||
44 | static void micro_key_receive(void *data, int len, unsigned char *msg) | ||
45 | { | ||
46 | struct ipaq_micro_keys *keys = data; | ||
47 | int key, down; | ||
48 | |||
49 | down = 0x80 & msg[0]; | ||
50 | key = 0x7f & msg[0]; | ||
51 | |||
52 | if (key < ARRAY_SIZE(micro_keycodes)) { | ||
53 | input_report_key(keys->input, keys->codes[key], down); | ||
54 | input_sync(keys->input); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | static void micro_key_start(struct ipaq_micro_keys *keys) | ||
59 | { | ||
60 | spin_lock(&keys->micro->lock); | ||
61 | keys->micro->key = micro_key_receive; | ||
62 | keys->micro->key_data = keys; | ||
63 | spin_unlock(&keys->micro->lock); | ||
64 | } | ||
65 | |||
66 | static void micro_key_stop(struct ipaq_micro_keys *keys) | ||
67 | { | ||
68 | spin_lock(&keys->micro->lock); | ||
69 | keys->micro->key = NULL; | ||
70 | keys->micro->key_data = NULL; | ||
71 | spin_unlock(&keys->micro->lock); | ||
72 | } | ||
73 | |||
74 | static int micro_key_open(struct input_dev *input) | ||
75 | { | ||
76 | struct ipaq_micro_keys *keys = input_get_drvdata(input); | ||
77 | |||
78 | micro_key_start(keys); | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | static void micro_key_close(struct input_dev *input) | ||
84 | { | ||
85 | struct ipaq_micro_keys *keys = input_get_drvdata(input); | ||
86 | |||
87 | micro_key_stop(keys); | ||
88 | } | ||
89 | |||
90 | static int micro_key_probe(struct platform_device *pdev) | ||
91 | { | ||
92 | struct ipaq_micro_keys *keys; | ||
93 | int error; | ||
94 | int i; | ||
95 | |||
96 | keys = devm_kzalloc(&pdev->dev, sizeof(*keys), GFP_KERNEL); | ||
97 | if (!keys) | ||
98 | return -ENOMEM; | ||
99 | |||
100 | keys->micro = dev_get_drvdata(pdev->dev.parent); | ||
101 | |||
102 | keys->input = devm_input_allocate_device(&pdev->dev); | ||
103 | if (!keys->input) | ||
104 | return -ENOMEM; | ||
105 | |||
106 | keys->input->keycodesize = sizeof(micro_keycodes[0]); | ||
107 | keys->input->keycodemax = ARRAY_SIZE(micro_keycodes); | ||
108 | keys->codes = devm_kmemdup(&pdev->dev, micro_keycodes, | ||
109 | keys->input->keycodesize * keys->input->keycodemax, | ||
110 | GFP_KERNEL); | ||
111 | keys->input->keycode = keys->codes; | ||
112 | |||
113 | __set_bit(EV_KEY, keys->input->evbit); | ||
114 | for (i = 0; i < ARRAY_SIZE(micro_keycodes); i++) | ||
115 | __set_bit(micro_keycodes[i], keys->input->keybit); | ||
116 | |||
117 | keys->input->name = "h3600 micro keys"; | ||
118 | keys->input->open = micro_key_open; | ||
119 | keys->input->close = micro_key_close; | ||
120 | input_set_drvdata(keys->input, keys); | ||
121 | |||
122 | error = input_register_device(keys->input); | ||
123 | if (error) | ||
124 | return error; | ||
125 | |||
126 | platform_set_drvdata(pdev, keys); | ||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | static int __maybe_unused micro_key_suspend(struct device *dev) | ||
131 | { | ||
132 | struct ipaq_micro_keys *keys = dev_get_drvdata(dev); | ||
133 | |||
134 | micro_key_stop(keys); | ||
135 | |||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | static int __maybe_unused micro_key_resume(struct device *dev) | ||
140 | { | ||
141 | struct ipaq_micro_keys *keys = dev_get_drvdata(dev); | ||
142 | struct input_dev *input = keys->input; | ||
143 | |||
144 | mutex_lock(&input->mutex); | ||
145 | |||
146 | if (input->users) | ||
147 | micro_key_start(keys); | ||
148 | |||
149 | mutex_unlock(&input->mutex); | ||
150 | |||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | static SIMPLE_DEV_PM_OPS(micro_key_dev_pm_ops, | ||
155 | micro_key_suspend, micro_key_resume); | ||
156 | |||
157 | static struct platform_driver micro_key_device_driver = { | ||
158 | .driver = { | ||
159 | .name = "ipaq-micro-keys", | ||
160 | .pm = µ_key_dev_pm_ops, | ||
161 | }, | ||
162 | .probe = micro_key_probe, | ||
163 | }; | ||
164 | module_platform_driver(micro_key_device_driver); | ||
165 | |||
166 | MODULE_LICENSE("GPL"); | ||
167 | MODULE_DESCRIPTION("driver for iPAQ Atmel micro keys"); | ||
168 | MODULE_ALIAS("platform:ipaq-micro-keys"); | ||
diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c index 32522176b0bd..31c606a4dd31 100644 --- a/drivers/input/keyboard/tc3589x-keypad.c +++ b/drivers/input/keyboard/tc3589x-keypad.c | |||
@@ -70,6 +70,28 @@ | |||
70 | #define TC3589x_KBD_INT_CLR 0x1 | 70 | #define TC3589x_KBD_INT_CLR 0x1 |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * struct tc35893_keypad_platform_data - platform specific keypad data | ||
74 | * @keymap_data: matrix scan code table for keycodes | ||
75 | * @krow: mask for available rows, value is 0xFF | ||
76 | * @kcol: mask for available columns, value is 0xFF | ||
77 | * @debounce_period: platform specific debounce time | ||
78 | * @settle_time: platform specific settle down time | ||
79 | * @irqtype: type of interrupt, falling or rising edge | ||
80 | * @enable_wakeup: specifies if keypad event can wake up system from sleep | ||
81 | * @no_autorepeat: flag for auto repetition | ||
82 | */ | ||
83 | struct tc3589x_keypad_platform_data { | ||
84 | const struct matrix_keymap_data *keymap_data; | ||
85 | u8 krow; | ||
86 | u8 kcol; | ||
87 | u8 debounce_period; | ||
88 | u8 settle_time; | ||
89 | unsigned long irqtype; | ||
90 | bool enable_wakeup; | ||
91 | bool no_autorepeat; | ||
92 | }; | ||
93 | |||
94 | /** | ||
73 | * struct tc_keypad - data structure used by keypad driver | 95 | * struct tc_keypad - data structure used by keypad driver |
74 | * @tc3589x: pointer to tc35893 | 96 | * @tc3589x: pointer to tc35893 |
75 | * @input: pointer to input device object | 97 | * @input: pointer to input device object |
@@ -354,13 +376,10 @@ static int tc3589x_keypad_probe(struct platform_device *pdev) | |||
354 | const struct tc3589x_keypad_platform_data *plat; | 376 | const struct tc3589x_keypad_platform_data *plat; |
355 | int error, irq; | 377 | int error, irq; |
356 | 378 | ||
357 | plat = tc3589x->pdata->keypad; | 379 | plat = tc3589x_keypad_of_probe(&pdev->dev); |
358 | if (!plat) { | 380 | if (IS_ERR(plat)) { |
359 | plat = tc3589x_keypad_of_probe(&pdev->dev); | 381 | dev_err(&pdev->dev, "invalid keypad platform data\n"); |
360 | if (IS_ERR(plat)) { | 382 | return PTR_ERR(plat); |
361 | dev_err(&pdev->dev, "invalid keypad platform data\n"); | ||
362 | return PTR_ERR(plat); | ||
363 | } | ||
364 | } | 383 | } |
365 | 384 | ||
366 | irq = platform_get_irq(pdev, 0); | 385 | irq = platform_get_irq(pdev, 0); |