aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Nikula <jarkko.nikula@nokia.com>2009-03-23 21:07:47 -0400
committerTony Lindgren <tony@atomide.com>2009-03-23 21:51:20 -0400
commit3a853fb933ddf9c5ea8c9f7c665dd8def26bceae (patch)
tree7fea1d04ad338993c3109b68f224525332831766
parentd4c58bf45a9a1668cb850e02a2e1aad785bd9325 (diff)
ARM: OMAP: Add command line option for I2C bus speed, v2
This patch adds a new command line option "i2c_bus=bus_id,clkrate" into I2C bus registration helper. Purpose of the option is to override the default board specific bus speed which is supplied by the omap_register_i2c_bus. The default bus speed is typically set to speed of slowest I2C chip on the bus and overriding allow to use some experimental configurations or updated chip versions without any kernel modifications. Cc: linux-i2c@vger.kernel.org Signed-off-by: Jarkko Nikula <jarkko.nikula@nokia.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--Documentation/kernel-parameters.txt4
-rw-r--r--arch/arm/plat-omap/i2c.c54
2 files changed, 48 insertions, 10 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 54f21a5c262b..d775076d1563 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -830,6 +830,10 @@ and is between 256 and 4096 characters. It is defined in the file
830 hvc_iucv= [S390] Number of z/VM IUCV hypervisor console (HVC) 830 hvc_iucv= [S390] Number of z/VM IUCV hypervisor console (HVC)
831 terminal devices. Valid values: 0..8 831 terminal devices. Valid values: 0..8
832 832
833 i2c_bus= [HW] Override the default board specific I2C bus speed
834 Format:
835 <bus_id>,<clkrate>
836
833 i8042.debug [HW] Toggle i8042 debug mode 837 i8042.debug [HW] Toggle i8042 debug mode
834 i8042.direct [HW] Put keyboard port into non-translated mode 838 i8042.direct [HW] Put keyboard port into non-translated mode
835 i8042.dumbkbd [HW] Pretend that controller can only read data from 839 i8042.dumbkbd [HW] Pretend that controller can only read data from
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;