2 * arch/ppc/platforms/lite5200.c
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 )
10 * Maintainer : Sylvain Munaut <tnt@246tNt.com>
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>
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)
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.
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>
34 #include <asm/bootinfo.h>
36 #include <asm/mpc52xx.h>
37 #include <asm/ppc_sys.h>
38 #include <asm/machdep.h>
40 #include <syslib/mpc52xx_pci.h>
43 extern int powersave_nap;
45 /* Board data given by U-Boot */
47 EXPORT_SYMBOL(__res); /* For modules */
50 /* ======================================================================== */
51 /* Platform specific code */
52 /* ======================================================================== */
54 /* Supported PSC function in "preference" order */
55 struct mpc52xx_psc_func mpc52xx_psc_functions[] = {
59 { .id = -1, /* End entry */
66 lite5200_show_cpuinfo(struct seq_file *m)
68 seq_printf(m, "machine\t\t: Freescale LITE5200\n");
74 lite5200_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
76 return (pin == 1) && (idsel==24) ? MPC52xx_IRQ0 : -1;
81 lite5200_setup_cpu(void)
83 struct mpc52xx_cdm __iomem *cdm;
84 struct mpc52xx_gpio __iomem *gpio;
85 struct mpc52xx_intr __iomem *intr;
86 struct mpc52xx_xlb __iomem *xlb;
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);
97 if (!cdm || !gpio || !xlb || !intr) {
98 printk("lite5200.c: Error while mapping CDM/GPIO/XLB/INTR during"
99 "lite5200_setup_cpu\n");
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);
109 out_be16(&cdm->fd_counters, 0x5555);
111 /* Get port mux config */
112 port_config = in_be32(&gpio->port_config);
114 /* 48Mhz internal, pin is GPIO */
115 port_config &= ~0x00800000;
118 port_config &= ~0x00007000; /* Differential mode - USB1 only */
119 port_config |= 0x00001000;
121 /* Commit port config */
122 out_be32(&gpio->port_config, port_config);
124 /* Configure the XLB Arbiter */
125 out_be32(&xlb->master_pri_enable, 0xff);
126 out_be32(&xlb->master_priority, 0x11111111);
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);
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);
141 if (cdm) iounmap(cdm);
142 if (gpio) iounmap(gpio);
143 if (xlb) iounmap(xlb);
144 if (intr) iounmap(intr);
148 lite5200_setup_arch(void)
150 /* CPU & Port mux setup */
151 lite5200_setup_cpu();
154 /* PCI Bridge setup */
155 mpc52xx_find_bridges();
160 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
161 unsigned long r6, unsigned long r7)
163 /* Generic MPC52xx platform initialization */
164 /* TODO Create one and move a max of stuff in it.
165 Put this init in the syslib */
167 struct bi_record *bootinfo = find_bootinfo();
170 parse_bootinfo(bootinfo);
172 /* Load the bd_t board info structure */
174 memcpy((void*)&__res,(void*)(r3+KERNELBASE),
177 #ifdef CONFIG_BLK_DEV_INITRD
178 /* Load the initrd */
180 initrd_start = r4 + KERNELBASE;
181 initrd_end = r5 + KERNELBASE;
185 /* Load the command line */
187 *(char *)(r7+KERNELBASE) = 0;
188 strcpy(cmd_line, (char *)(r6+KERNELBASE));
192 /* PPC Sys identification */
193 identify_ppc_sys_by_id(mfspr(SPRN_SVR));
198 /* No ISA bus by default */
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; */
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;
217 ppc_md.pci_map_irq = lite5200_map_irq;
220 ppc_md.find_end_of_memory = mpc52xx_find_end_of_memory;
221 ppc_md.setup_io_mappings = mpc52xx_map_io;
223 ppc_md.restart = mpc52xx_restart;
224 ppc_md.power_off = mpc52xx_power_off;
225 ppc_md.halt = mpc52xx_halt;
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;
232 ppc_md.calibrate_decr = mpc52xx_calibrate_decr;
233 #ifdef CONFIG_SERIAL_TEXT_DEBUG
234 ppc_md.progress = mpc52xx_progress;