Merge ../linux-2.6-watchdog-mm
[linux-2.6] / arch / ppc / platforms / 4xx / xilinx_ml300.c
1 /*
2  * Xilinx ML300 evaluation board initialization
3  *
4  * Author: MontaVista Software, Inc.
5  *         source@mvista.com
6  *
7  * 2002-2004 (c) MontaVista Software, Inc.  This file is licensed under the
8  * terms of the GNU General Public License version 2.  This program is licensed
9  * "as is" without any warranty of any kind, whether express or implied.
10  */
11
12 #include <linux/init.h>
13 #include <linux/irq.h>
14 #include <linux/tty.h>
15 #include <linux/serial.h>
16 #include <linux/serial_core.h>
17 #include <linux/serial_8250.h>
18 #include <linux/serialP.h>
19 #include <asm/io.h>
20 #include <asm/machdep.h>
21 #include <asm/ppc_sys.h>
22
23 #include <syslib/gen550.h>
24 #include <platforms/4xx/xparameters/xparameters.h>
25
26 /*
27  * As an overview of how the following functions (platform_init,
28  * ml300_map_io, ml300_setup_arch and ml300_init_IRQ) fit into the
29  * kernel startup procedure, here's a call tree:
30  *
31  * start_here                                   arch/ppc/kernel/head_4xx.S
32  *  early_init                                  arch/ppc/kernel/setup.c
33  *  machine_init                                arch/ppc/kernel/setup.c
34  *    platform_init                             this file
35  *      ppc4xx_init                             arch/ppc/syslib/ppc4xx_setup.c
36  *        parse_bootinfo
37  *          find_bootinfo
38  *        "setup some default ppc_md pointers"
39  *  MMU_init                                    arch/ppc/mm/init.c
40  *    *ppc_md.setup_io_mappings == ml300_map_io this file
41  *      ppc4xx_map_io                           arch/ppc/syslib/ppc4xx_setup.c
42  *  start_kernel                                init/main.c
43  *    setup_arch                                arch/ppc/kernel/setup.c
44  * #if defined(CONFIG_KGDB)
45  *      *ppc_md.kgdb_map_scc() == gen550_kgdb_map_scc
46  * #endif
47  *      *ppc_md.setup_arch == ml300_setup_arch  this file
48  *        ppc4xx_setup_arch                     arch/ppc/syslib/ppc4xx_setup.c
49  *          ppc4xx_find_bridges                 arch/ppc/syslib/ppc405_pci.c
50  *    init_IRQ                                  arch/ppc/kernel/irq.c
51  *      *ppc_md.init_IRQ == ml300_init_IRQ      this file
52  *        ppc4xx_init_IRQ                       arch/ppc/syslib/ppc4xx_setup.c
53  *          ppc4xx_pic_init                     arch/ppc/syslib/xilinx_pic.c
54  */
55
56 /* Board specifications structures */
57 struct ppc_sys_spec *cur_ppc_sys_spec;
58 struct ppc_sys_spec ppc_sys_specs[] = {
59         {
60                 /* Only one entry, always assume the same design */
61                 .ppc_sys_name   = "Xilinx ML300 Reference Design",
62                 .mask           = 0x00000000,
63                 .value          = 0x00000000,
64                 .num_devices    = 1,
65                 .device_list    = (enum ppc_sys_devices[])
66                 {
67                         VIRTEX_UART,
68                 },
69         },
70 };
71
72 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
73
74 static volatile unsigned *powerdown_base =
75     (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
76
77 static void
78 xilinx_power_off(void)
79 {
80         local_irq_disable();
81         out_be32(powerdown_base, XPAR_POWER_0_POWERDOWN_VALUE);
82         while (1) ;
83 }
84 #endif
85
86 void __init
87 ml300_map_io(void)
88 {
89         ppc4xx_map_io();
90
91 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
92         powerdown_base = ioremap((unsigned long) powerdown_base,
93                                  XPAR_POWER_0_POWERDOWN_HIGHADDR -
94                                  XPAR_POWER_0_POWERDOWN_BASEADDR + 1);
95 #endif
96 }
97
98 /* Early serial support functions */
99 static void __init
100 ml300_early_serial_init(int num, struct plat_serial8250_port *pdata)
101 {
102 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
103         struct uart_port serial_req;
104
105         memset(&serial_req, 0, sizeof(serial_req));
106         serial_req.mapbase      = pdata->mapbase;
107         serial_req.membase      = pdata->membase;
108         serial_req.irq          = pdata->irq;
109         serial_req.uartclk      = pdata->uartclk;
110         serial_req.regshift     = pdata->regshift;
111         serial_req.iotype       = pdata->iotype;
112         serial_req.flags        = pdata->flags;
113         gen550_init(num, &serial_req);
114 #endif
115 }
116
117 void __init
118 ml300_early_serial_map(void)
119 {
120 #ifdef CONFIG_SERIAL_8250
121         struct plat_serial8250_port *pdata;
122         int i = 0;
123
124         pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
125         while(pdata && pdata->flags)
126         {
127                 pdata->membase = ioremap(pdata->mapbase, 0x100);
128                 ml300_early_serial_init(i, pdata);
129                 pdata++;
130                 i++;
131         }
132 #endif /* CONFIG_SERIAL_8250 */
133 }
134
135 void __init
136 ml300_setup_arch(void)
137 {
138         ml300_early_serial_map();
139         ppc4xx_setup_arch();    /* calls ppc4xx_find_bridges() */
140
141         /* Identify the system */
142         printk(KERN_INFO "Xilinx Virtex-II Pro port\n");
143         printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
144 }
145
146 /* Called after board_setup_irq from ppc4xx_init_IRQ(). */
147 void __init
148 ml300_init_irq(void)
149 {
150         ppc4xx_init_IRQ();
151 }
152
153 void __init
154 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
155               unsigned long r6, unsigned long r7)
156 {
157         ppc4xx_init(r3, r4, r5, r6, r7);
158
159         identify_ppc_sys_by_id(mfspr(SPRN_PVR));
160
161         ppc_md.setup_arch = ml300_setup_arch;
162         ppc_md.setup_io_mappings = ml300_map_io;
163         ppc_md.init_IRQ = ml300_init_irq;
164
165 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
166         ppc_md.power_off = xilinx_power_off;
167 #endif
168
169 #ifdef CONFIG_KGDB
170         ppc_md.early_serial_map = ml300_early_serial_map;
171 #endif
172 }
173