aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-omap/i2c.c')
-rw-r--r--arch/arm/plat-omap/i2c.c54
1 files changed, 44 insertions, 10 deletions
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index 3e95954e2a87..aa70e435fa79 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -119,6 +119,46 @@ static void __init omap_i2c_mux_pins(int bus)
119 omap_cfg_reg(scl); 119 omap_cfg_reg(scl);
120} 120}
121 121
122static int __init omap_i2c_nr_ports(void)
123{
124 int ports = 0;
125
126 if (cpu_class_is_omap1())
127 ports = 1;
128 else if (cpu_is_omap24xx())
129 ports = 2;
130 else if (cpu_is_omap34xx())
131 ports = 3;
132
133 return ports;
134}
135
136/**
137 * omap_i2c_bus_setup - Process command line options for the I2C bus speed
138 * @str: String of options
139 *
140 * This function allow to override the default I2C bus speed for given I2C
141 * bus with a command line option.
142 *
143 * Format: i2c_bus=bus_id,clkrate (in kHz)
144 *
145 * Returns 1 on success, 0 otherwise.
146 */
147static int __init omap_i2c_bus_setup(char *str)
148{
149 int ports;
150 int ints[3];
151
152 ports = omap_i2c_nr_ports();
153 get_options(str, 3, ints);
154 if (ints[0] < 2 || ints[1] < 1 || ints[1] > ports)
155 return 0;
156 i2c_rate[ints[1] - 1] = ints[2];
157
158 return 1;
159}
160__setup("i2c_bus=", omap_i2c_bus_setup);
161
122/** 162/**
123 * omap_register_i2c_bus - register I2C bus with device descriptors 163 * omap_register_i2c_bus - register I2C bus with device descriptors
124 * @bus_id: bus id counting from number 1 164 * @bus_id: bus id counting from number 1
@@ -132,19 +172,12 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
132 struct i2c_board_info const *info, 172 struct i2c_board_info const *info,
133 unsigned len) 173 unsigned len)
134{ 174{
135 int ports, err; 175 int err;
136 struct platform_device *pdev; 176 struct platform_device *pdev;
137 struct resource *res; 177 struct resource *res;
138 resource_size_t base, irq; 178 resource_size_t base, irq;
139 179
140 if (cpu_class_is_omap1()) 180 BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports());
141 ports = 1;
142 else if (cpu_is_omap24xx())
143 ports = 2;
144 else if (cpu_is_omap34xx())
145 ports = 3;
146
147 BUG_ON(bus_id < 1 || bus_id > ports);
148 181
149 if (info) { 182 if (info) {
150 err = i2c_register_board_info(bus_id, info, len); 183 err = i2c_register_board_info(bus_id, info, len);
@@ -153,7 +186,8 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
153 } 186 }
154 187
155 pdev = &omap_i2c_devices[bus_id - 1]; 188 pdev = &omap_i2c_devices[bus_id - 1];
156 *(u32 *)pdev->dev.platform_data = clkrate; 189 if (i2c_rate[bus_id - 1] == 0)
190 i2c_rate[bus_id - 1] = clkrate;
157 191
158 if (bus_id == 1) { 192 if (bus_id == 1) {
159 res = pdev->resource; 193 res = pdev->resource;