2 * BK Id: SCCS/s.m8260_setup.c 1.39 09/26/02 22:14:34 paulus
5 * linux/arch/ppc/kernel/setup.c
7 * Copyright (C) 1995 Linus Torvalds
8 * Adapted from 'alpha' version by Gary Thomas
9 * Modified by Cort Dougan (cort@cs.nmt.edu)
10 * Modified for MBX using prep/chrp/pmac functions by Dan (dmalek@jlc.net)
11 * Further modified for generic 8xx and 8260 by Dan.
15 * bootup setup stuff..
18 #include <linux/config.h>
19 #include <linux/errno.h>
20 #include <linux/sched.h>
21 #include <linux/kernel.h>
23 #include <linux/stddef.h>
24 #include <linux/unistd.h>
25 #include <linux/ptrace.h>
26 #include <linux/slab.h>
27 #include <linux/user.h>
28 #include <linux/a.out.h>
29 #include <linux/tty.h>
30 #include <linux/major.h>
31 #include <linux/interrupt.h>
32 #include <linux/reboot.h>
33 #include <linux/init.h>
34 #include <linux/blk.h>
35 #include <linux/ioport.h>
36 #include <linux/ide.h>
37 #include <linux/seq_file.h>
40 #include <asm/processor.h>
41 #include <asm/residual.h>
43 #include <asm/pgtable.h>
45 #include <asm/mpc8260.h>
46 #include <asm/immap_8260.h>
47 #include <asm/machdep.h>
48 #include <asm/bootinfo.h>
51 #include "ppc8260_pic.h"
53 static int m8260_set_rtc_time(unsigned long time);
54 static unsigned long m8260_get_rtc_time(void);
55 static void m8260_calibrate_decr(void);
57 unsigned char __res[sizeof(bd_t)];
59 extern void m8260_cpm_reset(void);
62 m8260_setup_arch(void)
64 /* Reset the Communication Processor Module.
73 extern void xmon(void *);
76 machine_restart(NULL);
79 /* The decrementer counts at the system (internal) clock frequency
83 m8260_calibrate_decr(void)
85 bd_t *binfo = (bd_t *)__res;
88 freq = binfo->bi_busfreq;
90 tb_ticks_per_jiffy = freq / HZ / divisor;
91 tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
94 /* The 8260 has an internal 1-second timer update register that
95 * we should use for this purpose.
100 m8260_set_rtc_time(unsigned long time)
102 #ifdef CONFIG_TQM8260
103 ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcnt = time;
104 ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcntsc = 0x3;
112 m8260_get_rtc_time(void)
114 #ifdef CONFIG_TQM8260
115 return ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcnt;
117 /* Get time from the RTC.
119 return((unsigned long)rtc_time);
124 m8260_restart(char *cmd)
126 extern void m8260_gorom(bd_t *bi, uint addr);
129 /* Most boot roms have a warmstart as the second instruction
130 * of the reset vector. If that doesn't work for you, change this
131 * or the reboot program to send a proper address.
133 #ifdef CONFIG_TQM8260
134 startaddr = 0x40000104;
136 startaddr = 0xff000104;
139 if (!strncmp(cmd, "startaddr=", 10))
140 startaddr = simple_strtoul(&cmd[10], NULL, 0);
143 m8260_gorom((unsigned int)__pa(__res), startaddr);
147 m8260_power_off(void)
160 m8260_show_percpuinfo(struct seq_file *m, int i)
166 seq_printf(m, "core clock\t: %d MHz\n"
167 "CPM clock\t: %d MHz\n"
168 "bus clock\t: %d MHz\n",
169 bp->bi_intfreq / 1000000,
170 bp->bi_cpmfreq / 1000000,
171 bp->bi_busfreq / 1000000);
175 /* Initialize the internal interrupt controller. The number of
176 * interrupts supported can vary with the processor type, and the
177 * 8260 family can have up to 64.
178 * External interrupts can be either edge or level triggered, and
179 * need to be initialized by the appropriate driver.
185 void cpm_interrupt_init(void);
188 ppc8260_pic.irq_offset = 0;
190 for ( i = 0 ; i < NR_SIU_INTS ; i++ )
191 irq_desc[i].handler = &ppc8260_pic;
193 /* Initialize the default interrupt mapping priorities,
194 * in case the boot rom changed something on us.
196 immr->im_intctl.ic_sicr = 0;
197 immr->im_intctl.ic_siprr = 0x05309770;
198 immr->im_intctl.ic_scprrh = 0x05309770;
199 immr->im_intctl.ic_scprrl = 0x05309770;
206 static unsigned long __init
207 m8260_find_end_of_memory(void)
210 extern unsigned char __res[];
212 binfo = (bd_t *)__res;
214 return binfo->bi_memsize;
217 /* Map the IMMR, plus anything else we can cover
218 * in that upper space according to the memory controller
219 * chip select mapping. Grab another bunch of space
220 * below that for stuff we can't cover in the upper.
225 io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
226 io_block_mapping(0xe0000000, 0xe0000000, 0x10000000, _PAGE_IO);
230 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
231 unsigned long r6, unsigned long r7)
233 parse_bootinfo(find_bootinfo());
236 memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
238 #ifdef CONFIG_BLK_DEV_INITRD
239 /* take care of initrd if we have one */
241 initrd_start = r4 + KERNELBASE;
242 initrd_end = r5 + KERNELBASE;
244 #endif /* CONFIG_BLK_DEV_INITRD */
245 /* take care of cmd line */
247 *(char *)(r7+KERNELBASE) = 0;
248 strcpy(cmd_line, (char *)(r6+KERNELBASE));
251 ppc_md.setup_arch = m8260_setup_arch;
252 ppc_md.show_percpuinfo = m8260_show_percpuinfo;
253 ppc_md.irq_cannonicalize = NULL;
254 ppc_md.init_IRQ = m8260_init_IRQ;
255 ppc_md.get_irq = m8260_get_irq;
258 ppc_md.restart = m8260_restart;
259 ppc_md.power_off = m8260_power_off;
260 ppc_md.halt = m8260_halt;
262 ppc_md.time_init = NULL;
263 ppc_md.set_rtc_time = m8260_set_rtc_time;
264 ppc_md.get_rtc_time = m8260_get_rtc_time;
265 ppc_md.calibrate_decr = m8260_calibrate_decr;
267 ppc_md.find_end_of_memory = m8260_find_end_of_memory;
268 ppc_md.setup_io_mappings = m8260_map_io;
270 ppc_md.kbd_setkeycode = NULL;
271 ppc_md.kbd_getkeycode = NULL;
272 ppc_md.kbd_translate = NULL;
273 ppc_md.kbd_unexpected_up = NULL;
274 ppc_md.kbd_leds = NULL;
275 ppc_md.kbd_init_hw = NULL;
276 ppc_md.ppc_kbd_sysrq_xlate = NULL;
282 request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
283 unsigned long flag, const char *naem, void *dev)
285 panic("request IRQ\n");