^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * OMAP4 Keypad Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2010 Texas Instruments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Author: Abraham Arce <x0066660@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Initial Code: Syed Rafiuddin <rafiuddin.syed@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/input/matrix_keypad.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/pm_runtime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /* OMAP4 registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define OMAP4_KBD_REVISION 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define OMAP4_KBD_SYSCONFIG 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define OMAP4_KBD_SYSSTATUS 0x14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define OMAP4_KBD_IRQSTATUS 0x18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define OMAP4_KBD_IRQENABLE 0x1C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define OMAP4_KBD_WAKEUPENABLE 0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define OMAP4_KBD_PENDING 0x24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define OMAP4_KBD_CTRL 0x28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define OMAP4_KBD_DEBOUNCINGTIME 0x2C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define OMAP4_KBD_LONGKEYTIME 0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define OMAP4_KBD_TIMEOUT 0x34
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define OMAP4_KBD_STATEMACHINE 0x38
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define OMAP4_KBD_ROWINPUTS 0x3C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define OMAP4_KBD_COLUMNOUTPUTS 0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define OMAP4_KBD_FULLCODE31_0 0x44
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define OMAP4_KBD_FULLCODE63_32 0x48
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /* OMAP4 bit definitions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define OMAP4_DEF_IRQENABLE_EVENTEN BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define OMAP4_DEF_IRQENABLE_LONGKEY BIT(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define OMAP4_DEF_WUP_EVENT_ENA BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define OMAP4_DEF_WUP_LONG_KEY_ENA BIT(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define OMAP4_DEF_CTRL_NOSOFTMODE BIT(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define OMAP4_DEF_CTRL_PTV_SHIFT 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* OMAP4 values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define OMAP4_VAL_IRQDISABLE 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * Errata i689: If a key is released for a time shorter than debounce time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * the keyboard will idle and never detect the key release. The workaround
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * is to use at least a 12ms debounce time. See omap5432 TRM chapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * "26.4.6.2 Keyboard Controller Timer" for more information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define OMAP4_KEYPAD_PTV_DIV_128 0x6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define OMAP4_KEYPAD_DEBOUNCINGTIME_MS(dbms, ptv) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) ((((dbms) * 1000) / ((1 << ((ptv) + 1)) * (1000000 / 32768))) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define OMAP4_VAL_DEBOUNCINGTIME_16MS \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) OMAP4_KEYPAD_DEBOUNCINGTIME_MS(16, OMAP4_KEYPAD_PTV_DIV_128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) KBD_REVISION_OMAP4 = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) KBD_REVISION_OMAP5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct omap4_keypad {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) bool irq_wake_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) unsigned int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) unsigned int rows;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) unsigned int cols;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) u32 reg_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) u32 irqreg_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) unsigned int row_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) bool no_autorepeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) unsigned char key_state[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) unsigned short *keymap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) return __raw_readl(keypad_data->base +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) keypad_data->reg_offset + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) __raw_writel(value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) keypad_data->base + keypad_data->reg_offset + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static int kbd_read_irqreg(struct omap4_keypad *keypad_data, u32 offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) return __raw_readl(keypad_data->base +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) keypad_data->irqreg_offset + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static void kbd_write_irqreg(struct omap4_keypad *keypad_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) u32 offset, u32 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) __raw_writel(value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) keypad_data->base + keypad_data->irqreg_offset + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /* Interrupt handlers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static irqreturn_t omap4_keypad_irq_handler(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct omap4_keypad *keypad_data = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) if (kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return IRQ_WAKE_THREAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return IRQ_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct omap4_keypad *keypad_data = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct input_dev *input_dev = keypad_data->input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) unsigned char key_state[ARRAY_SIZE(keypad_data->key_state)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) unsigned int col, row, code, changed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) u32 *new_state = (u32 *) key_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) for (row = 0; row < keypad_data->rows; row++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) changed = key_state[row] ^ keypad_data->key_state[row];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (!changed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) for (col = 0; col < keypad_data->cols; col++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) if (changed & (1 << col)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) code = MATRIX_SCAN_CODE(row, col,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) keypad_data->row_shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) input_event(input_dev, EV_MSC, MSC_SCAN, code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) input_report_key(input_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) keypad_data->keymap[code],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) key_state[row] & (1 << col));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) input_sync(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) memcpy(keypad_data->key_state, key_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) sizeof(keypad_data->key_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /* clear pending interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static int omap4_keypad_open(struct input_dev *input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct omap4_keypad *keypad_data = input_get_drvdata(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) pm_runtime_get_sync(input->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) disable_irq(keypad_data->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) kbd_writel(keypad_data, OMAP4_KBD_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) OMAP4_DEF_CTRL_NOSOFTMODE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) (OMAP4_KEYPAD_PTV_DIV_128 << OMAP4_DEF_CTRL_PTV_SHIFT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) OMAP4_VAL_DEBOUNCINGTIME_16MS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* clear pending interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) OMAP4_DEF_IRQENABLE_EVENTEN |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) OMAP4_DEF_IRQENABLE_LONGKEY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) kbd_writel(keypad_data, OMAP4_KBD_WAKEUPENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) enable_irq(keypad_data->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static void omap4_keypad_stop(struct omap4_keypad *keypad_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /* Disable interrupts and wake-up events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) OMAP4_VAL_IRQDISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) kbd_writel(keypad_data, OMAP4_KBD_WAKEUPENABLE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) /* clear pending interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static void omap4_keypad_close(struct input_dev *input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct omap4_keypad *keypad_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) keypad_data = input_get_drvdata(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) disable_irq(keypad_data->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) omap4_keypad_stop(keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) enable_irq(keypad_data->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) pm_runtime_put_sync(input->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static int omap4_keypad_parse_dt(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct omap4_keypad *keypad_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct device_node *np = dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) err = matrix_keypad_parse_properties(dev, &keypad_data->rows,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) &keypad_data->cols);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if (of_get_property(np, "linux,input-no-autorepeat", NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) keypad_data->no_autorepeat = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static int omap4_keypad_check_revision(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct omap4_keypad *keypad_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) unsigned int rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) rev = __raw_readl(keypad_data->base + OMAP4_KBD_REVISION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) rev &= 0x03 << 30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) rev >>= 30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) switch (rev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) case KBD_REVISION_OMAP4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) keypad_data->reg_offset = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) keypad_data->irqreg_offset = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) case KBD_REVISION_OMAP5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) keypad_data->reg_offset = 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) keypad_data->irqreg_offset = 0x0c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) dev_err(dev, "Keypad reports unsupported revision %d", rev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static int omap4_keypad_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) struct omap4_keypad *keypad_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) unsigned int max_keys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) if (!res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) dev_err(&pdev->dev, "no base address specified\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) irq = platform_get_irq(pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if (irq < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) return irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) keypad_data = kzalloc(sizeof(struct omap4_keypad), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (!keypad_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) dev_err(&pdev->dev, "keypad_data memory allocation failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) keypad_data->irq = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) error = omap4_keypad_parse_dt(&pdev->dev, keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) goto err_free_keypad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) res = request_mem_region(res->start, resource_size(res), pdev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) if (!res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) dev_err(&pdev->dev, "can't request mem region\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) error = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) goto err_free_keypad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) keypad_data->base = ioremap(res->start, resource_size(res));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) if (!keypad_data->base) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) dev_err(&pdev->dev, "can't ioremap mem resource\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) goto err_release_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) pm_runtime_enable(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * Enable clocks for the keypad module so that we can read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * revision register.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) error = pm_runtime_get_sync(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) pm_runtime_put_noidle(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) error = omap4_keypad_check_revision(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) if (!error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /* Ensure device does not raise interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) omap4_keypad_stop(keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) pm_runtime_put_sync(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) goto err_pm_disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) /* input device allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) keypad_data->input = input_dev = input_allocate_device();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) if (!input_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) goto err_pm_disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) input_dev->name = pdev->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) input_dev->dev.parent = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) input_dev->id.bustype = BUS_HOST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) input_dev->id.vendor = 0x0001;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) input_dev->id.product = 0x0001;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) input_dev->id.version = 0x0001;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) input_dev->open = omap4_keypad_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) input_dev->close = omap4_keypad_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) input_set_capability(input_dev, EV_MSC, MSC_SCAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) if (!keypad_data->no_autorepeat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) __set_bit(EV_REP, input_dev->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) input_set_drvdata(input_dev, keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) keypad_data->row_shift = get_count_order(keypad_data->cols);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) max_keys = keypad_data->rows << keypad_data->row_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) keypad_data->keymap = kcalloc(max_keys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) sizeof(keypad_data->keymap[0]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) if (!keypad_data->keymap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) dev_err(&pdev->dev, "Not enough memory for keymap\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) goto err_free_input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) error = matrix_keypad_build_keymap(NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) keypad_data->rows, keypad_data->cols,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) keypad_data->keymap, input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) dev_err(&pdev->dev, "failed to build keymap\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) goto err_free_keymap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) error = request_threaded_irq(keypad_data->irq, omap4_keypad_irq_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) omap4_keypad_irq_thread_fn, IRQF_ONESHOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) "omap4-keypad", keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) dev_err(&pdev->dev, "failed to register interrupt\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) goto err_free_keymap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) error = input_register_device(keypad_data->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) if (error < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) dev_err(&pdev->dev, "failed to register input device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) goto err_free_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) device_init_wakeup(&pdev->dev, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) platform_set_drvdata(pdev, keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) err_free_irq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) free_irq(keypad_data->irq, keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) err_free_keymap:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) kfree(keypad_data->keymap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) err_free_input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) input_free_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) err_pm_disable:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) pm_runtime_disable(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) iounmap(keypad_data->base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) err_release_mem:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) release_mem_region(res->start, resource_size(res));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) err_free_keypad:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) kfree(keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) static int omap4_keypad_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) free_irq(keypad_data->irq, keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) pm_runtime_disable(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) input_unregister_device(keypad_data->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) iounmap(keypad_data->base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) release_mem_region(res->start, resource_size(res));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) kfree(keypad_data->keymap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) kfree(keypad_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) static const struct of_device_id omap_keypad_dt_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) { .compatible = "ti,omap4-keypad" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) #ifdef CONFIG_PM_SLEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) static int omap4_keypad_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) struct platform_device *pdev = to_platform_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) if (device_may_wakeup(&pdev->dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) error = enable_irq_wake(keypad_data->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) keypad_data->irq_wake_enabled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) static int omap4_keypad_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) struct platform_device *pdev = to_platform_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) disable_irq_wake(keypad_data->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) keypad_data->irq_wake_enabled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) static SIMPLE_DEV_PM_OPS(omap4_keypad_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) omap4_keypad_suspend, omap4_keypad_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) static struct platform_driver omap4_keypad_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) .probe = omap4_keypad_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) .remove = omap4_keypad_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) .name = "omap4-keypad",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) .pm = &omap4_keypad_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) .of_match_table = omap_keypad_dt_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) module_platform_driver(omap4_keypad_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) MODULE_AUTHOR("Texas Instruments");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) MODULE_DESCRIPTION("OMAP4 Keypad Driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) MODULE_ALIAS("platform:omap4-keypad");