|
| 1 | +/* |
| 2 | + * (C) Copyright 2011 Samsung Electronics Co. Ltd |
| 3 | + * |
| 4 | + * See file CREDITS for list of people who contributed to this |
| 5 | + * project. |
| 6 | + * |
| 7 | + * This program is free software; you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License version 2 as |
| 9 | + * published by the Free Software Foundation. |
| 10 | + * |
| 11 | + */ |
| 12 | + |
| 13 | +#include <config.h> |
| 14 | +#include <asm/arch/cpu.h> |
| 15 | + |
| 16 | +#define ELFIN_CLOCK_BASE 0x10030000 |
| 17 | + |
| 18 | +#define CLK_SRC_LEFTBUS_OFFSET 0x04200 |
| 19 | +#define CLK_DIV_LEFTBUS_OFFSET 0x04500 |
| 20 | + |
| 21 | +#define CLK_SRC_RIGHTBUS_OFFSET 0x08200 |
| 22 | +#define CLK_DIV_RIGHTBUS_OFFSET 0x08500 |
| 23 | + |
| 24 | +#define EPLL_LOCK_OFFSET 0x0C010 |
| 25 | +#define VPLL_LOCK_OFFSET 0x0C020 |
| 26 | +#define EPLL_CON0_OFFSET 0x0C110 |
| 27 | +#define EPLL_CON1_OFFSET 0x0C114 |
| 28 | +#define EPLL_CON2_OFFSET 0x0C118 |
| 29 | +#define VPLL_CON0_OFFSET 0x0C120 |
| 30 | +#define VPLL_CON1_OFFSET 0x0C124 |
| 31 | +#define VPLL_CON2_OFFSET 0x0C128 |
| 32 | + |
| 33 | +#define CLK_SRC_TOP0_OFFSET 0x0C210 |
| 34 | +#define CLK_SRC_TOP1_OFFSET 0x0C214 |
| 35 | +#define CLK_SRC_FSYS_OFFSET 0x0C240 |
| 36 | +#define CLK_SRC_PERIL0_OFFSET 0x0C250 |
| 37 | +#define CLK_DIV_TOP_OFFSET 0x0C510 |
| 38 | +#define CLK_DIV_FSYS1_OFFSET 0x0C544 |
| 39 | +#define CLK_DIV_FSYS2_OFFSET 0x0C548 |
| 40 | +#define CLK_DIV_FSYS3_OFFSET 0x0C54C |
| 41 | +#define CLK_DIV_PERIL0_OFFSET 0x0C550 |
| 42 | + |
| 43 | +#define CLK_SRC_DMC_OFFSET 0x10200 |
| 44 | +#define CLK_DIV_DMC0_OFFSET 0x10500 |
| 45 | +#define CLK_DIV_DMC1_OFFSET 0x10504 |
| 46 | + |
| 47 | +#define APLL_LOCK_OFFSET 0x14000 |
| 48 | +#define MPLL_LOCK_OFFSET 0x14008 |
| 49 | +#define APLL_CON0_OFFSET 0x14100 |
| 50 | +#define APLL_CON1_OFFSET 0x14104 |
| 51 | +#define MPLL_CON0_OFFSET 0x10108 |
| 52 | +#define MPLL_CON1_OFFSET 0x1010C |
| 53 | + |
| 54 | +#define CLK_SRC_CPU_OFFSET 0x14200 |
| 55 | +#define CLK_DIV_CPU0_OFFSET 0x14500 |
| 56 | +#define CLK_DIV_CPU1_OFFSET 0x14504 |
| 57 | + |
| 58 | + |
| 59 | +#define S5PV310_POWER_BASE 0x10020000 |
| 60 | +#define C2C_CTRL_OFFSET 0x24 |
| 61 | +#define APB_DMC_0_BASE 0x10600000 |
| 62 | +#define APB_DMC_1_BASE 0x10610000 |
| 63 | +#define DMC_CONCONTROL 0x00 |
| 64 | +#define DMC_MEMCONTROL 0x04 |
| 65 | +#define DMC_PHYCONTROL0 0x18 |
| 66 | +#define DMC_PHYCONTROL1 0x1C |
| 67 | +#define DMC_PHYCONTROL2 0x20 |
| 68 | + |
| 69 | +#include "i9300_val.h" |
| 70 | + |
| 71 | +/* |
| 72 | + * system_clock_init: Initialize core clock and bus clock. |
| 73 | + * void system_clock_init(void) |
| 74 | + */ |
| 75 | +#define MEM_DLLl_ON |
| 76 | + |
| 77 | + .globl system_clock_init_asm |
| 78 | +system_clock_init_asm: |
| 79 | + push {lr} |
| 80 | + |
| 81 | + ldr r0, =ELFIN_CLOCK_BASE @0x1003_0000 |
| 82 | + |
| 83 | +@ CMU_CPU MUX / DIV |
| 84 | + ldr r1, =0x0 |
| 85 | + ldr r2, =CLK_SRC_CPU_OFFSET |
| 86 | + str r1, [r0, r2] |
| 87 | + |
| 88 | + /* wait ?us */ |
| 89 | + mov r1, #0x10000 |
| 90 | +1: subs r1, r1, #1 |
| 91 | + bne 1b |
| 92 | + |
| 93 | + ldr r1, =CLK_DIV_DMC0_VAL |
| 94 | + ldr r2, =CLK_DIV_DMC0_OFFSET |
| 95 | + str r1, [r0, r2] |
| 96 | + ldr r1, =CLK_DIV_DMC1_VAL |
| 97 | + ldr r2, =CLK_DIV_DMC1_OFFSET |
| 98 | + str r1, [r0, r2] |
| 99 | + |
| 100 | +@ CMU_TOP MUX / DIV |
| 101 | + ldr r1, =CLK_SRC_TOP0_VAL |
| 102 | + ldr r2, =CLK_SRC_TOP0_OFFSET |
| 103 | + str r1, [r0, r2] |
| 104 | + ldr r1, =CLK_SRC_TOP1_VAL |
| 105 | + ldr r2, =CLK_SRC_TOP1_OFFSET |
| 106 | + str r1, [r0, r2] |
| 107 | + |
| 108 | + /* wait ?us */ |
| 109 | + mov r1, #0x10000 |
| 110 | +3: subs r1, r1, #1 |
| 111 | + bne 3b |
| 112 | + |
| 113 | + ldr r1, =CLK_DIV_TOP_VAL |
| 114 | + ldr r2, =CLK_DIV_TOP_OFFSET |
| 115 | + str r1, [r0, r2] |
| 116 | + |
| 117 | +@ CMU_LEFTBUS MUX / DIV |
| 118 | + ldr r1, =CLK_SRC_LEFTBUS_VAL |
| 119 | + ldr r2, =CLK_SRC_LEFTBUS_OFFSET |
| 120 | + str r1, [r0, r2] |
| 121 | + |
| 122 | + /* wait ?us */ |
| 123 | + mov r1, #0x10000 |
| 124 | +4: subs r1, r1, #1 |
| 125 | + bne 4b |
| 126 | + |
| 127 | + ldr r1, =CLK_DIV_LEFRBUS_VAL |
| 128 | + ldr r2, =CLK_DIV_LEFTBUS_OFFSET |
| 129 | + str r1, [r0, r2] |
| 130 | + |
| 131 | +@ CMU_RIGHTBUS MUX / DIV |
| 132 | + ldr r1, =CLK_SRC_RIGHTBUS_VAL |
| 133 | + ldr r2, =CLK_SRC_RIGHTBUS_OFFSET |
| 134 | + str r1, [r0, r2] |
| 135 | + |
| 136 | + /* wait ?us */ |
| 137 | + mov r1, #0x10000 |
| 138 | +5: subs r1, r1, #1 |
| 139 | + bne 5b |
| 140 | + |
| 141 | + ldr r1, =CLK_DIV_RIGHTBUS_VAL |
| 142 | + ldr r2, =CLK_DIV_RIGHTBUS_OFFSET |
| 143 | + str r1, [r0, r2] |
| 144 | + |
| 145 | +@ Set PLL locktime |
| 146 | + ldr r1, =APLL_LOCK_VAL |
| 147 | + ldr r2, =APLL_LOCK_OFFSET |
| 148 | + str r1, [r0, r2] |
| 149 | + |
| 150 | + ldr r1, =MPLL_LOCK_VAL |
| 151 | + ldr r2, =MPLL_LOCK_OFFSET |
| 152 | + str r1, [r0, r2] |
| 153 | + |
| 154 | + ldr r1, =EPLL_LOCK_VAL |
| 155 | + ldr r2, =EPLL_LOCK_OFFSET |
| 156 | + str r1, [r0, r2] |
| 157 | + |
| 158 | + ldr r1, =VPLL_LOCK_VAL |
| 159 | + ldr r2, =VPLL_LOCK_OFFSET |
| 160 | + str r1, [r0, r2] |
| 161 | + |
| 162 | + ldr r1, =CLK_DIV_CPU0_VAL |
| 163 | + ldr r2, =CLK_DIV_CPU0_OFFSET |
| 164 | + str r1, [r0, r2] |
| 165 | + ldr r1, =CLK_DIV_CPU1_VAL |
| 166 | + ldr r2, =CLK_DIV_CPU1_OFFSET |
| 167 | + str r1, [r0, r2] |
| 168 | + |
| 169 | +@ Set APLL |
| 170 | + ldr r1, =APLL_CON1_VAL |
| 171 | + ldr r2, =APLL_CON1_OFFSET |
| 172 | + str r1, [r0, r2] |
| 173 | + ldr r1, =APLL_CON0_VAL |
| 174 | + ldr r2, =APLL_CON0_OFFSET |
| 175 | + str r1, [r0, r2] |
| 176 | + |
| 177 | + /* check MPLL and if MPLL is not 400 Mhz skip MPLL resetting for C2C operation */ |
| 178 | + ldr r2, =MPLL_CON0_OFFSET |
| 179 | + ldr r1, [r0, r2] |
| 180 | + ldr r3, =0xA0640301 |
| 181 | + cmp r1, r3 |
| 182 | + bne skip_mpll |
| 183 | + |
| 184 | +@ Set MPLL |
| 185 | + ldr r1, =MPLL_CON1_VAL |
| 186 | + ldr r2, =MPLL_CON1_OFFSET |
| 187 | + str r1, [r0, r2] |
| 188 | + ldr r1, =MPLL_CON0_VAL |
| 189 | + ldr r2, =MPLL_CON0_OFFSET |
| 190 | + str r1, [r0, r2] |
| 191 | +skip_mpll: |
| 192 | + |
| 193 | +@ Set EPLL |
| 194 | + ldr r1, =EPLL_CON2_VAL |
| 195 | + ldr r2, =EPLL_CON2_OFFSET |
| 196 | + str r1, [r0, r2] |
| 197 | + ldr r1, =EPLL_CON1_VAL |
| 198 | + ldr r2, =EPLL_CON1_OFFSET |
| 199 | + str r1, [r0, r2] |
| 200 | + ldr r1, =EPLL_CON0_VAL |
| 201 | + ldr r2, =EPLL_CON0_OFFSET |
| 202 | + str r1, [r0, r2] |
| 203 | + |
| 204 | +@ Set VPLL |
| 205 | + ldr r1, =VPLL_CON2_VAL |
| 206 | + ldr r2, =VPLL_CON2_OFFSET |
| 207 | + str r1, [r0, r2] |
| 208 | + ldr r1, =VPLL_CON1_VAL |
| 209 | + ldr r2, =VPLL_CON1_OFFSET |
| 210 | + str r1, [r0, r2] |
| 211 | + ldr r1, =VPLL_CON0_VAL |
| 212 | + ldr r2, =VPLL_CON0_OFFSET |
| 213 | + str r1, [r0, r2] |
| 214 | + |
| 215 | + /* wait ?us */ |
| 216 | + mov r1, #0x40000 |
| 217 | +6: subs r1, r1, #1 |
| 218 | + bne 6b |
| 219 | + |
| 220 | + ldr r1, =0x01000001 |
| 221 | + ldr r2, =CLK_SRC_CPU_OFFSET |
| 222 | + str r1, [r0, r2] |
| 223 | + ldr r1, =0x00011000 |
| 224 | + ldr r2, =CLK_SRC_DMC_OFFSET |
| 225 | + str r1, [r0, r2] |
| 226 | + ldr r1, =0x00000110 |
| 227 | + ldr r2, =CLK_SRC_TOP0_OFFSET |
| 228 | + str r1, [r0, r2] |
| 229 | + ldr r1, =0x01111000 |
| 230 | + ldr r2, =CLK_SRC_TOP1_OFFSET |
| 231 | + str r1, [r0, r2] |
| 232 | + |
| 233 | + /* wait ?us */ |
| 234 | + mov r1, #0x10000 |
| 235 | +7: subs r1, r1, #1 |
| 236 | + bne 7b |
| 237 | + |
| 238 | + /* check C2C_CTRL enable bit */ |
| 239 | + ldr r3, =S5PV310_POWER_BASE |
| 240 | + ldr r4, =C2C_CTRL_OFFSET |
| 241 | + ldr r1, [r3, r4] |
| 242 | + and r1, r1, #1 |
| 243 | + cmp r1, #0 |
| 244 | + bne v310_2 |
| 245 | + |
| 246 | +@ ConControl |
| 247 | +#ifdef MEM_DLLl_ON |
| 248 | + ldr r0, =APB_DMC_0_BASE |
| 249 | + |
| 250 | + ldr r1, =0x7F10100A |
| 251 | + ldr r2, =DMC_PHYCONTROL0 |
| 252 | + str r1, [r0, r2] |
| 253 | + |
| 254 | + ldr r1, =0xE0000084 |
| 255 | + ldr r2, =DMC_PHYCONTROL1 |
| 256 | + str r1, [r0, r2] |
| 257 | + |
| 258 | + ldr r1, =0x7F10100B |
| 259 | + ldr r2, =DMC_PHYCONTROL0 |
| 260 | + str r1, [r0, r2] |
| 261 | + |
| 262 | + /* wait ?us */ |
| 263 | + mov r1, #0x20000 |
| 264 | +8: subs r1, r1, #1 |
| 265 | + bne 8b |
| 266 | + |
| 267 | + ldr r1, =0x0000008C |
| 268 | + ldr r2, =DMC_PHYCONTROL1 |
| 269 | + str r1, [r0, r2] |
| 270 | + ldr r1, =0x00000084 |
| 271 | + ldr r2, =DMC_PHYCONTROL1 |
| 272 | + str r1, [r0, r2] |
| 273 | + |
| 274 | + /* wait ?us */ |
| 275 | + mov r1, #0x20000 |
| 276 | +9: subs r1, r1, #1 |
| 277 | + bne 9b |
| 278 | + |
| 279 | + ldr r0, =APB_DMC_1_BASE |
| 280 | + |
| 281 | + ldr r1, =0x7F10100A |
| 282 | + ldr r2, =DMC_PHYCONTROL0 |
| 283 | + str r1, [r0, r2] |
| 284 | + |
| 285 | + ldr r1, =0xE0000084 |
| 286 | + ldr r2, =DMC_PHYCONTROL1 |
| 287 | + str r1, [r0, r2] |
| 288 | + |
| 289 | + ldr r1, =0x7F10100B |
| 290 | + ldr r2, =DMC_PHYCONTROL0 |
| 291 | + str r1, [r0, r2] |
| 292 | + |
| 293 | + /* wait ?us */ |
| 294 | + mov r1, #0x20000 |
| 295 | +10: subs r1, r1, #1 |
| 296 | + bne 10b |
| 297 | + |
| 298 | + ldr r1, =0x0000008C |
| 299 | + ldr r2, =DMC_PHYCONTROL1 |
| 300 | + str r1, [r0, r2] |
| 301 | + ldr r1, =0x00000084 |
| 302 | + ldr r2, =DMC_PHYCONTROL1 |
| 303 | + str r1, [r0, r2] |
| 304 | + |
| 305 | + /* wait ?us */ |
| 306 | + mov r1, #0x20000 |
| 307 | +11: subs r1, r1, #1 |
| 308 | + bne 11b |
| 309 | +#endif |
| 310 | + |
| 311 | + ldr r0, =APB_DMC_0_BASE |
| 312 | + ldr r1, =0x0FFF30FA |
| 313 | + ldr r2, =DMC_CONCONTROL |
| 314 | + str r1, [r0, r2] |
| 315 | + |
| 316 | + ldr r0, =APB_DMC_1_BASE |
| 317 | + ldr r1, =0x0FFF30FA |
| 318 | + ldr r2, =DMC_CONCONTROL |
| 319 | + str r1, [r0, r2] |
| 320 | + |
| 321 | + ldr r0, =APB_DMC_0_BASE |
| 322 | + ldr r1, =0x00202533 |
| 323 | + ldr r2, =DMC_MEMCONTROL |
| 324 | + str r1, [r0, r2] |
| 325 | + |
| 326 | + ldr r0, =APB_DMC_1_BASE |
| 327 | + ldr r1, =0x00202533 |
| 328 | + ldr r2, =DMC_MEMCONTROL |
| 329 | + str r1, [r0, r2] |
| 330 | + |
| 331 | +v310_2: |
| 332 | + pop {pc} |
| 333 | + |
0 commit comments