Merge with Linux 2.3.40.
[linux-2.6/linux-mips.git] / arch / ppc / kernel / oak_setup.c
blobad2c224bb6603bec05012e06ce91a6fe23560830
1 /*
3 * Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
5 * Module name: oak_setup.c
7 * Description:
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
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>
23 #include <asm/processor.h>
24 #include <asm/board.h>
25 #include <asm/machdep.h>
26 #include <asm/page.h>
28 #include "local_irq.h"
29 #include "ppc4xx_pic.h"
30 #include "time.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()
45 * Description:
46 * This routine...
48 * Input(s):
49 * r3 - Optional pointer to a board information structure.
50 * r4 - Optional pointer to the physical starting address of the init RAM
51 * disk.
52 * r5 - Optional pointer to the physical ending address of the init RAM
53 * disk.
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.
59 * Output(s):
60 * N/A
62 * Returns:
63 * N/A
66 void __init
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
72 * residual data area.
74 if (r3) {
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.
83 if (r4) {
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. */
91 if (r6) {
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;
104 ppc_md.init = NULL;
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;
124 #endif
126 return;
130 * Document me.
132 void __init
133 oak_setup_arch(void)
135 /* XXX - Implement me */
139 * int oak_setup_residual()
141 * Description:
142 * This routine pretty-prints the platform's internal CPU and bus clock
143 * frequencies into the buffer for usage in /proc/cpuinfo.
145 * Input(s):
146 * *buffer - Buffer into which CPU and bus clock frequencies are to be
147 * printed.
149 * Output(s):
150 * *buffer - Buffer with the CPU and bus clock frequencies.
152 * Returns:
153 * The number of bytes copied into 'buffer' if OK, otherwise zero or less
154 * on error.
157 oak_setup_residual(char *buffer)
159 int len = 0;
160 bd_t *bp = (bd_t *)__res;
162 len += sprintf(len + buffer,
163 "clock\t\t: %dMHz\n"
164 "bus clock\t\t: %dMHz\n",
165 bp->bi_intfreq / 1000000,
166 bp->bi_busfreq / 1000000);
168 return (len);
172 * Document me.
174 void __init
175 oak_init_IRQ(void)
177 int i;
179 ppc4xx_pic_init();
181 for (i = 0; i < NR_IRQS; i++) {
182 irq_desc[i].handler = ppc4xx_pic;
185 return;
189 * Document me.
192 oak_get_irq(struct pt_regs *regs)
194 return (ppc4xx_pic_get_irq(regs));
198 * Document me.
200 void
201 oak_restart(char *cmd)
203 abort();
207 * Document me.
209 void
210 oak_power_off(void)
212 oak_restart(NULL);
216 * Document me.
218 void
219 oak_halt(void)
221 oak_restart(NULL);
225 * Document me.
227 void __init
228 oak_time_init(void)
230 /* XXX - Implement me */
234 * Document me.
236 int __init
237 oak_set_rtc_time(unsigned long time)
239 /* XXX - Implement me */
241 return (0);
245 * Document me.
247 unsigned long __init
248 oak_get_rtc_time(void)
250 /* XXX - Implement me */
252 return (0);
256 * void __init oak_calibrate_decr()
258 * Description:
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.
264 * Input(s):
265 * N/A
267 * Output(s):
268 * N/A
270 * Returns:
271 * N/A
274 void __init
275 oak_calibrate_decr(void)
277 unsigned int freq;
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);