Commit d96ca3cd authored by Mark Brown's avatar Mark Brown

ASoC: Implement DC servo completion IRQ handling for wm_hubs devices

The individual devices should set the flag dcs_done_irq in the hubs
shared data structure to indicate that they will flag the interrupt
by calling wm_hubs_dcs_done().
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent b70a51ba
...@@ -63,9 +63,11 @@ static const struct soc_enum speaker_mode = ...@@ -63,9 +63,11 @@ static const struct soc_enum speaker_mode =
static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op) static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
unsigned int reg; unsigned int reg;
int count = 0; int count = 0;
unsigned int val; unsigned int val;
unsigned long timeout;
val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1; val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1;
...@@ -74,18 +76,37 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op) ...@@ -74,18 +76,37 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
dev_dbg(codec->dev, "Waiting for DC servo...\n"); dev_dbg(codec->dev, "Waiting for DC servo...\n");
do { if (hubs->dcs_done_irq) {
count++; timeout = wait_for_completion_timeout(&hubs->dcs_done,
msleep(1); msecs_to_jiffies(500));
if (timeout == 0)
dev_warn(codec->dev, "No DC servo interrupt\n");
reg = snd_soc_read(codec, WM8993_DC_SERVO_0); reg = snd_soc_read(codec, WM8993_DC_SERVO_0);
dev_dbg(codec->dev, "DC servo: %x\n", reg); } else {
} while (reg & op && count < 400); do {
count++;
msleep(1);
reg = snd_soc_read(codec, WM8993_DC_SERVO_0);
dev_dbg(codec->dev, "DC servo: %x\n", reg);
} while (reg & op && count < 400);
}
if (reg & op) if (reg & op)
dev_err(codec->dev, "Timed out waiting for DC Servo %x\n", dev_err(codec->dev, "Timed out waiting for DC Servo %x\n",
op); op);
} }
irqreturn_t wm_hubs_dcs_done(int irq, void *data)
{
struct wm_hubs_data *hubs = data;
complete(&hubs->dcs_done);
return IRQ_HANDLED;
}
EXPORT_SYMBOL_GPL(wm_hubs_dcs_done);
/* /*
* Startup calibration of the DC servo * Startup calibration of the DC servo
*/ */
...@@ -863,8 +884,11 @@ EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls); ...@@ -863,8 +884,11 @@ EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls);
int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec, int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec,
int lineout1_diff, int lineout2_diff) int lineout1_diff, int lineout2_diff)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_dapm_context *dapm = &codec->dapm;
init_completion(&hubs->dcs_done);
snd_soc_dapm_add_routes(dapm, analogue_routes, snd_soc_dapm_add_routes(dapm, analogue_routes,
ARRAY_SIZE(analogue_routes)); ARRAY_SIZE(analogue_routes));
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
#ifndef _WM_HUBS_H #ifndef _WM_HUBS_H
#define _WM_HUBS_H #define _WM_HUBS_H
#include <linux/completion.h>
#include <linux/interrupt.h>
struct snd_soc_codec; struct snd_soc_codec;
extern const unsigned int wm_hubs_spkmix_tlv[]; extern const unsigned int wm_hubs_spkmix_tlv[];
...@@ -28,6 +31,9 @@ struct wm_hubs_data { ...@@ -28,6 +31,9 @@ struct wm_hubs_data {
bool class_w; bool class_w;
u16 class_w_dcs; u16 class_w_dcs;
bool dcs_done_irq;
struct completion dcs_done;
}; };
extern int wm_hubs_add_analogue_controls(struct snd_soc_codec *); extern int wm_hubs_add_analogue_controls(struct snd_soc_codec *);
...@@ -38,4 +44,6 @@ extern int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *, ...@@ -38,4 +44,6 @@ extern int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *,
int jd_scthr, int jd_thr, int jd_scthr, int jd_thr,
int micbias1_lvl, int micbias2_lvl); int micbias1_lvl, int micbias2_lvl);
extern irqreturn_t wm_hubs_dcs_done(int irq, void *data);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment