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

2012-11-06 Thread Tony Lindgren
* Aaro Koskinen aaro.koski...@iki.fi [121031 11:10]:
 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.

Added Wolfram Sang w.s...@pengutronix.de to cc so he
knows to pick this one if no more comments. You may need to
resend with him in cc.

Regards,

Tony
 
 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
 ---
  arch/arm/mach-omap2/board-n8x0.c |   42 ++
  drivers/i2c/busses/Kconfig   |   10 ++
  drivers/i2c/busses/Makefile  |1 +
  drivers/i2c/busses/i2c-cbus.c|  300 
 ++
  include/linux/i2c-cbus.h |   27 
  5 files changed, 380 insertions(+), 0 deletions(-)
  create mode 100644 drivers/i2c/busses/i2c-cbus.c
  create mode 100644 include/linux/i2c-cbus.h
 
 diff --git a/arch/arm/mach-omap2/board-n8x0.c 
 b/arch/arm/mach-omap2/board-n8x0.c
 index d95f727..7ea0348 100644
 --- a/arch/arm/mach-omap2/board-n8x0.c
 +++ b/arch/arm/mach-omap2/board-n8x0.c
 @@ -16,8 +16,10 @@
  #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/i2c-cbus.h
  #include linux/spi/spi.h
  #include linux/usb/musb.h
  #include linux/platform_data/spi-omap2-mcspi.h
 @@ -39,6 +41,45 @@
  #define TUSB6010_GPIO_ENABLE 0
  #define TUSB6010_DMACHAN 0x3f
  
 +#if defined(CONFIG_I2C_CBUS) || defined(CONFIG_I2C_CBUS_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,
 + .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 */
 +static void __init n8x0_cbus_init(void)
 +{
 +}
 +#endif /* CONFIG_I2C_CBUS */
 +
  #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 65dd599..d01c8ef 100644
 --- a/drivers/i2c/busses/Kconfig
 +++ b/drivers/i2c/busses/Kconfig
 @@ -338,6 +338,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
   help
 The unit of the TWI clock is kHz.
  
 +config I2C_CBUS
 + 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.
 +
  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 2d33d62..3c548b1 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)   += i2c-cbus.o
  obj-$(CONFIG_I2C_CPM)+= i2c-cpm.o
  obj-$(CONFIG_I2C_DAVINCI)+= i2c-davinci.o
  obj-$(CONFIG_I2C_DESIGNWARE_CORE)+= i2c-designware-core.o
 diff --git a/drivers/i2c/busses/i2c-cbus.c b/drivers/i2c/busses/i2c-cbus.c
 new file mode 100644
 index 000..1ea7667
 --- /dev/null
 +++ b/drivers/i2c/busses/i2c-cbus.c
 @@ -0,0 +1,300 @@
 +/*
 + * CBUS I2C driver for Nokia Internet Tablets.
 + *
 + * Copyright (C) 2004-2010 Nokia Corporation
 + *
 + * Based on code written by Juha Yrjölä, David Weinehall, Mikko Ylinen and
 + * Felipe Balbi. Converted to I2C driver by Aaro Koskinen.
 + *
 + * This file is subject to the terms and conditions of the GNU General
 + * Public License. See the file COPYING in the main 

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

2012-10-31 Thread Felipe Balbi
On Wed, Oct 31, 2012 at 08:03:43PM +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
 ---
  arch/arm/mach-omap2/board-n8x0.c |   42 ++
  drivers/i2c/busses/Kconfig   |   10 ++
  drivers/i2c/busses/Makefile  |1 +
  drivers/i2c/busses/i2c-cbus.c|  300 
 ++
  include/linux/i2c-cbus.h |   27 
  5 files changed, 380 insertions(+), 0 deletions(-)
  create mode 100644 drivers/i2c/busses/i2c-cbus.c
  create mode 100644 include/linux/i2c-cbus.h
 
 diff --git a/arch/arm/mach-omap2/board-n8x0.c 
 b/arch/arm/mach-omap2/board-n8x0.c
 index d95f727..7ea0348 100644
 --- a/arch/arm/mach-omap2/board-n8x0.c
 +++ b/arch/arm/mach-omap2/board-n8x0.c
 @@ -16,8 +16,10 @@
  #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/i2c-cbus.h
  #include linux/spi/spi.h
  #include linux/usb/musb.h
  #include linux/platform_data/spi-omap2-mcspi.h
 @@ -39,6 +41,45 @@
  #define TUSB6010_GPIO_ENABLE 0
  #define TUSB6010_DMACHAN 0x3f
  
 +#if defined(CONFIG_I2C_CBUS) || defined(CONFIG_I2C_CBUS_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,
 + .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 */
 +static void __init n8x0_cbus_init(void)
 +{
 +}
 +#endif /* CONFIG_I2C_CBUS */
 +
  #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 65dd599..d01c8ef 100644
 --- a/drivers/i2c/busses/Kconfig
 +++ b/drivers/i2c/busses/Kconfig
 @@ -338,6 +338,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
   help
 The unit of the TWI clock is kHz.
  
 +config I2C_CBUS
 + 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.
 +
  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 2d33d62..3c548b1 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)   += i2c-cbus.o
  obj-$(CONFIG_I2C_CPM)+= i2c-cpm.o
  obj-$(CONFIG_I2C_DAVINCI)+= i2c-davinci.o
  obj-$(CONFIG_I2C_DESIGNWARE_CORE)+= i2c-designware-core.o
 diff --git a/drivers/i2c/busses/i2c-cbus.c b/drivers/i2c/busses/i2c-cbus.c
 new file mode 100644
 index 000..1ea7667
 --- /dev/null
 +++ b/drivers/i2c/busses/i2c-cbus.c
 @@ -0,0 +1,300 @@
 +/*
 + * CBUS I2C driver for Nokia Internet Tablets.
 + *
 + * Copyright (C) 2004-2010 Nokia Corporation
 + *
 + * Based on code written by Juha Yrjölä, David Weinehall, Mikko Ylinen and
 + * Felipe Balbi. Converted to I2C driver by Aaro Koskinen.
 + *
 + * This file is subject to the terms and conditions of the GNU General
 + * Public License. See the file COPYING in the main directory of this
 + * archive for more details.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY