[I2C] Split mv643xx I2C platform support
authorTzachi Perelstein <tzachi@marvell.com>
Mon, 12 Nov 2007 17:38:51 +0000 (19:38 +0200)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 26 Jan 2008 15:03:59 +0000 (15:03 +0000)
The motivation for this change is to allow other chips, like the
Marvell Orion ARM SoC family, to use the existing i2c-mv64xxx driver.

Signed-off-by: Tzachi Perelstein <tzachi@marvell.com>
Acked-by: Nicolas Pitre <nico@marvell.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Acked-by: Mark A. Greer <mgreer@mvista.com>
Acked-by: Jean Delvare <khali@linux-fr.org>
drivers/i2c/busses/Kconfig
drivers/i2c/busses/i2c-mv64xxx.c
include/linux/mv643xx.h
include/linux/mv643xx_i2c.h [new file with mode: 0644]

index c466c6cfc2e53512c402f2eae138c625a1fb1e69..b148bf0ec6b7ae4da3e5ee25cd9df870f2cb7d10 100644 (file)
@@ -648,7 +648,7 @@ config I2C_PCA_ISA
 
 config I2C_MV64XXX
        tristate "Marvell mv64xxx I2C Controller"
-       depends on MV64X60 && EXPERIMENTAL
+       depends on (MV64X60 || ARCH_ORION) && EXPERIMENTAL
        help
          If you say yes to this option, support will be included for the
          built-in I2C interface on the Marvell 64xxx line of host bridges.
index bb7bf68a7fb66eb4fb648ba0d770d2bcbda38333..cdd1ef99fcff512e90c900e07fb04669872bc7a3 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Driver for the i2c controller on the Marvell line of host bridges for MIPS
- * and PPC (e.g, gt642[46]0, mv643[46]0, mv644[46]0).
+ * Driver for the i2c controller on the Marvell line of host bridges
+ * (e.g, gt642[46]0, mv643[46]0, mv644[46]0, and Orion SoC family).
  *
  * Author: Mark A. Greer <mgreer@mvista.com>
  *
@@ -14,7 +14,7 @@
 #include <linux/spinlock.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
-#include <linux/mv643xx.h>
+#include <linux/mv643xx_i2c.h>
 #include <linux/platform_device.h>
 
 #include <asm/io.h>
@@ -86,6 +86,7 @@ struct mv64xxx_i2c_data {
        u32                     cntl_bits;
        void __iomem            *reg_base;
        u32                     reg_base_p;
+       u32                     reg_size;
        u32                     addr1;
        u32                     addr2;
        u32                     bytes_left;
@@ -463,17 +464,20 @@ static int __devinit
 mv64xxx_i2c_map_regs(struct platform_device *pd,
        struct mv64xxx_i2c_data *drv_data)
 {
-       struct resource *r;
+       int size;
+       struct resource *r = platform_get_resource(pd, IORESOURCE_MEM, 0);
 
-       if ((r = platform_get_resource(pd, IORESOURCE_MEM, 0)) &&
-               request_mem_region(r->start, MV64XXX_I2C_REG_BLOCK_SIZE,
-                       drv_data->adapter.name)) {
+       if (!r)
+               return -ENODEV;
 
-               drv_data->reg_base = ioremap(r->start,
-                       MV64XXX_I2C_REG_BLOCK_SIZE);
-               drv_data->reg_base_p = r->start;
-       } else
-               return -ENOMEM;
+       size = r->end - r->start + 1;
+
+       if (!request_mem_region(r->start, size, drv_data->adapter.name))
+               return -EBUSY;
+
+       drv_data->reg_base = ioremap(r->start, size);
+       drv_data->reg_base_p = r->start;
+       drv_data->reg_size = size;
 
        return 0;
 }
@@ -483,8 +487,7 @@ mv64xxx_i2c_unmap_regs(struct mv64xxx_i2c_data *drv_data)
 {
        if (drv_data->reg_base) {
                iounmap(drv_data->reg_base);
-               release_mem_region(drv_data->reg_base_p,
-                       MV64XXX_I2C_REG_BLOCK_SIZE);
+               release_mem_region(drv_data->reg_base_p, drv_data->reg_size);
        }
 
        drv_data->reg_base = NULL;
index d2ae6185f03be619ff8d21021cc7cee789956816..69327b7b4ce46e6601c128b46cdd0a3d81c400d4 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <asm/types.h>
 #include <linux/mv643xx_eth.h>
+#include <linux/mv643xx_i2c.h>
 
 /****************************************/
 /* Processor Address Space              */
 /* I2C Registers                        */
 /****************************************/
 
-#define MV64XXX_I2C_CTLR_NAME                                  "mv64xxx_i2c"
 #define MV64XXX_I2C_OFFSET                                          0xc000
 #define MV64XXX_I2C_REG_BLOCK_SIZE                                  0x0020
 
@@ -968,14 +968,6 @@ struct mpsc_pdata {
        u32     brg_clk_freq;
 };
 
-/* i2c Platform Device, Driver Data */
-struct mv64xxx_i2c_pdata {
-       u32     freq_m;
-       u32     freq_n;
-       u32     timeout;        /* In milliseconds */
-       u32     retries;
-};
-
 /* Watchdog Platform Device, Driver Data */
 #define        MV64x60_WDT_NAME                        "mv64x60_wdt"
 
diff --git a/include/linux/mv643xx_i2c.h b/include/linux/mv643xx_i2c.h
new file mode 100644 (file)
index 0000000..adb629b
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#ifndef _MV64XXX_I2C_H_
+#define _MV64XXX_I2C_H_
+
+#include <linux/types.h>
+
+#define MV64XXX_I2C_CTLR_NAME  "mv64xxx_i2c"
+
+/* i2c Platform Device, Driver Data */
+struct mv64xxx_i2c_pdata {
+       u32     freq_m;
+       u32     freq_n;
+       u32     timeout;        /* In milliseconds */
+       u32     retries;
+};
+
+#endif /*_MV64XXX_I2C_H_*/