pxa27x_keypad.c (7536d7be7b718f8c5834cbcb7601816562e1b805) pxa27x_keypad.c (39ab9ddeb3e9573a1ea9a17a1431ea5c81681964)
1/*
2 * linux/drivers/input/keyboard/pxa27x_keypad.c
3 *
4 * Driver for the pxa27x matrix keyboard controller.
5 *
6 * Created: Feb 22, 2007
7 * Author: Rodolfo Giometti <giometti@linux.it>
8 *

--- 91 unchanged lines hidden (view full) ---

100
101struct pxa27x_keypad {
102 struct pxa27x_keypad_platform_data *pdata;
103
104 struct clk *clk;
105 struct input_dev *input_dev;
106 void __iomem *mmio_base;
107
1/*
2 * linux/drivers/input/keyboard/pxa27x_keypad.c
3 *
4 * Driver for the pxa27x matrix keyboard controller.
5 *
6 * Created: Feb 22, 2007
7 * Author: Rodolfo Giometti <giometti@linux.it>
8 *

--- 91 unchanged lines hidden (view full) ---

100
101struct pxa27x_keypad {
102 struct pxa27x_keypad_platform_data *pdata;
103
104 struct clk *clk;
105 struct input_dev *input_dev;
106 void __iomem *mmio_base;
107
108 int irq;
109
108 /* matrix key code map */
109 unsigned int matrix_keycodes[MAX_MATRIX_KEY_NUM];
110
111 /* state row bits of each column scan */
112 uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS];
113 uint32_t direct_key_state;
114
115 unsigned int direct_key_mask;

--- 15 unchanged lines hidden (view full) ---

131 int row = ((*key) >> 28) & 0xf;
132 int col = ((*key) >> 24) & 0xf;
133 int code = (*key) & 0xffffff;
134
135 keypad->matrix_keycodes[(row << 3) + col] = code;
136 set_bit(code, input_dev->keybit);
137 }
138
110 /* matrix key code map */
111 unsigned int matrix_keycodes[MAX_MATRIX_KEY_NUM];
112
113 /* state row bits of each column scan */
114 uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS];
115 uint32_t direct_key_state;
116
117 unsigned int direct_key_mask;

--- 15 unchanged lines hidden (view full) ---

133 int row = ((*key) >> 28) & 0xf;
134 int col = ((*key) >> 24) & 0xf;
135 int code = (*key) & 0xffffff;
136
137 keypad->matrix_keycodes[(row << 3) + col] = code;
138 set_bit(code, input_dev->keybit);
139 }
140
139 for (i = 0; i < pdata->direct_key_num; i++)
140 set_bit(pdata->direct_key_map[i], input_dev->keybit);
141
142 keypad->rotary_up_key[0] = pdata->rotary0_up_key;
143 keypad->rotary_up_key[1] = pdata->rotary1_up_key;
144 keypad->rotary_down_key[0] = pdata->rotary0_down_key;
145 keypad->rotary_down_key[1] = pdata->rotary1_down_key;
146 keypad->rotary_rel_code[0] = pdata->rotary0_rel_code;
147 keypad->rotary_rel_code[1] = pdata->rotary1_rel_code;
148
141 keypad->rotary_up_key[0] = pdata->rotary0_up_key;
142 keypad->rotary_up_key[1] = pdata->rotary1_up_key;
143 keypad->rotary_down_key[0] = pdata->rotary0_down_key;
144 keypad->rotary_down_key[1] = pdata->rotary1_down_key;
145 keypad->rotary_rel_code[0] = pdata->rotary0_rel_code;
146 keypad->rotary_rel_code[1] = pdata->rotary1_rel_code;
147
149 if (pdata->enable_rotary0) {
150 if (pdata->rotary0_up_key && pdata->rotary0_down_key) {
151 set_bit(pdata->rotary0_up_key, input_dev->keybit);
152 set_bit(pdata->rotary0_down_key, input_dev->keybit);
153 } else
154 set_bit(pdata->rotary0_rel_code, input_dev->relbit);
155 }
148 if (pdata->rotary0_up_key && pdata->rotary0_down_key) {
149 set_bit(pdata->rotary0_up_key, input_dev->keybit);
150 set_bit(pdata->rotary0_down_key, input_dev->keybit);
151 } else
152 set_bit(pdata->rotary0_rel_code, input_dev->relbit);
156
153
157 if (pdata->enable_rotary1) {
158 if (pdata->rotary1_up_key && pdata->rotary1_down_key) {
159 set_bit(pdata->rotary1_up_key, input_dev->keybit);
160 set_bit(pdata->rotary1_down_key, input_dev->keybit);
161 } else
162 set_bit(pdata->rotary1_rel_code, input_dev->relbit);
163 }
154 if (pdata->rotary1_up_key && pdata->rotary1_down_key) {
155 set_bit(pdata->rotary1_up_key, input_dev->keybit);
156 set_bit(pdata->rotary1_down_key, input_dev->keybit);
157 } else
158 set_bit(pdata->rotary1_rel_code, input_dev->relbit);
164}
165
166static inline unsigned int lookup_matrix_keycode(
167 struct pxa27x_keypad *keypad, int row, int col)
168{
169 return keypad->matrix_keycodes[(row << 3) + col];
170}
171

--- 215 unchanged lines hidden (view full) ---

387}
388
389#ifdef CONFIG_PM
390static int pxa27x_keypad_suspend(struct platform_device *pdev, pm_message_t state)
391{
392 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
393
394 clk_disable(keypad->clk);
159}
160
161static inline unsigned int lookup_matrix_keycode(
162 struct pxa27x_keypad *keypad, int row, int col)
163{
164 return keypad->matrix_keycodes[(row << 3) + col];
165}
166

--- 215 unchanged lines hidden (view full) ---

382}
383
384#ifdef CONFIG_PM
385static int pxa27x_keypad_suspend(struct platform_device *pdev, pm_message_t state)
386{
387 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
388
389 clk_disable(keypad->clk);
390
391 if (device_may_wakeup(&pdev->dev))
392 enable_irq_wake(keypad->irq);
393
395 return 0;
396}
397
398static int pxa27x_keypad_resume(struct platform_device *pdev)
399{
400 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
401 struct input_dev *input_dev = keypad->input_dev;
402
394 return 0;
395}
396
397static int pxa27x_keypad_resume(struct platform_device *pdev)
398{
399 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
400 struct input_dev *input_dev = keypad->input_dev;
401
402 if (device_may_wakeup(&pdev->dev))
403 disable_irq_wake(keypad->irq);
404
403 mutex_lock(&input_dev->mutex);
404
405 if (input_dev->users) {
406 /* Enable unit clock */
407 clk_enable(keypad->clk);
408 pxa27x_keypad_config(keypad);
409 }
410

--- 75 unchanged lines hidden (view full) ---

486 input_dev->id.bustype = BUS_HOST;
487 input_dev->open = pxa27x_keypad_open;
488 input_dev->close = pxa27x_keypad_close;
489 input_dev->dev.parent = &pdev->dev;
490
491 keypad->input_dev = input_dev;
492 input_set_drvdata(input_dev, keypad);
493
405 mutex_lock(&input_dev->mutex);
406
407 if (input_dev->users) {
408 /* Enable unit clock */
409 clk_enable(keypad->clk);
410 pxa27x_keypad_config(keypad);
411 }
412

--- 75 unchanged lines hidden (view full) ---

488 input_dev->id.bustype = BUS_HOST;
489 input_dev->open = pxa27x_keypad_open;
490 input_dev->close = pxa27x_keypad_close;
491 input_dev->dev.parent = &pdev->dev;
492
493 keypad->input_dev = input_dev;
494 input_set_drvdata(input_dev, keypad);
495
494 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
495 if ((keypad->pdata->enable_rotary0 &&
496 keypad->pdata->rotary0_rel_code) ||
497 (keypad->pdata->enable_rotary1 &&
498 keypad->pdata->rotary1_rel_code)) {
499 input_dev->evbit[0] |= BIT_MASK(EV_REL);
500 }
496 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
497 BIT_MASK(EV_REL);
501
502 pxa27x_keypad_build_keycode(keypad);
503 platform_set_drvdata(pdev, keypad);
504
505 error = request_irq(irq, pxa27x_keypad_irq_handler, IRQF_DISABLED,
506 pdev->name, keypad);
507 if (error) {
508 dev_err(&pdev->dev, "failed to request IRQ\n");
509 goto failed_free_dev;
510 }
511
498
499 pxa27x_keypad_build_keycode(keypad);
500 platform_set_drvdata(pdev, keypad);
501
502 error = request_irq(irq, pxa27x_keypad_irq_handler, IRQF_DISABLED,
503 pdev->name, keypad);
504 if (error) {
505 dev_err(&pdev->dev, "failed to request IRQ\n");
506 goto failed_free_dev;
507 }
508
509 keypad->irq = irq;
510
512 /* Register the input device */
513 error = input_register_device(input_dev);
514 if (error) {
515 dev_err(&pdev->dev, "failed to register input device\n");
516 goto failed_free_irq;
517 }
518
511 /* Register the input device */
512 error = input_register_device(input_dev);
513 if (error) {
514 dev_err(&pdev->dev, "failed to register input device\n");
515 goto failed_free_irq;
516 }
517
518 device_init_wakeup(&pdev->dev, 1);
519
519 return 0;
520
521failed_free_irq:
522 free_irq(irq, pdev);
523 platform_set_drvdata(pdev, NULL);
524failed_free_dev:
525 input_free_device(input_dev);
526failed_put_clk:

--- 7 unchanged lines hidden (view full) ---

534 return error;
535}
536
537static int __devexit pxa27x_keypad_remove(struct platform_device *pdev)
538{
539 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
540 struct resource *res;
541
520 return 0;
521
522failed_free_irq:
523 free_irq(irq, pdev);
524 platform_set_drvdata(pdev, NULL);
525failed_free_dev:
526 input_free_device(input_dev);
527failed_put_clk:

--- 7 unchanged lines hidden (view full) ---

535 return error;
536}
537
538static int __devexit pxa27x_keypad_remove(struct platform_device *pdev)
539{
540 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
541 struct resource *res;
542
542 free_irq(platform_get_irq(pdev, 0), pdev);
543 free_irq(keypad->irq, pdev);
543
544 clk_disable(keypad->clk);
545 clk_put(keypad->clk);
546
547 input_unregister_device(keypad->input_dev);
548 input_free_device(keypad->input_dev);
549
550 iounmap(keypad->mmio_base);

--- 38 unchanged lines hidden ---
544
545 clk_disable(keypad->clk);
546 clk_put(keypad->clk);
547
548 input_unregister_device(keypad->input_dev);
549 input_free_device(keypad->input_dev);
550
551 iounmap(keypad->mmio_base);

--- 38 unchanged lines hidden ---