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