1 /* SPDX-License-Identifier: GPL-2.0 */
3 * DRAM/SDRAM initialization - alter with care
4 * This file is intended to be included from other assembler files
6 * Note: This file may not modify r9 because r9 is used to carry
7 * information from the decompressor to the kernel
9 * Copyright (C) 2000-2012 Axis Communications AB
13 /* Just to be certain the config file is included, we include it here
14 * explicitly instead of depending on it being included in the file that
19 ;; WARNING! The registers r8 and r9 are used as parameters carrying
20 ;; information from the decompressor (if the kernel was compressed).
21 ;; They should not be used in the code below.
23 move.d CONFIG_ETRAX_DEF_R_WAITSTATES, $r0
24 move.d $r0, [R_WAITSTATES]
26 move.d CONFIG_ETRAX_DEF_R_BUS_CONFIG, $r0
27 move.d $r0, [R_BUS_CONFIG]
29 #ifndef CONFIG_ETRAX_SDRAM
30 move.d CONFIG_ETRAX_DEF_R_DRAM_CONFIG, $r0
31 move.d $r0, [R_DRAM_CONFIG]
33 move.d CONFIG_ETRAX_DEF_R_DRAM_TIMING, $r0
34 move.d $r0, [R_DRAM_TIMING]
36 ;; Samsung SDRAMs seem to require to be initialized twice to work properly.
40 ; Refer to ETRAX 100LX Designers Reference for a description of SDRAM initialization
43 move.d CONFIG_ETRAX_DEF_R_SDRAM_CONFIG, $r0
44 move.d $r0, [R_SDRAM_CONFIG]
46 ; Calculate value of mrs_data
47 ; CAS latency = 2 && bus_width = 32 => 0x40
48 ; CAS latency = 3 && bus_width = 32 => 0x60
49 ; CAS latency = 2 && bus_width = 16 => 0x20
50 ; CAS latency = 3 && bus_width = 16 => 0x30
52 ; Check if value is already supplied in kernel config
53 move.d CONFIG_ETRAX_DEF_R_SDRAM_TIMING, $r2
58 move.d 0x40, $r2 ; Assume 32 bits and CAS latency = 2
59 move.d CONFIG_ETRAX_DEF_R_SDRAM_TIMING, $r1
61 and.d 0x03, $r1 ; Get CAS latency
62 and.d 0x1000, $r3 ; 50 or 100 MHz?
66 cmp.d 0x00, $r1 ; CAS latency = 2?
69 or.d 0x20, $r2 ; CAS latency = 3
73 cmp.d 0x01, $r1 ; CAS latency = 2?
76 or.d 0x20, $r2 ; CAS latency = 3
78 move.d CONFIG_ETRAX_DEF_R_SDRAM_CONFIG, $r1
79 and.d 0x800000, $r1 ; DRAM width is bit 23
82 lsrq 1, $r2 ; 16 bits. Shift down value.
84 ; Set timing parameters. Starts master clock
86 move.d CONFIG_ETRAX_DEF_R_SDRAM_TIMING, $r1
87 and.d 0x8000f9ff, $r1 ; Make sure mrs data and command is 0
88 or.d 0x80000000, $r1 ; Make sure sdram enable bit is set
90 or.d 0x0000c000, $r1 ; ref = disable
91 lslq 16, $r2 ; mrs data starts at bit 16
93 move.d $r1, [R_SDRAM_TIMING]
100 ; Issue initialization command sequence
101 move.d _sdram_commands_start, $r2
102 and.d 0x000fffff, $r2 ; Make sure commands are read from flash
103 move.d _sdram_commands_end, $r3
104 and.d 0x000fffff, $r3
107 lslq 9, $r4 ; Command starts at bit 9
109 move.d $r4, [R_SDRAM_TIMING]
110 nop ; Wait five nop cycles between each command
118 move.d $r5, [R_SDRAM_TIMING]
122 ba _sdram_commands_end
125 _sdram_commands_start: