]> git.ipfire.org Git - people/ms/u-boot.git/blame - arch/sparc/cpu/leon2/cpu_init.c
Blackfin: Remove
[people/ms/u-boot.git] / arch / sparc / cpu / leon2 / cpu_init.c
CommitLineData
b330990c
DH
1/* Initializes CPU and basic hardware such as memory
2 * controllers, IRQ controller and system timer 0.
3 *
e17c5200
FR
4 * (C) Copyright 2007, 2015
5 * Daniel Hellstrom, Cobham Gaisler, daniel@gaisler.com
b330990c 6 *
1a459660 7 * SPDX-License-Identifier: GPL-2.0+
b330990c
DH
8 */
9
10#include <common.h>
11#include <asm/asi.h>
12#include <asm/leon.h>
c97088c3 13#include <asm/io.h>
b330990c
DH
14
15#include <config.h>
16
17DECLARE_GLOBAL_DATA_PTR;
18
b330990c
DH
19/*
20 * Breath some life into the CPU...
21 *
22 * Set up the memory map,
23 * initialize a bunch of registers.
24 *
25 * Run from FLASH/PROM:
6052cbab 26 * - until memory controller is set up, only registers available
b330990c 27 * - no global variables available for writing
6052cbab 28 * - constants available
b330990c
DH
29 */
30
31void cpu_init_f(void)
32{
33 LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
34
35 /* initialize the IRQMP */
36 leon2->Interrupt_Force = 0;
37 leon2->Interrupt_Pending = 0;
38 leon2->Interrupt_Clear = 0xfffe; /* clear all old pending interrupts */
39 leon2->Interrupt_Mask = 0xfffe0000; /* mask all IRQs */
40
41 /* cache */
42
a5b629a3 43 /* I/O port setup */
b330990c 44#ifdef LEON2_IO_PORT_DIR
a5b629a3 45 leon2->PIO_Direction = LEON2_IO_PORT_DIR;
b330990c
DH
46#endif
47#ifdef LEON2_IO_PORT_DATA
a5b629a3 48 leon2->PIO_Data = LEON2_IO_PORT_DATA;
b330990c
DH
49#endif
50#ifdef LEON2_IO_PORT_INT
a5b629a3 51 leon2->PIO_Interrupt = LEON2_IO_PORT_INT;
b330990c 52#else
a5b629a3 53 leon2->PIO_Interrupt = 0;
b330990c 54#endif
c97088c3
FR
55
56 /* disable timers */
57 leon2->Timer_Control_1 = leon2->Timer_Control_2 = 0;
b330990c
DH
58}
59
e17c5200
FR
60int arch_cpu_init(void)
61{
62 gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
63 gd->bus_clk = CONFIG_SYS_CLK_FREQ;
64 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
65
66 return 0;
67}
68
b330990c 69/*
c97088c3 70 * initialize higher level parts of CPU
b330990c
DH
71 */
72int cpu_init_r(void)
73{
c97088c3 74 return 0;
b330990c
DH
75}
76
7a4fb11b 77/* initiate and setup timer0 to configured HZ. Base clock is 1MHz.
b330990c 78 */
c97088c3
FR
79int timer_init(void)
80{
81 LEON2_regs *leon2 = (LEON2_regs *)LEON2_PREGS;
82
83 /* initialize prescaler common to all timers to 1MHz */
84 leon2->Scaler_Counter = leon2->Scaler_Reload =
85 (((CONFIG_SYS_CLK_FREQ / 1000) + 500) / 1000) - 1;
86
87 /* SYS_HZ ticks per second */
88 leon2->Timer_Counter_1 = 0;
89 leon2->Timer_Reload_1 = (CONFIG_SYS_TIMER_RATE / CONFIG_SYS_HZ) - 1;
90 leon2->Timer_Control_1 = LEON2_TIMER_CTRL_EN | LEON2_TIMER_CTRL_RS |
91 LEON2_TIMER_CTRL_LD;
92
93 CONFIG_SYS_TIMER_COUNTER = (void *)&leon2->Timer_Counter_1;
94 return 0;
95}