Skip to content

Commit

Permalink
Merge remote-tracking branch 'asoc/topic/wm8994' into asoc-next
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Brown committed Dec 9, 2012
2 parents 6f5716a + 98869f6 commit 06f1c66
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 208 deletions.
35 changes: 19 additions & 16 deletions drivers/mfd/wm8994-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,19 @@ static const __devinitconst struct reg_default wm1811_reva_patch[] = {
*/
static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq)
{
struct wm8994_pdata *pdata = wm8994->dev->platform_data;
struct wm8994_pdata *pdata;
struct regmap_config *regmap_config;
const struct reg_default *regmap_patch = NULL;
const char *devname;
int ret, i, patch_regs;
int pulls = 0;

if (dev_get_platdata(wm8994->dev)) {
pdata = dev_get_platdata(wm8994->dev);
wm8994->pdata = *pdata;
}
pdata = &wm8994->pdata;

dev_set_drvdata(wm8994->dev, wm8994);

/* Add the on-chip regulators first for bootstrapping */
Expand Down Expand Up @@ -604,24 +610,21 @@ static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq)
}
}

if (pdata) {
wm8994->irq_base = pdata->irq_base;
wm8994->gpio_base = pdata->gpio_base;

/* GPIO configuration is only applied if it's non-zero */
for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
if (pdata->gpio_defaults[i]) {
wm8994_set_bits(wm8994, WM8994_GPIO_1 + i,
0xffff,
pdata->gpio_defaults[i]);
}
wm8994->irq_base = pdata->irq_base;
wm8994->gpio_base = pdata->gpio_base;

/* GPIO configuration is only applied if it's non-zero */
for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
if (pdata->gpio_defaults[i]) {
wm8994_set_bits(wm8994, WM8994_GPIO_1 + i,
0xffff, pdata->gpio_defaults[i]);
}
}

wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven;
wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven;

if (pdata->spkmode_pu)
pulls |= WM8994_SPKMODE_PU;
}
if (pdata->spkmode_pu)
pulls |= WM8994_SPKMODE_PU;

/* Disable unneeded pulls */
wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2,
Expand Down
4 changes: 4 additions & 0 deletions include/linux/mfd/wm8994/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <linux/interrupt.h>
#include <linux/regmap.h>

#include <linux/mfd/wm8994/pdata.h>

enum wm8994_type {
WM8994 = 0,
WM8958 = 1,
Expand Down Expand Up @@ -55,6 +57,8 @@ struct regulator_bulk_data;
struct wm8994 {
struct mutex irq_lock;

struct wm8994_pdata pdata;

enum wm8994_type type;
int revision;
int cust_id;
Expand Down
5 changes: 5 additions & 0 deletions include/linux/mfd/wm8994/pdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ struct wm8994_pdata {
unsigned int lineout1fb:1;
unsigned int lineout2fb:1;

/* Delay between detecting a jack and starting microphone
* detect (specified in ms)
*/
int micdet_delay;

/* IRQ for microphone detection if brought out directly as a
* signal.
*/
Expand Down
79 changes: 34 additions & 45 deletions sound/soc/codecs/wm8958-dsp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path)
{
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
struct wm8994_pdata *pdata = wm8994->pdata;
struct wm8994 *control = wm8994->wm8994;
int i;

/* If the DSP is already running then noop */
Expand All @@ -210,9 +210,9 @@ static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path)
WM8958_DSP2_ENA, WM8958_DSP2_ENA);

/* If we've got user supplied MBC settings use them */
if (pdata && pdata->num_mbc_cfgs) {
if (control->pdata.num_mbc_cfgs) {
struct wm8958_mbc_cfg *cfg
= &pdata->mbc_cfgs[wm8994->mbc_cfg];
= &control->pdata.mbc_cfgs[wm8994->mbc_cfg];

for (i = 0; i < ARRAY_SIZE(cfg->coeff_regs); i++)
snd_soc_write(codec, i + WM8958_MBC_BAND_1_K_1,
Expand All @@ -239,7 +239,7 @@ static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path)
static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path)
{
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
struct wm8994_pdata *pdata = wm8994->pdata;
struct wm8994 *control = wm8994->wm8994;
int i, ena;

if (wm8994->mbc_vss)
Expand All @@ -249,26 +249,26 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path)
WM8958_DSP2_ENA, WM8958_DSP2_ENA);

/* If we've got user supplied settings use them */
if (pdata && pdata->num_mbc_cfgs) {
if (control->pdata.num_mbc_cfgs) {
struct wm8958_mbc_cfg *cfg
= &pdata->mbc_cfgs[wm8994->mbc_cfg];
= &control->pdata.mbc_cfgs[wm8994->mbc_cfg];

for (i = 0; i < ARRAY_SIZE(cfg->combined_regs); i++)
snd_soc_write(codec, i + 0x2800,
cfg->combined_regs[i]);
}

if (pdata && pdata->num_vss_cfgs) {
if (control->pdata.num_vss_cfgs) {
struct wm8958_vss_cfg *cfg
= &pdata->vss_cfgs[wm8994->vss_cfg];
= &control->pdata.vss_cfgs[wm8994->vss_cfg];

for (i = 0; i < ARRAY_SIZE(cfg->regs); i++)
snd_soc_write(codec, i + 0x2600, cfg->regs[i]);
}

if (pdata && pdata->num_vss_hpf_cfgs) {
if (control->pdata.num_vss_hpf_cfgs) {
struct wm8958_vss_hpf_cfg *cfg
= &pdata->vss_hpf_cfgs[wm8994->vss_hpf_cfg];
= &control->pdata.vss_hpf_cfgs[wm8994->vss_hpf_cfg];

for (i = 0; i < ARRAY_SIZE(cfg->regs); i++)
snd_soc_write(codec, i + 0x2400, cfg->regs[i]);
Expand Down Expand Up @@ -300,7 +300,7 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path)
static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path)
{
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
struct wm8994_pdata *pdata = wm8994->pdata;
struct wm8994 *control = wm8994->wm8994;
int i;

wm8958_dsp2_fw(codec, "ENH_EQ", wm8994->enh_eq, false);
Expand All @@ -309,9 +309,9 @@ static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path)
WM8958_DSP2_ENA, WM8958_DSP2_ENA);

/* If we've got user supplied settings use them */
if (pdata && pdata->num_enh_eq_cfgs) {
if (control->pdata.num_enh_eq_cfgs) {
struct wm8958_enh_eq_cfg *cfg
= &pdata->enh_eq_cfgs[wm8994->enh_eq_cfg];
= &control->pdata.enh_eq_cfgs[wm8994->enh_eq_cfg];

for (i = 0; i < ARRAY_SIZE(cfg->regs); i++)
snd_soc_write(codec, i + 0x2200,
Expand Down Expand Up @@ -458,7 +458,7 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol,
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
struct wm8994_pdata *pdata = wm8994->pdata;
struct wm8994 *control = wm8994->wm8994;
int value = ucontrol->value.integer.value[0];
int reg;

Expand All @@ -467,7 +467,7 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol,
if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
return -EBUSY;

if (value >= pdata->num_mbc_cfgs)
if (value >= control->pdata.num_mbc_cfgs)
return -EINVAL;

wm8994->mbc_cfg = value;
Expand Down Expand Up @@ -548,7 +548,7 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol,
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
struct wm8994_pdata *pdata = wm8994->pdata;
struct wm8994 *control = wm8994->wm8994;
int value = ucontrol->value.integer.value[0];
int reg;

Expand All @@ -557,7 +557,7 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol,
if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
return -EBUSY;

if (value >= pdata->num_vss_cfgs)
if (value >= control->pdata.num_vss_cfgs)
return -EINVAL;

wm8994->vss_cfg = value;
Expand All @@ -581,7 +581,7 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol,
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
struct wm8994_pdata *pdata = wm8994->pdata;
struct wm8994 *control = wm8994->wm8994;
int value = ucontrol->value.integer.value[0];
int reg;

Expand All @@ -590,7 +590,7 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol,
if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
return -EBUSY;

if (value >= pdata->num_vss_hpf_cfgs)
if (value >= control->pdata.num_vss_hpf_cfgs)
return -EINVAL;

wm8994->vss_hpf_cfg = value;
Expand Down Expand Up @@ -748,7 +748,7 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol,
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
struct wm8994_pdata *pdata = wm8994->pdata;
struct wm8994 *control = wm8994->wm8994;
int value = ucontrol->value.integer.value[0];
int reg;

Expand All @@ -757,7 +757,7 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol,
if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
return -EBUSY;

if (value >= pdata->num_enh_eq_cfgs)
if (value >= control->pdata.num_enh_eq_cfgs)
return -EINVAL;

wm8994->enh_eq_cfg = value;
Expand Down Expand Up @@ -883,39 +883,25 @@ static void wm8958_mbc_vss_loaded(const struct firmware *fw, void *context)
wm8994->mbc_vss = fw;
mutex_unlock(&codec->mutex);
}

/* We can't have more than one request outstanding at once so
* we daisy chain.
*/
request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
"wm8958_enh_eq.wfw", codec->dev, GFP_KERNEL,
codec, wm8958_enh_eq_loaded);
}

static void wm8958_mbc_loaded(const struct firmware *fw, void *context)
{
struct snd_soc_codec *codec = context;
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);

if (wm8958_dsp2_fw(codec, "MBC", fw, true) != 0)
return;

mutex_lock(&codec->mutex);
wm8994->mbc = fw;
mutex_unlock(&codec->mutex);

/* We can't have more than one request outstanding at once so
* we daisy chain.
*/
request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
"wm8958_mbc_vss.wfw", codec->dev, GFP_KERNEL,
codec, wm8958_mbc_vss_loaded);
if (fw && (wm8958_dsp2_fw(codec, "MBC", fw, true) == 0)) {
mutex_lock(&codec->mutex);
wm8994->mbc = fw;
mutex_unlock(&codec->mutex);
}
}

void wm8958_dsp2_init(struct snd_soc_codec *codec)
{
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
struct wm8994_pdata *pdata = wm8994->pdata;
struct wm8994 *control = wm8994->wm8994;
struct wm8994_pdata *pdata = &control->pdata;
int ret, i;

wm8994->dsp_active = -1;
Expand All @@ -932,9 +918,12 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
"wm8958_mbc.wfw", codec->dev, GFP_KERNEL,
codec, wm8958_mbc_loaded);

if (!pdata)
return;
request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
"wm8958_mbc_vss.wfw", codec->dev, GFP_KERNEL,
codec, wm8958_mbc_vss_loaded);
request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
"wm8958_enh_eq.wfw", codec->dev, GFP_KERNEL,
codec, wm8958_enh_eq_loaded);

if (pdata->num_mbc_cfgs) {
struct snd_kcontrol_new control[] = {
Expand Down
Loading

0 comments on commit 06f1c66

Please sign in to comment.