Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap3/sram.S |
| 3 | * |
| 4 | * Omap3 specific functions that need to be run in internal SRAM |
| 5 | * |
| 6 | * (C) Copyright 2007 |
| 7 | * Texas Instruments Inc. |
| 8 | * Rajendra Nayak <rnayak@ti.com> |
| 9 | * |
| 10 | * (C) Copyright 2004 |
| 11 | * Texas Instruments, <www.ti.com> |
| 12 | * Richard Woodruff <r-woodruff2@ti.com> |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License as |
| 16 | * published by the Free Software Foundation; either version 2 of |
| 17 | * the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, write to the Free Software |
| 26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 27 | * MA 02111-1307 USA |
| 28 | */ |
| 29 | #include <linux/linkage.h> |
| 30 | #include <asm/assembler.h> |
| 31 | #include <mach/hardware.h> |
| 32 | |
| 33 | #include <mach/io.h> |
| 34 | |
| 35 | #include "sdrc.h" |
| 36 | #include "cm.h" |
| 37 | |
| 38 | .text |
| 39 | |
| 40 | /* |
| 41 | * Change frequency of core dpll |
| 42 | * r0 = sdrc_rfr_ctrl r1 = sdrc_actim_ctrla r2 = sdrc_actim_ctrlb r3 = M2 |
| 43 | */ |
| 44 | ENTRY(omap3_sram_configure_core_dpll) |
| 45 | stmfd sp!, {r1-r12, lr} @ store regs to stack |
Paul Walmsley | 69d4255 | 2009-05-12 17:27:09 -0600 | [diff] [blame] | 46 | dsb @ flush buffered writes to interconnect |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 47 | cmp r3, #0x2 |
| 48 | blne configure_sdrc |
| 49 | cmp r3, #0x2 |
| 50 | blne lock_dll |
| 51 | cmp r3, #0x1 |
| 52 | blne unlock_dll |
| 53 | bl sdram_in_selfrefresh @ put the SDRAM in self refresh |
| 54 | bl configure_core_dpll |
| 55 | bl enable_sdrc |
| 56 | cmp r3, #0x1 |
| 57 | blne wait_dll_unlock |
| 58 | cmp r3, #0x2 |
| 59 | blne wait_dll_lock |
| 60 | cmp r3, #0x1 |
| 61 | blne configure_sdrc |
Paul Walmsley | 69d4255 | 2009-05-12 17:27:09 -0600 | [diff] [blame] | 62 | isb @ prevent speculative exec past here |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 63 | mov r0, #0 @ return value |
| 64 | ldmfd sp!, {r1-r12, pc} @ restore regs and return |
| 65 | unlock_dll: |
| 66 | ldr r4, omap3_sdrc_dlla_ctrl |
| 67 | ldr r5, [r4] |
| 68 | orr r5, r5, #0x4 |
Paul Walmsley | d75d9e7 | 2009-05-12 17:27:09 -0600 | [diff] [blame] | 69 | str r5, [r4] @ (no OCP barrier needed) |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 70 | bx lr |
| 71 | lock_dll: |
| 72 | ldr r4, omap3_sdrc_dlla_ctrl |
| 73 | ldr r5, [r4] |
| 74 | bic r5, r5, #0x4 |
Paul Walmsley | d75d9e7 | 2009-05-12 17:27:09 -0600 | [diff] [blame] | 75 | str r5, [r4] @ (no OCP barrier needed) |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 76 | bx lr |
| 77 | sdram_in_selfrefresh: |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 78 | ldr r4, omap3_sdrc_power @ read the SDRC_POWER register |
| 79 | ldr r5, [r4] @ read the contents of SDRC_POWER |
Paul Walmsley | fa0406a | 2009-05-12 17:27:09 -0600 | [diff] [blame^] | 80 | mov r9, r5 @ keep a copy of SDRC_POWER bits |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 81 | orr r5, r5, #0x40 @ enable self refresh on idle req |
Paul Walmsley | fa0406a | 2009-05-12 17:27:09 -0600 | [diff] [blame^] | 82 | bic r5, r5, #0x4 @ clear PWDENA |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 83 | str r5, [r4] @ write back to SDRC_POWER register |
Paul Walmsley | d75d9e7 | 2009-05-12 17:27:09 -0600 | [diff] [blame] | 84 | ldr r5, [r4] @ posted-write barrier for SDRC |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 85 | ldr r4, omap3_cm_iclken1_core @ read the CM_ICLKEN1_CORE reg |
| 86 | ldr r5, [r4] |
Paul Walmsley | d75d9e7 | 2009-05-12 17:27:09 -0600 | [diff] [blame] | 87 | bic r5, r5, #0x2 @ disable iclk bit for SDRC |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 88 | str r5, [r4] |
| 89 | wait_sdrc_idle: |
| 90 | ldr r4, omap3_cm_idlest1_core |
| 91 | ldr r5, [r4] |
| 92 | and r5, r5, #0x2 @ check for SDRC idle |
| 93 | cmp r5, #2 |
| 94 | bne wait_sdrc_idle |
| 95 | bx lr |
| 96 | configure_core_dpll: |
| 97 | ldr r4, omap3_cm_clksel1_pll |
| 98 | ldr r5, [r4] |
| 99 | ldr r6, core_m2_mask_val @ modify m2 for core dpll |
| 100 | and r5, r5, r6 |
| 101 | orr r5, r5, r3, lsl #0x1B @ r3 contains the M2 val |
| 102 | str r5, [r4] |
Paul Walmsley | d75d9e7 | 2009-05-12 17:27:09 -0600 | [diff] [blame] | 103 | ldr r5, [r4] @ posted-write barrier for CM |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 104 | mov r5, #0x800 @ wait for the clock to stabilise |
| 105 | cmp r3, #2 |
| 106 | bne wait_clk_stable |
| 107 | bx lr |
| 108 | wait_clk_stable: |
| 109 | subs r5, r5, #1 |
| 110 | bne wait_clk_stable |
| 111 | nop |
| 112 | nop |
| 113 | nop |
| 114 | nop |
| 115 | nop |
| 116 | nop |
| 117 | nop |
| 118 | nop |
| 119 | nop |
| 120 | nop |
| 121 | bx lr |
| 122 | enable_sdrc: |
| 123 | ldr r4, omap3_cm_iclken1_core |
| 124 | ldr r5, [r4] |
| 125 | orr r5, r5, #0x2 @ enable iclk bit for SDRC |
| 126 | str r5, [r4] |
| 127 | wait_sdrc_idle1: |
| 128 | ldr r4, omap3_cm_idlest1_core |
| 129 | ldr r5, [r4] |
| 130 | and r5, r5, #0x2 |
| 131 | cmp r5, #0 |
| 132 | bne wait_sdrc_idle1 |
Paul Walmsley | fa0406a | 2009-05-12 17:27:09 -0600 | [diff] [blame^] | 133 | restore_sdrc_power_val: |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 134 | ldr r4, omap3_sdrc_power |
Paul Walmsley | fa0406a | 2009-05-12 17:27:09 -0600 | [diff] [blame^] | 135 | str r9, [r4] @ restore SDRC_POWER, no barrier needed |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 136 | bx lr |
| 137 | wait_dll_lock: |
| 138 | ldr r4, omap3_sdrc_dlla_status |
| 139 | ldr r5, [r4] |
| 140 | and r5, r5, #0x4 |
| 141 | cmp r5, #0x4 |
| 142 | bne wait_dll_lock |
| 143 | bx lr |
| 144 | wait_dll_unlock: |
| 145 | ldr r4, omap3_sdrc_dlla_status |
| 146 | ldr r5, [r4] |
| 147 | and r5, r5, #0x4 |
| 148 | cmp r5, #0x0 |
| 149 | bne wait_dll_unlock |
| 150 | bx lr |
| 151 | configure_sdrc: |
| 152 | ldr r4, omap3_sdrc_rfr_ctrl |
| 153 | str r0, [r4] |
| 154 | ldr r4, omap3_sdrc_actim_ctrla |
| 155 | str r1, [r4] |
| 156 | ldr r4, omap3_sdrc_actim_ctrlb |
| 157 | str r2, [r4] |
Paul Walmsley | d75d9e7 | 2009-05-12 17:27:09 -0600 | [diff] [blame] | 158 | ldr r2, [r4] @ posted-write barrier for SDRC |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 159 | bx lr |
| 160 | |
| 161 | omap3_sdrc_power: |
| 162 | .word OMAP34XX_SDRC_REGADDR(SDRC_POWER) |
| 163 | omap3_cm_clksel1_pll: |
| 164 | .word OMAP34XX_CM_REGADDR(PLL_MOD, CM_CLKSEL1) |
| 165 | omap3_cm_idlest1_core: |
| 166 | .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST) |
| 167 | omap3_cm_iclken1_core: |
| 168 | .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_ICLKEN1) |
| 169 | omap3_sdrc_rfr_ctrl: |
| 170 | .word OMAP34XX_SDRC_REGADDR(SDRC_RFR_CTRL_0) |
| 171 | omap3_sdrc_actim_ctrla: |
| 172 | .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_A_0) |
| 173 | omap3_sdrc_actim_ctrlb: |
| 174 | .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_B_0) |
| 175 | omap3_sdrc_dlla_status: |
| 176 | .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS) |
| 177 | omap3_sdrc_dlla_ctrl: |
| 178 | .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_CTRL) |
| 179 | core_m2_mask_val: |
| 180 | .word 0x07FFFFFF |
| 181 | |
| 182 | ENTRY(omap3_sram_configure_core_dpll_sz) |
| 183 | .word . - omap3_sram_configure_core_dpll |