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
62 * @ske_keypad_lock: spinlock protecting the keypad read/writes
75 static void ske_keypad_set_bits(struct ske_keypad *keypad, u16 addr,
80 spin_lock(&keypad->ske_keypad_lock);
82 ret = readl(keypad->reg_base + addr);
85 writel(ret, keypad->reg_base + addr);
87 spin_unlock(&keypad->ske_keypad_lock);
91 * ske_keypad_chip_init: init keypad controller configuration
95 static int __init ske_keypad_chip_init(struct ske_keypad *keypad)
98 int timeout = keypad->board->debounce_ms;
101 while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--)
109 * keypad dbounce is configured in DBCR[15:8]
112 spin_lock(&keypad->ske_keypad_lock);
113 value = readl(keypad->reg_base + SKE_DBCR);
115 value |= ((keypad->board->debounce_ms * 32000)/32768) << 8;
116 writel(value, keypad->reg_base + SKE_DBCR);
117 spin_unlock(&keypad->ske_keypad_lock);
120 ske_keypad_set_bits(keypad, SKE_CR, 0x0, SKE_KPMLT);
124 * KPCN[5:3] defines no. of keypad columns to be auto scanned
126 value = (keypad->board->kcol - 1) << 3;
127 ske_keypad_set_bits(keypad, SKE_CR, SKE_KPCN, value);
129 /* clear keypad interrupt for auto(and pending SW) scans */
130 ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA | SKE_KPICS);
132 /* un-mask keypad interrupts */
133 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
136 ske_keypad_set_bits(keypad, SKE_CR, 0x0, SKE_KPASEN);
141 static void ske_keypad_report(struct ske_keypad *keypad, u8 status, int col)
144 struct input_dev *input = keypad->input;
157 ske_ris = readl(keypad->reg_base + SKE_RIS);
161 input_report_key(input, keypad->keymap[code], key_pressed);
167 static void ske_keypad_read_data(struct ske_keypad *keypad)
181 ske_asr = readl(keypad->reg_base + SKE_ASR0 + (4 * i));
189 ske_keypad_report(keypad, status, col);
194 ske_keypad_report(keypad, status, col);
201 struct ske_keypad *keypad = dev_id;
202 int timeout = keypad->board->debounce_ms;
205 ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0);
206 ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA);
208 while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --timeout)
212 ske_keypad_read_data(keypad);
215 while ((readl(keypad->reg_base + SKE_RIS)) && --timeout)
219 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
226 struct ske_keypad *keypad = data;
228 keypad->board->exit();
236 struct ske_keypad *keypad;
242 dev_err(&pdev->dev, "invalid keypad platform data\n");
250 keypad = devm_kzalloc(dev, sizeof(struct ske_keypad),
253 if (!keypad || !input) {
254 dev_err(&pdev->dev, "failed to allocate keypad memory\n");
258 keypad->irq = irq;
259 keypad->board = plat;
260 keypad->input = input;
261 spin_lock_init(&keypad->ske_keypad_lock);
263 keypad->reg_base = devm_platform_ioremap_resource(pdev, 0);
264 if (IS_ERR(keypad->reg_base))
265 return PTR_ERR(keypad->reg_base);
267 keypad->pclk = devm_clk_get_enabled(dev, "apb_pclk");
268 if (IS_ERR(keypad->pclk)) {
270 return PTR_ERR(keypad->pclk);
273 keypad->clk = devm_clk_get_enabled(dev, NULL);
274 if (IS_ERR(keypad->clk)) {
276 return PTR_ERR(keypad->clk);
280 input->name = "ux500-ske-keypad";
285 keypad->keymap, input);
296 if (keypad->board->init)
297 keypad->board->init();
299 if (keypad->board->exit) {
301 keypad);
306 error = ske_keypad_chip_init(keypad);
308 dev_err(&pdev->dev, "unable to init keypad hardware\n");
312 error = devm_request_threaded_irq(dev, keypad->irq,
314 IRQF_ONESHOT, "ske-keypad", keypad);
316 dev_err(&pdev->dev, "allocate irq %d failed\n", keypad->irq);
330 platform_set_drvdata(pdev, keypad);
338 struct ske_keypad *keypad = platform_get_drvdata(pdev);
344 ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0);
352 struct ske_keypad *keypad = platform_get_drvdata(pdev);
358 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
368 .name = "nmk-ske-keypad",
378 MODULE_ALIAS("platform:nomadik-ske-keypad");