3 * Copyright (c) 1999-2000 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/param.h>
20 #include <linux/string.h>
21 #include <linux/blk.h>
22 #include <linux/irq.h>
23 #include <linux/seq_file.h>
25 #include <asm/processor.h>
26 #include <asm/board.h>
27 #include <asm/machdep.h>
29 #include <asm/bootinfo.h>
30 #include <asm/ppc4xx_pic.h>
33 #include "oak_setup.h"
35 /* Function Prototypes */
37 extern void abort(void);
39 /* Global Variables */
41 unsigned char __res[sizeof(bd_t)];
45 * void __init oak_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 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
70 unsigned long r6, unsigned long r7)
72 parse_bootinfo(find_bootinfo());
75 * If we were passed in a board information, copy it into the
79 memcpy((void *)__res, (void *)(r3 + KERNELBASE), sizeof(bd_t));
82 #if defined(CONFIG_BLK_DEV_INITRD)
84 * If the init RAM disk has been configured in, and there's a valid
85 * starting address for it, set it up.
88 initrd_start = r4 + KERNELBASE;
89 initrd_end = r5 + KERNELBASE;
91 #endif /* CONFIG_BLK_DEV_INITRD */
93 /* Copy the kernel command line arguments to a safe place. */
96 *(char *)(r7 + KERNELBASE) = 0;
97 strcpy(cmd_line, (char *)(r6 + KERNELBASE));
100 /* Initialize machine-dependency vectors */
102 ppc_md.setup_arch = oak_setup_arch;
103 ppc_md.show_percpuinfo = oak_show_percpuinfo;
104 ppc_md.irq_cannonicalize = NULL;
105 ppc_md.init_IRQ = oak_init_IRQ;
106 ppc_md.get_irq = oak_get_irq;
109 ppc_md.restart = oak_restart;
110 ppc_md.power_off = oak_power_off;
111 ppc_md.halt = oak_halt;
113 ppc_md.time_init = oak_time_init;
114 ppc_md.set_rtc_time = oak_set_rtc_time;
115 ppc_md.get_rtc_time = oak_get_rtc_time;
116 ppc_md.calibrate_decr = oak_calibrate_decr;
118 ppc_md.kbd_setkeycode = NULL;
119 ppc_md.kbd_getkeycode = NULL;
120 ppc_md.kbd_translate = NULL;
121 ppc_md.kbd_unexpected_up = NULL;
122 ppc_md.kbd_leds = NULL;
123 ppc_md.kbd_init_hw = NULL;
124 ppc_md.ppc_kbd_sysrq_xlate = NULL;
133 /* XXX - Implement me */
137 * int oak_show_percpuinfo()
140 * This routine pretty-prints the platform's internal CPU and bus clock
141 * frequencies into the buffer for usage in /proc/cpuinfo.
144 * *buffer - Buffer into which CPU and bus clock frequencies are to be
148 * *buffer - Buffer with the CPU and bus clock frequencies.
151 * The number of bytes copied into 'buffer' if OK, otherwise zero or less
155 oak_show_percpuinfo(struct seq_file *m, int i)
157 bd_t *bp = (bd_t *)__res;
159 seq_printf(m, "clock\t\t: %dMHz\n"
160 "bus clock\t\t: %dMHz\n",
161 bp->bi_intfreq / 1000000,
162 bp->bi_busfreq / 1000000);
177 for (i = 0; i < NR_IRQS; i++) {
178 irq_desc[i].handler = ppc4xx_pic;
188 oak_get_irq(struct pt_regs *regs)
190 return (ppc4xx_pic_get_irq(regs));
197 oak_restart(char *cmd)
226 /* XXX - Implement me */
234 oak_set_rtc_time(unsigned long time)
236 /* XXX - Implement me */
245 oak_get_rtc_time(void)
247 /* XXX - Implement me */
253 * void __init oak_calibrate_decr()
256 * This routine retrieves the internal processor frequency from the board
257 * information structure, sets up the kernel timer decrementer based on
258 * that value, enables the 403 programmable interval timer (PIT) and sets
259 * it up for auto-reload.
272 oak_calibrate_decr(void)
275 bd_t *bip = (bd_t *)__res;
277 freq = bip->bi_intfreq;
279 decrementer_count = freq / HZ;
280 count_period_num = 1;
281 count_period_den = freq;
283 /* Enable the PIT and set auto-reload of its value */
285 mtspr(SPRN_TCR, TCR_PIE | TCR_ARE);
287 /* Clear any pending timer interrupts */
289 mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_PIS | TSR_FIS);