2 * linux/arch/arm/mach-omap3/sram.S
4 * Omap3 specific functions that need to be run in internal SRAM
6 * Copyright (C) 2004, 2007, 2008 Texas Instruments, Inc.
7 * Copyright (C) 2008 Nokia Corporation
9 * Rajendra Nayak <rnayak@ti.com>
10 * Richard Woodruff <r-woodruff2@ti.com>
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <linux/linkage.h>
29 #include <asm/assembler.h>
30 #include <mach/hardware.h>
40 #define SDRC_NO_UNLOCK_DLL 0x0
41 #define SDRC_UNLOCK_DLL 0x1
43 /* SDRC_DLLA_CTRL bit settings */
44 #define FIXEDDELAY_SHIFT 24
45 #define FIXEDDELAY_MASK (0xff << FIXEDDELAY_SHIFT)
46 #define DLLIDLE_MASK 0x4
49 * SDRC_DLLA_CTRL default values: TI hardware team indicates that
50 * FIXEDDELAY should be initialized to 0xf. This apparently was
51 * empirically determined during process testing, so no derivation
54 #define FIXEDDELAY_DEFAULT (0x0f << FIXEDDELAY_SHIFT)
56 /* SDRC_DLLA_STATUS bit settings */
57 #define LOCKSTATUS_MASK 0x4
59 /* SDRC_POWER bit settings */
60 #define SRFRONIDLEREQ_MASK 0x40
61 #define PWDENA_MASK 0x4
63 /* CM_IDLEST1_CORE bit settings */
64 #define ST_SDRC_MASK 0x2
66 /* CM_ICLKEN1_CORE bit settings */
67 #define EN_SDRC_MASK 0x2
69 /* CM_CLKSEL1_PLL bit settings */
70 #define CORE_DPLL_CLKOUT_DIV_SHIFT 0x1b
73 * omap3_sram_configure_core_dpll - change DPLL3 M2 divider
74 * r0 = new SDRC_RFR_CTRL register contents
75 * r1 = new SDRC_ACTIM_CTRLA register contents
76 * r2 = new SDRC_ACTIM_CTRLB register contents
77 * r3 = new M2 divider setting (only 1 and 2 supported right now)
78 * r4 = unlock SDRC DLL? (1 = yes, 0 = no). Only unlock DLL for
80 * r5 = number of MPU cycles to wait for SDRC to stabilize after
81 * reprogramming the SDRC when switching to a slower MPU speed
82 * r6 = new SDRC_MR_0 register value
83 * r7 = increasing SDRC rate? (1 = yes, 0 = no)
86 ENTRY(omap3_sram_configure_core_dpll)
87 stmfd sp!, {r1-r12, lr} @ store regs to stack
88 ldr r4, [sp, #52] @ pull extra args off the stack
89 ldr r5, [sp, #56] @ load extra args from the stack
90 ldr r6, [sp, #60] @ load extra args from the stack
91 ldr r7, [sp, #64] @ load extra args from the stack
92 dsb @ flush buffered writes to interconnect
93 cmp r7, #1 @ if increasing SDRC clk rate,
94 bleq configure_sdrc @ program the SDRC regs early (for RFR)
95 cmp r4, #SDRC_UNLOCK_DLL @ set the intended DLL state
98 bl sdram_in_selfrefresh @ put SDRAM in self refresh, idle SDRC
99 bl configure_core_dpll @ change the DPLL3 M2 divider
100 bl enable_sdrc @ take SDRC out of idle
101 cmp r4, #SDRC_UNLOCK_DLL @ wait for DLL status to change
104 cmp r7, #1 @ if increasing SDRC clk rate,
105 beq return_to_sdram @ return to SDRAM code, otherwise,
106 bl configure_sdrc @ reprogram SDRC regs now
108 bl wait_clk_stable @ wait for SDRC to stabilize
110 isb @ prevent speculative exec past here
111 mov r0, #0 @ return value
112 ldmfd sp!, {r1-r12, pc} @ restore regs and return
114 ldr r11, omap3_sdrc_dlla_ctrl
116 and r12, r12, #FIXEDDELAY_MASK
117 orr r12, r12, #FIXEDDELAY_DEFAULT
118 orr r12, r12, #DLLIDLE_MASK
119 str r12, [r11] @ (no OCP barrier needed)
122 ldr r11, omap3_sdrc_dlla_ctrl
124 bic r12, r12, #DLLIDLE_MASK
125 str r12, [r11] @ (no OCP barrier needed)
127 sdram_in_selfrefresh:
128 ldr r11, omap3_sdrc_power @ read the SDRC_POWER register
129 ldr r12, [r11] @ read the contents of SDRC_POWER
130 mov r9, r12 @ keep a copy of SDRC_POWER bits
131 orr r12, r12, #SRFRONIDLEREQ_MASK @ enable self refresh on idle
132 bic r12, r12, #PWDENA_MASK @ clear PWDENA
133 str r12, [r11] @ write back to SDRC_POWER register
134 ldr r12, [r11] @ posted-write barrier for SDRC
136 ldr r11, omap3_cm_iclken1_core @ read the CM_ICLKEN1_CORE reg
138 bic r12, r12, #EN_SDRC_MASK @ disable iclk bit for SDRC
141 ldr r11, omap3_cm_idlest1_core
143 and r12, r12, #ST_SDRC_MASK @ check for SDRC idle
144 cmp r12, #ST_SDRC_MASK
148 ldr r11, omap3_cm_clksel1_pll
150 ldr r10, core_m2_mask_val @ modify m2 for core dpll
152 orr r12, r12, r3, lsl #CORE_DPLL_CLKOUT_DIV_SHIFT
154 ldr r12, [r11] @ posted-write barrier for CM
161 ldr r11, omap3_cm_iclken1_core
163 orr r12, r12, #EN_SDRC_MASK @ enable iclk bit for SDRC
166 ldr r11, omap3_cm_idlest1_core
168 and r12, r12, #ST_SDRC_MASK
171 restore_sdrc_power_val:
172 ldr r11, omap3_sdrc_power
173 str r9, [r11] @ restore SDRC_POWER, no barrier needed
176 ldr r11, omap3_sdrc_dlla_status
178 and r12, r12, #LOCKSTATUS_MASK
179 cmp r12, #LOCKSTATUS_MASK
183 ldr r11, omap3_sdrc_dlla_status
185 and r12, r12, #LOCKSTATUS_MASK
190 ldr r11, omap3_sdrc_rfr_ctrl
192 ldr r11, omap3_sdrc_actim_ctrla
194 ldr r11, omap3_sdrc_actim_ctrlb
196 ldr r11, omap3_sdrc_mr_0
198 ldr r6, [r11] @ posted-write barrier for SDRC
202 .word OMAP34XX_SDRC_REGADDR(SDRC_POWER)
203 omap3_cm_clksel1_pll:
204 .word OMAP34XX_CM_REGADDR(PLL_MOD, CM_CLKSEL1)
205 omap3_cm_idlest1_core:
206 .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST)
207 omap3_cm_iclken1_core:
208 .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_ICLKEN1)
210 .word OMAP34XX_SDRC_REGADDR(SDRC_RFR_CTRL_0)
211 omap3_sdrc_actim_ctrla:
212 .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_A_0)
213 omap3_sdrc_actim_ctrlb:
214 .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_B_0)
216 .word OMAP34XX_SDRC_REGADDR(SDRC_MR_0)
217 omap3_sdrc_dlla_status:
218 .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS)
219 omap3_sdrc_dlla_ctrl:
220 .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_CTRL)
224 ENTRY(omap3_sram_configure_core_dpll_sz)
225 .word . - omap3_sram_configure_core_dpll