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