[PATCH 2/2] ARM: OMAP: Add OMAP34xx pin muxing into I2C bus registration helper

2008-06-09 Thread Jarkko Nikula
Signed-off-by: Jarkko Nikula [EMAIL PROTECTED]
---
 arch/arm/plat-omap/i2c.c |   51 -
 1 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index 7990ab1..23c2920 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -80,26 +80,39 @@ static struct platform_device omap_i2c_devices[] = {
 #endif
 };
 
-static void __init omap_i2c_mux_pins(int bus_id)
+static const int omap1_pins[][2] = {
+   { I2C_SCL, I2C_SDA },
+};
+static const int omap24xx_pins[][2] = {
+   { M19_24XX_I2C1_SCL, L15_24XX_I2C1_SDA },
+   { J15_24XX_I2C2_SCL, H19_24XX_I2C2_SDA },
+};
+static const int omap34xx_pins[][2] = {
+   { K21_34XX_I2C1_SCL, J21_34XX_I2C1_SDA},
+   { AF15_34XX_I2C2_SCL, AE15_34XX_I2C2_SDA},
+   { AF14_34XX_I2C3_SCL, AG14_34XX_I2C3_SDA},
+   { AD26_34XX_I2C4_SCL, AE26_34XX_I2C4_SDA},
+};
+
+static void __init omap_i2c_mux_pins(int bus)
 {
-   /* TODO: Muxing for OMAP3 */
-   switch (bus_id) {
-   case 1:
-   if (cpu_class_is_omap1()) {
-   omap_cfg_reg(I2C_SCL);
-   omap_cfg_reg(I2C_SDA);
-   } else if (cpu_is_omap24xx()) {
-   omap_cfg_reg(M19_24XX_I2C1_SCL);
-   omap_cfg_reg(L15_24XX_I2C1_SDA);
-   }
-   break;
-   case 2:
-   if (cpu_is_omap24xx()) {
-   omap_cfg_reg(J15_24XX_I2C2_SCL);
-   omap_cfg_reg(H19_24XX_I2C2_SDA);
-   }
-   break;
+   int scl, sda;
+
+   if (cpu_class_is_omap1()) {
+   scl = omap1_pins[bus][0];
+   sda = omap1_pins[bus][1];
+   } else if (cpu_is_omap24xx()) {
+   scl = omap24xx_pins[bus][0];
+   sda = omap24xx_pins[bus][1];
+   } else if (cpu_is_omap34xx()) {
+   scl = omap34xx_pins[bus][0];
+   sda = omap34xx_pins[bus][1];
+   } else {
+   return;
}
+
+   omap_cfg_reg(sda);
+   omap_cfg_reg(scl);
 }
 
 int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
@@ -143,6 +156,6 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate,
res[1].start = irq;
}
 
-   omap_i2c_mux_pins(bus_id);
+   omap_i2c_mux_pins(bus_id - 1);
return platform_device_register(pdev);
 }
-- 
1.5.5.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] ARM: OMAP: Add OMAP34xx pin muxing into I2C bus registration helper

2008-06-09 Thread Jarkko Nikula
On Mon,  9 Jun 2008 17:46:41 +0300
Jarkko Nikula [EMAIL PROTECTED] wrote:

 Signed-off-by: Jarkko Nikula [EMAIL PROTECTED]
 ---
  arch/arm/plat-omap/i2c.c |   51 +++
 +- 1 files changed, 32 insertions(+), 19 deletions(-)
 
 -static void __init omap_i2c_mux_pins(int bus_id)
 +static const int omap1_pins[][2] = {
 + { I2C_SCL, I2C_SDA },
 +};
 +static const int omap24xx_pins[][2] = {
 + { M19_24XX_I2C1_SCL, L15_24XX_I2C1_SDA },
 + { J15_24XX_I2C2_SCL, H19_24XX_I2C2_SDA },
 +};
 +static const int omap34xx_pins[][2] = {
 + { K21_34XX_I2C1_SCL, J21_34XX_I2C1_SDA},
 + { AF15_34XX_I2C2_SCL, AE15_34XX_I2C2_SDA},
 + { AF14_34XX_I2C3_SCL, AG14_34XX_I2C3_SDA},
 + { AD26_34XX_I2C4_SCL, AE26_34XX_I2C4_SDA},
 +};
 +
NAK to myself. Avoiding few #ifdefs is not an excuse for spending some
bytes here and also it doesn't look good to add muxing support for bus
4 where the module itself doesn't support it (yet).

Lazy me :-)

Jarkko
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html