Changes in 4.9.241 ibmveth: Identify ingress large send packets. tipc: fix the skb_unshare() in tipc_buf_append() net/ipv4: always honour route mtu during forwarding r8169: fix data corruption issue on RTL8402 ALSA: bebob: potential info leak in hwdep_read() net: hdlc: In hdlc_rcv, check to make sure dev is an HDLC device net: hdlc_raw_eth: Clear the IFF_TX_SKB_SHARING flag after calling ether_setup nfc: Ensure presence of NFC_ATTR_FIRMWARE_NAME attribute in nfc_genl_fw_download() tcp: fix to update snd_wl1 in bulk receiver fast path icmp: randomize the global rate limiter cifs: remove bogus debug code KVM: x86/mmu: Commit zap of remaining invalid pages when recovering lpages ima: Don't ignore errors from crypto_shash_update() crypto: algif_aead - Do not set MAY_BACKLOG on the async path EDAC/i5100: Fix error handling order in i5100_init_one() crypto: ixp4xx - Fix the size used in a 'dma_free_coherent()' call media: Revert "media: exynos4-is: Add missed check for pinctrl_lookup_state()" media: m5mols: Check function pointer in m5mols_sensor_power media: omap3isp: Fix memleak in isp_probe crypto: omap-sham - fix digcnt register handling with export/import media: tc358743: initialize variable media: platform: fcp: Fix a reference count leak. media: ti-vpe: Fix a missing check and reference count leak regulator: resolve supply after creating regulator ath10k: provide survey info as accumulated data ath6kl: prevent potential array overflow in ath6kl_add_new_sta() ath9k: Fix potential out of bounds in ath9k_htc_txcompletion_cb() wcn36xx: Fix reported 802.11n rx_highest rate wcn3660/wcn3680 ASoC: qcom: lpass-platform: fix memory leak mwifiex: Do not use GFP_KERNEL in atomic context drm/gma500: fix error check scsi: qla4xxx: Fix an error handling path in 'qla4xxx_get_host_stats()' scsi: csiostor: Fix wrong return value in csio_hw_prep_fw() backlight: sky81452-backlight: Fix refcount imbalance on error VMCI: check return value of get_user_pages_fast() for errors tty: serial: earlycon dependency tty: hvcs: Don't NULL tty->driver_data until hvcs_cleanup() pty: do tty_flip_buffer_push without port->lock in pty_write drivers/virt/fsl_hypervisor: Fix error handling path video: fbdev: vga16fb: fix setting of pixclock because a pass-by-value error video: fbdev: sis: fix null ptr dereference HID: roccat: add bounds checking in kone_sysfs_write_settings() ath6kl: wmi: prevent a shift wrapping bug in ath6kl_wmi_delete_pstream_cmd() misc: mic: scif: Fix error handling path ALSA: seq: oss: Avoid mutex lock for a long-time ioctl quota: clear padding in v2r1_mem2diskdqb() net: enic: Cure the enic api locking trainwreck mfd: sm501: Fix leaks in probe() iwlwifi: mvm: split a print to avoid a WARNING in ROC usb: gadget: f_ncm: fix ncm_bitrate for SuperSpeed and above. usb: gadget: u_ether: enable qmult on SuperSpeed Plus as well nl80211: fix non-split wiphy information scsi: be2iscsi: Fix a theoretical leak in beiscsi_create_eqs() mwifiex: fix double free net: korina: fix kfree of rx/tx descriptor array IB/mlx4: Fix starvation in paravirt mux/demux IB/mlx4: Adjust delayed work when a dup is observed powerpc/pseries: Fix missing of_node_put() in rng_init() powerpc/icp-hv: Fix missing of_node_put() in success path mtd: lpddr: fix excessive stack usage with clang mtd: mtdoops: Don't write panic data twice ARM: 9007/1: l2c: fix prefetch bits init in L2X0_AUX_CTRL using DT values RDMA/qedr: Fix use of uninitialized field powerpc/tau: Use appropriate temperature sample interval powerpc/tau: Remove duplicated set_thresholds() call powerpc/tau: Disable TAU between measurements perf intel-pt: Fix "context_switch event has no tid" error RDMA/hns: Set the unsupported wr opcode kdb: Fix pager search for multi-line strings overflow: Include header file with SIZE_MAX declaration powerpc/perf: Exclude pmc5/6 from the irrelevant PMU group constraints powerpc/perf/hv-gpci: Fix starting index value cpufreq: powernv: Fix frame-size-overflow in powernv_cpufreq_reboot_notifier IB/rdmavt: Fix sizeof mismatch lib/crc32.c: fix trivial typo in preprocessor condition rapidio: fix error handling path rapidio: fix the missed put_device() for rio_mport_add_riodev clk: at91: clk-main: update key before writing AT91_CKGR_MOR clk: bcm2835: add missing release if devm_clk_hw_register fails vfio/pci: Clear token on bypass registration failure Input: imx6ul_tsc - clean up some errors in imx6ul_tsc_resume() Input: ep93xx_keypad - fix handling of platform_get_irq() error Input: omap4-keypad - fix handling of platform_get_irq() error Input: twl4030_keypad - fix handling of platform_get_irq() error Input: sun4i-ps2 - fix handling of platform_get_irq() error KVM: x86: emulating RDPID failure shall return #UD rather than #GP memory: omap-gpmc: Fix a couple off by ones memory: fsl-corenet-cf: Fix handling of platform_get_irq() error arm64: dts: qcom: msm8916: Fix MDP/DSI interrupts arm64: dts: zynqmp: Remove additional compatible string for i2c IPs powerpc/powernv/dump: Fix race while processing OPAL dump nvmet: fix uninitialized work for zero kato NTB: hw: amd: fix an issue about leak system resources crypto: ccp - fix error handling media: firewire: fix memory leak media: ati_remote: sanity check for both endpoints media: exynos4-is: Fix several reference count leaks due to pm_runtime_get_sync media: exynos4-is: Fix a reference count leak due to pm_runtime_get_sync media: exynos4-is: Fix a reference count leak media: vsp1: Fix runtime PM imbalance on error media: platform: s3c-camif: Fix runtime PM imbalance on error media: platform: sti: hva: Fix runtime PM imbalance on error media: bdisp: Fix runtime PM imbalance on error media: media/pci: prevent memory leak in bttv_probe media: uvcvideo: Ensure all probed info is returned to v4l2 mmc: sdio: Check for CISTPL_VERS_1 buffer size media: saa7134: avoid a shift overflow fs: dlm: fix configfs memory leak ntfs: add check for mft record size in superblock PM: hibernate: remove the bogus call to get_gendisk() in software_resume() scsi: mvumi: Fix error return in mvumi_io_attach() scsi: target: core: Add CONTROL field for trace events mic: vop: copy data to kernel space then write to io memory misc: vop: add round_up(x,4) for vring_size to avoid kernel panic usb: gadget: function: printer: fix use-after-free in __lock_acquire udf: Limit sparing table size udf: Avoid accessing uninitialized data on failed inode read USB: cdc-acm: handle broken union descriptors ath9k: hif_usb: fix race condition between usb_get_urb() and usb_kill_anchored_urbs() misc: rtsx: Fix memory leak in rtsx_pci_probe reiserfs: only call unlock_new_inode() if I_NEW xfs: make sure the rt allocator doesn't run off the end usb: ohci: Default to per-port over-current protection Bluetooth: Only mark socket zapped after unlocking scsi: ibmvfc: Fix error return in ibmvfc_probe() brcmsmac: fix memory leak in wlc_phy_attach_lcnphy rtl8xxxu: prevent potential memory leak Fix use after free in get_capset_info callback. tty: ipwireless: fix error handling ipvs: Fix uninit-value in do_ip_vs_set_ctl() reiserfs: Fix memory leak in reiserfs_parse_options() brcm80211: fix possible memleak in brcmf_proto_msgbuf_attach usb: core: Solve race condition in anchor cleanup functions ath10k: check idx validity in __ath10k_htt_rx_ring_fill_n() net: korina: cast KSEG0 address to pointer in kfree usb: cdc-acm: add quirk to blacklist ETAS ES58X devices USB: cdc-wdm: Make wdm_flush() interruptible and add wdm_fsync(). eeprom: at25: set minimum read/write access stride to 1 usb: gadget: f_ncm: allow using NCM in SuperSpeed Plus gadgets. Linux 4.9.241 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: Ie59605b312e5d0314299cad46ab57df803070564
473 lines
12 KiB
C
473 lines
12 KiB
C
/*
|
|
* OMAP4 Keypad Driver
|
|
*
|
|
* Copyright (C) 2010 Texas Instruments
|
|
*
|
|
* Author: Abraham Arce <x0066660@ti.com>
|
|
* Initial Code: Syed Rafiuddin <rafiuddin.syed@ti.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/io.h>
|
|
#include <linux/of.h>
|
|
#include <linux/input.h>
|
|
#include <linux/input/matrix_keypad.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/pm_runtime.h>
|
|
|
|
/* OMAP4 registers */
|
|
#define OMAP4_KBD_REVISION 0x00
|
|
#define OMAP4_KBD_SYSCONFIG 0x10
|
|
#define OMAP4_KBD_SYSSTATUS 0x14
|
|
#define OMAP4_KBD_IRQSTATUS 0x18
|
|
#define OMAP4_KBD_IRQENABLE 0x1C
|
|
#define OMAP4_KBD_WAKEUPENABLE 0x20
|
|
#define OMAP4_KBD_PENDING 0x24
|
|
#define OMAP4_KBD_CTRL 0x28
|
|
#define OMAP4_KBD_DEBOUNCINGTIME 0x2C
|
|
#define OMAP4_KBD_LONGKEYTIME 0x30
|
|
#define OMAP4_KBD_TIMEOUT 0x34
|
|
#define OMAP4_KBD_STATEMACHINE 0x38
|
|
#define OMAP4_KBD_ROWINPUTS 0x3C
|
|
#define OMAP4_KBD_COLUMNOUTPUTS 0x40
|
|
#define OMAP4_KBD_FULLCODE31_0 0x44
|
|
#define OMAP4_KBD_FULLCODE63_32 0x48
|
|
|
|
/* OMAP4 bit definitions */
|
|
#define OMAP4_DEF_IRQENABLE_EVENTEN BIT(0)
|
|
#define OMAP4_DEF_IRQENABLE_LONGKEY BIT(1)
|
|
#define OMAP4_DEF_WUP_EVENT_ENA BIT(0)
|
|
#define OMAP4_DEF_WUP_LONG_KEY_ENA BIT(1)
|
|
#define OMAP4_DEF_CTRL_NOSOFTMODE BIT(1)
|
|
#define OMAP4_DEF_CTRL_PTV_SHIFT 2
|
|
|
|
/* OMAP4 values */
|
|
#define OMAP4_VAL_IRQDISABLE 0x0
|
|
|
|
/*
|
|
* Errata i689: If a key is released for a time shorter than debounce time,
|
|
* the keyboard will idle and never detect the key release. The workaround
|
|
* is to use at least a 12ms debounce time. See omap5432 TRM chapter
|
|
* "26.4.6.2 Keyboard Controller Timer" for more information.
|
|
*/
|
|
#define OMAP4_KEYPAD_PTV_DIV_128 0x6
|
|
#define OMAP4_KEYPAD_DEBOUNCINGTIME_MS(dbms, ptv) \
|
|
((((dbms) * 1000) / ((1 << ((ptv) + 1)) * (1000000 / 32768))) - 1)
|
|
#define OMAP4_VAL_DEBOUNCINGTIME_16MS \
|
|
OMAP4_KEYPAD_DEBOUNCINGTIME_MS(16, OMAP4_KEYPAD_PTV_DIV_128)
|
|
|
|
enum {
|
|
KBD_REVISION_OMAP4 = 0,
|
|
KBD_REVISION_OMAP5,
|
|
};
|
|
|
|
struct omap4_keypad {
|
|
struct input_dev *input;
|
|
|
|
void __iomem *base;
|
|
bool irq_wake_enabled;
|
|
unsigned int irq;
|
|
|
|
unsigned int rows;
|
|
unsigned int cols;
|
|
u32 reg_offset;
|
|
u32 irqreg_offset;
|
|
unsigned int row_shift;
|
|
bool no_autorepeat;
|
|
unsigned char key_state[8];
|
|
unsigned short *keymap;
|
|
};
|
|
|
|
static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset)
|
|
{
|
|
return __raw_readl(keypad_data->base +
|
|
keypad_data->reg_offset + offset);
|
|
}
|
|
|
|
static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value)
|
|
{
|
|
__raw_writel(value,
|
|
keypad_data->base + keypad_data->reg_offset + offset);
|
|
}
|
|
|
|
static int kbd_read_irqreg(struct omap4_keypad *keypad_data, u32 offset)
|
|
{
|
|
return __raw_readl(keypad_data->base +
|
|
keypad_data->irqreg_offset + offset);
|
|
}
|
|
|
|
static void kbd_write_irqreg(struct omap4_keypad *keypad_data,
|
|
u32 offset, u32 value)
|
|
{
|
|
__raw_writel(value,
|
|
keypad_data->base + keypad_data->irqreg_offset + offset);
|
|
}
|
|
|
|
|
|
/* Interrupt handlers */
|
|
static irqreturn_t omap4_keypad_irq_handler(int irq, void *dev_id)
|
|
{
|
|
struct omap4_keypad *keypad_data = dev_id;
|
|
|
|
if (kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS))
|
|
return IRQ_WAKE_THREAD;
|
|
|
|
return IRQ_NONE;
|
|
}
|
|
|
|
static irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id)
|
|
{
|
|
struct omap4_keypad *keypad_data = dev_id;
|
|
struct input_dev *input_dev = keypad_data->input;
|
|
unsigned char key_state[ARRAY_SIZE(keypad_data->key_state)];
|
|
unsigned int col, row, code, changed;
|
|
u32 *new_state = (u32 *) key_state;
|
|
|
|
*new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0);
|
|
*(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32);
|
|
|
|
for (row = 0; row < keypad_data->rows; row++) {
|
|
changed = key_state[row] ^ keypad_data->key_state[row];
|
|
if (!changed)
|
|
continue;
|
|
|
|
for (col = 0; col < keypad_data->cols; col++) {
|
|
if (changed & (1 << col)) {
|
|
code = MATRIX_SCAN_CODE(row, col,
|
|
keypad_data->row_shift);
|
|
input_event(input_dev, EV_MSC, MSC_SCAN, code);
|
|
input_report_key(input_dev,
|
|
keypad_data->keymap[code],
|
|
key_state[row] & (1 << col));
|
|
}
|
|
}
|
|
}
|
|
|
|
input_sync(input_dev);
|
|
|
|
memcpy(keypad_data->key_state, key_state,
|
|
sizeof(keypad_data->key_state));
|
|
|
|
/* clear pending interrupts */
|
|
kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
|
|
kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
|
|
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
static int omap4_keypad_open(struct input_dev *input)
|
|
{
|
|
struct omap4_keypad *keypad_data = input_get_drvdata(input);
|
|
|
|
pm_runtime_get_sync(input->dev.parent);
|
|
|
|
disable_irq(keypad_data->irq);
|
|
|
|
kbd_writel(keypad_data, OMAP4_KBD_CTRL,
|
|
OMAP4_DEF_CTRL_NOSOFTMODE |
|
|
(OMAP4_KEYPAD_PTV_DIV_128 << OMAP4_DEF_CTRL_PTV_SHIFT));
|
|
kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME,
|
|
OMAP4_VAL_DEBOUNCINGTIME_16MS);
|
|
/* clear pending interrupts */
|
|
kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
|
|
kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
|
|
kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
|
|
OMAP4_DEF_IRQENABLE_EVENTEN |
|
|
OMAP4_DEF_IRQENABLE_LONGKEY);
|
|
kbd_writel(keypad_data, OMAP4_KBD_WAKEUPENABLE,
|
|
OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA);
|
|
|
|
enable_irq(keypad_data->irq);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void omap4_keypad_close(struct input_dev *input)
|
|
{
|
|
struct omap4_keypad *keypad_data = input_get_drvdata(input);
|
|
|
|
disable_irq(keypad_data->irq);
|
|
|
|
/* Disable interrupts and wake-up events */
|
|
kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
|
|
OMAP4_VAL_IRQDISABLE);
|
|
kbd_writel(keypad_data, OMAP4_KBD_WAKEUPENABLE, 0);
|
|
|
|
/* clear pending interrupts */
|
|
kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
|
|
kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
|
|
|
|
enable_irq(keypad_data->irq);
|
|
|
|
pm_runtime_put_sync(input->dev.parent);
|
|
}
|
|
|
|
static int omap4_keypad_parse_dt(struct device *dev,
|
|
struct omap4_keypad *keypad_data)
|
|
{
|
|
struct device_node *np = dev->of_node;
|
|
int err;
|
|
|
|
err = matrix_keypad_parse_of_params(dev, &keypad_data->rows,
|
|
&keypad_data->cols);
|
|
if (err)
|
|
return err;
|
|
|
|
if (of_get_property(np, "linux,input-no-autorepeat", NULL))
|
|
keypad_data->no_autorepeat = true;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int omap4_keypad_probe(struct platform_device *pdev)
|
|
{
|
|
struct omap4_keypad *keypad_data;
|
|
struct input_dev *input_dev;
|
|
struct resource *res;
|
|
unsigned int max_keys;
|
|
int rev;
|
|
int irq;
|
|
int error;
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
if (!res) {
|
|
dev_err(&pdev->dev, "no base address specified\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
|
if (irq < 0)
|
|
return irq;
|
|
|
|
keypad_data = kzalloc(sizeof(struct omap4_keypad), GFP_KERNEL);
|
|
if (!keypad_data) {
|
|
dev_err(&pdev->dev, "keypad_data memory allocation failed\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
keypad_data->irq = irq;
|
|
|
|
error = omap4_keypad_parse_dt(&pdev->dev, keypad_data);
|
|
if (error)
|
|
goto err_free_keypad;
|
|
|
|
res = request_mem_region(res->start, resource_size(res), pdev->name);
|
|
if (!res) {
|
|
dev_err(&pdev->dev, "can't request mem region\n");
|
|
error = -EBUSY;
|
|
goto err_free_keypad;
|
|
}
|
|
|
|
keypad_data->base = ioremap(res->start, resource_size(res));
|
|
if (!keypad_data->base) {
|
|
dev_err(&pdev->dev, "can't ioremap mem resource\n");
|
|
error = -ENOMEM;
|
|
goto err_release_mem;
|
|
}
|
|
|
|
|
|
/*
|
|
* Enable clocks for the keypad module so that we can read
|
|
* revision register.
|
|
*/
|
|
pm_runtime_enable(&pdev->dev);
|
|
error = pm_runtime_get_sync(&pdev->dev);
|
|
if (error) {
|
|
dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n");
|
|
goto err_unmap;
|
|
}
|
|
rev = __raw_readl(keypad_data->base + OMAP4_KBD_REVISION);
|
|
rev &= 0x03 << 30;
|
|
rev >>= 30;
|
|
switch (rev) {
|
|
case KBD_REVISION_OMAP4:
|
|
keypad_data->reg_offset = 0x00;
|
|
keypad_data->irqreg_offset = 0x00;
|
|
break;
|
|
case KBD_REVISION_OMAP5:
|
|
keypad_data->reg_offset = 0x10;
|
|
keypad_data->irqreg_offset = 0x0c;
|
|
break;
|
|
default:
|
|
dev_err(&pdev->dev,
|
|
"Keypad reports unsupported revision %d", rev);
|
|
error = -EINVAL;
|
|
goto err_pm_put_sync;
|
|
}
|
|
|
|
/* input device allocation */
|
|
keypad_data->input = input_dev = input_allocate_device();
|
|
if (!input_dev) {
|
|
error = -ENOMEM;
|
|
goto err_pm_put_sync;
|
|
}
|
|
|
|
input_dev->name = pdev->name;
|
|
input_dev->dev.parent = &pdev->dev;
|
|
input_dev->id.bustype = BUS_HOST;
|
|
input_dev->id.vendor = 0x0001;
|
|
input_dev->id.product = 0x0001;
|
|
input_dev->id.version = 0x0001;
|
|
|
|
input_dev->open = omap4_keypad_open;
|
|
input_dev->close = omap4_keypad_close;
|
|
|
|
input_set_capability(input_dev, EV_MSC, MSC_SCAN);
|
|
if (!keypad_data->no_autorepeat)
|
|
__set_bit(EV_REP, input_dev->evbit);
|
|
|
|
input_set_drvdata(input_dev, keypad_data);
|
|
|
|
keypad_data->row_shift = get_count_order(keypad_data->cols);
|
|
max_keys = keypad_data->rows << keypad_data->row_shift;
|
|
keypad_data->keymap = kzalloc(max_keys * sizeof(keypad_data->keymap[0]),
|
|
GFP_KERNEL);
|
|
if (!keypad_data->keymap) {
|
|
dev_err(&pdev->dev, "Not enough memory for keymap\n");
|
|
error = -ENOMEM;
|
|
goto err_free_input;
|
|
}
|
|
|
|
error = matrix_keypad_build_keymap(NULL, NULL,
|
|
keypad_data->rows, keypad_data->cols,
|
|
keypad_data->keymap, input_dev);
|
|
if (error) {
|
|
dev_err(&pdev->dev, "failed to build keymap\n");
|
|
goto err_free_keymap;
|
|
}
|
|
|
|
error = request_threaded_irq(keypad_data->irq, omap4_keypad_irq_handler,
|
|
omap4_keypad_irq_thread_fn, IRQF_ONESHOT,
|
|
"omap4-keypad", keypad_data);
|
|
if (error) {
|
|
dev_err(&pdev->dev, "failed to register interrupt\n");
|
|
goto err_free_input;
|
|
}
|
|
|
|
device_init_wakeup(&pdev->dev, true);
|
|
pm_runtime_put_sync(&pdev->dev);
|
|
|
|
error = input_register_device(keypad_data->input);
|
|
if (error < 0) {
|
|
dev_err(&pdev->dev, "failed to register input device\n");
|
|
goto err_pm_disable;
|
|
}
|
|
|
|
platform_set_drvdata(pdev, keypad_data);
|
|
return 0;
|
|
|
|
err_pm_disable:
|
|
pm_runtime_disable(&pdev->dev);
|
|
device_init_wakeup(&pdev->dev, false);
|
|
free_irq(keypad_data->irq, keypad_data);
|
|
err_free_keymap:
|
|
kfree(keypad_data->keymap);
|
|
err_free_input:
|
|
input_free_device(input_dev);
|
|
err_pm_put_sync:
|
|
pm_runtime_put_sync(&pdev->dev);
|
|
err_unmap:
|
|
iounmap(keypad_data->base);
|
|
err_release_mem:
|
|
release_mem_region(res->start, resource_size(res));
|
|
err_free_keypad:
|
|
kfree(keypad_data);
|
|
return error;
|
|
}
|
|
|
|
static int omap4_keypad_remove(struct platform_device *pdev)
|
|
{
|
|
struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
|
|
struct resource *res;
|
|
|
|
free_irq(keypad_data->irq, keypad_data);
|
|
|
|
pm_runtime_disable(&pdev->dev);
|
|
|
|
device_init_wakeup(&pdev->dev, false);
|
|
|
|
input_unregister_device(keypad_data->input);
|
|
|
|
iounmap(keypad_data->base);
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
release_mem_region(res->start, resource_size(res));
|
|
|
|
kfree(keypad_data->keymap);
|
|
kfree(keypad_data);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct of_device_id omap_keypad_dt_match[] = {
|
|
{ .compatible = "ti,omap4-keypad" },
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
|
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
static int omap4_keypad_suspend(struct device *dev)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
|
|
int error;
|
|
|
|
if (device_may_wakeup(&pdev->dev)) {
|
|
error = enable_irq_wake(keypad_data->irq);
|
|
if (!error)
|
|
keypad_data->irq_wake_enabled = true;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int omap4_keypad_resume(struct device *dev)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
|
|
|
|
if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) {
|
|
disable_irq_wake(keypad_data->irq);
|
|
keypad_data->irq_wake_enabled = false;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
static SIMPLE_DEV_PM_OPS(omap4_keypad_pm_ops,
|
|
omap4_keypad_suspend, omap4_keypad_resume);
|
|
|
|
static struct platform_driver omap4_keypad_driver = {
|
|
.probe = omap4_keypad_probe,
|
|
.remove = omap4_keypad_remove,
|
|
.driver = {
|
|
.name = "omap4-keypad",
|
|
.pm = &omap4_keypad_pm_ops,
|
|
.of_match_table = omap_keypad_dt_match,
|
|
},
|
|
};
|
|
module_platform_driver(omap4_keypad_driver);
|
|
|
|
MODULE_AUTHOR("Texas Instruments");
|
|
MODULE_DESCRIPTION("OMAP4 Keypad Driver");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_ALIAS("platform:omap4-keypad");
|