Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: pm: omap34xx: convert to generic suspend/resume support

Convert omap34xx to use the generic CPU suspend/resume support, rather
than implementing its own version. Tested on 3430 LDP.

Reviewed-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Acked-by: Jean Pihet <j-pihet@ti.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

+13 -177
+10 -37
arch/arm/mach-omap2/pm34xx.c
··· 40 40 #include <plat/gpmc.h> 41 41 #include <plat/dma.h> 42 42 43 - #include <asm/tlbflush.h> 44 - 45 43 #include "cm2xxx_3xxx.h" 46 44 #include "cm-regbits-34xx.h" 47 45 #include "prm-regbits-34xx.h" ··· 61 63 return false; 62 64 } 63 65 #endif 64 - 65 - /* Scratchpad offsets */ 66 - #define OMAP343X_TABLE_ADDRESS_OFFSET 0xc4 67 - #define OMAP343X_TABLE_VALUE_OFFSET 0xc0 68 - #define OMAP343X_CONTROL_REG_VALUE_OFFSET 0xc8 69 66 70 67 /* pm34xx errata defined in pm.h */ 71 68 u16 pm34xx_errata; ··· 305 312 return IRQ_HANDLED; 306 313 } 307 314 308 - /* Function to restore the table entry that was modified for enabling MMU */ 309 - static void restore_table_entry(void) 315 + static void omap34xx_do_sram_idle(unsigned long save_state) 310 316 { 311 - void __iomem *scratchpad_address; 312 - u32 previous_value, control_reg_value; 313 - u32 *address; 314 - 315 - scratchpad_address = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD); 316 - 317 - /* Get address of entry that was modified */ 318 - address = (u32 *)__raw_readl(scratchpad_address + 319 - OMAP343X_TABLE_ADDRESS_OFFSET); 320 - /* Get the previous value which needs to be restored */ 321 - previous_value = __raw_readl(scratchpad_address + 322 - OMAP343X_TABLE_VALUE_OFFSET); 323 - address = __va(address); 324 - *address = previous_value; 325 - flush_tlb_all(); 326 - control_reg_value = __raw_readl(scratchpad_address 327 - + OMAP343X_CONTROL_REG_VALUE_OFFSET); 328 - /* This will enable caches and prediction */ 329 - set_cr(control_reg_value); 317 + _omap_sram_idle(omap3_arm_context, save_state); 330 318 } 331 319 332 320 void omap_sram_idle(void) ··· 406 432 sdrc_pwr = sdrc_read_reg(SDRC_POWER); 407 433 408 434 /* 409 - * omap3_arm_context is the location where ARM registers 410 - * get saved. The restore path then reads from this 411 - * location and restores them back. 435 + * omap3_arm_context is the location where some ARM context 436 + * get saved. The rest is placed on the stack, and restored 437 + * from there before resuming. 412 438 */ 413 - _omap_sram_idle(omap3_arm_context, save_state); 414 - cpu_init(); 439 + if (save_state == 1 || save_state == 3) 440 + cpu_suspend(0, PHYS_OFFSET - PAGE_OFFSET, save_state, 441 + omap34xx_do_sram_idle); 442 + else 443 + omap34xx_do_sram_idle(save_state); 415 444 416 445 /* Restore normal SDRC POWER settings */ 417 446 if (omap_rev() >= OMAP3430_REV_ES3_0 && 418 447 omap_type() != OMAP2_DEVICE_TYPE_GP && 419 448 core_next_state == PWRDM_POWER_OFF) 420 449 sdrc_write_reg(sdrc_pwr, SDRC_POWER); 421 - 422 - /* Restore table entry modified during MMU restoration */ 423 - if (pwrdm_read_prev_pwrst(mpu_pwrdm) == PWRDM_POWER_OFF) 424 - restore_table_entry(); 425 450 426 451 /* CORE */ 427 452 if (core_next_state < PWRDM_POWER_ON) {
+3 -140
arch/arm/mach-omap2/sleep34xx.S
··· 211 211 mrc p15, 1, r5, c9, c0, 2 @ Read L2 AUX ctrl register 212 212 stmia r8!, {r4-r5} @ Push parameters for restore call 213 213 214 - /* Check what that target sleep state is from r1 */ 215 - cmp r1, #0x2 @ Only L2 lost, no need to save context 216 - beq clean_caches 217 - 218 - l1_logic_lost: 219 - mov r4, sp @ Store sp 220 - mrs r5, spsr @ Store spsr 221 - mov r6, lr @ Store lr 222 - stmia r8!, {r4-r6} 223 - 224 - mrc p15, 0, r4, c1, c0, 2 @ Coprocessor access control register 225 - mrc p15, 0, r5, c2, c0, 0 @ TTBR0 226 - mrc p15, 0, r6, c2, c0, 1 @ TTBR1 227 - mrc p15, 0, r7, c2, c0, 2 @ TTBCR 228 - stmia r8!, {r4-r7} 229 - 230 - mrc p15, 0, r4, c3, c0, 0 @ Domain access Control Register 231 - mrc p15, 0, r5, c10, c2, 0 @ PRRR 232 - mrc p15, 0, r6, c10, c2, 1 @ NMRR 233 - stmia r8!,{r4-r6} 234 - 235 - mrc p15, 0, r4, c13, c0, 1 @ Context ID 236 - mrc p15, 0, r5, c13, c0, 2 @ User r/w thread and process ID 237 - mrc p15, 0, r6, c12, c0, 0 @ Secure or NS vector base address 238 - mrs r7, cpsr @ Store current cpsr 239 - stmia r8!, {r4-r7} 240 - 241 - mrc p15, 0, r4, c1, c0, 0 @ save control register 242 - stmia r8!, {r4} 243 - 244 - clean_caches: 245 214 /* 246 215 * jump out to kernel flush routine 247 216 * - reuse that code is better ··· 435 466 orr r1, r1, #2 @ re-enable L2 cache 436 467 mcr p15, 0, r1, c1, c0, 1 437 468 skipl2reen: 438 - mov r1, #0 439 - /* 440 - * Invalidate all instruction caches to PoU 441 - * and flush branch target cache 442 - */ 443 - mcr p15, 0, r1, c7, c5, 0 444 469 445 - ldr r4, scratchpad_base 446 - ldr r3, [r4,#0xBC] 447 - adds r3, r3, #16 470 + /* Now branch to the common CPU resume function */ 471 + b cpu_resume 448 472 449 - ldmia r3!, {r4-r6} 450 - mov sp, r4 @ Restore sp 451 - msr spsr_cxsf, r5 @ Restore spsr 452 - mov lr, r6 @ Restore lr 453 - 454 - ldmia r3!, {r4-r7} 455 - mcr p15, 0, r4, c1, c0, 2 @ Coprocessor access Control Register 456 - mcr p15, 0, r5, c2, c0, 0 @ TTBR0 457 - mcr p15, 0, r6, c2, c0, 1 @ TTBR1 458 - mcr p15, 0, r7, c2, c0, 2 @ TTBCR 459 - 460 - ldmia r3!,{r4-r6} 461 - mcr p15, 0, r4, c3, c0, 0 @ Domain access Control Register 462 - mcr p15, 0, r5, c10, c2, 0 @ PRRR 463 - mcr p15, 0, r6, c10, c2, 1 @ NMRR 464 - 465 - 466 - ldmia r3!,{r4-r7} 467 - mcr p15, 0, r4, c13, c0, 1 @ Context ID 468 - mcr p15, 0, r5, c13, c0, 2 @ User r/w thread and process ID 469 - mrc p15, 0, r6, c12, c0, 0 @ Secure or NS vector base address 470 - msr cpsr, r7 @ store cpsr 471 - 472 - /* Enabling MMU here */ 473 - mrc p15, 0, r7, c2, c0, 2 @ Read TTBRControl 474 - /* Extract N (0:2) bits and decide whether to use TTBR0 or TTBR1 */ 475 - and r7, #0x7 476 - cmp r7, #0x0 477 - beq usettbr0 478 - ttbr_error: 479 - /* 480 - * More work needs to be done to support N[0:2] value other than 0 481 - * So looping here so that the error can be detected 482 - */ 483 - b ttbr_error 484 - usettbr0: 485 - mrc p15, 0, r2, c2, c0, 0 486 - ldr r5, ttbrbit_mask 487 - and r2, r5 488 - mov r4, pc 489 - ldr r5, table_index_mask 490 - and r4, r5 @ r4 = 31 to 20 bits of pc 491 - /* Extract the value to be written to table entry */ 492 - ldr r1, table_entry 493 - /* r1 has the value to be written to table entry*/ 494 - add r1, r1, r4 495 - /* Getting the address of table entry to modify */ 496 - lsr r4, #18 497 - /* r2 has the location which needs to be modified */ 498 - add r2, r4 499 - /* Storing previous entry of location being modified */ 500 - ldr r5, scratchpad_base 501 - ldr r4, [r2] 502 - str r4, [r5, #0xC0] 503 - /* Modify the table entry */ 504 - str r1, [r2] 505 - /* 506 - * Storing address of entry being modified 507 - * - will be restored after enabling MMU 508 - */ 509 - ldr r5, scratchpad_base 510 - str r2, [r5, #0xC4] 511 - 512 - mov r0, #0 513 - mcr p15, 0, r0, c7, c5, 4 @ Flush prefetch buffer 514 - mcr p15, 0, r0, c7, c5, 6 @ Invalidate branch predictor array 515 - mcr p15, 0, r0, c8, c5, 0 @ Invalidate instruction TLB 516 - mcr p15, 0, r0, c8, c6, 0 @ Invalidate data TLB 517 - /* 518 - * Restore control register. This enables the MMU. 519 - * The caches and prediction are not enabled here, they 520 - * will be enabled after restoring the MMU table entry. 521 - */ 522 - ldmia r3!, {r4} 523 - /* Store previous value of control register in scratchpad */ 524 - str r4, [r5, #0xC8] 525 - ldr r2, cache_pred_disable_mask 526 - and r4, r2 527 - mcr p15, 0, r4, c1, c0, 0 528 - dsb 529 - isb 530 - ldr r0, =restoremmu_on 531 - bx r0 532 - 533 - /* 534 - * ============================== 535 - * == Exit point from OFF mode == 536 - * ============================== 537 - */ 538 - restoremmu_on: 539 - ldmfd sp!, {r4 - r11, pc} @ restore regs and return 540 - 473 + .ltorg 541 474 542 475 /* 543 476 * Internal functions ··· 590 719 .word SRAM_BASE_P + 0x8000 591 720 sdrc_power: 592 721 .word SDRC_POWER_V 593 - ttbrbit_mask: 594 - .word 0xFFFFC000 595 - table_index_mask: 596 - .word 0xFFF00000 597 - table_entry: 598 - .word 0x00000C02 599 - cache_pred_disable_mask: 600 - .word 0xFFFFE7FB 601 722 control_stat: 602 723 .word CONTROL_STAT 603 724 control_mem_rta: