fsl_soc.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. /*
  2. * FSL SoC setup code
  3. *
  4. * Maintained by Kumar Gala (see MAINTAINERS for contact information)
  5. *
  6. * 2006 (c) MontaVista Software, Inc.
  7. * Vitaly Bordug <vbordug@ru.mvista.com>
  8. *
  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. #include <linux/stddef.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/errno.h>
  18. #include <linux/major.h>
  19. #include <linux/delay.h>
  20. #include <linux/irq.h>
  21. #include <linux/module.h>
  22. #include <linux/device.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/fsl_devices.h>
  25. #include <linux/fs_enet_pd.h>
  26. #include <linux/fs_uart_pd.h>
  27. #include <asm/system.h>
  28. #include <asm/atomic.h>
  29. #include <asm/io.h>
  30. #include <asm/irq.h>
  31. #include <asm/time.h>
  32. #include <asm/prom.h>
  33. #include <sysdev/fsl_soc.h>
  34. #include <mm/mmu_decl.h>
  35. #include <asm/cpm2.h>
  36. extern void init_fcc_ioports(struct fs_platform_info*);
  37. extern void init_scc_ioports(struct fs_uart_platform_info*);
  38. static phys_addr_t immrbase = -1;
  39. phys_addr_t get_immrbase(void)
  40. {
  41. struct device_node *soc;
  42. if (immrbase != -1)
  43. return immrbase;
  44. soc = of_find_node_by_type(NULL, "soc");
  45. if (soc) {
  46. unsigned int size;
  47. const void *prop = get_property(soc, "reg", &size);
  48. if (prop)
  49. immrbase = of_translate_address(soc, prop);
  50. of_node_put(soc);
  51. };
  52. return immrbase;
  53. }
  54. EXPORT_SYMBOL(get_immrbase);
  55. #ifdef CONFIG_CPM2
  56. static u32 brgfreq = -1;
  57. u32 get_brgfreq(void)
  58. {
  59. struct device_node *node;
  60. if (brgfreq != -1)
  61. return brgfreq;
  62. node = of_find_node_by_type(NULL, "cpm");
  63. if (node) {
  64. unsigned int size;
  65. const unsigned int *prop = get_property(node, "brg-frequency",
  66. &size);
  67. if (prop)
  68. brgfreq = *prop;
  69. of_node_put(node);
  70. };
  71. return brgfreq;
  72. }
  73. EXPORT_SYMBOL(get_brgfreq);
  74. static u32 fs_baudrate = -1;
  75. u32 get_baudrate(void)
  76. {
  77. struct device_node *node;
  78. if (fs_baudrate != -1)
  79. return fs_baudrate;
  80. node = of_find_node_by_type(NULL, "serial");
  81. if (node) {
  82. unsigned int size;
  83. const unsigned int *prop = get_property(node, "current-speed",
  84. &size);
  85. if (prop)
  86. fs_baudrate = *prop;
  87. of_node_put(node);
  88. };
  89. return fs_baudrate;
  90. }
  91. EXPORT_SYMBOL(get_baudrate);
  92. #endif /* CONFIG_CPM2 */
  93. static int __init gfar_mdio_of_init(void)
  94. {
  95. struct device_node *np;
  96. unsigned int i;
  97. struct platform_device *mdio_dev;
  98. struct resource res;
  99. int ret;
  100. for (np = NULL, i = 0;
  101. (np = of_find_compatible_node(np, "mdio", "gianfar")) != NULL;
  102. i++) {
  103. int k;
  104. struct device_node *child = NULL;
  105. struct gianfar_mdio_data mdio_data;
  106. memset(&res, 0, sizeof(res));
  107. memset(&mdio_data, 0, sizeof(mdio_data));
  108. ret = of_address_to_resource(np, 0, &res);
  109. if (ret)
  110. goto err;
  111. mdio_dev =
  112. platform_device_register_simple("fsl-gianfar_mdio",
  113. res.start, &res, 1);
  114. if (IS_ERR(mdio_dev)) {
  115. ret = PTR_ERR(mdio_dev);
  116. goto err;
  117. }
  118. for (k = 0; k < 32; k++)
  119. mdio_data.irq[k] = -1;
  120. while ((child = of_get_next_child(np, child)) != NULL) {
  121. int irq = irq_of_parse_and_map(child, 0);
  122. if (irq != NO_IRQ) {
  123. const u32 *id = get_property(child, "reg", NULL);
  124. mdio_data.irq[*id] = irq;
  125. }
  126. }
  127. ret =
  128. platform_device_add_data(mdio_dev, &mdio_data,
  129. sizeof(struct gianfar_mdio_data));
  130. if (ret)
  131. goto unreg;
  132. }
  133. return 0;
  134. unreg:
  135. platform_device_unregister(mdio_dev);
  136. err:
  137. return ret;
  138. }
  139. arch_initcall(gfar_mdio_of_init);
  140. static const char *gfar_tx_intr = "tx";
  141. static const char *gfar_rx_intr = "rx";
  142. static const char *gfar_err_intr = "error";
  143. static int __init gfar_of_init(void)
  144. {
  145. struct device_node *np;
  146. unsigned int i;
  147. struct platform_device *gfar_dev;
  148. struct resource res;
  149. int ret;
  150. for (np = NULL, i = 0;
  151. (np = of_find_compatible_node(np, "network", "gianfar")) != NULL;
  152. i++) {
  153. struct resource r[4];
  154. struct device_node *phy, *mdio;
  155. struct gianfar_platform_data gfar_data;
  156. const unsigned int *id;
  157. const char *model;
  158. const void *mac_addr;
  159. const phandle *ph;
  160. int n_res = 2;
  161. memset(r, 0, sizeof(r));
  162. memset(&gfar_data, 0, sizeof(gfar_data));
  163. ret = of_address_to_resource(np, 0, &r[0]);
  164. if (ret)
  165. goto err;
  166. r[1].start = r[1].end = irq_of_parse_and_map(np, 0);
  167. r[1].flags = IORESOURCE_IRQ;
  168. model = get_property(np, "model", NULL);
  169. /* If we aren't the FEC we have multiple interrupts */
  170. if (model && strcasecmp(model, "FEC")) {
  171. r[1].name = gfar_tx_intr;
  172. r[2].name = gfar_rx_intr;
  173. r[2].start = r[2].end = irq_of_parse_and_map(np, 1);
  174. r[2].flags = IORESOURCE_IRQ;
  175. r[3].name = gfar_err_intr;
  176. r[3].start = r[3].end = irq_of_parse_and_map(np, 2);
  177. r[3].flags = IORESOURCE_IRQ;
  178. n_res += 2;
  179. }
  180. gfar_dev =
  181. platform_device_register_simple("fsl-gianfar", i, &r[0],
  182. n_res);
  183. if (IS_ERR(gfar_dev)) {
  184. ret = PTR_ERR(gfar_dev);
  185. goto err;
  186. }
  187. mac_addr = get_property(np, "local-mac-address", NULL);
  188. if (mac_addr == NULL)
  189. mac_addr = get_property(np, "mac-address", NULL);
  190. if (mac_addr == NULL) {
  191. /* Obsolete */
  192. mac_addr = get_property(np, "address", NULL);
  193. }
  194. if (mac_addr)
  195. memcpy(gfar_data.mac_addr, mac_addr, 6);
  196. if (model && !strcasecmp(model, "TSEC"))
  197. gfar_data.device_flags =
  198. FSL_GIANFAR_DEV_HAS_GIGABIT |
  199. FSL_GIANFAR_DEV_HAS_COALESCE |
  200. FSL_GIANFAR_DEV_HAS_RMON |
  201. FSL_GIANFAR_DEV_HAS_MULTI_INTR;
  202. if (model && !strcasecmp(model, "eTSEC"))
  203. gfar_data.device_flags =
  204. FSL_GIANFAR_DEV_HAS_GIGABIT |
  205. FSL_GIANFAR_DEV_HAS_COALESCE |
  206. FSL_GIANFAR_DEV_HAS_RMON |
  207. FSL_GIANFAR_DEV_HAS_MULTI_INTR |
  208. FSL_GIANFAR_DEV_HAS_CSUM |
  209. FSL_GIANFAR_DEV_HAS_VLAN |
  210. FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
  211. ph = get_property(np, "phy-handle", NULL);
  212. phy = of_find_node_by_phandle(*ph);
  213. if (phy == NULL) {
  214. ret = -ENODEV;
  215. goto unreg;
  216. }
  217. mdio = of_get_parent(phy);
  218. id = get_property(phy, "reg", NULL);
  219. ret = of_address_to_resource(mdio, 0, &res);
  220. if (ret) {
  221. of_node_put(phy);
  222. of_node_put(mdio);
  223. goto unreg;
  224. }
  225. gfar_data.phy_id = *id;
  226. gfar_data.bus_id = res.start;
  227. of_node_put(phy);
  228. of_node_put(mdio);
  229. ret =
  230. platform_device_add_data(gfar_dev, &gfar_data,
  231. sizeof(struct
  232. gianfar_platform_data));
  233. if (ret)
  234. goto unreg;
  235. }
  236. return 0;
  237. unreg:
  238. platform_device_unregister(gfar_dev);
  239. err:
  240. return ret;
  241. }
  242. arch_initcall(gfar_of_init);
  243. static int __init fsl_i2c_of_init(void)
  244. {
  245. struct device_node *np;
  246. unsigned int i;
  247. struct platform_device *i2c_dev;
  248. int ret;
  249. for (np = NULL, i = 0;
  250. (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
  251. i++) {
  252. struct resource r[2];
  253. struct fsl_i2c_platform_data i2c_data;
  254. const unsigned char *flags = NULL;
  255. memset(&r, 0, sizeof(r));
  256. memset(&i2c_data, 0, sizeof(i2c_data));
  257. ret = of_address_to_resource(np, 0, &r[0]);
  258. if (ret)
  259. goto err;
  260. r[1].start = r[1].end = irq_of_parse_and_map(np, 0);
  261. r[1].flags = IORESOURCE_IRQ;
  262. i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
  263. if (IS_ERR(i2c_dev)) {
  264. ret = PTR_ERR(i2c_dev);
  265. goto err;
  266. }
  267. i2c_data.device_flags = 0;
  268. flags = get_property(np, "dfsrr", NULL);
  269. if (flags)
  270. i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
  271. flags = get_property(np, "fsl5200-clocking", NULL);
  272. if (flags)
  273. i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
  274. ret =
  275. platform_device_add_data(i2c_dev, &i2c_data,
  276. sizeof(struct
  277. fsl_i2c_platform_data));
  278. if (ret)
  279. goto unreg;
  280. }
  281. return 0;
  282. unreg:
  283. platform_device_unregister(i2c_dev);
  284. err:
  285. return ret;
  286. }
  287. arch_initcall(fsl_i2c_of_init);
  288. #ifdef CONFIG_PPC_83xx
  289. static int __init mpc83xx_wdt_init(void)
  290. {
  291. struct resource r;
  292. struct device_node *soc, *np;
  293. struct platform_device *dev;
  294. const unsigned int *freq;
  295. int ret;
  296. np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt");
  297. if (!np) {
  298. ret = -ENODEV;
  299. goto nodev;
  300. }
  301. soc = of_find_node_by_type(NULL, "soc");
  302. if (!soc) {
  303. ret = -ENODEV;
  304. goto nosoc;
  305. }
  306. freq = get_property(soc, "bus-frequency", NULL);
  307. if (!freq) {
  308. ret = -ENODEV;
  309. goto err;
  310. }
  311. memset(&r, 0, sizeof(r));
  312. ret = of_address_to_resource(np, 0, &r);
  313. if (ret)
  314. goto err;
  315. dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1);
  316. if (IS_ERR(dev)) {
  317. ret = PTR_ERR(dev);
  318. goto err;
  319. }
  320. ret = platform_device_add_data(dev, freq, sizeof(int));
  321. if (ret)
  322. goto unreg;
  323. of_node_put(soc);
  324. of_node_put(np);
  325. return 0;
  326. unreg:
  327. platform_device_unregister(dev);
  328. err:
  329. of_node_put(soc);
  330. nosoc:
  331. of_node_put(np);
  332. nodev:
  333. return ret;
  334. }
  335. arch_initcall(mpc83xx_wdt_init);
  336. #endif
  337. static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type)
  338. {
  339. if (!phy_type)
  340. return FSL_USB2_PHY_NONE;
  341. if (!strcasecmp(phy_type, "ulpi"))
  342. return FSL_USB2_PHY_ULPI;
  343. if (!strcasecmp(phy_type, "utmi"))
  344. return FSL_USB2_PHY_UTMI;
  345. if (!strcasecmp(phy_type, "utmi_wide"))
  346. return FSL_USB2_PHY_UTMI_WIDE;
  347. if (!strcasecmp(phy_type, "serial"))
  348. return FSL_USB2_PHY_SERIAL;
  349. return FSL_USB2_PHY_NONE;
  350. }
  351. static int __init fsl_usb_of_init(void)
  352. {
  353. struct device_node *np;
  354. unsigned int i;
  355. struct platform_device *usb_dev_mph = NULL, *usb_dev_dr = NULL;
  356. int ret;
  357. for (np = NULL, i = 0;
  358. (np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) != NULL;
  359. i++) {
  360. struct resource r[2];
  361. struct fsl_usb2_platform_data usb_data;
  362. const unsigned char *prop = NULL;
  363. memset(&r, 0, sizeof(r));
  364. memset(&usb_data, 0, sizeof(usb_data));
  365. ret = of_address_to_resource(np, 0, &r[0]);
  366. if (ret)
  367. goto err;
  368. r[1].start = r[1].end = irq_of_parse_and_map(np, 0);
  369. r[1].flags = IORESOURCE_IRQ;
  370. usb_dev_mph =
  371. platform_device_register_simple("fsl-ehci", i, r, 2);
  372. if (IS_ERR(usb_dev_mph)) {
  373. ret = PTR_ERR(usb_dev_mph);
  374. goto err;
  375. }
  376. usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL;
  377. usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask;
  378. usb_data.operating_mode = FSL_USB2_MPH_HOST;
  379. prop = get_property(np, "port0", NULL);
  380. if (prop)
  381. usb_data.port_enables |= FSL_USB2_PORT0_ENABLED;
  382. prop = get_property(np, "port1", NULL);
  383. if (prop)
  384. usb_data.port_enables |= FSL_USB2_PORT1_ENABLED;
  385. prop = get_property(np, "phy_type", NULL);
  386. usb_data.phy_mode = determine_usb_phy(prop);
  387. ret =
  388. platform_device_add_data(usb_dev_mph, &usb_data,
  389. sizeof(struct
  390. fsl_usb2_platform_data));
  391. if (ret)
  392. goto unreg_mph;
  393. }
  394. for (np = NULL;
  395. (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL;
  396. i++) {
  397. struct resource r[2];
  398. struct fsl_usb2_platform_data usb_data;
  399. const unsigned char *prop = NULL;
  400. memset(&r, 0, sizeof(r));
  401. memset(&usb_data, 0, sizeof(usb_data));
  402. ret = of_address_to_resource(np, 0, &r[0]);
  403. if (ret)
  404. goto unreg_mph;
  405. r[1].start = r[1].end = irq_of_parse_and_map(np, 0);
  406. r[1].flags = IORESOURCE_IRQ;
  407. usb_dev_dr =
  408. platform_device_register_simple("fsl-ehci", i, r, 2);
  409. if (IS_ERR(usb_dev_dr)) {
  410. ret = PTR_ERR(usb_dev_dr);
  411. goto err;
  412. }
  413. usb_dev_dr->dev.coherent_dma_mask = 0xffffffffUL;
  414. usb_dev_dr->dev.dma_mask = &usb_dev_dr->dev.coherent_dma_mask;
  415. usb_data.operating_mode = FSL_USB2_DR_HOST;
  416. prop = get_property(np, "phy_type", NULL);
  417. usb_data.phy_mode = determine_usb_phy(prop);
  418. ret =
  419. platform_device_add_data(usb_dev_dr, &usb_data,
  420. sizeof(struct
  421. fsl_usb2_platform_data));
  422. if (ret)
  423. goto unreg_dr;
  424. }
  425. return 0;
  426. unreg_dr:
  427. if (usb_dev_dr)
  428. platform_device_unregister(usb_dev_dr);
  429. unreg_mph:
  430. if (usb_dev_mph)
  431. platform_device_unregister(usb_dev_mph);
  432. err:
  433. return ret;
  434. }
  435. arch_initcall(fsl_usb_of_init);
  436. #ifdef CONFIG_CPM2
  437. static const char fcc_regs[] = "fcc_regs";
  438. static const char fcc_regs_c[] = "fcc_regs_c";
  439. static const char fcc_pram[] = "fcc_pram";
  440. static char bus_id[9][BUS_ID_SIZE];
  441. static int __init fs_enet_of_init(void)
  442. {
  443. struct device_node *np;
  444. unsigned int i;
  445. struct platform_device *fs_enet_dev;
  446. struct resource res;
  447. int ret;
  448. for (np = NULL, i = 0;
  449. (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL;
  450. i++) {
  451. struct resource r[4];
  452. struct device_node *phy, *mdio;
  453. struct fs_platform_info fs_enet_data;
  454. const unsigned int *id, *phy_addr, *phy_irq;
  455. const void *mac_addr;
  456. const phandle *ph;
  457. const char *model;
  458. memset(r, 0, sizeof(r));
  459. memset(&fs_enet_data, 0, sizeof(fs_enet_data));
  460. ret = of_address_to_resource(np, 0, &r[0]);
  461. if (ret)
  462. goto err;
  463. r[0].name = fcc_regs;
  464. ret = of_address_to_resource(np, 1, &r[1]);
  465. if (ret)
  466. goto err;
  467. r[1].name = fcc_pram;
  468. ret = of_address_to_resource(np, 2, &r[2]);
  469. if (ret)
  470. goto err;
  471. r[2].name = fcc_regs_c;
  472. fs_enet_data.fcc_regs_c = r[2].start;
  473. r[3].start = r[3].end = irq_of_parse_and_map(np, 0);
  474. r[3].flags = IORESOURCE_IRQ;
  475. fs_enet_dev =
  476. platform_device_register_simple("fsl-cpm-fcc", i, &r[0], 4);
  477. if (IS_ERR(fs_enet_dev)) {
  478. ret = PTR_ERR(fs_enet_dev);
  479. goto err;
  480. }
  481. model = get_property(np, "model", NULL);
  482. if (model == NULL) {
  483. ret = -ENODEV;
  484. goto unreg;
  485. }
  486. mac_addr = get_property(np, "mac-address", NULL);
  487. memcpy(fs_enet_data.macaddr, mac_addr, 6);
  488. ph = get_property(np, "phy-handle", NULL);
  489. phy = of_find_node_by_phandle(*ph);
  490. if (phy == NULL) {
  491. ret = -ENODEV;
  492. goto unreg;
  493. }
  494. phy_addr = get_property(phy, "reg", NULL);
  495. fs_enet_data.phy_addr = *phy_addr;
  496. phy_irq = get_property(phy, "interrupts", NULL);
  497. id = get_property(np, "device-id", NULL);
  498. fs_enet_data.fs_no = *id;
  499. strcpy(fs_enet_data.fs_type, model);
  500. mdio = of_get_parent(phy);
  501. ret = of_address_to_resource(mdio, 0, &res);
  502. if (ret) {
  503. of_node_put(phy);
  504. of_node_put(mdio);
  505. goto unreg;
  506. }
  507. fs_enet_data.clk_rx = *((u32 *) get_property(np, "rx-clock", NULL));
  508. fs_enet_data.clk_tx = *((u32 *) get_property(np, "tx-clock", NULL));
  509. if (strstr(model, "FCC")) {
  510. int fcc_index = *id - 1;
  511. const unsigned char *mdio_bb_prop;
  512. fs_enet_data.dpram_offset = (u32)cpm_dpram_addr(0);
  513. fs_enet_data.rx_ring = 32;
  514. fs_enet_data.tx_ring = 32;
  515. fs_enet_data.rx_copybreak = 240;
  516. fs_enet_data.use_napi = 0;
  517. fs_enet_data.napi_weight = 17;
  518. fs_enet_data.mem_offset = FCC_MEM_OFFSET(fcc_index);
  519. fs_enet_data.cp_page = CPM_CR_FCC_PAGE(fcc_index);
  520. fs_enet_data.cp_block = CPM_CR_FCC_SBLOCK(fcc_index);
  521. snprintf((char*)&bus_id[(*id)], BUS_ID_SIZE, "%x:%02x",
  522. (u32)res.start, fs_enet_data.phy_addr);
  523. fs_enet_data.bus_id = (char*)&bus_id[(*id)];
  524. fs_enet_data.init_ioports = init_fcc_ioports;
  525. mdio_bb_prop = get_property(phy, "bitbang", NULL);
  526. if (mdio_bb_prop) {
  527. struct platform_device *fs_enet_mdio_bb_dev;
  528. struct fs_mii_bb_platform_info fs_enet_mdio_bb_data;
  529. fs_enet_mdio_bb_dev =
  530. platform_device_register_simple("fsl-bb-mdio",
  531. i, NULL, 0);
  532. memset(&fs_enet_mdio_bb_data, 0,
  533. sizeof(struct fs_mii_bb_platform_info));
  534. fs_enet_mdio_bb_data.mdio_dat.bit =
  535. mdio_bb_prop[0];
  536. fs_enet_mdio_bb_data.mdio_dir.bit =
  537. mdio_bb_prop[1];
  538. fs_enet_mdio_bb_data.mdc_dat.bit =
  539. mdio_bb_prop[2];
  540. fs_enet_mdio_bb_data.mdio_port =
  541. mdio_bb_prop[3];
  542. fs_enet_mdio_bb_data.mdc_port =
  543. mdio_bb_prop[4];
  544. fs_enet_mdio_bb_data.delay =
  545. mdio_bb_prop[5];
  546. fs_enet_mdio_bb_data.irq[0] = phy_irq[0];
  547. fs_enet_mdio_bb_data.irq[1] = -1;
  548. fs_enet_mdio_bb_data.irq[2] = -1;
  549. fs_enet_mdio_bb_data.irq[3] = phy_irq[0];
  550. fs_enet_mdio_bb_data.irq[31] = -1;
  551. fs_enet_mdio_bb_data.mdio_dat.offset =
  552. (u32)&cpm2_immr->im_ioport.iop_pdatc;
  553. fs_enet_mdio_bb_data.mdio_dir.offset =
  554. (u32)&cpm2_immr->im_ioport.iop_pdirc;
  555. fs_enet_mdio_bb_data.mdc_dat.offset =
  556. (u32)&cpm2_immr->im_ioport.iop_pdatc;
  557. ret = platform_device_add_data(
  558. fs_enet_mdio_bb_dev,
  559. &fs_enet_mdio_bb_data,
  560. sizeof(struct fs_mii_bb_platform_info));
  561. if (ret)
  562. goto unreg;
  563. }
  564. of_node_put(phy);
  565. of_node_put(mdio);
  566. ret = platform_device_add_data(fs_enet_dev, &fs_enet_data,
  567. sizeof(struct
  568. fs_platform_info));
  569. if (ret)
  570. goto unreg;
  571. }
  572. }
  573. return 0;
  574. unreg:
  575. platform_device_unregister(fs_enet_dev);
  576. err:
  577. return ret;
  578. }
  579. arch_initcall(fs_enet_of_init);
  580. static const char scc_regs[] = "regs";
  581. static const char scc_pram[] = "pram";
  582. static int __init cpm_uart_of_init(void)
  583. {
  584. struct device_node *np;
  585. unsigned int i;
  586. struct platform_device *cpm_uart_dev;
  587. int ret;
  588. for (np = NULL, i = 0;
  589. (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL;
  590. i++) {
  591. struct resource r[3];
  592. struct fs_uart_platform_info cpm_uart_data;
  593. const int *id;
  594. const char *model;
  595. memset(r, 0, sizeof(r));
  596. memset(&cpm_uart_data, 0, sizeof(cpm_uart_data));
  597. ret = of_address_to_resource(np, 0, &r[0]);
  598. if (ret)
  599. goto err;
  600. r[0].name = scc_regs;
  601. ret = of_address_to_resource(np, 1, &r[1]);
  602. if (ret)
  603. goto err;
  604. r[1].name = scc_pram;
  605. r[2].start = r[2].end = irq_of_parse_and_map(np, 0);
  606. r[2].flags = IORESOURCE_IRQ;
  607. cpm_uart_dev =
  608. platform_device_register_simple("fsl-cpm-scc:uart", i, &r[0], 3);
  609. if (IS_ERR(cpm_uart_dev)) {
  610. ret = PTR_ERR(cpm_uart_dev);
  611. goto err;
  612. }
  613. id = get_property(np, "device-id", NULL);
  614. cpm_uart_data.fs_no = *id;
  615. model = (char*)get_property(np, "model", NULL);
  616. strcpy(cpm_uart_data.fs_type, model);
  617. cpm_uart_data.uart_clk = ppc_proc_freq;
  618. cpm_uart_data.tx_num_fifo = 4;
  619. cpm_uart_data.tx_buf_size = 32;
  620. cpm_uart_data.rx_num_fifo = 4;
  621. cpm_uart_data.rx_buf_size = 32;
  622. cpm_uart_data.clk_rx = *((u32 *) get_property(np, "rx-clock", NULL));
  623. cpm_uart_data.clk_tx = *((u32 *) get_property(np, "tx-clock", NULL));
  624. ret =
  625. platform_device_add_data(cpm_uart_dev, &cpm_uart_data,
  626. sizeof(struct
  627. fs_uart_platform_info));
  628. if (ret)
  629. goto unreg;
  630. }
  631. return 0;
  632. unreg:
  633. platform_device_unregister(cpm_uart_dev);
  634. err:
  635. return ret;
  636. }
  637. arch_initcall(cpm_uart_of_init);
  638. #endif /* CONFIG_CPM2 */