OMAP4: PMIC: Add support for twl6030 irq framework
Subsystems (5)
RFC PATCH 1/4 OMAP4: PMIC: Add support for twl6030 irq framework
From: Balaji T K <[email protected]>
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
--- arch/arm/plat-omap/include/mach/irqs.h | 12 ++ drivers/mfd/Kconfig | 13 ++ drivers/mfd/Makefile | 1 + drivers/mfd/twl-core.c | 97 +++++++++-- drivers/mfd/twl6030-irq.c | 301 ++++++++++++++++++++++++++++++++ include/linux/i2c/twl.h | 124 +++++++++++++- 6 files changed, 531 insertions(+), 17 deletions(-) create mode 100644 drivers/mfd/twl6030-irq.c
arch/arm/plat-omap/include/mach/irqs.h +12 -0
@@ -551,8 +551,20 @@#endif #define TWL4030_GPIO_IRQ_END (TWL4030_GPIO_IRQ_BASE + TWL4030_GPIO_NR_IRQS) +#define TWL6030_IRQ_BASE (OMAP_FPGA_IRQ_END) +#ifdef CONFIG_TWL6030_CORE +#define TWL6030_BASE_NR_IRQS 20 +#else +#define TWL6030_BASE_NR_IRQS 0 +#endif +#define TWL6030_IRQ_END (TWL6030_IRQ_BASE + TWL6030_BASE_NR_IRQS) +/* Total number of interrupts depends on the enabled blocks above */ +#ifdef CONFIG_TWL4030_CORE #define NR_IRQS TWL4030_GPIO_IRQ_END +#else +#define NR_IRQS TWL6030_IRQ_END +#endif #define OMAP_IRQ_BIT (irq) (1 << ((irq) % 32))
drivers/mfd/Kconfig +13 -0
@@ -108,6 +108,19 @@ config TWL4030_CORE high speed USB OTG transceiver, an audio codec (on most versions) and many other features. +config TWL6030_CORE + bool "Texas Instruments TWL6030 Support" + depends on I2C=y && GENERIC_HARDIRQS + depends on !TWL4030_CORE + help + Say yes here if you have 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. + + These multi-function chips are meant for OMAP4 processors, + providing power management, RTC, a USB transciever and a GPADC. + config MFD_TMIO bool default n
drivers/mfd/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_TPS65010) += tps65010.o obj-$(CONFIG_MENELAUS) += menelaus.o obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o +obj-$(CONFIG_TWL6030_CORE) += twl-core.o twl6030-irq.o obj-$(CONFIG_MFD_CORE) += mfd-core.o
drivers/mfd/twl-core.c +86 -11
180 lines not on this page · raw message
drivers/mfd/twl6030-irq.c new file +301 -0
301 lines not on this page · raw message
include/linux/i2c/twl.h +118 -6
153 lines not on this page · raw message
Signature · 1 line
1.5.4.7
hi,
Quoted 12 lines · On Mon, Jul 20, 2009 at 07:06:32PM +0530, [email protected] wrote:
arch/arm/plat-omap/include/mach/irqs.h +4
-0@@ -551,8 +551,20 @@#endif #define TWL4030_GPIO_IRQ_END (TWL4030_GPIO_IRQ_BASE + TWL4030_GPIO_NR_IRQS) +#define TWL6030_IRQ_BASE (OMAP_FPGA_IRQ_END) +#ifdef CONFIG_TWL6030_CORE +#define TWL6030_BASE_NR_IRQS 20 +#else
arch/arm/plat-omap/include/mach/irqs.h line 567
Quoted 10 lines
arch/arm/plat-omap/include/mach/irqs.h +8
-0+#define TWL6030_BASE_NR_IRQS 0 +#endif +#define TWL6030_IRQ_END (TWL6030_IRQ_BASE + TWL6030_BASE_NR_IRQS) +/* Total number of interrupts depends on the enabled blocks above */ +#ifdef CONFIG_TWL4030_CORE #define NR_IRQS TWL4030_GPIO_IRQ_END +#else +#define NR_IRQS TWL6030_IRQ_END +#endif
this will be tricky to make it better. Tony ? Dave ? Any suggestions ?
drivers/mfd/Makefile obj-$(CONFIG_TPS65010) += tps65010.o · line 26
Quoted 9 lines
drivers/mfd/Makefile +1
-0@@ -23,6 +23,7 @@ obj-$(CONFIG_TPS65010) += tps65010.o obj-$(CONFIG_MENELAUS) += menelaus.o obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o +obj-$(CONFIG_TWL6030_CORE) += twl-core.o twl6030-irq.o
this will break multi-omap builds. Tony can comment a bit more on this, but I suggest you try to find some way to figure out if you're running on twl4030/twl5030 or twl6030.
Maybe one way would be to add a TWL6030 flag to twl4030-core.c, just like we have TWL4030_VAUX2 and TPS_SUBSET. And I know of one more hw that will fall into this driver and patches shall be coming out soonish. So another flag should be added.
drivers/mfd/Makefile obj-$(CONFIG_TPS65010) += tps65010.o · line 27
Quoted 1 line
drivers/mfd/Makefile +1
-0+#ifdef CONFIG_TWL6030_CORE
we have to avoid these ifdeferry.
drivers/mfd/Makefile obj-$(CONFIG_TPS65010) += tps65010.o
Quoted 10 lines
drivers/mfd/Makefile +10
-0+#define TWL6030_MODULE_LAST TWL6030_MODULE_AUDIO +#define TWL_MODULE_LAST TWL6030_MODULE_LAST + +#define RTC_SUB_CHIP_ID SUB_CHIP_ID0 +#define REG_SUB_CHIP_ID SUB_CHIP_ID0 +#define USB_SUB_CHIP_ID SUB_CHIP_ID1 +#define MADC_SUB_CHIP_ID SUB_CHIP_ID1 +#define BCI_SUB_CHIP_ID SUB_CHIP_ID1 +#define GPIO_SUB_CHIP_ID 0 /* NOT SUPPORTED IN TWL6030 */ +#define KEYPAD_SUB_CHIP_ID 0 /* ADDED FOR COMPILATION ONLY */
maybe passing these via platform_data or using the TWL6030 flag somehow.
Quoted 42 lines
drivers/mfd/Makefile +30
-1+/* subchip/slave 0 0x48 - POWER */ +#define TWL6030_BASEADD_RTC 0x0000 +#define TWL6030_BASEADD_MEM 0x0017 +#define TWL6030_BASEADD_PM_MASTER 0x001F +#define TWL6030_BASEADD_PM_SLAVE_MISC 0x0030 +#define TWL6030_BASEADD_PM_SLAVE_SMPS 0x0040 +#define TWL6030_BASEADD_PM_SLAVE_LDO 0x0080 +#define TWL6030_BASEADD_PM_SLAVE_RES 0x00AD +#define TWL6030_BASEADD_PM_MISC 0x00E3 +#define TWL6030_BASEADD_PM_PUPD 0x00F0 + +/* subchip/slave 1 0x49 - FEATURE */ +#define TWL6030_BASEADD_USB 0x0000 +#define TWL6030_BASEADD_GPADC_CTRL 0x0030 +#define TWL6030_BASEADD_GPADC_RT 0x0035 +#define TWL6030_BASEADD_GPADC 0x005D +#define TWL6030_BASEADD_AUX 0x0090 +#define TWL6030_BASEADD_PWM 0x00BA +#define TWL6030_BASEADD_GASGAUGE 0x00C0 +#define TWL6030_BASEADD_PIH 0x00D0 +#define TWL6030_BASEADD_CHARGER 0x00E0 + +/* subchip/slave 2 0x4A - DFT */ +#define TWL6030_BASEADD_DIEID 0x00C0 + +/* subchip/slave 3 0x4B - AUDIO */ +#define TWL6030_BASEADD_AUDIO 0x0000 +#endif /* CONFIG_TWL6030_CORE */ + /* Few power values */ #define R_CFG_BOOT 0x05 #define R_PROTECT_KEY 0x0E@@ -190,7 +231,7 @@ /* is driver active, bound to a chip? */ static bool inuse; -/* Structure for each TWL4030 Slave */ +/* Structure for each TWL4030/TWL6030 Slave */ struct twl_client { struct i2c_client *client; u8 address;
drivers/mfd/Makefile struct twl_mapping { · line 255
Quoted 3 lines
drivers/mfd/Makefile +0
-0@@ -212,7 +253,7 @@ struct twl_mapping { }; #ifdef CONFIG_TWL4030_CORE
avoid ifdef
drivers/mfd/Makefile struct twl_mapping { · line 256
Quoted 2 lines
drivers/mfd/Makefile +1
-1-static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = { +static struct twl_mapping twl_map[TWL4030_MODULE_LAST + 1] = {
keep the old name
drivers/mfd/Makefile static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = { · line 291
Quoted 5 lines
drivers/mfd/Makefile +1
-0@@ -247,12 +288,45 @@ static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = { }; #endif +#ifdef CONFIG_TWL6030_CORE
avoid this
drivers/mfd/Makefile static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = { · line 292
Quoted 1 line
drivers/mfd/Makefile +1
-0+static struct twl_mapping twl_map[TWL6030_MODULE_LAST + 1] = {
call this oe twl6030_map, the you could use TWL6030 flag to choose which one to use.
drivers/mfd/Makefile static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = { · line 294
Quoted 3 lines
drivers/mfd/Makefile +1
-1/** - * twl_i2c_write - Writes a n bit register in TWL4030 + * twl_i2c_write - Writes a n bit register in TWL4030/TWL6030
TWL4030/TWL5030/TPS65920/TPS65930/TWL6030/...
this will only grow and grow.
drivers/mfd/Makefile int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) · line 351
Quoted 6 lines
drivers/mfd/Makefile +1
-1@@ -274,7 +348,7 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); return -EPERM; } - sid = twl4030_map[mod_no].sid; + sid = twl_map[mod_no].sid;
you could have something like:
if (twl_features & TWL6030) sid = twl6030_map[mod_no].sid; else sid = twl4030_map[mod_no].sid;
something like that.
drivers/mfd/Makefile int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) · line 369
Quoted 6 lines
drivers/mfd/Makefile +1
-1@@ -292,7 +366,7 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) msg->flags = 0; msg->buf = value; /* over write the first byte of buffer with the register address */ - *value = twl4030_map[mod_no].base + reg; + *value = twl_map[mod_no].base + reg;
ditto
Signature · 1 line
balbi
Felipe,
Thanks for the review.
Quoted 5 lines
-----Original Message-----
From: Felipe Balbi [mailto:me-uiRdBs8odbtmTBlB0Cgj/[email protected]]
Sent: Tuesday, July 21, 2009 12:37 AM
To: Krishnamoorthy, Balaji T
Cc: [email protected]; [email protected];
Quoted 8 lines
[email protected]; david-b-yBeKhBN/[email protected]; [email protected]; [email protected]; sameo-RWuK6r/[email protected]; [email protected]; [email protected]; [email protected]; lrg-kDsPt+C1G03kYMGBc/[email protected]; broonie-yzvPICuk2AATkU/[email protected]; Nayak, Rajendra; Shilimkar, Santosh
Subject: Re: [RFC][PATCH 1/4] OMAP4: PMIC: Add support for
twl6030 irq framework
I can summarize all your review comments in two points.
1. Renaming is some thing __you__ think in not necessary.
For this, I have already responded but just to clarify others on the list, I am just copy pasting your point and our view on this topic.
************************************************************************
Quoted 7 lines
this is kinda useless, we can consider twl6030 as being sw compatible (almost) with twl4030. And twl4030 driver already support plenty of other devices, just look at
drivers/mfd/twl4030-core.clines 807 - 814.
We have twl4003, twl5030, tps65950, tps65930 and tps65920.So IMO, renaming the files is unnecessary.
Well tps* are just another catalog names of the twl4* family. So you can keep adding whatever names there as long it's a same IC.
Perhaps you look in hurry to comment about this. Please look at the intention of these patches. TWL6030 has PM IC similar to TWL4030 with bit different interrupt management. Audio IC is a separate one as compared to combined in case of TWL4030.
If it allows code re-use by renaming files, it should be good. Isn't it ?
************************************************************************
Here is summary of Major difference between Triton(TWL4030) and Phoenix(TWL6030_ chips are:
-GPIO, Keypad is not present in Phoenix
-I2C Chips addresses of modules like RTC, BCI, ADC, USB, PMC Master/Slave
have changed. Base address of these module register is also changed.
-PIH and SIH, module interrupt status registers will be replaced by PIH
(INT_STS_A, INT_STS_B and INT_STS_C) and module interrupt status registers
-MADC to GPADC in Phoenix, 17 channels supported
GPADC in Phoenix supports Realtime, Asynchronous SW request.
-RTC register offsets have changed. Addition/removal of LDO/SMPS Voltage
Regulators
2. Usage of compile time macros like "CONFIG_TWL4030" and CONFIG_TWL6030" should be avoided and you think it would break multi-omap.
If we just go by definition " Multi-OMAP" is for different OMAP IC's. TWL4030 and TWL6030 are external companion IC's to OMAP.
Any ways, these compile time switches can be avoided if we make runtime provision for these TWL IC's like.
"is_twl4030(), is_twl6030" etc like "cpu_is_24xx(),cpu_is_44xx()" etc.
Obviously this asks to make the driver register map (which is different in case of TWL6030 w.r.t TWL4030) to be held in some arrays and select the appropriate one run-time. But it's doable if it helps.
The patch series was made under _assumption_ that either TWL4030 or TWL6030 would be used. I am not sure whether there will boards where both will co-exist.
Regards
Santosh--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
hi,
please send text mails and break your lines at 80 characters!
Quoted 11 lines · Santosh
Here is summary of Major difference between Triton(TWL4030) and Phoenix(TWL6030_ chips are:
-GPIO, Keypad is not present in Phoenix
-I2C Chips addresses of modules like RTC, BCI, ADC, USB, PMC Master/Slave
have changed. Base address of these module register is also changed.
-PIH and SIH, module interrupt status registers will be replaced by PIH
(INT_STS_A,INT_STS_BandINT_STS_C) and module interrupt status registers
-MADC to GPADC in Phoenix, 17 channels supported
GPADC in Phoenix supports Realtime, Asynchronous SW request.
-RTC register offsets have changed. Addition/removal of LDO/SMPS Voltage
Regulators
all of this can be addressed without ifdeferry around the code. Just add proper abstraction via platform_data, and that 'features' you see in twl4030-core.c
Quoted 5 lines
2. Usage of compile time macros like "
CONFIG_TWL4030" andCONFIG_TWL6030" should be avoided and you think it would break multi-omap.If we just go by definition " Multi-OMAP" is for different OMAP IC's. TWL4030 and TWL6030 are external companion IC's to OMAP.
what will happen if you build on kernel image for booting omap3 and omap4 ???
Quoted 3 lines
Any ways, these compile time switches can be avoided if we make runtime provision for these TWL IC's like.
"is_twl4030(),is_twl6030" etc like "cpu_is_24xx(),cpu_is_44xx()" etc.
or you just use the 'features' in the twl4030-core.c and based on that pass a flag to the children notifying it's triton/gaia/reno/phoenix.
Quoted 3 lines
Obviously this asks to make the driver register map (which is different in case of TWL6030 w.r.t TWL4030) to be held in some arrays and select the appropriate one run-time. But it's doable if it helps.
I'd say that's better than ifdeferry.
Quoted 3 lines
The patch series was made under _assumption_ that either TWL4030 or TWL6030 would be used. I am not sure whether there will boards where both will co-exist.
not in the same board, but think of building one kernel image for both omap3 and omap4. Nobody will do that in real life for real products, but it's really useful when it goes about testing code on several boards. You don't have to spend time building several different kernel images, you build only one that boots on all.
Signature · 1 line
balbi