Commit 3a853fb9 authored by Jarkko Nikula's avatar Jarkko Nikula Committed by Tony Lindgren

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: default avatarJarkko Nikula <jarkko.nikula@nokia.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent d4c58bf4
...@@ -830,6 +830,10 @@ and is between 256 and 4096 characters. It is defined in the file ...@@ -830,6 +830,10 @@ and is between 256 and 4096 characters. It is defined in the file
hvc_iucv= [S390] Number of z/VM IUCV hypervisor console (HVC) hvc_iucv= [S390] Number of z/VM IUCV hypervisor console (HVC)
terminal devices. Valid values: 0..8 terminal devices. Valid values: 0..8
i2c_bus= [HW] Override the default board specific I2C bus speed
Format:
<bus_id>,<clkrate>
i8042.debug [HW] Toggle i8042 debug mode i8042.debug [HW] Toggle i8042 debug mode
i8042.direct [HW] Put keyboard port into non-translated mode i8042.direct [HW] Put keyboard port into non-translated mode
i8042.dumbkbd [HW] Pretend that controller can only read data from i8042.dumbkbd [HW] Pretend that controller can only read data from
......
...@@ -119,6 +119,46 @@ static void __init omap_i2c_mux_pins(int bus) ...@@ -119,6 +119,46 @@ static void __init omap_i2c_mux_pins(int bus)
omap_cfg_reg(scl); omap_cfg_reg(scl);
} }
static int __init omap_i2c_nr_ports(void)
{
int ports = 0;
if (cpu_class_is_omap1())
ports = 1;
else if (cpu_is_omap24xx())
ports = 2;
else if (cpu_is_omap34xx())
ports = 3;
return ports;
}
/**
* omap_i2c_bus_setup - Process command line options for the I2C bus speed
* @str: String of options
*
* This function allow to override the default I2C bus speed for given I2C
* bus with a command line option.
*
* Format: i2c_bus=bus_id,clkrate (in kHz)
*
* Returns 1 on success, 0 otherwise.
*/
static int __init omap_i2c_bus_setup(char *str)
{
int ports;
int ints[3];
ports = omap_i2c_nr_ports();
get_options(str, 3, ints);
if (ints[0] < 2 || ints[1] < 1 || ints[1] > ports)
return 0;
i2c_rate[ints[1] - 1] = ints[2];
return 1;
}
__setup("i2c_bus=", omap_i2c_bus_setup);
/** /**
* omap_register_i2c_bus - register I2C bus with device descriptors * omap_register_i2c_bus - register I2C bus with device descriptors
* @bus_id: bus id counting from number 1 * @bus_id: bus id counting from number 1
...@@ -132,19 +172,12 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate, ...@@ -132,19 +172,12 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
struct i2c_board_info const *info, struct i2c_board_info const *info,
unsigned len) unsigned len)
{ {
int ports, err; int err;
struct platform_device *pdev; struct platform_device *pdev;
struct resource *res; struct resource *res;
resource_size_t base, irq; resource_size_t base, irq;
if (cpu_class_is_omap1()) BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports());
ports = 1;
else if (cpu_is_omap24xx())
ports = 2;
else if (cpu_is_omap34xx())
ports = 3;
BUG_ON(bus_id < 1 || bus_id > ports);
if (info) { if (info) {
err = i2c_register_board_info(bus_id, info, len); 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,7 +186,8 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
} }
pdev = &omap_i2c_devices[bus_id - 1]; pdev = &omap_i2c_devices[bus_id - 1];
*(u32 *)pdev->dev.platform_data = clkrate; if (i2c_rate[bus_id - 1] == 0)
i2c_rate[bus_id - 1] = clkrate;
if (bus_id == 1) { if (bus_id == 1) {
res = pdev->resource; res = pdev->resource;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment