I2C device has some board-specific parameters such as bus frequency
and per-transaction setup delay. The DM6446 DVEVM, for example,
requires a much lower bus frequency of 20kHz and a setup delay of
100us due to the presence of the MSP430 doing software I2C. Other
boards can use the defaults defined in drivers/i2c/i2c-davinci.c,
but will still need to define the platform device themselves.

Signed-off-by: Bernard Blackham <[EMAIL PROTECTED]>

---
 board-evm.c |   38 ++++++++++++++++++++++++++++++++++++++
 devices.c   |   33 ---------------------------------
 2 files changed, 38 insertions(+), 33 deletions(-)

Index: linux-2.6.24-tl1/arch/arm/mach-davinci/board-evm.c
===================================================================
--- linux-2.6.24-tl1.orig/arch/arm/mach-davinci/board-evm.c     2008-04-18 
02:41:49.000000000 +0800
+++ linux-2.6.24-tl1/arch/arm/mach-davinci/board-evm.c  2008-04-18 
02:49:39.000000000 +0800
@@ -28,6 +28,7 @@
 #include <asm/mach/flash.h>
 
 #include <asm/arch/common.h>
+#include <asm/arch/i2c.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/psc.h>
 
@@ -197,6 +198,40 @@
 #define setup_usb(void)        do {} while(0)
 #endif  /* CONFIG_USB_MUSB_HDRC */
 
+/*
+ * I2C
+ */
+#if defined(CONFIG_I2C_DAVINCI) || defined(CONFIG_I2C_DAVINCI_MODULE)
+
+static struct resource i2c_resources[] = {
+       {
+               .start          = DAVINCI_I2C_BASE,
+               .end            = DAVINCI_I2C_BASE + 0x40,
+               .flags          = IORESOURCE_MEM,
+       },
+       {
+               .start          = IRQ_I2C,
+               .flags          = IORESOURCE_IRQ,
+       },
+};
+
+static struct davinci_i2c_platform_data dvevm_i2c_platform_data = {
+       .bus_freq       = 20,
+       .bus_delay      = 100,
+};
+
+static struct platform_device davinci_i2c_device = {
+       .name           = "i2c_davinci",
+       .id             = 1,
+       .num_resources  = ARRAY_SIZE(i2c_resources),
+       .resource       = i2c_resources,
+       .dev = {
+               .platform_data = &dvevm_i2c_platform_data,
+       },
+};
+
+#endif
+
 static struct platform_device rtc_dev = {
        .name           = "rtc_davinci_evm",
        .id             = -1,
@@ -213,6 +248,9 @@
 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
        &usb_dev,
 #endif
+#if defined(CONFIG_I2C_DAVINCI) || defined(CONFIG_I2C_DAVINCI_MODULE)
+       &davinci_i2c_device,
+#endif
        &rtc_dev,
 };
 
Index: linux-2.6.24-tl1/arch/arm/mach-davinci/devices.c
===================================================================
--- linux-2.6.24-tl1.orig/arch/arm/mach-davinci/devices.c       2008-04-18 
02:41:49.000000000 +0800
+++ linux-2.6.24-tl1/arch/arm/mach-davinci/devices.c    2008-04-18 
02:49:43.000000000 +0800
@@ -20,38 +20,6 @@
 #include <asm/mach-types.h>
 #include <asm/mach/map.h>
 
-#if    defined(CONFIG_I2C_DAVINCI) || defined(CONFIG_I2C_DAVINCI_MODULE)
-
-static struct resource i2c_resources[] = {
-       {
-               .start          = DAVINCI_I2C_BASE,
-               .end            = DAVINCI_I2C_BASE + 0x40,
-               .flags          = IORESOURCE_MEM,
-       },
-       {
-               .start          = IRQ_I2C,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device davinci_i2c_device = {
-       .name           = "i2c_davinci",
-       .id             = 1,
-       .num_resources  = ARRAY_SIZE(i2c_resources),
-       .resource       = i2c_resources,
-};
-
-static void davinci_init_i2c(void)
-{
-       (void) platform_device_register(&davinci_i2c_device);
-}
-
-#else
-
-static void davinci_init_i2c(void) {}
-
-#endif
-
 
 #if    defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE)
 
@@ -99,7 +67,6 @@
        /* please keep these calls, and their implementations above,
         * in alphabetical order so they're easier to sort through.
         */
-       davinci_init_i2c();
        davinci_init_mmcsd();
 
        return 0;
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to