diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2012-05-16 07:11:58 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-05-20 11:27:12 -0400 |
commit | 37e13cecaa141eccce705843f5d2f7509e29bd3a (patch) | |
tree | 6f0b138f14c86ac5851b97fc3acd59c7a736ca5e /drivers/mfd/twl6040-core.c | |
parent | 1f01d60e4c0cae3416071680635f227df0020dd8 (diff) |
mfd: Add support for Device Tree to twl6040
Device tree based probing support for the core twl6040 driver. Child
devices will be created as MFD devices:
- ASoC codec is always created
- Vibra child is only created if the vibra section present in the DT blob.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/twl6040-core.c')
-rw-r--r-- | drivers/mfd/twl6040-core.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c index 9765dc2b0ca3..450a28fe8fc2 100644 --- a/drivers/mfd/twl6040-core.c +++ b/drivers/mfd/twl6040-core.c | |||
@@ -29,6 +29,10 @@ | |||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/platform_device.h> | 31 | #include <linux/platform_device.h> |
32 | #include <linux/of.h> | ||
33 | #include <linux/of_irq.h> | ||
34 | #include <linux/of_gpio.h> | ||
35 | #include <linux/of_platform.h> | ||
32 | #include <linux/gpio.h> | 36 | #include <linux/gpio.h> |
33 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
34 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
@@ -505,11 +509,12 @@ static int __devinit twl6040_probe(struct i2c_client *client, | |||
505 | const struct i2c_device_id *id) | 509 | const struct i2c_device_id *id) |
506 | { | 510 | { |
507 | struct twl6040_platform_data *pdata = client->dev.platform_data; | 511 | struct twl6040_platform_data *pdata = client->dev.platform_data; |
512 | struct device_node *node = client->dev.of_node; | ||
508 | struct twl6040 *twl6040; | 513 | struct twl6040 *twl6040; |
509 | struct mfd_cell *cell = NULL; | 514 | struct mfd_cell *cell = NULL; |
510 | int irq, ret, children = 0; | 515 | int irq, ret, children = 0; |
511 | 516 | ||
512 | if (!pdata) { | 517 | if (!pdata && !node) { |
513 | dev_err(&client->dev, "Platform data is missing\n"); | 518 | dev_err(&client->dev, "Platform data is missing\n"); |
514 | return -EINVAL; | 519 | return -EINVAL; |
515 | } | 520 | } |
@@ -560,9 +565,13 @@ static int __devinit twl6040_probe(struct i2c_client *client, | |||
560 | twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV); | 565 | twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV); |
561 | 566 | ||
562 | /* ERRATA: Automatic power-up is not possible in ES1.0 */ | 567 | /* ERRATA: Automatic power-up is not possible in ES1.0 */ |
563 | if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0) | 568 | if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0) { |
564 | twl6040->audpwron = pdata->audpwron_gpio; | 569 | if (pdata) |
565 | else | 570 | twl6040->audpwron = pdata->audpwron_gpio; |
571 | else | ||
572 | twl6040->audpwron = of_get_named_gpio(node, | ||
573 | "ti,audpwron-gpio", 0); | ||
574 | } else | ||
566 | twl6040->audpwron = -EINVAL; | 575 | twl6040->audpwron = -EINVAL; |
567 | 576 | ||
568 | if (gpio_is_valid(twl6040->audpwron)) { | 577 | if (gpio_is_valid(twl6040->audpwron)) { |
@@ -602,13 +611,13 @@ static int __devinit twl6040_probe(struct i2c_client *client, | |||
602 | twl6040_codec_rsrc[0].end = irq; | 611 | twl6040_codec_rsrc[0].end = irq; |
603 | cell->resources = twl6040_codec_rsrc; | 612 | cell->resources = twl6040_codec_rsrc; |
604 | cell->num_resources = ARRAY_SIZE(twl6040_codec_rsrc); | 613 | cell->num_resources = ARRAY_SIZE(twl6040_codec_rsrc); |
605 | if (pdata->codec) { | 614 | if (pdata && pdata->codec) { |
606 | cell->platform_data = pdata->codec; | 615 | cell->platform_data = pdata->codec; |
607 | cell->pdata_size = sizeof(*pdata->codec); | 616 | cell->pdata_size = sizeof(*pdata->codec); |
608 | } | 617 | } |
609 | children++; | 618 | children++; |
610 | 619 | ||
611 | if (pdata->vibra) { | 620 | if ((pdata && pdata->vibra) || of_find_node_by_name(node, "vibra")) { |
612 | irq = twl6040->irq_base + TWL6040_IRQ_VIB; | 621 | irq = twl6040->irq_base + TWL6040_IRQ_VIB; |
613 | 622 | ||
614 | cell = &twl6040->cells[children]; | 623 | cell = &twl6040->cells[children]; |
@@ -618,8 +627,10 @@ static int __devinit twl6040_probe(struct i2c_client *client, | |||
618 | cell->resources = twl6040_vibra_rsrc; | 627 | cell->resources = twl6040_vibra_rsrc; |
619 | cell->num_resources = ARRAY_SIZE(twl6040_vibra_rsrc); | 628 | cell->num_resources = ARRAY_SIZE(twl6040_vibra_rsrc); |
620 | 629 | ||
621 | cell->platform_data = pdata->vibra; | 630 | if (pdata && pdata->vibra) { |
622 | cell->pdata_size = sizeof(*pdata->vibra); | 631 | cell->platform_data = pdata->vibra; |
632 | cell->pdata_size = sizeof(*pdata->vibra); | ||
633 | } | ||
623 | children++; | 634 | children++; |
624 | } | 635 | } |
625 | 636 | ||