Lines Matching full:keypad
3 * Driver for the Cirrus EP93xx matrix keypad controller.
7 * Based on the pxa27x matrix keypad controller by Rodolfo Giometti.
28 #include <linux/platform_data/keypad-ep93xx.h>
31 * Keypad Interface Register offsets
82 struct ep93xx_keypad *keypad = dev_id; in ep93xx_keypad_irq_handler() local
83 struct input_dev *input_dev = keypad->input_dev; in ep93xx_keypad_irq_handler()
87 status = __raw_readl(keypad->mmio_base + KEY_REG); in ep93xx_keypad_irq_handler()
90 key1 = keypad->keycodes[keycode]; in ep93xx_keypad_irq_handler()
93 key2 = keypad->keycodes[keycode]; in ep93xx_keypad_irq_handler()
96 if (keypad->key1 && key1 != keypad->key1 && key2 != keypad->key1) in ep93xx_keypad_irq_handler()
97 input_report_key(input_dev, keypad->key1, 0); in ep93xx_keypad_irq_handler()
99 if (keypad->key2 && key1 != keypad->key2 && key2 != keypad->key2) in ep93xx_keypad_irq_handler()
100 input_report_key(input_dev, keypad->key2, 0); in ep93xx_keypad_irq_handler()
105 keypad->key1 = key1; in ep93xx_keypad_irq_handler()
106 keypad->key2 = key2; in ep93xx_keypad_irq_handler()
109 if (keypad->key1 && key1 != keypad->key1) in ep93xx_keypad_irq_handler()
110 input_report_key(input_dev, keypad->key1, 0); in ep93xx_keypad_irq_handler()
112 if (keypad->key2 && key1 != keypad->key2) in ep93xx_keypad_irq_handler()
113 input_report_key(input_dev, keypad->key2, 0); in ep93xx_keypad_irq_handler()
117 keypad->key1 = key1; in ep93xx_keypad_irq_handler()
118 keypad->key2 = 0; in ep93xx_keypad_irq_handler()
121 input_report_key(input_dev, keypad->key1, 0); in ep93xx_keypad_irq_handler()
122 input_report_key(input_dev, keypad->key2, 0); in ep93xx_keypad_irq_handler()
124 keypad->key1 = keypad->key2 = 0; in ep93xx_keypad_irq_handler()
131 static void ep93xx_keypad_config(struct ep93xx_keypad *keypad) in ep93xx_keypad_config() argument
133 struct ep93xx_keypad_platform_data *pdata = keypad->pdata; in ep93xx_keypad_config()
136 clk_set_rate(keypad->clk, pdata->clk_rate); in ep93xx_keypad_config()
151 __raw_writel(val, keypad->mmio_base + KEY_INIT); in ep93xx_keypad_config()
156 struct ep93xx_keypad *keypad = input_get_drvdata(pdev); in ep93xx_keypad_open() local
158 if (!keypad->enabled) { in ep93xx_keypad_open()
159 ep93xx_keypad_config(keypad); in ep93xx_keypad_open()
160 clk_enable(keypad->clk); in ep93xx_keypad_open()
161 keypad->enabled = true; in ep93xx_keypad_open()
169 struct ep93xx_keypad *keypad = input_get_drvdata(pdev); in ep93xx_keypad_close() local
171 if (keypad->enabled) { in ep93xx_keypad_close()
172 clk_disable(keypad->clk); in ep93xx_keypad_close()
173 keypad->enabled = false; in ep93xx_keypad_close()
182 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); in ep93xx_keypad_suspend() local
183 struct input_dev *input_dev = keypad->input_dev; in ep93xx_keypad_suspend()
187 if (keypad->enabled) { in ep93xx_keypad_suspend()
188 clk_disable(keypad->clk); in ep93xx_keypad_suspend()
189 keypad->enabled = false; in ep93xx_keypad_suspend()
195 enable_irq_wake(keypad->irq); in ep93xx_keypad_suspend()
203 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); in ep93xx_keypad_resume() local
204 struct input_dev *input_dev = keypad->input_dev; in ep93xx_keypad_resume()
207 disable_irq_wake(keypad->irq); in ep93xx_keypad_resume()
212 if (!keypad->enabled) { in ep93xx_keypad_resume()
213 ep93xx_keypad_config(keypad); in ep93xx_keypad_resume()
214 clk_enable(keypad->clk); in ep93xx_keypad_resume()
215 keypad->enabled = true; in ep93xx_keypad_resume()
230 struct ep93xx_keypad *keypad; in ep93xx_keypad_probe() local
236 keypad = kzalloc(sizeof(struct ep93xx_keypad), GFP_KERNEL); in ep93xx_keypad_probe()
237 if (!keypad) in ep93xx_keypad_probe()
240 keypad->pdata = dev_get_platdata(&pdev->dev); in ep93xx_keypad_probe()
241 if (!keypad->pdata) { in ep93xx_keypad_probe()
246 keymap_data = keypad->pdata->keymap_data; in ep93xx_keypad_probe()
252 keypad->irq = platform_get_irq(pdev, 0); in ep93xx_keypad_probe()
253 if (keypad->irq < 0) { in ep93xx_keypad_probe()
254 err = keypad->irq; in ep93xx_keypad_probe()
270 keypad->mmio_base = ioremap(res->start, resource_size(res)); in ep93xx_keypad_probe()
271 if (keypad->mmio_base == NULL) { in ep93xx_keypad_probe()
280 keypad->clk = clk_get(&pdev->dev, NULL); in ep93xx_keypad_probe()
281 if (IS_ERR(keypad->clk)) { in ep93xx_keypad_probe()
282 err = PTR_ERR(keypad->clk); in ep93xx_keypad_probe()
292 keypad->input_dev = input_dev; in ep93xx_keypad_probe()
302 keypad->keycodes, input_dev); in ep93xx_keypad_probe()
306 if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) in ep93xx_keypad_probe()
308 input_set_drvdata(input_dev, keypad); in ep93xx_keypad_probe()
310 err = request_irq(keypad->irq, ep93xx_keypad_irq_handler, in ep93xx_keypad_probe()
311 0, pdev->name, keypad); in ep93xx_keypad_probe()
319 platform_set_drvdata(pdev, keypad); in ep93xx_keypad_probe()
325 free_irq(keypad->irq, keypad); in ep93xx_keypad_probe()
329 clk_put(keypad->clk); in ep93xx_keypad_probe()
333 iounmap(keypad->mmio_base); in ep93xx_keypad_probe()
337 kfree(keypad); in ep93xx_keypad_probe()
343 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); in ep93xx_keypad_remove() local
346 free_irq(keypad->irq, keypad); in ep93xx_keypad_remove()
348 if (keypad->enabled) in ep93xx_keypad_remove()
349 clk_disable(keypad->clk); in ep93xx_keypad_remove()
350 clk_put(keypad->clk); in ep93xx_keypad_remove()
352 input_unregister_device(keypad->input_dev); in ep93xx_keypad_remove()
356 iounmap(keypad->mmio_base); in ep93xx_keypad_remove()
361 kfree(keypad); in ep93xx_keypad_remove()
368 .name = "ep93xx-keypad",
378 MODULE_DESCRIPTION("EP93xx Matrix Keypad Controller");
379 MODULE_ALIAS("platform:ep93xx-keypad");