diff options
author | Hu hui <b29976@freescale.com> | 2010-10-13 14:50:37 +0800 |
---|---|---|
committer | Hu Hui <b29976@freescale.com> | 2010-10-14 10:37:04 +0800 |
commit | 5cf5168865f3ef150b6c4bb8e7ca2f04541fdea1 (patch) | |
tree | cd5a45e8e37fec9a19b4d5a68729f9dc35514326 /drivers/input | |
parent | 5325044f9f5bfdb8ab7f36cb78e347ffc1d326ef (diff) |
ENGR00132553-2 Power: enable power on/off key as suspend/resume key
Driver Part
enable the powerkey as suspend/resume key on mx53evk and mx50 rdp
Signed-off-by: Hu Hui <b29976@freescale.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/Makefile | 1 | ||||
-rwxr-xr-x | drivers/input/keyboard/mxc_pwrkey.c | 128 |
2 files changed, 129 insertions, 0 deletions
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index ce93d014483d..5640a0aa9f39 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -39,6 +39,7 @@ obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o obj-$(CONFIG_KEYBOARD_MXC) += mxc_keyb.o +obj-$(CONFIG_KEYBOARD_MXC) += mxc_pwrkey.o obj-$(CONFIG_KEYBOARD_MPR084) += mpr084.o obj-$(CONFIG_KEYBOARD_MXS) += mxs-kbd.o obj-$(CONFIG_KEYBOARD_MC9S08DZ60) += mc9s08dz60_keyb.o diff --git a/drivers/input/keyboard/mxc_pwrkey.c b/drivers/input/keyboard/mxc_pwrkey.c new file mode 100755 index 000000000000..c4e9ce9865c1 --- /dev/null +++ b/drivers/input/keyboard/mxc_pwrkey.c @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. + */ + +/* + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#include <linux/module.h> +#include <linux/sched.h> +#include <linux/mm.h> +#include <linux/init.h> +#include <asm/io.h> +#include <asm/uaccess.h> +#include <linux/kd.h> +#include <linux/fs.h> +#include <linux/ioctl.h> +#include <linux/input.h> +#include <linux/irq.h> +#include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <linux/pmic_external.h> + +#define KEYCODE_ONOFF KEY_F4 + +/*! Input device structure. */ +static struct input_dev *mxcpwrkey_dev; +static bool key_press; +static void power_key_event_handler(void) +{ + if (!key_press) { + key_press = true; + input_report_key(mxcpwrkey_dev, KEYCODE_ONOFF, 1); + pr_info("%s_KeyUP\n", __func__); + } else { + if (key_press) { + key_press = false; + input_report_key(mxcpwrkey_dev, KEYCODE_ONOFF, 0); + pr_info("%s_KeyDown\n", __func__); + } + } +} +static int mxcpwrkey_probe(struct platform_device *pdev) +{ + int retval, err; + pmic_event_callback_t power_key_event; + + printk(KERN_INFO "PMIC powerkey probe\n"); + + key_press = false; + mxcpwrkey_dev = input_allocate_device(); + if (!mxcpwrkey_dev) { + printk(KERN_ERR "mxcpwrkey_dev: not enough memory for input device\n"); + retval = -ENOMEM; + goto err1; + } + + mxcpwrkey_dev->name = "mxc_power_key"; + mxcpwrkey_dev->phys = "mxcpwrkey/input0"; + mxcpwrkey_dev->id.bustype = BUS_HOST; + mxcpwrkey_dev->evbit[0] = BIT_MASK(EV_KEY); + + power_key_event.param = NULL; + power_key_event.func = (void *)power_key_event_handler; + pmic_event_subscribe(EVENT_PWRONI, power_key_event); + + input_set_capability(mxcpwrkey_dev, EV_KEY, KEYCODE_ONOFF); + + retval = input_register_device(mxcpwrkey_dev); + if (retval < 0) { + printk(KERN_ERR "mxcpwrkey_dev: failed to register input device\n"); + goto err2; + } + return 0; +err2: + input_free_device(mxcpwrkey_dev); +err1: + return retval; +} +static int mxcpwrkey_remove(struct platform_device *pdev) +{ + return 0; +} +static int mxc_pwrkey_suspend(struct platform_device *pdev, pm_message_t state) +{ + return 0; +} +static int mxc_pwrkey_resume(struct platform_device *pdev) +{ + return 0; +} +static struct platform_driver mxcpwrkey_driver = { + .driver = { + .name = "mxcpwrkey", + }, + .probe = mxcpwrkey_probe, + .remove = mxcpwrkey_remove, + .suspend = mxc_pwrkey_suspend, + .resume = mxc_pwrkey_resume, +}; +static int __init mxcpwrkey_init(void) +{ + platform_driver_register(&mxcpwrkey_driver); + return 0; +} + +static void __exit mxcpwrkey_exit(void) +{ + platform_driver_unregister(&mxcpwrkey_driver); +} +module_init(mxcpwrkey_init); +module_exit(mxcpwrkey_exit); + + +MODULE_AUTHOR("Freescale Semiconductor"); +MODULE_DESCRIPTION("MXC board power key Driver"); +MODULE_LICENSE("GPL"); |