Lines Matching +full:short +full:- +full:press +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2010
5 * Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson
6 * Author: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
22 #include <linux/platform_data/keypad-nomadik-ske.h>
54 * struct ske_keypad - data structure used by keypad driver
69 unsigned short keymap[SKE_KPD_NUM_ROWS * SKE_KPD_NUM_COLS];
80 spin_lock(&keypad->ske_keypad_lock); in ske_keypad_set_bits()
82 ret = readl(keypad->reg_base + addr); in ske_keypad_set_bits()
85 writel(ret, keypad->reg_base + addr); in ske_keypad_set_bits()
87 spin_unlock(&keypad->ske_keypad_lock); in ske_keypad_set_bits()
93 * Enable Multi key press detection, auto scan mode
98 int timeout = keypad->board->debounce_ms; in ske_keypad_chip_init()
101 while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--) in ske_keypad_chip_init()
104 if (timeout == -1) in ske_keypad_chip_init()
105 return -EINVAL; in ske_keypad_chip_init()
110 * dbounce value in steps of 32/32.768 ms in ske_keypad_chip_init()
112 spin_lock(&keypad->ske_keypad_lock); in ske_keypad_chip_init()
113 value = readl(keypad->reg_base + SKE_DBCR); in ske_keypad_chip_init()
115 value |= ((keypad->board->debounce_ms * 32000)/32768) << 8; in ske_keypad_chip_init()
116 writel(value, keypad->reg_base + SKE_DBCR); in ske_keypad_chip_init()
117 spin_unlock(&keypad->ske_keypad_lock); in ske_keypad_chip_init()
126 value = (keypad->board->kcol - 1) << 3; in ske_keypad_chip_init()
132 /* un-mask keypad interrupts */ in ske_keypad_chip_init()
144 struct input_dev *input = keypad->input; in ske_keypad_report()
157 ske_ris = readl(keypad->reg_base + SKE_RIS); in ske_keypad_report()
161 input_report_key(input, keypad->keymap[code], key_pressed); in ske_keypad_report()
163 num_of_rows--; in ske_keypad_report()
181 ske_asr = readl(keypad->reg_base + SKE_ASR0 + (4 * i)); in ske_keypad_read_data()
202 int timeout = keypad->board->debounce_ms; in ske_keypad_irq()
208 while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --timeout) in ske_keypad_irq()
215 while ((readl(keypad->reg_base + SKE_RIS)) && --timeout) in ske_keypad_irq()
227 dev_get_platdata(&pdev->dev); in ske_keypad_probe()
235 dev_err(&pdev->dev, "invalid keypad platform data\n"); in ske_keypad_probe()
236 return -EINVAL; in ske_keypad_probe()
241 return -EINVAL; in ske_keypad_probe()
245 dev_err(&pdev->dev, "missing platform resources\n"); in ske_keypad_probe()
246 return -EINVAL; in ske_keypad_probe()
252 dev_err(&pdev->dev, "failed to allocate keypad memory\n"); in ske_keypad_probe()
253 error = -ENOMEM; in ske_keypad_probe()
257 keypad->irq = irq; in ske_keypad_probe()
258 keypad->board = plat; in ske_keypad_probe()
259 keypad->input = input; in ske_keypad_probe()
260 spin_lock_init(&keypad->ske_keypad_lock); in ske_keypad_probe()
262 if (!request_mem_region(res->start, resource_size(res), pdev->name)) { in ske_keypad_probe()
263 dev_err(&pdev->dev, "failed to request I/O memory\n"); in ske_keypad_probe()
264 error = -EBUSY; in ske_keypad_probe()
268 keypad->reg_base = ioremap(res->start, resource_size(res)); in ske_keypad_probe()
269 if (!keypad->reg_base) { in ske_keypad_probe()
270 dev_err(&pdev->dev, "failed to remap I/O memory\n"); in ske_keypad_probe()
271 error = -ENXIO; in ske_keypad_probe()
275 keypad->pclk = clk_get(&pdev->dev, "apb_pclk"); in ske_keypad_probe()
276 if (IS_ERR(keypad->pclk)) { in ske_keypad_probe()
277 dev_err(&pdev->dev, "failed to get pclk\n"); in ske_keypad_probe()
278 error = PTR_ERR(keypad->pclk); in ske_keypad_probe()
282 keypad->clk = clk_get(&pdev->dev, NULL); in ske_keypad_probe()
283 if (IS_ERR(keypad->clk)) { in ske_keypad_probe()
284 dev_err(&pdev->dev, "failed to get clk\n"); in ske_keypad_probe()
285 error = PTR_ERR(keypad->clk); in ske_keypad_probe()
289 input->id.bustype = BUS_HOST; in ske_keypad_probe()
290 input->name = "ux500-ske-keypad"; in ske_keypad_probe()
291 input->dev.parent = &pdev->dev; in ske_keypad_probe()
293 error = matrix_keypad_build_keymap(plat->keymap_data, NULL, in ske_keypad_probe()
295 keypad->keymap, input); in ske_keypad_probe()
297 dev_err(&pdev->dev, "Failed to build keymap\n"); in ske_keypad_probe()
302 if (!plat->no_autorepeat) in ske_keypad_probe()
303 __set_bit(EV_REP, input->evbit); in ske_keypad_probe()
305 error = clk_prepare_enable(keypad->pclk); in ske_keypad_probe()
307 dev_err(&pdev->dev, "Failed to prepare/enable pclk\n"); in ske_keypad_probe()
311 error = clk_prepare_enable(keypad->clk); in ske_keypad_probe()
313 dev_err(&pdev->dev, "Failed to prepare/enable clk\n"); in ske_keypad_probe()
319 if (keypad->board->init) in ske_keypad_probe()
320 keypad->board->init(); in ske_keypad_probe()
324 dev_err(&pdev->dev, "unable to init keypad hardware\n"); in ske_keypad_probe()
328 error = request_threaded_irq(keypad->irq, NULL, ske_keypad_irq, in ske_keypad_probe()
329 IRQF_ONESHOT, "ske-keypad", keypad); in ske_keypad_probe()
331 dev_err(&pdev->dev, "allocate irq %d failed\n", keypad->irq); in ske_keypad_probe()
337 dev_err(&pdev->dev, in ske_keypad_probe()
342 if (plat->wakeup_enable) in ske_keypad_probe()
343 device_init_wakeup(&pdev->dev, true); in ske_keypad_probe()
350 free_irq(keypad->irq, keypad); in ske_keypad_probe()
352 clk_disable_unprepare(keypad->clk); in ske_keypad_probe()
354 clk_disable_unprepare(keypad->pclk); in ske_keypad_probe()
356 clk_put(keypad->clk); in ske_keypad_probe()
358 clk_put(keypad->pclk); in ske_keypad_probe()
360 iounmap(keypad->reg_base); in ske_keypad_probe()
362 release_mem_region(res->start, resource_size(res)); in ske_keypad_probe()
374 free_irq(keypad->irq, keypad); in ske_keypad_remove()
376 input_unregister_device(keypad->input); in ske_keypad_remove()
378 clk_disable_unprepare(keypad->clk); in ske_keypad_remove()
379 clk_put(keypad->clk); in ske_keypad_remove()
381 if (keypad->board->exit) in ske_keypad_remove()
382 keypad->board->exit(); in ske_keypad_remove()
384 iounmap(keypad->reg_base); in ske_keypad_remove()
385 release_mem_region(res->start, resource_size(res)); in ske_keypad_remove()
426 .name = "nmk-ske-keypad",
436 MODULE_DESCRIPTION("Nomadik Scroll-Key-Encoder Keypad Driver");
437 MODULE_ALIAS("platform:nomadik-ske-keypad");