Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / arch / powerpc / sysdev / fsl_soc.c
index ef10bcf..ceb5846 100644 (file)
@@ -9,6 +9,7 @@
  * option) any later version.
  */
 
+#include <linux/config.h>
 #include <linux/stddef.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -85,8 +86,11 @@ static int __init gfar_mdio_of_init(void)
                        mdio_data.irq[k] = -1;
 
                while ((child = of_get_next_child(np, child)) != NULL) {
-                       u32 *id = get_property(child, "reg", NULL);
-                       mdio_data.irq[*id] = irq_of_parse_and_map(child, 0);
+                       if (child->n_intrs) {
+                               u32 *id =
+                                   (u32 *) get_property(child, "reg", NULL);
+                               mdio_data.irq[*id] = child->intrs[0].line;
+                       }
                }
 
                ret =
@@ -128,7 +132,6 @@ static int __init gfar_of_init(void)
                char *model;
                void *mac_addr;
                phandle *ph;
-               int n_res = 1;
 
                memset(r, 0, sizeof(r));
                memset(&gfar_data, 0, sizeof(gfar_data));
@@ -137,7 +140,8 @@ static int __init gfar_of_init(void)
                if (ret)
                        goto err;
 
-               r[1].start = r[1].end = irq_of_parse_and_map(np, 0);
+               r[1].start = np->intrs[0].line;
+               r[1].end = np->intrs[0].line;
                r[1].flags = IORESOURCE_IRQ;
 
                model = get_property(np, "model", NULL);
@@ -147,35 +151,27 @@ static int __init gfar_of_init(void)
                        r[1].name = gfar_tx_intr;
 
                        r[2].name = gfar_rx_intr;
-                       r[2].start = r[2].end = irq_of_parse_and_map(np, 1);
+                       r[2].start = np->intrs[1].line;
+                       r[2].end = np->intrs[1].line;
                        r[2].flags = IORESOURCE_IRQ;
 
                        r[3].name = gfar_err_intr;
-                       r[3].start = r[3].end = irq_of_parse_and_map(np, 2);
+                       r[3].start = np->intrs[2].line;
+                       r[3].end = np->intrs[2].line;
                        r[3].flags = IORESOURCE_IRQ;
-
-                       n_res += 2;
                }
 
                gfar_dev =
                    platform_device_register_simple("fsl-gianfar", i, &r[0],
-                                                   n_res + 1);
+                                                   np->n_intrs + 1);
 
                if (IS_ERR(gfar_dev)) {
                        ret = PTR_ERR(gfar_dev);
                        goto err;
                }
 
-               mac_addr = get_property(np, "local-mac-address", NULL);
-               if (mac_addr == NULL)
-                       mac_addr = get_property(np, "mac-address", NULL);
-               if (mac_addr == NULL) {
-                       /* Obsolete */
-                       mac_addr = get_property(np, "address", NULL);
-               }
-
-               if (mac_addr)
-                       memcpy(gfar_data.mac_addr, mac_addr, 6);
+               mac_addr = get_property(np, "address", NULL);
+               memcpy(gfar_data.mac_addr, mac_addr, 6);
 
                if (model && !strcasecmp(model, "TSEC"))
                        gfar_data.device_flags =
@@ -256,7 +252,8 @@ static int __init fsl_i2c_of_init(void)
                if (ret)
                        goto err;
 
-               r[1].start = r[1].end = irq_of_parse_and_map(np, 0);
+               r[1].start = np->intrs[0].line;
+               r[1].end = np->intrs[0].line;
                r[1].flags = IORESOURCE_IRQ;
 
                i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
@@ -375,7 +372,7 @@ static int __init fsl_usb_of_init(void)
 {
        struct device_node *np;
        unsigned int i;
-       struct platform_device *usb_dev_mph = NULL, *usb_dev_dr = NULL;
+       struct platform_device *usb_dev;
        int ret;
 
        for (np = NULL, i = 0;
@@ -392,18 +389,19 @@ static int __init fsl_usb_of_init(void)
                if (ret)
                        goto err;
 
-               r[1].start = r[1].end = irq_of_parse_and_map(np, 0);
+               r[1].start = np->intrs[0].line;
+               r[1].end = np->intrs[0].line;
                r[1].flags = IORESOURCE_IRQ;
 
-               usb_dev_mph =
-                   platform_device_register_simple("fsl-ehci", i, r, 2);
-               if (IS_ERR(usb_dev_mph)) {
-                       ret = PTR_ERR(usb_dev_mph);
+               usb_dev =
+                   platform_device_register_simple("fsl-usb2-mph", i, r, 2);
+               if (IS_ERR(usb_dev)) {
+                       ret = PTR_ERR(usb_dev);
                        goto err;
                }
 
-               usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL;
-               usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask;
+               usb_dev->dev.coherent_dma_mask = 0xffffffffUL;
+               usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask;
 
                usb_data.operating_mode = FSL_USB2_MPH_HOST;
 
@@ -419,14 +417,31 @@ static int __init fsl_usb_of_init(void)
                usb_data.phy_mode = determine_usb_phy(prop);
 
                ret =
-                   platform_device_add_data(usb_dev_mph, &usb_data,
+                   platform_device_add_data(usb_dev, &usb_data,
                                             sizeof(struct
                                                    fsl_usb2_platform_data));
                if (ret)
-                       goto unreg_mph;
+                       goto unreg;
        }
 
-       for (np = NULL;
+       return 0;
+
+unreg:
+       platform_device_unregister(usb_dev);
+err:
+       return ret;
+}
+
+arch_initcall(fsl_usb_of_init);
+
+static int __init fsl_usb_dr_of_init(void)
+{
+       struct device_node *np;
+       unsigned int i;
+       struct platform_device *usb_dev;
+       int ret;
+
+       for (np = NULL, i = 0;
             (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL;
             i++) {
                struct resource r[2];
@@ -438,20 +453,21 @@ static int __init fsl_usb_of_init(void)
 
                ret = of_address_to_resource(np, 0, &r[0]);
                if (ret)
-                       goto unreg_mph;
+                       goto err;
 
-               r[1].start = r[1].end = irq_of_parse_and_map(np, 0);
+               r[1].start = np->intrs[0].line;
+               r[1].end = np->intrs[0].line;
                r[1].flags = IORESOURCE_IRQ;
 
-               usb_dev_dr =
-                   platform_device_register_simple("fsl-ehci", i, r, 2);
-               if (IS_ERR(usb_dev_dr)) {
-                       ret = PTR_ERR(usb_dev_dr);
+               usb_dev =
+                   platform_device_register_simple("fsl-usb2-dr", i, r, 2);
+               if (IS_ERR(usb_dev)) {
+                       ret = PTR_ERR(usb_dev);
                        goto err;
                }
 
-               usb_dev_dr->dev.coherent_dma_mask = 0xffffffffUL;
-               usb_dev_dr->dev.dma_mask = &usb_dev_dr->dev.coherent_dma_mask;
+               usb_dev->dev.coherent_dma_mask = 0xffffffffUL;
+               usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask;
 
                usb_data.operating_mode = FSL_USB2_DR_HOST;
 
@@ -459,22 +475,19 @@ static int __init fsl_usb_of_init(void)
                usb_data.phy_mode = determine_usb_phy(prop);
 
                ret =
-                   platform_device_add_data(usb_dev_dr, &usb_data,
+                   platform_device_add_data(usb_dev, &usb_data,
                                             sizeof(struct
                                                    fsl_usb2_platform_data));
                if (ret)
-                       goto unreg_dr;
+                       goto unreg;
        }
+
        return 0;
 
-unreg_dr:
-       if (usb_dev_dr)
-               platform_device_unregister(usb_dev_dr);
-unreg_mph:
-       if (usb_dev_mph)
-               platform_device_unregister(usb_dev_mph);
+unreg:
+       platform_device_unregister(usb_dev);
 err:
        return ret;
 }
 
-arch_initcall(fsl_usb_of_init);
+arch_initcall(fsl_usb_dr_of_init);