diff options
author | Tony Lindgren <tony@atomide.com> | 2009-12-11 19:16:32 -0500 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2009-12-11 19:16:32 -0500 |
commit | b63128e81214cc2db2995d690438055c26d213a5 (patch) | |
tree | 9b319655d1456fd9f2b8a1a25b7b70047e6fb0ad | |
parent | 4b715efccf9547c0d7fe864277526fee3d9b6bba (diff) |
omap: Split i2c platform init for mach-omap1 and mach-omap2
Otherwise we cannot limit new mux code to mach-omap2.
The same signal names should eventually work for other
omaps under mach-omap2.
Note that these pins don't need to be OMAP_PIN_INPUT_PULLUP,
just OMAP_PIN_INPUT is enough.
Cc: Jarkko Nikula <jhnikula@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r-- | arch/arm/mach-omap1/Makefile | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap1/i2c.c | 33 | ||||
-rw-r--r-- | arch/arm/mach-omap2/Makefile | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap2/i2c.c | 56 | ||||
-rw-r--r-- | arch/arm/plat-omap/i2c.c | 44 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/common.h | 14 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/i2c.h | 39 |
7 files changed, 137 insertions, 55 deletions
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile index ceced8ffe850..191e0cf6ee95 100644 --- a/arch/arm/mach-omap1/Makefile +++ b/arch/arm/mach-omap1/Makefile | |||
@@ -18,6 +18,9 @@ obj-$(CONFIG_PM) += pm.o sleep.o | |||
18 | obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o | 18 | obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o |
19 | mailbox_mach-objs := mailbox.o | 19 | mailbox_mach-objs := mailbox.o |
20 | 20 | ||
21 | i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o | ||
22 | obj-y += $(i2c-omap-m) $(i2c-omap-y) | ||
23 | |||
21 | led-y := leds.o | 24 | led-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 000000000000..bc9d12bc1c61 --- /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 | |||
25 | int __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 6e348e528f8d..e30e335dc2c3 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 | ||
65 | obj-$(CONFIG_OMAP_IOMMU) += $(iommu-y) | 65 | obj-$(CONFIG_OMAP_IOMMU) += $(iommu-y) |
66 | 66 | ||
67 | i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o | ||
68 | obj-y += $(i2c-omap-m) $(i2c-omap-y) | ||
69 | |||
67 | # Specific board support | 70 | # Specific board support |
68 | obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o | 71 | obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o |
69 | obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o | 72 | obj-$(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 000000000000..789ca8c02f0c --- /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 | |||
28 | int __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 c08362dbb8ed..33fff4ef382d 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) | ||
84 | static 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 | ||
89 | static const int omap24xx_pins[][2] = {}; | ||
90 | #endif | ||
91 | #if defined(CONFIG_ARCH_OMAP34XX) | ||
92 | static 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 | ||
98 | static 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 | ||
103 | static 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 | |||
124 | static int __init omap_i2c_nr_ports(void) | 85 | static 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: | |||
209 | subsys_initcall(omap_register_i2c_bus_cmdline); | 169 | subsys_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 | */ |
220 | int __init omap_register_i2c_bus(int bus_id, u32 clkrate, | 180 | int __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 2f816fe3ae86..32c22272425d 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 | ||
32 | struct sys_timer; | 32 | struct sys_timer; |
33 | 33 | ||
@@ -36,18 +36,6 @@ extern void __iomem *gic_cpu_base_addr; | |||
36 | 36 | ||
37 | extern void omap_map_common_io(void); | 37 | extern void omap_map_common_io(void); |
38 | extern struct sys_timer omap_timer; | 38 | extern struct sys_timer omap_timer; |
39 | #if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE) | ||
40 | extern int omap_register_i2c_bus(int bus_id, u32 clkrate, | ||
41 | struct i2c_board_info const *info, | ||
42 | unsigned len); | ||
43 | #else | ||
44 | static 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 */ |
53 | struct omap_globals { | 41 | struct 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 000000000000..585d9ca68b97 --- /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) | ||
25 | extern int omap_register_i2c_bus(int bus_id, u32 clkrate, | ||
26 | struct i2c_board_info const *info, | ||
27 | unsigned len); | ||
28 | #else | ||
29 | static 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 | |||
37 | int omap_plat_register_i2c_bus(int bus_id, u32 clkrate, | ||
38 | struct i2c_board_info const *info, | ||
39 | unsigned len); | ||