diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-13 23:43:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-13 23:43:32 -0500 |
commit | 21ebd6c68b5511b55f4f456e4ba17c2d711e3617 (patch) | |
tree | 2f4f98568a7a52ab6734fb190d0cbf6f9c1c6492 /drivers/mfd | |
parent | 4b8be38cf782f8ebebc089083fa0572ade79d7ca (diff) | |
parent | 74d836c4142e5d100f8d9a1b2ee3003c2ed7109d (diff) |
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (59 commits)
rtc: max8925: Add function to work as wakeup source
mfd: Add pm ops to max8925
mfd: Convert aat2870 to dev_pm_ops
mfd: Still check other interrupts if we get a wm831x touchscreen IRQ
mfd: Introduce missing kfree in 88pm860x probe routine
mfd: Add S5M series configuration
mfd: Add s5m series irq driver
mfd: Add S5M core driver
mfd: Improve mc13xxx dt binding document
mfd: Fix stmpe section mismatch
mfd: Fix stmpe build warning
mfd: Fix STMPE I2c build failure
mfd: Constify aat2870-core i2c_device_id table
gpio: Add support for stmpe variant 801
mfd: Add support for stmpe variant 801
mfd: Add support for stmpe variant 610
mfd: Add support for STMPE SPI interface
mfd: Separate out STMPE controller and interface specific code
misc: Remove max8997-muic sysfs attributes
mfd: Remove unused wm831x_irq_data_to_mask_reg()
...
Fix up trivial conflict in drivers/leds/Kconfig due to addition of
LEDS_MAX8997 and LEDS_TCA6507 next to each other.
Diffstat (limited to 'drivers/mfd')
54 files changed, 1775 insertions, 524 deletions
diff --git a/drivers/mfd/88pm860x-i2c.c b/drivers/mfd/88pm860x-i2c.c index e017dc88622a..f93dd9571c3c 100644 --- a/drivers/mfd/88pm860x-i2c.c +++ b/drivers/mfd/88pm860x-i2c.c | |||
@@ -12,51 +12,20 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/i2c.h> | 14 | #include <linux/i2c.h> |
15 | #include <linux/err.h> | ||
16 | #include <linux/regmap.h> | ||
15 | #include <linux/mfd/88pm860x.h> | 17 | #include <linux/mfd/88pm860x.h> |
16 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
17 | 19 | ||
18 | static inline int pm860x_read_device(struct i2c_client *i2c, | ||
19 | int reg, int bytes, void *dest) | ||
20 | { | ||
21 | unsigned char data; | ||
22 | int ret; | ||
23 | |||
24 | data = (unsigned char)reg; | ||
25 | ret = i2c_master_send(i2c, &data, 1); | ||
26 | if (ret < 0) | ||
27 | return ret; | ||
28 | |||
29 | ret = i2c_master_recv(i2c, dest, bytes); | ||
30 | if (ret < 0) | ||
31 | return ret; | ||
32 | return 0; | ||
33 | } | ||
34 | |||
35 | static inline int pm860x_write_device(struct i2c_client *i2c, | ||
36 | int reg, int bytes, void *src) | ||
37 | { | ||
38 | unsigned char buf[bytes + 1]; | ||
39 | int ret; | ||
40 | |||
41 | buf[0] = (unsigned char)reg; | ||
42 | memcpy(&buf[1], src, bytes); | ||
43 | |||
44 | ret = i2c_master_send(i2c, buf, bytes + 1); | ||
45 | if (ret < 0) | ||
46 | return ret; | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | int pm860x_reg_read(struct i2c_client *i2c, int reg) | 20 | int pm860x_reg_read(struct i2c_client *i2c, int reg) |
51 | { | 21 | { |
52 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); | 22 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); |
53 | unsigned char data; | 23 | struct regmap *map = (i2c == chip->client) ? chip->regmap |
24 | : chip->regmap_companion; | ||
25 | unsigned int data; | ||
54 | int ret; | 26 | int ret; |
55 | 27 | ||
56 | mutex_lock(&chip->io_lock); | 28 | ret = regmap_read(map, reg, &data); |
57 | ret = pm860x_read_device(i2c, reg, 1, &data); | ||
58 | mutex_unlock(&chip->io_lock); | ||
59 | |||
60 | if (ret < 0) | 29 | if (ret < 0) |
61 | return ret; | 30 | return ret; |
62 | else | 31 | else |
@@ -68,12 +37,11 @@ int pm860x_reg_write(struct i2c_client *i2c, int reg, | |||
68 | unsigned char data) | 37 | unsigned char data) |
69 | { | 38 | { |
70 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); | 39 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); |
40 | struct regmap *map = (i2c == chip->client) ? chip->regmap | ||
41 | : chip->regmap_companion; | ||
71 | int ret; | 42 | int ret; |
72 | 43 | ||
73 | mutex_lock(&chip->io_lock); | 44 | ret = regmap_write(map, reg, data); |
74 | ret = pm860x_write_device(i2c, reg, 1, &data); | ||
75 | mutex_unlock(&chip->io_lock); | ||
76 | |||
77 | return ret; | 45 | return ret; |
78 | } | 46 | } |
79 | EXPORT_SYMBOL(pm860x_reg_write); | 47 | EXPORT_SYMBOL(pm860x_reg_write); |
@@ -82,12 +50,11 @@ int pm860x_bulk_read(struct i2c_client *i2c, int reg, | |||
82 | int count, unsigned char *buf) | 50 | int count, unsigned char *buf) |
83 | { | 51 | { |
84 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); | 52 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); |
53 | struct regmap *map = (i2c == chip->client) ? chip->regmap | ||
54 | : chip->regmap_companion; | ||
85 | int ret; | 55 | int ret; |
86 | 56 | ||
87 | mutex_lock(&chip->io_lock); | 57 | ret = regmap_raw_read(map, reg, buf, count); |
88 | ret = pm860x_read_device(i2c, reg, count, buf); | ||
89 | mutex_unlock(&chip->io_lock); | ||
90 | |||
91 | return ret; | 58 | return ret; |
92 | } | 59 | } |
93 | EXPORT_SYMBOL(pm860x_bulk_read); | 60 | EXPORT_SYMBOL(pm860x_bulk_read); |
@@ -96,12 +63,11 @@ int pm860x_bulk_write(struct i2c_client *i2c, int reg, | |||
96 | int count, unsigned char *buf) | 63 | int count, unsigned char *buf) |
97 | { | 64 | { |
98 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); | 65 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); |
66 | struct regmap *map = (i2c == chip->client) ? chip->regmap | ||
67 | : chip->regmap_companion; | ||
99 | int ret; | 68 | int ret; |
100 | 69 | ||
101 | mutex_lock(&chip->io_lock); | 70 | ret = regmap_raw_write(map, reg, buf, count); |
102 | ret = pm860x_write_device(i2c, reg, count, buf); | ||
103 | mutex_unlock(&chip->io_lock); | ||
104 | |||
105 | return ret; | 71 | return ret; |
106 | } | 72 | } |
107 | EXPORT_SYMBOL(pm860x_bulk_write); | 73 | EXPORT_SYMBOL(pm860x_bulk_write); |
@@ -110,39 +76,78 @@ int pm860x_set_bits(struct i2c_client *i2c, int reg, | |||
110 | unsigned char mask, unsigned char data) | 76 | unsigned char mask, unsigned char data) |
111 | { | 77 | { |
112 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); | 78 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); |
113 | unsigned char value; | 79 | struct regmap *map = (i2c == chip->client) ? chip->regmap |
80 | : chip->regmap_companion; | ||
114 | int ret; | 81 | int ret; |
115 | 82 | ||
116 | mutex_lock(&chip->io_lock); | 83 | ret = regmap_update_bits(map, reg, mask, data); |
117 | ret = pm860x_read_device(i2c, reg, 1, &value); | ||
118 | if (ret < 0) | ||
119 | goto out; | ||
120 | value &= ~mask; | ||
121 | value |= data; | ||
122 | ret = pm860x_write_device(i2c, reg, 1, &value); | ||
123 | out: | ||
124 | mutex_unlock(&chip->io_lock); | ||
125 | return ret; | 84 | return ret; |
126 | } | 85 | } |
127 | EXPORT_SYMBOL(pm860x_set_bits); | 86 | EXPORT_SYMBOL(pm860x_set_bits); |
128 | 87 | ||
88 | static int read_device(struct i2c_client *i2c, int reg, | ||
89 | int bytes, void *dest) | ||
90 | { | ||
91 | unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX + 3]; | ||
92 | unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX + 2]; | ||
93 | struct i2c_adapter *adap = i2c->adapter; | ||
94 | struct i2c_msg msg[2] = {{i2c->addr, 0, 1, msgbuf0}, | ||
95 | {i2c->addr, I2C_M_RD, 0, msgbuf1}, | ||
96 | }; | ||
97 | int num = 1, ret = 0; | ||
98 | |||
99 | if (dest == NULL) | ||
100 | return -EINVAL; | ||
101 | msgbuf0[0] = (unsigned char)reg; /* command */ | ||
102 | msg[1].len = bytes; | ||
103 | |||
104 | /* if data needs to read back, num should be 2 */ | ||
105 | if (bytes > 0) | ||
106 | num = 2; | ||
107 | ret = adap->algo->master_xfer(adap, msg, num); | ||
108 | memcpy(dest, msgbuf1, bytes); | ||
109 | if (ret < 0) | ||
110 | return ret; | ||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | static int write_device(struct i2c_client *i2c, int reg, | ||
115 | int bytes, void *src) | ||
116 | { | ||
117 | unsigned char buf[bytes + 1]; | ||
118 | struct i2c_adapter *adap = i2c->adapter; | ||
119 | struct i2c_msg msg; | ||
120 | int ret; | ||
121 | |||
122 | buf[0] = (unsigned char)reg; | ||
123 | memcpy(&buf[1], src, bytes); | ||
124 | msg.addr = i2c->addr; | ||
125 | msg.flags = 0; | ||
126 | msg.len = bytes + 1; | ||
127 | msg.buf = buf; | ||
128 | |||
129 | ret = adap->algo->master_xfer(adap, &msg, 1); | ||
130 | if (ret < 0) | ||
131 | return ret; | ||
132 | return 0; | ||
133 | } | ||
134 | |||
129 | int pm860x_page_reg_read(struct i2c_client *i2c, int reg) | 135 | int pm860x_page_reg_read(struct i2c_client *i2c, int reg) |
130 | { | 136 | { |
131 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); | ||
132 | unsigned char zero = 0; | 137 | unsigned char zero = 0; |
133 | unsigned char data; | 138 | unsigned char data; |
134 | int ret; | 139 | int ret; |
135 | 140 | ||
136 | mutex_lock(&chip->io_lock); | 141 | i2c_lock_adapter(i2c->adapter); |
137 | pm860x_write_device(i2c, 0xFA, 0, &zero); | 142 | read_device(i2c, 0xFA, 0, &zero); |
138 | pm860x_write_device(i2c, 0xFB, 0, &zero); | 143 | read_device(i2c, 0xFB, 0, &zero); |
139 | pm860x_write_device(i2c, 0xFF, 0, &zero); | 144 | read_device(i2c, 0xFF, 0, &zero); |
140 | ret = pm860x_read_device(i2c, reg, 1, &data); | 145 | ret = read_device(i2c, reg, 1, &data); |
141 | if (ret >= 0) | 146 | if (ret >= 0) |
142 | ret = (int)data; | 147 | ret = (int)data; |
143 | pm860x_write_device(i2c, 0xFE, 0, &zero); | 148 | read_device(i2c, 0xFE, 0, &zero); |
144 | pm860x_write_device(i2c, 0xFC, 0, &zero); | 149 | read_device(i2c, 0xFC, 0, &zero); |
145 | mutex_unlock(&chip->io_lock); | 150 | i2c_unlock_adapter(i2c->adapter); |
146 | return ret; | 151 | return ret; |
147 | } | 152 | } |
148 | EXPORT_SYMBOL(pm860x_page_reg_read); | 153 | EXPORT_SYMBOL(pm860x_page_reg_read); |
@@ -150,18 +155,17 @@ EXPORT_SYMBOL(pm860x_page_reg_read); | |||
150 | int pm860x_page_reg_write(struct i2c_client *i2c, int reg, | 155 | int pm860x_page_reg_write(struct i2c_client *i2c, int reg, |
151 | unsigned char data) | 156 | unsigned char data) |
152 | { | 157 | { |
153 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); | ||
154 | unsigned char zero; | 158 | unsigned char zero; |
155 | int ret; | 159 | int ret; |
156 | 160 | ||
157 | mutex_lock(&chip->io_lock); | 161 | i2c_lock_adapter(i2c->adapter); |
158 | pm860x_write_device(i2c, 0xFA, 0, &zero); | 162 | read_device(i2c, 0xFA, 0, &zero); |
159 | pm860x_write_device(i2c, 0xFB, 0, &zero); | 163 | read_device(i2c, 0xFB, 0, &zero); |
160 | pm860x_write_device(i2c, 0xFF, 0, &zero); | 164 | read_device(i2c, 0xFF, 0, &zero); |
161 | ret = pm860x_write_device(i2c, reg, 1, &data); | 165 | ret = write_device(i2c, reg, 1, &data); |
162 | pm860x_write_device(i2c, 0xFE, 0, &zero); | 166 | read_device(i2c, 0xFE, 0, &zero); |
163 | pm860x_write_device(i2c, 0xFC, 0, &zero); | 167 | read_device(i2c, 0xFC, 0, &zero); |
164 | mutex_unlock(&chip->io_lock); | 168 | i2c_unlock_adapter(i2c->adapter); |
165 | return ret; | 169 | return ret; |
166 | } | 170 | } |
167 | EXPORT_SYMBOL(pm860x_page_reg_write); | 171 | EXPORT_SYMBOL(pm860x_page_reg_write); |
@@ -169,18 +173,17 @@ EXPORT_SYMBOL(pm860x_page_reg_write); | |||
169 | int pm860x_page_bulk_read(struct i2c_client *i2c, int reg, | 173 | int pm860x_page_bulk_read(struct i2c_client *i2c, int reg, |
170 | int count, unsigned char *buf) | 174 | int count, unsigned char *buf) |
171 | { | 175 | { |
172 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); | ||
173 | unsigned char zero = 0; | 176 | unsigned char zero = 0; |
174 | int ret; | 177 | int ret; |
175 | 178 | ||
176 | mutex_lock(&chip->io_lock); | 179 | i2c_lock_adapter(i2c->adapter); |
177 | pm860x_write_device(i2c, 0xFA, 0, &zero); | 180 | read_device(i2c, 0xfa, 0, &zero); |
178 | pm860x_write_device(i2c, 0xFB, 0, &zero); | 181 | read_device(i2c, 0xfb, 0, &zero); |
179 | pm860x_write_device(i2c, 0xFF, 0, &zero); | 182 | read_device(i2c, 0xff, 0, &zero); |
180 | ret = pm860x_read_device(i2c, reg, count, buf); | 183 | ret = read_device(i2c, reg, count, buf); |
181 | pm860x_write_device(i2c, 0xFE, 0, &zero); | 184 | read_device(i2c, 0xFE, 0, &zero); |
182 | pm860x_write_device(i2c, 0xFC, 0, &zero); | 185 | read_device(i2c, 0xFC, 0, &zero); |
183 | mutex_unlock(&chip->io_lock); | 186 | i2c_unlock_adapter(i2c->adapter); |
184 | return ret; | 187 | return ret; |
185 | } | 188 | } |
186 | EXPORT_SYMBOL(pm860x_page_bulk_read); | 189 | EXPORT_SYMBOL(pm860x_page_bulk_read); |
@@ -188,18 +191,18 @@ EXPORT_SYMBOL(pm860x_page_bulk_read); | |||
188 | int pm860x_page_bulk_write(struct i2c_client *i2c, int reg, | 191 | int pm860x_page_bulk_write(struct i2c_client *i2c, int reg, |
189 | int count, unsigned char *buf) | 192 | int count, unsigned char *buf) |
190 | { | 193 | { |
191 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); | ||
192 | unsigned char zero = 0; | 194 | unsigned char zero = 0; |
193 | int ret; | 195 | int ret; |
194 | 196 | ||
195 | mutex_lock(&chip->io_lock); | 197 | i2c_lock_adapter(i2c->adapter); |
196 | pm860x_write_device(i2c, 0xFA, 0, &zero); | 198 | read_device(i2c, 0xFA, 0, &zero); |
197 | pm860x_write_device(i2c, 0xFB, 0, &zero); | 199 | read_device(i2c, 0xFB, 0, &zero); |
198 | pm860x_write_device(i2c, 0xFF, 0, &zero); | 200 | read_device(i2c, 0xFF, 0, &zero); |
199 | ret = pm860x_write_device(i2c, reg, count, buf); | 201 | ret = write_device(i2c, reg, count, buf); |
200 | pm860x_write_device(i2c, 0xFE, 0, &zero); | 202 | read_device(i2c, 0xFE, 0, &zero); |
201 | pm860x_write_device(i2c, 0xFC, 0, &zero); | 203 | read_device(i2c, 0xFC, 0, &zero); |
202 | mutex_unlock(&chip->io_lock); | 204 | i2c_unlock_adapter(i2c->adapter); |
205 | i2c_unlock_adapter(i2c->adapter); | ||
203 | return ret; | 206 | return ret; |
204 | } | 207 | } |
205 | EXPORT_SYMBOL(pm860x_page_bulk_write); | 208 | EXPORT_SYMBOL(pm860x_page_bulk_write); |
@@ -207,25 +210,24 @@ EXPORT_SYMBOL(pm860x_page_bulk_write); | |||
207 | int pm860x_page_set_bits(struct i2c_client *i2c, int reg, | 210 | int pm860x_page_set_bits(struct i2c_client *i2c, int reg, |
208 | unsigned char mask, unsigned char data) | 211 | unsigned char mask, unsigned char data) |
209 | { | 212 | { |
210 | struct pm860x_chip *chip = i2c_get_clientdata(i2c); | ||
211 | unsigned char zero; | 213 | unsigned char zero; |
212 | unsigned char value; | 214 | unsigned char value; |
213 | int ret; | 215 | int ret; |
214 | 216 | ||
215 | mutex_lock(&chip->io_lock); | 217 | i2c_lock_adapter(i2c->adapter); |
216 | pm860x_write_device(i2c, 0xFA, 0, &zero); | 218 | read_device(i2c, 0xFA, 0, &zero); |
217 | pm860x_write_device(i2c, 0xFB, 0, &zero); | 219 | read_device(i2c, 0xFB, 0, &zero); |
218 | pm860x_write_device(i2c, 0xFF, 0, &zero); | 220 | read_device(i2c, 0xFF, 0, &zero); |
219 | ret = pm860x_read_device(i2c, reg, 1, &value); | 221 | ret = read_device(i2c, reg, 1, &value); |
220 | if (ret < 0) | 222 | if (ret < 0) |
221 | goto out; | 223 | goto out; |
222 | value &= ~mask; | 224 | value &= ~mask; |
223 | value |= data; | 225 | value |= data; |
224 | ret = pm860x_write_device(i2c, reg, 1, &value); | 226 | ret = write_device(i2c, reg, 1, &value); |
225 | out: | 227 | out: |
226 | pm860x_write_device(i2c, 0xFE, 0, &zero); | 228 | read_device(i2c, 0xFE, 0, &zero); |
227 | pm860x_write_device(i2c, 0xFC, 0, &zero); | 229 | read_device(i2c, 0xFC, 0, &zero); |
228 | mutex_unlock(&chip->io_lock); | 230 | i2c_unlock_adapter(i2c->adapter); |
229 | return ret; | 231 | return ret; |
230 | } | 232 | } |
231 | EXPORT_SYMBOL(pm860x_page_set_bits); | 233 | EXPORT_SYMBOL(pm860x_page_set_bits); |
@@ -257,11 +259,17 @@ static int verify_addr(struct i2c_client *i2c) | |||
257 | return 0; | 259 | return 0; |
258 | } | 260 | } |
259 | 261 | ||
262 | static struct regmap_config pm860x_regmap_config = { | ||
263 | .reg_bits = 8, | ||
264 | .val_bits = 8, | ||
265 | }; | ||
266 | |||
260 | static int __devinit pm860x_probe(struct i2c_client *client, | 267 | static int __devinit pm860x_probe(struct i2c_client *client, |
261 | const struct i2c_device_id *id) | 268 | const struct i2c_device_id *id) |
262 | { | 269 | { |
263 | struct pm860x_platform_data *pdata = client->dev.platform_data; | 270 | struct pm860x_platform_data *pdata = client->dev.platform_data; |
264 | struct pm860x_chip *chip; | 271 | struct pm860x_chip *chip; |
272 | int ret; | ||
265 | 273 | ||
266 | if (!pdata) { | 274 | if (!pdata) { |
267 | pr_info("No platform data in %s!\n", __func__); | 275 | pr_info("No platform data in %s!\n", __func__); |
@@ -273,10 +281,17 @@ static int __devinit pm860x_probe(struct i2c_client *client, | |||
273 | return -ENOMEM; | 281 | return -ENOMEM; |
274 | 282 | ||
275 | chip->id = verify_addr(client); | 283 | chip->id = verify_addr(client); |
284 | chip->regmap = regmap_init_i2c(client, &pm860x_regmap_config); | ||
285 | if (IS_ERR(chip->regmap)) { | ||
286 | ret = PTR_ERR(chip->regmap); | ||
287 | dev_err(&client->dev, "Failed to allocate register map: %d\n", | ||
288 | ret); | ||
289 | kfree(chip); | ||
290 | return ret; | ||
291 | } | ||
276 | chip->client = client; | 292 | chip->client = client; |
277 | i2c_set_clientdata(client, chip); | 293 | i2c_set_clientdata(client, chip); |
278 | chip->dev = &client->dev; | 294 | chip->dev = &client->dev; |
279 | mutex_init(&chip->io_lock); | ||
280 | dev_set_drvdata(chip->dev, chip); | 295 | dev_set_drvdata(chip->dev, chip); |
281 | 296 | ||
282 | /* | 297 | /* |
@@ -290,6 +305,14 @@ static int __devinit pm860x_probe(struct i2c_client *client, | |||
290 | chip->companion_addr = pdata->companion_addr; | 305 | chip->companion_addr = pdata->companion_addr; |
291 | chip->companion = i2c_new_dummy(chip->client->adapter, | 306 | chip->companion = i2c_new_dummy(chip->client->adapter, |
292 | chip->companion_addr); | 307 | chip->companion_addr); |
308 | chip->regmap_companion = regmap_init_i2c(chip->companion, | ||
309 | &pm860x_regmap_config); | ||
310 | if (IS_ERR(chip->regmap_companion)) { | ||
311 | ret = PTR_ERR(chip->regmap_companion); | ||
312 | dev_err(&chip->companion->dev, | ||
313 | "Failed to allocate register map: %d\n", ret); | ||
314 | return ret; | ||
315 | } | ||
293 | i2c_set_clientdata(chip->companion, chip); | 316 | i2c_set_clientdata(chip->companion, chip); |
294 | } | 317 | } |
295 | 318 | ||
@@ -302,7 +325,11 @@ static int __devexit pm860x_remove(struct i2c_client *client) | |||
302 | struct pm860x_chip *chip = i2c_get_clientdata(client); | 325 | struct pm860x_chip *chip = i2c_get_clientdata(client); |
303 | 326 | ||
304 | pm860x_device_exit(chip); | 327 | pm860x_device_exit(chip); |
305 | i2c_unregister_device(chip->companion); | 328 | if (chip->companion) { |
329 | regmap_exit(chip->regmap_companion); | ||
330 | i2c_unregister_device(chip->companion); | ||
331 | } | ||
332 | regmap_exit(chip->regmap); | ||
306 | kfree(chip); | 333 | kfree(chip); |
307 | return 0; | 334 | return 0; |
308 | } | 335 | } |
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 053208d31fb9..cd13e9f2f5e6 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -12,6 +12,7 @@ config MFD_CORE | |||
12 | config MFD_88PM860X | 12 | config MFD_88PM860X |
13 | bool "Support Marvell 88PM8606/88PM8607" | 13 | bool "Support Marvell 88PM8606/88PM8607" |
14 | depends on I2C=y && GENERIC_HARDIRQS | 14 | depends on I2C=y && GENERIC_HARDIRQS |
15 | select REGMAP_I2C | ||
15 | select MFD_CORE | 16 | select MFD_CORE |
16 | help | 17 | help |
17 | This supports for Marvell 88PM8606/88PM8607 Power Management IC. | 18 | This supports for Marvell 88PM8606/88PM8607 Power Management IC. |
@@ -199,7 +200,7 @@ config MENELAUS | |||
199 | 200 | ||
200 | config TWL4030_CORE | 201 | config TWL4030_CORE |
201 | bool "Texas Instruments TWL4030/TWL5030/TWL6030/TPS659x0 Support" | 202 | bool "Texas Instruments TWL4030/TWL5030/TWL6030/TPS659x0 Support" |
202 | depends on I2C=y && GENERIC_HARDIRQS | 203 | depends on I2C=y && GENERIC_HARDIRQS && IRQ_DOMAIN |
203 | help | 204 | help |
204 | Say yes here if you have TWL4030 / TWL6030 family chip on your board. | 205 | Say yes here if you have TWL4030 / TWL6030 family chip on your board. |
205 | This core driver provides register access and IRQ handling | 206 | This core driver provides register access and IRQ handling |
@@ -257,7 +258,7 @@ config TWL6040_CORE | |||
257 | 258 | ||
258 | config MFD_STMPE | 259 | config MFD_STMPE |
259 | bool "Support STMicroelectronics STMPE" | 260 | bool "Support STMicroelectronics STMPE" |
260 | depends on I2C=y && GENERIC_HARDIRQS | 261 | depends on (I2C=y || SPI_MASTER=y) && GENERIC_HARDIRQS |
261 | select MFD_CORE | 262 | select MFD_CORE |
262 | help | 263 | help |
263 | Support for the STMPE family of I/O Expanders from | 264 | Support for the STMPE family of I/O Expanders from |
@@ -278,6 +279,23 @@ config MFD_STMPE | |||
278 | Keypad: stmpe-keypad | 279 | Keypad: stmpe-keypad |
279 | Touchscreen: stmpe-ts | 280 | Touchscreen: stmpe-ts |
280 | 281 | ||
282 | menu "STMPE Interface Drivers" | ||
283 | depends on MFD_STMPE | ||
284 | |||
285 | config STMPE_I2C | ||
286 | bool "STMPE I2C Inteface" | ||
287 | depends on I2C=y | ||
288 | default y | ||
289 | help | ||
290 | This is used to enable I2C interface of STMPE | ||
291 | |||
292 | config STMPE_SPI | ||
293 | bool "STMPE SPI Inteface" | ||
294 | depends on SPI_MASTER | ||
295 | help | ||
296 | This is used to enable SPI interface of STMPE | ||
297 | endmenu | ||
298 | |||
281 | config MFD_TC3589X | 299 | config MFD_TC3589X |
282 | bool "Support Toshiba TC35892 and variants" | 300 | bool "Support Toshiba TC35892 and variants" |
283 | depends on I2C=y && GENERIC_HARDIRQS | 301 | depends on I2C=y && GENERIC_HARDIRQS |
@@ -311,7 +329,7 @@ config MFD_TC6387XB | |||
311 | 329 | ||
312 | config MFD_TC6393XB | 330 | config MFD_TC6393XB |
313 | bool "Support Toshiba TC6393XB" | 331 | bool "Support Toshiba TC6393XB" |
314 | depends on GPIOLIB && ARM | 332 | depends on GPIOLIB && ARM && HAVE_CLK |
315 | select MFD_CORE | 333 | select MFD_CORE |
316 | select MFD_TMIO | 334 | select MFD_TMIO |
317 | help | 335 | help |
@@ -399,6 +417,17 @@ config MFD_MAX8998 | |||
399 | additional drivers must be enabled in order to use the functionality | 417 | additional drivers must be enabled in order to use the functionality |
400 | of the device. | 418 | of the device. |
401 | 419 | ||
420 | config MFD_S5M_CORE | ||
421 | bool "SAMSUNG S5M Series Support" | ||
422 | depends on I2C=y && GENERIC_HARDIRQS | ||
423 | select MFD_CORE | ||
424 | select REGMAP_I2C | ||
425 | help | ||
426 | Support for the Samsung Electronics S5M MFD series. | ||
427 | This driver provies common support for accessing the device, | ||
428 | additional drivers must be enabled in order to use the functionality | ||
429 | of the device | ||
430 | |||
402 | config MFD_WM8400 | 431 | config MFD_WM8400 |
403 | tristate "Support Wolfson Microelectronics WM8400" | 432 | tristate "Support Wolfson Microelectronics WM8400" |
404 | select MFD_CORE | 433 | select MFD_CORE |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 47591fc7d0d2..b953bab934f7 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -16,6 +16,8 @@ obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o | |||
16 | obj-$(CONFIG_MFD_TI_SSP) += ti-ssp.o | 16 | obj-$(CONFIG_MFD_TI_SSP) += ti-ssp.o |
17 | 17 | ||
18 | obj-$(CONFIG_MFD_STMPE) += stmpe.o | 18 | obj-$(CONFIG_MFD_STMPE) += stmpe.o |
19 | obj-$(CONFIG_STMPE_I2C) += stmpe-i2c.o | ||
20 | obj-$(CONFIG_STMPE_SPI) += stmpe-spi.o | ||
19 | obj-$(CONFIG_MFD_TC3589X) += tc3589x.o | 21 | obj-$(CONFIG_MFD_TC3589X) += tc3589x.o |
20 | obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o | 22 | obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o |
21 | obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o tmio_core.o | 23 | obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o tmio_core.o |
@@ -109,3 +111,4 @@ obj-$(CONFIG_MFD_PM8XXX_IRQ) += pm8xxx-irq.o | |||
109 | obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o | 111 | obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o |
110 | obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o | 112 | obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o |
111 | obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o | 113 | obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o |
114 | obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o | ||
diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c index 02c42015ba51..3aa36eb5c79b 100644 --- a/drivers/mfd/aat2870-core.c +++ b/drivers/mfd/aat2870-core.c | |||
@@ -407,13 +407,13 @@ static int aat2870_i2c_probe(struct i2c_client *client, | |||
407 | aat2870->init(aat2870); | 407 | aat2870->init(aat2870); |
408 | 408 | ||
409 | if (aat2870->en_pin >= 0) { | 409 | if (aat2870->en_pin >= 0) { |
410 | ret = gpio_request(aat2870->en_pin, "aat2870-en"); | 410 | ret = gpio_request_one(aat2870->en_pin, GPIOF_OUT_INIT_HIGH, |
411 | "aat2870-en"); | ||
411 | if (ret < 0) { | 412 | if (ret < 0) { |
412 | dev_err(&client->dev, | 413 | dev_err(&client->dev, |
413 | "Failed to request GPIO %d\n", aat2870->en_pin); | 414 | "Failed to request GPIO %d\n", aat2870->en_pin); |
414 | goto out_kfree; | 415 | goto out_kfree; |
415 | } | 416 | } |
416 | gpio_direction_output(aat2870->en_pin, 1); | ||
417 | } | 417 | } |
418 | 418 | ||
419 | aat2870_enable(aat2870); | 419 | aat2870_enable(aat2870); |
@@ -468,9 +468,10 @@ static int aat2870_i2c_remove(struct i2c_client *client) | |||
468 | return 0; | 468 | return 0; |
469 | } | 469 | } |
470 | 470 | ||
471 | #ifdef CONFIG_PM | 471 | #ifdef CONFIG_PM_SLEEP |
472 | static int aat2870_i2c_suspend(struct i2c_client *client, pm_message_t state) | 472 | static int aat2870_i2c_suspend(struct device *dev) |
473 | { | 473 | { |
474 | struct i2c_client *client = to_i2c_client(dev); | ||
474 | struct aat2870_data *aat2870 = i2c_get_clientdata(client); | 475 | struct aat2870_data *aat2870 = i2c_get_clientdata(client); |
475 | 476 | ||
476 | aat2870_disable(aat2870); | 477 | aat2870_disable(aat2870); |
@@ -478,8 +479,9 @@ static int aat2870_i2c_suspend(struct i2c_client *client, pm_message_t state) | |||
478 | return 0; | 479 | return 0; |
479 | } | 480 | } |
480 | 481 | ||
481 | static int aat2870_i2c_resume(struct i2c_client *client) | 482 | static int aat2870_i2c_resume(struct device *dev) |
482 | { | 483 | { |
484 | struct i2c_client *client = to_i2c_client(dev); | ||
483 | struct aat2870_data *aat2870 = i2c_get_clientdata(client); | 485 | struct aat2870_data *aat2870 = i2c_get_clientdata(client); |
484 | struct aat2870_register *reg = NULL; | 486 | struct aat2870_register *reg = NULL; |
485 | int i; | 487 | int i; |
@@ -495,12 +497,12 @@ static int aat2870_i2c_resume(struct i2c_client *client) | |||
495 | 497 | ||
496 | return 0; | 498 | return 0; |
497 | } | 499 | } |
498 | #else | 500 | #endif /* CONFIG_PM_SLEEP */ |
499 | #define aat2870_i2c_suspend NULL | 501 | |
500 | #define aat2870_i2c_resume NULL | 502 | static SIMPLE_DEV_PM_OPS(aat2870_pm_ops, aat2870_i2c_suspend, |
501 | #endif /* CONFIG_PM */ | 503 | aat2870_i2c_resume); |
502 | 504 | ||
503 | static struct i2c_device_id aat2870_i2c_id_table[] = { | 505 | static const struct i2c_device_id aat2870_i2c_id_table[] = { |
504 | { "aat2870", 0 }, | 506 | { "aat2870", 0 }, |
505 | { } | 507 | { } |
506 | }; | 508 | }; |
@@ -510,11 +512,10 @@ static struct i2c_driver aat2870_i2c_driver = { | |||
510 | .driver = { | 512 | .driver = { |
511 | .name = "aat2870", | 513 | .name = "aat2870", |
512 | .owner = THIS_MODULE, | 514 | .owner = THIS_MODULE, |
515 | .pm = &aat2870_pm_ops, | ||
513 | }, | 516 | }, |
514 | .probe = aat2870_i2c_probe, | 517 | .probe = aat2870_i2c_probe, |
515 | .remove = aat2870_i2c_remove, | 518 | .remove = aat2870_i2c_remove, |
516 | .suspend = aat2870_i2c_suspend, | ||
517 | .resume = aat2870_i2c_resume, | ||
518 | .id_table = aat2870_i2c_id_table, | 519 | .id_table = aat2870_i2c_id_table, |
519 | }; | 520 | }; |
520 | 521 | ||
diff --git a/drivers/mfd/ab5500-core.c b/drivers/mfd/ab5500-core.c index ec10629a0b0b..bd56a764dea1 100644 --- a/drivers/mfd/ab5500-core.c +++ b/drivers/mfd/ab5500-core.c | |||
@@ -22,8 +22,8 @@ | |||
22 | #include <linux/irq.h> | 22 | #include <linux/irq.h> |
23 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
24 | #include <linux/random.h> | 24 | #include <linux/random.h> |
25 | #include <linux/mfd/ab5500/ab5500.h> | ||
26 | #include <linux/mfd/abx500.h> | 25 | #include <linux/mfd/abx500.h> |
26 | #include <linux/mfd/abx500/ab5500.h> | ||
27 | #include <linux/list.h> | 27 | #include <linux/list.h> |
28 | #include <linux/bitops.h> | 28 | #include <linux/bitops.h> |
29 | #include <linux/spinlock.h> | 29 | #include <linux/spinlock.h> |
diff --git a/drivers/mfd/ab5500-debugfs.c b/drivers/mfd/ab5500-debugfs.c index b7b2d3483fd4..72006940937a 100644 --- a/drivers/mfd/ab5500-debugfs.c +++ b/drivers/mfd/ab5500-debugfs.c | |||
@@ -7,8 +7,8 @@ | |||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/debugfs.h> | 8 | #include <linux/debugfs.h> |
9 | #include <linux/seq_file.h> | 9 | #include <linux/seq_file.h> |
10 | #include <linux/mfd/ab5500/ab5500.h> | ||
11 | #include <linux/mfd/abx500.h> | 10 | #include <linux/mfd/abx500.h> |
11 | #include <linux/mfd/abx500/ab5500.h> | ||
12 | #include <linux/uaccess.h> | 12 | #include <linux/uaccess.h> |
13 | 13 | ||
14 | #include "ab5500-core.h" | 14 | #include "ab5500-core.h" |
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index d3d572b2317b..53e2a80f42fa 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/mfd/core.h> | 18 | #include <linux/mfd/core.h> |
19 | #include <linux/mfd/abx500.h> | 19 | #include <linux/mfd/abx500.h> |
20 | #include <linux/mfd/ab8500.h> | 20 | #include <linux/mfd/abx500/ab8500.h> |
21 | #include <linux/regulator/ab8500.h> | 21 | #include <linux/regulator/ab8500.h> |
22 | 22 | ||
23 | /* | 23 | /* |
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index dedb7f65cea6..9a0211aa8897 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | 14 | ||
15 | #include <linux/mfd/abx500.h> | 15 | #include <linux/mfd/abx500.h> |
16 | #include <linux/mfd/ab8500.h> | 16 | #include <linux/mfd/abx500/ab8500.h> |
17 | 17 | ||
18 | static u32 debug_bank; | 18 | static u32 debug_bank; |
19 | static u32 debug_address; | 19 | static u32 debug_address; |
diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c index e985d1701a83..c39fc716e1dc 100644 --- a/drivers/mfd/ab8500-gpadc.c +++ b/drivers/mfd/ab8500-gpadc.c | |||
@@ -18,9 +18,9 @@ | |||
18 | #include <linux/err.h> | 18 | #include <linux/err.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/list.h> | 20 | #include <linux/list.h> |
21 | #include <linux/mfd/ab8500.h> | ||
22 | #include <linux/mfd/abx500.h> | 21 | #include <linux/mfd/abx500.h> |
23 | #include <linux/mfd/ab8500/gpadc.h> | 22 | #include <linux/mfd/abx500/ab8500.h> |
23 | #include <linux/mfd/abx500/ab8500-gpadc.h> | ||
24 | 24 | ||
25 | /* | 25 | /* |
26 | * GPADC register offsets | 26 | * GPADC register offsets |
diff --git a/drivers/mfd/ab8500-i2c.c b/drivers/mfd/ab8500-i2c.c index 9be541c6b004..087fecd71ce0 100644 --- a/drivers/mfd/ab8500-i2c.c +++ b/drivers/mfd/ab8500-i2c.c | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/platform_device.h> | 12 | #include <linux/platform_device.h> |
13 | #include <linux/mfd/ab8500.h> | 13 | #include <linux/mfd/abx500/ab8500.h> |
14 | #include <linux/mfd/db8500-prcmu.h> | 14 | #include <linux/mfd/db8500-prcmu.h> |
15 | 15 | ||
16 | static int ab8500_i2c_write(struct ab8500 *ab8500, u16 addr, u8 data) | 16 | static int ab8500_i2c_write(struct ab8500 *ab8500, u16 addr, u8 data) |
diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c index f20feefac190..c28d4eb1eff0 100644 --- a/drivers/mfd/ab8500-sysctrl.c +++ b/drivers/mfd/ab8500-sysctrl.c | |||
@@ -7,9 +7,9 @@ | |||
7 | #include <linux/err.h> | 7 | #include <linux/err.h> |
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/platform_device.h> | 9 | #include <linux/platform_device.h> |
10 | #include <linux/mfd/ab8500.h> | ||
11 | #include <linux/mfd/abx500.h> | 10 | #include <linux/mfd/abx500.h> |
12 | #include <linux/mfd/ab8500/sysctrl.h> | 11 | #include <linux/mfd/abx500/ab8500.h> |
12 | #include <linux/mfd/abx500/ab8500-sysctrl.h> | ||
13 | 13 | ||
14 | static struct device *sysctrl_dev; | 14 | static struct device *sysctrl_dev; |
15 | 15 | ||
diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index 155fa0407882..315fef5d466a 100644 --- a/drivers/mfd/cs5535-mfd.c +++ b/drivers/mfd/cs5535-mfd.c | |||
@@ -172,14 +172,14 @@ static void __devexit cs5535_mfd_remove(struct pci_dev *pdev) | |||
172 | pci_disable_device(pdev); | 172 | pci_disable_device(pdev); |
173 | } | 173 | } |
174 | 174 | ||
175 | static struct pci_device_id cs5535_mfd_pci_tbl[] = { | 175 | static DEFINE_PCI_DEVICE_TABLE(cs5535_mfd_pci_tbl) = { |
176 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, | 176 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, |
177 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, | 177 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, |
178 | { 0, } | 178 | { 0, } |
179 | }; | 179 | }; |
180 | MODULE_DEVICE_TABLE(pci, cs5535_mfd_pci_tbl); | 180 | MODULE_DEVICE_TABLE(pci, cs5535_mfd_pci_tbl); |
181 | 181 | ||
182 | static struct pci_driver cs5535_mfd_drv = { | 182 | static struct pci_driver cs5535_mfd_driver = { |
183 | .name = DRV_NAME, | 183 | .name = DRV_NAME, |
184 | .id_table = cs5535_mfd_pci_tbl, | 184 | .id_table = cs5535_mfd_pci_tbl, |
185 | .probe = cs5535_mfd_probe, | 185 | .probe = cs5535_mfd_probe, |
@@ -188,12 +188,12 @@ static struct pci_driver cs5535_mfd_drv = { | |||
188 | 188 | ||
189 | static int __init cs5535_mfd_init(void) | 189 | static int __init cs5535_mfd_init(void) |
190 | { | 190 | { |
191 | return pci_register_driver(&cs5535_mfd_drv); | 191 | return pci_register_driver(&cs5535_mfd_driver); |
192 | } | 192 | } |
193 | 193 | ||
194 | static void __exit cs5535_mfd_exit(void) | 194 | static void __exit cs5535_mfd_exit(void) |
195 | { | 195 | { |
196 | pci_unregister_driver(&cs5535_mfd_drv); | 196 | pci_unregister_driver(&cs5535_mfd_driver); |
197 | } | 197 | } |
198 | 198 | ||
199 | module_init(cs5535_mfd_init); | 199 | module_init(cs5535_mfd_init); |
diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c index 8ad88da647b9..7710227d284e 100644 --- a/drivers/mfd/dm355evm_msp.c +++ b/drivers/mfd/dm355evm_msp.c | |||
@@ -308,8 +308,7 @@ static int add_children(struct i2c_client *client) | |||
308 | for (i = 0; i < ARRAY_SIZE(config_inputs); i++) { | 308 | for (i = 0; i < ARRAY_SIZE(config_inputs); i++) { |
309 | int gpio = dm355evm_msp_gpio.base + config_inputs[i].offset; | 309 | int gpio = dm355evm_msp_gpio.base + config_inputs[i].offset; |
310 | 310 | ||
311 | gpio_request(gpio, config_inputs[i].label); | 311 | gpio_request_one(gpio, GPIOF_IN, config_inputs[i].label); |
312 | gpio_direction_input(gpio); | ||
313 | 312 | ||
314 | /* make it easy for userspace to see these */ | 313 | /* make it easy for userspace to see these */ |
315 | gpio_export(gpio, false); | 314 | gpio_export(gpio, false); |
diff --git a/drivers/mfd/intel_msic.c b/drivers/mfd/intel_msic.c index 97c27762174f..b76657eb0c51 100644 --- a/drivers/mfd/intel_msic.c +++ b/drivers/mfd/intel_msic.c | |||
@@ -485,17 +485,7 @@ static struct platform_driver intel_msic_driver = { | |||
485 | }, | 485 | }, |
486 | }; | 486 | }; |
487 | 487 | ||
488 | static int __init intel_msic_init(void) | 488 | module_platform_driver(intel_msic_driver); |
489 | { | ||
490 | return platform_driver_register(&intel_msic_driver); | ||
491 | } | ||
492 | module_init(intel_msic_init); | ||
493 | |||
494 | static void __exit intel_msic_exit(void) | ||
495 | { | ||
496 | platform_driver_unregister(&intel_msic_driver); | ||
497 | } | ||
498 | module_exit(intel_msic_exit); | ||
499 | 489 | ||
500 | MODULE_DESCRIPTION("Driver for Intel MSIC"); | 490 | MODULE_DESCRIPTION("Driver for Intel MSIC"); |
501 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); | 491 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); |
diff --git a/drivers/mfd/jz4740-adc.c b/drivers/mfd/jz4740-adc.c index ef39528088f2..87662a17dec6 100644 --- a/drivers/mfd/jz4740-adc.c +++ b/drivers/mfd/jz4740-adc.c | |||
@@ -181,7 +181,7 @@ static struct resource jz4740_battery_resources[] = { | |||
181 | }, | 181 | }, |
182 | }; | 182 | }; |
183 | 183 | ||
184 | const struct mfd_cell jz4740_adc_cells[] = { | 184 | static struct mfd_cell jz4740_adc_cells[] = { |
185 | { | 185 | { |
186 | .id = 0, | 186 | .id = 0, |
187 | .name = "jz4740-hwmon", | 187 | .name = "jz4740-hwmon", |
@@ -338,17 +338,7 @@ static struct platform_driver jz4740_adc_driver = { | |||
338 | }, | 338 | }, |
339 | }; | 339 | }; |
340 | 340 | ||
341 | static int __init jz4740_adc_init(void) | 341 | module_platform_driver(jz4740_adc_driver); |
342 | { | ||
343 | return platform_driver_register(&jz4740_adc_driver); | ||
344 | } | ||
345 | module_init(jz4740_adc_init); | ||
346 | |||
347 | static void __exit jz4740_adc_exit(void) | ||
348 | { | ||
349 | platform_driver_unregister(&jz4740_adc_driver); | ||
350 | } | ||
351 | module_exit(jz4740_adc_exit); | ||
352 | 342 | ||
353 | MODULE_DESCRIPTION("JZ4740 SoC ADC driver"); | 343 | MODULE_DESCRIPTION("JZ4740 SoC ADC driver"); |
354 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | 344 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); |
diff --git a/drivers/mfd/lpc_sch.c b/drivers/mfd/lpc_sch.c index ea1169b04779..abc421364a45 100644 --- a/drivers/mfd/lpc_sch.c +++ b/drivers/mfd/lpc_sch.c | |||
@@ -74,7 +74,7 @@ static struct mfd_cell tunnelcreek_cells[] = { | |||
74 | }, | 74 | }, |
75 | }; | 75 | }; |
76 | 76 | ||
77 | static struct pci_device_id lpc_sch_ids[] = { | 77 | static DEFINE_PCI_DEVICE_TABLE(lpc_sch_ids) = { |
78 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, | 78 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, |
79 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ITC_LPC) }, | 79 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ITC_LPC) }, |
80 | { 0, } | 80 | { 0, } |
diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c index 0219115e00c7..d9e4b36edee9 100644 --- a/drivers/mfd/max8925-i2c.c +++ b/drivers/mfd/max8925-i2c.c | |||
@@ -161,6 +161,8 @@ static int __devinit max8925_probe(struct i2c_client *client, | |||
161 | chip->adc = i2c_new_dummy(chip->i2c->adapter, ADC_I2C_ADDR); | 161 | chip->adc = i2c_new_dummy(chip->i2c->adapter, ADC_I2C_ADDR); |
162 | i2c_set_clientdata(chip->adc, chip); | 162 | i2c_set_clientdata(chip->adc, chip); |
163 | 163 | ||
164 | device_init_wakeup(&client->dev, 1); | ||
165 | |||
164 | max8925_device_init(chip, pdata); | 166 | max8925_device_init(chip, pdata); |
165 | 167 | ||
166 | return 0; | 168 | return 0; |
@@ -177,10 +179,35 @@ static int __devexit max8925_remove(struct i2c_client *client) | |||
177 | return 0; | 179 | return 0; |
178 | } | 180 | } |
179 | 181 | ||
182 | #ifdef CONFIG_PM_SLEEP | ||
183 | static int max8925_suspend(struct device *dev) | ||
184 | { | ||
185 | struct i2c_client *client = container_of(dev, struct i2c_client, dev); | ||
186 | struct max8925_chip *chip = i2c_get_clientdata(client); | ||
187 | |||
188 | if (device_may_wakeup(dev) && chip->wakeup_flag) | ||
189 | enable_irq_wake(chip->core_irq); | ||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | static int max8925_resume(struct device *dev) | ||
194 | { | ||
195 | struct i2c_client *client = container_of(dev, struct i2c_client, dev); | ||
196 | struct max8925_chip *chip = i2c_get_clientdata(client); | ||
197 | |||
198 | if (device_may_wakeup(dev) && chip->wakeup_flag) | ||
199 | disable_irq_wake(chip->core_irq); | ||
200 | return 0; | ||
201 | } | ||
202 | #endif | ||
203 | |||
204 | static SIMPLE_DEV_PM_OPS(max8925_pm_ops, max8925_suspend, max8925_resume); | ||
205 | |||
180 | static struct i2c_driver max8925_driver = { | 206 | static struct i2c_driver max8925_driver = { |
181 | .driver = { | 207 | .driver = { |
182 | .name = "max8925", | 208 | .name = "max8925", |
183 | .owner = THIS_MODULE, | 209 | .owner = THIS_MODULE, |
210 | .pm = &max8925_pm_ops, | ||
184 | }, | 211 | }, |
185 | .probe = max8925_probe, | 212 | .probe = max8925_probe, |
186 | .remove = __devexit_p(max8925_remove), | 213 | .remove = __devexit_p(max8925_remove), |
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c index 5be53ae9b61c..cb83a7ab53e7 100644 --- a/drivers/mfd/max8997.c +++ b/drivers/mfd/max8997.c | |||
@@ -43,7 +43,8 @@ static struct mfd_cell max8997_devs[] = { | |||
43 | { .name = "max8997-battery", }, | 43 | { .name = "max8997-battery", }, |
44 | { .name = "max8997-haptic", }, | 44 | { .name = "max8997-haptic", }, |
45 | { .name = "max8997-muic", }, | 45 | { .name = "max8997-muic", }, |
46 | { .name = "max8997-flash", }, | 46 | { .name = "max8997-led", .id = 1 }, |
47 | { .name = "max8997-led", .id = 2 }, | ||
47 | }; | 48 | }; |
48 | 49 | ||
49 | int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest) | 50 | int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest) |
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c index de4096aee248..6ef56d28c056 100644 --- a/drivers/mfd/max8998.c +++ b/drivers/mfd/max8998.c | |||
@@ -176,6 +176,8 @@ static int max8998_i2c_probe(struct i2c_client *i2c, | |||
176 | if (ret < 0) | 176 | if (ret < 0) |
177 | goto err; | 177 | goto err; |
178 | 178 | ||
179 | device_init_wakeup(max8998->dev, max8998->wakeup); | ||
180 | |||
179 | return ret; | 181 | return ret; |
180 | 182 | ||
181 | err: | 183 | err: |
@@ -210,7 +212,7 @@ static int max8998_suspend(struct device *dev) | |||
210 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); | 212 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); |
211 | struct max8998_dev *max8998 = i2c_get_clientdata(i2c); | 213 | struct max8998_dev *max8998 = i2c_get_clientdata(i2c); |
212 | 214 | ||
213 | if (max8998->wakeup) | 215 | if (device_may_wakeup(dev)) |
214 | irq_set_irq_wake(max8998->irq, 1); | 216 | irq_set_irq_wake(max8998->irq, 1); |
215 | return 0; | 217 | return 0; |
216 | } | 218 | } |
@@ -220,7 +222,7 @@ static int max8998_resume(struct device *dev) | |||
220 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); | 222 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); |
221 | struct max8998_dev *max8998 = i2c_get_clientdata(i2c); | 223 | struct max8998_dev *max8998 = i2c_get_clientdata(i2c); |
222 | 224 | ||
223 | if (max8998->wakeup) | 225 | if (device_may_wakeup(dev)) |
224 | irq_set_irq_wake(max8998->irq, 0); | 226 | irq_set_irq_wake(max8998->irq, 0); |
225 | /* | 227 | /* |
226 | * In LP3974, if IRQ registers are not "read & clear" | 228 | * In LP3974, if IRQ registers are not "read & clear" |
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c index e9619acc0237..7122386b4e3c 100644 --- a/drivers/mfd/mc13xxx-core.c +++ b/drivers/mfd/mc13xxx-core.c | |||
@@ -18,11 +18,15 @@ | |||
18 | #include <linux/spi/spi.h> | 18 | #include <linux/spi/spi.h> |
19 | #include <linux/mfd/core.h> | 19 | #include <linux/mfd/core.h> |
20 | #include <linux/mfd/mc13xxx.h> | 20 | #include <linux/mfd/mc13xxx.h> |
21 | #include <linux/of.h> | ||
22 | #include <linux/of_device.h> | ||
23 | #include <linux/of_gpio.h> | ||
21 | 24 | ||
22 | struct mc13xxx { | 25 | struct mc13xxx { |
23 | struct spi_device *spidev; | 26 | struct spi_device *spidev; |
24 | struct mutex lock; | 27 | struct mutex lock; |
25 | int irq; | 28 | int irq; |
29 | int flags; | ||
26 | 30 | ||
27 | irq_handler_t irqhandler[MC13XXX_NUM_IRQ]; | 31 | irq_handler_t irqhandler[MC13XXX_NUM_IRQ]; |
28 | void *irqdata[MC13XXX_NUM_IRQ]; | 32 | void *irqdata[MC13XXX_NUM_IRQ]; |
@@ -550,10 +554,7 @@ static const char *mc13xxx_get_chipname(struct mc13xxx *mc13xxx) | |||
550 | 554 | ||
551 | int mc13xxx_get_flags(struct mc13xxx *mc13xxx) | 555 | int mc13xxx_get_flags(struct mc13xxx *mc13xxx) |
552 | { | 556 | { |
553 | struct mc13xxx_platform_data *pdata = | 557 | return mc13xxx->flags; |
554 | dev_get_platdata(&mc13xxx->spidev->dev); | ||
555 | |||
556 | return pdata->flags; | ||
557 | } | 558 | } |
558 | EXPORT_SYMBOL(mc13xxx_get_flags); | 559 | EXPORT_SYMBOL(mc13xxx_get_flags); |
559 | 560 | ||
@@ -615,13 +616,13 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode, | |||
615 | break; | 616 | break; |
616 | 617 | ||
617 | case MC13XXX_ADC_MODE_SINGLE_CHAN: | 618 | case MC13XXX_ADC_MODE_SINGLE_CHAN: |
618 | adc0 |= old_adc0 & MC13XXX_ADC0_TSMOD_MASK; | 619 | adc0 |= old_adc0 & MC13XXX_ADC0_CONFIG_MASK; |
619 | adc1 |= (channel & 0x7) << MC13XXX_ADC1_CHAN0_SHIFT; | 620 | adc1 |= (channel & 0x7) << MC13XXX_ADC1_CHAN0_SHIFT; |
620 | adc1 |= MC13XXX_ADC1_RAND; | 621 | adc1 |= MC13XXX_ADC1_RAND; |
621 | break; | 622 | break; |
622 | 623 | ||
623 | case MC13XXX_ADC_MODE_MULT_CHAN: | 624 | case MC13XXX_ADC_MODE_MULT_CHAN: |
624 | adc0 |= old_adc0 & MC13XXX_ADC0_TSMOD_MASK; | 625 | adc0 |= old_adc0 & MC13XXX_ADC0_CONFIG_MASK; |
625 | adc1 |= 4 << MC13XXX_ADC1_CHAN1_SHIFT; | 626 | adc1 |= 4 << MC13XXX_ADC1_CHAN1_SHIFT; |
626 | break; | 627 | break; |
627 | 628 | ||
@@ -696,17 +697,67 @@ static int mc13xxx_add_subdevice(struct mc13xxx *mc13xxx, const char *format) | |||
696 | return mc13xxx_add_subdevice_pdata(mc13xxx, format, NULL, 0); | 697 | return mc13xxx_add_subdevice_pdata(mc13xxx, format, NULL, 0); |
697 | } | 698 | } |
698 | 699 | ||
700 | #ifdef CONFIG_OF | ||
701 | static int mc13xxx_probe_flags_dt(struct mc13xxx *mc13xxx) | ||
702 | { | ||
703 | struct device_node *np = mc13xxx->spidev->dev.of_node; | ||
704 | |||
705 | if (!np) | ||
706 | return -ENODEV; | ||
707 | |||
708 | if (of_get_property(np, "fsl,mc13xxx-uses-adc", NULL)) | ||
709 | mc13xxx->flags |= MC13XXX_USE_ADC; | ||
710 | |||
711 | if (of_get_property(np, "fsl,mc13xxx-uses-codec", NULL)) | ||
712 | mc13xxx->flags |= MC13XXX_USE_CODEC; | ||
713 | |||
714 | if (of_get_property(np, "fsl,mc13xxx-uses-rtc", NULL)) | ||
715 | mc13xxx->flags |= MC13XXX_USE_RTC; | ||
716 | |||
717 | if (of_get_property(np, "fsl,mc13xxx-uses-touch", NULL)) | ||
718 | mc13xxx->flags |= MC13XXX_USE_TOUCHSCREEN; | ||
719 | |||
720 | return 0; | ||
721 | } | ||
722 | #else | ||
723 | static inline int mc13xxx_probe_flags_dt(struct mc13xxx *mc13xxx) | ||
724 | { | ||
725 | return -ENODEV; | ||
726 | } | ||
727 | #endif | ||
728 | |||
729 | static const struct spi_device_id mc13xxx_device_id[] = { | ||
730 | { | ||
731 | .name = "mc13783", | ||
732 | .driver_data = MC13XXX_ID_MC13783, | ||
733 | }, { | ||
734 | .name = "mc13892", | ||
735 | .driver_data = MC13XXX_ID_MC13892, | ||
736 | }, { | ||
737 | /* sentinel */ | ||
738 | } | ||
739 | }; | ||
740 | MODULE_DEVICE_TABLE(spi, mc13xxx_device_id); | ||
741 | |||
742 | static const struct of_device_id mc13xxx_dt_ids[] = { | ||
743 | { .compatible = "fsl,mc13783", .data = (void *) MC13XXX_ID_MC13783, }, | ||
744 | { .compatible = "fsl,mc13892", .data = (void *) MC13XXX_ID_MC13892, }, | ||
745 | { /* sentinel */ } | ||
746 | }; | ||
747 | MODULE_DEVICE_TABLE(of, mc13xxx_dt_ids); | ||
748 | |||
699 | static int mc13xxx_probe(struct spi_device *spi) | 749 | static int mc13xxx_probe(struct spi_device *spi) |
700 | { | 750 | { |
751 | const struct of_device_id *of_id; | ||
752 | struct spi_driver *sdrv = to_spi_driver(spi->dev.driver); | ||
701 | struct mc13xxx *mc13xxx; | 753 | struct mc13xxx *mc13xxx; |
702 | struct mc13xxx_platform_data *pdata = dev_get_platdata(&spi->dev); | 754 | struct mc13xxx_platform_data *pdata = dev_get_platdata(&spi->dev); |
703 | enum mc13xxx_id id; | 755 | enum mc13xxx_id id; |
704 | int ret; | 756 | int ret; |
705 | 757 | ||
706 | if (!pdata) { | 758 | of_id = of_match_device(mc13xxx_dt_ids, &spi->dev); |
707 | dev_err(&spi->dev, "invalid platform data\n"); | 759 | if (of_id) |
708 | return -EINVAL; | 760 | sdrv->id_table = &mc13xxx_device_id[(enum mc13xxx_id) of_id->data]; |
709 | } | ||
710 | 761 | ||
711 | mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL); | 762 | mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL); |
712 | if (!mc13xxx) | 763 | if (!mc13xxx) |
@@ -749,28 +800,33 @@ err_revision: | |||
749 | 800 | ||
750 | mc13xxx_unlock(mc13xxx); | 801 | mc13xxx_unlock(mc13xxx); |
751 | 802 | ||
752 | if (pdata->flags & MC13XXX_USE_ADC) | 803 | if (mc13xxx_probe_flags_dt(mc13xxx) < 0 && pdata) |
804 | mc13xxx->flags = pdata->flags; | ||
805 | |||
806 | if (mc13xxx->flags & MC13XXX_USE_ADC) | ||
753 | mc13xxx_add_subdevice(mc13xxx, "%s-adc"); | 807 | mc13xxx_add_subdevice(mc13xxx, "%s-adc"); |
754 | 808 | ||
755 | if (pdata->flags & MC13XXX_USE_CODEC) | 809 | if (mc13xxx->flags & MC13XXX_USE_CODEC) |
756 | mc13xxx_add_subdevice(mc13xxx, "%s-codec"); | 810 | mc13xxx_add_subdevice(mc13xxx, "%s-codec"); |
757 | 811 | ||
758 | mc13xxx_add_subdevice_pdata(mc13xxx, "%s-regulator", | 812 | if (mc13xxx->flags & MC13XXX_USE_RTC) |
759 | &pdata->regulators, sizeof(pdata->regulators)); | ||
760 | |||
761 | if (pdata->flags & MC13XXX_USE_RTC) | ||
762 | mc13xxx_add_subdevice(mc13xxx, "%s-rtc"); | 813 | mc13xxx_add_subdevice(mc13xxx, "%s-rtc"); |
763 | 814 | ||
764 | if (pdata->flags & MC13XXX_USE_TOUCHSCREEN) | 815 | if (mc13xxx->flags & MC13XXX_USE_TOUCHSCREEN) |
765 | mc13xxx_add_subdevice(mc13xxx, "%s-ts"); | 816 | mc13xxx_add_subdevice(mc13xxx, "%s-ts"); |
766 | 817 | ||
767 | if (pdata->leds) | 818 | if (pdata) { |
819 | mc13xxx_add_subdevice_pdata(mc13xxx, "%s-regulator", | ||
820 | &pdata->regulators, sizeof(pdata->regulators)); | ||
768 | mc13xxx_add_subdevice_pdata(mc13xxx, "%s-led", | 821 | mc13xxx_add_subdevice_pdata(mc13xxx, "%s-led", |
769 | pdata->leds, sizeof(*pdata->leds)); | 822 | pdata->leds, sizeof(*pdata->leds)); |
770 | |||
771 | if (pdata->buttons) | ||
772 | mc13xxx_add_subdevice_pdata(mc13xxx, "%s-pwrbutton", | 823 | mc13xxx_add_subdevice_pdata(mc13xxx, "%s-pwrbutton", |
773 | pdata->buttons, sizeof(*pdata->buttons)); | 824 | pdata->buttons, sizeof(*pdata->buttons)); |
825 | } else { | ||
826 | mc13xxx_add_subdevice(mc13xxx, "%s-regulator"); | ||
827 | mc13xxx_add_subdevice(mc13xxx, "%s-led"); | ||
828 | mc13xxx_add_subdevice(mc13xxx, "%s-pwrbutton"); | ||
829 | } | ||
774 | 830 | ||
775 | return 0; | 831 | return 0; |
776 | } | 832 | } |
@@ -788,25 +844,12 @@ static int __devexit mc13xxx_remove(struct spi_device *spi) | |||
788 | return 0; | 844 | return 0; |
789 | } | 845 | } |
790 | 846 | ||
791 | static const struct spi_device_id mc13xxx_device_id[] = { | ||
792 | { | ||
793 | .name = "mc13783", | ||
794 | .driver_data = MC13XXX_ID_MC13783, | ||
795 | }, { | ||
796 | .name = "mc13892", | ||
797 | .driver_data = MC13XXX_ID_MC13892, | ||
798 | }, { | ||
799 | /* sentinel */ | ||
800 | } | ||
801 | }; | ||
802 | MODULE_DEVICE_TABLE(spi, mc13xxx_device_id); | ||
803 | |||
804 | static struct spi_driver mc13xxx_driver = { | 847 | static struct spi_driver mc13xxx_driver = { |
805 | .id_table = mc13xxx_device_id, | 848 | .id_table = mc13xxx_device_id, |
806 | .driver = { | 849 | .driver = { |
807 | .name = "mc13xxx", | 850 | .name = "mc13xxx", |
808 | .bus = &spi_bus_type, | ||
809 | .owner = THIS_MODULE, | 851 | .owner = THIS_MODULE, |
852 | .of_match_table = mc13xxx_dt_ids, | ||
810 | }, | 853 | }, |
811 | .probe = mc13xxx_probe, | 854 | .probe = mc13xxx_probe, |
812 | .remove = __devexit_p(mc13xxx_remove), | 855 | .remove = __devexit_p(mc13xxx_remove), |
diff --git a/drivers/mfd/mcp-core.c b/drivers/mfd/mcp-core.c index 84815f9ef636..63be60bc3455 100644 --- a/drivers/mfd/mcp-core.c +++ b/drivers/mfd/mcp-core.c | |||
@@ -26,9 +26,35 @@ | |||
26 | #define to_mcp(d) container_of(d, struct mcp, attached_device) | 26 | #define to_mcp(d) container_of(d, struct mcp, attached_device) |
27 | #define to_mcp_driver(d) container_of(d, struct mcp_driver, drv) | 27 | #define to_mcp_driver(d) container_of(d, struct mcp_driver, drv) |
28 | 28 | ||
29 | static const struct mcp_device_id *mcp_match_id(const struct mcp_device_id *id, | ||
30 | const char *codec) | ||
31 | { | ||
32 | while (id->name[0]) { | ||
33 | if (strcmp(codec, id->name) == 0) | ||
34 | return id; | ||
35 | id++; | ||
36 | } | ||
37 | return NULL; | ||
38 | } | ||
39 | |||
40 | const struct mcp_device_id *mcp_get_device_id(const struct mcp *mcp) | ||
41 | { | ||
42 | const struct mcp_driver *driver = | ||
43 | to_mcp_driver(mcp->attached_device.driver); | ||
44 | |||
45 | return mcp_match_id(driver->id_table, mcp->codec); | ||
46 | } | ||
47 | EXPORT_SYMBOL(mcp_get_device_id); | ||
48 | |||
29 | static int mcp_bus_match(struct device *dev, struct device_driver *drv) | 49 | static int mcp_bus_match(struct device *dev, struct device_driver *drv) |
30 | { | 50 | { |
31 | return 1; | 51 | const struct mcp *mcp = to_mcp(dev); |
52 | const struct mcp_driver *driver = to_mcp_driver(drv); | ||
53 | |||
54 | if (driver->id_table) | ||
55 | return !!mcp_match_id(driver->id_table, mcp->codec); | ||
56 | |||
57 | return 0; | ||
32 | } | 58 | } |
33 | 59 | ||
34 | static int mcp_bus_probe(struct device *dev) | 60 | static int mcp_bus_probe(struct device *dev) |
@@ -74,9 +100,18 @@ static int mcp_bus_resume(struct device *dev) | |||
74 | return ret; | 100 | return ret; |
75 | } | 101 | } |
76 | 102 | ||
103 | static int mcp_bus_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
104 | { | ||
105 | struct mcp *mcp = to_mcp(dev); | ||
106 | |||
107 | add_uevent_var(env, "MODALIAS=%s%s", MCP_MODULE_PREFIX, mcp->codec); | ||
108 | return 0; | ||
109 | } | ||
110 | |||
77 | static struct bus_type mcp_bus_type = { | 111 | static struct bus_type mcp_bus_type = { |
78 | .name = "mcp", | 112 | .name = "mcp", |
79 | .match = mcp_bus_match, | 113 | .match = mcp_bus_match, |
114 | .uevent = mcp_bus_uevent, | ||
80 | .probe = mcp_bus_probe, | 115 | .probe = mcp_bus_probe, |
81 | .remove = mcp_bus_remove, | 116 | .remove = mcp_bus_remove, |
82 | .suspend = mcp_bus_suspend, | 117 | .suspend = mcp_bus_suspend, |
@@ -212,9 +247,14 @@ struct mcp *mcp_host_alloc(struct device *parent, size_t size) | |||
212 | } | 247 | } |
213 | EXPORT_SYMBOL(mcp_host_alloc); | 248 | EXPORT_SYMBOL(mcp_host_alloc); |
214 | 249 | ||
215 | int mcp_host_register(struct mcp *mcp) | 250 | int mcp_host_register(struct mcp *mcp, void *pdata) |
216 | { | 251 | { |
252 | if (!mcp->codec) | ||
253 | return -EINVAL; | ||
254 | |||
255 | mcp->attached_device.platform_data = pdata; | ||
217 | dev_set_name(&mcp->attached_device, "mcp0"); | 256 | dev_set_name(&mcp->attached_device, "mcp0"); |
257 | request_module("%s%s", MCP_MODULE_PREFIX, mcp->codec); | ||
218 | return device_register(&mcp->attached_device); | 258 | return device_register(&mcp->attached_device); |
219 | } | 259 | } |
220 | EXPORT_SYMBOL(mcp_host_register); | 260 | EXPORT_SYMBOL(mcp_host_register); |
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c index 2dab02d9ac8b..9adc2eb69492 100644 --- a/drivers/mfd/mcp-sa11x0.c +++ b/drivers/mfd/mcp-sa11x0.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/spinlock.h> | 19 | #include <linux/spinlock.h> |
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/mfd/mcp.h> | 21 | #include <linux/mfd/mcp.h> |
22 | #include <linux/io.h> | ||
22 | 23 | ||
23 | #include <mach/dma.h> | 24 | #include <mach/dma.h> |
24 | #include <mach/hardware.h> | 25 | #include <mach/hardware.h> |
@@ -26,12 +27,19 @@ | |||
26 | #include <asm/system.h> | 27 | #include <asm/system.h> |
27 | #include <mach/mcp.h> | 28 | #include <mach/mcp.h> |
28 | 29 | ||
29 | #include <mach/assabet.h> | 30 | /* Register offsets */ |
30 | 31 | #define MCCR0 0x00 | |
32 | #define MCDR0 0x08 | ||
33 | #define MCDR1 0x0C | ||
34 | #define MCDR2 0x10 | ||
35 | #define MCSR 0x18 | ||
36 | #define MCCR1 0x00 | ||
31 | 37 | ||
32 | struct mcp_sa11x0 { | 38 | struct mcp_sa11x0 { |
33 | u32 mccr0; | 39 | u32 mccr0; |
34 | u32 mccr1; | 40 | u32 mccr1; |
41 | unsigned char *mccr0_base; | ||
42 | unsigned char *mccr1_base; | ||
35 | }; | 43 | }; |
36 | 44 | ||
37 | #define priv(mcp) ((struct mcp_sa11x0 *)mcp_priv(mcp)) | 45 | #define priv(mcp) ((struct mcp_sa11x0 *)mcp_priv(mcp)) |
@@ -39,25 +47,25 @@ struct mcp_sa11x0 { | |||
39 | static void | 47 | static void |
40 | mcp_sa11x0_set_telecom_divisor(struct mcp *mcp, unsigned int divisor) | 48 | mcp_sa11x0_set_telecom_divisor(struct mcp *mcp, unsigned int divisor) |
41 | { | 49 | { |
42 | unsigned int mccr0; | 50 | struct mcp_sa11x0 *priv = priv(mcp); |
43 | 51 | ||
44 | divisor /= 32; | 52 | divisor /= 32; |
45 | 53 | ||
46 | mccr0 = Ser4MCCR0 & ~0x00007f00; | 54 | priv->mccr0 &= ~0x00007f00; |
47 | mccr0 |= divisor << 8; | 55 | priv->mccr0 |= divisor << 8; |
48 | Ser4MCCR0 = mccr0; | 56 | __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); |
49 | } | 57 | } |
50 | 58 | ||
51 | static void | 59 | static void |
52 | mcp_sa11x0_set_audio_divisor(struct mcp *mcp, unsigned int divisor) | 60 | mcp_sa11x0_set_audio_divisor(struct mcp *mcp, unsigned int divisor) |
53 | { | 61 | { |
54 | unsigned int mccr0; | 62 | struct mcp_sa11x0 *priv = priv(mcp); |
55 | 63 | ||
56 | divisor /= 32; | 64 | divisor /= 32; |
57 | 65 | ||
58 | mccr0 = Ser4MCCR0 & ~0x0000007f; | 66 | priv->mccr0 &= ~0x0000007f; |
59 | mccr0 |= divisor; | 67 | priv->mccr0 |= divisor; |
60 | Ser4MCCR0 = mccr0; | 68 | __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); |
61 | } | 69 | } |
62 | 70 | ||
63 | /* | 71 | /* |
@@ -71,12 +79,16 @@ mcp_sa11x0_write(struct mcp *mcp, unsigned int reg, unsigned int val) | |||
71 | { | 79 | { |
72 | int ret = -ETIME; | 80 | int ret = -ETIME; |
73 | int i; | 81 | int i; |
82 | u32 mcpreg; | ||
83 | struct mcp_sa11x0 *priv = priv(mcp); | ||
74 | 84 | ||
75 | Ser4MCDR2 = reg << 17 | MCDR2_Wr | (val & 0xffff); | 85 | mcpreg = reg << 17 | MCDR2_Wr | (val & 0xffff); |
86 | __raw_writel(mcpreg, priv->mccr0_base + MCDR2); | ||
76 | 87 | ||
77 | for (i = 0; i < 2; i++) { | 88 | for (i = 0; i < 2; i++) { |
78 | udelay(mcp->rw_timeout); | 89 | udelay(mcp->rw_timeout); |
79 | if (Ser4MCSR & MCSR_CWC) { | 90 | mcpreg = __raw_readl(priv->mccr0_base + MCSR); |
91 | if (mcpreg & MCSR_CWC) { | ||
80 | ret = 0; | 92 | ret = 0; |
81 | break; | 93 | break; |
82 | } | 94 | } |
@@ -97,13 +109,18 @@ mcp_sa11x0_read(struct mcp *mcp, unsigned int reg) | |||
97 | { | 109 | { |
98 | int ret = -ETIME; | 110 | int ret = -ETIME; |
99 | int i; | 111 | int i; |
112 | u32 mcpreg; | ||
113 | struct mcp_sa11x0 *priv = priv(mcp); | ||
100 | 114 | ||
101 | Ser4MCDR2 = reg << 17 | MCDR2_Rd; | 115 | mcpreg = reg << 17 | MCDR2_Rd; |
116 | __raw_writel(mcpreg, priv->mccr0_base + MCDR2); | ||
102 | 117 | ||
103 | for (i = 0; i < 2; i++) { | 118 | for (i = 0; i < 2; i++) { |
104 | udelay(mcp->rw_timeout); | 119 | udelay(mcp->rw_timeout); |
105 | if (Ser4MCSR & MCSR_CRC) { | 120 | mcpreg = __raw_readl(priv->mccr0_base + MCSR); |
106 | ret = Ser4MCDR2 & 0xffff; | 121 | if (mcpreg & MCSR_CRC) { |
122 | ret = __raw_readl(priv->mccr0_base + MCDR2) | ||
123 | & 0xffff; | ||
107 | break; | 124 | break; |
108 | } | 125 | } |
109 | } | 126 | } |
@@ -116,13 +133,19 @@ mcp_sa11x0_read(struct mcp *mcp, unsigned int reg) | |||
116 | 133 | ||
117 | static void mcp_sa11x0_enable(struct mcp *mcp) | 134 | static void mcp_sa11x0_enable(struct mcp *mcp) |
118 | { | 135 | { |
119 | Ser4MCSR = -1; | 136 | struct mcp_sa11x0 *priv = priv(mcp); |
120 | Ser4MCCR0 |= MCCR0_MCE; | 137 | |
138 | __raw_writel(-1, priv->mccr0_base + MCSR); | ||
139 | priv->mccr0 |= MCCR0_MCE; | ||
140 | __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); | ||
121 | } | 141 | } |
122 | 142 | ||
123 | static void mcp_sa11x0_disable(struct mcp *mcp) | 143 | static void mcp_sa11x0_disable(struct mcp *mcp) |
124 | { | 144 | { |
125 | Ser4MCCR0 &= ~MCCR0_MCE; | 145 | struct mcp_sa11x0 *priv = priv(mcp); |
146 | |||
147 | priv->mccr0 &= ~MCCR0_MCE; | ||
148 | __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); | ||
126 | } | 149 | } |
127 | 150 | ||
128 | /* | 151 | /* |
@@ -142,50 +165,69 @@ static int mcp_sa11x0_probe(struct platform_device *pdev) | |||
142 | struct mcp_plat_data *data = pdev->dev.platform_data; | 165 | struct mcp_plat_data *data = pdev->dev.platform_data; |
143 | struct mcp *mcp; | 166 | struct mcp *mcp; |
144 | int ret; | 167 | int ret; |
168 | struct mcp_sa11x0 *priv; | ||
169 | struct resource *res_mem0, *res_mem1; | ||
170 | u32 size0, size1; | ||
145 | 171 | ||
146 | if (!data) | 172 | if (!data) |
147 | return -ENODEV; | 173 | return -ENODEV; |
148 | 174 | ||
149 | if (!request_mem_region(0x80060000, 0x60, "sa11x0-mcp")) | 175 | if (!data->codec) |
176 | return -ENODEV; | ||
177 | |||
178 | res_mem0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
179 | if (!res_mem0) | ||
180 | return -ENODEV; | ||
181 | size0 = res_mem0->end - res_mem0->start + 1; | ||
182 | |||
183 | res_mem1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
184 | if (!res_mem1) | ||
185 | return -ENODEV; | ||
186 | size1 = res_mem1->end - res_mem1->start + 1; | ||
187 | |||
188 | if (!request_mem_region(res_mem0->start, size0, "sa11x0-mcp")) | ||
150 | return -EBUSY; | 189 | return -EBUSY; |
151 | 190 | ||
191 | if (!request_mem_region(res_mem1->start, size1, "sa11x0-mcp")) { | ||
192 | ret = -EBUSY; | ||
193 | goto release; | ||
194 | } | ||
195 | |||
152 | mcp = mcp_host_alloc(&pdev->dev, sizeof(struct mcp_sa11x0)); | 196 | mcp = mcp_host_alloc(&pdev->dev, sizeof(struct mcp_sa11x0)); |
153 | if (!mcp) { | 197 | if (!mcp) { |
154 | ret = -ENOMEM; | 198 | ret = -ENOMEM; |
155 | goto release; | 199 | goto release2; |
156 | } | 200 | } |
157 | 201 | ||
202 | priv = priv(mcp); | ||
203 | |||
158 | mcp->owner = THIS_MODULE; | 204 | mcp->owner = THIS_MODULE; |
159 | mcp->ops = &mcp_sa11x0; | 205 | mcp->ops = &mcp_sa11x0; |
160 | mcp->sclk_rate = data->sclk_rate; | 206 | mcp->sclk_rate = data->sclk_rate; |
161 | mcp->dma_audio_rd = DMA_Ser4MCP0Rd; | 207 | mcp->dma_audio_rd = DDAR_DevAdd(res_mem0->start + MCDR0) |
162 | mcp->dma_audio_wr = DMA_Ser4MCP0Wr; | 208 | + DDAR_DevRd + DDAR_Brst4 + DDAR_8BitDev; |
163 | mcp->dma_telco_rd = DMA_Ser4MCP1Rd; | 209 | mcp->dma_audio_wr = DDAR_DevAdd(res_mem0->start + MCDR0) |
164 | mcp->dma_telco_wr = DMA_Ser4MCP1Wr; | 210 | + DDAR_DevWr + DDAR_Brst4 + DDAR_8BitDev; |
165 | mcp->gpio_base = data->gpio_base; | 211 | mcp->dma_telco_rd = DDAR_DevAdd(res_mem0->start + MCDR1) |
212 | + DDAR_DevRd + DDAR_Brst4 + DDAR_8BitDev; | ||
213 | mcp->dma_telco_wr = DDAR_DevAdd(res_mem0->start + MCDR1) | ||
214 | + DDAR_DevWr + DDAR_Brst4 + DDAR_8BitDev; | ||
215 | mcp->codec = data->codec; | ||
166 | 216 | ||
167 | platform_set_drvdata(pdev, mcp); | 217 | platform_set_drvdata(pdev, mcp); |
168 | 218 | ||
169 | if (machine_is_assabet()) { | ||
170 | ASSABET_BCR_set(ASSABET_BCR_CODEC_RST); | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * Setup the PPC unit correctly. | ||
175 | */ | ||
176 | PPDR &= ~PPC_RXD4; | ||
177 | PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; | ||
178 | PSDR |= PPC_RXD4; | ||
179 | PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); | ||
180 | PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); | ||
181 | |||
182 | /* | 219 | /* |
183 | * Initialise device. Note that we initially | 220 | * Initialise device. Note that we initially |
184 | * set the sampling rate to minimum. | 221 | * set the sampling rate to minimum. |
185 | */ | 222 | */ |
186 | Ser4MCSR = -1; | 223 | priv->mccr0_base = ioremap(res_mem0->start, size0); |
187 | Ser4MCCR1 = data->mccr1; | 224 | priv->mccr1_base = ioremap(res_mem1->start, size1); |
188 | Ser4MCCR0 = data->mccr0 | 0x7f7f; | 225 | |
226 | __raw_writel(-1, priv->mccr0_base + MCSR); | ||
227 | priv->mccr1 = data->mccr1; | ||
228 | priv->mccr0 = data->mccr0 | 0x7f7f; | ||
229 | __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); | ||
230 | __raw_writel(priv->mccr1, priv->mccr1_base + MCCR1); | ||
189 | 231 | ||
190 | /* | 232 | /* |
191 | * Calculate the read/write timeout (us) from the bit clock | 233 | * Calculate the read/write timeout (us) from the bit clock |
@@ -195,36 +237,53 @@ static int mcp_sa11x0_probe(struct platform_device *pdev) | |||
195 | mcp->rw_timeout = (64 * 3 * 1000000 + mcp->sclk_rate - 1) / | 237 | mcp->rw_timeout = (64 * 3 * 1000000 + mcp->sclk_rate - 1) / |
196 | mcp->sclk_rate; | 238 | mcp->sclk_rate; |
197 | 239 | ||
198 | ret = mcp_host_register(mcp); | 240 | ret = mcp_host_register(mcp, data->codec_pdata); |
199 | if (ret == 0) | 241 | if (ret == 0) |
200 | goto out; | 242 | goto out; |
201 | 243 | ||
244 | release2: | ||
245 | release_mem_region(res_mem1->start, size1); | ||
202 | release: | 246 | release: |
203 | release_mem_region(0x80060000, 0x60); | 247 | release_mem_region(res_mem0->start, size0); |
204 | platform_set_drvdata(pdev, NULL); | 248 | platform_set_drvdata(pdev, NULL); |
205 | 249 | ||
206 | out: | 250 | out: |
207 | return ret; | 251 | return ret; |
208 | } | 252 | } |
209 | 253 | ||
210 | static int mcp_sa11x0_remove(struct platform_device *dev) | 254 | static int mcp_sa11x0_remove(struct platform_device *pdev) |
211 | { | 255 | { |
212 | struct mcp *mcp = platform_get_drvdata(dev); | 256 | struct mcp *mcp = platform_get_drvdata(pdev); |
257 | struct mcp_sa11x0 *priv = priv(mcp); | ||
258 | struct resource *res_mem; | ||
259 | u32 size; | ||
213 | 260 | ||
214 | platform_set_drvdata(dev, NULL); | 261 | platform_set_drvdata(pdev, NULL); |
215 | mcp_host_unregister(mcp); | 262 | mcp_host_unregister(mcp); |
216 | release_mem_region(0x80060000, 0x60); | ||
217 | 263 | ||
264 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
265 | if (res_mem) { | ||
266 | size = res_mem->end - res_mem->start + 1; | ||
267 | release_mem_region(res_mem->start, size); | ||
268 | } | ||
269 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
270 | if (res_mem) { | ||
271 | size = res_mem->end - res_mem->start + 1; | ||
272 | release_mem_region(res_mem->start, size); | ||
273 | } | ||
274 | iounmap(priv->mccr0_base); | ||
275 | iounmap(priv->mccr1_base); | ||
218 | return 0; | 276 | return 0; |
219 | } | 277 | } |
220 | 278 | ||
221 | static int mcp_sa11x0_suspend(struct platform_device *dev, pm_message_t state) | 279 | static int mcp_sa11x0_suspend(struct platform_device *dev, pm_message_t state) |
222 | { | 280 | { |
223 | struct mcp *mcp = platform_get_drvdata(dev); | 281 | struct mcp *mcp = platform_get_drvdata(dev); |
282 | struct mcp_sa11x0 *priv = priv(mcp); | ||
283 | u32 mccr0; | ||
224 | 284 | ||
225 | priv(mcp)->mccr0 = Ser4MCCR0; | 285 | mccr0 = priv->mccr0 & ~MCCR0_MCE; |
226 | priv(mcp)->mccr1 = Ser4MCCR1; | 286 | __raw_writel(mccr0, priv->mccr0_base + MCCR0); |
227 | Ser4MCCR0 &= ~MCCR0_MCE; | ||
228 | 287 | ||
229 | return 0; | 288 | return 0; |
230 | } | 289 | } |
@@ -232,9 +291,10 @@ static int mcp_sa11x0_suspend(struct platform_device *dev, pm_message_t state) | |||
232 | static int mcp_sa11x0_resume(struct platform_device *dev) | 291 | static int mcp_sa11x0_resume(struct platform_device *dev) |
233 | { | 292 | { |
234 | struct mcp *mcp = platform_get_drvdata(dev); | 293 | struct mcp *mcp = platform_get_drvdata(dev); |
294 | struct mcp_sa11x0 *priv = priv(mcp); | ||
235 | 295 | ||
236 | Ser4MCCR1 = priv(mcp)->mccr1; | 296 | __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); |
237 | Ser4MCCR0 = priv(mcp)->mccr0; | 297 | __raw_writel(priv->mccr1, priv->mccr1_base + MCCR1); |
238 | 298 | ||
239 | return 0; | 299 | return 0; |
240 | } | 300 | } |
@@ -251,24 +311,14 @@ static struct platform_driver mcp_sa11x0_driver = { | |||
251 | .resume = mcp_sa11x0_resume, | 311 | .resume = mcp_sa11x0_resume, |
252 | .driver = { | 312 | .driver = { |
253 | .name = "sa11x0-mcp", | 313 | .name = "sa11x0-mcp", |
314 | .owner = THIS_MODULE, | ||
254 | }, | 315 | }, |
255 | }; | 316 | }; |
256 | 317 | ||
257 | /* | 318 | /* |
258 | * This needs re-working | 319 | * This needs re-working |
259 | */ | 320 | */ |
260 | static int __init mcp_sa11x0_init(void) | 321 | module_platform_driver(mcp_sa11x0_driver); |
261 | { | ||
262 | return platform_driver_register(&mcp_sa11x0_driver); | ||
263 | } | ||
264 | |||
265 | static void __exit mcp_sa11x0_exit(void) | ||
266 | { | ||
267 | platform_driver_unregister(&mcp_sa11x0_driver); | ||
268 | } | ||
269 | |||
270 | module_init(mcp_sa11x0_init); | ||
271 | module_exit(mcp_sa11x0_exit); | ||
272 | 322 | ||
273 | MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); | 323 | MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); |
274 | MODULE_DESCRIPTION("SA11x0 multimedia communications port driver"); | 324 | MODULE_DESCRIPTION("SA11x0 multimedia communications port driver"); |
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 3f565ef3e149..68ac2c55d5ae 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c | |||
@@ -503,19 +503,13 @@ static void omap_usbhs_init(struct device *dev) | |||
503 | spin_lock_irqsave(&omap->lock, flags); | 503 | spin_lock_irqsave(&omap->lock, flags); |
504 | 504 | ||
505 | if (pdata->ehci_data->phy_reset) { | 505 | if (pdata->ehci_data->phy_reset) { |
506 | if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) { | 506 | if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) |
507 | gpio_request(pdata->ehci_data->reset_gpio_port[0], | 507 | gpio_request_one(pdata->ehci_data->reset_gpio_port[0], |
508 | "USB1 PHY reset"); | 508 | GPIOF_OUT_INIT_LOW, "USB1 PHY reset"); |
509 | gpio_direction_output | ||
510 | (pdata->ehci_data->reset_gpio_port[0], 0); | ||
511 | } | ||
512 | 509 | ||
513 | if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) { | 510 | if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) |
514 | gpio_request(pdata->ehci_data->reset_gpio_port[1], | 511 | gpio_request_one(pdata->ehci_data->reset_gpio_port[1], |
515 | "USB2 PHY reset"); | 512 | GPIOF_OUT_INIT_LOW, "USB2 PHY reset"); |
516 | gpio_direction_output | ||
517 | (pdata->ehci_data->reset_gpio_port[1], 0); | ||
518 | } | ||
519 | 513 | ||
520 | /* Hold the PHY in RESET for enough time till DIR is high */ | 514 | /* Hold the PHY in RESET for enough time till DIR is high */ |
521 | udelay(10); | 515 | udelay(10); |
diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c index aed0d2a9b032..3927c17e4175 100644 --- a/drivers/mfd/pcf50633-adc.c +++ b/drivers/mfd/pcf50633-adc.c | |||
@@ -249,17 +249,7 @@ static struct platform_driver pcf50633_adc_driver = { | |||
249 | .remove = __devexit_p(pcf50633_adc_remove), | 249 | .remove = __devexit_p(pcf50633_adc_remove), |
250 | }; | 250 | }; |
251 | 251 | ||
252 | static int __init pcf50633_adc_init(void) | 252 | module_platform_driver(pcf50633_adc_driver); |
253 | { | ||
254 | return platform_driver_register(&pcf50633_adc_driver); | ||
255 | } | ||
256 | module_init(pcf50633_adc_init); | ||
257 | |||
258 | static void __exit pcf50633_adc_exit(void) | ||
259 | { | ||
260 | platform_driver_unregister(&pcf50633_adc_driver); | ||
261 | } | ||
262 | module_exit(pcf50633_adc_exit); | ||
263 | 253 | ||
264 | MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>"); | 254 | MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>"); |
265 | MODULE_DESCRIPTION("PCF50633 adc driver"); | 255 | MODULE_DESCRIPTION("PCF50633 adc driver"); |
diff --git a/drivers/mfd/s5m-core.c b/drivers/mfd/s5m-core.c new file mode 100644 index 000000000000..e075c113eec6 --- /dev/null +++ b/drivers/mfd/s5m-core.c | |||
@@ -0,0 +1,176 @@ | |||
1 | /* | ||
2 | * s5m87xx.c | ||
3 | * | ||
4 | * Copyright (c) 2011 Samsung Electronics Co., Ltd | ||
5 | * http://www.samsung.com | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/moduleparam.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/err.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/i2c.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/pm_runtime.h> | ||
22 | #include <linux/mutex.h> | ||
23 | #include <linux/mfd/core.h> | ||
24 | #include <linux/mfd/s5m87xx/s5m-core.h> | ||
25 | #include <linux/mfd/s5m87xx/s5m-pmic.h> | ||
26 | #include <linux/mfd/s5m87xx/s5m-rtc.h> | ||
27 | #include <linux/regmap.h> | ||
28 | |||
29 | static struct mfd_cell s5m87xx_devs[] = { | ||
30 | { | ||
31 | .name = "s5m8767-pmic", | ||
32 | }, { | ||
33 | .name = "s5m-rtc", | ||
34 | }, | ||
35 | }; | ||
36 | |||
37 | int s5m_reg_read(struct s5m87xx_dev *s5m87xx, u8 reg, void *dest) | ||
38 | { | ||
39 | return regmap_read(s5m87xx->regmap, reg, dest); | ||
40 | } | ||
41 | EXPORT_SYMBOL_GPL(s5m_reg_read); | ||
42 | |||
43 | int s5m_bulk_read(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf) | ||
44 | { | ||
45 | return regmap_bulk_read(s5m87xx->regmap, reg, buf, count);; | ||
46 | } | ||
47 | EXPORT_SYMBOL_GPL(s5m_bulk_read); | ||
48 | |||
49 | int s5m_reg_write(struct s5m87xx_dev *s5m87xx, u8 reg, u8 value) | ||
50 | { | ||
51 | return regmap_write(s5m87xx->regmap, reg, value); | ||
52 | } | ||
53 | EXPORT_SYMBOL_GPL(s5m_reg_write); | ||
54 | |||
55 | int s5m_bulk_write(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf) | ||
56 | { | ||
57 | return regmap_raw_write(s5m87xx->regmap, reg, buf, count * sizeof(u16)); | ||
58 | } | ||
59 | EXPORT_SYMBOL_GPL(s5m_bulk_write); | ||
60 | |||
61 | int s5m_reg_update(struct s5m87xx_dev *s5m87xx, u8 reg, u8 val, u8 mask) | ||
62 | { | ||
63 | return regmap_update_bits(s5m87xx->regmap, reg, mask, val); | ||
64 | } | ||
65 | EXPORT_SYMBOL_GPL(s5m_reg_update); | ||
66 | |||
67 | static struct regmap_config s5m_regmap_config = { | ||
68 | .reg_bits = 8, | ||
69 | .val_bits = 8, | ||
70 | }; | ||
71 | |||
72 | static int s5m87xx_i2c_probe(struct i2c_client *i2c, | ||
73 | const struct i2c_device_id *id) | ||
74 | { | ||
75 | struct s5m_platform_data *pdata = i2c->dev.platform_data; | ||
76 | struct s5m87xx_dev *s5m87xx; | ||
77 | int ret = 0; | ||
78 | int error; | ||
79 | |||
80 | s5m87xx = kzalloc(sizeof(struct s5m87xx_dev), GFP_KERNEL); | ||
81 | if (s5m87xx == NULL) | ||
82 | return -ENOMEM; | ||
83 | |||
84 | i2c_set_clientdata(i2c, s5m87xx); | ||
85 | s5m87xx->dev = &i2c->dev; | ||
86 | s5m87xx->i2c = i2c; | ||
87 | s5m87xx->irq = i2c->irq; | ||
88 | s5m87xx->type = id->driver_data; | ||
89 | |||
90 | if (pdata) { | ||
91 | s5m87xx->device_type = pdata->device_type; | ||
92 | s5m87xx->ono = pdata->ono; | ||
93 | s5m87xx->irq_base = pdata->irq_base; | ||
94 | s5m87xx->wakeup = pdata->wakeup; | ||
95 | } | ||
96 | |||
97 | s5m87xx->regmap = regmap_init_i2c(i2c, &s5m_regmap_config); | ||
98 | if (IS_ERR(s5m87xx->regmap)) { | ||
99 | error = PTR_ERR(s5m87xx->regmap); | ||
100 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", | ||
101 | error); | ||
102 | goto err; | ||
103 | } | ||
104 | |||
105 | s5m87xx->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR); | ||
106 | i2c_set_clientdata(s5m87xx->rtc, s5m87xx); | ||
107 | |||
108 | if (pdata->cfg_pmic_irq) | ||
109 | pdata->cfg_pmic_irq(); | ||
110 | |||
111 | s5m_irq_init(s5m87xx); | ||
112 | |||
113 | pm_runtime_set_active(s5m87xx->dev); | ||
114 | |||
115 | ret = mfd_add_devices(s5m87xx->dev, -1, | ||
116 | s5m87xx_devs, ARRAY_SIZE(s5m87xx_devs), | ||
117 | NULL, 0); | ||
118 | |||
119 | if (ret < 0) | ||
120 | goto err; | ||
121 | |||
122 | return ret; | ||
123 | |||
124 | err: | ||
125 | mfd_remove_devices(s5m87xx->dev); | ||
126 | s5m_irq_exit(s5m87xx); | ||
127 | i2c_unregister_device(s5m87xx->rtc); | ||
128 | regmap_exit(s5m87xx->regmap); | ||
129 | kfree(s5m87xx); | ||
130 | return ret; | ||
131 | } | ||
132 | |||
133 | static int s5m87xx_i2c_remove(struct i2c_client *i2c) | ||
134 | { | ||
135 | struct s5m87xx_dev *s5m87xx = i2c_get_clientdata(i2c); | ||
136 | |||
137 | mfd_remove_devices(s5m87xx->dev); | ||
138 | s5m_irq_exit(s5m87xx); | ||
139 | i2c_unregister_device(s5m87xx->rtc); | ||
140 | regmap_exit(s5m87xx->regmap); | ||
141 | kfree(s5m87xx); | ||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | static const struct i2c_device_id s5m87xx_i2c_id[] = { | ||
146 | { "s5m87xx", 0 }, | ||
147 | { } | ||
148 | }; | ||
149 | MODULE_DEVICE_TABLE(i2c, s5m87xx_i2c_id); | ||
150 | |||
151 | static struct i2c_driver s5m87xx_i2c_driver = { | ||
152 | .driver = { | ||
153 | .name = "s5m87xx", | ||
154 | .owner = THIS_MODULE, | ||
155 | }, | ||
156 | .probe = s5m87xx_i2c_probe, | ||
157 | .remove = s5m87xx_i2c_remove, | ||
158 | .id_table = s5m87xx_i2c_id, | ||
159 | }; | ||
160 | |||
161 | static int __init s5m87xx_i2c_init(void) | ||
162 | { | ||
163 | return i2c_add_driver(&s5m87xx_i2c_driver); | ||
164 | } | ||
165 | |||
166 | subsys_initcall(s5m87xx_i2c_init); | ||
167 | |||
168 | static void __exit s5m87xx_i2c_exit(void) | ||
169 | { | ||
170 | i2c_del_driver(&s5m87xx_i2c_driver); | ||
171 | } | ||
172 | module_exit(s5m87xx_i2c_exit); | ||
173 | |||
174 | MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>"); | ||
175 | MODULE_DESCRIPTION("Core support for the S5M MFD"); | ||
176 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/mfd/s5m-irq.c b/drivers/mfd/s5m-irq.c new file mode 100644 index 000000000000..de76dfb6f0ad --- /dev/null +++ b/drivers/mfd/s5m-irq.c | |||
@@ -0,0 +1,487 @@ | |||
1 | /* | ||
2 | * s5m-irq.c | ||
3 | * | ||
4 | * Copyright (c) 2011 Samsung Electronics Co., Ltd | ||
5 | * http://www.samsung.com | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/device.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/irq.h> | ||
17 | #include <linux/mfd/s5m87xx/s5m-core.h> | ||
18 | |||
19 | struct s5m_irq_data { | ||
20 | int reg; | ||
21 | int mask; | ||
22 | }; | ||
23 | |||
24 | static struct s5m_irq_data s5m8767_irqs[] = { | ||
25 | [S5M8767_IRQ_PWRR] = { | ||
26 | .reg = 1, | ||
27 | .mask = S5M8767_IRQ_PWRR_MASK, | ||
28 | }, | ||
29 | [S5M8767_IRQ_PWRF] = { | ||
30 | .reg = 1, | ||
31 | .mask = S5M8767_IRQ_PWRF_MASK, | ||
32 | }, | ||
33 | [S5M8767_IRQ_PWR1S] = { | ||
34 | .reg = 1, | ||
35 | .mask = S5M8767_IRQ_PWR1S_MASK, | ||
36 | }, | ||
37 | [S5M8767_IRQ_JIGR] = { | ||
38 | .reg = 1, | ||
39 | .mask = S5M8767_IRQ_JIGR_MASK, | ||
40 | }, | ||
41 | [S5M8767_IRQ_JIGF] = { | ||
42 | .reg = 1, | ||
43 | .mask = S5M8767_IRQ_JIGF_MASK, | ||
44 | }, | ||
45 | [S5M8767_IRQ_LOWBAT2] = { | ||
46 | .reg = 1, | ||
47 | .mask = S5M8767_IRQ_LOWBAT2_MASK, | ||
48 | }, | ||
49 | [S5M8767_IRQ_LOWBAT1] = { | ||
50 | .reg = 1, | ||
51 | .mask = S5M8767_IRQ_LOWBAT1_MASK, | ||
52 | }, | ||
53 | [S5M8767_IRQ_MRB] = { | ||
54 | .reg = 2, | ||
55 | .mask = S5M8767_IRQ_MRB_MASK, | ||
56 | }, | ||
57 | [S5M8767_IRQ_DVSOK2] = { | ||
58 | .reg = 2, | ||
59 | .mask = S5M8767_IRQ_DVSOK2_MASK, | ||
60 | }, | ||
61 | [S5M8767_IRQ_DVSOK3] = { | ||
62 | .reg = 2, | ||
63 | .mask = S5M8767_IRQ_DVSOK3_MASK, | ||
64 | }, | ||
65 | [S5M8767_IRQ_DVSOK4] = { | ||
66 | .reg = 2, | ||
67 | .mask = S5M8767_IRQ_DVSOK4_MASK, | ||
68 | }, | ||
69 | [S5M8767_IRQ_RTC60S] = { | ||
70 | .reg = 3, | ||
71 | .mask = S5M8767_IRQ_RTC60S_MASK, | ||
72 | }, | ||
73 | [S5M8767_IRQ_RTCA1] = { | ||
74 | .reg = 3, | ||
75 | .mask = S5M8767_IRQ_RTCA1_MASK, | ||
76 | }, | ||
77 | [S5M8767_IRQ_RTCA2] = { | ||
78 | .reg = 3, | ||
79 | .mask = S5M8767_IRQ_RTCA2_MASK, | ||
80 | }, | ||
81 | [S5M8767_IRQ_SMPL] = { | ||
82 | .reg = 3, | ||
83 | .mask = S5M8767_IRQ_SMPL_MASK, | ||
84 | }, | ||
85 | [S5M8767_IRQ_RTC1S] = { | ||
86 | .reg = 3, | ||
87 | .mask = S5M8767_IRQ_RTC1S_MASK, | ||
88 | }, | ||
89 | [S5M8767_IRQ_WTSR] = { | ||
90 | .reg = 3, | ||
91 | .mask = S5M8767_IRQ_WTSR_MASK, | ||
92 | }, | ||
93 | }; | ||
94 | |||
95 | static struct s5m_irq_data s5m8763_irqs[] = { | ||
96 | [S5M8763_IRQ_DCINF] = { | ||
97 | .reg = 1, | ||
98 | .mask = S5M8763_IRQ_DCINF_MASK, | ||
99 | }, | ||
100 | [S5M8763_IRQ_DCINR] = { | ||
101 | .reg = 1, | ||
102 | .mask = S5M8763_IRQ_DCINR_MASK, | ||
103 | }, | ||
104 | [S5M8763_IRQ_JIGF] = { | ||
105 | .reg = 1, | ||
106 | .mask = S5M8763_IRQ_JIGF_MASK, | ||
107 | }, | ||
108 | [S5M8763_IRQ_JIGR] = { | ||
109 | .reg = 1, | ||
110 | .mask = S5M8763_IRQ_JIGR_MASK, | ||
111 | }, | ||
112 | [S5M8763_IRQ_PWRONF] = { | ||
113 | .reg = 1, | ||
114 | .mask = S5M8763_IRQ_PWRONF_MASK, | ||
115 | }, | ||
116 | [S5M8763_IRQ_PWRONR] = { | ||
117 | .reg = 1, | ||
118 | .mask = S5M8763_IRQ_PWRONR_MASK, | ||
119 | }, | ||
120 | [S5M8763_IRQ_WTSREVNT] = { | ||
121 | .reg = 2, | ||
122 | .mask = S5M8763_IRQ_WTSREVNT_MASK, | ||
123 | }, | ||
124 | [S5M8763_IRQ_SMPLEVNT] = { | ||
125 | .reg = 2, | ||
126 | .mask = S5M8763_IRQ_SMPLEVNT_MASK, | ||
127 | }, | ||
128 | [S5M8763_IRQ_ALARM1] = { | ||
129 | .reg = 2, | ||
130 | .mask = S5M8763_IRQ_ALARM1_MASK, | ||
131 | }, | ||
132 | [S5M8763_IRQ_ALARM0] = { | ||
133 | .reg = 2, | ||
134 | .mask = S5M8763_IRQ_ALARM0_MASK, | ||
135 | }, | ||
136 | [S5M8763_IRQ_ONKEY1S] = { | ||
137 | .reg = 3, | ||
138 | .mask = S5M8763_IRQ_ONKEY1S_MASK, | ||
139 | }, | ||
140 | [S5M8763_IRQ_TOPOFFR] = { | ||
141 | .reg = 3, | ||
142 | .mask = S5M8763_IRQ_TOPOFFR_MASK, | ||
143 | }, | ||
144 | [S5M8763_IRQ_DCINOVPR] = { | ||
145 | .reg = 3, | ||
146 | .mask = S5M8763_IRQ_DCINOVPR_MASK, | ||
147 | }, | ||
148 | [S5M8763_IRQ_CHGRSTF] = { | ||
149 | .reg = 3, | ||
150 | .mask = S5M8763_IRQ_CHGRSTF_MASK, | ||
151 | }, | ||
152 | [S5M8763_IRQ_DONER] = { | ||
153 | .reg = 3, | ||
154 | .mask = S5M8763_IRQ_DONER_MASK, | ||
155 | }, | ||
156 | [S5M8763_IRQ_CHGFAULT] = { | ||
157 | .reg = 3, | ||
158 | .mask = S5M8763_IRQ_CHGFAULT_MASK, | ||
159 | }, | ||
160 | [S5M8763_IRQ_LOBAT1] = { | ||
161 | .reg = 4, | ||
162 | .mask = S5M8763_IRQ_LOBAT1_MASK, | ||
163 | }, | ||
164 | [S5M8763_IRQ_LOBAT2] = { | ||
165 | .reg = 4, | ||
166 | .mask = S5M8763_IRQ_LOBAT2_MASK, | ||
167 | }, | ||
168 | }; | ||
169 | |||
170 | static inline struct s5m_irq_data * | ||
171 | irq_to_s5m8767_irq(struct s5m87xx_dev *s5m87xx, int irq) | ||
172 | { | ||
173 | return &s5m8767_irqs[irq - s5m87xx->irq_base]; | ||
174 | } | ||
175 | |||
176 | static void s5m8767_irq_lock(struct irq_data *data) | ||
177 | { | ||
178 | struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); | ||
179 | |||
180 | mutex_lock(&s5m87xx->irqlock); | ||
181 | } | ||
182 | |||
183 | static void s5m8767_irq_sync_unlock(struct irq_data *data) | ||
184 | { | ||
185 | struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); | ||
186 | int i; | ||
187 | |||
188 | for (i = 0; i < ARRAY_SIZE(s5m87xx->irq_masks_cur); i++) { | ||
189 | if (s5m87xx->irq_masks_cur[i] != s5m87xx->irq_masks_cache[i]) { | ||
190 | s5m87xx->irq_masks_cache[i] = s5m87xx->irq_masks_cur[i]; | ||
191 | s5m_reg_write(s5m87xx, S5M8767_REG_INT1M + i, | ||
192 | s5m87xx->irq_masks_cur[i]); | ||
193 | } | ||
194 | } | ||
195 | |||
196 | mutex_unlock(&s5m87xx->irqlock); | ||
197 | } | ||
198 | |||
199 | static void s5m8767_irq_unmask(struct irq_data *data) | ||
200 | { | ||
201 | struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); | ||
202 | struct s5m_irq_data *irq_data = irq_to_s5m8767_irq(s5m87xx, | ||
203 | data->irq); | ||
204 | |||
205 | s5m87xx->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask; | ||
206 | } | ||
207 | |||
208 | static void s5m8767_irq_mask(struct irq_data *data) | ||
209 | { | ||
210 | struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); | ||
211 | struct s5m_irq_data *irq_data = irq_to_s5m8767_irq(s5m87xx, | ||
212 | data->irq); | ||
213 | |||
214 | s5m87xx->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask; | ||
215 | } | ||
216 | |||
217 | static struct irq_chip s5m8767_irq_chip = { | ||
218 | .name = "s5m8767", | ||
219 | .irq_bus_lock = s5m8767_irq_lock, | ||
220 | .irq_bus_sync_unlock = s5m8767_irq_sync_unlock, | ||
221 | .irq_mask = s5m8767_irq_mask, | ||
222 | .irq_unmask = s5m8767_irq_unmask, | ||
223 | }; | ||
224 | |||
225 | static inline struct s5m_irq_data * | ||
226 | irq_to_s5m8763_irq(struct s5m87xx_dev *s5m87xx, int irq) | ||
227 | { | ||
228 | return &s5m8763_irqs[irq - s5m87xx->irq_base]; | ||
229 | } | ||
230 | |||
231 | static void s5m8763_irq_lock(struct irq_data *data) | ||
232 | { | ||
233 | struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); | ||
234 | |||
235 | mutex_lock(&s5m87xx->irqlock); | ||
236 | } | ||
237 | |||
238 | static void s5m8763_irq_sync_unlock(struct irq_data *data) | ||
239 | { | ||
240 | struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); | ||
241 | int i; | ||
242 | |||
243 | for (i = 0; i < ARRAY_SIZE(s5m87xx->irq_masks_cur); i++) { | ||
244 | if (s5m87xx->irq_masks_cur[i] != s5m87xx->irq_masks_cache[i]) { | ||
245 | s5m87xx->irq_masks_cache[i] = s5m87xx->irq_masks_cur[i]; | ||
246 | s5m_reg_write(s5m87xx, S5M8763_REG_IRQM1 + i, | ||
247 | s5m87xx->irq_masks_cur[i]); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | mutex_unlock(&s5m87xx->irqlock); | ||
252 | } | ||
253 | |||
254 | static void s5m8763_irq_unmask(struct irq_data *data) | ||
255 | { | ||
256 | struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); | ||
257 | struct s5m_irq_data *irq_data = irq_to_s5m8763_irq(s5m87xx, | ||
258 | data->irq); | ||
259 | |||
260 | s5m87xx->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask; | ||
261 | } | ||
262 | |||
263 | static void s5m8763_irq_mask(struct irq_data *data) | ||
264 | { | ||
265 | struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); | ||
266 | struct s5m_irq_data *irq_data = irq_to_s5m8763_irq(s5m87xx, | ||
267 | data->irq); | ||
268 | |||
269 | s5m87xx->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask; | ||
270 | } | ||
271 | |||
272 | static struct irq_chip s5m8763_irq_chip = { | ||
273 | .name = "s5m8763", | ||
274 | .irq_bus_lock = s5m8763_irq_lock, | ||
275 | .irq_bus_sync_unlock = s5m8763_irq_sync_unlock, | ||
276 | .irq_mask = s5m8763_irq_mask, | ||
277 | .irq_unmask = s5m8763_irq_unmask, | ||
278 | }; | ||
279 | |||
280 | |||
281 | static irqreturn_t s5m8767_irq_thread(int irq, void *data) | ||
282 | { | ||
283 | struct s5m87xx_dev *s5m87xx = data; | ||
284 | u8 irq_reg[NUM_IRQ_REGS-1]; | ||
285 | int ret; | ||
286 | int i; | ||
287 | |||
288 | |||
289 | ret = s5m_bulk_read(s5m87xx, S5M8767_REG_INT1, | ||
290 | NUM_IRQ_REGS - 1, irq_reg); | ||
291 | if (ret < 0) { | ||
292 | dev_err(s5m87xx->dev, "Failed to read interrupt register: %d\n", | ||
293 | ret); | ||
294 | return IRQ_NONE; | ||
295 | } | ||
296 | |||
297 | for (i = 0; i < NUM_IRQ_REGS - 1; i++) | ||
298 | irq_reg[i] &= ~s5m87xx->irq_masks_cur[i]; | ||
299 | |||
300 | for (i = 0; i < S5M8767_IRQ_NR; i++) { | ||
301 | if (irq_reg[s5m8767_irqs[i].reg - 1] & s5m8767_irqs[i].mask) | ||
302 | handle_nested_irq(s5m87xx->irq_base + i); | ||
303 | } | ||
304 | |||
305 | return IRQ_HANDLED; | ||
306 | } | ||
307 | |||
308 | static irqreturn_t s5m8763_irq_thread(int irq, void *data) | ||
309 | { | ||
310 | struct s5m87xx_dev *s5m87xx = data; | ||
311 | u8 irq_reg[NUM_IRQ_REGS]; | ||
312 | int ret; | ||
313 | int i; | ||
314 | |||
315 | ret = s5m_bulk_read(s5m87xx, S5M8763_REG_IRQ1, | ||
316 | NUM_IRQ_REGS, irq_reg); | ||
317 | if (ret < 0) { | ||
318 | dev_err(s5m87xx->dev, "Failed to read interrupt register: %d\n", | ||
319 | ret); | ||
320 | return IRQ_NONE; | ||
321 | } | ||
322 | |||
323 | for (i = 0; i < NUM_IRQ_REGS; i++) | ||
324 | irq_reg[i] &= ~s5m87xx->irq_masks_cur[i]; | ||
325 | |||
326 | for (i = 0; i < S5M8763_IRQ_NR; i++) { | ||
327 | if (irq_reg[s5m8763_irqs[i].reg - 1] & s5m8763_irqs[i].mask) | ||
328 | handle_nested_irq(s5m87xx->irq_base + i); | ||
329 | } | ||
330 | |||
331 | return IRQ_HANDLED; | ||
332 | } | ||
333 | |||
334 | int s5m_irq_resume(struct s5m87xx_dev *s5m87xx) | ||
335 | { | ||
336 | if (s5m87xx->irq && s5m87xx->irq_base){ | ||
337 | switch (s5m87xx->device_type) { | ||
338 | case S5M8763X: | ||
339 | s5m8763_irq_thread(s5m87xx->irq_base, s5m87xx); | ||
340 | break; | ||
341 | case S5M8767X: | ||
342 | s5m8767_irq_thread(s5m87xx->irq_base, s5m87xx); | ||
343 | break; | ||
344 | default: | ||
345 | break; | ||
346 | |||
347 | } | ||
348 | } | ||
349 | return 0; | ||
350 | } | ||
351 | |||
352 | int s5m_irq_init(struct s5m87xx_dev *s5m87xx) | ||
353 | { | ||
354 | int i; | ||
355 | int cur_irq; | ||
356 | int ret = 0; | ||
357 | int type = s5m87xx->device_type; | ||
358 | |||
359 | if (!s5m87xx->irq) { | ||
360 | dev_warn(s5m87xx->dev, | ||
361 | "No interrupt specified, no interrupts\n"); | ||
362 | s5m87xx->irq_base = 0; | ||
363 | return 0; | ||
364 | } | ||
365 | |||
366 | if (!s5m87xx->irq_base) { | ||
367 | dev_err(s5m87xx->dev, | ||
368 | "No interrupt base specified, no interrupts\n"); | ||
369 | return 0; | ||
370 | } | ||
371 | |||
372 | mutex_init(&s5m87xx->irqlock); | ||
373 | |||
374 | switch (type) { | ||
375 | case S5M8763X: | ||
376 | for (i = 0; i < NUM_IRQ_REGS; i++) { | ||
377 | s5m87xx->irq_masks_cur[i] = 0xff; | ||
378 | s5m87xx->irq_masks_cache[i] = 0xff; | ||
379 | s5m_reg_write(s5m87xx, S5M8763_REG_IRQM1 + i, | ||
380 | 0xff); | ||
381 | } | ||
382 | |||
383 | s5m_reg_write(s5m87xx, S5M8763_REG_STATUSM1, 0xff); | ||
384 | s5m_reg_write(s5m87xx, S5M8763_REG_STATUSM2, 0xff); | ||
385 | |||
386 | for (i = 0; i < S5M8763_IRQ_NR; i++) { | ||
387 | cur_irq = i + s5m87xx->irq_base; | ||
388 | irq_set_chip_data(cur_irq, s5m87xx); | ||
389 | irq_set_chip_and_handler(cur_irq, &s5m8763_irq_chip, | ||
390 | handle_edge_irq); | ||
391 | irq_set_nested_thread(cur_irq, 1); | ||
392 | #ifdef CONFIG_ARM | ||
393 | set_irq_flags(cur_irq, IRQF_VALID); | ||
394 | #else | ||
395 | irq_set_noprobe(cur_irq); | ||
396 | #endif | ||
397 | } | ||
398 | |||
399 | ret = request_threaded_irq(s5m87xx->irq, NULL, | ||
400 | s5m8763_irq_thread, | ||
401 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | ||
402 | "s5m87xx-irq", s5m87xx); | ||
403 | if (ret) { | ||
404 | dev_err(s5m87xx->dev, "Failed to request IRQ %d: %d\n", | ||
405 | s5m87xx->irq, ret); | ||
406 | return ret; | ||
407 | } | ||
408 | break; | ||
409 | case S5M8767X: | ||
410 | for (i = 0; i < NUM_IRQ_REGS - 1; i++) { | ||
411 | s5m87xx->irq_masks_cur[i] = 0xff; | ||
412 | s5m87xx->irq_masks_cache[i] = 0xff; | ||
413 | s5m_reg_write(s5m87xx, S5M8767_REG_INT1M + i, | ||
414 | 0xff); | ||
415 | } | ||
416 | for (i = 0; i < S5M8767_IRQ_NR; i++) { | ||
417 | cur_irq = i + s5m87xx->irq_base; | ||
418 | irq_set_chip_data(cur_irq, s5m87xx); | ||
419 | if (ret) { | ||
420 | dev_err(s5m87xx->dev, | ||
421 | "Failed to irq_set_chip_data %d: %d\n", | ||
422 | s5m87xx->irq, ret); | ||
423 | return ret; | ||
424 | } | ||
425 | |||
426 | irq_set_chip_and_handler(cur_irq, &s5m8767_irq_chip, | ||
427 | handle_edge_irq); | ||
428 | irq_set_nested_thread(cur_irq, 1); | ||
429 | #ifdef CONFIG_ARM | ||
430 | set_irq_flags(cur_irq, IRQF_VALID); | ||
431 | #else | ||
432 | irq_set_noprobe(cur_irq); | ||
433 | #endif | ||
434 | } | ||
435 | |||
436 | ret = request_threaded_irq(s5m87xx->irq, NULL, | ||
437 | s5m8767_irq_thread, | ||
438 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | ||
439 | "s5m87xx-irq", s5m87xx); | ||
440 | if (ret) { | ||
441 | dev_err(s5m87xx->dev, "Failed to request IRQ %d: %d\n", | ||
442 | s5m87xx->irq, ret); | ||
443 | return ret; | ||
444 | } | ||
445 | break; | ||
446 | default: | ||
447 | break; | ||
448 | } | ||
449 | |||
450 | if (!s5m87xx->ono) | ||
451 | return 0; | ||
452 | |||
453 | switch (type) { | ||
454 | case S5M8763X: | ||
455 | ret = request_threaded_irq(s5m87xx->ono, NULL, | ||
456 | s5m8763_irq_thread, | ||
457 | IRQF_TRIGGER_FALLING | | ||
458 | IRQF_TRIGGER_RISING | | ||
459 | IRQF_ONESHOT, "s5m87xx-ono", | ||
460 | s5m87xx); | ||
461 | break; | ||
462 | case S5M8767X: | ||
463 | ret = request_threaded_irq(s5m87xx->ono, NULL, | ||
464 | s5m8767_irq_thread, | ||
465 | IRQF_TRIGGER_FALLING | | ||
466 | IRQF_TRIGGER_RISING | | ||
467 | IRQF_ONESHOT, "s5m87xx-ono", s5m87xx); | ||
468 | break; | ||
469 | default: | ||
470 | break; | ||
471 | } | ||
472 | |||
473 | if (ret) | ||
474 | dev_err(s5m87xx->dev, "Failed to request IRQ %d: %d\n", | ||
475 | s5m87xx->ono, ret); | ||
476 | |||
477 | return 0; | ||
478 | } | ||
479 | |||
480 | void s5m_irq_exit(struct s5m87xx_dev *s5m87xx) | ||
481 | { | ||
482 | if (s5m87xx->ono) | ||
483 | free_irq(s5m87xx->ono, s5m87xx); | ||
484 | |||
485 | if (s5m87xx->irq) | ||
486 | free_irq(s5m87xx->irq, s5m87xx); | ||
487 | } | ||
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index df3702c1756d..f4d86117f44a 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c | |||
@@ -1720,7 +1720,7 @@ static int sm501_plat_remove(struct platform_device *dev) | |||
1720 | return 0; | 1720 | return 0; |
1721 | } | 1721 | } |
1722 | 1722 | ||
1723 | static struct pci_device_id sm501_pci_tbl[] = { | 1723 | static DEFINE_PCI_DEVICE_TABLE(sm501_pci_tbl) = { |
1724 | { 0x126f, 0x0501, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | 1724 | { 0x126f, 0x0501, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, |
1725 | { 0, }, | 1725 | { 0, }, |
1726 | }; | 1726 | }; |
diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c new file mode 100644 index 000000000000..373f423b1181 --- /dev/null +++ b/drivers/mfd/stmpe-i2c.c | |||
@@ -0,0 +1,109 @@ | |||
1 | /* | ||
2 | * ST Microelectronics MFD: stmpe's i2c client specific driver | ||
3 | * | ||
4 | * Copyright (C) ST-Ericsson SA 2010 | ||
5 | * Copyright (C) ST Microelectronics SA 2011 | ||
6 | * | ||
7 | * License Terms: GNU General Public License, version 2 | ||
8 | * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson | ||
9 | * Author: Viresh Kumar <viresh.kumar@st.com> for ST Microelectronics | ||
10 | */ | ||
11 | |||
12 | #include <linux/i2c.h> | ||
13 | #include <linux/interrupt.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/types.h> | ||
17 | #include "stmpe.h" | ||
18 | |||
19 | static int i2c_reg_read(struct stmpe *stmpe, u8 reg) | ||
20 | { | ||
21 | struct i2c_client *i2c = stmpe->client; | ||
22 | |||
23 | return i2c_smbus_read_byte_data(i2c, reg); | ||
24 | } | ||
25 | |||
26 | static int i2c_reg_write(struct stmpe *stmpe, u8 reg, u8 val) | ||
27 | { | ||
28 | struct i2c_client *i2c = stmpe->client; | ||
29 | |||
30 | return i2c_smbus_write_byte_data(i2c, reg, val); | ||
31 | } | ||
32 | |||
33 | static int i2c_block_read(struct stmpe *stmpe, u8 reg, u8 length, u8 *values) | ||
34 | { | ||
35 | struct i2c_client *i2c = stmpe->client; | ||
36 | |||
37 | return i2c_smbus_read_i2c_block_data(i2c, reg, length, values); | ||
38 | } | ||
39 | |||
40 | static int i2c_block_write(struct stmpe *stmpe, u8 reg, u8 length, | ||
41 | const u8 *values) | ||
42 | { | ||
43 | struct i2c_client *i2c = stmpe->client; | ||
44 | |||
45 | return i2c_smbus_write_i2c_block_data(i2c, reg, length, values); | ||
46 | } | ||
47 | |||
48 | static struct stmpe_client_info i2c_ci = { | ||
49 | .read_byte = i2c_reg_read, | ||
50 | .write_byte = i2c_reg_write, | ||
51 | .read_block = i2c_block_read, | ||
52 | .write_block = i2c_block_write, | ||
53 | }; | ||
54 | |||
55 | static int __devinit | ||
56 | stmpe_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | ||
57 | { | ||
58 | i2c_ci.data = (void *)id; | ||
59 | i2c_ci.irq = i2c->irq; | ||
60 | i2c_ci.client = i2c; | ||
61 | i2c_ci.dev = &i2c->dev; | ||
62 | |||
63 | return stmpe_probe(&i2c_ci, id->driver_data); | ||
64 | } | ||
65 | |||
66 | static int __devexit stmpe_i2c_remove(struct i2c_client *i2c) | ||
67 | { | ||
68 | struct stmpe *stmpe = dev_get_drvdata(&i2c->dev); | ||
69 | |||
70 | return stmpe_remove(stmpe); | ||
71 | } | ||
72 | |||
73 | static const struct i2c_device_id stmpe_i2c_id[] = { | ||
74 | { "stmpe610", STMPE610 }, | ||
75 | { "stmpe801", STMPE801 }, | ||
76 | { "stmpe811", STMPE811 }, | ||
77 | { "stmpe1601", STMPE1601 }, | ||
78 | { "stmpe2401", STMPE2401 }, | ||
79 | { "stmpe2403", STMPE2403 }, | ||
80 | { } | ||
81 | }; | ||
82 | MODULE_DEVICE_TABLE(i2c, stmpe_id); | ||
83 | |||
84 | static struct i2c_driver stmpe_i2c_driver = { | ||
85 | .driver.name = "stmpe-i2c", | ||
86 | .driver.owner = THIS_MODULE, | ||
87 | #ifdef CONFIG_PM | ||
88 | .driver.pm = &stmpe_dev_pm_ops, | ||
89 | #endif | ||
90 | .probe = stmpe_i2c_probe, | ||
91 | .remove = __devexit_p(stmpe_i2c_remove), | ||
92 | .id_table = stmpe_i2c_id, | ||
93 | }; | ||
94 | |||
95 | static int __init stmpe_init(void) | ||
96 | { | ||
97 | return i2c_add_driver(&stmpe_i2c_driver); | ||
98 | } | ||
99 | subsys_initcall(stmpe_init); | ||
100 | |||
101 | static void __exit stmpe_exit(void) | ||
102 | { | ||
103 | i2c_del_driver(&stmpe_i2c_driver); | ||
104 | } | ||
105 | module_exit(stmpe_exit); | ||
106 | |||
107 | MODULE_LICENSE("GPL v2"); | ||
108 | MODULE_DESCRIPTION("STMPE MFD I2C Interface Driver"); | ||
109 | MODULE_AUTHOR("Rabin Vincent <rabin.vincent@stericsson.com>"); | ||
diff --git a/drivers/mfd/stmpe-spi.c b/drivers/mfd/stmpe-spi.c new file mode 100644 index 000000000000..b58c43c7ea93 --- /dev/null +++ b/drivers/mfd/stmpe-spi.c | |||
@@ -0,0 +1,150 @@ | |||
1 | /* | ||
2 | * ST Microelectronics MFD: stmpe's spi client specific driver | ||
3 | * | ||
4 | * Copyright (C) ST Microelectronics SA 2011 | ||
5 | * | ||
6 | * License Terms: GNU General Public License, version 2 | ||
7 | * Author: Viresh Kumar <viresh.kumar@st.com> for ST Microelectronics | ||
8 | */ | ||
9 | |||
10 | #include <linux/spi/spi.h> | ||
11 | #include <linux/interrupt.h> | ||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/types.h> | ||
15 | #include "stmpe.h" | ||
16 | |||
17 | #define READ_CMD (1 << 7) | ||
18 | |||
19 | static int spi_reg_read(struct stmpe *stmpe, u8 reg) | ||
20 | { | ||
21 | struct spi_device *spi = stmpe->client; | ||
22 | int status = spi_w8r16(spi, reg | READ_CMD); | ||
23 | |||
24 | return (status < 0) ? status : status >> 8; | ||
25 | } | ||
26 | |||
27 | static int spi_reg_write(struct stmpe *stmpe, u8 reg, u8 val) | ||
28 | { | ||
29 | struct spi_device *spi = stmpe->client; | ||
30 | u16 cmd = (val << 8) | reg; | ||
31 | |||
32 | return spi_write(spi, (const u8 *)&cmd, 2); | ||
33 | } | ||
34 | |||
35 | static int spi_block_read(struct stmpe *stmpe, u8 reg, u8 length, u8 *values) | ||
36 | { | ||
37 | int ret, i; | ||
38 | |||
39 | for (i = 0; i < length; i++) { | ||
40 | ret = spi_reg_read(stmpe, reg + i); | ||
41 | if (ret < 0) | ||
42 | return ret; | ||
43 | *(values + i) = ret; | ||
44 | } | ||
45 | |||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | static int spi_block_write(struct stmpe *stmpe, u8 reg, u8 length, | ||
50 | const u8 *values) | ||
51 | { | ||
52 | int ret = 0, i; | ||
53 | |||
54 | for (i = length; i > 0; i--, reg++) { | ||
55 | ret = spi_reg_write(stmpe, reg, *(values + i - 1)); | ||
56 | if (ret < 0) | ||
57 | return ret; | ||
58 | } | ||
59 | |||
60 | return ret; | ||
61 | } | ||
62 | |||
63 | static void spi_init(struct stmpe *stmpe) | ||
64 | { | ||
65 | struct spi_device *spi = stmpe->client; | ||
66 | |||
67 | spi->bits_per_word = 8; | ||
68 | |||
69 | /* This register is only present for stmpe811 */ | ||
70 | if (stmpe->variant->id_val == 0x0811) | ||
71 | spi_reg_write(stmpe, STMPE811_REG_SPI_CFG, spi->mode); | ||
72 | |||
73 | if (spi_setup(spi) < 0) | ||
74 | dev_dbg(&spi->dev, "spi_setup failed\n"); | ||
75 | } | ||
76 | |||
77 | static struct stmpe_client_info spi_ci = { | ||
78 | .read_byte = spi_reg_read, | ||
79 | .write_byte = spi_reg_write, | ||
80 | .read_block = spi_block_read, | ||
81 | .write_block = spi_block_write, | ||
82 | .init = spi_init, | ||
83 | }; | ||
84 | |||
85 | static int __devinit | ||
86 | stmpe_spi_probe(struct spi_device *spi) | ||
87 | { | ||
88 | const struct spi_device_id *id = spi_get_device_id(spi); | ||
89 | |||
90 | /* don't exceed max specified rate - 1MHz - Limitation of STMPE */ | ||
91 | if (spi->max_speed_hz > 1000000) { | ||
92 | dev_dbg(&spi->dev, "f(sample) %d KHz?\n", | ||
93 | (spi->max_speed_hz/1000)); | ||
94 | return -EINVAL; | ||
95 | } | ||
96 | |||
97 | spi_ci.irq = spi->irq; | ||
98 | spi_ci.client = spi; | ||
99 | spi_ci.dev = &spi->dev; | ||
100 | |||
101 | return stmpe_probe(&spi_ci, id->driver_data); | ||
102 | } | ||
103 | |||
104 | static int __devexit stmpe_spi_remove(struct spi_device *spi) | ||
105 | { | ||
106 | struct stmpe *stmpe = dev_get_drvdata(&spi->dev); | ||
107 | |||
108 | return stmpe_remove(stmpe); | ||
109 | } | ||
110 | |||
111 | static const struct spi_device_id stmpe_spi_id[] = { | ||
112 | { "stmpe610", STMPE610 }, | ||
113 | { "stmpe801", STMPE801 }, | ||
114 | { "stmpe811", STMPE811 }, | ||
115 | { "stmpe1601", STMPE1601 }, | ||
116 | { "stmpe2401", STMPE2401 }, | ||
117 | { "stmpe2403", STMPE2403 }, | ||
118 | { } | ||
119 | }; | ||
120 | MODULE_DEVICE_TABLE(spi, stmpe_id); | ||
121 | |||
122 | static struct spi_driver stmpe_spi_driver = { | ||
123 | .driver = { | ||
124 | .name = "stmpe-spi", | ||
125 | .bus = &spi_bus_type, | ||
126 | .owner = THIS_MODULE, | ||
127 | #ifdef CONFIG_PM | ||
128 | .pm = &stmpe_dev_pm_ops, | ||
129 | #endif | ||
130 | }, | ||
131 | .probe = stmpe_spi_probe, | ||
132 | .remove = __devexit_p(stmpe_spi_remove), | ||
133 | .id_table = stmpe_spi_id, | ||
134 | }; | ||
135 | |||
136 | static int __init stmpe_init(void) | ||
137 | { | ||
138 | return spi_register_driver(&stmpe_spi_driver); | ||
139 | } | ||
140 | subsys_initcall(stmpe_init); | ||
141 | |||
142 | static void __exit stmpe_exit(void) | ||
143 | { | ||
144 | spi_unregister_driver(&stmpe_spi_driver); | ||
145 | } | ||
146 | module_exit(stmpe_exit); | ||
147 | |||
148 | MODULE_LICENSE("GPL v2"); | ||
149 | MODULE_DESCRIPTION("STMPE MFD SPI Interface Driver"); | ||
150 | MODULE_AUTHOR("Viresh Kumar <viresh.kumar@st.com>"); | ||
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index 2963689cf45c..e07947e56b2a 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c | |||
@@ -1,18 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * ST Microelectronics MFD: stmpe's driver | ||
3 | * | ||
2 | * Copyright (C) ST-Ericsson SA 2010 | 4 | * Copyright (C) ST-Ericsson SA 2010 |
3 | * | 5 | * |
4 | * License Terms: GNU General Public License, version 2 | 6 | * License Terms: GNU General Public License, version 2 |
5 | * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson | 7 | * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson |
6 | */ | 8 | */ |
7 | 9 | ||
10 | #include <linux/gpio.h> | ||
11 | #include <linux/export.h> | ||
8 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
9 | #include <linux/module.h> | ||
10 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
11 | #include <linux/irq.h> | 14 | #include <linux/irq.h> |
15 | #include <linux/pm.h> | ||
12 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
13 | #include <linux/i2c.h> | ||
14 | #include <linux/mfd/core.h> | 17 | #include <linux/mfd/core.h> |
15 | #include <linux/mfd/stmpe.h> | ||
16 | #include "stmpe.h" | 18 | #include "stmpe.h" |
17 | 19 | ||
18 | static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks) | 20 | static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks) |
@@ -29,10 +31,9 @@ static int __stmpe_reg_read(struct stmpe *stmpe, u8 reg) | |||
29 | { | 31 | { |
30 | int ret; | 32 | int ret; |
31 | 33 | ||
32 | ret = i2c_smbus_read_byte_data(stmpe->i2c, reg); | 34 | ret = stmpe->ci->read_byte(stmpe, reg); |
33 | if (ret < 0) | 35 | if (ret < 0) |
34 | dev_err(stmpe->dev, "failed to read reg %#x: %d\n", | 36 | dev_err(stmpe->dev, "failed to read reg %#x: %d\n", reg, ret); |
35 | reg, ret); | ||
36 | 37 | ||
37 | dev_vdbg(stmpe->dev, "rd: reg %#x => data %#x\n", reg, ret); | 38 | dev_vdbg(stmpe->dev, "rd: reg %#x => data %#x\n", reg, ret); |
38 | 39 | ||
@@ -45,10 +46,9 @@ static int __stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 val) | |||
45 | 46 | ||
46 | dev_vdbg(stmpe->dev, "wr: reg %#x <= %#x\n", reg, val); | 47 | dev_vdbg(stmpe->dev, "wr: reg %#x <= %#x\n", reg, val); |
47 | 48 | ||
48 | ret = i2c_smbus_write_byte_data(stmpe->i2c, reg, val); | 49 | ret = stmpe->ci->write_byte(stmpe, reg, val); |
49 | if (ret < 0) | 50 | if (ret < 0) |
50 | dev_err(stmpe->dev, "failed to write reg %#x: %d\n", | 51 | dev_err(stmpe->dev, "failed to write reg %#x: %d\n", reg, ret); |
51 | reg, ret); | ||
52 | 52 | ||
53 | return ret; | 53 | return ret; |
54 | } | 54 | } |
@@ -72,10 +72,9 @@ static int __stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length, | |||
72 | { | 72 | { |
73 | int ret; | 73 | int ret; |
74 | 74 | ||
75 | ret = i2c_smbus_read_i2c_block_data(stmpe->i2c, reg, length, values); | 75 | ret = stmpe->ci->read_block(stmpe, reg, length, values); |
76 | if (ret < 0) | 76 | if (ret < 0) |
77 | dev_err(stmpe->dev, "failed to read regs %#x: %d\n", | 77 | dev_err(stmpe->dev, "failed to read regs %#x: %d\n", reg, ret); |
78 | reg, ret); | ||
79 | 78 | ||
80 | dev_vdbg(stmpe->dev, "rd: reg %#x (%d) => ret %#x\n", reg, length, ret); | 79 | dev_vdbg(stmpe->dev, "rd: reg %#x (%d) => ret %#x\n", reg, length, ret); |
81 | stmpe_dump_bytes("stmpe rd: ", values, length); | 80 | stmpe_dump_bytes("stmpe rd: ", values, length); |
@@ -91,11 +90,9 @@ static int __stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length, | |||
91 | dev_vdbg(stmpe->dev, "wr: regs %#x (%d)\n", reg, length); | 90 | dev_vdbg(stmpe->dev, "wr: regs %#x (%d)\n", reg, length); |
92 | stmpe_dump_bytes("stmpe wr: ", values, length); | 91 | stmpe_dump_bytes("stmpe wr: ", values, length); |
93 | 92 | ||
94 | ret = i2c_smbus_write_i2c_block_data(stmpe->i2c, reg, length, | 93 | ret = stmpe->ci->write_block(stmpe, reg, length, values); |
95 | values); | ||
96 | if (ret < 0) | 94 | if (ret < 0) |
97 | dev_err(stmpe->dev, "failed to write regs %#x: %d\n", | 95 | dev_err(stmpe->dev, "failed to write regs %#x: %d\n", reg, ret); |
98 | reg, ret); | ||
99 | 96 | ||
100 | return ret; | 97 | return ret; |
101 | } | 98 | } |
@@ -245,12 +242,14 @@ int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, enum stmpe_block block) | |||
245 | u8 regaddr = stmpe->regs[STMPE_IDX_GPAFR_U_MSB]; | 242 | u8 regaddr = stmpe->regs[STMPE_IDX_GPAFR_U_MSB]; |
246 | int af_bits = variant->af_bits; | 243 | int af_bits = variant->af_bits; |
247 | int numregs = DIV_ROUND_UP(stmpe->num_gpios * af_bits, 8); | 244 | int numregs = DIV_ROUND_UP(stmpe->num_gpios * af_bits, 8); |
248 | int afperreg = 8 / af_bits; | ||
249 | int mask = (1 << af_bits) - 1; | 245 | int mask = (1 << af_bits) - 1; |
250 | u8 regs[numregs]; | 246 | u8 regs[numregs]; |
251 | int af; | 247 | int af, afperreg, ret; |
252 | int ret; | 248 | |
249 | if (!variant->get_altfunc) | ||
250 | return 0; | ||
253 | 251 | ||
252 | afperreg = 8 / af_bits; | ||
254 | mutex_lock(&stmpe->lock); | 253 | mutex_lock(&stmpe->lock); |
255 | 254 | ||
256 | ret = __stmpe_enable(stmpe, STMPE_BLOCK_GPIO); | 255 | ret = __stmpe_enable(stmpe, STMPE_BLOCK_GPIO); |
@@ -325,7 +324,51 @@ static struct mfd_cell stmpe_keypad_cell = { | |||
325 | }; | 324 | }; |
326 | 325 | ||
327 | /* | 326 | /* |
328 | * Touchscreen (STMPE811) | 327 | * STMPE801 |
328 | */ | ||
329 | static const u8 stmpe801_regs[] = { | ||
330 | [STMPE_IDX_CHIP_ID] = STMPE801_REG_CHIP_ID, | ||
331 | [STMPE_IDX_ICR_LSB] = STMPE801_REG_SYS_CTRL, | ||
332 | [STMPE_IDX_GPMR_LSB] = STMPE801_REG_GPIO_MP_STA, | ||
333 | [STMPE_IDX_GPSR_LSB] = STMPE801_REG_GPIO_SET_PIN, | ||
334 | [STMPE_IDX_GPCR_LSB] = STMPE801_REG_GPIO_SET_PIN, | ||
335 | [STMPE_IDX_GPDR_LSB] = STMPE801_REG_GPIO_DIR, | ||
336 | [STMPE_IDX_IEGPIOR_LSB] = STMPE801_REG_GPIO_INT_EN, | ||
337 | [STMPE_IDX_ISGPIOR_MSB] = STMPE801_REG_GPIO_INT_STA, | ||
338 | |||
339 | }; | ||
340 | |||
341 | static struct stmpe_variant_block stmpe801_blocks[] = { | ||
342 | { | ||
343 | .cell = &stmpe_gpio_cell, | ||
344 | .irq = 0, | ||
345 | .block = STMPE_BLOCK_GPIO, | ||
346 | }, | ||
347 | }; | ||
348 | |||
349 | static int stmpe801_enable(struct stmpe *stmpe, unsigned int blocks, | ||
350 | bool enable) | ||
351 | { | ||
352 | if (blocks & STMPE_BLOCK_GPIO) | ||
353 | return 0; | ||
354 | else | ||
355 | return -EINVAL; | ||
356 | } | ||
357 | |||
358 | static struct stmpe_variant_info stmpe801 = { | ||
359 | .name = "stmpe801", | ||
360 | .id_val = STMPE801_ID, | ||
361 | .id_mask = 0xffff, | ||
362 | .num_gpios = 8, | ||
363 | .regs = stmpe801_regs, | ||
364 | .blocks = stmpe801_blocks, | ||
365 | .num_blocks = ARRAY_SIZE(stmpe801_blocks), | ||
366 | .num_irqs = STMPE801_NR_INTERNAL_IRQS, | ||
367 | .enable = stmpe801_enable, | ||
368 | }; | ||
369 | |||
370 | /* | ||
371 | * Touchscreen (STMPE811 or STMPE610) | ||
329 | */ | 372 | */ |
330 | 373 | ||
331 | static struct resource stmpe_ts_resources[] = { | 374 | static struct resource stmpe_ts_resources[] = { |
@@ -350,7 +393,7 @@ static struct mfd_cell stmpe_ts_cell = { | |||
350 | }; | 393 | }; |
351 | 394 | ||
352 | /* | 395 | /* |
353 | * STMPE811 | 396 | * STMPE811 or STMPE610 |
354 | */ | 397 | */ |
355 | 398 | ||
356 | static const u8 stmpe811_regs[] = { | 399 | static const u8 stmpe811_regs[] = { |
@@ -421,6 +464,21 @@ static struct stmpe_variant_info stmpe811 = { | |||
421 | .get_altfunc = stmpe811_get_altfunc, | 464 | .get_altfunc = stmpe811_get_altfunc, |
422 | }; | 465 | }; |
423 | 466 | ||
467 | /* Similar to 811, except number of gpios */ | ||
468 | static struct stmpe_variant_info stmpe610 = { | ||
469 | .name = "stmpe610", | ||
470 | .id_val = 0x0811, | ||
471 | .id_mask = 0xffff, | ||
472 | .num_gpios = 6, | ||
473 | .af_bits = 1, | ||
474 | .regs = stmpe811_regs, | ||
475 | .blocks = stmpe811_blocks, | ||
476 | .num_blocks = ARRAY_SIZE(stmpe811_blocks), | ||
477 | .num_irqs = STMPE811_NR_INTERNAL_IRQS, | ||
478 | .enable = stmpe811_enable, | ||
479 | .get_altfunc = stmpe811_get_altfunc, | ||
480 | }; | ||
481 | |||
424 | /* | 482 | /* |
425 | * STMPE1601 | 483 | * STMPE1601 |
426 | */ | 484 | */ |
@@ -655,6 +713,8 @@ static struct stmpe_variant_info stmpe2403 = { | |||
655 | }; | 713 | }; |
656 | 714 | ||
657 | static struct stmpe_variant_info *stmpe_variant_info[] = { | 715 | static struct stmpe_variant_info *stmpe_variant_info[] = { |
716 | [STMPE610] = &stmpe610, | ||
717 | [STMPE801] = &stmpe801, | ||
658 | [STMPE811] = &stmpe811, | 718 | [STMPE811] = &stmpe811, |
659 | [STMPE1601] = &stmpe1601, | 719 | [STMPE1601] = &stmpe1601, |
660 | [STMPE2401] = &stmpe2401, | 720 | [STMPE2401] = &stmpe2401, |
@@ -671,6 +731,11 @@ static irqreturn_t stmpe_irq(int irq, void *data) | |||
671 | int ret; | 731 | int ret; |
672 | int i; | 732 | int i; |
673 | 733 | ||
734 | if (variant->id_val == STMPE801_ID) { | ||
735 | handle_nested_irq(stmpe->irq_base); | ||
736 | return IRQ_HANDLED; | ||
737 | } | ||
738 | |||
674 | ret = stmpe_block_read(stmpe, israddr, num, isr); | 739 | ret = stmpe_block_read(stmpe, israddr, num, isr); |
675 | if (ret < 0) | 740 | if (ret < 0) |
676 | return IRQ_NONE; | 741 | return IRQ_NONE; |
@@ -757,14 +822,17 @@ static struct irq_chip stmpe_irq_chip = { | |||
757 | 822 | ||
758 | static int __devinit stmpe_irq_init(struct stmpe *stmpe) | 823 | static int __devinit stmpe_irq_init(struct stmpe *stmpe) |
759 | { | 824 | { |
825 | struct irq_chip *chip = NULL; | ||
760 | int num_irqs = stmpe->variant->num_irqs; | 826 | int num_irqs = stmpe->variant->num_irqs; |
761 | int base = stmpe->irq_base; | 827 | int base = stmpe->irq_base; |
762 | int irq; | 828 | int irq; |
763 | 829 | ||
830 | if (stmpe->variant->id_val != STMPE801_ID) | ||
831 | chip = &stmpe_irq_chip; | ||
832 | |||
764 | for (irq = base; irq < base + num_irqs; irq++) { | 833 | for (irq = base; irq < base + num_irqs; irq++) { |
765 | irq_set_chip_data(irq, stmpe); | 834 | irq_set_chip_data(irq, stmpe); |
766 | irq_set_chip_and_handler(irq, &stmpe_irq_chip, | 835 | irq_set_chip_and_handler(irq, chip, handle_edge_irq); |
767 | handle_edge_irq); | ||
768 | irq_set_nested_thread(irq, 1); | 836 | irq_set_nested_thread(irq, 1); |
769 | #ifdef CONFIG_ARM | 837 | #ifdef CONFIG_ARM |
770 | set_irq_flags(irq, IRQF_VALID); | 838 | set_irq_flags(irq, IRQF_VALID); |
@@ -796,7 +864,7 @@ static int __devinit stmpe_chip_init(struct stmpe *stmpe) | |||
796 | unsigned int irq_trigger = stmpe->pdata->irq_trigger; | 864 | unsigned int irq_trigger = stmpe->pdata->irq_trigger; |
797 | int autosleep_timeout = stmpe->pdata->autosleep_timeout; | 865 | int autosleep_timeout = stmpe->pdata->autosleep_timeout; |
798 | struct stmpe_variant_info *variant = stmpe->variant; | 866 | struct stmpe_variant_info *variant = stmpe->variant; |
799 | u8 icr = STMPE_ICR_LSB_GIM; | 867 | u8 icr; |
800 | unsigned int id; | 868 | unsigned int id; |
801 | u8 data[2]; | 869 | u8 data[2]; |
802 | int ret; | 870 | int ret; |
@@ -819,16 +887,32 @@ static int __devinit stmpe_chip_init(struct stmpe *stmpe) | |||
819 | if (ret) | 887 | if (ret) |
820 | return ret; | 888 | return ret; |
821 | 889 | ||
822 | if (irq_trigger == IRQF_TRIGGER_FALLING || | 890 | if (id == STMPE801_ID) |
823 | irq_trigger == IRQF_TRIGGER_RISING) | 891 | icr = STMPE801_REG_SYS_CTRL_INT_EN; |
824 | icr |= STMPE_ICR_LSB_EDGE; | 892 | else |
893 | icr = STMPE_ICR_LSB_GIM; | ||
894 | |||
895 | /* STMPE801 doesn't support Edge interrupts */ | ||
896 | if (id != STMPE801_ID) { | ||
897 | if (irq_trigger == IRQF_TRIGGER_FALLING || | ||
898 | irq_trigger == IRQF_TRIGGER_RISING) | ||
899 | icr |= STMPE_ICR_LSB_EDGE; | ||
900 | } | ||
825 | 901 | ||
826 | if (irq_trigger == IRQF_TRIGGER_RISING || | 902 | if (irq_trigger == IRQF_TRIGGER_RISING || |
827 | irq_trigger == IRQF_TRIGGER_HIGH) | 903 | irq_trigger == IRQF_TRIGGER_HIGH) { |
828 | icr |= STMPE_ICR_LSB_HIGH; | 904 | if (id == STMPE801_ID) |
905 | icr |= STMPE801_REG_SYS_CTRL_INT_HI; | ||
906 | else | ||
907 | icr |= STMPE_ICR_LSB_HIGH; | ||
908 | } | ||
829 | 909 | ||
830 | if (stmpe->pdata->irq_invert_polarity) | 910 | if (stmpe->pdata->irq_invert_polarity) { |
831 | icr ^= STMPE_ICR_LSB_HIGH; | 911 | if (id == STMPE801_ID) |
912 | icr ^= STMPE801_REG_SYS_CTRL_INT_HI; | ||
913 | else | ||
914 | icr ^= STMPE_ICR_LSB_HIGH; | ||
915 | } | ||
832 | 916 | ||
833 | if (stmpe->pdata->autosleep) { | 917 | if (stmpe->pdata->autosleep) { |
834 | ret = stmpe_autosleep(stmpe, autosleep_timeout); | 918 | ret = stmpe_autosleep(stmpe, autosleep_timeout); |
@@ -873,32 +957,10 @@ static int __devinit stmpe_devices_init(struct stmpe *stmpe) | |||
873 | return ret; | 957 | return ret; |
874 | } | 958 | } |
875 | 959 | ||
876 | #ifdef CONFIG_PM | 960 | /* Called from client specific probe routines */ |
877 | static int stmpe_suspend(struct device *dev) | 961 | int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum) |
878 | { | ||
879 | struct i2c_client *i2c = to_i2c_client(dev); | ||
880 | |||
881 | if (device_may_wakeup(&i2c->dev)) | ||
882 | enable_irq_wake(i2c->irq); | ||
883 | |||
884 | return 0; | ||
885 | } | ||
886 | |||
887 | static int stmpe_resume(struct device *dev) | ||
888 | { | ||
889 | struct i2c_client *i2c = to_i2c_client(dev); | ||
890 | |||
891 | if (device_may_wakeup(&i2c->dev)) | ||
892 | disable_irq_wake(i2c->irq); | ||
893 | |||
894 | return 0; | ||
895 | } | ||
896 | #endif | ||
897 | |||
898 | static int __devinit stmpe_probe(struct i2c_client *i2c, | ||
899 | const struct i2c_device_id *id) | ||
900 | { | 962 | { |
901 | struct stmpe_platform_data *pdata = i2c->dev.platform_data; | 963 | struct stmpe_platform_data *pdata = dev_get_platdata(ci->dev); |
902 | struct stmpe *stmpe; | 964 | struct stmpe *stmpe; |
903 | int ret; | 965 | int ret; |
904 | 966 | ||
@@ -912,30 +974,43 @@ static int __devinit stmpe_probe(struct i2c_client *i2c, | |||
912 | mutex_init(&stmpe->irq_lock); | 974 | mutex_init(&stmpe->irq_lock); |
913 | mutex_init(&stmpe->lock); | 975 | mutex_init(&stmpe->lock); |
914 | 976 | ||
915 | stmpe->dev = &i2c->dev; | 977 | stmpe->dev = ci->dev; |
916 | stmpe->i2c = i2c; | 978 | stmpe->client = ci->client; |
917 | |||
918 | stmpe->pdata = pdata; | 979 | stmpe->pdata = pdata; |
919 | stmpe->irq_base = pdata->irq_base; | 980 | stmpe->irq_base = pdata->irq_base; |
920 | 981 | stmpe->ci = ci; | |
921 | stmpe->partnum = id->driver_data; | 982 | stmpe->partnum = partnum; |
922 | stmpe->variant = stmpe_variant_info[stmpe->partnum]; | 983 | stmpe->variant = stmpe_variant_info[partnum]; |
923 | stmpe->regs = stmpe->variant->regs; | 984 | stmpe->regs = stmpe->variant->regs; |
924 | stmpe->num_gpios = stmpe->variant->num_gpios; | 985 | stmpe->num_gpios = stmpe->variant->num_gpios; |
986 | dev_set_drvdata(stmpe->dev, stmpe); | ||
925 | 987 | ||
926 | i2c_set_clientdata(i2c, stmpe); | 988 | if (ci->init) |
989 | ci->init(stmpe); | ||
990 | |||
991 | if (pdata->irq_over_gpio) { | ||
992 | ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe"); | ||
993 | if (ret) { | ||
994 | dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n", | ||
995 | ret); | ||
996 | goto out_free; | ||
997 | } | ||
998 | |||
999 | stmpe->irq = gpio_to_irq(pdata->irq_gpio); | ||
1000 | } else { | ||
1001 | stmpe->irq = ci->irq; | ||
1002 | } | ||
927 | 1003 | ||
928 | ret = stmpe_chip_init(stmpe); | 1004 | ret = stmpe_chip_init(stmpe); |
929 | if (ret) | 1005 | if (ret) |
930 | goto out_free; | 1006 | goto free_gpio; |
931 | 1007 | ||
932 | ret = stmpe_irq_init(stmpe); | 1008 | ret = stmpe_irq_init(stmpe); |
933 | if (ret) | 1009 | if (ret) |
934 | goto out_free; | 1010 | goto free_gpio; |
935 | 1011 | ||
936 | ret = request_threaded_irq(stmpe->i2c->irq, NULL, stmpe_irq, | 1012 | ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq, |
937 | pdata->irq_trigger | IRQF_ONESHOT, | 1013 | pdata->irq_trigger | IRQF_ONESHOT, "stmpe", stmpe); |
938 | "stmpe", stmpe); | ||
939 | if (ret) { | 1014 | if (ret) { |
940 | dev_err(stmpe->dev, "failed to request IRQ: %d\n", ret); | 1015 | dev_err(stmpe->dev, "failed to request IRQ: %d\n", ret); |
941 | goto out_removeirq; | 1016 | goto out_removeirq; |
@@ -951,67 +1026,55 @@ static int __devinit stmpe_probe(struct i2c_client *i2c, | |||
951 | 1026 | ||
952 | out_removedevs: | 1027 | out_removedevs: |
953 | mfd_remove_devices(stmpe->dev); | 1028 | mfd_remove_devices(stmpe->dev); |
954 | free_irq(stmpe->i2c->irq, stmpe); | 1029 | free_irq(stmpe->irq, stmpe); |
955 | out_removeirq: | 1030 | out_removeirq: |
956 | stmpe_irq_remove(stmpe); | 1031 | stmpe_irq_remove(stmpe); |
1032 | free_gpio: | ||
1033 | if (pdata->irq_over_gpio) | ||
1034 | gpio_free(pdata->irq_gpio); | ||
957 | out_free: | 1035 | out_free: |
958 | kfree(stmpe); | 1036 | kfree(stmpe); |
959 | return ret; | 1037 | return ret; |
960 | } | 1038 | } |
961 | 1039 | ||
962 | static int __devexit stmpe_remove(struct i2c_client *client) | 1040 | int stmpe_remove(struct stmpe *stmpe) |
963 | { | 1041 | { |
964 | struct stmpe *stmpe = i2c_get_clientdata(client); | ||
965 | |||
966 | mfd_remove_devices(stmpe->dev); | 1042 | mfd_remove_devices(stmpe->dev); |
967 | 1043 | ||
968 | free_irq(stmpe->i2c->irq, stmpe); | 1044 | free_irq(stmpe->irq, stmpe); |
969 | stmpe_irq_remove(stmpe); | 1045 | stmpe_irq_remove(stmpe); |
970 | 1046 | ||
1047 | if (stmpe->pdata->irq_over_gpio) | ||
1048 | gpio_free(stmpe->pdata->irq_gpio); | ||
1049 | |||
971 | kfree(stmpe); | 1050 | kfree(stmpe); |
972 | 1051 | ||
973 | return 0; | 1052 | return 0; |
974 | } | 1053 | } |
975 | 1054 | ||
976 | static const struct i2c_device_id stmpe_id[] = { | ||
977 | { "stmpe811", STMPE811 }, | ||
978 | { "stmpe1601", STMPE1601 }, | ||
979 | { "stmpe2401", STMPE2401 }, | ||
980 | { "stmpe2403", STMPE2403 }, | ||
981 | { } | ||
982 | }; | ||
983 | MODULE_DEVICE_TABLE(i2c, stmpe_id); | ||
984 | |||
985 | #ifdef CONFIG_PM | 1055 | #ifdef CONFIG_PM |
986 | static const struct dev_pm_ops stmpe_dev_pm_ops = { | 1056 | static int stmpe_suspend(struct device *dev) |
987 | .suspend = stmpe_suspend, | 1057 | { |
988 | .resume = stmpe_resume, | 1058 | struct stmpe *stmpe = dev_get_drvdata(dev); |
989 | }; | ||
990 | #endif | ||
991 | 1059 | ||
992 | static struct i2c_driver stmpe_driver = { | 1060 | if (device_may_wakeup(dev)) |
993 | .driver.name = "stmpe", | 1061 | enable_irq_wake(stmpe->irq); |
994 | .driver.owner = THIS_MODULE, | ||
995 | #ifdef CONFIG_PM | ||
996 | .driver.pm = &stmpe_dev_pm_ops, | ||
997 | #endif | ||
998 | .probe = stmpe_probe, | ||
999 | .remove = __devexit_p(stmpe_remove), | ||
1000 | .id_table = stmpe_id, | ||
1001 | }; | ||
1002 | 1062 | ||
1003 | static int __init stmpe_init(void) | 1063 | return 0; |
1004 | { | ||
1005 | return i2c_add_driver(&stmpe_driver); | ||
1006 | } | 1064 | } |
1007 | subsys_initcall(stmpe_init); | ||
1008 | 1065 | ||
1009 | static void __exit stmpe_exit(void) | 1066 | static int stmpe_resume(struct device *dev) |
1010 | { | 1067 | { |
1011 | i2c_del_driver(&stmpe_driver); | 1068 | struct stmpe *stmpe = dev_get_drvdata(dev); |
1069 | |||
1070 | if (device_may_wakeup(dev)) | ||
1071 | disable_irq_wake(stmpe->irq); | ||
1072 | |||
1073 | return 0; | ||
1012 | } | 1074 | } |
1013 | module_exit(stmpe_exit); | ||
1014 | 1075 | ||
1015 | MODULE_LICENSE("GPL v2"); | 1076 | const struct dev_pm_ops stmpe_dev_pm_ops = { |
1016 | MODULE_DESCRIPTION("STMPE MFD core driver"); | 1077 | .suspend = stmpe_suspend, |
1017 | MODULE_AUTHOR("Rabin Vincent <rabin.vincent@stericsson.com>"); | 1078 | .resume = stmpe_resume, |
1079 | }; | ||
1080 | #endif | ||
diff --git a/drivers/mfd/stmpe.h b/drivers/mfd/stmpe.h index e4ee38956583..7b8e13f5b764 100644 --- a/drivers/mfd/stmpe.h +++ b/drivers/mfd/stmpe.h | |||
@@ -8,6 +8,14 @@ | |||
8 | #ifndef __STMPE_H | 8 | #ifndef __STMPE_H |
9 | #define __STMPE_H | 9 | #define __STMPE_H |
10 | 10 | ||
11 | #include <linux/device.h> | ||
12 | #include <linux/mfd/core.h> | ||
13 | #include <linux/mfd/stmpe.h> | ||
14 | #include <linux/printk.h> | ||
15 | #include <linux/types.h> | ||
16 | |||
17 | extern const struct dev_pm_ops stmpe_dev_pm_ops; | ||
18 | |||
11 | #ifdef STMPE_DUMP_BYTES | 19 | #ifdef STMPE_DUMP_BYTES |
12 | static inline void stmpe_dump_bytes(const char *str, const void *buf, | 20 | static inline void stmpe_dump_bytes(const char *str, const void *buf, |
13 | size_t len) | 21 | size_t len) |
@@ -67,11 +75,55 @@ struct stmpe_variant_info { | |||
67 | int (*enable_autosleep)(struct stmpe *stmpe, int autosleep_timeout); | 75 | int (*enable_autosleep)(struct stmpe *stmpe, int autosleep_timeout); |
68 | }; | 76 | }; |
69 | 77 | ||
78 | /** | ||
79 | * struct stmpe_client_info - i2c or spi specific routines/info | ||
80 | * @data: client specific data | ||
81 | * @read_byte: read single byte | ||
82 | * @write_byte: write single byte | ||
83 | * @read_block: read block or multiple bytes | ||
84 | * @write_block: write block or multiple bytes | ||
85 | * @init: client init routine, called during probe | ||
86 | */ | ||
87 | struct stmpe_client_info { | ||
88 | void *data; | ||
89 | int irq; | ||
90 | void *client; | ||
91 | struct device *dev; | ||
92 | int (*read_byte)(struct stmpe *stmpe, u8 reg); | ||
93 | int (*write_byte)(struct stmpe *stmpe, u8 reg, u8 val); | ||
94 | int (*read_block)(struct stmpe *stmpe, u8 reg, u8 len, u8 *values); | ||
95 | int (*write_block)(struct stmpe *stmpe, u8 reg, u8 len, | ||
96 | const u8 *values); | ||
97 | void (*init)(struct stmpe *stmpe); | ||
98 | }; | ||
99 | |||
100 | int stmpe_probe(struct stmpe_client_info *ci, int partnum); | ||
101 | int stmpe_remove(struct stmpe *stmpe); | ||
102 | |||
70 | #define STMPE_ICR_LSB_HIGH (1 << 2) | 103 | #define STMPE_ICR_LSB_HIGH (1 << 2) |
71 | #define STMPE_ICR_LSB_EDGE (1 << 1) | 104 | #define STMPE_ICR_LSB_EDGE (1 << 1) |
72 | #define STMPE_ICR_LSB_GIM (1 << 0) | 105 | #define STMPE_ICR_LSB_GIM (1 << 0) |
73 | 106 | ||
74 | /* | 107 | /* |
108 | * STMPE801 | ||
109 | */ | ||
110 | #define STMPE801_ID 0x0108 | ||
111 | #define STMPE801_NR_INTERNAL_IRQS 1 | ||
112 | |||
113 | #define STMPE801_REG_CHIP_ID 0x00 | ||
114 | #define STMPE801_REG_VERSION_ID 0x02 | ||
115 | #define STMPE801_REG_SYS_CTRL 0x04 | ||
116 | #define STMPE801_REG_GPIO_INT_EN 0x08 | ||
117 | #define STMPE801_REG_GPIO_INT_STA 0x09 | ||
118 | #define STMPE801_REG_GPIO_MP_STA 0x10 | ||
119 | #define STMPE801_REG_GPIO_SET_PIN 0x11 | ||
120 | #define STMPE801_REG_GPIO_DIR 0x12 | ||
121 | |||
122 | #define STMPE801_REG_SYS_CTRL_RESET (1 << 7) | ||
123 | #define STMPE801_REG_SYS_CTRL_INT_EN (1 << 2) | ||
124 | #define STMPE801_REG_SYS_CTRL_INT_HI (1 << 0) | ||
125 | |||
126 | /* | ||
75 | * STMPE811 | 127 | * STMPE811 |
76 | */ | 128 | */ |
77 | 129 | ||
@@ -87,6 +139,7 @@ struct stmpe_variant_info { | |||
87 | 139 | ||
88 | #define STMPE811_REG_CHIP_ID 0x00 | 140 | #define STMPE811_REG_CHIP_ID 0x00 |
89 | #define STMPE811_REG_SYS_CTRL2 0x04 | 141 | #define STMPE811_REG_SYS_CTRL2 0x04 |
142 | #define STMPE811_REG_SPI_CFG 0x08 | ||
90 | #define STMPE811_REG_INT_CTRL 0x09 | 143 | #define STMPE811_REG_INT_CTRL 0x09 |
91 | #define STMPE811_REG_INT_EN 0x0A | 144 | #define STMPE811_REG_INT_EN 0x0A |
92 | #define STMPE811_REG_INT_STA 0x0B | 145 | #define STMPE811_REG_INT_STA 0x0B |
diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c index 91ad21ef7721..2d9e8799e733 100644 --- a/drivers/mfd/t7l66xb.c +++ b/drivers/mfd/t7l66xb.c | |||
@@ -442,21 +442,7 @@ static struct platform_driver t7l66xb_platform_driver = { | |||
442 | 442 | ||
443 | /*--------------------------------------------------------------------------*/ | 443 | /*--------------------------------------------------------------------------*/ |
444 | 444 | ||
445 | static int __init t7l66xb_init(void) | 445 | module_platform_driver(t7l66xb_platform_driver); |
446 | { | ||
447 | int retval = 0; | ||
448 | |||
449 | retval = platform_driver_register(&t7l66xb_platform_driver); | ||
450 | return retval; | ||
451 | } | ||
452 | |||
453 | static void __exit t7l66xb_exit(void) | ||
454 | { | ||
455 | platform_driver_unregister(&t7l66xb_platform_driver); | ||
456 | } | ||
457 | |||
458 | module_init(t7l66xb_init); | ||
459 | module_exit(t7l66xb_exit); | ||
460 | 446 | ||
461 | MODULE_DESCRIPTION("Toshiba T7L66XB core driver"); | 447 | MODULE_DESCRIPTION("Toshiba T7L66XB core driver"); |
462 | MODULE_LICENSE("GPL v2"); | 448 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c index 71bc835324d8..d20a284ad4ba 100644 --- a/drivers/mfd/tc6387xb.c +++ b/drivers/mfd/tc6387xb.c | |||
@@ -234,19 +234,7 @@ static struct platform_driver tc6387xb_platform_driver = { | |||
234 | .resume = tc6387xb_resume, | 234 | .resume = tc6387xb_resume, |
235 | }; | 235 | }; |
236 | 236 | ||
237 | 237 | module_platform_driver(tc6387xb_platform_driver); | |
238 | static int __init tc6387xb_init(void) | ||
239 | { | ||
240 | return platform_driver_register(&tc6387xb_platform_driver); | ||
241 | } | ||
242 | |||
243 | static void __exit tc6387xb_exit(void) | ||
244 | { | ||
245 | platform_driver_unregister(&tc6387xb_platform_driver); | ||
246 | } | ||
247 | |||
248 | module_init(tc6387xb_init); | ||
249 | module_exit(tc6387xb_exit); | ||
250 | 238 | ||
251 | MODULE_DESCRIPTION("Toshiba TC6387XB core driver"); | 239 | MODULE_DESCRIPTION("Toshiba TC6387XB core driver"); |
252 | MODULE_LICENSE("GPL v2"); | 240 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/mfd/ti-ssp.c b/drivers/mfd/ti-ssp.c index af9ab0e5ca64..4fb0e6c8e8fe 100644 --- a/drivers/mfd/ti-ssp.c +++ b/drivers/mfd/ti-ssp.c | |||
@@ -458,17 +458,7 @@ static struct platform_driver ti_ssp_driver = { | |||
458 | } | 458 | } |
459 | }; | 459 | }; |
460 | 460 | ||
461 | static int __init ti_ssp_init(void) | 461 | module_platform_driver(ti_ssp_driver); |
462 | { | ||
463 | return platform_driver_register(&ti_ssp_driver); | ||
464 | } | ||
465 | module_init(ti_ssp_init); | ||
466 | |||
467 | static void __exit ti_ssp_exit(void) | ||
468 | { | ||
469 | platform_driver_unregister(&ti_ssp_driver); | ||
470 | } | ||
471 | module_exit(ti_ssp_exit); | ||
472 | 462 | ||
473 | MODULE_DESCRIPTION("Sequencer Serial Port (SSP) Driver"); | 463 | MODULE_DESCRIPTION("Sequencer Serial Port (SSP) Driver"); |
474 | MODULE_AUTHOR("Cyril Chemparathy"); | 464 | MODULE_AUTHOR("Cyril Chemparathy"); |
diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 02d65692ceb4..0ba26fb12cf5 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c | |||
@@ -857,7 +857,7 @@ static void __devexit timb_remove(struct pci_dev *dev) | |||
857 | kfree(priv); | 857 | kfree(priv); |
858 | } | 858 | } |
859 | 859 | ||
860 | static struct pci_device_id timberdale_pci_tbl[] = { | 860 | static DEFINE_PCI_DEVICE_TABLE(timberdale_pci_tbl) = { |
861 | { PCI_DEVICE(PCI_VENDOR_ID_TIMB, PCI_DEVICE_ID_TIMB) }, | 861 | { PCI_DEVICE(PCI_VENDOR_ID_TIMB, PCI_DEVICE_ID_TIMB) }, |
862 | { 0 } | 862 | { 0 } |
863 | }; | 863 | }; |
diff --git a/drivers/mfd/tps65910-irq.c b/drivers/mfd/tps65910-irq.c index a56be931551c..95c0d7978bec 100644 --- a/drivers/mfd/tps65910-irq.c +++ b/drivers/mfd/tps65910-irq.c | |||
@@ -215,6 +215,7 @@ int tps65910_irq_init(struct tps65910 *tps65910, int irq, | |||
215 | 215 | ||
216 | int tps65910_irq_exit(struct tps65910 *tps65910) | 216 | int tps65910_irq_exit(struct tps65910 *tps65910) |
217 | { | 217 | { |
218 | free_irq(tps65910->chip_irq, tps65910); | 218 | if (tps65910->chip_irq) |
219 | free_irq(tps65910->chip_irq, tps65910); | ||
219 | return 0; | 220 | return 0; |
220 | } | 221 | } |
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index c1da84bc1573..01cf5012a08f 100644 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c | |||
@@ -172,15 +172,12 @@ static int tps65910_i2c_probe(struct i2c_client *i2c, | |||
172 | 172 | ||
173 | tps65910_gpio_init(tps65910, pmic_plat_data->gpio_base); | 173 | tps65910_gpio_init(tps65910, pmic_plat_data->gpio_base); |
174 | 174 | ||
175 | ret = tps65910_irq_init(tps65910, init_data->irq, init_data); | 175 | tps65910_irq_init(tps65910, init_data->irq, init_data); |
176 | if (ret < 0) | ||
177 | goto err; | ||
178 | 176 | ||
179 | kfree(init_data); | 177 | kfree(init_data); |
180 | return ret; | 178 | return ret; |
181 | 179 | ||
182 | err: | 180 | err: |
183 | mfd_remove_devices(tps65910->dev); | ||
184 | kfree(tps65910); | 181 | kfree(tps65910); |
185 | kfree(init_data); | 182 | kfree(init_data); |
186 | return ret; | 183 | return ret; |
@@ -190,8 +187,8 @@ static int tps65910_i2c_remove(struct i2c_client *i2c) | |||
190 | { | 187 | { |
191 | struct tps65910 *tps65910 = i2c_get_clientdata(i2c); | 188 | struct tps65910 *tps65910 = i2c_get_clientdata(i2c); |
192 | 189 | ||
193 | mfd_remove_devices(tps65910->dev); | ||
194 | tps65910_irq_exit(tps65910); | 190 | tps65910_irq_exit(tps65910); |
191 | mfd_remove_devices(tps65910->dev); | ||
195 | kfree(tps65910); | 192 | kfree(tps65910); |
196 | 193 | ||
197 | return 0; | 194 | return 0; |
diff --git a/drivers/mfd/tps65912-spi.c b/drivers/mfd/tps65912-spi.c index 6d71e0d25744..27d3302d56b8 100644 --- a/drivers/mfd/tps65912-spi.c +++ b/drivers/mfd/tps65912-spi.c | |||
@@ -111,7 +111,6 @@ static int __devexit tps65912_spi_remove(struct spi_device *spi) | |||
111 | static struct spi_driver tps65912_spi_driver = { | 111 | static struct spi_driver tps65912_spi_driver = { |
112 | .driver = { | 112 | .driver = { |
113 | .name = "tps65912", | 113 | .name = "tps65912", |
114 | .bus = &spi_bus_type, | ||
115 | .owner = THIS_MODULE, | 114 | .owner = THIS_MODULE, |
116 | }, | 115 | }, |
117 | .probe = tps65912_spi_probe, | 116 | .probe = tps65912_spi_probe, |
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 61e70cfaa774..e04e04ddc15e 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c | |||
@@ -34,6 +34,11 @@ | |||
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/clk.h> | 35 | #include <linux/clk.h> |
36 | #include <linux/err.h> | 36 | #include <linux/err.h> |
37 | #include <linux/device.h> | ||
38 | #include <linux/of.h> | ||
39 | #include <linux/of_irq.h> | ||
40 | #include <linux/of_platform.h> | ||
41 | #include <linux/irqdomain.h> | ||
37 | 42 | ||
38 | #include <linux/regulator/machine.h> | 43 | #include <linux/regulator/machine.h> |
39 | 44 | ||
@@ -144,6 +149,9 @@ | |||
144 | 149 | ||
145 | #define TWL_MODULE_LAST TWL4030_MODULE_LAST | 150 | #define TWL_MODULE_LAST TWL4030_MODULE_LAST |
146 | 151 | ||
152 | #define TWL4030_NR_IRQS 8 | ||
153 | #define TWL6030_NR_IRQS 20 | ||
154 | |||
147 | /* Base Address defns for twl4030_map[] */ | 155 | /* Base Address defns for twl4030_map[] */ |
148 | 156 | ||
149 | /* subchip/slave 0 - USB ID */ | 157 | /* subchip/slave 0 - USB ID */ |
@@ -255,6 +263,7 @@ struct twl_client { | |||
255 | 263 | ||
256 | static struct twl_client twl_modules[TWL_NUM_SLAVES]; | 264 | static struct twl_client twl_modules[TWL_NUM_SLAVES]; |
257 | 265 | ||
266 | static struct irq_domain domain; | ||
258 | 267 | ||
259 | /* mapping the module id to slave id and base address */ | 268 | /* mapping the module id to slave id and base address */ |
260 | struct twl_mapping { | 269 | struct twl_mapping { |
@@ -1183,14 +1192,48 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1183 | int status; | 1192 | int status; |
1184 | unsigned i; | 1193 | unsigned i; |
1185 | struct twl4030_platform_data *pdata = client->dev.platform_data; | 1194 | struct twl4030_platform_data *pdata = client->dev.platform_data; |
1195 | struct device_node *node = client->dev.of_node; | ||
1186 | u8 temp; | 1196 | u8 temp; |
1187 | int ret = 0; | 1197 | int ret = 0; |
1198 | int nr_irqs = TWL4030_NR_IRQS; | ||
1199 | |||
1200 | if ((id->driver_data) & TWL6030_CLASS) | ||
1201 | nr_irqs = TWL6030_NR_IRQS; | ||
1202 | |||
1203 | if (node && !pdata) { | ||
1204 | /* | ||
1205 | * XXX: Temporary pdata until the information is correctly | ||
1206 | * retrieved by every TWL modules from DT. | ||
1207 | */ | ||
1208 | pdata = devm_kzalloc(&client->dev, | ||
1209 | sizeof(struct twl4030_platform_data), | ||
1210 | GFP_KERNEL); | ||
1211 | if (!pdata) | ||
1212 | return -ENOMEM; | ||
1213 | } | ||
1188 | 1214 | ||
1189 | if (!pdata) { | 1215 | if (!pdata) { |
1190 | dev_dbg(&client->dev, "no platform data?\n"); | 1216 | dev_dbg(&client->dev, "no platform data?\n"); |
1191 | return -EINVAL; | 1217 | return -EINVAL; |
1192 | } | 1218 | } |
1193 | 1219 | ||
1220 | status = irq_alloc_descs(-1, pdata->irq_base, nr_irqs, 0); | ||
1221 | if (IS_ERR_VALUE(status)) { | ||
1222 | dev_err(&client->dev, "Fail to allocate IRQ descs\n"); | ||
1223 | return status; | ||
1224 | } | ||
1225 | |||
1226 | pdata->irq_base = status; | ||
1227 | pdata->irq_end = pdata->irq_base + nr_irqs; | ||
1228 | |||
1229 | domain.irq_base = pdata->irq_base; | ||
1230 | domain.nr_irq = nr_irqs; | ||
1231 | #ifdef CONFIG_OF_IRQ | ||
1232 | domain.of_node = of_node_get(node); | ||
1233 | domain.ops = &irq_domain_simple_ops; | ||
1234 | #endif | ||
1235 | irq_domain_add(&domain); | ||
1236 | |||
1194 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { | 1237 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { |
1195 | dev_dbg(&client->dev, "can't talk I2C?\n"); | 1238 | dev_dbg(&client->dev, "can't talk I2C?\n"); |
1196 | return -EIO; | 1239 | return -EIO; |
@@ -1270,7 +1313,13 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1270 | twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); | 1313 | twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); |
1271 | } | 1314 | } |
1272 | 1315 | ||
1273 | status = add_children(pdata, id->driver_data); | 1316 | #ifdef CONFIG_OF_DEVICE |
1317 | if (node) | ||
1318 | status = of_platform_populate(node, NULL, NULL, &client->dev); | ||
1319 | else | ||
1320 | #endif | ||
1321 | status = add_children(pdata, id->driver_data); | ||
1322 | |||
1274 | fail: | 1323 | fail: |
1275 | if (status < 0) | 1324 | if (status < 0) |
1276 | twl_remove(client); | 1325 | twl_remove(client); |
diff --git a/drivers/mfd/twl4030-audio.c b/drivers/mfd/twl4030-audio.c index ae51ab5d0e5d..838ce4eb444e 100644 --- a/drivers/mfd/twl4030-audio.c +++ b/drivers/mfd/twl4030-audio.c | |||
@@ -261,17 +261,7 @@ static struct platform_driver twl4030_audio_driver = { | |||
261 | }, | 261 | }, |
262 | }; | 262 | }; |
263 | 263 | ||
264 | static int __devinit twl4030_audio_init(void) | 264 | module_platform_driver(twl4030_audio_driver); |
265 | { | ||
266 | return platform_driver_register(&twl4030_audio_driver); | ||
267 | } | ||
268 | module_init(twl4030_audio_init); | ||
269 | |||
270 | static void __devexit twl4030_audio_exit(void) | ||
271 | { | ||
272 | platform_driver_unregister(&twl4030_audio_driver); | ||
273 | } | ||
274 | module_exit(twl4030_audio_exit); | ||
275 | 265 | ||
276 | MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>"); | 266 | MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>"); |
277 | MODULE_LICENSE("GPL"); | 267 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index 29f11e0765fe..b69bb517b102 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c | |||
@@ -492,7 +492,7 @@ static void twl4030_sih_bus_sync_unlock(struct irq_data *data) | |||
492 | u8 bytes[4]; | 492 | u8 bytes[4]; |
493 | } imr; | 493 | } imr; |
494 | 494 | ||
495 | /* byte[0] gets overwriten as we write ... */ | 495 | /* byte[0] gets overwritten as we write ... */ |
496 | imr.word = cpu_to_le32(agent->imr << 8); | 496 | imr.word = cpu_to_le32(agent->imr << 8); |
497 | agent->imr_change_pending = false; | 497 | agent->imr_change_pending = false; |
498 | 498 | ||
@@ -667,6 +667,7 @@ int twl4030_sih_setup(int module) | |||
667 | irq_set_chip_data(irq, agent); | 667 | irq_set_chip_data(irq, agent); |
668 | irq_set_chip_and_handler(irq, &twl4030_sih_irq_chip, | 668 | irq_set_chip_and_handler(irq, &twl4030_sih_irq_chip, |
669 | handle_edge_irq); | 669 | handle_edge_irq); |
670 | irq_set_nested_thread(irq, 1); | ||
670 | activate_irq(irq); | 671 | activate_irq(irq); |
671 | } | 672 | } |
672 | 673 | ||
diff --git a/drivers/mfd/twl4030-madc.c b/drivers/mfd/twl4030-madc.c index 834f824d3c11..456ecb5ac4fe 100644 --- a/drivers/mfd/twl4030-madc.c +++ b/drivers/mfd/twl4030-madc.c | |||
@@ -807,19 +807,7 @@ static struct platform_driver twl4030_madc_driver = { | |||
807 | }, | 807 | }, |
808 | }; | 808 | }; |
809 | 809 | ||
810 | static int __init twl4030_madc_init(void) | 810 | module_platform_driver(twl4030_madc_driver); |
811 | { | ||
812 | return platform_driver_register(&twl4030_madc_driver); | ||
813 | } | ||
814 | |||
815 | module_init(twl4030_madc_init); | ||
816 | |||
817 | static void __exit twl4030_madc_exit(void) | ||
818 | { | ||
819 | platform_driver_unregister(&twl4030_madc_driver); | ||
820 | } | ||
821 | |||
822 | module_exit(twl4030_madc_exit); | ||
823 | 811 | ||
824 | MODULE_DESCRIPTION("TWL4030 ADC driver"); | 812 | MODULE_DESCRIPTION("TWL4030 ADC driver"); |
825 | MODULE_LICENSE("GPL"); | 813 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c index a764676f0922..d905f5171153 100644 --- a/drivers/mfd/twl4030-power.c +++ b/drivers/mfd/twl4030-power.c | |||
@@ -34,7 +34,8 @@ | |||
34 | static u8 twl4030_start_script_address = 0x2b; | 34 | static u8 twl4030_start_script_address = 0x2b; |
35 | 35 | ||
36 | #define PWR_P1_SW_EVENTS 0x10 | 36 | #define PWR_P1_SW_EVENTS 0x10 |
37 | #define PWR_DEVOFF (1<<0) | 37 | #define PWR_DEVOFF (1 << 0) |
38 | #define SEQ_OFFSYNC (1 << 0) | ||
38 | 39 | ||
39 | #define PHY_TO_OFF_PM_MASTER(p) (p - 0x36) | 40 | #define PHY_TO_OFF_PM_MASTER(p) (p - 0x36) |
40 | #define PHY_TO_OFF_PM_RECEIVER(p) (p - 0x5b) | 41 | #define PHY_TO_OFF_PM_RECEIVER(p) (p - 0x5b) |
@@ -511,12 +512,27 @@ int twl4030_remove_script(u8 flags) | |||
511 | return err; | 512 | return err; |
512 | } | 513 | } |
513 | 514 | ||
515 | /* | ||
516 | * In master mode, start the power off sequence. | ||
517 | * After a successful execution, TWL shuts down the power to the SoC | ||
518 | * and all peripherals connected to it. | ||
519 | */ | ||
520 | void twl4030_power_off(void) | ||
521 | { | ||
522 | int err; | ||
523 | |||
524 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, PWR_DEVOFF, | ||
525 | TWL4030_PM_MASTER_P1_SW_EVENTS); | ||
526 | if (err) | ||
527 | pr_err("TWL4030 Unable to power off\n"); | ||
528 | } | ||
529 | |||
514 | void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts) | 530 | void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts) |
515 | { | 531 | { |
516 | int err = 0; | 532 | int err = 0; |
517 | int i; | 533 | int i; |
518 | struct twl4030_resconfig *resconfig; | 534 | struct twl4030_resconfig *resconfig; |
519 | u8 address = twl4030_start_script_address; | 535 | u8 val, address = twl4030_start_script_address; |
520 | 536 | ||
521 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, | 537 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, |
522 | TWL4030_PM_MASTER_KEY_CFG1, | 538 | TWL4030_PM_MASTER_KEY_CFG1, |
@@ -548,6 +564,28 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts) | |||
548 | } | 564 | } |
549 | } | 565 | } |
550 | 566 | ||
567 | /* Board has to be wired properly to use this feature */ | ||
568 | if (twl4030_scripts->use_poweroff && !pm_power_off) { | ||
569 | /* Default for SEQ_OFFSYNC is set, lets ensure this */ | ||
570 | err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val, | ||
571 | TWL4030_PM_MASTER_CFG_P123_TRANSITION); | ||
572 | if (err) { | ||
573 | pr_warning("TWL4030 Unable to read registers\n"); | ||
574 | |||
575 | } else if (!(val & SEQ_OFFSYNC)) { | ||
576 | val |= SEQ_OFFSYNC; | ||
577 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val, | ||
578 | TWL4030_PM_MASTER_CFG_P123_TRANSITION); | ||
579 | if (err) { | ||
580 | pr_err("TWL4030 Unable to setup SEQ_OFFSYNC\n"); | ||
581 | goto relock; | ||
582 | } | ||
583 | } | ||
584 | |||
585 | pm_power_off = twl4030_power_off; | ||
586 | } | ||
587 | |||
588 | relock: | ||
551 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, | 589 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, |
552 | TWL4030_PM_MASTER_PROTECT_KEY); | 590 | TWL4030_PM_MASTER_PROTECT_KEY); |
553 | if (err) | 591 | if (err) |
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c index 268f80fd0439..dda86293dc9f 100644 --- a/drivers/mfd/twl6040-core.c +++ b/drivers/mfd/twl6040-core.c | |||
@@ -509,13 +509,10 @@ static int __devinit twl6040_probe(struct platform_device *pdev) | |||
509 | twl6040->audpwron = -EINVAL; | 509 | twl6040->audpwron = -EINVAL; |
510 | 510 | ||
511 | if (gpio_is_valid(twl6040->audpwron)) { | 511 | if (gpio_is_valid(twl6040->audpwron)) { |
512 | ret = gpio_request(twl6040->audpwron, "audpwron"); | 512 | ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW, |
513 | "audpwron"); | ||
513 | if (ret) | 514 | if (ret) |
514 | goto gpio1_err; | 515 | goto gpio1_err; |
515 | |||
516 | ret = gpio_direction_output(twl6040->audpwron, 0); | ||
517 | if (ret) | ||
518 | goto gpio2_err; | ||
519 | } | 516 | } |
520 | 517 | ||
521 | /* codec interrupt */ | 518 | /* codec interrupt */ |
@@ -619,18 +616,7 @@ static struct platform_driver twl6040_driver = { | |||
619 | }, | 616 | }, |
620 | }; | 617 | }; |
621 | 618 | ||
622 | static int __devinit twl6040_init(void) | 619 | module_platform_driver(twl6040_driver); |
623 | { | ||
624 | return platform_driver_register(&twl6040_driver); | ||
625 | } | ||
626 | module_init(twl6040_init); | ||
627 | |||
628 | static void __devexit twl6040_exit(void) | ||
629 | { | ||
630 | platform_driver_unregister(&twl6040_driver); | ||
631 | } | ||
632 | |||
633 | module_exit(twl6040_exit); | ||
634 | 620 | ||
635 | MODULE_DESCRIPTION("TWL6040 MFD"); | 621 | MODULE_DESCRIPTION("TWL6040 MFD"); |
636 | MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>"); | 622 | MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>"); |
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c index b281217334eb..91c4f25e0e55 100644 --- a/drivers/mfd/ucb1x00-core.c +++ b/drivers/mfd/ucb1x00-core.c | |||
@@ -36,6 +36,15 @@ static DEFINE_MUTEX(ucb1x00_mutex); | |||
36 | static LIST_HEAD(ucb1x00_drivers); | 36 | static LIST_HEAD(ucb1x00_drivers); |
37 | static LIST_HEAD(ucb1x00_devices); | 37 | static LIST_HEAD(ucb1x00_devices); |
38 | 38 | ||
39 | static struct mcp_device_id ucb1x00_id[] = { | ||
40 | { "ucb1x00", 0 }, /* auto-detection */ | ||
41 | { "ucb1200", UCB_ID_1200 }, | ||
42 | { "ucb1300", UCB_ID_1300 }, | ||
43 | { "tc35143", UCB_ID_TC35143 }, | ||
44 | { } | ||
45 | }; | ||
46 | MODULE_DEVICE_TABLE(mcp, ucb1x00_id); | ||
47 | |||
39 | /** | 48 | /** |
40 | * ucb1x00_io_set_dir - set IO direction | 49 | * ucb1x00_io_set_dir - set IO direction |
41 | * @ucb: UCB1x00 structure describing chip | 50 | * @ucb: UCB1x00 structure describing chip |
@@ -527,17 +536,33 @@ static struct class ucb1x00_class = { | |||
527 | 536 | ||
528 | static int ucb1x00_probe(struct mcp *mcp) | 537 | static int ucb1x00_probe(struct mcp *mcp) |
529 | { | 538 | { |
539 | const struct mcp_device_id *mid; | ||
530 | struct ucb1x00 *ucb; | 540 | struct ucb1x00 *ucb; |
531 | struct ucb1x00_driver *drv; | 541 | struct ucb1x00_driver *drv; |
542 | struct ucb1x00_plat_data *pdata; | ||
532 | unsigned int id; | 543 | unsigned int id; |
533 | int ret = -ENODEV; | 544 | int ret = -ENODEV; |
534 | int temp; | 545 | int temp; |
535 | 546 | ||
536 | mcp_enable(mcp); | 547 | mcp_enable(mcp); |
537 | id = mcp_reg_read(mcp, UCB_ID); | 548 | id = mcp_reg_read(mcp, UCB_ID); |
549 | mid = mcp_get_device_id(mcp); | ||
538 | 550 | ||
539 | if (id != UCB_ID_1200 && id != UCB_ID_1300 && id != UCB_ID_TC35143) { | 551 | if (mid && mid->driver_data) { |
540 | printk(KERN_WARNING "UCB1x00 ID not found: %04x\n", id); | 552 | if (id != mid->driver_data) { |
553 | printk(KERN_WARNING "%s wrong ID %04x found: %04x\n", | ||
554 | mid->name, (unsigned int) mid->driver_data, id); | ||
555 | goto err_disable; | ||
556 | } | ||
557 | } else { | ||
558 | mid = &ucb1x00_id[1]; | ||
559 | while (mid->driver_data) { | ||
560 | if (id == mid->driver_data) | ||
561 | break; | ||
562 | mid++; | ||
563 | } | ||
564 | printk(KERN_WARNING "%s ID not found: %04x\n", | ||
565 | ucb1x00_id[0].name, id); | ||
541 | goto err_disable; | 566 | goto err_disable; |
542 | } | 567 | } |
543 | 568 | ||
@@ -546,28 +571,28 @@ static int ucb1x00_probe(struct mcp *mcp) | |||
546 | if (!ucb) | 571 | if (!ucb) |
547 | goto err_disable; | 572 | goto err_disable; |
548 | 573 | ||
549 | 574 | pdata = mcp->attached_device.platform_data; | |
550 | ucb->dev.class = &ucb1x00_class; | 575 | ucb->dev.class = &ucb1x00_class; |
551 | ucb->dev.parent = &mcp->attached_device; | 576 | ucb->dev.parent = &mcp->attached_device; |
552 | dev_set_name(&ucb->dev, "ucb1x00"); | 577 | dev_set_name(&ucb->dev, mid->name); |
553 | 578 | ||
554 | spin_lock_init(&ucb->lock); | 579 | spin_lock_init(&ucb->lock); |
555 | spin_lock_init(&ucb->io_lock); | 580 | spin_lock_init(&ucb->io_lock); |
556 | sema_init(&ucb->adc_sem, 1); | 581 | sema_init(&ucb->adc_sem, 1); |
557 | 582 | ||
558 | ucb->id = id; | 583 | ucb->id = mid; |
559 | ucb->mcp = mcp; | 584 | ucb->mcp = mcp; |
560 | ucb->irq = ucb1x00_detect_irq(ucb); | 585 | ucb->irq = ucb1x00_detect_irq(ucb); |
561 | if (ucb->irq == NO_IRQ) { | 586 | if (ucb->irq == NO_IRQ) { |
562 | printk(KERN_ERR "UCB1x00: IRQ probe failed\n"); | 587 | printk(KERN_ERR "%s: IRQ probe failed\n", mid->name); |
563 | ret = -ENODEV; | 588 | ret = -ENODEV; |
564 | goto err_free; | 589 | goto err_free; |
565 | } | 590 | } |
566 | 591 | ||
567 | ucb->gpio.base = -1; | 592 | ucb->gpio.base = -1; |
568 | if (mcp->gpio_base != 0) { | 593 | if (pdata && (pdata->gpio_base >= 0)) { |
569 | ucb->gpio.label = dev_name(&ucb->dev); | 594 | ucb->gpio.label = dev_name(&ucb->dev); |
570 | ucb->gpio.base = mcp->gpio_base; | 595 | ucb->gpio.base = pdata->gpio_base; |
571 | ucb->gpio.ngpio = 10; | 596 | ucb->gpio.ngpio = 10; |
572 | ucb->gpio.set = ucb1x00_gpio_set; | 597 | ucb->gpio.set = ucb1x00_gpio_set; |
573 | ucb->gpio.get = ucb1x00_gpio_get; | 598 | ucb->gpio.get = ucb1x00_gpio_get; |
@@ -580,10 +605,10 @@ static int ucb1x00_probe(struct mcp *mcp) | |||
580 | dev_info(&ucb->dev, "gpio_base not set so no gpiolib support"); | 605 | dev_info(&ucb->dev, "gpio_base not set so no gpiolib support"); |
581 | 606 | ||
582 | ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING, | 607 | ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING, |
583 | "UCB1x00", ucb); | 608 | mid->name, ucb); |
584 | if (ret) { | 609 | if (ret) { |
585 | printk(KERN_ERR "ucb1x00: unable to grab irq%d: %d\n", | 610 | printk(KERN_ERR "%s: unable to grab irq%d: %d\n", |
586 | ucb->irq, ret); | 611 | mid->name, ucb->irq, ret); |
587 | goto err_gpio; | 612 | goto err_gpio; |
588 | } | 613 | } |
589 | 614 | ||
@@ -705,6 +730,7 @@ static struct mcp_driver ucb1x00_driver = { | |||
705 | .remove = ucb1x00_remove, | 730 | .remove = ucb1x00_remove, |
706 | .suspend = ucb1x00_suspend, | 731 | .suspend = ucb1x00_suspend, |
707 | .resume = ucb1x00_resume, | 732 | .resume = ucb1x00_resume, |
733 | .id_table = ucb1x00_id, | ||
708 | }; | 734 | }; |
709 | 735 | ||
710 | static int __init ucb1x00_init(void) | 736 | static int __init ucb1x00_init(void) |
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c index 38ffbd50a0d2..40ec3c118868 100644 --- a/drivers/mfd/ucb1x00-ts.c +++ b/drivers/mfd/ucb1x00-ts.c | |||
@@ -382,7 +382,7 @@ static int ucb1x00_ts_add(struct ucb1x00_dev *dev) | |||
382 | ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC; | 382 | ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC; |
383 | 383 | ||
384 | idev->name = "Touchscreen panel"; | 384 | idev->name = "Touchscreen panel"; |
385 | idev->id.product = ts->ucb->id; | 385 | idev->id.product = ts->ucb->id->driver_data; |
386 | idev->open = ucb1x00_ts_open; | 386 | idev->open = ucb1x00_ts_open; |
387 | idev->close = ucb1x00_ts_close; | 387 | idev->close = ucb1x00_ts_close; |
388 | 388 | ||
diff --git a/drivers/mfd/vx855.c b/drivers/mfd/vx855.c index d698703dbd46..b73cc15e0081 100644 --- a/drivers/mfd/vx855.c +++ b/drivers/mfd/vx855.c | |||
@@ -118,7 +118,7 @@ static void __devexit vx855_remove(struct pci_dev *pdev) | |||
118 | pci_disable_device(pdev); | 118 | pci_disable_device(pdev); |
119 | } | 119 | } |
120 | 120 | ||
121 | static struct pci_device_id vx855_pci_tbl[] = { | 121 | static DEFINE_PCI_DEVICE_TABLE(vx855_pci_tbl) = { |
122 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) }, | 122 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) }, |
123 | { 0, } | 123 | { 0, } |
124 | }; | 124 | }; |
diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c index 0a2b8d41a702..f5e54fae8ada 100644 --- a/drivers/mfd/wm831x-core.c +++ b/drivers/mfd/wm831x-core.c | |||
@@ -559,6 +559,8 @@ static int wm831x_write(struct wm831x *wm831x, unsigned short reg, | |||
559 | dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n", | 559 | dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n", |
560 | buf[i], reg + i, reg + i); | 560 | buf[i], reg + i, reg + i); |
561 | ret = regmap_write(wm831x->regmap, reg + i, buf[i]); | 561 | ret = regmap_write(wm831x->regmap, reg + i, buf[i]); |
562 | if (ret != 0) | ||
563 | return ret; | ||
562 | } | 564 | } |
563 | 565 | ||
564 | return 0; | 566 | return 0; |
@@ -1875,7 +1877,6 @@ err_irq: | |||
1875 | err_regmap: | 1877 | err_regmap: |
1876 | mfd_remove_devices(wm831x->dev); | 1878 | mfd_remove_devices(wm831x->dev); |
1877 | regmap_exit(wm831x->regmap); | 1879 | regmap_exit(wm831x->regmap); |
1878 | kfree(wm831x); | ||
1879 | return ret; | 1880 | return ret; |
1880 | } | 1881 | } |
1881 | 1882 | ||
@@ -1887,7 +1888,6 @@ void wm831x_device_exit(struct wm831x *wm831x) | |||
1887 | free_irq(wm831x->irq_base + WM831X_IRQ_AUXADC_DATA, wm831x); | 1888 | free_irq(wm831x->irq_base + WM831X_IRQ_AUXADC_DATA, wm831x); |
1888 | wm831x_irq_exit(wm831x); | 1889 | wm831x_irq_exit(wm831x); |
1889 | regmap_exit(wm831x->regmap); | 1890 | regmap_exit(wm831x->regmap); |
1890 | kfree(wm831x); | ||
1891 | } | 1891 | } |
1892 | 1892 | ||
1893 | int wm831x_device_suspend(struct wm831x *wm831x) | 1893 | int wm831x_device_suspend(struct wm831x *wm831x) |
diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c index ac8da1d439da..cb15609b0a48 100644 --- a/drivers/mfd/wm831x-i2c.c +++ b/drivers/mfd/wm831x-i2c.c | |||
@@ -30,7 +30,7 @@ static int wm831x_i2c_probe(struct i2c_client *i2c, | |||
30 | struct wm831x *wm831x; | 30 | struct wm831x *wm831x; |
31 | int ret; | 31 | int ret; |
32 | 32 | ||
33 | wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL); | 33 | wm831x = devm_kzalloc(&i2c->dev, sizeof(struct wm831x), GFP_KERNEL); |
34 | if (wm831x == NULL) | 34 | if (wm831x == NULL) |
35 | return -ENOMEM; | 35 | return -ENOMEM; |
36 | 36 | ||
@@ -42,7 +42,6 @@ static int wm831x_i2c_probe(struct i2c_client *i2c, | |||
42 | ret = PTR_ERR(wm831x->regmap); | 42 | ret = PTR_ERR(wm831x->regmap); |
43 | dev_err(wm831x->dev, "Failed to allocate register map: %d\n", | 43 | dev_err(wm831x->dev, "Failed to allocate register map: %d\n", |
44 | ret); | 44 | ret); |
45 | kfree(wm831x); | ||
46 | return ret; | 45 | return ret; |
47 | } | 46 | } |
48 | 47 | ||
diff --git a/drivers/mfd/wm831x-irq.c b/drivers/mfd/wm831x-irq.c index f4747a4a9a93..bec4d0539160 100644 --- a/drivers/mfd/wm831x-irq.c +++ b/drivers/mfd/wm831x-irq.c | |||
@@ -325,11 +325,6 @@ static inline int irq_data_to_status_reg(struct wm831x_irq_data *irq_data) | |||
325 | return WM831X_INTERRUPT_STATUS_1 - 1 + irq_data->reg; | 325 | return WM831X_INTERRUPT_STATUS_1 - 1 + irq_data->reg; |
326 | } | 326 | } |
327 | 327 | ||
328 | static inline int irq_data_to_mask_reg(struct wm831x_irq_data *irq_data) | ||
329 | { | ||
330 | return WM831X_INTERRUPT_STATUS_1_MASK - 1 + irq_data->reg; | ||
331 | } | ||
332 | |||
333 | static inline struct wm831x_irq_data *irq_to_wm831x_irq(struct wm831x *wm831x, | 328 | static inline struct wm831x_irq_data *irq_to_wm831x_irq(struct wm831x *wm831x, |
334 | int irq) | 329 | int irq) |
335 | { | 330 | { |
@@ -477,8 +472,7 @@ static irqreturn_t wm831x_irq_thread(int irq, void *data) | |||
477 | handle_nested_irq(wm831x->irq_base + WM831X_IRQ_TCHPD); | 472 | handle_nested_irq(wm831x->irq_base + WM831X_IRQ_TCHPD); |
478 | if (primary & WM831X_TCHDATA_INT) | 473 | if (primary & WM831X_TCHDATA_INT) |
479 | handle_nested_irq(wm831x->irq_base + WM831X_IRQ_TCHDATA); | 474 | handle_nested_irq(wm831x->irq_base + WM831X_IRQ_TCHDATA); |
480 | if (primary & (WM831X_TCHDATA_EINT | WM831X_TCHPD_EINT)) | 475 | primary &= ~(WM831X_TCHDATA_EINT | WM831X_TCHPD_EINT); |
481 | goto out; | ||
482 | 476 | ||
483 | for (i = 0; i < ARRAY_SIZE(wm831x_irqs); i++) { | 477 | for (i = 0; i < ARRAY_SIZE(wm831x_irqs); i++) { |
484 | int offset = wm831x_irqs[i].reg - 1; | 478 | int offset = wm831x_irqs[i].reg - 1; |
diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c index 8d6a9a969dbc..62ef3254105f 100644 --- a/drivers/mfd/wm831x-spi.c +++ b/drivers/mfd/wm831x-spi.c | |||
@@ -30,7 +30,7 @@ static int __devinit wm831x_spi_probe(struct spi_device *spi) | |||
30 | 30 | ||
31 | type = (enum wm831x_parent)id->driver_data; | 31 | type = (enum wm831x_parent)id->driver_data; |
32 | 32 | ||
33 | wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL); | 33 | wm831x = devm_kzalloc(&spi->dev, sizeof(struct wm831x), GFP_KERNEL); |
34 | if (wm831x == NULL) | 34 | if (wm831x == NULL) |
35 | return -ENOMEM; | 35 | return -ENOMEM; |
36 | 36 | ||
@@ -45,7 +45,6 @@ static int __devinit wm831x_spi_probe(struct spi_device *spi) | |||
45 | ret = PTR_ERR(wm831x->regmap); | 45 | ret = PTR_ERR(wm831x->regmap); |
46 | dev_err(wm831x->dev, "Failed to allocate register map: %d\n", | 46 | dev_err(wm831x->dev, "Failed to allocate register map: %d\n", |
47 | ret); | 47 | ret); |
48 | kfree(wm831x); | ||
49 | return ret; | 48 | return ret; |
50 | } | 49 | } |
51 | 50 | ||
@@ -95,7 +94,6 @@ MODULE_DEVICE_TABLE(spi, wm831x_spi_id); | |||
95 | static struct spi_driver wm831x_spi_driver = { | 94 | static struct spi_driver wm831x_spi_driver = { |
96 | .driver = { | 95 | .driver = { |
97 | .name = "wm831x", | 96 | .name = "wm831x", |
98 | .bus = &spi_bus_type, | ||
99 | .owner = THIS_MODULE, | 97 | .owner = THIS_MODULE, |
100 | .pm = &wm831x_spi_pm, | 98 | .pm = &wm831x_spi_pm, |
101 | }, | 99 | }, |
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c index e81cc31e4202..dd1caaac55e4 100644 --- a/drivers/mfd/wm8350-core.c +++ b/drivers/mfd/wm8350-core.c | |||
@@ -573,6 +573,8 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq, | |||
573 | u16 id1, id2, mask_rev; | 573 | u16 id1, id2, mask_rev; |
574 | u16 cust_id, mode, chip_rev; | 574 | u16 cust_id, mode, chip_rev; |
575 | 575 | ||
576 | dev_set_drvdata(wm8350->dev, wm8350); | ||
577 | |||
576 | /* get WM8350 revision and config mode */ | 578 | /* get WM8350 revision and config mode */ |
577 | ret = wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1); | 579 | ret = wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1); |
578 | if (ret != 0) { | 580 | if (ret != 0) { |
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c index 5fe5de166adb..d955faaf27c4 100644 --- a/drivers/mfd/wm8350-i2c.c +++ b/drivers/mfd/wm8350-i2c.c | |||
@@ -63,7 +63,7 @@ static int wm8350_i2c_probe(struct i2c_client *i2c, | |||
63 | struct wm8350 *wm8350; | 63 | struct wm8350 *wm8350; |
64 | int ret = 0; | 64 | int ret = 0; |
65 | 65 | ||
66 | wm8350 = kzalloc(sizeof(struct wm8350), GFP_KERNEL); | 66 | wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL); |
67 | if (wm8350 == NULL) | 67 | if (wm8350 == NULL) |
68 | return -ENOMEM; | 68 | return -ENOMEM; |
69 | 69 | ||
@@ -80,7 +80,6 @@ static int wm8350_i2c_probe(struct i2c_client *i2c, | |||
80 | return ret; | 80 | return ret; |
81 | 81 | ||
82 | err: | 82 | err: |
83 | kfree(wm8350); | ||
84 | return ret; | 83 | return ret; |
85 | } | 84 | } |
86 | 85 | ||
@@ -89,7 +88,6 @@ static int wm8350_i2c_remove(struct i2c_client *i2c) | |||
89 | struct wm8350 *wm8350 = i2c_get_clientdata(i2c); | 88 | struct wm8350 *wm8350 = i2c_get_clientdata(i2c); |
90 | 89 | ||
91 | wm8350_device_exit(wm8350); | 90 | wm8350_device_exit(wm8350); |
92 | kfree(wm8350); | ||
93 | 91 | ||
94 | return 0; | 92 | return 0; |
95 | } | 93 | } |
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c index 62b4626f4561..2204893444a6 100644 --- a/drivers/mfd/wm8400-core.c +++ b/drivers/mfd/wm8400-core.c | |||
@@ -344,7 +344,7 @@ static int wm8400_i2c_probe(struct i2c_client *i2c, | |||
344 | struct wm8400 *wm8400; | 344 | struct wm8400 *wm8400; |
345 | int ret; | 345 | int ret; |
346 | 346 | ||
347 | wm8400 = kzalloc(sizeof(struct wm8400), GFP_KERNEL); | 347 | wm8400 = devm_kzalloc(&i2c->dev, sizeof(struct wm8400), GFP_KERNEL); |
348 | if (wm8400 == NULL) { | 348 | if (wm8400 == NULL) { |
349 | ret = -ENOMEM; | 349 | ret = -ENOMEM; |
350 | goto err; | 350 | goto err; |
@@ -353,7 +353,7 @@ static int wm8400_i2c_probe(struct i2c_client *i2c, | |||
353 | wm8400->regmap = regmap_init_i2c(i2c, &wm8400_regmap_config); | 353 | wm8400->regmap = regmap_init_i2c(i2c, &wm8400_regmap_config); |
354 | if (IS_ERR(wm8400->regmap)) { | 354 | if (IS_ERR(wm8400->regmap)) { |
355 | ret = PTR_ERR(wm8400->regmap); | 355 | ret = PTR_ERR(wm8400->regmap); |
356 | goto struct_err; | 356 | goto err; |
357 | } | 357 | } |
358 | 358 | ||
359 | wm8400->dev = &i2c->dev; | 359 | wm8400->dev = &i2c->dev; |
@@ -367,8 +367,6 @@ static int wm8400_i2c_probe(struct i2c_client *i2c, | |||
367 | 367 | ||
368 | map_err: | 368 | map_err: |
369 | regmap_exit(wm8400->regmap); | 369 | regmap_exit(wm8400->regmap); |
370 | struct_err: | ||
371 | kfree(wm8400); | ||
372 | err: | 370 | err: |
373 | return ret; | 371 | return ret; |
374 | } | 372 | } |
@@ -379,7 +377,6 @@ static int wm8400_i2c_remove(struct i2c_client *i2c) | |||
379 | 377 | ||
380 | wm8400_release(wm8400); | 378 | wm8400_release(wm8400); |
381 | regmap_exit(wm8400->regmap); | 379 | regmap_exit(wm8400->regmap); |
382 | kfree(wm8400); | ||
383 | 380 | ||
384 | return 0; | 381 | return 0; |
385 | } | 382 | } |