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