blob: ce3f6951828eea16e4450e4d1c42945125a6f33e [file] [log] [blame]
Grant Likely6b642532006-11-27 14:16:28 -07001/*
2 * Freescale Lite5200 board support
3 *
4 * Written by: Grant Likely <grant.likely@secretlab.ca>
5 *
6 * Copyright (C) Secret Lab Technologies Ltd. 2006. All rights reserved.
7 * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
8 *
9 * Description:
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#undef DEBUG
17
18#include <linux/stddef.h>
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/errno.h>
22#include <linux/reboot.h>
23#include <linux/pci.h>
24#include <linux/kdev_t.h>
25#include <linux/major.h>
26#include <linux/console.h>
27#include <linux/delay.h>
28#include <linux/seq_file.h>
29#include <linux/root_dev.h>
30#include <linux/initrd.h>
31
32#include <asm/system.h>
33#include <asm/atomic.h>
34#include <asm/time.h>
35#include <asm/io.h>
36#include <asm/machdep.h>
37#include <asm/ipic.h>
Grant Likely6b642532006-11-27 14:16:28 -070038#include <asm/irq.h>
39#include <asm/prom.h>
40#include <asm/udbg.h>
41#include <sysdev/fsl_soc.h>
Grant Likely6b642532006-11-27 14:16:28 -070042#include <asm/of_platform.h>
43
44#include <asm/mpc52xx.h>
45
46/* ************************************************************************
47 *
48 * Setup the architecture
49 *
50 */
51
52static void __init
Grant Likelye3aba812007-02-12 13:36:55 -070053lite5200_setup_cpu(void)
Grant Likely6b642532006-11-27 14:16:28 -070054{
55 struct mpc52xx_gpio __iomem *gpio;
56 u32 port_config;
57
58 /* Map zones */
Grant Likelye3aba812007-02-12 13:36:55 -070059 gpio = mpc52xx_find_and_map("mpc5200-gpio");
Grant Likely6b642532006-11-27 14:16:28 -070060 if (!gpio) {
61 printk(KERN_ERR __FILE__ ": "
62 "Error while mapping GPIO register for port config. "
63 "Expect some abnormal behavior\n");
64 goto error;
65 }
66
67 /* Set port config */
68 port_config = in_be32(&gpio->port_config);
69
70 port_config &= ~0x00800000; /* 48Mhz internal, pin is GPIO */
71
72 port_config &= ~0x00007000; /* USB port : Differential mode */
73 port_config |= 0x00001000; /* USB 1 only */
74
75 port_config &= ~0x03000000; /* ATA CS is on csb_4/5 */
76 port_config |= 0x01000000;
77
78 pr_debug("port_config: old:%x new:%x\n",
79 in_be32(&gpio->port_config), port_config);
80 out_be32(&gpio->port_config, port_config);
81
82 /* Unmap zone */
83error:
84 iounmap(gpio);
85}
86
Domen Puncer2e1ee1f2007-05-07 01:38:52 +100087#ifdef CONFIG_PM
88static u32 descr_a;
89static void lite5200_suspend_prepare(void __iomem *mbar)
90{
91 u8 pin = 1; /* GPIO_WKUP_1 (GPIO_PSC2_4) */
92 u8 level = 0; /* wakeup on low level */
93 mpc52xx_set_wakeup_gpio(pin, level);
94
95 /*
96 * power down usb port
97 * this needs to be called before of-ohci suspend code
98 */
99 descr_a = in_be32(mbar + 0x1048);
100 out_be32(mbar + 0x1048, (descr_a & ~0x200) | 0x100);
101}
102
103static void lite5200_resume_finish(void __iomem *mbar)
104{
105 out_be32(mbar + 0x1048, descr_a);
106}
107#endif
108
Grant Likelye3aba812007-02-12 13:36:55 -0700109static void __init lite5200_setup_arch(void)
Grant Likely6b642532006-11-27 14:16:28 -0700110{
Jon Loeliger7888fbf2007-07-28 04:24:52 +1000111#ifdef CONFIG_PCI
Grant Likely6b642532006-11-27 14:16:28 -0700112 struct device_node *np;
Jon Loeliger7888fbf2007-07-28 04:24:52 +1000113#endif
Grant Likely6b642532006-11-27 14:16:28 -0700114
115 if (ppc_md.progress)
Grant Likelye3aba812007-02-12 13:36:55 -0700116 ppc_md.progress("lite5200_setup_arch()", 0);
Grant Likely6b642532006-11-27 14:16:28 -0700117
Grant Likely6b642532006-11-27 14:16:28 -0700118 /* CPU & Port mux setup */
119 mpc52xx_setup_cpu(); /* Generic */
Grant Likelye3aba812007-02-12 13:36:55 -0700120 lite5200_setup_cpu(); /* Platorm specific */
Grant Likely6b642532006-11-27 14:16:28 -0700121
Domen Puncer2e1ee1f2007-05-07 01:38:52 +1000122#ifdef CONFIG_PM
123 mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare;
124 mpc52xx_suspend.board_resume_finish = lite5200_resume_finish;
125 mpc52xx_pm_init();
126#endif
127
Grant Likelyf42963f2006-12-12 15:13:19 -0700128#ifdef CONFIG_PCI
John Rigby6ec36702007-04-07 08:57:37 +1000129 np = of_find_node_by_type(NULL, "pci");
130 if (np) {
Grant Likelyf42963f2006-12-12 15:13:19 -0700131 mpc52xx_add_bridge(np);
John Rigby6ec36702007-04-07 08:57:37 +1000132 of_node_put(np);
133 }
Grant Likelyf42963f2006-12-12 15:13:19 -0700134#endif
135
Grant Likely6b642532006-11-27 14:16:28 -0700136#ifdef CONFIG_BLK_DEV_INITRD
137 if (initrd_start)
138 ROOT_DEV = Root_RAM0;
139 else
140#endif
141#ifdef CONFIG_ROOT_NFS
142 ROOT_DEV = Root_NFS;
143#else
144 ROOT_DEV = Root_HDA1;
145#endif
146
147}
148
Domen Puncerd3e0e022007-07-09 09:52:03 +0200149static void lite5200_show_cpuinfo(struct seq_file *m)
Grant Likely6b642532006-11-27 14:16:28 -0700150{
151 struct device_node* np = of_find_all_nodes(NULL);
152 const char *model = NULL;
153
154 if (np)
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000155 model = of_get_property(np, "model", NULL);
Grant Likely6b642532006-11-27 14:16:28 -0700156
157 seq_printf(m, "vendor\t\t: Freescale Semiconductor\n");
158 seq_printf(m, "machine\t\t: %s\n", model ? model : "unknown");
159
160 of_node_put(np);
161}
162
163/*
164 * Called very early, MMU is off, device-tree isn't unflattened
165 */
Grant Likelye3aba812007-02-12 13:36:55 -0700166static int __init lite5200_probe(void)
Grant Likely6b642532006-11-27 14:16:28 -0700167{
168 unsigned long node = of_get_flat_dt_root();
169 const char *model = of_get_flat_dt_prop(node, "model", NULL);
170
Grant Likelye3aba812007-02-12 13:36:55 -0700171 if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
172 !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
Grant Likely6b642532006-11-27 14:16:28 -0700173 return 0;
Grant Likelye3aba812007-02-12 13:36:55 -0700174 pr_debug("%s board found\n", model ? model : "unknown");
Grant Likely6b642532006-11-27 14:16:28 -0700175
176 return 1;
177}
178
Grant Likelye3aba812007-02-12 13:36:55 -0700179define_machine(lite5200) {
180 .name = "lite5200",
181 .probe = lite5200_probe,
182 .setup_arch = lite5200_setup_arch,
Sylvain Munaut5c334ee2007-01-02 23:29:53 +0100183 .init = mpc52xx_declare_of_platform_devices,
Grant Likely6b642532006-11-27 14:16:28 -0700184 .init_IRQ = mpc52xx_init_irq,
185 .get_irq = mpc52xx_get_irq,
Grant Likelye3aba812007-02-12 13:36:55 -0700186 .show_cpuinfo = lite5200_show_cpuinfo,
Grant Likely6b642532006-11-27 14:16:28 -0700187 .calibrate_decr = generic_calibrate_decr,
188};