Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[sfrench/cifs-2.6.git] / 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/config.h>
13 #include <linux/init.h>
14 #include <linux/irq.h>
15 #include <linux/tty.h>
16 #include <linux/serial.h>
17 #include <linux/serial_core.h>
18 #include <linux/serial_8250.h>
19 #include <linux/serialP.h>
20 #include <asm/io.h>
21 #include <asm/machdep.h>
22 #include <asm/ppc_sys.h>
23
24 #include <syslib/gen550.h>
25 #include <platforms/4xx/xparameters/xparameters.h>
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 /* Board specifications structures */
58 struct ppc_sys_spec *cur_ppc_sys_spec;
59 struct ppc_sys_spec ppc_sys_specs[] = {
60         {
61                 /* Only one entry, always assume the same design */
62                 .ppc_sys_name   = "Xilinx ML300 Reference Design",
63                 .mask           = 0x00000000,
64                 .value          = 0x00000000,
65                 .num_devices    = 1,
66                 .device_list    = (enum ppc_sys_devices[])
67                 {
68                         VIRTEX_UART,
69                 },
70         },
71 };
72
73 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
74
75 static volatile unsigned *powerdown_base =
76     (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
77
78 static void
79 xilinx_power_off(void)
80 {
81         local_irq_disable();
82         out_be32(powerdown_base, XPAR_POWER_0_POWERDOWN_VALUE);
83         while (1) ;
84 }
85 #endif
86
87 void __init
88 ml300_map_io(void)
89 {
90         ppc4xx_map_io();
91
92 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
93         powerdown_base = ioremap((unsigned long) powerdown_base,
94                                  XPAR_POWER_0_POWERDOWN_HIGHADDR -
95                                  XPAR_POWER_0_POWERDOWN_BASEADDR + 1);
96 #endif
97 }
98
99 /* Early serial support functions */
100 static void __init
101 ml300_early_serial_init(int num, struct plat_serial8250_port *pdata)
102 {
103 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
104         struct uart_port serial_req;
105
106         memset(&serial_req, 0, sizeof(serial_req));
107         serial_req.mapbase      = pdata->mapbase;
108         serial_req.membase      = pdata->membase;
109         serial_req.irq          = pdata->irq;
110         serial_req.uartclk      = pdata->uartclk;
111         serial_req.regshift     = pdata->regshift;
112         serial_req.iotype       = pdata->iotype;
113         serial_req.flags        = pdata->flags;
114         gen550_init(num, &serial_req);
115 #endif
116 }
117
118 void __init
119 ml300_early_serial_map(void)
120 {
121 #ifdef CONFIG_SERIAL_8250
122         struct plat_serial8250_port *pdata;
123         int i = 0;
124
125         pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
126         while(pdata && pdata->flags)
127         {
128                 pdata->membase = ioremap(pdata->mapbase, 0x100);
129                 ml300_early_serial_init(i, pdata);
130                 pdata++;
131                 i++;
132         }
133 #endif /* CONFIG_SERIAL_8250 */
134 }
135
136 void __init
137 ml300_setup_arch(void)
138 {
139         ml300_early_serial_map();
140         ppc4xx_setup_arch();    /* calls ppc4xx_find_bridges() */
141
142         /* Identify the system */
143         printk(KERN_INFO "Xilinx Virtex-II Pro port\n");
144         printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
145 }
146
147 /* Called after board_setup_irq from ppc4xx_init_IRQ(). */
148 void __init
149 ml300_init_irq(void)
150 {
151         ppc4xx_init_IRQ();
152 }
153
154 void __init
155 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
156               unsigned long r6, unsigned long r7)
157 {
158         ppc4xx_init(r3, r4, r5, r6, r7);
159
160         identify_ppc_sys_by_id(mfspr(SPRN_PVR));
161
162         ppc_md.setup_arch = ml300_setup_arch;
163         ppc_md.setup_io_mappings = ml300_map_io;
164         ppc_md.init_IRQ = ml300_init_irq;
165
166 #if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
167         ppc_md.power_off = xilinx_power_off;
168 #endif
169
170 #ifdef CONFIG_KGDB
171         ppc_md.early_serial_map = ml300_early_serial_map;
172 #endif
173 }
174