]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/ppc/platforms/radstone_ppc7d.c
Create platform_device.h to contain all the platform device details.
[linux-2.6-omap-h63xx.git] / arch / ppc / platforms / radstone_ppc7d.c
1 /*
2  * arch/ppc/platforms/radstone_ppc7d.c
3  *
4  * Board setup routines for the Radstone PPC7D boards.
5  *
6  * Author: James Chapman <jchapman@katalix.com>
7  *
8  * Based on code done by Rabeeh Khoury - rabeeh@galileo.co.il
9  * Based on code done by - Mark A. Greer <mgreer@mvista.com>
10  *
11  * This program is free software; you can redistribute it and/or modify it
12  * under the terms of the GNU General Public License as published by the
13  * Free Software Foundation; either version 2 of the License, or (at your
14  * option) any later version.
15  */
16
17 /* Radstone PPC7D boards are rugged VME boards with PPC 7447A CPUs,
18  * Discovery-II, dual gigabit ethernet, dual PMC, USB, keyboard/mouse,
19  * 4 serial ports, 2 high speed serial ports (MPSCs) and optional
20  * SCSI / VGA.
21  */
22
23 #include <linux/config.h>
24 #include <linux/stddef.h>
25 #include <linux/kernel.h>
26 #include <linux/init.h>
27 #include <linux/errno.h>
28 #include <linux/reboot.h>
29 #include <linux/pci.h>
30 #include <linux/kdev_t.h>
31 #include <linux/major.h>
32 #include <linux/initrd.h>
33 #include <linux/console.h>
34 #include <linux/delay.h>
35 #include <linux/ide.h>
36 #include <linux/seq_file.h>
37 #include <linux/root_dev.h>
38 #include <linux/serial.h>
39 #include <linux/tty.h>          /* for linux/serial_core.h */
40 #include <linux/serial_core.h>
41 #include <linux/mv643xx.h>
42 #include <linux/netdevice.h>
43 #include <linux/platform_device.h>
44
45 #include <asm/system.h>
46 #include <asm/pgtable.h>
47 #include <asm/page.h>
48 #include <asm/time.h>
49 #include <asm/dma.h>
50 #include <asm/io.h>
51 #include <asm/machdep.h>
52 #include <asm/prom.h>
53 #include <asm/smp.h>
54 #include <asm/vga.h>
55 #include <asm/open_pic.h>
56 #include <asm/i8259.h>
57 #include <asm/todc.h>
58 #include <asm/bootinfo.h>
59 #include <asm/mpc10x.h>
60 #include <asm/pci-bridge.h>
61 #include <asm/mv64x60.h>
62
63 #include "radstone_ppc7d.h"
64
65 #undef DEBUG
66
67 #define PPC7D_RST_PIN                   17      /* GPP17 */
68
69 extern u32 mv64360_irq_base;
70 extern spinlock_t rtc_lock;
71
72 static struct mv64x60_handle bh;
73 static int ppc7d_has_alma;
74
75 extern void gen550_progress(char *, unsigned short);
76 extern void gen550_init(int, struct uart_port *);
77
78 /* FIXME - move to h file */
79 extern int ds1337_do_command(int id, int cmd, void *arg);
80 #define DS1337_GET_DATE         0
81 #define DS1337_SET_DATE         1
82
83 /* residual data */
84 unsigned char __res[sizeof(bd_t)];
85
86 /*****************************************************************************
87  * Serial port code
88  *****************************************************************************/
89
90 #if defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG)
91 static void __init ppc7d_early_serial_map(void)
92 {
93 #if defined(CONFIG_SERIAL_MPSC_CONSOLE)
94         mv64x60_progress_init(CONFIG_MV64X60_NEW_BASE);
95 #elif defined(CONFIG_SERIAL_8250)
96         struct uart_port serial_req;
97
98         /* Setup serial port access */
99         memset(&serial_req, 0, sizeof(serial_req));
100         serial_req.uartclk = UART_CLK;
101         serial_req.irq = 4;
102         serial_req.flags = STD_COM_FLAGS;
103         serial_req.iotype = SERIAL_IO_MEM;
104         serial_req.membase = (u_char *) PPC7D_SERIAL_0;
105
106         gen550_init(0, &serial_req);
107         if (early_serial_setup(&serial_req) != 0)
108                 printk(KERN_ERR "Early serial init of port 0 failed\n");
109
110         /* Assume early_serial_setup() doesn't modify serial_req */
111         serial_req.line = 1;
112         serial_req.irq = 3;
113         serial_req.membase = (u_char *) PPC7D_SERIAL_1;
114
115         gen550_init(1, &serial_req);
116         if (early_serial_setup(&serial_req) != 0)
117                 printk(KERN_ERR "Early serial init of port 1 failed\n");
118 #else
119 #error CONFIG_KGDB || CONFIG_SERIAL_TEXT_DEBUG has no supported CONFIG_SERIAL_XXX
120 #endif
121 }
122 #endif /* CONFIG_KGDB || CONFIG_SERIAL_TEXT_DEBUG */
123
124 /*****************************************************************************
125  * Low-level board support code
126  *****************************************************************************/
127
128 static unsigned long __init ppc7d_find_end_of_memory(void)
129 {
130         bd_t *bp = (bd_t *) __res;
131
132         if (bp->bi_memsize)
133                 return bp->bi_memsize;
134
135         return (256 * 1024 * 1024);
136 }
137
138 static void __init ppc7d_map_io(void)
139 {
140         /* remove temporary mapping */
141         mtspr(SPRN_DBAT3U, 0x00000000);
142         mtspr(SPRN_DBAT3L, 0x00000000);
143
144         io_block_mapping(0xe8000000, 0xe8000000, 0x08000000, _PAGE_IO);
145         io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
146 }
147
148 static void ppc7d_restart(char *cmd)
149 {
150         u32 data;
151
152         /* Disable GPP17 interrupt */
153         data = mv64x60_read(&bh, MV64x60_GPP_INTR_MASK);
154         data &= ~(1 << PPC7D_RST_PIN);
155         mv64x60_write(&bh, MV64x60_GPP_INTR_MASK, data);
156
157         /* Configure MPP17 as GPP */
158         data = mv64x60_read(&bh, MV64x60_MPP_CNTL_2);
159         data &= ~(0x0000000f << 4);
160         mv64x60_write(&bh, MV64x60_MPP_CNTL_2, data);
161
162         /* Enable pin GPP17 for output */
163         data = mv64x60_read(&bh, MV64x60_GPP_IO_CNTL);
164         data |= (1 << PPC7D_RST_PIN);
165         mv64x60_write(&bh, MV64x60_GPP_IO_CNTL, data);
166
167         /* Toggle GPP9 pin to reset the board */
168         mv64x60_write(&bh, MV64x60_GPP_VALUE_CLR, 1 << PPC7D_RST_PIN);
169         mv64x60_write(&bh, MV64x60_GPP_VALUE_SET, 1 << PPC7D_RST_PIN);
170
171         for (;;) ;              /* Spin until reset happens */
172         /* NOTREACHED */
173 }
174
175 static void ppc7d_power_off(void)
176 {
177         u32 data;
178
179         local_irq_disable();
180
181         /* Ensure that internal MV643XX watchdog is disabled.
182          * The Disco watchdog uses MPP17 on this hardware.
183          */
184         data = mv64x60_read(&bh, MV64x60_MPP_CNTL_2);
185         data &= ~(0x0000000f << 4);
186         mv64x60_write(&bh, MV64x60_MPP_CNTL_2, data);
187
188         data = mv64x60_read(&bh, MV64x60_WDT_WDC);
189         if (data & 0x80000000) {
190                 mv64x60_write(&bh, MV64x60_WDT_WDC, 1 << 24);
191                 mv64x60_write(&bh, MV64x60_WDT_WDC, 2 << 24);
192         }
193
194         for (;;) ;              /* No way to shut power off with software */
195         /* NOTREACHED */
196 }
197
198 static void ppc7d_halt(void)
199 {
200         ppc7d_power_off();
201         /* NOTREACHED */
202 }
203
204 static unsigned long ppc7d_led_no_pulse;
205
206 static int __init ppc7d_led_pulse_disable(char *str)
207 {
208         ppc7d_led_no_pulse = 1;
209         return 1;
210 }
211
212 /* This kernel option disables the heartbeat pulsing of a board LED */
213 __setup("ledoff", ppc7d_led_pulse_disable);
214
215 static void ppc7d_heartbeat(void)
216 {
217         u32 data32;
218         u8 data8;
219         static int max706_wdog = 0;
220
221         /* Unfortunately we can't access the LED control registers
222          * during early init because they're on the CPLD which is the
223          * other side of a PCI bridge which goes unreachable during
224          * PCI scan. So write the LEDs only if the MV64360 watchdog is
225          * enabled (i.e. userspace apps are running so kernel is up)..
226          */
227         data32 = mv64x60_read(&bh, MV64x60_WDT_WDC);
228         if (data32 & 0x80000000) {
229                 /* Enable MAX706 watchdog if not done already */
230                 if (!max706_wdog) {
231                         outb(3, PPC7D_CPLD_RESET);
232                         max706_wdog = 1;
233                 }
234
235                 /* Hit the MAX706 watchdog */
236                 outb(0, PPC7D_CPLD_WATCHDOG_TRIG);
237
238                 /* Pulse LED DS219 if not disabled */
239                 if (!ppc7d_led_no_pulse) {
240                         static int led_on = 0;
241
242                         data8 = inb(PPC7D_CPLD_LEDS);
243                         if (led_on)
244                                 data8 &= ~PPC7D_CPLD_LEDS_DS219_MASK;
245                         else
246                                 data8 |= PPC7D_CPLD_LEDS_DS219_MASK;
247
248                         outb(data8, PPC7D_CPLD_LEDS);
249                         led_on = !led_on;
250                 }
251         }
252         ppc_md.heartbeat_count = ppc_md.heartbeat_reset;
253 }
254
255 static int ppc7d_show_cpuinfo(struct seq_file *m)
256 {
257         u8 val;
258         u8 val1, val2;
259         static int flash_sizes[4] = { 64, 32, 0, 16 };
260         static int flash_banks[4] = { 4, 3, 2, 1 };
261         static int sdram_bank_sizes[4] = { 128, 256, 512, 1 };
262         int sdram_num_banks = 2;
263         static char *pci_modes[] = { "PCI33", "PCI66",
264                 "Unknown", "Unknown",
265                 "PCIX33", "PCIX66",
266                 "PCIX100", "PCIX133"
267         };
268
269         seq_printf(m, "vendor\t\t: Radstone Technology\n");
270         seq_printf(m, "machine\t\t: PPC7D\n");
271
272         val = inb(PPC7D_CPLD_BOARD_REVISION);
273         val1 = (val & PPC7D_CPLD_BOARD_REVISION_NUMBER_MASK) >> 5;
274         val2 = (val & PPC7D_CPLD_BOARD_REVISION_LETTER_MASK);
275         seq_printf(m, "revision\t: %hd%c%c\n",
276                    val1,
277                    (val2 <= 0x18) ? 'A' + val2 : 'Y',
278                    (val2 > 0x18) ? 'A' + (val2 - 0x19) : ' ');
279
280         val = inb(PPC7D_CPLD_MOTHERBOARD_TYPE);
281         val1 = val & PPC7D_CPLD_MB_TYPE_PLL_MASK;
282         val2 = val & (PPC7D_CPLD_MB_TYPE_ECC_FITTED_MASK |
283                       PPC7D_CPLD_MB_TYPE_ECC_ENABLE_MASK);
284         seq_printf(m, "bus speed\t: %dMHz\n",
285                    (val1 == PPC7D_CPLD_MB_TYPE_PLL_133) ? 133 :
286                    (val1 == PPC7D_CPLD_MB_TYPE_PLL_100) ? 100 :
287                    (val1 == PPC7D_CPLD_MB_TYPE_PLL_64) ? 64 : 0);
288
289         val = inb(PPC7D_CPLD_MEM_CONFIG);
290         if (val & PPC7D_CPLD_SDRAM_BANK_NUM_MASK) sdram_num_banks--;
291
292         val = inb(PPC7D_CPLD_MEM_CONFIG_EXTEND);
293         val1 = (val & PPC7D_CPLD_SDRAM_BANK_SIZE_MASK) >> 6;
294         seq_printf(m, "SDRAM\t\t: %d banks of %d%c, total %d%c",
295                    sdram_num_banks,
296                    sdram_bank_sizes[val1],
297                    (sdram_bank_sizes[val1] < 128) ? 'G' : 'M',
298                    sdram_num_banks * sdram_bank_sizes[val1],
299                    (sdram_bank_sizes[val1] < 128) ? 'G' : 'M');
300         if (val2 & PPC7D_CPLD_MB_TYPE_ECC_FITTED_MASK) {
301                 seq_printf(m, " [ECC %sabled]",
302                            (val2 & PPC7D_CPLD_MB_TYPE_ECC_ENABLE_MASK) ? "en" :
303                            "dis");
304         }
305         seq_printf(m, "\n");
306
307         val1 = (val & PPC7D_CPLD_FLASH_DEV_SIZE_MASK);
308         val2 = (val & PPC7D_CPLD_FLASH_BANK_NUM_MASK) >> 2;
309         seq_printf(m, "FLASH\t\t: %d banks of %dM, total %dM\n",
310                    flash_banks[val2], flash_sizes[val1],
311                    flash_banks[val2] * flash_sizes[val1]);
312
313         val = inb(PPC7D_CPLD_FLASH_WRITE_CNTL);
314         val1 = inb(PPC7D_CPLD_SW_FLASH_WRITE_PROTECT);
315         seq_printf(m, "  write links\t: %s%s%s%s\n",
316                    (val & PPD7D_CPLD_FLASH_CNTL_WR_LINK_MASK) ? "WRITE " : "",
317                    (val & PPD7D_CPLD_FLASH_CNTL_BOOT_LINK_MASK) ? "BOOT " : "",
318                    (val & PPD7D_CPLD_FLASH_CNTL_USER_LINK_MASK) ? "USER " : "",
319                    (val & (PPD7D_CPLD_FLASH_CNTL_WR_LINK_MASK |
320                            PPD7D_CPLD_FLASH_CNTL_BOOT_LINK_MASK |
321                            PPD7D_CPLD_FLASH_CNTL_USER_LINK_MASK)) ==
322                    0 ? "NONE" : "");
323         seq_printf(m, "  write sector h/w enables: %s%s%s%s%s\n",
324                    (val & PPD7D_CPLD_FLASH_CNTL_RECO_WR_MASK) ? "RECOVERY " :
325                    "",
326                    (val & PPD7D_CPLD_FLASH_CNTL_BOOT_WR_MASK) ? "BOOT " : "",
327                    (val & PPD7D_CPLD_FLASH_CNTL_USER_WR_MASK) ? "USER " : "",
328                    (val1 & PPC7D_CPLD_FLASH_CNTL_NVRAM_PROT_MASK) ? "NVRAM " :
329                    "",
330                    (((val &
331                       (PPD7D_CPLD_FLASH_CNTL_RECO_WR_MASK |
332                        PPD7D_CPLD_FLASH_CNTL_BOOT_WR_MASK |
333                        PPD7D_CPLD_FLASH_CNTL_BOOT_WR_MASK)) == 0)
334                     && ((val1 & PPC7D_CPLD_FLASH_CNTL_NVRAM_PROT_MASK) ==
335                         0)) ? "NONE" : "");
336         val1 =
337             inb(PPC7D_CPLD_SW_FLASH_WRITE_PROTECT) &
338             (PPC7D_CPLD_SW_FLASH_WRPROT_SYSBOOT_MASK |
339              PPC7D_CPLD_SW_FLASH_WRPROT_USER_MASK);
340         seq_printf(m, "  software sector enables: %s%s%s\n",
341                    (val1 & PPC7D_CPLD_SW_FLASH_WRPROT_SYSBOOT_MASK) ? "SYSBOOT "
342                    : "",
343                    (val1 & PPC7D_CPLD_SW_FLASH_WRPROT_USER_MASK) ? "USER " : "",
344                    (val1 == 0) ? "NONE " : "");
345
346         seq_printf(m, "Boot options\t: %s%s%s%s\n",
347                    (val & PPC7D_CPLD_FLASH_CNTL_ALTBOOT_LINK_MASK) ?
348                    "ALTERNATE " : "",
349                    (val & PPC7D_CPLD_FLASH_CNTL_VMEBOOT_LINK_MASK) ? "VME " :
350                    "",
351                    (val & PPC7D_CPLD_FLASH_CNTL_RECBOOT_LINK_MASK) ? "RECOVERY "
352                    : "",
353                    ((val &
354                      (PPC7D_CPLD_FLASH_CNTL_ALTBOOT_LINK_MASK |
355                       PPC7D_CPLD_FLASH_CNTL_VMEBOOT_LINK_MASK |
356                       PPC7D_CPLD_FLASH_CNTL_RECBOOT_LINK_MASK)) ==
357                     0) ? "NONE" : "");
358
359         val = inb(PPC7D_CPLD_EQUIPMENT_PRESENT_1);
360         seq_printf(m, "Fitted modules\t: %s%s%s%s\n",
361                    (val & PPC7D_CPLD_EQPT_PRES_1_PMC1_MASK) ? "" : "PMC1 ",
362                    (val & PPC7D_CPLD_EQPT_PRES_1_PMC2_MASK) ? "" : "PMC2 ",
363                    (val & PPC7D_CPLD_EQPT_PRES_1_AFIX_MASK) ? "AFIX " : "",
364                    ((val & (PPC7D_CPLD_EQPT_PRES_1_PMC1_MASK |
365                             PPC7D_CPLD_EQPT_PRES_1_PMC2_MASK |
366                             PPC7D_CPLD_EQPT_PRES_1_AFIX_MASK)) ==
367                     (PPC7D_CPLD_EQPT_PRES_1_PMC1_MASK |
368                      PPC7D_CPLD_EQPT_PRES_1_PMC2_MASK)) ? "NONE" : "");
369
370         if (val & PPC7D_CPLD_EQPT_PRES_1_AFIX_MASK) {
371                 static const char *ids[] = {
372                         "unknown",
373                         "1553 (Dual Channel)",
374                         "1553 (Single Channel)",
375                         "8-bit SCSI + VGA",
376                         "16-bit SCSI + VGA",
377                         "1553 (Single Channel with sideband)",
378                         "1553 (Dual Channel with sideband)",
379                         NULL
380                 };
381                 u8 id = __raw_readb((void *)PPC7D_AFIX_REG_BASE + 0x03);
382                 seq_printf(m, "AFIX module\t: 0x%hx [%s]\n", id,
383                            id < 7 ? ids[id] : "unknown");
384         }
385
386         val = inb(PPC7D_CPLD_PCI_CONFIG);
387         val1 = (val & PPC7D_CPLD_PCI_CONFIG_PCI0_MASK) >> 4;
388         val2 = (val & PPC7D_CPLD_PCI_CONFIG_PCI1_MASK);
389         seq_printf(m, "PCI#0\t\t: %s\nPCI#1\t\t: %s\n",
390                    pci_modes[val1], pci_modes[val2]);
391
392         val = inb(PPC7D_CPLD_EQUIPMENT_PRESENT_2);
393         seq_printf(m, "PMC1\t\t: %s\nPMC2\t\t: %s\n",
394                    (val & PPC7D_CPLD_EQPT_PRES_3_PMC1_V_MASK) ? "3.3v" : "5v",
395                    (val & PPC7D_CPLD_EQPT_PRES_3_PMC2_V_MASK) ? "3.3v" : "5v");
396         seq_printf(m, "PMC power source: %s\n",
397                    (val & PPC7D_CPLD_EQPT_PRES_3_PMC_POWER_MASK) ? "VME" :
398                    "internal");
399
400         val = inb(PPC7D_CPLD_EQUIPMENT_PRESENT_4);
401         val2 = inb(PPC7D_CPLD_EQUIPMENT_PRESENT_2);
402         seq_printf(m, "Fit options\t: %s%s%s%s%s%s%s\n",
403                    (val & PPC7D_CPLD_EQPT_PRES_4_LPT_MASK) ? "LPT " : "",
404                    (val & PPC7D_CPLD_EQPT_PRES_4_PS2_FITTED) ? "PS2 " : "",
405                    (val & PPC7D_CPLD_EQPT_PRES_4_USB2_FITTED) ? "USB2 " : "",
406                    (val2 & PPC7D_CPLD_EQPT_PRES_2_UNIVERSE_MASK) ? "VME " : "",
407                    (val2 & PPC7D_CPLD_EQPT_PRES_2_COM36_MASK) ? "COM3-6 " : "",
408                    (val2 & PPC7D_CPLD_EQPT_PRES_2_GIGE_MASK) ? "eth0 " : "",
409                    (val2 & PPC7D_CPLD_EQPT_PRES_2_DUALGIGE_MASK) ? "eth1 " :
410                    "");
411
412         val = inb(PPC7D_CPLD_ID_LINK);
413         val1 = val & (PPC7D_CPLD_ID_LINK_E6_MASK |
414                       PPC7D_CPLD_ID_LINK_E7_MASK |
415                       PPC7D_CPLD_ID_LINK_E12_MASK |
416                       PPC7D_CPLD_ID_LINK_E13_MASK);
417
418         val = inb(PPC7D_CPLD_FLASH_WRITE_CNTL) &
419             (PPD7D_CPLD_FLASH_CNTL_WR_LINK_MASK |
420              PPD7D_CPLD_FLASH_CNTL_BOOT_LINK_MASK |
421              PPD7D_CPLD_FLASH_CNTL_USER_LINK_MASK);
422
423         seq_printf(m, "Board links present: %s%s%s%s%s%s%s%s\n",
424                    (val1 & PPC7D_CPLD_ID_LINK_E6_MASK) ? "E6 " : "",
425                    (val1 & PPC7D_CPLD_ID_LINK_E7_MASK) ? "E7 " : "",
426                    (val & PPD7D_CPLD_FLASH_CNTL_WR_LINK_MASK) ? "E9 " : "",
427                    (val & PPD7D_CPLD_FLASH_CNTL_BOOT_LINK_MASK) ? "E10 " : "",
428                    (val & PPD7D_CPLD_FLASH_CNTL_USER_LINK_MASK) ? "E11 " : "",
429                    (val1 & PPC7D_CPLD_ID_LINK_E12_MASK) ? "E12 " : "",
430                    (val1 & PPC7D_CPLD_ID_LINK_E13_MASK) ? "E13 " : "",
431                    ((val == 0) && (val1 == 0)) ? "NONE" : "");
432
433         val = inb(PPC7D_CPLD_WDOG_RESETSW_MASK);
434         seq_printf(m, "Front panel reset switch: %sabled\n",
435                    (val & PPC7D_CPLD_WDOG_RESETSW_MASK) ? "dis" : "en");
436
437         return 0;
438 }
439
440 static void __init ppc7d_calibrate_decr(void)
441 {
442         ulong freq;
443
444         freq = 100000000 / 4;
445
446         pr_debug("time_init: decrementer frequency = %lu.%.6lu MHz\n",
447                  freq / 1000000, freq % 1000000);
448
449         tb_ticks_per_jiffy = freq / HZ;
450         tb_to_us = mulhwu_scale_factor(freq, 1000000);
451 }
452
453 /*****************************************************************************
454  * Interrupt stuff
455  *****************************************************************************/
456
457 static irqreturn_t ppc7d_i8259_intr(int irq, void *dev_id, struct pt_regs *regs)
458 {
459         u32 temp = mv64x60_read(&bh, MV64x60_GPP_INTR_CAUSE);
460         if (temp & (1 << 28)) {
461                 i8259_irq(regs);
462                 mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, temp & (~(1 << 28)));
463                 return IRQ_HANDLED;
464         }
465
466         return IRQ_NONE;
467 }
468
469 /*
470  * Each interrupt cause is assigned an IRQ number.
471  * Southbridge has 16*2 (two 8259's) interrupts.
472  * Discovery-II has 96 interrupts (cause-hi, cause-lo, gpp x 32).
473  * If multiple interrupts are pending, get_irq() returns the
474  * lowest pending irq number first.
475  *
476  *
477  * IRQ #   Source                              Trig   Active
478  * =============================================================
479  *
480  * Southbridge
481  * -----------
482  * IRQ #   Source                              Trig
483  * =============================================================
484  * 0       ISA High Resolution Counter         Edge
485  * 1       Keyboard                            Edge
486  * 2       Cascade From (IRQ 8-15)             Edge
487  * 3       Com 2 (Uart 2)                      Edge
488  * 4       Com 1 (Uart 1)                      Edge
489  * 5       PCI Int D/AFIX IRQZ ID4 (2,7)       Level
490  * 6       GPIO                                Level
491  * 7       LPT                                 Edge
492  * 8       RTC Alarm                           Edge
493  * 9       PCI Int A/PMC 2/AFIX IRQW ID1 (2,0) Level
494  * 10      PCI Int B/PMC 1/AFIX IRQX ID2 (2,1) Level
495  * 11      USB2                                Level
496  * 12      Mouse                               Edge
497  * 13      Reserved internally by Ali M1535+
498  * 14      PCI Int C/VME/AFIX IRQY ID3 (2,6)   Level
499  * 15      COM 5/6                             Level
500  *
501  * 16..112 Discovery-II...
502  *
503  * MPP28   Southbridge                         Edge   High
504  *
505  *
506  * Interrupts are cascaded through to the Discovery-II.
507  *
508  *  PCI ---
509  *         \
510  * CPLD --> ALI1535 -------> DISCOVERY-II
511  *        INTF           MPP28
512  */
513 static void __init ppc7d_init_irq(void)
514 {
515         int irq;
516
517         pr_debug("%s\n", __FUNCTION__);
518         i8259_init(0);
519         mv64360_init_irq();
520
521         /* IRQ 0..15 are handled by the cascaded 8259's of the Ali1535 */
522         for (irq = 0; irq < 16; irq++) {
523                 irq_desc[irq].handler = &i8259_pic;
524         }
525         /* IRQs 5,6,9,10,11,14,15 are level sensitive */
526         irq_desc[5].status |= IRQ_LEVEL;
527         irq_desc[6].status |= IRQ_LEVEL;
528         irq_desc[9].status |= IRQ_LEVEL;
529         irq_desc[10].status |= IRQ_LEVEL;
530         irq_desc[11].status |= IRQ_LEVEL;
531         irq_desc[14].status |= IRQ_LEVEL;
532         irq_desc[15].status |= IRQ_LEVEL;
533
534         /* GPP28 is edge triggered */
535         irq_desc[mv64360_irq_base + MV64x60_IRQ_GPP28].status &= ~IRQ_LEVEL;
536 }
537
538 static u32 ppc7d_irq_canonicalize(u32 irq)
539 {
540         if ((irq >= 16) && (irq < (16 + 96)))
541                 irq -= 16;
542
543         return irq;
544 }
545
546 static int ppc7d_get_irq(struct pt_regs *regs)
547 {
548         int irq;
549
550         irq = mv64360_get_irq(regs);
551         if (irq == (mv64360_irq_base + MV64x60_IRQ_GPP28))
552                 irq = i8259_irq(regs);
553         return irq;
554 }
555
556 /*
557  * 9       PCI Int A/PMC 2/AFIX IRQW ID1 (2,0) Level
558  * 10      PCI Int B/PMC 1/AFIX IRQX ID2 (2,1) Level
559  * 14      PCI Int C/VME/AFIX IRQY ID3 (2,6)   Level
560  * 5       PCI Int D/AFIX IRQZ ID4 (2,7)       Level
561  */
562 static int __init ppc7d_map_irq(struct pci_dev *dev, unsigned char idsel,
563                                 unsigned char pin)
564 {
565         static const char pci_irq_table[][4] =
566             /*
567              *      PCI IDSEL/INTPIN->INTLINE
568              *         A   B   C   D
569              */
570         {
571                 {10, 14, 5, 9}, /* IDSEL 10 - PMC2 / AFIX IRQW */
572                 {9, 10, 14, 5}, /* IDSEL 11 - PMC1 / AFIX IRQX */
573                 {5, 9, 10, 14}, /* IDSEL 12 - AFIX IRQY */
574                 {14, 5, 9, 10}, /* IDSEL 13 - AFIX IRQZ */
575         };
576         const long min_idsel = 10, max_idsel = 14, irqs_per_slot = 4;
577
578         pr_debug("%s: %04x/%04x/%x: idsel=%hx pin=%hu\n", __FUNCTION__,
579                  dev->vendor, dev->device, PCI_FUNC(dev->devfn), idsel, pin);
580
581         return PCI_IRQ_TABLE_LOOKUP;
582 }
583
584 void __init ppc7d_intr_setup(void)
585 {
586         u32 data;
587
588         /*
589          * Define GPP 28 interrupt polarity as active high
590          * input signal and level triggered
591          */
592         data = mv64x60_read(&bh, MV64x60_GPP_LEVEL_CNTL);
593         data &= ~(1 << 28);
594         mv64x60_write(&bh, MV64x60_GPP_LEVEL_CNTL, data);
595         data = mv64x60_read(&bh, MV64x60_GPP_IO_CNTL);
596         data &= ~(1 << 28);
597         mv64x60_write(&bh, MV64x60_GPP_IO_CNTL, data);
598
599         /* Config GPP intr ctlr to respond to level trigger */
600         data = mv64x60_read(&bh, MV64x60_COMM_ARBITER_CNTL);
601         data |= (1 << 10);
602         mv64x60_write(&bh, MV64x60_COMM_ARBITER_CNTL, data);
603
604         /* XXXX Erranum FEr PCI-#8 */
605         data = mv64x60_read(&bh, MV64x60_PCI0_CMD);
606         data &= ~((1 << 5) | (1 << 9));
607         mv64x60_write(&bh, MV64x60_PCI0_CMD, data);
608         data = mv64x60_read(&bh, MV64x60_PCI1_CMD);
609         data &= ~((1 << 5) | (1 << 9));
610         mv64x60_write(&bh, MV64x60_PCI1_CMD, data);
611
612         /*
613          * Dismiss and then enable interrupt on GPP interrupt cause
614          * for CPU #0
615          */
616         mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, ~(1 << 28));
617         data = mv64x60_read(&bh, MV64x60_GPP_INTR_MASK);
618         data |= (1 << 28);
619         mv64x60_write(&bh, MV64x60_GPP_INTR_MASK, data);
620
621         /*
622          * Dismiss and then enable interrupt on CPU #0 high cause reg
623          * BIT27 summarizes GPP interrupts 23-31
624          */
625         mv64x60_write(&bh, MV64360_IC_MAIN_CAUSE_HI, ~(1 << 27));
626         data = mv64x60_read(&bh, MV64360_IC_CPU0_INTR_MASK_HI);
627         data |= (1 << 27);
628         mv64x60_write(&bh, MV64360_IC_CPU0_INTR_MASK_HI, data);
629 }
630
631 /*****************************************************************************
632  * Platform device data fixup routines.
633  *****************************************************************************/
634
635 #if defined(CONFIG_SERIAL_MPSC)
636 static void __init ppc7d_fixup_mpsc_pdata(struct platform_device *pdev)
637 {
638         struct mpsc_pdata *pdata;
639
640         pdata = (struct mpsc_pdata *)pdev->dev.platform_data;
641
642         pdata->max_idle = 40;
643         pdata->default_baud = PPC7D_DEFAULT_BAUD;
644         pdata->brg_clk_src = PPC7D_MPSC_CLK_SRC;
645         pdata->brg_clk_freq = PPC7D_MPSC_CLK_FREQ;
646
647         return;
648 }
649 #endif
650
651 #if defined(CONFIG_MV643XX_ETH)
652 static void __init ppc7d_fixup_eth_pdata(struct platform_device *pdev)
653 {
654         struct mv643xx_eth_platform_data *eth_pd;
655         static u16 phy_addr[] = {
656                 PPC7D_ETH0_PHY_ADDR,
657                 PPC7D_ETH1_PHY_ADDR,
658                 PPC7D_ETH2_PHY_ADDR,
659         };
660         int i;
661
662         eth_pd = pdev->dev.platform_data;
663         eth_pd->force_phy_addr = 1;
664         eth_pd->phy_addr = phy_addr[pdev->id];
665         eth_pd->tx_queue_size = PPC7D_ETH_TX_QUEUE_SIZE;
666         eth_pd->rx_queue_size = PPC7D_ETH_RX_QUEUE_SIZE;
667
668         /* Adjust IRQ by mv64360_irq_base */
669         for (i = 0; i < pdev->num_resources; i++) {
670                 struct resource *r = &pdev->resource[i];
671
672                 if (r->flags & IORESOURCE_IRQ) {
673                         r->start += mv64360_irq_base;
674                         r->end += mv64360_irq_base;
675                         pr_debug("%s, uses IRQ %d\n", pdev->name,
676                                  (int)r->start);
677                 }
678         }
679
680 }
681 #endif
682
683 #if defined(CONFIG_I2C_MV64XXX)
684 static void __init
685 ppc7d_fixup_i2c_pdata(struct platform_device *pdev)
686 {
687         struct mv64xxx_i2c_pdata *pdata;
688         int i;
689
690         pdata = pdev->dev.platform_data;
691         if (pdata == NULL) {
692                 pdata = kmalloc(sizeof(*pdata), GFP_KERNEL);
693                 if (pdata == NULL)
694                         return;
695
696                 memset(pdata, 0, sizeof(*pdata));
697                 pdev->dev.platform_data = pdata;
698         }
699
700         /* divisors M=8, N=3 for 100kHz I2C from 133MHz system clock */
701         pdata->freq_m = 8;
702         pdata->freq_n = 3;
703         pdata->timeout = 500;
704         pdata->retries = 3;
705
706         /* Adjust IRQ by mv64360_irq_base */
707         for (i = 0; i < pdev->num_resources; i++) {
708                 struct resource *r = &pdev->resource[i];
709
710                 if (r->flags & IORESOURCE_IRQ) {
711                         r->start += mv64360_irq_base;
712                         r->end += mv64360_irq_base;
713                         pr_debug("%s, uses IRQ %d\n", pdev->name, (int) r->start);
714                 }
715         }
716 }
717 #endif
718
719 static int __init ppc7d_platform_notify(struct device *dev)
720 {
721         static struct {
722                 char *bus_id;
723                 void ((*rtn) (struct platform_device * pdev));
724         } dev_map[] = {
725 #if defined(CONFIG_SERIAL_MPSC)
726                 { MPSC_CTLR_NAME ".0", ppc7d_fixup_mpsc_pdata },
727                 { MPSC_CTLR_NAME ".1", ppc7d_fixup_mpsc_pdata },
728 #endif
729 #if defined(CONFIG_MV643XX_ETH)
730                 { MV643XX_ETH_NAME ".0", ppc7d_fixup_eth_pdata },
731                 { MV643XX_ETH_NAME ".1", ppc7d_fixup_eth_pdata },
732                 { MV643XX_ETH_NAME ".2", ppc7d_fixup_eth_pdata },
733 #endif
734 #if defined(CONFIG_I2C_MV64XXX)
735                 { MV64XXX_I2C_CTLR_NAME ".0", ppc7d_fixup_i2c_pdata },
736 #endif
737         };
738         struct platform_device *pdev;
739         int i;
740
741         if (dev && dev->bus_id)
742                 for (i = 0; i < ARRAY_SIZE(dev_map); i++)
743                         if (!strncmp(dev->bus_id, dev_map[i].bus_id,
744                                      BUS_ID_SIZE)) {
745
746                                 pdev = container_of(dev,
747                                                     struct platform_device,
748                                                     dev);
749                                 dev_map[i].rtn(pdev);
750                         }
751
752         return 0;
753 }
754
755 /*****************************************************************************
756  * PCI device fixups.
757  * These aren't really fixups per se. They are used to init devices as they
758  * are found during PCI scan.
759  *
760  * The PPC7D has an HB8 PCI-X bridge which must be set up during a PCI
761  * scan in order to find other devices on its secondary side.
762  *****************************************************************************/
763
764 static void __init ppc7d_fixup_hb8(struct pci_dev *dev)
765 {
766         u16 val16;
767
768         if (dev->bus->number == 0) {
769                 pr_debug("PCI: HB8 init\n");
770
771                 pci_write_config_byte(dev, 0x1c,
772                                       ((PPC7D_PCI0_IO_START_PCI_ADDR & 0xf000)
773                                        >> 8) | 0x01);
774                 pci_write_config_byte(dev, 0x1d,
775                                       (((PPC7D_PCI0_IO_START_PCI_ADDR +
776                                          PPC7D_PCI0_IO_SIZE -
777                                          1) & 0xf000) >> 8) | 0x01);
778                 pci_write_config_word(dev, 0x30,
779                                       PPC7D_PCI0_IO_START_PCI_ADDR >> 16);
780                 pci_write_config_word(dev, 0x32,
781                                       ((PPC7D_PCI0_IO_START_PCI_ADDR +
782                                         PPC7D_PCI0_IO_SIZE -
783                                         1) >> 16) & 0xffff);
784
785                 pci_write_config_word(dev, 0x20,
786                                       PPC7D_PCI0_MEM0_START_PCI_LO_ADDR >> 16);
787                 pci_write_config_word(dev, 0x22,
788                                       ((PPC7D_PCI0_MEM0_START_PCI_LO_ADDR +
789                                         PPC7D_PCI0_MEM0_SIZE -
790                                         1) >> 16) & 0xffff);
791                 pci_write_config_word(dev, 0x24, 0);
792                 pci_write_config_word(dev, 0x26, 0);
793                 pci_write_config_dword(dev, 0x28, 0);
794                 pci_write_config_dword(dev, 0x2c, 0);
795
796                 pci_read_config_word(dev, 0x3e, &val16);
797                 val16 |= ((1 << 5) | (1 << 1)); /* signal master aborts and
798                                                  * SERR to primary
799                                                  */
800                 val16 &= ~(1 << 2);             /* ISA disable, so all ISA
801                                                  * ports forwarded to secondary
802                                                  */
803                 pci_write_config_word(dev, 0x3e, val16);
804         }
805 }
806
807 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HINT, 0x0028, ppc7d_fixup_hb8);
808
809 /* This should perhaps be a separate driver as we're actually initializing
810  * the chip for this board here. It's hardly a fixup...
811  */
812 static void __init ppc7d_fixup_ali1535(struct pci_dev *dev)
813 {
814         pr_debug("PCI: ALI1535 init\n");
815
816         if (dev->bus->number == 1) {
817                 /* Configure the ISA Port Settings */
818                 pci_write_config_byte(dev, 0x43, 0x00);
819
820                 /* Disable PCI Interrupt polling mode */
821                 pci_write_config_byte(dev, 0x45, 0x00);
822
823                 /* Multifunction pin select INTFJ -> INTF */
824                 pci_write_config_byte(dev, 0x78, 0x00);
825
826                 /* Set PCI INT -> IRQ Routing control in for external
827                  * pins south bridge.
828                  */
829                 pci_write_config_byte(dev, 0x48, 0x31); /* [7-4] INT B -> IRQ10
830                                                          * [3-0] INT A -> IRQ9
831                                                          */
832                 pci_write_config_byte(dev, 0x49, 0x5D); /* [7-4] INT D -> IRQ5
833                                                          * [3-0] INT C -> IRQ14
834                                                          */
835
836                 /* PPC7D setup */
837                 /* NEC USB device on IRQ 11 (INTE) - INTF disabled */
838                 pci_write_config_byte(dev, 0x4A, 0x09);
839
840                 /* GPIO on IRQ 6 */
841                 pci_write_config_byte(dev, 0x76, 0x07);
842
843                 /* SIRQ I (COMS 5/6) use IRQ line 15.
844                  * Positive (not subtractive) address decode.
845                  */
846                 pci_write_config_byte(dev, 0x44, 0x0f);
847
848                 /* SIRQ II disabled */
849                 pci_write_config_byte(dev, 0x75, 0x0);
850
851                 /* On board USB and RTC disabled */
852                 pci_write_config_word(dev, 0x52, (1 << 14));
853                 pci_write_config_byte(dev, 0x74, 0x00);
854
855                 /* On board IDE disabled */
856                 pci_write_config_byte(dev, 0x58, 0x00);
857
858                 /* Decode 32-bit addresses */
859                 pci_write_config_byte(dev, 0x5b, 0);
860
861                 /* Disable docking IO */
862                 pci_write_config_word(dev, 0x5c, 0x0000);
863
864                 /* Disable modem, enable sound */
865                 pci_write_config_byte(dev, 0x77, (1 << 6));
866
867                 /* Disable hot-docking mode */
868                 pci_write_config_byte(dev, 0x7d, 0x00);
869         }
870 }
871
872 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1533, ppc7d_fixup_ali1535);
873
874 static int ppc7d_pci_exclude_device(u8 bus, u8 devfn)
875 {
876         /* Early versions of this board were fitted with IBM ALMA
877          * PCI-VME bridge chips. The PCI config space of these devices
878          * was not set up correctly and causes PCI scan problems.
879          */
880         if ((bus == 1) && (PCI_SLOT(devfn) == 4) && ppc7d_has_alma)
881                 return PCIBIOS_DEVICE_NOT_FOUND;
882
883         return mv64x60_pci_exclude_device(bus, devfn);
884 }
885
886 /* This hook is called when each PCI bus is probed.
887  */
888 static void ppc7d_pci_fixup_bus(struct pci_bus *bus)
889 {
890         pr_debug("PCI BUS %hu: %lx/%lx %lx/%lx %lx/%lx %lx/%lx\n",
891                  bus->number,
892                  bus->resource[0] ? bus->resource[0]->start : 0,
893                  bus->resource[0] ? bus->resource[0]->end : 0,
894                  bus->resource[1] ? bus->resource[1]->start : 0,
895                  bus->resource[1] ? bus->resource[1]->end : 0,
896                  bus->resource[2] ? bus->resource[2]->start : 0,
897                  bus->resource[2] ? bus->resource[2]->end : 0,
898                  bus->resource[3] ? bus->resource[3]->start : 0,
899                  bus->resource[3] ? bus->resource[3]->end : 0);
900
901         if ((bus->number == 1) && (bus->resource[2] != NULL)) {
902                 /* Hide PCI window 2 of Bus 1 which is used only to
903                  * map legacy ISA memory space.
904                  */
905                 bus->resource[2]->start = 0;
906                 bus->resource[2]->end = 0;
907                 bus->resource[2]->flags = 0;
908         }
909 }
910
911 /*****************************************************************************
912  * Board device setup code
913  *****************************************************************************/
914
915 void __init ppc7d_setup_peripherals(void)
916 {
917         u32 val32;
918
919         /* Set up windows for boot CS */
920         mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
921                                  PPC7D_BOOT_WINDOW_BASE, PPC7D_BOOT_WINDOW_SIZE,
922                                  0);
923         bh.ci->enable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN);
924
925         /* Boot firmware configures the following DevCS addresses.
926          * DevCS0 - board control/status
927          * DevCS1 - test registers
928          * DevCS2 - AFIX port/address registers (for identifying)
929          * DevCS3 - FLASH
930          *
931          * We don't use DevCS0, DevCS1.
932          */
933         val32 = mv64x60_read(&bh, MV64360_CPU_BAR_ENABLE);
934         val32 |= ((1 << 4) | (1 << 5));
935         mv64x60_write(&bh, MV64360_CPU_BAR_ENABLE, val32);
936         mv64x60_write(&bh, MV64x60_CPU2DEV_0_BASE, 0);
937         mv64x60_write(&bh, MV64x60_CPU2DEV_0_SIZE, 0);
938         mv64x60_write(&bh, MV64x60_CPU2DEV_1_BASE, 0);
939         mv64x60_write(&bh, MV64x60_CPU2DEV_1_SIZE, 0);
940
941         mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_2_WIN,
942                                  PPC7D_AFIX_REG_BASE, PPC7D_AFIX_REG_SIZE, 0);
943         bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_2_WIN);
944
945         mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_3_WIN,
946                                  PPC7D_FLASH_BASE, PPC7D_FLASH_SIZE_ACTUAL, 0);
947         bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_3_WIN);
948
949         mv64x60_set_32bit_window(&bh, MV64x60_CPU2SRAM_WIN,
950                                  PPC7D_INTERNAL_SRAM_BASE, MV64360_SRAM_SIZE,
951                                  0);
952         bh.ci->enable_window_32bit(&bh, MV64x60_CPU2SRAM_WIN);
953
954         /* Set up Enet->SRAM window */
955         mv64x60_set_32bit_window(&bh, MV64x60_ENET2MEM_4_WIN,
956                                  PPC7D_INTERNAL_SRAM_BASE, MV64360_SRAM_SIZE,
957                                  0x2);
958         bh.ci->enable_window_32bit(&bh, MV64x60_ENET2MEM_4_WIN);
959
960         /* Give enet r/w access to memory region */
961         val32 = mv64x60_read(&bh, MV64360_ENET2MEM_ACC_PROT_0);
962         val32 |= (0x3 << (4 << 1));
963         mv64x60_write(&bh, MV64360_ENET2MEM_ACC_PROT_0, val32);
964         val32 = mv64x60_read(&bh, MV64360_ENET2MEM_ACC_PROT_1);
965         val32 |= (0x3 << (4 << 1));
966         mv64x60_write(&bh, MV64360_ENET2MEM_ACC_PROT_1, val32);
967         val32 = mv64x60_read(&bh, MV64360_ENET2MEM_ACC_PROT_2);
968         val32 |= (0x3 << (4 << 1));
969         mv64x60_write(&bh, MV64360_ENET2MEM_ACC_PROT_2, val32);
970
971         val32 = mv64x60_read(&bh, MV64x60_TIMR_CNTR_0_3_CNTL);
972         val32 &= ~((1 << 0) | (1 << 8) | (1 << 16) | (1 << 24));
973         mv64x60_write(&bh, MV64x60_TIMR_CNTR_0_3_CNTL, val32);
974
975         /* Enumerate pci bus.
976          *
977          * We scan PCI#0 first (the bus with the HB8 and other
978          * on-board peripherals). We must configure the 64360 before
979          * each scan, according to the bus number assignments.  Busses
980          * are assigned incrementally, starting at 0.  PCI#0 is
981          * usually assigned bus#0, the secondary side of the HB8 gets
982          * bus#1 and PCI#1 (second PMC site) gets bus#2.  However, if
983          * any PMC card has a PCI bridge, these bus assignments will
984          * change.
985          */
986
987         /* Turn off PCI retries */
988         val32 = mv64x60_read(&bh, MV64x60_CPU_CONFIG);
989         val32 |= (1 << 17);
990         mv64x60_write(&bh, MV64x60_CPU_CONFIG, val32);
991
992         /* Scan PCI#0 */
993         mv64x60_set_bus(&bh, 0, 0);
994         bh.hose_a->first_busno = 0;
995         bh.hose_a->last_busno = 0xff;
996         bh.hose_a->last_busno = pciauto_bus_scan(bh.hose_a, 0);
997         printk(KERN_INFO "PCI#0: first=%d last=%d\n",
998                bh.hose_a->first_busno, bh.hose_a->last_busno);
999
1000         /* Scan PCI#1 */
1001         bh.hose_b->first_busno = bh.hose_a->last_busno + 1;
1002         mv64x60_set_bus(&bh, 1, bh.hose_b->first_busno);
1003         bh.hose_b->last_busno = 0xff;
1004         bh.hose_b->last_busno = pciauto_bus_scan(bh.hose_b,
1005                 bh.hose_b->first_busno);
1006         printk(KERN_INFO "PCI#1: first=%d last=%d\n",
1007                bh.hose_b->first_busno, bh.hose_b->last_busno);
1008
1009         /* Turn on PCI retries */
1010         val32 = mv64x60_read(&bh, MV64x60_CPU_CONFIG);
1011         val32 &= ~(1 << 17);
1012         mv64x60_write(&bh, MV64x60_CPU_CONFIG, val32);
1013
1014         /* Setup interrupts */
1015         ppc7d_intr_setup();
1016 }
1017
1018 static void __init ppc7d_setup_bridge(void)
1019 {
1020         struct mv64x60_setup_info si;
1021         int i;
1022         u32 temp;
1023
1024         mv64360_irq_base = 16;  /* first 16 intrs are 2 x 8259's */
1025
1026         memset(&si, 0, sizeof(si));
1027
1028         si.phys_reg_base = CONFIG_MV64X60_NEW_BASE;
1029
1030         si.pci_0.enable_bus = 1;
1031         si.pci_0.pci_io.cpu_base = PPC7D_PCI0_IO_START_PROC_ADDR;
1032         si.pci_0.pci_io.pci_base_hi = 0;
1033         si.pci_0.pci_io.pci_base_lo = PPC7D_PCI0_IO_START_PCI_ADDR;
1034         si.pci_0.pci_io.size = PPC7D_PCI0_IO_SIZE;
1035         si.pci_0.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE;
1036         si.pci_0.pci_mem[0].cpu_base = PPC7D_PCI0_MEM0_START_PROC_ADDR;
1037         si.pci_0.pci_mem[0].pci_base_hi = PPC7D_PCI0_MEM0_START_PCI_HI_ADDR;
1038         si.pci_0.pci_mem[0].pci_base_lo = PPC7D_PCI0_MEM0_START_PCI_LO_ADDR;
1039         si.pci_0.pci_mem[0].size = PPC7D_PCI0_MEM0_SIZE;
1040         si.pci_0.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE;
1041         si.pci_0.pci_mem[1].cpu_base = PPC7D_PCI0_MEM1_START_PROC_ADDR;
1042         si.pci_0.pci_mem[1].pci_base_hi = PPC7D_PCI0_MEM1_START_PCI_HI_ADDR;
1043         si.pci_0.pci_mem[1].pci_base_lo = PPC7D_PCI0_MEM1_START_PCI_LO_ADDR;
1044         si.pci_0.pci_mem[1].size = PPC7D_PCI0_MEM1_SIZE;
1045         si.pci_0.pci_mem[1].swap = MV64x60_CPU2PCI_SWAP_NONE;
1046         si.pci_0.pci_cmd_bits = 0;
1047         si.pci_0.latency_timer = 0x80;
1048
1049         si.pci_1.enable_bus = 1;
1050         si.pci_1.pci_io.cpu_base = PPC7D_PCI1_IO_START_PROC_ADDR;
1051         si.pci_1.pci_io.pci_base_hi = 0;
1052         si.pci_1.pci_io.pci_base_lo = PPC7D_PCI1_IO_START_PCI_ADDR;
1053         si.pci_1.pci_io.size = PPC7D_PCI1_IO_SIZE;
1054         si.pci_1.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE;
1055         si.pci_1.pci_mem[0].cpu_base = PPC7D_PCI1_MEM0_START_PROC_ADDR;
1056         si.pci_1.pci_mem[0].pci_base_hi = PPC7D_PCI1_MEM0_START_PCI_HI_ADDR;
1057         si.pci_1.pci_mem[0].pci_base_lo = PPC7D_PCI1_MEM0_START_PCI_LO_ADDR;
1058         si.pci_1.pci_mem[0].size = PPC7D_PCI1_MEM0_SIZE;
1059         si.pci_1.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE;
1060         si.pci_1.pci_mem[1].cpu_base = PPC7D_PCI1_MEM1_START_PROC_ADDR;
1061         si.pci_1.pci_mem[1].pci_base_hi = PPC7D_PCI1_MEM1_START_PCI_HI_ADDR;
1062         si.pci_1.pci_mem[1].pci_base_lo = PPC7D_PCI1_MEM1_START_PCI_LO_ADDR;
1063         si.pci_1.pci_mem[1].size = PPC7D_PCI1_MEM1_SIZE;
1064         si.pci_1.pci_mem[1].swap = MV64x60_CPU2PCI_SWAP_NONE;
1065         si.pci_1.pci_cmd_bits = 0;
1066         si.pci_1.latency_timer = 0x80;
1067
1068         /* Don't clear the SRAM window since we use it for debug */
1069         si.window_preserve_mask_32_lo = (1 << MV64x60_CPU2SRAM_WIN);
1070
1071         printk(KERN_INFO "PCI: MV64360 PCI#0 IO at %x, size %x\n",
1072                si.pci_0.pci_io.cpu_base, si.pci_0.pci_io.size);
1073         printk(KERN_INFO "PCI: MV64360 PCI#1 IO at %x, size %x\n",
1074                si.pci_1.pci_io.cpu_base, si.pci_1.pci_io.size);
1075
1076         for (i = 0; i < MV64x60_CPU2MEM_WINDOWS; i++) {
1077 #if defined(CONFIG_NOT_COHERENT_CACHE)
1078                 si.cpu_prot_options[i] = 0;
1079                 si.enet_options[i] = MV64360_ENET2MEM_SNOOP_NONE;
1080                 si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_NONE;
1081                 si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_NONE;
1082
1083                 si.pci_0.acc_cntl_options[i] =
1084                     MV64360_PCI_ACC_CNTL_SNOOP_NONE |
1085                     MV64360_PCI_ACC_CNTL_SWAP_NONE |
1086                     MV64360_PCI_ACC_CNTL_MBURST_128_BYTES |
1087                     MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
1088
1089                 si.pci_1.acc_cntl_options[i] =
1090                     MV64360_PCI_ACC_CNTL_SNOOP_NONE |
1091                     MV64360_PCI_ACC_CNTL_SWAP_NONE |
1092                     MV64360_PCI_ACC_CNTL_MBURST_128_BYTES |
1093                     MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
1094 #else
1095                 si.cpu_prot_options[i] = 0;
1096                 /* All PPC7D hardware uses B0 or newer MV64360 silicon which
1097                  * does not have snoop bugs.
1098                  */
1099                 si.enet_options[i] = MV64360_ENET2MEM_SNOOP_WB;
1100                 si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_WB;
1101                 si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_WB;
1102
1103                 si.pci_0.acc_cntl_options[i] =
1104                     MV64360_PCI_ACC_CNTL_SNOOP_WB |
1105                     MV64360_PCI_ACC_CNTL_SWAP_NONE |
1106                     MV64360_PCI_ACC_CNTL_MBURST_32_BYTES |
1107                     MV64360_PCI_ACC_CNTL_RDSIZE_32_BYTES;
1108
1109                 si.pci_1.acc_cntl_options[i] =
1110                     MV64360_PCI_ACC_CNTL_SNOOP_WB |
1111                     MV64360_PCI_ACC_CNTL_SWAP_NONE |
1112                     MV64360_PCI_ACC_CNTL_MBURST_32_BYTES |
1113                     MV64360_PCI_ACC_CNTL_RDSIZE_32_BYTES;
1114 #endif
1115         }
1116
1117         /* Lookup PCI host bridges */
1118         if (mv64x60_init(&bh, &si))
1119                 printk(KERN_ERR "MV64360 initialization failed.\n");
1120
1121         pr_debug("MV64360 regs @ %lx/%p\n", bh.p_base, bh.v_base);
1122
1123         /* Enable WB Cache coherency on SRAM */
1124         temp = mv64x60_read(&bh, MV64360_SRAM_CONFIG);
1125         pr_debug("SRAM_CONFIG: %x\n", temp);
1126 #if defined(CONFIG_NOT_COHERENT_CACHE)
1127         mv64x60_write(&bh, MV64360_SRAM_CONFIG, temp & ~0x2);
1128 #else
1129         mv64x60_write(&bh, MV64360_SRAM_CONFIG, temp | 0x2);
1130 #endif
1131         /* If system operates with internal bus arbiter (CPU master
1132          * control bit8) clear AACK Delay bit [25] in CPU
1133          * configuration register.
1134          */
1135         temp = mv64x60_read(&bh, MV64x60_CPU_MASTER_CNTL);
1136         if (temp & (1 << 8)) {
1137                 temp = mv64x60_read(&bh, MV64x60_CPU_CONFIG);
1138                 mv64x60_write(&bh, MV64x60_CPU_CONFIG, (temp & ~(1 << 25)));
1139         }
1140
1141         /* Data and address parity is enabled */
1142         temp = mv64x60_read(&bh, MV64x60_CPU_CONFIG);
1143         mv64x60_write(&bh, MV64x60_CPU_CONFIG,
1144                       (temp | (1 << 26) | (1 << 19)));
1145
1146         pci_dram_offset = 0;    /* sys mem at same addr on PCI & cpu bus */
1147         ppc_md.pci_swizzle = common_swizzle;
1148         ppc_md.pci_map_irq = ppc7d_map_irq;
1149         ppc_md.pci_exclude_device = ppc7d_pci_exclude_device;
1150
1151         mv64x60_set_bus(&bh, 0, 0);
1152         bh.hose_a->first_busno = 0;
1153         bh.hose_a->last_busno = 0xff;
1154         bh.hose_a->mem_space.start = PPC7D_PCI0_MEM0_START_PCI_LO_ADDR;
1155         bh.hose_a->mem_space.end =
1156             PPC7D_PCI0_MEM0_START_PCI_LO_ADDR + PPC7D_PCI0_MEM0_SIZE;
1157
1158         /* These will be set later, as a result of PCI0 scan */
1159         bh.hose_b->first_busno = 0;
1160         bh.hose_b->last_busno = 0xff;
1161         bh.hose_b->mem_space.start = PPC7D_PCI1_MEM0_START_PCI_LO_ADDR;
1162         bh.hose_b->mem_space.end =
1163             PPC7D_PCI1_MEM0_START_PCI_LO_ADDR + PPC7D_PCI1_MEM0_SIZE;
1164
1165         pr_debug("MV64360: PCI#0 IO decode %08x/%08x IO remap %08x\n",
1166                  mv64x60_read(&bh, 0x48), mv64x60_read(&bh, 0x50),
1167                  mv64x60_read(&bh, 0xf0));
1168 }
1169
1170 static void __init ppc7d_setup_arch(void)
1171 {
1172         int port;
1173
1174         loops_per_jiffy = 100000000 / HZ;
1175
1176 #ifdef CONFIG_BLK_DEV_INITRD
1177         if (initrd_start)
1178                 ROOT_DEV = Root_RAM0;
1179         else
1180 #endif
1181 #ifdef  CONFIG_ROOT_NFS
1182                 ROOT_DEV = Root_NFS;
1183 #else
1184                 ROOT_DEV = Root_HDA1;
1185 #endif
1186
1187         if ((cur_cpu_spec[0]->cpu_features & CPU_FTR_SPEC7450) ||
1188             (cur_cpu_spec[0]->cpu_features & CPU_FTR_L3CR))
1189                 /* 745x is different.  We only want to pass along enable. */
1190                 _set_L2CR(L2CR_L2E);
1191         else if (cur_cpu_spec[0]->cpu_features & CPU_FTR_L2CR)
1192                 /* All modules have 1MB of L2.  We also assume that an
1193                  * L2 divisor of 3 will work.
1194                  */
1195                 _set_L2CR(L2CR_L2E | L2CR_L2SIZ_1MB | L2CR_L2CLK_DIV3
1196                           | L2CR_L2RAM_PIPE | L2CR_L2OH_1_0 | L2CR_L2DF);
1197
1198         if (cur_cpu_spec[0]->cpu_features & CPU_FTR_L3CR)
1199                 /* No L3 cache */
1200                 _set_L3CR(0);
1201
1202 #ifdef CONFIG_DUMMY_CONSOLE
1203         conswitchp = &dummy_con;
1204 #endif
1205
1206         /* Lookup PCI host bridges */
1207         if (ppc_md.progress)
1208                 ppc_md.progress("ppc7d_setup_arch: calling setup_bridge", 0);
1209
1210         ppc7d_setup_bridge();
1211         ppc7d_setup_peripherals();
1212
1213         /* Disable ethernet. It might have been setup by the bootrom */
1214         for (port = 0; port < 3; port++)
1215                 mv64x60_write(&bh, MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port),
1216                               0x0000ff00);
1217
1218         /* Clear queue pointers to ensure they are all initialized,
1219          * otherwise since queues 1-7 are unused, they have random
1220          * pointers which look strange in register dumps. Don't bother
1221          * with queue 0 since it will be initialized later.
1222          */
1223         for (port = 0; port < 3; port++) {
1224                 mv64x60_write(&bh,
1225                               MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_1(port),
1226                               0x00000000);
1227                 mv64x60_write(&bh,
1228                               MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_2(port),
1229                               0x00000000);
1230                 mv64x60_write(&bh,
1231                               MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_3(port),
1232                               0x00000000);
1233                 mv64x60_write(&bh,
1234                               MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_4(port),
1235                               0x00000000);
1236                 mv64x60_write(&bh,
1237                               MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_5(port),
1238                               0x00000000);
1239                 mv64x60_write(&bh,
1240                               MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_6(port),
1241                               0x00000000);
1242                 mv64x60_write(&bh,
1243                               MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_7(port),
1244                               0x00000000);
1245         }
1246
1247         printk(KERN_INFO "Radstone Technology PPC7D\n");
1248         if (ppc_md.progress)
1249                 ppc_md.progress("ppc7d_setup_arch: exit", 0);
1250
1251 }
1252
1253 /* Real Time Clock support.
1254  * PPC7D has a DS1337 accessed by I2C.
1255  */
1256 static ulong ppc7d_get_rtc_time(void)
1257 {
1258         struct rtc_time tm;
1259         int result;
1260
1261         spin_lock(&rtc_lock);
1262         result = ds1337_do_command(0, DS1337_GET_DATE, &tm);
1263         spin_unlock(&rtc_lock);
1264
1265         if (result == 0)
1266                 result = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
1267
1268         return result;
1269 }
1270
1271 static int ppc7d_set_rtc_time(unsigned long nowtime)
1272 {
1273         struct rtc_time tm;
1274         int result;
1275
1276         spin_lock(&rtc_lock);
1277         to_tm(nowtime, &tm);
1278         result = ds1337_do_command(0, DS1337_SET_DATE, &tm);
1279         spin_unlock(&rtc_lock);
1280
1281         return result;
1282 }
1283
1284 /* This kernel command line parameter can be used to have the target
1285  * wait for a JTAG debugger to attach. Of course, a JTAG debugger
1286  * with hardware breakpoint support can have the target stop at any
1287  * location during init, but this is a convenience feature that makes
1288  * it easier in the common case of loading the code using the ppcboot
1289  * bootloader..
1290  */
1291 static unsigned long ppc7d_wait_debugger;
1292
1293 static int __init ppc7d_waitdbg(char *str)
1294 {
1295         ppc7d_wait_debugger = 1;
1296         return 1;
1297 }
1298
1299 __setup("waitdbg", ppc7d_waitdbg);
1300
1301 /* Second phase board init, called after other (architecture common)
1302  * low-level services have been initialized.
1303  */
1304 static void ppc7d_init2(void)
1305 {
1306         unsigned long flags;
1307         u32 data;
1308         u8 data8;
1309
1310         pr_debug("%s: enter\n", __FUNCTION__);
1311
1312         /* Wait for debugger? */
1313         if (ppc7d_wait_debugger) {
1314                 printk("Waiting for debugger...\n");
1315
1316                 while (readl(&ppc7d_wait_debugger)) ;
1317         }
1318
1319         /* Hook up i8259 interrupt which is connected to GPP28 */
1320         request_irq(mv64360_irq_base + MV64x60_IRQ_GPP28, ppc7d_i8259_intr,
1321                     SA_INTERRUPT, "I8259 (GPP28) interrupt", (void *)0);
1322
1323         /* Configure MPP16 as watchdog NMI, MPP17 as watchdog WDE */
1324         spin_lock_irqsave(&mv64x60_lock, flags);
1325         data = mv64x60_read(&bh, MV64x60_MPP_CNTL_2);
1326         data &= ~(0x0000000f << 0);
1327         data |= (0x00000004 << 0);
1328         data &= ~(0x0000000f << 4);
1329         data |= (0x00000004 << 4);
1330         mv64x60_write(&bh, MV64x60_MPP_CNTL_2, data);
1331         spin_unlock_irqrestore(&mv64x60_lock, flags);
1332
1333         /* All LEDs off */
1334         data8 = inb(PPC7D_CPLD_LEDS);
1335         data8 &= ~0x08;
1336         data8 |= 0x07;
1337         outb(data8, PPC7D_CPLD_LEDS);
1338
1339         /* Hook up RTC. We couldn't do this earlier because we need the I2C subsystem */
1340         ppc_md.set_rtc_time = ppc7d_set_rtc_time;
1341         ppc_md.get_rtc_time = ppc7d_get_rtc_time;
1342
1343         pr_debug("%s: exit\n", __FUNCTION__);
1344 }
1345
1346 /* Called from machine_init(), early, before any of the __init functions
1347  * have run. We must init software-configurable pins before other functions
1348  * such as interrupt controllers are initialised.
1349  */
1350 void __init platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
1351                           unsigned long r6, unsigned long r7)
1352 {
1353         u8 val8;
1354         u8 rev_num;
1355
1356         /* Map 0xe0000000-0xffffffff early because we need access to SRAM
1357          * and the ISA memory space (for serial port) here. This mapping
1358          * is redone properly in ppc7d_map_io() later.
1359          */
1360         mtspr(SPRN_DBAT3U, 0xe0003fff);
1361         mtspr(SPRN_DBAT3L, 0xe000002a);
1362
1363         /*
1364          * Zero SRAM. Note that this generates parity errors on
1365          * internal data path in SRAM if it's first time accessing it
1366          * after reset.
1367          *
1368          * We do this ASAP to avoid parity errors when reading
1369          * uninitialized SRAM.
1370          */
1371         memset((void *)PPC7D_INTERNAL_SRAM_BASE, 0, MV64360_SRAM_SIZE);
1372
1373         pr_debug("platform_init: r3-r7: %lx %lx %lx %lx %lx\n",
1374                  r3, r4, r5, r6, r7);
1375
1376         parse_bootinfo(find_bootinfo());
1377
1378         /* ASSUMPTION:  If both r3 (bd_t pointer) and r6 (cmdline pointer)
1379          * are non-zero, then we should use the board info from the bd_t
1380          * structure and the cmdline pointed to by r6 instead of the
1381          * information from birecs, if any.  Otherwise, use the information
1382          * from birecs as discovered by the preceeding call to
1383          * parse_bootinfo().  This rule should work with both PPCBoot, which
1384          * uses a bd_t board info structure, and the kernel boot wrapper,
1385          * which uses birecs.
1386          */
1387         if (r3 && r6) {
1388                 bd_t *bp = (bd_t *) __res;
1389
1390                 /* copy board info structure */
1391                 memcpy((void *)__res, (void *)(r3 + KERNELBASE), sizeof(bd_t));
1392                 /* copy command line */
1393                 *(char *)(r7 + KERNELBASE) = 0;
1394                 strcpy(cmd_line, (char *)(r6 + KERNELBASE));
1395
1396                 printk(KERN_INFO "Board info data:-\n");
1397                 printk(KERN_INFO "  Internal freq: %lu MHz, bus freq: %lu MHz\n",
1398                        bp->bi_intfreq, bp->bi_busfreq);
1399                 printk(KERN_INFO "  Memory: %lx, size %lx\n", bp->bi_memstart,
1400                        bp->bi_memsize);
1401                 printk(KERN_INFO "  Console baudrate: %lu\n", bp->bi_baudrate);
1402                 printk(KERN_INFO "  Ethernet address: "
1403                        "%02x:%02x:%02x:%02x:%02x:%02x\n",
1404                        bp->bi_enetaddr[0], bp->bi_enetaddr[1],
1405                        bp->bi_enetaddr[2], bp->bi_enetaddr[3],
1406                        bp->bi_enetaddr[4], bp->bi_enetaddr[5]);
1407         }
1408 #ifdef CONFIG_BLK_DEV_INITRD
1409         /* take care of initrd if we have one */
1410         if (r4) {
1411                 initrd_start = r4 + KERNELBASE;
1412                 initrd_end = r5 + KERNELBASE;
1413                 printk(KERN_INFO "INITRD @ %lx/%lx\n", initrd_start, initrd_end);
1414         }
1415 #endif /* CONFIG_BLK_DEV_INITRD */
1416
1417         /* Map in board regs, etc. */
1418         isa_io_base = 0xe8000000;
1419         isa_mem_base = 0xe8000000;
1420         pci_dram_offset = 0x00000000;
1421         ISA_DMA_THRESHOLD = 0x00ffffff;
1422         DMA_MODE_READ = 0x44;
1423         DMA_MODE_WRITE = 0x48;
1424
1425         ppc_md.setup_arch = ppc7d_setup_arch;
1426         ppc_md.init = ppc7d_init2;
1427         ppc_md.show_cpuinfo = ppc7d_show_cpuinfo;
1428         ppc_md.irq_canonicalize = ppc7d_irq_canonicalize;
1429         ppc_md.init_IRQ = ppc7d_init_irq;
1430         ppc_md.get_irq = ppc7d_get_irq;
1431
1432         ppc_md.restart = ppc7d_restart;
1433         ppc_md.power_off = ppc7d_power_off;
1434         ppc_md.halt = ppc7d_halt;
1435
1436         ppc_md.find_end_of_memory = ppc7d_find_end_of_memory;
1437         ppc_md.setup_io_mappings = ppc7d_map_io;
1438
1439         ppc_md.time_init = NULL;
1440         ppc_md.set_rtc_time = NULL;
1441         ppc_md.get_rtc_time = NULL;
1442         ppc_md.calibrate_decr = ppc7d_calibrate_decr;
1443         ppc_md.nvram_read_val = NULL;
1444         ppc_md.nvram_write_val = NULL;
1445
1446         ppc_md.heartbeat = ppc7d_heartbeat;
1447         ppc_md.heartbeat_reset = HZ;
1448         ppc_md.heartbeat_count = ppc_md.heartbeat_reset;
1449
1450         ppc_md.pcibios_fixup_bus = ppc7d_pci_fixup_bus;
1451
1452 #if defined(CONFIG_SERIAL_MPSC) || defined(CONFIG_MV643XX_ETH) || \
1453     defined(CONFIG_I2C_MV64XXX)
1454         platform_notify = ppc7d_platform_notify;
1455 #endif
1456
1457 #ifdef CONFIG_SERIAL_MPSC
1458         /* On PPC7D, we must configure MPSC support via CPLD control
1459          * registers.
1460          */
1461         outb(PPC7D_CPLD_RTS_COM4_SCLK |
1462              PPC7D_CPLD_RTS_COM56_ENABLED, PPC7D_CPLD_RTS);
1463         outb(PPC7D_CPLD_COMS_COM3_TCLKEN |
1464              PPC7D_CPLD_COMS_COM3_TXEN |
1465              PPC7D_CPLD_COMS_COM4_TCLKEN |
1466              PPC7D_CPLD_COMS_COM4_TXEN, PPC7D_CPLD_COMS);
1467 #endif /* CONFIG_SERIAL_MPSC */
1468
1469 #if defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG)
1470         ppc7d_early_serial_map();
1471 #ifdef  CONFIG_SERIAL_TEXT_DEBUG
1472 #if defined(CONFIG_SERIAL_MPSC_CONSOLE)
1473         ppc_md.progress = mv64x60_mpsc_progress;
1474 #elif defined(CONFIG_SERIAL_8250)
1475         ppc_md.progress = gen550_progress;
1476 #else
1477 #error CONFIG_KGDB || CONFIG_SERIAL_TEXT_DEBUG has no supported CONFIG_SERIAL_XXX
1478 #endif /* CONFIG_SERIAL_8250 */
1479 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
1480 #endif /* CONFIG_KGDB || CONFIG_SERIAL_TEXT_DEBUG */
1481
1482         /* Enable write access to user flash.  This is necessary for
1483          * flash probe.
1484          */
1485         val8 = readb((void *)isa_io_base + PPC7D_CPLD_SW_FLASH_WRITE_PROTECT);
1486         writeb(val8 | (PPC7D_CPLD_SW_FLASH_WRPROT_ENABLED &
1487                        PPC7D_CPLD_SW_FLASH_WRPROT_USER_MASK),
1488                (void *)isa_io_base + PPC7D_CPLD_SW_FLASH_WRITE_PROTECT);
1489
1490         /* Determine if this board has IBM ALMA VME devices */
1491         val8 = readb((void *)isa_io_base + PPC7D_CPLD_BOARD_REVISION);
1492         rev_num = (val8 & PPC7D_CPLD_BOARD_REVISION_NUMBER_MASK) >> 5;
1493         if (rev_num <= 1)
1494                 ppc7d_has_alma = 1;
1495
1496 #ifdef DEBUG
1497         console_printk[0] = 8;
1498 #endif
1499 }