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
* See file CREDITS for list of people who contributed to this
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU General Public License as
12
* published by the Free Software Foundation; either version 2 of
13
* the License, or (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33
DECLARE_GLOBAL_DATA_PTR;
35
/* reset CPU (jump to 0, without reset) */
44
* Breath some life into the CPU...
46
* Set up the memory map,
47
* initialize a bunch of registers.
49
* Run from FLASH/PROM:
50
* - until memory controller is set up, only registers avaiable
51
* - no global variables available for writing
52
* - constants avaiable
57
LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
59
/* initialize the IRQMP */
60
leon2->Interrupt_Force = 0;
61
leon2->Interrupt_Pending = 0;
62
leon2->Interrupt_Clear = 0xfffe; /* clear all old pending interrupts */
63
leon2->Interrupt_Mask = 0xfffe0000; /* mask all IRQs */
68
#ifdef LEON2_IO_PORT_DIR
69
leon2->PIO_Direction = LEON2_IO_PORT_DIR;
71
#ifdef LEON2_IO_PORT_DATA
72
leon2->PIO_Data = LEON2_IO_PORT_DATA;
74
#ifdef LEON2_IO_PORT_INT
75
leon2->PIO_Interrupt = LEON2_IO_PORT_INT;
77
leon2->PIO_Interrupt = 0;
81
void cpu_init_f2(void)
87
* initialize higher level parts of CPU like time base and timers
91
LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
93
/* initialize prescaler common to all timers to 1MHz */
94
leon2->Scaler_Counter = leon2->Scaler_Reload =
95
(((CONFIG_SYS_CLK_FREQ / 1000) + 500) / 1000) - 1;
100
/* Uses Timer 0 to get accurate
101
* pauses. Max 2 raised to 32 ticks
104
void cpu_wait_ticks(unsigned long ticks)
106
unsigned long start = get_timer(0);
107
while (get_timer(start) < ticks) ;
110
/* initiate and setup timer0 interrupt to 1MHz
111
* Return irq number for timer int or a negative number for
114
int timer_interrupt_init_cpu(void)
116
LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
119
leon2->Timer_Counter_1 = 0;
120
leon2->Timer_Reload_1 = 999; /* (((1000000 / 100) - 1)) */
121
leon2->Timer_Control_1 =
122
(LEON2_TIMER_CTRL_EN | LEON2_TIMER_CTRL_RS | LEON2_TIMER_CTRL_LD);
124
return LEON2_TIMER1_IRQNO;
128
* This function is intended for SHORT delays only.
130
unsigned long cpu_usec2ticks(unsigned long usec)
132
/* timer set to 1kHz ==> 1 clk tick = 1 msec */
135
return (usec / 1000);
138
unsigned long cpu_ticks2usec(unsigned long ticks)