| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2012, NVIDIA Corporation. All rights reserved. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 5 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 6 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 9 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 10 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 11 | | - * more details. |
|---|
| 12 | | - * |
|---|
| 13 | | - * You should have received a copy of the GNU General Public License |
|---|
| 14 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 15 | 4 | */ |
|---|
| 16 | 5 | |
|---|
| 17 | 6 | #include <linux/linkage.h> |
|---|
| .. | .. |
|---|
| 29 | 18 | #define EMC_CFG 0xc |
|---|
| 30 | 19 | #define EMC_ADR_CFG 0x10 |
|---|
| 31 | 20 | #define EMC_TIMING_CONTROL 0x28 |
|---|
| 32 | | -#define EMC_REFRESH 0x70 |
|---|
| 33 | 21 | #define EMC_NOP 0xdc |
|---|
| 34 | 22 | #define EMC_SELF_REF 0xe0 |
|---|
| 35 | 23 | #define EMC_MRW 0xe8 |
|---|
| .. | .. |
|---|
| 71 | 59 | #define CLK_RESET_PLLX_MISC3_IDDQ 3 |
|---|
| 72 | 60 | #define CLK_RESET_PLLM_MISC_IDDQ 5 |
|---|
| 73 | 61 | #define CLK_RESET_PLLC_MISC_IDDQ 26 |
|---|
| 62 | +#define CLK_RESET_PLLP_RESHIFT 0x528 |
|---|
| 63 | +#define CLK_RESET_PLLP_RESHIFT_DEFAULT 0x3b |
|---|
| 64 | +#define CLK_RESET_PLLP_RESHIFT_ENABLE 0x3 |
|---|
| 74 | 65 | |
|---|
| 75 | 66 | #define CLK_RESET_CLK_SOURCE_MSELECT 0x3b4 |
|---|
| 76 | 67 | |
|---|
| .. | .. |
|---|
| 274 | 265 | ENDPROC(tegra30_sleep_core_finish) |
|---|
| 275 | 266 | |
|---|
| 276 | 267 | /* |
|---|
| 277 | | - * tegra30_sleep_cpu_secondary_finish(unsigned long v2p) |
|---|
| 268 | + * tegra30_pm_secondary_cpu_suspend(unsigned long unused_arg) |
|---|
| 278 | 269 | * |
|---|
| 279 | 270 | * Enters LP2 on secondary CPU by exiting coherency and powergating the CPU. |
|---|
| 280 | 271 | */ |
|---|
| 281 | | -ENTRY(tegra30_sleep_cpu_secondary_finish) |
|---|
| 272 | +ENTRY(tegra30_pm_secondary_cpu_suspend) |
|---|
| 282 | 273 | mov r7, lr |
|---|
| 283 | 274 | |
|---|
| 284 | 275 | /* Flush and disable the L1 data cache */ |
|---|
| .. | .. |
|---|
| 290 | 281 | bl tegra30_cpu_shutdown |
|---|
| 291 | 282 | mov r0, #1 @ never return here |
|---|
| 292 | 283 | ret r7 |
|---|
| 293 | | -ENDPROC(tegra30_sleep_cpu_secondary_finish) |
|---|
| 284 | +ENDPROC(tegra30_pm_secondary_cpu_suspend) |
|---|
| 294 | 285 | |
|---|
| 295 | 286 | /* |
|---|
| 296 | 287 | * tegra30_tear_down_cpu |
|---|
| .. | .. |
|---|
| 370 | 361 | |
|---|
| 371 | 362 | pll_enable r1, r0, CLK_RESET_PLLM_BASE, CLK_RESET_PLLM_MISC |
|---|
| 372 | 363 | pll_enable r1, r0, CLK_RESET_PLLC_BASE, CLK_RESET_PLLC_MISC |
|---|
| 373 | | - pll_enable r1, r0, CLK_RESET_PLLX_BASE, CLK_RESET_PLLX_MISC |
|---|
| 374 | 364 | |
|---|
| 375 | 365 | _pll_m_c_x_done: |
|---|
| 376 | 366 | pll_enable r1, r0, CLK_RESET_PLLP_BASE, CLK_RESET_PLLP_MISC |
|---|
| .. | .. |
|---|
| 380 | 370 | pll_locked r1, r0, CLK_RESET_PLLP_BASE |
|---|
| 381 | 371 | pll_locked r1, r0, CLK_RESET_PLLA_BASE |
|---|
| 382 | 372 | pll_locked r1, r0, CLK_RESET_PLLC_BASE |
|---|
| 383 | | - pll_locked r1, r0, CLK_RESET_PLLX_BASE |
|---|
| 384 | 373 | |
|---|
| 374 | + /* |
|---|
| 375 | + * CPUFreq driver could select other PLL for CPU. PLLX will be |
|---|
| 376 | + * enabled by the Tegra30 CLK driver on an as-needed basis, see |
|---|
| 377 | + * tegra30_cpu_clock_resume(). |
|---|
| 378 | + */ |
|---|
| 385 | 379 | tegra_get_soc_id TEGRA_APB_MISC_BASE, r1 |
|---|
| 386 | 380 | cmp r1, #TEGRA30 |
|---|
| 387 | 381 | beq 1f |
|---|
| 382 | + |
|---|
| 383 | + pll_locked r1, r0, CLK_RESET_PLLX_BASE |
|---|
| 384 | + |
|---|
| 388 | 385 | ldr r1, [r0, #CLK_RESET_PLLP_BASE] |
|---|
| 389 | 386 | bic r1, r1, #(1<<31) @ disable PllP bypass |
|---|
| 390 | 387 | str r1, [r0, #CLK_RESET_PLLP_BASE] |
|---|
| 388 | + |
|---|
| 389 | + mov r1, #CLK_RESET_PLLP_RESHIFT_DEFAULT |
|---|
| 390 | + str r1, [r0, #CLK_RESET_PLLP_RESHIFT] |
|---|
| 391 | 391 | 1: |
|---|
| 392 | 392 | |
|---|
| 393 | 393 | mov32 r7, TEGRA_TMRUS_BASE |
|---|
| .. | .. |
|---|
| 403 | 403 | ldr r4, [r5, #0x1C] @ restore SCLK_BURST |
|---|
| 404 | 404 | str r4, [r0, #CLK_RESET_SCLK_BURST] |
|---|
| 405 | 405 | |
|---|
| 406 | | - cmp r10, #TEGRA30 |
|---|
| 407 | | - movweq r4, #:lower16:((1 << 28) | (0x8)) @ burst policy is PLLX |
|---|
| 408 | | - movteq r4, #:upper16:((1 << 28) | (0x8)) |
|---|
| 409 | | - movwne r4, #:lower16:((1 << 28) | (0xe)) |
|---|
| 410 | | - movtne r4, #:upper16:((1 << 28) | (0xe)) |
|---|
| 406 | + movw r4, #:lower16:((1 << 28) | (0x4)) @ burst policy is PLLP |
|---|
| 407 | + movt r4, #:upper16:((1 << 28) | (0x4)) |
|---|
| 411 | 408 | str r4, [r0, #CLK_RESET_CCLK_BURST] |
|---|
| 412 | 409 | |
|---|
| 413 | 410 | /* Restore pad power state to normal */ |
|---|
| .. | .. |
|---|
| 467 | 464 | cmp r10, #TEGRA30 |
|---|
| 468 | 465 | streq r1, [r0, #EMC_NOP] |
|---|
| 469 | 466 | streq r1, [r0, #EMC_NOP] |
|---|
| 470 | | - streq r1, [r0, #EMC_REFRESH] |
|---|
| 471 | 467 | |
|---|
| 472 | 468 | emc_device_mask r1, r0 |
|---|
| 473 | 469 | |
|---|
| .. | .. |
|---|
| 528 | 524 | str r1, [r0, #EMC_ZCAL_INTERVAL] |
|---|
| 529 | 525 | ldr r1, [r5, #0x0] @ restore EMC_CFG |
|---|
| 530 | 526 | str r1, [r0, #EMC_CFG] |
|---|
| 527 | + |
|---|
| 528 | + emc_timing_update r1, r0 |
|---|
| 531 | 529 | |
|---|
| 532 | 530 | /* Tegra114 had dual EMC channel, now config the other one */ |
|---|
| 533 | 531 | cmp r10, #TEGRA114 |
|---|
| .. | .. |
|---|
| 655 | 653 | orrne r0, r0, #(1 << 31) @ enable PllP bypass on fast cluster |
|---|
| 656 | 654 | bic r0, r0, #(1 << 30) |
|---|
| 657 | 655 | str r0, [r5, #CLK_RESET_PLLP_BASE] |
|---|
| 656 | + beq 1f |
|---|
| 657 | + mov r0, #CLK_RESET_PLLP_RESHIFT_ENABLE |
|---|
| 658 | + str r0, [r5, #CLK_RESET_PLLP_RESHIFT] |
|---|
| 659 | +1: |
|---|
| 658 | 660 | ldr r0, [r5, #CLK_RESET_PLLA_BASE] |
|---|
| 659 | 661 | bic r0, r0, #(1 << 30) |
|---|
| 660 | 662 | str r0, [r5, #CLK_RESET_PLLA_BASE] |
|---|
| .. | .. |
|---|
| 670 | 672 | pll_iddq_entry r1, r5, CLK_RESET_PLLX_MISC3, CLK_RESET_PLLX_MISC3_IDDQ |
|---|
| 671 | 673 | _no_pll_in_iddq: |
|---|
| 672 | 674 | |
|---|
| 673 | | - /* switch to CLKS */ |
|---|
| 674 | | - mov r0, #0 /* brust policy = 32KHz */ |
|---|
| 675 | + /* |
|---|
| 676 | + * Switch to clk_s (32KHz); bits 28:31=0 |
|---|
| 677 | + * Enable burst on CPU IRQ; bit 24=1 |
|---|
| 678 | + * Set IRQ burst clock source to clk_m; bits 10:8=0 |
|---|
| 679 | + */ |
|---|
| 680 | + mov r0, #(1 << 24) |
|---|
| 675 | 681 | str r0, [r5, #CLK_RESET_SCLK_BURST] |
|---|
| 676 | 682 | |
|---|
| 677 | 683 | ret lr |
|---|
| .. | .. |
|---|
| 704 | 710 | dsb |
|---|
| 705 | 711 | ldr r0, [r6, r2] /* memory barrier */ |
|---|
| 706 | 712 | |
|---|
| 713 | + cmp r10, #TEGRA30 |
|---|
| 707 | 714 | halted: |
|---|
| 708 | 715 | isb |
|---|
| 709 | 716 | dsb |
|---|
| 710 | | - wfi /* CPU should be power gated here */ |
|---|
| 717 | + wfine /* CPU should be power gated here */ |
|---|
| 718 | + wfeeq |
|---|
| 711 | 719 | |
|---|
| 712 | 720 | /* !!!FIXME!!! Implement halt failure handler */ |
|---|
| 713 | 721 | b halted |
|---|