Path: blob/master/arch/cris/arch-v32/mach-fs/dram_init.S
15125 views
/*1* DRAM/SDRAM initialization - alter with care2* This file is intended to be included from other assembler files3*4* Note: This file may not modify r8 or r9 because they are used to5* carry information from the decompresser to the kernel6*7* Copyright (C) 2000-2007 Axis Communications AB8*9* Authors: Mikael Starvik <[email protected]>10*/1112/* Just to be certain the config file is included, we include it here13* explicitely instead of depending on it being included in the file that14* uses this code.15*/1617#include <hwregs/asm/reg_map_asm.h>18#include <hwregs/asm/bif_core_defs_asm.h>1920;; WARNING! The registers r8 and r9 are used as parameters carrying21;; information from the decompressor (if the kernel was compressed).22;; They should not be used in the code below.2324; Refer to BIF MDS for a description of SDRAM initialization2526; Bank configuration27move.d REG_ADDR(bif_core, regi_bif_core, rw_sdram_cfg_grp0), $r028move.d CONFIG_ETRAX_SDRAM_GRP0_CONFIG, $r129move.d $r1, [$r0]30move.d REG_ADDR(bif_core, regi_bif_core, rw_sdram_cfg_grp1), $r031move.d CONFIG_ETRAX_SDRAM_GRP1_CONFIG, $r132move.d $r1, [$r0]3334; Calculate value of mrs_data35; CAS latency = 2 && bus_width = 32 => 0x4036; CAS latency = 3 && bus_width = 32 => 0x6037; CAS latency = 2 && bus_width = 16 => 0x2038; CAS latency = 3 && bus_width = 16 => 0x303940; Check if value is already supplied in kernel config41move.d CONFIG_ETRAX_SDRAM_COMMAND, $r242bne _set_timing43nop4445move.d 0x40, $r4 ; Assume 32 bits and CAS latency = 246move.d CONFIG_ETRAX_SDRAM_TIMING, $r147and.d 0x07, $r1 ; Get CAS latency48cmpq 2, $r1 ; CL = 2 ?49beq _bw_check50nop51move.d 0x60, $r45253_bw_check:54; Assume that group 0 width is equal to group 1. This assumption55; is wrong for a group 1 only hardware (such as the grand old56; StorPoint+).57move.d CONFIG_ETRAX_SDRAM_GRP0_CONFIG, $r158and.d 0x200, $r1 ; DRAM width is bit 959beq _set_timing60lslq 2, $r4 ; mrs_data starts at bit 261lsrq 1, $r4 ; 16 bits. Shift down value.6263; Set timing parameters (refresh off to avoid Guinness TR 83)64_set_timing:65move.d CONFIG_ETRAX_SDRAM_TIMING, $r166and.d ~(3 << reg_bif_core_rw_sdram_timing___ref___lsb), $r167move.d REG_ADDR(bif_core, regi_bif_core, rw_sdram_timing), $r068move.d $r1, [$r0]6970; Issue NOP command71move.d REG_ADDR(bif_core, regi_bif_core, rw_sdram_cmd), $r572moveq regk_bif_core_nop, $r173move.d $r1, [$r5]7475; Wait 200us76move.d 10000, $r2771: bne 1b78subq 1, $r27980; Issue initialization command sequence81lapc _sdram_commands_start, $r282lapc _sdram_commands_end, $r3831: clear.d $r684move.b [$r2+], $r6 ; Load command85or.d $r4, $r6 ; Add calculated mrs86move.d $r6, [$r5] ; Write rw_sdram_cmd87; Wait 80 ns between each command88move.d 4000, $r7892: bne 2b90subq 1, $r791cmp.d $r2, $r3 ; Last command?92bne 1b93nop9495; Start refresh96move.d CONFIG_ETRAX_SDRAM_TIMING, $r197move.d REG_ADDR(bif_core, regi_bif_core, rw_sdram_timing), $r098move.d $r1, [$r0]99100; Initialization finished101ba _sdram_commands_end102nop103104_sdram_commands_start:105.byte regk_bif_core_pre ; Precharge106.byte regk_bif_core_ref ; refresh107.byte regk_bif_core_ref ; refresh108.byte regk_bif_core_ref ; refresh109.byte regk_bif_core_ref ; refresh110.byte regk_bif_core_ref ; refresh111.byte regk_bif_core_ref ; refresh112.byte regk_bif_core_ref ; refresh113.byte regk_bif_core_ref ; refresh114.byte regk_bif_core_mrs ; mrs115_sdram_commands_end:116117118