fix to allow usb modules to compile
[linux-2.4.21-pre4.git] / arch / ppc / platforms / adir_setup.c
1 /*
2  * arch/ppc/platforms/adir_setup.c
3  *
4  * Board setup routines for SBS Adirondack
5  *
6  * By Michael Sokolov <msokolov@ivan.Harhan.ORG>
7  * based on the K2 version by Matt Porter <mporter@mvista.com>
8  */
9
10 #include <linux/config.h>
11 #include <linux/stddef.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/errno.h>
15 #include <linux/reboot.h>
16 #include <linux/pci.h>
17 #include <linux/kdev_t.h>
18 #include <linux/types.h>
19 #include <linux/major.h>
20 #include <linux/blk.h>
21 #include <linux/console.h>
22 #include <linux/delay.h>
23 #include <linux/ide.h>
24 #include <linux/seq_file.h>
25
26 #include <asm/system.h>
27 #include <asm/pgtable.h>
28 #include <asm/page.h>
29 #include <asm/dma.h>
30 #include <asm/io.h>
31 #include <asm/machdep.h>
32 #include <asm/time.h>
33 #include <asm/todc.h>
34 #include <asm/bootinfo.h>
35
36 #include "adir.h"
37
38 extern void adir_init_IRQ(void);
39 extern int adir_get_irq(struct pt_regs *);
40 extern void adir_find_bridges(void);
41 extern unsigned long loops_per_jiffy;
42
43 static unsigned int cpu_750cx[16] = {
44         5, 15, 14, 0, 4, 13, 0, 9, 6, 11, 8, 10, 16, 12, 7, 0
45 };
46
47 static int
48 adir_get_bus_speed(void)
49 {
50         if (!(*((u_char *) ADIR_CLOCK_REG) & ADIR_CLOCK_REG_SEL133))
51                 return 100000000;
52         else
53                 return 133333333;
54 }
55
56 static int
57 adir_get_cpu_speed(void)
58 {
59         unsigned long hid1;
60         int cpu_speed;
61
62         hid1 = mfspr(HID1) >> 28;
63
64         hid1 = cpu_750cx[hid1];
65
66         cpu_speed = adir_get_bus_speed()*hid1/2;
67         return cpu_speed;
68 }
69
70 static void __init
71 adir_calibrate_decr(void)
72 {
73         int freq, divisor = 4;
74
75         /* determine processor bus speed */
76         freq = adir_get_bus_speed();
77         tb_ticks_per_jiffy = freq / HZ / divisor;
78         tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
79 }
80
81 static int
82 adir_show_cpuinfo(struct seq_file *m)
83 {
84         seq_printf(m, "vendor\t\t: SBS\n");
85         seq_printf(m, "machine\t\t: Adirondack\n");
86         seq_printf(m, "cpu speed\t: %dMhz\n", adir_get_cpu_speed()/1000000);
87         seq_printf(m, "bus speed\t: %dMhz\n", adir_get_bus_speed()/1000000);
88         seq_printf(m, "memory type\t: SDRAM\n");
89
90         return 0;
91 }
92
93 extern char cmd_line[];
94
95 TODC_ALLOC();
96
97 static void __init
98 adir_setup_arch(void)
99 {
100         unsigned int cpu;
101
102         /* Setup TODC access */
103         TODC_INIT(TODC_TYPE_MC146818, ADIR_NVRAM_RTC_ADDR, 0,
104                   ADIR_NVRAM_RTC_DATA, 8);
105
106         /* init to some ~sane value until calibrate_delay() runs */
107         loops_per_jiffy = 50000000/HZ;
108
109        /* Setup PCI host bridges */
110         adir_find_bridges();
111
112 #ifdef CONFIG_BLK_DEV_INITRD
113         if (initrd_start)
114                 ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); /* /dev/ram */
115         else
116 #endif
117 #ifdef CONFIG_ROOT_NFS
118                 ROOT_DEV = to_kdev_t(0x00FF);   /* /dev/nfs pseudo device */
119 #else
120                 ROOT_DEV = to_kdev_t(0x0801);   /* /dev/sda1 */
121 #endif
122
123         /* Identify the system */
124         printk("System Identification: SBS Adirondack - PowerPC 750CXe @ %d Mhz\n", adir_get_cpu_speed()/1000000);
125         printk("SBS Adirondack port (C) 2001 SBS Technologies, Inc.\n");
126
127         /* Identify the CPU manufacturer */
128         cpu = mfspr(PVR);
129         printk("CPU manufacturer: IBM [rev=%04x]\n", (cpu & 0xffff));
130 }
131
132 static void
133 adir_restart(char *cmd)
134 {
135         __cli();
136         /* SRR0 has system reset vector, SRR1 has default MSR value */
137         /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
138         __asm__ __volatile__
139         ("lis   3,0xfff0\n\t"
140          "ori   3,3,0x0100\n\t"
141          "mtspr 26,3\n\t"
142          "li    3,0\n\t"
143          "mtspr 27,3\n\t"
144          "rfi\n\t");
145         for(;;);
146 }
147
148 static void
149 adir_power_off(void)
150 {
151         for(;;);
152 }
153
154 static void
155 adir_halt(void)
156 {
157         adir_restart(NULL);
158 }
159
160 static unsigned long __init
161 adir_find_end_of_memory(void)
162 {
163         return boot_mem_size;
164 }
165
166 static void __init
167 adir_map_io(void)
168 {
169         io_block_mapping(ADIR_PCI32_VIRT_IO_BASE, ADIR_PCI32_IO_BASE,
170                                 ADIR_PCI32_VIRT_IO_SIZE, _PAGE_IO);
171         io_block_mapping(ADIR_PCI64_VIRT_IO_BASE, ADIR_PCI64_IO_BASE,
172                                 ADIR_PCI64_VIRT_IO_SIZE, _PAGE_IO);
173 }
174
175 void __init
176 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
177               unsigned long r6, unsigned long r7)
178 {
179         /*
180          * On the Adirondack we use bi_recs and pass the pointer to them in R3.
181          */
182         parse_bootinfo((struct bi_record *) (r3 + KERNELBASE));
183
184         /* Remember, isa_io_base is virtual but isa_mem_base is physical! */
185         isa_io_base = ADIR_PCI32_VIRT_IO_BASE;
186         isa_mem_base = ADIR_PCI32_MEM_BASE;
187         pci_dram_offset = ADIR_PCI_SYS_MEM_BASE;
188
189         ppc_md.setup_arch = adir_setup_arch;
190         ppc_md.show_cpuinfo = adir_show_cpuinfo;
191         ppc_md.irq_cannonicalize = NULL;
192         ppc_md.init_IRQ = adir_init_IRQ;
193         ppc_md.get_irq = adir_get_irq;
194         ppc_md.init = NULL;
195
196         ppc_md.find_end_of_memory = adir_find_end_of_memory;
197         ppc_md.setup_io_mappings = adir_map_io;
198
199         ppc_md.restart = adir_restart;
200         ppc_md.power_off = adir_power_off;
201         ppc_md.halt = adir_halt;
202
203         ppc_md.time_init = todc_time_init;
204         ppc_md.set_rtc_time = todc_set_rtc_time;
205         ppc_md.get_rtc_time = todc_get_rtc_time;
206         ppc_md.nvram_read_val = todc_mc146818_read_val;
207         ppc_md.nvram_write_val = todc_mc146818_write_val;
208         ppc_md.calibrate_decr = adir_calibrate_decr;
209 }