aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/twl-core.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-16 21:55:20 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-16 21:55:20 -0500
commit2dfea3803dcf70983d14ce1dcbb3e97a7459a28b (patch)
tree59bffc7389ff554585f79d7cc06021790dc2b317 /drivers/mfd/twl-core.c
parentaed606e3bc1f10753254db308d3fd8c053c41328 (diff)
parent1881b68b8961a86d40c3c5c205e533515a2dc9c6 (diff)
Merge tag 'mfd-3.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6
Pull MFS update from Samuel Ortiz: "This is the MFD patch set for the 3.8 merge window. We have several new drivers, most of the time coming with their sub devices drivers: - Austria Microsystem's AS3711 - Nano River's viperboard - TI's TPS80031, AM335x TS/ADC, - Realtek's MMC/memstick card reader - Nokia's retu We also got some notable cleanups and improvements: - tps6586x got converted to IRQ domains. - tps65910 and tps65090 moved to the regmap IRQ API. - STMPE is now Device Tree aware. - A general twl6040 and twl-core cleanup, with moves to the regmap I/O and IRQ APIs and a conversion to the recently added PWM framework. - sta2x11 gained regmap support. Then the rest is mostly tiny cleanups and fixes, among which we have Mark's wm5xxx and wm8xxx patchset." Far amount of annoying but largely trivial conflicts. Many due to __devinit/exit removal, others due to one or two of the new drivers also having come in through another tree. * tag 'mfd-3.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (119 commits) mfd: tps6507x: Convert to devm_kzalloc mfd: stmpe: Update DT support for stmpe driver mfd: wm5102: Add readback of DSP status 3 register mfd: arizona: Log if we fail to create the primary IRQ domain mfd: tps80031: MFD_TPS80031 needs to select REGMAP_IRQ mfd: tps80031: Add terminating entry for tps80031_id_table mfd: sta2x11: Fix potential NULL pointer dereference in __sta2x11_mfd_mask() mfd: wm5102: Add tuning for revision B mfd: arizona: Defer patch initialistation until after first device boot mfd: tps65910: Fix wrong ack_base register mfd: tps65910: Remove unused data mfd: stmpe: Get rid of irq_invert_polarity mfd: ab8500-core: Fix invalid free of devm_ allocated data mfd: wm5102: Mark DSP memory regions as volatile mfd: wm5102: Correct default for LDO1_CONTROL_2 mfd: arizona: Register haptics devices mfd: wm8994: Make current device behaviour the default mfd: tps65090: MFD_TPS65090 needs to select REGMAP_IRQ mfd: Fix stmpe.c build when OF is not enabled mfd: jz4740-adc: Use devm_kzalloc ...
Diffstat (limited to 'drivers/mfd/twl-core.c')
-rw-r--r--drivers/mfd/twl-core.c227
1 files changed, 118 insertions, 109 deletions
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 11b76c0109f5..4f3baadd0038 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -32,6 +32,7 @@
32#include <linux/mutex.h> 32#include <linux/mutex.h>
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/regmap.h>
35#include <linux/clk.h> 36#include <linux/clk.h>
36#include <linux/err.h> 37#include <linux/err.h>
37#include <linux/device.h> 38#include <linux/device.h>
@@ -65,9 +66,6 @@
65 66
66/* Triton Core internal information (BEGIN) */ 67/* Triton Core internal information (BEGIN) */
67 68
68/* Last - for index max*/
69#define TWL4030_MODULE_LAST TWL4030_MODULE_SECURED_REG
70
71#define TWL_NUM_SLAVES 4 69#define TWL_NUM_SLAVES 4
72 70
73#define SUB_CHIP_ID0 0 71#define SUB_CHIP_ID0 0
@@ -171,13 +169,7 @@ EXPORT_SYMBOL(twl_rev);
171/* Structure for each TWL4030/TWL6030 Slave */ 169/* Structure for each TWL4030/TWL6030 Slave */
172struct twl_client { 170struct twl_client {
173 struct i2c_client *client; 171 struct i2c_client *client;
174 u8 address; 172 struct regmap *regmap;
175
176 /* max numb of i2c_msg required is for read =2 */
177 struct i2c_msg xfer_msg[2];
178
179 /* To lock access to xfer_msg */
180 struct mutex xfer_lock;
181}; 173};
182 174
183static struct twl_client twl_modules[TWL_NUM_SLAVES]; 175static struct twl_client twl_modules[TWL_NUM_SLAVES];
@@ -189,7 +181,7 @@ struct twl_mapping {
189}; 181};
190static struct twl_mapping *twl_map; 182static struct twl_mapping *twl_map;
191 183
192static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = { 184static struct twl_mapping twl4030_map[] = {
193 /* 185 /*
194 * NOTE: don't change this table without updating the 186 * NOTE: don't change this table without updating the
195 * <linux/i2c/twl.h> defines for TWL4030_MODULE_* 187 * <linux/i2c/twl.h> defines for TWL4030_MODULE_*
@@ -197,34 +189,62 @@ static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
197 */ 189 */
198 190
199 { 0, TWL4030_BASEADD_USB }, 191 { 0, TWL4030_BASEADD_USB },
200
201 { 1, TWL4030_BASEADD_AUDIO_VOICE }, 192 { 1, TWL4030_BASEADD_AUDIO_VOICE },
202 { 1, TWL4030_BASEADD_GPIO }, 193 { 1, TWL4030_BASEADD_GPIO },
203 { 1, TWL4030_BASEADD_INTBR }, 194 { 1, TWL4030_BASEADD_INTBR },
204 { 1, TWL4030_BASEADD_PIH }, 195 { 1, TWL4030_BASEADD_PIH },
205 { 1, TWL4030_BASEADD_TEST },
206 196
197 { 1, TWL4030_BASEADD_TEST },
207 { 2, TWL4030_BASEADD_KEYPAD }, 198 { 2, TWL4030_BASEADD_KEYPAD },
208 { 2, TWL4030_BASEADD_MADC }, 199 { 2, TWL4030_BASEADD_MADC },
209 { 2, TWL4030_BASEADD_INTERRUPTS }, 200 { 2, TWL4030_BASEADD_INTERRUPTS },
210 { 2, TWL4030_BASEADD_LED }, 201 { 2, TWL4030_BASEADD_LED },
202
211 { 2, TWL4030_BASEADD_MAIN_CHARGE }, 203 { 2, TWL4030_BASEADD_MAIN_CHARGE },
212 { 2, TWL4030_BASEADD_PRECHARGE }, 204 { 2, TWL4030_BASEADD_PRECHARGE },
213 { 2, TWL4030_BASEADD_PWM0 }, 205 { 2, TWL4030_BASEADD_PWM0 },
214 { 2, TWL4030_BASEADD_PWM1 }, 206 { 2, TWL4030_BASEADD_PWM1 },
215 { 2, TWL4030_BASEADD_PWMA }, 207 { 2, TWL4030_BASEADD_PWMA },
208
216 { 2, TWL4030_BASEADD_PWMB }, 209 { 2, TWL4030_BASEADD_PWMB },
217 { 2, TWL5031_BASEADD_ACCESSORY }, 210 { 2, TWL5031_BASEADD_ACCESSORY },
218 { 2, TWL5031_BASEADD_INTERRUPTS }, 211 { 2, TWL5031_BASEADD_INTERRUPTS },
219
220 { 3, TWL4030_BASEADD_BACKUP }, 212 { 3, TWL4030_BASEADD_BACKUP },
221 { 3, TWL4030_BASEADD_INT }, 213 { 3, TWL4030_BASEADD_INT },
214
222 { 3, TWL4030_BASEADD_PM_MASTER }, 215 { 3, TWL4030_BASEADD_PM_MASTER },
223 { 3, TWL4030_BASEADD_PM_RECEIVER }, 216 { 3, TWL4030_BASEADD_PM_RECEIVER },
224 { 3, TWL4030_BASEADD_RTC }, 217 { 3, TWL4030_BASEADD_RTC },
225 { 3, TWL4030_BASEADD_SECURED_REG }, 218 { 3, TWL4030_BASEADD_SECURED_REG },
226}; 219};
227 220
221static struct regmap_config twl4030_regmap_config[4] = {
222 {
223 /* Address 0x48 */
224 .reg_bits = 8,
225 .val_bits = 8,
226 .max_register = 0xff,
227 },
228 {
229 /* Address 0x49 */
230 .reg_bits = 8,
231 .val_bits = 8,
232 .max_register = 0xff,
233 },
234 {
235 /* Address 0x4a */
236 .reg_bits = 8,
237 .val_bits = 8,
238 .max_register = 0xff,
239 },
240 {
241 /* Address 0x4b */
242 .reg_bits = 8,
243 .val_bits = 8,
244 .max_register = 0xff,
245 },
246};
247
228static struct twl_mapping twl6030_map[] = { 248static struct twl_mapping twl6030_map[] = {
229 /* 249 /*
230 * NOTE: don't change this table without updating the 250 * NOTE: don't change this table without updating the
@@ -254,14 +274,35 @@ static struct twl_mapping twl6030_map[] = {
254 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 274 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
255 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 275 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
256 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 276 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
277
257 { SUB_CHIP_ID0, TWL6030_BASEADD_PM_MASTER }, 278 { SUB_CHIP_ID0, TWL6030_BASEADD_PM_MASTER },
258 { SUB_CHIP_ID0, TWL6030_BASEADD_PM_SLAVE_MISC }, 279 { SUB_CHIP_ID0, TWL6030_BASEADD_PM_SLAVE_MISC },
259
260 { SUB_CHIP_ID0, TWL6030_BASEADD_RTC }, 280 { SUB_CHIP_ID0, TWL6030_BASEADD_RTC },
261 { SUB_CHIP_ID0, TWL6030_BASEADD_MEM }, 281 { SUB_CHIP_ID0, TWL6030_BASEADD_MEM },
262 { SUB_CHIP_ID1, TWL6025_BASEADD_CHARGER }, 282 { SUB_CHIP_ID1, TWL6025_BASEADD_CHARGER },
263}; 283};
264 284
285static struct regmap_config twl6030_regmap_config[3] = {
286 {
287 /* Address 0x48 */
288 .reg_bits = 8,
289 .val_bits = 8,
290 .max_register = 0xff,
291 },
292 {
293 /* Address 0x49 */
294 .reg_bits = 8,
295 .val_bits = 8,
296 .max_register = 0xff,
297 },
298 {
299 /* Address 0x4a */
300 .reg_bits = 8,
301 .val_bits = 8,
302 .max_register = 0xff,
303 },
304};
305
265/*----------------------------------------------------------------------*/ 306/*----------------------------------------------------------------------*/
266 307
267/* Exported Functions */ 308/* Exported Functions */
@@ -283,9 +324,8 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
283 int ret; 324 int ret;
284 int sid; 325 int sid;
285 struct twl_client *twl; 326 struct twl_client *twl;
286 struct i2c_msg *msg;
287 327
288 if (unlikely(mod_no > TWL_MODULE_LAST)) { 328 if (unlikely(mod_no >= TWL_MODULE_LAST)) {
289 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 329 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
290 return -EPERM; 330 return -EPERM;
291 } 331 }
@@ -301,32 +341,14 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
301 } 341 }
302 twl = &twl_modules[sid]; 342 twl = &twl_modules[sid];
303 343
304 mutex_lock(&twl->xfer_lock); 344 ret = regmap_bulk_write(twl->regmap, twl_map[mod_no].base + reg,
305 /* 345 value, num_bytes);
306 * [MSG1]: fill the register address data 346
307 * fill the data Tx buffer 347 if (ret)
308 */ 348 pr_err("%s: Write failed (mod %d, reg 0x%02x count %d)\n",
309 msg = &twl->xfer_msg[0]; 349 DRIVER_NAME, mod_no, reg, num_bytes);
310 msg->addr = twl->address; 350
311 msg->len = num_bytes + 1; 351 return ret;
312 msg->flags = 0;
313 msg->buf = value;
314 /* over write the first byte of buffer with the register address */
315 *value = twl_map[mod_no].base + reg;
316 ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 1);
317 mutex_unlock(&twl->xfer_lock);
318
319 /* i2c_transfer returns number of messages transferred */
320 if (ret != 1) {
321 pr_err("%s: i2c_write failed to transfer all messages\n",
322 DRIVER_NAME);
323 if (ret < 0)
324 return ret;
325 else
326 return -EIO;
327 } else {
328 return 0;
329 }
330} 352}
331EXPORT_SYMBOL(twl_i2c_write); 353EXPORT_SYMBOL(twl_i2c_write);
332 354
@@ -342,12 +364,10 @@ EXPORT_SYMBOL(twl_i2c_write);
342int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 364int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
343{ 365{
344 int ret; 366 int ret;
345 u8 val;
346 int sid; 367 int sid;
347 struct twl_client *twl; 368 struct twl_client *twl;
348 struct i2c_msg *msg;
349 369
350 if (unlikely(mod_no > TWL_MODULE_LAST)) { 370 if (unlikely(mod_no >= TWL_MODULE_LAST)) {
351 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 371 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
352 return -EPERM; 372 return -EPERM;
353 } 373 }
@@ -363,34 +383,14 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
363 } 383 }
364 twl = &twl_modules[sid]; 384 twl = &twl_modules[sid];
365 385
366 mutex_lock(&twl->xfer_lock); 386 ret = regmap_bulk_read(twl->regmap, twl_map[mod_no].base + reg,
367 /* [MSG1] fill the register address data */ 387 value, num_bytes);
368 msg = &twl->xfer_msg[0]; 388
369 msg->addr = twl->address; 389 if (ret)
370 msg->len = 1; 390 pr_err("%s: Read failed (mod %d, reg 0x%02x count %d)\n",
371 msg->flags = 0; /* Read the register value */ 391 DRIVER_NAME, mod_no, reg, num_bytes);
372 val = twl_map[mod_no].base + reg; 392
373 msg->buf = &val; 393 return ret;
374 /* [MSG2] fill the data rx buffer */
375 msg = &twl->xfer_msg[1];
376 msg->addr = twl->address;
377 msg->flags = I2C_M_RD; /* Read the register value */
378 msg->len = num_bytes; /* only n bytes */
379 msg->buf = value;
380 ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 2);
381 mutex_unlock(&twl->xfer_lock);
382
383 /* i2c_transfer returns number of messages transferred */
384 if (ret != 2) {
385 pr_err("%s: i2c_read failed to transfer all messages\n",
386 DRIVER_NAME);
387 if (ret < 0)
388 return ret;
389 else
390 return -EIO;
391 } else {
392 return 0;
393 }
394} 394}
395EXPORT_SYMBOL(twl_i2c_read); 395EXPORT_SYMBOL(twl_i2c_read);
396 396
@@ -404,12 +404,7 @@ EXPORT_SYMBOL(twl_i2c_read);
404 */ 404 */
405int twl_i2c_write_u8(u8 mod_no, u8 value, u8 reg) 405int twl_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
406{ 406{
407 407 return twl_i2c_write(mod_no, &value, reg, 1);
408 /* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */
409 u8 temp_buffer[2] = { 0 };
410 /* offset 1 contains the data */
411 temp_buffer[1] = value;
412 return twl_i2c_write(mod_no, temp_buffer, reg, 1);
413} 408}
414EXPORT_SYMBOL(twl_i2c_write_u8); 409EXPORT_SYMBOL(twl_i2c_write_u8);
415 410
@@ -646,8 +641,9 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
646 return PTR_ERR(child); 641 return PTR_ERR(child);
647 } 642 }
648 643
649 if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc) { 644 if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc &&
650 child = add_child(2, "twl4030_madc", 645 twl_class_is_4030()) {
646 child = add_child(SUB_CHIP_ID2, "twl4030_madc",
651 pdata->madc, sizeof(*pdata->madc), 647 pdata->madc, sizeof(*pdata->madc),
652 true, irq_base + MADC_INTR_OFFSET, 0); 648 true, irq_base + MADC_INTR_OFFSET, 0);
653 if (IS_ERR(child)) 649 if (IS_ERR(child))
@@ -663,15 +659,21 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
663 * HW security concerns, and "least privilege". 659 * HW security concerns, and "least privilege".
664 */ 660 */
665 sub_chip_id = twl_map[TWL_MODULE_RTC].sid; 661 sub_chip_id = twl_map[TWL_MODULE_RTC].sid;
666 child = add_child(sub_chip_id, "twl_rtc", 662 child = add_child(sub_chip_id, "twl_rtc", NULL, 0,
667 NULL, 0,
668 true, irq_base + RTC_INTR_OFFSET, 0); 663 true, irq_base + RTC_INTR_OFFSET, 0);
669 if (IS_ERR(child)) 664 if (IS_ERR(child))
670 return PTR_ERR(child); 665 return PTR_ERR(child);
671 } 666 }
672 667
673 if (IS_ENABLED(CONFIG_PWM_TWL6030) && twl_class_is_6030()) { 668 if (IS_ENABLED(CONFIG_PWM_TWL)) {
674 child = add_child(SUB_CHIP_ID1, "twl6030-pwm", NULL, 0, 669 child = add_child(SUB_CHIP_ID1, "twl-pwm", NULL, 0,
670 false, 0, 0);
671 if (IS_ERR(child))
672 return PTR_ERR(child);
673 }
674
675 if (IS_ENABLED(CONFIG_PWM_TWL_LED)) {
676 child = add_child(SUB_CHIP_ID1, "twl-pwmled", NULL, 0,
675 false, 0, 0); 677 false, 0, 0);
676 if (IS_ERR(child)) 678 if (IS_ERR(child))
677 return PTR_ERR(child); 679 return PTR_ERR(child);
@@ -723,9 +725,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
723 725
724 } 726 }
725 727
726 child = add_child(0, "twl4030_usb", 728 child = add_child(SUB_CHIP_ID0, "twl4030_usb",
727 pdata->usb, sizeof(*pdata->usb), 729 pdata->usb, sizeof(*pdata->usb), true,
728 true,
729 /* irq0 = USB_PRES, irq1 = USB */ 730 /* irq0 = USB_PRES, irq1 = USB */
730 irq_base + USB_PRES_INTR_OFFSET, 731 irq_base + USB_PRES_INTR_OFFSET,
731 irq_base + USB_INTR_OFFSET); 732 irq_base + USB_INTR_OFFSET);
@@ -773,9 +774,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
773 774
774 pdata->usb->features = features; 775 pdata->usb->features = features;
775 776
776 child = add_child(0, "twl6030_usb", 777 child = add_child(SUB_CHIP_ID0, "twl6030_usb",
777 pdata->usb, sizeof(*pdata->usb), 778 pdata->usb, sizeof(*pdata->usb), true,
778 true,
779 /* irq1 = VBUS_PRES, irq0 = USB ID */ 779 /* irq1 = VBUS_PRES, irq0 = USB ID */
780 irq_base + USBOTG_INTR_OFFSET, 780 irq_base + USBOTG_INTR_OFFSET,
781 irq_base + USB_PRES_INTR_OFFSET); 781 irq_base + USB_PRES_INTR_OFFSET);
@@ -799,22 +799,22 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
799 } 799 }
800 800
801 if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) { 801 if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) {
802 child = add_child(0, "twl4030_wdt", NULL, 0, false, 0, 0); 802 child = add_child(SUB_CHIP_ID3, "twl4030_wdt", NULL, 0,
803 false, 0, 0);
803 if (IS_ERR(child)) 804 if (IS_ERR(child))
804 return PTR_ERR(child); 805 return PTR_ERR(child);
805 } 806 }
806 807
807 if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON) && twl_class_is_4030()) { 808 if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON) && twl_class_is_4030()) {
808 child = add_child(1, "twl4030_pwrbutton", 809 child = add_child(SUB_CHIP_ID3, "twl4030_pwrbutton", NULL, 0,
809 NULL, 0, true, irq_base + 8 + 0, 0); 810 true, irq_base + 8 + 0, 0);
810 if (IS_ERR(child)) 811 if (IS_ERR(child))
811 return PTR_ERR(child); 812 return PTR_ERR(child);
812 } 813 }
813 814
814 if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO) && pdata->audio && 815 if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO) && pdata->audio &&
815 twl_class_is_4030()) { 816 twl_class_is_4030()) {
816 sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid; 817 child = add_child(SUB_CHIP_ID1, "twl4030-audio",
817 child = add_child(sub_chip_id, "twl4030-audio",
818 pdata->audio, sizeof(*pdata->audio), 818 pdata->audio, sizeof(*pdata->audio),
819 false, 0, 0); 819 false, 0, 0);
820 if (IS_ERR(child)) 820 if (IS_ERR(child))
@@ -1054,7 +1054,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
1054 1054
1055 if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci && 1055 if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci &&
1056 !(features & (TPS_SUBSET | TWL5031))) { 1056 !(features & (TPS_SUBSET | TWL5031))) {
1057 child = add_child(3, "twl4030_bci", 1057 child = add_child(SUB_CHIP_ID3, "twl4030_bci",
1058 pdata->bci, sizeof(*pdata->bci), false, 1058 pdata->bci, sizeof(*pdata->bci), false,
1059 /* irq0 = CHG_PRES, irq1 = BCI */ 1059 /* irq0 = CHG_PRES, irq1 = BCI */
1060 irq_base + BCI_PRES_INTR_OFFSET, 1060 irq_base + BCI_PRES_INTR_OFFSET,
@@ -1077,8 +1077,8 @@ static inline int __init protect_pm_master(void)
1077{ 1077{
1078 int e = 0; 1078 int e = 0;
1079 1079
1080 e = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, 1080 e = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0,
1081 TWL4030_PM_MASTER_PROTECT_KEY); 1081 TWL4030_PM_MASTER_PROTECT_KEY);
1082 return e; 1082 return e;
1083} 1083}
1084 1084
@@ -1086,12 +1086,10 @@ static inline int __init unprotect_pm_master(void)
1086{ 1086{
1087 int e = 0; 1087 int e = 0;
1088 1088
1089 e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 1089 e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
1090 TWL4030_PM_MASTER_KEY_CFG1, 1090 TWL4030_PM_MASTER_PROTECT_KEY);
1091 TWL4030_PM_MASTER_PROTECT_KEY); 1091 e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2,
1092 e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 1092 TWL4030_PM_MASTER_PROTECT_KEY);
1093 TWL4030_PM_MASTER_KEY_CFG2,
1094 TWL4030_PM_MASTER_PROTECT_KEY);
1095 1093
1096 return e; 1094 return e;
1097} 1095}
@@ -1176,6 +1174,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1176 struct twl4030_platform_data *pdata = client->dev.platform_data; 1174 struct twl4030_platform_data *pdata = client->dev.platform_data;
1177 struct device_node *node = client->dev.of_node; 1175 struct device_node *node = client->dev.of_node;
1178 struct platform_device *pdev; 1176 struct platform_device *pdev;
1177 struct regmap_config *twl_regmap_config;
1179 int irq_base = 0; 1178 int irq_base = 0;
1180 int status; 1179 int status;
1181 unsigned i, num_slaves; 1180 unsigned i, num_slaves;
@@ -1229,22 +1228,23 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1229 if ((id->driver_data) & TWL6030_CLASS) { 1228 if ((id->driver_data) & TWL6030_CLASS) {
1230 twl_id = TWL6030_CLASS_ID; 1229 twl_id = TWL6030_CLASS_ID;
1231 twl_map = &twl6030_map[0]; 1230 twl_map = &twl6030_map[0];
1231 twl_regmap_config = twl6030_regmap_config;
1232 num_slaves = TWL_NUM_SLAVES - 1; 1232 num_slaves = TWL_NUM_SLAVES - 1;
1233 } else { 1233 } else {
1234 twl_id = TWL4030_CLASS_ID; 1234 twl_id = TWL4030_CLASS_ID;
1235 twl_map = &twl4030_map[0]; 1235 twl_map = &twl4030_map[0];
1236 twl_regmap_config = twl4030_regmap_config;
1236 num_slaves = TWL_NUM_SLAVES; 1237 num_slaves = TWL_NUM_SLAVES;
1237 } 1238 }
1238 1239
1239 for (i = 0; i < num_slaves; i++) { 1240 for (i = 0; i < num_slaves; i++) {
1240 struct twl_client *twl = &twl_modules[i]; 1241 struct twl_client *twl = &twl_modules[i];
1241 1242
1242 twl->address = client->addr + i;
1243 if (i == 0) { 1243 if (i == 0) {
1244 twl->client = client; 1244 twl->client = client;
1245 } else { 1245 } else {
1246 twl->client = i2c_new_dummy(client->adapter, 1246 twl->client = i2c_new_dummy(client->adapter,
1247 twl->address); 1247 client->addr + i);
1248 if (!twl->client) { 1248 if (!twl->client) {
1249 dev_err(&client->dev, 1249 dev_err(&client->dev,
1250 "can't attach client %d\n", i); 1250 "can't attach client %d\n", i);
@@ -1252,7 +1252,16 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1252 goto fail; 1252 goto fail;
1253 } 1253 }
1254 } 1254 }
1255 mutex_init(&twl->xfer_lock); 1255
1256 twl->regmap = devm_regmap_init_i2c(twl->client,
1257 &twl_regmap_config[i]);
1258 if (IS_ERR(twl->regmap)) {
1259 status = PTR_ERR(twl->regmap);
1260 dev_err(&client->dev,
1261 "Failed to allocate regmap %d, err: %d\n", i,
1262 status);
1263 goto fail;
1264 }
1256 } 1265 }
1257 1266
1258 inuse = true; 1267 inuse = true;