Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / arch / ppc / kernel / walnut_setup.c
blobe48a3e61a9ed251a7a55aced6b4ab31da1265f97
1 /*
3 * Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
5 * Module name: walnut_setup.c
7 * Description:
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
11 * <dan@net4x.com>.
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>
27 #include <asm/page.h>
29 #include "local_irq.h"
30 #include "ppc4xx_pic.h"
31 #include <asm/time.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()
47 * Description:
48 * This routine...
50 * Input(s):
51 * r3 - Optional pointer to a board information structure.
52 * r4 - Optional pointer to the physical starting address of the init RAM
53 * disk.
54 * r5 - Optional pointer to the physical ending address of the init RAM
55 * disk.
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.
61 * Output(s):
62 * N/A
64 * Returns:
65 * N/A
68 void __init
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
74 * residual data area.
76 if (r3) {
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.
85 if (r4) {
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. */
93 if (r6) {
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;
106 ppc_md.init = NULL;
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;
126 #endif
128 return;
132 * Document me.
134 void __init
135 walnut_setup_arch(void)
137 /* XXX - Implement me */
141 * int walnut_setup_residual()
143 * Description:
144 * This routine pretty-prints the platform's internal CPU and bus clock
145 * frequencies into the buffer for usage in /proc/cpuinfo.
147 * Input(s):
148 * *buffer - Buffer into which CPU and bus clock frequencies are to be
149 * printed.
151 * Output(s):
152 * *buffer - Buffer with the CPU and bus clock frequencies.
154 * Returns:
155 * The number of bytes copied into 'buffer' if OK, otherwise zero or less
156 * on error.
159 walnut_setup_residual(char *buffer)
161 int len = 0;
162 bd_t *bp = (bd_t *)__res;
164 len += sprintf(len + buffer,
165 "clock\t\t: %dMHz\n"
166 "bus clock\t\t: %dMHz\n",
167 bp->bi_intfreq / 1000000,
168 bp->bi_busfreq / 1000000);
170 return (len);
174 * Document me.
176 void __init
177 walnut_init_IRQ(void)
179 int i;
181 ppc4xx_pic_init();
183 for (i = 0; i < NR_IRQS; i++) {
184 irq_desc[i].handler = ppc4xx_pic;
187 return;
191 * Document me.
194 walnut_get_irq(struct pt_regs *regs)
196 return (ppc4xx_pic_get_irq(regs));
200 * Document me.
202 void
203 walnut_restart(char *cmd)
205 abort();
209 * Document me.
211 void
212 walnut_power_off(void)
214 walnut_restart(NULL);
218 * Document me.
220 void
221 walnut_halt(void)
223 walnut_restart(NULL);
227 * Document me.
229 long __init
230 walnut_time_init(void)
232 /* XXX - Implement me */
233 return 0;
237 * Document me.
239 int __init
240 walnut_set_rtc_time(unsigned long time)
242 /* XXX - Implement me */
244 return (0);
248 * Document me.
250 unsigned long __init
251 walnut_get_rtc_time(void)
253 /* XXX - Implement me */
255 return (0);
259 * void __init walnut_calibrate_decr()
261 * Description:
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.
267 * Input(s):
268 * N/A
270 * Output(s):
271 * N/A
273 * Returns:
274 * N/A
277 void __init
278 walnut_calibrate_decr(void)
280 unsigned int freq;
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);