blob: d91efe1dc2d1e2ee2cf654be2f3c42446836e69c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Platform support file for the Freescale LITE5200 based on MPC52xx.
3 * A maximum of this file should be moved to syslib/mpc52xx_?????
4 * so that new platform based on MPC52xx need a minimal platform file
5 * ( avoid code duplication )
6 *
7 *
8 * Maintainer : Sylvain Munaut <tnt@246tNt.com>
9 *
10 * Based on the 2.4 code written by Kent Borg,
11 * Dale Farnsworth <dale.farnsworth@mvista.com> and
12 * Wolfgang Denk <wd@denx.de>
13 *
14 * Copyright 2004-2005 Sylvain Munaut <tnt@246tNt.com>
15 * Copyright 2003 Motorola Inc.
16 * Copyright 2003 MontaVista Software Inc.
17 * Copyright 2003 DENX Software Engineering (wd@denx.de)
18 *
19 * This file is licensed under the terms of the GNU General Public License
20 * version 2. This program is licensed "as is" without any warranty of any
21 * kind, whether express or implied.
22 */
23
24#include <linux/config.h>
25#include <linux/initrd.h>
26#include <linux/seq_file.h>
27#include <linux/kdev_t.h>
28#include <linux/root_dev.h>
29#include <linux/console.h>
30#include <linux/module.h>
31
32#include <asm/bootinfo.h>
33#include <asm/io.h>
34#include <asm/mpc52xx.h>
35#include <asm/ppc_sys.h>
Paul Mackerrasfd582ec2005-10-11 22:08:12 +100036#include <asm/machdep.h>
Sylvain Munautf8dd3112006-03-26 13:37:38 +020037#include <asm/pci-bridge.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39#include <syslib/mpc52xx_pci.h>
40
41
42extern int powersave_nap;
43
44/* Board data given by U-Boot */
45bd_t __res;
46EXPORT_SYMBOL(__res); /* For modules */
47
48
49/* ======================================================================== */
50/* Platform specific code */
51/* ======================================================================== */
52
53/* Supported PSC function in "preference" order */
54struct mpc52xx_psc_func mpc52xx_psc_functions[] = {
55 { .id = 0,
56 .func = "uart",
57 },
58 { .id = -1, /* End entry */
59 .func = NULL,
60 }
61 };
62
63
64static int
65lite5200_show_cpuinfo(struct seq_file *m)
66{
67 seq_printf(m, "machine\t\t: Freescale LITE5200\n");
68 return 0;
69}
70
71#ifdef CONFIG_PCI
Sylvain Munautf8dd3112006-03-26 13:37:38 +020072#ifdef CONFIG_LITE5200B
73static int
74lite5200_map_irq(struct pci_dev *dev, unsigned char idsel,
75 unsigned char pin)
76{
77 static char pci_irq_table[][4] =
78 /*
79 * PCI IDSEL/INTPIN->INTLINE
80 * A B C D
81 */
82 {
83 {MPC52xx_IRQ0, MPC52xx_IRQ1, MPC52xx_IRQ2, MPC52xx_IRQ3},
84 {MPC52xx_IRQ1, MPC52xx_IRQ2, MPC52xx_IRQ3, MPC52xx_IRQ0},
85 };
86
87 const long min_idsel = 24, max_idsel = 25, irqs_per_slot = 4;
88 return PCI_IRQ_TABLE_LOOKUP;
89}
90#else /* Original Lite */
Linus Torvalds1da177e2005-04-16 15:20:36 -070091static int
92lite5200_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
93{
94 return (pin == 1) && (idsel==24) ? MPC52xx_IRQ0 : -1;
95}
96#endif
Sylvain Munautf8dd3112006-03-26 13:37:38 +020097#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
99static void __init
100lite5200_setup_cpu(void)
101{
102 struct mpc52xx_cdm __iomem *cdm;
103 struct mpc52xx_gpio __iomem *gpio;
104 struct mpc52xx_intr __iomem *intr;
105 struct mpc52xx_xlb __iomem *xlb;
106
107 u32 port_config;
108 u32 intr_ctrl;
109
110 /* Map zones */
111 cdm = ioremap(MPC52xx_PA(MPC52xx_CDM_OFFSET), MPC52xx_CDM_SIZE);
112 gpio = ioremap(MPC52xx_PA(MPC52xx_GPIO_OFFSET), MPC52xx_GPIO_SIZE);
113 xlb = ioremap(MPC52xx_PA(MPC52xx_XLB_OFFSET), MPC52xx_XLB_SIZE);
114 intr = ioremap(MPC52xx_PA(MPC52xx_INTR_OFFSET), MPC52xx_INTR_SIZE);
115
116 if (!cdm || !gpio || !xlb || !intr) {
117 printk("lite5200.c: Error while mapping CDM/GPIO/XLB/INTR during"
118 "lite5200_setup_cpu\n");
119 goto unmap_regs;
120 }
121
122 /* Use internal 48 Mhz */
123 out_8(&cdm->ext_48mhz_en, 0x00);
124 out_8(&cdm->fd_enable, 0x01);
125 if (in_be32(&cdm->rstcfg) & 0x40) /* Assumes 33Mhz clock */
126 out_be16(&cdm->fd_counters, 0x0001);
127 else
128 out_be16(&cdm->fd_counters, 0x5555);
129
130 /* Get port mux config */
131 port_config = in_be32(&gpio->port_config);
132
133 /* 48Mhz internal, pin is GPIO */
134 port_config &= ~0x00800000;
135
136 /* USB port */
137 port_config &= ~0x00007000; /* Differential mode - USB1 only */
138 port_config |= 0x00001000;
139
140 /* Commit port config */
141 out_be32(&gpio->port_config, port_config);
142
143 /* Configure the XLB Arbiter */
144 out_be32(&xlb->master_pri_enable, 0xff);
145 out_be32(&xlb->master_priority, 0x11111111);
146
147 /* Enable ram snooping for 1GB window */
148 out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_SNOOP);
149 out_be32(&xlb->snoop_window, MPC52xx_PCI_TARGET_MEM | 0x1d);
150
Sylvain Munautf8dd3112006-03-26 13:37:38 +0200151 /* IRQ[0-3] setup */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 intr_ctrl = in_be32(&intr->ctrl);
153 intr_ctrl &= ~0x00ff0000;
Sylvain Munautf8dd3112006-03-26 13:37:38 +0200154#ifdef CONFIG_LITE5200B
155 /* IRQ[0-3] Level Active Low */
156 intr_ctrl |= 0x00ff0000;
157#else
158 /* IRQ0 Level Active Low
159 * IRQ[1-3] Level Active High */
160 intr_ctrl |= 0x00c00000;
161#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 out_be32(&intr->ctrl, intr_ctrl);
163
164 /* Unmap reg zone */
165unmap_regs:
166 if (cdm) iounmap(cdm);
167 if (gpio) iounmap(gpio);
168 if (xlb) iounmap(xlb);
169 if (intr) iounmap(intr);
170}
171
172static void __init
173lite5200_setup_arch(void)
174{
175 /* CPU & Port mux setup */
176 lite5200_setup_cpu();
177
178#ifdef CONFIG_PCI
179 /* PCI Bridge setup */
180 mpc52xx_find_bridges();
181#endif
182}
183
184void __init
185platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
186 unsigned long r6, unsigned long r7)
187{
188 /* Generic MPC52xx platform initialization */
189 /* TODO Create one and move a max of stuff in it.
190 Put this init in the syslib */
191
192 struct bi_record *bootinfo = find_bootinfo();
193
194 if (bootinfo)
195 parse_bootinfo(bootinfo);
196 else {
197 /* Load the bd_t board info structure */
198 if (r3)
199 memcpy((void*)&__res,(void*)(r3+KERNELBASE),
200 sizeof(bd_t));
201
202#ifdef CONFIG_BLK_DEV_INITRD
203 /* Load the initrd */
204 if (r4) {
205 initrd_start = r4 + KERNELBASE;
206 initrd_end = r5 + KERNELBASE;
207 }
208#endif
209
210 /* Load the command line */
211 if (r6) {
212 *(char *)(r7+KERNELBASE) = 0;
213 strcpy(cmd_line, (char *)(r6+KERNELBASE));
214 }
215 }
216
217 /* PPC Sys identification */
218 identify_ppc_sys_by_id(mfspr(SPRN_SVR));
219
220 /* BAT setup */
221 mpc52xx_set_bat();
222
223 /* No ISA bus by default */
Sylvain Munautf80257a2006-01-06 00:11:38 -0800224#ifdef CONFIG_PCI
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 isa_io_base = 0;
226 isa_mem_base = 0;
Sylvain Munautf80257a2006-01-06 00:11:38 -0800227#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228
229 /* Powersave */
230 /* This is provided as an example on how to do it. But you
231 need to be aware that NAP disable bus snoop and that may
232 be required for some devices to work properly, like USB ... */
233 /* powersave_nap = 1; */
234
235
236 /* Setup the ppc_md struct */
237 ppc_md.setup_arch = lite5200_setup_arch;
238 ppc_md.show_cpuinfo = lite5200_show_cpuinfo;
239 ppc_md.show_percpuinfo = NULL;
240 ppc_md.init_IRQ = mpc52xx_init_irq;
241 ppc_md.get_irq = mpc52xx_get_irq;
242
243#ifdef CONFIG_PCI
244 ppc_md.pci_map_irq = lite5200_map_irq;
245#endif
246
247 ppc_md.find_end_of_memory = mpc52xx_find_end_of_memory;
248 ppc_md.setup_io_mappings = mpc52xx_map_io;
249
250 ppc_md.restart = mpc52xx_restart;
251 ppc_md.power_off = mpc52xx_power_off;
252 ppc_md.halt = mpc52xx_halt;
253
254 /* No time keeper on the LITE5200 */
255 ppc_md.time_init = NULL;
256 ppc_md.get_rtc_time = NULL;
257 ppc_md.set_rtc_time = NULL;
258
259 ppc_md.calibrate_decr = mpc52xx_calibrate_decr;
260#ifdef CONFIG_SERIAL_TEXT_DEBUG
261 ppc_md.progress = mpc52xx_progress;
262#endif
263}
264