2 * DRAM/SDRAM initialization - alter with care
3 * This file is intended to be included from other assembler files
5 * Note: This file may not modify r9 because r9 is used to carry
6 * information from the decompresser to the kernel
8 * Copyright (C) 2000, 2001 Axis Communications AB
10 * Authors: Mikael Starvik (starvik@axis.com)
14 /* Just to be certain the config file is included, we include it here
15 * explicitly instead of depending on it being included in the file that
20 ;; WARNING! The registers r8 and r9 are used as parameters carrying
21 ;; information from the decompressor (if the kernel was compressed).
22 ;; They should not be used in the code below.
24 #ifndef CONFIG_SVINTO_SIM
25 move.d CONFIG_ETRAX_DEF_R_WAITSTATES, $r0
26 move.d $r0, [R_WAITSTATES]
28 move.d CONFIG_ETRAX_DEF_R_BUS_CONFIG, $r0
29 move.d $r0, [R_BUS_CONFIG]
31 #ifndef CONFIG_ETRAX_SDRAM
32 move.d CONFIG_ETRAX_DEF_R_DRAM_CONFIG, $r0
33 move.d $r0, [R_DRAM_CONFIG]
35 move.d CONFIG_ETRAX_DEF_R_DRAM_TIMING, $r0
36 move.d $r0, [R_DRAM_TIMING]
38 ;; Samsung SDRAMs seem to require to be initialized twice to work properly.
42 ; Refer to ETRAX 100LX Designers Reference for a description of SDRAM initialization
45 move.d CONFIG_ETRAX_DEF_R_SDRAM_CONFIG, $r0
46 move.d $r0, [R_SDRAM_CONFIG]
48 ; Calculate value of mrs_data
49 ; CAS latency = 2 && bus_width = 32 => 0x40
50 ; CAS latency = 3 && bus_width = 32 => 0x60
51 ; CAS latency = 2 && bus_width = 16 => 0x20
52 ; CAS latency = 3 && bus_width = 16 => 0x30
54 ; Check if value is already supplied in kernel config
55 move.d CONFIG_ETRAX_DEF_R_SDRAM_TIMING, $r2
60 move.d 0x40, $r2 ; Assume 32 bits and CAS latency = 2
61 move.d CONFIG_ETRAX_DEF_R_SDRAM_TIMING, $r1
63 and.d 0x03, $r1 ; Get CAS latency
64 and.d 0x1000, $r3 ; 50 or 100 MHz?
68 cmp.d 0x00, $r1 ; CAS latency = 2?
71 or.d 0x20, $r2 ; CAS latency = 3
75 cmp.d 0x01, $r1 ; CAS latency = 2?
78 or.d 0x20, $r2 ; CAS latency = 3
80 move.d CONFIG_ETRAX_DEF_R_SDRAM_CONFIG, $r1
81 and.d 0x800000, $r1 ; DRAM width is bit 23
84 lsrq 1, $r2 ; 16 bits. Shift down value.
86 ; Set timing parameters. Starts master clock
88 move.d CONFIG_ETRAX_DEF_R_SDRAM_TIMING, $r1
89 and.d 0x8000f9ff, $r1 ; Make sure mrs data and command is 0
90 or.d 0x80000000, $r1 ; Make sure sdram enable bit is set
92 or.d 0x0000c000, $r1 ; ref = disable
93 lslq 16, $r2 ; mrs data starts at bit 16
95 move.d $r1, [R_SDRAM_TIMING]
102 ; Issue initialization command sequence
103 move.d _sdram_commands_start, $r2
104 and.d 0x000fffff, $r2 ; Make sure commands are read from flash
105 move.d _sdram_commands_end, $r3
106 and.d 0x000fffff, $r3
109 lslq 9, $r4 ; Command starts at bit 9
111 move.d $r4, [R_SDRAM_TIMING]
112 nop ; Wait five nop cycles between each command
120 move.d $r5, [R_SDRAM_TIMING]
124 ba _sdram_commands_end
127 _sdram_commands_start: