blob: 3289fab01e9245a49919a61d5ecdc285a2a49810 [file] [log] [blame]
Kumar Galaeed32002006-01-13 11:19:13 -06001/*
2 * FSL SoC setup code
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
Vitaly Bordugfba43662006-09-21 17:26:34 +04006 * 2006 (c) MontaVista Software, Inc.
7 * Vitaly Bordug <vbordug@ru.mvista.com>
8 *
Kumar Galaeed32002006-01-13 11:19:13 -06009 * 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
Kumar Galaeed32002006-01-13 11:19:13 -060015#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>
Andy Fleminga9b14972006-10-19 19:52:26 -050025#include <linux/phy.h>
Kumar Galaeed32002006-01-13 11:19:13 -060026#include <linux/fsl_devices.h>
Vitaly Bordugfba43662006-09-21 17:26:34 +040027#include <linux/fs_enet_pd.h>
28#include <linux/fs_uart_pd.h>
Kumar Galaeed32002006-01-13 11:19:13 -060029
30#include <asm/system.h>
31#include <asm/atomic.h>
32#include <asm/io.h>
33#include <asm/irq.h>
Vitaly Bordugfba43662006-09-21 17:26:34 +040034#include <asm/time.h>
Kumar Galaeed32002006-01-13 11:19:13 -060035#include <asm/prom.h>
36#include <sysdev/fsl_soc.h>
37#include <mm/mmu_decl.h>
Vitaly Bordugfba43662006-09-21 17:26:34 +040038#include <asm/cpm2.h>
Kumar Galaeed32002006-01-13 11:19:13 -060039
Vitaly Bordugd3465c92006-09-21 22:38:05 +040040extern void init_fcc_ioports(struct fs_platform_info*);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +030041extern void init_fec_ioports(struct fs_platform_info*);
42extern void init_smc_ioports(struct fs_uart_platform_info*);
Kumar Galaeed32002006-01-13 11:19:13 -060043static phys_addr_t immrbase = -1;
44
45phys_addr_t get_immrbase(void)
46{
47 struct device_node *soc;
48
49 if (immrbase != -1)
50 return immrbase;
51
52 soc = of_find_node_by_type(NULL, "soc");
Kumar Gala2fb07d72006-01-23 16:58:04 -060053 if (soc) {
Kumar Galaeed32002006-01-13 11:19:13 -060054 unsigned int size;
Stephen Rothwelle2eb6392007-04-03 22:26:41 +100055 const void *prop = of_get_property(soc, "reg", &size);
Vitaly Bordugfba43662006-09-21 17:26:34 +040056
57 if (prop)
58 immrbase = of_translate_address(soc, prop);
Kumar Galaeed32002006-01-13 11:19:13 -060059 of_node_put(soc);
60 };
61
62 return immrbase;
63}
Kumar Gala2fb07d72006-01-23 16:58:04 -060064
Kumar Galaeed32002006-01-13 11:19:13 -060065EXPORT_SYMBOL(get_immrbase);
66
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +030067#if defined(CONFIG_CPM2) || defined(CONFIG_8xx)
Vitaly Bordugfba43662006-09-21 17:26:34 +040068
69static u32 brgfreq = -1;
70
71u32 get_brgfreq(void)
72{
73 struct device_node *node;
74
75 if (brgfreq != -1)
76 return brgfreq;
77
78 node = of_find_node_by_type(NULL, "cpm");
79 if (node) {
80 unsigned int size;
Stephen Rothwelle2eb6392007-04-03 22:26:41 +100081 const unsigned int *prop = of_get_property(node,
82 "brg-frequency", &size);
Vitaly Bordugfba43662006-09-21 17:26:34 +040083
84 if (prop)
85 brgfreq = *prop;
86 of_node_put(node);
87 };
88
89 return brgfreq;
90}
91
92EXPORT_SYMBOL(get_brgfreq);
93
94static u32 fs_baudrate = -1;
95
96u32 get_baudrate(void)
97{
98 struct device_node *node;
99
100 if (fs_baudrate != -1)
101 return fs_baudrate;
102
103 node = of_find_node_by_type(NULL, "serial");
104 if (node) {
105 unsigned int size;
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000106 const unsigned int *prop = of_get_property(node,
107 "current-speed", &size);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400108
109 if (prop)
110 fs_baudrate = *prop;
111 of_node_put(node);
112 };
113
114 return fs_baudrate;
115}
116
117EXPORT_SYMBOL(get_baudrate);
118#endif /* CONFIG_CPM2 */
119
Kumar Gala2fb07d72006-01-23 16:58:04 -0600120static int __init gfar_mdio_of_init(void)
Kumar Galaeed32002006-01-13 11:19:13 -0600121{
122 struct device_node *np;
123 unsigned int i;
Kumar Gala2fb07d72006-01-23 16:58:04 -0600124 struct platform_device *mdio_dev;
Kumar Galaeed32002006-01-13 11:19:13 -0600125 struct resource res;
126 int ret;
127
Kumar Gala2fb07d72006-01-23 16:58:04 -0600128 for (np = NULL, i = 0;
129 (np = of_find_compatible_node(np, "mdio", "gianfar")) != NULL;
130 i++) {
Kumar Galaeed32002006-01-13 11:19:13 -0600131 int k;
132 struct device_node *child = NULL;
133 struct gianfar_mdio_data mdio_data;
134
135 memset(&res, 0, sizeof(res));
136 memset(&mdio_data, 0, sizeof(mdio_data));
137
138 ret = of_address_to_resource(np, 0, &res);
139 if (ret)
Kumar Gala2fb07d72006-01-23 16:58:04 -0600140 goto err;
Kumar Galaeed32002006-01-13 11:19:13 -0600141
Kumar Gala2fb07d72006-01-23 16:58:04 -0600142 mdio_dev =
143 platform_device_register_simple("fsl-gianfar_mdio",
144 res.start, &res, 1);
Kumar Galaeed32002006-01-13 11:19:13 -0600145 if (IS_ERR(mdio_dev)) {
146 ret = PTR_ERR(mdio_dev);
Kumar Gala2fb07d72006-01-23 16:58:04 -0600147 goto err;
Kumar Galaeed32002006-01-13 11:19:13 -0600148 }
149
150 for (k = 0; k < 32; k++)
Andy Fleminga9b14972006-10-19 19:52:26 -0500151 mdio_data.irq[k] = PHY_POLL;
Kumar Galaeed32002006-01-13 11:19:13 -0600152
153 while ((child = of_get_next_child(np, child)) != NULL) {
Vitaly Bordugfba43662006-09-21 17:26:34 +0400154 int irq = irq_of_parse_and_map(child, 0);
155 if (irq != NO_IRQ) {
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000156 const u32 *id = of_get_property(child,
157 "reg", NULL);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400158 mdio_data.irq[*id] = irq;
159 }
Kumar Galaeed32002006-01-13 11:19:13 -0600160 }
161
Kumar Gala2fb07d72006-01-23 16:58:04 -0600162 ret =
163 platform_device_add_data(mdio_dev, &mdio_data,
164 sizeof(struct gianfar_mdio_data));
Kumar Galaeed32002006-01-13 11:19:13 -0600165 if (ret)
Kumar Gala2fb07d72006-01-23 16:58:04 -0600166 goto unreg;
Kumar Galaeed32002006-01-13 11:19:13 -0600167 }
168
Kumar Gala2fb07d72006-01-23 16:58:04 -0600169 return 0;
170
171unreg:
172 platform_device_unregister(mdio_dev);
173err:
174 return ret;
175}
176
177arch_initcall(gfar_mdio_of_init);
178
179static const char *gfar_tx_intr = "tx";
180static const char *gfar_rx_intr = "rx";
181static const char *gfar_err_intr = "error";
182
Andy Fleminga9b14972006-10-19 19:52:26 -0500183
Kumar Gala2fb07d72006-01-23 16:58:04 -0600184static int __init gfar_of_init(void)
185{
186 struct device_node *np;
187 unsigned int i;
188 struct platform_device *gfar_dev;
189 struct resource res;
190 int ret;
191
192 for (np = NULL, i = 0;
193 (np = of_find_compatible_node(np, "network", "gianfar")) != NULL;
194 i++) {
Kumar Galaeed32002006-01-13 11:19:13 -0600195 struct resource r[4];
196 struct device_node *phy, *mdio;
197 struct gianfar_platform_data gfar_data;
Jeremy Kerra7f67bd2006-07-12 15:35:54 +1000198 const unsigned int *id;
199 const char *model;
Andy Fleming7132ab72007-07-11 11:43:07 -0500200 const char *ctype;
Jeremy Kerra7f67bd2006-07-12 15:35:54 +1000201 const void *mac_addr;
202 const phandle *ph;
Vitaly Bordugfba43662006-09-21 17:26:34 +0400203 int n_res = 2;
Kumar Galaeed32002006-01-13 11:19:13 -0600204
205 memset(r, 0, sizeof(r));
206 memset(&gfar_data, 0, sizeof(gfar_data));
207
208 ret = of_address_to_resource(np, 0, &r[0]);
209 if (ret)
Kumar Gala2fb07d72006-01-23 16:58:04 -0600210 goto err;
Kumar Galaeed32002006-01-13 11:19:13 -0600211
Andy Fleminga9b14972006-10-19 19:52:26 -0500212 of_irq_to_resource(np, 0, &r[1]);
Kumar Galaeed32002006-01-13 11:19:13 -0600213
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000214 model = of_get_property(np, "model", NULL);
Kumar Galaeed32002006-01-13 11:19:13 -0600215
216 /* If we aren't the FEC we have multiple interrupts */
217 if (model && strcasecmp(model, "FEC")) {
218 r[1].name = gfar_tx_intr;
219
220 r[2].name = gfar_rx_intr;
Andy Fleminga9b14972006-10-19 19:52:26 -0500221 of_irq_to_resource(np, 1, &r[2]);
Kumar Galaeed32002006-01-13 11:19:13 -0600222
223 r[3].name = gfar_err_intr;
Andy Fleminga9b14972006-10-19 19:52:26 -0500224 of_irq_to_resource(np, 2, &r[3]);
Jon Loeliger919fede2006-07-31 15:35:41 -0500225
226 n_res += 2;
Kumar Galaeed32002006-01-13 11:19:13 -0600227 }
228
Kumar Gala2fb07d72006-01-23 16:58:04 -0600229 gfar_dev =
230 platform_device_register_simple("fsl-gianfar", i, &r[0],
Vitaly Bordugfba43662006-09-21 17:26:34 +0400231 n_res);
Kumar Galaeed32002006-01-13 11:19:13 -0600232
233 if (IS_ERR(gfar_dev)) {
234 ret = PTR_ERR(gfar_dev);
Kumar Gala2fb07d72006-01-23 16:58:04 -0600235 goto err;
Kumar Galaeed32002006-01-13 11:19:13 -0600236 }
237
Timur Tabi29cfe6f2007-02-16 12:01:29 -0600238 mac_addr = of_get_mac_address(np);
Jon Loeligerf5831652006-08-17 08:42:35 -0500239 if (mac_addr)
240 memcpy(gfar_data.mac_addr, mac_addr, 6);
Kumar Galaeed32002006-01-13 11:19:13 -0600241
242 if (model && !strcasecmp(model, "TSEC"))
243 gfar_data.device_flags =
Kumar Gala2fb07d72006-01-23 16:58:04 -0600244 FSL_GIANFAR_DEV_HAS_GIGABIT |
245 FSL_GIANFAR_DEV_HAS_COALESCE |
246 FSL_GIANFAR_DEV_HAS_RMON |
247 FSL_GIANFAR_DEV_HAS_MULTI_INTR;
Kumar Galaeed32002006-01-13 11:19:13 -0600248 if (model && !strcasecmp(model, "eTSEC"))
249 gfar_data.device_flags =
Kumar Gala2fb07d72006-01-23 16:58:04 -0600250 FSL_GIANFAR_DEV_HAS_GIGABIT |
251 FSL_GIANFAR_DEV_HAS_COALESCE |
252 FSL_GIANFAR_DEV_HAS_RMON |
253 FSL_GIANFAR_DEV_HAS_MULTI_INTR |
254 FSL_GIANFAR_DEV_HAS_CSUM |
255 FSL_GIANFAR_DEV_HAS_VLAN |
256 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
Kumar Galaeed32002006-01-13 11:19:13 -0600257
Andy Fleming7132ab72007-07-11 11:43:07 -0500258 ctype = of_get_property(np, "phy-connection-type", NULL);
259
260 /* We only care about rgmii-id. The rest are autodetected */
261 if (ctype && !strcmp(ctype, "rgmii-id"))
262 gfar_data.interface = PHY_INTERFACE_MODE_RGMII_ID;
263 else
264 gfar_data.interface = PHY_INTERFACE_MODE_MII;
265
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000266 ph = of_get_property(np, "phy-handle", NULL);
Kumar Galaeed32002006-01-13 11:19:13 -0600267 phy = of_find_node_by_phandle(*ph);
268
269 if (phy == NULL) {
270 ret = -ENODEV;
Kumar Gala2fb07d72006-01-23 16:58:04 -0600271 goto unreg;
Kumar Galaeed32002006-01-13 11:19:13 -0600272 }
273
274 mdio = of_get_parent(phy);
275
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000276 id = of_get_property(phy, "reg", NULL);
Kumar Galaeed32002006-01-13 11:19:13 -0600277 ret = of_address_to_resource(mdio, 0, &res);
278 if (ret) {
279 of_node_put(phy);
280 of_node_put(mdio);
Kumar Gala2fb07d72006-01-23 16:58:04 -0600281 goto unreg;
Kumar Galaeed32002006-01-13 11:19:13 -0600282 }
283
284 gfar_data.phy_id = *id;
285 gfar_data.bus_id = res.start;
286
287 of_node_put(phy);
288 of_node_put(mdio);
289
Kumar Gala2fb07d72006-01-23 16:58:04 -0600290 ret =
291 platform_device_add_data(gfar_dev, &gfar_data,
292 sizeof(struct
293 gianfar_platform_data));
Kumar Galaeed32002006-01-13 11:19:13 -0600294 if (ret)
Kumar Gala2fb07d72006-01-23 16:58:04 -0600295 goto unreg;
Kumar Galaeed32002006-01-13 11:19:13 -0600296 }
297
298 return 0;
299
Kumar Gala2fb07d72006-01-23 16:58:04 -0600300unreg:
Kumar Galaeed32002006-01-13 11:19:13 -0600301 platform_device_unregister(gfar_dev);
Kumar Gala2fb07d72006-01-23 16:58:04 -0600302err:
Kumar Galaeed32002006-01-13 11:19:13 -0600303 return ret;
304}
Kumar Gala2fb07d72006-01-23 16:58:04 -0600305
Kumar Galaeed32002006-01-13 11:19:13 -0600306arch_initcall(gfar_of_init);
307
308static int __init fsl_i2c_of_init(void)
309{
310 struct device_node *np;
311 unsigned int i;
312 struct platform_device *i2c_dev;
313 int ret;
314
Kumar Gala2fb07d72006-01-23 16:58:04 -0600315 for (np = NULL, i = 0;
316 (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
317 i++) {
Kumar Galaeed32002006-01-13 11:19:13 -0600318 struct resource r[2];
319 struct fsl_i2c_platform_data i2c_data;
Jeremy Kerra7f67bd2006-07-12 15:35:54 +1000320 const unsigned char *flags = NULL;
Kumar Galaeed32002006-01-13 11:19:13 -0600321
322 memset(&r, 0, sizeof(r));
323 memset(&i2c_data, 0, sizeof(i2c_data));
324
325 ret = of_address_to_resource(np, 0, &r[0]);
326 if (ret)
Kumar Gala2fb07d72006-01-23 16:58:04 -0600327 goto err;
Kumar Galaeed32002006-01-13 11:19:13 -0600328
Andy Fleminga9b14972006-10-19 19:52:26 -0500329 of_irq_to_resource(np, 0, &r[1]);
Kumar Galaeed32002006-01-13 11:19:13 -0600330
331 i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
332 if (IS_ERR(i2c_dev)) {
333 ret = PTR_ERR(i2c_dev);
Kumar Gala2fb07d72006-01-23 16:58:04 -0600334 goto err;
Kumar Galaeed32002006-01-13 11:19:13 -0600335 }
336
337 i2c_data.device_flags = 0;
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000338 flags = of_get_property(np, "dfsrr", NULL);
Kumar Galaeed32002006-01-13 11:19:13 -0600339 if (flags)
340 i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
341
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000342 flags = of_get_property(np, "fsl5200-clocking", NULL);
Kumar Galaeed32002006-01-13 11:19:13 -0600343 if (flags)
344 i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
345
Kumar Gala2fb07d72006-01-23 16:58:04 -0600346 ret =
347 platform_device_add_data(i2c_dev, &i2c_data,
348 sizeof(struct
349 fsl_i2c_platform_data));
Kumar Galaeed32002006-01-13 11:19:13 -0600350 if (ret)
Kumar Gala2fb07d72006-01-23 16:58:04 -0600351 goto unreg;
Kumar Galaeed32002006-01-13 11:19:13 -0600352 }
353
354 return 0;
355
Kumar Gala2fb07d72006-01-23 16:58:04 -0600356unreg:
Kumar Galaeed32002006-01-13 11:19:13 -0600357 platform_device_unregister(i2c_dev);
Kumar Gala2fb07d72006-01-23 16:58:04 -0600358err:
Kumar Galaeed32002006-01-13 11:19:13 -0600359 return ret;
360}
Kumar Gala2fb07d72006-01-23 16:58:04 -0600361
Kumar Galaeed32002006-01-13 11:19:13 -0600362arch_initcall(fsl_i2c_of_init);
363
364#ifdef CONFIG_PPC_83xx
365static int __init mpc83xx_wdt_init(void)
366{
367 struct resource r;
368 struct device_node *soc, *np;
369 struct platform_device *dev;
Jeremy Kerra7f67bd2006-07-12 15:35:54 +1000370 const unsigned int *freq;
Kumar Galaeed32002006-01-13 11:19:13 -0600371 int ret;
372
373 np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt");
374
375 if (!np) {
376 ret = -ENODEV;
Kumar Gala2fb07d72006-01-23 16:58:04 -0600377 goto nodev;
Kumar Galaeed32002006-01-13 11:19:13 -0600378 }
379
380 soc = of_find_node_by_type(NULL, "soc");
381
382 if (!soc) {
383 ret = -ENODEV;
Kumar Gala2fb07d72006-01-23 16:58:04 -0600384 goto nosoc;
Kumar Galaeed32002006-01-13 11:19:13 -0600385 }
386
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000387 freq = of_get_property(soc, "bus-frequency", NULL);
Kumar Galaeed32002006-01-13 11:19:13 -0600388 if (!freq) {
389 ret = -ENODEV;
Kumar Gala2fb07d72006-01-23 16:58:04 -0600390 goto err;
Kumar Galaeed32002006-01-13 11:19:13 -0600391 }
392
393 memset(&r, 0, sizeof(r));
394
395 ret = of_address_to_resource(np, 0, &r);
396 if (ret)
Kumar Gala2fb07d72006-01-23 16:58:04 -0600397 goto err;
Kumar Galaeed32002006-01-13 11:19:13 -0600398
399 dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1);
400 if (IS_ERR(dev)) {
401 ret = PTR_ERR(dev);
Kumar Gala2fb07d72006-01-23 16:58:04 -0600402 goto err;
Kumar Galaeed32002006-01-13 11:19:13 -0600403 }
404
405 ret = platform_device_add_data(dev, freq, sizeof(int));
406 if (ret)
Kumar Gala2fb07d72006-01-23 16:58:04 -0600407 goto unreg;
Kumar Galaeed32002006-01-13 11:19:13 -0600408
409 of_node_put(soc);
410 of_node_put(np);
411
412 return 0;
413
Kumar Gala2fb07d72006-01-23 16:58:04 -0600414unreg:
Kumar Galaeed32002006-01-13 11:19:13 -0600415 platform_device_unregister(dev);
Kumar Gala2fb07d72006-01-23 16:58:04 -0600416err:
Kumar Galaeed32002006-01-13 11:19:13 -0600417 of_node_put(soc);
Kumar Gala2fb07d72006-01-23 16:58:04 -0600418nosoc:
Kumar Galaeed32002006-01-13 11:19:13 -0600419 of_node_put(np);
Kumar Gala2fb07d72006-01-23 16:58:04 -0600420nodev:
Kumar Galaeed32002006-01-13 11:19:13 -0600421 return ret;
422}
Kumar Gala2fb07d72006-01-23 16:58:04 -0600423
Kumar Galaeed32002006-01-13 11:19:13 -0600424arch_initcall(mpc83xx_wdt_init);
425#endif
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600426
Jeremy Kerra7f67bd2006-07-12 15:35:54 +1000427static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type)
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600428{
429 if (!phy_type)
430 return FSL_USB2_PHY_NONE;
431 if (!strcasecmp(phy_type, "ulpi"))
432 return FSL_USB2_PHY_ULPI;
433 if (!strcasecmp(phy_type, "utmi"))
434 return FSL_USB2_PHY_UTMI;
435 if (!strcasecmp(phy_type, "utmi_wide"))
436 return FSL_USB2_PHY_UTMI_WIDE;
437 if (!strcasecmp(phy_type, "serial"))
438 return FSL_USB2_PHY_SERIAL;
439
440 return FSL_USB2_PHY_NONE;
441}
442
443static int __init fsl_usb_of_init(void)
444{
445 struct device_node *np;
446 unsigned int i;
Li Yang97c5a202007-02-07 13:49:24 +0800447 struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL,
448 *usb_dev_dr_client = NULL;
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600449 int ret;
450
451 for (np = NULL, i = 0;
452 (np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) != NULL;
453 i++) {
454 struct resource r[2];
455 struct fsl_usb2_platform_data usb_data;
Jeremy Kerra7f67bd2006-07-12 15:35:54 +1000456 const unsigned char *prop = NULL;
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600457
458 memset(&r, 0, sizeof(r));
459 memset(&usb_data, 0, sizeof(usb_data));
460
461 ret = of_address_to_resource(np, 0, &r[0]);
462 if (ret)
463 goto err;
464
Andy Fleminga9b14972006-10-19 19:52:26 -0500465 of_irq_to_resource(np, 0, &r[1]);
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600466
Kumar Gala01cced22006-04-11 10:07:16 -0500467 usb_dev_mph =
468 platform_device_register_simple("fsl-ehci", i, r, 2);
469 if (IS_ERR(usb_dev_mph)) {
470 ret = PTR_ERR(usb_dev_mph);
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600471 goto err;
472 }
473
Kumar Gala01cced22006-04-11 10:07:16 -0500474 usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL;
475 usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask;
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600476
477 usb_data.operating_mode = FSL_USB2_MPH_HOST;
478
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000479 prop = of_get_property(np, "port0", NULL);
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600480 if (prop)
481 usb_data.port_enables |= FSL_USB2_PORT0_ENABLED;
482
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000483 prop = of_get_property(np, "port1", NULL);
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600484 if (prop)
485 usb_data.port_enables |= FSL_USB2_PORT1_ENABLED;
486
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000487 prop = of_get_property(np, "phy_type", NULL);
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600488 usb_data.phy_mode = determine_usb_phy(prop);
489
490 ret =
Kumar Gala01cced22006-04-11 10:07:16 -0500491 platform_device_add_data(usb_dev_mph, &usb_data,
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600492 sizeof(struct
493 fsl_usb2_platform_data));
494 if (ret)
Kumar Gala01cced22006-04-11 10:07:16 -0500495 goto unreg_mph;
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600496 }
497
Kumar Gala01cced22006-04-11 10:07:16 -0500498 for (np = NULL;
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600499 (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL;
500 i++) {
501 struct resource r[2];
502 struct fsl_usb2_platform_data usb_data;
Jeremy Kerra7f67bd2006-07-12 15:35:54 +1000503 const unsigned char *prop = NULL;
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600504
505 memset(&r, 0, sizeof(r));
506 memset(&usb_data, 0, sizeof(usb_data));
507
508 ret = of_address_to_resource(np, 0, &r[0]);
509 if (ret)
Kumar Gala01cced22006-04-11 10:07:16 -0500510 goto unreg_mph;
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600511
Andy Fleminga9b14972006-10-19 19:52:26 -0500512 of_irq_to_resource(np, 0, &r[1]);
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600513
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000514 prop = of_get_property(np, "dr_mode", NULL);
Li Yang97c5a202007-02-07 13:49:24 +0800515
516 if (!prop || !strcmp(prop, "host")) {
517 usb_data.operating_mode = FSL_USB2_DR_HOST;
518 usb_dev_dr_host = platform_device_register_simple(
519 "fsl-ehci", i, r, 2);
520 if (IS_ERR(usb_dev_dr_host)) {
521 ret = PTR_ERR(usb_dev_dr_host);
522 goto err;
523 }
524 } else if (prop && !strcmp(prop, "peripheral")) {
525 usb_data.operating_mode = FSL_USB2_DR_DEVICE;
526 usb_dev_dr_client = platform_device_register_simple(
527 "fsl-usb2-udc", i, r, 2);
528 if (IS_ERR(usb_dev_dr_client)) {
529 ret = PTR_ERR(usb_dev_dr_client);
530 goto err;
531 }
532 } else if (prop && !strcmp(prop, "otg")) {
533 usb_data.operating_mode = FSL_USB2_DR_OTG;
534 usb_dev_dr_host = platform_device_register_simple(
535 "fsl-ehci", i, r, 2);
536 if (IS_ERR(usb_dev_dr_host)) {
537 ret = PTR_ERR(usb_dev_dr_host);
538 goto err;
539 }
540 usb_dev_dr_client = platform_device_register_simple(
541 "fsl-usb2-udc", i, r, 2);
542 if (IS_ERR(usb_dev_dr_client)) {
543 ret = PTR_ERR(usb_dev_dr_client);
544 goto err;
545 }
546 } else {
547 ret = -EINVAL;
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600548 goto err;
549 }
550
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000551 prop = of_get_property(np, "phy_type", NULL);
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600552 usb_data.phy_mode = determine_usb_phy(prop);
553
Li Yang97c5a202007-02-07 13:49:24 +0800554 if (usb_dev_dr_host) {
555 usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL;
556 usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host->
557 dev.coherent_dma_mask;
558 if ((ret = platform_device_add_data(usb_dev_dr_host,
559 &usb_data, sizeof(struct
560 fsl_usb2_platform_data))))
561 goto unreg_dr;
562 }
563 if (usb_dev_dr_client) {
564 usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL;
565 usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client->
566 dev.coherent_dma_mask;
567 if ((ret = platform_device_add_data(usb_dev_dr_client,
568 &usb_data, sizeof(struct
569 fsl_usb2_platform_data))))
570 goto unreg_dr;
571 }
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600572 }
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600573 return 0;
574
Kumar Gala01cced22006-04-11 10:07:16 -0500575unreg_dr:
Li Yang97c5a202007-02-07 13:49:24 +0800576 if (usb_dev_dr_host)
577 platform_device_unregister(usb_dev_dr_host);
578 if (usb_dev_dr_client)
579 platform_device_unregister(usb_dev_dr_client);
Kumar Gala01cced22006-04-11 10:07:16 -0500580unreg_mph:
581 if (usb_dev_mph)
582 platform_device_unregister(usb_dev_mph);
Kumar Gala4b10cfd2006-02-02 12:31:00 -0600583err:
584 return ret;
585}
586
Kumar Gala01cced22006-04-11 10:07:16 -0500587arch_initcall(fsl_usb_of_init);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400588
589#ifdef CONFIG_CPM2
590
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +0300591extern void init_scc_ioports(struct fs_uart_platform_info*);
592
Vitaly Bordugfba43662006-09-21 17:26:34 +0400593static const char fcc_regs[] = "fcc_regs";
594static const char fcc_regs_c[] = "fcc_regs_c";
595static const char fcc_pram[] = "fcc_pram";
596static char bus_id[9][BUS_ID_SIZE];
597
598static int __init fs_enet_of_init(void)
599{
600 struct device_node *np;
601 unsigned int i;
602 struct platform_device *fs_enet_dev;
603 struct resource res;
604 int ret;
605
606 for (np = NULL, i = 0;
607 (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL;
608 i++) {
609 struct resource r[4];
610 struct device_node *phy, *mdio;
611 struct fs_platform_info fs_enet_data;
Olof Johansson2b00b252006-10-05 21:16:48 -0500612 const unsigned int *id, *phy_addr, *phy_irq;
Vitaly Bordugfba43662006-09-21 17:26:34 +0400613 const void *mac_addr;
614 const phandle *ph;
615 const char *model;
616
617 memset(r, 0, sizeof(r));
618 memset(&fs_enet_data, 0, sizeof(fs_enet_data));
619
620 ret = of_address_to_resource(np, 0, &r[0]);
621 if (ret)
622 goto err;
623 r[0].name = fcc_regs;
624
625 ret = of_address_to_resource(np, 1, &r[1]);
626 if (ret)
627 goto err;
628 r[1].name = fcc_pram;
629
630 ret = of_address_to_resource(np, 2, &r[2]);
631 if (ret)
632 goto err;
633 r[2].name = fcc_regs_c;
Vitaly Borduged943c12006-10-02 22:41:50 +0400634 fs_enet_data.fcc_regs_c = r[2].start;
Vitaly Bordugfba43662006-09-21 17:26:34 +0400635
Andy Fleminga9b14972006-10-19 19:52:26 -0500636 of_irq_to_resource(np, 0, &r[3]);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400637
638 fs_enet_dev =
639 platform_device_register_simple("fsl-cpm-fcc", i, &r[0], 4);
640
641 if (IS_ERR(fs_enet_dev)) {
642 ret = PTR_ERR(fs_enet_dev);
643 goto err;
644 }
645
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000646 model = of_get_property(np, "model", NULL);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400647 if (model == NULL) {
648 ret = -ENODEV;
649 goto unreg;
650 }
651
Timur Tabi29cfe6f2007-02-16 12:01:29 -0600652 mac_addr = of_get_mac_address(np);
653 if (mac_addr)
654 memcpy(fs_enet_data.macaddr, mac_addr, 6);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400655
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000656 ph = of_get_property(np, "phy-handle", NULL);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400657 phy = of_find_node_by_phandle(*ph);
658
659 if (phy == NULL) {
660 ret = -ENODEV;
661 goto unreg;
662 }
663
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000664 phy_addr = of_get_property(phy, "reg", NULL);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400665 fs_enet_data.phy_addr = *phy_addr;
666
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000667 phy_irq = of_get_property(phy, "interrupts", NULL);
Vitaly Borduged943c12006-10-02 22:41:50 +0400668
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000669 id = of_get_property(np, "device-id", NULL);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400670 fs_enet_data.fs_no = *id;
Vitaly Bordug611a15a2006-09-21 22:38:05 +0400671 strcpy(fs_enet_data.fs_type, model);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400672
673 mdio = of_get_parent(phy);
674 ret = of_address_to_resource(mdio, 0, &res);
675 if (ret) {
676 of_node_put(phy);
677 of_node_put(mdio);
678 goto unreg;
679 }
680
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000681 fs_enet_data.clk_rx = *((u32 *)of_get_property(np,
682 "rx-clock", NULL));
683 fs_enet_data.clk_tx = *((u32 *)of_get_property(np,
684 "tx-clock", NULL));
Vitaly Bordugd3465c92006-09-21 22:38:05 +0400685
Vitaly Bordugfba43662006-09-21 17:26:34 +0400686 if (strstr(model, "FCC")) {
Vitaly Bordug611a15a2006-09-21 22:38:05 +0400687 int fcc_index = *id - 1;
Olof Johansson2b00b252006-10-05 21:16:48 -0500688 const unsigned char *mdio_bb_prop;
Vitaly Bordugfba43662006-09-21 17:26:34 +0400689
Vitaly Bordugfc8e50e2006-09-21 22:37:58 +0400690 fs_enet_data.dpram_offset = (u32)cpm_dpram_addr(0);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400691 fs_enet_data.rx_ring = 32;
692 fs_enet_data.tx_ring = 32;
693 fs_enet_data.rx_copybreak = 240;
694 fs_enet_data.use_napi = 0;
695 fs_enet_data.napi_weight = 17;
696 fs_enet_data.mem_offset = FCC_MEM_OFFSET(fcc_index);
697 fs_enet_data.cp_page = CPM_CR_FCC_PAGE(fcc_index);
698 fs_enet_data.cp_block = CPM_CR_FCC_SBLOCK(fcc_index);
699
700 snprintf((char*)&bus_id[(*id)], BUS_ID_SIZE, "%x:%02x",
701 (u32)res.start, fs_enet_data.phy_addr);
702 fs_enet_data.bus_id = (char*)&bus_id[(*id)];
Vitaly Bordugd3465c92006-09-21 22:38:05 +0400703 fs_enet_data.init_ioports = init_fcc_ioports;
Vitaly Bordugfba43662006-09-21 17:26:34 +0400704
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000705 mdio_bb_prop = of_get_property(phy, "bitbang", NULL);
Vitaly Borduged943c12006-10-02 22:41:50 +0400706 if (mdio_bb_prop) {
707 struct platform_device *fs_enet_mdio_bb_dev;
708 struct fs_mii_bb_platform_info fs_enet_mdio_bb_data;
Vitaly Bordugfba43662006-09-21 17:26:34 +0400709
Vitaly Borduged943c12006-10-02 22:41:50 +0400710 fs_enet_mdio_bb_dev =
711 platform_device_register_simple("fsl-bb-mdio",
712 i, NULL, 0);
713 memset(&fs_enet_mdio_bb_data, 0,
714 sizeof(struct fs_mii_bb_platform_info));
715 fs_enet_mdio_bb_data.mdio_dat.bit =
716 mdio_bb_prop[0];
717 fs_enet_mdio_bb_data.mdio_dir.bit =
718 mdio_bb_prop[1];
719 fs_enet_mdio_bb_data.mdc_dat.bit =
720 mdio_bb_prop[2];
721 fs_enet_mdio_bb_data.mdio_port =
722 mdio_bb_prop[3];
723 fs_enet_mdio_bb_data.mdc_port =
724 mdio_bb_prop[4];
725 fs_enet_mdio_bb_data.delay =
726 mdio_bb_prop[5];
727
728 fs_enet_mdio_bb_data.irq[0] = phy_irq[0];
729 fs_enet_mdio_bb_data.irq[1] = -1;
730 fs_enet_mdio_bb_data.irq[2] = -1;
731 fs_enet_mdio_bb_data.irq[3] = phy_irq[0];
732 fs_enet_mdio_bb_data.irq[31] = -1;
733
734 fs_enet_mdio_bb_data.mdio_dat.offset =
735 (u32)&cpm2_immr->im_ioport.iop_pdatc;
736 fs_enet_mdio_bb_data.mdio_dir.offset =
737 (u32)&cpm2_immr->im_ioport.iop_pdirc;
738 fs_enet_mdio_bb_data.mdc_dat.offset =
739 (u32)&cpm2_immr->im_ioport.iop_pdatc;
740
741 ret = platform_device_add_data(
742 fs_enet_mdio_bb_dev,
743 &fs_enet_mdio_bb_data,
744 sizeof(struct fs_mii_bb_platform_info));
745 if (ret)
746 goto unreg;
747 }
Li Yang97c5a202007-02-07 13:49:24 +0800748
Vitaly Borduged943c12006-10-02 22:41:50 +0400749 of_node_put(phy);
750 of_node_put(mdio);
751
752 ret = platform_device_add_data(fs_enet_dev, &fs_enet_data,
753 sizeof(struct
754 fs_platform_info));
Olof Johansson2b00b252006-10-05 21:16:48 -0500755 if (ret)
756 goto unreg;
757 }
Vitaly Bordugfba43662006-09-21 17:26:34 +0400758 }
759 return 0;
760
761unreg:
762 platform_device_unregister(fs_enet_dev);
763err:
764 return ret;
765}
766
767arch_initcall(fs_enet_of_init);
768
769static const char scc_regs[] = "regs";
770static const char scc_pram[] = "pram";
771
772static int __init cpm_uart_of_init(void)
773{
774 struct device_node *np;
775 unsigned int i;
776 struct platform_device *cpm_uart_dev;
777 int ret;
778
779 for (np = NULL, i = 0;
780 (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL;
781 i++) {
782 struct resource r[3];
783 struct fs_uart_platform_info cpm_uart_data;
784 const int *id;
Vitaly Bordug611a15a2006-09-21 22:38:05 +0400785 const char *model;
Vitaly Bordugfba43662006-09-21 17:26:34 +0400786
787 memset(r, 0, sizeof(r));
788 memset(&cpm_uart_data, 0, sizeof(cpm_uart_data));
789
790 ret = of_address_to_resource(np, 0, &r[0]);
791 if (ret)
792 goto err;
793
794 r[0].name = scc_regs;
795
796 ret = of_address_to_resource(np, 1, &r[1]);
797 if (ret)
798 goto err;
799 r[1].name = scc_pram;
800
Andy Fleminga9b14972006-10-19 19:52:26 -0500801 of_irq_to_resource(np, 0, &r[2]);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400802
803 cpm_uart_dev =
804 platform_device_register_simple("fsl-cpm-scc:uart", i, &r[0], 3);
805
806 if (IS_ERR(cpm_uart_dev)) {
807 ret = PTR_ERR(cpm_uart_dev);
808 goto err;
809 }
810
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000811 id = of_get_property(np, "device-id", NULL);
Vitaly Bordugfba43662006-09-21 17:26:34 +0400812 cpm_uart_data.fs_no = *id;
Vitaly Bordug611a15a2006-09-21 22:38:05 +0400813
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000814 model = of_get_property(np, "model", NULL);
Vitaly Bordug611a15a2006-09-21 22:38:05 +0400815 strcpy(cpm_uart_data.fs_type, model);
816
Vitaly Bordugfba43662006-09-21 17:26:34 +0400817 cpm_uart_data.uart_clk = ppc_proc_freq;
818
819 cpm_uart_data.tx_num_fifo = 4;
820 cpm_uart_data.tx_buf_size = 32;
821 cpm_uart_data.rx_num_fifo = 4;
822 cpm_uart_data.rx_buf_size = 32;
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000823 cpm_uart_data.clk_rx = *((u32 *)of_get_property(np,
824 "rx-clock", NULL));
825 cpm_uart_data.clk_tx = *((u32 *)of_get_property(np,
826 "tx-clock", NULL));
Vitaly Bordugfba43662006-09-21 17:26:34 +0400827
828 ret =
829 platform_device_add_data(cpm_uart_dev, &cpm_uart_data,
830 sizeof(struct
831 fs_uart_platform_info));
832 if (ret)
833 goto unreg;
834 }
835
836 return 0;
837
838unreg:
839 platform_device_unregister(cpm_uart_dev);
840err:
841 return ret;
842}
843
844arch_initcall(cpm_uart_of_init);
845#endif /* CONFIG_CPM2 */
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +0300846
847#ifdef CONFIG_8xx
848
849extern void init_scc_ioports(struct fs_platform_info*);
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000850extern int platform_device_skip(const char *model, int id);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +0300851
852static int __init fs_enet_mdio_of_init(void)
853{
854 struct device_node *np;
855 unsigned int i;
856 struct platform_device *mdio_dev;
857 struct resource res;
858 int ret;
859
860 for (np = NULL, i = 0;
861 (np = of_find_compatible_node(np, "mdio", "fs_enet")) != NULL;
862 i++) {
863 struct fs_mii_fec_platform_info mdio_data;
864
865 memset(&res, 0, sizeof(res));
866 memset(&mdio_data, 0, sizeof(mdio_data));
867
868 ret = of_address_to_resource(np, 0, &res);
869 if (ret)
870 goto err;
871
872 mdio_dev =
873 platform_device_register_simple("fsl-cpm-fec-mdio",
874 res.start, &res, 1);
875 if (IS_ERR(mdio_dev)) {
876 ret = PTR_ERR(mdio_dev);
877 goto err;
878 }
879
880 mdio_data.mii_speed = ((((ppc_proc_freq + 4999999) / 2500000) / 2) & 0x3F) << 1;
881
882 ret =
883 platform_device_add_data(mdio_dev, &mdio_data,
884 sizeof(struct fs_mii_fec_platform_info));
885 if (ret)
886 goto unreg;
887 }
888 return 0;
889
890unreg:
891 platform_device_unregister(mdio_dev);
892err:
893 return ret;
894}
895
896arch_initcall(fs_enet_mdio_of_init);
897
898static const char *enet_regs = "regs";
899static const char *enet_pram = "pram";
900static const char *enet_irq = "interrupt";
901static char bus_id[9][BUS_ID_SIZE];
902
903static int __init fs_enet_of_init(void)
904{
905 struct device_node *np;
906 unsigned int i;
907 struct platform_device *fs_enet_dev = NULL;
908 struct resource res;
909 int ret;
910
911 for (np = NULL, i = 0;
912 (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL;
913 i++) {
914 struct resource r[4];
915 struct device_node *phy = NULL, *mdio = NULL;
916 struct fs_platform_info fs_enet_data;
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000917 const unsigned int *id;
918 const unsigned int *phy_addr;
Scott Woodb7a69122007-05-09 03:15:34 +1000919 const void *mac_addr;
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000920 const phandle *ph;
921 const char *model;
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +0300922
923 memset(r, 0, sizeof(r));
924 memset(&fs_enet_data, 0, sizeof(fs_enet_data));
925
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000926 model = of_get_property(np, "model", NULL);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +0300927 if (model == NULL) {
928 ret = -ENODEV;
929 goto unreg;
930 }
931
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000932 id = of_get_property(np, "device-id", NULL);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +0300933 fs_enet_data.fs_no = *id;
934
935 if (platform_device_skip(model, *id))
936 continue;
937
938 ret = of_address_to_resource(np, 0, &r[0]);
939 if (ret)
940 goto err;
941 r[0].name = enet_regs;
942
Timur Tabi29cfe6f2007-02-16 12:01:29 -0600943 mac_addr = of_get_mac_address(np);
944 if (mac_addr)
945 memcpy(fs_enet_data.macaddr, mac_addr, 6);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +0300946
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000947 ph = of_get_property(np, "phy-handle", NULL);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +0300948 if (ph != NULL)
949 phy = of_find_node_by_phandle(*ph);
950
951 if (phy != NULL) {
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000952 phy_addr = of_get_property(phy, "reg", NULL);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +0300953 fs_enet_data.phy_addr = *phy_addr;
954 fs_enet_data.has_phy = 1;
955
956 mdio = of_get_parent(phy);
957 ret = of_address_to_resource(mdio, 0, &res);
958 if (ret) {
959 of_node_put(phy);
960 of_node_put(mdio);
961 goto unreg;
962 }
963 }
964
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000965 model = of_get_property(np, "model", NULL);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +0300966 strcpy(fs_enet_data.fs_type, model);
967
968 if (strstr(model, "FEC")) {
969 r[1].start = r[1].end = irq_of_parse_and_map(np, 0);
970 r[1].flags = IORESOURCE_IRQ;
971 r[1].name = enet_irq;
972
973 fs_enet_dev =
974 platform_device_register_simple("fsl-cpm-fec", i, &r[0], 2);
975
976 if (IS_ERR(fs_enet_dev)) {
977 ret = PTR_ERR(fs_enet_dev);
978 goto err;
979 }
980
981 fs_enet_data.rx_ring = 128;
982 fs_enet_data.tx_ring = 16;
983 fs_enet_data.rx_copybreak = 240;
984 fs_enet_data.use_napi = 1;
985 fs_enet_data.napi_weight = 17;
986
987 snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%x:%02x",
988 (u32)res.start, fs_enet_data.phy_addr);
989 fs_enet_data.bus_id = (char*)&bus_id[i];
990 fs_enet_data.init_ioports = init_fec_ioports;
991 }
992 if (strstr(model, "SCC")) {
993 ret = of_address_to_resource(np, 1, &r[1]);
994 if (ret)
995 goto err;
996 r[1].name = enet_pram;
997
998 r[2].start = r[2].end = irq_of_parse_and_map(np, 0);
999 r[2].flags = IORESOURCE_IRQ;
1000 r[2].name = enet_irq;
1001
1002 fs_enet_dev =
1003 platform_device_register_simple("fsl-cpm-scc", i, &r[0], 3);
1004
1005 if (IS_ERR(fs_enet_dev)) {
1006 ret = PTR_ERR(fs_enet_dev);
1007 goto err;
1008 }
1009
1010 fs_enet_data.rx_ring = 64;
1011 fs_enet_data.tx_ring = 8;
1012 fs_enet_data.rx_copybreak = 240;
1013 fs_enet_data.use_napi = 1;
1014 fs_enet_data.napi_weight = 17;
1015
1016 snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%s", "fixed@10:1");
1017 fs_enet_data.bus_id = (char*)&bus_id[i];
1018 fs_enet_data.init_ioports = init_scc_ioports;
1019 }
1020
1021 of_node_put(phy);
1022 of_node_put(mdio);
1023
1024 ret = platform_device_add_data(fs_enet_dev, &fs_enet_data,
1025 sizeof(struct
1026 fs_platform_info));
1027 if (ret)
1028 goto unreg;
1029 }
1030 return 0;
1031
1032unreg:
1033 platform_device_unregister(fs_enet_dev);
1034err:
1035 return ret;
1036}
1037
1038arch_initcall(fs_enet_of_init);
1039
Vitaly Bordug80128ff2007-07-09 11:37:35 -07001040static int __init fsl_pcmcia_of_init(void)
1041{
1042 struct device_node *np = NULL;
1043 /*
1044 * Register all the devices which type is "pcmcia"
1045 */
1046 while ((np = of_find_compatible_node(np,
1047 "pcmcia", "fsl,pq-pcmcia")) != NULL)
1048 of_platform_device_create(np, "m8xx-pcmcia", NULL);
1049 return 0;
1050}
1051
1052arch_initcall(fsl_pcmcia_of_init);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +03001053
1054static const char *smc_regs = "regs";
1055static const char *smc_pram = "pram";
1056
1057static int __init cpm_smc_uart_of_init(void)
1058{
1059 struct device_node *np;
1060 unsigned int i;
1061 struct platform_device *cpm_uart_dev;
1062 int ret;
1063
1064 for (np = NULL, i = 0;
1065 (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL;
1066 i++) {
1067 struct resource r[3];
1068 struct fs_uart_platform_info cpm_uart_data;
Stephen Rothwelle2eb6392007-04-03 22:26:41 +10001069 const int *id;
1070 const char *model;
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +03001071
1072 memset(r, 0, sizeof(r));
1073 memset(&cpm_uart_data, 0, sizeof(cpm_uart_data));
1074
1075 ret = of_address_to_resource(np, 0, &r[0]);
1076 if (ret)
1077 goto err;
1078
1079 r[0].name = smc_regs;
1080
1081 ret = of_address_to_resource(np, 1, &r[1]);
1082 if (ret)
1083 goto err;
1084 r[1].name = smc_pram;
1085
1086 r[2].start = r[2].end = irq_of_parse_and_map(np, 0);
1087 r[2].flags = IORESOURCE_IRQ;
1088
1089 cpm_uart_dev =
1090 platform_device_register_simple("fsl-cpm-smc:uart", i, &r[0], 3);
1091
1092 if (IS_ERR(cpm_uart_dev)) {
1093 ret = PTR_ERR(cpm_uart_dev);
1094 goto err;
1095 }
1096
Stephen Rothwelle2eb6392007-04-03 22:26:41 +10001097 model = of_get_property(np, "model", NULL);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +03001098 strcpy(cpm_uart_data.fs_type, model);
1099
Stephen Rothwelle2eb6392007-04-03 22:26:41 +10001100 id = of_get_property(np, "device-id", NULL);
Vitaly Bordug88bdc6f2007-01-24 22:41:15 +03001101 cpm_uart_data.fs_no = *id;
1102 cpm_uart_data.uart_clk = ppc_proc_freq;
1103
1104 cpm_uart_data.tx_num_fifo = 4;
1105 cpm_uart_data.tx_buf_size = 32;
1106 cpm_uart_data.rx_num_fifo = 4;
1107 cpm_uart_data.rx_buf_size = 32;
1108
1109 ret =
1110 platform_device_add_data(cpm_uart_dev, &cpm_uart_data,
1111 sizeof(struct
1112 fs_uart_platform_info));
1113 if (ret)
1114 goto unreg;
1115 }
1116
1117 return 0;
1118
1119unreg:
1120 platform_device_unregister(cpm_uart_dev);
1121err:
1122 return ret;
1123}
1124
1125arch_initcall(cpm_smc_uart_of_init);
1126
1127#endif /* CONFIG_8xx */