wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Board specific setup info |
| 3 | * |
| 4 | * (C) Copyright 2004 |
| 5 | * Texas Instruments, <www.ti.com> |
| 6 | * Richard Woodruff <r-woodruff2@ti.com> |
| 7 | * |
| 8 | * See file CREDITS for list of people who contributed to this |
| 9 | * project. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <config.h> |
| 28 | #include <version.h> |
| 29 | #include <asm/arch/omap2420.h> |
| 30 | #include <asm/arch/mem.h> |
| 31 | #include <asm/arch/clocks.h> |
| 32 | |
| 33 | _TEXT_BASE: |
| 34 | .word TEXT_BASE /* sdram load addr from config.mk */ |
| 35 | |
| 36 | #ifdef CONFIG_PARTIAL_SRAM |
| 37 | |
| 38 | /************************************************************************** |
| 39 | * cpy_clk_code: relocates clock code into SRAM where its safer to execute |
| 40 | * R1 = SRAM destination address. |
| 41 | *************************************************************************/ |
| 42 | .global cpy_clk_code |
| 43 | cpy_clk_code: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 44 | /* Copy DPLL code into SRAM */ |
| 45 | adr r0, go_to_speed /* get addr of clock setting code */ |
| 46 | mov r2, #384 /* r2 size to copy (div by 32 bytes) */ |
| 47 | mov r1, r1 /* r1 <- dest address (passed in) */ |
| 48 | add r2, r2, r0 /* r2 <- source end address */ |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 49 | next2: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 50 | ldmia r0!, {r3-r10} /* copy from source address [r0] */ |
| 51 | stmia r1!, {r3-r10} /* copy to target address [r1] */ |
| 52 | cmp r0, r2 /* until source end address [r2] */ |
| 53 | bne next2 |
| 54 | mov pc, lr /* back to caller */ |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 55 | |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 56 | /* **************************************************************************** |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 57 | * go_to_speed: -Moves to bypass, -Commits clock dividers, -puts dpll at speed |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 58 | * -executed from SRAM. |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 59 | * R0 = PRCM_CLKCFG_CTRL - addr of valid reg |
| 60 | * R1 = CM_CLKEN_PLL - addr dpll ctlr reg |
| 61 | * R2 = dpll value |
| 62 | * R3 = CM_IDLEST_CKGEN - addr dpll lock wait |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 63 | ******************************************************************************/ |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 64 | .global go_to_speed |
| 65 | go_to_speed: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 66 | sub sp, sp, #0x4 /* get some stack space */ |
| 67 | str r4, [sp] /* save r4's value */ |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 68 | |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 69 | /* move into fast relock bypass */ |
| 70 | ldr r8, pll_ctl_add |
| 71 | mov r4, #0x2 |
| 72 | str r4, [r8] |
| 73 | ldr r4, pll_stat |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 74 | block: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 75 | ldr r8, [r4] /* wait for bypass to take effect */ |
| 76 | and r8, r8, #0x3 |
| 77 | cmp r8, #0x1 |
| 78 | bne block |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 79 | |
| 80 | /* set new dpll dividers _after_ in bypass */ |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 81 | ldr r4, pll_div_add |
| 82 | ldr r8, pll_div_val |
| 83 | str r8, [r4] |
| 84 | |
| 85 | /* now prepare GPMC (flash) for new dpll speed */ |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 86 | /* flash needs to be stable when we jump back to it */ |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 87 | ldr r4, cfg3_0_addr |
| 88 | ldr r8, cfg3_0_val |
| 89 | str r8, [r4] |
| 90 | ldr r4, cfg4_0_addr |
| 91 | ldr r8, cfg4_0_val |
| 92 | str r8, [r4] |
| 93 | ldr r4, cfg1_0_addr |
| 94 | ldr r8, [r4] |
| 95 | orr r8, r8, #0x3 /* up gpmc divider */ |
| 96 | str r8, [r4] |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 97 | |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 98 | /* setup to 2x loop though code. The first loop pre-loads the |
| 99 | * icache, the 2nd commits the prcm config, and locks the dpll |
| 100 | */ |
| 101 | mov r4, #0x1000 /* spin spin spin */ |
| 102 | mov r8, #0x4 /* first pass condition & set registers */ |
| 103 | cmp r8, #0x4 |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 104 | 2: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 105 | ldrne r8, [r3] /* DPLL lock check */ |
| 106 | and r8, r8, #0x7 |
| 107 | cmp r8, #0x2 |
| 108 | beq 4f |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 109 | 3: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 110 | subeq r8, r8, #0x1 |
| 111 | streq r8, [r0] /* commit dividers (2nd time) */ |
| 112 | nop |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 113 | lloop1: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 114 | sub r4, r4, #0x1 /* Loop currently necessary else bad jumps */ |
| 115 | nop |
| 116 | cmp r4, #0x0 |
| 117 | bne lloop1 |
| 118 | mov r4, #0x40000 |
| 119 | cmp r8, #0x1 |
| 120 | nop |
| 121 | streq r2, [r1] /* lock dpll (2nd time) */ |
| 122 | nop |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 123 | lloop2: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 124 | sub r4, r4, #0x1 /* loop currently necessary else bad jumps */ |
| 125 | nop |
| 126 | cmp r4, #0x0 |
| 127 | bne lloop2 |
| 128 | mov r4, #0x40000 |
| 129 | cmp r8, #0x1 |
| 130 | nop |
| 131 | ldreq r8, [r3] /* get lock condition for dpll */ |
| 132 | cmp r8, #0x4 /* first time though? */ |
| 133 | bne 2b |
| 134 | moveq r8, #0x2 /* set to dpll check condition. */ |
| 135 | beq 3b /* if condition not true branch */ |
| 136 | 4: |
| 137 | ldr r4, [sp] |
| 138 | add sp, sp, #0x4 /* return stack space */ |
| 139 | mov pc, lr /* back to caller, locked */ |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 140 | |
| 141 | _go_to_speed: .word go_to_speed |
| 142 | |
| 143 | /* these constants need to be close for PIC code */ |
| 144 | cfg3_0_addr: |
| 145 | .word GPMC_CONFIG3_0 |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 146 | cfg3_0_val: |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 147 | .word H4_24XX_GPMC_CONFIG3_0 |
| 148 | cfg4_0_addr: |
| 149 | .word GPMC_CONFIG4_0 |
| 150 | cfg4_0_val: |
| 151 | .word H4_24XX_GPMC_CONFIG4_0 |
| 152 | cfg1_0_addr: |
| 153 | .word GPMC_CONFIG1_0 |
| 154 | pll_ctl_add: |
| 155 | .word CM_CLKEN_PLL |
| 156 | pll_stat: |
| 157 | .word CM_IDLEST_CKGEN |
| 158 | pll_div_add: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 159 | .word CM_CLKSEL1_PLL |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 160 | pll_div_val: |
| 161 | .word DPLL_VAL /* DPLL setting (300MHz default) */ |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 162 | #endif |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 163 | |
| 164 | .globl platformsetup |
| 165 | platformsetup: |
| 166 | mov r3, r0 /* save skip information */ |
| 167 | #ifdef CONFIG_APTIX |
| 168 | ldr r0, REG_SDRC_MCFG_0 |
| 169 | ldr r1, VAL_SDRC_MCFG_0 |
| 170 | str r1, [r0] |
| 171 | ldr r0, REG_SDRC_MR_0 |
| 172 | ldr r1, VAL_SDRC_MR_0 |
| 173 | str r1, [r0] |
| 174 | /* a ddr needs emr1 set here */ |
| 175 | ldr r0, REG_SDRC_SHARING |
| 176 | ldr r1, VAL_SDRC_SHARING |
| 177 | str r1, [r0] |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 178 | ldr r0, REG_SDRC_RFR_CTRL_0 |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 179 | ldr r1, VAL_SDRC_RFR_CTRL_0 |
| 180 | str r1, [r0] |
| 181 | |
| 182 | /* little delay after init */ |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 183 | mov r2, #0x1800 |
| 184 | 1: |
| 185 | subs r2, r2, #0x1 |
| 186 | bne 1b |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 187 | #endif |
| 188 | #ifdef CONFIG_PARTIAL_SRAM |
| 189 | ldr sp, SRAM_STACK |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 190 | str ip, [sp] /* stash old link register */ |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 191 | mov ip, lr /* save link reg across call */ |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 192 | mov r0, r3 /* pass skip info to s_init */ |
| 193 | bl s_init /* go setup pll,mux,memory */ |
| 194 | ldr ip, [sp] /* restore save ip */ |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 195 | mov lr, ip /* restore link reg */ |
| 196 | #endif |
| 197 | /* map interrupt controller */ |
| 198 | ldr r0, VAL_INTH_SETUP |
| 199 | mcr p15, 0, r0, c15, c2, 4 |
| 200 | |
| 201 | /* back to arch calling code */ |
| 202 | mov pc, lr |
| 203 | |
| 204 | /* the literal pools origin */ |
| 205 | .ltorg |
| 206 | |
| 207 | REG_CONTROL_STATUS: |
| 208 | .word CONTROL_STATUS |
| 209 | VAL_INTH_SETUP: |
| 210 | .word PERIFERAL_PORT_BASE |
| 211 | SRAM_STACK: |
| 212 | .word LOW_LEVEL_SRAM_STACK |
| 213 | |
| 214 | #ifdef CONFIG_APTIX |
| 215 | REG_SDRC_SHARING: |
| 216 | .word SDRC_SHARING |
| 217 | REG_SDRC_MCFG_0: |
| 218 | .word SDRC_MCFG_0 |
| 219 | REG_SDRC_MR_0: |
| 220 | .word SDRC_MR_0 |
| 221 | REG_SDRC_RFR_CTRL_0: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 222 | .word SDRC_RFR_CTRL |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 223 | VAL_SDRC_SHARING: |
| 224 | .word VAL_H4_SDRC_SHARING |
| 225 | VAL_SDRC_MCFG_0: |
| 226 | .word VAL_H4_SDRC_MCFG_0 |
| 227 | VAL_SDRC_MR_0: |
| 228 | .word VAL_H4_SDRC_MR_0 |
| 229 | VAL_SDRC_RFR_CTRL_0: |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame^] | 230 | .word VAL_H4_SDRC_RFR_CTRL_0 |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 231 | #endif |