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/of_platform.h>
26 #include <linux/phy.h>
27 #include <linux/fsl_devices.h>
28 #include <linux/fs_enet_pd.h>
29 #include <linux/fs_uart_pd.h>
31 #include <asm/system.h>
32 #include <asm/atomic.h>
37 #include <sysdev/fsl_soc.h>
38 #include <mm/mmu_decl.h>
41 extern void init_fcc_ioports(struct fs_platform_info
*);
42 extern void init_fec_ioports(struct fs_platform_info
*);
43 extern void init_smc_ioports(struct fs_uart_platform_info
*);
44 static phys_addr_t immrbase
= -1;
46 phys_addr_t
get_immrbase(void)
48 struct device_node
*soc
;
53 soc
= of_find_node_by_type(NULL
, "soc");
56 const void *prop
= of_get_property(soc
, "reg", &size
);
59 immrbase
= of_translate_address(soc
, prop
);
66 EXPORT_SYMBOL(get_immrbase
);
68 #if defined(CONFIG_CPM2) || defined(CONFIG_8xx)
70 static u32 brgfreq
= -1;
74 struct device_node
*node
;
79 node
= of_find_node_by_type(NULL
, "cpm");
82 const unsigned int *prop
= of_get_property(node
,
83 "brg-frequency", &size
);
93 EXPORT_SYMBOL(get_brgfreq
);
95 static u32 fs_baudrate
= -1;
97 u32
get_baudrate(void)
99 struct device_node
*node
;
101 if (fs_baudrate
!= -1)
104 node
= of_find_node_by_type(NULL
, "serial");
107 const unsigned int *prop
= of_get_property(node
,
108 "current-speed", &size
);
118 EXPORT_SYMBOL(get_baudrate
);
119 #endif /* CONFIG_CPM2 */
121 static int __init
gfar_mdio_of_init(void)
123 struct device_node
*np
;
125 struct platform_device
*mdio_dev
;
129 for (np
= NULL
, i
= 0;
130 (np
= of_find_compatible_node(np
, "mdio", "gianfar")) != NULL
;
133 struct device_node
*child
= NULL
;
134 struct gianfar_mdio_data mdio_data
;
136 memset(&res
, 0, sizeof(res
));
137 memset(&mdio_data
, 0, sizeof(mdio_data
));
139 ret
= of_address_to_resource(np
, 0, &res
);
144 platform_device_register_simple("fsl-gianfar_mdio",
146 if (IS_ERR(mdio_dev
)) {
147 ret
= PTR_ERR(mdio_dev
);
151 for (k
= 0; k
< 32; k
++)
152 mdio_data
.irq
[k
] = PHY_POLL
;
154 while ((child
= of_get_next_child(np
, child
)) != NULL
) {
155 int irq
= irq_of_parse_and_map(child
, 0);
157 const u32
*id
= of_get_property(child
,
159 mdio_data
.irq
[*id
] = irq
;
164 platform_device_add_data(mdio_dev
, &mdio_data
,
165 sizeof(struct gianfar_mdio_data
));
173 platform_device_unregister(mdio_dev
);
178 arch_initcall(gfar_mdio_of_init
);
180 static const char *gfar_tx_intr
= "tx";
181 static const char *gfar_rx_intr
= "rx";
182 static const char *gfar_err_intr
= "error";
185 static int __init
gfar_of_init(void)
187 struct device_node
*np
;
189 struct platform_device
*gfar_dev
;
193 for (np
= NULL
, i
= 0;
194 (np
= of_find_compatible_node(np
, "network", "gianfar")) != NULL
;
196 struct resource r
[4];
197 struct device_node
*phy
, *mdio
;
198 struct gianfar_platform_data gfar_data
;
199 const unsigned int *id
;
202 const void *mac_addr
;
206 memset(r
, 0, sizeof(r
));
207 memset(&gfar_data
, 0, sizeof(gfar_data
));
209 ret
= of_address_to_resource(np
, 0, &r
[0]);
213 of_irq_to_resource(np
, 0, &r
[1]);
215 model
= of_get_property(np
, "model", NULL
);
217 /* If we aren't the FEC we have multiple interrupts */
218 if (model
&& strcasecmp(model
, "FEC")) {
219 r
[1].name
= gfar_tx_intr
;
221 r
[2].name
= gfar_rx_intr
;
222 of_irq_to_resource(np
, 1, &r
[2]);
224 r
[3].name
= gfar_err_intr
;
225 of_irq_to_resource(np
, 2, &r
[3]);
231 platform_device_register_simple("fsl-gianfar", i
, &r
[0],
234 if (IS_ERR(gfar_dev
)) {
235 ret
= PTR_ERR(gfar_dev
);
239 mac_addr
= of_get_mac_address(np
);
241 memcpy(gfar_data
.mac_addr
, mac_addr
, 6);
243 if (model
&& !strcasecmp(model
, "TSEC"))
244 gfar_data
.device_flags
=
245 FSL_GIANFAR_DEV_HAS_GIGABIT
|
246 FSL_GIANFAR_DEV_HAS_COALESCE
|
247 FSL_GIANFAR_DEV_HAS_RMON
|
248 FSL_GIANFAR_DEV_HAS_MULTI_INTR
;
249 if (model
&& !strcasecmp(model
, "eTSEC"))
250 gfar_data
.device_flags
=
251 FSL_GIANFAR_DEV_HAS_GIGABIT
|
252 FSL_GIANFAR_DEV_HAS_COALESCE
|
253 FSL_GIANFAR_DEV_HAS_RMON
|
254 FSL_GIANFAR_DEV_HAS_MULTI_INTR
|
255 FSL_GIANFAR_DEV_HAS_CSUM
|
256 FSL_GIANFAR_DEV_HAS_VLAN
|
257 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH
;
259 ctype
= of_get_property(np
, "phy-connection-type", NULL
);
261 /* We only care about rgmii-id. The rest are autodetected */
262 if (ctype
&& !strcmp(ctype
, "rgmii-id"))
263 gfar_data
.interface
= PHY_INTERFACE_MODE_RGMII_ID
;
265 gfar_data
.interface
= PHY_INTERFACE_MODE_MII
;
267 ph
= of_get_property(np
, "phy-handle", NULL
);
268 phy
= of_find_node_by_phandle(*ph
);
275 mdio
= of_get_parent(phy
);
277 id
= of_get_property(phy
, "reg", NULL
);
278 ret
= of_address_to_resource(mdio
, 0, &res
);
285 gfar_data
.phy_id
= *id
;
286 gfar_data
.bus_id
= res
.start
;
292 platform_device_add_data(gfar_dev
, &gfar_data
,
294 gianfar_platform_data
));
302 platform_device_unregister(gfar_dev
);
307 arch_initcall(gfar_of_init
);
309 #ifdef CONFIG_I2C_BOARDINFO
310 #include <linux/i2c.h>
311 struct i2c_driver_device
{
317 static struct i2c_driver_device i2c_devices
[] __initdata
= {
318 {"ricoh,rs5c372a", "rtc-rs5c372", "rs5c372a",},
319 {"ricoh,rs5c372b", "rtc-rs5c372", "rs5c372b",},
320 {"ricoh,rv5c386", "rtc-rs5c372", "rv5c386",},
321 {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",},
324 static int __init
of_find_i2c_driver(struct device_node
*node
, struct i2c_board_info
*info
)
328 for (i
= 0; i
< ARRAY_SIZE(i2c_devices
); i
++) {
329 if (!of_device_is_compatible(node
, i2c_devices
[i
].of_device
))
331 strncpy(info
->driver_name
, i2c_devices
[i
].i2c_driver
, KOBJ_NAME_LEN
);
332 strncpy(info
->type
, i2c_devices
[i
].i2c_type
, I2C_NAME_SIZE
);
338 static void __init
of_register_i2c_devices(struct device_node
*adap_node
, int bus_num
)
340 struct device_node
*node
= NULL
;
342 while ((node
= of_get_next_child(adap_node
, node
))) {
343 struct i2c_board_info info
;
347 addr
= of_get_property(node
, "reg", &len
);
348 if (!addr
|| len
< sizeof(int) || *addr
> (1 << 10) - 1) {
349 printk(KERN_WARNING
"fsl_ioc.c: invalid i2c device entry\n");
353 info
.irq
= irq_of_parse_and_map(node
, 0);
354 if (info
.irq
== NO_IRQ
)
357 if (of_find_i2c_driver(node
, &info
) < 0)
360 info
.platform_data
= NULL
;
363 i2c_register_board_info(bus_num
, &info
, 1);
367 static int __init
fsl_i2c_of_init(void)
369 struct device_node
*np
;
371 struct platform_device
*i2c_dev
;
374 for (np
= NULL
, i
= 0;
375 (np
= of_find_compatible_node(np
, "i2c", "fsl-i2c")) != NULL
;
377 struct resource r
[2];
378 struct fsl_i2c_platform_data i2c_data
;
379 const unsigned char *flags
= NULL
;
381 memset(&r
, 0, sizeof(r
));
382 memset(&i2c_data
, 0, sizeof(i2c_data
));
384 ret
= of_address_to_resource(np
, 0, &r
[0]);
388 of_irq_to_resource(np
, 0, &r
[1]);
390 i2c_dev
= platform_device_register_simple("fsl-i2c", i
, r
, 2);
391 if (IS_ERR(i2c_dev
)) {
392 ret
= PTR_ERR(i2c_dev
);
396 i2c_data
.device_flags
= 0;
397 flags
= of_get_property(np
, "dfsrr", NULL
);
399 i2c_data
.device_flags
|= FSL_I2C_DEV_SEPARATE_DFSRR
;
401 flags
= of_get_property(np
, "fsl5200-clocking", NULL
);
403 i2c_data
.device_flags
|= FSL_I2C_DEV_CLOCK_5200
;
406 platform_device_add_data(i2c_dev
, &i2c_data
,
408 fsl_i2c_platform_data
));
412 of_register_i2c_devices(np
, i
);
418 platform_device_unregister(i2c_dev
);
423 arch_initcall(fsl_i2c_of_init
);
426 #ifdef CONFIG_PPC_83xx
427 static int __init
mpc83xx_wdt_init(void)
430 struct device_node
*soc
, *np
;
431 struct platform_device
*dev
;
432 const unsigned int *freq
;
435 np
= of_find_compatible_node(NULL
, "watchdog", "mpc83xx_wdt");
442 soc
= of_find_node_by_type(NULL
, "soc");
449 freq
= of_get_property(soc
, "bus-frequency", NULL
);
455 memset(&r
, 0, sizeof(r
));
457 ret
= of_address_to_resource(np
, 0, &r
);
461 dev
= platform_device_register_simple("mpc83xx_wdt", 0, &r
, 1);
467 ret
= platform_device_add_data(dev
, freq
, sizeof(int));
477 platform_device_unregister(dev
);
486 arch_initcall(mpc83xx_wdt_init
);
489 static enum fsl_usb2_phy_modes
determine_usb_phy(const char *phy_type
)
492 return FSL_USB2_PHY_NONE
;
493 if (!strcasecmp(phy_type
, "ulpi"))
494 return FSL_USB2_PHY_ULPI
;
495 if (!strcasecmp(phy_type
, "utmi"))
496 return FSL_USB2_PHY_UTMI
;
497 if (!strcasecmp(phy_type
, "utmi_wide"))
498 return FSL_USB2_PHY_UTMI_WIDE
;
499 if (!strcasecmp(phy_type
, "serial"))
500 return FSL_USB2_PHY_SERIAL
;
502 return FSL_USB2_PHY_NONE
;
505 static int __init
fsl_usb_of_init(void)
507 struct device_node
*np
;
509 struct platform_device
*usb_dev_mph
= NULL
, *usb_dev_dr_host
= NULL
,
510 *usb_dev_dr_client
= NULL
;
513 for (np
= NULL
, i
= 0;
514 (np
= of_find_compatible_node(np
, "usb", "fsl-usb2-mph")) != NULL
;
516 struct resource r
[2];
517 struct fsl_usb2_platform_data usb_data
;
518 const unsigned char *prop
= NULL
;
520 memset(&r
, 0, sizeof(r
));
521 memset(&usb_data
, 0, sizeof(usb_data
));
523 ret
= of_address_to_resource(np
, 0, &r
[0]);
527 of_irq_to_resource(np
, 0, &r
[1]);
530 platform_device_register_simple("fsl-ehci", i
, r
, 2);
531 if (IS_ERR(usb_dev_mph
)) {
532 ret
= PTR_ERR(usb_dev_mph
);
536 usb_dev_mph
->dev
.coherent_dma_mask
= 0xffffffffUL
;
537 usb_dev_mph
->dev
.dma_mask
= &usb_dev_mph
->dev
.coherent_dma_mask
;
539 usb_data
.operating_mode
= FSL_USB2_MPH_HOST
;
541 prop
= of_get_property(np
, "port0", NULL
);
543 usb_data
.port_enables
|= FSL_USB2_PORT0_ENABLED
;
545 prop
= of_get_property(np
, "port1", NULL
);
547 usb_data
.port_enables
|= FSL_USB2_PORT1_ENABLED
;
549 prop
= of_get_property(np
, "phy_type", NULL
);
550 usb_data
.phy_mode
= determine_usb_phy(prop
);
553 platform_device_add_data(usb_dev_mph
, &usb_data
,
555 fsl_usb2_platform_data
));
561 (np
= of_find_compatible_node(np
, "usb", "fsl-usb2-dr")) != NULL
;
563 struct resource r
[2];
564 struct fsl_usb2_platform_data usb_data
;
565 const unsigned char *prop
= NULL
;
567 memset(&r
, 0, sizeof(r
));
568 memset(&usb_data
, 0, sizeof(usb_data
));
570 ret
= of_address_to_resource(np
, 0, &r
[0]);
574 of_irq_to_resource(np
, 0, &r
[1]);
576 prop
= of_get_property(np
, "dr_mode", NULL
);
578 if (!prop
|| !strcmp(prop
, "host")) {
579 usb_data
.operating_mode
= FSL_USB2_DR_HOST
;
580 usb_dev_dr_host
= platform_device_register_simple(
581 "fsl-ehci", i
, r
, 2);
582 if (IS_ERR(usb_dev_dr_host
)) {
583 ret
= PTR_ERR(usb_dev_dr_host
);
586 } else if (prop
&& !strcmp(prop
, "peripheral")) {
587 usb_data
.operating_mode
= FSL_USB2_DR_DEVICE
;
588 usb_dev_dr_client
= platform_device_register_simple(
589 "fsl-usb2-udc", i
, r
, 2);
590 if (IS_ERR(usb_dev_dr_client
)) {
591 ret
= PTR_ERR(usb_dev_dr_client
);
594 } else if (prop
&& !strcmp(prop
, "otg")) {
595 usb_data
.operating_mode
= FSL_USB2_DR_OTG
;
596 usb_dev_dr_host
= platform_device_register_simple(
597 "fsl-ehci", i
, r
, 2);
598 if (IS_ERR(usb_dev_dr_host
)) {
599 ret
= PTR_ERR(usb_dev_dr_host
);
602 usb_dev_dr_client
= platform_device_register_simple(
603 "fsl-usb2-udc", i
, r
, 2);
604 if (IS_ERR(usb_dev_dr_client
)) {
605 ret
= PTR_ERR(usb_dev_dr_client
);
613 prop
= of_get_property(np
, "phy_type", NULL
);
614 usb_data
.phy_mode
= determine_usb_phy(prop
);
616 if (usb_dev_dr_host
) {
617 usb_dev_dr_host
->dev
.coherent_dma_mask
= 0xffffffffUL
;
618 usb_dev_dr_host
->dev
.dma_mask
= &usb_dev_dr_host
->
619 dev
.coherent_dma_mask
;
620 if ((ret
= platform_device_add_data(usb_dev_dr_host
,
621 &usb_data
, sizeof(struct
622 fsl_usb2_platform_data
))))
625 if (usb_dev_dr_client
) {
626 usb_dev_dr_client
->dev
.coherent_dma_mask
= 0xffffffffUL
;
627 usb_dev_dr_client
->dev
.dma_mask
= &usb_dev_dr_client
->
628 dev
.coherent_dma_mask
;
629 if ((ret
= platform_device_add_data(usb_dev_dr_client
,
630 &usb_data
, sizeof(struct
631 fsl_usb2_platform_data
))))
639 platform_device_unregister(usb_dev_dr_host
);
640 if (usb_dev_dr_client
)
641 platform_device_unregister(usb_dev_dr_client
);
644 platform_device_unregister(usb_dev_mph
);
649 arch_initcall(fsl_usb_of_init
);
653 extern void init_scc_ioports(struct fs_uart_platform_info
*);
655 static const char fcc_regs
[] = "fcc_regs";
656 static const char fcc_regs_c
[] = "fcc_regs_c";
657 static const char fcc_pram
[] = "fcc_pram";
658 static char bus_id
[9][BUS_ID_SIZE
];
660 static int __init
fs_enet_of_init(void)
662 struct device_node
*np
;
664 struct platform_device
*fs_enet_dev
;
668 for (np
= NULL
, i
= 0;
669 (np
= of_find_compatible_node(np
, "network", "fs_enet")) != NULL
;
671 struct resource r
[4];
672 struct device_node
*phy
, *mdio
;
673 struct fs_platform_info fs_enet_data
;
674 const unsigned int *id
, *phy_addr
, *phy_irq
;
675 const void *mac_addr
;
679 memset(r
, 0, sizeof(r
));
680 memset(&fs_enet_data
, 0, sizeof(fs_enet_data
));
682 ret
= of_address_to_resource(np
, 0, &r
[0]);
685 r
[0].name
= fcc_regs
;
687 ret
= of_address_to_resource(np
, 1, &r
[1]);
690 r
[1].name
= fcc_pram
;
692 ret
= of_address_to_resource(np
, 2, &r
[2]);
695 r
[2].name
= fcc_regs_c
;
696 fs_enet_data
.fcc_regs_c
= r
[2].start
;
698 of_irq_to_resource(np
, 0, &r
[3]);
701 platform_device_register_simple("fsl-cpm-fcc", i
, &r
[0], 4);
703 if (IS_ERR(fs_enet_dev
)) {
704 ret
= PTR_ERR(fs_enet_dev
);
708 model
= of_get_property(np
, "model", NULL
);
714 mac_addr
= of_get_mac_address(np
);
716 memcpy(fs_enet_data
.macaddr
, mac_addr
, 6);
718 ph
= of_get_property(np
, "phy-handle", NULL
);
719 phy
= of_find_node_by_phandle(*ph
);
726 phy_addr
= of_get_property(phy
, "reg", NULL
);
727 fs_enet_data
.phy_addr
= *phy_addr
;
729 phy_irq
= of_get_property(phy
, "interrupts", NULL
);
731 id
= of_get_property(np
, "device-id", NULL
);
732 fs_enet_data
.fs_no
= *id
;
733 strcpy(fs_enet_data
.fs_type
, model
);
735 mdio
= of_get_parent(phy
);
736 ret
= of_address_to_resource(mdio
, 0, &res
);
743 fs_enet_data
.clk_rx
= *((u32
*)of_get_property(np
,
745 fs_enet_data
.clk_tx
= *((u32
*)of_get_property(np
,
748 if (strstr(model
, "FCC")) {
749 int fcc_index
= *id
- 1;
750 const unsigned char *mdio_bb_prop
;
752 fs_enet_data
.dpram_offset
= (u32
)cpm_dpram_addr(0);
753 fs_enet_data
.rx_ring
= 32;
754 fs_enet_data
.tx_ring
= 32;
755 fs_enet_data
.rx_copybreak
= 240;
756 fs_enet_data
.use_napi
= 0;
757 fs_enet_data
.napi_weight
= 17;
758 fs_enet_data
.mem_offset
= FCC_MEM_OFFSET(fcc_index
);
759 fs_enet_data
.cp_page
= CPM_CR_FCC_PAGE(fcc_index
);
760 fs_enet_data
.cp_block
= CPM_CR_FCC_SBLOCK(fcc_index
);
762 snprintf((char*)&bus_id
[(*id
)], BUS_ID_SIZE
, "%x:%02x",
763 (u32
)res
.start
, fs_enet_data
.phy_addr
);
764 fs_enet_data
.bus_id
= (char*)&bus_id
[(*id
)];
765 fs_enet_data
.init_ioports
= init_fcc_ioports
;
767 mdio_bb_prop
= of_get_property(phy
, "bitbang", NULL
);
769 struct platform_device
*fs_enet_mdio_bb_dev
;
770 struct fs_mii_bb_platform_info fs_enet_mdio_bb_data
;
772 fs_enet_mdio_bb_dev
=
773 platform_device_register_simple("fsl-bb-mdio",
775 memset(&fs_enet_mdio_bb_data
, 0,
776 sizeof(struct fs_mii_bb_platform_info
));
777 fs_enet_mdio_bb_data
.mdio_dat
.bit
=
779 fs_enet_mdio_bb_data
.mdio_dir
.bit
=
781 fs_enet_mdio_bb_data
.mdc_dat
.bit
=
783 fs_enet_mdio_bb_data
.mdio_port
=
785 fs_enet_mdio_bb_data
.mdc_port
=
787 fs_enet_mdio_bb_data
.delay
=
790 fs_enet_mdio_bb_data
.irq
[0] = phy_irq
[0];
791 fs_enet_mdio_bb_data
.irq
[1] = -1;
792 fs_enet_mdio_bb_data
.irq
[2] = -1;
793 fs_enet_mdio_bb_data
.irq
[3] = phy_irq
[0];
794 fs_enet_mdio_bb_data
.irq
[31] = -1;
796 fs_enet_mdio_bb_data
.mdio_dat
.offset
=
797 (u32
)&cpm2_immr
->im_ioport
.iop_pdatc
;
798 fs_enet_mdio_bb_data
.mdio_dir
.offset
=
799 (u32
)&cpm2_immr
->im_ioport
.iop_pdirc
;
800 fs_enet_mdio_bb_data
.mdc_dat
.offset
=
801 (u32
)&cpm2_immr
->im_ioport
.iop_pdatc
;
803 ret
= platform_device_add_data(
805 &fs_enet_mdio_bb_data
,
806 sizeof(struct fs_mii_bb_platform_info
));
814 ret
= platform_device_add_data(fs_enet_dev
, &fs_enet_data
,
824 platform_device_unregister(fs_enet_dev
);
829 arch_initcall(fs_enet_of_init
);
831 static const char scc_regs
[] = "regs";
832 static const char scc_pram
[] = "pram";
834 static int __init
cpm_uart_of_init(void)
836 struct device_node
*np
;
838 struct platform_device
*cpm_uart_dev
;
841 for (np
= NULL
, i
= 0;
842 (np
= of_find_compatible_node(np
, "serial", "cpm_uart")) != NULL
;
844 struct resource r
[3];
845 struct fs_uart_platform_info cpm_uart_data
;
849 memset(r
, 0, sizeof(r
));
850 memset(&cpm_uart_data
, 0, sizeof(cpm_uart_data
));
852 ret
= of_address_to_resource(np
, 0, &r
[0]);
856 r
[0].name
= scc_regs
;
858 ret
= of_address_to_resource(np
, 1, &r
[1]);
861 r
[1].name
= scc_pram
;
863 of_irq_to_resource(np
, 0, &r
[2]);
866 platform_device_register_simple("fsl-cpm-scc:uart", i
, &r
[0], 3);
868 if (IS_ERR(cpm_uart_dev
)) {
869 ret
= PTR_ERR(cpm_uart_dev
);
873 id
= of_get_property(np
, "device-id", NULL
);
874 cpm_uart_data
.fs_no
= *id
;
876 model
= of_get_property(np
, "model", NULL
);
877 strcpy(cpm_uart_data
.fs_type
, model
);
879 cpm_uart_data
.uart_clk
= ppc_proc_freq
;
881 cpm_uart_data
.tx_num_fifo
= 4;
882 cpm_uart_data
.tx_buf_size
= 32;
883 cpm_uart_data
.rx_num_fifo
= 4;
884 cpm_uart_data
.rx_buf_size
= 32;
885 cpm_uart_data
.clk_rx
= *((u32
*)of_get_property(np
,
887 cpm_uart_data
.clk_tx
= *((u32
*)of_get_property(np
,
891 platform_device_add_data(cpm_uart_dev
, &cpm_uart_data
,
893 fs_uart_platform_info
));
901 platform_device_unregister(cpm_uart_dev
);
906 arch_initcall(cpm_uart_of_init
);
907 #endif /* CONFIG_CPM2 */
911 extern void init_scc_ioports(struct fs_platform_info
*);
912 extern int platform_device_skip(const char *model
, int id
);
914 static int __init
fs_enet_mdio_of_init(void)
916 struct device_node
*np
;
918 struct platform_device
*mdio_dev
;
922 for (np
= NULL
, i
= 0;
923 (np
= of_find_compatible_node(np
, "mdio", "fs_enet")) != NULL
;
925 struct fs_mii_fec_platform_info mdio_data
;
927 memset(&res
, 0, sizeof(res
));
928 memset(&mdio_data
, 0, sizeof(mdio_data
));
930 ret
= of_address_to_resource(np
, 0, &res
);
935 platform_device_register_simple("fsl-cpm-fec-mdio",
937 if (IS_ERR(mdio_dev
)) {
938 ret
= PTR_ERR(mdio_dev
);
942 mdio_data
.mii_speed
= ((((ppc_proc_freq
+ 4999999) / 2500000) / 2) & 0x3F) << 1;
945 platform_device_add_data(mdio_dev
, &mdio_data
,
946 sizeof(struct fs_mii_fec_platform_info
));
953 platform_device_unregister(mdio_dev
);
958 arch_initcall(fs_enet_mdio_of_init
);
960 static const char *enet_regs
= "regs";
961 static const char *enet_pram
= "pram";
962 static const char *enet_irq
= "interrupt";
963 static char bus_id
[9][BUS_ID_SIZE
];
965 static int __init
fs_enet_of_init(void)
967 struct device_node
*np
;
969 struct platform_device
*fs_enet_dev
= NULL
;
973 for (np
= NULL
, i
= 0;
974 (np
= of_find_compatible_node(np
, "network", "fs_enet")) != NULL
;
976 struct resource r
[4];
977 struct device_node
*phy
= NULL
, *mdio
= NULL
;
978 struct fs_platform_info fs_enet_data
;
979 const unsigned int *id
;
980 const unsigned int *phy_addr
;
981 const void *mac_addr
;
985 memset(r
, 0, sizeof(r
));
986 memset(&fs_enet_data
, 0, sizeof(fs_enet_data
));
988 model
= of_get_property(np
, "model", NULL
);
994 id
= of_get_property(np
, "device-id", NULL
);
995 fs_enet_data
.fs_no
= *id
;
997 if (platform_device_skip(model
, *id
))
1000 ret
= of_address_to_resource(np
, 0, &r
[0]);
1003 r
[0].name
= enet_regs
;
1005 mac_addr
= of_get_mac_address(np
);
1007 memcpy(fs_enet_data
.macaddr
, mac_addr
, 6);
1009 ph
= of_get_property(np
, "phy-handle", NULL
);
1011 phy
= of_find_node_by_phandle(*ph
);
1014 phy_addr
= of_get_property(phy
, "reg", NULL
);
1015 fs_enet_data
.phy_addr
= *phy_addr
;
1016 fs_enet_data
.has_phy
= 1;
1018 mdio
= of_get_parent(phy
);
1019 ret
= of_address_to_resource(mdio
, 0, &res
);
1027 model
= of_get_property(np
, "model", NULL
);
1028 strcpy(fs_enet_data
.fs_type
, model
);
1030 if (strstr(model
, "FEC")) {
1031 r
[1].start
= r
[1].end
= irq_of_parse_and_map(np
, 0);
1032 r
[1].flags
= IORESOURCE_IRQ
;
1033 r
[1].name
= enet_irq
;
1036 platform_device_register_simple("fsl-cpm-fec", i
, &r
[0], 2);
1038 if (IS_ERR(fs_enet_dev
)) {
1039 ret
= PTR_ERR(fs_enet_dev
);
1043 fs_enet_data
.rx_ring
= 128;
1044 fs_enet_data
.tx_ring
= 16;
1045 fs_enet_data
.rx_copybreak
= 240;
1046 fs_enet_data
.use_napi
= 1;
1047 fs_enet_data
.napi_weight
= 17;
1049 snprintf((char*)&bus_id
[i
], BUS_ID_SIZE
, "%x:%02x",
1050 (u32
)res
.start
, fs_enet_data
.phy_addr
);
1051 fs_enet_data
.bus_id
= (char*)&bus_id
[i
];
1052 fs_enet_data
.init_ioports
= init_fec_ioports
;
1054 if (strstr(model
, "SCC")) {
1055 ret
= of_address_to_resource(np
, 1, &r
[1]);
1058 r
[1].name
= enet_pram
;
1060 r
[2].start
= r
[2].end
= irq_of_parse_and_map(np
, 0);
1061 r
[2].flags
= IORESOURCE_IRQ
;
1062 r
[2].name
= enet_irq
;
1065 platform_device_register_simple("fsl-cpm-scc", i
, &r
[0], 3);
1067 if (IS_ERR(fs_enet_dev
)) {
1068 ret
= PTR_ERR(fs_enet_dev
);
1072 fs_enet_data
.rx_ring
= 64;
1073 fs_enet_data
.tx_ring
= 8;
1074 fs_enet_data
.rx_copybreak
= 240;
1075 fs_enet_data
.use_napi
= 1;
1076 fs_enet_data
.napi_weight
= 17;
1078 snprintf((char*)&bus_id
[i
], BUS_ID_SIZE
, "%s", "fixed@10:1");
1079 fs_enet_data
.bus_id
= (char*)&bus_id
[i
];
1080 fs_enet_data
.init_ioports
= init_scc_ioports
;
1086 ret
= platform_device_add_data(fs_enet_dev
, &fs_enet_data
,
1095 platform_device_unregister(fs_enet_dev
);
1100 arch_initcall(fs_enet_of_init
);
1102 static int __init
fsl_pcmcia_of_init(void)
1104 struct device_node
*np
= NULL
;
1106 * Register all the devices which type is "pcmcia"
1108 while ((np
= of_find_compatible_node(np
,
1109 "pcmcia", "fsl,pq-pcmcia")) != NULL
)
1110 of_platform_device_create(np
, "m8xx-pcmcia", NULL
);
1114 arch_initcall(fsl_pcmcia_of_init
);
1116 static const char *smc_regs
= "regs";
1117 static const char *smc_pram
= "pram";
1119 static int __init
cpm_smc_uart_of_init(void)
1121 struct device_node
*np
;
1123 struct platform_device
*cpm_uart_dev
;
1126 for (np
= NULL
, i
= 0;
1127 (np
= of_find_compatible_node(np
, "serial", "cpm_uart")) != NULL
;
1129 struct resource r
[3];
1130 struct fs_uart_platform_info cpm_uart_data
;
1134 memset(r
, 0, sizeof(r
));
1135 memset(&cpm_uart_data
, 0, sizeof(cpm_uart_data
));
1137 ret
= of_address_to_resource(np
, 0, &r
[0]);
1141 r
[0].name
= smc_regs
;
1143 ret
= of_address_to_resource(np
, 1, &r
[1]);
1146 r
[1].name
= smc_pram
;
1148 r
[2].start
= r
[2].end
= irq_of_parse_and_map(np
, 0);
1149 r
[2].flags
= IORESOURCE_IRQ
;
1152 platform_device_register_simple("fsl-cpm-smc:uart", i
, &r
[0], 3);
1154 if (IS_ERR(cpm_uart_dev
)) {
1155 ret
= PTR_ERR(cpm_uart_dev
);
1159 model
= of_get_property(np
, "model", NULL
);
1160 strcpy(cpm_uart_data
.fs_type
, model
);
1162 id
= of_get_property(np
, "device-id", NULL
);
1163 cpm_uart_data
.fs_no
= *id
;
1164 cpm_uart_data
.uart_clk
= ppc_proc_freq
;
1166 cpm_uart_data
.tx_num_fifo
= 4;
1167 cpm_uart_data
.tx_buf_size
= 32;
1168 cpm_uart_data
.rx_num_fifo
= 4;
1169 cpm_uart_data
.rx_buf_size
= 32;
1172 platform_device_add_data(cpm_uart_dev
, &cpm_uart_data
,
1174 fs_uart_platform_info
));
1182 platform_device_unregister(cpm_uart_dev
);
1187 arch_initcall(cpm_smc_uart_of_init
);
1189 #endif /* CONFIG_8xx */