2 * $Id: m8xx_setup.c,v 1.4 1999/09/18 18:40:36 dmalek Exp $
4 * linux/arch/ppc/kernel/setup.c
6 * Copyright (C) 1995 Linus Torvalds
7 * Adapted from 'alpha' version by Gary Thomas
8 * Modified by Cort Dougan (cort@cs.nmt.edu)
9 * Modified for MBX using prep/chrp/pmac functions by Dan (dmalek@jlc.net)
10 * Further modified for generic 8xx and 8260 by Dan.
14 * bootup setup stuff..
17 #include <linux/config.h>
18 #include <linux/errno.h>
19 #include <linux/sched.h>
20 #include <linux/kernel.h>
22 #include <linux/stddef.h>
23 #include <linux/unistd.h>
24 #include <linux/ptrace.h>
25 #include <linux/malloc.h>
26 #include <linux/user.h>
27 #include <linux/a.out.h>
28 #include <linux/tty.h>
29 #include <linux/major.h>
30 #include <linux/interrupt.h>
31 #include <linux/reboot.h>
32 #include <linux/init.h>
33 #include <linux/blk.h>
34 #include <linux/ioport.h>
35 #include <linux/ide.h>
38 #include <asm/processor.h>
39 #include <asm/residual.h>
41 #include <asm/pgtable.h>
43 #include <asm/mpc8260.h>
44 #include <asm/immap_8260.h>
45 #include <asm/machdep.h>
48 #include "ppc8260_pic.h"
50 static int m8260_set_rtc_time(unsigned long time
);
51 unsigned long m8260_get_rtc_time(void);
52 void m8260_calibrate_decr(void);
55 extern int mackbd_setkeycode(unsigned int scancode
, unsigned int keycode
);
56 extern int mackbd_getkeycode(unsigned int scancode
);
57 extern int mackbd_pretranslate(unsigned char scancode
, char raw_mode
);
58 extern int mackbd_translate(unsigned char scancode
, unsigned char *keycode
,
60 extern char mackbd_unexpected_up(unsigned char keycode
);
61 extern void mackbd_leds(unsigned char leds
);
62 extern void mackbd_init_hw(void);
65 extern unsigned long loops_per_sec
;
67 unsigned char __res
[sizeof(bd_t
)];
68 unsigned long empty_zero_page
[1024];
70 #ifdef CONFIG_BLK_DEV_RAM
71 extern int rd_doload
; /* 1 = load ramdisk, 0 = don't load */
72 extern int rd_prompt
; /* 1 = prompt for ramdisk, 0 = don't prompt */
73 extern int rd_image_start
; /* starting block # of image */
76 extern char saved_command_line
[256];
78 extern unsigned long find_available_memory(void);
79 extern void m8260_cpm_reset(void);
81 void __init
adbdev_init(void)
86 m8260_setup_arch(void)
88 extern char cmd_line
[];
90 printk("Boot arguments: %s\n", cmd_line
);
92 /* Reset the Communication Processor Module.
101 extern void xmon(void *);
104 machine_restart(NULL
);
107 /* The decrementer counts at the system (internal) clock frequency
110 void __init
m8260_calibrate_decr(void)
112 bd_t
*binfo
= (bd_t
*)__res
;
115 freq
= (binfo
->bi_busfreq
* 1000000);
117 tb_ticks_per_jiffy
= freq
/ HZ
/ divisor
;
118 tb_to_us
= mulhwu_scale_factor(freq
/ divisor
, 1000000);
121 /* The 8260 has an internal 1-second timer update register that
122 * we should use for this purpose.
124 static uint rtc_time
;
126 m8260_set_rtc_time(unsigned long time
)
133 m8260_get_rtc_time(void)
136 /* Get time from the RTC.
138 return((unsigned long)rtc_time
);
142 m8260_restart(char *cmd
)
144 extern void m8260_gorom(bd_t
*bi
, uint addr
);
147 /* Most boot roms have a warmstart as the second instruction
148 * of the reset vector. If that doesn't work for you, change this
149 * or the reboot program to send a proper address.
151 startaddr
= 0xff000104;
154 if (!strncmp(cmd
, "startaddr=", 10))
155 startaddr
= simple_strtoul(&cmd
[10], NULL
, 0);
158 m8260_gorom((uint
)__pa(__res
), startaddr
);
162 m8260_power_off(void)
174 int m8260_setup_residual(char *buffer
)
181 len
+= sprintf(len
+buffer
,"core clock\t: %d MHz\n"
182 "CPM clock\t: %d MHz\n"
183 "bus clock\t: %d MHz\n",
184 bp
->bi_intfreq
/*/ 1000000*/,
185 bp
->bi_cpmfreq
/*/ 1000000*/,
186 bp
->bi_busfreq
/*/ 1000000*/);
191 /* Initialize the internal interrupt controller. The number of
192 * interrupts supported can vary with the processor type, and the
193 * 8260 family can have up to 64.
194 * External interrupts can be either edge or level triggered, and
195 * need to be initialized by the appropriate driver.
201 void cpm_interrupt_init(void);
204 ppc8260_pic
.irq_offset
= 0;
206 for ( i
= 0 ; i
< NR_SIU_INTS
; i
++ )
207 irq_desc
[i
].handler
= &ppc8260_pic
;
209 /* Initialize the default interrupt mapping priorities,
210 * in case the boot rom changed something on us.
212 immr
->im_intctl
.ic_sicr
= 0;
213 immr
->im_intctl
.ic_siprr
= 0x05309770;
214 immr
->im_intctl
.ic_scprrh
= 0x05309770;
215 immr
->im_intctl
.ic_scprrl
= 0x05309770;
221 m8260_init(unsigned long r3
, unsigned long r4
, unsigned long r5
,
222 unsigned long r6
, unsigned long r7
)
226 memcpy( (void *)__res
,(void *)(r3
+KERNELBASE
), sizeof(bd_t
) );
228 #ifdef CONFIG_BLK_DEV_INITRD
229 /* take care of initrd if we have one */
232 initrd_start
= r4
+ KERNELBASE
;
233 initrd_end
= r5
+ KERNELBASE
;
235 #endif /* CONFIG_BLK_DEV_INITRD */
236 /* take care of cmd line */
240 *(char *)(r7
+KERNELBASE
) = 0;
241 strcpy(cmd_line
, (char *)(r6
+KERNELBASE
));
244 ppc_md
.setup_arch
= m8260_setup_arch
;
245 ppc_md
.setup_residual
= m8260_setup_residual
;
246 ppc_md
.get_cpuinfo
= NULL
;
247 ppc_md
.irq_cannonicalize
= NULL
;
248 ppc_md
.init_IRQ
= m8260_init_IRQ
;
249 ppc_md
.get_irq
= m8260_get_irq
;
252 ppc_md
.restart
= m8260_restart
;
253 ppc_md
.power_off
= m8260_power_off
;
254 ppc_md
.halt
= m8260_halt
;
256 ppc_md
.time_init
= NULL
;
257 ppc_md
.set_rtc_time
= m8260_set_rtc_time
;
258 ppc_md
.get_rtc_time
= m8260_get_rtc_time
;
259 ppc_md
.calibrate_decr
= m8260_calibrate_decr
;
262 ppc_md
.kbd_setkeycode
= pckbd_setkeycode
;
263 ppc_md
.kbd_getkeycode
= pckbd_getkeycode
;
264 ppc_md
.kbd_pretranslate
= pckbd_pretranslate
;
265 ppc_md
.kbd_translate
= pckbd_translate
;
266 ppc_md
.kbd_unexpected_up
= pckbd_unexpected_up
;
267 ppc_md
.kbd_leds
= pckbd_leds
;
268 ppc_md
.kbd_init_hw
= pckbd_init_hw
;
269 #ifdef CONFIG_MAGIC_SYSRQ
270 ppc_md
.kbd_sysrq_xlate
= pckbd_sysrq_xlate
;
273 ppc_md
.kbd_setkeycode
= NULL
;
274 ppc_md
.kbd_getkeycode
= NULL
;
275 ppc_md
.kbd_translate
= NULL
;
276 ppc_md
.kbd_unexpected_up
= NULL
;
277 ppc_md
.kbd_leds
= NULL
;
278 ppc_md
.kbd_init_hw
= NULL
;
279 #ifdef CONFIG_MAGIC_SYSRQ
280 ppc_md
.kbd_sysrq_xlate
= NULL
;
284 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
285 ppc_ide_md
.insw
= m8xx_ide_insw
;
286 ppc_ide_md
.outsw
= m8xx_ide_outsw
;
287 ppc_ide_md
.default_irq
= m8xx_ide_default_irq
;
288 ppc_ide_md
.default_io_base
= m8xx_ide_default_io_base
;
289 ppc_ide_md
.check_region
= m8xx_ide_check_region
;
290 ppc_ide_md
.request_region
= m8xx_ide_request_region
;
291 ppc_ide_md
.release_region
= m8xx_ide_release_region
;
292 ppc_ide_md
.fix_driveid
= m8xx_ide_fix_driveid
;
293 ppc_ide_md
.ide_init_hwif
= m8xx_ide_init_hwif_ports
;
294 ppc_ide_md
.ide_request_irq
= m8xx_ide_request_irq
;
296 ppc_ide_md
.io_base
= _IO_BASE
;
301 prom_init(uint r3
, uint r4
, uint r5
, uint r6
)
303 /* Nothing to do now, but we are called immediatedly upon
304 * kernel start up with MMU disabled, so if there is
305 * anything we need to do......
312 request_irq(unsigned int irq
, void (*handler
)(int, void *, struct pt_regs
*),
313 unsigned long flag
, const char *naem
, void *dev
)
315 panic("request IRQ\n");