提交 9e178620 编写于 作者: F Felipe Balbi 提交者: Samuel Ortiz

mfd: Make twl-core not depend on pdata->irq_base/end

With sparse IRQs the driver shouldn't depend at all on
any IRQ values coming from board-file.

Remove every occurences of pdata->irq_base/end.
Signed-off-by: NFelipe Balbi <balbi@ti.com>
Signed-off-by: NBenoit Cousson <b-cousson@ti.com>
Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
上级 9d4a4199
...@@ -652,7 +652,8 @@ add_regulator(int num, struct regulator_init_data *pdata, ...@@ -652,7 +652,8 @@ add_regulator(int num, struct regulator_init_data *pdata,
*/ */
static int 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; struct device *child;
unsigned sub_chip_id; unsigned sub_chip_id;
...@@ -660,7 +661,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) ...@@ -660,7 +661,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
if (twl_has_gpio() && pdata->gpio) { if (twl_has_gpio() && pdata->gpio) {
child = add_child(SUB_CHIP_ID1, "twl4030_gpio", child = add_child(SUB_CHIP_ID1, "twl4030_gpio",
pdata->gpio, sizeof(*pdata->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)) if (IS_ERR(child))
return PTR_ERR(child); return PTR_ERR(child);
} }
...@@ -668,7 +669,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) ...@@ -668,7 +669,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
if (twl_has_keypad() && pdata->keypad) { if (twl_has_keypad() && pdata->keypad) {
child = add_child(SUB_CHIP_ID2, "twl4030_keypad", child = add_child(SUB_CHIP_ID2, "twl4030_keypad",
pdata->keypad, sizeof(*pdata->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)) if (IS_ERR(child))
return PTR_ERR(child); return PTR_ERR(child);
} }
...@@ -676,7 +677,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) ...@@ -676,7 +677,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
if (twl_has_madc() && pdata->madc) { if (twl_has_madc() && pdata->madc) {
child = add_child(2, "twl4030_madc", child = add_child(2, "twl4030_madc",
pdata->madc, sizeof(*pdata->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)) if (IS_ERR(child))
return PTR_ERR(child); return PTR_ERR(child);
} }
...@@ -692,7 +693,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) ...@@ -692,7 +693,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
sub_chip_id = twl_map[TWL_MODULE_RTC].sid; sub_chip_id = twl_map[TWL_MODULE_RTC].sid;
child = add_child(sub_chip_id, "twl_rtc", child = add_child(sub_chip_id, "twl_rtc",
NULL, 0, NULL, 0,
true, pdata->irq_base + RTC_INTR_OFFSET, 0); true, irq_base + RTC_INTR_OFFSET, 0);
if (IS_ERR(child)) if (IS_ERR(child))
return PTR_ERR(child); return PTR_ERR(child);
} }
...@@ -745,8 +746,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) ...@@ -745,8 +746,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
pdata->usb, sizeof(*pdata->usb), pdata->usb, sizeof(*pdata->usb),
true, true,
/* irq0 = USB_PRES, irq1 = USB */ /* irq0 = USB_PRES, irq1 = USB */
pdata->irq_base + USB_PRES_INTR_OFFSET, irq_base + USB_PRES_INTR_OFFSET,
pdata->irq_base + USB_INTR_OFFSET); irq_base + USB_INTR_OFFSET);
if (IS_ERR(child)) if (IS_ERR(child))
return PTR_ERR(child); return PTR_ERR(child);
...@@ -794,8 +795,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) ...@@ -794,8 +795,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
pdata->usb, sizeof(*pdata->usb), pdata->usb, sizeof(*pdata->usb),
true, true,
/* irq1 = VBUS_PRES, irq0 = USB ID */ /* irq1 = VBUS_PRES, irq0 = USB ID */
pdata->irq_base + USBOTG_INTR_OFFSET, irq_base + USBOTG_INTR_OFFSET,
pdata->irq_base + USB_PRES_INTR_OFFSET); irq_base + USB_PRES_INTR_OFFSET);
if (IS_ERR(child)) if (IS_ERR(child))
return PTR_ERR(child); return PTR_ERR(child);
...@@ -822,7 +823,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) ...@@ -822,7 +823,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
if (twl_has_pwrbutton() && twl_class_is_4030()) { if (twl_has_pwrbutton() && twl_class_is_4030()) {
child = add_child(1, "twl4030_pwrbutton", 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)) if (IS_ERR(child))
return PTR_ERR(child); return PTR_ERR(child);
} }
...@@ -1056,8 +1057,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) ...@@ -1056,8 +1057,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
child = add_child(3, "twl4030_bci", child = add_child(3, "twl4030_bci",
pdata->bci, sizeof(*pdata->bci), false, pdata->bci, sizeof(*pdata->bci), false,
/* irq0 = CHG_PRES, irq1 = BCI */ /* irq0 = CHG_PRES, irq1 = BCI */
pdata->irq_base + BCI_PRES_INTR_OFFSET, irq_base + BCI_PRES_INTR_OFFSET,
pdata->irq_base + BCI_INTR_OFFSET); irq_base + BCI_INTR_OFFSET);
if (IS_ERR(child)) if (IS_ERR(child))
return PTR_ERR(child); return PTR_ERR(child);
} }
...@@ -1191,6 +1192,8 @@ static int twl_remove(struct i2c_client *client) ...@@ -1191,6 +1192,8 @@ static int twl_remove(struct i2c_client *client)
static int __devinit static int __devinit
twl_probe(struct i2c_client *client, const struct i2c_device_id *id) twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
{ {
int irq_base;
int irq_end;
int status; int status;
unsigned i; unsigned i;
struct twl4030_platform_data *pdata = client->dev.platform_data; struct twl4030_platform_data *pdata = client->dev.platform_data;
...@@ -1219,22 +1222,16 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -1219,22 +1222,16 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
return -EINVAL; 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)) { if (IS_ERR_VALUE(status)) {
dev_err(&client->dev, "Fail to allocate IRQ descs\n"); dev_err(&client->dev, "Fail to allocate IRQ descs\n");
return status; return status;
} }
pdata->irq_base = status; irq_base = status;
pdata->irq_end = pdata->irq_base + nr_irqs; irq_end = irq_base + nr_irqs;
irq_domain_add_legacy(node, nr_irqs, irq_base, 0,
#ifdef CONFIG_IRQ_DOMAIN &irq_domain_simple_ops, NULL);
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
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) {
dev_dbg(&client->dev, "can't talk I2C?\n"); dev_dbg(&client->dev, "can't talk I2C?\n");
...@@ -1287,16 +1284,14 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -1287,16 +1284,14 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
twl4030_power_init(pdata->power); twl4030_power_init(pdata->power);
/* Maybe init the T2 Interrupt subsystem */ /* Maybe init the T2 Interrupt subsystem */
if (client->irq if (client->irq) {
&& pdata->irq_base
&& pdata->irq_end > pdata->irq_base) {
if (twl_class_is_4030()) { if (twl_class_is_4030()) {
twl4030_init_chip_irq(id->name); twl4030_init_chip_irq(id->name);
status = twl4030_init_irq(client->irq, pdata->irq_base, status = twl4030_init_irq(client->irq, irq_base,
pdata->irq_end); irq_end);
} else { } else {
status = twl6030_init_irq(client->irq, pdata->irq_base, status = twl6030_init_irq(client->irq, irq_base,
pdata->irq_end); irq_end);
} }
if (status < 0) if (status < 0)
...@@ -1315,12 +1310,10 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -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); twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
} }
#ifdef CONFIG_OF_DEVICE
if (node) if (node)
status = of_platform_populate(node, NULL, NULL, &client->dev); status = of_platform_populate(node, NULL, NULL, &client->dev);
else if (status)
#endif status = add_children(pdata, irq_base, id->driver_data);
status = add_children(pdata, id->driver_data);
fail: fail:
if (status < 0) if (status < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册