]>
Commit | Line | Data |
---|---|---|
eed32001 KG |
1 | /* |
2 | * FSL SoC setup code | |
3 | * | |
4 | * Maintained by Kumar Gala (see MAINTAINERS for contact information) | |
5 | * | |
fba43665 VB |
6 | * 2006 (c) MontaVista Software, Inc. |
7 | * Vitaly Bordug <vbordug@ru.mvista.com> | |
8 | * | |
eed32001 KG |
9 | * This program is free software; you can redistribute it and/or modify it |
10 | * under the terms of the GNU General Public License as published by the | |
11 | * Free Software Foundation; either version 2 of the License, or (at your | |
12 | * option) any later version. | |
13 | */ | |
14 | ||
eed32001 KG |
15 | #include <linux/stddef.h> |
16 | #include <linux/kernel.h> | |
17 | #include <linux/init.h> | |
18 | #include <linux/errno.h> | |
19 | #include <linux/major.h> | |
20 | #include <linux/delay.h> | |
21 | #include <linux/irq.h> | |
22 | #include <linux/module.h> | |
23 | #include <linux/device.h> | |
24 | #include <linux/platform_device.h> | |
0af666fa | 25 | #include <linux/of_platform.h> |
a9b14973 | 26 | #include <linux/phy.h> |
eed32001 | 27 | #include <linux/fsl_devices.h> |
fba43665 VB |
28 | #include <linux/fs_enet_pd.h> |
29 | #include <linux/fs_uart_pd.h> | |
eed32001 KG |
30 | |
31 | #include <asm/system.h> | |
32 | #include <asm/atomic.h> | |
33 | #include <asm/io.h> | |
34 | #include <asm/irq.h> | |
fba43665 | 35 | #include <asm/time.h> |
eed32001 KG |
36 | #include <asm/prom.h> |
37 | #include <sysdev/fsl_soc.h> | |
38 | #include <mm/mmu_decl.h> | |
fba43665 | 39 | #include <asm/cpm2.h> |
eed32001 | 40 | |
d3465c92 | 41 | extern void init_fcc_ioports(struct fs_platform_info*); |
88bdc6f0 VB |
42 | extern void init_fec_ioports(struct fs_platform_info*); |
43 | extern void init_smc_ioports(struct fs_uart_platform_info*); | |
eed32001 KG |
44 | static phys_addr_t immrbase = -1; |
45 | ||
46 | phys_addr_t get_immrbase(void) | |
47 | { | |
48 | struct device_node *soc; | |
49 | ||
50 | if (immrbase != -1) | |
51 | return immrbase; | |
52 | ||
53 | soc = of_find_node_by_type(NULL, "soc"); | |
2fb07d77 | 54 | if (soc) { |
eed32001 | 55 | unsigned int size; |
e2eb6392 | 56 | const void *prop = of_get_property(soc, "reg", &size); |
fba43665 VB |
57 | |
58 | if (prop) | |
59 | immrbase = of_translate_address(soc, prop); | |
eed32001 KG |
60 | of_node_put(soc); |
61 | }; | |
62 | ||
63 | return immrbase; | |
64 | } | |
eed32001 | 65 | |
2fb07d77 | 66 | EXPORT_SYMBOL(get_immrbase); |
eed32001 | 67 | |
88bdc6f0 | 68 | #if defined(CONFIG_CPM2) || defined(CONFIG_8xx) |
fba43665 VB |
69 | |
70 | static u32 brgfreq = -1; | |
71 | ||
72 | u32 get_brgfreq(void) | |
73 | { | |
74 | struct device_node *node; | |
75 | ||
76 | if (brgfreq != -1) | |
77 | return brgfreq; | |
78 | ||
79 | node = of_find_node_by_type(NULL, "cpm"); | |
80 | if (node) { | |
81 | unsigned int size; | |
e2eb6392 SR |
82 | const unsigned int *prop = of_get_property(node, |
83 | "brg-frequency", &size); | |
fba43665 VB |
84 | |
85 | if (prop) | |
86 | brgfreq = *prop; | |
87 | of_node_put(node); | |
88 | }; | |
89 | ||
90 | return brgfreq; | |
91 | } | |
92 | ||
93 | EXPORT_SYMBOL(get_brgfreq); | |
94 | ||
95 | static u32 fs_baudrate = -1; | |
96 | ||
97 | u32 get_baudrate(void) | |
98 | { | |
99 | struct device_node *node; | |
100 | ||
101 | if (fs_baudrate != -1) | |
102 | return fs_baudrate; | |
103 | ||
104 | node = of_find_node_by_type(NULL, "serial"); | |
105 | if (node) { | |
106 | unsigned int size; | |
e2eb6392 SR |
107 | const unsigned int *prop = of_get_property(node, |
108 | "current-speed", &size); | |
fba43665 VB |
109 | |
110 | if (prop) | |
111 | fs_baudrate = *prop; | |
112 | of_node_put(node); | |
113 | }; | |
114 | ||
115 | return fs_baudrate; | |
116 | } | |
117 | ||
118 | EXPORT_SYMBOL(get_baudrate); | |
119 | #endif /* CONFIG_CPM2 */ | |
120 | ||
2fb07d77 | 121 | static int __init gfar_mdio_of_init(void) |
eed32001 KG |
122 | { |
123 | struct device_node *np; | |
124 | unsigned int i; | |
2fb07d77 | 125 | struct platform_device *mdio_dev; |
eed32001 KG |
126 | struct resource res; |
127 | int ret; | |
128 | ||
2fb07d77 KG |
129 | for (np = NULL, i = 0; |
130 | (np = of_find_compatible_node(np, "mdio", "gianfar")) != NULL; | |
131 | i++) { | |
eed32001 KG |
132 | int k; |
133 | struct device_node *child = NULL; | |
134 | struct gianfar_mdio_data mdio_data; | |
135 | ||
136 | memset(&res, 0, sizeof(res)); | |
137 | memset(&mdio_data, 0, sizeof(mdio_data)); | |
138 | ||
139 | ret = of_address_to_resource(np, 0, &res); | |
140 | if (ret) | |
2fb07d77 | 141 | goto err; |
eed32001 | 142 | |
2fb07d77 KG |
143 | mdio_dev = |
144 | platform_device_register_simple("fsl-gianfar_mdio", | |
145 | res.start, &res, 1); | |
eed32001 KG |
146 | if (IS_ERR(mdio_dev)) { |
147 | ret = PTR_ERR(mdio_dev); | |
2fb07d77 | 148 | goto err; |
eed32001 KG |
149 | } |
150 | ||
151 | for (k = 0; k < 32; k++) | |
a9b14973 | 152 | mdio_data.irq[k] = PHY_POLL; |
eed32001 KG |
153 | |
154 | while ((child = of_get_next_child(np, child)) != NULL) { | |
fba43665 VB |
155 | int irq = irq_of_parse_and_map(child, 0); |
156 | if (irq != NO_IRQ) { | |
e2eb6392 SR |
157 | const u32 *id = of_get_property(child, |
158 | "reg", NULL); | |
fba43665 VB |
159 | mdio_data.irq[*id] = irq; |
160 | } | |
eed32001 KG |
161 | } |
162 | ||
2fb07d77 KG |
163 | ret = |
164 | platform_device_add_data(mdio_dev, &mdio_data, | |
165 | sizeof(struct gianfar_mdio_data)); | |
eed32001 | 166 | if (ret) |
2fb07d77 | 167 | goto unreg; |
eed32001 KG |
168 | } |
169 | ||
2fb07d77 KG |
170 | return 0; |
171 | ||
172 | unreg: | |
173 | platform_device_unregister(mdio_dev); | |
174 | err: | |
175 | return ret; | |
176 | } | |
177 | ||
178 | arch_initcall(gfar_mdio_of_init); | |
179 | ||
180 | static const char *gfar_tx_intr = "tx"; | |
181 | static const char *gfar_rx_intr = "rx"; | |
182 | static const char *gfar_err_intr = "error"; | |
183 | ||
a9b14973 | 184 | |
2fb07d77 KG |
185 | static int __init gfar_of_init(void) |
186 | { | |
187 | struct device_node *np; | |
188 | unsigned int i; | |
189 | struct platform_device *gfar_dev; | |
190 | struct resource res; | |
191 | int ret; | |
192 | ||
193 | for (np = NULL, i = 0; | |
194 | (np = of_find_compatible_node(np, "network", "gianfar")) != NULL; | |
195 | i++) { | |
eed32001 KG |
196 | struct resource r[4]; |
197 | struct device_node *phy, *mdio; | |
198 | struct gianfar_platform_data gfar_data; | |
a7f67bdf JK |
199 | const unsigned int *id; |
200 | const char *model; | |
7132ab7f | 201 | const char *ctype; |
a7f67bdf JK |
202 | const void *mac_addr; |
203 | const phandle *ph; | |
fba43665 | 204 | int n_res = 2; |
eed32001 KG |
205 | |
206 | memset(r, 0, sizeof(r)); | |
207 | memset(&gfar_data, 0, sizeof(gfar_data)); | |
208 | ||
209 | ret = of_address_to_resource(np, 0, &r[0]); | |
210 | if (ret) | |
2fb07d77 | 211 | goto err; |
eed32001 | 212 | |
a9b14973 | 213 | of_irq_to_resource(np, 0, &r[1]); |
eed32001 | 214 | |
e2eb6392 | 215 | model = of_get_property(np, "model", NULL); |
eed32001 KG |
216 | |
217 | /* If we aren't the FEC we have multiple interrupts */ | |
218 | if (model && strcasecmp(model, "FEC")) { | |
219 | r[1].name = gfar_tx_intr; | |
220 | ||
221 | r[2].name = gfar_rx_intr; | |
a9b14973 | 222 | of_irq_to_resource(np, 1, &r[2]); |
eed32001 KG |
223 | |
224 | r[3].name = gfar_err_intr; | |
a9b14973 | 225 | of_irq_to_resource(np, 2, &r[3]); |
919fede6 JL |
226 | |
227 | n_res += 2; | |
eed32001 KG |
228 | } |
229 | ||
2fb07d77 KG |
230 | gfar_dev = |
231 | platform_device_register_simple("fsl-gianfar", i, &r[0], | |
fba43665 | 232 | n_res); |
eed32001 KG |
233 | |
234 | if (IS_ERR(gfar_dev)) { | |
235 | ret = PTR_ERR(gfar_dev); | |
2fb07d77 | 236 | goto err; |
eed32001 KG |
237 | } |
238 | ||
29cfe6f4 | 239 | mac_addr = of_get_mac_address(np); |
f583165f JL |
240 | if (mac_addr) |
241 | memcpy(gfar_data.mac_addr, mac_addr, 6); | |
eed32001 KG |
242 | |
243 | if (model && !strcasecmp(model, "TSEC")) | |
244 | gfar_data.device_flags = | |
2fb07d77 KG |
245 | FSL_GIANFAR_DEV_HAS_GIGABIT | |
246 | FSL_GIANFAR_DEV_HAS_COALESCE | | |
247 | FSL_GIANFAR_DEV_HAS_RMON | | |
248 | FSL_GIANFAR_DEV_HAS_MULTI_INTR; | |
eed32001 KG |
249 | if (model && !strcasecmp(model, "eTSEC")) |
250 | gfar_data.device_flags = | |
2fb07d77 KG |
251 | FSL_GIANFAR_DEV_HAS_GIGABIT | |
252 | FSL_GIANFAR_DEV_HAS_COALESCE | | |
253 | FSL_GIANFAR_DEV_HAS_RMON | | |
254 | FSL_GIANFAR_DEV_HAS_MULTI_INTR | | |
255 | FSL_GIANFAR_DEV_HAS_CSUM | | |
256 | FSL_GIANFAR_DEV_HAS_VLAN | | |
257 | FSL_GIANFAR_DEV_HAS_EXTENDED_HASH; | |
eed32001 | 258 | |
7132ab7f AF |
259 | ctype = of_get_property(np, "phy-connection-type", NULL); |
260 | ||
261 | /* We only care about rgmii-id. The rest are autodetected */ | |
262 | if (ctype && !strcmp(ctype, "rgmii-id")) | |
263 | gfar_data.interface = PHY_INTERFACE_MODE_RGMII_ID; | |
264 | else | |
265 | gfar_data.interface = PHY_INTERFACE_MODE_MII; | |
266 | ||
e2eb6392 | 267 | ph = of_get_property(np, "phy-handle", NULL); |
eed32001 KG |
268 | phy = of_find_node_by_phandle(*ph); |
269 | ||
270 | if (phy == NULL) { | |
271 | ret = -ENODEV; | |
2fb07d77 | 272 | goto unreg; |
eed32001 KG |
273 | } |
274 | ||
275 | mdio = of_get_parent(phy); | |
276 | ||
e2eb6392 | 277 | id = of_get_property(phy, "reg", NULL); |
eed32001 KG |
278 | ret = of_address_to_resource(mdio, 0, &res); |
279 | if (ret) { | |
280 | of_node_put(phy); | |
281 | of_node_put(mdio); | |
2fb07d77 | 282 | goto unreg; |
eed32001 KG |
283 | } |
284 | ||
285 | gfar_data.phy_id = *id; | |
286 | gfar_data.bus_id = res.start; | |
287 | ||
288 | of_node_put(phy); | |
289 | of_node_put(mdio); | |
290 | ||
2fb07d77 KG |
291 | ret = |
292 | platform_device_add_data(gfar_dev, &gfar_data, | |
293 | sizeof(struct | |
294 | gianfar_platform_data)); | |
eed32001 | 295 | if (ret) |
2fb07d77 | 296 | goto unreg; |
eed32001 KG |
297 | } |
298 | ||
299 | return 0; | |
300 | ||
2fb07d77 | 301 | unreg: |
eed32001 | 302 | platform_device_unregister(gfar_dev); |
2fb07d77 | 303 | err: |
eed32001 KG |
304 | return ret; |
305 | } | |
2fb07d77 | 306 | |
eed32001 KG |
307 | arch_initcall(gfar_of_init); |
308 | ||
d13ae862 GL |
309 | #ifdef CONFIG_I2C_BOARDINFO |
310 | #include <linux/i2c.h> | |
311 | struct i2c_driver_device { | |
312 | char *of_device; | |
313 | char *i2c_driver; | |
314 | char *i2c_type; | |
315 | }; | |
316 | ||
317 | static struct i2c_driver_device i2c_devices[] __initdata = { | |
318 | {"ricoh,rs5c372a", "rtc-rs5c372", "rs5c372a",}, | |
319 | {"ricoh,rs5c372b", "rtc-rs5c372", "rs5c372b",}, | |
320 | {"ricoh,rv5c386", "rtc-rs5c372", "rv5c386",}, | |
321 | {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",}, | |
322 | }; | |
323 | ||
e78bb5dc GL |
324 | static int __init of_find_i2c_driver(struct device_node *node, |
325 | struct i2c_board_info *info) | |
d13ae862 GL |
326 | { |
327 | int i; | |
328 | ||
329 | for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) { | |
330 | if (!of_device_is_compatible(node, i2c_devices[i].of_device)) | |
331 | continue; | |
e78bb5dc GL |
332 | if (strlcpy(info->driver_name, i2c_devices[i].i2c_driver, |
333 | KOBJ_NAME_LEN) >= KOBJ_NAME_LEN || | |
334 | strlcpy(info->type, i2c_devices[i].i2c_type, | |
335 | I2C_NAME_SIZE) >= I2C_NAME_SIZE) | |
336 | return -ENOMEM; | |
d13ae862 GL |
337 | return 0; |
338 | } | |
339 | return -ENODEV; | |
340 | } | |
341 | ||
e78bb5dc GL |
342 | static void __init of_register_i2c_devices(struct device_node *adap_node, |
343 | int bus_num) | |
d13ae862 GL |
344 | { |
345 | struct device_node *node = NULL; | |
346 | ||
347 | while ((node = of_get_next_child(adap_node, node))) { | |
348 | struct i2c_board_info info; | |
349 | const u32 *addr; | |
350 | int len; | |
351 | ||
352 | addr = of_get_property(node, "reg", &len); | |
353 | if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) { | |
354 | printk(KERN_WARNING "fsl_ioc.c: invalid i2c device entry\n"); | |
355 | continue; | |
356 | } | |
357 | ||
358 | info.irq = irq_of_parse_and_map(node, 0); | |
359 | if (info.irq == NO_IRQ) | |
360 | info.irq = -1; | |
361 | ||
362 | if (of_find_i2c_driver(node, &info) < 0) | |
363 | continue; | |
364 | ||
365 | info.platform_data = NULL; | |
366 | info.addr = *addr; | |
367 | ||
368 | i2c_register_board_info(bus_num, &info, 1); | |
369 | } | |
370 | } | |
371 | ||
eed32001 KG |
372 | static int __init fsl_i2c_of_init(void) |
373 | { | |
374 | struct device_node *np; | |
375 | unsigned int i; | |
376 | struct platform_device *i2c_dev; | |
377 | int ret; | |
378 | ||
2fb07d77 KG |
379 | for (np = NULL, i = 0; |
380 | (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL; | |
381 | i++) { | |
eed32001 KG |
382 | struct resource r[2]; |
383 | struct fsl_i2c_platform_data i2c_data; | |
a7f67bdf | 384 | const unsigned char *flags = NULL; |
eed32001 KG |
385 | |
386 | memset(&r, 0, sizeof(r)); | |
387 | memset(&i2c_data, 0, sizeof(i2c_data)); | |
388 | ||
389 | ret = of_address_to_resource(np, 0, &r[0]); | |
390 | if (ret) | |
2fb07d77 | 391 | goto err; |
eed32001 | 392 | |
a9b14973 | 393 | of_irq_to_resource(np, 0, &r[1]); |
eed32001 KG |
394 | |
395 | i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2); | |
396 | if (IS_ERR(i2c_dev)) { | |
397 | ret = PTR_ERR(i2c_dev); | |
2fb07d77 | 398 | goto err; |
eed32001 KG |
399 | } |
400 | ||
401 | i2c_data.device_flags = 0; | |
e2eb6392 | 402 | flags = of_get_property(np, "dfsrr", NULL); |
eed32001 KG |
403 | if (flags) |
404 | i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR; | |
405 | ||
e2eb6392 | 406 | flags = of_get_property(np, "fsl5200-clocking", NULL); |
eed32001 KG |
407 | if (flags) |
408 | i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200; | |
409 | ||
2fb07d77 KG |
410 | ret = |
411 | platform_device_add_data(i2c_dev, &i2c_data, | |
412 | sizeof(struct | |
413 | fsl_i2c_platform_data)); | |
eed32001 | 414 | if (ret) |
2fb07d77 | 415 | goto unreg; |
d13ae862 GL |
416 | |
417 | of_register_i2c_devices(np, i); | |
eed32001 KG |
418 | } |
419 | ||
420 | return 0; | |
421 | ||
2fb07d77 | 422 | unreg: |
eed32001 | 423 | platform_device_unregister(i2c_dev); |
2fb07d77 | 424 | err: |
eed32001 KG |
425 | return ret; |
426 | } | |
2fb07d77 | 427 | |
eed32001 | 428 | arch_initcall(fsl_i2c_of_init); |
d13ae862 | 429 | #endif |
eed32001 KG |
430 | |
431 | #ifdef CONFIG_PPC_83xx | |
432 | static int __init mpc83xx_wdt_init(void) | |
433 | { | |
434 | struct resource r; | |
435 | struct device_node *soc, *np; | |
436 | struct platform_device *dev; | |
a7f67bdf | 437 | const unsigned int *freq; |
eed32001 KG |
438 | int ret; |
439 | ||
440 | np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt"); | |
441 | ||
442 | if (!np) { | |
443 | ret = -ENODEV; | |
2fb07d77 | 444 | goto nodev; |
eed32001 KG |
445 | } |
446 | ||
447 | soc = of_find_node_by_type(NULL, "soc"); | |
448 | ||
449 | if (!soc) { | |
450 | ret = -ENODEV; | |
2fb07d77 | 451 | goto nosoc; |
eed32001 KG |
452 | } |
453 | ||
e2eb6392 | 454 | freq = of_get_property(soc, "bus-frequency", NULL); |
eed32001 KG |
455 | if (!freq) { |
456 | ret = -ENODEV; | |
2fb07d77 | 457 | goto err; |
eed32001 KG |
458 | } |
459 | ||
460 | memset(&r, 0, sizeof(r)); | |
461 | ||
462 | ret = of_address_to_resource(np, 0, &r); | |
463 | if (ret) | |
2fb07d77 | 464 | goto err; |
eed32001 KG |
465 | |
466 | dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1); | |
467 | if (IS_ERR(dev)) { | |
468 | ret = PTR_ERR(dev); | |
2fb07d77 | 469 | goto err; |
eed32001 KG |
470 | } |
471 | ||
472 | ret = platform_device_add_data(dev, freq, sizeof(int)); | |
473 | if (ret) | |
2fb07d77 | 474 | goto unreg; |
eed32001 KG |
475 | |
476 | of_node_put(soc); | |
477 | of_node_put(np); | |
478 | ||
479 | return 0; | |
480 | ||
2fb07d77 | 481 | unreg: |
eed32001 | 482 | platform_device_unregister(dev); |
2fb07d77 | 483 | err: |
eed32001 | 484 | of_node_put(soc); |
2fb07d77 | 485 | nosoc: |
eed32001 | 486 | of_node_put(np); |
2fb07d77 | 487 | nodev: |
eed32001 KG |
488 | return ret; |
489 | } | |
2fb07d77 | 490 | |
eed32001 KG |
491 | arch_initcall(mpc83xx_wdt_init); |
492 | #endif | |
4b10cfd4 | 493 | |
a7f67bdf | 494 | static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type) |
4b10cfd4 KG |
495 | { |
496 | if (!phy_type) | |
497 | return FSL_USB2_PHY_NONE; | |
498 | if (!strcasecmp(phy_type, "ulpi")) | |
499 | return FSL_USB2_PHY_ULPI; | |
500 | if (!strcasecmp(phy_type, "utmi")) | |
501 | return FSL_USB2_PHY_UTMI; | |
502 | if (!strcasecmp(phy_type, "utmi_wide")) | |
503 | return FSL_USB2_PHY_UTMI_WIDE; | |
504 | if (!strcasecmp(phy_type, "serial")) | |
505 | return FSL_USB2_PHY_SERIAL; | |
506 | ||
507 | return FSL_USB2_PHY_NONE; | |
508 | } | |
509 | ||
510 | static int __init fsl_usb_of_init(void) | |
511 | { | |
512 | struct device_node *np; | |
513 | unsigned int i; | |
97c5a20a LY |
514 | struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL, |
515 | *usb_dev_dr_client = NULL; | |
4b10cfd4 KG |
516 | int ret; |
517 | ||
518 | for (np = NULL, i = 0; | |
519 | (np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) != NULL; | |
520 | i++) { | |
521 | struct resource r[2]; | |
522 | struct fsl_usb2_platform_data usb_data; | |
a7f67bdf | 523 | const unsigned char *prop = NULL; |
4b10cfd4 KG |
524 | |
525 | memset(&r, 0, sizeof(r)); | |
526 | memset(&usb_data, 0, sizeof(usb_data)); | |
527 | ||
528 | ret = of_address_to_resource(np, 0, &r[0]); | |
529 | if (ret) | |
530 | goto err; | |
531 | ||
a9b14973 | 532 | of_irq_to_resource(np, 0, &r[1]); |
4b10cfd4 | 533 | |
01cced25 KG |
534 | usb_dev_mph = |
535 | platform_device_register_simple("fsl-ehci", i, r, 2); | |
536 | if (IS_ERR(usb_dev_mph)) { | |
537 | ret = PTR_ERR(usb_dev_mph); | |
4b10cfd4 KG |
538 | goto err; |
539 | } | |
540 | ||
01cced25 KG |
541 | usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL; |
542 | usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask; | |
4b10cfd4 KG |
543 | |
544 | usb_data.operating_mode = FSL_USB2_MPH_HOST; | |
545 | ||
e2eb6392 | 546 | prop = of_get_property(np, "port0", NULL); |
4b10cfd4 KG |
547 | if (prop) |
548 | usb_data.port_enables |= FSL_USB2_PORT0_ENABLED; | |
549 | ||
e2eb6392 | 550 | prop = of_get_property(np, "port1", NULL); |
4b10cfd4 KG |
551 | if (prop) |
552 | usb_data.port_enables |= FSL_USB2_PORT1_ENABLED; | |
553 | ||
e2eb6392 | 554 | prop = of_get_property(np, "phy_type", NULL); |
4b10cfd4 KG |
555 | usb_data.phy_mode = determine_usb_phy(prop); |
556 | ||
557 | ret = | |
01cced25 | 558 | platform_device_add_data(usb_dev_mph, &usb_data, |
4b10cfd4 KG |
559 | sizeof(struct |
560 | fsl_usb2_platform_data)); | |
561 | if (ret) | |
01cced25 | 562 | goto unreg_mph; |
4b10cfd4 KG |
563 | } |
564 | ||
01cced25 | 565 | for (np = NULL; |
4b10cfd4 KG |
566 | (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL; |
567 | i++) { | |
568 | struct resource r[2]; | |
569 | struct fsl_usb2_platform_data usb_data; | |
a7f67bdf | 570 | const unsigned char *prop = NULL; |
4b10cfd4 KG |
571 | |
572 | memset(&r, 0, sizeof(r)); | |
573 | memset(&usb_data, 0, sizeof(usb_data)); | |
574 | ||
575 | ret = of_address_to_resource(np, 0, &r[0]); | |
576 | if (ret) | |
01cced25 | 577 | goto unreg_mph; |
4b10cfd4 | 578 | |
a9b14973 | 579 | of_irq_to_resource(np, 0, &r[1]); |
4b10cfd4 | 580 | |
e2eb6392 | 581 | prop = of_get_property(np, "dr_mode", NULL); |
97c5a20a LY |
582 | |
583 | if (!prop || !strcmp(prop, "host")) { | |
584 | usb_data.operating_mode = FSL_USB2_DR_HOST; | |
585 | usb_dev_dr_host = platform_device_register_simple( | |
586 | "fsl-ehci", i, r, 2); | |
587 | if (IS_ERR(usb_dev_dr_host)) { | |
588 | ret = PTR_ERR(usb_dev_dr_host); | |
589 | goto err; | |
590 | } | |
591 | } else if (prop && !strcmp(prop, "peripheral")) { | |
592 | usb_data.operating_mode = FSL_USB2_DR_DEVICE; | |
593 | usb_dev_dr_client = platform_device_register_simple( | |
594 | "fsl-usb2-udc", i, r, 2); | |
595 | if (IS_ERR(usb_dev_dr_client)) { | |
596 | ret = PTR_ERR(usb_dev_dr_client); | |
597 | goto err; | |
598 | } | |
599 | } else if (prop && !strcmp(prop, "otg")) { | |
600 | usb_data.operating_mode = FSL_USB2_DR_OTG; | |
601 | usb_dev_dr_host = platform_device_register_simple( | |
602 | "fsl-ehci", i, r, 2); | |
603 | if (IS_ERR(usb_dev_dr_host)) { | |
604 | ret = PTR_ERR(usb_dev_dr_host); | |
605 | goto err; | |
606 | } | |
607 | usb_dev_dr_client = platform_device_register_simple( | |
608 | "fsl-usb2-udc", i, r, 2); | |
609 | if (IS_ERR(usb_dev_dr_client)) { | |
610 | ret = PTR_ERR(usb_dev_dr_client); | |
611 | goto err; | |
612 | } | |
613 | } else { | |
614 | ret = -EINVAL; | |
4b10cfd4 KG |
615 | goto err; |
616 | } | |
617 | ||
e2eb6392 | 618 | prop = of_get_property(np, "phy_type", NULL); |
4b10cfd4 KG |
619 | usb_data.phy_mode = determine_usb_phy(prop); |
620 | ||
97c5a20a LY |
621 | if (usb_dev_dr_host) { |
622 | usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL; | |
623 | usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host-> | |
624 | dev.coherent_dma_mask; | |
625 | if ((ret = platform_device_add_data(usb_dev_dr_host, | |
626 | &usb_data, sizeof(struct | |
627 | fsl_usb2_platform_data)))) | |
628 | goto unreg_dr; | |
629 | } | |
630 | if (usb_dev_dr_client) { | |
631 | usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL; | |
632 | usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client-> | |
633 | dev.coherent_dma_mask; | |
634 | if ((ret = platform_device_add_data(usb_dev_dr_client, | |
635 | &usb_data, sizeof(struct | |
636 | fsl_usb2_platform_data)))) | |
637 | goto unreg_dr; | |
638 | } | |
4b10cfd4 | 639 | } |
4b10cfd4 KG |
640 | return 0; |
641 | ||
01cced25 | 642 | unreg_dr: |
97c5a20a LY |
643 | if (usb_dev_dr_host) |
644 | platform_device_unregister(usb_dev_dr_host); | |
645 | if (usb_dev_dr_client) | |
646 | platform_device_unregister(usb_dev_dr_client); | |
01cced25 KG |
647 | unreg_mph: |
648 | if (usb_dev_mph) | |
649 | platform_device_unregister(usb_dev_mph); | |
4b10cfd4 KG |
650 | err: |
651 | return ret; | |
652 | } | |
653 | ||
01cced25 | 654 | arch_initcall(fsl_usb_of_init); |
fba43665 VB |
655 | |
656 | #ifdef CONFIG_CPM2 | |
657 | ||
88bdc6f0 VB |
658 | extern void init_scc_ioports(struct fs_uart_platform_info*); |
659 | ||
fba43665 VB |
660 | static const char fcc_regs[] = "fcc_regs"; |
661 | static const char fcc_regs_c[] = "fcc_regs_c"; | |
662 | static const char fcc_pram[] = "fcc_pram"; | |
663 | static char bus_id[9][BUS_ID_SIZE]; | |
664 | ||
665 | static int __init fs_enet_of_init(void) | |
666 | { | |
667 | struct device_node *np; | |
668 | unsigned int i; | |
669 | struct platform_device *fs_enet_dev; | |
670 | struct resource res; | |
671 | int ret; | |
672 | ||
673 | for (np = NULL, i = 0; | |
674 | (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL; | |
675 | i++) { | |
676 | struct resource r[4]; | |
677 | struct device_node *phy, *mdio; | |
678 | struct fs_platform_info fs_enet_data; | |
2b00b254 | 679 | const unsigned int *id, *phy_addr, *phy_irq; |
fba43665 VB |
680 | const void *mac_addr; |
681 | const phandle *ph; | |
682 | const char *model; | |
683 | ||
684 | memset(r, 0, sizeof(r)); | |
685 | memset(&fs_enet_data, 0, sizeof(fs_enet_data)); | |
686 | ||
687 | ret = of_address_to_resource(np, 0, &r[0]); | |
688 | if (ret) | |
689 | goto err; | |
690 | r[0].name = fcc_regs; | |
691 | ||
692 | ret = of_address_to_resource(np, 1, &r[1]); | |
693 | if (ret) | |
694 | goto err; | |
695 | r[1].name = fcc_pram; | |
696 | ||
697 | ret = of_address_to_resource(np, 2, &r[2]); | |
698 | if (ret) | |
699 | goto err; | |
700 | r[2].name = fcc_regs_c; | |
ed943c1f | 701 | fs_enet_data.fcc_regs_c = r[2].start; |
fba43665 | 702 | |
a9b14973 | 703 | of_irq_to_resource(np, 0, &r[3]); |
fba43665 VB |
704 | |
705 | fs_enet_dev = | |
706 | platform_device_register_simple("fsl-cpm-fcc", i, &r[0], 4); | |
707 | ||
708 | if (IS_ERR(fs_enet_dev)) { | |
709 | ret = PTR_ERR(fs_enet_dev); | |
710 | goto err; | |
711 | } | |
712 | ||
e2eb6392 | 713 | model = of_get_property(np, "model", NULL); |
fba43665 VB |
714 | if (model == NULL) { |
715 | ret = -ENODEV; | |
716 | goto unreg; | |
717 | } | |
718 | ||
29cfe6f4 TT |
719 | mac_addr = of_get_mac_address(np); |
720 | if (mac_addr) | |
721 | memcpy(fs_enet_data.macaddr, mac_addr, 6); | |
fba43665 | 722 | |
e2eb6392 | 723 | ph = of_get_property(np, "phy-handle", NULL); |
fba43665 VB |
724 | phy = of_find_node_by_phandle(*ph); |
725 | ||
726 | if (phy == NULL) { | |
727 | ret = -ENODEV; | |
728 | goto unreg; | |
729 | } | |
730 | ||
e2eb6392 | 731 | phy_addr = of_get_property(phy, "reg", NULL); |
fba43665 VB |
732 | fs_enet_data.phy_addr = *phy_addr; |
733 | ||
e2eb6392 | 734 | phy_irq = of_get_property(phy, "interrupts", NULL); |
ed943c1f | 735 | |
e2eb6392 | 736 | id = of_get_property(np, "device-id", NULL); |
fba43665 | 737 | fs_enet_data.fs_no = *id; |
611a15af | 738 | strcpy(fs_enet_data.fs_type, model); |
fba43665 VB |
739 | |
740 | mdio = of_get_parent(phy); | |
741 | ret = of_address_to_resource(mdio, 0, &res); | |
742 | if (ret) { | |
743 | of_node_put(phy); | |
744 | of_node_put(mdio); | |
745 | goto unreg; | |
746 | } | |
747 | ||
e2eb6392 SR |
748 | fs_enet_data.clk_rx = *((u32 *)of_get_property(np, |
749 | "rx-clock", NULL)); | |
750 | fs_enet_data.clk_tx = *((u32 *)of_get_property(np, | |
751 | "tx-clock", NULL)); | |
d3465c92 | 752 | |
fba43665 | 753 | if (strstr(model, "FCC")) { |
611a15af | 754 | int fcc_index = *id - 1; |
2b00b254 | 755 | const unsigned char *mdio_bb_prop; |
fba43665 | 756 | |
fc8e50e3 | 757 | fs_enet_data.dpram_offset = (u32)cpm_dpram_addr(0); |
fba43665 VB |
758 | fs_enet_data.rx_ring = 32; |
759 | fs_enet_data.tx_ring = 32; | |
760 | fs_enet_data.rx_copybreak = 240; | |
761 | fs_enet_data.use_napi = 0; | |
762 | fs_enet_data.napi_weight = 17; | |
763 | fs_enet_data.mem_offset = FCC_MEM_OFFSET(fcc_index); | |
764 | fs_enet_data.cp_page = CPM_CR_FCC_PAGE(fcc_index); | |
765 | fs_enet_data.cp_block = CPM_CR_FCC_SBLOCK(fcc_index); | |
766 | ||
767 | snprintf((char*)&bus_id[(*id)], BUS_ID_SIZE, "%x:%02x", | |
768 | (u32)res.start, fs_enet_data.phy_addr); | |
769 | fs_enet_data.bus_id = (char*)&bus_id[(*id)]; | |
d3465c92 | 770 | fs_enet_data.init_ioports = init_fcc_ioports; |
fba43665 | 771 | |
e2eb6392 | 772 | mdio_bb_prop = of_get_property(phy, "bitbang", NULL); |
ed943c1f VB |
773 | if (mdio_bb_prop) { |
774 | struct platform_device *fs_enet_mdio_bb_dev; | |
775 | struct fs_mii_bb_platform_info fs_enet_mdio_bb_data; | |
776 | ||
777 | fs_enet_mdio_bb_dev = | |
778 | platform_device_register_simple("fsl-bb-mdio", | |
779 | i, NULL, 0); | |
780 | memset(&fs_enet_mdio_bb_data, 0, | |
781 | sizeof(struct fs_mii_bb_platform_info)); | |
782 | fs_enet_mdio_bb_data.mdio_dat.bit = | |
783 | mdio_bb_prop[0]; | |
784 | fs_enet_mdio_bb_data.mdio_dir.bit = | |
785 | mdio_bb_prop[1]; | |
786 | fs_enet_mdio_bb_data.mdc_dat.bit = | |
787 | mdio_bb_prop[2]; | |
788 | fs_enet_mdio_bb_data.mdio_port = | |
789 | mdio_bb_prop[3]; | |
790 | fs_enet_mdio_bb_data.mdc_port = | |
791 | mdio_bb_prop[4]; | |
792 | fs_enet_mdio_bb_data.delay = | |
793 | mdio_bb_prop[5]; | |
794 | ||
795 | fs_enet_mdio_bb_data.irq[0] = phy_irq[0]; | |
796 | fs_enet_mdio_bb_data.irq[1] = -1; | |
797 | fs_enet_mdio_bb_data.irq[2] = -1; | |
798 | fs_enet_mdio_bb_data.irq[3] = phy_irq[0]; | |
799 | fs_enet_mdio_bb_data.irq[31] = -1; | |
800 | ||
801 | fs_enet_mdio_bb_data.mdio_dat.offset = | |
802 | (u32)&cpm2_immr->im_ioport.iop_pdatc; | |
803 | fs_enet_mdio_bb_data.mdio_dir.offset = | |
804 | (u32)&cpm2_immr->im_ioport.iop_pdirc; | |
805 | fs_enet_mdio_bb_data.mdc_dat.offset = | |
806 | (u32)&cpm2_immr->im_ioport.iop_pdatc; | |
807 | ||
808 | ret = platform_device_add_data( | |
809 | fs_enet_mdio_bb_dev, | |
810 | &fs_enet_mdio_bb_data, | |
811 | sizeof(struct fs_mii_bb_platform_info)); | |
812 | if (ret) | |
813 | goto unreg; | |
814 | } | |
97c5a20a | 815 | |
ed943c1f VB |
816 | of_node_put(phy); |
817 | of_node_put(mdio); | |
fba43665 | 818 | |
ed943c1f VB |
819 | ret = platform_device_add_data(fs_enet_dev, &fs_enet_data, |
820 | sizeof(struct | |
821 | fs_platform_info)); | |
2b00b254 OJ |
822 | if (ret) |
823 | goto unreg; | |
824 | } | |
fba43665 VB |
825 | } |
826 | return 0; | |
827 | ||
828 | unreg: | |
829 | platform_device_unregister(fs_enet_dev); | |
830 | err: | |
831 | return ret; | |
832 | } | |
833 | ||
834 | arch_initcall(fs_enet_of_init); | |
835 | ||
836 | static const char scc_regs[] = "regs"; | |
837 | static const char scc_pram[] = "pram"; | |
838 | ||
839 | static int __init cpm_uart_of_init(void) | |
840 | { | |
841 | struct device_node *np; | |
842 | unsigned int i; | |
843 | struct platform_device *cpm_uart_dev; | |
844 | int ret; | |
845 | ||
846 | for (np = NULL, i = 0; | |
847 | (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL; | |
848 | i++) { | |
849 | struct resource r[3]; | |
850 | struct fs_uart_platform_info cpm_uart_data; | |
851 | const int *id; | |
611a15af | 852 | const char *model; |
fba43665 VB |
853 | |
854 | memset(r, 0, sizeof(r)); | |
855 | memset(&cpm_uart_data, 0, sizeof(cpm_uart_data)); | |
856 | ||
857 | ret = of_address_to_resource(np, 0, &r[0]); | |
858 | if (ret) | |
859 | goto err; | |
860 | ||
861 | r[0].name = scc_regs; | |
862 | ||
863 | ret = of_address_to_resource(np, 1, &r[1]); | |
864 | if (ret) | |
865 | goto err; | |
866 | r[1].name = scc_pram; | |
867 | ||
a9b14973 | 868 | of_irq_to_resource(np, 0, &r[2]); |
fba43665 VB |
869 | |
870 | cpm_uart_dev = | |
871 | platform_device_register_simple("fsl-cpm-scc:uart", i, &r[0], 3); | |
872 | ||
873 | if (IS_ERR(cpm_uart_dev)) { | |
874 | ret = PTR_ERR(cpm_uart_dev); | |
875 | goto err; | |
876 | } | |
877 | ||
e2eb6392 | 878 | id = of_get_property(np, "device-id", NULL); |
fba43665 | 879 | cpm_uart_data.fs_no = *id; |
611a15af | 880 | |
e2eb6392 | 881 | model = of_get_property(np, "model", NULL); |
611a15af VB |
882 | strcpy(cpm_uart_data.fs_type, model); |
883 | ||
fba43665 VB |
884 | cpm_uart_data.uart_clk = ppc_proc_freq; |
885 | ||
886 | cpm_uart_data.tx_num_fifo = 4; | |
887 | cpm_uart_data.tx_buf_size = 32; | |
888 | cpm_uart_data.rx_num_fifo = 4; | |
889 | cpm_uart_data.rx_buf_size = 32; | |
e2eb6392 SR |
890 | cpm_uart_data.clk_rx = *((u32 *)of_get_property(np, |
891 | "rx-clock", NULL)); | |
892 | cpm_uart_data.clk_tx = *((u32 *)of_get_property(np, | |
893 | "tx-clock", NULL)); | |
fba43665 VB |
894 | |
895 | ret = | |
896 | platform_device_add_data(cpm_uart_dev, &cpm_uart_data, | |
897 | sizeof(struct | |
898 | fs_uart_platform_info)); | |
899 | if (ret) | |
900 | goto unreg; | |
901 | } | |
902 | ||
903 | return 0; | |
904 | ||
905 | unreg: | |
906 | platform_device_unregister(cpm_uart_dev); | |
907 | err: | |
908 | return ret; | |
909 | } | |
910 | ||
911 | arch_initcall(cpm_uart_of_init); | |
912 | #endif /* CONFIG_CPM2 */ | |
88bdc6f0 VB |
913 | |
914 | #ifdef CONFIG_8xx | |
915 | ||
916 | extern void init_scc_ioports(struct fs_platform_info*); | |
e2eb6392 | 917 | extern int platform_device_skip(const char *model, int id); |
88bdc6f0 VB |
918 | |
919 | static int __init fs_enet_mdio_of_init(void) | |
920 | { | |
921 | struct device_node *np; | |
922 | unsigned int i; | |
923 | struct platform_device *mdio_dev; | |
924 | struct resource res; | |
925 | int ret; | |
926 | ||
927 | for (np = NULL, i = 0; | |
928 | (np = of_find_compatible_node(np, "mdio", "fs_enet")) != NULL; | |
929 | i++) { | |
930 | struct fs_mii_fec_platform_info mdio_data; | |
931 | ||
932 | memset(&res, 0, sizeof(res)); | |
933 | memset(&mdio_data, 0, sizeof(mdio_data)); | |
934 | ||
935 | ret = of_address_to_resource(np, 0, &res); | |
936 | if (ret) | |
937 | goto err; | |
938 | ||
939 | mdio_dev = | |
940 | platform_device_register_simple("fsl-cpm-fec-mdio", | |
941 | res.start, &res, 1); | |
942 | if (IS_ERR(mdio_dev)) { | |
943 | ret = PTR_ERR(mdio_dev); | |
944 | goto err; | |
945 | } | |
946 | ||
947 | mdio_data.mii_speed = ((((ppc_proc_freq + 4999999) / 2500000) / 2) & 0x3F) << 1; | |
948 | ||
949 | ret = | |
950 | platform_device_add_data(mdio_dev, &mdio_data, | |
951 | sizeof(struct fs_mii_fec_platform_info)); | |
952 | if (ret) | |
953 | goto unreg; | |
954 | } | |
955 | return 0; | |
956 | ||
957 | unreg: | |
958 | platform_device_unregister(mdio_dev); | |
959 | err: | |
960 | return ret; | |
961 | } | |
962 | ||
963 | arch_initcall(fs_enet_mdio_of_init); | |
964 | ||
965 | static const char *enet_regs = "regs"; | |
966 | static const char *enet_pram = "pram"; | |
967 | static const char *enet_irq = "interrupt"; | |
968 | static char bus_id[9][BUS_ID_SIZE]; | |
969 | ||
970 | static int __init fs_enet_of_init(void) | |
971 | { | |
972 | struct device_node *np; | |
973 | unsigned int i; | |
974 | struct platform_device *fs_enet_dev = NULL; | |
975 | struct resource res; | |
976 | int ret; | |
977 | ||
978 | for (np = NULL, i = 0; | |
979 | (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL; | |
980 | i++) { | |
981 | struct resource r[4]; | |
982 | struct device_node *phy = NULL, *mdio = NULL; | |
983 | struct fs_platform_info fs_enet_data; | |
e2eb6392 SR |
984 | const unsigned int *id; |
985 | const unsigned int *phy_addr; | |
b7a69129 | 986 | const void *mac_addr; |
e2eb6392 SR |
987 | const phandle *ph; |
988 | const char *model; | |
88bdc6f0 VB |
989 | |
990 | memset(r, 0, sizeof(r)); | |
991 | memset(&fs_enet_data, 0, sizeof(fs_enet_data)); | |
992 | ||
e2eb6392 | 993 | model = of_get_property(np, "model", NULL); |
88bdc6f0 VB |
994 | if (model == NULL) { |
995 | ret = -ENODEV; | |
996 | goto unreg; | |
997 | } | |
998 | ||
e2eb6392 | 999 | id = of_get_property(np, "device-id", NULL); |
88bdc6f0 VB |
1000 | fs_enet_data.fs_no = *id; |
1001 | ||
1002 | if (platform_device_skip(model, *id)) | |
1003 | continue; | |
1004 | ||
1005 | ret = of_address_to_resource(np, 0, &r[0]); | |
1006 | if (ret) | |
1007 | goto err; | |
1008 | r[0].name = enet_regs; | |
1009 | ||
29cfe6f4 TT |
1010 | mac_addr = of_get_mac_address(np); |
1011 | if (mac_addr) | |
1012 | memcpy(fs_enet_data.macaddr, mac_addr, 6); | |
88bdc6f0 | 1013 | |
e2eb6392 | 1014 | ph = of_get_property(np, "phy-handle", NULL); |
88bdc6f0 VB |
1015 | if (ph != NULL) |
1016 | phy = of_find_node_by_phandle(*ph); | |
1017 | ||
1018 | if (phy != NULL) { | |
e2eb6392 | 1019 | phy_addr = of_get_property(phy, "reg", NULL); |
88bdc6f0 VB |
1020 | fs_enet_data.phy_addr = *phy_addr; |
1021 | fs_enet_data.has_phy = 1; | |
1022 | ||
1023 | mdio = of_get_parent(phy); | |
1024 | ret = of_address_to_resource(mdio, 0, &res); | |
1025 | if (ret) { | |
1026 | of_node_put(phy); | |
1027 | of_node_put(mdio); | |
1028 | goto unreg; | |
1029 | } | |
1030 | } | |
1031 | ||
e2eb6392 | 1032 | model = of_get_property(np, "model", NULL); |
88bdc6f0 VB |
1033 | strcpy(fs_enet_data.fs_type, model); |
1034 | ||
1035 | if (strstr(model, "FEC")) { | |
1036 | r[1].start = r[1].end = irq_of_parse_and_map(np, 0); | |
1037 | r[1].flags = IORESOURCE_IRQ; | |
1038 | r[1].name = enet_irq; | |
1039 | ||
1040 | fs_enet_dev = | |
1041 | platform_device_register_simple("fsl-cpm-fec", i, &r[0], 2); | |
1042 | ||
1043 | if (IS_ERR(fs_enet_dev)) { | |
1044 | ret = PTR_ERR(fs_enet_dev); | |
1045 | goto err; | |
1046 | } | |
1047 | ||
1048 | fs_enet_data.rx_ring = 128; | |
1049 | fs_enet_data.tx_ring = 16; | |
1050 | fs_enet_data.rx_copybreak = 240; | |
1051 | fs_enet_data.use_napi = 1; | |
1052 | fs_enet_data.napi_weight = 17; | |
1053 | ||
1054 | snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%x:%02x", | |
1055 | (u32)res.start, fs_enet_data.phy_addr); | |
1056 | fs_enet_data.bus_id = (char*)&bus_id[i]; | |
1057 | fs_enet_data.init_ioports = init_fec_ioports; | |
1058 | } | |
1059 | if (strstr(model, "SCC")) { | |
1060 | ret = of_address_to_resource(np, 1, &r[1]); | |
1061 | if (ret) | |
1062 | goto err; | |
1063 | r[1].name = enet_pram; | |
1064 | ||
1065 | r[2].start = r[2].end = irq_of_parse_and_map(np, 0); | |
1066 | r[2].flags = IORESOURCE_IRQ; | |
1067 | r[2].name = enet_irq; | |
1068 | ||
1069 | fs_enet_dev = | |
1070 | platform_device_register_simple("fsl-cpm-scc", i, &r[0], 3); | |
1071 | ||
1072 | if (IS_ERR(fs_enet_dev)) { | |
1073 | ret = PTR_ERR(fs_enet_dev); | |
1074 | goto err; | |
1075 | } | |
1076 | ||
1077 | fs_enet_data.rx_ring = 64; | |
1078 | fs_enet_data.tx_ring = 8; | |
1079 | fs_enet_data.rx_copybreak = 240; | |
1080 | fs_enet_data.use_napi = 1; | |
1081 | fs_enet_data.napi_weight = 17; | |
1082 | ||
1083 | snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%s", "fixed@10:1"); | |
1084 | fs_enet_data.bus_id = (char*)&bus_id[i]; | |
1085 | fs_enet_data.init_ioports = init_scc_ioports; | |
1086 | } | |
1087 | ||
1088 | of_node_put(phy); | |
1089 | of_node_put(mdio); | |
1090 | ||
1091 | ret = platform_device_add_data(fs_enet_dev, &fs_enet_data, | |
1092 | sizeof(struct | |
1093 | fs_platform_info)); | |
1094 | if (ret) | |
1095 | goto unreg; | |
1096 | } | |
1097 | return 0; | |
1098 | ||
1099 | unreg: | |
1100 | platform_device_unregister(fs_enet_dev); | |
1101 | err: | |
1102 | return ret; | |
1103 | } | |
1104 | ||
1105 | arch_initcall(fs_enet_of_init); | |
1106 | ||
80128ff7 VB |
1107 | static int __init fsl_pcmcia_of_init(void) |
1108 | { | |
1109 | struct device_node *np = NULL; | |
1110 | /* | |
1111 | * Register all the devices which type is "pcmcia" | |
1112 | */ | |
1113 | while ((np = of_find_compatible_node(np, | |
1114 | "pcmcia", "fsl,pq-pcmcia")) != NULL) | |
1115 | of_platform_device_create(np, "m8xx-pcmcia", NULL); | |
1116 | return 0; | |
1117 | } | |
1118 | ||
1119 | arch_initcall(fsl_pcmcia_of_init); | |
88bdc6f0 VB |
1120 | |
1121 | static const char *smc_regs = "regs"; | |
1122 | static const char *smc_pram = "pram"; | |
1123 | ||
1124 | static int __init cpm_smc_uart_of_init(void) | |
1125 | { | |
1126 | struct device_node *np; | |
1127 | unsigned int i; | |
1128 | struct platform_device *cpm_uart_dev; | |
1129 | int ret; | |
1130 | ||
1131 | for (np = NULL, i = 0; | |
1132 | (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL; | |
1133 | i++) { | |
1134 | struct resource r[3]; | |
1135 | struct fs_uart_platform_info cpm_uart_data; | |
e2eb6392 SR |
1136 | const int *id; |
1137 | const char *model; | |
88bdc6f0 VB |
1138 | |
1139 | memset(r, 0, sizeof(r)); | |
1140 | memset(&cpm_uart_data, 0, sizeof(cpm_uart_data)); | |
1141 | ||
1142 | ret = of_address_to_resource(np, 0, &r[0]); | |
1143 | if (ret) | |
1144 | goto err; | |
1145 | ||
1146 | r[0].name = smc_regs; | |
1147 | ||
1148 | ret = of_address_to_resource(np, 1, &r[1]); | |
1149 | if (ret) | |
1150 | goto err; | |
1151 | r[1].name = smc_pram; | |
1152 | ||
1153 | r[2].start = r[2].end = irq_of_parse_and_map(np, 0); | |
1154 | r[2].flags = IORESOURCE_IRQ; | |
1155 | ||
1156 | cpm_uart_dev = | |
1157 | platform_device_register_simple("fsl-cpm-smc:uart", i, &r[0], 3); | |
1158 | ||
1159 | if (IS_ERR(cpm_uart_dev)) { | |
1160 | ret = PTR_ERR(cpm_uart_dev); | |
1161 | goto err; | |
1162 | } | |
1163 | ||
e2eb6392 | 1164 | model = of_get_property(np, "model", NULL); |
88bdc6f0 VB |
1165 | strcpy(cpm_uart_data.fs_type, model); |
1166 | ||
e2eb6392 | 1167 | id = of_get_property(np, "device-id", NULL); |
88bdc6f0 VB |
1168 | cpm_uart_data.fs_no = *id; |
1169 | cpm_uart_data.uart_clk = ppc_proc_freq; | |
1170 | ||
1171 | cpm_uart_data.tx_num_fifo = 4; | |
1172 | cpm_uart_data.tx_buf_size = 32; | |
1173 | cpm_uart_data.rx_num_fifo = 4; | |
1174 | cpm_uart_data.rx_buf_size = 32; | |
1175 | ||
1176 | ret = | |
1177 | platform_device_add_data(cpm_uart_dev, &cpm_uart_data, | |
1178 | sizeof(struct | |
1179 | fs_uart_platform_info)); | |
1180 | if (ret) | |
1181 | goto unreg; | |
1182 | } | |
1183 | ||
1184 | return 0; | |
1185 | ||
1186 | unreg: | |
1187 | platform_device_unregister(cpm_uart_dev); | |
1188 | err: | |
1189 | return ret; | |
1190 | } | |
1191 | ||
1192 | arch_initcall(cpm_smc_uart_of_init); | |
1193 | ||
1194 | #endif /* CONFIG_8xx */ |