diff options
Diffstat (limited to 'arch/arm/mach-omap2/i2c.c')
-rw-r--r-- | arch/arm/mach-omap2/i2c.c | 16 |
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) | |||
109 | return 0; | 109 | return 0; |
110 | } | 110 | } |
111 | 111 | ||
112 | static int __init omap_i2c_nr_ports(void) | ||
113 | { | ||
114 | int ports = 0; | ||
115 | |||
116 | if (cpu_is_omap24xx()) | ||
117 | ports = 2; | ||
118 | else if (cpu_is_omap34xx()) | ||
119 | ports = 3; | ||
120 | else if (cpu_is_omap44xx()) | ||
121 | ports = 4; | ||
122 | return ports; | ||
123 | } | ||
124 | |||
112 | static const char name[] = "omap_i2c"; | 125 | static const char name[] = "omap_i2c"; |
113 | 126 | ||
114 | int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata, | 127 | 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, | |||
121 | struct omap_i2c_bus_platform_data *pdata; | 134 | struct omap_i2c_bus_platform_data *pdata; |
122 | struct omap_i2c_dev_attr *dev_attr; | 135 | struct omap_i2c_dev_attr *dev_attr; |
123 | 136 | ||
137 | if (bus_id > omap_i2c_nr_ports()) | ||
138 | return -EINVAL; | ||
139 | |||
124 | omap2_i2c_mux_pins(bus_id); | 140 | omap2_i2c_mux_pins(bus_id); |
125 | 141 | ||
126 | l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id); | 142 | l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id); |