Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / ppc / platforms / 85xx / mpc8560_ads.c
1 /*
2  * MPC8560ADS board specific routines
3  *
4  * Maintainer: Kumar Gala <galak@kernel.crashing.org>
5  *
6  * Copyright 2004 Freescale Semiconductor Inc.
7  *
8  * This program is free software; you can redistribute  it and/or modify it
9  * under  the terms of  the GNU General  Public License as published by the
10  * Free Software Foundation;  either version 2 of the  License, or (at your
11  * option) any later version.
12  */
13
14 #include <linux/config.h>
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/errno.h>
19 #include <linux/reboot.h>
20 #include <linux/pci.h>
21 #include <linux/kdev_t.h>
22 #include <linux/major.h>
23 #include <linux/console.h>
24 #include <linux/delay.h>
25 #include <linux/seq_file.h>
26 #include <linux/root_dev.h>
27 #include <linux/serial.h>
28 #include <linux/tty.h>  /* for linux/serial_core.h */
29 #include <linux/serial_core.h>
30 #include <linux/initrd.h>
31 #include <linux/module.h>
32 #include <linux/fsl_devices.h>
33
34 #include <asm/system.h>
35 #include <asm/pgtable.h>
36 #include <asm/page.h>
37 #include <asm/atomic.h>
38 #include <asm/time.h>
39 #include <asm/io.h>
40 #include <asm/machdep.h>
41 #include <asm/open_pic.h>
42 #include <asm/bootinfo.h>
43 #include <asm/pci-bridge.h>
44 #include <asm/mpc85xx.h>
45 #include <asm/irq.h>
46 #include <asm/immap_85xx.h>
47 #include <asm/kgdb.h>
48 #include <asm/ppc_sys.h>
49 #include <asm/cpm2.h>
50 #include <mm/mmu_decl.h>
51
52 #include <syslib/cpm2_pic.h>
53 #include <syslib/ppc85xx_common.h>
54 #include <syslib/ppc85xx_setup.h>
55
56
57 /* ************************************************************************
58  *
59  * Setup the architecture
60  *
61  */
62
63 static void __init
64 mpc8560ads_setup_arch(void)
65 {
66         bd_t *binfo = (bd_t *) __res;
67         unsigned int freq;
68         struct gianfar_platform_data *pdata;
69         struct gianfar_mdio_data *mdata;
70
71         cpm2_reset();
72
73         /* get the core frequency */
74         freq = binfo->bi_intfreq;
75
76         if (ppc_md.progress)
77                 ppc_md.progress("mpc8560ads_setup_arch()", 0);
78
79         /* Set loops_per_jiffy to a half-way reasonable value,
80            for use until calibrate_delay gets called. */
81         loops_per_jiffy = freq / HZ;
82
83 #ifdef CONFIG_PCI
84         /* setup PCI host bridges */
85         mpc85xx_setup_hose();
86 #endif
87
88         /* setup the board related info for the MDIO bus */
89         mdata = (struct gianfar_mdio_data *) ppc_sys_get_pdata(MPC85xx_MDIO);
90
91         mdata->irq[0] = MPC85xx_IRQ_EXT5;
92         mdata->irq[1] = MPC85xx_IRQ_EXT5;
93         mdata->irq[2] = -1;
94         mdata->irq[3] = MPC85xx_IRQ_EXT5;
95         mdata->irq[31] = -1;
96
97         /* setup the board related information for the enet controllers */
98         pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
99         if (pdata) {
100                 pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
101                 pdata->bus_id = 0;
102                 pdata->phy_id = 0;
103                 memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
104         }
105
106         pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2);
107         if (pdata) {
108                 pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
109                 pdata->bus_id = 0;
110                 pdata->phy_id = 1;
111                 memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
112         }
113
114 #ifdef CONFIG_BLK_DEV_INITRD
115         if (initrd_start)
116                 ROOT_DEV = Root_RAM0;
117         else
118 #endif
119 #ifdef  CONFIG_ROOT_NFS
120                 ROOT_DEV = Root_NFS;
121 #else
122                 ROOT_DEV = Root_HDA1;
123 #endif
124 }
125
126 static irqreturn_t cpm2_cascade(int irq, void *dev_id, struct pt_regs *regs)
127 {
128         while ((irq = cpm2_get_irq(regs)) >= 0)
129                 __do_IRQ(irq, regs);
130         return IRQ_HANDLED;
131 }
132
133 static struct irqaction cpm2_irqaction = {
134         .handler = cpm2_cascade,
135         .flags = SA_INTERRUPT,
136         .mask = CPU_MASK_NONE,
137         .name = "cpm2_cascade",
138 };
139
140 static void __init
141 mpc8560_ads_init_IRQ(void)
142 {
143         /* Setup OpenPIC */
144         mpc85xx_ads_init_IRQ();
145
146         /* Setup CPM2 PIC */
147         cpm2_init_IRQ();
148
149         setup_irq(MPC85xx_IRQ_CPM, &cpm2_irqaction);
150
151         return;
152 }
153
154
155
156 /* ************************************************************************ */
157 void __init
158 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
159               unsigned long r6, unsigned long r7)
160 {
161         /* parse_bootinfo must always be called first */
162         parse_bootinfo(find_bootinfo());
163
164         /*
165          * If we were passed in a board information, copy it into the
166          * residual data area.
167          */
168         if (r3) {
169                 memcpy((void *) __res, (void *) (r3 + KERNELBASE),
170                        sizeof (bd_t));
171
172         }
173 #if defined(CONFIG_BLK_DEV_INITRD)
174         /*
175          * If the init RAM disk has been configured in, and there's a valid
176          * starting address for it, set it up.
177          */
178         if (r4) {
179                 initrd_start = r4 + KERNELBASE;
180                 initrd_end = r5 + KERNELBASE;
181         }
182 #endif                          /* CONFIG_BLK_DEV_INITRD */
183
184         /* Copy the kernel command line arguments to a safe place. */
185
186         if (r6) {
187                 *(char *) (r7 + KERNELBASE) = 0;
188                 strcpy(cmd_line, (char *) (r6 + KERNELBASE));
189         }
190
191         identify_ppc_sys_by_id(mfspr(SPRN_SVR));
192
193         /* setup the PowerPC module struct */
194         ppc_md.setup_arch = mpc8560ads_setup_arch;
195         ppc_md.show_cpuinfo = mpc85xx_ads_show_cpuinfo;
196
197         ppc_md.init_IRQ = mpc8560_ads_init_IRQ;
198         ppc_md.get_irq = openpic_get_irq;
199
200         ppc_md.restart = mpc85xx_restart;
201         ppc_md.power_off = mpc85xx_power_off;
202         ppc_md.halt = mpc85xx_halt;
203
204         ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
205
206         ppc_md.time_init = NULL;
207         ppc_md.set_rtc_time = NULL;
208         ppc_md.get_rtc_time = NULL;
209         ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
210
211         if (ppc_md.progress)
212                 ppc_md.progress("mpc8560ads_init(): exit", 0);
213
214         return;
215 }