blob: 6b7d3cbc71076ebef4fce8f93fb8410ef714e9cd [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Jens Scharsig9bbaae32010-02-03 22:47:35 +01002/*
3 * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) and
4 * Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
5 *
6 * Modified for the at91rm9200dk board by
7 * (C) Copyright 2004
8 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
Jens Scharsig9bbaae32010-02-03 22:47:35 +01009 */
10
11#include <config.h>
12
Tom Rinie1e85442021-08-27 21:18:30 -040013#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
Jens Scharsig9bbaae32010-02-03 22:47:35 +010014
15#include <asm/arch/hardware.h>
16#include <asm/arch/at91_mc.h>
17#include <asm/arch/at91_pmc.h>
18#include <asm/arch/at91_pio.h>
19
20#define ARM920T_CONTROL 0xC0000000 /* @ set bit 31 (iA) and 30 (nF) */
21
22_MTEXT_BASE:
23#undef START_FROM_MEM
24#ifdef START_FROM_MEM
Simon Glass72cc5382022-10-20 18:22:39 -060025 .word CONFIG_TEXT_BASE-PHYS_FLASH_1
Jens Scharsig9bbaae32010-02-03 22:47:35 +010026#else
Simon Glass72cc5382022-10-20 18:22:39 -060027 .word CONFIG_TEXT_BASE
Jens Scharsig9bbaae32010-02-03 22:47:35 +010028#endif
29
30.globl lowlevel_init
31lowlevel_init:
32 ldr r1, =AT91_ASM_PMC_MOR
33 /* Main oscillator Enable register */
34#ifdef CONFIG_SYS_USE_MAIN_OSCILLATOR
35 ldr r0, =0x0000FF01 /* Enable main oscillator */
36#else
37 ldr r0, =0x0000FF00 /* Disable main oscillator */
38#endif
39 str r0, [r1] /*AT91C_CKGR_MOR] */
40 /* Add loop to compensate Main Oscillator startup time */
41 ldr r0, =0x00000010
42LoopOsc:
43 subs r0, r0, #1
44 bhi LoopOsc
45
46 /* memory control configuration */
47 /* this isn't very elegant, but what the heck */
48 ldr r0, =SMRDATA
49 ldr r1, _MTEXT_BASE
50 sub r0, r0, r1
Jens Scharsig36ff5f72010-12-18 02:30:04 +000051 ldr r2, =SMRDATAE
52 sub r2, r2, r1
Jens Scharsig9bbaae32010-02-03 22:47:35 +010053pllloop:
54 /* the address */
55 ldr r1, [r0], #4
56 /* the value */
57 ldr r3, [r0], #4
58 str r3, [r1]
59 cmp r2, r0
60 bne pllloop
61 /* delay - this is all done by guess */
62 ldr r0, =0x00010000
63 /* (vs reading PMC_SR for LOCKA, LOCKB ... or MOSCS earlier) */
64lock:
65 subs r0, r0, #1
66 bhi lock
67 ldr r0, =SMRDATA1
68 ldr r1, _MTEXT_BASE
69 sub r0, r0, r1
Jens Scharsig36ff5f72010-12-18 02:30:04 +000070 ldr r2, =SMRDATA1E
71 sub r2, r2, r1
Jens Scharsig9bbaae32010-02-03 22:47:35 +010072sdinit:
73 /* the address */
74 ldr r1, [r0], #4
75 /* the value */
76 ldr r3, [r0], #4
77 str r3, [r1]
78 cmp r2, r0
79 bne sdinit
80
81 /* switch from FastBus to Asynchronous clock mode */
82 mrc p15, 0, r0, c1, c0, 0
83 orr r0, r0, #ARM920T_CONTROL
84 mcr p15, 0, r0, c1, c0, 0
85
86 /* everything is fine now */
87 mov pc, lr
88
89 .ltorg
90
91SMRDATA:
92 .word AT91_ASM_MC_EBI_CFG
93 .word CONFIG_SYS_EBI_CFGR_VAL
94 .word AT91_ASM_MC_SMC_CSR0
95 .word CONFIG_SYS_SMC_CSR0_VAL
96 .word AT91_ASM_PMC_PLLAR
Tom Rini6a5dccc2022-11-16 13:10:41 -050097 .word CFG_SYS_PLLAR_VAL
Jens Scharsig9bbaae32010-02-03 22:47:35 +010098 .word AT91_ASM_PMC_PLLBR
99 .word CONFIG_SYS_PLLBR_VAL
100 .word AT91_ASM_PMC_MCKR
Tom Rini6a5dccc2022-11-16 13:10:41 -0500101 .word CFG_SYS_MCKR_VAL
Jens Scharsig36ff5f72010-12-18 02:30:04 +0000102SMRDATAE:
Jens Scharsig9bbaae32010-02-03 22:47:35 +0100103 /* here there's a delay */
104SMRDATA1:
105 .word AT91_ASM_PIOC_ASR
106 .word CONFIG_SYS_PIOC_ASR_VAL
107 .word AT91_ASM_PIOC_BSR
108 .word CONFIG_SYS_PIOC_BSR_VAL
109 .word AT91_ASM_PIOC_PDR
Tom Rini6a5dccc2022-11-16 13:10:41 -0500110 .word CFG_SYS_PIOC_PDR_VAL
Jens Scharsig9bbaae32010-02-03 22:47:35 +0100111 .word AT91_ASM_MC_EBI_CSA
112 .word CONFIG_SYS_EBI_CSA_VAL
113 .word AT91_ASM_MC_SDRAMC_CR
Tom Rini6a5dccc2022-11-16 13:10:41 -0500114 .word CFG_SYS_SDRC_CR_VAL
Jens Scharsig9bbaae32010-02-03 22:47:35 +0100115 .word AT91_ASM_MC_SDRAMC_MR
Tom Rini6a5dccc2022-11-16 13:10:41 -0500116 .word CFG_SYS_SDRC_MR_VAL
Tom Rinibb4dd962022-11-16 13:10:37 -0500117 .word CFG_SYS_SDRAM
118 .word CFG_SYS_SDRAM_VAL
Jens Scharsig9bbaae32010-02-03 22:47:35 +0100119 .word AT91_ASM_MC_SDRAMC_MR
Tom Rini6a5dccc2022-11-16 13:10:41 -0500120 .word CFG_SYS_SDRC_MR_VAL1
Tom Rinibb4dd962022-11-16 13:10:37 -0500121 .word CFG_SYS_SDRAM
122 .word CFG_SYS_SDRAM_VAL
123 .word CFG_SYS_SDRAM
124 .word CFG_SYS_SDRAM_VAL
125 .word CFG_SYS_SDRAM
126 .word CFG_SYS_SDRAM_VAL
127 .word CFG_SYS_SDRAM
128 .word CFG_SYS_SDRAM_VAL
129 .word CFG_SYS_SDRAM
130 .word CFG_SYS_SDRAM_VAL
131 .word CFG_SYS_SDRAM
132 .word CFG_SYS_SDRAM_VAL
133 .word CFG_SYS_SDRAM
134 .word CFG_SYS_SDRAM_VAL
135 .word CFG_SYS_SDRAM
136 .word CFG_SYS_SDRAM_VAL
Jens Scharsig9bbaae32010-02-03 22:47:35 +0100137 .word AT91_ASM_MC_SDRAMC_MR
Tom Rini6a5dccc2022-11-16 13:10:41 -0500138 .word CFG_SYS_SDRC_MR_VAL2
Tom Rinibb4dd962022-11-16 13:10:37 -0500139 .word CFG_SYS_SDRAM1
140 .word CFG_SYS_SDRAM_VAL
Jens Scharsig9bbaae32010-02-03 22:47:35 +0100141 .word AT91_ASM_MC_SDRAMC_TR
Tom Rini6a5dccc2022-11-16 13:10:41 -0500142 .word CFG_SYS_SDRC_TR_VAL
Tom Rinibb4dd962022-11-16 13:10:37 -0500143 .word CFG_SYS_SDRAM
144 .word CFG_SYS_SDRAM_VAL
Jens Scharsig9bbaae32010-02-03 22:47:35 +0100145 .word AT91_ASM_MC_SDRAMC_MR
Tom Rini6a5dccc2022-11-16 13:10:41 -0500146 .word CFG_SYS_SDRC_MR_VAL3
Tom Rinibb4dd962022-11-16 13:10:37 -0500147 .word CFG_SYS_SDRAM
148 .word CFG_SYS_SDRAM_VAL
Jens Scharsig36ff5f72010-12-18 02:30:04 +0000149SMRDATA1E:
Jens Scharsig9bbaae32010-02-03 22:47:35 +0100150 /* SMRDATA1 is 176 bytes long */
Tom Rinie1e85442021-08-27 21:18:30 -0400151#endif /* CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) */