Skip to content

Commit 3a42315

Browse files
committed
ASoC: Initial WM8958 audio configuration
The WM8958 is a WM8994 derivative. This patch merely ensures that some revision specific configuration for WM8994 is not enabled on WM8994, additional patches will add support for the new features introduced on the WM8958. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
1 parent 11cef5f commit 3a42315

1 file changed

Lines changed: 76 additions & 34 deletions

File tree

‎sound/soc/codecs/wm8994.c‎

Lines changed: 76 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,
15351535
static int wm8994_set_bias_level(struct snd_soc_codec *codec,
15361536
enum snd_soc_bias_level level)
15371537
{
1538+
struct wm8994 *control = codec->control_data;
15381539
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
15391540

15401541
switch (level) {
@@ -1551,7 +1552,7 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
15511552
if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
15521553
/* Tweak DC servo and DSP configuration for
15531554
* improved performance. */
1554-
if (wm8994->revision < 4) {
1555+
if (control->type == WM8994 && wm8994->revision < 4) {
15551556
/* Tweak DC servo and DSP configuration for
15561557
* improved performance. */
15571558
snd_soc_write(codec, 0x102, 0x3);
@@ -2264,8 +2265,12 @@ int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
22642265
{
22652266
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
22662267
struct wm8994_micdet *micdet;
2268+
struct wm8994 *control = codec->control_data;
22672269
int reg;
22682270

2271+
if (control->type != WM8994)
2272+
return -EINVAL;
2273+
22692274
switch (micbias) {
22702275
case 1:
22712276
micdet = &wm8994->micdet[0];
@@ -2334,11 +2339,13 @@ static irqreturn_t wm8994_mic_irq(int irq, void *data)
23342339

23352340
static int wm8994_codec_probe(struct snd_soc_codec *codec)
23362341
{
2342+
struct wm8994 *control;
23372343
struct wm8994_priv *wm8994;
23382344
struct snd_soc_dapm_context *dapm = &codec->dapm;
23392345
int ret, i;
23402346

23412347
codec->control_data = dev_get_drvdata(codec->dev->parent);
2348+
control = codec->control_data;
23422349

23432350
wm8994 = kzalloc(sizeof(struct wm8994_priv), GFP_KERNEL);
23442351
if (wm8994 == NULL)
@@ -2369,41 +2376,67 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
23692376

23702377
/* Set revision-specific configuration */
23712378
wm8994->revision = snd_soc_read(codec, WM8994_CHIP_REVISION);
2372-
switch (wm8994->revision) {
2373-
case 2:
2374-
case 3:
2375-
wm8994->hubs.dcs_codes = -5;
2376-
wm8994->hubs.hp_startup_mode = 1;
2379+
switch (control->type) {
2380+
case WM8994:
2381+
switch (wm8994->revision) {
2382+
case 2:
2383+
case 3:
2384+
wm8994->hubs.dcs_codes = -5;
2385+
wm8994->hubs.hp_startup_mode = 1;
2386+
wm8994->hubs.dcs_readback_mode = 1;
2387+
break;
2388+
default:
2389+
wm8994->hubs.dcs_readback_mode = 1;
2390+
break;
2391+
}
2392+
2393+
case WM8958:
23772394
wm8994->hubs.dcs_readback_mode = 1;
23782395
break;
2396+
23792397
default:
2380-
wm8994->hubs.dcs_readback_mode = 1;
23812398
break;
23822399
}
23832400

2384-
ret = wm8994_request_irq(codec->control_data, WM8994_IRQ_MIC1_DET,
2385-
wm8994_mic_irq, "Mic 1 detect", wm8994);
2386-
if (ret != 0)
2387-
dev_warn(codec->dev,
2388-
"Failed to request Mic1 detect IRQ: %d\n", ret);
2389-
2390-
ret = wm8994_request_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT,
2391-
wm8994_mic_irq, "Mic 1 short", wm8994);
2392-
if (ret != 0)
2393-
dev_warn(codec->dev,
2394-
"Failed to request Mic1 short IRQ: %d\n", ret);
2395-
2396-
ret = wm8994_request_irq(codec->control_data, WM8994_IRQ_MIC2_DET,
2397-
wm8994_mic_irq, "Mic 2 detect", wm8994);
2398-
if (ret != 0)
2399-
dev_warn(codec->dev,
2400-
"Failed to request Mic2 detect IRQ: %d\n", ret);
2401-
2402-
ret = wm8994_request_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT,
2403-
wm8994_mic_irq, "Mic 2 short", wm8994);
2404-
if (ret != 0)
2405-
dev_warn(codec->dev,
2406-
"Failed to request Mic2 short IRQ: %d\n", ret);
2401+
switch (control->type) {
2402+
case WM8994:
2403+
ret = wm8994_request_irq(codec->control_data,
2404+
WM8994_IRQ_MIC1_DET,
2405+
wm8994_mic_irq, "Mic 1 detect",
2406+
wm8994);
2407+
if (ret != 0)
2408+
dev_warn(codec->dev,
2409+
"Failed to request Mic1 detect IRQ: %d\n",
2410+
ret);
2411+
2412+
ret = wm8994_request_irq(codec->control_data,
2413+
WM8994_IRQ_MIC1_SHRT,
2414+
wm8994_mic_irq, "Mic 1 short",
2415+
wm8994);
2416+
if (ret != 0)
2417+
dev_warn(codec->dev,
2418+
"Failed to request Mic1 short IRQ: %d\n",
2419+
ret);
2420+
2421+
ret = wm8994_request_irq(codec->control_data,
2422+
WM8994_IRQ_MIC2_DET,
2423+
wm8994_mic_irq, "Mic 2 detect",
2424+
wm8994);
2425+
if (ret != 0)
2426+
dev_warn(codec->dev,
2427+
"Failed to request Mic2 detect IRQ: %d\n",
2428+
ret);
2429+
2430+
ret = wm8994_request_irq(codec->control_data,
2431+
WM8994_IRQ_MIC2_SHRT,
2432+
wm8994_mic_irq, "Mic 2 short",
2433+
wm8994);
2434+
if (ret != 0)
2435+
dev_warn(codec->dev,
2436+
"Failed to request Mic2 short IRQ: %d\n",
2437+
ret);
2438+
break;
2439+
}
24072440

24082441
/* Remember if AIFnLRCLK is configured as a GPIO. This should be
24092442
* configured on init - if a system wants to do this dynamically
@@ -2496,13 +2529,22 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
24962529
static int wm8994_codec_remove(struct snd_soc_codec *codec)
24972530
{
24982531
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
2532+
struct wm8994 *control = codec->control_data;
24992533

25002534
wm8994_set_bias_level(codec, SND_SOC_BIAS_OFF);
25012535

2502-
wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT, wm8994);
2503-
wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET, wm8994);
2504-
wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT, wm8994);
2505-
wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_DET, wm8994);
2536+
switch (control->type) {
2537+
case WM8994:
2538+
wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT,
2539+
wm8994);
2540+
wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET,
2541+
wm8994);
2542+
wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT,
2543+
wm8994);
2544+
wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_DET,
2545+
wm8994);
2546+
break;
2547+
}
25062548
kfree(wm8994->retune_mobile_texts);
25072549
kfree(wm8994->drc_texts);
25082550
kfree(wm8994);

0 commit comments

Comments
 (0)