This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / ppc / platforms / 85xx / mpc8560_ads.c
1 /*
2  * arch/ppc/platforms/85xx/mpc8560_ads.c
3  *
4  * MPC8560ADS board specific routines
5  *
6  * Maintainer: Kumar Gala <kumar.gala@freescale.com>
7  *
8  * Copyright 2004 Freescale Semiconductor Inc.
9  *
10  * This program is free software; you can redistribute  it and/or modify it
11  * under  the terms of  the GNU General  Public License as published by the
12  * Free Software Foundation;  either version 2 of the  License, or (at your
13  * option) any later version.
14  */
15
16 #include <linux/config.h>
17 #include <linux/stddef.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/errno.h>
21 #include <linux/reboot.h>
22 #include <linux/pci.h>
23 #include <linux/kdev_t.h>
24 #include <linux/major.h>
25 #include <linux/console.h>
26 #include <linux/delay.h>
27 #include <linux/irq.h>
28 #include <linux/seq_file.h>
29 #include <linux/root_dev.h>
30 #include <linux/serial.h>
31 #include <linux/tty.h>  /* for linux/serial_core.h */
32 #include <linux/serial_core.h>
33 #include <linux/initrd.h>
34 #include <linux/module.h>
35
36 #include <asm/system.h>
37 #include <asm/pgtable.h>
38 #include <asm/page.h>
39 #include <asm/atomic.h>
40 #include <asm/time.h>
41 #include <asm/io.h>
42 #include <asm/machdep.h>
43 #include <asm/prom.h>
44 #include <asm/open_pic.h>
45 #include <asm/bootinfo.h>
46 #include <asm/pci-bridge.h>
47 #include <asm/mpc85xx.h>
48 #include <asm/irq.h>
49 #include <asm/immap_85xx.h>
50 #include <asm/kgdb.h>
51 #include <asm/ocp.h>
52 #include <asm/cpm2.h>
53 #include <mm/mmu_decl.h>
54
55 #include <syslib/cpm2_pic.h>
56 #include <syslib/ppc85xx_common.h>
57 #include <syslib/ppc85xx_setup.h>
58
59 extern void cpm2_reset(void);
60
61 struct ocp_gfar_data mpc85xx_tsec1_def = {
62         .interruptTransmit = MPC85xx_IRQ_TSEC1_TX,
63         .interruptError = MPC85xx_IRQ_TSEC1_ERROR,
64         .interruptReceive = MPC85xx_IRQ_TSEC1_RX,
65         .interruptPHY = MPC85xx_IRQ_EXT5,
66         .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR
67                         | GFAR_HAS_RMON | GFAR_HAS_COALESCE
68                         | GFAR_HAS_PHY_INTR),
69         .phyid = 0,
70         .phyregidx = 0,
71 };
72
73 struct ocp_gfar_data mpc85xx_tsec2_def = {
74         .interruptTransmit = MPC85xx_IRQ_TSEC2_TX,
75         .interruptError = MPC85xx_IRQ_TSEC2_ERROR,
76         .interruptReceive = MPC85xx_IRQ_TSEC2_RX,
77         .interruptPHY = MPC85xx_IRQ_EXT5,
78         .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR
79                         | GFAR_HAS_RMON | GFAR_HAS_COALESCE
80                         | GFAR_HAS_PHY_INTR),
81         .phyid = 1,
82         .phyregidx = 0,
83 };
84
85 struct ocp_fs_i2c_data mpc85xx_i2c1_def = {
86         .flags = FS_I2C_SEPARATE_DFSRR,
87 };
88
89 /* ************************************************************************
90  *
91  * Setup the architecture
92  *
93  */
94
95 static void __init
96 mpc8560ads_setup_arch(void)
97 {
98         struct ocp_def *def;
99         struct ocp_gfar_data *einfo;
100         bd_t *binfo = (bd_t *) __res;
101         unsigned int freq;
102
103         cpm2_reset();
104
105         /* get the core frequency */
106         freq = binfo->bi_intfreq;
107
108         if (ppc_md.progress)
109                 ppc_md.progress("mpc8560ads_setup_arch()", 0);
110
111         /* Set loops_per_jiffy to a half-way reasonable value,
112            for use until calibrate_delay gets called. */
113         loops_per_jiffy = freq / HZ;
114
115 #ifdef CONFIG_PCI
116         /* setup PCI host bridges */
117         mpc85xx_setup_hose();
118 #endif
119
120         def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 0);
121         if (def) {
122                 einfo = (struct ocp_gfar_data *) def->additions;
123                 memcpy(einfo->mac_addr, binfo->bi_enetaddr, 6);
124         }
125
126         def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 1);
127         if (def) {
128                 einfo = (struct ocp_gfar_data *) def->additions;
129                 memcpy(einfo->mac_addr, binfo->bi_enet1addr, 6);
130         }
131
132 #ifdef CONFIG_BLK_DEV_INITRD
133         if (initrd_start)
134                 ROOT_DEV = Root_RAM0;
135         else
136 #endif
137 #ifdef  CONFIG_ROOT_NFS
138                 ROOT_DEV = Root_NFS;
139 #else
140                 ROOT_DEV = Root_HDA1;
141 #endif
142
143         ocp_for_each_device(mpc85xx_update_paddr_ocp, &(binfo->bi_immr_base));
144 }
145
146 static irqreturn_t cpm2_cascade(int irq, void *dev_id, struct pt_regs *regs)
147 {
148         while ((irq = cpm2_get_irq(regs)) >= 0) {
149                 ppc_irq_dispatch_handler(regs, irq);
150         }
151         return IRQ_HANDLED;
152 }
153
154 static void __init
155 mpc8560_ads_init_IRQ(void)
156 {
157         int i;
158         volatile cpm2_map_t *immap = cpm2_immr;
159
160         /* Setup OpenPIC */
161         mpc85xx_ads_init_IRQ();
162
163         /* disable all CPM interupts */
164         immap->im_intctl.ic_simrh = 0x0;
165         immap->im_intctl.ic_simrl = 0x0;
166
167         for (i = CPM_IRQ_OFFSET; i < (NR_CPM_INTS + CPM_IRQ_OFFSET); i++)
168                 irq_desc[i].handler = &cpm2_pic;
169
170         /* Initialize the default interrupt mapping priorities,
171          * in case the boot rom changed something on us.
172          */
173         immap->im_intctl.ic_sicr = 0;
174         immap->im_intctl.ic_scprrh = 0x05309770;
175         immap->im_intctl.ic_scprrl = 0x05309770;
176
177         request_irq(MPC85xx_IRQ_CPM, cpm2_cascade, SA_INTERRUPT, "cpm2_cascade", NULL);
178
179         return;
180 }
181
182
183
184 /* ************************************************************************ */
185 void __init
186 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
187               unsigned long r6, unsigned long r7)
188 {
189         /* parse_bootinfo must always be called first */
190         parse_bootinfo(find_bootinfo());
191
192         /*
193          * If we were passed in a board information, copy it into the
194          * residual data area.
195          */
196         if (r3) {
197                 memcpy((void *) __res, (void *) (r3 + KERNELBASE),
198                        sizeof (bd_t));
199
200         }
201 #if defined(CONFIG_BLK_DEV_INITRD)
202         /*
203          * If the init RAM disk has been configured in, and there's a valid
204          * starting address for it, set it up.
205          */
206         if (r4) {
207                 initrd_start = r4 + KERNELBASE;
208                 initrd_end = r5 + KERNELBASE;
209         }
210 #endif                          /* CONFIG_BLK_DEV_INITRD */
211
212         /* Copy the kernel command line arguments to a safe place. */
213
214         if (r6) {
215                 *(char *) (r7 + KERNELBASE) = 0;
216                 strcpy(cmd_line, (char *) (r6 + KERNELBASE));
217         }
218
219         /* setup the PowerPC module struct */
220         ppc_md.setup_arch = mpc8560ads_setup_arch;
221         ppc_md.show_cpuinfo = mpc85xx_ads_show_cpuinfo;
222
223         ppc_md.init_IRQ = mpc8560_ads_init_IRQ;
224         ppc_md.get_irq = openpic_get_irq;
225
226         ppc_md.restart = mpc85xx_restart;
227         ppc_md.power_off = mpc85xx_power_off;
228         ppc_md.halt = mpc85xx_halt;
229
230         ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
231
232         ppc_md.time_init = NULL;
233         ppc_md.set_rtc_time = NULL;
234         ppc_md.get_rtc_time = NULL;
235         ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
236
237         if (ppc_md.progress)
238                 ppc_md.progress("mpc8560ads_init(): exit", 0);
239
240         return;
241 }