aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/i2c.c
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2012-10-29 16:17:59 -0700
committerTony Lindgren <tony@atomide.com>2012-10-31 15:37:13 -0700
commitc34f7c696211e3d45ff94a34824b65aa52576bc6 (patch)
tree81327c2b471e51e47171ed11e57c99eda552a0ef /arch/arm/mach-omap2/i2c.c
parentARM: OMAP: Move omap2+ specific parts of sram.c to mach-omap2 (diff)
downloadlinux-dev-c34f7c696211e3d45ff94a34824b65aa52576bc6.tar.xz
linux-dev-c34f7c696211e3d45ff94a34824b65aa52576bc6.zip
ARM: OMAP: Make plat-omap/i2c.c port checks local
The common code should not have any omap1 or omap2+ specific code, and should not need to call the cpu_is_omap macros. The only remaining user for cpu_is_omap macros is omap_i2c_nr_ports(). Let's make those checks in the omap specific implementation of omap_i2c_add_bus() instead in order to remove cpu_is_omap usage from the common code. Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/i2c.c')
-rw-r--r--arch/arm/mach-omap2/i2c.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/i2c.c b/arch/arm/mach-omap2/i2c.c
index ad55b943108f..4e63097e3cd8 100644
--- a/arch/arm/mach-omap2/i2c.c
+++ b/arch/arm/mach-omap2/i2c.c
@@ -109,6 +109,19 @@ int omap_i2c_reset(struct omap_hwmod *oh)
return 0;
}
+static int __init omap_i2c_nr_ports(void)
+{
+ int ports = 0;
+
+ if (cpu_is_omap24xx())
+ ports = 2;
+ else if (cpu_is_omap34xx())
+ ports = 3;
+ else if (cpu_is_omap44xx())
+ ports = 4;
+ return ports;
+}
+
static const char name[] = "omap_i2c";
int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata,
@@ -121,6 +134,9 @@ int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata,
struct omap_i2c_bus_platform_data *pdata;
struct omap_i2c_dev_attr *dev_attr;
+ if (bus_id > omap_i2c_nr_ports())
+ return -EINVAL;
+
omap2_i2c_mux_pins(bus_id);
l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id);