3 * Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
5 * Module name: oak_setup.c
8 * Architecture- / platform-specific boot-time initialization code for
9 * the IBM PowerPC 403GCX "Oak" evaluation board. Adapted from original
10 * code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek
15 #include <linux/config.h>
16 #include <linux/init.h>
17 #include <linux/smp.h>
18 #include <linux/threads.h>
19 #include <linux/interrupt.h>
20 #include <linux/param.h>
21 #include <linux/string.h>
23 #include <asm/processor.h>
24 #include <asm/board.h>
25 #include <asm/machdep.h>
28 #include "local_irq.h"
29 #include "ppc4xx_pic.h"
31 #include "oak_setup.h"
33 /* Function Prototypes */
35 extern void abort(void);
37 /* Global Variables */
39 unsigned char __res
[sizeof(bd_t
)];
43 * void __init oak_init()
49 * r3 - Optional pointer to a board information structure.
50 * r4 - Optional pointer to the physical starting address of the init RAM
52 * r5 - Optional pointer to the physical ending address of the init RAM
54 * r6 - Optional pointer to the physical starting address of any kernel
55 * command-line parameters.
56 * r7 - Optional pointer to the physical ending address of any kernel
57 * command-line parameters.
67 oak_init(unsigned long r3
, unsigned long r4
, unsigned long r5
,
68 unsigned long r6
, unsigned long r7
)
71 * If we were passed in a board information, copy it into the
75 memcpy((void *)__res
, (void *)(r3
+ KERNELBASE
), sizeof(bd_t
));
78 #if defined(CONFIG_BLK_DEV_INITRD)
80 * If the init RAM disk has been configured in, and there's a valid
81 * starting address for it, set it up.
84 initrd_start
= r4
+ KERNELBASE
;
85 initrd_end
= r5
+ KERNELBASE
;
87 #endif /* CONFIG_BLK_DEV_INITRD */
89 /* Copy the kernel command line arguments to a safe place. */
92 *(char *)(r7
+ KERNELBASE
) = 0;
93 strcpy(cmd_line
, (char *)(r6
+ KERNELBASE
));
96 /* Initialize machine-dependency vectors */
98 ppc_md
.setup_arch
= oak_setup_arch
;
99 ppc_md
.setup_residual
= oak_setup_residual
;
100 ppc_md
.get_cpuinfo
= NULL
;
101 ppc_md
.irq_cannonicalize
= NULL
;
102 ppc_md
.init_IRQ
= oak_init_IRQ
;
103 ppc_md
.get_irq
= oak_get_irq
;
106 ppc_md
.restart
= oak_restart
;
107 ppc_md
.power_off
= oak_power_off
;
108 ppc_md
.halt
= oak_halt
;
110 ppc_md
.time_init
= oak_time_init
;
111 ppc_md
.set_rtc_time
= oak_set_rtc_time
;
112 ppc_md
.get_rtc_time
= oak_get_rtc_time
;
113 ppc_md
.calibrate_decr
= oak_calibrate_decr
;
115 ppc_md
.kbd_setkeycode
= NULL
;
116 ppc_md
.kbd_getkeycode
= NULL
;
117 ppc_md
.kbd_translate
= NULL
;
118 ppc_md
.kbd_unexpected_up
= NULL
;
119 ppc_md
.kbd_leds
= NULL
;
120 ppc_md
.kbd_init_hw
= NULL
;
122 #if defined(CONFIG_MAGIC_SYSRQ)
123 ppc_md
.kbd_sysrq_xlate
= NULL
;
135 /* XXX - Implement me */
139 * int oak_setup_residual()
142 * This routine pretty-prints the platform's internal CPU and bus clock
143 * frequencies into the buffer for usage in /proc/cpuinfo.
146 * *buffer - Buffer into which CPU and bus clock frequencies are to be
150 * *buffer - Buffer with the CPU and bus clock frequencies.
153 * The number of bytes copied into 'buffer' if OK, otherwise zero or less
157 oak_setup_residual(char *buffer
)
160 bd_t
*bp
= (bd_t
*)__res
;
162 len
+= sprintf(len
+ buffer
,
164 "bus clock\t\t: %dMHz\n",
165 bp
->bi_intfreq
/ 1000000,
166 bp
->bi_busfreq
/ 1000000);
181 for (i
= 0; i
< NR_IRQS
; i
++) {
182 irq_desc
[i
].handler
= ppc4xx_pic
;
192 oak_get_irq(struct pt_regs
*regs
)
194 return (ppc4xx_pic_get_irq(regs
));
201 oak_restart(char *cmd
)
230 /* XXX - Implement me */
237 oak_set_rtc_time(unsigned long time
)
239 /* XXX - Implement me */
248 oak_get_rtc_time(void)
250 /* XXX - Implement me */
256 * void __init oak_calibrate_decr()
259 * This routine retrieves the internal processor frequency from the board
260 * information structure, sets up the kernel timer decrementer based on
261 * that value, enables the 403 programmable interval timer (PIT) and sets
262 * it up for auto-reload.
275 oak_calibrate_decr(void)
278 bd_t
*bip
= (bd_t
*)__res
;
280 freq
= bip
->bi_intfreq
;
282 decrementer_count
= freq
/ HZ
;
283 count_period_num
= 1;
284 count_period_den
= freq
;
286 /* Enable the PIT and set auto-reload of its value */
288 mtspr(SPRN_TCR
, TCR_PIE
| TCR_ARE
);
290 /* Clear any pending timer interrupts */
292 mtspr(SPRN_TSR
, TSR_ENW
| TSR_WIS
| TSR_PIS
| TSR_FIS
);