blob: 3e46ed9774f7ada251a8ae7701afa876b9067597 [file] [log] [blame]
John Rigby6895d452010-01-25 23:12:58 -07001/*
2 * (C) Copyright 2009 DENX Software Engineering
3 * Author: John Rigby <jrigby@gmail.com>
4 *
5 * Based on U-Boot and RedBoot sources for several different i.mx
6 * platforms.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <asm/macro.h>
Benoît Thébaudeau85d993c2012-08-20 09:00:57 +000025#include <asm/arch/macro.h>
John Rigby6895d452010-01-25 23:12:58 -070026
27.macro init_clocks
28 /*
29 * clocks
30 *
31 * first enable CLKO debug output
32 * 0x40000000 enables the debug CLKO signal
33 * 0x05000000 sets CLKO divider to 6
34 * 0x00600000 makes CLKO parent clk the USB clk
35 */
36 write32 0x53f80064, 0x45600000
Benoît Thébaudeau85d993c2012-08-20 09:00:57 +000037
38 /* CCTL: ARM = 399 MHz, AHB = 133 MHz */
John Rigby6895d452010-01-25 23:12:58 -070039 write32 0x53f80008, 0x20034000
40
41 /*
Benoît Thébaudeau55270242012-08-08 03:55:32 +000042 * PCDR2: NFC = 33.25 MHz
43 * This is required for the NAND Flash of this board, which is a Samsung
44 * K9F1G08U0B with 25-ns R/W cycle times, in order to make it work with
45 * the NFC driver in symmetric (i.e. one-cycle) mode.
46 */
47 write32 0x53f80020, 0x01010103
48
49 /*
John Rigby6895d452010-01-25 23:12:58 -070050 * enable all implemented clocks in all three
51 * clock control registers
52 */
53 write32 0x53f8000c, 0x1fffffff
54 write32 0x53f80010, 0xffffffff
55 write32 0x53f80014, 0xfdfff
56.endm
57
58.macro init_ddrtype
59 /*
60 * ddr_type is 3.3v SDRAM
61 */
62 write32 0x43fac454, 0x800
63.endm
64
65/*
66 * sdram controller init
67 */
68.macro init_sdram_bank bankaddr, ctl, cfg
69 ldr r0, =0xb8001000
70 ldr r2, =\bankaddr
71 /*
72 * reset SDRAM controller
73 * then wait for initialization to complete
74 */
75 ldr r1, =(1 << 1)
76 str r1, [r0, #0x10]
771: ldr r3, [r0, #0x10]
78 tst r3, #(1 << 31)
79 beq 1b
80
81 ldr r1, =0x95728
82 str r1, [r0, #\cfg] /* config */
83
84 ldr r1, =0x92116480 /* control | precharge */
85 str r1, [r0, #\ctl] /* write command to controller */
86 str r1, [r2, #0x400] /* command encoded in address */
87
88 ldr r1, =0xa2116480 /* auto refresh */
89 str r1, [r0, #\ctl]
90 ldrb r3, [r2] /* read dram twice to auto refresh */
91 ldrb r3, [r2]
92
93 ldr r1, =0xb2116480 /* control | load mode */
94 str r1, [r0, #\ctl] /* write command to controller */
95 strb r1, [r2, #0x33] /* command encoded in address */
96
97 ldr r1, =0x82116480 /* control | normal (0)*/
98 str r1, [r0, #\ctl] /* write command to controller */
99.endm
100
101.globl lowlevel_init
102lowlevel_init:
103 init_aips
104 init_max
105 init_m3if
106 init_clocks
107
108 init_sdram_bank 0x80000000, 0x0, 0x4
109
110 init_sdram_bank 0x90000000, 0x8, 0xc
111 mov pc, lr