Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 308730
b: refs/heads/master
c: 5af7df6
h: refs/heads/master
v: v3
  • Loading branch information
Peter Ujfalusi authored and Samuel Ortiz committed May 9, 2012
1 parent 571fc43 commit 6c2179c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 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: 5a2f1b5fae593dbdf4f3656ee5a5d111df3e9acb
refs/heads/master: 5af7df6b831ef9fd5fbde9d4bbd596f742cb2ad8
33 changes: 29 additions & 4 deletions trunk/drivers/mfd/twl6040-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/delay.h>
Expand All @@ -35,8 +36,10 @@
#include <linux/err.h>
#include <linux/mfd/core.h>
#include <linux/mfd/twl6040.h>
#include <linux/regulator/consumer.h>

#define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1)
#define TWL6040_NUM_SUPPLIES (2)

int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
{
Expand Down Expand Up @@ -532,6 +535,21 @@ static int __devinit twl6040_probe(struct i2c_client *client,

i2c_set_clientdata(client, twl6040);

twl6040->supplies[0].supply = "vio";
twl6040->supplies[1].supply = "v2v1";
ret = regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES,
twl6040->supplies);
if (ret != 0) {
dev_err(&client->dev, "Failed to get supplies: %d\n", ret);
goto regulator_get_err;
}

ret = regulator_bulk_enable(TWL6040_NUM_SUPPLIES, twl6040->supplies);
if (ret != 0) {
dev_err(&client->dev, "Failed to enable supplies: %d\n", ret);
goto power_err;
}

twl6040->dev = &client->dev;
twl6040->irq = client->irq;
twl6040->irq_base = pdata->irq_base;
Expand All @@ -552,13 +570,13 @@ static int __devinit twl6040_probe(struct i2c_client *client,
ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW,
"audpwron");
if (ret)
goto gpio1_err;
goto gpio_err;
}

/* codec interrupt */
ret = twl6040_irq_init(twl6040);
if (ret)
goto gpio2_err;
goto irq_init_err;

ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY,
NULL, twl6040_naudint_handler, 0,
Expand Down Expand Up @@ -618,10 +636,14 @@ static int __devinit twl6040_probe(struct i2c_client *client,
free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
irq_err:
twl6040_irq_exit(twl6040);
gpio2_err:
irq_init_err:
if (gpio_is_valid(twl6040->audpwron))
gpio_free(twl6040->audpwron);
gpio1_err:
gpio_err:
regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies);
power_err:
regulator_bulk_free(TWL6040_NUM_SUPPLIES, twl6040->supplies);
regulator_get_err:
i2c_set_clientdata(client, NULL);
err:
return ret;
Expand All @@ -643,6 +665,9 @@ static int __devexit twl6040_remove(struct i2c_client *client)
mfd_remove_devices(&client->dev);
i2c_set_clientdata(client, NULL);

regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies);
regulator_bulk_free(TWL6040_NUM_SUPPLIES, twl6040->supplies);

return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/mfd/twl6040.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <linux/interrupt.h>
#include <linux/mfd/core.h>
#include <linux/regulator/consumer.h>

#define TWL6040_REG_ASICID 0x01
#define TWL6040_REG_ASICREV 0x02
Expand Down Expand Up @@ -203,6 +204,7 @@ struct regmap;
struct twl6040 {
struct device *dev;
struct regmap *regmap;
struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */
struct mutex mutex;
struct mutex io_mutex;
struct mutex irq_mutex;
Expand Down

0 comments on commit 6c2179c

Please sign in to comment.