aboutsummaryrefslogtreecommitdiff
path: root/drivers/input/misc/retu-pwrbutton.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 12:46:37 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 12:46:37 -0800
commit31564cbd77baa88405862d4aa0d00893ab1d8cb7 (patch)
tree2eaec947ab64ccfa2d94ca29bf14feb70b8a4b61 /drivers/input/misc/retu-pwrbutton.c
parent6842d98de7bb726dfddc719cb9ae022b26a0f2b8 (diff)
parent022573c275500e1a50889949f679d04b5446edf6 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull second round of input updates from Dmitry Torokhov: "As usual, there are a couple of new drivers, input core now supports managed input devices (devres), a slew of drivers now have device tree support and a bunch of fixes and cleanups." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (71 commits) Input: walkera0701 - fix crash on startup Input: matrix-keymap - provide a proper module license Input: gpio_keys_polled - switch to using gpio_request_one() Input: gpio_keys - switch to using gpio_request_one() Input: wacom - fix touch support for Bamboo Fun CTH-461 Input: xpad - add a few new VID/PID combinations Input: xpad - minor formatting fixes Input: gpio-keys-polled - honor 'autorepeat' setting in platform data Input: tca8418-keypad - switch to using managed resources Input: tca8418_keypad - increase severity of failures in probe() Input: tca8418_keypad - move device ID tables closer to where they are used Input: tca8418_keypad - use dev_get_platdata() to retrieve platform data Input: tca8418_keypad - use a temporary variable for parent device Input: tca8418_keypad - add support for shared interrupt Input: tca8418_keypad - add support for device tree bindings Input: remove Compaq iPAQ H3600 (Bitsy) touchscreen driver Input: bu21013_ts - add support for Device Tree booting Input: bu21013_ts - move GPIO init and exit functions into the driver Input: bu21013_ts - request regulator that actually exists ARM: ux500: Strip out duplicate touch screen platform information ...
Diffstat (limited to 'drivers/input/misc/retu-pwrbutton.c')
-rw-r--r--drivers/input/misc/retu-pwrbutton.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/drivers/input/misc/retu-pwrbutton.c b/drivers/input/misc/retu-pwrbutton.c
new file mode 100644
index 00000000000..7ca09baa001
--- /dev/null
+++ b/drivers/input/misc/retu-pwrbutton.c
@@ -0,0 +1,99 @@
+/*
+ * Retu power button driver.
+ *
+ * Copyright (C) 2004-2010 Nokia Corporation
+ *
+ * Original code written by Ari Saastamoinen, Juha Yrjölä and Felipe Balbi.
+ * Rewritten by Aaro Koskinen.
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * 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.
+ */
+
+#include <linux/irq.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/errno.h>
+#include <linux/input.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mfd/retu.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+
+#define RETU_STATUS_PWRONX (1 << 5)
+
+static irqreturn_t retu_pwrbutton_irq(int irq, void *_pwr)
+{
+ struct input_dev *idev = _pwr;
+ struct retu_dev *rdev = input_get_drvdata(idev);
+ bool state;
+
+ state = !(retu_read(rdev, RETU_REG_STATUS) & RETU_STATUS_PWRONX);
+ input_report_key(idev, KEY_POWER, state);
+ input_sync(idev);
+
+ return IRQ_HANDLED;
+}
+
+static int retu_pwrbutton_probe(struct platform_device *pdev)
+{
+ struct retu_dev *rdev = dev_get_drvdata(pdev->dev.parent);
+ struct input_dev *idev;
+ int irq;
+ int error;
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
+
+ idev = devm_input_allocate_device(&pdev->dev);
+ if (!idev)
+ return -ENOMEM;
+
+ idev->name = "retu-pwrbutton";
+ idev->dev.parent = &pdev->dev;
+
+ input_set_capability(idev, EV_KEY, KEY_POWER);
+ input_set_drvdata(idev, rdev);
+
+ error = devm_request_threaded_irq(&pdev->dev, irq,
+ NULL, retu_pwrbutton_irq, 0,
+ "retu-pwrbutton", idev);
+ if (error)
+ return error;
+
+ error = input_register_device(idev);
+ if (error)
+ return error;
+
+ return 0;
+}
+
+static int retu_pwrbutton_remove(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static struct platform_driver retu_pwrbutton_driver = {
+ .probe = retu_pwrbutton_probe,
+ .remove = retu_pwrbutton_remove,
+ .driver = {
+ .name = "retu-pwrbutton",
+ .owner = THIS_MODULE,
+ },
+};
+module_platform_driver(retu_pwrbutton_driver);
+
+MODULE_ALIAS("platform:retu-pwrbutton");
+MODULE_DESCRIPTION("Retu Power Button");
+MODULE_AUTHOR("Ari Saastamoinen");
+MODULE_AUTHOR("Felipe Balbi");
+MODULE_AUTHOR("Aaro Koskinen <aaro.koskinen@iki.fi>");
+MODULE_LICENSE("GPL");