Re: [PATCH v4 1/4] i2c: introduce i2c-cbus-gpio driver

2012-11-19 Thread Wolfram Sang
On Sun, Nov 18, 2012 at 06:36:19PM +0200, Aaro Koskinen wrote:
> Add i2c driver to enable access to devices behind CBUS on Nokia Internet
> Tablets.
> 
> The patch also adds CBUS I2C configuration for N8x0 which is one of the
> users of this driver.
> 
> Cc: linux-...@vger.kernel.org
> Acked-by: Felipe Balbi 
> Acked-by: Tony Lindgren 
> Signed-off-by: Aaro Koskinen 

Applied to for-next, thanks!

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH v4 1/4] i2c: introduce i2c-cbus-gpio driver

2012-11-19 Thread Wolfram Sang
On Sun, Nov 18, 2012 at 06:36:19PM +0200, Aaro Koskinen wrote:
 Add i2c driver to enable access to devices behind CBUS on Nokia Internet
 Tablets.
 
 The patch also adds CBUS I2C configuration for N8x0 which is one of the
 users of this driver.
 
 Cc: linux-...@vger.kernel.org
 Acked-by: Felipe Balbi ba...@ti.com
 Acked-by: Tony Lindgren t...@atomide.com
 Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi

Applied to for-next, thanks!

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


[PATCH v4 1/4] i2c: introduce i2c-cbus-gpio driver

2012-11-18 Thread Aaro Koskinen
Add i2c driver to enable access to devices behind CBUS on Nokia Internet
Tablets.

The patch also adds CBUS I2C configuration for N8x0 which is one of the
users of this driver.

Cc: linux-...@vger.kernel.org
Acked-by: Felipe Balbi 
Acked-by: Tony Lindgren 
Signed-off-by: Aaro Koskinen 
Cc: Wolfram Sang 
---
 .../devicetree/bindings/i2c/i2c-cbus-gpio.txt  |   27 ++
 arch/arm/mach-omap2/board-n8x0.c   |   42 +++
 drivers/i2c/busses/Kconfig |   10 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-cbus-gpio.c |  300 
 include/linux/platform_data/i2c-cbus-gpio.h|   27 ++
 6 files changed, 407 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
 create mode 100644 drivers/i2c/busses/i2c-cbus-gpio.c
 create mode 100644 include/linux/platform_data/i2c-cbus-gpio.h

diff --git a/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt 
b/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
new file mode 100644
index 000..8ce9cd2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
@@ -0,0 +1,27 @@
+Device tree bindings for i2c-cbus-gpio driver
+
+Required properties:
+   - compatible = "i2c-cbus-gpio";
+   - gpios: clk, dat, sel
+   - #address-cells = <1>;
+   - #size-cells = <0>;
+
+Optional properties:
+   - child nodes conforming to i2c bus binding
+
+Example:
+
+i2c@0 {
+   compatible = "i2c-cbus-gpio";
+   gpios = < 66 0 /* clk */
+ 65 0 /* dat */
+ 64 0 /* sel */
+   >;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   retu-mfd: retu@1 {
+   compatible = "retu-mfd";
+   reg = <0x1>;
+   };
+};
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index d95f727..bbfd742 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -16,10 +16,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -39,6 +41,45 @@
 #define TUSB6010_GPIO_ENABLE   0
 #define TUSB6010_DMACHAN   0x3f
 
+#if defined(CONFIG_I2C_CBUS_GPIO) || defined(CONFIG_I2C_CBUS_GPIO_MODULE)
+static struct i2c_cbus_platform_data n8x0_cbus_data = {
+   .clk_gpio = 66,
+   .dat_gpio = 65,
+   .sel_gpio = 64,
+};
+
+static struct platform_device n8x0_cbus_device = {
+   .name   = "i2c-cbus-gpio",
+   .id = 3,
+   .dev= {
+   .platform_data = _cbus_data,
+   },
+};
+
+static struct i2c_board_info n8x0_i2c_board_info_3[] __initdata = {
+   {
+   I2C_BOARD_INFO("retu-mfd", 0x01),
+   },
+};
+
+static void __init n8x0_cbus_init(void)
+{
+   const int retu_irq_gpio = 108;
+
+   if (gpio_request_one(retu_irq_gpio, GPIOF_IN, "Retu IRQ"))
+   return;
+   irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
+   n8x0_i2c_board_info_3[0].irq = gpio_to_irq(retu_irq_gpio);
+   i2c_register_board_info(3, n8x0_i2c_board_info_3,
+   ARRAY_SIZE(n8x0_i2c_board_info_3));
+   platform_device_register(_cbus_device);
+}
+#else /* CONFIG_I2C_CBUS_GPIO */
+static void __init n8x0_cbus_init(void)
+{
+}
+#endif /* CONFIG_I2C_CBUS_GPIO */
+
 #if defined(CONFIG_USB_MUSB_TUSB6010) || 
defined(CONFIG_USB_MUSB_TUSB6010_MODULE)
 /*
  * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
@@ -677,6 +718,7 @@ static void __init n8x0_init_machine(void)
gpmc_onenand_init(board_onenand_data);
n8x0_mmc_init();
n8x0_usb_init();
+   n8x0_cbus_init();
 }
 
 MACHINE_START(NOKIA_N800, "Nokia N800")
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index e9df461..e949edf 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -337,6 +337,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
help
  The unit of the TWI clock is kHz.
 
+config I2C_CBUS_GPIO
+   tristate "CBUS I2C driver"
+   depends on GENERIC_GPIO
+   help
+ Support for CBUS access using I2C API. Mostly relevant for Nokia
+ Internet Tablets (770, N800 and N810).
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-cbus-gpio.
+
 config I2C_CPM
tristate "Freescale CPM1 or CPM2 (MPC8xx/826x)"
depends on (CPM1 || CPM2) && OF_I2C
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 395b516..f9e3e0b 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_I2C_POWERMAC)+= i2c-powermac.o
 obj-$(CONFIG_I2C_AT91) += i2c-at91.o
 obj-$(CONFIG_I2C_AU1550)   += i2c-au1550.o
 obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
+obj-$(CONFIG_I2C_CBUS_GPIO)+= i2c-cbus-gpio.o
 obj-$(CONFIG_I2C_CPM) 

[PATCH v4 1/4] i2c: introduce i2c-cbus-gpio driver

2012-11-18 Thread Aaro Koskinen
Add i2c driver to enable access to devices behind CBUS on Nokia Internet
Tablets.

The patch also adds CBUS I2C configuration for N8x0 which is one of the
users of this driver.

Cc: linux-...@vger.kernel.org
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
Cc: Wolfram Sang w.s...@pengutronix.de
---
 .../devicetree/bindings/i2c/i2c-cbus-gpio.txt  |   27 ++
 arch/arm/mach-omap2/board-n8x0.c   |   42 +++
 drivers/i2c/busses/Kconfig |   10 +
 drivers/i2c/busses/Makefile|1 +
 drivers/i2c/busses/i2c-cbus-gpio.c |  300 
 include/linux/platform_data/i2c-cbus-gpio.h|   27 ++
 6 files changed, 407 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
 create mode 100644 drivers/i2c/busses/i2c-cbus-gpio.c
 create mode 100644 include/linux/platform_data/i2c-cbus-gpio.h

diff --git a/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt 
b/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
new file mode 100644
index 000..8ce9cd2
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-cbus-gpio.txt
@@ -0,0 +1,27 @@
+Device tree bindings for i2c-cbus-gpio driver
+
+Required properties:
+   - compatible = i2c-cbus-gpio;
+   - gpios: clk, dat, sel
+   - #address-cells = 1;
+   - #size-cells = 0;
+
+Optional properties:
+   - child nodes conforming to i2c bus binding
+
+Example:
+
+i2c@0 {
+   compatible = i2c-cbus-gpio;
+   gpios = gpio 66 0 /* clk */
+gpio 65 0 /* dat */
+gpio 64 0 /* sel */
+   ;
+   #address-cells = 1;
+   #size-cells = 0;
+
+   retu-mfd: retu@1 {
+   compatible = retu-mfd;
+   reg = 0x1;
+   };
+};
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index d95f727..bbfd742 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -16,10 +16,12 @@
 #include linux/gpio.h
 #include linux/init.h
 #include linux/io.h
+#include linux/irq.h
 #include linux/stddef.h
 #include linux/i2c.h
 #include linux/spi/spi.h
 #include linux/usb/musb.h
+#include linux/platform_data/i2c-cbus-gpio.h
 #include linux/platform_data/spi-omap2-mcspi.h
 #include linux/platform_data/mtd-onenand-omap2.h
 #include sound/tlv320aic3x.h
@@ -39,6 +41,45 @@
 #define TUSB6010_GPIO_ENABLE   0
 #define TUSB6010_DMACHAN   0x3f
 
+#if defined(CONFIG_I2C_CBUS_GPIO) || defined(CONFIG_I2C_CBUS_GPIO_MODULE)
+static struct i2c_cbus_platform_data n8x0_cbus_data = {
+   .clk_gpio = 66,
+   .dat_gpio = 65,
+   .sel_gpio = 64,
+};
+
+static struct platform_device n8x0_cbus_device = {
+   .name   = i2c-cbus-gpio,
+   .id = 3,
+   .dev= {
+   .platform_data = n8x0_cbus_data,
+   },
+};
+
+static struct i2c_board_info n8x0_i2c_board_info_3[] __initdata = {
+   {
+   I2C_BOARD_INFO(retu-mfd, 0x01),
+   },
+};
+
+static void __init n8x0_cbus_init(void)
+{
+   const int retu_irq_gpio = 108;
+
+   if (gpio_request_one(retu_irq_gpio, GPIOF_IN, Retu IRQ))
+   return;
+   irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
+   n8x0_i2c_board_info_3[0].irq = gpio_to_irq(retu_irq_gpio);
+   i2c_register_board_info(3, n8x0_i2c_board_info_3,
+   ARRAY_SIZE(n8x0_i2c_board_info_3));
+   platform_device_register(n8x0_cbus_device);
+}
+#else /* CONFIG_I2C_CBUS_GPIO */
+static void __init n8x0_cbus_init(void)
+{
+}
+#endif /* CONFIG_I2C_CBUS_GPIO */
+
 #if defined(CONFIG_USB_MUSB_TUSB6010) || 
defined(CONFIG_USB_MUSB_TUSB6010_MODULE)
 /*
  * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
@@ -677,6 +718,7 @@ static void __init n8x0_init_machine(void)
gpmc_onenand_init(board_onenand_data);
n8x0_mmc_init();
n8x0_usb_init();
+   n8x0_cbus_init();
 }
 
 MACHINE_START(NOKIA_N800, Nokia N800)
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index e9df461..e949edf 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -337,6 +337,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
help
  The unit of the TWI clock is kHz.
 
+config I2C_CBUS_GPIO
+   tristate CBUS I2C driver
+   depends on GENERIC_GPIO
+   help
+ Support for CBUS access using I2C API. Mostly relevant for Nokia
+ Internet Tablets (770, N800 and N810).
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-cbus-gpio.
+
 config I2C_CPM
tristate Freescale CPM1 or CPM2 (MPC8xx/826x)
depends on (CPM1 || CPM2)  OF_I2C
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 395b516..f9e3e0b 100644
--- a/drivers/i2c/busses/Makefile
+++