This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / ppc / platforms / 85xx / mpc8540_ads.c
1 /*
2  * arch/ppc/platforms/85xx/mpc8540_ads.c
3  *
4  * MPC8540ADS 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/module.h>
34
35 #include <asm/system.h>
36 #include <asm/pgtable.h>
37 #include <asm/page.h>
38 #include <asm/atomic.h>
39 #include <asm/time.h>
40 #include <asm/io.h>
41 #include <asm/machdep.h>
42 #include <asm/prom.h>
43 #include <asm/open_pic.h>
44 #include <asm/bootinfo.h>
45 #include <asm/pci-bridge.h>
46 #include <asm/mpc85xx.h>
47 #include <asm/irq.h>
48 #include <asm/immap_85xx.h>
49 #include <asm/kgdb.h>
50 #include <asm/ocp.h>
51 #include <mm/mmu_decl.h>
52
53 #include <syslib/ppc85xx_common.h>
54 #include <syslib/ppc85xx_setup.h>
55
56 struct ocp_gfar_data mpc85xx_tsec1_def = {
57         .interruptTransmit = MPC85xx_IRQ_TSEC1_TX,
58         .interruptError = MPC85xx_IRQ_TSEC1_ERROR,
59         .interruptReceive = MPC85xx_IRQ_TSEC1_RX,
60         .interruptPHY = MPC85xx_IRQ_EXT5,
61         .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR
62                         | GFAR_HAS_RMON
63                         | GFAR_HAS_PHY_INTR | GFAR_HAS_COALESCE),
64         .phyid = 0,
65         .phyregidx = 0,
66 };
67
68 struct ocp_gfar_data mpc85xx_tsec2_def = {
69         .interruptTransmit = MPC85xx_IRQ_TSEC2_TX,
70         .interruptError = MPC85xx_IRQ_TSEC2_ERROR,
71         .interruptReceive = MPC85xx_IRQ_TSEC2_RX,
72         .interruptPHY = MPC85xx_IRQ_EXT5,
73         .flags = (GFAR_HAS_GIGABIT | GFAR_HAS_MULTI_INTR
74                         | GFAR_HAS_RMON
75                         | GFAR_HAS_PHY_INTR | GFAR_HAS_COALESCE),
76         .phyid = 1,
77         .phyregidx = 0,
78 };
79
80 struct ocp_gfar_data mpc85xx_fec_def = {
81         .interruptTransmit = MPC85xx_IRQ_FEC,
82         .interruptError = MPC85xx_IRQ_FEC,
83         .interruptReceive = MPC85xx_IRQ_FEC,
84         .interruptPHY = MPC85xx_IRQ_EXT5,
85         .flags = 0,
86         .phyid = 3,
87         .phyregidx = 0,
88 };
89
90 struct ocp_fs_i2c_data mpc85xx_i2c1_def = {
91         .flags = FS_I2C_SEPARATE_DFSRR,
92 };
93
94 /* ************************************************************************
95  *
96  * Setup the architecture
97  *
98  */
99 static void __init
100 mpc8540ads_setup_arch(void)
101 {
102         struct ocp_def *def;
103         struct ocp_gfar_data *einfo;
104         bd_t *binfo = (bd_t *) __res;
105         unsigned int freq;
106
107         /* get the core frequency */
108         freq = binfo->bi_intfreq;
109
110         if (ppc_md.progress)
111                 ppc_md.progress("mpc8540ads_setup_arch()", 0);
112
113         /* Set loops_per_jiffy to a half-way reasonable value,
114            for use until calibrate_delay gets called. */
115         loops_per_jiffy = freq / HZ;
116
117 #ifdef CONFIG_PCI
118         /* setup PCI host bridges */
119         mpc85xx_setup_hose();
120 #endif
121
122 #ifdef CONFIG_DUMMY_CONSOLE
123         conswitchp = &dummy_con;
124 #endif
125
126 #ifdef CONFIG_SERIAL_8250
127         mpc85xx_early_serial_map();
128 #endif
129
130 #ifdef CONFIG_SERIAL_TEXT_DEBUG
131         /* Invalidate the entry we stole earlier the serial ports
132          * should be properly mapped */
133         invalidate_tlbcam_entry(NUM_TLBCAMS - 1);
134 #endif
135
136         def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 0);
137         if (def) {
138                 einfo = (struct ocp_gfar_data *) def->additions;
139                 memcpy(einfo->mac_addr, binfo->bi_enetaddr, 6);
140         }
141
142         def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 1);
143         if (def) {
144                 einfo = (struct ocp_gfar_data *) def->additions;
145                 memcpy(einfo->mac_addr, binfo->bi_enet1addr, 6);
146         }
147
148         def = ocp_get_one_device(OCP_VENDOR_FREESCALE, OCP_FUNC_GFAR, 2);
149         if (def) {
150                 einfo = (struct ocp_gfar_data *) def->additions;
151                 memcpy(einfo->mac_addr, binfo->bi_enet2addr, 6);
152         }
153
154 #ifdef CONFIG_BLK_DEV_INITRD
155         if (initrd_start)
156                 ROOT_DEV = Root_RAM0;
157         else
158 #endif
159 #ifdef  CONFIG_ROOT_NFS
160                 ROOT_DEV = Root_NFS;
161 #else
162                 ROOT_DEV = Root_HDA1;
163 #endif
164
165         ocp_for_each_device(mpc85xx_update_paddr_ocp, &(binfo->bi_immr_base));
166 }
167
168 /* ************************************************************************ */
169 void __init
170 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
171               unsigned long r6, unsigned long r7)
172 {
173         /* parse_bootinfo must always be called first */
174         parse_bootinfo(find_bootinfo());
175
176         /*
177          * If we were passed in a board information, copy it into the
178          * residual data area.
179          */
180         if (r3) {
181                 memcpy((void *) __res, (void *) (r3 + KERNELBASE),
182                        sizeof (bd_t));
183         }
184 #ifdef CONFIG_SERIAL_TEXT_DEBUG
185         {
186                 bd_t *binfo = (bd_t *) __res;
187
188                 /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */
189                 settlbcam(NUM_TLBCAMS - 1, binfo->bi_immr_base,
190                           binfo->bi_immr_base, MPC85xx_CCSRBAR_SIZE, _PAGE_IO, 0);
191         }
192 #endif
193
194 #if defined(CONFIG_BLK_DEV_INITRD)
195         /*
196          * If the init RAM disk has been configured in, and there's a valid
197          * starting address for it, set it up.
198          */
199         if (r4) {
200                 initrd_start = r4 + KERNELBASE;
201                 initrd_end = r5 + KERNELBASE;
202         }
203 #endif                          /* CONFIG_BLK_DEV_INITRD */
204
205         /* Copy the kernel command line arguments to a safe place. */
206
207         if (r6) {
208                 *(char *) (r7 + KERNELBASE) = 0;
209                 strcpy(cmd_line, (char *) (r6 + KERNELBASE));
210         }
211
212         /* setup the PowerPC module struct */
213         ppc_md.setup_arch = mpc8540ads_setup_arch;
214         ppc_md.show_cpuinfo = mpc85xx_ads_show_cpuinfo;
215
216         ppc_md.init_IRQ = mpc85xx_ads_init_IRQ;
217         ppc_md.get_irq = openpic_get_irq;
218
219         ppc_md.restart = mpc85xx_restart;
220         ppc_md.power_off = mpc85xx_power_off;
221         ppc_md.halt = mpc85xx_halt;
222
223         ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
224
225         ppc_md.time_init = NULL;
226         ppc_md.set_rtc_time = NULL;
227         ppc_md.get_rtc_time = NULL;
228         ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
229
230 #if defined(CONFIG_SERIAL_8250) && defined(CONFIG_SERIAL_TEXT_DEBUG)
231         ppc_md.progress = gen550_progress;
232 #endif  /* CONFIG_SERIAL_8250 && CONFIG_SERIAL_TEXT_DEBUG */
233
234         if (ppc_md.progress)
235                 ppc_md.progress("mpc8540ads_init(): exit", 0);
236
237         return;
238 }