aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap1/Makefile3
-rw-r--r--arch/arm/mach-omap1/i2c.c33
-rw-r--r--arch/arm/mach-omap2/Makefile3
-rw-r--r--arch/arm/mach-omap2/i2c.c56
-rw-r--r--arch/arm/plat-omap/i2c.c44
-rw-r--r--arch/arm/plat-omap/include/plat/common.h14
-rw-r--r--arch/arm/plat-omap/include/plat/i2c.h39
7 files changed, 137 insertions, 55 deletions
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index ceced8ffe85..191e0cf6ee9 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -18,6 +18,9 @@ obj-$(CONFIG_PM) += pm.o sleep.o
18obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o 18obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o
19mailbox_mach-objs := mailbox.o 19mailbox_mach-objs := mailbox.o
20 20
21i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o
22obj-y += $(i2c-omap-m) $(i2c-omap-y)
23
21led-y := leds.o 24led-y := leds.o
22 25
23# Specific board support 26# Specific board support
diff --git a/arch/arm/mach-omap1/i2c.c b/arch/arm/mach-omap1/i2c.c
new file mode 100644
index 00000000000..bc9d12bc1c6
--- /dev/null
+++ b/arch/arm/mach-omap1/i2c.c
@@ -0,0 +1,33 @@
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#include <plat/i2c.h>
23#include <plat/mux.h>
24
25int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
26 struct i2c_board_info const *info,
27 unsigned len)
28{
29 omap_cfg_reg(I2C_SDA);
30 omap_cfg_reg(I2C_SCL);
31
32 return omap_plat_register_i2c_bus(bus_id, clkrate, info, len);
33}
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 6e348e528f8..e30e335dc2c 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -64,6 +64,9 @@ iommu-$(CONFIG_ARCH_OMAP3) += omap3-iommu.o
64 64
65obj-$(CONFIG_OMAP_IOMMU) += $(iommu-y) 65obj-$(CONFIG_OMAP_IOMMU) += $(iommu-y)
66 66
67i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o
68obj-y += $(i2c-omap-m) $(i2c-omap-y)
69
67# Specific board support 70# Specific board support
68obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o 71obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o
69obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o 72obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o
diff --git a/arch/arm/mach-omap2/i2c.c b/arch/arm/mach-omap2/i2c.c
new file mode 100644
index 00000000000..789ca8c02f0
--- /dev/null
+++ b/arch/arm/mach-omap2/i2c.c
@@ -0,0 +1,56 @@
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#include <plat/cpu.h>
23#include <plat/i2c.h>
24#include <plat/mux.h>
25
26#include "mux.h"
27
28int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
29 struct i2c_board_info const *info,
30 unsigned len)
31{
32 if (cpu_is_omap24xx()) {
33 const int omap24xx_pins[][2] = {
34 { M19_24XX_I2C1_SCL, L15_24XX_I2C1_SDA },
35 { J15_24XX_I2C2_SCL, H19_24XX_I2C2_SDA },
36 };
37 int scl, sda;
38
39 scl = omap24xx_pins[bus_id - 1][0];
40 sda = omap24xx_pins[bus_id - 1][1];
41 omap_cfg_reg(sda);
42 omap_cfg_reg(scl);
43 }
44
45 /* First I2C bus is not muxable */
46 if (cpu_is_omap34xx() && bus_id > 1) {
47 char mux_name[sizeof("i2c2_scl.i2c2_scl")];
48
49 sprintf(mux_name, "i2c%i_scl.i2c%i_scl", bus_id, bus_id);
50 omap_mux_init_signal(mux_name, OMAP_PIN_INPUT);
51 sprintf(mux_name, "i2c%i_sda.i2c%i_sda", bus_id, bus_id);
52 omap_mux_init_signal(mux_name, OMAP_PIN_INPUT);
53 }
54
55 return omap_plat_register_i2c_bus(bus_id, clkrate, info, len);
56}
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index c08362dbb8e..33fff4ef382 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -80,47 +80,8 @@ static struct platform_device omap_i2c_devices[] = {
80#endif 80#endif
81}; 81};
82 82
83#if defined(CONFIG_ARCH_OMAP24XX)
84static const int omap24xx_pins[][2] = {
85 { M19_24XX_I2C1_SCL, L15_24XX_I2C1_SDA },
86 { J15_24XX_I2C2_SCL, H19_24XX_I2C2_SDA },
87};
88#else
89static const int omap24xx_pins[][2] = {};
90#endif
91#if defined(CONFIG_ARCH_OMAP34XX)
92static const int omap34xx_pins[][2] = {
93 { K21_34XX_I2C1_SCL, J21_34XX_I2C1_SDA},
94 { AF15_34XX_I2C2_SCL, AE15_34XX_I2C2_SDA},
95 { AF14_34XX_I2C3_SCL, AG14_34XX_I2C3_SDA},
96};
97#else
98static const int omap34xx_pins[][2] = {};
99#endif
100
101#define OMAP_I2C_CMDLINE_SETUP (BIT(31)) 83#define OMAP_I2C_CMDLINE_SETUP (BIT(31))
102 84
103static void __init omap_i2c_mux_pins(int bus)
104{
105 int scl, sda;
106
107 if (cpu_class_is_omap1()) {
108 scl = I2C_SCL;
109 sda = I2C_SDA;
110 } else if (cpu_is_omap24xx()) {
111 scl = omap24xx_pins[bus][0];
112 sda = omap24xx_pins[bus][1];
113 } else if (cpu_is_omap34xx()) {
114 scl = omap34xx_pins[bus][0];
115 sda = omap34xx_pins[bus][1];
116 } else {
117 return;
118 }
119
120 omap_cfg_reg(sda);
121 omap_cfg_reg(scl);
122}
123
124static int __init omap_i2c_nr_ports(void) 85static int __init omap_i2c_nr_ports(void)
125{ 86{
126 int ports = 0; 87 int ports = 0;
@@ -156,7 +117,6 @@ static int __init omap_i2c_add_bus(int bus_id)
156 res[1].start = irq; 117 res[1].start = irq;
157 } 118 }
158 119
159 omap_i2c_mux_pins(bus_id - 1);
160 return platform_device_register(pdev); 120 return platform_device_register(pdev);
161} 121}
162 122
@@ -209,7 +169,7 @@ out:
209subsys_initcall(omap_register_i2c_bus_cmdline); 169subsys_initcall(omap_register_i2c_bus_cmdline);
210 170
211/** 171/**
212 * omap_register_i2c_bus - register I2C bus with device descriptors 172 * omap_plat_register_i2c_bus - register I2C bus with device descriptors
213 * @bus_id: bus id counting from number 1 173 * @bus_id: bus id counting from number 1
214 * @clkrate: clock rate of the bus in kHz 174 * @clkrate: clock rate of the bus in kHz
215 * @info: pointer into I2C device descriptor table or NULL 175 * @info: pointer into I2C device descriptor table or NULL
@@ -217,7 +177,7 @@ subsys_initcall(omap_register_i2c_bus_cmdline);
217 * 177 *
218 * Returns 0 on success or an error code. 178 * Returns 0 on success or an error code.
219 */ 179 */
220int __init omap_register_i2c_bus(int bus_id, u32 clkrate, 180int __init omap_plat_register_i2c_bus(int bus_id, u32 clkrate,
221 struct i2c_board_info const *info, 181 struct i2c_board_info const *info,
222 unsigned len) 182 unsigned len)
223{ 183{
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index 2f816fe3ae8..32c22272425 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -27,7 +27,7 @@
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 <linux/i2c.h> 30#include <plat/i2c.h>
31 31
32struct sys_timer; 32struct sys_timer;
33 33
@@ -36,18 +36,6 @@ extern void __iomem *gic_cpu_base_addr;
36 36
37extern void omap_map_common_io(void); 37extern void omap_map_common_io(void);
38extern struct sys_timer omap_timer; 38extern struct sys_timer omap_timer;
39#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
40extern int omap_register_i2c_bus(int bus_id, u32 clkrate,
41 struct i2c_board_info const *info,
42 unsigned len);
43#else
44static inline int omap_register_i2c_bus(int bus_id, u32 clkrate,
45 struct i2c_board_info const *info,
46 unsigned len)
47{
48 return 0;
49}
50#endif
51 39
52/* IO bases for various OMAP processors */ 40/* IO bases for various OMAP processors */
53struct omap_globals { 41struct omap_globals {
diff --git a/arch/arm/plat-omap/include/plat/i2c.h b/arch/arm/plat-omap/include/plat/i2c.h
new file mode 100644
index 00000000000..585d9ca68b9
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/i2c.h
@@ -0,0 +1,39 @@
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#include <linux/i2c.h>
23
24#if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
25extern int omap_register_i2c_bus(int bus_id, u32 clkrate,
26 struct i2c_board_info const *info,
27 unsigned len);
28#else
29static inline int omap_register_i2c_bus(int bus_id, u32 clkrate,
30 struct i2c_board_info const *info,
31 unsigned len)
32{
33 return 0;
34}
35#endif
36
37int omap_plat_register_i2c_bus(int bus_id, u32 clkrate,
38 struct i2c_board_info const *info,
39 unsigned len);