Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186931
b: refs/heads/master
c: 473fe73
h: refs/heads/master
i:
  186929: 4f69b78
  186927: 9a5749d
v: v3
  • Loading branch information
Mark Brown authored and Samuel Ortiz committed Mar 7, 2010
1 parent 6eef8ed commit cab23e3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 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: d19663ac61a6e36eec655d3c84a106686ebddd2c
refs/heads/master: 473fe73650b9f92114edbedfbb616561c1a0026c
36 changes: 29 additions & 7 deletions trunk/drivers/mfd/wm831x-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ EXPORT_SYMBOL_GPL(wm831x_set_bits);
*/
int wm831x_auxadc_read(struct wm831x *wm831x, enum wm831x_auxadc input)
{
int tries = 10;
int ret, src;

mutex_lock(&wm831x->auxadc_lock);
Expand Down Expand Up @@ -349,13 +348,14 @@ int wm831x_auxadc_read(struct wm831x *wm831x, enum wm831x_auxadc input)
goto disable;
}

do {
msleep(1);
/* Ignore the result to allow us to soldier on without IRQ hookup */
wait_for_completion_timeout(&wm831x->auxadc_done, msecs_to_jiffies(5));

ret = wm831x_reg_read(wm831x, WM831X_AUXADC_CONTROL);
if (ret < 0)
ret = WM831X_AUX_CVT_ENA;
} while ((ret & WM831X_AUX_CVT_ENA) && --tries);
ret = wm831x_reg_read(wm831x, WM831X_AUXADC_CONTROL);
if (ret < 0) {
dev_err(wm831x->dev, "AUXADC status read failed: %d\n", ret);
goto disable;
}

if (ret & WM831X_AUX_CVT_ENA) {
dev_err(wm831x->dev, "Timed out reading AUXADC\n");
Expand Down Expand Up @@ -390,6 +390,15 @@ int wm831x_auxadc_read(struct wm831x *wm831x, enum wm831x_auxadc input)
}
EXPORT_SYMBOL_GPL(wm831x_auxadc_read);

static irqreturn_t wm831x_auxadc_irq(int irq, void *irq_data)
{
struct wm831x *wm831x = irq_data;

complete(&wm831x->auxadc_done);

return IRQ_HANDLED;
}

/**
* wm831x_auxadc_read_uv: Read a voltage from the WM831x AUXADC
*
Expand Down Expand Up @@ -1411,6 +1420,7 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
mutex_init(&wm831x->io_lock);
mutex_init(&wm831x->key_lock);
mutex_init(&wm831x->auxadc_lock);
init_completion(&wm831x->auxadc_done);
dev_set_drvdata(wm831x->dev, wm831x);

ret = wm831x_reg_read(wm831x, WM831X_PARENT_ID);
Expand Down Expand Up @@ -1523,6 +1533,16 @@ static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
if (ret != 0)
goto err;

if (wm831x->irq_base) {
ret = request_threaded_irq(wm831x->irq_base +
WM831X_IRQ_AUXADC_DATA,
NULL, wm831x_auxadc_irq, 0,
"auxadc", wm831x);
if (ret < 0)
dev_err(wm831x->dev, "AUXADC IRQ request failed: %d\n",
ret);
}

/* The core device is up, instantiate the subdevices. */
switch (parent) {
case WM8310:
Expand Down Expand Up @@ -1593,6 +1613,8 @@ static void wm831x_device_exit(struct wm831x *wm831x)
{
wm831x_otp_exit(wm831x);
mfd_remove_devices(wm831x->dev);
if (wm831x->irq_base)
free_irq(wm831x->irq_base + WM831X_IRQ_AUXADC_DATA, wm831x);
wm831x_irq_exit(wm831x);
kfree(wm831x);
}
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/mfd/wm831x/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef __MFD_WM831X_CORE_H__
#define __MFD_WM831X_CORE_H__

#include <linux/completion.h>
#include <linux/interrupt.h>

/*
Expand Down Expand Up @@ -261,6 +262,7 @@ struct wm831x {
int num_gpio;

struct mutex auxadc_lock;
struct completion auxadc_done;

/* The WM831x has a security key blocking access to certain
* registers. The mutex is taken by the accessors for locking
Expand Down

0 comments on commit cab23e3

Please sign in to comment.