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
= 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
= get_property(node
, "brg-frequency",
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
= get_property(node
, "current-speed",
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
= get_property(child
, "reg", NULL
);
157 mdio_data
.irq
[*id
] = irq
;
162 platform_device_add_data(mdio_dev
, &mdio_data
,
163 sizeof(struct gianfar_mdio_data
));
171 platform_device_unregister(mdio_dev
);
176 arch_initcall(gfar_mdio_of_init
);
178 static const char *gfar_tx_intr
= "tx";
179 static const char *gfar_rx_intr
= "rx";
180 static const char *gfar_err_intr
= "error";
183 static int __init
gfar_of_init(void)
185 struct device_node
*np
;
187 struct platform_device
*gfar_dev
;
191 for (np
= NULL
, i
= 0;
192 (np
= of_find_compatible_node(np
, "network", "gianfar")) != NULL
;
194 struct resource r
[4];
195 struct device_node
*phy
, *mdio
;
196 struct gianfar_platform_data gfar_data
;
197 const unsigned int *id
;
199 const void *mac_addr
;
203 memset(r
, 0, sizeof(r
));
204 memset(&gfar_data
, 0, sizeof(gfar_data
));
206 ret
= of_address_to_resource(np
, 0, &r
[0]);
210 of_irq_to_resource(np
, 0, &r
[1]);
212 model
= get_property(np
, "model", NULL
);
214 /* If we aren't the FEC we have multiple interrupts */
215 if (model
&& strcasecmp(model
, "FEC")) {
216 r
[1].name
= gfar_tx_intr
;
218 r
[2].name
= gfar_rx_intr
;
219 of_irq_to_resource(np
, 1, &r
[2]);
221 r
[3].name
= gfar_err_intr
;
222 of_irq_to_resource(np
, 2, &r
[3]);
228 platform_device_register_simple("fsl-gianfar", i
, &r
[0],
231 if (IS_ERR(gfar_dev
)) {
232 ret
= PTR_ERR(gfar_dev
);
236 mac_addr
= of_get_mac_address(np
);
238 memcpy(gfar_data
.mac_addr
, mac_addr
, 6);
240 if (model
&& !strcasecmp(model
, "TSEC"))
241 gfar_data
.device_flags
=
242 FSL_GIANFAR_DEV_HAS_GIGABIT
|
243 FSL_GIANFAR_DEV_HAS_COALESCE
|
244 FSL_GIANFAR_DEV_HAS_RMON
|
245 FSL_GIANFAR_DEV_HAS_MULTI_INTR
;
246 if (model
&& !strcasecmp(model
, "eTSEC"))
247 gfar_data
.device_flags
=
248 FSL_GIANFAR_DEV_HAS_GIGABIT
|
249 FSL_GIANFAR_DEV_HAS_COALESCE
|
250 FSL_GIANFAR_DEV_HAS_RMON
|
251 FSL_GIANFAR_DEV_HAS_MULTI_INTR
|
252 FSL_GIANFAR_DEV_HAS_CSUM
|
253 FSL_GIANFAR_DEV_HAS_VLAN
|
254 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH
;
256 ph
= get_property(np
, "phy-handle", NULL
);
257 phy
= of_find_node_by_phandle(*ph
);
264 mdio
= of_get_parent(phy
);
266 id
= get_property(phy
, "reg", NULL
);
267 ret
= of_address_to_resource(mdio
, 0, &res
);
274 gfar_data
.phy_id
= *id
;
275 gfar_data
.bus_id
= res
.start
;
281 platform_device_add_data(gfar_dev
, &gfar_data
,
283 gianfar_platform_data
));
291 platform_device_unregister(gfar_dev
);
296 arch_initcall(gfar_of_init
);
298 static int __init
fsl_i2c_of_init(void)
300 struct device_node
*np
;
302 struct platform_device
*i2c_dev
;
305 for (np
= NULL
, i
= 0;
306 (np
= of_find_compatible_node(np
, "i2c", "fsl-i2c")) != NULL
;
308 struct resource r
[2];
309 struct fsl_i2c_platform_data i2c_data
;
310 const unsigned char *flags
= NULL
;
312 memset(&r
, 0, sizeof(r
));
313 memset(&i2c_data
, 0, sizeof(i2c_data
));
315 ret
= of_address_to_resource(np
, 0, &r
[0]);
319 of_irq_to_resource(np
, 0, &r
[1]);
321 i2c_dev
= platform_device_register_simple("fsl-i2c", i
, r
, 2);
322 if (IS_ERR(i2c_dev
)) {
323 ret
= PTR_ERR(i2c_dev
);
327 i2c_data
.device_flags
= 0;
328 flags
= get_property(np
, "dfsrr", NULL
);
330 i2c_data
.device_flags
|= FSL_I2C_DEV_SEPARATE_DFSRR
;
332 flags
= get_property(np
, "fsl5200-clocking", NULL
);
334 i2c_data
.device_flags
|= FSL_I2C_DEV_CLOCK_5200
;
337 platform_device_add_data(i2c_dev
, &i2c_data
,
339 fsl_i2c_platform_data
));
347 platform_device_unregister(i2c_dev
);
352 arch_initcall(fsl_i2c_of_init
);
354 #ifdef CONFIG_PPC_83xx
355 static int __init
mpc83xx_wdt_init(void)
358 struct device_node
*soc
, *np
;
359 struct platform_device
*dev
;
360 const unsigned int *freq
;
363 np
= of_find_compatible_node(NULL
, "watchdog", "mpc83xx_wdt");
370 soc
= of_find_node_by_type(NULL
, "soc");
377 freq
= get_property(soc
, "bus-frequency", NULL
);
383 memset(&r
, 0, sizeof(r
));
385 ret
= of_address_to_resource(np
, 0, &r
);
389 dev
= platform_device_register_simple("mpc83xx_wdt", 0, &r
, 1);
395 ret
= platform_device_add_data(dev
, freq
, sizeof(int));
405 platform_device_unregister(dev
);
414 arch_initcall(mpc83xx_wdt_init
);
417 static enum fsl_usb2_phy_modes
determine_usb_phy(const char *phy_type
)
420 return FSL_USB2_PHY_NONE
;
421 if (!strcasecmp(phy_type
, "ulpi"))
422 return FSL_USB2_PHY_ULPI
;
423 if (!strcasecmp(phy_type
, "utmi"))
424 return FSL_USB2_PHY_UTMI
;
425 if (!strcasecmp(phy_type
, "utmi_wide"))
426 return FSL_USB2_PHY_UTMI_WIDE
;
427 if (!strcasecmp(phy_type
, "serial"))
428 return FSL_USB2_PHY_SERIAL
;
430 return FSL_USB2_PHY_NONE
;
433 static int __init
fsl_usb_of_init(void)
435 struct device_node
*np
;
437 struct platform_device
*usb_dev_mph
= NULL
, *usb_dev_dr_host
= NULL
,
438 *usb_dev_dr_client
= NULL
;
441 for (np
= NULL
, i
= 0;
442 (np
= of_find_compatible_node(np
, "usb", "fsl-usb2-mph")) != NULL
;
444 struct resource r
[2];
445 struct fsl_usb2_platform_data usb_data
;
446 const unsigned char *prop
= NULL
;
448 memset(&r
, 0, sizeof(r
));
449 memset(&usb_data
, 0, sizeof(usb_data
));
451 ret
= of_address_to_resource(np
, 0, &r
[0]);
455 of_irq_to_resource(np
, 0, &r
[1]);
458 platform_device_register_simple("fsl-ehci", i
, r
, 2);
459 if (IS_ERR(usb_dev_mph
)) {
460 ret
= PTR_ERR(usb_dev_mph
);
464 usb_dev_mph
->dev
.coherent_dma_mask
= 0xffffffffUL
;
465 usb_dev_mph
->dev
.dma_mask
= &usb_dev_mph
->dev
.coherent_dma_mask
;
467 usb_data
.operating_mode
= FSL_USB2_MPH_HOST
;
469 prop
= get_property(np
, "port0", NULL
);
471 usb_data
.port_enables
|= FSL_USB2_PORT0_ENABLED
;
473 prop
= get_property(np
, "port1", NULL
);
475 usb_data
.port_enables
|= FSL_USB2_PORT1_ENABLED
;
477 prop
= get_property(np
, "phy_type", NULL
);
478 usb_data
.phy_mode
= determine_usb_phy(prop
);
481 platform_device_add_data(usb_dev_mph
, &usb_data
,
483 fsl_usb2_platform_data
));
489 (np
= of_find_compatible_node(np
, "usb", "fsl-usb2-dr")) != NULL
;
491 struct resource r
[2];
492 struct fsl_usb2_platform_data usb_data
;
493 const unsigned char *prop
= NULL
;
495 memset(&r
, 0, sizeof(r
));
496 memset(&usb_data
, 0, sizeof(usb_data
));
498 ret
= of_address_to_resource(np
, 0, &r
[0]);
502 of_irq_to_resource(np
, 0, &r
[1]);
504 prop
= get_property(np
, "dr_mode", NULL
);
506 if (!prop
|| !strcmp(prop
, "host")) {
507 usb_data
.operating_mode
= FSL_USB2_DR_HOST
;
508 usb_dev_dr_host
= platform_device_register_simple(
509 "fsl-ehci", i
, r
, 2);
510 if (IS_ERR(usb_dev_dr_host
)) {
511 ret
= PTR_ERR(usb_dev_dr_host
);
514 } else if (prop
&& !strcmp(prop
, "peripheral")) {
515 usb_data
.operating_mode
= FSL_USB2_DR_DEVICE
;
516 usb_dev_dr_client
= platform_device_register_simple(
517 "fsl-usb2-udc", i
, r
, 2);
518 if (IS_ERR(usb_dev_dr_client
)) {
519 ret
= PTR_ERR(usb_dev_dr_client
);
522 } else if (prop
&& !strcmp(prop
, "otg")) {
523 usb_data
.operating_mode
= FSL_USB2_DR_OTG
;
524 usb_dev_dr_host
= platform_device_register_simple(
525 "fsl-ehci", i
, r
, 2);
526 if (IS_ERR(usb_dev_dr_host
)) {
527 ret
= PTR_ERR(usb_dev_dr_host
);
530 usb_dev_dr_client
= platform_device_register_simple(
531 "fsl-usb2-udc", i
, r
, 2);
532 if (IS_ERR(usb_dev_dr_client
)) {
533 ret
= PTR_ERR(usb_dev_dr_client
);
541 prop
= get_property(np
, "phy_type", NULL
);
542 usb_data
.phy_mode
= determine_usb_phy(prop
);
544 if (usb_dev_dr_host
) {
545 usb_dev_dr_host
->dev
.coherent_dma_mask
= 0xffffffffUL
;
546 usb_dev_dr_host
->dev
.dma_mask
= &usb_dev_dr_host
->
547 dev
.coherent_dma_mask
;
548 if ((ret
= platform_device_add_data(usb_dev_dr_host
,
549 &usb_data
, sizeof(struct
550 fsl_usb2_platform_data
))))
553 if (usb_dev_dr_client
) {
554 usb_dev_dr_client
->dev
.coherent_dma_mask
= 0xffffffffUL
;
555 usb_dev_dr_client
->dev
.dma_mask
= &usb_dev_dr_client
->
556 dev
.coherent_dma_mask
;
557 if ((ret
= platform_device_add_data(usb_dev_dr_client
,
558 &usb_data
, sizeof(struct
559 fsl_usb2_platform_data
))))
567 platform_device_unregister(usb_dev_dr_host
);
568 if (usb_dev_dr_client
)
569 platform_device_unregister(usb_dev_dr_client
);
572 platform_device_unregister(usb_dev_mph
);
577 arch_initcall(fsl_usb_of_init
);
581 extern void init_scc_ioports(struct fs_uart_platform_info
*);
583 static const char fcc_regs
[] = "fcc_regs";
584 static const char fcc_regs_c
[] = "fcc_regs_c";
585 static const char fcc_pram
[] = "fcc_pram";
586 static char bus_id
[9][BUS_ID_SIZE
];
588 static int __init
fs_enet_of_init(void)
590 struct device_node
*np
;
592 struct platform_device
*fs_enet_dev
;
596 for (np
= NULL
, i
= 0;
597 (np
= of_find_compatible_node(np
, "network", "fs_enet")) != NULL
;
599 struct resource r
[4];
600 struct device_node
*phy
, *mdio
;
601 struct fs_platform_info fs_enet_data
;
602 const unsigned int *id
, *phy_addr
, *phy_irq
;
603 const void *mac_addr
;
607 memset(r
, 0, sizeof(r
));
608 memset(&fs_enet_data
, 0, sizeof(fs_enet_data
));
610 ret
= of_address_to_resource(np
, 0, &r
[0]);
613 r
[0].name
= fcc_regs
;
615 ret
= of_address_to_resource(np
, 1, &r
[1]);
618 r
[1].name
= fcc_pram
;
620 ret
= of_address_to_resource(np
, 2, &r
[2]);
623 r
[2].name
= fcc_regs_c
;
624 fs_enet_data
.fcc_regs_c
= r
[2].start
;
626 of_irq_to_resource(np
, 0, &r
[3]);
629 platform_device_register_simple("fsl-cpm-fcc", i
, &r
[0], 4);
631 if (IS_ERR(fs_enet_dev
)) {
632 ret
= PTR_ERR(fs_enet_dev
);
636 model
= get_property(np
, "model", NULL
);
642 mac_addr
= of_get_mac_address(np
);
644 memcpy(fs_enet_data
.macaddr
, mac_addr
, 6);
646 ph
= get_property(np
, "phy-handle", NULL
);
647 phy
= of_find_node_by_phandle(*ph
);
654 phy_addr
= get_property(phy
, "reg", NULL
);
655 fs_enet_data
.phy_addr
= *phy_addr
;
657 phy_irq
= get_property(phy
, "interrupts", NULL
);
659 id
= get_property(np
, "device-id", NULL
);
660 fs_enet_data
.fs_no
= *id
;
661 strcpy(fs_enet_data
.fs_type
, model
);
663 mdio
= of_get_parent(phy
);
664 ret
= of_address_to_resource(mdio
, 0, &res
);
671 fs_enet_data
.clk_rx
= *((u32
*) get_property(np
, "rx-clock", NULL
));
672 fs_enet_data
.clk_tx
= *((u32
*) get_property(np
, "tx-clock", NULL
));
674 if (strstr(model
, "FCC")) {
675 int fcc_index
= *id
- 1;
676 const unsigned char *mdio_bb_prop
;
678 fs_enet_data
.dpram_offset
= (u32
)cpm_dpram_addr(0);
679 fs_enet_data
.rx_ring
= 32;
680 fs_enet_data
.tx_ring
= 32;
681 fs_enet_data
.rx_copybreak
= 240;
682 fs_enet_data
.use_napi
= 0;
683 fs_enet_data
.napi_weight
= 17;
684 fs_enet_data
.mem_offset
= FCC_MEM_OFFSET(fcc_index
);
685 fs_enet_data
.cp_page
= CPM_CR_FCC_PAGE(fcc_index
);
686 fs_enet_data
.cp_block
= CPM_CR_FCC_SBLOCK(fcc_index
);
688 snprintf((char*)&bus_id
[(*id
)], BUS_ID_SIZE
, "%x:%02x",
689 (u32
)res
.start
, fs_enet_data
.phy_addr
);
690 fs_enet_data
.bus_id
= (char*)&bus_id
[(*id
)];
691 fs_enet_data
.init_ioports
= init_fcc_ioports
;
693 mdio_bb_prop
= get_property(phy
, "bitbang", NULL
);
695 struct platform_device
*fs_enet_mdio_bb_dev
;
696 struct fs_mii_bb_platform_info fs_enet_mdio_bb_data
;
698 fs_enet_mdio_bb_dev
=
699 platform_device_register_simple("fsl-bb-mdio",
701 memset(&fs_enet_mdio_bb_data
, 0,
702 sizeof(struct fs_mii_bb_platform_info
));
703 fs_enet_mdio_bb_data
.mdio_dat
.bit
=
705 fs_enet_mdio_bb_data
.mdio_dir
.bit
=
707 fs_enet_mdio_bb_data
.mdc_dat
.bit
=
709 fs_enet_mdio_bb_data
.mdio_port
=
711 fs_enet_mdio_bb_data
.mdc_port
=
713 fs_enet_mdio_bb_data
.delay
=
716 fs_enet_mdio_bb_data
.irq
[0] = phy_irq
[0];
717 fs_enet_mdio_bb_data
.irq
[1] = -1;
718 fs_enet_mdio_bb_data
.irq
[2] = -1;
719 fs_enet_mdio_bb_data
.irq
[3] = phy_irq
[0];
720 fs_enet_mdio_bb_data
.irq
[31] = -1;
722 fs_enet_mdio_bb_data
.mdio_dat
.offset
=
723 (u32
)&cpm2_immr
->im_ioport
.iop_pdatc
;
724 fs_enet_mdio_bb_data
.mdio_dir
.offset
=
725 (u32
)&cpm2_immr
->im_ioport
.iop_pdirc
;
726 fs_enet_mdio_bb_data
.mdc_dat
.offset
=
727 (u32
)&cpm2_immr
->im_ioport
.iop_pdatc
;
729 ret
= platform_device_add_data(
731 &fs_enet_mdio_bb_data
,
732 sizeof(struct fs_mii_bb_platform_info
));
740 ret
= platform_device_add_data(fs_enet_dev
, &fs_enet_data
,
750 platform_device_unregister(fs_enet_dev
);
755 arch_initcall(fs_enet_of_init
);
757 static const char scc_regs
[] = "regs";
758 static const char scc_pram
[] = "pram";
760 static int __init
cpm_uart_of_init(void)
762 struct device_node
*np
;
764 struct platform_device
*cpm_uart_dev
;
767 for (np
= NULL
, i
= 0;
768 (np
= of_find_compatible_node(np
, "serial", "cpm_uart")) != NULL
;
770 struct resource r
[3];
771 struct fs_uart_platform_info cpm_uart_data
;
775 memset(r
, 0, sizeof(r
));
776 memset(&cpm_uart_data
, 0, sizeof(cpm_uart_data
));
778 ret
= of_address_to_resource(np
, 0, &r
[0]);
782 r
[0].name
= scc_regs
;
784 ret
= of_address_to_resource(np
, 1, &r
[1]);
787 r
[1].name
= scc_pram
;
789 of_irq_to_resource(np
, 0, &r
[2]);
792 platform_device_register_simple("fsl-cpm-scc:uart", i
, &r
[0], 3);
794 if (IS_ERR(cpm_uart_dev
)) {
795 ret
= PTR_ERR(cpm_uart_dev
);
799 id
= get_property(np
, "device-id", NULL
);
800 cpm_uart_data
.fs_no
= *id
;
802 model
= (char*)get_property(np
, "model", NULL
);
803 strcpy(cpm_uart_data
.fs_type
, model
);
805 cpm_uart_data
.uart_clk
= ppc_proc_freq
;
807 cpm_uart_data
.tx_num_fifo
= 4;
808 cpm_uart_data
.tx_buf_size
= 32;
809 cpm_uart_data
.rx_num_fifo
= 4;
810 cpm_uart_data
.rx_buf_size
= 32;
811 cpm_uart_data
.clk_rx
= *((u32
*) get_property(np
, "rx-clock", NULL
));
812 cpm_uart_data
.clk_tx
= *((u32
*) get_property(np
, "tx-clock", NULL
));
815 platform_device_add_data(cpm_uart_dev
, &cpm_uart_data
,
817 fs_uart_platform_info
));
825 platform_device_unregister(cpm_uart_dev
);
830 arch_initcall(cpm_uart_of_init
);
831 #endif /* CONFIG_CPM2 */
835 extern void init_scc_ioports(struct fs_platform_info
*);
836 extern int platform_device_skip(char *model
, int id
);
838 static int __init
fs_enet_mdio_of_init(void)
840 struct device_node
*np
;
842 struct platform_device
*mdio_dev
;
846 for (np
= NULL
, i
= 0;
847 (np
= of_find_compatible_node(np
, "mdio", "fs_enet")) != NULL
;
849 struct fs_mii_fec_platform_info mdio_data
;
851 memset(&res
, 0, sizeof(res
));
852 memset(&mdio_data
, 0, sizeof(mdio_data
));
854 ret
= of_address_to_resource(np
, 0, &res
);
859 platform_device_register_simple("fsl-cpm-fec-mdio",
861 if (IS_ERR(mdio_dev
)) {
862 ret
= PTR_ERR(mdio_dev
);
866 mdio_data
.mii_speed
= ((((ppc_proc_freq
+ 4999999) / 2500000) / 2) & 0x3F) << 1;
869 platform_device_add_data(mdio_dev
, &mdio_data
,
870 sizeof(struct fs_mii_fec_platform_info
));
877 platform_device_unregister(mdio_dev
);
882 arch_initcall(fs_enet_mdio_of_init
);
884 static const char *enet_regs
= "regs";
885 static const char *enet_pram
= "pram";
886 static const char *enet_irq
= "interrupt";
887 static char bus_id
[9][BUS_ID_SIZE
];
889 static int __init
fs_enet_of_init(void)
891 struct device_node
*np
;
893 struct platform_device
*fs_enet_dev
= NULL
;
897 for (np
= NULL
, i
= 0;
898 (np
= of_find_compatible_node(np
, "network", "fs_enet")) != NULL
;
900 struct resource r
[4];
901 struct device_node
*phy
= NULL
, *mdio
= NULL
;
902 struct fs_platform_info fs_enet_data
;
903 unsigned int *id
, *phy_addr
;
908 memset(r
, 0, sizeof(r
));
909 memset(&fs_enet_data
, 0, sizeof(fs_enet_data
));
911 model
= (char *)get_property(np
, "model", NULL
);
917 id
= (u32
*) get_property(np
, "device-id", NULL
);
918 fs_enet_data
.fs_no
= *id
;
920 if (platform_device_skip(model
, *id
))
923 ret
= of_address_to_resource(np
, 0, &r
[0]);
926 r
[0].name
= enet_regs
;
928 mac_addr
= of_get_mac_address(np
);
930 memcpy(fs_enet_data
.macaddr
, mac_addr
, 6);
932 ph
= (phandle
*) get_property(np
, "phy-handle", NULL
);
934 phy
= of_find_node_by_phandle(*ph
);
937 phy_addr
= (u32
*) get_property(phy
, "reg", NULL
);
938 fs_enet_data
.phy_addr
= *phy_addr
;
939 fs_enet_data
.has_phy
= 1;
941 mdio
= of_get_parent(phy
);
942 ret
= of_address_to_resource(mdio
, 0, &res
);
950 model
= (char*)get_property(np
, "model", NULL
);
951 strcpy(fs_enet_data
.fs_type
, model
);
953 if (strstr(model
, "FEC")) {
954 r
[1].start
= r
[1].end
= irq_of_parse_and_map(np
, 0);
955 r
[1].flags
= IORESOURCE_IRQ
;
956 r
[1].name
= enet_irq
;
959 platform_device_register_simple("fsl-cpm-fec", i
, &r
[0], 2);
961 if (IS_ERR(fs_enet_dev
)) {
962 ret
= PTR_ERR(fs_enet_dev
);
966 fs_enet_data
.rx_ring
= 128;
967 fs_enet_data
.tx_ring
= 16;
968 fs_enet_data
.rx_copybreak
= 240;
969 fs_enet_data
.use_napi
= 1;
970 fs_enet_data
.napi_weight
= 17;
972 snprintf((char*)&bus_id
[i
], BUS_ID_SIZE
, "%x:%02x",
973 (u32
)res
.start
, fs_enet_data
.phy_addr
);
974 fs_enet_data
.bus_id
= (char*)&bus_id
[i
];
975 fs_enet_data
.init_ioports
= init_fec_ioports
;
977 if (strstr(model
, "SCC")) {
978 ret
= of_address_to_resource(np
, 1, &r
[1]);
981 r
[1].name
= enet_pram
;
983 r
[2].start
= r
[2].end
= irq_of_parse_and_map(np
, 0);
984 r
[2].flags
= IORESOURCE_IRQ
;
985 r
[2].name
= enet_irq
;
988 platform_device_register_simple("fsl-cpm-scc", i
, &r
[0], 3);
990 if (IS_ERR(fs_enet_dev
)) {
991 ret
= PTR_ERR(fs_enet_dev
);
995 fs_enet_data
.rx_ring
= 64;
996 fs_enet_data
.tx_ring
= 8;
997 fs_enet_data
.rx_copybreak
= 240;
998 fs_enet_data
.use_napi
= 1;
999 fs_enet_data
.napi_weight
= 17;
1001 snprintf((char*)&bus_id
[i
], BUS_ID_SIZE
, "%s", "fixed@10:1");
1002 fs_enet_data
.bus_id
= (char*)&bus_id
[i
];
1003 fs_enet_data
.init_ioports
= init_scc_ioports
;
1009 ret
= platform_device_add_data(fs_enet_dev
, &fs_enet_data
,
1018 platform_device_unregister(fs_enet_dev
);
1023 arch_initcall(fs_enet_of_init
);
1026 static const char *smc_regs
= "regs";
1027 static const char *smc_pram
= "pram";
1029 static int __init
cpm_smc_uart_of_init(void)
1031 struct device_node
*np
;
1033 struct platform_device
*cpm_uart_dev
;
1036 for (np
= NULL
, i
= 0;
1037 (np
= of_find_compatible_node(np
, "serial", "cpm_uart")) != NULL
;
1039 struct resource r
[3];
1040 struct fs_uart_platform_info cpm_uart_data
;
1044 memset(r
, 0, sizeof(r
));
1045 memset(&cpm_uart_data
, 0, sizeof(cpm_uart_data
));
1047 ret
= of_address_to_resource(np
, 0, &r
[0]);
1051 r
[0].name
= smc_regs
;
1053 ret
= of_address_to_resource(np
, 1, &r
[1]);
1056 r
[1].name
= smc_pram
;
1058 r
[2].start
= r
[2].end
= irq_of_parse_and_map(np
, 0);
1059 r
[2].flags
= IORESOURCE_IRQ
;
1062 platform_device_register_simple("fsl-cpm-smc:uart", i
, &r
[0], 3);
1064 if (IS_ERR(cpm_uart_dev
)) {
1065 ret
= PTR_ERR(cpm_uart_dev
);
1069 model
= (char*)get_property(np
, "model", NULL
);
1070 strcpy(cpm_uart_data
.fs_type
, model
);
1072 id
= (int*)get_property(np
, "device-id", NULL
);
1073 cpm_uart_data
.fs_no
= *id
;
1074 cpm_uart_data
.uart_clk
= ppc_proc_freq
;
1076 cpm_uart_data
.tx_num_fifo
= 4;
1077 cpm_uart_data
.tx_buf_size
= 32;
1078 cpm_uart_data
.rx_num_fifo
= 4;
1079 cpm_uart_data
.rx_buf_size
= 32;
1082 platform_device_add_data(cpm_uart_dev
, &cpm_uart_data
,
1084 fs_uart_platform_info
));
1092 platform_device_unregister(cpm_uart_dev
);
1097 arch_initcall(cpm_smc_uart_of_init
);
1099 #endif /* CONFIG_8xx */