3 * Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
5 * Module name: walnut_setup.c
8 * Architecture- / platform-specific boot-time initialization code for
9 * the IBM PowerPC 403GP "Walnut" 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>
22 #include <linux/blk.h>
24 #include <asm/processor.h>
25 #include <asm/board.h>
26 #include <asm/machdep.h>
29 #include "local_irq.h"
30 #include "ppc4xx_pic.h"
32 #include "walnut_setup.h"
35 /* Function Prototypes */
37 extern void abort(void);
39 /* Global Variables */
41 unsigned char __res
[sizeof(bd_t
)];
45 * void __init walnut_init()
51 * r3 - Optional pointer to a board information structure.
52 * r4 - Optional pointer to the physical starting address of the init RAM
54 * r5 - Optional pointer to the physical ending address of the init RAM
56 * r6 - Optional pointer to the physical starting address of any kernel
57 * command-line parameters.
58 * r7 - Optional pointer to the physical ending address of any kernel
59 * command-line parameters.
69 walnut_init(unsigned long r3
, unsigned long r4
, unsigned long r5
,
70 unsigned long r6
, unsigned long r7
)
73 * If we were passed in a board information, copy it into the
77 memcpy((void *)__res
, (void *)(r3
+ KERNELBASE
), sizeof(bd_t
));
80 #if defined(CONFIG_BLK_DEV_INITRD)
82 * If the init RAM disk has been configured in, and there's a valid
83 * starting address for it, set it up.
86 initrd_start
= r4
+ KERNELBASE
;
87 initrd_end
= r5
+ KERNELBASE
;
89 #endif /* CONFIG_BLK_DEV_INITRD */
91 /* Copy the kernel command line arguments to a safe place. */
94 *(char *)(r7
+ KERNELBASE
) = 0;
95 strcpy(cmd_line
, (char *)(r6
+ KERNELBASE
));
98 /* Initialize machine-dependency vectors */
100 ppc_md
.setup_arch
= walnut_setup_arch
;
101 ppc_md
.setup_residual
= walnut_setup_residual
;
102 ppc_md
.get_cpuinfo
= NULL
;
103 ppc_md
.irq_cannonicalize
= NULL
;
104 ppc_md
.init_IRQ
= walnut_init_IRQ
;
105 ppc_md
.get_irq
= walnut_get_irq
;
108 ppc_md
.restart
= walnut_restart
;
109 ppc_md
.power_off
= walnut_power_off
;
110 ppc_md
.halt
= walnut_halt
;
112 ppc_md
.time_init
= walnut_time_init
;
113 ppc_md
.set_rtc_time
= walnut_set_rtc_time
;
114 ppc_md
.get_rtc_time
= walnut_get_rtc_time
;
115 ppc_md
.calibrate_decr
= walnut_calibrate_decr
;
117 ppc_md
.kbd_setkeycode
= NULL
;
118 ppc_md
.kbd_getkeycode
= NULL
;
119 ppc_md
.kbd_translate
= NULL
;
120 ppc_md
.kbd_unexpected_up
= NULL
;
121 ppc_md
.kbd_leds
= NULL
;
122 ppc_md
.kbd_init_hw
= NULL
;
124 #if defined(CONFIG_MAGIC_SYSRQ)
125 ppc_md
.ppc_kbd_sysrq_xlate
= NULL
;
135 walnut_setup_arch(void)
137 /* XXX - Implement me */
141 * int walnut_setup_residual()
144 * This routine pretty-prints the platform's internal CPU and bus clock
145 * frequencies into the buffer for usage in /proc/cpuinfo.
148 * *buffer - Buffer into which CPU and bus clock frequencies are to be
152 * *buffer - Buffer with the CPU and bus clock frequencies.
155 * The number of bytes copied into 'buffer' if OK, otherwise zero or less
159 walnut_setup_residual(char *buffer
)
162 bd_t
*bp
= (bd_t
*)__res
;
164 len
+= sprintf(len
+ buffer
,
166 "bus clock\t\t: %dMHz\n",
167 bp
->bi_intfreq
/ 1000000,
168 bp
->bi_busfreq
/ 1000000);
177 walnut_init_IRQ(void)
183 for (i
= 0; i
< NR_IRQS
; i
++) {
184 irq_desc
[i
].handler
= ppc4xx_pic
;
194 walnut_get_irq(struct pt_regs
*regs
)
196 return (ppc4xx_pic_get_irq(regs
));
203 walnut_restart(char *cmd
)
212 walnut_power_off(void)
214 walnut_restart(NULL
);
223 walnut_restart(NULL
);
230 walnut_time_init(void)
232 /* XXX - Implement me */
240 walnut_set_rtc_time(unsigned long time
)
242 /* XXX - Implement me */
251 walnut_get_rtc_time(void)
253 /* XXX - Implement me */
259 * void __init walnut_calibrate_decr()
262 * This routine retrieves the internal processor frequency from the board
263 * information structure, sets up the kernel timer decrementer based on
264 * that value, enables the 403 programmable interval timer (PIT) and sets
265 * it up for auto-reload.
278 walnut_calibrate_decr(void)
281 bd_t
*bip
= (bd_t
*)__res
;
283 freq
= bip
->bi_intfreq
;
285 decrementer_count
= freq
/ HZ
;
286 count_period_num
= 1;
287 count_period_den
= freq
;
289 /* Enable the PIT and set auto-reload of its value */
291 mtspr(SPRN_TCR
, TCR_PIE
| TCR_ARE
);
293 /* Clear any pending timer interrupts */
295 mtspr(SPRN_TSR
, TSR_ENW
| TSR_WIS
| TSR_PIS
| TSR_FIS
);