diff options
author | codeworkx <daniel.hillenbrand@codeworkx.de> | 2012-06-02 13:09:29 +0200 |
---|---|---|
committer | codeworkx <daniel.hillenbrand@codeworkx.de> | 2012-06-02 13:09:29 +0200 |
commit | c6da2cfeb05178a11c6d062a06f8078150ee492f (patch) | |
tree | f3b4021d252c52d6463a9b3c1bb7245e399b009c /arch/arm/mach-exynos/wakeup_assist.c | |
parent | c6d7c4dbff353eac7919342ae6b3299a378160a6 (diff) | |
download | kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.zip kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.tar.gz kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.tar.bz2 |
samsung update 1
Diffstat (limited to 'arch/arm/mach-exynos/wakeup_assist.c')
-rw-r--r-- | arch/arm/mach-exynos/wakeup_assist.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/arch/arm/mach-exynos/wakeup_assist.c b/arch/arm/mach-exynos/wakeup_assist.c new file mode 100644 index 0000000..fe6d9d7 --- /dev/null +++ b/arch/arm/mach-exynos/wakeup_assist.c @@ -0,0 +1,110 @@ +/* + * Wakeup assist driver + * + * 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. + */ + +#include <linux/err.h> +#include <linux/input.h> +#include <linux/platform_device.h> +#include <linux/io.h> +#include <mach/regs-pmu.h> + +#define DEV_NAME "wakeup_assist" + +static int wakeup_assist_keycode[] = { KEY_POWER }; + +static int __devinit wakeup_assist_probe(struct platform_device *pdev) +{ + int error; + struct input_dev *input_dev; + + input_dev = input_allocate_device(); + + if (!input_dev) + return -ENOMEM; + + input_dev->name = DEV_NAME; + input_dev->id.bustype = BUS_HOST; + input_dev->dev.parent = &pdev->dev; + + input_dev->evbit[0] = BIT_MASK(EV_KEY); + + input_set_capability(input_dev, EV_MSC, MSC_SCAN); + + input_dev->keycode = wakeup_assist_keycode; + input_dev->keycodesize = sizeof(wakeup_assist_keycode[0]); + input_dev->keycodemax = ARRAY_SIZE(wakeup_assist_keycode); + + __set_bit(wakeup_assist_keycode[0], input_dev->keybit); + __clear_bit(KEY_RESERVED, input_dev->keybit); + + error = input_register_device(input_dev); + if (error) { + input_free_device(input_dev); + return error; + } + + platform_set_drvdata(pdev, input_dev); + + return 0; +} + +static int __devexit wakeup_assist_remove(struct platform_device *pdev) +{ + struct input_dev *input_dev = platform_get_drvdata(pdev); + + platform_set_drvdata(pdev, NULL); + input_unregister_device(input_dev); + input_free_device(input_dev); + + return 0; +} + +static int wakeup_assist_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct input_dev *input_dev = platform_get_drvdata(pdev); + + if (readl(S5P_WAKEUP_STAT) & 0x1) { + input_report_key(input_dev, wakeup_assist_keycode[0], 0x2); + input_sync(input_dev); + input_report_key(input_dev, wakeup_assist_keycode[0], 0x0); + input_sync(input_dev); + } + + return 0; +} + +static const struct dev_pm_ops wakeup_assist_pm_ops = { + .resume = wakeup_assist_resume, +}; + +static struct platform_driver wakeup_assist_driver = { + .probe = wakeup_assist_probe, + .remove = __devexit_p(wakeup_assist_remove), + .driver = { + .name = DEV_NAME, + .owner = THIS_MODULE, + .pm = &wakeup_assist_pm_ops, + }, +}; + +static int __init wakeup_assist_init(void) +{ + return platform_driver_register(&wakeup_assist_driver); +} +module_init(wakeup_assist_init); + +static void __exit wakeup_assist_exit(void) +{ + platform_driver_unregister(&wakeup_assist_driver); +} +module_exit(wakeup_assist_exit); + +MODULE_DESCRIPTION("Wakeup assist driver"); +MODULE_AUTHOR("Eunki Kim <eunki_kim@samsung.com>"); +MODULE_LICENSE("GPL"); |