Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=01f0e78e15c52af480c867af5bd406afec80d9cc
Commit:     01f0e78e15c52af480c867af5bd406afec80d9cc
Parent:     649c8e0289eeee2ab3d4c6c6e062df24dd602233
Author:     Dale Farnsworth <[EMAIL PROTECTED]>
AuthorDate: Sat May 12 10:56:47 2007 +1000
Committer:  Paul Mackerras <[EMAIL PROTECTED]>
CommitDate: Sat May 12 11:32:50 2007 +1000

    [POWERPC] Create Marvell mv64x60 I2C platform_data
    
    This patch creates platform_device entries for the Marvell mv64x60
    I2C ports, based on information contained in device tree.
    
    This driver (like the other mv64x60 drivers) are unusual in that it
    works on both the MIPS and PowerPC architectures.  Because of that,
    the drivers do not support the normal PowerPC of_platform_bus_type.
    They support platform_bus_type instead.
    
    Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>
    Acked-by: Arnd Bergmann <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/mv64x60_dev.c |   72 +++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/mv64x60_dev.c 
b/arch/powerpc/sysdev/mv64x60_dev.c
index 0ccc495..4b0a9c8 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -323,6 +323,72 @@ error:
        return err;
 }
 
+/*
+ * Create mv64x60_i2c platform devices
+ */
+static int __init mv64x60_i2c_device_setup(struct device_node *np, int id)
+{
+       struct resource r[2];
+       struct platform_device *pdev;
+       struct mv64xxx_i2c_pdata pdata;
+       const unsigned int *prop;
+       int err;
+
+       memset(r, 0, sizeof(r));
+
+       err = of_address_to_resource(np, 0, &r[0]);
+       if (err)
+               return err;
+
+       of_irq_to_resource(np, 0, &r[1]);
+
+       memset(&pdata, 0, sizeof(pdata));
+
+       prop = of_get_property(np, "freq_m", NULL);
+       if (!prop)
+               return -ENODEV;
+       pdata.freq_m = *prop;
+
+       prop = of_get_property(np, "freq_n", NULL);
+       if (!prop)
+               return -ENODEV;
+       pdata.freq_n = *prop;
+
+       prop = of_get_property(np, "timeout", NULL);
+       if (prop)
+               pdata.timeout = *prop;
+       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;
+
+       err = platform_device_add_resources(pdev, r, 2);
+       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;
@@ -341,6 +407,12 @@ static int __init mv64x60_device_setup(void)
                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)))
+                       goto error;
+
        return 0;
 
 error:
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to