Lines Matching full:keypad
8 * Keypad controller driver for the SKE (Scroll Key Encoder) module used in
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, in ske_keypad_set_bits() argument
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()
91 * ske_keypad_chip_init: init keypad controller configuration
95 static int __init ske_keypad_chip_init(struct ske_keypad *keypad) in ske_keypad_chip_init() argument
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()
109 * keypad dbounce is configured in DBCR[15:8] 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()
120 ske_keypad_set_bits(keypad, SKE_CR, 0x0, SKE_KPMLT); in ske_keypad_chip_init()
124 * KPCN[5:3] defines no. of keypad columns to be auto scanned in ske_keypad_chip_init()
126 value = (keypad->board->kcol - 1) << 3; in ske_keypad_chip_init()
127 ske_keypad_set_bits(keypad, SKE_CR, SKE_KPCN, value); in ske_keypad_chip_init()
129 /* clear keypad interrupt for auto(and pending SW) scans */ in ske_keypad_chip_init()
130 ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA | SKE_KPICS); in ske_keypad_chip_init()
132 /* un-mask keypad interrupts */ in ske_keypad_chip_init()
133 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA); in ske_keypad_chip_init()
136 ske_keypad_set_bits(keypad, SKE_CR, 0x0, SKE_KPASEN); in ske_keypad_chip_init()
141 static void ske_keypad_report(struct ske_keypad *keypad, u8 status, int col) in ske_keypad_report() argument
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()
167 static void ske_keypad_read_data(struct ske_keypad *keypad) in ske_keypad_read_data() argument
181 ske_asr = readl(keypad->reg_base + SKE_ASR0 + (4 * i)); in ske_keypad_read_data()
189 ske_keypad_report(keypad, status, col); in ske_keypad_read_data()
194 ske_keypad_report(keypad, status, col); in ske_keypad_read_data()
201 struct ske_keypad *keypad = dev_id; in ske_keypad_irq() local
202 int timeout = keypad->board->debounce_ms; in ske_keypad_irq()
205 ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0); in ske_keypad_irq()
206 ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA); in ske_keypad_irq()
208 while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --timeout) in ske_keypad_irq()
212 ske_keypad_read_data(keypad); in ske_keypad_irq()
215 while ((readl(keypad->reg_base + SKE_RIS)) && --timeout) in ske_keypad_irq()
219 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA); in ske_keypad_irq()
226 struct ske_keypad *keypad = data; in ske_keypad_board_exit() local
228 keypad->board->exit(); in ske_keypad_board_exit()
236 struct ske_keypad *keypad; in ske_keypad_probe() local
242 dev_err(&pdev->dev, "invalid keypad platform data\n"); in ske_keypad_probe()
250 keypad = devm_kzalloc(dev, sizeof(struct ske_keypad), in ske_keypad_probe()
253 if (!keypad || !input) { in ske_keypad_probe()
254 dev_err(&pdev->dev, "failed to allocate keypad memory\n"); in ske_keypad_probe()
258 keypad->irq = irq; in ske_keypad_probe()
259 keypad->board = plat; in ske_keypad_probe()
260 keypad->input = input; in ske_keypad_probe()
261 spin_lock_init(&keypad->ske_keypad_lock); in ske_keypad_probe()
263 keypad->reg_base = devm_platform_ioremap_resource(pdev, 0); in ske_keypad_probe()
264 if (IS_ERR(keypad->reg_base)) in ske_keypad_probe()
265 return PTR_ERR(keypad->reg_base); in ske_keypad_probe()
267 keypad->pclk = devm_clk_get_enabled(dev, "apb_pclk"); in ske_keypad_probe()
268 if (IS_ERR(keypad->pclk)) { in ske_keypad_probe()
270 return PTR_ERR(keypad->pclk); in ske_keypad_probe()
273 keypad->clk = devm_clk_get_enabled(dev, NULL); in ske_keypad_probe()
274 if (IS_ERR(keypad->clk)) { in ske_keypad_probe()
276 return PTR_ERR(keypad->clk); in ske_keypad_probe()
280 input->name = "ux500-ske-keypad"; in ske_keypad_probe()
285 keypad->keymap, input); in ske_keypad_probe()
296 if (keypad->board->init) in ske_keypad_probe()
297 keypad->board->init(); in ske_keypad_probe()
299 if (keypad->board->exit) { in ske_keypad_probe()
301 keypad); in ske_keypad_probe()
306 error = ske_keypad_chip_init(keypad); in ske_keypad_probe()
308 dev_err(&pdev->dev, "unable to init keypad hardware\n"); in ske_keypad_probe()
312 error = devm_request_threaded_irq(dev, keypad->irq, in ske_keypad_probe()
314 IRQF_ONESHOT, "ske-keypad", keypad); in ske_keypad_probe()
316 dev_err(&pdev->dev, "allocate irq %d failed\n", keypad->irq); in ske_keypad_probe()
330 platform_set_drvdata(pdev, keypad); in ske_keypad_probe()
338 struct ske_keypad *keypad = platform_get_drvdata(pdev); in ske_keypad_suspend() local
344 ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0); in ske_keypad_suspend()
352 struct ske_keypad *keypad = platform_get_drvdata(pdev); in ske_keypad_resume() local
358 ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA); in ske_keypad_resume()
368 .name = "nmk-ske-keypad",
377 MODULE_DESCRIPTION("Nomadik Scroll-Key-Encoder Keypad Driver");
378 MODULE_ALIAS("platform:nomadik-ske-keypad");