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