diff options
author | Mark Brown <broonie@linaro.org> | 2013-11-08 05:43:42 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-11-08 05:43:42 -0500 |
commit | 22b468a06e5862c40a44798a335cb4956b78dbc0 (patch) | |
tree | e5f379123ce102a7ebf3fd725ef10e0ee7f9d250 /sound/soc | |
parent | 552b747564bf970095a0478d4f50ca82d3dd39c5 (diff) | |
parent | ae2ff9f6c529ba28adea906037a93fd14e46e052 (diff) |
Merge remote-tracking branch 'asoc/topic/wm8962' into asoc-next
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/wm8962.c | 226 |
1 files changed, 116 insertions, 110 deletions
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 22e42e788649..ac1ff9947a90 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c | |||
@@ -1758,6 +1758,9 @@ SOC_DOUBLE_R_TLV("EQ4 Volume", WM8962_EQ3, WM8962_EQ23, | |||
1758 | WM8962_EQL_B4_GAIN_SHIFT, 31, 0, eq_tlv), | 1758 | WM8962_EQL_B4_GAIN_SHIFT, 31, 0, eq_tlv), |
1759 | SOC_DOUBLE_R_TLV("EQ5 Volume", WM8962_EQ3, WM8962_EQ23, | 1759 | SOC_DOUBLE_R_TLV("EQ5 Volume", WM8962_EQ3, WM8962_EQ23, |
1760 | WM8962_EQL_B5_GAIN_SHIFT, 31, 0, eq_tlv), | 1760 | WM8962_EQL_B5_GAIN_SHIFT, 31, 0, eq_tlv), |
1761 | SND_SOC_BYTES("EQL Coefficients", WM8962_EQ4, 18), | ||
1762 | SND_SOC_BYTES("EQR Coefficients", WM8962_EQ24, 18), | ||
1763 | |||
1761 | 1764 | ||
1762 | SOC_SINGLE("3D Switch", WM8962_THREED1, 0, 1, 0), | 1765 | SOC_SINGLE("3D Switch", WM8962_THREED1, 0, 1, 0), |
1763 | SND_SOC_BYTES_MASK("3D Coefficients", WM8962_THREED1, 4, WM8962_THREED_ENA), | 1766 | SND_SOC_BYTES_MASK("3D Coefficients", WM8962_THREED1, 4, WM8962_THREED_ENA), |
@@ -1775,6 +1778,11 @@ WM8962_DSP2_ENABLE("HPF2 Switch", WM8962_HPF2_ENA_SHIFT), | |||
1775 | SND_SOC_BYTES("HPF Coefficients", WM8962_LHPF2, 1), | 1778 | SND_SOC_BYTES("HPF Coefficients", WM8962_LHPF2, 1), |
1776 | WM8962_DSP2_ENABLE("HD Bass Switch", WM8962_HDBASS_ENA_SHIFT), | 1779 | WM8962_DSP2_ENABLE("HD Bass Switch", WM8962_HDBASS_ENA_SHIFT), |
1777 | SND_SOC_BYTES("HD Bass Coefficients", WM8962_HDBASS_AI_1, 30), | 1780 | SND_SOC_BYTES("HD Bass Coefficients", WM8962_HDBASS_AI_1, 30), |
1781 | |||
1782 | SOC_DOUBLE("ALC Switch", WM8962_ALC1, WM8962_ALCL_ENA_SHIFT, | ||
1783 | WM8962_ALCR_ENA_SHIFT, 1, 0), | ||
1784 | SND_SOC_BYTES_MASK("ALC Coefficients", WM8962_ALC1, 4, | ||
1785 | WM8962_ALCL_ENA_MASK | WM8962_ALCR_ENA_MASK), | ||
1778 | }; | 1786 | }; |
1779 | 1787 | ||
1780 | static const struct snd_kcontrol_new wm8962_spk_mono_controls[] = { | 1788 | static const struct snd_kcontrol_new wm8962_spk_mono_controls[] = { |
@@ -3242,7 +3250,7 @@ static void wm8962_free_beep(struct snd_soc_codec *codec) | |||
3242 | } | 3250 | } |
3243 | #endif | 3251 | #endif |
3244 | 3252 | ||
3245 | static void wm8962_set_gpio_mode(struct snd_soc_codec *codec, int gpio) | 3253 | static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio) |
3246 | { | 3254 | { |
3247 | int mask = 0; | 3255 | int mask = 0; |
3248 | int val = 0; | 3256 | int val = 0; |
@@ -3263,8 +3271,8 @@ static void wm8962_set_gpio_mode(struct snd_soc_codec *codec, int gpio) | |||
3263 | } | 3271 | } |
3264 | 3272 | ||
3265 | if (mask) | 3273 | if (mask) |
3266 | snd_soc_update_bits(codec, WM8962_ANALOGUE_CLOCKING1, | 3274 | regmap_update_bits(wm8962->regmap, WM8962_ANALOGUE_CLOCKING1, |
3267 | mask, val); | 3275 | mask, val); |
3268 | } | 3276 | } |
3269 | 3277 | ||
3270 | #ifdef CONFIG_GPIOLIB | 3278 | #ifdef CONFIG_GPIOLIB |
@@ -3276,7 +3284,6 @@ static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip) | |||
3276 | static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) | 3284 | static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) |
3277 | { | 3285 | { |
3278 | struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); | 3286 | struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); |
3279 | struct snd_soc_codec *codec = wm8962->codec; | ||
3280 | 3287 | ||
3281 | /* The WM8962 GPIOs aren't linearly numbered. For simplicity | 3288 | /* The WM8962 GPIOs aren't linearly numbered. For simplicity |
3282 | * we export linear numbers and error out if the unsupported | 3289 | * we export linear numbers and error out if the unsupported |
@@ -3292,7 +3299,7 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) | |||
3292 | return -EINVAL; | 3299 | return -EINVAL; |
3293 | } | 3300 | } |
3294 | 3301 | ||
3295 | wm8962_set_gpio_mode(codec, offset + 1); | 3302 | wm8962_set_gpio_mode(wm8962, offset + 1); |
3296 | 3303 | ||
3297 | return 0; | 3304 | return 0; |
3298 | } | 3305 | } |
@@ -3376,8 +3383,7 @@ static int wm8962_probe(struct snd_soc_codec *codec) | |||
3376 | { | 3383 | { |
3377 | int ret; | 3384 | int ret; |
3378 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); | 3385 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); |
3379 | struct wm8962_pdata *pdata = &wm8962->pdata; | 3386 | int i; |
3380 | int i, trigger, irq_pol; | ||
3381 | bool dmicclk, dmicdat; | 3387 | bool dmicclk, dmicdat; |
3382 | 3388 | ||
3383 | wm8962->codec = codec; | 3389 | wm8962->codec = codec; |
@@ -3409,75 +3415,6 @@ static int wm8962_probe(struct snd_soc_codec *codec) | |||
3409 | } | 3415 | } |
3410 | } | 3416 | } |
3411 | 3417 | ||
3412 | /* SYSCLK defaults to on; make sure it is off so we can safely | ||
3413 | * write to registers if the device is declocked. | ||
3414 | */ | ||
3415 | snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_ENA, 0); | ||
3416 | |||
3417 | /* Ensure we have soft control over all registers */ | ||
3418 | snd_soc_update_bits(codec, WM8962_CLOCKING2, | ||
3419 | WM8962_CLKREG_OVD, WM8962_CLKREG_OVD); | ||
3420 | |||
3421 | /* Ensure that the oscillator and PLLs are disabled */ | ||
3422 | snd_soc_update_bits(codec, WM8962_PLL2, | ||
3423 | WM8962_OSC_ENA | WM8962_PLL2_ENA | WM8962_PLL3_ENA, | ||
3424 | 0); | ||
3425 | |||
3426 | /* Apply static configuration for GPIOs */ | ||
3427 | for (i = 0; i < ARRAY_SIZE(pdata->gpio_init); i++) | ||
3428 | if (pdata->gpio_init[i]) { | ||
3429 | wm8962_set_gpio_mode(codec, i + 1); | ||
3430 | snd_soc_write(codec, 0x200 + i, | ||
3431 | pdata->gpio_init[i] & 0xffff); | ||
3432 | } | ||
3433 | |||
3434 | |||
3435 | /* Put the speakers into mono mode? */ | ||
3436 | if (pdata->spk_mono) | ||
3437 | snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_2, | ||
3438 | WM8962_SPK_MONO_MASK, WM8962_SPK_MONO); | ||
3439 | |||
3440 | /* Micbias setup, detection enable and detection | ||
3441 | * threasholds. */ | ||
3442 | if (pdata->mic_cfg) | ||
3443 | snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4, | ||
3444 | WM8962_MICDET_ENA | | ||
3445 | WM8962_MICDET_THR_MASK | | ||
3446 | WM8962_MICSHORT_THR_MASK | | ||
3447 | WM8962_MICBIAS_LVL, | ||
3448 | pdata->mic_cfg); | ||
3449 | |||
3450 | /* Latch volume update bits */ | ||
3451 | snd_soc_update_bits(codec, WM8962_LEFT_INPUT_VOLUME, | ||
3452 | WM8962_IN_VU, WM8962_IN_VU); | ||
3453 | snd_soc_update_bits(codec, WM8962_RIGHT_INPUT_VOLUME, | ||
3454 | WM8962_IN_VU, WM8962_IN_VU); | ||
3455 | snd_soc_update_bits(codec, WM8962_LEFT_ADC_VOLUME, | ||
3456 | WM8962_ADC_VU, WM8962_ADC_VU); | ||
3457 | snd_soc_update_bits(codec, WM8962_RIGHT_ADC_VOLUME, | ||
3458 | WM8962_ADC_VU, WM8962_ADC_VU); | ||
3459 | snd_soc_update_bits(codec, WM8962_LEFT_DAC_VOLUME, | ||
3460 | WM8962_DAC_VU, WM8962_DAC_VU); | ||
3461 | snd_soc_update_bits(codec, WM8962_RIGHT_DAC_VOLUME, | ||
3462 | WM8962_DAC_VU, WM8962_DAC_VU); | ||
3463 | snd_soc_update_bits(codec, WM8962_SPKOUTL_VOLUME, | ||
3464 | WM8962_SPKOUT_VU, WM8962_SPKOUT_VU); | ||
3465 | snd_soc_update_bits(codec, WM8962_SPKOUTR_VOLUME, | ||
3466 | WM8962_SPKOUT_VU, WM8962_SPKOUT_VU); | ||
3467 | snd_soc_update_bits(codec, WM8962_HPOUTL_VOLUME, | ||
3468 | WM8962_HPOUT_VU, WM8962_HPOUT_VU); | ||
3469 | snd_soc_update_bits(codec, WM8962_HPOUTR_VOLUME, | ||
3470 | WM8962_HPOUT_VU, WM8962_HPOUT_VU); | ||
3471 | |||
3472 | /* Stereo control for EQ */ | ||
3473 | snd_soc_update_bits(codec, WM8962_EQ1, WM8962_EQ_SHARED_COEFF, 0); | ||
3474 | |||
3475 | /* Don't debouce interrupts so we don't need SYSCLK */ | ||
3476 | snd_soc_update_bits(codec, WM8962_IRQ_DEBOUNCE, | ||
3477 | WM8962_FLL_LOCK_DB | WM8962_PLL3_LOCK_DB | | ||
3478 | WM8962_PLL2_LOCK_DB | WM8962_TEMP_SHUT_DB, | ||
3479 | 0); | ||
3480 | |||
3481 | wm8962_add_widgets(codec); | 3418 | wm8962_add_widgets(codec); |
3482 | 3419 | ||
3483 | /* Save boards having to disable DMIC when not in use */ | 3420 | /* Save boards having to disable DMIC when not in use */ |
@@ -3506,36 +3443,6 @@ static int wm8962_probe(struct snd_soc_codec *codec) | |||
3506 | wm8962_init_beep(codec); | 3443 | wm8962_init_beep(codec); |
3507 | wm8962_init_gpio(codec); | 3444 | wm8962_init_gpio(codec); |
3508 | 3445 | ||
3509 | if (wm8962->irq) { | ||
3510 | if (pdata->irq_active_low) { | ||
3511 | trigger = IRQF_TRIGGER_LOW; | ||
3512 | irq_pol = WM8962_IRQ_POL; | ||
3513 | } else { | ||
3514 | trigger = IRQF_TRIGGER_HIGH; | ||
3515 | irq_pol = 0; | ||
3516 | } | ||
3517 | |||
3518 | snd_soc_update_bits(codec, WM8962_INTERRUPT_CONTROL, | ||
3519 | WM8962_IRQ_POL, irq_pol); | ||
3520 | |||
3521 | ret = request_threaded_irq(wm8962->irq, NULL, wm8962_irq, | ||
3522 | trigger | IRQF_ONESHOT, | ||
3523 | "wm8962", codec->dev); | ||
3524 | if (ret != 0) { | ||
3525 | dev_err(codec->dev, "Failed to request IRQ %d: %d\n", | ||
3526 | wm8962->irq, ret); | ||
3527 | wm8962->irq = 0; | ||
3528 | /* Non-fatal */ | ||
3529 | } else { | ||
3530 | /* Enable some IRQs by default */ | ||
3531 | snd_soc_update_bits(codec, | ||
3532 | WM8962_INTERRUPT_STATUS_2_MASK, | ||
3533 | WM8962_FLL_LOCK_EINT | | ||
3534 | WM8962_TEMP_SHUT_EINT | | ||
3535 | WM8962_FIFOS_ERR_EINT, 0); | ||
3536 | } | ||
3537 | } | ||
3538 | |||
3539 | return 0; | 3446 | return 0; |
3540 | } | 3447 | } |
3541 | 3448 | ||
@@ -3544,9 +3451,6 @@ static int wm8962_remove(struct snd_soc_codec *codec) | |||
3544 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); | 3451 | struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); |
3545 | int i; | 3452 | int i; |
3546 | 3453 | ||
3547 | if (wm8962->irq) | ||
3548 | free_irq(wm8962->irq, codec); | ||
3549 | |||
3550 | cancel_delayed_work_sync(&wm8962->mic_work); | 3454 | cancel_delayed_work_sync(&wm8962->mic_work); |
3551 | 3455 | ||
3552 | wm8962_free_gpio(codec); | 3456 | wm8962_free_gpio(codec); |
@@ -3619,7 +3523,7 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, | |||
3619 | struct wm8962_pdata *pdata = dev_get_platdata(&i2c->dev); | 3523 | struct wm8962_pdata *pdata = dev_get_platdata(&i2c->dev); |
3620 | struct wm8962_priv *wm8962; | 3524 | struct wm8962_priv *wm8962; |
3621 | unsigned int reg; | 3525 | unsigned int reg; |
3622 | int ret, i; | 3526 | int ret, i, irq_pol, trigger; |
3623 | 3527 | ||
3624 | wm8962 = devm_kzalloc(&i2c->dev, sizeof(struct wm8962_priv), | 3528 | wm8962 = devm_kzalloc(&i2c->dev, sizeof(struct wm8962_priv), |
3625 | GFP_KERNEL); | 3529 | GFP_KERNEL); |
@@ -3704,6 +3608,77 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, | |||
3704 | goto err_enable; | 3608 | goto err_enable; |
3705 | } | 3609 | } |
3706 | 3610 | ||
3611 | /* SYSCLK defaults to on; make sure it is off so we can safely | ||
3612 | * write to registers if the device is declocked. | ||
3613 | */ | ||
3614 | regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2, | ||
3615 | WM8962_SYSCLK_ENA, 0); | ||
3616 | |||
3617 | /* Ensure we have soft control over all registers */ | ||
3618 | regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2, | ||
3619 | WM8962_CLKREG_OVD, WM8962_CLKREG_OVD); | ||
3620 | |||
3621 | /* Ensure that the oscillator and PLLs are disabled */ | ||
3622 | regmap_update_bits(wm8962->regmap, WM8962_PLL2, | ||
3623 | WM8962_OSC_ENA | WM8962_PLL2_ENA | WM8962_PLL3_ENA, | ||
3624 | 0); | ||
3625 | |||
3626 | /* Apply static configuration for GPIOs */ | ||
3627 | for (i = 0; i < ARRAY_SIZE(wm8962->pdata.gpio_init); i++) | ||
3628 | if (wm8962->pdata.gpio_init[i]) { | ||
3629 | wm8962_set_gpio_mode(wm8962, i + 1); | ||
3630 | regmap_write(wm8962->regmap, 0x200 + i, | ||
3631 | wm8962->pdata.gpio_init[i] & 0xffff); | ||
3632 | } | ||
3633 | |||
3634 | |||
3635 | /* Put the speakers into mono mode? */ | ||
3636 | if (wm8962->pdata.spk_mono) | ||
3637 | regmap_update_bits(wm8962->regmap, WM8962_CLASS_D_CONTROL_2, | ||
3638 | WM8962_SPK_MONO_MASK, WM8962_SPK_MONO); | ||
3639 | |||
3640 | /* Micbias setup, detection enable and detection | ||
3641 | * threasholds. */ | ||
3642 | if (wm8962->pdata.mic_cfg) | ||
3643 | regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4, | ||
3644 | WM8962_MICDET_ENA | | ||
3645 | WM8962_MICDET_THR_MASK | | ||
3646 | WM8962_MICSHORT_THR_MASK | | ||
3647 | WM8962_MICBIAS_LVL, | ||
3648 | wm8962->pdata.mic_cfg); | ||
3649 | |||
3650 | /* Latch volume update bits */ | ||
3651 | regmap_update_bits(wm8962->regmap, WM8962_LEFT_INPUT_VOLUME, | ||
3652 | WM8962_IN_VU, WM8962_IN_VU); | ||
3653 | regmap_update_bits(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, | ||
3654 | WM8962_IN_VU, WM8962_IN_VU); | ||
3655 | regmap_update_bits(wm8962->regmap, WM8962_LEFT_ADC_VOLUME, | ||
3656 | WM8962_ADC_VU, WM8962_ADC_VU); | ||
3657 | regmap_update_bits(wm8962->regmap, WM8962_RIGHT_ADC_VOLUME, | ||
3658 | WM8962_ADC_VU, WM8962_ADC_VU); | ||
3659 | regmap_update_bits(wm8962->regmap, WM8962_LEFT_DAC_VOLUME, | ||
3660 | WM8962_DAC_VU, WM8962_DAC_VU); | ||
3661 | regmap_update_bits(wm8962->regmap, WM8962_RIGHT_DAC_VOLUME, | ||
3662 | WM8962_DAC_VU, WM8962_DAC_VU); | ||
3663 | regmap_update_bits(wm8962->regmap, WM8962_SPKOUTL_VOLUME, | ||
3664 | WM8962_SPKOUT_VU, WM8962_SPKOUT_VU); | ||
3665 | regmap_update_bits(wm8962->regmap, WM8962_SPKOUTR_VOLUME, | ||
3666 | WM8962_SPKOUT_VU, WM8962_SPKOUT_VU); | ||
3667 | regmap_update_bits(wm8962->regmap, WM8962_HPOUTL_VOLUME, | ||
3668 | WM8962_HPOUT_VU, WM8962_HPOUT_VU); | ||
3669 | regmap_update_bits(wm8962->regmap, WM8962_HPOUTR_VOLUME, | ||
3670 | WM8962_HPOUT_VU, WM8962_HPOUT_VU); | ||
3671 | |||
3672 | /* Stereo control for EQ */ | ||
3673 | regmap_update_bits(wm8962->regmap, WM8962_EQ1, | ||
3674 | WM8962_EQ_SHARED_COEFF, 0); | ||
3675 | |||
3676 | /* Don't debouce interrupts so we don't need SYSCLK */ | ||
3677 | regmap_update_bits(wm8962->regmap, WM8962_IRQ_DEBOUNCE, | ||
3678 | WM8962_FLL_LOCK_DB | WM8962_PLL3_LOCK_DB | | ||
3679 | WM8962_PLL2_LOCK_DB | WM8962_TEMP_SHUT_DB, | ||
3680 | 0); | ||
3681 | |||
3707 | if (wm8962->pdata.in4_dc_measure) { | 3682 | if (wm8962->pdata.in4_dc_measure) { |
3708 | ret = regmap_register_patch(wm8962->regmap, | 3683 | ret = regmap_register_patch(wm8962->regmap, |
3709 | wm8962_dc_measure, | 3684 | wm8962_dc_measure, |
@@ -3714,6 +3689,37 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, | |||
3714 | ret); | 3689 | ret); |
3715 | } | 3690 | } |
3716 | 3691 | ||
3692 | if (wm8962->irq) { | ||
3693 | if (wm8962->pdata.irq_active_low) { | ||
3694 | trigger = IRQF_TRIGGER_LOW; | ||
3695 | irq_pol = WM8962_IRQ_POL; | ||
3696 | } else { | ||
3697 | trigger = IRQF_TRIGGER_HIGH; | ||
3698 | irq_pol = 0; | ||
3699 | } | ||
3700 | |||
3701 | regmap_update_bits(wm8962->regmap, WM8962_INTERRUPT_CONTROL, | ||
3702 | WM8962_IRQ_POL, irq_pol); | ||
3703 | |||
3704 | ret = devm_request_threaded_irq(&i2c->dev, wm8962->irq, NULL, | ||
3705 | wm8962_irq, | ||
3706 | trigger | IRQF_ONESHOT, | ||
3707 | "wm8962", &i2c->dev); | ||
3708 | if (ret != 0) { | ||
3709 | dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n", | ||
3710 | wm8962->irq, ret); | ||
3711 | wm8962->irq = 0; | ||
3712 | /* Non-fatal */ | ||
3713 | } else { | ||
3714 | /* Enable some IRQs by default */ | ||
3715 | regmap_update_bits(wm8962->regmap, | ||
3716 | WM8962_INTERRUPT_STATUS_2_MASK, | ||
3717 | WM8962_FLL_LOCK_EINT | | ||
3718 | WM8962_TEMP_SHUT_EINT | | ||
3719 | WM8962_FIFOS_ERR_EINT, 0); | ||
3720 | } | ||
3721 | } | ||
3722 | |||
3717 | pm_runtime_enable(&i2c->dev); | 3723 | pm_runtime_enable(&i2c->dev); |
3718 | pm_request_idle(&i2c->dev); | 3724 | pm_request_idle(&i2c->dev); |
3719 | 3725 | ||