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>
39 #include <syslib/mpc52xx_pci.h>
42 extern int powersave_nap;
44 /* Board data given by U-Boot */
46 EXPORT_SYMBOL(__res); /* For modules */
49 /* ======================================================================== */
50 /* Platform specific code */
51 /* ======================================================================== */
53 /* Supported PSC function in "preference" order */
54 struct mpc52xx_psc_func mpc52xx_psc_functions[] = {
58 { .id = -1, /* End entry */
65 lite5200_show_cpuinfo(struct seq_file *m)
67 seq_printf(m, "machine\t\t: Freescale LITE5200\n");
73 lite5200_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
75 return (pin == 1) && (idsel==24) ? MPC52xx_IRQ0 : -1;
80 lite5200_setup_cpu(void)
82 struct mpc52xx_cdm __iomem *cdm;
83 struct mpc52xx_gpio __iomem *gpio;
84 struct mpc52xx_intr __iomem *intr;
85 struct mpc52xx_xlb __iomem *xlb;
91 cdm = ioremap(MPC52xx_PA(MPC52xx_CDM_OFFSET), MPC52xx_CDM_SIZE);
92 gpio = ioremap(MPC52xx_PA(MPC52xx_GPIO_OFFSET), MPC52xx_GPIO_SIZE);
93 xlb = ioremap(MPC52xx_PA(MPC52xx_XLB_OFFSET), MPC52xx_XLB_SIZE);
94 intr = ioremap(MPC52xx_PA(MPC52xx_INTR_OFFSET), MPC52xx_INTR_SIZE);
96 if (!cdm || !gpio || !xlb || !intr) {
97 printk("lite5200.c: Error while mapping CDM/GPIO/XLB/INTR during"
98 "lite5200_setup_cpu\n");
102 /* Use internal 48 Mhz */
103 out_8(&cdm->ext_48mhz_en, 0x00);
104 out_8(&cdm->fd_enable, 0x01);
105 if (in_be32(&cdm->rstcfg) & 0x40) /* Assumes 33Mhz clock */
106 out_be16(&cdm->fd_counters, 0x0001);
108 out_be16(&cdm->fd_counters, 0x5555);
110 /* Get port mux config */
111 port_config = in_be32(&gpio->port_config);
113 /* 48Mhz internal, pin is GPIO */
114 port_config &= ~0x00800000;
117 port_config &= ~0x00007000; /* Differential mode - USB1 only */
118 port_config |= 0x00001000;
120 /* Commit port config */
121 out_be32(&gpio->port_config, port_config);
123 /* Configure the XLB Arbiter */
124 out_be32(&xlb->master_pri_enable, 0xff);
125 out_be32(&xlb->master_priority, 0x11111111);
127 /* Enable ram snooping for 1GB window */
128 out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_SNOOP);
129 out_be32(&xlb->snoop_window, MPC52xx_PCI_TARGET_MEM | 0x1d);
131 /* IRQ[0-3] setup : IRQ0 - Level Active Low */
132 /* IRQ[1-3] - Level Active High */
133 intr_ctrl = in_be32(&intr->ctrl);
134 intr_ctrl &= ~0x00ff0000;
135 intr_ctrl |= 0x00c00000;
136 out_be32(&intr->ctrl, intr_ctrl);
140 if (cdm) iounmap(cdm);
141 if (gpio) iounmap(gpio);
142 if (xlb) iounmap(xlb);
143 if (intr) iounmap(intr);
147 lite5200_setup_arch(void)
149 /* CPU & Port mux setup */
150 lite5200_setup_cpu();
153 /* PCI Bridge setup */
154 mpc52xx_find_bridges();
159 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
160 unsigned long r6, unsigned long r7)
162 /* Generic MPC52xx platform initialization */
163 /* TODO Create one and move a max of stuff in it.
164 Put this init in the syslib */
166 struct bi_record *bootinfo = find_bootinfo();
169 parse_bootinfo(bootinfo);
171 /* Load the bd_t board info structure */
173 memcpy((void*)&__res,(void*)(r3+KERNELBASE),
176 #ifdef CONFIG_BLK_DEV_INITRD
177 /* Load the initrd */
179 initrd_start = r4 + KERNELBASE;
180 initrd_end = r5 + KERNELBASE;
184 /* Load the command line */
186 *(char *)(r7+KERNELBASE) = 0;
187 strcpy(cmd_line, (char *)(r6+KERNELBASE));
191 /* PPC Sys identification */
192 identify_ppc_sys_by_id(mfspr(SPRN_SVR));
197 /* No ISA bus by default */
202 /* This is provided as an example on how to do it. But you
203 need to be aware that NAP disable bus snoop and that may
204 be required for some devices to work properly, like USB ... */
205 /* powersave_nap = 1; */
208 /* Setup the ppc_md struct */
209 ppc_md.setup_arch = lite5200_setup_arch;
210 ppc_md.show_cpuinfo = lite5200_show_cpuinfo;
211 ppc_md.show_percpuinfo = NULL;
212 ppc_md.init_IRQ = mpc52xx_init_irq;
213 ppc_md.get_irq = mpc52xx_get_irq;
216 ppc_md.pci_map_irq = lite5200_map_irq;
219 ppc_md.find_end_of_memory = mpc52xx_find_end_of_memory;
220 ppc_md.setup_io_mappings = mpc52xx_map_io;
222 ppc_md.restart = mpc52xx_restart;
223 ppc_md.power_off = mpc52xx_power_off;
224 ppc_md.halt = mpc52xx_halt;
226 /* No time keeper on the LITE5200 */
227 ppc_md.time_init = NULL;
228 ppc_md.get_rtc_time = NULL;
229 ppc_md.set_rtc_time = NULL;
231 ppc_md.calibrate_decr = mpc52xx_calibrate_decr;
232 #ifdef CONFIG_SERIAL_TEXT_DEBUG
233 ppc_md.progress = mpc52xx_progress;