aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorTodd Fischer <todd.fischer@ridgerun.com>2010-04-08 03:04:55 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2010-05-27 19:37:38 -0400
commit31dd6a2672e337f5de188df3e5169ee732798236 (patch)
treed0a12a6622d9a32a107267a4479f6e12a495dbd3 /drivers/mfd
parent4ce5ba5ba2dfc8186bf31fe7f2d23ff6b5384124 (diff)
mfd: Add TPS6507x support
TPS6507x are multi function (PM, touchscreen) chipsets from TI. This commit also changes the corresponding regulator driver from being standalone to an MFD subdevice. Signed-off-by: Todd Fischer <todd.fischer@ridgerun.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/Kconfig12
-rw-r--r--drivers/mfd/Makefile1
-rw-r--r--drivers/mfd/tps6507x.c156
3 files changed, 169 insertions, 0 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 05c137d16b04..40e0a0a7df5b 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -116,6 +116,18 @@ config TPS65010
116 This driver can also be built as a module. If so, the module 116 This driver can also be built as a module. If so, the module
117 will be called tps65010. 117 will be called tps65010.
118 118
119config TPS6507X
120 tristate "TPS6507x Power Management / Touch Screen chips"
121 select MFD_CORE
122 depends on I2C
123 help
124 If you say yes here you get support for the TPS6507x series of
125 Power Management / Touch Screen chips. These include voltage
126 regulators, lithium ion/polymer battery charging, touch screen
127 and other features that are often used in portable devices.
128 This driver can also be built as a module. If so, the module
129 will be called tps6507x.
130
119config MENELAUS 131config MENELAUS
120 bool "Texas Instruments TWL92330/Menelaus PM chip" 132 bool "Texas Instruments TWL92330/Menelaus PM chip"
121 depends on I2C=y && ARCH_OMAP2 133 depends on I2C=y && ARCH_OMAP2
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 21eff85b288a..abf6f1766dcd 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o
29obj-$(CONFIG_MFD_WM8994) += wm8994-core.o wm8994-irq.o 29obj-$(CONFIG_MFD_WM8994) += wm8994-core.o wm8994-irq.o
30 30
31obj-$(CONFIG_TPS65010) += tps65010.o 31obj-$(CONFIG_TPS65010) += tps65010.o
32obj-$(CONFIG_TPS6507X) += tps6507x.o
32obj-$(CONFIG_MENELAUS) += menelaus.o 33obj-$(CONFIG_MENELAUS) += menelaus.o
33 34
34obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o 35obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
diff --git a/drivers/mfd/tps6507x.c b/drivers/mfd/tps6507x.c
new file mode 100644
index 000000000000..c59f74570b3b
--- /dev/null
+++ b/drivers/mfd/tps6507x.c
@@ -0,0 +1,156 @@
1/*
2 * tps6507x.c -- TPS6507x chip family multi-function driver
3 *
4 * Copyright (c) 2010 RidgeRun (todd.fischer@ridgerun.com)
5 *
6 * Author: Todd Fischer
7 * todd.fischer@ridgerun.com
8 *
9 * Credits:
10 *
11 * Using code from wm831x-*.c, wm8400-core, Wolfson Microelectronics PLC.
12 *
13 * For licencing details see kernel-base/COPYING
14 *
15 */
16
17#include <linux/module.h>
18#include <linux/moduleparam.h>
19#include <linux/init.h>
20#include <linux/slab.h>
21#include <linux/i2c.h>
22#include <linux/mfd/core.h>
23#include <linux/mfd/tps6507x.h>
24
25static struct mfd_cell tps6507x_devs[] = {
26 {
27 .name = "tps6507x-pmic",
28 },
29};
30
31
32static int tps6507x_i2c_read_device(struct tps6507x_dev *tps6507x, char reg,
33 int bytes, void *dest)
34{
35 struct i2c_client *i2c = tps6507x->i2c_client;
36 struct i2c_msg xfer[2];
37 int ret;
38
39 /* Write register */
40 xfer[0].addr = i2c->addr;
41 xfer[0].flags = 0;
42 xfer[0].len = 1;
43 xfer[0].buf = &reg;
44
45 /* Read data */
46 xfer[1].addr = i2c->addr;
47 xfer[1].flags = I2C_M_RD;
48 xfer[1].len = bytes;
49 xfer[1].buf = dest;
50
51 ret = i2c_transfer(i2c->adapter, xfer, 2);
52 if (ret == 2)
53 ret = 0;
54 else if (ret >= 0)
55 ret = -EIO;
56
57 return ret;
58}
59
60static int tps6507x_i2c_write_device(struct tps6507x_dev *tps6507x, char reg,
61 int bytes, void *src)
62{
63 struct i2c_client *i2c = tps6507x->i2c_client;
64 /* we add 1 byte for device register */
65 u8 msg[TPS6507X_MAX_REGISTER + 1];
66 int ret;
67
68 if (bytes > (TPS6507X_MAX_REGISTER + 1))
69 return -EINVAL;
70
71 msg[0] = reg;
72 memcpy(&msg[1], src, bytes);
73
74 ret = i2c_master_send(i2c, msg, bytes + 1);
75 if (ret < 0)
76 return ret;
77 if (ret != bytes + 1)
78 return -EIO;
79 return 0;
80}
81
82static int tps6507x_i2c_probe(struct i2c_client *i2c,
83 const struct i2c_device_id *id)
84{
85 struct tps6507x_dev *tps6507x;
86 int ret = 0;
87
88 tps6507x = kzalloc(sizeof(struct tps6507x_dev), GFP_KERNEL);
89 if (tps6507x == NULL) {
90 kfree(i2c);
91 return -ENOMEM;
92 }
93
94 i2c_set_clientdata(i2c, tps6507x);
95 tps6507x->dev = &i2c->dev;
96 tps6507x->i2c_client = i2c;
97 tps6507x->read_dev = tps6507x_i2c_read_device;
98 tps6507x->write_dev = tps6507x_i2c_write_device;
99
100 ret = mfd_add_devices(tps6507x->dev, -1,
101 tps6507x_devs, ARRAY_SIZE(tps6507x_devs),
102 NULL, 0);
103
104 if (ret < 0)
105 goto err;
106
107 return ret;
108
109err:
110 mfd_remove_devices(tps6507x->dev);
111 kfree(tps6507x);
112 return ret;
113}
114
115static int tps6507x_i2c_remove(struct i2c_client *i2c)
116{
117 struct tps6507x_dev *tps6507x = i2c_get_clientdata(i2c);
118
119 mfd_remove_devices(tps6507x->dev);
120 kfree(tps6507x);
121
122 return 0;
123}
124
125static const struct i2c_device_id tps6507x_i2c_id[] = {
126 { "tps6507x", 0 },
127 { }
128};
129MODULE_DEVICE_TABLE(i2c, tps6507x_i2c_id);
130
131
132static struct i2c_driver tps6507x_i2c_driver = {
133 .driver = {
134 .name = "tps6507x",
135 .owner = THIS_MODULE,
136 },
137 .probe = tps6507x_i2c_probe,
138 .remove = tps6507x_i2c_remove,
139 .id_table = tps6507x_i2c_id,
140};
141
142static int __init tps6507x_i2c_init(void)
143{
144 return i2c_add_driver(&tps6507x_i2c_driver);
145}
146/* init early so consumer devices can complete system boot */
147subsys_initcall(tps6507x_i2c_init);
148
149static void __exit tps6507x_i2c_exit(void)
150{
151 i2c_del_driver(&tps6507x_i2c_driver);
152}
153module_exit(tps6507x_i2c_exit);
154
155MODULE_DESCRIPTION("TPS6507x chip family multi-function driver");
156MODULE_LICENSE("GPL");