Commit 54292a46 authored by Russell King's avatar Russell King

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: default avatarJochen Friedrich <jochen@scram.de>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 69dde86a
...@@ -11,9 +11,13 @@ ...@@ -11,9 +11,13 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/gpio_keys.h>
#include <linux/input.h>
#include <linux/platform_device.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/device.h>
#include <linux/mfd/ucb1x00.h> #include <linux/mfd/ucb1x00.h>
#define UCB1X00_ATTR(name,input)\ #define UCB1X00_ATTR(name,input)\
...@@ -35,14 +39,45 @@ UCB1X00_ATTR(batt_temp, UCB_ADC_INP_AD2); ...@@ -35,14 +39,45 @@ UCB1X00_ATTR(batt_temp, UCB_ADC_INP_AD2);
static int ucb1x00_assabet_add(struct ucb1x00_dev *dev) static int ucb1x00_assabet_add(struct ucb1x00_dev *dev)
{ {
device_create_file(&dev->ucb->dev, &dev_attr_vbatt); struct ucb1x00 *ucb = dev->ucb;
device_create_file(&dev->ucb->dev, &dev_attr_vcharger); struct platform_device *pdev;
device_create_file(&dev->ucb->dev, &dev_attr_batt_temp); struct gpio_keys_platform_data keys;
static struct gpio_keys_button buttons[6];
unsigned i;
memset(buttons, 0, sizeof(buttons));
memset(&keys, 0, sizeof(keys));
for (i = 0; i < ARRAY_SIZE(buttons); i++) {
buttons[i].code = BTN_0 + i;
buttons[i].gpio = ucb->gpio.base + i;
buttons[i].type = EV_KEY;
buttons[i].can_disable = true;
}
keys.buttons = buttons;
keys.nbuttons = ARRAY_SIZE(buttons);
keys.poll_interval = 50;
keys.name = "ucb1x00";
pdev = platform_device_register_data(&ucb->dev, "gpio-keys", -1,
&keys, sizeof(keys));
device_create_file(&ucb->dev, &dev_attr_vbatt);
device_create_file(&ucb->dev, &dev_attr_vcharger);
device_create_file(&ucb->dev, &dev_attr_batt_temp);
dev->priv = pdev;
return 0; return 0;
} }
static void ucb1x00_assabet_remove(struct ucb1x00_dev *dev) static void ucb1x00_assabet_remove(struct ucb1x00_dev *dev)
{ {
struct platform_device *pdev = dev->priv;
if (!IS_ERR(pdev))
platform_device_unregister(pdev);
device_remove_file(&dev->ucb->dev, &dev_attr_batt_temp); device_remove_file(&dev->ucb->dev, &dev_attr_batt_temp);
device_remove_file(&dev->ucb->dev, &dev_attr_vcharger); device_remove_file(&dev->ucb->dev, &dev_attr_vcharger);
device_remove_file(&dev->ucb->dev, &dev_attr_vbatt); device_remove_file(&dev->ucb->dev, &dev_attr_vbatt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment