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
22#include <syslib/gen550.h>
23#include <syslib/virtex_devices.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
56const char* virtex_machine_name = "ML300 Reference Design";
57
58#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
59static volatile unsigned *powerdown_base =
60    (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
61
62static void
63xilinx_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
71void __init
72ml300_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
83void __init
84ml300_setup_arch(void)
85{
86	virtex_early_serial_map();
87	ppc4xx_setup_arch();	/* calls ppc4xx_find_bridges() */
88
89	/* Identify the system */
90	printk(KERN_INFO "Xilinx ML300 Reference System (Virtex-II Pro)\n");
91}
92
93/* Called after board_setup_irq from ppc4xx_init_IRQ(). */
94void __init
95ml300_init_irq(void)
96{
97	ppc4xx_init_IRQ();
98}
99
100void __init
101platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
102	      unsigned long r6, unsigned long r7)
103{
104	ppc4xx_init(r3, r4, r5, r6, r7);
105
106	ppc_md.setup_arch = ml300_setup_arch;
107	ppc_md.setup_io_mappings = ml300_map_io;
108	ppc_md.init_IRQ = ml300_init_irq;
109
110#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
111	ppc_md.power_off = xilinx_power_off;
112#endif
113
114#ifdef CONFIG_KGDB
115	ppc_md.early_serial_map = virtex_early_serial_map;
116#endif
117}
118