| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * wm8350.c -- WM8350 ALSA SoC audio driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2007-12 Wolfson Microelectronics PLC. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 10 | | - * published by the Free Software Foundation. |
|---|
| 11 | 8 | */ |
|---|
| 12 | 9 | |
|---|
| 13 | 10 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 334 | 331 | return ret; |
|---|
| 335 | 332 | |
|---|
| 336 | 333 | /* now hit the volume update bits (always bit 8) */ |
|---|
| 337 | | - val = snd_soc_component_read32(component, reg); |
|---|
| 334 | + val = snd_soc_component_read(component, reg); |
|---|
| 338 | 335 | snd_soc_component_write(component, reg, val | WM8350_OUT1_VU); |
|---|
| 339 | 336 | return 1; |
|---|
| 340 | 337 | } |
|---|
| .. | .. |
|---|
| 769 | 766 | case WM8350_MCLK_SEL_PLL_32K: |
|---|
| 770 | 767 | wm8350_set_bits(wm8350, WM8350_CLOCK_CONTROL_1, |
|---|
| 771 | 768 | WM8350_MCLK_SEL); |
|---|
| 772 | | - fll_4 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_4) & |
|---|
| 769 | + fll_4 = snd_soc_component_read(component, WM8350_FLL_CONTROL_4) & |
|---|
| 773 | 770 | ~WM8350_FLL_CLK_SRC_MASK; |
|---|
| 774 | 771 | snd_soc_component_write(component, WM8350_FLL_CONTROL_4, fll_4 | clk_id); |
|---|
| 775 | 772 | break; |
|---|
| .. | .. |
|---|
| 793 | 790 | |
|---|
| 794 | 791 | switch (div_id) { |
|---|
| 795 | 792 | case WM8350_ADC_CLKDIV: |
|---|
| 796 | | - val = snd_soc_component_read32(component, WM8350_ADC_DIVIDER) & |
|---|
| 793 | + val = snd_soc_component_read(component, WM8350_ADC_DIVIDER) & |
|---|
| 797 | 794 | ~WM8350_ADC_CLKDIV_MASK; |
|---|
| 798 | 795 | snd_soc_component_write(component, WM8350_ADC_DIVIDER, val | div); |
|---|
| 799 | 796 | break; |
|---|
| 800 | 797 | case WM8350_DAC_CLKDIV: |
|---|
| 801 | | - val = snd_soc_component_read32(component, WM8350_DAC_CLOCK_CONTROL) & |
|---|
| 798 | + val = snd_soc_component_read(component, WM8350_DAC_CLOCK_CONTROL) & |
|---|
| 802 | 799 | ~WM8350_DAC_CLKDIV_MASK; |
|---|
| 803 | 800 | snd_soc_component_write(component, WM8350_DAC_CLOCK_CONTROL, val | div); |
|---|
| 804 | 801 | break; |
|---|
| 805 | 802 | case WM8350_BCLK_CLKDIV: |
|---|
| 806 | | - val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) & |
|---|
| 803 | + val = snd_soc_component_read(component, WM8350_CLOCK_CONTROL_1) & |
|---|
| 807 | 804 | ~WM8350_BCLK_DIV_MASK; |
|---|
| 808 | 805 | snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div); |
|---|
| 809 | 806 | break; |
|---|
| 810 | 807 | case WM8350_OPCLK_CLKDIV: |
|---|
| 811 | | - val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) & |
|---|
| 808 | + val = snd_soc_component_read(component, WM8350_CLOCK_CONTROL_1) & |
|---|
| 812 | 809 | ~WM8350_OPCLK_DIV_MASK; |
|---|
| 813 | 810 | snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div); |
|---|
| 814 | 811 | break; |
|---|
| 815 | 812 | case WM8350_SYS_CLKDIV: |
|---|
| 816 | | - val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) & |
|---|
| 813 | + val = snd_soc_component_read(component, WM8350_CLOCK_CONTROL_1) & |
|---|
| 817 | 814 | ~WM8350_MCLK_DIV_MASK; |
|---|
| 818 | 815 | snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div); |
|---|
| 819 | 816 | break; |
|---|
| 820 | 817 | case WM8350_DACLR_CLKDIV: |
|---|
| 821 | | - val = snd_soc_component_read32(component, WM8350_DAC_LR_RATE) & |
|---|
| 818 | + val = snd_soc_component_read(component, WM8350_DAC_LR_RATE) & |
|---|
| 822 | 819 | ~WM8350_DACLRC_RATE_MASK; |
|---|
| 823 | 820 | snd_soc_component_write(component, WM8350_DAC_LR_RATE, val | div); |
|---|
| 824 | 821 | break; |
|---|
| 825 | 822 | case WM8350_ADCLR_CLKDIV: |
|---|
| 826 | | - val = snd_soc_component_read32(component, WM8350_ADC_LR_RATE) & |
|---|
| 823 | + val = snd_soc_component_read(component, WM8350_ADC_LR_RATE) & |
|---|
| 827 | 824 | ~WM8350_ADCLRC_RATE_MASK; |
|---|
| 828 | 825 | snd_soc_component_write(component, WM8350_ADC_LR_RATE, val | div); |
|---|
| 829 | 826 | break; |
|---|
| .. | .. |
|---|
| 837 | 834 | static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) |
|---|
| 838 | 835 | { |
|---|
| 839 | 836 | struct snd_soc_component *component = codec_dai->component; |
|---|
| 840 | | - u16 iface = snd_soc_component_read32(component, WM8350_AI_FORMATING) & |
|---|
| 837 | + u16 iface = snd_soc_component_read(component, WM8350_AI_FORMATING) & |
|---|
| 841 | 838 | ~(WM8350_AIF_BCLK_INV | WM8350_AIF_LRCLK_INV | WM8350_AIF_FMT_MASK); |
|---|
| 842 | | - u16 master = snd_soc_component_read32(component, WM8350_AI_DAC_CONTROL) & |
|---|
| 839 | + u16 master = snd_soc_component_read(component, WM8350_AI_DAC_CONTROL) & |
|---|
| 843 | 840 | ~WM8350_BCLK_MSTR; |
|---|
| 844 | | - u16 dac_lrc = snd_soc_component_read32(component, WM8350_DAC_LR_RATE) & |
|---|
| 841 | + u16 dac_lrc = snd_soc_component_read(component, WM8350_DAC_LR_RATE) & |
|---|
| 845 | 842 | ~WM8350_DACLRC_ENA; |
|---|
| 846 | | - u16 adc_lrc = snd_soc_component_read32(component, WM8350_ADC_LR_RATE) & |
|---|
| 843 | + u16 adc_lrc = snd_soc_component_read(component, WM8350_ADC_LR_RATE) & |
|---|
| 847 | 844 | ~WM8350_ADCLRC_ENA; |
|---|
| 848 | 845 | |
|---|
| 849 | 846 | /* set master/slave audio interface */ |
|---|
| .. | .. |
|---|
| 910 | 907 | struct snd_soc_component *component = codec_dai->component; |
|---|
| 911 | 908 | struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component); |
|---|
| 912 | 909 | struct wm8350 *wm8350 = wm8350_data->wm8350; |
|---|
| 913 | | - u16 iface = snd_soc_component_read32(component, WM8350_AI_FORMATING) & |
|---|
| 910 | + u16 iface = snd_soc_component_read(component, WM8350_AI_FORMATING) & |
|---|
| 914 | 911 | ~WM8350_AIF_WL_MASK; |
|---|
| 915 | 912 | |
|---|
| 916 | 913 | /* bit size */ |
|---|
| .. | .. |
|---|
| 945 | 942 | return 0; |
|---|
| 946 | 943 | } |
|---|
| 947 | 944 | |
|---|
| 948 | | -static int wm8350_mute(struct snd_soc_dai *dai, int mute) |
|---|
| 945 | +static int wm8350_mute(struct snd_soc_dai *dai, int mute, int direction) |
|---|
| 949 | 946 | { |
|---|
| 950 | 947 | struct snd_soc_component *component = dai->component; |
|---|
| 951 | 948 | unsigned int val; |
|---|
| .. | .. |
|---|
| 1050 | 1047 | fll_div.ratio); |
|---|
| 1051 | 1048 | |
|---|
| 1052 | 1049 | /* set up N.K & dividers */ |
|---|
| 1053 | | - fll_1 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_1) & |
|---|
| 1050 | + fll_1 = snd_soc_component_read(component, WM8350_FLL_CONTROL_1) & |
|---|
| 1054 | 1051 | ~(WM8350_FLL_OUTDIV_MASK | WM8350_FLL_RSP_RATE_MASK | 0xc000); |
|---|
| 1055 | 1052 | snd_soc_component_write(component, WM8350_FLL_CONTROL_1, |
|---|
| 1056 | 1053 | fll_1 | (fll_div.div << 8) | 0x50); |
|---|
| .. | .. |
|---|
| 1058 | 1055 | (fll_div.ratio << 11) | (fll_div. |
|---|
| 1059 | 1056 | n & WM8350_FLL_N_MASK)); |
|---|
| 1060 | 1057 | snd_soc_component_write(component, WM8350_FLL_CONTROL_3, fll_div.k); |
|---|
| 1061 | | - fll_4 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_4) & |
|---|
| 1058 | + fll_4 = snd_soc_component_read(component, WM8350_FLL_CONTROL_4) & |
|---|
| 1062 | 1059 | ~(WM8350_FLL_FRAC | WM8350_FLL_SLOW_LOCK_REF); |
|---|
| 1063 | 1060 | snd_soc_component_write(component, WM8350_FLL_CONTROL_4, |
|---|
| 1064 | 1061 | fll_4 | (fll_div.k ? WM8350_FLL_FRAC : 0) | |
|---|
| .. | .. |
|---|
| 1429 | 1426 | |
|---|
| 1430 | 1427 | static const struct snd_soc_dai_ops wm8350_dai_ops = { |
|---|
| 1431 | 1428 | .hw_params = wm8350_pcm_hw_params, |
|---|
| 1432 | | - .digital_mute = wm8350_mute, |
|---|
| 1429 | + .mute_stream = wm8350_mute, |
|---|
| 1433 | 1430 | .set_fmt = wm8350_set_dai_fmt, |
|---|
| 1434 | 1431 | .set_sysclk = wm8350_set_dai_sysclk, |
|---|
| 1435 | 1432 | .set_pll = wm8350_set_fll, |
|---|
| 1436 | 1433 | .set_clkdiv = wm8350_set_clkdiv, |
|---|
| 1434 | + .no_capture_mute = 1, |
|---|
| 1437 | 1435 | }; |
|---|
| 1438 | 1436 | |
|---|
| 1439 | 1437 | static struct snd_soc_dai_driver wm8350_dai = { |
|---|
| .. | .. |
|---|
| 1538 | 1536 | wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, |
|---|
| 1539 | 1537 | WM8350_JDL_ENA | WM8350_JDR_ENA); |
|---|
| 1540 | 1538 | |
|---|
| 1541 | | - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, |
|---|
| 1539 | + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, |
|---|
| 1542 | 1540 | wm8350_hpl_jack_handler, 0, "Left jack detect", |
|---|
| 1543 | 1541 | priv); |
|---|
| 1544 | | - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, |
|---|
| 1542 | + if (ret != 0) |
|---|
| 1543 | + goto err; |
|---|
| 1544 | + |
|---|
| 1545 | + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, |
|---|
| 1545 | 1546 | wm8350_hpr_jack_handler, 0, "Right jack detect", |
|---|
| 1546 | 1547 | priv); |
|---|
| 1547 | | - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, |
|---|
| 1548 | + if (ret != 0) |
|---|
| 1549 | + goto free_jck_det_l; |
|---|
| 1550 | + |
|---|
| 1551 | + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, |
|---|
| 1548 | 1552 | wm8350_mic_handler, 0, "Microphone short", priv); |
|---|
| 1549 | | - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICD, |
|---|
| 1553 | + if (ret != 0) |
|---|
| 1554 | + goto free_jck_det_r; |
|---|
| 1555 | + |
|---|
| 1556 | + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICD, |
|---|
| 1550 | 1557 | wm8350_mic_handler, 0, "Microphone detect", priv); |
|---|
| 1558 | + if (ret != 0) |
|---|
| 1559 | + goto free_micscd; |
|---|
| 1551 | 1560 | |
|---|
| 1552 | 1561 | return 0; |
|---|
| 1562 | + |
|---|
| 1563 | +free_micscd: |
|---|
| 1564 | + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, priv); |
|---|
| 1565 | +free_jck_det_r: |
|---|
| 1566 | + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, priv); |
|---|
| 1567 | +free_jck_det_l: |
|---|
| 1568 | + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, priv); |
|---|
| 1569 | +err: |
|---|
| 1570 | + return ret; |
|---|
| 1553 | 1571 | } |
|---|
| 1554 | 1572 | |
|---|
| 1555 | 1573 | static void wm8350_component_remove(struct snd_soc_component *component) |
|---|