From patchwork Wed Mar 4 21:52:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 9932 X-Patchwork-Delegate: tony@atomide.com 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 n24LnqLZ031369 for ; Wed, 4 Mar 2009 21:52:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753096AbZCDVw0 (ORCPT ); Wed, 4 Mar 2009 16:52:26 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754490AbZCDVw0 (ORCPT ); Wed, 4 Mar 2009 16:52:26 -0500 Received: from mho-01-bos.mailhop.org ([63.208.196.178]:58050 "EHLO mho-01-bos.mailhop.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753096AbZCDVwZ (ORCPT ); Wed, 4 Mar 2009 16:52:25 -0500 Received: from c-69-181-40-92.hsd1.ca.comcast.net ([69.181.40.92] helo=[127.0.0.1]) by mho-01-bos.mailhop.org with esmtpa (Exim 4.68) (envelope-from ) id 1Lez0p-000Bdv-6k; Wed, 04 Mar 2009 21:52:23 +0000 X-Mail-Handler: MailHop Outbound by DynDNS X-Originating-IP: 69.181.40.92 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/mailhop/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1+9SZj/Armj894yhVI5Xrxd Subject: [PATCH 4/7] ARM: OMAP: Add method to register additional I2C busses on the command line To: linux-arm-kernel@lists.arm.linux.org.uk From: Tony Lindgren Cc: linux-omap@vger.kernel.org, Jarkko Nikula Date: Wed, 04 Mar 2009 13:52:22 -0800 Message-ID: <20090304215222.21101.72095.stgit@localhost> In-Reply-To: <20090304214540.21101.72079.stgit@localhost> References: <20090304214540.21101.72079.stgit@localhost> User-Agent: StGit/0.14.3.343.g0584 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Jarkko Nikula This patch extends command line option "i2c_bus=bus_id,clkrate" so that it allow to register additional I2C busses that are not registered with omap_register_i2c_bus from board initialization code. Purpose of this is to register additional board busses which are routed to external connectors only without any on board I2C devices. Signed-off-by: Jarkko Nikula Signed-off-by: Tony Lindgren --- arch/arm/plat-omap/i2c.c | 73 +++++++++++++++++++++++++++++++++------------- 1 files changed, 52 insertions(+), 21 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c index aa70e43..a303071 100644 --- a/arch/arm/plat-omap/i2c.c +++ b/arch/arm/plat-omap/i2c.c @@ -98,6 +98,8 @@ static const int omap34xx_pins[][2] = { static const int omap34xx_pins[][2] = {}; #endif +#define OMAP_I2C_CMDLINE_SETUP (BIT(31)) + static void __init omap_i2c_mux_pins(int bus) { int scl, sda; @@ -133,6 +135,31 @@ static int __init omap_i2c_nr_ports(void) return ports; } +static int __init omap_i2c_add_bus(int bus_id) +{ + struct platform_device *pdev; + struct resource *res; + resource_size_t base, irq; + + pdev = &omap_i2c_devices[bus_id - 1]; + if (bus_id == 1) { + res = pdev->resource; + if (cpu_class_is_omap1()) { + base = OMAP1_I2C_BASE; + irq = INT_I2C; + } else { + base = OMAP2_I2C_BASE1; + irq = INT_24XX_I2C1_IRQ; + } + res[0].start = base; + res[0].end = base + OMAP_I2C_SIZE; + res[1].start = irq; + } + + omap_i2c_mux_pins(bus_id - 1); + return platform_device_register(pdev); +} + /** * omap_i2c_bus_setup - Process command line options for the I2C bus speed * @str: String of options @@ -154,11 +181,33 @@ static int __init omap_i2c_bus_setup(char *str) if (ints[0] < 2 || ints[1] < 1 || ints[1] > ports) return 0; i2c_rate[ints[1] - 1] = ints[2]; + i2c_rate[ints[1] - 1] |= OMAP_I2C_CMDLINE_SETUP; return 1; } __setup("i2c_bus=", omap_i2c_bus_setup); +/* + * Register busses defined in command line but that are not registered with + * omap_register_i2c_bus from board initialization code. + */ +static int __init omap_register_i2c_bus_cmdline(void) +{ + int i, err = 0; + + for (i = 0; i < ARRAY_SIZE(i2c_rate); i++) + if (i2c_rate[i] & OMAP_I2C_CMDLINE_SETUP) { + i2c_rate[i] &= ~OMAP_I2C_CMDLINE_SETUP; + err = omap_i2c_add_bus(i + 1); + if (err) + goto out; + } + +out: + return err; +} +subsys_initcall(omap_register_i2c_bus_cmdline); + /** * omap_register_i2c_bus - register I2C bus with device descriptors * @bus_id: bus id counting from number 1 @@ -173,9 +222,6 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate, unsigned len) { int err; - struct platform_device *pdev; - struct resource *res; - resource_size_t base, irq; BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports()); @@ -185,24 +231,9 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate, return err; } - pdev = &omap_i2c_devices[bus_id - 1]; - if (i2c_rate[bus_id - 1] == 0) + if (!i2c_rate[bus_id - 1]) i2c_rate[bus_id - 1] = clkrate; + i2c_rate[bus_id - 1] &= ~OMAP_I2C_CMDLINE_SETUP; - if (bus_id == 1) { - res = pdev->resource; - if (cpu_class_is_omap1()) { - base = OMAP1_I2C_BASE; - irq = INT_I2C; - } else { - base = OMAP2_I2C_BASE1; - irq = INT_24XX_I2C1_IRQ; - } - res[0].start = base; - res[0].end = base + OMAP_I2C_SIZE; - res[1].start = irq; - } - - omap_i2c_mux_pins(bus_id - 1); - return platform_device_register(pdev); + return omap_i2c_add_bus(bus_id); }