port enough sendpoint support for DSM-G600 from D-Link 2.4.21-pre4
[linux-2.4.git] / arch / ppc / platforms / pal4_setup.c
1 /*
2  * arch/ppc/platforms/pal4_setup.c
3  *
4  * Board setup routines for the SBS PalomarIV.
5  *
6  * Author: Dan Cox
7  *
8  * 2002 (c) MontaVista, Software, Inc.  This file is licensed under
9  * the terms of the GNU General Public License version 2.  This program
10  * is licensed "as is" without any warranty of any kind, whether express
11  * or implied.
12  */
13
14 #include <linux/config.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/types.h>
18 #include <linux/errno.h>
19 #include <linux/reboot.h>
20 #include <linux/time.h>
21 #include <linux/irq.h>
22 #include <linux/kdev_t.h>
23 #include <linux/blk.h>
24 #include <linux/console.h>
25 #include <linux/seq_file.h>
26
27 #include <asm/todc.h>
28 #include <asm/bootinfo.h>
29
30 #include "cpc700.h"
31 #include "pal4.h"
32
33 extern void pal4_find_bridges(void);
34
35 unsigned int cpc700_irq_assigns[][2] = {
36         {1, 1},    /* IRQ 0: ECC correctable error */
37         {1, 1},    /* IRQ 1: PCI write to memory range */
38         {0, 1},    /* IRQ 2: PCI write to command register */
39         {0, 1},    /* IRQ 3: UART 0 */
40         {0, 1},    /* IRQ 4: UART 1 */
41         {0, 1},    /* IRQ 5: ICC 0 */
42         {0, 1},    /* IRQ 6: ICC 1 */
43         {0, 1},    /* IRQ 7: GPT compare 0 */
44         {0, 1},    /* IRQ 8: GPT compare 1 */
45         {0, 1},    /* IRQ 9: GPT compare 2 */
46         {0, 1},    /* IRQ 10: GPT compare 3 */
47         {0, 1},    /* IRQ 11: GPT compare 4 */
48         {0, 1},    /* IRQ 12: GPT capture 0 */
49         {0, 1},    /* IRQ 13: GPT capture 1 */
50         {0, 1},    /* IRQ 14: GPT capture 2 */
51         {0, 1},    /* IRQ 15: GPT capture 3 */
52         {0, 1},    /* IRQ 16: GPT capture 4 */
53         {0, 0},    /* IRQ 17: reserved */
54         {0, 0},    /* IRQ 18: reserved */
55         {0, 0},    /* IRQ 19: reserved */
56         {0, 0},    /* IRQ 20: reserved */
57         {0, 1},    /* IRQ 21: Ethernet */
58         {0, 0},    /* IRQ 22: reserved */
59         {0, 0},    /* IRQ 23: reserved */
60         {0, 0},    /* IRQ 24: resreved */
61         {0, 0},    /* IRQ 25: reserved */
62         {0, 0},    /* IRQ 26: reserved */
63         {0, 0},    /* IRQ 27: reserved */
64         {0, 0},    /* IRQ 28: reserved */
65         {0, 0},    /* IRQ 29: reserved */
66         {0, 0},    /* IRQ 30: reserved */
67         {0, 0},    /* IRQ 31: reserved */
68 };
69
70 static int
71 pal4_show_cpuinfo(struct seq_file *m)
72 {
73         seq_printf(m, "board\t\t: SBS Palomar IV\n");
74
75         return 0;
76 }
77
78 static void
79 pal4_restart(char *cmd)
80 {
81         __cli();
82         __asm__ __volatile__("lis  3,0xfff0\n \
83                               ori  3,3,0x100\n \
84                               mtspr 26,3\n \
85                               li   3,0\n \
86                               mtspr 27,3\n \
87                               rfi");
88
89         for(;;);
90 }
91
92 static void
93 pal4_power_off(void)
94 {
95         __cli();
96         for(;;);
97 }
98
99 static void
100 pal4_halt(void)
101 {
102         pal4_power_off();
103 }
104
105 static unsigned long __init
106 pal4_find_end_of_memory(void)
107 {
108         int i;
109         unsigned long len, amt, batu, batl;
110
111         __asm__ __volatile__("lis  %0,0xf000\n \
112                               ori  %1,%0,0x002a\n \
113                               ori  %0,%0,0x1ffe\n \
114                               mtspr 0x21e,%0\n \
115                               mtspr 0x21f,%1\n \
116                               isync\n \
117                               sync" : "=r" (batu), "=r" (batl));
118
119         for(len = 0, i = CPC700_MB1EA; i <= CPC700_MB4EA; i+=4) {
120                 amt = cpc700_read_memreg(i);
121                 if (amt == 0)
122                         break;
123                 len = amt;
124         }
125
126         return len;
127 }
128
129 TODC_ALLOC();
130
131 static void __init
132 pal4_setup_arch(void)
133 {
134         unsigned long l2;
135
136         TODC_INIT(TODC_TYPE_MK48T37, 0, 0,
137                   ioremap(PAL4_NVRAM, PAL4_NVRAM_SIZE), 8);
138
139         pal4_find_bridges();
140
141 #ifdef CONFIG_BLK_DEV_INITRD
142         if (initrd_start)
143                 ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
144         else
145 #endif
146                 ROOT_DEV = to_kdev_t(0x00ff);
147
148         /* The L2 gets disabled in the bootloader, but all the proper
149            bits should be present from the fw, so just re-enable it */
150         l2 = _get_L2CR();
151         if (!(l2 & L2CR_L2E)) {
152                 /* presume that it was initially set if the size is
153                    still present. */
154                 if (l2 ^ L2CR_L2SIZ_MASK)
155                         _set_L2CR(l2 | L2CR_L2E);
156                 else
157                         printk("L2 not set by firmware; left disabled.\n");
158         }
159 }
160
161 static void __init
162 pal4_map_io(void)
163 {
164         io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
165 }
166
167 void __init
168 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
169               unsigned long r6, unsigned long r7)
170 {
171         parse_bootinfo(find_bootinfo());
172
173         isa_io_base = 0 /*PAL4_ISA_IO_BASE*/;
174         pci_dram_offset = 0 /*PAL4_PCI_SYS_MEM_BASE*/;
175
176         ppc_md.setup_arch = pal4_setup_arch;
177         ppc_md.show_cpuinfo = pal4_show_cpuinfo;
178
179         ppc_md.find_end_of_memory = pal4_find_end_of_memory;
180         ppc_md.setup_io_mappings = pal4_map_io;
181
182         ppc_md.init_IRQ = cpc700_init_IRQ;
183         ppc_md.get_irq = cpc700_get_irq;
184
185         ppc_md.restart = pal4_restart;
186         ppc_md.halt = pal4_halt;
187         ppc_md.power_off = pal4_power_off;
188
189         ppc_md.time_init = todc_time_init;
190         ppc_md.set_rtc_time = todc_set_rtc_time;
191         ppc_md.get_rtc_time = todc_get_rtc_time;
192         ppc_md.calibrate_decr = todc_calibrate_decr;
193
194         ppc_md.nvram_read_val = todc_direct_read_val;
195         ppc_md.nvram_write_val = todc_direct_write_val;
196 }
197