aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ucb1x00-assabet.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-01-21 10:53:42 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-02-18 18:15:44 -0500
commit54292a4649a5dd93562d10f188a8e201afebfe2f (patch)
tree69c51a1a5505a46cfeb71a16664b48c5ba75cc21 /drivers/mfd/ucb1x00-assabet.c
parent69dde86aa616b09bb3ef39a5ab783f82254d241c (diff)
MFD: ucb1x00-assabet: add support for UCB1x00 GPIO switches
Add support for UCB1x00 GPIO buttons found on the Assabet platform. We can now trivially support these buttons as we have standardized gpiolib, genirq and gpio keyboard support in place for this device. Acked-by: Jochen Friedrich <jochen@scram.de> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/mfd/ucb1x00-assabet.c')
-rw-r--r--drivers/mfd/ucb1x00-assabet.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/drivers/mfd/ucb1x00-assabet.c b/drivers/mfd/ucb1x00-assabet.c
index b7be613cb503..b63c0756a669 100644
--- a/drivers/mfd/ucb1x00-assabet.c
+++ b/drivers/mfd/ucb1x00-assabet.c
@@ -11,9 +11,13 @@
11 */ 11 */
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/device.h>
15#include <linux/err.h>
14#include <linux/fs.h> 16#include <linux/fs.h>
17#include <linux/gpio_keys.h>
18#include <linux/input.h>
19#include <linux/platform_device.h>
15#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
16#include <linux/device.h>
17#include <linux/mfd/ucb1x00.h> 21#include <linux/mfd/ucb1x00.h>
18 22
19#define UCB1X00_ATTR(name,input)\ 23#define UCB1X00_ATTR(name,input)\
@@ -35,14 +39,45 @@ UCB1X00_ATTR(batt_temp, UCB_ADC_INP_AD2);
35 39
36static int ucb1x00_assabet_add(struct ucb1x00_dev *dev) 40static int ucb1x00_assabet_add(struct ucb1x00_dev *dev)
37{ 41{
38 device_create_file(&dev->ucb->dev, &dev_attr_vbatt); 42 struct ucb1x00 *ucb = dev->ucb;
39 device_create_file(&dev->ucb->dev, &dev_attr_vcharger); 43 struct platform_device *pdev;
40 device_create_file(&dev->ucb->dev, &dev_attr_batt_temp); 44 struct gpio_keys_platform_data keys;
45 static struct gpio_keys_button buttons[6];
46 unsigned i;
47
48 memset(buttons, 0, sizeof(buttons));
49 memset(&keys, 0, sizeof(keys));
50
51 for (i = 0; i < ARRAY_SIZE(buttons); i++) {
52 buttons[i].code = BTN_0 + i;
53 buttons[i].gpio = ucb->gpio.base + i;
54 buttons[i].type = EV_KEY;
55 buttons[i].can_disable = true;
56 }
57
58 keys.buttons = buttons;
59 keys.nbuttons = ARRAY_SIZE(buttons);
60 keys.poll_interval = 50;
61 keys.name = "ucb1x00";
62
63 pdev = platform_device_register_data(&ucb->dev, "gpio-keys", -1,
64 &keys, sizeof(keys));
65
66 device_create_file(&ucb->dev, &dev_attr_vbatt);
67 device_create_file(&ucb->dev, &dev_attr_vcharger);
68 device_create_file(&ucb->dev, &dev_attr_batt_temp);
69
70 dev->priv = pdev;
41 return 0; 71 return 0;
42} 72}
43 73
44static void ucb1x00_assabet_remove(struct ucb1x00_dev *dev) 74static void ucb1x00_assabet_remove(struct ucb1x00_dev *dev)
45{ 75{
76 struct platform_device *pdev = dev->priv;
77
78 if (!IS_ERR(pdev))
79 platform_device_unregister(pdev);
80
46 device_remove_file(&dev->ucb->dev, &dev_attr_batt_temp); 81 device_remove_file(&dev->ucb->dev, &dev_attr_batt_temp);
47 device_remove_file(&dev->ucb->dev, &dev_attr_vcharger); 82 device_remove_file(&dev->ucb->dev, &dev_attr_vcharger);
48 device_remove_file(&dev->ucb->dev, &dev_attr_vbatt); 83 device_remove_file(&dev->ucb->dev, &dev_attr_vbatt);