Re: [PATCH v3 01/04] OMAP4: PMIC: Add support for twl6030 irq framework

2009-10-01 Thread Amit Kucheria
Hi Balaji,

Some comments inline.

On 09 Oct 01, balaj...@ti.com wrote:
 From: Balaji T K balaj...@ti.com
 
 This version of patch series enables RUN TIME selection of TWL4030 or TWL6030.
 CONFIG_TWL4030_CORE and CONFIG_TWL6030_CORE is replaced by CONFIG_TWL_CORE
 
 This patch adds support for phoenix interrupt framework. New Interrupt status
 register A, B, C are introduced in Phoenix and are cleared on write.
 Due to difference in interrupt handling with respect to TWL4030,
 twl6030-irq.c is created for TWL6030 PMIC
 
 Signed-off-by: Rajendra Nayak rna...@ti.com
 Signed-off-by: Balaji T K balaj...@ti.com
 Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com
 Acked-by: Samuel Ortiz sa...@linux.intel.com
 Reviewed-by: Tony Lindgren t...@atomide.com
 ---
  arch/arm/plat-omap/include/mach/irqs.h |   18 ++-
  drivers/mfd/Kconfig|6 +-
  drivers/mfd/Makefile   |2 +-
  drivers/mfd/twl-core.c |  124 --
  drivers/mfd/twl4030-irq.c  |4 +-
  drivers/mfd/twl6030-irq.c  |  299 
 
  include/linux/i2c/twl.h|   62 +++
  7 files changed, 495 insertions(+), 20 deletions(-)
  create mode 100644 drivers/mfd/twl6030-irq.c
 
 diff --git a/arch/arm/plat-omap/include/mach/irqs.h 
 b/arch/arm/plat-omap/include/mach/irqs.h
 index fb7cb77..e9e0500 100644
 --- a/arch/arm/plat-omap/include/mach/irqs.h
 +++ b/arch/arm/plat-omap/include/mach/irqs.h
 @@ -531,7 +531,7 @@
  
  /* External TWL4030 can handle interrupts on 2430 and 34xx boards */
  #define  TWL4030_IRQ_BASE(OMAP_FPGA_IRQ_END)
 -#ifdef   CONFIG_TWL4030_CORE
 +#ifdef   CONFIG_TWL_CORE
  #define  TWL4030_BASE_NR_IRQS8
  #define  TWL4030_PWR_NR_IRQS 8
  #else
 @@ -551,8 +551,22 @@
  #endif
  #define TWL4030_GPIO_IRQ_END (TWL4030_GPIO_IRQ_BASE + TWL4030_GPIO_NR_IRQS)
  
 +#define  TWL6030_IRQ_BASE(OMAP_FPGA_IRQ_END)
 +#ifdef CONFIG_TWL_CORE
 +#define  TWL6030_BASE_NR_IRQS20
 +#else
 +#define  TWL6030_BASE_NR_IRQS0
 +#endif
 +#define TWL6030_IRQ_END  (TWL6030_IRQ_BASE + 
 TWL6030_BASE_NR_IRQS)
 +
  /* Total number of interrupts depends on the enabled blocks above */
 -#define NR_IRQS  TWL4030_GPIO_IRQ_END
 +#if (TWL4030_GPIO_IRQ_END  TWL6030_IRQ_END)
 +#define TWL_IRQ_END  TWL4030_GPIO_IRQ_END
 +#else
 +#define TWL_IRQ_END  TWL6030_IRQ_END
 +#endif
 +
 +#define NR_IRQS  TWL_IRQ_END
  
  #define OMAP_IRQ_BIT(irq)(1  ((irq) % 32))
  
 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index 491ac0f..c714281 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -94,11 +94,11 @@ config MENELAUS
 and other features that are often used in portable devices like
 cell phones and PDAs.
  
 -config TWL4030_CORE
 - bool Texas Instruments TWL4030/TPS659x0 Support
 +config TWL_CORE
 + bool Texas Instruments TWL4030/TWL5030/TWL6030/TPS659x0 Support
   depends on I2C=y  GENERIC_HARDIRQS
   help
 -   Say yes here if you have TWL4030 family chip on your board.
 +   Say yes here if you have TWL4030 / TWL6030 family chip on your board.
 This core driver provides register access and IRQ handling
 facilities, and registers devices for the various functions
 so that function-specific drivers can bind to them.
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 4e9d513..c733440 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -22,7 +22,7 @@ obj-$(CONFIG_MFD_WM8350_I2C)+= wm8350-i2c.o
  obj-$(CONFIG_TPS65010)   += tps65010.o
  obj-$(CONFIG_MENELAUS)   += menelaus.o
  
 -obj-$(CONFIG_TWL4030_CORE)   += twl-core.o twl4030-irq.o
 +obj-$(CONFIG_TWL_CORE)   += twl-core.o twl4030-irq.o 
 twl6030-irq.o
  
  obj-$(CONFIG_MFD_CORE)   += mfd-core.o
  
 diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
 index 62ace48..73d50c9 100644
 --- a/drivers/mfd/twl-core.c
 +++ b/drivers/mfd/twl-core.c
 @@ -158,6 +158,33 @@
  /* Triton Core internal information (END) */
  
  
 +/* subchip/slave 0 0x48 - POWER */
 +#define TWL6030_BASEADD_RTC  0x
 +#define TWL6030_BASEADD_MEM  0x0017
 +#define TWL6030_BASEADD_PM_MASTER0x001F
 +#define TWL6030_BASEADD_PM_SLAVE_MISC0x0031
 +#define TWL6030_BASEADD_PM_SLAVE_SMPS0x0040
 +#define TWL6030_BASEADD_PM_SLAVE_LDO 0x0080
 +#define TWL6030_BASEADD_PM_SLAVE_RES 0x00AD
 +#define TWL6030_BASEADD_PM_MISC  0x00E2
 +#define TWL6030_BASEADD_PM_PUPD  0x00F0
 +
 +/* subchip/slave 1 0x49 - FEATURE */
 +#define TWL6030_BASEADD_USB  0x
 +#define TWL6030_BASEADD_GPADC_CTRL   0x002E
 +#define TWL6030_BASEADD_AUX  0x0090
 +#define TWL6030_BASEADD_PWM  0x00BA
 +#define TWL6030_BASEADD_GASGAUGE 0x00C0
 +#define TWL6030_BASEADD_PIH  0x00D0
 

RE: [PATCH v3 01/04] OMAP4: PMIC: Add support for twl6030 irq framework

2009-10-01 Thread Shilimkar, Santosh
Amit,

snip
 -Original Message-
 From: Amit Kucheria [mailto:amit.kuche...@verdurent.com] On Behalf Of Amit
 Kucheria
 Sent: Thursday, October 01, 2009 6:46 PM
 To: Krishnamoorthy, Balaji T
 Cc: linux-omap@vger.kernel.org; sa...@linux.intel.com; w...@iguana.be;
 timo.t.kokko...@nokia.com; ben-li...@fluff.org; l...@slimlogic.co.uk;
 broo...@opensource.wolfsonmicro.com; p_gortma...@yahoo.com;
 a.zu...@towertech.it; Nayak, Rajendra; Shilimkar, Santosh
 Subject: Re: [PATCH v3 01/04] OMAP4: PMIC: Add support for twl6030 irq
 framework
 

  +
  +   status = request_irq(irq_num, handle_twl6030_pih, IRQF_DISABLED,
  +   TWL6030-PIH, irq_event);
 
 There is no need for the kthread hack anymore now that threaded irqs are
 available to everyone (2.6.32-rc1)
 
 So above would become,
 status = request_threaded_irq(irq_num, handle_twl6030_pih,
 twl6030_irq_thread, IRQF_DISABLED,
  TWL6030-PIH, irq_event);
 where,
  handle_twl6030_pih is the hard irq handler that mask the interrupt
  twl6030_irq_thread is a sleeping call called by the irq framework
 
 You might also be able to do away with handle_twl6030_pih entirely and
 pass
 NULL. That along with a IRQF_ONESHOT flag the the request_threaded_irq
 routine should automatically mask the irq until the sleeping call returns.
 
 I am working on doing this to the twl4030 driver currently, if anybody
 else
 isn't.
This is interesting and can improve the TWL framework. Keep us posted about 
your testing on TWL4030.

Thanks !!

Regards
Santosh