blob: 267afb50607e59e4f8b1d945e6320ea6a8684720 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Grant C. Likelye27db622006-01-19 01:13:03 -070020#include <linux/serial_8250.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/serialP.h>
22#include <asm/io.h>
23#include <asm/machdep.h>
Grant C. Likelye27db622006-01-19 01:13:03 -070024#include <asm/ppc_sys.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Grant C. Likelye27db622006-01-19 01:13:03 -070026#include <syslib/gen550.h>
27#include <platforms/4xx/xparameters/xparameters.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29/*
30 * As an overview of how the following functions (platform_init,
31 * ml300_map_io, ml300_setup_arch and ml300_init_IRQ) fit into the
32 * kernel startup procedure, here's a call tree:
33 *
34 * start_here arch/ppc/kernel/head_4xx.S
35 * early_init arch/ppc/kernel/setup.c
36 * machine_init arch/ppc/kernel/setup.c
37 * platform_init this file
38 * ppc4xx_init arch/ppc/syslib/ppc4xx_setup.c
39 * parse_bootinfo
40 * find_bootinfo
41 * "setup some default ppc_md pointers"
42 * MMU_init arch/ppc/mm/init.c
43 * *ppc_md.setup_io_mappings == ml300_map_io this file
44 * ppc4xx_map_io arch/ppc/syslib/ppc4xx_setup.c
45 * start_kernel init/main.c
46 * setup_arch arch/ppc/kernel/setup.c
47 * #if defined(CONFIG_KGDB)
48 * *ppc_md.kgdb_map_scc() == gen550_kgdb_map_scc
49 * #endif
50 * *ppc_md.setup_arch == ml300_setup_arch this file
51 * ppc4xx_setup_arch arch/ppc/syslib/ppc4xx_setup.c
52 * ppc4xx_find_bridges arch/ppc/syslib/ppc405_pci.c
53 * init_IRQ arch/ppc/kernel/irq.c
54 * *ppc_md.init_IRQ == ml300_init_IRQ this file
55 * ppc4xx_init_IRQ arch/ppc/syslib/ppc4xx_setup.c
56 * ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c
57 */
58
Grant C. Likelye27db622006-01-19 01:13:03 -070059/* Board specifications structures */
60struct ppc_sys_spec *cur_ppc_sys_spec;
61struct ppc_sys_spec ppc_sys_specs[] = {
62 {
63 /* Only one entry, always assume the same design */
64 .ppc_sys_name = "Xilinx ML300 Reference Design",
65 .mask = 0x00000000,
66 .value = 0x00000000,
67 .num_devices = 1,
68 .device_list = (enum ppc_sys_devices[])
69 {
70 VIRTEX_UART,
71 },
72 },
73};
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
76
77static volatile unsigned *powerdown_base =
78 (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
79
80static void
81xilinx_power_off(void)
82{
83 local_irq_disable();
84 out_be32(powerdown_base, XPAR_POWER_0_POWERDOWN_VALUE);
85 while (1) ;
86}
87#endif
88
89void __init
90ml300_map_io(void)
91{
92 ppc4xx_map_io();
93
94#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
95 powerdown_base = ioremap((unsigned long) powerdown_base,
96 XPAR_POWER_0_POWERDOWN_HIGHADDR -
97 XPAR_POWER_0_POWERDOWN_BASEADDR + 1);
98#endif
99}
100
Grant C. Likelye27db622006-01-19 01:13:03 -0700101/* Early serial support functions */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102static void __init
Grant C. Likelye27db622006-01-19 01:13:03 -0700103ml300_early_serial_init(int num, struct plat_serial8250_port *pdata)
104{
105#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
106 struct uart_port serial_req;
107
108 memset(&serial_req, 0, sizeof(serial_req));
109 serial_req.mapbase = pdata->mapbase;
110 serial_req.membase = pdata->membase;
111 serial_req.irq = pdata->irq;
112 serial_req.uartclk = pdata->uartclk;
113 serial_req.regshift = pdata->regshift;
114 serial_req.iotype = pdata->iotype;
115 serial_req.flags = pdata->flags;
116 gen550_init(num, &serial_req);
117#endif
118}
119
120void __init
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121ml300_early_serial_map(void)
122{
123#ifdef CONFIG_SERIAL_8250
Grant C. Likelye27db622006-01-19 01:13:03 -0700124 struct plat_serial8250_port *pdata;
125 int i = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Grant C. Likelye27db622006-01-19 01:13:03 -0700127 pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
128 while(pdata && pdata->flags)
129 {
130 pdata->membase = ioremap(pdata->mapbase, 0x100);
131 ml300_early_serial_init(i, pdata);
132 pdata++;
133 i++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 }
135#endif /* CONFIG_SERIAL_8250 */
136}
137
138void __init
139ml300_setup_arch(void)
140{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 ml300_early_serial_map();
Grant C. Likelye27db622006-01-19 01:13:03 -0700142 ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144 /* Identify the system */
145 printk(KERN_INFO "Xilinx Virtex-II Pro port\n");
146 printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
147}
148
149/* Called after board_setup_irq from ppc4xx_init_IRQ(). */
150void __init
151ml300_init_irq(void)
152{
153 ppc4xx_init_IRQ();
154}
155
156void __init
157platform_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
Grant C. Likelye27db622006-01-19 01:13:03 -0700162 identify_ppc_sys_by_id(mfspr(SPRN_PVR));
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 ppc_md.setup_arch = ml300_setup_arch;
165 ppc_md.setup_io_mappings = ml300_map_io;
166 ppc_md.init_IRQ = ml300_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 = ml300_early_serial_map;
174#endif
175}
176