4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
6 * 2006 (c) MontaVista Software, Inc.
7 * Vitaly Bordug <vbordug@ru.mvista.com>
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.
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>
25 #include <linux/phy.h>
26 #include <linux/fsl_devices.h>
27 #include <linux/fs_enet_pd.h>
28 #include <linux/fs_uart_pd.h>
30 #include <asm/system.h>
31 #include <asm/atomic.h>
36 #include <sysdev/fsl_soc.h>
37 #include <mm/mmu_decl.h>
40 extern void init_fcc_ioports(struct fs_platform_info*);
41 extern void init_fec_ioports(struct fs_platform_info*);
42 extern void init_smc_ioports(struct fs_uart_platform_info*);
43 static phys_addr_t immrbase = -1;
45 phys_addr_t get_immrbase(void)
47 struct device_node *soc;
52 soc = of_find_node_by_type(NULL, "soc");
55 const void *prop = of_get_property(soc, "reg", &size);
58 immrbase = of_translate_address(soc, prop);
65 EXPORT_SYMBOL(get_immrbase);
67 #if defined(CONFIG_CPM2) || defined(CONFIG_8xx)
69 static u32 brgfreq = -1;
73 struct device_node *node;
78 node = of_find_node_by_type(NULL, "cpm");
81 const unsigned int *prop = of_get_property(node,
82 "brg-frequency", &size);
92 EXPORT_SYMBOL(get_brgfreq);
94 static u32 fs_baudrate = -1;
96 u32 get_baudrate(void)
98 struct device_node *node;
100 if (fs_baudrate != -1)
103 node = of_find_node_by_type(NULL, "serial");
106 const unsigned int *prop = of_get_property(node,
107 "current-speed", &size);
117 EXPORT_SYMBOL(get_baudrate);
118 #endif /* CONFIG_CPM2 */
120 static int __init gfar_mdio_of_init(void)
122 struct device_node *np;
124 struct platform_device *mdio_dev;
128 for (np = NULL, i = 0;
129 (np = of_find_compatible_node(np, "mdio", "gianfar")) != NULL;
132 struct device_node *child = NULL;
133 struct gianfar_mdio_data mdio_data;
135 memset(&res, 0, sizeof(res));
136 memset(&mdio_data, 0, sizeof(mdio_data));
138 ret = of_address_to_resource(np, 0, &res);
143 platform_device_register_simple("fsl-gianfar_mdio",
145 if (IS_ERR(mdio_dev)) {
146 ret = PTR_ERR(mdio_dev);
150 for (k = 0; k < 32; k++)
151 mdio_data.irq[k] = PHY_POLL;
153 while ((child = of_get_next_child(np, child)) != NULL) {
154 int irq = irq_of_parse_and_map(child, 0);
156 const u32 *id = of_get_property(child,
158 mdio_data.irq[*id] = irq;
163 platform_device_add_data(mdio_dev, &mdio_data,
164 sizeof(struct gianfar_mdio_data));
172 platform_device_unregister(mdio_dev);
177 arch_initcall(gfar_mdio_of_init);
179 static const char *gfar_tx_intr = "tx";
180 static const char *gfar_rx_intr = "rx";
181 static const char *gfar_err_intr = "error";
184 static int __init gfar_of_init(void)
186 struct device_node *np;
188 struct platform_device *gfar_dev;
192 for (np = NULL, i = 0;
193 (np = of_find_compatible_node(np, "network", "gianfar")) != NULL;
195 struct resource r[4];
196 struct device_node *phy, *mdio;
197 struct gianfar_platform_data gfar_data;
198 const unsigned int *id;
200 const void *mac_addr;
204 memset(r, 0, sizeof(r));
205 memset(&gfar_data, 0, sizeof(gfar_data));
207 ret = of_address_to_resource(np, 0, &r[0]);
211 of_irq_to_resource(np, 0, &r[1]);
213 model = of_get_property(np, "model", NULL);
215 /* If we aren't the FEC we have multiple interrupts */
216 if (model && strcasecmp(model, "FEC")) {
217 r[1].name = gfar_tx_intr;
219 r[2].name = gfar_rx_intr;
220 of_irq_to_resource(np, 1, &r[2]);
222 r[3].name = gfar_err_intr;
223 of_irq_to_resource(np, 2, &r[3]);
229 platform_device_register_simple("fsl-gianfar", i, &r[0],
232 if (IS_ERR(gfar_dev)) {
233 ret = PTR_ERR(gfar_dev);
237 mac_addr = of_get_mac_address(np);
239 memcpy(gfar_data.mac_addr, mac_addr, 6);
241 if (model && !strcasecmp(model, "TSEC"))
242 gfar_data.device_flags =
243 FSL_GIANFAR_DEV_HAS_GIGABIT |
244 FSL_GIANFAR_DEV_HAS_COALESCE |
245 FSL_GIANFAR_DEV_HAS_RMON |
246 FSL_GIANFAR_DEV_HAS_MULTI_INTR;
247 if (model && !strcasecmp(model, "eTSEC"))
248 gfar_data.device_flags =
249 FSL_GIANFAR_DEV_HAS_GIGABIT |
250 FSL_GIANFAR_DEV_HAS_COALESCE |
251 FSL_GIANFAR_DEV_HAS_RMON |
252 FSL_GIANFAR_DEV_HAS_MULTI_INTR |
253 FSL_GIANFAR_DEV_HAS_CSUM |
254 FSL_GIANFAR_DEV_HAS_VLAN |
255 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
257 ph = of_get_property(np, "phy-handle", NULL);
258 phy = of_find_node_by_phandle(*ph);
265 mdio = of_get_parent(phy);
267 id = of_get_property(phy, "reg", NULL);
268 ret = of_address_to_resource(mdio, 0, &res);
275 gfar_data.phy_id = *id;
276 gfar_data.bus_id = res.start;
282 platform_device_add_data(gfar_dev, &gfar_data,
284 gianfar_platform_data));
292 platform_device_unregister(gfar_dev);
297 arch_initcall(gfar_of_init);
299 static int __init fsl_i2c_of_init(void)
301 struct device_node *np;
303 struct platform_device *i2c_dev;
306 for (np = NULL, i = 0;
307 (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
309 struct resource r[2];
310 struct fsl_i2c_platform_data i2c_data;
311 const unsigned char *flags = NULL;
313 memset(&r, 0, sizeof(r));
314 memset(&i2c_data, 0, sizeof(i2c_data));
316 ret = of_address_to_resource(np, 0, &r[0]);
320 of_irq_to_resource(np, 0, &r[1]);
322 i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
323 if (IS_ERR(i2c_dev)) {
324 ret = PTR_ERR(i2c_dev);
328 i2c_data.device_flags = 0;
329 flags = of_get_property(np, "dfsrr", NULL);
331 i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
333 flags = of_get_property(np, "fsl5200-clocking", NULL);
335 i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
338 platform_device_add_data(i2c_dev, &i2c_data,
340 fsl_i2c_platform_data));
348 platform_device_unregister(i2c_dev);
353 arch_initcall(fsl_i2c_of_init);
355 #ifdef CONFIG_PPC_83xx
356 static int __init mpc83xx_wdt_init(void)
359 struct device_node *soc, *np;
360 struct platform_device *dev;
361 const unsigned int *freq;
364 np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt");
371 soc = of_find_node_by_type(NULL, "soc");
378 freq = of_get_property(soc, "bus-frequency", NULL);
384 memset(&r, 0, sizeof(r));
386 ret = of_address_to_resource(np, 0, &r);
390 dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1);
396 ret = platform_device_add_data(dev, freq, sizeof(int));
406 platform_device_unregister(dev);
415 arch_initcall(mpc83xx_wdt_init);
418 static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type)
421 return FSL_USB2_PHY_NONE;
422 if (!strcasecmp(phy_type, "ulpi"))
423 return FSL_USB2_PHY_ULPI;
424 if (!strcasecmp(phy_type, "utmi"))
425 return FSL_USB2_PHY_UTMI;
426 if (!strcasecmp(phy_type, "utmi_wide"))
427 return FSL_USB2_PHY_UTMI_WIDE;
428 if (!strcasecmp(phy_type, "serial"))
429 return FSL_USB2_PHY_SERIAL;
431 return FSL_USB2_PHY_NONE;
434 static int __init fsl_usb_of_init(void)
436 struct device_node *np;
438 struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL,
439 *usb_dev_dr_client = NULL;
442 for (np = NULL, i = 0;
443 (np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) != NULL;
445 struct resource r[2];
446 struct fsl_usb2_platform_data usb_data;
447 const unsigned char *prop = NULL;
449 memset(&r, 0, sizeof(r));
450 memset(&usb_data, 0, sizeof(usb_data));
452 ret = of_address_to_resource(np, 0, &r[0]);
456 of_irq_to_resource(np, 0, &r[1]);
459 platform_device_register_simple("fsl-ehci", i, r, 2);
460 if (IS_ERR(usb_dev_mph)) {
461 ret = PTR_ERR(usb_dev_mph);
465 usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL;
466 usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask;
468 usb_data.operating_mode = FSL_USB2_MPH_HOST;
470 prop = of_get_property(np, "port0", NULL);
472 usb_data.port_enables |= FSL_USB2_PORT0_ENABLED;
474 prop = of_get_property(np, "port1", NULL);
476 usb_data.port_enables |= FSL_USB2_PORT1_ENABLED;
478 prop = of_get_property(np, "phy_type", NULL);
479 usb_data.phy_mode = determine_usb_phy(prop);
482 platform_device_add_data(usb_dev_mph, &usb_data,
484 fsl_usb2_platform_data));
490 (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL;
492 struct resource r[2];
493 struct fsl_usb2_platform_data usb_data;
494 const unsigned char *prop = NULL;
496 memset(&r, 0, sizeof(r));
497 memset(&usb_data, 0, sizeof(usb_data));
499 ret = of_address_to_resource(np, 0, &r[0]);
503 of_irq_to_resource(np, 0, &r[1]);
505 prop = of_get_property(np, "dr_mode", NULL);
507 if (!prop || !strcmp(prop, "host")) {
508 usb_data.operating_mode = FSL_USB2_DR_HOST;
509 usb_dev_dr_host = platform_device_register_simple(
510 "fsl-ehci", i, r, 2);
511 if (IS_ERR(usb_dev_dr_host)) {
512 ret = PTR_ERR(usb_dev_dr_host);
515 } else if (prop && !strcmp(prop, "peripheral")) {
516 usb_data.operating_mode = FSL_USB2_DR_DEVICE;
517 usb_dev_dr_client = platform_device_register_simple(
518 "fsl-usb2-udc", i, r, 2);
519 if (IS_ERR(usb_dev_dr_client)) {
520 ret = PTR_ERR(usb_dev_dr_client);
523 } else if (prop && !strcmp(prop, "otg")) {
524 usb_data.operating_mode = FSL_USB2_DR_OTG;
525 usb_dev_dr_host = platform_device_register_simple(
526 "fsl-ehci", i, r, 2);
527 if (IS_ERR(usb_dev_dr_host)) {
528 ret = PTR_ERR(usb_dev_dr_host);
531 usb_dev_dr_client = platform_device_register_simple(
532 "fsl-usb2-udc", i, r, 2);
533 if (IS_ERR(usb_dev_dr_client)) {
534 ret = PTR_ERR(usb_dev_dr_client);
542 prop = of_get_property(np, "phy_type", NULL);
543 usb_data.phy_mode = determine_usb_phy(prop);
545 if (usb_dev_dr_host) {
546 usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL;
547 usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host->
548 dev.coherent_dma_mask;
549 if ((ret = platform_device_add_data(usb_dev_dr_host,
550 &usb_data, sizeof(struct
551 fsl_usb2_platform_data))))
554 if (usb_dev_dr_client) {
555 usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL;
556 usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client->
557 dev.coherent_dma_mask;
558 if ((ret = platform_device_add_data(usb_dev_dr_client,
559 &usb_data, sizeof(struct
560 fsl_usb2_platform_data))))
568 platform_device_unregister(usb_dev_dr_host);
569 if (usb_dev_dr_client)
570 platform_device_unregister(usb_dev_dr_client);
573 platform_device_unregister(usb_dev_mph);
578 arch_initcall(fsl_usb_of_init);
582 extern void init_scc_ioports(struct fs_uart_platform_info*);
584 static const char fcc_regs[] = "fcc_regs";
585 static const char fcc_regs_c[] = "fcc_regs_c";
586 static const char fcc_pram[] = "fcc_pram";
587 static char bus_id[9][BUS_ID_SIZE];
589 static int __init fs_enet_of_init(void)
591 struct device_node *np;
593 struct platform_device *fs_enet_dev;
597 for (np = NULL, i = 0;
598 (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL;
600 struct resource r[4];
601 struct device_node *phy, *mdio;
602 struct fs_platform_info fs_enet_data;
603 const unsigned int *id, *phy_addr, *phy_irq;
604 const void *mac_addr;
608 memset(r, 0, sizeof(r));
609 memset(&fs_enet_data, 0, sizeof(fs_enet_data));
611 ret = of_address_to_resource(np, 0, &r[0]);
614 r[0].name = fcc_regs;
616 ret = of_address_to_resource(np, 1, &r[1]);
619 r[1].name = fcc_pram;
621 ret = of_address_to_resource(np, 2, &r[2]);
624 r[2].name = fcc_regs_c;
625 fs_enet_data.fcc_regs_c = r[2].start;
627 of_irq_to_resource(np, 0, &r[3]);
630 platform_device_register_simple("fsl-cpm-fcc", i, &r[0], 4);
632 if (IS_ERR(fs_enet_dev)) {
633 ret = PTR_ERR(fs_enet_dev);
637 model = of_get_property(np, "model", NULL);
643 mac_addr = of_get_mac_address(np);
645 memcpy(fs_enet_data.macaddr, mac_addr, 6);
647 ph = of_get_property(np, "phy-handle", NULL);
648 phy = of_find_node_by_phandle(*ph);
655 phy_addr = of_get_property(phy, "reg", NULL);
656 fs_enet_data.phy_addr = *phy_addr;
658 phy_irq = of_get_property(phy, "interrupts", NULL);
660 id = of_get_property(np, "device-id", NULL);
661 fs_enet_data.fs_no = *id;
662 strcpy(fs_enet_data.fs_type, model);
664 mdio = of_get_parent(phy);
665 ret = of_address_to_resource(mdio, 0, &res);
672 fs_enet_data.clk_rx = *((u32 *)of_get_property(np,
674 fs_enet_data.clk_tx = *((u32 *)of_get_property(np,
677 if (strstr(model, "FCC")) {
678 int fcc_index = *id - 1;
679 const unsigned char *mdio_bb_prop;
681 fs_enet_data.dpram_offset = (u32)cpm_dpram_addr(0);
682 fs_enet_data.rx_ring = 32;
683 fs_enet_data.tx_ring = 32;
684 fs_enet_data.rx_copybreak = 240;
685 fs_enet_data.use_napi = 0;
686 fs_enet_data.napi_weight = 17;
687 fs_enet_data.mem_offset = FCC_MEM_OFFSET(fcc_index);
688 fs_enet_data.cp_page = CPM_CR_FCC_PAGE(fcc_index);
689 fs_enet_data.cp_block = CPM_CR_FCC_SBLOCK(fcc_index);
691 snprintf((char*)&bus_id[(*id)], BUS_ID_SIZE, "%x:%02x",
692 (u32)res.start, fs_enet_data.phy_addr);
693 fs_enet_data.bus_id = (char*)&bus_id[(*id)];
694 fs_enet_data.init_ioports = init_fcc_ioports;
696 mdio_bb_prop = of_get_property(phy, "bitbang", NULL);
698 struct platform_device *fs_enet_mdio_bb_dev;
699 struct fs_mii_bb_platform_info fs_enet_mdio_bb_data;
701 fs_enet_mdio_bb_dev =
702 platform_device_register_simple("fsl-bb-mdio",
704 memset(&fs_enet_mdio_bb_data, 0,
705 sizeof(struct fs_mii_bb_platform_info));
706 fs_enet_mdio_bb_data.mdio_dat.bit =
708 fs_enet_mdio_bb_data.mdio_dir.bit =
710 fs_enet_mdio_bb_data.mdc_dat.bit =
712 fs_enet_mdio_bb_data.mdio_port =
714 fs_enet_mdio_bb_data.mdc_port =
716 fs_enet_mdio_bb_data.delay =
719 fs_enet_mdio_bb_data.irq[0] = phy_irq[0];
720 fs_enet_mdio_bb_data.irq[1] = -1;
721 fs_enet_mdio_bb_data.irq[2] = -1;
722 fs_enet_mdio_bb_data.irq[3] = phy_irq[0];
723 fs_enet_mdio_bb_data.irq[31] = -1;
725 fs_enet_mdio_bb_data.mdio_dat.offset =
726 (u32)&cpm2_immr->im_ioport.iop_pdatc;
727 fs_enet_mdio_bb_data.mdio_dir.offset =
728 (u32)&cpm2_immr->im_ioport.iop_pdirc;
729 fs_enet_mdio_bb_data.mdc_dat.offset =
730 (u32)&cpm2_immr->im_ioport.iop_pdatc;
732 ret = platform_device_add_data(
734 &fs_enet_mdio_bb_data,
735 sizeof(struct fs_mii_bb_platform_info));
743 ret = platform_device_add_data(fs_enet_dev, &fs_enet_data,
753 platform_device_unregister(fs_enet_dev);
758 arch_initcall(fs_enet_of_init);
760 static const char scc_regs[] = "regs";
761 static const char scc_pram[] = "pram";
763 static int __init cpm_uart_of_init(void)
765 struct device_node *np;
767 struct platform_device *cpm_uart_dev;
770 for (np = NULL, i = 0;
771 (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL;
773 struct resource r[3];
774 struct fs_uart_platform_info cpm_uart_data;
778 memset(r, 0, sizeof(r));
779 memset(&cpm_uart_data, 0, sizeof(cpm_uart_data));
781 ret = of_address_to_resource(np, 0, &r[0]);
785 r[0].name = scc_regs;
787 ret = of_address_to_resource(np, 1, &r[1]);
790 r[1].name = scc_pram;
792 of_irq_to_resource(np, 0, &r[2]);
795 platform_device_register_simple("fsl-cpm-scc:uart", i, &r[0], 3);
797 if (IS_ERR(cpm_uart_dev)) {
798 ret = PTR_ERR(cpm_uart_dev);
802 id = of_get_property(np, "device-id", NULL);
803 cpm_uart_data.fs_no = *id;
805 model = of_get_property(np, "model", NULL);
806 strcpy(cpm_uart_data.fs_type, model);
808 cpm_uart_data.uart_clk = ppc_proc_freq;
810 cpm_uart_data.tx_num_fifo = 4;
811 cpm_uart_data.tx_buf_size = 32;
812 cpm_uart_data.rx_num_fifo = 4;
813 cpm_uart_data.rx_buf_size = 32;
814 cpm_uart_data.clk_rx = *((u32 *)of_get_property(np,
816 cpm_uart_data.clk_tx = *((u32 *)of_get_property(np,
820 platform_device_add_data(cpm_uart_dev, &cpm_uart_data,
822 fs_uart_platform_info));
830 platform_device_unregister(cpm_uart_dev);
835 arch_initcall(cpm_uart_of_init);
836 #endif /* CONFIG_CPM2 */
840 extern void init_scc_ioports(struct fs_platform_info*);
841 extern int platform_device_skip(const char *model, int id);
843 static int __init fs_enet_mdio_of_init(void)
845 struct device_node *np;
847 struct platform_device *mdio_dev;
851 for (np = NULL, i = 0;
852 (np = of_find_compatible_node(np, "mdio", "fs_enet")) != NULL;
854 struct fs_mii_fec_platform_info mdio_data;
856 memset(&res, 0, sizeof(res));
857 memset(&mdio_data, 0, sizeof(mdio_data));
859 ret = of_address_to_resource(np, 0, &res);
864 platform_device_register_simple("fsl-cpm-fec-mdio",
866 if (IS_ERR(mdio_dev)) {
867 ret = PTR_ERR(mdio_dev);
871 mdio_data.mii_speed = ((((ppc_proc_freq + 4999999) / 2500000) / 2) & 0x3F) << 1;
874 platform_device_add_data(mdio_dev, &mdio_data,
875 sizeof(struct fs_mii_fec_platform_info));
882 platform_device_unregister(mdio_dev);
887 arch_initcall(fs_enet_mdio_of_init);
889 static const char *enet_regs = "regs";
890 static const char *enet_pram = "pram";
891 static const char *enet_irq = "interrupt";
892 static char bus_id[9][BUS_ID_SIZE];
894 static int __init fs_enet_of_init(void)
896 struct device_node *np;
898 struct platform_device *fs_enet_dev = NULL;
902 for (np = NULL, i = 0;
903 (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL;
905 struct resource r[4];
906 struct device_node *phy = NULL, *mdio = NULL;
907 struct fs_platform_info fs_enet_data;
908 const unsigned int *id;
909 const unsigned int *phy_addr;
914 memset(r, 0, sizeof(r));
915 memset(&fs_enet_data, 0, sizeof(fs_enet_data));
917 model = of_get_property(np, "model", NULL);
923 id = of_get_property(np, "device-id", NULL);
924 fs_enet_data.fs_no = *id;
926 if (platform_device_skip(model, *id))
929 ret = of_address_to_resource(np, 0, &r[0]);
932 r[0].name = enet_regs;
934 mac_addr = of_get_mac_address(np);
936 memcpy(fs_enet_data.macaddr, mac_addr, 6);
938 ph = of_get_property(np, "phy-handle", NULL);
940 phy = of_find_node_by_phandle(*ph);
943 phy_addr = of_get_property(phy, "reg", NULL);
944 fs_enet_data.phy_addr = *phy_addr;
945 fs_enet_data.has_phy = 1;
947 mdio = of_get_parent(phy);
948 ret = of_address_to_resource(mdio, 0, &res);
956 model = of_get_property(np, "model", NULL);
957 strcpy(fs_enet_data.fs_type, model);
959 if (strstr(model, "FEC")) {
960 r[1].start = r[1].end = irq_of_parse_and_map(np, 0);
961 r[1].flags = IORESOURCE_IRQ;
962 r[1].name = enet_irq;
965 platform_device_register_simple("fsl-cpm-fec", i, &r[0], 2);
967 if (IS_ERR(fs_enet_dev)) {
968 ret = PTR_ERR(fs_enet_dev);
972 fs_enet_data.rx_ring = 128;
973 fs_enet_data.tx_ring = 16;
974 fs_enet_data.rx_copybreak = 240;
975 fs_enet_data.use_napi = 1;
976 fs_enet_data.napi_weight = 17;
978 snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%x:%02x",
979 (u32)res.start, fs_enet_data.phy_addr);
980 fs_enet_data.bus_id = (char*)&bus_id[i];
981 fs_enet_data.init_ioports = init_fec_ioports;
983 if (strstr(model, "SCC")) {
984 ret = of_address_to_resource(np, 1, &r[1]);
987 r[1].name = enet_pram;
989 r[2].start = r[2].end = irq_of_parse_and_map(np, 0);
990 r[2].flags = IORESOURCE_IRQ;
991 r[2].name = enet_irq;
994 platform_device_register_simple("fsl-cpm-scc", i, &r[0], 3);
996 if (IS_ERR(fs_enet_dev)) {
997 ret = PTR_ERR(fs_enet_dev);
1001 fs_enet_data.rx_ring = 64;
1002 fs_enet_data.tx_ring = 8;
1003 fs_enet_data.rx_copybreak = 240;
1004 fs_enet_data.use_napi = 1;
1005 fs_enet_data.napi_weight = 17;
1007 snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%s", "fixed@10:1");
1008 fs_enet_data.bus_id = (char*)&bus_id[i];
1009 fs_enet_data.init_ioports = init_scc_ioports;
1015 ret = platform_device_add_data(fs_enet_dev, &fs_enet_data,
1024 platform_device_unregister(fs_enet_dev);
1029 arch_initcall(fs_enet_of_init);
1032 static const char *smc_regs = "regs";
1033 static const char *smc_pram = "pram";
1035 static int __init cpm_smc_uart_of_init(void)
1037 struct device_node *np;
1039 struct platform_device *cpm_uart_dev;
1042 for (np = NULL, i = 0;
1043 (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL;
1045 struct resource r[3];
1046 struct fs_uart_platform_info cpm_uart_data;
1050 memset(r, 0, sizeof(r));
1051 memset(&cpm_uart_data, 0, sizeof(cpm_uart_data));
1053 ret = of_address_to_resource(np, 0, &r[0]);
1057 r[0].name = smc_regs;
1059 ret = of_address_to_resource(np, 1, &r[1]);
1062 r[1].name = smc_pram;
1064 r[2].start = r[2].end = irq_of_parse_and_map(np, 0);
1065 r[2].flags = IORESOURCE_IRQ;
1068 platform_device_register_simple("fsl-cpm-smc:uart", i, &r[0], 3);
1070 if (IS_ERR(cpm_uart_dev)) {
1071 ret = PTR_ERR(cpm_uart_dev);
1075 model = of_get_property(np, "model", NULL);
1076 strcpy(cpm_uart_data.fs_type, model);
1078 id = of_get_property(np, "device-id", NULL);
1079 cpm_uart_data.fs_no = *id;
1080 cpm_uart_data.uart_clk = ppc_proc_freq;
1082 cpm_uart_data.tx_num_fifo = 4;
1083 cpm_uart_data.tx_buf_size = 32;
1084 cpm_uart_data.rx_num_fifo = 4;
1085 cpm_uart_data.rx_buf_size = 32;
1088 platform_device_add_data(cpm_uart_dev, &cpm_uart_data,
1090 fs_uart_platform_info));
1098 platform_device_unregister(cpm_uart_dev);
1103 arch_initcall(cpm_smc_uart_of_init);
1105 #endif /* CONFIG_8xx */