Merge branch 'origin'
[pandora-kernel.git] / arch / ppc / platforms / 4xx / xilinx_ml300.c
1 /*
2  * arch/ppc/platforms/4xx/xilinx_ml300.c
3  *
4  * Xilinx ML300 evaluation board initialization
5  *
6  * Author: MontaVista Software, Inc.
7  *         source@mvista.com
8  *
9  * 2002-2004 (c) MontaVista Software, Inc.  This file is licensed under the
10  * terms of the GNU General Public License version 2.  This program is licensed
11  * "as is" without any warranty of any kind, whether express or implied.
12  */
13
14 #include <linux/config.h>
15 #include <linux/init.h>
16 #include <linux/irq.h>
17 #include <linux/tty.h>
18 #include <linux/serial.h>
19 #include <linux/serial_core.h>
20 #include <linux/serialP.h>
21 #include <asm/io.h>
22 #include <asm/machdep.h>
23 #include <asm/ocp.h>
24
25 #include <platforms/4xx/virtex-ii_pro.h>        /* for NR_SER_PORTS */
26
27 /*
28  * As an overview of how the following functions (platform_init,
29  * ml300_map_io, ml300_setup_arch and ml300_init_IRQ) fit into the
30  * kernel startup procedure, here's a call tree:
31  *
32  * start_here                                   arch/ppc/kernel/head_4xx.S
33  *  early_init                                  arch/ppc/kernel/setup.c
34  *  machine_init                                arch/ppc/kernel/setup.c
35  *    platform_init                             this file
36  *      ppc4xx_init                             arch/ppc/syslib/ppc4xx_setup.c
37  *        parse_bootinfo
38  *          find_bootinfo
39  *        "setup some default ppc_md pointers"
40  *  MMU_init                                    arch/ppc/mm/init.c
41  *    *ppc_md.setup_io_mappings == ml300_map_io this file
42  *      ppc4xx_map_io                           arch/ppc/syslib/ppc4xx_setup.c
43  *  start_kernel                                init/main.c
44  *    setup_arch                                arch/ppc/kernel/setup.c
45  * #if defined(CONFIG_KGDB)
46  *      *ppc_md.kgdb_map_scc() == gen550_kgdb_map_scc
47  * #endif
48  *      *ppc_md.setup_arch == ml300_setup_arch  this file
49  *        ppc4xx_setup_arch                     arch/ppc/syslib/ppc4xx_setup.c
50  *          ppc4xx_find_bridges                 arch/ppc/syslib/ppc405_pci.c
51  *    init_IRQ                                  arch/ppc/kernel/irq.c
52  *      *ppc_md.init_IRQ == ml300_init_IRQ      this file
53  *        ppc4xx_init_IRQ                       arch/ppc/syslib/ppc4xx_setup.c
54  *          ppc4xx_pic_init                     arch/ppc/syslib/xilinx_pic.c
55  */
56
57 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
58
59 static volatile unsigned *powerdown_base =
60     (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
61
62 static void
63 xilinx_power_off(void)
64 {
65         local_irq_disable();
66         out_be32(powerdown_base, XPAR_POWER_0_POWERDOWN_VALUE);
67         while (1) ;
68 }
69 #endif
70
71 void __init
72 ml300_map_io(void)
73 {
74         ppc4xx_map_io();
75
76 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
77         powerdown_base = ioremap((unsigned long) powerdown_base,
78                                  XPAR_POWER_0_POWERDOWN_HIGHADDR -
79                                  XPAR_POWER_0_POWERDOWN_BASEADDR + 1);
80 #endif
81 }
82
83 static void __init
84 ml300_early_serial_map(void)
85 {
86 #ifdef CONFIG_SERIAL_8250
87         struct serial_state old_ports[] = { SERIAL_PORT_DFNS };
88         struct uart_port port;
89         int i;
90
91         /* Setup ioremapped serial port access */
92         for (i = 0; i < ARRAY_SIZE(old_ports); i++ ) {
93                 memset(&port, 0, sizeof(port));
94                 port.membase = ioremap((phys_addr_t)(old_ports[i].iomem_base), 16);
95                 port.irq = old_ports[i].irq;
96                 port.uartclk = old_ports[i].baud_base * 16;
97                 port.regshift = old_ports[i].iomem_reg_shift;
98                 port.iotype = UPIO_MEM;
99                 port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
100                 port.line = i;
101
102                 if (early_serial_setup(&port) != 0) {
103                         printk("Early serial init of port %d failed\n", i);
104                 }
105         }
106 #endif /* CONFIG_SERIAL_8250 */
107 }
108
109 void __init
110 ml300_setup_arch(void)
111 {
112         ppc4xx_setup_arch();    /* calls ppc4xx_find_bridges() */
113
114         ml300_early_serial_map();
115
116         /* Identify the system */
117         printk(KERN_INFO "Xilinx Virtex-II Pro port\n");
118         printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
119 }
120
121 /* Called after board_setup_irq from ppc4xx_init_IRQ(). */
122 void __init
123 ml300_init_irq(void)
124 {
125         ppc4xx_init_IRQ();
126 }
127
128 void __init
129 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
130               unsigned long r6, unsigned long r7)
131 {
132         ppc4xx_init(r3, r4, r5, r6, r7);
133
134         ppc_md.setup_arch = ml300_setup_arch;
135         ppc_md.setup_io_mappings = ml300_map_io;
136         ppc_md.init_IRQ = ml300_init_irq;
137
138 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
139         ppc_md.power_off = xilinx_power_off;
140 #endif
141
142 #ifdef CONFIG_KGDB
143         ppc_md.early_serial_map = ml300_early_serial_map;
144 #endif
145 }
146