Lines Matching refs:keypad
22 #include <linux/platform_data/keypad-nomadik-ske.h>
44 /* keypad auto scan registers */
54 * struct ske_keypad - data structure used by keypad driver
58 * @board: keypad platform device
73 static void ske_keypad_set_bits(struct ske_keypad *keypad, u16 addr,
78 spin_lock(&keypad->ske_keypad_lock);
80 ret = readl(keypad->reg_base + addr);
83 writel(ret, keypad->reg_base + addr);
85 spin_unlock(&keypad->ske_keypad_lock);
89 * ske_keypad_chip_init: init keypad controller configuration
93 static int __init ske_keypad_chip_init(struct ske_keypad *keypad)
96 int timeout = keypad->board->debounce_ms;
99 while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--)
107 * keypad dbounce is configured in DBCR[15:8]
110 spin_lock(&keypad->ske_keypad_lock);
111 value = readl(keypad->reg_base + SKE_DBCR);
113 value |= ((keypad->board->debounce_ms * 32000)/32768) << 8;
114 writel(value, keypad->reg_base + SKE_DBCR);
115 spin_unlock(&keypad->ske_keypad_lock);
118 ske_keypad_set_bits(keypad, SKE_CR, 0x0, SKE_KPMLT);
122 * KPCN[5:3] defines no. of keypad columns to be auto scanned
124 value = (keypad->board->kcol - 1) << 3;
125 ske_keypad_set_bits(keypad, SKE_CR, SKE_KPCN, value);
127 /* clear keypad interrupt for auto(and pending SW) scans */
128 ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA | SKE_KPICS);
130 /* un-mask keypad interrupts */
131 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
134 ske_keypad_set_bits(keypad, SKE_CR, 0x0, SKE_KPASEN);
139 static void ske_keypad_report(struct ske_keypad *keypad, u8 status, int col)
142 struct input_dev *input = keypad->input;
155 ske_ris = readl(keypad->reg_base + SKE_RIS);
159 input_report_key(input, keypad->keymap[code], key_pressed);
165 static void ske_keypad_read_data(struct ske_keypad *keypad)
179 ske_asr = readl(keypad->reg_base + SKE_ASR0 + (4 * i));
187 ske_keypad_report(keypad, status, col);
192 ske_keypad_report(keypad, status, col);
199 struct ske_keypad *keypad = dev_id;
200 int timeout = keypad->board->debounce_ms;
203 ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0);
204 ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA);
206 while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --timeout)
210 ske_keypad_read_data(keypad);
213 while ((readl(keypad->reg_base + SKE_RIS)) && --timeout)
217 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
226 struct ske_keypad *keypad;
233 dev_err(&pdev->dev, "invalid keypad platform data\n");
247 keypad = kzalloc(sizeof(struct ske_keypad), GFP_KERNEL);
249 if (!keypad || !input) {
250 dev_err(&pdev->dev, "failed to allocate keypad memory\n");
255 keypad->irq = irq;
256 keypad->board = plat;
257 keypad->input = input;
258 spin_lock_init(&keypad->ske_keypad_lock);
266 keypad->reg_base = ioremap(res->start, resource_size(res));
267 if (!keypad->reg_base) {
273 keypad->pclk = clk_get(&pdev->dev, "apb_pclk");
274 if (IS_ERR(keypad->pclk)) {
276 error = PTR_ERR(keypad->pclk);
280 keypad->clk = clk_get(&pdev->dev, NULL);
281 if (IS_ERR(keypad->clk)) {
283 error = PTR_ERR(keypad->clk);
288 input->name = "ux500-ske-keypad";
293 keypad->keymap, input);
303 error = clk_prepare_enable(keypad->pclk);
309 error = clk_prepare_enable(keypad->clk);
317 if (keypad->board->init)
318 keypad->board->init();
320 error = ske_keypad_chip_init(keypad);
322 dev_err(&pdev->dev, "unable to init keypad hardware\n");
326 error = request_threaded_irq(keypad->irq, NULL, ske_keypad_irq,
327 IRQF_ONESHOT, "ske-keypad", keypad);
329 dev_err(&pdev->dev, "allocate irq %d failed\n", keypad->irq);
343 platform_set_drvdata(pdev, keypad);
348 free_irq(keypad->irq, keypad);
350 clk_disable_unprepare(keypad->clk);
352 clk_disable_unprepare(keypad->pclk);
354 clk_put(keypad->clk);
356 clk_put(keypad->pclk);
358 iounmap(keypad->reg_base);
363 kfree(keypad);
369 struct ske_keypad *keypad = platform_get_drvdata(pdev);
372 free_irq(keypad->irq, keypad);
374 input_unregister_device(keypad->input);
376 clk_disable_unprepare(keypad->clk);
377 clk_put(keypad->clk);
379 if (keypad->board->exit)
380 keypad->board->exit();
382 iounmap(keypad->reg_base);
384 kfree(keypad);
393 struct ske_keypad *keypad = platform_get_drvdata(pdev);
399 ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0);
407 struct ske_keypad *keypad = platform_get_drvdata(pdev);
413 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
424 .name = "nmk-ske-keypad",
435 MODULE_ALIAS("platform:nomadik-ske-keypad");