]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/sparc/cpu/leon2/cpu_init.c
1 /* Initializes CPU and basic hardware such as memory
2 * controllers, IRQ controller and system timer 0.
5 * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com
7 * SPDX-License-Identifier: GPL-2.0+
16 DECLARE_GLOBAL_DATA_PTR
;
18 /* reset CPU (jump to 0, without reset) */
27 * Breath some life into the CPU...
29 * Set up the memory map,
30 * initialize a bunch of registers.
32 * Run from FLASH/PROM:
33 * - until memory controller is set up, only registers available
34 * - no global variables available for writing
35 * - constants available
40 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
42 /* initialize the IRQMP */
43 leon2
->Interrupt_Force
= 0;
44 leon2
->Interrupt_Pending
= 0;
45 leon2
->Interrupt_Clear
= 0xfffe; /* clear all old pending interrupts */
46 leon2
->Interrupt_Mask
= 0xfffe0000; /* mask all IRQs */
51 #ifdef LEON2_IO_PORT_DIR
52 leon2
->PIO_Direction
= LEON2_IO_PORT_DIR
;
54 #ifdef LEON2_IO_PORT_DATA
55 leon2
->PIO_Data
= LEON2_IO_PORT_DATA
;
57 #ifdef LEON2_IO_PORT_INT
58 leon2
->PIO_Interrupt
= LEON2_IO_PORT_INT
;
60 leon2
->PIO_Interrupt
= 0;
64 void cpu_init_f2(void)
70 * initialize higher level parts of CPU like time base and timers
74 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
76 /* initialize prescaler common to all timers to 1MHz */
77 leon2
->Scaler_Counter
= leon2
->Scaler_Reload
=
78 (((CONFIG_SYS_CLK_FREQ
/ 1000) + 500) / 1000) - 1;
83 /* Uses Timer 0 to get accurate
84 * pauses. Max 2 raised to 32 ticks
87 void cpu_wait_ticks(unsigned long ticks
)
89 unsigned long start
= get_timer(0);
90 while (get_timer(start
) < ticks
) ;
93 /* initiate and setup timer0 interrupt to 1MHz
94 * Return irq number for timer int or a negative number for
97 int timer_interrupt_init_cpu(void)
99 LEON2_regs
*leon2
= (LEON2_regs
*) LEON2_PREGS
;
102 leon2
->Timer_Counter_1
= 0;
103 leon2
->Timer_Reload_1
= 999; /* (((1000000 / 100) - 1)) */
104 leon2
->Timer_Control_1
=
105 (LEON2_TIMER_CTRL_EN
| LEON2_TIMER_CTRL_RS
| LEON2_TIMER_CTRL_LD
);
107 return LEON2_TIMER1_IRQNO
;
111 * This function is intended for SHORT delays only.
113 unsigned long cpu_usec2ticks(unsigned long usec
)
115 /* timer set to 1kHz ==> 1 clk tick = 1 msec */
118 return (usec
/ 1000);
121 unsigned long cpu_ticks2usec(unsigned long ticks
)