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