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