All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: linux-arm-kernel@lists.arm.linux.org.uk
Cc: linux-omap@vger.kernel.org, Jarkko Nikula <jarkko.nikula@nokia.com>
Subject: [PATCH 4/7] ARM: OMAP: Add method to register additional I2C busses on the command line
Date: Wed, 04 Mar 2009 13:52:22 -0800	[thread overview]
Message-ID: <20090304215222.21101.72095.stgit@localhost> (raw)
In-Reply-To: <20090304214540.21101.72079.stgit@localhost>

From: Jarkko Nikula <jarkko.nikula@nokia.com>

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 <jarkko.nikula@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/i2c.c |   73 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 52 insertions(+), 21 deletions(-)

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);
 }


  parent reply	other threads:[~2009-03-04 21:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-04 21:47 [PATCH 0/7] Updates for common omap code for next merge window Tony Lindgren
2009-03-04 21:48 ` [PATCH 1/7] ARM: OMAP: Export dmtimer functions Tony Lindgren
2009-03-04 21:49 ` [PATCH 2/7] ARM: OMAP: Add documentation for function omap_register_i2c_bus Tony Lindgren
2009-03-04 21:51 ` [PATCH 3/7] ARM: OMAP: Add command line option for I2C bus speed Tony Lindgren
2009-03-05 16:20   ` Tony Lindgren
2009-03-05 19:37     ` Felipe Balbi
2009-03-06  7:13     ` Jarkko Nikula
2009-03-06 16:13       ` Tony Lindgren
     [not found]         ` <20090306161349.GC32353-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2009-03-10  8:47           ` [2.6.29-rc7][take #2][PATCH 0/3] " Jarkko Nikula
     [not found]             ` <1236674831-3637-1-git-send-email-jarkko.nikula-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2009-03-10  8:47               ` [2.6.29-rc7][take #2][PATCH 1/3] ARM: OMAP: Add documentation for function omap_register_i2c_bus Jarkko Nikula
2009-03-10  8:47                 ` [2.6.29-rc7][take #2][PATCH 2/3] ARM: OMAP: Add command line option for I2C bus speed Jarkko Nikula
     [not found]                   ` <1236674831-3637-3-git-send-email-jarkko.nikula-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2009-03-10  8:47                     ` [2.6.29-rc7][take #2][PATCH 3/3] ARM: OMAP: Add method to register additional I2C busses on the command line Jarkko Nikula
2009-03-16 17:29                     ` [2.6.29-rc7][take #2][PATCH 2/3] ARM: OMAP: Add command line option for I2C bus speed Tony Lindgren
     [not found]                       ` <20090316172908.GA19229-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2009-03-17  8:24                         ` Jarkko Nikula
2009-03-18 19:30         ` [PATCH 3/7] " Russell King - ARM Linux
2009-03-19 11:22           ` Jarkko Nikula
2009-03-04 21:52 ` Tony Lindgren [this message]
2009-03-04 21:53 ` [PATCH 5/7] ARM: OMAP: Get available DMA channels from cmdline Tony Lindgren
2009-03-04 21:54 ` [PATCH 6/7] ARM: OMAP: Dispatch only relevant DMA interrupts Tony Lindgren
2009-03-04 21:56 ` [PATCH 7/7] ARM: OMAP: get rid of OMAP_TAG_USB Tony Lindgren
2009-03-11 16:31   ` [PATCH 7/7] ARM: OMAP: get rid of OMAP_TAG_USB, v2 Tony Lindgren
2009-03-16 17:31 ` [PATCH 0/7] Updates for common omap code for next merge window Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090304215222.21101.72095.stgit@localhost \
    --to=tony@atomide.com \
    --cc=jarkko.nikula@nokia.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-omap@vger.kernel.org \
    --subject='Re: [PATCH 4/7] ARM: OMAP: Add method to register additional I2C busses on the command line' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.