fsl_soc.c 16 KB

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