Skip to content

Commit aeb5032

Browse files
Benoit CoussonSamuel Ortiz
authored andcommitted
mfd: twl-core: Add initial DT support for twl4030/twl6030
Add initial device-tree support for twl familly chips. The current version is missing the regulator entries due to the lack of DT regulator bindings for the moment. Only the simple sub-modules that do not depend on platform_data information can be initialized properly. Add irqdomain support. Add documentation for the Texas Instruments TWL Integrated Chip. Signed-off-by: Benoit Cousson <b-cousson@ti.com> Cc: Balaji T K <balajitk@ti.com> Cc: Graeme Gregory <gg@slimlogic.co.uk> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Acked-by: Rob Herring <rob.herring@calxeda.com> [grant.likely@secretlab.ca: Fix IRQ_DOMAIN dependency in kconfig] Cc: Grant Likely <grant.likely@secretlab.ca>
1 parent 5391b5c commit aeb5032

3 files changed

Lines changed: 98 additions & 2 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Texas Instruments TWL family
2+
3+
The TWLs are Integrated Power Management Chips.
4+
Some version might contain much more analog function like
5+
USB transceiver or Audio amplifier.
6+
These chips are connected to an i2c bus.
7+
8+
9+
Required properties:
10+
- compatible : Must be "ti,twl4030";
11+
For Integrated power-management/audio CODEC device used in OMAP3
12+
based boards
13+
- compatible : Must be "ti,twl6030";
14+
For Integrated power-management used in OMAP4 based boards
15+
- interrupts : This i2c device has an IRQ line connected to the main SoC
16+
- interrupt-controller : Since the twl support several interrupts internally,
17+
it is considered as an interrupt controller cascaded to the SoC one.
18+
- #interrupt-cells = <1>;
19+
- interrupt-parent : The parent interrupt controller.
20+
21+
Optional node:
22+
- Child nodes contain in the twl. The twl family is made of several variants
23+
that support a different number of features.
24+
The children nodes will thus depend of the capability of the variant.
25+
26+
27+
Example:
28+
/*
29+
* Integrated Power Management Chip
30+
* http://www.ti.com/lit/ds/symlink/twl6030.pdf
31+
*/
32+
twl@48 {
33+
compatible = "ti,twl6030";
34+
reg = <0x48>;
35+
interrupts = <39>; /* IRQ_SYS_1N cascaded to gic */
36+
interrupt-controller;
37+
#interrupt-cells = <1>;
38+
interrupt-parent = <&gic>;
39+
#address-cells = <1>;
40+
#size-cells = <0>;
41+
42+
twl_rtc {
43+
compatible = "ti,twl_rtc";
44+
interrupts = <11>;
45+
reg = <0>;
46+
};
47+
};

‎drivers/mfd/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ config MENELAUS
200200

201201
config TWL4030_CORE
202202
bool "Texas Instruments TWL4030/TWL5030/TWL6030/TPS659x0 Support"
203-
depends on I2C=y && GENERIC_HARDIRQS
203+
depends on I2C=y && GENERIC_HARDIRQS && IRQ_DOMAIN
204204
help
205205
Say yes here if you have TWL4030 / TWL6030 family chip on your board.
206206
This core driver provides register access and IRQ handling

‎drivers/mfd/twl-core.c‎

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
#include <linux/platform_device.h>
3535
#include <linux/clk.h>
3636
#include <linux/err.h>
37+
#include <linux/device.h>
38+
#include <linux/of.h>
39+
#include <linux/of_irq.h>
40+
#include <linux/of_platform.h>
41+
#include <linux/irqdomain.h>
3742

3843
#include <linux/regulator/machine.h>
3944

@@ -144,6 +149,9 @@
144149

145150
#define TWL_MODULE_LAST TWL4030_MODULE_LAST
146151

152+
#define TWL4030_NR_IRQS 8
153+
#define TWL6030_NR_IRQS 20
154+
147155
/* Base Address defns for twl4030_map[] */
148156

149157
/* subchip/slave 0 - USB ID */
@@ -255,6 +263,7 @@ struct twl_client {
255263

256264
static struct twl_client twl_modules[TWL_NUM_SLAVES];
257265

266+
static struct irq_domain domain;
258267

259268
/* mapping the module id to slave id and base address */
260269
struct twl_mapping {
@@ -1183,14 +1192,48 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
11831192
int status;
11841193
unsigned i;
11851194
struct twl4030_platform_data *pdata = client->dev.platform_data;
1195+
struct device_node *node = client->dev.of_node;
11861196
u8 temp;
11871197
int ret = 0;
1198+
int nr_irqs = TWL4030_NR_IRQS;
1199+
1200+
if ((id->driver_data) & TWL6030_CLASS)
1201+
nr_irqs = TWL6030_NR_IRQS;
1202+
1203+
if (node && !pdata) {
1204+
/*
1205+
* XXX: Temporary pdata until the information is correctly
1206+
* retrieved by every TWL modules from DT.
1207+
*/
1208+
pdata = devm_kzalloc(&client->dev,
1209+
sizeof(struct twl4030_platform_data),
1210+
GFP_KERNEL);
1211+
if (!pdata)
1212+
return -ENOMEM;
1213+
}
11881214

11891215
if (!pdata) {
11901216
dev_dbg(&client->dev, "no platform data?\n");
11911217
return -EINVAL;
11921218
}
11931219

1220+
status = irq_alloc_descs(-1, pdata->irq_base, nr_irqs, 0);
1221+
if (IS_ERR_VALUE(status)) {
1222+
dev_err(&client->dev, "Fail to allocate IRQ descs\n");
1223+
return status;
1224+
}
1225+
1226+
pdata->irq_base = status;
1227+
pdata->irq_end = pdata->irq_base + nr_irqs;
1228+
1229+
domain.irq_base = pdata->irq_base;
1230+
domain.nr_irq = nr_irqs;
1231+
#ifdef CONFIG_OF_IRQ
1232+
domain.of_node = of_node_get(node);
1233+
domain.ops = &irq_domain_simple_ops;
1234+
#endif
1235+
irq_domain_add(&domain);
1236+
11941237
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) {
11951238
dev_dbg(&client->dev, "can't talk I2C?\n");
11961239
return -EIO;
@@ -1270,7 +1313,13 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
12701313
twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
12711314
}
12721315

1273-
status = add_children(pdata, id->driver_data);
1316+
#ifdef CONFIG_OF_DEVICE
1317+
if (node)
1318+
status = of_platform_populate(node, NULL, NULL, &client->dev);
1319+
else
1320+
#endif
1321+
status = add_children(pdata, id->driver_data);
1322+
12741323
fail:
12751324
if (status < 0)
12761325
twl_remove(client);

0 commit comments

Comments
 (0)