diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2012-05-02 09:54:42 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-05-09 15:55:45 -0400 |
commit | 5af7df6b831ef9fd5fbde9d4bbd596f742cb2ad8 (patch) | |
tree | 83e1369eafeb492e0c53293870d2c9a137fc0399 | |
parent | 5a2f1b5fae593dbdf4f3656ee5a5d111df3e9acb (diff) |
mfd: Add regulator support for twl6040 VIO, V2V1 supplies
twl6040 has three power supply source:
VBAT needs to be connected to VBAT, VIO, and V2V1.
Add regulator support for the VIO, V2V1 supplies.
Initially handle the two supply together with bulk commands.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | drivers/mfd/twl6040-core.c | 33 | ||||
-rw-r--r-- | include/linux/mfd/twl6040.h | 2 |
2 files changed, 31 insertions, 4 deletions
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c index 493f4a692747..7a92d95bfb60 100644 --- a/drivers/mfd/twl6040-core.c +++ b/drivers/mfd/twl6040-core.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/err.h> | ||
30 | #include <linux/platform_device.h> | 31 | #include <linux/platform_device.h> |
31 | #include <linux/gpio.h> | 32 | #include <linux/gpio.h> |
32 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
@@ -35,8 +36,10 @@ | |||
35 | #include <linux/err.h> | 36 | #include <linux/err.h> |
36 | #include <linux/mfd/core.h> | 37 | #include <linux/mfd/core.h> |
37 | #include <linux/mfd/twl6040.h> | 38 | #include <linux/mfd/twl6040.h> |
39 | #include <linux/regulator/consumer.h> | ||
38 | 40 | ||
39 | #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) | 41 | #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) |
42 | #define TWL6040_NUM_SUPPLIES (2) | ||
40 | 43 | ||
41 | int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) | 44 | int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) |
42 | { | 45 | { |
@@ -532,6 +535,21 @@ static int __devinit twl6040_probe(struct i2c_client *client, | |||
532 | 535 | ||
533 | i2c_set_clientdata(client, twl6040); | 536 | i2c_set_clientdata(client, twl6040); |
534 | 537 | ||
538 | twl6040->supplies[0].supply = "vio"; | ||
539 | twl6040->supplies[1].supply = "v2v1"; | ||
540 | ret = regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES, | ||
541 | twl6040->supplies); | ||
542 | if (ret != 0) { | ||
543 | dev_err(&client->dev, "Failed to get supplies: %d\n", ret); | ||
544 | goto regulator_get_err; | ||
545 | } | ||
546 | |||
547 | ret = regulator_bulk_enable(TWL6040_NUM_SUPPLIES, twl6040->supplies); | ||
548 | if (ret != 0) { | ||
549 | dev_err(&client->dev, "Failed to enable supplies: %d\n", ret); | ||
550 | goto power_err; | ||
551 | } | ||
552 | |||
535 | twl6040->dev = &client->dev; | 553 | twl6040->dev = &client->dev; |
536 | twl6040->irq = client->irq; | 554 | twl6040->irq = client->irq; |
537 | twl6040->irq_base = pdata->irq_base; | 555 | twl6040->irq_base = pdata->irq_base; |
@@ -552,13 +570,13 @@ static int __devinit twl6040_probe(struct i2c_client *client, | |||
552 | ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW, | 570 | ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW, |
553 | "audpwron"); | 571 | "audpwron"); |
554 | if (ret) | 572 | if (ret) |
555 | goto gpio1_err; | 573 | goto gpio_err; |
556 | } | 574 | } |
557 | 575 | ||
558 | /* codec interrupt */ | 576 | /* codec interrupt */ |
559 | ret = twl6040_irq_init(twl6040); | 577 | ret = twl6040_irq_init(twl6040); |
560 | if (ret) | 578 | if (ret) |
561 | goto gpio2_err; | 579 | goto irq_init_err; |
562 | 580 | ||
563 | ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY, | 581 | ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY, |
564 | NULL, twl6040_naudint_handler, 0, | 582 | NULL, twl6040_naudint_handler, 0, |
@@ -618,10 +636,14 @@ mfd_err: | |||
618 | free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040); | 636 | free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040); |
619 | irq_err: | 637 | irq_err: |
620 | twl6040_irq_exit(twl6040); | 638 | twl6040_irq_exit(twl6040); |
621 | gpio2_err: | 639 | irq_init_err: |
622 | if (gpio_is_valid(twl6040->audpwron)) | 640 | if (gpio_is_valid(twl6040->audpwron)) |
623 | gpio_free(twl6040->audpwron); | 641 | gpio_free(twl6040->audpwron); |
624 | gpio1_err: | 642 | gpio_err: |
643 | regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies); | ||
644 | power_err: | ||
645 | regulator_bulk_free(TWL6040_NUM_SUPPLIES, twl6040->supplies); | ||
646 | regulator_get_err: | ||
625 | i2c_set_clientdata(client, NULL); | 647 | i2c_set_clientdata(client, NULL); |
626 | err: | 648 | err: |
627 | return ret; | 649 | return ret; |
@@ -643,6 +665,9 @@ static int __devexit twl6040_remove(struct i2c_client *client) | |||
643 | mfd_remove_devices(&client->dev); | 665 | mfd_remove_devices(&client->dev); |
644 | i2c_set_clientdata(client, NULL); | 666 | i2c_set_clientdata(client, NULL); |
645 | 667 | ||
668 | regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies); | ||
669 | regulator_bulk_free(TWL6040_NUM_SUPPLIES, twl6040->supplies); | ||
670 | |||
646 | return 0; | 671 | return 0; |
647 | } | 672 | } |
648 | 673 | ||
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h index b15b5f03f5c4..6659487c31e7 100644 --- a/include/linux/mfd/twl6040.h +++ b/include/linux/mfd/twl6040.h | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
29 | #include <linux/mfd/core.h> | 29 | #include <linux/mfd/core.h> |
30 | #include <linux/regulator/consumer.h> | ||
30 | 31 | ||
31 | #define TWL6040_REG_ASICID 0x01 | 32 | #define TWL6040_REG_ASICID 0x01 |
32 | #define TWL6040_REG_ASICREV 0x02 | 33 | #define TWL6040_REG_ASICREV 0x02 |
@@ -203,6 +204,7 @@ struct regmap; | |||
203 | struct twl6040 { | 204 | struct twl6040 { |
204 | struct device *dev; | 205 | struct device *dev; |
205 | struct regmap *regmap; | 206 | struct regmap *regmap; |
207 | struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */ | ||
206 | struct mutex mutex; | 208 | struct mutex mutex; |
207 | struct mutex io_mutex; | 209 | struct mutex io_mutex; |
208 | struct mutex irq_mutex; | 210 | struct mutex irq_mutex; |