Re: RFC: moving twl4030-gpio.c to gpiolib

2008-03-28 Thread Tony Lindgren
* Felipe Balbi [EMAIL PROTECTED] [080320 15:48]:
 
 After the patch from Kevin Hilman, I had to rebase my gpiolib patch
 
 Here an updated version of it.

Can you repost with Signed-off-by?

Tony


 == CUT HERE ==
 
 diff --git a/arch/arm/mach-omap2/board-sdp-hsmmc.c
 b/arch/arm/mach-omap2/board-sdp-hsmmc.c
 index 3ae5b20..df24be6 100644
 --- a/arch/arm/mach-omap2/board-sdp-hsmmc.c
 +++ b/arch/arm/mach-omap2/board-sdp-hsmmc.c
 @@ -14,6 +14,7 @@
  #include linux/interrupt.h
  #include linux/delay.h
  #include linux/i2c/twl4030.h
 +#include linux/gpio.h
  #include asm/hardware.h
  #include asm/arch/mmc.h
  #include asm/arch/board.h
 @@ -36,8 +37,9 @@
  #define MMC2_CD_IRQ  1
  
  static int sdp_mmc_card_detect(int irq)
 +
  {
 - return twl4030_get_gpio_datain(irq - IH_TWL4030_GPIO_BASE);
 + return gpio_get_value(irq - IH_TWL4030_GPIO_BASE);
  }
  
  /*
 @@ -50,11 +52,11 @@ static int sdp_mmc_late_init(struct device *dev)
   /*
* Configure TWL4030 GPIO parameters for MMC hotplug irq
*/
 - ret = twl4030_request_gpio(MMC1_CD_IRQ);
 + ret = gpio_request(TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ), mmc1_cd_irq);
   if (ret != 0)
   goto err;
  
 - ret = twl4030_set_gpio_edge_ctrl(MMC1_CD_IRQ,
 + ret = twl4030_set_gpio_edge_ctrl(TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ),
   TWL4030_GPIO_EDGE_RISING | TWL4030_GPIO_EDGE_FALLING);
   if (ret != 0)
   goto err;
 @@ -64,7 +66,8 @@ static int sdp_mmc_late_init(struct device *dev)
   if (ret != 0)
   goto err;
  
 - ret = twl4030_set_gpio_debounce(MMC1_CD_IRQ, TWL4030_GPIO_IS_ENABLE);
 + ret = twl4030_set_gpio_debounce(TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ),
 + TWL4030_GPIO_IS_ENABLE);
   if (ret != 0)
   goto err;
  
 @@ -77,11 +80,7 @@ err:
  
  static void sdp_mmc_cleanup(struct device *dev)
  {
 - int ret = 0;
 -
 - ret = twl4030_free_gpio(MMC1_CD_IRQ);
 - if (ret != 0)
 - dev_err(dev, Failed to configure TWL4030 GPIO IRQ\n);
 + gpio_free(TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ));
  }
  
  #ifdef CONFIG_PM
 diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
 index bbd2834..c340333 100644
 --- a/drivers/gpio/Kconfig
 +++ b/drivers/gpio/Kconfig
 @@ -61,6 +61,12 @@ config GPIO_PCF857X
 This driver provides an in-kernel interface to those GPIOs using
 platform-neutral GPIO calls.
  
 +config GPIO_TWL4030
 + bool TWL4030 GPIO Driver
 + depends on I2C  TWL4030_CORE
 + help
 +   Say yes here to provide support for twl4030 gpio submodule.
 +
  comment SPI GPIO expanders:
  
  config GPIO_MCP23S08
 diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
 index fdde992..346187e 100644
 --- a/drivers/gpio/Makefile
 +++ b/drivers/gpio/Makefile
 @@ -7,3 +7,4 @@ obj-$(CONFIG_HAVE_GPIO_LIB)   += gpiolib.o
  obj-$(CONFIG_GPIO_MCP23S08)  += mcp23s08.o
  obj-$(CONFIG_GPIO_PCA953X)   += pca953x.o
  obj-$(CONFIG_GPIO_PCF857X)   += pcf857x.o
 +obj-$(CONFIG_GPIO_TWL4030)   += twl4030-gpio.o
 diff --git a/drivers/gpio/twl4030-gpio.c b/drivers/gpio/twl4030-gpio.c
 new file mode 100644
 index 000..81ab4ce
 --- /dev/null
 +++ b/drivers/gpio/twl4030-gpio.c
 @@ -0,0 +1,510 @@
 +/*
 + * drivers/gpio/tlw4030-gpio.c - driver for TWL4030 GPIO MODULE
 + *
 + * Copyright (C) 2006-2007 Texas Instruments, Inc.
 + * Copyright (C) 2006 MontaVista Software, Inc.
 + * Copyright (C) 2008 Nokia Corporation
 + *
 + * Moved to gpiolib by:
 + *   Felipe Balbi [EMAIL PROTECTED]
 + *
 + * Code re-arranged and cleaned up by:
 + *   Syed Mohammed Khasim [EMAIL PROTECTED]
 + *
 + * Initial Code:
 + *   Andy Lowe / Nishanth Menon
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 USA
 + *
 + */
 +
 +#include linux/kernel.h
 +#include linux/slab.h
 +#include linux/mutex.h
 +#include linux/i2c.h
 +#include linux/i2c/twl4030.h
 +#include asm/gpio.h
 +#include asm/hardware.h
 +
 +#define gpio_to_twl(x)   container_of((x), struct twl4030_gpio, chip)
 +#define DATA_BANK_MAX8
 +#define GET_GPIO_DATA_BANK(x)((x)/DATA_BANK_MAX)
 +#define GET_GPIO_DATA_OFF(x) ((x)%DATA_BANK_MAX)
 +
 +/*
 + * GPIO Block Register definitions
 + */
 +
 +#define REG_GPIODATAIN1  0x0
 +#define REG_GPIODATAIN2  

Re: RFC: moving twl4030-gpio.c to gpiolib

2008-03-28 Thread Tony Lindgren
* Felipe Balbi [EMAIL PROTECTED] [080328 12:13]:
 
 
 On Fri, 28 Mar 2008 10:06:16 +0200, Tony Lindgren [EMAIL PROTECTED] wrote:
  * Felipe Balbi [EMAIL PROTECTED] [080320 15:48]:
 
  After the patch from Kevin Hilman, I had to rebase my gpiolib patch
 
  Here an updated version of it.
  
  Can you repost with Signed-off-by?
 
 This one shouldn't be applied yet, it breaks mmc card detection :-(
 I sent as RFC to get comments from anyone interested.
 
 After moving to gpiolib I can't request_irq() for the gpio_irq used on
 the card detection.

OK, let's wait on this one then :)

 
  
  Tony
  
  
  == CUT HERE ==
 
  diff --git a/arch/arm/mach-omap2/board-sdp-hsmmc.c
  b/arch/arm/mach-omap2/board-sdp-hsmmc.c
  index 3ae5b20..df24be6 100644
  --- a/arch/arm/mach-omap2/board-sdp-hsmmc.c
  +++ b/arch/arm/mach-omap2/board-sdp-hsmmc.c
  @@ -14,6 +14,7 @@
   #include linux/interrupt.h
   #include linux/delay.h
   #include linux/i2c/twl4030.h
  +#include linux/gpio.h
   #include asm/hardware.h
   #include asm/arch/mmc.h
   #include asm/arch/board.h
  @@ -36,8 +37,9 @@
   #define MMC2_CD_IRQ   1
 
   static int sdp_mmc_card_detect(int irq)
  +
   {
  -  return twl4030_get_gpio_datain(irq - IH_TWL4030_GPIO_BASE);
  +  return gpio_get_value(irq - IH_TWL4030_GPIO_BASE);
   }
 
   /*
  @@ -50,11 +52,11 @@ static int sdp_mmc_late_init(struct device *dev)
 /*
  * Configure TWL4030 GPIO parameters for MMC hotplug irq
  */
  -  ret = twl4030_request_gpio(MMC1_CD_IRQ);
  +  ret = gpio_request(TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ), mmc1_cd_irq);
 if (ret != 0)
 goto err;
 
  -  ret = twl4030_set_gpio_edge_ctrl(MMC1_CD_IRQ,
  +  ret = twl4030_set_gpio_edge_ctrl(TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ),
 TWL4030_GPIO_EDGE_RISING | TWL4030_GPIO_EDGE_FALLING);
 if (ret != 0)
 goto err;
  @@ -64,7 +66,8 @@ static int sdp_mmc_late_init(struct device *dev)
 if (ret != 0)
 goto err;
 
  -  ret = twl4030_set_gpio_debounce(MMC1_CD_IRQ, TWL4030_GPIO_IS_ENABLE);
  +  ret = twl4030_set_gpio_debounce(TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ),
  +  TWL4030_GPIO_IS_ENABLE);
 if (ret != 0)
 goto err;
 
  @@ -77,11 +80,7 @@ err:
 
   static void sdp_mmc_cleanup(struct device *dev)
   {
  -  int ret = 0;
  -
  -  ret = twl4030_free_gpio(MMC1_CD_IRQ);
  -  if (ret != 0)
  -  dev_err(dev, Failed to configure TWL4030 GPIO IRQ\n);
  +  gpio_free(TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ));
   }
 
   #ifdef CONFIG_PM
  diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
  index bbd2834..c340333 100644
  --- a/drivers/gpio/Kconfig
  +++ b/drivers/gpio/Kconfig
  @@ -61,6 +61,12 @@ config GPIO_PCF857X
   This driver provides an in-kernel interface to those GPIOs using
   platform-neutral GPIO calls.
 
  +config GPIO_TWL4030
  +  bool TWL4030 GPIO Driver
  +  depends on I2C  TWL4030_CORE
  +  help
  +Say yes here to provide support for twl4030 gpio submodule.
  +
   comment SPI GPIO expanders:
 
   config GPIO_MCP23S08
  diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
  index fdde992..346187e 100644
  --- a/drivers/gpio/Makefile
  +++ b/drivers/gpio/Makefile
  @@ -7,3 +7,4 @@ obj-$(CONFIG_HAVE_GPIO_LIB)+= gpiolib.o
   obj-$(CONFIG_GPIO_MCP23S08)   += mcp23s08.o
   obj-$(CONFIG_GPIO_PCA953X)+= pca953x.o
   obj-$(CONFIG_GPIO_PCF857X)+= pcf857x.o
  +obj-$(CONFIG_GPIO_TWL4030)+= twl4030-gpio.o
  diff --git a/drivers/gpio/twl4030-gpio.c b/drivers/gpio/twl4030-gpio.c
  new file mode 100644
  index 000..81ab4ce
  --- /dev/null
  +++ b/drivers/gpio/twl4030-gpio.c
  @@ -0,0 +1,510 @@
  +/*
  + * drivers/gpio/tlw4030-gpio.c - driver for TWL4030 GPIO MODULE
  + *
  + * Copyright (C) 2006-2007 Texas Instruments, Inc.
  + * Copyright (C) 2006 MontaVista Software, Inc.
  + * Copyright (C) 2008 Nokia Corporation
  + *
  + * Moved to gpiolib by:
  + *Felipe Balbi [EMAIL PROTECTED]
  + *
  + * Code re-arranged and cleaned up by:
  + *Syed Mohammed Khasim [EMAIL PROTECTED]
  + *
  + * Initial Code:
  + *Andy Lowe / Nishanth Menon
  + *
  + * This program is free software; you can redistribute it and/or modify
  + * it under the terms of the GNU General Public License as published by
  + * the Free Software Foundation; either version 2 of the License, or
  + * (at your option) any later version.
  + *
  + * This program is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  + * GNU General Public License for more details.
  + *
  + * You should have received a copy of the GNU General Public License
  + * along with this program; if not, write to the Free Software
  + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  USA
  + *
  + */
  +
  +#include linux/kernel.h
  +#include linux/slab.h
  +#include linux/mutex.h