]> err.no Git - linux-2.6/blobdiff - arch/powerpc/sysdev/mv64x60_dev.c
Merge branch 'linux-2.6'
[linux-2.6] / arch / powerpc / sysdev / mv64x60_dev.c
index b618fa60aef342f42dad4e845f1d9a73718cfee3..efda0028909dbec17e7a58adf8945a41f4f6615b 100644 (file)
@@ -241,7 +241,7 @@ static int __init mv64x60_eth_device_setup(struct device_node *np, int id)
 
        /* only register the shared platform device the first time through */
        if (id == 0 && (err = eth_register_shared_pdev(np)))
-               return err;;
+               return err;
 
        memset(r, 0, sizeof(r));
        of_irq_to_resource(np, 0, &r[0]);
@@ -361,12 +361,6 @@ static int __init mv64x60_i2c_device_setup(struct device_node *np, int id)
        else
                pdata.timeout = 1000;   /* 1 second */
 
-       prop = of_get_property(np, "retries", NULL);
-       if (prop)
-               pdata.retries = *prop;
-       else
-               pdata.retries = 1;
-
        pdev = platform_device_alloc(MV64XXX_I2C_CTLR_NAME, id);
        if (!pdev)
                return -ENOMEM;
@@ -390,30 +384,90 @@ error:
        return err;
 }
 
+/*
+ * Create mv64x60_wdt platform devices
+ */
+static int __init mv64x60_wdt_device_setup(struct device_node *np, int id)
+{
+       struct resource r;
+       struct platform_device *pdev;
+       struct mv64x60_wdt_pdata pdata;
+       const unsigned int *prop;
+       int err;
+
+       err = of_address_to_resource(np, 0, &r);
+       if (err)
+               return err;
+
+       memset(&pdata, 0, sizeof(pdata));
+
+       prop = of_get_property(np, "timeout", NULL);
+       if (!prop)
+               return -ENODEV;
+       pdata.timeout = *prop;
+
+       np = of_get_parent(np);
+       if (!np)
+               return -ENODEV;
+
+       prop = of_get_property(np, "clock-frequency", NULL);
+       of_node_put(np);
+       if (!prop)
+               return -ENODEV;
+       pdata.bus_clk = *prop / 1000000; /* wdt driver wants freq in MHz */
+
+       pdev = platform_device_alloc(MV64x60_WDT_NAME, id);
+       if (!pdev)
+               return -ENOMEM;
+
+       err = platform_device_add_resources(pdev, &r, 1);
+       if (err)
+               goto error;
+
+       err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+       if (err)
+               goto error;
+
+       err = platform_device_add(pdev);
+       if (err)
+               goto error;
+
+       return 0;
+
+error:
+       platform_device_put(pdev);
+       return err;
+}
+
 static int __init mv64x60_device_setup(void)
 {
        struct device_node *np = NULL;
        int id;
        int err;
 
-       for (id = 0;
-            (np = of_find_compatible_node(np, "serial", "marvell,mpsc")); id++)
-               if ((err = mv64x60_mpsc_device_setup(np, id)))
+       id = 0;
+       for_each_compatible_node(np, "serial", "marvell,mpsc")
+               if ((err = mv64x60_mpsc_device_setup(np, id++)))
                        goto error;
 
-       for (id = 0;
-            (np = of_find_compatible_node(np, "network",
-                                          "marvell,mv64x60-eth"));
-            id++)
-               if ((err = mv64x60_eth_device_setup(np, id)))
+       id = 0;
+       for_each_compatible_node(np, "network", "marvell,mv64x60-eth")
+               if ((err = mv64x60_eth_device_setup(np, id++)))
                        goto error;
 
-       for (id = 0;
-            (np = of_find_compatible_node(np, "i2c", "marvell,mv64x60-i2c"));
-            id++)
-               if ((err = mv64x60_i2c_device_setup(np, id)))
+       id = 0;
+       for_each_compatible_node(np, "i2c", "marvell,mv64x60-i2c")
+               if ((err = mv64x60_i2c_device_setup(np, id++)))
                        goto error;
 
+       /* support up to one watchdog timer */
+       np = of_find_compatible_node(np, NULL, "marvell,mv64x60-wdt");
+       if (np) {
+               if ((err = mv64x60_wdt_device_setup(np, id)))
+                       goto error;
+               of_node_put(np);
+       }
+
        return 0;
 
 error: