fix to allow usb modules to compile
[linux-2.4.21-pre4.git] / arch / ppc / kernel / m8260_setup.c
1 /*
2  * BK Id: SCCS/s.m8260_setup.c 1.39 09/26/02 22:14:34 paulus
3  */
4 /*
5  *  linux/arch/ppc/kernel/setup.c
6  *
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.
12  */
13
14 /*
15  * bootup setup stuff..
16  */
17
18 #include <linux/config.h>
19 #include <linux/errno.h>
20 #include <linux/sched.h>
21 #include <linux/kernel.h>
22 #include <linux/mm.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>
38
39 #include <asm/mmu.h>
40 #include <asm/processor.h>
41 #include <asm/residual.h>
42 #include <asm/io.h>
43 #include <asm/pgtable.h>
44 #include <asm/ide.h>
45 #include <asm/mpc8260.h>
46 #include <asm/immap_8260.h>
47 #include <asm/machdep.h>
48 #include <asm/bootinfo.h>
49 #include <asm/time.h>
50
51 #include "ppc8260_pic.h"
52
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);
56
57 unsigned char __res[sizeof(bd_t)];
58
59 extern void m8260_cpm_reset(void);
60
61 static void __init
62 m8260_setup_arch(void)
63 {
64         /* Reset the Communication Processor Module.
65         */
66         m8260_cpm_reset();
67 }
68
69 static void
70 abort(void)
71 {
72 #ifdef CONFIG_XMON
73         extern void xmon(void *);
74         xmon(0);
75 #endif
76         machine_restart(NULL);
77 }
78
79 /* The decrementer counts at the system (internal) clock frequency
80  * divided by four.
81  */
82 static void __init
83 m8260_calibrate_decr(void)
84 {
85         bd_t    *binfo = (bd_t *)__res;
86         int freq, divisor;
87
88         freq = binfo->bi_busfreq;
89         divisor = 4;
90         tb_ticks_per_jiffy = freq / HZ / divisor;
91         tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
92 }
93
94 /* The 8260 has an internal 1-second timer update register that
95  * we should use for this purpose.
96  */
97 static uint rtc_time;
98
99 static static int
100 m8260_set_rtc_time(unsigned long time)
101 {
102 #ifdef CONFIG_TQM8260
103         ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcnt = time;
104         ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcntsc = 0x3;
105 #else
106         rtc_time = time;
107 #endif
108         return(0);
109 }
110
111 static unsigned long
112 m8260_get_rtc_time(void)
113 {
114 #ifdef CONFIG_TQM8260
115         return ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcnt;
116 #else
117         /* Get time from the RTC.
118         */
119         return((unsigned long)rtc_time);
120 #endif
121 }
122
123 static void
124 m8260_restart(char *cmd)
125 {
126         extern void m8260_gorom(bd_t *bi, uint addr);
127         uint    startaddr;
128
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.
132          */
133 #ifdef CONFIG_TQM8260
134         startaddr = 0x40000104;
135 #else
136         startaddr = 0xff000104;
137 #endif
138         if (cmd != NULL) {
139                 if (!strncmp(cmd, "startaddr=", 10))
140                         startaddr = simple_strtoul(&cmd[10], NULL, 0);
141         }
142
143         m8260_gorom((unsigned int)__pa(__res), startaddr);
144 }
145
146 static void
147 m8260_power_off(void)
148 {
149    m8260_restart(NULL);
150 }
151
152 static void
153 m8260_halt(void)
154 {
155    m8260_restart(NULL);
156 }
157
158
159 static int
160 m8260_show_percpuinfo(struct seq_file *m, int i)
161 {
162         bd_t    *bp;
163
164         bp = (bd_t *)__res;
165
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);
172         return 0;
173 }
174
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.
180  */
181 static void __init
182 m8260_init_IRQ(void)
183 {
184         int i;
185         void cpm_interrupt_init(void);
186
187 #if 0
188         ppc8260_pic.irq_offset = 0;
189 #endif
190         for ( i = 0 ; i < NR_SIU_INTS ; i++ )
191                 irq_desc[i].handler = &ppc8260_pic;
192
193         /* Initialize the default interrupt mapping priorities,
194          * in case the boot rom changed something on us.
195          */
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;
200
201 }
202
203 /*
204  * Same hack as 8xx
205  */
206 static unsigned long __init
207 m8260_find_end_of_memory(void)
208 {
209         bd_t    *binfo;
210         extern unsigned char __res[];
211
212         binfo = (bd_t *)__res;
213
214         return binfo->bi_memsize;
215 }
216
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.
221  */
222 static void __init
223 m8260_map_io(void)
224 {
225         io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
226         io_block_mapping(0xe0000000, 0xe0000000, 0x10000000, _PAGE_IO);
227 }
228
229 void __init
230 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
231               unsigned long r6, unsigned long r7)
232 {
233         parse_bootinfo(find_bootinfo());
234
235         if ( r3 )
236                 memcpy( (void *)__res,(void *)(r3+KERNELBASE), sizeof(bd_t) );
237
238 #ifdef CONFIG_BLK_DEV_INITRD
239         /* take care of initrd if we have one */
240         if ( r4 ) {
241                 initrd_start = r4 + KERNELBASE;
242                 initrd_end = r5 + KERNELBASE;
243         }
244 #endif /* CONFIG_BLK_DEV_INITRD */
245         /* take care of cmd line */
246         if ( r6 ) {
247                 *(char *)(r7+KERNELBASE) = 0;
248                 strcpy(cmd_line, (char *)(r6+KERNELBASE));
249         }
250
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;
256         ppc_md.init                     = NULL;
257
258         ppc_md.restart                  = m8260_restart;
259         ppc_md.power_off                = m8260_power_off;
260         ppc_md.halt                     = m8260_halt;
261
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;
266
267         ppc_md.find_end_of_memory       = m8260_find_end_of_memory;
268         ppc_md.setup_io_mappings        = m8260_map_io;
269
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;
277 }
278
279 /* Mainly for ksyms.
280 */
281 int
282 request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
283                        unsigned long flag, const char *naem, void *dev)
284 {
285         panic("request IRQ\n");
286 }