diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-10-26 03:32:46 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-10-26 07:14:49 -0400 |
commit | d82ad8e0c0ecc49e81bf7d57fdc09b7d76c1afc0 (patch) | |
tree | df819814633bf1b2a22a423c4ef67b462ba0871c | |
parent | 274035751e25ee15a064e43cde7b4e7a9b75d921 (diff) | |
parent | bb9a13a0209c56cdf27d125a1f2f6f34378c64f4 (diff) |
Merge tag 'asoc-v4.3-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Updates for v4.4
Not much core work here, a few small tweaks to interfaces but mainly the
changes here are driver ones. Highlights include:
- Updates to the topology userspace interface
- Big updates to the Renesas support from Morimoto-san
- Most of the support for Intel Sky Lake systems.
- New drivers for Asahi Kasei Microdevices AK4613, Allwinnner A10,
Cirrus Logic WM8998, Dialog DA7219, Nuvoton NAU8825 and Rockchip
S/PDIF.
- A new driver for the Atmel Class D speaker drivers
334 files changed, 13681 insertions, 1628 deletions
@@ -59,6 +59,7 @@ James Bottomley <jejb@mulgrave.(none)> | |||
59 | James Bottomley <jejb@titanic.il.steeleye.com> | 59 | James Bottomley <jejb@titanic.il.steeleye.com> |
60 | James E Wilson <wilson@specifix.com> | 60 | James E Wilson <wilson@specifix.com> |
61 | James Ketrenos <jketreno@io.(none)> | 61 | James Ketrenos <jketreno@io.(none)> |
62 | <javier@osg.samsung.com> <javier.martinez@collabora.co.uk> | ||
62 | Jean Tourrilhes <jt@hpl.hp.com> | 63 | Jean Tourrilhes <jt@hpl.hp.com> |
63 | Jeff Garzik <jgarzik@pretzel.yyz.us> | 64 | Jeff Garzik <jgarzik@pretzel.yyz.us> |
64 | Jens Axboe <axboe@suse.de> | 65 | Jens Axboe <axboe@suse.de> |
diff --git a/Documentation/arm/OMAP/README b/Documentation/arm/OMAP/README new file mode 100644 index 000000000000..75645c45d14a --- /dev/null +++ b/Documentation/arm/OMAP/README | |||
@@ -0,0 +1,7 @@ | |||
1 | This file contains documentation for running mainline | ||
2 | kernel on omaps. | ||
3 | |||
4 | KERNEL NEW DEPENDENCIES | ||
5 | v4.3+ Update is needed for custom .config files to make sure | ||
6 | CONFIG_REGULATOR_PBIAS is enabled for MMC1 to work | ||
7 | properly. | ||
diff --git a/Documentation/devicetree/bindings/sound/atmel-classd.txt b/Documentation/devicetree/bindings/sound/atmel-classd.txt new file mode 100644 index 000000000000..0018451c4351 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/atmel-classd.txt | |||
@@ -0,0 +1,52 @@ | |||
1 | * Atmel ClassD driver under ALSA SoC architecture | ||
2 | |||
3 | Required properties: | ||
4 | - compatible | ||
5 | Should be "atmel,sama5d2-classd". | ||
6 | - reg | ||
7 | Should contain ClassD registers location and length. | ||
8 | - interrupts | ||
9 | Should contain the IRQ line for the ClassD. | ||
10 | - dmas | ||
11 | One DMA specifiers as described in atmel-dma.txt and dma.txt files. | ||
12 | - dma-names | ||
13 | Must be "tx". | ||
14 | - clock-names | ||
15 | Tuple listing input clock names. | ||
16 | Required elements: "pclk", "gclk" and "aclk". | ||
17 | - clocks | ||
18 | Please refer to clock-bindings.txt. | ||
19 | |||
20 | Optional properties: | ||
21 | - pinctrl-names, pinctrl-0 | ||
22 | Please refer to pinctrl-bindings.txt. | ||
23 | - atmel,model | ||
24 | The user-visible name of this sound complex. | ||
25 | The default value is "CLASSD". | ||
26 | - atmel,pwm-type | ||
27 | PWM modulation type, "single" or "diff". | ||
28 | The default value is "single". | ||
29 | - atmel,non-overlap-time | ||
30 | Set non-overlapping time, the unit is nanosecond(ns). | ||
31 | There are four values, | ||
32 | <5>, <10>, <15>, <20>, the default value is <10>. | ||
33 | Non-overlapping will be disabled if not specified. | ||
34 | |||
35 | Example: | ||
36 | classd: classd@fc048000 { | ||
37 | compatible = "atmel,sama5d2-classd"; | ||
38 | reg = <0xfc048000 0x100>; | ||
39 | interrupts = <59 IRQ_TYPE_LEVEL_HIGH 7>; | ||
40 | dmas = <&dma0 | ||
41 | (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | ||
42 | | AT91_XDMAC_DT_PERID(47))>; | ||
43 | dma-names = "tx"; | ||
44 | clocks = <&classd_clk>, <&classd_gclk>, <&audio_pll_pmc>; | ||
45 | clock-names = "pclk", "gclk", "aclk"; | ||
46 | |||
47 | pinctrl-names = "default"; | ||
48 | pinctrl-0 = <&pinctrl_classd_default>; | ||
49 | atmel,model = "classd @ SAMA5D2-Xplained"; | ||
50 | atmel,pwm-type = "diff"; | ||
51 | atmel,non-overlap-time = <10>; | ||
52 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/da7213.txt b/Documentation/devicetree/bindings/sound/da7213.txt new file mode 100644 index 000000000000..58902802d56c --- /dev/null +++ b/Documentation/devicetree/bindings/sound/da7213.txt | |||
@@ -0,0 +1,41 @@ | |||
1 | Dialog Semiconductor DA7213 Audio Codec bindings | ||
2 | |||
3 | ====== | ||
4 | |||
5 | Required properties: | ||
6 | - compatible : Should be "dlg,da7213" | ||
7 | - reg: Specifies the I2C slave address | ||
8 | |||
9 | Optional properties: | ||
10 | - clocks : phandle and clock specifier for codec MCLK. | ||
11 | - clock-names : Clock name string for 'clocks' attribute, should be "mclk". | ||
12 | |||
13 | - dlg,micbias1-lvl : Voltage (mV) for Mic Bias 1 | ||
14 | [<1600>, <2200>, <2500>, <3000>] | ||
15 | - dlg,micbias2-lvl : Voltage (mV) for Mic Bias 2 | ||
16 | [<1600>, <2200>, <2500>, <3000>] | ||
17 | - dlg,dmic-data-sel : DMIC channel select based on clock edge. | ||
18 | ["lrise_rfall", "lfall_rrise"] | ||
19 | - dlg,dmic-samplephase : When to sample audio from DMIC. | ||
20 | ["on_clkedge", "between_clkedge"] | ||
21 | - dlg,dmic-clkrate : DMIC clock frequency (Hz). | ||
22 | [<1500000>, <3000000>] | ||
23 | |||
24 | ====== | ||
25 | |||
26 | Example: | ||
27 | |||
28 | codec_i2c: da7213@1a { | ||
29 | compatible = "dlg,da7213"; | ||
30 | reg = <0x1a>; | ||
31 | |||
32 | clocks = <&clks 201>; | ||
33 | clock-names = "mclk"; | ||
34 | |||
35 | dlg,micbias1-lvl = <2500>; | ||
36 | dlg,micbias2-lvl = <2500>; | ||
37 | |||
38 | dlg,dmic-data-sel = "lrise_rfall"; | ||
39 | dlg,dmic-samplephase = "between_clkedge"; | ||
40 | dlg,dmic-clkrate = <3000000>; | ||
41 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/da7219.txt b/Documentation/devicetree/bindings/sound/da7219.txt new file mode 100644 index 000000000000..1b7030911a3b --- /dev/null +++ b/Documentation/devicetree/bindings/sound/da7219.txt | |||
@@ -0,0 +1,106 @@ | |||
1 | Dialog Semiconductor DA7219 Audio Codec bindings | ||
2 | |||
3 | DA7219 is an audio codec with advanced accessory detect features. | ||
4 | |||
5 | ====== | ||
6 | |||
7 | Required properties: | ||
8 | - compatible : Should be "dlg,da7219" | ||
9 | - reg: Specifies the I2C slave address | ||
10 | |||
11 | - interrupt-parent : Specifies the phandle of the interrupt controller to which | ||
12 | the IRQs from DA7219 are delivered to. | ||
13 | - interrupts : IRQ line info for DA7219. | ||
14 | (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt for | ||
15 | further information relating to interrupt properties) | ||
16 | |||
17 | - VDD-supply: VDD power supply for the device | ||
18 | - VDDMIC-supply: VDDMIC power supply for the device | ||
19 | - VDDIO-supply: VDDIO power supply for the device | ||
20 | (See Documentation/devicetree/bindings/regulator/regulator.txt for further | ||
21 | information relating to regulators) | ||
22 | |||
23 | Optional properties: | ||
24 | - interrupt-names : Name associated with interrupt line. Should be "wakeup" if | ||
25 | interrupt is to be used to wake system, otherwise "irq" should be used. | ||
26 | - wakeup-source: Flag to indicate this device can wake system (suspend/resume). | ||
27 | |||
28 | - clocks : phandle and clock specifier for codec MCLK. | ||
29 | - clock-names : Clock name string for 'clocks' attribute, should be "mclk". | ||
30 | |||
31 | - dlg,ldo-lvl : Required internal LDO voltage (mV) level for digital engine | ||
32 | [<1050>, <1100>, <1200>, <1400>] | ||
33 | - dlg,micbias-lvl : Voltage (mV) for Mic Bias | ||
34 | [<1800>, <2000>, <2200>, <2400>, <2600>] | ||
35 | - dlg,mic-amp-in-sel : Mic input source type | ||
36 | ["diff", "se_p", "se_n"] | ||
37 | |||
38 | ====== | ||
39 | |||
40 | Child node - 'da7219_aad': | ||
41 | |||
42 | Optional properties: | ||
43 | - dlg,micbias-pulse-lvl : Mic bias higher voltage pulse level (mV). | ||
44 | [<2800>, <2900>] | ||
45 | - dlg,micbias-pulse-time : Mic bias higher voltage pulse duration (ms) | ||
46 | - dlg,btn-cfg : Periodic button press measurements for 4-pole jack (ms) | ||
47 | [<2>, <5>, <10>, <50>, <100>, <200>, <500>] | ||
48 | - dlg,mic-det-thr : Impedance threshold for mic detection measurement (Ohms) | ||
49 | [<200>, <500>, <750>, <1000>] | ||
50 | - dlg,jack-ins-deb : Debounce time for jack insertion (ms) | ||
51 | [<5>, <10>, <20>, <50>, <100>, <200>, <500>, <1000>] | ||
52 | - dlg,jack-det-rate: Jack type detection latency (3/4 pole) | ||
53 | ["32ms_64ms", "64ms_128ms", "128ms_256ms", "256ms_512ms"] | ||
54 | - dlg,jack-rem-deb : Debounce time for jack removal (ms) | ||
55 | [<1>, <5>, <10>, <20>] | ||
56 | - dlg,a-d-btn-thr : Impedance threshold between buttons A and D | ||
57 | [0x0 - 0xFF] | ||
58 | - dlg,d-b-btn-thr : Impedance threshold between buttons D and B | ||
59 | [0x0 - 0xFF] | ||
60 | - dlg,b-c-btn-thr : Impedance threshold between buttons B and C | ||
61 | [0x0 - 0xFF] | ||
62 | - dlg,c-mic-btn-thr : Impedance threshold between button C and Mic | ||
63 | [0x0 - 0xFF] | ||
64 | - dlg,btn-avg : Number of 8-bit readings for averaged button measurement | ||
65 | [<1>, <2>, <4>, <8>] | ||
66 | - dlg,adc-1bit-rpt : Repeat count for 1-bit button measurement | ||
67 | [<1>, <2>, <4>, <8>] | ||
68 | |||
69 | ====== | ||
70 | |||
71 | Example: | ||
72 | |||
73 | codec: da7219@1a { | ||
74 | compatible = "dlg,da7219"; | ||
75 | reg = <0x1a>; | ||
76 | |||
77 | interrupt-parent = <&gpio6>; | ||
78 | interrupts = <11 IRQ_TYPE_LEVEL_HIGH>; | ||
79 | |||
80 | VDD-supply = <®_audio>; | ||
81 | VDDMIC-supply = <®_audio>; | ||
82 | VDDIO-supply = <®_audio>; | ||
83 | |||
84 | clocks = <&clks 201>; | ||
85 | clock-names = "mclk"; | ||
86 | |||
87 | dlg,ldo-lvl = <1200>; | ||
88 | dlg,micbias-lvl = <2600>; | ||
89 | dlg,mic-amp-in-sel = "diff"; | ||
90 | |||
91 | da7219_aad { | ||
92 | dlg,btn-cfg = <50>; | ||
93 | dlg,mic-det-thr = <500>; | ||
94 | dlg,jack-ins-deb = <20>; | ||
95 | dlg,jack-det-rate = "32ms_64ms"; | ||
96 | dlg,jack-rem-deb = <1>; | ||
97 | |||
98 | dlg,a-d-btn-thr = <0xa>; | ||
99 | dlg,d-b-btn-thr = <0x16>; | ||
100 | dlg,b-c-btn-thr = <0x21>; | ||
101 | dlg,c-mic-btn-thr = <0x3E>; | ||
102 | |||
103 | dlg,btn-avg = <4>; | ||
104 | dlg,adc-1bit-rpt = <1>; | ||
105 | }; | ||
106 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt index a96774c194c8..ce55c0a6f757 100644 --- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt +++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt | |||
@@ -13,13 +13,15 @@ So having this generic sound card allows all Freescale SoC users to benefit | |||
13 | from the simplification of a new card support and the capability of the wide | 13 | from the simplification of a new card support and the capability of the wide |
14 | sample rates support through ASRC. | 14 | sample rates support through ASRC. |
15 | 15 | ||
16 | Note: The card is initially designed for those sound cards who use I2S and | 16 | Note: The card is initially designed for those sound cards who use AC'97, I2S |
17 | PCM DAI formats. However, it'll be also possible to support those non | 17 | and PCM DAI formats. However, it'll be also possible to support those non |
18 | I2S/PCM type sound cards, such as S/PDIF audio and HDMI audio, as long | 18 | AC'97/I2S/PCM type sound cards, such as S/PDIF audio and HDMI audio, as |
19 | as the driver has been properly upgraded. | 19 | long as the driver has been properly upgraded. |
20 | 20 | ||
21 | 21 | ||
22 | The compatible list for this generic sound card currently: | 22 | The compatible list for this generic sound card currently: |
23 | "fsl,imx-audio-ac97" | ||
24 | |||
23 | "fsl,imx-audio-cs42888" | 25 | "fsl,imx-audio-cs42888" |
24 | 26 | ||
25 | "fsl,imx-audio-wm8962" | 27 | "fsl,imx-audio-wm8962" |
diff --git a/Documentation/devicetree/bindings/sound/nau8825.txt b/Documentation/devicetree/bindings/sound/nau8825.txt new file mode 100644 index 000000000000..d3374231c871 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/nau8825.txt | |||
@@ -0,0 +1,102 @@ | |||
1 | Nuvoton NAU8825 audio codec | ||
2 | |||
3 | This device supports I2C only. | ||
4 | |||
5 | Required properties: | ||
6 | - compatible : Must be "nuvoton,nau8825" | ||
7 | |||
8 | - reg : the I2C address of the device. This is either 0x1a (CSB=0) or 0x1b (CSB=1). | ||
9 | |||
10 | Optional properties: | ||
11 | - nuvoton,jkdet-enable: Enable jack detection via JKDET pin. | ||
12 | - nuvoton,jkdet-pull-enable: Enable JKDET pin pull. If set - pin pull enabled, | ||
13 | otherwise pin in high impedance state. | ||
14 | - nuvoton,jkdet-pull-up: Pull-up JKDET pin. If set then JKDET pin is pull up, otherwise pull down. | ||
15 | - nuvoton,jkdet-polarity: JKDET pin polarity. 0 - active high, 1 - active low. | ||
16 | |||
17 | - nuvoton,vref-impedance: VREF Impedance selection | ||
18 | 0 - Open | ||
19 | 1 - 25 kOhm | ||
20 | 2 - 125 kOhm | ||
21 | 3 - 2.5 kOhm | ||
22 | |||
23 | - nuvoton,micbias-voltage: Micbias voltage level. | ||
24 | 0 - VDDA | ||
25 | 1 - VDDA | ||
26 | 2 - VDDA * 1.1 | ||
27 | 3 - VDDA * 1.2 | ||
28 | 4 - VDDA * 1.3 | ||
29 | 5 - VDDA * 1.4 | ||
30 | 6 - VDDA * 1.53 | ||
31 | 7 - VDDA * 1.53 | ||
32 | |||
33 | - nuvoton,sar-threshold-num: Number of buttons supported | ||
34 | - nuvoton,sar-threshold: Impedance threshold for each button. Array that contains up to 8 buttons configuration. SAR value is calculated as | ||
35 | SAR = 255 * MICBIAS / SAR_VOLTAGE * R / (2000 + R) | ||
36 | where MICBIAS is configured by 'nuvoton,micbias-voltage', SAR_VOLTAGE is configured by 'nuvoton,sar-voltage', R - button impedance. | ||
37 | Refer datasheet section 10.2 for more information about threshold calculation. | ||
38 | |||
39 | - nuvoton,sar-hysteresis: Button impedance measurement hysteresis. | ||
40 | |||
41 | - nuvoton,sar-voltage: Reference voltage for button impedance measurement. | ||
42 | 0 - VDDA | ||
43 | 1 - VDDA | ||
44 | 2 - VDDA * 1.1 | ||
45 | 3 - VDDA * 1.2 | ||
46 | 4 - VDDA * 1.3 | ||
47 | 5 - VDDA * 1.4 | ||
48 | 6 - VDDA * 1.53 | ||
49 | 7 - VDDA * 1.53 | ||
50 | |||
51 | - nuvoton,sar-compare-time: SAR compare time | ||
52 | 0 - 500 ns | ||
53 | 1 - 1 us | ||
54 | 2 - 2 us | ||
55 | 3 - 4 us | ||
56 | |||
57 | - nuvoton,sar-sampling-time: SAR sampling time | ||
58 | 0 - 2 us | ||
59 | 1 - 4 us | ||
60 | 2 - 8 us | ||
61 | 3 - 16 us | ||
62 | |||
63 | - nuvoton,short-key-debounce: Button short key press debounce time. | ||
64 | 0 - 30 ms | ||
65 | 1 - 50 ms | ||
66 | 2 - 100 ms | ||
67 | 3 - 30 ms | ||
68 | |||
69 | - nuvoton,jack-insert-debounce: number from 0 to 7 that sets debounce time to 2^(n+2) ms | ||
70 | - nuvoton,jack-eject-debounce: number from 0 to 7 that sets debounce time to 2^(n+2) ms | ||
71 | |||
72 | - clocks: list of phandle and clock specifier pairs according to common clock bindings for the | ||
73 | clocks described in clock-names | ||
74 | - clock-names: should include "mclk" for the MCLK master clock | ||
75 | |||
76 | Example: | ||
77 | |||
78 | headset: nau8825@1a { | ||
79 | compatible = "nuvoton,nau8825"; | ||
80 | reg = <0x1a>; | ||
81 | interrupt-parent = <&gpio>; | ||
82 | interrupts = <TEGRA_GPIO(E, 6) IRQ_TYPE_LEVEL_LOW>; | ||
83 | nuvoton,jkdet-enable; | ||
84 | nuvoton,jkdet-pull-enable; | ||
85 | nuvoton,jkdet-pull-up; | ||
86 | nuvoton,jkdet-polarity = <GPIO_ACTIVE_LOW>; | ||
87 | nuvoton,vref-impedance = <2>; | ||
88 | nuvoton,micbias-voltage = <6>; | ||
89 | // Setup 4 buttons impedance according to Android specification | ||
90 | nuvoton,sar-threshold-num = <4>; | ||
91 | nuvoton,sar-threshold = <0xc 0x1e 0x38 0x60>; | ||
92 | nuvoton,sar-hysteresis = <1>; | ||
93 | nuvoton,sar-voltage = <0>; | ||
94 | nuvoton,sar-compare-time = <0>; | ||
95 | nuvoton,sar-sampling-time = <0>; | ||
96 | nuvoton,short-key-debounce = <2>; | ||
97 | nuvoton,jack-insert-debounce = <7>; | ||
98 | nuvoton,jack-eject-debounce = <7>; | ||
99 | |||
100 | clock-names = "mclk"; | ||
101 | clocks = <&tegra_car TEGRA210_CLK_CLK_OUT_2>; | ||
102 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/rockchip-i2s.txt b/Documentation/devicetree/bindings/sound/rockchip-i2s.txt index 9b82c20b306b..2267d249ca0e 100644 --- a/Documentation/devicetree/bindings/sound/rockchip-i2s.txt +++ b/Documentation/devicetree/bindings/sound/rockchip-i2s.txt | |||
@@ -12,8 +12,6 @@ Required properties: | |||
12 | - reg: physical base address of the controller and length of memory mapped | 12 | - reg: physical base address of the controller and length of memory mapped |
13 | region. | 13 | region. |
14 | - interrupts: should contain the I2S interrupt. | 14 | - interrupts: should contain the I2S interrupt. |
15 | - #address-cells: should be 1. | ||
16 | - #size-cells: should be 0. | ||
17 | - dmas: DMA specifiers for tx and rx dma. See the DMA client binding, | 15 | - dmas: DMA specifiers for tx and rx dma. See the DMA client binding, |
18 | Documentation/devicetree/bindings/dma/dma.txt | 16 | Documentation/devicetree/bindings/dma/dma.txt |
19 | - dma-names: should include "tx" and "rx". | 17 | - dma-names: should include "tx" and "rx". |
@@ -21,6 +19,7 @@ Required properties: | |||
21 | - clock-names: should contain followings: | 19 | - clock-names: should contain followings: |
22 | - "i2s_hclk": clock for I2S BUS | 20 | - "i2s_hclk": clock for I2S BUS |
23 | - "i2s_clk" : clock for I2S controller | 21 | - "i2s_clk" : clock for I2S controller |
22 | - rockchip,capture-channels: max capture channels, if not set, 2 channels default. | ||
24 | 23 | ||
25 | Example for rk3288 I2S controller: | 24 | Example for rk3288 I2S controller: |
26 | 25 | ||
@@ -28,10 +27,9 @@ i2s@ff890000 { | |||
28 | compatible = "rockchip,rk3288-i2s", "rockchip,rk3066-i2s"; | 27 | compatible = "rockchip,rk3288-i2s", "rockchip,rk3066-i2s"; |
29 | reg = <0xff890000 0x10000>; | 28 | reg = <0xff890000 0x10000>; |
30 | interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>; | 29 | interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>; |
31 | #address-cells = <1>; | ||
32 | #size-cells = <0>; | ||
33 | dmas = <&pdma1 0>, <&pdma1 1>; | 30 | dmas = <&pdma1 0>, <&pdma1 1>; |
34 | dma-names = "tx", "rx"; | 31 | dma-names = "tx", "rx"; |
35 | clock-names = "i2s_hclk", "i2s_clk"; | 32 | clock-names = "i2s_hclk", "i2s_clk"; |
36 | clocks = <&cru HCLK_I2S0>, <&cru SCLK_I2S0>; | 33 | clocks = <&cru HCLK_I2S0>, <&cru SCLK_I2S0>; |
34 | rockchip,capture-channels = <2>; | ||
37 | }; | 35 | }; |
diff --git a/Documentation/devicetree/bindings/sound/rockchip-spdif.txt b/Documentation/devicetree/bindings/sound/rockchip-spdif.txt new file mode 100644 index 000000000000..e64dbdea7db9 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/rockchip-spdif.txt | |||
@@ -0,0 +1,40 @@ | |||
1 | * Rockchip SPDIF transceiver | ||
2 | |||
3 | The S/PDIF audio block is a stereo transceiver that allows the | ||
4 | processor to receive and transmit digital audio via an coaxial cable or | ||
5 | a fibre cable. | ||
6 | |||
7 | Required properties: | ||
8 | |||
9 | - compatible: should be one of the following: | ||
10 | - "rockchip,rk3288-spdif", "rockchip,rk3188-spdif" or | ||
11 | "rockchip,rk3066-spdif" | ||
12 | - reg: physical base address of the controller and length of memory mapped | ||
13 | region. | ||
14 | - interrupts: should contain the SPDIF interrupt. | ||
15 | - dmas: DMA specifiers for tx dma. See the DMA client binding, | ||
16 | Documentation/devicetree/bindings/dma/dma.txt | ||
17 | - dma-names: should be "tx" | ||
18 | - clocks: a list of phandle + clock-specifier pairs, one for each entry | ||
19 | in clock-names. | ||
20 | - clock-names: should contain following: | ||
21 | - "hclk": clock for SPDIF controller | ||
22 | - "mclk" : clock for SPDIF bus | ||
23 | |||
24 | Required properties on RK3288: | ||
25 | - rockchip,grf: the phandle of the syscon node for the general register | ||
26 | file (GRF) | ||
27 | |||
28 | Example for the rk3188 SPDIF controller: | ||
29 | |||
30 | spdif: spdif@0x1011e000 { | ||
31 | compatible = "rockchip,rk3188-spdif", "rockchip,rk3066-spdif"; | ||
32 | reg = <0x1011e000 0x2000>; | ||
33 | interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>; | ||
34 | dmas = <&dmac1_s 8>; | ||
35 | dma-names = "tx"; | ||
36 | clock-names = "hclk", "mclk"; | ||
37 | clocks = <&cru HCLK_SPDIF>, <&cru SCLK_SPDIF>; | ||
38 | status = "disabled"; | ||
39 | #sound-dai-cells = <0>; | ||
40 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/rt5640.txt b/Documentation/devicetree/bindings/sound/rt5640.txt index bac4d9ac1edc..9e62f6eb348f 100644 --- a/Documentation/devicetree/bindings/sound/rt5640.txt +++ b/Documentation/devicetree/bindings/sound/rt5640.txt | |||
@@ -14,7 +14,8 @@ Optional properties: | |||
14 | 14 | ||
15 | - realtek,in1-differential | 15 | - realtek,in1-differential |
16 | - realtek,in2-differential | 16 | - realtek,in2-differential |
17 | Boolean. Indicate MIC1/2 input are differential, rather than single-ended. | 17 | - realtek,in3-differential |
18 | Boolean. Indicate MIC1/2/3 input are differential, rather than single-ended. | ||
18 | 19 | ||
19 | - realtek,ldo1-en-gpios : The GPIO that controls the CODEC's LDO1_EN pin. | 20 | - realtek,ldo1-en-gpios : The GPIO that controls the CODEC's LDO1_EN pin. |
20 | 21 | ||
@@ -24,9 +25,11 @@ Pins on the device (for linking into audio routes) for RT5639/RT5640: | |||
24 | * DMIC2 | 25 | * DMIC2 |
25 | * MICBIAS1 | 26 | * MICBIAS1 |
26 | * IN1P | 27 | * IN1P |
27 | * IN1R | 28 | * IN1N |
28 | * IN2P | 29 | * IN2P |
29 | * IN2R | 30 | * IN2N |
31 | * IN3P | ||
32 | * IN3N | ||
30 | * HPOL | 33 | * HPOL |
31 | * HPOR | 34 | * HPOR |
32 | * LOUTL | 35 | * LOUTL |
diff --git a/Documentation/devicetree/bindings/sound/sun4i-codec.txt b/Documentation/devicetree/bindings/sound/sun4i-codec.txt index 680144b74ae9..c92966bd5488 100644 --- a/Documentation/devicetree/bindings/sound/sun4i-codec.txt +++ b/Documentation/devicetree/bindings/sound/sun4i-codec.txt | |||
@@ -13,10 +13,6 @@ Required properties: | |||
13 | - clock-names: should contain followings: | 13 | - clock-names: should contain followings: |
14 | - "apb": the parent APB clock for this controller | 14 | - "apb": the parent APB clock for this controller |
15 | - "codec": the parent module clock | 15 | - "codec": the parent module clock |
16 | - routing : A list of the connections between audio components. Each | ||
17 | entry is a pair of strings, the first being the connection's sink, | ||
18 | the second being the connection's source. | ||
19 | |||
20 | 16 | ||
21 | Example: | 17 | Example: |
22 | codec: codec@01c22c00 { | 18 | codec: codec@01c22c00 { |
@@ -28,6 +24,4 @@ codec: codec@01c22c00 { | |||
28 | clock-names = "apb", "codec"; | 24 | clock-names = "apb", "codec"; |
29 | dmas = <&dma 0 19>, <&dma 0 19>; | 25 | dmas = <&dma 0 19>, <&dma 0 19>; |
30 | dma-names = "rx", "tx"; | 26 | dma-names = "rx", "tx"; |
31 | routing = "Headphone Jack", "HP Right", | ||
32 | "Headphone Jack", "HP Left"; | ||
33 | }; | 27 | }; |
diff --git a/MAINTAINERS b/MAINTAINERS index b8577ad9b8a2..cb1a432a4081 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -894,11 +894,12 @@ M: Lennert Buytenhek <kernel@wantstofly.org> | |||
894 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | 894 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
895 | S: Maintained | 895 | S: Maintained |
896 | 896 | ||
897 | ARM/Allwinner A1X SoC support | 897 | ARM/Allwinner sunXi SoC support |
898 | M: Maxime Ripard <maxime.ripard@free-electrons.com> | 898 | M: Maxime Ripard <maxime.ripard@free-electrons.com> |
899 | M: Chen-Yu Tsai <wens@csie.org> | ||
899 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | 900 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
900 | S: Maintained | 901 | S: Maintained |
901 | N: sun[x4567]i | 902 | N: sun[x456789]i |
902 | 903 | ||
903 | ARM/Allwinner SoC Clock Support | 904 | ARM/Allwinner SoC Clock Support |
904 | M: Emilio López <emilio@elopez.com.ar> | 905 | M: Emilio López <emilio@elopez.com.ar> |
@@ -3367,6 +3368,7 @@ M: Support Opensource <support.opensource@diasemi.com> | |||
3367 | W: http://www.dialog-semiconductor.com/products | 3368 | W: http://www.dialog-semiconductor.com/products |
3368 | S: Supported | 3369 | S: Supported |
3369 | F: Documentation/hwmon/da90?? | 3370 | F: Documentation/hwmon/da90?? |
3371 | F: Documentation/devicetree/bindings/sound/da[79]*.txt | ||
3370 | F: drivers/gpio/gpio-da90??.c | 3372 | F: drivers/gpio/gpio-da90??.c |
3371 | F: drivers/hwmon/da90??-hwmon.c | 3373 | F: drivers/hwmon/da90??-hwmon.c |
3372 | F: drivers/iio/adc/da91??-*.c | 3374 | F: drivers/iio/adc/da91??-*.c |
@@ -6793,7 +6795,6 @@ F: drivers/scsi/megaraid/ | |||
6793 | 6795 | ||
6794 | MELLANOX ETHERNET DRIVER (mlx4_en) | 6796 | MELLANOX ETHERNET DRIVER (mlx4_en) |
6795 | M: Amir Vadai <amirv@mellanox.com> | 6797 | M: Amir Vadai <amirv@mellanox.com> |
6796 | M: Ido Shamay <idos@mellanox.com> | ||
6797 | L: netdev@vger.kernel.org | 6798 | L: netdev@vger.kernel.org |
6798 | S: Supported | 6799 | S: Supported |
6799 | W: http://www.mellanox.com | 6800 | W: http://www.mellanox.com |
@@ -11675,6 +11676,7 @@ F: drivers/tty/serial/zs.* | |||
11675 | ZSMALLOC COMPRESSED SLAB MEMORY ALLOCATOR | 11676 | ZSMALLOC COMPRESSED SLAB MEMORY ALLOCATOR |
11676 | M: Minchan Kim <minchan@kernel.org> | 11677 | M: Minchan Kim <minchan@kernel.org> |
11677 | M: Nitin Gupta <ngupta@vflare.org> | 11678 | M: Nitin Gupta <ngupta@vflare.org> |
11679 | R: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> | ||
11678 | L: linux-mm@kvack.org | 11680 | L: linux-mm@kvack.org |
11679 | S: Maintained | 11681 | S: Maintained |
11680 | F: mm/zsmalloc.c | 11682 | F: mm/zsmalloc.c |
@@ -1,7 +1,7 @@ | |||
1 | VERSION = 4 | 1 | VERSION = 4 |
2 | PATCHLEVEL = 3 | 2 | PATCHLEVEL = 3 |
3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 0 |
4 | EXTRAVERSION = -rc6 | 4 | EXTRAVERSION = -rc7 |
5 | NAME = Blurry Fish Butt | 5 | NAME = Blurry Fish Butt |
6 | 6 | ||
7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
diff --git a/arch/arm/boot/dts/am57xx-beagle-x15.dts b/arch/arm/boot/dts/am57xx-beagle-x15.dts index 568adf5efde0..d55e3ea89fda 100644 --- a/arch/arm/boot/dts/am57xx-beagle-x15.dts +++ b/arch/arm/boot/dts/am57xx-beagle-x15.dts | |||
@@ -402,11 +402,12 @@ | |||
402 | /* SMPS9 unused */ | 402 | /* SMPS9 unused */ |
403 | 403 | ||
404 | ldo1_reg: ldo1 { | 404 | ldo1_reg: ldo1 { |
405 | /* VDD_SD */ | 405 | /* VDD_SD / VDDSHV8 */ |
406 | regulator-name = "ldo1"; | 406 | regulator-name = "ldo1"; |
407 | regulator-min-microvolt = <1800000>; | 407 | regulator-min-microvolt = <1800000>; |
408 | regulator-max-microvolt = <3300000>; | 408 | regulator-max-microvolt = <3300000>; |
409 | regulator-boot-on; | 409 | regulator-boot-on; |
410 | regulator-always-on; | ||
410 | }; | 411 | }; |
411 | 412 | ||
412 | ldo2_reg: ldo2 { | 413 | ldo2_reg: ldo2 { |
diff --git a/arch/arm/boot/dts/armada-385-db-ap.dts b/arch/arm/boot/dts/armada-385-db-ap.dts index 89f5a95954ed..4047621b137e 100644 --- a/arch/arm/boot/dts/armada-385-db-ap.dts +++ b/arch/arm/boot/dts/armada-385-db-ap.dts | |||
@@ -46,7 +46,7 @@ | |||
46 | 46 | ||
47 | / { | 47 | / { |
48 | model = "Marvell Armada 385 Access Point Development Board"; | 48 | model = "Marvell Armada 385 Access Point Development Board"; |
49 | compatible = "marvell,a385-db-ap", "marvell,armada385", "marvell,armada38x"; | 49 | compatible = "marvell,a385-db-ap", "marvell,armada385", "marvell,armada380"; |
50 | 50 | ||
51 | chosen { | 51 | chosen { |
52 | stdout-path = "serial1:115200n8"; | 52 | stdout-path = "serial1:115200n8"; |
diff --git a/arch/arm/boot/dts/berlin2q.dtsi b/arch/arm/boot/dts/berlin2q.dtsi index 63a48490e2f9..d4dbd28d348c 100644 --- a/arch/arm/boot/dts/berlin2q.dtsi +++ b/arch/arm/boot/dts/berlin2q.dtsi | |||
@@ -152,7 +152,7 @@ | |||
152 | }; | 152 | }; |
153 | 153 | ||
154 | usb_phy2: phy@a2f400 { | 154 | usb_phy2: phy@a2f400 { |
155 | compatible = "marvell,berlin2-usb-phy"; | 155 | compatible = "marvell,berlin2cd-usb-phy"; |
156 | reg = <0xa2f400 0x128>; | 156 | reg = <0xa2f400 0x128>; |
157 | #phy-cells = <0>; | 157 | #phy-cells = <0>; |
158 | resets = <&chip_rst 0x104 14>; | 158 | resets = <&chip_rst 0x104 14>; |
@@ -170,7 +170,7 @@ | |||
170 | }; | 170 | }; |
171 | 171 | ||
172 | usb_phy0: phy@b74000 { | 172 | usb_phy0: phy@b74000 { |
173 | compatible = "marvell,berlin2-usb-phy"; | 173 | compatible = "marvell,berlin2cd-usb-phy"; |
174 | reg = <0xb74000 0x128>; | 174 | reg = <0xb74000 0x128>; |
175 | #phy-cells = <0>; | 175 | #phy-cells = <0>; |
176 | resets = <&chip_rst 0x104 12>; | 176 | resets = <&chip_rst 0x104 12>; |
@@ -178,7 +178,7 @@ | |||
178 | }; | 178 | }; |
179 | 179 | ||
180 | usb_phy1: phy@b78000 { | 180 | usb_phy1: phy@b78000 { |
181 | compatible = "marvell,berlin2-usb-phy"; | 181 | compatible = "marvell,berlin2cd-usb-phy"; |
182 | reg = <0xb78000 0x128>; | 182 | reg = <0xb78000 0x128>; |
183 | #phy-cells = <0>; | 183 | #phy-cells = <0>; |
184 | resets = <&chip_rst 0x104 13>; | 184 | resets = <&chip_rst 0x104 13>; |
diff --git a/arch/arm/boot/dts/exynos5420-peach-pit.dts b/arch/arm/boot/dts/exynos5420-peach-pit.dts index 8f4d76c5e11c..1b95da79293c 100644 --- a/arch/arm/boot/dts/exynos5420-peach-pit.dts +++ b/arch/arm/boot/dts/exynos5420-peach-pit.dts | |||
@@ -915,6 +915,11 @@ | |||
915 | }; | 915 | }; |
916 | }; | 916 | }; |
917 | 917 | ||
918 | &pmu_system_controller { | ||
919 | assigned-clocks = <&pmu_system_controller 0>; | ||
920 | assigned-clock-parents = <&clock CLK_FIN_PLL>; | ||
921 | }; | ||
922 | |||
918 | &rtc { | 923 | &rtc { |
919 | status = "okay"; | 924 | status = "okay"; |
920 | clocks = <&clock CLK_RTC>, <&max77802 MAX77802_CLK_32K_AP>; | 925 | clocks = <&clock CLK_RTC>, <&max77802 MAX77802_CLK_32K_AP>; |
diff --git a/arch/arm/boot/dts/exynos5800-peach-pi.dts b/arch/arm/boot/dts/exynos5800-peach-pi.dts index 7d5b386b5ae6..8f40c7e549bd 100644 --- a/arch/arm/boot/dts/exynos5800-peach-pi.dts +++ b/arch/arm/boot/dts/exynos5800-peach-pi.dts | |||
@@ -878,6 +878,11 @@ | |||
878 | }; | 878 | }; |
879 | }; | 879 | }; |
880 | 880 | ||
881 | &pmu_system_controller { | ||
882 | assigned-clocks = <&pmu_system_controller 0>; | ||
883 | assigned-clock-parents = <&clock CLK_FIN_PLL>; | ||
884 | }; | ||
885 | |||
881 | &rtc { | 886 | &rtc { |
882 | status = "okay"; | 887 | status = "okay"; |
883 | clocks = <&clock CLK_RTC>, <&max77802 MAX77802_CLK_32K_AP>; | 888 | clocks = <&clock CLK_RTC>, <&max77802 MAX77802_CLK_32K_AP>; |
diff --git a/arch/arm/boot/dts/imx7d.dtsi b/arch/arm/boot/dts/imx7d.dtsi index b738ce0f9d9b..6e444bb873f9 100644 --- a/arch/arm/boot/dts/imx7d.dtsi +++ b/arch/arm/boot/dts/imx7d.dtsi | |||
@@ -588,10 +588,10 @@ | |||
588 | status = "disabled"; | 588 | status = "disabled"; |
589 | }; | 589 | }; |
590 | 590 | ||
591 | uart2: serial@30870000 { | 591 | uart2: serial@30890000 { |
592 | compatible = "fsl,imx7d-uart", | 592 | compatible = "fsl,imx7d-uart", |
593 | "fsl,imx6q-uart"; | 593 | "fsl,imx6q-uart"; |
594 | reg = <0x30870000 0x10000>; | 594 | reg = <0x30890000 0x10000>; |
595 | interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>; | 595 | interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>; |
596 | clocks = <&clks IMX7D_UART2_ROOT_CLK>, | 596 | clocks = <&clks IMX7D_UART2_ROOT_CLK>, |
597 | <&clks IMX7D_UART2_ROOT_CLK>; | 597 | <&clks IMX7D_UART2_ROOT_CLK>; |
diff --git a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts index 91146c318798..5b0430041ec6 100644 --- a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts +++ b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts | |||
@@ -12,7 +12,7 @@ | |||
12 | 12 | ||
13 | / { | 13 | / { |
14 | model = "LogicPD Zoom DM3730 Torpedo Development Kit"; | 14 | model = "LogicPD Zoom DM3730 Torpedo Development Kit"; |
15 | compatible = "logicpd,dm3730-torpedo-devkit", "ti,omap36xx"; | 15 | compatible = "logicpd,dm3730-torpedo-devkit", "ti,omap3630", "ti,omap3"; |
16 | 16 | ||
17 | gpio_keys { | 17 | gpio_keys { |
18 | compatible = "gpio-keys"; | 18 | compatible = "gpio-keys"; |
diff --git a/arch/arm/boot/dts/meson.dtsi b/arch/arm/boot/dts/meson.dtsi index 548441384d2a..8c77c87660cd 100644 --- a/arch/arm/boot/dts/meson.dtsi +++ b/arch/arm/boot/dts/meson.dtsi | |||
@@ -67,7 +67,7 @@ | |||
67 | 67 | ||
68 | timer@c1109940 { | 68 | timer@c1109940 { |
69 | compatible = "amlogic,meson6-timer"; | 69 | compatible = "amlogic,meson6-timer"; |
70 | reg = <0xc1109940 0x14>; | 70 | reg = <0xc1109940 0x18>; |
71 | interrupts = <0 10 1>; | 71 | interrupts = <0 10 1>; |
72 | }; | 72 | }; |
73 | 73 | ||
@@ -80,36 +80,37 @@ | |||
80 | wdt: watchdog@c1109900 { | 80 | wdt: watchdog@c1109900 { |
81 | compatible = "amlogic,meson6-wdt"; | 81 | compatible = "amlogic,meson6-wdt"; |
82 | reg = <0xc1109900 0x8>; | 82 | reg = <0xc1109900 0x8>; |
83 | interrupts = <0 0 1>; | ||
83 | }; | 84 | }; |
84 | 85 | ||
85 | uart_AO: serial@c81004c0 { | 86 | uart_AO: serial@c81004c0 { |
86 | compatible = "amlogic,meson-uart"; | 87 | compatible = "amlogic,meson-uart"; |
87 | reg = <0xc81004c0 0x14>; | 88 | reg = <0xc81004c0 0x18>; |
88 | interrupts = <0 90 1>; | 89 | interrupts = <0 90 1>; |
89 | clocks = <&clk81>; | 90 | clocks = <&clk81>; |
90 | status = "disabled"; | 91 | status = "disabled"; |
91 | }; | 92 | }; |
92 | 93 | ||
93 | uart_A: serial@c81084c0 { | 94 | uart_A: serial@c11084c0 { |
94 | compatible = "amlogic,meson-uart"; | 95 | compatible = "amlogic,meson-uart"; |
95 | reg = <0xc81084c0 0x14>; | 96 | reg = <0xc11084c0 0x18>; |
96 | interrupts = <0 90 1>; | 97 | interrupts = <0 26 1>; |
97 | clocks = <&clk81>; | 98 | clocks = <&clk81>; |
98 | status = "disabled"; | 99 | status = "disabled"; |
99 | }; | 100 | }; |
100 | 101 | ||
101 | uart_B: serial@c81084dc { | 102 | uart_B: serial@c11084dc { |
102 | compatible = "amlogic,meson-uart"; | 103 | compatible = "amlogic,meson-uart"; |
103 | reg = <0xc81084dc 0x14>; | 104 | reg = <0xc11084dc 0x18>; |
104 | interrupts = <0 90 1>; | 105 | interrupts = <0 75 1>; |
105 | clocks = <&clk81>; | 106 | clocks = <&clk81>; |
106 | status = "disabled"; | 107 | status = "disabled"; |
107 | }; | 108 | }; |
108 | 109 | ||
109 | uart_C: serial@c8108700 { | 110 | uart_C: serial@c1108700 { |
110 | compatible = "amlogic,meson-uart"; | 111 | compatible = "amlogic,meson-uart"; |
111 | reg = <0xc8108700 0x14>; | 112 | reg = <0xc1108700 0x18>; |
112 | interrupts = <0 90 1>; | 113 | interrupts = <0 93 1>; |
113 | clocks = <&clk81>; | 114 | clocks = <&clk81>; |
114 | status = "disabled"; | 115 | status = "disabled"; |
115 | }; | 116 | }; |
diff --git a/arch/arm/boot/dts/omap3-evm-37xx.dts b/arch/arm/boot/dts/omap3-evm-37xx.dts index 16e8ce350dda..bb339d1648e0 100644 --- a/arch/arm/boot/dts/omap3-evm-37xx.dts +++ b/arch/arm/boot/dts/omap3-evm-37xx.dts | |||
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | / { | 14 | / { |
15 | model = "TI OMAP37XX EVM (TMDSEVM3730)"; | 15 | model = "TI OMAP37XX EVM (TMDSEVM3730)"; |
16 | compatible = "ti,omap3-evm-37xx", "ti,omap36xx"; | 16 | compatible = "ti,omap3-evm-37xx", "ti,omap3630", "ti,omap3"; |
17 | 17 | ||
18 | memory { | 18 | memory { |
19 | device_type = "memory"; | 19 | device_type = "memory"; |
diff --git a/arch/arm/boot/dts/ste-hrefv60plus.dtsi b/arch/arm/boot/dts/ste-hrefv60plus.dtsi index 810cda743b6d..9c2387b34d0c 100644 --- a/arch/arm/boot/dts/ste-hrefv60plus.dtsi +++ b/arch/arm/boot/dts/ste-hrefv60plus.dtsi | |||
@@ -56,7 +56,7 @@ | |||
56 | /* VMMCI level-shifter enable */ | 56 | /* VMMCI level-shifter enable */ |
57 | default_hrefv60_cfg2 { | 57 | default_hrefv60_cfg2 { |
58 | pins = "GPIO169_D22"; | 58 | pins = "GPIO169_D22"; |
59 | ste,config = <&gpio_out_lo>; | 59 | ste,config = <&gpio_out_hi>; |
60 | }; | 60 | }; |
61 | /* VMMCI level-shifter voltage select */ | 61 | /* VMMCI level-shifter voltage select */ |
62 | default_hrefv60_cfg3 { | 62 | default_hrefv60_cfg3 { |
diff --git a/arch/arm/boot/dts/tegra114.dtsi b/arch/arm/boot/dts/tegra114.dtsi index 9d4f86e9c50a..d845bd1448b5 100644 --- a/arch/arm/boot/dts/tegra114.dtsi +++ b/arch/arm/boot/dts/tegra114.dtsi | |||
@@ -234,7 +234,9 @@ | |||
234 | gpio-controller; | 234 | gpio-controller; |
235 | #interrupt-cells = <2>; | 235 | #interrupt-cells = <2>; |
236 | interrupt-controller; | 236 | interrupt-controller; |
237 | /* | ||
237 | gpio-ranges = <&pinmux 0 0 246>; | 238 | gpio-ranges = <&pinmux 0 0 246>; |
239 | */ | ||
238 | }; | 240 | }; |
239 | 241 | ||
240 | apbmisc@70000800 { | 242 | apbmisc@70000800 { |
diff --git a/arch/arm/boot/dts/tegra124.dtsi b/arch/arm/boot/dts/tegra124.dtsi index 1e204a6de12c..819e2ae2cabe 100644 --- a/arch/arm/boot/dts/tegra124.dtsi +++ b/arch/arm/boot/dts/tegra124.dtsi | |||
@@ -258,7 +258,9 @@ | |||
258 | gpio-controller; | 258 | gpio-controller; |
259 | #interrupt-cells = <2>; | 259 | #interrupt-cells = <2>; |
260 | interrupt-controller; | 260 | interrupt-controller; |
261 | /* | ||
261 | gpio-ranges = <&pinmux 0 0 251>; | 262 | gpio-ranges = <&pinmux 0 0 251>; |
263 | */ | ||
262 | }; | 264 | }; |
263 | 265 | ||
264 | apbdma: dma@0,60020000 { | 266 | apbdma: dma@0,60020000 { |
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi index e058709e6d98..969b828505ae 100644 --- a/arch/arm/boot/dts/tegra20.dtsi +++ b/arch/arm/boot/dts/tegra20.dtsi | |||
@@ -244,7 +244,9 @@ | |||
244 | gpio-controller; | 244 | gpio-controller; |
245 | #interrupt-cells = <2>; | 245 | #interrupt-cells = <2>; |
246 | interrupt-controller; | 246 | interrupt-controller; |
247 | /* | ||
247 | gpio-ranges = <&pinmux 0 0 224>; | 248 | gpio-ranges = <&pinmux 0 0 224>; |
249 | */ | ||
248 | }; | 250 | }; |
249 | 251 | ||
250 | apbmisc@70000800 { | 252 | apbmisc@70000800 { |
diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi index fe04fb5e155f..c6938ad1b543 100644 --- a/arch/arm/boot/dts/tegra30.dtsi +++ b/arch/arm/boot/dts/tegra30.dtsi | |||
@@ -349,7 +349,9 @@ | |||
349 | gpio-controller; | 349 | gpio-controller; |
350 | #interrupt-cells = <2>; | 350 | #interrupt-cells = <2>; |
351 | interrupt-controller; | 351 | interrupt-controller; |
352 | /* | ||
352 | gpio-ranges = <&pinmux 0 0 248>; | 353 | gpio-ranges = <&pinmux 0 0 248>; |
354 | */ | ||
353 | }; | 355 | }; |
354 | 356 | ||
355 | apbmisc@70000800 { | 357 | apbmisc@70000800 { |
diff --git a/arch/arm/boot/dts/uniphier-ph1-ld6b-ref.dts b/arch/arm/boot/dts/uniphier-ph1-ld6b-ref.dts index 33963acd7e8f..f80f772d99fb 100644 --- a/arch/arm/boot/dts/uniphier-ph1-ld6b-ref.dts +++ b/arch/arm/boot/dts/uniphier-ph1-ld6b-ref.dts | |||
@@ -85,7 +85,7 @@ | |||
85 | }; | 85 | }; |
86 | 86 | ||
87 | ðsc { | 87 | ðsc { |
88 | interrupts = <0 50 4>; | 88 | interrupts = <0 52 4>; |
89 | }; | 89 | }; |
90 | 90 | ||
91 | &serial0 { | 91 | &serial0 { |
diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig index 210eccadb69a..356970f3b25e 100644 --- a/arch/arm/kvm/Kconfig +++ b/arch/arm/kvm/Kconfig | |||
@@ -21,6 +21,7 @@ config KVM | |||
21 | depends on MMU && OF | 21 | depends on MMU && OF |
22 | select PREEMPT_NOTIFIERS | 22 | select PREEMPT_NOTIFIERS |
23 | select ANON_INODES | 23 | select ANON_INODES |
24 | select ARM_GIC | ||
24 | select HAVE_KVM_CPU_RELAX_INTERCEPT | 25 | select HAVE_KVM_CPU_RELAX_INTERCEPT |
25 | select HAVE_KVM_ARCH_TLB_FLUSH_ALL | 26 | select HAVE_KVM_ARCH_TLB_FLUSH_ALL |
26 | select KVM_MMIO | 27 | select KVM_MMIO |
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index dc017adfddc8..78b286994577 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c | |||
@@ -1080,7 +1080,7 @@ static int init_hyp_mode(void) | |||
1080 | */ | 1080 | */ |
1081 | err = kvm_timer_hyp_init(); | 1081 | err = kvm_timer_hyp_init(); |
1082 | if (err) | 1082 | if (err) |
1083 | goto out_free_mappings; | 1083 | goto out_free_context; |
1084 | 1084 | ||
1085 | #ifndef CONFIG_HOTPLUG_CPU | 1085 | #ifndef CONFIG_HOTPLUG_CPU |
1086 | free_boot_hyp_pgd(); | 1086 | free_boot_hyp_pgd(); |
diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c index 4a87e86dec45..7c21760f590f 100644 --- a/arch/arm/mach-exynos/pm_domains.c +++ b/arch/arm/mach-exynos/pm_domains.c | |||
@@ -200,15 +200,15 @@ no_clk: | |||
200 | args.args_count = 0; | 200 | args.args_count = 0; |
201 | child_domain = of_genpd_get_from_provider(&args); | 201 | child_domain = of_genpd_get_from_provider(&args); |
202 | if (IS_ERR(child_domain)) | 202 | if (IS_ERR(child_domain)) |
203 | goto next_pd; | 203 | continue; |
204 | 204 | ||
205 | if (of_parse_phandle_with_args(np, "power-domains", | 205 | if (of_parse_phandle_with_args(np, "power-domains", |
206 | "#power-domain-cells", 0, &args) != 0) | 206 | "#power-domain-cells", 0, &args) != 0) |
207 | goto next_pd; | 207 | continue; |
208 | 208 | ||
209 | parent_domain = of_genpd_get_from_provider(&args); | 209 | parent_domain = of_genpd_get_from_provider(&args); |
210 | if (IS_ERR(parent_domain)) | 210 | if (IS_ERR(parent_domain)) |
211 | goto next_pd; | 211 | continue; |
212 | 212 | ||
213 | if (pm_genpd_add_subdomain(parent_domain, child_domain)) | 213 | if (pm_genpd_add_subdomain(parent_domain, child_domain)) |
214 | pr_warn("%s failed to add subdomain: %s\n", | 214 | pr_warn("%s failed to add subdomain: %s\n", |
@@ -216,8 +216,6 @@ no_clk: | |||
216 | else | 216 | else |
217 | pr_info("%s has as child subdomain: %s.\n", | 217 | pr_info("%s has as child subdomain: %s.\n", |
218 | parent_domain->name, child_domain->name); | 218 | parent_domain->name, child_domain->name); |
219 | next_pd: | ||
220 | of_node_put(np); | ||
221 | } | 219 | } |
222 | 220 | ||
223 | return 0; | 221 | return 0; |
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig index b3a0dff67e3f..33d1460a5639 100644 --- a/arch/arm/mach-omap2/Kconfig +++ b/arch/arm/mach-omap2/Kconfig | |||
@@ -49,6 +49,7 @@ config SOC_OMAP5 | |||
49 | select OMAP_INTERCONNECT | 49 | select OMAP_INTERCONNECT |
50 | select OMAP_INTERCONNECT_BARRIER | 50 | select OMAP_INTERCONNECT_BARRIER |
51 | select PM_OPP if PM | 51 | select PM_OPP if PM |
52 | select ZONE_DMA if ARM_LPAE | ||
52 | 53 | ||
53 | config SOC_AM33XX | 54 | config SOC_AM33XX |
54 | bool "TI AM33XX" | 55 | bool "TI AM33XX" |
@@ -78,6 +79,7 @@ config SOC_DRA7XX | |||
78 | select OMAP_INTERCONNECT | 79 | select OMAP_INTERCONNECT |
79 | select OMAP_INTERCONNECT_BARRIER | 80 | select OMAP_INTERCONNECT_BARRIER |
80 | select PM_OPP if PM | 81 | select PM_OPP if PM |
82 | select ZONE_DMA if ARM_LPAE | ||
81 | 83 | ||
82 | config ARCH_OMAP2PLUS | 84 | config ARCH_OMAP2PLUS |
83 | bool | 85 | bool |
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c index 6133eaac685d..fb219a30c10c 100644 --- a/arch/arm/mach-omap2/board-generic.c +++ b/arch/arm/mach-omap2/board-generic.c | |||
@@ -106,6 +106,7 @@ DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)") | |||
106 | MACHINE_END | 106 | MACHINE_END |
107 | 107 | ||
108 | static const char *const omap36xx_boards_compat[] __initconst = { | 108 | static const char *const omap36xx_boards_compat[] __initconst = { |
109 | "ti,omap3630", | ||
109 | "ti,omap36xx", | 110 | "ti,omap36xx", |
110 | NULL, | 111 | NULL, |
111 | }; | 112 | }; |
@@ -243,6 +244,9 @@ static const char *const omap5_boards_compat[] __initconst = { | |||
243 | }; | 244 | }; |
244 | 245 | ||
245 | DT_MACHINE_START(OMAP5_DT, "Generic OMAP5 (Flattened Device Tree)") | 246 | DT_MACHINE_START(OMAP5_DT, "Generic OMAP5 (Flattened Device Tree)") |
247 | #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE) | ||
248 | .dma_zone_size = SZ_2G, | ||
249 | #endif | ||
246 | .reserve = omap_reserve, | 250 | .reserve = omap_reserve, |
247 | .smp = smp_ops(omap4_smp_ops), | 251 | .smp = smp_ops(omap4_smp_ops), |
248 | .map_io = omap5_map_io, | 252 | .map_io = omap5_map_io, |
@@ -288,6 +292,9 @@ static const char *const dra74x_boards_compat[] __initconst = { | |||
288 | }; | 292 | }; |
289 | 293 | ||
290 | DT_MACHINE_START(DRA74X_DT, "Generic DRA74X (Flattened Device Tree)") | 294 | DT_MACHINE_START(DRA74X_DT, "Generic DRA74X (Flattened Device Tree)") |
295 | #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE) | ||
296 | .dma_zone_size = SZ_2G, | ||
297 | #endif | ||
291 | .reserve = omap_reserve, | 298 | .reserve = omap_reserve, |
292 | .smp = smp_ops(omap4_smp_ops), | 299 | .smp = smp_ops(omap4_smp_ops), |
293 | .map_io = dra7xx_map_io, | 300 | .map_io = dra7xx_map_io, |
@@ -308,6 +315,9 @@ static const char *const dra72x_boards_compat[] __initconst = { | |||
308 | }; | 315 | }; |
309 | 316 | ||
310 | DT_MACHINE_START(DRA72X_DT, "Generic DRA72X (Flattened Device Tree)") | 317 | DT_MACHINE_START(DRA72X_DT, "Generic DRA72X (Flattened Device Tree)") |
318 | #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE) | ||
319 | .dma_zone_size = SZ_2G, | ||
320 | #endif | ||
311 | .reserve = omap_reserve, | 321 | .reserve = omap_reserve, |
312 | .map_io = dra7xx_map_io, | 322 | .map_io = dra7xx_map_io, |
313 | .init_early = dra7xx_init_early, | 323 | .init_early = dra7xx_init_early, |
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index ea56397599c2..1dfe34654c43 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c | |||
@@ -559,7 +559,14 @@ static void pdata_quirks_check(struct pdata_init *quirks) | |||
559 | 559 | ||
560 | void __init pdata_quirks_init(const struct of_device_id *omap_dt_match_table) | 560 | void __init pdata_quirks_init(const struct of_device_id *omap_dt_match_table) |
561 | { | 561 | { |
562 | omap_sdrc_init(NULL, NULL); | 562 | /* |
563 | * We still need this for omap2420 and omap3 PM to work, others are | ||
564 | * using drivers/misc/sram.c already. | ||
565 | */ | ||
566 | if (of_machine_is_compatible("ti,omap2420") || | ||
567 | of_machine_is_compatible("ti,omap3")) | ||
568 | omap_sdrc_init(NULL, NULL); | ||
569 | |||
563 | pdata_quirks_check(auxdata_quirks); | 570 | pdata_quirks_check(auxdata_quirks); |
564 | of_platform_populate(NULL, omap_dt_match_table, | 571 | of_platform_populate(NULL, omap_dt_match_table, |
565 | omap_auxdata_lookup, NULL); | 572 | omap_auxdata_lookup, NULL); |
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c index 06005d3f2ba3..20ce2d386f17 100644 --- a/arch/arm/mach-pxa/pxa3xx.c +++ b/arch/arm/mach-pxa/pxa3xx.c | |||
@@ -42,10 +42,6 @@ | |||
42 | #define PECR_IS(n) ((1 << ((n) * 2)) << 29) | 42 | #define PECR_IS(n) ((1 << ((n) * 2)) << 29) |
43 | 43 | ||
44 | extern void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int)); | 44 | extern void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int)); |
45 | #ifdef CONFIG_PM | ||
46 | |||
47 | #define ISRAM_START 0x5c000000 | ||
48 | #define ISRAM_SIZE SZ_256K | ||
49 | 45 | ||
50 | /* | 46 | /* |
51 | * NAND NFC: DFI bus arbitration subset | 47 | * NAND NFC: DFI bus arbitration subset |
@@ -54,6 +50,11 @@ extern void __init pxa_dt_irq_init(int (*fn)(struct irq_data *, unsigned int)); | |||
54 | #define NDCR_ND_ARB_EN (1 << 12) | 50 | #define NDCR_ND_ARB_EN (1 << 12) |
55 | #define NDCR_ND_ARB_CNTL (1 << 19) | 51 | #define NDCR_ND_ARB_CNTL (1 << 19) |
56 | 52 | ||
53 | #ifdef CONFIG_PM | ||
54 | |||
55 | #define ISRAM_START 0x5c000000 | ||
56 | #define ISRAM_SIZE SZ_256K | ||
57 | |||
57 | static void __iomem *sram; | 58 | static void __iomem *sram; |
58 | static unsigned long wakeup_src; | 59 | static unsigned long wakeup_src; |
59 | 60 | ||
diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c index 876060bcceeb..b8efb8cd1f73 100644 --- a/arch/arm/net/bpf_jit_32.c +++ b/arch/arm/net/bpf_jit_32.c | |||
@@ -614,6 +614,7 @@ load_common: | |||
614 | case BPF_LD | BPF_B | BPF_IND: | 614 | case BPF_LD | BPF_B | BPF_IND: |
615 | load_order = 0; | 615 | load_order = 0; |
616 | load_ind: | 616 | load_ind: |
617 | update_on_xread(ctx); | ||
617 | OP_IMM3(ARM_ADD, r_off, r_X, k, ctx); | 618 | OP_IMM3(ARM_ADD, r_off, r_X, k, ctx); |
618 | goto load_common; | 619 | goto load_common; |
619 | case BPF_LDX | BPF_IMM: | 620 | case BPF_LDX | BPF_IMM: |
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c index 2235081a04ee..8861c367d061 100644 --- a/arch/arm/plat-orion/common.c +++ b/arch/arm/plat-orion/common.c | |||
@@ -495,7 +495,7 @@ void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq) | |||
495 | 495 | ||
496 | d->netdev = &orion_ge00.dev; | 496 | d->netdev = &orion_ge00.dev; |
497 | for (i = 0; i < d->nr_chips; i++) | 497 | for (i = 0; i < d->nr_chips; i++) |
498 | d->chip[i].host_dev = &orion_ge00_shared.dev; | 498 | d->chip[i].host_dev = &orion_ge_mvmdio.dev; |
499 | orion_switch_device.dev.platform_data = d; | 499 | orion_switch_device.dev.platform_data = d; |
500 | 500 | ||
501 | platform_device_register(&orion_switch_device); | 501 | platform_device_register(&orion_switch_device); |
diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h index 0dc42c5082b7..5f8229e24fe6 100644 --- a/arch/powerpc/include/asm/cache.h +++ b/arch/powerpc/include/asm/cache.h | |||
@@ -3,7 +3,6 @@ | |||
3 | 3 | ||
4 | #ifdef __KERNEL__ | 4 | #ifdef __KERNEL__ |
5 | 5 | ||
6 | #include <asm/reg.h> | ||
7 | 6 | ||
8 | /* bytes per L1 cache line */ | 7 | /* bytes per L1 cache line */ |
9 | #if defined(CONFIG_8xx) || defined(CONFIG_403GCX) | 8 | #if defined(CONFIG_8xx) || defined(CONFIG_403GCX) |
@@ -40,12 +39,6 @@ struct ppc64_caches { | |||
40 | }; | 39 | }; |
41 | 40 | ||
42 | extern struct ppc64_caches ppc64_caches; | 41 | extern struct ppc64_caches ppc64_caches; |
43 | |||
44 | static inline void logmpp(u64 x) | ||
45 | { | ||
46 | asm volatile(PPC_LOGMPP(R1) : : "r" (x)); | ||
47 | } | ||
48 | |||
49 | #endif /* __powerpc64__ && ! __ASSEMBLY__ */ | 42 | #endif /* __powerpc64__ && ! __ASSEMBLY__ */ |
50 | 43 | ||
51 | #if defined(__ASSEMBLY__) | 44 | #if defined(__ASSEMBLY__) |
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 827a38d7a9db..887c259556df 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h | |||
@@ -297,8 +297,6 @@ struct kvmppc_vcore { | |||
297 | u32 arch_compat; | 297 | u32 arch_compat; |
298 | ulong pcr; | 298 | ulong pcr; |
299 | ulong dpdes; /* doorbell state (POWER8) */ | 299 | ulong dpdes; /* doorbell state (POWER8) */ |
300 | void *mpp_buffer; /* Micro Partition Prefetch buffer */ | ||
301 | bool mpp_buffer_is_valid; | ||
302 | ulong conferring_threads; | 300 | ulong conferring_threads; |
303 | }; | 301 | }; |
304 | 302 | ||
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h index 790f5d1d9a46..7ab04fc59e24 100644 --- a/arch/powerpc/include/asm/ppc-opcode.h +++ b/arch/powerpc/include/asm/ppc-opcode.h | |||
@@ -141,7 +141,6 @@ | |||
141 | #define PPC_INST_ISEL 0x7c00001e | 141 | #define PPC_INST_ISEL 0x7c00001e |
142 | #define PPC_INST_ISEL_MASK 0xfc00003e | 142 | #define PPC_INST_ISEL_MASK 0xfc00003e |
143 | #define PPC_INST_LDARX 0x7c0000a8 | 143 | #define PPC_INST_LDARX 0x7c0000a8 |
144 | #define PPC_INST_LOGMPP 0x7c0007e4 | ||
145 | #define PPC_INST_LSWI 0x7c0004aa | 144 | #define PPC_INST_LSWI 0x7c0004aa |
146 | #define PPC_INST_LSWX 0x7c00042a | 145 | #define PPC_INST_LSWX 0x7c00042a |
147 | #define PPC_INST_LWARX 0x7c000028 | 146 | #define PPC_INST_LWARX 0x7c000028 |
@@ -285,20 +284,6 @@ | |||
285 | #define __PPC_EH(eh) 0 | 284 | #define __PPC_EH(eh) 0 |
286 | #endif | 285 | #endif |
287 | 286 | ||
288 | /* POWER8 Micro Partition Prefetch (MPP) parameters */ | ||
289 | /* Address mask is common for LOGMPP instruction and MPPR SPR */ | ||
290 | #define PPC_MPPE_ADDRESS_MASK 0xffffffffc000ULL | ||
291 | |||
292 | /* Bits 60 and 61 of MPP SPR should be set to one of the following */ | ||
293 | /* Aborting the fetch is indeed setting 00 in the table size bits */ | ||
294 | #define PPC_MPPR_FETCH_ABORT (0x0ULL << 60) | ||
295 | #define PPC_MPPR_FETCH_WHOLE_TABLE (0x2ULL << 60) | ||
296 | |||
297 | /* Bits 54 and 55 of register for LOGMPP instruction should be set to: */ | ||
298 | #define PPC_LOGMPP_LOG_L2 (0x02ULL << 54) | ||
299 | #define PPC_LOGMPP_LOG_L2L3 (0x01ULL << 54) | ||
300 | #define PPC_LOGMPP_LOG_ABORT (0x03ULL << 54) | ||
301 | |||
302 | /* Deal with instructions that older assemblers aren't aware of */ | 287 | /* Deal with instructions that older assemblers aren't aware of */ |
303 | #define PPC_DCBAL(a, b) stringify_in_c(.long PPC_INST_DCBAL | \ | 288 | #define PPC_DCBAL(a, b) stringify_in_c(.long PPC_INST_DCBAL | \ |
304 | __PPC_RA(a) | __PPC_RB(b)) | 289 | __PPC_RA(a) | __PPC_RB(b)) |
@@ -307,8 +292,6 @@ | |||
307 | #define PPC_LDARX(t, a, b, eh) stringify_in_c(.long PPC_INST_LDARX | \ | 292 | #define PPC_LDARX(t, a, b, eh) stringify_in_c(.long PPC_INST_LDARX | \ |
308 | ___PPC_RT(t) | ___PPC_RA(a) | \ | 293 | ___PPC_RT(t) | ___PPC_RA(a) | \ |
309 | ___PPC_RB(b) | __PPC_EH(eh)) | 294 | ___PPC_RB(b) | __PPC_EH(eh)) |
310 | #define PPC_LOGMPP(b) stringify_in_c(.long PPC_INST_LOGMPP | \ | ||
311 | __PPC_RB(b)) | ||
312 | #define PPC_LWARX(t, a, b, eh) stringify_in_c(.long PPC_INST_LWARX | \ | 295 | #define PPC_LWARX(t, a, b, eh) stringify_in_c(.long PPC_INST_LWARX | \ |
313 | ___PPC_RT(t) | ___PPC_RA(a) | \ | 296 | ___PPC_RT(t) | ___PPC_RA(a) | \ |
314 | ___PPC_RB(b) | __PPC_EH(eh)) | 297 | ___PPC_RB(b) | __PPC_EH(eh)) |
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index aa1cc5f015ee..a908ada8e0a5 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h | |||
@@ -226,7 +226,6 @@ | |||
226 | #define CTRL_TE 0x00c00000 /* thread enable */ | 226 | #define CTRL_TE 0x00c00000 /* thread enable */ |
227 | #define CTRL_RUNLATCH 0x1 | 227 | #define CTRL_RUNLATCH 0x1 |
228 | #define SPRN_DAWR 0xB4 | 228 | #define SPRN_DAWR 0xB4 |
229 | #define SPRN_MPPR 0xB8 /* Micro Partition Prefetch Register */ | ||
230 | #define SPRN_RPR 0xBA /* Relative Priority Register */ | 229 | #define SPRN_RPR 0xBA /* Relative Priority Register */ |
231 | #define SPRN_CIABR 0xBB | 230 | #define SPRN_CIABR 0xBB |
232 | #define CIABR_PRIV 0x3 | 231 | #define CIABR_PRIV 0x3 |
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c index 84bf934cf748..5a753fae8265 100644 --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c | |||
@@ -1043,6 +1043,9 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs) | |||
1043 | if (!capable(CAP_SYS_ADMIN)) | 1043 | if (!capable(CAP_SYS_ADMIN)) |
1044 | return -EPERM; | 1044 | return -EPERM; |
1045 | 1045 | ||
1046 | if (!rtas.entry) | ||
1047 | return -EINVAL; | ||
1048 | |||
1046 | if (copy_from_user(&args, uargs, 3 * sizeof(u32)) != 0) | 1049 | if (copy_from_user(&args, uargs, 3 * sizeof(u32)) != 0) |
1047 | return -EFAULT; | 1050 | return -EFAULT; |
1048 | 1051 | ||
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 228049786888..9c26c5a96ea2 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c | |||
@@ -36,7 +36,6 @@ | |||
36 | 36 | ||
37 | #include <asm/reg.h> | 37 | #include <asm/reg.h> |
38 | #include <asm/cputable.h> | 38 | #include <asm/cputable.h> |
39 | #include <asm/cache.h> | ||
40 | #include <asm/cacheflush.h> | 39 | #include <asm/cacheflush.h> |
41 | #include <asm/tlbflush.h> | 40 | #include <asm/tlbflush.h> |
42 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
@@ -75,12 +74,6 @@ | |||
75 | 74 | ||
76 | static DECLARE_BITMAP(default_enabled_hcalls, MAX_HCALL_OPCODE/4 + 1); | 75 | static DECLARE_BITMAP(default_enabled_hcalls, MAX_HCALL_OPCODE/4 + 1); |
77 | 76 | ||
78 | #if defined(CONFIG_PPC_64K_PAGES) | ||
79 | #define MPP_BUFFER_ORDER 0 | ||
80 | #elif defined(CONFIG_PPC_4K_PAGES) | ||
81 | #define MPP_BUFFER_ORDER 3 | ||
82 | #endif | ||
83 | |||
84 | static int dynamic_mt_modes = 6; | 77 | static int dynamic_mt_modes = 6; |
85 | module_param(dynamic_mt_modes, int, S_IRUGO | S_IWUSR); | 78 | module_param(dynamic_mt_modes, int, S_IRUGO | S_IWUSR); |
86 | MODULE_PARM_DESC(dynamic_mt_modes, "Set of allowed dynamic micro-threading modes: 0 (= none), 2, 4, or 6 (= 2 or 4)"); | 79 | MODULE_PARM_DESC(dynamic_mt_modes, "Set of allowed dynamic micro-threading modes: 0 (= none), 2, 4, or 6 (= 2 or 4)"); |
@@ -1455,13 +1448,6 @@ static struct kvmppc_vcore *kvmppc_vcore_create(struct kvm *kvm, int core) | |||
1455 | vcore->kvm = kvm; | 1448 | vcore->kvm = kvm; |
1456 | INIT_LIST_HEAD(&vcore->preempt_list); | 1449 | INIT_LIST_HEAD(&vcore->preempt_list); |
1457 | 1450 | ||
1458 | vcore->mpp_buffer_is_valid = false; | ||
1459 | |||
1460 | if (cpu_has_feature(CPU_FTR_ARCH_207S)) | ||
1461 | vcore->mpp_buffer = (void *)__get_free_pages( | ||
1462 | GFP_KERNEL|__GFP_ZERO, | ||
1463 | MPP_BUFFER_ORDER); | ||
1464 | |||
1465 | return vcore; | 1451 | return vcore; |
1466 | } | 1452 | } |
1467 | 1453 | ||
@@ -1894,33 +1880,6 @@ static int on_primary_thread(void) | |||
1894 | return 1; | 1880 | return 1; |
1895 | } | 1881 | } |
1896 | 1882 | ||
1897 | static void kvmppc_start_saving_l2_cache(struct kvmppc_vcore *vc) | ||
1898 | { | ||
1899 | phys_addr_t phy_addr, mpp_addr; | ||
1900 | |||
1901 | phy_addr = (phys_addr_t)virt_to_phys(vc->mpp_buffer); | ||
1902 | mpp_addr = phy_addr & PPC_MPPE_ADDRESS_MASK; | ||
1903 | |||
1904 | mtspr(SPRN_MPPR, mpp_addr | PPC_MPPR_FETCH_ABORT); | ||
1905 | logmpp(mpp_addr | PPC_LOGMPP_LOG_L2); | ||
1906 | |||
1907 | vc->mpp_buffer_is_valid = true; | ||
1908 | } | ||
1909 | |||
1910 | static void kvmppc_start_restoring_l2_cache(const struct kvmppc_vcore *vc) | ||
1911 | { | ||
1912 | phys_addr_t phy_addr, mpp_addr; | ||
1913 | |||
1914 | phy_addr = virt_to_phys(vc->mpp_buffer); | ||
1915 | mpp_addr = phy_addr & PPC_MPPE_ADDRESS_MASK; | ||
1916 | |||
1917 | /* We must abort any in-progress save operations to ensure | ||
1918 | * the table is valid so that prefetch engine knows when to | ||
1919 | * stop prefetching. */ | ||
1920 | logmpp(mpp_addr | PPC_LOGMPP_LOG_ABORT); | ||
1921 | mtspr(SPRN_MPPR, mpp_addr | PPC_MPPR_FETCH_WHOLE_TABLE); | ||
1922 | } | ||
1923 | |||
1924 | /* | 1883 | /* |
1925 | * A list of virtual cores for each physical CPU. | 1884 | * A list of virtual cores for each physical CPU. |
1926 | * These are vcores that could run but their runner VCPU tasks are | 1885 | * These are vcores that could run but their runner VCPU tasks are |
@@ -2471,14 +2430,8 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc) | |||
2471 | 2430 | ||
2472 | srcu_idx = srcu_read_lock(&vc->kvm->srcu); | 2431 | srcu_idx = srcu_read_lock(&vc->kvm->srcu); |
2473 | 2432 | ||
2474 | if (vc->mpp_buffer_is_valid) | ||
2475 | kvmppc_start_restoring_l2_cache(vc); | ||
2476 | |||
2477 | __kvmppc_vcore_entry(); | 2433 | __kvmppc_vcore_entry(); |
2478 | 2434 | ||
2479 | if (vc->mpp_buffer) | ||
2480 | kvmppc_start_saving_l2_cache(vc); | ||
2481 | |||
2482 | srcu_read_unlock(&vc->kvm->srcu, srcu_idx); | 2435 | srcu_read_unlock(&vc->kvm->srcu, srcu_idx); |
2483 | 2436 | ||
2484 | spin_lock(&vc->lock); | 2437 | spin_lock(&vc->lock); |
@@ -3073,14 +3026,8 @@ static void kvmppc_free_vcores(struct kvm *kvm) | |||
3073 | { | 3026 | { |
3074 | long int i; | 3027 | long int i; |
3075 | 3028 | ||
3076 | for (i = 0; i < KVM_MAX_VCORES; ++i) { | 3029 | for (i = 0; i < KVM_MAX_VCORES; ++i) |
3077 | if (kvm->arch.vcores[i] && kvm->arch.vcores[i]->mpp_buffer) { | ||
3078 | struct kvmppc_vcore *vc = kvm->arch.vcores[i]; | ||
3079 | free_pages((unsigned long)vc->mpp_buffer, | ||
3080 | MPP_BUFFER_ORDER); | ||
3081 | } | ||
3082 | kfree(kvm->arch.vcores[i]); | 3030 | kfree(kvm->arch.vcores[i]); |
3083 | } | ||
3084 | kvm->arch.online_vcores = 0; | 3031 | kvm->arch.online_vcores = 0; |
3085 | } | 3032 | } |
3086 | 3033 | ||
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c index 8f70ba681a78..ca264833ee64 100644 --- a/arch/powerpc/platforms/powernv/smp.c +++ b/arch/powerpc/platforms/powernv/smp.c | |||
@@ -171,7 +171,26 @@ static void pnv_smp_cpu_kill_self(void) | |||
171 | * so clear LPCR:PECE1. We keep PECE2 enabled. | 171 | * so clear LPCR:PECE1. We keep PECE2 enabled. |
172 | */ | 172 | */ |
173 | mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1); | 173 | mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1); |
174 | |||
175 | /* | ||
176 | * Hard-disable interrupts, and then clear irq_happened flags | ||
177 | * that we can safely ignore while off-line, since they | ||
178 | * are for things for which we do no processing when off-line | ||
179 | * (or in the case of HMI, all the processing we need to do | ||
180 | * is done in lower-level real-mode code). | ||
181 | */ | ||
182 | hard_irq_disable(); | ||
183 | local_paca->irq_happened &= ~(PACA_IRQ_DEC | PACA_IRQ_HMI); | ||
184 | |||
174 | while (!generic_check_cpu_restart(cpu)) { | 185 | while (!generic_check_cpu_restart(cpu)) { |
186 | /* | ||
187 | * Clear IPI flag, since we don't handle IPIs while | ||
188 | * offline, except for those when changing micro-threading | ||
189 | * mode, which are handled explicitly below, and those | ||
190 | * for coming online, which are handled via | ||
191 | * generic_check_cpu_restart() calls. | ||
192 | */ | ||
193 | kvmppc_set_host_ipi(cpu, 0); | ||
175 | 194 | ||
176 | ppc64_runlatch_off(); | 195 | ppc64_runlatch_off(); |
177 | 196 | ||
@@ -196,20 +215,20 @@ static void pnv_smp_cpu_kill_self(void) | |||
196 | * having finished executing in a KVM guest, then srr1 | 215 | * having finished executing in a KVM guest, then srr1 |
197 | * contains 0. | 216 | * contains 0. |
198 | */ | 217 | */ |
199 | if ((srr1 & wmask) == SRR1_WAKEEE) { | 218 | if (((srr1 & wmask) == SRR1_WAKEEE) || |
219 | (local_paca->irq_happened & PACA_IRQ_EE)) { | ||
200 | icp_native_flush_interrupt(); | 220 | icp_native_flush_interrupt(); |
201 | local_paca->irq_happened &= PACA_IRQ_HARD_DIS; | ||
202 | smp_mb(); | ||
203 | } else if ((srr1 & wmask) == SRR1_WAKEHDBELL) { | 221 | } else if ((srr1 & wmask) == SRR1_WAKEHDBELL) { |
204 | unsigned long msg = PPC_DBELL_TYPE(PPC_DBELL_SERVER); | 222 | unsigned long msg = PPC_DBELL_TYPE(PPC_DBELL_SERVER); |
205 | asm volatile(PPC_MSGCLR(%0) : : "r" (msg)); | 223 | asm volatile(PPC_MSGCLR(%0) : : "r" (msg)); |
206 | kvmppc_set_host_ipi(cpu, 0); | ||
207 | } | 224 | } |
225 | local_paca->irq_happened &= ~(PACA_IRQ_EE | PACA_IRQ_DBELL); | ||
226 | smp_mb(); | ||
208 | 227 | ||
209 | if (cpu_core_split_required()) | 228 | if (cpu_core_split_required()) |
210 | continue; | 229 | continue; |
211 | 230 | ||
212 | if (!generic_check_cpu_restart(cpu)) | 231 | if (srr1 && !generic_check_cpu_restart(cpu)) |
213 | DBG("CPU%d Unexpected exit while offline !\n", cpu); | 232 | DBG("CPU%d Unexpected exit while offline !\n", cpu); |
214 | } | 233 | } |
215 | mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) | LPCR_PECE1); | 234 | mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) | LPCR_PECE1); |
diff --git a/arch/um/Makefile b/arch/um/Makefile index 098ab3333e7c..e3abe6f3156d 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile | |||
@@ -70,8 +70,8 @@ KBUILD_AFLAGS += $(ARCH_INCLUDE) | |||
70 | 70 | ||
71 | USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \ | 71 | USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \ |
72 | $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ | 72 | $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ |
73 | -D_FILE_OFFSET_BITS=64 -idirafter include \ | 73 | -D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \ |
74 | -D__KERNEL__ -D__UM_HOST__ | 74 | -idirafter $(obj)/include -D__KERNEL__ -D__UM_HOST__ |
75 | 75 | ||
76 | #This will adjust *FLAGS accordingly to the platform. | 76 | #This will adjust *FLAGS accordingly to the platform. |
77 | include $(ARCH_DIR)/Makefile-os-$(OS) | 77 | include $(ARCH_DIR)/Makefile-os-$(OS) |
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c index d8a9fce6ee2e..98783dd0fa2e 100644 --- a/arch/um/kernel/trap.c +++ b/arch/um/kernel/trap.c | |||
@@ -220,7 +220,7 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, | |||
220 | show_regs(container_of(regs, struct pt_regs, regs)); | 220 | show_regs(container_of(regs, struct pt_regs, regs)); |
221 | panic("Segfault with no mm"); | 221 | panic("Segfault with no mm"); |
222 | } | 222 | } |
223 | else if (!is_user && address < TASK_SIZE) { | 223 | else if (!is_user && address > PAGE_SIZE && address < TASK_SIZE) { |
224 | show_regs(container_of(regs, struct pt_regs, regs)); | 224 | show_regs(container_of(regs, struct pt_regs, regs)); |
225 | panic("Kernel tried to access user memory at addr 0x%lx, ip 0x%lx", | 225 | panic("Kernel tried to access user memory at addr 0x%lx, ip 0x%lx", |
226 | address, ip); | 226 | address, ip); |
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c index e3ee4a51ef63..3f02d4232812 100644 --- a/arch/um/os-Linux/helper.c +++ b/arch/um/os-Linux/helper.c | |||
@@ -96,7 +96,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv) | |||
96 | "ret = %d\n", -n); | 96 | "ret = %d\n", -n); |
97 | ret = n; | 97 | ret = n; |
98 | } | 98 | } |
99 | CATCH_EINTR(waitpid(pid, NULL, __WCLONE)); | 99 | CATCH_EINTR(waitpid(pid, NULL, __WALL)); |
100 | } | 100 | } |
101 | 101 | ||
102 | out_free2: | 102 | out_free2: |
@@ -129,7 +129,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
129 | return err; | 129 | return err; |
130 | } | 130 | } |
131 | if (stack_out == NULL) { | 131 | if (stack_out == NULL) { |
132 | CATCH_EINTR(pid = waitpid(pid, &status, __WCLONE)); | 132 | CATCH_EINTR(pid = waitpid(pid, &status, __WALL)); |
133 | if (pid < 0) { | 133 | if (pid < 0) { |
134 | err = -errno; | 134 | err = -errno; |
135 | printk(UM_KERN_ERR "run_helper_thread - wait failed, " | 135 | printk(UM_KERN_ERR "run_helper_thread - wait failed, " |
@@ -148,7 +148,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, | |||
148 | int helper_wait(int pid) | 148 | int helper_wait(int pid) |
149 | { | 149 | { |
150 | int ret, status; | 150 | int ret, status; |
151 | int wflags = __WCLONE; | 151 | int wflags = __WALL; |
152 | 152 | ||
153 | CATCH_EINTR(ret = waitpid(pid, &status, wflags)); | 153 | CATCH_EINTR(ret = waitpid(pid, &status, wflags)); |
154 | if (ret < 0) { | 154 | if (ret < 0) { |
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index ee1b6d346b98..db51c1f27446 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c | |||
@@ -667,6 +667,7 @@ setup_gop32(struct screen_info *si, efi_guid_t *proto, | |||
667 | bool conout_found = false; | 667 | bool conout_found = false; |
668 | void *dummy = NULL; | 668 | void *dummy = NULL; |
669 | u32 h = handles[i]; | 669 | u32 h = handles[i]; |
670 | u32 current_fb_base; | ||
670 | 671 | ||
671 | status = efi_call_early(handle_protocol, h, | 672 | status = efi_call_early(handle_protocol, h, |
672 | proto, (void **)&gop32); | 673 | proto, (void **)&gop32); |
@@ -678,7 +679,7 @@ setup_gop32(struct screen_info *si, efi_guid_t *proto, | |||
678 | if (status == EFI_SUCCESS) | 679 | if (status == EFI_SUCCESS) |
679 | conout_found = true; | 680 | conout_found = true; |
680 | 681 | ||
681 | status = __gop_query32(gop32, &info, &size, &fb_base); | 682 | status = __gop_query32(gop32, &info, &size, ¤t_fb_base); |
682 | if (status == EFI_SUCCESS && (!first_gop || conout_found)) { | 683 | if (status == EFI_SUCCESS && (!first_gop || conout_found)) { |
683 | /* | 684 | /* |
684 | * Systems that use the UEFI Console Splitter may | 685 | * Systems that use the UEFI Console Splitter may |
@@ -692,6 +693,7 @@ setup_gop32(struct screen_info *si, efi_guid_t *proto, | |||
692 | pixel_format = info->pixel_format; | 693 | pixel_format = info->pixel_format; |
693 | pixel_info = info->pixel_information; | 694 | pixel_info = info->pixel_information; |
694 | pixels_per_scan_line = info->pixels_per_scan_line; | 695 | pixels_per_scan_line = info->pixels_per_scan_line; |
696 | fb_base = current_fb_base; | ||
695 | 697 | ||
696 | /* | 698 | /* |
697 | * Once we've found a GOP supporting ConOut, | 699 | * Once we've found a GOP supporting ConOut, |
@@ -770,6 +772,7 @@ setup_gop64(struct screen_info *si, efi_guid_t *proto, | |||
770 | bool conout_found = false; | 772 | bool conout_found = false; |
771 | void *dummy = NULL; | 773 | void *dummy = NULL; |
772 | u64 h = handles[i]; | 774 | u64 h = handles[i]; |
775 | u32 current_fb_base; | ||
773 | 776 | ||
774 | status = efi_call_early(handle_protocol, h, | 777 | status = efi_call_early(handle_protocol, h, |
775 | proto, (void **)&gop64); | 778 | proto, (void **)&gop64); |
@@ -781,7 +784,7 @@ setup_gop64(struct screen_info *si, efi_guid_t *proto, | |||
781 | if (status == EFI_SUCCESS) | 784 | if (status == EFI_SUCCESS) |
782 | conout_found = true; | 785 | conout_found = true; |
783 | 786 | ||
784 | status = __gop_query64(gop64, &info, &size, &fb_base); | 787 | status = __gop_query64(gop64, &info, &size, ¤t_fb_base); |
785 | if (status == EFI_SUCCESS && (!first_gop || conout_found)) { | 788 | if (status == EFI_SUCCESS && (!first_gop || conout_found)) { |
786 | /* | 789 | /* |
787 | * Systems that use the UEFI Console Splitter may | 790 | * Systems that use the UEFI Console Splitter may |
@@ -795,6 +798,7 @@ setup_gop64(struct screen_info *si, efi_guid_t *proto, | |||
795 | pixel_format = info->pixel_format; | 798 | pixel_format = info->pixel_format; |
796 | pixel_info = info->pixel_information; | 799 | pixel_info = info->pixel_information; |
797 | pixels_per_scan_line = info->pixels_per_scan_line; | 800 | pixels_per_scan_line = info->pixels_per_scan_line; |
801 | fb_base = current_fb_base; | ||
798 | 802 | ||
799 | /* | 803 | /* |
800 | * Once we've found a GOP supporting ConOut, | 804 | * Once we've found a GOP supporting ConOut, |
diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h index e4661196994e..ff8b9a17dc4b 100644 --- a/arch/x86/include/asm/string_64.h +++ b/arch/x86/include/asm/string_64.h | |||
@@ -27,12 +27,11 @@ static __always_inline void *__inline_memcpy(void *to, const void *from, size_t | |||
27 | function. */ | 27 | function. */ |
28 | 28 | ||
29 | #define __HAVE_ARCH_MEMCPY 1 | 29 | #define __HAVE_ARCH_MEMCPY 1 |
30 | extern void *memcpy(void *to, const void *from, size_t len); | ||
30 | extern void *__memcpy(void *to, const void *from, size_t len); | 31 | extern void *__memcpy(void *to, const void *from, size_t len); |
31 | 32 | ||
32 | #ifndef CONFIG_KMEMCHECK | 33 | #ifndef CONFIG_KMEMCHECK |
33 | #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 | 34 | #if (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || __GNUC__ < 4 |
34 | extern void *memcpy(void *to, const void *from, size_t len); | ||
35 | #else | ||
36 | #define memcpy(dst, src, len) \ | 35 | #define memcpy(dst, src, len) \ |
37 | ({ \ | 36 | ({ \ |
38 | size_t __len = (len); \ | 37 | size_t __len = (len); \ |
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 5c60bb162622..bb6bfc01cb82 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -2907,6 +2907,7 @@ int mp_irqdomain_alloc(struct irq_domain *domain, unsigned int virq, | |||
2907 | struct irq_data *irq_data; | 2907 | struct irq_data *irq_data; |
2908 | struct mp_chip_data *data; | 2908 | struct mp_chip_data *data; |
2909 | struct irq_alloc_info *info = arg; | 2909 | struct irq_alloc_info *info = arg; |
2910 | unsigned long flags; | ||
2910 | 2911 | ||
2911 | if (!info || nr_irqs > 1) | 2912 | if (!info || nr_irqs > 1) |
2912 | return -EINVAL; | 2913 | return -EINVAL; |
@@ -2939,11 +2940,14 @@ int mp_irqdomain_alloc(struct irq_domain *domain, unsigned int virq, | |||
2939 | 2940 | ||
2940 | cfg = irqd_cfg(irq_data); | 2941 | cfg = irqd_cfg(irq_data); |
2941 | add_pin_to_irq_node(data, ioapic_alloc_attr_node(info), ioapic, pin); | 2942 | add_pin_to_irq_node(data, ioapic_alloc_attr_node(info), ioapic, pin); |
2943 | |||
2944 | local_irq_save(flags); | ||
2942 | if (info->ioapic_entry) | 2945 | if (info->ioapic_entry) |
2943 | mp_setup_entry(cfg, data, info->ioapic_entry); | 2946 | mp_setup_entry(cfg, data, info->ioapic_entry); |
2944 | mp_register_handler(virq, data->trigger); | 2947 | mp_register_handler(virq, data->trigger); |
2945 | if (virq < nr_legacy_irqs()) | 2948 | if (virq < nr_legacy_irqs()) |
2946 | legacy_pic->mask(virq); | 2949 | legacy_pic->mask(virq); |
2950 | local_irq_restore(flags); | ||
2947 | 2951 | ||
2948 | apic_printk(APIC_VERBOSE, KERN_DEBUG | 2952 | apic_printk(APIC_VERBOSE, KERN_DEBUG |
2949 | "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> IRQ %d Mode:%i Active:%i Dest:%d)\n", | 2953 | "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> IRQ %d Mode:%i Active:%i Dest:%d)\n", |
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 39e585a554b7..e28db181e4fc 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c | |||
@@ -550,14 +550,14 @@ unsigned long get_wchan(struct task_struct *p) | |||
550 | if (sp < bottom || sp > top) | 550 | if (sp < bottom || sp > top) |
551 | return 0; | 551 | return 0; |
552 | 552 | ||
553 | fp = READ_ONCE(*(unsigned long *)sp); | 553 | fp = READ_ONCE_NOCHECK(*(unsigned long *)sp); |
554 | do { | 554 | do { |
555 | if (fp < bottom || fp > top) | 555 | if (fp < bottom || fp > top) |
556 | return 0; | 556 | return 0; |
557 | ip = READ_ONCE(*(unsigned long *)(fp + sizeof(unsigned long))); | 557 | ip = READ_ONCE_NOCHECK(*(unsigned long *)(fp + sizeof(unsigned long))); |
558 | if (!in_sched_functions(ip)) | 558 | if (!in_sched_functions(ip)) |
559 | return ip; | 559 | return ip; |
560 | fp = READ_ONCE(*(unsigned long *)fp); | 560 | fp = READ_ONCE_NOCHECK(*(unsigned long *)fp); |
561 | } while (count++ < 16 && p->state != TASK_RUNNING); | 561 | } while (count++ < 16 && p->state != TASK_RUNNING); |
562 | return 0; | 562 | return 0; |
563 | } | 563 | } |
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index fdb7f2a2d328..a3cccbfc5f77 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -1173,6 +1173,14 @@ void __init setup_arch(char **cmdline_p) | |||
1173 | clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY, | 1173 | clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY, |
1174 | swapper_pg_dir + KERNEL_PGD_BOUNDARY, | 1174 | swapper_pg_dir + KERNEL_PGD_BOUNDARY, |
1175 | KERNEL_PGD_PTRS); | 1175 | KERNEL_PGD_PTRS); |
1176 | |||
1177 | /* | ||
1178 | * sync back low identity map too. It is used for example | ||
1179 | * in the 32-bit EFI stub. | ||
1180 | */ | ||
1181 | clone_pgd_range(initial_page_table, | ||
1182 | swapper_pg_dir + KERNEL_PGD_BOUNDARY, | ||
1183 | KERNEL_PGD_PTRS); | ||
1176 | #endif | 1184 | #endif |
1177 | 1185 | ||
1178 | tboot_probe(); | 1186 | tboot_probe(); |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index e0c198e5f920..892ee2e5ecbc 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -509,7 +509,7 @@ void __inquire_remote_apic(int apicid) | |||
509 | */ | 509 | */ |
510 | #define UDELAY_10MS_DEFAULT 10000 | 510 | #define UDELAY_10MS_DEFAULT 10000 |
511 | 511 | ||
512 | static unsigned int init_udelay = UDELAY_10MS_DEFAULT; | 512 | static unsigned int init_udelay = INT_MAX; |
513 | 513 | ||
514 | static int __init cpu_init_udelay(char *str) | 514 | static int __init cpu_init_udelay(char *str) |
515 | { | 515 | { |
@@ -522,13 +522,16 @@ early_param("cpu_init_udelay", cpu_init_udelay); | |||
522 | static void __init smp_quirk_init_udelay(void) | 522 | static void __init smp_quirk_init_udelay(void) |
523 | { | 523 | { |
524 | /* if cmdline changed it from default, leave it alone */ | 524 | /* if cmdline changed it from default, leave it alone */ |
525 | if (init_udelay != UDELAY_10MS_DEFAULT) | 525 | if (init_udelay != INT_MAX) |
526 | return; | 526 | return; |
527 | 527 | ||
528 | /* if modern processor, use no delay */ | 528 | /* if modern processor, use no delay */ |
529 | if (((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 == 6)) || | 529 | if (((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 == 6)) || |
530 | ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && (boot_cpu_data.x86 >= 0xF))) | 530 | ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && (boot_cpu_data.x86 >= 0xF))) |
531 | init_udelay = 0; | 531 | init_udelay = 0; |
532 | |||
533 | /* else, use legacy delay */ | ||
534 | init_udelay = UDELAY_10MS_DEFAULT; | ||
532 | } | 535 | } |
533 | 536 | ||
534 | /* | 537 | /* |
@@ -657,7 +660,9 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) | |||
657 | /* | 660 | /* |
658 | * Give the other CPU some time to accept the IPI. | 661 | * Give the other CPU some time to accept the IPI. |
659 | */ | 662 | */ |
660 | if (init_udelay) | 663 | if (init_udelay == 0) |
664 | udelay(10); | ||
665 | else | ||
661 | udelay(300); | 666 | udelay(300); |
662 | 667 | ||
663 | pr_debug("Startup point 1\n"); | 668 | pr_debug("Startup point 1\n"); |
@@ -668,7 +673,9 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) | |||
668 | /* | 673 | /* |
669 | * Give the other CPU some time to accept the IPI. | 674 | * Give the other CPU some time to accept the IPI. |
670 | */ | 675 | */ |
671 | if (init_udelay) | 676 | if (init_udelay == 0) |
677 | udelay(10); | ||
678 | else | ||
672 | udelay(200); | 679 | udelay(200); |
673 | 680 | ||
674 | if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ | 681 | if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ |
diff --git a/arch/x86/um/ldt.c b/arch/x86/um/ldt.c index 9701a4fd7bf2..836a1eb5df43 100644 --- a/arch/x86/um/ldt.c +++ b/arch/x86/um/ldt.c | |||
@@ -12,7 +12,10 @@ | |||
12 | #include <skas.h> | 12 | #include <skas.h> |
13 | #include <sysdep/tls.h> | 13 | #include <sysdep/tls.h> |
14 | 14 | ||
15 | extern int modify_ldt(int func, void *ptr, unsigned long bytecount); | 15 | static inline int modify_ldt (int func, void *ptr, unsigned long bytecount) |
16 | { | ||
17 | return syscall(__NR_modify_ldt, func, ptr, bytecount); | ||
18 | } | ||
16 | 19 | ||
17 | static long write_ldt_entry(struct mm_id *mm_idp, int func, | 20 | static long write_ldt_entry(struct mm_id *mm_idp, int func, |
18 | struct user_desc *desc, void **addr, int done) | 21 | struct user_desc *desc, void **addr, int done) |
diff --git a/block/blk-core.c b/block/blk-core.c index 2eb722d48773..18e92a6645e2 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -576,7 +576,7 @@ void blk_cleanup_queue(struct request_queue *q) | |||
576 | q->queue_lock = &q->__queue_lock; | 576 | q->queue_lock = &q->__queue_lock; |
577 | spin_unlock_irq(lock); | 577 | spin_unlock_irq(lock); |
578 | 578 | ||
579 | bdi_destroy(&q->backing_dev_info); | 579 | bdi_unregister(&q->backing_dev_info); |
580 | 580 | ||
581 | /* @q is and will stay empty, shutdown and put */ | 581 | /* @q is and will stay empty, shutdown and put */ |
582 | blk_put_queue(q); | 582 | blk_put_queue(q); |
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index ed96474d75cb..ec2d11915142 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c | |||
@@ -641,6 +641,7 @@ void blk_mq_free_tags(struct blk_mq_tags *tags) | |||
641 | { | 641 | { |
642 | bt_free(&tags->bitmap_tags); | 642 | bt_free(&tags->bitmap_tags); |
643 | bt_free(&tags->breserved_tags); | 643 | bt_free(&tags->breserved_tags); |
644 | free_cpumask_var(tags->cpumask); | ||
644 | kfree(tags); | 645 | kfree(tags); |
645 | } | 646 | } |
646 | 647 | ||
diff --git a/block/blk-mq.c b/block/blk-mq.c index 7785ae96267a..85f014327342 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -2296,10 +2296,8 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set) | |||
2296 | int i; | 2296 | int i; |
2297 | 2297 | ||
2298 | for (i = 0; i < set->nr_hw_queues; i++) { | 2298 | for (i = 0; i < set->nr_hw_queues; i++) { |
2299 | if (set->tags[i]) { | 2299 | if (set->tags[i]) |
2300 | blk_mq_free_rq_map(set, set->tags[i], i); | 2300 | blk_mq_free_rq_map(set, set->tags[i], i); |
2301 | free_cpumask_var(set->tags[i]->cpumask); | ||
2302 | } | ||
2303 | } | 2301 | } |
2304 | 2302 | ||
2305 | kfree(set->tags); | 2303 | kfree(set->tags); |
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 3e44a9da2a13..07b42f5ad797 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c | |||
@@ -540,6 +540,7 @@ static void blk_release_queue(struct kobject *kobj) | |||
540 | struct request_queue *q = | 540 | struct request_queue *q = |
541 | container_of(kobj, struct request_queue, kobj); | 541 | container_of(kobj, struct request_queue, kobj); |
542 | 542 | ||
543 | bdi_exit(&q->backing_dev_info); | ||
543 | blkcg_exit_queue(q); | 544 | blkcg_exit_queue(q); |
544 | 545 | ||
545 | if (q->elevator) { | 546 | if (q->elevator) { |
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c index 950fff9ce453..a12ff9863d7e 100644 --- a/drivers/base/dma-contiguous.c +++ b/drivers/base/dma-contiguous.c | |||
@@ -187,7 +187,7 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, | |||
187 | * global one. Requires architecture specific dev_get_cma_area() helper | 187 | * global one. Requires architecture specific dev_get_cma_area() helper |
188 | * function. | 188 | * function. |
189 | */ | 189 | */ |
190 | struct page *dma_alloc_from_contiguous(struct device *dev, int count, | 190 | struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, |
191 | unsigned int align) | 191 | unsigned int align) |
192 | { | 192 | { |
193 | if (align > CONFIG_CMA_ALIGNMENT) | 193 | if (align > CONFIG_CMA_ALIGNMENT) |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 293495a75d3d..1b87623381e2 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -60,6 +60,7 @@ struct nbd_device { | |||
60 | bool disconnect; /* a disconnect has been requested by user */ | 60 | bool disconnect; /* a disconnect has been requested by user */ |
61 | 61 | ||
62 | struct timer_list timeout_timer; | 62 | struct timer_list timeout_timer; |
63 | spinlock_t tasks_lock; | ||
63 | struct task_struct *task_recv; | 64 | struct task_struct *task_recv; |
64 | struct task_struct *task_send; | 65 | struct task_struct *task_send; |
65 | 66 | ||
@@ -140,21 +141,23 @@ static void sock_shutdown(struct nbd_device *nbd) | |||
140 | static void nbd_xmit_timeout(unsigned long arg) | 141 | static void nbd_xmit_timeout(unsigned long arg) |
141 | { | 142 | { |
142 | struct nbd_device *nbd = (struct nbd_device *)arg; | 143 | struct nbd_device *nbd = (struct nbd_device *)arg; |
143 | struct task_struct *task; | 144 | unsigned long flags; |
144 | 145 | ||
145 | if (list_empty(&nbd->queue_head)) | 146 | if (list_empty(&nbd->queue_head)) |
146 | return; | 147 | return; |
147 | 148 | ||
148 | nbd->disconnect = true; | 149 | nbd->disconnect = true; |
149 | 150 | ||
150 | task = READ_ONCE(nbd->task_recv); | 151 | spin_lock_irqsave(&nbd->tasks_lock, flags); |
151 | if (task) | 152 | |
152 | force_sig(SIGKILL, task); | 153 | if (nbd->task_recv) |
154 | force_sig(SIGKILL, nbd->task_recv); | ||
153 | 155 | ||
154 | task = READ_ONCE(nbd->task_send); | 156 | if (nbd->task_send) |
155 | if (task) | ||
156 | force_sig(SIGKILL, nbd->task_send); | 157 | force_sig(SIGKILL, nbd->task_send); |
157 | 158 | ||
159 | spin_unlock_irqrestore(&nbd->tasks_lock, flags); | ||
160 | |||
158 | dev_err(nbd_to_dev(nbd), "Connection timed out, killed receiver and sender, shutting down connection\n"); | 161 | dev_err(nbd_to_dev(nbd), "Connection timed out, killed receiver and sender, shutting down connection\n"); |
159 | } | 162 | } |
160 | 163 | ||
@@ -403,17 +406,24 @@ static int nbd_thread_recv(struct nbd_device *nbd) | |||
403 | { | 406 | { |
404 | struct request *req; | 407 | struct request *req; |
405 | int ret; | 408 | int ret; |
409 | unsigned long flags; | ||
406 | 410 | ||
407 | BUG_ON(nbd->magic != NBD_MAGIC); | 411 | BUG_ON(nbd->magic != NBD_MAGIC); |
408 | 412 | ||
409 | sk_set_memalloc(nbd->sock->sk); | 413 | sk_set_memalloc(nbd->sock->sk); |
410 | 414 | ||
415 | spin_lock_irqsave(&nbd->tasks_lock, flags); | ||
411 | nbd->task_recv = current; | 416 | nbd->task_recv = current; |
417 | spin_unlock_irqrestore(&nbd->tasks_lock, flags); | ||
412 | 418 | ||
413 | ret = device_create_file(disk_to_dev(nbd->disk), &pid_attr); | 419 | ret = device_create_file(disk_to_dev(nbd->disk), &pid_attr); |
414 | if (ret) { | 420 | if (ret) { |
415 | dev_err(disk_to_dev(nbd->disk), "device_create_file failed!\n"); | 421 | dev_err(disk_to_dev(nbd->disk), "device_create_file failed!\n"); |
422 | |||
423 | spin_lock_irqsave(&nbd->tasks_lock, flags); | ||
416 | nbd->task_recv = NULL; | 424 | nbd->task_recv = NULL; |
425 | spin_unlock_irqrestore(&nbd->tasks_lock, flags); | ||
426 | |||
417 | return ret; | 427 | return ret; |
418 | } | 428 | } |
419 | 429 | ||
@@ -429,7 +439,9 @@ static int nbd_thread_recv(struct nbd_device *nbd) | |||
429 | 439 | ||
430 | device_remove_file(disk_to_dev(nbd->disk), &pid_attr); | 440 | device_remove_file(disk_to_dev(nbd->disk), &pid_attr); |
431 | 441 | ||
442 | spin_lock_irqsave(&nbd->tasks_lock, flags); | ||
432 | nbd->task_recv = NULL; | 443 | nbd->task_recv = NULL; |
444 | spin_unlock_irqrestore(&nbd->tasks_lock, flags); | ||
433 | 445 | ||
434 | if (signal_pending(current)) { | 446 | if (signal_pending(current)) { |
435 | siginfo_t info; | 447 | siginfo_t info; |
@@ -534,8 +546,11 @@ static int nbd_thread_send(void *data) | |||
534 | { | 546 | { |
535 | struct nbd_device *nbd = data; | 547 | struct nbd_device *nbd = data; |
536 | struct request *req; | 548 | struct request *req; |
549 | unsigned long flags; | ||
537 | 550 | ||
551 | spin_lock_irqsave(&nbd->tasks_lock, flags); | ||
538 | nbd->task_send = current; | 552 | nbd->task_send = current; |
553 | spin_unlock_irqrestore(&nbd->tasks_lock, flags); | ||
539 | 554 | ||
540 | set_user_nice(current, MIN_NICE); | 555 | set_user_nice(current, MIN_NICE); |
541 | while (!kthread_should_stop() || !list_empty(&nbd->waiting_queue)) { | 556 | while (!kthread_should_stop() || !list_empty(&nbd->waiting_queue)) { |
@@ -572,7 +587,15 @@ static int nbd_thread_send(void *data) | |||
572 | nbd_handle_req(nbd, req); | 587 | nbd_handle_req(nbd, req); |
573 | } | 588 | } |
574 | 589 | ||
590 | spin_lock_irqsave(&nbd->tasks_lock, flags); | ||
575 | nbd->task_send = NULL; | 591 | nbd->task_send = NULL; |
592 | spin_unlock_irqrestore(&nbd->tasks_lock, flags); | ||
593 | |||
594 | /* Clear maybe pending signals */ | ||
595 | if (signal_pending(current)) { | ||
596 | siginfo_t info; | ||
597 | dequeue_signal_lock(current, ¤t->blocked, &info); | ||
598 | } | ||
576 | 599 | ||
577 | return 0; | 600 | return 0; |
578 | } | 601 | } |
@@ -1052,6 +1075,7 @@ static int __init nbd_init(void) | |||
1052 | nbd_dev[i].magic = NBD_MAGIC; | 1075 | nbd_dev[i].magic = NBD_MAGIC; |
1053 | INIT_LIST_HEAD(&nbd_dev[i].waiting_queue); | 1076 | INIT_LIST_HEAD(&nbd_dev[i].waiting_queue); |
1054 | spin_lock_init(&nbd_dev[i].queue_lock); | 1077 | spin_lock_init(&nbd_dev[i].queue_lock); |
1078 | spin_lock_init(&nbd_dev[i].tasks_lock); | ||
1055 | INIT_LIST_HEAD(&nbd_dev[i].queue_head); | 1079 | INIT_LIST_HEAD(&nbd_dev[i].queue_head); |
1056 | mutex_init(&nbd_dev[i].tx_lock); | 1080 | mutex_init(&nbd_dev[i].tx_lock); |
1057 | init_timer(&nbd_dev[i].timeout_timer); | 1081 | init_timer(&nbd_dev[i].timeout_timer); |
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 6f04771f1019..ccc0c1f93daa 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c | |||
@@ -603,27 +603,31 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx, | |||
603 | struct nvme_iod *iod = ctx; | 603 | struct nvme_iod *iod = ctx; |
604 | struct request *req = iod_get_private(iod); | 604 | struct request *req = iod_get_private(iod); |
605 | struct nvme_cmd_info *cmd_rq = blk_mq_rq_to_pdu(req); | 605 | struct nvme_cmd_info *cmd_rq = blk_mq_rq_to_pdu(req); |
606 | |||
607 | u16 status = le16_to_cpup(&cqe->status) >> 1; | 606 | u16 status = le16_to_cpup(&cqe->status) >> 1; |
607 | bool requeue = false; | ||
608 | int error = 0; | ||
608 | 609 | ||
609 | if (unlikely(status)) { | 610 | if (unlikely(status)) { |
610 | if (!(status & NVME_SC_DNR || blk_noretry_request(req)) | 611 | if (!(status & NVME_SC_DNR || blk_noretry_request(req)) |
611 | && (jiffies - req->start_time) < req->timeout) { | 612 | && (jiffies - req->start_time) < req->timeout) { |
612 | unsigned long flags; | 613 | unsigned long flags; |
613 | 614 | ||
615 | requeue = true; | ||
614 | blk_mq_requeue_request(req); | 616 | blk_mq_requeue_request(req); |
615 | spin_lock_irqsave(req->q->queue_lock, flags); | 617 | spin_lock_irqsave(req->q->queue_lock, flags); |
616 | if (!blk_queue_stopped(req->q)) | 618 | if (!blk_queue_stopped(req->q)) |
617 | blk_mq_kick_requeue_list(req->q); | 619 | blk_mq_kick_requeue_list(req->q); |
618 | spin_unlock_irqrestore(req->q->queue_lock, flags); | 620 | spin_unlock_irqrestore(req->q->queue_lock, flags); |
619 | return; | 621 | goto release_iod; |
620 | } | 622 | } |
621 | 623 | ||
622 | if (req->cmd_type == REQ_TYPE_DRV_PRIV) { | 624 | if (req->cmd_type == REQ_TYPE_DRV_PRIV) { |
623 | if (cmd_rq->ctx == CMD_CTX_CANCELLED) | 625 | if (cmd_rq->ctx == CMD_CTX_CANCELLED) |
624 | status = -EINTR; | 626 | error = -EINTR; |
627 | else | ||
628 | error = status; | ||
625 | } else { | 629 | } else { |
626 | status = nvme_error_status(status); | 630 | error = nvme_error_status(status); |
627 | } | 631 | } |
628 | } | 632 | } |
629 | 633 | ||
@@ -635,8 +639,9 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx, | |||
635 | if (cmd_rq->aborted) | 639 | if (cmd_rq->aborted) |
636 | dev_warn(nvmeq->dev->dev, | 640 | dev_warn(nvmeq->dev->dev, |
637 | "completing aborted command with status:%04x\n", | 641 | "completing aborted command with status:%04x\n", |
638 | status); | 642 | error); |
639 | 643 | ||
644 | release_iod: | ||
640 | if (iod->nents) { | 645 | if (iod->nents) { |
641 | dma_unmap_sg(nvmeq->dev->dev, iod->sg, iod->nents, | 646 | dma_unmap_sg(nvmeq->dev->dev, iod->sg, iod->nents, |
642 | rq_data_dir(req) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 647 | rq_data_dir(req) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
@@ -649,7 +654,8 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx, | |||
649 | } | 654 | } |
650 | nvme_free_iod(nvmeq->dev, iod); | 655 | nvme_free_iod(nvmeq->dev, iod); |
651 | 656 | ||
652 | blk_mq_complete_request(req, status); | 657 | if (likely(!requeue)) |
658 | blk_mq_complete_request(req, error); | ||
653 | } | 659 | } |
654 | 660 | ||
655 | /* length is in bytes. gfp flags indicates whether we may sleep. */ | 661 | /* length is in bytes. gfp flags indicates whether we may sleep. */ |
@@ -1804,7 +1810,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) | |||
1804 | 1810 | ||
1805 | length = (io.nblocks + 1) << ns->lba_shift; | 1811 | length = (io.nblocks + 1) << ns->lba_shift; |
1806 | meta_len = (io.nblocks + 1) * ns->ms; | 1812 | meta_len = (io.nblocks + 1) * ns->ms; |
1807 | metadata = (void __user *)(unsigned long)io.metadata; | 1813 | metadata = (void __user *)(uintptr_t)io.metadata; |
1808 | write = io.opcode & 1; | 1814 | write = io.opcode & 1; |
1809 | 1815 | ||
1810 | if (ns->ext) { | 1816 | if (ns->ext) { |
@@ -1844,7 +1850,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) | |||
1844 | c.rw.metadata = cpu_to_le64(meta_dma); | 1850 | c.rw.metadata = cpu_to_le64(meta_dma); |
1845 | 1851 | ||
1846 | status = __nvme_submit_sync_cmd(ns->queue, &c, NULL, | 1852 | status = __nvme_submit_sync_cmd(ns->queue, &c, NULL, |
1847 | (void __user *)io.addr, length, NULL, 0); | 1853 | (void __user *)(uintptr_t)io.addr, length, NULL, 0); |
1848 | unmap: | 1854 | unmap: |
1849 | if (meta) { | 1855 | if (meta) { |
1850 | if (status == NVME_SC_SUCCESS && !write) { | 1856 | if (status == NVME_SC_SUCCESS && !write) { |
@@ -1886,7 +1892,7 @@ static int nvme_user_cmd(struct nvme_dev *dev, struct nvme_ns *ns, | |||
1886 | timeout = msecs_to_jiffies(cmd.timeout_ms); | 1892 | timeout = msecs_to_jiffies(cmd.timeout_ms); |
1887 | 1893 | ||
1888 | status = __nvme_submit_sync_cmd(ns ? ns->queue : dev->admin_q, &c, | 1894 | status = __nvme_submit_sync_cmd(ns ? ns->queue : dev->admin_q, &c, |
1889 | NULL, (void __user *)cmd.addr, cmd.data_len, | 1895 | NULL, (void __user *)(uintptr_t)cmd.addr, cmd.data_len, |
1890 | &cmd.result, timeout); | 1896 | &cmd.result, timeout); |
1891 | if (status >= 0) { | 1897 | if (status >= 0) { |
1892 | if (put_user(cmd.result, &ucmd->result)) | 1898 | if (put_user(cmd.result, &ucmd->result)) |
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index f5e49b639818..6f26cf38c6f9 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -96,6 +96,8 @@ static int atomic_dec_return_safe(atomic_t *v) | |||
96 | #define RBD_MINORS_PER_MAJOR 256 | 96 | #define RBD_MINORS_PER_MAJOR 256 |
97 | #define RBD_SINGLE_MAJOR_PART_SHIFT 4 | 97 | #define RBD_SINGLE_MAJOR_PART_SHIFT 4 |
98 | 98 | ||
99 | #define RBD_MAX_PARENT_CHAIN_LEN 16 | ||
100 | |||
99 | #define RBD_SNAP_DEV_NAME_PREFIX "snap_" | 101 | #define RBD_SNAP_DEV_NAME_PREFIX "snap_" |
100 | #define RBD_MAX_SNAP_NAME_LEN \ | 102 | #define RBD_MAX_SNAP_NAME_LEN \ |
101 | (NAME_MAX - (sizeof (RBD_SNAP_DEV_NAME_PREFIX) - 1)) | 103 | (NAME_MAX - (sizeof (RBD_SNAP_DEV_NAME_PREFIX) - 1)) |
@@ -426,7 +428,7 @@ static ssize_t rbd_add_single_major(struct bus_type *bus, const char *buf, | |||
426 | size_t count); | 428 | size_t count); |
427 | static ssize_t rbd_remove_single_major(struct bus_type *bus, const char *buf, | 429 | static ssize_t rbd_remove_single_major(struct bus_type *bus, const char *buf, |
428 | size_t count); | 430 | size_t count); |
429 | static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping); | 431 | static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth); |
430 | static void rbd_spec_put(struct rbd_spec *spec); | 432 | static void rbd_spec_put(struct rbd_spec *spec); |
431 | 433 | ||
432 | static int rbd_dev_id_to_minor(int dev_id) | 434 | static int rbd_dev_id_to_minor(int dev_id) |
@@ -5131,44 +5133,51 @@ out_err: | |||
5131 | return ret; | 5133 | return ret; |
5132 | } | 5134 | } |
5133 | 5135 | ||
5134 | static int rbd_dev_probe_parent(struct rbd_device *rbd_dev) | 5136 | /* |
5137 | * @depth is rbd_dev_image_probe() -> rbd_dev_probe_parent() -> | ||
5138 | * rbd_dev_image_probe() recursion depth, which means it's also the | ||
5139 | * length of the already discovered part of the parent chain. | ||
5140 | */ | ||
5141 | static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) | ||
5135 | { | 5142 | { |
5136 | struct rbd_device *parent = NULL; | 5143 | struct rbd_device *parent = NULL; |
5137 | struct rbd_spec *parent_spec; | ||
5138 | struct rbd_client *rbdc; | ||
5139 | int ret; | 5144 | int ret; |
5140 | 5145 | ||
5141 | if (!rbd_dev->parent_spec) | 5146 | if (!rbd_dev->parent_spec) |
5142 | return 0; | 5147 | return 0; |
5143 | /* | ||
5144 | * We need to pass a reference to the client and the parent | ||
5145 | * spec when creating the parent rbd_dev. Images related by | ||
5146 | * parent/child relationships always share both. | ||
5147 | */ | ||
5148 | parent_spec = rbd_spec_get(rbd_dev->parent_spec); | ||
5149 | rbdc = __rbd_get_client(rbd_dev->rbd_client); | ||
5150 | 5148 | ||
5151 | ret = -ENOMEM; | 5149 | if (++depth > RBD_MAX_PARENT_CHAIN_LEN) { |
5152 | parent = rbd_dev_create(rbdc, parent_spec, NULL); | 5150 | pr_info("parent chain is too long (%d)\n", depth); |
5153 | if (!parent) | 5151 | ret = -EINVAL; |
5152 | goto out_err; | ||
5153 | } | ||
5154 | |||
5155 | parent = rbd_dev_create(rbd_dev->rbd_client, rbd_dev->parent_spec, | ||
5156 | NULL); | ||
5157 | if (!parent) { | ||
5158 | ret = -ENOMEM; | ||
5154 | goto out_err; | 5159 | goto out_err; |
5160 | } | ||
5161 | |||
5162 | /* | ||
5163 | * Images related by parent/child relationships always share | ||
5164 | * rbd_client and spec/parent_spec, so bump their refcounts. | ||
5165 | */ | ||
5166 | __rbd_get_client(rbd_dev->rbd_client); | ||
5167 | rbd_spec_get(rbd_dev->parent_spec); | ||
5155 | 5168 | ||
5156 | ret = rbd_dev_image_probe(parent, false); | 5169 | ret = rbd_dev_image_probe(parent, depth); |
5157 | if (ret < 0) | 5170 | if (ret < 0) |
5158 | goto out_err; | 5171 | goto out_err; |
5172 | |||
5159 | rbd_dev->parent = parent; | 5173 | rbd_dev->parent = parent; |
5160 | atomic_set(&rbd_dev->parent_ref, 1); | 5174 | atomic_set(&rbd_dev->parent_ref, 1); |
5161 | |||
5162 | return 0; | 5175 | return 0; |
5176 | |||
5163 | out_err: | 5177 | out_err: |
5164 | if (parent) { | 5178 | rbd_dev_unparent(rbd_dev); |
5165 | rbd_dev_unparent(rbd_dev); | 5179 | if (parent) |
5166 | rbd_dev_destroy(parent); | 5180 | rbd_dev_destroy(parent); |
5167 | } else { | ||
5168 | rbd_put_client(rbdc); | ||
5169 | rbd_spec_put(parent_spec); | ||
5170 | } | ||
5171 | |||
5172 | return ret; | 5181 | return ret; |
5173 | } | 5182 | } |
5174 | 5183 | ||
@@ -5286,7 +5295,7 @@ static void rbd_dev_image_release(struct rbd_device *rbd_dev) | |||
5286 | * parent), initiate a watch on its header object before using that | 5295 | * parent), initiate a watch on its header object before using that |
5287 | * object to get detailed information about the rbd image. | 5296 | * object to get detailed information about the rbd image. |
5288 | */ | 5297 | */ |
5289 | static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping) | 5298 | static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth) |
5290 | { | 5299 | { |
5291 | int ret; | 5300 | int ret; |
5292 | 5301 | ||
@@ -5304,7 +5313,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping) | |||
5304 | if (ret) | 5313 | if (ret) |
5305 | goto err_out_format; | 5314 | goto err_out_format; |
5306 | 5315 | ||
5307 | if (mapping) { | 5316 | if (!depth) { |
5308 | ret = rbd_dev_header_watch_sync(rbd_dev); | 5317 | ret = rbd_dev_header_watch_sync(rbd_dev); |
5309 | if (ret) { | 5318 | if (ret) { |
5310 | if (ret == -ENOENT) | 5319 | if (ret == -ENOENT) |
@@ -5325,7 +5334,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping) | |||
5325 | * Otherwise this is a parent image, identified by pool, image | 5334 | * Otherwise this is a parent image, identified by pool, image |
5326 | * and snap ids - need to fill in names for those ids. | 5335 | * and snap ids - need to fill in names for those ids. |
5327 | */ | 5336 | */ |
5328 | if (mapping) | 5337 | if (!depth) |
5329 | ret = rbd_spec_fill_snap_id(rbd_dev); | 5338 | ret = rbd_spec_fill_snap_id(rbd_dev); |
5330 | else | 5339 | else |
5331 | ret = rbd_spec_fill_names(rbd_dev); | 5340 | ret = rbd_spec_fill_names(rbd_dev); |
@@ -5347,12 +5356,12 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping) | |||
5347 | * Need to warn users if this image is the one being | 5356 | * Need to warn users if this image is the one being |
5348 | * mapped and has a parent. | 5357 | * mapped and has a parent. |
5349 | */ | 5358 | */ |
5350 | if (mapping && rbd_dev->parent_spec) | 5359 | if (!depth && rbd_dev->parent_spec) |
5351 | rbd_warn(rbd_dev, | 5360 | rbd_warn(rbd_dev, |
5352 | "WARNING: kernel layering is EXPERIMENTAL!"); | 5361 | "WARNING: kernel layering is EXPERIMENTAL!"); |
5353 | } | 5362 | } |
5354 | 5363 | ||
5355 | ret = rbd_dev_probe_parent(rbd_dev); | 5364 | ret = rbd_dev_probe_parent(rbd_dev, depth); |
5356 | if (ret) | 5365 | if (ret) |
5357 | goto err_out_probe; | 5366 | goto err_out_probe; |
5358 | 5367 | ||
@@ -5363,7 +5372,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping) | |||
5363 | err_out_probe: | 5372 | err_out_probe: |
5364 | rbd_dev_unprobe(rbd_dev); | 5373 | rbd_dev_unprobe(rbd_dev); |
5365 | err_out_watch: | 5374 | err_out_watch: |
5366 | if (mapping) | 5375 | if (!depth) |
5367 | rbd_dev_header_unwatch_sync(rbd_dev); | 5376 | rbd_dev_header_unwatch_sync(rbd_dev); |
5368 | out_header_name: | 5377 | out_header_name: |
5369 | kfree(rbd_dev->header_name); | 5378 | kfree(rbd_dev->header_name); |
@@ -5426,7 +5435,7 @@ static ssize_t do_rbd_add(struct bus_type *bus, | |||
5426 | spec = NULL; /* rbd_dev now owns this */ | 5435 | spec = NULL; /* rbd_dev now owns this */ |
5427 | rbd_opts = NULL; /* rbd_dev now owns this */ | 5436 | rbd_opts = NULL; /* rbd_dev now owns this */ |
5428 | 5437 | ||
5429 | rc = rbd_dev_image_probe(rbd_dev, true); | 5438 | rc = rbd_dev_image_probe(rbd_dev, 0); |
5430 | if (rc < 0) | 5439 | if (rc < 0) |
5431 | goto err_out_rbd_dev; | 5440 | goto err_out_rbd_dev; |
5432 | 5441 | ||
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 611170896b8c..a69c02dadec0 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -1956,7 +1956,8 @@ static void blkback_changed(struct xenbus_device *dev, | |||
1956 | break; | 1956 | break; |
1957 | /* Missed the backend's Closing state -- fallthrough */ | 1957 | /* Missed the backend's Closing state -- fallthrough */ |
1958 | case XenbusStateClosing: | 1958 | case XenbusStateClosing: |
1959 | blkfront_closing(info); | 1959 | if (info) |
1960 | blkfront_closing(info); | ||
1960 | break; | 1961 | break; |
1961 | } | 1962 | } |
1962 | } | 1963 | } |
diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c index 7d9879e166cf..7082c7268845 100644 --- a/drivers/bus/arm-ccn.c +++ b/drivers/bus/arm-ccn.c | |||
@@ -1184,11 +1184,12 @@ static int arm_ccn_pmu_cpu_notifier(struct notifier_block *nb, | |||
1184 | if (!cpumask_test_and_clear_cpu(cpu, &dt->cpu)) | 1184 | if (!cpumask_test_and_clear_cpu(cpu, &dt->cpu)) |
1185 | break; | 1185 | break; |
1186 | target = cpumask_any_but(cpu_online_mask, cpu); | 1186 | target = cpumask_any_but(cpu_online_mask, cpu); |
1187 | if (target < 0) | 1187 | if (target >= nr_cpu_ids) |
1188 | break; | 1188 | break; |
1189 | perf_pmu_migrate_context(&dt->pmu, cpu, target); | 1189 | perf_pmu_migrate_context(&dt->pmu, cpu, target); |
1190 | cpumask_set_cpu(target, &dt->cpu); | 1190 | cpumask_set_cpu(target, &dt->cpu); |
1191 | WARN_ON(irq_set_affinity(ccn->irq, &dt->cpu) != 0); | 1191 | if (ccn->irq) |
1192 | WARN_ON(irq_set_affinity(ccn->irq, &dt->cpu) != 0); | ||
1192 | default: | 1193 | default: |
1193 | break; | 1194 | break; |
1194 | } | 1195 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index efed11509f4a..ed2bbe5b10af 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |||
@@ -294,10 +294,14 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, | |||
294 | struct amdgpu_device *adev = dev_get_drvdata(dev); | 294 | struct amdgpu_device *adev = dev_get_drvdata(dev); |
295 | umode_t effective_mode = attr->mode; | 295 | umode_t effective_mode = attr->mode; |
296 | 296 | ||
297 | /* Skip limit attributes if DPM is not enabled */ | 297 | /* Skip attributes if DPM is not enabled */ |
298 | if (!adev->pm.dpm_enabled && | 298 | if (!adev->pm.dpm_enabled && |
299 | (attr == &sensor_dev_attr_temp1_crit.dev_attr.attr || | 299 | (attr == &sensor_dev_attr_temp1_crit.dev_attr.attr || |
300 | attr == &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr)) | 300 | attr == &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr || |
301 | attr == &sensor_dev_attr_pwm1.dev_attr.attr || | ||
302 | attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || | ||
303 | attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || | ||
304 | attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) | ||
301 | return 0; | 305 | return 0; |
302 | 306 | ||
303 | /* Skip fan attributes if fan is not present */ | 307 | /* Skip fan attributes if fan is not present */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c index 9745ed3a9aef..7e9154c7f1db 100644 --- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c | |||
@@ -2997,6 +2997,9 @@ static int kv_dpm_late_init(void *handle) | |||
2997 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2997 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
2998 | int ret; | 2998 | int ret; |
2999 | 2999 | ||
3000 | if (!amdgpu_dpm) | ||
3001 | return 0; | ||
3002 | |||
3000 | /* init the sysfs and debugfs files late */ | 3003 | /* init the sysfs and debugfs files late */ |
3001 | ret = amdgpu_pm_sysfs_init(adev); | 3004 | ret = amdgpu_pm_sysfs_init(adev); |
3002 | if (ret) | 3005 | if (ret) |
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 5bca390d9ae2..809959d56d78 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c | |||
@@ -1194,17 +1194,18 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_ | |||
1194 | 1194 | ||
1195 | list_for_each_entry(port, &mstb->ports, next) { | 1195 | list_for_each_entry(port, &mstb->ports, next) { |
1196 | if (port->port_num == port_num) { | 1196 | if (port->port_num == port_num) { |
1197 | if (!port->mstb) { | 1197 | mstb = port->mstb; |
1198 | if (!mstb) { | ||
1198 | DRM_ERROR("failed to lookup MSTB with lct %d, rad %02x\n", lct, rad[0]); | 1199 | DRM_ERROR("failed to lookup MSTB with lct %d, rad %02x\n", lct, rad[0]); |
1199 | return NULL; | 1200 | goto out; |
1200 | } | 1201 | } |
1201 | 1202 | ||
1202 | mstb = port->mstb; | ||
1203 | break; | 1203 | break; |
1204 | } | 1204 | } |
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | kref_get(&mstb->kref); | 1207 | kref_get(&mstb->kref); |
1208 | out: | ||
1208 | mutex_unlock(&mgr->lock); | 1209 | mutex_unlock(&mgr->lock); |
1209 | return mstb; | 1210 | return mstb; |
1210 | } | 1211 | } |
diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c index f6ecbda2c604..674341708033 100644 --- a/drivers/gpu/drm/i915/i915_gem_shrinker.c +++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c | |||
@@ -143,7 +143,7 @@ i915_gem_shrink(struct drm_i915_private *dev_priv, | |||
143 | } | 143 | } |
144 | 144 | ||
145 | /** | 145 | /** |
146 | * i915_gem_shrink - Shrink buffer object caches completely | 146 | * i915_gem_shrink_all - Shrink buffer object caches completely |
147 | * @dev_priv: i915 device | 147 | * @dev_priv: i915 device |
148 | * | 148 | * |
149 | * This is a simple wraper around i915_gem_shrink() to aggressively shrink all | 149 | * This is a simple wraper around i915_gem_shrink() to aggressively shrink all |
diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c index 8fd431bcdfd3..a96b9006a51e 100644 --- a/drivers/gpu/drm/i915/i915_gem_userptr.c +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c | |||
@@ -804,7 +804,10 @@ static const struct drm_i915_gem_object_ops i915_gem_userptr_ops = { | |||
804 | * Also note, that the object created here is not currently a "first class" | 804 | * Also note, that the object created here is not currently a "first class" |
805 | * object, in that several ioctls are banned. These are the CPU access | 805 | * object, in that several ioctls are banned. These are the CPU access |
806 | * ioctls: mmap(), pwrite and pread. In practice, you are expected to use | 806 | * ioctls: mmap(), pwrite and pread. In practice, you are expected to use |
807 | * direct access via your pointer rather than use those ioctls. | 807 | * direct access via your pointer rather than use those ioctls. Another |
808 | * restriction is that we do not allow userptr surfaces to be pinned to the | ||
809 | * hardware and so we reject any attempt to create a framebuffer out of a | ||
810 | * userptr. | ||
808 | * | 811 | * |
809 | * If you think this is a good interface to use to pass GPU memory between | 812 | * If you think this is a good interface to use to pass GPU memory between |
810 | * drivers, please use dma-buf instead. In fact, wherever possible use | 813 | * drivers, please use dma-buf instead. In fact, wherever possible use |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index cf418be7d30a..b2270d576979 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -1724,6 +1724,15 @@ static void i9xx_enable_pll(struct intel_crtc *crtc) | |||
1724 | I915_READ(DPLL(!crtc->pipe)) | DPLL_DVO_2X_MODE); | 1724 | I915_READ(DPLL(!crtc->pipe)) | DPLL_DVO_2X_MODE); |
1725 | } | 1725 | } |
1726 | 1726 | ||
1727 | /* | ||
1728 | * Apparently we need to have VGA mode enabled prior to changing | ||
1729 | * the P1/P2 dividers. Otherwise the DPLL will keep using the old | ||
1730 | * dividers, even though the register value does change. | ||
1731 | */ | ||
1732 | I915_WRITE(reg, 0); | ||
1733 | |||
1734 | I915_WRITE(reg, dpll); | ||
1735 | |||
1727 | /* Wait for the clocks to stabilize. */ | 1736 | /* Wait for the clocks to stabilize. */ |
1728 | POSTING_READ(reg); | 1737 | POSTING_READ(reg); |
1729 | udelay(150); | 1738 | udelay(150); |
@@ -14107,6 +14116,11 @@ static int intel_user_framebuffer_create_handle(struct drm_framebuffer *fb, | |||
14107 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); | 14116 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); |
14108 | struct drm_i915_gem_object *obj = intel_fb->obj; | 14117 | struct drm_i915_gem_object *obj = intel_fb->obj; |
14109 | 14118 | ||
14119 | if (obj->userptr.mm) { | ||
14120 | DRM_DEBUG("attempting to use a userptr for a framebuffer, denied\n"); | ||
14121 | return -EINVAL; | ||
14122 | } | ||
14123 | |||
14110 | return drm_gem_handle_create(file, &obj->base, handle); | 14124 | return drm_gem_handle_create(file, &obj->base, handle); |
14111 | } | 14125 | } |
14112 | 14126 | ||
@@ -14897,9 +14911,19 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc) | |||
14897 | /* restore vblank interrupts to correct state */ | 14911 | /* restore vblank interrupts to correct state */ |
14898 | drm_crtc_vblank_reset(&crtc->base); | 14912 | drm_crtc_vblank_reset(&crtc->base); |
14899 | if (crtc->active) { | 14913 | if (crtc->active) { |
14914 | struct intel_plane *plane; | ||
14915 | |||
14900 | drm_calc_timestamping_constants(&crtc->base, &crtc->base.hwmode); | 14916 | drm_calc_timestamping_constants(&crtc->base, &crtc->base.hwmode); |
14901 | update_scanline_offset(crtc); | 14917 | update_scanline_offset(crtc); |
14902 | drm_crtc_vblank_on(&crtc->base); | 14918 | drm_crtc_vblank_on(&crtc->base); |
14919 | |||
14920 | /* Disable everything but the primary plane */ | ||
14921 | for_each_intel_plane_on_crtc(dev, crtc, plane) { | ||
14922 | if (plane->base.type == DRM_PLANE_TYPE_PRIMARY) | ||
14923 | continue; | ||
14924 | |||
14925 | plane->disable_plane(&plane->base, &crtc->base); | ||
14926 | } | ||
14903 | } | 14927 | } |
14904 | 14928 | ||
14905 | /* We need to sanitize the plane -> pipe mapping first because this will | 14929 | /* We need to sanitize the plane -> pipe mapping first because this will |
@@ -15067,38 +15091,25 @@ void i915_redisable_vga(struct drm_device *dev) | |||
15067 | i915_redisable_vga_power_on(dev); | 15091 | i915_redisable_vga_power_on(dev); |
15068 | } | 15092 | } |
15069 | 15093 | ||
15070 | static bool primary_get_hw_state(struct intel_crtc *crtc) | 15094 | static bool primary_get_hw_state(struct intel_plane *plane) |
15071 | { | 15095 | { |
15072 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; | 15096 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
15073 | 15097 | ||
15074 | return !!(I915_READ(DSPCNTR(crtc->plane)) & DISPLAY_PLANE_ENABLE); | 15098 | return I915_READ(DSPCNTR(plane->plane)) & DISPLAY_PLANE_ENABLE; |
15075 | } | 15099 | } |
15076 | 15100 | ||
15077 | static void readout_plane_state(struct intel_crtc *crtc, | 15101 | /* FIXME read out full plane state for all planes */ |
15078 | struct intel_crtc_state *crtc_state) | 15102 | static void readout_plane_state(struct intel_crtc *crtc) |
15079 | { | 15103 | { |
15080 | struct intel_plane *p; | 15104 | struct drm_plane *primary = crtc->base.primary; |
15081 | struct intel_plane_state *plane_state; | 15105 | struct intel_plane_state *plane_state = |
15082 | bool active = crtc_state->base.active; | 15106 | to_intel_plane_state(primary->state); |
15083 | |||
15084 | for_each_intel_plane(crtc->base.dev, p) { | ||
15085 | if (crtc->pipe != p->pipe) | ||
15086 | continue; | ||
15087 | |||
15088 | plane_state = to_intel_plane_state(p->base.state); | ||
15089 | 15107 | ||
15090 | if (p->base.type == DRM_PLANE_TYPE_PRIMARY) { | 15108 | plane_state->visible = |
15091 | plane_state->visible = primary_get_hw_state(crtc); | 15109 | primary_get_hw_state(to_intel_plane(primary)); |
15092 | if (plane_state->visible) | ||
15093 | crtc->base.state->plane_mask |= | ||
15094 | 1 << drm_plane_index(&p->base); | ||
15095 | } else { | ||
15096 | if (active) | ||
15097 | p->disable_plane(&p->base, &crtc->base); | ||
15098 | 15110 | ||
15099 | plane_state->visible = false; | 15111 | if (plane_state->visible) |
15100 | } | 15112 | crtc->base.state->plane_mask |= 1 << drm_plane_index(primary); |
15101 | } | ||
15102 | } | 15113 | } |
15103 | 15114 | ||
15104 | static void intel_modeset_readout_hw_state(struct drm_device *dev) | 15115 | static void intel_modeset_readout_hw_state(struct drm_device *dev) |
@@ -15121,34 +15132,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) | |||
15121 | crtc->base.state->active = crtc->active; | 15132 | crtc->base.state->active = crtc->active; |
15122 | crtc->base.enabled = crtc->active; | 15133 | crtc->base.enabled = crtc->active; |
15123 | 15134 | ||
15124 | memset(&crtc->base.mode, 0, sizeof(crtc->base.mode)); | 15135 | readout_plane_state(crtc); |
15125 | if (crtc->base.state->active) { | ||
15126 | intel_mode_from_pipe_config(&crtc->base.mode, crtc->config); | ||
15127 | intel_mode_from_pipe_config(&crtc->base.state->adjusted_mode, crtc->config); | ||
15128 | WARN_ON(drm_atomic_set_mode_for_crtc(crtc->base.state, &crtc->base.mode)); | ||
15129 | |||
15130 | /* | ||
15131 | * The initial mode needs to be set in order to keep | ||
15132 | * the atomic core happy. It wants a valid mode if the | ||
15133 | * crtc's enabled, so we do the above call. | ||
15134 | * | ||
15135 | * At this point some state updated by the connectors | ||
15136 | * in their ->detect() callback has not run yet, so | ||
15137 | * no recalculation can be done yet. | ||
15138 | * | ||
15139 | * Even if we could do a recalculation and modeset | ||
15140 | * right now it would cause a double modeset if | ||
15141 | * fbdev or userspace chooses a different initial mode. | ||
15142 | * | ||
15143 | * If that happens, someone indicated they wanted a | ||
15144 | * mode change, which means it's safe to do a full | ||
15145 | * recalculation. | ||
15146 | */ | ||
15147 | crtc->base.state->mode.private_flags = I915_MODE_FLAG_INHERITED; | ||
15148 | } | ||
15149 | |||
15150 | crtc->base.hwmode = crtc->config->base.adjusted_mode; | ||
15151 | readout_plane_state(crtc, to_intel_crtc_state(crtc->base.state)); | ||
15152 | 15136 | ||
15153 | DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n", | 15137 | DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n", |
15154 | crtc->base.base.id, | 15138 | crtc->base.base.id, |
@@ -15207,6 +15191,36 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) | |||
15207 | connector->base.name, | 15191 | connector->base.name, |
15208 | connector->base.encoder ? "enabled" : "disabled"); | 15192 | connector->base.encoder ? "enabled" : "disabled"); |
15209 | } | 15193 | } |
15194 | |||
15195 | for_each_intel_crtc(dev, crtc) { | ||
15196 | crtc->base.hwmode = crtc->config->base.adjusted_mode; | ||
15197 | |||
15198 | memset(&crtc->base.mode, 0, sizeof(crtc->base.mode)); | ||
15199 | if (crtc->base.state->active) { | ||
15200 | intel_mode_from_pipe_config(&crtc->base.mode, crtc->config); | ||
15201 | intel_mode_from_pipe_config(&crtc->base.state->adjusted_mode, crtc->config); | ||
15202 | WARN_ON(drm_atomic_set_mode_for_crtc(crtc->base.state, &crtc->base.mode)); | ||
15203 | |||
15204 | /* | ||
15205 | * The initial mode needs to be set in order to keep | ||
15206 | * the atomic core happy. It wants a valid mode if the | ||
15207 | * crtc's enabled, so we do the above call. | ||
15208 | * | ||
15209 | * At this point some state updated by the connectors | ||
15210 | * in their ->detect() callback has not run yet, so | ||
15211 | * no recalculation can be done yet. | ||
15212 | * | ||
15213 | * Even if we could do a recalculation and modeset | ||
15214 | * right now it would cause a double modeset if | ||
15215 | * fbdev or userspace chooses a different initial mode. | ||
15216 | * | ||
15217 | * If that happens, someone indicated they wanted a | ||
15218 | * mode change, which means it's safe to do a full | ||
15219 | * recalculation. | ||
15220 | */ | ||
15221 | crtc->base.state->mode.private_flags = I915_MODE_FLAG_INHERITED; | ||
15222 | } | ||
15223 | } | ||
15210 | } | 15224 | } |
15211 | 15225 | ||
15212 | /* Scan out the current hw modeset state, | 15226 | /* Scan out the current hw modeset state, |
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 7412caedcf7f..29dd4488dc49 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c | |||
@@ -1659,6 +1659,7 @@ static int gen8_emit_flush_render(struct drm_i915_gem_request *request, | |||
1659 | if (flush_domains) { | 1659 | if (flush_domains) { |
1660 | flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH; | 1660 | flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH; |
1661 | flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH; | 1661 | flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH; |
1662 | flags |= PIPE_CONTROL_FLUSH_ENABLE; | ||
1662 | } | 1663 | } |
1663 | 1664 | ||
1664 | if (invalidate_domains) { | 1665 | if (invalidate_domains) { |
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index 6e6b8db996ef..61b451fbd09e 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c | |||
@@ -347,6 +347,7 @@ gen7_render_ring_flush(struct drm_i915_gem_request *req, | |||
347 | if (flush_domains) { | 347 | if (flush_domains) { |
348 | flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH; | 348 | flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH; |
349 | flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH; | 349 | flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH; |
350 | flags |= PIPE_CONTROL_FLUSH_ENABLE; | ||
350 | } | 351 | } |
351 | if (invalidate_domains) { | 352 | if (invalidate_domains) { |
352 | flags |= PIPE_CONTROL_TLB_INVALIDATE; | 353 | flags |= PIPE_CONTROL_TLB_INVALIDATE; |
@@ -418,6 +419,7 @@ gen8_render_ring_flush(struct drm_i915_gem_request *req, | |||
418 | if (flush_domains) { | 419 | if (flush_domains) { |
419 | flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH; | 420 | flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH; |
420 | flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH; | 421 | flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH; |
422 | flags |= PIPE_CONTROL_FLUSH_ENABLE; | ||
421 | } | 423 | } |
422 | if (invalidate_domains) { | 424 | if (invalidate_domains) { |
423 | flags |= PIPE_CONTROL_TLB_INVALIDATE; | 425 | flags |= PIPE_CONTROL_TLB_INVALIDATE; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 2c9981512d27..41be584147b9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c | |||
@@ -227,11 +227,12 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem, | |||
227 | struct nouveau_bo *nvbo = nouveau_gem_object(gem); | 227 | struct nouveau_bo *nvbo = nouveau_gem_object(gem); |
228 | struct nvkm_vma *vma; | 228 | struct nvkm_vma *vma; |
229 | 229 | ||
230 | if (nvbo->bo.mem.mem_type == TTM_PL_TT) | 230 | if (is_power_of_2(nvbo->valid_domains)) |
231 | rep->domain = nvbo->valid_domains; | ||
232 | else if (nvbo->bo.mem.mem_type == TTM_PL_TT) | ||
231 | rep->domain = NOUVEAU_GEM_DOMAIN_GART; | 233 | rep->domain = NOUVEAU_GEM_DOMAIN_GART; |
232 | else | 234 | else |
233 | rep->domain = NOUVEAU_GEM_DOMAIN_VRAM; | 235 | rep->domain = NOUVEAU_GEM_DOMAIN_VRAM; |
234 | |||
235 | rep->offset = nvbo->bo.offset; | 236 | rep->offset = nvbo->bo.offset; |
236 | if (cli->vm) { | 237 | if (cli->vm) { |
237 | vma = nouveau_bo_vma_find(nvbo, cli->vm); | 238 | vma = nouveau_bo_vma_find(nvbo, cli->vm); |
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index 44489cce7458..6a0a176e26ec 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c | |||
@@ -717,10 +717,14 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, | |||
717 | struct radeon_device *rdev = dev_get_drvdata(dev); | 717 | struct radeon_device *rdev = dev_get_drvdata(dev); |
718 | umode_t effective_mode = attr->mode; | 718 | umode_t effective_mode = attr->mode; |
719 | 719 | ||
720 | /* Skip limit attributes if DPM is not enabled */ | 720 | /* Skip attributes if DPM is not enabled */ |
721 | if (rdev->pm.pm_method != PM_METHOD_DPM && | 721 | if (rdev->pm.pm_method != PM_METHOD_DPM && |
722 | (attr == &sensor_dev_attr_temp1_crit.dev_attr.attr || | 722 | (attr == &sensor_dev_attr_temp1_crit.dev_attr.attr || |
723 | attr == &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr)) | 723 | attr == &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr || |
724 | attr == &sensor_dev_attr_pwm1.dev_attr.attr || | ||
725 | attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || | ||
726 | attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || | ||
727 | attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) | ||
724 | return 0; | 728 | return 0; |
725 | 729 | ||
726 | /* Skip fan attributes if fan is not present */ | 730 | /* Skip fan attributes if fan is not present */ |
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index ff30f8806880..fb9311110424 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c | |||
@@ -149,8 +149,6 @@ | |||
149 | #define ST_ACCEL_4_BDU_MASK 0x40 | 149 | #define ST_ACCEL_4_BDU_MASK 0x40 |
150 | #define ST_ACCEL_4_DRDY_IRQ_ADDR 0x21 | 150 | #define ST_ACCEL_4_DRDY_IRQ_ADDR 0x21 |
151 | #define ST_ACCEL_4_DRDY_IRQ_INT1_MASK 0x04 | 151 | #define ST_ACCEL_4_DRDY_IRQ_INT1_MASK 0x04 |
152 | #define ST_ACCEL_4_IG1_EN_ADDR 0x21 | ||
153 | #define ST_ACCEL_4_IG1_EN_MASK 0x08 | ||
154 | #define ST_ACCEL_4_MULTIREAD_BIT true | 152 | #define ST_ACCEL_4_MULTIREAD_BIT true |
155 | 153 | ||
156 | /* CUSTOM VALUES FOR SENSOR 5 */ | 154 | /* CUSTOM VALUES FOR SENSOR 5 */ |
@@ -489,10 +487,6 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { | |||
489 | .drdy_irq = { | 487 | .drdy_irq = { |
490 | .addr = ST_ACCEL_4_DRDY_IRQ_ADDR, | 488 | .addr = ST_ACCEL_4_DRDY_IRQ_ADDR, |
491 | .mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK, | 489 | .mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK, |
492 | .ig1 = { | ||
493 | .en_addr = ST_ACCEL_4_IG1_EN_ADDR, | ||
494 | .en_mask = ST_ACCEL_4_IG1_EN_MASK, | ||
495 | }, | ||
496 | }, | 490 | }, |
497 | .multi_read_bit = ST_ACCEL_4_MULTIREAD_BIT, | 491 | .multi_read_bit = ST_ACCEL_4_MULTIREAD_BIT, |
498 | .bootime = 2, /* guess */ | 492 | .bootime = 2, /* guess */ |
diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c index ebe415f10640..0c74869a540a 100644 --- a/drivers/iio/adc/twl4030-madc.c +++ b/drivers/iio/adc/twl4030-madc.c | |||
@@ -45,13 +45,18 @@ | |||
45 | #include <linux/types.h> | 45 | #include <linux/types.h> |
46 | #include <linux/gfp.h> | 46 | #include <linux/gfp.h> |
47 | #include <linux/err.h> | 47 | #include <linux/err.h> |
48 | #include <linux/regulator/consumer.h> | ||
48 | 49 | ||
49 | #include <linux/iio/iio.h> | 50 | #include <linux/iio/iio.h> |
50 | 51 | ||
52 | #define TWL4030_USB_SEL_MADC_MCPC (1<<3) | ||
53 | #define TWL4030_USB_CARKIT_ANA_CTRL 0xBB | ||
54 | |||
51 | /** | 55 | /** |
52 | * struct twl4030_madc_data - a container for madc info | 56 | * struct twl4030_madc_data - a container for madc info |
53 | * @dev: Pointer to device structure for madc | 57 | * @dev: Pointer to device structure for madc |
54 | * @lock: Mutex protecting this data structure | 58 | * @lock: Mutex protecting this data structure |
59 | * @regulator: Pointer to bias regulator for madc | ||
55 | * @requests: Array of request struct corresponding to SW1, SW2 and RT | 60 | * @requests: Array of request struct corresponding to SW1, SW2 and RT |
56 | * @use_second_irq: IRQ selection (main or co-processor) | 61 | * @use_second_irq: IRQ selection (main or co-processor) |
57 | * @imr: Interrupt mask register of MADC | 62 | * @imr: Interrupt mask register of MADC |
@@ -60,6 +65,7 @@ | |||
60 | struct twl4030_madc_data { | 65 | struct twl4030_madc_data { |
61 | struct device *dev; | 66 | struct device *dev; |
62 | struct mutex lock; /* mutex protecting this data structure */ | 67 | struct mutex lock; /* mutex protecting this data structure */ |
68 | struct regulator *usb3v1; | ||
63 | struct twl4030_madc_request requests[TWL4030_MADC_NUM_METHODS]; | 69 | struct twl4030_madc_request requests[TWL4030_MADC_NUM_METHODS]; |
64 | bool use_second_irq; | 70 | bool use_second_irq; |
65 | u8 imr; | 71 | u8 imr; |
@@ -841,6 +847,32 @@ static int twl4030_madc_probe(struct platform_device *pdev) | |||
841 | } | 847 | } |
842 | twl4030_madc = madc; | 848 | twl4030_madc = madc; |
843 | 849 | ||
850 | /* Configure MADC[3:6] */ | ||
851 | ret = twl_i2c_read_u8(TWL_MODULE_USB, ®val, | ||
852 | TWL4030_USB_CARKIT_ANA_CTRL); | ||
853 | if (ret) { | ||
854 | dev_err(&pdev->dev, "unable to read reg CARKIT_ANA_CTRL 0x%X\n", | ||
855 | TWL4030_USB_CARKIT_ANA_CTRL); | ||
856 | goto err_i2c; | ||
857 | } | ||
858 | regval |= TWL4030_USB_SEL_MADC_MCPC; | ||
859 | ret = twl_i2c_write_u8(TWL_MODULE_USB, regval, | ||
860 | TWL4030_USB_CARKIT_ANA_CTRL); | ||
861 | if (ret) { | ||
862 | dev_err(&pdev->dev, "unable to write reg CARKIT_ANA_CTRL 0x%X\n", | ||
863 | TWL4030_USB_CARKIT_ANA_CTRL); | ||
864 | goto err_i2c; | ||
865 | } | ||
866 | |||
867 | /* Enable 3v1 bias regulator for MADC[3:6] */ | ||
868 | madc->usb3v1 = devm_regulator_get(madc->dev, "vusb3v1"); | ||
869 | if (IS_ERR(madc->usb3v1)) | ||
870 | return -ENODEV; | ||
871 | |||
872 | ret = regulator_enable(madc->usb3v1); | ||
873 | if (ret) | ||
874 | dev_err(madc->dev, "could not enable 3v1 bias regulator\n"); | ||
875 | |||
844 | ret = iio_device_register(iio_dev); | 876 | ret = iio_device_register(iio_dev); |
845 | if (ret) { | 877 | if (ret) { |
846 | dev_err(&pdev->dev, "could not register iio device\n"); | 878 | dev_err(&pdev->dev, "could not register iio device\n"); |
@@ -866,6 +898,8 @@ static int twl4030_madc_remove(struct platform_device *pdev) | |||
866 | twl4030_madc_set_current_generator(madc, 0, 0); | 898 | twl4030_madc_set_current_generator(madc, 0, 0); |
867 | twl4030_madc_set_power(madc, 0); | 899 | twl4030_madc_set_power(madc, 0); |
868 | 900 | ||
901 | regulator_disable(madc->usb3v1); | ||
902 | |||
869 | return 0; | 903 | return 0; |
870 | } | 904 | } |
871 | 905 | ||
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 8f66c67ff0df..87471ef37198 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c | |||
@@ -508,12 +508,12 @@ void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u8 port, | |||
508 | memset(&gid_attr, 0, sizeof(gid_attr)); | 508 | memset(&gid_attr, 0, sizeof(gid_attr)); |
509 | gid_attr.ndev = ndev; | 509 | gid_attr.ndev = ndev; |
510 | 510 | ||
511 | mutex_lock(&table->lock); | ||
511 | ix = find_gid(table, NULL, NULL, true, GID_ATTR_FIND_MASK_DEFAULT); | 512 | ix = find_gid(table, NULL, NULL, true, GID_ATTR_FIND_MASK_DEFAULT); |
512 | 513 | ||
513 | /* Coudn't find default GID location */ | 514 | /* Coudn't find default GID location */ |
514 | WARN_ON(ix < 0); | 515 | WARN_ON(ix < 0); |
515 | 516 | ||
516 | mutex_lock(&table->lock); | ||
517 | if (!__ib_cache_gid_get(ib_dev, port, ix, | 517 | if (!__ib_cache_gid_get(ib_dev, port, ix, |
518 | ¤t_gid, ¤t_gid_attr) && | 518 | ¤t_gid, ¤t_gid_attr) && |
519 | mode == IB_CACHE_GID_DEFAULT_MODE_SET && | 519 | mode == IB_CACHE_GID_DEFAULT_MODE_SET && |
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index ea4db9c1d44f..4f918b929eca 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c | |||
@@ -835,6 +835,11 @@ retest: | |||
835 | case IB_CM_SIDR_REQ_RCVD: | 835 | case IB_CM_SIDR_REQ_RCVD: |
836 | spin_unlock_irq(&cm_id_priv->lock); | 836 | spin_unlock_irq(&cm_id_priv->lock); |
837 | cm_reject_sidr_req(cm_id_priv, IB_SIDR_REJECT); | 837 | cm_reject_sidr_req(cm_id_priv, IB_SIDR_REJECT); |
838 | spin_lock_irq(&cm.lock); | ||
839 | if (!RB_EMPTY_NODE(&cm_id_priv->sidr_id_node)) | ||
840 | rb_erase(&cm_id_priv->sidr_id_node, | ||
841 | &cm.remote_sidr_table); | ||
842 | spin_unlock_irq(&cm.lock); | ||
838 | break; | 843 | break; |
839 | case IB_CM_REQ_SENT: | 844 | case IB_CM_REQ_SENT: |
840 | case IB_CM_MRA_REQ_RCVD: | 845 | case IB_CM_MRA_REQ_RCVD: |
@@ -3172,7 +3177,10 @@ int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, | |||
3172 | spin_unlock_irqrestore(&cm_id_priv->lock, flags); | 3177 | spin_unlock_irqrestore(&cm_id_priv->lock, flags); |
3173 | 3178 | ||
3174 | spin_lock_irqsave(&cm.lock, flags); | 3179 | spin_lock_irqsave(&cm.lock, flags); |
3175 | rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table); | 3180 | if (!RB_EMPTY_NODE(&cm_id_priv->sidr_id_node)) { |
3181 | rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table); | ||
3182 | RB_CLEAR_NODE(&cm_id_priv->sidr_id_node); | ||
3183 | } | ||
3176 | spin_unlock_irqrestore(&cm.lock, flags); | 3184 | spin_unlock_irqrestore(&cm.lock, flags); |
3177 | return 0; | 3185 | return 0; |
3178 | 3186 | ||
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 59a2dafc8c57..36b12d560e17 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -1067,14 +1067,14 @@ static int cma_save_req_info(const struct ib_cm_event *ib_event, | |||
1067 | sizeof(req->local_gid)); | 1067 | sizeof(req->local_gid)); |
1068 | req->has_gid = true; | 1068 | req->has_gid = true; |
1069 | req->service_id = req_param->primary_path->service_id; | 1069 | req->service_id = req_param->primary_path->service_id; |
1070 | req->pkey = req_param->bth_pkey; | 1070 | req->pkey = be16_to_cpu(req_param->primary_path->pkey); |
1071 | break; | 1071 | break; |
1072 | case IB_CM_SIDR_REQ_RECEIVED: | 1072 | case IB_CM_SIDR_REQ_RECEIVED: |
1073 | req->device = sidr_param->listen_id->device; | 1073 | req->device = sidr_param->listen_id->device; |
1074 | req->port = sidr_param->port; | 1074 | req->port = sidr_param->port; |
1075 | req->has_gid = false; | 1075 | req->has_gid = false; |
1076 | req->service_id = sidr_param->service_id; | 1076 | req->service_id = sidr_param->service_id; |
1077 | req->pkey = sidr_param->bth_pkey; | 1077 | req->pkey = sidr_param->pkey; |
1078 | break; | 1078 | break; |
1079 | default: | 1079 | default: |
1080 | return -EINVAL; | 1080 | return -EINVAL; |
@@ -1324,7 +1324,7 @@ static struct rdma_id_private *cma_id_from_event(struct ib_cm_id *cm_id, | |||
1324 | bind_list = cma_ps_find(rdma_ps_from_service_id(req.service_id), | 1324 | bind_list = cma_ps_find(rdma_ps_from_service_id(req.service_id), |
1325 | cma_port_from_service_id(req.service_id)); | 1325 | cma_port_from_service_id(req.service_id)); |
1326 | id_priv = cma_find_listener(bind_list, cm_id, ib_event, &req, *net_dev); | 1326 | id_priv = cma_find_listener(bind_list, cm_id, ib_event, &req, *net_dev); |
1327 | if (IS_ERR(id_priv)) { | 1327 | if (IS_ERR(id_priv) && *net_dev) { |
1328 | dev_put(*net_dev); | 1328 | dev_put(*net_dev); |
1329 | *net_dev = NULL; | 1329 | *net_dev = NULL; |
1330 | } | 1330 | } |
diff --git a/drivers/infiniband/core/roce_gid_mgmt.c b/drivers/infiniband/core/roce_gid_mgmt.c index 6b24cba1e474..178f98482e13 100644 --- a/drivers/infiniband/core/roce_gid_mgmt.c +++ b/drivers/infiniband/core/roce_gid_mgmt.c | |||
@@ -250,25 +250,44 @@ static void enum_netdev_ipv4_ips(struct ib_device *ib_dev, | |||
250 | u8 port, struct net_device *ndev) | 250 | u8 port, struct net_device *ndev) |
251 | { | 251 | { |
252 | struct in_device *in_dev; | 252 | struct in_device *in_dev; |
253 | struct sin_list { | ||
254 | struct list_head list; | ||
255 | struct sockaddr_in ip; | ||
256 | }; | ||
257 | struct sin_list *sin_iter; | ||
258 | struct sin_list *sin_temp; | ||
253 | 259 | ||
260 | LIST_HEAD(sin_list); | ||
254 | if (ndev->reg_state >= NETREG_UNREGISTERING) | 261 | if (ndev->reg_state >= NETREG_UNREGISTERING) |
255 | return; | 262 | return; |
256 | 263 | ||
257 | in_dev = in_dev_get(ndev); | 264 | rcu_read_lock(); |
258 | if (!in_dev) | 265 | in_dev = __in_dev_get_rcu(ndev); |
266 | if (!in_dev) { | ||
267 | rcu_read_unlock(); | ||
259 | return; | 268 | return; |
269 | } | ||
260 | 270 | ||
261 | for_ifa(in_dev) { | 271 | for_ifa(in_dev) { |
262 | struct sockaddr_in ip; | 272 | struct sin_list *entry = kzalloc(sizeof(*entry), GFP_ATOMIC); |
263 | 273 | ||
264 | ip.sin_family = AF_INET; | 274 | if (!entry) { |
265 | ip.sin_addr.s_addr = ifa->ifa_address; | 275 | pr_warn("roce_gid_mgmt: couldn't allocate entry for IPv4 update\n"); |
266 | update_gid_ip(GID_ADD, ib_dev, port, ndev, | 276 | continue; |
267 | (struct sockaddr *)&ip); | 277 | } |
278 | entry->ip.sin_family = AF_INET; | ||
279 | entry->ip.sin_addr.s_addr = ifa->ifa_address; | ||
280 | list_add_tail(&entry->list, &sin_list); | ||
268 | } | 281 | } |
269 | endfor_ifa(in_dev); | 282 | endfor_ifa(in_dev); |
283 | rcu_read_unlock(); | ||
270 | 284 | ||
271 | in_dev_put(in_dev); | 285 | list_for_each_entry_safe(sin_iter, sin_temp, &sin_list, list) { |
286 | update_gid_ip(GID_ADD, ib_dev, port, ndev, | ||
287 | (struct sockaddr *)&sin_iter->ip); | ||
288 | list_del(&sin_iter->list); | ||
289 | kfree(sin_iter); | ||
290 | } | ||
272 | } | 291 | } |
273 | 292 | ||
274 | static void enum_netdev_ipv6_ips(struct ib_device *ib_dev, | 293 | static void enum_netdev_ipv6_ips(struct ib_device *ib_dev, |
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index a53fc9b01c69..30467d10df91 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c | |||
@@ -1624,11 +1624,16 @@ static int ucma_open(struct inode *inode, struct file *filp) | |||
1624 | if (!file) | 1624 | if (!file) |
1625 | return -ENOMEM; | 1625 | return -ENOMEM; |
1626 | 1626 | ||
1627 | file->close_wq = create_singlethread_workqueue("ucma_close_id"); | ||
1628 | if (!file->close_wq) { | ||
1629 | kfree(file); | ||
1630 | return -ENOMEM; | ||
1631 | } | ||
1632 | |||
1627 | INIT_LIST_HEAD(&file->event_list); | 1633 | INIT_LIST_HEAD(&file->event_list); |
1628 | INIT_LIST_HEAD(&file->ctx_list); | 1634 | INIT_LIST_HEAD(&file->ctx_list); |
1629 | init_waitqueue_head(&file->poll_wait); | 1635 | init_waitqueue_head(&file->poll_wait); |
1630 | mutex_init(&file->mut); | 1636 | mutex_init(&file->mut); |
1631 | file->close_wq = create_singlethread_workqueue("ucma_close_id"); | ||
1632 | 1637 | ||
1633 | filp->private_data = file; | 1638 | filp->private_data = file; |
1634 | file->filp = filp; | 1639 | file->filp = filp; |
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 35365f046923..d65cf42399e8 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -2115,15 +2115,19 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn, | |||
2115 | return -ENOMEM; | 2115 | return -ENOMEM; |
2116 | /* It is large page*/ | 2116 | /* It is large page*/ |
2117 | if (largepage_lvl > 1) { | 2117 | if (largepage_lvl > 1) { |
2118 | unsigned long nr_superpages, end_pfn; | ||
2119 | |||
2118 | pteval |= DMA_PTE_LARGE_PAGE; | 2120 | pteval |= DMA_PTE_LARGE_PAGE; |
2119 | lvl_pages = lvl_to_nr_pages(largepage_lvl); | 2121 | lvl_pages = lvl_to_nr_pages(largepage_lvl); |
2122 | |||
2123 | nr_superpages = sg_res / lvl_pages; | ||
2124 | end_pfn = iov_pfn + nr_superpages * lvl_pages - 1; | ||
2125 | |||
2120 | /* | 2126 | /* |
2121 | * Ensure that old small page tables are | 2127 | * Ensure that old small page tables are |
2122 | * removed to make room for superpage, | 2128 | * removed to make room for superpage(s). |
2123 | * if they exist. | ||
2124 | */ | 2129 | */ |
2125 | dma_pte_free_pagetable(domain, iov_pfn, | 2130 | dma_pte_free_pagetable(domain, iov_pfn, end_pfn); |
2126 | iov_pfn + lvl_pages - 1); | ||
2127 | } else { | 2131 | } else { |
2128 | pteval &= ~(uint64_t)DMA_PTE_LARGE_PAGE; | 2132 | pteval &= ~(uint64_t)DMA_PTE_LARGE_PAGE; |
2129 | } | 2133 | } |
diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c index 20cc36b01b77..0a17d1b91a81 100644 --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c | |||
@@ -634,10 +634,10 @@ static int __commit_transaction(struct dm_cache_metadata *cmd, | |||
634 | 634 | ||
635 | disk_super = dm_block_data(sblock); | 635 | disk_super = dm_block_data(sblock); |
636 | 636 | ||
637 | disk_super->flags = cpu_to_le32(cmd->flags); | ||
637 | if (mutator) | 638 | if (mutator) |
638 | update_flags(disk_super, mutator); | 639 | update_flags(disk_super, mutator); |
639 | 640 | ||
640 | disk_super->flags = cpu_to_le32(cmd->flags); | ||
641 | disk_super->mapping_root = cpu_to_le64(cmd->root); | 641 | disk_super->mapping_root = cpu_to_le64(cmd->root); |
642 | disk_super->hint_root = cpu_to_le64(cmd->hint_root); | 642 | disk_super->hint_root = cpu_to_le64(cmd->hint_root); |
643 | disk_super->discard_root = cpu_to_le64(cmd->discard_root); | 643 | disk_super->discard_root = cpu_to_le64(cmd->discard_root); |
diff --git a/drivers/md/persistent-data/dm-btree-remove.c b/drivers/md/persistent-data/dm-btree-remove.c index 421a36c593e3..2e4c4cb79e4d 100644 --- a/drivers/md/persistent-data/dm-btree-remove.c +++ b/drivers/md/persistent-data/dm-btree-remove.c | |||
@@ -301,11 +301,16 @@ static void redistribute3(struct dm_btree_info *info, struct btree_node *parent, | |||
301 | { | 301 | { |
302 | int s; | 302 | int s; |
303 | uint32_t max_entries = le32_to_cpu(left->header.max_entries); | 303 | uint32_t max_entries = le32_to_cpu(left->header.max_entries); |
304 | unsigned target = (nr_left + nr_center + nr_right) / 3; | 304 | unsigned total = nr_left + nr_center + nr_right; |
305 | BUG_ON(target > max_entries); | 305 | unsigned target_right = total / 3; |
306 | unsigned remainder = (target_right * 3) != total; | ||
307 | unsigned target_left = target_right + remainder; | ||
308 | |||
309 | BUG_ON(target_left > max_entries); | ||
310 | BUG_ON(target_right > max_entries); | ||
306 | 311 | ||
307 | if (nr_left < nr_right) { | 312 | if (nr_left < nr_right) { |
308 | s = nr_left - target; | 313 | s = nr_left - target_left; |
309 | 314 | ||
310 | if (s < 0 && nr_center < -s) { | 315 | if (s < 0 && nr_center < -s) { |
311 | /* not enough in central node */ | 316 | /* not enough in central node */ |
@@ -316,10 +321,10 @@ static void redistribute3(struct dm_btree_info *info, struct btree_node *parent, | |||
316 | } else | 321 | } else |
317 | shift(left, center, s); | 322 | shift(left, center, s); |
318 | 323 | ||
319 | shift(center, right, target - nr_right); | 324 | shift(center, right, target_right - nr_right); |
320 | 325 | ||
321 | } else { | 326 | } else { |
322 | s = target - nr_right; | 327 | s = target_right - nr_right; |
323 | if (s > 0 && nr_center < s) { | 328 | if (s > 0 && nr_center < s) { |
324 | /* not enough in central node */ | 329 | /* not enough in central node */ |
325 | shift(center, right, nr_center); | 330 | shift(center, right, nr_center); |
@@ -329,7 +334,7 @@ static void redistribute3(struct dm_btree_info *info, struct btree_node *parent, | |||
329 | } else | 334 | } else |
330 | shift(center, right, s); | 335 | shift(center, right, s); |
331 | 336 | ||
332 | shift(left, center, nr_left - target); | 337 | shift(left, center, nr_left - target_left); |
333 | } | 338 | } |
334 | 339 | ||
335 | *key_ptr(parent, c->index) = center->keys[0]; | 340 | *key_ptr(parent, c->index) = center->keys[0]; |
diff --git a/drivers/md/persistent-data/dm-btree.c b/drivers/md/persistent-data/dm-btree.c index b6cec258cc21..0e09aef43998 100644 --- a/drivers/md/persistent-data/dm-btree.c +++ b/drivers/md/persistent-data/dm-btree.c | |||
@@ -523,7 +523,7 @@ static int btree_split_beneath(struct shadow_spine *s, uint64_t key) | |||
523 | 523 | ||
524 | r = new_block(s->info, &right); | 524 | r = new_block(s->info, &right); |
525 | if (r < 0) { | 525 | if (r < 0) { |
526 | /* FIXME: put left */ | 526 | unlock_block(s->info, left); |
527 | return r; | 527 | return r; |
528 | } | 528 | } |
529 | 529 | ||
diff --git a/drivers/media/dvb-frontends/horus3a.h b/drivers/media/dvb-frontends/horus3a.h index b055319d532e..c1e2d1834b78 100644 --- a/drivers/media/dvb-frontends/horus3a.h +++ b/drivers/media/dvb-frontends/horus3a.h | |||
@@ -46,8 +46,8 @@ extern struct dvb_frontend *horus3a_attach(struct dvb_frontend *fe, | |||
46 | const struct horus3a_config *config, | 46 | const struct horus3a_config *config, |
47 | struct i2c_adapter *i2c); | 47 | struct i2c_adapter *i2c); |
48 | #else | 48 | #else |
49 | static inline struct dvb_frontend *horus3a_attach( | 49 | static inline struct dvb_frontend *horus3a_attach(struct dvb_frontend *fe, |
50 | const struct cxd2820r_config *config, | 50 | const struct horus3a_config *config, |
51 | struct i2c_adapter *i2c) | 51 | struct i2c_adapter *i2c) |
52 | { | 52 | { |
53 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | 53 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
diff --git a/drivers/media/dvb-frontends/lnbh25.h b/drivers/media/dvb-frontends/lnbh25.h index 69f30e21f6b3..1f329ef05acc 100644 --- a/drivers/media/dvb-frontends/lnbh25.h +++ b/drivers/media/dvb-frontends/lnbh25.h | |||
@@ -43,7 +43,7 @@ struct dvb_frontend *lnbh25_attach( | |||
43 | struct lnbh25_config *cfg, | 43 | struct lnbh25_config *cfg, |
44 | struct i2c_adapter *i2c); | 44 | struct i2c_adapter *i2c); |
45 | #else | 45 | #else |
46 | static inline dvb_frontend *lnbh25_attach( | 46 | static inline struct dvb_frontend *lnbh25_attach( |
47 | struct dvb_frontend *fe, | 47 | struct dvb_frontend *fe, |
48 | struct lnbh25_config *cfg, | 48 | struct lnbh25_config *cfg, |
49 | struct i2c_adapter *i2c) | 49 | struct i2c_adapter *i2c) |
diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c index ff31e7a01ca9..feeeb70d841e 100644 --- a/drivers/media/dvb-frontends/m88ds3103.c +++ b/drivers/media/dvb-frontends/m88ds3103.c | |||
@@ -18,6 +18,27 @@ | |||
18 | 18 | ||
19 | static struct dvb_frontend_ops m88ds3103_ops; | 19 | static struct dvb_frontend_ops m88ds3103_ops; |
20 | 20 | ||
21 | /* write single register with mask */ | ||
22 | static int m88ds3103_update_bits(struct m88ds3103_dev *dev, | ||
23 | u8 reg, u8 mask, u8 val) | ||
24 | { | ||
25 | int ret; | ||
26 | u8 tmp; | ||
27 | |||
28 | /* no need for read if whole reg is written */ | ||
29 | if (mask != 0xff) { | ||
30 | ret = regmap_bulk_read(dev->regmap, reg, &tmp, 1); | ||
31 | if (ret) | ||
32 | return ret; | ||
33 | |||
34 | val &= mask; | ||
35 | tmp &= ~mask; | ||
36 | val |= tmp; | ||
37 | } | ||
38 | |||
39 | return regmap_bulk_write(dev->regmap, reg, &val, 1); | ||
40 | } | ||
41 | |||
21 | /* write reg val table using reg addr auto increment */ | 42 | /* write reg val table using reg addr auto increment */ |
22 | static int m88ds3103_wr_reg_val_tab(struct m88ds3103_dev *dev, | 43 | static int m88ds3103_wr_reg_val_tab(struct m88ds3103_dev *dev, |
23 | const struct m88ds3103_reg_val *tab, int tab_len) | 44 | const struct m88ds3103_reg_val *tab, int tab_len) |
@@ -394,10 +415,10 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
394 | u8tmp2 = 0x00; /* 0b00 */ | 415 | u8tmp2 = 0x00; /* 0b00 */ |
395 | break; | 416 | break; |
396 | } | 417 | } |
397 | ret = regmap_update_bits(dev->regmap, 0x22, 0xc0, u8tmp1 << 6); | 418 | ret = m88ds3103_update_bits(dev, 0x22, 0xc0, u8tmp1 << 6); |
398 | if (ret) | 419 | if (ret) |
399 | goto err; | 420 | goto err; |
400 | ret = regmap_update_bits(dev->regmap, 0x24, 0xc0, u8tmp2 << 6); | 421 | ret = m88ds3103_update_bits(dev, 0x24, 0xc0, u8tmp2 << 6); |
401 | if (ret) | 422 | if (ret) |
402 | goto err; | 423 | goto err; |
403 | } | 424 | } |
@@ -455,13 +476,13 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
455 | if (ret) | 476 | if (ret) |
456 | goto err; | 477 | goto err; |
457 | } | 478 | } |
458 | ret = regmap_update_bits(dev->regmap, 0x9d, 0x08, 0x08); | 479 | ret = m88ds3103_update_bits(dev, 0x9d, 0x08, 0x08); |
459 | if (ret) | 480 | if (ret) |
460 | goto err; | 481 | goto err; |
461 | ret = regmap_write(dev->regmap, 0xf1, 0x01); | 482 | ret = regmap_write(dev->regmap, 0xf1, 0x01); |
462 | if (ret) | 483 | if (ret) |
463 | goto err; | 484 | goto err; |
464 | ret = regmap_update_bits(dev->regmap, 0x30, 0x80, 0x80); | 485 | ret = m88ds3103_update_bits(dev, 0x30, 0x80, 0x80); |
465 | if (ret) | 486 | if (ret) |
466 | goto err; | 487 | goto err; |
467 | } | 488 | } |
@@ -498,7 +519,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
498 | switch (dev->cfg->ts_mode) { | 519 | switch (dev->cfg->ts_mode) { |
499 | case M88DS3103_TS_SERIAL: | 520 | case M88DS3103_TS_SERIAL: |
500 | case M88DS3103_TS_SERIAL_D7: | 521 | case M88DS3103_TS_SERIAL_D7: |
501 | ret = regmap_update_bits(dev->regmap, 0x29, 0x20, u8tmp1); | 522 | ret = m88ds3103_update_bits(dev, 0x29, 0x20, u8tmp1); |
502 | if (ret) | 523 | if (ret) |
503 | goto err; | 524 | goto err; |
504 | u8tmp1 = 0; | 525 | u8tmp1 = 0; |
@@ -567,11 +588,11 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) | |||
567 | if (ret) | 588 | if (ret) |
568 | goto err; | 589 | goto err; |
569 | 590 | ||
570 | ret = regmap_update_bits(dev->regmap, 0x4d, 0x02, dev->cfg->spec_inv << 1); | 591 | ret = m88ds3103_update_bits(dev, 0x4d, 0x02, dev->cfg->spec_inv << 1); |
571 | if (ret) | 592 | if (ret) |
572 | goto err; | 593 | goto err; |
573 | 594 | ||
574 | ret = regmap_update_bits(dev->regmap, 0x30, 0x10, dev->cfg->agc_inv << 4); | 595 | ret = m88ds3103_update_bits(dev, 0x30, 0x10, dev->cfg->agc_inv << 4); |
575 | if (ret) | 596 | if (ret) |
576 | goto err; | 597 | goto err; |
577 | 598 | ||
@@ -625,13 +646,13 @@ static int m88ds3103_init(struct dvb_frontend *fe) | |||
625 | dev->warm = false; | 646 | dev->warm = false; |
626 | 647 | ||
627 | /* wake up device from sleep */ | 648 | /* wake up device from sleep */ |
628 | ret = regmap_update_bits(dev->regmap, 0x08, 0x01, 0x01); | 649 | ret = m88ds3103_update_bits(dev, 0x08, 0x01, 0x01); |
629 | if (ret) | 650 | if (ret) |
630 | goto err; | 651 | goto err; |
631 | ret = regmap_update_bits(dev->regmap, 0x04, 0x01, 0x00); | 652 | ret = m88ds3103_update_bits(dev, 0x04, 0x01, 0x00); |
632 | if (ret) | 653 | if (ret) |
633 | goto err; | 654 | goto err; |
634 | ret = regmap_update_bits(dev->regmap, 0x23, 0x10, 0x00); | 655 | ret = m88ds3103_update_bits(dev, 0x23, 0x10, 0x00); |
635 | if (ret) | 656 | if (ret) |
636 | goto err; | 657 | goto err; |
637 | 658 | ||
@@ -749,18 +770,18 @@ static int m88ds3103_sleep(struct dvb_frontend *fe) | |||
749 | utmp = 0x29; | 770 | utmp = 0x29; |
750 | else | 771 | else |
751 | utmp = 0x27; | 772 | utmp = 0x27; |
752 | ret = regmap_update_bits(dev->regmap, utmp, 0x01, 0x00); | 773 | ret = m88ds3103_update_bits(dev, utmp, 0x01, 0x00); |
753 | if (ret) | 774 | if (ret) |
754 | goto err; | 775 | goto err; |
755 | 776 | ||
756 | /* sleep */ | 777 | /* sleep */ |
757 | ret = regmap_update_bits(dev->regmap, 0x08, 0x01, 0x00); | 778 | ret = m88ds3103_update_bits(dev, 0x08, 0x01, 0x00); |
758 | if (ret) | 779 | if (ret) |
759 | goto err; | 780 | goto err; |
760 | ret = regmap_update_bits(dev->regmap, 0x04, 0x01, 0x01); | 781 | ret = m88ds3103_update_bits(dev, 0x04, 0x01, 0x01); |
761 | if (ret) | 782 | if (ret) |
762 | goto err; | 783 | goto err; |
763 | ret = regmap_update_bits(dev->regmap, 0x23, 0x10, 0x10); | 784 | ret = m88ds3103_update_bits(dev, 0x23, 0x10, 0x10); |
764 | if (ret) | 785 | if (ret) |
765 | goto err; | 786 | goto err; |
766 | 787 | ||
@@ -992,12 +1013,12 @@ static int m88ds3103_set_tone(struct dvb_frontend *fe, | |||
992 | } | 1013 | } |
993 | 1014 | ||
994 | utmp = tone << 7 | dev->cfg->envelope_mode << 5; | 1015 | utmp = tone << 7 | dev->cfg->envelope_mode << 5; |
995 | ret = regmap_update_bits(dev->regmap, 0xa2, 0xe0, utmp); | 1016 | ret = m88ds3103_update_bits(dev, 0xa2, 0xe0, utmp); |
996 | if (ret) | 1017 | if (ret) |
997 | goto err; | 1018 | goto err; |
998 | 1019 | ||
999 | utmp = 1 << 2; | 1020 | utmp = 1 << 2; |
1000 | ret = regmap_update_bits(dev->regmap, 0xa1, reg_a1_mask, utmp); | 1021 | ret = m88ds3103_update_bits(dev, 0xa1, reg_a1_mask, utmp); |
1001 | if (ret) | 1022 | if (ret) |
1002 | goto err; | 1023 | goto err; |
1003 | 1024 | ||
@@ -1047,7 +1068,7 @@ static int m88ds3103_set_voltage(struct dvb_frontend *fe, | |||
1047 | voltage_dis ^= dev->cfg->lnb_en_pol; | 1068 | voltage_dis ^= dev->cfg->lnb_en_pol; |
1048 | 1069 | ||
1049 | utmp = voltage_dis << 1 | voltage_sel << 0; | 1070 | utmp = voltage_dis << 1 | voltage_sel << 0; |
1050 | ret = regmap_update_bits(dev->regmap, 0xa2, 0x03, utmp); | 1071 | ret = m88ds3103_update_bits(dev, 0xa2, 0x03, utmp); |
1051 | if (ret) | 1072 | if (ret) |
1052 | goto err; | 1073 | goto err; |
1053 | 1074 | ||
@@ -1080,7 +1101,7 @@ static int m88ds3103_diseqc_send_master_cmd(struct dvb_frontend *fe, | |||
1080 | } | 1101 | } |
1081 | 1102 | ||
1082 | utmp = dev->cfg->envelope_mode << 5; | 1103 | utmp = dev->cfg->envelope_mode << 5; |
1083 | ret = regmap_update_bits(dev->regmap, 0xa2, 0xe0, utmp); | 1104 | ret = m88ds3103_update_bits(dev, 0xa2, 0xe0, utmp); |
1084 | if (ret) | 1105 | if (ret) |
1085 | goto err; | 1106 | goto err; |
1086 | 1107 | ||
@@ -1115,12 +1136,12 @@ static int m88ds3103_diseqc_send_master_cmd(struct dvb_frontend *fe, | |||
1115 | } else { | 1136 | } else { |
1116 | dev_dbg(&client->dev, "diseqc tx timeout\n"); | 1137 | dev_dbg(&client->dev, "diseqc tx timeout\n"); |
1117 | 1138 | ||
1118 | ret = regmap_update_bits(dev->regmap, 0xa1, 0xc0, 0x40); | 1139 | ret = m88ds3103_update_bits(dev, 0xa1, 0xc0, 0x40); |
1119 | if (ret) | 1140 | if (ret) |
1120 | goto err; | 1141 | goto err; |
1121 | } | 1142 | } |
1122 | 1143 | ||
1123 | ret = regmap_update_bits(dev->regmap, 0xa2, 0xc0, 0x80); | 1144 | ret = m88ds3103_update_bits(dev, 0xa2, 0xc0, 0x80); |
1124 | if (ret) | 1145 | if (ret) |
1125 | goto err; | 1146 | goto err; |
1126 | 1147 | ||
@@ -1152,7 +1173,7 @@ static int m88ds3103_diseqc_send_burst(struct dvb_frontend *fe, | |||
1152 | } | 1173 | } |
1153 | 1174 | ||
1154 | utmp = dev->cfg->envelope_mode << 5; | 1175 | utmp = dev->cfg->envelope_mode << 5; |
1155 | ret = regmap_update_bits(dev->regmap, 0xa2, 0xe0, utmp); | 1176 | ret = m88ds3103_update_bits(dev, 0xa2, 0xe0, utmp); |
1156 | if (ret) | 1177 | if (ret) |
1157 | goto err; | 1178 | goto err; |
1158 | 1179 | ||
@@ -1194,12 +1215,12 @@ static int m88ds3103_diseqc_send_burst(struct dvb_frontend *fe, | |||
1194 | } else { | 1215 | } else { |
1195 | dev_dbg(&client->dev, "diseqc tx timeout\n"); | 1216 | dev_dbg(&client->dev, "diseqc tx timeout\n"); |
1196 | 1217 | ||
1197 | ret = regmap_update_bits(dev->regmap, 0xa1, 0xc0, 0x40); | 1218 | ret = m88ds3103_update_bits(dev, 0xa1, 0xc0, 0x40); |
1198 | if (ret) | 1219 | if (ret) |
1199 | goto err; | 1220 | goto err; |
1200 | } | 1221 | } |
1201 | 1222 | ||
1202 | ret = regmap_update_bits(dev->regmap, 0xa2, 0xc0, 0x80); | 1223 | ret = m88ds3103_update_bits(dev, 0xa2, 0xc0, 0x80); |
1203 | if (ret) | 1224 | if (ret) |
1204 | goto err; | 1225 | goto err; |
1205 | 1226 | ||
@@ -1435,13 +1456,13 @@ static int m88ds3103_probe(struct i2c_client *client, | |||
1435 | goto err_kfree; | 1456 | goto err_kfree; |
1436 | 1457 | ||
1437 | /* sleep */ | 1458 | /* sleep */ |
1438 | ret = regmap_update_bits(dev->regmap, 0x08, 0x01, 0x00); | 1459 | ret = m88ds3103_update_bits(dev, 0x08, 0x01, 0x00); |
1439 | if (ret) | 1460 | if (ret) |
1440 | goto err_kfree; | 1461 | goto err_kfree; |
1441 | ret = regmap_update_bits(dev->regmap, 0x04, 0x01, 0x01); | 1462 | ret = m88ds3103_update_bits(dev, 0x04, 0x01, 0x01); |
1442 | if (ret) | 1463 | if (ret) |
1443 | goto err_kfree; | 1464 | goto err_kfree; |
1444 | ret = regmap_update_bits(dev->regmap, 0x23, 0x10, 0x10); | 1465 | ret = m88ds3103_update_bits(dev, 0x23, 0x10, 0x10); |
1445 | if (ret) | 1466 | if (ret) |
1446 | goto err_kfree; | 1467 | goto err_kfree; |
1447 | 1468 | ||
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c index 81788c5a44d8..821a8f481507 100644 --- a/drivers/media/dvb-frontends/si2168.c +++ b/drivers/media/dvb-frontends/si2168.c | |||
@@ -502,6 +502,10 @@ static int si2168_init(struct dvb_frontend *fe) | |||
502 | /* firmware is in the new format */ | 502 | /* firmware is in the new format */ |
503 | for (remaining = fw->size; remaining > 0; remaining -= 17) { | 503 | for (remaining = fw->size; remaining > 0; remaining -= 17) { |
504 | len = fw->data[fw->size - remaining]; | 504 | len = fw->data[fw->size - remaining]; |
505 | if (len > SI2168_ARGLEN) { | ||
506 | ret = -EINVAL; | ||
507 | break; | ||
508 | } | ||
505 | memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len); | 509 | memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len); |
506 | cmd.wlen = len; | 510 | cmd.wlen = len; |
507 | cmd.rlen = 1; | 511 | cmd.rlen = 1; |
diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c b/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c index f55b3276f28d..56773f3893d4 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_spi.c | |||
@@ -80,11 +80,9 @@ irqreturn_t netup_spi_interrupt(struct netup_spi *spi) | |||
80 | u16 reg; | 80 | u16 reg; |
81 | unsigned long flags; | 81 | unsigned long flags; |
82 | 82 | ||
83 | if (!spi) { | 83 | if (!spi) |
84 | dev_dbg(&spi->master->dev, | ||
85 | "%s(): SPI not initialized\n", __func__); | ||
86 | return IRQ_NONE; | 84 | return IRQ_NONE; |
87 | } | 85 | |
88 | spin_lock_irqsave(&spi->lock, flags); | 86 | spin_lock_irqsave(&spi->lock, flags); |
89 | reg = readw(&spi->regs->control_stat); | 87 | reg = readw(&spi->regs->control_stat); |
90 | if (!(reg & NETUP_SPI_CTRL_IRQ)) { | 88 | if (!(reg & NETUP_SPI_CTRL_IRQ)) { |
@@ -234,11 +232,9 @@ void netup_spi_release(struct netup_unidvb_dev *ndev) | |||
234 | unsigned long flags; | 232 | unsigned long flags; |
235 | struct netup_spi *spi = ndev->spi; | 233 | struct netup_spi *spi = ndev->spi; |
236 | 234 | ||
237 | if (!spi) { | 235 | if (!spi) |
238 | dev_dbg(&spi->master->dev, | ||
239 | "%s(): SPI not initialized\n", __func__); | ||
240 | return; | 236 | return; |
241 | } | 237 | |
242 | spin_lock_irqsave(&spi->lock, flags); | 238 | spin_lock_irqsave(&spi->lock, flags); |
243 | reg = readw(&spi->regs->control_stat); | 239 | reg = readw(&spi->regs->control_stat); |
244 | writew(reg | NETUP_SPI_CTRL_IRQ, &spi->regs->control_stat); | 240 | writew(reg | NETUP_SPI_CTRL_IRQ, &spi->regs->control_stat); |
diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c index 486aef50d99b..f922f2e827bc 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | |||
@@ -1097,7 +1097,7 @@ static int load_slim_core_fw(const struct firmware *fw, void *context) | |||
1097 | Elf32_Ehdr *ehdr; | 1097 | Elf32_Ehdr *ehdr; |
1098 | Elf32_Phdr *phdr; | 1098 | Elf32_Phdr *phdr; |
1099 | u8 __iomem *dst; | 1099 | u8 __iomem *dst; |
1100 | int err, i; | 1100 | int err = 0, i; |
1101 | 1101 | ||
1102 | if (!fw || !context) | 1102 | if (!fw || !context) |
1103 | return -EINVAL; | 1103 | return -EINVAL; |
@@ -1106,7 +1106,7 @@ static int load_slim_core_fw(const struct firmware *fw, void *context) | |||
1106 | phdr = (Elf32_Phdr *)(fw->data + ehdr->e_phoff); | 1106 | phdr = (Elf32_Phdr *)(fw->data + ehdr->e_phoff); |
1107 | 1107 | ||
1108 | /* go through the available ELF segments */ | 1108 | /* go through the available ELF segments */ |
1109 | for (i = 0; i < ehdr->e_phnum && !err; i++, phdr++) { | 1109 | for (i = 0; i < ehdr->e_phnum; i++, phdr++) { |
1110 | 1110 | ||
1111 | /* Only consider LOAD segments */ | 1111 | /* Only consider LOAD segments */ |
1112 | if (phdr->p_type != PT_LOAD) | 1112 | if (phdr->p_type != PT_LOAD) |
@@ -1192,7 +1192,6 @@ err: | |||
1192 | 1192 | ||
1193 | static int load_c8sectpfe_fw_step1(struct c8sectpfei *fei) | 1193 | static int load_c8sectpfe_fw_step1(struct c8sectpfei *fei) |
1194 | { | 1194 | { |
1195 | int ret; | ||
1196 | int err; | 1195 | int err; |
1197 | 1196 | ||
1198 | dev_info(fei->dev, "Loading firmware: %s\n", FIRMWARE_MEMDMA); | 1197 | dev_info(fei->dev, "Loading firmware: %s\n", FIRMWARE_MEMDMA); |
@@ -1207,7 +1206,7 @@ static int load_c8sectpfe_fw_step1(struct c8sectpfei *fei) | |||
1207 | if (err) { | 1206 | if (err) { |
1208 | dev_err(fei->dev, "request_firmware_nowait err: %d.\n", err); | 1207 | dev_err(fei->dev, "request_firmware_nowait err: %d.\n", err); |
1209 | complete_all(&fei->fw_ack); | 1208 | complete_all(&fei->fw_ack); |
1210 | return ret; | 1209 | return err; |
1211 | } | 1210 | } |
1212 | 1211 | ||
1213 | return 0; | 1212 | return 0; |
diff --git a/drivers/media/rc/ir-hix5hd2.c b/drivers/media/rc/ir-hix5hd2.c index 1c087cb76815..d0549fba711c 100644 --- a/drivers/media/rc/ir-hix5hd2.c +++ b/drivers/media/rc/ir-hix5hd2.c | |||
@@ -257,7 +257,7 @@ static int hix5hd2_ir_probe(struct platform_device *pdev) | |||
257 | goto clkerr; | 257 | goto clkerr; |
258 | 258 | ||
259 | if (devm_request_irq(dev, priv->irq, hix5hd2_ir_rx_interrupt, | 259 | if (devm_request_irq(dev, priv->irq, hix5hd2_ir_rx_interrupt, |
260 | IRQF_NO_SUSPEND, pdev->name, priv) < 0) { | 260 | 0, pdev->name, priv) < 0) { |
261 | dev_err(dev, "IRQ %d register failed\n", priv->irq); | 261 | dev_err(dev, "IRQ %d register failed\n", priv->irq); |
262 | ret = -EINVAL; | 262 | ret = -EINVAL; |
263 | goto regerr; | 263 | goto regerr; |
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index 507382160e5e..ce157edd45fa 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c | |||
@@ -166,6 +166,10 @@ static int si2157_init(struct dvb_frontend *fe) | |||
166 | 166 | ||
167 | for (remaining = fw->size; remaining > 0; remaining -= 17) { | 167 | for (remaining = fw->size; remaining > 0; remaining -= 17) { |
168 | len = fw->data[fw->size - remaining]; | 168 | len = fw->data[fw->size - remaining]; |
169 | if (len > SI2157_ARGLEN) { | ||
170 | dev_err(&client->dev, "Bad firmware length\n"); | ||
171 | goto err_release_firmware; | ||
172 | } | ||
169 | memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len); | 173 | memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len); |
170 | cmd.wlen = len; | 174 | cmd.wlen = len; |
171 | cmd.rlen = 1; | 175 | cmd.rlen = 1; |
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index c3cac4c12fb3..197a4f2e54d2 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c | |||
@@ -34,6 +34,14 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) | |||
34 | unsigned int pipe; | 34 | unsigned int pipe; |
35 | u8 requesttype; | 35 | u8 requesttype; |
36 | 36 | ||
37 | mutex_lock(&d->usb_mutex); | ||
38 | |||
39 | if (req->size > sizeof(dev->buf)) { | ||
40 | dev_err(&d->intf->dev, "too large message %u\n", req->size); | ||
41 | ret = -EINVAL; | ||
42 | goto err_mutex_unlock; | ||
43 | } | ||
44 | |||
37 | if (req->index & CMD_WR_FLAG) { | 45 | if (req->index & CMD_WR_FLAG) { |
38 | /* write */ | 46 | /* write */ |
39 | memcpy(dev->buf, req->data, req->size); | 47 | memcpy(dev->buf, req->data, req->size); |
@@ -50,14 +58,17 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) | |||
50 | dvb_usb_dbg_usb_control_msg(d->udev, 0, requesttype, req->value, | 58 | dvb_usb_dbg_usb_control_msg(d->udev, 0, requesttype, req->value, |
51 | req->index, dev->buf, req->size); | 59 | req->index, dev->buf, req->size); |
52 | if (ret < 0) | 60 | if (ret < 0) |
53 | goto err; | 61 | goto err_mutex_unlock; |
54 | 62 | ||
55 | /* read request, copy returned data to return buf */ | 63 | /* read request, copy returned data to return buf */ |
56 | if (requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) | 64 | if (requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) |
57 | memcpy(req->data, dev->buf, req->size); | 65 | memcpy(req->data, dev->buf, req->size); |
58 | 66 | ||
67 | mutex_unlock(&d->usb_mutex); | ||
68 | |||
59 | return 0; | 69 | return 0; |
60 | err: | 70 | err_mutex_unlock: |
71 | mutex_unlock(&d->usb_mutex); | ||
61 | dev_dbg(&d->intf->dev, "failed=%d\n", ret); | 72 | dev_dbg(&d->intf->dev, "failed=%d\n", ret); |
62 | return ret; | 73 | return ret; |
63 | } | 74 | } |
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h index 9f6115a2ee01..138062960a73 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h | |||
@@ -71,7 +71,7 @@ | |||
71 | 71 | ||
72 | 72 | ||
73 | struct rtl28xxu_dev { | 73 | struct rtl28xxu_dev { |
74 | u8 buf[28]; | 74 | u8 buf[128]; |
75 | u8 chip_id; | 75 | u8 chip_id; |
76 | u8 tuner; | 76 | u8 tuner; |
77 | char *tuner_name; | 77 | char *tuner_name; |
diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig index 82876a67f144..9beece00869b 100644 --- a/drivers/media/v4l2-core/Kconfig +++ b/drivers/media/v4l2-core/Kconfig | |||
@@ -47,7 +47,7 @@ config V4L2_MEM2MEM_DEV | |||
47 | # Used by LED subsystem flash drivers | 47 | # Used by LED subsystem flash drivers |
48 | config V4L2_FLASH_LED_CLASS | 48 | config V4L2_FLASH_LED_CLASS |
49 | tristate "V4L2 flash API for LED flash class devices" | 49 | tristate "V4L2 flash API for LED flash class devices" |
50 | depends on VIDEO_V4L2_SUBDEV_API | 50 | depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API |
51 | depends on LEDS_CLASS_FLASH | 51 | depends on LEDS_CLASS_FLASH |
52 | ---help--- | 52 | ---help--- |
53 | Say Y here to enable V4L2 flash API support for LED flash | 53 | Say Y here to enable V4L2 flash API support for LED flash |
diff --git a/drivers/memory/Kconfig b/drivers/memory/Kconfig index c6a644b22af4..6f3154613dc7 100644 --- a/drivers/memory/Kconfig +++ b/drivers/memory/Kconfig | |||
@@ -58,12 +58,18 @@ config OMAP_GPMC | |||
58 | memory drives like NOR, NAND, OneNAND, SRAM. | 58 | memory drives like NOR, NAND, OneNAND, SRAM. |
59 | 59 | ||
60 | config OMAP_GPMC_DEBUG | 60 | config OMAP_GPMC_DEBUG |
61 | bool | 61 | bool "Enable GPMC debug output and skip reset of GPMC during init" |
62 | depends on OMAP_GPMC | 62 | depends on OMAP_GPMC |
63 | help | 63 | help |
64 | Enables verbose debugging mostly to decode the bootloader provided | 64 | Enables verbose debugging mostly to decode the bootloader provided |
65 | timings. Enable this during development to configure devices | 65 | timings. To preserve the bootloader provided timings, the reset |
66 | connected to the GPMC bus. | 66 | of GPMC is skipped during init. Enable this during development to |
67 | configure devices connected to the GPMC bus. | ||
68 | |||
69 | NOTE: In addition to matching the register setup with the bootloader | ||
70 | you also need to match the GPMC FCLK frequency used by the | ||
71 | bootloader or else the GPMC timings won't be identical with the | ||
72 | bootloader timings. | ||
67 | 73 | ||
68 | config MVEBU_DEVBUS | 74 | config MVEBU_DEVBUS |
69 | bool "Marvell EBU Device Bus Controller" | 75 | bool "Marvell EBU Device Bus Controller" |
diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c index 32ac049f2bc4..6515dfc2b805 100644 --- a/drivers/memory/omap-gpmc.c +++ b/drivers/memory/omap-gpmc.c | |||
@@ -696,7 +696,6 @@ int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t, | |||
696 | int div; | 696 | int div; |
697 | u32 l; | 697 | u32 l; |
698 | 698 | ||
699 | gpmc_cs_show_timings(cs, "before gpmc_cs_set_timings"); | ||
700 | div = gpmc_calc_divider(t->sync_clk); | 699 | div = gpmc_calc_divider(t->sync_clk); |
701 | if (div < 0) | 700 | if (div < 0) |
702 | return div; | 701 | return div; |
@@ -1988,6 +1987,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev, | |||
1988 | if (ret < 0) | 1987 | if (ret < 0) |
1989 | goto err; | 1988 | goto err; |
1990 | 1989 | ||
1990 | gpmc_cs_show_timings(cs, "before gpmc_cs_program_settings"); | ||
1991 | ret = gpmc_cs_program_settings(cs, &gpmc_s); | 1991 | ret = gpmc_cs_program_settings(cs, &gpmc_s); |
1992 | if (ret < 0) | 1992 | if (ret < 0) |
1993 | goto err; | 1993 | goto err; |
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index b78cf5d403a3..7fc9174d4619 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c | |||
@@ -2263,15 +2263,12 @@ static int mmc_test_profile_sglen_r_nonblock_perf(struct mmc_test_card *test) | |||
2263 | /* | 2263 | /* |
2264 | * eMMC hardware reset. | 2264 | * eMMC hardware reset. |
2265 | */ | 2265 | */ |
2266 | static int mmc_test_hw_reset(struct mmc_test_card *test) | 2266 | static int mmc_test_reset(struct mmc_test_card *test) |
2267 | { | 2267 | { |
2268 | struct mmc_card *card = test->card; | 2268 | struct mmc_card *card = test->card; |
2269 | struct mmc_host *host = card->host; | 2269 | struct mmc_host *host = card->host; |
2270 | int err; | 2270 | int err; |
2271 | 2271 | ||
2272 | if (!mmc_card_mmc(card) || !mmc_can_reset(card)) | ||
2273 | return RESULT_UNSUP_CARD; | ||
2274 | |||
2275 | err = mmc_hw_reset(host); | 2272 | err = mmc_hw_reset(host); |
2276 | if (!err) | 2273 | if (!err) |
2277 | return RESULT_OK; | 2274 | return RESULT_OK; |
@@ -2605,8 +2602,8 @@ static const struct mmc_test_case mmc_test_cases[] = { | |||
2605 | }, | 2602 | }, |
2606 | 2603 | ||
2607 | { | 2604 | { |
2608 | .name = "eMMC hardware reset", | 2605 | .name = "Reset test", |
2609 | .run = mmc_test_hw_reset, | 2606 | .run = mmc_test_reset, |
2610 | }, | 2607 | }, |
2611 | }; | 2608 | }; |
2612 | 2609 | ||
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index e726903170a8..f6cd995dbe92 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -1924,7 +1924,6 @@ EXPORT_SYMBOL(mmc_can_reset); | |||
1924 | static int mmc_reset(struct mmc_host *host) | 1924 | static int mmc_reset(struct mmc_host *host) |
1925 | { | 1925 | { |
1926 | struct mmc_card *card = host->card; | 1926 | struct mmc_card *card = host->card; |
1927 | u32 status; | ||
1928 | 1927 | ||
1929 | if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset) | 1928 | if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset) |
1930 | return -EOPNOTSUPP; | 1929 | return -EOPNOTSUPP; |
@@ -1937,12 +1936,6 @@ static int mmc_reset(struct mmc_host *host) | |||
1937 | 1936 | ||
1938 | host->ops->hw_reset(host); | 1937 | host->ops->hw_reset(host); |
1939 | 1938 | ||
1940 | /* If the reset has happened, then a status command will fail */ | ||
1941 | if (!mmc_send_status(card, &status)) { | ||
1942 | mmc_host_clk_release(host); | ||
1943 | return -ENOSYS; | ||
1944 | } | ||
1945 | |||
1946 | /* Set initial state and call mmc_set_ios */ | 1939 | /* Set initial state and call mmc_set_ios */ |
1947 | mmc_set_initial_state(host); | 1940 | mmc_set_initial_state(host); |
1948 | mmc_host_clk_release(host); | 1941 | mmc_host_clk_release(host); |
diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c index e5fac368068a..131026fbc2d7 100644 --- a/drivers/net/can/sja1000/peak_pci.c +++ b/drivers/net/can/sja1000/peak_pci.c | |||
@@ -87,6 +87,7 @@ static const struct pci_device_id peak_pci_tbl[] = { | |||
87 | {PEAK_PCI_VENDOR_ID, PEAK_PC_104P_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, | 87 | {PEAK_PCI_VENDOR_ID, PEAK_PC_104P_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, |
88 | {PEAK_PCI_VENDOR_ID, PEAK_PCI_104E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, | 88 | {PEAK_PCI_VENDOR_ID, PEAK_PCI_104E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, |
89 | {PEAK_PCI_VENDOR_ID, PEAK_CPCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, | 89 | {PEAK_PCI_VENDOR_ID, PEAK_CPCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, |
90 | {PEAK_PCI_VENDOR_ID, PEAK_PCIE_OEM_ID, PCI_ANY_ID, PCI_ANY_ID,}, | ||
90 | #ifdef CONFIG_CAN_PEAK_PCIEC | 91 | #ifdef CONFIG_CAN_PEAK_PCIEC |
91 | {PEAK_PCI_VENDOR_ID, PEAK_PCIEC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, | 92 | {PEAK_PCI_VENDOR_ID, PEAK_PCIEC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, |
92 | {PEAK_PCI_VENDOR_ID, PEAK_PCIEC34_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, | 93 | {PEAK_PCI_VENDOR_ID, PEAK_PCIEC34_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, |
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c b/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c index 2c063b60db4b..96f485ab612e 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c | |||
@@ -327,9 +327,13 @@ void xgbe_debugfs_init(struct xgbe_prv_data *pdata) | |||
327 | pdata->debugfs_xpcs_reg = 0; | 327 | pdata->debugfs_xpcs_reg = 0; |
328 | 328 | ||
329 | buf = kasprintf(GFP_KERNEL, "amd-xgbe-%s", pdata->netdev->name); | 329 | buf = kasprintf(GFP_KERNEL, "amd-xgbe-%s", pdata->netdev->name); |
330 | if (!buf) | ||
331 | return; | ||
332 | |||
330 | pdata->xgbe_debugfs = debugfs_create_dir(buf, NULL); | 333 | pdata->xgbe_debugfs = debugfs_create_dir(buf, NULL); |
331 | if (!pdata->xgbe_debugfs) { | 334 | if (!pdata->xgbe_debugfs) { |
332 | netdev_err(pdata->netdev, "debugfs_create_dir failed\n"); | 335 | netdev_err(pdata->netdev, "debugfs_create_dir failed\n"); |
336 | kfree(buf); | ||
333 | return; | 337 | return; |
334 | } | 338 | } |
335 | 339 | ||
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index aeb7ce64452e..be628bd9fb18 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | |||
@@ -3351,6 +3351,13 @@ static int bnx2x_set_rss_flags(struct bnx2x *bp, struct ethtool_rxnfc *info) | |||
3351 | udp_rss_requested = 0; | 3351 | udp_rss_requested = 0; |
3352 | else | 3352 | else |
3353 | return -EINVAL; | 3353 | return -EINVAL; |
3354 | |||
3355 | if (CHIP_IS_E1x(bp) && udp_rss_requested) { | ||
3356 | DP(BNX2X_MSG_ETHTOOL, | ||
3357 | "57710, 57711 boards don't support RSS according to UDP 4-tuple\n"); | ||
3358 | return -EINVAL; | ||
3359 | } | ||
3360 | |||
3354 | if ((info->flow_type == UDP_V4_FLOW) && | 3361 | if ((info->flow_type == UDP_V4_FLOW) && |
3355 | (bp->rss_conf_obj.udp_rss_v4 != udp_rss_requested)) { | 3362 | (bp->rss_conf_obj.udp_rss_v4 != udp_rss_requested)) { |
3356 | bp->rss_conf_obj.udp_rss_v4 = udp_rss_requested; | 3363 | bp->rss_conf_obj.udp_rss_v4 = udp_rss_requested; |
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 3bc701e4c59e..1805541b4240 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c | |||
@@ -1683,6 +1683,24 @@ static void bcmgenet_intr_disable(struct bcmgenet_priv *priv) | |||
1683 | bcmgenet_intrl2_1_writel(priv, 0, INTRL2_CPU_MASK_CLEAR); | 1683 | bcmgenet_intrl2_1_writel(priv, 0, INTRL2_CPU_MASK_CLEAR); |
1684 | } | 1684 | } |
1685 | 1685 | ||
1686 | static void bcmgenet_link_intr_enable(struct bcmgenet_priv *priv) | ||
1687 | { | ||
1688 | u32 int0_enable = 0; | ||
1689 | |||
1690 | /* Monitor cable plug/unplugged event for internal PHY, external PHY | ||
1691 | * and MoCA PHY | ||
1692 | */ | ||
1693 | if (priv->internal_phy) { | ||
1694 | int0_enable |= UMAC_IRQ_LINK_EVENT; | ||
1695 | } else if (priv->ext_phy) { | ||
1696 | int0_enable |= UMAC_IRQ_LINK_EVENT; | ||
1697 | } else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) { | ||
1698 | if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET) | ||
1699 | int0_enable |= UMAC_IRQ_LINK_EVENT; | ||
1700 | } | ||
1701 | bcmgenet_intrl2_0_writel(priv, int0_enable, INTRL2_CPU_MASK_CLEAR); | ||
1702 | } | ||
1703 | |||
1686 | static int init_umac(struct bcmgenet_priv *priv) | 1704 | static int init_umac(struct bcmgenet_priv *priv) |
1687 | { | 1705 | { |
1688 | struct device *kdev = &priv->pdev->dev; | 1706 | struct device *kdev = &priv->pdev->dev; |
@@ -1723,15 +1741,8 @@ static int init_umac(struct bcmgenet_priv *priv) | |||
1723 | /* Enable Tx default queue 16 interrupts */ | 1741 | /* Enable Tx default queue 16 interrupts */ |
1724 | int0_enable |= UMAC_IRQ_TXDMA_DONE; | 1742 | int0_enable |= UMAC_IRQ_TXDMA_DONE; |
1725 | 1743 | ||
1726 | /* Monitor cable plug/unplugged event for internal PHY */ | 1744 | /* Configure backpressure vectors for MoCA */ |
1727 | if (priv->internal_phy) { | 1745 | if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) { |
1728 | int0_enable |= UMAC_IRQ_LINK_EVENT; | ||
1729 | } else if (priv->ext_phy) { | ||
1730 | int0_enable |= UMAC_IRQ_LINK_EVENT; | ||
1731 | } else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) { | ||
1732 | if (priv->hw_params->flags & GENET_HAS_MOCA_LINK_DET) | ||
1733 | int0_enable |= UMAC_IRQ_LINK_EVENT; | ||
1734 | |||
1735 | reg = bcmgenet_bp_mc_get(priv); | 1746 | reg = bcmgenet_bp_mc_get(priv); |
1736 | reg |= BIT(priv->hw_params->bp_in_en_shift); | 1747 | reg |= BIT(priv->hw_params->bp_in_en_shift); |
1737 | 1748 | ||
@@ -2645,6 +2656,9 @@ static void bcmgenet_netif_start(struct net_device *dev) | |||
2645 | 2656 | ||
2646 | netif_tx_start_all_queues(dev); | 2657 | netif_tx_start_all_queues(dev); |
2647 | 2658 | ||
2659 | /* Monitor link interrupts now */ | ||
2660 | bcmgenet_link_intr_enable(priv); | ||
2661 | |||
2648 | phy_start(priv->phydev); | 2662 | phy_start(priv->phydev); |
2649 | } | 2663 | } |
2650 | 2664 | ||
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 821540913343..d463563e1f70 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h | |||
@@ -592,6 +592,7 @@ struct be_adapter { | |||
592 | int be_get_temp_freq; | 592 | int be_get_temp_freq; |
593 | struct be_hwmon hwmon_info; | 593 | struct be_hwmon hwmon_info; |
594 | u8 pf_number; | 594 | u8 pf_number; |
595 | u8 pci_func_num; | ||
595 | struct rss_info rss_info; | 596 | struct rss_info rss_info; |
596 | /* Filters for packets that need to be sent to BMC */ | 597 | /* Filters for packets that need to be sent to BMC */ |
597 | u32 bmc_filt_mask; | 598 | u32 bmc_filt_mask; |
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index eb323913cd39..1795c935ff02 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c | |||
@@ -851,8 +851,10 @@ static int be_cmd_notify_wait(struct be_adapter *adapter, | |||
851 | return status; | 851 | return status; |
852 | 852 | ||
853 | dest_wrb = be_cmd_copy(adapter, wrb); | 853 | dest_wrb = be_cmd_copy(adapter, wrb); |
854 | if (!dest_wrb) | 854 | if (!dest_wrb) { |
855 | return -EBUSY; | 855 | status = -EBUSY; |
856 | goto unlock; | ||
857 | } | ||
856 | 858 | ||
857 | if (use_mcc(adapter)) | 859 | if (use_mcc(adapter)) |
858 | status = be_mcc_notify_wait(adapter); | 860 | status = be_mcc_notify_wait(adapter); |
@@ -862,6 +864,7 @@ static int be_cmd_notify_wait(struct be_adapter *adapter, | |||
862 | if (!status) | 864 | if (!status) |
863 | memcpy(wrb, dest_wrb, sizeof(*wrb)); | 865 | memcpy(wrb, dest_wrb, sizeof(*wrb)); |
864 | 866 | ||
867 | unlock: | ||
865 | be_cmd_unlock(adapter); | 868 | be_cmd_unlock(adapter); |
866 | return status; | 869 | return status; |
867 | } | 870 | } |
@@ -1984,6 +1987,8 @@ int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value) | |||
1984 | be_if_cap_flags(adapter)); | 1987 | be_if_cap_flags(adapter)); |
1985 | } | 1988 | } |
1986 | flags &= be_if_cap_flags(adapter); | 1989 | flags &= be_if_cap_flags(adapter); |
1990 | if (!flags) | ||
1991 | return -ENOTSUPP; | ||
1987 | 1992 | ||
1988 | return __be_cmd_rx_filter(adapter, flags, value); | 1993 | return __be_cmd_rx_filter(adapter, flags, value); |
1989 | } | 1994 | } |
@@ -2887,6 +2892,7 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter) | |||
2887 | if (!status) { | 2892 | if (!status) { |
2888 | attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr); | 2893 | attribs = attribs_cmd.va + sizeof(struct be_cmd_resp_hdr); |
2889 | adapter->hba_port_num = attribs->hba_attribs.phy_port; | 2894 | adapter->hba_port_num = attribs->hba_attribs.phy_port; |
2895 | adapter->pci_func_num = attribs->pci_func_num; | ||
2890 | serial_num = attribs->hba_attribs.controller_serial_number; | 2896 | serial_num = attribs->hba_attribs.controller_serial_number; |
2891 | for (i = 0; i < CNTL_SERIAL_NUM_WORDS; i++) | 2897 | for (i = 0; i < CNTL_SERIAL_NUM_WORDS; i++) |
2892 | adapter->serial_num[i] = le32_to_cpu(serial_num[i]) & | 2898 | adapter->serial_num[i] = le32_to_cpu(serial_num[i]) & |
@@ -3709,7 +3715,6 @@ int be_cmd_get_func_config(struct be_adapter *adapter, struct be_resources *res) | |||
3709 | status = -EINVAL; | 3715 | status = -EINVAL; |
3710 | goto err; | 3716 | goto err; |
3711 | } | 3717 | } |
3712 | |||
3713 | adapter->pf_number = desc->pf_num; | 3718 | adapter->pf_number = desc->pf_num; |
3714 | be_copy_nic_desc(res, desc); | 3719 | be_copy_nic_desc(res, desc); |
3715 | } | 3720 | } |
@@ -3721,7 +3726,10 @@ err: | |||
3721 | return status; | 3726 | return status; |
3722 | } | 3727 | } |
3723 | 3728 | ||
3724 | /* Will use MBOX only if MCCQ has not been created */ | 3729 | /* Will use MBOX only if MCCQ has not been created |
3730 | * non-zero domain => a PF is querying this on behalf of a VF | ||
3731 | * zero domain => a PF or a VF is querying this for itself | ||
3732 | */ | ||
3725 | int be_cmd_get_profile_config(struct be_adapter *adapter, | 3733 | int be_cmd_get_profile_config(struct be_adapter *adapter, |
3726 | struct be_resources *res, u8 query, u8 domain) | 3734 | struct be_resources *res, u8 query, u8 domain) |
3727 | { | 3735 | { |
@@ -3748,10 +3756,15 @@ int be_cmd_get_profile_config(struct be_adapter *adapter, | |||
3748 | OPCODE_COMMON_GET_PROFILE_CONFIG, | 3756 | OPCODE_COMMON_GET_PROFILE_CONFIG, |
3749 | cmd.size, &wrb, &cmd); | 3757 | cmd.size, &wrb, &cmd); |
3750 | 3758 | ||
3751 | req->hdr.domain = domain; | ||
3752 | if (!lancer_chip(adapter)) | 3759 | if (!lancer_chip(adapter)) |
3753 | req->hdr.version = 1; | 3760 | req->hdr.version = 1; |
3754 | req->type = ACTIVE_PROFILE_TYPE; | 3761 | req->type = ACTIVE_PROFILE_TYPE; |
3762 | /* When a function is querying profile information relating to | ||
3763 | * itself hdr.pf_number must be set to it's pci_func_num + 1 | ||
3764 | */ | ||
3765 | req->hdr.domain = domain; | ||
3766 | if (domain == 0) | ||
3767 | req->hdr.pf_num = adapter->pci_func_num + 1; | ||
3755 | 3768 | ||
3756 | /* When QUERY_MODIFIABLE_FIELDS_TYPE bit is set, cmd returns the | 3769 | /* When QUERY_MODIFIABLE_FIELDS_TYPE bit is set, cmd returns the |
3757 | * descriptors with all bits set to "1" for the fields which can be | 3770 | * descriptors with all bits set to "1" for the fields which can be |
@@ -3921,12 +3934,16 @@ static void be_fill_vf_res_template(struct be_adapter *adapter, | |||
3921 | vf_if_cap_flags &= ~(BE_IF_FLAGS_RSS | | 3934 | vf_if_cap_flags &= ~(BE_IF_FLAGS_RSS | |
3922 | BE_IF_FLAGS_DEFQ_RSS); | 3935 | BE_IF_FLAGS_DEFQ_RSS); |
3923 | } | 3936 | } |
3924 | |||
3925 | nic_vft->cap_flags = cpu_to_le32(vf_if_cap_flags); | ||
3926 | } else { | 3937 | } else { |
3927 | num_vf_qs = 1; | 3938 | num_vf_qs = 1; |
3928 | } | 3939 | } |
3929 | 3940 | ||
3941 | if (res_mod.vf_if_cap_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) { | ||
3942 | nic_vft->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT); | ||
3943 | vf_if_cap_flags &= ~BE_IF_FLAGS_VLAN_PROMISCUOUS; | ||
3944 | } | ||
3945 | |||
3946 | nic_vft->cap_flags = cpu_to_le32(vf_if_cap_flags); | ||
3930 | nic_vft->rq_count = cpu_to_le16(num_vf_qs); | 3947 | nic_vft->rq_count = cpu_to_le16(num_vf_qs); |
3931 | nic_vft->txq_count = cpu_to_le16(num_vf_qs); | 3948 | nic_vft->txq_count = cpu_to_le16(num_vf_qs); |
3932 | nic_vft->rssq_count = cpu_to_le16(num_vf_qs); | 3949 | nic_vft->rssq_count = cpu_to_le16(num_vf_qs); |
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h index 7d178bdb112e..91155ea74f34 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.h +++ b/drivers/net/ethernet/emulex/benet/be_cmds.h | |||
@@ -289,7 +289,9 @@ struct be_cmd_req_hdr { | |||
289 | u32 timeout; /* dword 1 */ | 289 | u32 timeout; /* dword 1 */ |
290 | u32 request_length; /* dword 2 */ | 290 | u32 request_length; /* dword 2 */ |
291 | u8 version; /* dword 3 */ | 291 | u8 version; /* dword 3 */ |
292 | u8 rsvd[3]; /* dword 3 */ | 292 | u8 rsvd1; /* dword 3 */ |
293 | u8 pf_num; /* dword 3 */ | ||
294 | u8 rsvd2; /* dword 3 */ | ||
293 | }; | 295 | }; |
294 | 296 | ||
295 | #define RESP_HDR_INFO_OPCODE_SHIFT 0 /* bits 0 - 7 */ | 297 | #define RESP_HDR_INFO_OPCODE_SHIFT 0 /* bits 0 - 7 */ |
@@ -1652,7 +1654,11 @@ struct mgmt_hba_attribs { | |||
1652 | 1654 | ||
1653 | struct mgmt_controller_attrib { | 1655 | struct mgmt_controller_attrib { |
1654 | struct mgmt_hba_attribs hba_attribs; | 1656 | struct mgmt_hba_attribs hba_attribs; |
1655 | u32 rsvd0[10]; | 1657 | u32 rsvd0[2]; |
1658 | u16 rsvd1; | ||
1659 | u8 pci_func_num; | ||
1660 | u8 rsvd2; | ||
1661 | u32 rsvd3[7]; | ||
1656 | } __packed; | 1662 | } __packed; |
1657 | 1663 | ||
1658 | struct be_cmd_req_cntl_attribs { | 1664 | struct be_cmd_req_cntl_attribs { |
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 7bf51a1a0a77..eb48a977f8da 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
@@ -1123,11 +1123,12 @@ static struct sk_buff *be_xmit_workarounds(struct be_adapter *adapter, | |||
1123 | struct sk_buff *skb, | 1123 | struct sk_buff *skb, |
1124 | struct be_wrb_params *wrb_params) | 1124 | struct be_wrb_params *wrb_params) |
1125 | { | 1125 | { |
1126 | /* Lancer, SH-R ASICs have a bug wherein Packets that are 32 bytes or | 1126 | /* Lancer, SH and BE3 in SRIOV mode have a bug wherein |
1127 | * less may cause a transmit stall on that port. So the work-around is | 1127 | * packets that are 32b or less may cause a transmit stall |
1128 | * to pad short packets (<= 32 bytes) to a 36-byte length. | 1128 | * on that port. The workaround is to pad such packets |
1129 | * (len <= 32 bytes) to a minimum length of 36b. | ||
1129 | */ | 1130 | */ |
1130 | if (unlikely(!BEx_chip(adapter) && skb->len <= 32)) { | 1131 | if (skb->len <= 32) { |
1131 | if (skb_put_padto(skb, 36)) | 1132 | if (skb_put_padto(skb, 36)) |
1132 | return NULL; | 1133 | return NULL; |
1133 | } | 1134 | } |
@@ -4205,10 +4206,6 @@ static int be_get_config(struct be_adapter *adapter) | |||
4205 | int status, level; | 4206 | int status, level; |
4206 | u16 profile_id; | 4207 | u16 profile_id; |
4207 | 4208 | ||
4208 | status = be_cmd_get_cntl_attributes(adapter); | ||
4209 | if (status) | ||
4210 | return status; | ||
4211 | |||
4212 | status = be_cmd_query_fw_cfg(adapter); | 4209 | status = be_cmd_query_fw_cfg(adapter); |
4213 | if (status) | 4210 | if (status) |
4214 | return status; | 4211 | return status; |
@@ -4407,6 +4404,11 @@ static int be_setup(struct be_adapter *adapter) | |||
4407 | if (!lancer_chip(adapter)) | 4404 | if (!lancer_chip(adapter)) |
4408 | be_cmd_req_native_mode(adapter); | 4405 | be_cmd_req_native_mode(adapter); |
4409 | 4406 | ||
4407 | /* Need to invoke this cmd first to get the PCI Function Number */ | ||
4408 | status = be_cmd_get_cntl_attributes(adapter); | ||
4409 | if (status) | ||
4410 | return status; | ||
4411 | |||
4410 | if (!BE2_chip(adapter) && be_physfn(adapter)) | 4412 | if (!BE2_chip(adapter) && be_physfn(adapter)) |
4411 | be_alloc_sriov_res(adapter); | 4413 | be_alloc_sriov_res(adapter); |
4412 | 4414 | ||
@@ -4999,7 +5001,15 @@ static bool be_check_ufi_compatibility(struct be_adapter *adapter, | |||
4999 | return false; | 5001 | return false; |
5000 | } | 5002 | } |
5001 | 5003 | ||
5002 | return (fhdr->asic_type_rev >= adapter->asic_rev); | 5004 | /* In BE3 FW images the "asic_type_rev" field doesn't track the |
5005 | * asic_rev of the chips it is compatible with. | ||
5006 | * When asic_type_rev is 0 the image is compatible only with | ||
5007 | * pre-BE3-R chips (asic_rev < 0x10) | ||
5008 | */ | ||
5009 | if (BEx_chip(adapter) && fhdr->asic_type_rev == 0) | ||
5010 | return adapter->asic_rev < 0x10; | ||
5011 | else | ||
5012 | return (fhdr->asic_type_rev >= adapter->asic_rev); | ||
5003 | } | 5013 | } |
5004 | 5014 | ||
5005 | static int be_fw_download(struct be_adapter *adapter, const struct firmware* fw) | 5015 | static int be_fw_download(struct be_adapter *adapter, const struct firmware* fw) |
diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c index 3c40f6b99224..55c36230e176 100644 --- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c +++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c | |||
@@ -198,11 +198,13 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus) | |||
198 | 198 | ||
199 | #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) | 199 | #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) |
200 | /* | 200 | /* |
201 | * Return the TBIPA address, starting from the address | ||
202 | * of the mapped GFAR MDIO registers (struct gfar) | ||
201 | * This is mildly evil, but so is our hardware for doing this. | 203 | * This is mildly evil, but so is our hardware for doing this. |
202 | * Also, we have to cast back to struct gfar because of | 204 | * Also, we have to cast back to struct gfar because of |
203 | * definition weirdness done in gianfar.h. | 205 | * definition weirdness done in gianfar.h. |
204 | */ | 206 | */ |
205 | static uint32_t __iomem *get_gfar_tbipa(void __iomem *p) | 207 | static uint32_t __iomem *get_gfar_tbipa_from_mdio(void __iomem *p) |
206 | { | 208 | { |
207 | struct gfar __iomem *enet_regs = p; | 209 | struct gfar __iomem *enet_regs = p; |
208 | 210 | ||
@@ -210,6 +212,15 @@ static uint32_t __iomem *get_gfar_tbipa(void __iomem *p) | |||
210 | } | 212 | } |
211 | 213 | ||
212 | /* | 214 | /* |
215 | * Return the TBIPA address, starting from the address | ||
216 | * of the mapped GFAR MII registers (gfar_mii_regs[] within struct gfar) | ||
217 | */ | ||
218 | static uint32_t __iomem *get_gfar_tbipa_from_mii(void __iomem *p) | ||
219 | { | ||
220 | return get_gfar_tbipa_from_mdio(container_of(p, struct gfar, gfar_mii_regs)); | ||
221 | } | ||
222 | |||
223 | /* | ||
213 | * Return the TBIPAR address for an eTSEC2 node | 224 | * Return the TBIPAR address for an eTSEC2 node |
214 | */ | 225 | */ |
215 | static uint32_t __iomem *get_etsec_tbipa(void __iomem *p) | 226 | static uint32_t __iomem *get_etsec_tbipa(void __iomem *p) |
@@ -220,11 +231,12 @@ static uint32_t __iomem *get_etsec_tbipa(void __iomem *p) | |||
220 | 231 | ||
221 | #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) | 232 | #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) |
222 | /* | 233 | /* |
223 | * Return the TBIPAR address for a QE MDIO node | 234 | * Return the TBIPAR address for a QE MDIO node, starting from the address |
235 | * of the mapped MII registers (struct fsl_pq_mii) | ||
224 | */ | 236 | */ |
225 | static uint32_t __iomem *get_ucc_tbipa(void __iomem *p) | 237 | static uint32_t __iomem *get_ucc_tbipa(void __iomem *p) |
226 | { | 238 | { |
227 | struct fsl_pq_mdio __iomem *mdio = p; | 239 | struct fsl_pq_mdio __iomem *mdio = container_of(p, struct fsl_pq_mdio, mii); |
228 | 240 | ||
229 | return &mdio->utbipar; | 241 | return &mdio->utbipar; |
230 | } | 242 | } |
@@ -300,14 +312,14 @@ static const struct of_device_id fsl_pq_mdio_match[] = { | |||
300 | .compatible = "fsl,gianfar-tbi", | 312 | .compatible = "fsl,gianfar-tbi", |
301 | .data = &(struct fsl_pq_mdio_data) { | 313 | .data = &(struct fsl_pq_mdio_data) { |
302 | .mii_offset = 0, | 314 | .mii_offset = 0, |
303 | .get_tbipa = get_gfar_tbipa, | 315 | .get_tbipa = get_gfar_tbipa_from_mii, |
304 | }, | 316 | }, |
305 | }, | 317 | }, |
306 | { | 318 | { |
307 | .compatible = "fsl,gianfar-mdio", | 319 | .compatible = "fsl,gianfar-mdio", |
308 | .data = &(struct fsl_pq_mdio_data) { | 320 | .data = &(struct fsl_pq_mdio_data) { |
309 | .mii_offset = 0, | 321 | .mii_offset = 0, |
310 | .get_tbipa = get_gfar_tbipa, | 322 | .get_tbipa = get_gfar_tbipa_from_mii, |
311 | }, | 323 | }, |
312 | }, | 324 | }, |
313 | { | 325 | { |
@@ -315,7 +327,7 @@ static const struct of_device_id fsl_pq_mdio_match[] = { | |||
315 | .compatible = "gianfar", | 327 | .compatible = "gianfar", |
316 | .data = &(struct fsl_pq_mdio_data) { | 328 | .data = &(struct fsl_pq_mdio_data) { |
317 | .mii_offset = offsetof(struct fsl_pq_mdio, mii), | 329 | .mii_offset = offsetof(struct fsl_pq_mdio, mii), |
318 | .get_tbipa = get_gfar_tbipa, | 330 | .get_tbipa = get_gfar_tbipa_from_mdio, |
319 | }, | 331 | }, |
320 | }, | 332 | }, |
321 | { | 333 | { |
@@ -445,6 +457,16 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev) | |||
445 | 457 | ||
446 | tbipa = data->get_tbipa(priv->map); | 458 | tbipa = data->get_tbipa(priv->map); |
447 | 459 | ||
460 | /* | ||
461 | * Add consistency check to make sure TBI is contained | ||
462 | * within the mapped range (not because we would get a | ||
463 | * segfault, rather to catch bugs in computing TBI | ||
464 | * address). Print error message but continue anyway. | ||
465 | */ | ||
466 | if ((void *)tbipa > priv->map + resource_size(&res) - 4) | ||
467 | dev_err(&pdev->dev, "invalid register map (should be at least 0x%04x to contain TBI address)\n", | ||
468 | ((void *)tbipa - priv->map) + 4); | ||
469 | |||
448 | iowrite32be(be32_to_cpup(prop), tbipa); | 470 | iowrite32be(be32_to_cpup(prop), tbipa); |
449 | } | 471 | } |
450 | } | 472 | } |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.c b/drivers/net/ethernet/intel/i40e/i40e_adminq.c index 62488a67149d..c0e943aecd13 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_adminq.c +++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.c | |||
@@ -386,7 +386,6 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw) | |||
386 | 386 | ||
387 | hw->aq.asq.next_to_use = 0; | 387 | hw->aq.asq.next_to_use = 0; |
388 | hw->aq.asq.next_to_clean = 0; | 388 | hw->aq.asq.next_to_clean = 0; |
389 | hw->aq.asq.count = hw->aq.num_asq_entries; | ||
390 | 389 | ||
391 | /* allocate the ring memory */ | 390 | /* allocate the ring memory */ |
392 | ret_code = i40e_alloc_adminq_asq_ring(hw); | 391 | ret_code = i40e_alloc_adminq_asq_ring(hw); |
@@ -404,6 +403,7 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw) | |||
404 | goto init_adminq_free_rings; | 403 | goto init_adminq_free_rings; |
405 | 404 | ||
406 | /* success! */ | 405 | /* success! */ |
406 | hw->aq.asq.count = hw->aq.num_asq_entries; | ||
407 | goto init_adminq_exit; | 407 | goto init_adminq_exit; |
408 | 408 | ||
409 | init_adminq_free_rings: | 409 | init_adminq_free_rings: |
@@ -445,7 +445,6 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw) | |||
445 | 445 | ||
446 | hw->aq.arq.next_to_use = 0; | 446 | hw->aq.arq.next_to_use = 0; |
447 | hw->aq.arq.next_to_clean = 0; | 447 | hw->aq.arq.next_to_clean = 0; |
448 | hw->aq.arq.count = hw->aq.num_arq_entries; | ||
449 | 448 | ||
450 | /* allocate the ring memory */ | 449 | /* allocate the ring memory */ |
451 | ret_code = i40e_alloc_adminq_arq_ring(hw); | 450 | ret_code = i40e_alloc_adminq_arq_ring(hw); |
@@ -463,6 +462,7 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw) | |||
463 | goto init_adminq_free_rings; | 462 | goto init_adminq_free_rings; |
464 | 463 | ||
465 | /* success! */ | 464 | /* success! */ |
465 | hw->aq.arq.count = hw->aq.num_arq_entries; | ||
466 | goto init_adminq_exit; | 466 | goto init_adminq_exit; |
467 | 467 | ||
468 | init_adminq_free_rings: | 468 | init_adminq_free_rings: |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 2fdf978ae6a5..dd44fafd8798 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c | |||
@@ -8389,6 +8389,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi) | |||
8389 | 8389 | ||
8390 | netdev->hw_enc_features |= NETIF_F_IP_CSUM | | 8390 | netdev->hw_enc_features |= NETIF_F_IP_CSUM | |
8391 | NETIF_F_GSO_UDP_TUNNEL | | 8391 | NETIF_F_GSO_UDP_TUNNEL | |
8392 | NETIF_F_GSO_GRE | | ||
8392 | NETIF_F_TSO; | 8393 | NETIF_F_TSO; |
8393 | 8394 | ||
8394 | netdev->features = NETIF_F_SG | | 8395 | netdev->features = NETIF_F_SG | |
@@ -8396,6 +8397,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi) | |||
8396 | NETIF_F_SCTP_CSUM | | 8397 | NETIF_F_SCTP_CSUM | |
8397 | NETIF_F_HIGHDMA | | 8398 | NETIF_F_HIGHDMA | |
8398 | NETIF_F_GSO_UDP_TUNNEL | | 8399 | NETIF_F_GSO_UDP_TUNNEL | |
8400 | NETIF_F_GSO_GRE | | ||
8399 | NETIF_F_HW_VLAN_CTAG_TX | | 8401 | NETIF_F_HW_VLAN_CTAG_TX | |
8400 | NETIF_F_HW_VLAN_CTAG_RX | | 8402 | NETIF_F_HW_VLAN_CTAG_RX | |
8401 | NETIF_F_HW_VLAN_CTAG_FILTER | | 8403 | NETIF_F_HW_VLAN_CTAG_FILTER | |
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c index 929d47152bf2..a23ebfd5cd25 100644 --- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.c +++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.c | |||
@@ -373,7 +373,6 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw) | |||
373 | 373 | ||
374 | hw->aq.asq.next_to_use = 0; | 374 | hw->aq.asq.next_to_use = 0; |
375 | hw->aq.asq.next_to_clean = 0; | 375 | hw->aq.asq.next_to_clean = 0; |
376 | hw->aq.asq.count = hw->aq.num_asq_entries; | ||
377 | 376 | ||
378 | /* allocate the ring memory */ | 377 | /* allocate the ring memory */ |
379 | ret_code = i40e_alloc_adminq_asq_ring(hw); | 378 | ret_code = i40e_alloc_adminq_asq_ring(hw); |
@@ -391,6 +390,7 @@ static i40e_status i40e_init_asq(struct i40e_hw *hw) | |||
391 | goto init_adminq_free_rings; | 390 | goto init_adminq_free_rings; |
392 | 391 | ||
393 | /* success! */ | 392 | /* success! */ |
393 | hw->aq.asq.count = hw->aq.num_asq_entries; | ||
394 | goto init_adminq_exit; | 394 | goto init_adminq_exit; |
395 | 395 | ||
396 | init_adminq_free_rings: | 396 | init_adminq_free_rings: |
@@ -432,7 +432,6 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw) | |||
432 | 432 | ||
433 | hw->aq.arq.next_to_use = 0; | 433 | hw->aq.arq.next_to_use = 0; |
434 | hw->aq.arq.next_to_clean = 0; | 434 | hw->aq.arq.next_to_clean = 0; |
435 | hw->aq.arq.count = hw->aq.num_arq_entries; | ||
436 | 435 | ||
437 | /* allocate the ring memory */ | 436 | /* allocate the ring memory */ |
438 | ret_code = i40e_alloc_adminq_arq_ring(hw); | 437 | ret_code = i40e_alloc_adminq_arq_ring(hw); |
@@ -450,6 +449,7 @@ static i40e_status i40e_init_arq(struct i40e_hw *hw) | |||
450 | goto init_adminq_free_rings; | 449 | goto init_adminq_free_rings; |
451 | 450 | ||
452 | /* success! */ | 451 | /* success! */ |
452 | hw->aq.arq.count = hw->aq.num_arq_entries; | ||
453 | goto init_adminq_exit; | 453 | goto init_adminq_exit; |
454 | 454 | ||
455 | init_adminq_free_rings: | 455 | init_adminq_free_rings: |
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c index 8e81e53c370e..c34488479365 100644 --- a/drivers/net/ethernet/mellanox/mlx4/eq.c +++ b/drivers/net/ethernet/mellanox/mlx4/eq.c | |||
@@ -1364,6 +1364,10 @@ int mlx4_test_interrupts(struct mlx4_dev *dev) | |||
1364 | * and performing a NOP command | 1364 | * and performing a NOP command |
1365 | */ | 1365 | */ |
1366 | for(i = 0; !err && (i < dev->caps.num_comp_vectors); ++i) { | 1366 | for(i = 0; !err && (i < dev->caps.num_comp_vectors); ++i) { |
1367 | /* Make sure request_irq was called */ | ||
1368 | if (!priv->eq_table.eq[i].have_irq) | ||
1369 | continue; | ||
1370 | |||
1367 | /* Temporary use polling for command completions */ | 1371 | /* Temporary use polling for command completions */ |
1368 | mlx4_cmd_use_polling(dev); | 1372 | mlx4_cmd_use_polling(dev); |
1369 | 1373 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 006757f80988..cc3a9897574c 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c | |||
@@ -2669,14 +2669,11 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev) | |||
2669 | 2669 | ||
2670 | if (msi_x) { | 2670 | if (msi_x) { |
2671 | int nreq = dev->caps.num_ports * num_online_cpus() + 1; | 2671 | int nreq = dev->caps.num_ports * num_online_cpus() + 1; |
2672 | bool shared_ports = false; | ||
2673 | 2672 | ||
2674 | nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs, | 2673 | nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs, |
2675 | nreq); | 2674 | nreq); |
2676 | if (nreq > MAX_MSIX) { | 2675 | if (nreq > MAX_MSIX) |
2677 | nreq = MAX_MSIX; | 2676 | nreq = MAX_MSIX; |
2678 | shared_ports = true; | ||
2679 | } | ||
2680 | 2677 | ||
2681 | entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); | 2678 | entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); |
2682 | if (!entries) | 2679 | if (!entries) |
@@ -2699,9 +2696,6 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev) | |||
2699 | bitmap_zero(priv->eq_table.eq[MLX4_EQ_ASYNC].actv_ports.ports, | 2696 | bitmap_zero(priv->eq_table.eq[MLX4_EQ_ASYNC].actv_ports.ports, |
2700 | dev->caps.num_ports); | 2697 | dev->caps.num_ports); |
2701 | 2698 | ||
2702 | if (MLX4_IS_LEGACY_EQ_MODE(dev->caps)) | ||
2703 | shared_ports = true; | ||
2704 | |||
2705 | for (i = 0; i < dev->caps.num_comp_vectors + 1; i++) { | 2699 | for (i = 0; i < dev->caps.num_comp_vectors + 1; i++) { |
2706 | if (i == MLX4_EQ_ASYNC) | 2700 | if (i == MLX4_EQ_ASYNC) |
2707 | continue; | 2701 | continue; |
@@ -2709,7 +2703,7 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev) | |||
2709 | priv->eq_table.eq[i].irq = | 2703 | priv->eq_table.eq[i].irq = |
2710 | entries[i + 1 - !!(i > MLX4_EQ_ASYNC)].vector; | 2704 | entries[i + 1 - !!(i > MLX4_EQ_ASYNC)].vector; |
2711 | 2705 | ||
2712 | if (shared_ports) { | 2706 | if (MLX4_IS_LEGACY_EQ_MODE(dev->caps)) { |
2713 | bitmap_fill(priv->eq_table.eq[i].actv_ports.ports, | 2707 | bitmap_fill(priv->eq_table.eq[i].actv_ports.ports, |
2714 | dev->caps.num_ports); | 2708 | dev->caps.num_ports); |
2715 | /* We don't set affinity hint when there | 2709 | /* We don't set affinity hint when there |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c b/drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c index e71563ce05d1..22d603f78273 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_flow_table.c | |||
@@ -598,6 +598,8 @@ void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv) | |||
598 | return; | 598 | return; |
599 | 599 | ||
600 | priv->vlan.filter_disabled = false; | 600 | priv->vlan.filter_disabled = false; |
601 | if (priv->netdev->flags & IFF_PROMISC) | ||
602 | return; | ||
601 | mlx5e_del_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID, 0); | 603 | mlx5e_del_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID, 0); |
602 | } | 604 | } |
603 | 605 | ||
@@ -607,6 +609,8 @@ void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv) | |||
607 | return; | 609 | return; |
608 | 610 | ||
609 | priv->vlan.filter_disabled = true; | 611 | priv->vlan.filter_disabled = true; |
612 | if (priv->netdev->flags & IFF_PROMISC) | ||
613 | return; | ||
610 | mlx5e_add_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID, 0); | 614 | mlx5e_add_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID, 0); |
611 | } | 615 | } |
612 | 616 | ||
@@ -717,8 +721,12 @@ void mlx5e_set_rx_mode_work(struct work_struct *work) | |||
717 | bool enable_broadcast = !ea->broadcast_enabled && broadcast_enabled; | 721 | bool enable_broadcast = !ea->broadcast_enabled && broadcast_enabled; |
718 | bool disable_broadcast = ea->broadcast_enabled && !broadcast_enabled; | 722 | bool disable_broadcast = ea->broadcast_enabled && !broadcast_enabled; |
719 | 723 | ||
720 | if (enable_promisc) | 724 | if (enable_promisc) { |
721 | mlx5e_add_eth_addr_rule(priv, &ea->promisc, MLX5E_PROMISC); | 725 | mlx5e_add_eth_addr_rule(priv, &ea->promisc, MLX5E_PROMISC); |
726 | if (!priv->vlan.filter_disabled) | ||
727 | mlx5e_add_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID, | ||
728 | 0); | ||
729 | } | ||
722 | if (enable_allmulti) | 730 | if (enable_allmulti) |
723 | mlx5e_add_eth_addr_rule(priv, &ea->allmulti, MLX5E_ALLMULTI); | 731 | mlx5e_add_eth_addr_rule(priv, &ea->allmulti, MLX5E_ALLMULTI); |
724 | if (enable_broadcast) | 732 | if (enable_broadcast) |
@@ -730,8 +738,12 @@ void mlx5e_set_rx_mode_work(struct work_struct *work) | |||
730 | mlx5e_del_eth_addr_from_flow_table(priv, &ea->broadcast); | 738 | mlx5e_del_eth_addr_from_flow_table(priv, &ea->broadcast); |
731 | if (disable_allmulti) | 739 | if (disable_allmulti) |
732 | mlx5e_del_eth_addr_from_flow_table(priv, &ea->allmulti); | 740 | mlx5e_del_eth_addr_from_flow_table(priv, &ea->allmulti); |
733 | if (disable_promisc) | 741 | if (disable_promisc) { |
742 | if (!priv->vlan.filter_disabled) | ||
743 | mlx5e_del_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_VID, | ||
744 | 0); | ||
734 | mlx5e_del_eth_addr_from_flow_table(priv, &ea->promisc); | 745 | mlx5e_del_eth_addr_from_flow_table(priv, &ea->promisc); |
746 | } | ||
735 | 747 | ||
736 | ea->promisc_enabled = promisc_enabled; | 748 | ea->promisc_enabled = promisc_enabled; |
737 | ea->allmulti_enabled = allmulti_enabled; | 749 | ea->allmulti_enabled = allmulti_enabled; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c b/drivers/net/ethernet/mellanox/mlx5/core/port.c index 821caaab9bfb..3b9480fa3403 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/port.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c | |||
@@ -311,7 +311,7 @@ static int mlx5_query_port_pvlc(struct mlx5_core_dev *dev, u32 *pvlc, | |||
311 | int err; | 311 | int err; |
312 | 312 | ||
313 | memset(in, 0, sizeof(in)); | 313 | memset(in, 0, sizeof(in)); |
314 | MLX5_SET(ptys_reg, in, local_port, local_port); | 314 | MLX5_SET(pvlc_reg, in, local_port, local_port); |
315 | 315 | ||
316 | err = mlx5_core_access_reg(dev, in, sizeof(in), pvlc, | 316 | err = mlx5_core_access_reg(dev, in, sizeof(in), pvlc, |
317 | pvlc_size, MLX5_REG_PVLC, 0, 0); | 317 | pvlc_size, MLX5_REG_PVLC, 0, 0); |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index dbcaf5df8967..28c19cc1a17c 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c | |||
@@ -374,26 +374,31 @@ static int __mlxsw_emad_transmit(struct mlxsw_core *mlxsw_core, | |||
374 | int err; | 374 | int err; |
375 | int ret; | 375 | int ret; |
376 | 376 | ||
377 | mlxsw_core->emad.trans_active = true; | ||
378 | |||
377 | err = mlxsw_core_skb_transmit(mlxsw_core->driver_priv, skb, tx_info); | 379 | err = mlxsw_core_skb_transmit(mlxsw_core->driver_priv, skb, tx_info); |
378 | if (err) { | 380 | if (err) { |
379 | dev_err(mlxsw_core->bus_info->dev, "Failed to transmit EMAD (tid=%llx)\n", | 381 | dev_err(mlxsw_core->bus_info->dev, "Failed to transmit EMAD (tid=%llx)\n", |
380 | mlxsw_core->emad.tid); | 382 | mlxsw_core->emad.tid); |
381 | dev_kfree_skb(skb); | 383 | dev_kfree_skb(skb); |
382 | return err; | 384 | goto trans_inactive_out; |
383 | } | 385 | } |
384 | 386 | ||
385 | mlxsw_core->emad.trans_active = true; | ||
386 | ret = wait_event_timeout(mlxsw_core->emad.wait, | 387 | ret = wait_event_timeout(mlxsw_core->emad.wait, |
387 | !(mlxsw_core->emad.trans_active), | 388 | !(mlxsw_core->emad.trans_active), |
388 | msecs_to_jiffies(MLXSW_EMAD_TIMEOUT_MS)); | 389 | msecs_to_jiffies(MLXSW_EMAD_TIMEOUT_MS)); |
389 | if (!ret) { | 390 | if (!ret) { |
390 | dev_warn(mlxsw_core->bus_info->dev, "EMAD timed-out (tid=%llx)\n", | 391 | dev_warn(mlxsw_core->bus_info->dev, "EMAD timed-out (tid=%llx)\n", |
391 | mlxsw_core->emad.tid); | 392 | mlxsw_core->emad.tid); |
392 | mlxsw_core->emad.trans_active = false; | 393 | err = -EIO; |
393 | return -EIO; | 394 | goto trans_inactive_out; |
394 | } | 395 | } |
395 | 396 | ||
396 | return 0; | 397 | return 0; |
398 | |||
399 | trans_inactive_out: | ||
400 | mlxsw_core->emad.trans_active = false; | ||
401 | return err; | ||
397 | } | 402 | } |
398 | 403 | ||
399 | static int mlxsw_emad_process_status(struct mlxsw_core *mlxsw_core, | 404 | static int mlxsw_emad_process_status(struct mlxsw_core *mlxsw_core, |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/item.h b/drivers/net/ethernet/mellanox/mlxsw/item.h index ffd55d030ce2..36fb1cec53c9 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/item.h +++ b/drivers/net/ethernet/mellanox/mlxsw/item.h | |||
@@ -187,6 +187,7 @@ __mlxsw_item_bit_array_offset(struct mlxsw_item *item, u16 index, u8 *shift) | |||
187 | { | 187 | { |
188 | u16 max_index, be_index; | 188 | u16 max_index, be_index; |
189 | u16 offset; /* byte offset inside the array */ | 189 | u16 offset; /* byte offset inside the array */ |
190 | u8 in_byte_index; | ||
190 | 191 | ||
191 | BUG_ON(index && !item->element_size); | 192 | BUG_ON(index && !item->element_size); |
192 | if (item->offset % sizeof(u32) != 0 || | 193 | if (item->offset % sizeof(u32) != 0 || |
@@ -199,7 +200,8 @@ __mlxsw_item_bit_array_offset(struct mlxsw_item *item, u16 index, u8 *shift) | |||
199 | max_index = (item->size.bytes << 3) / item->element_size - 1; | 200 | max_index = (item->size.bytes << 3) / item->element_size - 1; |
200 | be_index = max_index - index; | 201 | be_index = max_index - index; |
201 | offset = be_index * item->element_size >> 3; | 202 | offset = be_index * item->element_size >> 3; |
202 | *shift = index % (BITS_PER_BYTE / item->element_size) << 1; | 203 | in_byte_index = index % (BITS_PER_BYTE / item->element_size); |
204 | *shift = in_byte_index * item->element_size; | ||
203 | 205 | ||
204 | return item->offset + offset; | 206 | return item->offset + offset; |
205 | } | 207 | } |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c index 462cea31ecbb..cef866c37648 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c | |||
@@ -1582,11 +1582,11 @@ static int mlxsw_pci_cmd_exec(void *bus_priv, u16 opcode, u8 opcode_mod, | |||
1582 | 1582 | ||
1583 | if (in_mbox) | 1583 | if (in_mbox) |
1584 | memcpy(mlxsw_pci->cmd.in_mbox.buf, in_mbox, in_mbox_size); | 1584 | memcpy(mlxsw_pci->cmd.in_mbox.buf, in_mbox, in_mbox_size); |
1585 | mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_HI, in_mapaddr >> 32); | 1585 | mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_HI, upper_32_bits(in_mapaddr)); |
1586 | mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_LO, in_mapaddr); | 1586 | mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_LO, lower_32_bits(in_mapaddr)); |
1587 | 1587 | ||
1588 | mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_HI, out_mapaddr >> 32); | 1588 | mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_HI, upper_32_bits(out_mapaddr)); |
1589 | mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_LO, out_mapaddr); | 1589 | mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_LO, lower_32_bits(out_mapaddr)); |
1590 | 1590 | ||
1591 | mlxsw_pci_write32(mlxsw_pci, CIR_IN_MODIFIER, in_mod); | 1591 | mlxsw_pci_write32(mlxsw_pci, CIR_IN_MODIFIER, in_mod); |
1592 | mlxsw_pci_write32(mlxsw_pci, CIR_TOKEN, 0); | 1592 | mlxsw_pci_write32(mlxsw_pci, CIR_TOKEN, 0); |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c index 3e52ee93438c..62cbbd1ada8d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c +++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c | |||
@@ -1069,9 +1069,9 @@ static int mlxsw_sx_port_create(struct mlxsw_sx *mlxsw_sx, u8 local_port) | |||
1069 | return 0; | 1069 | return 0; |
1070 | 1070 | ||
1071 | err_register_netdev: | 1071 | err_register_netdev: |
1072 | err_port_admin_status_set: | ||
1073 | err_port_mac_learning_mode_set: | 1072 | err_port_mac_learning_mode_set: |
1074 | err_port_stp_state_set: | 1073 | err_port_stp_state_set: |
1074 | err_port_admin_status_set: | ||
1075 | err_port_mtu_set: | 1075 | err_port_mtu_set: |
1076 | err_port_speed_set: | 1076 | err_port_speed_set: |
1077 | err_port_swid_set: | 1077 | err_port_swid_set: |
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c index 66fd868152e5..b159ef8303cc 100644 --- a/drivers/net/ethernet/nxp/lpc_eth.c +++ b/drivers/net/ethernet/nxp/lpc_eth.c | |||
@@ -476,13 +476,12 @@ static void __lpc_get_mac(struct netdata_local *pldat, u8 *mac) | |||
476 | mac[5] = tmp >> 8; | 476 | mac[5] = tmp >> 8; |
477 | } | 477 | } |
478 | 478 | ||
479 | static void __lpc_eth_clock_enable(struct netdata_local *pldat, | 479 | static void __lpc_eth_clock_enable(struct netdata_local *pldat, bool enable) |
480 | bool enable) | ||
481 | { | 480 | { |
482 | if (enable) | 481 | if (enable) |
483 | clk_enable(pldat->clk); | 482 | clk_prepare_enable(pldat->clk); |
484 | else | 483 | else |
485 | clk_disable(pldat->clk); | 484 | clk_disable_unprepare(pldat->clk); |
486 | } | 485 | } |
487 | 486 | ||
488 | static void __lpc_params_setup(struct netdata_local *pldat) | 487 | static void __lpc_params_setup(struct netdata_local *pldat) |
@@ -1494,7 +1493,7 @@ err_out_free_irq: | |||
1494 | err_out_iounmap: | 1493 | err_out_iounmap: |
1495 | iounmap(pldat->net_base); | 1494 | iounmap(pldat->net_base); |
1496 | err_out_disable_clocks: | 1495 | err_out_disable_clocks: |
1497 | clk_disable(pldat->clk); | 1496 | clk_disable_unprepare(pldat->clk); |
1498 | clk_put(pldat->clk); | 1497 | clk_put(pldat->clk); |
1499 | err_out_free_dev: | 1498 | err_out_free_dev: |
1500 | free_netdev(ndev); | 1499 | free_netdev(ndev); |
@@ -1519,7 +1518,7 @@ static int lpc_eth_drv_remove(struct platform_device *pdev) | |||
1519 | iounmap(pldat->net_base); | 1518 | iounmap(pldat->net_base); |
1520 | mdiobus_unregister(pldat->mii_bus); | 1519 | mdiobus_unregister(pldat->mii_bus); |
1521 | mdiobus_free(pldat->mii_bus); | 1520 | mdiobus_free(pldat->mii_bus); |
1522 | clk_disable(pldat->clk); | 1521 | clk_disable_unprepare(pldat->clk); |
1523 | clk_put(pldat->clk); | 1522 | clk_put(pldat->clk); |
1524 | free_netdev(ndev); | 1523 | free_netdev(ndev); |
1525 | 1524 | ||
@@ -1540,7 +1539,7 @@ static int lpc_eth_drv_suspend(struct platform_device *pdev, | |||
1540 | if (netif_running(ndev)) { | 1539 | if (netif_running(ndev)) { |
1541 | netif_device_detach(ndev); | 1540 | netif_device_detach(ndev); |
1542 | __lpc_eth_shutdown(pldat); | 1541 | __lpc_eth_shutdown(pldat); |
1543 | clk_disable(pldat->clk); | 1542 | clk_disable_unprepare(pldat->clk); |
1544 | 1543 | ||
1545 | /* | 1544 | /* |
1546 | * Reset again now clock is disable to be sure | 1545 | * Reset again now clock is disable to be sure |
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c index a83263743665..2b7550c43f78 100644 --- a/drivers/net/ethernet/via/via-rhine.c +++ b/drivers/net/ethernet/via/via-rhine.c | |||
@@ -2134,10 +2134,11 @@ static int rhine_rx(struct net_device *dev, int limit) | |||
2134 | } | 2134 | } |
2135 | 2135 | ||
2136 | skb_put(skb, pkt_len); | 2136 | skb_put(skb, pkt_len); |
2137 | skb->protocol = eth_type_trans(skb, dev); | ||
2138 | 2137 | ||
2139 | rhine_rx_vlan_tag(skb, desc, data_size); | 2138 | rhine_rx_vlan_tag(skb, desc, data_size); |
2140 | 2139 | ||
2140 | skb->protocol = eth_type_trans(skb, dev); | ||
2141 | |||
2141 | netif_receive_skb(skb); | 2142 | netif_receive_skb(skb); |
2142 | 2143 | ||
2143 | u64_stats_update_begin(&rp->rx_stats.syncp); | 2144 | u64_stats_update_begin(&rp->rx_stats.syncp); |
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 8f5c02eed47d..cde29f8a37bf 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c | |||
@@ -870,14 +870,14 @@ static int geneve_newlink(struct net *net, struct net_device *dev, | |||
870 | __be16 dst_port = htons(GENEVE_UDP_PORT); | 870 | __be16 dst_port = htons(GENEVE_UDP_PORT); |
871 | __u8 ttl = 0, tos = 0; | 871 | __u8 ttl = 0, tos = 0; |
872 | bool metadata = false; | 872 | bool metadata = false; |
873 | __be32 rem_addr; | 873 | __be32 rem_addr = 0; |
874 | __u32 vni; | 874 | __u32 vni = 0; |
875 | 875 | ||
876 | if (!data[IFLA_GENEVE_ID] || !data[IFLA_GENEVE_REMOTE]) | 876 | if (data[IFLA_GENEVE_ID]) |
877 | return -EINVAL; | 877 | vni = nla_get_u32(data[IFLA_GENEVE_ID]); |
878 | 878 | ||
879 | vni = nla_get_u32(data[IFLA_GENEVE_ID]); | 879 | if (data[IFLA_GENEVE_REMOTE]) |
880 | rem_addr = nla_get_in_addr(data[IFLA_GENEVE_REMOTE]); | 880 | rem_addr = nla_get_in_addr(data[IFLA_GENEVE_REMOTE]); |
881 | 881 | ||
882 | if (data[IFLA_GENEVE_TTL]) | 882 | if (data[IFLA_GENEVE_TTL]) |
883 | ttl = nla_get_u8(data[IFLA_GENEVE_TTL]); | 883 | ttl = nla_get_u8(data[IFLA_GENEVE_TTL]); |
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index c5ad98ace5d0..11e3975485c1 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig | |||
@@ -168,8 +168,6 @@ config MDIO_OCTEON | |||
168 | busses. It is required by the Octeon and ThunderX ethernet device | 168 | busses. It is required by the Octeon and ThunderX ethernet device |
169 | drivers. | 169 | drivers. |
170 | 170 | ||
171 | If in doubt, say Y. | ||
172 | |||
173 | config MDIO_SUN4I | 171 | config MDIO_SUN4I |
174 | tristate "Allwinner sun4i MDIO interface support" | 172 | tristate "Allwinner sun4i MDIO interface support" |
175 | depends on ARCH_SUNXI | 173 | depends on ARCH_SUNXI |
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c index 3837ae344f63..2ed75060da50 100644 --- a/drivers/net/ppp/pppoe.c +++ b/drivers/net/ppp/pppoe.c | |||
@@ -313,7 +313,6 @@ static void pppoe_flush_dev(struct net_device *dev) | |||
313 | if (po->pppoe_dev == dev && | 313 | if (po->pppoe_dev == dev && |
314 | sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND | PPPOX_ZOMBIE)) { | 314 | sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND | PPPOX_ZOMBIE)) { |
315 | pppox_unbind_sock(sk); | 315 | pppox_unbind_sock(sk); |
316 | sk->sk_state = PPPOX_ZOMBIE; | ||
317 | sk->sk_state_change(sk); | 316 | sk->sk_state_change(sk); |
318 | po->pppoe_dev = NULL; | 317 | po->pppoe_dev = NULL; |
319 | dev_put(dev); | 318 | dev_put(dev); |
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index fbb9325d1f6e..e66805eeffb4 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig | |||
@@ -164,6 +164,7 @@ config USB_NET_AX8817X | |||
164 | * Aten UC210T | 164 | * Aten UC210T |
165 | * ASIX AX88172 | 165 | * ASIX AX88172 |
166 | * Billionton Systems, USB2AR | 166 | * Billionton Systems, USB2AR |
167 | * Billionton Systems, GUSB2AM-1G-B | ||
167 | * Buffalo LUA-U2-KTX | 168 | * Buffalo LUA-U2-KTX |
168 | * Corega FEther USB2-TX | 169 | * Corega FEther USB2-TX |
169 | * D-Link DUB-E100 | 170 | * D-Link DUB-E100 |
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c index 75d6f26729a3..079069a060a6 100644 --- a/drivers/net/usb/asix_common.c +++ b/drivers/net/usb/asix_common.c | |||
@@ -91,8 +91,10 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb, | |||
91 | } | 91 | } |
92 | rx->ax_skb = netdev_alloc_skb_ip_align(dev->net, | 92 | rx->ax_skb = netdev_alloc_skb_ip_align(dev->net, |
93 | rx->size); | 93 | rx->size); |
94 | if (!rx->ax_skb) | 94 | if (!rx->ax_skb) { |
95 | rx->size = 0; | ||
95 | return 0; | 96 | return 0; |
97 | } | ||
96 | } | 98 | } |
97 | 99 | ||
98 | if (rx->size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) { | 100 | if (rx->size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) { |
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c index 1173a24feda3..5cabefc23494 100644 --- a/drivers/net/usb/asix_devices.c +++ b/drivers/net/usb/asix_devices.c | |||
@@ -959,6 +959,10 @@ static const struct usb_device_id products [] = { | |||
959 | USB_DEVICE (0x08dd, 0x90ff), | 959 | USB_DEVICE (0x08dd, 0x90ff), |
960 | .driver_info = (unsigned long) &ax8817x_info, | 960 | .driver_info = (unsigned long) &ax8817x_info, |
961 | }, { | 961 | }, { |
962 | // Billionton Systems, GUSB2AM-1G-B | ||
963 | USB_DEVICE(0x08dd, 0x0114), | ||
964 | .driver_info = (unsigned long) &ax88178_info, | ||
965 | }, { | ||
962 | // ATEN UC210T | 966 | // ATEN UC210T |
963 | USB_DEVICE (0x0557, 0x2009), | 967 | USB_DEVICE (0x0557, 0x2009), |
964 | .driver_info = (unsigned long) &ax8817x_info, | 968 | .driver_info = (unsigned long) &ax8817x_info, |
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index bbac1d35ed4e..afdc65fd5bc5 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -2745,11 +2745,10 @@ static int vxlan_newlink(struct net *src_net, struct net_device *dev, | |||
2745 | struct vxlan_config conf; | 2745 | struct vxlan_config conf; |
2746 | int err; | 2746 | int err; |
2747 | 2747 | ||
2748 | if (!data[IFLA_VXLAN_ID]) | ||
2749 | return -EINVAL; | ||
2750 | |||
2751 | memset(&conf, 0, sizeof(conf)); | 2748 | memset(&conf, 0, sizeof(conf)); |
2752 | conf.vni = nla_get_u32(data[IFLA_VXLAN_ID]); | 2749 | |
2750 | if (data[IFLA_VXLAN_ID]) | ||
2751 | conf.vni = nla_get_u32(data[IFLA_VXLAN_ID]); | ||
2753 | 2752 | ||
2754 | if (data[IFLA_VXLAN_GROUP]) { | 2753 | if (data[IFLA_VXLAN_GROUP]) { |
2755 | conf.remote_ip.sin.sin_addr.s_addr = nla_get_in_addr(data[IFLA_VXLAN_GROUP]); | 2754 | conf.remote_ip.sin.sin_addr.s_addr = nla_get_in_addr(data[IFLA_VXLAN_GROUP]); |
diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h index 23afcda2de96..678d72af4a9d 100644 --- a/drivers/net/wireless/ath/ath10k/hw.h +++ b/drivers/net/wireless/ath/ath10k/hw.h | |||
@@ -337,7 +337,7 @@ enum ath10k_hw_rate_cck { | |||
337 | #define TARGET_10X_MAX_FRAG_ENTRIES 0 | 337 | #define TARGET_10X_MAX_FRAG_ENTRIES 0 |
338 | 338 | ||
339 | /* 10.2 parameters */ | 339 | /* 10.2 parameters */ |
340 | #define TARGET_10_2_DMA_BURST_SIZE 1 | 340 | #define TARGET_10_2_DMA_BURST_SIZE 0 |
341 | 341 | ||
342 | /* Target specific defines for WMI-TLV firmware */ | 342 | /* Target specific defines for WMI-TLV firmware */ |
343 | #define TARGET_TLV_NUM_VDEVS 4 | 343 | #define TARGET_TLV_NUM_VDEVS 4 |
@@ -391,7 +391,7 @@ enum ath10k_hw_rate_cck { | |||
391 | 391 | ||
392 | #define TARGET_10_4_TX_DBG_LOG_SIZE 1024 | 392 | #define TARGET_10_4_TX_DBG_LOG_SIZE 1024 |
393 | #define TARGET_10_4_NUM_WDS_ENTRIES 32 | 393 | #define TARGET_10_4_NUM_WDS_ENTRIES 32 |
394 | #define TARGET_10_4_DMA_BURST_SIZE 1 | 394 | #define TARGET_10_4_DMA_BURST_SIZE 0 |
395 | #define TARGET_10_4_MAC_AGGR_DELIM 0 | 395 | #define TARGET_10_4_MAC_AGGR_DELIM 0 |
396 | #define TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1 | 396 | #define TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1 |
397 | #define TARGET_10_4_VOW_CONFIG 0 | 397 | #define TARGET_10_4_VOW_CONFIG 0 |
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 57f95f2dca5b..90eb75012e4f 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c | |||
@@ -880,6 +880,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) | |||
880 | hw->max_rate_tries = 10; | 880 | hw->max_rate_tries = 10; |
881 | hw->sta_data_size = sizeof(struct ath_node); | 881 | hw->sta_data_size = sizeof(struct ath_node); |
882 | hw->vif_data_size = sizeof(struct ath_vif); | 882 | hw->vif_data_size = sizeof(struct ath_vif); |
883 | hw->extra_tx_headroom = 4; | ||
883 | 884 | ||
884 | hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1; | 885 | hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1; |
885 | hw->wiphy->available_antennas_tx = BIT(ah->caps.max_txchains) - 1; | 886 | hw->wiphy->available_antennas_tx = BIT(ah->caps.max_txchains) - 1; |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 28490702124a..71d3e9adbf3c 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -120,6 +120,7 @@ MODULE_PARM_DESC(allhwsupport, "Enable support for all hardware (even it if over | |||
120 | #ifdef CONFIG_B43_BCMA | 120 | #ifdef CONFIG_B43_BCMA |
121 | static const struct bcma_device_id b43_bcma_tbl[] = { | 121 | static const struct bcma_device_id b43_bcma_tbl[] = { |
122 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x11, BCMA_ANY_CLASS), | 122 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x11, BCMA_ANY_CLASS), |
123 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x15, BCMA_ANY_CLASS), | ||
123 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x17, BCMA_ANY_CLASS), | 124 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x17, BCMA_ANY_CLASS), |
124 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x18, BCMA_ANY_CLASS), | 125 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x18, BCMA_ANY_CLASS), |
125 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x1C, BCMA_ANY_CLASS), | 126 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 0x1C, BCMA_ANY_CLASS), |
diff --git a/drivers/net/wireless/iwlwifi/dvm/lib.c b/drivers/net/wireless/iwlwifi/dvm/lib.c index ab45819c1fbb..e18629a16fb0 100644 --- a/drivers/net/wireless/iwlwifi/dvm/lib.c +++ b/drivers/net/wireless/iwlwifi/dvm/lib.c | |||
@@ -1020,7 +1020,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, | |||
1020 | u8 *pn = seq.ccmp.pn; | 1020 | u8 *pn = seq.ccmp.pn; |
1021 | 1021 | ||
1022 | ieee80211_get_key_rx_seq(key, i, &seq); | 1022 | ieee80211_get_key_rx_seq(key, i, &seq); |
1023 | aes_sc->pn = cpu_to_le64( | 1023 | aes_sc[i].pn = cpu_to_le64( |
1024 | (u64)pn[5] | | 1024 | (u64)pn[5] | |
1025 | ((u64)pn[4] << 8) | | 1025 | ((u64)pn[4] << 8) | |
1026 | ((u64)pn[3] << 16) | | 1026 | ((u64)pn[3] << 16) | |
diff --git a/drivers/net/wireless/iwlwifi/iwl-7000.c b/drivers/net/wireless/iwlwifi/iwl-7000.c index 6951aba620eb..3fb327d5a911 100644 --- a/drivers/net/wireless/iwlwifi/iwl-7000.c +++ b/drivers/net/wireless/iwlwifi/iwl-7000.c | |||
@@ -348,6 +348,6 @@ const struct iwl_cfg iwl7265d_n_cfg = { | |||
348 | }; | 348 | }; |
349 | 349 | ||
350 | MODULE_FIRMWARE(IWL7260_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); | 350 | MODULE_FIRMWARE(IWL7260_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); |
351 | MODULE_FIRMWARE(IWL3160_MODULE_FIRMWARE(IWL3160_UCODE_API_OK)); | 351 | MODULE_FIRMWARE(IWL3160_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); |
352 | MODULE_FIRMWARE(IWL7265_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); | 352 | MODULE_FIRMWARE(IWL7265_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); |
353 | MODULE_FIRMWARE(IWL7265D_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); | 353 | MODULE_FIRMWARE(IWL7265D_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); |
diff --git a/drivers/net/wireless/iwlwifi/mvm/d3.c b/drivers/net/wireless/iwlwifi/mvm/d3.c index 04264e417c1c..576187611e61 100644 --- a/drivers/net/wireless/iwlwifi/mvm/d3.c +++ b/drivers/net/wireless/iwlwifi/mvm/d3.c | |||
@@ -274,18 +274,13 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw, | |||
274 | break; | 274 | break; |
275 | case WLAN_CIPHER_SUITE_CCMP: | 275 | case WLAN_CIPHER_SUITE_CCMP: |
276 | if (sta) { | 276 | if (sta) { |
277 | u8 *pn = seq.ccmp.pn; | 277 | u64 pn64; |
278 | 278 | ||
279 | aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; | 279 | aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; |
280 | aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; | 280 | aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; |
281 | 281 | ||
282 | ieee80211_get_key_tx_seq(key, &seq); | 282 | pn64 = atomic64_read(&key->tx_pn); |
283 | aes_tx_sc->pn = cpu_to_le64((u64)pn[5] | | 283 | aes_tx_sc->pn = cpu_to_le64(pn64); |
284 | ((u64)pn[4] << 8) | | ||
285 | ((u64)pn[3] << 16) | | ||
286 | ((u64)pn[2] << 24) | | ||
287 | ((u64)pn[1] << 32) | | ||
288 | ((u64)pn[0] << 40)); | ||
289 | } else { | 284 | } else { |
290 | aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; | 285 | aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; |
291 | } | 286 | } |
@@ -298,12 +293,12 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw, | |||
298 | u8 *pn = seq.ccmp.pn; | 293 | u8 *pn = seq.ccmp.pn; |
299 | 294 | ||
300 | ieee80211_get_key_rx_seq(key, i, &seq); | 295 | ieee80211_get_key_rx_seq(key, i, &seq); |
301 | aes_sc->pn = cpu_to_le64((u64)pn[5] | | 296 | aes_sc[i].pn = cpu_to_le64((u64)pn[5] | |
302 | ((u64)pn[4] << 8) | | 297 | ((u64)pn[4] << 8) | |
303 | ((u64)pn[3] << 16) | | 298 | ((u64)pn[3] << 16) | |
304 | ((u64)pn[2] << 24) | | 299 | ((u64)pn[2] << 24) | |
305 | ((u64)pn[1] << 32) | | 300 | ((u64)pn[1] << 32) | |
306 | ((u64)pn[0] << 40)); | 301 | ((u64)pn[0] << 40)); |
307 | } | 302 | } |
308 | data->use_rsc_tsc = true; | 303 | data->use_rsc_tsc = true; |
309 | break; | 304 | break; |
@@ -1453,15 +1448,15 @@ static void iwl_mvm_d3_update_gtks(struct ieee80211_hw *hw, | |||
1453 | 1448 | ||
1454 | switch (key->cipher) { | 1449 | switch (key->cipher) { |
1455 | case WLAN_CIPHER_SUITE_CCMP: | 1450 | case WLAN_CIPHER_SUITE_CCMP: |
1456 | iwl_mvm_aes_sc_to_seq(&sc->aes.tsc, &seq); | ||
1457 | iwl_mvm_set_aes_rx_seq(sc->aes.unicast_rsc, key); | 1451 | iwl_mvm_set_aes_rx_seq(sc->aes.unicast_rsc, key); |
1452 | atomic64_set(&key->tx_pn, le64_to_cpu(sc->aes.tsc.pn)); | ||
1458 | break; | 1453 | break; |
1459 | case WLAN_CIPHER_SUITE_TKIP: | 1454 | case WLAN_CIPHER_SUITE_TKIP: |
1460 | iwl_mvm_tkip_sc_to_seq(&sc->tkip.tsc, &seq); | 1455 | iwl_mvm_tkip_sc_to_seq(&sc->tkip.tsc, &seq); |
1461 | iwl_mvm_set_tkip_rx_seq(sc->tkip.unicast_rsc, key); | 1456 | iwl_mvm_set_tkip_rx_seq(sc->tkip.unicast_rsc, key); |
1457 | ieee80211_set_key_tx_seq(key, &seq); | ||
1462 | break; | 1458 | break; |
1463 | } | 1459 | } |
1464 | ieee80211_set_key_tx_seq(key, &seq); | ||
1465 | 1460 | ||
1466 | /* that's it for this key */ | 1461 | /* that's it for this key */ |
1467 | return; | 1462 | return; |
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw.c b/drivers/net/wireless/iwlwifi/mvm/fw.c index 4a0ce83315bd..5c7f7cc9ffcc 100644 --- a/drivers/net/wireless/iwlwifi/mvm/fw.c +++ b/drivers/net/wireless/iwlwifi/mvm/fw.c | |||
@@ -703,7 +703,7 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) | |||
703 | * abort after reading the nvm in case RF Kill is on, we will complete | 703 | * abort after reading the nvm in case RF Kill is on, we will complete |
704 | * the init seq later when RF kill will switch to off | 704 | * the init seq later when RF kill will switch to off |
705 | */ | 705 | */ |
706 | if (iwl_mvm_is_radio_killed(mvm)) { | 706 | if (iwl_mvm_is_radio_hw_killed(mvm)) { |
707 | IWL_DEBUG_RF_KILL(mvm, | 707 | IWL_DEBUG_RF_KILL(mvm, |
708 | "jump over all phy activities due to RF kill\n"); | 708 | "jump over all phy activities due to RF kill\n"); |
709 | iwl_remove_notification(&mvm->notif_wait, &calib_wait); | 709 | iwl_remove_notification(&mvm->notif_wait, &calib_wait); |
@@ -736,7 +736,7 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm) | |||
736 | ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, | 736 | ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait, |
737 | MVM_UCODE_CALIB_TIMEOUT); | 737 | MVM_UCODE_CALIB_TIMEOUT); |
738 | 738 | ||
739 | if (ret && iwl_mvm_is_radio_killed(mvm)) { | 739 | if (ret && iwl_mvm_is_radio_hw_killed(mvm)) { |
740 | IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n"); | 740 | IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n"); |
741 | ret = 1; | 741 | ret = 1; |
742 | } | 742 | } |
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c index aa8c2b7f23c7..7c2944a72470 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c | |||
@@ -2388,6 +2388,7 @@ static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw, | |||
2388 | iwl_mvm_remove_time_event(mvm, mvmvif, | 2388 | iwl_mvm_remove_time_event(mvm, mvmvif, |
2389 | &mvmvif->time_event_data); | 2389 | &mvmvif->time_event_data); |
2390 | RCU_INIT_POINTER(mvm->csa_vif, NULL); | 2390 | RCU_INIT_POINTER(mvm->csa_vif, NULL); |
2391 | mvmvif->csa_countdown = false; | ||
2391 | } | 2392 | } |
2392 | 2393 | ||
2393 | if (rcu_access_pointer(mvm->csa_tx_blocked_vif) == vif) { | 2394 | if (rcu_access_pointer(mvm->csa_tx_blocked_vif) == vif) { |
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h index b95a07ec9e36..c754051a4cea 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mvm.h +++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h | |||
@@ -860,6 +860,11 @@ static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm) | |||
860 | test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status); | 860 | test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status); |
861 | } | 861 | } |
862 | 862 | ||
863 | static inline bool iwl_mvm_is_radio_hw_killed(struct iwl_mvm *mvm) | ||
864 | { | ||
865 | return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status); | ||
866 | } | ||
867 | |||
863 | /* Must be called with rcu_read_lock() held and it can only be | 868 | /* Must be called with rcu_read_lock() held and it can only be |
864 | * released when mvmsta is not needed anymore. | 869 | * released when mvmsta is not needed anymore. |
865 | */ | 870 | */ |
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c index a37de3f410a0..f0cb092f980e 100644 --- a/drivers/net/wireless/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/iwlwifi/mvm/ops.c | |||
@@ -590,6 +590,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg, | |||
590 | ieee80211_unregister_hw(mvm->hw); | 590 | ieee80211_unregister_hw(mvm->hw); |
591 | iwl_mvm_leds_exit(mvm); | 591 | iwl_mvm_leds_exit(mvm); |
592 | out_free: | 592 | out_free: |
593 | flush_delayed_work(&mvm->fw_dump_wk); | ||
593 | iwl_phy_db_free(mvm->phy_db); | 594 | iwl_phy_db_free(mvm->phy_db); |
594 | kfree(mvm->scan_cmd); | 595 | kfree(mvm->scan_cmd); |
595 | if (!cfg->no_power_up_nic_in_init || !mvm->nvm_file_name) | 596 | if (!cfg->no_power_up_nic_in_init || !mvm->nvm_file_name) |
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c index b0825c402c73..644b58bc5226 100644 --- a/drivers/net/wireless/iwlwifi/pcie/drv.c +++ b/drivers/net/wireless/iwlwifi/pcie/drv.c | |||
@@ -414,6 +414,11 @@ static const struct pci_device_id iwl_hw_card_ids[] = { | |||
414 | {IWL_PCI_DEVICE(0x095A, 0x5590, iwl7265_2ac_cfg)}, | 414 | {IWL_PCI_DEVICE(0x095A, 0x5590, iwl7265_2ac_cfg)}, |
415 | {IWL_PCI_DEVICE(0x095B, 0x5290, iwl7265_2ac_cfg)}, | 415 | {IWL_PCI_DEVICE(0x095B, 0x5290, iwl7265_2ac_cfg)}, |
416 | {IWL_PCI_DEVICE(0x095A, 0x5490, iwl7265_2ac_cfg)}, | 416 | {IWL_PCI_DEVICE(0x095A, 0x5490, iwl7265_2ac_cfg)}, |
417 | {IWL_PCI_DEVICE(0x095A, 0x5F10, iwl7265_2ac_cfg)}, | ||
418 | {IWL_PCI_DEVICE(0x095B, 0x5212, iwl7265_2ac_cfg)}, | ||
419 | {IWL_PCI_DEVICE(0x095B, 0x520A, iwl7265_2ac_cfg)}, | ||
420 | {IWL_PCI_DEVICE(0x095A, 0x9000, iwl7265_2ac_cfg)}, | ||
421 | {IWL_PCI_DEVICE(0x095A, 0x9400, iwl7265_2ac_cfg)}, | ||
417 | 422 | ||
418 | /* 8000 Series */ | 423 | /* 8000 Series */ |
419 | {IWL_PCI_DEVICE(0x24F3, 0x0010, iwl8260_2ac_cfg)}, | 424 | {IWL_PCI_DEVICE(0x24F3, 0x0010, iwl8260_2ac_cfg)}, |
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 5932306084fd..bf9afbf46c1b 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -1114,6 +1114,7 @@ static struct usb_device_id rt2800usb_device_table[] = { | |||
1114 | { USB_DEVICE(0x0db0, 0x871c) }, | 1114 | { USB_DEVICE(0x0db0, 0x871c) }, |
1115 | { USB_DEVICE(0x0db0, 0x899a) }, | 1115 | { USB_DEVICE(0x0db0, 0x899a) }, |
1116 | /* Ovislink */ | 1116 | /* Ovislink */ |
1117 | { USB_DEVICE(0x1b75, 0x3070) }, | ||
1117 | { USB_DEVICE(0x1b75, 0x3071) }, | 1118 | { USB_DEVICE(0x1b75, 0x3071) }, |
1118 | { USB_DEVICE(0x1b75, 0x3072) }, | 1119 | { USB_DEVICE(0x1b75, 0x3072) }, |
1119 | { USB_DEVICE(0x1b75, 0xa200) }, | 1120 | { USB_DEVICE(0x1b75, 0xa200) }, |
diff --git a/drivers/net/wireless/rtlwifi/pci.h b/drivers/net/wireless/rtlwifi/pci.h index d4567d12e07e..5da6703942d9 100644 --- a/drivers/net/wireless/rtlwifi/pci.h +++ b/drivers/net/wireless/rtlwifi/pci.h | |||
@@ -247,6 +247,8 @@ struct rtl_pci { | |||
247 | /* MSI support */ | 247 | /* MSI support */ |
248 | bool msi_support; | 248 | bool msi_support; |
249 | bool using_msi; | 249 | bool using_msi; |
250 | /* interrupt clear before set */ | ||
251 | bool int_clear; | ||
250 | }; | 252 | }; |
251 | 253 | ||
252 | struct mp_adapter { | 254 | struct mp_adapter { |
diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c index b7f18e2155eb..6e9418ed90c2 100644 --- a/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c | |||
@@ -2253,11 +2253,28 @@ void rtl8821ae_set_qos(struct ieee80211_hw *hw, int aci) | |||
2253 | } | 2253 | } |
2254 | } | 2254 | } |
2255 | 2255 | ||
2256 | static void rtl8821ae_clear_interrupt(struct ieee80211_hw *hw) | ||
2257 | { | ||
2258 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
2259 | u32 tmp = rtl_read_dword(rtlpriv, REG_HISR); | ||
2260 | |||
2261 | rtl_write_dword(rtlpriv, REG_HISR, tmp); | ||
2262 | |||
2263 | tmp = rtl_read_dword(rtlpriv, REG_HISRE); | ||
2264 | rtl_write_dword(rtlpriv, REG_HISRE, tmp); | ||
2265 | |||
2266 | tmp = rtl_read_dword(rtlpriv, REG_HSISR); | ||
2267 | rtl_write_dword(rtlpriv, REG_HSISR, tmp); | ||
2268 | } | ||
2269 | |||
2256 | void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw) | 2270 | void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw) |
2257 | { | 2271 | { |
2258 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 2272 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
2259 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | 2273 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
2260 | 2274 | ||
2275 | if (!rtlpci->int_clear) | ||
2276 | rtl8821ae_clear_interrupt(hw);/*clear it here first*/ | ||
2277 | |||
2261 | rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF); | 2278 | rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF); |
2262 | rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF); | 2279 | rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF); |
2263 | rtlpci->irq_enabled = true; | 2280 | rtlpci->irq_enabled = true; |
diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c b/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c index a4988121e1ab..8ee141a55bc5 100644 --- a/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c | |||
@@ -96,6 +96,7 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw) | |||
96 | 96 | ||
97 | rtl8821ae_bt_reg_init(hw); | 97 | rtl8821ae_bt_reg_init(hw); |
98 | rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; | 98 | rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; |
99 | rtlpci->int_clear = rtlpriv->cfg->mod_params->int_clear; | ||
99 | rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer(); | 100 | rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer(); |
100 | 101 | ||
101 | rtlpriv->dm.dm_initialgain_enable = 1; | 102 | rtlpriv->dm.dm_initialgain_enable = 1; |
@@ -167,6 +168,7 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw) | |||
167 | rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; | 168 | rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; |
168 | rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; | 169 | rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; |
169 | rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; | 170 | rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; |
171 | rtlpci->msi_support = rtlpriv->cfg->mod_params->int_clear; | ||
170 | if (rtlpriv->cfg->mod_params->disable_watchdog) | 172 | if (rtlpriv->cfg->mod_params->disable_watchdog) |
171 | pr_info("watchdog disabled\n"); | 173 | pr_info("watchdog disabled\n"); |
172 | rtlpriv->psc.reg_fwctrl_lps = 3; | 174 | rtlpriv->psc.reg_fwctrl_lps = 3; |
@@ -308,6 +310,7 @@ static struct rtl_mod_params rtl8821ae_mod_params = { | |||
308 | .swctrl_lps = false, | 310 | .swctrl_lps = false, |
309 | .fwctrl_lps = true, | 311 | .fwctrl_lps = true, |
310 | .msi_support = true, | 312 | .msi_support = true, |
313 | .int_clear = true, | ||
311 | .debug = DBG_EMERG, | 314 | .debug = DBG_EMERG, |
312 | .disable_watchdog = 0, | 315 | .disable_watchdog = 0, |
313 | }; | 316 | }; |
@@ -437,6 +440,7 @@ module_param_named(fwlps, rtl8821ae_mod_params.fwctrl_lps, bool, 0444); | |||
437 | module_param_named(msi, rtl8821ae_mod_params.msi_support, bool, 0444); | 440 | module_param_named(msi, rtl8821ae_mod_params.msi_support, bool, 0444); |
438 | module_param_named(disable_watchdog, rtl8821ae_mod_params.disable_watchdog, | 441 | module_param_named(disable_watchdog, rtl8821ae_mod_params.disable_watchdog, |
439 | bool, 0444); | 442 | bool, 0444); |
443 | module_param_named(int_clear, rtl8821ae_mod_params.int_clear, bool, 0444); | ||
440 | MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n"); | 444 | MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n"); |
441 | MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n"); | 445 | MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n"); |
442 | MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n"); | 446 | MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n"); |
@@ -444,6 +448,7 @@ MODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 1)\n"); | |||
444 | MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 1)\n"); | 448 | MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 1)\n"); |
445 | MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)"); | 449 | MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)"); |
446 | MODULE_PARM_DESC(disable_watchdog, "Set to 1 to disable the watchdog (default 0)\n"); | 450 | MODULE_PARM_DESC(disable_watchdog, "Set to 1 to disable the watchdog (default 0)\n"); |
451 | MODULE_PARM_DESC(int_clear, "Set to 1 to disable interrupt clear before set (default 0)\n"); | ||
447 | 452 | ||
448 | static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume); | 453 | static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume); |
449 | 454 | ||
diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h index b90ca618b123..4544752a2ba8 100644 --- a/drivers/net/wireless/rtlwifi/wifi.h +++ b/drivers/net/wireless/rtlwifi/wifi.h | |||
@@ -2249,6 +2249,9 @@ struct rtl_mod_params { | |||
2249 | 2249 | ||
2250 | /* default 0: 1 means disable */ | 2250 | /* default 0: 1 means disable */ |
2251 | bool disable_watchdog; | 2251 | bool disable_watchdog; |
2252 | |||
2253 | /* default 0: 1 means do not disable interrupts */ | ||
2254 | bool int_clear; | ||
2252 | }; | 2255 | }; |
2253 | 2256 | ||
2254 | struct rtl_hal_usbint_cfg { | 2257 | struct rtl_hal_usbint_cfg { |
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c index 929a6e7e5ecf..56ebd8267386 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c | |||
@@ -788,6 +788,12 @@ static void connect(struct backend_info *be) | |||
788 | /* Use the number of queues requested by the frontend */ | 788 | /* Use the number of queues requested by the frontend */ |
789 | be->vif->queues = vzalloc(requested_num_queues * | 789 | be->vif->queues = vzalloc(requested_num_queues * |
790 | sizeof(struct xenvif_queue)); | 790 | sizeof(struct xenvif_queue)); |
791 | if (!be->vif->queues) { | ||
792 | xenbus_dev_fatal(dev, -ENOMEM, | ||
793 | "allocating queues"); | ||
794 | return; | ||
795 | } | ||
796 | |||
791 | be->vif->num_queues = requested_num_queues; | 797 | be->vif->num_queues = requested_num_queues; |
792 | be->vif->stalled_queues = requested_num_queues; | 798 | be->vif->stalled_queues = requested_num_queues; |
793 | 799 | ||
diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 2365a32a595e..be3755c973e9 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c | |||
@@ -823,9 +823,15 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) | |||
823 | } | 823 | } |
824 | 824 | ||
825 | /* Now look up the logical CPU number */ | 825 | /* Now look up the logical CPU number */ |
826 | for_each_possible_cpu(cpu) | 826 | for_each_possible_cpu(cpu) { |
827 | if (dn == of_cpu_device_node_get(cpu)) | 827 | struct device_node *cpu_dn; |
828 | |||
829 | cpu_dn = of_cpu_device_node_get(cpu); | ||
830 | of_node_put(cpu_dn); | ||
831 | |||
832 | if (dn == cpu_dn) | ||
828 | break; | 833 | break; |
834 | } | ||
829 | 835 | ||
830 | if (cpu >= nr_cpu_ids) { | 836 | if (cpu >= nr_cpu_ids) { |
831 | pr_warn("Failed to find logical CPU for %s\n", | 837 | pr_warn("Failed to find logical CPU for %s\n", |
diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index 23685e74917e..bd2c69f85949 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c | |||
@@ -116,7 +116,7 @@ static int sca3000_read_first_n_hw_rb(struct iio_buffer *r, | |||
116 | if (ret) | 116 | if (ret) |
117 | goto error_ret; | 117 | goto error_ret; |
118 | 118 | ||
119 | for (i = 0; i < num_read; i++) | 119 | for (i = 0; i < num_read / sizeof(u16); i++) |
120 | *(((u16 *)rx) + i) = be16_to_cpup((__be16 *)rx + i); | 120 | *(((u16 *)rx) + i) = be16_to_cpup((__be16 *)rx + i); |
121 | 121 | ||
122 | if (copy_to_user(buf, rx, num_read)) | 122 | if (copy_to_user(buf, rx, num_read)) |
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 3f7715c9968b..47fc00a3f63b 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c | |||
@@ -915,11 +915,12 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev, | |||
915 | case IIO_CHAN_INFO_OFFSET: | 915 | case IIO_CHAN_INFO_OFFSET: |
916 | if (chan->type == IIO_TEMP) { | 916 | if (chan->type == IIO_TEMP) { |
917 | /* The calculated value from the ADC is in Kelvin, we | 917 | /* The calculated value from the ADC is in Kelvin, we |
918 | * want Celsius for hwmon so the offset is | 918 | * want Celsius for hwmon so the offset is -273.15 |
919 | * -272.15 * scale | 919 | * The offset is applied before scaling so it is |
920 | * actually -213.15 * 4 / 1.012 = -1079.644268 | ||
920 | */ | 921 | */ |
921 | *val = -1075; | 922 | *val = -1079; |
922 | *val2 = 691699; | 923 | *val2 = 644268; |
923 | 924 | ||
924 | return IIO_VAL_INT_PLUS_MICRO; | 925 | return IIO_VAL_INT_PLUS_MICRO; |
925 | } | 926 | } |
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 0bae8cc6c23a..ca920b0ecf8f 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c | |||
@@ -932,7 +932,7 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data, | |||
932 | 932 | ||
933 | if (data->soc == SOC_ARCH_EXYNOS5260) | 933 | if (data->soc == SOC_ARCH_EXYNOS5260) |
934 | emul_con = EXYNOS5260_EMUL_CON; | 934 | emul_con = EXYNOS5260_EMUL_CON; |
935 | if (data->soc == SOC_ARCH_EXYNOS5433) | 935 | else if (data->soc == SOC_ARCH_EXYNOS5433) |
936 | emul_con = EXYNOS5433_TMU_EMUL_CON; | 936 | emul_con = EXYNOS5433_TMU_EMUL_CON; |
937 | else if (data->soc == SOC_ARCH_EXYNOS7) | 937 | else if (data->soc == SOC_ARCH_EXYNOS7) |
938 | emul_con = EXYNOS7_TMU_REG_EMUL_CON; | 938 | emul_con = EXYNOS7_TMU_REG_EMUL_CON; |
diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c index 21d01a491405..e508939daea3 100644 --- a/drivers/tty/serial/8250/8250_dma.c +++ b/drivers/tty/serial/8250/8250_dma.c | |||
@@ -80,10 +80,6 @@ int serial8250_tx_dma(struct uart_8250_port *p) | |||
80 | return 0; | 80 | return 0; |
81 | 81 | ||
82 | dma->tx_size = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); | 82 | dma->tx_size = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); |
83 | if (dma->tx_size < p->port.fifosize) { | ||
84 | ret = -EINVAL; | ||
85 | goto err; | ||
86 | } | ||
87 | 83 | ||
88 | desc = dmaengine_prep_slave_single(dma->txchan, | 84 | desc = dmaengine_prep_slave_single(dma->txchan, |
89 | dma->tx_addr + xmit->tail, | 85 | dma->tx_addr + xmit->tail, |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index c79d33676672..c47d3e480586 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -147,6 +147,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
147 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | 147 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && |
148 | pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI) { | 148 | pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI) { |
149 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; | 149 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; |
150 | xhci->quirks |= XHCI_SPURIOUS_WAKEUP; | ||
150 | } | 151 | } |
151 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | 152 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && |
152 | (pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI || | 153 | (pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI || |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 43291f93afeb..97ffe3997273 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -2191,6 +2191,10 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2191 | } | 2191 | } |
2192 | /* Fast path - was this the last TRB in the TD for this URB? */ | 2192 | /* Fast path - was this the last TRB in the TD for this URB? */ |
2193 | } else if (event_trb == td->last_trb) { | 2193 | } else if (event_trb == td->last_trb) { |
2194 | if (td->urb_length_set && trb_comp_code == COMP_SHORT_TX) | ||
2195 | return finish_td(xhci, td, event_trb, event, ep, | ||
2196 | status, false); | ||
2197 | |||
2194 | if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { | 2198 | if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { |
2195 | td->urb->actual_length = | 2199 | td->urb->actual_length = |
2196 | td->urb->transfer_buffer_length - | 2200 | td->urb->transfer_buffer_length - |
@@ -2242,6 +2246,12 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2242 | td->urb->actual_length += | 2246 | td->urb->actual_length += |
2243 | TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - | 2247 | TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - |
2244 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); | 2248 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2249 | |||
2250 | if (trb_comp_code == COMP_SHORT_TX) { | ||
2251 | xhci_dbg(xhci, "mid bulk/intr SP, wait for last TRB event\n"); | ||
2252 | td->urb_length_set = true; | ||
2253 | return 0; | ||
2254 | } | ||
2245 | } | 2255 | } |
2246 | 2256 | ||
2247 | return finish_td(xhci, td, event_trb, event, ep, status, false); | 2257 | return finish_td(xhci, td, event_trb, event, ep, status, false); |
@@ -2274,6 +2284,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
2274 | u32 trb_comp_code; | 2284 | u32 trb_comp_code; |
2275 | int ret = 0; | 2285 | int ret = 0; |
2276 | int td_num = 0; | 2286 | int td_num = 0; |
2287 | bool handling_skipped_tds = false; | ||
2277 | 2288 | ||
2278 | slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); | 2289 | slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); |
2279 | xdev = xhci->devs[slot_id]; | 2290 | xdev = xhci->devs[slot_id]; |
@@ -2410,6 +2421,10 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
2410 | ep->skip = true; | 2421 | ep->skip = true; |
2411 | xhci_dbg(xhci, "Miss service interval error, set skip flag\n"); | 2422 | xhci_dbg(xhci, "Miss service interval error, set skip flag\n"); |
2412 | goto cleanup; | 2423 | goto cleanup; |
2424 | case COMP_PING_ERR: | ||
2425 | ep->skip = true; | ||
2426 | xhci_dbg(xhci, "No Ping response error, Skip one Isoc TD\n"); | ||
2427 | goto cleanup; | ||
2413 | default: | 2428 | default: |
2414 | if (xhci_is_vendor_info_code(xhci, trb_comp_code)) { | 2429 | if (xhci_is_vendor_info_code(xhci, trb_comp_code)) { |
2415 | status = 0; | 2430 | status = 0; |
@@ -2546,13 +2561,18 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
2546 | ep, &status); | 2561 | ep, &status); |
2547 | 2562 | ||
2548 | cleanup: | 2563 | cleanup: |
2564 | |||
2565 | |||
2566 | handling_skipped_tds = ep->skip && | ||
2567 | trb_comp_code != COMP_MISSED_INT && | ||
2568 | trb_comp_code != COMP_PING_ERR; | ||
2569 | |||
2549 | /* | 2570 | /* |
2550 | * Do not update event ring dequeue pointer if ep->skip is set. | 2571 | * Do not update event ring dequeue pointer if we're in a loop |
2551 | * Will roll back to continue process missed tds. | 2572 | * processing missed tds. |
2552 | */ | 2573 | */ |
2553 | if (trb_comp_code == COMP_MISSED_INT || !ep->skip) { | 2574 | if (!handling_skipped_tds) |
2554 | inc_deq(xhci, xhci->event_ring); | 2575 | inc_deq(xhci, xhci->event_ring); |
2555 | } | ||
2556 | 2576 | ||
2557 | if (ret) { | 2577 | if (ret) { |
2558 | urb = td->urb; | 2578 | urb = td->urb; |
@@ -2587,7 +2607,7 @@ cleanup: | |||
2587 | * Process them as short transfer until reach the td pointed by | 2607 | * Process them as short transfer until reach the td pointed by |
2588 | * the event. | 2608 | * the event. |
2589 | */ | 2609 | */ |
2590 | } while (ep->skip && trb_comp_code != COMP_MISSED_INT); | 2610 | } while (handling_skipped_tds); |
2591 | 2611 | ||
2592 | return 0; | 2612 | return 0; |
2593 | } | 2613 | } |
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 1aaf89300621..92f394927f24 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c | |||
@@ -1093,6 +1093,7 @@ static void fbcon_init(struct vc_data *vc, int init) | |||
1093 | con_copy_unimap(vc, svc); | 1093 | con_copy_unimap(vc, svc); |
1094 | 1094 | ||
1095 | ops = info->fbcon_par; | 1095 | ops = info->fbcon_par; |
1096 | ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms); | ||
1096 | p->con_rotate = initial_rotation; | 1097 | p->con_rotate = initial_rotation; |
1097 | set_blitting_type(vc, info); | 1098 | set_blitting_type(vc, info); |
1098 | 1099 | ||
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index b823fac91c92..8c6f247ba81d 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -2584,7 +2584,7 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
2584 | alloc_start); | 2584 | alloc_start); |
2585 | if (ret) | 2585 | if (ret) |
2586 | goto out; | 2586 | goto out; |
2587 | } else { | 2587 | } else if (offset + len > inode->i_size) { |
2588 | /* | 2588 | /* |
2589 | * If we are fallocating from the end of the file onward we | 2589 | * If we are fallocating from the end of the file onward we |
2590 | * need to zero out the end of the page if i_size lands in the | 2590 | * need to zero out the end of the page if i_size lands in the |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 3e3e6130637f..8d20f3b1cab0 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -4641,7 +4641,7 @@ locked: | |||
4641 | 4641 | ||
4642 | if (bctl->flags & ~(BTRFS_BALANCE_ARGS_MASK | BTRFS_BALANCE_TYPE_MASK)) { | 4642 | if (bctl->flags & ~(BTRFS_BALANCE_ARGS_MASK | BTRFS_BALANCE_TYPE_MASK)) { |
4643 | ret = -EINVAL; | 4643 | ret = -EINVAL; |
4644 | goto out_bargs; | 4644 | goto out_bctl; |
4645 | } | 4645 | } |
4646 | 4646 | ||
4647 | do_balance: | 4647 | do_balance: |
@@ -4655,12 +4655,15 @@ do_balance: | |||
4655 | need_unlock = false; | 4655 | need_unlock = false; |
4656 | 4656 | ||
4657 | ret = btrfs_balance(bctl, bargs); | 4657 | ret = btrfs_balance(bctl, bargs); |
4658 | bctl = NULL; | ||
4658 | 4659 | ||
4659 | if (arg) { | 4660 | if (arg) { |
4660 | if (copy_to_user(arg, bargs, sizeof(*bargs))) | 4661 | if (copy_to_user(arg, bargs, sizeof(*bargs))) |
4661 | ret = -EFAULT; | 4662 | ret = -EFAULT; |
4662 | } | 4663 | } |
4663 | 4664 | ||
4665 | out_bctl: | ||
4666 | kfree(bctl); | ||
4664 | out_bargs: | 4667 | out_bargs: |
4665 | kfree(bargs); | 4668 | kfree(bargs); |
4666 | out_unlock: | 4669 | out_unlock: |
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 091a36444972..29e4599f6fc1 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -778,19 +778,24 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi, | |||
778 | struct wb_writeback_work *base_work, | 778 | struct wb_writeback_work *base_work, |
779 | bool skip_if_busy) | 779 | bool skip_if_busy) |
780 | { | 780 | { |
781 | int next_memcg_id = 0; | 781 | struct bdi_writeback *last_wb = NULL; |
782 | struct bdi_writeback *wb; | 782 | struct bdi_writeback *wb = list_entry_rcu(&bdi->wb_list, |
783 | struct wb_iter iter; | 783 | struct bdi_writeback, bdi_node); |
784 | 784 | ||
785 | might_sleep(); | 785 | might_sleep(); |
786 | restart: | 786 | restart: |
787 | rcu_read_lock(); | 787 | rcu_read_lock(); |
788 | bdi_for_each_wb(wb, bdi, &iter, next_memcg_id) { | 788 | list_for_each_entry_continue_rcu(wb, &bdi->wb_list, bdi_node) { |
789 | DEFINE_WB_COMPLETION_ONSTACK(fallback_work_done); | 789 | DEFINE_WB_COMPLETION_ONSTACK(fallback_work_done); |
790 | struct wb_writeback_work fallback_work; | 790 | struct wb_writeback_work fallback_work; |
791 | struct wb_writeback_work *work; | 791 | struct wb_writeback_work *work; |
792 | long nr_pages; | 792 | long nr_pages; |
793 | 793 | ||
794 | if (last_wb) { | ||
795 | wb_put(last_wb); | ||
796 | last_wb = NULL; | ||
797 | } | ||
798 | |||
794 | /* SYNC_ALL writes out I_DIRTY_TIME too */ | 799 | /* SYNC_ALL writes out I_DIRTY_TIME too */ |
795 | if (!wb_has_dirty_io(wb) && | 800 | if (!wb_has_dirty_io(wb) && |
796 | (base_work->sync_mode == WB_SYNC_NONE || | 801 | (base_work->sync_mode == WB_SYNC_NONE || |
@@ -819,12 +824,22 @@ restart: | |||
819 | 824 | ||
820 | wb_queue_work(wb, work); | 825 | wb_queue_work(wb, work); |
821 | 826 | ||
822 | next_memcg_id = wb->memcg_css->id + 1; | 827 | /* |
828 | * Pin @wb so that it stays on @bdi->wb_list. This allows | ||
829 | * continuing iteration from @wb after dropping and | ||
830 | * regrabbing rcu read lock. | ||
831 | */ | ||
832 | wb_get(wb); | ||
833 | last_wb = wb; | ||
834 | |||
823 | rcu_read_unlock(); | 835 | rcu_read_unlock(); |
824 | wb_wait_for_completion(bdi, &fallback_work_done); | 836 | wb_wait_for_completion(bdi, &fallback_work_done); |
825 | goto restart; | 837 | goto restart; |
826 | } | 838 | } |
827 | rcu_read_unlock(); | 839 | rcu_read_unlock(); |
840 | |||
841 | if (last_wb) | ||
842 | wb_put(last_wb); | ||
828 | } | 843 | } |
829 | 844 | ||
830 | #else /* CONFIG_CGROUP_WRITEBACK */ | 845 | #else /* CONFIG_CGROUP_WRITEBACK */ |
@@ -1857,12 +1872,11 @@ void wakeup_flusher_threads(long nr_pages, enum wb_reason reason) | |||
1857 | rcu_read_lock(); | 1872 | rcu_read_lock(); |
1858 | list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) { | 1873 | list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) { |
1859 | struct bdi_writeback *wb; | 1874 | struct bdi_writeback *wb; |
1860 | struct wb_iter iter; | ||
1861 | 1875 | ||
1862 | if (!bdi_has_dirty_io(bdi)) | 1876 | if (!bdi_has_dirty_io(bdi)) |
1863 | continue; | 1877 | continue; |
1864 | 1878 | ||
1865 | bdi_for_each_wb(wb, bdi, &iter, 0) | 1879 | list_for_each_entry_rcu(wb, &bdi->wb_list, bdi_node) |
1866 | wb_start_writeback(wb, wb_split_bdi_pages(wb, nr_pages), | 1880 | wb_start_writeback(wb, wb_split_bdi_pages(wb, nr_pages), |
1867 | false, reason); | 1881 | false, reason); |
1868 | } | 1882 | } |
@@ -1894,11 +1908,10 @@ static void wakeup_dirtytime_writeback(struct work_struct *w) | |||
1894 | rcu_read_lock(); | 1908 | rcu_read_lock(); |
1895 | list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) { | 1909 | list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) { |
1896 | struct bdi_writeback *wb; | 1910 | struct bdi_writeback *wb; |
1897 | struct wb_iter iter; | ||
1898 | 1911 | ||
1899 | bdi_for_each_wb(wb, bdi, &iter, 0) | 1912 | list_for_each_entry_rcu(wb, &bdi->wb_list, bdi_node) |
1900 | if (!list_empty(&bdi->wb.b_dirty_time)) | 1913 | if (!list_empty(&wb->b_dirty_time)) |
1901 | wb_wakeup(&bdi->wb); | 1914 | wb_wakeup(wb); |
1902 | } | 1915 | } |
1903 | rcu_read_unlock(); | 1916 | rcu_read_unlock(); |
1904 | schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); | 1917 | schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ); |
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index ee5aa4daaea0..ce38b4ccc9ab 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c | |||
@@ -1658,12 +1658,13 @@ send_response: | |||
1658 | if (ret < 0) { | 1658 | if (ret < 0) { |
1659 | mlog(ML_ERROR, "failed to dispatch assert master work\n"); | 1659 | mlog(ML_ERROR, "failed to dispatch assert master work\n"); |
1660 | response = DLM_MASTER_RESP_ERROR; | 1660 | response = DLM_MASTER_RESP_ERROR; |
1661 | spin_unlock(&res->spinlock); | ||
1661 | dlm_lockres_put(res); | 1662 | dlm_lockres_put(res); |
1662 | } else { | 1663 | } else { |
1663 | dispatched = 1; | 1664 | dispatched = 1; |
1664 | __dlm_lockres_grab_inflight_worker(dlm, res); | 1665 | __dlm_lockres_grab_inflight_worker(dlm, res); |
1666 | spin_unlock(&res->spinlock); | ||
1665 | } | 1667 | } |
1666 | spin_unlock(&res->spinlock); | ||
1667 | } else { | 1668 | } else { |
1668 | if (res) | 1669 | if (res) |
1669 | dlm_lockres_put(res); | 1670 | dlm_lockres_put(res); |
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index 3d90ad7ff91f..58eaa5c0d387 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c | |||
@@ -1723,8 +1723,8 @@ int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data, | |||
1723 | } else { | 1723 | } else { |
1724 | dispatched = 1; | 1724 | dispatched = 1; |
1725 | __dlm_lockres_grab_inflight_worker(dlm, res); | 1725 | __dlm_lockres_grab_inflight_worker(dlm, res); |
1726 | spin_unlock(&res->spinlock); | ||
1726 | } | 1727 | } |
1727 | spin_unlock(&res->spinlock); | ||
1728 | } else { | 1728 | } else { |
1729 | /* put.. incase we are not the master */ | 1729 | /* put.. incase we are not the master */ |
1730 | spin_unlock(&res->spinlock); | 1730 | spin_unlock(&res->spinlock); |
diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h index a23209b43842..1b4d69f68c33 100644 --- a/include/linux/backing-dev-defs.h +++ b/include/linux/backing-dev-defs.h | |||
@@ -116,6 +116,8 @@ struct bdi_writeback { | |||
116 | struct list_head work_list; | 116 | struct list_head work_list; |
117 | struct delayed_work dwork; /* work item used for writeback */ | 117 | struct delayed_work dwork; /* work item used for writeback */ |
118 | 118 | ||
119 | struct list_head bdi_node; /* anchored at bdi->wb_list */ | ||
120 | |||
119 | #ifdef CONFIG_CGROUP_WRITEBACK | 121 | #ifdef CONFIG_CGROUP_WRITEBACK |
120 | struct percpu_ref refcnt; /* used only for !root wb's */ | 122 | struct percpu_ref refcnt; /* used only for !root wb's */ |
121 | struct fprop_local_percpu memcg_completions; | 123 | struct fprop_local_percpu memcg_completions; |
@@ -150,6 +152,7 @@ struct backing_dev_info { | |||
150 | atomic_long_t tot_write_bandwidth; | 152 | atomic_long_t tot_write_bandwidth; |
151 | 153 | ||
152 | struct bdi_writeback wb; /* the root writeback info for this bdi */ | 154 | struct bdi_writeback wb; /* the root writeback info for this bdi */ |
155 | struct list_head wb_list; /* list of all wbs */ | ||
153 | #ifdef CONFIG_CGROUP_WRITEBACK | 156 | #ifdef CONFIG_CGROUP_WRITEBACK |
154 | struct radix_tree_root cgwb_tree; /* radix tree of active cgroup wbs */ | 157 | struct radix_tree_root cgwb_tree; /* radix tree of active cgroup wbs */ |
155 | struct rb_root cgwb_congested_tree; /* their congested states */ | 158 | struct rb_root cgwb_congested_tree; /* their congested states */ |
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index d5eb4ad1c534..c85f74946a8b 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h | |||
@@ -19,13 +19,17 @@ | |||
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | 20 | ||
21 | int __must_check bdi_init(struct backing_dev_info *bdi); | 21 | int __must_check bdi_init(struct backing_dev_info *bdi); |
22 | void bdi_destroy(struct backing_dev_info *bdi); | 22 | void bdi_exit(struct backing_dev_info *bdi); |
23 | 23 | ||
24 | __printf(3, 4) | 24 | __printf(3, 4) |
25 | int bdi_register(struct backing_dev_info *bdi, struct device *parent, | 25 | int bdi_register(struct backing_dev_info *bdi, struct device *parent, |
26 | const char *fmt, ...); | 26 | const char *fmt, ...); |
27 | int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); | 27 | int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); |
28 | void bdi_unregister(struct backing_dev_info *bdi); | ||
29 | |||
28 | int __must_check bdi_setup_and_register(struct backing_dev_info *, char *); | 30 | int __must_check bdi_setup_and_register(struct backing_dev_info *, char *); |
31 | void bdi_destroy(struct backing_dev_info *bdi); | ||
32 | |||
29 | void wb_start_writeback(struct bdi_writeback *wb, long nr_pages, | 33 | void wb_start_writeback(struct bdi_writeback *wb, long nr_pages, |
30 | bool range_cyclic, enum wb_reason reason); | 34 | bool range_cyclic, enum wb_reason reason); |
31 | void wb_start_background_writeback(struct bdi_writeback *wb); | 35 | void wb_start_background_writeback(struct bdi_writeback *wb); |
@@ -408,61 +412,6 @@ static inline void unlocked_inode_to_wb_end(struct inode *inode, bool locked) | |||
408 | rcu_read_unlock(); | 412 | rcu_read_unlock(); |
409 | } | 413 | } |
410 | 414 | ||
411 | struct wb_iter { | ||
412 | int start_memcg_id; | ||
413 | struct radix_tree_iter tree_iter; | ||
414 | void **slot; | ||
415 | }; | ||
416 | |||
417 | static inline struct bdi_writeback *__wb_iter_next(struct wb_iter *iter, | ||
418 | struct backing_dev_info *bdi) | ||
419 | { | ||
420 | struct radix_tree_iter *titer = &iter->tree_iter; | ||
421 | |||
422 | WARN_ON_ONCE(!rcu_read_lock_held()); | ||
423 | |||
424 | if (iter->start_memcg_id >= 0) { | ||
425 | iter->slot = radix_tree_iter_init(titer, iter->start_memcg_id); | ||
426 | iter->start_memcg_id = -1; | ||
427 | } else { | ||
428 | iter->slot = radix_tree_next_slot(iter->slot, titer, 0); | ||
429 | } | ||
430 | |||
431 | if (!iter->slot) | ||
432 | iter->slot = radix_tree_next_chunk(&bdi->cgwb_tree, titer, 0); | ||
433 | if (iter->slot) | ||
434 | return *iter->slot; | ||
435 | return NULL; | ||
436 | } | ||
437 | |||
438 | static inline struct bdi_writeback *__wb_iter_init(struct wb_iter *iter, | ||
439 | struct backing_dev_info *bdi, | ||
440 | int start_memcg_id) | ||
441 | { | ||
442 | iter->start_memcg_id = start_memcg_id; | ||
443 | |||
444 | if (start_memcg_id) | ||
445 | return __wb_iter_next(iter, bdi); | ||
446 | else | ||
447 | return &bdi->wb; | ||
448 | } | ||
449 | |||
450 | /** | ||
451 | * bdi_for_each_wb - walk all wb's of a bdi in ascending memcg ID order | ||
452 | * @wb_cur: cursor struct bdi_writeback pointer | ||
453 | * @bdi: bdi to walk wb's of | ||
454 | * @iter: pointer to struct wb_iter to be used as iteration buffer | ||
455 | * @start_memcg_id: memcg ID to start iteration from | ||
456 | * | ||
457 | * Iterate @wb_cur through the wb's (bdi_writeback's) of @bdi in ascending | ||
458 | * memcg ID order starting from @start_memcg_id. @iter is struct wb_iter | ||
459 | * to be used as temp storage during iteration. rcu_read_lock() must be | ||
460 | * held throughout iteration. | ||
461 | */ | ||
462 | #define bdi_for_each_wb(wb_cur, bdi, iter, start_memcg_id) \ | ||
463 | for ((wb_cur) = __wb_iter_init(iter, bdi, start_memcg_id); \ | ||
464 | (wb_cur); (wb_cur) = __wb_iter_next(iter, bdi)) | ||
465 | |||
466 | #else /* CONFIG_CGROUP_WRITEBACK */ | 415 | #else /* CONFIG_CGROUP_WRITEBACK */ |
467 | 416 | ||
468 | static inline bool inode_cgwb_enabled(struct inode *inode) | 417 | static inline bool inode_cgwb_enabled(struct inode *inode) |
@@ -522,14 +471,6 @@ static inline void wb_blkcg_offline(struct blkcg *blkcg) | |||
522 | { | 471 | { |
523 | } | 472 | } |
524 | 473 | ||
525 | struct wb_iter { | ||
526 | int next_id; | ||
527 | }; | ||
528 | |||
529 | #define bdi_for_each_wb(wb_cur, bdi, iter, start_blkcg_id) \ | ||
530 | for ((iter)->next_id = (start_blkcg_id); \ | ||
531 | ({ (wb_cur) = !(iter)->next_id++ ? &(bdi)->wb : NULL; }); ) | ||
532 | |||
533 | static inline int inode_congested(struct inode *inode, int cong_bits) | 474 | static inline int inode_congested(struct inode *inode, int cong_bits) |
534 | { | 475 | { |
535 | return wb_congested(&inode_to_bdi(inode)->wb, cong_bits); | 476 | return wb_congested(&inode_to_bdi(inode)->wb, cong_bits); |
diff --git a/include/linux/cma.h b/include/linux/cma.h index f7ef093ec49a..29f9e774ab76 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h | |||
@@ -26,6 +26,6 @@ extern int __init cma_declare_contiguous(phys_addr_t base, | |||
26 | extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, | 26 | extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, |
27 | unsigned int order_per_bit, | 27 | unsigned int order_per_bit, |
28 | struct cma **res_cma); | 28 | struct cma **res_cma); |
29 | extern struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align); | 29 | extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align); |
30 | extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count); | 30 | extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count); |
31 | #endif | 31 | #endif |
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index dfaa7b3e9ae9..8efb40e61d6e 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
@@ -237,12 +237,25 @@ | |||
237 | #define KASAN_ABI_VERSION 3 | 237 | #define KASAN_ABI_VERSION 3 |
238 | #endif | 238 | #endif |
239 | 239 | ||
240 | #if GCC_VERSION >= 40902 | ||
241 | /* | ||
242 | * Tell the compiler that address safety instrumentation (KASAN) | ||
243 | * should not be applied to that function. | ||
244 | * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 | ||
245 | */ | ||
246 | #define __no_sanitize_address __attribute__((no_sanitize_address)) | ||
247 | #endif | ||
248 | |||
240 | #endif /* gcc version >= 40000 specific checks */ | 249 | #endif /* gcc version >= 40000 specific checks */ |
241 | 250 | ||
242 | #if !defined(__noclone) | 251 | #if !defined(__noclone) |
243 | #define __noclone /* not needed */ | 252 | #define __noclone /* not needed */ |
244 | #endif | 253 | #endif |
245 | 254 | ||
255 | #if !defined(__no_sanitize_address) | ||
256 | #define __no_sanitize_address | ||
257 | #endif | ||
258 | |||
246 | /* | 259 | /* |
247 | * A trick to suppress uninitialized variable warning without generating any | 260 | * A trick to suppress uninitialized variable warning without generating any |
248 | * code | 261 | * code |
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index c836eb2dc44d..3d7810341b57 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -198,19 +198,45 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); | |||
198 | 198 | ||
199 | #include <uapi/linux/types.h> | 199 | #include <uapi/linux/types.h> |
200 | 200 | ||
201 | static __always_inline void __read_once_size(const volatile void *p, void *res, int size) | 201 | #define __READ_ONCE_SIZE \ |
202 | ({ \ | ||
203 | switch (size) { \ | ||
204 | case 1: *(__u8 *)res = *(volatile __u8 *)p; break; \ | ||
205 | case 2: *(__u16 *)res = *(volatile __u16 *)p; break; \ | ||
206 | case 4: *(__u32 *)res = *(volatile __u32 *)p; break; \ | ||
207 | case 8: *(__u64 *)res = *(volatile __u64 *)p; break; \ | ||
208 | default: \ | ||
209 | barrier(); \ | ||
210 | __builtin_memcpy((void *)res, (const void *)p, size); \ | ||
211 | barrier(); \ | ||
212 | } \ | ||
213 | }) | ||
214 | |||
215 | static __always_inline | ||
216 | void __read_once_size(const volatile void *p, void *res, int size) | ||
202 | { | 217 | { |
203 | switch (size) { | 218 | __READ_ONCE_SIZE; |
204 | case 1: *(__u8 *)res = *(volatile __u8 *)p; break; | 219 | } |
205 | case 2: *(__u16 *)res = *(volatile __u16 *)p; break; | 220 | |
206 | case 4: *(__u32 *)res = *(volatile __u32 *)p; break; | 221 | #ifdef CONFIG_KASAN |
207 | case 8: *(__u64 *)res = *(volatile __u64 *)p; break; | 222 | /* |
208 | default: | 223 | * This function is not 'inline' because __no_sanitize_address confilcts |
209 | barrier(); | 224 | * with inlining. Attempt to inline it may cause a build failure. |
210 | __builtin_memcpy((void *)res, (const void *)p, size); | 225 | * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 |
211 | barrier(); | 226 | * '__maybe_unused' allows us to avoid defined-but-not-used warnings. |
212 | } | 227 | */ |
228 | static __no_sanitize_address __maybe_unused | ||
229 | void __read_once_size_nocheck(const volatile void *p, void *res, int size) | ||
230 | { | ||
231 | __READ_ONCE_SIZE; | ||
232 | } | ||
233 | #else | ||
234 | static __always_inline | ||
235 | void __read_once_size_nocheck(const volatile void *p, void *res, int size) | ||
236 | { | ||
237 | __READ_ONCE_SIZE; | ||
213 | } | 238 | } |
239 | #endif | ||
214 | 240 | ||
215 | static __always_inline void __write_once_size(volatile void *p, void *res, int size) | 241 | static __always_inline void __write_once_size(volatile void *p, void *res, int size) |
216 | { | 242 | { |
@@ -248,8 +274,22 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s | |||
248 | * required ordering. | 274 | * required ordering. |
249 | */ | 275 | */ |
250 | 276 | ||
251 | #define READ_ONCE(x) \ | 277 | #define __READ_ONCE(x, check) \ |
252 | ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) | 278 | ({ \ |
279 | union { typeof(x) __val; char __c[1]; } __u; \ | ||
280 | if (check) \ | ||
281 | __read_once_size(&(x), __u.__c, sizeof(x)); \ | ||
282 | else \ | ||
283 | __read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \ | ||
284 | __u.__val; \ | ||
285 | }) | ||
286 | #define READ_ONCE(x) __READ_ONCE(x, 1) | ||
287 | |||
288 | /* | ||
289 | * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need | ||
290 | * to hide memory access from KASAN. | ||
291 | */ | ||
292 | #define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0) | ||
253 | 293 | ||
254 | #define WRITE_ONCE(x, val) \ | 294 | #define WRITE_ONCE(x, val) \ |
255 | ({ \ | 295 | ({ \ |
diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h index 569bbd039896..fec734df1524 100644 --- a/include/linux/dma-contiguous.h +++ b/include/linux/dma-contiguous.h | |||
@@ -111,7 +111,7 @@ static inline int dma_declare_contiguous(struct device *dev, phys_addr_t size, | |||
111 | return ret; | 111 | return ret; |
112 | } | 112 | } |
113 | 113 | ||
114 | struct page *dma_alloc_from_contiguous(struct device *dev, int count, | 114 | struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, |
115 | unsigned int order); | 115 | unsigned int order); |
116 | bool dma_release_from_contiguous(struct device *dev, struct page *pages, | 116 | bool dma_release_from_contiguous(struct device *dev, struct page *pages, |
117 | int count); | 117 | int count); |
@@ -144,7 +144,7 @@ int dma_declare_contiguous(struct device *dev, phys_addr_t size, | |||
144 | } | 144 | } |
145 | 145 | ||
146 | static inline | 146 | static inline |
147 | struct page *dma_alloc_from_contiguous(struct device *dev, int count, | 147 | struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, |
148 | unsigned int order) | 148 | unsigned int order) |
149 | { | 149 | { |
150 | return NULL; | 150 | return NULL; |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 6452ff4c463f..3e3318ddfc0e 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -676,8 +676,9 @@ enum { | |||
676 | 676 | ||
677 | struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg); | 677 | struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg); |
678 | struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb); | 678 | struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb); |
679 | void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pavail, | 679 | void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages, |
680 | unsigned long *pdirty, unsigned long *pwriteback); | 680 | unsigned long *pheadroom, unsigned long *pdirty, |
681 | unsigned long *pwriteback); | ||
681 | 682 | ||
682 | #else /* CONFIG_CGROUP_WRITEBACK */ | 683 | #else /* CONFIG_CGROUP_WRITEBACK */ |
683 | 684 | ||
@@ -687,7 +688,8 @@ static inline struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb) | |||
687 | } | 688 | } |
688 | 689 | ||
689 | static inline void mem_cgroup_wb_stats(struct bdi_writeback *wb, | 690 | static inline void mem_cgroup_wb_stats(struct bdi_writeback *wb, |
690 | unsigned long *pavail, | 691 | unsigned long *pfilepages, |
692 | unsigned long *pheadroom, | ||
691 | unsigned long *pdirty, | 693 | unsigned long *pdirty, |
692 | unsigned long *pwriteback) | 694 | unsigned long *pwriteback) |
693 | { | 695 | { |
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index cb1b9bbda332..b36d837c701e 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
@@ -64,7 +64,7 @@ struct unix_sock { | |||
64 | struct socket_wq peer_wq; | 64 | struct socket_wq peer_wq; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static inline struct unix_sock *unix_sk(struct sock *sk) | 67 | static inline struct unix_sock *unix_sk(const struct sock *sk) |
68 | { | 68 | { |
69 | return (struct unix_sock *)sk; | 69 | return (struct unix_sock *)sk; |
70 | } | 70 | } |
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index 186f3a1e1b1f..fc1937698625 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h | |||
@@ -113,12 +113,12 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, | |||
113 | void __inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo, | 113 | void __inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo, |
114 | bool rearm); | 114 | bool rearm); |
115 | 115 | ||
116 | static void inline inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo) | 116 | static inline void inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo) |
117 | { | 117 | { |
118 | __inet_twsk_schedule(tw, timeo, false); | 118 | __inet_twsk_schedule(tw, timeo, false); |
119 | } | 119 | } |
120 | 120 | ||
121 | static void inline inet_twsk_reschedule(struct inet_timewait_sock *tw, int timeo) | 121 | static inline void inet_twsk_reschedule(struct inet_timewait_sock *tw, int timeo) |
122 | { | 122 | { |
123 | __inet_twsk_schedule(tw, timeo, true); | 123 | __inet_twsk_schedule(tw, timeo, true); |
124 | } | 124 | } |
diff --git a/include/net/sock.h b/include/net/sock.h index 7aa78440559a..e23717013a4e 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -828,6 +828,14 @@ static inline __must_check int sk_add_backlog(struct sock *sk, struct sk_buff *s | |||
828 | if (sk_rcvqueues_full(sk, limit)) | 828 | if (sk_rcvqueues_full(sk, limit)) |
829 | return -ENOBUFS; | 829 | return -ENOBUFS; |
830 | 830 | ||
831 | /* | ||
832 | * If the skb was allocated from pfmemalloc reserves, only | ||
833 | * allow SOCK_MEMALLOC sockets to use it as this socket is | ||
834 | * helping free memory | ||
835 | */ | ||
836 | if (skb_pfmemalloc(skb) && !sock_flag(sk, SOCK_MEMALLOC)) | ||
837 | return -ENOMEM; | ||
838 | |||
831 | __sk_add_backlog(sk, skb); | 839 | __sk_add_backlog(sk, skb); |
832 | sk->sk_backlog.len += skb->truesize; | 840 | sk->sk_backlog.len += skb->truesize; |
833 | return 0; | 841 | return 0; |
diff --git a/include/sound/da7213.h b/include/sound/da7213.h index 673f5c39cbf2..e7eac8979995 100644 --- a/include/sound/da7213.h +++ b/include/sound/da7213.h | |||
@@ -44,9 +44,6 @@ struct da7213_platform_data { | |||
44 | enum da7213_dmic_data_sel dmic_data_sel; | 44 | enum da7213_dmic_data_sel dmic_data_sel; |
45 | enum da7213_dmic_samplephase dmic_samplephase; | 45 | enum da7213_dmic_samplephase dmic_samplephase; |
46 | enum da7213_dmic_clk_rate dmic_clk_rate; | 46 | enum da7213_dmic_clk_rate dmic_clk_rate; |
47 | |||
48 | /* MCLK squaring config */ | ||
49 | bool mclk_squaring; | ||
50 | }; | 47 | }; |
51 | 48 | ||
52 | #endif /* _DA7213_PDATA_H */ | 49 | #endif /* _DA7213_PDATA_H */ |
diff --git a/include/sound/da7219-aad.h b/include/sound/da7219-aad.h new file mode 100644 index 000000000000..17802fb86ec4 --- /dev/null +++ b/include/sound/da7219-aad.h | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | * da7219-aad.h - DA7322 ASoC Codec AAD Driver Platform Data | ||
3 | * | ||
4 | * Copyright (c) 2015 Dialog Semiconductor Ltd. | ||
5 | * | ||
6 | * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #ifndef __DA7219_AAD_PDATA_H | ||
15 | #define __DA7219_AAD_PDATA_H | ||
16 | |||
17 | enum da7219_aad_micbias_pulse_lvl { | ||
18 | DA7219_AAD_MICBIAS_PULSE_LVL_OFF = 0, | ||
19 | DA7219_AAD_MICBIAS_PULSE_LVL_2_8V = 6, | ||
20 | DA7219_AAD_MICBIAS_PULSE_LVL_2_9V, | ||
21 | }; | ||
22 | |||
23 | enum da7219_aad_btn_cfg { | ||
24 | DA7219_AAD_BTN_CFG_2MS = 1, | ||
25 | DA7219_AAD_BTN_CFG_5MS, | ||
26 | DA7219_AAD_BTN_CFG_10MS, | ||
27 | DA7219_AAD_BTN_CFG_50MS, | ||
28 | DA7219_AAD_BTN_CFG_100MS, | ||
29 | DA7219_AAD_BTN_CFG_200MS, | ||
30 | DA7219_AAD_BTN_CFG_500MS, | ||
31 | }; | ||
32 | |||
33 | enum da7219_aad_mic_det_thr { | ||
34 | DA7219_AAD_MIC_DET_THR_200_OHMS = 0, | ||
35 | DA7219_AAD_MIC_DET_THR_500_OHMS, | ||
36 | DA7219_AAD_MIC_DET_THR_750_OHMS, | ||
37 | DA7219_AAD_MIC_DET_THR_1000_OHMS, | ||
38 | }; | ||
39 | |||
40 | enum da7219_aad_jack_ins_deb { | ||
41 | DA7219_AAD_JACK_INS_DEB_5MS = 0, | ||
42 | DA7219_AAD_JACK_INS_DEB_10MS, | ||
43 | DA7219_AAD_JACK_INS_DEB_20MS, | ||
44 | DA7219_AAD_JACK_INS_DEB_50MS, | ||
45 | DA7219_AAD_JACK_INS_DEB_100MS, | ||
46 | DA7219_AAD_JACK_INS_DEB_200MS, | ||
47 | DA7219_AAD_JACK_INS_DEB_500MS, | ||
48 | DA7219_AAD_JACK_INS_DEB_1S, | ||
49 | }; | ||
50 | |||
51 | enum da7219_aad_jack_det_rate { | ||
52 | DA7219_AAD_JACK_DET_RATE_32_64MS = 0, | ||
53 | DA7219_AAD_JACK_DET_RATE_64_128MS, | ||
54 | DA7219_AAD_JACK_DET_RATE_128_256MS, | ||
55 | DA7219_AAD_JACK_DET_RATE_256_512MS, | ||
56 | }; | ||
57 | |||
58 | enum da7219_aad_jack_rem_deb { | ||
59 | DA7219_AAD_JACK_REM_DEB_1MS = 0, | ||
60 | DA7219_AAD_JACK_REM_DEB_5MS, | ||
61 | DA7219_AAD_JACK_REM_DEB_10MS, | ||
62 | DA7219_AAD_JACK_REM_DEB_20MS, | ||
63 | }; | ||
64 | |||
65 | enum da7219_aad_btn_avg { | ||
66 | DA7219_AAD_BTN_AVG_1 = 0, | ||
67 | DA7219_AAD_BTN_AVG_2, | ||
68 | DA7219_AAD_BTN_AVG_4, | ||
69 | DA7219_AAD_BTN_AVG_8, | ||
70 | }; | ||
71 | |||
72 | enum da7219_aad_adc_1bit_rpt { | ||
73 | DA7219_AAD_ADC_1BIT_RPT_1 = 0, | ||
74 | DA7219_AAD_ADC_1BIT_RPT_2, | ||
75 | DA7219_AAD_ADC_1BIT_RPT_4, | ||
76 | DA7219_AAD_ADC_1BIT_RPT_8, | ||
77 | }; | ||
78 | |||
79 | struct da7219_aad_pdata { | ||
80 | int irq; | ||
81 | |||
82 | enum da7219_aad_micbias_pulse_lvl micbias_pulse_lvl; | ||
83 | u32 micbias_pulse_time; | ||
84 | enum da7219_aad_btn_cfg btn_cfg; | ||
85 | enum da7219_aad_mic_det_thr mic_det_thr; | ||
86 | enum da7219_aad_jack_ins_deb jack_ins_deb; | ||
87 | enum da7219_aad_jack_det_rate jack_det_rate; | ||
88 | enum da7219_aad_jack_rem_deb jack_rem_deb; | ||
89 | |||
90 | u8 a_d_btn_thr; | ||
91 | u8 d_b_btn_thr; | ||
92 | u8 b_c_btn_thr; | ||
93 | u8 c_mic_btn_thr; | ||
94 | |||
95 | enum da7219_aad_btn_avg btn_avg; | ||
96 | enum da7219_aad_adc_1bit_rpt adc_1bit_rpt; | ||
97 | }; | ||
98 | |||
99 | #endif /* __DA7219_AAD_PDATA_H */ | ||
diff --git a/include/sound/da7219.h b/include/sound/da7219.h new file mode 100644 index 000000000000..3f39e135312d --- /dev/null +++ b/include/sound/da7219.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * da7219.h - DA7219 ASoC Codec Driver Platform Data | ||
3 | * | ||
4 | * Copyright (c) 2015 Dialog Semiconductor | ||
5 | * | ||
6 | * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #ifndef __DA7219_PDATA_H | ||
15 | #define __DA7219_PDATA_H | ||
16 | |||
17 | /* LDO */ | ||
18 | enum da7219_ldo_lvl_sel { | ||
19 | DA7219_LDO_LVL_SEL_1_05V = 0, | ||
20 | DA7219_LDO_LVL_SEL_1_10V, | ||
21 | DA7219_LDO_LVL_SEL_1_20V, | ||
22 | DA7219_LDO_LVL_SEL_1_40V, | ||
23 | }; | ||
24 | |||
25 | /* Mic Bias */ | ||
26 | enum da7219_micbias_voltage { | ||
27 | DA7219_MICBIAS_1_8V = 1, | ||
28 | DA7219_MICBIAS_2_0V, | ||
29 | DA7219_MICBIAS_2_2V, | ||
30 | DA7219_MICBIAS_2_4V, | ||
31 | DA7219_MICBIAS_2_6V, | ||
32 | }; | ||
33 | |||
34 | /* Mic input type */ | ||
35 | enum da7219_mic_amp_in_sel { | ||
36 | DA7219_MIC_AMP_IN_SEL_DIFF = 0, | ||
37 | DA7219_MIC_AMP_IN_SEL_SE_P, | ||
38 | DA7219_MIC_AMP_IN_SEL_SE_N, | ||
39 | }; | ||
40 | |||
41 | struct da7219_aad_pdata; | ||
42 | |||
43 | struct da7219_pdata { | ||
44 | /* Internal LDO */ | ||
45 | enum da7219_ldo_lvl_sel ldo_lvl_sel; | ||
46 | |||
47 | /* Mic */ | ||
48 | enum da7219_micbias_voltage micbias_lvl; | ||
49 | enum da7219_mic_amp_in_sel mic_amp_in_sel; | ||
50 | |||
51 | /* AAD */ | ||
52 | struct da7219_aad_pdata *aad_pdata; | ||
53 | }; | ||
54 | |||
55 | #endif /* __DA7219_PDATA_H */ | ||
diff --git a/include/sound/designware_i2s.h b/include/sound/designware_i2s.h index 3a8fca9409a7..8966ba7c9629 100644 --- a/include/sound/designware_i2s.h +++ b/include/sound/designware_i2s.h | |||
@@ -38,6 +38,8 @@ struct i2s_clk_config_data { | |||
38 | struct i2s_platform_data { | 38 | struct i2s_platform_data { |
39 | #define DWC_I2S_PLAY (1 << 0) | 39 | #define DWC_I2S_PLAY (1 << 0) |
40 | #define DWC_I2S_RECORD (1 << 1) | 40 | #define DWC_I2S_RECORD (1 << 1) |
41 | #define DW_I2S_SLAVE (1 << 2) | ||
42 | #define DW_I2S_MASTER (1 << 3) | ||
41 | unsigned int cap; | 43 | unsigned int cap; |
42 | int channel; | 44 | int channel; |
43 | u32 snd_fmts; | 45 | u32 snd_fmts; |
diff --git a/include/sound/pxa2xx-lib.h b/include/sound/pxa2xx-lib.h index 56e818e4a1cb..6ef629bde164 100644 --- a/include/sound/pxa2xx-lib.h +++ b/include/sound/pxa2xx-lib.h | |||
@@ -12,7 +12,6 @@ extern int __pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream); | |||
12 | extern int pxa2xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd); | 12 | extern int pxa2xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd); |
13 | extern snd_pcm_uframes_t pxa2xx_pcm_pointer(struct snd_pcm_substream *substream); | 13 | extern snd_pcm_uframes_t pxa2xx_pcm_pointer(struct snd_pcm_substream *substream); |
14 | extern int __pxa2xx_pcm_prepare(struct snd_pcm_substream *substream); | 14 | extern int __pxa2xx_pcm_prepare(struct snd_pcm_substream *substream); |
15 | extern void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id); | ||
16 | extern int __pxa2xx_pcm_open(struct snd_pcm_substream *substream); | 15 | extern int __pxa2xx_pcm_open(struct snd_pcm_substream *substream); |
17 | extern int __pxa2xx_pcm_close(struct snd_pcm_substream *substream); | 16 | extern int __pxa2xx_pcm_close(struct snd_pcm_substream *substream); |
18 | extern int pxa2xx_pcm_mmap(struct snd_pcm_substream *substream, | 17 | extern int pxa2xx_pcm_mmap(struct snd_pcm_substream *substream, |
diff --git a/include/sound/rt5640.h b/include/sound/rt5640.h index 59d26dd81e45..e3c84b92ff70 100644 --- a/include/sound/rt5640.h +++ b/include/sound/rt5640.h | |||
@@ -12,9 +12,10 @@ | |||
12 | #define __LINUX_SND_RT5640_H | 12 | #define __LINUX_SND_RT5640_H |
13 | 13 | ||
14 | struct rt5640_platform_data { | 14 | struct rt5640_platform_data { |
15 | /* IN1 & IN2 can optionally be differential */ | 15 | /* IN1 & IN2 & IN3 can optionally be differential */ |
16 | bool in1_diff; | 16 | bool in1_diff; |
17 | bool in2_diff; | 17 | bool in2_diff; |
18 | bool in3_diff; | ||
18 | 19 | ||
19 | bool dmic_en; | 20 | bool dmic_en; |
20 | bool dmic1_data_pin; /* 0 = IN1P; 1 = GPIO3 */ | 21 | bool dmic1_data_pin; /* 0 = IN1P; 1 = GPIO3 */ |
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 2df96b1384c7..212eaaf172ed 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h | |||
@@ -48,10 +48,25 @@ struct snd_compr_stream; | |||
48 | #define SND_SOC_DAIFMT_GATED (0 << 4) /* clock is gated */ | 48 | #define SND_SOC_DAIFMT_GATED (0 << 4) /* clock is gated */ |
49 | 49 | ||
50 | /* | 50 | /* |
51 | * DAI hardware signal inversions. | 51 | * DAI hardware signal polarity. |
52 | * | 52 | * |
53 | * Specifies whether the DAI can also support inverted clocks for the specified | 53 | * Specifies whether the DAI can also support inverted clocks for the specified |
54 | * format. | 54 | * format. |
55 | * | ||
56 | * BCLK: | ||
57 | * - "normal" polarity means signal is available at rising edge of BCLK | ||
58 | * - "inverted" polarity means signal is available at falling edge of BCLK | ||
59 | * | ||
60 | * FSYNC "normal" polarity depends on the frame format: | ||
61 | * - I2S: frame consists of left then right channel data. Left channel starts | ||
62 | * with falling FSYNC edge, right channel starts with rising FSYNC edge. | ||
63 | * - Left/Right Justified: frame consists of left then right channel data. | ||
64 | * Left channel starts with rising FSYNC edge, right channel starts with | ||
65 | * falling FSYNC edge. | ||
66 | * - DSP A/B: Frame starts with rising FSYNC edge. | ||
67 | * - AC97: Frame starts with rising FSYNC edge. | ||
68 | * | ||
69 | * "Negative" FSYNC polarity is the one opposite of "normal" polarity. | ||
55 | */ | 70 | */ |
56 | #define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bit clock + frame */ | 71 | #define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bit clock + frame */ |
57 | #define SND_SOC_DAIFMT_NB_IF (2 << 8) /* normal BCLK + inv FRM */ | 72 | #define SND_SOC_DAIFMT_NB_IF (2 << 8) /* normal BCLK + inv FRM */ |
@@ -214,7 +229,7 @@ struct snd_soc_dai_driver { | |||
214 | int (*suspend)(struct snd_soc_dai *dai); | 229 | int (*suspend)(struct snd_soc_dai *dai); |
215 | int (*resume)(struct snd_soc_dai *dai); | 230 | int (*resume)(struct snd_soc_dai *dai); |
216 | /* compress dai */ | 231 | /* compress dai */ |
217 | bool compress_dai; | 232 | int (*compress_new)(struct snd_soc_pcm_runtime *rtd, int num); |
218 | /* DAI is also used for the control bus */ | 233 | /* DAI is also used for the control bus */ |
219 | bool bus_control; | 234 | bool bus_control; |
220 | 235 | ||
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 5abba037d245..7855cfe46b69 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h | |||
@@ -451,6 +451,9 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream, | |||
451 | struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm( | 451 | struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm( |
452 | struct snd_kcontrol *kcontrol); | 452 | struct snd_kcontrol *kcontrol); |
453 | 453 | ||
454 | struct snd_soc_dapm_widget *snd_soc_dapm_kcontrol_widget( | ||
455 | struct snd_kcontrol *kcontrol); | ||
456 | |||
454 | int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm, | 457 | int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm, |
455 | enum snd_soc_bias_level level); | 458 | enum snd_soc_bias_level level); |
456 | 459 | ||
diff --git a/include/sound/soc.h b/include/sound/soc.h index 470f20887b61..a8b4b9c8b1d2 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -86,7 +86,7 @@ | |||
86 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | 86 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
87 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | 87 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
88 | .tlv.p = (tlv_array),\ | 88 | .tlv.p = (tlv_array),\ |
89 | .info = snd_soc_info_volsw, \ | 89 | .info = snd_soc_info_volsw_sx, \ |
90 | .get = snd_soc_get_volsw_sx,\ | 90 | .get = snd_soc_get_volsw_sx,\ |
91 | .put = snd_soc_put_volsw_sx, \ | 91 | .put = snd_soc_put_volsw_sx, \ |
92 | .private_value = (unsigned long)&(struct soc_mixer_control) \ | 92 | .private_value = (unsigned long)&(struct soc_mixer_control) \ |
@@ -156,7 +156,7 @@ | |||
156 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | 156 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
157 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | 157 | SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
158 | .tlv.p = (tlv_array), \ | 158 | .tlv.p = (tlv_array), \ |
159 | .info = snd_soc_info_volsw, \ | 159 | .info = snd_soc_info_volsw_sx, \ |
160 | .get = snd_soc_get_volsw_sx, \ | 160 | .get = snd_soc_get_volsw_sx, \ |
161 | .put = snd_soc_put_volsw_sx, \ | 161 | .put = snd_soc_put_volsw_sx, \ |
162 | .private_value = (unsigned long)&(struct soc_mixer_control) \ | 162 | .private_value = (unsigned long)&(struct soc_mixer_control) \ |
@@ -217,6 +217,13 @@ | |||
217 | .get = xhandler_get, .put = xhandler_put, \ | 217 | .get = xhandler_get, .put = xhandler_put, \ |
218 | .private_value = \ | 218 | .private_value = \ |
219 | SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) } | 219 | SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) } |
220 | #define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\ | ||
221 | xhandler_get, xhandler_put) \ | ||
222 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | ||
223 | .info = snd_soc_info_volsw, \ | ||
224 | .get = xhandler_get, .put = xhandler_put, \ | ||
225 | .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ | ||
226 | xmax, xinvert) } | ||
220 | #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\ | 227 | #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\ |
221 | xhandler_get, xhandler_put, tlv_array) \ | 228 | xhandler_get, xhandler_put, tlv_array) \ |
222 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 229 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
@@ -452,7 +459,9 @@ int snd_soc_platform_read(struct snd_soc_platform *platform, | |||
452 | int snd_soc_platform_write(struct snd_soc_platform *platform, | 459 | int snd_soc_platform_write(struct snd_soc_platform *platform, |
453 | unsigned int reg, unsigned int val); | 460 | unsigned int reg, unsigned int val); |
454 | int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); | 461 | int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); |
455 | int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num); | 462 | #ifdef CONFIG_SND_SOC_COMPRESS |
463 | int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num); | ||
464 | #endif | ||
456 | 465 | ||
457 | struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, | 466 | struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, |
458 | const char *dai_link, int stream); | 467 | const char *dai_link, int stream); |
@@ -586,6 +595,8 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, | |||
586 | struct snd_ctl_elem_value *ucontrol); | 595 | struct snd_ctl_elem_value *ucontrol); |
587 | int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, | 596 | int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, |
588 | struct snd_ctl_elem_info *uinfo); | 597 | struct snd_ctl_elem_info *uinfo); |
598 | int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol, | ||
599 | struct snd_ctl_elem_info *uinfo); | ||
589 | #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info | 600 | #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info |
590 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, | 601 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, |
591 | struct snd_ctl_elem_value *ucontrol); | 602 | struct snd_ctl_elem_value *ucontrol); |
@@ -603,7 +614,7 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, | |||
603 | struct snd_ctl_elem_value *ucontrol); | 614 | struct snd_ctl_elem_value *ucontrol); |
604 | int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, | 615 | int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, |
605 | struct snd_ctl_elem_value *ucontrol); | 616 | struct snd_ctl_elem_value *ucontrol); |
606 | int snd_soc_limit_volume(struct snd_soc_codec *codec, | 617 | int snd_soc_limit_volume(struct snd_soc_card *card, |
607 | const char *name, int max); | 618 | const char *name, int max); |
608 | int snd_soc_bytes_info(struct snd_kcontrol *kcontrol, | 619 | int snd_soc_bytes_info(struct snd_kcontrol *kcontrol, |
609 | struct snd_ctl_elem_info *uinfo); | 620 | struct snd_ctl_elem_info *uinfo); |
diff --git a/include/sound/wm8904.h b/include/sound/wm8904.h index 898be3a8db9a..6d8f8fba3341 100644 --- a/include/sound/wm8904.h +++ b/include/sound/wm8904.h | |||
@@ -119,7 +119,7 @@ | |||
119 | #define WM8904_MIC_REGS 2 | 119 | #define WM8904_MIC_REGS 2 |
120 | #define WM8904_GPIO_REGS 4 | 120 | #define WM8904_GPIO_REGS 4 |
121 | #define WM8904_DRC_REGS 4 | 121 | #define WM8904_DRC_REGS 4 |
122 | #define WM8904_EQ_REGS 25 | 122 | #define WM8904_EQ_REGS 24 |
123 | 123 | ||
124 | /** | 124 | /** |
125 | * DRC configurations are specified with a label and a set of register | 125 | * DRC configurations are specified with a label and a set of register |
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h index 32e07d8cbaf4..036f73bc54cd 100644 --- a/include/uapi/linux/openvswitch.h +++ b/include/uapi/linux/openvswitch.h | |||
@@ -323,10 +323,10 @@ enum ovs_key_attr { | |||
323 | OVS_KEY_ATTR_MPLS, /* array of struct ovs_key_mpls. | 323 | OVS_KEY_ATTR_MPLS, /* array of struct ovs_key_mpls. |
324 | * The implementation may restrict | 324 | * The implementation may restrict |
325 | * the accepted length of the array. */ | 325 | * the accepted length of the array. */ |
326 | OVS_KEY_ATTR_CT_STATE, /* u8 bitmask of OVS_CS_F_* */ | 326 | OVS_KEY_ATTR_CT_STATE, /* u32 bitmask of OVS_CS_F_* */ |
327 | OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */ | 327 | OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */ |
328 | OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */ | 328 | OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */ |
329 | OVS_KEY_ATTR_CT_LABEL, /* 16-octet connection tracking label */ | 329 | OVS_KEY_ATTR_CT_LABELS, /* 16-octet connection tracking label */ |
330 | 330 | ||
331 | #ifdef __KERNEL__ | 331 | #ifdef __KERNEL__ |
332 | OVS_KEY_ATTR_TUNNEL_INFO, /* struct ip_tunnel_info */ | 332 | OVS_KEY_ATTR_TUNNEL_INFO, /* struct ip_tunnel_info */ |
@@ -439,9 +439,9 @@ struct ovs_key_nd { | |||
439 | __u8 nd_tll[ETH_ALEN]; | 439 | __u8 nd_tll[ETH_ALEN]; |
440 | }; | 440 | }; |
441 | 441 | ||
442 | #define OVS_CT_LABEL_LEN 16 | 442 | #define OVS_CT_LABELS_LEN 16 |
443 | struct ovs_key_ct_label { | 443 | struct ovs_key_ct_labels { |
444 | __u8 ct_label[OVS_CT_LABEL_LEN]; | 444 | __u8 ct_labels[OVS_CT_LABELS_LEN]; |
445 | }; | 445 | }; |
446 | 446 | ||
447 | /* OVS_KEY_ATTR_CT_STATE flags */ | 447 | /* OVS_KEY_ATTR_CT_STATE flags */ |
@@ -449,9 +449,9 @@ struct ovs_key_ct_label { | |||
449 | #define OVS_CS_F_ESTABLISHED 0x02 /* Part of an existing connection. */ | 449 | #define OVS_CS_F_ESTABLISHED 0x02 /* Part of an existing connection. */ |
450 | #define OVS_CS_F_RELATED 0x04 /* Related to an established | 450 | #define OVS_CS_F_RELATED 0x04 /* Related to an established |
451 | * connection. */ | 451 | * connection. */ |
452 | #define OVS_CS_F_INVALID 0x20 /* Could not track connection. */ | 452 | #define OVS_CS_F_REPLY_DIR 0x08 /* Flow is in the reply direction. */ |
453 | #define OVS_CS_F_REPLY_DIR 0x40 /* Flow is in the reply direction. */ | 453 | #define OVS_CS_F_INVALID 0x10 /* Could not track connection. */ |
454 | #define OVS_CS_F_TRACKED 0x80 /* Conntrack has occurred. */ | 454 | #define OVS_CS_F_TRACKED 0x20 /* Conntrack has occurred. */ |
455 | 455 | ||
456 | /** | 456 | /** |
457 | * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands. | 457 | * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands. |
@@ -618,22 +618,24 @@ struct ovs_action_hash { | |||
618 | 618 | ||
619 | /** | 619 | /** |
620 | * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action. | 620 | * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action. |
621 | * @OVS_CT_ATTR_FLAGS: u32 connection tracking flags. | 621 | * @OVS_CT_ATTR_COMMIT: If present, commits the connection to the conntrack |
622 | * table. This allows future packets for the same connection to be identified | ||
623 | * as 'established' or 'related'. | ||
622 | * @OVS_CT_ATTR_ZONE: u16 connection tracking zone. | 624 | * @OVS_CT_ATTR_ZONE: u16 connection tracking zone. |
623 | * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the | 625 | * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the |
624 | * mask, the corresponding bit in the value is copied to the connection | 626 | * mask, the corresponding bit in the value is copied to the connection |
625 | * tracking mark field in the connection. | 627 | * tracking mark field in the connection. |
626 | * @OVS_CT_ATTR_LABEL: %OVS_CT_LABEL_LEN value followed by %OVS_CT_LABEL_LEN | 628 | * @OVS_CT_ATTR_LABEL: %OVS_CT_LABELS_LEN value followed by %OVS_CT_LABELS_LEN |
627 | * mask. For each bit set in the mask, the corresponding bit in the value is | 629 | * mask. For each bit set in the mask, the corresponding bit in the value is |
628 | * copied to the connection tracking label field in the connection. | 630 | * copied to the connection tracking label field in the connection. |
629 | * @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG. | 631 | * @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG. |
630 | */ | 632 | */ |
631 | enum ovs_ct_attr { | 633 | enum ovs_ct_attr { |
632 | OVS_CT_ATTR_UNSPEC, | 634 | OVS_CT_ATTR_UNSPEC, |
633 | OVS_CT_ATTR_FLAGS, /* u8 bitmask of OVS_CT_F_*. */ | 635 | OVS_CT_ATTR_COMMIT, /* No argument, commits connection. */ |
634 | OVS_CT_ATTR_ZONE, /* u16 zone id. */ | 636 | OVS_CT_ATTR_ZONE, /* u16 zone id. */ |
635 | OVS_CT_ATTR_MARK, /* mark to associate with this connection. */ | 637 | OVS_CT_ATTR_MARK, /* mark to associate with this connection. */ |
636 | OVS_CT_ATTR_LABEL, /* label to associate with this connection. */ | 638 | OVS_CT_ATTR_LABELS, /* labels to associate with this connection. */ |
637 | OVS_CT_ATTR_HELPER, /* netlink helper to assist detection of | 639 | OVS_CT_ATTR_HELPER, /* netlink helper to assist detection of |
638 | related connections. */ | 640 | related connections. */ |
639 | __OVS_CT_ATTR_MAX | 641 | __OVS_CT_ATTR_MAX |
@@ -641,14 +643,6 @@ enum ovs_ct_attr { | |||
641 | 643 | ||
642 | #define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1) | 644 | #define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1) |
643 | 645 | ||
644 | /* | ||
645 | * OVS_CT_ATTR_FLAGS flags - bitmask of %OVS_CT_F_* | ||
646 | * @OVS_CT_F_COMMIT: Commits the flow to the conntrack table. This allows | ||
647 | * future packets for the same connection to be identified as 'established' | ||
648 | * or 'related'. | ||
649 | */ | ||
650 | #define OVS_CT_F_COMMIT 0x01 | ||
651 | |||
652 | /** | 646 | /** |
653 | * enum ovs_action_attr - Action types. | 647 | * enum ovs_action_attr - Action types. |
654 | * | 648 | * |
@@ -705,7 +699,7 @@ enum ovs_action_attr { | |||
705 | * data immediately followed by a mask. | 699 | * data immediately followed by a mask. |
706 | * The data must be zero for the unmasked | 700 | * The data must be zero for the unmasked |
707 | * bits. */ | 701 | * bits. */ |
708 | OVS_ACTION_ATTR_CT, /* One nested OVS_CT_ATTR_* . */ | 702 | OVS_ACTION_ATTR_CT, /* Nested OVS_CT_ATTR_* . */ |
709 | 703 | ||
710 | __OVS_ACTION_ATTR_MAX, /* Nothing past this will be accepted | 704 | __OVS_ACTION_ATTR_MAX, /* Nothing past this will be accepted |
711 | * from userspace. */ | 705 | * from userspace. */ |
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h index 702024769c74..9d8f5d10c1e5 100644 --- a/include/uapi/linux/rtnetlink.h +++ b/include/uapi/linux/rtnetlink.h | |||
@@ -160,7 +160,7 @@ struct rtattr { | |||
160 | 160 | ||
161 | /* Macros to handle rtattributes */ | 161 | /* Macros to handle rtattributes */ |
162 | 162 | ||
163 | #define RTA_ALIGNTO 4 | 163 | #define RTA_ALIGNTO 4U |
164 | #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) ) | 164 | #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) ) |
165 | #define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \ | 165 | #define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \ |
166 | (rta)->rta_len >= sizeof(struct rtattr) && \ | 166 | (rta)->rta_len >= sizeof(struct rtattr) && \ |
diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h index 247c50bd60f0..26539a7e4880 100644 --- a/include/uapi/sound/asoc.h +++ b/include/uapi/sound/asoc.h | |||
@@ -83,7 +83,7 @@ | |||
83 | #define SND_SOC_TPLG_NUM_TEXTS 16 | 83 | #define SND_SOC_TPLG_NUM_TEXTS 16 |
84 | 84 | ||
85 | /* ABI version */ | 85 | /* ABI version */ |
86 | #define SND_SOC_TPLG_ABI_VERSION 0x3 | 86 | #define SND_SOC_TPLG_ABI_VERSION 0x4 |
87 | 87 | ||
88 | /* Max size of TLV data */ | 88 | /* Max size of TLV data */ |
89 | #define SND_SOC_TPLG_TLV_SIZE 32 | 89 | #define SND_SOC_TPLG_TLV_SIZE 32 |
@@ -103,7 +103,8 @@ | |||
103 | #define SND_SOC_TPLG_TYPE_PCM 7 | 103 | #define SND_SOC_TPLG_TYPE_PCM 7 |
104 | #define SND_SOC_TPLG_TYPE_MANIFEST 8 | 104 | #define SND_SOC_TPLG_TYPE_MANIFEST 8 |
105 | #define SND_SOC_TPLG_TYPE_CODEC_LINK 9 | 105 | #define SND_SOC_TPLG_TYPE_CODEC_LINK 9 |
106 | #define SND_SOC_TPLG_TYPE_PDATA 10 | 106 | #define SND_SOC_TPLG_TYPE_BACKEND_LINK 10 |
107 | #define SND_SOC_TPLG_TYPE_PDATA 11 | ||
107 | #define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_PDATA | 108 | #define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_PDATA |
108 | 109 | ||
109 | /* vendor block IDs - please add new vendor types to end */ | 110 | /* vendor block IDs - please add new vendor types to end */ |
@@ -198,7 +199,7 @@ struct snd_soc_tplg_ctl_hdr { | |||
198 | struct snd_soc_tplg_stream_caps { | 199 | struct snd_soc_tplg_stream_caps { |
199 | __le32 size; /* in bytes of this structure */ | 200 | __le32 size; /* in bytes of this structure */ |
200 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | 201 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; |
201 | __le64 formats[SND_SOC_TPLG_MAX_FORMATS]; /* supported formats SNDRV_PCM_FMTBIT_* */ | 202 | __le64 formats; /* supported formats SNDRV_PCM_FMTBIT_* */ |
202 | __le32 rates; /* supported rates SNDRV_PCM_RATE_* */ | 203 | __le32 rates; /* supported rates SNDRV_PCM_RATE_* */ |
203 | __le32 rate_min; /* min rate */ | 204 | __le32 rate_min; /* min rate */ |
204 | __le32 rate_max; /* max rate */ | 205 | __le32 rate_max; /* max rate */ |
@@ -217,23 +218,12 @@ struct snd_soc_tplg_stream_caps { | |||
217 | */ | 218 | */ |
218 | struct snd_soc_tplg_stream { | 219 | struct snd_soc_tplg_stream { |
219 | __le32 size; /* in bytes of this structure */ | 220 | __le32 size; /* in bytes of this structure */ |
221 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; /* Name of the stream */ | ||
220 | __le64 format; /* SNDRV_PCM_FMTBIT_* */ | 222 | __le64 format; /* SNDRV_PCM_FMTBIT_* */ |
221 | __le32 rate; /* SNDRV_PCM_RATE_* */ | 223 | __le32 rate; /* SNDRV_PCM_RATE_* */ |
222 | __le32 period_bytes; /* size of period in bytes */ | 224 | __le32 period_bytes; /* size of period in bytes */ |
223 | __le32 buffer_bytes; /* size of buffer in bytes */ | 225 | __le32 buffer_bytes; /* size of buffer in bytes */ |
224 | __le32 channels; /* channels */ | 226 | __le32 channels; /* channels */ |
225 | __le32 tdm_slot; /* optional BE bitmask of supported TDM slots */ | ||
226 | __le32 dai_fmt; /* SND_SOC_DAIFMT_ */ | ||
227 | } __attribute__((packed)); | ||
228 | |||
229 | /* | ||
230 | * Duplex stream configuration supported by SW/FW. | ||
231 | */ | ||
232 | struct snd_soc_tplg_stream_config { | ||
233 | __le32 size; /* in bytes of this structure */ | ||
234 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | ||
235 | struct snd_soc_tplg_stream playback; | ||
236 | struct snd_soc_tplg_stream capture; | ||
237 | } __attribute__((packed)); | 227 | } __attribute__((packed)); |
238 | 228 | ||
239 | /* | 229 | /* |
@@ -366,11 +356,11 @@ struct snd_soc_tplg_dapm_widget { | |||
366 | __le32 shift; /* bits to shift */ | 356 | __le32 shift; /* bits to shift */ |
367 | __le32 mask; /* non-shifted mask */ | 357 | __le32 mask; /* non-shifted mask */ |
368 | __le32 subseq; /* sort within widget type */ | 358 | __le32 subseq; /* sort within widget type */ |
369 | __u32 invert; /* invert the power bit */ | 359 | __le32 invert; /* invert the power bit */ |
370 | __u32 ignore_suspend; /* kept enabled over suspend */ | 360 | __le32 ignore_suspend; /* kept enabled over suspend */ |
371 | __u16 event_flags; | 361 | __le16 event_flags; |
372 | __u16 event_type; | 362 | __le16 event_type; |
373 | __u16 num_kcontrols; | 363 | __le32 num_kcontrols; |
374 | struct snd_soc_tplg_private priv; | 364 | struct snd_soc_tplg_private priv; |
375 | /* | 365 | /* |
376 | * kcontrols that relate to this widget | 366 | * kcontrols that relate to this widget |
@@ -378,30 +368,46 @@ struct snd_soc_tplg_dapm_widget { | |||
378 | */ | 368 | */ |
379 | } __attribute__((packed)); | 369 | } __attribute__((packed)); |
380 | 370 | ||
381 | struct snd_soc_tplg_pcm_cfg_caps { | ||
382 | struct snd_soc_tplg_stream_caps caps; | ||
383 | struct snd_soc_tplg_stream_config configs[SND_SOC_TPLG_STREAM_CONFIG_MAX]; | ||
384 | __le32 num_configs; /* number of configs */ | ||
385 | } __attribute__((packed)); | ||
386 | 371 | ||
387 | /* | 372 | /* |
388 | * Describes SW/FW specific features of PCM or DAI link. | 373 | * Describes SW/FW specific features of PCM (FE DAI & DAI link). |
389 | * | 374 | * |
390 | * File block representation for PCM/DAI-Link :- | 375 | * File block representation for PCM :- |
391 | * +-----------------------------------+-----+ | 376 | * +-----------------------------------+-----+ |
392 | * | struct snd_soc_tplg_hdr | 1 | | 377 | * | struct snd_soc_tplg_hdr | 1 | |
393 | * +-----------------------------------+-----+ | 378 | * +-----------------------------------+-----+ |
394 | * | struct snd_soc_tplg_dapm_pcm_dai | N | | 379 | * | struct snd_soc_tplg_pcm | N | |
395 | * +-----------------------------------+-----+ | 380 | * +-----------------------------------+-----+ |
396 | */ | 381 | */ |
397 | struct snd_soc_tplg_pcm_dai { | 382 | struct snd_soc_tplg_pcm { |
398 | __le32 size; /* in bytes of this structure */ | 383 | __le32 size; /* in bytes of this structure */ |
399 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; | 384 | char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; |
400 | __le32 id; /* unique ID - used to match */ | 385 | char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; |
401 | __le32 playback; /* supports playback mode */ | 386 | __le32 pcm_id; /* unique ID - used to match */ |
402 | __le32 capture; /* supports capture mode */ | 387 | __le32 dai_id; /* unique ID - used to match */ |
403 | __le32 compress; /* 1 = compressed; 0 = PCM */ | 388 | __le32 playback; /* supports playback mode */ |
404 | struct snd_soc_tplg_pcm_cfg_caps capconf[2]; /* capabilities and configs */ | 389 | __le32 capture; /* supports capture mode */ |
390 | __le32 compress; /* 1 = compressed; 0 = PCM */ | ||
391 | struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */ | ||
392 | __le32 num_streams; /* number of streams */ | ||
393 | struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */ | ||
405 | } __attribute__((packed)); | 394 | } __attribute__((packed)); |
406 | 395 | ||
396 | |||
397 | /* | ||
398 | * Describes the BE or CC link runtime supported configs or params | ||
399 | * | ||
400 | * File block representation for BE/CC link config :- | ||
401 | * +-----------------------------------+-----+ | ||
402 | * | struct snd_soc_tplg_hdr | 1 | | ||
403 | * +-----------------------------------+-----+ | ||
404 | * | struct snd_soc_tplg_link_config | N | | ||
405 | * +-----------------------------------+-----+ | ||
406 | */ | ||
407 | struct snd_soc_tplg_link_config { | ||
408 | __le32 size; /* in bytes of this structure */ | ||
409 | __le32 id; /* unique ID - used to match */ | ||
410 | struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* supported configs playback and captrure */ | ||
411 | __le32 num_streams; /* number of streams */ | ||
412 | } __attribute__((packed)); | ||
407 | #endif | 413 | #endif |
diff --git a/kernel/kmod.c b/kernel/kmod.c index da98d0593de2..0277d1216f80 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
@@ -327,9 +327,13 @@ static void call_usermodehelper_exec_work(struct work_struct *work) | |||
327 | call_usermodehelper_exec_sync(sub_info); | 327 | call_usermodehelper_exec_sync(sub_info); |
328 | } else { | 328 | } else { |
329 | pid_t pid; | 329 | pid_t pid; |
330 | 330 | /* | |
331 | * Use CLONE_PARENT to reparent it to kthreadd; we do not | ||
332 | * want to pollute current->children, and we need a parent | ||
333 | * that always ignores SIGCHLD to ensure auto-reaping. | ||
334 | */ | ||
331 | pid = kernel_thread(call_usermodehelper_exec_async, sub_info, | 335 | pid = kernel_thread(call_usermodehelper_exec_async, sub_info, |
332 | SIGCHLD); | 336 | CLONE_PARENT | SIGCHLD); |
333 | if (pid < 0) { | 337 | if (pid < 0) { |
334 | sub_info->retval = pid; | 338 | sub_info->retval = pid; |
335 | umh_complete(sub_info); | 339 | umh_complete(sub_info); |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 10a8faa1b0d4..bcd214e4b4d6 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -2366,8 +2366,15 @@ void wake_up_new_task(struct task_struct *p) | |||
2366 | trace_sched_wakeup_new(p); | 2366 | trace_sched_wakeup_new(p); |
2367 | check_preempt_curr(rq, p, WF_FORK); | 2367 | check_preempt_curr(rq, p, WF_FORK); |
2368 | #ifdef CONFIG_SMP | 2368 | #ifdef CONFIG_SMP |
2369 | if (p->sched_class->task_woken) | 2369 | if (p->sched_class->task_woken) { |
2370 | /* | ||
2371 | * Nothing relies on rq->lock after this, so its fine to | ||
2372 | * drop it. | ||
2373 | */ | ||
2374 | lockdep_unpin_lock(&rq->lock); | ||
2370 | p->sched_class->task_woken(rq, p); | 2375 | p->sched_class->task_woken(rq, p); |
2376 | lockdep_pin_lock(&rq->lock); | ||
2377 | } | ||
2371 | #endif | 2378 | #endif |
2372 | task_rq_unlock(rq, p, &flags); | 2379 | task_rq_unlock(rq, p, &flags); |
2373 | } | 2380 | } |
@@ -7238,9 +7245,6 @@ void __init sched_init_smp(void) | |||
7238 | alloc_cpumask_var(&non_isolated_cpus, GFP_KERNEL); | 7245 | alloc_cpumask_var(&non_isolated_cpus, GFP_KERNEL); |
7239 | alloc_cpumask_var(&fallback_doms, GFP_KERNEL); | 7246 | alloc_cpumask_var(&fallback_doms, GFP_KERNEL); |
7240 | 7247 | ||
7241 | /* nohz_full won't take effect without isolating the cpus. */ | ||
7242 | tick_nohz_full_add_cpus_to(cpu_isolated_map); | ||
7243 | |||
7244 | sched_init_numa(); | 7248 | sched_init_numa(); |
7245 | 7249 | ||
7246 | /* | 7250 | /* |
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index fc8f01083527..8b0a15e285f9 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c | |||
@@ -668,8 +668,15 @@ static enum hrtimer_restart dl_task_timer(struct hrtimer *timer) | |||
668 | * Queueing this task back might have overloaded rq, check if we need | 668 | * Queueing this task back might have overloaded rq, check if we need |
669 | * to kick someone away. | 669 | * to kick someone away. |
670 | */ | 670 | */ |
671 | if (has_pushable_dl_tasks(rq)) | 671 | if (has_pushable_dl_tasks(rq)) { |
672 | /* | ||
673 | * Nothing relies on rq->lock after this, so its safe to drop | ||
674 | * rq->lock. | ||
675 | */ | ||
676 | lockdep_unpin_lock(&rq->lock); | ||
672 | push_dl_task(rq); | 677 | push_dl_task(rq); |
678 | lockdep_pin_lock(&rq->lock); | ||
679 | } | ||
673 | #endif | 680 | #endif |
674 | 681 | ||
675 | unlock: | 682 | unlock: |
@@ -1066,8 +1073,9 @@ select_task_rq_dl(struct task_struct *p, int cpu, int sd_flag, int flags) | |||
1066 | int target = find_later_rq(p); | 1073 | int target = find_later_rq(p); |
1067 | 1074 | ||
1068 | if (target != -1 && | 1075 | if (target != -1 && |
1069 | dl_time_before(p->dl.deadline, | 1076 | (dl_time_before(p->dl.deadline, |
1070 | cpu_rq(target)->dl.earliest_dl.curr)) | 1077 | cpu_rq(target)->dl.earliest_dl.curr) || |
1078 | (cpu_rq(target)->dl.dl_nr_running == 0))) | ||
1071 | cpu = target; | 1079 | cpu = target; |
1072 | } | 1080 | } |
1073 | rcu_read_unlock(); | 1081 | rcu_read_unlock(); |
@@ -1417,7 +1425,8 @@ static struct rq *find_lock_later_rq(struct task_struct *task, struct rq *rq) | |||
1417 | 1425 | ||
1418 | later_rq = cpu_rq(cpu); | 1426 | later_rq = cpu_rq(cpu); |
1419 | 1427 | ||
1420 | if (!dl_time_before(task->dl.deadline, | 1428 | if (later_rq->dl.dl_nr_running && |
1429 | !dl_time_before(task->dl.deadline, | ||
1421 | later_rq->dl.earliest_dl.curr)) { | 1430 | later_rq->dl.earliest_dl.curr)) { |
1422 | /* | 1431 | /* |
1423 | * Target rq has tasks of equal or earlier deadline, | 1432 | * Target rq has tasks of equal or earlier deadline, |
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6e2e3483b1ec..9a5e60fe721a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -2363,7 +2363,7 @@ static inline long calc_tg_weight(struct task_group *tg, struct cfs_rq *cfs_rq) | |||
2363 | */ | 2363 | */ |
2364 | tg_weight = atomic_long_read(&tg->load_avg); | 2364 | tg_weight = atomic_long_read(&tg->load_avg); |
2365 | tg_weight -= cfs_rq->tg_load_avg_contrib; | 2365 | tg_weight -= cfs_rq->tg_load_avg_contrib; |
2366 | tg_weight += cfs_rq_load_avg(cfs_rq); | 2366 | tg_weight += cfs_rq->load.weight; |
2367 | 2367 | ||
2368 | return tg_weight; | 2368 | return tg_weight; |
2369 | } | 2369 | } |
@@ -2373,7 +2373,7 @@ static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg) | |||
2373 | long tg_weight, load, shares; | 2373 | long tg_weight, load, shares; |
2374 | 2374 | ||
2375 | tg_weight = calc_tg_weight(tg, cfs_rq); | 2375 | tg_weight = calc_tg_weight(tg, cfs_rq); |
2376 | load = cfs_rq_load_avg(cfs_rq); | 2376 | load = cfs_rq->load.weight; |
2377 | 2377 | ||
2378 | shares = (tg->shares * load); | 2378 | shares = (tg->shares * load); |
2379 | if (tg_weight) | 2379 | if (tg_weight) |
@@ -2664,13 +2664,14 @@ static inline u64 cfs_rq_clock_task(struct cfs_rq *cfs_rq); | |||
2664 | /* Group cfs_rq's load_avg is used for task_h_load and update_cfs_share */ | 2664 | /* Group cfs_rq's load_avg is used for task_h_load and update_cfs_share */ |
2665 | static inline int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) | 2665 | static inline int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) |
2666 | { | 2666 | { |
2667 | int decayed; | ||
2668 | struct sched_avg *sa = &cfs_rq->avg; | 2667 | struct sched_avg *sa = &cfs_rq->avg; |
2668 | int decayed, removed = 0; | ||
2669 | 2669 | ||
2670 | if (atomic_long_read(&cfs_rq->removed_load_avg)) { | 2670 | if (atomic_long_read(&cfs_rq->removed_load_avg)) { |
2671 | long r = atomic_long_xchg(&cfs_rq->removed_load_avg, 0); | 2671 | long r = atomic_long_xchg(&cfs_rq->removed_load_avg, 0); |
2672 | sa->load_avg = max_t(long, sa->load_avg - r, 0); | 2672 | sa->load_avg = max_t(long, sa->load_avg - r, 0); |
2673 | sa->load_sum = max_t(s64, sa->load_sum - r * LOAD_AVG_MAX, 0); | 2673 | sa->load_sum = max_t(s64, sa->load_sum - r * LOAD_AVG_MAX, 0); |
2674 | removed = 1; | ||
2674 | } | 2675 | } |
2675 | 2676 | ||
2676 | if (atomic_long_read(&cfs_rq->removed_util_avg)) { | 2677 | if (atomic_long_read(&cfs_rq->removed_util_avg)) { |
@@ -2688,7 +2689,7 @@ static inline int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) | |||
2688 | cfs_rq->load_last_update_time_copy = sa->last_update_time; | 2689 | cfs_rq->load_last_update_time_copy = sa->last_update_time; |
2689 | #endif | 2690 | #endif |
2690 | 2691 | ||
2691 | return decayed; | 2692 | return decayed || removed; |
2692 | } | 2693 | } |
2693 | 2694 | ||
2694 | /* Update task and its cfs_rq load average */ | 2695 | /* Update task and its cfs_rq load average */ |
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 8f177c73ae19..4a2ef5a02fd3 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c | |||
@@ -57,9 +57,11 @@ static inline int cpu_idle_poll(void) | |||
57 | rcu_idle_enter(); | 57 | rcu_idle_enter(); |
58 | trace_cpu_idle_rcuidle(0, smp_processor_id()); | 58 | trace_cpu_idle_rcuidle(0, smp_processor_id()); |
59 | local_irq_enable(); | 59 | local_irq_enable(); |
60 | stop_critical_timings(); | ||
60 | while (!tif_need_resched() && | 61 | while (!tif_need_resched() && |
61 | (cpu_idle_force_poll || tick_check_broadcast_expired())) | 62 | (cpu_idle_force_poll || tick_check_broadcast_expired())) |
62 | cpu_relax(); | 63 | cpu_relax(); |
64 | start_critical_timings(); | ||
63 | trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); | 65 | trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); |
64 | rcu_idle_exit(); | 66 | rcu_idle_exit(); |
65 | return 1; | 67 | return 1; |
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c index b746399ab59c..8abf1ba18085 100644 --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c | |||
@@ -85,9 +85,19 @@ check_stack(unsigned long ip, unsigned long *stack) | |||
85 | if (!object_is_on_stack(stack)) | 85 | if (!object_is_on_stack(stack)) |
86 | return; | 86 | return; |
87 | 87 | ||
88 | /* Can't do this from NMI context (can cause deadlocks) */ | ||
89 | if (in_nmi()) | ||
90 | return; | ||
91 | |||
88 | local_irq_save(flags); | 92 | local_irq_save(flags); |
89 | arch_spin_lock(&max_stack_lock); | 93 | arch_spin_lock(&max_stack_lock); |
90 | 94 | ||
95 | /* | ||
96 | * RCU may not be watching, make it see us. | ||
97 | * The stack trace code uses rcu_sched. | ||
98 | */ | ||
99 | rcu_irq_enter(); | ||
100 | |||
91 | /* In case another CPU set the tracer_frame on us */ | 101 | /* In case another CPU set the tracer_frame on us */ |
92 | if (unlikely(!frame_size)) | 102 | if (unlikely(!frame_size)) |
93 | this_size -= tracer_frame; | 103 | this_size -= tracer_frame; |
@@ -169,6 +179,7 @@ check_stack(unsigned long ip, unsigned long *stack) | |||
169 | } | 179 | } |
170 | 180 | ||
171 | out: | 181 | out: |
182 | rcu_irq_exit(); | ||
172 | arch_spin_unlock(&max_stack_lock); | 183 | arch_spin_unlock(&max_stack_lock); |
173 | local_irq_restore(flags); | 184 | local_irq_restore(flags); |
174 | } | 185 | } |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ab76b99adc85..1d1521c26302 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -197,6 +197,7 @@ config ENABLE_MUST_CHECK | |||
197 | config FRAME_WARN | 197 | config FRAME_WARN |
198 | int "Warn for stack frames larger than (needs gcc 4.4)" | 198 | int "Warn for stack frames larger than (needs gcc 4.4)" |
199 | range 0 8192 | 199 | range 0 8192 |
200 | default 0 if KASAN | ||
200 | default 1024 if !64BIT | 201 | default 1024 if !64BIT |
201 | default 2048 if 64BIT | 202 | default 2048 if 64BIT |
202 | help | 203 | help |
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index f1cdeb024d17..6a823a53e357 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c | |||
@@ -44,7 +44,7 @@ static void fail_dump(struct fault_attr *attr) | |||
44 | printk(KERN_NOTICE "FAULT_INJECTION: forcing a failure.\n" | 44 | printk(KERN_NOTICE "FAULT_INJECTION: forcing a failure.\n" |
45 | "name %pd, interval %lu, probability %lu, " | 45 | "name %pd, interval %lu, probability %lu, " |
46 | "space %d, times %d\n", attr->dname, | 46 | "space %d, times %d\n", attr->dname, |
47 | attr->probability, attr->interval, | 47 | attr->interval, attr->probability, |
48 | atomic_read(&attr->space), | 48 | atomic_read(&attr->space), |
49 | atomic_read(&attr->times)); | 49 | atomic_read(&attr->times)); |
50 | if (attr->verbose > 1) | 50 | if (attr->verbose > 1) |
diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 2df8ddcb0ca0..619984fc07ec 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c | |||
@@ -480,6 +480,10 @@ static void cgwb_release_workfn(struct work_struct *work) | |||
480 | release_work); | 480 | release_work); |
481 | struct backing_dev_info *bdi = wb->bdi; | 481 | struct backing_dev_info *bdi = wb->bdi; |
482 | 482 | ||
483 | spin_lock_irq(&cgwb_lock); | ||
484 | list_del_rcu(&wb->bdi_node); | ||
485 | spin_unlock_irq(&cgwb_lock); | ||
486 | |||
483 | wb_shutdown(wb); | 487 | wb_shutdown(wb); |
484 | 488 | ||
485 | css_put(wb->memcg_css); | 489 | css_put(wb->memcg_css); |
@@ -575,6 +579,7 @@ static int cgwb_create(struct backing_dev_info *bdi, | |||
575 | ret = radix_tree_insert(&bdi->cgwb_tree, memcg_css->id, wb); | 579 | ret = radix_tree_insert(&bdi->cgwb_tree, memcg_css->id, wb); |
576 | if (!ret) { | 580 | if (!ret) { |
577 | atomic_inc(&bdi->usage_cnt); | 581 | atomic_inc(&bdi->usage_cnt); |
582 | list_add_tail_rcu(&wb->bdi_node, &bdi->wb_list); | ||
578 | list_add(&wb->memcg_node, memcg_cgwb_list); | 583 | list_add(&wb->memcg_node, memcg_cgwb_list); |
579 | list_add(&wb->blkcg_node, blkcg_cgwb_list); | 584 | list_add(&wb->blkcg_node, blkcg_cgwb_list); |
580 | css_get(memcg_css); | 585 | css_get(memcg_css); |
@@ -676,7 +681,7 @@ static int cgwb_bdi_init(struct backing_dev_info *bdi) | |||
676 | static void cgwb_bdi_destroy(struct backing_dev_info *bdi) | 681 | static void cgwb_bdi_destroy(struct backing_dev_info *bdi) |
677 | { | 682 | { |
678 | struct radix_tree_iter iter; | 683 | struct radix_tree_iter iter; |
679 | struct bdi_writeback_congested *congested, *congested_n; | 684 | struct rb_node *rbn; |
680 | void **slot; | 685 | void **slot; |
681 | 686 | ||
682 | WARN_ON(test_bit(WB_registered, &bdi->wb.state)); | 687 | WARN_ON(test_bit(WB_registered, &bdi->wb.state)); |
@@ -686,9 +691,11 @@ static void cgwb_bdi_destroy(struct backing_dev_info *bdi) | |||
686 | radix_tree_for_each_slot(slot, &bdi->cgwb_tree, &iter, 0) | 691 | radix_tree_for_each_slot(slot, &bdi->cgwb_tree, &iter, 0) |
687 | cgwb_kill(*slot); | 692 | cgwb_kill(*slot); |
688 | 693 | ||
689 | rbtree_postorder_for_each_entry_safe(congested, congested_n, | 694 | while ((rbn = rb_first(&bdi->cgwb_congested_tree))) { |
690 | &bdi->cgwb_congested_tree, rb_node) { | 695 | struct bdi_writeback_congested *congested = |
691 | rb_erase(&congested->rb_node, &bdi->cgwb_congested_tree); | 696 | rb_entry(rbn, struct bdi_writeback_congested, rb_node); |
697 | |||
698 | rb_erase(rbn, &bdi->cgwb_congested_tree); | ||
692 | congested->bdi = NULL; /* mark @congested unlinked */ | 699 | congested->bdi = NULL; /* mark @congested unlinked */ |
693 | } | 700 | } |
694 | 701 | ||
@@ -764,15 +771,22 @@ static void cgwb_bdi_destroy(struct backing_dev_info *bdi) { } | |||
764 | 771 | ||
765 | int bdi_init(struct backing_dev_info *bdi) | 772 | int bdi_init(struct backing_dev_info *bdi) |
766 | { | 773 | { |
774 | int ret; | ||
775 | |||
767 | bdi->dev = NULL; | 776 | bdi->dev = NULL; |
768 | 777 | ||
769 | bdi->min_ratio = 0; | 778 | bdi->min_ratio = 0; |
770 | bdi->max_ratio = 100; | 779 | bdi->max_ratio = 100; |
771 | bdi->max_prop_frac = FPROP_FRAC_BASE; | 780 | bdi->max_prop_frac = FPROP_FRAC_BASE; |
772 | INIT_LIST_HEAD(&bdi->bdi_list); | 781 | INIT_LIST_HEAD(&bdi->bdi_list); |
782 | INIT_LIST_HEAD(&bdi->wb_list); | ||
773 | init_waitqueue_head(&bdi->wb_waitq); | 783 | init_waitqueue_head(&bdi->wb_waitq); |
774 | 784 | ||
775 | return cgwb_bdi_init(bdi); | 785 | ret = cgwb_bdi_init(bdi); |
786 | |||
787 | list_add_tail_rcu(&bdi->wb.bdi_node, &bdi->wb_list); | ||
788 | |||
789 | return ret; | ||
776 | } | 790 | } |
777 | EXPORT_SYMBOL(bdi_init); | 791 | EXPORT_SYMBOL(bdi_init); |
778 | 792 | ||
@@ -823,7 +837,7 @@ static void bdi_remove_from_list(struct backing_dev_info *bdi) | |||
823 | synchronize_rcu_expedited(); | 837 | synchronize_rcu_expedited(); |
824 | } | 838 | } |
825 | 839 | ||
826 | void bdi_destroy(struct backing_dev_info *bdi) | 840 | void bdi_unregister(struct backing_dev_info *bdi) |
827 | { | 841 | { |
828 | /* make sure nobody finds us on the bdi_list anymore */ | 842 | /* make sure nobody finds us on the bdi_list anymore */ |
829 | bdi_remove_from_list(bdi); | 843 | bdi_remove_from_list(bdi); |
@@ -835,9 +849,19 @@ void bdi_destroy(struct backing_dev_info *bdi) | |||
835 | device_unregister(bdi->dev); | 849 | device_unregister(bdi->dev); |
836 | bdi->dev = NULL; | 850 | bdi->dev = NULL; |
837 | } | 851 | } |
852 | } | ||
838 | 853 | ||
854 | void bdi_exit(struct backing_dev_info *bdi) | ||
855 | { | ||
856 | WARN_ON_ONCE(bdi->dev); | ||
839 | wb_exit(&bdi->wb); | 857 | wb_exit(&bdi->wb); |
840 | } | 858 | } |
859 | |||
860 | void bdi_destroy(struct backing_dev_info *bdi) | ||
861 | { | ||
862 | bdi_unregister(bdi); | ||
863 | bdi_exit(bdi); | ||
864 | } | ||
841 | EXPORT_SYMBOL(bdi_destroy); | 865 | EXPORT_SYMBOL(bdi_destroy); |
842 | 866 | ||
843 | /* | 867 | /* |
@@ -361,7 +361,7 @@ err: | |||
361 | * This function allocates part of contiguous memory on specific | 361 | * This function allocates part of contiguous memory on specific |
362 | * contiguous memory area. | 362 | * contiguous memory area. |
363 | */ | 363 | */ |
364 | struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align) | 364 | struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align) |
365 | { | 365 | { |
366 | unsigned long mask, offset, pfn, start = 0; | 366 | unsigned long mask, offset, pfn, start = 0; |
367 | unsigned long bitmap_maxno, bitmap_no, bitmap_count; | 367 | unsigned long bitmap_maxno, bitmap_no, bitmap_count; |
@@ -371,7 +371,7 @@ struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align) | |||
371 | if (!cma || !cma->count) | 371 | if (!cma || !cma->count) |
372 | return NULL; | 372 | return NULL; |
373 | 373 | ||
374 | pr_debug("%s(cma %p, count %d, align %d)\n", __func__, (void *)cma, | 374 | pr_debug("%s(cma %p, count %zu, align %d)\n", __func__, (void *)cma, |
375 | count, align); | 375 | count, align); |
376 | 376 | ||
377 | if (!count) | 377 | if (!count) |
diff --git a/mm/filemap.c b/mm/filemap.c index 1cc5467cf36c..327910c2400c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -2488,6 +2488,11 @@ again: | |||
2488 | break; | 2488 | break; |
2489 | } | 2489 | } |
2490 | 2490 | ||
2491 | if (fatal_signal_pending(current)) { | ||
2492 | status = -EINTR; | ||
2493 | break; | ||
2494 | } | ||
2495 | |||
2491 | status = a_ops->write_begin(file, mapping, pos, bytes, flags, | 2496 | status = a_ops->write_begin(file, mapping, pos, bytes, flags, |
2492 | &page, &fsdata); | 2497 | &page, &fsdata); |
2493 | if (unlikely(status < 0)) | 2498 | if (unlikely(status < 0)) |
@@ -2525,10 +2530,6 @@ again: | |||
2525 | written += copied; | 2530 | written += copied; |
2526 | 2531 | ||
2527 | balance_dirty_pages_ratelimited(mapping); | 2532 | balance_dirty_pages_ratelimited(mapping); |
2528 | if (fatal_signal_pending(current)) { | ||
2529 | status = -EINTR; | ||
2530 | break; | ||
2531 | } | ||
2532 | } while (iov_iter_count(i)); | 2533 | } while (iov_iter_count(i)); |
2533 | 2534 | ||
2534 | return written ? written : status; | 2535 | return written ? written : status; |
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 4b06b8db9df2..bbac913f96bc 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -2206,7 +2206,8 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, | |||
2206 | for (_pte = pte; _pte < pte+HPAGE_PMD_NR; | 2206 | for (_pte = pte; _pte < pte+HPAGE_PMD_NR; |
2207 | _pte++, address += PAGE_SIZE) { | 2207 | _pte++, address += PAGE_SIZE) { |
2208 | pte_t pteval = *_pte; | 2208 | pte_t pteval = *_pte; |
2209 | if (pte_none(pteval) || is_zero_pfn(pte_pfn(pteval))) { | 2209 | if (pte_none(pteval) || (pte_present(pteval) && |
2210 | is_zero_pfn(pte_pfn(pteval)))) { | ||
2210 | if (!userfaultfd_armed(vma) && | 2211 | if (!userfaultfd_armed(vma) && |
2211 | ++none_or_zero <= khugepaged_max_ptes_none) | 2212 | ++none_or_zero <= khugepaged_max_ptes_none) |
2212 | continue; | 2213 | continue; |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index d9b5c817dce8..c57c4423c688 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -3741,44 +3741,43 @@ struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb) | |||
3741 | /** | 3741 | /** |
3742 | * mem_cgroup_wb_stats - retrieve writeback related stats from its memcg | 3742 | * mem_cgroup_wb_stats - retrieve writeback related stats from its memcg |
3743 | * @wb: bdi_writeback in question | 3743 | * @wb: bdi_writeback in question |
3744 | * @pavail: out parameter for number of available pages | 3744 | * @pfilepages: out parameter for number of file pages |
3745 | * @pheadroom: out parameter for number of allocatable pages according to memcg | ||
3745 | * @pdirty: out parameter for number of dirty pages | 3746 | * @pdirty: out parameter for number of dirty pages |
3746 | * @pwriteback: out parameter for number of pages under writeback | 3747 | * @pwriteback: out parameter for number of pages under writeback |
3747 | * | 3748 | * |
3748 | * Determine the numbers of available, dirty, and writeback pages in @wb's | 3749 | * Determine the numbers of file, headroom, dirty, and writeback pages in |
3749 | * memcg. Dirty and writeback are self-explanatory. Available is a bit | 3750 | * @wb's memcg. File, dirty and writeback are self-explanatory. Headroom |
3750 | * more involved. | 3751 | * is a bit more involved. |
3751 | * | 3752 | * |
3752 | * A memcg's headroom is "min(max, high) - used". The available memory is | 3753 | * A memcg's headroom is "min(max, high) - used". In the hierarchy, the |
3753 | * calculated as the lowest headroom of itself and the ancestors plus the | 3754 | * headroom is calculated as the lowest headroom of itself and the |
3754 | * number of pages already being used for file pages. Note that this | 3755 | * ancestors. Note that this doesn't consider the actual amount of |
3755 | * doesn't consider the actual amount of available memory in the system. | 3756 | * available memory in the system. The caller should further cap |
3756 | * The caller should further cap *@pavail accordingly. | 3757 | * *@pheadroom accordingly. |
3757 | */ | 3758 | */ |
3758 | void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pavail, | 3759 | void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages, |
3759 | unsigned long *pdirty, unsigned long *pwriteback) | 3760 | unsigned long *pheadroom, unsigned long *pdirty, |
3761 | unsigned long *pwriteback) | ||
3760 | { | 3762 | { |
3761 | struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css); | 3763 | struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css); |
3762 | struct mem_cgroup *parent; | 3764 | struct mem_cgroup *parent; |
3763 | unsigned long head_room = PAGE_COUNTER_MAX; | ||
3764 | unsigned long file_pages; | ||
3765 | 3765 | ||
3766 | *pdirty = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_DIRTY); | 3766 | *pdirty = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_DIRTY); |
3767 | 3767 | ||
3768 | /* this should eventually include NR_UNSTABLE_NFS */ | 3768 | /* this should eventually include NR_UNSTABLE_NFS */ |
3769 | *pwriteback = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_WRITEBACK); | 3769 | *pwriteback = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_WRITEBACK); |
3770 | *pfilepages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) | | ||
3771 | (1 << LRU_ACTIVE_FILE)); | ||
3772 | *pheadroom = PAGE_COUNTER_MAX; | ||
3770 | 3773 | ||
3771 | file_pages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) | | ||
3772 | (1 << LRU_ACTIVE_FILE)); | ||
3773 | while ((parent = parent_mem_cgroup(memcg))) { | 3774 | while ((parent = parent_mem_cgroup(memcg))) { |
3774 | unsigned long ceiling = min(memcg->memory.limit, memcg->high); | 3775 | unsigned long ceiling = min(memcg->memory.limit, memcg->high); |
3775 | unsigned long used = page_counter_read(&memcg->memory); | 3776 | unsigned long used = page_counter_read(&memcg->memory); |
3776 | 3777 | ||
3777 | head_room = min(head_room, ceiling - min(ceiling, used)); | 3778 | *pheadroom = min(*pheadroom, ceiling - min(ceiling, used)); |
3778 | memcg = parent; | 3779 | memcg = parent; |
3779 | } | 3780 | } |
3780 | |||
3781 | *pavail = file_pages + head_room; | ||
3782 | } | 3781 | } |
3783 | 3782 | ||
3784 | #else /* CONFIG_CGROUP_WRITEBACK */ | 3783 | #else /* CONFIG_CGROUP_WRITEBACK */ |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 0a931cdd4f6b..2c90357c34ea 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -145,9 +145,6 @@ struct dirty_throttle_control { | |||
145 | unsigned long pos_ratio; | 145 | unsigned long pos_ratio; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | #define DTC_INIT_COMMON(__wb) .wb = (__wb), \ | ||
149 | .wb_completions = &(__wb)->completions | ||
150 | |||
151 | /* | 148 | /* |
152 | * Length of period for aging writeout fractions of bdis. This is an | 149 | * Length of period for aging writeout fractions of bdis. This is an |
153 | * arbitrarily chosen number. The longer the period, the slower fractions will | 150 | * arbitrarily chosen number. The longer the period, the slower fractions will |
@@ -157,12 +154,16 @@ struct dirty_throttle_control { | |||
157 | 154 | ||
158 | #ifdef CONFIG_CGROUP_WRITEBACK | 155 | #ifdef CONFIG_CGROUP_WRITEBACK |
159 | 156 | ||
160 | #define GDTC_INIT(__wb) .dom = &global_wb_domain, \ | 157 | #define GDTC_INIT(__wb) .wb = (__wb), \ |
161 | DTC_INIT_COMMON(__wb) | 158 | .dom = &global_wb_domain, \ |
159 | .wb_completions = &(__wb)->completions | ||
160 | |||
162 | #define GDTC_INIT_NO_WB .dom = &global_wb_domain | 161 | #define GDTC_INIT_NO_WB .dom = &global_wb_domain |
163 | #define MDTC_INIT(__wb, __gdtc) .dom = mem_cgroup_wb_domain(__wb), \ | 162 | |
164 | .gdtc = __gdtc, \ | 163 | #define MDTC_INIT(__wb, __gdtc) .wb = (__wb), \ |
165 | DTC_INIT_COMMON(__wb) | 164 | .dom = mem_cgroup_wb_domain(__wb), \ |
165 | .wb_completions = &(__wb)->memcg_completions, \ | ||
166 | .gdtc = __gdtc | ||
166 | 167 | ||
167 | static bool mdtc_valid(struct dirty_throttle_control *dtc) | 168 | static bool mdtc_valid(struct dirty_throttle_control *dtc) |
168 | { | 169 | { |
@@ -213,7 +214,8 @@ static void wb_min_max_ratio(struct bdi_writeback *wb, | |||
213 | 214 | ||
214 | #else /* CONFIG_CGROUP_WRITEBACK */ | 215 | #else /* CONFIG_CGROUP_WRITEBACK */ |
215 | 216 | ||
216 | #define GDTC_INIT(__wb) DTC_INIT_COMMON(__wb) | 217 | #define GDTC_INIT(__wb) .wb = (__wb), \ |
218 | .wb_completions = &(__wb)->completions | ||
217 | #define GDTC_INIT_NO_WB | 219 | #define GDTC_INIT_NO_WB |
218 | #define MDTC_INIT(__wb, __gdtc) | 220 | #define MDTC_INIT(__wb, __gdtc) |
219 | 221 | ||
@@ -682,13 +684,19 @@ static unsigned long hard_dirty_limit(struct wb_domain *dom, | |||
682 | return max(thresh, dom->dirty_limit); | 684 | return max(thresh, dom->dirty_limit); |
683 | } | 685 | } |
684 | 686 | ||
685 | /* memory available to a memcg domain is capped by system-wide clean memory */ | 687 | /* |
686 | static void mdtc_cap_avail(struct dirty_throttle_control *mdtc) | 688 | * Memory which can be further allocated to a memcg domain is capped by |
689 | * system-wide clean memory excluding the amount being used in the domain. | ||
690 | */ | ||
691 | static void mdtc_calc_avail(struct dirty_throttle_control *mdtc, | ||
692 | unsigned long filepages, unsigned long headroom) | ||
687 | { | 693 | { |
688 | struct dirty_throttle_control *gdtc = mdtc_gdtc(mdtc); | 694 | struct dirty_throttle_control *gdtc = mdtc_gdtc(mdtc); |
689 | unsigned long clean = gdtc->avail - min(gdtc->avail, gdtc->dirty); | 695 | unsigned long clean = filepages - min(filepages, mdtc->dirty); |
696 | unsigned long global_clean = gdtc->avail - min(gdtc->avail, gdtc->dirty); | ||
697 | unsigned long other_clean = global_clean - min(global_clean, clean); | ||
690 | 698 | ||
691 | mdtc->avail = min(mdtc->avail, clean); | 699 | mdtc->avail = filepages + min(headroom, other_clean); |
692 | } | 700 | } |
693 | 701 | ||
694 | /** | 702 | /** |
@@ -1562,16 +1570,16 @@ static void balance_dirty_pages(struct address_space *mapping, | |||
1562 | } | 1570 | } |
1563 | 1571 | ||
1564 | if (mdtc) { | 1572 | if (mdtc) { |
1565 | unsigned long writeback; | 1573 | unsigned long filepages, headroom, writeback; |
1566 | 1574 | ||
1567 | /* | 1575 | /* |
1568 | * If @wb belongs to !root memcg, repeat the same | 1576 | * If @wb belongs to !root memcg, repeat the same |
1569 | * basic calculations for the memcg domain. | 1577 | * basic calculations for the memcg domain. |
1570 | */ | 1578 | */ |
1571 | mem_cgroup_wb_stats(wb, &mdtc->avail, &mdtc->dirty, | 1579 | mem_cgroup_wb_stats(wb, &filepages, &headroom, |
1572 | &writeback); | 1580 | &mdtc->dirty, &writeback); |
1573 | mdtc_cap_avail(mdtc); | ||
1574 | mdtc->dirty += writeback; | 1581 | mdtc->dirty += writeback; |
1582 | mdtc_calc_avail(mdtc, filepages, headroom); | ||
1575 | 1583 | ||
1576 | domain_dirty_limits(mdtc); | 1584 | domain_dirty_limits(mdtc); |
1577 | 1585 | ||
@@ -1893,10 +1901,11 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb) | |||
1893 | return true; | 1901 | return true; |
1894 | 1902 | ||
1895 | if (mdtc) { | 1903 | if (mdtc) { |
1896 | unsigned long writeback; | 1904 | unsigned long filepages, headroom, writeback; |
1897 | 1905 | ||
1898 | mem_cgroup_wb_stats(wb, &mdtc->avail, &mdtc->dirty, &writeback); | 1906 | mem_cgroup_wb_stats(wb, &filepages, &headroom, &mdtc->dirty, |
1899 | mdtc_cap_avail(mdtc); | 1907 | &writeback); |
1908 | mdtc_calc_avail(mdtc, filepages, headroom); | ||
1900 | domain_dirty_limits(mdtc); /* ditto, ignore writeback */ | 1909 | domain_dirty_limits(mdtc); /* ditto, ignore writeback */ |
1901 | 1910 | ||
1902 | if (mdtc->dirty > mdtc->bg_thresh) | 1911 | if (mdtc->dirty > mdtc->bg_thresh) |
@@ -1956,7 +1965,6 @@ void laptop_mode_timer_fn(unsigned long data) | |||
1956 | int nr_pages = global_page_state(NR_FILE_DIRTY) + | 1965 | int nr_pages = global_page_state(NR_FILE_DIRTY) + |
1957 | global_page_state(NR_UNSTABLE_NFS); | 1966 | global_page_state(NR_UNSTABLE_NFS); |
1958 | struct bdi_writeback *wb; | 1967 | struct bdi_writeback *wb; |
1959 | struct wb_iter iter; | ||
1960 | 1968 | ||
1961 | /* | 1969 | /* |
1962 | * We want to write everything out, not just down to the dirty | 1970 | * We want to write everything out, not just down to the dirty |
@@ -1965,10 +1973,12 @@ void laptop_mode_timer_fn(unsigned long data) | |||
1965 | if (!bdi_has_dirty_io(&q->backing_dev_info)) | 1973 | if (!bdi_has_dirty_io(&q->backing_dev_info)) |
1966 | return; | 1974 | return; |
1967 | 1975 | ||
1968 | bdi_for_each_wb(wb, &q->backing_dev_info, &iter, 0) | 1976 | rcu_read_lock(); |
1977 | list_for_each_entry_rcu(wb, &q->backing_dev_info.wb_list, bdi_node) | ||
1969 | if (wb_has_dirty_io(wb)) | 1978 | if (wb_has_dirty_io(wb)) |
1970 | wb_start_writeback(wb, nr_pages, true, | 1979 | wb_start_writeback(wb, nr_pages, true, |
1971 | WB_REASON_LAPTOP_TIMER); | 1980 | WB_REASON_LAPTOP_TIMER); |
1981 | rcu_read_unlock(); | ||
1972 | } | 1982 | } |
1973 | 1983 | ||
1974 | /* | 1984 | /* |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index b4548c739a64..2dda439c8cb8 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -91,10 +91,50 @@ static void hci_connect_le_scan_cleanup(struct hci_conn *conn) | |||
91 | * autoconnect action, remove them completely. If they are, just unmark | 91 | * autoconnect action, remove them completely. If they are, just unmark |
92 | * them as waiting for connection, by clearing explicit_connect field. | 92 | * them as waiting for connection, by clearing explicit_connect field. |
93 | */ | 93 | */ |
94 | if (params->auto_connect == HCI_AUTO_CONN_EXPLICIT) | 94 | params->explicit_connect = false; |
95 | |||
96 | list_del_init(¶ms->action); | ||
97 | |||
98 | switch (params->auto_connect) { | ||
99 | case HCI_AUTO_CONN_EXPLICIT: | ||
95 | hci_conn_params_del(conn->hdev, bdaddr, bdaddr_type); | 100 | hci_conn_params_del(conn->hdev, bdaddr, bdaddr_type); |
96 | else | 101 | /* return instead of break to avoid duplicate scan update */ |
97 | params->explicit_connect = false; | 102 | return; |
103 | case HCI_AUTO_CONN_DIRECT: | ||
104 | case HCI_AUTO_CONN_ALWAYS: | ||
105 | list_add(¶ms->action, &conn->hdev->pend_le_conns); | ||
106 | break; | ||
107 | case HCI_AUTO_CONN_REPORT: | ||
108 | list_add(¶ms->action, &conn->hdev->pend_le_reports); | ||
109 | break; | ||
110 | default: | ||
111 | break; | ||
112 | } | ||
113 | |||
114 | hci_update_background_scan(conn->hdev); | ||
115 | } | ||
116 | |||
117 | static void hci_conn_cleanup(struct hci_conn *conn) | ||
118 | { | ||
119 | struct hci_dev *hdev = conn->hdev; | ||
120 | |||
121 | if (test_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags)) | ||
122 | hci_conn_params_del(conn->hdev, &conn->dst, conn->dst_type); | ||
123 | |||
124 | hci_chan_list_flush(conn); | ||
125 | |||
126 | hci_conn_hash_del(hdev, conn); | ||
127 | |||
128 | if (hdev->notify) | ||
129 | hdev->notify(hdev, HCI_NOTIFY_CONN_DEL); | ||
130 | |||
131 | hci_conn_del_sysfs(conn); | ||
132 | |||
133 | debugfs_remove_recursive(conn->debugfs); | ||
134 | |||
135 | hci_dev_put(hdev); | ||
136 | |||
137 | hci_conn_put(conn); | ||
98 | } | 138 | } |
99 | 139 | ||
100 | /* This function requires the caller holds hdev->lock */ | 140 | /* This function requires the caller holds hdev->lock */ |
@@ -102,8 +142,13 @@ static void hci_connect_le_scan_remove(struct hci_conn *conn) | |||
102 | { | 142 | { |
103 | hci_connect_le_scan_cleanup(conn); | 143 | hci_connect_le_scan_cleanup(conn); |
104 | 144 | ||
105 | hci_conn_hash_del(conn->hdev, conn); | 145 | /* We can't call hci_conn_del here since that would deadlock |
106 | hci_update_background_scan(conn->hdev); | 146 | * with trying to call cancel_delayed_work_sync(&conn->disc_work). |
147 | * Instead, call just hci_conn_cleanup() which contains the bare | ||
148 | * minimum cleanup operations needed for a connection in this | ||
149 | * state. | ||
150 | */ | ||
151 | hci_conn_cleanup(conn); | ||
107 | } | 152 | } |
108 | 153 | ||
109 | static void hci_acl_create_connection(struct hci_conn *conn) | 154 | static void hci_acl_create_connection(struct hci_conn *conn) |
@@ -581,27 +626,17 @@ int hci_conn_del(struct hci_conn *conn) | |||
581 | } | 626 | } |
582 | } | 627 | } |
583 | 628 | ||
584 | hci_chan_list_flush(conn); | ||
585 | |||
586 | if (conn->amp_mgr) | 629 | if (conn->amp_mgr) |
587 | amp_mgr_put(conn->amp_mgr); | 630 | amp_mgr_put(conn->amp_mgr); |
588 | 631 | ||
589 | hci_conn_hash_del(hdev, conn); | ||
590 | if (hdev->notify) | ||
591 | hdev->notify(hdev, HCI_NOTIFY_CONN_DEL); | ||
592 | |||
593 | skb_queue_purge(&conn->data_q); | 632 | skb_queue_purge(&conn->data_q); |
594 | 633 | ||
595 | hci_conn_del_sysfs(conn); | 634 | /* Remove the connection from the list and cleanup its remaining |
596 | 635 | * state. This is a separate function since for some cases like | |
597 | debugfs_remove_recursive(conn->debugfs); | 636 | * BT_CONNECT_SCAN we *only* want the cleanup part without the |
598 | 637 | * rest of hci_conn_del. | |
599 | if (test_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags)) | 638 | */ |
600 | hci_conn_params_del(conn->hdev, &conn->dst, conn->dst_type); | 639 | hci_conn_cleanup(conn); |
601 | |||
602 | hci_dev_put(hdev); | ||
603 | |||
604 | hci_conn_put(conn); | ||
605 | 640 | ||
606 | return 0; | 641 | return 0; |
607 | } | 642 | } |
@@ -973,15 +1008,23 @@ static int hci_explicit_conn_params_set(struct hci_request *req, | |||
973 | if (is_connected(hdev, addr, addr_type)) | 1008 | if (is_connected(hdev, addr, addr_type)) |
974 | return -EISCONN; | 1009 | return -EISCONN; |
975 | 1010 | ||
976 | params = hci_conn_params_add(hdev, addr, addr_type); | 1011 | params = hci_conn_params_lookup(hdev, addr, addr_type); |
977 | if (!params) | 1012 | if (!params) { |
978 | return -EIO; | 1013 | params = hci_conn_params_add(hdev, addr, addr_type); |
1014 | if (!params) | ||
1015 | return -ENOMEM; | ||
979 | 1016 | ||
980 | /* If we created new params, or existing params were marked as disabled, | 1017 | /* If we created new params, mark them to be deleted in |
981 | * mark them to be used just once to connect. | 1018 | * hci_connect_le_scan_cleanup. It's different case than |
982 | */ | 1019 | * existing disabled params, those will stay after cleanup. |
983 | if (params->auto_connect == HCI_AUTO_CONN_DISABLED) { | 1020 | */ |
984 | params->auto_connect = HCI_AUTO_CONN_EXPLICIT; | 1021 | params->auto_connect = HCI_AUTO_CONN_EXPLICIT; |
1022 | } | ||
1023 | |||
1024 | /* We're trying to connect, so make sure params are at pend_le_conns */ | ||
1025 | if (params->auto_connect == HCI_AUTO_CONN_DISABLED || | ||
1026 | params->auto_connect == HCI_AUTO_CONN_REPORT || | ||
1027 | params->auto_connect == HCI_AUTO_CONN_EXPLICIT) { | ||
985 | list_del_init(¶ms->action); | 1028 | list_del_init(¶ms->action); |
986 | list_add(¶ms->action, &hdev->pend_le_conns); | 1029 | list_add(¶ms->action, &hdev->pend_le_conns); |
987 | } | 1030 | } |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index adcbc74c2432..e837539452fb 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -2861,13 +2861,6 @@ struct hci_conn_params *hci_explicit_connect_lookup(struct hci_dev *hdev, | |||
2861 | return param; | 2861 | return param; |
2862 | } | 2862 | } |
2863 | 2863 | ||
2864 | list_for_each_entry(param, &hdev->pend_le_reports, action) { | ||
2865 | if (bacmp(¶m->addr, addr) == 0 && | ||
2866 | param->addr_type == addr_type && | ||
2867 | param->explicit_connect) | ||
2868 | return param; | ||
2869 | } | ||
2870 | |||
2871 | return NULL; | 2864 | return NULL; |
2872 | } | 2865 | } |
2873 | 2866 | ||
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 186041866315..bc31099d3b5b 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -55,7 +55,12 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) | |||
55 | wake_up_bit(&hdev->flags, HCI_INQUIRY); | 55 | wake_up_bit(&hdev->flags, HCI_INQUIRY); |
56 | 56 | ||
57 | hci_dev_lock(hdev); | 57 | hci_dev_lock(hdev); |
58 | hci_discovery_set_state(hdev, DISCOVERY_STOPPED); | 58 | /* Set discovery state to stopped if we're not doing LE active |
59 | * scanning. | ||
60 | */ | ||
61 | if (!hci_dev_test_flag(hdev, HCI_LE_SCAN) || | ||
62 | hdev->le_scan_type != LE_SCAN_ACTIVE) | ||
63 | hci_discovery_set_state(hdev, DISCOVERY_STOPPED); | ||
59 | hci_dev_unlock(hdev); | 64 | hci_dev_unlock(hdev); |
60 | 65 | ||
61 | hci_conn_check_pending(hdev); | 66 | hci_conn_check_pending(hdev); |
@@ -4648,8 +4653,8 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev, | |||
4648 | /* If we're not connectable only connect devices that we have in | 4653 | /* If we're not connectable only connect devices that we have in |
4649 | * our pend_le_conns list. | 4654 | * our pend_le_conns list. |
4650 | */ | 4655 | */ |
4651 | params = hci_explicit_connect_lookup(hdev, addr, addr_type); | 4656 | params = hci_pend_le_action_lookup(&hdev->pend_le_conns, addr, |
4652 | 4657 | addr_type); | |
4653 | if (!params) | 4658 | if (!params) |
4654 | return NULL; | 4659 | return NULL; |
4655 | 4660 | ||
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index ccaf5a436d8f..c4fe2fee753f 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -3545,6 +3545,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3545 | auth_type); | 3545 | auth_type); |
3546 | } else { | 3546 | } else { |
3547 | u8 addr_type; | 3547 | u8 addr_type; |
3548 | struct hci_conn_params *p; | ||
3548 | 3549 | ||
3549 | /* Convert from L2CAP channel address type to HCI address type | 3550 | /* Convert from L2CAP channel address type to HCI address type |
3550 | */ | 3551 | */ |
@@ -3562,7 +3563,10 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3562 | * If connection parameters already exist, then they | 3563 | * If connection parameters already exist, then they |
3563 | * will be kept and this function does nothing. | 3564 | * will be kept and this function does nothing. |
3564 | */ | 3565 | */ |
3565 | hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type); | 3566 | p = hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type); |
3567 | |||
3568 | if (p->auto_connect == HCI_AUTO_CONN_EXPLICIT) | ||
3569 | p->auto_connect = HCI_AUTO_CONN_DISABLED; | ||
3566 | 3570 | ||
3567 | conn = hci_connect_le_scan(hdev, &cp->addr.bdaddr, | 3571 | conn = hci_connect_le_scan(hdev, &cp->addr.bdaddr, |
3568 | addr_type, sec_level, | 3572 | addr_type, sec_level, |
@@ -6117,14 +6121,21 @@ static int hci_conn_params_set(struct hci_request *req, bdaddr_t *addr, | |||
6117 | __hci_update_background_scan(req); | 6121 | __hci_update_background_scan(req); |
6118 | break; | 6122 | break; |
6119 | case HCI_AUTO_CONN_REPORT: | 6123 | case HCI_AUTO_CONN_REPORT: |
6120 | list_add(¶ms->action, &hdev->pend_le_reports); | 6124 | if (params->explicit_connect) |
6125 | list_add(¶ms->action, &hdev->pend_le_conns); | ||
6126 | else | ||
6127 | list_add(¶ms->action, &hdev->pend_le_reports); | ||
6121 | __hci_update_background_scan(req); | 6128 | __hci_update_background_scan(req); |
6122 | break; | 6129 | break; |
6123 | case HCI_AUTO_CONN_DIRECT: | 6130 | case HCI_AUTO_CONN_DIRECT: |
6124 | case HCI_AUTO_CONN_ALWAYS: | 6131 | case HCI_AUTO_CONN_ALWAYS: |
6125 | if (!is_connected(hdev, addr, addr_type)) { | 6132 | if (!is_connected(hdev, addr, addr_type)) { |
6126 | list_add(¶ms->action, &hdev->pend_le_conns); | 6133 | list_add(¶ms->action, &hdev->pend_le_conns); |
6127 | __hci_update_background_scan(req); | 6134 | /* If we are in scan phase of connecting, we were |
6135 | * already added to pend_le_conns and scanning. | ||
6136 | */ | ||
6137 | if (params->auto_connect != HCI_AUTO_CONN_EXPLICIT) | ||
6138 | __hci_update_background_scan(req); | ||
6128 | } | 6139 | } |
6129 | break; | 6140 | break; |
6130 | } | 6141 | } |
@@ -6379,7 +6390,8 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev, | |||
6379 | goto unlock; | 6390 | goto unlock; |
6380 | } | 6391 | } |
6381 | 6392 | ||
6382 | if (params->auto_connect == HCI_AUTO_CONN_DISABLED) { | 6393 | if (params->auto_connect == HCI_AUTO_CONN_DISABLED || |
6394 | params->auto_connect == HCI_AUTO_CONN_EXPLICIT) { | ||
6383 | err = cmd->cmd_complete(cmd, | 6395 | err = cmd->cmd_complete(cmd, |
6384 | MGMT_STATUS_INVALID_PARAMS); | 6396 | MGMT_STATUS_INVALID_PARAMS); |
6385 | mgmt_pending_remove(cmd); | 6397 | mgmt_pending_remove(cmd); |
@@ -6415,6 +6427,10 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev, | |||
6415 | if (p->auto_connect == HCI_AUTO_CONN_DISABLED) | 6427 | if (p->auto_connect == HCI_AUTO_CONN_DISABLED) |
6416 | continue; | 6428 | continue; |
6417 | device_removed(sk, hdev, &p->addr, p->addr_type); | 6429 | device_removed(sk, hdev, &p->addr, p->addr_type); |
6430 | if (p->explicit_connect) { | ||
6431 | p->auto_connect = HCI_AUTO_CONN_EXPLICIT; | ||
6432 | continue; | ||
6433 | } | ||
6418 | list_del(&p->action); | 6434 | list_del(&p->action); |
6419 | list_del(&p->list); | 6435 | list_del(&p->list); |
6420 | kfree(p); | 6436 | kfree(p); |
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index b495ab1797fa..29edf74846fc 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -1284,7 +1284,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr) | |||
1284 | 1284 | ||
1285 | gstrings.len = ret; | 1285 | gstrings.len = ret; |
1286 | 1286 | ||
1287 | data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER); | 1287 | data = kcalloc(gstrings.len, ETH_GSTRING_LEN, GFP_USER); |
1288 | if (!data) | 1288 | if (!data) |
1289 | return -ENOMEM; | 1289 | return -ENOMEM; |
1290 | 1290 | ||
diff --git a/net/core/filter.c b/net/core/filter.c index 05a04ea87172..bb18c3680001 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -1415,6 +1415,7 @@ static u64 bpf_clone_redirect(u64 r1, u64 ifindex, u64 flags, u64 r4, u64 r5) | |||
1415 | return dev_forward_skb(dev, skb2); | 1415 | return dev_forward_skb(dev, skb2); |
1416 | 1416 | ||
1417 | skb2->dev = dev; | 1417 | skb2->dev = dev; |
1418 | skb_sender_cpu_clear(skb2); | ||
1418 | return dev_queue_xmit(skb2); | 1419 | return dev_queue_xmit(skb2); |
1419 | } | 1420 | } |
1420 | 1421 | ||
@@ -1854,9 +1855,13 @@ int sk_get_filter(struct sock *sk, struct sock_filter __user *ubuf, | |||
1854 | goto out; | 1855 | goto out; |
1855 | 1856 | ||
1856 | /* We're copying the filter that has been originally attached, | 1857 | /* We're copying the filter that has been originally attached, |
1857 | * so no conversion/decode needed anymore. | 1858 | * so no conversion/decode needed anymore. eBPF programs that |
1859 | * have no original program cannot be dumped through this. | ||
1858 | */ | 1860 | */ |
1861 | ret = -EACCES; | ||
1859 | fprog = filter->prog->orig_prog; | 1862 | fprog = filter->prog->orig_prog; |
1863 | if (!fprog) | ||
1864 | goto out; | ||
1860 | 1865 | ||
1861 | ret = fprog->len; | 1866 | ret = fprog->len; |
1862 | if (!len) | 1867 | if (!len) |
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index c59fa5d9c22c..adb5325f4934 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/of_platform.h> | 22 | #include <linux/of_platform.h> |
23 | #include <linux/of_net.h> | 23 | #include <linux/of_net.h> |
24 | #include <linux/sysfs.h> | 24 | #include <linux/sysfs.h> |
25 | #include <linux/phy_fixed.h> | ||
25 | #include "dsa_priv.h" | 26 | #include "dsa_priv.h" |
26 | 27 | ||
27 | char dsa_driver_version[] = "0.1"; | 28 | char dsa_driver_version[] = "0.1"; |
@@ -305,7 +306,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) | |||
305 | if (ret < 0) | 306 | if (ret < 0) |
306 | goto out; | 307 | goto out; |
307 | 308 | ||
308 | ds->slave_mii_bus = mdiobus_alloc(); | 309 | ds->slave_mii_bus = devm_mdiobus_alloc(parent); |
309 | if (ds->slave_mii_bus == NULL) { | 310 | if (ds->slave_mii_bus == NULL) { |
310 | ret = -ENOMEM; | 311 | ret = -ENOMEM; |
311 | goto out; | 312 | goto out; |
@@ -314,7 +315,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) | |||
314 | 315 | ||
315 | ret = mdiobus_register(ds->slave_mii_bus); | 316 | ret = mdiobus_register(ds->slave_mii_bus); |
316 | if (ret < 0) | 317 | if (ret < 0) |
317 | goto out_free; | 318 | goto out; |
318 | 319 | ||
319 | 320 | ||
320 | /* | 321 | /* |
@@ -367,10 +368,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) | |||
367 | 368 | ||
368 | return ret; | 369 | return ret; |
369 | 370 | ||
370 | out_free: | ||
371 | mdiobus_free(ds->slave_mii_bus); | ||
372 | out: | 371 | out: |
373 | kfree(ds); | ||
374 | return ret; | 372 | return ret; |
375 | } | 373 | } |
376 | 374 | ||
@@ -400,7 +398,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, | |||
400 | /* | 398 | /* |
401 | * Allocate and initialise switch state. | 399 | * Allocate and initialise switch state. |
402 | */ | 400 | */ |
403 | ds = kzalloc(sizeof(*ds) + drv->priv_size, GFP_KERNEL); | 401 | ds = devm_kzalloc(parent, sizeof(*ds) + drv->priv_size, GFP_KERNEL); |
404 | if (ds == NULL) | 402 | if (ds == NULL) |
405 | return ERR_PTR(-ENOMEM); | 403 | return ERR_PTR(-ENOMEM); |
406 | 404 | ||
@@ -420,10 +418,47 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, | |||
420 | 418 | ||
421 | static void dsa_switch_destroy(struct dsa_switch *ds) | 419 | static void dsa_switch_destroy(struct dsa_switch *ds) |
422 | { | 420 | { |
421 | struct device_node *port_dn; | ||
422 | struct phy_device *phydev; | ||
423 | struct dsa_chip_data *cd = ds->pd; | ||
424 | int port; | ||
425 | |||
423 | #ifdef CONFIG_NET_DSA_HWMON | 426 | #ifdef CONFIG_NET_DSA_HWMON |
424 | if (ds->hwmon_dev) | 427 | if (ds->hwmon_dev) |
425 | hwmon_device_unregister(ds->hwmon_dev); | 428 | hwmon_device_unregister(ds->hwmon_dev); |
426 | #endif | 429 | #endif |
430 | |||
431 | /* Disable configuration of the CPU and DSA ports */ | ||
432 | for (port = 0; port < DSA_MAX_PORTS; port++) { | ||
433 | if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) | ||
434 | continue; | ||
435 | |||
436 | port_dn = cd->port_dn[port]; | ||
437 | if (of_phy_is_fixed_link(port_dn)) { | ||
438 | phydev = of_phy_find_device(port_dn); | ||
439 | if (phydev) { | ||
440 | int addr = phydev->addr; | ||
441 | |||
442 | phy_device_free(phydev); | ||
443 | of_node_put(port_dn); | ||
444 | fixed_phy_del(addr); | ||
445 | } | ||
446 | } | ||
447 | } | ||
448 | |||
449 | /* Destroy network devices for physical switch ports. */ | ||
450 | for (port = 0; port < DSA_MAX_PORTS; port++) { | ||
451 | if (!(ds->phys_port_mask & (1 << port))) | ||
452 | continue; | ||
453 | |||
454 | if (!ds->ports[port]) | ||
455 | continue; | ||
456 | |||
457 | unregister_netdev(ds->ports[port]); | ||
458 | free_netdev(ds->ports[port]); | ||
459 | } | ||
460 | |||
461 | mdiobus_unregister(ds->slave_mii_bus); | ||
427 | } | 462 | } |
428 | 463 | ||
429 | #ifdef CONFIG_PM_SLEEP | 464 | #ifdef CONFIG_PM_SLEEP |
@@ -802,10 +837,11 @@ static inline void dsa_of_remove(struct device *dev) | |||
802 | } | 837 | } |
803 | #endif | 838 | #endif |
804 | 839 | ||
805 | static void dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, | 840 | static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, |
806 | struct device *parent, struct dsa_platform_data *pd) | 841 | struct device *parent, struct dsa_platform_data *pd) |
807 | { | 842 | { |
808 | int i; | 843 | int i; |
844 | unsigned configured = 0; | ||
809 | 845 | ||
810 | dst->pd = pd; | 846 | dst->pd = pd; |
811 | dst->master_netdev = dev; | 847 | dst->master_netdev = dev; |
@@ -825,9 +861,17 @@ static void dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, | |||
825 | dst->ds[i] = ds; | 861 | dst->ds[i] = ds; |
826 | if (ds->drv->poll_link != NULL) | 862 | if (ds->drv->poll_link != NULL) |
827 | dst->link_poll_needed = 1; | 863 | dst->link_poll_needed = 1; |
864 | |||
865 | ++configured; | ||
828 | } | 866 | } |
829 | 867 | ||
830 | /* | 868 | /* |
869 | * If no switch was found, exit cleanly | ||
870 | */ | ||
871 | if (!configured) | ||
872 | return -EPROBE_DEFER; | ||
873 | |||
874 | /* | ||
831 | * If we use a tagging format that doesn't have an ethertype | 875 | * If we use a tagging format that doesn't have an ethertype |
832 | * field, make sure that all packets from this point on get | 876 | * field, make sure that all packets from this point on get |
833 | * sent to the tag format's receive function. | 877 | * sent to the tag format's receive function. |
@@ -843,6 +887,8 @@ static void dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, | |||
843 | dst->link_poll_timer.expires = round_jiffies(jiffies + HZ); | 887 | dst->link_poll_timer.expires = round_jiffies(jiffies + HZ); |
844 | add_timer(&dst->link_poll_timer); | 888 | add_timer(&dst->link_poll_timer); |
845 | } | 889 | } |
890 | |||
891 | return 0; | ||
846 | } | 892 | } |
847 | 893 | ||
848 | static int dsa_probe(struct platform_device *pdev) | 894 | static int dsa_probe(struct platform_device *pdev) |
@@ -883,7 +929,7 @@ static int dsa_probe(struct platform_device *pdev) | |||
883 | goto out; | 929 | goto out; |
884 | } | 930 | } |
885 | 931 | ||
886 | dst = kzalloc(sizeof(*dst), GFP_KERNEL); | 932 | dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); |
887 | if (dst == NULL) { | 933 | if (dst == NULL) { |
888 | dev_put(dev); | 934 | dev_put(dev); |
889 | ret = -ENOMEM; | 935 | ret = -ENOMEM; |
@@ -892,7 +938,9 @@ static int dsa_probe(struct platform_device *pdev) | |||
892 | 938 | ||
893 | platform_set_drvdata(pdev, dst); | 939 | platform_set_drvdata(pdev, dst); |
894 | 940 | ||
895 | dsa_setup_dst(dst, dev, &pdev->dev, pd); | 941 | ret = dsa_setup_dst(dst, dev, &pdev->dev, pd); |
942 | if (ret) | ||
943 | goto out; | ||
896 | 944 | ||
897 | return 0; | 945 | return 0; |
898 | 946 | ||
@@ -914,7 +962,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst) | |||
914 | for (i = 0; i < dst->pd->nr_chips; i++) { | 962 | for (i = 0; i < dst->pd->nr_chips; i++) { |
915 | struct dsa_switch *ds = dst->ds[i]; | 963 | struct dsa_switch *ds = dst->ds[i]; |
916 | 964 | ||
917 | if (ds != NULL) | 965 | if (ds) |
918 | dsa_switch_destroy(ds); | 966 | dsa_switch_destroy(ds); |
919 | } | 967 | } |
920 | } | 968 | } |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index f03db8b7abee..0c9c3482e419 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -312,7 +312,7 @@ static void arp_send_dst(int type, int ptype, __be32 dest_ip, | |||
312 | if (!skb) | 312 | if (!skb) |
313 | return; | 313 | return; |
314 | 314 | ||
315 | skb_dst_set(skb, dst); | 315 | skb_dst_set(skb, dst_clone(dst)); |
316 | arp_xmit(skb); | 316 | arp_xmit(skb); |
317 | } | 317 | } |
318 | 318 | ||
@@ -384,7 +384,7 @@ static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb) | |||
384 | } | 384 | } |
385 | 385 | ||
386 | if (skb && !(dev->priv_flags & IFF_XMIT_DST_RELEASE)) | 386 | if (skb && !(dev->priv_flags & IFF_XMIT_DST_RELEASE)) |
387 | dst = dst_clone(skb_dst(skb)); | 387 | dst = skb_dst(skb); |
388 | arp_send_dst(ARPOP_REQUEST, ETH_P_ARP, target, dev, saddr, | 388 | arp_send_dst(ARPOP_REQUEST, ETH_P_ARP, target, dev, saddr, |
389 | dst_hw, dev->dev_addr, NULL, dst); | 389 | dst_hw, dev->dev_addr, NULL, dst); |
390 | } | 390 | } |
@@ -811,7 +811,7 @@ static int arp_process(struct sock *sk, struct sk_buff *skb) | |||
811 | } else { | 811 | } else { |
812 | pneigh_enqueue(&arp_tbl, | 812 | pneigh_enqueue(&arp_tbl, |
813 | in_dev->arp_parms, skb); | 813 | in_dev->arp_parms, skb); |
814 | return 0; | 814 | goto out_free_dst; |
815 | } | 815 | } |
816 | goto out; | 816 | goto out; |
817 | } | 817 | } |
@@ -865,6 +865,8 @@ static int arp_process(struct sock *sk, struct sk_buff *skb) | |||
865 | 865 | ||
866 | out: | 866 | out: |
867 | consume_skb(skb); | 867 | consume_skb(skb); |
868 | out_free_dst: | ||
869 | dst_release(reply_dst); | ||
868 | return 0; | 870 | return 0; |
869 | } | 871 | } |
870 | 872 | ||
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 7bb9c39e0a4d..61b45a17fc73 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -577,21 +577,22 @@ EXPORT_SYMBOL(inet_rtx_syn_ack); | |||
577 | static bool reqsk_queue_unlink(struct request_sock_queue *queue, | 577 | static bool reqsk_queue_unlink(struct request_sock_queue *queue, |
578 | struct request_sock *req) | 578 | struct request_sock *req) |
579 | { | 579 | { |
580 | struct listen_sock *lopt = queue->listen_opt; | ||
581 | struct request_sock **prev; | 580 | struct request_sock **prev; |
581 | struct listen_sock *lopt; | ||
582 | bool found = false; | 582 | bool found = false; |
583 | 583 | ||
584 | spin_lock(&queue->syn_wait_lock); | 584 | spin_lock(&queue->syn_wait_lock); |
585 | 585 | lopt = queue->listen_opt; | |
586 | for (prev = &lopt->syn_table[req->rsk_hash]; *prev != NULL; | 586 | if (lopt) { |
587 | prev = &(*prev)->dl_next) { | 587 | for (prev = &lopt->syn_table[req->rsk_hash]; *prev != NULL; |
588 | if (*prev == req) { | 588 | prev = &(*prev)->dl_next) { |
589 | *prev = req->dl_next; | 589 | if (*prev == req) { |
590 | found = true; | 590 | *prev = req->dl_next; |
591 | break; | 591 | found = true; |
592 | break; | ||
593 | } | ||
592 | } | 594 | } |
593 | } | 595 | } |
594 | |||
595 | spin_unlock(&queue->syn_wait_lock); | 596 | spin_unlock(&queue->syn_wait_lock); |
596 | if (timer_pending(&req->rsk_timer) && del_timer_sync(&req->rsk_timer)) | 597 | if (timer_pending(&req->rsk_timer) && del_timer_sync(&req->rsk_timer)) |
597 | reqsk_put(req); | 598 | reqsk_put(req); |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 900113376d4e..36b85bd05ac8 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -3119,6 +3119,8 @@ static void addrconf_gre_config(struct net_device *dev) | |||
3119 | } | 3119 | } |
3120 | 3120 | ||
3121 | addrconf_addr_gen(idev, true); | 3121 | addrconf_addr_gen(idev, true); |
3122 | if (dev->flags & IFF_POINTOPOINT) | ||
3123 | addrconf_add_mroute(dev); | ||
3122 | } | 3124 | } |
3123 | #endif | 3125 | #endif |
3124 | 3126 | ||
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 92b1aa38f121..61d403ee1031 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -376,6 +376,9 @@ int ip6_forward(struct sk_buff *skb) | |||
376 | if (skb->pkt_type != PACKET_HOST) | 376 | if (skb->pkt_type != PACKET_HOST) |
377 | goto drop; | 377 | goto drop; |
378 | 378 | ||
379 | if (unlikely(skb->sk)) | ||
380 | goto drop; | ||
381 | |||
379 | if (skb_warn_if_lro(skb)) | 382 | if (skb_warn_if_lro(skb)) |
380 | goto drop; | 383 | goto drop; |
381 | 384 | ||
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index cb32ce250db0..968f31c01f89 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -142,6 +142,9 @@ static void rt6_uncached_list_flush_dev(struct net *net, struct net_device *dev) | |||
142 | struct net_device *loopback_dev = net->loopback_dev; | 142 | struct net_device *loopback_dev = net->loopback_dev; |
143 | int cpu; | 143 | int cpu; |
144 | 144 | ||
145 | if (dev == loopback_dev) | ||
146 | return; | ||
147 | |||
145 | for_each_possible_cpu(cpu) { | 148 | for_each_possible_cpu(cpu) { |
146 | struct uncached_list *ul = per_cpu_ptr(&rt6_uncached_list, cpu); | 149 | struct uncached_list *ul = per_cpu_ptr(&rt6_uncached_list, cpu); |
147 | struct rt6_info *rt; | 150 | struct rt6_info *rt; |
@@ -151,14 +154,12 @@ static void rt6_uncached_list_flush_dev(struct net *net, struct net_device *dev) | |||
151 | struct inet6_dev *rt_idev = rt->rt6i_idev; | 154 | struct inet6_dev *rt_idev = rt->rt6i_idev; |
152 | struct net_device *rt_dev = rt->dst.dev; | 155 | struct net_device *rt_dev = rt->dst.dev; |
153 | 156 | ||
154 | if (rt_idev && (rt_idev->dev == dev || !dev) && | 157 | if (rt_idev->dev == dev) { |
155 | rt_idev->dev != loopback_dev) { | ||
156 | rt->rt6i_idev = in6_dev_get(loopback_dev); | 158 | rt->rt6i_idev = in6_dev_get(loopback_dev); |
157 | in6_dev_put(rt_idev); | 159 | in6_dev_put(rt_idev); |
158 | } | 160 | } |
159 | 161 | ||
160 | if (rt_dev && (rt_dev == dev || !dev) && | 162 | if (rt_dev == dev) { |
161 | rt_dev != loopback_dev) { | ||
162 | rt->dst.dev = loopback_dev; | 163 | rt->dst.dev = loopback_dev; |
163 | dev_hold(rt->dst.dev); | 164 | dev_hold(rt->dst.dev); |
164 | dev_put(rt_dev); | 165 | dev_put(rt_dev); |
@@ -247,12 +248,6 @@ static void ip6_rt_blackhole_redirect(struct dst_entry *dst, struct sock *sk, | |||
247 | { | 248 | { |
248 | } | 249 | } |
249 | 250 | ||
250 | static u32 *ip6_rt_blackhole_cow_metrics(struct dst_entry *dst, | ||
251 | unsigned long old) | ||
252 | { | ||
253 | return NULL; | ||
254 | } | ||
255 | |||
256 | static struct dst_ops ip6_dst_blackhole_ops = { | 251 | static struct dst_ops ip6_dst_blackhole_ops = { |
257 | .family = AF_INET6, | 252 | .family = AF_INET6, |
258 | .destroy = ip6_dst_destroy, | 253 | .destroy = ip6_dst_destroy, |
@@ -261,7 +256,7 @@ static struct dst_ops ip6_dst_blackhole_ops = { | |||
261 | .default_advmss = ip6_default_advmss, | 256 | .default_advmss = ip6_default_advmss, |
262 | .update_pmtu = ip6_rt_blackhole_update_pmtu, | 257 | .update_pmtu = ip6_rt_blackhole_update_pmtu, |
263 | .redirect = ip6_rt_blackhole_redirect, | 258 | .redirect = ip6_rt_blackhole_redirect, |
264 | .cow_metrics = ip6_rt_blackhole_cow_metrics, | 259 | .cow_metrics = dst_cow_metrics_generic, |
265 | .neigh_lookup = ip6_neigh_lookup, | 260 | .neigh_lookup = ip6_neigh_lookup, |
266 | }; | 261 | }; |
267 | 262 | ||
@@ -318,6 +313,15 @@ static const struct rt6_info ip6_blk_hole_entry_template = { | |||
318 | 313 | ||
319 | #endif | 314 | #endif |
320 | 315 | ||
316 | static void rt6_info_init(struct rt6_info *rt) | ||
317 | { | ||
318 | struct dst_entry *dst = &rt->dst; | ||
319 | |||
320 | memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst)); | ||
321 | INIT_LIST_HEAD(&rt->rt6i_siblings); | ||
322 | INIT_LIST_HEAD(&rt->rt6i_uncached); | ||
323 | } | ||
324 | |||
321 | /* allocate dst with ip6_dst_ops */ | 325 | /* allocate dst with ip6_dst_ops */ |
322 | static struct rt6_info *__ip6_dst_alloc(struct net *net, | 326 | static struct rt6_info *__ip6_dst_alloc(struct net *net, |
323 | struct net_device *dev, | 327 | struct net_device *dev, |
@@ -326,13 +330,9 @@ static struct rt6_info *__ip6_dst_alloc(struct net *net, | |||
326 | struct rt6_info *rt = dst_alloc(&net->ipv6.ip6_dst_ops, dev, | 330 | struct rt6_info *rt = dst_alloc(&net->ipv6.ip6_dst_ops, dev, |
327 | 0, DST_OBSOLETE_FORCE_CHK, flags); | 331 | 0, DST_OBSOLETE_FORCE_CHK, flags); |
328 | 332 | ||
329 | if (rt) { | 333 | if (rt) |
330 | struct dst_entry *dst = &rt->dst; | 334 | rt6_info_init(rt); |
331 | 335 | ||
332 | memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst)); | ||
333 | INIT_LIST_HEAD(&rt->rt6i_siblings); | ||
334 | INIT_LIST_HEAD(&rt->rt6i_uncached); | ||
335 | } | ||
336 | return rt; | 336 | return rt; |
337 | } | 337 | } |
338 | 338 | ||
@@ -1213,24 +1213,20 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori | |||
1213 | 1213 | ||
1214 | rt = dst_alloc(&ip6_dst_blackhole_ops, ort->dst.dev, 1, DST_OBSOLETE_NONE, 0); | 1214 | rt = dst_alloc(&ip6_dst_blackhole_ops, ort->dst.dev, 1, DST_OBSOLETE_NONE, 0); |
1215 | if (rt) { | 1215 | if (rt) { |
1216 | new = &rt->dst; | 1216 | rt6_info_init(rt); |
1217 | |||
1218 | memset(new + 1, 0, sizeof(*rt) - sizeof(*new)); | ||
1219 | 1217 | ||
1218 | new = &rt->dst; | ||
1220 | new->__use = 1; | 1219 | new->__use = 1; |
1221 | new->input = dst_discard; | 1220 | new->input = dst_discard; |
1222 | new->output = dst_discard_sk; | 1221 | new->output = dst_discard_sk; |
1223 | 1222 | ||
1224 | if (dst_metrics_read_only(&ort->dst)) | 1223 | dst_copy_metrics(new, &ort->dst); |
1225 | new->_metrics = ort->dst._metrics; | ||
1226 | else | ||
1227 | dst_copy_metrics(new, &ort->dst); | ||
1228 | rt->rt6i_idev = ort->rt6i_idev; | 1224 | rt->rt6i_idev = ort->rt6i_idev; |
1229 | if (rt->rt6i_idev) | 1225 | if (rt->rt6i_idev) |
1230 | in6_dev_hold(rt->rt6i_idev); | 1226 | in6_dev_hold(rt->rt6i_idev); |
1231 | 1227 | ||
1232 | rt->rt6i_gateway = ort->rt6i_gateway; | 1228 | rt->rt6i_gateway = ort->rt6i_gateway; |
1233 | rt->rt6i_flags = ort->rt6i_flags; | 1229 | rt->rt6i_flags = ort->rt6i_flags & ~RTF_PCPU; |
1234 | rt->rt6i_metric = 0; | 1230 | rt->rt6i_metric = 0; |
1235 | 1231 | ||
1236 | memcpy(&rt->rt6i_dst, &ort->rt6i_dst, sizeof(struct rt6key)); | 1232 | memcpy(&rt->rt6i_dst, &ort->rt6i_dst, sizeof(struct rt6key)); |
@@ -2622,7 +2618,8 @@ void rt6_ifdown(struct net *net, struct net_device *dev) | |||
2622 | 2618 | ||
2623 | fib6_clean_all(net, fib6_ifdown, &adn); | 2619 | fib6_clean_all(net, fib6_ifdown, &adn); |
2624 | icmp6_clean_all(fib6_ifdown, &adn); | 2620 | icmp6_clean_all(fib6_ifdown, &adn); |
2625 | rt6_uncached_list_flush_dev(net, dev); | 2621 | if (dev) |
2622 | rt6_uncached_list_flush_dev(net, dev); | ||
2626 | } | 2623 | } |
2627 | 2624 | ||
2628 | struct rt6_mtu_change_arg { | 2625 | struct rt6_mtu_change_arg { |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 30caa289c5db..5cedfda4b241 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
@@ -37,6 +37,7 @@ static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos, int oif, | |||
37 | 37 | ||
38 | memset(&fl6, 0, sizeof(fl6)); | 38 | memset(&fl6, 0, sizeof(fl6)); |
39 | fl6.flowi6_oif = oif; | 39 | fl6.flowi6_oif = oif; |
40 | fl6.flowi6_flags = FLOWI_FLAG_SKIP_NH_OIF; | ||
40 | memcpy(&fl6.daddr, daddr, sizeof(fl6.daddr)); | 41 | memcpy(&fl6.daddr, daddr, sizeof(fl6.daddr)); |
41 | if (saddr) | 42 | if (saddr) |
42 | memcpy(&fl6.saddr, saddr, sizeof(fl6.saddr)); | 43 | memcpy(&fl6.saddr, saddr, sizeof(fl6.saddr)); |
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index ced6bf3be8d6..1560c8482bcb 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c | |||
@@ -149,7 +149,7 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf, | |||
149 | 149 | ||
150 | for (i = 0; i < NUM_IEEE80211_HW_FLAGS; i++) { | 150 | for (i = 0; i < NUM_IEEE80211_HW_FLAGS; i++) { |
151 | if (test_bit(i, local->hw.flags)) | 151 | if (test_bit(i, local->hw.flags)) |
152 | pos += scnprintf(pos, end - pos, "%s", | 152 | pos += scnprintf(pos, end - pos, "%s\n", |
153 | hw_flag_names[i]); | 153 | hw_flag_names[i]); |
154 | } | 154 | } |
155 | 155 | ||
diff --git a/net/mac80211/status.c b/net/mac80211/status.c index 8ba583243509..3ed7ddfbf8e8 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c | |||
@@ -101,6 +101,7 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local, | |||
101 | * when it wakes up for the next time. | 101 | * when it wakes up for the next time. |
102 | */ | 102 | */ |
103 | set_sta_flag(sta, WLAN_STA_CLEAR_PS_FILT); | 103 | set_sta_flag(sta, WLAN_STA_CLEAR_PS_FILT); |
104 | ieee80211_clear_fast_xmit(sta); | ||
104 | 105 | ||
105 | /* | 106 | /* |
106 | * This code races in the following way: | 107 | * This code races in the following way: |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 84e0e8c7fb23..7892eb8ed4c8 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -1218,8 +1218,10 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, | |||
1218 | 1218 | ||
1219 | if (!tx->sta) | 1219 | if (!tx->sta) |
1220 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; | 1220 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; |
1221 | else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) | 1221 | else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) { |
1222 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; | 1222 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; |
1223 | ieee80211_check_fast_xmit(tx->sta); | ||
1224 | } | ||
1223 | 1225 | ||
1224 | info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; | 1226 | info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; |
1225 | 1227 | ||
@@ -2451,7 +2453,8 @@ void ieee80211_check_fast_xmit(struct sta_info *sta) | |||
2451 | 2453 | ||
2452 | if (test_sta_flag(sta, WLAN_STA_PS_STA) || | 2454 | if (test_sta_flag(sta, WLAN_STA_PS_STA) || |
2453 | test_sta_flag(sta, WLAN_STA_PS_DRIVER) || | 2455 | test_sta_flag(sta, WLAN_STA_PS_DRIVER) || |
2454 | test_sta_flag(sta, WLAN_STA_PS_DELIVER)) | 2456 | test_sta_flag(sta, WLAN_STA_PS_DELIVER) || |
2457 | test_sta_flag(sta, WLAN_STA_CLEAR_PS_FILT)) | ||
2455 | goto out; | 2458 | goto out; |
2456 | 2459 | ||
2457 | if (sdata->noack_map) | 2460 | if (sdata->noack_map) |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 8f060d7f9a0e..0a49a8c7c564 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -2785,6 +2785,7 @@ static int netlink_dump(struct sock *sk) | |||
2785 | struct sk_buff *skb = NULL; | 2785 | struct sk_buff *skb = NULL; |
2786 | struct nlmsghdr *nlh; | 2786 | struct nlmsghdr *nlh; |
2787 | int len, err = -ENOBUFS; | 2787 | int len, err = -ENOBUFS; |
2788 | int alloc_min_size; | ||
2788 | int alloc_size; | 2789 | int alloc_size; |
2789 | 2790 | ||
2790 | mutex_lock(nlk->cb_mutex); | 2791 | mutex_lock(nlk->cb_mutex); |
@@ -2793,9 +2794,6 @@ static int netlink_dump(struct sock *sk) | |||
2793 | goto errout_skb; | 2794 | goto errout_skb; |
2794 | } | 2795 | } |
2795 | 2796 | ||
2796 | cb = &nlk->cb; | ||
2797 | alloc_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE); | ||
2798 | |||
2799 | if (!netlink_rx_is_mmaped(sk) && | 2797 | if (!netlink_rx_is_mmaped(sk) && |
2800 | atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) | 2798 | atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) |
2801 | goto errout_skb; | 2799 | goto errout_skb; |
@@ -2805,23 +2803,35 @@ static int netlink_dump(struct sock *sk) | |||
2805 | * to reduce number of system calls on dump operations, if user | 2803 | * to reduce number of system calls on dump operations, if user |
2806 | * ever provided a big enough buffer. | 2804 | * ever provided a big enough buffer. |
2807 | */ | 2805 | */ |
2808 | if (alloc_size < nlk->max_recvmsg_len) { | 2806 | cb = &nlk->cb; |
2809 | skb = netlink_alloc_skb(sk, | 2807 | alloc_min_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE); |
2810 | nlk->max_recvmsg_len, | 2808 | |
2811 | nlk->portid, | 2809 | if (alloc_min_size < nlk->max_recvmsg_len) { |
2810 | alloc_size = nlk->max_recvmsg_len; | ||
2811 | skb = netlink_alloc_skb(sk, alloc_size, nlk->portid, | ||
2812 | GFP_KERNEL | | 2812 | GFP_KERNEL | |
2813 | __GFP_NOWARN | | 2813 | __GFP_NOWARN | |
2814 | __GFP_NORETRY); | 2814 | __GFP_NORETRY); |
2815 | /* available room should be exact amount to avoid MSG_TRUNC */ | ||
2816 | if (skb) | ||
2817 | skb_reserve(skb, skb_tailroom(skb) - | ||
2818 | nlk->max_recvmsg_len); | ||
2819 | } | 2815 | } |
2820 | if (!skb) | 2816 | if (!skb) { |
2817 | alloc_size = alloc_min_size; | ||
2821 | skb = netlink_alloc_skb(sk, alloc_size, nlk->portid, | 2818 | skb = netlink_alloc_skb(sk, alloc_size, nlk->portid, |
2822 | GFP_KERNEL); | 2819 | GFP_KERNEL); |
2820 | } | ||
2823 | if (!skb) | 2821 | if (!skb) |
2824 | goto errout_skb; | 2822 | goto errout_skb; |
2823 | |||
2824 | /* Trim skb to allocated size. User is expected to provide buffer as | ||
2825 | * large as max(min_dump_alloc, 16KiB (mac_recvmsg_len capped at | ||
2826 | * netlink_recvmsg())). dump will pack as many smaller messages as | ||
2827 | * could fit within the allocated skb. skb is typically allocated | ||
2828 | * with larger space than required (could be as much as near 2x the | ||
2829 | * requested size with align to next power of 2 approach). Allowing | ||
2830 | * dump to use the excess space makes it difficult for a user to have a | ||
2831 | * reasonable static buffer based on the expected largest dump of a | ||
2832 | * single netdev. The outcome is MSG_TRUNC error. | ||
2833 | */ | ||
2834 | skb_reserve(skb, skb_tailroom(skb) - alloc_size); | ||
2825 | netlink_skb_set_owner_r(skb, sk); | 2835 | netlink_skb_set_owner_r(skb, sk); |
2826 | 2836 | ||
2827 | len = cb->dump(skb, cb); | 2837 | len = cb->dump(skb, cb); |
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index 315f5330b6e5..c6a39bf2c3b9 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c | |||
@@ -684,7 +684,7 @@ static void ovs_fragment(struct vport *vport, struct sk_buff *skb, u16 mru, | |||
684 | { | 684 | { |
685 | if (skb_network_offset(skb) > MAX_L2_LEN) { | 685 | if (skb_network_offset(skb) > MAX_L2_LEN) { |
686 | OVS_NLERR(1, "L2 header too long to fragment"); | 686 | OVS_NLERR(1, "L2 header too long to fragment"); |
687 | return; | 687 | goto err; |
688 | } | 688 | } |
689 | 689 | ||
690 | if (ethertype == htons(ETH_P_IP)) { | 690 | if (ethertype == htons(ETH_P_IP)) { |
@@ -708,8 +708,7 @@ static void ovs_fragment(struct vport *vport, struct sk_buff *skb, u16 mru, | |||
708 | struct rt6_info ovs_rt; | 708 | struct rt6_info ovs_rt; |
709 | 709 | ||
710 | if (!v6ops) { | 710 | if (!v6ops) { |
711 | kfree_skb(skb); | 711 | goto err; |
712 | return; | ||
713 | } | 712 | } |
714 | 713 | ||
715 | prepare_frag(vport, skb); | 714 | prepare_frag(vport, skb); |
@@ -728,8 +727,12 @@ static void ovs_fragment(struct vport *vport, struct sk_buff *skb, u16 mru, | |||
728 | WARN_ONCE(1, "Failed fragment ->%s: eth=%04x, MRU=%d, MTU=%d.", | 727 | WARN_ONCE(1, "Failed fragment ->%s: eth=%04x, MRU=%d, MTU=%d.", |
729 | ovs_vport_name(vport), ntohs(ethertype), mru, | 728 | ovs_vport_name(vport), ntohs(ethertype), mru, |
730 | vport->dev->mtu); | 729 | vport->dev->mtu); |
731 | kfree_skb(skb); | 730 | goto err; |
732 | } | 731 | } |
732 | |||
733 | return; | ||
734 | err: | ||
735 | kfree_skb(skb); | ||
733 | } | 736 | } |
734 | 737 | ||
735 | static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port, | 738 | static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port, |
@@ -968,7 +971,7 @@ static int execute_masked_set_action(struct sk_buff *skb, | |||
968 | case OVS_KEY_ATTR_CT_STATE: | 971 | case OVS_KEY_ATTR_CT_STATE: |
969 | case OVS_KEY_ATTR_CT_ZONE: | 972 | case OVS_KEY_ATTR_CT_ZONE: |
970 | case OVS_KEY_ATTR_CT_MARK: | 973 | case OVS_KEY_ATTR_CT_MARK: |
971 | case OVS_KEY_ATTR_CT_LABEL: | 974 | case OVS_KEY_ATTR_CT_LABELS: |
972 | err = -EINVAL; | 975 | err = -EINVAL; |
973 | break; | 976 | break; |
974 | } | 977 | } |
@@ -1099,6 +1102,12 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, | |||
1099 | break; | 1102 | break; |
1100 | 1103 | ||
1101 | case OVS_ACTION_ATTR_CT: | 1104 | case OVS_ACTION_ATTR_CT: |
1105 | if (!is_flow_key_valid(key)) { | ||
1106 | err = ovs_flow_key_update(skb, key); | ||
1107 | if (err) | ||
1108 | return err; | ||
1109 | } | ||
1110 | |||
1102 | err = ovs_ct_execute(ovs_dp_get_net(dp), skb, key, | 1111 | err = ovs_ct_execute(ovs_dp_get_net(dp), skb, key, |
1103 | nla_data(a)); | 1112 | nla_data(a)); |
1104 | 1113 | ||
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 002a755fa07e..80bf702715bb 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c | |||
@@ -37,9 +37,9 @@ struct md_mark { | |||
37 | }; | 37 | }; |
38 | 38 | ||
39 | /* Metadata label for masked write to conntrack label. */ | 39 | /* Metadata label for masked write to conntrack label. */ |
40 | struct md_label { | 40 | struct md_labels { |
41 | struct ovs_key_ct_label value; | 41 | struct ovs_key_ct_labels value; |
42 | struct ovs_key_ct_label mask; | 42 | struct ovs_key_ct_labels mask; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /* Conntrack action context for execution. */ | 45 | /* Conntrack action context for execution. */ |
@@ -47,10 +47,10 @@ struct ovs_conntrack_info { | |||
47 | struct nf_conntrack_helper *helper; | 47 | struct nf_conntrack_helper *helper; |
48 | struct nf_conntrack_zone zone; | 48 | struct nf_conntrack_zone zone; |
49 | struct nf_conn *ct; | 49 | struct nf_conn *ct; |
50 | u32 flags; | 50 | u8 commit : 1; |
51 | u16 family; | 51 | u16 family; |
52 | struct md_mark mark; | 52 | struct md_mark mark; |
53 | struct md_label label; | 53 | struct md_labels labels; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | static u16 key_to_nfproto(const struct sw_flow_key *key) | 56 | static u16 key_to_nfproto(const struct sw_flow_key *key) |
@@ -109,21 +109,21 @@ static u32 ovs_ct_get_mark(const struct nf_conn *ct) | |||
109 | #endif | 109 | #endif |
110 | } | 110 | } |
111 | 111 | ||
112 | static void ovs_ct_get_label(const struct nf_conn *ct, | 112 | static void ovs_ct_get_labels(const struct nf_conn *ct, |
113 | struct ovs_key_ct_label *label) | 113 | struct ovs_key_ct_labels *labels) |
114 | { | 114 | { |
115 | struct nf_conn_labels *cl = ct ? nf_ct_labels_find(ct) : NULL; | 115 | struct nf_conn_labels *cl = ct ? nf_ct_labels_find(ct) : NULL; |
116 | 116 | ||
117 | if (cl) { | 117 | if (cl) { |
118 | size_t len = cl->words * sizeof(long); | 118 | size_t len = cl->words * sizeof(long); |
119 | 119 | ||
120 | if (len > OVS_CT_LABEL_LEN) | 120 | if (len > OVS_CT_LABELS_LEN) |
121 | len = OVS_CT_LABEL_LEN; | 121 | len = OVS_CT_LABELS_LEN; |
122 | else if (len < OVS_CT_LABEL_LEN) | 122 | else if (len < OVS_CT_LABELS_LEN) |
123 | memset(label, 0, OVS_CT_LABEL_LEN); | 123 | memset(labels, 0, OVS_CT_LABELS_LEN); |
124 | memcpy(label, cl->bits, len); | 124 | memcpy(labels, cl->bits, len); |
125 | } else { | 125 | } else { |
126 | memset(label, 0, OVS_CT_LABEL_LEN); | 126 | memset(labels, 0, OVS_CT_LABELS_LEN); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
@@ -134,7 +134,7 @@ static void __ovs_ct_update_key(struct sw_flow_key *key, u8 state, | |||
134 | key->ct.state = state; | 134 | key->ct.state = state; |
135 | key->ct.zone = zone->id; | 135 | key->ct.zone = zone->id; |
136 | key->ct.mark = ovs_ct_get_mark(ct); | 136 | key->ct.mark = ovs_ct_get_mark(ct); |
137 | ovs_ct_get_label(ct, &key->ct.label); | 137 | ovs_ct_get_labels(ct, &key->ct.labels); |
138 | } | 138 | } |
139 | 139 | ||
140 | /* Update 'key' based on skb->nfct. If 'post_ct' is true, then OVS has | 140 | /* Update 'key' based on skb->nfct. If 'post_ct' is true, then OVS has |
@@ -167,7 +167,7 @@ void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key) | |||
167 | 167 | ||
168 | int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb) | 168 | int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb) |
169 | { | 169 | { |
170 | if (nla_put_u8(skb, OVS_KEY_ATTR_CT_STATE, key->ct.state)) | 170 | if (nla_put_u32(skb, OVS_KEY_ATTR_CT_STATE, key->ct.state)) |
171 | return -EMSGSIZE; | 171 | return -EMSGSIZE; |
172 | 172 | ||
173 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) && | 173 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) && |
@@ -179,8 +179,8 @@ int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb) | |||
179 | return -EMSGSIZE; | 179 | return -EMSGSIZE; |
180 | 180 | ||
181 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) && | 181 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) && |
182 | nla_put(skb, OVS_KEY_ATTR_CT_LABEL, sizeof(key->ct.label), | 182 | nla_put(skb, OVS_KEY_ATTR_CT_LABELS, sizeof(key->ct.labels), |
183 | &key->ct.label)) | 183 | &key->ct.labels)) |
184 | return -EMSGSIZE; | 184 | return -EMSGSIZE; |
185 | 185 | ||
186 | return 0; | 186 | return 0; |
@@ -213,9 +213,9 @@ static int ovs_ct_set_mark(struct sk_buff *skb, struct sw_flow_key *key, | |||
213 | #endif | 213 | #endif |
214 | } | 214 | } |
215 | 215 | ||
216 | static int ovs_ct_set_label(struct sk_buff *skb, struct sw_flow_key *key, | 216 | static int ovs_ct_set_labels(struct sk_buff *skb, struct sw_flow_key *key, |
217 | const struct ovs_key_ct_label *label, | 217 | const struct ovs_key_ct_labels *labels, |
218 | const struct ovs_key_ct_label *mask) | 218 | const struct ovs_key_ct_labels *mask) |
219 | { | 219 | { |
220 | enum ip_conntrack_info ctinfo; | 220 | enum ip_conntrack_info ctinfo; |
221 | struct nf_conn_labels *cl; | 221 | struct nf_conn_labels *cl; |
@@ -235,15 +235,15 @@ static int ovs_ct_set_label(struct sk_buff *skb, struct sw_flow_key *key, | |||
235 | nf_ct_labels_ext_add(ct); | 235 | nf_ct_labels_ext_add(ct); |
236 | cl = nf_ct_labels_find(ct); | 236 | cl = nf_ct_labels_find(ct); |
237 | } | 237 | } |
238 | if (!cl || cl->words * sizeof(long) < OVS_CT_LABEL_LEN) | 238 | if (!cl || cl->words * sizeof(long) < OVS_CT_LABELS_LEN) |
239 | return -ENOSPC; | 239 | return -ENOSPC; |
240 | 240 | ||
241 | err = nf_connlabels_replace(ct, (u32 *)label, (u32 *)mask, | 241 | err = nf_connlabels_replace(ct, (u32 *)labels, (u32 *)mask, |
242 | OVS_CT_LABEL_LEN / sizeof(u32)); | 242 | OVS_CT_LABELS_LEN / sizeof(u32)); |
243 | if (err) | 243 | if (err) |
244 | return err; | 244 | return err; |
245 | 245 | ||
246 | ovs_ct_get_label(ct, &key->ct.label); | 246 | ovs_ct_get_labels(ct, &key->ct.labels); |
247 | return 0; | 247 | return 0; |
248 | } | 248 | } |
249 | 249 | ||
@@ -465,12 +465,12 @@ static int ovs_ct_commit(struct net *net, struct sw_flow_key *key, | |||
465 | return 0; | 465 | return 0; |
466 | } | 466 | } |
467 | 467 | ||
468 | static bool label_nonzero(const struct ovs_key_ct_label *label) | 468 | static bool labels_nonzero(const struct ovs_key_ct_labels *labels) |
469 | { | 469 | { |
470 | size_t i; | 470 | size_t i; |
471 | 471 | ||
472 | for (i = 0; i < sizeof(*label); i++) | 472 | for (i = 0; i < sizeof(*labels); i++) |
473 | if (label->ct_label[i]) | 473 | if (labels->ct_labels[i]) |
474 | return true; | 474 | return true; |
475 | 475 | ||
476 | return false; | 476 | return false; |
@@ -493,7 +493,7 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb, | |||
493 | return err; | 493 | return err; |
494 | } | 494 | } |
495 | 495 | ||
496 | if (info->flags & OVS_CT_F_COMMIT) | 496 | if (info->commit) |
497 | err = ovs_ct_commit(net, key, info, skb); | 497 | err = ovs_ct_commit(net, key, info, skb); |
498 | else | 498 | else |
499 | err = ovs_ct_lookup(net, key, info, skb); | 499 | err = ovs_ct_lookup(net, key, info, skb); |
@@ -506,9 +506,9 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb, | |||
506 | if (err) | 506 | if (err) |
507 | goto err; | 507 | goto err; |
508 | } | 508 | } |
509 | if (label_nonzero(&info->label.mask)) | 509 | if (labels_nonzero(&info->labels.mask)) |
510 | err = ovs_ct_set_label(skb, key, &info->label.value, | 510 | err = ovs_ct_set_labels(skb, key, &info->labels.value, |
511 | &info->label.mask); | 511 | &info->labels.mask); |
512 | err: | 512 | err: |
513 | skb_push(skb, nh_ofs); | 513 | skb_push(skb, nh_ofs); |
514 | return err; | 514 | return err; |
@@ -539,14 +539,13 @@ static int ovs_ct_add_helper(struct ovs_conntrack_info *info, const char *name, | |||
539 | } | 539 | } |
540 | 540 | ||
541 | static const struct ovs_ct_len_tbl ovs_ct_attr_lens[OVS_CT_ATTR_MAX + 1] = { | 541 | static const struct ovs_ct_len_tbl ovs_ct_attr_lens[OVS_CT_ATTR_MAX + 1] = { |
542 | [OVS_CT_ATTR_FLAGS] = { .minlen = sizeof(u32), | 542 | [OVS_CT_ATTR_COMMIT] = { .minlen = 0, .maxlen = 0 }, |
543 | .maxlen = sizeof(u32) }, | ||
544 | [OVS_CT_ATTR_ZONE] = { .minlen = sizeof(u16), | 543 | [OVS_CT_ATTR_ZONE] = { .minlen = sizeof(u16), |
545 | .maxlen = sizeof(u16) }, | 544 | .maxlen = sizeof(u16) }, |
546 | [OVS_CT_ATTR_MARK] = { .minlen = sizeof(struct md_mark), | 545 | [OVS_CT_ATTR_MARK] = { .minlen = sizeof(struct md_mark), |
547 | .maxlen = sizeof(struct md_mark) }, | 546 | .maxlen = sizeof(struct md_mark) }, |
548 | [OVS_CT_ATTR_LABEL] = { .minlen = sizeof(struct md_label), | 547 | [OVS_CT_ATTR_LABELS] = { .minlen = sizeof(struct md_labels), |
549 | .maxlen = sizeof(struct md_label) }, | 548 | .maxlen = sizeof(struct md_labels) }, |
550 | [OVS_CT_ATTR_HELPER] = { .minlen = 1, | 549 | [OVS_CT_ATTR_HELPER] = { .minlen = 1, |
551 | .maxlen = NF_CT_HELPER_NAME_LEN } | 550 | .maxlen = NF_CT_HELPER_NAME_LEN } |
552 | }; | 551 | }; |
@@ -576,8 +575,8 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info, | |||
576 | } | 575 | } |
577 | 576 | ||
578 | switch (type) { | 577 | switch (type) { |
579 | case OVS_CT_ATTR_FLAGS: | 578 | case OVS_CT_ATTR_COMMIT: |
580 | info->flags = nla_get_u32(a); | 579 | info->commit = true; |
581 | break; | 580 | break; |
582 | #ifdef CONFIG_NF_CONNTRACK_ZONES | 581 | #ifdef CONFIG_NF_CONNTRACK_ZONES |
583 | case OVS_CT_ATTR_ZONE: | 582 | case OVS_CT_ATTR_ZONE: |
@@ -593,10 +592,10 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info, | |||
593 | } | 592 | } |
594 | #endif | 593 | #endif |
595 | #ifdef CONFIG_NF_CONNTRACK_LABELS | 594 | #ifdef CONFIG_NF_CONNTRACK_LABELS |
596 | case OVS_CT_ATTR_LABEL: { | 595 | case OVS_CT_ATTR_LABELS: { |
597 | struct md_label *label = nla_data(a); | 596 | struct md_labels *labels = nla_data(a); |
598 | 597 | ||
599 | info->label = *label; | 598 | info->labels = *labels; |
600 | break; | 599 | break; |
601 | } | 600 | } |
602 | #endif | 601 | #endif |
@@ -633,7 +632,7 @@ bool ovs_ct_verify(struct net *net, enum ovs_key_attr attr) | |||
633 | attr == OVS_KEY_ATTR_CT_MARK) | 632 | attr == OVS_KEY_ATTR_CT_MARK) |
634 | return true; | 633 | return true; |
635 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) && | 634 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) && |
636 | attr == OVS_KEY_ATTR_CT_LABEL) { | 635 | attr == OVS_KEY_ATTR_CT_LABELS) { |
637 | struct ovs_net *ovs_net = net_generic(net, ovs_net_id); | 636 | struct ovs_net *ovs_net = net_generic(net, ovs_net_id); |
638 | 637 | ||
639 | return ovs_net->xt_label; | 638 | return ovs_net->xt_label; |
@@ -701,7 +700,7 @@ int ovs_ct_action_to_attr(const struct ovs_conntrack_info *ct_info, | |||
701 | if (!start) | 700 | if (!start) |
702 | return -EMSGSIZE; | 701 | return -EMSGSIZE; |
703 | 702 | ||
704 | if (nla_put_u32(skb, OVS_CT_ATTR_FLAGS, ct_info->flags)) | 703 | if (ct_info->commit && nla_put_flag(skb, OVS_CT_ATTR_COMMIT)) |
705 | return -EMSGSIZE; | 704 | return -EMSGSIZE; |
706 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) && | 705 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) && |
707 | nla_put_u16(skb, OVS_CT_ATTR_ZONE, ct_info->zone.id)) | 706 | nla_put_u16(skb, OVS_CT_ATTR_ZONE, ct_info->zone.id)) |
@@ -711,8 +710,8 @@ int ovs_ct_action_to_attr(const struct ovs_conntrack_info *ct_info, | |||
711 | &ct_info->mark)) | 710 | &ct_info->mark)) |
712 | return -EMSGSIZE; | 711 | return -EMSGSIZE; |
713 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) && | 712 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) && |
714 | nla_put(skb, OVS_CT_ATTR_LABEL, sizeof(ct_info->label), | 713 | nla_put(skb, OVS_CT_ATTR_LABELS, sizeof(ct_info->labels), |
715 | &ct_info->label)) | 714 | &ct_info->labels)) |
716 | return -EMSGSIZE; | 715 | return -EMSGSIZE; |
717 | if (ct_info->helper) { | 716 | if (ct_info->helper) { |
718 | if (nla_put_string(skb, OVS_CT_ATTR_HELPER, | 717 | if (nla_put_string(skb, OVS_CT_ATTR_HELPER, |
@@ -737,7 +736,7 @@ void ovs_ct_free_action(const struct nlattr *a) | |||
737 | 736 | ||
738 | void ovs_ct_init(struct net *net) | 737 | void ovs_ct_init(struct net *net) |
739 | { | 738 | { |
740 | unsigned int n_bits = sizeof(struct ovs_key_ct_label) * BITS_PER_BYTE; | 739 | unsigned int n_bits = sizeof(struct ovs_key_ct_labels) * BITS_PER_BYTE; |
741 | struct ovs_net *ovs_net = net_generic(net, ovs_net_id); | 740 | struct ovs_net *ovs_net = net_generic(net, ovs_net_id); |
742 | 741 | ||
743 | if (nf_connlabels_get(net, n_bits)) { | 742 | if (nf_connlabels_get(net, n_bits)) { |
diff --git a/net/openvswitch/conntrack.h b/net/openvswitch/conntrack.h index 43f5dd7a5577..da8714942c95 100644 --- a/net/openvswitch/conntrack.h +++ b/net/openvswitch/conntrack.h | |||
@@ -34,6 +34,13 @@ int ovs_ct_execute(struct net *, struct sk_buff *, struct sw_flow_key *, | |||
34 | void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key); | 34 | void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key); |
35 | int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb); | 35 | int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb); |
36 | void ovs_ct_free_action(const struct nlattr *a); | 36 | void ovs_ct_free_action(const struct nlattr *a); |
37 | |||
38 | static inline bool ovs_ct_state_supported(u32 state) | ||
39 | { | ||
40 | return !(state & ~(OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | | ||
41 | OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | | ||
42 | OVS_CS_F_INVALID | OVS_CS_F_TRACKED)); | ||
43 | } | ||
37 | #else | 44 | #else |
38 | #include <linux/errno.h> | 45 | #include <linux/errno.h> |
39 | 46 | ||
@@ -46,6 +53,11 @@ static inline bool ovs_ct_verify(struct net *net, int attr) | |||
46 | return false; | 53 | return false; |
47 | } | 54 | } |
48 | 55 | ||
56 | static inline bool ovs_ct_state_supported(u32 state) | ||
57 | { | ||
58 | return false; | ||
59 | } | ||
60 | |||
49 | static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla, | 61 | static inline int ovs_ct_copy_action(struct net *net, const struct nlattr *nla, |
50 | const struct sw_flow_key *key, | 62 | const struct sw_flow_key *key, |
51 | struct sw_flow_actions **acts, bool log) | 63 | struct sw_flow_actions **acts, bool log) |
@@ -72,7 +84,7 @@ static inline void ovs_ct_fill_key(const struct sk_buff *skb, | |||
72 | key->ct.state = 0; | 84 | key->ct.state = 0; |
73 | key->ct.zone = 0; | 85 | key->ct.zone = 0; |
74 | key->ct.mark = 0; | 86 | key->ct.mark = 0; |
75 | memset(&key->ct.label, 0, sizeof(key->ct.label)); | 87 | memset(&key->ct.labels, 0, sizeof(key->ct.labels)); |
76 | } | 88 | } |
77 | 89 | ||
78 | static inline int ovs_ct_put_key(const struct sw_flow_key *key, | 90 | static inline int ovs_ct_put_key(const struct sw_flow_key *key, |
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h index fe527d2dd4b7..8cfa15a08668 100644 --- a/net/openvswitch/flow.h +++ b/net/openvswitch/flow.h | |||
@@ -116,7 +116,7 @@ struct sw_flow_key { | |||
116 | u16 zone; | 116 | u16 zone; |
117 | u32 mark; | 117 | u32 mark; |
118 | u8 state; | 118 | u8 state; |
119 | struct ovs_key_ct_label label; | 119 | struct ovs_key_ct_labels labels; |
120 | } ct; | 120 | } ct; |
121 | 121 | ||
122 | } __aligned(BITS_PER_LONG/8); /* Ensure that we can do comparisons as longs. */ | 122 | } __aligned(BITS_PER_LONG/8); /* Ensure that we can do comparisons as longs. */ |
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c index 5c030a4d7338..171a691f1c32 100644 --- a/net/openvswitch/flow_netlink.c +++ b/net/openvswitch/flow_netlink.c | |||
@@ -291,10 +291,10 @@ size_t ovs_key_attr_size(void) | |||
291 | + nla_total_size(4) /* OVS_KEY_ATTR_SKB_MARK */ | 291 | + nla_total_size(4) /* OVS_KEY_ATTR_SKB_MARK */ |
292 | + nla_total_size(4) /* OVS_KEY_ATTR_DP_HASH */ | 292 | + nla_total_size(4) /* OVS_KEY_ATTR_DP_HASH */ |
293 | + nla_total_size(4) /* OVS_KEY_ATTR_RECIRC_ID */ | 293 | + nla_total_size(4) /* OVS_KEY_ATTR_RECIRC_ID */ |
294 | + nla_total_size(1) /* OVS_KEY_ATTR_CT_STATE */ | 294 | + nla_total_size(4) /* OVS_KEY_ATTR_CT_STATE */ |
295 | + nla_total_size(2) /* OVS_KEY_ATTR_CT_ZONE */ | 295 | + nla_total_size(2) /* OVS_KEY_ATTR_CT_ZONE */ |
296 | + nla_total_size(4) /* OVS_KEY_ATTR_CT_MARK */ | 296 | + nla_total_size(4) /* OVS_KEY_ATTR_CT_MARK */ |
297 | + nla_total_size(16) /* OVS_KEY_ATTR_CT_LABEL */ | 297 | + nla_total_size(16) /* OVS_KEY_ATTR_CT_LABELS */ |
298 | + nla_total_size(12) /* OVS_KEY_ATTR_ETHERNET */ | 298 | + nla_total_size(12) /* OVS_KEY_ATTR_ETHERNET */ |
299 | + nla_total_size(2) /* OVS_KEY_ATTR_ETHERTYPE */ | 299 | + nla_total_size(2) /* OVS_KEY_ATTR_ETHERTYPE */ |
300 | + nla_total_size(4) /* OVS_KEY_ATTR_VLAN */ | 300 | + nla_total_size(4) /* OVS_KEY_ATTR_VLAN */ |
@@ -349,10 +349,10 @@ static const struct ovs_len_tbl ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = { | |||
349 | [OVS_KEY_ATTR_TUNNEL] = { .len = OVS_ATTR_NESTED, | 349 | [OVS_KEY_ATTR_TUNNEL] = { .len = OVS_ATTR_NESTED, |
350 | .next = ovs_tunnel_key_lens, }, | 350 | .next = ovs_tunnel_key_lens, }, |
351 | [OVS_KEY_ATTR_MPLS] = { .len = sizeof(struct ovs_key_mpls) }, | 351 | [OVS_KEY_ATTR_MPLS] = { .len = sizeof(struct ovs_key_mpls) }, |
352 | [OVS_KEY_ATTR_CT_STATE] = { .len = sizeof(u8) }, | 352 | [OVS_KEY_ATTR_CT_STATE] = { .len = sizeof(u32) }, |
353 | [OVS_KEY_ATTR_CT_ZONE] = { .len = sizeof(u16) }, | 353 | [OVS_KEY_ATTR_CT_ZONE] = { .len = sizeof(u16) }, |
354 | [OVS_KEY_ATTR_CT_MARK] = { .len = sizeof(u32) }, | 354 | [OVS_KEY_ATTR_CT_MARK] = { .len = sizeof(u32) }, |
355 | [OVS_KEY_ATTR_CT_LABEL] = { .len = sizeof(struct ovs_key_ct_label) }, | 355 | [OVS_KEY_ATTR_CT_LABELS] = { .len = sizeof(struct ovs_key_ct_labels) }, |
356 | }; | 356 | }; |
357 | 357 | ||
358 | static bool check_attr_len(unsigned int attr_len, unsigned int expected_len) | 358 | static bool check_attr_len(unsigned int attr_len, unsigned int expected_len) |
@@ -814,7 +814,13 @@ static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match, | |||
814 | 814 | ||
815 | if (*attrs & (1 << OVS_KEY_ATTR_CT_STATE) && | 815 | if (*attrs & (1 << OVS_KEY_ATTR_CT_STATE) && |
816 | ovs_ct_verify(net, OVS_KEY_ATTR_CT_STATE)) { | 816 | ovs_ct_verify(net, OVS_KEY_ATTR_CT_STATE)) { |
817 | u8 ct_state = nla_get_u8(a[OVS_KEY_ATTR_CT_STATE]); | 817 | u32 ct_state = nla_get_u32(a[OVS_KEY_ATTR_CT_STATE]); |
818 | |||
819 | if (!is_mask && !ovs_ct_state_supported(ct_state)) { | ||
820 | OVS_NLERR(log, "ct_state flags %08x unsupported", | ||
821 | ct_state); | ||
822 | return -EINVAL; | ||
823 | } | ||
818 | 824 | ||
819 | SW_FLOW_KEY_PUT(match, ct.state, ct_state, is_mask); | 825 | SW_FLOW_KEY_PUT(match, ct.state, ct_state, is_mask); |
820 | *attrs &= ~(1ULL << OVS_KEY_ATTR_CT_STATE); | 826 | *attrs &= ~(1ULL << OVS_KEY_ATTR_CT_STATE); |
@@ -833,14 +839,14 @@ static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match, | |||
833 | SW_FLOW_KEY_PUT(match, ct.mark, mark, is_mask); | 839 | SW_FLOW_KEY_PUT(match, ct.mark, mark, is_mask); |
834 | *attrs &= ~(1ULL << OVS_KEY_ATTR_CT_MARK); | 840 | *attrs &= ~(1ULL << OVS_KEY_ATTR_CT_MARK); |
835 | } | 841 | } |
836 | if (*attrs & (1 << OVS_KEY_ATTR_CT_LABEL) && | 842 | if (*attrs & (1 << OVS_KEY_ATTR_CT_LABELS) && |
837 | ovs_ct_verify(net, OVS_KEY_ATTR_CT_LABEL)) { | 843 | ovs_ct_verify(net, OVS_KEY_ATTR_CT_LABELS)) { |
838 | const struct ovs_key_ct_label *cl; | 844 | const struct ovs_key_ct_labels *cl; |
839 | 845 | ||
840 | cl = nla_data(a[OVS_KEY_ATTR_CT_LABEL]); | 846 | cl = nla_data(a[OVS_KEY_ATTR_CT_LABELS]); |
841 | SW_FLOW_KEY_MEMCPY(match, ct.label, cl->ct_label, | 847 | SW_FLOW_KEY_MEMCPY(match, ct.labels, cl->ct_labels, |
842 | sizeof(*cl), is_mask); | 848 | sizeof(*cl), is_mask); |
843 | *attrs &= ~(1ULL << OVS_KEY_ATTR_CT_LABEL); | 849 | *attrs &= ~(1ULL << OVS_KEY_ATTR_CT_LABELS); |
844 | } | 850 | } |
845 | return 0; | 851 | return 0; |
846 | } | 852 | } |
@@ -1973,7 +1979,7 @@ static int validate_set(const struct nlattr *a, | |||
1973 | case OVS_KEY_ATTR_PRIORITY: | 1979 | case OVS_KEY_ATTR_PRIORITY: |
1974 | case OVS_KEY_ATTR_SKB_MARK: | 1980 | case OVS_KEY_ATTR_SKB_MARK: |
1975 | case OVS_KEY_ATTR_CT_MARK: | 1981 | case OVS_KEY_ATTR_CT_MARK: |
1976 | case OVS_KEY_ATTR_CT_LABEL: | 1982 | case OVS_KEY_ATTR_CT_LABELS: |
1977 | case OVS_KEY_ATTR_ETHERNET: | 1983 | case OVS_KEY_ATTR_ETHERNET: |
1978 | break; | 1984 | break; |
1979 | 1985 | ||
diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c index f2ea83ba4763..c7f74aab34b9 100644 --- a/net/openvswitch/flow_table.c +++ b/net/openvswitch/flow_table.c | |||
@@ -93,7 +93,8 @@ struct sw_flow *ovs_flow_alloc(void) | |||
93 | 93 | ||
94 | /* Initialize the default stat node. */ | 94 | /* Initialize the default stat node. */ |
95 | stats = kmem_cache_alloc_node(flow_stats_cache, | 95 | stats = kmem_cache_alloc_node(flow_stats_cache, |
96 | GFP_KERNEL | __GFP_ZERO, 0); | 96 | GFP_KERNEL | __GFP_ZERO, |
97 | node_online(0) ? 0 : NUMA_NO_NODE); | ||
97 | if (!stats) | 98 | if (!stats) |
98 | goto err; | 99 | goto err; |
99 | 100 | ||
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c index dc81dc619aa2..12a36ac21eda 100644 --- a/net/openvswitch/vport.c +++ b/net/openvswitch/vport.c | |||
@@ -280,35 +280,19 @@ void ovs_vport_del(struct vport *vport) | |||
280 | */ | 280 | */ |
281 | void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats) | 281 | void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats) |
282 | { | 282 | { |
283 | struct net_device *dev = vport->dev; | 283 | const struct rtnl_link_stats64 *dev_stats; |
284 | int i; | 284 | struct rtnl_link_stats64 temp; |
285 | 285 | ||
286 | memset(stats, 0, sizeof(*stats)); | 286 | dev_stats = dev_get_stats(vport->dev, &temp); |
287 | stats->rx_errors = dev->stats.rx_errors; | 287 | stats->rx_errors = dev_stats->rx_errors; |
288 | stats->tx_errors = dev->stats.tx_errors; | 288 | stats->tx_errors = dev_stats->tx_errors; |
289 | stats->tx_dropped = dev->stats.tx_dropped; | 289 | stats->tx_dropped = dev_stats->tx_dropped; |
290 | stats->rx_dropped = dev->stats.rx_dropped; | 290 | stats->rx_dropped = dev_stats->rx_dropped; |
291 | 291 | ||
292 | stats->rx_dropped += atomic_long_read(&dev->rx_dropped); | 292 | stats->rx_bytes = dev_stats->rx_bytes; |
293 | stats->tx_dropped += atomic_long_read(&dev->tx_dropped); | 293 | stats->rx_packets = dev_stats->rx_packets; |
294 | 294 | stats->tx_bytes = dev_stats->tx_bytes; | |
295 | for_each_possible_cpu(i) { | 295 | stats->tx_packets = dev_stats->tx_packets; |
296 | const struct pcpu_sw_netstats *percpu_stats; | ||
297 | struct pcpu_sw_netstats local_stats; | ||
298 | unsigned int start; | ||
299 | |||
300 | percpu_stats = per_cpu_ptr(dev->tstats, i); | ||
301 | |||
302 | do { | ||
303 | start = u64_stats_fetch_begin_irq(&percpu_stats->syncp); | ||
304 | local_stats = *percpu_stats; | ||
305 | } while (u64_stats_fetch_retry_irq(&percpu_stats->syncp, start)); | ||
306 | |||
307 | stats->rx_bytes += local_stats.rx_bytes; | ||
308 | stats->rx_packets += local_stats.rx_packets; | ||
309 | stats->tx_bytes += local_stats.tx_bytes; | ||
310 | stats->tx_packets += local_stats.tx_packets; | ||
311 | } | ||
312 | } | 296 | } |
313 | 297 | ||
314 | /** | 298 | /** |
@@ -460,6 +444,15 @@ int ovs_vport_receive(struct vport *vport, struct sk_buff *skb, | |||
460 | 444 | ||
461 | OVS_CB(skb)->input_vport = vport; | 445 | OVS_CB(skb)->input_vport = vport; |
462 | OVS_CB(skb)->mru = 0; | 446 | OVS_CB(skb)->mru = 0; |
447 | if (unlikely(dev_net(skb->dev) != ovs_dp_get_net(vport->dp))) { | ||
448 | u32 mark; | ||
449 | |||
450 | mark = skb->mark; | ||
451 | skb_scrub_packet(skb, true); | ||
452 | skb->mark = mark; | ||
453 | tun_info = NULL; | ||
454 | } | ||
455 | |||
463 | /* Extract flow from 'skb' into 'key'. */ | 456 | /* Extract flow from 'skb' into 'key'. */ |
464 | error = ovs_flow_key_extract(tun_info, skb, &key); | 457 | error = ovs_flow_key_extract(tun_info, skb, &key); |
465 | if (unlikely(error)) { | 458 | if (unlikely(error)) { |
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 2d1be4a760fd..32fcdecdb9e2 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c | |||
@@ -31,13 +31,17 @@ | |||
31 | 31 | ||
32 | #define MIRRED_TAB_MASK 7 | 32 | #define MIRRED_TAB_MASK 7 |
33 | static LIST_HEAD(mirred_list); | 33 | static LIST_HEAD(mirred_list); |
34 | static DEFINE_SPINLOCK(mirred_list_lock); | ||
34 | 35 | ||
35 | static void tcf_mirred_release(struct tc_action *a, int bind) | 36 | static void tcf_mirred_release(struct tc_action *a, int bind) |
36 | { | 37 | { |
37 | struct tcf_mirred *m = to_mirred(a); | 38 | struct tcf_mirred *m = to_mirred(a); |
38 | struct net_device *dev = rcu_dereference_protected(m->tcfm_dev, 1); | 39 | struct net_device *dev = rcu_dereference_protected(m->tcfm_dev, 1); |
39 | 40 | ||
41 | /* We could be called either in a RCU callback or with RTNL lock held. */ | ||
42 | spin_lock_bh(&mirred_list_lock); | ||
40 | list_del(&m->tcfm_list); | 43 | list_del(&m->tcfm_list); |
44 | spin_unlock_bh(&mirred_list_lock); | ||
41 | if (dev) | 45 | if (dev) |
42 | dev_put(dev); | 46 | dev_put(dev); |
43 | } | 47 | } |
@@ -103,10 +107,10 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, | |||
103 | } else { | 107 | } else { |
104 | if (bind) | 108 | if (bind) |
105 | return 0; | 109 | return 0; |
106 | if (!ovr) { | 110 | |
107 | tcf_hash_release(a, bind); | 111 | tcf_hash_release(a, bind); |
112 | if (!ovr) | ||
108 | return -EEXIST; | 113 | return -EEXIST; |
109 | } | ||
110 | } | 114 | } |
111 | m = to_mirred(a); | 115 | m = to_mirred(a); |
112 | 116 | ||
@@ -123,7 +127,9 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, | |||
123 | } | 127 | } |
124 | 128 | ||
125 | if (ret == ACT_P_CREATED) { | 129 | if (ret == ACT_P_CREATED) { |
130 | spin_lock_bh(&mirred_list_lock); | ||
126 | list_add(&m->tcfm_list, &mirred_list); | 131 | list_add(&m->tcfm_list, &mirred_list); |
132 | spin_unlock_bh(&mirred_list_lock); | ||
127 | tcf_hash_insert(a); | 133 | tcf_hash_insert(a); |
128 | } | 134 | } |
129 | 135 | ||
@@ -173,6 +179,7 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a, | |||
173 | 179 | ||
174 | skb2->skb_iif = skb->dev->ifindex; | 180 | skb2->skb_iif = skb->dev->ifindex; |
175 | skb2->dev = dev; | 181 | skb2->dev = dev; |
182 | skb_sender_cpu_clear(skb2); | ||
176 | err = dev_queue_xmit(skb2); | 183 | err = dev_queue_xmit(skb2); |
177 | 184 | ||
178 | if (err) { | 185 | if (err) { |
@@ -221,7 +228,8 @@ static int mirred_device_event(struct notifier_block *unused, | |||
221 | struct tcf_mirred *m; | 228 | struct tcf_mirred *m; |
222 | 229 | ||
223 | ASSERT_RTNL(); | 230 | ASSERT_RTNL(); |
224 | if (event == NETDEV_UNREGISTER) | 231 | if (event == NETDEV_UNREGISTER) { |
232 | spin_lock_bh(&mirred_list_lock); | ||
225 | list_for_each_entry(m, &mirred_list, tcfm_list) { | 233 | list_for_each_entry(m, &mirred_list, tcfm_list) { |
226 | if (rcu_access_pointer(m->tcfm_dev) == dev) { | 234 | if (rcu_access_pointer(m->tcfm_dev) == dev) { |
227 | dev_put(dev); | 235 | dev_put(dev); |
@@ -231,6 +239,8 @@ static int mirred_device_event(struct notifier_block *unused, | |||
231 | RCU_INIT_POINTER(m->tcfm_dev, NULL); | 239 | RCU_INIT_POINTER(m->tcfm_dev, NULL); |
232 | } | 240 | } |
233 | } | 241 | } |
242 | spin_unlock_bh(&mirred_list_lock); | ||
243 | } | ||
234 | 244 | ||
235 | return NOTIFY_DONE; | 245 | return NOTIFY_DONE; |
236 | } | 246 | } |
diff --git a/net/sched/sch_hhf.c b/net/sched/sch_hhf.c index 9d15cb6b8cb1..86b04e31e60b 100644 --- a/net/sched/sch_hhf.c +++ b/net/sched/sch_hhf.c | |||
@@ -368,6 +368,15 @@ static unsigned int hhf_drop(struct Qdisc *sch) | |||
368 | return bucket - q->buckets; | 368 | return bucket - q->buckets; |
369 | } | 369 | } |
370 | 370 | ||
371 | static unsigned int hhf_qdisc_drop(struct Qdisc *sch) | ||
372 | { | ||
373 | unsigned int prev_backlog; | ||
374 | |||
375 | prev_backlog = sch->qstats.backlog; | ||
376 | hhf_drop(sch); | ||
377 | return prev_backlog - sch->qstats.backlog; | ||
378 | } | ||
379 | |||
371 | static int hhf_enqueue(struct sk_buff *skb, struct Qdisc *sch) | 380 | static int hhf_enqueue(struct sk_buff *skb, struct Qdisc *sch) |
372 | { | 381 | { |
373 | struct hhf_sched_data *q = qdisc_priv(sch); | 382 | struct hhf_sched_data *q = qdisc_priv(sch); |
@@ -696,7 +705,7 @@ static struct Qdisc_ops hhf_qdisc_ops __read_mostly = { | |||
696 | .enqueue = hhf_enqueue, | 705 | .enqueue = hhf_enqueue, |
697 | .dequeue = hhf_dequeue, | 706 | .dequeue = hhf_dequeue, |
698 | .peek = qdisc_peek_dequeued, | 707 | .peek = qdisc_peek_dequeued, |
699 | .drop = hhf_drop, | 708 | .drop = hhf_qdisc_drop, |
700 | .init = hhf_init, | 709 | .init = hhf_init, |
701 | .reset = hhf_reset, | 710 | .reset = hhf_reset, |
702 | .destroy = hhf_destroy, | 711 | .destroy = hhf_destroy, |
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index fda38f830a10..77f5d17e2612 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/notifier.h> | 16 | #include <linux/notifier.h> |
17 | #include <linux/netdevice.h> | 17 | #include <linux/netdevice.h> |
18 | #include <linux/if_bridge.h> | 18 | #include <linux/if_bridge.h> |
19 | #include <linux/if_vlan.h> | ||
19 | #include <net/ip_fib.h> | 20 | #include <net/ip_fib.h> |
20 | #include <net/switchdev.h> | 21 | #include <net/switchdev.h> |
21 | 22 | ||
@@ -634,6 +635,8 @@ static int switchdev_port_br_afspec(struct net_device *dev, | |||
634 | if (nla_len(attr) != sizeof(struct bridge_vlan_info)) | 635 | if (nla_len(attr) != sizeof(struct bridge_vlan_info)) |
635 | return -EINVAL; | 636 | return -EINVAL; |
636 | vinfo = nla_data(attr); | 637 | vinfo = nla_data(attr); |
638 | if (!vinfo->vid || vinfo->vid >= VLAN_VID_MASK) | ||
639 | return -EINVAL; | ||
637 | vlan->flags = vinfo->flags; | 640 | vlan->flags = vinfo->flags; |
638 | if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) { | 641 | if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) { |
639 | if (vlan->vid_begin) | 642 | if (vlan->vid_begin) |
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index a82c5848d4bc..5351a3f97e8e 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
@@ -357,7 +357,7 @@ static inline u32 msg_importance(struct tipc_msg *m) | |||
357 | if (likely((usr <= TIPC_CRITICAL_IMPORTANCE) && !msg_errcode(m))) | 357 | if (likely((usr <= TIPC_CRITICAL_IMPORTANCE) && !msg_errcode(m))) |
358 | return usr; | 358 | return usr; |
359 | if ((usr == MSG_FRAGMENTER) || (usr == MSG_BUNDLER)) | 359 | if ((usr == MSG_FRAGMENTER) || (usr == MSG_BUNDLER)) |
360 | return msg_bits(m, 5, 13, 0x7); | 360 | return msg_bits(m, 9, 0, 0x7); |
361 | return TIPC_SYSTEM_IMPORTANCE; | 361 | return TIPC_SYSTEM_IMPORTANCE; |
362 | } | 362 | } |
363 | 363 | ||
@@ -366,7 +366,7 @@ static inline void msg_set_importance(struct tipc_msg *m, u32 i) | |||
366 | int usr = msg_user(m); | 366 | int usr = msg_user(m); |
367 | 367 | ||
368 | if (likely((usr == MSG_FRAGMENTER) || (usr == MSG_BUNDLER))) | 368 | if (likely((usr == MSG_FRAGMENTER) || (usr == MSG_BUNDLER))) |
369 | msg_set_bits(m, 5, 13, 0x7, i); | 369 | msg_set_bits(m, 9, 0, 0x7, i); |
370 | else if (i < TIPC_SYSTEM_IMPORTANCE) | 370 | else if (i < TIPC_SYSTEM_IMPORTANCE) |
371 | msg_set_user(m, i); | 371 | msg_set_user(m, i); |
372 | else | 372 | else |
diff --git a/net/tipc/node.c b/net/tipc/node.c index 703875fd6cde..2c32a83037a3 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -1116,7 +1116,7 @@ static bool tipc_node_check_state(struct tipc_node *n, struct sk_buff *skb, | |||
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | /* Ignore duplicate packets */ | 1118 | /* Ignore duplicate packets */ |
1119 | if (less(oseqno, rcv_nxt)) | 1119 | if ((usr != LINK_PROTOCOL) && less(oseqno, rcv_nxt)) |
1120 | return true; | 1120 | return true; |
1121 | 1121 | ||
1122 | /* Initiate or update failover mode if applicable */ | 1122 | /* Initiate or update failover mode if applicable */ |
@@ -1146,8 +1146,8 @@ static bool tipc_node_check_state(struct tipc_node *n, struct sk_buff *skb, | |||
1146 | if (!pl || !tipc_link_is_up(pl)) | 1146 | if (!pl || !tipc_link_is_up(pl)) |
1147 | return true; | 1147 | return true; |
1148 | 1148 | ||
1149 | /* Initiate or update synch mode if applicable */ | 1149 | /* Initiate synch mode if applicable */ |
1150 | if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG)) { | 1150 | if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG) && (oseqno == 1)) { |
1151 | syncpt = iseqno + exp_pkts - 1; | 1151 | syncpt = iseqno + exp_pkts - 1; |
1152 | if (!tipc_link_is_up(l)) { | 1152 | if (!tipc_link_is_up(l)) { |
1153 | tipc_link_fsm_evt(l, LINK_ESTABLISH_EVT); | 1153 | tipc_link_fsm_evt(l, LINK_ESTABLISH_EVT); |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index ef31b40ad550..94f658235fb4 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -2064,6 +2064,11 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state) | |||
2064 | goto out; | 2064 | goto out; |
2065 | } | 2065 | } |
2066 | 2066 | ||
2067 | if (flags & MSG_PEEK) | ||
2068 | skip = sk_peek_offset(sk, flags); | ||
2069 | else | ||
2070 | skip = 0; | ||
2071 | |||
2067 | do { | 2072 | do { |
2068 | int chunk; | 2073 | int chunk; |
2069 | struct sk_buff *skb, *last; | 2074 | struct sk_buff *skb, *last; |
@@ -2112,7 +2117,6 @@ unlock: | |||
2112 | break; | 2117 | break; |
2113 | } | 2118 | } |
2114 | 2119 | ||
2115 | skip = sk_peek_offset(sk, flags); | ||
2116 | while (skip >= unix_skb_len(skb)) { | 2120 | while (skip >= unix_skb_len(skb)) { |
2117 | skip -= unix_skb_len(skb); | 2121 | skip -= unix_skb_len(skb); |
2118 | last = skb; | 2122 | last = skb; |
@@ -2179,14 +2183,12 @@ unlock: | |||
2179 | if (UNIXCB(skb).fp) | 2183 | if (UNIXCB(skb).fp) |
2180 | scm.fp = scm_fp_dup(UNIXCB(skb).fp); | 2184 | scm.fp = scm_fp_dup(UNIXCB(skb).fp); |
2181 | 2185 | ||
2182 | if (skip) { | 2186 | sk_peek_offset_fwd(sk, chunk); |
2183 | sk_peek_offset_fwd(sk, chunk); | ||
2184 | skip -= chunk; | ||
2185 | } | ||
2186 | 2187 | ||
2187 | if (UNIXCB(skb).fp) | 2188 | if (UNIXCB(skb).fp) |
2188 | break; | 2189 | break; |
2189 | 2190 | ||
2191 | skip = 0; | ||
2190 | last = skb; | 2192 | last = skb; |
2191 | last_len = skb->len; | 2193 | last_len = skb->len; |
2192 | unix_state_lock(sk); | 2194 | unix_state_lock(sk); |
diff --git a/security/keys/gc.c b/security/keys/gc.c index 39eac1fd5706..addf060399e0 100644 --- a/security/keys/gc.c +++ b/security/keys/gc.c | |||
@@ -134,8 +134,10 @@ static noinline void key_gc_unused_keys(struct list_head *keys) | |||
134 | kdebug("- %u", key->serial); | 134 | kdebug("- %u", key->serial); |
135 | key_check(key); | 135 | key_check(key); |
136 | 136 | ||
137 | /* Throw away the key data */ | 137 | /* Throw away the key data if the key is instantiated */ |
138 | if (key->type->destroy) | 138 | if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags) && |
139 | !test_bit(KEY_FLAG_NEGATIVE, &key->flags) && | ||
140 | key->type->destroy) | ||
139 | key->type->destroy(key); | 141 | key->type->destroy(key); |
140 | 142 | ||
141 | security_key_free(key); | 143 | security_key_free(key); |
diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 486ef6fa393b..0d6253124278 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c | |||
@@ -440,6 +440,9 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx, | |||
440 | 440 | ||
441 | kenter(""); | 441 | kenter(""); |
442 | 442 | ||
443 | if (ctx->index_key.type == &key_type_keyring) | ||
444 | return ERR_PTR(-EPERM); | ||
445 | |||
443 | user = key_user_lookup(current_fsuid()); | 446 | user = key_user_lookup(current_fsuid()); |
444 | if (!user) | 447 | if (!user) |
445 | return ERR_PTR(-ENOMEM); | 448 | return ERR_PTR(-ENOMEM); |
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index 38590b322c54..fbd5dad0c484 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/dmaengine.h> | 17 | #include <linux/dmaengine.h> |
18 | #include <linux/dma/pxa-dma.h> | ||
18 | 19 | ||
19 | #include <sound/core.h> | 20 | #include <sound/core.h> |
20 | #include <sound/pcm.h> | 21 | #include <sound/pcm.h> |
@@ -43,7 +44,11 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = { | |||
43 | .reset = pxa2xx_ac97_reset, | 44 | .reset = pxa2xx_ac97_reset, |
44 | }; | 45 | }; |
45 | 46 | ||
46 | static unsigned long pxa2xx_ac97_pcm_out_req = 12; | 47 | static struct pxad_param pxa2xx_ac97_pcm_out_req = { |
48 | .prio = PXAD_PRIO_LOWEST, | ||
49 | .drcmr = 12, | ||
50 | }; | ||
51 | |||
47 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_out = { | 52 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_out = { |
48 | .addr = __PREG(PCDR), | 53 | .addr = __PREG(PCDR), |
49 | .addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, | 54 | .addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, |
@@ -51,7 +56,11 @@ static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_out = { | |||
51 | .filter_data = &pxa2xx_ac97_pcm_out_req, | 56 | .filter_data = &pxa2xx_ac97_pcm_out_req, |
52 | }; | 57 | }; |
53 | 58 | ||
54 | static unsigned long pxa2xx_ac97_pcm_in_req = 11; | 59 | static struct pxad_param pxa2xx_ac97_pcm_in_req = { |
60 | .prio = PXAD_PRIO_LOWEST, | ||
61 | .drcmr = 11, | ||
62 | }; | ||
63 | |||
55 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_in = { | 64 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_in = { |
56 | .addr = __PREG(PCDR), | 65 | .addr = __PREG(PCDR), |
57 | .addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, | 66 | .addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, |
diff --git a/sound/arm/pxa2xx-pcm-lib.c b/sound/arm/pxa2xx-pcm-lib.c index 01f8fdc42b1b..e9b98af6b52c 100644 --- a/sound/arm/pxa2xx-pcm-lib.c +++ b/sound/arm/pxa2xx-pcm-lib.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/dma-mapping.h> | 9 | #include <linux/dma-mapping.h> |
10 | #include <linux/dmaengine.h> | 10 | #include <linux/dmaengine.h> |
11 | #include <linux/dma/pxa-dma.h> | ||
11 | 12 | ||
12 | #include <sound/core.h> | 13 | #include <sound/core.h> |
13 | #include <sound/pcm.h> | 14 | #include <sound/pcm.h> |
@@ -15,8 +16,6 @@ | |||
15 | #include <sound/pxa2xx-lib.h> | 16 | #include <sound/pxa2xx-lib.h> |
16 | #include <sound/dmaengine_pcm.h> | 17 | #include <sound/dmaengine_pcm.h> |
17 | 18 | ||
18 | #include <mach/dma.h> | ||
19 | |||
20 | #include "pxa2xx-pcm.h" | 19 | #include "pxa2xx-pcm.h" |
21 | 20 | ||
22 | static const struct snd_pcm_hardware pxa2xx_pcm_hardware = { | 21 | static const struct snd_pcm_hardware pxa2xx_pcm_hardware = { |
@@ -31,7 +30,7 @@ static const struct snd_pcm_hardware pxa2xx_pcm_hardware = { | |||
31 | .period_bytes_min = 32, | 30 | .period_bytes_min = 32, |
32 | .period_bytes_max = 8192 - 32, | 31 | .period_bytes_max = 8192 - 32, |
33 | .periods_min = 1, | 32 | .periods_min = 1, |
34 | .periods_max = PAGE_SIZE/sizeof(pxa_dma_desc), | 33 | .periods_max = 256, |
35 | .buffer_bytes_max = 128 * 1024, | 34 | .buffer_bytes_max = 128 * 1024, |
36 | .fifo_size = 32, | 35 | .fifo_size = 32, |
37 | }; | 36 | }; |
@@ -39,65 +38,29 @@ static const struct snd_pcm_hardware pxa2xx_pcm_hardware = { | |||
39 | int __pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream, | 38 | int __pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream, |
40 | struct snd_pcm_hw_params *params) | 39 | struct snd_pcm_hw_params *params) |
41 | { | 40 | { |
42 | struct snd_pcm_runtime *runtime = substream->runtime; | 41 | struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); |
43 | struct pxa2xx_runtime_data *rtd = runtime->private_data; | 42 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
44 | size_t totsize = params_buffer_bytes(params); | 43 | struct snd_dmaengine_dai_dma_data *dma_params; |
45 | size_t period = params_period_bytes(params); | 44 | struct dma_slave_config config; |
46 | pxa_dma_desc *dma_desc; | 45 | int ret; |
47 | dma_addr_t dma_buff_phys, next_desc_phys; | ||
48 | u32 dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG; | ||
49 | 46 | ||
50 | /* temporary transition hack */ | 47 | dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); |
51 | switch (rtd->params->addr_width) { | 48 | if (!dma_params) |
52 | case DMA_SLAVE_BUSWIDTH_1_BYTE: | 49 | return 0; |
53 | dcmd |= DCMD_WIDTH1; | ||
54 | break; | ||
55 | case DMA_SLAVE_BUSWIDTH_2_BYTES: | ||
56 | dcmd |= DCMD_WIDTH2; | ||
57 | break; | ||
58 | case DMA_SLAVE_BUSWIDTH_4_BYTES: | ||
59 | dcmd |= DCMD_WIDTH4; | ||
60 | break; | ||
61 | default: | ||
62 | /* can't happen */ | ||
63 | break; | ||
64 | } | ||
65 | 50 | ||
66 | switch (rtd->params->maxburst) { | 51 | ret = snd_hwparams_to_dma_slave_config(substream, params, &config); |
67 | case 8: | 52 | if (ret) |
68 | dcmd |= DCMD_BURST8; | 53 | return ret; |
69 | break; | ||
70 | case 16: | ||
71 | dcmd |= DCMD_BURST16; | ||
72 | break; | ||
73 | case 32: | ||
74 | dcmd |= DCMD_BURST32; | ||
75 | break; | ||
76 | } | ||
77 | 54 | ||
78 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); | 55 | snd_dmaengine_pcm_set_config_from_dai_data(substream, |
79 | runtime->dma_bytes = totsize; | 56 | snd_soc_dai_get_dma_data(rtd->cpu_dai, substream), |
57 | &config); | ||
80 | 58 | ||
81 | dma_desc = rtd->dma_desc_array; | 59 | ret = dmaengine_slave_config(chan, &config); |
82 | next_desc_phys = rtd->dma_desc_array_phys; | 60 | if (ret) |
83 | dma_buff_phys = runtime->dma_addr; | 61 | return ret; |
84 | do { | 62 | |
85 | next_desc_phys += sizeof(pxa_dma_desc); | 63 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); |
86 | dma_desc->ddadr = next_desc_phys; | ||
87 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
88 | dma_desc->dsadr = dma_buff_phys; | ||
89 | dma_desc->dtadr = rtd->params->addr; | ||
90 | } else { | ||
91 | dma_desc->dsadr = rtd->params->addr; | ||
92 | dma_desc->dtadr = dma_buff_phys; | ||
93 | } | ||
94 | if (period > totsize) | ||
95 | period = totsize; | ||
96 | dma_desc->dcmd = dcmd | period | DCMD_ENDIRQEN; | ||
97 | dma_desc++; | ||
98 | dma_buff_phys += period; | ||
99 | } while (totsize -= period); | ||
100 | dma_desc[-1].ddadr = rtd->dma_desc_array_phys; | ||
101 | 64 | ||
102 | return 0; | 65 | return 0; |
103 | } | 66 | } |
@@ -105,13 +68,6 @@ EXPORT_SYMBOL(__pxa2xx_pcm_hw_params); | |||
105 | 68 | ||
106 | int __pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream) | 69 | int __pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream) |
107 | { | 70 | { |
108 | struct pxa2xx_runtime_data *rtd = substream->runtime->private_data; | ||
109 | |||
110 | if (rtd && rtd->params && rtd->params->filter_data) { | ||
111 | unsigned long req = *(unsigned long *) rtd->params->filter_data; | ||
112 | DRCMR(req) = 0; | ||
113 | } | ||
114 | |||
115 | snd_pcm_set_runtime_buffer(substream, NULL); | 71 | snd_pcm_set_runtime_buffer(substream, NULL); |
116 | return 0; | 72 | return 0; |
117 | } | 73 | } |
@@ -119,100 +75,36 @@ EXPORT_SYMBOL(__pxa2xx_pcm_hw_free); | |||
119 | 75 | ||
120 | int pxa2xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | 76 | int pxa2xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
121 | { | 77 | { |
122 | struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; | 78 | return snd_dmaengine_pcm_trigger(substream, cmd); |
123 | int ret = 0; | ||
124 | |||
125 | switch (cmd) { | ||
126 | case SNDRV_PCM_TRIGGER_START: | ||
127 | DDADR(prtd->dma_ch) = prtd->dma_desc_array_phys; | ||
128 | DCSR(prtd->dma_ch) = DCSR_RUN; | ||
129 | break; | ||
130 | |||
131 | case SNDRV_PCM_TRIGGER_STOP: | ||
132 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
133 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
134 | DCSR(prtd->dma_ch) &= ~DCSR_RUN; | ||
135 | break; | ||
136 | |||
137 | case SNDRV_PCM_TRIGGER_RESUME: | ||
138 | DCSR(prtd->dma_ch) |= DCSR_RUN; | ||
139 | break; | ||
140 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
141 | DDADR(prtd->dma_ch) = prtd->dma_desc_array_phys; | ||
142 | DCSR(prtd->dma_ch) |= DCSR_RUN; | ||
143 | break; | ||
144 | |||
145 | default: | ||
146 | ret = -EINVAL; | ||
147 | } | ||
148 | |||
149 | return ret; | ||
150 | } | 79 | } |
151 | EXPORT_SYMBOL(pxa2xx_pcm_trigger); | 80 | EXPORT_SYMBOL(pxa2xx_pcm_trigger); |
152 | 81 | ||
153 | snd_pcm_uframes_t | 82 | snd_pcm_uframes_t |
154 | pxa2xx_pcm_pointer(struct snd_pcm_substream *substream) | 83 | pxa2xx_pcm_pointer(struct snd_pcm_substream *substream) |
155 | { | 84 | { |
156 | struct snd_pcm_runtime *runtime = substream->runtime; | 85 | return snd_dmaengine_pcm_pointer(substream); |
157 | struct pxa2xx_runtime_data *prtd = runtime->private_data; | ||
158 | |||
159 | dma_addr_t ptr = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? | ||
160 | DSADR(prtd->dma_ch) : DTADR(prtd->dma_ch); | ||
161 | snd_pcm_uframes_t x = bytes_to_frames(runtime, ptr - runtime->dma_addr); | ||
162 | |||
163 | if (x == runtime->buffer_size) | ||
164 | x = 0; | ||
165 | return x; | ||
166 | } | 86 | } |
167 | EXPORT_SYMBOL(pxa2xx_pcm_pointer); | 87 | EXPORT_SYMBOL(pxa2xx_pcm_pointer); |
168 | 88 | ||
169 | int __pxa2xx_pcm_prepare(struct snd_pcm_substream *substream) | 89 | int __pxa2xx_pcm_prepare(struct snd_pcm_substream *substream) |
170 | { | 90 | { |
171 | struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; | ||
172 | unsigned long req; | ||
173 | |||
174 | if (!prtd || !prtd->params) | ||
175 | return 0; | ||
176 | |||
177 | if (prtd->dma_ch == -1) | ||
178 | return -EINVAL; | ||
179 | |||
180 | DCSR(prtd->dma_ch) &= ~DCSR_RUN; | ||
181 | DCSR(prtd->dma_ch) = 0; | ||
182 | DCMD(prtd->dma_ch) = 0; | ||
183 | req = *(unsigned long *) prtd->params->filter_data; | ||
184 | DRCMR(req) = prtd->dma_ch | DRCMR_MAPVLD; | ||
185 | |||
186 | return 0; | 91 | return 0; |
187 | } | 92 | } |
188 | EXPORT_SYMBOL(__pxa2xx_pcm_prepare); | 93 | EXPORT_SYMBOL(__pxa2xx_pcm_prepare); |
189 | 94 | ||
190 | void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id) | ||
191 | { | ||
192 | struct snd_pcm_substream *substream = dev_id; | ||
193 | int dcsr; | ||
194 | |||
195 | dcsr = DCSR(dma_ch); | ||
196 | DCSR(dma_ch) = dcsr & ~DCSR_STOPIRQEN; | ||
197 | |||
198 | if (dcsr & DCSR_ENDINTR) { | ||
199 | snd_pcm_period_elapsed(substream); | ||
200 | } else { | ||
201 | printk(KERN_ERR "DMA error on channel %d (DCSR=%#x)\n", | ||
202 | dma_ch, dcsr); | ||
203 | snd_pcm_stop_xrun(substream); | ||
204 | } | ||
205 | } | ||
206 | EXPORT_SYMBOL(pxa2xx_pcm_dma_irq); | ||
207 | |||
208 | int __pxa2xx_pcm_open(struct snd_pcm_substream *substream) | 95 | int __pxa2xx_pcm_open(struct snd_pcm_substream *substream) |
209 | { | 96 | { |
97 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
210 | struct snd_pcm_runtime *runtime = substream->runtime; | 98 | struct snd_pcm_runtime *runtime = substream->runtime; |
211 | struct pxa2xx_runtime_data *rtd; | 99 | struct snd_dmaengine_dai_dma_data *dma_params; |
212 | int ret; | 100 | int ret; |
213 | 101 | ||
214 | runtime->hw = pxa2xx_pcm_hardware; | 102 | runtime->hw = pxa2xx_pcm_hardware; |
215 | 103 | ||
104 | dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
105 | if (!dma_params) | ||
106 | return 0; | ||
107 | |||
216 | /* | 108 | /* |
217 | * For mysterious reasons (and despite what the manual says) | 109 | * For mysterious reasons (and despite what the manual says) |
218 | * playback samples are lost if the DMA count is not a multiple | 110 | * playback samples are lost if the DMA count is not a multiple |
@@ -221,48 +113,27 @@ int __pxa2xx_pcm_open(struct snd_pcm_substream *substream) | |||
221 | ret = snd_pcm_hw_constraint_step(runtime, 0, | 113 | ret = snd_pcm_hw_constraint_step(runtime, 0, |
222 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); | 114 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); |
223 | if (ret) | 115 | if (ret) |
224 | goto out; | 116 | return ret; |
225 | 117 | ||
226 | ret = snd_pcm_hw_constraint_step(runtime, 0, | 118 | ret = snd_pcm_hw_constraint_step(runtime, 0, |
227 | SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32); | 119 | SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32); |
228 | if (ret) | 120 | if (ret) |
229 | goto out; | 121 | return ret; |
230 | 122 | ||
231 | ret = snd_pcm_hw_constraint_integer(runtime, | 123 | ret = snd_pcm_hw_constraint_integer(runtime, |
232 | SNDRV_PCM_HW_PARAM_PERIODS); | 124 | SNDRV_PCM_HW_PARAM_PERIODS); |
233 | if (ret < 0) | 125 | if (ret < 0) |
234 | goto out; | 126 | return ret; |
235 | |||
236 | ret = -ENOMEM; | ||
237 | rtd = kzalloc(sizeof(*rtd), GFP_KERNEL); | ||
238 | if (!rtd) | ||
239 | goto out; | ||
240 | rtd->dma_desc_array = | ||
241 | dma_alloc_writecombine(substream->pcm->card->dev, PAGE_SIZE, | ||
242 | &rtd->dma_desc_array_phys, GFP_KERNEL); | ||
243 | if (!rtd->dma_desc_array) | ||
244 | goto err1; | ||
245 | 127 | ||
246 | rtd->dma_ch = -1; | 128 | return snd_dmaengine_pcm_open_request_chan(substream, |
247 | runtime->private_data = rtd; | 129 | pxad_filter_fn, |
248 | return 0; | 130 | dma_params->filter_data); |
249 | |||
250 | err1: | ||
251 | kfree(rtd); | ||
252 | out: | ||
253 | return ret; | ||
254 | } | 131 | } |
255 | EXPORT_SYMBOL(__pxa2xx_pcm_open); | 132 | EXPORT_SYMBOL(__pxa2xx_pcm_open); |
256 | 133 | ||
257 | int __pxa2xx_pcm_close(struct snd_pcm_substream *substream) | 134 | int __pxa2xx_pcm_close(struct snd_pcm_substream *substream) |
258 | { | 135 | { |
259 | struct snd_pcm_runtime *runtime = substream->runtime; | 136 | return snd_dmaengine_pcm_close_release_chan(substream); |
260 | struct pxa2xx_runtime_data *rtd = runtime->private_data; | ||
261 | |||
262 | dma_free_writecombine(substream->pcm->card->dev, PAGE_SIZE, | ||
263 | rtd->dma_desc_array, rtd->dma_desc_array_phys); | ||
264 | kfree(rtd); | ||
265 | return 0; | ||
266 | } | 137 | } |
267 | EXPORT_SYMBOL(__pxa2xx_pcm_close); | 138 | EXPORT_SYMBOL(__pxa2xx_pcm_close); |
268 | 139 | ||
diff --git a/sound/arm/pxa2xx-pcm.c b/sound/arm/pxa2xx-pcm.c index 83be8e3f095e..83fcfac97739 100644 --- a/sound/arm/pxa2xx-pcm.c +++ b/sound/arm/pxa2xx-pcm.c | |||
@@ -46,17 +46,13 @@ static int pxa2xx_pcm_open(struct snd_pcm_substream *substream) | |||
46 | 46 | ||
47 | rtd->params = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? | 47 | rtd->params = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? |
48 | client->playback_params : client->capture_params; | 48 | client->playback_params : client->capture_params; |
49 | ret = pxa_request_dma("dma", DMA_PRIO_LOW, | ||
50 | pxa2xx_pcm_dma_irq, substream); | ||
51 | if (ret < 0) | ||
52 | goto err2; | ||
53 | rtd->dma_ch = ret; | ||
54 | 49 | ||
55 | ret = client->startup(substream); | 50 | ret = client->startup(substream); |
56 | if (!ret) | 51 | if (!ret) |
57 | goto out; | 52 | goto err2; |
53 | |||
54 | return 0; | ||
58 | 55 | ||
59 | pxa_free_dma(rtd->dma_ch); | ||
60 | err2: | 56 | err2: |
61 | __pxa2xx_pcm_close(substream); | 57 | __pxa2xx_pcm_close(substream); |
62 | out: | 58 | out: |
@@ -66,9 +62,7 @@ static int pxa2xx_pcm_open(struct snd_pcm_substream *substream) | |||
66 | static int pxa2xx_pcm_close(struct snd_pcm_substream *substream) | 62 | static int pxa2xx_pcm_close(struct snd_pcm_substream *substream) |
67 | { | 63 | { |
68 | struct pxa2xx_pcm_client *client = substream->private_data; | 64 | struct pxa2xx_pcm_client *client = substream->private_data; |
69 | struct pxa2xx_runtime_data *rtd = substream->runtime->private_data; | ||
70 | 65 | ||
71 | pxa_free_dma(rtd->dma_ch); | ||
72 | client->shutdown(substream); | 66 | client->shutdown(substream); |
73 | 67 | ||
74 | return __pxa2xx_pcm_close(substream); | 68 | return __pxa2xx_pcm_close(substream); |
diff --git a/sound/arm/pxa2xx-pcm.h b/sound/arm/pxa2xx-pcm.h index 00330985beec..8fa2b7c9e6b8 100644 --- a/sound/arm/pxa2xx-pcm.h +++ b/sound/arm/pxa2xx-pcm.h | |||
@@ -13,8 +13,6 @@ | |||
13 | struct pxa2xx_runtime_data { | 13 | struct pxa2xx_runtime_data { |
14 | int dma_ch; | 14 | int dma_ch; |
15 | struct snd_dmaengine_dai_dma_data *params; | 15 | struct snd_dmaengine_dai_dma_data *params; |
16 | struct pxa_dma_desc *dma_desc_array; | ||
17 | dma_addr_t dma_desc_array_phys; | ||
18 | }; | 16 | }; |
19 | 17 | ||
20 | struct pxa2xx_pcm_client { | 18 | struct pxa2xx_pcm_client { |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 2eeaf5ea20f9..83741887faa1 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -3323,10 +3323,8 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec) | |||
3323 | int dev, err; | 3323 | int dev, err; |
3324 | 3324 | ||
3325 | err = snd_hda_codec_parse_pcms(codec); | 3325 | err = snd_hda_codec_parse_pcms(codec); |
3326 | if (err < 0) { | 3326 | if (err < 0) |
3327 | snd_hda_codec_reset(codec); | ||
3328 | return err; | 3327 | return err; |
3329 | } | ||
3330 | 3328 | ||
3331 | /* attach a new PCM streams */ | 3329 | /* attach a new PCM streams */ |
3332 | list_for_each_entry(cpcm, &codec->pcm_list_head, list) { | 3330 | list_for_each_entry(cpcm, &codec->pcm_list_head, list) { |
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 7de792b06007..7ff7d88e46dd 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig | |||
@@ -9,7 +9,6 @@ menuconfig SND_SOC | |||
9 | select SND_JACK if INPUT=y || INPUT=SND | 9 | select SND_JACK if INPUT=y || INPUT=SND |
10 | select REGMAP_I2C if I2C | 10 | select REGMAP_I2C if I2C |
11 | select REGMAP_SPI if SPI_MASTER | 11 | select REGMAP_SPI if SPI_MASTER |
12 | select SND_COMPRESS_OFFLOAD | ||
13 | ---help--- | 12 | ---help--- |
14 | 13 | ||
15 | If you want ASoC support, you should say Y here and also to the | 14 | If you want ASoC support, you should say Y here and also to the |
@@ -30,6 +29,10 @@ config SND_SOC_GENERIC_DMAENGINE_PCM | |||
30 | bool | 29 | bool |
31 | select SND_DMAENGINE_PCM | 30 | select SND_DMAENGINE_PCM |
32 | 31 | ||
32 | config SND_SOC_COMPRESS | ||
33 | bool | ||
34 | select SND_COMPRESS_OFFLOAD | ||
35 | |||
33 | config SND_SOC_TOPOLOGY | 36 | config SND_SOC_TOPOLOGY |
34 | bool | 37 | bool |
35 | 38 | ||
diff --git a/sound/soc/Makefile b/sound/soc/Makefile index af0a5714e107..8eb06db32fa0 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile | |||
@@ -1,5 +1,6 @@ | |||
1 | snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o | 1 | snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o |
2 | snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o soc-ops.o | 2 | snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o |
3 | snd-soc-core-$(CONFIG_SND_SOC_COMPRESS) += soc-compress.o | ||
3 | 4 | ||
4 | ifneq ($(CONFIG_SND_SOC_TOPOLOGY),) | 5 | ifneq ($(CONFIG_SND_SOC_TOPOLOGY),) |
5 | snd-soc-core-objs += soc-topology.o | 6 | snd-soc-core-objs += soc-topology.o |
diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index 1489cd461aec..2d30464b81ce 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig | |||
@@ -59,4 +59,13 @@ config SND_AT91_SOC_SAM9X5_WM8731 | |||
59 | help | 59 | help |
60 | Say Y if you want to add support for audio SoC on an | 60 | Say Y if you want to add support for audio SoC on an |
61 | at91sam9x5 based board that is using WM8731 codec. | 61 | at91sam9x5 based board that is using WM8731 codec. |
62 | |||
63 | config SND_ATMEL_SOC_CLASSD | ||
64 | tristate "Atmel ASoC driver for boards using CLASSD" | ||
65 | depends on ARCH_AT91 || COMPILE_TEST | ||
66 | select SND_ATMEL_SOC_DMA | ||
67 | select REGMAP_MMIO | ||
68 | help | ||
69 | Say Y if you want to add support for Atmel ASoC driver for boards using | ||
70 | CLASSD. | ||
62 | endif | 71 | endif |
diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile index b327e5cc8de3..f6f7db428216 100644 --- a/sound/soc/atmel/Makefile +++ b/sound/soc/atmel/Makefile | |||
@@ -11,7 +11,9 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o | |||
11 | snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o | 11 | snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o |
12 | snd-atmel-soc-wm8904-objs := atmel_wm8904.o | 12 | snd-atmel-soc-wm8904-objs := atmel_wm8904.o |
13 | snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o | 13 | snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o |
14 | snd-atmel-soc-classd-objs := atmel-classd.o | ||
14 | 15 | ||
15 | obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o | 16 | obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o |
16 | obj-$(CONFIG_SND_ATMEL_SOC_WM8904) += snd-atmel-soc-wm8904.o | 17 | obj-$(CONFIG_SND_ATMEL_SOC_WM8904) += snd-atmel-soc-wm8904.o |
17 | obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o | 18 | obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o |
19 | obj-$(CONFIG_SND_ATMEL_SOC_CLASSD) += snd-atmel-soc-classd.o | ||
diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c new file mode 100644 index 000000000000..8276675730ef --- /dev/null +++ b/sound/soc/atmel/atmel-classd.c | |||
@@ -0,0 +1,679 @@ | |||
1 | /* Atmel ALSA SoC Audio Class D Amplifier (CLASSD) driver | ||
2 | * | ||
3 | * Copyright (C) 2015 Atmel | ||
4 | * | ||
5 | * Author: Songjun Wu <songjun.wu@atmel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 or later | ||
9 | * as published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/of.h> | ||
13 | #include <linux/clk.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/regmap.h> | ||
17 | #include <sound/core.h> | ||
18 | #include <sound/dmaengine_pcm.h> | ||
19 | #include <sound/pcm_params.h> | ||
20 | #include <sound/tlv.h> | ||
21 | #include "atmel-classd.h" | ||
22 | |||
23 | struct atmel_classd_pdata { | ||
24 | bool non_overlap_enable; | ||
25 | int non_overlap_time; | ||
26 | int pwm_type; | ||
27 | const char *card_name; | ||
28 | }; | ||
29 | |||
30 | struct atmel_classd { | ||
31 | dma_addr_t phy_base; | ||
32 | struct regmap *regmap; | ||
33 | struct clk *pclk; | ||
34 | struct clk *gclk; | ||
35 | struct clk *aclk; | ||
36 | int irq; | ||
37 | const struct atmel_classd_pdata *pdata; | ||
38 | }; | ||
39 | |||
40 | #ifdef CONFIG_OF | ||
41 | static const struct of_device_id atmel_classd_of_match[] = { | ||
42 | { | ||
43 | .compatible = "atmel,sama5d2-classd", | ||
44 | }, { | ||
45 | /* sentinel */ | ||
46 | } | ||
47 | }; | ||
48 | MODULE_DEVICE_TABLE(of, atmel_classd_of_match); | ||
49 | |||
50 | static struct atmel_classd_pdata *atmel_classd_dt_init(struct device *dev) | ||
51 | { | ||
52 | struct device_node *np = dev->of_node; | ||
53 | struct atmel_classd_pdata *pdata; | ||
54 | const char *pwm_type; | ||
55 | int ret; | ||
56 | |||
57 | if (!np) { | ||
58 | dev_err(dev, "device node not found\n"); | ||
59 | return ERR_PTR(-EINVAL); | ||
60 | } | ||
61 | |||
62 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
63 | if (!pdata) | ||
64 | return ERR_PTR(-ENOMEM); | ||
65 | |||
66 | ret = of_property_read_string(np, "atmel,pwm-type", &pwm_type); | ||
67 | if ((ret == 0) && (strcmp(pwm_type, "diff") == 0)) | ||
68 | pdata->pwm_type = CLASSD_MR_PWMTYP_DIFF; | ||
69 | else | ||
70 | pdata->pwm_type = CLASSD_MR_PWMTYP_SINGLE; | ||
71 | |||
72 | ret = of_property_read_u32(np, | ||
73 | "atmel,non-overlap-time", &pdata->non_overlap_time); | ||
74 | if (ret) | ||
75 | pdata->non_overlap_enable = false; | ||
76 | else | ||
77 | pdata->non_overlap_enable = true; | ||
78 | |||
79 | ret = of_property_read_string(np, "atmel,model", &pdata->card_name); | ||
80 | if (ret) | ||
81 | pdata->card_name = "CLASSD"; | ||
82 | |||
83 | return pdata; | ||
84 | } | ||
85 | #else | ||
86 | static inline struct atmel_classd_pdata * | ||
87 | atmel_classd_dt_init(struct device *dev) | ||
88 | { | ||
89 | return ERR_PTR(-EINVAL); | ||
90 | } | ||
91 | #endif | ||
92 | |||
93 | #define ATMEL_CLASSD_RATES (SNDRV_PCM_RATE_8000 \ | ||
94 | | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 \ | ||
95 | | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 \ | ||
96 | | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 \ | ||
97 | | SNDRV_PCM_RATE_96000) | ||
98 | |||
99 | static const struct snd_pcm_hardware atmel_classd_hw = { | ||
100 | .info = SNDRV_PCM_INFO_MMAP | ||
101 | | SNDRV_PCM_INFO_MMAP_VALID | ||
102 | | SNDRV_PCM_INFO_INTERLEAVED | ||
103 | | SNDRV_PCM_INFO_RESUME | ||
104 | | SNDRV_PCM_INFO_PAUSE, | ||
105 | .formats = (SNDRV_PCM_FMTBIT_S16_LE), | ||
106 | .rates = ATMEL_CLASSD_RATES, | ||
107 | .rate_min = 8000, | ||
108 | .rate_max = 96000, | ||
109 | .channels_min = 2, | ||
110 | .channels_max = 2, | ||
111 | .buffer_bytes_max = 64 * 1024, | ||
112 | .period_bytes_min = 256, | ||
113 | .period_bytes_max = 32 * 1024, | ||
114 | .periods_min = 2, | ||
115 | .periods_max = 256, | ||
116 | }; | ||
117 | |||
118 | #define ATMEL_CLASSD_PREALLOC_BUF_SIZE (64 * 1024) | ||
119 | |||
120 | /* cpu dai component */ | ||
121 | static int atmel_classd_cpu_dai_startup(struct snd_pcm_substream *substream, | ||
122 | struct snd_soc_dai *cpu_dai) | ||
123 | { | ||
124 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
125 | struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); | ||
126 | |||
127 | regmap_write(dd->regmap, CLASSD_THR, 0x0); | ||
128 | |||
129 | return clk_prepare_enable(dd->pclk); | ||
130 | } | ||
131 | |||
132 | static void atmel_classd_cpu_dai_shutdown(struct snd_pcm_substream *substream, | ||
133 | struct snd_soc_dai *cpu_dai) | ||
134 | { | ||
135 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
136 | struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); | ||
137 | |||
138 | clk_disable_unprepare(dd->pclk); | ||
139 | } | ||
140 | |||
141 | static const struct snd_soc_dai_ops atmel_classd_cpu_dai_ops = { | ||
142 | .startup = atmel_classd_cpu_dai_startup, | ||
143 | .shutdown = atmel_classd_cpu_dai_shutdown, | ||
144 | }; | ||
145 | |||
146 | static struct snd_soc_dai_driver atmel_classd_cpu_dai = { | ||
147 | .playback = { | ||
148 | .channels_min = 2, | ||
149 | .channels_max = 2, | ||
150 | .rates = ATMEL_CLASSD_RATES, | ||
151 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | ||
152 | .ops = &atmel_classd_cpu_dai_ops, | ||
153 | }; | ||
154 | |||
155 | static const struct snd_soc_component_driver atmel_classd_cpu_dai_component = { | ||
156 | .name = "atmel-classd", | ||
157 | }; | ||
158 | |||
159 | /* platform */ | ||
160 | static int | ||
161 | atmel_classd_platform_configure_dma(struct snd_pcm_substream *substream, | ||
162 | struct snd_pcm_hw_params *params, | ||
163 | struct dma_slave_config *slave_config) | ||
164 | { | ||
165 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
166 | struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); | ||
167 | |||
168 | if (params_physical_width(params) != 16) { | ||
169 | dev_err(rtd->platform->dev, | ||
170 | "only supports 16-bit audio data\n"); | ||
171 | return -EINVAL; | ||
172 | } | ||
173 | |||
174 | slave_config->direction = DMA_MEM_TO_DEV; | ||
175 | slave_config->dst_addr = dd->phy_base + CLASSD_THR; | ||
176 | slave_config->dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
177 | slave_config->dst_maxburst = 1; | ||
178 | slave_config->src_maxburst = 1; | ||
179 | slave_config->device_fc = false; | ||
180 | |||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | static const struct snd_dmaengine_pcm_config | ||
185 | atmel_classd_dmaengine_pcm_config = { | ||
186 | .prepare_slave_config = atmel_classd_platform_configure_dma, | ||
187 | .pcm_hardware = &atmel_classd_hw, | ||
188 | .prealloc_buffer_size = ATMEL_CLASSD_PREALLOC_BUF_SIZE, | ||
189 | }; | ||
190 | |||
191 | /* codec */ | ||
192 | static const char * const mono_mode_text[] = { | ||
193 | "mix", "sat", "left", "right" | ||
194 | }; | ||
195 | |||
196 | static SOC_ENUM_SINGLE_DECL(classd_mono_mode_enum, | ||
197 | CLASSD_INTPMR, CLASSD_INTPMR_MONO_MODE_SHIFT, | ||
198 | mono_mode_text); | ||
199 | |||
200 | static const char * const eqcfg_text[] = { | ||
201 | "Treble-12dB", "Treble-6dB", | ||
202 | "Medium-8dB", "Medium-3dB", | ||
203 | "Bass-12dB", "Bass-6dB", | ||
204 | "0 dB", | ||
205 | "Bass+6dB", "Bass+12dB", | ||
206 | "Medium+3dB", "Medium+8dB", | ||
207 | "Treble+6dB", "Treble+12dB", | ||
208 | }; | ||
209 | |||
210 | static const unsigned int eqcfg_value[] = { | ||
211 | CLASSD_INTPMR_EQCFG_T_CUT_12, CLASSD_INTPMR_EQCFG_T_CUT_6, | ||
212 | CLASSD_INTPMR_EQCFG_M_CUT_8, CLASSD_INTPMR_EQCFG_M_CUT_3, | ||
213 | CLASSD_INTPMR_EQCFG_B_CUT_12, CLASSD_INTPMR_EQCFG_B_CUT_6, | ||
214 | CLASSD_INTPMR_EQCFG_FLAT, | ||
215 | CLASSD_INTPMR_EQCFG_B_BOOST_6, CLASSD_INTPMR_EQCFG_B_BOOST_12, | ||
216 | CLASSD_INTPMR_EQCFG_M_BOOST_3, CLASSD_INTPMR_EQCFG_M_BOOST_8, | ||
217 | CLASSD_INTPMR_EQCFG_T_BOOST_6, CLASSD_INTPMR_EQCFG_T_BOOST_12, | ||
218 | }; | ||
219 | |||
220 | static SOC_VALUE_ENUM_SINGLE_DECL(classd_eqcfg_enum, | ||
221 | CLASSD_INTPMR, CLASSD_INTPMR_EQCFG_SHIFT, 0xf, | ||
222 | eqcfg_text, eqcfg_value); | ||
223 | |||
224 | static const DECLARE_TLV_DB_SCALE(classd_digital_tlv, -7800, 100, 1); | ||
225 | |||
226 | static const struct snd_kcontrol_new atmel_classd_snd_controls[] = { | ||
227 | SOC_DOUBLE_TLV("Playback Volume", CLASSD_INTPMR, | ||
228 | CLASSD_INTPMR_ATTL_SHIFT, CLASSD_INTPMR_ATTR_SHIFT, | ||
229 | 78, 1, classd_digital_tlv), | ||
230 | |||
231 | SOC_SINGLE("Deemphasis Switch", CLASSD_INTPMR, | ||
232 | CLASSD_INTPMR_DEEMP_SHIFT, 1, 0), | ||
233 | |||
234 | SOC_SINGLE("Mono Switch", CLASSD_INTPMR, CLASSD_INTPMR_MONO_SHIFT, 1, 0), | ||
235 | |||
236 | SOC_SINGLE("Swap Switch", CLASSD_INTPMR, CLASSD_INTPMR_SWAP_SHIFT, 1, 0), | ||
237 | |||
238 | SOC_ENUM("Mono Mode", classd_mono_mode_enum), | ||
239 | |||
240 | SOC_ENUM("EQ", classd_eqcfg_enum), | ||
241 | }; | ||
242 | |||
243 | static const char * const pwm_type[] = { | ||
244 | "Single ended", "Differential" | ||
245 | }; | ||
246 | |||
247 | static int atmel_classd_codec_probe(struct snd_soc_codec *codec) | ||
248 | { | ||
249 | struct snd_soc_card *card = snd_soc_codec_get_drvdata(codec); | ||
250 | struct atmel_classd *dd = snd_soc_card_get_drvdata(card); | ||
251 | const struct atmel_classd_pdata *pdata = dd->pdata; | ||
252 | u32 mask, val; | ||
253 | |||
254 | mask = CLASSD_MR_PWMTYP_MASK; | ||
255 | val = pdata->pwm_type << CLASSD_MR_PWMTYP_SHIFT; | ||
256 | |||
257 | mask |= CLASSD_MR_NON_OVERLAP_MASK; | ||
258 | if (pdata->non_overlap_enable) { | ||
259 | val |= (CLASSD_MR_NON_OVERLAP_EN | ||
260 | << CLASSD_MR_NON_OVERLAP_SHIFT); | ||
261 | |||
262 | mask |= CLASSD_MR_NOVR_VAL_MASK; | ||
263 | switch (pdata->non_overlap_time) { | ||
264 | case 5: | ||
265 | val |= (CLASSD_MR_NOVR_VAL_5NS | ||
266 | << CLASSD_MR_NOVR_VAL_SHIFT); | ||
267 | break; | ||
268 | case 10: | ||
269 | val |= (CLASSD_MR_NOVR_VAL_10NS | ||
270 | << CLASSD_MR_NOVR_VAL_SHIFT); | ||
271 | break; | ||
272 | case 15: | ||
273 | val |= (CLASSD_MR_NOVR_VAL_15NS | ||
274 | << CLASSD_MR_NOVR_VAL_SHIFT); | ||
275 | break; | ||
276 | case 20: | ||
277 | val |= (CLASSD_MR_NOVR_VAL_20NS | ||
278 | << CLASSD_MR_NOVR_VAL_SHIFT); | ||
279 | break; | ||
280 | default: | ||
281 | val |= (CLASSD_MR_NOVR_VAL_10NS | ||
282 | << CLASSD_MR_NOVR_VAL_SHIFT); | ||
283 | dev_warn(codec->dev, | ||
284 | "non-overlapping value %d is invalid, the default value 10 is specified\n", | ||
285 | pdata->non_overlap_time); | ||
286 | break; | ||
287 | } | ||
288 | } | ||
289 | |||
290 | snd_soc_update_bits(codec, CLASSD_MR, mask, val); | ||
291 | |||
292 | dev_info(codec->dev, | ||
293 | "PWM modulation type is %s, non-overlapping is %s\n", | ||
294 | pwm_type[pdata->pwm_type], | ||
295 | pdata->non_overlap_enable?"enabled":"disabled"); | ||
296 | |||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static struct regmap *atmel_classd_codec_get_remap(struct device *dev) | ||
301 | { | ||
302 | return dev_get_regmap(dev, NULL); | ||
303 | } | ||
304 | |||
305 | static struct snd_soc_codec_driver soc_codec_dev_classd = { | ||
306 | .probe = atmel_classd_codec_probe, | ||
307 | .controls = atmel_classd_snd_controls, | ||
308 | .num_controls = ARRAY_SIZE(atmel_classd_snd_controls), | ||
309 | .get_regmap = atmel_classd_codec_get_remap, | ||
310 | }; | ||
311 | |||
312 | /* codec dai component */ | ||
313 | static int atmel_classd_codec_dai_startup(struct snd_pcm_substream *substream, | ||
314 | struct snd_soc_dai *codec_dai) | ||
315 | { | ||
316 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
317 | struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); | ||
318 | int ret; | ||
319 | |||
320 | ret = clk_prepare_enable(dd->aclk); | ||
321 | if (ret) | ||
322 | return ret; | ||
323 | |||
324 | return clk_prepare_enable(dd->gclk); | ||
325 | } | ||
326 | |||
327 | static int atmel_classd_codec_dai_digital_mute(struct snd_soc_dai *codec_dai, | ||
328 | int mute) | ||
329 | { | ||
330 | struct snd_soc_codec *codec = codec_dai->codec; | ||
331 | u32 mask, val; | ||
332 | |||
333 | mask = CLASSD_MR_LMUTE_MASK | CLASSD_MR_RMUTE_MASK; | ||
334 | |||
335 | if (mute) | ||
336 | val = mask; | ||
337 | else | ||
338 | val = 0; | ||
339 | |||
340 | snd_soc_update_bits(codec, CLASSD_MR, mask, val); | ||
341 | |||
342 | return 0; | ||
343 | } | ||
344 | |||
345 | #define CLASSD_ACLK_RATE_11M2896_MPY_8 (112896 * 100 * 8) | ||
346 | #define CLASSD_ACLK_RATE_12M288_MPY_8 (12228 * 1000 * 8) | ||
347 | |||
348 | static struct { | ||
349 | int rate; | ||
350 | int sample_rate; | ||
351 | int dsp_clk; | ||
352 | unsigned long aclk_rate; | ||
353 | } const sample_rates[] = { | ||
354 | { 8000, CLASSD_INTPMR_FRAME_8K, | ||
355 | CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_ACLK_RATE_12M288_MPY_8 }, | ||
356 | { 16000, CLASSD_INTPMR_FRAME_16K, | ||
357 | CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_ACLK_RATE_12M288_MPY_8 }, | ||
358 | { 32000, CLASSD_INTPMR_FRAME_32K, | ||
359 | CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_ACLK_RATE_12M288_MPY_8 }, | ||
360 | { 48000, CLASSD_INTPMR_FRAME_48K, | ||
361 | CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_ACLK_RATE_12M288_MPY_8 }, | ||
362 | { 96000, CLASSD_INTPMR_FRAME_96K, | ||
363 | CLASSD_INTPMR_DSP_CLK_FREQ_12M288, CLASSD_ACLK_RATE_12M288_MPY_8 }, | ||
364 | { 22050, CLASSD_INTPMR_FRAME_22K, | ||
365 | CLASSD_INTPMR_DSP_CLK_FREQ_11M2896, CLASSD_ACLK_RATE_11M2896_MPY_8 }, | ||
366 | { 44100, CLASSD_INTPMR_FRAME_44K, | ||
367 | CLASSD_INTPMR_DSP_CLK_FREQ_11M2896, CLASSD_ACLK_RATE_11M2896_MPY_8 }, | ||
368 | { 88200, CLASSD_INTPMR_FRAME_88K, | ||
369 | CLASSD_INTPMR_DSP_CLK_FREQ_11M2896, CLASSD_ACLK_RATE_11M2896_MPY_8 }, | ||
370 | }; | ||
371 | |||
372 | static int | ||
373 | atmel_classd_codec_dai_hw_params(struct snd_pcm_substream *substream, | ||
374 | struct snd_pcm_hw_params *params, | ||
375 | struct snd_soc_dai *codec_dai) | ||
376 | { | ||
377 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
378 | struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); | ||
379 | struct snd_soc_codec *codec = codec_dai->codec; | ||
380 | int fs; | ||
381 | int i, best, best_val, cur_val, ret; | ||
382 | u32 mask, val; | ||
383 | |||
384 | fs = params_rate(params); | ||
385 | |||
386 | best = 0; | ||
387 | best_val = abs(fs - sample_rates[0].rate); | ||
388 | for (i = 1; i < ARRAY_SIZE(sample_rates); i++) { | ||
389 | /* Closest match */ | ||
390 | cur_val = abs(fs - sample_rates[i].rate); | ||
391 | if (cur_val < best_val) { | ||
392 | best = i; | ||
393 | best_val = cur_val; | ||
394 | } | ||
395 | } | ||
396 | |||
397 | dev_dbg(codec->dev, | ||
398 | "Selected SAMPLE_RATE of %dHz, ACLK_RATE of %ldHz\n", | ||
399 | sample_rates[best].rate, sample_rates[best].aclk_rate); | ||
400 | |||
401 | clk_disable_unprepare(dd->gclk); | ||
402 | clk_disable_unprepare(dd->aclk); | ||
403 | |||
404 | ret = clk_set_rate(dd->aclk, sample_rates[best].aclk_rate); | ||
405 | if (ret) | ||
406 | return ret; | ||
407 | |||
408 | mask = CLASSD_INTPMR_DSP_CLK_FREQ_MASK | CLASSD_INTPMR_FRAME_MASK; | ||
409 | val = (sample_rates[best].dsp_clk << CLASSD_INTPMR_DSP_CLK_FREQ_SHIFT) | ||
410 | | (sample_rates[best].sample_rate << CLASSD_INTPMR_FRAME_SHIFT); | ||
411 | |||
412 | snd_soc_update_bits(codec, CLASSD_INTPMR, mask, val); | ||
413 | |||
414 | ret = clk_prepare_enable(dd->aclk); | ||
415 | if (ret) | ||
416 | return ret; | ||
417 | |||
418 | return clk_prepare_enable(dd->gclk); | ||
419 | } | ||
420 | |||
421 | static void | ||
422 | atmel_classd_codec_dai_shutdown(struct snd_pcm_substream *substream, | ||
423 | struct snd_soc_dai *codec_dai) | ||
424 | { | ||
425 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
426 | struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); | ||
427 | |||
428 | clk_disable_unprepare(dd->gclk); | ||
429 | clk_disable_unprepare(dd->aclk); | ||
430 | } | ||
431 | |||
432 | static int atmel_classd_codec_dai_prepare(struct snd_pcm_substream *substream, | ||
433 | struct snd_soc_dai *codec_dai) | ||
434 | { | ||
435 | struct snd_soc_codec *codec = codec_dai->codec; | ||
436 | |||
437 | snd_soc_update_bits(codec, CLASSD_MR, | ||
438 | CLASSD_MR_LEN_MASK | CLASSD_MR_REN_MASK, | ||
439 | (CLASSD_MR_LEN_DIS << CLASSD_MR_LEN_SHIFT) | ||
440 | |(CLASSD_MR_REN_DIS << CLASSD_MR_REN_SHIFT)); | ||
441 | |||
442 | return 0; | ||
443 | } | ||
444 | |||
445 | static int atmel_classd_codec_dai_trigger(struct snd_pcm_substream *substream, | ||
446 | int cmd, struct snd_soc_dai *codec_dai) | ||
447 | { | ||
448 | struct snd_soc_codec *codec = codec_dai->codec; | ||
449 | u32 mask, val; | ||
450 | |||
451 | mask = CLASSD_MR_LEN_MASK | CLASSD_MR_REN_MASK; | ||
452 | |||
453 | switch (cmd) { | ||
454 | case SNDRV_PCM_TRIGGER_START: | ||
455 | case SNDRV_PCM_TRIGGER_RESUME: | ||
456 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
457 | val = mask; | ||
458 | break; | ||
459 | case SNDRV_PCM_TRIGGER_STOP: | ||
460 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
461 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
462 | val = (CLASSD_MR_LEN_DIS << CLASSD_MR_LEN_SHIFT) | ||
463 | | (CLASSD_MR_REN_DIS << CLASSD_MR_REN_SHIFT); | ||
464 | break; | ||
465 | default: | ||
466 | return -EINVAL; | ||
467 | } | ||
468 | |||
469 | snd_soc_update_bits(codec, CLASSD_MR, mask, val); | ||
470 | |||
471 | return 0; | ||
472 | } | ||
473 | |||
474 | static const struct snd_soc_dai_ops atmel_classd_codec_dai_ops = { | ||
475 | .digital_mute = atmel_classd_codec_dai_digital_mute, | ||
476 | .startup = atmel_classd_codec_dai_startup, | ||
477 | .shutdown = atmel_classd_codec_dai_shutdown, | ||
478 | .hw_params = atmel_classd_codec_dai_hw_params, | ||
479 | .prepare = atmel_classd_codec_dai_prepare, | ||
480 | .trigger = atmel_classd_codec_dai_trigger, | ||
481 | }; | ||
482 | |||
483 | #define ATMEL_CLASSD_CODEC_DAI_NAME "atmel-classd-hifi" | ||
484 | |||
485 | static struct snd_soc_dai_driver atmel_classd_codec_dai = { | ||
486 | .name = ATMEL_CLASSD_CODEC_DAI_NAME, | ||
487 | .playback = { | ||
488 | .stream_name = "Playback", | ||
489 | .channels_min = 2, | ||
490 | .channels_max = 2, | ||
491 | .rates = ATMEL_CLASSD_RATES, | ||
492 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
493 | }, | ||
494 | .ops = &atmel_classd_codec_dai_ops, | ||
495 | }; | ||
496 | |||
497 | /* ASoC sound card */ | ||
498 | static int atmel_classd_asoc_card_init(struct device *dev, | ||
499 | struct snd_soc_card *card) | ||
500 | { | ||
501 | struct snd_soc_dai_link *dai_link; | ||
502 | struct atmel_classd *dd = snd_soc_card_get_drvdata(card); | ||
503 | |||
504 | dai_link = devm_kzalloc(dev, sizeof(*dai_link), GFP_KERNEL); | ||
505 | if (!dai_link) | ||
506 | return -ENOMEM; | ||
507 | |||
508 | dai_link->name = "CLASSD"; | ||
509 | dai_link->stream_name = "CLASSD PCM"; | ||
510 | dai_link->codec_dai_name = ATMEL_CLASSD_CODEC_DAI_NAME; | ||
511 | dai_link->cpu_dai_name = dev_name(dev); | ||
512 | dai_link->codec_name = dev_name(dev); | ||
513 | dai_link->platform_name = dev_name(dev); | ||
514 | |||
515 | card->dai_link = dai_link; | ||
516 | card->num_links = 1; | ||
517 | card->name = dd->pdata->card_name; | ||
518 | card->dev = dev; | ||
519 | |||
520 | return 0; | ||
521 | }; | ||
522 | |||
523 | /* regmap configuration */ | ||
524 | static const struct reg_default atmel_classd_reg_defaults[] = { | ||
525 | { CLASSD_INTPMR, 0x00301212 }, | ||
526 | }; | ||
527 | |||
528 | #define ATMEL_CLASSD_REG_MAX 0xE4 | ||
529 | static const struct regmap_config atmel_classd_regmap_config = { | ||
530 | .reg_bits = 32, | ||
531 | .reg_stride = 4, | ||
532 | .val_bits = 32, | ||
533 | .max_register = ATMEL_CLASSD_REG_MAX, | ||
534 | |||
535 | .cache_type = REGCACHE_FLAT, | ||
536 | .reg_defaults = atmel_classd_reg_defaults, | ||
537 | .num_reg_defaults = ARRAY_SIZE(atmel_classd_reg_defaults), | ||
538 | }; | ||
539 | |||
540 | static int atmel_classd_probe(struct platform_device *pdev) | ||
541 | { | ||
542 | struct device *dev = &pdev->dev; | ||
543 | struct atmel_classd *dd; | ||
544 | struct resource *res; | ||
545 | void __iomem *io_base; | ||
546 | const struct atmel_classd_pdata *pdata; | ||
547 | struct snd_soc_card *card; | ||
548 | int ret; | ||
549 | |||
550 | pdata = dev_get_platdata(dev); | ||
551 | if (!pdata) { | ||
552 | pdata = atmel_classd_dt_init(dev); | ||
553 | if (IS_ERR(pdata)) | ||
554 | return PTR_ERR(pdata); | ||
555 | } | ||
556 | |||
557 | dd = devm_kzalloc(dev, sizeof(*dd), GFP_KERNEL); | ||
558 | if (!dd) | ||
559 | return -ENOMEM; | ||
560 | |||
561 | dd->pdata = pdata; | ||
562 | |||
563 | dd->irq = platform_get_irq(pdev, 0); | ||
564 | if (dd->irq < 0) { | ||
565 | ret = dd->irq; | ||
566 | dev_err(dev, "failed to could not get irq: %d\n", ret); | ||
567 | return ret; | ||
568 | } | ||
569 | |||
570 | dd->pclk = devm_clk_get(dev, "pclk"); | ||
571 | if (IS_ERR(dd->pclk)) { | ||
572 | ret = PTR_ERR(dd->pclk); | ||
573 | dev_err(dev, "failed to get peripheral clock: %d\n", ret); | ||
574 | return ret; | ||
575 | } | ||
576 | |||
577 | dd->gclk = devm_clk_get(dev, "gclk"); | ||
578 | if (IS_ERR(dd->gclk)) { | ||
579 | ret = PTR_ERR(dd->gclk); | ||
580 | dev_err(dev, "failed to get GCK clock: %d\n", ret); | ||
581 | return ret; | ||
582 | } | ||
583 | |||
584 | dd->aclk = devm_clk_get(dev, "aclk"); | ||
585 | if (IS_ERR(dd->aclk)) { | ||
586 | ret = PTR_ERR(dd->aclk); | ||
587 | dev_err(dev, "failed to get audio clock: %d\n", ret); | ||
588 | return ret; | ||
589 | } | ||
590 | |||
591 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
592 | if (!res) { | ||
593 | dev_err(dev, "no memory resource\n"); | ||
594 | return -ENXIO; | ||
595 | } | ||
596 | |||
597 | io_base = devm_ioremap_resource(dev, res); | ||
598 | if (IS_ERR(io_base)) { | ||
599 | ret = PTR_ERR(io_base); | ||
600 | dev_err(dev, "failed to remap register memory: %d\n", ret); | ||
601 | return ret; | ||
602 | } | ||
603 | |||
604 | dd->phy_base = res->start; | ||
605 | |||
606 | dd->regmap = devm_regmap_init_mmio(dev, io_base, | ||
607 | &atmel_classd_regmap_config); | ||
608 | if (IS_ERR(dd->regmap)) { | ||
609 | ret = PTR_ERR(dd->regmap); | ||
610 | dev_err(dev, "failed to init register map: %d\n", ret); | ||
611 | return ret; | ||
612 | } | ||
613 | |||
614 | ret = devm_snd_soc_register_component(dev, | ||
615 | &atmel_classd_cpu_dai_component, | ||
616 | &atmel_classd_cpu_dai, 1); | ||
617 | if (ret) { | ||
618 | dev_err(dev, "could not register CPU DAI: %d\n", ret); | ||
619 | return ret; | ||
620 | } | ||
621 | |||
622 | ret = devm_snd_dmaengine_pcm_register(dev, | ||
623 | &atmel_classd_dmaengine_pcm_config, | ||
624 | 0); | ||
625 | if (ret) { | ||
626 | dev_err(dev, "could not register platform: %d\n", ret); | ||
627 | return ret; | ||
628 | } | ||
629 | |||
630 | ret = snd_soc_register_codec(dev, &soc_codec_dev_classd, | ||
631 | &atmel_classd_codec_dai, 1); | ||
632 | if (ret) { | ||
633 | dev_err(dev, "could not register codec: %d\n", ret); | ||
634 | return ret; | ||
635 | } | ||
636 | |||
637 | /* register sound card */ | ||
638 | card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); | ||
639 | if (!card) | ||
640 | return -ENOMEM; | ||
641 | |||
642 | snd_soc_card_set_drvdata(card, dd); | ||
643 | platform_set_drvdata(pdev, card); | ||
644 | |||
645 | ret = atmel_classd_asoc_card_init(dev, card); | ||
646 | if (ret) { | ||
647 | dev_err(dev, "failed to init sound card\n"); | ||
648 | return ret; | ||
649 | } | ||
650 | |||
651 | ret = devm_snd_soc_register_card(dev, card); | ||
652 | if (ret) { | ||
653 | dev_err(dev, "failed to register sound card: %d\n", ret); | ||
654 | return ret; | ||
655 | } | ||
656 | |||
657 | return 0; | ||
658 | } | ||
659 | |||
660 | static int atmel_classd_remove(struct platform_device *pdev) | ||
661 | { | ||
662 | snd_soc_unregister_codec(&pdev->dev); | ||
663 | return 0; | ||
664 | } | ||
665 | |||
666 | static struct platform_driver atmel_classd_driver = { | ||
667 | .driver = { | ||
668 | .name = "atmel-classd", | ||
669 | .of_match_table = of_match_ptr(atmel_classd_of_match), | ||
670 | .pm = &snd_soc_pm_ops, | ||
671 | }, | ||
672 | .probe = atmel_classd_probe, | ||
673 | .remove = atmel_classd_remove, | ||
674 | }; | ||
675 | module_platform_driver(atmel_classd_driver); | ||
676 | |||
677 | MODULE_DESCRIPTION("Atmel ClassD driver under ALSA SoC architecture"); | ||
678 | MODULE_AUTHOR("Songjun Wu <songjun.wu@atmel.com>"); | ||
679 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/atmel/atmel-classd.h b/sound/soc/atmel/atmel-classd.h new file mode 100644 index 000000000000..73f8fdd1ca83 --- /dev/null +++ b/sound/soc/atmel/atmel-classd.h | |||
@@ -0,0 +1,120 @@ | |||
1 | #ifndef __ATMEL_CLASSD_H_ | ||
2 | #define __ATMEL_CLASSD_H_ | ||
3 | |||
4 | #define CLASSD_CR 0x00000000 | ||
5 | #define CLASSD_CR_RESET 0x1 | ||
6 | |||
7 | #define CLASSD_MR 0x00000004 | ||
8 | |||
9 | #define CLASSD_MR_LEN_DIS 0x0 | ||
10 | #define CLASSD_MR_LEN_EN 0x1 | ||
11 | #define CLASSD_MR_LEN_MASK (0x1 << 0) | ||
12 | #define CLASSD_MR_LEN_SHIFT (0) | ||
13 | |||
14 | #define CLASSD_MR_LMUTE_DIS 0x0 | ||
15 | #define CLASSD_MR_LMUTE_EN 0x1 | ||
16 | #define CLASSD_MR_LMUTE_SHIFT (0x1) | ||
17 | #define CLASSD_MR_LMUTE_MASK (0x1 << 1) | ||
18 | |||
19 | #define CLASSD_MR_REN_DIS 0x0 | ||
20 | #define CLASSD_MR_REN_EN 0x1 | ||
21 | #define CLASSD_MR_REN_MASK (0x1 << 4) | ||
22 | #define CLASSD_MR_REN_SHIFT (4) | ||
23 | |||
24 | #define CLASSD_MR_RMUTE_DIS 0x0 | ||
25 | #define CLASSD_MR_RMUTE_EN 0x1 | ||
26 | #define CLASSD_MR_RMUTE_SHIFT (0x5) | ||
27 | #define CLASSD_MR_RMUTE_MASK (0x1 << 5) | ||
28 | |||
29 | #define CLASSD_MR_PWMTYP_SINGLE 0x0 | ||
30 | #define CLASSD_MR_PWMTYP_DIFF 0x1 | ||
31 | #define CLASSD_MR_PWMTYP_MASK (0x1 << 8) | ||
32 | #define CLASSD_MR_PWMTYP_SHIFT (8) | ||
33 | |||
34 | #define CLASSD_MR_NON_OVERLAP_DIS 0x0 | ||
35 | #define CLASSD_MR_NON_OVERLAP_EN 0x1 | ||
36 | #define CLASSD_MR_NON_OVERLAP_MASK (0x1 << 16) | ||
37 | #define CLASSD_MR_NON_OVERLAP_SHIFT (16) | ||
38 | |||
39 | #define CLASSD_MR_NOVR_VAL_5NS 0x0 | ||
40 | #define CLASSD_MR_NOVR_VAL_10NS 0x1 | ||
41 | #define CLASSD_MR_NOVR_VAL_15NS 0x2 | ||
42 | #define CLASSD_MR_NOVR_VAL_20NS 0x3 | ||
43 | #define CLASSD_MR_NOVR_VAL_MASK (0x3 << 20) | ||
44 | #define CLASSD_MR_NOVR_VAL_SHIFT (20) | ||
45 | |||
46 | #define CLASSD_INTPMR 0x00000008 | ||
47 | |||
48 | #define CLASSD_INTPMR_ATTL_MASK (0x3f << 0) | ||
49 | #define CLASSD_INTPMR_ATTL_SHIFT (0) | ||
50 | #define CLASSD_INTPMR_ATTR_MASK (0x3f << 8) | ||
51 | #define CLASSD_INTPMR_ATTR_SHIFT (8) | ||
52 | |||
53 | #define CLASSD_INTPMR_DSP_CLK_FREQ_12M288 0x0 | ||
54 | #define CLASSD_INTPMR_DSP_CLK_FREQ_11M2896 0x1 | ||
55 | #define CLASSD_INTPMR_DSP_CLK_FREQ_MASK (0x1 << 16) | ||
56 | #define CLASSD_INTPMR_DSP_CLK_FREQ_SHIFT (16) | ||
57 | |||
58 | #define CLASSD_INTPMR_DEEMP_DIS 0x0 | ||
59 | #define CLASSD_INTPMR_DEEMP_EN 0x1 | ||
60 | #define CLASSD_INTPMR_DEEMP_MASK (0x1 << 18) | ||
61 | #define CLASSD_INTPMR_DEEMP_SHIFT (18) | ||
62 | |||
63 | #define CLASSD_INTPMR_SWAP_LEFT_ON_LSB 0x0 | ||
64 | #define CLASSD_INTPMR_SWAP_RIGHT_ON_LSB 0x1 | ||
65 | #define CLASSD_INTPMR_SWAP_MASK (0x1 << 19) | ||
66 | #define CLASSD_INTPMR_SWAP_SHIFT (19) | ||
67 | |||
68 | #define CLASSD_INTPMR_FRAME_8K 0x0 | ||
69 | #define CLASSD_INTPMR_FRAME_16K 0x1 | ||
70 | #define CLASSD_INTPMR_FRAME_32K 0x2 | ||
71 | #define CLASSD_INTPMR_FRAME_48K 0x3 | ||
72 | #define CLASSD_INTPMR_FRAME_96K 0x4 | ||
73 | #define CLASSD_INTPMR_FRAME_22K 0x5 | ||
74 | #define CLASSD_INTPMR_FRAME_44K 0x6 | ||
75 | #define CLASSD_INTPMR_FRAME_88K 0x7 | ||
76 | #define CLASSD_INTPMR_FRAME_MASK (0x7 << 20) | ||
77 | #define CLASSD_INTPMR_FRAME_SHIFT (20) | ||
78 | |||
79 | #define CLASSD_INTPMR_EQCFG_FLAT 0x0 | ||
80 | #define CLASSD_INTPMR_EQCFG_B_BOOST_12 0x1 | ||
81 | #define CLASSD_INTPMR_EQCFG_B_BOOST_6 0x2 | ||
82 | #define CLASSD_INTPMR_EQCFG_B_CUT_12 0x3 | ||
83 | #define CLASSD_INTPMR_EQCFG_B_CUT_6 0x4 | ||
84 | #define CLASSD_INTPMR_EQCFG_M_BOOST_3 0x5 | ||
85 | #define CLASSD_INTPMR_EQCFG_M_BOOST_8 0x6 | ||
86 | #define CLASSD_INTPMR_EQCFG_M_CUT_3 0x7 | ||
87 | #define CLASSD_INTPMR_EQCFG_M_CUT_8 0x8 | ||
88 | #define CLASSD_INTPMR_EQCFG_T_BOOST_12 0x9 | ||
89 | #define CLASSD_INTPMR_EQCFG_T_BOOST_6 0xa | ||
90 | #define CLASSD_INTPMR_EQCFG_T_CUT_12 0xb | ||
91 | #define CLASSD_INTPMR_EQCFG_T_CUT_6 0xc | ||
92 | #define CLASSD_INTPMR_EQCFG_SHIFT (24) | ||
93 | |||
94 | #define CLASSD_INTPMR_MONO_DIS 0x0 | ||
95 | #define CLASSD_INTPMR_MONO_EN 0x1 | ||
96 | #define CLASSD_INTPMR_MONO_MASK (0x1 << 28) | ||
97 | #define CLASSD_INTPMR_MONO_SHIFT (28) | ||
98 | |||
99 | #define CLASSD_INTPMR_MONO_MODE_MIX 0x0 | ||
100 | #define CLASSD_INTPMR_MONO_MODE_SAT 0x1 | ||
101 | #define CLASSD_INTPMR_MONO_MODE_LEFT 0x2 | ||
102 | #define CLASSD_INTPMR_MONO_MODE_RIGHT 0x3 | ||
103 | #define CLASSD_INTPMR_MONO_MODE_MASK (0x3 << 29) | ||
104 | #define CLASSD_INTPMR_MONO_MODE_SHIFT (29) | ||
105 | |||
106 | #define CLASSD_INTSR 0x0000000c | ||
107 | |||
108 | #define CLASSD_THR 0x00000010 | ||
109 | |||
110 | #define CLASSD_IER 0x00000014 | ||
111 | |||
112 | #define CLASSD_IDR 0x00000018 | ||
113 | |||
114 | #define CLASSD_IMR 0x0000001c | ||
115 | |||
116 | #define CLASSD_ISR 0x00000020 | ||
117 | |||
118 | #define CLASSD_WPMR 0x000000e4 | ||
119 | |||
120 | #endif | ||
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 70e5a75901aa..cfdafc4c11ea 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -58,6 +58,7 @@ config SND_SOC_ALL_CODECS | |||
58 | select SND_SOC_CX20442 if TTY | 58 | select SND_SOC_CX20442 if TTY |
59 | select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI | 59 | select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI |
60 | select SND_SOC_DA7213 if I2C | 60 | select SND_SOC_DA7213 if I2C |
61 | select SND_SOC_DA7219 if I2C | ||
61 | select SND_SOC_DA732X if I2C | 62 | select SND_SOC_DA732X if I2C |
62 | select SND_SOC_DA9055 if I2C | 63 | select SND_SOC_DA9055 if I2C |
63 | select SND_SOC_DMIC | 64 | select SND_SOC_DMIC |
@@ -80,6 +81,7 @@ config SND_SOC_ALL_CODECS | |||
80 | select SND_SOC_MAX9877 if I2C | 81 | select SND_SOC_MAX9877 if I2C |
81 | select SND_SOC_MC13783 if MFD_MC13XXX | 82 | select SND_SOC_MC13783 if MFD_MC13XXX |
82 | select SND_SOC_ML26124 if I2C | 83 | select SND_SOC_ML26124 if I2C |
84 | select SND_SOC_NAU8825 if I2C | ||
83 | select SND_SOC_PCM1681 if I2C | 85 | select SND_SOC_PCM1681 if I2C |
84 | select SND_SOC_PCM1792A if SPI_MASTER | 86 | select SND_SOC_PCM1792A if SPI_MASTER |
85 | select SND_SOC_PCM3008 | 87 | select SND_SOC_PCM3008 |
@@ -171,6 +173,7 @@ config SND_SOC_ALL_CODECS | |||
171 | select SND_SOC_WM8995 if SND_SOC_I2C_AND_SPI | 173 | select SND_SOC_WM8995 if SND_SOC_I2C_AND_SPI |
172 | select SND_SOC_WM8996 if I2C | 174 | select SND_SOC_WM8996 if I2C |
173 | select SND_SOC_WM8997 if MFD_WM8997 | 175 | select SND_SOC_WM8997 if MFD_WM8997 |
176 | select SND_SOC_WM8998 if MFD_WM8998 | ||
174 | select SND_SOC_WM9081 if I2C | 177 | select SND_SOC_WM9081 if I2C |
175 | select SND_SOC_WM9090 if I2C | 178 | select SND_SOC_WM9090 if I2C |
176 | select SND_SOC_WM9705 if SND_SOC_AC97_BUS | 179 | select SND_SOC_WM9705 if SND_SOC_AC97_BUS |
@@ -195,9 +198,11 @@ config SND_SOC_ARIZONA | |||
195 | default y if SND_SOC_WM5102=y | 198 | default y if SND_SOC_WM5102=y |
196 | default y if SND_SOC_WM5110=y | 199 | default y if SND_SOC_WM5110=y |
197 | default y if SND_SOC_WM8997=y | 200 | default y if SND_SOC_WM8997=y |
201 | default y if SND_SOC_WM8998=y | ||
198 | default m if SND_SOC_WM5102=m | 202 | default m if SND_SOC_WM5102=m |
199 | default m if SND_SOC_WM5110=m | 203 | default m if SND_SOC_WM5110=m |
200 | default m if SND_SOC_WM8997=m | 204 | default m if SND_SOC_WM8997=m |
205 | default m if SND_SOC_WM8998=m | ||
201 | 206 | ||
202 | config SND_SOC_WM_HUBS | 207 | config SND_SOC_WM_HUBS |
203 | tristate | 208 | tristate |
@@ -434,6 +439,9 @@ config SND_SOC_DA7210 | |||
434 | config SND_SOC_DA7213 | 439 | config SND_SOC_DA7213 |
435 | tristate | 440 | tristate |
436 | 441 | ||
442 | config SND_SOC_DA7219 | ||
443 | tristate | ||
444 | |||
437 | config SND_SOC_DA732X | 445 | config SND_SOC_DA732X |
438 | tristate | 446 | tristate |
439 | 447 | ||
@@ -866,6 +874,9 @@ config SND_SOC_WM8996 | |||
866 | config SND_SOC_WM8997 | 874 | config SND_SOC_WM8997 |
867 | tristate | 875 | tristate |
868 | 876 | ||
877 | config SND_SOC_WM8998 | ||
878 | tristate | ||
879 | |||
869 | config SND_SOC_WM9081 | 880 | config SND_SOC_WM9081 |
870 | tristate | 881 | tristate |
871 | 882 | ||
@@ -897,6 +908,9 @@ config SND_SOC_MC13783 | |||
897 | config SND_SOC_ML26124 | 908 | config SND_SOC_ML26124 |
898 | tristate | 909 | tristate |
899 | 910 | ||
911 | config SND_SOC_NAU8825 | ||
912 | tristate | ||
913 | |||
900 | config SND_SOC_TPA6130A2 | 914 | config SND_SOC_TPA6130A2 |
901 | tristate "Texas Instruments TPA6130A2 headphone amplifier" | 915 | tristate "Texas Instruments TPA6130A2 headphone amplifier" |
902 | depends on I2C | 916 | depends on I2C |
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index be1491acb6ae..f632fc42f59f 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
@@ -50,6 +50,7 @@ snd-soc-cs4349-objs := cs4349.o | |||
50 | snd-soc-cx20442-objs := cx20442.o | 50 | snd-soc-cx20442-objs := cx20442.o |
51 | snd-soc-da7210-objs := da7210.o | 51 | snd-soc-da7210-objs := da7210.o |
52 | snd-soc-da7213-objs := da7213.o | 52 | snd-soc-da7213-objs := da7213.o |
53 | snd-soc-da7219-objs := da7219.o da7219-aad.o | ||
53 | snd-soc-da732x-objs := da732x.o | 54 | snd-soc-da732x-objs := da732x.o |
54 | snd-soc-da9055-objs := da9055.o | 55 | snd-soc-da9055-objs := da9055.o |
55 | snd-soc-bt-sco-objs := bt-sco.o | 56 | snd-soc-bt-sco-objs := bt-sco.o |
@@ -73,6 +74,7 @@ snd-soc-max98925-objs := max98925.o | |||
73 | snd-soc-max9850-objs := max9850.o | 74 | snd-soc-max9850-objs := max9850.o |
74 | snd-soc-mc13783-objs := mc13783.o | 75 | snd-soc-mc13783-objs := mc13783.o |
75 | snd-soc-ml26124-objs := ml26124.o | 76 | snd-soc-ml26124-objs := ml26124.o |
77 | snd-soc-nau8825-objs := nau8825.o | ||
76 | snd-soc-pcm1681-objs := pcm1681.o | 78 | snd-soc-pcm1681-objs := pcm1681.o |
77 | snd-soc-pcm1792a-codec-objs := pcm1792a.o | 79 | snd-soc-pcm1792a-codec-objs := pcm1792a.o |
78 | snd-soc-pcm3008-objs := pcm3008.o | 80 | snd-soc-pcm3008-objs := pcm3008.o |
@@ -176,6 +178,7 @@ snd-soc-wm8993-objs := wm8993.o | |||
176 | snd-soc-wm8994-objs := wm8994.o wm8958-dsp2.o | 178 | snd-soc-wm8994-objs := wm8994.o wm8958-dsp2.o |
177 | snd-soc-wm8995-objs := wm8995.o | 179 | snd-soc-wm8995-objs := wm8995.o |
178 | snd-soc-wm8997-objs := wm8997.o | 180 | snd-soc-wm8997-objs := wm8997.o |
181 | snd-soc-wm8998-objs := wm8998.o | ||
179 | snd-soc-wm9081-objs := wm9081.o | 182 | snd-soc-wm9081-objs := wm9081.o |
180 | snd-soc-wm9090-objs := wm9090.o | 183 | snd-soc-wm9090-objs := wm9090.o |
181 | snd-soc-wm9705-objs := wm9705.o | 184 | snd-soc-wm9705-objs := wm9705.o |
@@ -242,6 +245,7 @@ obj-$(CONFIG_SND_SOC_CS4349) += snd-soc-cs4349.o | |||
242 | obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o | 245 | obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o |
243 | obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o | 246 | obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o |
244 | obj-$(CONFIG_SND_SOC_DA7213) += snd-soc-da7213.o | 247 | obj-$(CONFIG_SND_SOC_DA7213) += snd-soc-da7213.o |
248 | obj-$(CONFIG_SND_SOC_DA7219) += snd-soc-da7219.o | ||
245 | obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o | 249 | obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o |
246 | obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o | 250 | obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o |
247 | obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o | 251 | obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o |
@@ -265,6 +269,7 @@ obj-$(CONFIG_SND_SOC_MAX98925) += snd-soc-max98925.o | |||
265 | obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o | 269 | obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o |
266 | obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o | 270 | obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o |
267 | obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o | 271 | obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o |
272 | obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o | ||
268 | obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o | 273 | obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o |
269 | obj-$(CONFIG_SND_SOC_PCM1792A) += snd-soc-pcm1792a-codec.o | 274 | obj-$(CONFIG_SND_SOC_PCM1792A) += snd-soc-pcm1792a-codec.o |
270 | obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o | 275 | obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o |
@@ -364,6 +369,7 @@ obj-$(CONFIG_SND_SOC_WM8993) += snd-soc-wm8993.o | |||
364 | obj-$(CONFIG_SND_SOC_WM8994) += snd-soc-wm8994.o | 369 | obj-$(CONFIG_SND_SOC_WM8994) += snd-soc-wm8994.o |
365 | obj-$(CONFIG_SND_SOC_WM8995) += snd-soc-wm8995.o | 370 | obj-$(CONFIG_SND_SOC_WM8995) += snd-soc-wm8995.o |
366 | obj-$(CONFIG_SND_SOC_WM8997) += snd-soc-wm8997.o | 371 | obj-$(CONFIG_SND_SOC_WM8997) += snd-soc-wm8997.o |
372 | obj-$(CONFIG_SND_SOC_WM8998) += snd-soc-wm8998.o | ||
367 | obj-$(CONFIG_SND_SOC_WM9081) += snd-soc-wm9081.o | 373 | obj-$(CONFIG_SND_SOC_WM9081) += snd-soc-wm9081.o |
368 | obj-$(CONFIG_SND_SOC_WM9090) += snd-soc-wm9090.o | 374 | obj-$(CONFIG_SND_SOC_WM9090) += snd-soc-wm9090.o |
369 | obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o | 375 | obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o |
diff --git a/sound/soc/codecs/ad193x-i2c.c b/sound/soc/codecs/ad193x-i2c.c index df3a1a415825..171313664bc8 100644 --- a/sound/soc/codecs/ad193x-i2c.c +++ b/sound/soc/codecs/ad193x-i2c.c | |||
@@ -15,8 +15,8 @@ | |||
15 | #include "ad193x.h" | 15 | #include "ad193x.h" |
16 | 16 | ||
17 | static const struct i2c_device_id ad193x_id[] = { | 17 | static const struct i2c_device_id ad193x_id[] = { |
18 | { "ad1936", 0 }, | 18 | { "ad1936", AD193X }, |
19 | { "ad1937", 0 }, | 19 | { "ad1937", AD193X }, |
20 | { } | 20 | { } |
21 | }; | 21 | }; |
22 | MODULE_DEVICE_TABLE(i2c, ad193x_id); | 22 | MODULE_DEVICE_TABLE(i2c, ad193x_id); |
@@ -30,7 +30,9 @@ static int ad193x_i2c_probe(struct i2c_client *client, | |||
30 | config.val_bits = 8; | 30 | config.val_bits = 8; |
31 | config.reg_bits = 8; | 31 | config.reg_bits = 8; |
32 | 32 | ||
33 | return ad193x_probe(&client->dev, devm_regmap_init_i2c(client, &config)); | 33 | return ad193x_probe(&client->dev, |
34 | devm_regmap_init_i2c(client, &config), | ||
35 | (enum ad193x_type)id->driver_data); | ||
34 | } | 36 | } |
35 | 37 | ||
36 | static int ad193x_i2c_remove(struct i2c_client *client) | 38 | static int ad193x_i2c_remove(struct i2c_client *client) |
diff --git a/sound/soc/codecs/ad193x-spi.c b/sound/soc/codecs/ad193x-spi.c index 390cef9b9dc2..431f95da1de1 100644 --- a/sound/soc/codecs/ad193x-spi.c +++ b/sound/soc/codecs/ad193x-spi.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | static int ad193x_spi_probe(struct spi_device *spi) | 17 | static int ad193x_spi_probe(struct spi_device *spi) |
18 | { | 18 | { |
19 | const struct spi_device_id *id = spi_get_device_id(spi); | ||
19 | struct regmap_config config; | 20 | struct regmap_config config; |
20 | 21 | ||
21 | config = ad193x_regmap_config; | 22 | config = ad193x_regmap_config; |
@@ -24,7 +25,8 @@ static int ad193x_spi_probe(struct spi_device *spi) | |||
24 | config.read_flag_mask = 0x09; | 25 | config.read_flag_mask = 0x09; |
25 | config.write_flag_mask = 0x08; | 26 | config.write_flag_mask = 0x08; |
26 | 27 | ||
27 | return ad193x_probe(&spi->dev, devm_regmap_init_spi(spi, &config)); | 28 | return ad193x_probe(&spi->dev, devm_regmap_init_spi(spi, &config), |
29 | (enum ad193x_type)id->driver_data); | ||
28 | } | 30 | } |
29 | 31 | ||
30 | static int ad193x_spi_remove(struct spi_device *spi) | 32 | static int ad193x_spi_remove(struct spi_device *spi) |
@@ -33,6 +35,17 @@ static int ad193x_spi_remove(struct spi_device *spi) | |||
33 | return 0; | 35 | return 0; |
34 | } | 36 | } |
35 | 37 | ||
38 | static const struct spi_device_id ad193x_spi_id[] = { | ||
39 | { "ad193x", AD193X }, | ||
40 | { "ad1933", AD1933 }, | ||
41 | { "ad1934", AD1934 }, | ||
42 | { "ad1938", AD193X }, | ||
43 | { "ad1939", AD193X }, | ||
44 | { "adau1328", AD193X }, | ||
45 | { } | ||
46 | }; | ||
47 | MODULE_DEVICE_TABLE(spi, ad193x_spi_id); | ||
48 | |||
36 | static struct spi_driver ad193x_spi_driver = { | 49 | static struct spi_driver ad193x_spi_driver = { |
37 | .driver = { | 50 | .driver = { |
38 | .name = "ad193x", | 51 | .name = "ad193x", |
@@ -40,6 +53,7 @@ static struct spi_driver ad193x_spi_driver = { | |||
40 | }, | 53 | }, |
41 | .probe = ad193x_spi_probe, | 54 | .probe = ad193x_spi_probe, |
42 | .remove = ad193x_spi_remove, | 55 | .remove = ad193x_spi_remove, |
56 | .id_table = ad193x_spi_id, | ||
43 | }; | 57 | }; |
44 | module_spi_driver(ad193x_spi_driver); | 58 | module_spi_driver(ad193x_spi_driver); |
45 | 59 | ||
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index 17c953595660..3a3f3f2343d7 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c | |||
@@ -23,6 +23,7 @@ | |||
23 | /* codec private data */ | 23 | /* codec private data */ |
24 | struct ad193x_priv { | 24 | struct ad193x_priv { |
25 | struct regmap *regmap; | 25 | struct regmap *regmap; |
26 | enum ad193x_type type; | ||
26 | int sysclk; | 27 | int sysclk; |
27 | }; | 28 | }; |
28 | 29 | ||
@@ -47,12 +48,6 @@ static const struct snd_kcontrol_new ad193x_snd_controls[] = { | |||
47 | SOC_DOUBLE_R_TLV("DAC4 Volume", AD193X_DAC_L4_VOL, | 48 | SOC_DOUBLE_R_TLV("DAC4 Volume", AD193X_DAC_L4_VOL, |
48 | AD193X_DAC_R4_VOL, 0, 0xFF, 1, adau193x_tlv), | 49 | AD193X_DAC_R4_VOL, 0, 0xFF, 1, adau193x_tlv), |
49 | 50 | ||
50 | /* ADC switch control */ | ||
51 | SOC_DOUBLE("ADC1 Switch", AD193X_ADC_CTRL0, AD193X_ADCL1_MUTE, | ||
52 | AD193X_ADCR1_MUTE, 1, 1), | ||
53 | SOC_DOUBLE("ADC2 Switch", AD193X_ADC_CTRL0, AD193X_ADCL2_MUTE, | ||
54 | AD193X_ADCR2_MUTE, 1, 1), | ||
55 | |||
56 | /* DAC switch control */ | 51 | /* DAC switch control */ |
57 | SOC_DOUBLE("DAC1 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL1_MUTE, | 52 | SOC_DOUBLE("DAC1 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL1_MUTE, |
58 | AD193X_DACR1_MUTE, 1, 1), | 53 | AD193X_DACR1_MUTE, 1, 1), |
@@ -63,26 +58,37 @@ static const struct snd_kcontrol_new ad193x_snd_controls[] = { | |||
63 | SOC_DOUBLE("DAC4 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL4_MUTE, | 58 | SOC_DOUBLE("DAC4 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL4_MUTE, |
64 | AD193X_DACR4_MUTE, 1, 1), | 59 | AD193X_DACR4_MUTE, 1, 1), |
65 | 60 | ||
61 | /* DAC de-emphasis */ | ||
62 | SOC_ENUM("Playback Deemphasis", ad193x_deemp_enum), | ||
63 | }; | ||
64 | |||
65 | static const struct snd_kcontrol_new ad193x_adc_snd_controls[] = { | ||
66 | /* ADC switch control */ | ||
67 | SOC_DOUBLE("ADC1 Switch", AD193X_ADC_CTRL0, AD193X_ADCL1_MUTE, | ||
68 | AD193X_ADCR1_MUTE, 1, 1), | ||
69 | SOC_DOUBLE("ADC2 Switch", AD193X_ADC_CTRL0, AD193X_ADCL2_MUTE, | ||
70 | AD193X_ADCR2_MUTE, 1, 1), | ||
71 | |||
66 | /* ADC high-pass filter */ | 72 | /* ADC high-pass filter */ |
67 | SOC_SINGLE("ADC High Pass Filter Switch", AD193X_ADC_CTRL0, | 73 | SOC_SINGLE("ADC High Pass Filter Switch", AD193X_ADC_CTRL0, |
68 | AD193X_ADC_HIGHPASS_FILTER, 1, 0), | 74 | AD193X_ADC_HIGHPASS_FILTER, 1, 0), |
69 | |||
70 | /* DAC de-emphasis */ | ||
71 | SOC_ENUM("Playback Deemphasis", ad193x_deemp_enum), | ||
72 | }; | 75 | }; |
73 | 76 | ||
74 | static const struct snd_soc_dapm_widget ad193x_dapm_widgets[] = { | 77 | static const struct snd_soc_dapm_widget ad193x_dapm_widgets[] = { |
75 | SND_SOC_DAPM_DAC("DAC", "Playback", SND_SOC_NOPM, 0, 0), | 78 | SND_SOC_DAPM_DAC("DAC", "Playback", SND_SOC_NOPM, 0, 0), |
76 | SND_SOC_DAPM_PGA("DAC Output", AD193X_DAC_CTRL0, 0, 1, NULL, 0), | 79 | SND_SOC_DAPM_PGA("DAC Output", AD193X_DAC_CTRL0, 0, 1, NULL, 0), |
77 | SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0), | ||
78 | SND_SOC_DAPM_SUPPLY("PLL_PWR", AD193X_PLL_CLK_CTRL0, 0, 1, NULL, 0), | 80 | SND_SOC_DAPM_SUPPLY("PLL_PWR", AD193X_PLL_CLK_CTRL0, 0, 1, NULL, 0), |
79 | SND_SOC_DAPM_SUPPLY("ADC_PWR", AD193X_ADC_CTRL0, 0, 1, NULL, 0), | ||
80 | SND_SOC_DAPM_SUPPLY("SYSCLK", AD193X_PLL_CLK_CTRL0, 7, 0, NULL, 0), | 81 | SND_SOC_DAPM_SUPPLY("SYSCLK", AD193X_PLL_CLK_CTRL0, 7, 0, NULL, 0), |
81 | SND_SOC_DAPM_VMID("VMID"), | 82 | SND_SOC_DAPM_VMID("VMID"), |
82 | SND_SOC_DAPM_OUTPUT("DAC1OUT"), | 83 | SND_SOC_DAPM_OUTPUT("DAC1OUT"), |
83 | SND_SOC_DAPM_OUTPUT("DAC2OUT"), | 84 | SND_SOC_DAPM_OUTPUT("DAC2OUT"), |
84 | SND_SOC_DAPM_OUTPUT("DAC3OUT"), | 85 | SND_SOC_DAPM_OUTPUT("DAC3OUT"), |
85 | SND_SOC_DAPM_OUTPUT("DAC4OUT"), | 86 | SND_SOC_DAPM_OUTPUT("DAC4OUT"), |
87 | }; | ||
88 | |||
89 | static const struct snd_soc_dapm_widget ad193x_adc_widgets[] = { | ||
90 | SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0), | ||
91 | SND_SOC_DAPM_SUPPLY("ADC_PWR", AD193X_ADC_CTRL0, 0, 1, NULL, 0), | ||
86 | SND_SOC_DAPM_INPUT("ADC1IN"), | 92 | SND_SOC_DAPM_INPUT("ADC1IN"), |
87 | SND_SOC_DAPM_INPUT("ADC2IN"), | 93 | SND_SOC_DAPM_INPUT("ADC2IN"), |
88 | }; | 94 | }; |
@@ -91,18 +97,33 @@ static const struct snd_soc_dapm_route audio_paths[] = { | |||
91 | { "DAC", NULL, "SYSCLK" }, | 97 | { "DAC", NULL, "SYSCLK" }, |
92 | { "DAC Output", NULL, "DAC" }, | 98 | { "DAC Output", NULL, "DAC" }, |
93 | { "DAC Output", NULL, "VMID" }, | 99 | { "DAC Output", NULL, "VMID" }, |
94 | { "ADC", NULL, "SYSCLK" }, | ||
95 | { "DAC", NULL, "ADC_PWR" }, | ||
96 | { "ADC", NULL, "ADC_PWR" }, | ||
97 | { "DAC1OUT", NULL, "DAC Output" }, | 100 | { "DAC1OUT", NULL, "DAC Output" }, |
98 | { "DAC2OUT", NULL, "DAC Output" }, | 101 | { "DAC2OUT", NULL, "DAC Output" }, |
99 | { "DAC3OUT", NULL, "DAC Output" }, | 102 | { "DAC3OUT", NULL, "DAC Output" }, |
100 | { "DAC4OUT", NULL, "DAC Output" }, | 103 | { "DAC4OUT", NULL, "DAC Output" }, |
104 | { "SYSCLK", NULL, "PLL_PWR" }, | ||
105 | }; | ||
106 | |||
107 | static const struct snd_soc_dapm_route ad193x_adc_audio_paths[] = { | ||
108 | { "ADC", NULL, "SYSCLK" }, | ||
109 | { "ADC", NULL, "ADC_PWR" }, | ||
101 | { "ADC", NULL, "ADC1IN" }, | 110 | { "ADC", NULL, "ADC1IN" }, |
102 | { "ADC", NULL, "ADC2IN" }, | 111 | { "ADC", NULL, "ADC2IN" }, |
103 | { "SYSCLK", NULL, "PLL_PWR" }, | ||
104 | }; | 112 | }; |
105 | 113 | ||
114 | static inline bool ad193x_has_adc(const struct ad193x_priv *ad193x) | ||
115 | { | ||
116 | switch (ad193x->type) { | ||
117 | case AD1933: | ||
118 | case AD1934: | ||
119 | return false; | ||
120 | default: | ||
121 | break; | ||
122 | } | ||
123 | |||
124 | return true; | ||
125 | } | ||
126 | |||
106 | /* | 127 | /* |
107 | * DAI ops entries | 128 | * DAI ops entries |
108 | */ | 129 | */ |
@@ -147,8 +168,10 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, | |||
147 | 168 | ||
148 | regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL1, | 169 | regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL1, |
149 | AD193X_DAC_CHAN_MASK, channels << AD193X_DAC_CHAN_SHFT); | 170 | AD193X_DAC_CHAN_MASK, channels << AD193X_DAC_CHAN_SHFT); |
150 | regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL2, | 171 | if (ad193x_has_adc(ad193x)) |
151 | AD193X_ADC_CHAN_MASK, channels << AD193X_ADC_CHAN_SHFT); | 172 | regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL2, |
173 | AD193X_ADC_CHAN_MASK, | ||
174 | channels << AD193X_ADC_CHAN_SHFT); | ||
152 | 175 | ||
153 | return 0; | 176 | return 0; |
154 | } | 177 | } |
@@ -172,7 +195,9 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
172 | adc_serfmt |= AD193X_ADC_SERFMT_AUX; | 195 | adc_serfmt |= AD193X_ADC_SERFMT_AUX; |
173 | break; | 196 | break; |
174 | default: | 197 | default: |
175 | return -EINVAL; | 198 | if (ad193x_has_adc(ad193x)) |
199 | return -EINVAL; | ||
200 | break; | ||
176 | } | 201 | } |
177 | 202 | ||
178 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | 203 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { |
@@ -217,10 +242,12 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
217 | return -EINVAL; | 242 | return -EINVAL; |
218 | } | 243 | } |
219 | 244 | ||
220 | regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL1, | 245 | if (ad193x_has_adc(ad193x)) { |
221 | AD193X_ADC_SERFMT_MASK, adc_serfmt); | 246 | regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL1, |
222 | regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL2, | 247 | AD193X_ADC_SERFMT_MASK, adc_serfmt); |
223 | AD193X_ADC_FMT_MASK, adc_fmt); | 248 | regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL2, |
249 | AD193X_ADC_FMT_MASK, adc_fmt); | ||
250 | } | ||
224 | regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL1, | 251 | regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL1, |
225 | AD193X_DAC_FMT_MASK, dac_fmt); | 252 | AD193X_DAC_FMT_MASK, dac_fmt); |
226 | 253 | ||
@@ -287,8 +314,9 @@ static int ad193x_hw_params(struct snd_pcm_substream *substream, | |||
287 | AD193X_DAC_WORD_LEN_MASK, | 314 | AD193X_DAC_WORD_LEN_MASK, |
288 | word_len << AD193X_DAC_WORD_LEN_SHFT); | 315 | word_len << AD193X_DAC_WORD_LEN_SHFT); |
289 | 316 | ||
290 | regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL1, | 317 | if (ad193x_has_adc(ad193x)) |
291 | AD193X_ADC_WORD_LEN_MASK, word_len); | 318 | regmap_update_bits(ad193x->regmap, AD193X_ADC_CTRL1, |
319 | AD193X_ADC_WORD_LEN_MASK, word_len); | ||
292 | 320 | ||
293 | return 0; | 321 | return 0; |
294 | } | 322 | } |
@@ -326,6 +354,8 @@ static struct snd_soc_dai_driver ad193x_dai = { | |||
326 | static int ad193x_codec_probe(struct snd_soc_codec *codec) | 354 | static int ad193x_codec_probe(struct snd_soc_codec *codec) |
327 | { | 355 | { |
328 | struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); | 356 | struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); |
357 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | ||
358 | int num, ret; | ||
329 | 359 | ||
330 | /* default setting for ad193x */ | 360 | /* default setting for ad193x */ |
331 | 361 | ||
@@ -335,14 +365,46 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec) | |||
335 | regmap_write(ad193x->regmap, AD193X_DAC_CTRL2, 0x1A); | 365 | regmap_write(ad193x->regmap, AD193X_DAC_CTRL2, 0x1A); |
336 | /* dac in tdm mode */ | 366 | /* dac in tdm mode */ |
337 | regmap_write(ad193x->regmap, AD193X_DAC_CTRL0, 0x40); | 367 | regmap_write(ad193x->regmap, AD193X_DAC_CTRL0, 0x40); |
338 | /* high-pass filter enable */ | 368 | |
339 | regmap_write(ad193x->regmap, AD193X_ADC_CTRL0, 0x3); | 369 | /* adc only */ |
340 | /* sata delay=1, adc aux mode */ | 370 | if (ad193x_has_adc(ad193x)) { |
341 | regmap_write(ad193x->regmap, AD193X_ADC_CTRL1, 0x43); | 371 | /* high-pass filter enable */ |
372 | regmap_write(ad193x->regmap, AD193X_ADC_CTRL0, 0x3); | ||
373 | /* sata delay=1, adc aux mode */ | ||
374 | regmap_write(ad193x->regmap, AD193X_ADC_CTRL1, 0x43); | ||
375 | } | ||
376 | |||
342 | /* pll input: mclki/xi */ | 377 | /* pll input: mclki/xi */ |
343 | regmap_write(ad193x->regmap, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9D; mclk=12.288Mhz: 0x99 */ | 378 | regmap_write(ad193x->regmap, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9D; mclk=12.288Mhz: 0x99 */ |
344 | regmap_write(ad193x->regmap, AD193X_PLL_CLK_CTRL1, 0x04); | 379 | regmap_write(ad193x->regmap, AD193X_PLL_CLK_CTRL1, 0x04); |
345 | 380 | ||
381 | /* adc only */ | ||
382 | if (ad193x_has_adc(ad193x)) { | ||
383 | /* add adc controls */ | ||
384 | num = ARRAY_SIZE(ad193x_adc_snd_controls); | ||
385 | ret = snd_soc_add_codec_controls(codec, | ||
386 | ad193x_adc_snd_controls, | ||
387 | num); | ||
388 | if (ret) | ||
389 | return ret; | ||
390 | |||
391 | /* add adc widgets */ | ||
392 | num = ARRAY_SIZE(ad193x_adc_widgets); | ||
393 | ret = snd_soc_dapm_new_controls(dapm, | ||
394 | ad193x_adc_widgets, | ||
395 | num); | ||
396 | if (ret) | ||
397 | return ret; | ||
398 | |||
399 | /* add adc routes */ | ||
400 | num = ARRAY_SIZE(ad193x_adc_audio_paths); | ||
401 | ret = snd_soc_dapm_add_routes(dapm, | ||
402 | ad193x_adc_audio_paths, | ||
403 | num); | ||
404 | if (ret) | ||
405 | return ret; | ||
406 | } | ||
407 | |||
346 | return 0; | 408 | return 0; |
347 | } | 409 | } |
348 | 410 | ||
@@ -356,18 +418,13 @@ static struct snd_soc_codec_driver soc_codec_dev_ad193x = { | |||
356 | .num_dapm_routes = ARRAY_SIZE(audio_paths), | 418 | .num_dapm_routes = ARRAY_SIZE(audio_paths), |
357 | }; | 419 | }; |
358 | 420 | ||
359 | static bool adau193x_reg_volatile(struct device *dev, unsigned int reg) | ||
360 | { | ||
361 | return false; | ||
362 | } | ||
363 | |||
364 | const struct regmap_config ad193x_regmap_config = { | 421 | const struct regmap_config ad193x_regmap_config = { |
365 | .max_register = AD193X_NUM_REGS - 1, | 422 | .max_register = AD193X_NUM_REGS - 1, |
366 | .volatile_reg = adau193x_reg_volatile, | ||
367 | }; | 423 | }; |
368 | EXPORT_SYMBOL_GPL(ad193x_regmap_config); | 424 | EXPORT_SYMBOL_GPL(ad193x_regmap_config); |
369 | 425 | ||
370 | int ad193x_probe(struct device *dev, struct regmap *regmap) | 426 | int ad193x_probe(struct device *dev, struct regmap *regmap, |
427 | enum ad193x_type type) | ||
371 | { | 428 | { |
372 | struct ad193x_priv *ad193x; | 429 | struct ad193x_priv *ad193x; |
373 | 430 | ||
@@ -379,6 +436,7 @@ int ad193x_probe(struct device *dev, struct regmap *regmap) | |||
379 | return -ENOMEM; | 436 | return -ENOMEM; |
380 | 437 | ||
381 | ad193x->regmap = regmap; | 438 | ad193x->regmap = regmap; |
439 | ad193x->type = type; | ||
382 | 440 | ||
383 | dev_set_drvdata(dev, ad193x); | 441 | dev_set_drvdata(dev, ad193x); |
384 | 442 | ||
diff --git a/sound/soc/codecs/ad193x.h b/sound/soc/codecs/ad193x.h index ab9a998f15be..8b1e65f928d2 100644 --- a/sound/soc/codecs/ad193x.h +++ b/sound/soc/codecs/ad193x.h | |||
@@ -13,8 +13,15 @@ | |||
13 | 13 | ||
14 | struct device; | 14 | struct device; |
15 | 15 | ||
16 | enum ad193x_type { | ||
17 | AD193X, | ||
18 | AD1933, | ||
19 | AD1934, | ||
20 | }; | ||
21 | |||
16 | extern const struct regmap_config ad193x_regmap_config; | 22 | extern const struct regmap_config ad193x_regmap_config; |
17 | int ad193x_probe(struct device *dev, struct regmap *regmap); | 23 | int ad193x_probe(struct device *dev, struct regmap *regmap, |
24 | enum ad193x_type type); | ||
18 | 25 | ||
19 | #define AD193X_PLL_CLK_CTRL0 0x00 | 26 | #define AD193X_PLL_CLK_CTRL0 0x00 |
20 | #define AD193X_PLL_POWERDOWN 0x01 | 27 | #define AD193X_PLL_POWERDOWN 0x01 |
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index ac21b85ff75f..9929efc6b9aa 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c | |||
@@ -316,6 +316,7 @@ const char *arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS] = { | |||
316 | "Tone Generator 2", | 316 | "Tone Generator 2", |
317 | "Haptics", | 317 | "Haptics", |
318 | "AEC", | 318 | "AEC", |
319 | "AEC2", | ||
319 | "Mic Mute Mixer", | 320 | "Mic Mute Mixer", |
320 | "Noise Generator", | 321 | "Noise Generator", |
321 | "IN1L", | 322 | "IN1L", |
@@ -423,6 +424,7 @@ int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS] = { | |||
423 | 0x05, | 424 | 0x05, |
424 | 0x06, /* Haptics */ | 425 | 0x06, /* Haptics */ |
425 | 0x08, /* AEC */ | 426 | 0x08, /* AEC */ |
427 | 0x09, /* AEC2 */ | ||
426 | 0x0c, /* Noise mixer */ | 428 | 0x0c, /* Noise mixer */ |
427 | 0x0d, /* Comfort noise */ | 429 | 0x0d, /* Comfort noise */ |
428 | 0x10, /* IN1L */ | 430 | 0x10, /* IN1L */ |
@@ -527,6 +529,32 @@ EXPORT_SYMBOL_GPL(arizona_mixer_values); | |||
527 | const DECLARE_TLV_DB_SCALE(arizona_mixer_tlv, -3200, 100, 0); | 529 | const DECLARE_TLV_DB_SCALE(arizona_mixer_tlv, -3200, 100, 0); |
528 | EXPORT_SYMBOL_GPL(arizona_mixer_tlv); | 530 | EXPORT_SYMBOL_GPL(arizona_mixer_tlv); |
529 | 531 | ||
532 | const char * const arizona_sample_rate_text[ARIZONA_SAMPLE_RATE_ENUM_SIZE] = { | ||
533 | "12kHz", "24kHz", "48kHz", "96kHz", "192kHz", | ||
534 | "11.025kHz", "22.05kHz", "44.1kHz", "88.2kHz", "176.4kHz", | ||
535 | "4kHz", "8kHz", "16kHz", "32kHz", | ||
536 | }; | ||
537 | EXPORT_SYMBOL_GPL(arizona_sample_rate_text); | ||
538 | |||
539 | const unsigned int arizona_sample_rate_val[ARIZONA_SAMPLE_RATE_ENUM_SIZE] = { | ||
540 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, | ||
541 | 0x10, 0x11, 0x12, 0x13, | ||
542 | }; | ||
543 | EXPORT_SYMBOL_GPL(arizona_sample_rate_val); | ||
544 | |||
545 | const char *arizona_sample_rate_val_to_name(unsigned int rate_val) | ||
546 | { | ||
547 | int i; | ||
548 | |||
549 | for (i = 0; i < ARRAY_SIZE(arizona_sample_rate_val); ++i) { | ||
550 | if (arizona_sample_rate_val[i] == rate_val) | ||
551 | return arizona_sample_rate_text[i]; | ||
552 | } | ||
553 | |||
554 | return "Illegal"; | ||
555 | } | ||
556 | EXPORT_SYMBOL_GPL(arizona_sample_rate_val_to_name); | ||
557 | |||
530 | const char *arizona_rate_text[ARIZONA_RATE_ENUM_SIZE] = { | 558 | const char *arizona_rate_text[ARIZONA_RATE_ENUM_SIZE] = { |
531 | "SYNCCLK rate", "8kHz", "16kHz", "ASYNCCLK rate", | 559 | "SYNCCLK rate", "8kHz", "16kHz", "ASYNCCLK rate", |
532 | }; | 560 | }; |
@@ -1884,6 +1912,11 @@ static int arizona_calc_fratio(struct arizona_fll *fll, | |||
1884 | if (fll->arizona->rev < 3 || sync) | 1912 | if (fll->arizona->rev < 3 || sync) |
1885 | return init_ratio; | 1913 | return init_ratio; |
1886 | break; | 1914 | break; |
1915 | case WM8998: | ||
1916 | case WM1814: | ||
1917 | if (sync) | ||
1918 | return init_ratio; | ||
1919 | break; | ||
1887 | default: | 1920 | default: |
1888 | return init_ratio; | 1921 | return init_ratio; |
1889 | } | 1922 | } |
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index 7b68d05a0939..fea8b8ae8e1a 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h | |||
@@ -93,12 +93,17 @@ struct arizona_priv { | |||
93 | bool dvfs_cached; | 93 | bool dvfs_cached; |
94 | }; | 94 | }; |
95 | 95 | ||
96 | #define ARIZONA_NUM_MIXER_INPUTS 103 | 96 | #define ARIZONA_NUM_MIXER_INPUTS 104 |
97 | 97 | ||
98 | extern const unsigned int arizona_mixer_tlv[]; | 98 | extern const unsigned int arizona_mixer_tlv[]; |
99 | extern const char *arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS]; | 99 | extern const char *arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS]; |
100 | extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS]; | 100 | extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS]; |
101 | 101 | ||
102 | #define ARIZONA_GAINMUX_CONTROLS(name, base) \ | ||
103 | SOC_SINGLE_RANGE_TLV(name " Input Volume", base + 1, \ | ||
104 | ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \ | ||
105 | arizona_mixer_tlv) | ||
106 | |||
102 | #define ARIZONA_MIXER_CONTROLS(name, base) \ | 107 | #define ARIZONA_MIXER_CONTROLS(name, base) \ |
103 | SOC_SINGLE_RANGE_TLV(name " Input 1 Volume", base + 1, \ | 108 | SOC_SINGLE_RANGE_TLV(name " Input 1 Volume", base + 1, \ |
104 | ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \ | 109 | ARIZONA_MIXER_VOL_SHIFT, 0x20, 0x50, 0, \ |
@@ -209,8 +214,12 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS]; | |||
209 | .num_regs = 1 }) } | 214 | .num_regs = 1 }) } |
210 | 215 | ||
211 | #define ARIZONA_RATE_ENUM_SIZE 4 | 216 | #define ARIZONA_RATE_ENUM_SIZE 4 |
217 | #define ARIZONA_SAMPLE_RATE_ENUM_SIZE 14 | ||
218 | |||
212 | extern const char *arizona_rate_text[ARIZONA_RATE_ENUM_SIZE]; | 219 | extern const char *arizona_rate_text[ARIZONA_RATE_ENUM_SIZE]; |
213 | extern const int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE]; | 220 | extern const int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE]; |
221 | extern const char * const arizona_sample_rate_text[ARIZONA_SAMPLE_RATE_ENUM_SIZE]; | ||
222 | extern const unsigned int arizona_sample_rate_val[ARIZONA_SAMPLE_RATE_ENUM_SIZE]; | ||
214 | 223 | ||
215 | extern const struct soc_enum arizona_isrc_fsl[]; | 224 | extern const struct soc_enum arizona_isrc_fsl[]; |
216 | extern const struct soc_enum arizona_isrc_fsh[]; | 225 | extern const struct soc_enum arizona_isrc_fsh[]; |
@@ -296,4 +305,5 @@ int arizona_set_output_mode(struct snd_soc_codec *codec, int output, | |||
296 | 305 | ||
297 | extern bool arizona_input_analog(struct snd_soc_codec *codec, int shift); | 306 | extern bool arizona_input_analog(struct snd_soc_codec *codec, int shift); |
298 | 307 | ||
308 | extern const char *arizona_sample_rate_val_to_name(unsigned int rate_val); | ||
299 | #endif | 309 | #endif |
diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index a9c86efb3187..7278f93460c1 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c | |||
@@ -12,6 +12,7 @@ | |||
12 | * option) any later version. | 12 | * option) any later version. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/clk.h> | ||
15 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
16 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
17 | #include <linux/regmap.h> | 18 | #include <linux/regmap.h> |
@@ -1222,23 +1223,44 @@ static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1222 | { | 1223 | { |
1223 | struct snd_soc_codec *codec = codec_dai->codec; | 1224 | struct snd_soc_codec *codec = codec_dai->codec; |
1224 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 1225 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); |
1226 | int ret = 0; | ||
1227 | |||
1228 | if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq)) | ||
1229 | return 0; | ||
1230 | |||
1231 | if (((freq < 5000000) && (freq != 32768)) || (freq > 54000000)) { | ||
1232 | dev_err(codec_dai->dev, "Unsupported MCLK value %d\n", | ||
1233 | freq); | ||
1234 | return -EINVAL; | ||
1235 | } | ||
1225 | 1236 | ||
1226 | switch (clk_id) { | 1237 | switch (clk_id) { |
1227 | case DA7213_CLKSRC_MCLK: | 1238 | case DA7213_CLKSRC_MCLK: |
1228 | if ((freq == 32768) || | 1239 | da7213->mclk_squarer_en = false; |
1229 | ((freq >= 5000000) && (freq <= 54000000))) { | 1240 | break; |
1230 | da7213->mclk_rate = freq; | 1241 | case DA7213_CLKSRC_MCLK_SQR: |
1231 | return 0; | 1242 | da7213->mclk_squarer_en = true; |
1232 | } else { | ||
1233 | dev_err(codec_dai->dev, "Unsupported MCLK value %d\n", | ||
1234 | freq); | ||
1235 | return -EINVAL; | ||
1236 | } | ||
1237 | break; | 1243 | break; |
1238 | default: | 1244 | default: |
1239 | dev_err(codec_dai->dev, "Unknown clock source %d\n", clk_id); | 1245 | dev_err(codec_dai->dev, "Unknown clock source %d\n", clk_id); |
1240 | return -EINVAL; | 1246 | return -EINVAL; |
1241 | } | 1247 | } |
1248 | |||
1249 | da7213->clk_src = clk_id; | ||
1250 | |||
1251 | if (da7213->mclk) { | ||
1252 | freq = clk_round_rate(da7213->mclk, freq); | ||
1253 | ret = clk_set_rate(da7213->mclk, freq); | ||
1254 | if (ret) { | ||
1255 | dev_err(codec_dai->dev, "Failed to set clock rate %d\n", | ||
1256 | freq); | ||
1257 | return ret; | ||
1258 | } | ||
1259 | } | ||
1260 | |||
1261 | da7213->mclk_rate = freq; | ||
1262 | |||
1263 | return 0; | ||
1242 | } | 1264 | } |
1243 | 1265 | ||
1244 | /* Supported PLL input frequencies are 5MHz - 54MHz. */ | 1266 | /* Supported PLL input frequencies are 5MHz - 54MHz. */ |
@@ -1366,12 +1388,25 @@ static struct snd_soc_dai_driver da7213_dai = { | |||
1366 | static int da7213_set_bias_level(struct snd_soc_codec *codec, | 1388 | static int da7213_set_bias_level(struct snd_soc_codec *codec, |
1367 | enum snd_soc_bias_level level) | 1389 | enum snd_soc_bias_level level) |
1368 | { | 1390 | { |
1391 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | ||
1392 | int ret; | ||
1393 | |||
1369 | switch (level) { | 1394 | switch (level) { |
1370 | case SND_SOC_BIAS_ON: | 1395 | case SND_SOC_BIAS_ON: |
1371 | case SND_SOC_BIAS_PREPARE: | 1396 | case SND_SOC_BIAS_PREPARE: |
1372 | break; | 1397 | break; |
1373 | case SND_SOC_BIAS_STANDBY: | 1398 | case SND_SOC_BIAS_STANDBY: |
1374 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { | 1399 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { |
1400 | /* MCLK */ | ||
1401 | if (da7213->mclk) { | ||
1402 | ret = clk_prepare_enable(da7213->mclk); | ||
1403 | if (ret) { | ||
1404 | dev_err(codec->dev, | ||
1405 | "Failed to enable mclk\n"); | ||
1406 | return ret; | ||
1407 | } | ||
1408 | } | ||
1409 | |||
1375 | /* Enable VMID reference & master bias */ | 1410 | /* Enable VMID reference & master bias */ |
1376 | snd_soc_update_bits(codec, DA7213_REFERENCES, | 1411 | snd_soc_update_bits(codec, DA7213_REFERENCES, |
1377 | DA7213_VMID_EN | DA7213_BIAS_EN, | 1412 | DA7213_VMID_EN | DA7213_BIAS_EN, |
@@ -1382,15 +1417,127 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, | |||
1382 | /* Disable VMID reference & master bias */ | 1417 | /* Disable VMID reference & master bias */ |
1383 | snd_soc_update_bits(codec, DA7213_REFERENCES, | 1418 | snd_soc_update_bits(codec, DA7213_REFERENCES, |
1384 | DA7213_VMID_EN | DA7213_BIAS_EN, 0); | 1419 | DA7213_VMID_EN | DA7213_BIAS_EN, 0); |
1420 | |||
1421 | /* MCLK */ | ||
1422 | if (da7213->mclk) | ||
1423 | clk_disable_unprepare(da7213->mclk); | ||
1385 | break; | 1424 | break; |
1386 | } | 1425 | } |
1387 | return 0; | 1426 | return 0; |
1388 | } | 1427 | } |
1389 | 1428 | ||
1429 | /* DT */ | ||
1430 | static const struct of_device_id da7213_of_match[] = { | ||
1431 | { .compatible = "dlg,da7213", }, | ||
1432 | { } | ||
1433 | }; | ||
1434 | MODULE_DEVICE_TABLE(of, da7213_of_match); | ||
1435 | |||
1436 | static enum da7213_micbias_voltage | ||
1437 | da7213_of_micbias_lvl(struct snd_soc_codec *codec, u32 val) | ||
1438 | { | ||
1439 | switch (val) { | ||
1440 | case 1600: | ||
1441 | return DA7213_MICBIAS_1_6V; | ||
1442 | case 2200: | ||
1443 | return DA7213_MICBIAS_2_2V; | ||
1444 | case 2500: | ||
1445 | return DA7213_MICBIAS_2_5V; | ||
1446 | case 3000: | ||
1447 | return DA7213_MICBIAS_3_0V; | ||
1448 | default: | ||
1449 | dev_warn(codec->dev, "Invalid micbias level\n"); | ||
1450 | return DA7213_MICBIAS_2_2V; | ||
1451 | } | ||
1452 | } | ||
1453 | |||
1454 | static enum da7213_dmic_data_sel | ||
1455 | da7213_of_dmic_data_sel(struct snd_soc_codec *codec, const char *str) | ||
1456 | { | ||
1457 | if (!strcmp(str, "lrise_rfall")) { | ||
1458 | return DA7213_DMIC_DATA_LRISE_RFALL; | ||
1459 | } else if (!strcmp(str, "lfall_rrise")) { | ||
1460 | return DA7213_DMIC_DATA_LFALL_RRISE; | ||
1461 | } else { | ||
1462 | dev_warn(codec->dev, "Invalid DMIC data select type\n"); | ||
1463 | return DA7213_DMIC_DATA_LRISE_RFALL; | ||
1464 | } | ||
1465 | } | ||
1466 | |||
1467 | static enum da7213_dmic_samplephase | ||
1468 | da7213_of_dmic_samplephase(struct snd_soc_codec *codec, const char *str) | ||
1469 | { | ||
1470 | if (!strcmp(str, "on_clkedge")) { | ||
1471 | return DA7213_DMIC_SAMPLE_ON_CLKEDGE; | ||
1472 | } else if (!strcmp(str, "between_clkedge")) { | ||
1473 | return DA7213_DMIC_SAMPLE_BETWEEN_CLKEDGE; | ||
1474 | } else { | ||
1475 | dev_warn(codec->dev, "Invalid DMIC sample phase\n"); | ||
1476 | return DA7213_DMIC_SAMPLE_ON_CLKEDGE; | ||
1477 | } | ||
1478 | } | ||
1479 | |||
1480 | static enum da7213_dmic_clk_rate | ||
1481 | da7213_of_dmic_clkrate(struct snd_soc_codec *codec, u32 val) | ||
1482 | { | ||
1483 | switch (val) { | ||
1484 | case 1500000: | ||
1485 | return DA7213_DMIC_CLK_1_5MHZ; | ||
1486 | case 3000000: | ||
1487 | return DA7213_DMIC_CLK_3_0MHZ; | ||
1488 | default: | ||
1489 | dev_warn(codec->dev, "Invalid DMIC clock rate\n"); | ||
1490 | return DA7213_DMIC_CLK_1_5MHZ; | ||
1491 | } | ||
1492 | } | ||
1493 | |||
1494 | static struct da7213_platform_data | ||
1495 | *da7213_of_to_pdata(struct snd_soc_codec *codec) | ||
1496 | { | ||
1497 | struct device_node *np = codec->dev->of_node; | ||
1498 | struct da7213_platform_data *pdata; | ||
1499 | const char *of_str; | ||
1500 | u32 of_val32; | ||
1501 | |||
1502 | pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); | ||
1503 | if (!pdata) { | ||
1504 | dev_warn(codec->dev, "Failed to allocate memory for pdata\n"); | ||
1505 | return NULL; | ||
1506 | } | ||
1507 | |||
1508 | if (of_property_read_u32(np, "dlg,micbias1-lvl", &of_val32) >= 0) | ||
1509 | pdata->micbias1_lvl = da7213_of_micbias_lvl(codec, of_val32); | ||
1510 | else | ||
1511 | pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; | ||
1512 | |||
1513 | if (of_property_read_u32(np, "dlg,micbias2-lvl", &of_val32) >= 0) | ||
1514 | pdata->micbias2_lvl = da7213_of_micbias_lvl(codec, of_val32); | ||
1515 | else | ||
1516 | pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; | ||
1517 | |||
1518 | if (!of_property_read_string(np, "dlg,dmic-data-sel", &of_str)) | ||
1519 | pdata->dmic_data_sel = da7213_of_dmic_data_sel(codec, of_str); | ||
1520 | else | ||
1521 | pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; | ||
1522 | |||
1523 | if (!of_property_read_string(np, "dlg,dmic-samplephase", &of_str)) | ||
1524 | pdata->dmic_samplephase = | ||
1525 | da7213_of_dmic_samplephase(codec, of_str); | ||
1526 | else | ||
1527 | pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; | ||
1528 | |||
1529 | if (of_property_read_u32(np, "dlg,dmic-clkrate", &of_val32) >= 0) | ||
1530 | pdata->dmic_clk_rate = da7213_of_dmic_clkrate(codec, of_val32); | ||
1531 | else | ||
1532 | pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; | ||
1533 | |||
1534 | return pdata; | ||
1535 | } | ||
1536 | |||
1537 | |||
1390 | static int da7213_probe(struct snd_soc_codec *codec) | 1538 | static int da7213_probe(struct snd_soc_codec *codec) |
1391 | { | 1539 | { |
1392 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 1540 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); |
1393 | struct da7213_platform_data *pdata = da7213->pdata; | ||
1394 | 1541 | ||
1395 | /* Default to using ALC auto offset calibration mode. */ | 1542 | /* Default to using ALC auto offset calibration mode. */ |
1396 | snd_soc_update_bits(codec, DA7213_ALC_CTRL1, | 1543 | snd_soc_update_bits(codec, DA7213_ALC_CTRL1, |
@@ -1450,8 +1597,15 @@ static int da7213_probe(struct snd_soc_codec *codec) | |||
1450 | snd_soc_update_bits(codec, DA7213_LINE_CTRL, | 1597 | snd_soc_update_bits(codec, DA7213_LINE_CTRL, |
1451 | DA7213_LINE_AMP_OE, DA7213_LINE_AMP_OE); | 1598 | DA7213_LINE_AMP_OE, DA7213_LINE_AMP_OE); |
1452 | 1599 | ||
1600 | /* Handle DT/Platform data */ | ||
1601 | if (codec->dev->of_node) | ||
1602 | da7213->pdata = da7213_of_to_pdata(codec); | ||
1603 | else | ||
1604 | da7213->pdata = dev_get_platdata(codec->dev); | ||
1605 | |||
1453 | /* Set platform data values */ | 1606 | /* Set platform data values */ |
1454 | if (da7213->pdata) { | 1607 | if (da7213->pdata) { |
1608 | struct da7213_platform_data *pdata = da7213->pdata; | ||
1455 | u8 micbias_lvl = 0, dmic_cfg = 0; | 1609 | u8 micbias_lvl = 0, dmic_cfg = 0; |
1456 | 1610 | ||
1457 | /* Set Mic Bias voltages */ | 1611 | /* Set Mic Bias voltages */ |
@@ -1503,10 +1657,17 @@ static int da7213_probe(struct snd_soc_codec *codec) | |||
1503 | DA7213_DMIC_DATA_SEL_MASK | | 1657 | DA7213_DMIC_DATA_SEL_MASK | |
1504 | DA7213_DMIC_SAMPLEPHASE_MASK | | 1658 | DA7213_DMIC_SAMPLEPHASE_MASK | |
1505 | DA7213_DMIC_CLK_RATE_MASK, dmic_cfg); | 1659 | DA7213_DMIC_CLK_RATE_MASK, dmic_cfg); |
1660 | } | ||
1506 | 1661 | ||
1507 | /* Set MCLK squaring */ | 1662 | /* Check if MCLK provided */ |
1508 | da7213->mclk_squarer_en = pdata->mclk_squaring; | 1663 | da7213->mclk = devm_clk_get(codec->dev, "mclk"); |
1664 | if (IS_ERR(da7213->mclk)) { | ||
1665 | if (PTR_ERR(da7213->mclk) != -ENOENT) | ||
1666 | return PTR_ERR(da7213->mclk); | ||
1667 | else | ||
1668 | da7213->mclk = NULL; | ||
1509 | } | 1669 | } |
1670 | |||
1510 | return 0; | 1671 | return 0; |
1511 | } | 1672 | } |
1512 | 1673 | ||
@@ -1537,7 +1698,6 @@ static int da7213_i2c_probe(struct i2c_client *i2c, | |||
1537 | const struct i2c_device_id *id) | 1698 | const struct i2c_device_id *id) |
1538 | { | 1699 | { |
1539 | struct da7213_priv *da7213; | 1700 | struct da7213_priv *da7213; |
1540 | struct da7213_platform_data *pdata = dev_get_platdata(&i2c->dev); | ||
1541 | int ret; | 1701 | int ret; |
1542 | 1702 | ||
1543 | da7213 = devm_kzalloc(&i2c->dev, sizeof(struct da7213_priv), | 1703 | da7213 = devm_kzalloc(&i2c->dev, sizeof(struct da7213_priv), |
@@ -1545,9 +1705,6 @@ static int da7213_i2c_probe(struct i2c_client *i2c, | |||
1545 | if (!da7213) | 1705 | if (!da7213) |
1546 | return -ENOMEM; | 1706 | return -ENOMEM; |
1547 | 1707 | ||
1548 | if (pdata) | ||
1549 | da7213->pdata = pdata; | ||
1550 | |||
1551 | i2c_set_clientdata(i2c, da7213); | 1708 | i2c_set_clientdata(i2c, da7213); |
1552 | 1709 | ||
1553 | da7213->regmap = devm_regmap_init_i2c(i2c, &da7213_regmap_config); | 1710 | da7213->regmap = devm_regmap_init_i2c(i2c, &da7213_regmap_config); |
@@ -1582,6 +1739,7 @@ MODULE_DEVICE_TABLE(i2c, da7213_i2c_id); | |||
1582 | static struct i2c_driver da7213_i2c_driver = { | 1739 | static struct i2c_driver da7213_i2c_driver = { |
1583 | .driver = { | 1740 | .driver = { |
1584 | .name = "da7213", | 1741 | .name = "da7213", |
1742 | .of_match_table = of_match_ptr(da7213_of_match), | ||
1585 | }, | 1743 | }, |
1586 | .probe = da7213_i2c_probe, | 1744 | .probe = da7213_i2c_probe, |
1587 | .remove = da7213_remove, | 1745 | .remove = da7213_remove, |
diff --git a/sound/soc/codecs/da7213.h b/sound/soc/codecs/da7213.h index 9cb9ddd01282..030fd691b076 100644 --- a/sound/soc/codecs/da7213.h +++ b/sound/soc/codecs/da7213.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #ifndef _DA7213_H | 13 | #ifndef _DA7213_H |
14 | #define _DA7213_H | 14 | #define _DA7213_H |
15 | 15 | ||
16 | #include <linux/clk.h> | ||
16 | #include <linux/regmap.h> | 17 | #include <linux/regmap.h> |
17 | #include <sound/da7213.h> | 18 | #include <sound/da7213.h> |
18 | 19 | ||
@@ -504,14 +505,17 @@ | |||
504 | #define DA7213_PLL_INDIV_20_40_MHZ_VAL 8 | 505 | #define DA7213_PLL_INDIV_20_40_MHZ_VAL 8 |
505 | #define DA7213_PLL_INDIV_40_54_MHZ_VAL 16 | 506 | #define DA7213_PLL_INDIV_40_54_MHZ_VAL 16 |
506 | 507 | ||
507 | enum clk_src { | 508 | enum da7213_clk_src { |
508 | DA7213_CLKSRC_MCLK | 509 | DA7213_CLKSRC_MCLK = 0, |
510 | DA7213_CLKSRC_MCLK_SQR, | ||
509 | }; | 511 | }; |
510 | 512 | ||
511 | /* Codec private data */ | 513 | /* Codec private data */ |
512 | struct da7213_priv { | 514 | struct da7213_priv { |
513 | struct regmap *regmap; | 515 | struct regmap *regmap; |
516 | struct clk *mclk; | ||
514 | unsigned int mclk_rate; | 517 | unsigned int mclk_rate; |
518 | int clk_src; | ||
515 | bool master; | 519 | bool master; |
516 | bool mclk_squarer_en; | 520 | bool mclk_squarer_en; |
517 | bool srm_en; | 521 | bool srm_en; |
diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c new file mode 100644 index 000000000000..9459593eef13 --- /dev/null +++ b/sound/soc/codecs/da7219-aad.c | |||
@@ -0,0 +1,823 @@ | |||
1 | /* | ||
2 | * da7219-aad.c - Dialog DA7219 ALSA SoC AAD Driver | ||
3 | * | ||
4 | * Copyright (c) 2015 Dialog Semiconductor Ltd. | ||
5 | * | ||
6 | * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/of_device.h> | ||
17 | #include <linux/of_irq.h> | ||
18 | #include <linux/pm_wakeirq.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/workqueue.h> | ||
22 | #include <sound/soc.h> | ||
23 | #include <sound/jack.h> | ||
24 | #include <sound/da7219.h> | ||
25 | |||
26 | #include "da7219.h" | ||
27 | #include "da7219-aad.h" | ||
28 | |||
29 | |||
30 | /* | ||
31 | * Detection control | ||
32 | */ | ||
33 | |||
34 | void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack) | ||
35 | { | ||
36 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
37 | |||
38 | da7219->aad->jack = jack; | ||
39 | da7219->aad->jack_inserted = false; | ||
40 | |||
41 | /* Send an initial empty report */ | ||
42 | snd_soc_jack_report(jack, 0, DA7219_AAD_REPORT_ALL_MASK); | ||
43 | |||
44 | /* Enable/Disable jack detection */ | ||
45 | snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, | ||
46 | DA7219_ACCDET_EN_MASK, | ||
47 | (jack ? DA7219_ACCDET_EN_MASK : 0)); | ||
48 | } | ||
49 | EXPORT_SYMBOL_GPL(da7219_aad_jack_det); | ||
50 | |||
51 | /* | ||
52 | * Button/HPTest work | ||
53 | */ | ||
54 | |||
55 | static void da7219_aad_btn_det_work(struct work_struct *work) | ||
56 | { | ||
57 | struct da7219_aad_priv *da7219_aad = | ||
58 | container_of(work, struct da7219_aad_priv, btn_det_work); | ||
59 | struct snd_soc_codec *codec = da7219_aad->codec; | ||
60 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | ||
61 | u8 statusa, micbias_ctrl; | ||
62 | bool micbias_up = false; | ||
63 | int retries = 0; | ||
64 | |||
65 | /* Drive headphones/lineout */ | ||
66 | snd_soc_update_bits(codec, DA7219_HP_L_CTRL, | ||
67 | DA7219_HP_L_AMP_OE_MASK, | ||
68 | DA7219_HP_L_AMP_OE_MASK); | ||
69 | snd_soc_update_bits(codec, DA7219_HP_R_CTRL, | ||
70 | DA7219_HP_R_AMP_OE_MASK, | ||
71 | DA7219_HP_R_AMP_OE_MASK); | ||
72 | |||
73 | /* Make sure mic bias is up */ | ||
74 | snd_soc_dapm_force_enable_pin(dapm, "Mic Bias"); | ||
75 | snd_soc_dapm_sync(dapm); | ||
76 | |||
77 | do { | ||
78 | statusa = snd_soc_read(codec, DA7219_ACCDET_STATUS_A); | ||
79 | if (statusa & DA7219_MICBIAS_UP_STS_MASK) | ||
80 | micbias_up = true; | ||
81 | else if (retries++ < DA7219_AAD_MICBIAS_CHK_RETRIES) | ||
82 | msleep(DA7219_AAD_MICBIAS_CHK_DELAY); | ||
83 | } while ((!micbias_up) && (retries < DA7219_AAD_MICBIAS_CHK_RETRIES)); | ||
84 | |||
85 | if (retries >= DA7219_AAD_MICBIAS_CHK_RETRIES) | ||
86 | dev_warn(codec->dev, "Mic bias status check timed out"); | ||
87 | |||
88 | /* | ||
89 | * Mic bias pulse required to enable mic, must be done before enabling | ||
90 | * button detection to prevent erroneous button readings. | ||
91 | */ | ||
92 | if (da7219_aad->micbias_pulse_lvl && da7219_aad->micbias_pulse_time) { | ||
93 | /* Pulse higher level voltage */ | ||
94 | micbias_ctrl = snd_soc_read(codec, DA7219_MICBIAS_CTRL); | ||
95 | snd_soc_update_bits(codec, DA7219_MICBIAS_CTRL, | ||
96 | DA7219_MICBIAS1_LEVEL_MASK, | ||
97 | da7219_aad->micbias_pulse_lvl); | ||
98 | msleep(da7219_aad->micbias_pulse_time); | ||
99 | snd_soc_write(codec, DA7219_MICBIAS_CTRL, micbias_ctrl); | ||
100 | |||
101 | } | ||
102 | |||
103 | snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, | ||
104 | DA7219_BUTTON_CONFIG_MASK, | ||
105 | da7219_aad->btn_cfg); | ||
106 | } | ||
107 | |||
108 | static void da7219_aad_hptest_work(struct work_struct *work) | ||
109 | { | ||
110 | struct da7219_aad_priv *da7219_aad = | ||
111 | container_of(work, struct da7219_aad_priv, hptest_work); | ||
112 | struct snd_soc_codec *codec = da7219_aad->codec; | ||
113 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | ||
114 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
115 | |||
116 | u16 tonegen_freq_hptest; | ||
117 | u8 accdet_cfg8; | ||
118 | int report = 0; | ||
119 | |||
120 | /* Lock DAPM and any Kcontrols that are affected by this test */ | ||
121 | snd_soc_dapm_mutex_lock(dapm); | ||
122 | mutex_lock(&da7219->lock); | ||
123 | |||
124 | /* Bypass cache so it saves current settings */ | ||
125 | regcache_cache_bypass(da7219->regmap, true); | ||
126 | |||
127 | /* Make sure Tone Generator is disabled */ | ||
128 | snd_soc_write(codec, DA7219_TONE_GEN_CFG1, 0); | ||
129 | |||
130 | /* Enable HPTest block, 1KOhms check */ | ||
131 | snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_8, | ||
132 | DA7219_HPTEST_EN_MASK | DA7219_HPTEST_RES_SEL_MASK, | ||
133 | DA7219_HPTEST_EN_MASK | | ||
134 | DA7219_HPTEST_RES_SEL_1KOHMS); | ||
135 | |||
136 | /* Set gains to 0db */ | ||
137 | snd_soc_write(codec, DA7219_DAC_L_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); | ||
138 | snd_soc_write(codec, DA7219_DAC_R_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); | ||
139 | snd_soc_write(codec, DA7219_HP_L_GAIN, DA7219_HP_AMP_GAIN_0DB); | ||
140 | snd_soc_write(codec, DA7219_HP_R_GAIN, DA7219_HP_AMP_GAIN_0DB); | ||
141 | |||
142 | /* Disable DAC filters, EQs and soft mute */ | ||
143 | snd_soc_update_bits(codec, DA7219_DAC_FILTERS1, DA7219_HPF_MODE_MASK, | ||
144 | 0); | ||
145 | snd_soc_update_bits(codec, DA7219_DAC_FILTERS4, DA7219_DAC_EQ_EN_MASK, | ||
146 | 0); | ||
147 | snd_soc_update_bits(codec, DA7219_DAC_FILTERS5, | ||
148 | DA7219_DAC_SOFTMUTE_EN_MASK, 0); | ||
149 | |||
150 | /* Enable HP left & right paths */ | ||
151 | snd_soc_update_bits(codec, DA7219_CP_CTRL, DA7219_CP_EN_MASK, | ||
152 | DA7219_CP_EN_MASK); | ||
153 | snd_soc_update_bits(codec, DA7219_DIG_ROUTING_DAC, | ||
154 | DA7219_DAC_L_SRC_MASK | DA7219_DAC_R_SRC_MASK, | ||
155 | DA7219_DAC_L_SRC_TONEGEN | | ||
156 | DA7219_DAC_R_SRC_TONEGEN); | ||
157 | snd_soc_update_bits(codec, DA7219_DAC_L_CTRL, | ||
158 | DA7219_DAC_L_EN_MASK | DA7219_DAC_L_MUTE_EN_MASK, | ||
159 | DA7219_DAC_L_EN_MASK); | ||
160 | snd_soc_update_bits(codec, DA7219_DAC_R_CTRL, | ||
161 | DA7219_DAC_R_EN_MASK | DA7219_DAC_R_MUTE_EN_MASK, | ||
162 | DA7219_DAC_R_EN_MASK); | ||
163 | snd_soc_update_bits(codec, DA7219_MIXOUT_L_SELECT, | ||
164 | DA7219_MIXOUT_L_MIX_SELECT_MASK, | ||
165 | DA7219_MIXOUT_L_MIX_SELECT_MASK); | ||
166 | snd_soc_update_bits(codec, DA7219_MIXOUT_R_SELECT, | ||
167 | DA7219_MIXOUT_R_MIX_SELECT_MASK, | ||
168 | DA7219_MIXOUT_R_MIX_SELECT_MASK); | ||
169 | snd_soc_update_bits(codec, DA7219_DROUTING_ST_OUTFILT_1L, | ||
170 | DA7219_OUTFILT_ST_1L_SRC_MASK, | ||
171 | DA7219_DMIX_ST_SRC_OUTFILT1L); | ||
172 | snd_soc_update_bits(codec, DA7219_DROUTING_ST_OUTFILT_1R, | ||
173 | DA7219_OUTFILT_ST_1R_SRC_MASK, | ||
174 | DA7219_DMIX_ST_SRC_OUTFILT1R); | ||
175 | snd_soc_update_bits(codec, DA7219_MIXOUT_L_CTRL, | ||
176 | DA7219_MIXOUT_L_AMP_EN_MASK, | ||
177 | DA7219_MIXOUT_L_AMP_EN_MASK); | ||
178 | snd_soc_update_bits(codec, DA7219_MIXOUT_R_CTRL, | ||
179 | DA7219_MIXOUT_R_AMP_EN_MASK, | ||
180 | DA7219_MIXOUT_R_AMP_EN_MASK); | ||
181 | snd_soc_write(codec, DA7219_HP_L_CTRL, | ||
182 | DA7219_HP_L_AMP_OE_MASK | DA7219_HP_L_AMP_EN_MASK); | ||
183 | snd_soc_write(codec, DA7219_HP_R_CTRL, | ||
184 | DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK); | ||
185 | |||
186 | /* Configure & start Tone Generator */ | ||
187 | snd_soc_write(codec, DA7219_TONE_GEN_ON_PER, DA7219_BEEP_ON_PER_MASK); | ||
188 | tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ); | ||
189 | regmap_raw_write(da7219->regmap, DA7219_TONE_GEN_FREQ1_L, | ||
190 | &tonegen_freq_hptest, sizeof(tonegen_freq_hptest)); | ||
191 | snd_soc_update_bits(codec, DA7219_TONE_GEN_CFG2, | ||
192 | DA7219_SWG_SEL_MASK | DA7219_TONE_GEN_GAIN_MASK, | ||
193 | DA7219_SWG_SEL_SRAMP | | ||
194 | DA7219_TONE_GEN_GAIN_MINUS_15DB); | ||
195 | snd_soc_write(codec, DA7219_TONE_GEN_CFG1, DA7219_START_STOPN_MASK); | ||
196 | |||
197 | msleep(DA7219_AAD_HPTEST_PERIOD); | ||
198 | |||
199 | /* Grab comparator reading */ | ||
200 | accdet_cfg8 = snd_soc_read(codec, DA7219_ACCDET_CONFIG_8); | ||
201 | if (accdet_cfg8 & DA7219_HPTEST_COMP_MASK) | ||
202 | report |= SND_JACK_HEADPHONE; | ||
203 | else | ||
204 | report |= SND_JACK_LINEOUT; | ||
205 | |||
206 | /* Stop tone generator */ | ||
207 | snd_soc_write(codec, DA7219_TONE_GEN_CFG1, 0); | ||
208 | |||
209 | msleep(DA7219_AAD_HPTEST_PERIOD); | ||
210 | |||
211 | /* Restore original settings from cache */ | ||
212 | regcache_mark_dirty(da7219->regmap); | ||
213 | regcache_sync_region(da7219->regmap, DA7219_HP_L_CTRL, | ||
214 | DA7219_HP_R_CTRL); | ||
215 | regcache_sync_region(da7219->regmap, DA7219_MIXOUT_L_CTRL, | ||
216 | DA7219_MIXOUT_R_CTRL); | ||
217 | regcache_sync_region(da7219->regmap, DA7219_DROUTING_ST_OUTFILT_1L, | ||
218 | DA7219_DROUTING_ST_OUTFILT_1R); | ||
219 | regcache_sync_region(da7219->regmap, DA7219_MIXOUT_L_SELECT, | ||
220 | DA7219_MIXOUT_R_SELECT); | ||
221 | regcache_sync_region(da7219->regmap, DA7219_DAC_L_CTRL, | ||
222 | DA7219_DAC_R_CTRL); | ||
223 | regcache_sync_region(da7219->regmap, DA7219_DIG_ROUTING_DAC, | ||
224 | DA7219_DIG_ROUTING_DAC); | ||
225 | regcache_sync_region(da7219->regmap, DA7219_CP_CTRL, DA7219_CP_CTRL); | ||
226 | regcache_sync_region(da7219->regmap, DA7219_DAC_FILTERS5, | ||
227 | DA7219_DAC_FILTERS5); | ||
228 | regcache_sync_region(da7219->regmap, DA7219_DAC_FILTERS4, | ||
229 | DA7219_DAC_FILTERS1); | ||
230 | regcache_sync_region(da7219->regmap, DA7219_HP_L_GAIN, | ||
231 | DA7219_HP_R_GAIN); | ||
232 | regcache_sync_region(da7219->regmap, DA7219_DAC_L_GAIN, | ||
233 | DA7219_DAC_R_GAIN); | ||
234 | regcache_sync_region(da7219->regmap, DA7219_TONE_GEN_ON_PER, | ||
235 | DA7219_TONE_GEN_ON_PER); | ||
236 | regcache_sync_region(da7219->regmap, DA7219_TONE_GEN_FREQ1_L, | ||
237 | DA7219_TONE_GEN_FREQ1_U); | ||
238 | regcache_sync_region(da7219->regmap, DA7219_TONE_GEN_CFG1, | ||
239 | DA7219_TONE_GEN_CFG2); | ||
240 | |||
241 | regcache_cache_bypass(da7219->regmap, false); | ||
242 | |||
243 | /* Disable HPTest block */ | ||
244 | snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_8, | ||
245 | DA7219_HPTEST_EN_MASK, 0); | ||
246 | |||
247 | /* Drive Headphones/lineout */ | ||
248 | snd_soc_update_bits(codec, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, | ||
249 | DA7219_HP_L_AMP_OE_MASK); | ||
250 | snd_soc_update_bits(codec, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, | ||
251 | DA7219_HP_R_AMP_OE_MASK); | ||
252 | |||
253 | mutex_unlock(&da7219->lock); | ||
254 | snd_soc_dapm_mutex_unlock(dapm); | ||
255 | |||
256 | /* | ||
257 | * Only send report if jack hasn't been removed during process, | ||
258 | * otherwise it's invalid and we drop it. | ||
259 | */ | ||
260 | if (da7219_aad->jack_inserted) | ||
261 | snd_soc_jack_report(da7219_aad->jack, report, | ||
262 | SND_JACK_HEADSET | SND_JACK_LINEOUT); | ||
263 | } | ||
264 | |||
265 | |||
266 | /* | ||
267 | * IRQ | ||
268 | */ | ||
269 | |||
270 | static irqreturn_t da7219_aad_irq_thread(int irq, void *data) | ||
271 | { | ||
272 | struct da7219_aad_priv *da7219_aad = data; | ||
273 | struct snd_soc_codec *codec = da7219_aad->codec; | ||
274 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | ||
275 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
276 | u8 events[DA7219_AAD_IRQ_REG_MAX]; | ||
277 | u8 statusa; | ||
278 | int i, report = 0, mask = 0; | ||
279 | |||
280 | /* Read current IRQ events */ | ||
281 | regmap_bulk_read(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A, | ||
282 | events, DA7219_AAD_IRQ_REG_MAX); | ||
283 | |||
284 | if (!events[DA7219_AAD_IRQ_REG_A] && !events[DA7219_AAD_IRQ_REG_B]) | ||
285 | return IRQ_NONE; | ||
286 | |||
287 | /* Read status register for jack insertion & type status */ | ||
288 | statusa = snd_soc_read(codec, DA7219_ACCDET_STATUS_A); | ||
289 | |||
290 | /* Clear events */ | ||
291 | regmap_bulk_write(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A, | ||
292 | events, DA7219_AAD_IRQ_REG_MAX); | ||
293 | |||
294 | dev_dbg(codec->dev, "IRQ events = 0x%x|0x%x, status = 0x%x\n", | ||
295 | events[DA7219_AAD_IRQ_REG_A], events[DA7219_AAD_IRQ_REG_B], | ||
296 | statusa); | ||
297 | |||
298 | if (statusa & DA7219_JACK_INSERTION_STS_MASK) { | ||
299 | /* Jack Insertion */ | ||
300 | if (events[DA7219_AAD_IRQ_REG_A] & | ||
301 | DA7219_E_JACK_INSERTED_MASK) { | ||
302 | report |= SND_JACK_MECHANICAL; | ||
303 | mask |= SND_JACK_MECHANICAL; | ||
304 | da7219_aad->jack_inserted = true; | ||
305 | } | ||
306 | |||
307 | /* Jack type detection */ | ||
308 | if (events[DA7219_AAD_IRQ_REG_A] & | ||
309 | DA7219_E_JACK_DETECT_COMPLETE_MASK) { | ||
310 | /* | ||
311 | * If 4-pole, then enable button detection, else perform | ||
312 | * HP impedance test to determine output type to report. | ||
313 | * | ||
314 | * We schedule work here as the tasks themselves can | ||
315 | * take time to complete, and in particular for hptest | ||
316 | * we want to be able to check if the jack was removed | ||
317 | * during the procedure as this will invalidate the | ||
318 | * result. By doing this as work, the IRQ thread can | ||
319 | * handle a removal, and we can check at the end of | ||
320 | * hptest if we have a valid result or not. | ||
321 | */ | ||
322 | if (statusa & DA7219_JACK_TYPE_STS_MASK) { | ||
323 | report |= SND_JACK_HEADSET; | ||
324 | mask |= SND_JACK_HEADSET | SND_JACK_LINEOUT; | ||
325 | schedule_work(&da7219_aad->btn_det_work); | ||
326 | } else { | ||
327 | schedule_work(&da7219_aad->hptest_work); | ||
328 | } | ||
329 | } | ||
330 | |||
331 | /* Button support for 4-pole jack */ | ||
332 | if (statusa & DA7219_JACK_TYPE_STS_MASK) { | ||
333 | for (i = 0; i < DA7219_AAD_MAX_BUTTONS; ++i) { | ||
334 | /* Button Press */ | ||
335 | if (events[DA7219_AAD_IRQ_REG_B] & | ||
336 | (DA7219_E_BUTTON_A_PRESSED_MASK << i)) { | ||
337 | report |= SND_JACK_BTN_0 >> i; | ||
338 | mask |= SND_JACK_BTN_0 >> i; | ||
339 | } | ||
340 | } | ||
341 | snd_soc_jack_report(da7219_aad->jack, report, mask); | ||
342 | |||
343 | for (i = 0; i < DA7219_AAD_MAX_BUTTONS; ++i) { | ||
344 | /* Button Release */ | ||
345 | if (events[DA7219_AAD_IRQ_REG_B] & | ||
346 | (DA7219_E_BUTTON_A_RELEASED_MASK >> i)) { | ||
347 | report &= ~(SND_JACK_BTN_0 >> i); | ||
348 | mask |= SND_JACK_BTN_0 >> i; | ||
349 | } | ||
350 | } | ||
351 | } | ||
352 | } else { | ||
353 | /* Jack removal */ | ||
354 | if (events[DA7219_AAD_IRQ_REG_A] & DA7219_E_JACK_REMOVED_MASK) { | ||
355 | report = 0; | ||
356 | mask |= DA7219_AAD_REPORT_ALL_MASK; | ||
357 | da7219_aad->jack_inserted = false; | ||
358 | |||
359 | /* Un-drive headphones/lineout */ | ||
360 | snd_soc_update_bits(codec, DA7219_HP_R_CTRL, | ||
361 | DA7219_HP_R_AMP_OE_MASK, 0); | ||
362 | snd_soc_update_bits(codec, DA7219_HP_L_CTRL, | ||
363 | DA7219_HP_L_AMP_OE_MASK, 0); | ||
364 | |||
365 | /* Ensure button detection disabled */ | ||
366 | snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, | ||
367 | DA7219_BUTTON_CONFIG_MASK, 0); | ||
368 | |||
369 | /* Disable mic bias */ | ||
370 | snd_soc_dapm_disable_pin(dapm, "Mic Bias"); | ||
371 | snd_soc_dapm_sync(dapm); | ||
372 | |||
373 | /* Cancel any pending work */ | ||
374 | cancel_work_sync(&da7219_aad->btn_det_work); | ||
375 | cancel_work_sync(&da7219_aad->hptest_work); | ||
376 | } | ||
377 | } | ||
378 | |||
379 | snd_soc_jack_report(da7219_aad->jack, report, mask); | ||
380 | |||
381 | return IRQ_HANDLED; | ||
382 | } | ||
383 | |||
384 | /* | ||
385 | * DT to pdata conversion | ||
386 | */ | ||
387 | |||
388 | static enum da7219_aad_micbias_pulse_lvl | ||
389 | da7219_aad_of_micbias_pulse_lvl(struct snd_soc_codec *codec, u32 val) | ||
390 | { | ||
391 | switch (val) { | ||
392 | case 2800: | ||
393 | return DA7219_AAD_MICBIAS_PULSE_LVL_2_8V; | ||
394 | case 2900: | ||
395 | return DA7219_AAD_MICBIAS_PULSE_LVL_2_9V; | ||
396 | default: | ||
397 | dev_warn(codec->dev, "Invalid micbias pulse level"); | ||
398 | return DA7219_AAD_MICBIAS_PULSE_LVL_OFF; | ||
399 | } | ||
400 | } | ||
401 | |||
402 | static enum da7219_aad_btn_cfg | ||
403 | da7219_aad_of_btn_cfg(struct snd_soc_codec *codec, u32 val) | ||
404 | { | ||
405 | switch (val) { | ||
406 | case 2: | ||
407 | return DA7219_AAD_BTN_CFG_2MS; | ||
408 | case 5: | ||
409 | return DA7219_AAD_BTN_CFG_5MS; | ||
410 | case 10: | ||
411 | return DA7219_AAD_BTN_CFG_10MS; | ||
412 | case 50: | ||
413 | return DA7219_AAD_BTN_CFG_50MS; | ||
414 | case 100: | ||
415 | return DA7219_AAD_BTN_CFG_100MS; | ||
416 | case 200: | ||
417 | return DA7219_AAD_BTN_CFG_200MS; | ||
418 | case 500: | ||
419 | return DA7219_AAD_BTN_CFG_500MS; | ||
420 | default: | ||
421 | dev_warn(codec->dev, "Invalid button config"); | ||
422 | return DA7219_AAD_BTN_CFG_10MS; | ||
423 | } | ||
424 | } | ||
425 | |||
426 | static enum da7219_aad_mic_det_thr | ||
427 | da7219_aad_of_mic_det_thr(struct snd_soc_codec *codec, u32 val) | ||
428 | { | ||
429 | switch (val) { | ||
430 | case 200: | ||
431 | return DA7219_AAD_MIC_DET_THR_200_OHMS; | ||
432 | case 500: | ||
433 | return DA7219_AAD_MIC_DET_THR_500_OHMS; | ||
434 | case 750: | ||
435 | return DA7219_AAD_MIC_DET_THR_750_OHMS; | ||
436 | case 1000: | ||
437 | return DA7219_AAD_MIC_DET_THR_1000_OHMS; | ||
438 | default: | ||
439 | dev_warn(codec->dev, "Invalid mic detect threshold"); | ||
440 | return DA7219_AAD_MIC_DET_THR_500_OHMS; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | static enum da7219_aad_jack_ins_deb | ||
445 | da7219_aad_of_jack_ins_deb(struct snd_soc_codec *codec, u32 val) | ||
446 | { | ||
447 | switch (val) { | ||
448 | case 5: | ||
449 | return DA7219_AAD_JACK_INS_DEB_5MS; | ||
450 | case 10: | ||
451 | return DA7219_AAD_JACK_INS_DEB_10MS; | ||
452 | case 20: | ||
453 | return DA7219_AAD_JACK_INS_DEB_20MS; | ||
454 | case 50: | ||
455 | return DA7219_AAD_JACK_INS_DEB_50MS; | ||
456 | case 100: | ||
457 | return DA7219_AAD_JACK_INS_DEB_100MS; | ||
458 | case 200: | ||
459 | return DA7219_AAD_JACK_INS_DEB_200MS; | ||
460 | case 500: | ||
461 | return DA7219_AAD_JACK_INS_DEB_500MS; | ||
462 | case 1000: | ||
463 | return DA7219_AAD_JACK_INS_DEB_1S; | ||
464 | default: | ||
465 | dev_warn(codec->dev, "Invalid jack insert debounce"); | ||
466 | return DA7219_AAD_JACK_INS_DEB_20MS; | ||
467 | } | ||
468 | } | ||
469 | |||
470 | static enum da7219_aad_jack_det_rate | ||
471 | da7219_aad_of_jack_det_rate(struct snd_soc_codec *codec, const char *str) | ||
472 | { | ||
473 | if (!strcmp(str, "32ms_64ms")) { | ||
474 | return DA7219_AAD_JACK_DET_RATE_32_64MS; | ||
475 | } else if (!strcmp(str, "64ms_128ms")) { | ||
476 | return DA7219_AAD_JACK_DET_RATE_64_128MS; | ||
477 | } else if (!strcmp(str, "128ms_256ms")) { | ||
478 | return DA7219_AAD_JACK_DET_RATE_128_256MS; | ||
479 | } else if (!strcmp(str, "256ms_512ms")) { | ||
480 | return DA7219_AAD_JACK_DET_RATE_256_512MS; | ||
481 | } else { | ||
482 | dev_warn(codec->dev, "Invalid jack detect rate"); | ||
483 | return DA7219_AAD_JACK_DET_RATE_256_512MS; | ||
484 | } | ||
485 | } | ||
486 | |||
487 | static enum da7219_aad_jack_rem_deb | ||
488 | da7219_aad_of_jack_rem_deb(struct snd_soc_codec *codec, u32 val) | ||
489 | { | ||
490 | switch (val) { | ||
491 | case 1: | ||
492 | return DA7219_AAD_JACK_REM_DEB_1MS; | ||
493 | case 5: | ||
494 | return DA7219_AAD_JACK_REM_DEB_5MS; | ||
495 | case 10: | ||
496 | return DA7219_AAD_JACK_REM_DEB_10MS; | ||
497 | case 20: | ||
498 | return DA7219_AAD_JACK_REM_DEB_20MS; | ||
499 | default: | ||
500 | dev_warn(codec->dev, "Invalid jack removal debounce"); | ||
501 | return DA7219_AAD_JACK_REM_DEB_1MS; | ||
502 | } | ||
503 | } | ||
504 | |||
505 | static enum da7219_aad_btn_avg | ||
506 | da7219_aad_of_btn_avg(struct snd_soc_codec *codec, u32 val) | ||
507 | { | ||
508 | switch (val) { | ||
509 | case 1: | ||
510 | return DA7219_AAD_BTN_AVG_1; | ||
511 | case 2: | ||
512 | return DA7219_AAD_BTN_AVG_2; | ||
513 | case 4: | ||
514 | return DA7219_AAD_BTN_AVG_4; | ||
515 | case 8: | ||
516 | return DA7219_AAD_BTN_AVG_8; | ||
517 | default: | ||
518 | dev_warn(codec->dev, "Invalid button average value"); | ||
519 | return DA7219_AAD_BTN_AVG_2; | ||
520 | } | ||
521 | } | ||
522 | |||
523 | static enum da7219_aad_adc_1bit_rpt | ||
524 | da7219_aad_of_adc_1bit_rpt(struct snd_soc_codec *codec, u32 val) | ||
525 | { | ||
526 | switch (val) { | ||
527 | case 1: | ||
528 | return DA7219_AAD_ADC_1BIT_RPT_1; | ||
529 | case 2: | ||
530 | return DA7219_AAD_ADC_1BIT_RPT_2; | ||
531 | case 4: | ||
532 | return DA7219_AAD_ADC_1BIT_RPT_4; | ||
533 | case 8: | ||
534 | return DA7219_AAD_ADC_1BIT_RPT_8; | ||
535 | default: | ||
536 | dev_warn(codec->dev, "Invalid ADC 1-bit repeat value"); | ||
537 | return DA7219_AAD_ADC_1BIT_RPT_1; | ||
538 | } | ||
539 | } | ||
540 | |||
541 | static struct da7219_aad_pdata *da7219_aad_of_to_pdata(struct snd_soc_codec *codec) | ||
542 | { | ||
543 | struct device_node *np = codec->dev->of_node; | ||
544 | struct device_node *aad_np = of_find_node_by_name(np, "da7219_aad"); | ||
545 | struct da7219_aad_pdata *aad_pdata; | ||
546 | const char *of_str; | ||
547 | u32 of_val32; | ||
548 | |||
549 | if (!aad_np) | ||
550 | return NULL; | ||
551 | |||
552 | aad_pdata = devm_kzalloc(codec->dev, sizeof(*aad_pdata), GFP_KERNEL); | ||
553 | if (!aad_pdata) | ||
554 | goto out; | ||
555 | |||
556 | aad_pdata->irq = irq_of_parse_and_map(np, 0); | ||
557 | |||
558 | if (of_property_read_u32(aad_np, "dlg,micbias-pulse-lvl", | ||
559 | &of_val32) >= 0) | ||
560 | aad_pdata->micbias_pulse_lvl = | ||
561 | da7219_aad_of_micbias_pulse_lvl(codec, of_val32); | ||
562 | else | ||
563 | aad_pdata->micbias_pulse_lvl = DA7219_AAD_MICBIAS_PULSE_LVL_OFF; | ||
564 | |||
565 | if (of_property_read_u32(aad_np, "dlg,micbias-pulse-time", | ||
566 | &of_val32) >= 0) | ||
567 | aad_pdata->micbias_pulse_time = of_val32; | ||
568 | |||
569 | if (of_property_read_u32(aad_np, "dlg,btn-cfg", &of_val32) >= 0) | ||
570 | aad_pdata->btn_cfg = da7219_aad_of_btn_cfg(codec, of_val32); | ||
571 | else | ||
572 | aad_pdata->btn_cfg = DA7219_AAD_BTN_CFG_10MS; | ||
573 | |||
574 | if (of_property_read_u32(aad_np, "dlg,mic-det-thr", &of_val32) >= 0) | ||
575 | aad_pdata->mic_det_thr = | ||
576 | da7219_aad_of_mic_det_thr(codec, of_val32); | ||
577 | else | ||
578 | aad_pdata->mic_det_thr = DA7219_AAD_MIC_DET_THR_500_OHMS; | ||
579 | |||
580 | if (of_property_read_u32(aad_np, "dlg,jack-ins-deb", &of_val32) >= 0) | ||
581 | aad_pdata->jack_ins_deb = | ||
582 | da7219_aad_of_jack_ins_deb(codec, of_val32); | ||
583 | else | ||
584 | aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS; | ||
585 | |||
586 | if (!of_property_read_string(aad_np, "dlg,jack-det-rate", &of_str)) | ||
587 | aad_pdata->jack_det_rate = | ||
588 | da7219_aad_of_jack_det_rate(codec, of_str); | ||
589 | else | ||
590 | aad_pdata->jack_det_rate = DA7219_AAD_JACK_DET_RATE_256_512MS; | ||
591 | |||
592 | if (of_property_read_u32(aad_np, "dlg,jack-rem-deb", &of_val32) >= 0) | ||
593 | aad_pdata->jack_rem_deb = | ||
594 | da7219_aad_of_jack_rem_deb(codec, of_val32); | ||
595 | else | ||
596 | aad_pdata->jack_rem_deb = DA7219_AAD_JACK_REM_DEB_1MS; | ||
597 | |||
598 | if (of_property_read_u32(aad_np, "dlg,a-d-btn-thr", &of_val32) >= 0) | ||
599 | aad_pdata->a_d_btn_thr = (u8) of_val32; | ||
600 | else | ||
601 | aad_pdata->a_d_btn_thr = 0xA; | ||
602 | |||
603 | if (of_property_read_u32(aad_np, "dlg,d-b-btn-thr", &of_val32) >= 0) | ||
604 | aad_pdata->d_b_btn_thr = (u8) of_val32; | ||
605 | else | ||
606 | aad_pdata->d_b_btn_thr = 0x16; | ||
607 | |||
608 | if (of_property_read_u32(aad_np, "dlg,b-c-btn-thr", &of_val32) >= 0) | ||
609 | aad_pdata->b_c_btn_thr = (u8) of_val32; | ||
610 | else | ||
611 | aad_pdata->b_c_btn_thr = 0x21; | ||
612 | |||
613 | if (of_property_read_u32(aad_np, "dlg,c-mic-btn-thr", &of_val32) >= 0) | ||
614 | aad_pdata->c_mic_btn_thr = (u8) of_val32; | ||
615 | else | ||
616 | aad_pdata->c_mic_btn_thr = 0x3E; | ||
617 | |||
618 | if (of_property_read_u32(aad_np, "dlg,btn-avg", &of_val32) >= 0) | ||
619 | aad_pdata->btn_avg = da7219_aad_of_btn_avg(codec, of_val32); | ||
620 | else | ||
621 | aad_pdata->btn_avg = DA7219_AAD_BTN_AVG_2; | ||
622 | |||
623 | if (of_property_read_u32(aad_np, "dlg,adc-1bit-rpt", &of_val32) >= 0) | ||
624 | aad_pdata->adc_1bit_rpt = | ||
625 | da7219_aad_of_adc_1bit_rpt(codec, of_val32); | ||
626 | else | ||
627 | aad_pdata->adc_1bit_rpt = DA7219_AAD_ADC_1BIT_RPT_1; | ||
628 | |||
629 | out: | ||
630 | of_node_put(aad_np); | ||
631 | |||
632 | return aad_pdata; | ||
633 | } | ||
634 | |||
635 | static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) | ||
636 | { | ||
637 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
638 | struct da7219_aad_priv *da7219_aad = da7219->aad; | ||
639 | struct da7219_pdata *pdata = da7219->pdata; | ||
640 | |||
641 | if ((pdata) && (pdata->aad_pdata)) { | ||
642 | struct da7219_aad_pdata *aad_pdata = pdata->aad_pdata; | ||
643 | u8 cfg, mask; | ||
644 | |||
645 | da7219_aad->irq = aad_pdata->irq; | ||
646 | |||
647 | switch (aad_pdata->micbias_pulse_lvl) { | ||
648 | case DA7219_AAD_MICBIAS_PULSE_LVL_2_8V: | ||
649 | case DA7219_AAD_MICBIAS_PULSE_LVL_2_9V: | ||
650 | da7219_aad->micbias_pulse_lvl = | ||
651 | (aad_pdata->micbias_pulse_lvl << | ||
652 | DA7219_MICBIAS1_LEVEL_SHIFT); | ||
653 | break; | ||
654 | default: | ||
655 | break; | ||
656 | } | ||
657 | |||
658 | da7219_aad->micbias_pulse_time = aad_pdata->micbias_pulse_time; | ||
659 | |||
660 | switch (aad_pdata->btn_cfg) { | ||
661 | case DA7219_AAD_BTN_CFG_2MS: | ||
662 | case DA7219_AAD_BTN_CFG_5MS: | ||
663 | case DA7219_AAD_BTN_CFG_10MS: | ||
664 | case DA7219_AAD_BTN_CFG_50MS: | ||
665 | case DA7219_AAD_BTN_CFG_100MS: | ||
666 | case DA7219_AAD_BTN_CFG_200MS: | ||
667 | case DA7219_AAD_BTN_CFG_500MS: | ||
668 | da7219_aad->btn_cfg = (aad_pdata->btn_cfg << | ||
669 | DA7219_BUTTON_CONFIG_SHIFT); | ||
670 | } | ||
671 | |||
672 | cfg = 0; | ||
673 | mask = 0; | ||
674 | switch (aad_pdata->mic_det_thr) { | ||
675 | case DA7219_AAD_MIC_DET_THR_200_OHMS: | ||
676 | case DA7219_AAD_MIC_DET_THR_500_OHMS: | ||
677 | case DA7219_AAD_MIC_DET_THR_750_OHMS: | ||
678 | case DA7219_AAD_MIC_DET_THR_1000_OHMS: | ||
679 | cfg |= (aad_pdata->mic_det_thr << | ||
680 | DA7219_MIC_DET_THRESH_SHIFT); | ||
681 | mask |= DA7219_MIC_DET_THRESH_MASK; | ||
682 | } | ||
683 | snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, mask, cfg); | ||
684 | |||
685 | cfg = 0; | ||
686 | mask = 0; | ||
687 | switch (aad_pdata->jack_ins_deb) { | ||
688 | case DA7219_AAD_JACK_INS_DEB_5MS: | ||
689 | case DA7219_AAD_JACK_INS_DEB_10MS: | ||
690 | case DA7219_AAD_JACK_INS_DEB_20MS: | ||
691 | case DA7219_AAD_JACK_INS_DEB_50MS: | ||
692 | case DA7219_AAD_JACK_INS_DEB_100MS: | ||
693 | case DA7219_AAD_JACK_INS_DEB_200MS: | ||
694 | case DA7219_AAD_JACK_INS_DEB_500MS: | ||
695 | case DA7219_AAD_JACK_INS_DEB_1S: | ||
696 | cfg |= (aad_pdata->jack_ins_deb << | ||
697 | DA7219_JACKDET_DEBOUNCE_SHIFT); | ||
698 | mask |= DA7219_JACKDET_DEBOUNCE_MASK; | ||
699 | } | ||
700 | switch (aad_pdata->jack_det_rate) { | ||
701 | case DA7219_AAD_JACK_DET_RATE_32_64MS: | ||
702 | case DA7219_AAD_JACK_DET_RATE_64_128MS: | ||
703 | case DA7219_AAD_JACK_DET_RATE_128_256MS: | ||
704 | case DA7219_AAD_JACK_DET_RATE_256_512MS: | ||
705 | cfg |= (aad_pdata->jack_det_rate << | ||
706 | DA7219_JACK_DETECT_RATE_SHIFT); | ||
707 | mask |= DA7219_JACK_DETECT_RATE_MASK; | ||
708 | } | ||
709 | switch (aad_pdata->jack_rem_deb) { | ||
710 | case DA7219_AAD_JACK_REM_DEB_1MS: | ||
711 | case DA7219_AAD_JACK_REM_DEB_5MS: | ||
712 | case DA7219_AAD_JACK_REM_DEB_10MS: | ||
713 | case DA7219_AAD_JACK_REM_DEB_20MS: | ||
714 | cfg |= (aad_pdata->jack_rem_deb << | ||
715 | DA7219_JACKDET_REM_DEB_SHIFT); | ||
716 | mask |= DA7219_JACKDET_REM_DEB_MASK; | ||
717 | } | ||
718 | snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_2, mask, cfg); | ||
719 | |||
720 | snd_soc_write(codec, DA7219_ACCDET_CONFIG_3, | ||
721 | aad_pdata->a_d_btn_thr); | ||
722 | snd_soc_write(codec, DA7219_ACCDET_CONFIG_4, | ||
723 | aad_pdata->d_b_btn_thr); | ||
724 | snd_soc_write(codec, DA7219_ACCDET_CONFIG_5, | ||
725 | aad_pdata->b_c_btn_thr); | ||
726 | snd_soc_write(codec, DA7219_ACCDET_CONFIG_6, | ||
727 | aad_pdata->c_mic_btn_thr); | ||
728 | |||
729 | cfg = 0; | ||
730 | mask = 0; | ||
731 | switch (aad_pdata->btn_avg) { | ||
732 | case DA7219_AAD_BTN_AVG_1: | ||
733 | case DA7219_AAD_BTN_AVG_2: | ||
734 | case DA7219_AAD_BTN_AVG_4: | ||
735 | case DA7219_AAD_BTN_AVG_8: | ||
736 | cfg |= (aad_pdata->btn_avg << | ||
737 | DA7219_BUTTON_AVERAGE_SHIFT); | ||
738 | mask |= DA7219_BUTTON_AVERAGE_MASK; | ||
739 | } | ||
740 | switch (aad_pdata->adc_1bit_rpt) { | ||
741 | case DA7219_AAD_ADC_1BIT_RPT_1: | ||
742 | case DA7219_AAD_ADC_1BIT_RPT_2: | ||
743 | case DA7219_AAD_ADC_1BIT_RPT_4: | ||
744 | case DA7219_AAD_ADC_1BIT_RPT_8: | ||
745 | cfg |= (aad_pdata->adc_1bit_rpt << | ||
746 | DA7219_ADC_1_BIT_REPEAT_SHIFT); | ||
747 | mask |= DA7219_ADC_1_BIT_REPEAT_MASK; | ||
748 | } | ||
749 | snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_7, mask, cfg); | ||
750 | } | ||
751 | } | ||
752 | |||
753 | |||
754 | /* | ||
755 | * Init/Exit | ||
756 | */ | ||
757 | |||
758 | int da7219_aad_init(struct snd_soc_codec *codec) | ||
759 | { | ||
760 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
761 | struct da7219_aad_priv *da7219_aad; | ||
762 | u8 mask[DA7219_AAD_IRQ_REG_MAX]; | ||
763 | int ret; | ||
764 | |||
765 | da7219_aad = devm_kzalloc(codec->dev, sizeof(*da7219_aad), GFP_KERNEL); | ||
766 | if (!da7219_aad) | ||
767 | return -ENOMEM; | ||
768 | |||
769 | da7219->aad = da7219_aad; | ||
770 | da7219_aad->codec = codec; | ||
771 | |||
772 | /* Handle any DT/platform data */ | ||
773 | if ((codec->dev->of_node) && (da7219->pdata)) | ||
774 | da7219->pdata->aad_pdata = da7219_aad_of_to_pdata(codec); | ||
775 | |||
776 | da7219_aad_handle_pdata(codec); | ||
777 | |||
778 | /* Disable button detection */ | ||
779 | snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, | ||
780 | DA7219_BUTTON_CONFIG_MASK, 0); | ||
781 | |||
782 | INIT_WORK(&da7219_aad->btn_det_work, da7219_aad_btn_det_work); | ||
783 | INIT_WORK(&da7219_aad->hptest_work, da7219_aad_hptest_work); | ||
784 | |||
785 | ret = request_threaded_irq(da7219_aad->irq, NULL, | ||
786 | da7219_aad_irq_thread, | ||
787 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | ||
788 | "da7219-aad", da7219_aad); | ||
789 | if (ret) { | ||
790 | dev_err(codec->dev, "Failed to request IRQ: %d\n", ret); | ||
791 | return ret; | ||
792 | } | ||
793 | |||
794 | /* Unmask AAD IRQs */ | ||
795 | memset(mask, 0, DA7219_AAD_IRQ_REG_MAX); | ||
796 | regmap_bulk_write(da7219->regmap, DA7219_ACCDET_IRQ_MASK_A, | ||
797 | &mask, DA7219_AAD_IRQ_REG_MAX); | ||
798 | |||
799 | return 0; | ||
800 | } | ||
801 | EXPORT_SYMBOL_GPL(da7219_aad_init); | ||
802 | |||
803 | void da7219_aad_exit(struct snd_soc_codec *codec) | ||
804 | { | ||
805 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
806 | struct da7219_aad_priv *da7219_aad = da7219->aad; | ||
807 | u8 mask[DA7219_AAD_IRQ_REG_MAX]; | ||
808 | |||
809 | /* Mask off AAD IRQs */ | ||
810 | memset(mask, DA7219_BYTE_MASK, DA7219_AAD_IRQ_REG_MAX); | ||
811 | regmap_bulk_write(da7219->regmap, DA7219_ACCDET_IRQ_MASK_A, | ||
812 | mask, DA7219_AAD_IRQ_REG_MAX); | ||
813 | |||
814 | free_irq(da7219_aad->irq, da7219_aad); | ||
815 | |||
816 | cancel_work_sync(&da7219_aad->btn_det_work); | ||
817 | cancel_work_sync(&da7219_aad->hptest_work); | ||
818 | } | ||
819 | EXPORT_SYMBOL_GPL(da7219_aad_exit); | ||
820 | |||
821 | MODULE_DESCRIPTION("ASoC DA7219 AAD Driver"); | ||
822 | MODULE_AUTHOR("Adam Thomson <Adam.Thomson.Opensource@diasemi.com>"); | ||
823 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/da7219-aad.h b/sound/soc/codecs/da7219-aad.h new file mode 100644 index 000000000000..4fccf677cd06 --- /dev/null +++ b/sound/soc/codecs/da7219-aad.h | |||
@@ -0,0 +1,212 @@ | |||
1 | /* | ||
2 | * da7219-aad.h - DA7322 ASoC AAD Driver | ||
3 | * | ||
4 | * Copyright (c) 2015 Dialog Semiconductor Ltd. | ||
5 | * | ||
6 | * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #ifndef __DA7219_AAD_H | ||
15 | #define __DA7219_AAD_H | ||
16 | |||
17 | #include <linux/timer.h> | ||
18 | #include <sound/soc.h> | ||
19 | #include <sound/jack.h> | ||
20 | #include <sound/da7219-aad.h> | ||
21 | |||
22 | /* | ||
23 | * Registers | ||
24 | */ | ||
25 | |||
26 | #define DA7219_ACCDET_STATUS_A 0xC0 | ||
27 | #define DA7219_ACCDET_STATUS_B 0xC1 | ||
28 | #define DA7219_ACCDET_IRQ_EVENT_A 0xC2 | ||
29 | #define DA7219_ACCDET_IRQ_EVENT_B 0xC3 | ||
30 | #define DA7219_ACCDET_IRQ_MASK_A 0xC4 | ||
31 | #define DA7219_ACCDET_IRQ_MASK_B 0xC5 | ||
32 | #define DA7219_ACCDET_CONFIG_1 0xC6 | ||
33 | #define DA7219_ACCDET_CONFIG_2 0xC7 | ||
34 | #define DA7219_ACCDET_CONFIG_3 0xC8 | ||
35 | #define DA7219_ACCDET_CONFIG_4 0xC9 | ||
36 | #define DA7219_ACCDET_CONFIG_5 0xCA | ||
37 | #define DA7219_ACCDET_CONFIG_6 0xCB | ||
38 | #define DA7219_ACCDET_CONFIG_7 0xCC | ||
39 | #define DA7219_ACCDET_CONFIG_8 0xCD | ||
40 | |||
41 | |||
42 | /* | ||
43 | * Bit Fields | ||
44 | */ | ||
45 | |||
46 | /* DA7219_ACCDET_STATUS_A = 0xC0 */ | ||
47 | #define DA7219_JACK_INSERTION_STS_SHIFT 0 | ||
48 | #define DA7219_JACK_INSERTION_STS_MASK (0x1 << 0) | ||
49 | #define DA7219_JACK_TYPE_STS_SHIFT 1 | ||
50 | #define DA7219_JACK_TYPE_STS_MASK (0x1 << 1) | ||
51 | #define DA7219_JACK_PIN_ORDER_STS_SHIFT 2 | ||
52 | #define DA7219_JACK_PIN_ORDER_STS_MASK (0x1 << 2) | ||
53 | #define DA7219_MICBIAS_UP_STS_SHIFT 3 | ||
54 | #define DA7219_MICBIAS_UP_STS_MASK (0x1 << 3) | ||
55 | |||
56 | /* DA7219_ACCDET_STATUS_B = 0xC1 */ | ||
57 | #define DA7219_BUTTON_TYPE_STS_SHIFT 0 | ||
58 | #define DA7219_BUTTON_TYPE_STS_MASK (0xFF << 0) | ||
59 | |||
60 | /* DA7219_ACCDET_IRQ_EVENT_A = 0xC2 */ | ||
61 | #define DA7219_E_JACK_INSERTED_SHIFT 0 | ||
62 | #define DA7219_E_JACK_INSERTED_MASK (0x1 << 0) | ||
63 | #define DA7219_E_JACK_REMOVED_SHIFT 1 | ||
64 | #define DA7219_E_JACK_REMOVED_MASK (0x1 << 1) | ||
65 | #define DA7219_E_JACK_DETECT_COMPLETE_SHIFT 2 | ||
66 | #define DA7219_E_JACK_DETECT_COMPLETE_MASK (0x1 << 2) | ||
67 | |||
68 | /* DA7219_ACCDET_IRQ_EVENT_B = 0xC3 */ | ||
69 | #define DA7219_E_BUTTON_A_PRESSED_SHIFT 0 | ||
70 | #define DA7219_E_BUTTON_A_PRESSED_MASK (0x1 << 0) | ||
71 | #define DA7219_E_BUTTON_B_PRESSED_SHIFT 1 | ||
72 | #define DA7219_E_BUTTON_B_PRESSED_MASK (0x1 << 1) | ||
73 | #define DA7219_E_BUTTON_C_PRESSED_SHIFT 2 | ||
74 | #define DA7219_E_BUTTON_C_PRESSED_MASK (0x1 << 2) | ||
75 | #define DA7219_E_BUTTON_D_PRESSED_SHIFT 3 | ||
76 | #define DA7219_E_BUTTON_D_PRESSED_MASK (0x1 << 3) | ||
77 | #define DA7219_E_BUTTON_D_RELEASED_SHIFT 4 | ||
78 | #define DA7219_E_BUTTON_D_RELEASED_MASK (0x1 << 4) | ||
79 | #define DA7219_E_BUTTON_C_RELEASED_SHIFT 5 | ||
80 | #define DA7219_E_BUTTON_C_RELEASED_MASK (0x1 << 5) | ||
81 | #define DA7219_E_BUTTON_B_RELEASED_SHIFT 6 | ||
82 | #define DA7219_E_BUTTON_B_RELEASED_MASK (0x1 << 6) | ||
83 | #define DA7219_E_BUTTON_A_RELEASED_SHIFT 7 | ||
84 | #define DA7219_E_BUTTON_A_RELEASED_MASK (0x1 << 7) | ||
85 | |||
86 | /* DA7219_ACCDET_IRQ_MASK_A = 0xC4 */ | ||
87 | #define DA7219_M_JACK_INSERTED_SHIFT 0 | ||
88 | #define DA7219_M_JACK_INSERTED_MASK (0x1 << 0) | ||
89 | #define DA7219_M_JACK_REMOVED_SHIFT 1 | ||
90 | #define DA7219_M_JACK_REMOVED_MASK (0x1 << 1) | ||
91 | #define DA7219_M_JACK_DETECT_COMPLETE_SHIFT 2 | ||
92 | #define DA7219_M_JACK_DETECT_COMPLETE_MASK (0x1 << 2) | ||
93 | |||
94 | /* DA7219_ACCDET_IRQ_MASK_B = 0xC5 */ | ||
95 | #define DA7219_M_BUTTON_A_PRESSED_SHIFT 0 | ||
96 | #define DA7219_M_BUTTON_A_PRESSED_MASK (0x1 << 0) | ||
97 | #define DA7219_M_BUTTON_B_PRESSED_SHIFT 1 | ||
98 | #define DA7219_M_BUTTON_B_PRESSED_MASK (0x1 << 1) | ||
99 | #define DA7219_M_BUTTON_C_PRESSED_SHIFT 2 | ||
100 | #define DA7219_M_BUTTON_C_PRESSED_MASK (0x1 << 2) | ||
101 | #define DA7219_M_BUTTON_D_PRESSED_SHIFT 3 | ||
102 | #define DA7219_M_BUTTON_D_PRESSED_MASK (0x1 << 3) | ||
103 | #define DA7219_M_BUTTON_D_RELEASED_SHIFT 4 | ||
104 | #define DA7219_M_BUTTON_D_RELEASED_MASK (0x1 << 4) | ||
105 | #define DA7219_M_BUTTON_C_RELEASED_SHIFT 5 | ||
106 | #define DA7219_M_BUTTON_C_RELEASED_MASK (0x1 << 5) | ||
107 | #define DA7219_M_BUTTON_B_RELEASED_SHIFT 6 | ||
108 | #define DA7219_M_BUTTON_B_RELEASED_MASK (0x1 << 6) | ||
109 | #define DA7219_M_BUTTON_A_RELEASED_SHIFT 7 | ||
110 | #define DA7219_M_BUTTON_A_RELEASED_MASK (0x1 << 7) | ||
111 | |||
112 | /* DA7219_ACCDET_CONFIG_1 = 0xC6 */ | ||
113 | #define DA7219_ACCDET_EN_SHIFT 0 | ||
114 | #define DA7219_ACCDET_EN_MASK (0x1 << 0) | ||
115 | #define DA7219_BUTTON_CONFIG_SHIFT 1 | ||
116 | #define DA7219_BUTTON_CONFIG_MASK (0x7 << 1) | ||
117 | #define DA7219_MIC_DET_THRESH_SHIFT 4 | ||
118 | #define DA7219_MIC_DET_THRESH_MASK (0x3 << 4) | ||
119 | #define DA7219_JACK_TYPE_DET_EN_SHIFT 6 | ||
120 | #define DA7219_JACK_TYPE_DET_EN_MASK (0x1 << 6) | ||
121 | #define DA7219_PIN_ORDER_DET_EN_SHIFT 7 | ||
122 | #define DA7219_PIN_ORDER_DET_EN_MASK (0x1 << 7) | ||
123 | |||
124 | /* DA7219_ACCDET_CONFIG_2 = 0xC7 */ | ||
125 | #define DA7219_ACCDET_PAUSE_SHIFT 0 | ||
126 | #define DA7219_ACCDET_PAUSE_MASK (0x1 << 0) | ||
127 | #define DA7219_JACKDET_DEBOUNCE_SHIFT 1 | ||
128 | #define DA7219_JACKDET_DEBOUNCE_MASK (0x7 << 1) | ||
129 | #define DA7219_JACK_DETECT_RATE_SHIFT 4 | ||
130 | #define DA7219_JACK_DETECT_RATE_MASK (0x3 << 4) | ||
131 | #define DA7219_JACKDET_REM_DEB_SHIFT 6 | ||
132 | #define DA7219_JACKDET_REM_DEB_MASK (0x3 << 6) | ||
133 | |||
134 | /* DA7219_ACCDET_CONFIG_3 = 0xC8 */ | ||
135 | #define DA7219_A_D_BUTTON_THRESH_SHIFT 0 | ||
136 | #define DA7219_A_D_BUTTON_THRESH_MASK (0xFF << 0) | ||
137 | |||
138 | /* DA7219_ACCDET_CONFIG_4 = 0xC9 */ | ||
139 | #define DA7219_D_B_BUTTON_THRESH_SHIFT 0 | ||
140 | #define DA7219_D_B_BUTTON_THRESH_MASK (0xFF << 0) | ||
141 | |||
142 | /* DA7219_ACCDET_CONFIG_5 = 0xCA */ | ||
143 | #define DA7219_B_C_BUTTON_THRESH_SHIFT 0 | ||
144 | #define DA7219_B_C_BUTTON_THRESH_MASK (0xFF << 0) | ||
145 | |||
146 | /* DA7219_ACCDET_CONFIG_6 = 0xCB */ | ||
147 | #define DA7219_C_MIC_BUTTON_THRESH_SHIFT 0 | ||
148 | #define DA7219_C_MIC_BUTTON_THRESH_MASK (0xFF << 0) | ||
149 | |||
150 | /* DA7219_ACCDET_CONFIG_7 = 0xCC */ | ||
151 | #define DA7219_BUTTON_AVERAGE_SHIFT 0 | ||
152 | #define DA7219_BUTTON_AVERAGE_MASK (0x3 << 0) | ||
153 | #define DA7219_ADC_1_BIT_REPEAT_SHIFT 2 | ||
154 | #define DA7219_ADC_1_BIT_REPEAT_MASK (0x3 << 2) | ||
155 | #define DA7219_PIN_ORDER_FORCE_SHIFT 4 | ||
156 | #define DA7219_PIN_ORDER_FORCE_MASK (0x1 << 4) | ||
157 | #define DA7219_JACK_TYPE_FORCE_SHIFT 5 | ||
158 | #define DA7219_JACK_TYPE_FORCE_MASK (0x1 << 5) | ||
159 | |||
160 | /* DA7219_ACCDET_CONFIG_8 = 0xCD */ | ||
161 | #define DA7219_HPTEST_EN_SHIFT 0 | ||
162 | #define DA7219_HPTEST_EN_MASK (0x1 << 0) | ||
163 | #define DA7219_HPTEST_RES_SEL_SHIFT 1 | ||
164 | #define DA7219_HPTEST_RES_SEL_MASK (0x3 << 1) | ||
165 | #define DA7219_HPTEST_RES_SEL_1KOHMS (0x0 << 1) | ||
166 | #define DA7219_HPTEST_COMP_SHIFT 4 | ||
167 | #define DA7219_HPTEST_COMP_MASK (0x1 << 4) | ||
168 | |||
169 | |||
170 | #define DA7219_AAD_MAX_BUTTONS 4 | ||
171 | #define DA7219_AAD_REPORT_ALL_MASK (SND_JACK_MECHANICAL | \ | ||
172 | SND_JACK_HEADSET | SND_JACK_LINEOUT | \ | ||
173 | SND_JACK_BTN_0 | SND_JACK_BTN_1 | \ | ||
174 | SND_JACK_BTN_2 | SND_JACK_BTN_3) | ||
175 | |||
176 | #define DA7219_AAD_MICBIAS_CHK_DELAY 10 | ||
177 | #define DA7219_AAD_MICBIAS_CHK_RETRIES 5 | ||
178 | |||
179 | #define DA7219_AAD_HPTEST_RAMP_FREQ 0x28 | ||
180 | #define DA7219_AAD_HPTEST_PERIOD 65 | ||
181 | |||
182 | enum da7219_aad_event_regs { | ||
183 | DA7219_AAD_IRQ_REG_A = 0, | ||
184 | DA7219_AAD_IRQ_REG_B, | ||
185 | DA7219_AAD_IRQ_REG_MAX, | ||
186 | }; | ||
187 | |||
188 | /* Private data */ | ||
189 | struct da7219_aad_priv { | ||
190 | struct snd_soc_codec *codec; | ||
191 | int irq; | ||
192 | |||
193 | u8 micbias_pulse_lvl; | ||
194 | u32 micbias_pulse_time; | ||
195 | |||
196 | u8 btn_cfg; | ||
197 | |||
198 | struct work_struct btn_det_work; | ||
199 | struct work_struct hptest_work; | ||
200 | |||
201 | struct snd_soc_jack *jack; | ||
202 | bool jack_inserted; | ||
203 | }; | ||
204 | |||
205 | /* AAD control */ | ||
206 | void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack); | ||
207 | |||
208 | /* Init/Exit */ | ||
209 | int da7219_aad_init(struct snd_soc_codec *codec); | ||
210 | void da7219_aad_exit(struct snd_soc_codec *codec); | ||
211 | |||
212 | #endif /* __DA7219_AAD_H */ | ||
diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c new file mode 100644 index 000000000000..f238c1e8a69c --- /dev/null +++ b/sound/soc/codecs/da7219.c | |||
@@ -0,0 +1,1955 @@ | |||
1 | /* | ||
2 | * da7219.c - DA7219 ALSA SoC Codec Driver | ||
3 | * | ||
4 | * Copyright (c) 2015 Dialog Semiconductor | ||
5 | * | ||
6 | * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/clk.h> | ||
15 | #include <linux/i2c.h> | ||
16 | #include <linux/of_device.h> | ||
17 | #include <linux/regmap.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/pm.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/delay.h> | ||
22 | #include <linux/regulator/consumer.h> | ||
23 | #include <sound/pcm.h> | ||
24 | #include <sound/pcm_params.h> | ||
25 | #include <sound/soc.h> | ||
26 | #include <sound/soc-dapm.h> | ||
27 | #include <sound/initval.h> | ||
28 | #include <sound/tlv.h> | ||
29 | #include <asm/div64.h> | ||
30 | |||
31 | #include <sound/da7219.h> | ||
32 | #include "da7219.h" | ||
33 | #include "da7219-aad.h" | ||
34 | |||
35 | |||
36 | /* | ||
37 | * TLVs and Enums | ||
38 | */ | ||
39 | |||
40 | /* Input TLVs */ | ||
41 | static const DECLARE_TLV_DB_SCALE(da7219_mic_gain_tlv, -600, 600, 0); | ||
42 | static const DECLARE_TLV_DB_SCALE(da7219_mixin_gain_tlv, -450, 150, 0); | ||
43 | static const DECLARE_TLV_DB_SCALE(da7219_adc_dig_gain_tlv, -8325, 75, 0); | ||
44 | static const DECLARE_TLV_DB_SCALE(da7219_alc_threshold_tlv, -9450, 150, 0); | ||
45 | static const DECLARE_TLV_DB_SCALE(da7219_alc_gain_tlv, 0, 600, 0); | ||
46 | static const DECLARE_TLV_DB_SCALE(da7219_alc_ana_gain_tlv, 0, 600, 0); | ||
47 | static const DECLARE_TLV_DB_SCALE(da7219_sidetone_gain_tlv, -4200, 300, 0); | ||
48 | static const DECLARE_TLV_DB_SCALE(da7219_tonegen_gain_tlv, -4500, 300, 0); | ||
49 | |||
50 | /* Output TLVs */ | ||
51 | static const DECLARE_TLV_DB_SCALE(da7219_dac_eq_band_tlv, -1050, 150, 0); | ||
52 | |||
53 | static const DECLARE_TLV_DB_RANGE(da7219_dac_dig_gain_tlv, | ||
54 | 0x0, 0x07, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), | ||
55 | /* -77.25dB to 12dB */ | ||
56 | 0x08, 0x7f, TLV_DB_SCALE_ITEM(-7725, 75, 0) | ||
57 | ); | ||
58 | |||
59 | static const DECLARE_TLV_DB_SCALE(da7219_dac_ng_threshold_tlv, -10200, 600, 0); | ||
60 | static const DECLARE_TLV_DB_SCALE(da7219_hp_gain_tlv, -5700, 100, 0); | ||
61 | |||
62 | /* Input Enums */ | ||
63 | static const char * const da7219_alc_attack_rate_txt[] = { | ||
64 | "7.33/fs", "14.66/fs", "29.32/fs", "58.64/fs", "117.3/fs", "234.6/fs", | ||
65 | "469.1/fs", "938.2/fs", "1876/fs", "3753/fs", "7506/fs", "15012/fs", | ||
66 | "30024/fs" | ||
67 | }; | ||
68 | |||
69 | static const struct soc_enum da7219_alc_attack_rate = | ||
70 | SOC_ENUM_SINGLE(DA7219_ALC_CTRL2, DA7219_ALC_ATTACK_SHIFT, | ||
71 | DA7219_ALC_ATTACK_MAX, da7219_alc_attack_rate_txt); | ||
72 | |||
73 | static const char * const da7219_alc_release_rate_txt[] = { | ||
74 | "28.66/fs", "57.33/fs", "114.6/fs", "229.3/fs", "458.6/fs", "917.1/fs", | ||
75 | "1834/fs", "3668/fs", "7337/fs", "14674/fs", "29348/fs" | ||
76 | }; | ||
77 | |||
78 | static const struct soc_enum da7219_alc_release_rate = | ||
79 | SOC_ENUM_SINGLE(DA7219_ALC_CTRL2, DA7219_ALC_RELEASE_SHIFT, | ||
80 | DA7219_ALC_RELEASE_MAX, da7219_alc_release_rate_txt); | ||
81 | |||
82 | static const char * const da7219_alc_hold_time_txt[] = { | ||
83 | "62/fs", "124/fs", "248/fs", "496/fs", "992/fs", "1984/fs", "3968/fs", | ||
84 | "7936/fs", "15872/fs", "31744/fs", "63488/fs", "126976/fs", | ||
85 | "253952/fs", "507904/fs", "1015808/fs", "2031616/fs" | ||
86 | }; | ||
87 | |||
88 | static const struct soc_enum da7219_alc_hold_time = | ||
89 | SOC_ENUM_SINGLE(DA7219_ALC_CTRL3, DA7219_ALC_HOLD_SHIFT, | ||
90 | DA7219_ALC_HOLD_MAX, da7219_alc_hold_time_txt); | ||
91 | |||
92 | static const char * const da7219_alc_env_rate_txt[] = { | ||
93 | "1/4", "1/16", "1/256", "1/65536" | ||
94 | }; | ||
95 | |||
96 | static const struct soc_enum da7219_alc_env_attack_rate = | ||
97 | SOC_ENUM_SINGLE(DA7219_ALC_CTRL3, DA7219_ALC_INTEG_ATTACK_SHIFT, | ||
98 | DA7219_ALC_INTEG_MAX, da7219_alc_env_rate_txt); | ||
99 | |||
100 | static const struct soc_enum da7219_alc_env_release_rate = | ||
101 | SOC_ENUM_SINGLE(DA7219_ALC_CTRL3, DA7219_ALC_INTEG_RELEASE_SHIFT, | ||
102 | DA7219_ALC_INTEG_MAX, da7219_alc_env_rate_txt); | ||
103 | |||
104 | static const char * const da7219_alc_anticlip_step_txt[] = { | ||
105 | "0.034dB/fs", "0.068dB/fs", "0.136dB/fs", "0.272dB/fs" | ||
106 | }; | ||
107 | |||
108 | static const struct soc_enum da7219_alc_anticlip_step = | ||
109 | SOC_ENUM_SINGLE(DA7219_ALC_ANTICLIP_CTRL, | ||
110 | DA7219_ALC_ANTICLIP_STEP_SHIFT, | ||
111 | DA7219_ALC_ANTICLIP_STEP_MAX, | ||
112 | da7219_alc_anticlip_step_txt); | ||
113 | |||
114 | /* Input/Output Enums */ | ||
115 | static const char * const da7219_gain_ramp_rate_txt[] = { | ||
116 | "Nominal Rate * 8", "Nominal Rate", "Nominal Rate / 8", | ||
117 | "Nominal Rate / 16" | ||
118 | }; | ||
119 | |||
120 | static const struct soc_enum da7219_gain_ramp_rate = | ||
121 | SOC_ENUM_SINGLE(DA7219_GAIN_RAMP_CTRL, DA7219_GAIN_RAMP_RATE_SHIFT, | ||
122 | DA7219_GAIN_RAMP_RATE_MAX, da7219_gain_ramp_rate_txt); | ||
123 | |||
124 | static const char * const da7219_hpf_mode_txt[] = { | ||
125 | "Disabled", "Audio", "Voice" | ||
126 | }; | ||
127 | |||
128 | static const unsigned int da7219_hpf_mode_val[] = { | ||
129 | DA7219_HPF_DISABLED, DA7219_HPF_AUDIO_EN, DA7219_HPF_VOICE_EN, | ||
130 | }; | ||
131 | |||
132 | static const struct soc_enum da7219_adc_hpf_mode = | ||
133 | SOC_VALUE_ENUM_SINGLE(DA7219_ADC_FILTERS1, DA7219_HPF_MODE_SHIFT, | ||
134 | DA7219_HPF_MODE_MASK, DA7219_HPF_MODE_MAX, | ||
135 | da7219_hpf_mode_txt, da7219_hpf_mode_val); | ||
136 | |||
137 | static const struct soc_enum da7219_dac_hpf_mode = | ||
138 | SOC_VALUE_ENUM_SINGLE(DA7219_DAC_FILTERS1, DA7219_HPF_MODE_SHIFT, | ||
139 | DA7219_HPF_MODE_MASK, DA7219_HPF_MODE_MAX, | ||
140 | da7219_hpf_mode_txt, da7219_hpf_mode_val); | ||
141 | |||
142 | static const char * const da7219_audio_hpf_corner_txt[] = { | ||
143 | "2Hz", "4Hz", "8Hz", "16Hz" | ||
144 | }; | ||
145 | |||
146 | static const struct soc_enum da7219_adc_audio_hpf_corner = | ||
147 | SOC_ENUM_SINGLE(DA7219_ADC_FILTERS1, | ||
148 | DA7219_ADC_AUDIO_HPF_CORNER_SHIFT, | ||
149 | DA7219_AUDIO_HPF_CORNER_MAX, | ||
150 | da7219_audio_hpf_corner_txt); | ||
151 | |||
152 | static const struct soc_enum da7219_dac_audio_hpf_corner = | ||
153 | SOC_ENUM_SINGLE(DA7219_DAC_FILTERS1, | ||
154 | DA7219_DAC_AUDIO_HPF_CORNER_SHIFT, | ||
155 | DA7219_AUDIO_HPF_CORNER_MAX, | ||
156 | da7219_audio_hpf_corner_txt); | ||
157 | |||
158 | static const char * const da7219_voice_hpf_corner_txt[] = { | ||
159 | "2.5Hz", "25Hz", "50Hz", "100Hz", "150Hz", "200Hz", "300Hz", "400Hz" | ||
160 | }; | ||
161 | |||
162 | static const struct soc_enum da7219_adc_voice_hpf_corner = | ||
163 | SOC_ENUM_SINGLE(DA7219_ADC_FILTERS1, | ||
164 | DA7219_ADC_VOICE_HPF_CORNER_SHIFT, | ||
165 | DA7219_VOICE_HPF_CORNER_MAX, | ||
166 | da7219_voice_hpf_corner_txt); | ||
167 | |||
168 | static const struct soc_enum da7219_dac_voice_hpf_corner = | ||
169 | SOC_ENUM_SINGLE(DA7219_DAC_FILTERS1, | ||
170 | DA7219_DAC_VOICE_HPF_CORNER_SHIFT, | ||
171 | DA7219_VOICE_HPF_CORNER_MAX, | ||
172 | da7219_voice_hpf_corner_txt); | ||
173 | |||
174 | static const char * const da7219_tonegen_dtmf_key_txt[] = { | ||
175 | "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", | ||
176 | "*", "#" | ||
177 | }; | ||
178 | |||
179 | static const struct soc_enum da7219_tonegen_dtmf_key = | ||
180 | SOC_ENUM_SINGLE(DA7219_TONE_GEN_CFG1, DA7219_DTMF_REG_SHIFT, | ||
181 | DA7219_DTMF_REG_MAX, da7219_tonegen_dtmf_key_txt); | ||
182 | |||
183 | static const char * const da7219_tonegen_swg_sel_txt[] = { | ||
184 | "Sum", "SWG1", "SWG2", "SWG1_1-Cos" | ||
185 | }; | ||
186 | |||
187 | static const struct soc_enum da7219_tonegen_swg_sel = | ||
188 | SOC_ENUM_SINGLE(DA7219_TONE_GEN_CFG2, DA7219_SWG_SEL_SHIFT, | ||
189 | DA7219_SWG_SEL_MAX, da7219_tonegen_swg_sel_txt); | ||
190 | |||
191 | /* Output Enums */ | ||
192 | static const char * const da7219_dac_softmute_rate_txt[] = { | ||
193 | "1 Sample", "2 Samples", "4 Samples", "8 Samples", "16 Samples", | ||
194 | "32 Samples", "64 Samples" | ||
195 | }; | ||
196 | |||
197 | static const struct soc_enum da7219_dac_softmute_rate = | ||
198 | SOC_ENUM_SINGLE(DA7219_DAC_FILTERS5, DA7219_DAC_SOFTMUTE_RATE_SHIFT, | ||
199 | DA7219_DAC_SOFTMUTE_RATE_MAX, | ||
200 | da7219_dac_softmute_rate_txt); | ||
201 | |||
202 | static const char * const da7219_dac_ng_setup_time_txt[] = { | ||
203 | "256 Samples", "512 Samples", "1024 Samples", "2048 Samples" | ||
204 | }; | ||
205 | |||
206 | static const struct soc_enum da7219_dac_ng_setup_time = | ||
207 | SOC_ENUM_SINGLE(DA7219_DAC_NG_SETUP_TIME, | ||
208 | DA7219_DAC_NG_SETUP_TIME_SHIFT, | ||
209 | DA7219_DAC_NG_SETUP_TIME_MAX, | ||
210 | da7219_dac_ng_setup_time_txt); | ||
211 | |||
212 | static const char * const da7219_dac_ng_rampup_txt[] = { | ||
213 | "0.22ms/dB", "0.0138ms/dB" | ||
214 | }; | ||
215 | |||
216 | static const struct soc_enum da7219_dac_ng_rampup_rate = | ||
217 | SOC_ENUM_SINGLE(DA7219_DAC_NG_SETUP_TIME, | ||
218 | DA7219_DAC_NG_RAMPUP_RATE_SHIFT, | ||
219 | DA7219_DAC_NG_RAMP_RATE_MAX, | ||
220 | da7219_dac_ng_rampup_txt); | ||
221 | |||
222 | static const char * const da7219_dac_ng_rampdown_txt[] = { | ||
223 | "0.88ms/dB", "14.08ms/dB" | ||
224 | }; | ||
225 | |||
226 | static const struct soc_enum da7219_dac_ng_rampdown_rate = | ||
227 | SOC_ENUM_SINGLE(DA7219_DAC_NG_SETUP_TIME, | ||
228 | DA7219_DAC_NG_RAMPDN_RATE_SHIFT, | ||
229 | DA7219_DAC_NG_RAMP_RATE_MAX, | ||
230 | da7219_dac_ng_rampdown_txt); | ||
231 | |||
232 | |||
233 | static const char * const da7219_cp_track_mode_txt[] = { | ||
234 | "Largest Volume", "DAC Volume", "Signal Magnitude" | ||
235 | }; | ||
236 | |||
237 | static const unsigned int da7219_cp_track_mode_val[] = { | ||
238 | DA7219_CP_MCHANGE_LARGEST_VOL, DA7219_CP_MCHANGE_DAC_VOL, | ||
239 | DA7219_CP_MCHANGE_SIG_MAG | ||
240 | }; | ||
241 | |||
242 | static const struct soc_enum da7219_cp_track_mode = | ||
243 | SOC_VALUE_ENUM_SINGLE(DA7219_CP_CTRL, DA7219_CP_MCHANGE_SHIFT, | ||
244 | DA7219_CP_MCHANGE_REL_MASK, DA7219_CP_MCHANGE_MAX, | ||
245 | da7219_cp_track_mode_txt, | ||
246 | da7219_cp_track_mode_val); | ||
247 | |||
248 | |||
249 | /* | ||
250 | * Control Functions | ||
251 | */ | ||
252 | |||
253 | /* Locked Kcontrol calls */ | ||
254 | static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol, | ||
255 | struct snd_ctl_elem_value *ucontrol) | ||
256 | { | ||
257 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
258 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
259 | int ret; | ||
260 | |||
261 | mutex_lock(&da7219->lock); | ||
262 | ret = snd_soc_get_volsw(kcontrol, ucontrol); | ||
263 | mutex_unlock(&da7219->lock); | ||
264 | |||
265 | return ret; | ||
266 | } | ||
267 | |||
268 | static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol, | ||
269 | struct snd_ctl_elem_value *ucontrol) | ||
270 | { | ||
271 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
272 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
273 | int ret; | ||
274 | |||
275 | mutex_lock(&da7219->lock); | ||
276 | ret = snd_soc_put_volsw(kcontrol, ucontrol); | ||
277 | mutex_unlock(&da7219->lock); | ||
278 | |||
279 | return ret; | ||
280 | } | ||
281 | |||
282 | static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol, | ||
283 | struct snd_ctl_elem_value *ucontrol) | ||
284 | { | ||
285 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
286 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
287 | int ret; | ||
288 | |||
289 | mutex_lock(&da7219->lock); | ||
290 | ret = snd_soc_get_enum_double(kcontrol, ucontrol); | ||
291 | mutex_unlock(&da7219->lock); | ||
292 | |||
293 | return ret; | ||
294 | } | ||
295 | |||
296 | static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol, | ||
297 | struct snd_ctl_elem_value *ucontrol) | ||
298 | { | ||
299 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
300 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
301 | int ret; | ||
302 | |||
303 | mutex_lock(&da7219->lock); | ||
304 | ret = snd_soc_put_enum_double(kcontrol, ucontrol); | ||
305 | mutex_unlock(&da7219->lock); | ||
306 | |||
307 | return ret; | ||
308 | } | ||
309 | |||
310 | /* ALC */ | ||
311 | static void da7219_alc_calib(struct snd_soc_codec *codec) | ||
312 | { | ||
313 | u8 mic_ctrl, mixin_ctrl, adc_ctrl, calib_ctrl; | ||
314 | |||
315 | /* Save current state of mic control register */ | ||
316 | mic_ctrl = snd_soc_read(codec, DA7219_MIC_1_CTRL); | ||
317 | |||
318 | /* Save current state of input mixer control register */ | ||
319 | mixin_ctrl = snd_soc_read(codec, DA7219_MIXIN_L_CTRL); | ||
320 | |||
321 | /* Save current state of input ADC control register */ | ||
322 | adc_ctrl = snd_soc_read(codec, DA7219_ADC_L_CTRL); | ||
323 | |||
324 | /* Enable then Mute MIC PGAs */ | ||
325 | snd_soc_update_bits(codec, DA7219_MIC_1_CTRL, DA7219_MIC_1_AMP_EN_MASK, | ||
326 | DA7219_MIC_1_AMP_EN_MASK); | ||
327 | snd_soc_update_bits(codec, DA7219_MIC_1_CTRL, | ||
328 | DA7219_MIC_1_AMP_MUTE_EN_MASK, | ||
329 | DA7219_MIC_1_AMP_MUTE_EN_MASK); | ||
330 | |||
331 | /* Enable input mixers unmuted */ | ||
332 | snd_soc_update_bits(codec, DA7219_MIXIN_L_CTRL, | ||
333 | DA7219_MIXIN_L_AMP_EN_MASK | | ||
334 | DA7219_MIXIN_L_AMP_MUTE_EN_MASK, | ||
335 | DA7219_MIXIN_L_AMP_EN_MASK); | ||
336 | |||
337 | /* Enable input filters unmuted */ | ||
338 | snd_soc_update_bits(codec, DA7219_ADC_L_CTRL, | ||
339 | DA7219_ADC_L_MUTE_EN_MASK | DA7219_ADC_L_EN_MASK, | ||
340 | DA7219_ADC_L_EN_MASK); | ||
341 | |||
342 | /* Perform auto calibration */ | ||
343 | snd_soc_update_bits(codec, DA7219_ALC_CTRL1, | ||
344 | DA7219_ALC_AUTO_CALIB_EN_MASK, | ||
345 | DA7219_ALC_AUTO_CALIB_EN_MASK); | ||
346 | do { | ||
347 | calib_ctrl = snd_soc_read(codec, DA7219_ALC_CTRL1); | ||
348 | } while (calib_ctrl & DA7219_ALC_AUTO_CALIB_EN_MASK); | ||
349 | |||
350 | /* If auto calibration fails, disable DC offset, hybrid ALC */ | ||
351 | if (calib_ctrl & DA7219_ALC_CALIB_OVERFLOW_MASK) { | ||
352 | dev_warn(codec->dev, | ||
353 | "ALC auto calibration failed with overflow\n"); | ||
354 | snd_soc_update_bits(codec, DA7219_ALC_CTRL1, | ||
355 | DA7219_ALC_OFFSET_EN_MASK | | ||
356 | DA7219_ALC_SYNC_MODE_MASK, 0); | ||
357 | } else { | ||
358 | /* Enable DC offset cancellation, hybrid mode */ | ||
359 | snd_soc_update_bits(codec, DA7219_ALC_CTRL1, | ||
360 | DA7219_ALC_OFFSET_EN_MASK | | ||
361 | DA7219_ALC_SYNC_MODE_MASK, | ||
362 | DA7219_ALC_OFFSET_EN_MASK | | ||
363 | DA7219_ALC_SYNC_MODE_MASK); | ||
364 | } | ||
365 | |||
366 | /* Restore input filter control register to original state */ | ||
367 | snd_soc_write(codec, DA7219_ADC_L_CTRL, adc_ctrl); | ||
368 | |||
369 | /* Restore input mixer control registers to original state */ | ||
370 | snd_soc_write(codec, DA7219_MIXIN_L_CTRL, mixin_ctrl); | ||
371 | |||
372 | /* Restore MIC control registers to original states */ | ||
373 | snd_soc_write(codec, DA7219_MIC_1_CTRL, mic_ctrl); | ||
374 | } | ||
375 | |||
376 | static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, | ||
377 | struct snd_ctl_elem_value *ucontrol) | ||
378 | { | ||
379 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
380 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
381 | int ret; | ||
382 | |||
383 | ret = snd_soc_put_volsw(kcontrol, ucontrol); | ||
384 | |||
385 | /* | ||
386 | * If ALC in operation and value of control has been updated, | ||
387 | * make sure calibrated offsets are updated. | ||
388 | */ | ||
389 | if ((ret == 1) && (da7219->alc_en)) | ||
390 | da7219_alc_calib(codec); | ||
391 | |||
392 | return ret; | ||
393 | } | ||
394 | |||
395 | static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol, | ||
396 | struct snd_ctl_elem_value *ucontrol) | ||
397 | { | ||
398 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
399 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
400 | |||
401 | |||
402 | /* Force ALC offset calibration if enabling ALC */ | ||
403 | if ((ucontrol->value.integer.value[0]) && (!da7219->alc_en)) { | ||
404 | da7219_alc_calib(codec); | ||
405 | da7219->alc_en = true; | ||
406 | } else { | ||
407 | da7219->alc_en = false; | ||
408 | } | ||
409 | |||
410 | return snd_soc_put_volsw(kcontrol, ucontrol); | ||
411 | } | ||
412 | |||
413 | /* ToneGen */ | ||
414 | static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol, | ||
415 | struct snd_ctl_elem_value *ucontrol) | ||
416 | { | ||
417 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
418 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
419 | struct soc_mixer_control *mixer_ctrl = | ||
420 | (struct soc_mixer_control *) kcontrol->private_value; | ||
421 | unsigned int reg = mixer_ctrl->reg; | ||
422 | u16 val; | ||
423 | int ret; | ||
424 | |||
425 | mutex_lock(&da7219->lock); | ||
426 | ret = regmap_raw_read(da7219->regmap, reg, &val, sizeof(val)); | ||
427 | mutex_unlock(&da7219->lock); | ||
428 | |||
429 | if (ret) | ||
430 | return ret; | ||
431 | |||
432 | /* | ||
433 | * Frequency value spans two 8-bit registers, lower then upper byte. | ||
434 | * Therefore we need to convert to host endianness here. | ||
435 | */ | ||
436 | ucontrol->value.integer.value[0] = le16_to_cpu(val); | ||
437 | |||
438 | return 0; | ||
439 | } | ||
440 | |||
441 | static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol, | ||
442 | struct snd_ctl_elem_value *ucontrol) | ||
443 | { | ||
444 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
445 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
446 | struct soc_mixer_control *mixer_ctrl = | ||
447 | (struct soc_mixer_control *) kcontrol->private_value; | ||
448 | unsigned int reg = mixer_ctrl->reg; | ||
449 | u16 val; | ||
450 | int ret; | ||
451 | |||
452 | /* | ||
453 | * Frequency value spans two 8-bit registers, lower then upper byte. | ||
454 | * Therefore we need to convert to little endian here to align with | ||
455 | * HW registers. | ||
456 | */ | ||
457 | val = cpu_to_le16(ucontrol->value.integer.value[0]); | ||
458 | |||
459 | mutex_lock(&da7219->lock); | ||
460 | ret = regmap_raw_write(da7219->regmap, reg, &val, sizeof(val)); | ||
461 | mutex_unlock(&da7219->lock); | ||
462 | |||
463 | return ret; | ||
464 | } | ||
465 | |||
466 | |||
467 | /* | ||
468 | * KControls | ||
469 | */ | ||
470 | |||
471 | static const struct snd_kcontrol_new da7219_snd_controls[] = { | ||
472 | /* Mics */ | ||
473 | SOC_SINGLE_TLV("Mic Volume", DA7219_MIC_1_GAIN, | ||
474 | DA7219_MIC_1_AMP_GAIN_SHIFT, DA7219_MIC_1_AMP_GAIN_MAX, | ||
475 | DA7219_NO_INVERT, da7219_mic_gain_tlv), | ||
476 | SOC_SINGLE("Mic Switch", DA7219_MIC_1_CTRL, | ||
477 | DA7219_MIC_1_AMP_MUTE_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
478 | DA7219_INVERT), | ||
479 | |||
480 | /* Mixer Input */ | ||
481 | SOC_SINGLE_EXT_TLV("Mixin Volume", DA7219_MIXIN_L_GAIN, | ||
482 | DA7219_MIXIN_L_AMP_GAIN_SHIFT, | ||
483 | DA7219_MIXIN_L_AMP_GAIN_MAX, DA7219_NO_INVERT, | ||
484 | snd_soc_get_volsw, da7219_mixin_gain_put, | ||
485 | da7219_mixin_gain_tlv), | ||
486 | SOC_SINGLE("Mixin Switch", DA7219_MIXIN_L_CTRL, | ||
487 | DA7219_MIXIN_L_AMP_MUTE_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
488 | DA7219_INVERT), | ||
489 | SOC_SINGLE("Mixin Gain Ramp Switch", DA7219_MIXIN_L_CTRL, | ||
490 | DA7219_MIXIN_L_AMP_RAMP_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
491 | DA7219_NO_INVERT), | ||
492 | SOC_SINGLE("Mixin ZC Gain Switch", DA7219_MIXIN_L_CTRL, | ||
493 | DA7219_MIXIN_L_AMP_ZC_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
494 | DA7219_NO_INVERT), | ||
495 | |||
496 | /* ADC */ | ||
497 | SOC_SINGLE_TLV("Capture Digital Volume", DA7219_ADC_L_GAIN, | ||
498 | DA7219_ADC_L_DIGITAL_GAIN_SHIFT, | ||
499 | DA7219_ADC_L_DIGITAL_GAIN_MAX, DA7219_NO_INVERT, | ||
500 | da7219_adc_dig_gain_tlv), | ||
501 | SOC_SINGLE("Capture Digital Switch", DA7219_ADC_L_CTRL, | ||
502 | DA7219_ADC_L_MUTE_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
503 | DA7219_INVERT), | ||
504 | SOC_SINGLE("Capture Digital Gain Ramp Switch", DA7219_ADC_L_CTRL, | ||
505 | DA7219_ADC_L_RAMP_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
506 | DA7219_NO_INVERT), | ||
507 | |||
508 | /* ALC */ | ||
509 | SOC_ENUM("ALC Attack Rate", da7219_alc_attack_rate), | ||
510 | SOC_ENUM("ALC Release Rate", da7219_alc_release_rate), | ||
511 | SOC_ENUM("ALC Hold Time", da7219_alc_hold_time), | ||
512 | SOC_ENUM("ALC Envelope Attack Rate", da7219_alc_env_attack_rate), | ||
513 | SOC_ENUM("ALC Envelope Release Rate", da7219_alc_env_release_rate), | ||
514 | SOC_SINGLE_TLV("ALC Noise Threshold", DA7219_ALC_NOISE, | ||
515 | DA7219_ALC_NOISE_SHIFT, DA7219_ALC_THRESHOLD_MAX, | ||
516 | DA7219_INVERT, da7219_alc_threshold_tlv), | ||
517 | SOC_SINGLE_TLV("ALC Min Threshold", DA7219_ALC_TARGET_MIN, | ||
518 | DA7219_ALC_THRESHOLD_MIN_SHIFT, DA7219_ALC_THRESHOLD_MAX, | ||
519 | DA7219_INVERT, da7219_alc_threshold_tlv), | ||
520 | SOC_SINGLE_TLV("ALC Max Threshold", DA7219_ALC_TARGET_MAX, | ||
521 | DA7219_ALC_THRESHOLD_MAX_SHIFT, DA7219_ALC_THRESHOLD_MAX, | ||
522 | DA7219_INVERT, da7219_alc_threshold_tlv), | ||
523 | SOC_SINGLE_TLV("ALC Max Attenuation", DA7219_ALC_GAIN_LIMITS, | ||
524 | DA7219_ALC_ATTEN_MAX_SHIFT, DA7219_ALC_ATTEN_GAIN_MAX, | ||
525 | DA7219_NO_INVERT, da7219_alc_gain_tlv), | ||
526 | SOC_SINGLE_TLV("ALC Max Volume", DA7219_ALC_GAIN_LIMITS, | ||
527 | DA7219_ALC_GAIN_MAX_SHIFT, DA7219_ALC_ATTEN_GAIN_MAX, | ||
528 | DA7219_NO_INVERT, da7219_alc_gain_tlv), | ||
529 | SOC_SINGLE_RANGE_TLV("ALC Min Analog Volume", DA7219_ALC_ANA_GAIN_LIMITS, | ||
530 | DA7219_ALC_ANA_GAIN_MIN_SHIFT, | ||
531 | DA7219_ALC_ANA_GAIN_MIN, DA7219_ALC_ANA_GAIN_MAX, | ||
532 | DA7219_NO_INVERT, da7219_alc_ana_gain_tlv), | ||
533 | SOC_SINGLE_RANGE_TLV("ALC Max Analog Volume", DA7219_ALC_ANA_GAIN_LIMITS, | ||
534 | DA7219_ALC_ANA_GAIN_MAX_SHIFT, | ||
535 | DA7219_ALC_ANA_GAIN_MIN, DA7219_ALC_ANA_GAIN_MAX, | ||
536 | DA7219_NO_INVERT, da7219_alc_ana_gain_tlv), | ||
537 | SOC_ENUM("ALC Anticlip Step", da7219_alc_anticlip_step), | ||
538 | SOC_SINGLE("ALC Anticlip Switch", DA7219_ALC_ANTICLIP_CTRL, | ||
539 | DA7219_ALC_ANTIPCLIP_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
540 | DA7219_NO_INVERT), | ||
541 | SOC_SINGLE_EXT("ALC Switch", DA7219_ALC_CTRL1, DA7219_ALC_EN_SHIFT, | ||
542 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT, | ||
543 | snd_soc_get_volsw, da7219_alc_sw_put), | ||
544 | |||
545 | /* Input High-Pass Filters */ | ||
546 | SOC_ENUM("ADC HPF Mode", da7219_adc_hpf_mode), | ||
547 | SOC_ENUM("ADC HPF Corner Audio", da7219_adc_audio_hpf_corner), | ||
548 | SOC_ENUM("ADC HPF Corner Voice", da7219_adc_voice_hpf_corner), | ||
549 | |||
550 | /* Sidetone Filter */ | ||
551 | SOC_SINGLE_TLV("Sidetone Volume", DA7219_SIDETONE_GAIN, | ||
552 | DA7219_SIDETONE_GAIN_SHIFT, DA7219_SIDETONE_GAIN_MAX, | ||
553 | DA7219_NO_INVERT, da7219_sidetone_gain_tlv), | ||
554 | SOC_SINGLE("Sidetone Switch", DA7219_SIDETONE_CTRL, | ||
555 | DA7219_SIDETONE_MUTE_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
556 | DA7219_INVERT), | ||
557 | |||
558 | /* Tone Generator */ | ||
559 | SOC_SINGLE_EXT_TLV("ToneGen Volume", DA7219_TONE_GEN_CFG2, | ||
560 | DA7219_TONE_GEN_GAIN_SHIFT, DA7219_TONE_GEN_GAIN_MAX, | ||
561 | DA7219_NO_INVERT, da7219_volsw_locked_get, | ||
562 | da7219_volsw_locked_put, da7219_tonegen_gain_tlv), | ||
563 | SOC_ENUM_EXT("ToneGen DTMF Key", da7219_tonegen_dtmf_key, | ||
564 | da7219_enum_locked_get, da7219_enum_locked_put), | ||
565 | SOC_SINGLE_EXT("ToneGen DTMF Switch", DA7219_TONE_GEN_CFG1, | ||
566 | DA7219_DTMF_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
567 | DA7219_NO_INVERT, da7219_volsw_locked_get, | ||
568 | da7219_volsw_locked_put), | ||
569 | SOC_ENUM_EXT("ToneGen Sinewave Gen Type", da7219_tonegen_swg_sel, | ||
570 | da7219_enum_locked_get, da7219_enum_locked_put), | ||
571 | SOC_SINGLE_EXT("ToneGen Sinewave1 Freq", DA7219_TONE_GEN_FREQ1_L, | ||
572 | DA7219_FREQ1_L_SHIFT, DA7219_FREQ_MAX, DA7219_NO_INVERT, | ||
573 | da7219_tonegen_freq_get, da7219_tonegen_freq_put), | ||
574 | SOC_SINGLE_EXT("ToneGen Sinewave2 Freq", DA7219_TONE_GEN_FREQ2_L, | ||
575 | DA7219_FREQ2_L_SHIFT, DA7219_FREQ_MAX, DA7219_NO_INVERT, | ||
576 | da7219_tonegen_freq_get, da7219_tonegen_freq_put), | ||
577 | SOC_SINGLE_EXT("ToneGen On Time", DA7219_TONE_GEN_ON_PER, | ||
578 | DA7219_BEEP_ON_PER_SHIFT, DA7219_BEEP_ON_OFF_MAX, | ||
579 | DA7219_NO_INVERT, da7219_volsw_locked_get, | ||
580 | da7219_volsw_locked_put), | ||
581 | SOC_SINGLE("ToneGen Off Time", DA7219_TONE_GEN_OFF_PER, | ||
582 | DA7219_BEEP_OFF_PER_SHIFT, DA7219_BEEP_ON_OFF_MAX, | ||
583 | DA7219_NO_INVERT), | ||
584 | |||
585 | /* Gain ramping */ | ||
586 | SOC_ENUM("Gain Ramp Rate", da7219_gain_ramp_rate), | ||
587 | |||
588 | /* DAC High-Pass Filter */ | ||
589 | SOC_ENUM_EXT("DAC HPF Mode", da7219_dac_hpf_mode, | ||
590 | da7219_enum_locked_get, da7219_enum_locked_put), | ||
591 | SOC_ENUM("DAC HPF Corner Audio", da7219_dac_audio_hpf_corner), | ||
592 | SOC_ENUM("DAC HPF Corner Voice", da7219_dac_voice_hpf_corner), | ||
593 | |||
594 | /* DAC 5-Band Equaliser */ | ||
595 | SOC_SINGLE_TLV("DAC EQ Band1 Volume", DA7219_DAC_FILTERS2, | ||
596 | DA7219_DAC_EQ_BAND1_SHIFT, DA7219_DAC_EQ_BAND_MAX, | ||
597 | DA7219_NO_INVERT, da7219_dac_eq_band_tlv), | ||
598 | SOC_SINGLE_TLV("DAC EQ Band2 Volume", DA7219_DAC_FILTERS2, | ||
599 | DA7219_DAC_EQ_BAND2_SHIFT, DA7219_DAC_EQ_BAND_MAX, | ||
600 | DA7219_NO_INVERT, da7219_dac_eq_band_tlv), | ||
601 | SOC_SINGLE_TLV("DAC EQ Band3 Volume", DA7219_DAC_FILTERS3, | ||
602 | DA7219_DAC_EQ_BAND3_SHIFT, DA7219_DAC_EQ_BAND_MAX, | ||
603 | DA7219_NO_INVERT, da7219_dac_eq_band_tlv), | ||
604 | SOC_SINGLE_TLV("DAC EQ Band4 Volume", DA7219_DAC_FILTERS3, | ||
605 | DA7219_DAC_EQ_BAND4_SHIFT, DA7219_DAC_EQ_BAND_MAX, | ||
606 | DA7219_NO_INVERT, da7219_dac_eq_band_tlv), | ||
607 | SOC_SINGLE_TLV("DAC EQ Band5 Volume", DA7219_DAC_FILTERS4, | ||
608 | DA7219_DAC_EQ_BAND5_SHIFT, DA7219_DAC_EQ_BAND_MAX, | ||
609 | DA7219_NO_INVERT, da7219_dac_eq_band_tlv), | ||
610 | SOC_SINGLE_EXT("DAC EQ Switch", DA7219_DAC_FILTERS4, | ||
611 | DA7219_DAC_EQ_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
612 | DA7219_NO_INVERT, da7219_volsw_locked_get, | ||
613 | da7219_volsw_locked_put), | ||
614 | |||
615 | /* DAC Softmute */ | ||
616 | SOC_ENUM("DAC Soft Mute Rate", da7219_dac_softmute_rate), | ||
617 | SOC_SINGLE_EXT("DAC Soft Mute Switch", DA7219_DAC_FILTERS5, | ||
618 | DA7219_DAC_SOFTMUTE_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
619 | DA7219_NO_INVERT, da7219_volsw_locked_get, | ||
620 | da7219_volsw_locked_put), | ||
621 | |||
622 | /* DAC Noise Gate */ | ||
623 | SOC_ENUM("DAC NG Setup Time", da7219_dac_ng_setup_time), | ||
624 | SOC_ENUM("DAC NG Rampup Rate", da7219_dac_ng_rampup_rate), | ||
625 | SOC_ENUM("DAC NG Rampdown Rate", da7219_dac_ng_rampdown_rate), | ||
626 | SOC_SINGLE_TLV("DAC NG Off Threshold", DA7219_DAC_NG_OFF_THRESH, | ||
627 | DA7219_DAC_NG_OFF_THRESHOLD_SHIFT, | ||
628 | DA7219_DAC_NG_THRESHOLD_MAX, DA7219_NO_INVERT, | ||
629 | da7219_dac_ng_threshold_tlv), | ||
630 | SOC_SINGLE_TLV("DAC NG On Threshold", DA7219_DAC_NG_ON_THRESH, | ||
631 | DA7219_DAC_NG_ON_THRESHOLD_SHIFT, | ||
632 | DA7219_DAC_NG_THRESHOLD_MAX, DA7219_NO_INVERT, | ||
633 | da7219_dac_ng_threshold_tlv), | ||
634 | SOC_SINGLE("DAC NG Switch", DA7219_DAC_NG_CTRL, DA7219_DAC_NG_EN_SHIFT, | ||
635 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT), | ||
636 | |||
637 | /* DACs */ | ||
638 | SOC_DOUBLE_R_EXT_TLV("Playback Digital Volume", DA7219_DAC_L_GAIN, | ||
639 | DA7219_DAC_R_GAIN, DA7219_DAC_L_DIGITAL_GAIN_SHIFT, | ||
640 | DA7219_DAC_DIGITAL_GAIN_MAX, DA7219_NO_INVERT, | ||
641 | da7219_volsw_locked_get, da7219_volsw_locked_put, | ||
642 | da7219_dac_dig_gain_tlv), | ||
643 | SOC_DOUBLE_R_EXT("Playback Digital Switch", DA7219_DAC_L_CTRL, | ||
644 | DA7219_DAC_R_CTRL, DA7219_DAC_L_MUTE_EN_SHIFT, | ||
645 | DA7219_SWITCH_EN_MAX, DA7219_INVERT, | ||
646 | da7219_volsw_locked_get, da7219_volsw_locked_put), | ||
647 | SOC_DOUBLE_R("Playback Digital Gain Ramp Switch", DA7219_DAC_L_CTRL, | ||
648 | DA7219_DAC_R_CTRL, DA7219_DAC_L_RAMP_EN_SHIFT, | ||
649 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT), | ||
650 | |||
651 | /* CP */ | ||
652 | SOC_ENUM("Charge Pump Track Mode", da7219_cp_track_mode), | ||
653 | SOC_SINGLE("Charge Pump Threshold", DA7219_CP_VOL_THRESHOLD1, | ||
654 | DA7219_CP_THRESH_VDD2_SHIFT, DA7219_CP_THRESH_VDD2_MAX, | ||
655 | DA7219_NO_INVERT), | ||
656 | |||
657 | /* Headphones */ | ||
658 | SOC_DOUBLE_R_EXT_TLV("Headphone Volume", DA7219_HP_L_GAIN, | ||
659 | DA7219_HP_R_GAIN, DA7219_HP_L_AMP_GAIN_SHIFT, | ||
660 | DA7219_HP_AMP_GAIN_MAX, DA7219_NO_INVERT, | ||
661 | da7219_volsw_locked_get, da7219_volsw_locked_put, | ||
662 | da7219_hp_gain_tlv), | ||
663 | SOC_DOUBLE_R_EXT("Headphone Switch", DA7219_HP_L_CTRL, DA7219_HP_R_CTRL, | ||
664 | DA7219_HP_L_AMP_MUTE_EN_SHIFT, DA7219_SWITCH_EN_MAX, | ||
665 | DA7219_INVERT, da7219_volsw_locked_get, | ||
666 | da7219_volsw_locked_put), | ||
667 | SOC_DOUBLE_R("Headphone Gain Ramp Switch", DA7219_HP_L_CTRL, | ||
668 | DA7219_HP_R_CTRL, DA7219_HP_L_AMP_RAMP_EN_SHIFT, | ||
669 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT), | ||
670 | SOC_DOUBLE_R("Headphone ZC Gain Switch", DA7219_HP_L_CTRL, | ||
671 | DA7219_HP_R_CTRL, DA7219_HP_L_AMP_ZC_EN_SHIFT, | ||
672 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT), | ||
673 | }; | ||
674 | |||
675 | |||
676 | /* | ||
677 | * DAPM Mux Controls | ||
678 | */ | ||
679 | |||
680 | static const char * const da7219_out_sel_txt[] = { | ||
681 | "ADC", "Tone Generator", "DAIL", "DAIR" | ||
682 | }; | ||
683 | |||
684 | static const struct soc_enum da7219_out_dail_sel = | ||
685 | SOC_ENUM_SINGLE(DA7219_DIG_ROUTING_DAI, | ||
686 | DA7219_DAI_L_SRC_SHIFT, | ||
687 | DA7219_OUT_SRC_MAX, | ||
688 | da7219_out_sel_txt); | ||
689 | |||
690 | static const struct snd_kcontrol_new da7219_out_dail_sel_mux = | ||
691 | SOC_DAPM_ENUM("Out DAIL Mux", da7219_out_dail_sel); | ||
692 | |||
693 | static const struct soc_enum da7219_out_dair_sel = | ||
694 | SOC_ENUM_SINGLE(DA7219_DIG_ROUTING_DAI, | ||
695 | DA7219_DAI_R_SRC_SHIFT, | ||
696 | DA7219_OUT_SRC_MAX, | ||
697 | da7219_out_sel_txt); | ||
698 | |||
699 | static const struct snd_kcontrol_new da7219_out_dair_sel_mux = | ||
700 | SOC_DAPM_ENUM("Out DAIR Mux", da7219_out_dair_sel); | ||
701 | |||
702 | static const struct soc_enum da7219_out_dacl_sel = | ||
703 | SOC_ENUM_SINGLE(DA7219_DIG_ROUTING_DAC, | ||
704 | DA7219_DAC_L_SRC_SHIFT, | ||
705 | DA7219_OUT_SRC_MAX, | ||
706 | da7219_out_sel_txt); | ||
707 | |||
708 | static const struct snd_kcontrol_new da7219_out_dacl_sel_mux = | ||
709 | SOC_DAPM_ENUM("Out DACL Mux", da7219_out_dacl_sel); | ||
710 | |||
711 | static const struct soc_enum da7219_out_dacr_sel = | ||
712 | SOC_ENUM_SINGLE(DA7219_DIG_ROUTING_DAC, | ||
713 | DA7219_DAC_R_SRC_SHIFT, | ||
714 | DA7219_OUT_SRC_MAX, | ||
715 | da7219_out_sel_txt); | ||
716 | |||
717 | static const struct snd_kcontrol_new da7219_out_dacr_sel_mux = | ||
718 | SOC_DAPM_ENUM("Out DACR Mux", da7219_out_dacr_sel); | ||
719 | |||
720 | |||
721 | /* | ||
722 | * DAPM Mixer Controls | ||
723 | */ | ||
724 | |||
725 | static const struct snd_kcontrol_new da7219_mixin_controls[] = { | ||
726 | SOC_DAPM_SINGLE("Mic Switch", DA7219_MIXIN_L_SELECT, | ||
727 | DA7219_MIXIN_L_MIX_SELECT_SHIFT, | ||
728 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT), | ||
729 | }; | ||
730 | |||
731 | static const struct snd_kcontrol_new da7219_mixout_l_controls[] = { | ||
732 | SOC_DAPM_SINGLE("DACL Switch", DA7219_MIXOUT_L_SELECT, | ||
733 | DA7219_MIXOUT_L_MIX_SELECT_SHIFT, | ||
734 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT), | ||
735 | }; | ||
736 | |||
737 | static const struct snd_kcontrol_new da7219_mixout_r_controls[] = { | ||
738 | SOC_DAPM_SINGLE("DACR Switch", DA7219_MIXOUT_R_SELECT, | ||
739 | DA7219_MIXOUT_R_MIX_SELECT_SHIFT, | ||
740 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT), | ||
741 | }; | ||
742 | |||
743 | #define DA7219_DMIX_ST_CTRLS(reg) \ | ||
744 | SOC_DAPM_SINGLE("Out FilterL Switch", reg, \ | ||
745 | DA7219_DMIX_ST_SRC_OUTFILT1L_SHIFT, \ | ||
746 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT), \ | ||
747 | SOC_DAPM_SINGLE("Out FilterR Switch", reg, \ | ||
748 | DA7219_DMIX_ST_SRC_OUTFILT1R_SHIFT, \ | ||
749 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT), \ | ||
750 | SOC_DAPM_SINGLE("Sidetone Switch", reg, \ | ||
751 | DA7219_DMIX_ST_SRC_SIDETONE_SHIFT, \ | ||
752 | DA7219_SWITCH_EN_MAX, DA7219_NO_INVERT) \ | ||
753 | |||
754 | static const struct snd_kcontrol_new da7219_st_out_filtl_mix_controls[] = { | ||
755 | DA7219_DMIX_ST_CTRLS(DA7219_DROUTING_ST_OUTFILT_1L), | ||
756 | }; | ||
757 | |||
758 | static const struct snd_kcontrol_new da7219_st_out_filtr_mix_controls[] = { | ||
759 | DA7219_DMIX_ST_CTRLS(DA7219_DROUTING_ST_OUTFILT_1R), | ||
760 | }; | ||
761 | |||
762 | |||
763 | /* | ||
764 | * DAPM Events | ||
765 | */ | ||
766 | |||
767 | static int da7219_dai_event(struct snd_soc_dapm_widget *w, | ||
768 | struct snd_kcontrol *kcontrol, int event) | ||
769 | { | ||
770 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | ||
771 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
772 | u8 pll_ctrl, pll_status; | ||
773 | int i = 0; | ||
774 | bool srm_lock = false; | ||
775 | |||
776 | switch (event) { | ||
777 | case SND_SOC_DAPM_PRE_PMU: | ||
778 | if (da7219->master) | ||
779 | /* Enable DAI clks for master mode */ | ||
780 | snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, | ||
781 | DA7219_DAI_CLK_EN_MASK, | ||
782 | DA7219_DAI_CLK_EN_MASK); | ||
783 | |||
784 | /* PC synchronised to DAI */ | ||
785 | snd_soc_update_bits(codec, DA7219_PC_COUNT, | ||
786 | DA7219_PC_FREERUN_MASK, 0); | ||
787 | |||
788 | /* Slave mode, if SRM not enabled no need for status checks */ | ||
789 | pll_ctrl = snd_soc_read(codec, DA7219_PLL_CTRL); | ||
790 | if ((pll_ctrl & DA7219_PLL_MODE_MASK) != DA7219_PLL_MODE_SRM) | ||
791 | return 0; | ||
792 | |||
793 | /* Check SRM has locked */ | ||
794 | do { | ||
795 | pll_status = snd_soc_read(codec, DA7219_PLL_SRM_STS); | ||
796 | if (pll_status & DA7219_PLL_SRM_STS_SRM_LOCK) { | ||
797 | srm_lock = true; | ||
798 | } else { | ||
799 | ++i; | ||
800 | msleep(50); | ||
801 | } | ||
802 | } while ((i < DA7219_SRM_CHECK_RETRIES) & (!srm_lock)); | ||
803 | |||
804 | if (!srm_lock) | ||
805 | dev_warn(codec->dev, "SRM failed to lock\n"); | ||
806 | |||
807 | return 0; | ||
808 | case SND_SOC_DAPM_POST_PMD: | ||
809 | /* PC free-running */ | ||
810 | snd_soc_update_bits(codec, DA7219_PC_COUNT, | ||
811 | DA7219_PC_FREERUN_MASK, | ||
812 | DA7219_PC_FREERUN_MASK); | ||
813 | |||
814 | /* Disable DAI clks if in master mode */ | ||
815 | if (da7219->master) | ||
816 | snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, | ||
817 | DA7219_DAI_CLK_EN_MASK, 0); | ||
818 | return 0; | ||
819 | default: | ||
820 | return -EINVAL; | ||
821 | } | ||
822 | } | ||
823 | |||
824 | |||
825 | /* | ||
826 | * DAPM Widgets | ||
827 | */ | ||
828 | |||
829 | static const struct snd_soc_dapm_widget da7219_dapm_widgets[] = { | ||
830 | /* Input Supplies */ | ||
831 | SND_SOC_DAPM_SUPPLY("Mic Bias", DA7219_MICBIAS_CTRL, | ||
832 | DA7219_MICBIAS1_EN_SHIFT, DA7219_NO_INVERT, | ||
833 | NULL, 0), | ||
834 | |||
835 | /* Inputs */ | ||
836 | SND_SOC_DAPM_INPUT("MIC"), | ||
837 | |||
838 | /* Input PGAs */ | ||
839 | SND_SOC_DAPM_PGA("Mic PGA", DA7219_MIC_1_CTRL, | ||
840 | DA7219_MIC_1_AMP_EN_SHIFT, DA7219_NO_INVERT, | ||
841 | NULL, 0), | ||
842 | SND_SOC_DAPM_PGA("Mixin PGA", DA7219_MIXIN_L_CTRL, | ||
843 | DA7219_MIXIN_L_AMP_EN_SHIFT, DA7219_NO_INVERT, | ||
844 | NULL, 0), | ||
845 | |||
846 | /* Input Filters */ | ||
847 | SND_SOC_DAPM_ADC("ADC", NULL, DA7219_ADC_L_CTRL, DA7219_ADC_L_EN_SHIFT, | ||
848 | DA7219_NO_INVERT), | ||
849 | |||
850 | /* Tone Generator */ | ||
851 | SND_SOC_DAPM_SIGGEN("TONE"), | ||
852 | SND_SOC_DAPM_PGA("Tone Generator", DA7219_TONE_GEN_CFG1, | ||
853 | DA7219_START_STOPN_SHIFT, DA7219_NO_INVERT, NULL, 0), | ||
854 | |||
855 | /* Sidetone Input */ | ||
856 | SND_SOC_DAPM_ADC("Sidetone Filter", NULL, DA7219_SIDETONE_CTRL, | ||
857 | DA7219_SIDETONE_EN_SHIFT, DA7219_NO_INVERT), | ||
858 | |||
859 | /* Input Mixer Supply */ | ||
860 | SND_SOC_DAPM_SUPPLY("Mixer In Supply", DA7219_MIXIN_L_CTRL, | ||
861 | DA7219_MIXIN_L_MIX_EN_SHIFT, DA7219_NO_INVERT, | ||
862 | NULL, 0), | ||
863 | |||
864 | /* Input Mixer */ | ||
865 | SND_SOC_DAPM_MIXER("Mixer In", SND_SOC_NOPM, 0, 0, | ||
866 | da7219_mixin_controls, | ||
867 | ARRAY_SIZE(da7219_mixin_controls)), | ||
868 | |||
869 | /* Input Muxes */ | ||
870 | SND_SOC_DAPM_MUX("Out DAIL Mux", SND_SOC_NOPM, 0, 0, | ||
871 | &da7219_out_dail_sel_mux), | ||
872 | SND_SOC_DAPM_MUX("Out DAIR Mux", SND_SOC_NOPM, 0, 0, | ||
873 | &da7219_out_dair_sel_mux), | ||
874 | |||
875 | /* DAI Supply */ | ||
876 | SND_SOC_DAPM_SUPPLY("DAI", DA7219_DAI_CTRL, DA7219_DAI_EN_SHIFT, | ||
877 | DA7219_NO_INVERT, da7219_dai_event, | ||
878 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
879 | |||
880 | /* DAI */ | ||
881 | SND_SOC_DAPM_AIF_OUT("DAIOUT", "Capture", 0, SND_SOC_NOPM, 0, 0), | ||
882 | SND_SOC_DAPM_AIF_IN("DAIIN", "Playback", 0, SND_SOC_NOPM, 0, 0), | ||
883 | |||
884 | /* Output Muxes */ | ||
885 | SND_SOC_DAPM_MUX("Out DACL Mux", SND_SOC_NOPM, 0, 0, | ||
886 | &da7219_out_dacl_sel_mux), | ||
887 | SND_SOC_DAPM_MUX("Out DACR Mux", SND_SOC_NOPM, 0, 0, | ||
888 | &da7219_out_dacr_sel_mux), | ||
889 | |||
890 | /* Output Mixers */ | ||
891 | SND_SOC_DAPM_MIXER("Mixer Out FilterL", SND_SOC_NOPM, 0, 0, | ||
892 | da7219_mixout_l_controls, | ||
893 | ARRAY_SIZE(da7219_mixout_l_controls)), | ||
894 | SND_SOC_DAPM_MIXER("Mixer Out FilterR", SND_SOC_NOPM, 0, 0, | ||
895 | da7219_mixout_r_controls, | ||
896 | ARRAY_SIZE(da7219_mixout_r_controls)), | ||
897 | |||
898 | /* Sidetone Mixers */ | ||
899 | SND_SOC_DAPM_MIXER("ST Mixer Out FilterL", SND_SOC_NOPM, 0, 0, | ||
900 | da7219_st_out_filtl_mix_controls, | ||
901 | ARRAY_SIZE(da7219_st_out_filtl_mix_controls)), | ||
902 | SND_SOC_DAPM_MIXER("ST Mixer Out FilterR", SND_SOC_NOPM, 0, | ||
903 | 0, da7219_st_out_filtr_mix_controls, | ||
904 | ARRAY_SIZE(da7219_st_out_filtr_mix_controls)), | ||
905 | |||
906 | /* DACs */ | ||
907 | SND_SOC_DAPM_DAC("DACL", NULL, DA7219_DAC_L_CTRL, DA7219_DAC_L_EN_SHIFT, | ||
908 | DA7219_NO_INVERT), | ||
909 | SND_SOC_DAPM_DAC("DACR", NULL, DA7219_DAC_R_CTRL, DA7219_DAC_R_EN_SHIFT, | ||
910 | DA7219_NO_INVERT), | ||
911 | |||
912 | /* Output PGAs */ | ||
913 | SND_SOC_DAPM_PGA("Mixout Left PGA", DA7219_MIXOUT_L_CTRL, | ||
914 | DA7219_MIXOUT_L_AMP_EN_SHIFT, DA7219_NO_INVERT, | ||
915 | NULL, 0), | ||
916 | SND_SOC_DAPM_PGA("Mixout Right PGA", DA7219_MIXOUT_R_CTRL, | ||
917 | DA7219_MIXOUT_R_AMP_EN_SHIFT, DA7219_NO_INVERT, | ||
918 | NULL, 0), | ||
919 | SND_SOC_DAPM_PGA("Headphone Left PGA", DA7219_HP_L_CTRL, | ||
920 | DA7219_HP_L_AMP_EN_SHIFT, DA7219_NO_INVERT, NULL, 0), | ||
921 | SND_SOC_DAPM_PGA("Headphone Right PGA", DA7219_HP_R_CTRL, | ||
922 | DA7219_HP_R_AMP_EN_SHIFT, DA7219_NO_INVERT, NULL, 0), | ||
923 | |||
924 | /* Output Supplies */ | ||
925 | SND_SOC_DAPM_SUPPLY("Charge Pump", DA7219_CP_CTRL, DA7219_CP_EN_SHIFT, | ||
926 | DA7219_NO_INVERT, NULL, 0), | ||
927 | |||
928 | /* Outputs */ | ||
929 | SND_SOC_DAPM_OUTPUT("HPL"), | ||
930 | SND_SOC_DAPM_OUTPUT("HPR"), | ||
931 | }; | ||
932 | |||
933 | |||
934 | /* | ||
935 | * DAPM Mux Routes | ||
936 | */ | ||
937 | |||
938 | #define DA7219_OUT_DAI_MUX_ROUTES(name) \ | ||
939 | {name, "ADC", "Mixer In"}, \ | ||
940 | {name, "Tone Generator", "Tone Generator"}, \ | ||
941 | {name, "DAIL", "DAIOUT"}, \ | ||
942 | {name, "DAIR", "DAIOUT"} | ||
943 | |||
944 | #define DA7219_OUT_DAC_MUX_ROUTES(name) \ | ||
945 | {name, "ADC", "Mixer In"}, \ | ||
946 | {name, "Tone Generator", "Tone Generator"}, \ | ||
947 | {name, "DAIL", "DAIIN"}, \ | ||
948 | {name, "DAIR", "DAIIN"} | ||
949 | |||
950 | /* | ||
951 | * DAPM Mixer Routes | ||
952 | */ | ||
953 | |||
954 | #define DA7219_DMIX_ST_ROUTES(name) \ | ||
955 | {name, "Out FilterL Switch", "Mixer Out FilterL"}, \ | ||
956 | {name, "Out FilterR Switch", "Mixer Out FilterR"}, \ | ||
957 | {name, "Sidetone Switch", "Sidetone Filter"} | ||
958 | |||
959 | |||
960 | /* | ||
961 | * DAPM audio route definition | ||
962 | */ | ||
963 | |||
964 | static const struct snd_soc_dapm_route da7219_audio_map[] = { | ||
965 | /* Input paths */ | ||
966 | {"MIC", NULL, "Mic Bias"}, | ||
967 | {"Mic PGA", NULL, "MIC"}, | ||
968 | {"Mixin PGA", NULL, "Mic PGA"}, | ||
969 | {"ADC", NULL, "Mixin PGA"}, | ||
970 | |||
971 | {"Sidetone Filter", NULL, "ADC"}, | ||
972 | {"Mixer In", NULL, "Mixer In Supply"}, | ||
973 | {"Mixer In", "Mic Switch", "ADC"}, | ||
974 | |||
975 | {"Tone Generator", NULL, "TONE"}, | ||
976 | |||
977 | DA7219_OUT_DAI_MUX_ROUTES("Out DAIL Mux"), | ||
978 | DA7219_OUT_DAI_MUX_ROUTES("Out DAIR Mux"), | ||
979 | |||
980 | {"DAIOUT", NULL, "Out DAIL Mux"}, | ||
981 | {"DAIOUT", NULL, "Out DAIR Mux"}, | ||
982 | {"DAIOUT", NULL, "DAI"}, | ||
983 | |||
984 | /* Output paths */ | ||
985 | {"DAIIN", NULL, "DAI"}, | ||
986 | |||
987 | DA7219_OUT_DAC_MUX_ROUTES("Out DACL Mux"), | ||
988 | DA7219_OUT_DAC_MUX_ROUTES("Out DACR Mux"), | ||
989 | |||
990 | {"Mixer Out FilterL", "DACL Switch", "Out DACL Mux"}, | ||
991 | {"Mixer Out FilterR", "DACR Switch", "Out DACR Mux"}, | ||
992 | |||
993 | DA7219_DMIX_ST_ROUTES("ST Mixer Out FilterL"), | ||
994 | DA7219_DMIX_ST_ROUTES("ST Mixer Out FilterR"), | ||
995 | |||
996 | {"DACL", NULL, "ST Mixer Out FilterL"}, | ||
997 | {"DACR", NULL, "ST Mixer Out FilterR"}, | ||
998 | |||
999 | {"Mixout Left PGA", NULL, "DACL"}, | ||
1000 | {"Mixout Right PGA", NULL, "DACR"}, | ||
1001 | |||
1002 | {"Headphone Left PGA", NULL, "Mixout Left PGA"}, | ||
1003 | {"Headphone Right PGA", NULL, "Mixout Right PGA"}, | ||
1004 | |||
1005 | {"HPL", NULL, "Headphone Left PGA"}, | ||
1006 | {"HPR", NULL, "Headphone Right PGA"}, | ||
1007 | |||
1008 | {"HPL", NULL, "Charge Pump"}, | ||
1009 | {"HPR", NULL, "Charge Pump"}, | ||
1010 | }; | ||
1011 | |||
1012 | |||
1013 | /* | ||
1014 | * DAI operations | ||
1015 | */ | ||
1016 | |||
1017 | static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai, | ||
1018 | int clk_id, unsigned int freq, int dir) | ||
1019 | { | ||
1020 | struct snd_soc_codec *codec = codec_dai->codec; | ||
1021 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1022 | int ret = 0; | ||
1023 | |||
1024 | if ((da7219->clk_src == clk_id) && (da7219->mclk_rate == freq)) | ||
1025 | return 0; | ||
1026 | |||
1027 | if (((freq < 2000000) && (freq != 32768)) || (freq > 54000000)) { | ||
1028 | dev_err(codec_dai->dev, "Unsupported MCLK value %d\n", | ||
1029 | freq); | ||
1030 | return -EINVAL; | ||
1031 | } | ||
1032 | |||
1033 | switch (clk_id) { | ||
1034 | case DA7219_CLKSRC_MCLK_SQR: | ||
1035 | snd_soc_update_bits(codec, DA7219_PLL_CTRL, | ||
1036 | DA7219_PLL_MCLK_SQR_EN_MASK, | ||
1037 | DA7219_PLL_MCLK_SQR_EN_MASK); | ||
1038 | break; | ||
1039 | case DA7219_CLKSRC_MCLK: | ||
1040 | snd_soc_update_bits(codec, DA7219_PLL_CTRL, | ||
1041 | DA7219_PLL_MCLK_SQR_EN_MASK, 0); | ||
1042 | break; | ||
1043 | default: | ||
1044 | dev_err(codec_dai->dev, "Unknown clock source %d\n", clk_id); | ||
1045 | return -EINVAL; | ||
1046 | } | ||
1047 | |||
1048 | da7219->clk_src = clk_id; | ||
1049 | |||
1050 | if (da7219->mclk) { | ||
1051 | freq = clk_round_rate(da7219->mclk, freq); | ||
1052 | ret = clk_set_rate(da7219->mclk, freq); | ||
1053 | if (ret) { | ||
1054 | dev_err(codec_dai->dev, "Failed to set clock rate %d\n", | ||
1055 | freq); | ||
1056 | return ret; | ||
1057 | } | ||
1058 | } | ||
1059 | |||
1060 | da7219->mclk_rate = freq; | ||
1061 | |||
1062 | return 0; | ||
1063 | } | ||
1064 | |||
1065 | static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | ||
1066 | int source, unsigned int fref, unsigned int fout) | ||
1067 | { | ||
1068 | struct snd_soc_codec *codec = codec_dai->codec; | ||
1069 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1070 | |||
1071 | u8 pll_ctrl, indiv_bits, indiv; | ||
1072 | u8 pll_frac_top, pll_frac_bot, pll_integer; | ||
1073 | u32 freq_ref; | ||
1074 | u64 frac_div; | ||
1075 | |||
1076 | /* Verify 32KHz, 2MHz - 54MHz MCLK provided, and set input divider */ | ||
1077 | if (da7219->mclk_rate == 32768) { | ||
1078 | indiv_bits = DA7219_PLL_INDIV_2_5_MHZ; | ||
1079 | indiv = DA7219_PLL_INDIV_2_5_MHZ_VAL; | ||
1080 | } else if (da7219->mclk_rate < 2000000) { | ||
1081 | dev_err(codec->dev, "PLL input clock %d below valid range\n", | ||
1082 | da7219->mclk_rate); | ||
1083 | return -EINVAL; | ||
1084 | } else if (da7219->mclk_rate <= 5000000) { | ||
1085 | indiv_bits = DA7219_PLL_INDIV_2_5_MHZ; | ||
1086 | indiv = DA7219_PLL_INDIV_2_5_MHZ_VAL; | ||
1087 | } else if (da7219->mclk_rate <= 10000000) { | ||
1088 | indiv_bits = DA7219_PLL_INDIV_5_10_MHZ; | ||
1089 | indiv = DA7219_PLL_INDIV_5_10_MHZ_VAL; | ||
1090 | } else if (da7219->mclk_rate <= 20000000) { | ||
1091 | indiv_bits = DA7219_PLL_INDIV_10_20_MHZ; | ||
1092 | indiv = DA7219_PLL_INDIV_10_20_MHZ_VAL; | ||
1093 | } else if (da7219->mclk_rate <= 40000000) { | ||
1094 | indiv_bits = DA7219_PLL_INDIV_20_40_MHZ; | ||
1095 | indiv = DA7219_PLL_INDIV_20_40_MHZ_VAL; | ||
1096 | } else if (da7219->mclk_rate <= 54000000) { | ||
1097 | indiv_bits = DA7219_PLL_INDIV_40_54_MHZ; | ||
1098 | indiv = DA7219_PLL_INDIV_40_54_MHZ_VAL; | ||
1099 | } else { | ||
1100 | dev_err(codec->dev, "PLL input clock %d above valid range\n", | ||
1101 | da7219->mclk_rate); | ||
1102 | return -EINVAL; | ||
1103 | } | ||
1104 | freq_ref = (da7219->mclk_rate / indiv); | ||
1105 | pll_ctrl = indiv_bits; | ||
1106 | |||
1107 | /* Configure PLL */ | ||
1108 | switch (source) { | ||
1109 | case DA7219_SYSCLK_MCLK: | ||
1110 | pll_ctrl |= DA7219_PLL_MODE_BYPASS; | ||
1111 | snd_soc_update_bits(codec, DA7219_PLL_CTRL, | ||
1112 | DA7219_PLL_INDIV_MASK | | ||
1113 | DA7219_PLL_MODE_MASK, pll_ctrl); | ||
1114 | return 0; | ||
1115 | case DA7219_SYSCLK_PLL: | ||
1116 | pll_ctrl |= DA7219_PLL_MODE_NORMAL; | ||
1117 | break; | ||
1118 | case DA7219_SYSCLK_PLL_SRM: | ||
1119 | pll_ctrl |= DA7219_PLL_MODE_SRM; | ||
1120 | break; | ||
1121 | case DA7219_SYSCLK_PLL_32KHZ: | ||
1122 | pll_ctrl |= DA7219_PLL_MODE_32KHZ; | ||
1123 | break; | ||
1124 | default: | ||
1125 | dev_err(codec->dev, "Invalid PLL config\n"); | ||
1126 | return -EINVAL; | ||
1127 | } | ||
1128 | |||
1129 | /* Calculate dividers for PLL */ | ||
1130 | pll_integer = fout / freq_ref; | ||
1131 | frac_div = (u64)(fout % freq_ref) * 8192ULL; | ||
1132 | do_div(frac_div, freq_ref); | ||
1133 | pll_frac_top = (frac_div >> DA7219_BYTE_SHIFT) & DA7219_BYTE_MASK; | ||
1134 | pll_frac_bot = (frac_div) & DA7219_BYTE_MASK; | ||
1135 | |||
1136 | /* Write PLL config & dividers */ | ||
1137 | snd_soc_write(codec, DA7219_PLL_FRAC_TOP, pll_frac_top); | ||
1138 | snd_soc_write(codec, DA7219_PLL_FRAC_BOT, pll_frac_bot); | ||
1139 | snd_soc_write(codec, DA7219_PLL_INTEGER, pll_integer); | ||
1140 | snd_soc_update_bits(codec, DA7219_PLL_CTRL, | ||
1141 | DA7219_PLL_INDIV_MASK | DA7219_PLL_MODE_MASK, | ||
1142 | pll_ctrl); | ||
1143 | |||
1144 | return 0; | ||
1145 | } | ||
1146 | |||
1147 | static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | ||
1148 | { | ||
1149 | struct snd_soc_codec *codec = codec_dai->codec; | ||
1150 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1151 | u8 dai_clk_mode = 0, dai_ctrl = 0; | ||
1152 | |||
1153 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
1154 | case SND_SOC_DAIFMT_CBM_CFM: | ||
1155 | da7219->master = true; | ||
1156 | break; | ||
1157 | case SND_SOC_DAIFMT_CBS_CFS: | ||
1158 | da7219->master = false; | ||
1159 | break; | ||
1160 | default: | ||
1161 | return -EINVAL; | ||
1162 | } | ||
1163 | |||
1164 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
1165 | case SND_SOC_DAIFMT_NB_NF: | ||
1166 | break; | ||
1167 | case SND_SOC_DAIFMT_NB_IF: | ||
1168 | dai_clk_mode |= DA7219_DAI_WCLK_POL_INV; | ||
1169 | break; | ||
1170 | case SND_SOC_DAIFMT_IB_NF: | ||
1171 | dai_clk_mode |= DA7219_DAI_CLK_POL_INV; | ||
1172 | break; | ||
1173 | case SND_SOC_DAIFMT_IB_IF: | ||
1174 | dai_clk_mode |= DA7219_DAI_WCLK_POL_INV | | ||
1175 | DA7219_DAI_CLK_POL_INV; | ||
1176 | break; | ||
1177 | default: | ||
1178 | return -EINVAL; | ||
1179 | } | ||
1180 | |||
1181 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
1182 | case SND_SOC_DAIFMT_I2S: | ||
1183 | dai_ctrl |= DA7219_DAI_FORMAT_I2S; | ||
1184 | break; | ||
1185 | case SND_SOC_DAIFMT_LEFT_J: | ||
1186 | dai_ctrl |= DA7219_DAI_FORMAT_LEFT_J; | ||
1187 | break; | ||
1188 | case SND_SOC_DAIFMT_RIGHT_J: | ||
1189 | dai_ctrl |= DA7219_DAI_FORMAT_RIGHT_J; | ||
1190 | break; | ||
1191 | case SND_SOC_DAIFMT_DSP_B: | ||
1192 | dai_ctrl |= DA7219_DAI_FORMAT_DSP; | ||
1193 | break; | ||
1194 | default: | ||
1195 | return -EINVAL; | ||
1196 | } | ||
1197 | |||
1198 | /* By default 64 BCLKs per WCLK is supported */ | ||
1199 | dai_clk_mode |= DA7219_DAI_BCLKS_PER_WCLK_64; | ||
1200 | |||
1201 | snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, | ||
1202 | DA7219_DAI_BCLKS_PER_WCLK_MASK | | ||
1203 | DA7219_DAI_CLK_POL_MASK | DA7219_DAI_WCLK_POL_MASK, | ||
1204 | dai_clk_mode); | ||
1205 | snd_soc_update_bits(codec, DA7219_DAI_CTRL, DA7219_DAI_FORMAT_MASK, | ||
1206 | dai_ctrl); | ||
1207 | |||
1208 | return 0; | ||
1209 | } | ||
1210 | |||
1211 | static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, | ||
1212 | unsigned int tx_mask, unsigned int rx_mask, | ||
1213 | int slots, int slot_width) | ||
1214 | { | ||
1215 | struct snd_soc_codec *codec = dai->codec; | ||
1216 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1217 | u8 dai_bclks_per_wclk; | ||
1218 | u16 offset; | ||
1219 | u32 frame_size; | ||
1220 | |||
1221 | /* No channels enabled so disable TDM, revert to 64-bit frames */ | ||
1222 | if (!tx_mask) { | ||
1223 | snd_soc_update_bits(codec, DA7219_DAI_TDM_CTRL, | ||
1224 | DA7219_DAI_TDM_CH_EN_MASK | | ||
1225 | DA7219_DAI_TDM_MODE_EN_MASK, 0); | ||
1226 | snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, | ||
1227 | DA7219_DAI_BCLKS_PER_WCLK_MASK, | ||
1228 | DA7219_DAI_BCLKS_PER_WCLK_64); | ||
1229 | return 0; | ||
1230 | } | ||
1231 | |||
1232 | /* Check we have valid slots */ | ||
1233 | if (fls(tx_mask) > DA7219_DAI_TDM_MAX_SLOTS) { | ||
1234 | dev_err(codec->dev, "Invalid number of slots, max = %d\n", | ||
1235 | DA7219_DAI_TDM_MAX_SLOTS); | ||
1236 | return -EINVAL; | ||
1237 | } | ||
1238 | |||
1239 | /* Check we have a valid offset given */ | ||
1240 | if (rx_mask > DA7219_DAI_OFFSET_MAX) { | ||
1241 | dev_err(codec->dev, "Invalid slot offset, max = %d\n", | ||
1242 | DA7219_DAI_OFFSET_MAX); | ||
1243 | return -EINVAL; | ||
1244 | } | ||
1245 | |||
1246 | /* Calculate & validate frame size based on slot info provided. */ | ||
1247 | frame_size = slots * slot_width; | ||
1248 | switch (frame_size) { | ||
1249 | case 32: | ||
1250 | dai_bclks_per_wclk = DA7219_DAI_BCLKS_PER_WCLK_32; | ||
1251 | break; | ||
1252 | case 64: | ||
1253 | dai_bclks_per_wclk = DA7219_DAI_BCLKS_PER_WCLK_64; | ||
1254 | break; | ||
1255 | case 128: | ||
1256 | dai_bclks_per_wclk = DA7219_DAI_BCLKS_PER_WCLK_128; | ||
1257 | break; | ||
1258 | case 256: | ||
1259 | dai_bclks_per_wclk = DA7219_DAI_BCLKS_PER_WCLK_256; | ||
1260 | break; | ||
1261 | default: | ||
1262 | dev_err(codec->dev, "Invalid frame size %d\n", frame_size); | ||
1263 | return -EINVAL; | ||
1264 | } | ||
1265 | |||
1266 | snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, | ||
1267 | DA7219_DAI_BCLKS_PER_WCLK_MASK, | ||
1268 | dai_bclks_per_wclk); | ||
1269 | |||
1270 | offset = cpu_to_le16(rx_mask); | ||
1271 | regmap_bulk_write(da7219->regmap, DA7219_DAI_OFFSET_LOWER, | ||
1272 | &offset, sizeof(offset)); | ||
1273 | |||
1274 | snd_soc_update_bits(codec, DA7219_DAI_TDM_CTRL, | ||
1275 | DA7219_DAI_TDM_CH_EN_MASK | | ||
1276 | DA7219_DAI_TDM_MODE_EN_MASK, | ||
1277 | (tx_mask << DA7219_DAI_TDM_CH_EN_SHIFT) | | ||
1278 | DA7219_DAI_TDM_MODE_EN_MASK); | ||
1279 | |||
1280 | return 0; | ||
1281 | } | ||
1282 | |||
1283 | static int da7219_hw_params(struct snd_pcm_substream *substream, | ||
1284 | struct snd_pcm_hw_params *params, | ||
1285 | struct snd_soc_dai *dai) | ||
1286 | { | ||
1287 | struct snd_soc_codec *codec = dai->codec; | ||
1288 | u8 dai_ctrl = 0, fs; | ||
1289 | unsigned int channels; | ||
1290 | |||
1291 | switch (params_width(params)) { | ||
1292 | case 16: | ||
1293 | dai_ctrl |= DA7219_DAI_WORD_LENGTH_S16_LE; | ||
1294 | break; | ||
1295 | case 20: | ||
1296 | dai_ctrl |= DA7219_DAI_WORD_LENGTH_S20_LE; | ||
1297 | break; | ||
1298 | case 24: | ||
1299 | dai_ctrl |= DA7219_DAI_WORD_LENGTH_S24_LE; | ||
1300 | break; | ||
1301 | case 32: | ||
1302 | dai_ctrl |= DA7219_DAI_WORD_LENGTH_S32_LE; | ||
1303 | break; | ||
1304 | default: | ||
1305 | return -EINVAL; | ||
1306 | } | ||
1307 | |||
1308 | channels = params_channels(params); | ||
1309 | if ((channels < 1) | (channels > DA7219_DAI_CH_NUM_MAX)) { | ||
1310 | dev_err(codec->dev, | ||
1311 | "Invalid number of channels, only 1 to %d supported\n", | ||
1312 | DA7219_DAI_CH_NUM_MAX); | ||
1313 | return -EINVAL; | ||
1314 | } | ||
1315 | dai_ctrl |= channels << DA7219_DAI_CH_NUM_SHIFT; | ||
1316 | |||
1317 | switch (params_rate(params)) { | ||
1318 | case 8000: | ||
1319 | fs = DA7219_SR_8000; | ||
1320 | break; | ||
1321 | case 11025: | ||
1322 | fs = DA7219_SR_11025; | ||
1323 | break; | ||
1324 | case 12000: | ||
1325 | fs = DA7219_SR_12000; | ||
1326 | break; | ||
1327 | case 16000: | ||
1328 | fs = DA7219_SR_16000; | ||
1329 | break; | ||
1330 | case 22050: | ||
1331 | fs = DA7219_SR_22050; | ||
1332 | break; | ||
1333 | case 24000: | ||
1334 | fs = DA7219_SR_24000; | ||
1335 | break; | ||
1336 | case 32000: | ||
1337 | fs = DA7219_SR_32000; | ||
1338 | break; | ||
1339 | case 44100: | ||
1340 | fs = DA7219_SR_44100; | ||
1341 | break; | ||
1342 | case 48000: | ||
1343 | fs = DA7219_SR_48000; | ||
1344 | break; | ||
1345 | case 88200: | ||
1346 | fs = DA7219_SR_88200; | ||
1347 | break; | ||
1348 | case 96000: | ||
1349 | fs = DA7219_SR_96000; | ||
1350 | break; | ||
1351 | default: | ||
1352 | return -EINVAL; | ||
1353 | } | ||
1354 | |||
1355 | snd_soc_update_bits(codec, DA7219_DAI_CTRL, | ||
1356 | DA7219_DAI_WORD_LENGTH_MASK | | ||
1357 | DA7219_DAI_CH_NUM_MASK, | ||
1358 | dai_ctrl); | ||
1359 | snd_soc_write(codec, DA7219_SR, fs); | ||
1360 | |||
1361 | return 0; | ||
1362 | } | ||
1363 | |||
1364 | static const struct snd_soc_dai_ops da7219_dai_ops = { | ||
1365 | .hw_params = da7219_hw_params, | ||
1366 | .set_sysclk = da7219_set_dai_sysclk, | ||
1367 | .set_pll = da7219_set_dai_pll, | ||
1368 | .set_fmt = da7219_set_dai_fmt, | ||
1369 | .set_tdm_slot = da7219_set_dai_tdm_slot, | ||
1370 | }; | ||
1371 | |||
1372 | #define DA7219_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ | ||
1373 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) | ||
1374 | |||
1375 | static struct snd_soc_dai_driver da7219_dai = { | ||
1376 | .name = "da7219-hifi", | ||
1377 | .playback = { | ||
1378 | .stream_name = "Playback", | ||
1379 | .channels_min = 1, | ||
1380 | .channels_max = DA7219_DAI_CH_NUM_MAX, | ||
1381 | .rates = SNDRV_PCM_RATE_8000_96000, | ||
1382 | .formats = DA7219_FORMATS, | ||
1383 | }, | ||
1384 | .capture = { | ||
1385 | .stream_name = "Capture", | ||
1386 | .channels_min = 1, | ||
1387 | .channels_max = DA7219_DAI_CH_NUM_MAX, | ||
1388 | .rates = SNDRV_PCM_RATE_8000_96000, | ||
1389 | .formats = DA7219_FORMATS, | ||
1390 | }, | ||
1391 | .ops = &da7219_dai_ops, | ||
1392 | .symmetric_rates = 1, | ||
1393 | .symmetric_channels = 1, | ||
1394 | .symmetric_samplebits = 1, | ||
1395 | }; | ||
1396 | |||
1397 | |||
1398 | /* | ||
1399 | * DT | ||
1400 | */ | ||
1401 | |||
1402 | static const struct of_device_id da7219_of_match[] = { | ||
1403 | { .compatible = "dlg,da7219", }, | ||
1404 | { } | ||
1405 | }; | ||
1406 | MODULE_DEVICE_TABLE(of, da7219_of_match); | ||
1407 | |||
1408 | static enum da7219_ldo_lvl_sel da7219_of_ldo_lvl(struct snd_soc_codec *codec, | ||
1409 | u32 val) | ||
1410 | { | ||
1411 | switch (val) { | ||
1412 | case 1050: | ||
1413 | return DA7219_LDO_LVL_SEL_1_05V; | ||
1414 | case 1100: | ||
1415 | return DA7219_LDO_LVL_SEL_1_10V; | ||
1416 | case 1200: | ||
1417 | return DA7219_LDO_LVL_SEL_1_20V; | ||
1418 | case 1400: | ||
1419 | return DA7219_LDO_LVL_SEL_1_40V; | ||
1420 | default: | ||
1421 | dev_warn(codec->dev, "Invalid LDO level"); | ||
1422 | return DA7219_LDO_LVL_SEL_1_05V; | ||
1423 | } | ||
1424 | } | ||
1425 | |||
1426 | static enum da7219_micbias_voltage | ||
1427 | da7219_of_micbias_lvl(struct snd_soc_codec *codec, u32 val) | ||
1428 | { | ||
1429 | switch (val) { | ||
1430 | case 1800: | ||
1431 | return DA7219_MICBIAS_1_8V; | ||
1432 | case 2000: | ||
1433 | return DA7219_MICBIAS_2_0V; | ||
1434 | case 2200: | ||
1435 | return DA7219_MICBIAS_2_2V; | ||
1436 | case 2400: | ||
1437 | return DA7219_MICBIAS_2_4V; | ||
1438 | case 2600: | ||
1439 | return DA7219_MICBIAS_2_6V; | ||
1440 | default: | ||
1441 | dev_warn(codec->dev, "Invalid micbias level"); | ||
1442 | return DA7219_MICBIAS_2_2V; | ||
1443 | } | ||
1444 | } | ||
1445 | |||
1446 | static enum da7219_mic_amp_in_sel | ||
1447 | da7219_of_mic_amp_in_sel(struct snd_soc_codec *codec, const char *str) | ||
1448 | { | ||
1449 | if (!strcmp(str, "diff")) { | ||
1450 | return DA7219_MIC_AMP_IN_SEL_DIFF; | ||
1451 | } else if (!strcmp(str, "se_p")) { | ||
1452 | return DA7219_MIC_AMP_IN_SEL_SE_P; | ||
1453 | } else if (!strcmp(str, "se_n")) { | ||
1454 | return DA7219_MIC_AMP_IN_SEL_SE_N; | ||
1455 | } else { | ||
1456 | dev_warn(codec->dev, "Invalid mic input type selection"); | ||
1457 | return DA7219_MIC_AMP_IN_SEL_DIFF; | ||
1458 | } | ||
1459 | } | ||
1460 | |||
1461 | static struct da7219_pdata *da7219_of_to_pdata(struct snd_soc_codec *codec) | ||
1462 | { | ||
1463 | struct device_node *np = codec->dev->of_node; | ||
1464 | struct da7219_pdata *pdata; | ||
1465 | const char *of_str; | ||
1466 | u32 of_val32; | ||
1467 | |||
1468 | pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); | ||
1469 | if (!pdata) | ||
1470 | return NULL; | ||
1471 | |||
1472 | if (of_property_read_u32(np, "dlg,ldo-lvl", &of_val32) >= 0) | ||
1473 | pdata->ldo_lvl_sel = da7219_of_ldo_lvl(codec, of_val32); | ||
1474 | |||
1475 | if (of_property_read_u32(np, "dlg,micbias-lvl", &of_val32) >= 0) | ||
1476 | pdata->micbias_lvl = da7219_of_micbias_lvl(codec, of_val32); | ||
1477 | else | ||
1478 | pdata->micbias_lvl = DA7219_MICBIAS_2_2V; | ||
1479 | |||
1480 | if (!of_property_read_string(np, "dlg,mic-amp-in-sel", &of_str)) | ||
1481 | pdata->mic_amp_in_sel = da7219_of_mic_amp_in_sel(codec, of_str); | ||
1482 | else | ||
1483 | pdata->mic_amp_in_sel = DA7219_MIC_AMP_IN_SEL_DIFF; | ||
1484 | |||
1485 | return pdata; | ||
1486 | } | ||
1487 | |||
1488 | |||
1489 | /* | ||
1490 | * Codec driver functions | ||
1491 | */ | ||
1492 | |||
1493 | static int da7219_set_bias_level(struct snd_soc_codec *codec, | ||
1494 | enum snd_soc_bias_level level) | ||
1495 | { | ||
1496 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1497 | int ret; | ||
1498 | |||
1499 | switch (level) { | ||
1500 | case SND_SOC_BIAS_ON: | ||
1501 | case SND_SOC_BIAS_PREPARE: | ||
1502 | break; | ||
1503 | case SND_SOC_BIAS_STANDBY: | ||
1504 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { | ||
1505 | /* MCLK */ | ||
1506 | if (da7219->mclk) { | ||
1507 | ret = clk_prepare_enable(da7219->mclk); | ||
1508 | if (ret) { | ||
1509 | dev_err(codec->dev, | ||
1510 | "Failed to enable mclk\n"); | ||
1511 | return ret; | ||
1512 | } | ||
1513 | } | ||
1514 | |||
1515 | /* Master bias */ | ||
1516 | snd_soc_update_bits(codec, DA7219_REFERENCES, | ||
1517 | DA7219_BIAS_EN_MASK, | ||
1518 | DA7219_BIAS_EN_MASK); | ||
1519 | |||
1520 | /* Enable Internal Digital LDO */ | ||
1521 | snd_soc_update_bits(codec, DA7219_LDO_CTRL, | ||
1522 | DA7219_LDO_EN_MASK, | ||
1523 | DA7219_LDO_EN_MASK); | ||
1524 | } | ||
1525 | break; | ||
1526 | case SND_SOC_BIAS_OFF: | ||
1527 | /* Only disable if jack detection not active */ | ||
1528 | if (!da7219->aad->jack) { | ||
1529 | /* Bypass Internal Digital LDO */ | ||
1530 | snd_soc_update_bits(codec, DA7219_LDO_CTRL, | ||
1531 | DA7219_LDO_EN_MASK, 0); | ||
1532 | |||
1533 | /* Master bias */ | ||
1534 | snd_soc_update_bits(codec, DA7219_REFERENCES, | ||
1535 | DA7219_BIAS_EN_MASK, 0); | ||
1536 | } | ||
1537 | |||
1538 | /* MCLK */ | ||
1539 | if (da7219->mclk) | ||
1540 | clk_disable_unprepare(da7219->mclk); | ||
1541 | break; | ||
1542 | } | ||
1543 | |||
1544 | return 0; | ||
1545 | } | ||
1546 | |||
1547 | static const char *da7219_supply_names[DA7219_NUM_SUPPLIES] = { | ||
1548 | [DA7219_SUPPLY_VDD] = "VDD", | ||
1549 | [DA7219_SUPPLY_VDDMIC] = "VDDMIC", | ||
1550 | [DA7219_SUPPLY_VDDIO] = "VDDIO", | ||
1551 | }; | ||
1552 | |||
1553 | static int da7219_handle_supplies(struct snd_soc_codec *codec) | ||
1554 | { | ||
1555 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1556 | struct regulator *vddio; | ||
1557 | u8 io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_2_5V_3_6V; | ||
1558 | int i, ret; | ||
1559 | |||
1560 | /* Get required supplies */ | ||
1561 | for (i = 0; i < DA7219_NUM_SUPPLIES; ++i) | ||
1562 | da7219->supplies[i].supply = da7219_supply_names[i]; | ||
1563 | |||
1564 | ret = devm_regulator_bulk_get(codec->dev, DA7219_NUM_SUPPLIES, | ||
1565 | da7219->supplies); | ||
1566 | if (ret) { | ||
1567 | dev_err(codec->dev, "Failed to get supplies"); | ||
1568 | return ret; | ||
1569 | } | ||
1570 | |||
1571 | /* Determine VDDIO voltage provided */ | ||
1572 | vddio = da7219->supplies[DA7219_SUPPLY_VDDIO].consumer; | ||
1573 | ret = regulator_get_voltage(vddio); | ||
1574 | if (ret < 1200000) | ||
1575 | dev_warn(codec->dev, "Invalid VDDIO voltage\n"); | ||
1576 | else if (ret < 2800000) | ||
1577 | io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_1_2V_2_8V; | ||
1578 | |||
1579 | /* Enable main supplies */ | ||
1580 | ret = regulator_bulk_enable(DA7219_NUM_SUPPLIES, da7219->supplies); | ||
1581 | if (ret) { | ||
1582 | dev_err(codec->dev, "Failed to enable supplies"); | ||
1583 | return ret; | ||
1584 | } | ||
1585 | |||
1586 | /* Ensure device in active mode */ | ||
1587 | snd_soc_write(codec, DA7219_SYSTEM_ACTIVE, DA7219_SYSTEM_ACTIVE_MASK); | ||
1588 | |||
1589 | /* Update IO voltage level range */ | ||
1590 | snd_soc_write(codec, DA7219_IO_CTRL, io_voltage_lvl); | ||
1591 | |||
1592 | return 0; | ||
1593 | } | ||
1594 | |||
1595 | static void da7219_handle_pdata(struct snd_soc_codec *codec) | ||
1596 | { | ||
1597 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1598 | struct da7219_pdata *pdata = da7219->pdata; | ||
1599 | |||
1600 | if (pdata) { | ||
1601 | u8 micbias_lvl = 0; | ||
1602 | |||
1603 | /* Internal LDO */ | ||
1604 | switch (pdata->ldo_lvl_sel) { | ||
1605 | case DA7219_LDO_LVL_SEL_1_05V: | ||
1606 | case DA7219_LDO_LVL_SEL_1_10V: | ||
1607 | case DA7219_LDO_LVL_SEL_1_20V: | ||
1608 | case DA7219_LDO_LVL_SEL_1_40V: | ||
1609 | snd_soc_update_bits(codec, DA7219_LDO_CTRL, | ||
1610 | DA7219_LDO_LEVEL_SELECT_MASK, | ||
1611 | (pdata->ldo_lvl_sel << | ||
1612 | DA7219_LDO_LEVEL_SELECT_SHIFT)); | ||
1613 | break; | ||
1614 | } | ||
1615 | |||
1616 | /* Mic Bias voltages */ | ||
1617 | switch (pdata->micbias_lvl) { | ||
1618 | case DA7219_MICBIAS_1_8V: | ||
1619 | case DA7219_MICBIAS_2_0V: | ||
1620 | case DA7219_MICBIAS_2_2V: | ||
1621 | case DA7219_MICBIAS_2_4V: | ||
1622 | case DA7219_MICBIAS_2_6V: | ||
1623 | micbias_lvl |= (pdata->micbias_lvl << | ||
1624 | DA7219_MICBIAS1_LEVEL_SHIFT); | ||
1625 | break; | ||
1626 | } | ||
1627 | |||
1628 | snd_soc_write(codec, DA7219_MICBIAS_CTRL, micbias_lvl); | ||
1629 | |||
1630 | /* Mic */ | ||
1631 | switch (pdata->mic_amp_in_sel) { | ||
1632 | case DA7219_MIC_AMP_IN_SEL_DIFF: | ||
1633 | case DA7219_MIC_AMP_IN_SEL_SE_P: | ||
1634 | case DA7219_MIC_AMP_IN_SEL_SE_N: | ||
1635 | snd_soc_write(codec, DA7219_MIC_1_SELECT, | ||
1636 | pdata->mic_amp_in_sel); | ||
1637 | break; | ||
1638 | } | ||
1639 | } | ||
1640 | } | ||
1641 | |||
1642 | static int da7219_probe(struct snd_soc_codec *codec) | ||
1643 | { | ||
1644 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1645 | int ret; | ||
1646 | |||
1647 | mutex_init(&da7219->lock); | ||
1648 | |||
1649 | /* Regulator configuration */ | ||
1650 | ret = da7219_handle_supplies(codec); | ||
1651 | if (ret) | ||
1652 | return ret; | ||
1653 | |||
1654 | /* Handle DT/Platform data */ | ||
1655 | if (codec->dev->of_node) | ||
1656 | da7219->pdata = da7219_of_to_pdata(codec); | ||
1657 | else | ||
1658 | da7219->pdata = dev_get_platdata(codec->dev); | ||
1659 | |||
1660 | da7219_handle_pdata(codec); | ||
1661 | |||
1662 | /* Check if MCLK provided */ | ||
1663 | da7219->mclk = devm_clk_get(codec->dev, "mclk"); | ||
1664 | if (IS_ERR(da7219->mclk)) { | ||
1665 | if (PTR_ERR(da7219->mclk) != -ENOENT) | ||
1666 | return PTR_ERR(da7219->mclk); | ||
1667 | else | ||
1668 | da7219->mclk = NULL; | ||
1669 | } | ||
1670 | |||
1671 | /* Default PC counter to free-running */ | ||
1672 | snd_soc_update_bits(codec, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK, | ||
1673 | DA7219_PC_FREERUN_MASK); | ||
1674 | |||
1675 | /* Default gain ramping */ | ||
1676 | snd_soc_update_bits(codec, DA7219_MIXIN_L_CTRL, | ||
1677 | DA7219_MIXIN_L_AMP_RAMP_EN_MASK, | ||
1678 | DA7219_MIXIN_L_AMP_RAMP_EN_MASK); | ||
1679 | snd_soc_update_bits(codec, DA7219_ADC_L_CTRL, DA7219_ADC_L_RAMP_EN_MASK, | ||
1680 | DA7219_ADC_L_RAMP_EN_MASK); | ||
1681 | snd_soc_update_bits(codec, DA7219_DAC_L_CTRL, DA7219_DAC_L_RAMP_EN_MASK, | ||
1682 | DA7219_DAC_L_RAMP_EN_MASK); | ||
1683 | snd_soc_update_bits(codec, DA7219_DAC_R_CTRL, DA7219_DAC_R_RAMP_EN_MASK, | ||
1684 | DA7219_DAC_R_RAMP_EN_MASK); | ||
1685 | snd_soc_update_bits(codec, DA7219_HP_L_CTRL, | ||
1686 | DA7219_HP_L_AMP_RAMP_EN_MASK, | ||
1687 | DA7219_HP_L_AMP_RAMP_EN_MASK); | ||
1688 | snd_soc_update_bits(codec, DA7219_HP_R_CTRL, | ||
1689 | DA7219_HP_R_AMP_RAMP_EN_MASK, | ||
1690 | DA7219_HP_R_AMP_RAMP_EN_MASK); | ||
1691 | |||
1692 | /* Default infinite tone gen, start/stop by Kcontrol */ | ||
1693 | snd_soc_write(codec, DA7219_TONE_GEN_CYCLES, DA7219_BEEP_CYCLES_MASK); | ||
1694 | |||
1695 | /* Initialise AAD block */ | ||
1696 | return da7219_aad_init(codec); | ||
1697 | } | ||
1698 | |||
1699 | static int da7219_remove(struct snd_soc_codec *codec) | ||
1700 | { | ||
1701 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1702 | |||
1703 | da7219_aad_exit(codec); | ||
1704 | |||
1705 | /* Supplies */ | ||
1706 | return regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies); | ||
1707 | } | ||
1708 | |||
1709 | #ifdef CONFIG_PM | ||
1710 | static int da7219_suspend(struct snd_soc_codec *codec) | ||
1711 | { | ||
1712 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1713 | |||
1714 | snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); | ||
1715 | |||
1716 | /* Put device into standby mode if jack detection disabled */ | ||
1717 | if (!da7219->aad->jack) | ||
1718 | snd_soc_write(codec, DA7219_SYSTEM_ACTIVE, 0); | ||
1719 | |||
1720 | return 0; | ||
1721 | } | ||
1722 | |||
1723 | static int da7219_resume(struct snd_soc_codec *codec) | ||
1724 | { | ||
1725 | struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); | ||
1726 | |||
1727 | /* Put device into active mode if previously pushed to standby */ | ||
1728 | if (!da7219->aad->jack) | ||
1729 | snd_soc_write(codec, DA7219_SYSTEM_ACTIVE, | ||
1730 | DA7219_SYSTEM_ACTIVE_MASK); | ||
1731 | |||
1732 | snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
1733 | |||
1734 | return 0; | ||
1735 | } | ||
1736 | #else | ||
1737 | #define da7219_suspend NULL | ||
1738 | #define da7219_resume NULL | ||
1739 | #endif | ||
1740 | |||
1741 | static struct snd_soc_codec_driver soc_codec_dev_da7219 = { | ||
1742 | .probe = da7219_probe, | ||
1743 | .remove = da7219_remove, | ||
1744 | .suspend = da7219_suspend, | ||
1745 | .resume = da7219_resume, | ||
1746 | .set_bias_level = da7219_set_bias_level, | ||
1747 | |||
1748 | .controls = da7219_snd_controls, | ||
1749 | .num_controls = ARRAY_SIZE(da7219_snd_controls), | ||
1750 | |||
1751 | .dapm_widgets = da7219_dapm_widgets, | ||
1752 | .num_dapm_widgets = ARRAY_SIZE(da7219_dapm_widgets), | ||
1753 | .dapm_routes = da7219_audio_map, | ||
1754 | .num_dapm_routes = ARRAY_SIZE(da7219_audio_map), | ||
1755 | }; | ||
1756 | |||
1757 | |||
1758 | /* | ||
1759 | * Regmap configs | ||
1760 | */ | ||
1761 | |||
1762 | static struct reg_default da7219_reg_defaults[] = { | ||
1763 | { DA7219_MIC_1_SELECT, 0x00 }, | ||
1764 | { DA7219_CIF_TIMEOUT_CTRL, 0x01 }, | ||
1765 | { DA7219_SR_24_48, 0x00 }, | ||
1766 | { DA7219_SR, 0x0A }, | ||
1767 | { DA7219_CIF_I2C_ADDR_CFG, 0x02 }, | ||
1768 | { DA7219_PLL_CTRL, 0x10 }, | ||
1769 | { DA7219_PLL_FRAC_TOP, 0x00 }, | ||
1770 | { DA7219_PLL_FRAC_BOT, 0x00 }, | ||
1771 | { DA7219_PLL_INTEGER, 0x20 }, | ||
1772 | { DA7219_DIG_ROUTING_DAI, 0x10 }, | ||
1773 | { DA7219_DAI_CLK_MODE, 0x01 }, | ||
1774 | { DA7219_DAI_CTRL, 0x28 }, | ||
1775 | { DA7219_DAI_TDM_CTRL, 0x40 }, | ||
1776 | { DA7219_DIG_ROUTING_DAC, 0x32 }, | ||
1777 | { DA7219_DAI_OFFSET_LOWER, 0x00 }, | ||
1778 | { DA7219_DAI_OFFSET_UPPER, 0x00 }, | ||
1779 | { DA7219_REFERENCES, 0x00 }, | ||
1780 | { DA7219_MIXIN_L_SELECT, 0x00 }, | ||
1781 | { DA7219_MIXIN_L_GAIN, 0x03 }, | ||
1782 | { DA7219_ADC_L_GAIN, 0x6F }, | ||
1783 | { DA7219_ADC_FILTERS1, 0x80 }, | ||
1784 | { DA7219_MIC_1_GAIN, 0x01 }, | ||
1785 | { DA7219_SIDETONE_CTRL, 0x40 }, | ||
1786 | { DA7219_SIDETONE_GAIN, 0x0E }, | ||
1787 | { DA7219_DROUTING_ST_OUTFILT_1L, 0x01 }, | ||
1788 | { DA7219_DROUTING_ST_OUTFILT_1R, 0x02 }, | ||
1789 | { DA7219_DAC_FILTERS5, 0x00 }, | ||
1790 | { DA7219_DAC_FILTERS2, 0x88 }, | ||
1791 | { DA7219_DAC_FILTERS3, 0x88 }, | ||
1792 | { DA7219_DAC_FILTERS4, 0x08 }, | ||
1793 | { DA7219_DAC_FILTERS1, 0x80 }, | ||
1794 | { DA7219_DAC_L_GAIN, 0x6F }, | ||
1795 | { DA7219_DAC_R_GAIN, 0x6F }, | ||
1796 | { DA7219_CP_CTRL, 0x20 }, | ||
1797 | { DA7219_HP_L_GAIN, 0x39 }, | ||
1798 | { DA7219_HP_R_GAIN, 0x39 }, | ||
1799 | { DA7219_MIXOUT_L_SELECT, 0x00 }, | ||
1800 | { DA7219_MIXOUT_R_SELECT, 0x00 }, | ||
1801 | { DA7219_MICBIAS_CTRL, 0x03 }, | ||
1802 | { DA7219_MIC_1_CTRL, 0x40 }, | ||
1803 | { DA7219_MIXIN_L_CTRL, 0x40 }, | ||
1804 | { DA7219_ADC_L_CTRL, 0x40 }, | ||
1805 | { DA7219_DAC_L_CTRL, 0x40 }, | ||
1806 | { DA7219_DAC_R_CTRL, 0x40 }, | ||
1807 | { DA7219_HP_L_CTRL, 0x40 }, | ||
1808 | { DA7219_HP_R_CTRL, 0x40 }, | ||
1809 | { DA7219_MIXOUT_L_CTRL, 0x10 }, | ||
1810 | { DA7219_MIXOUT_R_CTRL, 0x10 }, | ||
1811 | { DA7219_CHIP_ID1, 0x23 }, | ||
1812 | { DA7219_CHIP_ID2, 0x93 }, | ||
1813 | { DA7219_CHIP_REVISION, 0x00 }, | ||
1814 | { DA7219_LDO_CTRL, 0x00 }, | ||
1815 | { DA7219_IO_CTRL, 0x00 }, | ||
1816 | { DA7219_GAIN_RAMP_CTRL, 0x00 }, | ||
1817 | { DA7219_PC_COUNT, 0x02 }, | ||
1818 | { DA7219_CP_VOL_THRESHOLD1, 0x0E }, | ||
1819 | { DA7219_DIG_CTRL, 0x00 }, | ||
1820 | { DA7219_ALC_CTRL2, 0x00 }, | ||
1821 | { DA7219_ALC_CTRL3, 0x00 }, | ||
1822 | { DA7219_ALC_NOISE, 0x3F }, | ||
1823 | { DA7219_ALC_TARGET_MIN, 0x3F }, | ||
1824 | { DA7219_ALC_TARGET_MAX, 0x00 }, | ||
1825 | { DA7219_ALC_GAIN_LIMITS, 0xFF }, | ||
1826 | { DA7219_ALC_ANA_GAIN_LIMITS, 0x71 }, | ||
1827 | { DA7219_ALC_ANTICLIP_CTRL, 0x00 }, | ||
1828 | { DA7219_ALC_ANTICLIP_LEVEL, 0x00 }, | ||
1829 | { DA7219_DAC_NG_SETUP_TIME, 0x00 }, | ||
1830 | { DA7219_DAC_NG_OFF_THRESH, 0x00 }, | ||
1831 | { DA7219_DAC_NG_ON_THRESH, 0x00 }, | ||
1832 | { DA7219_DAC_NG_CTRL, 0x00 }, | ||
1833 | { DA7219_TONE_GEN_CFG1, 0x00 }, | ||
1834 | { DA7219_TONE_GEN_CFG2, 0x00 }, | ||
1835 | { DA7219_TONE_GEN_CYCLES, 0x00 }, | ||
1836 | { DA7219_TONE_GEN_FREQ1_L, 0x55 }, | ||
1837 | { DA7219_TONE_GEN_FREQ1_U, 0x15 }, | ||
1838 | { DA7219_TONE_GEN_FREQ2_L, 0x00 }, | ||
1839 | { DA7219_TONE_GEN_FREQ2_U, 0x40 }, | ||
1840 | { DA7219_TONE_GEN_ON_PER, 0x02 }, | ||
1841 | { DA7219_TONE_GEN_OFF_PER, 0x01 }, | ||
1842 | { DA7219_ACCDET_IRQ_MASK_A, 0x00 }, | ||
1843 | { DA7219_ACCDET_IRQ_MASK_B, 0x00 }, | ||
1844 | { DA7219_ACCDET_CONFIG_1, 0xD6 }, | ||
1845 | { DA7219_ACCDET_CONFIG_2, 0x34 }, | ||
1846 | { DA7219_ACCDET_CONFIG_3, 0x0A }, | ||
1847 | { DA7219_ACCDET_CONFIG_4, 0x16 }, | ||
1848 | { DA7219_ACCDET_CONFIG_5, 0x21 }, | ||
1849 | { DA7219_ACCDET_CONFIG_6, 0x3E }, | ||
1850 | { DA7219_ACCDET_CONFIG_7, 0x01 }, | ||
1851 | { DA7219_SYSTEM_ACTIVE, 0x00 }, | ||
1852 | }; | ||
1853 | |||
1854 | static bool da7219_volatile_register(struct device *dev, unsigned int reg) | ||
1855 | { | ||
1856 | switch (reg) { | ||
1857 | case DA7219_MIC_1_GAIN_STATUS: | ||
1858 | case DA7219_MIXIN_L_GAIN_STATUS: | ||
1859 | case DA7219_ADC_L_GAIN_STATUS: | ||
1860 | case DA7219_DAC_L_GAIN_STATUS: | ||
1861 | case DA7219_DAC_R_GAIN_STATUS: | ||
1862 | case DA7219_HP_L_GAIN_STATUS: | ||
1863 | case DA7219_HP_R_GAIN_STATUS: | ||
1864 | case DA7219_CIF_CTRL: | ||
1865 | case DA7219_PLL_SRM_STS: | ||
1866 | case DA7219_ALC_CTRL1: | ||
1867 | case DA7219_SYSTEM_MODES_INPUT: | ||
1868 | case DA7219_SYSTEM_MODES_OUTPUT: | ||
1869 | case DA7219_ALC_OFFSET_AUTO_M_L: | ||
1870 | case DA7219_ALC_OFFSET_AUTO_U_L: | ||
1871 | case DA7219_TONE_GEN_CFG1: | ||
1872 | case DA7219_ACCDET_STATUS_A: | ||
1873 | case DA7219_ACCDET_STATUS_B: | ||
1874 | case DA7219_ACCDET_IRQ_EVENT_A: | ||
1875 | case DA7219_ACCDET_IRQ_EVENT_B: | ||
1876 | case DA7219_ACCDET_CONFIG_8: | ||
1877 | case DA7219_SYSTEM_STATUS: | ||
1878 | return 1; | ||
1879 | default: | ||
1880 | return 0; | ||
1881 | } | ||
1882 | } | ||
1883 | |||
1884 | static const struct regmap_config da7219_regmap_config = { | ||
1885 | .reg_bits = 8, | ||
1886 | .val_bits = 8, | ||
1887 | |||
1888 | .max_register = DA7219_SYSTEM_ACTIVE, | ||
1889 | .reg_defaults = da7219_reg_defaults, | ||
1890 | .num_reg_defaults = ARRAY_SIZE(da7219_reg_defaults), | ||
1891 | .volatile_reg = da7219_volatile_register, | ||
1892 | .cache_type = REGCACHE_RBTREE, | ||
1893 | }; | ||
1894 | |||
1895 | |||
1896 | /* | ||
1897 | * I2C layer | ||
1898 | */ | ||
1899 | |||
1900 | static int da7219_i2c_probe(struct i2c_client *i2c, | ||
1901 | const struct i2c_device_id *id) | ||
1902 | { | ||
1903 | struct da7219_priv *da7219; | ||
1904 | int ret; | ||
1905 | |||
1906 | da7219 = devm_kzalloc(&i2c->dev, sizeof(struct da7219_priv), | ||
1907 | GFP_KERNEL); | ||
1908 | if (!da7219) | ||
1909 | return -ENOMEM; | ||
1910 | |||
1911 | i2c_set_clientdata(i2c, da7219); | ||
1912 | |||
1913 | da7219->regmap = devm_regmap_init_i2c(i2c, &da7219_regmap_config); | ||
1914 | if (IS_ERR(da7219->regmap)) { | ||
1915 | ret = PTR_ERR(da7219->regmap); | ||
1916 | dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); | ||
1917 | return ret; | ||
1918 | } | ||
1919 | |||
1920 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da7219, | ||
1921 | &da7219_dai, 1); | ||
1922 | if (ret < 0) { | ||
1923 | dev_err(&i2c->dev, "Failed to register da7219 codec: %d\n", | ||
1924 | ret); | ||
1925 | } | ||
1926 | return ret; | ||
1927 | } | ||
1928 | |||
1929 | static int da7219_i2c_remove(struct i2c_client *client) | ||
1930 | { | ||
1931 | snd_soc_unregister_codec(&client->dev); | ||
1932 | return 0; | ||
1933 | } | ||
1934 | |||
1935 | static const struct i2c_device_id da7219_i2c_id[] = { | ||
1936 | { "da7219", }, | ||
1937 | { } | ||
1938 | }; | ||
1939 | MODULE_DEVICE_TABLE(i2c, da7219_i2c_id); | ||
1940 | |||
1941 | static struct i2c_driver da7219_i2c_driver = { | ||
1942 | .driver = { | ||
1943 | .name = "da7219", | ||
1944 | .of_match_table = of_match_ptr(da7219_of_match), | ||
1945 | }, | ||
1946 | .probe = da7219_i2c_probe, | ||
1947 | .remove = da7219_i2c_remove, | ||
1948 | .id_table = da7219_i2c_id, | ||
1949 | }; | ||
1950 | |||
1951 | module_i2c_driver(da7219_i2c_driver); | ||
1952 | |||
1953 | MODULE_DESCRIPTION("ASoC DA7219 Codec Driver"); | ||
1954 | MODULE_AUTHOR("Adam Thomson <Adam.Thomson.Opensource@diasemi.com>"); | ||
1955 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/da7219.h b/sound/soc/codecs/da7219.h new file mode 100644 index 000000000000..b514268c6c56 --- /dev/null +++ b/sound/soc/codecs/da7219.h | |||
@@ -0,0 +1,820 @@ | |||
1 | /* | ||
2 | * da7219.h - DA7219 ALSA SoC Codec Driver | ||
3 | * | ||
4 | * Copyright (c) 2015 Dialog Semiconductor | ||
5 | * | ||
6 | * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #ifndef __DA7219_H | ||
15 | #define __DA7219_H | ||
16 | |||
17 | #include <linux/regmap.h> | ||
18 | #include <linux/regulator/consumer.h> | ||
19 | #include <sound/da7219.h> | ||
20 | |||
21 | /* | ||
22 | * Registers | ||
23 | */ | ||
24 | |||
25 | #define DA7219_MIC_1_GAIN_STATUS 0x6 | ||
26 | #define DA7219_MIXIN_L_GAIN_STATUS 0x8 | ||
27 | #define DA7219_ADC_L_GAIN_STATUS 0xA | ||
28 | #define DA7219_DAC_L_GAIN_STATUS 0xC | ||
29 | #define DA7219_DAC_R_GAIN_STATUS 0xD | ||
30 | #define DA7219_HP_L_GAIN_STATUS 0xE | ||
31 | #define DA7219_HP_R_GAIN_STATUS 0xF | ||
32 | #define DA7219_MIC_1_SELECT 0x10 | ||
33 | #define DA7219_CIF_TIMEOUT_CTRL 0x12 | ||
34 | #define DA7219_CIF_CTRL 0x13 | ||
35 | #define DA7219_SR_24_48 0x16 | ||
36 | #define DA7219_SR 0x17 | ||
37 | #define DA7219_CIF_I2C_ADDR_CFG 0x1B | ||
38 | #define DA7219_PLL_CTRL 0x20 | ||
39 | #define DA7219_PLL_FRAC_TOP 0x22 | ||
40 | #define DA7219_PLL_FRAC_BOT 0x23 | ||
41 | #define DA7219_PLL_INTEGER 0x24 | ||
42 | #define DA7219_PLL_SRM_STS 0x25 | ||
43 | #define DA7219_DIG_ROUTING_DAI 0x2A | ||
44 | #define DA7219_DAI_CLK_MODE 0x2B | ||
45 | #define DA7219_DAI_CTRL 0x2C | ||
46 | #define DA7219_DAI_TDM_CTRL 0x2D | ||
47 | #define DA7219_DIG_ROUTING_DAC 0x2E | ||
48 | #define DA7219_ALC_CTRL1 0x2F | ||
49 | #define DA7219_DAI_OFFSET_LOWER 0x30 | ||
50 | #define DA7219_DAI_OFFSET_UPPER 0x31 | ||
51 | #define DA7219_REFERENCES 0x32 | ||
52 | #define DA7219_MIXIN_L_SELECT 0x33 | ||
53 | #define DA7219_MIXIN_L_GAIN 0x34 | ||
54 | #define DA7219_ADC_L_GAIN 0x36 | ||
55 | #define DA7219_ADC_FILTERS1 0x38 | ||
56 | #define DA7219_MIC_1_GAIN 0x39 | ||
57 | #define DA7219_SIDETONE_CTRL 0x3A | ||
58 | #define DA7219_SIDETONE_GAIN 0x3B | ||
59 | #define DA7219_DROUTING_ST_OUTFILT_1L 0x3C | ||
60 | #define DA7219_DROUTING_ST_OUTFILT_1R 0x3D | ||
61 | #define DA7219_DAC_FILTERS5 0x40 | ||
62 | #define DA7219_DAC_FILTERS2 0x41 | ||
63 | #define DA7219_DAC_FILTERS3 0x42 | ||
64 | #define DA7219_DAC_FILTERS4 0x43 | ||
65 | #define DA7219_DAC_FILTERS1 0x44 | ||
66 | #define DA7219_DAC_L_GAIN 0x45 | ||
67 | #define DA7219_DAC_R_GAIN 0x46 | ||
68 | #define DA7219_CP_CTRL 0x47 | ||
69 | #define DA7219_HP_L_GAIN 0x48 | ||
70 | #define DA7219_HP_R_GAIN 0x49 | ||
71 | #define DA7219_MIXOUT_L_SELECT 0x4B | ||
72 | #define DA7219_MIXOUT_R_SELECT 0x4C | ||
73 | #define DA7219_SYSTEM_MODES_INPUT 0x50 | ||
74 | #define DA7219_SYSTEM_MODES_OUTPUT 0x51 | ||
75 | #define DA7219_MICBIAS_CTRL 0x62 | ||
76 | #define DA7219_MIC_1_CTRL 0x63 | ||
77 | #define DA7219_MIXIN_L_CTRL 0x65 | ||
78 | #define DA7219_ADC_L_CTRL 0x67 | ||
79 | #define DA7219_DAC_L_CTRL 0x69 | ||
80 | #define DA7219_DAC_R_CTRL 0x6A | ||
81 | #define DA7219_HP_L_CTRL 0x6B | ||
82 | #define DA7219_HP_R_CTRL 0x6C | ||
83 | #define DA7219_MIXOUT_L_CTRL 0x6E | ||
84 | #define DA7219_MIXOUT_R_CTRL 0x6F | ||
85 | #define DA7219_CHIP_ID1 0x81 | ||
86 | #define DA7219_CHIP_ID2 0x82 | ||
87 | #define DA7219_CHIP_REVISION 0x83 | ||
88 | #define DA7219_LDO_CTRL 0x90 | ||
89 | #define DA7219_IO_CTRL 0x91 | ||
90 | #define DA7219_GAIN_RAMP_CTRL 0x92 | ||
91 | #define DA7219_PC_COUNT 0x94 | ||
92 | #define DA7219_CP_VOL_THRESHOLD1 0x95 | ||
93 | #define DA7219_CP_DELAY 0x96 | ||
94 | #define DA7219_DIG_CTRL 0x99 | ||
95 | #define DA7219_ALC_CTRL2 0x9A | ||
96 | #define DA7219_ALC_CTRL3 0x9B | ||
97 | #define DA7219_ALC_NOISE 0x9C | ||
98 | #define DA7219_ALC_TARGET_MIN 0x9D | ||
99 | #define DA7219_ALC_TARGET_MAX 0x9E | ||
100 | #define DA7219_ALC_GAIN_LIMITS 0x9F | ||
101 | #define DA7219_ALC_ANA_GAIN_LIMITS 0xA0 | ||
102 | #define DA7219_ALC_ANTICLIP_CTRL 0xA1 | ||
103 | #define DA7219_ALC_ANTICLIP_LEVEL 0xA2 | ||
104 | #define DA7219_ALC_OFFSET_AUTO_M_L 0xA3 | ||
105 | #define DA7219_ALC_OFFSET_AUTO_U_L 0xA4 | ||
106 | #define DA7219_DAC_NG_SETUP_TIME 0xAF | ||
107 | #define DA7219_DAC_NG_OFF_THRESH 0xB0 | ||
108 | #define DA7219_DAC_NG_ON_THRESH 0xB1 | ||
109 | #define DA7219_DAC_NG_CTRL 0xB2 | ||
110 | #define DA7219_TONE_GEN_CFG1 0xB4 | ||
111 | #define DA7219_TONE_GEN_CFG2 0xB5 | ||
112 | #define DA7219_TONE_GEN_CYCLES 0xB6 | ||
113 | #define DA7219_TONE_GEN_FREQ1_L 0xB7 | ||
114 | #define DA7219_TONE_GEN_FREQ1_U 0xB8 | ||
115 | #define DA7219_TONE_GEN_FREQ2_L 0xB9 | ||
116 | #define DA7219_TONE_GEN_FREQ2_U 0xBA | ||
117 | #define DA7219_TONE_GEN_ON_PER 0xBB | ||
118 | #define DA7219_TONE_GEN_OFF_PER 0xBC | ||
119 | #define DA7219_SYSTEM_STATUS 0xE0 | ||
120 | #define DA7219_SYSTEM_ACTIVE 0xFD | ||
121 | |||
122 | |||
123 | /* | ||
124 | * Bit Fields | ||
125 | */ | ||
126 | |||
127 | #define DA7219_SWITCH_EN_MAX 0x1 | ||
128 | |||
129 | /* DA7219_MIC_1_GAIN_STATUS = 0x6 */ | ||
130 | #define DA7219_MIC_1_AMP_GAIN_STATUS_SHIFT 0 | ||
131 | #define DA7219_MIC_1_AMP_GAIN_STATUS_MASK (0x7 << 0) | ||
132 | #define DA7219_MIC_1_AMP_GAIN_MAX 0x7 | ||
133 | |||
134 | /* DA7219_MIXIN_L_GAIN_STATUS = 0x8 */ | ||
135 | #define DA7219_MIXIN_L_AMP_GAIN_STATUS_SHIFT 0 | ||
136 | #define DA7219_MIXIN_L_AMP_GAIN_STATUS_MASK (0xF << 0) | ||
137 | |||
138 | /* DA7219_ADC_L_GAIN_STATUS = 0xA */ | ||
139 | #define DA7219_ADC_L_DIGITAL_GAIN_STATUS_SHIFT 0 | ||
140 | #define DA7219_ADC_L_DIGITAL_GAIN_STATUS_MASK (0x7F << 0) | ||
141 | |||
142 | /* DA7219_DAC_L_GAIN_STATUS = 0xC */ | ||
143 | #define DA7219_DAC_L_DIGITAL_GAIN_STATUS_SHIFT 0 | ||
144 | #define DA7219_DAC_L_DIGITAL_GAIN_STATUS_MASK (0x7F << 0) | ||
145 | |||
146 | /* DA7219_DAC_R_GAIN_STATUS = 0xD */ | ||
147 | #define DA7219_DAC_R_DIGITAL_GAIN_STATUS_SHIFT 0 | ||
148 | #define DA7219_DAC_R_DIGITAL_GAIN_STATUS_MASK (0x7F << 0) | ||
149 | |||
150 | /* DA7219_HP_L_GAIN_STATUS = 0xE */ | ||
151 | #define DA7219_HP_L_AMP_GAIN_STATUS_SHIFT 0 | ||
152 | #define DA7219_HP_L_AMP_GAIN_STATUS_MASK (0x3F << 0) | ||
153 | |||
154 | /* DA7219_HP_R_GAIN_STATUS = 0xF */ | ||
155 | #define DA7219_HP_R_AMP_GAIN_STATUS_SHIFT 0 | ||
156 | #define DA7219_HP_R_AMP_GAIN_STATUS_MASK (0x3F << 0) | ||
157 | |||
158 | /* DA7219_MIC_1_SELECT = 0x10 */ | ||
159 | #define DA7219_MIC_1_AMP_IN_SEL_SHIFT 0 | ||
160 | #define DA7219_MIC_1_AMP_IN_SEL_MASK (0x3 << 0) | ||
161 | |||
162 | /* DA7219_CIF_TIMEOUT_CTRL = 0x12 */ | ||
163 | #define DA7219_I2C_TIMEOUT_EN_SHIFT 0 | ||
164 | #define DA7219_I2C_TIMEOUT_EN_MASK (0x1 << 0) | ||
165 | |||
166 | /* DA7219_CIF_CTRL = 0x13 */ | ||
167 | #define DA7219_CIF_I2C_WRITE_MODE_SHIFT 0 | ||
168 | #define DA7219_CIF_I2C_WRITE_MODE_MASK (0x1 << 0) | ||
169 | #define DA7219_CIF_REG_SOFT_RESET_SHIFT 7 | ||
170 | #define DA7219_CIF_REG_SOFT_RESET_MASK (0x1 << 7) | ||
171 | |||
172 | /* DA7219_SR_24_48 = 0x16 */ | ||
173 | #define DA7219_SR_24_48_SHIFT 0 | ||
174 | #define DA7219_SR_24_48_MASK (0x1 << 0) | ||
175 | |||
176 | /* DA7219_SR = 0x17 */ | ||
177 | #define DA7219_SR_SHIFT 0 | ||
178 | #define DA7219_SR_MASK (0xF << 0) | ||
179 | #define DA7219_SR_8000 (0x01 << 0) | ||
180 | #define DA7219_SR_11025 (0x02 << 0) | ||
181 | #define DA7219_SR_12000 (0x03 << 0) | ||
182 | #define DA7219_SR_16000 (0x05 << 0) | ||
183 | #define DA7219_SR_22050 (0x06 << 0) | ||
184 | #define DA7219_SR_24000 (0x07 << 0) | ||
185 | #define DA7219_SR_32000 (0x09 << 0) | ||
186 | #define DA7219_SR_44100 (0x0A << 0) | ||
187 | #define DA7219_SR_48000 (0x0B << 0) | ||
188 | #define DA7219_SR_88200 (0x0E << 0) | ||
189 | #define DA7219_SR_96000 (0x0F << 0) | ||
190 | |||
191 | /* DA7219_CIF_I2C_ADDR_CFG = 0x1B */ | ||
192 | #define DA7219_CIF_I2C_ADDR_CFG_SHIFT 0 | ||
193 | #define DA7219_CIF_I2C_ADDR_CFG_MASK (0x3 << 0) | ||
194 | |||
195 | /* DA7219_PLL_CTRL = 0x20 */ | ||
196 | #define DA7219_PLL_INDIV_SHIFT 2 | ||
197 | #define DA7219_PLL_INDIV_MASK (0x7 << 2) | ||
198 | #define DA7219_PLL_INDIV_2_5_MHZ (0x0 << 2) | ||
199 | #define DA7219_PLL_INDIV_5_10_MHZ (0x1 << 2) | ||
200 | #define DA7219_PLL_INDIV_10_20_MHZ (0x2 << 2) | ||
201 | #define DA7219_PLL_INDIV_20_40_MHZ (0x3 << 2) | ||
202 | #define DA7219_PLL_INDIV_40_54_MHZ (0x4 << 2) | ||
203 | #define DA7219_PLL_MCLK_SQR_EN_SHIFT 5 | ||
204 | #define DA7219_PLL_MCLK_SQR_EN_MASK (0x1 << 5) | ||
205 | #define DA7219_PLL_MODE_SHIFT 6 | ||
206 | #define DA7219_PLL_MODE_MASK (0x3 << 6) | ||
207 | #define DA7219_PLL_MODE_BYPASS (0x0 << 6) | ||
208 | #define DA7219_PLL_MODE_NORMAL (0x1 << 6) | ||
209 | #define DA7219_PLL_MODE_SRM (0x2 << 6) | ||
210 | #define DA7219_PLL_MODE_32KHZ (0x3 << 6) | ||
211 | |||
212 | /* DA7219_PLL_FRAC_TOP = 0x22 */ | ||
213 | #define DA7219_PLL_FBDIV_FRAC_TOP_SHIFT 0 | ||
214 | #define DA7219_PLL_FBDIV_FRAC_TOP_MASK (0x1F << 0) | ||
215 | |||
216 | /* DA7219_PLL_FRAC_BOT = 0x23 */ | ||
217 | #define DA7219_PLL_FBDIV_FRAC_BOT_SHIFT 0 | ||
218 | #define DA7219_PLL_FBDIV_FRAC_BOT_MASK (0xFF << 0) | ||
219 | |||
220 | /* DA7219_PLL_INTEGER = 0x24 */ | ||
221 | #define DA7219_PLL_FBDIV_INTEGER_SHIFT 0 | ||
222 | #define DA7219_PLL_FBDIV_INTEGER_MASK (0x7F << 0) | ||
223 | |||
224 | /* DA7219_PLL_SRM_STS = 0x25 */ | ||
225 | #define DA7219_PLL_SRM_STATE_SHIFT 0 | ||
226 | #define DA7219_PLL_SRM_STATE_MASK (0xF << 0) | ||
227 | #define DA7219_PLL_SRM_STATUS_SHIFT 4 | ||
228 | #define DA7219_PLL_SRM_STATUS_MASK (0xF << 4) | ||
229 | #define DA7219_PLL_SRM_STS_SRM_LOCK (0x1 << 7) | ||
230 | |||
231 | /* DA7219_DIG_ROUTING_DAI = 0x2A */ | ||
232 | #define DA7219_DAI_L_SRC_SHIFT 0 | ||
233 | #define DA7219_DAI_L_SRC_MASK (0x3 << 0) | ||
234 | #define DA7219_DAI_R_SRC_SHIFT 4 | ||
235 | #define DA7219_DAI_R_SRC_MASK (0x3 << 4) | ||
236 | #define DA7219_OUT_SRC_MAX 4 | ||
237 | |||
238 | /* DA7219_DAI_CLK_MODE = 0x2B */ | ||
239 | #define DA7219_DAI_BCLKS_PER_WCLK_SHIFT 0 | ||
240 | #define DA7219_DAI_BCLKS_PER_WCLK_MASK (0x3 << 0) | ||
241 | #define DA7219_DAI_BCLKS_PER_WCLK_32 (0x0 << 0) | ||
242 | #define DA7219_DAI_BCLKS_PER_WCLK_64 (0x1 << 0) | ||
243 | #define DA7219_DAI_BCLKS_PER_WCLK_128 (0x2 << 0) | ||
244 | #define DA7219_DAI_BCLKS_PER_WCLK_256 (0x3 << 0) | ||
245 | #define DA7219_DAI_CLK_POL_SHIFT 2 | ||
246 | #define DA7219_DAI_CLK_POL_MASK (0x1 << 2) | ||
247 | #define DA7219_DAI_CLK_POL_INV (0x1 << 2) | ||
248 | #define DA7219_DAI_WCLK_POL_SHIFT 3 | ||
249 | #define DA7219_DAI_WCLK_POL_MASK (0x1 << 3) | ||
250 | #define DA7219_DAI_WCLK_POL_INV (0x1 << 3) | ||
251 | #define DA7219_DAI_WCLK_TRI_STATE_SHIFT 4 | ||
252 | #define DA7219_DAI_WCLK_TRI_STATE_MASK (0x1 << 4) | ||
253 | #define DA7219_DAI_CLK_EN_SHIFT 7 | ||
254 | #define DA7219_DAI_CLK_EN_MASK (0x1 << 7) | ||
255 | |||
256 | /* DA7219_DAI_CTRL = 0x2C */ | ||
257 | #define DA7219_DAI_FORMAT_SHIFT 0 | ||
258 | #define DA7219_DAI_FORMAT_MASK (0x3 << 0) | ||
259 | #define DA7219_DAI_FORMAT_I2S (0x0 << 0) | ||
260 | #define DA7219_DAI_FORMAT_LEFT_J (0x1 << 0) | ||
261 | #define DA7219_DAI_FORMAT_RIGHT_J (0x2 << 0) | ||
262 | #define DA7219_DAI_FORMAT_DSP (0x3 << 0) | ||
263 | #define DA7219_DAI_WORD_LENGTH_SHIFT 2 | ||
264 | #define DA7219_DAI_WORD_LENGTH_MASK (0x3 << 2) | ||
265 | #define DA7219_DAI_WORD_LENGTH_S16_LE (0x0 << 2) | ||
266 | #define DA7219_DAI_WORD_LENGTH_S20_LE (0x1 << 2) | ||
267 | #define DA7219_DAI_WORD_LENGTH_S24_LE (0x2 << 2) | ||
268 | #define DA7219_DAI_WORD_LENGTH_S32_LE (0x3 << 2) | ||
269 | #define DA7219_DAI_CH_NUM_SHIFT 4 | ||
270 | #define DA7219_DAI_CH_NUM_MASK (0x3 << 4) | ||
271 | #define DA7219_DAI_CH_NUM_MAX 2 | ||
272 | #define DA7219_DAI_EN_SHIFT 7 | ||
273 | #define DA7219_DAI_EN_MASK (0x1 << 7) | ||
274 | |||
275 | /* DA7219_DAI_TDM_CTRL = 0x2D */ | ||
276 | #define DA7219_DAI_TDM_CH_EN_SHIFT 0 | ||
277 | #define DA7219_DAI_TDM_CH_EN_MASK (0x3 << 0) | ||
278 | #define DA7219_DAI_OE_SHIFT 6 | ||
279 | #define DA7219_DAI_OE_MASK (0x1 << 6) | ||
280 | #define DA7219_DAI_TDM_MODE_EN_SHIFT 7 | ||
281 | #define DA7219_DAI_TDM_MODE_EN_MASK (0x1 << 7) | ||
282 | #define DA7219_DAI_TDM_MAX_SLOTS 2 | ||
283 | |||
284 | /* DA7219_DIG_ROUTING_DAC = 0x2E */ | ||
285 | #define DA7219_DAC_L_SRC_SHIFT 0 | ||
286 | #define DA7219_DAC_L_SRC_MASK (0x3 << 0) | ||
287 | #define DA7219_DAC_L_SRC_TONEGEN (0x1 << 0) | ||
288 | #define DA7219_DAC_L_MONO_SHIFT 3 | ||
289 | #define DA7219_DAC_L_MONO_MASK (0x1 << 3) | ||
290 | #define DA7219_DAC_R_SRC_SHIFT 4 | ||
291 | #define DA7219_DAC_R_SRC_MASK (0x3 << 4) | ||
292 | #define DA7219_DAC_R_SRC_TONEGEN (0x1 << 4) | ||
293 | #define DA7219_DAC_R_MONO_SHIFT 7 | ||
294 | #define DA7219_DAC_R_MONO_MASK (0x1 << 7) | ||
295 | |||
296 | /* DA7219_ALC_CTRL1 = 0x2F */ | ||
297 | #define DA7219_ALC_OFFSET_EN_SHIFT 0 | ||
298 | #define DA7219_ALC_OFFSET_EN_MASK (0x1 << 0) | ||
299 | #define DA7219_ALC_SYNC_MODE_SHIFT 1 | ||
300 | #define DA7219_ALC_SYNC_MODE_MASK (0x1 << 1) | ||
301 | #define DA7219_ALC_EN_SHIFT 3 | ||
302 | #define DA7219_ALC_EN_MASK (0x1 << 3) | ||
303 | #define DA7219_ALC_AUTO_CALIB_EN_SHIFT 4 | ||
304 | #define DA7219_ALC_AUTO_CALIB_EN_MASK (0x1 << 4) | ||
305 | #define DA7219_ALC_CALIB_OVERFLOW_SHIFT 5 | ||
306 | #define DA7219_ALC_CALIB_OVERFLOW_MASK (0x1 << 5) | ||
307 | |||
308 | /* DA7219_DAI_OFFSET_LOWER = 0x30 */ | ||
309 | #define DA7219_DAI_OFFSET_LOWER_SHIFT 0 | ||
310 | #define DA7219_DAI_OFFSET_LOWER_MASK (0xFF << 0) | ||
311 | |||
312 | /* DA7219_DAI_OFFSET_UPPER = 0x31 */ | ||
313 | #define DA7219_DAI_OFFSET_UPPER_SHIFT 0 | ||
314 | #define DA7219_DAI_OFFSET_UPPER_MASK (0x7 << 0) | ||
315 | #define DA7219_DAI_OFFSET_MAX 0x2FF | ||
316 | |||
317 | /* DA7219_REFERENCES = 0x32 */ | ||
318 | #define DA7219_BIAS_EN_SHIFT 3 | ||
319 | #define DA7219_BIAS_EN_MASK (0x1 << 3) | ||
320 | #define DA7219_VMID_FAST_CHARGE_SHIFT 4 | ||
321 | #define DA7219_VMID_FAST_CHARGE_MASK (0x1 << 4) | ||
322 | |||
323 | /* DA7219_MIXIN_L_SELECT = 0x33 */ | ||
324 | #define DA7219_MIXIN_L_MIX_SELECT_SHIFT 0 | ||
325 | #define DA7219_MIXIN_L_MIX_SELECT_MASK (0x1 << 0) | ||
326 | |||
327 | /* DA7219_MIXIN_L_GAIN = 0x34 */ | ||
328 | #define DA7219_MIXIN_L_AMP_GAIN_SHIFT 0 | ||
329 | #define DA7219_MIXIN_L_AMP_GAIN_MASK (0xF << 0) | ||
330 | #define DA7219_MIXIN_L_AMP_GAIN_MAX 0xF | ||
331 | |||
332 | /* DA7219_ADC_L_GAIN = 0x36 */ | ||
333 | #define DA7219_ADC_L_DIGITAL_GAIN_SHIFT 0 | ||
334 | #define DA7219_ADC_L_DIGITAL_GAIN_MASK (0x7F << 0) | ||
335 | #define DA7219_ADC_L_DIGITAL_GAIN_MAX 0x7F | ||
336 | |||
337 | /* DA7219_ADC_FILTERS1 = 0x38 */ | ||
338 | #define DA7219_ADC_VOICE_HPF_CORNER_SHIFT 0 | ||
339 | #define DA7219_ADC_VOICE_HPF_CORNER_MASK (0x7 << 0) | ||
340 | #define DA7219_VOICE_HPF_CORNER_MAX 8 | ||
341 | #define DA7219_ADC_VOICE_EN_SHIFT 3 | ||
342 | #define DA7219_ADC_VOICE_EN_MASK (0x1 << 3) | ||
343 | #define DA7219_ADC_AUDIO_HPF_CORNER_SHIFT 4 | ||
344 | #define DA7219_ADC_AUDIO_HPF_CORNER_MASK (0x3 << 4) | ||
345 | #define DA7219_AUDIO_HPF_CORNER_MAX 4 | ||
346 | #define DA7219_ADC_HPF_EN_SHIFT 7 | ||
347 | #define DA7219_ADC_HPF_EN_MASK (0x1 << 7) | ||
348 | #define DA7219_HPF_MODE_SHIFT 0 | ||
349 | #define DA7219_HPF_DISABLED ((0x0 << 3) | (0x0 << 7)) | ||
350 | #define DA7219_HPF_AUDIO_EN ((0x0 << 3) | (0x1 << 7)) | ||
351 | #define DA7219_HPF_VOICE_EN ((0x1 << 3) | (0x1 << 7)) | ||
352 | #define DA7219_HPF_MODE_MASK ((0x1 << 3) | (0x1 << 7)) | ||
353 | #define DA7219_HPF_MODE_MAX 3 | ||
354 | |||
355 | /* DA7219_MIC_1_GAIN = 0x39 */ | ||
356 | #define DA7219_MIC_1_AMP_GAIN_SHIFT 0 | ||
357 | #define DA7219_MIC_1_AMP_GAIN_MASK (0x7 << 0) | ||
358 | |||
359 | /* DA7219_SIDETONE_CTRL = 0x3A */ | ||
360 | #define DA7219_SIDETONE_MUTE_EN_SHIFT 6 | ||
361 | #define DA7219_SIDETONE_MUTE_EN_MASK (0x1 << 6) | ||
362 | #define DA7219_SIDETONE_EN_SHIFT 7 | ||
363 | #define DA7219_SIDETONE_EN_MASK (0x1 << 7) | ||
364 | |||
365 | /* DA7219_SIDETONE_GAIN = 0x3B */ | ||
366 | #define DA7219_SIDETONE_GAIN_SHIFT 0 | ||
367 | #define DA7219_SIDETONE_GAIN_MASK (0xF << 0) | ||
368 | #define DA7219_SIDETONE_GAIN_MAX 0xE | ||
369 | |||
370 | /* DA7219_DROUTING_ST_OUTFILT_1L = 0x3C */ | ||
371 | #define DA7219_OUTFILT_ST_1L_SRC_SHIFT 0 | ||
372 | #define DA7219_OUTFILT_ST_1L_SRC_MASK (0x7 << 0) | ||
373 | #define DA7219_DMIX_ST_SRC_OUTFILT1L_SHIFT 0 | ||
374 | #define DA7219_DMIX_ST_SRC_OUTFILT1R_SHIFT 1 | ||
375 | #define DA7219_DMIX_ST_SRC_SIDETONE_SHIFT 2 | ||
376 | #define DA7219_DMIX_ST_SRC_OUTFILT1L (0x1 << 0) | ||
377 | #define DA7219_DMIX_ST_SRC_OUTFILT1R (0x1 << 1) | ||
378 | |||
379 | /* DA7219_DROUTING_ST_OUTFILT_1R = 0x3D */ | ||
380 | #define DA7219_OUTFILT_ST_1R_SRC_SHIFT 0 | ||
381 | #define DA7219_OUTFILT_ST_1R_SRC_MASK (0x7 << 0) | ||
382 | |||
383 | /* DA7219_DAC_FILTERS5 = 0x40 */ | ||
384 | #define DA7219_DAC_SOFTMUTE_RATE_SHIFT 4 | ||
385 | #define DA7219_DAC_SOFTMUTE_RATE_MASK (0x7 << 4) | ||
386 | #define DA7219_DAC_SOFTMUTE_RATE_MAX 7 | ||
387 | #define DA7219_DAC_SOFTMUTE_EN_SHIFT 7 | ||
388 | #define DA7219_DAC_SOFTMUTE_EN_MASK (0x1 << 7) | ||
389 | |||
390 | /* DA7219_DAC_FILTERS2 = 0x41 */ | ||
391 | #define DA7219_DAC_EQ_BAND1_SHIFT 0 | ||
392 | #define DA7219_DAC_EQ_BAND1_MASK (0xF << 0) | ||
393 | #define DA7219_DAC_EQ_BAND2_SHIFT 4 | ||
394 | #define DA7219_DAC_EQ_BAND2_MASK (0xF << 4) | ||
395 | #define DA7219_DAC_EQ_BAND_MAX 0xF | ||
396 | |||
397 | /* DA7219_DAC_FILTERS3 = 0x42 */ | ||
398 | #define DA7219_DAC_EQ_BAND3_SHIFT 0 | ||
399 | #define DA7219_DAC_EQ_BAND3_MASK (0xF << 0) | ||
400 | #define DA7219_DAC_EQ_BAND4_SHIFT 4 | ||
401 | #define DA7219_DAC_EQ_BAND4_MASK (0xF << 4) | ||
402 | |||
403 | /* DA7219_DAC_FILTERS4 = 0x43 */ | ||
404 | #define DA7219_DAC_EQ_BAND5_SHIFT 0 | ||
405 | #define DA7219_DAC_EQ_BAND5_MASK (0xF << 0) | ||
406 | #define DA7219_DAC_EQ_EN_SHIFT 7 | ||
407 | #define DA7219_DAC_EQ_EN_MASK (0x1 << 7) | ||
408 | |||
409 | /* DA7219_DAC_FILTERS1 = 0x44 */ | ||
410 | #define DA7219_DAC_VOICE_HPF_CORNER_SHIFT 0 | ||
411 | #define DA7219_DAC_VOICE_HPF_CORNER_MASK (0x7 << 0) | ||
412 | #define DA7219_DAC_VOICE_EN_SHIFT 3 | ||
413 | #define DA7219_DAC_VOICE_EN_MASK (0x1 << 3) | ||
414 | #define DA7219_DAC_AUDIO_HPF_CORNER_SHIFT 4 | ||
415 | #define DA7219_DAC_AUDIO_HPF_CORNER_MASK (0x3 << 4) | ||
416 | #define DA7219_DAC_HPF_EN_SHIFT 7 | ||
417 | #define DA7219_DAC_HPF_EN_MASK (0x1 << 7) | ||
418 | |||
419 | /* DA7219_DAC_L_GAIN = 0x45 */ | ||
420 | #define DA7219_DAC_L_DIGITAL_GAIN_SHIFT 0 | ||
421 | #define DA7219_DAC_L_DIGITAL_GAIN_MASK (0x7F << 0) | ||
422 | #define DA7219_DAC_DIGITAL_GAIN_MAX 0x7F | ||
423 | #define DA7219_DAC_DIGITAL_GAIN_0DB (0x6F << 0) | ||
424 | |||
425 | /* DA7219_DAC_R_GAIN = 0x46 */ | ||
426 | #define DA7219_DAC_R_DIGITAL_GAIN_SHIFT 0 | ||
427 | #define DA7219_DAC_R_DIGITAL_GAIN_MASK (0x7F << 0) | ||
428 | |||
429 | /* DA7219_CP_CTRL = 0x47 */ | ||
430 | #define DA7219_CP_MCHANGE_SHIFT 4 | ||
431 | #define DA7219_CP_MCHANGE_MASK (0x3 << 4) | ||
432 | #define DA7219_CP_MCHANGE_REL_MASK 0x3 | ||
433 | #define DA7219_CP_MCHANGE_MAX 3 | ||
434 | #define DA7219_CP_MCHANGE_LARGEST_VOL 0x1 | ||
435 | #define DA7219_CP_MCHANGE_DAC_VOL 0x2 | ||
436 | #define DA7219_CP_MCHANGE_SIG_MAG 0x3 | ||
437 | #define DA7219_CP_EN_SHIFT 7 | ||
438 | #define DA7219_CP_EN_MASK (0x1 << 7) | ||
439 | |||
440 | /* DA7219_HP_L_GAIN = 0x48 */ | ||
441 | #define DA7219_HP_L_AMP_GAIN_SHIFT 0 | ||
442 | #define DA7219_HP_L_AMP_GAIN_MASK (0x3F << 0) | ||
443 | #define DA7219_HP_AMP_GAIN_MAX 0x3F | ||
444 | #define DA7219_HP_AMP_GAIN_0DB (0x39 << 0) | ||
445 | |||
446 | /* DA7219_HP_R_GAIN = 0x49 */ | ||
447 | #define DA7219_HP_R_AMP_GAIN_SHIFT 0 | ||
448 | #define DA7219_HP_R_AMP_GAIN_MASK (0x3F << 0) | ||
449 | |||
450 | /* DA7219_MIXOUT_L_SELECT = 0x4B */ | ||
451 | #define DA7219_MIXOUT_L_MIX_SELECT_SHIFT 0 | ||
452 | #define DA7219_MIXOUT_L_MIX_SELECT_MASK (0x1 << 0) | ||
453 | |||
454 | /* DA7219_MIXOUT_R_SELECT = 0x4C */ | ||
455 | #define DA7219_MIXOUT_R_MIX_SELECT_SHIFT 0 | ||
456 | #define DA7219_MIXOUT_R_MIX_SELECT_MASK (0x1 << 0) | ||
457 | |||
458 | /* DA7219_SYSTEM_MODES_INPUT = 0x50 */ | ||
459 | #define DA7219_MODE_SUBMIT_SHIFT 0 | ||
460 | #define DA7219_MODE_SUBMIT_MASK (0x1 << 0) | ||
461 | #define DA7219_ADC_MODE_SHIFT 1 | ||
462 | #define DA7219_ADC_MODE_MASK (0x7F << 1) | ||
463 | |||
464 | /* DA7219_SYSTEM_MODES_OUTPUT = 0x51 */ | ||
465 | #define DA7219_MODE_SUBMIT_SHIFT 0 | ||
466 | #define DA7219_MODE_SUBMIT_MASK (0x1 << 0) | ||
467 | #define DA7219_DAC_MODE_SHIFT 1 | ||
468 | #define DA7219_DAC_MODE_MASK (0x7F << 1) | ||
469 | |||
470 | /* DA7219_MICBIAS_CTRL = 0x62 */ | ||
471 | #define DA7219_MICBIAS1_LEVEL_SHIFT 0 | ||
472 | #define DA7219_MICBIAS1_LEVEL_MASK (0x7 << 0) | ||
473 | #define DA7219_MICBIAS1_EN_SHIFT 3 | ||
474 | #define DA7219_MICBIAS1_EN_MASK (0x1 << 3) | ||
475 | |||
476 | /* DA7219_MIC_1_CTRL = 0x63 */ | ||
477 | #define DA7219_MIC_1_AMP_RAMP_EN_SHIFT 5 | ||
478 | #define DA7219_MIC_1_AMP_RAMP_EN_MASK (0x1 << 5) | ||
479 | #define DA7219_MIC_1_AMP_MUTE_EN_SHIFT 6 | ||
480 | #define DA7219_MIC_1_AMP_MUTE_EN_MASK (0x1 << 6) | ||
481 | #define DA7219_MIC_1_AMP_EN_SHIFT 7 | ||
482 | #define DA7219_MIC_1_AMP_EN_MASK (0x1 << 7) | ||
483 | |||
484 | /* DA7219_MIXIN_L_CTRL = 0x65 */ | ||
485 | #define DA7219_MIXIN_L_MIX_EN_SHIFT 3 | ||
486 | #define DA7219_MIXIN_L_MIX_EN_MASK (0x1 << 3) | ||
487 | #define DA7219_MIXIN_L_AMP_ZC_EN_SHIFT 4 | ||
488 | #define DA7219_MIXIN_L_AMP_ZC_EN_MASK (0x1 << 4) | ||
489 | #define DA7219_MIXIN_L_AMP_RAMP_EN_SHIFT 5 | ||
490 | #define DA7219_MIXIN_L_AMP_RAMP_EN_MASK (0x1 << 5) | ||
491 | #define DA7219_MIXIN_L_AMP_MUTE_EN_SHIFT 6 | ||
492 | #define DA7219_MIXIN_L_AMP_MUTE_EN_MASK (0x1 << 6) | ||
493 | #define DA7219_MIXIN_L_AMP_EN_SHIFT 7 | ||
494 | #define DA7219_MIXIN_L_AMP_EN_MASK (0x1 << 7) | ||
495 | |||
496 | /* DA7219_ADC_L_CTRL = 0x67 */ | ||
497 | #define DA7219_ADC_L_BIAS_SHIFT 0 | ||
498 | #define DA7219_ADC_L_BIAS_MASK (0x3 << 0) | ||
499 | #define DA7219_ADC_L_RAMP_EN_SHIFT 5 | ||
500 | #define DA7219_ADC_L_RAMP_EN_MASK (0x1 << 5) | ||
501 | #define DA7219_ADC_L_MUTE_EN_SHIFT 6 | ||
502 | #define DA7219_ADC_L_MUTE_EN_MASK (0x1 << 6) | ||
503 | #define DA7219_ADC_L_EN_SHIFT 7 | ||
504 | #define DA7219_ADC_L_EN_MASK (0x1 << 7) | ||
505 | |||
506 | /* DA7219_DAC_L_CTRL = 0x69 */ | ||
507 | #define DA7219_DAC_L_RAMP_EN_SHIFT 5 | ||
508 | #define DA7219_DAC_L_RAMP_EN_MASK (0x1 << 5) | ||
509 | #define DA7219_DAC_L_MUTE_EN_SHIFT 6 | ||
510 | #define DA7219_DAC_L_MUTE_EN_MASK (0x1 << 6) | ||
511 | #define DA7219_DAC_L_EN_SHIFT 7 | ||
512 | #define DA7219_DAC_L_EN_MASK (0x1 << 7) | ||
513 | |||
514 | /* DA7219_DAC_R_CTRL = 0x6A */ | ||
515 | #define DA7219_DAC_R_RAMP_EN_SHIFT 5 | ||
516 | #define DA7219_DAC_R_RAMP_EN_MASK (0x1 << 5) | ||
517 | #define DA7219_DAC_R_MUTE_EN_SHIFT 6 | ||
518 | #define DA7219_DAC_R_MUTE_EN_MASK (0x1 << 6) | ||
519 | #define DA7219_DAC_R_EN_SHIFT 7 | ||
520 | #define DA7219_DAC_R_EN_MASK (0x1 << 7) | ||
521 | |||
522 | /* DA7219_HP_L_CTRL = 0x6B */ | ||
523 | #define DA7219_HP_L_AMP_MIN_GAIN_EN_SHIFT 2 | ||
524 | #define DA7219_HP_L_AMP_MIN_GAIN_EN_MASK (0x1 << 2) | ||
525 | #define DA7219_HP_L_AMP_OE_SHIFT 3 | ||
526 | #define DA7219_HP_L_AMP_OE_MASK (0x1 << 3) | ||
527 | #define DA7219_HP_L_AMP_ZC_EN_SHIFT 4 | ||
528 | #define DA7219_HP_L_AMP_ZC_EN_MASK (0x1 << 4) | ||
529 | #define DA7219_HP_L_AMP_RAMP_EN_SHIFT 5 | ||
530 | #define DA7219_HP_L_AMP_RAMP_EN_MASK (0x1 << 5) | ||
531 | #define DA7219_HP_L_AMP_MUTE_EN_SHIFT 6 | ||
532 | #define DA7219_HP_L_AMP_MUTE_EN_MASK (0x1 << 6) | ||
533 | #define DA7219_HP_L_AMP_EN_SHIFT 7 | ||
534 | #define DA7219_HP_L_AMP_EN_MASK (0x1 << 7) | ||
535 | |||
536 | /* DA7219_HP_R_CTRL = 0x6C */ | ||
537 | #define DA7219_HP_R_AMP_MIN_GAIN_EN_SHIFT 2 | ||
538 | #define DA7219_HP_R_AMP_MIN_GAIN_EN_MASK (0x1 << 2) | ||
539 | #define DA7219_HP_R_AMP_OE_SHIFT 3 | ||
540 | #define DA7219_HP_R_AMP_OE_MASK (0x1 << 3) | ||
541 | #define DA7219_HP_R_AMP_ZC_EN_SHIFT 4 | ||
542 | #define DA7219_HP_R_AMP_ZC_EN_MASK (0x1 << 4) | ||
543 | #define DA7219_HP_R_AMP_RAMP_EN_SHIFT 5 | ||
544 | #define DA7219_HP_R_AMP_RAMP_EN_MASK (0x1 << 5) | ||
545 | #define DA7219_HP_R_AMP_MUTE_EN_SHIFT 6 | ||
546 | #define DA7219_HP_R_AMP_MUTE_EN_MASK (0x1 << 6) | ||
547 | #define DA7219_HP_R_AMP_EN_SHIFT 7 | ||
548 | #define DA7219_HP_R_AMP_EN_MASK (0x1 << 7) | ||
549 | |||
550 | /* DA7219_MIXOUT_L_CTRL = 0x6E */ | ||
551 | #define DA7219_MIXOUT_L_AMP_EN_SHIFT 7 | ||
552 | #define DA7219_MIXOUT_L_AMP_EN_MASK (0x1 << 7) | ||
553 | |||
554 | /* DA7219_MIXOUT_R_CTRL = 0x6F */ | ||
555 | #define DA7219_MIXOUT_R_AMP_EN_SHIFT 7 | ||
556 | #define DA7219_MIXOUT_R_AMP_EN_MASK (0x1 << 7) | ||
557 | |||
558 | /* DA7219_CHIP_ID1 = 0x81 */ | ||
559 | #define DA7219_CHIP_ID1_SHIFT 0 | ||
560 | #define DA7219_CHIP_ID1_MASK (0xFF << 0) | ||
561 | |||
562 | /* DA7219_CHIP_ID2 = 0x82 */ | ||
563 | #define DA7219_CHIP_ID2_SHIFT 0 | ||
564 | #define DA7219_CHIP_ID2_MASK (0xFF << 0) | ||
565 | |||
566 | /* DA7219_CHIP_REVISION = 0x83 */ | ||
567 | #define DA7219_CHIP_MINOR_SHIFT 0 | ||
568 | #define DA7219_CHIP_MINOR_MASK (0xF << 0) | ||
569 | #define DA7219_CHIP_MAJOR_SHIFT 4 | ||
570 | #define DA7219_CHIP_MAJOR_MASK (0xF << 4) | ||
571 | |||
572 | /* DA7219_LDO_CTRL = 0x90 */ | ||
573 | #define DA7219_LDO_LEVEL_SELECT_SHIFT 4 | ||
574 | #define DA7219_LDO_LEVEL_SELECT_MASK (0x3 << 4) | ||
575 | #define DA7219_LDO_EN_SHIFT 7 | ||
576 | #define DA7219_LDO_EN_MASK (0x1 << 7) | ||
577 | |||
578 | /* DA7219_IO_CTRL = 0x91 */ | ||
579 | #define DA7219_IO_VOLTAGE_LEVEL_SHIFT 0 | ||
580 | #define DA7219_IO_VOLTAGE_LEVEL_MASK (0x1 << 0) | ||
581 | #define DA7219_IO_VOLTAGE_LEVEL_2_5V_3_6V 0 | ||
582 | #define DA7219_IO_VOLTAGE_LEVEL_1_2V_2_8V 1 | ||
583 | |||
584 | /* DA7219_GAIN_RAMP_CTRL = 0x92 */ | ||
585 | #define DA7219_GAIN_RAMP_RATE_SHIFT 0 | ||
586 | #define DA7219_GAIN_RAMP_RATE_MASK (0x3 << 0) | ||
587 | #define DA7219_GAIN_RAMP_RATE_MAX 4 | ||
588 | |||
589 | /* DA7219_PC_COUNT = 0x94 */ | ||
590 | #define DA7219_PC_FREERUN_SHIFT 0 | ||
591 | #define DA7219_PC_FREERUN_MASK (0x1 << 0) | ||
592 | #define DA7219_PC_RESYNC_AUTO_SHIFT 1 | ||
593 | #define DA7219_PC_RESYNC_AUTO_MASK (0x1 << 1) | ||
594 | |||
595 | /* DA7219_CP_VOL_THRESHOLD1 = 0x95 */ | ||
596 | #define DA7219_CP_THRESH_VDD2_SHIFT 0 | ||
597 | #define DA7219_CP_THRESH_VDD2_MASK (0x3F << 0) | ||
598 | #define DA7219_CP_THRESH_VDD2_MAX 0x3F | ||
599 | |||
600 | /* DA7219_DIG_CTRL = 0x99 */ | ||
601 | #define DA7219_DAC_L_INV_SHIFT 3 | ||
602 | #define DA7219_DAC_L_INV_MASK (0x1 << 3) | ||
603 | #define DA7219_DAC_R_INV_SHIFT 7 | ||
604 | #define DA7219_DAC_R_INV_MASK (0x1 << 7) | ||
605 | |||
606 | /* DA7219_ALC_CTRL2 = 0x9A */ | ||
607 | #define DA7219_ALC_ATTACK_SHIFT 0 | ||
608 | #define DA7219_ALC_ATTACK_MASK (0xF << 0) | ||
609 | #define DA7219_ALC_ATTACK_MAX 13 | ||
610 | #define DA7219_ALC_RELEASE_SHIFT 4 | ||
611 | #define DA7219_ALC_RELEASE_MASK (0xF << 4) | ||
612 | #define DA7219_ALC_RELEASE_MAX 11 | ||
613 | |||
614 | /* DA7219_ALC_CTRL3 = 0x9B */ | ||
615 | #define DA7219_ALC_HOLD_SHIFT 0 | ||
616 | #define DA7219_ALC_HOLD_MASK (0xF << 0) | ||
617 | #define DA7219_ALC_HOLD_MAX 16 | ||
618 | #define DA7219_ALC_INTEG_ATTACK_SHIFT 4 | ||
619 | #define DA7219_ALC_INTEG_ATTACK_MASK (0x3 << 4) | ||
620 | #define DA7219_ALC_INTEG_RELEASE_SHIFT 6 | ||
621 | #define DA7219_ALC_INTEG_RELEASE_MASK (0x3 << 6) | ||
622 | #define DA7219_ALC_INTEG_MAX 4 | ||
623 | |||
624 | /* DA7219_ALC_NOISE = 0x9C */ | ||
625 | #define DA7219_ALC_NOISE_SHIFT 0 | ||
626 | #define DA7219_ALC_NOISE_MASK (0x3F << 0) | ||
627 | #define DA7219_ALC_THRESHOLD_MAX 0x3F | ||
628 | |||
629 | /* DA7219_ALC_TARGET_MIN = 0x9D */ | ||
630 | #define DA7219_ALC_THRESHOLD_MIN_SHIFT 0 | ||
631 | #define DA7219_ALC_THRESHOLD_MIN_MASK (0x3F << 0) | ||
632 | |||
633 | /* DA7219_ALC_TARGET_MAX = 0x9E */ | ||
634 | #define DA7219_ALC_THRESHOLD_MAX_SHIFT 0 | ||
635 | #define DA7219_ALC_THRESHOLD_MAX_MASK (0x3F << 0) | ||
636 | |||
637 | /* DA7219_ALC_GAIN_LIMITS = 0x9F */ | ||
638 | #define DA7219_ALC_ATTEN_MAX_SHIFT 0 | ||
639 | #define DA7219_ALC_ATTEN_MAX_MASK (0xF << 0) | ||
640 | #define DA7219_ALC_GAIN_MAX_SHIFT 4 | ||
641 | #define DA7219_ALC_GAIN_MAX_MASK (0xF << 4) | ||
642 | #define DA7219_ALC_ATTEN_GAIN_MAX 0xF | ||
643 | |||
644 | /* DA7219_ALC_ANA_GAIN_LIMITS = 0xA0 */ | ||
645 | #define DA7219_ALC_ANA_GAIN_MIN_SHIFT 0 | ||
646 | #define DA7219_ALC_ANA_GAIN_MIN_MASK (0x7 << 0) | ||
647 | #define DA7219_ALC_ANA_GAIN_MIN 0x1 | ||
648 | #define DA7219_ALC_ANA_GAIN_MAX_SHIFT 4 | ||
649 | #define DA7219_ALC_ANA_GAIN_MAX_MASK (0x7 << 4) | ||
650 | #define DA7219_ALC_ANA_GAIN_MAX 0x7 | ||
651 | |||
652 | /* DA7219_ALC_ANTICLIP_CTRL = 0xA1 */ | ||
653 | #define DA7219_ALC_ANTICLIP_STEP_SHIFT 0 | ||
654 | #define DA7219_ALC_ANTICLIP_STEP_MASK (0x3 << 0) | ||
655 | #define DA7219_ALC_ANTICLIP_STEP_MAX 4 | ||
656 | #define DA7219_ALC_ANTIPCLIP_EN_SHIFT 7 | ||
657 | #define DA7219_ALC_ANTIPCLIP_EN_MASK (0x1 << 7) | ||
658 | |||
659 | /* DA7219_ALC_ANTICLIP_LEVEL = 0xA2 */ | ||
660 | #define DA7219_ALC_ANTICLIP_LEVEL_SHIFT 0 | ||
661 | #define DA7219_ALC_ANTICLIP_LEVEL_MASK (0x7F << 0) | ||
662 | |||
663 | /* DA7219_ALC_OFFSET_AUTO_M_L = 0xA3 */ | ||
664 | #define DA7219_ALC_OFFSET_AUTO_M_L_SHIFT 0 | ||
665 | #define DA7219_ALC_OFFSET_AUTO_M_L_MASK (0xFF << 0) | ||
666 | |||
667 | /* DA7219_ALC_OFFSET_AUTO_U_L = 0xA4 */ | ||
668 | #define DA7219_ALC_OFFSET_AUTO_U_L_SHIFT 0 | ||
669 | #define DA7219_ALC_OFFSET_AUTO_U_L_MASK (0xF << 0) | ||
670 | |||
671 | /* DA7219_DAC_NG_SETUP_TIME = 0xAF */ | ||
672 | #define DA7219_DAC_NG_SETUP_TIME_SHIFT 0 | ||
673 | #define DA7219_DAC_NG_SETUP_TIME_MASK (0x3 << 0) | ||
674 | #define DA7219_DAC_NG_SETUP_TIME_MAX 4 | ||
675 | #define DA7219_DAC_NG_RAMPUP_RATE_SHIFT 2 | ||
676 | #define DA7219_DAC_NG_RAMPUP_RATE_MASK (0x1 << 2) | ||
677 | #define DA7219_DAC_NG_RAMPDN_RATE_SHIFT 3 | ||
678 | #define DA7219_DAC_NG_RAMPDN_RATE_MASK (0x1 << 3) | ||
679 | #define DA7219_DAC_NG_RAMP_RATE_MAX 2 | ||
680 | |||
681 | /* DA7219_DAC_NG_OFF_THRESH = 0xB0 */ | ||
682 | #define DA7219_DAC_NG_OFF_THRESHOLD_SHIFT 0 | ||
683 | #define DA7219_DAC_NG_OFF_THRESHOLD_MASK (0x7 << 0) | ||
684 | #define DA7219_DAC_NG_THRESHOLD_MAX 0x7 | ||
685 | |||
686 | /* DA7219_DAC_NG_ON_THRESH = 0xB1 */ | ||
687 | #define DA7219_DAC_NG_ON_THRESHOLD_SHIFT 0 | ||
688 | #define DA7219_DAC_NG_ON_THRESHOLD_MASK (0x7 << 0) | ||
689 | |||
690 | /* DA7219_DAC_NG_CTRL = 0xB2 */ | ||
691 | #define DA7219_DAC_NG_EN_SHIFT 7 | ||
692 | #define DA7219_DAC_NG_EN_MASK (0x1 << 7) | ||
693 | |||
694 | /* DA7219_TONE_GEN_CFG1 = 0xB4 */ | ||
695 | #define DA7219_DTMF_REG_SHIFT 0 | ||
696 | #define DA7219_DTMF_REG_MASK (0xF << 0) | ||
697 | #define DA7219_DTMF_REG_MAX 16 | ||
698 | #define DA7219_DTMF_EN_SHIFT 4 | ||
699 | #define DA7219_DTMF_EN_MASK (0x1 << 4) | ||
700 | #define DA7219_START_STOPN_SHIFT 7 | ||
701 | #define DA7219_START_STOPN_MASK (0x1 << 7) | ||
702 | |||
703 | /* DA7219_TONE_GEN_CFG2 = 0xB5 */ | ||
704 | #define DA7219_SWG_SEL_SHIFT 0 | ||
705 | #define DA7219_SWG_SEL_MASK (0x3 << 0) | ||
706 | #define DA7219_SWG_SEL_MAX 4 | ||
707 | #define DA7219_SWG_SEL_SRAMP (0x3 << 0) | ||
708 | #define DA7219_TONE_GEN_GAIN_SHIFT 4 | ||
709 | #define DA7219_TONE_GEN_GAIN_MASK (0xF << 4) | ||
710 | #define DA7219_TONE_GEN_GAIN_MAX 0xF | ||
711 | #define DA7219_TONE_GEN_GAIN_MINUS_9DB (0x3 << 4) | ||
712 | #define DA7219_TONE_GEN_GAIN_MINUS_15DB (0x5 << 4) | ||
713 | |||
714 | /* DA7219_TONE_GEN_CYCLES = 0xB6 */ | ||
715 | #define DA7219_BEEP_CYCLES_SHIFT 0 | ||
716 | #define DA7219_BEEP_CYCLES_MASK (0x7 << 0) | ||
717 | |||
718 | /* DA7219_TONE_GEN_FREQ1_L = 0xB7 */ | ||
719 | #define DA7219_FREQ1_L_SHIFT 0 | ||
720 | #define DA7219_FREQ1_L_MASK (0xFF << 0) | ||
721 | #define DA7219_FREQ_MAX 0xFFFF | ||
722 | |||
723 | /* DA7219_TONE_GEN_FREQ1_U = 0xB8 */ | ||
724 | #define DA7219_FREQ1_U_SHIFT 0 | ||
725 | #define DA7219_FREQ1_U_MASK (0xFF << 0) | ||
726 | |||
727 | /* DA7219_TONE_GEN_FREQ2_L = 0xB9 */ | ||
728 | #define DA7219_FREQ2_L_SHIFT 0 | ||
729 | #define DA7219_FREQ2_L_MASK (0xFF << 0) | ||
730 | |||
731 | /* DA7219_TONE_GEN_FREQ2_U = 0xBA */ | ||
732 | #define DA7219_FREQ2_U_SHIFT 0 | ||
733 | #define DA7219_FREQ2_U_MASK (0xFF << 0) | ||
734 | |||
735 | /* DA7219_TONE_GEN_ON_PER = 0xBB */ | ||
736 | #define DA7219_BEEP_ON_PER_SHIFT 0 | ||
737 | #define DA7219_BEEP_ON_PER_MASK (0x3F << 0) | ||
738 | #define DA7219_BEEP_ON_OFF_MAX 0x3F | ||
739 | |||
740 | /* DA7219_TONE_GEN_OFF_PER = 0xBC */ | ||
741 | #define DA7219_BEEP_OFF_PER_SHIFT 0 | ||
742 | #define DA7219_BEEP_OFF_PER_MASK (0x3F << 0) | ||
743 | |||
744 | /* DA7219_SYSTEM_STATUS = 0xE0 */ | ||
745 | #define DA7219_SC1_BUSY_SHIFT 0 | ||
746 | #define DA7219_SC1_BUSY_MASK (0x1 << 0) | ||
747 | #define DA7219_SC2_BUSY_SHIFT 1 | ||
748 | #define DA7219_SC2_BUSY_MASK (0x1 << 1) | ||
749 | |||
750 | /* DA7219_SYSTEM_ACTIVE = 0xFD */ | ||
751 | #define DA7219_SYSTEM_ACTIVE_SHIFT 0 | ||
752 | #define DA7219_SYSTEM_ACTIVE_MASK (0x1 << 0) | ||
753 | |||
754 | |||
755 | /* | ||
756 | * General defines & data | ||
757 | */ | ||
758 | |||
759 | /* Register inversion */ | ||
760 | #define DA7219_NO_INVERT 0 | ||
761 | #define DA7219_INVERT 1 | ||
762 | |||
763 | /* Byte related defines */ | ||
764 | #define DA7219_BYTE_SHIFT 8 | ||
765 | #define DA7219_BYTE_MASK 0xFF | ||
766 | |||
767 | /* PLL Output Frequencies */ | ||
768 | #define DA7219_PLL_FREQ_OUT_90316 90316800 | ||
769 | #define DA7219_PLL_FREQ_OUT_98304 98304000 | ||
770 | |||
771 | /* PLL Frequency Dividers */ | ||
772 | #define DA7219_PLL_INDIV_2_5_MHZ_VAL 1 | ||
773 | #define DA7219_PLL_INDIV_5_10_MHZ_VAL 2 | ||
774 | #define DA7219_PLL_INDIV_10_20_MHZ_VAL 4 | ||
775 | #define DA7219_PLL_INDIV_20_40_MHZ_VAL 8 | ||
776 | #define DA7219_PLL_INDIV_40_54_MHZ_VAL 16 | ||
777 | |||
778 | /* SRM */ | ||
779 | #define DA7219_SRM_CHECK_RETRIES 8 | ||
780 | |||
781 | enum da7219_clk_src { | ||
782 | DA7219_CLKSRC_MCLK = 0, | ||
783 | DA7219_CLKSRC_MCLK_SQR, | ||
784 | }; | ||
785 | |||
786 | enum da7219_sys_clk { | ||
787 | DA7219_SYSCLK_MCLK = 0, | ||
788 | DA7219_SYSCLK_PLL, | ||
789 | DA7219_SYSCLK_PLL_SRM, | ||
790 | DA7219_SYSCLK_PLL_32KHZ | ||
791 | }; | ||
792 | |||
793 | /* Regulators */ | ||
794 | enum da7219_supplies { | ||
795 | DA7219_SUPPLY_VDD = 0, | ||
796 | DA7219_SUPPLY_VDDMIC, | ||
797 | DA7219_SUPPLY_VDDIO, | ||
798 | DA7219_NUM_SUPPLIES, | ||
799 | }; | ||
800 | |||
801 | struct da7219_aad_priv; | ||
802 | |||
803 | /* Private data */ | ||
804 | struct da7219_priv { | ||
805 | struct da7219_aad_priv *aad; | ||
806 | struct da7219_pdata *pdata; | ||
807 | |||
808 | struct regulator_bulk_data supplies[DA7219_NUM_SUPPLIES]; | ||
809 | struct regmap *regmap; | ||
810 | struct mutex lock; | ||
811 | |||
812 | struct clk *mclk; | ||
813 | unsigned int mclk_rate; | ||
814 | int clk_src; | ||
815 | |||
816 | bool master; | ||
817 | bool alc_en; | ||
818 | }; | ||
819 | |||
820 | #endif /* __DA7219_H */ | ||
diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index 6a091016e0fc..969e337dc17c 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c | |||
@@ -129,7 +129,7 @@ static int es8328_put_deemph(struct snd_kcontrol *kcontrol, | |||
129 | { | 129 | { |
130 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 130 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
131 | struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec); | 131 | struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec); |
132 | int deemph = ucontrol->value.integer.value[0]; | 132 | unsigned int deemph = ucontrol->value.integer.value[0]; |
133 | int ret; | 133 | int ret; |
134 | 134 | ||
135 | if (deemph > 1) | 135 | if (deemph > 1) |
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c new file mode 100644 index 000000000000..7fc7b4e3f444 --- /dev/null +++ b/sound/soc/codecs/nau8825.c | |||
@@ -0,0 +1,1309 @@ | |||
1 | /* | ||
2 | * Nuvoton NAU8825 audio codec driver | ||
3 | * | ||
4 | * Copyright 2015 Google Chromium project. | ||
5 | * Author: Anatol Pomozov <anatol@chromium.org> | ||
6 | * Copyright 2015 Nuvoton Technology Corp. | ||
7 | * Co-author: Meng-Huang Kuo <mhkuo@nuvoton.com> | ||
8 | * | ||
9 | * Licensed under the GPL-2. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/delay.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/i2c.h> | ||
16 | #include <linux/regmap.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/clk.h> | ||
19 | #include <linux/acpi.h> | ||
20 | #include <linux/math64.h> | ||
21 | |||
22 | #include <sound/initval.h> | ||
23 | #include <sound/tlv.h> | ||
24 | #include <sound/core.h> | ||
25 | #include <sound/pcm.h> | ||
26 | #include <sound/pcm_params.h> | ||
27 | #include <sound/soc.h> | ||
28 | #include <sound/jack.h> | ||
29 | |||
30 | |||
31 | #include "nau8825.h" | ||
32 | |||
33 | #define NAU_FREF_MAX 13500000 | ||
34 | #define NAU_FVCO_MAX 100000000 | ||
35 | #define NAU_FVCO_MIN 90000000 | ||
36 | |||
37 | struct nau8825_fll { | ||
38 | int mclk_src; | ||
39 | int ratio; | ||
40 | int fll_frac; | ||
41 | int fll_int; | ||
42 | int clk_ref_div; | ||
43 | }; | ||
44 | |||
45 | struct nau8825_fll_attr { | ||
46 | unsigned int param; | ||
47 | unsigned int val; | ||
48 | }; | ||
49 | |||
50 | /* scaling for mclk from sysclk_src output */ | ||
51 | static const struct nau8825_fll_attr mclk_src_scaling[] = { | ||
52 | { 1, 0x0 }, | ||
53 | { 2, 0x2 }, | ||
54 | { 4, 0x3 }, | ||
55 | { 8, 0x4 }, | ||
56 | { 16, 0x5 }, | ||
57 | { 32, 0x6 }, | ||
58 | { 3, 0x7 }, | ||
59 | { 6, 0xa }, | ||
60 | { 12, 0xb }, | ||
61 | { 24, 0xc }, | ||
62 | { 48, 0xd }, | ||
63 | { 96, 0xe }, | ||
64 | { 5, 0xf }, | ||
65 | }; | ||
66 | |||
67 | /* ratio for input clk freq */ | ||
68 | static const struct nau8825_fll_attr fll_ratio[] = { | ||
69 | { 512000, 0x01 }, | ||
70 | { 256000, 0x02 }, | ||
71 | { 128000, 0x04 }, | ||
72 | { 64000, 0x08 }, | ||
73 | { 32000, 0x10 }, | ||
74 | { 8000, 0x20 }, | ||
75 | { 4000, 0x40 }, | ||
76 | }; | ||
77 | |||
78 | static const struct nau8825_fll_attr fll_pre_scalar[] = { | ||
79 | { 1, 0x0 }, | ||
80 | { 2, 0x1 }, | ||
81 | { 4, 0x2 }, | ||
82 | { 8, 0x3 }, | ||
83 | }; | ||
84 | |||
85 | static const struct reg_default nau8825_reg_defaults[] = { | ||
86 | { NAU8825_REG_ENA_CTRL, 0x00ff }, | ||
87 | { NAU8825_REG_CLK_DIVIDER, 0x0050 }, | ||
88 | { NAU8825_REG_FLL1, 0x0 }, | ||
89 | { NAU8825_REG_FLL2, 0x3126 }, | ||
90 | { NAU8825_REG_FLL3, 0x0008 }, | ||
91 | { NAU8825_REG_FLL4, 0x0010 }, | ||
92 | { NAU8825_REG_FLL5, 0x0 }, | ||
93 | { NAU8825_REG_FLL6, 0x6000 }, | ||
94 | { NAU8825_REG_FLL_VCO_RSV, 0xf13c }, | ||
95 | { NAU8825_REG_HSD_CTRL, 0x000c }, | ||
96 | { NAU8825_REG_JACK_DET_CTRL, 0x0 }, | ||
97 | { NAU8825_REG_INTERRUPT_MASK, 0x0 }, | ||
98 | { NAU8825_REG_INTERRUPT_DIS_CTRL, 0xffff }, | ||
99 | { NAU8825_REG_SAR_CTRL, 0x0015 }, | ||
100 | { NAU8825_REG_KEYDET_CTRL, 0x0110 }, | ||
101 | { NAU8825_REG_VDET_THRESHOLD_1, 0x0 }, | ||
102 | { NAU8825_REG_VDET_THRESHOLD_2, 0x0 }, | ||
103 | { NAU8825_REG_VDET_THRESHOLD_3, 0x0 }, | ||
104 | { NAU8825_REG_VDET_THRESHOLD_4, 0x0 }, | ||
105 | { NAU8825_REG_GPIO34_CTRL, 0x0 }, | ||
106 | { NAU8825_REG_GPIO12_CTRL, 0x0 }, | ||
107 | { NAU8825_REG_TDM_CTRL, 0x0 }, | ||
108 | { NAU8825_REG_I2S_PCM_CTRL1, 0x000b }, | ||
109 | { NAU8825_REG_I2S_PCM_CTRL2, 0x8010 }, | ||
110 | { NAU8825_REG_LEFT_TIME_SLOT, 0x0 }, | ||
111 | { NAU8825_REG_RIGHT_TIME_SLOT, 0x0 }, | ||
112 | { NAU8825_REG_BIQ_CTRL, 0x0 }, | ||
113 | { NAU8825_REG_BIQ_COF1, 0x0 }, | ||
114 | { NAU8825_REG_BIQ_COF2, 0x0 }, | ||
115 | { NAU8825_REG_BIQ_COF3, 0x0 }, | ||
116 | { NAU8825_REG_BIQ_COF4, 0x0 }, | ||
117 | { NAU8825_REG_BIQ_COF5, 0x0 }, | ||
118 | { NAU8825_REG_BIQ_COF6, 0x0 }, | ||
119 | { NAU8825_REG_BIQ_COF7, 0x0 }, | ||
120 | { NAU8825_REG_BIQ_COF8, 0x0 }, | ||
121 | { NAU8825_REG_BIQ_COF9, 0x0 }, | ||
122 | { NAU8825_REG_BIQ_COF10, 0x0 }, | ||
123 | { NAU8825_REG_ADC_RATE, 0x0010 }, | ||
124 | { NAU8825_REG_DAC_CTRL1, 0x0001 }, | ||
125 | { NAU8825_REG_DAC_CTRL2, 0x0 }, | ||
126 | { NAU8825_REG_DAC_DGAIN_CTRL, 0x0 }, | ||
127 | { NAU8825_REG_ADC_DGAIN_CTRL, 0x00cf }, | ||
128 | { NAU8825_REG_MUTE_CTRL, 0x0 }, | ||
129 | { NAU8825_REG_HSVOL_CTRL, 0x0 }, | ||
130 | { NAU8825_REG_DACL_CTRL, 0x02cf }, | ||
131 | { NAU8825_REG_DACR_CTRL, 0x00cf }, | ||
132 | { NAU8825_REG_ADC_DRC_KNEE_IP12, 0x1486 }, | ||
133 | { NAU8825_REG_ADC_DRC_KNEE_IP34, 0x0f12 }, | ||
134 | { NAU8825_REG_ADC_DRC_SLOPES, 0x25ff }, | ||
135 | { NAU8825_REG_ADC_DRC_ATKDCY, 0x3457 }, | ||
136 | { NAU8825_REG_DAC_DRC_KNEE_IP12, 0x1486 }, | ||
137 | { NAU8825_REG_DAC_DRC_KNEE_IP34, 0x0f12 }, | ||
138 | { NAU8825_REG_DAC_DRC_SLOPES, 0x25f9 }, | ||
139 | { NAU8825_REG_DAC_DRC_ATKDCY, 0x3457 }, | ||
140 | { NAU8825_REG_IMM_MODE_CTRL, 0x0 }, | ||
141 | { NAU8825_REG_CLASSG_CTRL, 0x0 }, | ||
142 | { NAU8825_REG_OPT_EFUSE_CTRL, 0x0 }, | ||
143 | { NAU8825_REG_MISC_CTRL, 0x0 }, | ||
144 | { NAU8825_REG_BIAS_ADJ, 0x0 }, | ||
145 | { NAU8825_REG_TRIM_SETTINGS, 0x0 }, | ||
146 | { NAU8825_REG_ANALOG_CONTROL_1, 0x0 }, | ||
147 | { NAU8825_REG_ANALOG_CONTROL_2, 0x0 }, | ||
148 | { NAU8825_REG_ANALOG_ADC_1, 0x0011 }, | ||
149 | { NAU8825_REG_ANALOG_ADC_2, 0x0020 }, | ||
150 | { NAU8825_REG_RDAC, 0x0008 }, | ||
151 | { NAU8825_REG_MIC_BIAS, 0x0006 }, | ||
152 | { NAU8825_REG_BOOST, 0x0 }, | ||
153 | { NAU8825_REG_FEPGA, 0x0 }, | ||
154 | { NAU8825_REG_POWER_UP_CONTROL, 0x0 }, | ||
155 | { NAU8825_REG_CHARGE_PUMP, 0x0 }, | ||
156 | }; | ||
157 | |||
158 | static bool nau8825_readable_reg(struct device *dev, unsigned int reg) | ||
159 | { | ||
160 | switch (reg) { | ||
161 | case NAU8825_REG_ENA_CTRL: | ||
162 | case NAU8825_REG_CLK_DIVIDER ... NAU8825_REG_FLL_VCO_RSV: | ||
163 | case NAU8825_REG_HSD_CTRL ... NAU8825_REG_JACK_DET_CTRL: | ||
164 | case NAU8825_REG_INTERRUPT_MASK ... NAU8825_REG_KEYDET_CTRL: | ||
165 | case NAU8825_REG_VDET_THRESHOLD_1 ... NAU8825_REG_DACR_CTRL: | ||
166 | case NAU8825_REG_ADC_DRC_KNEE_IP12 ... NAU8825_REG_ADC_DRC_ATKDCY: | ||
167 | case NAU8825_REG_DAC_DRC_KNEE_IP12 ... NAU8825_REG_DAC_DRC_ATKDCY: | ||
168 | case NAU8825_REG_IMM_MODE_CTRL ... NAU8825_REG_IMM_RMS_R: | ||
169 | case NAU8825_REG_CLASSG_CTRL ... NAU8825_REG_OPT_EFUSE_CTRL: | ||
170 | case NAU8825_REG_MISC_CTRL: | ||
171 | case NAU8825_REG_I2C_DEVICE_ID ... NAU8825_REG_SARDOUT_RAM_STATUS: | ||
172 | case NAU8825_REG_BIAS_ADJ: | ||
173 | case NAU8825_REG_TRIM_SETTINGS ... NAU8825_REG_ANALOG_CONTROL_2: | ||
174 | case NAU8825_REG_ANALOG_ADC_1 ... NAU8825_REG_MIC_BIAS: | ||
175 | case NAU8825_REG_BOOST ... NAU8825_REG_FEPGA: | ||
176 | case NAU8825_REG_POWER_UP_CONTROL ... NAU8825_REG_GENERAL_STATUS: | ||
177 | return true; | ||
178 | default: | ||
179 | return false; | ||
180 | } | ||
181 | |||
182 | } | ||
183 | |||
184 | static bool nau8825_writeable_reg(struct device *dev, unsigned int reg) | ||
185 | { | ||
186 | switch (reg) { | ||
187 | case NAU8825_REG_RESET ... NAU8825_REG_ENA_CTRL: | ||
188 | case NAU8825_REG_CLK_DIVIDER ... NAU8825_REG_FLL_VCO_RSV: | ||
189 | case NAU8825_REG_HSD_CTRL ... NAU8825_REG_JACK_DET_CTRL: | ||
190 | case NAU8825_REG_INTERRUPT_MASK: | ||
191 | case NAU8825_REG_INT_CLR_KEY_STATUS ... NAU8825_REG_KEYDET_CTRL: | ||
192 | case NAU8825_REG_VDET_THRESHOLD_1 ... NAU8825_REG_DACR_CTRL: | ||
193 | case NAU8825_REG_ADC_DRC_KNEE_IP12 ... NAU8825_REG_ADC_DRC_ATKDCY: | ||
194 | case NAU8825_REG_DAC_DRC_KNEE_IP12 ... NAU8825_REG_DAC_DRC_ATKDCY: | ||
195 | case NAU8825_REG_IMM_MODE_CTRL: | ||
196 | case NAU8825_REG_CLASSG_CTRL ... NAU8825_REG_OPT_EFUSE_CTRL: | ||
197 | case NAU8825_REG_MISC_CTRL: | ||
198 | case NAU8825_REG_BIAS_ADJ: | ||
199 | case NAU8825_REG_TRIM_SETTINGS ... NAU8825_REG_ANALOG_CONTROL_2: | ||
200 | case NAU8825_REG_ANALOG_ADC_1 ... NAU8825_REG_MIC_BIAS: | ||
201 | case NAU8825_REG_BOOST ... NAU8825_REG_FEPGA: | ||
202 | case NAU8825_REG_POWER_UP_CONTROL ... NAU8825_REG_CHARGE_PUMP: | ||
203 | return true; | ||
204 | default: | ||
205 | return false; | ||
206 | } | ||
207 | } | ||
208 | |||
209 | static bool nau8825_volatile_reg(struct device *dev, unsigned int reg) | ||
210 | { | ||
211 | switch (reg) { | ||
212 | case NAU8825_REG_RESET: | ||
213 | case NAU8825_REG_IRQ_STATUS: | ||
214 | case NAU8825_REG_INT_CLR_KEY_STATUS: | ||
215 | case NAU8825_REG_IMM_RMS_L: | ||
216 | case NAU8825_REG_IMM_RMS_R: | ||
217 | case NAU8825_REG_I2C_DEVICE_ID: | ||
218 | case NAU8825_REG_SARDOUT_RAM_STATUS: | ||
219 | case NAU8825_REG_CHARGE_PUMP_INPUT_READ: | ||
220 | case NAU8825_REG_GENERAL_STATUS: | ||
221 | return true; | ||
222 | default: | ||
223 | return false; | ||
224 | } | ||
225 | } | ||
226 | |||
227 | static int nau8825_pump_event(struct snd_soc_dapm_widget *w, | ||
228 | struct snd_kcontrol *kcontrol, int event) | ||
229 | { | ||
230 | switch (event) { | ||
231 | case SND_SOC_DAPM_POST_PMU: | ||
232 | /* Prevent startup click by letting charge pump to ramp up */ | ||
233 | msleep(10); | ||
234 | break; | ||
235 | default: | ||
236 | return -EINVAL; | ||
237 | } | ||
238 | |||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | static const char * const nau8825_adc_decimation[] = { | ||
243 | "32", "64", "128", "256" | ||
244 | }; | ||
245 | |||
246 | static const struct soc_enum nau8825_adc_decimation_enum = | ||
247 | SOC_ENUM_SINGLE(NAU8825_REG_ADC_RATE, NAU8825_ADC_SYNC_DOWN_SFT, | ||
248 | ARRAY_SIZE(nau8825_adc_decimation), nau8825_adc_decimation); | ||
249 | |||
250 | static const char * const nau8825_dac_oversampl[] = { | ||
251 | "64", "256", "128", "", "32" | ||
252 | }; | ||
253 | |||
254 | static const struct soc_enum nau8825_dac_oversampl_enum = | ||
255 | SOC_ENUM_SINGLE(NAU8825_REG_DAC_CTRL1, NAU8825_DAC_OVERSAMPLE_SFT, | ||
256 | ARRAY_SIZE(nau8825_dac_oversampl), nau8825_dac_oversampl); | ||
257 | |||
258 | static const DECLARE_TLV_DB_MINMAX_MUTE(adc_vol_tlv, -10300, 2400); | ||
259 | static const DECLARE_TLV_DB_MINMAX_MUTE(sidetone_vol_tlv, -4200, 0); | ||
260 | static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -5400, 0); | ||
261 | static const DECLARE_TLV_DB_MINMAX(fepga_gain_tlv, -100, 3600); | ||
262 | static const DECLARE_TLV_DB_MINMAX_MUTE(crosstalk_vol_tlv, -9600, 2400); | ||
263 | |||
264 | static const struct snd_kcontrol_new nau8825_controls[] = { | ||
265 | SOC_SINGLE_TLV("Mic Volume", NAU8825_REG_ADC_DGAIN_CTRL, | ||
266 | 0, 0xff, 0, adc_vol_tlv), | ||
267 | SOC_DOUBLE_TLV("Headphone Bypass Volume", NAU8825_REG_ADC_DGAIN_CTRL, | ||
268 | 12, 8, 0x0f, 0, sidetone_vol_tlv), | ||
269 | SOC_DOUBLE_TLV("Headphone Volume", NAU8825_REG_HSVOL_CTRL, | ||
270 | 6, 0, 0x3f, 1, dac_vol_tlv), | ||
271 | SOC_SINGLE_TLV("Frontend PGA Volume", NAU8825_REG_POWER_UP_CONTROL, | ||
272 | 8, 37, 0, fepga_gain_tlv), | ||
273 | SOC_DOUBLE_TLV("Headphone Crosstalk Volume", NAU8825_REG_DAC_DGAIN_CTRL, | ||
274 | 0, 8, 0xff, 0, crosstalk_vol_tlv), | ||
275 | |||
276 | SOC_ENUM("ADC Decimation Rate", nau8825_adc_decimation_enum), | ||
277 | SOC_ENUM("DAC Oversampling Rate", nau8825_dac_oversampl_enum), | ||
278 | }; | ||
279 | |||
280 | /* DAC Mux 0x33[9] and 0x34[9] */ | ||
281 | static const char * const nau8825_dac_src[] = { | ||
282 | "DACL", "DACR", | ||
283 | }; | ||
284 | |||
285 | static SOC_ENUM_SINGLE_DECL( | ||
286 | nau8825_dacl_enum, NAU8825_REG_DACL_CTRL, | ||
287 | NAU8825_DACL_CH_SEL_SFT, nau8825_dac_src); | ||
288 | |||
289 | static SOC_ENUM_SINGLE_DECL( | ||
290 | nau8825_dacr_enum, NAU8825_REG_DACR_CTRL, | ||
291 | NAU8825_DACR_CH_SEL_SFT, nau8825_dac_src); | ||
292 | |||
293 | static const struct snd_kcontrol_new nau8825_dacl_mux = | ||
294 | SOC_DAPM_ENUM("DACL Source", nau8825_dacl_enum); | ||
295 | |||
296 | static const struct snd_kcontrol_new nau8825_dacr_mux = | ||
297 | SOC_DAPM_ENUM("DACR Source", nau8825_dacr_enum); | ||
298 | |||
299 | |||
300 | static const struct snd_soc_dapm_widget nau8825_dapm_widgets[] = { | ||
301 | SND_SOC_DAPM_AIF_OUT("AIFTX", "Capture", 0, NAU8825_REG_I2S_PCM_CTRL2, | ||
302 | 15, 1), | ||
303 | |||
304 | SND_SOC_DAPM_INPUT("MIC"), | ||
305 | SND_SOC_DAPM_MICBIAS("MICBIAS", NAU8825_REG_MIC_BIAS, 8, 0), | ||
306 | |||
307 | SND_SOC_DAPM_PGA("Frontend PGA", NAU8825_REG_POWER_UP_CONTROL, 14, 0, | ||
308 | NULL, 0), | ||
309 | |||
310 | SND_SOC_DAPM_ADC("ADC", NULL, NAU8825_REG_ENA_CTRL, 8, 0), | ||
311 | SND_SOC_DAPM_SUPPLY("ADC Clock", NAU8825_REG_ENA_CTRL, 7, 0, NULL, 0), | ||
312 | SND_SOC_DAPM_SUPPLY("ADC Power", NAU8825_REG_ANALOG_ADC_2, 6, 0, NULL, | ||
313 | 0), | ||
314 | |||
315 | /* ADC for button press detection */ | ||
316 | SND_SOC_DAPM_ADC("SAR", NULL, NAU8825_REG_SAR_CTRL, | ||
317 | NAU8825_SAR_ADC_EN_SFT, 0), | ||
318 | |||
319 | SND_SOC_DAPM_DAC("ADACL", NULL, NAU8825_REG_RDAC, 12, 0), | ||
320 | SND_SOC_DAPM_DAC("ADACR", NULL, NAU8825_REG_RDAC, 13, 0), | ||
321 | SND_SOC_DAPM_SUPPLY("ADACL Clock", NAU8825_REG_RDAC, 8, 0, NULL, 0), | ||
322 | SND_SOC_DAPM_SUPPLY("ADACR Clock", NAU8825_REG_RDAC, 9, 0, NULL, 0), | ||
323 | |||
324 | SND_SOC_DAPM_DAC("DDACR", NULL, NAU8825_REG_ENA_CTRL, | ||
325 | NAU8825_ENABLE_DACR_SFT, 0), | ||
326 | SND_SOC_DAPM_DAC("DDACL", NULL, NAU8825_REG_ENA_CTRL, | ||
327 | NAU8825_ENABLE_DACL_SFT, 0), | ||
328 | SND_SOC_DAPM_SUPPLY("DDAC Clock", NAU8825_REG_ENA_CTRL, 6, 0, NULL, 0), | ||
329 | |||
330 | SND_SOC_DAPM_MUX("DACL Mux", SND_SOC_NOPM, 0, 0, &nau8825_dacl_mux), | ||
331 | SND_SOC_DAPM_MUX("DACR Mux", SND_SOC_NOPM, 0, 0, &nau8825_dacr_mux), | ||
332 | |||
333 | SND_SOC_DAPM_PGA("HP amp L", NAU8825_REG_CLASSG_CTRL, 1, 0, NULL, 0), | ||
334 | SND_SOC_DAPM_PGA("HP amp R", NAU8825_REG_CLASSG_CTRL, 2, 0, NULL, 0), | ||
335 | SND_SOC_DAPM_SUPPLY("HP amp power", NAU8825_REG_CLASSG_CTRL, 0, 0, NULL, | ||
336 | 0), | ||
337 | |||
338 | SND_SOC_DAPM_SUPPLY("Charge Pump", NAU8825_REG_CHARGE_PUMP, 5, 0, | ||
339 | nau8825_pump_event, SND_SOC_DAPM_POST_PMU), | ||
340 | |||
341 | SND_SOC_DAPM_PGA("Output Driver R Stage 1", | ||
342 | NAU8825_REG_POWER_UP_CONTROL, 5, 0, NULL, 0), | ||
343 | SND_SOC_DAPM_PGA("Output Driver L Stage 1", | ||
344 | NAU8825_REG_POWER_UP_CONTROL, 4, 0, NULL, 0), | ||
345 | SND_SOC_DAPM_PGA("Output Driver R Stage 2", | ||
346 | NAU8825_REG_POWER_UP_CONTROL, 3, 0, NULL, 0), | ||
347 | SND_SOC_DAPM_PGA("Output Driver L Stage 2", | ||
348 | NAU8825_REG_POWER_UP_CONTROL, 2, 0, NULL, 0), | ||
349 | SND_SOC_DAPM_PGA_S("Output Driver R Stage 3", 1, | ||
350 | NAU8825_REG_POWER_UP_CONTROL, 1, 0, NULL, 0), | ||
351 | SND_SOC_DAPM_PGA_S("Output Driver L Stage 3", 1, | ||
352 | NAU8825_REG_POWER_UP_CONTROL, 0, 0, NULL, 0), | ||
353 | |||
354 | SND_SOC_DAPM_PGA_S("Output DACL", 2, NAU8825_REG_CHARGE_PUMP, 8, 1, NULL, 0), | ||
355 | SND_SOC_DAPM_PGA_S("Output DACR", 2, NAU8825_REG_CHARGE_PUMP, 9, 1, NULL, 0), | ||
356 | |||
357 | SND_SOC_DAPM_OUTPUT("HPOL"), | ||
358 | SND_SOC_DAPM_OUTPUT("HPOR"), | ||
359 | }; | ||
360 | |||
361 | static const struct snd_soc_dapm_route nau8825_dapm_routes[] = { | ||
362 | {"Frontend PGA", NULL, "MIC"}, | ||
363 | {"ADC", NULL, "Frontend PGA"}, | ||
364 | {"ADC", NULL, "ADC Clock"}, | ||
365 | {"ADC", NULL, "ADC Power"}, | ||
366 | {"AIFTX", NULL, "ADC"}, | ||
367 | |||
368 | {"DDACL", NULL, "Playback"}, | ||
369 | {"DDACR", NULL, "Playback"}, | ||
370 | {"DDACL", NULL, "DDAC Clock"}, | ||
371 | {"DDACR", NULL, "DDAC Clock"}, | ||
372 | {"DACL Mux", "DACL", "DDACL"}, | ||
373 | {"DACL Mux", "DACR", "DDACR"}, | ||
374 | {"DACR Mux", "DACL", "DDACL"}, | ||
375 | {"DACR Mux", "DACR", "DDACR"}, | ||
376 | {"HP amp L", NULL, "DACL Mux"}, | ||
377 | {"HP amp R", NULL, "DACR Mux"}, | ||
378 | {"HP amp L", NULL, "HP amp power"}, | ||
379 | {"HP amp R", NULL, "HP amp power"}, | ||
380 | {"ADACL", NULL, "HP amp L"}, | ||
381 | {"ADACR", NULL, "HP amp R"}, | ||
382 | {"ADACL", NULL, "ADACL Clock"}, | ||
383 | {"ADACR", NULL, "ADACR Clock"}, | ||
384 | {"Output Driver L Stage 1", NULL, "ADACL"}, | ||
385 | {"Output Driver R Stage 1", NULL, "ADACR"}, | ||
386 | {"Output Driver L Stage 2", NULL, "Output Driver L Stage 1"}, | ||
387 | {"Output Driver R Stage 2", NULL, "Output Driver R Stage 1"}, | ||
388 | {"Output Driver L Stage 3", NULL, "Output Driver L Stage 2"}, | ||
389 | {"Output Driver R Stage 3", NULL, "Output Driver R Stage 2"}, | ||
390 | {"Output DACL", NULL, "Output Driver L Stage 3"}, | ||
391 | {"Output DACR", NULL, "Output Driver R Stage 3"}, | ||
392 | {"HPOL", NULL, "Output DACL"}, | ||
393 | {"HPOR", NULL, "Output DACR"}, | ||
394 | {"HPOL", NULL, "Charge Pump"}, | ||
395 | {"HPOR", NULL, "Charge Pump"}, | ||
396 | }; | ||
397 | |||
398 | static int nau8825_hw_params(struct snd_pcm_substream *substream, | ||
399 | struct snd_pcm_hw_params *params, | ||
400 | struct snd_soc_dai *dai) | ||
401 | { | ||
402 | struct snd_soc_codec *codec = dai->codec; | ||
403 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | ||
404 | unsigned int val_len = 0; | ||
405 | |||
406 | switch (params_width(params)) { | ||
407 | case 16: | ||
408 | val_len |= NAU8825_I2S_DL_16; | ||
409 | break; | ||
410 | case 20: | ||
411 | val_len |= NAU8825_I2S_DL_20; | ||
412 | break; | ||
413 | case 24: | ||
414 | val_len |= NAU8825_I2S_DL_24; | ||
415 | break; | ||
416 | case 32: | ||
417 | val_len |= NAU8825_I2S_DL_32; | ||
418 | break; | ||
419 | default: | ||
420 | return -EINVAL; | ||
421 | } | ||
422 | |||
423 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL1, | ||
424 | NAU8825_I2S_DL_MASK, val_len); | ||
425 | |||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | ||
430 | { | ||
431 | struct snd_soc_codec *codec = codec_dai->codec; | ||
432 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | ||
433 | unsigned int ctrl1_val = 0, ctrl2_val = 0; | ||
434 | |||
435 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
436 | case SND_SOC_DAIFMT_CBM_CFM: | ||
437 | ctrl2_val |= NAU8825_I2S_MS_MASTER; | ||
438 | break; | ||
439 | case SND_SOC_DAIFMT_CBS_CFS: | ||
440 | break; | ||
441 | default: | ||
442 | return -EINVAL; | ||
443 | } | ||
444 | |||
445 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
446 | case SND_SOC_DAIFMT_NB_NF: | ||
447 | break; | ||
448 | case SND_SOC_DAIFMT_IB_NF: | ||
449 | ctrl1_val |= NAU8825_I2S_BP_INV; | ||
450 | break; | ||
451 | default: | ||
452 | return -EINVAL; | ||
453 | } | ||
454 | |||
455 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
456 | case SND_SOC_DAIFMT_I2S: | ||
457 | ctrl1_val |= NAU8825_I2S_DF_I2S; | ||
458 | break; | ||
459 | case SND_SOC_DAIFMT_LEFT_J: | ||
460 | ctrl1_val |= NAU8825_I2S_DF_LEFT; | ||
461 | break; | ||
462 | case SND_SOC_DAIFMT_RIGHT_J: | ||
463 | ctrl1_val |= NAU8825_I2S_DF_RIGTH; | ||
464 | break; | ||
465 | case SND_SOC_DAIFMT_DSP_A: | ||
466 | ctrl1_val |= NAU8825_I2S_DF_PCM_AB; | ||
467 | break; | ||
468 | case SND_SOC_DAIFMT_DSP_B: | ||
469 | ctrl1_val |= NAU8825_I2S_DF_PCM_AB; | ||
470 | ctrl1_val |= NAU8825_I2S_PCMB_EN; | ||
471 | break; | ||
472 | default: | ||
473 | return -EINVAL; | ||
474 | } | ||
475 | |||
476 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL1, | ||
477 | NAU8825_I2S_DL_MASK | NAU8825_I2S_DF_MASK | | ||
478 | NAU8825_I2S_BP_MASK | NAU8825_I2S_PCMB_MASK, | ||
479 | ctrl1_val); | ||
480 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, | ||
481 | NAU8825_I2S_MS_MASK, ctrl2_val); | ||
482 | |||
483 | return 0; | ||
484 | } | ||
485 | |||
486 | static const struct snd_soc_dai_ops nau8825_dai_ops = { | ||
487 | .hw_params = nau8825_hw_params, | ||
488 | .set_fmt = nau8825_set_dai_fmt, | ||
489 | }; | ||
490 | |||
491 | #define NAU8825_RATES SNDRV_PCM_RATE_8000_192000 | ||
492 | #define NAU8825_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE \ | ||
493 | | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) | ||
494 | |||
495 | static struct snd_soc_dai_driver nau8825_dai = { | ||
496 | .name = "nau8825-hifi", | ||
497 | .playback = { | ||
498 | .stream_name = "Playback", | ||
499 | .channels_min = 1, | ||
500 | .channels_max = 2, | ||
501 | .rates = NAU8825_RATES, | ||
502 | .formats = NAU8825_FORMATS, | ||
503 | }, | ||
504 | .capture = { | ||
505 | .stream_name = "Capture", | ||
506 | .channels_min = 1, | ||
507 | .channels_max = 1, | ||
508 | .rates = NAU8825_RATES, | ||
509 | .formats = NAU8825_FORMATS, | ||
510 | }, | ||
511 | .ops = &nau8825_dai_ops, | ||
512 | }; | ||
513 | |||
514 | /** | ||
515 | * nau8825_enable_jack_detect - Specify a jack for event reporting | ||
516 | * | ||
517 | * @component: component to register the jack with | ||
518 | * @jack: jack to use to report headset and button events on | ||
519 | * | ||
520 | * After this function has been called the headset insert/remove and button | ||
521 | * events will be routed to the given jack. Jack can be null to stop | ||
522 | * reporting. | ||
523 | */ | ||
524 | int nau8825_enable_jack_detect(struct snd_soc_codec *codec, | ||
525 | struct snd_soc_jack *jack) | ||
526 | { | ||
527 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | ||
528 | struct regmap *regmap = nau8825->regmap; | ||
529 | |||
530 | nau8825->jack = jack; | ||
531 | |||
532 | /* Ground HP Outputs[1:0], needed for headset auto detection | ||
533 | * Enable Automatic Mic/Gnd switching reading on insert interrupt[6] | ||
534 | */ | ||
535 | regmap_update_bits(regmap, NAU8825_REG_HSD_CTRL, | ||
536 | NAU8825_HSD_AUTO_MODE | NAU8825_SPKR_DWN1R | NAU8825_SPKR_DWN1L, | ||
537 | NAU8825_HSD_AUTO_MODE | NAU8825_SPKR_DWN1R | NAU8825_SPKR_DWN1L); | ||
538 | |||
539 | regmap_update_bits(regmap, NAU8825_REG_INTERRUPT_MASK, | ||
540 | NAU8825_IRQ_HEADSET_COMPLETE_EN | NAU8825_IRQ_EJECT_EN, 0); | ||
541 | |||
542 | return 0; | ||
543 | } | ||
544 | EXPORT_SYMBOL_GPL(nau8825_enable_jack_detect); | ||
545 | |||
546 | |||
547 | static bool nau8825_is_jack_inserted(struct regmap *regmap) | ||
548 | { | ||
549 | int status; | ||
550 | |||
551 | regmap_read(regmap, NAU8825_REG_I2C_DEVICE_ID, &status); | ||
552 | return !(status & NAU8825_GPIO2JD1); | ||
553 | } | ||
554 | |||
555 | static void nau8825_restart_jack_detection(struct regmap *regmap) | ||
556 | { | ||
557 | /* this will restart the entire jack detection process including MIC/GND | ||
558 | * switching and create interrupts. We have to go from 0 to 1 and back | ||
559 | * to 0 to restart. | ||
560 | */ | ||
561 | regmap_update_bits(regmap, NAU8825_REG_JACK_DET_CTRL, | ||
562 | NAU8825_JACK_DET_RESTART, NAU8825_JACK_DET_RESTART); | ||
563 | regmap_update_bits(regmap, NAU8825_REG_JACK_DET_CTRL, | ||
564 | NAU8825_JACK_DET_RESTART, 0); | ||
565 | } | ||
566 | |||
567 | static void nau8825_eject_jack(struct nau8825 *nau8825) | ||
568 | { | ||
569 | struct snd_soc_dapm_context *dapm = nau8825->dapm; | ||
570 | struct regmap *regmap = nau8825->regmap; | ||
571 | |||
572 | snd_soc_dapm_disable_pin(dapm, "SAR"); | ||
573 | snd_soc_dapm_disable_pin(dapm, "MICBIAS"); | ||
574 | /* Detach 2kOhm Resistors from MICBIAS to MICGND1/2 */ | ||
575 | regmap_update_bits(regmap, NAU8825_REG_MIC_BIAS, | ||
576 | NAU8825_MICBIAS_JKSLV | NAU8825_MICBIAS_JKR2, 0); | ||
577 | /* ground HPL/HPR, MICGRND1/2 */ | ||
578 | regmap_update_bits(regmap, NAU8825_REG_HSD_CTRL, 0xf, 0xf); | ||
579 | |||
580 | snd_soc_dapm_sync(dapm); | ||
581 | } | ||
582 | |||
583 | static int nau8825_button_decode(int value) | ||
584 | { | ||
585 | int buttons = 0; | ||
586 | |||
587 | /* The chip supports up to 8 buttons, but ALSA defines only 6 buttons */ | ||
588 | if (value & BIT(0)) | ||
589 | buttons |= SND_JACK_BTN_0; | ||
590 | if (value & BIT(1)) | ||
591 | buttons |= SND_JACK_BTN_1; | ||
592 | if (value & BIT(2)) | ||
593 | buttons |= SND_JACK_BTN_2; | ||
594 | if (value & BIT(3)) | ||
595 | buttons |= SND_JACK_BTN_3; | ||
596 | if (value & BIT(4)) | ||
597 | buttons |= SND_JACK_BTN_4; | ||
598 | if (value & BIT(5)) | ||
599 | buttons |= SND_JACK_BTN_5; | ||
600 | |||
601 | return buttons; | ||
602 | } | ||
603 | |||
604 | static int nau8825_jack_insert(struct nau8825 *nau8825) | ||
605 | { | ||
606 | struct regmap *regmap = nau8825->regmap; | ||
607 | struct snd_soc_dapm_context *dapm = nau8825->dapm; | ||
608 | int jack_status_reg, mic_detected; | ||
609 | int type = 0; | ||
610 | |||
611 | regmap_read(regmap, NAU8825_REG_GENERAL_STATUS, &jack_status_reg); | ||
612 | mic_detected = (jack_status_reg >> 10) & 3; | ||
613 | |||
614 | switch (mic_detected) { | ||
615 | case 0: | ||
616 | /* no mic */ | ||
617 | type = SND_JACK_HEADPHONE; | ||
618 | break; | ||
619 | case 1: | ||
620 | dev_dbg(nau8825->dev, "OMTP (micgnd1) mic connected\n"); | ||
621 | type = SND_JACK_HEADSET; | ||
622 | |||
623 | /* Unground MICGND1 */ | ||
624 | regmap_update_bits(regmap, NAU8825_REG_HSD_CTRL, 3 << 2, | ||
625 | 1 << 2); | ||
626 | /* Attach 2kOhm Resistor from MICBIAS to MICGND1 */ | ||
627 | regmap_update_bits(regmap, NAU8825_REG_MIC_BIAS, | ||
628 | NAU8825_MICBIAS_JKSLV | NAU8825_MICBIAS_JKR2, | ||
629 | NAU8825_MICBIAS_JKR2); | ||
630 | /* Attach SARADC to MICGND1 */ | ||
631 | regmap_update_bits(regmap, NAU8825_REG_SAR_CTRL, | ||
632 | NAU8825_SAR_INPUT_MASK, | ||
633 | NAU8825_SAR_INPUT_JKR2); | ||
634 | |||
635 | snd_soc_dapm_force_enable_pin(dapm, "MICBIAS"); | ||
636 | snd_soc_dapm_force_enable_pin(dapm, "SAR"); | ||
637 | snd_soc_dapm_sync(dapm); | ||
638 | break; | ||
639 | case 2: | ||
640 | case 3: | ||
641 | dev_dbg(nau8825->dev, "CTIA (micgnd2) mic connected\n"); | ||
642 | type = SND_JACK_HEADSET; | ||
643 | |||
644 | /* Unground MICGND2 */ | ||
645 | regmap_update_bits(regmap, NAU8825_REG_HSD_CTRL, 3 << 2, | ||
646 | 2 << 2); | ||
647 | /* Attach 2kOhm Resistor from MICBIAS to MICGND2 */ | ||
648 | regmap_update_bits(regmap, NAU8825_REG_MIC_BIAS, | ||
649 | NAU8825_MICBIAS_JKSLV | NAU8825_MICBIAS_JKR2, | ||
650 | NAU8825_MICBIAS_JKSLV); | ||
651 | /* Attach SARADC to MICGND2 */ | ||
652 | regmap_update_bits(regmap, NAU8825_REG_SAR_CTRL, | ||
653 | NAU8825_SAR_INPUT_MASK, | ||
654 | NAU8825_SAR_INPUT_JKSLV); | ||
655 | |||
656 | snd_soc_dapm_force_enable_pin(dapm, "MICBIAS"); | ||
657 | snd_soc_dapm_force_enable_pin(dapm, "SAR"); | ||
658 | snd_soc_dapm_sync(dapm); | ||
659 | break; | ||
660 | } | ||
661 | |||
662 | if (type & SND_JACK_HEADPHONE) { | ||
663 | /* Unground HPL/R */ | ||
664 | regmap_update_bits(regmap, NAU8825_REG_HSD_CTRL, 0x3, 0); | ||
665 | } | ||
666 | |||
667 | return type; | ||
668 | } | ||
669 | |||
670 | #define NAU8825_BUTTONS (SND_JACK_BTN_0 | SND_JACK_BTN_1 | \ | ||
671 | SND_JACK_BTN_2 | SND_JACK_BTN_3) | ||
672 | |||
673 | static irqreturn_t nau8825_interrupt(int irq, void *data) | ||
674 | { | ||
675 | struct nau8825 *nau8825 = (struct nau8825 *)data; | ||
676 | struct regmap *regmap = nau8825->regmap; | ||
677 | int active_irq, clear_irq = 0, event = 0, event_mask = 0; | ||
678 | |||
679 | regmap_read(regmap, NAU8825_REG_IRQ_STATUS, &active_irq); | ||
680 | |||
681 | if ((active_irq & NAU8825_JACK_EJECTION_IRQ_MASK) == | ||
682 | NAU8825_JACK_EJECTION_DETECTED) { | ||
683 | |||
684 | nau8825_eject_jack(nau8825); | ||
685 | event_mask |= SND_JACK_HEADSET; | ||
686 | clear_irq = NAU8825_JACK_EJECTION_IRQ_MASK; | ||
687 | } else if (active_irq & NAU8825_KEY_SHORT_PRESS_IRQ) { | ||
688 | int key_status; | ||
689 | |||
690 | regmap_read(regmap, NAU8825_REG_INT_CLR_KEY_STATUS, | ||
691 | &key_status); | ||
692 | |||
693 | /* upper 8 bits of the register are for short pressed keys, | ||
694 | * lower 8 bits - for long pressed buttons | ||
695 | */ | ||
696 | nau8825->button_pressed = nau8825_button_decode( | ||
697 | key_status >> 8); | ||
698 | |||
699 | event |= nau8825->button_pressed; | ||
700 | event_mask |= NAU8825_BUTTONS; | ||
701 | clear_irq = NAU8825_KEY_SHORT_PRESS_IRQ; | ||
702 | } else if (active_irq & NAU8825_KEY_RELEASE_IRQ) { | ||
703 | event_mask = NAU8825_BUTTONS; | ||
704 | clear_irq = NAU8825_KEY_RELEASE_IRQ; | ||
705 | } else if (active_irq & NAU8825_HEADSET_COMPLETION_IRQ) { | ||
706 | if (nau8825_is_jack_inserted(regmap)) { | ||
707 | event |= nau8825_jack_insert(nau8825); | ||
708 | } else { | ||
709 | dev_warn(nau8825->dev, "Headset completion IRQ fired but no headset connected\n"); | ||
710 | nau8825_eject_jack(nau8825); | ||
711 | } | ||
712 | |||
713 | event_mask |= SND_JACK_HEADSET; | ||
714 | clear_irq = NAU8825_HEADSET_COMPLETION_IRQ; | ||
715 | } | ||
716 | |||
717 | if (!clear_irq) | ||
718 | clear_irq = active_irq; | ||
719 | /* clears the rightmost interruption */ | ||
720 | regmap_write(regmap, NAU8825_REG_INT_CLR_KEY_STATUS, clear_irq); | ||
721 | |||
722 | if (event_mask) | ||
723 | snd_soc_jack_report(nau8825->jack, event, event_mask); | ||
724 | |||
725 | return IRQ_HANDLED; | ||
726 | } | ||
727 | |||
728 | static void nau8825_setup_buttons(struct nau8825 *nau8825) | ||
729 | { | ||
730 | struct regmap *regmap = nau8825->regmap; | ||
731 | |||
732 | regmap_update_bits(regmap, NAU8825_REG_SAR_CTRL, | ||
733 | NAU8825_SAR_TRACKING_GAIN_MASK, | ||
734 | nau8825->sar_voltage << NAU8825_SAR_TRACKING_GAIN_SFT); | ||
735 | regmap_update_bits(regmap, NAU8825_REG_SAR_CTRL, | ||
736 | NAU8825_SAR_COMPARE_TIME_MASK, | ||
737 | nau8825->sar_compare_time << NAU8825_SAR_COMPARE_TIME_SFT); | ||
738 | regmap_update_bits(regmap, NAU8825_REG_SAR_CTRL, | ||
739 | NAU8825_SAR_SAMPLING_TIME_MASK, | ||
740 | nau8825->sar_sampling_time << NAU8825_SAR_SAMPLING_TIME_SFT); | ||
741 | |||
742 | regmap_update_bits(regmap, NAU8825_REG_KEYDET_CTRL, | ||
743 | NAU8825_KEYDET_LEVELS_NR_MASK, | ||
744 | (nau8825->sar_threshold_num - 1) << NAU8825_KEYDET_LEVELS_NR_SFT); | ||
745 | regmap_update_bits(regmap, NAU8825_REG_KEYDET_CTRL, | ||
746 | NAU8825_KEYDET_HYSTERESIS_MASK, | ||
747 | nau8825->sar_hysteresis << NAU8825_KEYDET_HYSTERESIS_SFT); | ||
748 | regmap_update_bits(regmap, NAU8825_REG_KEYDET_CTRL, | ||
749 | NAU8825_KEYDET_SHORTKEY_DEBOUNCE_MASK, | ||
750 | nau8825->key_debounce << NAU8825_KEYDET_SHORTKEY_DEBOUNCE_SFT); | ||
751 | |||
752 | regmap_write(regmap, NAU8825_REG_VDET_THRESHOLD_1, | ||
753 | (nau8825->sar_threshold[0] << 8) | nau8825->sar_threshold[1]); | ||
754 | regmap_write(regmap, NAU8825_REG_VDET_THRESHOLD_2, | ||
755 | (nau8825->sar_threshold[2] << 8) | nau8825->sar_threshold[3]); | ||
756 | regmap_write(regmap, NAU8825_REG_VDET_THRESHOLD_3, | ||
757 | (nau8825->sar_threshold[4] << 8) | nau8825->sar_threshold[5]); | ||
758 | regmap_write(regmap, NAU8825_REG_VDET_THRESHOLD_4, | ||
759 | (nau8825->sar_threshold[6] << 8) | nau8825->sar_threshold[7]); | ||
760 | |||
761 | /* Enable short press and release interruptions */ | ||
762 | regmap_update_bits(regmap, NAU8825_REG_INTERRUPT_MASK, | ||
763 | NAU8825_IRQ_KEY_SHORT_PRESS_EN | NAU8825_IRQ_KEY_RELEASE_EN, | ||
764 | 0); | ||
765 | } | ||
766 | |||
767 | static void nau8825_init_regs(struct nau8825 *nau8825) | ||
768 | { | ||
769 | struct regmap *regmap = nau8825->regmap; | ||
770 | |||
771 | /* Enable Bias/Vmid */ | ||
772 | regmap_update_bits(nau8825->regmap, NAU8825_REG_BIAS_ADJ, | ||
773 | NAU8825_BIAS_VMID, NAU8825_BIAS_VMID); | ||
774 | regmap_update_bits(nau8825->regmap, NAU8825_REG_BOOST, | ||
775 | NAU8825_GLOBAL_BIAS_EN, NAU8825_GLOBAL_BIAS_EN); | ||
776 | |||
777 | /* VMID Tieoff */ | ||
778 | regmap_update_bits(regmap, NAU8825_REG_BIAS_ADJ, | ||
779 | NAU8825_BIAS_VMID_SEL_MASK, | ||
780 | nau8825->vref_impedance << NAU8825_BIAS_VMID_SEL_SFT); | ||
781 | /* Disable Boost Driver, Automatic Short circuit protection enable */ | ||
782 | regmap_update_bits(regmap, NAU8825_REG_BOOST, | ||
783 | NAU8825_PRECHARGE_DIS | NAU8825_HP_BOOST_G_DIS | | ||
784 | NAU8825_SHORT_SHUTDOWN_EN, | ||
785 | NAU8825_PRECHARGE_DIS | NAU8825_HP_BOOST_G_DIS | | ||
786 | NAU8825_SHORT_SHUTDOWN_EN); | ||
787 | |||
788 | regmap_update_bits(regmap, NAU8825_REG_GPIO12_CTRL, | ||
789 | NAU8825_JKDET_OUTPUT_EN, | ||
790 | nau8825->jkdet_enable ? 0 : NAU8825_JKDET_OUTPUT_EN); | ||
791 | regmap_update_bits(regmap, NAU8825_REG_GPIO12_CTRL, | ||
792 | NAU8825_JKDET_PULL_EN, | ||
793 | nau8825->jkdet_pull_enable ? 0 : NAU8825_JKDET_PULL_EN); | ||
794 | regmap_update_bits(regmap, NAU8825_REG_GPIO12_CTRL, | ||
795 | NAU8825_JKDET_PULL_UP, | ||
796 | nau8825->jkdet_pull_up ? NAU8825_JKDET_PULL_UP : 0); | ||
797 | regmap_update_bits(regmap, NAU8825_REG_JACK_DET_CTRL, | ||
798 | NAU8825_JACK_POLARITY, | ||
799 | /* jkdet_polarity - 1 is for active-low */ | ||
800 | nau8825->jkdet_polarity ? 0 : NAU8825_JACK_POLARITY); | ||
801 | |||
802 | regmap_update_bits(regmap, NAU8825_REG_JACK_DET_CTRL, | ||
803 | NAU8825_JACK_INSERT_DEBOUNCE_MASK, | ||
804 | nau8825->jack_insert_debounce << NAU8825_JACK_INSERT_DEBOUNCE_SFT); | ||
805 | regmap_update_bits(regmap, NAU8825_REG_JACK_DET_CTRL, | ||
806 | NAU8825_JACK_EJECT_DEBOUNCE_MASK, | ||
807 | nau8825->jack_eject_debounce << NAU8825_JACK_EJECT_DEBOUNCE_SFT); | ||
808 | |||
809 | /* Mask unneeded IRQs: 1 - disable, 0 - enable */ | ||
810 | regmap_update_bits(regmap, NAU8825_REG_INTERRUPT_MASK, 0x7ff, 0x7ff); | ||
811 | |||
812 | regmap_update_bits(regmap, NAU8825_REG_MIC_BIAS, | ||
813 | NAU8825_MICBIAS_VOLTAGE_MASK, nau8825->micbias_voltage); | ||
814 | |||
815 | if (nau8825->sar_threshold_num) | ||
816 | nau8825_setup_buttons(nau8825); | ||
817 | |||
818 | /* Default oversampling/decimations settings are unusable | ||
819 | * (audible hiss). Set it to something better. | ||
820 | */ | ||
821 | regmap_update_bits(regmap, NAU8825_REG_ADC_RATE, | ||
822 | NAU8825_ADC_SYNC_DOWN_MASK, NAU8825_ADC_SYNC_DOWN_128); | ||
823 | regmap_update_bits(regmap, NAU8825_REG_DAC_CTRL1, | ||
824 | NAU8825_DAC_OVERSAMPLE_MASK, NAU8825_DAC_OVERSAMPLE_128); | ||
825 | } | ||
826 | |||
827 | static const struct regmap_config nau8825_regmap_config = { | ||
828 | .val_bits = 16, | ||
829 | .reg_bits = 16, | ||
830 | |||
831 | .max_register = NAU8825_REG_MAX, | ||
832 | .readable_reg = nau8825_readable_reg, | ||
833 | .writeable_reg = nau8825_writeable_reg, | ||
834 | .volatile_reg = nau8825_volatile_reg, | ||
835 | |||
836 | .cache_type = REGCACHE_RBTREE, | ||
837 | .reg_defaults = nau8825_reg_defaults, | ||
838 | .num_reg_defaults = ARRAY_SIZE(nau8825_reg_defaults), | ||
839 | }; | ||
840 | |||
841 | static int nau8825_codec_probe(struct snd_soc_codec *codec) | ||
842 | { | ||
843 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | ||
844 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | ||
845 | |||
846 | nau8825->dapm = dapm; | ||
847 | |||
848 | /* The interrupt clock is gated by x1[10:8], | ||
849 | * one of them needs to be enabled all the time for | ||
850 | * interrupts to happen. | ||
851 | */ | ||
852 | snd_soc_dapm_force_enable_pin(dapm, "DDACR"); | ||
853 | snd_soc_dapm_sync(dapm); | ||
854 | |||
855 | /* Unmask interruptions. Handler uses dapm object so we can enable | ||
856 | * interruptions only after dapm is fully initialized. | ||
857 | */ | ||
858 | regmap_write(nau8825->regmap, NAU8825_REG_INTERRUPT_DIS_CTRL, 0); | ||
859 | nau8825_restart_jack_detection(nau8825->regmap); | ||
860 | |||
861 | return 0; | ||
862 | } | ||
863 | |||
864 | /** | ||
865 | * nau8825_calc_fll_param - Calculate FLL parameters. | ||
866 | * @fll_in: external clock provided to codec. | ||
867 | * @fs: sampling rate. | ||
868 | * @fll_param: Pointer to structure of FLL parameters. | ||
869 | * | ||
870 | * Calculate FLL parameters to configure codec. | ||
871 | * | ||
872 | * Returns 0 for success or negative error code. | ||
873 | */ | ||
874 | static int nau8825_calc_fll_param(unsigned int fll_in, unsigned int fs, | ||
875 | struct nau8825_fll *fll_param) | ||
876 | { | ||
877 | u64 fvco; | ||
878 | unsigned int fref, i; | ||
879 | |||
880 | /* Ensure the reference clock frequency (FREF) is <= 13.5MHz by dividing | ||
881 | * freq_in by 1, 2, 4, or 8 using FLL pre-scalar. | ||
882 | * FREF = freq_in / NAU8825_FLL_REF_DIV_MASK | ||
883 | */ | ||
884 | for (i = 0; i < ARRAY_SIZE(fll_pre_scalar); i++) { | ||
885 | fref = fll_in / fll_pre_scalar[i].param; | ||
886 | if (fref <= NAU_FREF_MAX) | ||
887 | break; | ||
888 | } | ||
889 | if (i == ARRAY_SIZE(fll_pre_scalar)) | ||
890 | return -EINVAL; | ||
891 | fll_param->clk_ref_div = fll_pre_scalar[i].val; | ||
892 | |||
893 | /* Choose the FLL ratio based on FREF */ | ||
894 | for (i = 0; i < ARRAY_SIZE(fll_ratio); i++) { | ||
895 | if (fref >= fll_ratio[i].param) | ||
896 | break; | ||
897 | } | ||
898 | if (i == ARRAY_SIZE(fll_ratio)) | ||
899 | return -EINVAL; | ||
900 | fll_param->ratio = fll_ratio[i].val; | ||
901 | |||
902 | /* Calculate the frequency of DCO (FDCO) given freq_out = 256 * Fs. | ||
903 | * FDCO must be within the 90MHz - 100MHz or the FFL cannot be | ||
904 | * guaranteed across the full range of operation. | ||
905 | * FDCO = freq_out * 2 * mclk_src_scaling | ||
906 | */ | ||
907 | for (i = 0; i < ARRAY_SIZE(mclk_src_scaling); i++) { | ||
908 | fvco = 256 * fs * 2 * mclk_src_scaling[i].param; | ||
909 | if (NAU_FVCO_MIN < fvco && fvco < NAU_FVCO_MAX) | ||
910 | break; | ||
911 | } | ||
912 | if (i == ARRAY_SIZE(mclk_src_scaling)) | ||
913 | return -EINVAL; | ||
914 | fll_param->mclk_src = mclk_src_scaling[i].val; | ||
915 | |||
916 | /* Calculate the FLL 10-bit integer input and the FLL 16-bit fractional | ||
917 | * input based on FDCO, FREF and FLL ratio. | ||
918 | */ | ||
919 | fvco = div_u64(fvco << 16, fref * fll_param->ratio); | ||
920 | fll_param->fll_int = (fvco >> 16) & 0x3FF; | ||
921 | fll_param->fll_frac = fvco & 0xFFFF; | ||
922 | return 0; | ||
923 | } | ||
924 | |||
925 | static void nau8825_fll_apply(struct nau8825 *nau8825, | ||
926 | struct nau8825_fll *fll_param) | ||
927 | { | ||
928 | regmap_update_bits(nau8825->regmap, NAU8825_REG_CLK_DIVIDER, | ||
929 | NAU8825_CLK_MCLK_SRC_MASK, fll_param->mclk_src); | ||
930 | regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL1, | ||
931 | NAU8825_FLL_RATIO_MASK, fll_param->ratio); | ||
932 | /* FLL 16-bit fractional input */ | ||
933 | regmap_write(nau8825->regmap, NAU8825_REG_FLL2, fll_param->fll_frac); | ||
934 | /* FLL 10-bit integer input */ | ||
935 | regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL3, | ||
936 | NAU8825_FLL_INTEGER_MASK, fll_param->fll_int); | ||
937 | /* FLL pre-scaler */ | ||
938 | regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL4, | ||
939 | NAU8825_FLL_REF_DIV_MASK, fll_param->clk_ref_div); | ||
940 | /* select divided VCO input */ | ||
941 | regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL5, | ||
942 | NAU8825_FLL_FILTER_SW_MASK, 0x0000); | ||
943 | /* FLL sigma delta modulator enable */ | ||
944 | regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL6, | ||
945 | NAU8825_SDM_EN_MASK, NAU8825_SDM_EN); | ||
946 | } | ||
947 | |||
948 | /* freq_out must be 256*Fs in order to achieve the best performance */ | ||
949 | static int nau8825_set_pll(struct snd_soc_codec *codec, int pll_id, int source, | ||
950 | unsigned int freq_in, unsigned int freq_out) | ||
951 | { | ||
952 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | ||
953 | struct nau8825_fll fll_param; | ||
954 | int ret, fs; | ||
955 | |||
956 | fs = freq_out / 256; | ||
957 | ret = nau8825_calc_fll_param(freq_in, fs, &fll_param); | ||
958 | if (ret < 0) { | ||
959 | dev_err(codec->dev, "Unsupported input clock %d\n", freq_in); | ||
960 | return ret; | ||
961 | } | ||
962 | dev_dbg(codec->dev, "mclk_src=%x ratio=%x fll_frac=%x fll_int=%x clk_ref_div=%x\n", | ||
963 | fll_param.mclk_src, fll_param.ratio, fll_param.fll_frac, | ||
964 | fll_param.fll_int, fll_param.clk_ref_div); | ||
965 | |||
966 | nau8825_fll_apply(nau8825, &fll_param); | ||
967 | mdelay(2); | ||
968 | regmap_update_bits(nau8825->regmap, NAU8825_REG_CLK_DIVIDER, | ||
969 | NAU8825_CLK_SRC_MASK, NAU8825_CLK_SRC_VCO); | ||
970 | return 0; | ||
971 | } | ||
972 | |||
973 | static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, | ||
974 | unsigned int freq) | ||
975 | { | ||
976 | struct regmap *regmap = nau8825->regmap; | ||
977 | int ret; | ||
978 | |||
979 | switch (clk_id) { | ||
980 | case NAU8825_CLK_MCLK: | ||
981 | regmap_update_bits(regmap, NAU8825_REG_CLK_DIVIDER, | ||
982 | NAU8825_CLK_SRC_MASK, NAU8825_CLK_SRC_MCLK); | ||
983 | regmap_update_bits(regmap, NAU8825_REG_FLL6, NAU8825_DCO_EN, 0); | ||
984 | |||
985 | /* We selected MCLK source but the clock itself managed externally */ | ||
986 | if (!nau8825->mclk) | ||
987 | break; | ||
988 | |||
989 | if (!nau8825->mclk_freq) { | ||
990 | ret = clk_prepare_enable(nau8825->mclk); | ||
991 | if (ret) { | ||
992 | dev_err(nau8825->dev, "Unable to prepare codec mclk\n"); | ||
993 | return ret; | ||
994 | } | ||
995 | } | ||
996 | |||
997 | if (nau8825->mclk_freq != freq) { | ||
998 | nau8825->mclk_freq = freq; | ||
999 | |||
1000 | freq = clk_round_rate(nau8825->mclk, freq); | ||
1001 | ret = clk_set_rate(nau8825->mclk, freq); | ||
1002 | if (ret) { | ||
1003 | dev_err(nau8825->dev, "Unable to set mclk rate\n"); | ||
1004 | return ret; | ||
1005 | } | ||
1006 | } | ||
1007 | |||
1008 | break; | ||
1009 | case NAU8825_CLK_INTERNAL: | ||
1010 | regmap_update_bits(regmap, NAU8825_REG_FLL6, NAU8825_DCO_EN, | ||
1011 | NAU8825_DCO_EN); | ||
1012 | regmap_update_bits(regmap, NAU8825_REG_CLK_DIVIDER, | ||
1013 | NAU8825_CLK_SRC_MASK, NAU8825_CLK_SRC_VCO); | ||
1014 | |||
1015 | if (nau8825->mclk_freq) { | ||
1016 | clk_disable_unprepare(nau8825->mclk); | ||
1017 | nau8825->mclk_freq = 0; | ||
1018 | } | ||
1019 | |||
1020 | break; | ||
1021 | default: | ||
1022 | dev_err(nau8825->dev, "Invalid clock id (%d)\n", clk_id); | ||
1023 | return -EINVAL; | ||
1024 | } | ||
1025 | |||
1026 | dev_dbg(nau8825->dev, "Sysclk is %dHz and clock id is %d\n", freq, | ||
1027 | clk_id); | ||
1028 | return 0; | ||
1029 | } | ||
1030 | |||
1031 | static int nau8825_set_sysclk(struct snd_soc_codec *codec, int clk_id, | ||
1032 | int source, unsigned int freq, int dir) | ||
1033 | { | ||
1034 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | ||
1035 | |||
1036 | return nau8825_configure_sysclk(nau8825, clk_id, freq); | ||
1037 | } | ||
1038 | |||
1039 | static int nau8825_set_bias_level(struct snd_soc_codec *codec, | ||
1040 | enum snd_soc_bias_level level) | ||
1041 | { | ||
1042 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | ||
1043 | int ret; | ||
1044 | |||
1045 | switch (level) { | ||
1046 | case SND_SOC_BIAS_ON: | ||
1047 | break; | ||
1048 | |||
1049 | case SND_SOC_BIAS_PREPARE: | ||
1050 | break; | ||
1051 | |||
1052 | case SND_SOC_BIAS_STANDBY: | ||
1053 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { | ||
1054 | if (nau8825->mclk_freq) { | ||
1055 | ret = clk_prepare_enable(nau8825->mclk); | ||
1056 | if (ret) { | ||
1057 | dev_err(nau8825->dev, "Unable to prepare codec mclk\n"); | ||
1058 | return ret; | ||
1059 | } | ||
1060 | } | ||
1061 | |||
1062 | ret = regcache_sync(nau8825->regmap); | ||
1063 | if (ret) { | ||
1064 | dev_err(codec->dev, | ||
1065 | "Failed to sync cache: %d\n", ret); | ||
1066 | return ret; | ||
1067 | } | ||
1068 | } | ||
1069 | |||
1070 | break; | ||
1071 | |||
1072 | case SND_SOC_BIAS_OFF: | ||
1073 | if (nau8825->mclk_freq) | ||
1074 | clk_disable_unprepare(nau8825->mclk); | ||
1075 | |||
1076 | regcache_mark_dirty(nau8825->regmap); | ||
1077 | break; | ||
1078 | } | ||
1079 | return 0; | ||
1080 | } | ||
1081 | |||
1082 | static struct snd_soc_codec_driver nau8825_codec_driver = { | ||
1083 | .probe = nau8825_codec_probe, | ||
1084 | .set_sysclk = nau8825_set_sysclk, | ||
1085 | .set_pll = nau8825_set_pll, | ||
1086 | .set_bias_level = nau8825_set_bias_level, | ||
1087 | .suspend_bias_off = true, | ||
1088 | |||
1089 | .controls = nau8825_controls, | ||
1090 | .num_controls = ARRAY_SIZE(nau8825_controls), | ||
1091 | .dapm_widgets = nau8825_dapm_widgets, | ||
1092 | .num_dapm_widgets = ARRAY_SIZE(nau8825_dapm_widgets), | ||
1093 | .dapm_routes = nau8825_dapm_routes, | ||
1094 | .num_dapm_routes = ARRAY_SIZE(nau8825_dapm_routes), | ||
1095 | }; | ||
1096 | |||
1097 | static void nau8825_reset_chip(struct regmap *regmap) | ||
1098 | { | ||
1099 | regmap_write(regmap, NAU8825_REG_RESET, 0x00); | ||
1100 | regmap_write(regmap, NAU8825_REG_RESET, 0x00); | ||
1101 | } | ||
1102 | |||
1103 | static void nau8825_print_device_properties(struct nau8825 *nau8825) | ||
1104 | { | ||
1105 | int i; | ||
1106 | struct device *dev = nau8825->dev; | ||
1107 | |||
1108 | dev_dbg(dev, "jkdet-enable: %d\n", nau8825->jkdet_enable); | ||
1109 | dev_dbg(dev, "jkdet-pull-enable: %d\n", nau8825->jkdet_pull_enable); | ||
1110 | dev_dbg(dev, "jkdet-pull-up: %d\n", nau8825->jkdet_pull_up); | ||
1111 | dev_dbg(dev, "jkdet-polarity: %d\n", nau8825->jkdet_polarity); | ||
1112 | dev_dbg(dev, "micbias-voltage: %d\n", nau8825->micbias_voltage); | ||
1113 | dev_dbg(dev, "vref-impedance: %d\n", nau8825->vref_impedance); | ||
1114 | |||
1115 | dev_dbg(dev, "sar-threshold-num: %d\n", nau8825->sar_threshold_num); | ||
1116 | for (i = 0; i < nau8825->sar_threshold_num; i++) | ||
1117 | dev_dbg(dev, "sar-threshold[%d]=%d\n", i, | ||
1118 | nau8825->sar_threshold[i]); | ||
1119 | |||
1120 | dev_dbg(dev, "sar-hysteresis: %d\n", nau8825->sar_hysteresis); | ||
1121 | dev_dbg(dev, "sar-voltage: %d\n", nau8825->sar_voltage); | ||
1122 | dev_dbg(dev, "sar-compare-time: %d\n", nau8825->sar_compare_time); | ||
1123 | dev_dbg(dev, "sar-sampling-time: %d\n", nau8825->sar_sampling_time); | ||
1124 | dev_dbg(dev, "short-key-debounce: %d\n", nau8825->key_debounce); | ||
1125 | dev_dbg(dev, "jack-insert-debounce: %d\n", | ||
1126 | nau8825->jack_insert_debounce); | ||
1127 | dev_dbg(dev, "jack-eject-debounce: %d\n", | ||
1128 | nau8825->jack_eject_debounce); | ||
1129 | } | ||
1130 | |||
1131 | static int nau8825_read_device_properties(struct device *dev, | ||
1132 | struct nau8825 *nau8825) { | ||
1133 | |||
1134 | nau8825->jkdet_enable = device_property_read_bool(dev, | ||
1135 | "nuvoton,jkdet-enable"); | ||
1136 | nau8825->jkdet_pull_enable = device_property_read_bool(dev, | ||
1137 | "nuvoton,jkdet-pull-enable"); | ||
1138 | nau8825->jkdet_pull_up = device_property_read_bool(dev, | ||
1139 | "nuvoton,jkdet-pull-up"); | ||
1140 | device_property_read_u32(dev, "nuvoton,jkdet-polarity", | ||
1141 | &nau8825->jkdet_polarity); | ||
1142 | device_property_read_u32(dev, "nuvoton,micbias-voltage", | ||
1143 | &nau8825->micbias_voltage); | ||
1144 | device_property_read_u32(dev, "nuvoton,vref-impedance", | ||
1145 | &nau8825->vref_impedance); | ||
1146 | device_property_read_u32(dev, "nuvoton,sar-threshold-num", | ||
1147 | &nau8825->sar_threshold_num); | ||
1148 | device_property_read_u32_array(dev, "nuvoton,sar-threshold", | ||
1149 | nau8825->sar_threshold, nau8825->sar_threshold_num); | ||
1150 | device_property_read_u32(dev, "nuvoton,sar-hysteresis", | ||
1151 | &nau8825->sar_hysteresis); | ||
1152 | device_property_read_u32(dev, "nuvoton,sar-voltage", | ||
1153 | &nau8825->sar_voltage); | ||
1154 | device_property_read_u32(dev, "nuvoton,sar-compare-time", | ||
1155 | &nau8825->sar_compare_time); | ||
1156 | device_property_read_u32(dev, "nuvoton,sar-sampling-time", | ||
1157 | &nau8825->sar_sampling_time); | ||
1158 | device_property_read_u32(dev, "nuvoton,short-key-debounce", | ||
1159 | &nau8825->key_debounce); | ||
1160 | device_property_read_u32(dev, "nuvoton,jack-insert-debounce", | ||
1161 | &nau8825->jack_insert_debounce); | ||
1162 | device_property_read_u32(dev, "nuvoton,jack-eject-debounce", | ||
1163 | &nau8825->jack_eject_debounce); | ||
1164 | |||
1165 | nau8825->mclk = devm_clk_get(dev, "mclk"); | ||
1166 | if (PTR_ERR(nau8825->mclk) == -EPROBE_DEFER) { | ||
1167 | return -EPROBE_DEFER; | ||
1168 | } else if (PTR_ERR(nau8825->mclk) == -ENOENT) { | ||
1169 | /* The MCLK is managed externally or not used at all */ | ||
1170 | nau8825->mclk = NULL; | ||
1171 | dev_info(dev, "No 'mclk' clock found, assume MCLK is managed externally"); | ||
1172 | } else if (IS_ERR(nau8825->mclk)) { | ||
1173 | return -EINVAL; | ||
1174 | } | ||
1175 | |||
1176 | return 0; | ||
1177 | } | ||
1178 | |||
1179 | static int nau8825_setup_irq(struct nau8825 *nau8825) | ||
1180 | { | ||
1181 | struct regmap *regmap = nau8825->regmap; | ||
1182 | int ret; | ||
1183 | |||
1184 | /* IRQ Output Enable */ | ||
1185 | regmap_update_bits(regmap, NAU8825_REG_INTERRUPT_MASK, | ||
1186 | NAU8825_IRQ_OUTPUT_EN, NAU8825_IRQ_OUTPUT_EN); | ||
1187 | |||
1188 | /* Enable internal VCO needed for interruptions */ | ||
1189 | nau8825_configure_sysclk(nau8825, NAU8825_CLK_INTERNAL, 0); | ||
1190 | |||
1191 | /* Enable DDACR needed for interrupts | ||
1192 | * It is the same as force_enable_pin("DDACR") we do later | ||
1193 | */ | ||
1194 | regmap_update_bits(regmap, NAU8825_REG_ENA_CTRL, | ||
1195 | NAU8825_ENABLE_DACR, NAU8825_ENABLE_DACR); | ||
1196 | |||
1197 | /* Chip needs one FSCLK cycle in order to generate interrupts, | ||
1198 | * as we cannot guarantee one will be provided by the system. Turning | ||
1199 | * master mode on then off enables us to generate that FSCLK cycle | ||
1200 | * with a minimum of contention on the clock bus. | ||
1201 | */ | ||
1202 | regmap_update_bits(regmap, NAU8825_REG_I2S_PCM_CTRL2, | ||
1203 | NAU8825_I2S_MS_MASK, NAU8825_I2S_MS_MASTER); | ||
1204 | regmap_update_bits(regmap, NAU8825_REG_I2S_PCM_CTRL2, | ||
1205 | NAU8825_I2S_MS_MASK, NAU8825_I2S_MS_SLAVE); | ||
1206 | |||
1207 | ret = devm_request_threaded_irq(nau8825->dev, nau8825->irq, NULL, | ||
1208 | nau8825_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT, | ||
1209 | "nau8825", nau8825); | ||
1210 | |||
1211 | if (ret) { | ||
1212 | dev_err(nau8825->dev, "Cannot request irq %d (%d)\n", | ||
1213 | nau8825->irq, ret); | ||
1214 | return ret; | ||
1215 | } | ||
1216 | |||
1217 | return 0; | ||
1218 | } | ||
1219 | |||
1220 | static int nau8825_i2c_probe(struct i2c_client *i2c, | ||
1221 | const struct i2c_device_id *id) | ||
1222 | { | ||
1223 | struct device *dev = &i2c->dev; | ||
1224 | struct nau8825 *nau8825 = dev_get_platdata(&i2c->dev); | ||
1225 | int ret, value; | ||
1226 | |||
1227 | if (!nau8825) { | ||
1228 | nau8825 = devm_kzalloc(dev, sizeof(*nau8825), GFP_KERNEL); | ||
1229 | if (!nau8825) | ||
1230 | return -ENOMEM; | ||
1231 | ret = nau8825_read_device_properties(dev, nau8825); | ||
1232 | if (ret) | ||
1233 | return ret; | ||
1234 | } | ||
1235 | |||
1236 | i2c_set_clientdata(i2c, nau8825); | ||
1237 | |||
1238 | nau8825->regmap = devm_regmap_init_i2c(i2c, &nau8825_regmap_config); | ||
1239 | if (IS_ERR(nau8825->regmap)) | ||
1240 | return PTR_ERR(nau8825->regmap); | ||
1241 | nau8825->dev = dev; | ||
1242 | nau8825->irq = i2c->irq; | ||
1243 | |||
1244 | nau8825_print_device_properties(nau8825); | ||
1245 | |||
1246 | nau8825_reset_chip(nau8825->regmap); | ||
1247 | ret = regmap_read(nau8825->regmap, NAU8825_REG_I2C_DEVICE_ID, &value); | ||
1248 | if (ret < 0) { | ||
1249 | dev_err(dev, "Failed to read device id from the NAU8825: %d\n", | ||
1250 | ret); | ||
1251 | return ret; | ||
1252 | } | ||
1253 | if ((value & NAU8825_SOFTWARE_ID_MASK) != | ||
1254 | NAU8825_SOFTWARE_ID_NAU8825) { | ||
1255 | dev_err(dev, "Not a NAU8825 chip\n"); | ||
1256 | return -ENODEV; | ||
1257 | } | ||
1258 | |||
1259 | nau8825_init_regs(nau8825); | ||
1260 | |||
1261 | if (i2c->irq) | ||
1262 | nau8825_setup_irq(nau8825); | ||
1263 | |||
1264 | return snd_soc_register_codec(&i2c->dev, &nau8825_codec_driver, | ||
1265 | &nau8825_dai, 1); | ||
1266 | } | ||
1267 | |||
1268 | static int nau8825_i2c_remove(struct i2c_client *client) | ||
1269 | { | ||
1270 | snd_soc_unregister_codec(&client->dev); | ||
1271 | return 0; | ||
1272 | } | ||
1273 | |||
1274 | static const struct i2c_device_id nau8825_i2c_ids[] = { | ||
1275 | { "nau8825", 0 }, | ||
1276 | { } | ||
1277 | }; | ||
1278 | |||
1279 | #ifdef CONFIG_OF | ||
1280 | static const struct of_device_id nau8825_of_ids[] = { | ||
1281 | { .compatible = "nuvoton,nau8825", }, | ||
1282 | {} | ||
1283 | }; | ||
1284 | MODULE_DEVICE_TABLE(of, nau8825_of_ids); | ||
1285 | #endif | ||
1286 | |||
1287 | #ifdef CONFIG_ACPI | ||
1288 | static const struct acpi_device_id nau8825_acpi_match[] = { | ||
1289 | { "10508825", 0 }, | ||
1290 | {}, | ||
1291 | }; | ||
1292 | MODULE_DEVICE_TABLE(acpi, nau8825_acpi_match); | ||
1293 | #endif | ||
1294 | |||
1295 | static struct i2c_driver nau8825_driver = { | ||
1296 | .driver = { | ||
1297 | .name = "nau8825", | ||
1298 | .of_match_table = of_match_ptr(nau8825_of_ids), | ||
1299 | .acpi_match_table = ACPI_PTR(nau8825_acpi_match), | ||
1300 | }, | ||
1301 | .probe = nau8825_i2c_probe, | ||
1302 | .remove = nau8825_i2c_remove, | ||
1303 | .id_table = nau8825_i2c_ids, | ||
1304 | }; | ||
1305 | module_i2c_driver(nau8825_driver); | ||
1306 | |||
1307 | MODULE_DESCRIPTION("ASoC nau8825 driver"); | ||
1308 | MODULE_AUTHOR("Anatol Pomozov <anatol@chromium.org>"); | ||
1309 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h new file mode 100644 index 000000000000..dff8edb83bfd --- /dev/null +++ b/sound/soc/codecs/nau8825.h | |||
@@ -0,0 +1,341 @@ | |||
1 | /* | ||
2 | * NAU8825 ALSA SoC audio driver | ||
3 | * | ||
4 | * Copyright 2015 Google Inc. | ||
5 | * Author: Anatol Pomozov <anatol.pomozov@chrominium.org> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef __NAU8825_H__ | ||
13 | #define __NAU8825_H__ | ||
14 | |||
15 | #define NAU8825_REG_RESET 0x00 | ||
16 | #define NAU8825_REG_ENA_CTRL 0x01 | ||
17 | #define NAU8825_REG_CLK_DIVIDER 0x03 | ||
18 | #define NAU8825_REG_FLL1 0x04 | ||
19 | #define NAU8825_REG_FLL2 0x05 | ||
20 | #define NAU8825_REG_FLL3 0x06 | ||
21 | #define NAU8825_REG_FLL4 0x07 | ||
22 | #define NAU8825_REG_FLL5 0x08 | ||
23 | #define NAU8825_REG_FLL6 0x09 | ||
24 | #define NAU8825_REG_FLL_VCO_RSV 0x0a | ||
25 | #define NAU8825_REG_HSD_CTRL 0x0c | ||
26 | #define NAU8825_REG_JACK_DET_CTRL 0x0d | ||
27 | #define NAU8825_REG_INTERRUPT_MASK 0x0f | ||
28 | #define NAU8825_REG_IRQ_STATUS 0x10 | ||
29 | #define NAU8825_REG_INT_CLR_KEY_STATUS 0x11 | ||
30 | #define NAU8825_REG_INTERRUPT_DIS_CTRL 0x12 | ||
31 | #define NAU8825_REG_SAR_CTRL 0x13 | ||
32 | #define NAU8825_REG_KEYDET_CTRL 0x14 | ||
33 | #define NAU8825_REG_VDET_THRESHOLD_1 0x15 | ||
34 | #define NAU8825_REG_VDET_THRESHOLD_2 0x16 | ||
35 | #define NAU8825_REG_VDET_THRESHOLD_3 0x17 | ||
36 | #define NAU8825_REG_VDET_THRESHOLD_4 0x18 | ||
37 | #define NAU8825_REG_GPIO34_CTRL 0x19 | ||
38 | #define NAU8825_REG_GPIO12_CTRL 0x1a | ||
39 | #define NAU8825_REG_TDM_CTRL 0x1b | ||
40 | #define NAU8825_REG_I2S_PCM_CTRL1 0x1c | ||
41 | #define NAU8825_REG_I2S_PCM_CTRL2 0x1d | ||
42 | #define NAU8825_REG_LEFT_TIME_SLOT 0x1e | ||
43 | #define NAU8825_REG_RIGHT_TIME_SLOT 0x1f | ||
44 | #define NAU8825_REG_BIQ_CTRL 0x20 | ||
45 | #define NAU8825_REG_BIQ_COF1 0x21 | ||
46 | #define NAU8825_REG_BIQ_COF2 0x22 | ||
47 | #define NAU8825_REG_BIQ_COF3 0x23 | ||
48 | #define NAU8825_REG_BIQ_COF4 0x24 | ||
49 | #define NAU8825_REG_BIQ_COF5 0x25 | ||
50 | #define NAU8825_REG_BIQ_COF6 0x26 | ||
51 | #define NAU8825_REG_BIQ_COF7 0x27 | ||
52 | #define NAU8825_REG_BIQ_COF8 0x28 | ||
53 | #define NAU8825_REG_BIQ_COF9 0x29 | ||
54 | #define NAU8825_REG_BIQ_COF10 0x2a | ||
55 | #define NAU8825_REG_ADC_RATE 0x2b | ||
56 | #define NAU8825_REG_DAC_CTRL1 0x2c | ||
57 | #define NAU8825_REG_DAC_CTRL2 0x2d | ||
58 | #define NAU8825_REG_DAC_DGAIN_CTRL 0x2f | ||
59 | #define NAU8825_REG_ADC_DGAIN_CTRL 0x30 | ||
60 | #define NAU8825_REG_MUTE_CTRL 0x31 | ||
61 | #define NAU8825_REG_HSVOL_CTRL 0x32 | ||
62 | #define NAU8825_REG_DACL_CTRL 0x33 | ||
63 | #define NAU8825_REG_DACR_CTRL 0x34 | ||
64 | #define NAU8825_REG_ADC_DRC_KNEE_IP12 0x38 | ||
65 | #define NAU8825_REG_ADC_DRC_KNEE_IP34 0x39 | ||
66 | #define NAU8825_REG_ADC_DRC_SLOPES 0x3a | ||
67 | #define NAU8825_REG_ADC_DRC_ATKDCY 0x3b | ||
68 | #define NAU8825_REG_DAC_DRC_KNEE_IP12 0x45 | ||
69 | #define NAU8825_REG_DAC_DRC_KNEE_IP34 0x46 | ||
70 | #define NAU8825_REG_DAC_DRC_SLOPES 0x47 | ||
71 | #define NAU8825_REG_DAC_DRC_ATKDCY 0x48 | ||
72 | #define NAU8825_REG_IMM_MODE_CTRL 0x4c | ||
73 | #define NAU8825_REG_IMM_RMS_L 0x4d | ||
74 | #define NAU8825_REG_IMM_RMS_R 0x4e | ||
75 | #define NAU8825_REG_CLASSG_CTRL 0x50 | ||
76 | #define NAU8825_REG_OPT_EFUSE_CTRL 0x51 | ||
77 | #define NAU8825_REG_MISC_CTRL 0x55 | ||
78 | #define NAU8825_REG_I2C_DEVICE_ID 0x58 | ||
79 | #define NAU8825_REG_SARDOUT_RAM_STATUS 0x59 | ||
80 | #define NAU8825_REG_BIAS_ADJ 0x66 | ||
81 | #define NAU8825_REG_TRIM_SETTINGS 0x68 | ||
82 | #define NAU8825_REG_ANALOG_CONTROL_1 0x69 | ||
83 | #define NAU8825_REG_ANALOG_CONTROL_2 0x6a | ||
84 | #define NAU8825_REG_ANALOG_ADC_1 0x71 | ||
85 | #define NAU8825_REG_ANALOG_ADC_2 0x72 | ||
86 | #define NAU8825_REG_RDAC 0x73 | ||
87 | #define NAU8825_REG_MIC_BIAS 0x74 | ||
88 | #define NAU8825_REG_BOOST 0x76 | ||
89 | #define NAU8825_REG_FEPGA 0x77 | ||
90 | #define NAU8825_REG_POWER_UP_CONTROL 0x7f | ||
91 | #define NAU8825_REG_CHARGE_PUMP 0x80 | ||
92 | #define NAU8825_REG_CHARGE_PUMP_INPUT_READ 0x81 | ||
93 | #define NAU8825_REG_GENERAL_STATUS 0x82 | ||
94 | #define NAU8825_REG_MAX NAU8825_REG_GENERAL_STATUS | ||
95 | |||
96 | /* ENA_CTRL (0x1) */ | ||
97 | #define NAU8825_ENABLE_DACR_SFT 10 | ||
98 | #define NAU8825_ENABLE_DACR (1 << NAU8825_ENABLE_DACR_SFT) | ||
99 | #define NAU8825_ENABLE_DACL_SFT 9 | ||
100 | #define NAU8825_ENABLE_ADC_SFT 8 | ||
101 | #define NAU8825_ENABLE_SAR_SFT 1 | ||
102 | |||
103 | /* CLK_DIVIDER (0x3) */ | ||
104 | #define NAU8825_CLK_SRC_SFT 15 | ||
105 | #define NAU8825_CLK_SRC_MASK (1 << NAU8825_CLK_SRC_SFT) | ||
106 | #define NAU8825_CLK_SRC_VCO (1 << NAU8825_CLK_SRC_SFT) | ||
107 | #define NAU8825_CLK_SRC_MCLK (0 << NAU8825_CLK_SRC_SFT) | ||
108 | #define NAU8825_CLK_MCLK_SRC_MASK (0xf << 0) | ||
109 | |||
110 | /* FLL1 (0x04) */ | ||
111 | #define NAU8825_FLL_RATIO_MASK (0x7f << 0) | ||
112 | |||
113 | /* FLL3 (0x06) */ | ||
114 | #define NAU8825_FLL_INTEGER_MASK (0x3ff << 0) | ||
115 | |||
116 | /* FLL4 (0x07) */ | ||
117 | #define NAU8825_FLL_REF_DIV_MASK (0x3 << 10) | ||
118 | |||
119 | /* FLL5 (0x08) */ | ||
120 | #define NAU8825_FLL_FILTER_SW_MASK (0x1 << 14) | ||
121 | |||
122 | /* FLL6 (0x9) */ | ||
123 | #define NAU8825_DCO_EN_MASK (0x1 << 15) | ||
124 | #define NAU8825_DCO_EN (0x1 << 15) | ||
125 | #define NAU8825_DCO_DIS (0x0 << 15) | ||
126 | #define NAU8825_SDM_EN_MASK (0x1 << 14) | ||
127 | #define NAU8825_SDM_EN (0x1 << 14) | ||
128 | #define NAU8825_SDM_DIS (0x0 << 14) | ||
129 | |||
130 | /* HSD_CTRL (0xc) */ | ||
131 | #define NAU8825_HSD_AUTO_MODE (1 << 6) | ||
132 | /* 0 - short to GND, 1 - open */ | ||
133 | #define NAU8825_SPKR_DWN1R (1 << 1) | ||
134 | #define NAU8825_SPKR_DWN1L (1 << 0) | ||
135 | |||
136 | /* JACK_DET_CTRL (0xd) */ | ||
137 | #define NAU8825_JACK_DET_RESTART (1 << 9) | ||
138 | #define NAU8825_JACK_INSERT_DEBOUNCE_SFT 5 | ||
139 | #define NAU8825_JACK_INSERT_DEBOUNCE_MASK (0x7 << NAU8825_JACK_INSERT_DEBOUNCE_SFT) | ||
140 | #define NAU8825_JACK_EJECT_DEBOUNCE_SFT 2 | ||
141 | #define NAU8825_JACK_EJECT_DEBOUNCE_MASK (0x7 << NAU8825_JACK_EJECT_DEBOUNCE_SFT) | ||
142 | #define NAU8825_JACK_POLARITY (1 << 1) /* 0 - active low, 1 - active high */ | ||
143 | |||
144 | /* INTERRUPT_MASK (0xf) */ | ||
145 | #define NAU8825_IRQ_OUTPUT_EN (1 << 11) | ||
146 | #define NAU8825_IRQ_HEADSET_COMPLETE_EN (1 << 10) | ||
147 | #define NAU8825_IRQ_KEY_RELEASE_EN (1 << 7) | ||
148 | #define NAU8825_IRQ_KEY_SHORT_PRESS_EN (1 << 5) | ||
149 | #define NAU8825_IRQ_EJECT_EN (1 << 2) | ||
150 | |||
151 | /* IRQ_STATUS (0x10) */ | ||
152 | #define NAU8825_HEADSET_COMPLETION_IRQ (1 << 10) | ||
153 | #define NAU8825_SHORT_CIRCUIT_IRQ (1 << 9) | ||
154 | #define NAU8825_IMPEDANCE_MEAS_IRQ (1 << 8) | ||
155 | #define NAU8825_KEY_IRQ_MASK (0x7 << 5) | ||
156 | #define NAU8825_KEY_RELEASE_IRQ (1 << 7) | ||
157 | #define NAU8825_KEY_LONG_PRESS_IRQ (1 << 6) | ||
158 | #define NAU8825_KEY_SHORT_PRESS_IRQ (1 << 5) | ||
159 | #define NAU8825_MIC_DETECTION_IRQ (1 << 4) | ||
160 | #define NAU8825_JACK_EJECTION_IRQ_MASK (3 << 2) | ||
161 | #define NAU8825_JACK_EJECTION_DETECTED (1 << 2) | ||
162 | #define NAU8825_JACK_INSERTION_IRQ_MASK (3 << 0) | ||
163 | #define NAU8825_JACK_INSERTION_DETECTED (1 << 0) | ||
164 | |||
165 | /* INTERRUPT_DIS_CTRL (0x12) */ | ||
166 | #define NAU8825_IRQ_HEADSET_COMPLETE_DIS (1 << 10) | ||
167 | #define NAU8825_IRQ_KEY_RELEASE_DIS (1 << 7) | ||
168 | #define NAU8825_IRQ_KEY_SHORT_PRESS_DIS (1 << 5) | ||
169 | #define NAU8825_IRQ_EJECT_DIS (1 << 2) | ||
170 | |||
171 | /* SAR_CTRL (0x13) */ | ||
172 | #define NAU8825_SAR_ADC_EN_SFT 12 | ||
173 | #define NAU8825_SAR_ADC_EN (1 << NAU8825_SAR_ADC_EN_SFT) | ||
174 | #define NAU8825_SAR_INPUT_MASK (1 << 11) | ||
175 | #define NAU8825_SAR_INPUT_JKSLV (1 << 11) | ||
176 | #define NAU8825_SAR_INPUT_JKR2 (0 << 11) | ||
177 | #define NAU8825_SAR_TRACKING_GAIN_SFT 8 | ||
178 | #define NAU8825_SAR_TRACKING_GAIN_MASK (0x7 << NAU8825_SAR_TRACKING_GAIN_SFT) | ||
179 | #define NAU8825_SAR_COMPARE_TIME_SFT 2 | ||
180 | #define NAU8825_SAR_COMPARE_TIME_MASK (3 << 2) | ||
181 | #define NAU8825_SAR_SAMPLING_TIME_SFT 0 | ||
182 | #define NAU8825_SAR_SAMPLING_TIME_MASK (3 << 0) | ||
183 | |||
184 | /* KEYDET_CTRL (0x14) */ | ||
185 | #define NAU8825_KEYDET_SHORTKEY_DEBOUNCE_SFT 12 | ||
186 | #define NAU8825_KEYDET_SHORTKEY_DEBOUNCE_MASK (0x3 << NAU8825_KEYDET_SHORTKEY_DEBOUNCE_SFT) | ||
187 | #define NAU8825_KEYDET_LEVELS_NR_SFT 8 | ||
188 | #define NAU8825_KEYDET_LEVELS_NR_MASK (0x7 << 8) | ||
189 | #define NAU8825_KEYDET_HYSTERESIS_SFT 0 | ||
190 | #define NAU8825_KEYDET_HYSTERESIS_MASK 0xf | ||
191 | |||
192 | /* GPIO12_CTRL (0x1a) */ | ||
193 | #define NAU8825_JKDET_PULL_UP (1 << 11) /* 0 - pull down, 1 - pull up */ | ||
194 | #define NAU8825_JKDET_PULL_EN (1 << 9) /* 0 - enable pull, 1 - disable */ | ||
195 | #define NAU8825_JKDET_OUTPUT_EN (1 << 8) /* 0 - enable input, 1 - enable output */ | ||
196 | |||
197 | /* I2S_PCM_CTRL1 (0x1c) */ | ||
198 | #define NAU8825_I2S_BP_SFT 7 | ||
199 | #define NAU8825_I2S_BP_MASK (1 << NAU8825_I2S_BP_SFT) | ||
200 | #define NAU8825_I2S_BP_INV (1 << NAU8825_I2S_BP_SFT) | ||
201 | #define NAU8825_I2S_PCMB_SFT 6 | ||
202 | #define NAU8825_I2S_PCMB_MASK (1 << NAU8825_I2S_PCMB_SFT) | ||
203 | #define NAU8825_I2S_PCMB_EN (1 << NAU8825_I2S_PCMB_SFT) | ||
204 | #define NAU8825_I2S_DL_SFT 2 | ||
205 | #define NAU8825_I2S_DL_MASK (0x3 << NAU8825_I2S_DL_SFT) | ||
206 | #define NAU8825_I2S_DL_16 (0 << NAU8825_I2S_DL_SFT) | ||
207 | #define NAU8825_I2S_DL_20 (1 << NAU8825_I2S_DL_SFT) | ||
208 | #define NAU8825_I2S_DL_24 (2 << NAU8825_I2S_DL_SFT) | ||
209 | #define NAU8825_I2S_DL_32 (3 << NAU8825_I2S_DL_SFT) | ||
210 | #define NAU8825_I2S_DF_SFT 0 | ||
211 | #define NAU8825_I2S_DF_MASK (0x3 << NAU8825_I2S_DF_SFT) | ||
212 | #define NAU8825_I2S_DF_RIGTH (0 << NAU8825_I2S_DF_SFT) | ||
213 | #define NAU8825_I2S_DF_LEFT (1 << NAU8825_I2S_DF_SFT) | ||
214 | #define NAU8825_I2S_DF_I2S (2 << NAU8825_I2S_DF_SFT) | ||
215 | #define NAU8825_I2S_DF_PCM_AB (3 << NAU8825_I2S_DF_SFT) | ||
216 | |||
217 | /* I2S_PCM_CTRL2 (0x1d) */ | ||
218 | #define NAU8825_I2S_TRISTATE (1 << 15) /* 0 - normal mode, 1 - Hi-Z output */ | ||
219 | #define NAU8825_I2S_MS_SFT 3 | ||
220 | #define NAU8825_I2S_MS_MASK (1 << NAU8825_I2S_MS_SFT) | ||
221 | #define NAU8825_I2S_MS_MASTER (1 << NAU8825_I2S_MS_SFT) | ||
222 | #define NAU8825_I2S_MS_SLAVE (0 << NAU8825_I2S_MS_SFT) | ||
223 | |||
224 | /* ADC_RATE (0x2b) */ | ||
225 | #define NAU8825_ADC_SYNC_DOWN_SFT 0 | ||
226 | #define NAU8825_ADC_SYNC_DOWN_MASK 0x3 | ||
227 | #define NAU8825_ADC_SYNC_DOWN_32 0 | ||
228 | #define NAU8825_ADC_SYNC_DOWN_64 1 | ||
229 | #define NAU8825_ADC_SYNC_DOWN_128 2 | ||
230 | #define NAU8825_ADC_SYNC_DOWN_256 3 | ||
231 | |||
232 | /* DAC_CTRL1 (0x2c) */ | ||
233 | #define NAU8825_DAC_CLIP_OFF (1 << 7) | ||
234 | #define NAU8825_DAC_OVERSAMPLE_SFT 0 | ||
235 | #define NAU8825_DAC_OVERSAMPLE_MASK 0x7 | ||
236 | #define NAU8825_DAC_OVERSAMPLE_64 0 | ||
237 | #define NAU8825_DAC_OVERSAMPLE_256 1 | ||
238 | #define NAU8825_DAC_OVERSAMPLE_128 2 | ||
239 | #define NAU8825_DAC_OVERSAMPLE_32 4 | ||
240 | |||
241 | /* MUTE_CTRL (0x31) */ | ||
242 | #define NAU8825_DAC_ZERO_CROSSING_EN (1 << 9) | ||
243 | #define NAU8825_DAC_SOFT_MUTE (1 << 9) | ||
244 | |||
245 | /* HSVOL_CTRL (0x32) */ | ||
246 | #define NAU8825_HP_MUTE (1 << 15) | ||
247 | |||
248 | /* DACL_CTRL (0x33) */ | ||
249 | #define NAU8825_DACL_CH_SEL_SFT 9 | ||
250 | |||
251 | /* DACR_CTRL (0x34) */ | ||
252 | #define NAU8825_DACR_CH_SEL_SFT 9 | ||
253 | |||
254 | /* I2C_DEVICE_ID (0x58) */ | ||
255 | #define NAU8825_GPIO2JD1 (1 << 7) | ||
256 | #define NAU8825_SOFTWARE_ID_MASK 0x3 | ||
257 | #define NAU8825_SOFTWARE_ID_NAU8825 0x0 | ||
258 | |||
259 | /* BIAS_ADJ (0x66) */ | ||
260 | #define NAU8825_BIAS_VMID (1 << 6) | ||
261 | #define NAU8825_BIAS_VMID_SEL_SFT 4 | ||
262 | #define NAU8825_BIAS_VMID_SEL_MASK (3 << NAU8825_BIAS_VMID_SEL_SFT) | ||
263 | |||
264 | /* ANALOG_CONTROL_2 (0x6a) */ | ||
265 | #define NAU8825_HP_NON_CLASSG_CURRENT_2xADJ (1 << 12) | ||
266 | #define NAU8825_DAC_CAPACITOR_MSB (1 << 1) | ||
267 | #define NAU8825_DAC_CAPACITOR_LSB (1 << 0) | ||
268 | |||
269 | /* ANALOG_ADC_2 (0x72) */ | ||
270 | #define NAU8825_ADC_VREFSEL_MASK (0x3 << 8) | ||
271 | #define NAU8825_ADC_VREFSEL_ANALOG (0 << 8) | ||
272 | #define NAU8825_ADC_VREFSEL_VMID (1 << 8) | ||
273 | #define NAU8825_ADC_VREFSEL_VMID_PLUS_0_5DB (2 << 8) | ||
274 | #define NAU8825_ADC_VREFSEL_VMID_PLUS_1DB (3 << 8) | ||
275 | #define NAU8825_POWERUP_ADCL (1 << 6) | ||
276 | |||
277 | /* MIC_BIAS (0x74) */ | ||
278 | #define NAU8825_MICBIAS_JKSLV (1 << 14) | ||
279 | #define NAU8825_MICBIAS_JKR2 (1 << 12) | ||
280 | #define NAU8825_MICBIAS_POWERUP_SFT 8 | ||
281 | #define NAU8825_MICBIAS_VOLTAGE_SFT 0 | ||
282 | #define NAU8825_MICBIAS_VOLTAGE_MASK 0x7 | ||
283 | |||
284 | /* BOOST (0x76) */ | ||
285 | #define NAU8825_PRECHARGE_DIS (1 << 13) | ||
286 | #define NAU8825_GLOBAL_BIAS_EN (1 << 12) | ||
287 | #define NAU8825_HP_BOOST_G_DIS (1 << 8) | ||
288 | #define NAU8825_SHORT_SHUTDOWN_EN (1 << 6) | ||
289 | |||
290 | /* POWER_UP_CONTROL (0x7f) */ | ||
291 | #define NAU8825_POWERUP_INTEGR_R (1 << 5) | ||
292 | #define NAU8825_POWERUP_INTEGR_L (1 << 4) | ||
293 | #define NAU8825_POWERUP_DRV_IN_R (1 << 3) | ||
294 | #define NAU8825_POWERUP_DRV_IN_L (1 << 2) | ||
295 | #define NAU8825_POWERUP_HP_DRV_R (1 << 1) | ||
296 | #define NAU8825_POWERUP_HP_DRV_L (1 << 0) | ||
297 | |||
298 | /* CHARGE_PUMP (0x80) */ | ||
299 | #define NAU8825_JAMNODCLOW (1 << 10) | ||
300 | #define NAU8825_POWER_DOWN_DACR (1 << 9) | ||
301 | #define NAU8825_POWER_DOWN_DACL (1 << 8) | ||
302 | #define NAU8825_CHANRGE_PUMP_EN (1 << 5) | ||
303 | |||
304 | |||
305 | /* System Clock Source */ | ||
306 | enum { | ||
307 | NAU8825_CLK_MCLK = 0, | ||
308 | NAU8825_CLK_INTERNAL, | ||
309 | }; | ||
310 | |||
311 | struct nau8825 { | ||
312 | struct device *dev; | ||
313 | struct regmap *regmap; | ||
314 | struct snd_soc_dapm_context *dapm; | ||
315 | struct snd_soc_jack *jack; | ||
316 | struct clk *mclk; | ||
317 | int irq; | ||
318 | int mclk_freq; /* 0 - mclk is disabled */ | ||
319 | int button_pressed; | ||
320 | int micbias_voltage; | ||
321 | int vref_impedance; | ||
322 | bool jkdet_enable; | ||
323 | bool jkdet_pull_enable; | ||
324 | bool jkdet_pull_up; | ||
325 | int jkdet_polarity; | ||
326 | int sar_threshold_num; | ||
327 | int sar_threshold[8]; | ||
328 | int sar_hysteresis; | ||
329 | int sar_voltage; | ||
330 | int sar_compare_time; | ||
331 | int sar_sampling_time; | ||
332 | int key_debounce; | ||
333 | int jack_insert_debounce; | ||
334 | int jack_eject_debounce; | ||
335 | }; | ||
336 | |||
337 | int nau8825_enable_jack_detect(struct snd_soc_codec *codec, | ||
338 | struct snd_soc_jack *jack); | ||
339 | |||
340 | |||
341 | #endif /* __NAU8825_H__ */ | ||
diff --git a/sound/soc/codecs/rl6347a.c b/sound/soc/codecs/rl6347a.c index 91d5166bd3a1..a4b910efbd45 100644 --- a/sound/soc/codecs/rl6347a.c +++ b/sound/soc/codecs/rl6347a.c | |||
@@ -11,25 +11,8 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/moduleparam.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/pm.h> | ||
18 | #include <linux/i2c.h> | 14 | #include <linux/i2c.h> |
19 | #include <linux/platform_device.h> | 15 | #include <linux/regmap.h> |
20 | #include <linux/spi/spi.h> | ||
21 | #include <linux/dmi.h> | ||
22 | #include <linux/acpi.h> | ||
23 | #include <sound/core.h> | ||
24 | #include <sound/pcm.h> | ||
25 | #include <sound/pcm_params.h> | ||
26 | #include <sound/soc.h> | ||
27 | #include <sound/soc-dapm.h> | ||
28 | #include <sound/initval.h> | ||
29 | #include <sound/tlv.h> | ||
30 | #include <sound/jack.h> | ||
31 | #include <linux/workqueue.h> | ||
32 | #include <sound/hda_verbs.h> | ||
33 | 16 | ||
34 | #include "rl6347a.h" | 17 | #include "rl6347a.h" |
35 | 18 | ||
diff --git a/sound/soc/codecs/rl6347a.h b/sound/soc/codecs/rl6347a.h index 1cb56e50b7f3..e127919cb36b 100644 --- a/sound/soc/codecs/rl6347a.h +++ b/sound/soc/codecs/rl6347a.h | |||
@@ -12,6 +12,8 @@ | |||
12 | #ifndef __RL6347A_H__ | 12 | #ifndef __RL6347A_H__ |
13 | #define __RL6347A_H__ | 13 | #define __RL6347A_H__ |
14 | 14 | ||
15 | #include <sound/hda_verbs.h> | ||
16 | |||
15 | #define VERB_CMD(V, N, D) ((N << 20) | (V << 8) | D) | 17 | #define VERB_CMD(V, N, D) ((N << 20) | (V << 8) | D) |
16 | 18 | ||
17 | #define RL6347A_VENDOR_REGISTERS 0x20 | 19 | #define RL6347A_VENDOR_REGISTERS 0x20 |
diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index bd9365885f73..af2ed774b552 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <sound/jack.h> | 29 | #include <sound/jack.h> |
30 | #include <linux/workqueue.h> | 30 | #include <linux/workqueue.h> |
31 | #include <sound/rt286.h> | 31 | #include <sound/rt286.h> |
32 | #include <sound/hda_verbs.h> | ||
33 | 32 | ||
34 | #include "rl6347a.h" | 33 | #include "rl6347a.h" |
35 | #include "rt286.h" | 34 | #include "rt286.h" |
@@ -38,7 +37,7 @@ | |||
38 | #define RT288_VENDOR_ID 0x10ec0288 | 37 | #define RT288_VENDOR_ID 0x10ec0288 |
39 | 38 | ||
40 | struct rt286_priv { | 39 | struct rt286_priv { |
41 | const struct reg_default *index_cache; | 40 | struct reg_default *index_cache; |
42 | int index_cache_size; | 41 | int index_cache_size; |
43 | struct regmap *regmap; | 42 | struct regmap *regmap; |
44 | struct snd_soc_codec *codec; | 43 | struct snd_soc_codec *codec; |
@@ -1161,7 +1160,11 @@ static int rt286_i2c_probe(struct i2c_client *i2c, | |||
1161 | return -ENODEV; | 1160 | return -ENODEV; |
1162 | } | 1161 | } |
1163 | 1162 | ||
1164 | rt286->index_cache = rt286_index_def; | 1163 | rt286->index_cache = devm_kmemdup(&i2c->dev, rt286_index_def, |
1164 | sizeof(rt286_index_def), GFP_KERNEL); | ||
1165 | if (!rt286->index_cache) | ||
1166 | return -ENOMEM; | ||
1167 | |||
1165 | rt286->index_cache_size = INDEX_CACHE_SIZE; | 1168 | rt286->index_cache_size = INDEX_CACHE_SIZE; |
1166 | rt286->i2c = i2c; | 1169 | rt286->i2c = i2c; |
1167 | i2c_set_clientdata(i2c, rt286); | 1170 | i2c_set_clientdata(i2c, rt286); |
diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c index 3c2f0f8d6266..b3f795c60749 100644 --- a/sound/soc/codecs/rt298.c +++ b/sound/soc/codecs/rt298.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <sound/jack.h> | 28 | #include <sound/jack.h> |
29 | #include <linux/workqueue.h> | 29 | #include <linux/workqueue.h> |
30 | #include <sound/rt298.h> | 30 | #include <sound/rt298.h> |
31 | #include <sound/hda_verbs.h> | ||
32 | 31 | ||
33 | #include "rl6347a.h" | 32 | #include "rl6347a.h" |
34 | #include "rt298.h" | 33 | #include "rt298.h" |
@@ -49,25 +48,25 @@ struct rt298_priv { | |||
49 | int is_hp_in; | 48 | int is_hp_in; |
50 | }; | 49 | }; |
51 | 50 | ||
52 | static struct reg_default rt298_index_def[] = { | 51 | static const struct reg_default rt298_index_def[] = { |
53 | { 0x01, 0xaaaa }, | 52 | { 0x01, 0xa5a8 }, |
54 | { 0x02, 0x8aaa }, | 53 | { 0x02, 0x8e95 }, |
55 | { 0x03, 0x0002 }, | 54 | { 0x03, 0x0002 }, |
56 | { 0x04, 0xaf01 }, | 55 | { 0x04, 0xaf67 }, |
57 | { 0x08, 0x000d }, | 56 | { 0x08, 0x200f }, |
58 | { 0x09, 0xd810 }, | 57 | { 0x09, 0xd010 }, |
59 | { 0x0a, 0x0120 }, | 58 | { 0x0a, 0x0100 }, |
60 | { 0x0b, 0x0000 }, | 59 | { 0x0b, 0x0000 }, |
61 | { 0x0d, 0x2800 }, | 60 | { 0x0d, 0x2800 }, |
62 | { 0x0f, 0x0000 }, | 61 | { 0x0f, 0x0022 }, |
63 | { 0x19, 0x0a17 }, | 62 | { 0x19, 0x0217 }, |
64 | { 0x20, 0x0020 }, | 63 | { 0x20, 0x0020 }, |
65 | { 0x33, 0x0208 }, | 64 | { 0x33, 0x0208 }, |
66 | { 0x46, 0x0300 }, | 65 | { 0x46, 0x0300 }, |
67 | { 0x49, 0x0004 }, | 66 | { 0x49, 0x4004 }, |
68 | { 0x4f, 0x50e9 }, | 67 | { 0x4f, 0x50c9 }, |
69 | { 0x50, 0x2000 }, | 68 | { 0x50, 0x3000 }, |
70 | { 0x63, 0x2902 }, | 69 | { 0x63, 0x1b02 }, |
71 | { 0x67, 0x1111 }, | 70 | { 0x67, 0x1111 }, |
72 | { 0x68, 0x1016 }, | 71 | { 0x68, 0x1016 }, |
73 | { 0x69, 0x273f }, | 72 | { 0x69, 0x273f }, |
@@ -129,7 +128,7 @@ static bool rt298_volatile_register(struct device *dev, unsigned int reg) | |||
129 | case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT298_HP_OUT, 0): | 128 | case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT298_HP_OUT, 0): |
130 | return true; | 129 | return true; |
131 | default: | 130 | default: |
132 | return true; | 131 | return false; |
133 | } | 132 | } |
134 | 133 | ||
135 | 134 | ||
@@ -1165,7 +1164,11 @@ static int rt298_i2c_probe(struct i2c_client *i2c, | |||
1165 | return -ENODEV; | 1164 | return -ENODEV; |
1166 | } | 1165 | } |
1167 | 1166 | ||
1168 | rt298->index_cache = rt298_index_def; | 1167 | rt298->index_cache = devm_kmemdup(&i2c->dev, rt298_index_def, |
1168 | sizeof(rt298_index_def), GFP_KERNEL); | ||
1169 | if (!rt298->index_cache) | ||
1170 | return -ENOMEM; | ||
1171 | |||
1169 | rt298->index_cache_size = INDEX_CACHE_SIZE; | 1172 | rt298->index_cache_size = INDEX_CACHE_SIZE; |
1170 | rt298->i2c = i2c; | 1173 | rt298->i2c = i2c; |
1171 | i2c_set_clientdata(i2c, rt298); | 1174 | i2c_set_clientdata(i2c, rt298); |
@@ -1214,7 +1217,7 @@ static int rt298_i2c_probe(struct i2c_client *i2c, | |||
1214 | mdelay(10); | 1217 | mdelay(10); |
1215 | 1218 | ||
1216 | if (!rt298->pdata.gpio2_en) | 1219 | if (!rt298->pdata.gpio2_en) |
1217 | regmap_write(rt298->regmap, RT298_SET_DMIC2_DEFAULT, 0x4000); | 1220 | regmap_write(rt298->regmap, RT298_SET_DMIC2_DEFAULT, 0x40); |
1218 | else | 1221 | else |
1219 | regmap_write(rt298->regmap, RT298_SET_DMIC2_DEFAULT, 0); | 1222 | regmap_write(rt298->regmap, RT298_SET_DMIC2_DEFAULT, 0); |
1220 | 1223 | ||
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index e1ceeb885f7d..f2beb1aa5763 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c | |||
@@ -405,11 +405,14 @@ static const struct snd_kcontrol_new rt5640_snd_controls[] = { | |||
405 | SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5640_DAC1_DIG_VOL, | 405 | SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5640_DAC1_DIG_VOL, |
406 | RT5640_L_VOL_SFT, RT5640_R_VOL_SFT, | 406 | RT5640_L_VOL_SFT, RT5640_R_VOL_SFT, |
407 | 175, 0, dac_vol_tlv), | 407 | 175, 0, dac_vol_tlv), |
408 | /* IN1/IN2 Control */ | 408 | /* IN1/IN2/IN3 Control */ |
409 | SOC_SINGLE_TLV("IN1 Boost", RT5640_IN1_IN2, | 409 | SOC_SINGLE_TLV("IN1 Boost", RT5640_IN1_IN2, |
410 | RT5640_BST_SFT1, 8, 0, bst_tlv), | 410 | RT5640_BST_SFT1, 8, 0, bst_tlv), |
411 | SOC_SINGLE_TLV("IN2 Boost", RT5640_IN3_IN4, | 411 | SOC_SINGLE_TLV("IN2 Boost", RT5640_IN3_IN4, |
412 | RT5640_BST_SFT2, 8, 0, bst_tlv), | 412 | RT5640_BST_SFT2, 8, 0, bst_tlv), |
413 | SOC_SINGLE_TLV("IN3 Boost", RT5640_IN1_IN2, | ||
414 | RT5640_BST_SFT2, 8, 0, bst_tlv), | ||
415 | |||
413 | /* INL/INR Volume Control */ | 416 | /* INL/INR Volume Control */ |
414 | SOC_DOUBLE_TLV("IN Capture Volume", RT5640_INL_INR_VOL, | 417 | SOC_DOUBLE_TLV("IN Capture Volume", RT5640_INL_INR_VOL, |
415 | RT5640_INL_VOL_SFT, RT5640_INR_VOL_SFT, | 418 | RT5640_INL_VOL_SFT, RT5640_INR_VOL_SFT, |
@@ -598,6 +601,8 @@ static const struct snd_kcontrol_new rt5640_rec_l_mix[] = { | |||
598 | RT5640_M_HP_L_RM_L_SFT, 1, 1), | 601 | RT5640_M_HP_L_RM_L_SFT, 1, 1), |
599 | SOC_DAPM_SINGLE("INL Switch", RT5640_REC_L2_MIXER, | 602 | SOC_DAPM_SINGLE("INL Switch", RT5640_REC_L2_MIXER, |
600 | RT5640_M_IN_L_RM_L_SFT, 1, 1), | 603 | RT5640_M_IN_L_RM_L_SFT, 1, 1), |
604 | SOC_DAPM_SINGLE("BST3 Switch", RT5640_REC_L2_MIXER, | ||
605 | RT5640_M_BST2_RM_L_SFT, 1, 1), | ||
601 | SOC_DAPM_SINGLE("BST2 Switch", RT5640_REC_L2_MIXER, | 606 | SOC_DAPM_SINGLE("BST2 Switch", RT5640_REC_L2_MIXER, |
602 | RT5640_M_BST4_RM_L_SFT, 1, 1), | 607 | RT5640_M_BST4_RM_L_SFT, 1, 1), |
603 | SOC_DAPM_SINGLE("BST1 Switch", RT5640_REC_L2_MIXER, | 608 | SOC_DAPM_SINGLE("BST1 Switch", RT5640_REC_L2_MIXER, |
@@ -611,6 +616,8 @@ static const struct snd_kcontrol_new rt5640_rec_r_mix[] = { | |||
611 | RT5640_M_HP_R_RM_R_SFT, 1, 1), | 616 | RT5640_M_HP_R_RM_R_SFT, 1, 1), |
612 | SOC_DAPM_SINGLE("INR Switch", RT5640_REC_R2_MIXER, | 617 | SOC_DAPM_SINGLE("INR Switch", RT5640_REC_R2_MIXER, |
613 | RT5640_M_IN_R_RM_R_SFT, 1, 1), | 618 | RT5640_M_IN_R_RM_R_SFT, 1, 1), |
619 | SOC_DAPM_SINGLE("BST3 Switch", RT5640_REC_R2_MIXER, | ||
620 | RT5640_M_BST2_RM_R_SFT, 1, 1), | ||
614 | SOC_DAPM_SINGLE("BST2 Switch", RT5640_REC_R2_MIXER, | 621 | SOC_DAPM_SINGLE("BST2 Switch", RT5640_REC_R2_MIXER, |
615 | RT5640_M_BST4_RM_R_SFT, 1, 1), | 622 | RT5640_M_BST4_RM_R_SFT, 1, 1), |
616 | SOC_DAPM_SINGLE("BST1 Switch", RT5640_REC_R2_MIXER, | 623 | SOC_DAPM_SINGLE("BST1 Switch", RT5640_REC_R2_MIXER, |
@@ -1065,6 +1072,8 @@ static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] = { | |||
1065 | SND_SOC_DAPM_INPUT("IN1N"), | 1072 | SND_SOC_DAPM_INPUT("IN1N"), |
1066 | SND_SOC_DAPM_INPUT("IN2P"), | 1073 | SND_SOC_DAPM_INPUT("IN2P"), |
1067 | SND_SOC_DAPM_INPUT("IN2N"), | 1074 | SND_SOC_DAPM_INPUT("IN2N"), |
1075 | SND_SOC_DAPM_INPUT("IN3P"), | ||
1076 | SND_SOC_DAPM_INPUT("IN3N"), | ||
1068 | SND_SOC_DAPM_PGA("DMIC L1", SND_SOC_NOPM, 0, 0, NULL, 0), | 1077 | SND_SOC_DAPM_PGA("DMIC L1", SND_SOC_NOPM, 0, 0, NULL, 0), |
1069 | SND_SOC_DAPM_PGA("DMIC R1", SND_SOC_NOPM, 0, 0, NULL, 0), | 1078 | SND_SOC_DAPM_PGA("DMIC R1", SND_SOC_NOPM, 0, 0, NULL, 0), |
1070 | SND_SOC_DAPM_PGA("DMIC L2", SND_SOC_NOPM, 0, 0, NULL, 0), | 1079 | SND_SOC_DAPM_PGA("DMIC L2", SND_SOC_NOPM, 0, 0, NULL, 0), |
@@ -1081,6 +1090,8 @@ static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] = { | |||
1081 | RT5640_PWR_BST1_BIT, 0, NULL, 0), | 1090 | RT5640_PWR_BST1_BIT, 0, NULL, 0), |
1082 | SND_SOC_DAPM_PGA("BST2", RT5640_PWR_ANLG2, | 1091 | SND_SOC_DAPM_PGA("BST2", RT5640_PWR_ANLG2, |
1083 | RT5640_PWR_BST4_BIT, 0, NULL, 0), | 1092 | RT5640_PWR_BST4_BIT, 0, NULL, 0), |
1093 | SND_SOC_DAPM_PGA("BST3", RT5640_PWR_ANLG2, | ||
1094 | RT5640_PWR_BST2_BIT, 0, NULL, 0), | ||
1084 | /* Input Volume */ | 1095 | /* Input Volume */ |
1085 | SND_SOC_DAPM_PGA("INL VOL", RT5640_PWR_VOL, | 1096 | SND_SOC_DAPM_PGA("INL VOL", RT5640_PWR_VOL, |
1086 | RT5640_PWR_IN_L_BIT, 0, NULL, 0), | 1097 | RT5640_PWR_IN_L_BIT, 0, NULL, 0), |
@@ -1310,6 +1321,7 @@ static const struct snd_soc_dapm_widget rt5639_specific_dapm_widgets[] = { | |||
1310 | static const struct snd_soc_dapm_route rt5640_dapm_routes[] = { | 1321 | static const struct snd_soc_dapm_route rt5640_dapm_routes[] = { |
1311 | {"IN1P", NULL, "LDO2"}, | 1322 | {"IN1P", NULL, "LDO2"}, |
1312 | {"IN2P", NULL, "LDO2"}, | 1323 | {"IN2P", NULL, "LDO2"}, |
1324 | {"IN3P", NULL, "LDO2"}, | ||
1313 | 1325 | ||
1314 | {"DMIC L1", NULL, "DMIC1"}, | 1326 | {"DMIC L1", NULL, "DMIC1"}, |
1315 | {"DMIC R1", NULL, "DMIC1"}, | 1327 | {"DMIC R1", NULL, "DMIC1"}, |
@@ -1320,18 +1332,22 @@ static const struct snd_soc_dapm_route rt5640_dapm_routes[] = { | |||
1320 | {"BST1", NULL, "IN1N"}, | 1332 | {"BST1", NULL, "IN1N"}, |
1321 | {"BST2", NULL, "IN2P"}, | 1333 | {"BST2", NULL, "IN2P"}, |
1322 | {"BST2", NULL, "IN2N"}, | 1334 | {"BST2", NULL, "IN2N"}, |
1335 | {"BST3", NULL, "IN3P"}, | ||
1336 | {"BST3", NULL, "IN3N"}, | ||
1323 | 1337 | ||
1324 | {"INL VOL", NULL, "IN2P"}, | 1338 | {"INL VOL", NULL, "IN2P"}, |
1325 | {"INR VOL", NULL, "IN2N"}, | 1339 | {"INR VOL", NULL, "IN2N"}, |
1326 | 1340 | ||
1327 | {"RECMIXL", "HPOL Switch", "HPOL"}, | 1341 | {"RECMIXL", "HPOL Switch", "HPOL"}, |
1328 | {"RECMIXL", "INL Switch", "INL VOL"}, | 1342 | {"RECMIXL", "INL Switch", "INL VOL"}, |
1343 | {"RECMIXL", "BST3 Switch", "BST3"}, | ||
1329 | {"RECMIXL", "BST2 Switch", "BST2"}, | 1344 | {"RECMIXL", "BST2 Switch", "BST2"}, |
1330 | {"RECMIXL", "BST1 Switch", "BST1"}, | 1345 | {"RECMIXL", "BST1 Switch", "BST1"}, |
1331 | {"RECMIXL", "OUT MIXL Switch", "OUT MIXL"}, | 1346 | {"RECMIXL", "OUT MIXL Switch", "OUT MIXL"}, |
1332 | 1347 | ||
1333 | {"RECMIXR", "HPOR Switch", "HPOR"}, | 1348 | {"RECMIXR", "HPOR Switch", "HPOR"}, |
1334 | {"RECMIXR", "INR Switch", "INR VOL"}, | 1349 | {"RECMIXR", "INR Switch", "INR VOL"}, |
1350 | {"RECMIXR", "BST3 Switch", "BST3"}, | ||
1335 | {"RECMIXR", "BST2 Switch", "BST2"}, | 1351 | {"RECMIXR", "BST2 Switch", "BST2"}, |
1336 | {"RECMIXR", "BST1 Switch", "BST1"}, | 1352 | {"RECMIXR", "BST1 Switch", "BST1"}, |
1337 | {"RECMIXR", "OUT MIXR Switch", "OUT MIXR"}, | 1353 | {"RECMIXR", "OUT MIXR Switch", "OUT MIXR"}, |
@@ -2260,6 +2276,10 @@ static int rt5640_i2c_probe(struct i2c_client *i2c, | |||
2260 | regmap_update_bits(rt5640->regmap, RT5640_IN3_IN4, | 2276 | regmap_update_bits(rt5640->regmap, RT5640_IN3_IN4, |
2261 | RT5640_IN_DF2, RT5640_IN_DF2); | 2277 | RT5640_IN_DF2, RT5640_IN_DF2); |
2262 | 2278 | ||
2279 | if (rt5640->pdata.in3_diff) | ||
2280 | regmap_update_bits(rt5640->regmap, RT5640_IN1_IN2, | ||
2281 | RT5640_IN_DF2, RT5640_IN_DF2); | ||
2282 | |||
2263 | rt5640->hp_mute = 1; | 2283 | rt5640->hp_mute = 1; |
2264 | 2284 | ||
2265 | return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5640, | 2285 | return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5640, |
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 080cc1ce3963..28132375e427 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c | |||
@@ -42,6 +42,8 @@ | |||
42 | 42 | ||
43 | #define RT5645_PR_BASE (RT5645_PR_RANGE_BASE + (0 * RT5645_PR_SPACING)) | 43 | #define RT5645_PR_BASE (RT5645_PR_RANGE_BASE + (0 * RT5645_PR_SPACING)) |
44 | 44 | ||
45 | #define RT5645_HWEQ_NUM 57 | ||
46 | |||
45 | static const struct regmap_range_cfg rt5645_ranges[] = { | 47 | static const struct regmap_range_cfg rt5645_ranges[] = { |
46 | { | 48 | { |
47 | .name = "PR", | 49 | .name = "PR", |
@@ -224,6 +226,11 @@ static const struct reg_default rt5645_reg[] = { | |||
224 | { 0xff, 0x6308 }, | 226 | { 0xff, 0x6308 }, |
225 | }; | 227 | }; |
226 | 228 | ||
229 | struct rt5645_eq_param_s { | ||
230 | unsigned short reg; | ||
231 | unsigned short val; | ||
232 | }; | ||
233 | |||
227 | static const char *const rt5645_supply_names[] = { | 234 | static const char *const rt5645_supply_names[] = { |
228 | "avdd", | 235 | "avdd", |
229 | "cpvdd", | 236 | "cpvdd", |
@@ -240,6 +247,7 @@ struct rt5645_priv { | |||
240 | struct snd_soc_jack *btn_jack; | 247 | struct snd_soc_jack *btn_jack; |
241 | struct delayed_work jack_detect_work; | 248 | struct delayed_work jack_detect_work; |
242 | struct regulator_bulk_data supplies[ARRAY_SIZE(rt5645_supply_names)]; | 249 | struct regulator_bulk_data supplies[ARRAY_SIZE(rt5645_supply_names)]; |
250 | struct rt5645_eq_param_s *eq_param; | ||
243 | 251 | ||
244 | int codec_type; | 252 | int codec_type; |
245 | int sysclk; | 253 | int sysclk; |
@@ -469,6 +477,94 @@ static const DECLARE_TLV_DB_RANGE(bst_tlv, | |||
469 | 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0) | 477 | 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0) |
470 | ); | 478 | ); |
471 | 479 | ||
480 | /* {-6, -4.5, -3, -1.5, 0, 0.82, 1.58, 2.28} dB */ | ||
481 | static const DECLARE_TLV_DB_RANGE(spk_clsd_tlv, | ||
482 | 0, 4, TLV_DB_SCALE_ITEM(-600, 150, 0), | ||
483 | 5, 5, TLV_DB_SCALE_ITEM(82, 0, 0), | ||
484 | 6, 6, TLV_DB_SCALE_ITEM(158, 0, 0), | ||
485 | 7, 7, TLV_DB_SCALE_ITEM(228, 0, 0) | ||
486 | ); | ||
487 | |||
488 | static int rt5645_hweq_info(struct snd_kcontrol *kcontrol, | ||
489 | struct snd_ctl_elem_info *uinfo) | ||
490 | { | ||
491 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; | ||
492 | uinfo->count = RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s); | ||
493 | |||
494 | return 0; | ||
495 | } | ||
496 | |||
497 | static int rt5645_hweq_get(struct snd_kcontrol *kcontrol, | ||
498 | struct snd_ctl_elem_value *ucontrol) | ||
499 | { | ||
500 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
501 | struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); | ||
502 | struct rt5645_eq_param_s *eq_param = | ||
503 | (struct rt5645_eq_param_s *)ucontrol->value.bytes.data; | ||
504 | int i; | ||
505 | |||
506 | for (i = 0; i < RT5645_HWEQ_NUM; i++) { | ||
507 | eq_param[i].reg = cpu_to_be16(rt5645->eq_param[i].reg); | ||
508 | eq_param[i].val = cpu_to_be16(rt5645->eq_param[i].val); | ||
509 | } | ||
510 | |||
511 | return 0; | ||
512 | } | ||
513 | |||
514 | static bool rt5645_validate_hweq(unsigned short reg) | ||
515 | { | ||
516 | if ((reg >= 0x1a4 && reg <= 0x1cd) | (reg >= 0x1e5 && reg <= 0x1f8) | | ||
517 | (reg == RT5645_EQ_CTRL2)) | ||
518 | return true; | ||
519 | |||
520 | return false; | ||
521 | } | ||
522 | |||
523 | static int rt5645_hweq_put(struct snd_kcontrol *kcontrol, | ||
524 | struct snd_ctl_elem_value *ucontrol) | ||
525 | { | ||
526 | struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); | ||
527 | struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); | ||
528 | struct rt5645_eq_param_s *eq_param = | ||
529 | (struct rt5645_eq_param_s *)ucontrol->value.bytes.data; | ||
530 | int i; | ||
531 | |||
532 | for (i = 0; i < RT5645_HWEQ_NUM; i++) { | ||
533 | eq_param[i].reg = be16_to_cpu(eq_param[i].reg); | ||
534 | eq_param[i].val = be16_to_cpu(eq_param[i].val); | ||
535 | } | ||
536 | |||
537 | /* The final setting of the table should be RT5645_EQ_CTRL2 */ | ||
538 | for (i = RT5645_HWEQ_NUM - 1; i >= 0; i--) { | ||
539 | if (eq_param[i].reg == 0) | ||
540 | continue; | ||
541 | else if (eq_param[i].reg != RT5645_EQ_CTRL2) | ||
542 | return 0; | ||
543 | else | ||
544 | break; | ||
545 | } | ||
546 | |||
547 | for (i = 0; i < RT5645_HWEQ_NUM; i++) { | ||
548 | if (!rt5645_validate_hweq(eq_param[i].reg) && | ||
549 | eq_param[i].reg != 0) | ||
550 | return 0; | ||
551 | else if (eq_param[i].reg == 0) | ||
552 | break; | ||
553 | } | ||
554 | |||
555 | memcpy(rt5645->eq_param, eq_param, | ||
556 | RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s)); | ||
557 | |||
558 | return 0; | ||
559 | } | ||
560 | |||
561 | #define RT5645_HWEQ(xname) \ | ||
562 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | ||
563 | .info = rt5645_hweq_info, \ | ||
564 | .get = rt5645_hweq_get, \ | ||
565 | .put = rt5645_hweq_put \ | ||
566 | } | ||
567 | |||
472 | static const struct snd_kcontrol_new rt5645_snd_controls[] = { | 568 | static const struct snd_kcontrol_new rt5645_snd_controls[] = { |
473 | /* Speaker Output Volume */ | 569 | /* Speaker Output Volume */ |
474 | SOC_DOUBLE("Speaker Channel Switch", RT5645_SPK_VOL, | 570 | SOC_DOUBLE("Speaker Channel Switch", RT5645_SPK_VOL, |
@@ -476,6 +572,10 @@ static const struct snd_kcontrol_new rt5645_snd_controls[] = { | |||
476 | SOC_DOUBLE_TLV("Speaker Playback Volume", RT5645_SPK_VOL, | 572 | SOC_DOUBLE_TLV("Speaker Playback Volume", RT5645_SPK_VOL, |
477 | RT5645_L_VOL_SFT, RT5645_R_VOL_SFT, 39, 1, out_vol_tlv), | 573 | RT5645_L_VOL_SFT, RT5645_R_VOL_SFT, 39, 1, out_vol_tlv), |
478 | 574 | ||
575 | /* ClassD modulator Speaker Gain Ratio */ | ||
576 | SOC_SINGLE_TLV("Speaker ClassD Playback Volume", RT5645_SPO_CLSD_RATIO, | ||
577 | RT5645_SPK_G_CLSD_SFT, 7, 0, spk_clsd_tlv), | ||
578 | |||
479 | /* Headphone Output Volume */ | 579 | /* Headphone Output Volume */ |
480 | SOC_DOUBLE("Headphone Channel Switch", RT5645_HP_VOL, | 580 | SOC_DOUBLE("Headphone Channel Switch", RT5645_HP_VOL, |
481 | RT5645_VOL_L_SFT, RT5645_VOL_R_SFT, 1, 1), | 581 | RT5645_VOL_L_SFT, RT5645_VOL_R_SFT, 1, 1), |
@@ -529,6 +629,7 @@ static const struct snd_kcontrol_new rt5645_snd_controls[] = { | |||
529 | /* I2S2 function select */ | 629 | /* I2S2 function select */ |
530 | SOC_SINGLE("I2S2 Func Switch", RT5645_GPIO_CTRL1, RT5645_I2S2_SEL_SFT, | 630 | SOC_SINGLE("I2S2 Func Switch", RT5645_GPIO_CTRL1, RT5645_I2S2_SEL_SFT, |
531 | 1, 1), | 631 | 1, 1), |
632 | RT5645_HWEQ("Speaker HWEQ"), | ||
532 | }; | 633 | }; |
533 | 634 | ||
534 | /** | 635 | /** |
@@ -619,6 +720,22 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, | |||
619 | 720 | ||
620 | } | 721 | } |
621 | 722 | ||
723 | static int rt5645_enable_hweq(struct snd_soc_codec *codec) | ||
724 | { | ||
725 | struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); | ||
726 | int i; | ||
727 | |||
728 | for (i = 0; i < RT5645_HWEQ_NUM; i++) { | ||
729 | if (rt5645_validate_hweq(rt5645->eq_param[i].reg)) | ||
730 | regmap_write(rt5645->regmap, rt5645->eq_param[i].reg, | ||
731 | rt5645->eq_param[i].val); | ||
732 | else | ||
733 | break; | ||
734 | } | ||
735 | |||
736 | return 0; | ||
737 | } | ||
738 | |||
622 | /** | 739 | /** |
623 | * rt5645_sel_asrc_clk_src - select ASRC clock source for a set of filters | 740 | * rt5645_sel_asrc_clk_src - select ASRC clock source for a set of filters |
624 | * @codec: SoC audio codec device. | 741 | * @codec: SoC audio codec device. |
@@ -1523,6 +1640,7 @@ static int rt5645_spk_event(struct snd_soc_dapm_widget *w, | |||
1523 | 1640 | ||
1524 | switch (event) { | 1641 | switch (event) { |
1525 | case SND_SOC_DAPM_POST_PMU: | 1642 | case SND_SOC_DAPM_POST_PMU: |
1643 | rt5645_enable_hweq(codec); | ||
1526 | snd_soc_update_bits(codec, RT5645_PWR_DIG1, | 1644 | snd_soc_update_bits(codec, RT5645_PWR_DIG1, |
1527 | RT5645_PWR_CLS_D | RT5645_PWR_CLS_D_R | | 1645 | RT5645_PWR_CLS_D | RT5645_PWR_CLS_D_R | |
1528 | RT5645_PWR_CLS_D_L, | 1646 | RT5645_PWR_CLS_D_L, |
@@ -1531,6 +1649,7 @@ static int rt5645_spk_event(struct snd_soc_dapm_widget *w, | |||
1531 | break; | 1649 | break; |
1532 | 1650 | ||
1533 | case SND_SOC_DAPM_PRE_PMD: | 1651 | case SND_SOC_DAPM_PRE_PMD: |
1652 | snd_soc_write(codec, RT5645_EQ_CTRL2, 0); | ||
1534 | snd_soc_update_bits(codec, RT5645_PWR_DIG1, | 1653 | snd_soc_update_bits(codec, RT5645_PWR_DIG1, |
1535 | RT5645_PWR_CLS_D | RT5645_PWR_CLS_D_R | | 1654 | RT5645_PWR_CLS_D | RT5645_PWR_CLS_D_R | |
1536 | RT5645_PWR_CLS_D_L, 0); | 1655 | RT5645_PWR_CLS_D_L, 0); |
@@ -2733,6 +2852,10 @@ static int rt5645_set_bias_level(struct snd_soc_codec *codec, | |||
2733 | snd_soc_update_bits(codec, RT5645_PWR_ANLG1, | 2852 | snd_soc_update_bits(codec, RT5645_PWR_ANLG1, |
2734 | RT5645_PWR_FV1 | RT5645_PWR_FV2, | 2853 | RT5645_PWR_FV1 | RT5645_PWR_FV2, |
2735 | RT5645_PWR_FV1 | RT5645_PWR_FV2); | 2854 | RT5645_PWR_FV1 | RT5645_PWR_FV2); |
2855 | if (rt5645->en_button_func && | ||
2856 | snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) | ||
2857 | queue_delayed_work(system_power_efficient_wq, | ||
2858 | &rt5645->jack_detect_work, msecs_to_jiffies(0)); | ||
2736 | break; | 2859 | break; |
2737 | 2860 | ||
2738 | case SND_SOC_BIAS_OFF: | 2861 | case SND_SOC_BIAS_OFF: |
@@ -3044,6 +3167,9 @@ static int rt5645_probe(struct snd_soc_codec *codec) | |||
3044 | snd_soc_dapm_sync(dapm); | 3167 | snd_soc_dapm_sync(dapm); |
3045 | } | 3168 | } |
3046 | 3169 | ||
3170 | rt5645->eq_param = devm_kzalloc(codec->dev, | ||
3171 | RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s), GFP_KERNEL); | ||
3172 | |||
3047 | return 0; | 3173 | return 0; |
3048 | } | 3174 | } |
3049 | 3175 | ||
@@ -3104,7 +3230,7 @@ static struct snd_soc_dai_driver rt5645_dai[] = { | |||
3104 | .capture = { | 3230 | .capture = { |
3105 | .stream_name = "AIF1 Capture", | 3231 | .stream_name = "AIF1 Capture", |
3106 | .channels_min = 1, | 3232 | .channels_min = 1, |
3107 | .channels_max = 2, | 3233 | .channels_max = 4, |
3108 | .rates = RT5645_STEREO_RATES, | 3234 | .rates = RT5645_STEREO_RATES, |
3109 | .formats = RT5645_FORMATS, | 3235 | .formats = RT5645_FORMATS, |
3110 | }, | 3236 | }, |
@@ -3215,6 +3341,13 @@ static const struct dmi_system_id dmi_platform_intel_braswell[] = { | |||
3215 | DMI_MATCH(DMI_PRODUCT_NAME, "Ultima"), | 3341 | DMI_MATCH(DMI_PRODUCT_NAME, "Ultima"), |
3216 | }, | 3342 | }, |
3217 | }, | 3343 | }, |
3344 | { | ||
3345 | .ident = "Google Reks", | ||
3346 | .callback = strago_quirk_cb, | ||
3347 | .matches = { | ||
3348 | DMI_MATCH(DMI_PRODUCT_NAME, "Reks"), | ||
3349 | }, | ||
3350 | }, | ||
3218 | { } | 3351 | { } |
3219 | }; | 3352 | }; |
3220 | 3353 | ||
@@ -3232,7 +3365,7 @@ static int buddy_quirk_cb(const struct dmi_system_id *id) | |||
3232 | return 1; | 3365 | return 1; |
3233 | } | 3366 | } |
3234 | 3367 | ||
3235 | static struct dmi_system_id dmi_platform_intel_broadwell[] __initdata = { | 3368 | static struct dmi_system_id dmi_platform_intel_broadwell[] = { |
3236 | { | 3369 | { |
3237 | .ident = "Chrome Buddy", | 3370 | .ident = "Chrome Buddy", |
3238 | .callback = buddy_quirk_cb, | 3371 | .callback = buddy_quirk_cb, |
@@ -3505,6 +3638,8 @@ static void rt5645_i2c_shutdown(struct i2c_client *i2c) | |||
3505 | RT5645_CBJ_MN_JD); | 3638 | RT5645_CBJ_MN_JD); |
3506 | regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1, RT5645_CBJ_BST1_EN, | 3639 | regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1, RT5645_CBJ_BST1_EN, |
3507 | 0); | 3640 | 0); |
3641 | msleep(20); | ||
3642 | regmap_write(rt5645->regmap, RT5645_RESET, 0); | ||
3508 | } | 3643 | } |
3509 | 3644 | ||
3510 | static struct i2c_driver rt5645_i2c_driver = { | 3645 | static struct i2c_driver rt5645_i2c_driver = { |
diff --git a/sound/soc/codecs/rt5645.h b/sound/soc/codecs/rt5645.h index 61bc8ab77646..093e46d559fb 100644 --- a/sound/soc/codecs/rt5645.h +++ b/sound/soc/codecs/rt5645.h | |||
@@ -621,14 +621,14 @@ | |||
621 | #define RT5645_G_OM_L_SM_L_SFT 6 | 621 | #define RT5645_G_OM_L_SM_L_SFT 6 |
622 | #define RT5645_M_BST1_L_SM_L (0x1 << 5) | 622 | #define RT5645_M_BST1_L_SM_L (0x1 << 5) |
623 | #define RT5645_M_BST1_L_SM_L_SFT 5 | 623 | #define RT5645_M_BST1_L_SM_L_SFT 5 |
624 | #define RT5645_M_BST3_L_SM_L (0x1 << 4) | ||
625 | #define RT5645_M_BST3_L_SM_L_SFT 4 | ||
624 | #define RT5645_M_IN_L_SM_L (0x1 << 3) | 626 | #define RT5645_M_IN_L_SM_L (0x1 << 3) |
625 | #define RT5645_M_IN_L_SM_L_SFT 3 | 627 | #define RT5645_M_IN_L_SM_L_SFT 3 |
626 | #define RT5645_M_DAC_L1_SM_L (0x1 << 1) | ||
627 | #define RT5645_M_DAC_L1_SM_L_SFT 1 | ||
628 | #define RT5645_M_DAC_L2_SM_L (0x1 << 2) | 628 | #define RT5645_M_DAC_L2_SM_L (0x1 << 2) |
629 | #define RT5645_M_DAC_L2_SM_L_SFT 2 | 629 | #define RT5645_M_DAC_L2_SM_L_SFT 2 |
630 | #define RT5645_M_BST3_L_SM_L (0x1 << 4) | 630 | #define RT5645_M_DAC_L1_SM_L (0x1 << 1) |
631 | #define RT5645_M_BST3_L_SM_L_SFT 4 | 631 | #define RT5645_M_DAC_L1_SM_L_SFT 1 |
632 | 632 | ||
633 | /* SPK Right Mixer Control (0x47) */ | 633 | /* SPK Right Mixer Control (0x47) */ |
634 | #define RT5645_G_RM_R_SM_R_MASK (0x3 << 14) | 634 | #define RT5645_G_RM_R_SM_R_MASK (0x3 << 14) |
@@ -643,14 +643,14 @@ | |||
643 | #define RT5645_G_OM_R_SM_R_SFT 6 | 643 | #define RT5645_G_OM_R_SM_R_SFT 6 |
644 | #define RT5645_M_BST2_R_SM_R (0x1 << 5) | 644 | #define RT5645_M_BST2_R_SM_R (0x1 << 5) |
645 | #define RT5645_M_BST2_R_SM_R_SFT 5 | 645 | #define RT5645_M_BST2_R_SM_R_SFT 5 |
646 | #define RT5645_M_BST3_R_SM_R (0x1 << 4) | ||
647 | #define RT5645_M_BST3_R_SM_R_SFT 4 | ||
646 | #define RT5645_M_IN_R_SM_R (0x1 << 3) | 648 | #define RT5645_M_IN_R_SM_R (0x1 << 3) |
647 | #define RT5645_M_IN_R_SM_R_SFT 3 | 649 | #define RT5645_M_IN_R_SM_R_SFT 3 |
648 | #define RT5645_M_DAC_R1_SM_R (0x1 << 1) | ||
649 | #define RT5645_M_DAC_R1_SM_R_SFT 1 | ||
650 | #define RT5645_M_DAC_R2_SM_R (0x1 << 2) | 650 | #define RT5645_M_DAC_R2_SM_R (0x1 << 2) |
651 | #define RT5645_M_DAC_R2_SM_R_SFT 2 | 651 | #define RT5645_M_DAC_R2_SM_R_SFT 2 |
652 | #define RT5645_M_BST3_R_SM_R (0x1 << 4) | 652 | #define RT5645_M_DAC_R1_SM_R (0x1 << 1) |
653 | #define RT5645_M_BST3_R_SM_R_SFT 4 | 653 | #define RT5645_M_DAC_R1_SM_R_SFT 1 |
654 | 654 | ||
655 | /* SPOLMIX Control (0x48) */ | 655 | /* SPOLMIX Control (0x48) */ |
656 | #define RT5645_M_DAC_L1_SPM_L (0x1 << 15) | 656 | #define RT5645_M_DAC_L1_SPM_L (0x1 << 15) |
@@ -670,13 +670,17 @@ | |||
670 | #define RT5645_M_SV_R_SPM_R (0x1 << 0) | 670 | #define RT5645_M_SV_R_SPM_R (0x1 << 0) |
671 | #define RT5645_M_SV_R_SPM_R_SFT 0 | 671 | #define RT5645_M_SV_R_SPM_R_SFT 0 |
672 | 672 | ||
673 | /* SPOMIX Ratio Control (0x4a) */ | ||
674 | #define RT5645_SPK_G_CLSD_MASK (0x7 << 0) | ||
675 | #define RT5645_SPK_G_CLSD_SFT 0 | ||
676 | |||
673 | /* Mono Output Mixer Control (0x4c) */ | 677 | /* Mono Output Mixer Control (0x4c) */ |
678 | #define RT5645_G_MONOMIX_MASK (0x1 << 10) | ||
679 | #define RT5645_G_MONOMIX_SFT 10 | ||
674 | #define RT5645_M_OV_L_MM (0x1 << 9) | 680 | #define RT5645_M_OV_L_MM (0x1 << 9) |
675 | #define RT5645_M_OV_L_MM_SFT 9 | 681 | #define RT5645_M_OV_L_MM_SFT 9 |
676 | #define RT5645_M_DAC_L2_MA (0x1 << 8) | 682 | #define RT5645_M_DAC_L2_MA (0x1 << 8) |
677 | #define RT5645_M_DAC_L2_MA_SFT 8 | 683 | #define RT5645_M_DAC_L2_MA_SFT 8 |
678 | #define RT5645_G_MONOMIX_MASK (0x1 << 10) | ||
679 | #define RT5645_G_MONOMIX_SFT 10 | ||
680 | #define RT5645_M_BST2_MM (0x1 << 4) | 684 | #define RT5645_M_BST2_MM (0x1 << 4) |
681 | #define RT5645_M_BST2_MM_SFT 4 | 685 | #define RT5645_M_BST2_MM_SFT 4 |
682 | #define RT5645_M_DAC_R1_MM (0x1 << 3) | 686 | #define RT5645_M_DAC_R1_MM (0x1 << 3) |
diff --git a/sound/soc/codecs/ssm2518.c b/sound/soc/codecs/ssm2518.c index ddb0203fc649..86b81a60ac52 100644 --- a/sound/soc/codecs/ssm2518.c +++ b/sound/soc/codecs/ssm2518.c | |||
@@ -723,17 +723,11 @@ static struct snd_soc_codec_driver ssm2518_codec_driver = { | |||
723 | .num_dapm_routes = ARRAY_SIZE(ssm2518_routes), | 723 | .num_dapm_routes = ARRAY_SIZE(ssm2518_routes), |
724 | }; | 724 | }; |
725 | 725 | ||
726 | static bool ssm2518_register_volatile(struct device *dev, unsigned int reg) | ||
727 | { | ||
728 | return false; | ||
729 | } | ||
730 | |||
731 | static const struct regmap_config ssm2518_regmap_config = { | 726 | static const struct regmap_config ssm2518_regmap_config = { |
732 | .val_bits = 8, | 727 | .val_bits = 8, |
733 | .reg_bits = 8, | 728 | .reg_bits = 8, |
734 | 729 | ||
735 | .max_register = SSM2518_REG_DRC_9, | 730 | .max_register = SSM2518_REG_DRC_9, |
736 | .volatile_reg = ssm2518_register_volatile, | ||
737 | 731 | ||
738 | .cache_type = REGCACHE_RBTREE, | 732 | .cache_type = REGCACHE_RBTREE, |
739 | .reg_defaults = ssm2518_reg_defaults, | 733 | .reg_defaults = ssm2518_reg_defaults, |
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 786abd02b140..a67ea10f41a1 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c | |||
@@ -620,7 +620,7 @@ static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, | |||
620 | { | 620 | { |
621 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 621 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
622 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); | 622 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); |
623 | int anc_active = ucontrol->value.integer.value[0]; | 623 | unsigned int anc_active = ucontrol->value.integer.value[0]; |
624 | int ret; | 624 | int ret; |
625 | 625 | ||
626 | if (anc_active > 1) | 626 | if (anc_active > 1) |
@@ -653,7 +653,7 @@ static int wm2000_speaker_put(struct snd_kcontrol *kcontrol, | |||
653 | { | 653 | { |
654 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 654 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
655 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); | 655 | struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); |
656 | int val = ucontrol->value.integer.value[0]; | 656 | unsigned int val = ucontrol->value.integer.value[0]; |
657 | int ret; | 657 | int ret; |
658 | 658 | ||
659 | if (val > 1) | 659 | if (val > 1) |
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index ace8645245a0..07cf1bd7913a 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c | |||
@@ -132,7 +132,7 @@ static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, | |||
132 | { | 132 | { |
133 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 133 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
134 | struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); | 134 | struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); |
135 | int deemph = ucontrol->value.integer.value[0]; | 135 | unsigned int deemph = ucontrol->value.integer.value[0]; |
136 | int ret = 0; | 136 | int ret = 0; |
137 | 137 | ||
138 | if (deemph > 1) | 138 | if (deemph > 1) |
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index b011253459af..e4cc41e6c23e 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
@@ -452,7 +452,7 @@ static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, | |||
452 | { | 452 | { |
453 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 453 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
454 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); | 454 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); |
455 | int deemph = ucontrol->value.integer.value[0]; | 455 | unsigned int deemph = ucontrol->value.integer.value[0]; |
456 | int ret = 0; | 456 | int ret = 0; |
457 | 457 | ||
458 | if (deemph > 1) | 458 | if (deemph > 1) |
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index b783743dc97e..2aa23f1b9e3c 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c | |||
@@ -534,7 +534,7 @@ static int wm8904_put_deemph(struct snd_kcontrol *kcontrol, | |||
534 | { | 534 | { |
535 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 535 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
536 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); | 536 | struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); |
537 | int deemph = ucontrol->value.integer.value[0]; | 537 | unsigned int deemph = ucontrol->value.integer.value[0]; |
538 | 538 | ||
539 | if (deemph > 1) | 539 | if (deemph > 1) |
540 | return -EINVAL; | 540 | return -EINVAL; |
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c index 12e4435f00f8..9db00d53abe7 100644 --- a/sound/soc/codecs/wm8955.c +++ b/sound/soc/codecs/wm8955.c | |||
@@ -402,7 +402,7 @@ static int wm8955_put_deemph(struct snd_kcontrol *kcontrol, | |||
402 | { | 402 | { |
403 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 403 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
404 | struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); | 404 | struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); |
405 | int deemph = ucontrol->value.integer.value[0]; | 405 | unsigned int deemph = ucontrol->value.integer.value[0]; |
406 | 406 | ||
407 | if (deemph > 1) | 407 | if (deemph > 1) |
408 | return -EINVAL; | 408 | return -EINVAL; |
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index dbd88408861a..056375339ea3 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c | |||
@@ -201,7 +201,7 @@ static int wm8960_put_deemph(struct snd_kcontrol *kcontrol, | |||
201 | { | 201 | { |
202 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 202 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
203 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); | 203 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); |
204 | int deemph = ucontrol->value.integer.value[0]; | 204 | unsigned int deemph = ucontrol->value.integer.value[0]; |
205 | 205 | ||
206 | if (deemph > 1) | 206 | if (deemph > 1) |
207 | return -EINVAL; | 207 | return -EINVAL; |
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 2fbc6ef8cbdb..39ebd7bf4f53 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c | |||
@@ -3808,6 +3808,8 @@ static int wm8962_runtime_resume(struct device *dev) | |||
3808 | 3808 | ||
3809 | wm8962_reset(wm8962); | 3809 | wm8962_reset(wm8962); |
3810 | 3810 | ||
3811 | regcache_mark_dirty(wm8962->regmap); | ||
3812 | |||
3811 | /* SYSCLK defaults to on; make sure it is off so we can safely | 3813 | /* SYSCLK defaults to on; make sure it is off so we can safely |
3812 | * write to registers if the device is declocked. | 3814 | * write to registers if the device is declocked. |
3813 | */ | 3815 | */ |
diff --git a/sound/soc/codecs/wm8998.c b/sound/soc/codecs/wm8998.c new file mode 100644 index 000000000000..8782dfb628ab --- /dev/null +++ b/sound/soc/codecs/wm8998.c | |||
@@ -0,0 +1,1430 @@ | |||
1 | /* | ||
2 | * wm8998.c -- ALSA SoC Audio driver for WM8998 codecs | ||
3 | * | ||
4 | * Copyright 2015 Cirrus Logic, Inc. | ||
5 | * | ||
6 | * Author: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> | ||
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 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/moduleparam.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/pm.h> | ||
18 | #include <linux/pm_runtime.h> | ||
19 | #include <linux/regmap.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <sound/core.h> | ||
22 | #include <sound/pcm.h> | ||
23 | #include <sound/pcm_params.h> | ||
24 | #include <sound/soc.h> | ||
25 | #include <sound/jack.h> | ||
26 | #include <sound/initval.h> | ||
27 | #include <sound/tlv.h> | ||
28 | |||
29 | #include <linux/mfd/arizona/core.h> | ||
30 | #include <linux/mfd/arizona/registers.h> | ||
31 | |||
32 | #include "arizona.h" | ||
33 | #include "wm8998.h" | ||
34 | |||
35 | struct wm8998_priv { | ||
36 | struct arizona_priv core; | ||
37 | struct arizona_fll fll[2]; | ||
38 | }; | ||
39 | |||
40 | static int wm8998_asrc_ev(struct snd_soc_dapm_widget *w, | ||
41 | struct snd_kcontrol *kcontrol, | ||
42 | int event) | ||
43 | { | ||
44 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | ||
45 | unsigned int val; | ||
46 | |||
47 | switch (event) { | ||
48 | case SND_SOC_DAPM_PRE_PMU: | ||
49 | val = snd_soc_read(codec, ARIZONA_ASRC_RATE1); | ||
50 | val &= ARIZONA_ASRC_RATE1_MASK; | ||
51 | val >>= ARIZONA_ASRC_RATE1_SHIFT; | ||
52 | |||
53 | switch (val) { | ||
54 | case 0: | ||
55 | case 1: | ||
56 | case 2: | ||
57 | val = snd_soc_read(codec, | ||
58 | ARIZONA_SAMPLE_RATE_1 + val); | ||
59 | if (val >= 0x11) { | ||
60 | dev_warn(codec->dev, | ||
61 | "Unsupported ASRC rate1 (%s)\n", | ||
62 | arizona_sample_rate_val_to_name(val)); | ||
63 | return -EINVAL; | ||
64 | } | ||
65 | break; | ||
66 | default: | ||
67 | dev_err(codec->dev, | ||
68 | "Illegal ASRC rate1 selector (0x%x)\n", | ||
69 | val); | ||
70 | return -EINVAL; | ||
71 | } | ||
72 | |||
73 | val = snd_soc_read(codec, ARIZONA_ASRC_RATE2); | ||
74 | val &= ARIZONA_ASRC_RATE2_MASK; | ||
75 | val >>= ARIZONA_ASRC_RATE2_SHIFT; | ||
76 | |||
77 | switch (val) { | ||
78 | case 8: | ||
79 | case 9: | ||
80 | val -= 0x8; | ||
81 | val = snd_soc_read(codec, | ||
82 | ARIZONA_ASYNC_SAMPLE_RATE_1 + val); | ||
83 | if (val >= 0x11) { | ||
84 | dev_warn(codec->dev, | ||
85 | "Unsupported ASRC rate2 (%s)\n", | ||
86 | arizona_sample_rate_val_to_name(val)); | ||
87 | return -EINVAL; | ||
88 | } | ||
89 | break; | ||
90 | default: | ||
91 | dev_err(codec->dev, | ||
92 | "Illegal ASRC rate2 selector (0x%x)\n", | ||
93 | val); | ||
94 | return -EINVAL; | ||
95 | } | ||
96 | break; | ||
97 | default: | ||
98 | return -EINVAL; | ||
99 | } | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | static int wm8998_in1mux_put(struct snd_kcontrol *kcontrol, | ||
105 | struct snd_ctl_elem_value *ucontrol) | ||
106 | { | ||
107 | struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); | ||
108 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | ||
109 | struct wm8998_priv *wm8998 = snd_soc_codec_get_drvdata(codec); | ||
110 | struct arizona *arizona = wm8998->core.arizona; | ||
111 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | ||
112 | unsigned int mux, inmode; | ||
113 | unsigned int mode_val, src_val; | ||
114 | |||
115 | mux = ucontrol->value.enumerated.item[0]; | ||
116 | if (mux > 1) | ||
117 | return -EINVAL; | ||
118 | |||
119 | /* L and R registers have same shift and mask */ | ||
120 | inmode = arizona->pdata.inmode[2 * mux]; | ||
121 | src_val = mux << ARIZONA_IN1L_SRC_SHIFT; | ||
122 | if (inmode & ARIZONA_INMODE_SE) | ||
123 | src_val |= 1 << ARIZONA_IN1L_SRC_SE_SHIFT; | ||
124 | |||
125 | switch (arizona->pdata.inmode[0]) { | ||
126 | case ARIZONA_INMODE_DMIC: | ||
127 | if (mux) | ||
128 | mode_val = 0; /* B always analogue */ | ||
129 | else | ||
130 | mode_val = 1 << ARIZONA_IN1_MODE_SHIFT; | ||
131 | |||
132 | snd_soc_update_bits(codec, ARIZONA_IN1L_CONTROL, | ||
133 | ARIZONA_IN1_MODE_MASK, mode_val); | ||
134 | |||
135 | /* IN1A is digital so L and R must change together */ | ||
136 | /* src_val setting same for both registers */ | ||
137 | snd_soc_update_bits(codec, | ||
138 | ARIZONA_ADC_DIGITAL_VOLUME_1L, | ||
139 | ARIZONA_IN1L_SRC_MASK | | ||
140 | ARIZONA_IN1L_SRC_SE_MASK, src_val); | ||
141 | snd_soc_update_bits(codec, | ||
142 | ARIZONA_ADC_DIGITAL_VOLUME_1R, | ||
143 | ARIZONA_IN1R_SRC_MASK | | ||
144 | ARIZONA_IN1R_SRC_SE_MASK, src_val); | ||
145 | break; | ||
146 | default: | ||
147 | /* both analogue */ | ||
148 | snd_soc_update_bits(codec, | ||
149 | e->reg, | ||
150 | ARIZONA_IN1L_SRC_MASK | | ||
151 | ARIZONA_IN1L_SRC_SE_MASK, | ||
152 | src_val); | ||
153 | break; | ||
154 | } | ||
155 | |||
156 | return snd_soc_dapm_mux_update_power(dapm, kcontrol, | ||
157 | ucontrol->value.enumerated.item[0], | ||
158 | e, NULL); | ||
159 | } | ||
160 | |||
161 | static int wm8998_in2mux_put(struct snd_kcontrol *kcontrol, | ||
162 | struct snd_ctl_elem_value *ucontrol) | ||
163 | { | ||
164 | struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); | ||
165 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | ||
166 | struct wm8998_priv *wm8998 = snd_soc_codec_get_drvdata(codec); | ||
167 | struct arizona *arizona = wm8998->core.arizona; | ||
168 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | ||
169 | unsigned int mux, inmode, src_val, mode_val; | ||
170 | |||
171 | mux = ucontrol->value.enumerated.item[0]; | ||
172 | if (mux > 1) | ||
173 | return -EINVAL; | ||
174 | |||
175 | inmode = arizona->pdata.inmode[1 + (2 * mux)]; | ||
176 | if (inmode & ARIZONA_INMODE_DMIC) | ||
177 | mode_val = 1 << ARIZONA_IN2_MODE_SHIFT; | ||
178 | else | ||
179 | mode_val = 0; | ||
180 | |||
181 | src_val = mux << ARIZONA_IN2L_SRC_SHIFT; | ||
182 | if (inmode & ARIZONA_INMODE_SE) | ||
183 | src_val |= 1 << ARIZONA_IN2L_SRC_SE_SHIFT; | ||
184 | |||
185 | snd_soc_update_bits(codec, ARIZONA_IN2L_CONTROL, | ||
186 | ARIZONA_IN2_MODE_MASK, mode_val); | ||
187 | |||
188 | snd_soc_update_bits(codec, ARIZONA_ADC_DIGITAL_VOLUME_2L, | ||
189 | ARIZONA_IN2L_SRC_MASK | ARIZONA_IN2L_SRC_SE_MASK, | ||
190 | src_val); | ||
191 | |||
192 | return snd_soc_dapm_mux_update_power(dapm, kcontrol, | ||
193 | ucontrol->value.enumerated.item[0], | ||
194 | e, NULL); | ||
195 | } | ||
196 | |||
197 | static const char * const wm8998_inmux_texts[] = { | ||
198 | "A", | ||
199 | "B", | ||
200 | }; | ||
201 | |||
202 | static const SOC_ENUM_SINGLE_DECL(wm8998_in1muxl_enum, | ||
203 | ARIZONA_ADC_DIGITAL_VOLUME_1L, | ||
204 | ARIZONA_IN1L_SRC_SHIFT, | ||
205 | wm8998_inmux_texts); | ||
206 | |||
207 | static const SOC_ENUM_SINGLE_DECL(wm8998_in1muxr_enum, | ||
208 | ARIZONA_ADC_DIGITAL_VOLUME_1R, | ||
209 | ARIZONA_IN1R_SRC_SHIFT, | ||
210 | wm8998_inmux_texts); | ||
211 | |||
212 | static const SOC_ENUM_SINGLE_DECL(wm8998_in2mux_enum, | ||
213 | ARIZONA_ADC_DIGITAL_VOLUME_2L, | ||
214 | ARIZONA_IN2L_SRC_SHIFT, | ||
215 | wm8998_inmux_texts); | ||
216 | |||
217 | static const struct snd_kcontrol_new wm8998_in1mux[2] = { | ||
218 | SOC_DAPM_ENUM_EXT("IN1L Mux", wm8998_in1muxl_enum, | ||
219 | snd_soc_dapm_get_enum_double, wm8998_in1mux_put), | ||
220 | SOC_DAPM_ENUM_EXT("IN1R Mux", wm8998_in1muxr_enum, | ||
221 | snd_soc_dapm_get_enum_double, wm8998_in1mux_put), | ||
222 | }; | ||
223 | |||
224 | static const struct snd_kcontrol_new wm8998_in2mux = | ||
225 | SOC_DAPM_ENUM_EXT("IN2 Mux", wm8998_in2mux_enum, | ||
226 | snd_soc_dapm_get_enum_double, wm8998_in2mux_put); | ||
227 | |||
228 | static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0); | ||
229 | static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); | ||
230 | static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0); | ||
231 | static DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0); | ||
232 | |||
233 | #define WM8998_NG_SRC(name, base) \ | ||
234 | SOC_SINGLE(name " NG HPOUTL Switch", base, 0, 1, 0), \ | ||
235 | SOC_SINGLE(name " NG HPOUTR Switch", base, 1, 1, 0), \ | ||
236 | SOC_SINGLE(name " NG LINEOUTL Switch", base, 2, 1, 0), \ | ||
237 | SOC_SINGLE(name " NG LINEOUTR Switch", base, 3, 1, 0), \ | ||
238 | SOC_SINGLE(name " NG EPOUT Switch", base, 4, 1, 0), \ | ||
239 | SOC_SINGLE(name " NG SPKOUTL Switch", base, 6, 1, 0), \ | ||
240 | SOC_SINGLE(name " NG SPKOUTR Switch", base, 7, 1, 0) | ||
241 | |||
242 | static const struct snd_kcontrol_new wm8998_snd_controls[] = { | ||
243 | SOC_ENUM("IN1 OSR", arizona_in_dmic_osr[0]), | ||
244 | SOC_ENUM("IN2 OSR", arizona_in_dmic_osr[1]), | ||
245 | |||
246 | SOC_SINGLE_RANGE_TLV("IN1L Volume", ARIZONA_IN1L_CONTROL, | ||
247 | ARIZONA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), | ||
248 | SOC_SINGLE_RANGE_TLV("IN1R Volume", ARIZONA_IN1R_CONTROL, | ||
249 | ARIZONA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), | ||
250 | SOC_SINGLE_RANGE_TLV("IN2 Volume", ARIZONA_IN2L_CONTROL, | ||
251 | ARIZONA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), | ||
252 | |||
253 | SOC_ENUM("IN HPF Cutoff Frequency", arizona_in_hpf_cut_enum), | ||
254 | |||
255 | SOC_SINGLE("IN1L HPF Switch", ARIZONA_IN1L_CONTROL, | ||
256 | ARIZONA_IN1L_HPF_SHIFT, 1, 0), | ||
257 | SOC_SINGLE("IN1R HPF Switch", ARIZONA_IN1R_CONTROL, | ||
258 | ARIZONA_IN1R_HPF_SHIFT, 1, 0), | ||
259 | SOC_SINGLE("IN2 HPF Switch", ARIZONA_IN2L_CONTROL, | ||
260 | ARIZONA_IN2L_HPF_SHIFT, 1, 0), | ||
261 | |||
262 | SOC_SINGLE_TLV("IN1L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L, | ||
263 | ARIZONA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv), | ||
264 | SOC_SINGLE_TLV("IN1R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1R, | ||
265 | ARIZONA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv), | ||
266 | SOC_SINGLE_TLV("IN2 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2L, | ||
267 | ARIZONA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv), | ||
268 | |||
269 | SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp), | ||
270 | SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp), | ||
271 | |||
272 | ARIZONA_GAINMUX_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE), | ||
273 | ARIZONA_GAINMUX_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), | ||
274 | ARIZONA_GAINMUX_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), | ||
275 | ARIZONA_GAINMUX_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), | ||
276 | |||
277 | SND_SOC_BYTES("EQ1 Coefficients", ARIZONA_EQ1_3, 19), | ||
278 | SOC_SINGLE("EQ1 Mode Switch", ARIZONA_EQ1_2, ARIZONA_EQ1_B1_MODE_SHIFT, 1, 0), | ||
279 | SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, | ||
280 | 24, 0, eq_tlv), | ||
281 | SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT, | ||
282 | 24, 0, eq_tlv), | ||
283 | SOC_SINGLE_TLV("EQ1 B3 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B3_GAIN_SHIFT, | ||
284 | 24, 0, eq_tlv), | ||
285 | SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT, | ||
286 | 24, 0, eq_tlv), | ||
287 | SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT, | ||
288 | 24, 0, eq_tlv), | ||
289 | |||
290 | SND_SOC_BYTES("EQ2 Coefficients", ARIZONA_EQ2_3, 19), | ||
291 | SOC_SINGLE("EQ2 Mode Switch", ARIZONA_EQ2_2, ARIZONA_EQ2_B1_MODE_SHIFT, 1, 0), | ||
292 | SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT, | ||
293 | 24, 0, eq_tlv), | ||
294 | SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT, | ||
295 | 24, 0, eq_tlv), | ||
296 | SOC_SINGLE_TLV("EQ2 B3 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B3_GAIN_SHIFT, | ||
297 | 24, 0, eq_tlv), | ||
298 | SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT, | ||
299 | 24, 0, eq_tlv), | ||
300 | SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT, | ||
301 | 24, 0, eq_tlv), | ||
302 | |||
303 | SND_SOC_BYTES("EQ3 Coefficients", ARIZONA_EQ3_3, 19), | ||
304 | SOC_SINGLE("EQ3 Mode Switch", ARIZONA_EQ3_2, ARIZONA_EQ3_B1_MODE_SHIFT, 1, 0), | ||
305 | SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT, | ||
306 | 24, 0, eq_tlv), | ||
307 | SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT, | ||
308 | 24, 0, eq_tlv), | ||
309 | SOC_SINGLE_TLV("EQ3 B3 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B3_GAIN_SHIFT, | ||
310 | 24, 0, eq_tlv), | ||
311 | SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT, | ||
312 | 24, 0, eq_tlv), | ||
313 | SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT, | ||
314 | 24, 0, eq_tlv), | ||
315 | |||
316 | SND_SOC_BYTES("EQ4 Coefficients", ARIZONA_EQ4_3, 19), | ||
317 | SOC_SINGLE("EQ4 Mode Switch", ARIZONA_EQ4_2, ARIZONA_EQ4_B1_MODE_SHIFT, 1, 0), | ||
318 | SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT, | ||
319 | 24, 0, eq_tlv), | ||
320 | SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT, | ||
321 | 24, 0, eq_tlv), | ||
322 | SOC_SINGLE_TLV("EQ4 B3 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B3_GAIN_SHIFT, | ||
323 | 24, 0, eq_tlv), | ||
324 | SOC_SINGLE_TLV("EQ4 B4 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B4_GAIN_SHIFT, | ||
325 | 24, 0, eq_tlv), | ||
326 | SOC_SINGLE_TLV("EQ4 B5 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B5_GAIN_SHIFT, | ||
327 | 24, 0, eq_tlv), | ||
328 | |||
329 | ARIZONA_GAINMUX_CONTROLS("DRC1L", ARIZONA_DRC1LMIX_INPUT_1_SOURCE), | ||
330 | ARIZONA_GAINMUX_CONTROLS("DRC1R", ARIZONA_DRC1RMIX_INPUT_1_SOURCE), | ||
331 | |||
332 | SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5, | ||
333 | ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA), | ||
334 | |||
335 | ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE), | ||
336 | ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE), | ||
337 | ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE), | ||
338 | ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE), | ||
339 | |||
340 | SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1), | ||
341 | SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1), | ||
342 | SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1), | ||
343 | SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1), | ||
344 | |||
345 | SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode), | ||
346 | SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), | ||
347 | SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), | ||
348 | SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode), | ||
349 | |||
350 | SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), | ||
351 | SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), | ||
352 | SOC_ENUM("ISRC1 FSH", arizona_isrc_fsh[0]), | ||
353 | SOC_ENUM("ISRC2 FSH", arizona_isrc_fsh[1]), | ||
354 | SOC_ENUM("ASRC RATE 1", arizona_asrc_rate1), | ||
355 | |||
356 | ARIZONA_MIXER_CONTROLS("HPOUTL", ARIZONA_OUT1LMIX_INPUT_1_SOURCE), | ||
357 | ARIZONA_MIXER_CONTROLS("HPOUTR", ARIZONA_OUT1RMIX_INPUT_1_SOURCE), | ||
358 | ARIZONA_MIXER_CONTROLS("LINEOUTL", ARIZONA_OUT2LMIX_INPUT_1_SOURCE), | ||
359 | ARIZONA_MIXER_CONTROLS("LINEOUTR", ARIZONA_OUT2RMIX_INPUT_1_SOURCE), | ||
360 | ARIZONA_MIXER_CONTROLS("EPOUT", ARIZONA_OUT3LMIX_INPUT_1_SOURCE), | ||
361 | ARIZONA_MIXER_CONTROLS("SPKOUTL", ARIZONA_OUT4LMIX_INPUT_1_SOURCE), | ||
362 | ARIZONA_MIXER_CONTROLS("SPKOUTR", ARIZONA_OUT4RMIX_INPUT_1_SOURCE), | ||
363 | ARIZONA_MIXER_CONTROLS("SPKDATL", ARIZONA_OUT5LMIX_INPUT_1_SOURCE), | ||
364 | ARIZONA_MIXER_CONTROLS("SPKDATR", ARIZONA_OUT5RMIX_INPUT_1_SOURCE), | ||
365 | |||
366 | SOC_DOUBLE_R("HPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L, | ||
367 | ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1), | ||
368 | SOC_DOUBLE_R("LINEOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_2L, | ||
369 | ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_MUTE_SHIFT, 1, 1), | ||
370 | SOC_SINGLE("EPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_3L, | ||
371 | ARIZONA_OUT3L_MUTE_SHIFT, 1, 1), | ||
372 | SOC_DOUBLE_R("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L, | ||
373 | ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_MUTE_SHIFT, 1, 1), | ||
374 | SOC_DOUBLE_R("SPKDAT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_5L, | ||
375 | ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_MUTE_SHIFT, 1, 1), | ||
376 | |||
377 | SOC_DOUBLE_R_TLV("HPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L, | ||
378 | ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT, | ||
379 | 0xbf, 0, digital_tlv), | ||
380 | SOC_DOUBLE_R_TLV("LINEOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_2L, | ||
381 | ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_VOL_SHIFT, | ||
382 | 0xbf, 0, digital_tlv), | ||
383 | SOC_SINGLE_TLV("EPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_3L, | ||
384 | ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv), | ||
385 | SOC_DOUBLE_R_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L, | ||
386 | ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_VOL_SHIFT, | ||
387 | 0xbf, 0, digital_tlv), | ||
388 | SOC_DOUBLE_R_TLV("SPKDAT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L, | ||
389 | ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT, | ||
390 | 0xbf, 0, digital_tlv), | ||
391 | |||
392 | SOC_DOUBLE("SPKDAT Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT, | ||
393 | ARIZONA_SPK1R_MUTE_SHIFT, 1, 1), | ||
394 | |||
395 | SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp), | ||
396 | SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp), | ||
397 | |||
398 | SOC_SINGLE("Noise Gate Switch", ARIZONA_NOISE_GATE_CONTROL, | ||
399 | ARIZONA_NGATE_ENA_SHIFT, 1, 0), | ||
400 | SOC_SINGLE_TLV("Noise Gate Threshold Volume", ARIZONA_NOISE_GATE_CONTROL, | ||
401 | ARIZONA_NGATE_THR_SHIFT, 7, 1, ng_tlv), | ||
402 | SOC_ENUM("Noise Gate Hold", arizona_ng_hold), | ||
403 | |||
404 | WM8998_NG_SRC("HPOUTL", ARIZONA_NOISE_GATE_SELECT_1L), | ||
405 | WM8998_NG_SRC("HPOUTR", ARIZONA_NOISE_GATE_SELECT_1R), | ||
406 | WM8998_NG_SRC("LINEOUTL", ARIZONA_NOISE_GATE_SELECT_2L), | ||
407 | WM8998_NG_SRC("LINEOUTR", ARIZONA_NOISE_GATE_SELECT_2R), | ||
408 | WM8998_NG_SRC("EPOUT", ARIZONA_NOISE_GATE_SELECT_3L), | ||
409 | WM8998_NG_SRC("SPKOUTL", ARIZONA_NOISE_GATE_SELECT_4L), | ||
410 | WM8998_NG_SRC("SPKOUTR", ARIZONA_NOISE_GATE_SELECT_4R), | ||
411 | WM8998_NG_SRC("SPKDATL", ARIZONA_NOISE_GATE_SELECT_5L), | ||
412 | WM8998_NG_SRC("SPKDATR", ARIZONA_NOISE_GATE_SELECT_5R), | ||
413 | |||
414 | ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE), | ||
415 | ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE), | ||
416 | ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE), | ||
417 | ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE), | ||
418 | ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE), | ||
419 | ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE), | ||
420 | |||
421 | ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE), | ||
422 | ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE), | ||
423 | ARIZONA_MIXER_CONTROLS("AIF2TX3", ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE), | ||
424 | ARIZONA_MIXER_CONTROLS("AIF2TX4", ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE), | ||
425 | ARIZONA_MIXER_CONTROLS("AIF2TX5", ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE), | ||
426 | ARIZONA_MIXER_CONTROLS("AIF2TX6", ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE), | ||
427 | |||
428 | ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE), | ||
429 | ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE), | ||
430 | |||
431 | ARIZONA_GAINMUX_CONTROLS("SLIMTX1", ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE), | ||
432 | ARIZONA_GAINMUX_CONTROLS("SLIMTX2", ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE), | ||
433 | ARIZONA_GAINMUX_CONTROLS("SLIMTX3", ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE), | ||
434 | ARIZONA_GAINMUX_CONTROLS("SLIMTX4", ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE), | ||
435 | ARIZONA_GAINMUX_CONTROLS("SLIMTX5", ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE), | ||
436 | ARIZONA_GAINMUX_CONTROLS("SLIMTX6", ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE), | ||
437 | |||
438 | ARIZONA_GAINMUX_CONTROLS("SPDIFTX1", ARIZONA_SPDIFTX1MIX_INPUT_1_SOURCE), | ||
439 | ARIZONA_GAINMUX_CONTROLS("SPDIFTX2", ARIZONA_SPDIFTX2MIX_INPUT_1_SOURCE), | ||
440 | }; | ||
441 | |||
442 | ARIZONA_MUX_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE); | ||
443 | ARIZONA_MUX_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE); | ||
444 | ARIZONA_MUX_ENUMS(EQ3, ARIZONA_EQ3MIX_INPUT_1_SOURCE); | ||
445 | ARIZONA_MUX_ENUMS(EQ4, ARIZONA_EQ4MIX_INPUT_1_SOURCE); | ||
446 | |||
447 | ARIZONA_MUX_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE); | ||
448 | ARIZONA_MUX_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE); | ||
449 | |||
450 | ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE); | ||
451 | ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE); | ||
452 | ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE); | ||
453 | ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE); | ||
454 | |||
455 | ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE); | ||
456 | ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE); | ||
457 | |||
458 | ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE); | ||
459 | ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE); | ||
460 | ARIZONA_MIXER_ENUMS(OUT2L, ARIZONA_OUT2LMIX_INPUT_1_SOURCE); | ||
461 | ARIZONA_MIXER_ENUMS(OUT2R, ARIZONA_OUT2RMIX_INPUT_1_SOURCE); | ||
462 | ARIZONA_MIXER_ENUMS(OUT3, ARIZONA_OUT3LMIX_INPUT_1_SOURCE); | ||
463 | ARIZONA_MIXER_ENUMS(SPKOUTL, ARIZONA_OUT4LMIX_INPUT_1_SOURCE); | ||
464 | ARIZONA_MIXER_ENUMS(SPKOUTR, ARIZONA_OUT4RMIX_INPUT_1_SOURCE); | ||
465 | ARIZONA_MIXER_ENUMS(SPKDATL, ARIZONA_OUT5LMIX_INPUT_1_SOURCE); | ||
466 | ARIZONA_MIXER_ENUMS(SPKDATR, ARIZONA_OUT5RMIX_INPUT_1_SOURCE); | ||
467 | |||
468 | ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE); | ||
469 | ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE); | ||
470 | ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE); | ||
471 | ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE); | ||
472 | ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE); | ||
473 | ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE); | ||
474 | |||
475 | ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE); | ||
476 | ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE); | ||
477 | ARIZONA_MIXER_ENUMS(AIF2TX3, ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE); | ||
478 | ARIZONA_MIXER_ENUMS(AIF2TX4, ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE); | ||
479 | ARIZONA_MIXER_ENUMS(AIF2TX5, ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE); | ||
480 | ARIZONA_MIXER_ENUMS(AIF2TX6, ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE); | ||
481 | |||
482 | ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE); | ||
483 | ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE); | ||
484 | |||
485 | ARIZONA_MUX_ENUMS(SLIMTX1, ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE); | ||
486 | ARIZONA_MUX_ENUMS(SLIMTX2, ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE); | ||
487 | ARIZONA_MUX_ENUMS(SLIMTX3, ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE); | ||
488 | ARIZONA_MUX_ENUMS(SLIMTX4, ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE); | ||
489 | ARIZONA_MUX_ENUMS(SLIMTX5, ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE); | ||
490 | ARIZONA_MUX_ENUMS(SLIMTX6, ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE); | ||
491 | |||
492 | ARIZONA_MUX_ENUMS(SPD1TX1, ARIZONA_SPDIFTX1MIX_INPUT_1_SOURCE); | ||
493 | ARIZONA_MUX_ENUMS(SPD1TX2, ARIZONA_SPDIFTX2MIX_INPUT_1_SOURCE); | ||
494 | |||
495 | ARIZONA_MUX_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE); | ||
496 | ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE); | ||
497 | ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); | ||
498 | ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); | ||
499 | |||
500 | ARIZONA_MUX_ENUMS(ISRC1INT1, ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE); | ||
501 | ARIZONA_MUX_ENUMS(ISRC1INT2, ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE); | ||
502 | ARIZONA_MUX_ENUMS(ISRC1INT3, ARIZONA_ISRC1INT3MIX_INPUT_1_SOURCE); | ||
503 | ARIZONA_MUX_ENUMS(ISRC1INT4, ARIZONA_ISRC1INT4MIX_INPUT_1_SOURCE); | ||
504 | |||
505 | ARIZONA_MUX_ENUMS(ISRC1DEC1, ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE); | ||
506 | ARIZONA_MUX_ENUMS(ISRC1DEC2, ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE); | ||
507 | ARIZONA_MUX_ENUMS(ISRC1DEC3, ARIZONA_ISRC1DEC3MIX_INPUT_1_SOURCE); | ||
508 | ARIZONA_MUX_ENUMS(ISRC1DEC4, ARIZONA_ISRC1DEC4MIX_INPUT_1_SOURCE); | ||
509 | |||
510 | ARIZONA_MUX_ENUMS(ISRC2INT1, ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE); | ||
511 | ARIZONA_MUX_ENUMS(ISRC2INT2, ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE); | ||
512 | |||
513 | ARIZONA_MUX_ENUMS(ISRC2DEC1, ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE); | ||
514 | ARIZONA_MUX_ENUMS(ISRC2DEC2, ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE); | ||
515 | |||
516 | static const char * const wm8998_aec_loopback_texts[] = { | ||
517 | "HPOUTL", "HPOUTR", "LINEOUTL", "LINEOUTR", "EPOUT", | ||
518 | "SPKOUTL", "SPKOUTR", "SPKDATL", "SPKDATR", | ||
519 | }; | ||
520 | |||
521 | static const unsigned int wm8998_aec_loopback_values[] = { | ||
522 | 0, 1, 2, 3, 4, 6, 7, 8, 9, | ||
523 | }; | ||
524 | |||
525 | static const SOC_VALUE_ENUM_SINGLE_DECL(wm8998_aec1_loopback, | ||
526 | ARIZONA_DAC_AEC_CONTROL_1, | ||
527 | ARIZONA_AEC_LOOPBACK_SRC_SHIFT, 0xf, | ||
528 | wm8998_aec_loopback_texts, | ||
529 | wm8998_aec_loopback_values); | ||
530 | |||
531 | static const SOC_VALUE_ENUM_SINGLE_DECL(wm8998_aec2_loopback, | ||
532 | ARIZONA_DAC_AEC_CONTROL_2, | ||
533 | ARIZONA_AEC_LOOPBACK_SRC_SHIFT, 0xf, | ||
534 | wm8998_aec_loopback_texts, | ||
535 | wm8998_aec_loopback_values); | ||
536 | |||
537 | static const struct snd_kcontrol_new wm8998_aec_loopback_mux[] = { | ||
538 | SOC_DAPM_ENUM("AEC1 Loopback", wm8998_aec1_loopback), | ||
539 | SOC_DAPM_ENUM("AEC2 Loopback", wm8998_aec2_loopback), | ||
540 | }; | ||
541 | |||
542 | static const struct snd_soc_dapm_widget wm8998_dapm_widgets[] = { | ||
543 | SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, | ||
544 | ARIZONA_SYSCLK_ENA_SHIFT, 0, NULL, 0), | ||
545 | SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1, | ||
546 | ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), | ||
547 | SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK, | ||
548 | ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0), | ||
549 | SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK, | ||
550 | ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0), | ||
551 | |||
552 | SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0), | ||
553 | SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0, 0), | ||
554 | SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0), | ||
555 | SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS), | ||
556 | SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0, 0), | ||
557 | SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0), | ||
558 | |||
559 | SND_SOC_DAPM_SIGGEN("TONE"), | ||
560 | SND_SOC_DAPM_SIGGEN("HAPTICS"), | ||
561 | |||
562 | SND_SOC_DAPM_INPUT("IN1AL"), | ||
563 | SND_SOC_DAPM_INPUT("IN1AR"), | ||
564 | SND_SOC_DAPM_INPUT("IN1BL"), | ||
565 | SND_SOC_DAPM_INPUT("IN1BR"), | ||
566 | SND_SOC_DAPM_INPUT("IN2A"), | ||
567 | SND_SOC_DAPM_INPUT("IN2B"), | ||
568 | |||
569 | SND_SOC_DAPM_MUX("IN1L Mux", SND_SOC_NOPM, 0, 0, &wm8998_in1mux[0]), | ||
570 | SND_SOC_DAPM_MUX("IN1R Mux", SND_SOC_NOPM, 0, 0, &wm8998_in1mux[1]), | ||
571 | SND_SOC_DAPM_MUX("IN2 Mux", SND_SOC_NOPM, 0, 0, &wm8998_in2mux), | ||
572 | |||
573 | SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"), | ||
574 | |||
575 | SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT, | ||
576 | 0, NULL, 0, arizona_in_ev, | ||
577 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | | ||
578 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), | ||
579 | SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT, | ||
580 | 0, NULL, 0, arizona_in_ev, | ||
581 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | | ||
582 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), | ||
583 | SND_SOC_DAPM_PGA_E("IN2 PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT, | ||
584 | 0, NULL, 0, arizona_in_ev, | ||
585 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | | ||
586 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), | ||
587 | |||
588 | SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1, | ||
589 | ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), | ||
590 | SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2, | ||
591 | ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), | ||
592 | SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3, | ||
593 | ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), | ||
594 | |||
595 | SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1, | ||
596 | ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0), | ||
597 | SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1, | ||
598 | ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0), | ||
599 | |||
600 | SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0), | ||
601 | SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0), | ||
602 | SND_SOC_DAPM_PGA("EQ3", ARIZONA_EQ3_1, ARIZONA_EQ3_ENA_SHIFT, 0, NULL, 0), | ||
603 | SND_SOC_DAPM_PGA("EQ4", ARIZONA_EQ4_1, ARIZONA_EQ4_ENA_SHIFT, 0, NULL, 0), | ||
604 | |||
605 | SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0, | ||
606 | NULL, 0), | ||
607 | SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0, | ||
608 | NULL, 0), | ||
609 | |||
610 | SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0, | ||
611 | NULL, 0), | ||
612 | SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0, | ||
613 | NULL, 0), | ||
614 | SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0, | ||
615 | NULL, 0), | ||
616 | SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0, | ||
617 | NULL, 0), | ||
618 | |||
619 | SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT, | ||
620 | 0, NULL, 0), | ||
621 | SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT, | ||
622 | 0, NULL, 0), | ||
623 | |||
624 | SND_SOC_DAPM_PGA_E("ASRC1L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1L_ENA_SHIFT, 0, | ||
625 | NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU), | ||
626 | SND_SOC_DAPM_PGA_E("ASRC1R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1R_ENA_SHIFT, 0, | ||
627 | NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU), | ||
628 | SND_SOC_DAPM_PGA_E("ASRC2L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2L_ENA_SHIFT, 0, | ||
629 | NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU), | ||
630 | SND_SOC_DAPM_PGA_E("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0, | ||
631 | NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU), | ||
632 | |||
633 | SND_SOC_DAPM_PGA("ISRC1INT1", ARIZONA_ISRC_1_CTRL_3, | ||
634 | ARIZONA_ISRC1_INT0_ENA_SHIFT, 0, NULL, 0), | ||
635 | SND_SOC_DAPM_PGA("ISRC1INT2", ARIZONA_ISRC_1_CTRL_3, | ||
636 | ARIZONA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0), | ||
637 | SND_SOC_DAPM_PGA("ISRC1INT3", ARIZONA_ISRC_1_CTRL_3, | ||
638 | ARIZONA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0), | ||
639 | SND_SOC_DAPM_PGA("ISRC1INT4", ARIZONA_ISRC_1_CTRL_3, | ||
640 | ARIZONA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0), | ||
641 | |||
642 | SND_SOC_DAPM_PGA("ISRC1DEC1", ARIZONA_ISRC_1_CTRL_3, | ||
643 | ARIZONA_ISRC1_DEC0_ENA_SHIFT, 0, NULL, 0), | ||
644 | SND_SOC_DAPM_PGA("ISRC1DEC2", ARIZONA_ISRC_1_CTRL_3, | ||
645 | ARIZONA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0), | ||
646 | SND_SOC_DAPM_PGA("ISRC1DEC3", ARIZONA_ISRC_1_CTRL_3, | ||
647 | ARIZONA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0), | ||
648 | SND_SOC_DAPM_PGA("ISRC1DEC4", ARIZONA_ISRC_1_CTRL_3, | ||
649 | ARIZONA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0), | ||
650 | |||
651 | SND_SOC_DAPM_PGA("ISRC2INT1", ARIZONA_ISRC_2_CTRL_3, | ||
652 | ARIZONA_ISRC2_INT0_ENA_SHIFT, 0, NULL, 0), | ||
653 | SND_SOC_DAPM_PGA("ISRC2INT2", ARIZONA_ISRC_2_CTRL_3, | ||
654 | ARIZONA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0), | ||
655 | |||
656 | SND_SOC_DAPM_PGA("ISRC2DEC1", ARIZONA_ISRC_2_CTRL_3, | ||
657 | ARIZONA_ISRC2_DEC0_ENA_SHIFT, 0, NULL, 0), | ||
658 | SND_SOC_DAPM_PGA("ISRC2DEC2", ARIZONA_ISRC_2_CTRL_3, | ||
659 | ARIZONA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0), | ||
660 | |||
661 | SND_SOC_DAPM_MUX("AEC1 Loopback", ARIZONA_DAC_AEC_CONTROL_1, | ||
662 | ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, | ||
663 | &wm8998_aec_loopback_mux[0]), | ||
664 | |||
665 | SND_SOC_DAPM_MUX("AEC2 Loopback", ARIZONA_DAC_AEC_CONTROL_2, | ||
666 | ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, | ||
667 | &wm8998_aec_loopback_mux[1]), | ||
668 | |||
669 | SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0, | ||
670 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0), | ||
671 | SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0, | ||
672 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0), | ||
673 | SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0, | ||
674 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0), | ||
675 | SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0, | ||
676 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0), | ||
677 | SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0, | ||
678 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0), | ||
679 | SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0, | ||
680 | ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0), | ||
681 | |||
682 | SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0, | ||
683 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0), | ||
684 | SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0, | ||
685 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0), | ||
686 | SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0, | ||
687 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0), | ||
688 | SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0, | ||
689 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0), | ||
690 | SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0, | ||
691 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0), | ||
692 | SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0, | ||
693 | ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0), | ||
694 | |||
695 | SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0, | ||
696 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0), | ||
697 | SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0, | ||
698 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0), | ||
699 | SND_SOC_DAPM_AIF_OUT("AIF2TX3", NULL, 0, | ||
700 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX3_ENA_SHIFT, 0), | ||
701 | SND_SOC_DAPM_AIF_OUT("AIF2TX4", NULL, 0, | ||
702 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX4_ENA_SHIFT, 0), | ||
703 | SND_SOC_DAPM_AIF_OUT("AIF2TX5", NULL, 0, | ||
704 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX5_ENA_SHIFT, 0), | ||
705 | SND_SOC_DAPM_AIF_OUT("AIF2TX6", NULL, 0, | ||
706 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX6_ENA_SHIFT, 0), | ||
707 | |||
708 | SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0, | ||
709 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0), | ||
710 | SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0, | ||
711 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0), | ||
712 | SND_SOC_DAPM_AIF_IN("AIF2RX3", NULL, 0, | ||
713 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX3_ENA_SHIFT, 0), | ||
714 | SND_SOC_DAPM_AIF_IN("AIF2RX4", NULL, 0, | ||
715 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX4_ENA_SHIFT, 0), | ||
716 | SND_SOC_DAPM_AIF_IN("AIF2RX5", NULL, 0, | ||
717 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX5_ENA_SHIFT, 0), | ||
718 | SND_SOC_DAPM_AIF_IN("AIF2RX6", NULL, 0, | ||
719 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX6_ENA_SHIFT, 0), | ||
720 | |||
721 | SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0, | ||
722 | ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, | ||
723 | ARIZONA_SLIMRX1_ENA_SHIFT, 0), | ||
724 | SND_SOC_DAPM_AIF_IN("SLIMRX2", NULL, 0, | ||
725 | ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, | ||
726 | ARIZONA_SLIMRX2_ENA_SHIFT, 0), | ||
727 | SND_SOC_DAPM_AIF_IN("SLIMRX3", NULL, 0, | ||
728 | ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, | ||
729 | ARIZONA_SLIMRX3_ENA_SHIFT, 0), | ||
730 | SND_SOC_DAPM_AIF_IN("SLIMRX4", NULL, 0, | ||
731 | ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, | ||
732 | ARIZONA_SLIMRX4_ENA_SHIFT, 0), | ||
733 | |||
734 | SND_SOC_DAPM_AIF_OUT("SLIMTX1", NULL, 0, | ||
735 | ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, | ||
736 | ARIZONA_SLIMTX1_ENA_SHIFT, 0), | ||
737 | SND_SOC_DAPM_AIF_OUT("SLIMTX2", NULL, 0, | ||
738 | ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, | ||
739 | ARIZONA_SLIMTX2_ENA_SHIFT, 0), | ||
740 | SND_SOC_DAPM_AIF_OUT("SLIMTX3", NULL, 0, | ||
741 | ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, | ||
742 | ARIZONA_SLIMTX3_ENA_SHIFT, 0), | ||
743 | SND_SOC_DAPM_AIF_OUT("SLIMTX4", NULL, 0, | ||
744 | ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, | ||
745 | ARIZONA_SLIMTX4_ENA_SHIFT, 0), | ||
746 | SND_SOC_DAPM_AIF_OUT("SLIMTX5", NULL, 0, | ||
747 | ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, | ||
748 | ARIZONA_SLIMTX5_ENA_SHIFT, 0), | ||
749 | SND_SOC_DAPM_AIF_OUT("SLIMTX6", NULL, 0, | ||
750 | ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE, | ||
751 | ARIZONA_SLIMTX6_ENA_SHIFT, 0), | ||
752 | |||
753 | SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0, | ||
754 | ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX1_ENA_SHIFT, 0), | ||
755 | SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 0, | ||
756 | ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX2_ENA_SHIFT, 0), | ||
757 | |||
758 | SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0, | ||
759 | ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX1_ENA_SHIFT, 0), | ||
760 | SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0, | ||
761 | ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0), | ||
762 | |||
763 | SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, | ||
764 | ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, | ||
765 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
766 | SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM, | ||
767 | ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, | ||
768 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
769 | SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1, | ||
770 | ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | ||
771 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
772 | SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1, | ||
773 | ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | ||
774 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
775 | SND_SOC_DAPM_PGA_E("OUT3", ARIZONA_OUTPUT_ENABLES_1, | ||
776 | ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | ||
777 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
778 | SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1, | ||
779 | ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | ||
780 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
781 | SND_SOC_DAPM_PGA_E("OUT5R", ARIZONA_OUTPUT_ENABLES_1, | ||
782 | ARIZONA_OUT5R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev, | ||
783 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
784 | |||
785 | SND_SOC_DAPM_PGA("SPD1TX1", ARIZONA_SPD1_TX_CONTROL, | ||
786 | ARIZONA_SPD1_VAL1_SHIFT, 0, NULL, 0), | ||
787 | SND_SOC_DAPM_PGA("SPD1TX2", ARIZONA_SPD1_TX_CONTROL, | ||
788 | ARIZONA_SPD1_VAL2_SHIFT, 0, NULL, 0), | ||
789 | SND_SOC_DAPM_OUT_DRV("SPD1", ARIZONA_SPD1_TX_CONTROL, | ||
790 | ARIZONA_SPD1_ENA_SHIFT, 0, NULL, 0), | ||
791 | |||
792 | ARIZONA_MUX_WIDGETS(EQ1, "EQ1"), | ||
793 | ARIZONA_MUX_WIDGETS(EQ2, "EQ2"), | ||
794 | ARIZONA_MUX_WIDGETS(EQ3, "EQ3"), | ||
795 | ARIZONA_MUX_WIDGETS(EQ4, "EQ4"), | ||
796 | |||
797 | ARIZONA_MUX_WIDGETS(DRC1L, "DRC1L"), | ||
798 | ARIZONA_MUX_WIDGETS(DRC1R, "DRC1R"), | ||
799 | |||
800 | ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"), | ||
801 | ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"), | ||
802 | ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"), | ||
803 | ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"), | ||
804 | |||
805 | ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"), | ||
806 | ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"), | ||
807 | |||
808 | ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUTL"), | ||
809 | ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUTR"), | ||
810 | ARIZONA_MIXER_WIDGETS(OUT2L, "LINEOUTL"), | ||
811 | ARIZONA_MIXER_WIDGETS(OUT2R, "LINEOUTR"), | ||
812 | ARIZONA_MIXER_WIDGETS(OUT3, "EPOUT"), | ||
813 | ARIZONA_MIXER_WIDGETS(SPKOUTL, "SPKOUTL"), | ||
814 | ARIZONA_MIXER_WIDGETS(SPKOUTR, "SPKOUTR"), | ||
815 | ARIZONA_MIXER_WIDGETS(SPKDATL, "SPKDATL"), | ||
816 | ARIZONA_MIXER_WIDGETS(SPKDATR, "SPKDATR"), | ||
817 | |||
818 | ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"), | ||
819 | ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"), | ||
820 | ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"), | ||
821 | ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"), | ||
822 | ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"), | ||
823 | ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"), | ||
824 | |||
825 | ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"), | ||
826 | ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"), | ||
827 | ARIZONA_MIXER_WIDGETS(AIF2TX3, "AIF2TX3"), | ||
828 | ARIZONA_MIXER_WIDGETS(AIF2TX4, "AIF2TX4"), | ||
829 | ARIZONA_MIXER_WIDGETS(AIF2TX5, "AIF2TX5"), | ||
830 | ARIZONA_MIXER_WIDGETS(AIF2TX6, "AIF2TX6"), | ||
831 | |||
832 | ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), | ||
833 | ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), | ||
834 | |||
835 | ARIZONA_MUX_WIDGETS(SLIMTX1, "SLIMTX1"), | ||
836 | ARIZONA_MUX_WIDGETS(SLIMTX2, "SLIMTX2"), | ||
837 | ARIZONA_MUX_WIDGETS(SLIMTX3, "SLIMTX3"), | ||
838 | ARIZONA_MUX_WIDGETS(SLIMTX4, "SLIMTX4"), | ||
839 | ARIZONA_MUX_WIDGETS(SLIMTX5, "SLIMTX5"), | ||
840 | ARIZONA_MUX_WIDGETS(SLIMTX6, "SLIMTX6"), | ||
841 | |||
842 | ARIZONA_MUX_WIDGETS(SPD1TX1, "SPDIFTX1"), | ||
843 | ARIZONA_MUX_WIDGETS(SPD1TX2, "SPDIFTX2"), | ||
844 | |||
845 | ARIZONA_MUX_WIDGETS(ASRC1L, "ASRC1L"), | ||
846 | ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"), | ||
847 | ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"), | ||
848 | ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"), | ||
849 | |||
850 | ARIZONA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"), | ||
851 | ARIZONA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"), | ||
852 | ARIZONA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"), | ||
853 | ARIZONA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"), | ||
854 | |||
855 | ARIZONA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"), | ||
856 | ARIZONA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"), | ||
857 | ARIZONA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"), | ||
858 | ARIZONA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"), | ||
859 | |||
860 | ARIZONA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"), | ||
861 | ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"), | ||
862 | |||
863 | ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"), | ||
864 | ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"), | ||
865 | |||
866 | SND_SOC_DAPM_OUTPUT("HPOUTL"), | ||
867 | SND_SOC_DAPM_OUTPUT("HPOUTR"), | ||
868 | SND_SOC_DAPM_OUTPUT("LINEOUTL"), | ||
869 | SND_SOC_DAPM_OUTPUT("LINEOUTR"), | ||
870 | SND_SOC_DAPM_OUTPUT("EPOUT"), | ||
871 | SND_SOC_DAPM_OUTPUT("SPKOUTLN"), | ||
872 | SND_SOC_DAPM_OUTPUT("SPKOUTLP"), | ||
873 | SND_SOC_DAPM_OUTPUT("SPKOUTRN"), | ||
874 | SND_SOC_DAPM_OUTPUT("SPKOUTRP"), | ||
875 | SND_SOC_DAPM_OUTPUT("SPKDATL"), | ||
876 | SND_SOC_DAPM_OUTPUT("SPKDATR"), | ||
877 | SND_SOC_DAPM_OUTPUT("SPDIF"), | ||
878 | |||
879 | SND_SOC_DAPM_OUTPUT("MICSUPP"), | ||
880 | }; | ||
881 | |||
882 | #define ARIZONA_MIXER_INPUT_ROUTES(name) \ | ||
883 | { name, "Tone Generator 1", "Tone Generator 1" }, \ | ||
884 | { name, "Tone Generator 2", "Tone Generator 2" }, \ | ||
885 | { name, "Haptics", "HAPTICS" }, \ | ||
886 | { name, "AEC", "AEC1 Loopback" }, \ | ||
887 | { name, "AEC2", "AEC2 Loopback" }, \ | ||
888 | { name, "IN1L", "IN1L PGA" }, \ | ||
889 | { name, "IN1R", "IN1R PGA" }, \ | ||
890 | { name, "IN2L", "IN2 PGA" }, \ | ||
891 | { name, "AIF1RX1", "AIF1RX1" }, \ | ||
892 | { name, "AIF1RX2", "AIF1RX2" }, \ | ||
893 | { name, "AIF1RX3", "AIF1RX3" }, \ | ||
894 | { name, "AIF1RX4", "AIF1RX4" }, \ | ||
895 | { name, "AIF1RX5", "AIF1RX5" }, \ | ||
896 | { name, "AIF1RX6", "AIF1RX6" }, \ | ||
897 | { name, "AIF2RX1", "AIF2RX1" }, \ | ||
898 | { name, "AIF2RX2", "AIF2RX2" }, \ | ||
899 | { name, "AIF2RX3", "AIF2RX3" }, \ | ||
900 | { name, "AIF2RX4", "AIF2RX4" }, \ | ||
901 | { name, "AIF2RX5", "AIF2RX5" }, \ | ||
902 | { name, "AIF2RX6", "AIF2RX6" }, \ | ||
903 | { name, "AIF3RX1", "AIF3RX1" }, \ | ||
904 | { name, "AIF3RX2", "AIF3RX2" }, \ | ||
905 | { name, "SLIMRX1", "SLIMRX1" }, \ | ||
906 | { name, "SLIMRX2", "SLIMRX2" }, \ | ||
907 | { name, "SLIMRX3", "SLIMRX3" }, \ | ||
908 | { name, "SLIMRX4", "SLIMRX4" }, \ | ||
909 | { name, "EQ1", "EQ1" }, \ | ||
910 | { name, "EQ2", "EQ2" }, \ | ||
911 | { name, "EQ3", "EQ3" }, \ | ||
912 | { name, "EQ4", "EQ4" }, \ | ||
913 | { name, "DRC1L", "DRC1L" }, \ | ||
914 | { name, "DRC1R", "DRC1R" }, \ | ||
915 | { name, "LHPF1", "LHPF1" }, \ | ||
916 | { name, "LHPF2", "LHPF2" }, \ | ||
917 | { name, "LHPF3", "LHPF3" }, \ | ||
918 | { name, "LHPF4", "LHPF4" }, \ | ||
919 | { name, "ASRC1L", "ASRC1L" }, \ | ||
920 | { name, "ASRC1R", "ASRC1R" }, \ | ||
921 | { name, "ASRC2L", "ASRC2L" }, \ | ||
922 | { name, "ASRC2R", "ASRC2R" }, \ | ||
923 | { name, "ISRC1DEC1", "ISRC1DEC1" }, \ | ||
924 | { name, "ISRC1DEC2", "ISRC1DEC2" }, \ | ||
925 | { name, "ISRC1DEC3", "ISRC1DEC3" }, \ | ||
926 | { name, "ISRC1DEC4", "ISRC1DEC4" }, \ | ||
927 | { name, "ISRC1INT1", "ISRC1INT1" }, \ | ||
928 | { name, "ISRC1INT2", "ISRC1INT2" }, \ | ||
929 | { name, "ISRC1INT3", "ISRC1INT3" }, \ | ||
930 | { name, "ISRC1INT4", "ISRC1INT4" }, \ | ||
931 | { name, "ISRC2DEC1", "ISRC2DEC1" }, \ | ||
932 | { name, "ISRC2DEC2", "ISRC2DEC2" }, \ | ||
933 | { name, "ISRC2INT1", "ISRC2INT1" }, \ | ||
934 | { name, "ISRC2INT2", "ISRC2INT2" } | ||
935 | |||
936 | static const struct snd_soc_dapm_route wm8998_dapm_routes[] = { | ||
937 | { "AIF2 Capture", NULL, "DBVDD2" }, | ||
938 | { "AIF2 Playback", NULL, "DBVDD2" }, | ||
939 | |||
940 | { "AIF3 Capture", NULL, "DBVDD3" }, | ||
941 | { "AIF3 Playback", NULL, "DBVDD3" }, | ||
942 | |||
943 | { "OUT1L", NULL, "CPVDD" }, | ||
944 | { "OUT1R", NULL, "CPVDD" }, | ||
945 | { "OUT2L", NULL, "CPVDD" }, | ||
946 | { "OUT2R", NULL, "CPVDD" }, | ||
947 | { "OUT3", NULL, "CPVDD" }, | ||
948 | |||
949 | { "OUT4L", NULL, "SPKVDDL" }, | ||
950 | { "OUT4R", NULL, "SPKVDDR" }, | ||
951 | |||
952 | { "OUT1L", NULL, "SYSCLK" }, | ||
953 | { "OUT1R", NULL, "SYSCLK" }, | ||
954 | { "OUT2L", NULL, "SYSCLK" }, | ||
955 | { "OUT2R", NULL, "SYSCLK" }, | ||
956 | { "OUT3", NULL, "SYSCLK" }, | ||
957 | { "OUT4L", NULL, "SYSCLK" }, | ||
958 | { "OUT4R", NULL, "SYSCLK" }, | ||
959 | { "OUT5L", NULL, "SYSCLK" }, | ||
960 | { "OUT5R", NULL, "SYSCLK" }, | ||
961 | |||
962 | { "IN1AL", NULL, "SYSCLK" }, | ||
963 | { "IN1AR", NULL, "SYSCLK" }, | ||
964 | { "IN1BL", NULL, "SYSCLK" }, | ||
965 | { "IN1BR", NULL, "SYSCLK" }, | ||
966 | { "IN2A", NULL, "SYSCLK" }, | ||
967 | { "IN2B", NULL, "SYSCLK" }, | ||
968 | |||
969 | { "SPD1", NULL, "SYSCLK" }, | ||
970 | { "SPD1", NULL, "SPD1TX1" }, | ||
971 | { "SPD1", NULL, "SPD1TX2" }, | ||
972 | |||
973 | { "MICBIAS1", NULL, "MICVDD" }, | ||
974 | { "MICBIAS2", NULL, "MICVDD" }, | ||
975 | { "MICBIAS3", NULL, "MICVDD" }, | ||
976 | |||
977 | { "Tone Generator 1", NULL, "SYSCLK" }, | ||
978 | { "Tone Generator 2", NULL, "SYSCLK" }, | ||
979 | |||
980 | { "Tone Generator 1", NULL, "TONE" }, | ||
981 | { "Tone Generator 2", NULL, "TONE" }, | ||
982 | |||
983 | { "AIF1 Capture", NULL, "AIF1TX1" }, | ||
984 | { "AIF1 Capture", NULL, "AIF1TX2" }, | ||
985 | { "AIF1 Capture", NULL, "AIF1TX3" }, | ||
986 | { "AIF1 Capture", NULL, "AIF1TX4" }, | ||
987 | { "AIF1 Capture", NULL, "AIF1TX5" }, | ||
988 | { "AIF1 Capture", NULL, "AIF1TX6" }, | ||
989 | |||
990 | { "AIF1RX1", NULL, "AIF1 Playback" }, | ||
991 | { "AIF1RX2", NULL, "AIF1 Playback" }, | ||
992 | { "AIF1RX3", NULL, "AIF1 Playback" }, | ||
993 | { "AIF1RX4", NULL, "AIF1 Playback" }, | ||
994 | { "AIF1RX5", NULL, "AIF1 Playback" }, | ||
995 | { "AIF1RX6", NULL, "AIF1 Playback" }, | ||
996 | |||
997 | { "AIF2 Capture", NULL, "AIF2TX1" }, | ||
998 | { "AIF2 Capture", NULL, "AIF2TX2" }, | ||
999 | { "AIF2 Capture", NULL, "AIF2TX3" }, | ||
1000 | { "AIF2 Capture", NULL, "AIF2TX4" }, | ||
1001 | { "AIF2 Capture", NULL, "AIF2TX5" }, | ||
1002 | { "AIF2 Capture", NULL, "AIF2TX6" }, | ||
1003 | |||
1004 | { "AIF2RX1", NULL, "AIF2 Playback" }, | ||
1005 | { "AIF2RX2", NULL, "AIF2 Playback" }, | ||
1006 | { "AIF2RX3", NULL, "AIF2 Playback" }, | ||
1007 | { "AIF2RX4", NULL, "AIF2 Playback" }, | ||
1008 | { "AIF2RX5", NULL, "AIF2 Playback" }, | ||
1009 | { "AIF2RX6", NULL, "AIF2 Playback" }, | ||
1010 | |||
1011 | { "AIF3 Capture", NULL, "AIF3TX1" }, | ||
1012 | { "AIF3 Capture", NULL, "AIF3TX2" }, | ||
1013 | |||
1014 | { "AIF3RX1", NULL, "AIF3 Playback" }, | ||
1015 | { "AIF3RX2", NULL, "AIF3 Playback" }, | ||
1016 | |||
1017 | { "Slim1 Capture", NULL, "SLIMTX1" }, | ||
1018 | { "Slim1 Capture", NULL, "SLIMTX2" }, | ||
1019 | { "Slim1 Capture", NULL, "SLIMTX3" }, | ||
1020 | { "Slim1 Capture", NULL, "SLIMTX4" }, | ||
1021 | |||
1022 | { "Slim2 Capture", NULL, "SLIMTX5" }, | ||
1023 | { "Slim2 Capture", NULL, "SLIMTX6" }, | ||
1024 | |||
1025 | { "SLIMRX1", NULL, "Slim1 Playback" }, | ||
1026 | { "SLIMRX2", NULL, "Slim1 Playback" }, | ||
1027 | |||
1028 | { "SLIMRX3", NULL, "Slim2 Playback" }, | ||
1029 | { "SLIMRX4", NULL, "Slim2 Playback" }, | ||
1030 | |||
1031 | { "AIF1 Playback", NULL, "SYSCLK" }, | ||
1032 | { "AIF2 Playback", NULL, "SYSCLK" }, | ||
1033 | { "AIF3 Playback", NULL, "SYSCLK" }, | ||
1034 | { "Slim1 Playback", NULL, "SYSCLK" }, | ||
1035 | { "Slim2 Playback", NULL, "SYSCLK" }, | ||
1036 | |||
1037 | { "AIF1 Capture", NULL, "SYSCLK" }, | ||
1038 | { "AIF2 Capture", NULL, "SYSCLK" }, | ||
1039 | { "AIF3 Capture", NULL, "SYSCLK" }, | ||
1040 | { "Slim1 Capture", NULL, "SYSCLK" }, | ||
1041 | { "Slim2 Capture", NULL, "SYSCLK" }, | ||
1042 | |||
1043 | { "IN1L Mux", "A", "IN1AL" }, | ||
1044 | { "IN1R Mux", "A", "IN1AR" }, | ||
1045 | { "IN1L Mux", "B", "IN1BL" }, | ||
1046 | { "IN1R Mux", "B", "IN1BR" }, | ||
1047 | |||
1048 | { "IN2 Mux", "A", "IN2A" }, | ||
1049 | { "IN2 Mux", "B", "IN2B" }, | ||
1050 | |||
1051 | { "IN1L PGA", NULL, "IN1L Mux" }, | ||
1052 | { "IN1R PGA", NULL, "IN1R Mux" }, | ||
1053 | { "IN2 PGA", NULL, "IN2 Mux" }, | ||
1054 | |||
1055 | ARIZONA_MIXER_ROUTES("OUT1L", "HPOUTL"), | ||
1056 | ARIZONA_MIXER_ROUTES("OUT1R", "HPOUTR"), | ||
1057 | ARIZONA_MIXER_ROUTES("OUT2L", "LINEOUTL"), | ||
1058 | ARIZONA_MIXER_ROUTES("OUT2R", "LINEOUTR"), | ||
1059 | ARIZONA_MIXER_ROUTES("OUT3", "EPOUT"), | ||
1060 | |||
1061 | ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUTL"), | ||
1062 | ARIZONA_MIXER_ROUTES("OUT4R", "SPKOUTR"), | ||
1063 | ARIZONA_MIXER_ROUTES("OUT5L", "SPKDATL"), | ||
1064 | ARIZONA_MIXER_ROUTES("OUT5R", "SPKDATR"), | ||
1065 | |||
1066 | ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"), | ||
1067 | ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"), | ||
1068 | |||
1069 | ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"), | ||
1070 | ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"), | ||
1071 | ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"), | ||
1072 | ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"), | ||
1073 | ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"), | ||
1074 | ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"), | ||
1075 | |||
1076 | ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"), | ||
1077 | ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"), | ||
1078 | ARIZONA_MIXER_ROUTES("AIF2TX3", "AIF2TX3"), | ||
1079 | ARIZONA_MIXER_ROUTES("AIF2TX4", "AIF2TX4"), | ||
1080 | ARIZONA_MIXER_ROUTES("AIF2TX5", "AIF2TX5"), | ||
1081 | ARIZONA_MIXER_ROUTES("AIF2TX6", "AIF2TX6"), | ||
1082 | |||
1083 | ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"), | ||
1084 | ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"), | ||
1085 | |||
1086 | ARIZONA_MUX_ROUTES("SLIMTX1", "SLIMTX1"), | ||
1087 | ARIZONA_MUX_ROUTES("SLIMTX2", "SLIMTX2"), | ||
1088 | ARIZONA_MUX_ROUTES("SLIMTX3", "SLIMTX3"), | ||
1089 | ARIZONA_MUX_ROUTES("SLIMTX4", "SLIMTX4"), | ||
1090 | ARIZONA_MUX_ROUTES("SLIMTX5", "SLIMTX5"), | ||
1091 | ARIZONA_MUX_ROUTES("SLIMTX6", "SLIMTX6"), | ||
1092 | |||
1093 | ARIZONA_MUX_ROUTES("SPD1TX1", "SPDIFTX1"), | ||
1094 | ARIZONA_MUX_ROUTES("SPD1TX2", "SPDIFTX2"), | ||
1095 | |||
1096 | ARIZONA_MUX_ROUTES("EQ1", "EQ1"), | ||
1097 | ARIZONA_MUX_ROUTES("EQ2", "EQ2"), | ||
1098 | ARIZONA_MUX_ROUTES("EQ3", "EQ3"), | ||
1099 | ARIZONA_MUX_ROUTES("EQ4", "EQ4"), | ||
1100 | |||
1101 | ARIZONA_MUX_ROUTES("DRC1L", "DRC1L"), | ||
1102 | ARIZONA_MUX_ROUTES("DRC1R", "DRC1R"), | ||
1103 | |||
1104 | ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"), | ||
1105 | ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"), | ||
1106 | ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"), | ||
1107 | ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"), | ||
1108 | |||
1109 | ARIZONA_MUX_ROUTES("ASRC1L", "ASRC1L"), | ||
1110 | ARIZONA_MUX_ROUTES("ASRC1R", "ASRC1R"), | ||
1111 | ARIZONA_MUX_ROUTES("ASRC2L", "ASRC2L"), | ||
1112 | ARIZONA_MUX_ROUTES("ASRC2R", "ASRC2R"), | ||
1113 | |||
1114 | ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"), | ||
1115 | ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"), | ||
1116 | ARIZONA_MUX_ROUTES("ISRC1INT3", "ISRC1INT3"), | ||
1117 | ARIZONA_MUX_ROUTES("ISRC1INT4", "ISRC1INT4"), | ||
1118 | |||
1119 | ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"), | ||
1120 | ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"), | ||
1121 | ARIZONA_MUX_ROUTES("ISRC1DEC3", "ISRC1DEC3"), | ||
1122 | ARIZONA_MUX_ROUTES("ISRC1DEC4", "ISRC1DEC4"), | ||
1123 | |||
1124 | ARIZONA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"), | ||
1125 | ARIZONA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"), | ||
1126 | |||
1127 | ARIZONA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"), | ||
1128 | ARIZONA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"), | ||
1129 | |||
1130 | { "AEC1 Loopback", "HPOUTL", "OUT1L" }, | ||
1131 | { "AEC1 Loopback", "HPOUTR", "OUT1R" }, | ||
1132 | { "AEC2 Loopback", "HPOUTL", "OUT1L" }, | ||
1133 | { "AEC2 Loopback", "HPOUTR", "OUT1R" }, | ||
1134 | { "HPOUTL", NULL, "OUT1L" }, | ||
1135 | { "HPOUTR", NULL, "OUT1R" }, | ||
1136 | |||
1137 | { "AEC1 Loopback", "LINEOUTL", "OUT2L" }, | ||
1138 | { "AEC1 Loopback", "LINEOUTR", "OUT2R" }, | ||
1139 | { "AEC2 Loopback", "LINEOUTL", "OUT2L" }, | ||
1140 | { "AEC2 Loopback", "LINEOUTR", "OUT2R" }, | ||
1141 | { "LINEOUTL", NULL, "OUT2L" }, | ||
1142 | { "LINEOUTR", NULL, "OUT2R" }, | ||
1143 | |||
1144 | { "AEC1 Loopback", "EPOUT", "OUT3" }, | ||
1145 | { "AEC2 Loopback", "EPOUT", "OUT3" }, | ||
1146 | { "EPOUT", NULL, "OUT3" }, | ||
1147 | |||
1148 | { "AEC1 Loopback", "SPKOUTL", "OUT4L" }, | ||
1149 | { "AEC2 Loopback", "SPKOUTL", "OUT4L" }, | ||
1150 | { "SPKOUTLN", NULL, "OUT4L" }, | ||
1151 | { "SPKOUTLP", NULL, "OUT4L" }, | ||
1152 | |||
1153 | { "AEC1 Loopback", "SPKOUTR", "OUT4R" }, | ||
1154 | { "AEC2 Loopback", "SPKOUTR", "OUT4R" }, | ||
1155 | { "SPKOUTRN", NULL, "OUT4R" }, | ||
1156 | { "SPKOUTRP", NULL, "OUT4R" }, | ||
1157 | |||
1158 | { "SPDIF", NULL, "SPD1" }, | ||
1159 | |||
1160 | { "AEC1 Loopback", "SPKDATL", "OUT5L" }, | ||
1161 | { "AEC1 Loopback", "SPKDATR", "OUT5R" }, | ||
1162 | { "AEC2 Loopback", "SPKDATL", "OUT5L" }, | ||
1163 | { "AEC2 Loopback", "SPKDATR", "OUT5R" }, | ||
1164 | { "SPKDATL", NULL, "OUT5L" }, | ||
1165 | { "SPKDATR", NULL, "OUT5R" }, | ||
1166 | |||
1167 | { "MICSUPP", NULL, "SYSCLK" }, | ||
1168 | |||
1169 | { "DRC1 Signal Activity", NULL, "DRC1L" }, | ||
1170 | { "DRC1 Signal Activity", NULL, "DRC1R" }, | ||
1171 | }; | ||
1172 | |||
1173 | #define WM8998_RATES SNDRV_PCM_RATE_8000_192000 | ||
1174 | |||
1175 | #define WM8998_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ | ||
1176 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) | ||
1177 | |||
1178 | static struct snd_soc_dai_driver wm8998_dai[] = { | ||
1179 | { | ||
1180 | .name = "wm8998-aif1", | ||
1181 | .id = 1, | ||
1182 | .base = ARIZONA_AIF1_BCLK_CTRL, | ||
1183 | .playback = { | ||
1184 | .stream_name = "AIF1 Playback", | ||
1185 | .channels_min = 1, | ||
1186 | .channels_max = 6, | ||
1187 | .rates = WM8998_RATES, | ||
1188 | .formats = WM8998_FORMATS, | ||
1189 | }, | ||
1190 | .capture = { | ||
1191 | .stream_name = "AIF1 Capture", | ||
1192 | .channels_min = 1, | ||
1193 | .channels_max = 6, | ||
1194 | .rates = WM8998_RATES, | ||
1195 | .formats = WM8998_FORMATS, | ||
1196 | }, | ||
1197 | .ops = &arizona_dai_ops, | ||
1198 | .symmetric_rates = 1, | ||
1199 | .symmetric_samplebits = 1, | ||
1200 | }, | ||
1201 | { | ||
1202 | .name = "wm8998-aif2", | ||
1203 | .id = 2, | ||
1204 | .base = ARIZONA_AIF2_BCLK_CTRL, | ||
1205 | .playback = { | ||
1206 | .stream_name = "AIF2 Playback", | ||
1207 | .channels_min = 1, | ||
1208 | .channels_max = 6, | ||
1209 | .rates = WM8998_RATES, | ||
1210 | .formats = WM8998_FORMATS, | ||
1211 | }, | ||
1212 | .capture = { | ||
1213 | .stream_name = "AIF2 Capture", | ||
1214 | .channels_min = 1, | ||
1215 | .channels_max = 6, | ||
1216 | .rates = WM8998_RATES, | ||
1217 | .formats = WM8998_FORMATS, | ||
1218 | }, | ||
1219 | .ops = &arizona_dai_ops, | ||
1220 | .symmetric_rates = 1, | ||
1221 | .symmetric_samplebits = 1, | ||
1222 | }, | ||
1223 | { | ||
1224 | .name = "wm8998-aif3", | ||
1225 | .id = 3, | ||
1226 | .base = ARIZONA_AIF3_BCLK_CTRL, | ||
1227 | .playback = { | ||
1228 | .stream_name = "AIF3 Playback", | ||
1229 | .channels_min = 1, | ||
1230 | .channels_max = 2, | ||
1231 | .rates = WM8998_RATES, | ||
1232 | .formats = WM8998_FORMATS, | ||
1233 | }, | ||
1234 | .capture = { | ||
1235 | .stream_name = "AIF3 Capture", | ||
1236 | .channels_min = 1, | ||
1237 | .channels_max = 2, | ||
1238 | .rates = WM8998_RATES, | ||
1239 | .formats = WM8998_FORMATS, | ||
1240 | }, | ||
1241 | .ops = &arizona_dai_ops, | ||
1242 | .symmetric_rates = 1, | ||
1243 | .symmetric_samplebits = 1, | ||
1244 | }, | ||
1245 | { | ||
1246 | .name = "wm8998-slim1", | ||
1247 | .id = 4, | ||
1248 | .playback = { | ||
1249 | .stream_name = "Slim1 Playback", | ||
1250 | .channels_min = 1, | ||
1251 | .channels_max = 2, | ||
1252 | .rates = WM8998_RATES, | ||
1253 | .formats = WM8998_FORMATS, | ||
1254 | }, | ||
1255 | .capture = { | ||
1256 | .stream_name = "Slim1 Capture", | ||
1257 | .channels_min = 1, | ||
1258 | .channels_max = 4, | ||
1259 | .rates = WM8998_RATES, | ||
1260 | .formats = WM8998_FORMATS, | ||
1261 | }, | ||
1262 | .ops = &arizona_simple_dai_ops, | ||
1263 | }, | ||
1264 | { | ||
1265 | .name = "wm8998-slim2", | ||
1266 | .id = 5, | ||
1267 | .playback = { | ||
1268 | .stream_name = "Slim2 Playback", | ||
1269 | .channels_min = 1, | ||
1270 | .channels_max = 2, | ||
1271 | .rates = WM8998_RATES, | ||
1272 | .formats = WM8998_FORMATS, | ||
1273 | }, | ||
1274 | .capture = { | ||
1275 | .stream_name = "Slim2 Capture", | ||
1276 | .channels_min = 1, | ||
1277 | .channels_max = 2, | ||
1278 | .rates = WM8998_RATES, | ||
1279 | .formats = WM8998_FORMATS, | ||
1280 | }, | ||
1281 | .ops = &arizona_simple_dai_ops, | ||
1282 | }, | ||
1283 | }; | ||
1284 | |||
1285 | static int wm8998_set_fll(struct snd_soc_codec *codec, int fll_id, int source, | ||
1286 | unsigned int Fref, unsigned int Fout) | ||
1287 | { | ||
1288 | struct wm8998_priv *wm8998 = snd_soc_codec_get_drvdata(codec); | ||
1289 | |||
1290 | switch (fll_id) { | ||
1291 | case WM8998_FLL1: | ||
1292 | return arizona_set_fll(&wm8998->fll[0], source, Fref, Fout); | ||
1293 | case WM8998_FLL2: | ||
1294 | return arizona_set_fll(&wm8998->fll[1], source, Fref, Fout); | ||
1295 | case WM8998_FLL1_REFCLK: | ||
1296 | return arizona_set_fll_refclk(&wm8998->fll[0], source, Fref, | ||
1297 | Fout); | ||
1298 | case WM8998_FLL2_REFCLK: | ||
1299 | return arizona_set_fll_refclk(&wm8998->fll[1], source, Fref, | ||
1300 | Fout); | ||
1301 | default: | ||
1302 | return -EINVAL; | ||
1303 | } | ||
1304 | } | ||
1305 | |||
1306 | static int wm8998_codec_probe(struct snd_soc_codec *codec) | ||
1307 | { | ||
1308 | struct wm8998_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
1309 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); | ||
1310 | |||
1311 | priv->core.arizona->dapm = dapm; | ||
1312 | |||
1313 | arizona_init_spk(codec); | ||
1314 | arizona_init_gpio(codec); | ||
1315 | |||
1316 | snd_soc_dapm_disable_pin(dapm, "HAPTICS"); | ||
1317 | |||
1318 | return 0; | ||
1319 | } | ||
1320 | |||
1321 | static int wm8998_codec_remove(struct snd_soc_codec *codec) | ||
1322 | { | ||
1323 | struct wm8998_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
1324 | |||
1325 | priv->core.arizona->dapm = NULL; | ||
1326 | |||
1327 | return 0; | ||
1328 | } | ||
1329 | |||
1330 | #define WM8998_DIG_VU 0x0200 | ||
1331 | |||
1332 | static unsigned int wm8998_digital_vu[] = { | ||
1333 | ARIZONA_DAC_DIGITAL_VOLUME_1L, | ||
1334 | ARIZONA_DAC_DIGITAL_VOLUME_1R, | ||
1335 | ARIZONA_DAC_DIGITAL_VOLUME_2L, | ||
1336 | ARIZONA_DAC_DIGITAL_VOLUME_2R, | ||
1337 | ARIZONA_DAC_DIGITAL_VOLUME_3L, | ||
1338 | ARIZONA_DAC_DIGITAL_VOLUME_4L, | ||
1339 | ARIZONA_DAC_DIGITAL_VOLUME_4R, | ||
1340 | ARIZONA_DAC_DIGITAL_VOLUME_5L, | ||
1341 | ARIZONA_DAC_DIGITAL_VOLUME_5R, | ||
1342 | }; | ||
1343 | |||
1344 | static struct regmap *wm8998_get_regmap(struct device *dev) | ||
1345 | { | ||
1346 | struct wm8998_priv *priv = dev_get_drvdata(dev); | ||
1347 | |||
1348 | return priv->core.arizona->regmap; | ||
1349 | } | ||
1350 | |||
1351 | static struct snd_soc_codec_driver soc_codec_dev_wm8998 = { | ||
1352 | .probe = wm8998_codec_probe, | ||
1353 | .remove = wm8998_codec_remove, | ||
1354 | .get_regmap = wm8998_get_regmap, | ||
1355 | |||
1356 | .idle_bias_off = true, | ||
1357 | |||
1358 | .set_sysclk = arizona_set_sysclk, | ||
1359 | .set_pll = wm8998_set_fll, | ||
1360 | |||
1361 | .controls = wm8998_snd_controls, | ||
1362 | .num_controls = ARRAY_SIZE(wm8998_snd_controls), | ||
1363 | .dapm_widgets = wm8998_dapm_widgets, | ||
1364 | .num_dapm_widgets = ARRAY_SIZE(wm8998_dapm_widgets), | ||
1365 | .dapm_routes = wm8998_dapm_routes, | ||
1366 | .num_dapm_routes = ARRAY_SIZE(wm8998_dapm_routes), | ||
1367 | }; | ||
1368 | |||
1369 | static int wm8998_probe(struct platform_device *pdev) | ||
1370 | { | ||
1371 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); | ||
1372 | struct wm8998_priv *wm8998; | ||
1373 | int i; | ||
1374 | |||
1375 | wm8998 = devm_kzalloc(&pdev->dev, sizeof(struct wm8998_priv), | ||
1376 | GFP_KERNEL); | ||
1377 | if (!wm8998) | ||
1378 | return -ENOMEM; | ||
1379 | platform_set_drvdata(pdev, wm8998); | ||
1380 | |||
1381 | wm8998->core.arizona = arizona; | ||
1382 | wm8998->core.num_inputs = 3; /* IN1L, IN1R, IN2 */ | ||
1383 | |||
1384 | for (i = 0; i < ARRAY_SIZE(wm8998->fll); i++) | ||
1385 | wm8998->fll[i].vco_mult = 1; | ||
1386 | |||
1387 | arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1, | ||
1388 | ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK, | ||
1389 | &wm8998->fll[0]); | ||
1390 | arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1, | ||
1391 | ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK, | ||
1392 | &wm8998->fll[1]); | ||
1393 | |||
1394 | for (i = 0; i < ARRAY_SIZE(wm8998_dai); i++) | ||
1395 | arizona_init_dai(&wm8998->core, i); | ||
1396 | |||
1397 | /* Latch volume update bits */ | ||
1398 | for (i = 0; i < ARRAY_SIZE(wm8998_digital_vu); i++) | ||
1399 | regmap_update_bits(arizona->regmap, wm8998_digital_vu[i], | ||
1400 | WM8998_DIG_VU, WM8998_DIG_VU); | ||
1401 | |||
1402 | pm_runtime_enable(&pdev->dev); | ||
1403 | pm_runtime_idle(&pdev->dev); | ||
1404 | |||
1405 | return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8998, | ||
1406 | wm8998_dai, ARRAY_SIZE(wm8998_dai)); | ||
1407 | } | ||
1408 | |||
1409 | static int wm8998_remove(struct platform_device *pdev) | ||
1410 | { | ||
1411 | snd_soc_unregister_codec(&pdev->dev); | ||
1412 | pm_runtime_disable(&pdev->dev); | ||
1413 | |||
1414 | return 0; | ||
1415 | } | ||
1416 | |||
1417 | static struct platform_driver wm8998_codec_driver = { | ||
1418 | .driver = { | ||
1419 | .name = "wm8998-codec", | ||
1420 | }, | ||
1421 | .probe = wm8998_probe, | ||
1422 | .remove = wm8998_remove, | ||
1423 | }; | ||
1424 | |||
1425 | module_platform_driver(wm8998_codec_driver); | ||
1426 | |||
1427 | MODULE_DESCRIPTION("ASoC WM8998 driver"); | ||
1428 | MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.wolfsonmicro.com>"); | ||
1429 | MODULE_LICENSE("GPL v2"); | ||
1430 | MODULE_ALIAS("platform:wm8998-codec"); | ||
diff --git a/sound/soc/codecs/wm8998.h b/sound/soc/codecs/wm8998.h new file mode 100644 index 000000000000..1e8647252162 --- /dev/null +++ b/sound/soc/codecs/wm8998.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * wm8998.h -- ALSA SoC Audio driver for WM8998 codecs | ||
3 | * | ||
4 | * Copyright 2015 Cirrus Logic, Inc. | ||
5 | * | ||
6 | * Author: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> | ||
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 | */ | ||
12 | |||
13 | #ifndef _WM8998_H | ||
14 | #define _WM8998_H | ||
15 | |||
16 | #include "arizona.h" | ||
17 | |||
18 | #define WM8998_FLL1 1 | ||
19 | #define WM8998_FLL2 2 | ||
20 | #define WM8998_FLL1_REFCLK 3 | ||
21 | #define WM8998_FLL2_REFCLK 4 | ||
22 | |||
23 | #endif | ||
diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c index ba34252b7bba..6e6a70c5c2bd 100644 --- a/sound/soc/dwc/designware_i2s.c +++ b/sound/soc/dwc/designware_i2s.c | |||
@@ -282,23 +282,25 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream, | |||
282 | 282 | ||
283 | config->sample_rate = params_rate(params); | 283 | config->sample_rate = params_rate(params); |
284 | 284 | ||
285 | if (dev->i2s_clk_cfg) { | 285 | if (dev->capability & DW_I2S_MASTER) { |
286 | ret = dev->i2s_clk_cfg(config); | 286 | if (dev->i2s_clk_cfg) { |
287 | if (ret < 0) { | 287 | ret = dev->i2s_clk_cfg(config); |
288 | dev_err(dev->dev, "runtime audio clk config fail\n"); | 288 | if (ret < 0) { |
289 | return ret; | 289 | dev_err(dev->dev, "runtime audio clk config fail\n"); |
290 | } | 290 | return ret; |
291 | } else { | 291 | } |
292 | u32 bitclk = config->sample_rate * config->data_width * 2; | 292 | } else { |
293 | 293 | u32 bitclk = config->sample_rate * | |
294 | ret = clk_set_rate(dev->clk, bitclk); | 294 | config->data_width * 2; |
295 | if (ret) { | 295 | |
296 | dev_err(dev->dev, "Can't set I2S clock rate: %d\n", | 296 | ret = clk_set_rate(dev->clk, bitclk); |
297 | ret); | 297 | if (ret) { |
298 | return ret; | 298 | dev_err(dev->dev, "Can't set I2S clock rate: %d\n", |
299 | ret); | ||
300 | return ret; | ||
301 | } | ||
299 | } | 302 | } |
300 | } | 303 | } |
301 | |||
302 | return 0; | 304 | return 0; |
303 | } | 305 | } |
304 | 306 | ||
@@ -348,12 +350,43 @@ static int dw_i2s_trigger(struct snd_pcm_substream *substream, | |||
348 | return ret; | 350 | return ret; |
349 | } | 351 | } |
350 | 352 | ||
353 | static int dw_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | ||
354 | { | ||
355 | struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); | ||
356 | int ret = 0; | ||
357 | |||
358 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
359 | case SND_SOC_DAIFMT_CBM_CFM: | ||
360 | if (dev->capability & DW_I2S_SLAVE) | ||
361 | ret = 0; | ||
362 | else | ||
363 | ret = -EINVAL; | ||
364 | break; | ||
365 | case SND_SOC_DAIFMT_CBS_CFS: | ||
366 | if (dev->capability & DW_I2S_MASTER) | ||
367 | ret = 0; | ||
368 | else | ||
369 | ret = -EINVAL; | ||
370 | break; | ||
371 | case SND_SOC_DAIFMT_CBM_CFS: | ||
372 | case SND_SOC_DAIFMT_CBS_CFM: | ||
373 | ret = -EINVAL; | ||
374 | break; | ||
375 | default: | ||
376 | dev_dbg(dev->dev, "dwc : Invalid master/slave format\n"); | ||
377 | ret = -EINVAL; | ||
378 | break; | ||
379 | } | ||
380 | return ret; | ||
381 | } | ||
382 | |||
351 | static struct snd_soc_dai_ops dw_i2s_dai_ops = { | 383 | static struct snd_soc_dai_ops dw_i2s_dai_ops = { |
352 | .startup = dw_i2s_startup, | 384 | .startup = dw_i2s_startup, |
353 | .shutdown = dw_i2s_shutdown, | 385 | .shutdown = dw_i2s_shutdown, |
354 | .hw_params = dw_i2s_hw_params, | 386 | .hw_params = dw_i2s_hw_params, |
355 | .prepare = dw_i2s_prepare, | 387 | .prepare = dw_i2s_prepare, |
356 | .trigger = dw_i2s_trigger, | 388 | .trigger = dw_i2s_trigger, |
389 | .set_fmt = dw_i2s_set_fmt, | ||
357 | }; | 390 | }; |
358 | 391 | ||
359 | static const struct snd_soc_component_driver dw_i2s_component = { | 392 | static const struct snd_soc_component_driver dw_i2s_component = { |
@@ -366,7 +399,8 @@ static int dw_i2s_suspend(struct snd_soc_dai *dai) | |||
366 | { | 399 | { |
367 | struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); | 400 | struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); |
368 | 401 | ||
369 | clk_disable(dev->clk); | 402 | if (dev->capability & DW_I2S_MASTER) |
403 | clk_disable(dev->clk); | ||
370 | return 0; | 404 | return 0; |
371 | } | 405 | } |
372 | 406 | ||
@@ -374,7 +408,8 @@ static int dw_i2s_resume(struct snd_soc_dai *dai) | |||
374 | { | 408 | { |
375 | struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); | 409 | struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); |
376 | 410 | ||
377 | clk_enable(dev->clk); | 411 | if (dev->capability & DW_I2S_MASTER) |
412 | clk_enable(dev->clk); | ||
378 | return 0; | 413 | return 0; |
379 | } | 414 | } |
380 | 415 | ||
@@ -452,6 +487,14 @@ static int dw_configure_dai(struct dw_i2s_dev *dev, | |||
452 | dw_i2s_dai->capture.rates = rates; | 487 | dw_i2s_dai->capture.rates = rates; |
453 | } | 488 | } |
454 | 489 | ||
490 | if (COMP1_MODE_EN(comp1)) { | ||
491 | dev_dbg(dev->dev, "designware: i2s master mode supported\n"); | ||
492 | dev->capability |= DW_I2S_MASTER; | ||
493 | } else { | ||
494 | dev_dbg(dev->dev, "designware: i2s slave mode supported\n"); | ||
495 | dev->capability |= DW_I2S_SLAVE; | ||
496 | } | ||
497 | |||
455 | return 0; | 498 | return 0; |
456 | } | 499 | } |
457 | 500 | ||
@@ -538,6 +581,7 @@ static int dw_i2s_probe(struct platform_device *pdev) | |||
538 | struct resource *res; | 581 | struct resource *res; |
539 | int ret; | 582 | int ret; |
540 | struct snd_soc_dai_driver *dw_i2s_dai; | 583 | struct snd_soc_dai_driver *dw_i2s_dai; |
584 | const char *clk_id; | ||
541 | 585 | ||
542 | dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); | 586 | dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); |
543 | if (!dev) { | 587 | if (!dev) { |
@@ -559,32 +603,35 @@ static int dw_i2s_probe(struct platform_device *pdev) | |||
559 | return PTR_ERR(dev->i2s_base); | 603 | return PTR_ERR(dev->i2s_base); |
560 | 604 | ||
561 | dev->dev = &pdev->dev; | 605 | dev->dev = &pdev->dev; |
606 | |||
562 | if (pdata) { | 607 | if (pdata) { |
608 | dev->capability = pdata->cap; | ||
609 | clk_id = NULL; | ||
563 | ret = dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata); | 610 | ret = dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata); |
564 | if (ret < 0) | 611 | } else { |
565 | return ret; | 612 | clk_id = "i2sclk"; |
613 | ret = dw_configure_dai_by_dt(dev, dw_i2s_dai, res); | ||
614 | } | ||
615 | if (ret < 0) | ||
616 | return ret; | ||
566 | 617 | ||
567 | dev->capability = pdata->cap; | 618 | if (dev->capability & DW_I2S_MASTER) { |
568 | dev->i2s_clk_cfg = pdata->i2s_clk_cfg; | 619 | if (pdata) { |
569 | if (!dev->i2s_clk_cfg) { | 620 | dev->i2s_clk_cfg = pdata->i2s_clk_cfg; |
570 | dev_err(&pdev->dev, "no clock configure method\n"); | 621 | if (!dev->i2s_clk_cfg) { |
571 | return -ENODEV; | 622 | dev_err(&pdev->dev, "no clock configure method\n"); |
623 | return -ENODEV; | ||
624 | } | ||
572 | } | 625 | } |
626 | dev->clk = devm_clk_get(&pdev->dev, clk_id); | ||
573 | 627 | ||
574 | dev->clk = devm_clk_get(&pdev->dev, NULL); | 628 | if (IS_ERR(dev->clk)) |
575 | } else { | 629 | return PTR_ERR(dev->clk); |
576 | ret = dw_configure_dai_by_dt(dev, dw_i2s_dai, res); | 630 | |
631 | ret = clk_prepare_enable(dev->clk); | ||
577 | if (ret < 0) | 632 | if (ret < 0) |
578 | return ret; | 633 | return ret; |
579 | |||
580 | dev->clk = devm_clk_get(&pdev->dev, "i2sclk"); | ||
581 | } | 634 | } |
582 | if (IS_ERR(dev->clk)) | ||
583 | return PTR_ERR(dev->clk); | ||
584 | |||
585 | ret = clk_prepare_enable(dev->clk); | ||
586 | if (ret < 0) | ||
587 | return ret; | ||
588 | 635 | ||
589 | dev_set_drvdata(&pdev->dev, dev); | 636 | dev_set_drvdata(&pdev->dev, dev); |
590 | ret = devm_snd_soc_register_component(&pdev->dev, &dw_i2s_component, | 637 | ret = devm_snd_soc_register_component(&pdev->dev, &dw_i2s_component, |
@@ -606,7 +653,8 @@ static int dw_i2s_probe(struct platform_device *pdev) | |||
606 | return 0; | 653 | return 0; |
607 | 654 | ||
608 | err_clk_disable: | 655 | err_clk_disable: |
609 | clk_disable_unprepare(dev->clk); | 656 | if (dev->capability & DW_I2S_MASTER) |
657 | clk_disable_unprepare(dev->clk); | ||
610 | return ret; | 658 | return ret; |
611 | } | 659 | } |
612 | 660 | ||
@@ -614,7 +662,8 @@ static int dw_i2s_remove(struct platform_device *pdev) | |||
614 | { | 662 | { |
615 | struct dw_i2s_dev *dev = dev_get_drvdata(&pdev->dev); | 663 | struct dw_i2s_dev *dev = dev_get_drvdata(&pdev->dev); |
616 | 664 | ||
617 | clk_disable_unprepare(dev->clk); | 665 | if (dev->capability & DW_I2S_MASTER) |
666 | clk_disable_unprepare(dev->clk); | ||
618 | 667 | ||
619 | return 0; | 668 | return 0; |
620 | } | 669 | } |
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 0901d5e20df2..1b05d1c5d9fd 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c | |||
@@ -14,6 +14,9 @@ | |||
14 | #include <linux/i2c.h> | 14 | #include <linux/i2c.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/of_platform.h> | 16 | #include <linux/of_platform.h> |
17 | #if IS_ENABLED(CONFIG_SND_AC97_CODEC) | ||
18 | #include <sound/ac97_codec.h> | ||
19 | #endif | ||
17 | #include <sound/pcm_params.h> | 20 | #include <sound/pcm_params.h> |
18 | #include <sound/soc.h> | 21 | #include <sound/soc.h> |
19 | 22 | ||
@@ -115,6 +118,11 @@ static const struct snd_soc_dapm_widget fsl_asoc_card_dapm_widgets[] = { | |||
115 | SND_SOC_DAPM_MIC("DMIC", NULL), | 118 | SND_SOC_DAPM_MIC("DMIC", NULL), |
116 | }; | 119 | }; |
117 | 120 | ||
121 | static bool fsl_asoc_card_is_ac97(struct fsl_asoc_card_priv *priv) | ||
122 | { | ||
123 | return priv->dai_fmt == SND_SOC_DAIFMT_AC97; | ||
124 | } | ||
125 | |||
118 | static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream, | 126 | static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream, |
119 | struct snd_pcm_hw_params *params) | 127 | struct snd_pcm_hw_params *params) |
120 | { | 128 | { |
@@ -133,7 +141,9 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream, | |||
133 | * set_bias_level(), bypass the remaining settings in hw_params(). | 141 | * set_bias_level(), bypass the remaining settings in hw_params(). |
134 | * Note: (dai_fmt & CBM_CFM) includes CBM_CFM and CBM_CFS. | 142 | * Note: (dai_fmt & CBM_CFM) includes CBM_CFM and CBM_CFS. |
135 | */ | 143 | */ |
136 | if (priv->card.set_bias_level && priv->dai_fmt & SND_SOC_DAIFMT_CBM_CFM) | 144 | if ((priv->card.set_bias_level && |
145 | priv->dai_fmt & SND_SOC_DAIFMT_CBM_CFM) || | ||
146 | fsl_asoc_card_is_ac97(priv)) | ||
137 | return 0; | 147 | return 0; |
138 | 148 | ||
139 | /* Specific configurations of DAIs starts from here */ | 149 | /* Specific configurations of DAIs starts from here */ |
@@ -300,7 +310,7 @@ static int fsl_asoc_card_audmux_init(struct device_node *np, | |||
300 | ext_port--; | 310 | ext_port--; |
301 | 311 | ||
302 | /* | 312 | /* |
303 | * Use asynchronous mode (6 wires) for all cases. | 313 | * Use asynchronous mode (6 wires) for all cases except AC97. |
304 | * If only 4 wires are needed, just set SSI into | 314 | * If only 4 wires are needed, just set SSI into |
305 | * synchronous mode and enable 4 PADs in IOMUX. | 315 | * synchronous mode and enable 4 PADs in IOMUX. |
306 | */ | 316 | */ |
@@ -346,15 +356,30 @@ static int fsl_asoc_card_audmux_init(struct device_node *np, | |||
346 | IMX_AUDMUX_V2_PTCR_TCLKDIR; | 356 | IMX_AUDMUX_V2_PTCR_TCLKDIR; |
347 | break; | 357 | break; |
348 | default: | 358 | default: |
349 | return -EINVAL; | 359 | if (!fsl_asoc_card_is_ac97(priv)) |
360 | return -EINVAL; | ||
361 | } | ||
362 | |||
363 | if (fsl_asoc_card_is_ac97(priv)) { | ||
364 | int_ptcr = IMX_AUDMUX_V2_PTCR_SYN | | ||
365 | IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) | | ||
366 | IMX_AUDMUX_V2_PTCR_TCLKDIR; | ||
367 | ext_ptcr = IMX_AUDMUX_V2_PTCR_SYN | | ||
368 | IMX_AUDMUX_V2_PTCR_TFSEL(int_port) | | ||
369 | IMX_AUDMUX_V2_PTCR_TFSDIR; | ||
350 | } | 370 | } |
351 | 371 | ||
352 | /* Asynchronous mode can not be set along with RCLKDIR */ | 372 | /* Asynchronous mode can not be set along with RCLKDIR */ |
353 | ret = imx_audmux_v2_configure_port(int_port, 0, | 373 | if (!fsl_asoc_card_is_ac97(priv)) { |
354 | IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port)); | 374 | unsigned int pdcr = |
355 | if (ret) { | 375 | IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port); |
356 | dev_err(dev, "audmux internal port setup failed\n"); | 376 | |
357 | return ret; | 377 | ret = imx_audmux_v2_configure_port(int_port, 0, |
378 | pdcr); | ||
379 | if (ret) { | ||
380 | dev_err(dev, "audmux internal port setup failed\n"); | ||
381 | return ret; | ||
382 | } | ||
358 | } | 383 | } |
359 | 384 | ||
360 | ret = imx_audmux_v2_configure_port(int_port, int_ptcr, | 385 | ret = imx_audmux_v2_configure_port(int_port, int_ptcr, |
@@ -364,11 +389,16 @@ static int fsl_asoc_card_audmux_init(struct device_node *np, | |||
364 | return ret; | 389 | return ret; |
365 | } | 390 | } |
366 | 391 | ||
367 | ret = imx_audmux_v2_configure_port(ext_port, 0, | 392 | if (!fsl_asoc_card_is_ac97(priv)) { |
368 | IMX_AUDMUX_V2_PDCR_RXDSEL(int_port)); | 393 | unsigned int pdcr = |
369 | if (ret) { | 394 | IMX_AUDMUX_V2_PDCR_RXDSEL(int_port); |
370 | dev_err(dev, "audmux external port setup failed\n"); | 395 | |
371 | return ret; | 396 | ret = imx_audmux_v2_configure_port(ext_port, 0, |
397 | pdcr); | ||
398 | if (ret) { | ||
399 | dev_err(dev, "audmux external port setup failed\n"); | ||
400 | return ret; | ||
401 | } | ||
372 | } | 402 | } |
373 | 403 | ||
374 | ret = imx_audmux_v2_configure_port(ext_port, ext_ptcr, | 404 | ret = imx_audmux_v2_configure_port(ext_port, ext_ptcr, |
@@ -389,6 +419,23 @@ static int fsl_asoc_card_late_probe(struct snd_soc_card *card) | |||
389 | struct device *dev = card->dev; | 419 | struct device *dev = card->dev; |
390 | int ret; | 420 | int ret; |
391 | 421 | ||
422 | if (fsl_asoc_card_is_ac97(priv)) { | ||
423 | #if IS_ENABLED(CONFIG_SND_AC97_CODEC) | ||
424 | struct snd_soc_codec *codec = card->rtd[0].codec; | ||
425 | struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); | ||
426 | |||
427 | /* | ||
428 | * Use slots 3/4 for S/PDIF so SSI won't try to enable | ||
429 | * other slots and send some samples there | ||
430 | * due to SLOTREQ bits for S/PDIF received from codec | ||
431 | */ | ||
432 | snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, | ||
433 | AC97_EA_SPSA_SLOT_MASK, AC97_EA_SPSA_3_4); | ||
434 | #endif | ||
435 | |||
436 | return 0; | ||
437 | } | ||
438 | |||
392 | ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id, | 439 | ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id, |
393 | codec_priv->mclk_freq, SND_SOC_CLOCK_IN); | 440 | codec_priv->mclk_freq, SND_SOC_CLOCK_IN); |
394 | if (ret) { | 441 | if (ret) { |
@@ -407,7 +454,6 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) | |||
407 | struct platform_device *cpu_pdev; | 454 | struct platform_device *cpu_pdev; |
408 | struct fsl_asoc_card_priv *priv; | 455 | struct fsl_asoc_card_priv *priv; |
409 | struct i2c_client *codec_dev; | 456 | struct i2c_client *codec_dev; |
410 | struct clk *codec_clk; | ||
411 | const char *codec_dai_name; | 457 | const char *codec_dai_name; |
412 | u32 width; | 458 | u32 width; |
413 | int ret; | 459 | int ret; |
@@ -420,9 +466,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) | |||
420 | /* Give a chance to old DT binding */ | 466 | /* Give a chance to old DT binding */ |
421 | if (!cpu_np) | 467 | if (!cpu_np) |
422 | cpu_np = of_parse_phandle(np, "ssi-controller", 0); | 468 | cpu_np = of_parse_phandle(np, "ssi-controller", 0); |
423 | codec_np = of_parse_phandle(np, "audio-codec", 0); | 469 | if (!cpu_np) { |
424 | if (!cpu_np || !codec_np) { | 470 | dev_err(&pdev->dev, "CPU phandle missing or invalid\n"); |
425 | dev_err(&pdev->dev, "phandle missing or invalid\n"); | ||
426 | ret = -EINVAL; | 471 | ret = -EINVAL; |
427 | goto fail; | 472 | goto fail; |
428 | } | 473 | } |
@@ -434,22 +479,24 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) | |||
434 | goto fail; | 479 | goto fail; |
435 | } | 480 | } |
436 | 481 | ||
437 | codec_dev = of_find_i2c_device_by_node(codec_np); | 482 | codec_np = of_parse_phandle(np, "audio-codec", 0); |
438 | if (!codec_dev) { | 483 | if (codec_np) |
439 | dev_err(&pdev->dev, "failed to find codec platform device\n"); | 484 | codec_dev = of_find_i2c_device_by_node(codec_np); |
440 | ret = -EINVAL; | 485 | else |
441 | goto fail; | 486 | codec_dev = NULL; |
442 | } | ||
443 | 487 | ||
444 | asrc_np = of_parse_phandle(np, "audio-asrc", 0); | 488 | asrc_np = of_parse_phandle(np, "audio-asrc", 0); |
445 | if (asrc_np) | 489 | if (asrc_np) |
446 | asrc_pdev = of_find_device_by_node(asrc_np); | 490 | asrc_pdev = of_find_device_by_node(asrc_np); |
447 | 491 | ||
448 | /* Get the MCLK rate only, and leave it controlled by CODEC drivers */ | 492 | /* Get the MCLK rate only, and leave it controlled by CODEC drivers */ |
449 | codec_clk = clk_get(&codec_dev->dev, NULL); | 493 | if (codec_dev) { |
450 | if (!IS_ERR(codec_clk)) { | 494 | struct clk *codec_clk = clk_get(&codec_dev->dev, NULL); |
451 | priv->codec_priv.mclk_freq = clk_get_rate(codec_clk); | 495 | |
452 | clk_put(codec_clk); | 496 | if (!IS_ERR(codec_clk)) { |
497 | priv->codec_priv.mclk_freq = clk_get_rate(codec_clk); | ||
498 | clk_put(codec_clk); | ||
499 | } | ||
453 | } | 500 | } |
454 | 501 | ||
455 | /* Default sample rate and format, will be updated in hw_params() */ | 502 | /* Default sample rate and format, will be updated in hw_params() */ |
@@ -486,12 +533,22 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) | |||
486 | priv->codec_priv.fll_id = WM8960_SYSCLK_AUTO; | 533 | priv->codec_priv.fll_id = WM8960_SYSCLK_AUTO; |
487 | priv->codec_priv.pll_id = WM8960_SYSCLK_AUTO; | 534 | priv->codec_priv.pll_id = WM8960_SYSCLK_AUTO; |
488 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; | 535 | priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; |
536 | } else if (of_device_is_compatible(np, "fsl,imx-audio-ac97")) { | ||
537 | codec_dai_name = "ac97-hifi"; | ||
538 | priv->card.set_bias_level = NULL; | ||
539 | priv->dai_fmt = SND_SOC_DAIFMT_AC97; | ||
489 | } else { | 540 | } else { |
490 | dev_err(&pdev->dev, "unknown Device Tree compatible\n"); | 541 | dev_err(&pdev->dev, "unknown Device Tree compatible\n"); |
491 | ret = -EINVAL; | 542 | ret = -EINVAL; |
492 | goto asrc_fail; | 543 | goto asrc_fail; |
493 | } | 544 | } |
494 | 545 | ||
546 | if (!fsl_asoc_card_is_ac97(priv) && !codec_dev) { | ||
547 | dev_err(&pdev->dev, "failed to find codec device\n"); | ||
548 | ret = -EINVAL; | ||
549 | goto asrc_fail; | ||
550 | } | ||
551 | |||
495 | /* Common settings for corresponding Freescale CPU DAI driver */ | 552 | /* Common settings for corresponding Freescale CPU DAI driver */ |
496 | if (strstr(cpu_np->name, "ssi")) { | 553 | if (strstr(cpu_np->name, "ssi")) { |
497 | /* Only SSI needs to configure AUDMUX */ | 554 | /* Only SSI needs to configure AUDMUX */ |
@@ -508,7 +565,9 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) | |||
508 | priv->cpu_priv.sysclk_id[0] = FSL_SAI_CLK_MAST1; | 565 | priv->cpu_priv.sysclk_id[0] = FSL_SAI_CLK_MAST1; |
509 | } | 566 | } |
510 | 567 | ||
511 | sprintf(priv->name, "%s-audio", codec_dev->name); | 568 | snprintf(priv->name, sizeof(priv->name), "%s-audio", |
569 | fsl_asoc_card_is_ac97(priv) ? "ac97" : | ||
570 | codec_dev->name); | ||
512 | 571 | ||
513 | /* Initialize sound card */ | 572 | /* Initialize sound card */ |
514 | priv->pdev = pdev; | 573 | priv->pdev = pdev; |
@@ -532,8 +591,26 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) | |||
532 | 591 | ||
533 | /* Normal DAI Link */ | 592 | /* Normal DAI Link */ |
534 | priv->dai_link[0].cpu_of_node = cpu_np; | 593 | priv->dai_link[0].cpu_of_node = cpu_np; |
535 | priv->dai_link[0].codec_of_node = codec_np; | ||
536 | priv->dai_link[0].codec_dai_name = codec_dai_name; | 594 | priv->dai_link[0].codec_dai_name = codec_dai_name; |
595 | |||
596 | if (!fsl_asoc_card_is_ac97(priv)) | ||
597 | priv->dai_link[0].codec_of_node = codec_np; | ||
598 | else { | ||
599 | u32 idx; | ||
600 | |||
601 | ret = of_property_read_u32(cpu_np, "cell-index", &idx); | ||
602 | if (ret) { | ||
603 | dev_err(&pdev->dev, | ||
604 | "cannot get CPU index property\n"); | ||
605 | goto asrc_fail; | ||
606 | } | ||
607 | |||
608 | priv->dai_link[0].codec_name = | ||
609 | devm_kasprintf(&pdev->dev, GFP_KERNEL, | ||
610 | "ac97-codec.%u", | ||
611 | (unsigned int)idx); | ||
612 | } | ||
613 | |||
537 | priv->dai_link[0].platform_of_node = cpu_np; | 614 | priv->dai_link[0].platform_of_node = cpu_np; |
538 | priv->dai_link[0].dai_fmt = priv->dai_fmt; | 615 | priv->dai_link[0].dai_fmt = priv->dai_fmt; |
539 | priv->card.num_links = 1; | 616 | priv->card.num_links = 1; |
@@ -544,6 +621,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) | |||
544 | priv->dai_link[1].platform_of_node = asrc_np; | 621 | priv->dai_link[1].platform_of_node = asrc_np; |
545 | priv->dai_link[2].codec_dai_name = codec_dai_name; | 622 | priv->dai_link[2].codec_dai_name = codec_dai_name; |
546 | priv->dai_link[2].codec_of_node = codec_np; | 623 | priv->dai_link[2].codec_of_node = codec_np; |
624 | priv->dai_link[2].codec_name = | ||
625 | priv->dai_link[0].codec_name; | ||
547 | priv->dai_link[2].cpu_of_node = cpu_np; | 626 | priv->dai_link[2].cpu_of_node = cpu_np; |
548 | priv->dai_link[2].dai_fmt = priv->dai_fmt; | 627 | priv->dai_link[2].dai_fmt = priv->dai_fmt; |
549 | priv->card.num_links = 3; | 628 | priv->card.num_links = 3; |
@@ -579,14 +658,15 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) | |||
579 | 658 | ||
580 | asrc_fail: | 659 | asrc_fail: |
581 | of_node_put(asrc_np); | 660 | of_node_put(asrc_np); |
582 | fail: | ||
583 | of_node_put(codec_np); | 661 | of_node_put(codec_np); |
662 | fail: | ||
584 | of_node_put(cpu_np); | 663 | of_node_put(cpu_np); |
585 | 664 | ||
586 | return ret; | 665 | return ret; |
587 | } | 666 | } |
588 | 667 | ||
589 | static const struct of_device_id fsl_asoc_card_dt_ids[] = { | 668 | static const struct of_device_id fsl_asoc_card_dt_ids[] = { |
669 | { .compatible = "fsl,imx-audio-ac97", }, | ||
590 | { .compatible = "fsl,imx-audio-cs42888", }, | 670 | { .compatible = "fsl,imx-audio-cs42888", }, |
591 | { .compatible = "fsl,imx-audio-sgtl5000", }, | 671 | { .compatible = "fsl,imx-audio-sgtl5000", }, |
592 | { .compatible = "fsl,imx-audio-wm8962", }, | 672 | { .compatible = "fsl,imx-audio-wm8962", }, |
diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index 837979ea5c92..59f234e51971 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c | |||
@@ -652,6 +652,24 @@ static const struct snd_soc_component_driver fsl_esai_component = { | |||
652 | .name = "fsl-esai", | 652 | .name = "fsl-esai", |
653 | }; | 653 | }; |
654 | 654 | ||
655 | static const struct reg_default fsl_esai_reg_defaults[] = { | ||
656 | {0x8, 0x00000000}, | ||
657 | {0x10, 0x00000000}, | ||
658 | {0x18, 0x00000000}, | ||
659 | {0x98, 0x00000000}, | ||
660 | {0xd0, 0x00000000}, | ||
661 | {0xd4, 0x00000000}, | ||
662 | {0xd8, 0x00000000}, | ||
663 | {0xdc, 0x00000000}, | ||
664 | {0xe0, 0x00000000}, | ||
665 | {0xe4, 0x0000ffff}, | ||
666 | {0xe8, 0x0000ffff}, | ||
667 | {0xec, 0x0000ffff}, | ||
668 | {0xf0, 0x0000ffff}, | ||
669 | {0xf8, 0x00000000}, | ||
670 | {0xfc, 0x00000000}, | ||
671 | }; | ||
672 | |||
655 | static bool fsl_esai_readable_reg(struct device *dev, unsigned int reg) | 673 | static bool fsl_esai_readable_reg(struct device *dev, unsigned int reg) |
656 | { | 674 | { |
657 | switch (reg) { | 675 | switch (reg) { |
@@ -684,6 +702,31 @@ static bool fsl_esai_readable_reg(struct device *dev, unsigned int reg) | |||
684 | } | 702 | } |
685 | } | 703 | } |
686 | 704 | ||
705 | static bool fsl_esai_volatile_reg(struct device *dev, unsigned int reg) | ||
706 | { | ||
707 | switch (reg) { | ||
708 | case REG_ESAI_ETDR: | ||
709 | case REG_ESAI_ERDR: | ||
710 | case REG_ESAI_ESR: | ||
711 | case REG_ESAI_TFSR: | ||
712 | case REG_ESAI_RFSR: | ||
713 | case REG_ESAI_TX0: | ||
714 | case REG_ESAI_TX1: | ||
715 | case REG_ESAI_TX2: | ||
716 | case REG_ESAI_TX3: | ||
717 | case REG_ESAI_TX4: | ||
718 | case REG_ESAI_TX5: | ||
719 | case REG_ESAI_RX0: | ||
720 | case REG_ESAI_RX1: | ||
721 | case REG_ESAI_RX2: | ||
722 | case REG_ESAI_RX3: | ||
723 | case REG_ESAI_SAISR: | ||
724 | return true; | ||
725 | default: | ||
726 | return false; | ||
727 | } | ||
728 | } | ||
729 | |||
687 | static bool fsl_esai_writeable_reg(struct device *dev, unsigned int reg) | 730 | static bool fsl_esai_writeable_reg(struct device *dev, unsigned int reg) |
688 | { | 731 | { |
689 | switch (reg) { | 732 | switch (reg) { |
@@ -721,8 +764,12 @@ static const struct regmap_config fsl_esai_regmap_config = { | |||
721 | .val_bits = 32, | 764 | .val_bits = 32, |
722 | 765 | ||
723 | .max_register = REG_ESAI_PCRC, | 766 | .max_register = REG_ESAI_PCRC, |
767 | .reg_defaults = fsl_esai_reg_defaults, | ||
768 | .num_reg_defaults = ARRAY_SIZE(fsl_esai_reg_defaults), | ||
724 | .readable_reg = fsl_esai_readable_reg, | 769 | .readable_reg = fsl_esai_readable_reg, |
770 | .volatile_reg = fsl_esai_volatile_reg, | ||
725 | .writeable_reg = fsl_esai_writeable_reg, | 771 | .writeable_reg = fsl_esai_writeable_reg, |
772 | .cache_type = REGCACHE_RBTREE, | ||
726 | }; | 773 | }; |
727 | 774 | ||
728 | static int fsl_esai_probe(struct platform_device *pdev) | 775 | static int fsl_esai_probe(struct platform_device *pdev) |
@@ -853,10 +900,51 @@ static const struct of_device_id fsl_esai_dt_ids[] = { | |||
853 | }; | 900 | }; |
854 | MODULE_DEVICE_TABLE(of, fsl_esai_dt_ids); | 901 | MODULE_DEVICE_TABLE(of, fsl_esai_dt_ids); |
855 | 902 | ||
903 | #ifdef CONFIG_PM_SLEEP | ||
904 | static int fsl_esai_suspend(struct device *dev) | ||
905 | { | ||
906 | struct fsl_esai *esai = dev_get_drvdata(dev); | ||
907 | |||
908 | regcache_cache_only(esai->regmap, true); | ||
909 | regcache_mark_dirty(esai->regmap); | ||
910 | |||
911 | return 0; | ||
912 | } | ||
913 | |||
914 | static int fsl_esai_resume(struct device *dev) | ||
915 | { | ||
916 | struct fsl_esai *esai = dev_get_drvdata(dev); | ||
917 | int ret; | ||
918 | |||
919 | regcache_cache_only(esai->regmap, false); | ||
920 | |||
921 | /* FIFO reset for safety */ | ||
922 | regmap_update_bits(esai->regmap, REG_ESAI_TFCR, | ||
923 | ESAI_xFCR_xFR, ESAI_xFCR_xFR); | ||
924 | regmap_update_bits(esai->regmap, REG_ESAI_RFCR, | ||
925 | ESAI_xFCR_xFR, ESAI_xFCR_xFR); | ||
926 | |||
927 | ret = regcache_sync(esai->regmap); | ||
928 | if (ret) | ||
929 | return ret; | ||
930 | |||
931 | /* FIFO reset done */ | ||
932 | regmap_update_bits(esai->regmap, REG_ESAI_TFCR, ESAI_xFCR_xFR, 0); | ||
933 | regmap_update_bits(esai->regmap, REG_ESAI_RFCR, ESAI_xFCR_xFR, 0); | ||
934 | |||
935 | return 0; | ||
936 | } | ||
937 | #endif /* CONFIG_PM_SLEEP */ | ||
938 | |||
939 | static const struct dev_pm_ops fsl_esai_pm_ops = { | ||
940 | SET_SYSTEM_SLEEP_PM_OPS(fsl_esai_suspend, fsl_esai_resume) | ||
941 | }; | ||
942 | |||
856 | static struct platform_driver fsl_esai_driver = { | 943 | static struct platform_driver fsl_esai_driver = { |
857 | .probe = fsl_esai_probe, | 944 | .probe = fsl_esai_probe, |
858 | .driver = { | 945 | .driver = { |
859 | .name = "fsl-esai-dai", | 946 | .name = "fsl-esai-dai", |
947 | .pm = &fsl_esai_pm_ops, | ||
860 | .of_match_table = fsl_esai_dt_ids, | 948 | .of_match_table = fsl_esai_dt_ids, |
861 | }, | 949 | }, |
862 | }; | 950 | }; |
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 9366b5a42e1d..a4435f5e3be9 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c | |||
@@ -27,13 +27,13 @@ | |||
27 | #define FSL_SAI_FLAGS (FSL_SAI_CSR_SEIE |\ | 27 | #define FSL_SAI_FLAGS (FSL_SAI_CSR_SEIE |\ |
28 | FSL_SAI_CSR_FEIE) | 28 | FSL_SAI_CSR_FEIE) |
29 | 29 | ||
30 | static u32 fsl_sai_rates[] = { | 30 | static const unsigned int fsl_sai_rates[] = { |
31 | 8000, 11025, 12000, 16000, 22050, | 31 | 8000, 11025, 12000, 16000, 22050, |
32 | 24000, 32000, 44100, 48000, 64000, | 32 | 24000, 32000, 44100, 48000, 64000, |
33 | 88200, 96000, 176400, 192000 | 33 | 88200, 96000, 176400, 192000 |
34 | }; | 34 | }; |
35 | 35 | ||
36 | static struct snd_pcm_hw_constraint_list fsl_sai_rate_constraints = { | 36 | static const struct snd_pcm_hw_constraint_list fsl_sai_rate_constraints = { |
37 | .count = ARRAY_SIZE(fsl_sai_rates), | 37 | .count = ARRAY_SIZE(fsl_sai_rates), |
38 | .list = fsl_sai_rates, | 38 | .list = fsl_sai_rates, |
39 | }; | 39 | }; |
@@ -637,6 +637,8 @@ static bool fsl_sai_readable_reg(struct device *dev, unsigned int reg) | |||
637 | static bool fsl_sai_volatile_reg(struct device *dev, unsigned int reg) | 637 | static bool fsl_sai_volatile_reg(struct device *dev, unsigned int reg) |
638 | { | 638 | { |
639 | switch (reg) { | 639 | switch (reg) { |
640 | case FSL_SAI_TCSR: | ||
641 | case FSL_SAI_RCSR: | ||
640 | case FSL_SAI_TFR: | 642 | case FSL_SAI_TFR: |
641 | case FSL_SAI_RFR: | 643 | case FSL_SAI_RFR: |
642 | case FSL_SAI_TDR: | 644 | case FSL_SAI_TDR: |
@@ -681,6 +683,7 @@ static const struct regmap_config fsl_sai_regmap_config = { | |||
681 | .readable_reg = fsl_sai_readable_reg, | 683 | .readable_reg = fsl_sai_readable_reg, |
682 | .volatile_reg = fsl_sai_volatile_reg, | 684 | .volatile_reg = fsl_sai_volatile_reg, |
683 | .writeable_reg = fsl_sai_writeable_reg, | 685 | .writeable_reg = fsl_sai_writeable_reg, |
686 | .cache_type = REGCACHE_FLAT, | ||
684 | }; | 687 | }; |
685 | 688 | ||
686 | static int fsl_sai_probe(struct platform_device *pdev) | 689 | static int fsl_sai_probe(struct platform_device *pdev) |
@@ -803,10 +806,40 @@ static const struct of_device_id fsl_sai_ids[] = { | |||
803 | }; | 806 | }; |
804 | MODULE_DEVICE_TABLE(of, fsl_sai_ids); | 807 | MODULE_DEVICE_TABLE(of, fsl_sai_ids); |
805 | 808 | ||
809 | #ifdef CONFIG_PM_SLEEP | ||
810 | static int fsl_sai_suspend(struct device *dev) | ||
811 | { | ||
812 | struct fsl_sai *sai = dev_get_drvdata(dev); | ||
813 | |||
814 | regcache_cache_only(sai->regmap, true); | ||
815 | regcache_mark_dirty(sai->regmap); | ||
816 | |||
817 | return 0; | ||
818 | } | ||
819 | |||
820 | static int fsl_sai_resume(struct device *dev) | ||
821 | { | ||
822 | struct fsl_sai *sai = dev_get_drvdata(dev); | ||
823 | |||
824 | regcache_cache_only(sai->regmap, false); | ||
825 | regmap_write(sai->regmap, FSL_SAI_TCSR, FSL_SAI_CSR_SR); | ||
826 | regmap_write(sai->regmap, FSL_SAI_RCSR, FSL_SAI_CSR_SR); | ||
827 | msleep(1); | ||
828 | regmap_write(sai->regmap, FSL_SAI_TCSR, 0); | ||
829 | regmap_write(sai->regmap, FSL_SAI_RCSR, 0); | ||
830 | return regcache_sync(sai->regmap); | ||
831 | } | ||
832 | #endif /* CONFIG_PM_SLEEP */ | ||
833 | |||
834 | static const struct dev_pm_ops fsl_sai_pm_ops = { | ||
835 | SET_SYSTEM_SLEEP_PM_OPS(fsl_sai_suspend, fsl_sai_resume) | ||
836 | }; | ||
837 | |||
806 | static struct platform_driver fsl_sai_driver = { | 838 | static struct platform_driver fsl_sai_driver = { |
807 | .probe = fsl_sai_probe, | 839 | .probe = fsl_sai_probe, |
808 | .driver = { | 840 | .driver = { |
809 | .name = "fsl-sai", | 841 | .name = "fsl-sai", |
842 | .pm = &fsl_sai_pm_ops, | ||
810 | .of_match_table = fsl_sai_ids, | 843 | .of_match_table = fsl_sai_ids, |
811 | }, | 844 | }, |
812 | }; | 845 | }; |
diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index ab729f2426fe..3d59bb6719f2 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c | |||
@@ -108,6 +108,8 @@ struct fsl_spdif_priv { | |||
108 | struct clk *sysclk; | 108 | struct clk *sysclk; |
109 | struct snd_dmaengine_dai_dma_data dma_params_tx; | 109 | struct snd_dmaengine_dai_dma_data dma_params_tx; |
110 | struct snd_dmaengine_dai_dma_data dma_params_rx; | 110 | struct snd_dmaengine_dai_dma_data dma_params_rx; |
111 | /* regcache for SRPC */ | ||
112 | u32 regcache_srpc; | ||
111 | }; | 113 | }; |
112 | 114 | ||
113 | /* DPLL locked and lock loss interrupt handler */ | 115 | /* DPLL locked and lock loss interrupt handler */ |
@@ -300,6 +302,8 @@ static int spdif_softreset(struct fsl_spdif_priv *spdif_priv) | |||
300 | struct regmap *regmap = spdif_priv->regmap; | 302 | struct regmap *regmap = spdif_priv->regmap; |
301 | u32 val, cycle = 1000; | 303 | u32 val, cycle = 1000; |
302 | 304 | ||
305 | regcache_cache_bypass(regmap, true); | ||
306 | |||
303 | regmap_write(regmap, REG_SPDIF_SCR, SCR_SOFT_RESET); | 307 | regmap_write(regmap, REG_SPDIF_SCR, SCR_SOFT_RESET); |
304 | 308 | ||
305 | /* | 309 | /* |
@@ -310,6 +314,10 @@ static int spdif_softreset(struct fsl_spdif_priv *spdif_priv) | |||
310 | regmap_read(regmap, REG_SPDIF_SCR, &val); | 314 | regmap_read(regmap, REG_SPDIF_SCR, &val); |
311 | } while ((val & SCR_SOFT_RESET) && cycle--); | 315 | } while ((val & SCR_SOFT_RESET) && cycle--); |
312 | 316 | ||
317 | regcache_cache_bypass(regmap, false); | ||
318 | regcache_mark_dirty(regmap); | ||
319 | regcache_sync(regmap); | ||
320 | |||
313 | if (cycle) | 321 | if (cycle) |
314 | return 0; | 322 | return 0; |
315 | else | 323 | else |
@@ -997,6 +1005,14 @@ static const struct snd_soc_component_driver fsl_spdif_component = { | |||
997 | }; | 1005 | }; |
998 | 1006 | ||
999 | /* FSL SPDIF REGMAP */ | 1007 | /* FSL SPDIF REGMAP */ |
1008 | static const struct reg_default fsl_spdif_reg_defaults[] = { | ||
1009 | {0x0, 0x00000400}, | ||
1010 | {0x4, 0x00000000}, | ||
1011 | {0xc, 0x00000000}, | ||
1012 | {0x34, 0x00000000}, | ||
1013 | {0x38, 0x00000000}, | ||
1014 | {0x50, 0x00020f00}, | ||
1015 | }; | ||
1000 | 1016 | ||
1001 | static bool fsl_spdif_readable_reg(struct device *dev, unsigned int reg) | 1017 | static bool fsl_spdif_readable_reg(struct device *dev, unsigned int reg) |
1002 | { | 1018 | { |
@@ -1022,6 +1038,26 @@ static bool fsl_spdif_readable_reg(struct device *dev, unsigned int reg) | |||
1022 | } | 1038 | } |
1023 | } | 1039 | } |
1024 | 1040 | ||
1041 | static bool fsl_spdif_volatile_reg(struct device *dev, unsigned int reg) | ||
1042 | { | ||
1043 | switch (reg) { | ||
1044 | case REG_SPDIF_SRPC: | ||
1045 | case REG_SPDIF_SIS: | ||
1046 | case REG_SPDIF_SRL: | ||
1047 | case REG_SPDIF_SRR: | ||
1048 | case REG_SPDIF_SRCSH: | ||
1049 | case REG_SPDIF_SRCSL: | ||
1050 | case REG_SPDIF_SRU: | ||
1051 | case REG_SPDIF_SRQ: | ||
1052 | case REG_SPDIF_STL: | ||
1053 | case REG_SPDIF_STR: | ||
1054 | case REG_SPDIF_SRFM: | ||
1055 | return true; | ||
1056 | default: | ||
1057 | return false; | ||
1058 | } | ||
1059 | } | ||
1060 | |||
1025 | static bool fsl_spdif_writeable_reg(struct device *dev, unsigned int reg) | 1061 | static bool fsl_spdif_writeable_reg(struct device *dev, unsigned int reg) |
1026 | { | 1062 | { |
1027 | switch (reg) { | 1063 | switch (reg) { |
@@ -1047,8 +1083,12 @@ static const struct regmap_config fsl_spdif_regmap_config = { | |||
1047 | .val_bits = 32, | 1083 | .val_bits = 32, |
1048 | 1084 | ||
1049 | .max_register = REG_SPDIF_STC, | 1085 | .max_register = REG_SPDIF_STC, |
1086 | .reg_defaults = fsl_spdif_reg_defaults, | ||
1087 | .num_reg_defaults = ARRAY_SIZE(fsl_spdif_reg_defaults), | ||
1050 | .readable_reg = fsl_spdif_readable_reg, | 1088 | .readable_reg = fsl_spdif_readable_reg, |
1089 | .volatile_reg = fsl_spdif_volatile_reg, | ||
1051 | .writeable_reg = fsl_spdif_writeable_reg, | 1090 | .writeable_reg = fsl_spdif_writeable_reg, |
1091 | .cache_type = REGCACHE_RBTREE, | ||
1052 | }; | 1092 | }; |
1053 | 1093 | ||
1054 | static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv, | 1094 | static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv, |
@@ -1271,6 +1311,38 @@ static int fsl_spdif_probe(struct platform_device *pdev) | |||
1271 | return ret; | 1311 | return ret; |
1272 | } | 1312 | } |
1273 | 1313 | ||
1314 | #ifdef CONFIG_PM_SLEEP | ||
1315 | static int fsl_spdif_suspend(struct device *dev) | ||
1316 | { | ||
1317 | struct fsl_spdif_priv *spdif_priv = dev_get_drvdata(dev); | ||
1318 | |||
1319 | regmap_read(spdif_priv->regmap, REG_SPDIF_SRPC, | ||
1320 | &spdif_priv->regcache_srpc); | ||
1321 | |||
1322 | regcache_cache_only(spdif_priv->regmap, true); | ||
1323 | regcache_mark_dirty(spdif_priv->regmap); | ||
1324 | |||
1325 | return 0; | ||
1326 | } | ||
1327 | |||
1328 | static int fsl_spdif_resume(struct device *dev) | ||
1329 | { | ||
1330 | struct fsl_spdif_priv *spdif_priv = dev_get_drvdata(dev); | ||
1331 | |||
1332 | regcache_cache_only(spdif_priv->regmap, false); | ||
1333 | |||
1334 | regmap_update_bits(spdif_priv->regmap, REG_SPDIF_SRPC, | ||
1335 | SRPC_CLKSRC_SEL_MASK | SRPC_GAINSEL_MASK, | ||
1336 | spdif_priv->regcache_srpc); | ||
1337 | |||
1338 | return regcache_sync(spdif_priv->regmap); | ||
1339 | } | ||
1340 | #endif /* CONFIG_PM_SLEEP */ | ||
1341 | |||
1342 | static const struct dev_pm_ops fsl_spdif_pm = { | ||
1343 | SET_SYSTEM_SLEEP_PM_OPS(fsl_spdif_suspend, fsl_spdif_resume) | ||
1344 | }; | ||
1345 | |||
1274 | static const struct of_device_id fsl_spdif_dt_ids[] = { | 1346 | static const struct of_device_id fsl_spdif_dt_ids[] = { |
1275 | { .compatible = "fsl,imx35-spdif", }, | 1347 | { .compatible = "fsl,imx35-spdif", }, |
1276 | { .compatible = "fsl,vf610-spdif", }, | 1348 | { .compatible = "fsl,vf610-spdif", }, |
@@ -1282,6 +1354,7 @@ static struct platform_driver fsl_spdif_driver = { | |||
1282 | .driver = { | 1354 | .driver = { |
1283 | .name = "fsl-spdif-dai", | 1355 | .name = "fsl-spdif-dai", |
1284 | .of_match_table = fsl_spdif_dt_ids, | 1356 | .of_match_table = fsl_spdif_dt_ids, |
1357 | .pm = &fsl_spdif_pm, | ||
1285 | }, | 1358 | }, |
1286 | .probe = fsl_spdif_probe, | 1359 | .probe = fsl_spdif_probe, |
1287 | }; | 1360 | }; |
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 37c5cd4d0e59..95d2392303eb 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c | |||
@@ -111,12 +111,75 @@ struct fsl_ssi_rxtx_reg_val { | |||
111 | struct fsl_ssi_reg_val rx; | 111 | struct fsl_ssi_reg_val rx; |
112 | struct fsl_ssi_reg_val tx; | 112 | struct fsl_ssi_reg_val tx; |
113 | }; | 113 | }; |
114 | |||
115 | static const struct reg_default fsl_ssi_reg_defaults[] = { | ||
116 | {0x10, 0x00000000}, | ||
117 | {0x18, 0x00003003}, | ||
118 | {0x1c, 0x00000200}, | ||
119 | {0x20, 0x00000200}, | ||
120 | {0x24, 0x00040000}, | ||
121 | {0x28, 0x00040000}, | ||
122 | {0x38, 0x00000000}, | ||
123 | {0x48, 0x00000000}, | ||
124 | {0x4c, 0x00000000}, | ||
125 | {0x54, 0x00000000}, | ||
126 | {0x58, 0x00000000}, | ||
127 | }; | ||
128 | |||
129 | static bool fsl_ssi_readable_reg(struct device *dev, unsigned int reg) | ||
130 | { | ||
131 | switch (reg) { | ||
132 | case CCSR_SSI_SACCEN: | ||
133 | case CCSR_SSI_SACCDIS: | ||
134 | return false; | ||
135 | default: | ||
136 | return true; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | static bool fsl_ssi_volatile_reg(struct device *dev, unsigned int reg) | ||
141 | { | ||
142 | switch (reg) { | ||
143 | case CCSR_SSI_STX0: | ||
144 | case CCSR_SSI_STX1: | ||
145 | case CCSR_SSI_SRX0: | ||
146 | case CCSR_SSI_SRX1: | ||
147 | case CCSR_SSI_SISR: | ||
148 | case CCSR_SSI_SFCSR: | ||
149 | case CCSR_SSI_SACADD: | ||
150 | case CCSR_SSI_SACDAT: | ||
151 | case CCSR_SSI_SATAG: | ||
152 | case CCSR_SSI_SACCST: | ||
153 | return true; | ||
154 | default: | ||
155 | return false; | ||
156 | } | ||
157 | } | ||
158 | |||
159 | static bool fsl_ssi_writeable_reg(struct device *dev, unsigned int reg) | ||
160 | { | ||
161 | switch (reg) { | ||
162 | case CCSR_SSI_SRX0: | ||
163 | case CCSR_SSI_SRX1: | ||
164 | case CCSR_SSI_SACCST: | ||
165 | return false; | ||
166 | default: | ||
167 | return true; | ||
168 | } | ||
169 | } | ||
170 | |||
114 | static const struct regmap_config fsl_ssi_regconfig = { | 171 | static const struct regmap_config fsl_ssi_regconfig = { |
115 | .max_register = CCSR_SSI_SACCDIS, | 172 | .max_register = CCSR_SSI_SACCDIS, |
116 | .reg_bits = 32, | 173 | .reg_bits = 32, |
117 | .val_bits = 32, | 174 | .val_bits = 32, |
118 | .reg_stride = 4, | 175 | .reg_stride = 4, |
119 | .val_format_endian = REGMAP_ENDIAN_NATIVE, | 176 | .val_format_endian = REGMAP_ENDIAN_NATIVE, |
177 | .reg_defaults = fsl_ssi_reg_defaults, | ||
178 | .num_reg_defaults = ARRAY_SIZE(fsl_ssi_reg_defaults), | ||
179 | .readable_reg = fsl_ssi_readable_reg, | ||
180 | .volatile_reg = fsl_ssi_volatile_reg, | ||
181 | .writeable_reg = fsl_ssi_writeable_reg, | ||
182 | .cache_type = REGCACHE_RBTREE, | ||
120 | }; | 183 | }; |
121 | 184 | ||
122 | struct fsl_ssi_soc_data { | 185 | struct fsl_ssi_soc_data { |
@@ -176,6 +239,9 @@ struct fsl_ssi_private { | |||
176 | unsigned int baudclk_streams; | 239 | unsigned int baudclk_streams; |
177 | unsigned int bitclk_freq; | 240 | unsigned int bitclk_freq; |
178 | 241 | ||
242 | /*regcache for SFCSR*/ | ||
243 | u32 regcache_sfcsr; | ||
244 | |||
179 | /* DMA params */ | 245 | /* DMA params */ |
180 | struct snd_dmaengine_dai_dma_data dma_params_tx; | 246 | struct snd_dmaengine_dai_dma_data dma_params_tx; |
181 | struct snd_dmaengine_dai_dma_data dma_params_rx; | 247 | struct snd_dmaengine_dai_dma_data dma_params_rx; |
@@ -1514,10 +1580,46 @@ static int fsl_ssi_remove(struct platform_device *pdev) | |||
1514 | return 0; | 1580 | return 0; |
1515 | } | 1581 | } |
1516 | 1582 | ||
1583 | #ifdef CONFIG_PM_SLEEP | ||
1584 | static int fsl_ssi_suspend(struct device *dev) | ||
1585 | { | ||
1586 | struct fsl_ssi_private *ssi_private = dev_get_drvdata(dev); | ||
1587 | struct regmap *regs = ssi_private->regs; | ||
1588 | |||
1589 | regmap_read(regs, CCSR_SSI_SFCSR, | ||
1590 | &ssi_private->regcache_sfcsr); | ||
1591 | |||
1592 | regcache_cache_only(regs, true); | ||
1593 | regcache_mark_dirty(regs); | ||
1594 | |||
1595 | return 0; | ||
1596 | } | ||
1597 | |||
1598 | static int fsl_ssi_resume(struct device *dev) | ||
1599 | { | ||
1600 | struct fsl_ssi_private *ssi_private = dev_get_drvdata(dev); | ||
1601 | struct regmap *regs = ssi_private->regs; | ||
1602 | |||
1603 | regcache_cache_only(regs, false); | ||
1604 | |||
1605 | regmap_update_bits(regs, CCSR_SSI_SFCSR, | ||
1606 | CCSR_SSI_SFCSR_RFWM1_MASK | CCSR_SSI_SFCSR_TFWM1_MASK | | ||
1607 | CCSR_SSI_SFCSR_RFWM0_MASK | CCSR_SSI_SFCSR_TFWM0_MASK, | ||
1608 | ssi_private->regcache_sfcsr); | ||
1609 | |||
1610 | return regcache_sync(regs); | ||
1611 | } | ||
1612 | #endif /* CONFIG_PM_SLEEP */ | ||
1613 | |||
1614 | static const struct dev_pm_ops fsl_ssi_pm = { | ||
1615 | SET_SYSTEM_SLEEP_PM_OPS(fsl_ssi_suspend, fsl_ssi_resume) | ||
1616 | }; | ||
1617 | |||
1517 | static struct platform_driver fsl_ssi_driver = { | 1618 | static struct platform_driver fsl_ssi_driver = { |
1518 | .driver = { | 1619 | .driver = { |
1519 | .name = "fsl-ssi-dai", | 1620 | .name = "fsl-ssi-dai", |
1520 | .of_match_table = fsl_ssi_ids, | 1621 | .of_match_table = fsl_ssi_ids, |
1622 | .pm = &fsl_ssi_pm, | ||
1521 | }, | 1623 | }, |
1522 | .probe = fsl_ssi_probe, | 1624 | .probe = fsl_ssi_probe, |
1523 | .remove = fsl_ssi_remove, | 1625 | .remove = fsl_ssi_remove, |
diff --git a/sound/soc/fsl/imx-spdif.c b/sound/soc/fsl/imx-spdif.c index 33da26a12457..a407e833c612 100644 --- a/sound/soc/fsl/imx-spdif.c +++ b/sound/soc/fsl/imx-spdif.c | |||
@@ -89,6 +89,7 @@ MODULE_DEVICE_TABLE(of, imx_spdif_dt_ids); | |||
89 | static struct platform_driver imx_spdif_driver = { | 89 | static struct platform_driver imx_spdif_driver = { |
90 | .driver = { | 90 | .driver = { |
91 | .name = "imx-spdif", | 91 | .name = "imx-spdif", |
92 | .pm = &snd_soc_pm_ops, | ||
92 | .of_match_table = imx_spdif_dt_ids, | 93 | .of_match_table = imx_spdif_dt_ids, |
93 | }, | 94 | }, |
94 | .probe = imx_spdif_audio_probe, | 95 | .probe = imx_spdif_audio_probe, |
diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig index 05fde5e6e257..7b778ab85f8b 100644 --- a/sound/soc/intel/Kconfig +++ b/sound/soc/intel/Kconfig | |||
@@ -12,6 +12,7 @@ config SND_MFLD_MACHINE | |||
12 | 12 | ||
13 | config SND_SST_MFLD_PLATFORM | 13 | config SND_SST_MFLD_PLATFORM |
14 | tristate | 14 | tristate |
15 | select SND_SOC_COMPRESS | ||
15 | 16 | ||
16 | config SND_SST_IPC | 17 | config SND_SST_IPC |
17 | tristate | 18 | tristate |
@@ -138,4 +139,18 @@ config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH | |||
138 | config SND_SOC_INTEL_SKYLAKE | 139 | config SND_SOC_INTEL_SKYLAKE |
139 | tristate | 140 | tristate |
140 | select SND_HDA_EXT_CORE | 141 | select SND_HDA_EXT_CORE |
142 | select SND_SOC_TOPOLOGY | ||
141 | select SND_SOC_INTEL_SST | 143 | select SND_SOC_INTEL_SST |
144 | |||
145 | config SND_SOC_INTEL_SKL_RT286_MACH | ||
146 | tristate "ASoC Audio driver for SKL with RT286 I2S mode" | ||
147 | depends on X86 && ACPI | ||
148 | select SND_SOC_INTEL_SST | ||
149 | select SND_SOC_INTEL_SKYLAKE | ||
150 | select SND_SOC_RT286 | ||
151 | select SND_SOC_DMIC | ||
152 | help | ||
153 | This adds support for ASoC machine driver for Skylake platforms | ||
154 | with RT286 I2S audio codec. | ||
155 | Say Y if you have such a device | ||
156 | If unsure select "N". | ||
diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 5e9c316c142a..0487cfaac538 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c | |||
@@ -512,7 +512,7 @@ static struct snd_soc_dai_driver sst_platform_dai[] = { | |||
512 | }, | 512 | }, |
513 | { | 513 | { |
514 | .name = "compress-cpu-dai", | 514 | .name = "compress-cpu-dai", |
515 | .compress_dai = 1, | 515 | .compress_new = snd_soc_new_compress, |
516 | .ops = &sst_compr_dai_ops, | 516 | .ops = &sst_compr_dai_ops, |
517 | .playback = { | 517 | .playback = { |
518 | .stream_name = "Compress Playback", | 518 | .stream_name = "Compress Playback", |
diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index cb94895c9edb..371c4565cad8 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile | |||
@@ -6,6 +6,7 @@ snd-soc-sst-bytcr-rt5640-objs := bytcr_rt5640.o | |||
6 | snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o | 6 | snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o |
7 | snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o | 7 | snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o |
8 | snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o | 8 | snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o |
9 | snd-soc-skl_rt286-objs := skl_rt286.o | ||
9 | 10 | ||
10 | obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o | 11 | obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o |
11 | obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o | 12 | obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o |
@@ -15,3 +16,4 @@ obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o | |||
15 | obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o | 16 | obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o |
16 | obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o | 17 | obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o |
17 | obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max98090_ti.o | 18 | obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max98090_ti.o |
19 | obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o | ||
diff --git a/sound/soc/intel/boards/skl_rt286.c b/sound/soc/intel/boards/skl_rt286.c new file mode 100644 index 000000000000..a73a431bd8b7 --- /dev/null +++ b/sound/soc/intel/boards/skl_rt286.c | |||
@@ -0,0 +1,259 @@ | |||
1 | /* | ||
2 | * Intel Skylake I2S Machine Driver | ||
3 | * | ||
4 | * Copyright (C) 2014-2015, Intel Corporation. All rights reserved. | ||
5 | * | ||
6 | * Modified from: | ||
7 | * Intel Broadwell Wildcatpoint SST Audio | ||
8 | * | ||
9 | * Copyright (C) 2013, Intel Corporation. All rights reserved. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License version | ||
13 | * 2 as published by the Free Software Foundation. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | */ | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <sound/core.h> | ||
24 | #include <sound/pcm.h> | ||
25 | #include <sound/soc.h> | ||
26 | #include <sound/jack.h> | ||
27 | #include <sound/pcm_params.h> | ||
28 | #include "../../codecs/rt286.h" | ||
29 | |||
30 | static struct snd_soc_jack skylake_headset; | ||
31 | /* Headset jack detection DAPM pins */ | ||
32 | static struct snd_soc_jack_pin skylake_headset_pins[] = { | ||
33 | { | ||
34 | .pin = "Mic Jack", | ||
35 | .mask = SND_JACK_MICROPHONE, | ||
36 | }, | ||
37 | { | ||
38 | .pin = "Headphone Jack", | ||
39 | .mask = SND_JACK_HEADPHONE, | ||
40 | }, | ||
41 | }; | ||
42 | |||
43 | static const struct snd_kcontrol_new skylake_controls[] = { | ||
44 | SOC_DAPM_PIN_SWITCH("Speaker"), | ||
45 | SOC_DAPM_PIN_SWITCH("Headphone Jack"), | ||
46 | SOC_DAPM_PIN_SWITCH("Mic Jack"), | ||
47 | }; | ||
48 | |||
49 | static const struct snd_soc_dapm_widget skylake_widgets[] = { | ||
50 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | ||
51 | SND_SOC_DAPM_SPK("Speaker", NULL), | ||
52 | SND_SOC_DAPM_MIC("Mic Jack", NULL), | ||
53 | SND_SOC_DAPM_MIC("DMIC2", NULL), | ||
54 | SND_SOC_DAPM_MIC("SoC DMIC", NULL), | ||
55 | }; | ||
56 | |||
57 | static const struct snd_soc_dapm_route skylake_rt286_map[] = { | ||
58 | /* speaker */ | ||
59 | {"Speaker", NULL, "SPOR"}, | ||
60 | {"Speaker", NULL, "SPOL"}, | ||
61 | |||
62 | /* HP jack connectors - unknown if we have jack deteck */ | ||
63 | {"Headphone Jack", NULL, "HPO Pin"}, | ||
64 | |||
65 | /* other jacks */ | ||
66 | {"MIC1", NULL, "Mic Jack"}, | ||
67 | |||
68 | /* digital mics */ | ||
69 | {"DMIC1 Pin", NULL, "DMIC2"}, | ||
70 | {"DMIC AIF", NULL, "SoC DMIC"}, | ||
71 | |||
72 | /* CODEC BE connections */ | ||
73 | { "AIF1 Playback", NULL, "ssp0 Tx"}, | ||
74 | { "ssp0 Tx", NULL, "codec0_out"}, | ||
75 | { "ssp0 Tx", NULL, "codec1_out"}, | ||
76 | |||
77 | { "codec0_in", NULL, "ssp0 Rx" }, | ||
78 | { "codec1_in", NULL, "ssp0 Rx" }, | ||
79 | { "ssp0 Rx", NULL, "AIF1 Capture" }, | ||
80 | |||
81 | { "dmic01_hifi", NULL, "DMIC01 Rx" }, | ||
82 | { "DMIC01 Rx", NULL, "Capture" }, | ||
83 | |||
84 | { "hif1", NULL, "iDisp Tx"}, | ||
85 | { "iDisp Tx", NULL, "iDisp_out"}, | ||
86 | |||
87 | }; | ||
88 | |||
89 | static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) | ||
90 | { | ||
91 | struct snd_soc_codec *codec = rtd->codec; | ||
92 | int ret; | ||
93 | |||
94 | ret = snd_soc_card_jack_new(rtd->card, "Headset", | ||
95 | SND_JACK_HEADSET | SND_JACK_BTN_0, | ||
96 | &skylake_headset, | ||
97 | skylake_headset_pins, ARRAY_SIZE(skylake_headset_pins)); | ||
98 | |||
99 | if (ret) | ||
100 | return ret; | ||
101 | |||
102 | rt286_mic_detect(codec, &skylake_headset); | ||
103 | |||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | |||
108 | static int skylake_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, | ||
109 | struct snd_pcm_hw_params *params) | ||
110 | { | ||
111 | struct snd_interval *rate = hw_param_interval(params, | ||
112 | SNDRV_PCM_HW_PARAM_RATE); | ||
113 | struct snd_interval *channels = hw_param_interval(params, | ||
114 | SNDRV_PCM_HW_PARAM_CHANNELS); | ||
115 | |||
116 | /* The output is 48KHz, stereo, 16bits */ | ||
117 | rate->min = rate->max = 48000; | ||
118 | channels->min = channels->max = 2; | ||
119 | params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static int skylake_rt286_hw_params(struct snd_pcm_substream *substream, | ||
125 | struct snd_pcm_hw_params *params) | ||
126 | { | ||
127 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
128 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
129 | int ret; | ||
130 | |||
131 | ret = snd_soc_dai_set_sysclk(codec_dai, RT286_SCLK_S_PLL, 24000000, | ||
132 | SND_SOC_CLOCK_IN); | ||
133 | if (ret < 0) | ||
134 | dev_err(rtd->dev, "set codec sysclk failed: %d\n", ret); | ||
135 | |||
136 | return ret; | ||
137 | } | ||
138 | |||
139 | static struct snd_soc_ops skylake_rt286_ops = { | ||
140 | .hw_params = skylake_rt286_hw_params, | ||
141 | }; | ||
142 | |||
143 | /* skylake digital audio interface glue - connects codec <--> CPU */ | ||
144 | static struct snd_soc_dai_link skylake_rt286_dais[] = { | ||
145 | /* Front End DAI links */ | ||
146 | { | ||
147 | .name = "Skl Audio Port", | ||
148 | .stream_name = "Audio", | ||
149 | .cpu_dai_name = "System Pin", | ||
150 | .platform_name = "0000:00:1f.3", | ||
151 | .nonatomic = 1, | ||
152 | .dynamic = 1, | ||
153 | .codec_name = "snd-soc-dummy", | ||
154 | .codec_dai_name = "snd-soc-dummy-dai", | ||
155 | .trigger = { | ||
156 | SND_SOC_DPCM_TRIGGER_POST, | ||
157 | SND_SOC_DPCM_TRIGGER_POST | ||
158 | }, | ||
159 | .dpcm_playback = 1, | ||
160 | }, | ||
161 | { | ||
162 | .name = "Skl Audio Capture Port", | ||
163 | .stream_name = "Audio Record", | ||
164 | .cpu_dai_name = "System Pin", | ||
165 | .platform_name = "0000:00:1f.3", | ||
166 | .nonatomic = 1, | ||
167 | .dynamic = 1, | ||
168 | .codec_name = "snd-soc-dummy", | ||
169 | .codec_dai_name = "snd-soc-dummy-dai", | ||
170 | .trigger = { | ||
171 | SND_SOC_DPCM_TRIGGER_POST, | ||
172 | SND_SOC_DPCM_TRIGGER_POST | ||
173 | }, | ||
174 | .dpcm_capture = 1, | ||
175 | }, | ||
176 | { | ||
177 | .name = "Skl Audio Reference cap", | ||
178 | .stream_name = "refcap", | ||
179 | .cpu_dai_name = "Reference Pin", | ||
180 | .codec_name = "snd-soc-dummy", | ||
181 | .codec_dai_name = "snd-soc-dummy-dai", | ||
182 | .platform_name = "0000:00:1f.3", | ||
183 | .init = NULL, | ||
184 | .dpcm_capture = 1, | ||
185 | .ignore_suspend = 1, | ||
186 | .nonatomic = 1, | ||
187 | .dynamic = 1, | ||
188 | }, | ||
189 | |||
190 | /* Back End DAI links */ | ||
191 | { | ||
192 | /* SSP0 - Codec */ | ||
193 | .name = "SSP0-Codec", | ||
194 | .be_id = 0, | ||
195 | .cpu_dai_name = "SSP0 Pin", | ||
196 | .platform_name = "0000:00:1f.3", | ||
197 | .no_pcm = 1, | ||
198 | .codec_name = "i2c-INT343A:00", | ||
199 | .codec_dai_name = "rt286-aif1", | ||
200 | .init = skylake_rt286_codec_init, | ||
201 | .dai_fmt = SND_SOC_DAIFMT_I2S | | ||
202 | SND_SOC_DAIFMT_NB_NF | | ||
203 | SND_SOC_DAIFMT_CBS_CFS, | ||
204 | .ignore_suspend = 1, | ||
205 | .ignore_pmdown_time = 1, | ||
206 | .be_hw_params_fixup = skylake_ssp0_fixup, | ||
207 | .ops = &skylake_rt286_ops, | ||
208 | .dpcm_playback = 1, | ||
209 | .dpcm_capture = 1, | ||
210 | }, | ||
211 | { | ||
212 | .name = "dmic01", | ||
213 | .be_id = 1, | ||
214 | .cpu_dai_name = "DMIC01 Pin", | ||
215 | .codec_name = "dmic-codec", | ||
216 | .codec_dai_name = "dmic-hifi", | ||
217 | .platform_name = "0000:00:1f.3", | ||
218 | .ignore_suspend = 1, | ||
219 | .dpcm_capture = 1, | ||
220 | .no_pcm = 1, | ||
221 | }, | ||
222 | }; | ||
223 | |||
224 | /* skylake audio machine driver for SPT + RT286S */ | ||
225 | static struct snd_soc_card skylake_rt286 = { | ||
226 | .name = "skylake-rt286", | ||
227 | .owner = THIS_MODULE, | ||
228 | .dai_link = skylake_rt286_dais, | ||
229 | .num_links = ARRAY_SIZE(skylake_rt286_dais), | ||
230 | .controls = skylake_controls, | ||
231 | .num_controls = ARRAY_SIZE(skylake_controls), | ||
232 | .dapm_widgets = skylake_widgets, | ||
233 | .num_dapm_widgets = ARRAY_SIZE(skylake_widgets), | ||
234 | .dapm_routes = skylake_rt286_map, | ||
235 | .num_dapm_routes = ARRAY_SIZE(skylake_rt286_map), | ||
236 | .fully_routed = true, | ||
237 | }; | ||
238 | |||
239 | static int skylake_audio_probe(struct platform_device *pdev) | ||
240 | { | ||
241 | skylake_rt286.dev = &pdev->dev; | ||
242 | |||
243 | return devm_snd_soc_register_card(&pdev->dev, &skylake_rt286); | ||
244 | } | ||
245 | |||
246 | static struct platform_driver skylake_audio = { | ||
247 | .probe = skylake_audio_probe, | ||
248 | .driver = { | ||
249 | .name = "skl_alc286s_i2s", | ||
250 | }, | ||
251 | }; | ||
252 | |||
253 | module_platform_driver(skylake_audio) | ||
254 | |||
255 | /* Module information */ | ||
256 | MODULE_AUTHOR("Omair Mohammed Abdullah <omair.m.abdullah@intel.com>"); | ||
257 | MODULE_DESCRIPTION("Intel SST Audio for Skylake"); | ||
258 | MODULE_LICENSE("GPL v2"); | ||
259 | MODULE_ALIAS("platform:skl_alc286s_i2s"); | ||
diff --git a/sound/soc/intel/common/Makefile b/sound/soc/intel/common/Makefile index f24154ca4e98..d9105584c51f 100644 --- a/sound/soc/intel/common/Makefile +++ b/sound/soc/intel/common/Makefile | |||
@@ -1,7 +1,11 @@ | |||
1 | snd-soc-sst-dsp-objs := sst-dsp.o sst-firmware.o | 1 | snd-soc-sst-dsp-objs := sst-dsp.o |
2 | snd-soc-sst-acpi-objs := sst-acpi.o | 2 | snd-soc-sst-acpi-objs := sst-acpi.o |
3 | snd-soc-sst-ipc-objs := sst-ipc.o | 3 | snd-soc-sst-ipc-objs := sst-ipc.o |
4 | 4 | ||
5 | ifneq ($(CONFIG_DW_DMAC_CORE),) | ||
6 | snd-soc-sst-dsp-objs += sst-firmware.o | ||
7 | endif | ||
8 | |||
5 | obj-$(CONFIG_SND_SOC_INTEL_SST) += snd-soc-sst-dsp.o snd-soc-sst-ipc.o | 9 | obj-$(CONFIG_SND_SOC_INTEL_SST) += snd-soc-sst-dsp.o snd-soc-sst-ipc.o |
6 | obj-$(CONFIG_SND_SOC_INTEL_SST_ACPI) += snd-soc-sst-acpi.o | 10 | obj-$(CONFIG_SND_SOC_INTEL_SST_ACPI) += snd-soc-sst-acpi.o |
7 | 11 | ||
diff --git a/sound/soc/intel/common/sst-dsp-priv.h b/sound/soc/intel/common/sst-dsp-priv.h index cbd568eac033..2151652d37b7 100644 --- a/sound/soc/intel/common/sst-dsp-priv.h +++ b/sound/soc/intel/common/sst-dsp-priv.h | |||
@@ -314,6 +314,7 @@ struct sst_dsp { | |||
314 | int sst_state; | 314 | int sst_state; |
315 | struct skl_cl_dev cl_dev; | 315 | struct skl_cl_dev cl_dev; |
316 | u32 intr_status; | 316 | u32 intr_status; |
317 | const struct firmware *fw; | ||
317 | }; | 318 | }; |
318 | 319 | ||
319 | /* Size optimised DRAM/IRAM memcpy */ | 320 | /* Size optimised DRAM/IRAM memcpy */ |
diff --git a/sound/soc/intel/common/sst-dsp.c b/sound/soc/intel/common/sst-dsp.c index a627236dd1f5..c9452e02e0dd 100644 --- a/sound/soc/intel/common/sst-dsp.c +++ b/sound/soc/intel/common/sst-dsp.c | |||
@@ -420,6 +420,7 @@ void sst_dsp_inbox_read(struct sst_dsp *sst, void *message, size_t bytes) | |||
420 | } | 420 | } |
421 | EXPORT_SYMBOL_GPL(sst_dsp_inbox_read); | 421 | EXPORT_SYMBOL_GPL(sst_dsp_inbox_read); |
422 | 422 | ||
423 | #if IS_ENABLED(CONFIG_DW_DMAC_CORE) | ||
423 | struct sst_dsp *sst_dsp_new(struct device *dev, | 424 | struct sst_dsp *sst_dsp_new(struct device *dev, |
424 | struct sst_dsp_device *sst_dev, struct sst_pdata *pdata) | 425 | struct sst_dsp_device *sst_dev, struct sst_pdata *pdata) |
425 | { | 426 | { |
@@ -484,6 +485,7 @@ void sst_dsp_free(struct sst_dsp *sst) | |||
484 | sst_dma_free(sst->dma); | 485 | sst_dma_free(sst->dma); |
485 | } | 486 | } |
486 | EXPORT_SYMBOL_GPL(sst_dsp_free); | 487 | EXPORT_SYMBOL_GPL(sst_dsp_free); |
488 | #endif | ||
487 | 489 | ||
488 | /* Module information */ | 490 | /* Module information */ |
489 | MODULE_AUTHOR("Liam Girdwood"); | 491 | MODULE_AUTHOR("Liam Girdwood"); |
diff --git a/sound/soc/intel/common/sst-dsp.h b/sound/soc/intel/common/sst-dsp.h index 1f45f18715c0..859f0de00339 100644 --- a/sound/soc/intel/common/sst-dsp.h +++ b/sound/soc/intel/common/sst-dsp.h | |||
@@ -216,10 +216,12 @@ struct sst_pdata { | |||
216 | void *dsp; | 216 | void *dsp; |
217 | }; | 217 | }; |
218 | 218 | ||
219 | #if IS_ENABLED(CONFIG_DW_DMAC_CORE) | ||
219 | /* Initialization */ | 220 | /* Initialization */ |
220 | struct sst_dsp *sst_dsp_new(struct device *dev, | 221 | struct sst_dsp *sst_dsp_new(struct device *dev, |
221 | struct sst_dsp_device *sst_dev, struct sst_pdata *pdata); | 222 | struct sst_dsp_device *sst_dev, struct sst_pdata *pdata); |
222 | void sst_dsp_free(struct sst_dsp *sst); | 223 | void sst_dsp_free(struct sst_dsp *sst); |
224 | #endif | ||
223 | 225 | ||
224 | /* SHIM Read / Write */ | 226 | /* SHIM Read / Write */ |
225 | void sst_dsp_shim_write(struct sst_dsp *sst, u32 offset, u32 value); | 227 | void sst_dsp_shim_write(struct sst_dsp *sst, u32 offset, u32 value); |
diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c index ebcca6dc48d1..1636a1eeb002 100644 --- a/sound/soc/intel/common/sst-firmware.c +++ b/sound/soc/intel/common/sst-firmware.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/acpi.h> | 26 | #include <linux/acpi.h> |
27 | 27 | ||
28 | /* supported DMA engine drivers */ | 28 | /* supported DMA engine drivers */ |
29 | #include <linux/platform_data/dma-dw.h> | ||
30 | #include <linux/dma/dw.h> | 29 | #include <linux/dma/dw.h> |
31 | 30 | ||
32 | #include <asm/page.h> | 31 | #include <asm/page.h> |
@@ -169,12 +168,6 @@ err: | |||
169 | return ret; | 168 | return ret; |
170 | } | 169 | } |
171 | 170 | ||
172 | static struct dw_dma_platform_data dw_pdata = { | ||
173 | .is_private = 1, | ||
174 | .chan_allocation_order = CHAN_ALLOCATION_ASCENDING, | ||
175 | .chan_priority = CHAN_PRIORITY_ASCENDING, | ||
176 | }; | ||
177 | |||
178 | static struct dw_dma_chip *dw_probe(struct device *dev, struct resource *mem, | 171 | static struct dw_dma_chip *dw_probe(struct device *dev, struct resource *mem, |
179 | int irq) | 172 | int irq) |
180 | { | 173 | { |
@@ -195,7 +188,8 @@ static struct dw_dma_chip *dw_probe(struct device *dev, struct resource *mem, | |||
195 | return ERR_PTR(err); | 188 | return ERR_PTR(err); |
196 | 189 | ||
197 | chip->dev = dev; | 190 | chip->dev = dev; |
198 | err = dw_dma_probe(chip, &dw_pdata); | 191 | |
192 | err = dw_dma_probe(chip, NULL); | ||
199 | if (err) | 193 | if (err) |
200 | return ERR_PTR(err); | 194 | return ERR_PTR(err); |
201 | 195 | ||
diff --git a/sound/soc/intel/skylake/Makefile b/sound/soc/intel/skylake/Makefile index 27db22178204..914b6dab9bea 100644 --- a/sound/soc/intel/skylake/Makefile +++ b/sound/soc/intel/skylake/Makefile | |||
@@ -1,4 +1,5 @@ | |||
1 | snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o | 1 | snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o \ |
2 | skl-topology.o | ||
2 | 3 | ||
3 | obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o | 4 | obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o |
4 | 5 | ||
diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index 826d4fd8930a..50a109503a3f 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c | |||
@@ -54,6 +54,24 @@ static int skl_free_dma_buf(struct device *dev, struct snd_dma_buffer *dmab) | |||
54 | return 0; | 54 | return 0; |
55 | } | 55 | } |
56 | 56 | ||
57 | #define NOTIFICATION_PARAM_ID 3 | ||
58 | #define NOTIFICATION_MASK 0xf | ||
59 | |||
60 | /* disable notfication for underruns/overruns from firmware module */ | ||
61 | static void skl_dsp_enable_notification(struct skl_sst *ctx, bool enable) | ||
62 | { | ||
63 | struct notification_mask mask; | ||
64 | struct skl_ipc_large_config_msg msg = {0}; | ||
65 | |||
66 | mask.notify = NOTIFICATION_MASK; | ||
67 | mask.enable = enable; | ||
68 | |||
69 | msg.large_param_id = NOTIFICATION_PARAM_ID; | ||
70 | msg.param_data_size = sizeof(mask); | ||
71 | |||
72 | skl_ipc_set_large_config(&ctx->ipc, &msg, (u32 *)&mask); | ||
73 | } | ||
74 | |||
57 | int skl_init_dsp(struct skl *skl) | 75 | int skl_init_dsp(struct skl *skl) |
58 | { | 76 | { |
59 | void __iomem *mmio_base; | 77 | void __iomem *mmio_base; |
@@ -79,7 +97,10 @@ int skl_init_dsp(struct skl *skl) | |||
79 | 97 | ||
80 | ret = skl_sst_dsp_init(bus->dev, mmio_base, irq, | 98 | ret = skl_sst_dsp_init(bus->dev, mmio_base, irq, |
81 | loader_ops, &skl->skl_sst); | 99 | loader_ops, &skl->skl_sst); |
100 | if (ret < 0) | ||
101 | return ret; | ||
82 | 102 | ||
103 | skl_dsp_enable_notification(skl->skl_sst, false); | ||
83 | dev_dbg(bus->dev, "dsp registration status=%d\n", ret); | 104 | dev_dbg(bus->dev, "dsp registration status=%d\n", ret); |
84 | 105 | ||
85 | return ret; | 106 | return ret; |
@@ -122,6 +143,7 @@ int skl_suspend_dsp(struct skl *skl) | |||
122 | int skl_resume_dsp(struct skl *skl) | 143 | int skl_resume_dsp(struct skl *skl) |
123 | { | 144 | { |
124 | struct skl_sst *ctx = skl->skl_sst; | 145 | struct skl_sst *ctx = skl->skl_sst; |
146 | int ret; | ||
125 | 147 | ||
126 | /* if ppcap is not supported return 0 */ | 148 | /* if ppcap is not supported return 0 */ |
127 | if (!skl->ebus.ppcap) | 149 | if (!skl->ebus.ppcap) |
@@ -131,7 +153,12 @@ int skl_resume_dsp(struct skl *skl) | |||
131 | snd_hdac_ext_bus_ppcap_enable(&skl->ebus, true); | 153 | snd_hdac_ext_bus_ppcap_enable(&skl->ebus, true); |
132 | snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, true); | 154 | snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, true); |
133 | 155 | ||
134 | return skl_dsp_wake(ctx->dsp); | 156 | ret = skl_dsp_wake(ctx->dsp); |
157 | if (ret < 0) | ||
158 | return ret; | ||
159 | |||
160 | skl_dsp_enable_notification(skl->skl_sst, false); | ||
161 | return ret; | ||
135 | } | 162 | } |
136 | 163 | ||
137 | enum skl_bitdepth skl_get_bit_depth(int params) | 164 | enum skl_bitdepth skl_get_bit_depth(int params) |
@@ -294,6 +321,7 @@ static void skl_copy_copier_caps(struct skl_module_cfg *mconfig, | |||
294 | (mconfig->formats_config.caps_size) / 4; | 321 | (mconfig->formats_config.caps_size) / 4; |
295 | } | 322 | } |
296 | 323 | ||
324 | #define SKL_NON_GATEWAY_CPR_NODE_ID 0xFFFFFFFF | ||
297 | /* | 325 | /* |
298 | * Calculate the gatewat settings required for copier module, type of | 326 | * Calculate the gatewat settings required for copier module, type of |
299 | * gateway and index of gateway to use | 327 | * gateway and index of gateway to use |
@@ -303,6 +331,7 @@ static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx, | |||
303 | struct skl_cpr_cfg *cpr_mconfig) | 331 | struct skl_cpr_cfg *cpr_mconfig) |
304 | { | 332 | { |
305 | union skl_connector_node_id node_id = {0}; | 333 | union skl_connector_node_id node_id = {0}; |
334 | union skl_ssp_dma_node ssp_node = {0}; | ||
306 | struct skl_pipe_params *params = mconfig->pipe->p_params; | 335 | struct skl_pipe_params *params = mconfig->pipe->p_params; |
307 | 336 | ||
308 | switch (mconfig->dev_type) { | 337 | switch (mconfig->dev_type) { |
@@ -320,9 +349,9 @@ static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx, | |||
320 | (SKL_CONN_SOURCE == mconfig->hw_conn_type) ? | 349 | (SKL_CONN_SOURCE == mconfig->hw_conn_type) ? |
321 | SKL_DMA_I2S_LINK_OUTPUT_CLASS : | 350 | SKL_DMA_I2S_LINK_OUTPUT_CLASS : |
322 | SKL_DMA_I2S_LINK_INPUT_CLASS; | 351 | SKL_DMA_I2S_LINK_INPUT_CLASS; |
323 | node_id.node.vindex = params->host_dma_id + | 352 | ssp_node.dma_node.time_slot_index = mconfig->time_slot; |
324 | (mconfig->time_slot << 1) + | 353 | ssp_node.dma_node.i2s_instance = mconfig->vbus_id; |
325 | (mconfig->vbus_id << 3); | 354 | node_id.node.vindex = ssp_node.val; |
326 | break; | 355 | break; |
327 | 356 | ||
328 | case SKL_DEVICE_DMIC: | 357 | case SKL_DEVICE_DMIC: |
@@ -339,13 +368,18 @@ static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx, | |||
339 | node_id.node.vindex = params->link_dma_id; | 368 | node_id.node.vindex = params->link_dma_id; |
340 | break; | 369 | break; |
341 | 370 | ||
342 | default: | 371 | case SKL_DEVICE_HDAHOST: |
343 | node_id.node.dma_type = | 372 | node_id.node.dma_type = |
344 | (SKL_CONN_SOURCE == mconfig->hw_conn_type) ? | 373 | (SKL_CONN_SOURCE == mconfig->hw_conn_type) ? |
345 | SKL_DMA_HDA_HOST_OUTPUT_CLASS : | 374 | SKL_DMA_HDA_HOST_OUTPUT_CLASS : |
346 | SKL_DMA_HDA_HOST_INPUT_CLASS; | 375 | SKL_DMA_HDA_HOST_INPUT_CLASS; |
347 | node_id.node.vindex = params->host_dma_id; | 376 | node_id.node.vindex = params->host_dma_id; |
348 | break; | 377 | break; |
378 | |||
379 | default: | ||
380 | cpr_mconfig->gtw_cfg.node_id = SKL_NON_GATEWAY_CPR_NODE_ID; | ||
381 | cpr_mconfig->cpr_feature_mask = 0; | ||
382 | return; | ||
349 | } | 383 | } |
350 | 384 | ||
351 | cpr_mconfig->gtw_cfg.node_id = node_id.val; | 385 | cpr_mconfig->gtw_cfg.node_id = node_id.val; |
diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c index 13036b19d7e5..b0c7bd113aac 100644 --- a/sound/soc/intel/skylake/skl-nhlt.c +++ b/sound/soc/intel/skylake/skl-nhlt.c | |||
@@ -25,7 +25,7 @@ static u8 OSC_UUID[16] = {0x6E, 0x88, 0x9F, 0xA6, 0xEB, 0x6C, 0x94, 0x45, | |||
25 | 25 | ||
26 | #define DSDT_NHLT_PATH "\\_SB.PCI0.HDAS" | 26 | #define DSDT_NHLT_PATH "\\_SB.PCI0.HDAS" |
27 | 27 | ||
28 | void __iomem *skl_nhlt_init(struct device *dev) | 28 | void *skl_nhlt_init(struct device *dev) |
29 | { | 29 | { |
30 | acpi_handle handle; | 30 | acpi_handle handle; |
31 | union acpi_object *obj; | 31 | union acpi_object *obj; |
@@ -40,17 +40,17 @@ void __iomem *skl_nhlt_init(struct device *dev) | |||
40 | if (obj && obj->type == ACPI_TYPE_BUFFER) { | 40 | if (obj && obj->type == ACPI_TYPE_BUFFER) { |
41 | nhlt_ptr = (struct nhlt_resource_desc *)obj->buffer.pointer; | 41 | nhlt_ptr = (struct nhlt_resource_desc *)obj->buffer.pointer; |
42 | 42 | ||
43 | return ioremap_cache(nhlt_ptr->min_addr, nhlt_ptr->length); | 43 | return memremap(nhlt_ptr->min_addr, nhlt_ptr->length, |
44 | MEMREMAP_WB); | ||
44 | } | 45 | } |
45 | 46 | ||
46 | dev_err(dev, "device specific method to extract NHLT blob failed\n"); | 47 | dev_err(dev, "device specific method to extract NHLT blob failed\n"); |
47 | return NULL; | 48 | return NULL; |
48 | } | 49 | } |
49 | 50 | ||
50 | void skl_nhlt_free(void __iomem *addr) | 51 | void skl_nhlt_free(void *addr) |
51 | { | 52 | { |
52 | iounmap(addr); | 53 | memunmap(addr); |
53 | addr = NULL; | ||
54 | } | 54 | } |
55 | 55 | ||
56 | static struct nhlt_specific_cfg *skl_get_specific_cfg( | 56 | static struct nhlt_specific_cfg *skl_get_specific_cfg( |
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index bea26730873c..a2f94ce1679d 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <sound/pcm_params.h> | 24 | #include <sound/pcm_params.h> |
25 | #include <sound/soc.h> | 25 | #include <sound/soc.h> |
26 | #include "skl.h" | 26 | #include "skl.h" |
27 | #include "skl-topology.h" | ||
27 | 28 | ||
28 | #define HDA_MONO 1 | 29 | #define HDA_MONO 1 |
29 | #define HDA_STEREO 2 | 30 | #define HDA_STEREO 2 |
@@ -115,7 +116,7 @@ static int skl_pcm_open(struct snd_pcm_substream *substream, | |||
115 | 116 | ||
116 | dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); | 117 | dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); |
117 | ret = pm_runtime_get_sync(dai->dev); | 118 | ret = pm_runtime_get_sync(dai->dev); |
118 | if (ret) | 119 | if (ret < 0) |
119 | return ret; | 120 | return ret; |
120 | 121 | ||
121 | stream = snd_hdac_ext_stream_assign(ebus, substream, | 122 | stream = snd_hdac_ext_stream_assign(ebus, substream, |
@@ -214,6 +215,8 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream, | |||
214 | struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev); | 215 | struct hdac_ext_bus *ebus = dev_get_drvdata(dai->dev); |
215 | struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); | 216 | struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); |
216 | struct snd_pcm_runtime *runtime = substream->runtime; | 217 | struct snd_pcm_runtime *runtime = substream->runtime; |
218 | struct skl_pipe_params p_params = {0}; | ||
219 | struct skl_module_cfg *m_cfg; | ||
217 | int ret, dma_id; | 220 | int ret, dma_id; |
218 | 221 | ||
219 | dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); | 222 | dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); |
@@ -228,6 +231,16 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream, | |||
228 | dma_id = hdac_stream(stream)->stream_tag - 1; | 231 | dma_id = hdac_stream(stream)->stream_tag - 1; |
229 | dev_dbg(dai->dev, "dma_id=%d\n", dma_id); | 232 | dev_dbg(dai->dev, "dma_id=%d\n", dma_id); |
230 | 233 | ||
234 | p_params.s_fmt = snd_pcm_format_width(params_format(params)); | ||
235 | p_params.ch = params_channels(params); | ||
236 | p_params.s_freq = params_rate(params); | ||
237 | p_params.host_dma_id = dma_id; | ||
238 | p_params.stream = substream->stream; | ||
239 | |||
240 | m_cfg = skl_tplg_fe_get_cpr_module(dai, p_params.stream); | ||
241 | if (m_cfg) | ||
242 | skl_tplg_update_pipe_params(dai->dev, m_cfg, &p_params); | ||
243 | |||
231 | return 0; | 244 | return 0; |
232 | } | 245 | } |
233 | 246 | ||
@@ -268,6 +281,46 @@ static int skl_pcm_hw_free(struct snd_pcm_substream *substream, | |||
268 | return skl_substream_free_pages(ebus_to_hbus(ebus), substream); | 281 | return skl_substream_free_pages(ebus_to_hbus(ebus), substream); |
269 | } | 282 | } |
270 | 283 | ||
284 | static int skl_be_hw_params(struct snd_pcm_substream *substream, | ||
285 | struct snd_pcm_hw_params *params, | ||
286 | struct snd_soc_dai *dai) | ||
287 | { | ||
288 | struct skl_pipe_params p_params = {0}; | ||
289 | |||
290 | p_params.s_fmt = snd_pcm_format_width(params_format(params)); | ||
291 | p_params.ch = params_channels(params); | ||
292 | p_params.s_freq = params_rate(params); | ||
293 | p_params.stream = substream->stream; | ||
294 | skl_tplg_be_update_params(dai, &p_params); | ||
295 | |||
296 | return 0; | ||
297 | } | ||
298 | |||
299 | static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd, | ||
300 | struct snd_soc_dai *dai) | ||
301 | { | ||
302 | struct skl *skl = get_skl_ctx(dai->dev); | ||
303 | struct skl_sst *ctx = skl->skl_sst; | ||
304 | struct skl_module_cfg *mconfig; | ||
305 | |||
306 | mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream); | ||
307 | if (!mconfig) | ||
308 | return -EIO; | ||
309 | |||
310 | switch (cmd) { | ||
311 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
312 | case SNDRV_PCM_TRIGGER_RESUME: | ||
313 | return skl_run_pipe(ctx, mconfig->pipe); | ||
314 | |||
315 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
316 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
317 | return skl_stop_pipe(ctx, mconfig->pipe); | ||
318 | |||
319 | default: | ||
320 | return 0; | ||
321 | } | ||
322 | } | ||
323 | |||
271 | static int skl_link_hw_params(struct snd_pcm_substream *substream, | 324 | static int skl_link_hw_params(struct snd_pcm_substream *substream, |
272 | struct snd_pcm_hw_params *params, | 325 | struct snd_pcm_hw_params *params, |
273 | struct snd_soc_dai *dai) | 326 | struct snd_soc_dai *dai) |
@@ -277,9 +330,8 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream, | |||
277 | struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); | 330 | struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); |
278 | struct skl_dma_params *dma_params; | 331 | struct skl_dma_params *dma_params; |
279 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 332 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
280 | int dma_id; | 333 | struct skl_pipe_params p_params = {0}; |
281 | 334 | ||
282 | pr_debug("%s\n", __func__); | ||
283 | link_dev = snd_hdac_ext_stream_assign(ebus, substream, | 335 | link_dev = snd_hdac_ext_stream_assign(ebus, substream, |
284 | HDAC_EXT_STREAM_TYPE_LINK); | 336 | HDAC_EXT_STREAM_TYPE_LINK); |
285 | if (!link_dev) | 337 | if (!link_dev) |
@@ -293,7 +345,14 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream, | |||
293 | if (dma_params) | 345 | if (dma_params) |
294 | dma_params->stream_tag = hdac_stream(link_dev)->stream_tag; | 346 | dma_params->stream_tag = hdac_stream(link_dev)->stream_tag; |
295 | snd_soc_dai_set_dma_data(codec_dai, substream, (void *)dma_params); | 347 | snd_soc_dai_set_dma_data(codec_dai, substream, (void *)dma_params); |
296 | dma_id = hdac_stream(link_dev)->stream_tag - 1; | 348 | |
349 | p_params.s_fmt = snd_pcm_format_width(params_format(params)); | ||
350 | p_params.ch = params_channels(params); | ||
351 | p_params.s_freq = params_rate(params); | ||
352 | p_params.stream = substream->stream; | ||
353 | p_params.link_dma_id = hdac_stream(link_dev)->stream_tag - 1; | ||
354 | |||
355 | skl_tplg_be_update_params(dai, &p_params); | ||
297 | 356 | ||
298 | return 0; | 357 | return 0; |
299 | } | 358 | } |
@@ -308,27 +367,12 @@ static int skl_link_pcm_prepare(struct snd_pcm_substream *substream, | |||
308 | unsigned int format_val = 0; | 367 | unsigned int format_val = 0; |
309 | struct skl_dma_params *dma_params; | 368 | struct skl_dma_params *dma_params; |
310 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 369 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
311 | struct snd_pcm_hw_params *params; | ||
312 | struct snd_interval *channels, *rate; | ||
313 | struct hdac_ext_link *link; | 370 | struct hdac_ext_link *link; |
314 | 371 | ||
315 | dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); | ||
316 | if (link_dev->link_prepared) { | 372 | if (link_dev->link_prepared) { |
317 | dev_dbg(dai->dev, "already stream is prepared - returning\n"); | 373 | dev_dbg(dai->dev, "already stream is prepared - returning\n"); |
318 | return 0; | 374 | return 0; |
319 | } | 375 | } |
320 | params = devm_kzalloc(dai->dev, sizeof(*params), GFP_KERNEL); | ||
321 | if (params == NULL) | ||
322 | return -ENOMEM; | ||
323 | |||
324 | channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); | ||
325 | channels->min = channels->max = substream->runtime->channels; | ||
326 | rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); | ||
327 | rate->min = rate->max = substream->runtime->rate; | ||
328 | snd_mask_set(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT - | ||
329 | SNDRV_PCM_HW_PARAM_FIRST_MASK], | ||
330 | substream->runtime->format); | ||
331 | |||
332 | 376 | ||
333 | dma_params = (struct skl_dma_params *) | 377 | dma_params = (struct skl_dma_params *) |
334 | snd_soc_dai_get_dma_data(codec_dai, substream); | 378 | snd_soc_dai_get_dma_data(codec_dai, substream); |
@@ -399,13 +443,13 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream, | |||
399 | return 0; | 443 | return 0; |
400 | } | 444 | } |
401 | 445 | ||
402 | static int skl_hda_be_startup(struct snd_pcm_substream *substream, | 446 | static int skl_be_startup(struct snd_pcm_substream *substream, |
403 | struct snd_soc_dai *dai) | 447 | struct snd_soc_dai *dai) |
404 | { | 448 | { |
405 | return pm_runtime_get_sync(dai->dev); | 449 | return pm_runtime_get_sync(dai->dev); |
406 | } | 450 | } |
407 | 451 | ||
408 | static void skl_hda_be_shutdown(struct snd_pcm_substream *substream, | 452 | static void skl_be_shutdown(struct snd_pcm_substream *substream, |
409 | struct snd_soc_dai *dai) | 453 | struct snd_soc_dai *dai) |
410 | { | 454 | { |
411 | pm_runtime_mark_last_busy(dai->dev); | 455 | pm_runtime_mark_last_busy(dai->dev); |
@@ -418,20 +462,28 @@ static struct snd_soc_dai_ops skl_pcm_dai_ops = { | |||
418 | .prepare = skl_pcm_prepare, | 462 | .prepare = skl_pcm_prepare, |
419 | .hw_params = skl_pcm_hw_params, | 463 | .hw_params = skl_pcm_hw_params, |
420 | .hw_free = skl_pcm_hw_free, | 464 | .hw_free = skl_pcm_hw_free, |
465 | .trigger = skl_pcm_trigger, | ||
421 | }; | 466 | }; |
422 | 467 | ||
423 | static struct snd_soc_dai_ops skl_dmic_dai_ops = { | 468 | static struct snd_soc_dai_ops skl_dmic_dai_ops = { |
424 | .startup = skl_hda_be_startup, | 469 | .startup = skl_be_startup, |
425 | .shutdown = skl_hda_be_shutdown, | 470 | .hw_params = skl_be_hw_params, |
471 | .shutdown = skl_be_shutdown, | ||
472 | }; | ||
473 | |||
474 | static struct snd_soc_dai_ops skl_be_ssp_dai_ops = { | ||
475 | .startup = skl_be_startup, | ||
476 | .hw_params = skl_be_hw_params, | ||
477 | .shutdown = skl_be_shutdown, | ||
426 | }; | 478 | }; |
427 | 479 | ||
428 | static struct snd_soc_dai_ops skl_link_dai_ops = { | 480 | static struct snd_soc_dai_ops skl_link_dai_ops = { |
429 | .startup = skl_hda_be_startup, | 481 | .startup = skl_be_startup, |
430 | .prepare = skl_link_pcm_prepare, | 482 | .prepare = skl_link_pcm_prepare, |
431 | .hw_params = skl_link_hw_params, | 483 | .hw_params = skl_link_hw_params, |
432 | .hw_free = skl_link_hw_free, | 484 | .hw_free = skl_link_hw_free, |
433 | .trigger = skl_link_pcm_trigger, | 485 | .trigger = skl_link_pcm_trigger, |
434 | .shutdown = skl_hda_be_shutdown, | 486 | .shutdown = skl_be_shutdown, |
435 | }; | 487 | }; |
436 | 488 | ||
437 | static struct snd_soc_dai_driver skl_platform_dai[] = { | 489 | static struct snd_soc_dai_driver skl_platform_dai[] = { |
@@ -488,6 +540,24 @@ static struct snd_soc_dai_driver skl_platform_dai[] = { | |||
488 | }, | 540 | }, |
489 | /* BE CPU Dais */ | 541 | /* BE CPU Dais */ |
490 | { | 542 | { |
543 | .name = "SSP0 Pin", | ||
544 | .ops = &skl_be_ssp_dai_ops, | ||
545 | .playback = { | ||
546 | .stream_name = "ssp0 Tx", | ||
547 | .channels_min = HDA_STEREO, | ||
548 | .channels_max = HDA_STEREO, | ||
549 | .rates = SNDRV_PCM_RATE_48000, | ||
550 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
551 | }, | ||
552 | .capture = { | ||
553 | .stream_name = "ssp0 Rx", | ||
554 | .channels_min = HDA_STEREO, | ||
555 | .channels_max = HDA_STEREO, | ||
556 | .rates = SNDRV_PCM_RATE_48000, | ||
557 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
558 | }, | ||
559 | }, | ||
560 | { | ||
491 | .name = "iDisp Pin", | 561 | .name = "iDisp Pin", |
492 | .ops = &skl_link_dai_ops, | 562 | .ops = &skl_link_dai_ops, |
493 | .playback = { | 563 | .playback = { |
@@ -544,7 +614,7 @@ static int skl_platform_open(struct snd_pcm_substream *substream) | |||
544 | return 0; | 614 | return 0; |
545 | } | 615 | } |
546 | 616 | ||
547 | static int skl_pcm_trigger(struct snd_pcm_substream *substream, | 617 | static int skl_coupled_trigger(struct snd_pcm_substream *substream, |
548 | int cmd) | 618 | int cmd) |
549 | { | 619 | { |
550 | struct hdac_ext_bus *ebus = get_bus_ctx(substream); | 620 | struct hdac_ext_bus *ebus = get_bus_ctx(substream); |
@@ -618,7 +688,7 @@ static int skl_pcm_trigger(struct snd_pcm_substream *substream, | |||
618 | return 0; | 688 | return 0; |
619 | } | 689 | } |
620 | 690 | ||
621 | static int skl_dsp_trigger(struct snd_pcm_substream *substream, | 691 | static int skl_decoupled_trigger(struct snd_pcm_substream *substream, |
622 | int cmd) | 692 | int cmd) |
623 | { | 693 | { |
624 | struct hdac_ext_bus *ebus = get_bus_ctx(substream); | 694 | struct hdac_ext_bus *ebus = get_bus_ctx(substream); |
@@ -675,9 +745,9 @@ static int skl_platform_pcm_trigger(struct snd_pcm_substream *substream, | |||
675 | struct hdac_ext_bus *ebus = get_bus_ctx(substream); | 745 | struct hdac_ext_bus *ebus = get_bus_ctx(substream); |
676 | 746 | ||
677 | if (ebus->ppcap) | 747 | if (ebus->ppcap) |
678 | return skl_dsp_trigger(substream, cmd); | 748 | return skl_decoupled_trigger(substream, cmd); |
679 | else | 749 | else |
680 | return skl_pcm_trigger(substream, cmd); | 750 | return skl_coupled_trigger(substream, cmd); |
681 | } | 751 | } |
682 | 752 | ||
683 | /* calculate runtime delay from LPIB */ | 753 | /* calculate runtime delay from LPIB */ |
@@ -844,7 +914,17 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd) | |||
844 | return retval; | 914 | return retval; |
845 | } | 915 | } |
846 | 916 | ||
917 | static int skl_platform_soc_probe(struct snd_soc_platform *platform) | ||
918 | { | ||
919 | struct hdac_ext_bus *ebus = dev_get_drvdata(platform->dev); | ||
920 | |||
921 | if (ebus->ppcap) | ||
922 | return skl_tplg_init(platform, ebus); | ||
923 | |||
924 | return 0; | ||
925 | } | ||
847 | static struct snd_soc_platform_driver skl_platform_drv = { | 926 | static struct snd_soc_platform_driver skl_platform_drv = { |
927 | .probe = skl_platform_soc_probe, | ||
848 | .ops = &skl_platform_ops, | 928 | .ops = &skl_platform_ops, |
849 | .pcm_new = skl_pcm_new, | 929 | .pcm_new = skl_pcm_new, |
850 | .pcm_free = skl_pcm_free, | 930 | .pcm_free = skl_pcm_free, |
@@ -857,6 +937,11 @@ static const struct snd_soc_component_driver skl_component = { | |||
857 | int skl_platform_register(struct device *dev) | 937 | int skl_platform_register(struct device *dev) |
858 | { | 938 | { |
859 | int ret; | 939 | int ret; |
940 | struct hdac_ext_bus *ebus = dev_get_drvdata(dev); | ||
941 | struct skl *skl = ebus_to_skl(ebus); | ||
942 | |||
943 | INIT_LIST_HEAD(&skl->ppl_list); | ||
944 | INIT_LIST_HEAD(&skl->dapm_path_list); | ||
860 | 945 | ||
861 | ret = snd_soc_register_platform(dev, &skl_platform_drv); | 946 | ret = snd_soc_register_platform(dev, &skl_platform_drv); |
862 | if (ret) { | 947 | if (ret) { |
diff --git a/sound/soc/intel/skylake/skl-sst-dsp.c b/sound/soc/intel/skylake/skl-sst-dsp.c index 94875b008b0b..1bfb7f63b572 100644 --- a/sound/soc/intel/skylake/skl-sst-dsp.c +++ b/sound/soc/intel/skylake/skl-sst-dsp.c | |||
@@ -175,7 +175,7 @@ static int skl_dsp_core_power_down(struct sst_dsp *ctx) | |||
175 | /* poll with timeout to check if operation successful */ | 175 | /* poll with timeout to check if operation successful */ |
176 | return sst_dsp_register_poll(ctx, | 176 | return sst_dsp_register_poll(ctx, |
177 | SKL_ADSP_REG_ADSPCS, | 177 | SKL_ADSP_REG_ADSPCS, |
178 | SKL_ADSPCS_SPA_MASK, | 178 | SKL_ADSPCS_CPA_MASK, |
179 | 0, | 179 | 0, |
180 | SKL_DSP_PD_TO, | 180 | SKL_DSP_PD_TO, |
181 | "Power down"); | 181 | "Power down"); |
@@ -262,6 +262,11 @@ irqreturn_t skl_dsp_sst_interrupt(int irq, void *dev_id) | |||
262 | val = sst_dsp_shim_read_unlocked(ctx, SKL_ADSP_REG_ADSPIS); | 262 | val = sst_dsp_shim_read_unlocked(ctx, SKL_ADSP_REG_ADSPIS); |
263 | ctx->intr_status = val; | 263 | ctx->intr_status = val; |
264 | 264 | ||
265 | if (val == 0xffffffff) { | ||
266 | spin_unlock(&ctx->spinlock); | ||
267 | return IRQ_NONE; | ||
268 | } | ||
269 | |||
265 | if (val & SKL_ADSPIS_IPC) { | 270 | if (val & SKL_ADSPIS_IPC) { |
266 | skl_ipc_int_disable(ctx); | 271 | skl_ipc_int_disable(ctx); |
267 | result = IRQ_WAKE_THREAD; | 272 | result = IRQ_WAKE_THREAD; |
diff --git a/sound/soc/intel/skylake/skl-sst-ipc.c b/sound/soc/intel/skylake/skl-sst-ipc.c index 937a0a3a63a0..3345ea0d4414 100644 --- a/sound/soc/intel/skylake/skl-sst-ipc.c +++ b/sound/soc/intel/skylake/skl-sst-ipc.c | |||
@@ -464,6 +464,18 @@ void skl_ipc_op_int_enable(struct sst_dsp *ctx) | |||
464 | SKL_ADSP_REG_HIPCCTL_BUSY, SKL_ADSP_REG_HIPCCTL_BUSY); | 464 | SKL_ADSP_REG_HIPCCTL_BUSY, SKL_ADSP_REG_HIPCCTL_BUSY); |
465 | } | 465 | } |
466 | 466 | ||
467 | void skl_ipc_op_int_disable(struct sst_dsp *ctx) | ||
468 | { | ||
469 | /* disable IPC DONE interrupt */ | ||
470 | sst_dsp_shim_update_bits_unlocked(ctx, SKL_ADSP_REG_HIPCCTL, | ||
471 | SKL_ADSP_REG_HIPCCTL_DONE, 0); | ||
472 | |||
473 | /* Disable IPC BUSY interrupt */ | ||
474 | sst_dsp_shim_update_bits_unlocked(ctx, SKL_ADSP_REG_HIPCCTL, | ||
475 | SKL_ADSP_REG_HIPCCTL_BUSY, 0); | ||
476 | |||
477 | } | ||
478 | |||
467 | bool skl_ipc_int_status(struct sst_dsp *ctx) | 479 | bool skl_ipc_int_status(struct sst_dsp *ctx) |
468 | { | 480 | { |
469 | return sst_dsp_shim_read_unlocked(ctx, | 481 | return sst_dsp_shim_read_unlocked(ctx, |
diff --git a/sound/soc/intel/skylake/skl-sst-ipc.h b/sound/soc/intel/skylake/skl-sst-ipc.h index 9f5f67202858..f1a154e45dc3 100644 --- a/sound/soc/intel/skylake/skl-sst-ipc.h +++ b/sound/soc/intel/skylake/skl-sst-ipc.h | |||
@@ -116,6 +116,7 @@ int skl_ipc_set_large_config(struct sst_generic_ipc *ipc, | |||
116 | 116 | ||
117 | void skl_ipc_int_enable(struct sst_dsp *dsp); | 117 | void skl_ipc_int_enable(struct sst_dsp *dsp); |
118 | void skl_ipc_op_int_enable(struct sst_dsp *ctx); | 118 | void skl_ipc_op_int_enable(struct sst_dsp *ctx); |
119 | void skl_ipc_op_int_disable(struct sst_dsp *ctx); | ||
119 | void skl_ipc_int_disable(struct sst_dsp *dsp); | 120 | void skl_ipc_int_disable(struct sst_dsp *dsp); |
120 | 121 | ||
121 | bool skl_ipc_int_status(struct sst_dsp *dsp); | 122 | bool skl_ipc_int_status(struct sst_dsp *dsp); |
diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c index c18ea51b7484..3b83dc99f1d4 100644 --- a/sound/soc/intel/skylake/skl-sst.c +++ b/sound/soc/intel/skylake/skl-sst.c | |||
@@ -70,15 +70,31 @@ static int skl_transfer_firmware(struct sst_dsp *ctx, | |||
70 | static int skl_load_base_firmware(struct sst_dsp *ctx) | 70 | static int skl_load_base_firmware(struct sst_dsp *ctx) |
71 | { | 71 | { |
72 | int ret = 0, i; | 72 | int ret = 0, i; |
73 | const struct firmware *fw = NULL; | ||
74 | struct skl_sst *skl = ctx->thread_context; | 73 | struct skl_sst *skl = ctx->thread_context; |
75 | u32 reg; | 74 | u32 reg; |
76 | 75 | ||
77 | ret = request_firmware(&fw, "dsp_fw_release.bin", ctx->dev); | 76 | skl->boot_complete = false; |
77 | init_waitqueue_head(&skl->boot_wait); | ||
78 | |||
79 | if (ctx->fw == NULL) { | ||
80 | ret = request_firmware(&ctx->fw, "dsp_fw_release.bin", ctx->dev); | ||
81 | if (ret < 0) { | ||
82 | dev_err(ctx->dev, "Request firmware failed %d\n", ret); | ||
83 | skl_dsp_disable_core(ctx); | ||
84 | return -EIO; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | ret = skl_dsp_boot(ctx); | ||
78 | if (ret < 0) { | 89 | if (ret < 0) { |
79 | dev_err(ctx->dev, "Request firmware failed %d\n", ret); | 90 | dev_err(ctx->dev, "Boot dsp core failed ret: %d", ret); |
80 | skl_dsp_disable_core(ctx); | 91 | goto skl_load_base_firmware_failed; |
81 | return -EIO; | 92 | } |
93 | |||
94 | ret = skl_cldma_prepare(ctx); | ||
95 | if (ret < 0) { | ||
96 | dev_err(ctx->dev, "CL dma prepare failed : %d", ret); | ||
97 | goto skl_load_base_firmware_failed; | ||
82 | } | 98 | } |
83 | 99 | ||
84 | /* enable Interrupt */ | 100 | /* enable Interrupt */ |
@@ -102,7 +118,7 @@ static int skl_load_base_firmware(struct sst_dsp *ctx) | |||
102 | goto skl_load_base_firmware_failed; | 118 | goto skl_load_base_firmware_failed; |
103 | } | 119 | } |
104 | 120 | ||
105 | ret = skl_transfer_firmware(ctx, fw->data, fw->size); | 121 | ret = skl_transfer_firmware(ctx, ctx->fw->data, ctx->fw->size); |
106 | if (ret < 0) { | 122 | if (ret < 0) { |
107 | dev_err(ctx->dev, "Transfer firmware failed%d\n", ret); | 123 | dev_err(ctx->dev, "Transfer firmware failed%d\n", ret); |
108 | goto skl_load_base_firmware_failed; | 124 | goto skl_load_base_firmware_failed; |
@@ -118,13 +134,12 @@ static int skl_load_base_firmware(struct sst_dsp *ctx) | |||
118 | dev_dbg(ctx->dev, "Download firmware successful%d\n", ret); | 134 | dev_dbg(ctx->dev, "Download firmware successful%d\n", ret); |
119 | skl_dsp_set_state_locked(ctx, SKL_DSP_RUNNING); | 135 | skl_dsp_set_state_locked(ctx, SKL_DSP_RUNNING); |
120 | } | 136 | } |
121 | release_firmware(fw); | ||
122 | |||
123 | return 0; | 137 | return 0; |
124 | 138 | ||
125 | skl_load_base_firmware_failed: | 139 | skl_load_base_firmware_failed: |
126 | skl_dsp_disable_core(ctx); | 140 | skl_dsp_disable_core(ctx); |
127 | release_firmware(fw); | 141 | release_firmware(ctx->fw); |
142 | ctx->fw = NULL; | ||
128 | return ret; | 143 | return ret; |
129 | } | 144 | } |
130 | 145 | ||
@@ -172,6 +187,12 @@ static int skl_set_dsp_D3(struct sst_dsp *ctx) | |||
172 | } | 187 | } |
173 | skl_dsp_set_state_locked(ctx, SKL_DSP_RESET); | 188 | skl_dsp_set_state_locked(ctx, SKL_DSP_RESET); |
174 | 189 | ||
190 | /* disable Interrupt */ | ||
191 | ctx->cl_dev.ops.cl_cleanup_controller(ctx); | ||
192 | skl_cldma_int_disable(ctx); | ||
193 | skl_ipc_op_int_disable(ctx); | ||
194 | skl_ipc_int_disable(ctx); | ||
195 | |||
175 | return ret; | 196 | return ret; |
176 | } | 197 | } |
177 | 198 | ||
@@ -235,22 +256,6 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, | |||
235 | if (ret) | 256 | if (ret) |
236 | return ret; | 257 | return ret; |
237 | 258 | ||
238 | skl->boot_complete = false; | ||
239 | init_waitqueue_head(&skl->boot_wait); | ||
240 | |||
241 | ret = skl_dsp_boot(sst); | ||
242 | if (ret < 0) { | ||
243 | dev_err(skl->dev, "Boot dsp core failed ret: %d", ret); | ||
244 | goto free_ipc; | ||
245 | } | ||
246 | |||
247 | ret = skl_cldma_prepare(sst); | ||
248 | if (ret < 0) { | ||
249 | dev_err(dev, "CL dma prepare failed : %d", ret); | ||
250 | goto free_ipc; | ||
251 | } | ||
252 | |||
253 | |||
254 | ret = sst->fw_ops.load_fw(sst); | 259 | ret = sst->fw_ops.load_fw(sst); |
255 | if (ret < 0) { | 260 | if (ret < 0) { |
256 | dev_err(dev, "Load base fw failed : %d", ret); | 261 | dev_err(dev, "Load base fw failed : %d", ret); |
@@ -262,7 +267,6 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, | |||
262 | 267 | ||
263 | return 0; | 268 | return 0; |
264 | 269 | ||
265 | free_ipc: | ||
266 | skl_ipc_free(&skl->ipc); | 270 | skl_ipc_free(&skl->ipc); |
267 | return ret; | 271 | return ret; |
268 | } | 272 | } |
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c new file mode 100644 index 000000000000..a7854c8fc523 --- /dev/null +++ b/sound/soc/intel/skylake/skl-topology.c | |||
@@ -0,0 +1,1252 @@ | |||
1 | /* | ||
2 | * skl-topology.c - Implements Platform component ALSA controls/widget | ||
3 | * handlers. | ||
4 | * | ||
5 | * Copyright (C) 2014-2015 Intel Corp | ||
6 | * Author: Jeeja KP <jeeja.kp@intel.com> | ||
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as version 2, as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | */ | ||
18 | |||
19 | #include <linux/slab.h> | ||
20 | #include <linux/types.h> | ||
21 | #include <linux/firmware.h> | ||
22 | #include <sound/soc.h> | ||
23 | #include <sound/soc-topology.h> | ||
24 | #include "skl-sst-dsp.h" | ||
25 | #include "skl-sst-ipc.h" | ||
26 | #include "skl-topology.h" | ||
27 | #include "skl.h" | ||
28 | #include "skl-tplg-interface.h" | ||
29 | |||
30 | #define SKL_CH_FIXUP_MASK (1 << 0) | ||
31 | #define SKL_RATE_FIXUP_MASK (1 << 1) | ||
32 | #define SKL_FMT_FIXUP_MASK (1 << 2) | ||
33 | |||
34 | /* | ||
35 | * SKL DSP driver modelling uses only few DAPM widgets so for rest we will | ||
36 | * ignore. This helpers checks if the SKL driver handles this widget type | ||
37 | */ | ||
38 | static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget *w) | ||
39 | { | ||
40 | switch (w->id) { | ||
41 | case snd_soc_dapm_dai_link: | ||
42 | case snd_soc_dapm_dai_in: | ||
43 | case snd_soc_dapm_aif_in: | ||
44 | case snd_soc_dapm_aif_out: | ||
45 | case snd_soc_dapm_dai_out: | ||
46 | case snd_soc_dapm_switch: | ||
47 | return false; | ||
48 | default: | ||
49 | return true; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | /* | ||
54 | * Each pipelines needs memory to be allocated. Check if we have free memory | ||
55 | * from available pool. Then only add this to pool | ||
56 | * This is freed when pipe is deleted | ||
57 | * Note: DSP does actual memory management we only keep track for complete | ||
58 | * pool | ||
59 | */ | ||
60 | static bool skl_tplg_alloc_pipe_mem(struct skl *skl, | ||
61 | struct skl_module_cfg *mconfig) | ||
62 | { | ||
63 | struct skl_sst *ctx = skl->skl_sst; | ||
64 | |||
65 | if (skl->resource.mem + mconfig->pipe->memory_pages > | ||
66 | skl->resource.max_mem) { | ||
67 | dev_err(ctx->dev, | ||
68 | "%s: module_id %d instance %d\n", __func__, | ||
69 | mconfig->id.module_id, | ||
70 | mconfig->id.instance_id); | ||
71 | dev_err(ctx->dev, | ||
72 | "exceeds ppl memory available %d mem %d\n", | ||
73 | skl->resource.max_mem, skl->resource.mem); | ||
74 | return false; | ||
75 | } | ||
76 | |||
77 | skl->resource.mem += mconfig->pipe->memory_pages; | ||
78 | return true; | ||
79 | } | ||
80 | |||
81 | /* | ||
82 | * Pipeline needs needs DSP CPU resources for computation, this is | ||
83 | * quantified in MCPS (Million Clocks Per Second) required for module/pipe | ||
84 | * | ||
85 | * Each pipelines needs mcps to be allocated. Check if we have mcps for this | ||
86 | * pipe. This adds the mcps to driver counter | ||
87 | * This is removed on pipeline delete | ||
88 | */ | ||
89 | static bool skl_tplg_alloc_pipe_mcps(struct skl *skl, | ||
90 | struct skl_module_cfg *mconfig) | ||
91 | { | ||
92 | struct skl_sst *ctx = skl->skl_sst; | ||
93 | |||
94 | if (skl->resource.mcps + mconfig->mcps > skl->resource.max_mcps) { | ||
95 | dev_err(ctx->dev, | ||
96 | "%s: module_id %d instance %d\n", __func__, | ||
97 | mconfig->id.module_id, mconfig->id.instance_id); | ||
98 | dev_err(ctx->dev, | ||
99 | "exceeds ppl memory available %d > mem %d\n", | ||
100 | skl->resource.max_mcps, skl->resource.mcps); | ||
101 | return false; | ||
102 | } | ||
103 | |||
104 | skl->resource.mcps += mconfig->mcps; | ||
105 | return true; | ||
106 | } | ||
107 | |||
108 | /* | ||
109 | * Free the mcps when tearing down | ||
110 | */ | ||
111 | static void | ||
112 | skl_tplg_free_pipe_mcps(struct skl *skl, struct skl_module_cfg *mconfig) | ||
113 | { | ||
114 | skl->resource.mcps -= mconfig->mcps; | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | * Free the memory when tearing down | ||
119 | */ | ||
120 | static void | ||
121 | skl_tplg_free_pipe_mem(struct skl *skl, struct skl_module_cfg *mconfig) | ||
122 | { | ||
123 | skl->resource.mem -= mconfig->pipe->memory_pages; | ||
124 | } | ||
125 | |||
126 | |||
127 | static void skl_dump_mconfig(struct skl_sst *ctx, | ||
128 | struct skl_module_cfg *mcfg) | ||
129 | { | ||
130 | dev_dbg(ctx->dev, "Dumping config\n"); | ||
131 | dev_dbg(ctx->dev, "Input Format:\n"); | ||
132 | dev_dbg(ctx->dev, "channels = %d\n", mcfg->in_fmt.channels); | ||
133 | dev_dbg(ctx->dev, "s_freq = %d\n", mcfg->in_fmt.s_freq); | ||
134 | dev_dbg(ctx->dev, "ch_cfg = %d\n", mcfg->in_fmt.ch_cfg); | ||
135 | dev_dbg(ctx->dev, "valid bit depth = %d\n", | ||
136 | mcfg->in_fmt.valid_bit_depth); | ||
137 | dev_dbg(ctx->dev, "Output Format:\n"); | ||
138 | dev_dbg(ctx->dev, "channels = %d\n", mcfg->out_fmt.channels); | ||
139 | dev_dbg(ctx->dev, "s_freq = %d\n", mcfg->out_fmt.s_freq); | ||
140 | dev_dbg(ctx->dev, "valid bit depth = %d\n", | ||
141 | mcfg->out_fmt.valid_bit_depth); | ||
142 | dev_dbg(ctx->dev, "ch_cfg = %d\n", mcfg->out_fmt.ch_cfg); | ||
143 | } | ||
144 | |||
145 | static void skl_tplg_update_params(struct skl_module_fmt *fmt, | ||
146 | struct skl_pipe_params *params, int fixup) | ||
147 | { | ||
148 | if (fixup & SKL_RATE_FIXUP_MASK) | ||
149 | fmt->s_freq = params->s_freq; | ||
150 | if (fixup & SKL_CH_FIXUP_MASK) | ||
151 | fmt->channels = params->ch; | ||
152 | if (fixup & SKL_FMT_FIXUP_MASK) | ||
153 | fmt->valid_bit_depth = params->s_fmt; | ||
154 | } | ||
155 | |||
156 | /* | ||
157 | * A pipeline may have modules which impact the pcm parameters, like SRC, | ||
158 | * channel converter, format converter. | ||
159 | * We need to calculate the output params by applying the 'fixup' | ||
160 | * Topology will tell driver which type of fixup is to be applied by | ||
161 | * supplying the fixup mask, so based on that we calculate the output | ||
162 | * | ||
163 | * Now In FE the pcm hw_params is source/target format. Same is applicable | ||
164 | * for BE with its hw_params invoked. | ||
165 | * here based on FE, BE pipeline and direction we calculate the input and | ||
166 | * outfix and then apply that for a module | ||
167 | */ | ||
168 | static void skl_tplg_update_params_fixup(struct skl_module_cfg *m_cfg, | ||
169 | struct skl_pipe_params *params, bool is_fe) | ||
170 | { | ||
171 | int in_fixup, out_fixup; | ||
172 | struct skl_module_fmt *in_fmt, *out_fmt; | ||
173 | |||
174 | in_fmt = &m_cfg->in_fmt; | ||
175 | out_fmt = &m_cfg->out_fmt; | ||
176 | |||
177 | if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
178 | if (is_fe) { | ||
179 | in_fixup = m_cfg->params_fixup; | ||
180 | out_fixup = (~m_cfg->converter) & | ||
181 | m_cfg->params_fixup; | ||
182 | } else { | ||
183 | out_fixup = m_cfg->params_fixup; | ||
184 | in_fixup = (~m_cfg->converter) & | ||
185 | m_cfg->params_fixup; | ||
186 | } | ||
187 | } else { | ||
188 | if (is_fe) { | ||
189 | out_fixup = m_cfg->params_fixup; | ||
190 | in_fixup = (~m_cfg->converter) & | ||
191 | m_cfg->params_fixup; | ||
192 | } else { | ||
193 | in_fixup = m_cfg->params_fixup; | ||
194 | out_fixup = (~m_cfg->converter) & | ||
195 | m_cfg->params_fixup; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | skl_tplg_update_params(in_fmt, params, in_fixup); | ||
200 | skl_tplg_update_params(out_fmt, params, out_fixup); | ||
201 | } | ||
202 | |||
203 | /* | ||
204 | * A module needs input and output buffers, which are dependent upon pcm | ||
205 | * params, so once we have calculate params, we need buffer calculation as | ||
206 | * well. | ||
207 | */ | ||
208 | static void skl_tplg_update_buffer_size(struct skl_sst *ctx, | ||
209 | struct skl_module_cfg *mcfg) | ||
210 | { | ||
211 | int multiplier = 1; | ||
212 | |||
213 | if (mcfg->m_type == SKL_MODULE_TYPE_SRCINT) | ||
214 | multiplier = 5; | ||
215 | |||
216 | mcfg->ibs = (mcfg->in_fmt.s_freq / 1000) * | ||
217 | (mcfg->in_fmt.channels) * | ||
218 | (mcfg->in_fmt.bit_depth >> 3) * | ||
219 | multiplier; | ||
220 | |||
221 | mcfg->obs = (mcfg->out_fmt.s_freq / 1000) * | ||
222 | (mcfg->out_fmt.channels) * | ||
223 | (mcfg->out_fmt.bit_depth >> 3) * | ||
224 | multiplier; | ||
225 | } | ||
226 | |||
227 | static void skl_tplg_update_module_params(struct snd_soc_dapm_widget *w, | ||
228 | struct skl_sst *ctx) | ||
229 | { | ||
230 | struct skl_module_cfg *m_cfg = w->priv; | ||
231 | struct skl_pipe_params *params = m_cfg->pipe->p_params; | ||
232 | int p_conn_type = m_cfg->pipe->conn_type; | ||
233 | bool is_fe; | ||
234 | |||
235 | if (!m_cfg->params_fixup) | ||
236 | return; | ||
237 | |||
238 | dev_dbg(ctx->dev, "Mconfig for widget=%s BEFORE updation\n", | ||
239 | w->name); | ||
240 | |||
241 | skl_dump_mconfig(ctx, m_cfg); | ||
242 | |||
243 | if (p_conn_type == SKL_PIPE_CONN_TYPE_FE) | ||
244 | is_fe = true; | ||
245 | else | ||
246 | is_fe = false; | ||
247 | |||
248 | skl_tplg_update_params_fixup(m_cfg, params, is_fe); | ||
249 | skl_tplg_update_buffer_size(ctx, m_cfg); | ||
250 | |||
251 | dev_dbg(ctx->dev, "Mconfig for widget=%s AFTER updation\n", | ||
252 | w->name); | ||
253 | |||
254 | skl_dump_mconfig(ctx, m_cfg); | ||
255 | } | ||
256 | |||
257 | /* | ||
258 | * A pipe can have multiple modules, each of them will be a DAPM widget as | ||
259 | * well. While managing a pipeline we need to get the list of all the | ||
260 | * widgets in a pipelines, so this helper - skl_tplg_get_pipe_widget() helps | ||
261 | * to get the SKL type widgets in that pipeline | ||
262 | */ | ||
263 | static int skl_tplg_alloc_pipe_widget(struct device *dev, | ||
264 | struct snd_soc_dapm_widget *w, struct skl_pipe *pipe) | ||
265 | { | ||
266 | struct skl_module_cfg *src_module = NULL; | ||
267 | struct snd_soc_dapm_path *p = NULL; | ||
268 | struct skl_pipe_module *p_module = NULL; | ||
269 | |||
270 | p_module = devm_kzalloc(dev, sizeof(*p_module), GFP_KERNEL); | ||
271 | if (!p_module) | ||
272 | return -ENOMEM; | ||
273 | |||
274 | p_module->w = w; | ||
275 | list_add_tail(&p_module->node, &pipe->w_list); | ||
276 | |||
277 | snd_soc_dapm_widget_for_each_sink_path(w, p) { | ||
278 | if ((p->sink->priv == NULL) | ||
279 | && (!is_skl_dsp_widget_type(w))) | ||
280 | continue; | ||
281 | |||
282 | if ((p->sink->priv != NULL) && p->connect | ||
283 | && is_skl_dsp_widget_type(p->sink)) { | ||
284 | |||
285 | src_module = p->sink->priv; | ||
286 | if (pipe->ppl_id == src_module->pipe->ppl_id) | ||
287 | skl_tplg_alloc_pipe_widget(dev, | ||
288 | p->sink, pipe); | ||
289 | } | ||
290 | } | ||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | /* | ||
295 | * Inside a pipe instance, we can have various modules. These modules need | ||
296 | * to instantiated in DSP by invoking INIT_MODULE IPC, which is achieved by | ||
297 | * skl_init_module() routine, so invoke that for all modules in a pipeline | ||
298 | */ | ||
299 | static int | ||
300 | skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe) | ||
301 | { | ||
302 | struct skl_pipe_module *w_module; | ||
303 | struct snd_soc_dapm_widget *w; | ||
304 | struct skl_module_cfg *mconfig; | ||
305 | struct skl_sst *ctx = skl->skl_sst; | ||
306 | int ret = 0; | ||
307 | |||
308 | list_for_each_entry(w_module, &pipe->w_list, node) { | ||
309 | w = w_module->w; | ||
310 | mconfig = w->priv; | ||
311 | |||
312 | /* check resource available */ | ||
313 | if (!skl_tplg_alloc_pipe_mcps(skl, mconfig)) | ||
314 | return -ENOMEM; | ||
315 | |||
316 | /* | ||
317 | * apply fix/conversion to module params based on | ||
318 | * FE/BE params | ||
319 | */ | ||
320 | skl_tplg_update_module_params(w, ctx); | ||
321 | ret = skl_init_module(ctx, mconfig, NULL); | ||
322 | if (ret < 0) | ||
323 | return ret; | ||
324 | } | ||
325 | |||
326 | return 0; | ||
327 | } | ||
328 | |||
329 | /* | ||
330 | * Mixer module represents a pipeline. So in the Pre-PMU event of mixer we | ||
331 | * need create the pipeline. So we do following: | ||
332 | * - check the resources | ||
333 | * - Create the pipeline | ||
334 | * - Initialize the modules in pipeline | ||
335 | * - finally bind all modules together | ||
336 | */ | ||
337 | static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w, | ||
338 | struct skl *skl) | ||
339 | { | ||
340 | int ret; | ||
341 | struct skl_module_cfg *mconfig = w->priv; | ||
342 | struct skl_pipe_module *w_module; | ||
343 | struct skl_pipe *s_pipe = mconfig->pipe; | ||
344 | struct skl_module_cfg *src_module = NULL, *dst_module; | ||
345 | struct skl_sst *ctx = skl->skl_sst; | ||
346 | |||
347 | /* check resource available */ | ||
348 | if (!skl_tplg_alloc_pipe_mcps(skl, mconfig)) | ||
349 | return -EBUSY; | ||
350 | |||
351 | if (!skl_tplg_alloc_pipe_mem(skl, mconfig)) | ||
352 | return -ENOMEM; | ||
353 | |||
354 | /* | ||
355 | * Create a list of modules for pipe. | ||
356 | * This list contains modules from source to sink | ||
357 | */ | ||
358 | ret = skl_create_pipeline(ctx, mconfig->pipe); | ||
359 | if (ret < 0) | ||
360 | return ret; | ||
361 | |||
362 | /* | ||
363 | * we create a w_list of all widgets in that pipe. This list is not | ||
364 | * freed on PMD event as widgets within a pipe are static. This | ||
365 | * saves us cycles to get widgets in pipe every time. | ||
366 | * | ||
367 | * So if we have already initialized all the widgets of a pipeline | ||
368 | * we skip, so check for list_empty and create the list if empty | ||
369 | */ | ||
370 | if (list_empty(&s_pipe->w_list)) { | ||
371 | ret = skl_tplg_alloc_pipe_widget(ctx->dev, w, s_pipe); | ||
372 | if (ret < 0) | ||
373 | return ret; | ||
374 | } | ||
375 | |||
376 | /* Init all pipe modules from source to sink */ | ||
377 | ret = skl_tplg_init_pipe_modules(skl, s_pipe); | ||
378 | if (ret < 0) | ||
379 | return ret; | ||
380 | |||
381 | /* Bind modules from source to sink */ | ||
382 | list_for_each_entry(w_module, &s_pipe->w_list, node) { | ||
383 | dst_module = w_module->w->priv; | ||
384 | |||
385 | if (src_module == NULL) { | ||
386 | src_module = dst_module; | ||
387 | continue; | ||
388 | } | ||
389 | |||
390 | ret = skl_bind_modules(ctx, src_module, dst_module); | ||
391 | if (ret < 0) | ||
392 | return ret; | ||
393 | |||
394 | src_module = dst_module; | ||
395 | } | ||
396 | |||
397 | return 0; | ||
398 | } | ||
399 | |||
400 | /* | ||
401 | * A PGA represents a module in a pipeline. So in the Pre-PMU event of PGA | ||
402 | * we need to do following: | ||
403 | * - Bind to sink pipeline | ||
404 | * Since the sink pipes can be running and we don't get mixer event on | ||
405 | * connect for already running mixer, we need to find the sink pipes | ||
406 | * here and bind to them. This way dynamic connect works. | ||
407 | * - Start sink pipeline, if not running | ||
408 | * - Then run current pipe | ||
409 | */ | ||
410 | static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w, | ||
411 | struct skl *skl) | ||
412 | { | ||
413 | struct snd_soc_dapm_path *p; | ||
414 | struct skl_dapm_path_list *path_list; | ||
415 | struct snd_soc_dapm_widget *source, *sink; | ||
416 | struct skl_module_cfg *src_mconfig, *sink_mconfig; | ||
417 | struct skl_sst *ctx = skl->skl_sst; | ||
418 | int ret = 0; | ||
419 | |||
420 | source = w; | ||
421 | src_mconfig = source->priv; | ||
422 | |||
423 | /* | ||
424 | * find which sink it is connected to, bind with the sink, | ||
425 | * if sink is not started, start sink pipe first, then start | ||
426 | * this pipe | ||
427 | */ | ||
428 | snd_soc_dapm_widget_for_each_source_path(w, p) { | ||
429 | if (!p->connect) | ||
430 | continue; | ||
431 | |||
432 | dev_dbg(ctx->dev, "%s: src widget=%s\n", __func__, w->name); | ||
433 | dev_dbg(ctx->dev, "%s: sink widget=%s\n", __func__, p->sink->name); | ||
434 | |||
435 | /* | ||
436 | * here we will check widgets in sink pipelines, so that | ||
437 | * can be any widgets type and we are only interested if | ||
438 | * they are ones used for SKL so check that first | ||
439 | */ | ||
440 | if ((p->sink->priv != NULL) && | ||
441 | is_skl_dsp_widget_type(p->sink)) { | ||
442 | |||
443 | sink = p->sink; | ||
444 | src_mconfig = source->priv; | ||
445 | sink_mconfig = sink->priv; | ||
446 | |||
447 | /* Bind source to sink, mixin is always source */ | ||
448 | ret = skl_bind_modules(ctx, src_mconfig, sink_mconfig); | ||
449 | if (ret) | ||
450 | return ret; | ||
451 | |||
452 | /* Start sinks pipe first */ | ||
453 | if (sink_mconfig->pipe->state != SKL_PIPE_STARTED) { | ||
454 | ret = skl_run_pipe(ctx, sink_mconfig->pipe); | ||
455 | if (ret) | ||
456 | return ret; | ||
457 | } | ||
458 | |||
459 | path_list = kzalloc( | ||
460 | sizeof(struct skl_dapm_path_list), | ||
461 | GFP_KERNEL); | ||
462 | if (path_list == NULL) | ||
463 | return -ENOMEM; | ||
464 | |||
465 | /* Add connected path to one global list */ | ||
466 | path_list->dapm_path = p; | ||
467 | list_add_tail(&path_list->node, &skl->dapm_path_list); | ||
468 | break; | ||
469 | } | ||
470 | } | ||
471 | |||
472 | /* Start source pipe last after starting all sinks */ | ||
473 | ret = skl_run_pipe(ctx, src_mconfig->pipe); | ||
474 | if (ret) | ||
475 | return ret; | ||
476 | |||
477 | return 0; | ||
478 | } | ||
479 | |||
480 | /* | ||
481 | * in the Post-PMU event of mixer we need to do following: | ||
482 | * - Check if this pipe is running | ||
483 | * - if not, then | ||
484 | * - bind this pipeline to its source pipeline | ||
485 | * if source pipe is already running, this means it is a dynamic | ||
486 | * connection and we need to bind only to that pipe | ||
487 | * - start this pipeline | ||
488 | */ | ||
489 | static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget *w, | ||
490 | struct skl *skl) | ||
491 | { | ||
492 | int ret = 0; | ||
493 | struct snd_soc_dapm_path *p; | ||
494 | struct snd_soc_dapm_widget *source, *sink; | ||
495 | struct skl_module_cfg *src_mconfig, *sink_mconfig; | ||
496 | struct skl_sst *ctx = skl->skl_sst; | ||
497 | int src_pipe_started = 0; | ||
498 | |||
499 | sink = w; | ||
500 | sink_mconfig = sink->priv; | ||
501 | |||
502 | /* | ||
503 | * If source pipe is already started, that means source is driving | ||
504 | * one more sink before this sink got connected, Since source is | ||
505 | * started, bind this sink to source and start this pipe. | ||
506 | */ | ||
507 | snd_soc_dapm_widget_for_each_sink_path(w, p) { | ||
508 | if (!p->connect) | ||
509 | continue; | ||
510 | |||
511 | dev_dbg(ctx->dev, "sink widget=%s\n", w->name); | ||
512 | dev_dbg(ctx->dev, "src widget=%s\n", p->source->name); | ||
513 | |||
514 | /* | ||
515 | * here we will check widgets in sink pipelines, so that | ||
516 | * can be any widgets type and we are only interested if | ||
517 | * they are ones used for SKL so check that first | ||
518 | */ | ||
519 | if ((p->source->priv != NULL) && | ||
520 | is_skl_dsp_widget_type(p->source)) { | ||
521 | source = p->source; | ||
522 | src_mconfig = source->priv; | ||
523 | sink_mconfig = sink->priv; | ||
524 | src_pipe_started = 1; | ||
525 | |||
526 | /* | ||
527 | * check pipe state, then no need to bind or start | ||
528 | * the pipe | ||
529 | */ | ||
530 | if (src_mconfig->pipe->state != SKL_PIPE_STARTED) | ||
531 | src_pipe_started = 0; | ||
532 | } | ||
533 | } | ||
534 | |||
535 | if (src_pipe_started) { | ||
536 | ret = skl_bind_modules(ctx, src_mconfig, sink_mconfig); | ||
537 | if (ret) | ||
538 | return ret; | ||
539 | |||
540 | ret = skl_run_pipe(ctx, sink_mconfig->pipe); | ||
541 | } | ||
542 | |||
543 | return ret; | ||
544 | } | ||
545 | |||
546 | /* | ||
547 | * in the Pre-PMD event of mixer we need to do following: | ||
548 | * - Stop the pipe | ||
549 | * - find the source connections and remove that from dapm_path_list | ||
550 | * - unbind with source pipelines if still connected | ||
551 | */ | ||
552 | static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget *w, | ||
553 | struct skl *skl) | ||
554 | { | ||
555 | struct snd_soc_dapm_widget *source, *sink; | ||
556 | struct skl_module_cfg *src_mconfig, *sink_mconfig; | ||
557 | int ret = 0, path_found = 0; | ||
558 | struct skl_dapm_path_list *path_list, *tmp_list; | ||
559 | struct skl_sst *ctx = skl->skl_sst; | ||
560 | |||
561 | sink = w; | ||
562 | sink_mconfig = sink->priv; | ||
563 | |||
564 | /* Stop the pipe */ | ||
565 | ret = skl_stop_pipe(ctx, sink_mconfig->pipe); | ||
566 | if (ret) | ||
567 | return ret; | ||
568 | |||
569 | /* | ||
570 | * This list, dapm_path_list handling here does not need any locks | ||
571 | * as we are under dapm lock while handling widget events. | ||
572 | * List can be manipulated safely only under dapm widgets handler | ||
573 | * routines | ||
574 | */ | ||
575 | list_for_each_entry_safe(path_list, tmp_list, | ||
576 | &skl->dapm_path_list, node) { | ||
577 | if (path_list->dapm_path->sink == sink) { | ||
578 | dev_dbg(ctx->dev, "Path found = %s\n", | ||
579 | path_list->dapm_path->name); | ||
580 | source = path_list->dapm_path->source; | ||
581 | src_mconfig = source->priv; | ||
582 | path_found = 1; | ||
583 | |||
584 | list_del(&path_list->node); | ||
585 | kfree(path_list); | ||
586 | break; | ||
587 | } | ||
588 | } | ||
589 | |||
590 | /* | ||
591 | * If path_found == 1, that means pmd for source pipe has | ||
592 | * not occurred, source is connected to some other sink. | ||
593 | * so its responsibility of sink to unbind itself from source. | ||
594 | */ | ||
595 | if (path_found) { | ||
596 | ret = skl_stop_pipe(ctx, src_mconfig->pipe); | ||
597 | if (ret < 0) | ||
598 | return ret; | ||
599 | |||
600 | ret = skl_unbind_modules(ctx, src_mconfig, sink_mconfig); | ||
601 | } | ||
602 | |||
603 | return ret; | ||
604 | } | ||
605 | |||
606 | /* | ||
607 | * in the Post-PMD event of mixer we need to do following: | ||
608 | * - Free the mcps used | ||
609 | * - Free the mem used | ||
610 | * - Unbind the modules within the pipeline | ||
611 | * - Delete the pipeline (modules are not required to be explicitly | ||
612 | * deleted, pipeline delete is enough here | ||
613 | */ | ||
614 | static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, | ||
615 | struct skl *skl) | ||
616 | { | ||
617 | struct skl_module_cfg *mconfig = w->priv; | ||
618 | struct skl_pipe_module *w_module; | ||
619 | struct skl_module_cfg *src_module = NULL, *dst_module; | ||
620 | struct skl_sst *ctx = skl->skl_sst; | ||
621 | struct skl_pipe *s_pipe = mconfig->pipe; | ||
622 | int ret = 0; | ||
623 | |||
624 | skl_tplg_free_pipe_mcps(skl, mconfig); | ||
625 | |||
626 | list_for_each_entry(w_module, &s_pipe->w_list, node) { | ||
627 | dst_module = w_module->w->priv; | ||
628 | |||
629 | if (src_module == NULL) { | ||
630 | src_module = dst_module; | ||
631 | continue; | ||
632 | } | ||
633 | |||
634 | ret = skl_unbind_modules(ctx, src_module, dst_module); | ||
635 | if (ret < 0) | ||
636 | return ret; | ||
637 | |||
638 | src_module = dst_module; | ||
639 | } | ||
640 | |||
641 | ret = skl_delete_pipe(ctx, mconfig->pipe); | ||
642 | skl_tplg_free_pipe_mem(skl, mconfig); | ||
643 | |||
644 | return ret; | ||
645 | } | ||
646 | |||
647 | /* | ||
648 | * in the Post-PMD event of PGA we need to do following: | ||
649 | * - Free the mcps used | ||
650 | * - Stop the pipeline | ||
651 | * - In source pipe is connected, unbind with source pipelines | ||
652 | */ | ||
653 | static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, | ||
654 | struct skl *skl) | ||
655 | { | ||
656 | struct snd_soc_dapm_widget *source, *sink; | ||
657 | struct skl_module_cfg *src_mconfig, *sink_mconfig; | ||
658 | int ret = 0, path_found = 0; | ||
659 | struct skl_dapm_path_list *path_list, *tmp_path_list; | ||
660 | struct skl_sst *ctx = skl->skl_sst; | ||
661 | |||
662 | source = w; | ||
663 | src_mconfig = source->priv; | ||
664 | |||
665 | skl_tplg_free_pipe_mcps(skl, src_mconfig); | ||
666 | /* Stop the pipe since this is a mixin module */ | ||
667 | ret = skl_stop_pipe(ctx, src_mconfig->pipe); | ||
668 | if (ret) | ||
669 | return ret; | ||
670 | |||
671 | list_for_each_entry_safe(path_list, tmp_path_list, &skl->dapm_path_list, node) { | ||
672 | if (path_list->dapm_path->source == source) { | ||
673 | dev_dbg(ctx->dev, "Path found = %s\n", | ||
674 | path_list->dapm_path->name); | ||
675 | sink = path_list->dapm_path->sink; | ||
676 | sink_mconfig = sink->priv; | ||
677 | path_found = 1; | ||
678 | |||
679 | list_del(&path_list->node); | ||
680 | kfree(path_list); | ||
681 | break; | ||
682 | } | ||
683 | } | ||
684 | |||
685 | /* | ||
686 | * This is a connector and if path is found that means | ||
687 | * unbind between source and sink has not happened yet | ||
688 | */ | ||
689 | if (path_found) { | ||
690 | ret = skl_stop_pipe(ctx, src_mconfig->pipe); | ||
691 | if (ret < 0) | ||
692 | return ret; | ||
693 | |||
694 | ret = skl_unbind_modules(ctx, src_mconfig, sink_mconfig); | ||
695 | } | ||
696 | |||
697 | return ret; | ||
698 | } | ||
699 | |||
700 | /* | ||
701 | * In modelling, we assume there will be ONLY one mixer in a pipeline. If | ||
702 | * mixer is not required then it is treated as static mixer aka vmixer with | ||
703 | * a hard path to source module | ||
704 | * So we don't need to check if source is started or not as hard path puts | ||
705 | * dependency on each other | ||
706 | */ | ||
707 | static int skl_tplg_vmixer_event(struct snd_soc_dapm_widget *w, | ||
708 | struct snd_kcontrol *k, int event) | ||
709 | { | ||
710 | struct snd_soc_dapm_context *dapm = w->dapm; | ||
711 | struct skl *skl = get_skl_ctx(dapm->dev); | ||
712 | |||
713 | switch (event) { | ||
714 | case SND_SOC_DAPM_PRE_PMU: | ||
715 | return skl_tplg_mixer_dapm_pre_pmu_event(w, skl); | ||
716 | |||
717 | case SND_SOC_DAPM_POST_PMD: | ||
718 | return skl_tplg_mixer_dapm_post_pmd_event(w, skl); | ||
719 | } | ||
720 | |||
721 | return 0; | ||
722 | } | ||
723 | |||
724 | /* | ||
725 | * In modelling, we assume there will be ONLY one mixer in a pipeline. If a | ||
726 | * second one is required that is created as another pipe entity. | ||
727 | * The mixer is responsible for pipe management and represent a pipeline | ||
728 | * instance | ||
729 | */ | ||
730 | static int skl_tplg_mixer_event(struct snd_soc_dapm_widget *w, | ||
731 | struct snd_kcontrol *k, int event) | ||
732 | { | ||
733 | struct snd_soc_dapm_context *dapm = w->dapm; | ||
734 | struct skl *skl = get_skl_ctx(dapm->dev); | ||
735 | |||
736 | switch (event) { | ||
737 | case SND_SOC_DAPM_PRE_PMU: | ||
738 | return skl_tplg_mixer_dapm_pre_pmu_event(w, skl); | ||
739 | |||
740 | case SND_SOC_DAPM_POST_PMU: | ||
741 | return skl_tplg_mixer_dapm_post_pmu_event(w, skl); | ||
742 | |||
743 | case SND_SOC_DAPM_PRE_PMD: | ||
744 | return skl_tplg_mixer_dapm_pre_pmd_event(w, skl); | ||
745 | |||
746 | case SND_SOC_DAPM_POST_PMD: | ||
747 | return skl_tplg_mixer_dapm_post_pmd_event(w, skl); | ||
748 | } | ||
749 | |||
750 | return 0; | ||
751 | } | ||
752 | |||
753 | /* | ||
754 | * In modelling, we assumed rest of the modules in pipeline are PGA. But we | ||
755 | * are interested in last PGA (leaf PGA) in a pipeline to disconnect with | ||
756 | * the sink when it is running (two FE to one BE or one FE to two BE) | ||
757 | * scenarios | ||
758 | */ | ||
759 | static int skl_tplg_pga_event(struct snd_soc_dapm_widget *w, | ||
760 | struct snd_kcontrol *k, int event) | ||
761 | |||
762 | { | ||
763 | struct snd_soc_dapm_context *dapm = w->dapm; | ||
764 | struct skl *skl = get_skl_ctx(dapm->dev); | ||
765 | |||
766 | switch (event) { | ||
767 | case SND_SOC_DAPM_PRE_PMU: | ||
768 | return skl_tplg_pga_dapm_pre_pmu_event(w, skl); | ||
769 | |||
770 | case SND_SOC_DAPM_POST_PMD: | ||
771 | return skl_tplg_pga_dapm_post_pmd_event(w, skl); | ||
772 | } | ||
773 | |||
774 | return 0; | ||
775 | } | ||
776 | |||
777 | /* | ||
778 | * The FE params are passed by hw_params of the DAI. | ||
779 | * On hw_params, the params are stored in Gateway module of the FE and we | ||
780 | * need to calculate the format in DSP module configuration, that | ||
781 | * conversion is done here | ||
782 | */ | ||
783 | int skl_tplg_update_pipe_params(struct device *dev, | ||
784 | struct skl_module_cfg *mconfig, | ||
785 | struct skl_pipe_params *params) | ||
786 | { | ||
787 | struct skl_pipe *pipe = mconfig->pipe; | ||
788 | struct skl_module_fmt *format = NULL; | ||
789 | |||
790 | memcpy(pipe->p_params, params, sizeof(*params)); | ||
791 | |||
792 | if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
793 | format = &mconfig->in_fmt; | ||
794 | else | ||
795 | format = &mconfig->out_fmt; | ||
796 | |||
797 | /* set the hw_params */ | ||
798 | format->s_freq = params->s_freq; | ||
799 | format->channels = params->ch; | ||
800 | format->valid_bit_depth = skl_get_bit_depth(params->s_fmt); | ||
801 | |||
802 | /* | ||
803 | * 16 bit is 16 bit container whereas 24 bit is in 32 bit | ||
804 | * container so update bit depth accordingly | ||
805 | */ | ||
806 | switch (format->valid_bit_depth) { | ||
807 | case SKL_DEPTH_16BIT: | ||
808 | format->bit_depth = format->valid_bit_depth; | ||
809 | break; | ||
810 | |||
811 | case SKL_DEPTH_24BIT: | ||
812 | format->bit_depth = SKL_DEPTH_32BIT; | ||
813 | break; | ||
814 | |||
815 | default: | ||
816 | dev_err(dev, "Invalid bit depth %x for pipe\n", | ||
817 | format->valid_bit_depth); | ||
818 | return -EINVAL; | ||
819 | } | ||
820 | |||
821 | if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
822 | mconfig->ibs = (format->s_freq / 1000) * | ||
823 | (format->channels) * | ||
824 | (format->bit_depth >> 3); | ||
825 | } else { | ||
826 | mconfig->obs = (format->s_freq / 1000) * | ||
827 | (format->channels) * | ||
828 | (format->bit_depth >> 3); | ||
829 | } | ||
830 | |||
831 | return 0; | ||
832 | } | ||
833 | |||
834 | /* | ||
835 | * Query the module config for the FE DAI | ||
836 | * This is used to find the hw_params set for that DAI and apply to FE | ||
837 | * pipeline | ||
838 | */ | ||
839 | struct skl_module_cfg * | ||
840 | skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream) | ||
841 | { | ||
842 | struct snd_soc_dapm_widget *w; | ||
843 | struct snd_soc_dapm_path *p = NULL; | ||
844 | |||
845 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
846 | w = dai->playback_widget; | ||
847 | snd_soc_dapm_widget_for_each_sink_path(w, p) { | ||
848 | if (p->connect && p->sink->power && | ||
849 | is_skl_dsp_widget_type(p->sink)) | ||
850 | continue; | ||
851 | |||
852 | if (p->sink->priv) { | ||
853 | dev_dbg(dai->dev, "set params for %s\n", | ||
854 | p->sink->name); | ||
855 | return p->sink->priv; | ||
856 | } | ||
857 | } | ||
858 | } else { | ||
859 | w = dai->capture_widget; | ||
860 | snd_soc_dapm_widget_for_each_source_path(w, p) { | ||
861 | if (p->connect && p->source->power && | ||
862 | is_skl_dsp_widget_type(p->source)) | ||
863 | continue; | ||
864 | |||
865 | if (p->source->priv) { | ||
866 | dev_dbg(dai->dev, "set params for %s\n", | ||
867 | p->source->name); | ||
868 | return p->source->priv; | ||
869 | } | ||
870 | } | ||
871 | } | ||
872 | |||
873 | return NULL; | ||
874 | } | ||
875 | |||
876 | static u8 skl_tplg_be_link_type(int dev_type) | ||
877 | { | ||
878 | int ret; | ||
879 | |||
880 | switch (dev_type) { | ||
881 | case SKL_DEVICE_BT: | ||
882 | ret = NHLT_LINK_SSP; | ||
883 | break; | ||
884 | |||
885 | case SKL_DEVICE_DMIC: | ||
886 | ret = NHLT_LINK_DMIC; | ||
887 | break; | ||
888 | |||
889 | case SKL_DEVICE_I2S: | ||
890 | ret = NHLT_LINK_SSP; | ||
891 | break; | ||
892 | |||
893 | case SKL_DEVICE_HDALINK: | ||
894 | ret = NHLT_LINK_HDA; | ||
895 | break; | ||
896 | |||
897 | default: | ||
898 | ret = NHLT_LINK_INVALID; | ||
899 | break; | ||
900 | } | ||
901 | |||
902 | return ret; | ||
903 | } | ||
904 | |||
905 | /* | ||
906 | * Fill the BE gateway parameters | ||
907 | * The BE gateway expects a blob of parameters which are kept in the ACPI | ||
908 | * NHLT blob, so query the blob for interface type (i2s/pdm) and instance. | ||
909 | * The port can have multiple settings so pick based on the PCM | ||
910 | * parameters | ||
911 | */ | ||
912 | static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai *dai, | ||
913 | struct skl_module_cfg *mconfig, | ||
914 | struct skl_pipe_params *params) | ||
915 | { | ||
916 | struct skl_pipe *pipe = mconfig->pipe; | ||
917 | struct nhlt_specific_cfg *cfg; | ||
918 | struct skl *skl = get_skl_ctx(dai->dev); | ||
919 | int link_type = skl_tplg_be_link_type(mconfig->dev_type); | ||
920 | |||
921 | memcpy(pipe->p_params, params, sizeof(*params)); | ||
922 | |||
923 | /* update the blob based on virtual bus_id*/ | ||
924 | cfg = skl_get_ep_blob(skl, mconfig->vbus_id, link_type, | ||
925 | params->s_fmt, params->ch, | ||
926 | params->s_freq, params->stream); | ||
927 | if (cfg) { | ||
928 | mconfig->formats_config.caps_size = cfg->size; | ||
929 | mconfig->formats_config.caps = (u32 *) &cfg->caps; | ||
930 | } else { | ||
931 | dev_err(dai->dev, "Blob NULL for id %x type %d dirn %d\n", | ||
932 | mconfig->vbus_id, link_type, | ||
933 | params->stream); | ||
934 | dev_err(dai->dev, "PCM: ch %d, freq %d, fmt %d\n", | ||
935 | params->ch, params->s_freq, params->s_fmt); | ||
936 | return -EINVAL; | ||
937 | } | ||
938 | |||
939 | return 0; | ||
940 | } | ||
941 | |||
942 | static int skl_tplg_be_set_src_pipe_params(struct snd_soc_dai *dai, | ||
943 | struct snd_soc_dapm_widget *w, | ||
944 | struct skl_pipe_params *params) | ||
945 | { | ||
946 | struct snd_soc_dapm_path *p; | ||
947 | int ret = -EIO; | ||
948 | |||
949 | snd_soc_dapm_widget_for_each_source_path(w, p) { | ||
950 | if (p->connect && is_skl_dsp_widget_type(p->source) && | ||
951 | p->source->priv) { | ||
952 | |||
953 | if (!p->source->power) { | ||
954 | ret = skl_tplg_be_fill_pipe_params( | ||
955 | dai, p->source->priv, | ||
956 | params); | ||
957 | if (ret < 0) | ||
958 | return ret; | ||
959 | } else { | ||
960 | return -EBUSY; | ||
961 | } | ||
962 | } else { | ||
963 | ret = skl_tplg_be_set_src_pipe_params( | ||
964 | dai, p->source, params); | ||
965 | if (ret < 0) | ||
966 | return ret; | ||
967 | } | ||
968 | } | ||
969 | |||
970 | return ret; | ||
971 | } | ||
972 | |||
973 | static int skl_tplg_be_set_sink_pipe_params(struct snd_soc_dai *dai, | ||
974 | struct snd_soc_dapm_widget *w, struct skl_pipe_params *params) | ||
975 | { | ||
976 | struct snd_soc_dapm_path *p = NULL; | ||
977 | int ret = -EIO; | ||
978 | |||
979 | snd_soc_dapm_widget_for_each_sink_path(w, p) { | ||
980 | if (p->connect && is_skl_dsp_widget_type(p->sink) && | ||
981 | p->sink->priv) { | ||
982 | |||
983 | if (!p->sink->power) { | ||
984 | ret = skl_tplg_be_fill_pipe_params( | ||
985 | dai, p->sink->priv, params); | ||
986 | if (ret < 0) | ||
987 | return ret; | ||
988 | } else { | ||
989 | return -EBUSY; | ||
990 | } | ||
991 | |||
992 | } else { | ||
993 | ret = skl_tplg_be_set_sink_pipe_params( | ||
994 | dai, p->sink, params); | ||
995 | if (ret < 0) | ||
996 | return ret; | ||
997 | } | ||
998 | } | ||
999 | |||
1000 | return ret; | ||
1001 | } | ||
1002 | |||
1003 | /* | ||
1004 | * BE hw_params can be a source parameters (capture) or sink parameters | ||
1005 | * (playback). Based on sink and source we need to either find the source | ||
1006 | * list or the sink list and set the pipeline parameters | ||
1007 | */ | ||
1008 | int skl_tplg_be_update_params(struct snd_soc_dai *dai, | ||
1009 | struct skl_pipe_params *params) | ||
1010 | { | ||
1011 | struct snd_soc_dapm_widget *w; | ||
1012 | |||
1013 | if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
1014 | w = dai->playback_widget; | ||
1015 | |||
1016 | return skl_tplg_be_set_src_pipe_params(dai, w, params); | ||
1017 | |||
1018 | } else { | ||
1019 | w = dai->capture_widget; | ||
1020 | |||
1021 | return skl_tplg_be_set_sink_pipe_params(dai, w, params); | ||
1022 | } | ||
1023 | |||
1024 | return 0; | ||
1025 | } | ||
1026 | |||
1027 | static const struct snd_soc_tplg_widget_events skl_tplg_widget_ops[] = { | ||
1028 | {SKL_MIXER_EVENT, skl_tplg_mixer_event}, | ||
1029 | {SKL_VMIXER_EVENT, skl_tplg_vmixer_event}, | ||
1030 | {SKL_PGA_EVENT, skl_tplg_pga_event}, | ||
1031 | }; | ||
1032 | |||
1033 | /* | ||
1034 | * The topology binary passes the pin info for a module so initialize the pin | ||
1035 | * info passed into module instance | ||
1036 | */ | ||
1037 | static void skl_fill_module_pin_info(struct skl_dfw_module_pin *dfw_pin, | ||
1038 | struct skl_module_pin *m_pin, | ||
1039 | bool is_dynamic, int max_pin) | ||
1040 | { | ||
1041 | int i; | ||
1042 | |||
1043 | for (i = 0; i < max_pin; i++) { | ||
1044 | m_pin[i].id.module_id = dfw_pin[i].module_id; | ||
1045 | m_pin[i].id.instance_id = dfw_pin[i].instance_id; | ||
1046 | m_pin[i].in_use = false; | ||
1047 | m_pin[i].is_dynamic = is_dynamic; | ||
1048 | } | ||
1049 | } | ||
1050 | |||
1051 | /* | ||
1052 | * Add pipeline from topology binary into driver pipeline list | ||
1053 | * | ||
1054 | * If already added we return that instance | ||
1055 | * Otherwise we create a new instance and add into driver list | ||
1056 | */ | ||
1057 | static struct skl_pipe *skl_tplg_add_pipe(struct device *dev, | ||
1058 | struct skl *skl, struct skl_dfw_pipe *dfw_pipe) | ||
1059 | { | ||
1060 | struct skl_pipeline *ppl; | ||
1061 | struct skl_pipe *pipe; | ||
1062 | struct skl_pipe_params *params; | ||
1063 | |||
1064 | list_for_each_entry(ppl, &skl->ppl_list, node) { | ||
1065 | if (ppl->pipe->ppl_id == dfw_pipe->pipe_id) | ||
1066 | return ppl->pipe; | ||
1067 | } | ||
1068 | |||
1069 | ppl = devm_kzalloc(dev, sizeof(*ppl), GFP_KERNEL); | ||
1070 | if (!ppl) | ||
1071 | return NULL; | ||
1072 | |||
1073 | pipe = devm_kzalloc(dev, sizeof(*pipe), GFP_KERNEL); | ||
1074 | if (!pipe) | ||
1075 | return NULL; | ||
1076 | |||
1077 | params = devm_kzalloc(dev, sizeof(*params), GFP_KERNEL); | ||
1078 | if (!params) | ||
1079 | return NULL; | ||
1080 | |||
1081 | pipe->ppl_id = dfw_pipe->pipe_id; | ||
1082 | pipe->memory_pages = dfw_pipe->memory_pages; | ||
1083 | pipe->pipe_priority = dfw_pipe->pipe_priority; | ||
1084 | pipe->conn_type = dfw_pipe->conn_type; | ||
1085 | pipe->state = SKL_PIPE_INVALID; | ||
1086 | pipe->p_params = params; | ||
1087 | INIT_LIST_HEAD(&pipe->w_list); | ||
1088 | |||
1089 | ppl->pipe = pipe; | ||
1090 | list_add(&ppl->node, &skl->ppl_list); | ||
1091 | |||
1092 | return ppl->pipe; | ||
1093 | } | ||
1094 | |||
1095 | /* | ||
1096 | * Topology core widget load callback | ||
1097 | * | ||
1098 | * This is used to save the private data for each widget which gives | ||
1099 | * information to the driver about module and pipeline parameters which DSP | ||
1100 | * FW expects like ids, resource values, formats etc | ||
1101 | */ | ||
1102 | static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, | ||
1103 | struct snd_soc_dapm_widget *w, | ||
1104 | struct snd_soc_tplg_dapm_widget *tplg_w) | ||
1105 | { | ||
1106 | int ret; | ||
1107 | struct hdac_ext_bus *ebus = snd_soc_component_get_drvdata(cmpnt); | ||
1108 | struct skl *skl = ebus_to_skl(ebus); | ||
1109 | struct hdac_bus *bus = ebus_to_hbus(ebus); | ||
1110 | struct skl_module_cfg *mconfig; | ||
1111 | struct skl_pipe *pipe; | ||
1112 | struct skl_dfw_module *dfw_config = | ||
1113 | (struct skl_dfw_module *)tplg_w->priv.data; | ||
1114 | |||
1115 | if (!tplg_w->priv.size) | ||
1116 | goto bind_event; | ||
1117 | |||
1118 | mconfig = devm_kzalloc(bus->dev, sizeof(*mconfig), GFP_KERNEL); | ||
1119 | |||
1120 | if (!mconfig) | ||
1121 | return -ENOMEM; | ||
1122 | |||
1123 | w->priv = mconfig; | ||
1124 | mconfig->id.module_id = dfw_config->module_id; | ||
1125 | mconfig->id.instance_id = dfw_config->instance_id; | ||
1126 | mconfig->mcps = dfw_config->max_mcps; | ||
1127 | mconfig->ibs = dfw_config->ibs; | ||
1128 | mconfig->obs = dfw_config->obs; | ||
1129 | mconfig->core_id = dfw_config->core_id; | ||
1130 | mconfig->max_in_queue = dfw_config->max_in_queue; | ||
1131 | mconfig->max_out_queue = dfw_config->max_out_queue; | ||
1132 | mconfig->is_loadable = dfw_config->is_loadable; | ||
1133 | mconfig->in_fmt.channels = dfw_config->in_fmt.channels; | ||
1134 | mconfig->in_fmt.s_freq = dfw_config->in_fmt.freq; | ||
1135 | mconfig->in_fmt.bit_depth = dfw_config->in_fmt.bit_depth; | ||
1136 | mconfig->in_fmt.valid_bit_depth = | ||
1137 | dfw_config->in_fmt.valid_bit_depth; | ||
1138 | mconfig->in_fmt.ch_cfg = dfw_config->in_fmt.ch_cfg; | ||
1139 | mconfig->out_fmt.channels = dfw_config->out_fmt.channels; | ||
1140 | mconfig->out_fmt.s_freq = dfw_config->out_fmt.freq; | ||
1141 | mconfig->out_fmt.bit_depth = dfw_config->out_fmt.bit_depth; | ||
1142 | mconfig->out_fmt.valid_bit_depth = | ||
1143 | dfw_config->out_fmt.valid_bit_depth; | ||
1144 | mconfig->out_fmt.ch_cfg = dfw_config->out_fmt.ch_cfg; | ||
1145 | mconfig->params_fixup = dfw_config->params_fixup; | ||
1146 | mconfig->converter = dfw_config->converter; | ||
1147 | mconfig->m_type = dfw_config->module_type; | ||
1148 | mconfig->vbus_id = dfw_config->vbus_id; | ||
1149 | |||
1150 | pipe = skl_tplg_add_pipe(bus->dev, skl, &dfw_config->pipe); | ||
1151 | if (pipe) | ||
1152 | mconfig->pipe = pipe; | ||
1153 | |||
1154 | mconfig->dev_type = dfw_config->dev_type; | ||
1155 | mconfig->hw_conn_type = dfw_config->hw_conn_type; | ||
1156 | mconfig->time_slot = dfw_config->time_slot; | ||
1157 | mconfig->formats_config.caps_size = dfw_config->caps.caps_size; | ||
1158 | |||
1159 | mconfig->m_in_pin = devm_kzalloc(bus->dev, | ||
1160 | (mconfig->max_in_queue) * | ||
1161 | sizeof(*mconfig->m_in_pin), | ||
1162 | GFP_KERNEL); | ||
1163 | if (!mconfig->m_in_pin) | ||
1164 | return -ENOMEM; | ||
1165 | |||
1166 | mconfig->m_out_pin = devm_kzalloc(bus->dev, (mconfig->max_out_queue) * | ||
1167 | sizeof(*mconfig->m_out_pin), | ||
1168 | GFP_KERNEL); | ||
1169 | if (!mconfig->m_out_pin) | ||
1170 | return -ENOMEM; | ||
1171 | |||
1172 | skl_fill_module_pin_info(dfw_config->in_pin, mconfig->m_in_pin, | ||
1173 | dfw_config->is_dynamic_in_pin, | ||
1174 | mconfig->max_in_queue); | ||
1175 | |||
1176 | skl_fill_module_pin_info(dfw_config->out_pin, mconfig->m_out_pin, | ||
1177 | dfw_config->is_dynamic_out_pin, | ||
1178 | mconfig->max_out_queue); | ||
1179 | |||
1180 | |||
1181 | if (mconfig->formats_config.caps_size == 0) | ||
1182 | goto bind_event; | ||
1183 | |||
1184 | mconfig->formats_config.caps = (u32 *)devm_kzalloc(bus->dev, | ||
1185 | mconfig->formats_config.caps_size, GFP_KERNEL); | ||
1186 | |||
1187 | if (mconfig->formats_config.caps == NULL) | ||
1188 | return -ENOMEM; | ||
1189 | |||
1190 | memcpy(mconfig->formats_config.caps, dfw_config->caps.caps, | ||
1191 | dfw_config->caps.caps_size); | ||
1192 | |||
1193 | bind_event: | ||
1194 | if (tplg_w->event_type == 0) { | ||
1195 | dev_dbg(bus->dev, "ASoC: No event handler required\n"); | ||
1196 | return 0; | ||
1197 | } | ||
1198 | |||
1199 | ret = snd_soc_tplg_widget_bind_event(w, skl_tplg_widget_ops, | ||
1200 | ARRAY_SIZE(skl_tplg_widget_ops), | ||
1201 | tplg_w->event_type); | ||
1202 | |||
1203 | if (ret) { | ||
1204 | dev_err(bus->dev, "%s: No matching event handlers found for %d\n", | ||
1205 | __func__, tplg_w->event_type); | ||
1206 | return -EINVAL; | ||
1207 | } | ||
1208 | |||
1209 | return 0; | ||
1210 | } | ||
1211 | |||
1212 | static struct snd_soc_tplg_ops skl_tplg_ops = { | ||
1213 | .widget_load = skl_tplg_widget_load, | ||
1214 | }; | ||
1215 | |||
1216 | /* This will be read from topology manifest, currently defined here */ | ||
1217 | #define SKL_MAX_MCPS 30000000 | ||
1218 | #define SKL_FW_MAX_MEM 1000000 | ||
1219 | |||
1220 | /* | ||
1221 | * SKL topology init routine | ||
1222 | */ | ||
1223 | int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) | ||
1224 | { | ||
1225 | int ret; | ||
1226 | const struct firmware *fw; | ||
1227 | struct hdac_bus *bus = ebus_to_hbus(ebus); | ||
1228 | struct skl *skl = ebus_to_skl(ebus); | ||
1229 | |||
1230 | ret = request_firmware(&fw, "dfw_sst.bin", bus->dev); | ||
1231 | if (ret < 0) { | ||
1232 | dev_err(bus->dev, "tplg fw %s load failed with %d\n", | ||
1233 | "dfw_sst.bin", ret); | ||
1234 | return ret; | ||
1235 | } | ||
1236 | |||
1237 | /* | ||
1238 | * The complete tplg for SKL is loaded as index 0, we don't use | ||
1239 | * any other index | ||
1240 | */ | ||
1241 | ret = snd_soc_tplg_component_load(&platform->component, | ||
1242 | &skl_tplg_ops, fw, 0); | ||
1243 | if (ret < 0) { | ||
1244 | dev_err(bus->dev, "tplg component load failed%d\n", ret); | ||
1245 | return -EINVAL; | ||
1246 | } | ||
1247 | |||
1248 | skl->resource.max_mcps = SKL_MAX_MCPS; | ||
1249 | skl->resource.max_mem = SKL_FW_MAX_MEM; | ||
1250 | |||
1251 | return 0; | ||
1252 | } | ||
diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index 8c7767baa94f..76053a8de41c 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h | |||
@@ -129,6 +129,11 @@ struct skl_src_module_cfg { | |||
129 | enum skl_s_freq src_cfg; | 129 | enum skl_s_freq src_cfg; |
130 | } __packed; | 130 | } __packed; |
131 | 131 | ||
132 | struct notification_mask { | ||
133 | u32 notify; | ||
134 | u32 enable; | ||
135 | } __packed; | ||
136 | |||
132 | struct skl_up_down_mixer_cfg { | 137 | struct skl_up_down_mixer_cfg { |
133 | struct skl_base_cfg base_cfg; | 138 | struct skl_base_cfg base_cfg; |
134 | enum skl_ch_cfg out_ch_cfg; | 139 | enum skl_ch_cfg out_ch_cfg; |
@@ -153,8 +158,7 @@ enum skl_dma_type { | |||
153 | union skl_ssp_dma_node { | 158 | union skl_ssp_dma_node { |
154 | u8 val; | 159 | u8 val; |
155 | struct { | 160 | struct { |
156 | u8 dual_mono:1; | 161 | u8 time_slot_index:4; |
157 | u8 time_slot:3; | ||
158 | u8 i2s_instance:4; | 162 | u8 i2s_instance:4; |
159 | } dma_node; | 163 | } dma_node; |
160 | }; | 164 | }; |
@@ -263,6 +267,34 @@ struct skl_module_cfg { | |||
263 | struct skl_specific_cfg formats_config; | 267 | struct skl_specific_cfg formats_config; |
264 | }; | 268 | }; |
265 | 269 | ||
270 | struct skl_pipeline { | ||
271 | struct skl_pipe *pipe; | ||
272 | struct list_head node; | ||
273 | }; | ||
274 | |||
275 | struct skl_dapm_path_list { | ||
276 | struct snd_soc_dapm_path *dapm_path; | ||
277 | struct list_head node; | ||
278 | }; | ||
279 | |||
280 | static inline struct skl *get_skl_ctx(struct device *dev) | ||
281 | { | ||
282 | struct hdac_ext_bus *ebus = dev_get_drvdata(dev); | ||
283 | |||
284 | return ebus_to_skl(ebus); | ||
285 | } | ||
286 | |||
287 | int skl_tplg_be_update_params(struct snd_soc_dai *dai, | ||
288 | struct skl_pipe_params *params); | ||
289 | void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai, | ||
290 | struct skl_pipe_params *params, int stream); | ||
291 | int skl_tplg_init(struct snd_soc_platform *platform, | ||
292 | struct hdac_ext_bus *ebus); | ||
293 | struct skl_module_cfg *skl_tplg_fe_get_cpr_module( | ||
294 | struct snd_soc_dai *dai, int stream); | ||
295 | int skl_tplg_update_pipe_params(struct device *dev, | ||
296 | struct skl_module_cfg *mconfig, struct skl_pipe_params *params); | ||
297 | |||
266 | int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe); | 298 | int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe); |
267 | 299 | ||
268 | int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe); | 300 | int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe); |
diff --git a/sound/soc/intel/skylake/skl-tplg-interface.h b/sound/soc/intel/skylake/skl-tplg-interface.h index a50689825bca..2bc396d54cbe 100644 --- a/sound/soc/intel/skylake/skl-tplg-interface.h +++ b/sound/soc/intel/skylake/skl-tplg-interface.h | |||
@@ -19,6 +19,29 @@ | |||
19 | #ifndef __HDA_TPLG_INTERFACE_H__ | 19 | #ifndef __HDA_TPLG_INTERFACE_H__ |
20 | #define __HDA_TPLG_INTERFACE_H__ | 20 | #define __HDA_TPLG_INTERFACE_H__ |
21 | 21 | ||
22 | /* | ||
23 | * Default types range from 0~12. type can range from 0 to 0xff | ||
24 | * SST types start at higher to avoid any overlapping in future | ||
25 | */ | ||
26 | #define SOC_CONTROL_TYPE_HDA_SST_ALGO_PARAMS 0x100 | ||
27 | #define SOC_CONTROL_TYPE_HDA_SST_MUX 0x101 | ||
28 | #define SOC_CONTROL_TYPE_HDA_SST_MIX 0x101 | ||
29 | #define SOC_CONTROL_TYPE_HDA_SST_BYTE 0x103 | ||
30 | |||
31 | #define HDA_SST_CFG_MAX 900 /* size of copier cfg*/ | ||
32 | #define MAX_IN_QUEUE 8 | ||
33 | #define MAX_OUT_QUEUE 8 | ||
34 | |||
35 | /* Event types goes here */ | ||
36 | /* Reserve event type 0 for no event handlers */ | ||
37 | enum skl_event_types { | ||
38 | SKL_EVENT_NONE = 0, | ||
39 | SKL_MIXER_EVENT, | ||
40 | SKL_MUX_EVENT, | ||
41 | SKL_VMIXER_EVENT, | ||
42 | SKL_PGA_EVENT | ||
43 | }; | ||
44 | |||
22 | /** | 45 | /** |
23 | * enum skl_ch_cfg - channel configuration | 46 | * enum skl_ch_cfg - channel configuration |
24 | * | 47 | * |
@@ -83,6 +106,66 @@ enum skl_dev_type { | |||
83 | SKL_DEVICE_I2S = 0x2, | 106 | SKL_DEVICE_I2S = 0x2, |
84 | SKL_DEVICE_SLIMBUS = 0x3, | 107 | SKL_DEVICE_SLIMBUS = 0x3, |
85 | SKL_DEVICE_HDALINK = 0x4, | 108 | SKL_DEVICE_HDALINK = 0x4, |
109 | SKL_DEVICE_HDAHOST = 0x5, | ||
86 | SKL_DEVICE_NONE | 110 | SKL_DEVICE_NONE |
87 | }; | 111 | }; |
112 | |||
113 | struct skl_dfw_module_pin { | ||
114 | u16 module_id; | ||
115 | u16 instance_id; | ||
116 | } __packed; | ||
117 | |||
118 | struct skl_dfw_module_fmt { | ||
119 | u32 channels; | ||
120 | u32 freq; | ||
121 | u32 bit_depth; | ||
122 | u32 valid_bit_depth; | ||
123 | u32 ch_cfg; | ||
124 | } __packed; | ||
125 | |||
126 | struct skl_dfw_module_caps { | ||
127 | u32 caps_size; | ||
128 | u32 caps[HDA_SST_CFG_MAX]; | ||
129 | }; | ||
130 | |||
131 | struct skl_dfw_pipe { | ||
132 | u8 pipe_id; | ||
133 | u8 pipe_priority; | ||
134 | u16 conn_type; | ||
135 | u32 memory_pages; | ||
136 | } __packed; | ||
137 | |||
138 | struct skl_dfw_module { | ||
139 | u16 module_id; | ||
140 | u16 instance_id; | ||
141 | u32 max_mcps; | ||
142 | u8 core_id; | ||
143 | u8 max_in_queue; | ||
144 | u8 max_out_queue; | ||
145 | u8 is_loadable; | ||
146 | u8 conn_type; | ||
147 | u8 dev_type; | ||
148 | u8 hw_conn_type; | ||
149 | u8 time_slot; | ||
150 | u32 obs; | ||
151 | u32 ibs; | ||
152 | u32 params_fixup; | ||
153 | u32 converter; | ||
154 | u32 module_type; | ||
155 | u32 vbus_id; | ||
156 | u8 is_dynamic_in_pin; | ||
157 | u8 is_dynamic_out_pin; | ||
158 | struct skl_dfw_pipe pipe; | ||
159 | struct skl_dfw_module_fmt in_fmt; | ||
160 | struct skl_dfw_module_fmt out_fmt; | ||
161 | struct skl_dfw_module_pin in_pin[MAX_IN_QUEUE]; | ||
162 | struct skl_dfw_module_pin out_pin[MAX_OUT_QUEUE]; | ||
163 | struct skl_dfw_module_caps caps; | ||
164 | } __packed; | ||
165 | |||
166 | struct skl_dfw_algo_data { | ||
167 | u32 max; | ||
168 | char *params; | ||
169 | } __packed; | ||
170 | |||
88 | #endif | 171 | #endif |
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 348d094e81d6..5319529aedf7 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c | |||
@@ -166,12 +166,20 @@ static int skl_runtime_suspend(struct device *dev) | |||
166 | struct pci_dev *pci = to_pci_dev(dev); | 166 | struct pci_dev *pci = to_pci_dev(dev); |
167 | struct hdac_ext_bus *ebus = pci_get_drvdata(pci); | 167 | struct hdac_ext_bus *ebus = pci_get_drvdata(pci); |
168 | struct hdac_bus *bus = ebus_to_hbus(ebus); | 168 | struct hdac_bus *bus = ebus_to_hbus(ebus); |
169 | struct skl *skl = ebus_to_skl(ebus); | ||
170 | int ret; | ||
169 | 171 | ||
170 | dev_dbg(bus->dev, "in %s\n", __func__); | 172 | dev_dbg(bus->dev, "in %s\n", __func__); |
171 | 173 | ||
172 | /* enable controller wake up event */ | 174 | /* enable controller wake up event */ |
173 | snd_hdac_chip_updatew(bus, WAKEEN, 0, STATESTS_INT_MASK); | 175 | snd_hdac_chip_updatew(bus, WAKEEN, 0, STATESTS_INT_MASK); |
174 | 176 | ||
177 | snd_hdac_ext_bus_link_power_down_all(ebus); | ||
178 | |||
179 | ret = skl_suspend_dsp(skl); | ||
180 | if (ret < 0) | ||
181 | return ret; | ||
182 | |||
175 | snd_hdac_bus_stop_chip(bus); | 183 | snd_hdac_bus_stop_chip(bus); |
176 | snd_hdac_bus_enter_link_reset(bus); | 184 | snd_hdac_bus_enter_link_reset(bus); |
177 | 185 | ||
@@ -183,7 +191,7 @@ static int skl_runtime_resume(struct device *dev) | |||
183 | struct pci_dev *pci = to_pci_dev(dev); | 191 | struct pci_dev *pci = to_pci_dev(dev); |
184 | struct hdac_ext_bus *ebus = pci_get_drvdata(pci); | 192 | struct hdac_ext_bus *ebus = pci_get_drvdata(pci); |
185 | struct hdac_bus *bus = ebus_to_hbus(ebus); | 193 | struct hdac_bus *bus = ebus_to_hbus(ebus); |
186 | struct skl *hda = ebus_to_skl(ebus); | 194 | struct skl *skl = ebus_to_skl(ebus); |
187 | int status; | 195 | int status; |
188 | 196 | ||
189 | dev_dbg(bus->dev, "in %s\n", __func__); | 197 | dev_dbg(bus->dev, "in %s\n", __func__); |
@@ -191,12 +199,12 @@ static int skl_runtime_resume(struct device *dev) | |||
191 | /* Read STATESTS before controller reset */ | 199 | /* Read STATESTS before controller reset */ |
192 | status = snd_hdac_chip_readw(bus, STATESTS); | 200 | status = snd_hdac_chip_readw(bus, STATESTS); |
193 | 201 | ||
194 | skl_init_pci(hda); | 202 | skl_init_pci(skl); |
195 | snd_hdac_bus_init_chip(bus, true); | 203 | snd_hdac_bus_init_chip(bus, true); |
196 | /* disable controller Wake Up event */ | 204 | /* disable controller Wake Up event */ |
197 | snd_hdac_chip_updatew(bus, WAKEEN, STATESTS_INT_MASK, 0); | 205 | snd_hdac_chip_updatew(bus, WAKEEN, STATESTS_INT_MASK, 0); |
198 | 206 | ||
199 | return 0; | 207 | return skl_resume_dsp(skl); |
200 | } | 208 | } |
201 | #endif /* CONFIG_PM */ | 209 | #endif /* CONFIG_PM */ |
202 | 210 | ||
@@ -453,21 +461,28 @@ static int skl_probe(struct pci_dev *pci, | |||
453 | if (err < 0) | 461 | if (err < 0) |
454 | goto out_free; | 462 | goto out_free; |
455 | 463 | ||
464 | skl->nhlt = skl_nhlt_init(bus->dev); | ||
465 | |||
466 | if (skl->nhlt == NULL) | ||
467 | goto out_free; | ||
468 | |||
456 | pci_set_drvdata(skl->pci, ebus); | 469 | pci_set_drvdata(skl->pci, ebus); |
457 | 470 | ||
458 | /* check if dsp is there */ | 471 | /* check if dsp is there */ |
459 | if (ebus->ppcap) { | 472 | if (ebus->ppcap) { |
460 | /* TODO register with dsp IPC */ | 473 | err = skl_init_dsp(skl); |
461 | dev_dbg(bus->dev, "Register dsp\n"); | 474 | if (err < 0) { |
475 | dev_dbg(bus->dev, "error failed to register dsp\n"); | ||
476 | goto out_free; | ||
477 | } | ||
462 | } | 478 | } |
463 | |||
464 | if (ebus->mlcap) | 479 | if (ebus->mlcap) |
465 | snd_hdac_ext_bus_get_ml_capabilities(ebus); | 480 | snd_hdac_ext_bus_get_ml_capabilities(ebus); |
466 | 481 | ||
467 | /* create device for soc dmic */ | 482 | /* create device for soc dmic */ |
468 | err = skl_dmic_device_register(skl); | 483 | err = skl_dmic_device_register(skl); |
469 | if (err < 0) | 484 | if (err < 0) |
470 | goto out_free; | 485 | goto out_dsp_free; |
471 | 486 | ||
472 | /* register platform dai and controls */ | 487 | /* register platform dai and controls */ |
473 | err = skl_platform_register(bus->dev); | 488 | err = skl_platform_register(bus->dev); |
@@ -491,6 +506,8 @@ out_unregister: | |||
491 | skl_platform_unregister(bus->dev); | 506 | skl_platform_unregister(bus->dev); |
492 | out_dmic_free: | 507 | out_dmic_free: |
493 | skl_dmic_device_unregister(skl); | 508 | skl_dmic_device_unregister(skl); |
509 | out_dsp_free: | ||
510 | skl_free_dsp(skl); | ||
494 | out_free: | 511 | out_free: |
495 | skl->init_failed = 1; | 512 | skl->init_failed = 1; |
496 | skl_free(ebus); | 513 | skl_free(ebus); |
@@ -507,6 +524,7 @@ static void skl_remove(struct pci_dev *pci) | |||
507 | pm_runtime_get_noresume(&pci->dev); | 524 | pm_runtime_get_noresume(&pci->dev); |
508 | pci_dev_put(pci); | 525 | pci_dev_put(pci); |
509 | skl_platform_unregister(&pci->dev); | 526 | skl_platform_unregister(&pci->dev); |
527 | skl_free_dsp(skl); | ||
510 | skl_dmic_device_unregister(skl); | 528 | skl_dmic_device_unregister(skl); |
511 | skl_free(ebus); | 529 | skl_free(ebus); |
512 | dev_set_drvdata(&pci->dev, NULL); | 530 | dev_set_drvdata(&pci->dev, NULL); |
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index f7fdbb02947f..dd2e79ae45a8 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h | |||
@@ -48,6 +48,13 @@ | |||
48 | #define AZX_REG_VS_SDXEFIFOS_XBASE 0x1094 | 48 | #define AZX_REG_VS_SDXEFIFOS_XBASE 0x1094 |
49 | #define AZX_REG_VS_SDXEFIFOS_XINTERVAL 0x20 | 49 | #define AZX_REG_VS_SDXEFIFOS_XINTERVAL 0x20 |
50 | 50 | ||
51 | struct skl_dsp_resource { | ||
52 | u32 max_mcps; | ||
53 | u32 max_mem; | ||
54 | u32 mcps; | ||
55 | u32 mem; | ||
56 | }; | ||
57 | |||
51 | struct skl { | 58 | struct skl { |
52 | struct hdac_ext_bus ebus; | 59 | struct hdac_ext_bus ebus; |
53 | struct pci_dev *pci; | 60 | struct pci_dev *pci; |
@@ -55,8 +62,12 @@ struct skl { | |||
55 | unsigned int init_failed:1; /* delayed init failed */ | 62 | unsigned int init_failed:1; /* delayed init failed */ |
56 | struct platform_device *dmic_dev; | 63 | struct platform_device *dmic_dev; |
57 | 64 | ||
58 | void __iomem *nhlt; /* nhlt ptr */ | 65 | void *nhlt; /* nhlt ptr */ |
59 | struct skl_sst *skl_sst; /* sst skl ctx */ | 66 | struct skl_sst *skl_sst; /* sst skl ctx */ |
67 | |||
68 | struct skl_dsp_resource resource; | ||
69 | struct list_head ppl_list; | ||
70 | struct list_head dapm_path_list; | ||
60 | }; | 71 | }; |
61 | 72 | ||
62 | #define skl_to_ebus(s) (&(s)->ebus) | 73 | #define skl_to_ebus(s) (&(s)->ebus) |
@@ -72,8 +83,8 @@ struct skl_dma_params { | |||
72 | int skl_platform_unregister(struct device *dev); | 83 | int skl_platform_unregister(struct device *dev); |
73 | int skl_platform_register(struct device *dev); | 84 | int skl_platform_register(struct device *dev); |
74 | 85 | ||
75 | void __iomem *skl_nhlt_init(struct device *dev); | 86 | void *skl_nhlt_init(struct device *dev); |
76 | void skl_nhlt_free(void __iomem *addr); | 87 | void skl_nhlt_free(void *addr); |
77 | struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance, | 88 | struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance, |
78 | u8 link_type, u8 s_fmt, u8 no_ch, u32 s_rate, u8 dirn); | 89 | u8 link_type, u8 s_fmt, u8 no_ch, u32 s_rate, u8 dirn); |
79 | 90 | ||
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 20728d07de5e..5e21f08579d8 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c | |||
@@ -296,7 +296,7 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) | |||
296 | dev_err(card->dev, "Failed to add TPA6130A2 controls\n"); | 296 | dev_err(card->dev, "Failed to add TPA6130A2 controls\n"); |
297 | return err; | 297 | return err; |
298 | } | 298 | } |
299 | snd_soc_limit_volume(codec, "TPA6130A2 Headphone Playback Volume", 42); | 299 | snd_soc_limit_volume(card, "TPA6130A2 Headphone Playback Volume", 42); |
300 | 300 | ||
301 | err = omap_mcbsp_st_add_controls(rtd, 2); | 301 | err = omap_mcbsp_st_add_controls(rtd, 2); |
302 | if (err < 0) { | 302 | if (err < 0) { |
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c index 9e4b04e0fbd1..f3de615aacd7 100644 --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/dmaengine.h> | 17 | #include <linux/dmaengine.h> |
18 | #include <linux/dma/pxa-dma.h> | ||
18 | 19 | ||
19 | #include <sound/core.h> | 20 | #include <sound/core.h> |
20 | #include <sound/ac97_codec.h> | 21 | #include <sound/ac97_codec.h> |
@@ -49,7 +50,11 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = { | |||
49 | .reset = pxa2xx_ac97_cold_reset, | 50 | .reset = pxa2xx_ac97_cold_reset, |
50 | }; | 51 | }; |
51 | 52 | ||
52 | static unsigned long pxa2xx_ac97_pcm_stereo_in_req = 11; | 53 | static struct pxad_param pxa2xx_ac97_pcm_stereo_in_req = { |
54 | .prio = PXAD_PRIO_LOWEST, | ||
55 | .drcmr = 11, | ||
56 | }; | ||
57 | |||
53 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = { | 58 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = { |
54 | .addr = __PREG(PCDR), | 59 | .addr = __PREG(PCDR), |
55 | .addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, | 60 | .addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, |
@@ -57,7 +62,11 @@ static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = { | |||
57 | .filter_data = &pxa2xx_ac97_pcm_stereo_in_req, | 62 | .filter_data = &pxa2xx_ac97_pcm_stereo_in_req, |
58 | }; | 63 | }; |
59 | 64 | ||
60 | static unsigned long pxa2xx_ac97_pcm_stereo_out_req = 12; | 65 | static struct pxad_param pxa2xx_ac97_pcm_stereo_out_req = { |
66 | .prio = PXAD_PRIO_LOWEST, | ||
67 | .drcmr = 12, | ||
68 | }; | ||
69 | |||
61 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_out = { | 70 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_out = { |
62 | .addr = __PREG(PCDR), | 71 | .addr = __PREG(PCDR), |
63 | .addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, | 72 | .addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, |
@@ -65,7 +74,10 @@ static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_out = { | |||
65 | .filter_data = &pxa2xx_ac97_pcm_stereo_out_req, | 74 | .filter_data = &pxa2xx_ac97_pcm_stereo_out_req, |
66 | }; | 75 | }; |
67 | 76 | ||
68 | static unsigned long pxa2xx_ac97_pcm_aux_mono_out_req = 10; | 77 | static struct pxad_param pxa2xx_ac97_pcm_aux_mono_out_req = { |
78 | .prio = PXAD_PRIO_LOWEST, | ||
79 | .drcmr = 10, | ||
80 | }; | ||
69 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_out = { | 81 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_out = { |
70 | .addr = __PREG(MODR), | 82 | .addr = __PREG(MODR), |
71 | .addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES, | 83 | .addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES, |
@@ -73,7 +85,10 @@ static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_out = { | |||
73 | .filter_data = &pxa2xx_ac97_pcm_aux_mono_out_req, | 85 | .filter_data = &pxa2xx_ac97_pcm_aux_mono_out_req, |
74 | }; | 86 | }; |
75 | 87 | ||
76 | static unsigned long pxa2xx_ac97_pcm_aux_mono_in_req = 9; | 88 | static struct pxad_param pxa2xx_ac97_pcm_aux_mono_in_req = { |
89 | .prio = PXAD_PRIO_LOWEST, | ||
90 | .drcmr = 9, | ||
91 | }; | ||
77 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_in = { | 92 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_in = { |
78 | .addr = __PREG(MODR), | 93 | .addr = __PREG(MODR), |
79 | .addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES, | 94 | .addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES, |
@@ -81,7 +96,10 @@ static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_in = { | |||
81 | .filter_data = &pxa2xx_ac97_pcm_aux_mono_in_req, | 96 | .filter_data = &pxa2xx_ac97_pcm_aux_mono_in_req, |
82 | }; | 97 | }; |
83 | 98 | ||
84 | static unsigned long pxa2xx_ac97_pcm_aux_mic_mono_req = 8; | 99 | static struct pxad_param pxa2xx_ac97_pcm_aux_mic_mono_req = { |
100 | .prio = PXAD_PRIO_LOWEST, | ||
101 | .drcmr = 8, | ||
102 | }; | ||
85 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = { | 103 | static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = { |
86 | .addr = __PREG(MCDR), | 104 | .addr = __PREG(MCDR), |
87 | .addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES, | 105 | .addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES, |
@@ -89,9 +107,8 @@ static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = { | |||
89 | .filter_data = &pxa2xx_ac97_pcm_aux_mic_mono_req, | 107 | .filter_data = &pxa2xx_ac97_pcm_aux_mic_mono_req, |
90 | }; | 108 | }; |
91 | 109 | ||
92 | static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream, | 110 | static int pxa2xx_ac97_hifi_startup(struct snd_pcm_substream *substream, |
93 | struct snd_pcm_hw_params *params, | 111 | struct snd_soc_dai *cpu_dai) |
94 | struct snd_soc_dai *cpu_dai) | ||
95 | { | 112 | { |
96 | struct snd_dmaengine_dai_dma_data *dma_data; | 113 | struct snd_dmaengine_dai_dma_data *dma_data; |
97 | 114 | ||
@@ -105,9 +122,8 @@ static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream, | |||
105 | return 0; | 122 | return 0; |
106 | } | 123 | } |
107 | 124 | ||
108 | static int pxa2xx_ac97_hw_aux_params(struct snd_pcm_substream *substream, | 125 | static int pxa2xx_ac97_aux_startup(struct snd_pcm_substream *substream, |
109 | struct snd_pcm_hw_params *params, | 126 | struct snd_soc_dai *cpu_dai) |
110 | struct snd_soc_dai *cpu_dai) | ||
111 | { | 127 | { |
112 | struct snd_dmaengine_dai_dma_data *dma_data; | 128 | struct snd_dmaengine_dai_dma_data *dma_data; |
113 | 129 | ||
@@ -121,9 +137,8 @@ static int pxa2xx_ac97_hw_aux_params(struct snd_pcm_substream *substream, | |||
121 | return 0; | 137 | return 0; |
122 | } | 138 | } |
123 | 139 | ||
124 | static int pxa2xx_ac97_hw_mic_params(struct snd_pcm_substream *substream, | 140 | static int pxa2xx_ac97_mic_startup(struct snd_pcm_substream *substream, |
125 | struct snd_pcm_hw_params *params, | 141 | struct snd_soc_dai *cpu_dai) |
126 | struct snd_soc_dai *cpu_dai) | ||
127 | { | 142 | { |
128 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 143 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
129 | return -ENODEV; | 144 | return -ENODEV; |
@@ -139,15 +154,15 @@ static int pxa2xx_ac97_hw_mic_params(struct snd_pcm_substream *substream, | |||
139 | SNDRV_PCM_RATE_48000) | 154 | SNDRV_PCM_RATE_48000) |
140 | 155 | ||
141 | static const struct snd_soc_dai_ops pxa_ac97_hifi_dai_ops = { | 156 | static const struct snd_soc_dai_ops pxa_ac97_hifi_dai_ops = { |
142 | .hw_params = pxa2xx_ac97_hw_params, | 157 | .startup = pxa2xx_ac97_hifi_startup, |
143 | }; | 158 | }; |
144 | 159 | ||
145 | static const struct snd_soc_dai_ops pxa_ac97_aux_dai_ops = { | 160 | static const struct snd_soc_dai_ops pxa_ac97_aux_dai_ops = { |
146 | .hw_params = pxa2xx_ac97_hw_aux_params, | 161 | .startup = pxa2xx_ac97_aux_startup, |
147 | }; | 162 | }; |
148 | 163 | ||
149 | static const struct snd_soc_dai_ops pxa_ac97_mic_dai_ops = { | 164 | static const struct snd_soc_dai_ops pxa_ac97_mic_dai_ops = { |
150 | .hw_params = pxa2xx_ac97_hw_mic_params, | 165 | .startup = pxa2xx_ac97_mic_startup, |
151 | }; | 166 | }; |
152 | 167 | ||
153 | /* | 168 | /* |
diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c index 6b4e40036910..0389cf7b4b1e 100644 --- a/sound/soc/pxa/pxa2xx-i2s.c +++ b/sound/soc/pxa/pxa2xx-i2s.c | |||
@@ -319,6 +319,9 @@ static int pxa2xx_i2s_probe(struct snd_soc_dai *dai) | |||
319 | /* Along with FIFO servicing */ | 319 | /* Along with FIFO servicing */ |
320 | SAIMR &= ~(SAIMR_RFS | SAIMR_TFS); | 320 | SAIMR &= ~(SAIMR_RFS | SAIMR_TFS); |
321 | 321 | ||
322 | snd_soc_dai_init_dma_data(dai, &pxa2xx_i2s_pcm_stereo_out, | ||
323 | &pxa2xx_i2s_pcm_stereo_in); | ||
324 | |||
322 | return 0; | 325 | return 0; |
323 | } | 326 | } |
324 | 327 | ||
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c index 29a3fdbb7b59..9f390398d518 100644 --- a/sound/soc/pxa/pxa2xx-pcm.c +++ b/sound/soc/pxa/pxa2xx-pcm.c | |||
@@ -15,8 +15,6 @@ | |||
15 | #include <linux/dmaengine.h> | 15 | #include <linux/dmaengine.h> |
16 | #include <linux/of.h> | 16 | #include <linux/of.h> |
17 | 17 | ||
18 | #include <mach/dma.h> | ||
19 | |||
20 | #include <sound/core.h> | 18 | #include <sound/core.h> |
21 | #include <sound/soc.h> | 19 | #include <sound/soc.h> |
22 | #include <sound/pxa2xx-lib.h> | 20 | #include <sound/pxa2xx-lib.h> |
@@ -27,11 +25,8 @@ | |||
27 | static int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream, | 25 | static int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream, |
28 | struct snd_pcm_hw_params *params) | 26 | struct snd_pcm_hw_params *params) |
29 | { | 27 | { |
30 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
31 | struct pxa2xx_runtime_data *prtd = runtime->private_data; | ||
32 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 28 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
33 | struct snd_dmaengine_dai_dma_data *dma; | 29 | struct snd_dmaengine_dai_dma_data *dma; |
34 | int ret; | ||
35 | 30 | ||
36 | dma = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | 31 | dma = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); |
37 | 32 | ||
@@ -40,40 +35,13 @@ static int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream, | |||
40 | if (!dma) | 35 | if (!dma) |
41 | return 0; | 36 | return 0; |
42 | 37 | ||
43 | /* this may get called several times by oss emulation | ||
44 | * with different params */ | ||
45 | if (prtd->params == NULL) { | ||
46 | prtd->params = dma; | ||
47 | ret = pxa_request_dma("name", DMA_PRIO_LOW, | ||
48 | pxa2xx_pcm_dma_irq, substream); | ||
49 | if (ret < 0) | ||
50 | return ret; | ||
51 | prtd->dma_ch = ret; | ||
52 | } else if (prtd->params != dma) { | ||
53 | pxa_free_dma(prtd->dma_ch); | ||
54 | prtd->params = dma; | ||
55 | ret = pxa_request_dma("name", DMA_PRIO_LOW, | ||
56 | pxa2xx_pcm_dma_irq, substream); | ||
57 | if (ret < 0) | ||
58 | return ret; | ||
59 | prtd->dma_ch = ret; | ||
60 | } | ||
61 | |||
62 | return __pxa2xx_pcm_hw_params(substream, params); | 38 | return __pxa2xx_pcm_hw_params(substream, params); |
63 | } | 39 | } |
64 | 40 | ||
65 | static int pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream) | 41 | static int pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream) |
66 | { | 42 | { |
67 | struct pxa2xx_runtime_data *prtd = substream->runtime->private_data; | ||
68 | |||
69 | __pxa2xx_pcm_hw_free(substream); | 43 | __pxa2xx_pcm_hw_free(substream); |
70 | 44 | ||
71 | if (prtd->dma_ch >= 0) { | ||
72 | pxa_free_dma(prtd->dma_ch); | ||
73 | prtd->dma_ch = -1; | ||
74 | prtd->params = NULL; | ||
75 | } | ||
76 | |||
77 | return 0; | 45 | return 0; |
78 | } | 46 | } |
79 | 47 | ||
diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig index 570905709d3a..f1e0c703e0d2 100644 --- a/sound/soc/rockchip/Kconfig +++ b/sound/soc/rockchip/Kconfig | |||
@@ -15,6 +15,14 @@ config SND_SOC_ROCKCHIP_I2S | |||
15 | Rockchip I2S device. The device supports upto maximum of | 15 | Rockchip I2S device. The device supports upto maximum of |
16 | 8 channels each for play and record. | 16 | 8 channels each for play and record. |
17 | 17 | ||
18 | config SND_SOC_ROCKCHIP_SPDIF | ||
19 | tristate "Rockchip SPDIF Device Driver" | ||
20 | depends on CLKDEV_LOOKUP && SND_SOC_ROCKCHIP | ||
21 | select SND_SOC_GENERIC_DMAENGINE_PCM | ||
22 | help | ||
23 | Say Y or M if you want to add support for SPDIF driver for | ||
24 | Rockchip SPDIF transceiver device. | ||
25 | |||
18 | config SND_SOC_ROCKCHIP_MAX98090 | 26 | config SND_SOC_ROCKCHIP_MAX98090 |
19 | tristate "ASoC support for Rockchip boards using a MAX98090 codec" | 27 | tristate "ASoC support for Rockchip boards using a MAX98090 codec" |
20 | depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP | 28 | depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP |
diff --git a/sound/soc/rockchip/Makefile b/sound/soc/rockchip/Makefile index 1bc1dc3c729a..c0bf560125f3 100644 --- a/sound/soc/rockchip/Makefile +++ b/sound/soc/rockchip/Makefile | |||
@@ -1,7 +1,9 @@ | |||
1 | # ROCKCHIP Platform Support | 1 | # ROCKCHIP Platform Support |
2 | snd-soc-i2s-objs := rockchip_i2s.o | 2 | snd-soc-rockchip-i2s-objs := rockchip_i2s.o |
3 | snd-soc-rockchip-spdif-objs := rockchip_spdif.o | ||
3 | 4 | ||
4 | obj-$(CONFIG_SND_SOC_ROCKCHIP_I2S) += snd-soc-i2s.o | 5 | obj-$(CONFIG_SND_SOC_ROCKCHIP_I2S) += snd-soc-rockchip-i2s.o |
6 | obj-$(CONFIG_SND_SOC_ROCKCHIP_SPDIF) += snd-soc-rockchip-spdif.o | ||
5 | 7 | ||
6 | snd-soc-rockchip-max98090-objs := rockchip_max98090.o | 8 | snd-soc-rockchip-max98090-objs := rockchip_max98090.o |
7 | snd-soc-rockchip-rt5645-objs := rockchip_rt5645.o | 9 | snd-soc-rockchip-rt5645-objs := rockchip_rt5645.o |
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index b93610212e3d..58ee64594f07 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c | |||
@@ -226,6 +226,7 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream, | |||
226 | struct snd_soc_dai *dai) | 226 | struct snd_soc_dai *dai) |
227 | { | 227 | { |
228 | struct rk_i2s_dev *i2s = to_info(dai); | 228 | struct rk_i2s_dev *i2s = to_info(dai); |
229 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
229 | unsigned int val = 0; | 230 | unsigned int val = 0; |
230 | 231 | ||
231 | switch (params_format(params)) { | 232 | switch (params_format(params)) { |
@@ -245,13 +246,46 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream, | |||
245 | return -EINVAL; | 246 | return -EINVAL; |
246 | } | 247 | } |
247 | 248 | ||
248 | regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val); | 249 | switch (params_channels(params)) { |
249 | regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val); | 250 | case 8: |
251 | val |= I2S_CHN_8; | ||
252 | break; | ||
253 | case 6: | ||
254 | val |= I2S_CHN_6; | ||
255 | break; | ||
256 | case 4: | ||
257 | val |= I2S_CHN_4; | ||
258 | break; | ||
259 | case 2: | ||
260 | val |= I2S_CHN_2; | ||
261 | break; | ||
262 | default: | ||
263 | dev_err(i2s->dev, "invalid channel: %d\n", | ||
264 | params_channels(params)); | ||
265 | return -EINVAL; | ||
266 | } | ||
267 | |||
268 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
269 | regmap_update_bits(i2s->regmap, I2S_RXCR, | ||
270 | I2S_RXCR_VDW_MASK | I2S_RXCR_CSR_MASK, | ||
271 | val); | ||
272 | else | ||
273 | regmap_update_bits(i2s->regmap, I2S_TXCR, | ||
274 | I2S_TXCR_VDW_MASK | I2S_TXCR_CSR_MASK, | ||
275 | val); | ||
276 | |||
250 | regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK, | 277 | regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK, |
251 | I2S_DMACR_TDL(16)); | 278 | I2S_DMACR_TDL(16)); |
252 | regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDL_MASK, | 279 | regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDL_MASK, |
253 | I2S_DMACR_RDL(16)); | 280 | I2S_DMACR_RDL(16)); |
254 | 281 | ||
282 | val = I2S_CKR_TRCM_TXRX; | ||
283 | if (dai->driver->symmetric_rates || rtd->dai_link->symmetric_rates) | ||
284 | val = I2S_CKR_TRCM_TXSHARE; | ||
285 | |||
286 | regmap_update_bits(i2s->regmap, I2S_CKR, | ||
287 | I2S_CKR_TRCM_MASK, | ||
288 | val); | ||
255 | return 0; | 289 | return 0; |
256 | } | 290 | } |
257 | 291 | ||
@@ -415,10 +449,12 @@ static const struct regmap_config rockchip_i2s_regmap_config = { | |||
415 | 449 | ||
416 | static int rockchip_i2s_probe(struct platform_device *pdev) | 450 | static int rockchip_i2s_probe(struct platform_device *pdev) |
417 | { | 451 | { |
452 | struct device_node *node = pdev->dev.of_node; | ||
418 | struct rk_i2s_dev *i2s; | 453 | struct rk_i2s_dev *i2s; |
419 | struct resource *res; | 454 | struct resource *res; |
420 | void __iomem *regs; | 455 | void __iomem *regs; |
421 | int ret; | 456 | int ret; |
457 | int val; | ||
422 | 458 | ||
423 | i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); | 459 | i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); |
424 | if (!i2s) { | 460 | if (!i2s) { |
@@ -475,6 +511,14 @@ static int rockchip_i2s_probe(struct platform_device *pdev) | |||
475 | goto err_pm_disable; | 511 | goto err_pm_disable; |
476 | } | 512 | } |
477 | 513 | ||
514 | /* refine capture channels */ | ||
515 | if (!of_property_read_u32(node, "rockchip,capture-channels", &val)) { | ||
516 | if (val >= 2 && val <= 8) | ||
517 | rockchip_i2s_dai.capture.channels_max = val; | ||
518 | else | ||
519 | rockchip_i2s_dai.capture.channels_max = 2; | ||
520 | } | ||
521 | |||
478 | ret = devm_snd_soc_register_component(&pdev->dev, | 522 | ret = devm_snd_soc_register_component(&pdev->dev, |
479 | &rockchip_i2s_component, | 523 | &rockchip_i2s_component, |
480 | &rockchip_i2s_dai, 1); | 524 | &rockchip_i2s_dai, 1); |
diff --git a/sound/soc/rockchip/rockchip_i2s.h b/sound/soc/rockchip/rockchip_i2s.h index 93f456f518a9..dc6e2c74d088 100644 --- a/sound/soc/rockchip/rockchip_i2s.h +++ b/sound/soc/rockchip/rockchip_i2s.h | |||
@@ -49,6 +49,9 @@ | |||
49 | * RXCR | 49 | * RXCR |
50 | * receive operation control register | 50 | * receive operation control register |
51 | */ | 51 | */ |
52 | #define I2S_RXCR_CSR_SHIFT 15 | ||
53 | #define I2S_RXCR_CSR(x) (x << I2S_RXCR_CSR_SHIFT) | ||
54 | #define I2S_RXCR_CSR_MASK (3 << I2S_RXCR_CSR_SHIFT) | ||
52 | #define I2S_RXCR_HWT BIT(14) | 55 | #define I2S_RXCR_HWT BIT(14) |
53 | #define I2S_RXCR_SJM_SHIFT 12 | 56 | #define I2S_RXCR_SJM_SHIFT 12 |
54 | #define I2S_RXCR_SJM_R (0 << I2S_RXCR_SJM_SHIFT) | 57 | #define I2S_RXCR_SJM_R (0 << I2S_RXCR_SJM_SHIFT) |
@@ -75,6 +78,12 @@ | |||
75 | * CKR | 78 | * CKR |
76 | * clock generation register | 79 | * clock generation register |
77 | */ | 80 | */ |
81 | #define I2S_CKR_TRCM_SHIFT 28 | ||
82 | #define I2S_CKR_TRCM(x) (x << I2S_CKR_TRCM_SHIFT) | ||
83 | #define I2S_CKR_TRCM_TXRX (0 << I2S_CKR_TRCM_SHIFT) | ||
84 | #define I2S_CKR_TRCM_TXSHARE (1 << I2S_CKR_TRCM_SHIFT) | ||
85 | #define I2S_CKR_TRCM_RXSHARE (2 << I2S_CKR_TRCM_SHIFT) | ||
86 | #define I2S_CKR_TRCM_MASK (3 << I2S_CKR_TRCM_SHIFT) | ||
78 | #define I2S_CKR_MSS_SHIFT 27 | 87 | #define I2S_CKR_MSS_SHIFT 27 |
79 | #define I2S_CKR_MSS_MASTER (0 << I2S_CKR_MSS_SHIFT) | 88 | #define I2S_CKR_MSS_MASTER (0 << I2S_CKR_MSS_SHIFT) |
80 | #define I2S_CKR_MSS_SLAVE (1 << I2S_CKR_MSS_SHIFT) | 89 | #define I2S_CKR_MSS_SLAVE (1 << I2S_CKR_MSS_SHIFT) |
@@ -207,6 +216,13 @@ enum { | |||
207 | ROCKCHIP_DIV_BCLK, | 216 | ROCKCHIP_DIV_BCLK, |
208 | }; | 217 | }; |
209 | 218 | ||
219 | /* channel select */ | ||
220 | #define I2S_CSR_SHIFT 15 | ||
221 | #define I2S_CHN_2 (0 << I2S_CSR_SHIFT) | ||
222 | #define I2S_CHN_4 (1 << I2S_CSR_SHIFT) | ||
223 | #define I2S_CHN_6 (2 << I2S_CSR_SHIFT) | ||
224 | #define I2S_CHN_8 (3 << I2S_CSR_SHIFT) | ||
225 | |||
210 | /* I2S REGS */ | 226 | /* I2S REGS */ |
211 | #define I2S_TXCR (0x0000) | 227 | #define I2S_TXCR (0x0000) |
212 | #define I2S_RXCR (0x0004) | 228 | #define I2S_RXCR (0x0004) |
diff --git a/sound/soc/rockchip/rockchip_spdif.c b/sound/soc/rockchip/rockchip_spdif.c new file mode 100644 index 000000000000..a38a3029062c --- /dev/null +++ b/sound/soc/rockchip/rockchip_spdif.c | |||
@@ -0,0 +1,405 @@ | |||
1 | /* sound/soc/rockchip/rk_spdif.c | ||
2 | * | ||
3 | * ALSA SoC Audio Layer - Rockchip I2S Controller driver | ||
4 | * | ||
5 | * Copyright (c) 2014 Rockchip Electronics Co. Ltd. | ||
6 | * Author: Jianqun <jay.xu@rock-chips.com> | ||
7 | * Copyright (c) 2015 Collabora Ltd. | ||
8 | * Author: Sjoerd Simons <sjoerd.simons@collabora.co.uk> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/of_gpio.h> | ||
18 | #include <linux/clk.h> | ||
19 | #include <linux/pm_runtime.h> | ||
20 | #include <linux/mfd/syscon.h> | ||
21 | #include <linux/regmap.h> | ||
22 | #include <sound/pcm_params.h> | ||
23 | #include <sound/dmaengine_pcm.h> | ||
24 | |||
25 | #include "rockchip_spdif.h" | ||
26 | |||
27 | enum rk_spdif_type { | ||
28 | RK_SPDIF_RK3066, | ||
29 | RK_SPDIF_RK3188, | ||
30 | RK_SPDIF_RK3288, | ||
31 | }; | ||
32 | |||
33 | #define RK3288_GRF_SOC_CON2 0x24c | ||
34 | |||
35 | struct rk_spdif_dev { | ||
36 | struct device *dev; | ||
37 | |||
38 | struct clk *mclk; | ||
39 | struct clk *hclk; | ||
40 | |||
41 | struct snd_dmaengine_dai_dma_data playback_dma_data; | ||
42 | |||
43 | struct regmap *regmap; | ||
44 | }; | ||
45 | |||
46 | static const struct of_device_id rk_spdif_match[] = { | ||
47 | { .compatible = "rockchip,rk3066-spdif", | ||
48 | .data = (void *) RK_SPDIF_RK3066 }, | ||
49 | { .compatible = "rockchip,rk3188-spdif", | ||
50 | .data = (void *) RK_SPDIF_RK3188 }, | ||
51 | { .compatible = "rockchip,rk3288-spdif", | ||
52 | .data = (void *) RK_SPDIF_RK3288 }, | ||
53 | {}, | ||
54 | }; | ||
55 | MODULE_DEVICE_TABLE(of, rk_spdif_match); | ||
56 | |||
57 | static int rk_spdif_runtime_suspend(struct device *dev) | ||
58 | { | ||
59 | struct rk_spdif_dev *spdif = dev_get_drvdata(dev); | ||
60 | |||
61 | clk_disable_unprepare(spdif->mclk); | ||
62 | clk_disable_unprepare(spdif->hclk); | ||
63 | |||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | static int rk_spdif_runtime_resume(struct device *dev) | ||
68 | { | ||
69 | struct rk_spdif_dev *spdif = dev_get_drvdata(dev); | ||
70 | int ret; | ||
71 | |||
72 | ret = clk_prepare_enable(spdif->mclk); | ||
73 | if (ret) { | ||
74 | dev_err(spdif->dev, "mclk clock enable failed %d\n", ret); | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | ret = clk_prepare_enable(spdif->hclk); | ||
79 | if (ret) { | ||
80 | dev_err(spdif->dev, "hclk clock enable failed %d\n", ret); | ||
81 | return ret; | ||
82 | } | ||
83 | |||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | static int rk_spdif_hw_params(struct snd_pcm_substream *substream, | ||
88 | struct snd_pcm_hw_params *params, | ||
89 | struct snd_soc_dai *dai) | ||
90 | { | ||
91 | struct rk_spdif_dev *spdif = snd_soc_dai_get_drvdata(dai); | ||
92 | unsigned int val = SPDIF_CFGR_HALFWORD_ENABLE; | ||
93 | int srate, mclk; | ||
94 | int ret; | ||
95 | |||
96 | srate = params_rate(params); | ||
97 | switch (srate) { | ||
98 | case 32000: | ||
99 | case 48000: | ||
100 | case 96000: | ||
101 | mclk = 96000 * 128; /* 12288000 hz */ | ||
102 | break; | ||
103 | case 44100: | ||
104 | mclk = 44100 * 256; /* 11289600 hz */ | ||
105 | break; | ||
106 | case 192000: | ||
107 | mclk = 192000 * 128; /* 24576000 hz */ | ||
108 | break; | ||
109 | default: | ||
110 | return -EINVAL; | ||
111 | } | ||
112 | |||
113 | switch (params_format(params)) { | ||
114 | case SNDRV_PCM_FORMAT_S16_LE: | ||
115 | val |= SPDIF_CFGR_VDW_16; | ||
116 | break; | ||
117 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
118 | val |= SPDIF_CFGR_VDW_20; | ||
119 | break; | ||
120 | case SNDRV_PCM_FORMAT_S24_LE: | ||
121 | val |= SPDIF_CFGR_VDW_24; | ||
122 | break; | ||
123 | default: | ||
124 | return -EINVAL; | ||
125 | } | ||
126 | |||
127 | /* Set clock and calculate divider */ | ||
128 | ret = clk_set_rate(spdif->mclk, mclk); | ||
129 | if (ret != 0) { | ||
130 | dev_err(spdif->dev, "Failed to set module clock rate: %d\n", | ||
131 | ret); | ||
132 | return ret; | ||
133 | } | ||
134 | |||
135 | val |= SPDIF_CFGR_CLK_DIV(mclk/(srate * 256)); | ||
136 | ret = regmap_update_bits(spdif->regmap, SPDIF_CFGR, | ||
137 | SPDIF_CFGR_CLK_DIV_MASK | SPDIF_CFGR_HALFWORD_ENABLE | | ||
138 | SDPIF_CFGR_VDW_MASK, | ||
139 | val); | ||
140 | |||
141 | return ret; | ||
142 | } | ||
143 | |||
144 | static int rk_spdif_trigger(struct snd_pcm_substream *substream, | ||
145 | int cmd, struct snd_soc_dai *dai) | ||
146 | { | ||
147 | struct rk_spdif_dev *spdif = snd_soc_dai_get_drvdata(dai); | ||
148 | int ret; | ||
149 | |||
150 | switch (cmd) { | ||
151 | case SNDRV_PCM_TRIGGER_START: | ||
152 | case SNDRV_PCM_TRIGGER_RESUME: | ||
153 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
154 | ret = regmap_update_bits(spdif->regmap, SPDIF_DMACR, | ||
155 | SPDIF_DMACR_TDE_ENABLE, | ||
156 | SPDIF_DMACR_TDE_ENABLE); | ||
157 | |||
158 | if (ret != 0) | ||
159 | return ret; | ||
160 | |||
161 | ret = regmap_update_bits(spdif->regmap, SPDIF_XFER, | ||
162 | SPDIF_XFER_TXS_START, | ||
163 | SPDIF_XFER_TXS_START); | ||
164 | break; | ||
165 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
166 | case SNDRV_PCM_TRIGGER_STOP: | ||
167 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
168 | ret = regmap_update_bits(spdif->regmap, SPDIF_DMACR, | ||
169 | SPDIF_DMACR_TDE_ENABLE, | ||
170 | SPDIF_DMACR_TDE_DISABLE); | ||
171 | |||
172 | if (ret != 0) | ||
173 | return ret; | ||
174 | |||
175 | ret = regmap_update_bits(spdif->regmap, SPDIF_XFER, | ||
176 | SPDIF_XFER_TXS_START, | ||
177 | SPDIF_XFER_TXS_STOP); | ||
178 | break; | ||
179 | default: | ||
180 | ret = -EINVAL; | ||
181 | break; | ||
182 | } | ||
183 | |||
184 | return ret; | ||
185 | } | ||
186 | |||
187 | static int rk_spdif_dai_probe(struct snd_soc_dai *dai) | ||
188 | { | ||
189 | struct rk_spdif_dev *spdif = snd_soc_dai_get_drvdata(dai); | ||
190 | |||
191 | dai->playback_dma_data = &spdif->playback_dma_data; | ||
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | static const struct snd_soc_dai_ops rk_spdif_dai_ops = { | ||
197 | .hw_params = rk_spdif_hw_params, | ||
198 | .trigger = rk_spdif_trigger, | ||
199 | }; | ||
200 | |||
201 | static struct snd_soc_dai_driver rk_spdif_dai = { | ||
202 | .probe = rk_spdif_dai_probe, | ||
203 | .playback = { | ||
204 | .stream_name = "Playback", | ||
205 | .channels_min = 2, | ||
206 | .channels_max = 2, | ||
207 | .rates = (SNDRV_PCM_RATE_32000 | | ||
208 | SNDRV_PCM_RATE_44100 | | ||
209 | SNDRV_PCM_RATE_48000 | | ||
210 | SNDRV_PCM_RATE_96000 | | ||
211 | SNDRV_PCM_RATE_192000), | ||
212 | .formats = (SNDRV_PCM_FMTBIT_S16_LE | | ||
213 | SNDRV_PCM_FMTBIT_S20_3LE | | ||
214 | SNDRV_PCM_FMTBIT_S24_LE), | ||
215 | }, | ||
216 | .ops = &rk_spdif_dai_ops, | ||
217 | }; | ||
218 | |||
219 | static const struct snd_soc_component_driver rk_spdif_component = { | ||
220 | .name = "rockchip-spdif", | ||
221 | }; | ||
222 | |||
223 | static bool rk_spdif_wr_reg(struct device *dev, unsigned int reg) | ||
224 | { | ||
225 | switch (reg) { | ||
226 | case SPDIF_CFGR: | ||
227 | case SPDIF_DMACR: | ||
228 | case SPDIF_INTCR: | ||
229 | case SPDIF_XFER: | ||
230 | case SPDIF_SMPDR: | ||
231 | return true; | ||
232 | default: | ||
233 | return false; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | static bool rk_spdif_rd_reg(struct device *dev, unsigned int reg) | ||
238 | { | ||
239 | switch (reg) { | ||
240 | case SPDIF_CFGR: | ||
241 | case SPDIF_SDBLR: | ||
242 | case SPDIF_INTCR: | ||
243 | case SPDIF_INTSR: | ||
244 | case SPDIF_XFER: | ||
245 | return true; | ||
246 | default: | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | |||
251 | static bool rk_spdif_volatile_reg(struct device *dev, unsigned int reg) | ||
252 | { | ||
253 | switch (reg) { | ||
254 | case SPDIF_INTSR: | ||
255 | case SPDIF_SDBLR: | ||
256 | return true; | ||
257 | default: | ||
258 | return false; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | static const struct regmap_config rk_spdif_regmap_config = { | ||
263 | .reg_bits = 32, | ||
264 | .reg_stride = 4, | ||
265 | .val_bits = 32, | ||
266 | .max_register = SPDIF_SMPDR, | ||
267 | .writeable_reg = rk_spdif_wr_reg, | ||
268 | .readable_reg = rk_spdif_rd_reg, | ||
269 | .volatile_reg = rk_spdif_volatile_reg, | ||
270 | .cache_type = REGCACHE_FLAT, | ||
271 | }; | ||
272 | |||
273 | static int rk_spdif_probe(struct platform_device *pdev) | ||
274 | { | ||
275 | struct device_node *np = pdev->dev.of_node; | ||
276 | struct rk_spdif_dev *spdif; | ||
277 | const struct of_device_id *match; | ||
278 | struct resource *res; | ||
279 | void __iomem *regs; | ||
280 | int ret; | ||
281 | |||
282 | match = of_match_node(rk_spdif_match, np); | ||
283 | if ((int) match->data == RK_SPDIF_RK3288) { | ||
284 | struct regmap *grf; | ||
285 | |||
286 | grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); | ||
287 | if (IS_ERR(grf)) { | ||
288 | dev_err(&pdev->dev, | ||
289 | "rockchip_spdif missing 'rockchip,grf' \n"); | ||
290 | return PTR_ERR(grf); | ||
291 | } | ||
292 | |||
293 | /* Select the 8 channel SPDIF solution on RK3288 as | ||
294 | * the 2 channel one does not appear to work | ||
295 | */ | ||
296 | regmap_write(grf, RK3288_GRF_SOC_CON2, BIT(1) << 16); | ||
297 | } | ||
298 | |||
299 | spdif = devm_kzalloc(&pdev->dev, sizeof(*spdif), GFP_KERNEL); | ||
300 | if (!spdif) | ||
301 | return -ENOMEM; | ||
302 | |||
303 | spdif->hclk = devm_clk_get(&pdev->dev, "hclk"); | ||
304 | if (IS_ERR(spdif->hclk)) { | ||
305 | dev_err(&pdev->dev, "Can't retrieve rk_spdif bus clock\n"); | ||
306 | return PTR_ERR(spdif->hclk); | ||
307 | } | ||
308 | ret = clk_prepare_enable(spdif->hclk); | ||
309 | if (ret) { | ||
310 | dev_err(spdif->dev, "hclock enable failed %d\n", ret); | ||
311 | return ret; | ||
312 | } | ||
313 | |||
314 | spdif->mclk = devm_clk_get(&pdev->dev, "mclk"); | ||
315 | if (IS_ERR(spdif->mclk)) { | ||
316 | dev_err(&pdev->dev, "Can't retrieve rk_spdif master clock\n"); | ||
317 | return PTR_ERR(spdif->mclk); | ||
318 | } | ||
319 | |||
320 | ret = clk_prepare_enable(spdif->mclk); | ||
321 | if (ret) { | ||
322 | dev_err(spdif->dev, "clock enable failed %d\n", ret); | ||
323 | return ret; | ||
324 | } | ||
325 | |||
326 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
327 | regs = devm_ioremap_resource(&pdev->dev, res); | ||
328 | if (IS_ERR(regs)) | ||
329 | return PTR_ERR(regs); | ||
330 | |||
331 | spdif->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "hclk", regs, | ||
332 | &rk_spdif_regmap_config); | ||
333 | if (IS_ERR(spdif->regmap)) { | ||
334 | dev_err(&pdev->dev, | ||
335 | "Failed to initialise managed register map\n"); | ||
336 | return PTR_ERR(spdif->regmap); | ||
337 | } | ||
338 | |||
339 | spdif->playback_dma_data.addr = res->start + SPDIF_SMPDR; | ||
340 | spdif->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
341 | spdif->playback_dma_data.maxburst = 4; | ||
342 | |||
343 | spdif->dev = &pdev->dev; | ||
344 | dev_set_drvdata(&pdev->dev, spdif); | ||
345 | |||
346 | pm_runtime_set_active(&pdev->dev); | ||
347 | pm_runtime_enable(&pdev->dev); | ||
348 | pm_request_idle(&pdev->dev); | ||
349 | |||
350 | ret = devm_snd_soc_register_component(&pdev->dev, | ||
351 | &rk_spdif_component, | ||
352 | &rk_spdif_dai, 1); | ||
353 | if (ret) { | ||
354 | dev_err(&pdev->dev, "Could not register DAI\n"); | ||
355 | goto err_pm_runtime; | ||
356 | } | ||
357 | |||
358 | ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); | ||
359 | if (ret) { | ||
360 | dev_err(&pdev->dev, "Could not register PCM\n"); | ||
361 | goto err_pm_runtime; | ||
362 | } | ||
363 | |||
364 | return 0; | ||
365 | |||
366 | err_pm_runtime: | ||
367 | pm_runtime_disable(&pdev->dev); | ||
368 | |||
369 | return ret; | ||
370 | } | ||
371 | |||
372 | static int rk_spdif_remove(struct platform_device *pdev) | ||
373 | { | ||
374 | struct rk_spdif_dev *spdif = dev_get_drvdata(&pdev->dev); | ||
375 | |||
376 | pm_runtime_disable(&pdev->dev); | ||
377 | if (!pm_runtime_status_suspended(&pdev->dev)) | ||
378 | rk_spdif_runtime_suspend(&pdev->dev); | ||
379 | |||
380 | clk_disable_unprepare(spdif->mclk); | ||
381 | clk_disable_unprepare(spdif->hclk); | ||
382 | |||
383 | return 0; | ||
384 | } | ||
385 | |||
386 | static const struct dev_pm_ops rk_spdif_pm_ops = { | ||
387 | SET_RUNTIME_PM_OPS(rk_spdif_runtime_suspend, rk_spdif_runtime_resume, | ||
388 | NULL) | ||
389 | }; | ||
390 | |||
391 | static struct platform_driver rk_spdif_driver = { | ||
392 | .probe = rk_spdif_probe, | ||
393 | .remove = rk_spdif_remove, | ||
394 | .driver = { | ||
395 | .name = "rockchip-spdif", | ||
396 | .of_match_table = of_match_ptr(rk_spdif_match), | ||
397 | .pm = &rk_spdif_pm_ops, | ||
398 | }, | ||
399 | }; | ||
400 | module_platform_driver(rk_spdif_driver); | ||
401 | |||
402 | MODULE_ALIAS("platform:rockchip-spdif"); | ||
403 | MODULE_DESCRIPTION("ROCKCHIP SPDIF transceiver Interface"); | ||
404 | MODULE_AUTHOR("Sjoerd Simons <sjoerd.simons@collabora.co.uk>"); | ||
405 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/sound/soc/rockchip/rockchip_spdif.h b/sound/soc/rockchip/rockchip_spdif.h new file mode 100644 index 000000000000..07f86a21046a --- /dev/null +++ b/sound/soc/rockchip/rockchip_spdif.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | * ALSA SoC Audio Layer - Rockchip SPDIF transceiver driver | ||
3 | * | ||
4 | * Copyright (c) 2015 Collabora Ltd. | ||
5 | * Author: Sjoerd Simons <sjoerd.simons@collabora.co.uk> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef _ROCKCHIP_SPDIF_H | ||
13 | #define _ROCKCHIP_SPDIF_H | ||
14 | |||
15 | /* | ||
16 | * CFGR | ||
17 | * transfer configuration register | ||
18 | */ | ||
19 | #define SPDIF_CFGR_CLK_DIV_SHIFT (16) | ||
20 | #define SPDIF_CFGR_CLK_DIV_MASK (0xff << SPDIF_CFGR_CLK_DIV_SHIFT) | ||
21 | #define SPDIF_CFGR_CLK_DIV(x) (x << SPDIF_CFGR_CLK_DIV_SHIFT) | ||
22 | |||
23 | #define SPDIF_CFGR_HALFWORD_SHIFT 2 | ||
24 | #define SPDIF_CFGR_HALFWORD_DISABLE (0 << SPDIF_CFGR_HALFWORD_SHIFT) | ||
25 | #define SPDIF_CFGR_HALFWORD_ENABLE (1 << SPDIF_CFGR_HALFWORD_SHIFT) | ||
26 | |||
27 | #define SPDIF_CFGR_VDW_SHIFT 0 | ||
28 | #define SPDIF_CFGR_VDW(x) (x << SPDIF_CFGR_VDW_SHIFT) | ||
29 | #define SDPIF_CFGR_VDW_MASK (0xf << SPDIF_CFGR_VDW_SHIFT) | ||
30 | |||
31 | #define SPDIF_CFGR_VDW_16 SPDIF_CFGR_VDW(0x00) | ||
32 | #define SPDIF_CFGR_VDW_20 SPDIF_CFGR_VDW(0x01) | ||
33 | #define SPDIF_CFGR_VDW_24 SPDIF_CFGR_VDW(0x10) | ||
34 | |||
35 | /* | ||
36 | * DMACR | ||
37 | * DMA control register | ||
38 | */ | ||
39 | #define SPDIF_DMACR_TDE_SHIFT 5 | ||
40 | #define SPDIF_DMACR_TDE_DISABLE (0 << SPDIF_DMACR_TDE_SHIFT) | ||
41 | #define SPDIF_DMACR_TDE_ENABLE (1 << SPDIF_DMACR_TDE_SHIFT) | ||
42 | |||
43 | #define SPDIF_DMACR_TDL_SHIFT 0 | ||
44 | #define SPDIF_DMACR_TDL(x) ((x) << SPDIF_DMACR_TDL_SHIFT) | ||
45 | #define SPDIF_DMACR_TDL_MASK (0x1f << SDPIF_DMACR_TDL_SHIFT) | ||
46 | |||
47 | /* | ||
48 | * XFER | ||
49 | * Transfer control register | ||
50 | */ | ||
51 | #define SPDIF_XFER_TXS_SHIFT 0 | ||
52 | #define SPDIF_XFER_TXS_STOP (0 << SPDIF_XFER_TXS_SHIFT) | ||
53 | #define SPDIF_XFER_TXS_START (1 << SPDIF_XFER_TXS_SHIFT) | ||
54 | |||
55 | #define SPDIF_CFGR (0x0000) | ||
56 | #define SPDIF_SDBLR (0x0004) | ||
57 | #define SPDIF_DMACR (0x0008) | ||
58 | #define SPDIF_INTCR (0x000c) | ||
59 | #define SPDIF_INTSR (0x0010) | ||
60 | #define SPDIF_XFER (0x0018) | ||
61 | #define SPDIF_SMPDR (0x0020) | ||
62 | |||
63 | #endif /* _ROCKCHIP_SPDIF_H */ | ||
diff --git a/sound/soc/samsung/h1940_uda1380.c b/sound/soc/samsung/h1940_uda1380.c index c72e9fb26658..5f5825faeb2a 100644 --- a/sound/soc/samsung/h1940_uda1380.c +++ b/sound/soc/samsung/h1940_uda1380.c | |||
@@ -26,16 +26,15 @@ | |||
26 | #include <mach/gpio-samsung.h> | 26 | #include <mach/gpio-samsung.h> |
27 | #include "s3c24xx-i2s.h" | 27 | #include "s3c24xx-i2s.h" |
28 | 28 | ||
29 | static unsigned int rates[] = { | 29 | static const unsigned int rates[] = { |
30 | 11025, | 30 | 11025, |
31 | 22050, | 31 | 22050, |
32 | 44100, | 32 | 44100, |
33 | }; | 33 | }; |
34 | 34 | ||
35 | static struct snd_pcm_hw_constraint_list hw_rates = { | 35 | static const struct snd_pcm_hw_constraint_list hw_rates = { |
36 | .count = ARRAY_SIZE(rates), | 36 | .count = ARRAY_SIZE(rates), |
37 | .list = rates, | 37 | .list = rates, |
38 | .mask = 0, | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | static struct snd_soc_jack hp_jack; | 40 | static struct snd_soc_jack hp_jack; |
diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c index 35e37c457f1f..fa096abe9e75 100644 --- a/sound/soc/samsung/rx1950_uda1380.c +++ b/sound/soc/samsung/rx1950_uda1380.c | |||
@@ -38,16 +38,15 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream, | |||
38 | static int rx1950_spk_power(struct snd_soc_dapm_widget *w, | 38 | static int rx1950_spk_power(struct snd_soc_dapm_widget *w, |
39 | struct snd_kcontrol *kcontrol, int event); | 39 | struct snd_kcontrol *kcontrol, int event); |
40 | 40 | ||
41 | static unsigned int rates[] = { | 41 | static const unsigned int rates[] = { |
42 | 16000, | 42 | 16000, |
43 | 44100, | 43 | 44100, |
44 | 48000, | 44 | 48000, |
45 | }; | 45 | }; |
46 | 46 | ||
47 | static struct snd_pcm_hw_constraint_list hw_rates = { | 47 | static const struct snd_pcm_hw_constraint_list hw_rates = { |
48 | .count = ARRAY_SIZE(rates), | 48 | .count = ARRAY_SIZE(rates), |
49 | .list = rates, | 49 | .list = rates, |
50 | .mask = 0, | ||
51 | }; | 50 | }; |
52 | 51 | ||
53 | static struct snd_soc_jack hp_jack; | 52 | static struct snd_soc_jack hp_jack; |
diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig index 6ca90aaf141f..206d1edab07c 100644 --- a/sound/soc/sh/Kconfig +++ b/sound/soc/sh/Kconfig | |||
@@ -41,7 +41,7 @@ config SND_SOC_RCAR | |||
41 | select SND_SIMPLE_CARD | 41 | select SND_SIMPLE_CARD |
42 | select REGMAP_MMIO | 42 | select REGMAP_MMIO |
43 | help | 43 | help |
44 | This option enables R-Car SUR/SCU/SSIU/SSI sound support | 44 | This option enables R-Car SRU/SCU/SSIU/SSI sound support |
45 | 45 | ||
46 | config SND_SOC_RSRC_CARD | 46 | config SND_SOC_RSRC_CARD |
47 | tristate "Renesas Sampling Rate Convert Sound Card" | 47 | tristate "Renesas Sampling Rate Convert Sound Card" |
diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index c4ebbb7a7b6f..2a5b3a293cd2 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c | |||
@@ -69,11 +69,10 @@ static u32 rsnd_adg_calculate_rbgx(unsigned long div) | |||
69 | static u32 rsnd_adg_ssi_ws_timing_gen2(struct rsnd_dai_stream *io) | 69 | static u32 rsnd_adg_ssi_ws_timing_gen2(struct rsnd_dai_stream *io) |
70 | { | 70 | { |
71 | struct rsnd_mod *mod = rsnd_io_to_mod_ssi(io); | 71 | struct rsnd_mod *mod = rsnd_io_to_mod_ssi(io); |
72 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | ||
73 | int id = rsnd_mod_id(mod); | 72 | int id = rsnd_mod_id(mod); |
74 | int ws = id; | 73 | int ws = id; |
75 | 74 | ||
76 | if (rsnd_ssi_is_pin_sharing(rsnd_ssi_mod_get(priv, id))) { | 75 | if (rsnd_ssi_is_pin_sharing(io)) { |
77 | switch (id) { | 76 | switch (id) { |
78 | case 1: | 77 | case 1: |
79 | case 2: | 78 | case 2: |
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index eec294da81e3..deed48ef28b8 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c | |||
@@ -300,7 +300,7 @@ u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io) | |||
300 | /* | 300 | /* |
301 | * rsnd_dai functions | 301 | * rsnd_dai functions |
302 | */ | 302 | */ |
303 | #define __rsnd_mod_call(mod, io, func, param...) \ | 303 | #define rsnd_mod_call(mod, io, func, param...) \ |
304 | ({ \ | 304 | ({ \ |
305 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); \ | 305 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); \ |
306 | struct device *dev = rsnd_priv_to_dev(priv); \ | 306 | struct device *dev = rsnd_priv_to_dev(priv); \ |
@@ -308,24 +308,17 @@ u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io) | |||
308 | u8 val = (mod->status >> __rsnd_mod_shift_##func) & 0xF; \ | 308 | u8 val = (mod->status >> __rsnd_mod_shift_##func) & 0xF; \ |
309 | u8 add = ((val + __rsnd_mod_add_##func) & 0xF); \ | 309 | u8 add = ((val + __rsnd_mod_add_##func) & 0xF); \ |
310 | int ret = 0; \ | 310 | int ret = 0; \ |
311 | int called = 0; \ | 311 | int call = (val == __rsnd_mod_call_##func) && (mod)->ops->func; \ |
312 | if (val == __rsnd_mod_call_##func) { \ | ||
313 | called = 1; \ | ||
314 | ret = (mod)->ops->func(mod, io, param); \ | ||
315 | } \ | ||
316 | mod->status = (mod->status & ~mask) + \ | 312 | mod->status = (mod->status & ~mask) + \ |
317 | (add << __rsnd_mod_shift_##func); \ | 313 | (add << __rsnd_mod_shift_##func); \ |
318 | dev_dbg(dev, "%s[%d] 0x%08x %s\n", \ | 314 | dev_dbg(dev, "%s[%d]\t0x%08x %s\n", \ |
319 | rsnd_mod_name(mod), rsnd_mod_id(mod), mod->status, \ | 315 | rsnd_mod_name(mod), rsnd_mod_id(mod), \ |
320 | called ? #func : ""); \ | 316 | mod->status, call ? #func : ""); \ |
317 | if (call) \ | ||
318 | ret = (mod)->ops->func(mod, io, param); \ | ||
321 | ret; \ | 319 | ret; \ |
322 | }) | 320 | }) |
323 | 321 | ||
324 | #define rsnd_mod_call(mod, io, func, param...) \ | ||
325 | (!(mod) ? -ENODEV : \ | ||
326 | !((mod)->ops->func) ? 0 : \ | ||
327 | __rsnd_mod_call(mod, io, func, param)) | ||
328 | |||
329 | #define rsnd_dai_call(fn, io, param...) \ | 322 | #define rsnd_dai_call(fn, io, param...) \ |
330 | ({ \ | 323 | ({ \ |
331 | struct rsnd_mod *mod; \ | 324 | struct rsnd_mod *mod; \ |
@@ -334,9 +327,7 @@ u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io) | |||
334 | mod = (io)->mod[i]; \ | 327 | mod = (io)->mod[i]; \ |
335 | if (!mod) \ | 328 | if (!mod) \ |
336 | continue; \ | 329 | continue; \ |
337 | ret = rsnd_mod_call(mod, io, fn, param); \ | 330 | ret |= rsnd_mod_call(mod, io, fn, param); \ |
338 | if (ret < 0) \ | ||
339 | break; \ | ||
340 | } \ | 331 | } \ |
341 | ret; \ | 332 | ret; \ |
342 | }) | 333 | }) |
@@ -502,16 +493,10 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd, | |||
502 | break; | 493 | break; |
503 | case SNDRV_PCM_TRIGGER_STOP: | 494 | case SNDRV_PCM_TRIGGER_STOP: |
504 | ret = rsnd_dai_call(stop, io, priv); | 495 | ret = rsnd_dai_call(stop, io, priv); |
505 | if (ret < 0) | ||
506 | goto dai_trigger_end; | ||
507 | 496 | ||
508 | ret = rsnd_dai_call(quit, io, priv); | 497 | ret |= rsnd_dai_call(quit, io, priv); |
509 | if (ret < 0) | ||
510 | goto dai_trigger_end; | ||
511 | 498 | ||
512 | ret = rsnd_platform_call(priv, dai, stop, ssi_id); | 499 | ret |= rsnd_platform_call(priv, dai, stop, ssi_id); |
513 | if (ret < 0) | ||
514 | goto dai_trigger_end; | ||
515 | 500 | ||
516 | rsnd_dai_stream_quit(io); | 501 | rsnd_dai_stream_quit(io); |
517 | break; | 502 | break; |
@@ -1236,20 +1221,11 @@ static int rsnd_probe(struct platform_device *pdev) | |||
1236 | }; | 1221 | }; |
1237 | int ret, i; | 1222 | int ret, i; |
1238 | 1223 | ||
1239 | info = NULL; | 1224 | info = devm_kzalloc(&pdev->dev, sizeof(struct rcar_snd_info), |
1240 | of_data = NULL; | 1225 | GFP_KERNEL); |
1241 | if (of_id) { | 1226 | if (!info) |
1242 | info = devm_kzalloc(&pdev->dev, | 1227 | return -ENOMEM; |
1243 | sizeof(struct rcar_snd_info), GFP_KERNEL); | 1228 | of_data = of_id->data; |
1244 | of_data = of_id->data; | ||
1245 | } else { | ||
1246 | info = pdev->dev.platform_data; | ||
1247 | } | ||
1248 | |||
1249 | if (!info) { | ||
1250 | dev_err(dev, "driver needs R-Car sound information\n"); | ||
1251 | return -ENODEV; | ||
1252 | } | ||
1253 | 1229 | ||
1254 | /* | 1230 | /* |
1255 | * init priv data | 1231 | * init priv data |
diff --git a/sound/soc/sh/rcar/ctu.c b/sound/soc/sh/rcar/ctu.c index a3e7c716e1f7..3cb214ab848b 100644 --- a/sound/soc/sh/rcar/ctu.c +++ b/sound/soc/sh/rcar/ctu.c | |||
@@ -35,7 +35,7 @@ static int rsnd_ctu_init(struct rsnd_mod *mod, | |||
35 | struct rsnd_dai_stream *io, | 35 | struct rsnd_dai_stream *io, |
36 | struct rsnd_priv *priv) | 36 | struct rsnd_priv *priv) |
37 | { | 37 | { |
38 | rsnd_mod_hw_start(mod); | 38 | rsnd_mod_power_on(mod); |
39 | 39 | ||
40 | rsnd_ctu_initialize_lock(mod); | 40 | rsnd_ctu_initialize_lock(mod); |
41 | 41 | ||
@@ -50,7 +50,7 @@ static int rsnd_ctu_quit(struct rsnd_mod *mod, | |||
50 | struct rsnd_dai_stream *io, | 50 | struct rsnd_dai_stream *io, |
51 | struct rsnd_priv *priv) | 51 | struct rsnd_priv *priv) |
52 | { | 52 | { |
53 | rsnd_mod_hw_stop(mod); | 53 | rsnd_mod_power_off(mod); |
54 | 54 | ||
55 | return 0; | 55 | return 0; |
56 | } | 56 | } |
@@ -118,10 +118,8 @@ int rsnd_ctu_probe(struct platform_device *pdev, | |||
118 | int i, nr, ret; | 118 | int i, nr, ret; |
119 | 119 | ||
120 | /* This driver doesn't support Gen1 at this point */ | 120 | /* This driver doesn't support Gen1 at this point */ |
121 | if (rsnd_is_gen1(priv)) { | 121 | if (rsnd_is_gen1(priv)) |
122 | dev_warn(dev, "CTU is not supported on Gen1\n"); | 122 | return 0; |
123 | return -EINVAL; | ||
124 | } | ||
125 | 123 | ||
126 | rsnd_of_parse_ctu(pdev, of_data, priv); | 124 | rsnd_of_parse_ctu(pdev, of_data, priv); |
127 | 125 | ||
diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c index bfbb8a5e93bd..5d084d040961 100644 --- a/sound/soc/sh/rcar/dma.c +++ b/sound/soc/sh/rcar/dma.c | |||
@@ -470,7 +470,7 @@ rsnd_gen2_dma_addr(struct rsnd_dai_stream *io, | |||
470 | dev_err(dev, "DVC is selected without SRC\n"); | 470 | dev_err(dev, "DVC is selected without SRC\n"); |
471 | 471 | ||
472 | /* use SSIU or SSI ? */ | 472 | /* use SSIU or SSI ? */ |
473 | if (is_ssi && rsnd_ssi_use_busif(io, mod)) | 473 | if (is_ssi && rsnd_ssi_use_busif(io)) |
474 | is_ssi++; | 474 | is_ssi++; |
475 | 475 | ||
476 | return (is_from) ? | 476 | return (is_from) ? |
diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 8d8eee6350c9..58f690900e6d 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c | |||
@@ -153,7 +153,7 @@ static int rsnd_dvc_init(struct rsnd_mod *mod, | |||
153 | struct rsnd_dai_stream *io, | 153 | struct rsnd_dai_stream *io, |
154 | struct rsnd_priv *priv) | 154 | struct rsnd_priv *priv) |
155 | { | 155 | { |
156 | rsnd_mod_hw_start(mod); | 156 | rsnd_mod_power_on(mod); |
157 | 157 | ||
158 | rsnd_dvc_soft_reset(mod); | 158 | rsnd_dvc_soft_reset(mod); |
159 | 159 | ||
@@ -175,7 +175,7 @@ static int rsnd_dvc_quit(struct rsnd_mod *mod, | |||
175 | struct rsnd_dai_stream *io, | 175 | struct rsnd_dai_stream *io, |
176 | struct rsnd_priv *priv) | 176 | struct rsnd_priv *priv) |
177 | { | 177 | { |
178 | rsnd_mod_hw_stop(mod); | 178 | rsnd_mod_power_off(mod); |
179 | 179 | ||
180 | return 0; | 180 | return 0; |
181 | } | 181 | } |
@@ -333,10 +333,8 @@ int rsnd_dvc_probe(struct platform_device *pdev, | |||
333 | int i, nr, ret; | 333 | int i, nr, ret; |
334 | 334 | ||
335 | /* This driver doesn't support Gen1 at this point */ | 335 | /* This driver doesn't support Gen1 at this point */ |
336 | if (rsnd_is_gen1(priv)) { | 336 | if (rsnd_is_gen1(priv)) |
337 | dev_warn(dev, "CMD is not supported on Gen1\n"); | 337 | return 0; |
338 | return -EINVAL; | ||
339 | } | ||
340 | 338 | ||
341 | rsnd_of_parse_dvc(pdev, of_data, priv); | 339 | rsnd_of_parse_dvc(pdev, of_data, priv); |
342 | 340 | ||
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index f04d17bc6e3d..76da7620904c 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c | |||
@@ -22,13 +22,15 @@ | |||
22 | #include "rsnd.h" | 22 | #include "rsnd.h" |
23 | 23 | ||
24 | struct rsnd_gen { | 24 | struct rsnd_gen { |
25 | void __iomem *base[RSND_BASE_MAX]; | ||
26 | |||
27 | struct rsnd_gen_ops *ops; | 25 | struct rsnd_gen_ops *ops; |
28 | 26 | ||
27 | /* RSND_BASE_MAX base */ | ||
28 | void __iomem *base[RSND_BASE_MAX]; | ||
29 | phys_addr_t res[RSND_BASE_MAX]; | ||
29 | struct regmap *regmap[RSND_BASE_MAX]; | 30 | struct regmap *regmap[RSND_BASE_MAX]; |
31 | |||
32 | /* RSND_REG_MAX base */ | ||
30 | struct regmap_field *regs[RSND_REG_MAX]; | 33 | struct regmap_field *regs[RSND_REG_MAX]; |
31 | phys_addr_t res[RSND_REG_MAX]; | ||
32 | }; | 34 | }; |
33 | 35 | ||
34 | #define rsnd_priv_to_gen(p) ((struct rsnd_gen *)(p)->gen) | 36 | #define rsnd_priv_to_gen(p) ((struct rsnd_gen *)(p)->gen) |
@@ -79,11 +81,11 @@ u32 rsnd_read(struct rsnd_priv *priv, | |||
79 | if (!rsnd_is_accessible_reg(priv, gen, reg)) | 81 | if (!rsnd_is_accessible_reg(priv, gen, reg)) |
80 | return 0; | 82 | return 0; |
81 | 83 | ||
84 | regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val); | ||
85 | |||
82 | dev_dbg(dev, "r %s[%d] - %4d : %08x\n", | 86 | dev_dbg(dev, "r %s[%d] - %4d : %08x\n", |
83 | rsnd_mod_name(mod), rsnd_mod_id(mod), reg, val); | 87 | rsnd_mod_name(mod), rsnd_mod_id(mod), reg, val); |
84 | 88 | ||
85 | regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val); | ||
86 | |||
87 | return val; | 89 | return val; |
88 | } | 90 | } |
89 | 91 | ||
@@ -182,6 +184,7 @@ static int _rsnd_gen_regmap_init(struct rsnd_priv *priv, | |||
182 | if (IS_ERR(regmap)) | 184 | if (IS_ERR(regmap)) |
183 | return PTR_ERR(regmap); | 185 | return PTR_ERR(regmap); |
184 | 186 | ||
187 | /* RSND_BASE_MAX base */ | ||
185 | gen->base[reg_id] = base; | 188 | gen->base[reg_id] = base; |
186 | gen->regmap[reg_id] = regmap; | 189 | gen->regmap[reg_id] = regmap; |
187 | gen->res[reg_id] = res->start; | 190 | gen->res[reg_id] = res->start; |
@@ -198,6 +201,7 @@ static int _rsnd_gen_regmap_init(struct rsnd_priv *priv, | |||
198 | if (IS_ERR(regs)) | 201 | if (IS_ERR(regs)) |
199 | return PTR_ERR(regs); | 202 | return PTR_ERR(regs); |
200 | 203 | ||
204 | /* RSND_REG_MAX base */ | ||
201 | gen->regs[conf[i].idx] = regs; | 205 | gen->regs[conf[i].idx] = regs; |
202 | } | 206 | } |
203 | 207 | ||
diff --git a/sound/soc/sh/rcar/mix.c b/sound/soc/sh/rcar/mix.c index 8544403ffb26..953dd0be9b60 100644 --- a/sound/soc/sh/rcar/mix.c +++ b/sound/soc/sh/rcar/mix.c | |||
@@ -58,7 +58,7 @@ static int rsnd_mix_init(struct rsnd_mod *mod, | |||
58 | struct rsnd_dai_stream *io, | 58 | struct rsnd_dai_stream *io, |
59 | struct rsnd_priv *priv) | 59 | struct rsnd_priv *priv) |
60 | { | 60 | { |
61 | rsnd_mod_hw_start(mod); | 61 | rsnd_mod_power_on(mod); |
62 | 62 | ||
63 | rsnd_mix_soft_reset(mod); | 63 | rsnd_mix_soft_reset(mod); |
64 | 64 | ||
@@ -83,7 +83,7 @@ static int rsnd_mix_quit(struct rsnd_mod *mod, | |||
83 | struct rsnd_dai_stream *io, | 83 | struct rsnd_dai_stream *io, |
84 | struct rsnd_priv *priv) | 84 | struct rsnd_priv *priv) |
85 | { | 85 | { |
86 | rsnd_mod_hw_stop(mod); | 86 | rsnd_mod_power_off(mod); |
87 | 87 | ||
88 | return 0; | 88 | return 0; |
89 | } | 89 | } |
@@ -151,10 +151,8 @@ int rsnd_mix_probe(struct platform_device *pdev, | |||
151 | int i, nr, ret; | 151 | int i, nr, ret; |
152 | 152 | ||
153 | /* This driver doesn't support Gen1 at this point */ | 153 | /* This driver doesn't support Gen1 at this point */ |
154 | if (rsnd_is_gen1(priv)) { | 154 | if (rsnd_is_gen1(priv)) |
155 | dev_warn(dev, "MIX is not supported on Gen1\n"); | 155 | return 0; |
156 | return -EINVAL; | ||
157 | } | ||
158 | 156 | ||
159 | rsnd_of_parse_mix(pdev, of_data, priv); | 157 | rsnd_of_parse_mix(pdev, of_data, priv); |
160 | 158 | ||
diff --git a/include/sound/rcar_snd.h b/sound/soc/sh/rcar/rcar_snd.h index d8e33d38da43..d8e33d38da43 100644 --- a/include/sound/rcar_snd.h +++ b/sound/soc/sh/rcar/rcar_snd.h | |||
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index e4068d78616c..085329878525 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
@@ -21,10 +21,11 @@ | |||
21 | #include <linux/of_irq.h> | 21 | #include <linux/of_irq.h> |
22 | #include <linux/sh_dma.h> | 22 | #include <linux/sh_dma.h> |
23 | #include <linux/workqueue.h> | 23 | #include <linux/workqueue.h> |
24 | #include <sound/rcar_snd.h> | ||
25 | #include <sound/soc.h> | 24 | #include <sound/soc.h> |
26 | #include <sound/pcm_params.h> | 25 | #include <sound/pcm_params.h> |
27 | 26 | ||
27 | #include "rcar_snd.h" | ||
28 | |||
28 | /* | 29 | /* |
29 | * pseudo register | 30 | * pseudo register |
30 | * | 31 | * |
@@ -329,8 +330,8 @@ struct rsnd_mod { | |||
329 | #define rsnd_mod_to_priv(mod) ((mod)->priv) | 330 | #define rsnd_mod_to_priv(mod) ((mod)->priv) |
330 | #define rsnd_mod_to_dma(mod) (&(mod)->dma) | 331 | #define rsnd_mod_to_dma(mod) (&(mod)->dma) |
331 | #define rsnd_mod_id(mod) ((mod) ? (mod)->id : -1) | 332 | #define rsnd_mod_id(mod) ((mod) ? (mod)->id : -1) |
332 | #define rsnd_mod_hw_start(mod) clk_enable((mod)->clk) | 333 | #define rsnd_mod_power_on(mod) clk_enable((mod)->clk) |
333 | #define rsnd_mod_hw_stop(mod) clk_disable((mod)->clk) | 334 | #define rsnd_mod_power_off(mod) clk_disable((mod)->clk) |
334 | #define rsnd_mod_get(ip) (&(ip)->mod) | 335 | #define rsnd_mod_get(ip) (&(ip)->mod) |
335 | 336 | ||
336 | int rsnd_mod_init(struct rsnd_priv *priv, | 337 | int rsnd_mod_init(struct rsnd_priv *priv, |
@@ -571,9 +572,12 @@ int rsnd_ssi_probe(struct platform_device *pdev, | |||
571 | void rsnd_ssi_remove(struct platform_device *pdev, | 572 | void rsnd_ssi_remove(struct platform_device *pdev, |
572 | struct rsnd_priv *priv); | 573 | struct rsnd_priv *priv); |
573 | struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id); | 574 | struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id); |
574 | int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod); | ||
575 | int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod); | 575 | int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod); |
576 | int rsnd_ssi_use_busif(struct rsnd_dai_stream *io, struct rsnd_mod *mod); | 576 | int rsnd_ssi_use_busif(struct rsnd_dai_stream *io); |
577 | |||
578 | #define rsnd_ssi_is_pin_sharing(io) \ | ||
579 | __rsnd_ssi_is_pin_sharing(rsnd_io_to_mod_ssi(io)) | ||
580 | int __rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod); | ||
577 | 581 | ||
578 | /* | 582 | /* |
579 | * R-Car SRC | 583 | * R-Car SRC |
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index ca7a20f03c9b..261b50217c48 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c | |||
@@ -159,7 +159,7 @@ int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, | |||
159 | /* | 159 | /* |
160 | * SSI_MODE1 | 160 | * SSI_MODE1 |
161 | */ | 161 | */ |
162 | if (rsnd_ssi_is_pin_sharing(ssi_mod)) { | 162 | if (rsnd_ssi_is_pin_sharing(io)) { |
163 | int shift = -1; | 163 | int shift = -1; |
164 | switch (ssi_id) { | 164 | switch (ssi_id) { |
165 | case 1: | 165 | case 1: |
@@ -352,7 +352,7 @@ static int rsnd_src_init(struct rsnd_mod *mod, | |||
352 | { | 352 | { |
353 | struct rsnd_src *src = rsnd_mod_to_src(mod); | 353 | struct rsnd_src *src = rsnd_mod_to_src(mod); |
354 | 354 | ||
355 | rsnd_mod_hw_start(mod); | 355 | rsnd_mod_power_on(mod); |
356 | 356 | ||
357 | rsnd_src_soft_reset(mod); | 357 | rsnd_src_soft_reset(mod); |
358 | 358 | ||
@@ -373,7 +373,7 @@ static int rsnd_src_quit(struct rsnd_mod *mod, | |||
373 | struct rsnd_src *src = rsnd_mod_to_src(mod); | 373 | struct rsnd_src *src = rsnd_mod_to_src(mod); |
374 | struct device *dev = rsnd_priv_to_dev(priv); | 374 | struct device *dev = rsnd_priv_to_dev(priv); |
375 | 375 | ||
376 | rsnd_mod_hw_stop(mod); | 376 | rsnd_mod_power_off(mod); |
377 | 377 | ||
378 | if (src->err) | 378 | if (src->err) |
379 | dev_warn(dev, "%s[%d] under/over flow err = %d\n", | 379 | dev_warn(dev, "%s[%d] under/over flow err = %d\n", |
@@ -1036,8 +1036,10 @@ int rsnd_src_probe(struct platform_device *pdev, | |||
1036 | int i, nr, ret; | 1036 | int i, nr, ret; |
1037 | 1037 | ||
1038 | ops = NULL; | 1038 | ops = NULL; |
1039 | if (rsnd_is_gen1(priv)) | 1039 | if (rsnd_is_gen1(priv)) { |
1040 | ops = &rsnd_src_gen1_ops; | 1040 | ops = &rsnd_src_gen1_ops; |
1041 | dev_warn(dev, "Gen1 support will be removed soon\n"); | ||
1042 | } | ||
1041 | if (rsnd_is_gen2(priv)) | 1043 | if (rsnd_is_gen2(priv)) |
1042 | ops = &rsnd_src_gen2_ops; | 1044 | ops = &rsnd_src_gen2_ops; |
1043 | if (!ops) { | 1045 | if (!ops) { |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 5e05f9422073..1427ec21bd7e 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
@@ -79,7 +79,6 @@ struct rsnd_ssi { | |||
79 | 79 | ||
80 | #define rsnd_ssi_nr(priv) ((priv)->ssi_nr) | 80 | #define rsnd_ssi_nr(priv) ((priv)->ssi_nr) |
81 | #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod) | 81 | #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod) |
82 | #define rsnd_dma_to_ssi(dma) rsnd_mod_to_ssi(rsnd_dma_to_mod(dma)) | ||
83 | #define rsnd_ssi_pio_available(ssi) ((ssi)->info->irq > 0) | 82 | #define rsnd_ssi_pio_available(ssi) ((ssi)->info->irq > 0) |
84 | #define rsnd_ssi_parent(ssi) ((ssi)->parent) | 83 | #define rsnd_ssi_parent(ssi) ((ssi)->parent) |
85 | #define rsnd_ssi_mode_flags(p) ((p)->info->flags) | 84 | #define rsnd_ssi_mode_flags(p) ((p)->info->flags) |
@@ -87,8 +86,9 @@ struct rsnd_ssi { | |||
87 | #define rsnd_ssi_of_node(priv) \ | 86 | #define rsnd_ssi_of_node(priv) \ |
88 | of_get_child_by_name(rsnd_priv_to_dev(priv)->of_node, "rcar_sound,ssi") | 87 | of_get_child_by_name(rsnd_priv_to_dev(priv)->of_node, "rcar_sound,ssi") |
89 | 88 | ||
90 | int rsnd_ssi_use_busif(struct rsnd_dai_stream *io, struct rsnd_mod *mod) | 89 | int rsnd_ssi_use_busif(struct rsnd_dai_stream *io) |
91 | { | 90 | { |
91 | struct rsnd_mod *mod = rsnd_io_to_mod_ssi(io); | ||
92 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); | 92 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
93 | int use_busif = 0; | 93 | int use_busif = 0; |
94 | 94 | ||
@@ -184,7 +184,7 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, | |||
184 | u32 cr; | 184 | u32 cr; |
185 | 185 | ||
186 | if (0 == ssi->usrcnt) { | 186 | if (0 == ssi->usrcnt) { |
187 | rsnd_mod_hw_start(mod); | 187 | rsnd_mod_power_on(mod); |
188 | 188 | ||
189 | if (rsnd_rdai_is_clk_master(rdai)) { | 189 | if (rsnd_rdai_is_clk_master(rdai)) { |
190 | struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi); | 190 | struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi); |
@@ -265,7 +265,7 @@ static void rsnd_ssi_hw_stop(struct rsnd_dai_stream *io, struct rsnd_ssi *ssi) | |||
265 | rsnd_ssi_master_clk_stop(ssi); | 265 | rsnd_ssi_master_clk_stop(ssi); |
266 | } | 266 | } |
267 | 267 | ||
268 | rsnd_mod_hw_stop(mod); | 268 | rsnd_mod_power_off(mod); |
269 | 269 | ||
270 | ssi->chan = 0; | 270 | ssi->chan = 0; |
271 | } | 271 | } |
@@ -395,7 +395,7 @@ static int rsnd_ssi_start(struct rsnd_mod *mod, | |||
395 | { | 395 | { |
396 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); | 396 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
397 | 397 | ||
398 | rsnd_src_ssiu_start(mod, io, rsnd_ssi_use_busif(io, mod)); | 398 | rsnd_src_ssiu_start(mod, io, rsnd_ssi_use_busif(io)); |
399 | 399 | ||
400 | rsnd_ssi_hw_start(ssi, io); | 400 | rsnd_ssi_hw_start(ssi, io); |
401 | 401 | ||
@@ -555,7 +555,7 @@ static int rsnd_ssi_dma_remove(struct rsnd_mod *mod, | |||
555 | rsnd_dma_quit(io, rsnd_mod_to_dma(mod)); | 555 | rsnd_dma_quit(io, rsnd_mod_to_dma(mod)); |
556 | 556 | ||
557 | /* PIO will request IRQ again */ | 557 | /* PIO will request IRQ again */ |
558 | devm_free_irq(dev, irq, ssi); | 558 | devm_free_irq(dev, irq, mod); |
559 | 559 | ||
560 | return 0; | 560 | return 0; |
561 | } | 561 | } |
@@ -614,7 +614,7 @@ static struct dma_chan *rsnd_ssi_dma_req(struct rsnd_dai_stream *io, | |||
614 | int is_play = rsnd_io_is_play(io); | 614 | int is_play = rsnd_io_is_play(io); |
615 | char *name; | 615 | char *name; |
616 | 616 | ||
617 | if (rsnd_ssi_use_busif(io, mod)) | 617 | if (rsnd_ssi_use_busif(io)) |
618 | name = is_play ? "rxu" : "txu"; | 618 | name = is_play ? "rxu" : "txu"; |
619 | else | 619 | else |
620 | name = is_play ? "rx" : "tx"; | 620 | name = is_play ? "rx" : "tx"; |
@@ -660,7 +660,7 @@ struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id) | |||
660 | return rsnd_mod_get((struct rsnd_ssi *)(priv->ssi) + id); | 660 | return rsnd_mod_get((struct rsnd_ssi *)(priv->ssi) + id); |
661 | } | 661 | } |
662 | 662 | ||
663 | int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod) | 663 | int __rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod) |
664 | { | 664 | { |
665 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); | 665 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); |
666 | 666 | ||
@@ -671,7 +671,7 @@ static void rsnd_ssi_parent_setup(struct rsnd_priv *priv, struct rsnd_ssi *ssi) | |||
671 | { | 671 | { |
672 | struct rsnd_mod *mod = rsnd_mod_get(ssi); | 672 | struct rsnd_mod *mod = rsnd_mod_get(ssi); |
673 | 673 | ||
674 | if (!rsnd_ssi_is_pin_sharing(mod)) | 674 | if (!__rsnd_ssi_is_pin_sharing(mod)) |
675 | return; | 675 | return; |
676 | 676 | ||
677 | switch (rsnd_mod_id(mod)) { | 677 | switch (rsnd_mod_id(mod)) { |
@@ -700,9 +700,6 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev, | |||
700 | struct device *dev = &pdev->dev; | 700 | struct device *dev = &pdev->dev; |
701 | int nr, i; | 701 | int nr, i; |
702 | 702 | ||
703 | if (!of_data) | ||
704 | return; | ||
705 | |||
706 | node = rsnd_ssi_of_node(priv); | 703 | node = rsnd_ssi_of_node(priv); |
707 | if (!node) | 704 | if (!node) |
708 | return; | 705 | return; |
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 025c38fbe3c0..12a9820feac1 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c | |||
@@ -612,8 +612,15 @@ static struct snd_compr_ops soc_compr_dyn_ops = { | |||
612 | .get_codec_caps = soc_compr_get_codec_caps | 612 | .get_codec_caps = soc_compr_get_codec_caps |
613 | }; | 613 | }; |
614 | 614 | ||
615 | /* create a new compress */ | 615 | /** |
616 | int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) | 616 | * snd_soc_new_compress - create a new compress. |
617 | * | ||
618 | * @rtd: The runtime for which we will create compress | ||
619 | * @num: the device index number (zero based - shared with normal PCMs) | ||
620 | * | ||
621 | * Return: 0 for success, else error. | ||
622 | */ | ||
623 | int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) | ||
617 | { | 624 | { |
618 | struct snd_soc_codec *codec = rtd->codec; | 625 | struct snd_soc_codec *codec = rtd->codec; |
619 | struct snd_soc_platform *platform = rtd->platform; | 626 | struct snd_soc_platform *platform = rtd->platform; |
@@ -703,3 +710,4 @@ compr_err: | |||
703 | kfree(compr); | 710 | kfree(compr); |
704 | return ret; | 711 | return ret; |
705 | } | 712 | } |
713 | EXPORT_SYMBOL_GPL(snd_soc_new_compress); | ||
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3b471f9c98c6..24b096066a07 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -1370,9 +1370,9 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | |||
1370 | soc_dpcm_debugfs_add(rtd); | 1370 | soc_dpcm_debugfs_add(rtd); |
1371 | #endif | 1371 | #endif |
1372 | 1372 | ||
1373 | if (cpu_dai->driver->compress_dai) { | 1373 | if (cpu_dai->driver->compress_new) { |
1374 | /*create compress_device"*/ | 1374 | /*create compress_device"*/ |
1375 | ret = soc_new_compress(rtd, num); | 1375 | ret = cpu_dai->driver->compress_new(rtd, num); |
1376 | if (ret < 0) { | 1376 | if (ret < 0) { |
1377 | dev_err(card->dev, "ASoC: can't create compress %s\n", | 1377 | dev_err(card->dev, "ASoC: can't create compress %s\n", |
1378 | dai_link->stream_name); | 1378 | dai_link->stream_name); |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index ff8bda471b25..016eba10b1ec 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -509,6 +509,18 @@ static bool dapm_kcontrol_set_value(const struct snd_kcontrol *kcontrol, | |||
509 | } | 509 | } |
510 | 510 | ||
511 | /** | 511 | /** |
512 | * snd_soc_dapm_kcontrol_widget() - Returns the widget associated to a | ||
513 | * kcontrol | ||
514 | * @kcontrol: The kcontrol | ||
515 | */ | ||
516 | struct snd_soc_dapm_widget *snd_soc_dapm_kcontrol_widget( | ||
517 | struct snd_kcontrol *kcontrol) | ||
518 | { | ||
519 | return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]; | ||
520 | } | ||
521 | EXPORT_SYMBOL_GPL(snd_soc_dapm_kcontrol_widget); | ||
522 | |||
523 | /** | ||
512 | * snd_soc_dapm_kcontrol_dapm() - Returns the dapm context associated to a | 524 | * snd_soc_dapm_kcontrol_dapm() - Returns the dapm context associated to a |
513 | * kcontrol | 525 | * kcontrol |
514 | * @kcontrol: The kcontrol | 526 | * @kcontrol: The kcontrol |
@@ -779,7 +791,7 @@ static int dapm_is_shared_kcontrol(struct snd_soc_dapm_context *dapm, | |||
779 | * Determine if a kcontrol is shared. If it is, look it up. If it isn't, | 791 | * Determine if a kcontrol is shared. If it is, look it up. If it isn't, |
780 | * create it. Either way, add the widget into the control's widget list | 792 | * create it. Either way, add the widget into the control's widget list |
781 | */ | 793 | */ |
782 | static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w, | 794 | static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w, |
783 | int kci) | 795 | int kci) |
784 | { | 796 | { |
785 | struct snd_soc_dapm_context *dapm = w->dapm; | 797 | struct snd_soc_dapm_context *dapm = w->dapm; |
@@ -810,6 +822,7 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w, | |||
810 | switch (w->id) { | 822 | switch (w->id) { |
811 | case snd_soc_dapm_switch: | 823 | case snd_soc_dapm_switch: |
812 | case snd_soc_dapm_mixer: | 824 | case snd_soc_dapm_mixer: |
825 | case snd_soc_dapm_pga: | ||
813 | wname_in_long_name = true; | 826 | wname_in_long_name = true; |
814 | kcname_in_long_name = true; | 827 | kcname_in_long_name = true; |
815 | break; | 828 | break; |
@@ -899,7 +912,7 @@ static int dapm_new_mixer(struct snd_soc_dapm_widget *w) | |||
899 | continue; | 912 | continue; |
900 | 913 | ||
901 | if (!w->kcontrols[i]) { | 914 | if (!w->kcontrols[i]) { |
902 | ret = dapm_create_or_share_mixmux_kcontrol(w, i); | 915 | ret = dapm_create_or_share_kcontrol(w, i); |
903 | if (ret < 0) | 916 | if (ret < 0) |
904 | return ret; | 917 | return ret; |
905 | } | 918 | } |
@@ -952,7 +965,7 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w) | |||
952 | return -EINVAL; | 965 | return -EINVAL; |
953 | } | 966 | } |
954 | 967 | ||
955 | ret = dapm_create_or_share_mixmux_kcontrol(w, 0); | 968 | ret = dapm_create_or_share_kcontrol(w, 0); |
956 | if (ret < 0) | 969 | if (ret < 0) |
957 | return ret; | 970 | return ret; |
958 | 971 | ||
@@ -967,9 +980,13 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w) | |||
967 | /* create new dapm volume control */ | 980 | /* create new dapm volume control */ |
968 | static int dapm_new_pga(struct snd_soc_dapm_widget *w) | 981 | static int dapm_new_pga(struct snd_soc_dapm_widget *w) |
969 | { | 982 | { |
970 | if (w->num_kcontrols) | 983 | int i, ret; |
971 | dev_err(w->dapm->dev, | 984 | |
972 | "ASoC: PGA controls not supported: '%s'\n", w->name); | 985 | for (i = 0; i < w->num_kcontrols; i++) { |
986 | ret = dapm_create_or_share_kcontrol(w, i); | ||
987 | if (ret < 0) | ||
988 | return ret; | ||
989 | } | ||
973 | 990 | ||
974 | return 0; | 991 | return 0; |
975 | } | 992 | } |
@@ -3473,11 +3490,29 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
3473 | switch (event) { | 3490 | switch (event) { |
3474 | case SND_SOC_DAPM_PRE_PMU: | 3491 | case SND_SOC_DAPM_PRE_PMU: |
3475 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; | 3492 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; |
3493 | if (source->driver->ops && source->driver->ops->startup) { | ||
3494 | ret = source->driver->ops->startup(&substream, source); | ||
3495 | if (ret < 0) { | ||
3496 | dev_err(source->dev, | ||
3497 | "ASoC: startup() failed: %d\n", ret); | ||
3498 | goto out; | ||
3499 | } | ||
3500 | source->active++; | ||
3501 | } | ||
3476 | ret = soc_dai_hw_params(&substream, params, source); | 3502 | ret = soc_dai_hw_params(&substream, params, source); |
3477 | if (ret < 0) | 3503 | if (ret < 0) |
3478 | goto out; | 3504 | goto out; |
3479 | 3505 | ||
3480 | substream.stream = SNDRV_PCM_STREAM_PLAYBACK; | 3506 | substream.stream = SNDRV_PCM_STREAM_PLAYBACK; |
3507 | if (sink->driver->ops && sink->driver->ops->startup) { | ||
3508 | ret = sink->driver->ops->startup(&substream, sink); | ||
3509 | if (ret < 0) { | ||
3510 | dev_err(sink->dev, | ||
3511 | "ASoC: startup() failed: %d\n", ret); | ||
3512 | goto out; | ||
3513 | } | ||
3514 | sink->active++; | ||
3515 | } | ||
3481 | ret = soc_dai_hw_params(&substream, params, sink); | 3516 | ret = soc_dai_hw_params(&substream, params, sink); |
3482 | if (ret < 0) | 3517 | if (ret < 0) |
3483 | goto out; | 3518 | goto out; |
@@ -3497,6 +3532,18 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
3497 | if (ret != 0 && ret != -ENOTSUPP) | 3532 | if (ret != 0 && ret != -ENOTSUPP) |
3498 | dev_warn(sink->dev, "ASoC: Failed to mute: %d\n", ret); | 3533 | dev_warn(sink->dev, "ASoC: Failed to mute: %d\n", ret); |
3499 | ret = 0; | 3534 | ret = 0; |
3535 | |||
3536 | source->active--; | ||
3537 | if (source->driver->ops && source->driver->ops->shutdown) { | ||
3538 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; | ||
3539 | source->driver->ops->shutdown(&substream, source); | ||
3540 | } | ||
3541 | |||
3542 | sink->active--; | ||
3543 | if (sink->driver->ops && sink->driver->ops->shutdown) { | ||
3544 | substream.stream = SNDRV_PCM_STREAM_PLAYBACK; | ||
3545 | sink->driver->ops->shutdown(&substream, sink); | ||
3546 | } | ||
3500 | break; | 3547 | break; |
3501 | 3548 | ||
3502 | default: | 3549 | default: |
diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index 100d92b5b77e..ecd38e52285a 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c | |||
@@ -207,6 +207,34 @@ int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, | |||
207 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw); | 207 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * snd_soc_info_volsw_sx - Mixer info callback for SX TLV controls | ||
211 | * @kcontrol: mixer control | ||
212 | * @uinfo: control element information | ||
213 | * | ||
214 | * Callback to provide information about a single mixer control, or a double | ||
215 | * mixer control that spans 2 registers of the SX TLV type. SX TLV controls | ||
216 | * have a range that represents both positive and negative values either side | ||
217 | * of zero but without a sign bit. | ||
218 | * | ||
219 | * Returns 0 for success. | ||
220 | */ | ||
221 | int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol, | ||
222 | struct snd_ctl_elem_info *uinfo) | ||
223 | { | ||
224 | struct soc_mixer_control *mc = | ||
225 | (struct soc_mixer_control *)kcontrol->private_value; | ||
226 | |||
227 | snd_soc_info_volsw(kcontrol, uinfo); | ||
228 | /* Max represents the number of levels in an SX control not the | ||
229 | * maximum value, so add the minimum value back on | ||
230 | */ | ||
231 | uinfo->value.integer.max += mc->min; | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw_sx); | ||
236 | |||
237 | /** | ||
210 | * snd_soc_get_volsw - single mixer get callback | 238 | * snd_soc_get_volsw - single mixer get callback |
211 | * @kcontrol: mixer control | 239 | * @kcontrol: mixer control |
212 | * @ucontrol: control element information | 240 | * @ucontrol: control element information |
@@ -560,16 +588,16 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_range); | |||
560 | /** | 588 | /** |
561 | * snd_soc_limit_volume - Set new limit to an existing volume control. | 589 | * snd_soc_limit_volume - Set new limit to an existing volume control. |
562 | * | 590 | * |
563 | * @codec: where to look for the control | 591 | * @card: where to look for the control |
564 | * @name: Name of the control | 592 | * @name: Name of the control |
565 | * @max: new maximum limit | 593 | * @max: new maximum limit |
566 | * | 594 | * |
567 | * Return 0 for success, else error. | 595 | * Return 0 for success, else error. |
568 | */ | 596 | */ |
569 | int snd_soc_limit_volume(struct snd_soc_codec *codec, | 597 | int snd_soc_limit_volume(struct snd_soc_card *card, |
570 | const char *name, int max) | 598 | const char *name, int max) |
571 | { | 599 | { |
572 | struct snd_card *card = codec->component.card->snd_card; | 600 | struct snd_card *snd_card = card->snd_card; |
573 | struct snd_kcontrol *kctl; | 601 | struct snd_kcontrol *kctl; |
574 | struct soc_mixer_control *mc; | 602 | struct soc_mixer_control *mc; |
575 | int found = 0; | 603 | int found = 0; |
@@ -579,7 +607,7 @@ int snd_soc_limit_volume(struct snd_soc_codec *codec, | |||
579 | if (unlikely(!name || max <= 0)) | 607 | if (unlikely(!name || max <= 0)) |
580 | return -EINVAL; | 608 | return -EINVAL; |
581 | 609 | ||
582 | list_for_each_entry(kctl, &card->controls, list) { | 610 | list_for_each_entry(kctl, &snd_card->controls, list) { |
583 | if (!strncmp(kctl->id.name, name, sizeof(kctl->id.name))) { | 611 | if (!strncmp(kctl->id.name, name, sizeof(kctl->id.name))) { |
584 | found = 1; | 612 | found = 1; |
585 | break; | 613 | break; |
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 69d01cd925ce..8d7ec80af51b 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c | |||
@@ -1558,7 +1558,7 @@ static int soc_tplg_pcm_dai_elems_load(struct soc_tplg *tplg, | |||
1558 | pcm_dai = (struct snd_soc_tplg_pcm_dai *)tplg->pos; | 1558 | pcm_dai = (struct snd_soc_tplg_pcm_dai *)tplg->pos; |
1559 | 1559 | ||
1560 | if (soc_tplg_check_elem_count(tplg, | 1560 | if (soc_tplg_check_elem_count(tplg, |
1561 | sizeof(struct snd_soc_tplg_pcm_dai), count, | 1561 | sizeof(struct snd_soc_tplg_pcm), count, |
1562 | hdr->payload_size, "PCM DAI")) { | 1562 | hdr->payload_size, "PCM DAI")) { |
1563 | dev_err(tplg->dev, "ASoC: invalid count %d for PCM DAI elems\n", | 1563 | dev_err(tplg->dev, "ASoC: invalid count %d for PCM DAI elems\n", |
1564 | count); | 1564 | count); |
@@ -1566,7 +1566,7 @@ static int soc_tplg_pcm_dai_elems_load(struct soc_tplg *tplg, | |||
1566 | } | 1566 | } |
1567 | 1567 | ||
1568 | dev_dbg(tplg->dev, "ASoC: adding %d PCM DAIs\n", count); | 1568 | dev_dbg(tplg->dev, "ASoC: adding %d PCM DAIs\n", count); |
1569 | tplg->pos += sizeof(struct snd_soc_tplg_pcm_dai) * count; | 1569 | tplg->pos += sizeof(struct snd_soc_tplg_pcm) * count; |
1570 | 1570 | ||
1571 | dobj = kzalloc(sizeof(struct snd_soc_dobj), GFP_KERNEL); | 1571 | dobj = kzalloc(sizeof(struct snd_soc_dobj), GFP_KERNEL); |
1572 | if (dobj == NULL) | 1572 | if (dobj == NULL) |
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 8d59d83b5aa4..bcbf4da168b6 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c | |||
@@ -283,7 +283,7 @@ static int sun4i_codec_hw_params(struct snd_pcm_substream *substream, | |||
283 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 283 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
284 | struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); | 284 | struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card); |
285 | unsigned long clk_freq; | 285 | unsigned long clk_freq; |
286 | int hwrate; | 286 | int ret, hwrate; |
287 | u32 val; | 287 | u32 val; |
288 | 288 | ||
289 | if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) | 289 | if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) |
@@ -293,8 +293,9 @@ static int sun4i_codec_hw_params(struct snd_pcm_substream *substream, | |||
293 | if (!clk_freq) | 293 | if (!clk_freq) |
294 | return -EINVAL; | 294 | return -EINVAL; |
295 | 295 | ||
296 | if (clk_set_rate(scodec->clk_module, clk_freq)) | 296 | ret = clk_set_rate(scodec->clk_module, clk_freq); |
297 | return -EINVAL; | 297 | if (ret) |
298 | return ret; | ||
298 | 299 | ||
299 | hwrate = sun4i_codec_get_hw_rate(params); | 300 | hwrate = sun4i_codec_get_hw_rate(params); |
300 | if (hwrate < 0) | 301 | if (hwrate < 0) |
@@ -388,8 +389,7 @@ static struct snd_soc_dai_driver sun4i_codec_dai = { | |||
388 | .rate_max = 192000, | 389 | .rate_max = 192000, |
389 | .rates = SNDRV_PCM_RATE_8000_48000 | | 390 | .rates = SNDRV_PCM_RATE_8000_48000 | |
390 | SNDRV_PCM_RATE_96000 | | 391 | SNDRV_PCM_RATE_96000 | |
391 | SNDRV_PCM_RATE_192000 | | 392 | SNDRV_PCM_RATE_192000, |
392 | SNDRV_PCM_RATE_KNOT, | ||
393 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | 393 | .formats = SNDRV_PCM_FMTBIT_S16_LE | |
394 | SNDRV_PCM_FMTBIT_S32_LE, | 394 | SNDRV_PCM_FMTBIT_S32_LE, |
395 | .sig_bits = 24, | 395 | .sig_bits = 24, |
@@ -571,7 +571,6 @@ static struct snd_soc_dai_link *sun4i_codec_create_link(struct device *dev, | |||
571 | static struct snd_soc_card *sun4i_codec_create_card(struct device *dev) | 571 | static struct snd_soc_card *sun4i_codec_create_card(struct device *dev) |
572 | { | 572 | { |
573 | struct snd_soc_card *card; | 573 | struct snd_soc_card *card; |
574 | int ret; | ||
575 | 574 | ||
576 | card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); | 575 | card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); |
577 | if (!card) | 576 | if (!card) |
@@ -584,12 +583,6 @@ static struct snd_soc_card *sun4i_codec_create_card(struct device *dev) | |||
584 | card->dev = dev; | 583 | card->dev = dev; |
585 | card->name = "sun4i-codec"; | 584 | card->name = "sun4i-codec"; |
586 | 585 | ||
587 | ret = snd_soc_of_parse_audio_routing(card, "routing"); | ||
588 | if (ret) { | ||
589 | dev_err(dev, "Failed to create our audio routing\n"); | ||
590 | return NULL; | ||
591 | } | ||
592 | |||
593 | return card; | 586 | return card; |
594 | }; | 587 | }; |
595 | 588 | ||
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 48c6e1ac6827..b9d3a32cbc04 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c | |||
@@ -137,6 +137,8 @@ bool kvm_timer_should_fire(struct kvm_vcpu *vcpu) | |||
137 | void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) | 137 | void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) |
138 | { | 138 | { |
139 | struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; | 139 | struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; |
140 | bool phys_active; | ||
141 | int ret; | ||
140 | 142 | ||
141 | /* | 143 | /* |
142 | * We're about to run this vcpu again, so there is no need to | 144 | * We're about to run this vcpu again, so there is no need to |
@@ -151,6 +153,23 @@ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) | |||
151 | */ | 153 | */ |
152 | if (kvm_timer_should_fire(vcpu)) | 154 | if (kvm_timer_should_fire(vcpu)) |
153 | kvm_timer_inject_irq(vcpu); | 155 | kvm_timer_inject_irq(vcpu); |
156 | |||
157 | /* | ||
158 | * We keep track of whether the edge-triggered interrupt has been | ||
159 | * signalled to the vgic/guest, and if so, we mask the interrupt and | ||
160 | * the physical distributor to prevent the timer from raising a | ||
161 | * physical interrupt whenever we run a guest, preventing forward | ||
162 | * VCPU progress. | ||
163 | */ | ||
164 | if (kvm_vgic_get_phys_irq_active(timer->map)) | ||
165 | phys_active = true; | ||
166 | else | ||
167 | phys_active = false; | ||
168 | |||
169 | ret = irq_set_irqchip_state(timer->map->irq, | ||
170 | IRQCHIP_STATE_ACTIVE, | ||
171 | phys_active); | ||
172 | WARN_ON(ret); | ||
154 | } | 173 | } |
155 | 174 | ||
156 | /** | 175 | /** |
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 6bd1c9bf7ae7..66c66165e712 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c | |||
@@ -531,6 +531,34 @@ bool vgic_handle_set_pending_reg(struct kvm *kvm, | |||
531 | return false; | 531 | return false; |
532 | } | 532 | } |
533 | 533 | ||
534 | /* | ||
535 | * If a mapped interrupt's state has been modified by the guest such that it | ||
536 | * is no longer active or pending, without it have gone through the sync path, | ||
537 | * then the map->active field must be cleared so the interrupt can be taken | ||
538 | * again. | ||
539 | */ | ||
540 | static void vgic_handle_clear_mapped_irq(struct kvm_vcpu *vcpu) | ||
541 | { | ||
542 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; | ||
543 | struct list_head *root; | ||
544 | struct irq_phys_map_entry *entry; | ||
545 | struct irq_phys_map *map; | ||
546 | |||
547 | rcu_read_lock(); | ||
548 | |||
549 | /* Check for PPIs */ | ||
550 | root = &vgic_cpu->irq_phys_map_list; | ||
551 | list_for_each_entry_rcu(entry, root, entry) { | ||
552 | map = &entry->map; | ||
553 | |||
554 | if (!vgic_dist_irq_is_pending(vcpu, map->virt_irq) && | ||
555 | !vgic_irq_is_active(vcpu, map->virt_irq)) | ||
556 | map->active = false; | ||
557 | } | ||
558 | |||
559 | rcu_read_unlock(); | ||
560 | } | ||
561 | |||
534 | bool vgic_handle_clear_pending_reg(struct kvm *kvm, | 562 | bool vgic_handle_clear_pending_reg(struct kvm *kvm, |
535 | struct kvm_exit_mmio *mmio, | 563 | struct kvm_exit_mmio *mmio, |
536 | phys_addr_t offset, int vcpu_id) | 564 | phys_addr_t offset, int vcpu_id) |
@@ -561,6 +589,7 @@ bool vgic_handle_clear_pending_reg(struct kvm *kvm, | |||
561 | vcpu_id, offset); | 589 | vcpu_id, offset); |
562 | vgic_reg_access(mmio, reg, offset, mode); | 590 | vgic_reg_access(mmio, reg, offset, mode); |
563 | 591 | ||
592 | vgic_handle_clear_mapped_irq(kvm_get_vcpu(kvm, vcpu_id)); | ||
564 | vgic_update_state(kvm); | 593 | vgic_update_state(kvm); |
565 | return true; | 594 | return true; |
566 | } | 595 | } |
@@ -598,6 +627,7 @@ bool vgic_handle_clear_active_reg(struct kvm *kvm, | |||
598 | ACCESS_READ_VALUE | ACCESS_WRITE_CLEARBIT); | 627 | ACCESS_READ_VALUE | ACCESS_WRITE_CLEARBIT); |
599 | 628 | ||
600 | if (mmio->is_write) { | 629 | if (mmio->is_write) { |
630 | vgic_handle_clear_mapped_irq(kvm_get_vcpu(kvm, vcpu_id)); | ||
601 | vgic_update_state(kvm); | 631 | vgic_update_state(kvm); |
602 | return true; | 632 | return true; |
603 | } | 633 | } |
@@ -982,6 +1012,12 @@ static int compute_pending_for_cpu(struct kvm_vcpu *vcpu) | |||
982 | pend_percpu = vcpu->arch.vgic_cpu.pending_percpu; | 1012 | pend_percpu = vcpu->arch.vgic_cpu.pending_percpu; |
983 | pend_shared = vcpu->arch.vgic_cpu.pending_shared; | 1013 | pend_shared = vcpu->arch.vgic_cpu.pending_shared; |
984 | 1014 | ||
1015 | if (!dist->enabled) { | ||
1016 | bitmap_zero(pend_percpu, VGIC_NR_PRIVATE_IRQS); | ||
1017 | bitmap_zero(pend_shared, nr_shared); | ||
1018 | return 0; | ||
1019 | } | ||
1020 | |||
985 | pending = vgic_bitmap_get_cpu_map(&dist->irq_pending, vcpu_id); | 1021 | pending = vgic_bitmap_get_cpu_map(&dist->irq_pending, vcpu_id); |
986 | enabled = vgic_bitmap_get_cpu_map(&dist->irq_enabled, vcpu_id); | 1022 | enabled = vgic_bitmap_get_cpu_map(&dist->irq_enabled, vcpu_id); |
987 | bitmap_and(pend_percpu, pending, enabled, VGIC_NR_PRIVATE_IRQS); | 1023 | bitmap_and(pend_percpu, pending, enabled, VGIC_NR_PRIVATE_IRQS); |
@@ -1009,11 +1045,6 @@ void vgic_update_state(struct kvm *kvm) | |||
1009 | struct kvm_vcpu *vcpu; | 1045 | struct kvm_vcpu *vcpu; |
1010 | int c; | 1046 | int c; |
1011 | 1047 | ||
1012 | if (!dist->enabled) { | ||
1013 | set_bit(0, dist->irq_pending_on_cpu); | ||
1014 | return; | ||
1015 | } | ||
1016 | |||
1017 | kvm_for_each_vcpu(c, vcpu, kvm) { | 1048 | kvm_for_each_vcpu(c, vcpu, kvm) { |
1018 | if (compute_pending_for_cpu(vcpu)) | 1049 | if (compute_pending_for_cpu(vcpu)) |
1019 | set_bit(c, dist->irq_pending_on_cpu); | 1050 | set_bit(c, dist->irq_pending_on_cpu); |
@@ -1092,6 +1123,15 @@ static void vgic_retire_lr(int lr_nr, int irq, struct kvm_vcpu *vcpu) | |||
1092 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; | 1123 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; |
1093 | struct vgic_lr vlr = vgic_get_lr(vcpu, lr_nr); | 1124 | struct vgic_lr vlr = vgic_get_lr(vcpu, lr_nr); |
1094 | 1125 | ||
1126 | /* | ||
1127 | * We must transfer the pending state back to the distributor before | ||
1128 | * retiring the LR, otherwise we may loose edge-triggered interrupts. | ||
1129 | */ | ||
1130 | if (vlr.state & LR_STATE_PENDING) { | ||
1131 | vgic_dist_irq_set_pending(vcpu, irq); | ||
1132 | vlr.hwirq = 0; | ||
1133 | } | ||
1134 | |||
1095 | vlr.state = 0; | 1135 | vlr.state = 0; |
1096 | vgic_set_lr(vcpu, lr_nr, vlr); | 1136 | vgic_set_lr(vcpu, lr_nr, vlr); |
1097 | clear_bit(lr_nr, vgic_cpu->lr_used); | 1137 | clear_bit(lr_nr, vgic_cpu->lr_used); |
@@ -1132,7 +1172,8 @@ static void vgic_queue_irq_to_lr(struct kvm_vcpu *vcpu, int irq, | |||
1132 | kvm_debug("Set active, clear distributor: 0x%x\n", vlr.state); | 1172 | kvm_debug("Set active, clear distributor: 0x%x\n", vlr.state); |
1133 | vgic_irq_clear_active(vcpu, irq); | 1173 | vgic_irq_clear_active(vcpu, irq); |
1134 | vgic_update_state(vcpu->kvm); | 1174 | vgic_update_state(vcpu->kvm); |
1135 | } else if (vgic_dist_irq_is_pending(vcpu, irq)) { | 1175 | } else { |
1176 | WARN_ON(!vgic_dist_irq_is_pending(vcpu, irq)); | ||
1136 | vlr.state |= LR_STATE_PENDING; | 1177 | vlr.state |= LR_STATE_PENDING; |
1137 | kvm_debug("Set pending: 0x%x\n", vlr.state); | 1178 | kvm_debug("Set pending: 0x%x\n", vlr.state); |
1138 | } | 1179 | } |
@@ -1240,7 +1281,7 @@ static void __kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) | |||
1240 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; | 1281 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; |
1241 | struct vgic_dist *dist = &vcpu->kvm->arch.vgic; | 1282 | struct vgic_dist *dist = &vcpu->kvm->arch.vgic; |
1242 | unsigned long *pa_percpu, *pa_shared; | 1283 | unsigned long *pa_percpu, *pa_shared; |
1243 | int i, vcpu_id, lr, ret; | 1284 | int i, vcpu_id; |
1244 | int overflow = 0; | 1285 | int overflow = 0; |
1245 | int nr_shared = vgic_nr_shared_irqs(dist); | 1286 | int nr_shared = vgic_nr_shared_irqs(dist); |
1246 | 1287 | ||
@@ -1295,31 +1336,6 @@ epilog: | |||
1295 | */ | 1336 | */ |
1296 | clear_bit(vcpu_id, dist->irq_pending_on_cpu); | 1337 | clear_bit(vcpu_id, dist->irq_pending_on_cpu); |
1297 | } | 1338 | } |
1298 | |||
1299 | for (lr = 0; lr < vgic->nr_lr; lr++) { | ||
1300 | struct vgic_lr vlr; | ||
1301 | |||
1302 | if (!test_bit(lr, vgic_cpu->lr_used)) | ||
1303 | continue; | ||
1304 | |||
1305 | vlr = vgic_get_lr(vcpu, lr); | ||
1306 | |||
1307 | /* | ||
1308 | * If we have a mapping, and the virtual interrupt is | ||
1309 | * presented to the guest (as pending or active), then we must | ||
1310 | * set the state to active in the physical world. See | ||
1311 | * Documentation/virtual/kvm/arm/vgic-mapped-irqs.txt. | ||
1312 | */ | ||
1313 | if (vlr.state & LR_HW) { | ||
1314 | struct irq_phys_map *map; | ||
1315 | map = vgic_irq_map_search(vcpu, vlr.irq); | ||
1316 | |||
1317 | ret = irq_set_irqchip_state(map->irq, | ||
1318 | IRQCHIP_STATE_ACTIVE, | ||
1319 | true); | ||
1320 | WARN_ON(ret); | ||
1321 | } | ||
1322 | } | ||
1323 | } | 1339 | } |
1324 | 1340 | ||
1325 | static bool vgic_process_maintenance(struct kvm_vcpu *vcpu) | 1341 | static bool vgic_process_maintenance(struct kvm_vcpu *vcpu) |
@@ -1421,7 +1437,7 @@ static int vgic_sync_hwirq(struct kvm_vcpu *vcpu, struct vgic_lr vlr) | |||
1421 | return 0; | 1437 | return 0; |
1422 | 1438 | ||
1423 | map = vgic_irq_map_search(vcpu, vlr.irq); | 1439 | map = vgic_irq_map_search(vcpu, vlr.irq); |
1424 | BUG_ON(!map || !map->active); | 1440 | BUG_ON(!map); |
1425 | 1441 | ||
1426 | ret = irq_get_irqchip_state(map->irq, | 1442 | ret = irq_get_irqchip_state(map->irq, |
1427 | IRQCHIP_STATE_ACTIVE, | 1443 | IRQCHIP_STATE_ACTIVE, |
@@ -1429,13 +1445,8 @@ static int vgic_sync_hwirq(struct kvm_vcpu *vcpu, struct vgic_lr vlr) | |||
1429 | 1445 | ||
1430 | WARN_ON(ret); | 1446 | WARN_ON(ret); |
1431 | 1447 | ||
1432 | if (map->active) { | 1448 | if (map->active) |
1433 | ret = irq_set_irqchip_state(map->irq, | ||
1434 | IRQCHIP_STATE_ACTIVE, | ||
1435 | false); | ||
1436 | WARN_ON(ret); | ||
1437 | return 0; | 1449 | return 0; |
1438 | } | ||
1439 | 1450 | ||
1440 | return 1; | 1451 | return 1; |
1441 | } | 1452 | } |
@@ -1607,8 +1618,12 @@ static int vgic_update_irq_pending(struct kvm *kvm, int cpuid, | |||
1607 | } else { | 1618 | } else { |
1608 | if (level_triggered) { | 1619 | if (level_triggered) { |
1609 | vgic_dist_irq_clear_level(vcpu, irq_num); | 1620 | vgic_dist_irq_clear_level(vcpu, irq_num); |
1610 | if (!vgic_dist_irq_soft_pend(vcpu, irq_num)) | 1621 | if (!vgic_dist_irq_soft_pend(vcpu, irq_num)) { |
1611 | vgic_dist_irq_clear_pending(vcpu, irq_num); | 1622 | vgic_dist_irq_clear_pending(vcpu, irq_num); |
1623 | vgic_cpu_irq_clear(vcpu, irq_num); | ||
1624 | if (!compute_pending_for_cpu(vcpu)) | ||
1625 | clear_bit(cpuid, dist->irq_pending_on_cpu); | ||
1626 | } | ||
1612 | } | 1627 | } |
1613 | 1628 | ||
1614 | ret = false; | 1629 | ret = false; |