aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2012-10-08 12:11:22 -0400
committerTony Lindgren <tony@atomide.com>2012-10-17 14:36:50 -0400
commit3a8761c0272c961c707e5af2eb0179adf3ef7e14 (patch)
tree101b61bd1bc57de37c52587ecaff1da4e84d7742
parent8599e7c58786e3aef0bdb0fa093fd5150ae8a9bc (diff)
ARM: OMAP: Split plat-omap/i2c.c into mach-omap1 and mach-omap2
There's no need to keep the device related things in the common i2c.c as omap2+ is using hwmod. Split the code to mach-omap1 and mach-omap2 parts and only leave common code to plat-omap/i2c.c. Note that as omap1 only has one i2c controller, we can now remove the old device related macros. Reviewed-by: Shubhrajyoti D <shubhrajyoti@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--arch/arm/mach-omap1/common.h3
-rw-r--r--arch/arm/mach-omap1/i2c.c59
-rw-r--r--arch/arm/mach-omap2/board-rm680.c1
-rw-r--r--arch/arm/mach-omap2/common.h4
-rw-r--r--arch/arm/mach-omap2/i2c.c50
-rw-r--r--arch/arm/mach-omap2/i2c.h (renamed from arch/arm/plat-omap/include/plat/i2c.h)25
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2420_data.c5
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2430_data.c5
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_33xx_data.c4
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c4
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c3
-rw-r--r--arch/arm/mach-omap2/twl-common.c1
-rw-r--r--arch/arm/plat-omap/i2c.c133
-rw-r--r--arch/arm/plat-omap/i2c.h47
-rw-r--r--arch/arm/plat-omap/include/plat/common.h1
15 files changed, 182 insertions, 163 deletions
diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
index a65f50aeda6b..c96c1320b001 100644
--- a/arch/arm/mach-omap1/common.h
+++ b/arch/arm/mach-omap1/common.h
@@ -28,6 +28,9 @@
28 28
29#include <plat/common.h> 29#include <plat/common.h>
30#include <linux/mtd/mtd.h> 30#include <linux/mtd/mtd.h>
31#include <linux/i2c-omap.h>
32
33#include "../plat-omap/i2c.h"
31 34
32#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850) 35#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
33void omap7xx_map_io(void); 36void omap7xx_map_io(void);
diff --git a/arch/arm/mach-omap1/i2c.c b/arch/arm/mach-omap1/i2c.c
index a0551a6d7451..a6f465a44642 100644
--- a/arch/arm/mach-omap1/i2c.c
+++ b/arch/arm/mach-omap1/i2c.c
@@ -19,11 +19,25 @@
19 * 19 *
20 */ 20 */
21 21
22#include <plat/i2c.h> 22#include <linux/i2c-omap.h>
23#include <mach/mux.h> 23#include <mach/mux.h>
24#include <plat/cpu.h> 24#include <plat/cpu.h>
25 25
26void __init omap1_i2c_mux_pins(int bus_id) 26#include "../plat-omap/i2c.h"
27
28#define OMAP_I2C_SIZE 0x3f
29#define OMAP1_I2C_BASE 0xfffb3800
30#define OMAP1_INT_I2C (32 + 4)
31
32static const char name[] = "omap_i2c";
33
34static struct resource i2c_resources[2] = {
35};
36
37static struct platform_device omap_i2c_devices[1] = {
38};
39
40static void __init omap1_i2c_mux_pins(int bus_id)
27{ 41{
28 if (cpu_is_omap7xx()) { 42 if (cpu_is_omap7xx()) {
29 omap_cfg_reg(I2C_7XX_SDA); 43 omap_cfg_reg(I2C_7XX_SDA);
@@ -33,3 +47,44 @@ void __init omap1_i2c_mux_pins(int bus_id)
33 omap_cfg_reg(I2C_SCL); 47 omap_cfg_reg(I2C_SCL);
34 } 48 }
35} 49}
50
51int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *pdata,
52 int bus_id)
53{
54 struct platform_device *pdev;
55 struct resource *res;
56
57 omap1_i2c_mux_pins(bus_id);
58
59 pdev = &omap_i2c_devices[bus_id - 1];
60 pdev->id = bus_id;
61 pdev->name = name;
62 pdev->num_resources = ARRAY_SIZE(i2c_resources);
63 res = i2c_resources;
64 res[0].start = OMAP1_I2C_BASE;
65 res[0].end = res[0].start + OMAP_I2C_SIZE;
66 res[0].flags = IORESOURCE_MEM;
67 res[1].start = OMAP1_INT_I2C;
68 res[1].flags = IORESOURCE_IRQ;
69 pdev->resource = res;
70
71 /* all OMAP1 have IP version 1 register set */
72 pdata->rev = OMAP_I2C_IP_VERSION_1;
73
74 /* all OMAP1 I2C are implemented like this */
75 pdata->flags = OMAP_I2C_FLAG_NO_FIFO |
76 OMAP_I2C_FLAG_SIMPLE_CLOCK |
77 OMAP_I2C_FLAG_16BIT_DATA_REG |
78 OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK;
79
80 /* how the cpu bus is wired up differs for 7xx only */
81
82 if (cpu_is_omap7xx())
83 pdata->flags |= OMAP_I2C_FLAG_BUS_SHIFT_1;
84 else
85 pdata->flags |= OMAP_I2C_FLAG_BUS_SHIFT_2;
86
87 pdev->dev.platform_data = pdata;
88
89 return platform_device_register(pdev);
90}
diff --git a/arch/arm/mach-omap2/board-rm680.c b/arch/arm/mach-omap2/board-rm680.c
index 208a7a239db5..d42ecfe56096 100644
--- a/arch/arm/mach-omap2/board-rm680.c
+++ b/arch/arm/mach-omap2/board-rm680.c
@@ -22,7 +22,6 @@
22#include <asm/mach/arch.h> 22#include <asm/mach/arch.h>
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24 24
25#include <plat/i2c.h>
26#include <plat/usb.h> 25#include <plat/usb.h>
27#include "gpmc.h" 26#include "gpmc.h"
28#include "common.h" 27#include "common.h"
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 7045e4d61ac3..a68b421b3f86 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -28,7 +28,9 @@
28 28
29#include <linux/irq.h> 29#include <linux/irq.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/i2c.h>
31#include <linux/i2c/twl.h> 32#include <linux/i2c/twl.h>
33#include <linux/i2c-omap.h>
32 34
33#include <asm/proc-fns.h> 35#include <asm/proc-fns.h>
34 36
@@ -36,6 +38,8 @@
36#include <plat/serial.h> 38#include <plat/serial.h>
37#include <plat/common.h> 39#include <plat/common.h>
38 40
41#include "i2c.h"
42
39#define OMAP_INTC_START NR_IRQS 43#define OMAP_INTC_START NR_IRQS
40 44
41#ifdef CONFIG_SOC_OMAP2420 45#ifdef CONFIG_SOC_OMAP2420
diff --git a/arch/arm/mach-omap2/i2c.c b/arch/arm/mach-omap2/i2c.c
index fc57e67b321f..9f12f63ec54d 100644
--- a/arch/arm/mach-omap2/i2c.c
+++ b/arch/arm/mach-omap2/i2c.c
@@ -19,11 +19,12 @@
19 * 19 *
20 */ 20 */
21 21
22#include <plat/i2c.h>
23#include "common.h" 22#include "common.h"
24#include <plat/omap_hwmod.h> 23#include <plat/omap_hwmod.h>
24#include <plat/omap_device.h>
25 25
26#include "mux.h" 26#include "mux.h"
27#include "i2c.h"
27 28
28/* In register I2C_CON, Bit 15 is the I2C enable bit */ 29/* In register I2C_CON, Bit 15 is the I2C enable bit */
29#define I2C_EN BIT(15) 30#define I2C_EN BIT(15)
@@ -33,7 +34,9 @@
33/* Maximum microseconds to wait for OMAP module to softreset */ 34/* Maximum microseconds to wait for OMAP module to softreset */
34#define MAX_MODULE_SOFTRESET_WAIT 10000 35#define MAX_MODULE_SOFTRESET_WAIT 10000
35 36
36void __init omap2_i2c_mux_pins(int bus_id) 37#define MAX_OMAP_I2C_HWMOD_NAME_LEN 16
38
39static void __init omap2_i2c_mux_pins(int bus_id)
37{ 40{
38 char mux_name[sizeof("i2c2_scl.i2c2_scl")]; 41 char mux_name[sizeof("i2c2_scl.i2c2_scl")];
39 42
@@ -104,3 +107,46 @@ int omap_i2c_reset(struct omap_hwmod *oh)
104 107
105 return 0; 108 return 0;
106} 109}
110
111static const char name[] = "omap_i2c";
112
113int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata,
114 int bus_id)
115{
116 int l;
117 struct omap_hwmod *oh;
118 struct platform_device *pdev;
119 char oh_name[MAX_OMAP_I2C_HWMOD_NAME_LEN];
120 struct omap_i2c_bus_platform_data *pdata;
121 struct omap_i2c_dev_attr *dev_attr;
122
123 omap2_i2c_mux_pins(bus_id);
124
125 l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id);
126 WARN(l >= MAX_OMAP_I2C_HWMOD_NAME_LEN,
127 "String buffer overflow in I2C%d device setup\n", bus_id);
128 oh = omap_hwmod_lookup(oh_name);
129 if (!oh) {
130 pr_err("Could not look up %s\n", oh_name);
131 return -EEXIST;
132 }
133
134 pdata = i2c_pdata;
135 /*
136 * pass the hwmod class's CPU-specific knowledge of I2C IP revision in
137 * use, and functionality implementation flags, up to the OMAP I2C
138 * driver via platform data
139 */
140 pdata->rev = oh->class->rev;
141
142 dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr;
143 pdata->flags = dev_attr->flags;
144
145 pdev = omap_device_build(name, bus_id, oh, pdata,
146 sizeof(struct omap_i2c_bus_platform_data),
147 NULL, 0, 0);
148 WARN(IS_ERR(pdev), "Could not build omap_device for %s\n", name);
149
150 return PTR_RET(pdev);
151}
152
diff --git a/arch/arm/plat-omap/include/plat/i2c.h b/arch/arm/mach-omap2/i2c.h
index 7c22b9e10dc3..81dbb992a6bc 100644
--- a/arch/arm/plat-omap/include/plat/i2c.h
+++ b/arch/arm/mach-omap2/i2c.h
@@ -18,24 +18,11 @@
18 * 02110-1301 USA 18 * 02110-1301 USA
19 * 19 *
20 */ 20 */
21#ifndef __ASM__ARCH_OMAP_I2C_H
22#define __ASM__ARCH_OMAP_I2C_H
23 21
24#include <linux/i2c.h> 22#include "../plat-omap/i2c.h"
25#include <linux/i2c-omap.h>
26 23
27#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE) 24#ifndef __MACH_OMAP2_I2C_H
28extern int omap_register_i2c_bus(int bus_id, u32 clkrate, 25#define __MACH_OMAP2_I2C_H
29 struct i2c_board_info const *info,
30 unsigned len);
31#else
32static inline int omap_register_i2c_bus(int bus_id, u32 clkrate,
33 struct i2c_board_info const *info,
34 unsigned len)
35{
36 return 0;
37}
38#endif
39 26
40/** 27/**
41 * i2c_dev_attr - OMAP I2C controller device attributes for omap_hwmod 28 * i2c_dev_attr - OMAP I2C controller device attributes for omap_hwmod
@@ -50,10 +37,6 @@ struct omap_i2c_dev_attr {
50 u32 flags; 37 u32 flags;
51}; 38};
52 39
53void __init omap1_i2c_mux_pins(int bus_id);
54void __init omap2_i2c_mux_pins(int bus_id);
55
56struct omap_hwmod;
57int omap_i2c_reset(struct omap_hwmod *oh); 40int omap_i2c_reset(struct omap_hwmod *oh);
58 41
59#endif /* __ASM__ARCH_OMAP_I2C_H */ 42#endif /* __MACH_OMAP2_I2C_H */
diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index 80bbbee57649..95a0053b6ae1 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -12,12 +12,12 @@
12 * XXX handle crossbar/shared link difference for L3? 12 * XXX handle crossbar/shared link difference for L3?
13 * XXX these should be marked initdata for multi-OMAP kernels 13 * XXX these should be marked initdata for multi-OMAP kernels
14 */ 14 */
15
16#include <linux/i2c-omap.h>
15#include <linux/platform_data/spi-omap2-mcspi.h> 17#include <linux/platform_data/spi-omap2-mcspi.h>
16 18
17#include <plat/omap_hwmod.h> 19#include <plat/omap_hwmod.h>
18#include <plat-omap/dma-omap.h> 20#include <plat-omap/dma-omap.h>
19#include <plat/serial.h>
20#include <plat/i2c.h>
21#include <plat/dmtimer.h> 21#include <plat/dmtimer.h>
22#include "l3_2xxx.h" 22#include "l3_2xxx.h"
23#include "l4_2xxx.h" 23#include "l4_2xxx.h"
@@ -26,6 +26,7 @@
26 26
27#include "cm-regbits-24xx.h" 27#include "cm-regbits-24xx.h"
28#include "prm-regbits-24xx.h" 28#include "prm-regbits-24xx.h"
29#include "i2c.h"
29#include "mmc.h" 30#include "mmc.h"
30#include "wd_timer.h" 31#include "wd_timer.h"
31 32
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index dff04f948a2f..a6c24aea28b6 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -12,13 +12,13 @@
12 * XXX handle crossbar/shared link difference for L3? 12 * XXX handle crossbar/shared link difference for L3?
13 * XXX these should be marked initdata for multi-OMAP kernels 13 * XXX these should be marked initdata for multi-OMAP kernels
14 */ 14 */
15
16#include <linux/i2c-omap.h>
15#include <linux/platform_data/asoc-ti-mcbsp.h> 17#include <linux/platform_data/asoc-ti-mcbsp.h>
16#include <linux/platform_data/spi-omap2-mcspi.h> 18#include <linux/platform_data/spi-omap2-mcspi.h>
17 19
18#include <plat/omap_hwmod.h> 20#include <plat/omap_hwmod.h>
19#include <plat-omap/dma-omap.h> 21#include <plat-omap/dma-omap.h>
20#include <plat/serial.h>
21#include <plat/i2c.h>
22#include <plat/dmtimer.h> 22#include <plat/dmtimer.h>
23#include "mmc.h" 23#include "mmc.h"
24#include "l3_2xxx.h" 24#include "l3_2xxx.h"
@@ -27,6 +27,7 @@
27#include "omap_hwmod_common_data.h" 27#include "omap_hwmod_common_data.h"
28#include "prm-regbits-24xx.h" 28#include "prm-regbits-24xx.h"
29#include "cm-regbits-24xx.h" 29#include "cm-regbits-24xx.h"
30#include "i2c.h"
30#include "wd_timer.h" 31#include "wd_timer.h"
31 32
32/* 33/*
diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
index 44a661882a7e..cb7c393c08de 100644
--- a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
@@ -14,11 +14,12 @@
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 */ 15 */
16 16
17#include <linux/i2c-omap.h>
18
17#include <plat/omap_hwmod.h> 19#include <plat/omap_hwmod.h>
18#include <plat/cpu.h> 20#include <plat/cpu.h>
19#include <linux/platform_data/gpio-omap.h> 21#include <linux/platform_data/gpio-omap.h>
20#include <linux/platform_data/spi-omap2-mcspi.h> 22#include <linux/platform_data/spi-omap2-mcspi.h>
21#include <plat/i2c.h>
22 23
23#include "omap_hwmod_common_data.h" 24#include "omap_hwmod_common_data.h"
24 25
@@ -26,6 +27,7 @@
26#include "cm33xx.h" 27#include "cm33xx.h"
27#include "prm33xx.h" 28#include "prm33xx.h"
28#include "prm-regbits-33xx.h" 29#include "prm-regbits-33xx.h"
30#include "i2c.h"
29#include "mmc.h" 31#include "mmc.h"
30 32
31/* 33/*
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 2aaf3ce80626..14451217dac2 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -14,6 +14,8 @@
14 * 14 *
15 * XXX these should be marked initdata for multi-OMAP kernels 15 * XXX these should be marked initdata for multi-OMAP kernels
16 */ 16 */
17
18#include <linux/i2c-omap.h>
17#include <linux/power/smartreflex.h> 19#include <linux/power/smartreflex.h>
18#include <linux/platform_data/gpio-omap.h> 20#include <linux/platform_data/gpio-omap.h>
19 21
@@ -22,7 +24,6 @@
22#include <plat/serial.h> 24#include <plat/serial.h>
23#include "l3_3xxx.h" 25#include "l3_3xxx.h"
24#include "l4_3xxx.h" 26#include "l4_3xxx.h"
25#include <plat/i2c.h>
26#include <linux/platform_data/asoc-ti-mcbsp.h> 27#include <linux/platform_data/asoc-ti-mcbsp.h>
27#include <linux/platform_data/spi-omap2-mcspi.h> 28#include <linux/platform_data/spi-omap2-mcspi.h>
28#include <plat/dmtimer.h> 29#include <plat/dmtimer.h>
@@ -36,6 +37,7 @@
36#include "cm-regbits-34xx.h" 37#include "cm-regbits-34xx.h"
37 38
38#include "dma.h" 39#include "dma.h"
40#include "i2c.h"
39#include "mmc.h" 41#include "mmc.h"
40#include "wd_timer.h" 42#include "wd_timer.h"
41 43
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index f47a57fa1f3a..2c736cd2bea1 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -21,9 +21,9 @@
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/platform_data/gpio-omap.h> 22#include <linux/platform_data/gpio-omap.h>
23#include <linux/power/smartreflex.h> 23#include <linux/power/smartreflex.h>
24#include <linux/i2c-omap.h>
24 25
25#include <plat/omap_hwmod.h> 26#include <plat/omap_hwmod.h>
26#include <plat/i2c.h>
27#include <plat-omap/dma-omap.h> 27#include <plat-omap/dma-omap.h>
28#include <linux/platform_data/spi-omap2-mcspi.h> 28#include <linux/platform_data/spi-omap2-mcspi.h>
29#include <linux/platform_data/asoc-ti-mcbsp.h> 29#include <linux/platform_data/asoc-ti-mcbsp.h>
@@ -36,6 +36,7 @@
36#include "cm2_44xx.h" 36#include "cm2_44xx.h"
37#include "prm44xx.h" 37#include "prm44xx.h"
38#include "prm-regbits-44xx.h" 38#include "prm-regbits-44xx.h"
39#include "i2c.h"
39#include "mmc.h" 40#include "mmc.h"
40#include "wd_timer.h" 41#include "wd_timer.h"
41 42
diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index 635e109f5ad3..1a0739d397f3 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -26,7 +26,6 @@
26#include <linux/regulator/machine.h> 26#include <linux/regulator/machine.h>
27#include <linux/regulator/fixed.h> 27#include <linux/regulator/fixed.h>
28 28
29#include <plat/i2c.h>
30#include <plat/usb.h> 29#include <plat/usb.h>
31 30
32#include "soc.h" 31#include "soc.h"
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index a5683a84c6ee..37597a6bbed2 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -26,52 +26,18 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-omap.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/err.h> 31#include <linux/err.h>
31#include <linux/clk.h> 32#include <linux/clk.h>
32 33
33#include <mach/irqs.h> 34#include <mach/irqs.h>
34#include <plat/i2c.h> 35#include <plat/cpu.h>
35#include <plat/omap_device.h>
36 36
37#define OMAP_I2C_SIZE 0x3f 37#include "i2c.h"
38#define OMAP1_I2C_BASE 0xfffb3800
39#define OMAP1_INT_I2C (32 + 4)
40 38
41static const char name[] = "omap_i2c";
42
43#define I2C_RESOURCE_BUILDER(base, irq) \
44 { \
45 .start = (base), \
46 .end = (base) + OMAP_I2C_SIZE, \
47 .flags = IORESOURCE_MEM, \
48 }, \
49 { \
50 .start = (irq), \
51 .flags = IORESOURCE_IRQ, \
52 },
53
54static struct resource i2c_resources[][2] = {
55 { I2C_RESOURCE_BUILDER(0, 0) },
56};
57
58#define I2C_DEV_BUILDER(bus_id, res, data) \
59 { \
60 .id = (bus_id), \
61 .name = name, \
62 .num_resources = ARRAY_SIZE(res), \
63 .resource = (res), \
64 .dev = { \
65 .platform_data = (data), \
66 }, \
67 }
68
69#define MAX_OMAP_I2C_HWMOD_NAME_LEN 16
70#define OMAP_I2C_MAX_CONTROLLERS 4 39#define OMAP_I2C_MAX_CONTROLLERS 4
71static struct omap_i2c_bus_platform_data i2c_pdata[OMAP_I2C_MAX_CONTROLLERS]; 40static struct omap_i2c_bus_platform_data i2c_pdata[OMAP_I2C_MAX_CONTROLLERS];
72static struct platform_device omap_i2c_devices[] = {
73 I2C_DEV_BUILDER(1, i2c_resources[0], &i2c_pdata[0]),
74};
75 41
76#define OMAP_I2C_CMDLINE_SETUP (BIT(31)) 42#define OMAP_I2C_CMDLINE_SETUP (BIT(31))
77 43
@@ -91,95 +57,6 @@ static int __init omap_i2c_nr_ports(void)
91 return ports; 57 return ports;
92} 58}
93 59
94static inline int omap1_i2c_add_bus(int bus_id)
95{
96 struct platform_device *pdev;
97 struct omap_i2c_bus_platform_data *pdata;
98 struct resource *res;
99
100 omap1_i2c_mux_pins(bus_id);
101
102 pdev = &omap_i2c_devices[bus_id - 1];
103 res = pdev->resource;
104 res[0].start = OMAP1_I2C_BASE;
105 res[0].end = res[0].start + OMAP_I2C_SIZE;
106 res[1].start = OMAP1_INT_I2C;
107 pdata = &i2c_pdata[bus_id - 1];
108
109 /* all OMAP1 have IP version 1 register set */
110 pdata->rev = OMAP_I2C_IP_VERSION_1;
111
112 /* all OMAP1 I2C are implemented like this */
113 pdata->flags = OMAP_I2C_FLAG_NO_FIFO |
114 OMAP_I2C_FLAG_SIMPLE_CLOCK |
115 OMAP_I2C_FLAG_16BIT_DATA_REG |
116 OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK;
117
118 /* how the cpu bus is wired up differs for 7xx only */
119
120 if (cpu_is_omap7xx())
121 pdata->flags |= OMAP_I2C_FLAG_BUS_SHIFT_1;
122 else
123 pdata->flags |= OMAP_I2C_FLAG_BUS_SHIFT_2;
124
125 return platform_device_register(pdev);
126}
127
128
129#ifdef CONFIG_ARCH_OMAP2PLUS
130static inline int omap2_i2c_add_bus(int bus_id)
131{
132 int l;
133 struct omap_hwmod *oh;
134 struct platform_device *pdev;
135 char oh_name[MAX_OMAP_I2C_HWMOD_NAME_LEN];
136 struct omap_i2c_bus_platform_data *pdata;
137 struct omap_i2c_dev_attr *dev_attr;
138
139 omap2_i2c_mux_pins(bus_id);
140
141 l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id);
142 WARN(l >= MAX_OMAP_I2C_HWMOD_NAME_LEN,
143 "String buffer overflow in I2C%d device setup\n", bus_id);
144 oh = omap_hwmod_lookup(oh_name);
145 if (!oh) {
146 pr_err("Could not look up %s\n", oh_name);
147 return -EEXIST;
148 }
149
150 pdata = &i2c_pdata[bus_id - 1];
151 /*
152 * pass the hwmod class's CPU-specific knowledge of I2C IP revision in
153 * use, and functionality implementation flags, up to the OMAP I2C
154 * driver via platform data
155 */
156 pdata->rev = oh->class->rev;
157
158 dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr;
159 pdata->flags = dev_attr->flags;
160
161 pdev = omap_device_build(name, bus_id, oh, pdata,
162 sizeof(struct omap_i2c_bus_platform_data),
163 NULL, 0, 0);
164 WARN(IS_ERR(pdev), "Could not build omap_device for %s\n", name);
165
166 return PTR_RET(pdev);
167}
168#else
169static inline int omap2_i2c_add_bus(int bus_id)
170{
171 return 0;
172}
173#endif
174
175static int __init omap_i2c_add_bus(int bus_id)
176{
177 if (cpu_class_is_omap1())
178 return omap1_i2c_add_bus(bus_id);
179 else
180 return omap2_i2c_add_bus(bus_id);
181}
182
183/** 60/**
184 * omap_i2c_bus_setup - Process command line options for the I2C bus speed 61 * omap_i2c_bus_setup - Process command line options for the I2C bus speed
185 * @str: String of options 62 * @str: String of options
@@ -218,7 +95,7 @@ static int __init omap_register_i2c_bus_cmdline(void)
218 for (i = 0; i < ARRAY_SIZE(i2c_pdata); i++) 95 for (i = 0; i < ARRAY_SIZE(i2c_pdata); i++)
219 if (i2c_pdata[i].clkrate & OMAP_I2C_CMDLINE_SETUP) { 96 if (i2c_pdata[i].clkrate & OMAP_I2C_CMDLINE_SETUP) {
220 i2c_pdata[i].clkrate &= ~OMAP_I2C_CMDLINE_SETUP; 97 i2c_pdata[i].clkrate &= ~OMAP_I2C_CMDLINE_SETUP;
221 err = omap_i2c_add_bus(i + 1); 98 err = omap_i2c_add_bus(&i2c_pdata[i], i + 1);
222 if (err) 99 if (err)
223 goto out; 100 goto out;
224 } 101 }
@@ -256,5 +133,5 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
256 133
257 i2c_pdata[bus_id - 1].clkrate &= ~OMAP_I2C_CMDLINE_SETUP; 134 i2c_pdata[bus_id - 1].clkrate &= ~OMAP_I2C_CMDLINE_SETUP;
258 135
259 return omap_i2c_add_bus(bus_id); 136 return omap_i2c_add_bus(&i2c_pdata[bus_id - 1], bus_id);
260} 137}
diff --git a/arch/arm/plat-omap/i2c.h b/arch/arm/plat-omap/i2c.h
new file mode 100644
index 000000000000..7a9028cb5a75
--- /dev/null
+++ b/arch/arm/plat-omap/i2c.h
@@ -0,0 +1,47 @@
1/*
2 * Helper module for board specific I2C bus registration
3 *
4 * Copyright (C) 2009 Nokia Corporation.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19 *
20 */
21
22#ifndef __PLAT_OMAP_I2C_H
23#define __PLAT_OMAP_I2C_H
24
25struct i2c_board_info;
26struct omap_i2c_bus_platform_data;
27
28int omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata,
29 int bus_id);
30
31#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
32extern int omap_register_i2c_bus(int bus_id, u32 clkrate,
33 struct i2c_board_info const *info,
34 unsigned len);
35#else
36static inline int omap_register_i2c_bus(int bus_id, u32 clkrate,
37 struct i2c_board_info const *info,
38 unsigned len)
39{
40 return 0;
41}
42#endif
43
44struct omap_hwmod;
45int omap_i2c_reset(struct omap_hwmod *oh);
46
47#endif /* __PLAT_OMAP_I2C_H */
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index d1cb6f527b7e..55c0f8bfc85b 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -27,7 +27,6 @@
27#ifndef __ARCH_ARM_MACH_OMAP_COMMON_H 27#ifndef __ARCH_ARM_MACH_OMAP_COMMON_H
28#define __ARCH_ARM_MACH_OMAP_COMMON_H 28#define __ARCH_ARM_MACH_OMAP_COMMON_H
29 29
30#include <plat/i2c.h>
31#include <plat/omap_hwmod.h> 30#include <plat/omap_hwmod.h>
32 31
33extern int __init omap_init_clocksource_32k(void __iomem *vbase); 32extern int __init omap_init_clocksource_32k(void __iomem *vbase);