diff options
author | Balaji Rao <balajirrao@openmoko.org> | 2008-11-20 19:46:51 +0000 |
---|---|---|
committer | Andy Green <agreen@pads.home.warmcat.com> | 2008-11-20 19:46:51 +0000 |
commit | 5557b3223d35dd25366d6ef047299b1dc94b17e6 (patch) | |
tree | 51916c9efabb93c2a337a703abf686accbfdad36 /drivers/mfd/pcf50633-gpio.c | |
parent | b0c88072f6652fa897d67a4e8c5bea5e09438189 (diff) |
pcf50633_mfd.patch
pcf50633 driver rewritten to use the MFD model.
Diffstat (limited to 'drivers/mfd/pcf50633-gpio.c')
-rw-r--r-- | drivers/mfd/pcf50633-gpio.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/mfd/pcf50633-gpio.c b/drivers/mfd/pcf50633-gpio.c new file mode 100644 index 00000000000..f71acbd6dbc --- /dev/null +++ b/drivers/mfd/pcf50633-gpio.c @@ -0,0 +1,62 @@ +#include <linux/mfd/pcf50633/core.h> +#include <linux/mfd/pcf50633/gpio.h> + +void pcf50633_gpio_set(struct pcf50633 *pcf, int gpio, int on) +{ + u8 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG; + + if (on) + pcf50633_reg_set_bit_mask(pcf, reg, 0x0f, 0x07); + else + pcf50633_reg_set_bit_mask(pcf, reg, 0x0f, 0x00); +} +EXPORT_SYMBOL_GPL(pcf50633_gpio_set); + +int pcf50633_gpio_get(struct pcf50633 *pcf, int gpio) +{ + u8 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG; + u8 val = pcf50633_reg_read(pcf, reg) & 0x0f; + + if (val == PCF50633_GPOCFG_GPOSEL_1 || + val == (PCF50633_GPOCFG_GPOSEL_0|PCF50633_GPOCFG_GPOSEL_INVERSE)) + return 1; + + return 0; +} +EXPORT_SYMBOL_GPL(pcf50633_gpio_get); + +int __init pcf50633_gpio_probe(struct platform_device *pdev) +{ + return 0; +} + +static int __devexit pcf50633_gpio_remove(struct platform_device *pdev) +{ + return 0; +} + +struct platform_driver pcf50633_gpio_driver = { + .driver = { + .name = "pcf50633-gpio", + }, + .probe = pcf50633_gpio_probe, + .remove = __devexit_p(pcf50633_gpio_remove), +}; + +static int __init pcf50633_gpio_init(void) +{ + return platform_driver_register(&pcf50633_gpio_driver); +} +module_init(pcf50633_gpio_init); + +static void __exit pcf50633_gpio_exit(void) +{ + platform_driver_unregister(&pcf50633_gpio_driver); +} +module_exit(pcf50633_gpio_exit); + +MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>"); +MODULE_DESCRIPTION("PCF50633 gpio driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:pcf50633-gpio"); + |