Skip to content

Commit e8deb28

Browse files
balajitkSamuel Ortiz
authored andcommitted
mfd: Add support for twl6030 irq framework
This patch adds support for phoenix interrupt framework. New iInterrupt status register A, B, C are introduced in Phoenix and are cleared on write. Due to the differences in interrupt handling with respect to TWL4030, twl6030-irq.c is created for TWL6030 PMIC Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Balaji T K <balajitk@ti.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Reviewed-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent c4aa6f3 commit e8deb28

7 files changed

Lines changed: 490 additions & 21 deletions

File tree

‎arch/arm/plat-omap/include/plat/irqs.h‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,22 @@
472472
#endif
473473
#define TWL4030_GPIO_IRQ_END (TWL4030_GPIO_IRQ_BASE + TWL4030_GPIO_NR_IRQS)
474474

475+
#define TWL6030_IRQ_BASE (OMAP_FPGA_IRQ_END)
476+
#ifdef CONFIG_TWL4030_CORE
477+
#define TWL6030_BASE_NR_IRQS 20
478+
#else
479+
#define TWL6030_BASE_NR_IRQS 0
480+
#endif
481+
#define TWL6030_IRQ_END (TWL6030_IRQ_BASE + TWL6030_BASE_NR_IRQS)
482+
475483
/* Total number of interrupts depends on the enabled blocks above */
476-
#define NR_IRQS TWL4030_GPIO_IRQ_END
484+
#if (TWL4030_GPIO_IRQ_END > TWL6030_IRQ_END)
485+
#define TWL_IRQ_END TWL4030_GPIO_IRQ_END
486+
#else
487+
#define TWL_IRQ_END TWL6030_IRQ_END
488+
#endif
489+
490+
#define NR_IRQS TWL_IRQ_END
477491

478492
#define OMAP_IRQ_BIT(irq) (1 << ((irq) % 32))
479493

‎drivers/mfd/Kconfig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ config MENELAUS
103103
cell phones and PDAs.
104104

105105
config TWL4030_CORE
106-
bool "Texas Instruments TWL4030/TPS659x0 Support"
106+
bool "Texas Instruments TWL4030/TWL5030/TWL6030/TPS659x0 Support"
107107
depends on I2C=y && GENERIC_HARDIRQS
108108
help
109-
Say yes here if you have TWL4030 family chip on your board.
109+
Say yes here if you have TWL4030 / TWL6030 family chip on your board.
110110
This core driver provides register access and IRQ handling
111111
facilities, and registers devices for the various functions
112112
so that function-specific drivers can bind to them.

‎drivers/mfd/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o
2626
obj-$(CONFIG_TPS65010) += tps65010.o
2727
obj-$(CONFIG_MENELAUS) += menelaus.o
2828

29-
obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o
29+
obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
3030
obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o
3131
obj-$(CONFIG_TWL4030_CODEC) += twl4030-codec.o
3232

‎drivers/mfd/twl-core.c‎

Lines changed: 106 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,30 @@
181181
/* Triton Core internal information (END) */
182182

183183

184+
/* subchip/slave 0 0x48 - POWER */
185+
#define TWL6030_BASEADD_RTC 0x0000
186+
#define TWL6030_BASEADD_MEM 0x0017
187+
#define TWL6030_BASEADD_PM_MASTER 0x001F
188+
#define TWL6030_BASEADD_PM_SLAVE_MISC 0x0030 /* PM_RECEIVER */
189+
#define TWL6030_BASEADD_PM_MISC 0x00E2
190+
#define TWL6030_BASEADD_PM_PUPD 0x00F0
191+
192+
/* subchip/slave 1 0x49 - FEATURE */
193+
#define TWL6030_BASEADD_USB 0x0000
194+
#define TWL6030_BASEADD_GPADC_CTRL 0x002E
195+
#define TWL6030_BASEADD_AUX 0x0090
196+
#define TWL6030_BASEADD_PWM 0x00BA
197+
#define TWL6030_BASEADD_GASGAUGE 0x00C0
198+
#define TWL6030_BASEADD_PIH 0x00D0
199+
#define TWL6030_BASEADD_CHARGER 0x00E0
200+
201+
/* subchip/slave 2 0x4A - DFT */
202+
#define TWL6030_BASEADD_DIEID 0x00C0
203+
204+
/* subchip/slave 3 0x4B - AUDIO */
205+
#define TWL6030_BASEADD_AUDIO 0x0000
206+
#define TWL6030_BASEADD_RSV 0x0000
207+
184208
/* Few power values */
185209
#define R_CFG_BOOT 0x05
186210
#define R_PROTECT_KEY 0x0E
@@ -202,13 +226,21 @@
202226
#define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */
203227
#define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */
204228
#define TWL5031 BIT(2) /* twl5031 has different registers */
229+
#define TWL6030_CLASS BIT(3) /* TWL6030 class */
205230

206231
/*----------------------------------------------------------------------*/
207232

208233
/* is driver active, bound to a chip? */
209234
static bool inuse;
210235

211-
/* Structure for each TWL4030 Slave */
236+
static unsigned int twl_id;
237+
unsigned int twl_rev(void)
238+
{
239+
return twl_id;
240+
}
241+
EXPORT_SYMBOL(twl_rev);
242+
243+
/* Structure for each TWL4030/TWL6030 Slave */
212244
struct twl_client {
213245
struct i2c_client *client;
214246
u8 address;
@@ -228,11 +260,12 @@ struct twl_mapping {
228260
unsigned char sid; /* Slave ID */
229261
unsigned char base; /* base address */
230262
};
263+
struct twl_mapping *twl_map;
231264

232265
static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
233266
/*
234267
* NOTE: don't change this table without updating the
235-
* <linux/i2c/twl4030.h> defines for TWL4030_MODULE_*
268+
* <linux/i2c/twl.h> defines for TWL4030_MODULE_*
236269
* so they continue to match the order in this table.
237270
*/
238271

@@ -265,6 +298,40 @@ static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
265298
{ 3, TWL4030_BASEADD_SECURED_REG },
266299
};
267300

301+
static struct twl_mapping twl6030_map[] = {
302+
/*
303+
* NOTE: don't change this table without updating the
304+
* <linux/i2c/twl.h> defines for TWL4030_MODULE_*
305+
* so they continue to match the order in this table.
306+
*/
307+
{ SUB_CHIP_ID1, TWL6030_BASEADD_USB },
308+
{ SUB_CHIP_ID3, TWL6030_BASEADD_AUDIO },
309+
{ SUB_CHIP_ID2, TWL6030_BASEADD_DIEID },
310+
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
311+
{ SUB_CHIP_ID1, TWL6030_BASEADD_PIH },
312+
313+
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
314+
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
315+
{ SUB_CHIP_ID1, TWL6030_BASEADD_GPADC_CTRL },
316+
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
317+
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
318+
319+
{ SUB_CHIP_ID1, TWL6030_BASEADD_CHARGER },
320+
{ SUB_CHIP_ID1, TWL6030_BASEADD_GASGAUGE },
321+
{ SUB_CHIP_ID1, TWL6030_BASEADD_PWM },
322+
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
323+
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
324+
325+
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
326+
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
327+
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
328+
{ SUB_CHIP_ID0, TWL6030_BASEADD_PM_MASTER },
329+
{ SUB_CHIP_ID0, TWL6030_BASEADD_PM_SLAVE_MISC },
330+
331+
{ SUB_CHIP_ID0, TWL6030_BASEADD_RTC },
332+
{ SUB_CHIP_ID0, TWL6030_BASEADD_MEM },
333+
};
334+
268335
/*----------------------------------------------------------------------*/
269336

270337
/* Exported Functions */
@@ -292,7 +359,7 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
292359
pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
293360
return -EPERM;
294361
}
295-
sid = twl4030_map[mod_no].sid;
362+
sid = twl_map[mod_no].sid;
296363
twl = &twl_modules[sid];
297364

298365
if (unlikely(!inuse)) {
@@ -310,7 +377,7 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
310377
msg->flags = 0;
311378
msg->buf = value;
312379
/* over write the first byte of buffer with the register address */
313-
*value = twl4030_map[mod_no].base + reg;
380+
*value = twl_map[mod_no].base + reg;
314381
ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 1);
315382
mutex_unlock(&twl->xfer_lock);
316383

@@ -349,7 +416,7 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
349416
pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
350417
return -EPERM;
351418
}
352-
sid = twl4030_map[mod_no].sid;
419+
sid = twl_map[mod_no].sid;
353420
twl = &twl_modules[sid];
354421

355422
if (unlikely(!inuse)) {
@@ -362,7 +429,7 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
362429
msg->addr = twl->address;
363430
msg->len = 1;
364431
msg->flags = 0; /* Read the register value */
365-
val = twl4030_map[mod_no].base + reg;
432+
val = twl_map[mod_no].base + reg;
366433
msg->buf = &val;
367434
/* [MSG2] fill the data rx buffer */
368435
msg = &twl->xfer_msg[1];
@@ -486,6 +553,7 @@ add_regulator_linked(int num, struct regulator_init_data *pdata,
486553
struct regulator_consumer_supply *consumers,
487554
unsigned num_consumers)
488555
{
556+
unsigned sub_chip_id;
489557
/* regulator framework demands init_data ... */
490558
if (!pdata)
491559
return NULL;
@@ -496,7 +564,8 @@ add_regulator_linked(int num, struct regulator_init_data *pdata,
496564
}
497565

498566
/* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */
499-
return add_numbered_child(3, "twl_reg", num,
567+
sub_chip_id = twl_map[TWL_MODULE_PM_MASTER].sid;
568+
return add_numbered_child(sub_chip_id, "twl_reg", num,
500569
pdata, sizeof(*pdata), false, 0, 0);
501570
}
502571

@@ -516,6 +585,7 @@ static int
516585
add_children(struct twl4030_platform_data *pdata, unsigned long features)
517586
{
518587
struct device *child;
588+
unsigned sub_chip_id;
519589

520590
if (twl_has_bci() && pdata->bci &&
521591
!(features & (TPS_SUBSET | TWL5031))) {
@@ -561,7 +631,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
561631
* Eventually, Linux might become more aware of such
562632
* HW security concerns, and "least privilege".
563633
*/
564-
child = add_child(3, "twl_rtc",
634+
sub_chip_id = twl_map[TWL_MODULE_RTC].sid;
635+
child = add_child(sub_chip_id, "twl_rtc",
565636
NULL, 0,
566637
true, pdata->irq_base + RTC_INTR_OFFSET, 0);
567638
if (IS_ERR(child))
@@ -812,16 +883,22 @@ static void clocks_init(struct device *dev,
812883

813884
/*----------------------------------------------------------------------*/
814885

815-
int twl_init_irq(int irq_num, unsigned irq_base, unsigned irq_end);
816-
int twl_exit_irq(void);
817-
int twl_init_chip_irq(const char *chip);
886+
int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end);
887+
int twl4030_exit_irq(void);
888+
int twl4030_init_chip_irq(const char *chip);
889+
int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end);
890+
int twl6030_exit_irq(void);
818891

819892
static int twl_remove(struct i2c_client *client)
820893
{
821894
unsigned i;
822895
int status;
823896

824-
status = twl_exit_irq();
897+
if (twl_class_is_4030())
898+
status = twl4030_exit_irq();
899+
else
900+
status = twl6030_exit_irq();
901+
825902
if (status < 0)
826903
return status;
827904

@@ -878,6 +955,13 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
878955
mutex_init(&twl->xfer_lock);
879956
}
880957
inuse = true;
958+
if ((id->driver_data) & TWL6030_CLASS) {
959+
twl_id = TWL6030_CLASS_ID;
960+
twl_map = &twl6030_map[0];
961+
} else {
962+
twl_id = TWL4030_CLASS_ID;
963+
twl_map = &twl4030_map[0];
964+
}
881965

882966
/* setup clock framework */
883967
clocks_init(&client->dev, pdata->clock);
@@ -890,8 +974,15 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
890974
if (client->irq
891975
&& pdata->irq_base
892976
&& pdata->irq_end > pdata->irq_base) {
893-
twl_init_chip_irq(id->name);
894-
status = twl_init_irq(client->irq, pdata->irq_base, pdata->irq_end);
977+
if (twl_class_is_4030()) {
978+
twl4030_init_chip_irq(id->name);
979+
status = twl4030_init_irq(client->irq, pdata->irq_base,
980+
pdata->irq_end);
981+
} else {
982+
status = twl6030_init_irq(client->irq, pdata->irq_base,
983+
pdata->irq_end);
984+
}
985+
895986
if (status < 0)
896987
goto fail;
897988
}
@@ -910,6 +1001,7 @@ static const struct i2c_device_id twl_ids[] = {
9101001
{ "tps65950", 0 }, /* catalog version of twl5030 */
9111002
{ "tps65930", TPS_SUBSET }, /* fewer LDOs and DACs; no charger */
9121003
{ "tps65920", TPS_SUBSET }, /* fewer LDOs; no codec or charger */
1004+
{ "twl6030", TWL6030_CLASS }, /* "Phoenix power chip" */
9131005
{ /* end of list */ },
9141006
};
9151007
MODULE_DEVICE_TABLE(i2c, twl_ids);

‎drivers/mfd/twl4030-irq.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ int twl4030_sih_setup(int module)
778778
/* FIXME pass in which interrupt line we'll use ... */
779779
#define twl_irq_line 0
780780

781-
int twl_init_irq(int irq_num, unsigned irq_base, unsigned irq_end)
781+
int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end)
782782
{
783783
static struct irq_chip twl4030_irq_chip;
784784

@@ -858,7 +858,7 @@ int twl_init_irq(int irq_num, unsigned irq_base, unsigned irq_end)
858858
return status;
859859
}
860860

861-
int twl_exit_irq(void)
861+
int twl4030_exit_irq(void)
862862
{
863863
/* FIXME undo twl_init_irq() */
864864
if (twl4030_irq_base) {
@@ -868,7 +868,7 @@ int twl_exit_irq(void)
868868
return 0;
869869
}
870870

871-
int twl_init_chip_irq(const char *chip)
871+
int twl4030_init_chip_irq(const char *chip)
872872
{
873873
if (!strcmp(chip, "twl5031")) {
874874
sih_modules = sih_modules_twl5031;

0 commit comments

Comments
 (0)