From patchwork Tue Mar 10 08:47:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 10830 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2A8kwHB029535 for ; Tue, 10 Mar 2009 08:46:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753275AbZCJIq5 (ORCPT ); Tue, 10 Mar 2009 04:46:57 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753372AbZCJIq5 (ORCPT ); Tue, 10 Mar 2009 04:46:57 -0400 Received: from smtp.nokia.com ([192.100.122.233]:49007 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753280AbZCJIqz (ORCPT ); Tue, 10 Mar 2009 04:46:55 -0400 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx06.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id n2A8klVh023654; Tue, 10 Mar 2009 10:46:50 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 10 Mar 2009 10:46:46 +0200 Received: from mgw-int02.ntc.nokia.com ([172.21.143.97]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 10 Mar 2009 10:46:46 +0200 Received: from localhost.localdomain (esdhcp042162.research.nokia.com [172.21.42.162]) by mgw-int02.ntc.nokia.com (Switch-3.2.5/Switch-3.2.5) with ESMTP id n2A8kglB015252; Tue, 10 Mar 2009 10:46:45 +0200 From: Jarkko Nikula To: linux-omap@vger.kernel.org Cc: linux-i2c@vger.kernel.org, Jarkko Nikula Subject: [2.6.29-rc7][take #2][PATCH 2/3] ARM: OMAP: Add command line option for I2C bus speed Date: Tue, 10 Mar 2009 10:47:10 +0200 Message-Id: <1236674831-3637-3-git-send-email-jarkko.nikula@nokia.com> X-Mailer: git-send-email 1.6.1.3 In-Reply-To: <1236674831-3637-2-git-send-email-jarkko.nikula@nokia.com> References: <20090306161349.GC32353@atomide.com> <1236674831-3637-1-git-send-email-jarkko.nikula@nokia.com> <1236674831-3637-2-git-send-email-jarkko.nikula@nokia.com> X-OriginalArrivalTime: 10 Mar 2009 08:46:46.0633 (UTC) FILETIME=[BEC3B590:01C9A15C] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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. Signed-off-by: Jarkko Nikula --- Documentation/kernel-parameters.txt | 4 ++ arch/arm/plat-omap/i2c.c | 54 ++++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 54f21a5..d775076 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 hvc_iucv= [S390] Number of z/VM IUCV hypervisor console (HVC) terminal devices. Valid values: 0..8 + i2c_bus= [HW] Override the default board specific I2C bus speed + Format: + , + i8042.debug [HW] Toggle i8042 debug mode i8042.direct [HW] Put keyboard port into non-translated mode 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 3e95954..aa70e43 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) 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 * @bus_id: bus id counting from number 1 @@ -132,19 +172,12 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate, struct i2c_board_info const *info, unsigned len) { - int ports, err; + int err; struct platform_device *pdev; struct resource *res; resource_size_t base, irq; - if (cpu_class_is_omap1()) - ports = 1; - else if (cpu_is_omap24xx()) - ports = 2; - else if (cpu_is_omap34xx()) - ports = 3; - - BUG_ON(bus_id < 1 || bus_id > ports); + BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports()); if (info) { err = i2c_register_board_info(bus_id, info, len); @@ -153,7 +186,8 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate, } 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) { res = pdev->resource;