]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/cpu/pxa/cpu.c
3 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 * Marius Groeger <mgroeger@sysgo.de>
7 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
8 * Alex Zuepke <azu@sysgo.de>
10 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 #include <asm/system.h>
37 #include <asm/arch/pxa-regs.h>
39 static void cache_flush(void);
41 int cleanup_before_linux (void)
44 * this function is called just before we call linux
45 * it prepares the processor for linux
47 * just disable everything that can disturb booting linux
50 disable_interrupts ();
52 /* turn off I-cache */
63 static void cache_flush (void)
67 asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (i
));
70 #ifndef CONFIG_CPU_MONAHANS
71 void set_GPIO_mode(int gpio_mode
)
73 int gpio
= gpio_mode
& GPIO_MD_MASK_NR
;
74 int fn
= (gpio_mode
& GPIO_MD_MASK_FN
) >> 8;
77 /* This below changes direction setting of GPIO "gpio" */
78 val
= readl(GPDR(gpio
));
80 if (gpio_mode
& GPIO_MD_MASK_DIR
)
81 val
|= GPIO_bit(gpio
);
83 val
&= ~GPIO_bit(gpio
);
85 writel(val
, GPDR(gpio
));
87 /* This below updates only AF of GPIO "gpio" */
88 val
= readl(GAFR(gpio
));
89 val
&= ~(0x3 << (((gpio
) & 0xf) * 2));
90 val
|= fn
<< (((gpio
) & 0xf) * 2);
91 writel(val
, GAFR(gpio
));
93 #endif /* CONFIG_CPU_MONAHANS */
95 void pxa_wait_ticks(int ticks
)
98 while (readl(OSCR
) < ticks
)
99 asm volatile("":::"memory");
102 inline void writelrb(uint32_t val
, uint32_t addr
)
105 asm volatile("":::"memory");
107 asm volatile("":::"memory");
110 void pxa_dram_init(void)
115 * 1) Initialize Asynchronous static memory controller
118 writelrb(CONFIG_SYS_MSC0_VAL
, MSC0
);
119 writelrb(CONFIG_SYS_MSC1_VAL
, MSC1
);
120 writelrb(CONFIG_SYS_MSC2_VAL
, MSC2
);
122 * 2) Initialize Card Interface
125 /* MECR: Memory Expansion Card Register */
126 writelrb(CONFIG_SYS_MECR_VAL
, MECR
);
127 /* MCMEM0: Card Interface slot 0 timing */
128 writelrb(CONFIG_SYS_MCMEM0_VAL
, MCMEM0
);
129 /* MCMEM1: Card Interface slot 1 timing */
130 writelrb(CONFIG_SYS_MCMEM1_VAL
, MCMEM1
);
131 /* MCATT0: Card Interface Attribute Space Timing, slot 0 */
132 writelrb(CONFIG_SYS_MCATT0_VAL
, MCATT0
);
133 /* MCATT1: Card Interface Attribute Space Timing, slot 1 */
134 writelrb(CONFIG_SYS_MCATT1_VAL
, MCATT1
);
135 /* MCIO0: Card Interface I/O Space Timing, slot 0 */
136 writelrb(CONFIG_SYS_MCIO0_VAL
, MCIO0
);
137 /* MCIO1: Card Interface I/O Space Timing, slot 1 */
138 writelrb(CONFIG_SYS_MCIO1_VAL
, MCIO1
);
141 * 3) Configure Fly-By DMA register
144 writelrb(CONFIG_SYS_FLYCNFG_VAL
, FLYCNFG
);
147 * 4) Initialize Timing for Sync Memory (SDCLK0)
151 * Before accessing MDREFR we need a valid DRI field, so we set
152 * this to power on defaults + DRI field.
155 /* Read current MDREFR config and zero out DRI */
156 tmp
= readl(MDREFR
) & ~0xfff;
157 /* Add user-specified DRI */
158 tmp
|= CONFIG_SYS_MDREFR_VAL
& 0xfff;
159 /* Configure important bits */
160 tmp
|= MDREFR_K0RUN
| MDREFR_SLFRSH
;
161 tmp
&= ~(MDREFR_APD
| MDREFR_E1PIN
);
163 /* Write MDREFR back */
164 writelrb(tmp
, MDREFR
);
167 * 5) Initialize Synchronous Static Memory (Flash/Peripherals)
170 /* Initialize SXCNFG register. Assert the enable bits.
172 * Write SXMRS to cause an MRS command to all enabled banks of
173 * synchronous static memory. Note that SXLCR need not be written
176 writelrb(CONFIG_SYS_SXCNFG_VAL
, SXCNFG
);
179 * 6) Initialize SDRAM
182 writelrb(CONFIG_SYS_MDREFR_VAL
& ~MDREFR_SLFRSH
, MDREFR
);
183 writelrb(CONFIG_SYS_MDREFR_VAL
| MDREFR_E1PIN
, MDREFR
);
186 * 7) Write MDCNFG with MDCNFG:DEx deasserted (set to 0), to configure
187 * but not enable each SDRAM partition pair.
190 writelrb(CONFIG_SYS_MDCNFG_VAL
&
191 ~(MDCNFG_DE0
| MDCNFG_DE1
| MDCNFG_DE2
| MDCNFG_DE3
), MDCNFG
);
192 /* Wait for the clock to the SDRAMs to stabilize, 100..200 usec. */
193 pxa_wait_ticks(0x300);
196 * 8) Trigger a number (usually 8) refresh cycles by attempting
197 * non-burst read or write accesses to disabled SDRAM, as commonly
198 * specified in the power up sequence documented in SDRAM data
199 * sheets. The address(es) used for this purpose must not be
202 for (i
= 9; i
>= 0; i
--) {
203 writel(i
, 0xa0000000);
204 asm volatile("":::"memory");
207 * 9) Write MDCNFG with enable bits asserted (MDCNFG:DEx set to 1).
210 tmp
= CONFIG_SYS_MDCNFG_VAL
&
211 (MDCNFG_DE0
| MDCNFG_DE1
| MDCNFG_DE2
| MDCNFG_DE3
);
212 tmp
|= readl(MDCNFG
);
213 writelrb(tmp
, MDCNFG
);
219 writelrb(CONFIG_SYS_MDMRS_VAL
, MDMRS
);
225 if (CONFIG_SYS_MDREFR_VAL
& MDREFR_APD
) {
228 writelrb(tmp
, MDREFR
);
232 void pxa_gpio_setup(void)
234 writel(CONFIG_SYS_GPSR0_VAL
, GPSR0
);
235 writel(CONFIG_SYS_GPSR1_VAL
, GPSR1
);
236 writel(CONFIG_SYS_GPSR2_VAL
, GPSR2
);
237 #if defined(CONFIG_PXA27X) || defined(CONFIG_CPU_MONAHANS)
238 writel(CONFIG_SYS_GPSR3_VAL
, GPSR3
);
241 writel(CONFIG_SYS_GPCR0_VAL
, GPCR0
);
242 writel(CONFIG_SYS_GPCR1_VAL
, GPCR1
);
243 writel(CONFIG_SYS_GPCR2_VAL
, GPCR2
);
244 #if defined(CONFIG_PXA27X) || defined(CONFIG_CPU_MONAHANS)
245 writel(CONFIG_SYS_GPCR3_VAL
, GPCR3
);
248 writel(CONFIG_SYS_GPDR0_VAL
, GPDR0
);
249 writel(CONFIG_SYS_GPDR1_VAL
, GPDR1
);
250 writel(CONFIG_SYS_GPDR2_VAL
, GPDR2
);
251 #if defined(CONFIG_PXA27X) || defined(CONFIG_CPU_MONAHANS)
252 writel(CONFIG_SYS_GPDR3_VAL
, GPDR3
);
255 writel(CONFIG_SYS_GAFR0_L_VAL
, GAFR0_L
);
256 writel(CONFIG_SYS_GAFR0_U_VAL
, GAFR0_U
);
257 writel(CONFIG_SYS_GAFR1_L_VAL
, GAFR1_L
);
258 writel(CONFIG_SYS_GAFR1_U_VAL
, GAFR1_U
);
259 writel(CONFIG_SYS_GAFR2_L_VAL
, GAFR2_L
);
260 writel(CONFIG_SYS_GAFR2_U_VAL
, GAFR2_U
);
261 #if defined(CONFIG_PXA27X) || defined(CONFIG_CPU_MONAHANS)
262 writel(CONFIG_SYS_GAFR3_L_VAL
, GAFR3_L
);
263 writel(CONFIG_SYS_GAFR3_U_VAL
, GAFR3_U
);
266 writel(CONFIG_SYS_PSSR_VAL
, PSSR
);
269 void pxa_interrupt_setup(void)
273 #if defined(CONFIG_PXA27X) || defined(CONFIG_CPU_MONAHANS)
279 void pxa_clock_setup(void)
281 #ifndef CONFIG_CPU_MONAHANS
282 writel(CONFIG_SYS_CKEN
, CKEN
);
283 writel(CONFIG_SYS_CCCR
, CCCR
);
284 asm volatile("mcr p14, 0, %0, c6, c0, 0"::"r"(2));
286 /* Set CKENA/CKENB/ACCR for MH */
289 /* enable the 32Khz oscillator for RTC and PowerManager */
290 writel(OSCC_OON
, OSCC
);
291 while(!(readl(OSCC
) & OSCC_OOK
))
292 asm volatile("":::"memory");
295 void pxa_wakeup(void)
300 writel(rcsr
& (RCSR_GPR
| RCSR_SMR
| RCSR_WDR
| RCSR_HWR
), RCSR
);
303 if (rcsr
& RCSR_SMR
) {
304 writel(PSSR_PH
, PSSR
);
308 asm volatile("mov pc, %0"::"r"(readl(PSSR
)));
312 int arch_cpu_init(void)
315 /* pxa_wait_ticks(0x8000); */
317 pxa_interrupt_setup();