1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#undef DEBUG
17
18#include <linux/init.h>
19#include <linux/pci.h>
20#include <linux/of.h>
21#include <linux/of_address.h>
22#include <linux/root_dev.h>
23#include <linux/initrd.h>
24#include <asm/time.h>
25#include <asm/io.h>
26#include <asm/machdep.h>
27#include <asm/prom.h>
28#include <asm/mpc52xx.h>
29
30
31
32
33
34
35
36
37static const struct of_device_id mpc5200_cdm_ids[] __initconst = {
38 { .compatible = "fsl,mpc5200-cdm", },
39 { .compatible = "mpc5200-cdm", },
40 {}
41};
42
43static const struct of_device_id mpc5200_gpio_ids[] __initconst = {
44 { .compatible = "fsl,mpc5200-gpio", },
45 { .compatible = "mpc5200-gpio", },
46 {}
47};
48
49
50
51
52
53
54
55
56static void __init
57lite5200_fix_clock_config(void)
58{
59 struct device_node *np;
60 struct mpc52xx_cdm __iomem *cdm;
61
62 np = of_find_matching_node(NULL, mpc5200_cdm_ids);
63 cdm = of_iomap(np, 0);
64 of_node_put(np);
65 if (!cdm) {
66 printk(KERN_ERR "%s() failed; expect abnormal behaviour\n",
67 __func__);
68 return;
69 }
70
71
72 out_8(&cdm->ext_48mhz_en, 0x00);
73 out_8(&cdm->fd_enable, 0x01);
74 if (in_be32(&cdm->rstcfg) & 0x40)
75 out_be16(&cdm->fd_counters, 0x0001);
76 else
77 out_be16(&cdm->fd_counters, 0x5555);
78
79
80 iounmap(cdm);
81}
82
83
84
85
86
87
88
89
90static void __init
91lite5200_fix_port_config(void)
92{
93 struct device_node *np;
94 struct mpc52xx_gpio __iomem *gpio;
95 u32 port_config;
96
97 np = of_find_matching_node(NULL, mpc5200_gpio_ids);
98 gpio = of_iomap(np, 0);
99 of_node_put(np);
100 if (!gpio) {
101 printk(KERN_ERR "%s() failed. expect abnormal behavior\n",
102 __func__);
103 return;
104 }
105
106
107 port_config = in_be32(&gpio->port_config);
108
109 port_config &= ~0x00800000;
110
111 port_config &= ~0x00007000;
112 port_config |= 0x00001000;
113
114 port_config &= ~0x03000000;
115 port_config |= 0x01000000;
116
117 pr_debug("port_config: old:%x new:%x\n",
118 in_be32(&gpio->port_config), port_config);
119 out_be32(&gpio->port_config, port_config);
120
121
122 iounmap(gpio);
123}
124
125#ifdef CONFIG_PM
126static void lite5200_suspend_prepare(void __iomem *mbar)
127{
128 u8 pin = 1;
129 u8 level = 0;
130 mpc52xx_set_wakeup_gpio(pin, level);
131
132
133
134
135
136
137
138
139 out_be32(mbar + 0x1048, in_be32(mbar + 0x1048) & ~0x300);
140
141 out_be32(mbar + 0x1050, 0x00000001);
142}
143
144static void lite5200_resume_finish(void __iomem *mbar)
145{
146
147 out_be32(mbar + 0x1050, 0x00010000);
148}
149#endif
150
151static void __init lite5200_setup_arch(void)
152{
153 if (ppc_md.progress)
154 ppc_md.progress("lite5200_setup_arch()", 0);
155
156
157 mpc52xx_map_common_devices();
158
159
160 mpc5200_setup_xlb_arbiter();
161
162
163 lite5200_fix_clock_config();
164 lite5200_fix_port_config();
165
166#ifdef CONFIG_PM
167 mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare;
168 mpc52xx_suspend.board_resume_finish = lite5200_resume_finish;
169 lite5200_pm_init();
170#endif
171
172 mpc52xx_setup_pci();
173}
174
175static const char * const board[] __initconst = {
176 "fsl,lite5200",
177 "fsl,lite5200b",
178 NULL,
179};
180
181
182
183
184static int __init lite5200_probe(void)
185{
186 return of_device_compatible_match(of_root, board);
187}
188
189define_machine(lite5200) {
190 .name = "lite5200",
191 .probe = lite5200_probe,
192 .setup_arch = lite5200_setup_arch,
193 .init = mpc52xx_declare_of_platform_devices,
194 .init_IRQ = mpc52xx_init_irq,
195 .get_irq = mpc52xx_get_irq,
196 .restart = mpc52xx_restart,
197 .calibrate_decr = generic_calibrate_decr,
198};
199