diff options
author | Tzachi Perelstein <tzachi@marvell.com> | 2007-11-12 12:38:51 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-01-26 10:03:59 -0500 |
commit | a0832798c05241f15e793805b6024919c07b8292 (patch) | |
tree | 32651dbe7acda8a17efe4f44e75547e6266bb49b | |
parent | 60ce1c20068ec2c138cdf9e5cbe583cc60883c62 (diff) |
[I2C] Split mv643xx I2C platform support
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>
-rw-r--r-- | drivers/i2c/busses/Kconfig | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-mv64xxx.c | 31 | ||||
-rw-r--r-- | include/linux/mv643xx.h | 10 | ||||
-rw-r--r-- | include/linux/mv643xx_i2c.h | 23 |
4 files changed, 42 insertions, 24 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index c466c6cfc2e5..b148bf0ec6b7 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -648,7 +648,7 @@ config I2C_PCA_ISA | |||
648 | 648 | ||
649 | config I2C_MV64XXX | 649 | config I2C_MV64XXX |
650 | tristate "Marvell mv64xxx I2C Controller" | 650 | tristate "Marvell mv64xxx I2C Controller" |
651 | depends on MV64X60 && EXPERIMENTAL | 651 | depends on (MV64X60 || ARCH_ORION) && EXPERIMENTAL |
652 | help | 652 | help |
653 | If you say yes to this option, support will be included for the | 653 | If you say yes to this option, support will be included for the |
654 | built-in I2C interface on the Marvell 64xxx line of host bridges. | 654 | built-in I2C interface on the Marvell 64xxx line of host bridges. |
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index bb7bf68a7fb6..cdd1ef99fcff 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the i2c controller on the Marvell line of host bridges for MIPS | 2 | * Driver for the i2c controller on the Marvell line of host bridges |
3 | * and PPC (e.g, gt642[46]0, mv643[46]0, mv644[46]0). | 3 | * (e.g, gt642[46]0, mv643[46]0, mv644[46]0, and Orion SoC family). |
4 | * | 4 | * |
5 | * Author: Mark A. Greer <mgreer@mvista.com> | 5 | * Author: Mark A. Greer <mgreer@mvista.com> |
6 | * | 6 | * |
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/spinlock.h> | 14 | #include <linux/spinlock.h> |
15 | #include <linux/i2c.h> | 15 | #include <linux/i2c.h> |
16 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
17 | #include <linux/mv643xx.h> | 17 | #include <linux/mv643xx_i2c.h> |
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | 19 | ||
20 | #include <asm/io.h> | 20 | #include <asm/io.h> |
@@ -86,6 +86,7 @@ struct mv64xxx_i2c_data { | |||
86 | u32 cntl_bits; | 86 | u32 cntl_bits; |
87 | void __iomem *reg_base; | 87 | void __iomem *reg_base; |
88 | u32 reg_base_p; | 88 | u32 reg_base_p; |
89 | u32 reg_size; | ||
89 | u32 addr1; | 90 | u32 addr1; |
90 | u32 addr2; | 91 | u32 addr2; |
91 | u32 bytes_left; | 92 | u32 bytes_left; |
@@ -463,17 +464,20 @@ static int __devinit | |||
463 | mv64xxx_i2c_map_regs(struct platform_device *pd, | 464 | mv64xxx_i2c_map_regs(struct platform_device *pd, |
464 | struct mv64xxx_i2c_data *drv_data) | 465 | struct mv64xxx_i2c_data *drv_data) |
465 | { | 466 | { |
466 | struct resource *r; | 467 | int size; |
468 | struct resource *r = platform_get_resource(pd, IORESOURCE_MEM, 0); | ||
467 | 469 | ||
468 | if ((r = platform_get_resource(pd, IORESOURCE_MEM, 0)) && | 470 | if (!r) |
469 | request_mem_region(r->start, MV64XXX_I2C_REG_BLOCK_SIZE, | 471 | return -ENODEV; |
470 | drv_data->adapter.name)) { | ||
471 | 472 | ||
472 | drv_data->reg_base = ioremap(r->start, | 473 | size = r->end - r->start + 1; |
473 | MV64XXX_I2C_REG_BLOCK_SIZE); | 474 | |
474 | drv_data->reg_base_p = r->start; | 475 | if (!request_mem_region(r->start, size, drv_data->adapter.name)) |
475 | } else | 476 | return -EBUSY; |
476 | return -ENOMEM; | 477 | |
478 | drv_data->reg_base = ioremap(r->start, size); | ||
479 | drv_data->reg_base_p = r->start; | ||
480 | drv_data->reg_size = size; | ||
477 | 481 | ||
478 | return 0; | 482 | return 0; |
479 | } | 483 | } |
@@ -483,8 +487,7 @@ mv64xxx_i2c_unmap_regs(struct mv64xxx_i2c_data *drv_data) | |||
483 | { | 487 | { |
484 | if (drv_data->reg_base) { | 488 | if (drv_data->reg_base) { |
485 | iounmap(drv_data->reg_base); | 489 | iounmap(drv_data->reg_base); |
486 | release_mem_region(drv_data->reg_base_p, | 490 | release_mem_region(drv_data->reg_base_p, drv_data->reg_size); |
487 | MV64XXX_I2C_REG_BLOCK_SIZE); | ||
488 | } | 491 | } |
489 | 492 | ||
490 | drv_data->reg_base = NULL; | 493 | drv_data->reg_base = NULL; |
diff --git a/include/linux/mv643xx.h b/include/linux/mv643xx.h index d2ae6185f03b..69327b7b4ce4 100644 --- a/include/linux/mv643xx.h +++ b/include/linux/mv643xx.h | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #include <asm/types.h> | 16 | #include <asm/types.h> |
17 | #include <linux/mv643xx_eth.h> | 17 | #include <linux/mv643xx_eth.h> |
18 | #include <linux/mv643xx_i2c.h> | ||
18 | 19 | ||
19 | /****************************************/ | 20 | /****************************************/ |
20 | /* Processor Address Space */ | 21 | /* Processor Address Space */ |
@@ -863,7 +864,6 @@ | |||
863 | /* I2C Registers */ | 864 | /* I2C Registers */ |
864 | /****************************************/ | 865 | /****************************************/ |
865 | 866 | ||
866 | #define MV64XXX_I2C_CTLR_NAME "mv64xxx_i2c" | ||
867 | #define MV64XXX_I2C_OFFSET 0xc000 | 867 | #define MV64XXX_I2C_OFFSET 0xc000 |
868 | #define MV64XXX_I2C_REG_BLOCK_SIZE 0x0020 | 868 | #define MV64XXX_I2C_REG_BLOCK_SIZE 0x0020 |
869 | 869 | ||
@@ -968,14 +968,6 @@ struct mpsc_pdata { | |||
968 | u32 brg_clk_freq; | 968 | u32 brg_clk_freq; |
969 | }; | 969 | }; |
970 | 970 | ||
971 | /* i2c Platform Device, Driver Data */ | ||
972 | struct mv64xxx_i2c_pdata { | ||
973 | u32 freq_m; | ||
974 | u32 freq_n; | ||
975 | u32 timeout; /* In milliseconds */ | ||
976 | u32 retries; | ||
977 | }; | ||
978 | |||
979 | /* Watchdog Platform Device, Driver Data */ | 971 | /* Watchdog Platform Device, Driver Data */ |
980 | #define MV64x60_WDT_NAME "mv64x60_wdt" | 972 | #define MV64x60_WDT_NAME "mv64x60_wdt" |
981 | 973 | ||
diff --git a/include/linux/mv643xx_i2c.h b/include/linux/mv643xx_i2c.h new file mode 100644 index 000000000000..adb629b15477 --- /dev/null +++ b/include/linux/mv643xx_i2c.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or modify it | ||
3 | * under the terms of the GNU General Public License as published by the | ||
4 | * Free Software Foundation; either version 2 of the License, or (at your | ||
5 | * option) any later version. | ||
6 | */ | ||
7 | |||
8 | #ifndef _MV64XXX_I2C_H_ | ||
9 | #define _MV64XXX_I2C_H_ | ||
10 | |||
11 | #include <linux/types.h> | ||
12 | |||
13 | #define MV64XXX_I2C_CTLR_NAME "mv64xxx_i2c" | ||
14 | |||
15 | /* i2c Platform Device, Driver Data */ | ||
16 | struct mv64xxx_i2c_pdata { | ||
17 | u32 freq_m; | ||
18 | u32 freq_n; | ||
19 | u32 timeout; /* In milliseconds */ | ||
20 | u32 retries; | ||
21 | }; | ||
22 | |||
23 | #endif /*_MV64XXX_I2C_H_*/ | ||