Merge branch 'upstream'
[pandora-kernel.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 <galak@kernel.crashing.org>
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/seq_file.h>
28 #include <linux/root_dev.h>
29 #include <linux/serial.h>
30 #include <linux/tty.h>  /* for linux/serial_core.h */
31 #include <linux/serial_core.h>
32 #include <linux/initrd.h>
33 #include <linux/module.h>
34 #include <linux/fsl_devices.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/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/ppc_sys.h>
51 #include <mm/mmu_decl.h>
52
53 #include <syslib/ppc85xx_setup.h>
54
55 /* ************************************************************************
56  *
57  * Setup the architecture
58  *
59  */
60 static void __init
61 mpc8540ads_setup_arch(void)
62 {
63         bd_t *binfo = (bd_t *) __res;
64         unsigned int freq;
65         struct gianfar_platform_data *pdata;
66         struct gianfar_mdio_data *mdata;
67
68         /* get the core frequency */
69         freq = binfo->bi_intfreq;
70
71         if (ppc_md.progress)
72                 ppc_md.progress("mpc8540ads_setup_arch()", 0);
73
74         /* Set loops_per_jiffy to a half-way reasonable value,
75            for use until calibrate_delay gets called. */
76         loops_per_jiffy = freq / HZ;
77
78 #ifdef CONFIG_PCI
79         /* setup PCI host bridges */
80         mpc85xx_setup_hose();
81 #endif
82
83 #ifdef CONFIG_SERIAL_8250
84         mpc85xx_early_serial_map();
85 #endif
86
87 #ifdef CONFIG_SERIAL_TEXT_DEBUG
88         /* Invalidate the entry we stole earlier the serial ports
89          * should be properly mapped */
90         invalidate_tlbcam_entry(num_tlbcam_entries - 1);
91 #endif
92
93         /* setup the board related info for the MDIO bus */
94         mdata = (struct gianfar_mdio_data *) ppc_sys_get_pdata(MPC85xx_MDIO);
95
96         mdata->irq[0] = MPC85xx_IRQ_EXT5;
97         mdata->irq[1] = MPC85xx_IRQ_EXT5;
98         mdata->irq[2] = -1;
99         mdata->irq[3] = MPC85xx_IRQ_EXT5;
100         mdata->irq[31] = -1;
101
102         /* setup the board related information for the enet controllers */
103         pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
104         if (pdata) {
105                 pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
106                 pdata->bus_id = 0;
107                 pdata->phy_id = 0;
108                 memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
109         }
110
111         pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2);
112         if (pdata) {
113                 pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
114                 pdata->bus_id = 0;
115                 pdata->phy_id = 1;
116                 memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
117         }
118
119         pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_FEC);
120         if (pdata) {
121                 pdata->board_flags = 0;
122                 pdata->bus_id = 0;
123                 pdata->phy_id = 3;
124                 memcpy(pdata->mac_addr, binfo->bi_enet2addr, 6);
125         }
126
127 #ifdef CONFIG_BLK_DEV_INITRD
128         if (initrd_start)
129                 ROOT_DEV = Root_RAM0;
130         else
131 #endif
132 #ifdef  CONFIG_ROOT_NFS
133                 ROOT_DEV = Root_NFS;
134 #else
135                 ROOT_DEV = Root_HDA1;
136 #endif
137 }
138
139 /* ************************************************************************ */
140 void __init
141 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
142               unsigned long r6, unsigned long r7)
143 {
144         /* parse_bootinfo must always be called first */
145         parse_bootinfo(find_bootinfo());
146
147         /*
148          * If we were passed in a board information, copy it into the
149          * residual data area.
150          */
151         if (r3) {
152                 memcpy((void *) __res, (void *) (r3 + KERNELBASE),
153                        sizeof (bd_t));
154         }
155 #ifdef CONFIG_SERIAL_TEXT_DEBUG
156         {
157                 bd_t *binfo = (bd_t *) __res;
158                 struct uart_port p;
159
160                 /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */
161                 settlbcam(num_tlbcam_entries - 1, binfo->bi_immr_base,
162                           binfo->bi_immr_base, MPC85xx_CCSRBAR_SIZE, _PAGE_IO, 0);
163
164                 memset(&p, 0, sizeof (p));
165                 p.iotype = SERIAL_IO_MEM;
166                 p.membase = (void *) binfo->bi_immr_base + MPC85xx_UART0_OFFSET;
167                 p.uartclk = binfo->bi_busfreq;
168
169                 gen550_init(0, &p);
170
171                 memset(&p, 0, sizeof (p));
172                 p.iotype = SERIAL_IO_MEM;
173                 p.membase = (void *) binfo->bi_immr_base + MPC85xx_UART1_OFFSET;
174                 p.uartclk = binfo->bi_busfreq;
175
176                 gen550_init(1, &p);
177         }
178 #endif
179
180 #if defined(CONFIG_BLK_DEV_INITRD)
181         /*
182          * If the init RAM disk has been configured in, and there's a valid
183          * starting address for it, set it up.
184          */
185         if (r4) {
186                 initrd_start = r4 + KERNELBASE;
187                 initrd_end = r5 + KERNELBASE;
188         }
189 #endif                          /* CONFIG_BLK_DEV_INITRD */
190
191         /* Copy the kernel command line arguments to a safe place. */
192
193         if (r6) {
194                 *(char *) (r7 + KERNELBASE) = 0;
195                 strcpy(cmd_line, (char *) (r6 + KERNELBASE));
196         }
197
198         identify_ppc_sys_by_id(mfspr(SPRN_SVR));
199
200         /* setup the PowerPC module struct */
201         ppc_md.setup_arch = mpc8540ads_setup_arch;
202         ppc_md.show_cpuinfo = mpc85xx_ads_show_cpuinfo;
203
204         ppc_md.init_IRQ = mpc85xx_ads_init_IRQ;
205         ppc_md.get_irq = openpic_get_irq;
206
207         ppc_md.restart = mpc85xx_restart;
208         ppc_md.power_off = mpc85xx_power_off;
209         ppc_md.halt = mpc85xx_halt;
210
211         ppc_md.find_end_of_memory = mpc85xx_find_end_of_memory;
212
213         ppc_md.time_init = NULL;
214         ppc_md.set_rtc_time = NULL;
215         ppc_md.get_rtc_time = NULL;
216         ppc_md.calibrate_decr = mpc85xx_calibrate_decr;
217
218 #if defined(CONFIG_SERIAL_8250) && defined(CONFIG_SERIAL_TEXT_DEBUG)
219         ppc_md.progress = gen550_progress;
220 #endif  /* CONFIG_SERIAL_8250 && CONFIG_SERIAL_TEXT_DEBUG */
221 #if defined(CONFIG_SERIAL_8250) && defined(CONFIG_KGDB)
222         ppc_md.early_serial_map = mpc85xx_early_serial_map;
223 #endif  /* CONFIG_SERIAL_8250 && CONFIG_KGDB */
224
225         if (ppc_md.progress)
226                 ppc_md.progress("mpc8540ads_init(): exit", 0);
227
228         return;
229 }