Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 296890
b: refs/heads/master
c: 9e17862
h: refs/heads/master
v: v3
  • Loading branch information
Felipe Balbi authored and Samuel Ortiz committed Mar 22, 2012
1 parent 6ff003d commit ff64e6c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d4a4199e7029b4f1e8daa10b6839839a9fb89a7
refs/heads/master: 9e1786202704f199941f7c2f5c9fe12879de7917
61 changes: 27 additions & 34 deletions trunk/drivers/mfd/twl-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,31 +652,32 @@ add_regulator(int num, struct regulator_init_data *pdata,
*/

static int
add_children(struct twl4030_platform_data *pdata, unsigned long features)
add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
unsigned long features)
{
struct device *child;
unsigned sub_chip_id;

if (twl_has_gpio() && pdata->gpio) {
child = add_child(SUB_CHIP_ID1, "twl4030_gpio",
pdata->gpio, sizeof(*pdata->gpio),
false, pdata->irq_base + GPIO_INTR_OFFSET, 0);
false, irq_base + GPIO_INTR_OFFSET, 0);
if (IS_ERR(child))
return PTR_ERR(child);
}

if (twl_has_keypad() && pdata->keypad) {
child = add_child(SUB_CHIP_ID2, "twl4030_keypad",
pdata->keypad, sizeof(*pdata->keypad),
true, pdata->irq_base + KEYPAD_INTR_OFFSET, 0);
true, irq_base + KEYPAD_INTR_OFFSET, 0);
if (IS_ERR(child))
return PTR_ERR(child);
}

if (twl_has_madc() && pdata->madc) {
child = add_child(2, "twl4030_madc",
pdata->madc, sizeof(*pdata->madc),
true, pdata->irq_base + MADC_INTR_OFFSET, 0);
true, irq_base + MADC_INTR_OFFSET, 0);
if (IS_ERR(child))
return PTR_ERR(child);
}
Expand All @@ -692,7 +693,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
sub_chip_id = twl_map[TWL_MODULE_RTC].sid;
child = add_child(sub_chip_id, "twl_rtc",
NULL, 0,
true, pdata->irq_base + RTC_INTR_OFFSET, 0);
true, irq_base + RTC_INTR_OFFSET, 0);
if (IS_ERR(child))
return PTR_ERR(child);
}
Expand Down Expand Up @@ -745,8 +746,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
pdata->usb, sizeof(*pdata->usb),
true,
/* irq0 = USB_PRES, irq1 = USB */
pdata->irq_base + USB_PRES_INTR_OFFSET,
pdata->irq_base + USB_INTR_OFFSET);
irq_base + USB_PRES_INTR_OFFSET,
irq_base + USB_INTR_OFFSET);

if (IS_ERR(child))
return PTR_ERR(child);
Expand Down Expand Up @@ -794,8 +795,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
pdata->usb, sizeof(*pdata->usb),
true,
/* irq1 = VBUS_PRES, irq0 = USB ID */
pdata->irq_base + USBOTG_INTR_OFFSET,
pdata->irq_base + USB_PRES_INTR_OFFSET);
irq_base + USBOTG_INTR_OFFSET,
irq_base + USB_PRES_INTR_OFFSET);

if (IS_ERR(child))
return PTR_ERR(child);
Expand All @@ -822,7 +823,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)

if (twl_has_pwrbutton() && twl_class_is_4030()) {
child = add_child(1, "twl4030_pwrbutton",
NULL, 0, true, pdata->irq_base + 8 + 0, 0);
NULL, 0, true, irq_base + 8 + 0, 0);
if (IS_ERR(child))
return PTR_ERR(child);
}
Expand Down Expand Up @@ -1056,8 +1057,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
child = add_child(3, "twl4030_bci",
pdata->bci, sizeof(*pdata->bci), false,
/* irq0 = CHG_PRES, irq1 = BCI */
pdata->irq_base + BCI_PRES_INTR_OFFSET,
pdata->irq_base + BCI_INTR_OFFSET);
irq_base + BCI_PRES_INTR_OFFSET,
irq_base + BCI_INTR_OFFSET);
if (IS_ERR(child))
return PTR_ERR(child);
}
Expand Down Expand Up @@ -1191,6 +1192,8 @@ static int twl_remove(struct i2c_client *client)
static int __devinit
twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
int irq_base;
int irq_end;
int status;
unsigned i;
struct twl4030_platform_data *pdata = client->dev.platform_data;
Expand Down Expand Up @@ -1219,22 +1222,16 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
return -EINVAL;
}

status = irq_alloc_descs(-1, pdata->irq_base, nr_irqs, 0);
status = irq_alloc_descs(-1, 0, nr_irqs, 0);
if (IS_ERR_VALUE(status)) {
dev_err(&client->dev, "Fail to allocate IRQ descs\n");
return status;
}

pdata->irq_base = status;
pdata->irq_end = pdata->irq_base + nr_irqs;

#ifdef CONFIG_IRQ_DOMAIN
domain.irq_base = pdata->irq_base;
domain.nr_irq = nr_irqs;
domain.of_node = of_node_get(node);
domain.ops = &irq_domain_simple_ops;
irq_domain_add(&domain);
#endif
irq_base = status;
irq_end = irq_base + nr_irqs;
irq_domain_add_legacy(node, nr_irqs, irq_base, 0,
&irq_domain_simple_ops, NULL);

if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) {
dev_dbg(&client->dev, "can't talk I2C?\n");
Expand Down Expand Up @@ -1287,16 +1284,14 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
twl4030_power_init(pdata->power);

/* Maybe init the T2 Interrupt subsystem */
if (client->irq
&& pdata->irq_base
&& pdata->irq_end > pdata->irq_base) {
if (client->irq) {
if (twl_class_is_4030()) {
twl4030_init_chip_irq(id->name);
status = twl4030_init_irq(client->irq, pdata->irq_base,
pdata->irq_end);
status = twl4030_init_irq(client->irq, irq_base,
irq_end);
} else {
status = twl6030_init_irq(client->irq, pdata->irq_base,
pdata->irq_end);
status = twl6030_init_irq(client->irq, irq_base,
irq_end);
}

if (status < 0)
Expand All @@ -1315,12 +1310,10 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
}

#ifdef CONFIG_OF_DEVICE
if (node)
status = of_platform_populate(node, NULL, NULL, &client->dev);
else
#endif
status = add_children(pdata, id->driver_data);
if (status)
status = add_children(pdata, irq_base, id->driver_data);

fail:
if (status < 0)
Expand Down

0 comments on commit ff64e6c

Please sign in to comment.