aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2012-11-13 03:28:52 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2012-11-21 10:08:05 -0500
commit4850f1247aa495a664133fb3f6b8139b89b2c6db (patch)
tree0156c235113c3f5ba078f76abb81b9034672374f
parente45342f678d0f08d284358504f995f495fc6f4f1 (diff)
mfd: twl4030-power: Change TWL4030_MODULE_* ids to TWL_MODULE_*
To facilitate upcoming cleanup in twl stack. No functional changes. Acked-by: Tero Kristo <t-kristo@ti.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/mfd/twl4030-power.c124
1 files changed, 51 insertions, 73 deletions
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 79ca33dfacca..4fda77c74552 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -128,12 +128,10 @@ static int __devinit twl4030_write_script_byte(u8 address, u8 byte)
128{ 128{
129 int err; 129 int err;
130 130
131 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 131 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_MEMORY_ADDRESS);
132 R_MEMORY_ADDRESS);
133 if (err) 132 if (err)
134 goto out; 133 goto out;
135 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, byte, 134 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, byte, R_MEMORY_DATA);
136 R_MEMORY_DATA);
137out: 135out:
138 return err; 136 return err;
139} 137}
@@ -189,19 +187,16 @@ static int __devinit twl4030_config_wakeup3_sequence(u8 address)
189 u8 data; 187 u8 data;
190 188
191 /* Set SLEEP to ACTIVE SEQ address for P3 */ 189 /* Set SLEEP to ACTIVE SEQ address for P3 */
192 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 190 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_S2A3);
193 R_SEQ_ADD_S2A3);
194 if (err) 191 if (err)
195 goto out; 192 goto out;
196 193
197 /* P3 LVL_WAKEUP should be on LEVEL */ 194 /* P3 LVL_WAKEUP should be on LEVEL */
198 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 195 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data, R_P3_SW_EVENTS);
199 R_P3_SW_EVENTS);
200 if (err) 196 if (err)
201 goto out; 197 goto out;
202 data |= LVL_WAKEUP; 198 data |= LVL_WAKEUP;
203 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 199 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P3_SW_EVENTS);
204 R_P3_SW_EVENTS);
205out: 200out:
206 if (err) 201 if (err)
207 pr_err("TWL4030 wakeup sequence for P3 config error\n"); 202 pr_err("TWL4030 wakeup sequence for P3 config error\n");
@@ -214,43 +209,38 @@ static int __devinit twl4030_config_wakeup12_sequence(u8 address)
214 u8 data; 209 u8 data;
215 210
216 /* Set SLEEP to ACTIVE SEQ address for P1 and P2 */ 211 /* Set SLEEP to ACTIVE SEQ address for P1 and P2 */
217 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 212 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_S2A12);
218 R_SEQ_ADD_S2A12);
219 if (err) 213 if (err)
220 goto out; 214 goto out;
221 215
222 /* P1/P2 LVL_WAKEUP should be on LEVEL */ 216 /* P1/P2 LVL_WAKEUP should be on LEVEL */
223 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 217 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data, R_P1_SW_EVENTS);
224 R_P1_SW_EVENTS);
225 if (err) 218 if (err)
226 goto out; 219 goto out;
227 220
228 data |= LVL_WAKEUP; 221 data |= LVL_WAKEUP;
229 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 222 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P1_SW_EVENTS);
230 R_P1_SW_EVENTS);
231 if (err) 223 if (err)
232 goto out; 224 goto out;
233 225
234 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 226 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data, R_P2_SW_EVENTS);
235 R_P2_SW_EVENTS);
236 if (err) 227 if (err)
237 goto out; 228 goto out;
238 229
239 data |= LVL_WAKEUP; 230 data |= LVL_WAKEUP;
240 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 231 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P2_SW_EVENTS);
241 R_P2_SW_EVENTS);
242 if (err) 232 if (err)
243 goto out; 233 goto out;
244 234
245 if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) { 235 if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) {
246 /* Disabling AC charger effect on sleep-active transitions */ 236 /* Disabling AC charger effect on sleep-active transitions */
247 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 237 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data,
248 R_CFG_P1_TRANSITION); 238 R_CFG_P1_TRANSITION);
249 if (err) 239 if (err)
250 goto out; 240 goto out;
251 data &= ~(1<<1); 241 data &= ~(1<<1);
252 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data , 242 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data,
253 R_CFG_P1_TRANSITION); 243 R_CFG_P1_TRANSITION);
254 if (err) 244 if (err)
255 goto out; 245 goto out;
256 } 246 }
@@ -267,8 +257,7 @@ static int __devinit twl4030_config_sleep_sequence(u8 address)
267 int err; 257 int err;
268 258
269 /* Set ACTIVE to SLEEP SEQ address in T2 memory*/ 259 /* Set ACTIVE to SLEEP SEQ address in T2 memory*/
270 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 260 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_A2S);
271 R_SEQ_ADD_A2S);
272 261
273 if (err) 262 if (err)
274 pr_err("TWL4030 sleep sequence config error\n"); 263 pr_err("TWL4030 sleep sequence config error\n");
@@ -282,42 +271,35 @@ static int __devinit twl4030_config_warmreset_sequence(u8 address)
282 u8 rd_data; 271 u8 rd_data;
283 272
284 /* Set WARM RESET SEQ address for P1 */ 273 /* Set WARM RESET SEQ address for P1 */
285 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 274 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_WARM);
286 R_SEQ_ADD_WARM);
287 if (err) 275 if (err)
288 goto out; 276 goto out;
289 277
290 /* P1/P2/P3 enable WARMRESET */ 278 /* P1/P2/P3 enable WARMRESET */
291 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 279 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &rd_data, R_P1_SW_EVENTS);
292 R_P1_SW_EVENTS);
293 if (err) 280 if (err)
294 goto out; 281 goto out;
295 282
296 rd_data |= ENABLE_WARMRESET; 283 rd_data |= ENABLE_WARMRESET;
297 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 284 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, rd_data, R_P1_SW_EVENTS);
298 R_P1_SW_EVENTS);
299 if (err) 285 if (err)
300 goto out; 286 goto out;
301 287
302 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 288 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &rd_data, R_P2_SW_EVENTS);
303 R_P2_SW_EVENTS);
304 if (err) 289 if (err)
305 goto out; 290 goto out;
306 291
307 rd_data |= ENABLE_WARMRESET; 292 rd_data |= ENABLE_WARMRESET;
308 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 293 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, rd_data, R_P2_SW_EVENTS);
309 R_P2_SW_EVENTS);
310 if (err) 294 if (err)
311 goto out; 295 goto out;
312 296
313 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 297 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &rd_data, R_P3_SW_EVENTS);
314 R_P3_SW_EVENTS);
315 if (err) 298 if (err)
316 goto out; 299 goto out;
317 300
318 rd_data |= ENABLE_WARMRESET; 301 rd_data |= ENABLE_WARMRESET;
319 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 302 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, rd_data, R_P3_SW_EVENTS);
320 R_P3_SW_EVENTS);
321out: 303out:
322 if (err) 304 if (err)
323 pr_err("TWL4030 warmreset seq config error\n"); 305 pr_err("TWL4030 warmreset seq config error\n");
@@ -341,7 +323,7 @@ static int __devinit twl4030_configure_resource(struct twl4030_resconfig *rconfi
341 rconfig_addr = res_config_addrs[rconfig->resource]; 323 rconfig_addr = res_config_addrs[rconfig->resource];
342 324
343 /* Set resource group */ 325 /* Set resource group */
344 err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &grp, 326 err = twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &grp,
345 rconfig_addr + DEV_GRP_OFFSET); 327 rconfig_addr + DEV_GRP_OFFSET);
346 if (err) { 328 if (err) {
347 pr_err("TWL4030 Resource %d group could not be read\n", 329 pr_err("TWL4030 Resource %d group could not be read\n",
@@ -352,7 +334,7 @@ static int __devinit twl4030_configure_resource(struct twl4030_resconfig *rconfi
352 if (rconfig->devgroup != TWL4030_RESCONFIG_UNDEF) { 334 if (rconfig->devgroup != TWL4030_RESCONFIG_UNDEF) {
353 grp &= ~DEV_GRP_MASK; 335 grp &= ~DEV_GRP_MASK;
354 grp |= rconfig->devgroup << DEV_GRP_SHIFT; 336 grp |= rconfig->devgroup << DEV_GRP_SHIFT;
355 err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 337 err = twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER,
356 grp, rconfig_addr + DEV_GRP_OFFSET); 338 grp, rconfig_addr + DEV_GRP_OFFSET);
357 if (err < 0) { 339 if (err < 0) {
358 pr_err("TWL4030 failed to program devgroup\n"); 340 pr_err("TWL4030 failed to program devgroup\n");
@@ -361,7 +343,7 @@ static int __devinit twl4030_configure_resource(struct twl4030_resconfig *rconfi
361 } 343 }
362 344
363 /* Set resource types */ 345 /* Set resource types */
364 err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &type, 346 err = twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &type,
365 rconfig_addr + TYPE_OFFSET); 347 rconfig_addr + TYPE_OFFSET);
366 if (err < 0) { 348 if (err < 0) {
367 pr_err("TWL4030 Resource %d type could not be read\n", 349 pr_err("TWL4030 Resource %d type could not be read\n",
@@ -379,7 +361,7 @@ static int __devinit twl4030_configure_resource(struct twl4030_resconfig *rconfi
379 type |= rconfig->type2 << TYPE2_SHIFT; 361 type |= rconfig->type2 << TYPE2_SHIFT;
380 } 362 }
381 363
382 err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 364 err = twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER,
383 type, rconfig_addr + TYPE_OFFSET); 365 type, rconfig_addr + TYPE_OFFSET);
384 if (err < 0) { 366 if (err < 0) {
385 pr_err("TWL4030 failed to program resource type\n"); 367 pr_err("TWL4030 failed to program resource type\n");
@@ -387,7 +369,7 @@ static int __devinit twl4030_configure_resource(struct twl4030_resconfig *rconfi
387 } 369 }
388 370
389 /* Set remap states */ 371 /* Set remap states */
390 err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &remap, 372 err = twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &remap,
391 rconfig_addr + REMAP_OFFSET); 373 rconfig_addr + REMAP_OFFSET);
392 if (err < 0) { 374 if (err < 0) {
393 pr_err("TWL4030 Resource %d remap could not be read\n", 375 pr_err("TWL4030 Resource %d remap could not be read\n",
@@ -405,7 +387,7 @@ static int __devinit twl4030_configure_resource(struct twl4030_resconfig *rconfi
405 remap |= rconfig->remap_sleep << SLEEP_STATE_SHIFT; 387 remap |= rconfig->remap_sleep << SLEEP_STATE_SHIFT;
406 } 388 }
407 389
408 err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 390 err = twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER,
409 remap, 391 remap,
410 rconfig_addr + REMAP_OFFSET); 392 rconfig_addr + REMAP_OFFSET);
411 if (err < 0) { 393 if (err < 0) {
@@ -463,49 +445,47 @@ int twl4030_remove_script(u8 flags)
463{ 445{
464 int err = 0; 446 int err = 0;
465 447
466 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 448 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
467 TWL4030_PM_MASTER_KEY_CFG1, 449 TWL4030_PM_MASTER_PROTECT_KEY);
468 TWL4030_PM_MASTER_PROTECT_KEY);
469 if (err) { 450 if (err) {
470 pr_err("twl4030: unable to unlock PROTECT_KEY\n"); 451 pr_err("twl4030: unable to unlock PROTECT_KEY\n");
471 return err; 452 return err;
472 } 453 }
473 454
474 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 455 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2,
475 TWL4030_PM_MASTER_KEY_CFG2, 456 TWL4030_PM_MASTER_PROTECT_KEY);
476 TWL4030_PM_MASTER_PROTECT_KEY);
477 if (err) { 457 if (err) {
478 pr_err("twl4030: unable to unlock PROTECT_KEY\n"); 458 pr_err("twl4030: unable to unlock PROTECT_KEY\n");
479 return err; 459 return err;
480 } 460 }
481 461
482 if (flags & TWL4030_WRST_SCRIPT) { 462 if (flags & TWL4030_WRST_SCRIPT) {
483 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, 463 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT,
484 R_SEQ_ADD_WARM); 464 R_SEQ_ADD_WARM);
485 if (err) 465 if (err)
486 return err; 466 return err;
487 } 467 }
488 if (flags & TWL4030_WAKEUP12_SCRIPT) { 468 if (flags & TWL4030_WAKEUP12_SCRIPT) {
489 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, 469 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT,
490 R_SEQ_ADD_S2A12); 470 R_SEQ_ADD_S2A12);
491 if (err) 471 if (err)
492 return err; 472 return err;
493 } 473 }
494 if (flags & TWL4030_WAKEUP3_SCRIPT) { 474 if (flags & TWL4030_WAKEUP3_SCRIPT) {
495 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, 475 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT,
496 R_SEQ_ADD_S2A3); 476 R_SEQ_ADD_S2A3);
497 if (err) 477 if (err)
498 return err; 478 return err;
499 } 479 }
500 if (flags & TWL4030_SLEEP_SCRIPT) { 480 if (flags & TWL4030_SLEEP_SCRIPT) {
501 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, 481 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT,
502 R_SEQ_ADD_A2S); 482 R_SEQ_ADD_A2S);
503 if (err) 483 if (err)
504 return err; 484 return err;
505 } 485 }
506 486
507 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, 487 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0,
508 TWL4030_PM_MASTER_PROTECT_KEY); 488 TWL4030_PM_MASTER_PROTECT_KEY);
509 if (err) 489 if (err)
510 pr_err("TWL4030 Unable to relock registers\n"); 490 pr_err("TWL4030 Unable to relock registers\n");
511 491
@@ -521,7 +501,7 @@ void twl4030_power_off(void)
521{ 501{
522 int err; 502 int err;
523 503
524 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, PWR_DEVOFF, 504 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, PWR_DEVOFF,
525 TWL4030_PM_MASTER_P1_SW_EVENTS); 505 TWL4030_PM_MASTER_P1_SW_EVENTS);
526 if (err) 506 if (err)
527 pr_err("TWL4030 Unable to power off\n"); 507 pr_err("TWL4030 Unable to power off\n");
@@ -534,15 +514,13 @@ void __devinit twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
534 struct twl4030_resconfig *resconfig; 514 struct twl4030_resconfig *resconfig;
535 u8 val, address = twl4030_start_script_address; 515 u8 val, address = twl4030_start_script_address;
536 516
537 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 517 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
538 TWL4030_PM_MASTER_KEY_CFG1, 518 TWL4030_PM_MASTER_PROTECT_KEY);
539 TWL4030_PM_MASTER_PROTECT_KEY);
540 if (err) 519 if (err)
541 goto unlock; 520 goto unlock;
542 521
543 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 522 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2,
544 TWL4030_PM_MASTER_KEY_CFG2, 523 TWL4030_PM_MASTER_PROTECT_KEY);
545 TWL4030_PM_MASTER_PROTECT_KEY);
546 if (err) 524 if (err)
547 goto unlock; 525 goto unlock;
548 526
@@ -567,14 +545,14 @@ void __devinit twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
567 /* Board has to be wired properly to use this feature */ 545 /* Board has to be wired properly to use this feature */
568 if (twl4030_scripts->use_poweroff && !pm_power_off) { 546 if (twl4030_scripts->use_poweroff && !pm_power_off) {
569 /* Default for SEQ_OFFSYNC is set, lets ensure this */ 547 /* Default for SEQ_OFFSYNC is set, lets ensure this */
570 err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val, 548 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
571 TWL4030_PM_MASTER_CFG_P123_TRANSITION); 549 TWL4030_PM_MASTER_CFG_P123_TRANSITION);
572 if (err) { 550 if (err) {
573 pr_warning("TWL4030 Unable to read registers\n"); 551 pr_warning("TWL4030 Unable to read registers\n");
574 552
575 } else if (!(val & SEQ_OFFSYNC)) { 553 } else if (!(val & SEQ_OFFSYNC)) {
576 val |= SEQ_OFFSYNC; 554 val |= SEQ_OFFSYNC;
577 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val, 555 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, val,
578 TWL4030_PM_MASTER_CFG_P123_TRANSITION); 556 TWL4030_PM_MASTER_CFG_P123_TRANSITION);
579 if (err) { 557 if (err) {
580 pr_err("TWL4030 Unable to setup SEQ_OFFSYNC\n"); 558 pr_err("TWL4030 Unable to setup SEQ_OFFSYNC\n");
@@ -586,8 +564,8 @@ void __devinit twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
586 } 564 }
587 565
588relock: 566relock:
589 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, 567 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0,
590 TWL4030_PM_MASTER_PROTECT_KEY); 568 TWL4030_PM_MASTER_PROTECT_KEY);
591 if (err) 569 if (err)
592 pr_err("TWL4030 Unable to relock registers\n"); 570 pr_err("TWL4030 Unable to relock registers\n");
593 return; 571 return;