driver: add dev_name inline
[barebox-mini2440.git] / board / scb9328 / lowlevel_init.S
blob5b024286bbcd8b12bfbfd6000b46f7d31106dfb6
1 /*
2  * Copyright (C) 2004 Sascha Hauer, Synertronixx GmbH
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17  * 02111-1307, USA.
18  *
19  */
21 #include <mach/imx-regs.h>
23 #define CPU200
25 #ifdef CPU200
26 #define CFG_MPCTL0_VAL 0x00321431
27 #else
28 #define CFG_MPCTL0_VAL 0x040e200e
29 #endif
31 #define BUS72
33 #ifdef BUS72
34 #define CFG_SPCTL0_VAL 0x04002400
35 #endif
37 #ifdef BUS96
38 #define CFG_SPCTL0_VAL 0x04001800
39 #endif
41 #ifdef BUS64
42 #define CFG_SPCTL0_VAL 0x08001800
43 #endif
45 /* Das ist der BCLK Divider, der aus der System PLL
46    BCLK und HCLK erzeugt:
47    31 | xxxx xxxx xxxx xxxx xx10 11xx xxxx xxxx | 0
48    0x2f008403 : 192MHz/2=96MHz, 144MHz/2=72MHz PRESC=1->BCLKDIV=2
49    0x2f008803 : 192MHz/3=64MHz, 240MHz/3=80MHz PRESC=1->BCLKDIV=2
50    0x2f001003 : 192MHz/5=38,4MHz
51    0x2f000003 : 64MHz/1
52    Bit 22: SPLL Restart
53    Bit 21: MPLL Restart */
55 #ifdef BUS64
56 #define CFG_CSCR_VAL 0x2f030003
57 #endif
59 #ifdef BUS72
60 #define CFG_CSCR_VAL 0x2f030403
61 #endif
62 /* Bit[0:3] contain PERCLK1DIV for UART 1
63    0x000b00b ->b<- -> 192MHz/12=16MHz
64    0x000b00b ->8<- -> 144MHz/09=16MHz
65    0x000b00b ->3<- -> 64MHz/4=16MHz */
67 #ifdef BUS96
68 #define CFG_PCDR_VAL 0x000b00b5
69 #endif
71 #ifdef BUS64
72 #define CFG_PCDR_VAL 0x000b00b3
73 #endif
75 #ifdef BUS72
76 #define CFG_PCDR_VAL 0x000b00b8
77 #endif
79 #define writel(val, reg) \
80         ldr             r0,     =reg;   \
81         ldr             r1,     =val;   \
82         str             r1,   [r0];
84 .globl board_init_lowlevel
85 board_init_lowlevel:
87         mov     r10, lr
89         /* Change PERCLK1DIV to 14 ie 14+1 */
90         writel(CFG_PCDR_VAL, PCDR)
92         /* set MCU PLL Control Register 0 */
93         writel(CFG_MPCTL0_VAL, MPCTL0)
95         /* set mpll restart bit */
96         ldr             r0, =CSCR
97         ldr             r1, [r0]
98         orr             r1,r1,#(1<<21)
99         str             r1, [r0]
101         mov             r2,#0x10
103         mov             r3,#0x2000
105         subs    r3,r3,#1
106         bne             2b
108         subs    r2,r2,#1
109         bne             1b
111         /* set System PLL Control Register 0 */
112         writel(CFG_SPCTL0_VAL, SPCTL0)
114         /* set spll restart bit */
115         ldr             r0, =CSCR
116         ldr             r1, [r0]
117         orr             r1,r1,#(1<<22)
118         str             r1, [r0]
120         mov             r2,#0x10
122         mov             r3,#0x2000
124         subs    r3,r3,#1
125         bne             2b
127         subs    r2,r2,#1
128         bne             1b
130         writel(CFG_CSCR_VAL, CSCR)
132 /* I have now read the ARM920 DataSheet back-to-Back, and have stumbled upon
133  *this.....
135  * It would appear that from a Cold-Boot the ARM920T enters "FastBus" mode CP15
136  * register 1, this stops it using the output of the PLL and thus runs at the
137  * slow rate. Unless you place the Core into "Asynch" mode, the CPU will never
138  * use the value set in the CM_OSC registers...regardless of what you set it
139  * too!  Thus, although i thought i was running at 140MHz, i'm actually running
140  * at 40!..
142  * Slapping this into my bootloader does the trick...
144  * MRC p15,0,r0,c1,c0,0    ; read core configuration register
145  * ORR r0,r0,#0xC0000000   ; set asynchronous clocks and not fastbus mode
146  * MCR p15,0,r0,c1,c0,0    ; write modified value to core configuration
147  * register
148  */
149         MRC p15,0,r0,c1,c0,0
150         ORR r0,r0,#0xC0000000
151         MCR p15,0,r0,c1,c0,0
153         /* Skip SDRAM initialization if we run from RAM */
154         cmp     pc, #0x08000000
155         bls     1f
156         cmp     pc, #0x09000000
157         bhi     1f
159         mov     pc,r10
163 /* SDRAM Setup */
165         writel(0x910a8200, SDCTL0) /* Precharge cmd, CAS = 2 */
166         writel(0x0, 0x08200000) /* Issue Precharge all Command */
167         writel(0xa10a8200, SDCTL0) /* Autorefresh cmd, CAS = 2 */
169         ldr             r0, =0x08000000
170         ldr             r1, =0x0 /* Issue AutoRefresh Command */
171         str             r1,   [r0]
172         str             r1,   [r0]
173         str             r1,   [r0]
174         str             r1,   [r0]
175         str             r1,   [r0]
176         str             r1,   [r0]
177         str             r1,   [r0]
178         str             r1,   [r0]
180         writel(0xb10a8300, SDCTL0)
181         writel(0x0, 0x08223000) /* CAS Latency 2, issue Mode Register Command, Burst Length = 8 */
182         writel(0x810a8200, SDCTL0) /* Set to Normal Mode CAS 2 */
184         mov     pc,r10