Lines Matching full:keypad

3  * Samsung keypad driver
23 #include <linux/input/samsung-keypad.h>
79 static void samsung_keypad_scan(struct samsung_keypad *keypad, in samsung_keypad_scan() argument
85 for (col = 0; col < keypad->cols; col++) { in samsung_keypad_scan()
86 if (keypad->type == KEYPAD_TYPE_S5PV210) { in samsung_keypad_scan()
94 writel(val, keypad->base + SAMSUNG_KEYIFCOL); in samsung_keypad_scan()
97 val = readl(keypad->base + SAMSUNG_KEYIFROW); in samsung_keypad_scan()
98 row_state[col] = ~val & ((1 << keypad->rows) - 1); in samsung_keypad_scan()
102 writel(0, keypad->base + SAMSUNG_KEYIFCOL); in samsung_keypad_scan()
105 static bool samsung_keypad_report(struct samsung_keypad *keypad, in samsung_keypad_report() argument
108 struct input_dev *input_dev = keypad->input_dev; in samsung_keypad_report()
115 for (col = 0; col < keypad->cols; col++) { in samsung_keypad_report()
116 changed = row_state[col] ^ keypad->row_state[col]; in samsung_keypad_report()
121 for (row = 0; row < keypad->rows; row++) { in samsung_keypad_report()
127 dev_dbg(&keypad->input_dev->dev, in samsung_keypad_report()
131 val = MATRIX_SCAN_CODE(row, col, keypad->row_shift); in samsung_keypad_report()
135 keypad->keycodes[val], pressed); in samsung_keypad_report()
137 input_sync(keypad->input_dev); in samsung_keypad_report()
140 memcpy(keypad->row_state, row_state, sizeof(keypad->row_state)); in samsung_keypad_report()
147 struct samsung_keypad *keypad = dev_id; in samsung_keypad_irq() local
151 pm_runtime_get_sync(&keypad->pdev->dev); in samsung_keypad_irq()
154 readl(keypad->base + SAMSUNG_KEYIFSTSCLR); in samsung_keypad_irq()
156 writel(~0x0, keypad->base + SAMSUNG_KEYIFSTSCLR); in samsung_keypad_irq()
158 samsung_keypad_scan(keypad, row_state); in samsung_keypad_irq()
160 key_down = samsung_keypad_report(keypad, row_state); in samsung_keypad_irq()
162 wait_event_timeout(keypad->wait, keypad->stopped, in samsung_keypad_irq()
165 } while (key_down && !keypad->stopped); in samsung_keypad_irq()
167 pm_runtime_put(&keypad->pdev->dev); in samsung_keypad_irq()
172 static void samsung_keypad_start(struct samsung_keypad *keypad) in samsung_keypad_start() argument
176 pm_runtime_get_sync(&keypad->pdev->dev); in samsung_keypad_start()
179 keypad->stopped = false; in samsung_keypad_start()
181 clk_enable(keypad->clk); in samsung_keypad_start()
184 val = readl(keypad->base + SAMSUNG_KEYIFCON); in samsung_keypad_start()
186 writel(val, keypad->base + SAMSUNG_KEYIFCON); in samsung_keypad_start()
189 writel(0, keypad->base + SAMSUNG_KEYIFCOL); in samsung_keypad_start()
191 pm_runtime_put(&keypad->pdev->dev); in samsung_keypad_start()
194 static void samsung_keypad_stop(struct samsung_keypad *keypad) in samsung_keypad_stop() argument
198 pm_runtime_get_sync(&keypad->pdev->dev); in samsung_keypad_stop()
201 keypad->stopped = true; in samsung_keypad_stop()
202 wake_up(&keypad->wait); in samsung_keypad_stop()
203 disable_irq(keypad->irq); in samsung_keypad_stop()
206 writel(~0x0, keypad->base + SAMSUNG_KEYIFSTSCLR); in samsung_keypad_stop()
209 val = readl(keypad->base + SAMSUNG_KEYIFCON); in samsung_keypad_stop()
211 writel(val, keypad->base + SAMSUNG_KEYIFCON); in samsung_keypad_stop()
213 clk_disable(keypad->clk); in samsung_keypad_stop()
219 enable_irq(keypad->irq); in samsung_keypad_stop()
221 pm_runtime_put(&keypad->pdev->dev); in samsung_keypad_stop()
226 struct samsung_keypad *keypad = input_get_drvdata(input_dev); in samsung_keypad_open() local
228 samsung_keypad_start(keypad); in samsung_keypad_open()
235 struct samsung_keypad *keypad = input_get_drvdata(input_dev); in samsung_keypad_close() local
237 samsung_keypad_stop(keypad); in samsung_keypad_close()
261 of_property_read_u32(np, "samsung,keypad-num-rows", &num_rows); in samsung_keypad_parse_dt()
262 of_property_read_u32(np, "samsung,keypad-num-columns", &num_cols); in samsung_keypad_parse_dt()
264 dev_err(dev, "number of keypad rows/columns not specified\n"); in samsung_keypad_parse_dt()
288 of_property_read_u32(key_np, "keypad,row", &row); in samsung_keypad_parse_dt()
289 of_property_read_u32(key_np, "keypad,column", &col); in samsung_keypad_parse_dt()
318 struct samsung_keypad *keypad; in samsung_keypad_probe() local
349 keymap_size = (pdata->rows << row_shift) * sizeof(keypad->keycodes[0]); in samsung_keypad_probe()
351 keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad) + keymap_size, in samsung_keypad_probe()
354 if (!keypad || !input_dev) in samsung_keypad_probe()
361 keypad->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); in samsung_keypad_probe()
362 if (!keypad->base) in samsung_keypad_probe()
365 keypad->clk = devm_clk_get(&pdev->dev, "keypad"); in samsung_keypad_probe()
366 if (IS_ERR(keypad->clk)) { in samsung_keypad_probe()
367 dev_err(&pdev->dev, "failed to get keypad clk\n"); in samsung_keypad_probe()
368 return PTR_ERR(keypad->clk); in samsung_keypad_probe()
371 error = clk_prepare(keypad->clk); in samsung_keypad_probe()
373 dev_err(&pdev->dev, "keypad clock prepare failed\n"); in samsung_keypad_probe()
377 keypad->input_dev = input_dev; in samsung_keypad_probe()
378 keypad->pdev = pdev; in samsung_keypad_probe()
379 keypad->row_shift = row_shift; in samsung_keypad_probe()
380 keypad->rows = pdata->rows; in samsung_keypad_probe()
381 keypad->cols = pdata->cols; in samsung_keypad_probe()
382 keypad->stopped = true; in samsung_keypad_probe()
383 init_waitqueue_head(&keypad->wait); in samsung_keypad_probe()
386 keypad->type = of_device_is_compatible(pdev->dev.of_node, in samsung_keypad_probe()
387 "samsung,s5pv210-keypad"); in samsung_keypad_probe()
389 keypad->type = platform_get_device_id(pdev)->driver_data; in samsung_keypad_probe()
400 keypad->keycodes, input_dev); in samsung_keypad_probe()
410 input_set_drvdata(input_dev, keypad); in samsung_keypad_probe()
412 keypad->irq = platform_get_irq(pdev, 0); in samsung_keypad_probe()
413 if (keypad->irq < 0) { in samsung_keypad_probe()
414 error = keypad->irq; in samsung_keypad_probe()
418 error = devm_request_threaded_irq(&pdev->dev, keypad->irq, NULL, in samsung_keypad_probe()
420 dev_name(&pdev->dev), keypad); in samsung_keypad_probe()
422 dev_err(&pdev->dev, "failed to register keypad interrupt\n"); in samsung_keypad_probe()
427 platform_set_drvdata(pdev, keypad); in samsung_keypad_probe()
430 error = input_register_device(keypad->input_dev); in samsung_keypad_probe()
444 clk_unprepare(keypad->clk); in samsung_keypad_probe()
450 struct samsung_keypad *keypad = platform_get_drvdata(pdev); in samsung_keypad_remove() local
454 input_unregister_device(keypad->input_dev); in samsung_keypad_remove()
456 clk_unprepare(keypad->clk); in samsung_keypad_remove()
465 struct samsung_keypad *keypad = platform_get_drvdata(pdev); in samsung_keypad_runtime_suspend() local
469 if (keypad->stopped) in samsung_keypad_runtime_suspend()
473 error = enable_irq_wake(keypad->irq); in samsung_keypad_runtime_suspend()
475 keypad->wake_enabled = true; in samsung_keypad_runtime_suspend()
477 val = readl(keypad->base + SAMSUNG_KEYIFCON); in samsung_keypad_runtime_suspend()
479 writel(val, keypad->base + SAMSUNG_KEYIFCON); in samsung_keypad_runtime_suspend()
481 clk_disable(keypad->clk); in samsung_keypad_runtime_suspend()
489 struct samsung_keypad *keypad = platform_get_drvdata(pdev); in samsung_keypad_runtime_resume() local
492 if (keypad->stopped) in samsung_keypad_runtime_resume()
495 clk_enable(keypad->clk); in samsung_keypad_runtime_resume()
497 val = readl(keypad->base + SAMSUNG_KEYIFCON); in samsung_keypad_runtime_resume()
499 writel(val, keypad->base + SAMSUNG_KEYIFCON); in samsung_keypad_runtime_resume()
501 if (keypad->wake_enabled) in samsung_keypad_runtime_resume()
502 disable_irq_wake(keypad->irq); in samsung_keypad_runtime_resume()
509 static void samsung_keypad_toggle_wakeup(struct samsung_keypad *keypad, in samsung_keypad_toggle_wakeup() argument
514 clk_enable(keypad->clk); in samsung_keypad_toggle_wakeup()
516 val = readl(keypad->base + SAMSUNG_KEYIFCON); in samsung_keypad_toggle_wakeup()
519 if (device_may_wakeup(&keypad->pdev->dev)) in samsung_keypad_toggle_wakeup()
520 enable_irq_wake(keypad->irq); in samsung_keypad_toggle_wakeup()
523 if (device_may_wakeup(&keypad->pdev->dev)) in samsung_keypad_toggle_wakeup()
524 disable_irq_wake(keypad->irq); in samsung_keypad_toggle_wakeup()
526 writel(val, keypad->base + SAMSUNG_KEYIFCON); in samsung_keypad_toggle_wakeup()
528 clk_disable(keypad->clk); in samsung_keypad_toggle_wakeup()
534 struct samsung_keypad *keypad = platform_get_drvdata(pdev); in samsung_keypad_suspend() local
535 struct input_dev *input_dev = keypad->input_dev; in samsung_keypad_suspend()
540 samsung_keypad_stop(keypad); in samsung_keypad_suspend()
542 samsung_keypad_toggle_wakeup(keypad, true); in samsung_keypad_suspend()
552 struct samsung_keypad *keypad = platform_get_drvdata(pdev); in samsung_keypad_resume() local
553 struct input_dev *input_dev = keypad->input_dev; in samsung_keypad_resume()
557 samsung_keypad_toggle_wakeup(keypad, false); in samsung_keypad_resume()
560 samsung_keypad_start(keypad); in samsung_keypad_resume()
576 { .compatible = "samsung,s3c6410-keypad" },
577 { .compatible = "samsung,s5pv210-keypad" },
585 .name = "samsung-keypad",
588 .name = "s5pv210-keypad",
599 .name = "samsung-keypad",
607 MODULE_DESCRIPTION("Samsung keypad driver");