diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-01-05 05:19:46 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-01-05 05:19:46 -0500 |
commit | 0822069f3f15b85c45d7bfd9397eff275983c5c8 (patch) | |
tree | 5626a32fb6aa1df487751d478b28ddd1caf16440 | |
parent | 4b5a5096bb834102b2e821f5f34274f041862d67 (diff) | |
parent | 2cde51fbd0f310c8a2c5f977e665c0ac3945b46d (diff) |
Merge tag 'asoc-v3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Updates for v3.14
Not a lot going on framework wise, partly due to Christmas at least in
the case of the work I've been doing, but there's been quite a lot of
cleanup activity going on and the usual trickle of new drivers:
- Update to the generic DMA code to support deferred probe and managed
resources.
- New drivers for BCM2835 (used in Raspberry Pi), Tegra with MAX98090
and Analog Devices AXI I2S and S/PDIF controller IPs.
- Device tree support for the simple card, max98090 and cs42l52.
- Conversion of the Samsung drivers to native dmaengine, making them
multiplatform compatible and hopefully helping keep them more modern
and up to date.
- More regmap conversions, including a very welcome one for twl6040
from Peter Ujfalusi.
- A big overhaul of the DaVinci drivers also from Peter Ujfalusi.
450 files changed, 9901 insertions, 5195 deletions
diff --git a/Documentation/block/null_blk.txt b/Documentation/block/null_blk.txt new file mode 100644 index 000000000000..b2830b435895 --- /dev/null +++ b/Documentation/block/null_blk.txt | |||
@@ -0,0 +1,72 @@ | |||
1 | Null block device driver | ||
2 | ================================================================================ | ||
3 | |||
4 | I. Overview | ||
5 | |||
6 | The null block device (/dev/nullb*) is used for benchmarking the various | ||
7 | block-layer implementations. It emulates a block device of X gigabytes in size. | ||
8 | The following instances are possible: | ||
9 | |||
10 | Single-queue block-layer | ||
11 | - Request-based. | ||
12 | - Single submission queue per device. | ||
13 | - Implements IO scheduling algorithms (CFQ, Deadline, noop). | ||
14 | Multi-queue block-layer | ||
15 | - Request-based. | ||
16 | - Configurable submission queues per device. | ||
17 | No block-layer (Known as bio-based) | ||
18 | - Bio-based. IO requests are submitted directly to the device driver. | ||
19 | - Directly accepts bio data structure and returns them. | ||
20 | |||
21 | All of them have a completion queue for each core in the system. | ||
22 | |||
23 | II. Module parameters applicable for all instances: | ||
24 | |||
25 | queue_mode=[0-2]: Default: 2-Multi-queue | ||
26 | Selects which block-layer the module should instantiate with. | ||
27 | |||
28 | 0: Bio-based. | ||
29 | 1: Single-queue. | ||
30 | 2: Multi-queue. | ||
31 | |||
32 | home_node=[0--nr_nodes]: Default: NUMA_NO_NODE | ||
33 | Selects what CPU node the data structures are allocated from. | ||
34 | |||
35 | gb=[Size in GB]: Default: 250GB | ||
36 | The size of the device reported to the system. | ||
37 | |||
38 | bs=[Block size (in bytes)]: Default: 512 bytes | ||
39 | The block size reported to the system. | ||
40 | |||
41 | nr_devices=[Number of devices]: Default: 2 | ||
42 | Number of block devices instantiated. They are instantiated as /dev/nullb0, | ||
43 | etc. | ||
44 | |||
45 | irq_mode=[0-2]: Default: 1-Soft-irq | ||
46 | The completion mode used for completing IOs to the block-layer. | ||
47 | |||
48 | 0: None. | ||
49 | 1: Soft-irq. Uses IPI to complete IOs across CPU nodes. Simulates the overhead | ||
50 | when IOs are issued from another CPU node than the home the device is | ||
51 | connected to. | ||
52 | 2: Timer: Waits a specific period (completion_nsec) for each IO before | ||
53 | completion. | ||
54 | |||
55 | completion_nsec=[ns]: Default: 10.000ns | ||
56 | Combined with irq_mode=2 (timer). The time each completion event must wait. | ||
57 | |||
58 | submit_queues=[0..nr_cpus]: | ||
59 | The number of submission queues attached to the device driver. If unset, it | ||
60 | defaults to 1 on single-queue and bio-based instances. For multi-queue, | ||
61 | it is ignored when use_per_node_hctx module parameter is 1. | ||
62 | |||
63 | hw_queue_depth=[0..qdepth]: Default: 64 | ||
64 | The hardware queue depth of the device. | ||
65 | |||
66 | III: Multi-queue specific parameters | ||
67 | |||
68 | use_per_node_hctx=[0/1]: Default: 0 | ||
69 | 0: The number of submit queues are set to the value of the submit_queues | ||
70 | parameter. | ||
71 | 1: The multi-queue block layer is instantiated with a hardware dispatch | ||
72 | queue for each CPU node in the system. | ||
diff --git a/Documentation/devicetree/bindings/sound/adi,axi-i2s.txt b/Documentation/devicetree/bindings/sound/adi,axi-i2s.txt new file mode 100644 index 000000000000..5875ca459ed1 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/adi,axi-i2s.txt | |||
@@ -0,0 +1,31 @@ | |||
1 | ADI AXI-I2S controller | ||
2 | |||
3 | Required properties: | ||
4 | - compatible : Must be "adi,axi-i2s-1.00.a" | ||
5 | - reg : Must contain I2S core's registers location and length | ||
6 | - clocks : Pairs of phandle and specifier referencing the controller's clocks. | ||
7 | The controller expects two clocks, the clock used for the AXI interface and | ||
8 | the clock used as the sampling rate reference clock sample. | ||
9 | - clock-names : "axi" for the clock to the AXI interface, "ref" for the sample | ||
10 | rate reference clock. | ||
11 | - dmas: Pairs of phandle and specifier for the DMA channels that are used by | ||
12 | the core. The core expects two dma channels, one for transmit and one for | ||
13 | receive. | ||
14 | - dma-names : "tx" for the transmit channel, "rx" for the receive channel. | ||
15 | |||
16 | For more details on the 'dma', 'dma-names', 'clock' and 'clock-names' properties | ||
17 | please check: | ||
18 | * resource-names.txt | ||
19 | * clock/clock-bindings.txt | ||
20 | * dma/dma.txt | ||
21 | |||
22 | Example: | ||
23 | |||
24 | i2s: i2s@0x77600000 { | ||
25 | compatible = "adi,axi-i2s-1.00.a"; | ||
26 | reg = <0x77600000 0x1000>; | ||
27 | clocks = <&clk 15>, <&audio_clock>; | ||
28 | clock-names = "axi", "ref"; | ||
29 | dmas = <&ps7_dma 0>, <&ps7_dma 1>; | ||
30 | dma-names = "tx", "rx"; | ||
31 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/adi,axi-spdif-tx.txt b/Documentation/devicetree/bindings/sound/adi,axi-spdif-tx.txt new file mode 100644 index 000000000000..46f344965313 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/adi,axi-spdif-tx.txt | |||
@@ -0,0 +1,30 @@ | |||
1 | ADI AXI-SPDIF controller | ||
2 | |||
3 | Required properties: | ||
4 | - compatible : Must be "adi,axi-spdif-1.00.a" | ||
5 | - reg : Must contain SPDIF core's registers location and length | ||
6 | - clocks : Pairs of phandle and specifier referencing the controller's clocks. | ||
7 | The controller expects two clocks, the clock used for the AXI interface and | ||
8 | the clock used as the sampling rate reference clock sample. | ||
9 | - clock-names: "axi" for the clock to the AXI interface, "ref" for the sample | ||
10 | rate reference clock. | ||
11 | - dmas: Pairs of phandle and specifier for the DMA channel that is used by | ||
12 | the core. The core expects one dma channel for transmit. | ||
13 | - dma-names : Must be "tx" | ||
14 | |||
15 | For more details on the 'dma', 'dma-names', 'clock' and 'clock-names' properties | ||
16 | please check: | ||
17 | * resource-names.txt | ||
18 | * clock/clock-bindings.txt | ||
19 | * dma/dma.txt | ||
20 | |||
21 | Example: | ||
22 | |||
23 | spdif: spdif@0x77400000 { | ||
24 | compatible = "adi,axi-spdif-tx-1.00.a"; | ||
25 | reg = <0x77600000 0x1000>; | ||
26 | clocks = <&clk 15>, <&audio_clock>; | ||
27 | clock-names = "axi", "ref"; | ||
28 | dmas = <&ps7_dma 0>; | ||
29 | dma-names = "tx"; | ||
30 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/bcm2835-i2s.txt b/Documentation/devicetree/bindings/sound/bcm2835-i2s.txt new file mode 100644 index 000000000000..65783de0aedf --- /dev/null +++ b/Documentation/devicetree/bindings/sound/bcm2835-i2s.txt | |||
@@ -0,0 +1,25 @@ | |||
1 | * Broadcom BCM2835 SoC I2S/PCM module | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: "brcm,bcm2835-i2s" | ||
5 | - reg: A list of base address and size entries: | ||
6 | * The first entry should cover the PCM registers | ||
7 | * The second entry should cover the PCM clock registers | ||
8 | - dmas: List of DMA controller phandle and DMA request line ordered pairs. | ||
9 | - dma-names: Identifier string for each DMA request line in the dmas property. | ||
10 | These strings correspond 1:1 with the ordered pairs in dmas. | ||
11 | |||
12 | One of the DMA channels will be responsible for transmission (should be | ||
13 | named "tx") and one for reception (should be named "rx"). | ||
14 | |||
15 | Example: | ||
16 | |||
17 | bcm2835_i2s: i2s@7e203000 { | ||
18 | compatible = "brcm,bcm2835-i2s"; | ||
19 | reg = <0x7e203000 0x20>, | ||
20 | <0x7e101098 0x02>; | ||
21 | |||
22 | dmas = <&dma 2>, | ||
23 | <&dma 3>; | ||
24 | dma-names = "tx", "rx"; | ||
25 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/cs42l52.txt b/Documentation/devicetree/bindings/sound/cs42l52.txt new file mode 100644 index 000000000000..bc03c9312a19 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/cs42l52.txt | |||
@@ -0,0 +1,46 @@ | |||
1 | CS42L52 audio CODEC | ||
2 | |||
3 | Required properties: | ||
4 | |||
5 | - compatible : "cirrus,cs42l52" | ||
6 | |||
7 | - reg : the I2C address of the device for I2C | ||
8 | |||
9 | Optional properties: | ||
10 | |||
11 | - cirrus,reset-gpio : GPIO controller's phandle and the number | ||
12 | of the GPIO used to reset the codec. | ||
13 | |||
14 | - cirrus,chgfreq-divisor : Values used to set the Charge Pump Frequency. | ||
15 | Allowable values of 0x00 through 0x0F. These are raw values written to the | ||
16 | register, not the actual frequency. The frequency is determined by the following. | ||
17 | Frequency = (64xFs)/(N+2) | ||
18 | N = chgfreq_val | ||
19 | Fs = Sample Rate (variable) | ||
20 | |||
21 | - cirrus,mica-differential-cfg : boolean, If present, then the MICA input is configured | ||
22 | as a differential input. If not present then the MICA input is configured as | ||
23 | Single-ended input. Single-ended mode allows for MIC1 or MIC2 muxing for input. | ||
24 | |||
25 | - cirrus,micb-differential-cfg : boolean, If present, then the MICB input is configured | ||
26 | as a differential input. If not present then the MICB input is configured as | ||
27 | Single-ended input. Single-ended mode allows for MIC1 or MIC2 muxing for input. | ||
28 | |||
29 | - cirrus,micbias-lvl: Set the output voltage level on the MICBIAS Pin | ||
30 | 0 = 0.5 x VA | ||
31 | 1 = 0.6 x VA | ||
32 | 2 = 0.7 x VA | ||
33 | 3 = 0.8 x VA | ||
34 | 4 = 0.83 x VA | ||
35 | 5 = 0.91 x VA | ||
36 | |||
37 | Example: | ||
38 | |||
39 | codec: codec@4a { | ||
40 | compatible = "cirrus,cs42l52"; | ||
41 | reg = <0x4a>; | ||
42 | reset-gpio = <&gpio 10 0>; | ||
43 | cirrus,chgfreq-divisor = <0x05>; | ||
44 | cirrus.mica-differential-cfg; | ||
45 | cirrus,micbias-lvl = <5>; | ||
46 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt index ed785b3f67be..569b26c4a81e 100644 --- a/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt +++ b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt | |||
@@ -4,7 +4,8 @@ Required properties: | |||
4 | - compatible : | 4 | - compatible : |
5 | "ti,dm646x-mcasp-audio" : for DM646x platforms | 5 | "ti,dm646x-mcasp-audio" : for DM646x platforms |
6 | "ti,da830-mcasp-audio" : for both DA830 & DA850 platforms | 6 | "ti,da830-mcasp-audio" : for both DA830 & DA850 platforms |
7 | "ti,am33xx-mcasp-audio" : for AM33xx platforms (AM33xx, TI81xx) | 7 | "ti,am33xx-mcasp-audio" : for AM33xx platforms (AM33xx, AM43xx, TI81xx) |
8 | "ti,dra7-mcasp-audio" : for DRA7xx platforms | ||
8 | 9 | ||
9 | - reg : Should contain reg specifiers for the entries in the reg-names property. | 10 | - reg : Should contain reg specifiers for the entries in the reg-names property. |
10 | - reg-names : Should contain: | 11 | - reg-names : Should contain: |
@@ -36,7 +37,8 @@ Optional properties: | |||
36 | - pinctrl-0: Should specify pin control group used for this controller. | 37 | - pinctrl-0: Should specify pin control group used for this controller. |
37 | - pinctrl-names: Should contain only one value - "default", for more details | 38 | - pinctrl-names: Should contain only one value - "default", for more details |
38 | please refer to pinctrl-bindings.txt | 39 | please refer to pinctrl-bindings.txt |
39 | 40 | - fck_parent : Should contain a valid clock name which will be used as parent | |
41 | for the McASP fck | ||
40 | 42 | ||
41 | Example: | 43 | Example: |
42 | 44 | ||
diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt new file mode 100644 index 000000000000..98611a6761c0 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/fsl-sai.txt | |||
@@ -0,0 +1,40 @@ | |||
1 | Freescale Synchronous Audio Interface (SAI). | ||
2 | |||
3 | The SAI is based on I2S module that used communicating with audio codecs, | ||
4 | which provides a synchronous audio interface that supports fullduplex | ||
5 | serial interfaces with frame synchronization such as I2S, AC97, TDM, and | ||
6 | codec/DSP interfaces. | ||
7 | |||
8 | |||
9 | Required properties: | ||
10 | - compatible: Compatible list, contains "fsl,vf610-sai". | ||
11 | - reg: Offset and length of the register set for the device. | ||
12 | - clocks: Must contain an entry for each entry in clock-names. | ||
13 | - clock-names : Must include the "sai" entry. | ||
14 | - dmas : Generic dma devicetree binding as described in | ||
15 | Documentation/devicetree/bindings/dma/dma.txt. | ||
16 | - dma-names : Two dmas have to be defined, "tx" and "rx". | ||
17 | - pinctrl-names: Must contain a "default" entry. | ||
18 | - pinctrl-NNN: One property must exist for each entry in pinctrl-names. | ||
19 | See ../pinctrl/pinctrl-bindings.txt for details of the property values. | ||
20 | - big-endian-regs: If this property is absent, the little endian mode will | ||
21 | be in use as default, or the big endian mode will be in use for all the | ||
22 | device registers. | ||
23 | - big-endian-data: If this property is absent, the little endian mode will | ||
24 | be in use as default, or the big endian mode will be in use for all the | ||
25 | fifo data. | ||
26 | |||
27 | Example: | ||
28 | sai2: sai@40031000 { | ||
29 | compatible = "fsl,vf610-sai"; | ||
30 | reg = <0x40031000 0x1000>; | ||
31 | pinctrl-names = "default"; | ||
32 | pinctrl-0 = <&pinctrl_sai2_1>; | ||
33 | clocks = <&clks VF610_CLK_SAI2>; | ||
34 | clock-names = "sai"; | ||
35 | dma-names = "tx", "rx"; | ||
36 | dmas = <&edma0 0 VF610_EDMA_MUXID0_SAI2_TX>, | ||
37 | <&edma0 0 VF610_EDMA_MUXID0_SAI2_RX>; | ||
38 | big-endian-regs; | ||
39 | big-endian-data; | ||
40 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/hdmi.txt b/Documentation/devicetree/bindings/sound/hdmi.txt new file mode 100644 index 000000000000..31af7bca3099 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/hdmi.txt | |||
@@ -0,0 +1,17 @@ | |||
1 | Device-Tree bindings for dummy HDMI codec | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: should be "linux,hdmi-audio". | ||
5 | |||
6 | CODEC output pins: | ||
7 | * TX | ||
8 | |||
9 | CODEC input pins: | ||
10 | * RX | ||
11 | |||
12 | Example node: | ||
13 | |||
14 | hdmi_audio: hdmi_audio@0 { | ||
15 | compatible = "linux,hdmi-audio"; | ||
16 | status = "okay"; | ||
17 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt new file mode 100644 index 000000000000..e4c8b36dcf89 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/max98090.txt | |||
@@ -0,0 +1,43 @@ | |||
1 | MAX98090 audio CODEC | ||
2 | |||
3 | This device supports I2C only. | ||
4 | |||
5 | Required properties: | ||
6 | |||
7 | - compatible : "maxim,max98090". | ||
8 | |||
9 | - reg : The I2C address of the device. | ||
10 | |||
11 | - interrupts : The CODEC's interrupt output. | ||
12 | |||
13 | Pins on the device (for linking into audio routes): | ||
14 | |||
15 | * MIC1 | ||
16 | * MIC2 | ||
17 | * DMICL | ||
18 | * DMICR | ||
19 | * IN1 | ||
20 | * IN2 | ||
21 | * IN3 | ||
22 | * IN4 | ||
23 | * IN5 | ||
24 | * IN6 | ||
25 | * IN12 | ||
26 | * IN34 | ||
27 | * IN56 | ||
28 | * HPL | ||
29 | * HPR | ||
30 | * SPKL | ||
31 | * SPKR | ||
32 | * RCVL | ||
33 | * RCVR | ||
34 | * MICBIAS | ||
35 | |||
36 | Example: | ||
37 | |||
38 | audio-codec@10 { | ||
39 | compatible = "maxim,max98090"; | ||
40 | reg = <0x10>; | ||
41 | interrupt-parent = <&gpio>; | ||
42 | interrupts = <TEGRA_GPIO(H, 4) GPIO_ACTIVE_HIGH>; | ||
43 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt new file mode 100644 index 000000000000..9c7c55c71370 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt | |||
@@ -0,0 +1,51 @@ | |||
1 | NVIDIA Tegra audio complex, with MAX98090 CODEC | ||
2 | |||
3 | Required properties: | ||
4 | - compatible : "nvidia,tegra-audio-max98090" | ||
5 | - clocks : Must contain an entry for each entry in clock-names. | ||
6 | See ../clocks/clock-bindings.txt for details. | ||
7 | - clock-names : Must include the following entries: | ||
8 | - pll_a | ||
9 | - pll_a_out0 | ||
10 | - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) | ||
11 | - nvidia,model : The user-visible name of this sound complex. | ||
12 | - nvidia,audio-routing : A list of the connections between audio components. | ||
13 | Each entry is a pair of strings, the first being the connection's sink, | ||
14 | the second being the connection's source. Valid names for sources and | ||
15 | sinks are the MAX98090's pins (as documented in its binding), and the jacks | ||
16 | on the board: | ||
17 | |||
18 | * Headphones | ||
19 | * Speakers | ||
20 | * Mic Jack | ||
21 | |||
22 | - nvidia,i2s-controller : The phandle of the Tegra I2S controller that's | ||
23 | connected to the CODEC. | ||
24 | - nvidia,audio-codec : The phandle of the MAX98090 audio codec. | ||
25 | |||
26 | Optional properties: | ||
27 | - nvidia,hp-det-gpios : The GPIO that detect headphones are plugged in | ||
28 | |||
29 | Example: | ||
30 | |||
31 | sound { | ||
32 | compatible = "nvidia,tegra-audio-max98090-venice2", | ||
33 | "nvidia,tegra-audio-max98090"; | ||
34 | nvidia,model = "NVIDIA Tegra Venice2"; | ||
35 | |||
36 | nvidia,audio-routing = | ||
37 | "Headphones", "HPR", | ||
38 | "Headphones", "HPL", | ||
39 | "Speakers", "SPKR", | ||
40 | "Speakers", "SPKL", | ||
41 | "Mic Jack", "MICBIAS", | ||
42 | "IN34", "Mic Jack"; | ||
43 | |||
44 | nvidia,i2s-controller = <&tegra_i2s1>; | ||
45 | nvidia,audio-codec = <&acodec>; | ||
46 | |||
47 | clocks = <&tegra_car TEGRA124_CLK_PLL_A>, | ||
48 | <&tegra_car TEGRA124_CLK_PLL_A_OUT0>, | ||
49 | <&tegra_car TEGRA124_CLK_EXTERN1>; | ||
50 | clock-names = "pll_a", "pll_a_out0", "mclk"; | ||
51 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt new file mode 100644 index 000000000000..2ee80c76ca64 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/simple-card.txt | |||
@@ -0,0 +1,77 @@ | |||
1 | Simple-Card: | ||
2 | |||
3 | Simple-Card specifies audio DAI connection of SoC <-> codec. | ||
4 | |||
5 | Required properties: | ||
6 | |||
7 | - compatible : "simple-audio-card" | ||
8 | |||
9 | Optional properties: | ||
10 | |||
11 | - simple-audio-card,format : CPU/CODEC common audio format. | ||
12 | "i2s", "right_j", "left_j" , "dsp_a" | ||
13 | "dsp_b", "ac97", "pdm", "msb", "lsb" | ||
14 | - simple-audio-routing : A list of the connections between audio components. | ||
15 | Each entry is a pair of strings, the first being the | ||
16 | connection's sink, the second being the connection's | ||
17 | source. | ||
18 | |||
19 | Required subnodes: | ||
20 | |||
21 | - simple-audio-card,cpu : CPU sub-node | ||
22 | - simple-audio-card,codec : CODEC sub-node | ||
23 | |||
24 | Required CPU/CODEC subnodes properties: | ||
25 | |||
26 | - sound-dai : phandle and port of CPU/CODEC | ||
27 | |||
28 | Optional CPU/CODEC subnodes properties: | ||
29 | |||
30 | - format : CPU/CODEC specific audio format if needed. | ||
31 | see simple-audio-card,format | ||
32 | - frame-master : bool property. add this if subnode is frame master | ||
33 | - bitclock-master : bool property. add this if subnode is bitclock master | ||
34 | - bitclock-inversion : bool property. add this if subnode has clock inversion | ||
35 | - frame-inversion : bool property. add this if subnode has frame inversion | ||
36 | - clocks / system-clock-frequency : specify subnode's clock if needed. | ||
37 | it can be specified via "clocks" if system has | ||
38 | clock node (= common clock), or "system-clock-frequency" | ||
39 | (if system doens't support common clock) | ||
40 | |||
41 | Example: | ||
42 | |||
43 | sound { | ||
44 | compatible = "simple-audio-card"; | ||
45 | simple-audio-card,format = "left_j"; | ||
46 | simple-audio-routing = | ||
47 | "MIC_IN", "Mic Jack", | ||
48 | "Headphone Jack", "HP_OUT", | ||
49 | "Ext Spk", "LINE_OUT"; | ||
50 | |||
51 | simple-audio-card,cpu { | ||
52 | sound-dai = <&sh_fsi2 0>; | ||
53 | }; | ||
54 | |||
55 | simple-audio-card,codec { | ||
56 | sound-dai = <&ak4648>; | ||
57 | bitclock-master; | ||
58 | frame-master; | ||
59 | clocks = <&osc>; | ||
60 | }; | ||
61 | }; | ||
62 | |||
63 | &i2c0 { | ||
64 | ak4648: ak4648@12 { | ||
65 | #sound-dai-cells = <0>; | ||
66 | compatible = "asahi-kasei,ak4648"; | ||
67 | reg = <0x12>; | ||
68 | }; | ||
69 | }; | ||
70 | |||
71 | sh_fsi2: sh_fsi2@ec230000 { | ||
72 | #sound-dai-cells = <1>; | ||
73 | compatible = "renesas,sh_fsi2"; | ||
74 | reg = <0xec230000 0x400>; | ||
75 | interrupt-parent = <&gic>; | ||
76 | interrupts = <0 146 0x4>; | ||
77 | }; | ||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 50680a59a2ff..b9e9bd854298 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -1529,6 +1529,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
1529 | 1529 | ||
1530 | * atapi_dmadir: Enable ATAPI DMADIR bridge support | 1530 | * atapi_dmadir: Enable ATAPI DMADIR bridge support |
1531 | 1531 | ||
1532 | * disable: Disable this device. | ||
1533 | |||
1532 | If there are multiple matching configurations changing | 1534 | If there are multiple matching configurations changing |
1533 | the same attribute, the last one is used. | 1535 | the same attribute, the last one is used. |
1534 | 1536 | ||
diff --git a/Documentation/module-signing.txt b/Documentation/module-signing.txt new file mode 100644 index 000000000000..2b40e04d3c49 --- /dev/null +++ b/Documentation/module-signing.txt | |||
@@ -0,0 +1,240 @@ | |||
1 | ============================== | ||
2 | KERNEL MODULE SIGNING FACILITY | ||
3 | ============================== | ||
4 | |||
5 | CONTENTS | ||
6 | |||
7 | - Overview. | ||
8 | - Configuring module signing. | ||
9 | - Generating signing keys. | ||
10 | - Public keys in the kernel. | ||
11 | - Manually signing modules. | ||
12 | - Signed modules and stripping. | ||
13 | - Loading signed modules. | ||
14 | - Non-valid signatures and unsigned modules. | ||
15 | - Administering/protecting the private key. | ||
16 | |||
17 | |||
18 | ======== | ||
19 | OVERVIEW | ||
20 | ======== | ||
21 | |||
22 | The kernel module signing facility cryptographically signs modules during | ||
23 | installation and then checks the signature upon loading the module. This | ||
24 | allows increased kernel security by disallowing the loading of unsigned modules | ||
25 | or modules signed with an invalid key. Module signing increases security by | ||
26 | making it harder to load a malicious module into the kernel. The module | ||
27 | signature checking is done by the kernel so that it is not necessary to have | ||
28 | trusted userspace bits. | ||
29 | |||
30 | This facility uses X.509 ITU-T standard certificates to encode the public keys | ||
31 | involved. The signatures are not themselves encoded in any industrial standard | ||
32 | type. The facility currently only supports the RSA public key encryption | ||
33 | standard (though it is pluggable and permits others to be used). The possible | ||
34 | hash algorithms that can be used are SHA-1, SHA-224, SHA-256, SHA-384, and | ||
35 | SHA-512 (the algorithm is selected by data in the signature). | ||
36 | |||
37 | |||
38 | ========================== | ||
39 | CONFIGURING MODULE SIGNING | ||
40 | ========================== | ||
41 | |||
42 | The module signing facility is enabled by going to the "Enable Loadable Module | ||
43 | Support" section of the kernel configuration and turning on | ||
44 | |||
45 | CONFIG_MODULE_SIG "Module signature verification" | ||
46 | |||
47 | This has a number of options available: | ||
48 | |||
49 | (1) "Require modules to be validly signed" (CONFIG_MODULE_SIG_FORCE) | ||
50 | |||
51 | This specifies how the kernel should deal with a module that has a | ||
52 | signature for which the key is not known or a module that is unsigned. | ||
53 | |||
54 | If this is off (ie. "permissive"), then modules for which the key is not | ||
55 | available and modules that are unsigned are permitted, but the kernel will | ||
56 | be marked as being tainted. | ||
57 | |||
58 | If this is on (ie. "restrictive"), only modules that have a valid | ||
59 | signature that can be verified by a public key in the kernel's possession | ||
60 | will be loaded. All other modules will generate an error. | ||
61 | |||
62 | Irrespective of the setting here, if the module has a signature block that | ||
63 | cannot be parsed, it will be rejected out of hand. | ||
64 | |||
65 | |||
66 | (2) "Automatically sign all modules" (CONFIG_MODULE_SIG_ALL) | ||
67 | |||
68 | If this is on then modules will be automatically signed during the | ||
69 | modules_install phase of a build. If this is off, then the modules must | ||
70 | be signed manually using: | ||
71 | |||
72 | scripts/sign-file | ||
73 | |||
74 | |||
75 | (3) "Which hash algorithm should modules be signed with?" | ||
76 | |||
77 | This presents a choice of which hash algorithm the installation phase will | ||
78 | sign the modules with: | ||
79 | |||
80 | CONFIG_SIG_SHA1 "Sign modules with SHA-1" | ||
81 | CONFIG_SIG_SHA224 "Sign modules with SHA-224" | ||
82 | CONFIG_SIG_SHA256 "Sign modules with SHA-256" | ||
83 | CONFIG_SIG_SHA384 "Sign modules with SHA-384" | ||
84 | CONFIG_SIG_SHA512 "Sign modules with SHA-512" | ||
85 | |||
86 | The algorithm selected here will also be built into the kernel (rather | ||
87 | than being a module) so that modules signed with that algorithm can have | ||
88 | their signatures checked without causing a dependency loop. | ||
89 | |||
90 | |||
91 | ======================= | ||
92 | GENERATING SIGNING KEYS | ||
93 | ======================= | ||
94 | |||
95 | Cryptographic keypairs are required to generate and check signatures. A | ||
96 | private key is used to generate a signature and the corresponding public key is | ||
97 | used to check it. The private key is only needed during the build, after which | ||
98 | it can be deleted or stored securely. The public key gets built into the | ||
99 | kernel so that it can be used to check the signatures as the modules are | ||
100 | loaded. | ||
101 | |||
102 | Under normal conditions, the kernel build will automatically generate a new | ||
103 | keypair using openssl if one does not exist in the files: | ||
104 | |||
105 | signing_key.priv | ||
106 | signing_key.x509 | ||
107 | |||
108 | during the building of vmlinux (the public part of the key needs to be built | ||
109 | into vmlinux) using parameters in the: | ||
110 | |||
111 | x509.genkey | ||
112 | |||
113 | file (which is also generated if it does not already exist). | ||
114 | |||
115 | It is strongly recommended that you provide your own x509.genkey file. | ||
116 | |||
117 | Most notably, in the x509.genkey file, the req_distinguished_name section | ||
118 | should be altered from the default: | ||
119 | |||
120 | [ req_distinguished_name ] | ||
121 | O = Magrathea | ||
122 | CN = Glacier signing key | ||
123 | emailAddress = slartibartfast@magrathea.h2g2 | ||
124 | |||
125 | The generated RSA key size can also be set with: | ||
126 | |||
127 | [ req ] | ||
128 | default_bits = 4096 | ||
129 | |||
130 | |||
131 | It is also possible to manually generate the key private/public files using the | ||
132 | x509.genkey key generation configuration file in the root node of the Linux | ||
133 | kernel sources tree and the openssl command. The following is an example to | ||
134 | generate the public/private key files: | ||
135 | |||
136 | openssl req -new -nodes -utf8 -sha256 -days 36500 -batch -x509 \ | ||
137 | -config x509.genkey -outform DER -out signing_key.x509 \ | ||
138 | -keyout signing_key.priv | ||
139 | |||
140 | |||
141 | ========================= | ||
142 | PUBLIC KEYS IN THE KERNEL | ||
143 | ========================= | ||
144 | |||
145 | The kernel contains a ring of public keys that can be viewed by root. They're | ||
146 | in a keyring called ".system_keyring" that can be seen by: | ||
147 | |||
148 | [root@deneb ~]# cat /proc/keys | ||
149 | ... | ||
150 | 223c7853 I------ 1 perm 1f030000 0 0 keyring .system_keyring: 1 | ||
151 | 302d2d52 I------ 1 perm 1f010000 0 0 asymmetri Fedora kernel signing key: d69a84e6bce3d216b979e9505b3e3ef9a7118079: X509.RSA a7118079 [] | ||
152 | ... | ||
153 | |||
154 | Beyond the public key generated specifically for module signing, any file | ||
155 | placed in the kernel source root directory or the kernel build root directory | ||
156 | whose name is suffixed with ".x509" will be assumed to be an X.509 public key | ||
157 | and will be added to the keyring. | ||
158 | |||
159 | Further, the architecture code may take public keys from a hardware store and | ||
160 | add those in also (e.g. from the UEFI key database). | ||
161 | |||
162 | Finally, it is possible to add additional public keys by doing: | ||
163 | |||
164 | keyctl padd asymmetric "" [.system_keyring-ID] <[key-file] | ||
165 | |||
166 | e.g.: | ||
167 | |||
168 | keyctl padd asymmetric "" 0x223c7853 <my_public_key.x509 | ||
169 | |||
170 | Note, however, that the kernel will only permit keys to be added to | ||
171 | .system_keyring _if_ the new key's X.509 wrapper is validly signed by a key | ||
172 | that is already resident in the .system_keyring at the time the key was added. | ||
173 | |||
174 | |||
175 | ========================= | ||
176 | MANUALLY SIGNING MODULES | ||
177 | ========================= | ||
178 | |||
179 | To manually sign a module, use the scripts/sign-file tool available in | ||
180 | the Linux kernel source tree. The script requires 4 arguments: | ||
181 | |||
182 | 1. The hash algorithm (e.g., sha256) | ||
183 | 2. The private key filename | ||
184 | 3. The public key filename | ||
185 | 4. The kernel module to be signed | ||
186 | |||
187 | The following is an example to sign a kernel module: | ||
188 | |||
189 | scripts/sign-file sha512 kernel-signkey.priv \ | ||
190 | kernel-signkey.x509 module.ko | ||
191 | |||
192 | The hash algorithm used does not have to match the one configured, but if it | ||
193 | doesn't, you should make sure that hash algorithm is either built into the | ||
194 | kernel or can be loaded without requiring itself. | ||
195 | |||
196 | |||
197 | ============================ | ||
198 | SIGNED MODULES AND STRIPPING | ||
199 | ============================ | ||
200 | |||
201 | A signed module has a digital signature simply appended at the end. The string | ||
202 | "~Module signature appended~." at the end of the module's file confirms that a | ||
203 | signature is present but it does not confirm that the signature is valid! | ||
204 | |||
205 | Signed modules are BRITTLE as the signature is outside of the defined ELF | ||
206 | container. Thus they MAY NOT be stripped once the signature is computed and | ||
207 | attached. Note the entire module is the signed payload, including any and all | ||
208 | debug information present at the time of signing. | ||
209 | |||
210 | |||
211 | ====================== | ||
212 | LOADING SIGNED MODULES | ||
213 | ====================== | ||
214 | |||
215 | Modules are loaded with insmod, modprobe, init_module() or finit_module(), | ||
216 | exactly as for unsigned modules as no processing is done in userspace. The | ||
217 | signature checking is all done within the kernel. | ||
218 | |||
219 | |||
220 | ========================================= | ||
221 | NON-VALID SIGNATURES AND UNSIGNED MODULES | ||
222 | ========================================= | ||
223 | |||
224 | If CONFIG_MODULE_SIG_FORCE is enabled or enforcemodulesig=1 is supplied on | ||
225 | the kernel command line, the kernel will only load validly signed modules | ||
226 | for which it has a public key. Otherwise, it will also load modules that are | ||
227 | unsigned. Any module for which the kernel has a key, but which proves to have | ||
228 | a signature mismatch will not be permitted to load. | ||
229 | |||
230 | Any module that has an unparseable signature will be rejected. | ||
231 | |||
232 | |||
233 | ========================================= | ||
234 | ADMINISTERING/PROTECTING THE PRIVATE KEY | ||
235 | ========================================= | ||
236 | |||
237 | Since the private key is used to sign modules, viruses and malware could use | ||
238 | the private key to sign modules and compromise the operating system. The | ||
239 | private key must be either destroyed or moved to a secure location and not kept | ||
240 | in the root node of the kernel source tree. | ||
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt index 3c12d9a7ed00..8a984e994e61 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt | |||
@@ -16,8 +16,12 @@ ip_default_ttl - INTEGER | |||
16 | Default: 64 (as recommended by RFC1700) | 16 | Default: 64 (as recommended by RFC1700) |
17 | 17 | ||
18 | ip_no_pmtu_disc - BOOLEAN | 18 | ip_no_pmtu_disc - BOOLEAN |
19 | Disable Path MTU Discovery. | 19 | Disable Path MTU Discovery. If enabled and a |
20 | default FALSE | 20 | fragmentation-required ICMP is received, the PMTU to this |
21 | destination will be set to min_pmtu (see below). You will need | ||
22 | to raise min_pmtu to the smallest interface MTU on your system | ||
23 | manually if you want to avoid locally generated fragments. | ||
24 | Default: FALSE | ||
21 | 25 | ||
22 | min_pmtu - INTEGER | 26 | min_pmtu - INTEGER |
23 | default 552 - minimum discovered Path MTU | 27 | default 552 - minimum discovered Path MTU |
diff --git a/MAINTAINERS b/MAINTAINERS index 1344816c4c06..d5e4ff328cc7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -1008,6 +1008,8 @@ M: Santosh Shilimkar <santosh.shilimkar@ti.com> | |||
1008 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | 1008 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
1009 | S: Maintained | 1009 | S: Maintained |
1010 | F: arch/arm/mach-keystone/ | 1010 | F: arch/arm/mach-keystone/ |
1011 | F: drivers/clk/keystone/ | ||
1012 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux-keystone.git | ||
1011 | 1013 | ||
1012 | ARM/LOGICPD PXA270 MACHINE SUPPORT | 1014 | ARM/LOGICPD PXA270 MACHINE SUPPORT |
1013 | M: Lennert Buytenhek <kernel@wantstofly.org> | 1015 | M: Lennert Buytenhek <kernel@wantstofly.org> |
@@ -3761,9 +3763,11 @@ F: include/uapi/linux/gigaset_dev.h | |||
3761 | 3763 | ||
3762 | GPIO SUBSYSTEM | 3764 | GPIO SUBSYSTEM |
3763 | M: Linus Walleij <linus.walleij@linaro.org> | 3765 | M: Linus Walleij <linus.walleij@linaro.org> |
3764 | S: Maintained | 3766 | M: Alexandre Courbot <gnurou@gmail.com> |
3765 | L: linux-gpio@vger.kernel.org | 3767 | L: linux-gpio@vger.kernel.org |
3766 | F: Documentation/gpio.txt | 3768 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git |
3769 | S: Maintained | ||
3770 | F: Documentation/gpio/ | ||
3767 | F: drivers/gpio/ | 3771 | F: drivers/gpio/ |
3768 | F: include/linux/gpio* | 3772 | F: include/linux/gpio* |
3769 | F: include/asm-generic/gpio.h | 3773 | F: include/asm-generic/gpio.h |
@@ -3831,6 +3835,12 @@ T: git git://linuxtv.org/media_tree.git | |||
3831 | S: Maintained | 3835 | S: Maintained |
3832 | F: drivers/media/usb/gspca/ | 3836 | F: drivers/media/usb/gspca/ |
3833 | 3837 | ||
3838 | GUID PARTITION TABLE (GPT) | ||
3839 | M: Davidlohr Bueso <davidlohr@hp.com> | ||
3840 | L: linux-efi@vger.kernel.org | ||
3841 | S: Maintained | ||
3842 | F: block/partitions/efi.* | ||
3843 | |||
3834 | STK1160 USB VIDEO CAPTURE DRIVER | 3844 | STK1160 USB VIDEO CAPTURE DRIVER |
3835 | M: Ezequiel Garcia <elezegarcia@gmail.com> | 3845 | M: Ezequiel Garcia <elezegarcia@gmail.com> |
3836 | L: linux-media@vger.kernel.org | 3846 | L: linux-media@vger.kernel.org |
@@ -5911,12 +5921,21 @@ M: Steffen Klassert <steffen.klassert@secunet.com> | |||
5911 | M: Herbert Xu <herbert@gondor.apana.org.au> | 5921 | M: Herbert Xu <herbert@gondor.apana.org.au> |
5912 | M: "David S. Miller" <davem@davemloft.net> | 5922 | M: "David S. Miller" <davem@davemloft.net> |
5913 | L: netdev@vger.kernel.org | 5923 | L: netdev@vger.kernel.org |
5914 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git | 5924 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec.git |
5925 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git | ||
5915 | S: Maintained | 5926 | S: Maintained |
5916 | F: net/xfrm/ | 5927 | F: net/xfrm/ |
5917 | F: net/key/ | 5928 | F: net/key/ |
5918 | F: net/ipv4/xfrm* | 5929 | F: net/ipv4/xfrm* |
5930 | F: net/ipv4/esp4.c | ||
5931 | F: net/ipv4/ah4.c | ||
5932 | F: net/ipv4/ipcomp.c | ||
5933 | F: net/ipv4/ip_vti.c | ||
5919 | F: net/ipv6/xfrm* | 5934 | F: net/ipv6/xfrm* |
5935 | F: net/ipv6/esp6.c | ||
5936 | F: net/ipv6/ah6.c | ||
5937 | F: net/ipv6/ipcomp6.c | ||
5938 | F: net/ipv6/ip6_vti.c | ||
5920 | F: include/uapi/linux/xfrm.h | 5939 | F: include/uapi/linux/xfrm.h |
5921 | F: include/net/xfrm.h | 5940 | F: include/net/xfrm.h |
5922 | 5941 | ||
@@ -9571,7 +9590,7 @@ F: drivers/xen/*swiotlb* | |||
9571 | 9590 | ||
9572 | XFS FILESYSTEM | 9591 | XFS FILESYSTEM |
9573 | P: Silicon Graphics Inc | 9592 | P: Silicon Graphics Inc |
9574 | M: Dave Chinner <dchinner@fromorbit.com> | 9593 | M: Dave Chinner <david@fromorbit.com> |
9575 | M: Ben Myers <bpm@sgi.com> | 9594 | M: Ben Myers <bpm@sgi.com> |
9576 | M: xfs@oss.sgi.com | 9595 | M: xfs@oss.sgi.com |
9577 | L: xfs@oss.sgi.com | 9596 | L: xfs@oss.sgi.com |
@@ -1,7 +1,7 @@ | |||
1 | VERSION = 3 | 1 | VERSION = 3 |
2 | PATCHLEVEL = 13 | 2 | PATCHLEVEL = 13 |
3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 0 |
4 | EXTRAVERSION = -rc4 | 4 | EXTRAVERSION = -rc6 |
5 | NAME = One Giant Leap for Frogkind | 5 | NAME = One Giant Leap for Frogkind |
6 | 6 | ||
7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
@@ -732,19 +732,15 @@ export mod_strip_cmd | |||
732 | # Select initial ramdisk compression format, default is gzip(1). | 732 | # Select initial ramdisk compression format, default is gzip(1). |
733 | # This shall be used by the dracut(8) tool while creating an initramfs image. | 733 | # This shall be used by the dracut(8) tool while creating an initramfs image. |
734 | # | 734 | # |
735 | INITRD_COMPRESS=gzip | 735 | INITRD_COMPRESS-y := gzip |
736 | ifeq ($(CONFIG_RD_BZIP2), y) | 736 | INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2 |
737 | INITRD_COMPRESS=bzip2 | 737 | INITRD_COMPRESS-$(CONFIG_RD_LZMA) := lzma |
738 | else ifeq ($(CONFIG_RD_LZMA), y) | 738 | INITRD_COMPRESS-$(CONFIG_RD_XZ) := xz |
739 | INITRD_COMPRESS=lzma | 739 | INITRD_COMPRESS-$(CONFIG_RD_LZO) := lzo |
740 | else ifeq ($(CONFIG_RD_XZ), y) | 740 | INITRD_COMPRESS-$(CONFIG_RD_LZ4) := lz4 |
741 | INITRD_COMPRESS=xz | 741 | # do not export INITRD_COMPRESS, since we didn't actually |
742 | else ifeq ($(CONFIG_RD_LZO), y) | 742 | # choose a sane default compression above. |
743 | INITRD_COMPRESS=lzo | 743 | # export INITRD_COMPRESS := $(INITRD_COMPRESS-y) |
744 | else ifeq ($(CONFIG_RD_LZ4), y) | ||
745 | INITRD_COMPRESS=lz4 | ||
746 | endif | ||
747 | export INITRD_COMPRESS | ||
748 | 744 | ||
749 | ifdef CONFIG_MODULE_SIG_ALL | 745 | ifdef CONFIG_MODULE_SIG_ALL |
750 | MODSECKEY = ./signing_key.priv | 746 | MODSECKEY = ./signing_key.priv |
diff --git a/arch/arc/include/uapi/asm/unistd.h b/arch/arc/include/uapi/asm/unistd.h index 68125dd766c6..39e58d1cdf90 100644 --- a/arch/arc/include/uapi/asm/unistd.h +++ b/arch/arc/include/uapi/asm/unistd.h | |||
@@ -8,7 +8,11 @@ | |||
8 | 8 | ||
9 | /******** no-legacy-syscalls-ABI *******/ | 9 | /******** no-legacy-syscalls-ABI *******/ |
10 | 10 | ||
11 | #ifndef _UAPI_ASM_ARC_UNISTD_H | 11 | /* |
12 | * Non-typical guard macro to enable inclusion twice in ARCH sys.c | ||
13 | * That is how the Generic syscall wrapper generator works | ||
14 | */ | ||
15 | #if !defined(_UAPI_ASM_ARC_UNISTD_H) || defined(__SYSCALL) | ||
12 | #define _UAPI_ASM_ARC_UNISTD_H | 16 | #define _UAPI_ASM_ARC_UNISTD_H |
13 | 17 | ||
14 | #define __ARCH_WANT_SYS_EXECVE | 18 | #define __ARCH_WANT_SYS_EXECVE |
@@ -36,4 +40,6 @@ __SYSCALL(__NR_arc_gettls, sys_arc_gettls) | |||
36 | #define __NR_sysfs (__NR_arch_specific_syscall + 3) | 40 | #define __NR_sysfs (__NR_arch_specific_syscall + 3) |
37 | __SYSCALL(__NR_sysfs, sys_sysfs) | 41 | __SYSCALL(__NR_sysfs, sys_sysfs) |
38 | 42 | ||
43 | #undef __SYSCALL | ||
44 | |||
39 | #endif | 45 | #endif |
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index c1f1a7eee953..ba0e23234ecf 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -723,6 +723,7 @@ config ARCH_S3C64XX | |||
723 | bool "Samsung S3C64XX" | 723 | bool "Samsung S3C64XX" |
724 | select ARCH_HAS_CPUFREQ | 724 | select ARCH_HAS_CPUFREQ |
725 | select ARCH_REQUIRE_GPIOLIB | 725 | select ARCH_REQUIRE_GPIOLIB |
726 | select ARM_AMBA | ||
726 | select ARM_VIC | 727 | select ARM_VIC |
727 | select CLKDEV_LOOKUP | 728 | select CLKDEV_LOOKUP |
728 | select CLKSRC_SAMSUNG_PWM | 729 | select CLKSRC_SAMSUNG_PWM |
diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi index ee845fad939b..9987dd0e9c59 100644 --- a/arch/arm/boot/dts/r8a7790.dtsi +++ b/arch/arm/boot/dts/r8a7790.dtsi | |||
@@ -87,9 +87,9 @@ | |||
87 | interrupts = <1 9 0xf04>; | 87 | interrupts = <1 9 0xf04>; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | gpio0: gpio@ffc40000 { | 90 | gpio0: gpio@e6050000 { |
91 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; | 91 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
92 | reg = <0 0xffc40000 0 0x2c>; | 92 | reg = <0 0xe6050000 0 0x50>; |
93 | interrupt-parent = <&gic>; | 93 | interrupt-parent = <&gic>; |
94 | interrupts = <0 4 0x4>; | 94 | interrupts = <0 4 0x4>; |
95 | #gpio-cells = <2>; | 95 | #gpio-cells = <2>; |
@@ -99,9 +99,9 @@ | |||
99 | interrupt-controller; | 99 | interrupt-controller; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | gpio1: gpio@ffc41000 { | 102 | gpio1: gpio@e6051000 { |
103 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; | 103 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
104 | reg = <0 0xffc41000 0 0x2c>; | 104 | reg = <0 0xe6051000 0 0x50>; |
105 | interrupt-parent = <&gic>; | 105 | interrupt-parent = <&gic>; |
106 | interrupts = <0 5 0x4>; | 106 | interrupts = <0 5 0x4>; |
107 | #gpio-cells = <2>; | 107 | #gpio-cells = <2>; |
@@ -111,9 +111,9 @@ | |||
111 | interrupt-controller; | 111 | interrupt-controller; |
112 | }; | 112 | }; |
113 | 113 | ||
114 | gpio2: gpio@ffc42000 { | 114 | gpio2: gpio@e6052000 { |
115 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; | 115 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
116 | reg = <0 0xffc42000 0 0x2c>; | 116 | reg = <0 0xe6052000 0 0x50>; |
117 | interrupt-parent = <&gic>; | 117 | interrupt-parent = <&gic>; |
118 | interrupts = <0 6 0x4>; | 118 | interrupts = <0 6 0x4>; |
119 | #gpio-cells = <2>; | 119 | #gpio-cells = <2>; |
@@ -123,9 +123,9 @@ | |||
123 | interrupt-controller; | 123 | interrupt-controller; |
124 | }; | 124 | }; |
125 | 125 | ||
126 | gpio3: gpio@ffc43000 { | 126 | gpio3: gpio@e6053000 { |
127 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; | 127 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
128 | reg = <0 0xffc43000 0 0x2c>; | 128 | reg = <0 0xe6053000 0 0x50>; |
129 | interrupt-parent = <&gic>; | 129 | interrupt-parent = <&gic>; |
130 | interrupts = <0 7 0x4>; | 130 | interrupts = <0 7 0x4>; |
131 | #gpio-cells = <2>; | 131 | #gpio-cells = <2>; |
@@ -135,9 +135,9 @@ | |||
135 | interrupt-controller; | 135 | interrupt-controller; |
136 | }; | 136 | }; |
137 | 137 | ||
138 | gpio4: gpio@ffc44000 { | 138 | gpio4: gpio@e6054000 { |
139 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; | 139 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
140 | reg = <0 0xffc44000 0 0x2c>; | 140 | reg = <0 0xe6054000 0 0x50>; |
141 | interrupt-parent = <&gic>; | 141 | interrupt-parent = <&gic>; |
142 | interrupts = <0 8 0x4>; | 142 | interrupts = <0 8 0x4>; |
143 | #gpio-cells = <2>; | 143 | #gpio-cells = <2>; |
@@ -147,9 +147,9 @@ | |||
147 | interrupt-controller; | 147 | interrupt-controller; |
148 | }; | 148 | }; |
149 | 149 | ||
150 | gpio5: gpio@ffc45000 { | 150 | gpio5: gpio@e6055000 { |
151 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; | 151 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
152 | reg = <0 0xffc45000 0 0x2c>; | 152 | reg = <0 0xe6055000 0 0x50>; |
153 | interrupt-parent = <&gic>; | 153 | interrupt-parent = <&gic>; |
154 | interrupts = <0 9 0x4>; | 154 | interrupts = <0 9 0x4>; |
155 | #gpio-cells = <2>; | 155 | #gpio-cells = <2>; |
@@ -241,7 +241,7 @@ | |||
241 | 241 | ||
242 | sdhi0: sdhi@ee100000 { | 242 | sdhi0: sdhi@ee100000 { |
243 | compatible = "renesas,sdhi-r8a7790"; | 243 | compatible = "renesas,sdhi-r8a7790"; |
244 | reg = <0 0xee100000 0 0x100>; | 244 | reg = <0 0xee100000 0 0x200>; |
245 | interrupt-parent = <&gic>; | 245 | interrupt-parent = <&gic>; |
246 | interrupts = <0 165 4>; | 246 | interrupts = <0 165 4>; |
247 | cap-sd-highspeed; | 247 | cap-sd-highspeed; |
@@ -250,7 +250,7 @@ | |||
250 | 250 | ||
251 | sdhi1: sdhi@ee120000 { | 251 | sdhi1: sdhi@ee120000 { |
252 | compatible = "renesas,sdhi-r8a7790"; | 252 | compatible = "renesas,sdhi-r8a7790"; |
253 | reg = <0 0xee120000 0 0x100>; | 253 | reg = <0 0xee120000 0 0x200>; |
254 | interrupt-parent = <&gic>; | 254 | interrupt-parent = <&gic>; |
255 | interrupts = <0 166 4>; | 255 | interrupts = <0 166 4>; |
256 | cap-sd-highspeed; | 256 | cap-sd-highspeed; |
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c index 4ec8d82b0492..44a59c3abfb0 100644 --- a/arch/arm/mach-omap2/board-ldp.c +++ b/arch/arm/mach-omap2/board-ldp.c | |||
@@ -242,12 +242,18 @@ static void __init ldp_display_init(void) | |||
242 | 242 | ||
243 | static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio) | 243 | static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio) |
244 | { | 244 | { |
245 | int res; | ||
246 | |||
245 | /* LCD enable GPIO */ | 247 | /* LCD enable GPIO */ |
246 | ldp_lcd_pdata.enable_gpio = gpio + 7; | 248 | ldp_lcd_pdata.enable_gpio = gpio + 7; |
247 | 249 | ||
248 | /* Backlight enable GPIO */ | 250 | /* Backlight enable GPIO */ |
249 | ldp_lcd_pdata.backlight_gpio = gpio + 15; | 251 | ldp_lcd_pdata.backlight_gpio = gpio + 15; |
250 | 252 | ||
253 | res = platform_device_register(&ldp_lcd_device); | ||
254 | if (res) | ||
255 | pr_err("Unable to register LCD: %d\n", res); | ||
256 | |||
251 | return 0; | 257 | return 0; |
252 | } | 258 | } |
253 | 259 | ||
@@ -346,7 +352,6 @@ static struct omap2_hsmmc_info mmc[] __initdata = { | |||
346 | 352 | ||
347 | static struct platform_device *ldp_devices[] __initdata = { | 353 | static struct platform_device *ldp_devices[] __initdata = { |
348 | &ldp_gpio_keys_device, | 354 | &ldp_gpio_keys_device, |
349 | &ldp_lcd_device, | ||
350 | }; | 355 | }; |
351 | 356 | ||
352 | #ifdef CONFIG_OMAP_MUX | 357 | #ifdef CONFIG_OMAP_MUX |
diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c index 58347bb874a0..4cf165502b35 100644 --- a/arch/arm/mach-omap2/display.c +++ b/arch/arm/mach-omap2/display.c | |||
@@ -101,13 +101,51 @@ static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initconst = { | |||
101 | { "dss_hdmi", "omapdss_hdmi", -1 }, | 101 | { "dss_hdmi", "omapdss_hdmi", -1 }, |
102 | }; | 102 | }; |
103 | 103 | ||
104 | static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes) | ||
105 | { | ||
106 | u32 enable_mask, enable_shift; | ||
107 | u32 pipd_mask, pipd_shift; | ||
108 | u32 reg; | ||
109 | |||
110 | if (dsi_id == 0) { | ||
111 | enable_mask = OMAP4_DSI1_LANEENABLE_MASK; | ||
112 | enable_shift = OMAP4_DSI1_LANEENABLE_SHIFT; | ||
113 | pipd_mask = OMAP4_DSI1_PIPD_MASK; | ||
114 | pipd_shift = OMAP4_DSI1_PIPD_SHIFT; | ||
115 | } else if (dsi_id == 1) { | ||
116 | enable_mask = OMAP4_DSI2_LANEENABLE_MASK; | ||
117 | enable_shift = OMAP4_DSI2_LANEENABLE_SHIFT; | ||
118 | pipd_mask = OMAP4_DSI2_PIPD_MASK; | ||
119 | pipd_shift = OMAP4_DSI2_PIPD_SHIFT; | ||
120 | } else { | ||
121 | return -ENODEV; | ||
122 | } | ||
123 | |||
124 | reg = omap4_ctrl_pad_readl(OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY); | ||
125 | |||
126 | reg &= ~enable_mask; | ||
127 | reg &= ~pipd_mask; | ||
128 | |||
129 | reg |= (lanes << enable_shift) & enable_mask; | ||
130 | reg |= (lanes << pipd_shift) & pipd_mask; | ||
131 | |||
132 | omap4_ctrl_pad_writel(reg, OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY); | ||
133 | |||
134 | return 0; | ||
135 | } | ||
136 | |||
104 | static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask) | 137 | static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask) |
105 | { | 138 | { |
139 | if (cpu_is_omap44xx()) | ||
140 | return omap4_dsi_mux_pads(dsi_id, lane_mask); | ||
141 | |||
106 | return 0; | 142 | return 0; |
107 | } | 143 | } |
108 | 144 | ||
109 | static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask) | 145 | static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask) |
110 | { | 146 | { |
147 | if (cpu_is_omap44xx()) | ||
148 | omap4_dsi_mux_pads(dsi_id, 0); | ||
111 | } | 149 | } |
112 | 150 | ||
113 | static int omap_dss_set_min_bus_tput(struct device *dev, unsigned long tput) | 151 | static int omap_dss_set_min_bus_tput(struct device *dev, unsigned long tput) |
diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c index 56cebb05509e..d23c77fadb31 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c | |||
@@ -796,7 +796,7 @@ struct omap_hwmod omap2xxx_counter_32k_hwmod = { | |||
796 | 796 | ||
797 | /* gpmc */ | 797 | /* gpmc */ |
798 | static struct omap_hwmod_irq_info omap2xxx_gpmc_irqs[] = { | 798 | static struct omap_hwmod_irq_info omap2xxx_gpmc_irqs[] = { |
799 | { .irq = 20 }, | 799 | { .irq = 20 + OMAP_INTC_START, }, |
800 | { .irq = -1 } | 800 | { .irq = -1 } |
801 | }; | 801 | }; |
802 | 802 | ||
@@ -841,7 +841,7 @@ static struct omap_hwmod_class omap2_rng_hwmod_class = { | |||
841 | }; | 841 | }; |
842 | 842 | ||
843 | static struct omap_hwmod_irq_info omap2_rng_mpu_irqs[] = { | 843 | static struct omap_hwmod_irq_info omap2_rng_mpu_irqs[] = { |
844 | { .irq = 52 }, | 844 | { .irq = 52 + OMAP_INTC_START, }, |
845 | { .irq = -1 } | 845 | { .irq = -1 } |
846 | }; | 846 | }; |
847 | 847 | ||
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c index d33742908f97..4c3b1e6df508 100644 --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | |||
@@ -2165,7 +2165,7 @@ static struct omap_hwmod_class omap3xxx_gpmc_hwmod_class = { | |||
2165 | }; | 2165 | }; |
2166 | 2166 | ||
2167 | static struct omap_hwmod_irq_info omap3xxx_gpmc_irqs[] = { | 2167 | static struct omap_hwmod_irq_info omap3xxx_gpmc_irqs[] = { |
2168 | { .irq = 20 }, | 2168 | { .irq = 20 + OMAP_INTC_START, }, |
2169 | { .irq = -1 } | 2169 | { .irq = -1 } |
2170 | }; | 2170 | }; |
2171 | 2171 | ||
@@ -2999,7 +2999,7 @@ static struct omap_mmu_dev_attr mmu_isp_dev_attr = { | |||
2999 | 2999 | ||
3000 | static struct omap_hwmod omap3xxx_mmu_isp_hwmod; | 3000 | static struct omap_hwmod omap3xxx_mmu_isp_hwmod; |
3001 | static struct omap_hwmod_irq_info omap3xxx_mmu_isp_irqs[] = { | 3001 | static struct omap_hwmod_irq_info omap3xxx_mmu_isp_irqs[] = { |
3002 | { .irq = 24 }, | 3002 | { .irq = 24 + OMAP_INTC_START, }, |
3003 | { .irq = -1 } | 3003 | { .irq = -1 } |
3004 | }; | 3004 | }; |
3005 | 3005 | ||
@@ -3041,7 +3041,7 @@ static struct omap_mmu_dev_attr mmu_iva_dev_attr = { | |||
3041 | 3041 | ||
3042 | static struct omap_hwmod omap3xxx_mmu_iva_hwmod; | 3042 | static struct omap_hwmod omap3xxx_mmu_iva_hwmod; |
3043 | static struct omap_hwmod_irq_info omap3xxx_mmu_iva_irqs[] = { | 3043 | static struct omap_hwmod_irq_info omap3xxx_mmu_iva_irqs[] = { |
3044 | { .irq = 28 }, | 3044 | { .irq = 28 + OMAP_INTC_START, }, |
3045 | { .irq = -1 } | 3045 | { .irq = -1 } |
3046 | }; | 3046 | }; |
3047 | 3047 | ||
diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c index db32d5380b11..18f333c440db 100644 --- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c | |||
@@ -1637,7 +1637,7 @@ static struct omap_hwmod dra7xx_uart1_hwmod = { | |||
1637 | .class = &dra7xx_uart_hwmod_class, | 1637 | .class = &dra7xx_uart_hwmod_class, |
1638 | .clkdm_name = "l4per_clkdm", | 1638 | .clkdm_name = "l4per_clkdm", |
1639 | .main_clk = "uart1_gfclk_mux", | 1639 | .main_clk = "uart1_gfclk_mux", |
1640 | .flags = HWMOD_SWSUP_SIDLE_ACT, | 1640 | .flags = HWMOD_SWSUP_SIDLE_ACT | DEBUG_OMAP2UART1_FLAGS, |
1641 | .prcm = { | 1641 | .prcm = { |
1642 | .omap4 = { | 1642 | .omap4 = { |
1643 | .clkctrl_offs = DRA7XX_CM_L4PER_UART1_CLKCTRL_OFFSET, | 1643 | .clkctrl_offs = DRA7XX_CM_L4PER_UART1_CLKCTRL_OFFSET, |
diff --git a/arch/arm/mach-pxa/include/mach/lubbock.h b/arch/arm/mach-pxa/include/mach/lubbock.h index 2a086e8373eb..958cd6af9384 100644 --- a/arch/arm/mach-pxa/include/mach/lubbock.h +++ b/arch/arm/mach-pxa/include/mach/lubbock.h | |||
@@ -10,6 +10,8 @@ | |||
10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <mach/irqs.h> | ||
14 | |||
13 | #define LUBBOCK_ETH_PHYS PXA_CS3_PHYS | 15 | #define LUBBOCK_ETH_PHYS PXA_CS3_PHYS |
14 | 16 | ||
15 | #define LUBBOCK_FPGA_PHYS PXA_CS2_PHYS | 17 | #define LUBBOCK_FPGA_PHYS PXA_CS2_PHYS |
diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig index 2cb8dc55b50e..7094bccbae91 100644 --- a/arch/arm/mach-s3c64xx/Kconfig +++ b/arch/arm/mach-s3c64xx/Kconfig | |||
@@ -17,9 +17,10 @@ config CPU_S3C6410 | |||
17 | help | 17 | help |
18 | Enable S3C6410 CPU support | 18 | Enable S3C6410 CPU support |
19 | 19 | ||
20 | config S3C64XX_DMA | 20 | config S3C64XX_PL080 |
21 | bool "S3C64XX DMA" | 21 | bool "S3C64XX DMA using generic PL08x driver" |
22 | select S3C_DMA | 22 | select AMBA_PL08X |
23 | select SAMSUNG_DMADEV | ||
23 | 24 | ||
24 | config S3C64XX_SETUP_SDHCI | 25 | config S3C64XX_SETUP_SDHCI |
25 | bool | 26 | bool |
diff --git a/arch/arm/mach-s3c64xx/Makefile b/arch/arm/mach-s3c64xx/Makefile index 6faedcffce04..58069a702a43 100644 --- a/arch/arm/mach-s3c64xx/Makefile +++ b/arch/arm/mach-s3c64xx/Makefile | |||
@@ -26,7 +26,7 @@ obj-$(CONFIG_CPU_IDLE) += cpuidle.o | |||
26 | 26 | ||
27 | # DMA support | 27 | # DMA support |
28 | 28 | ||
29 | obj-$(CONFIG_S3C64XX_DMA) += dma.o | 29 | obj-$(CONFIG_S3C64XX_PL080) += pl080.o |
30 | 30 | ||
31 | # Device support | 31 | # Device support |
32 | 32 | ||
diff --git a/arch/arm/mach-s3c64xx/common.h b/arch/arm/mach-s3c64xx/common.h index bd3bd562011e..7043e7a3a67e 100644 --- a/arch/arm/mach-s3c64xx/common.h +++ b/arch/arm/mach-s3c64xx/common.h | |||
@@ -58,4 +58,9 @@ int __init s3c64xx_pm_late_initcall(void); | |||
58 | static inline int s3c64xx_pm_late_initcall(void) { return 0; } | 58 | static inline int s3c64xx_pm_late_initcall(void) { return 0; } |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | #ifdef CONFIG_S3C64XX_PL080 | ||
62 | extern struct pl08x_platform_data s3c64xx_dma0_plat_data; | ||
63 | extern struct pl08x_platform_data s3c64xx_dma1_plat_data; | ||
64 | #endif | ||
65 | |||
61 | #endif /* __ARCH_ARM_MACH_S3C64XX_COMMON_H */ | 66 | #endif /* __ARCH_ARM_MACH_S3C64XX_COMMON_H */ |
diff --git a/arch/arm/mach-s3c64xx/dma.c b/arch/arm/mach-s3c64xx/dma.c deleted file mode 100644 index 7e22c2113816..000000000000 --- a/arch/arm/mach-s3c64xx/dma.c +++ /dev/null | |||
@@ -1,762 +0,0 @@ | |||
1 | /* linux/arch/arm/plat-s3c64xx/dma.c | ||
2 | * | ||
3 | * Copyright 2009 Openmoko, Inc. | ||
4 | * Copyright 2009 Simtec Electronics | ||
5 | * Ben Dooks <ben@simtec.co.uk> | ||
6 | * http://armlinux.simtec.co.uk/ | ||
7 | * | ||
8 | * S3C64XX DMA core | ||
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 | /* | ||
16 | * NOTE: Code in this file is not used when booting with Device Tree support. | ||
17 | */ | ||
18 | |||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/dmapool.h> | ||
23 | #include <linux/device.h> | ||
24 | #include <linux/errno.h> | ||
25 | #include <linux/slab.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/clk.h> | ||
28 | #include <linux/err.h> | ||
29 | #include <linux/io.h> | ||
30 | #include <linux/amba/pl080.h> | ||
31 | #include <linux/of.h> | ||
32 | |||
33 | #include <mach/dma.h> | ||
34 | #include <mach/map.h> | ||
35 | #include <mach/irqs.h> | ||
36 | |||
37 | #include "regs-sys.h" | ||
38 | |||
39 | /* dma channel state information */ | ||
40 | |||
41 | struct s3c64xx_dmac { | ||
42 | struct device dev; | ||
43 | struct clk *clk; | ||
44 | void __iomem *regs; | ||
45 | struct s3c2410_dma_chan *channels; | ||
46 | enum dma_ch chanbase; | ||
47 | }; | ||
48 | |||
49 | /* pool to provide LLI buffers */ | ||
50 | static struct dma_pool *dma_pool; | ||
51 | |||
52 | /* Debug configuration and code */ | ||
53 | |||
54 | static unsigned char debug_show_buffs = 0; | ||
55 | |||
56 | static void dbg_showchan(struct s3c2410_dma_chan *chan) | ||
57 | { | ||
58 | pr_debug("DMA%d: %08x->%08x L %08x C %08x,%08x S %08x\n", | ||
59 | chan->number, | ||
60 | readl(chan->regs + PL080_CH_SRC_ADDR), | ||
61 | readl(chan->regs + PL080_CH_DST_ADDR), | ||
62 | readl(chan->regs + PL080_CH_LLI), | ||
63 | readl(chan->regs + PL080_CH_CONTROL), | ||
64 | readl(chan->regs + PL080S_CH_CONTROL2), | ||
65 | readl(chan->regs + PL080S_CH_CONFIG)); | ||
66 | } | ||
67 | |||
68 | static void show_lli(struct pl080s_lli *lli) | ||
69 | { | ||
70 | pr_debug("LLI[%p] %08x->%08x, NL %08x C %08x,%08x\n", | ||
71 | lli, lli->src_addr, lli->dst_addr, lli->next_lli, | ||
72 | lli->control0, lli->control1); | ||
73 | } | ||
74 | |||
75 | static void dbg_showbuffs(struct s3c2410_dma_chan *chan) | ||
76 | { | ||
77 | struct s3c64xx_dma_buff *ptr; | ||
78 | struct s3c64xx_dma_buff *end; | ||
79 | |||
80 | pr_debug("DMA%d: buffs next %p, curr %p, end %p\n", | ||
81 | chan->number, chan->next, chan->curr, chan->end); | ||
82 | |||
83 | ptr = chan->next; | ||
84 | end = chan->end; | ||
85 | |||
86 | if (debug_show_buffs) { | ||
87 | for (; ptr != NULL; ptr = ptr->next) { | ||
88 | pr_debug("DMA%d: %08x ", | ||
89 | chan->number, ptr->lli_dma); | ||
90 | show_lli(ptr->lli); | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | |||
95 | /* End of Debug */ | ||
96 | |||
97 | static struct s3c2410_dma_chan *s3c64xx_dma_map_channel(unsigned int channel) | ||
98 | { | ||
99 | struct s3c2410_dma_chan *chan; | ||
100 | unsigned int start, offs; | ||
101 | |||
102 | start = 0; | ||
103 | |||
104 | if (channel >= DMACH_PCM1_TX) | ||
105 | start = 8; | ||
106 | |||
107 | for (offs = 0; offs < 8; offs++) { | ||
108 | chan = &s3c2410_chans[start + offs]; | ||
109 | if (!chan->in_use) | ||
110 | goto found; | ||
111 | } | ||
112 | |||
113 | return NULL; | ||
114 | |||
115 | found: | ||
116 | s3c_dma_chan_map[channel] = chan; | ||
117 | return chan; | ||
118 | } | ||
119 | |||
120 | int s3c2410_dma_config(enum dma_ch channel, int xferunit) | ||
121 | { | ||
122 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); | ||
123 | |||
124 | if (chan == NULL) | ||
125 | return -EINVAL; | ||
126 | |||
127 | switch (xferunit) { | ||
128 | case 1: | ||
129 | chan->hw_width = 0; | ||
130 | break; | ||
131 | case 2: | ||
132 | chan->hw_width = 1; | ||
133 | break; | ||
134 | case 4: | ||
135 | chan->hw_width = 2; | ||
136 | break; | ||
137 | default: | ||
138 | printk(KERN_ERR "%s: illegal width %d\n", __func__, xferunit); | ||
139 | return -EINVAL; | ||
140 | } | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | EXPORT_SYMBOL(s3c2410_dma_config); | ||
145 | |||
146 | static void s3c64xx_dma_fill_lli(struct s3c2410_dma_chan *chan, | ||
147 | struct pl080s_lli *lli, | ||
148 | dma_addr_t data, int size) | ||
149 | { | ||
150 | dma_addr_t src, dst; | ||
151 | u32 control0, control1; | ||
152 | |||
153 | switch (chan->source) { | ||
154 | case DMA_FROM_DEVICE: | ||
155 | src = chan->dev_addr; | ||
156 | dst = data; | ||
157 | control0 = PL080_CONTROL_SRC_AHB2; | ||
158 | control0 |= PL080_CONTROL_DST_INCR; | ||
159 | break; | ||
160 | |||
161 | case DMA_TO_DEVICE: | ||
162 | src = data; | ||
163 | dst = chan->dev_addr; | ||
164 | control0 = PL080_CONTROL_DST_AHB2; | ||
165 | control0 |= PL080_CONTROL_SRC_INCR; | ||
166 | break; | ||
167 | default: | ||
168 | BUG(); | ||
169 | } | ||
170 | |||
171 | /* note, we do not currently setup any of the burst controls */ | ||
172 | |||
173 | control1 = size >> chan->hw_width; /* size in no of xfers */ | ||
174 | control0 |= PL080_CONTROL_PROT_SYS; /* always in priv. mode */ | ||
175 | control0 |= PL080_CONTROL_TC_IRQ_EN; /* always fire IRQ */ | ||
176 | control0 |= (u32)chan->hw_width << PL080_CONTROL_DWIDTH_SHIFT; | ||
177 | control0 |= (u32)chan->hw_width << PL080_CONTROL_SWIDTH_SHIFT; | ||
178 | |||
179 | lli->src_addr = src; | ||
180 | lli->dst_addr = dst; | ||
181 | lli->next_lli = 0; | ||
182 | lli->control0 = control0; | ||
183 | lli->control1 = control1; | ||
184 | } | ||
185 | |||
186 | static void s3c64xx_lli_to_regs(struct s3c2410_dma_chan *chan, | ||
187 | struct pl080s_lli *lli) | ||
188 | { | ||
189 | void __iomem *regs = chan->regs; | ||
190 | |||
191 | pr_debug("%s: LLI %p => regs\n", __func__, lli); | ||
192 | show_lli(lli); | ||
193 | |||
194 | writel(lli->src_addr, regs + PL080_CH_SRC_ADDR); | ||
195 | writel(lli->dst_addr, regs + PL080_CH_DST_ADDR); | ||
196 | writel(lli->next_lli, regs + PL080_CH_LLI); | ||
197 | writel(lli->control0, regs + PL080_CH_CONTROL); | ||
198 | writel(lli->control1, regs + PL080S_CH_CONTROL2); | ||
199 | } | ||
200 | |||
201 | static int s3c64xx_dma_start(struct s3c2410_dma_chan *chan) | ||
202 | { | ||
203 | struct s3c64xx_dmac *dmac = chan->dmac; | ||
204 | u32 config; | ||
205 | u32 bit = chan->bit; | ||
206 | |||
207 | dbg_showchan(chan); | ||
208 | |||
209 | pr_debug("%s: clearing interrupts\n", __func__); | ||
210 | |||
211 | /* clear interrupts */ | ||
212 | writel(bit, dmac->regs + PL080_TC_CLEAR); | ||
213 | writel(bit, dmac->regs + PL080_ERR_CLEAR); | ||
214 | |||
215 | pr_debug("%s: starting channel\n", __func__); | ||
216 | |||
217 | config = readl(chan->regs + PL080S_CH_CONFIG); | ||
218 | config |= PL080_CONFIG_ENABLE; | ||
219 | config &= ~PL080_CONFIG_HALT; | ||
220 | |||
221 | pr_debug("%s: writing config %08x\n", __func__, config); | ||
222 | writel(config, chan->regs + PL080S_CH_CONFIG); | ||
223 | |||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | static int s3c64xx_dma_stop(struct s3c2410_dma_chan *chan) | ||
228 | { | ||
229 | u32 config; | ||
230 | int timeout; | ||
231 | |||
232 | pr_debug("%s: stopping channel\n", __func__); | ||
233 | |||
234 | dbg_showchan(chan); | ||
235 | |||
236 | config = readl(chan->regs + PL080S_CH_CONFIG); | ||
237 | config |= PL080_CONFIG_HALT; | ||
238 | writel(config, chan->regs + PL080S_CH_CONFIG); | ||
239 | |||
240 | timeout = 1000; | ||
241 | do { | ||
242 | config = readl(chan->regs + PL080S_CH_CONFIG); | ||
243 | pr_debug("%s: %d - config %08x\n", __func__, timeout, config); | ||
244 | if (config & PL080_CONFIG_ACTIVE) | ||
245 | udelay(10); | ||
246 | else | ||
247 | break; | ||
248 | } while (--timeout > 0); | ||
249 | |||
250 | if (config & PL080_CONFIG_ACTIVE) { | ||
251 | printk(KERN_ERR "%s: channel still active\n", __func__); | ||
252 | return -EFAULT; | ||
253 | } | ||
254 | |||
255 | config = readl(chan->regs + PL080S_CH_CONFIG); | ||
256 | config &= ~PL080_CONFIG_ENABLE; | ||
257 | writel(config, chan->regs + PL080S_CH_CONFIG); | ||
258 | |||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | static inline void s3c64xx_dma_bufffdone(struct s3c2410_dma_chan *chan, | ||
263 | struct s3c64xx_dma_buff *buf, | ||
264 | enum s3c2410_dma_buffresult result) | ||
265 | { | ||
266 | if (chan->callback_fn != NULL) | ||
267 | (chan->callback_fn)(chan, buf->pw, 0, result); | ||
268 | } | ||
269 | |||
270 | static void s3c64xx_dma_freebuff(struct s3c64xx_dma_buff *buff) | ||
271 | { | ||
272 | dma_pool_free(dma_pool, buff->lli, buff->lli_dma); | ||
273 | kfree(buff); | ||
274 | } | ||
275 | |||
276 | static int s3c64xx_dma_flush(struct s3c2410_dma_chan *chan) | ||
277 | { | ||
278 | struct s3c64xx_dma_buff *buff, *next; | ||
279 | u32 config; | ||
280 | |||
281 | dbg_showchan(chan); | ||
282 | |||
283 | pr_debug("%s: flushing channel\n", __func__); | ||
284 | |||
285 | config = readl(chan->regs + PL080S_CH_CONFIG); | ||
286 | config &= ~PL080_CONFIG_ENABLE; | ||
287 | writel(config, chan->regs + PL080S_CH_CONFIG); | ||
288 | |||
289 | /* dump all the buffers associated with this channel */ | ||
290 | |||
291 | for (buff = chan->curr; buff != NULL; buff = next) { | ||
292 | next = buff->next; | ||
293 | pr_debug("%s: buff %p (next %p)\n", __func__, buff, buff->next); | ||
294 | |||
295 | s3c64xx_dma_bufffdone(chan, buff, S3C2410_RES_ABORT); | ||
296 | s3c64xx_dma_freebuff(buff); | ||
297 | } | ||
298 | |||
299 | chan->curr = chan->next = chan->end = NULL; | ||
300 | |||
301 | return 0; | ||
302 | } | ||
303 | |||
304 | int s3c2410_dma_ctrl(enum dma_ch channel, enum s3c2410_chan_op op) | ||
305 | { | ||
306 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); | ||
307 | |||
308 | WARN_ON(!chan); | ||
309 | if (!chan) | ||
310 | return -EINVAL; | ||
311 | |||
312 | switch (op) { | ||
313 | case S3C2410_DMAOP_START: | ||
314 | return s3c64xx_dma_start(chan); | ||
315 | |||
316 | case S3C2410_DMAOP_STOP: | ||
317 | return s3c64xx_dma_stop(chan); | ||
318 | |||
319 | case S3C2410_DMAOP_FLUSH: | ||
320 | return s3c64xx_dma_flush(chan); | ||
321 | |||
322 | /* believe PAUSE/RESUME are no-ops */ | ||
323 | case S3C2410_DMAOP_PAUSE: | ||
324 | case S3C2410_DMAOP_RESUME: | ||
325 | case S3C2410_DMAOP_STARTED: | ||
326 | case S3C2410_DMAOP_TIMEOUT: | ||
327 | return 0; | ||
328 | } | ||
329 | |||
330 | return -ENOENT; | ||
331 | } | ||
332 | EXPORT_SYMBOL(s3c2410_dma_ctrl); | ||
333 | |||
334 | /* s3c2410_dma_enque | ||
335 | * | ||
336 | */ | ||
337 | |||
338 | int s3c2410_dma_enqueue(enum dma_ch channel, void *id, | ||
339 | dma_addr_t data, int size) | ||
340 | { | ||
341 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); | ||
342 | struct s3c64xx_dma_buff *next; | ||
343 | struct s3c64xx_dma_buff *buff; | ||
344 | struct pl080s_lli *lli; | ||
345 | unsigned long flags; | ||
346 | int ret; | ||
347 | |||
348 | WARN_ON(!chan); | ||
349 | if (!chan) | ||
350 | return -EINVAL; | ||
351 | |||
352 | buff = kzalloc(sizeof(struct s3c64xx_dma_buff), GFP_ATOMIC); | ||
353 | if (!buff) { | ||
354 | printk(KERN_ERR "%s: no memory for buffer\n", __func__); | ||
355 | return -ENOMEM; | ||
356 | } | ||
357 | |||
358 | lli = dma_pool_alloc(dma_pool, GFP_ATOMIC, &buff->lli_dma); | ||
359 | if (!lli) { | ||
360 | printk(KERN_ERR "%s: no memory for lli\n", __func__); | ||
361 | ret = -ENOMEM; | ||
362 | goto err_buff; | ||
363 | } | ||
364 | |||
365 | pr_debug("%s: buff %p, dp %08x lli (%p, %08x) %d\n", | ||
366 | __func__, buff, data, lli, (u32)buff->lli_dma, size); | ||
367 | |||
368 | buff->lli = lli; | ||
369 | buff->pw = id; | ||
370 | |||
371 | s3c64xx_dma_fill_lli(chan, lli, data, size); | ||
372 | |||
373 | local_irq_save(flags); | ||
374 | |||
375 | if ((next = chan->next) != NULL) { | ||
376 | struct s3c64xx_dma_buff *end = chan->end; | ||
377 | struct pl080s_lli *endlli = end->lli; | ||
378 | |||
379 | pr_debug("enquing onto channel\n"); | ||
380 | |||
381 | end->next = buff; | ||
382 | endlli->next_lli = buff->lli_dma; | ||
383 | |||
384 | if (chan->flags & S3C2410_DMAF_CIRCULAR) { | ||
385 | struct s3c64xx_dma_buff *curr = chan->curr; | ||
386 | lli->next_lli = curr->lli_dma; | ||
387 | } | ||
388 | |||
389 | if (next == chan->curr) { | ||
390 | writel(buff->lli_dma, chan->regs + PL080_CH_LLI); | ||
391 | chan->next = buff; | ||
392 | } | ||
393 | |||
394 | show_lli(endlli); | ||
395 | chan->end = buff; | ||
396 | } else { | ||
397 | pr_debug("enquing onto empty channel\n"); | ||
398 | |||
399 | chan->curr = buff; | ||
400 | chan->next = buff; | ||
401 | chan->end = buff; | ||
402 | |||
403 | s3c64xx_lli_to_regs(chan, lli); | ||
404 | } | ||
405 | |||
406 | local_irq_restore(flags); | ||
407 | |||
408 | show_lli(lli); | ||
409 | |||
410 | dbg_showchan(chan); | ||
411 | dbg_showbuffs(chan); | ||
412 | return 0; | ||
413 | |||
414 | err_buff: | ||
415 | kfree(buff); | ||
416 | return ret; | ||
417 | } | ||
418 | |||
419 | EXPORT_SYMBOL(s3c2410_dma_enqueue); | ||
420 | |||
421 | |||
422 | int s3c2410_dma_devconfig(enum dma_ch channel, | ||
423 | enum dma_data_direction source, | ||
424 | unsigned long devaddr) | ||
425 | { | ||
426 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); | ||
427 | u32 peripheral; | ||
428 | u32 config = 0; | ||
429 | |||
430 | pr_debug("%s: channel %d, source %d, dev %08lx, chan %p\n", | ||
431 | __func__, channel, source, devaddr, chan); | ||
432 | |||
433 | WARN_ON(!chan); | ||
434 | if (!chan) | ||
435 | return -EINVAL; | ||
436 | |||
437 | peripheral = (chan->peripheral & 0xf); | ||
438 | chan->source = source; | ||
439 | chan->dev_addr = devaddr; | ||
440 | |||
441 | pr_debug("%s: peripheral %d\n", __func__, peripheral); | ||
442 | |||
443 | switch (source) { | ||
444 | case DMA_FROM_DEVICE: | ||
445 | config = 2 << PL080_CONFIG_FLOW_CONTROL_SHIFT; | ||
446 | config |= peripheral << PL080_CONFIG_SRC_SEL_SHIFT; | ||
447 | break; | ||
448 | case DMA_TO_DEVICE: | ||
449 | config = 1 << PL080_CONFIG_FLOW_CONTROL_SHIFT; | ||
450 | config |= peripheral << PL080_CONFIG_DST_SEL_SHIFT; | ||
451 | break; | ||
452 | default: | ||
453 | printk(KERN_ERR "%s: bad source\n", __func__); | ||
454 | return -EINVAL; | ||
455 | } | ||
456 | |||
457 | /* allow TC and ERR interrupts */ | ||
458 | config |= PL080_CONFIG_TC_IRQ_MASK; | ||
459 | config |= PL080_CONFIG_ERR_IRQ_MASK; | ||
460 | |||
461 | pr_debug("%s: config %08x\n", __func__, config); | ||
462 | |||
463 | writel(config, chan->regs + PL080S_CH_CONFIG); | ||
464 | |||
465 | return 0; | ||
466 | } | ||
467 | EXPORT_SYMBOL(s3c2410_dma_devconfig); | ||
468 | |||
469 | |||
470 | int s3c2410_dma_getposition(enum dma_ch channel, | ||
471 | dma_addr_t *src, dma_addr_t *dst) | ||
472 | { | ||
473 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); | ||
474 | |||
475 | WARN_ON(!chan); | ||
476 | if (!chan) | ||
477 | return -EINVAL; | ||
478 | |||
479 | if (src != NULL) | ||
480 | *src = readl(chan->regs + PL080_CH_SRC_ADDR); | ||
481 | |||
482 | if (dst != NULL) | ||
483 | *dst = readl(chan->regs + PL080_CH_DST_ADDR); | ||
484 | |||
485 | return 0; | ||
486 | } | ||
487 | EXPORT_SYMBOL(s3c2410_dma_getposition); | ||
488 | |||
489 | /* s3c2410_request_dma | ||
490 | * | ||
491 | * get control of an dma channel | ||
492 | */ | ||
493 | |||
494 | int s3c2410_dma_request(enum dma_ch channel, | ||
495 | struct s3c2410_dma_client *client, | ||
496 | void *dev) | ||
497 | { | ||
498 | struct s3c2410_dma_chan *chan; | ||
499 | unsigned long flags; | ||
500 | |||
501 | pr_debug("dma%d: s3c2410_request_dma: client=%s, dev=%p\n", | ||
502 | channel, client->name, dev); | ||
503 | |||
504 | local_irq_save(flags); | ||
505 | |||
506 | chan = s3c64xx_dma_map_channel(channel); | ||
507 | if (chan == NULL) { | ||
508 | local_irq_restore(flags); | ||
509 | return -EBUSY; | ||
510 | } | ||
511 | |||
512 | dbg_showchan(chan); | ||
513 | |||
514 | chan->client = client; | ||
515 | chan->in_use = 1; | ||
516 | chan->peripheral = channel; | ||
517 | chan->flags = 0; | ||
518 | |||
519 | local_irq_restore(flags); | ||
520 | |||
521 | /* need to setup */ | ||
522 | |||
523 | pr_debug("%s: channel initialised, %p\n", __func__, chan); | ||
524 | |||
525 | return chan->number | DMACH_LOW_LEVEL; | ||
526 | } | ||
527 | |||
528 | EXPORT_SYMBOL(s3c2410_dma_request); | ||
529 | |||
530 | /* s3c2410_dma_free | ||
531 | * | ||
532 | * release the given channel back to the system, will stop and flush | ||
533 | * any outstanding transfers, and ensure the channel is ready for the | ||
534 | * next claimant. | ||
535 | * | ||
536 | * Note, although a warning is currently printed if the freeing client | ||
537 | * info is not the same as the registrant's client info, the free is still | ||
538 | * allowed to go through. | ||
539 | */ | ||
540 | |||
541 | int s3c2410_dma_free(enum dma_ch channel, struct s3c2410_dma_client *client) | ||
542 | { | ||
543 | struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); | ||
544 | unsigned long flags; | ||
545 | |||
546 | if (chan == NULL) | ||
547 | return -EINVAL; | ||
548 | |||
549 | local_irq_save(flags); | ||
550 | |||
551 | if (chan->client != client) { | ||
552 | printk(KERN_WARNING "dma%d: possible free from different client (channel %p, passed %p)\n", | ||
553 | channel, chan->client, client); | ||
554 | } | ||
555 | |||
556 | /* sort out stopping and freeing the channel */ | ||
557 | |||
558 | |||
559 | chan->client = NULL; | ||
560 | chan->in_use = 0; | ||
561 | |||
562 | if (!(channel & DMACH_LOW_LEVEL)) | ||
563 | s3c_dma_chan_map[channel] = NULL; | ||
564 | |||
565 | local_irq_restore(flags); | ||
566 | |||
567 | return 0; | ||
568 | } | ||
569 | |||
570 | EXPORT_SYMBOL(s3c2410_dma_free); | ||
571 | |||
572 | static irqreturn_t s3c64xx_dma_irq(int irq, void *pw) | ||
573 | { | ||
574 | struct s3c64xx_dmac *dmac = pw; | ||
575 | struct s3c2410_dma_chan *chan; | ||
576 | enum s3c2410_dma_buffresult res; | ||
577 | u32 tcstat, errstat; | ||
578 | u32 bit; | ||
579 | int offs; | ||
580 | |||
581 | tcstat = readl(dmac->regs + PL080_TC_STATUS); | ||
582 | errstat = readl(dmac->regs + PL080_ERR_STATUS); | ||
583 | |||
584 | for (offs = 0, bit = 1; offs < 8; offs++, bit <<= 1) { | ||
585 | struct s3c64xx_dma_buff *buff; | ||
586 | |||
587 | if (!(errstat & bit) && !(tcstat & bit)) | ||
588 | continue; | ||
589 | |||
590 | chan = dmac->channels + offs; | ||
591 | res = S3C2410_RES_ERR; | ||
592 | |||
593 | if (tcstat & bit) { | ||
594 | writel(bit, dmac->regs + PL080_TC_CLEAR); | ||
595 | res = S3C2410_RES_OK; | ||
596 | } | ||
597 | |||
598 | if (errstat & bit) | ||
599 | writel(bit, dmac->regs + PL080_ERR_CLEAR); | ||
600 | |||
601 | /* 'next' points to the buffer that is next to the | ||
602 | * currently active buffer. | ||
603 | * For CIRCULAR queues, 'next' will be same as 'curr' | ||
604 | * when 'end' is the active buffer. | ||
605 | */ | ||
606 | buff = chan->curr; | ||
607 | while (buff && buff != chan->next | ||
608 | && buff->next != chan->next) | ||
609 | buff = buff->next; | ||
610 | |||
611 | if (!buff) | ||
612 | BUG(); | ||
613 | |||
614 | if (buff == chan->next) | ||
615 | buff = chan->end; | ||
616 | |||
617 | s3c64xx_dma_bufffdone(chan, buff, res); | ||
618 | |||
619 | /* Free the node and update curr, if non-circular queue */ | ||
620 | if (!(chan->flags & S3C2410_DMAF_CIRCULAR)) { | ||
621 | chan->curr = buff->next; | ||
622 | s3c64xx_dma_freebuff(buff); | ||
623 | } | ||
624 | |||
625 | /* Update 'next' */ | ||
626 | buff = chan->next; | ||
627 | if (chan->next == chan->end) { | ||
628 | chan->next = chan->curr; | ||
629 | if (!(chan->flags & S3C2410_DMAF_CIRCULAR)) | ||
630 | chan->end = NULL; | ||
631 | } else { | ||
632 | chan->next = buff->next; | ||
633 | } | ||
634 | } | ||
635 | |||
636 | return IRQ_HANDLED; | ||
637 | } | ||
638 | |||
639 | static struct bus_type dma_subsys = { | ||
640 | .name = "s3c64xx-dma", | ||
641 | .dev_name = "s3c64xx-dma", | ||
642 | }; | ||
643 | |||
644 | static int s3c64xx_dma_init1(int chno, enum dma_ch chbase, | ||
645 | int irq, unsigned int base) | ||
646 | { | ||
647 | struct s3c2410_dma_chan *chptr = &s3c2410_chans[chno]; | ||
648 | struct s3c64xx_dmac *dmac; | ||
649 | char clkname[16]; | ||
650 | void __iomem *regs; | ||
651 | void __iomem *regptr; | ||
652 | int err, ch; | ||
653 | |||
654 | dmac = kzalloc(sizeof(struct s3c64xx_dmac), GFP_KERNEL); | ||
655 | if (!dmac) { | ||
656 | printk(KERN_ERR "%s: failed to alloc mem\n", __func__); | ||
657 | return -ENOMEM; | ||
658 | } | ||
659 | |||
660 | dmac->dev.id = chno / 8; | ||
661 | dmac->dev.bus = &dma_subsys; | ||
662 | |||
663 | err = device_register(&dmac->dev); | ||
664 | if (err) { | ||
665 | printk(KERN_ERR "%s: failed to register device\n", __func__); | ||
666 | goto err_alloc; | ||
667 | } | ||
668 | |||
669 | regs = ioremap(base, 0x200); | ||
670 | if (!regs) { | ||
671 | printk(KERN_ERR "%s: failed to ioremap()\n", __func__); | ||
672 | err = -ENXIO; | ||
673 | goto err_dev; | ||
674 | } | ||
675 | |||
676 | snprintf(clkname, sizeof(clkname), "dma%d", dmac->dev.id); | ||
677 | |||
678 | dmac->clk = clk_get(NULL, clkname); | ||
679 | if (IS_ERR(dmac->clk)) { | ||
680 | printk(KERN_ERR "%s: failed to get clock %s\n", __func__, clkname); | ||
681 | err = PTR_ERR(dmac->clk); | ||
682 | goto err_map; | ||
683 | } | ||
684 | |||
685 | clk_prepare_enable(dmac->clk); | ||
686 | |||
687 | dmac->regs = regs; | ||
688 | dmac->chanbase = chbase; | ||
689 | dmac->channels = chptr; | ||
690 | |||
691 | err = request_irq(irq, s3c64xx_dma_irq, 0, "DMA", dmac); | ||
692 | if (err < 0) { | ||
693 | printk(KERN_ERR "%s: failed to get irq\n", __func__); | ||
694 | goto err_clk; | ||
695 | } | ||
696 | |||
697 | regptr = regs + PL080_Cx_BASE(0); | ||
698 | |||
699 | for (ch = 0; ch < 8; ch++, chptr++) { | ||
700 | pr_debug("%s: registering DMA %d (%p)\n", | ||
701 | __func__, chno + ch, regptr); | ||
702 | |||
703 | chptr->bit = 1 << ch; | ||
704 | chptr->number = chno + ch; | ||
705 | chptr->dmac = dmac; | ||
706 | chptr->regs = regptr; | ||
707 | regptr += PL080_Cx_STRIDE; | ||
708 | } | ||
709 | |||
710 | /* for the moment, permanently enable the controller */ | ||
711 | writel(PL080_CONFIG_ENABLE, regs + PL080_CONFIG); | ||
712 | |||
713 | printk(KERN_INFO "PL080: IRQ %d, at %p, channels %d..%d\n", | ||
714 | irq, regs, chno, chno+8); | ||
715 | |||
716 | return 0; | ||
717 | |||
718 | err_clk: | ||
719 | clk_disable_unprepare(dmac->clk); | ||
720 | clk_put(dmac->clk); | ||
721 | err_map: | ||
722 | iounmap(regs); | ||
723 | err_dev: | ||
724 | device_unregister(&dmac->dev); | ||
725 | err_alloc: | ||
726 | kfree(dmac); | ||
727 | return err; | ||
728 | } | ||
729 | |||
730 | static int __init s3c64xx_dma_init(void) | ||
731 | { | ||
732 | int ret; | ||
733 | |||
734 | /* This driver is not supported when booting with device tree. */ | ||
735 | if (of_have_populated_dt()) | ||
736 | return -ENODEV; | ||
737 | |||
738 | printk(KERN_INFO "%s: Registering DMA channels\n", __func__); | ||
739 | |||
740 | dma_pool = dma_pool_create("DMA-LLI", NULL, sizeof(struct pl080s_lli), 16, 0); | ||
741 | if (!dma_pool) { | ||
742 | printk(KERN_ERR "%s: failed to create pool\n", __func__); | ||
743 | return -ENOMEM; | ||
744 | } | ||
745 | |||
746 | ret = subsys_system_register(&dma_subsys, NULL); | ||
747 | if (ret) { | ||
748 | printk(KERN_ERR "%s: failed to create subsys\n", __func__); | ||
749 | return -ENOMEM; | ||
750 | } | ||
751 | |||
752 | /* Set all DMA configuration to be DMA, not SDMA */ | ||
753 | writel(0xffffff, S3C64XX_SDMA_SEL); | ||
754 | |||
755 | /* Register standard DMA controllers */ | ||
756 | s3c64xx_dma_init1(0, DMACH_UART0, IRQ_DMA0, 0x75000000); | ||
757 | s3c64xx_dma_init1(8, DMACH_PCM1_TX, IRQ_DMA1, 0x75100000); | ||
758 | |||
759 | return 0; | ||
760 | } | ||
761 | |||
762 | arch_initcall(s3c64xx_dma_init); | ||
diff --git a/arch/arm/mach-s3c64xx/include/mach/dma.h b/arch/arm/mach-s3c64xx/include/mach/dma.h index fe1a98cf0e4c..059b1fc85037 100644 --- a/arch/arm/mach-s3c64xx/include/mach/dma.h +++ b/arch/arm/mach-s3c64xx/include/mach/dma.h | |||
@@ -11,51 +11,48 @@ | |||
11 | #ifndef __ASM_ARCH_DMA_H | 11 | #ifndef __ASM_ARCH_DMA_H |
12 | #define __ASM_ARCH_DMA_H __FILE__ | 12 | #define __ASM_ARCH_DMA_H __FILE__ |
13 | 13 | ||
14 | #define S3C_DMA_CHANNELS (16) | 14 | #define S3C64XX_DMA_CHAN(name) ((unsigned long)(name)) |
15 | |||
16 | /* DMA0/SDMA0 */ | ||
17 | #define DMACH_UART0 S3C64XX_DMA_CHAN("uart0_tx") | ||
18 | #define DMACH_UART0_SRC2 S3C64XX_DMA_CHAN("uart0_rx") | ||
19 | #define DMACH_UART1 S3C64XX_DMA_CHAN("uart1_tx") | ||
20 | #define DMACH_UART1_SRC2 S3C64XX_DMA_CHAN("uart1_rx") | ||
21 | #define DMACH_UART2 S3C64XX_DMA_CHAN("uart2_tx") | ||
22 | #define DMACH_UART2_SRC2 S3C64XX_DMA_CHAN("uart2_rx") | ||
23 | #define DMACH_UART3 S3C64XX_DMA_CHAN("uart3_tx") | ||
24 | #define DMACH_UART3_SRC2 S3C64XX_DMA_CHAN("uart3_rx") | ||
25 | #define DMACH_PCM0_TX S3C64XX_DMA_CHAN("pcm0_tx") | ||
26 | #define DMACH_PCM0_RX S3C64XX_DMA_CHAN("pcm0_rx") | ||
27 | #define DMACH_I2S0_OUT S3C64XX_DMA_CHAN("i2s0_tx") | ||
28 | #define DMACH_I2S0_IN S3C64XX_DMA_CHAN("i2s0_rx") | ||
29 | #define DMACH_SPI0_TX S3C64XX_DMA_CHAN("spi0_tx") | ||
30 | #define DMACH_SPI0_RX S3C64XX_DMA_CHAN("spi0_rx") | ||
31 | #define DMACH_HSI_I2SV40_TX S3C64XX_DMA_CHAN("i2s2_tx") | ||
32 | #define DMACH_HSI_I2SV40_RX S3C64XX_DMA_CHAN("i2s2_rx") | ||
33 | |||
34 | /* DMA1/SDMA1 */ | ||
35 | #define DMACH_PCM1_TX S3C64XX_DMA_CHAN("pcm1_tx") | ||
36 | #define DMACH_PCM1_RX S3C64XX_DMA_CHAN("pcm1_rx") | ||
37 | #define DMACH_I2S1_OUT S3C64XX_DMA_CHAN("i2s1_tx") | ||
38 | #define DMACH_I2S1_IN S3C64XX_DMA_CHAN("i2s1_rx") | ||
39 | #define DMACH_SPI1_TX S3C64XX_DMA_CHAN("spi1_tx") | ||
40 | #define DMACH_SPI1_RX S3C64XX_DMA_CHAN("spi1_rx") | ||
41 | #define DMACH_AC97_PCMOUT S3C64XX_DMA_CHAN("ac97_out") | ||
42 | #define DMACH_AC97_PCMIN S3C64XX_DMA_CHAN("ac97_in") | ||
43 | #define DMACH_AC97_MICIN S3C64XX_DMA_CHAN("ac97_mic") | ||
44 | #define DMACH_PWM S3C64XX_DMA_CHAN("pwm") | ||
45 | #define DMACH_IRDA S3C64XX_DMA_CHAN("irda") | ||
46 | #define DMACH_EXTERNAL S3C64XX_DMA_CHAN("external") | ||
47 | #define DMACH_SECURITY_RX S3C64XX_DMA_CHAN("sec_rx") | ||
48 | #define DMACH_SECURITY_TX S3C64XX_DMA_CHAN("sec_tx") | ||
15 | 49 | ||
16 | /* see mach-s3c2410/dma.h for notes on dma channel numbers */ | ||
17 | |||
18 | /* Note, for the S3C64XX architecture we keep the DMACH_ | ||
19 | * defines in the order they are allocated to [S]DMA0/[S]DMA1 | ||
20 | * so that is easy to do DHACH_ -> DMA controller conversion | ||
21 | */ | ||
22 | enum dma_ch { | 50 | enum dma_ch { |
23 | /* DMA0/SDMA0 */ | 51 | DMACH_MAX = 32 |
24 | DMACH_UART0 = 0, | 52 | }; |
25 | DMACH_UART0_SRC2, | ||
26 | DMACH_UART1, | ||
27 | DMACH_UART1_SRC2, | ||
28 | DMACH_UART2, | ||
29 | DMACH_UART2_SRC2, | ||
30 | DMACH_UART3, | ||
31 | DMACH_UART3_SRC2, | ||
32 | DMACH_PCM0_TX, | ||
33 | DMACH_PCM0_RX, | ||
34 | DMACH_I2S0_OUT, | ||
35 | DMACH_I2S0_IN, | ||
36 | DMACH_SPI0_TX, | ||
37 | DMACH_SPI0_RX, | ||
38 | DMACH_HSI_I2SV40_TX, | ||
39 | DMACH_HSI_I2SV40_RX, | ||
40 | 53 | ||
41 | /* DMA1/SDMA1 */ | 54 | struct s3c2410_dma_client { |
42 | DMACH_PCM1_TX = 16, | 55 | char *name; |
43 | DMACH_PCM1_RX, | ||
44 | DMACH_I2S1_OUT, | ||
45 | DMACH_I2S1_IN, | ||
46 | DMACH_SPI1_TX, | ||
47 | DMACH_SPI1_RX, | ||
48 | DMACH_AC97_PCMOUT, | ||
49 | DMACH_AC97_PCMIN, | ||
50 | DMACH_AC97_MICIN, | ||
51 | DMACH_PWM, | ||
52 | DMACH_IRDA, | ||
53 | DMACH_EXTERNAL, | ||
54 | DMACH_RES1, | ||
55 | DMACH_RES2, | ||
56 | DMACH_SECURITY_RX, /* SDMA1 only */ | ||
57 | DMACH_SECURITY_TX, /* SDMA1 only */ | ||
58 | DMACH_MAX /* the end */ | ||
59 | }; | 56 | }; |
60 | 57 | ||
61 | static inline bool samsung_dma_has_circular(void) | 58 | static inline bool samsung_dma_has_circular(void) |
@@ -65,67 +62,10 @@ static inline bool samsung_dma_has_circular(void) | |||
65 | 62 | ||
66 | static inline bool samsung_dma_is_dmadev(void) | 63 | static inline bool samsung_dma_is_dmadev(void) |
67 | { | 64 | { |
68 | return false; | 65 | return true; |
69 | } | 66 | } |
70 | #define S3C2410_DMAF_CIRCULAR (1 << 0) | ||
71 | |||
72 | #include <plat/dma.h> | ||
73 | |||
74 | #define DMACH_LOW_LEVEL (1<<28) /* use this to specifiy hardware ch no */ | ||
75 | |||
76 | struct s3c64xx_dma_buff; | ||
77 | |||
78 | /** s3c64xx_dma_buff - S3C64XX DMA buffer descriptor | ||
79 | * @next: Pointer to next buffer in queue or ring. | ||
80 | * @pw: Client provided identifier | ||
81 | * @lli: Pointer to hardware descriptor this buffer is associated with. | ||
82 | * @lli_dma: Hardare address of the descriptor. | ||
83 | */ | ||
84 | struct s3c64xx_dma_buff { | ||
85 | struct s3c64xx_dma_buff *next; | ||
86 | |||
87 | void *pw; | ||
88 | struct pl080s_lli *lli; | ||
89 | dma_addr_t lli_dma; | ||
90 | }; | ||
91 | |||
92 | struct s3c64xx_dmac; | ||
93 | |||
94 | struct s3c2410_dma_chan { | ||
95 | unsigned char number; /* number of this dma channel */ | ||
96 | unsigned char in_use; /* channel allocated */ | ||
97 | unsigned char bit; /* bit for enable/disable/etc */ | ||
98 | unsigned char hw_width; | ||
99 | unsigned char peripheral; | ||
100 | |||
101 | unsigned int flags; | ||
102 | enum dma_data_direction source; | ||
103 | |||
104 | |||
105 | dma_addr_t dev_addr; | ||
106 | |||
107 | struct s3c2410_dma_client *client; | ||
108 | struct s3c64xx_dmac *dmac; /* pointer to controller */ | ||
109 | |||
110 | void __iomem *regs; | ||
111 | |||
112 | /* cdriver callbacks */ | ||
113 | s3c2410_dma_cbfn_t callback_fn; /* buffer done callback */ | ||
114 | s3c2410_dma_opfn_t op_fn; /* channel op callback */ | ||
115 | |||
116 | /* buffer list and information */ | ||
117 | struct s3c64xx_dma_buff *curr; /* current dma buffer */ | ||
118 | struct s3c64xx_dma_buff *next; /* next buffer to load */ | ||
119 | struct s3c64xx_dma_buff *end; /* end of queue */ | ||
120 | |||
121 | /* note, when channel is running in circular mode, curr is the | ||
122 | * first buffer enqueued, end is the last and curr is where the | ||
123 | * last buffer-done event is set-at. The buffers are not freed | ||
124 | * and the last buffer hardware descriptor points back to the | ||
125 | * first. | ||
126 | */ | ||
127 | }; | ||
128 | 67 | ||
129 | #include <plat/dma-core.h> | 68 | #include <linux/amba/pl08x.h> |
69 | #include <plat/dma-ops.h> | ||
130 | 70 | ||
131 | #endif /* __ASM_ARCH_IRQ_H */ | 71 | #endif /* __ASM_ARCH_IRQ_H */ |
diff --git a/arch/arm/mach-s3c64xx/mach-s3c64xx-dt.c b/arch/arm/mach-s3c64xx/mach-s3c64xx-dt.c index 7eb9a10fc1af..2fddf38192df 100644 --- a/arch/arm/mach-s3c64xx/mach-s3c64xx-dt.c +++ b/arch/arm/mach-s3c64xx/mach-s3c64xx-dt.c | |||
@@ -8,8 +8,6 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/clk-provider.h> | ||
12 | #include <linux/irqchip.h> | ||
13 | #include <linux/of_platform.h> | 11 | #include <linux/of_platform.h> |
14 | 12 | ||
15 | #include <asm/mach/arch.h> | 13 | #include <asm/mach/arch.h> |
@@ -48,15 +46,9 @@ static void __init s3c64xx_dt_map_io(void) | |||
48 | panic("SoC is not S3C64xx!"); | 46 | panic("SoC is not S3C64xx!"); |
49 | } | 47 | } |
50 | 48 | ||
51 | static void __init s3c64xx_dt_init_irq(void) | ||
52 | { | ||
53 | of_clk_init(NULL); | ||
54 | samsung_wdt_reset_of_init(); | ||
55 | irqchip_init(); | ||
56 | }; | ||
57 | |||
58 | static void __init s3c64xx_dt_init_machine(void) | 49 | static void __init s3c64xx_dt_init_machine(void) |
59 | { | 50 | { |
51 | samsung_wdt_reset_of_init(); | ||
60 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | 52 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
61 | } | 53 | } |
62 | 54 | ||
@@ -79,7 +71,6 @@ DT_MACHINE_START(S3C6400_DT, "Samsung S3C64xx (Flattened Device Tree)") | |||
79 | /* Maintainer: Tomasz Figa <tomasz.figa@gmail.com> */ | 71 | /* Maintainer: Tomasz Figa <tomasz.figa@gmail.com> */ |
80 | .dt_compat = s3c64xx_dt_compat, | 72 | .dt_compat = s3c64xx_dt_compat, |
81 | .map_io = s3c64xx_dt_map_io, | 73 | .map_io = s3c64xx_dt_map_io, |
82 | .init_irq = s3c64xx_dt_init_irq, | ||
83 | .init_machine = s3c64xx_dt_init_machine, | 74 | .init_machine = s3c64xx_dt_init_machine, |
84 | .restart = s3c64xx_dt_restart, | 75 | .restart = s3c64xx_dt_restart, |
85 | MACHINE_END | 76 | MACHINE_END |
diff --git a/arch/arm/mach-s3c64xx/pl080.c b/arch/arm/mach-s3c64xx/pl080.c new file mode 100644 index 000000000000..901a984bddc2 --- /dev/null +++ b/arch/arm/mach-s3c64xx/pl080.c | |||
@@ -0,0 +1,244 @@ | |||
1 | /* | ||
2 | * Samsung's S3C64XX generic DMA support using amba-pl08x driver. | ||
3 | * | ||
4 | * Copyright (c) 2013 Tomasz Figa <tomasz.figa@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/amba/bus.h> | ||
13 | #include <linux/amba/pl080.h> | ||
14 | #include <linux/amba/pl08x.h> | ||
15 | #include <linux/of.h> | ||
16 | |||
17 | #include <mach/irqs.h> | ||
18 | #include <mach/map.h> | ||
19 | |||
20 | #include "regs-sys.h" | ||
21 | |||
22 | static int pl08x_get_xfer_signal(const struct pl08x_channel_data *cd) | ||
23 | { | ||
24 | return cd->min_signal; | ||
25 | } | ||
26 | |||
27 | static void pl08x_put_xfer_signal(const struct pl08x_channel_data *cd, int ch) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | /* | ||
32 | * DMA0 | ||
33 | */ | ||
34 | |||
35 | static struct pl08x_channel_data s3c64xx_dma0_info[] = { | ||
36 | { | ||
37 | .bus_id = "uart0_tx", | ||
38 | .min_signal = 0, | ||
39 | .max_signal = 0, | ||
40 | .periph_buses = PL08X_AHB2, | ||
41 | }, { | ||
42 | .bus_id = "uart0_rx", | ||
43 | .min_signal = 1, | ||
44 | .max_signal = 1, | ||
45 | .periph_buses = PL08X_AHB2, | ||
46 | }, { | ||
47 | .bus_id = "uart1_tx", | ||
48 | .min_signal = 2, | ||
49 | .max_signal = 2, | ||
50 | .periph_buses = PL08X_AHB2, | ||
51 | }, { | ||
52 | .bus_id = "uart1_rx", | ||
53 | .min_signal = 3, | ||
54 | .max_signal = 3, | ||
55 | .periph_buses = PL08X_AHB2, | ||
56 | }, { | ||
57 | .bus_id = "uart2_tx", | ||
58 | .min_signal = 4, | ||
59 | .max_signal = 4, | ||
60 | .periph_buses = PL08X_AHB2, | ||
61 | }, { | ||
62 | .bus_id = "uart2_rx", | ||
63 | .min_signal = 5, | ||
64 | .max_signal = 5, | ||
65 | .periph_buses = PL08X_AHB2, | ||
66 | }, { | ||
67 | .bus_id = "uart3_tx", | ||
68 | .min_signal = 6, | ||
69 | .max_signal = 6, | ||
70 | .periph_buses = PL08X_AHB2, | ||
71 | }, { | ||
72 | .bus_id = "uart3_rx", | ||
73 | .min_signal = 7, | ||
74 | .max_signal = 7, | ||
75 | .periph_buses = PL08X_AHB2, | ||
76 | }, { | ||
77 | .bus_id = "pcm0_tx", | ||
78 | .min_signal = 8, | ||
79 | .max_signal = 8, | ||
80 | .periph_buses = PL08X_AHB2, | ||
81 | }, { | ||
82 | .bus_id = "pcm0_rx", | ||
83 | .min_signal = 9, | ||
84 | .max_signal = 9, | ||
85 | .periph_buses = PL08X_AHB2, | ||
86 | }, { | ||
87 | .bus_id = "i2s0_tx", | ||
88 | .min_signal = 10, | ||
89 | .max_signal = 10, | ||
90 | .periph_buses = PL08X_AHB2, | ||
91 | }, { | ||
92 | .bus_id = "i2s0_rx", | ||
93 | .min_signal = 11, | ||
94 | .max_signal = 11, | ||
95 | .periph_buses = PL08X_AHB2, | ||
96 | }, { | ||
97 | .bus_id = "spi0_tx", | ||
98 | .min_signal = 12, | ||
99 | .max_signal = 12, | ||
100 | .periph_buses = PL08X_AHB2, | ||
101 | }, { | ||
102 | .bus_id = "spi0_rx", | ||
103 | .min_signal = 13, | ||
104 | .max_signal = 13, | ||
105 | .periph_buses = PL08X_AHB2, | ||
106 | }, { | ||
107 | .bus_id = "i2s2_tx", | ||
108 | .min_signal = 14, | ||
109 | .max_signal = 14, | ||
110 | .periph_buses = PL08X_AHB2, | ||
111 | }, { | ||
112 | .bus_id = "i2s2_rx", | ||
113 | .min_signal = 15, | ||
114 | .max_signal = 15, | ||
115 | .periph_buses = PL08X_AHB2, | ||
116 | } | ||
117 | }; | ||
118 | |||
119 | struct pl08x_platform_data s3c64xx_dma0_plat_data = { | ||
120 | .memcpy_channel = { | ||
121 | .bus_id = "memcpy", | ||
122 | .cctl_memcpy = | ||
123 | (PL080_BSIZE_4 << PL080_CONTROL_SB_SIZE_SHIFT | | ||
124 | PL080_BSIZE_4 << PL080_CONTROL_DB_SIZE_SHIFT | | ||
125 | PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT | | ||
126 | PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT | | ||
127 | PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE | | ||
128 | PL080_CONTROL_PROT_SYS), | ||
129 | }, | ||
130 | .lli_buses = PL08X_AHB1, | ||
131 | .mem_buses = PL08X_AHB1, | ||
132 | .get_xfer_signal = pl08x_get_xfer_signal, | ||
133 | .put_xfer_signal = pl08x_put_xfer_signal, | ||
134 | .slave_channels = s3c64xx_dma0_info, | ||
135 | .num_slave_channels = ARRAY_SIZE(s3c64xx_dma0_info), | ||
136 | }; | ||
137 | |||
138 | static AMBA_AHB_DEVICE(s3c64xx_dma0, "dma-pl080s.0", 0, | ||
139 | 0x75000000, {IRQ_DMA0}, &s3c64xx_dma0_plat_data); | ||
140 | |||
141 | /* | ||
142 | * DMA1 | ||
143 | */ | ||
144 | |||
145 | static struct pl08x_channel_data s3c64xx_dma1_info[] = { | ||
146 | { | ||
147 | .bus_id = "pcm1_tx", | ||
148 | .min_signal = 0, | ||
149 | .max_signal = 0, | ||
150 | .periph_buses = PL08X_AHB2, | ||
151 | }, { | ||
152 | .bus_id = "pcm1_rx", | ||
153 | .min_signal = 1, | ||
154 | .max_signal = 1, | ||
155 | .periph_buses = PL08X_AHB2, | ||
156 | }, { | ||
157 | .bus_id = "i2s1_tx", | ||
158 | .min_signal = 2, | ||
159 | .max_signal = 2, | ||
160 | .periph_buses = PL08X_AHB2, | ||
161 | }, { | ||
162 | .bus_id = "i2s1_rx", | ||
163 | .min_signal = 3, | ||
164 | .max_signal = 3, | ||
165 | .periph_buses = PL08X_AHB2, | ||
166 | }, { | ||
167 | .bus_id = "spi1_tx", | ||
168 | .min_signal = 4, | ||
169 | .max_signal = 4, | ||
170 | .periph_buses = PL08X_AHB2, | ||
171 | }, { | ||
172 | .bus_id = "spi1_rx", | ||
173 | .min_signal = 5, | ||
174 | .max_signal = 5, | ||
175 | .periph_buses = PL08X_AHB2, | ||
176 | }, { | ||
177 | .bus_id = "ac97_out", | ||
178 | .min_signal = 6, | ||
179 | .max_signal = 6, | ||
180 | .periph_buses = PL08X_AHB2, | ||
181 | }, { | ||
182 | .bus_id = "ac97_in", | ||
183 | .min_signal = 7, | ||
184 | .max_signal = 7, | ||
185 | .periph_buses = PL08X_AHB2, | ||
186 | }, { | ||
187 | .bus_id = "ac97_mic", | ||
188 | .min_signal = 8, | ||
189 | .max_signal = 8, | ||
190 | .periph_buses = PL08X_AHB2, | ||
191 | }, { | ||
192 | .bus_id = "pwm", | ||
193 | .min_signal = 9, | ||
194 | .max_signal = 9, | ||
195 | .periph_buses = PL08X_AHB2, | ||
196 | }, { | ||
197 | .bus_id = "irda", | ||
198 | .min_signal = 10, | ||
199 | .max_signal = 10, | ||
200 | .periph_buses = PL08X_AHB2, | ||
201 | }, { | ||
202 | .bus_id = "external", | ||
203 | .min_signal = 11, | ||
204 | .max_signal = 11, | ||
205 | .periph_buses = PL08X_AHB2, | ||
206 | }, | ||
207 | }; | ||
208 | |||
209 | struct pl08x_platform_data s3c64xx_dma1_plat_data = { | ||
210 | .memcpy_channel = { | ||
211 | .bus_id = "memcpy", | ||
212 | .cctl_memcpy = | ||
213 | (PL080_BSIZE_4 << PL080_CONTROL_SB_SIZE_SHIFT | | ||
214 | PL080_BSIZE_4 << PL080_CONTROL_DB_SIZE_SHIFT | | ||
215 | PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT | | ||
216 | PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT | | ||
217 | PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE | | ||
218 | PL080_CONTROL_PROT_SYS), | ||
219 | }, | ||
220 | .lli_buses = PL08X_AHB1, | ||
221 | .mem_buses = PL08X_AHB1, | ||
222 | .get_xfer_signal = pl08x_get_xfer_signal, | ||
223 | .put_xfer_signal = pl08x_put_xfer_signal, | ||
224 | .slave_channels = s3c64xx_dma1_info, | ||
225 | .num_slave_channels = ARRAY_SIZE(s3c64xx_dma1_info), | ||
226 | }; | ||
227 | |||
228 | static AMBA_AHB_DEVICE(s3c64xx_dma1, "dma-pl080s.1", 0, | ||
229 | 0x75100000, {IRQ_DMA1}, &s3c64xx_dma1_plat_data); | ||
230 | |||
231 | static int __init s3c64xx_pl080_init(void) | ||
232 | { | ||
233 | /* Set all DMA configuration to be DMA, not SDMA */ | ||
234 | writel(0xffffff, S3C64XX_SDMA_SEL); | ||
235 | |||
236 | if (of_have_populated_dt()) | ||
237 | return 0; | ||
238 | |||
239 | amba_device_register(&s3c64xx_dma0_device, &iomem_resource); | ||
240 | amba_device_register(&s3c64xx_dma1_device, &iomem_resource); | ||
241 | |||
242 | return 0; | ||
243 | } | ||
244 | arch_initcall(s3c64xx_pl080_init); | ||
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c index 958e3cbf0ac2..c18689123023 100644 --- a/arch/arm/mach-shmobile/board-armadillo800eva.c +++ b/arch/arm/mach-shmobile/board-armadillo800eva.c | |||
@@ -614,6 +614,11 @@ static struct regulator_consumer_supply fixed3v3_power_consumers[] = { | |||
614 | REGULATOR_SUPPLY("vqmmc", "sh_mmcif"), | 614 | REGULATOR_SUPPLY("vqmmc", "sh_mmcif"), |
615 | }; | 615 | }; |
616 | 616 | ||
617 | /* Fixed 3.3V regulator used by LCD backlight */ | ||
618 | static struct regulator_consumer_supply fixed5v0_power_consumers[] = { | ||
619 | REGULATOR_SUPPLY("power", "pwm-backlight.0"), | ||
620 | }; | ||
621 | |||
617 | /* Fixed 3.3V regulator to be used by SDHI0 */ | 622 | /* Fixed 3.3V regulator to be used by SDHI0 */ |
618 | static struct regulator_consumer_supply vcc_sdhi0_consumers[] = { | 623 | static struct regulator_consumer_supply vcc_sdhi0_consumers[] = { |
619 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"), | 624 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"), |
@@ -1196,6 +1201,8 @@ static void __init eva_init(void) | |||
1196 | 1201 | ||
1197 | regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers, | 1202 | regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers, |
1198 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); | 1203 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); |
1204 | regulator_register_always_on(3, "fixed-5.0V", fixed5v0_power_consumers, | ||
1205 | ARRAY_SIZE(fixed5v0_power_consumers), 5000000); | ||
1199 | 1206 | ||
1200 | pinctrl_register_mappings(eva_pinctrl_map, ARRAY_SIZE(eva_pinctrl_map)); | 1207 | pinctrl_register_mappings(eva_pinctrl_map, ARRAY_SIZE(eva_pinctrl_map)); |
1201 | pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup)); | 1208 | pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup)); |
diff --git a/arch/arm/mach-shmobile/board-bockw.c b/arch/arm/mach-shmobile/board-bockw.c index 38611526fe9a..3c4995aebd22 100644 --- a/arch/arm/mach-shmobile/board-bockw.c +++ b/arch/arm/mach-shmobile/board-bockw.c | |||
@@ -679,7 +679,7 @@ static void __init bockw_init(void) | |||
679 | .id = i, | 679 | .id = i, |
680 | .data = &rsnd_card_info[i], | 680 | .data = &rsnd_card_info[i], |
681 | .size_data = sizeof(struct asoc_simple_card_info), | 681 | .size_data = sizeof(struct asoc_simple_card_info), |
682 | .dma_mask = ~0, | 682 | .dma_mask = DMA_BIT_MASK(32), |
683 | }; | 683 | }; |
684 | 684 | ||
685 | platform_device_register_full(&cardinfo); | 685 | platform_device_register_full(&cardinfo); |
diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index a8d3ce646fb9..e0406fd37390 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c | |||
@@ -245,7 +245,9 @@ static void __init lager_init(void) | |||
245 | { | 245 | { |
246 | lager_add_standard_devices(); | 246 | lager_add_standard_devices(); |
247 | 247 | ||
248 | phy_register_fixup_for_id("r8a7790-ether-ff:01", lager_ksz8041_fixup); | 248 | if (IS_ENABLED(CONFIG_PHYLIB)) |
249 | phy_register_fixup_for_id("r8a7790-ether-ff:01", | ||
250 | lager_ksz8041_fixup); | ||
249 | } | 251 | } |
250 | 252 | ||
251 | static const char * const lager_boards_compat_dt[] __initconst = { | 253 | static const char * const lager_boards_compat_dt[] __initconst = { |
diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c index 99a3590f0349..ac07e871f6a7 100644 --- a/arch/arm/plat-samsung/devs.c +++ b/arch/arm/plat-samsung/devs.c | |||
@@ -1468,6 +1468,8 @@ void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, | |||
1468 | pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio; | 1468 | pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio; |
1469 | #if defined(CONFIG_PL330_DMA) | 1469 | #if defined(CONFIG_PL330_DMA) |
1470 | pd.filter = pl330_filter; | 1470 | pd.filter = pl330_filter; |
1471 | #elif defined(CONFIG_S3C64XX_PL080) | ||
1472 | pd.filter = pl08x_filter_id; | ||
1471 | #elif defined(CONFIG_S3C24XX_DMAC) | 1473 | #elif defined(CONFIG_S3C24XX_DMAC) |
1472 | pd.filter = s3c24xx_dma_filter; | 1474 | pd.filter = s3c24xx_dma_filter; |
1473 | #endif | 1475 | #endif |
@@ -1509,8 +1511,10 @@ void __init s3c64xx_spi1_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, | |||
1509 | pd.num_cs = num_cs; | 1511 | pd.num_cs = num_cs; |
1510 | pd.src_clk_nr = src_clk_nr; | 1512 | pd.src_clk_nr = src_clk_nr; |
1511 | pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio; | 1513 | pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio; |
1512 | #ifdef CONFIG_PL330_DMA | 1514 | #if defined(CONFIG_PL330_DMA) |
1513 | pd.filter = pl330_filter; | 1515 | pd.filter = pl330_filter; |
1516 | #elif defined(CONFIG_S3C64XX_PL080) | ||
1517 | pd.filter = pl08x_filter_id; | ||
1514 | #endif | 1518 | #endif |
1515 | 1519 | ||
1516 | s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1); | 1520 | s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1); |
@@ -1550,8 +1554,10 @@ void __init s3c64xx_spi2_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, | |||
1550 | pd.num_cs = num_cs; | 1554 | pd.num_cs = num_cs; |
1551 | pd.src_clk_nr = src_clk_nr; | 1555 | pd.src_clk_nr = src_clk_nr; |
1552 | pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio; | 1556 | pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio; |
1553 | #ifdef CONFIG_PL330_DMA | 1557 | #if defined(CONFIG_PL330_DMA) |
1554 | pd.filter = pl330_filter; | 1558 | pd.filter = pl330_filter; |
1559 | #elif defined(CONFIG_S3C64XX_PL080) | ||
1560 | pd.filter = pl08x_filter_id; | ||
1555 | #endif | 1561 | #endif |
1556 | 1562 | ||
1557 | s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi2); | 1563 | s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi2); |
diff --git a/arch/arm/plat-samsung/dma-ops.c b/arch/arm/plat-samsung/dma-ops.c index ec0d731b0e7b..886326ee6f6c 100644 --- a/arch/arm/plat-samsung/dma-ops.c +++ b/arch/arm/plat-samsung/dma-ops.c | |||
@@ -18,6 +18,12 @@ | |||
18 | 18 | ||
19 | #include <mach/dma.h> | 19 | #include <mach/dma.h> |
20 | 20 | ||
21 | #if defined(CONFIG_PL330_DMA) | ||
22 | #define dma_filter pl330_filter | ||
23 | #elif defined(CONFIG_S3C64XX_PL080) | ||
24 | #define dma_filter pl08x_filter_id | ||
25 | #endif | ||
26 | |||
21 | static unsigned samsung_dmadev_request(enum dma_ch dma_ch, | 27 | static unsigned samsung_dmadev_request(enum dma_ch dma_ch, |
22 | struct samsung_dma_req *param, | 28 | struct samsung_dma_req *param, |
23 | struct device *dev, char *ch_name) | 29 | struct device *dev, char *ch_name) |
@@ -30,7 +36,7 @@ static unsigned samsung_dmadev_request(enum dma_ch dma_ch, | |||
30 | if (dev->of_node) | 36 | if (dev->of_node) |
31 | return (unsigned)dma_request_slave_channel(dev, ch_name); | 37 | return (unsigned)dma_request_slave_channel(dev, ch_name); |
32 | else | 38 | else |
33 | return (unsigned)dma_request_channel(mask, pl330_filter, | 39 | return (unsigned)dma_request_channel(mask, dma_filter, |
34 | (void *)dma_ch); | 40 | (void *)dma_ch); |
35 | } | 41 | } |
36 | 42 | ||
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 83e4f959ee47..85501238b425 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c | |||
@@ -96,7 +96,7 @@ static int remap_pte_fn(pte_t *ptep, pgtable_t token, unsigned long addr, | |||
96 | struct remap_data *info = data; | 96 | struct remap_data *info = data; |
97 | struct page *page = info->pages[info->index++]; | 97 | struct page *page = info->pages[info->index++]; |
98 | unsigned long pfn = page_to_pfn(page); | 98 | unsigned long pfn = page_to_pfn(page); |
99 | pte_t pte = pfn_pte(pfn, info->prot); | 99 | pte_t pte = pte_mkspecial(pfn_pte(pfn, info->prot)); |
100 | 100 | ||
101 | if (map_foreign_page(pfn, info->fgmfn, info->domid)) | 101 | if (map_foreign_page(pfn, info->fgmfn, info->domid)) |
102 | return -EFAULT; | 102 | return -EFAULT; |
@@ -224,10 +224,10 @@ static int __init xen_guest_init(void) | |||
224 | } | 224 | } |
225 | if (of_address_to_resource(node, GRANT_TABLE_PHYSADDR, &res)) | 225 | if (of_address_to_resource(node, GRANT_TABLE_PHYSADDR, &res)) |
226 | return 0; | 226 | return 0; |
227 | xen_hvm_resume_frames = res.start >> PAGE_SHIFT; | 227 | xen_hvm_resume_frames = res.start; |
228 | xen_events_irq = irq_of_parse_and_map(node, 0); | 228 | xen_events_irq = irq_of_parse_and_map(node, 0); |
229 | pr_info("Xen %s support found, events_irq=%d gnttab_frame_pfn=%lx\n", | 229 | pr_info("Xen %s support found, events_irq=%d gnttab_frame_pfn=%lx\n", |
230 | version, xen_events_irq, xen_hvm_resume_frames); | 230 | version, xen_events_irq, (xen_hvm_resume_frames >> PAGE_SHIFT)); |
231 | xen_domain_type = XEN_HVM_DOMAIN; | 231 | xen_domain_type = XEN_HVM_DOMAIN; |
232 | 232 | ||
233 | xen_setup_features(); | 233 | xen_setup_features(); |
diff --git a/arch/arm64/include/asm/xen/page-coherent.h b/arch/arm64/include/asm/xen/page-coherent.h index 2820f1a6eebe..dde3fc9c49f0 100644 --- a/arch/arm64/include/asm/xen/page-coherent.h +++ b/arch/arm64/include/asm/xen/page-coherent.h | |||
@@ -23,25 +23,21 @@ static inline void xen_dma_map_page(struct device *hwdev, struct page *page, | |||
23 | unsigned long offset, size_t size, enum dma_data_direction dir, | 23 | unsigned long offset, size_t size, enum dma_data_direction dir, |
24 | struct dma_attrs *attrs) | 24 | struct dma_attrs *attrs) |
25 | { | 25 | { |
26 | __generic_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs); | ||
27 | } | 26 | } |
28 | 27 | ||
29 | static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle, | 28 | static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle, |
30 | size_t size, enum dma_data_direction dir, | 29 | size_t size, enum dma_data_direction dir, |
31 | struct dma_attrs *attrs) | 30 | struct dma_attrs *attrs) |
32 | { | 31 | { |
33 | __generic_dma_ops(hwdev)->unmap_page(hwdev, handle, size, dir, attrs); | ||
34 | } | 32 | } |
35 | 33 | ||
36 | static inline void xen_dma_sync_single_for_cpu(struct device *hwdev, | 34 | static inline void xen_dma_sync_single_for_cpu(struct device *hwdev, |
37 | dma_addr_t handle, size_t size, enum dma_data_direction dir) | 35 | dma_addr_t handle, size_t size, enum dma_data_direction dir) |
38 | { | 36 | { |
39 | __generic_dma_ops(hwdev)->sync_single_for_cpu(hwdev, handle, size, dir); | ||
40 | } | 37 | } |
41 | 38 | ||
42 | static inline void xen_dma_sync_single_for_device(struct device *hwdev, | 39 | static inline void xen_dma_sync_single_for_device(struct device *hwdev, |
43 | dma_addr_t handle, size_t size, enum dma_data_direction dir) | 40 | dma_addr_t handle, size_t size, enum dma_data_direction dir) |
44 | { | 41 | { |
45 | __generic_dma_ops(hwdev)->sync_single_for_device(hwdev, handle, size, dir); | ||
46 | } | 42 | } |
47 | #endif /* _ASM_ARM64_XEN_PAGE_COHERENT_H */ | 43 | #endif /* _ASM_ARM64_XEN_PAGE_COHERENT_H */ |
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 6777a2192b83..6a8928bba03c 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c | |||
@@ -214,31 +214,29 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type, | |||
214 | { | 214 | { |
215 | int err, len, type, disabled = !ctrl.enabled; | 215 | int err, len, type, disabled = !ctrl.enabled; |
216 | 216 | ||
217 | if (disabled) { | 217 | attr->disabled = disabled; |
218 | len = 0; | 218 | if (disabled) |
219 | type = HW_BREAKPOINT_EMPTY; | 219 | return 0; |
220 | } else { | 220 | |
221 | err = arch_bp_generic_fields(ctrl, &len, &type); | 221 | err = arch_bp_generic_fields(ctrl, &len, &type); |
222 | if (err) | 222 | if (err) |
223 | return err; | 223 | return err; |
224 | 224 | ||
225 | switch (note_type) { | 225 | switch (note_type) { |
226 | case NT_ARM_HW_BREAK: | 226 | case NT_ARM_HW_BREAK: |
227 | if ((type & HW_BREAKPOINT_X) != type) | 227 | if ((type & HW_BREAKPOINT_X) != type) |
228 | return -EINVAL; | ||
229 | break; | ||
230 | case NT_ARM_HW_WATCH: | ||
231 | if ((type & HW_BREAKPOINT_RW) != type) | ||
232 | return -EINVAL; | ||
233 | break; | ||
234 | default: | ||
235 | return -EINVAL; | 228 | return -EINVAL; |
236 | } | 229 | break; |
230 | case NT_ARM_HW_WATCH: | ||
231 | if ((type & HW_BREAKPOINT_RW) != type) | ||
232 | return -EINVAL; | ||
233 | break; | ||
234 | default: | ||
235 | return -EINVAL; | ||
237 | } | 236 | } |
238 | 237 | ||
239 | attr->bp_len = len; | 238 | attr->bp_len = len; |
240 | attr->bp_type = type; | 239 | attr->bp_type = type; |
241 | attr->disabled = disabled; | ||
242 | 240 | ||
243 | return 0; | 241 | return 0; |
244 | } | 242 | } |
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index 4a594b76674d..bc23b1ba7980 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h | |||
@@ -192,6 +192,10 @@ extern void kvmppc_load_up_vsx(void); | |||
192 | extern u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst); | 192 | extern u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst); |
193 | extern ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst); | 193 | extern ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst); |
194 | extern int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd); | 194 | extern int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd); |
195 | extern void kvmppc_copy_to_svcpu(struct kvmppc_book3s_shadow_vcpu *svcpu, | ||
196 | struct kvm_vcpu *vcpu); | ||
197 | extern void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu, | ||
198 | struct kvmppc_book3s_shadow_vcpu *svcpu); | ||
195 | 199 | ||
196 | static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu) | 200 | static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu) |
197 | { | 201 | { |
diff --git a/arch/powerpc/include/asm/kvm_book3s_asm.h b/arch/powerpc/include/asm/kvm_book3s_asm.h index 0bd9348a4db9..192917d2239c 100644 --- a/arch/powerpc/include/asm/kvm_book3s_asm.h +++ b/arch/powerpc/include/asm/kvm_book3s_asm.h | |||
@@ -79,6 +79,7 @@ struct kvmppc_host_state { | |||
79 | ulong vmhandler; | 79 | ulong vmhandler; |
80 | ulong scratch0; | 80 | ulong scratch0; |
81 | ulong scratch1; | 81 | ulong scratch1; |
82 | ulong scratch2; | ||
82 | u8 in_guest; | 83 | u8 in_guest; |
83 | u8 restore_hid5; | 84 | u8 restore_hid5; |
84 | u8 napping; | 85 | u8 napping; |
@@ -106,6 +107,7 @@ struct kvmppc_host_state { | |||
106 | }; | 107 | }; |
107 | 108 | ||
108 | struct kvmppc_book3s_shadow_vcpu { | 109 | struct kvmppc_book3s_shadow_vcpu { |
110 | bool in_use; | ||
109 | ulong gpr[14]; | 111 | ulong gpr[14]; |
110 | u32 cr; | 112 | u32 cr; |
111 | u32 xer; | 113 | u32 xer; |
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index 033c06be1d84..7bdcf340016c 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h | |||
@@ -720,13 +720,13 @@ int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe, | |||
720 | int64_t opal_pci_poll(uint64_t phb_id); | 720 | int64_t opal_pci_poll(uint64_t phb_id); |
721 | int64_t opal_return_cpu(void); | 721 | int64_t opal_return_cpu(void); |
722 | 722 | ||
723 | int64_t opal_xscom_read(uint32_t gcid, uint32_t pcb_addr, uint64_t *val); | 723 | int64_t opal_xscom_read(uint32_t gcid, uint32_t pcb_addr, __be64 *val); |
724 | int64_t opal_xscom_write(uint32_t gcid, uint32_t pcb_addr, uint64_t val); | 724 | int64_t opal_xscom_write(uint32_t gcid, uint32_t pcb_addr, uint64_t val); |
725 | 725 | ||
726 | int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type, | 726 | int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type, |
727 | uint32_t addr, uint32_t data, uint32_t sz); | 727 | uint32_t addr, uint32_t data, uint32_t sz); |
728 | int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type, | 728 | int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type, |
729 | uint32_t addr, uint32_t *data, uint32_t sz); | 729 | uint32_t addr, __be32 *data, uint32_t sz); |
730 | int64_t opal_validate_flash(uint64_t buffer, uint32_t *size, uint32_t *result); | 730 | int64_t opal_validate_flash(uint64_t buffer, uint32_t *size, uint32_t *result); |
731 | int64_t opal_manage_flash(uint8_t op); | 731 | int64_t opal_manage_flash(uint8_t op); |
732 | int64_t opal_update_flash(uint64_t blk_list); | 732 | int64_t opal_update_flash(uint64_t blk_list); |
diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h index 9ee12610af02..aace90547614 100644 --- a/arch/powerpc/include/asm/switch_to.h +++ b/arch/powerpc/include/asm/switch_to.h | |||
@@ -35,7 +35,7 @@ extern void giveup_vsx(struct task_struct *); | |||
35 | extern void enable_kernel_spe(void); | 35 | extern void enable_kernel_spe(void); |
36 | extern void giveup_spe(struct task_struct *); | 36 | extern void giveup_spe(struct task_struct *); |
37 | extern void load_up_spe(struct task_struct *); | 37 | extern void load_up_spe(struct task_struct *); |
38 | extern void switch_booke_debug_regs(struct thread_struct *new_thread); | 38 | extern void switch_booke_debug_regs(struct debug_reg *new_debug); |
39 | 39 | ||
40 | #ifndef CONFIG_SMP | 40 | #ifndef CONFIG_SMP |
41 | extern void discard_lazy_cpu_state(void); | 41 | extern void discard_lazy_cpu_state(void); |
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 2ea5cc033ec8..d3de01066f7d 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c | |||
@@ -576,6 +576,7 @@ int main(void) | |||
576 | HSTATE_FIELD(HSTATE_VMHANDLER, vmhandler); | 576 | HSTATE_FIELD(HSTATE_VMHANDLER, vmhandler); |
577 | HSTATE_FIELD(HSTATE_SCRATCH0, scratch0); | 577 | HSTATE_FIELD(HSTATE_SCRATCH0, scratch0); |
578 | HSTATE_FIELD(HSTATE_SCRATCH1, scratch1); | 578 | HSTATE_FIELD(HSTATE_SCRATCH1, scratch1); |
579 | HSTATE_FIELD(HSTATE_SCRATCH2, scratch2); | ||
579 | HSTATE_FIELD(HSTATE_IN_GUEST, in_guest); | 580 | HSTATE_FIELD(HSTATE_IN_GUEST, in_guest); |
580 | HSTATE_FIELD(HSTATE_RESTORE_HID5, restore_hid5); | 581 | HSTATE_FIELD(HSTATE_RESTORE_HID5, restore_hid5); |
581 | HSTATE_FIELD(HSTATE_NAPPING, napping); | 582 | HSTATE_FIELD(HSTATE_NAPPING, napping); |
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c index 779a78c26435..11c1d069d920 100644 --- a/arch/powerpc/kernel/crash_dump.c +++ b/arch/powerpc/kernel/crash_dump.c | |||
@@ -124,15 +124,15 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf, | |||
124 | void crash_free_reserved_phys_range(unsigned long begin, unsigned long end) | 124 | void crash_free_reserved_phys_range(unsigned long begin, unsigned long end) |
125 | { | 125 | { |
126 | unsigned long addr; | 126 | unsigned long addr; |
127 | const u32 *basep, *sizep; | 127 | const __be32 *basep, *sizep; |
128 | unsigned int rtas_start = 0, rtas_end = 0; | 128 | unsigned int rtas_start = 0, rtas_end = 0; |
129 | 129 | ||
130 | basep = of_get_property(rtas.dev, "linux,rtas-base", NULL); | 130 | basep = of_get_property(rtas.dev, "linux,rtas-base", NULL); |
131 | sizep = of_get_property(rtas.dev, "rtas-size", NULL); | 131 | sizep = of_get_property(rtas.dev, "rtas-size", NULL); |
132 | 132 | ||
133 | if (basep && sizep) { | 133 | if (basep && sizep) { |
134 | rtas_start = *basep; | 134 | rtas_start = be32_to_cpup(basep); |
135 | rtas_end = *basep + *sizep; | 135 | rtas_end = rtas_start + be32_to_cpup(sizep); |
136 | } | 136 | } |
137 | 137 | ||
138 | for (addr = begin; addr < end; addr += PAGE_SIZE) { | 138 | for (addr = begin; addr < end; addr += PAGE_SIZE) { |
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 3386d8ab7eb0..4a96556fd2d4 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c | |||
@@ -339,7 +339,7 @@ static void set_debug_reg_defaults(struct thread_struct *thread) | |||
339 | #endif | 339 | #endif |
340 | } | 340 | } |
341 | 341 | ||
342 | static void prime_debug_regs(struct thread_struct *thread) | 342 | static void prime_debug_regs(struct debug_reg *debug) |
343 | { | 343 | { |
344 | /* | 344 | /* |
345 | * We could have inherited MSR_DE from userspace, since | 345 | * We could have inherited MSR_DE from userspace, since |
@@ -348,22 +348,22 @@ static void prime_debug_regs(struct thread_struct *thread) | |||
348 | */ | 348 | */ |
349 | mtmsr(mfmsr() & ~MSR_DE); | 349 | mtmsr(mfmsr() & ~MSR_DE); |
350 | 350 | ||
351 | mtspr(SPRN_IAC1, thread->debug.iac1); | 351 | mtspr(SPRN_IAC1, debug->iac1); |
352 | mtspr(SPRN_IAC2, thread->debug.iac2); | 352 | mtspr(SPRN_IAC2, debug->iac2); |
353 | #if CONFIG_PPC_ADV_DEBUG_IACS > 2 | 353 | #if CONFIG_PPC_ADV_DEBUG_IACS > 2 |
354 | mtspr(SPRN_IAC3, thread->debug.iac3); | 354 | mtspr(SPRN_IAC3, debug->iac3); |
355 | mtspr(SPRN_IAC4, thread->debug.iac4); | 355 | mtspr(SPRN_IAC4, debug->iac4); |
356 | #endif | 356 | #endif |
357 | mtspr(SPRN_DAC1, thread->debug.dac1); | 357 | mtspr(SPRN_DAC1, debug->dac1); |
358 | mtspr(SPRN_DAC2, thread->debug.dac2); | 358 | mtspr(SPRN_DAC2, debug->dac2); |
359 | #if CONFIG_PPC_ADV_DEBUG_DVCS > 0 | 359 | #if CONFIG_PPC_ADV_DEBUG_DVCS > 0 |
360 | mtspr(SPRN_DVC1, thread->debug.dvc1); | 360 | mtspr(SPRN_DVC1, debug->dvc1); |
361 | mtspr(SPRN_DVC2, thread->debug.dvc2); | 361 | mtspr(SPRN_DVC2, debug->dvc2); |
362 | #endif | 362 | #endif |
363 | mtspr(SPRN_DBCR0, thread->debug.dbcr0); | 363 | mtspr(SPRN_DBCR0, debug->dbcr0); |
364 | mtspr(SPRN_DBCR1, thread->debug.dbcr1); | 364 | mtspr(SPRN_DBCR1, debug->dbcr1); |
365 | #ifdef CONFIG_BOOKE | 365 | #ifdef CONFIG_BOOKE |
366 | mtspr(SPRN_DBCR2, thread->debug.dbcr2); | 366 | mtspr(SPRN_DBCR2, debug->dbcr2); |
367 | #endif | 367 | #endif |
368 | } | 368 | } |
369 | /* | 369 | /* |
@@ -371,11 +371,11 @@ static void prime_debug_regs(struct thread_struct *thread) | |||
371 | * debug registers, set the debug registers from the values | 371 | * debug registers, set the debug registers from the values |
372 | * stored in the new thread. | 372 | * stored in the new thread. |
373 | */ | 373 | */ |
374 | void switch_booke_debug_regs(struct thread_struct *new_thread) | 374 | void switch_booke_debug_regs(struct debug_reg *new_debug) |
375 | { | 375 | { |
376 | if ((current->thread.debug.dbcr0 & DBCR0_IDM) | 376 | if ((current->thread.debug.dbcr0 & DBCR0_IDM) |
377 | || (new_thread->debug.dbcr0 & DBCR0_IDM)) | 377 | || (new_debug->dbcr0 & DBCR0_IDM)) |
378 | prime_debug_regs(new_thread); | 378 | prime_debug_regs(new_debug); |
379 | } | 379 | } |
380 | EXPORT_SYMBOL_GPL(switch_booke_debug_regs); | 380 | EXPORT_SYMBOL_GPL(switch_booke_debug_regs); |
381 | #else /* !CONFIG_PPC_ADV_DEBUG_REGS */ | 381 | #else /* !CONFIG_PPC_ADV_DEBUG_REGS */ |
@@ -683,7 +683,7 @@ struct task_struct *__switch_to(struct task_struct *prev, | |||
683 | #endif /* CONFIG_SMP */ | 683 | #endif /* CONFIG_SMP */ |
684 | 684 | ||
685 | #ifdef CONFIG_PPC_ADV_DEBUG_REGS | 685 | #ifdef CONFIG_PPC_ADV_DEBUG_REGS |
686 | switch_booke_debug_regs(&new->thread); | 686 | switch_booke_debug_regs(&new->thread.debug); |
687 | #else | 687 | #else |
688 | /* | 688 | /* |
689 | * For PPC_BOOK3S_64, we use the hw-breakpoint interfaces that would | 689 | * For PPC_BOOK3S_64, we use the hw-breakpoint interfaces that would |
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 75fb40498b41..2e3d2bf536c5 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c | |||
@@ -1555,7 +1555,7 @@ long arch_ptrace(struct task_struct *child, long request, | |||
1555 | 1555 | ||
1556 | flush_fp_to_thread(child); | 1556 | flush_fp_to_thread(child); |
1557 | if (fpidx < (PT_FPSCR - PT_FPR0)) | 1557 | if (fpidx < (PT_FPSCR - PT_FPR0)) |
1558 | memcpy(&tmp, &child->thread.fp_state.fpr, | 1558 | memcpy(&tmp, &child->thread.TS_FPR(fpidx), |
1559 | sizeof(long)); | 1559 | sizeof(long)); |
1560 | else | 1560 | else |
1561 | tmp = child->thread.fp_state.fpscr; | 1561 | tmp = child->thread.fp_state.fpscr; |
@@ -1588,7 +1588,7 @@ long arch_ptrace(struct task_struct *child, long request, | |||
1588 | 1588 | ||
1589 | flush_fp_to_thread(child); | 1589 | flush_fp_to_thread(child); |
1590 | if (fpidx < (PT_FPSCR - PT_FPR0)) | 1590 | if (fpidx < (PT_FPSCR - PT_FPR0)) |
1591 | memcpy(&child->thread.fp_state.fpr, &data, | 1591 | memcpy(&child->thread.TS_FPR(fpidx), &data, |
1592 | sizeof(long)); | 1592 | sizeof(long)); |
1593 | else | 1593 | else |
1594 | child->thread.fp_state.fpscr = data; | 1594 | child->thread.fp_state.fpscr = data; |
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index febc80445d25..bc76cc6b419c 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c | |||
@@ -479,7 +479,7 @@ void __init smp_setup_cpu_maps(void) | |||
479 | if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR) && | 479 | if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR) && |
480 | (dn = of_find_node_by_path("/rtas"))) { | 480 | (dn = of_find_node_by_path("/rtas"))) { |
481 | int num_addr_cell, num_size_cell, maxcpus; | 481 | int num_addr_cell, num_size_cell, maxcpus; |
482 | const unsigned int *ireg; | 482 | const __be32 *ireg; |
483 | 483 | ||
484 | num_addr_cell = of_n_addr_cells(dn); | 484 | num_addr_cell = of_n_addr_cells(dn); |
485 | num_size_cell = of_n_size_cells(dn); | 485 | num_size_cell = of_n_size_cells(dn); |
@@ -489,7 +489,7 @@ void __init smp_setup_cpu_maps(void) | |||
489 | if (!ireg) | 489 | if (!ireg) |
490 | goto out; | 490 | goto out; |
491 | 491 | ||
492 | maxcpus = ireg[num_addr_cell + num_size_cell]; | 492 | maxcpus = be32_to_cpup(ireg + num_addr_cell + num_size_cell); |
493 | 493 | ||
494 | /* Double maxcpus for processors which have SMT capability */ | 494 | /* Double maxcpus for processors which have SMT capability */ |
495 | if (cpu_has_feature(CPU_FTR_SMT)) | 495 | if (cpu_has_feature(CPU_FTR_SMT)) |
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index a3b64f3bf9a2..c1cf4a1522d9 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c | |||
@@ -580,7 +580,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle) | |||
580 | int cpu_to_core_id(int cpu) | 580 | int cpu_to_core_id(int cpu) |
581 | { | 581 | { |
582 | struct device_node *np; | 582 | struct device_node *np; |
583 | const int *reg; | 583 | const __be32 *reg; |
584 | int id = -1; | 584 | int id = -1; |
585 | 585 | ||
586 | np = of_get_cpu_node(cpu, NULL); | 586 | np = of_get_cpu_node(cpu, NULL); |
@@ -591,7 +591,7 @@ int cpu_to_core_id(int cpu) | |||
591 | if (!reg) | 591 | if (!reg) |
592 | goto out; | 592 | goto out; |
593 | 593 | ||
594 | id = *reg; | 594 | id = be32_to_cpup(reg); |
595 | out: | 595 | out: |
596 | of_node_put(np); | 596 | of_node_put(np); |
597 | return id; | 597 | return id; |
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index f3ff587a8b7d..c5d148434c08 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c | |||
@@ -469,11 +469,14 @@ static int kvmppc_mmu_book3s_64_hv_xlate(struct kvm_vcpu *vcpu, gva_t eaddr, | |||
469 | slb_v = vcpu->kvm->arch.vrma_slb_v; | 469 | slb_v = vcpu->kvm->arch.vrma_slb_v; |
470 | } | 470 | } |
471 | 471 | ||
472 | preempt_disable(); | ||
472 | /* Find the HPTE in the hash table */ | 473 | /* Find the HPTE in the hash table */ |
473 | index = kvmppc_hv_find_lock_hpte(kvm, eaddr, slb_v, | 474 | index = kvmppc_hv_find_lock_hpte(kvm, eaddr, slb_v, |
474 | HPTE_V_VALID | HPTE_V_ABSENT); | 475 | HPTE_V_VALID | HPTE_V_ABSENT); |
475 | if (index < 0) | 476 | if (index < 0) { |
477 | preempt_enable(); | ||
476 | return -ENOENT; | 478 | return -ENOENT; |
479 | } | ||
477 | hptep = (unsigned long *)(kvm->arch.hpt_virt + (index << 4)); | 480 | hptep = (unsigned long *)(kvm->arch.hpt_virt + (index << 4)); |
478 | v = hptep[0] & ~HPTE_V_HVLOCK; | 481 | v = hptep[0] & ~HPTE_V_HVLOCK; |
479 | gr = kvm->arch.revmap[index].guest_rpte; | 482 | gr = kvm->arch.revmap[index].guest_rpte; |
@@ -481,6 +484,7 @@ static int kvmppc_mmu_book3s_64_hv_xlate(struct kvm_vcpu *vcpu, gva_t eaddr, | |||
481 | /* Unlock the HPTE */ | 484 | /* Unlock the HPTE */ |
482 | asm volatile("lwsync" : : : "memory"); | 485 | asm volatile("lwsync" : : : "memory"); |
483 | hptep[0] = v; | 486 | hptep[0] = v; |
487 | preempt_enable(); | ||
484 | 488 | ||
485 | gpte->eaddr = eaddr; | 489 | gpte->eaddr = eaddr; |
486 | gpte->vpage = ((v & HPTE_V_AVPN) << 4) | ((eaddr >> 12) & 0xfff); | 490 | gpte->vpage = ((v & HPTE_V_AVPN) << 4) | ((eaddr >> 12) & 0xfff); |
@@ -665,6 +669,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
665 | return -EFAULT; | 669 | return -EFAULT; |
666 | } else { | 670 | } else { |
667 | page = pages[0]; | 671 | page = pages[0]; |
672 | pfn = page_to_pfn(page); | ||
668 | if (PageHuge(page)) { | 673 | if (PageHuge(page)) { |
669 | page = compound_head(page); | 674 | page = compound_head(page); |
670 | pte_size <<= compound_order(page); | 675 | pte_size <<= compound_order(page); |
@@ -689,7 +694,6 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
689 | } | 694 | } |
690 | rcu_read_unlock_sched(); | 695 | rcu_read_unlock_sched(); |
691 | } | 696 | } |
692 | pfn = page_to_pfn(page); | ||
693 | } | 697 | } |
694 | 698 | ||
695 | ret = -EFAULT; | 699 | ret = -EFAULT; |
@@ -707,8 +711,14 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
707 | r = (r & ~(HPTE_R_W|HPTE_R_I|HPTE_R_G)) | HPTE_R_M; | 711 | r = (r & ~(HPTE_R_W|HPTE_R_I|HPTE_R_G)) | HPTE_R_M; |
708 | } | 712 | } |
709 | 713 | ||
710 | /* Set the HPTE to point to pfn */ | 714 | /* |
711 | r = (r & ~(HPTE_R_PP0 - pte_size)) | (pfn << PAGE_SHIFT); | 715 | * Set the HPTE to point to pfn. |
716 | * Since the pfn is at PAGE_SIZE granularity, make sure we | ||
717 | * don't mask out lower-order bits if psize < PAGE_SIZE. | ||
718 | */ | ||
719 | if (psize < PAGE_SIZE) | ||
720 | psize = PAGE_SIZE; | ||
721 | r = (r & ~(HPTE_R_PP0 - psize)) | ((pfn << PAGE_SHIFT) & ~(psize - 1)); | ||
712 | if (hpte_is_writable(r) && !write_ok) | 722 | if (hpte_is_writable(r) && !write_ok) |
713 | r = hpte_make_readonly(r); | 723 | r = hpte_make_readonly(r); |
714 | ret = RESUME_GUEST; | 724 | ret = RESUME_GUEST; |
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 072287f1c3bc..b51d5db78068 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c | |||
@@ -131,8 +131,9 @@ static void kvmppc_fast_vcpu_kick_hv(struct kvm_vcpu *vcpu) | |||
131 | static void kvmppc_core_vcpu_load_hv(struct kvm_vcpu *vcpu, int cpu) | 131 | static void kvmppc_core_vcpu_load_hv(struct kvm_vcpu *vcpu, int cpu) |
132 | { | 132 | { |
133 | struct kvmppc_vcore *vc = vcpu->arch.vcore; | 133 | struct kvmppc_vcore *vc = vcpu->arch.vcore; |
134 | unsigned long flags; | ||
134 | 135 | ||
135 | spin_lock(&vcpu->arch.tbacct_lock); | 136 | spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); |
136 | if (vc->runner == vcpu && vc->vcore_state != VCORE_INACTIVE && | 137 | if (vc->runner == vcpu && vc->vcore_state != VCORE_INACTIVE && |
137 | vc->preempt_tb != TB_NIL) { | 138 | vc->preempt_tb != TB_NIL) { |
138 | vc->stolen_tb += mftb() - vc->preempt_tb; | 139 | vc->stolen_tb += mftb() - vc->preempt_tb; |
@@ -143,19 +144,20 @@ static void kvmppc_core_vcpu_load_hv(struct kvm_vcpu *vcpu, int cpu) | |||
143 | vcpu->arch.busy_stolen += mftb() - vcpu->arch.busy_preempt; | 144 | vcpu->arch.busy_stolen += mftb() - vcpu->arch.busy_preempt; |
144 | vcpu->arch.busy_preempt = TB_NIL; | 145 | vcpu->arch.busy_preempt = TB_NIL; |
145 | } | 146 | } |
146 | spin_unlock(&vcpu->arch.tbacct_lock); | 147 | spin_unlock_irqrestore(&vcpu->arch.tbacct_lock, flags); |
147 | } | 148 | } |
148 | 149 | ||
149 | static void kvmppc_core_vcpu_put_hv(struct kvm_vcpu *vcpu) | 150 | static void kvmppc_core_vcpu_put_hv(struct kvm_vcpu *vcpu) |
150 | { | 151 | { |
151 | struct kvmppc_vcore *vc = vcpu->arch.vcore; | 152 | struct kvmppc_vcore *vc = vcpu->arch.vcore; |
153 | unsigned long flags; | ||
152 | 154 | ||
153 | spin_lock(&vcpu->arch.tbacct_lock); | 155 | spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); |
154 | if (vc->runner == vcpu && vc->vcore_state != VCORE_INACTIVE) | 156 | if (vc->runner == vcpu && vc->vcore_state != VCORE_INACTIVE) |
155 | vc->preempt_tb = mftb(); | 157 | vc->preempt_tb = mftb(); |
156 | if (vcpu->arch.state == KVMPPC_VCPU_BUSY_IN_HOST) | 158 | if (vcpu->arch.state == KVMPPC_VCPU_BUSY_IN_HOST) |
157 | vcpu->arch.busy_preempt = mftb(); | 159 | vcpu->arch.busy_preempt = mftb(); |
158 | spin_unlock(&vcpu->arch.tbacct_lock); | 160 | spin_unlock_irqrestore(&vcpu->arch.tbacct_lock, flags); |
159 | } | 161 | } |
160 | 162 | ||
161 | static void kvmppc_set_msr_hv(struct kvm_vcpu *vcpu, u64 msr) | 163 | static void kvmppc_set_msr_hv(struct kvm_vcpu *vcpu, u64 msr) |
@@ -486,11 +488,11 @@ static u64 vcore_stolen_time(struct kvmppc_vcore *vc, u64 now) | |||
486 | */ | 488 | */ |
487 | if (vc->vcore_state != VCORE_INACTIVE && | 489 | if (vc->vcore_state != VCORE_INACTIVE && |
488 | vc->runner->arch.run_task != current) { | 490 | vc->runner->arch.run_task != current) { |
489 | spin_lock(&vc->runner->arch.tbacct_lock); | 491 | spin_lock_irq(&vc->runner->arch.tbacct_lock); |
490 | p = vc->stolen_tb; | 492 | p = vc->stolen_tb; |
491 | if (vc->preempt_tb != TB_NIL) | 493 | if (vc->preempt_tb != TB_NIL) |
492 | p += now - vc->preempt_tb; | 494 | p += now - vc->preempt_tb; |
493 | spin_unlock(&vc->runner->arch.tbacct_lock); | 495 | spin_unlock_irq(&vc->runner->arch.tbacct_lock); |
494 | } else { | 496 | } else { |
495 | p = vc->stolen_tb; | 497 | p = vc->stolen_tb; |
496 | } | 498 | } |
@@ -512,10 +514,10 @@ static void kvmppc_create_dtl_entry(struct kvm_vcpu *vcpu, | |||
512 | core_stolen = vcore_stolen_time(vc, now); | 514 | core_stolen = vcore_stolen_time(vc, now); |
513 | stolen = core_stolen - vcpu->arch.stolen_logged; | 515 | stolen = core_stolen - vcpu->arch.stolen_logged; |
514 | vcpu->arch.stolen_logged = core_stolen; | 516 | vcpu->arch.stolen_logged = core_stolen; |
515 | spin_lock(&vcpu->arch.tbacct_lock); | 517 | spin_lock_irq(&vcpu->arch.tbacct_lock); |
516 | stolen += vcpu->arch.busy_stolen; | 518 | stolen += vcpu->arch.busy_stolen; |
517 | vcpu->arch.busy_stolen = 0; | 519 | vcpu->arch.busy_stolen = 0; |
518 | spin_unlock(&vcpu->arch.tbacct_lock); | 520 | spin_unlock_irq(&vcpu->arch.tbacct_lock); |
519 | if (!dt || !vpa) | 521 | if (!dt || !vpa) |
520 | return; | 522 | return; |
521 | memset(dt, 0, sizeof(struct dtl_entry)); | 523 | memset(dt, 0, sizeof(struct dtl_entry)); |
@@ -589,7 +591,9 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) | |||
589 | if (list_empty(&vcpu->kvm->arch.rtas_tokens)) | 591 | if (list_empty(&vcpu->kvm->arch.rtas_tokens)) |
590 | return RESUME_HOST; | 592 | return RESUME_HOST; |
591 | 593 | ||
594 | idx = srcu_read_lock(&vcpu->kvm->srcu); | ||
592 | rc = kvmppc_rtas_hcall(vcpu); | 595 | rc = kvmppc_rtas_hcall(vcpu); |
596 | srcu_read_unlock(&vcpu->kvm->srcu, idx); | ||
593 | 597 | ||
594 | if (rc == -ENOENT) | 598 | if (rc == -ENOENT) |
595 | return RESUME_HOST; | 599 | return RESUME_HOST; |
@@ -1115,13 +1119,13 @@ static void kvmppc_remove_runnable(struct kvmppc_vcore *vc, | |||
1115 | 1119 | ||
1116 | if (vcpu->arch.state != KVMPPC_VCPU_RUNNABLE) | 1120 | if (vcpu->arch.state != KVMPPC_VCPU_RUNNABLE) |
1117 | return; | 1121 | return; |
1118 | spin_lock(&vcpu->arch.tbacct_lock); | 1122 | spin_lock_irq(&vcpu->arch.tbacct_lock); |
1119 | now = mftb(); | 1123 | now = mftb(); |
1120 | vcpu->arch.busy_stolen += vcore_stolen_time(vc, now) - | 1124 | vcpu->arch.busy_stolen += vcore_stolen_time(vc, now) - |
1121 | vcpu->arch.stolen_logged; | 1125 | vcpu->arch.stolen_logged; |
1122 | vcpu->arch.busy_preempt = now; | 1126 | vcpu->arch.busy_preempt = now; |
1123 | vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST; | 1127 | vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST; |
1124 | spin_unlock(&vcpu->arch.tbacct_lock); | 1128 | spin_unlock_irq(&vcpu->arch.tbacct_lock); |
1125 | --vc->n_runnable; | 1129 | --vc->n_runnable; |
1126 | list_del(&vcpu->arch.run_list); | 1130 | list_del(&vcpu->arch.run_list); |
1127 | } | 1131 | } |
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c index 9c515440ad1a..8689e2e30857 100644 --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c | |||
@@ -225,6 +225,7 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, | |||
225 | is_io = pa & (HPTE_R_I | HPTE_R_W); | 225 | is_io = pa & (HPTE_R_I | HPTE_R_W); |
226 | pte_size = PAGE_SIZE << (pa & KVMPPC_PAGE_ORDER_MASK); | 226 | pte_size = PAGE_SIZE << (pa & KVMPPC_PAGE_ORDER_MASK); |
227 | pa &= PAGE_MASK; | 227 | pa &= PAGE_MASK; |
228 | pa |= gpa & ~PAGE_MASK; | ||
228 | } else { | 229 | } else { |
229 | /* Translate to host virtual address */ | 230 | /* Translate to host virtual address */ |
230 | hva = __gfn_to_hva_memslot(memslot, gfn); | 231 | hva = __gfn_to_hva_memslot(memslot, gfn); |
@@ -238,13 +239,13 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, | |||
238 | ptel = hpte_make_readonly(ptel); | 239 | ptel = hpte_make_readonly(ptel); |
239 | is_io = hpte_cache_bits(pte_val(pte)); | 240 | is_io = hpte_cache_bits(pte_val(pte)); |
240 | pa = pte_pfn(pte) << PAGE_SHIFT; | 241 | pa = pte_pfn(pte) << PAGE_SHIFT; |
242 | pa |= hva & (pte_size - 1); | ||
243 | pa |= gpa & ~PAGE_MASK; | ||
241 | } | 244 | } |
242 | } | 245 | } |
243 | 246 | ||
244 | if (pte_size < psize) | 247 | if (pte_size < psize) |
245 | return H_PARAMETER; | 248 | return H_PARAMETER; |
246 | if (pa && pte_size > psize) | ||
247 | pa |= gpa & (pte_size - 1); | ||
248 | 249 | ||
249 | ptel &= ~(HPTE_R_PP0 - psize); | 250 | ptel &= ~(HPTE_R_PP0 - psize); |
250 | ptel |= pa; | 251 | ptel |= pa; |
@@ -749,6 +750,10 @@ static int slb_base_page_shift[4] = { | |||
749 | 20, /* 1M, unsupported */ | 750 | 20, /* 1M, unsupported */ |
750 | }; | 751 | }; |
751 | 752 | ||
753 | /* When called from virtmode, this func should be protected by | ||
754 | * preempt_disable(), otherwise, the holding of HPTE_V_HVLOCK | ||
755 | * can trigger deadlock issue. | ||
756 | */ | ||
752 | long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr, unsigned long slb_v, | 757 | long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr, unsigned long slb_v, |
753 | unsigned long valid) | 758 | unsigned long valid) |
754 | { | 759 | { |
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index bc8de75b1925..be4fa04a37c9 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S | |||
@@ -153,7 +153,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | |||
153 | 153 | ||
154 | 13: b machine_check_fwnmi | 154 | 13: b machine_check_fwnmi |
155 | 155 | ||
156 | |||
157 | /* | 156 | /* |
158 | * We come in here when wakened from nap mode on a secondary hw thread. | 157 | * We come in here when wakened from nap mode on a secondary hw thread. |
159 | * Relocation is off and most register values are lost. | 158 | * Relocation is off and most register values are lost. |
@@ -224,6 +223,11 @@ kvm_start_guest: | |||
224 | /* Clear our vcpu pointer so we don't come back in early */ | 223 | /* Clear our vcpu pointer so we don't come back in early */ |
225 | li r0, 0 | 224 | li r0, 0 |
226 | std r0, HSTATE_KVM_VCPU(r13) | 225 | std r0, HSTATE_KVM_VCPU(r13) |
226 | /* | ||
227 | * Make sure we clear HSTATE_KVM_VCPU(r13) before incrementing | ||
228 | * the nap_count, because once the increment to nap_count is | ||
229 | * visible we could be given another vcpu. | ||
230 | */ | ||
227 | lwsync | 231 | lwsync |
228 | /* Clear any pending IPI - we're an offline thread */ | 232 | /* Clear any pending IPI - we're an offline thread */ |
229 | ld r5, HSTATE_XICS_PHYS(r13) | 233 | ld r5, HSTATE_XICS_PHYS(r13) |
@@ -241,7 +245,6 @@ kvm_start_guest: | |||
241 | /* increment the nap count and then go to nap mode */ | 245 | /* increment the nap count and then go to nap mode */ |
242 | ld r4, HSTATE_KVM_VCORE(r13) | 246 | ld r4, HSTATE_KVM_VCORE(r13) |
243 | addi r4, r4, VCORE_NAP_COUNT | 247 | addi r4, r4, VCORE_NAP_COUNT |
244 | lwsync /* make previous updates visible */ | ||
245 | 51: lwarx r3, 0, r4 | 248 | 51: lwarx r3, 0, r4 |
246 | addi r3, r3, 1 | 249 | addi r3, r3, 1 |
247 | stwcx. r3, 0, r4 | 250 | stwcx. r3, 0, r4 |
@@ -751,15 +754,14 @@ kvmppc_interrupt_hv: | |||
751 | * guest CR, R12 saved in shadow VCPU SCRATCH1/0 | 754 | * guest CR, R12 saved in shadow VCPU SCRATCH1/0 |
752 | * guest R13 saved in SPRN_SCRATCH0 | 755 | * guest R13 saved in SPRN_SCRATCH0 |
753 | */ | 756 | */ |
754 | /* abuse host_r2 as third scratch area; we get r2 from PACATOC(r13) */ | 757 | std r9, HSTATE_SCRATCH2(r13) |
755 | std r9, HSTATE_HOST_R2(r13) | ||
756 | 758 | ||
757 | lbz r9, HSTATE_IN_GUEST(r13) | 759 | lbz r9, HSTATE_IN_GUEST(r13) |
758 | cmpwi r9, KVM_GUEST_MODE_HOST_HV | 760 | cmpwi r9, KVM_GUEST_MODE_HOST_HV |
759 | beq kvmppc_bad_host_intr | 761 | beq kvmppc_bad_host_intr |
760 | #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE | 762 | #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE |
761 | cmpwi r9, KVM_GUEST_MODE_GUEST | 763 | cmpwi r9, KVM_GUEST_MODE_GUEST |
762 | ld r9, HSTATE_HOST_R2(r13) | 764 | ld r9, HSTATE_SCRATCH2(r13) |
763 | beq kvmppc_interrupt_pr | 765 | beq kvmppc_interrupt_pr |
764 | #endif | 766 | #endif |
765 | /* We're now back in the host but in guest MMU context */ | 767 | /* We're now back in the host but in guest MMU context */ |
@@ -779,7 +781,7 @@ kvmppc_interrupt_hv: | |||
779 | std r6, VCPU_GPR(R6)(r9) | 781 | std r6, VCPU_GPR(R6)(r9) |
780 | std r7, VCPU_GPR(R7)(r9) | 782 | std r7, VCPU_GPR(R7)(r9) |
781 | std r8, VCPU_GPR(R8)(r9) | 783 | std r8, VCPU_GPR(R8)(r9) |
782 | ld r0, HSTATE_HOST_R2(r13) | 784 | ld r0, HSTATE_SCRATCH2(r13) |
783 | std r0, VCPU_GPR(R9)(r9) | 785 | std r0, VCPU_GPR(R9)(r9) |
784 | std r10, VCPU_GPR(R10)(r9) | 786 | std r10, VCPU_GPR(R10)(r9) |
785 | std r11, VCPU_GPR(R11)(r9) | 787 | std r11, VCPU_GPR(R11)(r9) |
@@ -990,14 +992,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | |||
990 | */ | 992 | */ |
991 | /* Increment the threads-exiting-guest count in the 0xff00 | 993 | /* Increment the threads-exiting-guest count in the 0xff00 |
992 | bits of vcore->entry_exit_count */ | 994 | bits of vcore->entry_exit_count */ |
993 | lwsync | ||
994 | ld r5,HSTATE_KVM_VCORE(r13) | 995 | ld r5,HSTATE_KVM_VCORE(r13) |
995 | addi r6,r5,VCORE_ENTRY_EXIT | 996 | addi r6,r5,VCORE_ENTRY_EXIT |
996 | 41: lwarx r3,0,r6 | 997 | 41: lwarx r3,0,r6 |
997 | addi r0,r3,0x100 | 998 | addi r0,r3,0x100 |
998 | stwcx. r0,0,r6 | 999 | stwcx. r0,0,r6 |
999 | bne 41b | 1000 | bne 41b |
1000 | lwsync | 1001 | isync /* order stwcx. vs. reading napping_threads */ |
1001 | 1002 | ||
1002 | /* | 1003 | /* |
1003 | * At this point we have an interrupt that we have to pass | 1004 | * At this point we have an interrupt that we have to pass |
@@ -1030,6 +1031,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | |||
1030 | sld r0,r0,r4 | 1031 | sld r0,r0,r4 |
1031 | andc. r3,r3,r0 /* no sense IPI'ing ourselves */ | 1032 | andc. r3,r3,r0 /* no sense IPI'ing ourselves */ |
1032 | beq 43f | 1033 | beq 43f |
1034 | /* Order entry/exit update vs. IPIs */ | ||
1035 | sync | ||
1033 | mulli r4,r4,PACA_SIZE /* get paca for thread 0 */ | 1036 | mulli r4,r4,PACA_SIZE /* get paca for thread 0 */ |
1034 | subf r6,r4,r13 | 1037 | subf r6,r4,r13 |
1035 | 42: andi. r0,r3,1 | 1038 | 42: andi. r0,r3,1 |
@@ -1638,10 +1641,10 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206) | |||
1638 | bge kvm_cede_exit | 1641 | bge kvm_cede_exit |
1639 | stwcx. r4,0,r6 | 1642 | stwcx. r4,0,r6 |
1640 | bne 31b | 1643 | bne 31b |
1644 | /* order napping_threads update vs testing entry_exit_count */ | ||
1645 | isync | ||
1641 | li r0,1 | 1646 | li r0,1 |
1642 | stb r0,HSTATE_NAPPING(r13) | 1647 | stb r0,HSTATE_NAPPING(r13) |
1643 | /* order napping_threads update vs testing entry_exit_count */ | ||
1644 | lwsync | ||
1645 | mr r4,r3 | 1648 | mr r4,r3 |
1646 | lwz r7,VCORE_ENTRY_EXIT(r5) | 1649 | lwz r7,VCORE_ENTRY_EXIT(r5) |
1647 | cmpwi r7,0x100 | 1650 | cmpwi r7,0x100 |
diff --git a/arch/powerpc/kvm/book3s_interrupts.S b/arch/powerpc/kvm/book3s_interrupts.S index f4dd041c14ea..f779450cb07c 100644 --- a/arch/powerpc/kvm/book3s_interrupts.S +++ b/arch/powerpc/kvm/book3s_interrupts.S | |||
@@ -129,29 +129,32 @@ kvm_start_lightweight: | |||
129 | * R12 = exit handler id | 129 | * R12 = exit handler id |
130 | * R13 = PACA | 130 | * R13 = PACA |
131 | * SVCPU.* = guest * | 131 | * SVCPU.* = guest * |
132 | * MSR.EE = 1 | ||
132 | * | 133 | * |
133 | */ | 134 | */ |
134 | 135 | ||
136 | PPC_LL r3, GPR4(r1) /* vcpu pointer */ | ||
137 | |||
138 | /* | ||
139 | * kvmppc_copy_from_svcpu can clobber volatile registers, save | ||
140 | * the exit handler id to the vcpu and restore it from there later. | ||
141 | */ | ||
142 | stw r12, VCPU_TRAP(r3) | ||
143 | |||
135 | /* Transfer reg values from shadow vcpu back to vcpu struct */ | 144 | /* Transfer reg values from shadow vcpu back to vcpu struct */ |
136 | /* On 64-bit, interrupts are still off at this point */ | 145 | /* On 64-bit, interrupts are still off at this point */ |
137 | PPC_LL r3, GPR4(r1) /* vcpu pointer */ | 146 | |
138 | GET_SHADOW_VCPU(r4) | 147 | GET_SHADOW_VCPU(r4) |
139 | bl FUNC(kvmppc_copy_from_svcpu) | 148 | bl FUNC(kvmppc_copy_from_svcpu) |
140 | nop | 149 | nop |
141 | 150 | ||
142 | #ifdef CONFIG_PPC_BOOK3S_64 | 151 | #ifdef CONFIG_PPC_BOOK3S_64 |
143 | /* Re-enable interrupts */ | ||
144 | ld r3, HSTATE_HOST_MSR(r13) | ||
145 | ori r3, r3, MSR_EE | ||
146 | MTMSR_EERI(r3) | ||
147 | |||
148 | /* | 152 | /* |
149 | * Reload kernel SPRG3 value. | 153 | * Reload kernel SPRG3 value. |
150 | * No need to save guest value as usermode can't modify SPRG3. | 154 | * No need to save guest value as usermode can't modify SPRG3. |
151 | */ | 155 | */ |
152 | ld r3, PACA_SPRG3(r13) | 156 | ld r3, PACA_SPRG3(r13) |
153 | mtspr SPRN_SPRG3, r3 | 157 | mtspr SPRN_SPRG3, r3 |
154 | |||
155 | #endif /* CONFIG_PPC_BOOK3S_64 */ | 158 | #endif /* CONFIG_PPC_BOOK3S_64 */ |
156 | 159 | ||
157 | /* R7 = vcpu */ | 160 | /* R7 = vcpu */ |
@@ -177,7 +180,7 @@ kvm_start_lightweight: | |||
177 | PPC_STL r31, VCPU_GPR(R31)(r7) | 180 | PPC_STL r31, VCPU_GPR(R31)(r7) |
178 | 181 | ||
179 | /* Pass the exit number as 3rd argument to kvmppc_handle_exit */ | 182 | /* Pass the exit number as 3rd argument to kvmppc_handle_exit */ |
180 | mr r5, r12 | 183 | lwz r5, VCPU_TRAP(r7) |
181 | 184 | ||
182 | /* Restore r3 (kvm_run) and r4 (vcpu) */ | 185 | /* Restore r3 (kvm_run) and r4 (vcpu) */ |
183 | REST_2GPRS(3, r1) | 186 | REST_2GPRS(3, r1) |
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index fe14ca3dd171..5b9e9063cfaf 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c | |||
@@ -66,6 +66,7 @@ static void kvmppc_core_vcpu_load_pr(struct kvm_vcpu *vcpu, int cpu) | |||
66 | struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu); | 66 | struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu); |
67 | memcpy(svcpu->slb, to_book3s(vcpu)->slb_shadow, sizeof(svcpu->slb)); | 67 | memcpy(svcpu->slb, to_book3s(vcpu)->slb_shadow, sizeof(svcpu->slb)); |
68 | svcpu->slb_max = to_book3s(vcpu)->slb_shadow_max; | 68 | svcpu->slb_max = to_book3s(vcpu)->slb_shadow_max; |
69 | svcpu->in_use = 0; | ||
69 | svcpu_put(svcpu); | 70 | svcpu_put(svcpu); |
70 | #endif | 71 | #endif |
71 | vcpu->cpu = smp_processor_id(); | 72 | vcpu->cpu = smp_processor_id(); |
@@ -78,6 +79,9 @@ static void kvmppc_core_vcpu_put_pr(struct kvm_vcpu *vcpu) | |||
78 | { | 79 | { |
79 | #ifdef CONFIG_PPC_BOOK3S_64 | 80 | #ifdef CONFIG_PPC_BOOK3S_64 |
80 | struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu); | 81 | struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu); |
82 | if (svcpu->in_use) { | ||
83 | kvmppc_copy_from_svcpu(vcpu, svcpu); | ||
84 | } | ||
81 | memcpy(to_book3s(vcpu)->slb_shadow, svcpu->slb, sizeof(svcpu->slb)); | 85 | memcpy(to_book3s(vcpu)->slb_shadow, svcpu->slb, sizeof(svcpu->slb)); |
82 | to_book3s(vcpu)->slb_shadow_max = svcpu->slb_max; | 86 | to_book3s(vcpu)->slb_shadow_max = svcpu->slb_max; |
83 | svcpu_put(svcpu); | 87 | svcpu_put(svcpu); |
@@ -110,12 +114,26 @@ void kvmppc_copy_to_svcpu(struct kvmppc_book3s_shadow_vcpu *svcpu, | |||
110 | svcpu->ctr = vcpu->arch.ctr; | 114 | svcpu->ctr = vcpu->arch.ctr; |
111 | svcpu->lr = vcpu->arch.lr; | 115 | svcpu->lr = vcpu->arch.lr; |
112 | svcpu->pc = vcpu->arch.pc; | 116 | svcpu->pc = vcpu->arch.pc; |
117 | svcpu->in_use = true; | ||
113 | } | 118 | } |
114 | 119 | ||
115 | /* Copy data touched by real-mode code from shadow vcpu back to vcpu */ | 120 | /* Copy data touched by real-mode code from shadow vcpu back to vcpu */ |
116 | void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu, | 121 | void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu, |
117 | struct kvmppc_book3s_shadow_vcpu *svcpu) | 122 | struct kvmppc_book3s_shadow_vcpu *svcpu) |
118 | { | 123 | { |
124 | /* | ||
125 | * vcpu_put would just call us again because in_use hasn't | ||
126 | * been updated yet. | ||
127 | */ | ||
128 | preempt_disable(); | ||
129 | |||
130 | /* | ||
131 | * Maybe we were already preempted and synced the svcpu from | ||
132 | * our preempt notifiers. Don't bother touching this svcpu then. | ||
133 | */ | ||
134 | if (!svcpu->in_use) | ||
135 | goto out; | ||
136 | |||
119 | vcpu->arch.gpr[0] = svcpu->gpr[0]; | 137 | vcpu->arch.gpr[0] = svcpu->gpr[0]; |
120 | vcpu->arch.gpr[1] = svcpu->gpr[1]; | 138 | vcpu->arch.gpr[1] = svcpu->gpr[1]; |
121 | vcpu->arch.gpr[2] = svcpu->gpr[2]; | 139 | vcpu->arch.gpr[2] = svcpu->gpr[2]; |
@@ -139,6 +157,10 @@ void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu, | |||
139 | vcpu->arch.fault_dar = svcpu->fault_dar; | 157 | vcpu->arch.fault_dar = svcpu->fault_dar; |
140 | vcpu->arch.fault_dsisr = svcpu->fault_dsisr; | 158 | vcpu->arch.fault_dsisr = svcpu->fault_dsisr; |
141 | vcpu->arch.last_inst = svcpu->last_inst; | 159 | vcpu->arch.last_inst = svcpu->last_inst; |
160 | svcpu->in_use = false; | ||
161 | |||
162 | out: | ||
163 | preempt_enable(); | ||
142 | } | 164 | } |
143 | 165 | ||
144 | static int kvmppc_core_check_requests_pr(struct kvm_vcpu *vcpu) | 166 | static int kvmppc_core_check_requests_pr(struct kvm_vcpu *vcpu) |
diff --git a/arch/powerpc/kvm/book3s_rmhandlers.S b/arch/powerpc/kvm/book3s_rmhandlers.S index a38c4c9edab8..c3c5231adade 100644 --- a/arch/powerpc/kvm/book3s_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_rmhandlers.S | |||
@@ -153,15 +153,11 @@ _GLOBAL(kvmppc_entry_trampoline) | |||
153 | 153 | ||
154 | li r6, MSR_IR | MSR_DR | 154 | li r6, MSR_IR | MSR_DR |
155 | andc r6, r5, r6 /* Clear DR and IR in MSR value */ | 155 | andc r6, r5, r6 /* Clear DR and IR in MSR value */ |
156 | #ifdef CONFIG_PPC_BOOK3S_32 | ||
157 | /* | 156 | /* |
158 | * Set EE in HOST_MSR so that it's enabled when we get into our | 157 | * Set EE in HOST_MSR so that it's enabled when we get into our |
159 | * C exit handler function. On 64-bit we delay enabling | 158 | * C exit handler function. |
160 | * interrupts until we have finished transferring stuff | ||
161 | * to or from the PACA. | ||
162 | */ | 159 | */ |
163 | ori r5, r5, MSR_EE | 160 | ori r5, r5, MSR_EE |
164 | #endif | ||
165 | mtsrr0 r7 | 161 | mtsrr0 r7 |
166 | mtsrr1 r6 | 162 | mtsrr1 r6 |
167 | RFI | 163 | RFI |
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 53e65a210b9a..0591e05db74b 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c | |||
@@ -681,7 +681,7 @@ int kvmppc_core_check_requests(struct kvm_vcpu *vcpu) | |||
681 | int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | 681 | int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) |
682 | { | 682 | { |
683 | int ret, s; | 683 | int ret, s; |
684 | struct thread_struct thread; | 684 | struct debug_reg debug; |
685 | #ifdef CONFIG_PPC_FPU | 685 | #ifdef CONFIG_PPC_FPU |
686 | struct thread_fp_state fp; | 686 | struct thread_fp_state fp; |
687 | int fpexc_mode; | 687 | int fpexc_mode; |
@@ -723,9 +723,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
723 | #endif | 723 | #endif |
724 | 724 | ||
725 | /* Switch to guest debug context */ | 725 | /* Switch to guest debug context */ |
726 | thread.debug = vcpu->arch.shadow_dbg_reg; | 726 | debug = vcpu->arch.shadow_dbg_reg; |
727 | switch_booke_debug_regs(&thread); | 727 | switch_booke_debug_regs(&debug); |
728 | thread.debug = current->thread.debug; | 728 | debug = current->thread.debug; |
729 | current->thread.debug = vcpu->arch.shadow_dbg_reg; | 729 | current->thread.debug = vcpu->arch.shadow_dbg_reg; |
730 | 730 | ||
731 | kvmppc_fix_ee_before_entry(); | 731 | kvmppc_fix_ee_before_entry(); |
@@ -736,8 +736,8 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
736 | We also get here with interrupts enabled. */ | 736 | We also get here with interrupts enabled. */ |
737 | 737 | ||
738 | /* Switch back to user space debug context */ | 738 | /* Switch back to user space debug context */ |
739 | switch_booke_debug_regs(&thread); | 739 | switch_booke_debug_regs(&debug); |
740 | current->thread.debug = thread.debug; | 740 | current->thread.debug = debug; |
741 | 741 | ||
742 | #ifdef CONFIG_PPC_FPU | 742 | #ifdef CONFIG_PPC_FPU |
743 | kvmppc_save_guest_fp(vcpu); | 743 | kvmppc_save_guest_fp(vcpu); |
diff --git a/arch/powerpc/platforms/powernv/opal-lpc.c b/arch/powerpc/platforms/powernv/opal-lpc.c index e7e59e4f9892..79d83cad3d67 100644 --- a/arch/powerpc/platforms/powernv/opal-lpc.c +++ b/arch/powerpc/platforms/powernv/opal-lpc.c | |||
@@ -24,25 +24,25 @@ static int opal_lpc_chip_id = -1; | |||
24 | static u8 opal_lpc_inb(unsigned long port) | 24 | static u8 opal_lpc_inb(unsigned long port) |
25 | { | 25 | { |
26 | int64_t rc; | 26 | int64_t rc; |
27 | uint32_t data; | 27 | __be32 data; |
28 | 28 | ||
29 | if (opal_lpc_chip_id < 0 || port > 0xffff) | 29 | if (opal_lpc_chip_id < 0 || port > 0xffff) |
30 | return 0xff; | 30 | return 0xff; |
31 | rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 1); | 31 | rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 1); |
32 | return rc ? 0xff : data; | 32 | return rc ? 0xff : be32_to_cpu(data); |
33 | } | 33 | } |
34 | 34 | ||
35 | static __le16 __opal_lpc_inw(unsigned long port) | 35 | static __le16 __opal_lpc_inw(unsigned long port) |
36 | { | 36 | { |
37 | int64_t rc; | 37 | int64_t rc; |
38 | uint32_t data; | 38 | __be32 data; |
39 | 39 | ||
40 | if (opal_lpc_chip_id < 0 || port > 0xfffe) | 40 | if (opal_lpc_chip_id < 0 || port > 0xfffe) |
41 | return 0xffff; | 41 | return 0xffff; |
42 | if (port & 1) | 42 | if (port & 1) |
43 | return (__le16)opal_lpc_inb(port) << 8 | opal_lpc_inb(port + 1); | 43 | return (__le16)opal_lpc_inb(port) << 8 | opal_lpc_inb(port + 1); |
44 | rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 2); | 44 | rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 2); |
45 | return rc ? 0xffff : data; | 45 | return rc ? 0xffff : be32_to_cpu(data); |
46 | } | 46 | } |
47 | static u16 opal_lpc_inw(unsigned long port) | 47 | static u16 opal_lpc_inw(unsigned long port) |
48 | { | 48 | { |
@@ -52,7 +52,7 @@ static u16 opal_lpc_inw(unsigned long port) | |||
52 | static __le32 __opal_lpc_inl(unsigned long port) | 52 | static __le32 __opal_lpc_inl(unsigned long port) |
53 | { | 53 | { |
54 | int64_t rc; | 54 | int64_t rc; |
55 | uint32_t data; | 55 | __be32 data; |
56 | 56 | ||
57 | if (opal_lpc_chip_id < 0 || port > 0xfffc) | 57 | if (opal_lpc_chip_id < 0 || port > 0xfffc) |
58 | return 0xffffffff; | 58 | return 0xffffffff; |
@@ -62,7 +62,7 @@ static __le32 __opal_lpc_inl(unsigned long port) | |||
62 | (__le32)opal_lpc_inb(port + 2) << 8 | | 62 | (__le32)opal_lpc_inb(port + 2) << 8 | |
63 | opal_lpc_inb(port + 3); | 63 | opal_lpc_inb(port + 3); |
64 | rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 4); | 64 | rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 4); |
65 | return rc ? 0xffffffff : data; | 65 | return rc ? 0xffffffff : be32_to_cpu(data); |
66 | } | 66 | } |
67 | 67 | ||
68 | static u32 opal_lpc_inl(unsigned long port) | 68 | static u32 opal_lpc_inl(unsigned long port) |
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c index 4d99a8fd55ac..4fbf276ac99e 100644 --- a/arch/powerpc/platforms/powernv/opal-xscom.c +++ b/arch/powerpc/platforms/powernv/opal-xscom.c | |||
@@ -96,9 +96,11 @@ static int opal_scom_read(scom_map_t map, u64 reg, u64 *value) | |||
96 | { | 96 | { |
97 | struct opal_scom_map *m = map; | 97 | struct opal_scom_map *m = map; |
98 | int64_t rc; | 98 | int64_t rc; |
99 | __be64 v; | ||
99 | 100 | ||
100 | reg = opal_scom_unmangle(reg); | 101 | reg = opal_scom_unmangle(reg); |
101 | rc = opal_xscom_read(m->chip, m->addr + reg, (uint64_t *)__pa(value)); | 102 | rc = opal_xscom_read(m->chip, m->addr + reg, (__be64 *)__pa(&v)); |
103 | *value = be64_to_cpu(v); | ||
102 | return opal_xscom_err_xlate(rc); | 104 | return opal_xscom_err_xlate(rc); |
103 | } | 105 | } |
104 | 106 | ||
diff --git a/arch/powerpc/platforms/pseries/lparcfg.c b/arch/powerpc/platforms/pseries/lparcfg.c index e738007eae64..c9fecf09b8fa 100644 --- a/arch/powerpc/platforms/pseries/lparcfg.c +++ b/arch/powerpc/platforms/pseries/lparcfg.c | |||
@@ -157,7 +157,7 @@ static void parse_ppp_data(struct seq_file *m) | |||
157 | { | 157 | { |
158 | struct hvcall_ppp_data ppp_data; | 158 | struct hvcall_ppp_data ppp_data; |
159 | struct device_node *root; | 159 | struct device_node *root; |
160 | const int *perf_level; | 160 | const __be32 *perf_level; |
161 | int rc; | 161 | int rc; |
162 | 162 | ||
163 | rc = h_get_ppp(&ppp_data); | 163 | rc = h_get_ppp(&ppp_data); |
@@ -201,7 +201,7 @@ static void parse_ppp_data(struct seq_file *m) | |||
201 | perf_level = of_get_property(root, | 201 | perf_level = of_get_property(root, |
202 | "ibm,partition-performance-parameters-level", | 202 | "ibm,partition-performance-parameters-level", |
203 | NULL); | 203 | NULL); |
204 | if (perf_level && (*perf_level >= 1)) { | 204 | if (perf_level && (be32_to_cpup(perf_level) >= 1)) { |
205 | seq_printf(m, | 205 | seq_printf(m, |
206 | "physical_procs_allocated_to_virtualization=%d\n", | 206 | "physical_procs_allocated_to_virtualization=%d\n", |
207 | ppp_data.phys_platform_procs); | 207 | ppp_data.phys_platform_procs); |
@@ -435,7 +435,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v) | |||
435 | int partition_potential_processors; | 435 | int partition_potential_processors; |
436 | int partition_active_processors; | 436 | int partition_active_processors; |
437 | struct device_node *rtas_node; | 437 | struct device_node *rtas_node; |
438 | const int *lrdrp = NULL; | 438 | const __be32 *lrdrp = NULL; |
439 | 439 | ||
440 | rtas_node = of_find_node_by_path("/rtas"); | 440 | rtas_node = of_find_node_by_path("/rtas"); |
441 | if (rtas_node) | 441 | if (rtas_node) |
@@ -444,7 +444,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v) | |||
444 | if (lrdrp == NULL) { | 444 | if (lrdrp == NULL) { |
445 | partition_potential_processors = vdso_data->processorCount; | 445 | partition_potential_processors = vdso_data->processorCount; |
446 | } else { | 446 | } else { |
447 | partition_potential_processors = *(lrdrp + 4); | 447 | partition_potential_processors = be32_to_cpup(lrdrp + 4); |
448 | } | 448 | } |
449 | of_node_put(rtas_node); | 449 | of_node_put(rtas_node); |
450 | 450 | ||
@@ -654,7 +654,7 @@ static int lparcfg_data(struct seq_file *m, void *v) | |||
654 | const char *model = ""; | 654 | const char *model = ""; |
655 | const char *system_id = ""; | 655 | const char *system_id = ""; |
656 | const char *tmp; | 656 | const char *tmp; |
657 | const unsigned int *lp_index_ptr; | 657 | const __be32 *lp_index_ptr; |
658 | unsigned int lp_index = 0; | 658 | unsigned int lp_index = 0; |
659 | 659 | ||
660 | seq_printf(m, "%s %s\n", MODULE_NAME, MODULE_VERS); | 660 | seq_printf(m, "%s %s\n", MODULE_NAME, MODULE_VERS); |
@@ -670,7 +670,7 @@ static int lparcfg_data(struct seq_file *m, void *v) | |||
670 | lp_index_ptr = of_get_property(rootdn, "ibm,partition-no", | 670 | lp_index_ptr = of_get_property(rootdn, "ibm,partition-no", |
671 | NULL); | 671 | NULL); |
672 | if (lp_index_ptr) | 672 | if (lp_index_ptr) |
673 | lp_index = *lp_index_ptr; | 673 | lp_index = be32_to_cpup(lp_index_ptr); |
674 | of_node_put(rootdn); | 674 | of_node_put(rootdn); |
675 | } | 675 | } |
676 | seq_printf(m, "serial_number=%s\n", system_id); | 676 | seq_printf(m, "serial_number=%s\n", system_id); |
diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c index 6d2f0abce6fa..0c882e83c4ce 100644 --- a/arch/powerpc/platforms/pseries/msi.c +++ b/arch/powerpc/platforms/pseries/msi.c | |||
@@ -130,7 +130,8 @@ static int check_req(struct pci_dev *pdev, int nvec, char *prop_name) | |||
130 | { | 130 | { |
131 | struct device_node *dn; | 131 | struct device_node *dn; |
132 | struct pci_dn *pdn; | 132 | struct pci_dn *pdn; |
133 | const u32 *req_msi; | 133 | const __be32 *p; |
134 | u32 req_msi; | ||
134 | 135 | ||
135 | pdn = pci_get_pdn(pdev); | 136 | pdn = pci_get_pdn(pdev); |
136 | if (!pdn) | 137 | if (!pdn) |
@@ -138,19 +139,20 @@ static int check_req(struct pci_dev *pdev, int nvec, char *prop_name) | |||
138 | 139 | ||
139 | dn = pdn->node; | 140 | dn = pdn->node; |
140 | 141 | ||
141 | req_msi = of_get_property(dn, prop_name, NULL); | 142 | p = of_get_property(dn, prop_name, NULL); |
142 | if (!req_msi) { | 143 | if (!p) { |
143 | pr_debug("rtas_msi: No %s on %s\n", prop_name, dn->full_name); | 144 | pr_debug("rtas_msi: No %s on %s\n", prop_name, dn->full_name); |
144 | return -ENOENT; | 145 | return -ENOENT; |
145 | } | 146 | } |
146 | 147 | ||
147 | if (*req_msi < nvec) { | 148 | req_msi = be32_to_cpup(p); |
149 | if (req_msi < nvec) { | ||
148 | pr_debug("rtas_msi: %s requests < %d MSIs\n", prop_name, nvec); | 150 | pr_debug("rtas_msi: %s requests < %d MSIs\n", prop_name, nvec); |
149 | 151 | ||
150 | if (*req_msi == 0) /* Be paranoid */ | 152 | if (req_msi == 0) /* Be paranoid */ |
151 | return -ENOSPC; | 153 | return -ENOSPC; |
152 | 154 | ||
153 | return *req_msi; | 155 | return req_msi; |
154 | } | 156 | } |
155 | 157 | ||
156 | return 0; | 158 | return 0; |
@@ -171,7 +173,7 @@ static int check_req_msix(struct pci_dev *pdev, int nvec) | |||
171 | static struct device_node *find_pe_total_msi(struct pci_dev *dev, int *total) | 173 | static struct device_node *find_pe_total_msi(struct pci_dev *dev, int *total) |
172 | { | 174 | { |
173 | struct device_node *dn; | 175 | struct device_node *dn; |
174 | const u32 *p; | 176 | const __be32 *p; |
175 | 177 | ||
176 | dn = of_node_get(pci_device_to_OF_node(dev)); | 178 | dn = of_node_get(pci_device_to_OF_node(dev)); |
177 | while (dn) { | 179 | while (dn) { |
@@ -179,7 +181,7 @@ static struct device_node *find_pe_total_msi(struct pci_dev *dev, int *total) | |||
179 | if (p) { | 181 | if (p) { |
180 | pr_debug("rtas_msi: found prop on dn %s\n", | 182 | pr_debug("rtas_msi: found prop on dn %s\n", |
181 | dn->full_name); | 183 | dn->full_name); |
182 | *total = *p; | 184 | *total = be32_to_cpup(p); |
183 | return dn; | 185 | return dn; |
184 | } | 186 | } |
185 | 187 | ||
@@ -232,13 +234,13 @@ struct msi_counts { | |||
232 | static void *count_non_bridge_devices(struct device_node *dn, void *data) | 234 | static void *count_non_bridge_devices(struct device_node *dn, void *data) |
233 | { | 235 | { |
234 | struct msi_counts *counts = data; | 236 | struct msi_counts *counts = data; |
235 | const u32 *p; | 237 | const __be32 *p; |
236 | u32 class; | 238 | u32 class; |
237 | 239 | ||
238 | pr_debug("rtas_msi: counting %s\n", dn->full_name); | 240 | pr_debug("rtas_msi: counting %s\n", dn->full_name); |
239 | 241 | ||
240 | p = of_get_property(dn, "class-code", NULL); | 242 | p = of_get_property(dn, "class-code", NULL); |
241 | class = p ? *p : 0; | 243 | class = p ? be32_to_cpup(p) : 0; |
242 | 244 | ||
243 | if ((class >> 8) != PCI_CLASS_BRIDGE_PCI) | 245 | if ((class >> 8) != PCI_CLASS_BRIDGE_PCI) |
244 | counts->num_devices++; | 246 | counts->num_devices++; |
@@ -249,7 +251,7 @@ static void *count_non_bridge_devices(struct device_node *dn, void *data) | |||
249 | static void *count_spare_msis(struct device_node *dn, void *data) | 251 | static void *count_spare_msis(struct device_node *dn, void *data) |
250 | { | 252 | { |
251 | struct msi_counts *counts = data; | 253 | struct msi_counts *counts = data; |
252 | const u32 *p; | 254 | const __be32 *p; |
253 | int req; | 255 | int req; |
254 | 256 | ||
255 | if (dn == counts->requestor) | 257 | if (dn == counts->requestor) |
@@ -260,11 +262,11 @@ static void *count_spare_msis(struct device_node *dn, void *data) | |||
260 | req = 0; | 262 | req = 0; |
261 | p = of_get_property(dn, "ibm,req#msi", NULL); | 263 | p = of_get_property(dn, "ibm,req#msi", NULL); |
262 | if (p) | 264 | if (p) |
263 | req = *p; | 265 | req = be32_to_cpup(p); |
264 | 266 | ||
265 | p = of_get_property(dn, "ibm,req#msi-x", NULL); | 267 | p = of_get_property(dn, "ibm,req#msi-x", NULL); |
266 | if (p) | 268 | if (p) |
267 | req = max(req, (int)*p); | 269 | req = max(req, (int)be32_to_cpup(p)); |
268 | } | 270 | } |
269 | 271 | ||
270 | if (req < counts->quota) | 272 | if (req < counts->quota) |
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c index 7bfaf58d4664..d7096f2f7751 100644 --- a/arch/powerpc/platforms/pseries/nvram.c +++ b/arch/powerpc/platforms/pseries/nvram.c | |||
@@ -43,8 +43,8 @@ static char nvram_buf[NVRW_CNT]; /* assume this is in the first 4GB */ | |||
43 | static DEFINE_SPINLOCK(nvram_lock); | 43 | static DEFINE_SPINLOCK(nvram_lock); |
44 | 44 | ||
45 | struct err_log_info { | 45 | struct err_log_info { |
46 | int error_type; | 46 | __be32 error_type; |
47 | unsigned int seq_num; | 47 | __be32 seq_num; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | struct nvram_os_partition { | 50 | struct nvram_os_partition { |
@@ -79,9 +79,9 @@ static const char *pseries_nvram_os_partitions[] = { | |||
79 | }; | 79 | }; |
80 | 80 | ||
81 | struct oops_log_info { | 81 | struct oops_log_info { |
82 | u16 version; | 82 | __be16 version; |
83 | u16 report_length; | 83 | __be16 report_length; |
84 | u64 timestamp; | 84 | __be64 timestamp; |
85 | } __attribute__((packed)); | 85 | } __attribute__((packed)); |
86 | 86 | ||
87 | static void oops_to_nvram(struct kmsg_dumper *dumper, | 87 | static void oops_to_nvram(struct kmsg_dumper *dumper, |
@@ -291,8 +291,8 @@ int nvram_write_os_partition(struct nvram_os_partition *part, char * buff, | |||
291 | length = part->size; | 291 | length = part->size; |
292 | } | 292 | } |
293 | 293 | ||
294 | info.error_type = err_type; | 294 | info.error_type = cpu_to_be32(err_type); |
295 | info.seq_num = error_log_cnt; | 295 | info.seq_num = cpu_to_be32(error_log_cnt); |
296 | 296 | ||
297 | tmp_index = part->index; | 297 | tmp_index = part->index; |
298 | 298 | ||
@@ -364,8 +364,8 @@ int nvram_read_partition(struct nvram_os_partition *part, char *buff, | |||
364 | } | 364 | } |
365 | 365 | ||
366 | if (part->os_partition) { | 366 | if (part->os_partition) { |
367 | *error_log_cnt = info.seq_num; | 367 | *error_log_cnt = be32_to_cpu(info.seq_num); |
368 | *err_type = info.error_type; | 368 | *err_type = be32_to_cpu(info.error_type); |
369 | } | 369 | } |
370 | 370 | ||
371 | return 0; | 371 | return 0; |
@@ -529,9 +529,9 @@ static int zip_oops(size_t text_len) | |||
529 | pr_err("nvram: logging uncompressed oops/panic report\n"); | 529 | pr_err("nvram: logging uncompressed oops/panic report\n"); |
530 | return -1; | 530 | return -1; |
531 | } | 531 | } |
532 | oops_hdr->version = OOPS_HDR_VERSION; | 532 | oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); |
533 | oops_hdr->report_length = (u16) zipped_len; | 533 | oops_hdr->report_length = cpu_to_be16(zipped_len); |
534 | oops_hdr->timestamp = get_seconds(); | 534 | oops_hdr->timestamp = cpu_to_be64(get_seconds()); |
535 | return 0; | 535 | return 0; |
536 | } | 536 | } |
537 | 537 | ||
@@ -574,9 +574,9 @@ static int nvram_pstore_write(enum pstore_type_id type, | |||
574 | clobbering_unread_rtas_event()) | 574 | clobbering_unread_rtas_event()) |
575 | return -1; | 575 | return -1; |
576 | 576 | ||
577 | oops_hdr->version = OOPS_HDR_VERSION; | 577 | oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); |
578 | oops_hdr->report_length = (u16) size; | 578 | oops_hdr->report_length = cpu_to_be16(size); |
579 | oops_hdr->timestamp = get_seconds(); | 579 | oops_hdr->timestamp = cpu_to_be64(get_seconds()); |
580 | 580 | ||
581 | if (compressed) | 581 | if (compressed) |
582 | err_type = ERR_TYPE_KERNEL_PANIC_GZ; | 582 | err_type = ERR_TYPE_KERNEL_PANIC_GZ; |
@@ -670,16 +670,16 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type, | |||
670 | size_t length, hdr_size; | 670 | size_t length, hdr_size; |
671 | 671 | ||
672 | oops_hdr = (struct oops_log_info *)buff; | 672 | oops_hdr = (struct oops_log_info *)buff; |
673 | if (oops_hdr->version < OOPS_HDR_VERSION) { | 673 | if (be16_to_cpu(oops_hdr->version) < OOPS_HDR_VERSION) { |
674 | /* Old format oops header had 2-byte record size */ | 674 | /* Old format oops header had 2-byte record size */ |
675 | hdr_size = sizeof(u16); | 675 | hdr_size = sizeof(u16); |
676 | length = oops_hdr->version; | 676 | length = be16_to_cpu(oops_hdr->version); |
677 | time->tv_sec = 0; | 677 | time->tv_sec = 0; |
678 | time->tv_nsec = 0; | 678 | time->tv_nsec = 0; |
679 | } else { | 679 | } else { |
680 | hdr_size = sizeof(*oops_hdr); | 680 | hdr_size = sizeof(*oops_hdr); |
681 | length = oops_hdr->report_length; | 681 | length = be16_to_cpu(oops_hdr->report_length); |
682 | time->tv_sec = oops_hdr->timestamp; | 682 | time->tv_sec = be64_to_cpu(oops_hdr->timestamp); |
683 | time->tv_nsec = 0; | 683 | time->tv_nsec = 0; |
684 | } | 684 | } |
685 | *buf = kmalloc(length, GFP_KERNEL); | 685 | *buf = kmalloc(length, GFP_KERNEL); |
@@ -889,13 +889,13 @@ static void oops_to_nvram(struct kmsg_dumper *dumper, | |||
889 | kmsg_dump_get_buffer(dumper, false, | 889 | kmsg_dump_get_buffer(dumper, false, |
890 | oops_data, oops_data_sz, &text_len); | 890 | oops_data, oops_data_sz, &text_len); |
891 | err_type = ERR_TYPE_KERNEL_PANIC; | 891 | err_type = ERR_TYPE_KERNEL_PANIC; |
892 | oops_hdr->version = OOPS_HDR_VERSION; | 892 | oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); |
893 | oops_hdr->report_length = (u16) text_len; | 893 | oops_hdr->report_length = cpu_to_be16(text_len); |
894 | oops_hdr->timestamp = get_seconds(); | 894 | oops_hdr->timestamp = cpu_to_be64(get_seconds()); |
895 | } | 895 | } |
896 | 896 | ||
897 | (void) nvram_write_os_partition(&oops_log_partition, oops_buf, | 897 | (void) nvram_write_os_partition(&oops_log_partition, oops_buf, |
898 | (int) (sizeof(*oops_hdr) + oops_hdr->report_length), err_type, | 898 | (int) (sizeof(*oops_hdr) + text_len), err_type, |
899 | ++oops_count); | 899 | ++oops_count); |
900 | 900 | ||
901 | spin_unlock_irqrestore(&lock, flags); | 901 | spin_unlock_irqrestore(&lock, flags); |
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c index 5f93856cdf47..70670a2d9cf2 100644 --- a/arch/powerpc/platforms/pseries/pci.c +++ b/arch/powerpc/platforms/pseries/pci.c | |||
@@ -113,7 +113,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge) | |||
113 | { | 113 | { |
114 | struct device_node *dn, *pdn; | 114 | struct device_node *dn, *pdn; |
115 | struct pci_bus *bus; | 115 | struct pci_bus *bus; |
116 | const uint32_t *pcie_link_speed_stats; | 116 | const __be32 *pcie_link_speed_stats; |
117 | 117 | ||
118 | bus = bridge->bus; | 118 | bus = bridge->bus; |
119 | 119 | ||
@@ -122,7 +122,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge) | |||
122 | return 0; | 122 | return 0; |
123 | 123 | ||
124 | for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) { | 124 | for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) { |
125 | pcie_link_speed_stats = (const uint32_t *) of_get_property(pdn, | 125 | pcie_link_speed_stats = of_get_property(pdn, |
126 | "ibm,pcie-link-speed-stats", NULL); | 126 | "ibm,pcie-link-speed-stats", NULL); |
127 | if (pcie_link_speed_stats) | 127 | if (pcie_link_speed_stats) |
128 | break; | 128 | break; |
@@ -135,7 +135,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge) | |||
135 | return 0; | 135 | return 0; |
136 | } | 136 | } |
137 | 137 | ||
138 | switch (pcie_link_speed_stats[0]) { | 138 | switch (be32_to_cpup(pcie_link_speed_stats)) { |
139 | case 0x01: | 139 | case 0x01: |
140 | bus->max_bus_speed = PCIE_SPEED_2_5GT; | 140 | bus->max_bus_speed = PCIE_SPEED_2_5GT; |
141 | break; | 141 | break; |
@@ -147,7 +147,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge) | |||
147 | break; | 147 | break; |
148 | } | 148 | } |
149 | 149 | ||
150 | switch (pcie_link_speed_stats[1]) { | 150 | switch (be32_to_cpup(pcie_link_speed_stats)) { |
151 | case 0x01: | 151 | case 0x01: |
152 | bus->cur_bus_speed = PCIE_SPEED_2_5GT; | 152 | bus->cur_bus_speed = PCIE_SPEED_2_5GT; |
153 | break; | 153 | break; |
diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 7b95f29e3174..3baff31e58cf 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile | |||
@@ -6,7 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ | |||
6 | checksum.o strlen.o div64.o div64-generic.o | 6 | checksum.o strlen.o div64.o div64-generic.o |
7 | 7 | ||
8 | # Extracted from libgcc | 8 | # Extracted from libgcc |
9 | lib-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ | 9 | obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ |
10 | ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ | 10 | ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ |
11 | udiv_qrnnd.o | 11 | udiv_qrnnd.o |
12 | 12 | ||
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 8358dc144959..0f9e94537eee 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h | |||
@@ -619,7 +619,7 @@ static inline unsigned long pte_present(pte_t pte) | |||
619 | } | 619 | } |
620 | 620 | ||
621 | #define pte_accessible pte_accessible | 621 | #define pte_accessible pte_accessible |
622 | static inline unsigned long pte_accessible(pte_t a) | 622 | static inline unsigned long pte_accessible(struct mm_struct *mm, pte_t a) |
623 | { | 623 | { |
624 | return pte_val(a) & _PAGE_VALID; | 624 | return pte_val(a) & _PAGE_VALID; |
625 | } | 625 | } |
@@ -847,7 +847,7 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, | |||
847 | * SUN4V NOTE: _PAGE_VALID is the same value in both the SUN4U | 847 | * SUN4V NOTE: _PAGE_VALID is the same value in both the SUN4U |
848 | * and SUN4V pte layout, so this inline test is fine. | 848 | * and SUN4V pte layout, so this inline test is fine. |
849 | */ | 849 | */ |
850 | if (likely(mm != &init_mm) && pte_accessible(orig)) | 850 | if (likely(mm != &init_mm) && pte_accessible(mm, orig)) |
851 | tlb_batch_add(mm, addr, ptep, orig, fullmm); | 851 | tlb_batch_add(mm, addr, ptep, orig, fullmm); |
852 | } | 852 | } |
853 | 853 | ||
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index e903c71f7e69..0952ecd60eca 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -26,6 +26,7 @@ config X86 | |||
26 | select HAVE_AOUT if X86_32 | 26 | select HAVE_AOUT if X86_32 |
27 | select HAVE_UNSTABLE_SCHED_CLOCK | 27 | select HAVE_UNSTABLE_SCHED_CLOCK |
28 | select ARCH_SUPPORTS_NUMA_BALANCING | 28 | select ARCH_SUPPORTS_NUMA_BALANCING |
29 | select ARCH_SUPPORTS_INT128 if X86_64 | ||
29 | select ARCH_WANTS_PROT_NUMA_PROT_NONE | 30 | select ARCH_WANTS_PROT_NUMA_PROT_NONE |
30 | select HAVE_IDE | 31 | select HAVE_IDE |
31 | select HAVE_OPROFILE | 32 | select HAVE_OPROFILE |
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 3d1999458709..bbc8b12fa443 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
@@ -452,9 +452,16 @@ static inline int pte_present(pte_t a) | |||
452 | } | 452 | } |
453 | 453 | ||
454 | #define pte_accessible pte_accessible | 454 | #define pte_accessible pte_accessible |
455 | static inline int pte_accessible(pte_t a) | 455 | static inline bool pte_accessible(struct mm_struct *mm, pte_t a) |
456 | { | 456 | { |
457 | return pte_flags(a) & _PAGE_PRESENT; | 457 | if (pte_flags(a) & _PAGE_PRESENT) |
458 | return true; | ||
459 | |||
460 | if ((pte_flags(a) & (_PAGE_PROTNONE | _PAGE_NUMA)) && | ||
461 | mm_tlb_flush_pending(mm)) | ||
462 | return true; | ||
463 | |||
464 | return false; | ||
458 | } | 465 | } |
459 | 466 | ||
460 | static inline int pte_hidden(pte_t pte) | 467 | static inline int pte_hidden(pte_t pte) |
diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h index 8729723636fd..c8b051933b1b 100644 --- a/arch/x86/include/asm/preempt.h +++ b/arch/x86/include/asm/preempt.h | |||
@@ -8,6 +8,12 @@ | |||
8 | DECLARE_PER_CPU(int, __preempt_count); | 8 | DECLARE_PER_CPU(int, __preempt_count); |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * We use the PREEMPT_NEED_RESCHED bit as an inverted NEED_RESCHED such | ||
12 | * that a decrement hitting 0 means we can and should reschedule. | ||
13 | */ | ||
14 | #define PREEMPT_ENABLED (0 + PREEMPT_NEED_RESCHED) | ||
15 | |||
16 | /* | ||
11 | * We mask the PREEMPT_NEED_RESCHED bit so as not to confuse all current users | 17 | * We mask the PREEMPT_NEED_RESCHED bit so as not to confuse all current users |
12 | * that think a non-zero value indicates we cannot preempt. | 18 | * that think a non-zero value indicates we cannot preempt. |
13 | */ | 19 | */ |
@@ -74,6 +80,11 @@ static __always_inline void __preempt_count_sub(int val) | |||
74 | __this_cpu_add_4(__preempt_count, -val); | 80 | __this_cpu_add_4(__preempt_count, -val); |
75 | } | 81 | } |
76 | 82 | ||
83 | /* | ||
84 | * Because we keep PREEMPT_NEED_RESCHED set when we do _not_ need to reschedule | ||
85 | * a decrement which hits zero means we have no preempt_count and should | ||
86 | * reschedule. | ||
87 | */ | ||
77 | static __always_inline bool __preempt_count_dec_and_test(void) | 88 | static __always_inline bool __preempt_count_dec_and_test(void) |
78 | { | 89 | { |
79 | GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e"); | 90 | GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e"); |
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index dc1ec0dff939..ea04b342c026 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c | |||
@@ -387,7 +387,8 @@ static void init_intel(struct cpuinfo_x86 *c) | |||
387 | set_cpu_cap(c, X86_FEATURE_PEBS); | 387 | set_cpu_cap(c, X86_FEATURE_PEBS); |
388 | } | 388 | } |
389 | 389 | ||
390 | if (c->x86 == 6 && c->x86_model == 29 && cpu_has_clflush) | 390 | if (c->x86 == 6 && cpu_has_clflush && |
391 | (c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47)) | ||
391 | set_cpu_cap(c, X86_FEATURE_CLFLUSH_MONITOR); | 392 | set_cpu_cap(c, X86_FEATURE_CLFLUSH_MONITOR); |
392 | 393 | ||
393 | #ifdef CONFIG_X86_64 | 394 | #ifdef CONFIG_X86_64 |
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h index fd00bb29425d..c1a861829d81 100644 --- a/arch/x86/kernel/cpu/perf_event.h +++ b/arch/x86/kernel/cpu/perf_event.h | |||
@@ -262,11 +262,20 @@ struct cpu_hw_events { | |||
262 | __EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK, \ | 262 | __EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK, \ |
263 | HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_ST_HSW) | 263 | HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_ST_HSW) |
264 | 264 | ||
265 | #define EVENT_CONSTRAINT_END \ | 265 | /* |
266 | EVENT_CONSTRAINT(0, 0, 0) | 266 | * We define the end marker as having a weight of -1 |
267 | * to enable blacklisting of events using a counter bitmask | ||
268 | * of zero and thus a weight of zero. | ||
269 | * The end marker has a weight that cannot possibly be | ||
270 | * obtained from counting the bits in the bitmask. | ||
271 | */ | ||
272 | #define EVENT_CONSTRAINT_END { .weight = -1 } | ||
267 | 273 | ||
274 | /* | ||
275 | * Check for end marker with weight == -1 | ||
276 | */ | ||
268 | #define for_each_event_constraint(e, c) \ | 277 | #define for_each_event_constraint(e, c) \ |
269 | for ((e) = (c); (e)->weight; (e)++) | 278 | for ((e) = (c); (e)->weight != -1; (e)++) |
270 | 279 | ||
271 | /* | 280 | /* |
272 | * Extra registers for specific events. | 281 | * Extra registers for specific events. |
diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c index dd74e46828c0..0596e8e0cc19 100644 --- a/arch/x86/mm/gup.c +++ b/arch/x86/mm/gup.c | |||
@@ -83,6 +83,12 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr, | |||
83 | pte_t pte = gup_get_pte(ptep); | 83 | pte_t pte = gup_get_pte(ptep); |
84 | struct page *page; | 84 | struct page *page; |
85 | 85 | ||
86 | /* Similar to the PMD case, NUMA hinting must take slow path */ | ||
87 | if (pte_numa(pte)) { | ||
88 | pte_unmap(ptep); | ||
89 | return 0; | ||
90 | } | ||
91 | |||
86 | if ((pte_flags(pte) & (mask | _PAGE_SPECIAL)) != mask) { | 92 | if ((pte_flags(pte) & (mask | _PAGE_SPECIAL)) != mask) { |
87 | pte_unmap(ptep); | 93 | pte_unmap(ptep); |
88 | return 0; | 94 | return 0; |
@@ -167,6 +173,13 @@ static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end, | |||
167 | if (pmd_none(pmd) || pmd_trans_splitting(pmd)) | 173 | if (pmd_none(pmd) || pmd_trans_splitting(pmd)) |
168 | return 0; | 174 | return 0; |
169 | if (unlikely(pmd_large(pmd))) { | 175 | if (unlikely(pmd_large(pmd))) { |
176 | /* | ||
177 | * NUMA hinting faults need to be handled in the GUP | ||
178 | * slowpath for accounting purposes and so that they | ||
179 | * can be serialised against THP migration. | ||
180 | */ | ||
181 | if (pmd_numa(pmd)) | ||
182 | return 0; | ||
170 | if (!gup_huge_pmd(pmd, addr, next, write, pages, nr)) | 183 | if (!gup_huge_pmd(pmd, addr, next, write, pages, nr)) |
171 | return 0; | 184 | return 0; |
172 | } else { | 185 | } else { |
diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c index ba6cf8e9aa0a..b91ce75bd35d 100644 --- a/block/blk-mq-sysfs.c +++ b/block/blk-mq-sysfs.c | |||
@@ -335,9 +335,22 @@ static struct kobj_type blk_mq_hw_ktype = { | |||
335 | void blk_mq_unregister_disk(struct gendisk *disk) | 335 | void blk_mq_unregister_disk(struct gendisk *disk) |
336 | { | 336 | { |
337 | struct request_queue *q = disk->queue; | 337 | struct request_queue *q = disk->queue; |
338 | struct blk_mq_hw_ctx *hctx; | ||
339 | struct blk_mq_ctx *ctx; | ||
340 | int i, j; | ||
341 | |||
342 | queue_for_each_hw_ctx(q, hctx, i) { | ||
343 | hctx_for_each_ctx(hctx, ctx, j) { | ||
344 | kobject_del(&ctx->kobj); | ||
345 | kobject_put(&ctx->kobj); | ||
346 | } | ||
347 | kobject_del(&hctx->kobj); | ||
348 | kobject_put(&hctx->kobj); | ||
349 | } | ||
338 | 350 | ||
339 | kobject_uevent(&q->mq_kobj, KOBJ_REMOVE); | 351 | kobject_uevent(&q->mq_kobj, KOBJ_REMOVE); |
340 | kobject_del(&q->mq_kobj); | 352 | kobject_del(&q->mq_kobj); |
353 | kobject_put(&q->mq_kobj); | ||
341 | 354 | ||
342 | kobject_put(&disk_to_dev(disk)->kobj); | 355 | kobject_put(&disk_to_dev(disk)->kobj); |
343 | } | 356 | } |
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 5d9248526d78..4770de5707b9 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -348,7 +348,6 @@ source "drivers/acpi/apei/Kconfig" | |||
348 | config ACPI_EXTLOG | 348 | config ACPI_EXTLOG |
349 | tristate "Extended Error Log support" | 349 | tristate "Extended Error Log support" |
350 | depends on X86_MCE && X86_LOCAL_APIC | 350 | depends on X86_MCE && X86_LOCAL_APIC |
351 | select EFI | ||
352 | select UEFI_CPER | 351 | select UEFI_CPER |
353 | default n | 352 | default n |
354 | help | 353 | help |
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 6745fe137b9e..e60390597372 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c | |||
@@ -162,6 +162,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = { | |||
162 | { "80860F14", (unsigned long)&byt_sdio_dev_desc }, | 162 | { "80860F14", (unsigned long)&byt_sdio_dev_desc }, |
163 | { "80860F41", (unsigned long)&byt_i2c_dev_desc }, | 163 | { "80860F41", (unsigned long)&byt_i2c_dev_desc }, |
164 | { "INT33B2", }, | 164 | { "INT33B2", }, |
165 | { "INT33FC", }, | ||
165 | 166 | ||
166 | { "INT3430", (unsigned long)&lpt_dev_desc }, | 167 | { "INT3430", (unsigned long)&lpt_dev_desc }, |
167 | { "INT3431", (unsigned long)&lpt_dev_desc }, | 168 | { "INT3431", (unsigned long)&lpt_dev_desc }, |
diff --git a/drivers/acpi/apei/Kconfig b/drivers/acpi/apei/Kconfig index 786294bb682c..3650b2183227 100644 --- a/drivers/acpi/apei/Kconfig +++ b/drivers/acpi/apei/Kconfig | |||
@@ -2,7 +2,6 @@ config ACPI_APEI | |||
2 | bool "ACPI Platform Error Interface (APEI)" | 2 | bool "ACPI Platform Error Interface (APEI)" |
3 | select MISC_FILESYSTEMS | 3 | select MISC_FILESYSTEMS |
4 | select PSTORE | 4 | select PSTORE |
5 | select EFI | ||
6 | select UEFI_CPER | 5 | select UEFI_CPER |
7 | depends on X86 | 6 | depends on X86 |
8 | help | 7 | help |
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c index 26311f23c824..cb1d557fc22c 100644 --- a/drivers/acpi/apei/erst.c +++ b/drivers/acpi/apei/erst.c | |||
@@ -942,6 +942,7 @@ static int erst_clearer(enum pstore_type_id type, u64 id, int count, | |||
942 | static struct pstore_info erst_info = { | 942 | static struct pstore_info erst_info = { |
943 | .owner = THIS_MODULE, | 943 | .owner = THIS_MODULE, |
944 | .name = "erst", | 944 | .name = "erst", |
945 | .flags = PSTORE_FLAGS_FRAGILE, | ||
945 | .open = erst_open_pstore, | 946 | .open = erst_open_pstore, |
946 | .close = erst_close_pstore, | 947 | .close = erst_close_pstore, |
947 | .read = erst_reader, | 948 | .read = erst_reader, |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 14f1e9506338..c0ed4f273cf2 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -1238,15 +1238,6 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1238 | if (rc) | 1238 | if (rc) |
1239 | return rc; | 1239 | return rc; |
1240 | 1240 | ||
1241 | /* AHCI controllers often implement SFF compatible interface. | ||
1242 | * Grab all PCI BARs just in case. | ||
1243 | */ | ||
1244 | rc = pcim_iomap_regions_request_all(pdev, 1 << ahci_pci_bar, DRV_NAME); | ||
1245 | if (rc == -EBUSY) | ||
1246 | pcim_pin_device(pdev); | ||
1247 | if (rc) | ||
1248 | return rc; | ||
1249 | |||
1250 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | 1241 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && |
1251 | (pdev->device == 0x2652 || pdev->device == 0x2653)) { | 1242 | (pdev->device == 0x2652 || pdev->device == 0x2653)) { |
1252 | u8 map; | 1243 | u8 map; |
@@ -1263,6 +1254,15 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1263 | } | 1254 | } |
1264 | } | 1255 | } |
1265 | 1256 | ||
1257 | /* AHCI controllers often implement SFF compatible interface. | ||
1258 | * Grab all PCI BARs just in case. | ||
1259 | */ | ||
1260 | rc = pcim_iomap_regions_request_all(pdev, 1 << ahci_pci_bar, DRV_NAME); | ||
1261 | if (rc == -EBUSY) | ||
1262 | pcim_pin_device(pdev); | ||
1263 | if (rc) | ||
1264 | return rc; | ||
1265 | |||
1266 | hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); | 1266 | hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); |
1267 | if (!hpriv) | 1267 | if (!hpriv) |
1268 | return -ENOMEM; | 1268 | return -ENOMEM; |
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c index ae2d73fe321e..3e23e9941dad 100644 --- a/drivers/ata/ahci_imx.c +++ b/drivers/ata/ahci_imx.c | |||
@@ -113,7 +113,7 @@ static int imx6q_sata_init(struct device *dev, void __iomem *mmio) | |||
113 | /* | 113 | /* |
114 | * set PHY Paremeters, two steps to configure the GPR13, | 114 | * set PHY Paremeters, two steps to configure the GPR13, |
115 | * one write for rest of parameters, mask of first write | 115 | * one write for rest of parameters, mask of first write |
116 | * is 0x07fffffd, and the other one write for setting | 116 | * is 0x07ffffff, and the other one write for setting |
117 | * the mpll_clk_en. | 117 | * the mpll_clk_en. |
118 | */ | 118 | */ |
119 | regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK | 119 | regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK |
@@ -124,6 +124,7 @@ static int imx6q_sata_init(struct device *dev, void __iomem *mmio) | |||
124 | | IMX6Q_GPR13_SATA_TX_ATTEN_MASK | 124 | | IMX6Q_GPR13_SATA_TX_ATTEN_MASK |
125 | | IMX6Q_GPR13_SATA_TX_BOOST_MASK | 125 | | IMX6Q_GPR13_SATA_TX_BOOST_MASK |
126 | | IMX6Q_GPR13_SATA_TX_LVL_MASK | 126 | | IMX6Q_GPR13_SATA_TX_LVL_MASK |
127 | | IMX6Q_GPR13_SATA_MPLL_CLK_EN | ||
127 | | IMX6Q_GPR13_SATA_TX_EDGE_RATE | 128 | | IMX6Q_GPR13_SATA_TX_EDGE_RATE |
128 | , IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB | 129 | , IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB |
129 | | IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M | 130 | | IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 75b93678bbcd..1393a5890ed5 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -2149,9 +2149,16 @@ static int ata_dev_config_ncq(struct ata_device *dev, | |||
2149 | "failed to get NCQ Send/Recv Log Emask 0x%x\n", | 2149 | "failed to get NCQ Send/Recv Log Emask 0x%x\n", |
2150 | err_mask); | 2150 | err_mask); |
2151 | } else { | 2151 | } else { |
2152 | u8 *cmds = dev->ncq_send_recv_cmds; | ||
2153 | |||
2152 | dev->flags |= ATA_DFLAG_NCQ_SEND_RECV; | 2154 | dev->flags |= ATA_DFLAG_NCQ_SEND_RECV; |
2153 | memcpy(dev->ncq_send_recv_cmds, ap->sector_buf, | 2155 | memcpy(cmds, ap->sector_buf, ATA_LOG_NCQ_SEND_RECV_SIZE); |
2154 | ATA_LOG_NCQ_SEND_RECV_SIZE); | 2156 | |
2157 | if (dev->horkage & ATA_HORKAGE_NO_NCQ_TRIM) { | ||
2158 | ata_dev_dbg(dev, "disabling queued TRIM support\n"); | ||
2159 | cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] &= | ||
2160 | ~ATA_LOG_NCQ_SEND_RECV_DSM_TRIM; | ||
2161 | } | ||
2155 | } | 2162 | } |
2156 | } | 2163 | } |
2157 | 2164 | ||
@@ -4156,6 +4163,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
4156 | { "ST3320[68]13AS", "SD1[5-9]", ATA_HORKAGE_NONCQ | | 4163 | { "ST3320[68]13AS", "SD1[5-9]", ATA_HORKAGE_NONCQ | |
4157 | ATA_HORKAGE_FIRMWARE_WARN }, | 4164 | ATA_HORKAGE_FIRMWARE_WARN }, |
4158 | 4165 | ||
4166 | /* Seagate Momentus SpinPoint M8 seem to have FPMDA_AA issues */ | ||
4167 | { "ST1000LM024 HN-M101MBB", "2AR10001", ATA_HORKAGE_BROKEN_FPDMA_AA }, | ||
4168 | |||
4159 | /* Blacklist entries taken from Silicon Image 3124/3132 | 4169 | /* Blacklist entries taken from Silicon Image 3124/3132 |
4160 | Windows driver .inf file - also several Linux problem reports */ | 4170 | Windows driver .inf file - also several Linux problem reports */ |
4161 | { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, }, | 4171 | { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, }, |
@@ -4202,6 +4212,10 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
4202 | { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER }, | 4212 | { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER }, |
4203 | { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, | 4213 | { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, |
4204 | 4214 | ||
4215 | /* devices that don't properly handle queued TRIM commands */ | ||
4216 | { "Micron_M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, | ||
4217 | { "Crucial_CT???M500SSD1", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, | ||
4218 | |||
4205 | /* End Marker */ | 4219 | /* End Marker */ |
4206 | { } | 4220 | { } |
4207 | }; | 4221 | }; |
@@ -6519,6 +6533,7 @@ static int __init ata_parse_force_one(char **cur, | |||
6519 | { "norst", .lflags = ATA_LFLAG_NO_HRST | ATA_LFLAG_NO_SRST }, | 6533 | { "norst", .lflags = ATA_LFLAG_NO_HRST | ATA_LFLAG_NO_SRST }, |
6520 | { "rstonce", .lflags = ATA_LFLAG_RST_ONCE }, | 6534 | { "rstonce", .lflags = ATA_LFLAG_RST_ONCE }, |
6521 | { "atapi_dmadir", .horkage_on = ATA_HORKAGE_ATAPI_DMADIR }, | 6535 | { "atapi_dmadir", .horkage_on = ATA_HORKAGE_ATAPI_DMADIR }, |
6536 | { "disable", .horkage_on = ATA_HORKAGE_DISABLE }, | ||
6522 | }; | 6537 | }; |
6523 | char *start = *cur, *p = *cur; | 6538 | char *start = *cur, *p = *cur; |
6524 | char *id, *val, *endp; | 6539 | char *id, *val, *endp; |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index ab58556d347c..377eb889f555 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -3872,6 +3872,27 @@ void ata_scsi_hotplug(struct work_struct *work) | |||
3872 | return; | 3872 | return; |
3873 | } | 3873 | } |
3874 | 3874 | ||
3875 | /* | ||
3876 | * XXX - UGLY HACK | ||
3877 | * | ||
3878 | * The block layer suspend/resume path is fundamentally broken due | ||
3879 | * to freezable kthreads and workqueue and may deadlock if a block | ||
3880 | * device gets removed while resume is in progress. I don't know | ||
3881 | * what the solution is short of removing freezable kthreads and | ||
3882 | * workqueues altogether. | ||
3883 | * | ||
3884 | * The following is an ugly hack to avoid kicking off device | ||
3885 | * removal while freezer is active. This is a joke but does avoid | ||
3886 | * this particular deadlock scenario. | ||
3887 | * | ||
3888 | * https://bugzilla.kernel.org/show_bug.cgi?id=62801 | ||
3889 | * http://marc.info/?l=linux-kernel&m=138695698516487 | ||
3890 | */ | ||
3891 | #ifdef CONFIG_FREEZER | ||
3892 | while (pm_freezing) | ||
3893 | msleep(10); | ||
3894 | #endif | ||
3895 | |||
3875 | DPRINTK("ENTER\n"); | 3896 | DPRINTK("ENTER\n"); |
3876 | mutex_lock(&ap->scsi_scan_mutex); | 3897 | mutex_lock(&ap->scsi_scan_mutex); |
3877 | 3898 | ||
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index f370fc13aea5..a2e69d26266d 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <linux/module.h> | 1 | #include <linux/module.h> |
2 | |||
2 | #include <linux/moduleparam.h> | 3 | #include <linux/moduleparam.h> |
3 | #include <linux/sched.h> | 4 | #include <linux/sched.h> |
4 | #include <linux/fs.h> | 5 | #include <linux/fs.h> |
@@ -65,7 +66,7 @@ enum { | |||
65 | NULL_Q_MQ = 2, | 66 | NULL_Q_MQ = 2, |
66 | }; | 67 | }; |
67 | 68 | ||
68 | static int submit_queues = 1; | 69 | static int submit_queues; |
69 | module_param(submit_queues, int, S_IRUGO); | 70 | module_param(submit_queues, int, S_IRUGO); |
70 | MODULE_PARM_DESC(submit_queues, "Number of submission queues"); | 71 | MODULE_PARM_DESC(submit_queues, "Number of submission queues"); |
71 | 72 | ||
@@ -101,9 +102,9 @@ static int hw_queue_depth = 64; | |||
101 | module_param(hw_queue_depth, int, S_IRUGO); | 102 | module_param(hw_queue_depth, int, S_IRUGO); |
102 | MODULE_PARM_DESC(hw_queue_depth, "Queue depth for each hardware queue. Default: 64"); | 103 | MODULE_PARM_DESC(hw_queue_depth, "Queue depth for each hardware queue. Default: 64"); |
103 | 104 | ||
104 | static bool use_per_node_hctx = true; | 105 | static bool use_per_node_hctx = false; |
105 | module_param(use_per_node_hctx, bool, S_IRUGO); | 106 | module_param(use_per_node_hctx, bool, S_IRUGO); |
106 | MODULE_PARM_DESC(use_per_node_hctx, "Use per-node allocation for hardware context queues. Default: true"); | 107 | MODULE_PARM_DESC(use_per_node_hctx, "Use per-node allocation for hardware context queues. Default: false"); |
107 | 108 | ||
108 | static void put_tag(struct nullb_queue *nq, unsigned int tag) | 109 | static void put_tag(struct nullb_queue *nq, unsigned int tag) |
109 | { | 110 | { |
@@ -346,8 +347,37 @@ static int null_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq) | |||
346 | 347 | ||
347 | static struct blk_mq_hw_ctx *null_alloc_hctx(struct blk_mq_reg *reg, unsigned int hctx_index) | 348 | static struct blk_mq_hw_ctx *null_alloc_hctx(struct blk_mq_reg *reg, unsigned int hctx_index) |
348 | { | 349 | { |
349 | return kzalloc_node(sizeof(struct blk_mq_hw_ctx), GFP_KERNEL, | 350 | int b_size = DIV_ROUND_UP(reg->nr_hw_queues, nr_online_nodes); |
350 | hctx_index); | 351 | int tip = (reg->nr_hw_queues % nr_online_nodes); |
352 | int node = 0, i, n; | ||
353 | |||
354 | /* | ||
355 | * Split submit queues evenly wrt to the number of nodes. If uneven, | ||
356 | * fill the first buckets with one extra, until the rest is filled with | ||
357 | * no extra. | ||
358 | */ | ||
359 | for (i = 0, n = 1; i < hctx_index; i++, n++) { | ||
360 | if (n % b_size == 0) { | ||
361 | n = 0; | ||
362 | node++; | ||
363 | |||
364 | tip--; | ||
365 | if (!tip) | ||
366 | b_size = reg->nr_hw_queues / nr_online_nodes; | ||
367 | } | ||
368 | } | ||
369 | |||
370 | /* | ||
371 | * A node might not be online, therefore map the relative node id to the | ||
372 | * real node id. | ||
373 | */ | ||
374 | for_each_online_node(n) { | ||
375 | if (!node) | ||
376 | break; | ||
377 | node--; | ||
378 | } | ||
379 | |||
380 | return kzalloc_node(sizeof(struct blk_mq_hw_ctx), GFP_KERNEL, n); | ||
351 | } | 381 | } |
352 | 382 | ||
353 | static void null_free_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_index) | 383 | static void null_free_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_index) |
@@ -355,16 +385,24 @@ static void null_free_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_index) | |||
355 | kfree(hctx); | 385 | kfree(hctx); |
356 | } | 386 | } |
357 | 387 | ||
388 | static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq) | ||
389 | { | ||
390 | BUG_ON(!nullb); | ||
391 | BUG_ON(!nq); | ||
392 | |||
393 | init_waitqueue_head(&nq->wait); | ||
394 | nq->queue_depth = nullb->queue_depth; | ||
395 | } | ||
396 | |||
358 | static int null_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, | 397 | static int null_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, |
359 | unsigned int index) | 398 | unsigned int index) |
360 | { | 399 | { |
361 | struct nullb *nullb = data; | 400 | struct nullb *nullb = data; |
362 | struct nullb_queue *nq = &nullb->queues[index]; | 401 | struct nullb_queue *nq = &nullb->queues[index]; |
363 | 402 | ||
364 | init_waitqueue_head(&nq->wait); | ||
365 | nq->queue_depth = nullb->queue_depth; | ||
366 | nullb->nr_queues++; | ||
367 | hctx->driver_data = nq; | 403 | hctx->driver_data = nq; |
404 | null_init_queue(nullb, nq); | ||
405 | nullb->nr_queues++; | ||
368 | 406 | ||
369 | return 0; | 407 | return 0; |
370 | } | 408 | } |
@@ -417,13 +455,13 @@ static int setup_commands(struct nullb_queue *nq) | |||
417 | 455 | ||
418 | nq->cmds = kzalloc(nq->queue_depth * sizeof(*cmd), GFP_KERNEL); | 456 | nq->cmds = kzalloc(nq->queue_depth * sizeof(*cmd), GFP_KERNEL); |
419 | if (!nq->cmds) | 457 | if (!nq->cmds) |
420 | return 1; | 458 | return -ENOMEM; |
421 | 459 | ||
422 | tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG; | 460 | tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG; |
423 | nq->tag_map = kzalloc(tag_size * sizeof(unsigned long), GFP_KERNEL); | 461 | nq->tag_map = kzalloc(tag_size * sizeof(unsigned long), GFP_KERNEL); |
424 | if (!nq->tag_map) { | 462 | if (!nq->tag_map) { |
425 | kfree(nq->cmds); | 463 | kfree(nq->cmds); |
426 | return 1; | 464 | return -ENOMEM; |
427 | } | 465 | } |
428 | 466 | ||
429 | for (i = 0; i < nq->queue_depth; i++) { | 467 | for (i = 0; i < nq->queue_depth; i++) { |
@@ -454,33 +492,37 @@ static void cleanup_queues(struct nullb *nullb) | |||
454 | 492 | ||
455 | static int setup_queues(struct nullb *nullb) | 493 | static int setup_queues(struct nullb *nullb) |
456 | { | 494 | { |
457 | struct nullb_queue *nq; | 495 | nullb->queues = kzalloc(submit_queues * sizeof(struct nullb_queue), |
458 | int i; | 496 | GFP_KERNEL); |
459 | |||
460 | nullb->queues = kzalloc(submit_queues * sizeof(*nq), GFP_KERNEL); | ||
461 | if (!nullb->queues) | 497 | if (!nullb->queues) |
462 | return 1; | 498 | return -ENOMEM; |
463 | 499 | ||
464 | nullb->nr_queues = 0; | 500 | nullb->nr_queues = 0; |
465 | nullb->queue_depth = hw_queue_depth; | 501 | nullb->queue_depth = hw_queue_depth; |
466 | 502 | ||
467 | if (queue_mode == NULL_Q_MQ) | 503 | return 0; |
468 | return 0; | 504 | } |
505 | |||
506 | static int init_driver_queues(struct nullb *nullb) | ||
507 | { | ||
508 | struct nullb_queue *nq; | ||
509 | int i, ret = 0; | ||
469 | 510 | ||
470 | for (i = 0; i < submit_queues; i++) { | 511 | for (i = 0; i < submit_queues; i++) { |
471 | nq = &nullb->queues[i]; | 512 | nq = &nullb->queues[i]; |
472 | init_waitqueue_head(&nq->wait); | 513 | |
473 | nq->queue_depth = hw_queue_depth; | 514 | null_init_queue(nullb, nq); |
474 | if (setup_commands(nq)) | 515 | |
475 | break; | 516 | ret = setup_commands(nq); |
517 | if (ret) | ||
518 | goto err_queue; | ||
476 | nullb->nr_queues++; | 519 | nullb->nr_queues++; |
477 | } | 520 | } |
478 | 521 | ||
479 | if (i == submit_queues) | 522 | return 0; |
480 | return 0; | 523 | err_queue: |
481 | |||
482 | cleanup_queues(nullb); | 524 | cleanup_queues(nullb); |
483 | return 1; | 525 | return ret; |
484 | } | 526 | } |
485 | 527 | ||
486 | static int null_add_dev(void) | 528 | static int null_add_dev(void) |
@@ -518,11 +560,13 @@ static int null_add_dev(void) | |||
518 | } else if (queue_mode == NULL_Q_BIO) { | 560 | } else if (queue_mode == NULL_Q_BIO) { |
519 | nullb->q = blk_alloc_queue_node(GFP_KERNEL, home_node); | 561 | nullb->q = blk_alloc_queue_node(GFP_KERNEL, home_node); |
520 | blk_queue_make_request(nullb->q, null_queue_bio); | 562 | blk_queue_make_request(nullb->q, null_queue_bio); |
563 | init_driver_queues(nullb); | ||
521 | } else { | 564 | } else { |
522 | nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node); | 565 | nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node); |
523 | blk_queue_prep_rq(nullb->q, null_rq_prep_fn); | 566 | blk_queue_prep_rq(nullb->q, null_rq_prep_fn); |
524 | if (nullb->q) | 567 | if (nullb->q) |
525 | blk_queue_softirq_done(nullb->q, null_softirq_done_fn); | 568 | blk_queue_softirq_done(nullb->q, null_softirq_done_fn); |
569 | init_driver_queues(nullb); | ||
526 | } | 570 | } |
527 | 571 | ||
528 | if (!nullb->q) | 572 | if (!nullb->q) |
@@ -579,7 +623,13 @@ static int __init null_init(void) | |||
579 | } | 623 | } |
580 | #endif | 624 | #endif |
581 | 625 | ||
582 | if (submit_queues > nr_cpu_ids) | 626 | if (queue_mode == NULL_Q_MQ && use_per_node_hctx) { |
627 | if (submit_queues < nr_online_nodes) { | ||
628 | pr_warn("null_blk: submit_queues param is set to %u.", | ||
629 | nr_online_nodes); | ||
630 | submit_queues = nr_online_nodes; | ||
631 | } | ||
632 | } else if (submit_queues > nr_cpu_ids) | ||
583 | submit_queues = nr_cpu_ids; | 633 | submit_queues = nr_cpu_ids; |
584 | else if (!submit_queues) | 634 | else if (!submit_queues) |
585 | submit_queues = 1; | 635 | submit_queues = 1; |
diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index 9199c93be926..eb6e1e0e8db2 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c | |||
@@ -5269,7 +5269,7 @@ const char *skd_skdev_state_to_str(enum skd_drvr_state state) | |||
5269 | } | 5269 | } |
5270 | } | 5270 | } |
5271 | 5271 | ||
5272 | const char *skd_skmsg_state_to_str(enum skd_fit_msg_state state) | 5272 | static const char *skd_skmsg_state_to_str(enum skd_fit_msg_state state) |
5273 | { | 5273 | { |
5274 | switch (state) { | 5274 | switch (state) { |
5275 | case SKD_MSG_STATE_IDLE: | 5275 | case SKD_MSG_STATE_IDLE: |
@@ -5281,7 +5281,7 @@ const char *skd_skmsg_state_to_str(enum skd_fit_msg_state state) | |||
5281 | } | 5281 | } |
5282 | } | 5282 | } |
5283 | 5283 | ||
5284 | const char *skd_skreq_state_to_str(enum skd_req_state state) | 5284 | static const char *skd_skreq_state_to_str(enum skd_req_state state) |
5285 | { | 5285 | { |
5286 | switch (state) { | 5286 | switch (state) { |
5287 | case SKD_REQ_STATE_IDLE: | 5287 | case SKD_REQ_STATE_IDLE: |
diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c index 7be41e676a64..00a3abe103a5 100644 --- a/drivers/clk/clk-s2mps11.c +++ b/drivers/clk/clk-s2mps11.c | |||
@@ -60,7 +60,7 @@ static int s2mps11_clk_prepare(struct clk_hw *hw) | |||
60 | struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); | 60 | struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); |
61 | int ret; | 61 | int ret; |
62 | 62 | ||
63 | ret = regmap_update_bits(s2mps11->iodev->regmap, | 63 | ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, |
64 | S2MPS11_REG_RTC_CTRL, | 64 | S2MPS11_REG_RTC_CTRL, |
65 | s2mps11->mask, s2mps11->mask); | 65 | s2mps11->mask, s2mps11->mask); |
66 | if (!ret) | 66 | if (!ret) |
@@ -74,7 +74,7 @@ static void s2mps11_clk_unprepare(struct clk_hw *hw) | |||
74 | struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); | 74 | struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); |
75 | int ret; | 75 | int ret; |
76 | 76 | ||
77 | ret = regmap_update_bits(s2mps11->iodev->regmap, S2MPS11_REG_RTC_CTRL, | 77 | ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, S2MPS11_REG_RTC_CTRL, |
78 | s2mps11->mask, ~s2mps11->mask); | 78 | s2mps11->mask, ~s2mps11->mask); |
79 | 79 | ||
80 | if (!ret) | 80 | if (!ret) |
@@ -174,7 +174,7 @@ static int s2mps11_clk_probe(struct platform_device *pdev) | |||
174 | s2mps11_clk->hw.init = &s2mps11_clks_init[i]; | 174 | s2mps11_clk->hw.init = &s2mps11_clks_init[i]; |
175 | s2mps11_clk->mask = 1 << i; | 175 | s2mps11_clk->mask = 1 << i; |
176 | 176 | ||
177 | ret = regmap_read(s2mps11_clk->iodev->regmap, | 177 | ret = regmap_read(s2mps11_clk->iodev->regmap_pmic, |
178 | S2MPS11_REG_RTC_CTRL, &val); | 178 | S2MPS11_REG_RTC_CTRL, &val); |
179 | if (ret < 0) | 179 | if (ret < 0) |
180 | goto err_reg; | 180 | goto err_reg; |
diff --git a/drivers/clk/samsung/clk-s3c64xx.c b/drivers/clk/samsung/clk-s3c64xx.c index 7d2c84265947..8e27aee6887e 100644 --- a/drivers/clk/samsung/clk-s3c64xx.c +++ b/drivers/clk/samsung/clk-s3c64xx.c | |||
@@ -331,8 +331,8 @@ static struct samsung_clock_alias s3c64xx_clock_aliases[] = { | |||
331 | ALIAS(HCLK_HSMMC1, "s3c-sdhci.1", "mmc_busclk.0"), | 331 | ALIAS(HCLK_HSMMC1, "s3c-sdhci.1", "mmc_busclk.0"), |
332 | ALIAS(HCLK_HSMMC0, "s3c-sdhci.0", "hsmmc"), | 332 | ALIAS(HCLK_HSMMC0, "s3c-sdhci.0", "hsmmc"), |
333 | ALIAS(HCLK_HSMMC0, "s3c-sdhci.0", "mmc_busclk.0"), | 333 | ALIAS(HCLK_HSMMC0, "s3c-sdhci.0", "mmc_busclk.0"), |
334 | ALIAS(HCLK_DMA1, NULL, "dma1"), | 334 | ALIAS(HCLK_DMA1, "dma-pl080s.1", "apb_pclk"), |
335 | ALIAS(HCLK_DMA0, NULL, "dma0"), | 335 | ALIAS(HCLK_DMA0, "dma-pl080s.0", "apb_pclk"), |
336 | ALIAS(HCLK_CAMIF, "s3c-camif", "camif"), | 336 | ALIAS(HCLK_CAMIF, "s3c-camif", "camif"), |
337 | ALIAS(HCLK_LCD, "s3c-fb", "lcd"), | 337 | ALIAS(HCLK_LCD, "s3c-fb", "lcd"), |
338 | ALIAS(PCLK_SPI1, "s3c6410-spi.1", "spi"), | 338 | ALIAS(PCLK_SPI1, "s3c6410-spi.1", "spi"), |
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 5c07a56962db..634c4d6dd45a 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig | |||
@@ -75,6 +75,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK | |||
75 | config CLKSRC_EFM32 | 75 | config CLKSRC_EFM32 |
76 | bool "Clocksource for Energy Micro's EFM32 SoCs" if !ARCH_EFM32 | 76 | bool "Clocksource for Energy Micro's EFM32 SoCs" if !ARCH_EFM32 |
77 | depends on OF && ARM && (ARCH_EFM32 || COMPILE_TEST) | 77 | depends on OF && ARM && (ARCH_EFM32 || COMPILE_TEST) |
78 | select CLKSRC_MMIO | ||
78 | default ARCH_EFM32 | 79 | default ARCH_EFM32 |
79 | help | 80 | help |
80 | Support to use the timers of EFM32 SoCs as clock source and clock | 81 | Support to use the timers of EFM32 SoCs as clock source and clock |
diff --git a/drivers/clocksource/clksrc-of.c b/drivers/clocksource/clksrc-of.c index 35639cf4e5a2..b9ddd9e3a2f5 100644 --- a/drivers/clocksource/clksrc-of.c +++ b/drivers/clocksource/clksrc-of.c | |||
@@ -35,6 +35,5 @@ void __init clocksource_of_init(void) | |||
35 | 35 | ||
36 | init_func = match->data; | 36 | init_func = match->data; |
37 | init_func(np); | 37 | init_func(np); |
38 | of_node_put(np); | ||
39 | } | 38 | } |
40 | } | 39 | } |
diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c index 45ba8aecc729..2a2ea2717f3a 100644 --- a/drivers/clocksource/dw_apb_timer_of.c +++ b/drivers/clocksource/dw_apb_timer_of.c | |||
@@ -108,12 +108,11 @@ static void __init add_clocksource(struct device_node *source_timer) | |||
108 | 108 | ||
109 | static u64 read_sched_clock(void) | 109 | static u64 read_sched_clock(void) |
110 | { | 110 | { |
111 | return __raw_readl(sched_io_base); | 111 | return ~__raw_readl(sched_io_base); |
112 | } | 112 | } |
113 | 113 | ||
114 | static const struct of_device_id sptimer_ids[] __initconst = { | 114 | static const struct of_device_id sptimer_ids[] __initconst = { |
115 | { .compatible = "picochip,pc3x2-rtc" }, | 115 | { .compatible = "picochip,pc3x2-rtc" }, |
116 | { .compatible = "snps,dw-apb-timer-sp" }, | ||
117 | { /* Sentinel */ }, | 116 | { /* Sentinel */ }, |
118 | }; | 117 | }; |
119 | 118 | ||
@@ -151,4 +150,6 @@ static void __init dw_apb_timer_init(struct device_node *timer) | |||
151 | num_called++; | 150 | num_called++; |
152 | } | 151 | } |
153 | CLOCKSOURCE_OF_DECLARE(pc3x2_timer, "picochip,pc3x2-timer", dw_apb_timer_init); | 152 | CLOCKSOURCE_OF_DECLARE(pc3x2_timer, "picochip,pc3x2-timer", dw_apb_timer_init); |
154 | CLOCKSOURCE_OF_DECLARE(apb_timer, "snps,dw-apb-timer-osc", dw_apb_timer_init); | 153 | CLOCKSOURCE_OF_DECLARE(apb_timer_osc, "snps,dw-apb-timer-osc", dw_apb_timer_init); |
154 | CLOCKSOURCE_OF_DECLARE(apb_timer_sp, "snps,dw-apb-timer-sp", dw_apb_timer_init); | ||
155 | CLOCKSOURCE_OF_DECLARE(apb_timer, "snps,dw-apb-timer", dw_apb_timer_init); | ||
diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c index 2fb4695a28d8..a4f6119aafd8 100644 --- a/drivers/clocksource/sun4i_timer.c +++ b/drivers/clocksource/sun4i_timer.c | |||
@@ -179,6 +179,9 @@ static void __init sun4i_timer_init(struct device_node *node) | |||
179 | writel(TIMER_CTL_CLK_SRC(TIMER_CTL_CLK_SRC_OSC24M), | 179 | writel(TIMER_CTL_CLK_SRC(TIMER_CTL_CLK_SRC_OSC24M), |
180 | timer_base + TIMER_CTL_REG(0)); | 180 | timer_base + TIMER_CTL_REG(0)); |
181 | 181 | ||
182 | /* Make sure timer is stopped before playing with interrupts */ | ||
183 | sun4i_clkevt_time_stop(0); | ||
184 | |||
182 | ret = setup_irq(irq, &sun4i_timer_irq); | 185 | ret = setup_irq(irq, &sun4i_timer_irq); |
183 | if (ret) | 186 | if (ret) |
184 | pr_warn("failed to setup irq %d\n", irq); | 187 | pr_warn("failed to setup irq %d\n", irq); |
diff --git a/drivers/clocksource/time-armada-370-xp.c b/drivers/clocksource/time-armada-370-xp.c index d8e47e502785..4e7f6802e840 100644 --- a/drivers/clocksource/time-armada-370-xp.c +++ b/drivers/clocksource/time-armada-370-xp.c | |||
@@ -256,11 +256,6 @@ static void __init armada_370_xp_timer_common_init(struct device_node *np) | |||
256 | ticks_per_jiffy = (timer_clk + HZ / 2) / HZ; | 256 | ticks_per_jiffy = (timer_clk + HZ / 2) / HZ; |
257 | 257 | ||
258 | /* | 258 | /* |
259 | * Set scale and timer for sched_clock. | ||
260 | */ | ||
261 | sched_clock_register(armada_370_xp_read_sched_clock, 32, timer_clk); | ||
262 | |||
263 | /* | ||
264 | * Setup free-running clocksource timer (interrupts | 259 | * Setup free-running clocksource timer (interrupts |
265 | * disabled). | 260 | * disabled). |
266 | */ | 261 | */ |
@@ -270,6 +265,11 @@ static void __init armada_370_xp_timer_common_init(struct device_node *np) | |||
270 | timer_ctrl_clrset(0, TIMER0_EN | TIMER0_RELOAD_EN | | 265 | timer_ctrl_clrset(0, TIMER0_EN | TIMER0_RELOAD_EN | |
271 | TIMER0_DIV(TIMER_DIVIDER_SHIFT)); | 266 | TIMER0_DIV(TIMER_DIVIDER_SHIFT)); |
272 | 267 | ||
268 | /* | ||
269 | * Set scale and timer for sched_clock. | ||
270 | */ | ||
271 | sched_clock_register(armada_370_xp_read_sched_clock, 32, timer_clk); | ||
272 | |||
273 | clocksource_mmio_init(timer_base + TIMER0_VAL_OFF, | 273 | clocksource_mmio_init(timer_base + TIMER0_VAL_OFF, |
274 | "armada_370_xp_clocksource", | 274 | "armada_370_xp_clocksource", |
275 | timer_clk, 300, 32, clocksource_mmio_readl_down); | 275 | timer_clk, 300, 32, clocksource_mmio_readl_down); |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 02d534da22dd..16d7b4ac94be 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -828,6 +828,12 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) | |||
828 | int ret = 0; | 828 | int ret = 0; |
829 | 829 | ||
830 | memcpy(&new_policy, policy, sizeof(*policy)); | 830 | memcpy(&new_policy, policy, sizeof(*policy)); |
831 | |||
832 | /* Use the default policy if its valid. */ | ||
833 | if (cpufreq_driver->setpolicy) | ||
834 | cpufreq_parse_governor(policy->governor->name, | ||
835 | &new_policy.policy, NULL); | ||
836 | |||
831 | /* assure that the starting sequence is run in cpufreq_set_policy */ | 837 | /* assure that the starting sequence is run in cpufreq_set_policy */ |
832 | policy->governor = NULL; | 838 | policy->governor = NULL; |
833 | 839 | ||
@@ -845,8 +851,7 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) | |||
845 | 851 | ||
846 | #ifdef CONFIG_HOTPLUG_CPU | 852 | #ifdef CONFIG_HOTPLUG_CPU |
847 | static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, | 853 | static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, |
848 | unsigned int cpu, struct device *dev, | 854 | unsigned int cpu, struct device *dev) |
849 | bool frozen) | ||
850 | { | 855 | { |
851 | int ret = 0; | 856 | int ret = 0; |
852 | unsigned long flags; | 857 | unsigned long flags; |
@@ -877,11 +882,7 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, | |||
877 | } | 882 | } |
878 | } | 883 | } |
879 | 884 | ||
880 | /* Don't touch sysfs links during light-weight init */ | 885 | return sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); |
881 | if (!frozen) | ||
882 | ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); | ||
883 | |||
884 | return ret; | ||
885 | } | 886 | } |
886 | #endif | 887 | #endif |
887 | 888 | ||
@@ -926,6 +927,27 @@ err_free_policy: | |||
926 | return NULL; | 927 | return NULL; |
927 | } | 928 | } |
928 | 929 | ||
930 | static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy) | ||
931 | { | ||
932 | struct kobject *kobj; | ||
933 | struct completion *cmp; | ||
934 | |||
935 | down_read(&policy->rwsem); | ||
936 | kobj = &policy->kobj; | ||
937 | cmp = &policy->kobj_unregister; | ||
938 | up_read(&policy->rwsem); | ||
939 | kobject_put(kobj); | ||
940 | |||
941 | /* | ||
942 | * We need to make sure that the underlying kobj is | ||
943 | * actually not referenced anymore by anybody before we | ||
944 | * proceed with unloading. | ||
945 | */ | ||
946 | pr_debug("waiting for dropping of refcount\n"); | ||
947 | wait_for_completion(cmp); | ||
948 | pr_debug("wait complete\n"); | ||
949 | } | ||
950 | |||
929 | static void cpufreq_policy_free(struct cpufreq_policy *policy) | 951 | static void cpufreq_policy_free(struct cpufreq_policy *policy) |
930 | { | 952 | { |
931 | free_cpumask_var(policy->related_cpus); | 953 | free_cpumask_var(policy->related_cpus); |
@@ -986,7 +1008,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
986 | list_for_each_entry(tpolicy, &cpufreq_policy_list, policy_list) { | 1008 | list_for_each_entry(tpolicy, &cpufreq_policy_list, policy_list) { |
987 | if (cpumask_test_cpu(cpu, tpolicy->related_cpus)) { | 1009 | if (cpumask_test_cpu(cpu, tpolicy->related_cpus)) { |
988 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1010 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
989 | ret = cpufreq_add_policy_cpu(tpolicy, cpu, dev, frozen); | 1011 | ret = cpufreq_add_policy_cpu(tpolicy, cpu, dev); |
990 | up_read(&cpufreq_rwsem); | 1012 | up_read(&cpufreq_rwsem); |
991 | return ret; | 1013 | return ret; |
992 | } | 1014 | } |
@@ -1096,7 +1118,10 @@ err_get_freq: | |||
1096 | if (cpufreq_driver->exit) | 1118 | if (cpufreq_driver->exit) |
1097 | cpufreq_driver->exit(policy); | 1119 | cpufreq_driver->exit(policy); |
1098 | err_set_policy_cpu: | 1120 | err_set_policy_cpu: |
1121 | if (frozen) | ||
1122 | cpufreq_policy_put_kobj(policy); | ||
1099 | cpufreq_policy_free(policy); | 1123 | cpufreq_policy_free(policy); |
1124 | |||
1100 | nomem_out: | 1125 | nomem_out: |
1101 | up_read(&cpufreq_rwsem); | 1126 | up_read(&cpufreq_rwsem); |
1102 | 1127 | ||
@@ -1118,7 +1143,7 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | |||
1118 | } | 1143 | } |
1119 | 1144 | ||
1120 | static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, | 1145 | static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, |
1121 | unsigned int old_cpu, bool frozen) | 1146 | unsigned int old_cpu) |
1122 | { | 1147 | { |
1123 | struct device *cpu_dev; | 1148 | struct device *cpu_dev; |
1124 | int ret; | 1149 | int ret; |
@@ -1126,10 +1151,6 @@ static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, | |||
1126 | /* first sibling now owns the new sysfs dir */ | 1151 | /* first sibling now owns the new sysfs dir */ |
1127 | cpu_dev = get_cpu_device(cpumask_any_but(policy->cpus, old_cpu)); | 1152 | cpu_dev = get_cpu_device(cpumask_any_but(policy->cpus, old_cpu)); |
1128 | 1153 | ||
1129 | /* Don't touch sysfs files during light-weight tear-down */ | ||
1130 | if (frozen) | ||
1131 | return cpu_dev->id; | ||
1132 | |||
1133 | sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); | 1154 | sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); |
1134 | ret = kobject_move(&policy->kobj, &cpu_dev->kobj); | 1155 | ret = kobject_move(&policy->kobj, &cpu_dev->kobj); |
1135 | if (ret) { | 1156 | if (ret) { |
@@ -1196,7 +1217,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, | |||
1196 | if (!frozen) | 1217 | if (!frozen) |
1197 | sysfs_remove_link(&dev->kobj, "cpufreq"); | 1218 | sysfs_remove_link(&dev->kobj, "cpufreq"); |
1198 | } else if (cpus > 1) { | 1219 | } else if (cpus > 1) { |
1199 | new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen); | 1220 | new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu); |
1200 | if (new_cpu >= 0) { | 1221 | if (new_cpu >= 0) { |
1201 | update_policy_cpu(policy, new_cpu); | 1222 | update_policy_cpu(policy, new_cpu); |
1202 | 1223 | ||
@@ -1218,8 +1239,6 @@ static int __cpufreq_remove_dev_finish(struct device *dev, | |||
1218 | int ret; | 1239 | int ret; |
1219 | unsigned long flags; | 1240 | unsigned long flags; |
1220 | struct cpufreq_policy *policy; | 1241 | struct cpufreq_policy *policy; |
1221 | struct kobject *kobj; | ||
1222 | struct completion *cmp; | ||
1223 | 1242 | ||
1224 | read_lock_irqsave(&cpufreq_driver_lock, flags); | 1243 | read_lock_irqsave(&cpufreq_driver_lock, flags); |
1225 | policy = per_cpu(cpufreq_cpu_data, cpu); | 1244 | policy = per_cpu(cpufreq_cpu_data, cpu); |
@@ -1249,22 +1268,8 @@ static int __cpufreq_remove_dev_finish(struct device *dev, | |||
1249 | } | 1268 | } |
1250 | } | 1269 | } |
1251 | 1270 | ||
1252 | if (!frozen) { | 1271 | if (!frozen) |
1253 | down_read(&policy->rwsem); | 1272 | cpufreq_policy_put_kobj(policy); |
1254 | kobj = &policy->kobj; | ||
1255 | cmp = &policy->kobj_unregister; | ||
1256 | up_read(&policy->rwsem); | ||
1257 | kobject_put(kobj); | ||
1258 | |||
1259 | /* | ||
1260 | * We need to make sure that the underlying kobj is | ||
1261 | * actually not referenced anymore by anybody before we | ||
1262 | * proceed with unloading. | ||
1263 | */ | ||
1264 | pr_debug("waiting for dropping of refcount\n"); | ||
1265 | wait_for_completion(cmp); | ||
1266 | pr_debug("wait complete\n"); | ||
1267 | } | ||
1268 | 1273 | ||
1269 | /* | 1274 | /* |
1270 | * Perform the ->exit() even during light-weight tear-down, | 1275 | * Perform the ->exit() even during light-weight tear-down, |
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 446687cc2334..c823daaf9043 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig | |||
@@ -62,6 +62,7 @@ config INTEL_IOATDMA | |||
62 | tristate "Intel I/OAT DMA support" | 62 | tristate "Intel I/OAT DMA support" |
63 | depends on PCI && X86 | 63 | depends on PCI && X86 |
64 | select DMA_ENGINE | 64 | select DMA_ENGINE |
65 | select DMA_ENGINE_RAID | ||
65 | select DCA | 66 | select DCA |
66 | help | 67 | help |
67 | Enable support for the Intel(R) I/OAT DMA engine present | 68 | Enable support for the Intel(R) I/OAT DMA engine present |
@@ -112,6 +113,7 @@ config MV_XOR | |||
112 | bool "Marvell XOR engine support" | 113 | bool "Marvell XOR engine support" |
113 | depends on PLAT_ORION | 114 | depends on PLAT_ORION |
114 | select DMA_ENGINE | 115 | select DMA_ENGINE |
116 | select DMA_ENGINE_RAID | ||
115 | select ASYNC_TX_ENABLE_CHANNEL_SWITCH | 117 | select ASYNC_TX_ENABLE_CHANNEL_SWITCH |
116 | ---help--- | 118 | ---help--- |
117 | Enable support for the Marvell XOR engine. | 119 | Enable support for the Marvell XOR engine. |
@@ -187,6 +189,7 @@ config AMCC_PPC440SPE_ADMA | |||
187 | tristate "AMCC PPC440SPe ADMA support" | 189 | tristate "AMCC PPC440SPe ADMA support" |
188 | depends on 440SPe || 440SP | 190 | depends on 440SPe || 440SP |
189 | select DMA_ENGINE | 191 | select DMA_ENGINE |
192 | select DMA_ENGINE_RAID | ||
190 | select ARCH_HAS_ASYNC_TX_FIND_CHANNEL | 193 | select ARCH_HAS_ASYNC_TX_FIND_CHANNEL |
191 | select ASYNC_TX_ENABLE_CHANNEL_SWITCH | 194 | select ASYNC_TX_ENABLE_CHANNEL_SWITCH |
192 | help | 195 | help |
@@ -352,6 +355,7 @@ config NET_DMA | |||
352 | bool "Network: TCP receive copy offload" | 355 | bool "Network: TCP receive copy offload" |
353 | depends on DMA_ENGINE && NET | 356 | depends on DMA_ENGINE && NET |
354 | default (INTEL_IOATDMA || FSL_DMA) | 357 | default (INTEL_IOATDMA || FSL_DMA) |
358 | depends on BROKEN | ||
355 | help | 359 | help |
356 | This enables the use of DMA engines in the network stack to | 360 | This enables the use of DMA engines in the network stack to |
357 | offload receive copy-to-user operations, freeing CPU cycles. | 361 | offload receive copy-to-user operations, freeing CPU cycles. |
@@ -377,4 +381,7 @@ config DMATEST | |||
377 | Simple DMA test client. Say N unless you're debugging a | 381 | Simple DMA test client. Say N unless you're debugging a |
378 | DMA Device driver. | 382 | DMA Device driver. |
379 | 383 | ||
384 | config DMA_ENGINE_RAID | ||
385 | bool | ||
386 | |||
380 | endif | 387 | endif |
diff --git a/drivers/dma/at_hdmac_regs.h b/drivers/dma/at_hdmac_regs.h index f31d647acdfa..2787aba60c6b 100644 --- a/drivers/dma/at_hdmac_regs.h +++ b/drivers/dma/at_hdmac_regs.h | |||
@@ -347,10 +347,6 @@ static struct device *chan2dev(struct dma_chan *chan) | |||
347 | { | 347 | { |
348 | return &chan->dev->device; | 348 | return &chan->dev->device; |
349 | } | 349 | } |
350 | static struct device *chan2parent(struct dma_chan *chan) | ||
351 | { | ||
352 | return chan->dev->device.parent; | ||
353 | } | ||
354 | 350 | ||
355 | #if defined(VERBOSE_DEBUG) | 351 | #if defined(VERBOSE_DEBUG) |
356 | static void vdbg_dump_regs(struct at_dma_chan *atchan) | 352 | static void vdbg_dump_regs(struct at_dma_chan *atchan) |
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index ea806bdc12ef..92caad629d99 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c | |||
@@ -540,6 +540,8 @@ EXPORT_SYMBOL_GPL(dma_get_slave_channel); | |||
540 | * @mask: capabilities that the channel must satisfy | 540 | * @mask: capabilities that the channel must satisfy |
541 | * @fn: optional callback to disposition available channels | 541 | * @fn: optional callback to disposition available channels |
542 | * @fn_param: opaque parameter to pass to dma_filter_fn | 542 | * @fn_param: opaque parameter to pass to dma_filter_fn |
543 | * | ||
544 | * Returns pointer to appropriate DMA channel on success or NULL. | ||
543 | */ | 545 | */ |
544 | struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask, | 546 | struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask, |
545 | dma_filter_fn fn, void *fn_param) | 547 | dma_filter_fn fn, void *fn_param) |
@@ -591,18 +593,43 @@ EXPORT_SYMBOL_GPL(__dma_request_channel); | |||
591 | * dma_request_slave_channel - try to allocate an exclusive slave channel | 593 | * dma_request_slave_channel - try to allocate an exclusive slave channel |
592 | * @dev: pointer to client device structure | 594 | * @dev: pointer to client device structure |
593 | * @name: slave channel name | 595 | * @name: slave channel name |
596 | * | ||
597 | * Returns pointer to appropriate DMA channel on success or an error pointer. | ||
594 | */ | 598 | */ |
595 | struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name) | 599 | struct dma_chan *dma_request_slave_channel_reason(struct device *dev, |
600 | const char *name) | ||
596 | { | 601 | { |
602 | struct dma_chan *chan; | ||
603 | |||
597 | /* If device-tree is present get slave info from here */ | 604 | /* If device-tree is present get slave info from here */ |
598 | if (dev->of_node) | 605 | if (dev->of_node) |
599 | return of_dma_request_slave_channel(dev->of_node, name); | 606 | return of_dma_request_slave_channel(dev->of_node, name); |
600 | 607 | ||
601 | /* If device was enumerated by ACPI get slave info from here */ | 608 | /* If device was enumerated by ACPI get slave info from here */ |
602 | if (ACPI_HANDLE(dev)) | 609 | if (ACPI_HANDLE(dev)) { |
603 | return acpi_dma_request_slave_chan_by_name(dev, name); | 610 | chan = acpi_dma_request_slave_chan_by_name(dev, name); |
611 | if (chan) | ||
612 | return chan; | ||
613 | } | ||
604 | 614 | ||
605 | return NULL; | 615 | return ERR_PTR(-ENODEV); |
616 | } | ||
617 | EXPORT_SYMBOL_GPL(dma_request_slave_channel_reason); | ||
618 | |||
619 | /** | ||
620 | * dma_request_slave_channel - try to allocate an exclusive slave channel | ||
621 | * @dev: pointer to client device structure | ||
622 | * @name: slave channel name | ||
623 | * | ||
624 | * Returns pointer to appropriate DMA channel on success or NULL. | ||
625 | */ | ||
626 | struct dma_chan *dma_request_slave_channel(struct device *dev, | ||
627 | const char *name) | ||
628 | { | ||
629 | struct dma_chan *ch = dma_request_slave_channel_reason(dev, name); | ||
630 | if (IS_ERR(ch)) | ||
631 | return NULL; | ||
632 | return ch; | ||
606 | } | 633 | } |
607 | EXPORT_SYMBOL_GPL(dma_request_slave_channel); | 634 | EXPORT_SYMBOL_GPL(dma_request_slave_channel); |
608 | 635 | ||
@@ -912,7 +939,7 @@ struct dmaengine_unmap_pool { | |||
912 | #define __UNMAP_POOL(x) { .size = x, .name = "dmaengine-unmap-" __stringify(x) } | 939 | #define __UNMAP_POOL(x) { .size = x, .name = "dmaengine-unmap-" __stringify(x) } |
913 | static struct dmaengine_unmap_pool unmap_pool[] = { | 940 | static struct dmaengine_unmap_pool unmap_pool[] = { |
914 | __UNMAP_POOL(2), | 941 | __UNMAP_POOL(2), |
915 | #if IS_ENABLED(CONFIG_ASYNC_TX_DMA) | 942 | #if IS_ENABLED(CONFIG_DMA_ENGINE_RAID) |
916 | __UNMAP_POOL(16), | 943 | __UNMAP_POOL(16), |
917 | __UNMAP_POOL(128), | 944 | __UNMAP_POOL(128), |
918 | __UNMAP_POOL(256), | 945 | __UNMAP_POOL(256), |
@@ -1054,7 +1081,7 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg, | |||
1054 | dma_cookie_t cookie; | 1081 | dma_cookie_t cookie; |
1055 | unsigned long flags; | 1082 | unsigned long flags; |
1056 | 1083 | ||
1057 | unmap = dmaengine_get_unmap_data(dev->dev, 2, GFP_NOIO); | 1084 | unmap = dmaengine_get_unmap_data(dev->dev, 2, GFP_NOWAIT); |
1058 | if (!unmap) | 1085 | if (!unmap) |
1059 | return -ENOMEM; | 1086 | return -ENOMEM; |
1060 | 1087 | ||
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 20f9a3aaf926..9dfcaf5c1288 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c | |||
@@ -539,9 +539,9 @@ static int dmatest_func(void *data) | |||
539 | 539 | ||
540 | um->len = params->buf_size; | 540 | um->len = params->buf_size; |
541 | for (i = 0; i < src_cnt; i++) { | 541 | for (i = 0; i < src_cnt; i++) { |
542 | unsigned long buf = (unsigned long) thread->srcs[i]; | 542 | void *buf = thread->srcs[i]; |
543 | struct page *pg = virt_to_page(buf); | 543 | struct page *pg = virt_to_page(buf); |
544 | unsigned pg_off = buf & ~PAGE_MASK; | 544 | unsigned pg_off = (unsigned long) buf & ~PAGE_MASK; |
545 | 545 | ||
546 | um->addr[i] = dma_map_page(dev->dev, pg, pg_off, | 546 | um->addr[i] = dma_map_page(dev->dev, pg, pg_off, |
547 | um->len, DMA_TO_DEVICE); | 547 | um->len, DMA_TO_DEVICE); |
@@ -559,9 +559,9 @@ static int dmatest_func(void *data) | |||
559 | /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */ | 559 | /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */ |
560 | dsts = &um->addr[src_cnt]; | 560 | dsts = &um->addr[src_cnt]; |
561 | for (i = 0; i < dst_cnt; i++) { | 561 | for (i = 0; i < dst_cnt; i++) { |
562 | unsigned long buf = (unsigned long) thread->dsts[i]; | 562 | void *buf = thread->dsts[i]; |
563 | struct page *pg = virt_to_page(buf); | 563 | struct page *pg = virt_to_page(buf); |
564 | unsigned pg_off = buf & ~PAGE_MASK; | 564 | unsigned pg_off = (unsigned long) buf & ~PAGE_MASK; |
565 | 565 | ||
566 | dsts[i] = dma_map_page(dev->dev, pg, pg_off, um->len, | 566 | dsts[i] = dma_map_page(dev->dev, pg, pg_off, um->len, |
567 | DMA_BIDIRECTIONAL); | 567 | DMA_BIDIRECTIONAL); |
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c index 7086a16a55f2..f157c6f76b32 100644 --- a/drivers/dma/fsldma.c +++ b/drivers/dma/fsldma.c | |||
@@ -86,11 +86,6 @@ static void set_desc_cnt(struct fsldma_chan *chan, | |||
86 | hw->count = CPU_TO_DMA(chan, count, 32); | 86 | hw->count = CPU_TO_DMA(chan, count, 32); |
87 | } | 87 | } |
88 | 88 | ||
89 | static u32 get_desc_cnt(struct fsldma_chan *chan, struct fsl_desc_sw *desc) | ||
90 | { | ||
91 | return DMA_TO_CPU(chan, desc->hw.count, 32); | ||
92 | } | ||
93 | |||
94 | static void set_desc_src(struct fsldma_chan *chan, | 89 | static void set_desc_src(struct fsldma_chan *chan, |
95 | struct fsl_dma_ld_hw *hw, dma_addr_t src) | 90 | struct fsl_dma_ld_hw *hw, dma_addr_t src) |
96 | { | 91 | { |
@@ -101,16 +96,6 @@ static void set_desc_src(struct fsldma_chan *chan, | |||
101 | hw->src_addr = CPU_TO_DMA(chan, snoop_bits | src, 64); | 96 | hw->src_addr = CPU_TO_DMA(chan, snoop_bits | src, 64); |
102 | } | 97 | } |
103 | 98 | ||
104 | static dma_addr_t get_desc_src(struct fsldma_chan *chan, | ||
105 | struct fsl_desc_sw *desc) | ||
106 | { | ||
107 | u64 snoop_bits; | ||
108 | |||
109 | snoop_bits = ((chan->feature & FSL_DMA_IP_MASK) == FSL_DMA_IP_85XX) | ||
110 | ? ((u64)FSL_DMA_SATR_SREADTYPE_SNOOP_READ << 32) : 0; | ||
111 | return DMA_TO_CPU(chan, desc->hw.src_addr, 64) & ~snoop_bits; | ||
112 | } | ||
113 | |||
114 | static void set_desc_dst(struct fsldma_chan *chan, | 99 | static void set_desc_dst(struct fsldma_chan *chan, |
115 | struct fsl_dma_ld_hw *hw, dma_addr_t dst) | 100 | struct fsl_dma_ld_hw *hw, dma_addr_t dst) |
116 | { | 101 | { |
@@ -121,16 +106,6 @@ static void set_desc_dst(struct fsldma_chan *chan, | |||
121 | hw->dst_addr = CPU_TO_DMA(chan, snoop_bits | dst, 64); | 106 | hw->dst_addr = CPU_TO_DMA(chan, snoop_bits | dst, 64); |
122 | } | 107 | } |
123 | 108 | ||
124 | static dma_addr_t get_desc_dst(struct fsldma_chan *chan, | ||
125 | struct fsl_desc_sw *desc) | ||
126 | { | ||
127 | u64 snoop_bits; | ||
128 | |||
129 | snoop_bits = ((chan->feature & FSL_DMA_IP_MASK) == FSL_DMA_IP_85XX) | ||
130 | ? ((u64)FSL_DMA_DATR_DWRITETYPE_SNOOP_WRITE << 32) : 0; | ||
131 | return DMA_TO_CPU(chan, desc->hw.dst_addr, 64) & ~snoop_bits; | ||
132 | } | ||
133 | |||
134 | static void set_desc_next(struct fsldma_chan *chan, | 109 | static void set_desc_next(struct fsldma_chan *chan, |
135 | struct fsl_dma_ld_hw *hw, dma_addr_t next) | 110 | struct fsl_dma_ld_hw *hw, dma_addr_t next) |
136 | { | 111 | { |
@@ -408,7 +383,7 @@ static dma_cookie_t fsl_dma_tx_submit(struct dma_async_tx_descriptor *tx) | |||
408 | struct fsl_desc_sw *desc = tx_to_fsl_desc(tx); | 383 | struct fsl_desc_sw *desc = tx_to_fsl_desc(tx); |
409 | struct fsl_desc_sw *child; | 384 | struct fsl_desc_sw *child; |
410 | unsigned long flags; | 385 | unsigned long flags; |
411 | dma_cookie_t cookie; | 386 | dma_cookie_t cookie = -EINVAL; |
412 | 387 | ||
413 | spin_lock_irqsave(&chan->desc_lock, flags); | 388 | spin_lock_irqsave(&chan->desc_lock, flags); |
414 | 389 | ||
@@ -854,10 +829,6 @@ static void fsldma_cleanup_descriptor(struct fsldma_chan *chan, | |||
854 | struct fsl_desc_sw *desc) | 829 | struct fsl_desc_sw *desc) |
855 | { | 830 | { |
856 | struct dma_async_tx_descriptor *txd = &desc->async_tx; | 831 | struct dma_async_tx_descriptor *txd = &desc->async_tx; |
857 | struct device *dev = chan->common.device->dev; | ||
858 | dma_addr_t src = get_desc_src(chan, desc); | ||
859 | dma_addr_t dst = get_desc_dst(chan, desc); | ||
860 | u32 len = get_desc_cnt(chan, desc); | ||
861 | 832 | ||
862 | /* Run the link descriptor callback function */ | 833 | /* Run the link descriptor callback function */ |
863 | if (txd->callback) { | 834 | if (txd->callback) { |
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c index 7807f0ef4e20..53fb0c8365b0 100644 --- a/drivers/dma/mv_xor.c +++ b/drivers/dma/mv_xor.c | |||
@@ -54,12 +54,6 @@ static void mv_desc_init(struct mv_xor_desc_slot *desc, unsigned long flags) | |||
54 | hw_desc->desc_command = (1 << 31); | 54 | hw_desc->desc_command = (1 << 31); |
55 | } | 55 | } |
56 | 56 | ||
57 | static u32 mv_desc_get_dest_addr(struct mv_xor_desc_slot *desc) | ||
58 | { | ||
59 | struct mv_xor_desc *hw_desc = desc->hw_desc; | ||
60 | return hw_desc->phy_dest_addr; | ||
61 | } | ||
62 | |||
63 | static void mv_desc_set_byte_count(struct mv_xor_desc_slot *desc, | 57 | static void mv_desc_set_byte_count(struct mv_xor_desc_slot *desc, |
64 | u32 byte_count) | 58 | u32 byte_count) |
65 | { | 59 | { |
@@ -787,7 +781,6 @@ static void mv_xor_issue_pending(struct dma_chan *chan) | |||
787 | /* | 781 | /* |
788 | * Perform a transaction to verify the HW works. | 782 | * Perform a transaction to verify the HW works. |
789 | */ | 783 | */ |
790 | #define MV_XOR_TEST_SIZE 2000 | ||
791 | 784 | ||
792 | static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) | 785 | static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) |
793 | { | 786 | { |
@@ -797,20 +790,21 @@ static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) | |||
797 | struct dma_chan *dma_chan; | 790 | struct dma_chan *dma_chan; |
798 | dma_cookie_t cookie; | 791 | dma_cookie_t cookie; |
799 | struct dma_async_tx_descriptor *tx; | 792 | struct dma_async_tx_descriptor *tx; |
793 | struct dmaengine_unmap_data *unmap; | ||
800 | int err = 0; | 794 | int err = 0; |
801 | 795 | ||
802 | src = kmalloc(sizeof(u8) * MV_XOR_TEST_SIZE, GFP_KERNEL); | 796 | src = kmalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL); |
803 | if (!src) | 797 | if (!src) |
804 | return -ENOMEM; | 798 | return -ENOMEM; |
805 | 799 | ||
806 | dest = kzalloc(sizeof(u8) * MV_XOR_TEST_SIZE, GFP_KERNEL); | 800 | dest = kzalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL); |
807 | if (!dest) { | 801 | if (!dest) { |
808 | kfree(src); | 802 | kfree(src); |
809 | return -ENOMEM; | 803 | return -ENOMEM; |
810 | } | 804 | } |
811 | 805 | ||
812 | /* Fill in src buffer */ | 806 | /* Fill in src buffer */ |
813 | for (i = 0; i < MV_XOR_TEST_SIZE; i++) | 807 | for (i = 0; i < PAGE_SIZE; i++) |
814 | ((u8 *) src)[i] = (u8)i; | 808 | ((u8 *) src)[i] = (u8)i; |
815 | 809 | ||
816 | dma_chan = &mv_chan->dmachan; | 810 | dma_chan = &mv_chan->dmachan; |
@@ -819,14 +813,26 @@ static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) | |||
819 | goto out; | 813 | goto out; |
820 | } | 814 | } |
821 | 815 | ||
822 | dest_dma = dma_map_single(dma_chan->device->dev, dest, | 816 | unmap = dmaengine_get_unmap_data(dma_chan->device->dev, 2, GFP_KERNEL); |
823 | MV_XOR_TEST_SIZE, DMA_FROM_DEVICE); | 817 | if (!unmap) { |
818 | err = -ENOMEM; | ||
819 | goto free_resources; | ||
820 | } | ||
821 | |||
822 | src_dma = dma_map_page(dma_chan->device->dev, virt_to_page(src), 0, | ||
823 | PAGE_SIZE, DMA_TO_DEVICE); | ||
824 | unmap->to_cnt = 1; | ||
825 | unmap->addr[0] = src_dma; | ||
824 | 826 | ||
825 | src_dma = dma_map_single(dma_chan->device->dev, src, | 827 | dest_dma = dma_map_page(dma_chan->device->dev, virt_to_page(dest), 0, |
826 | MV_XOR_TEST_SIZE, DMA_TO_DEVICE); | 828 | PAGE_SIZE, DMA_FROM_DEVICE); |
829 | unmap->from_cnt = 1; | ||
830 | unmap->addr[1] = dest_dma; | ||
831 | |||
832 | unmap->len = PAGE_SIZE; | ||
827 | 833 | ||
828 | tx = mv_xor_prep_dma_memcpy(dma_chan, dest_dma, src_dma, | 834 | tx = mv_xor_prep_dma_memcpy(dma_chan, dest_dma, src_dma, |
829 | MV_XOR_TEST_SIZE, 0); | 835 | PAGE_SIZE, 0); |
830 | cookie = mv_xor_tx_submit(tx); | 836 | cookie = mv_xor_tx_submit(tx); |
831 | mv_xor_issue_pending(dma_chan); | 837 | mv_xor_issue_pending(dma_chan); |
832 | async_tx_ack(tx); | 838 | async_tx_ack(tx); |
@@ -841,8 +847,8 @@ static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) | |||
841 | } | 847 | } |
842 | 848 | ||
843 | dma_sync_single_for_cpu(dma_chan->device->dev, dest_dma, | 849 | dma_sync_single_for_cpu(dma_chan->device->dev, dest_dma, |
844 | MV_XOR_TEST_SIZE, DMA_FROM_DEVICE); | 850 | PAGE_SIZE, DMA_FROM_DEVICE); |
845 | if (memcmp(src, dest, MV_XOR_TEST_SIZE)) { | 851 | if (memcmp(src, dest, PAGE_SIZE)) { |
846 | dev_err(dma_chan->device->dev, | 852 | dev_err(dma_chan->device->dev, |
847 | "Self-test copy failed compare, disabling\n"); | 853 | "Self-test copy failed compare, disabling\n"); |
848 | err = -ENODEV; | 854 | err = -ENODEV; |
@@ -850,6 +856,7 @@ static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) | |||
850 | } | 856 | } |
851 | 857 | ||
852 | free_resources: | 858 | free_resources: |
859 | dmaengine_unmap_put(unmap); | ||
853 | mv_xor_free_chan_resources(dma_chan); | 860 | mv_xor_free_chan_resources(dma_chan); |
854 | out: | 861 | out: |
855 | kfree(src); | 862 | kfree(src); |
@@ -867,13 +874,15 @@ mv_xor_xor_self_test(struct mv_xor_chan *mv_chan) | |||
867 | dma_addr_t dma_srcs[MV_XOR_NUM_SRC_TEST]; | 874 | dma_addr_t dma_srcs[MV_XOR_NUM_SRC_TEST]; |
868 | dma_addr_t dest_dma; | 875 | dma_addr_t dest_dma; |
869 | struct dma_async_tx_descriptor *tx; | 876 | struct dma_async_tx_descriptor *tx; |
877 | struct dmaengine_unmap_data *unmap; | ||
870 | struct dma_chan *dma_chan; | 878 | struct dma_chan *dma_chan; |
871 | dma_cookie_t cookie; | 879 | dma_cookie_t cookie; |
872 | u8 cmp_byte = 0; | 880 | u8 cmp_byte = 0; |
873 | u32 cmp_word; | 881 | u32 cmp_word; |
874 | int err = 0; | 882 | int err = 0; |
883 | int src_count = MV_XOR_NUM_SRC_TEST; | ||
875 | 884 | ||
876 | for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { | 885 | for (src_idx = 0; src_idx < src_count; src_idx++) { |
877 | xor_srcs[src_idx] = alloc_page(GFP_KERNEL); | 886 | xor_srcs[src_idx] = alloc_page(GFP_KERNEL); |
878 | if (!xor_srcs[src_idx]) { | 887 | if (!xor_srcs[src_idx]) { |
879 | while (src_idx--) | 888 | while (src_idx--) |
@@ -890,13 +899,13 @@ mv_xor_xor_self_test(struct mv_xor_chan *mv_chan) | |||
890 | } | 899 | } |
891 | 900 | ||
892 | /* Fill in src buffers */ | 901 | /* Fill in src buffers */ |
893 | for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { | 902 | for (src_idx = 0; src_idx < src_count; src_idx++) { |
894 | u8 *ptr = page_address(xor_srcs[src_idx]); | 903 | u8 *ptr = page_address(xor_srcs[src_idx]); |
895 | for (i = 0; i < PAGE_SIZE; i++) | 904 | for (i = 0; i < PAGE_SIZE; i++) |
896 | ptr[i] = (1 << src_idx); | 905 | ptr[i] = (1 << src_idx); |
897 | } | 906 | } |
898 | 907 | ||
899 | for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) | 908 | for (src_idx = 0; src_idx < src_count; src_idx++) |
900 | cmp_byte ^= (u8) (1 << src_idx); | 909 | cmp_byte ^= (u8) (1 << src_idx); |
901 | 910 | ||
902 | cmp_word = (cmp_byte << 24) | (cmp_byte << 16) | | 911 | cmp_word = (cmp_byte << 24) | (cmp_byte << 16) | |
@@ -910,16 +919,29 @@ mv_xor_xor_self_test(struct mv_xor_chan *mv_chan) | |||
910 | goto out; | 919 | goto out; |
911 | } | 920 | } |
912 | 921 | ||
922 | unmap = dmaengine_get_unmap_data(dma_chan->device->dev, src_count + 1, | ||
923 | GFP_KERNEL); | ||
924 | if (!unmap) { | ||
925 | err = -ENOMEM; | ||
926 | goto free_resources; | ||
927 | } | ||
928 | |||
913 | /* test xor */ | 929 | /* test xor */ |
914 | dest_dma = dma_map_page(dma_chan->device->dev, dest, 0, PAGE_SIZE, | 930 | for (i = 0; i < src_count; i++) { |
915 | DMA_FROM_DEVICE); | 931 | unmap->addr[i] = dma_map_page(dma_chan->device->dev, xor_srcs[i], |
932 | 0, PAGE_SIZE, DMA_TO_DEVICE); | ||
933 | dma_srcs[i] = unmap->addr[i]; | ||
934 | unmap->to_cnt++; | ||
935 | } | ||
916 | 936 | ||
917 | for (i = 0; i < MV_XOR_NUM_SRC_TEST; i++) | 937 | unmap->addr[src_count] = dma_map_page(dma_chan->device->dev, dest, 0, PAGE_SIZE, |
918 | dma_srcs[i] = dma_map_page(dma_chan->device->dev, xor_srcs[i], | 938 | DMA_FROM_DEVICE); |
919 | 0, PAGE_SIZE, DMA_TO_DEVICE); | 939 | dest_dma = unmap->addr[src_count]; |
940 | unmap->from_cnt = 1; | ||
941 | unmap->len = PAGE_SIZE; | ||
920 | 942 | ||
921 | tx = mv_xor_prep_dma_xor(dma_chan, dest_dma, dma_srcs, | 943 | tx = mv_xor_prep_dma_xor(dma_chan, dest_dma, dma_srcs, |
922 | MV_XOR_NUM_SRC_TEST, PAGE_SIZE, 0); | 944 | src_count, PAGE_SIZE, 0); |
923 | 945 | ||
924 | cookie = mv_xor_tx_submit(tx); | 946 | cookie = mv_xor_tx_submit(tx); |
925 | mv_xor_issue_pending(dma_chan); | 947 | mv_xor_issue_pending(dma_chan); |
@@ -948,9 +970,10 @@ mv_xor_xor_self_test(struct mv_xor_chan *mv_chan) | |||
948 | } | 970 | } |
949 | 971 | ||
950 | free_resources: | 972 | free_resources: |
973 | dmaengine_unmap_put(unmap); | ||
951 | mv_xor_free_chan_resources(dma_chan); | 974 | mv_xor_free_chan_resources(dma_chan); |
952 | out: | 975 | out: |
953 | src_idx = MV_XOR_NUM_SRC_TEST; | 976 | src_idx = src_count; |
954 | while (src_idx--) | 977 | while (src_idx--) |
955 | __free_page(xor_srcs[src_idx]); | 978 | __free_page(xor_srcs[src_idx]); |
956 | __free_page(dest); | 979 | __free_page(dest); |
@@ -1176,6 +1199,7 @@ static int mv_xor_probe(struct platform_device *pdev) | |||
1176 | int i = 0; | 1199 | int i = 0; |
1177 | 1200 | ||
1178 | for_each_child_of_node(pdev->dev.of_node, np) { | 1201 | for_each_child_of_node(pdev->dev.of_node, np) { |
1202 | struct mv_xor_chan *chan; | ||
1179 | dma_cap_mask_t cap_mask; | 1203 | dma_cap_mask_t cap_mask; |
1180 | int irq; | 1204 | int irq; |
1181 | 1205 | ||
@@ -1193,21 +1217,21 @@ static int mv_xor_probe(struct platform_device *pdev) | |||
1193 | goto err_channel_add; | 1217 | goto err_channel_add; |
1194 | } | 1218 | } |
1195 | 1219 | ||
1196 | xordev->channels[i] = | 1220 | chan = mv_xor_channel_add(xordev, pdev, i, |
1197 | mv_xor_channel_add(xordev, pdev, i, | 1221 | cap_mask, irq); |
1198 | cap_mask, irq); | 1222 | if (IS_ERR(chan)) { |
1199 | if (IS_ERR(xordev->channels[i])) { | 1223 | ret = PTR_ERR(chan); |
1200 | ret = PTR_ERR(xordev->channels[i]); | ||
1201 | xordev->channels[i] = NULL; | ||
1202 | irq_dispose_mapping(irq); | 1224 | irq_dispose_mapping(irq); |
1203 | goto err_channel_add; | 1225 | goto err_channel_add; |
1204 | } | 1226 | } |
1205 | 1227 | ||
1228 | xordev->channels[i] = chan; | ||
1206 | i++; | 1229 | i++; |
1207 | } | 1230 | } |
1208 | } else if (pdata && pdata->channels) { | 1231 | } else if (pdata && pdata->channels) { |
1209 | for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) { | 1232 | for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) { |
1210 | struct mv_xor_channel_data *cd; | 1233 | struct mv_xor_channel_data *cd; |
1234 | struct mv_xor_chan *chan; | ||
1211 | int irq; | 1235 | int irq; |
1212 | 1236 | ||
1213 | cd = &pdata->channels[i]; | 1237 | cd = &pdata->channels[i]; |
@@ -1222,13 +1246,14 @@ static int mv_xor_probe(struct platform_device *pdev) | |||
1222 | goto err_channel_add; | 1246 | goto err_channel_add; |
1223 | } | 1247 | } |
1224 | 1248 | ||
1225 | xordev->channels[i] = | 1249 | chan = mv_xor_channel_add(xordev, pdev, i, |
1226 | mv_xor_channel_add(xordev, pdev, i, | 1250 | cd->cap_mask, irq); |
1227 | cd->cap_mask, irq); | 1251 | if (IS_ERR(chan)) { |
1228 | if (IS_ERR(xordev->channels[i])) { | 1252 | ret = PTR_ERR(chan); |
1229 | ret = PTR_ERR(xordev->channels[i]); | ||
1230 | goto err_channel_add; | 1253 | goto err_channel_add; |
1231 | } | 1254 | } |
1255 | |||
1256 | xordev->channels[i] = chan; | ||
1232 | } | 1257 | } |
1233 | } | 1258 | } |
1234 | 1259 | ||
diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c index 0b88dd3d05f4..e8fe9dc455f4 100644 --- a/drivers/dma/of-dma.c +++ b/drivers/dma/of-dma.c | |||
@@ -143,7 +143,7 @@ static int of_dma_match_channel(struct device_node *np, const char *name, | |||
143 | * @np: device node to get DMA request from | 143 | * @np: device node to get DMA request from |
144 | * @name: name of desired channel | 144 | * @name: name of desired channel |
145 | * | 145 | * |
146 | * Returns pointer to appropriate dma channel on success or NULL on error. | 146 | * Returns pointer to appropriate DMA channel on success or an error pointer. |
147 | */ | 147 | */ |
148 | struct dma_chan *of_dma_request_slave_channel(struct device_node *np, | 148 | struct dma_chan *of_dma_request_slave_channel(struct device_node *np, |
149 | const char *name) | 149 | const char *name) |
@@ -152,17 +152,18 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np, | |||
152 | struct of_dma *ofdma; | 152 | struct of_dma *ofdma; |
153 | struct dma_chan *chan; | 153 | struct dma_chan *chan; |
154 | int count, i; | 154 | int count, i; |
155 | int ret_no_channel = -ENODEV; | ||
155 | 156 | ||
156 | if (!np || !name) { | 157 | if (!np || !name) { |
157 | pr_err("%s: not enough information provided\n", __func__); | 158 | pr_err("%s: not enough information provided\n", __func__); |
158 | return NULL; | 159 | return ERR_PTR(-ENODEV); |
159 | } | 160 | } |
160 | 161 | ||
161 | count = of_property_count_strings(np, "dma-names"); | 162 | count = of_property_count_strings(np, "dma-names"); |
162 | if (count < 0) { | 163 | if (count < 0) { |
163 | pr_err("%s: dma-names property of node '%s' missing or empty\n", | 164 | pr_err("%s: dma-names property of node '%s' missing or empty\n", |
164 | __func__, np->full_name); | 165 | __func__, np->full_name); |
165 | return NULL; | 166 | return ERR_PTR(-ENODEV); |
166 | } | 167 | } |
167 | 168 | ||
168 | for (i = 0; i < count; i++) { | 169 | for (i = 0; i < count; i++) { |
@@ -172,10 +173,12 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np, | |||
172 | mutex_lock(&of_dma_lock); | 173 | mutex_lock(&of_dma_lock); |
173 | ofdma = of_dma_find_controller(&dma_spec); | 174 | ofdma = of_dma_find_controller(&dma_spec); |
174 | 175 | ||
175 | if (ofdma) | 176 | if (ofdma) { |
176 | chan = ofdma->of_dma_xlate(&dma_spec, ofdma); | 177 | chan = ofdma->of_dma_xlate(&dma_spec, ofdma); |
177 | else | 178 | } else { |
179 | ret_no_channel = -EPROBE_DEFER; | ||
178 | chan = NULL; | 180 | chan = NULL; |
181 | } | ||
179 | 182 | ||
180 | mutex_unlock(&of_dma_lock); | 183 | mutex_unlock(&of_dma_lock); |
181 | 184 | ||
@@ -185,7 +188,7 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np, | |||
185 | return chan; | 188 | return chan; |
186 | } | 189 | } |
187 | 190 | ||
188 | return NULL; | 191 | return ERR_PTR(ret_no_channel); |
189 | } | 192 | } |
190 | 193 | ||
191 | /** | 194 | /** |
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index cdf0483b8f2d..536632f6479c 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c | |||
@@ -2492,12 +2492,9 @@ static dma_cookie_t pl330_tx_submit(struct dma_async_tx_descriptor *tx) | |||
2492 | 2492 | ||
2493 | static inline void _init_desc(struct dma_pl330_desc *desc) | 2493 | static inline void _init_desc(struct dma_pl330_desc *desc) |
2494 | { | 2494 | { |
2495 | desc->pchan = NULL; | ||
2496 | desc->req.x = &desc->px; | 2495 | desc->req.x = &desc->px; |
2497 | desc->req.token = desc; | 2496 | desc->req.token = desc; |
2498 | desc->rqcfg.swap = SWAP_NO; | 2497 | desc->rqcfg.swap = SWAP_NO; |
2499 | desc->rqcfg.privileged = 0; | ||
2500 | desc->rqcfg.insnaccess = 0; | ||
2501 | desc->rqcfg.scctl = SCCTRL0; | 2498 | desc->rqcfg.scctl = SCCTRL0; |
2502 | desc->rqcfg.dcctl = DCCTRL0; | 2499 | desc->rqcfg.dcctl = DCCTRL0; |
2503 | desc->req.cfg = &desc->rqcfg; | 2500 | desc->req.cfg = &desc->rqcfg; |
@@ -2517,7 +2514,7 @@ static int add_desc(struct dma_pl330_dmac *pdmac, gfp_t flg, int count) | |||
2517 | if (!pdmac) | 2514 | if (!pdmac) |
2518 | return 0; | 2515 | return 0; |
2519 | 2516 | ||
2520 | desc = kmalloc(count * sizeof(*desc), flg); | 2517 | desc = kcalloc(count, sizeof(*desc), flg); |
2521 | if (!desc) | 2518 | if (!desc) |
2522 | return 0; | 2519 | return 0; |
2523 | 2520 | ||
diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c index 8da48c6b2a38..8bba298535b0 100644 --- a/drivers/dma/ppc4xx/adma.c +++ b/drivers/dma/ppc4xx/adma.c | |||
@@ -533,29 +533,6 @@ static void ppc440spe_desc_init_memcpy(struct ppc440spe_adma_desc_slot *desc, | |||
533 | } | 533 | } |
534 | 534 | ||
535 | /** | 535 | /** |
536 | * ppc440spe_desc_init_memset - initialize the descriptor for MEMSET operation | ||
537 | */ | ||
538 | static void ppc440spe_desc_init_memset(struct ppc440spe_adma_desc_slot *desc, | ||
539 | int value, unsigned long flags) | ||
540 | { | ||
541 | struct dma_cdb *hw_desc = desc->hw_desc; | ||
542 | |||
543 | memset(desc->hw_desc, 0, sizeof(struct dma_cdb)); | ||
544 | desc->hw_next = NULL; | ||
545 | desc->src_cnt = 1; | ||
546 | desc->dst_cnt = 1; | ||
547 | |||
548 | if (flags & DMA_PREP_INTERRUPT) | ||
549 | set_bit(PPC440SPE_DESC_INT, &desc->flags); | ||
550 | else | ||
551 | clear_bit(PPC440SPE_DESC_INT, &desc->flags); | ||
552 | |||
553 | hw_desc->sg1u = hw_desc->sg1l = cpu_to_le32((u32)value); | ||
554 | hw_desc->sg3u = hw_desc->sg3l = cpu_to_le32((u32)value); | ||
555 | hw_desc->opc = DMA_CDB_OPC_DFILL128; | ||
556 | } | ||
557 | |||
558 | /** | ||
559 | * ppc440spe_desc_set_src_addr - set source address into the descriptor | 536 | * ppc440spe_desc_set_src_addr - set source address into the descriptor |
560 | */ | 537 | */ |
561 | static void ppc440spe_desc_set_src_addr(struct ppc440spe_adma_desc_slot *desc, | 538 | static void ppc440spe_desc_set_src_addr(struct ppc440spe_adma_desc_slot *desc, |
@@ -1504,8 +1481,6 @@ static dma_cookie_t ppc440spe_adma_run_tx_complete_actions( | |||
1504 | struct ppc440spe_adma_chan *chan, | 1481 | struct ppc440spe_adma_chan *chan, |
1505 | dma_cookie_t cookie) | 1482 | dma_cookie_t cookie) |
1506 | { | 1483 | { |
1507 | int i; | ||
1508 | |||
1509 | BUG_ON(desc->async_tx.cookie < 0); | 1484 | BUG_ON(desc->async_tx.cookie < 0); |
1510 | if (desc->async_tx.cookie > 0) { | 1485 | if (desc->async_tx.cookie > 0) { |
1511 | cookie = desc->async_tx.cookie; | 1486 | cookie = desc->async_tx.cookie; |
@@ -3898,7 +3873,7 @@ static void ppc440spe_adma_init_capabilities(struct ppc440spe_adma_device *adev) | |||
3898 | ppc440spe_adma_prep_dma_interrupt; | 3873 | ppc440spe_adma_prep_dma_interrupt; |
3899 | } | 3874 | } |
3900 | pr_info("%s: AMCC(R) PPC440SP(E) ADMA Engine: " | 3875 | pr_info("%s: AMCC(R) PPC440SP(E) ADMA Engine: " |
3901 | "( %s%s%s%s%s%s%s)\n", | 3876 | "( %s%s%s%s%s%s)\n", |
3902 | dev_name(adev->dev), | 3877 | dev_name(adev->dev), |
3903 | dma_has_cap(DMA_PQ, adev->common.cap_mask) ? "pq " : "", | 3878 | dma_has_cap(DMA_PQ, adev->common.cap_mask) ? "pq " : "", |
3904 | dma_has_cap(DMA_PQ_VAL, adev->common.cap_mask) ? "pq_val " : "", | 3879 | dma_has_cap(DMA_PQ_VAL, adev->common.cap_mask) ? "pq_val " : "", |
diff --git a/drivers/dma/txx9dmac.c b/drivers/dma/txx9dmac.c index bae6c29f5502..17686caf64d5 100644 --- a/drivers/dma/txx9dmac.c +++ b/drivers/dma/txx9dmac.c | |||
@@ -406,7 +406,6 @@ txx9dmac_descriptor_complete(struct txx9dmac_chan *dc, | |||
406 | dma_async_tx_callback callback; | 406 | dma_async_tx_callback callback; |
407 | void *param; | 407 | void *param; |
408 | struct dma_async_tx_descriptor *txd = &desc->txd; | 408 | struct dma_async_tx_descriptor *txd = &desc->txd; |
409 | struct txx9dmac_slave *ds = dc->chan.private; | ||
410 | 409 | ||
411 | dev_vdbg(chan2dev(&dc->chan), "descriptor %u %p complete\n", | 410 | dev_vdbg(chan2dev(&dc->chan), "descriptor %u %p complete\n", |
412 | txd->cookie, desc); | 411 | txd->cookie, desc); |
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c index b0bb056458a3..281029daf98c 100644 --- a/drivers/firewire/sbp2.c +++ b/drivers/firewire/sbp2.c | |||
@@ -1623,7 +1623,6 @@ static struct scsi_host_template scsi_driver_template = { | |||
1623 | .cmd_per_lun = 1, | 1623 | .cmd_per_lun = 1, |
1624 | .can_queue = 1, | 1624 | .can_queue = 1, |
1625 | .sdev_attrs = sbp2_scsi_sysfs_attrs, | 1625 | .sdev_attrs = sbp2_scsi_sysfs_attrs, |
1626 | .no_write_same = 1, | ||
1627 | }; | 1626 | }; |
1628 | 1627 | ||
1629 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); | 1628 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); |
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 299fad6b5867..5373dc5b6011 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile | |||
@@ -14,3 +14,4 @@ obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o | |||
14 | 14 | ||
15 | obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ | 15 | obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ |
16 | obj-$(CONFIG_EFI) += efi/ | 16 | obj-$(CONFIG_EFI) += efi/ |
17 | obj-$(CONFIG_UEFI_CPER) += efi/ | ||
diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig index 3150aa4874e8..6aecbc86ec94 100644 --- a/drivers/firmware/efi/Kconfig +++ b/drivers/firmware/efi/Kconfig | |||
@@ -36,7 +36,7 @@ config EFI_VARS_PSTORE_DEFAULT_DISABLE | |||
36 | backend for pstore by default. This setting can be overridden | 36 | backend for pstore by default. This setting can be overridden |
37 | using the efivars module's pstore_disable parameter. | 37 | using the efivars module's pstore_disable parameter. |
38 | 38 | ||
39 | config UEFI_CPER | ||
40 | def_bool n | ||
41 | |||
42 | endmenu | 39 | endmenu |
40 | |||
41 | config UEFI_CPER | ||
42 | bool | ||
diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index 9ba156d3c775..6c2a41ec21ba 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Makefile for linux kernel | 2 | # Makefile for linux kernel |
3 | # | 3 | # |
4 | obj-y += efi.o vars.o | 4 | obj-$(CONFIG_EFI) += efi.o vars.o |
5 | obj-$(CONFIG_EFI_VARS) += efivars.o | 5 | obj-$(CONFIG_EFI_VARS) += efivars.o |
6 | obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o | 6 | obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o |
7 | obj-$(CONFIG_UEFI_CPER) += cper.o | 7 | obj-$(CONFIG_UEFI_CPER) += cper.o |
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c index 743fd426f21b..4b9dc836dcf9 100644 --- a/drivers/firmware/efi/efi-pstore.c +++ b/drivers/firmware/efi/efi-pstore.c | |||
@@ -356,6 +356,7 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, | |||
356 | static struct pstore_info efi_pstore_info = { | 356 | static struct pstore_info efi_pstore_info = { |
357 | .owner = THIS_MODULE, | 357 | .owner = THIS_MODULE, |
358 | .name = "efi", | 358 | .name = "efi", |
359 | .flags = PSTORE_FLAGS_FRAGILE, | ||
359 | .open = efi_pstore_open, | 360 | .open = efi_pstore_open, |
360 | .close = efi_pstore_close, | 361 | .close = efi_pstore_close, |
361 | .read = efi_pstore_read, | 362 | .read = efi_pstore_read, |
diff --git a/drivers/gpio/gpio-msm-v2.c b/drivers/gpio/gpio-msm-v2.c index 7b37300973db..2baf0ddf7e02 100644 --- a/drivers/gpio/gpio-msm-v2.c +++ b/drivers/gpio/gpio-msm-v2.c | |||
@@ -252,7 +252,7 @@ static void msm_gpio_irq_mask(struct irq_data *d) | |||
252 | 252 | ||
253 | spin_lock_irqsave(&tlmm_lock, irq_flags); | 253 | spin_lock_irqsave(&tlmm_lock, irq_flags); |
254 | writel(TARGET_PROC_NONE, GPIO_INTR_CFG_SU(gpio)); | 254 | writel(TARGET_PROC_NONE, GPIO_INTR_CFG_SU(gpio)); |
255 | clear_gpio_bits(INTR_RAW_STATUS_EN | INTR_ENABLE, GPIO_INTR_CFG(gpio)); | 255 | clear_gpio_bits(BIT(INTR_RAW_STATUS_EN) | BIT(INTR_ENABLE), GPIO_INTR_CFG(gpio)); |
256 | __clear_bit(gpio, msm_gpio.enabled_irqs); | 256 | __clear_bit(gpio, msm_gpio.enabled_irqs); |
257 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); | 257 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); |
258 | } | 258 | } |
@@ -264,7 +264,7 @@ static void msm_gpio_irq_unmask(struct irq_data *d) | |||
264 | 264 | ||
265 | spin_lock_irqsave(&tlmm_lock, irq_flags); | 265 | spin_lock_irqsave(&tlmm_lock, irq_flags); |
266 | __set_bit(gpio, msm_gpio.enabled_irqs); | 266 | __set_bit(gpio, msm_gpio.enabled_irqs); |
267 | set_gpio_bits(INTR_RAW_STATUS_EN | INTR_ENABLE, GPIO_INTR_CFG(gpio)); | 267 | set_gpio_bits(BIT(INTR_RAW_STATUS_EN) | BIT(INTR_ENABLE), GPIO_INTR_CFG(gpio)); |
268 | writel(TARGET_PROC_SCORPION, GPIO_INTR_CFG_SU(gpio)); | 268 | writel(TARGET_PROC_SCORPION, GPIO_INTR_CFG_SU(gpio)); |
269 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); | 269 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); |
270 | } | 270 | } |
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index fe088a30567a..8b7e719a68c3 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c | |||
@@ -169,7 +169,8 @@ static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id) | |||
169 | u32 pending; | 169 | u32 pending; |
170 | unsigned int offset, irqs_handled = 0; | 170 | unsigned int offset, irqs_handled = 0; |
171 | 171 | ||
172 | while ((pending = gpio_rcar_read(p, INTDT))) { | 172 | while ((pending = gpio_rcar_read(p, INTDT) & |
173 | gpio_rcar_read(p, INTMSK))) { | ||
173 | offset = __ffs(pending); | 174 | offset = __ffs(pending); |
174 | gpio_rcar_write(p, INTCLR, BIT(offset)); | 175 | gpio_rcar_write(p, INTCLR, BIT(offset)); |
175 | generic_handle_irq(irq_find_mapping(p->irq_domain, offset)); | 176 | generic_handle_irq(irq_find_mapping(p->irq_domain, offset)); |
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c index b97d6a6577b9..f9996899c1f2 100644 --- a/drivers/gpio/gpio-twl4030.c +++ b/drivers/gpio/gpio-twl4030.c | |||
@@ -300,7 +300,7 @@ static int twl_direction_in(struct gpio_chip *chip, unsigned offset) | |||
300 | if (offset < TWL4030_GPIO_MAX) | 300 | if (offset < TWL4030_GPIO_MAX) |
301 | ret = twl4030_set_gpio_direction(offset, 1); | 301 | ret = twl4030_set_gpio_direction(offset, 1); |
302 | else | 302 | else |
303 | ret = -EINVAL; | 303 | ret = -EINVAL; /* LED outputs can't be set as input */ |
304 | 304 | ||
305 | if (!ret) | 305 | if (!ret) |
306 | priv->direction &= ~BIT(offset); | 306 | priv->direction &= ~BIT(offset); |
@@ -354,11 +354,20 @@ static void twl_set(struct gpio_chip *chip, unsigned offset, int value) | |||
354 | static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value) | 354 | static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value) |
355 | { | 355 | { |
356 | struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); | 356 | struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); |
357 | int ret = -EINVAL; | 357 | int ret = 0; |
358 | 358 | ||
359 | mutex_lock(&priv->mutex); | 359 | mutex_lock(&priv->mutex); |
360 | if (offset < TWL4030_GPIO_MAX) | 360 | if (offset < TWL4030_GPIO_MAX) { |
361 | ret = twl4030_set_gpio_direction(offset, 0); | 361 | ret = twl4030_set_gpio_direction(offset, 0); |
362 | if (ret) { | ||
363 | mutex_unlock(&priv->mutex); | ||
364 | return ret; | ||
365 | } | ||
366 | } | ||
367 | |||
368 | /* | ||
369 | * LED gpios i.e. offset >= TWL4030_GPIO_MAX are always output | ||
370 | */ | ||
362 | 371 | ||
363 | priv->direction |= BIT(offset); | 372 | priv->direction |= BIT(offset); |
364 | mutex_unlock(&priv->mutex); | 373 | mutex_unlock(&priv->mutex); |
diff --git a/drivers/gpu/drm/armada/armada_drm.h b/drivers/gpu/drm/armada/armada_drm.h index eef09ec9a5ff..a72cae03b99b 100644 --- a/drivers/gpu/drm/armada/armada_drm.h +++ b/drivers/gpu/drm/armada/armada_drm.h | |||
@@ -103,6 +103,7 @@ void armada_drm_queue_unref_work(struct drm_device *, | |||
103 | extern const struct drm_mode_config_funcs armada_drm_mode_config_funcs; | 103 | extern const struct drm_mode_config_funcs armada_drm_mode_config_funcs; |
104 | 104 | ||
105 | int armada_fbdev_init(struct drm_device *); | 105 | int armada_fbdev_init(struct drm_device *); |
106 | void armada_fbdev_lastclose(struct drm_device *); | ||
106 | void armada_fbdev_fini(struct drm_device *); | 107 | void armada_fbdev_fini(struct drm_device *); |
107 | 108 | ||
108 | int armada_overlay_plane_create(struct drm_device *, unsigned long); | 109 | int armada_overlay_plane_create(struct drm_device *, unsigned long); |
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 4f2b28354915..62d0ff3efddf 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c | |||
@@ -321,6 +321,11 @@ static struct drm_ioctl_desc armada_ioctls[] = { | |||
321 | DRM_UNLOCKED), | 321 | DRM_UNLOCKED), |
322 | }; | 322 | }; |
323 | 323 | ||
324 | static void armada_drm_lastclose(struct drm_device *dev) | ||
325 | { | ||
326 | armada_fbdev_lastclose(dev); | ||
327 | } | ||
328 | |||
324 | static const struct file_operations armada_drm_fops = { | 329 | static const struct file_operations armada_drm_fops = { |
325 | .owner = THIS_MODULE, | 330 | .owner = THIS_MODULE, |
326 | .llseek = no_llseek, | 331 | .llseek = no_llseek, |
@@ -337,7 +342,7 @@ static struct drm_driver armada_drm_driver = { | |||
337 | .open = NULL, | 342 | .open = NULL, |
338 | .preclose = NULL, | 343 | .preclose = NULL, |
339 | .postclose = NULL, | 344 | .postclose = NULL, |
340 | .lastclose = NULL, | 345 | .lastclose = armada_drm_lastclose, |
341 | .unload = armada_drm_unload, | 346 | .unload = armada_drm_unload, |
342 | .get_vblank_counter = drm_vblank_count, | 347 | .get_vblank_counter = drm_vblank_count, |
343 | .enable_vblank = armada_drm_enable_vblank, | 348 | .enable_vblank = armada_drm_enable_vblank, |
diff --git a/drivers/gpu/drm/armada/armada_fbdev.c b/drivers/gpu/drm/armada/armada_fbdev.c index dd5ea77dac96..948cb14c561e 100644 --- a/drivers/gpu/drm/armada/armada_fbdev.c +++ b/drivers/gpu/drm/armada/armada_fbdev.c | |||
@@ -105,9 +105,9 @@ static int armada_fb_create(struct drm_fb_helper *fbh, | |||
105 | drm_fb_helper_fill_fix(info, dfb->fb.pitches[0], dfb->fb.depth); | 105 | drm_fb_helper_fill_fix(info, dfb->fb.pitches[0], dfb->fb.depth); |
106 | drm_fb_helper_fill_var(info, fbh, sizes->fb_width, sizes->fb_height); | 106 | drm_fb_helper_fill_var(info, fbh, sizes->fb_width, sizes->fb_height); |
107 | 107 | ||
108 | DRM_DEBUG_KMS("allocated %dx%d %dbpp fb: 0x%08x\n", | 108 | DRM_DEBUG_KMS("allocated %dx%d %dbpp fb: 0x%08llx\n", |
109 | dfb->fb.width, dfb->fb.height, | 109 | dfb->fb.width, dfb->fb.height, dfb->fb.bits_per_pixel, |
110 | dfb->fb.bits_per_pixel, obj->phys_addr); | 110 | (unsigned long long)obj->phys_addr); |
111 | 111 | ||
112 | return 0; | 112 | return 0; |
113 | 113 | ||
@@ -177,6 +177,16 @@ int armada_fbdev_init(struct drm_device *dev) | |||
177 | return ret; | 177 | return ret; |
178 | } | 178 | } |
179 | 179 | ||
180 | void armada_fbdev_lastclose(struct drm_device *dev) | ||
181 | { | ||
182 | struct armada_private *priv = dev->dev_private; | ||
183 | |||
184 | drm_modeset_lock_all(dev); | ||
185 | if (priv->fbdev) | ||
186 | drm_fb_helper_restore_fbdev_mode(priv->fbdev); | ||
187 | drm_modeset_unlock_all(dev); | ||
188 | } | ||
189 | |||
180 | void armada_fbdev_fini(struct drm_device *dev) | 190 | void armada_fbdev_fini(struct drm_device *dev) |
181 | { | 191 | { |
182 | struct armada_private *priv = dev->dev_private; | 192 | struct armada_private *priv = dev->dev_private; |
@@ -192,11 +202,11 @@ void armada_fbdev_fini(struct drm_device *dev) | |||
192 | framebuffer_release(info); | 202 | framebuffer_release(info); |
193 | } | 203 | } |
194 | 204 | ||
205 | drm_fb_helper_fini(fbh); | ||
206 | |||
195 | if (fbh->fb) | 207 | if (fbh->fb) |
196 | fbh->fb->funcs->destroy(fbh->fb); | 208 | fbh->fb->funcs->destroy(fbh->fb); |
197 | 209 | ||
198 | drm_fb_helper_fini(fbh); | ||
199 | |||
200 | priv->fbdev = NULL; | 210 | priv->fbdev = NULL; |
201 | } | 211 | } |
202 | } | 212 | } |
diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c index 9f2356bae7fd..887816f43476 100644 --- a/drivers/gpu/drm/armada/armada_gem.c +++ b/drivers/gpu/drm/armada/armada_gem.c | |||
@@ -172,8 +172,9 @@ armada_gem_linear_back(struct drm_device *dev, struct armada_gem_object *obj) | |||
172 | obj->dev_addr = obj->linear->start; | 172 | obj->dev_addr = obj->linear->start; |
173 | } | 173 | } |
174 | 174 | ||
175 | DRM_DEBUG_DRIVER("obj %p phys %#x dev %#x\n", | 175 | DRM_DEBUG_DRIVER("obj %p phys %#llx dev %#llx\n", obj, |
176 | obj, obj->phys_addr, obj->dev_addr); | 176 | (unsigned long long)obj->phys_addr, |
177 | (unsigned long long)obj->dev_addr); | ||
177 | 178 | ||
178 | return 0; | 179 | return 0; |
179 | } | 180 | } |
@@ -557,7 +558,6 @@ armada_gem_prime_import(struct drm_device *dev, struct dma_buf *buf) | |||
557 | * refcount on the gem object itself. | 558 | * refcount on the gem object itself. |
558 | */ | 559 | */ |
559 | drm_gem_object_reference(obj); | 560 | drm_gem_object_reference(obj); |
560 | dma_buf_put(buf); | ||
561 | return obj; | 561 | return obj; |
562 | } | 562 | } |
563 | } | 563 | } |
@@ -573,6 +573,7 @@ armada_gem_prime_import(struct drm_device *dev, struct dma_buf *buf) | |||
573 | } | 573 | } |
574 | 574 | ||
575 | dobj->obj.import_attach = attach; | 575 | dobj->obj.import_attach = attach; |
576 | get_dma_buf(buf); | ||
576 | 577 | ||
577 | /* | 578 | /* |
578 | * Don't call dma_buf_map_attachment() here - it maps the | 579 | * Don't call dma_buf_map_attachment() here - it maps the |
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 0a1e4a5f4234..8835dcddfac3 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c | |||
@@ -68,6 +68,8 @@ | |||
68 | #define EDID_QUIRK_DETAILED_SYNC_PP (1 << 6) | 68 | #define EDID_QUIRK_DETAILED_SYNC_PP (1 << 6) |
69 | /* Force reduced-blanking timings for detailed modes */ | 69 | /* Force reduced-blanking timings for detailed modes */ |
70 | #define EDID_QUIRK_FORCE_REDUCED_BLANKING (1 << 7) | 70 | #define EDID_QUIRK_FORCE_REDUCED_BLANKING (1 << 7) |
71 | /* Force 8bpc */ | ||
72 | #define EDID_QUIRK_FORCE_8BPC (1 << 8) | ||
71 | 73 | ||
72 | struct detailed_mode_closure { | 74 | struct detailed_mode_closure { |
73 | struct drm_connector *connector; | 75 | struct drm_connector *connector; |
@@ -128,6 +130,9 @@ static struct edid_quirk { | |||
128 | 130 | ||
129 | /* Medion MD 30217 PG */ | 131 | /* Medion MD 30217 PG */ |
130 | { "MED", 0x7b8, EDID_QUIRK_PREFER_LARGE_75 }, | 132 | { "MED", 0x7b8, EDID_QUIRK_PREFER_LARGE_75 }, |
133 | |||
134 | /* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */ | ||
135 | { "SEC", 0xd033, EDID_QUIRK_FORCE_8BPC }, | ||
131 | }; | 136 | }; |
132 | 137 | ||
133 | /* | 138 | /* |
@@ -3435,6 +3440,9 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid) | |||
3435 | 3440 | ||
3436 | drm_add_display_info(edid, &connector->display_info); | 3441 | drm_add_display_info(edid, &connector->display_info); |
3437 | 3442 | ||
3443 | if (quirks & EDID_QUIRK_FORCE_8BPC) | ||
3444 | connector->display_info.bpc = 8; | ||
3445 | |||
3438 | return num_modes; | 3446 | return num_modes; |
3439 | } | 3447 | } |
3440 | EXPORT_SYMBOL(drm_add_edid_modes); | 3448 | EXPORT_SYMBOL(drm_add_edid_modes); |
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index f53d5246979c..66dd3a001cf1 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c | |||
@@ -566,11 +566,11 @@ err_unload: | |||
566 | if (dev->driver->unload) | 566 | if (dev->driver->unload) |
567 | dev->driver->unload(dev); | 567 | dev->driver->unload(dev); |
568 | err_primary_node: | 568 | err_primary_node: |
569 | drm_put_minor(dev->primary); | 569 | drm_unplug_minor(dev->primary); |
570 | err_render_node: | 570 | err_render_node: |
571 | drm_put_minor(dev->render); | 571 | drm_unplug_minor(dev->render); |
572 | err_control_node: | 572 | err_control_node: |
573 | drm_put_minor(dev->control); | 573 | drm_unplug_minor(dev->control); |
574 | err_agp: | 574 | err_agp: |
575 | if (dev->driver->bus->agp_destroy) | 575 | if (dev->driver->bus->agp_destroy) |
576 | dev->driver->bus->agp_destroy(dev); | 576 | dev->driver->bus->agp_destroy(dev); |
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 0cab2d045135..5c648425c1e0 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -83,6 +83,14 @@ void i915_update_dri1_breadcrumb(struct drm_device *dev) | |||
83 | drm_i915_private_t *dev_priv = dev->dev_private; | 83 | drm_i915_private_t *dev_priv = dev->dev_private; |
84 | struct drm_i915_master_private *master_priv; | 84 | struct drm_i915_master_private *master_priv; |
85 | 85 | ||
86 | /* | ||
87 | * The dri breadcrumb update races against the drm master disappearing. | ||
88 | * Instead of trying to fix this (this is by far not the only ums issue) | ||
89 | * just don't do the update in kms mode. | ||
90 | */ | ||
91 | if (drm_core_check_feature(dev, DRIVER_MODESET)) | ||
92 | return; | ||
93 | |||
86 | if (dev->primary->master) { | 94 | if (dev->primary->master) { |
87 | master_priv = dev->primary->master->driver_priv; | 95 | master_priv = dev->primary->master->driver_priv; |
88 | if (master_priv->sarea_priv) | 96 | if (master_priv->sarea_priv) |
@@ -1490,16 +1498,9 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
1490 | spin_lock_init(&dev_priv->uncore.lock); | 1498 | spin_lock_init(&dev_priv->uncore.lock); |
1491 | spin_lock_init(&dev_priv->mm.object_stat_lock); | 1499 | spin_lock_init(&dev_priv->mm.object_stat_lock); |
1492 | mutex_init(&dev_priv->dpio_lock); | 1500 | mutex_init(&dev_priv->dpio_lock); |
1493 | mutex_init(&dev_priv->rps.hw_lock); | ||
1494 | mutex_init(&dev_priv->modeset_restore_lock); | 1501 | mutex_init(&dev_priv->modeset_restore_lock); |
1495 | 1502 | ||
1496 | mutex_init(&dev_priv->pc8.lock); | 1503 | intel_pm_setup(dev); |
1497 | dev_priv->pc8.requirements_met = false; | ||
1498 | dev_priv->pc8.gpu_idle = false; | ||
1499 | dev_priv->pc8.irqs_disabled = false; | ||
1500 | dev_priv->pc8.enabled = false; | ||
1501 | dev_priv->pc8.disable_count = 2; /* requirements_met + gpu_idle */ | ||
1502 | INIT_DELAYED_WORK(&dev_priv->pc8.enable_work, hsw_enable_pc8_work); | ||
1503 | 1504 | ||
1504 | intel_display_crc_init(dev); | 1505 | intel_display_crc_init(dev); |
1505 | 1506 | ||
@@ -1603,7 +1604,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
1603 | } | 1604 | } |
1604 | 1605 | ||
1605 | intel_irq_init(dev); | 1606 | intel_irq_init(dev); |
1606 | intel_pm_init(dev); | ||
1607 | intel_uncore_sanitize(dev); | 1607 | intel_uncore_sanitize(dev); |
1608 | 1608 | ||
1609 | /* Try to make sure MCHBAR is enabled before poking at it */ | 1609 | /* Try to make sure MCHBAR is enabled before poking at it */ |
@@ -1848,8 +1848,10 @@ void i915_driver_lastclose(struct drm_device * dev) | |||
1848 | 1848 | ||
1849 | void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) | 1849 | void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) |
1850 | { | 1850 | { |
1851 | mutex_lock(&dev->struct_mutex); | ||
1851 | i915_gem_context_close(dev, file_priv); | 1852 | i915_gem_context_close(dev, file_priv); |
1852 | i915_gem_release(dev, file_priv); | 1853 | i915_gem_release(dev, file_priv); |
1854 | mutex_unlock(&dev->struct_mutex); | ||
1853 | } | 1855 | } |
1854 | 1856 | ||
1855 | void i915_driver_postclose(struct drm_device *dev, struct drm_file *file) | 1857 | void i915_driver_postclose(struct drm_device *dev, struct drm_file *file) |
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 2e367a1c6a64..5b7b7e06cb3a 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
@@ -651,6 +651,7 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings) | |||
651 | intel_modeset_init_hw(dev); | 651 | intel_modeset_init_hw(dev); |
652 | 652 | ||
653 | drm_modeset_lock_all(dev); | 653 | drm_modeset_lock_all(dev); |
654 | drm_mode_config_reset(dev); | ||
654 | intel_modeset_setup_hw_state(dev, true); | 655 | intel_modeset_setup_hw_state(dev, true); |
655 | drm_modeset_unlock_all(dev); | 656 | drm_modeset_unlock_all(dev); |
656 | 657 | ||
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index ccdbecca070d..90fcccba17b0 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -1755,8 +1755,13 @@ struct drm_i915_file_private { | |||
1755 | #define IS_MOBILE(dev) (INTEL_INFO(dev)->is_mobile) | 1755 | #define IS_MOBILE(dev) (INTEL_INFO(dev)->is_mobile) |
1756 | #define IS_HSW_EARLY_SDV(dev) (IS_HASWELL(dev) && \ | 1756 | #define IS_HSW_EARLY_SDV(dev) (IS_HASWELL(dev) && \ |
1757 | ((dev)->pdev->device & 0xFF00) == 0x0C00) | 1757 | ((dev)->pdev->device & 0xFF00) == 0x0C00) |
1758 | #define IS_ULT(dev) (IS_HASWELL(dev) && \ | 1758 | #define IS_BDW_ULT(dev) (IS_BROADWELL(dev) && \ |
1759 | (((dev)->pdev->device & 0xf) == 0x2 || \ | ||
1760 | ((dev)->pdev->device & 0xf) == 0x6 || \ | ||
1761 | ((dev)->pdev->device & 0xf) == 0xe)) | ||
1762 | #define IS_HSW_ULT(dev) (IS_HASWELL(dev) && \ | ||
1759 | ((dev)->pdev->device & 0xFF00) == 0x0A00) | 1763 | ((dev)->pdev->device & 0xFF00) == 0x0A00) |
1764 | #define IS_ULT(dev) (IS_HSW_ULT(dev) || IS_BDW_ULT(dev)) | ||
1760 | #define IS_HSW_GT3(dev) (IS_HASWELL(dev) && \ | 1765 | #define IS_HSW_GT3(dev) (IS_HASWELL(dev) && \ |
1761 | ((dev)->pdev->device & 0x00F0) == 0x0020) | 1766 | ((dev)->pdev->device & 0x00F0) == 0x0020) |
1762 | #define IS_PRELIMINARY_HW(intel_info) ((intel_info)->is_preliminary) | 1767 | #define IS_PRELIMINARY_HW(intel_info) ((intel_info)->is_preliminary) |
@@ -1901,9 +1906,7 @@ void i915_queue_hangcheck(struct drm_device *dev); | |||
1901 | void i915_handle_error(struct drm_device *dev, bool wedged); | 1906 | void i915_handle_error(struct drm_device *dev, bool wedged); |
1902 | 1907 | ||
1903 | extern void intel_irq_init(struct drm_device *dev); | 1908 | extern void intel_irq_init(struct drm_device *dev); |
1904 | extern void intel_pm_init(struct drm_device *dev); | ||
1905 | extern void intel_hpd_init(struct drm_device *dev); | 1909 | extern void intel_hpd_init(struct drm_device *dev); |
1906 | extern void intel_pm_init(struct drm_device *dev); | ||
1907 | 1910 | ||
1908 | extern void intel_uncore_sanitize(struct drm_device *dev); | 1911 | extern void intel_uncore_sanitize(struct drm_device *dev); |
1909 | extern void intel_uncore_early_sanitize(struct drm_device *dev); | 1912 | extern void intel_uncore_early_sanitize(struct drm_device *dev); |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 621c7c67a643..76d3d1ab73c6 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -2343,15 +2343,24 @@ static void i915_gem_free_request(struct drm_i915_gem_request *request) | |||
2343 | kfree(request); | 2343 | kfree(request); |
2344 | } | 2344 | } |
2345 | 2345 | ||
2346 | static void i915_gem_reset_ring_lists(struct drm_i915_private *dev_priv, | 2346 | static void i915_gem_reset_ring_status(struct drm_i915_private *dev_priv, |
2347 | struct intel_ring_buffer *ring) | 2347 | struct intel_ring_buffer *ring) |
2348 | { | 2348 | { |
2349 | u32 completed_seqno; | 2349 | u32 completed_seqno = ring->get_seqno(ring, false); |
2350 | u32 acthd; | 2350 | u32 acthd = intel_ring_get_active_head(ring); |
2351 | struct drm_i915_gem_request *request; | ||
2352 | |||
2353 | list_for_each_entry(request, &ring->request_list, list) { | ||
2354 | if (i915_seqno_passed(completed_seqno, request->seqno)) | ||
2355 | continue; | ||
2351 | 2356 | ||
2352 | acthd = intel_ring_get_active_head(ring); | 2357 | i915_set_reset_status(ring, request, acthd); |
2353 | completed_seqno = ring->get_seqno(ring, false); | 2358 | } |
2359 | } | ||
2354 | 2360 | ||
2361 | static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv, | ||
2362 | struct intel_ring_buffer *ring) | ||
2363 | { | ||
2355 | while (!list_empty(&ring->request_list)) { | 2364 | while (!list_empty(&ring->request_list)) { |
2356 | struct drm_i915_gem_request *request; | 2365 | struct drm_i915_gem_request *request; |
2357 | 2366 | ||
@@ -2359,9 +2368,6 @@ static void i915_gem_reset_ring_lists(struct drm_i915_private *dev_priv, | |||
2359 | struct drm_i915_gem_request, | 2368 | struct drm_i915_gem_request, |
2360 | list); | 2369 | list); |
2361 | 2370 | ||
2362 | if (request->seqno > completed_seqno) | ||
2363 | i915_set_reset_status(ring, request, acthd); | ||
2364 | |||
2365 | i915_gem_free_request(request); | 2371 | i915_gem_free_request(request); |
2366 | } | 2372 | } |
2367 | 2373 | ||
@@ -2403,8 +2409,16 @@ void i915_gem_reset(struct drm_device *dev) | |||
2403 | struct intel_ring_buffer *ring; | 2409 | struct intel_ring_buffer *ring; |
2404 | int i; | 2410 | int i; |
2405 | 2411 | ||
2412 | /* | ||
2413 | * Before we free the objects from the requests, we need to inspect | ||
2414 | * them for finding the guilty party. As the requests only borrow | ||
2415 | * their reference to the objects, the inspection must be done first. | ||
2416 | */ | ||
2417 | for_each_ring(ring, dev_priv, i) | ||
2418 | i915_gem_reset_ring_status(dev_priv, ring); | ||
2419 | |||
2406 | for_each_ring(ring, dev_priv, i) | 2420 | for_each_ring(ring, dev_priv, i) |
2407 | i915_gem_reset_ring_lists(dev_priv, ring); | 2421 | i915_gem_reset_ring_cleanup(dev_priv, ring); |
2408 | 2422 | ||
2409 | i915_gem_cleanup_ringbuffer(dev); | 2423 | i915_gem_cleanup_ringbuffer(dev); |
2410 | 2424 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 72a3df32292f..b0f42b9ca037 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
@@ -347,10 +347,8 @@ void i915_gem_context_close(struct drm_device *dev, struct drm_file *file) | |||
347 | { | 347 | { |
348 | struct drm_i915_file_private *file_priv = file->driver_priv; | 348 | struct drm_i915_file_private *file_priv = file->driver_priv; |
349 | 349 | ||
350 | mutex_lock(&dev->struct_mutex); | ||
351 | idr_for_each(&file_priv->context_idr, context_idr_cleanup, NULL); | 350 | idr_for_each(&file_priv->context_idr, context_idr_cleanup, NULL); |
352 | idr_destroy(&file_priv->context_idr); | 351 | idr_destroy(&file_priv->context_idr); |
353 | mutex_unlock(&dev->struct_mutex); | ||
354 | } | 352 | } |
355 | 353 | ||
356 | static struct i915_hw_context * | 354 | static struct i915_hw_context * |
@@ -423,11 +421,21 @@ static int do_switch(struct i915_hw_context *to) | |||
423 | if (ret) | 421 | if (ret) |
424 | return ret; | 422 | return ret; |
425 | 423 | ||
426 | /* Clear this page out of any CPU caches for coherent swap-in/out. Note | 424 | /* |
425 | * Pin can switch back to the default context if we end up calling into | ||
426 | * evict_everything - as a last ditch gtt defrag effort that also | ||
427 | * switches to the default context. Hence we need to reload from here. | ||
428 | */ | ||
429 | from = ring->last_context; | ||
430 | |||
431 | /* | ||
432 | * Clear this page out of any CPU caches for coherent swap-in/out. Note | ||
427 | * that thanks to write = false in this call and us not setting any gpu | 433 | * that thanks to write = false in this call and us not setting any gpu |
428 | * write domains when putting a context object onto the active list | 434 | * write domains when putting a context object onto the active list |
429 | * (when switching away from it), this won't block. | 435 | * (when switching away from it), this won't block. |
430 | * XXX: We need a real interface to do this instead of trickery. */ | 436 | * |
437 | * XXX: We need a real interface to do this instead of trickery. | ||
438 | */ | ||
431 | ret = i915_gem_object_set_to_gtt_domain(to->obj, false); | 439 | ret = i915_gem_object_set_to_gtt_domain(to->obj, false); |
432 | if (ret) { | 440 | if (ret) { |
433 | i915_gem_object_unpin(to->obj); | 441 | i915_gem_object_unpin(to->obj); |
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c index b7376533633d..8f3adc7d0dc8 100644 --- a/drivers/gpu/drm/i915/i915_gem_evict.c +++ b/drivers/gpu/drm/i915/i915_gem_evict.c | |||
@@ -88,6 +88,7 @@ i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm, | |||
88 | } else | 88 | } else |
89 | drm_mm_init_scan(&vm->mm, min_size, alignment, cache_level); | 89 | drm_mm_init_scan(&vm->mm, min_size, alignment, cache_level); |
90 | 90 | ||
91 | search_again: | ||
91 | /* First see if there is a large enough contiguous idle region... */ | 92 | /* First see if there is a large enough contiguous idle region... */ |
92 | list_for_each_entry(vma, &vm->inactive_list, mm_list) { | 93 | list_for_each_entry(vma, &vm->inactive_list, mm_list) { |
93 | if (mark_free(vma, &unwind_list)) | 94 | if (mark_free(vma, &unwind_list)) |
@@ -115,10 +116,17 @@ none: | |||
115 | list_del_init(&vma->exec_list); | 116 | list_del_init(&vma->exec_list); |
116 | } | 117 | } |
117 | 118 | ||
118 | /* We expect the caller to unpin, evict all and try again, or give up. | 119 | /* Can we unpin some objects such as idle hw contents, |
119 | * So calling i915_gem_evict_vm() is unnecessary. | 120 | * or pending flips? |
120 | */ | 121 | */ |
121 | return -ENOSPC; | 122 | ret = nonblocking ? -ENOSPC : i915_gpu_idle(dev); |
123 | if (ret) | ||
124 | return ret; | ||
125 | |||
126 | /* Only idle the GPU and repeat the search once */ | ||
127 | i915_gem_retire_requests(dev); | ||
128 | nonblocking = true; | ||
129 | goto search_again; | ||
122 | 130 | ||
123 | found: | 131 | found: |
124 | /* drm_mm doesn't allow any other other operations while | 132 | /* drm_mm doesn't allow any other other operations while |
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index b7e787fb4649..a3ba9a8cd687 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c | |||
@@ -93,7 +93,7 @@ eb_lookup_vmas(struct eb_vmas *eb, | |||
93 | { | 93 | { |
94 | struct drm_i915_gem_object *obj; | 94 | struct drm_i915_gem_object *obj; |
95 | struct list_head objects; | 95 | struct list_head objects; |
96 | int i, ret = 0; | 96 | int i, ret; |
97 | 97 | ||
98 | INIT_LIST_HEAD(&objects); | 98 | INIT_LIST_HEAD(&objects); |
99 | spin_lock(&file->table_lock); | 99 | spin_lock(&file->table_lock); |
@@ -106,7 +106,7 @@ eb_lookup_vmas(struct eb_vmas *eb, | |||
106 | DRM_DEBUG("Invalid object handle %d at index %d\n", | 106 | DRM_DEBUG("Invalid object handle %d at index %d\n", |
107 | exec[i].handle, i); | 107 | exec[i].handle, i); |
108 | ret = -ENOENT; | 108 | ret = -ENOENT; |
109 | goto out; | 109 | goto err; |
110 | } | 110 | } |
111 | 111 | ||
112 | if (!list_empty(&obj->obj_exec_link)) { | 112 | if (!list_empty(&obj->obj_exec_link)) { |
@@ -114,7 +114,7 @@ eb_lookup_vmas(struct eb_vmas *eb, | |||
114 | DRM_DEBUG("Object %p [handle %d, index %d] appears more than once in object list\n", | 114 | DRM_DEBUG("Object %p [handle %d, index %d] appears more than once in object list\n", |
115 | obj, exec[i].handle, i); | 115 | obj, exec[i].handle, i); |
116 | ret = -EINVAL; | 116 | ret = -EINVAL; |
117 | goto out; | 117 | goto err; |
118 | } | 118 | } |
119 | 119 | ||
120 | drm_gem_object_reference(&obj->base); | 120 | drm_gem_object_reference(&obj->base); |
@@ -123,9 +123,13 @@ eb_lookup_vmas(struct eb_vmas *eb, | |||
123 | spin_unlock(&file->table_lock); | 123 | spin_unlock(&file->table_lock); |
124 | 124 | ||
125 | i = 0; | 125 | i = 0; |
126 | list_for_each_entry(obj, &objects, obj_exec_link) { | 126 | while (!list_empty(&objects)) { |
127 | struct i915_vma *vma; | 127 | struct i915_vma *vma; |
128 | 128 | ||
129 | obj = list_first_entry(&objects, | ||
130 | struct drm_i915_gem_object, | ||
131 | obj_exec_link); | ||
132 | |||
129 | /* | 133 | /* |
130 | * NOTE: We can leak any vmas created here when something fails | 134 | * NOTE: We can leak any vmas created here when something fails |
131 | * later on. But that's no issue since vma_unbind can deal with | 135 | * later on. But that's no issue since vma_unbind can deal with |
@@ -138,10 +142,12 @@ eb_lookup_vmas(struct eb_vmas *eb, | |||
138 | if (IS_ERR(vma)) { | 142 | if (IS_ERR(vma)) { |
139 | DRM_DEBUG("Failed to lookup VMA\n"); | 143 | DRM_DEBUG("Failed to lookup VMA\n"); |
140 | ret = PTR_ERR(vma); | 144 | ret = PTR_ERR(vma); |
141 | goto out; | 145 | goto err; |
142 | } | 146 | } |
143 | 147 | ||
148 | /* Transfer ownership from the objects list to the vmas list. */ | ||
144 | list_add_tail(&vma->exec_list, &eb->vmas); | 149 | list_add_tail(&vma->exec_list, &eb->vmas); |
150 | list_del_init(&obj->obj_exec_link); | ||
145 | 151 | ||
146 | vma->exec_entry = &exec[i]; | 152 | vma->exec_entry = &exec[i]; |
147 | if (eb->and < 0) { | 153 | if (eb->and < 0) { |
@@ -155,16 +161,22 @@ eb_lookup_vmas(struct eb_vmas *eb, | |||
155 | ++i; | 161 | ++i; |
156 | } | 162 | } |
157 | 163 | ||
164 | return 0; | ||
165 | |||
158 | 166 | ||
159 | out: | 167 | err: |
160 | while (!list_empty(&objects)) { | 168 | while (!list_empty(&objects)) { |
161 | obj = list_first_entry(&objects, | 169 | obj = list_first_entry(&objects, |
162 | struct drm_i915_gem_object, | 170 | struct drm_i915_gem_object, |
163 | obj_exec_link); | 171 | obj_exec_link); |
164 | list_del_init(&obj->obj_exec_link); | 172 | list_del_init(&obj->obj_exec_link); |
165 | if (ret) | 173 | drm_gem_object_unreference(&obj->base); |
166 | drm_gem_object_unreference(&obj->base); | ||
167 | } | 174 | } |
175 | /* | ||
176 | * Objects already transfered to the vmas list will be unreferenced by | ||
177 | * eb_destroy. | ||
178 | */ | ||
179 | |||
168 | return ret; | 180 | return ret; |
169 | } | 181 | } |
170 | 182 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 38cb8d44a013..c79dd2b1f70e 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c | |||
@@ -337,8 +337,8 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm) | |||
337 | kfree(ppgtt->gen8_pt_dma_addr[i]); | 337 | kfree(ppgtt->gen8_pt_dma_addr[i]); |
338 | } | 338 | } |
339 | 339 | ||
340 | __free_pages(ppgtt->gen8_pt_pages, ppgtt->num_pt_pages << PAGE_SHIFT); | 340 | __free_pages(ppgtt->gen8_pt_pages, get_order(ppgtt->num_pt_pages << PAGE_SHIFT)); |
341 | __free_pages(ppgtt->pd_pages, ppgtt->num_pd_pages << PAGE_SHIFT); | 341 | __free_pages(ppgtt->pd_pages, get_order(ppgtt->num_pd_pages << PAGE_SHIFT)); |
342 | } | 342 | } |
343 | 343 | ||
344 | /** | 344 | /** |
@@ -1241,6 +1241,11 @@ static inline unsigned int gen8_get_total_gtt_size(u16 bdw_gmch_ctl) | |||
1241 | bdw_gmch_ctl &= BDW_GMCH_GGMS_MASK; | 1241 | bdw_gmch_ctl &= BDW_GMCH_GGMS_MASK; |
1242 | if (bdw_gmch_ctl) | 1242 | if (bdw_gmch_ctl) |
1243 | bdw_gmch_ctl = 1 << bdw_gmch_ctl; | 1243 | bdw_gmch_ctl = 1 << bdw_gmch_ctl; |
1244 | if (bdw_gmch_ctl > 4) { | ||
1245 | WARN_ON(!i915_preliminary_hw_support); | ||
1246 | return 4<<20; | ||
1247 | } | ||
1248 | |||
1244 | return bdw_gmch_ctl << 20; | 1249 | return bdw_gmch_ctl << 20; |
1245 | } | 1250 | } |
1246 | 1251 | ||
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 080f6fd4e839..54e82a80cf50 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -6303,7 +6303,7 @@ static void assert_can_disable_lcpll(struct drm_i915_private *dev_priv) | |||
6303 | uint32_t val; | 6303 | uint32_t val; |
6304 | 6304 | ||
6305 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) | 6305 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) |
6306 | WARN(crtc->base.enabled, "CRTC for pipe %c enabled\n", | 6306 | WARN(crtc->active, "CRTC for pipe %c enabled\n", |
6307 | pipe_name(crtc->pipe)); | 6307 | pipe_name(crtc->pipe)); |
6308 | 6308 | ||
6309 | WARN(I915_READ(HSW_PWR_WELL_DRIVER), "Power well on\n"); | 6309 | WARN(I915_READ(HSW_PWR_WELL_DRIVER), "Power well on\n"); |
@@ -9135,7 +9135,7 @@ intel_pipe_config_compare(struct drm_device *dev, | |||
9135 | if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) | 9135 | if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) |
9136 | PIPE_CONF_CHECK_I(pipe_bpp); | 9136 | PIPE_CONF_CHECK_I(pipe_bpp); |
9137 | 9137 | ||
9138 | if (!IS_HASWELL(dev)) { | 9138 | if (!HAS_DDI(dev)) { |
9139 | PIPE_CONF_CHECK_CLOCK_FUZZY(adjusted_mode.crtc_clock); | 9139 | PIPE_CONF_CHECK_CLOCK_FUZZY(adjusted_mode.crtc_clock); |
9140 | PIPE_CONF_CHECK_CLOCK_FUZZY(port_clock); | 9140 | PIPE_CONF_CHECK_CLOCK_FUZZY(port_clock); |
9141 | } | 9141 | } |
@@ -11036,8 +11036,6 @@ void intel_modeset_setup_hw_state(struct drm_device *dev, | |||
11036 | } | 11036 | } |
11037 | 11037 | ||
11038 | intel_modeset_check_state(dev); | 11038 | intel_modeset_check_state(dev); |
11039 | |||
11040 | drm_mode_config_reset(dev); | ||
11041 | } | 11039 | } |
11042 | 11040 | ||
11043 | void intel_modeset_gem_init(struct drm_device *dev) | 11041 | void intel_modeset_gem_init(struct drm_device *dev) |
@@ -11046,7 +11044,10 @@ void intel_modeset_gem_init(struct drm_device *dev) | |||
11046 | 11044 | ||
11047 | intel_setup_overlay(dev); | 11045 | intel_setup_overlay(dev); |
11048 | 11046 | ||
11047 | drm_modeset_lock_all(dev); | ||
11048 | drm_mode_config_reset(dev); | ||
11049 | intel_modeset_setup_hw_state(dev, false); | 11049 | intel_modeset_setup_hw_state(dev, false); |
11050 | drm_modeset_unlock_all(dev); | ||
11050 | } | 11051 | } |
11051 | 11052 | ||
11052 | void intel_modeset_cleanup(struct drm_device *dev) | 11053 | void intel_modeset_cleanup(struct drm_device *dev) |
@@ -11125,14 +11126,15 @@ void intel_connector_attach_encoder(struct intel_connector *connector, | |||
11125 | int intel_modeset_vga_set_state(struct drm_device *dev, bool state) | 11126 | int intel_modeset_vga_set_state(struct drm_device *dev, bool state) |
11126 | { | 11127 | { |
11127 | struct drm_i915_private *dev_priv = dev->dev_private; | 11128 | struct drm_i915_private *dev_priv = dev->dev_private; |
11129 | unsigned reg = INTEL_INFO(dev)->gen >= 6 ? SNB_GMCH_CTRL : INTEL_GMCH_CTRL; | ||
11128 | u16 gmch_ctrl; | 11130 | u16 gmch_ctrl; |
11129 | 11131 | ||
11130 | pci_read_config_word(dev_priv->bridge_dev, INTEL_GMCH_CTRL, &gmch_ctrl); | 11132 | pci_read_config_word(dev_priv->bridge_dev, reg, &gmch_ctrl); |
11131 | if (state) | 11133 | if (state) |
11132 | gmch_ctrl &= ~INTEL_GMCH_VGA_DISABLE; | 11134 | gmch_ctrl &= ~INTEL_GMCH_VGA_DISABLE; |
11133 | else | 11135 | else |
11134 | gmch_ctrl |= INTEL_GMCH_VGA_DISABLE; | 11136 | gmch_ctrl |= INTEL_GMCH_VGA_DISABLE; |
11135 | pci_write_config_word(dev_priv->bridge_dev, INTEL_GMCH_CTRL, gmch_ctrl); | 11137 | pci_write_config_word(dev_priv->bridge_dev, reg, gmch_ctrl); |
11136 | return 0; | 11138 | return 0; |
11137 | } | 11139 | } |
11138 | 11140 | ||
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index a18e88b3e425..79f91f26e288 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -821,6 +821,7 @@ void intel_update_sprite_watermarks(struct drm_plane *plane, | |||
821 | uint32_t sprite_width, int pixel_size, | 821 | uint32_t sprite_width, int pixel_size, |
822 | bool enabled, bool scaled); | 822 | bool enabled, bool scaled); |
823 | void intel_init_pm(struct drm_device *dev); | 823 | void intel_init_pm(struct drm_device *dev); |
824 | void intel_pm_setup(struct drm_device *dev); | ||
824 | bool intel_fbc_enabled(struct drm_device *dev); | 825 | bool intel_fbc_enabled(struct drm_device *dev); |
825 | void intel_update_fbc(struct drm_device *dev); | 826 | void intel_update_fbc(struct drm_device *dev); |
826 | void intel_gpu_ips_init(struct drm_i915_private *dev_priv); | 827 | void intel_gpu_ips_init(struct drm_i915_private *dev_priv); |
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index f161ac02c4f6..e6f782d1c669 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c | |||
@@ -451,7 +451,9 @@ static u32 intel_panel_get_backlight(struct drm_device *dev, | |||
451 | 451 | ||
452 | spin_lock_irqsave(&dev_priv->backlight.lock, flags); | 452 | spin_lock_irqsave(&dev_priv->backlight.lock, flags); |
453 | 453 | ||
454 | if (HAS_PCH_SPLIT(dev)) { | 454 | if (IS_BROADWELL(dev)) { |
455 | val = I915_READ(BLC_PWM_PCH_CTL2) & BACKLIGHT_DUTY_CYCLE_MASK; | ||
456 | } else if (HAS_PCH_SPLIT(dev)) { | ||
455 | val = I915_READ(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK; | 457 | val = I915_READ(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK; |
456 | } else { | 458 | } else { |
457 | if (IS_VALLEYVIEW(dev)) | 459 | if (IS_VALLEYVIEW(dev)) |
@@ -479,6 +481,13 @@ static u32 intel_panel_get_backlight(struct drm_device *dev, | |||
479 | return val; | 481 | return val; |
480 | } | 482 | } |
481 | 483 | ||
484 | static void intel_bdw_panel_set_backlight(struct drm_device *dev, u32 level) | ||
485 | { | ||
486 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
487 | u32 val = I915_READ(BLC_PWM_PCH_CTL2) & ~BACKLIGHT_DUTY_CYCLE_MASK; | ||
488 | I915_WRITE(BLC_PWM_PCH_CTL2, val | level); | ||
489 | } | ||
490 | |||
482 | static void intel_pch_panel_set_backlight(struct drm_device *dev, u32 level) | 491 | static void intel_pch_panel_set_backlight(struct drm_device *dev, u32 level) |
483 | { | 492 | { |
484 | struct drm_i915_private *dev_priv = dev->dev_private; | 493 | struct drm_i915_private *dev_priv = dev->dev_private; |
@@ -496,7 +505,9 @@ static void intel_panel_actually_set_backlight(struct drm_device *dev, | |||
496 | DRM_DEBUG_DRIVER("set backlight PWM = %d\n", level); | 505 | DRM_DEBUG_DRIVER("set backlight PWM = %d\n", level); |
497 | level = intel_panel_compute_brightness(dev, pipe, level); | 506 | level = intel_panel_compute_brightness(dev, pipe, level); |
498 | 507 | ||
499 | if (HAS_PCH_SPLIT(dev)) | 508 | if (IS_BROADWELL(dev)) |
509 | return intel_bdw_panel_set_backlight(dev, level); | ||
510 | else if (HAS_PCH_SPLIT(dev)) | ||
500 | return intel_pch_panel_set_backlight(dev, level); | 511 | return intel_pch_panel_set_backlight(dev, level); |
501 | 512 | ||
502 | if (is_backlight_combination_mode(dev)) { | 513 | if (is_backlight_combination_mode(dev)) { |
@@ -666,7 +677,16 @@ void intel_panel_enable_backlight(struct intel_connector *connector) | |||
666 | POSTING_READ(reg); | 677 | POSTING_READ(reg); |
667 | I915_WRITE(reg, tmp | BLM_PWM_ENABLE); | 678 | I915_WRITE(reg, tmp | BLM_PWM_ENABLE); |
668 | 679 | ||
669 | if (HAS_PCH_SPLIT(dev) && | 680 | if (IS_BROADWELL(dev)) { |
681 | /* | ||
682 | * Broadwell requires PCH override to drive the PCH | ||
683 | * backlight pin. The above will configure the CPU | ||
684 | * backlight pin, which we don't plan to use. | ||
685 | */ | ||
686 | tmp = I915_READ(BLC_PWM_PCH_CTL1); | ||
687 | tmp |= BLM_PCH_OVERRIDE_ENABLE | BLM_PCH_PWM_ENABLE; | ||
688 | I915_WRITE(BLC_PWM_PCH_CTL1, tmp); | ||
689 | } else if (HAS_PCH_SPLIT(dev) && | ||
670 | !(dev_priv->quirks & QUIRK_NO_PCH_PWM_ENABLE)) { | 690 | !(dev_priv->quirks & QUIRK_NO_PCH_PWM_ENABLE)) { |
671 | tmp = I915_READ(BLC_PWM_PCH_CTL1); | 691 | tmp = I915_READ(BLC_PWM_PCH_CTL1); |
672 | tmp |= BLM_PCH_PWM_ENABLE; | 692 | tmp |= BLM_PCH_PWM_ENABLE; |
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index 6e0d5e075b15..26c29c173221 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c | |||
@@ -5685,8 +5685,11 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable) | |||
5685 | { | 5685 | { |
5686 | struct drm_i915_private *dev_priv = dev->dev_private; | 5686 | struct drm_i915_private *dev_priv = dev->dev_private; |
5687 | bool is_enabled, enable_requested; | 5687 | bool is_enabled, enable_requested; |
5688 | unsigned long irqflags; | ||
5688 | uint32_t tmp; | 5689 | uint32_t tmp; |
5689 | 5690 | ||
5691 | WARN_ON(dev_priv->pc8.enabled); | ||
5692 | |||
5690 | tmp = I915_READ(HSW_PWR_WELL_DRIVER); | 5693 | tmp = I915_READ(HSW_PWR_WELL_DRIVER); |
5691 | is_enabled = tmp & HSW_PWR_WELL_STATE_ENABLED; | 5694 | is_enabled = tmp & HSW_PWR_WELL_STATE_ENABLED; |
5692 | enable_requested = tmp & HSW_PWR_WELL_ENABLE_REQUEST; | 5695 | enable_requested = tmp & HSW_PWR_WELL_ENABLE_REQUEST; |
@@ -5702,9 +5705,24 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable) | |||
5702 | HSW_PWR_WELL_STATE_ENABLED), 20)) | 5705 | HSW_PWR_WELL_STATE_ENABLED), 20)) |
5703 | DRM_ERROR("Timeout enabling power well\n"); | 5706 | DRM_ERROR("Timeout enabling power well\n"); |
5704 | } | 5707 | } |
5708 | |||
5709 | if (IS_BROADWELL(dev)) { | ||
5710 | spin_lock_irqsave(&dev_priv->irq_lock, irqflags); | ||
5711 | I915_WRITE(GEN8_DE_PIPE_IMR(PIPE_B), | ||
5712 | dev_priv->de_irq_mask[PIPE_B]); | ||
5713 | I915_WRITE(GEN8_DE_PIPE_IER(PIPE_B), | ||
5714 | ~dev_priv->de_irq_mask[PIPE_B] | | ||
5715 | GEN8_PIPE_VBLANK); | ||
5716 | I915_WRITE(GEN8_DE_PIPE_IMR(PIPE_C), | ||
5717 | dev_priv->de_irq_mask[PIPE_C]); | ||
5718 | I915_WRITE(GEN8_DE_PIPE_IER(PIPE_C), | ||
5719 | ~dev_priv->de_irq_mask[PIPE_C] | | ||
5720 | GEN8_PIPE_VBLANK); | ||
5721 | POSTING_READ(GEN8_DE_PIPE_IER(PIPE_C)); | ||
5722 | spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); | ||
5723 | } | ||
5705 | } else { | 5724 | } else { |
5706 | if (enable_requested) { | 5725 | if (enable_requested) { |
5707 | unsigned long irqflags; | ||
5708 | enum pipe p; | 5726 | enum pipe p; |
5709 | 5727 | ||
5710 | I915_WRITE(HSW_PWR_WELL_DRIVER, 0); | 5728 | I915_WRITE(HSW_PWR_WELL_DRIVER, 0); |
@@ -5731,16 +5749,24 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable) | |||
5731 | static void __intel_power_well_get(struct drm_device *dev, | 5749 | static void __intel_power_well_get(struct drm_device *dev, |
5732 | struct i915_power_well *power_well) | 5750 | struct i915_power_well *power_well) |
5733 | { | 5751 | { |
5734 | if (!power_well->count++) | 5752 | struct drm_i915_private *dev_priv = dev->dev_private; |
5753 | |||
5754 | if (!power_well->count++) { | ||
5755 | hsw_disable_package_c8(dev_priv); | ||
5735 | __intel_set_power_well(dev, true); | 5756 | __intel_set_power_well(dev, true); |
5757 | } | ||
5736 | } | 5758 | } |
5737 | 5759 | ||
5738 | static void __intel_power_well_put(struct drm_device *dev, | 5760 | static void __intel_power_well_put(struct drm_device *dev, |
5739 | struct i915_power_well *power_well) | 5761 | struct i915_power_well *power_well) |
5740 | { | 5762 | { |
5763 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
5764 | |||
5741 | WARN_ON(!power_well->count); | 5765 | WARN_ON(!power_well->count); |
5742 | if (!--power_well->count && i915_disable_power_well) | 5766 | if (!--power_well->count && i915_disable_power_well) { |
5743 | __intel_set_power_well(dev, false); | 5767 | __intel_set_power_well(dev, false); |
5768 | hsw_enable_package_c8(dev_priv); | ||
5769 | } | ||
5744 | } | 5770 | } |
5745 | 5771 | ||
5746 | void intel_display_power_get(struct drm_device *dev, | 5772 | void intel_display_power_get(struct drm_device *dev, |
@@ -6130,10 +6156,19 @@ int vlv_freq_opcode(int ddr_freq, int val) | |||
6130 | return val; | 6156 | return val; |
6131 | } | 6157 | } |
6132 | 6158 | ||
6133 | void intel_pm_init(struct drm_device *dev) | 6159 | void intel_pm_setup(struct drm_device *dev) |
6134 | { | 6160 | { |
6135 | struct drm_i915_private *dev_priv = dev->dev_private; | 6161 | struct drm_i915_private *dev_priv = dev->dev_private; |
6136 | 6162 | ||
6163 | mutex_init(&dev_priv->rps.hw_lock); | ||
6164 | |||
6165 | mutex_init(&dev_priv->pc8.lock); | ||
6166 | dev_priv->pc8.requirements_met = false; | ||
6167 | dev_priv->pc8.gpu_idle = false; | ||
6168 | dev_priv->pc8.irqs_disabled = false; | ||
6169 | dev_priv->pc8.enabled = false; | ||
6170 | dev_priv->pc8.disable_count = 2; /* requirements_met + gpu_idle */ | ||
6171 | INIT_DELAYED_WORK(&dev_priv->pc8.enable_work, hsw_enable_pc8_work); | ||
6137 | INIT_DELAYED_WORK(&dev_priv->rps.delayed_resume_work, | 6172 | INIT_DELAYED_WORK(&dev_priv->rps.delayed_resume_work, |
6138 | intel_gen6_powersave_work); | 6173 | intel_gen6_powersave_work); |
6139 | } | 6174 | } |
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index b620337e6d67..c2f09d456300 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c | |||
@@ -965,6 +965,7 @@ void intel_ring_setup_status_page(struct intel_ring_buffer *ring) | |||
965 | } else if (IS_GEN6(ring->dev)) { | 965 | } else if (IS_GEN6(ring->dev)) { |
966 | mmio = RING_HWS_PGA_GEN6(ring->mmio_base); | 966 | mmio = RING_HWS_PGA_GEN6(ring->mmio_base); |
967 | } else { | 967 | } else { |
968 | /* XXX: gen8 returns to sanity */ | ||
968 | mmio = RING_HWS_PGA(ring->mmio_base); | 969 | mmio = RING_HWS_PGA(ring->mmio_base); |
969 | } | 970 | } |
970 | 971 | ||
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c index 0b02078a0b84..25cbe073c388 100644 --- a/drivers/gpu/drm/i915/intel_uncore.c +++ b/drivers/gpu/drm/i915/intel_uncore.c | |||
@@ -784,6 +784,7 @@ static int gen6_do_reset(struct drm_device *dev) | |||
784 | int intel_gpu_reset(struct drm_device *dev) | 784 | int intel_gpu_reset(struct drm_device *dev) |
785 | { | 785 | { |
786 | switch (INTEL_INFO(dev)->gen) { | 786 | switch (INTEL_INFO(dev)->gen) { |
787 | case 8: | ||
787 | case 7: | 788 | case 7: |
788 | case 6: return gen6_do_reset(dev); | 789 | case 6: return gen6_do_reset(dev); |
789 | case 5: return ironlake_do_reset(dev); | 790 | case 5: return ironlake_do_reset(dev); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 7a3759f1c41a..98a22e6e27a1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c | |||
@@ -858,6 +858,12 @@ static int nouveau_pmops_runtime_suspend(struct device *dev) | |||
858 | if (nouveau_runtime_pm == 0) | 858 | if (nouveau_runtime_pm == 0) |
859 | return -EINVAL; | 859 | return -EINVAL; |
860 | 860 | ||
861 | /* are we optimus enabled? */ | ||
862 | if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) { | ||
863 | DRM_DEBUG_DRIVER("failing to power off - not optimus\n"); | ||
864 | return -EINVAL; | ||
865 | } | ||
866 | |||
861 | nv_debug_level(SILENT); | 867 | nv_debug_level(SILENT); |
862 | drm_kms_helper_poll_disable(drm_dev); | 868 | drm_kms_helper_poll_disable(drm_dev); |
863 | vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF); | 869 | vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF); |
diff --git a/drivers/gpu/drm/qxl/Kconfig b/drivers/gpu/drm/qxl/Kconfig index 037d324bf58f..66ac0ff95f5a 100644 --- a/drivers/gpu/drm/qxl/Kconfig +++ b/drivers/gpu/drm/qxl/Kconfig | |||
@@ -8,5 +8,6 @@ config DRM_QXL | |||
8 | select DRM_KMS_HELPER | 8 | select DRM_KMS_HELPER |
9 | select DRM_KMS_FB_HELPER | 9 | select DRM_KMS_FB_HELPER |
10 | select DRM_TTM | 10 | select DRM_TTM |
11 | select CRC32 | ||
11 | help | 12 | help |
12 | QXL virtual GPU for Spice virtualization desktop integration. Do not enable this driver unless your distro ships a corresponding X.org QXL driver that can handle kernel modesetting. | 13 | QXL virtual GPU for Spice virtualization desktop integration. Do not enable this driver unless your distro ships a corresponding X.org QXL driver that can handle kernel modesetting. |
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c index 5e827c29d194..d70aafb83307 100644 --- a/drivers/gpu/drm/qxl/qxl_display.c +++ b/drivers/gpu/drm/qxl/qxl_display.c | |||
@@ -24,7 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | 26 | ||
27 | #include "linux/crc32.h" | 27 | #include <linux/crc32.h> |
28 | 28 | ||
29 | #include "qxl_drv.h" | 29 | #include "qxl_drv.h" |
30 | #include "qxl_object.h" | 30 | #include "qxl_object.h" |
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c index 80a20120e625..b1970596a782 100644 --- a/drivers/gpu/drm/radeon/atombios_crtc.c +++ b/drivers/gpu/drm/radeon/atombios_crtc.c | |||
@@ -1196,7 +1196,9 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, | |||
1196 | } else if ((rdev->family == CHIP_TAHITI) || | 1196 | } else if ((rdev->family == CHIP_TAHITI) || |
1197 | (rdev->family == CHIP_PITCAIRN)) | 1197 | (rdev->family == CHIP_PITCAIRN)) |
1198 | fb_format |= SI_GRPH_PIPE_CONFIG(SI_ADDR_SURF_P8_32x32_8x16); | 1198 | fb_format |= SI_GRPH_PIPE_CONFIG(SI_ADDR_SURF_P8_32x32_8x16); |
1199 | else if (rdev->family == CHIP_VERDE) | 1199 | else if ((rdev->family == CHIP_VERDE) || |
1200 | (rdev->family == CHIP_OLAND) || | ||
1201 | (rdev->family == CHIP_HAINAN)) /* for completeness. HAINAN has no display hw */ | ||
1200 | fb_format |= SI_GRPH_PIPE_CONFIG(SI_ADDR_SURF_P4_8x16); | 1202 | fb_format |= SI_GRPH_PIPE_CONFIG(SI_ADDR_SURF_P4_8x16); |
1201 | 1203 | ||
1202 | switch (radeon_crtc->crtc_id) { | 1204 | switch (radeon_crtc->crtc_id) { |
diff --git a/drivers/gpu/drm/radeon/cik_sdma.c b/drivers/gpu/drm/radeon/cik_sdma.c index 0300727a4f70..d08b83c6267b 100644 --- a/drivers/gpu/drm/radeon/cik_sdma.c +++ b/drivers/gpu/drm/radeon/cik_sdma.c | |||
@@ -458,7 +458,7 @@ int cik_copy_dma(struct radeon_device *rdev, | |||
458 | radeon_ring_write(ring, 0); /* src/dst endian swap */ | 458 | radeon_ring_write(ring, 0); /* src/dst endian swap */ |
459 | radeon_ring_write(ring, src_offset & 0xffffffff); | 459 | radeon_ring_write(ring, src_offset & 0xffffffff); |
460 | radeon_ring_write(ring, upper_32_bits(src_offset) & 0xffffffff); | 460 | radeon_ring_write(ring, upper_32_bits(src_offset) & 0xffffffff); |
461 | radeon_ring_write(ring, dst_offset & 0xfffffffc); | 461 | radeon_ring_write(ring, dst_offset & 0xffffffff); |
462 | radeon_ring_write(ring, upper_32_bits(dst_offset) & 0xffffffff); | 462 | radeon_ring_write(ring, upper_32_bits(dst_offset) & 0xffffffff); |
463 | src_offset += cur_size_in_bytes; | 463 | src_offset += cur_size_in_bytes; |
464 | dst_offset += cur_size_in_bytes; | 464 | dst_offset += cur_size_in_bytes; |
diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c index de86493cbc44..713a5d359901 100644 --- a/drivers/gpu/drm/radeon/dce6_afmt.c +++ b/drivers/gpu/drm/radeon/dce6_afmt.c | |||
@@ -174,7 +174,7 @@ void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder) | |||
174 | } | 174 | } |
175 | 175 | ||
176 | sad_count = drm_edid_to_speaker_allocation(radeon_connector->edid, &sadb); | 176 | sad_count = drm_edid_to_speaker_allocation(radeon_connector->edid, &sadb); |
177 | if (sad_count < 0) { | 177 | if (sad_count <= 0) { |
178 | DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sad_count); | 178 | DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sad_count); |
179 | return; | 179 | return; |
180 | } | 180 | } |
@@ -235,7 +235,7 @@ void dce6_afmt_write_sad_regs(struct drm_encoder *encoder) | |||
235 | } | 235 | } |
236 | 236 | ||
237 | sad_count = drm_edid_to_sad(radeon_connector->edid, &sads); | 237 | sad_count = drm_edid_to_sad(radeon_connector->edid, &sads); |
238 | if (sad_count < 0) { | 238 | if (sad_count <= 0) { |
239 | DRM_ERROR("Couldn't read SADs: %d\n", sad_count); | 239 | DRM_ERROR("Couldn't read SADs: %d\n", sad_count); |
240 | return; | 240 | return; |
241 | } | 241 | } |
@@ -308,7 +308,9 @@ int dce6_audio_init(struct radeon_device *rdev) | |||
308 | rdev->audio.enabled = true; | 308 | rdev->audio.enabled = true; |
309 | 309 | ||
310 | if (ASIC_IS_DCE8(rdev)) | 310 | if (ASIC_IS_DCE8(rdev)) |
311 | rdev->audio.num_pins = 7; | 311 | rdev->audio.num_pins = 6; |
312 | else if (ASIC_IS_DCE61(rdev)) | ||
313 | rdev->audio.num_pins = 4; | ||
312 | else | 314 | else |
313 | rdev->audio.num_pins = 6; | 315 | rdev->audio.num_pins = 6; |
314 | 316 | ||
diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c index aa695c4feb3d..0c6d5cef4cf1 100644 --- a/drivers/gpu/drm/radeon/evergreen_hdmi.c +++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c | |||
@@ -118,7 +118,7 @@ static void dce4_afmt_write_speaker_allocation(struct drm_encoder *encoder) | |||
118 | } | 118 | } |
119 | 119 | ||
120 | sad_count = drm_edid_to_speaker_allocation(radeon_connector->edid, &sadb); | 120 | sad_count = drm_edid_to_speaker_allocation(radeon_connector->edid, &sadb); |
121 | if (sad_count < 0) { | 121 | if (sad_count <= 0) { |
122 | DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sad_count); | 122 | DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sad_count); |
123 | return; | 123 | return; |
124 | } | 124 | } |
@@ -173,7 +173,7 @@ static void evergreen_hdmi_write_sad_regs(struct drm_encoder *encoder) | |||
173 | } | 173 | } |
174 | 174 | ||
175 | sad_count = drm_edid_to_sad(radeon_connector->edid, &sads); | 175 | sad_count = drm_edid_to_sad(radeon_connector->edid, &sads); |
176 | if (sad_count < 0) { | 176 | if (sad_count <= 0) { |
177 | DRM_ERROR("Couldn't read SADs: %d\n", sad_count); | 177 | DRM_ERROR("Couldn't read SADs: %d\n", sad_count); |
178 | return; | 178 | return; |
179 | } | 179 | } |
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c index 11aab2ab54ce..f59a9e9fccf8 100644 --- a/drivers/gpu/drm/radeon/ni.c +++ b/drivers/gpu/drm/radeon/ni.c | |||
@@ -895,6 +895,10 @@ static void cayman_gpu_init(struct radeon_device *rdev) | |||
895 | (rdev->pdev->device == 0x999C)) { | 895 | (rdev->pdev->device == 0x999C)) { |
896 | rdev->config.cayman.max_simds_per_se = 6; | 896 | rdev->config.cayman.max_simds_per_se = 6; |
897 | rdev->config.cayman.max_backends_per_se = 2; | 897 | rdev->config.cayman.max_backends_per_se = 2; |
898 | rdev->config.cayman.max_hw_contexts = 8; | ||
899 | rdev->config.cayman.sx_max_export_size = 256; | ||
900 | rdev->config.cayman.sx_max_export_pos_size = 64; | ||
901 | rdev->config.cayman.sx_max_export_smx_size = 192; | ||
898 | } else if ((rdev->pdev->device == 0x9903) || | 902 | } else if ((rdev->pdev->device == 0x9903) || |
899 | (rdev->pdev->device == 0x9904) || | 903 | (rdev->pdev->device == 0x9904) || |
900 | (rdev->pdev->device == 0x990A) || | 904 | (rdev->pdev->device == 0x990A) || |
@@ -905,6 +909,10 @@ static void cayman_gpu_init(struct radeon_device *rdev) | |||
905 | (rdev->pdev->device == 0x999D)) { | 909 | (rdev->pdev->device == 0x999D)) { |
906 | rdev->config.cayman.max_simds_per_se = 4; | 910 | rdev->config.cayman.max_simds_per_se = 4; |
907 | rdev->config.cayman.max_backends_per_se = 2; | 911 | rdev->config.cayman.max_backends_per_se = 2; |
912 | rdev->config.cayman.max_hw_contexts = 8; | ||
913 | rdev->config.cayman.sx_max_export_size = 256; | ||
914 | rdev->config.cayman.sx_max_export_pos_size = 64; | ||
915 | rdev->config.cayman.sx_max_export_smx_size = 192; | ||
908 | } else if ((rdev->pdev->device == 0x9919) || | 916 | } else if ((rdev->pdev->device == 0x9919) || |
909 | (rdev->pdev->device == 0x9990) || | 917 | (rdev->pdev->device == 0x9990) || |
910 | (rdev->pdev->device == 0x9991) || | 918 | (rdev->pdev->device == 0x9991) || |
@@ -915,9 +923,17 @@ static void cayman_gpu_init(struct radeon_device *rdev) | |||
915 | (rdev->pdev->device == 0x99A0)) { | 923 | (rdev->pdev->device == 0x99A0)) { |
916 | rdev->config.cayman.max_simds_per_se = 3; | 924 | rdev->config.cayman.max_simds_per_se = 3; |
917 | rdev->config.cayman.max_backends_per_se = 1; | 925 | rdev->config.cayman.max_backends_per_se = 1; |
926 | rdev->config.cayman.max_hw_contexts = 4; | ||
927 | rdev->config.cayman.sx_max_export_size = 128; | ||
928 | rdev->config.cayman.sx_max_export_pos_size = 32; | ||
929 | rdev->config.cayman.sx_max_export_smx_size = 96; | ||
918 | } else { | 930 | } else { |
919 | rdev->config.cayman.max_simds_per_se = 2; | 931 | rdev->config.cayman.max_simds_per_se = 2; |
920 | rdev->config.cayman.max_backends_per_se = 1; | 932 | rdev->config.cayman.max_backends_per_se = 1; |
933 | rdev->config.cayman.max_hw_contexts = 4; | ||
934 | rdev->config.cayman.sx_max_export_size = 128; | ||
935 | rdev->config.cayman.sx_max_export_pos_size = 32; | ||
936 | rdev->config.cayman.sx_max_export_smx_size = 96; | ||
921 | } | 937 | } |
922 | rdev->config.cayman.max_texture_channel_caches = 2; | 938 | rdev->config.cayman.max_texture_channel_caches = 2; |
923 | rdev->config.cayman.max_gprs = 256; | 939 | rdev->config.cayman.max_gprs = 256; |
@@ -925,10 +941,6 @@ static void cayman_gpu_init(struct radeon_device *rdev) | |||
925 | rdev->config.cayman.max_gs_threads = 32; | 941 | rdev->config.cayman.max_gs_threads = 32; |
926 | rdev->config.cayman.max_stack_entries = 512; | 942 | rdev->config.cayman.max_stack_entries = 512; |
927 | rdev->config.cayman.sx_num_of_sets = 8; | 943 | rdev->config.cayman.sx_num_of_sets = 8; |
928 | rdev->config.cayman.sx_max_export_size = 256; | ||
929 | rdev->config.cayman.sx_max_export_pos_size = 64; | ||
930 | rdev->config.cayman.sx_max_export_smx_size = 192; | ||
931 | rdev->config.cayman.max_hw_contexts = 8; | ||
932 | rdev->config.cayman.sq_num_cf_insts = 2; | 944 | rdev->config.cayman.sq_num_cf_insts = 2; |
933 | 945 | ||
934 | rdev->config.cayman.sc_prim_fifo_size = 0x40; | 946 | rdev->config.cayman.sc_prim_fifo_size = 0x40; |
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c index e354ce94cdd1..c0425bb6223a 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.c +++ b/drivers/gpu/drm/radeon/radeon_asic.c | |||
@@ -2021,7 +2021,7 @@ static struct radeon_asic ci_asic = { | |||
2021 | .hdmi_setmode = &evergreen_hdmi_setmode, | 2021 | .hdmi_setmode = &evergreen_hdmi_setmode, |
2022 | }, | 2022 | }, |
2023 | .copy = { | 2023 | .copy = { |
2024 | .blit = NULL, | 2024 | .blit = &cik_copy_cpdma, |
2025 | .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, | 2025 | .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, |
2026 | .dma = &cik_copy_dma, | 2026 | .dma = &cik_copy_dma, |
2027 | .dma_ring_index = R600_RING_TYPE_DMA_INDEX, | 2027 | .dma_ring_index = R600_RING_TYPE_DMA_INDEX, |
@@ -2122,7 +2122,7 @@ static struct radeon_asic kv_asic = { | |||
2122 | .hdmi_setmode = &evergreen_hdmi_setmode, | 2122 | .hdmi_setmode = &evergreen_hdmi_setmode, |
2123 | }, | 2123 | }, |
2124 | .copy = { | 2124 | .copy = { |
2125 | .blit = NULL, | 2125 | .blit = &cik_copy_cpdma, |
2126 | .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, | 2126 | .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, |
2127 | .dma = &cik_copy_dma, | 2127 | .dma = &cik_copy_dma, |
2128 | .dma_ring_index = R600_RING_TYPE_DMA_INDEX, | 2128 | .dma_ring_index = R600_RING_TYPE_DMA_INDEX, |
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 9f5ff28864f6..1958b36ad0e5 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c | |||
@@ -508,15 +508,6 @@ static const struct file_operations radeon_driver_kms_fops = { | |||
508 | #endif | 508 | #endif |
509 | }; | 509 | }; |
510 | 510 | ||
511 | |||
512 | static void | ||
513 | radeon_pci_shutdown(struct pci_dev *pdev) | ||
514 | { | ||
515 | struct drm_device *dev = pci_get_drvdata(pdev); | ||
516 | |||
517 | radeon_driver_unload_kms(dev); | ||
518 | } | ||
519 | |||
520 | static struct drm_driver kms_driver = { | 511 | static struct drm_driver kms_driver = { |
521 | .driver_features = | 512 | .driver_features = |
522 | DRIVER_USE_AGP | | 513 | DRIVER_USE_AGP | |
@@ -586,7 +577,6 @@ static struct pci_driver radeon_kms_pci_driver = { | |||
586 | .probe = radeon_pci_probe, | 577 | .probe = radeon_pci_probe, |
587 | .remove = radeon_pci_remove, | 578 | .remove = radeon_pci_remove, |
588 | .driver.pm = &radeon_pm_ops, | 579 | .driver.pm = &radeon_pm_ops, |
589 | .shutdown = radeon_pci_shutdown, | ||
590 | }; | 580 | }; |
591 | 581 | ||
592 | static int __init radeon_init(void) | 582 | static int __init radeon_init(void) |
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c index 1c560629575a..e7dab069cccf 100644 --- a/drivers/gpu/drm/radeon/rs690.c +++ b/drivers/gpu/drm/radeon/rs690.c | |||
@@ -162,6 +162,16 @@ static void rs690_mc_init(struct radeon_device *rdev) | |||
162 | base = RREG32_MC(R_000100_MCCFG_FB_LOCATION); | 162 | base = RREG32_MC(R_000100_MCCFG_FB_LOCATION); |
163 | base = G_000100_MC_FB_START(base) << 16; | 163 | base = G_000100_MC_FB_START(base) << 16; |
164 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); | 164 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); |
165 | /* Some boards seem to be configured for 128MB of sideport memory, | ||
166 | * but really only have 64MB. Just skip the sideport and use | ||
167 | * UMA memory. | ||
168 | */ | ||
169 | if (rdev->mc.igp_sideport_enabled && | ||
170 | (rdev->mc.real_vram_size == (384 * 1024 * 1024))) { | ||
171 | base += 128 * 1024 * 1024; | ||
172 | rdev->mc.real_vram_size -= 128 * 1024 * 1024; | ||
173 | rdev->mc.mc_vram_size = rdev->mc.real_vram_size; | ||
174 | } | ||
165 | 175 | ||
166 | /* Use K8 direct mapping for fast fb access. */ | 176 | /* Use K8 direct mapping for fast fb access. */ |
167 | rdev->fastfb_working = false; | 177 | rdev->fastfb_working = false; |
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c index 913b025ae9b3..374499db20c7 100644 --- a/drivers/gpu/drm/radeon/rv770_dpm.c +++ b/drivers/gpu/drm/radeon/rv770_dpm.c | |||
@@ -2328,6 +2328,12 @@ void rv770_get_engine_memory_ss(struct radeon_device *rdev) | |||
2328 | pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss, | 2328 | pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss, |
2329 | ASIC_INTERNAL_MEMORY_SS, 0); | 2329 | ASIC_INTERNAL_MEMORY_SS, 0); |
2330 | 2330 | ||
2331 | /* disable ss, causes hangs on some cayman boards */ | ||
2332 | if (rdev->family == CHIP_CAYMAN) { | ||
2333 | pi->sclk_ss = false; | ||
2334 | pi->mclk_ss = false; | ||
2335 | } | ||
2336 | |||
2331 | if (pi->sclk_ss || pi->mclk_ss) | 2337 | if (pi->sclk_ss || pi->mclk_ss) |
2332 | pi->dynamic_ss = true; | 2338 | pi->dynamic_ss = true; |
2333 | else | 2339 | else |
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 15b86a94949d..406152152315 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c | |||
@@ -353,7 +353,8 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, | |||
353 | * Don't move nonexistent data. Clear destination instead. | 353 | * Don't move nonexistent data. Clear destination instead. |
354 | */ | 354 | */ |
355 | if (old_iomap == NULL && | 355 | if (old_iomap == NULL && |
356 | (ttm == NULL || ttm->state == tt_unpopulated)) { | 356 | (ttm == NULL || (ttm->state == tt_unpopulated && |
357 | !(ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)))) { | ||
357 | memset_io(new_iomap, 0, new_mem->num_pages*PAGE_SIZE); | 358 | memset_io(new_iomap, 0, new_mem->num_pages*PAGE_SIZE); |
358 | goto out2; | 359 | goto out2; |
359 | } | 360 | } |
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index b249ab9b1eb2..6440eeac22d2 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c | |||
@@ -169,9 +169,9 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
169 | } | 169 | } |
170 | 170 | ||
171 | page_offset = ((address - vma->vm_start) >> PAGE_SHIFT) + | 171 | page_offset = ((address - vma->vm_start) >> PAGE_SHIFT) + |
172 | drm_vma_node_start(&bo->vma_node) - vma->vm_pgoff; | 172 | vma->vm_pgoff - drm_vma_node_start(&bo->vma_node); |
173 | page_last = vma_pages(vma) + | 173 | page_last = vma_pages(vma) + vma->vm_pgoff - |
174 | drm_vma_node_start(&bo->vma_node) - vma->vm_pgoff; | 174 | drm_vma_node_start(&bo->vma_node); |
175 | 175 | ||
176 | if (unlikely(page_offset >= bo->num_pages)) { | 176 | if (unlikely(page_offset >= bo->num_pages)) { |
177 | retval = VM_FAULT_SIGBUS; | 177 | retval = VM_FAULT_SIGBUS; |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c index a51f48e3e917..45d5b5ab6ca9 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | |||
@@ -68,6 +68,9 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data, | |||
68 | SVGA_FIFO_3D_HWVERSION)); | 68 | SVGA_FIFO_3D_HWVERSION)); |
69 | break; | 69 | break; |
70 | } | 70 | } |
71 | case DRM_VMW_PARAM_MAX_SURF_MEMORY: | ||
72 | param->value = dev_priv->memory_size; | ||
73 | break; | ||
71 | default: | 74 | default: |
72 | DRM_ERROR("Illegal vmwgfx get param request: %d\n", | 75 | DRM_ERROR("Illegal vmwgfx get param request: %d\n", |
73 | param->param); | 76 | param->param); |
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 92d1206482a6..f80b700f821c 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c | |||
@@ -377,6 +377,9 @@ static int intel_idle(struct cpuidle_device *dev, | |||
377 | 377 | ||
378 | if (!current_set_polling_and_test()) { | 378 | if (!current_set_polling_and_test()) { |
379 | 379 | ||
380 | if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR)) | ||
381 | clflush((void *)¤t_thread_info()->flags); | ||
382 | |||
380 | __monitor((void *)¤t_thread_info()->flags, 0, 0); | 383 | __monitor((void *)¤t_thread_info()->flags, 0, 0); |
381 | smp_mb(); | 384 | smp_mb(); |
382 | if (!need_resched()) | 385 | if (!need_resched()) |
diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index acb7f90359a3..749a6cadab8b 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c | |||
@@ -200,7 +200,13 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = { | |||
200 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), | 200 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
201 | .address = 1, | 201 | .address = 1, |
202 | .scan_index = 1, | 202 | .scan_index = 1, |
203 | .scan_type = IIO_ST('u', 12, 16, 0), | 203 | .scan_type = { |
204 | .sign = 'u', | ||
205 | .realbits = 12, | ||
206 | .storagebits = 16, | ||
207 | .shift = 0, | ||
208 | .endianness = IIO_BE, | ||
209 | }, | ||
204 | }, | 210 | }, |
205 | .channel[1] = { | 211 | .channel[1] = { |
206 | .type = IIO_VOLTAGE, | 212 | .type = IIO_VOLTAGE, |
@@ -210,7 +216,13 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = { | |||
210 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), | 216 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
211 | .address = 0, | 217 | .address = 0, |
212 | .scan_index = 0, | 218 | .scan_index = 0, |
213 | .scan_type = IIO_ST('u', 12, 16, 0), | 219 | .scan_type = { |
220 | .sign = 'u', | ||
221 | .realbits = 12, | ||
222 | .storagebits = 16, | ||
223 | .shift = 0, | ||
224 | .endianness = IIO_BE, | ||
225 | }, | ||
214 | }, | 226 | }, |
215 | .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2), | 227 | .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2), |
216 | .int_vref_mv = 2500, | 228 | .int_vref_mv = 2500, |
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c index 3fb7757a1028..368660dfe135 100644 --- a/drivers/iio/imu/adis16400_core.c +++ b/drivers/iio/imu/adis16400_core.c | |||
@@ -651,7 +651,12 @@ static const struct iio_chan_spec adis16448_channels[] = { | |||
651 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), | 651 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
652 | .address = ADIS16448_BARO_OUT, | 652 | .address = ADIS16448_BARO_OUT, |
653 | .scan_index = ADIS16400_SCAN_BARO, | 653 | .scan_index = ADIS16400_SCAN_BARO, |
654 | .scan_type = IIO_ST('s', 16, 16, 0), | 654 | .scan_type = { |
655 | .sign = 's', | ||
656 | .realbits = 16, | ||
657 | .storagebits = 16, | ||
658 | .endianness = IIO_BE, | ||
659 | }, | ||
655 | }, | 660 | }, |
656 | ADIS16400_TEMP_CHAN(ADIS16448_TEMP_OUT, 12), | 661 | ADIS16400_TEMP_CHAN(ADIS16448_TEMP_OUT, 12), |
657 | IIO_CHAN_SOFT_TIMESTAMP(11) | 662 | IIO_CHAN_SOFT_TIMESTAMP(11) |
diff --git a/drivers/iio/light/cm36651.c b/drivers/iio/light/cm36651.c index 21df57130018..0922e39b0ea9 100644 --- a/drivers/iio/light/cm36651.c +++ b/drivers/iio/light/cm36651.c | |||
@@ -387,7 +387,7 @@ static int cm36651_read_int_time(struct cm36651_data *cm36651, | |||
387 | return -EINVAL; | 387 | return -EINVAL; |
388 | } | 388 | } |
389 | 389 | ||
390 | return IIO_VAL_INT_PLUS_MICRO; | 390 | return IIO_VAL_INT; |
391 | } | 391 | } |
392 | 392 | ||
393 | static int cm36651_write_int_time(struct cm36651_data *cm36651, | 393 | static int cm36651_write_int_time(struct cm36651_data *cm36651, |
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c index c47c2034ca71..0717940ec3b5 100644 --- a/drivers/infiniband/core/iwcm.c +++ b/drivers/infiniband/core/iwcm.c | |||
@@ -181,9 +181,16 @@ static void add_ref(struct iw_cm_id *cm_id) | |||
181 | static void rem_ref(struct iw_cm_id *cm_id) | 181 | static void rem_ref(struct iw_cm_id *cm_id) |
182 | { | 182 | { |
183 | struct iwcm_id_private *cm_id_priv; | 183 | struct iwcm_id_private *cm_id_priv; |
184 | int cb_destroy; | ||
185 | |||
184 | cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); | 186 | cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); |
185 | if (iwcm_deref_id(cm_id_priv) && | 187 | |
186 | test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags)) { | 188 | /* |
189 | * Test bit before deref in case the cm_id gets freed on another | ||
190 | * thread. | ||
191 | */ | ||
192 | cb_destroy = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); | ||
193 | if (iwcm_deref_id(cm_id_priv) && cb_destroy) { | ||
187 | BUG_ON(!list_empty(&cm_id_priv->work_list)); | 194 | BUG_ON(!list_empty(&cm_id_priv->work_list)); |
188 | free_cm_id(cm_id_priv); | 195 | free_cm_id(cm_id_priv); |
189 | } | 196 | } |
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index bdc842e9faef..a283274a5a09 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h | |||
@@ -49,12 +49,20 @@ | |||
49 | 49 | ||
50 | #define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \ | 50 | #define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \ |
51 | do { \ | 51 | do { \ |
52 | (udata)->inbuf = (void __user *) (ibuf); \ | 52 | (udata)->inbuf = (const void __user *) (ibuf); \ |
53 | (udata)->outbuf = (void __user *) (obuf); \ | 53 | (udata)->outbuf = (void __user *) (obuf); \ |
54 | (udata)->inlen = (ilen); \ | 54 | (udata)->inlen = (ilen); \ |
55 | (udata)->outlen = (olen); \ | 55 | (udata)->outlen = (olen); \ |
56 | } while (0) | 56 | } while (0) |
57 | 57 | ||
58 | #define INIT_UDATA_BUF_OR_NULL(udata, ibuf, obuf, ilen, olen) \ | ||
59 | do { \ | ||
60 | (udata)->inbuf = (ilen) ? (const void __user *) (ibuf) : NULL; \ | ||
61 | (udata)->outbuf = (olen) ? (void __user *) (obuf) : NULL; \ | ||
62 | (udata)->inlen = (ilen); \ | ||
63 | (udata)->outlen = (olen); \ | ||
64 | } while (0) | ||
65 | |||
58 | /* | 66 | /* |
59 | * Our lifetime rules for these structs are the following: | 67 | * Our lifetime rules for these structs are the following: |
60 | * | 68 | * |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 65f6e7dc380c..f1cc83855af6 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -2593,6 +2593,9 @@ out_put: | |||
2593 | static int kern_spec_to_ib_spec(struct ib_uverbs_flow_spec *kern_spec, | 2593 | static int kern_spec_to_ib_spec(struct ib_uverbs_flow_spec *kern_spec, |
2594 | union ib_flow_spec *ib_spec) | 2594 | union ib_flow_spec *ib_spec) |
2595 | { | 2595 | { |
2596 | if (kern_spec->reserved) | ||
2597 | return -EINVAL; | ||
2598 | |||
2596 | ib_spec->type = kern_spec->type; | 2599 | ib_spec->type = kern_spec->type; |
2597 | 2600 | ||
2598 | switch (ib_spec->type) { | 2601 | switch (ib_spec->type) { |
@@ -2646,6 +2649,9 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, | |||
2646 | void *ib_spec; | 2649 | void *ib_spec; |
2647 | int i; | 2650 | int i; |
2648 | 2651 | ||
2652 | if (ucore->inlen < sizeof(cmd)) | ||
2653 | return -EINVAL; | ||
2654 | |||
2649 | if (ucore->outlen < sizeof(resp)) | 2655 | if (ucore->outlen < sizeof(resp)) |
2650 | return -ENOSPC; | 2656 | return -ENOSPC; |
2651 | 2657 | ||
@@ -2671,6 +2677,10 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, | |||
2671 | (cmd.flow_attr.num_of_specs * sizeof(struct ib_uverbs_flow_spec))) | 2677 | (cmd.flow_attr.num_of_specs * sizeof(struct ib_uverbs_flow_spec))) |
2672 | return -EINVAL; | 2678 | return -EINVAL; |
2673 | 2679 | ||
2680 | if (cmd.flow_attr.reserved[0] || | ||
2681 | cmd.flow_attr.reserved[1]) | ||
2682 | return -EINVAL; | ||
2683 | |||
2674 | if (cmd.flow_attr.num_of_specs) { | 2684 | if (cmd.flow_attr.num_of_specs) { |
2675 | kern_flow_attr = kmalloc(sizeof(*kern_flow_attr) + cmd.flow_attr.size, | 2685 | kern_flow_attr = kmalloc(sizeof(*kern_flow_attr) + cmd.flow_attr.size, |
2676 | GFP_KERNEL); | 2686 | GFP_KERNEL); |
@@ -2731,6 +2741,7 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, | |||
2731 | if (cmd.flow_attr.size || (i != flow_attr->num_of_specs)) { | 2741 | if (cmd.flow_attr.size || (i != flow_attr->num_of_specs)) { |
2732 | pr_warn("create flow failed, flow %d: %d bytes left from uverb cmd\n", | 2742 | pr_warn("create flow failed, flow %d: %d bytes left from uverb cmd\n", |
2733 | i, cmd.flow_attr.size); | 2743 | i, cmd.flow_attr.size); |
2744 | err = -EINVAL; | ||
2734 | goto err_free; | 2745 | goto err_free; |
2735 | } | 2746 | } |
2736 | flow_id = ib_create_flow(qp, flow_attr, IB_FLOW_DOMAIN_USER); | 2747 | flow_id = ib_create_flow(qp, flow_attr, IB_FLOW_DOMAIN_USER); |
@@ -2791,10 +2802,16 @@ int ib_uverbs_ex_destroy_flow(struct ib_uverbs_file *file, | |||
2791 | struct ib_uobject *uobj; | 2802 | struct ib_uobject *uobj; |
2792 | int ret; | 2803 | int ret; |
2793 | 2804 | ||
2805 | if (ucore->inlen < sizeof(cmd)) | ||
2806 | return -EINVAL; | ||
2807 | |||
2794 | ret = ib_copy_from_udata(&cmd, ucore, sizeof(cmd)); | 2808 | ret = ib_copy_from_udata(&cmd, ucore, sizeof(cmd)); |
2795 | if (ret) | 2809 | if (ret) |
2796 | return ret; | 2810 | return ret; |
2797 | 2811 | ||
2812 | if (cmd.comp_mask) | ||
2813 | return -EINVAL; | ||
2814 | |||
2798 | uobj = idr_write_uobj(&ib_uverbs_rule_idr, cmd.flow_handle, | 2815 | uobj = idr_write_uobj(&ib_uverbs_rule_idr, cmd.flow_handle, |
2799 | file->ucontext); | 2816 | file->ucontext); |
2800 | if (!uobj) | 2817 | if (!uobj) |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 34386943ebcf..08219fb3338b 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -668,25 +668,30 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, | |||
668 | if ((hdr.in_words + ex_hdr.provider_in_words) * 8 != count) | 668 | if ((hdr.in_words + ex_hdr.provider_in_words) * 8 != count) |
669 | return -EINVAL; | 669 | return -EINVAL; |
670 | 670 | ||
671 | if (ex_hdr.cmd_hdr_reserved) | ||
672 | return -EINVAL; | ||
673 | |||
671 | if (ex_hdr.response) { | 674 | if (ex_hdr.response) { |
672 | if (!hdr.out_words && !ex_hdr.provider_out_words) | 675 | if (!hdr.out_words && !ex_hdr.provider_out_words) |
673 | return -EINVAL; | 676 | return -EINVAL; |
677 | |||
678 | if (!access_ok(VERIFY_WRITE, | ||
679 | (void __user *) (unsigned long) ex_hdr.response, | ||
680 | (hdr.out_words + ex_hdr.provider_out_words) * 8)) | ||
681 | return -EFAULT; | ||
674 | } else { | 682 | } else { |
675 | if (hdr.out_words || ex_hdr.provider_out_words) | 683 | if (hdr.out_words || ex_hdr.provider_out_words) |
676 | return -EINVAL; | 684 | return -EINVAL; |
677 | } | 685 | } |
678 | 686 | ||
679 | INIT_UDATA(&ucore, | 687 | INIT_UDATA_BUF_OR_NULL(&ucore, buf, (unsigned long) ex_hdr.response, |
680 | (hdr.in_words) ? buf : 0, | 688 | hdr.in_words * 8, hdr.out_words * 8); |
681 | (unsigned long)ex_hdr.response, | 689 | |
682 | hdr.in_words * 8, | 690 | INIT_UDATA_BUF_OR_NULL(&uhw, |
683 | hdr.out_words * 8); | 691 | buf + ucore.inlen, |
684 | 692 | (unsigned long) ex_hdr.response + ucore.outlen, | |
685 | INIT_UDATA(&uhw, | 693 | ex_hdr.provider_in_words * 8, |
686 | (ex_hdr.provider_in_words) ? buf + ucore.inlen : 0, | 694 | ex_hdr.provider_out_words * 8); |
687 | (ex_hdr.provider_out_words) ? (unsigned long)ex_hdr.response + ucore.outlen : 0, | ||
688 | ex_hdr.provider_in_words * 8, | ||
689 | ex_hdr.provider_out_words * 8); | ||
690 | 695 | ||
691 | err = uverbs_ex_cmd_table[command](file, | 696 | err = uverbs_ex_cmd_table[command](file, |
692 | &ucore, | 697 | &ucore, |
diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c index 4cb8eb24497c..84e45006451c 100644 --- a/drivers/infiniband/hw/cxgb4/mem.c +++ b/drivers/infiniband/hw/cxgb4/mem.c | |||
@@ -173,7 +173,7 @@ static int _c4iw_write_mem_inline(struct c4iw_rdev *rdev, u32 addr, u32 len, | |||
173 | return ret; | 173 | return ret; |
174 | } | 174 | } |
175 | 175 | ||
176 | int _c4iw_write_mem_dma(struct c4iw_rdev *rdev, u32 addr, u32 len, void *data) | 176 | static int _c4iw_write_mem_dma(struct c4iw_rdev *rdev, u32 addr, u32 len, void *data) |
177 | { | 177 | { |
178 | u32 remain = len; | 178 | u32 remain = len; |
179 | u32 dmalen; | 179 | u32 dmalen; |
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 6be57c38638d..9804fca6bf06 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
@@ -207,7 +207,9 @@ isert_free_rx_descriptors(struct isert_conn *isert_conn) | |||
207 | isert_conn->conn_rx_descs = NULL; | 207 | isert_conn->conn_rx_descs = NULL; |
208 | } | 208 | } |
209 | 209 | ||
210 | static void isert_cq_tx_work(struct work_struct *); | ||
210 | static void isert_cq_tx_callback(struct ib_cq *, void *); | 211 | static void isert_cq_tx_callback(struct ib_cq *, void *); |
212 | static void isert_cq_rx_work(struct work_struct *); | ||
211 | static void isert_cq_rx_callback(struct ib_cq *, void *); | 213 | static void isert_cq_rx_callback(struct ib_cq *, void *); |
212 | 214 | ||
213 | static int | 215 | static int |
@@ -259,26 +261,36 @@ isert_create_device_ib_res(struct isert_device *device) | |||
259 | cq_desc[i].device = device; | 261 | cq_desc[i].device = device; |
260 | cq_desc[i].cq_index = i; | 262 | cq_desc[i].cq_index = i; |
261 | 263 | ||
264 | INIT_WORK(&cq_desc[i].cq_rx_work, isert_cq_rx_work); | ||
262 | device->dev_rx_cq[i] = ib_create_cq(device->ib_device, | 265 | device->dev_rx_cq[i] = ib_create_cq(device->ib_device, |
263 | isert_cq_rx_callback, | 266 | isert_cq_rx_callback, |
264 | isert_cq_event_callback, | 267 | isert_cq_event_callback, |
265 | (void *)&cq_desc[i], | 268 | (void *)&cq_desc[i], |
266 | ISER_MAX_RX_CQ_LEN, i); | 269 | ISER_MAX_RX_CQ_LEN, i); |
267 | if (IS_ERR(device->dev_rx_cq[i])) | 270 | if (IS_ERR(device->dev_rx_cq[i])) { |
271 | ret = PTR_ERR(device->dev_rx_cq[i]); | ||
272 | device->dev_rx_cq[i] = NULL; | ||
268 | goto out_cq; | 273 | goto out_cq; |
274 | } | ||
269 | 275 | ||
276 | INIT_WORK(&cq_desc[i].cq_tx_work, isert_cq_tx_work); | ||
270 | device->dev_tx_cq[i] = ib_create_cq(device->ib_device, | 277 | device->dev_tx_cq[i] = ib_create_cq(device->ib_device, |
271 | isert_cq_tx_callback, | 278 | isert_cq_tx_callback, |
272 | isert_cq_event_callback, | 279 | isert_cq_event_callback, |
273 | (void *)&cq_desc[i], | 280 | (void *)&cq_desc[i], |
274 | ISER_MAX_TX_CQ_LEN, i); | 281 | ISER_MAX_TX_CQ_LEN, i); |
275 | if (IS_ERR(device->dev_tx_cq[i])) | 282 | if (IS_ERR(device->dev_tx_cq[i])) { |
283 | ret = PTR_ERR(device->dev_tx_cq[i]); | ||
284 | device->dev_tx_cq[i] = NULL; | ||
276 | goto out_cq; | 285 | goto out_cq; |
286 | } | ||
277 | 287 | ||
278 | if (ib_req_notify_cq(device->dev_rx_cq[i], IB_CQ_NEXT_COMP)) | 288 | ret = ib_req_notify_cq(device->dev_rx_cq[i], IB_CQ_NEXT_COMP); |
289 | if (ret) | ||
279 | goto out_cq; | 290 | goto out_cq; |
280 | 291 | ||
281 | if (ib_req_notify_cq(device->dev_tx_cq[i], IB_CQ_NEXT_COMP)) | 292 | ret = ib_req_notify_cq(device->dev_tx_cq[i], IB_CQ_NEXT_COMP); |
293 | if (ret) | ||
282 | goto out_cq; | 294 | goto out_cq; |
283 | } | 295 | } |
284 | 296 | ||
@@ -1724,7 +1736,6 @@ isert_cq_tx_callback(struct ib_cq *cq, void *context) | |||
1724 | { | 1736 | { |
1725 | struct isert_cq_desc *cq_desc = (struct isert_cq_desc *)context; | 1737 | struct isert_cq_desc *cq_desc = (struct isert_cq_desc *)context; |
1726 | 1738 | ||
1727 | INIT_WORK(&cq_desc->cq_tx_work, isert_cq_tx_work); | ||
1728 | queue_work(isert_comp_wq, &cq_desc->cq_tx_work); | 1739 | queue_work(isert_comp_wq, &cq_desc->cq_tx_work); |
1729 | } | 1740 | } |
1730 | 1741 | ||
@@ -1768,7 +1779,6 @@ isert_cq_rx_callback(struct ib_cq *cq, void *context) | |||
1768 | { | 1779 | { |
1769 | struct isert_cq_desc *cq_desc = (struct isert_cq_desc *)context; | 1780 | struct isert_cq_desc *cq_desc = (struct isert_cq_desc *)context; |
1770 | 1781 | ||
1771 | INIT_WORK(&cq_desc->cq_rx_work, isert_cq_rx_work); | ||
1772 | queue_work(isert_rx_wq, &cq_desc->cq_rx_work); | 1782 | queue_work(isert_rx_wq, &cq_desc->cq_rx_work); |
1773 | } | 1783 | } |
1774 | 1784 | ||
diff --git a/drivers/irqchip/irq-renesas-intc-irqpin.c b/drivers/irqchip/irq-renesas-intc-irqpin.c index 82cec63a9011..3ee78f02e5d7 100644 --- a/drivers/irqchip/irq-renesas-intc-irqpin.c +++ b/drivers/irqchip/irq-renesas-intc-irqpin.c | |||
@@ -149,8 +149,9 @@ static void intc_irqpin_read_modify_write(struct intc_irqpin_priv *p, | |||
149 | static void intc_irqpin_mask_unmask_prio(struct intc_irqpin_priv *p, | 149 | static void intc_irqpin_mask_unmask_prio(struct intc_irqpin_priv *p, |
150 | int irq, int do_mask) | 150 | int irq, int do_mask) |
151 | { | 151 | { |
152 | int bitfield_width = 4; /* PRIO assumed to have fixed bitfield width */ | 152 | /* The PRIO register is assumed to be 32-bit with fixed 4-bit fields. */ |
153 | int shift = (7 - irq) * bitfield_width; /* PRIO assumed to be 32-bit */ | 153 | int bitfield_width = 4; |
154 | int shift = 32 - (irq + 1) * bitfield_width; | ||
154 | 155 | ||
155 | intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_PRIO, | 156 | intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_PRIO, |
156 | shift, bitfield_width, | 157 | shift, bitfield_width, |
@@ -159,8 +160,9 @@ static void intc_irqpin_mask_unmask_prio(struct intc_irqpin_priv *p, | |||
159 | 160 | ||
160 | static int intc_irqpin_set_sense(struct intc_irqpin_priv *p, int irq, int value) | 161 | static int intc_irqpin_set_sense(struct intc_irqpin_priv *p, int irq, int value) |
161 | { | 162 | { |
163 | /* The SENSE register is assumed to be 32-bit. */ | ||
162 | int bitfield_width = p->config.sense_bitfield_width; | 164 | int bitfield_width = p->config.sense_bitfield_width; |
163 | int shift = (7 - irq) * bitfield_width; /* SENSE assumed to be 32-bit */ | 165 | int shift = 32 - (irq + 1) * bitfield_width; |
164 | 166 | ||
165 | dev_dbg(&p->pdev->dev, "sense irq = %d, mode = %d\n", irq, value); | 167 | dev_dbg(&p->pdev->dev, "sense irq = %d, mode = %d\n", irq, value); |
166 | 168 | ||
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index 2b46bf1d7e40..4c9852d92b0a 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c | |||
@@ -421,9 +421,11 @@ out: | |||
421 | 421 | ||
422 | if (watermark <= WATERMARK_METADATA) { | 422 | if (watermark <= WATERMARK_METADATA) { |
423 | SET_GC_MARK(b, GC_MARK_METADATA); | 423 | SET_GC_MARK(b, GC_MARK_METADATA); |
424 | SET_GC_MOVE(b, 0); | ||
424 | b->prio = BTREE_PRIO; | 425 | b->prio = BTREE_PRIO; |
425 | } else { | 426 | } else { |
426 | SET_GC_MARK(b, GC_MARK_RECLAIMABLE); | 427 | SET_GC_MARK(b, GC_MARK_RECLAIMABLE); |
428 | SET_GC_MOVE(b, 0); | ||
427 | b->prio = INITIAL_PRIO; | 429 | b->prio = INITIAL_PRIO; |
428 | } | 430 | } |
429 | 431 | ||
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 4beb55a0ff30..754f43177483 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h | |||
@@ -197,7 +197,7 @@ struct bucket { | |||
197 | uint8_t disk_gen; | 197 | uint8_t disk_gen; |
198 | uint8_t last_gc; /* Most out of date gen in the btree */ | 198 | uint8_t last_gc; /* Most out of date gen in the btree */ |
199 | uint8_t gc_gen; | 199 | uint8_t gc_gen; |
200 | uint16_t gc_mark; | 200 | uint16_t gc_mark; /* Bitfield used by GC. See below for field */ |
201 | }; | 201 | }; |
202 | 202 | ||
203 | /* | 203 | /* |
@@ -209,7 +209,8 @@ BITMASK(GC_MARK, struct bucket, gc_mark, 0, 2); | |||
209 | #define GC_MARK_RECLAIMABLE 0 | 209 | #define GC_MARK_RECLAIMABLE 0 |
210 | #define GC_MARK_DIRTY 1 | 210 | #define GC_MARK_DIRTY 1 |
211 | #define GC_MARK_METADATA 2 | 211 | #define GC_MARK_METADATA 2 |
212 | BITMASK(GC_SECTORS_USED, struct bucket, gc_mark, 2, 14); | 212 | BITMASK(GC_SECTORS_USED, struct bucket, gc_mark, 2, 13); |
213 | BITMASK(GC_MOVE, struct bucket, gc_mark, 15, 1); | ||
213 | 214 | ||
214 | #include "journal.h" | 215 | #include "journal.h" |
215 | #include "stats.h" | 216 | #include "stats.h" |
@@ -372,14 +373,14 @@ struct cached_dev { | |||
372 | unsigned char writeback_percent; | 373 | unsigned char writeback_percent; |
373 | unsigned writeback_delay; | 374 | unsigned writeback_delay; |
374 | 375 | ||
375 | int writeback_rate_change; | ||
376 | int64_t writeback_rate_derivative; | ||
377 | uint64_t writeback_rate_target; | 376 | uint64_t writeback_rate_target; |
377 | int64_t writeback_rate_proportional; | ||
378 | int64_t writeback_rate_derivative; | ||
379 | int64_t writeback_rate_change; | ||
378 | 380 | ||
379 | unsigned writeback_rate_update_seconds; | 381 | unsigned writeback_rate_update_seconds; |
380 | unsigned writeback_rate_d_term; | 382 | unsigned writeback_rate_d_term; |
381 | unsigned writeback_rate_p_term_inverse; | 383 | unsigned writeback_rate_p_term_inverse; |
382 | unsigned writeback_rate_d_smooth; | ||
383 | }; | 384 | }; |
384 | 385 | ||
385 | enum alloc_watermarks { | 386 | enum alloc_watermarks { |
@@ -445,7 +446,6 @@ struct cache { | |||
445 | * call prio_write() to keep gens from wrapping. | 446 | * call prio_write() to keep gens from wrapping. |
446 | */ | 447 | */ |
447 | uint8_t need_save_prio; | 448 | uint8_t need_save_prio; |
448 | unsigned gc_move_threshold; | ||
449 | 449 | ||
450 | /* | 450 | /* |
451 | * If nonzero, we know we aren't going to find any buckets to invalidate | 451 | * If nonzero, we know we aren't going to find any buckets to invalidate |
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 5e2765aadce1..31bb53fcc67a 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c | |||
@@ -1561,6 +1561,28 @@ size_t bch_btree_gc_finish(struct cache_set *c) | |||
1561 | SET_GC_MARK(PTR_BUCKET(c, &c->uuid_bucket, i), | 1561 | SET_GC_MARK(PTR_BUCKET(c, &c->uuid_bucket, i), |
1562 | GC_MARK_METADATA); | 1562 | GC_MARK_METADATA); |
1563 | 1563 | ||
1564 | /* don't reclaim buckets to which writeback keys point */ | ||
1565 | rcu_read_lock(); | ||
1566 | for (i = 0; i < c->nr_uuids; i++) { | ||
1567 | struct bcache_device *d = c->devices[i]; | ||
1568 | struct cached_dev *dc; | ||
1569 | struct keybuf_key *w, *n; | ||
1570 | unsigned j; | ||
1571 | |||
1572 | if (!d || UUID_FLASH_ONLY(&c->uuids[i])) | ||
1573 | continue; | ||
1574 | dc = container_of(d, struct cached_dev, disk); | ||
1575 | |||
1576 | spin_lock(&dc->writeback_keys.lock); | ||
1577 | rbtree_postorder_for_each_entry_safe(w, n, | ||
1578 | &dc->writeback_keys.keys, node) | ||
1579 | for (j = 0; j < KEY_PTRS(&w->key); j++) | ||
1580 | SET_GC_MARK(PTR_BUCKET(c, &w->key, j), | ||
1581 | GC_MARK_DIRTY); | ||
1582 | spin_unlock(&dc->writeback_keys.lock); | ||
1583 | } | ||
1584 | rcu_read_unlock(); | ||
1585 | |||
1564 | for_each_cache(ca, c, i) { | 1586 | for_each_cache(ca, c, i) { |
1565 | uint64_t *i; | 1587 | uint64_t *i; |
1566 | 1588 | ||
@@ -1817,7 +1839,8 @@ static bool fix_overlapping_extents(struct btree *b, struct bkey *insert, | |||
1817 | if (KEY_START(k) > KEY_START(insert) + sectors_found) | 1839 | if (KEY_START(k) > KEY_START(insert) + sectors_found) |
1818 | goto check_failed; | 1840 | goto check_failed; |
1819 | 1841 | ||
1820 | if (KEY_PTRS(replace_key) != KEY_PTRS(k)) | 1842 | if (KEY_PTRS(k) != KEY_PTRS(replace_key) || |
1843 | KEY_DIRTY(k) != KEY_DIRTY(replace_key)) | ||
1821 | goto check_failed; | 1844 | goto check_failed; |
1822 | 1845 | ||
1823 | /* skip past gen */ | 1846 | /* skip past gen */ |
@@ -2217,7 +2240,7 @@ struct btree_insert_op { | |||
2217 | struct bkey *replace_key; | 2240 | struct bkey *replace_key; |
2218 | }; | 2241 | }; |
2219 | 2242 | ||
2220 | int btree_insert_fn(struct btree_op *b_op, struct btree *b) | 2243 | static int btree_insert_fn(struct btree_op *b_op, struct btree *b) |
2221 | { | 2244 | { |
2222 | struct btree_insert_op *op = container_of(b_op, | 2245 | struct btree_insert_op *op = container_of(b_op, |
2223 | struct btree_insert_op, op); | 2246 | struct btree_insert_op, op); |
diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c index 7c1275e66025..f2f0998c4a91 100644 --- a/drivers/md/bcache/movinggc.c +++ b/drivers/md/bcache/movinggc.c | |||
@@ -25,10 +25,9 @@ static bool moving_pred(struct keybuf *buf, struct bkey *k) | |||
25 | unsigned i; | 25 | unsigned i; |
26 | 26 | ||
27 | for (i = 0; i < KEY_PTRS(k); i++) { | 27 | for (i = 0; i < KEY_PTRS(k); i++) { |
28 | struct cache *ca = PTR_CACHE(c, k, i); | ||
29 | struct bucket *g = PTR_BUCKET(c, k, i); | 28 | struct bucket *g = PTR_BUCKET(c, k, i); |
30 | 29 | ||
31 | if (GC_SECTORS_USED(g) < ca->gc_move_threshold) | 30 | if (GC_MOVE(g)) |
32 | return true; | 31 | return true; |
33 | } | 32 | } |
34 | 33 | ||
@@ -65,11 +64,16 @@ static void write_moving_finish(struct closure *cl) | |||
65 | 64 | ||
66 | static void read_moving_endio(struct bio *bio, int error) | 65 | static void read_moving_endio(struct bio *bio, int error) |
67 | { | 66 | { |
67 | struct bbio *b = container_of(bio, struct bbio, bio); | ||
68 | struct moving_io *io = container_of(bio->bi_private, | 68 | struct moving_io *io = container_of(bio->bi_private, |
69 | struct moving_io, cl); | 69 | struct moving_io, cl); |
70 | 70 | ||
71 | if (error) | 71 | if (error) |
72 | io->op.error = error; | 72 | io->op.error = error; |
73 | else if (!KEY_DIRTY(&b->key) && | ||
74 | ptr_stale(io->op.c, &b->key, 0)) { | ||
75 | io->op.error = -EINTR; | ||
76 | } | ||
73 | 77 | ||
74 | bch_bbio_endio(io->op.c, bio, error, "reading data to move"); | 78 | bch_bbio_endio(io->op.c, bio, error, "reading data to move"); |
75 | } | 79 | } |
@@ -141,6 +145,11 @@ static void read_moving(struct cache_set *c) | |||
141 | if (!w) | 145 | if (!w) |
142 | break; | 146 | break; |
143 | 147 | ||
148 | if (ptr_stale(c, &w->key, 0)) { | ||
149 | bch_keybuf_del(&c->moving_gc_keys, w); | ||
150 | continue; | ||
151 | } | ||
152 | |||
144 | io = kzalloc(sizeof(struct moving_io) + sizeof(struct bio_vec) | 153 | io = kzalloc(sizeof(struct moving_io) + sizeof(struct bio_vec) |
145 | * DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS), | 154 | * DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS), |
146 | GFP_KERNEL); | 155 | GFP_KERNEL); |
@@ -184,7 +193,8 @@ static bool bucket_cmp(struct bucket *l, struct bucket *r) | |||
184 | 193 | ||
185 | static unsigned bucket_heap_top(struct cache *ca) | 194 | static unsigned bucket_heap_top(struct cache *ca) |
186 | { | 195 | { |
187 | return GC_SECTORS_USED(heap_peek(&ca->heap)); | 196 | struct bucket *b; |
197 | return (b = heap_peek(&ca->heap)) ? GC_SECTORS_USED(b) : 0; | ||
188 | } | 198 | } |
189 | 199 | ||
190 | void bch_moving_gc(struct cache_set *c) | 200 | void bch_moving_gc(struct cache_set *c) |
@@ -226,9 +236,8 @@ void bch_moving_gc(struct cache_set *c) | |||
226 | sectors_to_move -= GC_SECTORS_USED(b); | 236 | sectors_to_move -= GC_SECTORS_USED(b); |
227 | } | 237 | } |
228 | 238 | ||
229 | ca->gc_move_threshold = bucket_heap_top(ca); | 239 | while (heap_pop(&ca->heap, b, bucket_cmp)) |
230 | 240 | SET_GC_MOVE(b, 1); | |
231 | pr_debug("threshold %u", ca->gc_move_threshold); | ||
232 | } | 241 | } |
233 | 242 | ||
234 | mutex_unlock(&c->bucket_lock); | 243 | mutex_unlock(&c->bucket_lock); |
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index dec15cd2d797..c57bfa071a57 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c | |||
@@ -1676,7 +1676,7 @@ err: | |||
1676 | static bool can_attach_cache(struct cache *ca, struct cache_set *c) | 1676 | static bool can_attach_cache(struct cache *ca, struct cache_set *c) |
1677 | { | 1677 | { |
1678 | return ca->sb.block_size == c->sb.block_size && | 1678 | return ca->sb.block_size == c->sb.block_size && |
1679 | ca->sb.bucket_size == c->sb.block_size && | 1679 | ca->sb.bucket_size == c->sb.bucket_size && |
1680 | ca->sb.nr_in_set == c->sb.nr_in_set; | 1680 | ca->sb.nr_in_set == c->sb.nr_in_set; |
1681 | } | 1681 | } |
1682 | 1682 | ||
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index 80d4c2bee18a..a1f85612f0b3 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c | |||
@@ -83,7 +83,6 @@ rw_attribute(writeback_rate); | |||
83 | rw_attribute(writeback_rate_update_seconds); | 83 | rw_attribute(writeback_rate_update_seconds); |
84 | rw_attribute(writeback_rate_d_term); | 84 | rw_attribute(writeback_rate_d_term); |
85 | rw_attribute(writeback_rate_p_term_inverse); | 85 | rw_attribute(writeback_rate_p_term_inverse); |
86 | rw_attribute(writeback_rate_d_smooth); | ||
87 | read_attribute(writeback_rate_debug); | 86 | read_attribute(writeback_rate_debug); |
88 | 87 | ||
89 | read_attribute(stripe_size); | 88 | read_attribute(stripe_size); |
@@ -129,31 +128,41 @@ SHOW(__bch_cached_dev) | |||
129 | var_printf(writeback_running, "%i"); | 128 | var_printf(writeback_running, "%i"); |
130 | var_print(writeback_delay); | 129 | var_print(writeback_delay); |
131 | var_print(writeback_percent); | 130 | var_print(writeback_percent); |
132 | sysfs_print(writeback_rate, dc->writeback_rate.rate); | 131 | sysfs_hprint(writeback_rate, dc->writeback_rate.rate << 9); |
133 | 132 | ||
134 | var_print(writeback_rate_update_seconds); | 133 | var_print(writeback_rate_update_seconds); |
135 | var_print(writeback_rate_d_term); | 134 | var_print(writeback_rate_d_term); |
136 | var_print(writeback_rate_p_term_inverse); | 135 | var_print(writeback_rate_p_term_inverse); |
137 | var_print(writeback_rate_d_smooth); | ||
138 | 136 | ||
139 | if (attr == &sysfs_writeback_rate_debug) { | 137 | if (attr == &sysfs_writeback_rate_debug) { |
138 | char rate[20]; | ||
140 | char dirty[20]; | 139 | char dirty[20]; |
141 | char derivative[20]; | ||
142 | char target[20]; | 140 | char target[20]; |
143 | bch_hprint(dirty, | 141 | char proportional[20]; |
144 | bcache_dev_sectors_dirty(&dc->disk) << 9); | 142 | char derivative[20]; |
145 | bch_hprint(derivative, dc->writeback_rate_derivative << 9); | 143 | char change[20]; |
144 | s64 next_io; | ||
145 | |||
146 | bch_hprint(rate, dc->writeback_rate.rate << 9); | ||
147 | bch_hprint(dirty, bcache_dev_sectors_dirty(&dc->disk) << 9); | ||
146 | bch_hprint(target, dc->writeback_rate_target << 9); | 148 | bch_hprint(target, dc->writeback_rate_target << 9); |
149 | bch_hprint(proportional,dc->writeback_rate_proportional << 9); | ||
150 | bch_hprint(derivative, dc->writeback_rate_derivative << 9); | ||
151 | bch_hprint(change, dc->writeback_rate_change << 9); | ||
152 | |||
153 | next_io = div64_s64(dc->writeback_rate.next - local_clock(), | ||
154 | NSEC_PER_MSEC); | ||
147 | 155 | ||
148 | return sprintf(buf, | 156 | return sprintf(buf, |
149 | "rate:\t\t%u\n" | 157 | "rate:\t\t%s/sec\n" |
150 | "change:\t\t%i\n" | ||
151 | "dirty:\t\t%s\n" | 158 | "dirty:\t\t%s\n" |
159 | "target:\t\t%s\n" | ||
160 | "proportional:\t%s\n" | ||
152 | "derivative:\t%s\n" | 161 | "derivative:\t%s\n" |
153 | "target:\t\t%s\n", | 162 | "change:\t\t%s/sec\n" |
154 | dc->writeback_rate.rate, | 163 | "next io:\t%llims\n", |
155 | dc->writeback_rate_change, | 164 | rate, dirty, target, proportional, |
156 | dirty, derivative, target); | 165 | derivative, change, next_io); |
157 | } | 166 | } |
158 | 167 | ||
159 | sysfs_hprint(dirty_data, | 168 | sysfs_hprint(dirty_data, |
@@ -189,6 +198,7 @@ STORE(__cached_dev) | |||
189 | struct kobj_uevent_env *env; | 198 | struct kobj_uevent_env *env; |
190 | 199 | ||
191 | #define d_strtoul(var) sysfs_strtoul(var, dc->var) | 200 | #define d_strtoul(var) sysfs_strtoul(var, dc->var) |
201 | #define d_strtoul_nonzero(var) sysfs_strtoul_clamp(var, dc->var, 1, INT_MAX) | ||
192 | #define d_strtoi_h(var) sysfs_hatoi(var, dc->var) | 202 | #define d_strtoi_h(var) sysfs_hatoi(var, dc->var) |
193 | 203 | ||
194 | sysfs_strtoul(data_csum, dc->disk.data_csum); | 204 | sysfs_strtoul(data_csum, dc->disk.data_csum); |
@@ -197,16 +207,15 @@ STORE(__cached_dev) | |||
197 | d_strtoul(writeback_metadata); | 207 | d_strtoul(writeback_metadata); |
198 | d_strtoul(writeback_running); | 208 | d_strtoul(writeback_running); |
199 | d_strtoul(writeback_delay); | 209 | d_strtoul(writeback_delay); |
200 | sysfs_strtoul_clamp(writeback_rate, | 210 | |
201 | dc->writeback_rate.rate, 1, 1000000); | ||
202 | sysfs_strtoul_clamp(writeback_percent, dc->writeback_percent, 0, 40); | 211 | sysfs_strtoul_clamp(writeback_percent, dc->writeback_percent, 0, 40); |
203 | 212 | ||
204 | d_strtoul(writeback_rate_update_seconds); | 213 | sysfs_strtoul_clamp(writeback_rate, |
214 | dc->writeback_rate.rate, 1, INT_MAX); | ||
215 | |||
216 | d_strtoul_nonzero(writeback_rate_update_seconds); | ||
205 | d_strtoul(writeback_rate_d_term); | 217 | d_strtoul(writeback_rate_d_term); |
206 | d_strtoul(writeback_rate_p_term_inverse); | 218 | d_strtoul_nonzero(writeback_rate_p_term_inverse); |
207 | sysfs_strtoul_clamp(writeback_rate_p_term_inverse, | ||
208 | dc->writeback_rate_p_term_inverse, 1, INT_MAX); | ||
209 | d_strtoul(writeback_rate_d_smooth); | ||
210 | 219 | ||
211 | d_strtoi_h(sequential_cutoff); | 220 | d_strtoi_h(sequential_cutoff); |
212 | d_strtoi_h(readahead); | 221 | d_strtoi_h(readahead); |
@@ -313,7 +322,6 @@ static struct attribute *bch_cached_dev_files[] = { | |||
313 | &sysfs_writeback_rate_update_seconds, | 322 | &sysfs_writeback_rate_update_seconds, |
314 | &sysfs_writeback_rate_d_term, | 323 | &sysfs_writeback_rate_d_term, |
315 | &sysfs_writeback_rate_p_term_inverse, | 324 | &sysfs_writeback_rate_p_term_inverse, |
316 | &sysfs_writeback_rate_d_smooth, | ||
317 | &sysfs_writeback_rate_debug, | 325 | &sysfs_writeback_rate_debug, |
318 | &sysfs_dirty_data, | 326 | &sysfs_dirty_data, |
319 | &sysfs_stripe_size, | 327 | &sysfs_stripe_size, |
diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index 462214eeacbe..bb37618e7664 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c | |||
@@ -209,7 +209,13 @@ uint64_t bch_next_delay(struct bch_ratelimit *d, uint64_t done) | |||
209 | { | 209 | { |
210 | uint64_t now = local_clock(); | 210 | uint64_t now = local_clock(); |
211 | 211 | ||
212 | d->next += div_u64(done, d->rate); | 212 | d->next += div_u64(done * NSEC_PER_SEC, d->rate); |
213 | |||
214 | if (time_before64(now + NSEC_PER_SEC, d->next)) | ||
215 | d->next = now + NSEC_PER_SEC; | ||
216 | |||
217 | if (time_after64(now - NSEC_PER_SEC * 2, d->next)) | ||
218 | d->next = now - NSEC_PER_SEC * 2; | ||
213 | 219 | ||
214 | return time_after64(d->next, now) | 220 | return time_after64(d->next, now) |
215 | ? div_u64(d->next - now, NSEC_PER_SEC / HZ) | 221 | ? div_u64(d->next - now, NSEC_PER_SEC / HZ) |
diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h index 362c4b3f8b4a..1030c6020e98 100644 --- a/drivers/md/bcache/util.h +++ b/drivers/md/bcache/util.h | |||
@@ -110,7 +110,7 @@ do { \ | |||
110 | _r; \ | 110 | _r; \ |
111 | }) | 111 | }) |
112 | 112 | ||
113 | #define heap_peek(h) ((h)->size ? (h)->data[0] : NULL) | 113 | #define heap_peek(h) ((h)->used ? (h)->data[0] : NULL) |
114 | 114 | ||
115 | #define heap_full(h) ((h)->used == (h)->size) | 115 | #define heap_full(h) ((h)->used == (h)->size) |
116 | 116 | ||
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index 99053b1251be..6c44fe059c27 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c | |||
@@ -30,38 +30,40 @@ static void __update_writeback_rate(struct cached_dev *dc) | |||
30 | 30 | ||
31 | /* PD controller */ | 31 | /* PD controller */ |
32 | 32 | ||
33 | int change = 0; | ||
34 | int64_t error; | ||
35 | int64_t dirty = bcache_dev_sectors_dirty(&dc->disk); | 33 | int64_t dirty = bcache_dev_sectors_dirty(&dc->disk); |
36 | int64_t derivative = dirty - dc->disk.sectors_dirty_last; | 34 | int64_t derivative = dirty - dc->disk.sectors_dirty_last; |
35 | int64_t proportional = dirty - target; | ||
36 | int64_t change; | ||
37 | 37 | ||
38 | dc->disk.sectors_dirty_last = dirty; | 38 | dc->disk.sectors_dirty_last = dirty; |
39 | 39 | ||
40 | derivative *= dc->writeback_rate_d_term; | 40 | /* Scale to sectors per second */ |
41 | derivative = clamp(derivative, -dirty, dirty); | ||
42 | 41 | ||
43 | derivative = ewma_add(dc->disk.sectors_dirty_derivative, derivative, | 42 | proportional *= dc->writeback_rate_update_seconds; |
44 | dc->writeback_rate_d_smooth, 0); | 43 | proportional = div_s64(proportional, dc->writeback_rate_p_term_inverse); |
45 | 44 | ||
46 | /* Avoid divide by zero */ | 45 | derivative = div_s64(derivative, dc->writeback_rate_update_seconds); |
47 | if (!target) | ||
48 | goto out; | ||
49 | 46 | ||
50 | error = div64_s64((dirty + derivative - target) << 8, target); | 47 | derivative = ewma_add(dc->disk.sectors_dirty_derivative, derivative, |
48 | (dc->writeback_rate_d_term / | ||
49 | dc->writeback_rate_update_seconds) ?: 1, 0); | ||
50 | |||
51 | derivative *= dc->writeback_rate_d_term; | ||
52 | derivative = div_s64(derivative, dc->writeback_rate_p_term_inverse); | ||
51 | 53 | ||
52 | change = div_s64((dc->writeback_rate.rate * error) >> 8, | 54 | change = proportional + derivative; |
53 | dc->writeback_rate_p_term_inverse); | ||
54 | 55 | ||
55 | /* Don't increase writeback rate if the device isn't keeping up */ | 56 | /* Don't increase writeback rate if the device isn't keeping up */ |
56 | if (change > 0 && | 57 | if (change > 0 && |
57 | time_after64(local_clock(), | 58 | time_after64(local_clock(), |
58 | dc->writeback_rate.next + 10 * NSEC_PER_MSEC)) | 59 | dc->writeback_rate.next + NSEC_PER_MSEC)) |
59 | change = 0; | 60 | change = 0; |
60 | 61 | ||
61 | dc->writeback_rate.rate = | 62 | dc->writeback_rate.rate = |
62 | clamp_t(int64_t, dc->writeback_rate.rate + change, | 63 | clamp_t(int64_t, (int64_t) dc->writeback_rate.rate + change, |
63 | 1, NSEC_PER_MSEC); | 64 | 1, NSEC_PER_MSEC); |
64 | out: | 65 | |
66 | dc->writeback_rate_proportional = proportional; | ||
65 | dc->writeback_rate_derivative = derivative; | 67 | dc->writeback_rate_derivative = derivative; |
66 | dc->writeback_rate_change = change; | 68 | dc->writeback_rate_change = change; |
67 | dc->writeback_rate_target = target; | 69 | dc->writeback_rate_target = target; |
@@ -87,15 +89,11 @@ static void update_writeback_rate(struct work_struct *work) | |||
87 | 89 | ||
88 | static unsigned writeback_delay(struct cached_dev *dc, unsigned sectors) | 90 | static unsigned writeback_delay(struct cached_dev *dc, unsigned sectors) |
89 | { | 91 | { |
90 | uint64_t ret; | ||
91 | |||
92 | if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) || | 92 | if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) || |
93 | !dc->writeback_percent) | 93 | !dc->writeback_percent) |
94 | return 0; | 94 | return 0; |
95 | 95 | ||
96 | ret = bch_next_delay(&dc->writeback_rate, sectors * 10000000ULL); | 96 | return bch_next_delay(&dc->writeback_rate, sectors); |
97 | |||
98 | return min_t(uint64_t, ret, HZ); | ||
99 | } | 97 | } |
100 | 98 | ||
101 | struct dirty_io { | 99 | struct dirty_io { |
@@ -241,7 +239,7 @@ static void read_dirty(struct cached_dev *dc) | |||
241 | if (KEY_START(&w->key) != dc->last_read || | 239 | if (KEY_START(&w->key) != dc->last_read || |
242 | jiffies_to_msecs(delay) > 50) | 240 | jiffies_to_msecs(delay) > 50) |
243 | while (!kthread_should_stop() && delay) | 241 | while (!kthread_should_stop() && delay) |
244 | delay = schedule_timeout_interruptible(delay); | 242 | delay = schedule_timeout_uninterruptible(delay); |
245 | 243 | ||
246 | dc->last_read = KEY_OFFSET(&w->key); | 244 | dc->last_read = KEY_OFFSET(&w->key); |
247 | 245 | ||
@@ -438,7 +436,7 @@ static int bch_writeback_thread(void *arg) | |||
438 | while (delay && | 436 | while (delay && |
439 | !kthread_should_stop() && | 437 | !kthread_should_stop() && |
440 | !test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)) | 438 | !test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)) |
441 | delay = schedule_timeout_interruptible(delay); | 439 | delay = schedule_timeout_uninterruptible(delay); |
442 | } | 440 | } |
443 | } | 441 | } |
444 | 442 | ||
@@ -476,6 +474,8 @@ void bch_sectors_dirty_init(struct cached_dev *dc) | |||
476 | 474 | ||
477 | bch_btree_map_keys(&op.op, dc->disk.c, &KEY(op.inode, 0, 0), | 475 | bch_btree_map_keys(&op.op, dc->disk.c, &KEY(op.inode, 0, 0), |
478 | sectors_dirty_init_fn, 0); | 476 | sectors_dirty_init_fn, 0); |
477 | |||
478 | dc->disk.sectors_dirty_last = bcache_dev_sectors_dirty(&dc->disk); | ||
479 | } | 479 | } |
480 | 480 | ||
481 | int bch_cached_dev_writeback_init(struct cached_dev *dc) | 481 | int bch_cached_dev_writeback_init(struct cached_dev *dc) |
@@ -490,18 +490,15 @@ int bch_cached_dev_writeback_init(struct cached_dev *dc) | |||
490 | dc->writeback_delay = 30; | 490 | dc->writeback_delay = 30; |
491 | dc->writeback_rate.rate = 1024; | 491 | dc->writeback_rate.rate = 1024; |
492 | 492 | ||
493 | dc->writeback_rate_update_seconds = 30; | 493 | dc->writeback_rate_update_seconds = 5; |
494 | dc->writeback_rate_d_term = 16; | 494 | dc->writeback_rate_d_term = 30; |
495 | dc->writeback_rate_p_term_inverse = 64; | 495 | dc->writeback_rate_p_term_inverse = 6000; |
496 | dc->writeback_rate_d_smooth = 8; | ||
497 | 496 | ||
498 | dc->writeback_thread = kthread_create(bch_writeback_thread, dc, | 497 | dc->writeback_thread = kthread_create(bch_writeback_thread, dc, |
499 | "bcache_writeback"); | 498 | "bcache_writeback"); |
500 | if (IS_ERR(dc->writeback_thread)) | 499 | if (IS_ERR(dc->writeback_thread)) |
501 | return PTR_ERR(dc->writeback_thread); | 500 | return PTR_ERR(dc->writeback_thread); |
502 | 501 | ||
503 | set_task_state(dc->writeback_thread, TASK_INTERRUPTIBLE); | ||
504 | |||
505 | INIT_DELAYED_WORK(&dc->writeback_rate_update, update_writeback_rate); | 502 | INIT_DELAYED_WORK(&dc->writeback_rate_update, update_writeback_rate); |
506 | schedule_delayed_work(&dc->writeback_rate_update, | 503 | schedule_delayed_work(&dc->writeback_rate_update, |
507 | dc->writeback_rate_update_seconds * HZ); | 504 | dc->writeback_rate_update_seconds * HZ); |
diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c index 0779d5ab9ab1..51b6df1a7949 100644 --- a/drivers/mfd/twl6040.c +++ b/drivers/mfd/twl6040.c | |||
@@ -44,6 +44,54 @@ | |||
44 | #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) | 44 | #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) |
45 | #define TWL6040_NUM_SUPPLIES (2) | 45 | #define TWL6040_NUM_SUPPLIES (2) |
46 | 46 | ||
47 | static struct reg_default twl6040_defaults[] = { | ||
48 | { 0x01, 0x4B }, /* REG_ASICID (ro) */ | ||
49 | { 0x02, 0x00 }, /* REG_ASICREV (ro) */ | ||
50 | { 0x03, 0x00 }, /* REG_INTID */ | ||
51 | { 0x04, 0x00 }, /* REG_INTMR */ | ||
52 | { 0x05, 0x00 }, /* REG_NCPCTRL */ | ||
53 | { 0x06, 0x00 }, /* REG_LDOCTL */ | ||
54 | { 0x07, 0x60 }, /* REG_HPPLLCTL */ | ||
55 | { 0x08, 0x00 }, /* REG_LPPLLCTL */ | ||
56 | { 0x09, 0x4A }, /* REG_LPPLLDIV */ | ||
57 | { 0x0A, 0x00 }, /* REG_AMICBCTL */ | ||
58 | { 0x0B, 0x00 }, /* REG_DMICBCTL */ | ||
59 | { 0x0C, 0x00 }, /* REG_MICLCTL */ | ||
60 | { 0x0D, 0x00 }, /* REG_MICRCTL */ | ||
61 | { 0x0E, 0x00 }, /* REG_MICGAIN */ | ||
62 | { 0x0F, 0x1B }, /* REG_LINEGAIN */ | ||
63 | { 0x10, 0x00 }, /* REG_HSLCTL */ | ||
64 | { 0x11, 0x00 }, /* REG_HSRCTL */ | ||
65 | { 0x12, 0x00 }, /* REG_HSGAIN */ | ||
66 | { 0x13, 0x00 }, /* REG_EARCTL */ | ||
67 | { 0x14, 0x00 }, /* REG_HFLCTL */ | ||
68 | { 0x15, 0x00 }, /* REG_HFLGAIN */ | ||
69 | { 0x16, 0x00 }, /* REG_HFRCTL */ | ||
70 | { 0x17, 0x00 }, /* REG_HFRGAIN */ | ||
71 | { 0x18, 0x00 }, /* REG_VIBCTLL */ | ||
72 | { 0x19, 0x00 }, /* REG_VIBDATL */ | ||
73 | { 0x1A, 0x00 }, /* REG_VIBCTLR */ | ||
74 | { 0x1B, 0x00 }, /* REG_VIBDATR */ | ||
75 | { 0x1C, 0x00 }, /* REG_HKCTL1 */ | ||
76 | { 0x1D, 0x00 }, /* REG_HKCTL2 */ | ||
77 | { 0x1E, 0x00 }, /* REG_GPOCTL */ | ||
78 | { 0x1F, 0x00 }, /* REG_ALB */ | ||
79 | { 0x20, 0x00 }, /* REG_DLB */ | ||
80 | /* 0x28, REG_TRIM1 */ | ||
81 | /* 0x29, REG_TRIM2 */ | ||
82 | /* 0x2A, REG_TRIM3 */ | ||
83 | /* 0x2B, REG_HSOTRIM */ | ||
84 | /* 0x2C, REG_HFOTRIM */ | ||
85 | { 0x2D, 0x08 }, /* REG_ACCCTL */ | ||
86 | { 0x2E, 0x00 }, /* REG_STATUS (ro) */ | ||
87 | }; | ||
88 | |||
89 | struct reg_default twl6040_patch[] = { | ||
90 | /* Select I2C bus access to dual access registers */ | ||
91 | { TWL6040_REG_ACCCTL, 0x09 }, | ||
92 | }; | ||
93 | |||
94 | |||
47 | static bool twl6040_has_vibra(struct device_node *node) | 95 | static bool twl6040_has_vibra(struct device_node *node) |
48 | { | 96 | { |
49 | #ifdef CONFIG_OF | 97 | #ifdef CONFIG_OF |
@@ -238,6 +286,9 @@ int twl6040_power(struct twl6040 *twl6040, int on) | |||
238 | if (twl6040->power_count++) | 286 | if (twl6040->power_count++) |
239 | goto out; | 287 | goto out; |
240 | 288 | ||
289 | /* Allow writes to the chip */ | ||
290 | regcache_cache_only(twl6040->regmap, false); | ||
291 | |||
241 | if (gpio_is_valid(twl6040->audpwron)) { | 292 | if (gpio_is_valid(twl6040->audpwron)) { |
242 | /* use automatic power-up sequence */ | 293 | /* use automatic power-up sequence */ |
243 | ret = twl6040_power_up_automatic(twl6040); | 294 | ret = twl6040_power_up_automatic(twl6040); |
@@ -253,6 +304,10 @@ int twl6040_power(struct twl6040 *twl6040, int on) | |||
253 | goto out; | 304 | goto out; |
254 | } | 305 | } |
255 | } | 306 | } |
307 | |||
308 | /* Sync with the HW */ | ||
309 | regcache_sync(twl6040->regmap); | ||
310 | |||
256 | /* Default PLL configuration after power up */ | 311 | /* Default PLL configuration after power up */ |
257 | twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL; | 312 | twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL; |
258 | twl6040->sysclk = 19200000; | 313 | twl6040->sysclk = 19200000; |
@@ -279,6 +334,11 @@ int twl6040_power(struct twl6040 *twl6040, int on) | |||
279 | /* use manual power-down sequence */ | 334 | /* use manual power-down sequence */ |
280 | twl6040_power_down_manual(twl6040); | 335 | twl6040_power_down_manual(twl6040); |
281 | } | 336 | } |
337 | |||
338 | /* Set regmap to cache only and mark it as dirty */ | ||
339 | regcache_cache_only(twl6040->regmap, true); | ||
340 | regcache_mark_dirty(twl6040->regmap); | ||
341 | |||
282 | twl6040->sysclk = 0; | 342 | twl6040->sysclk = 0; |
283 | twl6040->mclk = 0; | 343 | twl6040->mclk = 0; |
284 | } | 344 | } |
@@ -490,9 +550,24 @@ static bool twl6040_readable_reg(struct device *dev, unsigned int reg) | |||
490 | static bool twl6040_volatile_reg(struct device *dev, unsigned int reg) | 550 | static bool twl6040_volatile_reg(struct device *dev, unsigned int reg) |
491 | { | 551 | { |
492 | switch (reg) { | 552 | switch (reg) { |
493 | case TWL6040_REG_VIBCTLL: | 553 | case TWL6040_REG_ASICID: |
494 | case TWL6040_REG_VIBCTLR: | 554 | case TWL6040_REG_ASICREV: |
495 | case TWL6040_REG_INTMR: | 555 | case TWL6040_REG_INTID: |
556 | case TWL6040_REG_LPPLLCTL: | ||
557 | case TWL6040_REG_HPPLLCTL: | ||
558 | case TWL6040_REG_STATUS: | ||
559 | return true; | ||
560 | default: | ||
561 | return false; | ||
562 | } | ||
563 | } | ||
564 | |||
565 | static bool twl6040_writeable_reg(struct device *dev, unsigned int reg) | ||
566 | { | ||
567 | switch (reg) { | ||
568 | case TWL6040_REG_ASICID: | ||
569 | case TWL6040_REG_ASICREV: | ||
570 | case TWL6040_REG_STATUS: | ||
496 | return false; | 571 | return false; |
497 | default: | 572 | default: |
498 | return true; | 573 | return true; |
@@ -502,10 +577,15 @@ static bool twl6040_volatile_reg(struct device *dev, unsigned int reg) | |||
502 | static struct regmap_config twl6040_regmap_config = { | 577 | static struct regmap_config twl6040_regmap_config = { |
503 | .reg_bits = 8, | 578 | .reg_bits = 8, |
504 | .val_bits = 8, | 579 | .val_bits = 8, |
580 | |||
581 | .reg_defaults = twl6040_defaults, | ||
582 | .num_reg_defaults = ARRAY_SIZE(twl6040_defaults), | ||
583 | |||
505 | .max_register = TWL6040_REG_STATUS, /* 0x2e */ | 584 | .max_register = TWL6040_REG_STATUS, /* 0x2e */ |
506 | 585 | ||
507 | .readable_reg = twl6040_readable_reg, | 586 | .readable_reg = twl6040_readable_reg, |
508 | .volatile_reg = twl6040_volatile_reg, | 587 | .volatile_reg = twl6040_volatile_reg, |
588 | .writeable_reg = twl6040_writeable_reg, | ||
509 | 589 | ||
510 | .cache_type = REGCACHE_RBTREE, | 590 | .cache_type = REGCACHE_RBTREE, |
511 | }; | 591 | }; |
@@ -624,6 +704,8 @@ static int twl6040_probe(struct i2c_client *client, | |||
624 | 704 | ||
625 | /* dual-access registers controlled by I2C only */ | 705 | /* dual-access registers controlled by I2C only */ |
626 | twl6040_set_bits(twl6040, TWL6040_REG_ACCCTL, TWL6040_I2CSEL); | 706 | twl6040_set_bits(twl6040, TWL6040_REG_ACCCTL, TWL6040_I2CSEL); |
707 | regmap_register_patch(twl6040->regmap, twl6040_patch, | ||
708 | ARRAY_SIZE(twl6040_patch)); | ||
627 | 709 | ||
628 | /* | 710 | /* |
629 | * The main functionality of twl6040 to provide audio on OMAP4+ systems. | 711 | * The main functionality of twl6040 to provide audio on OMAP4+ systems. |
@@ -656,6 +738,10 @@ static int twl6040_probe(struct i2c_client *client, | |||
656 | cell->name = "twl6040-gpo"; | 738 | cell->name = "twl6040-gpo"; |
657 | children++; | 739 | children++; |
658 | 740 | ||
741 | /* The chip is powered down so mark regmap to cache only and dirty */ | ||
742 | regcache_cache_only(twl6040->regmap, true); | ||
743 | regcache_mark_dirty(twl6040->regmap); | ||
744 | |||
659 | ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children, | 745 | ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children, |
660 | NULL, 0, NULL); | 746 | NULL, 0, NULL); |
661 | if (ret) | 747 | if (ret) |
diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c index bf8b3b5ad1fe..abd6713de7b0 100644 --- a/drivers/mfd/wm5110-tables.c +++ b/drivers/mfd/wm5110-tables.c | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/mfd/arizona/core.h> | 15 | #include <linux/mfd/arizona/core.h> |
16 | #include <linux/mfd/arizona/registers.h> | 16 | #include <linux/mfd/arizona/registers.h> |
17 | #include <linux/device.h> | ||
17 | 18 | ||
18 | #include "arizona.h" | 19 | #include "arizona.h" |
19 | 20 | ||
@@ -524,6 +525,7 @@ static const struct reg_default wm5110_reg_default[] = { | |||
524 | { 0x00000300, 0x0000 }, /* R768 - Input Enables */ | 525 | { 0x00000300, 0x0000 }, /* R768 - Input Enables */ |
525 | { 0x00000308, 0x0000 }, /* R776 - Input Rate */ | 526 | { 0x00000308, 0x0000 }, /* R776 - Input Rate */ |
526 | { 0x00000309, 0x0022 }, /* R777 - Input Volume Ramp */ | 527 | { 0x00000309, 0x0022 }, /* R777 - Input Volume Ramp */ |
528 | { 0x0000030C, 0x0002 }, /* R780 - HPF Control */ | ||
527 | { 0x00000310, 0x2080 }, /* R784 - IN1L Control */ | 529 | { 0x00000310, 0x2080 }, /* R784 - IN1L Control */ |
528 | { 0x00000311, 0x0180 }, /* R785 - ADC Digital Volume 1L */ | 530 | { 0x00000311, 0x0180 }, /* R785 - ADC Digital Volume 1L */ |
529 | { 0x00000312, 0x0000 }, /* R786 - DMIC1L Control */ | 531 | { 0x00000312, 0x0000 }, /* R786 - DMIC1L Control */ |
@@ -545,6 +547,7 @@ static const struct reg_default wm5110_reg_default[] = { | |||
545 | { 0x00000328, 0x2000 }, /* R808 - IN4L Control */ | 547 | { 0x00000328, 0x2000 }, /* R808 - IN4L Control */ |
546 | { 0x00000329, 0x0180 }, /* R809 - ADC Digital Volume 4L */ | 548 | { 0x00000329, 0x0180 }, /* R809 - ADC Digital Volume 4L */ |
547 | { 0x0000032A, 0x0000 }, /* R810 - DMIC4L Control */ | 549 | { 0x0000032A, 0x0000 }, /* R810 - DMIC4L Control */ |
550 | { 0x0000032C, 0x0000 }, /* R812 - IN4R Control */ | ||
548 | { 0x0000032D, 0x0180 }, /* R813 - ADC Digital Volume 4R */ | 551 | { 0x0000032D, 0x0180 }, /* R813 - ADC Digital Volume 4R */ |
549 | { 0x0000032E, 0x0000 }, /* R814 - DMIC4R Control */ | 552 | { 0x0000032E, 0x0000 }, /* R814 - DMIC4R Control */ |
550 | { 0x00000400, 0x0000 }, /* R1024 - Output Enables 1 */ | 553 | { 0x00000400, 0x0000 }, /* R1024 - Output Enables 1 */ |
@@ -598,6 +601,7 @@ static const struct reg_default wm5110_reg_default[] = { | |||
598 | { 0x0000043D, 0x0180 }, /* R1085 - DAC Digital Volume 6R */ | 601 | { 0x0000043D, 0x0180 }, /* R1085 - DAC Digital Volume 6R */ |
599 | { 0x0000043E, 0x0080 }, /* R1086 - DAC Volume Limit 6R */ | 602 | { 0x0000043E, 0x0080 }, /* R1086 - DAC Volume Limit 6R */ |
600 | { 0x0000043F, 0x0800 }, /* R1087 - Noise Gate Select 6R */ | 603 | { 0x0000043F, 0x0800 }, /* R1087 - Noise Gate Select 6R */ |
604 | { 0x00000440, 0x8FFF }, /* R1088 - DRE Enable */ | ||
601 | { 0x00000450, 0x0000 }, /* R1104 - DAC AEC Control 1 */ | 605 | { 0x00000450, 0x0000 }, /* R1104 - DAC AEC Control 1 */ |
602 | { 0x00000458, 0x0000 }, /* R1112 - Noise Gate Control */ | 606 | { 0x00000458, 0x0000 }, /* R1112 - Noise Gate Control */ |
603 | { 0x00000480, 0x0040 }, /* R1152 - Class W ANC Threshold 1 */ | 607 | { 0x00000480, 0x0040 }, /* R1152 - Class W ANC Threshold 1 */ |
@@ -882,6 +886,38 @@ static const struct reg_default wm5110_reg_default[] = { | |||
882 | { 0x0000074D, 0x0080 }, /* R1869 - AIF2TX2MIX Input 3 Volume */ | 886 | { 0x0000074D, 0x0080 }, /* R1869 - AIF2TX2MIX Input 3 Volume */ |
883 | { 0x0000074E, 0x0000 }, /* R1870 - AIF2TX2MIX Input 4 Source */ | 887 | { 0x0000074E, 0x0000 }, /* R1870 - AIF2TX2MIX Input 4 Source */ |
884 | { 0x0000074F, 0x0080 }, /* R1871 - AIF2TX2MIX Input 4 Volume */ | 888 | { 0x0000074F, 0x0080 }, /* R1871 - AIF2TX2MIX Input 4 Volume */ |
889 | { 0x00000750, 0x0000 }, /* R1872 - AIF2TX3MIX Input 1 Source */ | ||
890 | { 0x00000751, 0x0080 }, /* R1873 - AIF2TX3MIX Input 1 Volume */ | ||
891 | { 0x00000752, 0x0000 }, /* R1874 - AIF2TX3MIX Input 2 Source */ | ||
892 | { 0x00000753, 0x0080 }, /* R1875 - AIF2TX3MIX Input 2 Volume */ | ||
893 | { 0x00000754, 0x0000 }, /* R1876 - AIF2TX3MIX Input 3 Source */ | ||
894 | { 0x00000755, 0x0080 }, /* R1877 - AIF2TX3MIX Input 3 Volume */ | ||
895 | { 0x00000756, 0x0000 }, /* R1878 - AIF2TX3MIX Input 4 Source */ | ||
896 | { 0x00000757, 0x0080 }, /* R1879 - AIF2TX3MIX Input 4 Volume */ | ||
897 | { 0x00000758, 0x0000 }, /* R1880 - AIF2TX4MIX Input 1 Source */ | ||
898 | { 0x00000759, 0x0080 }, /* R1881 - AIF2TX4MIX Input 1 Volume */ | ||
899 | { 0x0000075A, 0x0000 }, /* R1882 - AIF2TX4MIX Input 2 Source */ | ||
900 | { 0x0000075B, 0x0080 }, /* R1883 - AIF2TX4MIX Input 2 Volume */ | ||
901 | { 0x0000075C, 0x0000 }, /* R1884 - AIF2TX4MIX Input 3 Source */ | ||
902 | { 0x0000075D, 0x0080 }, /* R1885 - AIF2TX4MIX Input 3 Volume */ | ||
903 | { 0x0000075E, 0x0000 }, /* R1886 - AIF2TX4MIX Input 4 Source */ | ||
904 | { 0x0000075F, 0x0080 }, /* R1887 - AIF2TX4MIX Input 4 Volume */ | ||
905 | { 0x00000760, 0x0000 }, /* R1888 - AIF2TX5MIX Input 1 Source */ | ||
906 | { 0x00000761, 0x0080 }, /* R1889 - AIF2TX5MIX Input 1 Volume */ | ||
907 | { 0x00000762, 0x0000 }, /* R1890 - AIF2TX5MIX Input 2 Source */ | ||
908 | { 0x00000763, 0x0080 }, /* R1891 - AIF2TX5MIX Input 2 Volume */ | ||
909 | { 0x00000764, 0x0000 }, /* R1892 - AIF2TX5MIX Input 3 Source */ | ||
910 | { 0x00000765, 0x0080 }, /* R1893 - AIF2TX5MIX Input 3 Volume */ | ||
911 | { 0x00000766, 0x0000 }, /* R1894 - AIF2TX5MIX Input 4 Source */ | ||
912 | { 0x00000767, 0x0080 }, /* R1895 - AIF2TX5MIX Input 4 Volume */ | ||
913 | { 0x00000768, 0x0000 }, /* R1896 - AIF2TX6MIX Input 1 Source */ | ||
914 | { 0x00000769, 0x0080 }, /* R1897 - AIF2TX6MIX Input 1 Volume */ | ||
915 | { 0x0000076A, 0x0000 }, /* R1898 - AIF2TX6MIX Input 2 Source */ | ||
916 | { 0x0000076B, 0x0080 }, /* R1899 - AIF2TX6MIX Input 2 Volume */ | ||
917 | { 0x0000076C, 0x0000 }, /* R1900 - AIF2TX6MIX Input 3 Source */ | ||
918 | { 0x0000076D, 0x0080 }, /* R1901 - AIF2TX6MIX Input 3 Volume */ | ||
919 | { 0x0000076E, 0x0000 }, /* R1902 - AIF2TX6MIX Input 4 Source */ | ||
920 | { 0x0000076F, 0x0080 }, /* R1903 - AIF2TX6MIX Input 4 Volume */ | ||
885 | { 0x00000780, 0x0000 }, /* R1920 - AIF3TX1MIX Input 1 Source */ | 921 | { 0x00000780, 0x0000 }, /* R1920 - AIF3TX1MIX Input 1 Source */ |
886 | { 0x00000781, 0x0080 }, /* R1921 - AIF3TX1MIX Input 1 Volume */ | 922 | { 0x00000781, 0x0080 }, /* R1921 - AIF3TX1MIX Input 1 Volume */ |
887 | { 0x00000782, 0x0000 }, /* R1922 - AIF3TX1MIX Input 2 Source */ | 923 | { 0x00000782, 0x0000 }, /* R1922 - AIF3TX1MIX Input 2 Source */ |
@@ -1342,6 +1378,64 @@ static const struct reg_default wm5110_reg_default[] = { | |||
1342 | { 0x00001404, 0x0000 }, /* R5124 - DSP4 Status 1 */ | 1378 | { 0x00001404, 0x0000 }, /* R5124 - DSP4 Status 1 */ |
1343 | }; | 1379 | }; |
1344 | 1380 | ||
1381 | static bool wm5110_is_rev_b_adsp_memory(unsigned int reg) | ||
1382 | { | ||
1383 | if ((reg >= 0x100000 && reg < 0x103000) || | ||
1384 | (reg >= 0x180000 && reg < 0x181000) || | ||
1385 | (reg >= 0x190000 && reg < 0x192000) || | ||
1386 | (reg >= 0x1a8000 && reg < 0x1a9000) || | ||
1387 | (reg >= 0x200000 && reg < 0x209000) || | ||
1388 | (reg >= 0x280000 && reg < 0x281000) || | ||
1389 | (reg >= 0x290000 && reg < 0x29a000) || | ||
1390 | (reg >= 0x2a8000 && reg < 0x2aa000) || | ||
1391 | (reg >= 0x300000 && reg < 0x30f000) || | ||
1392 | (reg >= 0x380000 && reg < 0x382000) || | ||
1393 | (reg >= 0x390000 && reg < 0x39e000) || | ||
1394 | (reg >= 0x3a8000 && reg < 0x3b6000) || | ||
1395 | (reg >= 0x400000 && reg < 0x403000) || | ||
1396 | (reg >= 0x480000 && reg < 0x481000) || | ||
1397 | (reg >= 0x490000 && reg < 0x492000) || | ||
1398 | (reg >= 0x4a8000 && reg < 0x4a9000)) | ||
1399 | return true; | ||
1400 | else | ||
1401 | return false; | ||
1402 | } | ||
1403 | |||
1404 | static bool wm5110_is_rev_d_adsp_memory(unsigned int reg) | ||
1405 | { | ||
1406 | if ((reg >= 0x100000 && reg < 0x106000) || | ||
1407 | (reg >= 0x180000 && reg < 0x182000) || | ||
1408 | (reg >= 0x190000 && reg < 0x198000) || | ||
1409 | (reg >= 0x1a8000 && reg < 0x1aa000) || | ||
1410 | (reg >= 0x200000 && reg < 0x20f000) || | ||
1411 | (reg >= 0x280000 && reg < 0x282000) || | ||
1412 | (reg >= 0x290000 && reg < 0x29c000) || | ||
1413 | (reg >= 0x2a6000 && reg < 0x2b4000) || | ||
1414 | (reg >= 0x300000 && reg < 0x30f000) || | ||
1415 | (reg >= 0x380000 && reg < 0x382000) || | ||
1416 | (reg >= 0x390000 && reg < 0x3a2000) || | ||
1417 | (reg >= 0x3a6000 && reg < 0x3b4000) || | ||
1418 | (reg >= 0x400000 && reg < 0x406000) || | ||
1419 | (reg >= 0x480000 && reg < 0x482000) || | ||
1420 | (reg >= 0x490000 && reg < 0x498000) || | ||
1421 | (reg >= 0x4a8000 && reg < 0x4aa000)) | ||
1422 | return true; | ||
1423 | else | ||
1424 | return false; | ||
1425 | } | ||
1426 | |||
1427 | static bool wm5110_is_adsp_memory(struct device *dev, unsigned int reg) | ||
1428 | { | ||
1429 | struct arizona *arizona = dev_get_drvdata(dev); | ||
1430 | |||
1431 | switch (arizona->rev) { | ||
1432 | case 0 ... 2: | ||
1433 | return wm5110_is_rev_b_adsp_memory(reg); | ||
1434 | default: | ||
1435 | return wm5110_is_rev_d_adsp_memory(reg); | ||
1436 | } | ||
1437 | } | ||
1438 | |||
1345 | static bool wm5110_readable_register(struct device *dev, unsigned int reg) | 1439 | static bool wm5110_readable_register(struct device *dev, unsigned int reg) |
1346 | { | 1440 | { |
1347 | switch (reg) { | 1441 | switch (reg) { |
@@ -1460,6 +1554,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) | |||
1460 | case ARIZONA_INPUT_ENABLES_STATUS: | 1554 | case ARIZONA_INPUT_ENABLES_STATUS: |
1461 | case ARIZONA_INPUT_RATE: | 1555 | case ARIZONA_INPUT_RATE: |
1462 | case ARIZONA_INPUT_VOLUME_RAMP: | 1556 | case ARIZONA_INPUT_VOLUME_RAMP: |
1557 | case ARIZONA_HPF_CONTROL: | ||
1463 | case ARIZONA_IN1L_CONTROL: | 1558 | case ARIZONA_IN1L_CONTROL: |
1464 | case ARIZONA_ADC_DIGITAL_VOLUME_1L: | 1559 | case ARIZONA_ADC_DIGITAL_VOLUME_1L: |
1465 | case ARIZONA_DMIC1L_CONTROL: | 1560 | case ARIZONA_DMIC1L_CONTROL: |
@@ -1481,6 +1576,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) | |||
1481 | case ARIZONA_IN4L_CONTROL: | 1576 | case ARIZONA_IN4L_CONTROL: |
1482 | case ARIZONA_ADC_DIGITAL_VOLUME_4L: | 1577 | case ARIZONA_ADC_DIGITAL_VOLUME_4L: |
1483 | case ARIZONA_DMIC4L_CONTROL: | 1578 | case ARIZONA_DMIC4L_CONTROL: |
1579 | case ARIZONA_IN4R_CONTROL: | ||
1484 | case ARIZONA_ADC_DIGITAL_VOLUME_4R: | 1580 | case ARIZONA_ADC_DIGITAL_VOLUME_4R: |
1485 | case ARIZONA_DMIC4R_CONTROL: | 1581 | case ARIZONA_DMIC4R_CONTROL: |
1486 | case ARIZONA_OUTPUT_ENABLES_1: | 1582 | case ARIZONA_OUTPUT_ENABLES_1: |
@@ -1536,6 +1632,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) | |||
1536 | case ARIZONA_DAC_DIGITAL_VOLUME_6R: | 1632 | case ARIZONA_DAC_DIGITAL_VOLUME_6R: |
1537 | case ARIZONA_DAC_VOLUME_LIMIT_6R: | 1633 | case ARIZONA_DAC_VOLUME_LIMIT_6R: |
1538 | case ARIZONA_NOISE_GATE_SELECT_6R: | 1634 | case ARIZONA_NOISE_GATE_SELECT_6R: |
1635 | case ARIZONA_DRE_ENABLE: | ||
1539 | case ARIZONA_DAC_AEC_CONTROL_1: | 1636 | case ARIZONA_DAC_AEC_CONTROL_1: |
1540 | case ARIZONA_NOISE_GATE_CONTROL: | 1637 | case ARIZONA_NOISE_GATE_CONTROL: |
1541 | case ARIZONA_PDM_SPK1_CTRL_1: | 1638 | case ARIZONA_PDM_SPK1_CTRL_1: |
@@ -1820,6 +1917,38 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) | |||
1820 | case ARIZONA_AIF2TX2MIX_INPUT_3_VOLUME: | 1917 | case ARIZONA_AIF2TX2MIX_INPUT_3_VOLUME: |
1821 | case ARIZONA_AIF2TX2MIX_INPUT_4_SOURCE: | 1918 | case ARIZONA_AIF2TX2MIX_INPUT_4_SOURCE: |
1822 | case ARIZONA_AIF2TX2MIX_INPUT_4_VOLUME: | 1919 | case ARIZONA_AIF2TX2MIX_INPUT_4_VOLUME: |
1920 | case ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE: | ||
1921 | case ARIZONA_AIF2TX3MIX_INPUT_1_VOLUME: | ||
1922 | case ARIZONA_AIF2TX3MIX_INPUT_2_SOURCE: | ||
1923 | case ARIZONA_AIF2TX3MIX_INPUT_2_VOLUME: | ||
1924 | case ARIZONA_AIF2TX3MIX_INPUT_3_SOURCE: | ||
1925 | case ARIZONA_AIF2TX3MIX_INPUT_3_VOLUME: | ||
1926 | case ARIZONA_AIF2TX3MIX_INPUT_4_SOURCE: | ||
1927 | case ARIZONA_AIF2TX3MIX_INPUT_4_VOLUME: | ||
1928 | case ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE: | ||
1929 | case ARIZONA_AIF2TX4MIX_INPUT_1_VOLUME: | ||
1930 | case ARIZONA_AIF2TX4MIX_INPUT_2_SOURCE: | ||
1931 | case ARIZONA_AIF2TX4MIX_INPUT_2_VOLUME: | ||
1932 | case ARIZONA_AIF2TX4MIX_INPUT_3_SOURCE: | ||
1933 | case ARIZONA_AIF2TX4MIX_INPUT_3_VOLUME: | ||
1934 | case ARIZONA_AIF2TX4MIX_INPUT_4_SOURCE: | ||
1935 | case ARIZONA_AIF2TX4MIX_INPUT_4_VOLUME: | ||
1936 | case ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE: | ||
1937 | case ARIZONA_AIF2TX5MIX_INPUT_1_VOLUME: | ||
1938 | case ARIZONA_AIF2TX5MIX_INPUT_2_SOURCE: | ||
1939 | case ARIZONA_AIF2TX5MIX_INPUT_2_VOLUME: | ||
1940 | case ARIZONA_AIF2TX5MIX_INPUT_3_SOURCE: | ||
1941 | case ARIZONA_AIF2TX5MIX_INPUT_3_VOLUME: | ||
1942 | case ARIZONA_AIF2TX5MIX_INPUT_4_SOURCE: | ||
1943 | case ARIZONA_AIF2TX5MIX_INPUT_4_VOLUME: | ||
1944 | case ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE: | ||
1945 | case ARIZONA_AIF2TX6MIX_INPUT_1_VOLUME: | ||
1946 | case ARIZONA_AIF2TX6MIX_INPUT_2_SOURCE: | ||
1947 | case ARIZONA_AIF2TX6MIX_INPUT_2_VOLUME: | ||
1948 | case ARIZONA_AIF2TX6MIX_INPUT_3_SOURCE: | ||
1949 | case ARIZONA_AIF2TX6MIX_INPUT_3_VOLUME: | ||
1950 | case ARIZONA_AIF2TX6MIX_INPUT_4_SOURCE: | ||
1951 | case ARIZONA_AIF2TX6MIX_INPUT_4_VOLUME: | ||
1823 | case ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE: | 1952 | case ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE: |
1824 | case ARIZONA_AIF3TX1MIX_INPUT_1_VOLUME: | 1953 | case ARIZONA_AIF3TX1MIX_INPUT_1_VOLUME: |
1825 | case ARIZONA_AIF3TX1MIX_INPUT_2_SOURCE: | 1954 | case ARIZONA_AIF3TX1MIX_INPUT_2_SOURCE: |
@@ -2331,7 +2460,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) | |||
2331 | case ARIZONA_DSP4_SCRATCH_3: | 2460 | case ARIZONA_DSP4_SCRATCH_3: |
2332 | return true; | 2461 | return true; |
2333 | default: | 2462 | default: |
2334 | return false; | 2463 | return wm5110_is_adsp_memory(dev, reg); |
2335 | } | 2464 | } |
2336 | } | 2465 | } |
2337 | 2466 | ||
@@ -2407,16 +2536,18 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg) | |||
2407 | case ARIZONA_DSP4_SCRATCH_3: | 2536 | case ARIZONA_DSP4_SCRATCH_3: |
2408 | return true; | 2537 | return true; |
2409 | default: | 2538 | default: |
2410 | return false; | 2539 | return wm5110_is_adsp_memory(dev, reg); |
2411 | } | 2540 | } |
2412 | } | 2541 | } |
2413 | 2542 | ||
2543 | #define WM5110_MAX_REGISTER 0x4a9fff | ||
2544 | |||
2414 | const struct regmap_config wm5110_spi_regmap = { | 2545 | const struct regmap_config wm5110_spi_regmap = { |
2415 | .reg_bits = 32, | 2546 | .reg_bits = 32, |
2416 | .pad_bits = 16, | 2547 | .pad_bits = 16, |
2417 | .val_bits = 16, | 2548 | .val_bits = 16, |
2418 | 2549 | ||
2419 | .max_register = ARIZONA_DSP1_STATUS_2, | 2550 | .max_register = WM5110_MAX_REGISTER, |
2420 | .readable_reg = wm5110_readable_register, | 2551 | .readable_reg = wm5110_readable_register, |
2421 | .volatile_reg = wm5110_volatile_register, | 2552 | .volatile_reg = wm5110_volatile_register, |
2422 | 2553 | ||
@@ -2430,7 +2561,7 @@ const struct regmap_config wm5110_i2c_regmap = { | |||
2430 | .reg_bits = 32, | 2561 | .reg_bits = 32, |
2431 | .val_bits = 16, | 2562 | .val_bits = 16, |
2432 | 2563 | ||
2433 | .max_register = ARIZONA_DSP1_STATUS_2, | 2564 | .max_register = WM5110_MAX_REGISTER, |
2434 | .readable_reg = wm5110_readable_register, | 2565 | .readable_reg = wm5110_readable_register, |
2435 | .volatile_reg = wm5110_volatile_register, | 2566 | .volatile_reg = wm5110_volatile_register, |
2436 | 2567 | ||
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c index 5f9a7ad9b964..8aeec0b4601a 100644 --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c | |||
@@ -625,6 +625,7 @@ static int ems_usb_start(struct ems_usb *dev) | |||
625 | usb_unanchor_urb(urb); | 625 | usb_unanchor_urb(urb); |
626 | usb_free_coherent(dev->udev, RX_BUFFER_SIZE, buf, | 626 | usb_free_coherent(dev->udev, RX_BUFFER_SIZE, buf, |
627 | urb->transfer_dma); | 627 | urb->transfer_dma); |
628 | usb_free_urb(urb); | ||
628 | break; | 629 | break; |
629 | } | 630 | } |
630 | 631 | ||
@@ -798,8 +799,8 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne | |||
798 | * allowed (MAX_TX_URBS). | 799 | * allowed (MAX_TX_URBS). |
799 | */ | 800 | */ |
800 | if (!context) { | 801 | if (!context) { |
801 | usb_unanchor_urb(urb); | ||
802 | usb_free_coherent(dev->udev, size, buf, urb->transfer_dma); | 802 | usb_free_coherent(dev->udev, size, buf, urb->transfer_dma); |
803 | usb_free_urb(urb); | ||
803 | 804 | ||
804 | netdev_warn(netdev, "couldn't find free context\n"); | 805 | netdev_warn(netdev, "couldn't find free context\n"); |
805 | 806 | ||
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c index 8ee9d1556e6e..263dd921edc4 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c | |||
@@ -927,6 +927,9 @@ static int pcan_usb_pro_init(struct peak_usb_device *dev) | |||
927 | /* set LED in default state (end of init phase) */ | 927 | /* set LED in default state (end of init phase) */ |
928 | pcan_usb_pro_set_led(dev, 0, 1); | 928 | pcan_usb_pro_set_led(dev, 0, 1); |
929 | 929 | ||
930 | kfree(bi); | ||
931 | kfree(fi); | ||
932 | |||
930 | return 0; | 933 | return 0; |
931 | 934 | ||
932 | err_out: | 935 | err_out: |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c index b1cb0ffb15c7..6055d397a29e 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | |||
@@ -447,8 +447,9 @@ irqreturn_t qlcnic_83xx_intr(int irq, void *data) | |||
447 | 447 | ||
448 | qlcnic_83xx_poll_process_aen(adapter); | 448 | qlcnic_83xx_poll_process_aen(adapter); |
449 | 449 | ||
450 | if (ahw->diag_test == QLCNIC_INTERRUPT_TEST) { | 450 | if (ahw->diag_test) { |
451 | ahw->diag_cnt++; | 451 | if (ahw->diag_test == QLCNIC_INTERRUPT_TEST) |
452 | ahw->diag_cnt++; | ||
452 | qlcnic_83xx_enable_legacy_msix_mbx_intr(adapter); | 453 | qlcnic_83xx_enable_legacy_msix_mbx_intr(adapter); |
453 | return IRQ_HANDLED; | 454 | return IRQ_HANDLED; |
454 | } | 455 | } |
@@ -1345,11 +1346,6 @@ static int qlcnic_83xx_diag_alloc_res(struct net_device *netdev, int test, | |||
1345 | } | 1346 | } |
1346 | 1347 | ||
1347 | if (adapter->ahw->diag_test == QLCNIC_LOOPBACK_TEST) { | 1348 | if (adapter->ahw->diag_test == QLCNIC_LOOPBACK_TEST) { |
1348 | /* disable and free mailbox interrupt */ | ||
1349 | if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) { | ||
1350 | qlcnic_83xx_enable_mbx_poll(adapter); | ||
1351 | qlcnic_83xx_free_mbx_intr(adapter); | ||
1352 | } | ||
1353 | adapter->ahw->loopback_state = 0; | 1349 | adapter->ahw->loopback_state = 0; |
1354 | adapter->ahw->hw_ops->setup_link_event(adapter, 1); | 1350 | adapter->ahw->hw_ops->setup_link_event(adapter, 1); |
1355 | } | 1351 | } |
@@ -1363,33 +1359,20 @@ static void qlcnic_83xx_diag_free_res(struct net_device *netdev, | |||
1363 | { | 1359 | { |
1364 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 1360 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
1365 | struct qlcnic_host_sds_ring *sds_ring; | 1361 | struct qlcnic_host_sds_ring *sds_ring; |
1366 | int ring, err; | 1362 | int ring; |
1367 | 1363 | ||
1368 | clear_bit(__QLCNIC_DEV_UP, &adapter->state); | 1364 | clear_bit(__QLCNIC_DEV_UP, &adapter->state); |
1369 | if (adapter->ahw->diag_test == QLCNIC_INTERRUPT_TEST) { | 1365 | if (adapter->ahw->diag_test == QLCNIC_INTERRUPT_TEST) { |
1370 | for (ring = 0; ring < adapter->drv_sds_rings; ring++) { | 1366 | for (ring = 0; ring < adapter->drv_sds_rings; ring++) { |
1371 | sds_ring = &adapter->recv_ctx->sds_rings[ring]; | 1367 | sds_ring = &adapter->recv_ctx->sds_rings[ring]; |
1372 | qlcnic_83xx_disable_intr(adapter, sds_ring); | 1368 | if (adapter->flags & QLCNIC_MSIX_ENABLED) |
1373 | if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) | 1369 | qlcnic_83xx_disable_intr(adapter, sds_ring); |
1374 | qlcnic_83xx_enable_mbx_poll(adapter); | ||
1375 | } | 1370 | } |
1376 | } | 1371 | } |
1377 | 1372 | ||
1378 | qlcnic_fw_destroy_ctx(adapter); | 1373 | qlcnic_fw_destroy_ctx(adapter); |
1379 | qlcnic_detach(adapter); | 1374 | qlcnic_detach(adapter); |
1380 | 1375 | ||
1381 | if (adapter->ahw->diag_test == QLCNIC_LOOPBACK_TEST) { | ||
1382 | if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) { | ||
1383 | err = qlcnic_83xx_setup_mbx_intr(adapter); | ||
1384 | qlcnic_83xx_disable_mbx_poll(adapter); | ||
1385 | if (err) { | ||
1386 | dev_err(&adapter->pdev->dev, | ||
1387 | "%s: failed to setup mbx interrupt\n", | ||
1388 | __func__); | ||
1389 | goto out; | ||
1390 | } | ||
1391 | } | ||
1392 | } | ||
1393 | adapter->ahw->diag_test = 0; | 1376 | adapter->ahw->diag_test = 0; |
1394 | adapter->drv_sds_rings = drv_sds_rings; | 1377 | adapter->drv_sds_rings = drv_sds_rings; |
1395 | 1378 | ||
@@ -1399,9 +1382,6 @@ static void qlcnic_83xx_diag_free_res(struct net_device *netdev, | |||
1399 | if (netif_running(netdev)) | 1382 | if (netif_running(netdev)) |
1400 | __qlcnic_up(adapter, netdev); | 1383 | __qlcnic_up(adapter, netdev); |
1401 | 1384 | ||
1402 | if (adapter->ahw->diag_test == QLCNIC_INTERRUPT_TEST && | ||
1403 | !(adapter->flags & QLCNIC_MSIX_ENABLED)) | ||
1404 | qlcnic_83xx_disable_mbx_poll(adapter); | ||
1405 | out: | 1385 | out: |
1406 | netif_device_attach(netdev); | 1386 | netif_device_attach(netdev); |
1407 | } | 1387 | } |
@@ -3754,6 +3734,19 @@ static void qlcnic_83xx_decode_mbx_rsp(struct qlcnic_adapter *adapter, | |||
3754 | return; | 3734 | return; |
3755 | } | 3735 | } |
3756 | 3736 | ||
3737 | static inline void qlcnic_dump_mailbox_registers(struct qlcnic_adapter *adapter) | ||
3738 | { | ||
3739 | struct qlcnic_hardware_context *ahw = adapter->ahw; | ||
3740 | u32 offset; | ||
3741 | |||
3742 | offset = QLCRDX(ahw, QLCNIC_DEF_INT_MASK); | ||
3743 | dev_info(&adapter->pdev->dev, "Mbx interrupt mask=0x%x, Mbx interrupt enable=0x%x, Host mbx control=0x%x, Fw mbx control=0x%x", | ||
3744 | readl(ahw->pci_base0 + offset), | ||
3745 | QLCRDX(ahw, QLCNIC_MBX_INTR_ENBL), | ||
3746 | QLCRDX(ahw, QLCNIC_HOST_MBX_CTRL), | ||
3747 | QLCRDX(ahw, QLCNIC_FW_MBX_CTRL)); | ||
3748 | } | ||
3749 | |||
3757 | static void qlcnic_83xx_mailbox_worker(struct work_struct *work) | 3750 | static void qlcnic_83xx_mailbox_worker(struct work_struct *work) |
3758 | { | 3751 | { |
3759 | struct qlcnic_mailbox *mbx = container_of(work, struct qlcnic_mailbox, | 3752 | struct qlcnic_mailbox *mbx = container_of(work, struct qlcnic_mailbox, |
@@ -3798,6 +3791,8 @@ static void qlcnic_83xx_mailbox_worker(struct work_struct *work) | |||
3798 | __func__, cmd->cmd_op, cmd->type, ahw->pci_func, | 3791 | __func__, cmd->cmd_op, cmd->type, ahw->pci_func, |
3799 | ahw->op_mode); | 3792 | ahw->op_mode); |
3800 | clear_bit(QLC_83XX_MBX_READY, &mbx->status); | 3793 | clear_bit(QLC_83XX_MBX_READY, &mbx->status); |
3794 | qlcnic_dump_mailbox_registers(adapter); | ||
3795 | qlcnic_83xx_get_mbx_data(adapter, cmd); | ||
3801 | qlcnic_dump_mbx(adapter, cmd); | 3796 | qlcnic_dump_mbx(adapter, cmd); |
3802 | qlcnic_83xx_idc_request_reset(adapter, | 3797 | qlcnic_83xx_idc_request_reset(adapter, |
3803 | QLCNIC_FORCE_FW_DUMP_KEY); | 3798 | QLCNIC_FORCE_FW_DUMP_KEY); |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h index 4cae6caa6bfa..a6a33508e401 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h | |||
@@ -662,4 +662,5 @@ pci_ers_result_t qlcnic_83xx_io_error_detected(struct pci_dev *, | |||
662 | pci_channel_state_t); | 662 | pci_channel_state_t); |
663 | pci_ers_result_t qlcnic_83xx_io_slot_reset(struct pci_dev *); | 663 | pci_ers_result_t qlcnic_83xx_io_slot_reset(struct pci_dev *); |
664 | void qlcnic_83xx_io_resume(struct pci_dev *); | 664 | void qlcnic_83xx_io_resume(struct pci_dev *); |
665 | void qlcnic_83xx_stop_hw(struct qlcnic_adapter *); | ||
665 | #endif | 666 | #endif |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c index 89208e5b25d6..918e18ddf038 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c | |||
@@ -740,6 +740,7 @@ static int qlcnic_83xx_idc_unknown_state(struct qlcnic_adapter *adapter) | |||
740 | adapter->ahw->idc.err_code = -EIO; | 740 | adapter->ahw->idc.err_code = -EIO; |
741 | dev_err(&adapter->pdev->dev, | 741 | dev_err(&adapter->pdev->dev, |
742 | "%s: Device in unknown state\n", __func__); | 742 | "%s: Device in unknown state\n", __func__); |
743 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | ||
743 | return 0; | 744 | return 0; |
744 | } | 745 | } |
745 | 746 | ||
@@ -818,7 +819,6 @@ static int qlcnic_83xx_idc_ready_state(struct qlcnic_adapter *adapter) | |||
818 | struct qlcnic_hardware_context *ahw = adapter->ahw; | 819 | struct qlcnic_hardware_context *ahw = adapter->ahw; |
819 | struct qlcnic_mailbox *mbx = ahw->mailbox; | 820 | struct qlcnic_mailbox *mbx = ahw->mailbox; |
820 | int ret = 0; | 821 | int ret = 0; |
821 | u32 owner; | ||
822 | u32 val; | 822 | u32 val; |
823 | 823 | ||
824 | /* Perform NIC configuration based ready state entry actions */ | 824 | /* Perform NIC configuration based ready state entry actions */ |
@@ -848,9 +848,9 @@ static int qlcnic_83xx_idc_ready_state(struct qlcnic_adapter *adapter) | |||
848 | set_bit(__QLCNIC_RESETTING, &adapter->state); | 848 | set_bit(__QLCNIC_RESETTING, &adapter->state); |
849 | qlcnic_83xx_idc_enter_need_reset_state(adapter, 1); | 849 | qlcnic_83xx_idc_enter_need_reset_state(adapter, 1); |
850 | } else { | 850 | } else { |
851 | owner = qlcnic_83xx_idc_find_reset_owner_id(adapter); | 851 | netdev_info(adapter->netdev, "%s: Auto firmware recovery is disabled\n", |
852 | if (ahw->pci_func == owner) | 852 | __func__); |
853 | qlcnic_dump_fw(adapter); | 853 | qlcnic_83xx_idc_enter_failed_state(adapter, 1); |
854 | } | 854 | } |
855 | return -EIO; | 855 | return -EIO; |
856 | } | 856 | } |
@@ -948,13 +948,26 @@ static int qlcnic_83xx_idc_need_quiesce_state(struct qlcnic_adapter *adapter) | |||
948 | return 0; | 948 | return 0; |
949 | } | 949 | } |
950 | 950 | ||
951 | static int qlcnic_83xx_idc_failed_state(struct qlcnic_adapter *adapter) | 951 | static void qlcnic_83xx_idc_failed_state(struct qlcnic_adapter *adapter) |
952 | { | 952 | { |
953 | dev_err(&adapter->pdev->dev, "%s: please restart!!\n", __func__); | 953 | struct qlcnic_hardware_context *ahw = adapter->ahw; |
954 | u32 val, owner; | ||
955 | |||
956 | val = QLCRDX(adapter->ahw, QLC_83XX_IDC_CTRL); | ||
957 | if (val & QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY) { | ||
958 | owner = qlcnic_83xx_idc_find_reset_owner_id(adapter); | ||
959 | if (ahw->pci_func == owner) { | ||
960 | qlcnic_83xx_stop_hw(adapter); | ||
961 | qlcnic_dump_fw(adapter); | ||
962 | } | ||
963 | } | ||
964 | |||
965 | netdev_warn(adapter->netdev, "%s: Reboot will be required to recover the adapter!!\n", | ||
966 | __func__); | ||
954 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | 967 | clear_bit(__QLCNIC_RESETTING, &adapter->state); |
955 | adapter->ahw->idc.err_code = -EIO; | 968 | ahw->idc.err_code = -EIO; |
956 | 969 | ||
957 | return 0; | 970 | return; |
958 | } | 971 | } |
959 | 972 | ||
960 | static int qlcnic_83xx_idc_quiesce_state(struct qlcnic_adapter *adapter) | 973 | static int qlcnic_83xx_idc_quiesce_state(struct qlcnic_adapter *adapter) |
@@ -1063,12 +1076,6 @@ void qlcnic_83xx_idc_poll_dev_state(struct work_struct *work) | |||
1063 | adapter->ahw->idc.prev_state = adapter->ahw->idc.curr_state; | 1076 | adapter->ahw->idc.prev_state = adapter->ahw->idc.curr_state; |
1064 | qlcnic_83xx_periodic_tasks(adapter); | 1077 | qlcnic_83xx_periodic_tasks(adapter); |
1065 | 1078 | ||
1066 | /* Do not reschedule if firmaware is in hanged state and auto | ||
1067 | * recovery is disabled | ||
1068 | */ | ||
1069 | if ((adapter->flags & QLCNIC_FW_HANG) && !qlcnic_auto_fw_reset) | ||
1070 | return; | ||
1071 | |||
1072 | /* Re-schedule the function */ | 1079 | /* Re-schedule the function */ |
1073 | if (test_bit(QLC_83XX_MODULE_LOADED, &adapter->ahw->idc.status)) | 1080 | if (test_bit(QLC_83XX_MODULE_LOADED, &adapter->ahw->idc.status)) |
1074 | qlcnic_schedule_work(adapter, qlcnic_83xx_idc_poll_dev_state, | 1081 | qlcnic_schedule_work(adapter, qlcnic_83xx_idc_poll_dev_state, |
@@ -1219,10 +1226,10 @@ void qlcnic_83xx_idc_request_reset(struct qlcnic_adapter *adapter, u32 key) | |||
1219 | } | 1226 | } |
1220 | 1227 | ||
1221 | val = QLCRDX(adapter->ahw, QLC_83XX_IDC_CTRL); | 1228 | val = QLCRDX(adapter->ahw, QLC_83XX_IDC_CTRL); |
1222 | if ((val & QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY) || | 1229 | if (val & QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY) { |
1223 | !qlcnic_auto_fw_reset) { | 1230 | netdev_info(adapter->netdev, "%s: Auto firmware recovery is disabled\n", |
1224 | dev_err(&adapter->pdev->dev, | 1231 | __func__); |
1225 | "%s:failed, device in non reset mode\n", __func__); | 1232 | qlcnic_83xx_idc_enter_failed_state(adapter, 0); |
1226 | qlcnic_83xx_unlock_driver(adapter); | 1233 | qlcnic_83xx_unlock_driver(adapter); |
1227 | return; | 1234 | return; |
1228 | } | 1235 | } |
@@ -1254,24 +1261,24 @@ static int qlcnic_83xx_copy_bootloader(struct qlcnic_adapter *adapter) | |||
1254 | if (size & 0xF) | 1261 | if (size & 0xF) |
1255 | size = (size + 16) & ~0xF; | 1262 | size = (size + 16) & ~0xF; |
1256 | 1263 | ||
1257 | p_cache = kzalloc(size, GFP_KERNEL); | 1264 | p_cache = vzalloc(size); |
1258 | if (p_cache == NULL) | 1265 | if (p_cache == NULL) |
1259 | return -ENOMEM; | 1266 | return -ENOMEM; |
1260 | 1267 | ||
1261 | ret = qlcnic_83xx_lockless_flash_read32(adapter, src, p_cache, | 1268 | ret = qlcnic_83xx_lockless_flash_read32(adapter, src, p_cache, |
1262 | size / sizeof(u32)); | 1269 | size / sizeof(u32)); |
1263 | if (ret) { | 1270 | if (ret) { |
1264 | kfree(p_cache); | 1271 | vfree(p_cache); |
1265 | return ret; | 1272 | return ret; |
1266 | } | 1273 | } |
1267 | /* 16 byte write to MS memory */ | 1274 | /* 16 byte write to MS memory */ |
1268 | ret = qlcnic_83xx_ms_mem_write128(adapter, dest, (u32 *)p_cache, | 1275 | ret = qlcnic_83xx_ms_mem_write128(adapter, dest, (u32 *)p_cache, |
1269 | size / 16); | 1276 | size / 16); |
1270 | if (ret) { | 1277 | if (ret) { |
1271 | kfree(p_cache); | 1278 | vfree(p_cache); |
1272 | return ret; | 1279 | return ret; |
1273 | } | 1280 | } |
1274 | kfree(p_cache); | 1281 | vfree(p_cache); |
1275 | 1282 | ||
1276 | return ret; | 1283 | return ret; |
1277 | } | 1284 | } |
@@ -1939,7 +1946,7 @@ static void qlcnic_83xx_exec_template_cmd(struct qlcnic_adapter *p_dev, | |||
1939 | p_dev->ahw->reset.seq_index = index; | 1946 | p_dev->ahw->reset.seq_index = index; |
1940 | } | 1947 | } |
1941 | 1948 | ||
1942 | static void qlcnic_83xx_stop_hw(struct qlcnic_adapter *p_dev) | 1949 | void qlcnic_83xx_stop_hw(struct qlcnic_adapter *p_dev) |
1943 | { | 1950 | { |
1944 | p_dev->ahw->reset.seq_index = 0; | 1951 | p_dev->ahw->reset.seq_index = 0; |
1945 | 1952 | ||
@@ -1994,6 +2001,14 @@ static int qlcnic_83xx_restart_hw(struct qlcnic_adapter *adapter) | |||
1994 | val = QLCRDX(adapter->ahw, QLC_83XX_IDC_CTRL); | 2001 | val = QLCRDX(adapter->ahw, QLC_83XX_IDC_CTRL); |
1995 | if (!(val & QLC_83XX_IDC_GRACEFULL_RESET)) | 2002 | if (!(val & QLC_83XX_IDC_GRACEFULL_RESET)) |
1996 | qlcnic_dump_fw(adapter); | 2003 | qlcnic_dump_fw(adapter); |
2004 | |||
2005 | if (val & QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY) { | ||
2006 | netdev_info(adapter->netdev, "%s: Auto firmware recovery is disabled\n", | ||
2007 | __func__); | ||
2008 | qlcnic_83xx_idc_enter_failed_state(adapter, 1); | ||
2009 | return err; | ||
2010 | } | ||
2011 | |||
1997 | qlcnic_83xx_init_hw(adapter); | 2012 | qlcnic_83xx_init_hw(adapter); |
1998 | 2013 | ||
1999 | if (qlcnic_83xx_copy_bootloader(adapter)) | 2014 | if (qlcnic_83xx_copy_bootloader(adapter)) |
@@ -2073,8 +2088,8 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter) | |||
2073 | ahw->nic_mode = QLCNIC_DEFAULT_MODE; | 2088 | ahw->nic_mode = QLCNIC_DEFAULT_MODE; |
2074 | adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver; | 2089 | adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver; |
2075 | ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry; | 2090 | ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry; |
2076 | adapter->max_sds_rings = ahw->max_rx_ques; | 2091 | adapter->max_sds_rings = QLCNIC_MAX_SDS_RINGS; |
2077 | adapter->max_tx_rings = ahw->max_tx_ques; | 2092 | adapter->max_tx_rings = QLCNIC_MAX_TX_RINGS; |
2078 | } else { | 2093 | } else { |
2079 | return -EIO; | 2094 | return -EIO; |
2080 | } | 2095 | } |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c index b36c02fafcfd..e3be2760665c 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | |||
@@ -667,30 +667,25 @@ qlcnic_set_ringparam(struct net_device *dev, | |||
667 | static int qlcnic_validate_ring_count(struct qlcnic_adapter *adapter, | 667 | static int qlcnic_validate_ring_count(struct qlcnic_adapter *adapter, |
668 | u8 rx_ring, u8 tx_ring) | 668 | u8 rx_ring, u8 tx_ring) |
669 | { | 669 | { |
670 | if (rx_ring == 0 || tx_ring == 0) | ||
671 | return -EINVAL; | ||
672 | |||
670 | if (rx_ring != 0) { | 673 | if (rx_ring != 0) { |
671 | if (rx_ring > adapter->max_sds_rings) { | 674 | if (rx_ring > adapter->max_sds_rings) { |
672 | netdev_err(adapter->netdev, "Invalid ring count, SDS ring count %d should not be greater than max %d driver sds rings.\n", | 675 | netdev_err(adapter->netdev, |
676 | "Invalid ring count, SDS ring count %d should not be greater than max %d driver sds rings.\n", | ||
673 | rx_ring, adapter->max_sds_rings); | 677 | rx_ring, adapter->max_sds_rings); |
674 | return -EINVAL; | 678 | return -EINVAL; |
675 | } | 679 | } |
676 | } | 680 | } |
677 | 681 | ||
678 | if (tx_ring != 0) { | 682 | if (tx_ring != 0) { |
679 | if (qlcnic_82xx_check(adapter) && | 683 | if (tx_ring > adapter->max_tx_rings) { |
680 | (tx_ring > adapter->max_tx_rings)) { | ||
681 | netdev_err(adapter->netdev, | 684 | netdev_err(adapter->netdev, |
682 | "Invalid ring count, Tx ring count %d should not be greater than max %d driver Tx rings.\n", | 685 | "Invalid ring count, Tx ring count %d should not be greater than max %d driver Tx rings.\n", |
683 | tx_ring, adapter->max_tx_rings); | 686 | tx_ring, adapter->max_tx_rings); |
684 | return -EINVAL; | 687 | return -EINVAL; |
685 | } | 688 | } |
686 | |||
687 | if (qlcnic_83xx_check(adapter) && | ||
688 | (tx_ring > QLCNIC_SINGLE_RING)) { | ||
689 | netdev_err(adapter->netdev, | ||
690 | "Invalid ring count, Tx ring count %d should not be greater than %d driver Tx rings.\n", | ||
691 | tx_ring, QLCNIC_SINGLE_RING); | ||
692 | return -EINVAL; | ||
693 | } | ||
694 | } | 689 | } |
695 | 690 | ||
696 | return 0; | 691 | return 0; |
@@ -948,6 +943,7 @@ static int qlcnic_irq_test(struct net_device *netdev) | |||
948 | struct qlcnic_hardware_context *ahw = adapter->ahw; | 943 | struct qlcnic_hardware_context *ahw = adapter->ahw; |
949 | struct qlcnic_cmd_args cmd; | 944 | struct qlcnic_cmd_args cmd; |
950 | int ret, drv_sds_rings = adapter->drv_sds_rings; | 945 | int ret, drv_sds_rings = adapter->drv_sds_rings; |
946 | int drv_tx_rings = adapter->drv_tx_rings; | ||
951 | 947 | ||
952 | if (qlcnic_83xx_check(adapter)) | 948 | if (qlcnic_83xx_check(adapter)) |
953 | return qlcnic_83xx_interrupt_test(netdev); | 949 | return qlcnic_83xx_interrupt_test(netdev); |
@@ -980,6 +976,7 @@ free_diag_res: | |||
980 | 976 | ||
981 | clear_diag_irq: | 977 | clear_diag_irq: |
982 | adapter->drv_sds_rings = drv_sds_rings; | 978 | adapter->drv_sds_rings = drv_sds_rings; |
979 | adapter->drv_tx_rings = drv_tx_rings; | ||
983 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | 980 | clear_bit(__QLCNIC_RESETTING, &adapter->state); |
984 | 981 | ||
985 | return ret; | 982 | return ret; |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c index 0149c9495347..eda6c691d897 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | |||
@@ -687,17 +687,11 @@ void qlcnic_advert_link_change(struct qlcnic_adapter *adapter, int linkup) | |||
687 | if (adapter->ahw->linkup && !linkup) { | 687 | if (adapter->ahw->linkup && !linkup) { |
688 | netdev_info(netdev, "NIC Link is down\n"); | 688 | netdev_info(netdev, "NIC Link is down\n"); |
689 | adapter->ahw->linkup = 0; | 689 | adapter->ahw->linkup = 0; |
690 | if (netif_running(netdev)) { | 690 | netif_carrier_off(netdev); |
691 | netif_carrier_off(netdev); | ||
692 | netif_tx_stop_all_queues(netdev); | ||
693 | } | ||
694 | } else if (!adapter->ahw->linkup && linkup) { | 691 | } else if (!adapter->ahw->linkup && linkup) { |
695 | netdev_info(netdev, "NIC Link is up\n"); | 692 | netdev_info(netdev, "NIC Link is up\n"); |
696 | adapter->ahw->linkup = 1; | 693 | adapter->ahw->linkup = 1; |
697 | if (netif_running(netdev)) { | 694 | netif_carrier_on(netdev); |
698 | netif_carrier_on(netdev); | ||
699 | netif_wake_queue(netdev); | ||
700 | } | ||
701 | } | 695 | } |
702 | } | 696 | } |
703 | 697 | ||
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 05c1eef8df13..2c8cac0c6a55 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | |||
@@ -1178,6 +1178,7 @@ qlcnic_initialize_nic(struct qlcnic_adapter *adapter) | |||
1178 | } else { | 1178 | } else { |
1179 | adapter->ahw->nic_mode = QLCNIC_DEFAULT_MODE; | 1179 | adapter->ahw->nic_mode = QLCNIC_DEFAULT_MODE; |
1180 | adapter->max_tx_rings = QLCNIC_MAX_HW_TX_RINGS; | 1180 | adapter->max_tx_rings = QLCNIC_MAX_HW_TX_RINGS; |
1181 | adapter->max_sds_rings = QLCNIC_MAX_SDS_RINGS; | ||
1181 | adapter->flags &= ~QLCNIC_ESWITCH_ENABLED; | 1182 | adapter->flags &= ~QLCNIC_ESWITCH_ENABLED; |
1182 | } | 1183 | } |
1183 | 1184 | ||
@@ -1940,7 +1941,6 @@ int qlcnic_diag_alloc_res(struct net_device *netdev, int test) | |||
1940 | qlcnic_detach(adapter); | 1941 | qlcnic_detach(adapter); |
1941 | 1942 | ||
1942 | adapter->drv_sds_rings = QLCNIC_SINGLE_RING; | 1943 | adapter->drv_sds_rings = QLCNIC_SINGLE_RING; |
1943 | adapter->drv_tx_rings = QLCNIC_SINGLE_RING; | ||
1944 | adapter->ahw->diag_test = test; | 1944 | adapter->ahw->diag_test = test; |
1945 | adapter->ahw->linkup = 0; | 1945 | adapter->ahw->linkup = 0; |
1946 | 1946 | ||
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 524f713f6017..f8135725bcf6 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c | |||
@@ -327,7 +327,6 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) | |||
327 | return -EINVAL; | 327 | return -EINVAL; |
328 | 328 | ||
329 | nvdev->start_remove = true; | 329 | nvdev->start_remove = true; |
330 | cancel_delayed_work_sync(&ndevctx->dwork); | ||
331 | cancel_work_sync(&ndevctx->work); | 330 | cancel_work_sync(&ndevctx->work); |
332 | netif_tx_disable(ndev); | 331 | netif_tx_disable(ndev); |
333 | rndis_filter_device_remove(hdev); | 332 | rndis_filter_device_remove(hdev); |
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index e884ee1fe7ed..27bbe58dcbe7 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c | |||
@@ -1197,6 +1197,9 @@ static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, | |||
1197 | 1197 | ||
1198 | err = -EPROTO; | 1198 | err = -EPROTO; |
1199 | 1199 | ||
1200 | if (fragment) | ||
1201 | goto out; | ||
1202 | |||
1200 | switch (ip_hdr(skb)->protocol) { | 1203 | switch (ip_hdr(skb)->protocol) { |
1201 | case IPPROTO_TCP: | 1204 | case IPPROTO_TCP: |
1202 | err = maybe_pull_tail(skb, | 1205 | err = maybe_pull_tail(skb, |
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index a344f3d52361..330ef2d06567 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig | |||
@@ -24,8 +24,8 @@ config PHY_EXYNOS_MIPI_VIDEO | |||
24 | config OMAP_USB2 | 24 | config OMAP_USB2 |
25 | tristate "OMAP USB2 PHY Driver" | 25 | tristate "OMAP USB2 PHY Driver" |
26 | depends on ARCH_OMAP2PLUS | 26 | depends on ARCH_OMAP2PLUS |
27 | depends on USB_PHY | ||
27 | select GENERIC_PHY | 28 | select GENERIC_PHY |
28 | select USB_PHY | ||
29 | select OMAP_CONTROL_USB | 29 | select OMAP_CONTROL_USB |
30 | help | 30 | help |
31 | Enable this to support the transceiver that is part of SOC. This | 31 | Enable this to support the transceiver that is part of SOC. This |
@@ -36,8 +36,8 @@ config OMAP_USB2 | |||
36 | config TWL4030_USB | 36 | config TWL4030_USB |
37 | tristate "TWL4030 USB Transceiver Driver" | 37 | tristate "TWL4030 USB Transceiver Driver" |
38 | depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS | 38 | depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS |
39 | depends on USB_PHY | ||
39 | select GENERIC_PHY | 40 | select GENERIC_PHY |
40 | select USB_PHY | ||
41 | help | 41 | help |
42 | Enable this to support the USB OTG transceiver on TWL4030 | 42 | Enable this to support the USB OTG transceiver on TWL4030 |
43 | family chips (including the TWL5030 and TPS659x0 devices). | 43 | family chips (including the TWL5030 and TPS659x0 devices). |
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 03cf8fb81554..58e0e9739028 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c | |||
@@ -437,23 +437,18 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, | |||
437 | int id; | 437 | int id; |
438 | struct phy *phy; | 438 | struct phy *phy; |
439 | 439 | ||
440 | if (!dev) { | 440 | if (WARN_ON(!dev)) |
441 | dev_WARN(dev, "no device provided for PHY\n"); | 441 | return ERR_PTR(-EINVAL); |
442 | ret = -EINVAL; | ||
443 | goto err0; | ||
444 | } | ||
445 | 442 | ||
446 | phy = kzalloc(sizeof(*phy), GFP_KERNEL); | 443 | phy = kzalloc(sizeof(*phy), GFP_KERNEL); |
447 | if (!phy) { | 444 | if (!phy) |
448 | ret = -ENOMEM; | 445 | return ERR_PTR(-ENOMEM); |
449 | goto err0; | ||
450 | } | ||
451 | 446 | ||
452 | id = ida_simple_get(&phy_ida, 0, 0, GFP_KERNEL); | 447 | id = ida_simple_get(&phy_ida, 0, 0, GFP_KERNEL); |
453 | if (id < 0) { | 448 | if (id < 0) { |
454 | dev_err(dev, "unable to get id\n"); | 449 | dev_err(dev, "unable to get id\n"); |
455 | ret = id; | 450 | ret = id; |
456 | goto err0; | 451 | goto free_phy; |
457 | } | 452 | } |
458 | 453 | ||
459 | device_initialize(&phy->dev); | 454 | device_initialize(&phy->dev); |
@@ -468,11 +463,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, | |||
468 | 463 | ||
469 | ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id); | 464 | ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id); |
470 | if (ret) | 465 | if (ret) |
471 | goto err1; | 466 | goto put_dev; |
472 | 467 | ||
473 | ret = device_add(&phy->dev); | 468 | ret = device_add(&phy->dev); |
474 | if (ret) | 469 | if (ret) |
475 | goto err1; | 470 | goto put_dev; |
476 | 471 | ||
477 | if (pm_runtime_enabled(dev)) { | 472 | if (pm_runtime_enabled(dev)) { |
478 | pm_runtime_enable(&phy->dev); | 473 | pm_runtime_enable(&phy->dev); |
@@ -481,12 +476,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, | |||
481 | 476 | ||
482 | return phy; | 477 | return phy; |
483 | 478 | ||
484 | err1: | 479 | put_dev: |
485 | ida_remove(&phy_ida, phy->id); | ||
486 | put_device(&phy->dev); | 480 | put_device(&phy->dev); |
481 | ida_remove(&phy_ida, phy->id); | ||
482 | free_phy: | ||
487 | kfree(phy); | 483 | kfree(phy); |
488 | |||
489 | err0: | ||
490 | return ERR_PTR(ret); | 484 | return ERR_PTR(ret); |
491 | } | 485 | } |
492 | EXPORT_SYMBOL_GPL(phy_create); | 486 | EXPORT_SYMBOL_GPL(phy_create); |
diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c index 2832576d8b12..114f5ef4b73a 100644 --- a/drivers/pinctrl/pinctrl-baytrail.c +++ b/drivers/pinctrl/pinctrl-baytrail.c | |||
@@ -512,6 +512,7 @@ static const struct dev_pm_ops byt_gpio_pm_ops = { | |||
512 | 512 | ||
513 | static const struct acpi_device_id byt_gpio_acpi_match[] = { | 513 | static const struct acpi_device_id byt_gpio_acpi_match[] = { |
514 | { "INT33B2", 0 }, | 514 | { "INT33B2", 0 }, |
515 | { "INT33FC", 0 }, | ||
515 | { } | 516 | { } |
516 | }; | 517 | }; |
517 | MODULE_DEVICE_TABLE(acpi, byt_gpio_acpi_match); | 518 | MODULE_DEVICE_TABLE(acpi, byt_gpio_acpi_match); |
diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h index 11bd0d970a52..e2142956a8e5 100644 --- a/drivers/pinctrl/sh-pfc/sh_pfc.h +++ b/drivers/pinctrl/sh-pfc/sh_pfc.h | |||
@@ -254,7 +254,7 @@ struct sh_pfc_soc_info { | |||
254 | #define PINMUX_GPIO(_pin) \ | 254 | #define PINMUX_GPIO(_pin) \ |
255 | [GPIO_##_pin] = { \ | 255 | [GPIO_##_pin] = { \ |
256 | .pin = (u16)-1, \ | 256 | .pin = (u16)-1, \ |
257 | .name = __stringify(name), \ | 257 | .name = __stringify(GPIO_##_pin), \ |
258 | .enum_id = _pin##_DATA, \ | 258 | .enum_id = _pin##_DATA, \ |
259 | } | 259 | } |
260 | 260 | ||
diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c index 2a786c504460..3c6768378a94 100644 --- a/drivers/powercap/intel_rapl.c +++ b/drivers/powercap/intel_rapl.c | |||
@@ -833,6 +833,11 @@ static int rapl_write_data_raw(struct rapl_domain *rd, | |||
833 | return 0; | 833 | return 0; |
834 | } | 834 | } |
835 | 835 | ||
836 | static const struct x86_cpu_id energy_unit_quirk_ids[] = { | ||
837 | { X86_VENDOR_INTEL, 6, 0x37},/* VLV */ | ||
838 | {} | ||
839 | }; | ||
840 | |||
836 | static int rapl_check_unit(struct rapl_package *rp, int cpu) | 841 | static int rapl_check_unit(struct rapl_package *rp, int cpu) |
837 | { | 842 | { |
838 | u64 msr_val; | 843 | u64 msr_val; |
@@ -853,8 +858,11 @@ static int rapl_check_unit(struct rapl_package *rp, int cpu) | |||
853 | * time unit: 1/time_unit_divisor Seconds | 858 | * time unit: 1/time_unit_divisor Seconds |
854 | */ | 859 | */ |
855 | value = (msr_val & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET; | 860 | value = (msr_val & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET; |
856 | rp->energy_unit_divisor = 1 << value; | 861 | /* some CPUs have different way to calculate energy unit */ |
857 | 862 | if (x86_match_cpu(energy_unit_quirk_ids)) | |
863 | rp->energy_unit_divisor = 1000000 / (1 << value); | ||
864 | else | ||
865 | rp->energy_unit_divisor = 1 << value; | ||
858 | 866 | ||
859 | value = (msr_val & POWER_UNIT_MASK) >> POWER_UNIT_OFFSET; | 867 | value = (msr_val & POWER_UNIT_MASK) >> POWER_UNIT_OFFSET; |
860 | rp->power_unit_divisor = 1 << value; | 868 | rp->power_unit_divisor = 1 << value; |
@@ -941,6 +949,7 @@ static void package_power_limit_irq_restore(int package_id) | |||
941 | static const struct x86_cpu_id rapl_ids[] = { | 949 | static const struct x86_cpu_id rapl_ids[] = { |
942 | { X86_VENDOR_INTEL, 6, 0x2a},/* SNB */ | 950 | { X86_VENDOR_INTEL, 6, 0x2a},/* SNB */ |
943 | { X86_VENDOR_INTEL, 6, 0x2d},/* SNB EP */ | 951 | { X86_VENDOR_INTEL, 6, 0x2d},/* SNB EP */ |
952 | { X86_VENDOR_INTEL, 6, 0x37},/* VLV */ | ||
944 | { X86_VENDOR_INTEL, 6, 0x3a},/* IVB */ | 953 | { X86_VENDOR_INTEL, 6, 0x3a},/* IVB */ |
945 | { X86_VENDOR_INTEL, 6, 0x45},/* HSW */ | 954 | { X86_VENDOR_INTEL, 6, 0x45},/* HSW */ |
946 | /* TODO: Add more CPU IDs after testing */ | 955 | /* TODO: Add more CPU IDs after testing */ |
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 333677d68d0e..9e61922d8230 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
@@ -438,7 +438,7 @@ common_reg: | |||
438 | platform_set_drvdata(pdev, s2mps11); | 438 | platform_set_drvdata(pdev, s2mps11); |
439 | 439 | ||
440 | config.dev = &pdev->dev; | 440 | config.dev = &pdev->dev; |
441 | config.regmap = iodev->regmap; | 441 | config.regmap = iodev->regmap_pmic; |
442 | config.driver_data = s2mps11; | 442 | config.driver_data = s2mps11; |
443 | for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) { | 443 | for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) { |
444 | if (!reg_np) { | 444 | if (!reg_np) { |
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 596480022b0a..38a1257e76e1 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c | |||
@@ -471,7 +471,7 @@ static void qlt_schedule_sess_for_deletion(struct qla_tgt_sess *sess, | |||
471 | schedule_delayed_work(&tgt->sess_del_work, 0); | 471 | schedule_delayed_work(&tgt->sess_del_work, 0); |
472 | else | 472 | else |
473 | schedule_delayed_work(&tgt->sess_del_work, | 473 | schedule_delayed_work(&tgt->sess_del_work, |
474 | jiffies - sess->expires); | 474 | sess->expires - jiffies); |
475 | } | 475 | } |
476 | 476 | ||
477 | /* ha->hardware_lock supposed to be held on entry */ | 477 | /* ha->hardware_lock supposed to be held on entry */ |
@@ -550,13 +550,14 @@ static void qlt_del_sess_work_fn(struct delayed_work *work) | |||
550 | struct scsi_qla_host *vha = tgt->vha; | 550 | struct scsi_qla_host *vha = tgt->vha; |
551 | struct qla_hw_data *ha = vha->hw; | 551 | struct qla_hw_data *ha = vha->hw; |
552 | struct qla_tgt_sess *sess; | 552 | struct qla_tgt_sess *sess; |
553 | unsigned long flags; | 553 | unsigned long flags, elapsed; |
554 | 554 | ||
555 | spin_lock_irqsave(&ha->hardware_lock, flags); | 555 | spin_lock_irqsave(&ha->hardware_lock, flags); |
556 | while (!list_empty(&tgt->del_sess_list)) { | 556 | while (!list_empty(&tgt->del_sess_list)) { |
557 | sess = list_entry(tgt->del_sess_list.next, typeof(*sess), | 557 | sess = list_entry(tgt->del_sess_list.next, typeof(*sess), |
558 | del_list_entry); | 558 | del_list_entry); |
559 | if (time_after_eq(jiffies, sess->expires)) { | 559 | elapsed = jiffies; |
560 | if (time_after_eq(elapsed, sess->expires)) { | ||
560 | qlt_undelete_sess(sess); | 561 | qlt_undelete_sess(sess); |
561 | 562 | ||
562 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf004, | 563 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf004, |
@@ -566,7 +567,7 @@ static void qlt_del_sess_work_fn(struct delayed_work *work) | |||
566 | ha->tgt.tgt_ops->put_sess(sess); | 567 | ha->tgt.tgt_ops->put_sess(sess); |
567 | } else { | 568 | } else { |
568 | schedule_delayed_work(&tgt->sess_del_work, | 569 | schedule_delayed_work(&tgt->sess_del_work, |
569 | jiffies - sess->expires); | 570 | sess->expires - elapsed); |
570 | break; | 571 | break; |
571 | } | 572 | } |
572 | } | 573 | } |
@@ -4290,6 +4291,7 @@ int qlt_lport_register(struct qla_tgt_func_tmpl *qla_tgt_ops, u64 wwpn, | |||
4290 | if (rc != 0) { | 4291 | if (rc != 0) { |
4291 | ha->tgt.tgt_ops = NULL; | 4292 | ha->tgt.tgt_ops = NULL; |
4292 | ha->tgt.target_lport_ptr = NULL; | 4293 | ha->tgt.target_lport_ptr = NULL; |
4294 | scsi_host_put(host); | ||
4293 | } | 4295 | } |
4294 | mutex_unlock(&qla_tgt_mutex); | 4296 | mutex_unlock(&qla_tgt_mutex); |
4295 | return rc; | 4297 | return rc; |
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index eb1f1ef5fa2e..e2dd2fbec5ee 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -395,7 +395,7 @@ config SPI_S3C24XX_FIQ | |||
395 | config SPI_S3C64XX | 395 | config SPI_S3C64XX |
396 | tristate "Samsung S3C64XX series type SPI" | 396 | tristate "Samsung S3C64XX series type SPI" |
397 | depends on PLAT_SAMSUNG | 397 | depends on PLAT_SAMSUNG |
398 | select S3C64XX_DMA if ARCH_S3C64XX | 398 | select S3C64XX_PL080 if ARCH_S3C64XX |
399 | help | 399 | help |
400 | SPI driver for Samsung S3C64XX and newer SoCs. | 400 | SPI driver for Samsung S3C64XX and newer SoCs. |
401 | 401 | ||
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 8f02bf66e20b..4964d2a2fc7d 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c | |||
@@ -446,7 +446,7 @@ int comedi_load_firmware(struct comedi_device *dev, | |||
446 | release_firmware(fw); | 446 | release_firmware(fw); |
447 | } | 447 | } |
448 | 448 | ||
449 | return ret; | 449 | return ret < 0 ? ret : 0; |
450 | } | 450 | } |
451 | EXPORT_SYMBOL_GPL(comedi_load_firmware); | 451 | EXPORT_SYMBOL_GPL(comedi_load_firmware); |
452 | 452 | ||
diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c index 432e3f9c3301..c55f234b29e6 100644 --- a/drivers/staging/comedi/drivers/8255_pci.c +++ b/drivers/staging/comedi/drivers/8255_pci.c | |||
@@ -63,7 +63,8 @@ enum pci_8255_boardid { | |||
63 | BOARD_ADLINK_PCI7296, | 63 | BOARD_ADLINK_PCI7296, |
64 | BOARD_CB_PCIDIO24, | 64 | BOARD_CB_PCIDIO24, |
65 | BOARD_CB_PCIDIO24H, | 65 | BOARD_CB_PCIDIO24H, |
66 | BOARD_CB_PCIDIO48H, | 66 | BOARD_CB_PCIDIO48H_OLD, |
67 | BOARD_CB_PCIDIO48H_NEW, | ||
67 | BOARD_CB_PCIDIO96H, | 68 | BOARD_CB_PCIDIO96H, |
68 | BOARD_NI_PCIDIO96, | 69 | BOARD_NI_PCIDIO96, |
69 | BOARD_NI_PCIDIO96B, | 70 | BOARD_NI_PCIDIO96B, |
@@ -106,11 +107,16 @@ static const struct pci_8255_boardinfo pci_8255_boards[] = { | |||
106 | .dio_badr = 2, | 107 | .dio_badr = 2, |
107 | .n_8255 = 1, | 108 | .n_8255 = 1, |
108 | }, | 109 | }, |
109 | [BOARD_CB_PCIDIO48H] = { | 110 | [BOARD_CB_PCIDIO48H_OLD] = { |
110 | .name = "cb_pci-dio48h", | 111 | .name = "cb_pci-dio48h", |
111 | .dio_badr = 1, | 112 | .dio_badr = 1, |
112 | .n_8255 = 2, | 113 | .n_8255 = 2, |
113 | }, | 114 | }, |
115 | [BOARD_CB_PCIDIO48H_NEW] = { | ||
116 | .name = "cb_pci-dio48h", | ||
117 | .dio_badr = 2, | ||
118 | .n_8255 = 2, | ||
119 | }, | ||
114 | [BOARD_CB_PCIDIO96H] = { | 120 | [BOARD_CB_PCIDIO96H] = { |
115 | .name = "cb_pci-dio96h", | 121 | .name = "cb_pci-dio96h", |
116 | .dio_badr = 2, | 122 | .dio_badr = 2, |
@@ -263,7 +269,10 @@ static DEFINE_PCI_DEVICE_TABLE(pci_8255_pci_table) = { | |||
263 | { PCI_VDEVICE(ADLINK, 0x7296), BOARD_ADLINK_PCI7296 }, | 269 | { PCI_VDEVICE(ADLINK, 0x7296), BOARD_ADLINK_PCI7296 }, |
264 | { PCI_VDEVICE(CB, 0x0028), BOARD_CB_PCIDIO24 }, | 270 | { PCI_VDEVICE(CB, 0x0028), BOARD_CB_PCIDIO24 }, |
265 | { PCI_VDEVICE(CB, 0x0014), BOARD_CB_PCIDIO24H }, | 271 | { PCI_VDEVICE(CB, 0x0014), BOARD_CB_PCIDIO24H }, |
266 | { PCI_VDEVICE(CB, 0x000b), BOARD_CB_PCIDIO48H }, | 272 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_CB, 0x000b, 0x0000, 0x0000), |
273 | .driver_data = BOARD_CB_PCIDIO48H_OLD }, | ||
274 | { PCI_DEVICE_SUB(PCI_VENDOR_ID_CB, 0x000b, PCI_VENDOR_ID_CB, 0x000b), | ||
275 | .driver_data = BOARD_CB_PCIDIO48H_NEW }, | ||
267 | { PCI_VDEVICE(CB, 0x0017), BOARD_CB_PCIDIO96H }, | 276 | { PCI_VDEVICE(CB, 0x0017), BOARD_CB_PCIDIO96H }, |
268 | { PCI_VDEVICE(NI, 0x0160), BOARD_NI_PCIDIO96 }, | 277 | { PCI_VDEVICE(NI, 0x0160), BOARD_NI_PCIDIO96 }, |
269 | { PCI_VDEVICE(NI, 0x1630), BOARD_NI_PCIDIO96B }, | 278 | { PCI_VDEVICE(NI, 0x1630), BOARD_NI_PCIDIO96B }, |
diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 99421f90d189..0485d7f39867 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c | |||
@@ -451,7 +451,12 @@ done: | |||
451 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ | 451 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ |
452 | BIT(IIO_CHAN_INFO_SAMP_FREQ), \ | 452 | BIT(IIO_CHAN_INFO_SAMP_FREQ), \ |
453 | .scan_index = idx, \ | 453 | .scan_index = idx, \ |
454 | .scan_type = IIO_ST('s', 16, 16, IIO_BE), \ | 454 | .scan_type = { \ |
455 | .sign = 's', \ | ||
456 | .realbits = 16, \ | ||
457 | .storagebits = 16, \ | ||
458 | .endianness = IIO_BE, \ | ||
459 | }, \ | ||
455 | } | 460 | } |
456 | 461 | ||
457 | static const struct iio_chan_spec hmc5843_channels[] = { | 462 | static const struct iio_chan_spec hmc5843_channels[] = { |
diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 6bd015ac9d68..96e4eee344ef 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c | |||
@@ -88,8 +88,9 @@ static int imx_drm_driver_unload(struct drm_device *drm) | |||
88 | 88 | ||
89 | imx_drm_device_put(); | 89 | imx_drm_device_put(); |
90 | 90 | ||
91 | drm_mode_config_cleanup(imxdrm->drm); | 91 | drm_vblank_cleanup(imxdrm->drm); |
92 | drm_kms_helper_poll_fini(imxdrm->drm); | 92 | drm_kms_helper_poll_fini(imxdrm->drm); |
93 | drm_mode_config_cleanup(imxdrm->drm); | ||
93 | 94 | ||
94 | return 0; | 95 | return 0; |
95 | } | 96 | } |
@@ -199,8 +200,8 @@ static void imx_drm_driver_preclose(struct drm_device *drm, | |||
199 | if (!file->is_master) | 200 | if (!file->is_master) |
200 | return; | 201 | return; |
201 | 202 | ||
202 | for (i = 0; i < 4; i++) | 203 | for (i = 0; i < MAX_CRTC; i++) |
203 | imx_drm_disable_vblank(drm , i); | 204 | imx_drm_disable_vblank(drm, i); |
204 | } | 205 | } |
205 | 206 | ||
206 | static const struct file_operations imx_drm_driver_fops = { | 207 | static const struct file_operations imx_drm_driver_fops = { |
@@ -376,8 +377,6 @@ static int imx_drm_crtc_register(struct imx_drm_crtc *imx_drm_crtc) | |||
376 | struct imx_drm_device *imxdrm = __imx_drm_device(); | 377 | struct imx_drm_device *imxdrm = __imx_drm_device(); |
377 | int ret; | 378 | int ret; |
378 | 379 | ||
379 | drm_crtc_init(imxdrm->drm, imx_drm_crtc->crtc, | ||
380 | imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs); | ||
381 | ret = drm_mode_crtc_set_gamma_size(imx_drm_crtc->crtc, 256); | 380 | ret = drm_mode_crtc_set_gamma_size(imx_drm_crtc->crtc, 256); |
382 | if (ret) | 381 | if (ret) |
383 | return ret; | 382 | return ret; |
@@ -385,6 +384,9 @@ static int imx_drm_crtc_register(struct imx_drm_crtc *imx_drm_crtc) | |||
385 | drm_crtc_helper_add(imx_drm_crtc->crtc, | 384 | drm_crtc_helper_add(imx_drm_crtc->crtc, |
386 | imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs); | 385 | imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs); |
387 | 386 | ||
387 | drm_crtc_init(imxdrm->drm, imx_drm_crtc->crtc, | ||
388 | imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs); | ||
389 | |||
388 | drm_mode_group_reinit(imxdrm->drm); | 390 | drm_mode_group_reinit(imxdrm->drm); |
389 | 391 | ||
390 | return 0; | 392 | return 0; |
@@ -428,11 +430,11 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) | |||
428 | ret = drm_mode_group_init_legacy_group(imxdrm->drm, | 430 | ret = drm_mode_group_init_legacy_group(imxdrm->drm, |
429 | &imxdrm->drm->primary->mode_group); | 431 | &imxdrm->drm->primary->mode_group); |
430 | if (ret) | 432 | if (ret) |
431 | goto err_init; | 433 | goto err_kms; |
432 | 434 | ||
433 | ret = drm_vblank_init(imxdrm->drm, MAX_CRTC); | 435 | ret = drm_vblank_init(imxdrm->drm, MAX_CRTC); |
434 | if (ret) | 436 | if (ret) |
435 | goto err_init; | 437 | goto err_kms; |
436 | 438 | ||
437 | /* | 439 | /* |
438 | * with vblank_disable_allowed = true, vblank interrupt will be disabled | 440 | * with vblank_disable_allowed = true, vblank interrupt will be disabled |
@@ -441,12 +443,19 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) | |||
441 | */ | 443 | */ |
442 | imxdrm->drm->vblank_disable_allowed = true; | 444 | imxdrm->drm->vblank_disable_allowed = true; |
443 | 445 | ||
444 | if (!imx_drm_device_get()) | 446 | if (!imx_drm_device_get()) { |
445 | ret = -EINVAL; | 447 | ret = -EINVAL; |
448 | goto err_vblank; | ||
449 | } | ||
446 | 450 | ||
447 | ret = 0; | 451 | mutex_unlock(&imxdrm->mutex); |
452 | return 0; | ||
448 | 453 | ||
449 | err_init: | 454 | err_vblank: |
455 | drm_vblank_cleanup(drm); | ||
456 | err_kms: | ||
457 | drm_kms_helper_poll_fini(drm); | ||
458 | drm_mode_config_cleanup(drm); | ||
450 | mutex_unlock(&imxdrm->mutex); | 459 | mutex_unlock(&imxdrm->mutex); |
451 | 460 | ||
452 | return ret; | 461 | return ret; |
@@ -492,6 +501,15 @@ int imx_drm_add_crtc(struct drm_crtc *crtc, | |||
492 | 501 | ||
493 | mutex_lock(&imxdrm->mutex); | 502 | mutex_lock(&imxdrm->mutex); |
494 | 503 | ||
504 | /* | ||
505 | * The vblank arrays are dimensioned by MAX_CRTC - we can't | ||
506 | * pass IDs greater than this to those functions. | ||
507 | */ | ||
508 | if (imxdrm->pipes >= MAX_CRTC) { | ||
509 | ret = -EINVAL; | ||
510 | goto err_busy; | ||
511 | } | ||
512 | |||
495 | if (imxdrm->drm->open_count) { | 513 | if (imxdrm->drm->open_count) { |
496 | ret = -EBUSY; | 514 | ret = -EBUSY; |
497 | goto err_busy; | 515 | goto err_busy; |
@@ -528,6 +546,7 @@ int imx_drm_add_crtc(struct drm_crtc *crtc, | |||
528 | return 0; | 546 | return 0; |
529 | 547 | ||
530 | err_register: | 548 | err_register: |
549 | list_del(&imx_drm_crtc->list); | ||
531 | kfree(imx_drm_crtc); | 550 | kfree(imx_drm_crtc); |
532 | err_alloc: | 551 | err_alloc: |
533 | err_busy: | 552 | err_busy: |
diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index 680f4c8fa081..2c44fef8d58b 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c | |||
@@ -114,7 +114,6 @@ struct imx_tve { | |||
114 | struct drm_encoder encoder; | 114 | struct drm_encoder encoder; |
115 | struct imx_drm_encoder *imx_drm_encoder; | 115 | struct imx_drm_encoder *imx_drm_encoder; |
116 | struct device *dev; | 116 | struct device *dev; |
117 | spinlock_t enable_lock; /* serializes tve_enable/disable */ | ||
118 | spinlock_t lock; /* register lock */ | 117 | spinlock_t lock; /* register lock */ |
119 | bool enabled; | 118 | bool enabled; |
120 | int mode; | 119 | int mode; |
@@ -146,10 +145,8 @@ __releases(&tve->lock) | |||
146 | 145 | ||
147 | static void tve_enable(struct imx_tve *tve) | 146 | static void tve_enable(struct imx_tve *tve) |
148 | { | 147 | { |
149 | unsigned long flags; | ||
150 | int ret; | 148 | int ret; |
151 | 149 | ||
152 | spin_lock_irqsave(&tve->enable_lock, flags); | ||
153 | if (!tve->enabled) { | 150 | if (!tve->enabled) { |
154 | tve->enabled = true; | 151 | tve->enabled = true; |
155 | clk_prepare_enable(tve->clk); | 152 | clk_prepare_enable(tve->clk); |
@@ -169,23 +166,18 @@ static void tve_enable(struct imx_tve *tve) | |||
169 | TVE_CD_SM_IEN | | 166 | TVE_CD_SM_IEN | |
170 | TVE_CD_LM_IEN | | 167 | TVE_CD_LM_IEN | |
171 | TVE_CD_MON_END_IEN); | 168 | TVE_CD_MON_END_IEN); |
172 | |||
173 | spin_unlock_irqrestore(&tve->enable_lock, flags); | ||
174 | } | 169 | } |
175 | 170 | ||
176 | static void tve_disable(struct imx_tve *tve) | 171 | static void tve_disable(struct imx_tve *tve) |
177 | { | 172 | { |
178 | unsigned long flags; | ||
179 | int ret; | 173 | int ret; |
180 | 174 | ||
181 | spin_lock_irqsave(&tve->enable_lock, flags); | ||
182 | if (tve->enabled) { | 175 | if (tve->enabled) { |
183 | tve->enabled = false; | 176 | tve->enabled = false; |
184 | ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, | 177 | ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, |
185 | TVE_IPU_CLK_EN | TVE_EN, 0); | 178 | TVE_IPU_CLK_EN | TVE_EN, 0); |
186 | clk_disable_unprepare(tve->clk); | 179 | clk_disable_unprepare(tve->clk); |
187 | } | 180 | } |
188 | spin_unlock_irqrestore(&tve->enable_lock, flags); | ||
189 | } | 181 | } |
190 | 182 | ||
191 | static int tve_setup_tvout(struct imx_tve *tve) | 183 | static int tve_setup_tvout(struct imx_tve *tve) |
@@ -601,7 +593,6 @@ static int imx_tve_probe(struct platform_device *pdev) | |||
601 | 593 | ||
602 | tve->dev = &pdev->dev; | 594 | tve->dev = &pdev->dev; |
603 | spin_lock_init(&tve->lock); | 595 | spin_lock_init(&tve->lock); |
604 | spin_lock_init(&tve->enable_lock); | ||
605 | 596 | ||
606 | ddc_node = of_parse_phandle(np, "ddc", 0); | 597 | ddc_node = of_parse_phandle(np, "ddc", 0); |
607 | if (ddc_node) { | 598 | if (ddc_node) { |
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c index 7a22ce619ed2..97ca6924dbb3 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c | |||
@@ -996,35 +996,35 @@ static const struct ipu_platform_reg client_reg[] = { | |||
996 | }, | 996 | }, |
997 | }; | 997 | }; |
998 | 998 | ||
999 | static DEFINE_MUTEX(ipu_client_id_mutex); | ||
999 | static int ipu_client_id; | 1000 | static int ipu_client_id; |
1000 | 1001 | ||
1001 | static int ipu_add_subdevice_pdata(struct device *dev, | ||
1002 | const struct ipu_platform_reg *reg) | ||
1003 | { | ||
1004 | struct platform_device *pdev; | ||
1005 | |||
1006 | pdev = platform_device_register_data(dev, reg->name, ipu_client_id++, | ||
1007 | ®->pdata, sizeof(struct ipu_platform_reg)); | ||
1008 | |||
1009 | return PTR_ERR_OR_ZERO(pdev); | ||
1010 | } | ||
1011 | |||
1012 | static int ipu_add_client_devices(struct ipu_soc *ipu) | 1002 | static int ipu_add_client_devices(struct ipu_soc *ipu) |
1013 | { | 1003 | { |
1014 | int ret; | 1004 | struct device *dev = ipu->dev; |
1015 | int i; | 1005 | unsigned i; |
1006 | int id, ret; | ||
1007 | |||
1008 | mutex_lock(&ipu_client_id_mutex); | ||
1009 | id = ipu_client_id; | ||
1010 | ipu_client_id += ARRAY_SIZE(client_reg); | ||
1011 | mutex_unlock(&ipu_client_id_mutex); | ||
1016 | 1012 | ||
1017 | for (i = 0; i < ARRAY_SIZE(client_reg); i++) { | 1013 | for (i = 0; i < ARRAY_SIZE(client_reg); i++) { |
1018 | const struct ipu_platform_reg *reg = &client_reg[i]; | 1014 | const struct ipu_platform_reg *reg = &client_reg[i]; |
1019 | ret = ipu_add_subdevice_pdata(ipu->dev, reg); | 1015 | struct platform_device *pdev; |
1020 | if (ret) | 1016 | |
1017 | pdev = platform_device_register_data(dev, reg->name, | ||
1018 | id++, ®->pdata, sizeof(reg->pdata)); | ||
1019 | |||
1020 | if (IS_ERR(pdev)) | ||
1021 | goto err_register; | 1021 | goto err_register; |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | return 0; | 1024 | return 0; |
1025 | 1025 | ||
1026 | err_register: | 1026 | err_register: |
1027 | platform_device_unregister_children(to_platform_device(ipu->dev)); | 1027 | platform_device_unregister_children(to_platform_device(dev)); |
1028 | 1028 | ||
1029 | return ret; | 1029 | return ret; |
1030 | } | 1030 | } |
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index d70e9119e906..00867190413c 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -465,6 +465,7 @@ int iscsit_del_np(struct iscsi_np *np) | |||
465 | */ | 465 | */ |
466 | send_sig(SIGINT, np->np_thread, 1); | 466 | send_sig(SIGINT, np->np_thread, 1); |
467 | kthread_stop(np->np_thread); | 467 | kthread_stop(np->np_thread); |
468 | np->np_thread = NULL; | ||
468 | } | 469 | } |
469 | 470 | ||
470 | np->np_transport->iscsit_free_np(np); | 471 | np->np_transport->iscsit_free_np(np); |
@@ -823,24 +824,22 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | |||
823 | if (((hdr->flags & ISCSI_FLAG_CMD_READ) || | 824 | if (((hdr->flags & ISCSI_FLAG_CMD_READ) || |
824 | (hdr->flags & ISCSI_FLAG_CMD_WRITE)) && !hdr->data_length) { | 825 | (hdr->flags & ISCSI_FLAG_CMD_WRITE)) && !hdr->data_length) { |
825 | /* | 826 | /* |
826 | * Vmware ESX v3.0 uses a modified Cisco Initiator (v3.4.2) | 827 | * From RFC-3720 Section 10.3.1: |
827 | * that adds support for RESERVE/RELEASE. There is a bug | 828 | * |
828 | * add with this new functionality that sets R/W bits when | 829 | * "Either or both of R and W MAY be 1 when either the |
829 | * neither CDB carries any READ or WRITE datapayloads. | 830 | * Expected Data Transfer Length and/or Bidirectional Read |
831 | * Expected Data Transfer Length are 0" | ||
832 | * | ||
833 | * For this case, go ahead and clear the unnecssary bits | ||
834 | * to avoid any confusion with ->data_direction. | ||
830 | */ | 835 | */ |
831 | if ((hdr->cdb[0] == 0x16) || (hdr->cdb[0] == 0x17)) { | 836 | hdr->flags &= ~ISCSI_FLAG_CMD_READ; |
832 | hdr->flags &= ~ISCSI_FLAG_CMD_READ; | 837 | hdr->flags &= ~ISCSI_FLAG_CMD_WRITE; |
833 | hdr->flags &= ~ISCSI_FLAG_CMD_WRITE; | ||
834 | goto done; | ||
835 | } | ||
836 | 838 | ||
837 | pr_err("ISCSI_FLAG_CMD_READ or ISCSI_FLAG_CMD_WRITE" | 839 | pr_warn("ISCSI_FLAG_CMD_READ or ISCSI_FLAG_CMD_WRITE" |
838 | " set when Expected Data Transfer Length is 0 for" | 840 | " set when Expected Data Transfer Length is 0 for" |
839 | " CDB: 0x%02x. Bad iSCSI Initiator.\n", hdr->cdb[0]); | 841 | " CDB: 0x%02x, Fixing up flags\n", hdr->cdb[0]); |
840 | return iscsit_add_reject_cmd(cmd, | ||
841 | ISCSI_REASON_BOOKMARK_INVALID, buf); | ||
842 | } | 842 | } |
843 | done: | ||
844 | 843 | ||
845 | if (!(hdr->flags & ISCSI_FLAG_CMD_READ) && | 844 | if (!(hdr->flags & ISCSI_FLAG_CMD_READ) && |
846 | !(hdr->flags & ISCSI_FLAG_CMD_WRITE) && (hdr->data_length != 0)) { | 845 | !(hdr->flags & ISCSI_FLAG_CMD_WRITE) && (hdr->data_length != 0)) { |
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index e3318edb233d..1c0088fe9e99 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -474,7 +474,8 @@ static ssize_t __iscsi_##prefix##_store_##name( \ | |||
474 | \ | 474 | \ |
475 | if (!capable(CAP_SYS_ADMIN)) \ | 475 | if (!capable(CAP_SYS_ADMIN)) \ |
476 | return -EPERM; \ | 476 | return -EPERM; \ |
477 | \ | 477 | if (count >= sizeof(auth->name)) \ |
478 | return -EINVAL; \ | ||
478 | snprintf(auth->name, sizeof(auth->name), "%s", page); \ | 479 | snprintf(auth->name, sizeof(auth->name), "%s", page); \ |
479 | if (!strncmp("NULL", auth->name, 4)) \ | 480 | if (!strncmp("NULL", auth->name, 4)) \ |
480 | auth->naf_flags &= ~flags; \ | 481 | auth->naf_flags &= ~flags; \ |
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 4eb93b2b6473..e29279e6b577 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c | |||
@@ -1403,11 +1403,6 @@ old_sess_out: | |||
1403 | 1403 | ||
1404 | out: | 1404 | out: |
1405 | stop = kthread_should_stop(); | 1405 | stop = kthread_should_stop(); |
1406 | if (!stop && signal_pending(current)) { | ||
1407 | spin_lock_bh(&np->np_thread_lock); | ||
1408 | stop = (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN); | ||
1409 | spin_unlock_bh(&np->np_thread_lock); | ||
1410 | } | ||
1411 | /* Wait for another socket.. */ | 1406 | /* Wait for another socket.. */ |
1412 | if (!stop) | 1407 | if (!stop) |
1413 | return 1; | 1408 | return 1; |
@@ -1415,7 +1410,6 @@ exit: | |||
1415 | iscsi_stop_login_thread_timer(np); | 1410 | iscsi_stop_login_thread_timer(np); |
1416 | spin_lock_bh(&np->np_thread_lock); | 1411 | spin_lock_bh(&np->np_thread_lock); |
1417 | np->np_thread_state = ISCSI_NP_THREAD_EXIT; | 1412 | np->np_thread_state = ISCSI_NP_THREAD_EXIT; |
1418 | np->np_thread = NULL; | ||
1419 | spin_unlock_bh(&np->np_thread_lock); | 1413 | spin_unlock_bh(&np->np_thread_lock); |
1420 | 1414 | ||
1421 | return 0; | 1415 | return 0; |
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 207b340498a3..d06de84b069b 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -1106,6 +1106,11 @@ int se_dev_set_block_size(struct se_device *dev, u32 block_size) | |||
1106 | dev->dev_attrib.block_size = block_size; | 1106 | dev->dev_attrib.block_size = block_size; |
1107 | pr_debug("dev[%p]: SE Device block_size changed to %u\n", | 1107 | pr_debug("dev[%p]: SE Device block_size changed to %u\n", |
1108 | dev, block_size); | 1108 | dev, block_size); |
1109 | |||
1110 | if (dev->dev_attrib.max_bytes_per_io) | ||
1111 | dev->dev_attrib.hw_max_sectors = | ||
1112 | dev->dev_attrib.max_bytes_per_io / block_size; | ||
1113 | |||
1109 | return 0; | 1114 | return 0; |
1110 | } | 1115 | } |
1111 | 1116 | ||
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 0e34cda3271e..78241a53b555 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c | |||
@@ -66,9 +66,8 @@ static int fd_attach_hba(struct se_hba *hba, u32 host_id) | |||
66 | pr_debug("CORE_HBA[%d] - TCM FILEIO HBA Driver %s on Generic" | 66 | pr_debug("CORE_HBA[%d] - TCM FILEIO HBA Driver %s on Generic" |
67 | " Target Core Stack %s\n", hba->hba_id, FD_VERSION, | 67 | " Target Core Stack %s\n", hba->hba_id, FD_VERSION, |
68 | TARGET_CORE_MOD_VERSION); | 68 | TARGET_CORE_MOD_VERSION); |
69 | pr_debug("CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic" | 69 | pr_debug("CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic\n", |
70 | " MaxSectors: %u\n", | 70 | hba->hba_id, fd_host->fd_host_id); |
71 | hba->hba_id, fd_host->fd_host_id, FD_MAX_SECTORS); | ||
72 | 71 | ||
73 | return 0; | 72 | return 0; |
74 | } | 73 | } |
@@ -220,7 +219,8 @@ static int fd_configure_device(struct se_device *dev) | |||
220 | } | 219 | } |
221 | 220 | ||
222 | dev->dev_attrib.hw_block_size = fd_dev->fd_block_size; | 221 | dev->dev_attrib.hw_block_size = fd_dev->fd_block_size; |
223 | dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS; | 222 | dev->dev_attrib.max_bytes_per_io = FD_MAX_BYTES; |
223 | dev->dev_attrib.hw_max_sectors = FD_MAX_BYTES / fd_dev->fd_block_size; | ||
224 | dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH; | 224 | dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH; |
225 | 225 | ||
226 | if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) { | 226 | if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) { |
diff --git a/drivers/target/target_core_file.h b/drivers/target/target_core_file.h index 37ffc5bd2399..d7772c167685 100644 --- a/drivers/target/target_core_file.h +++ b/drivers/target/target_core_file.h | |||
@@ -7,7 +7,10 @@ | |||
7 | #define FD_DEVICE_QUEUE_DEPTH 32 | 7 | #define FD_DEVICE_QUEUE_DEPTH 32 |
8 | #define FD_MAX_DEVICE_QUEUE_DEPTH 128 | 8 | #define FD_MAX_DEVICE_QUEUE_DEPTH 128 |
9 | #define FD_BLOCKSIZE 512 | 9 | #define FD_BLOCKSIZE 512 |
10 | #define FD_MAX_SECTORS 2048 | 10 | /* |
11 | * Limited by the number of iovecs (2048) per vfs_[writev,readv] call | ||
12 | */ | ||
13 | #define FD_MAX_BYTES 8388608 | ||
11 | 14 | ||
12 | #define RRF_EMULATE_CDB 0x01 | 15 | #define RRF_EMULATE_CDB 0x01 |
13 | #define RRF_GOT_LBA 0x02 | 16 | #define RRF_GOT_LBA 0x02 |
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index f697f8baec54..2a573de19a9f 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c | |||
@@ -278,7 +278,6 @@ struct se_node_acl *core_tpg_check_initiator_node_acl( | |||
278 | snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); | 278 | snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); |
279 | acl->se_tpg = tpg; | 279 | acl->se_tpg = tpg; |
280 | acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); | 280 | acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); |
281 | spin_lock_init(&acl->stats_lock); | ||
282 | acl->dynamic_node_acl = 1; | 281 | acl->dynamic_node_acl = 1; |
283 | 282 | ||
284 | tpg->se_tpg_tfo->set_default_node_attributes(acl); | 283 | tpg->se_tpg_tfo->set_default_node_attributes(acl); |
@@ -406,7 +405,6 @@ struct se_node_acl *core_tpg_add_initiator_node_acl( | |||
406 | snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); | 405 | snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); |
407 | acl->se_tpg = tpg; | 406 | acl->se_tpg = tpg; |
408 | acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); | 407 | acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); |
409 | spin_lock_init(&acl->stats_lock); | ||
410 | 408 | ||
411 | tpg->se_tpg_tfo->set_default_node_attributes(acl); | 409 | tpg->se_tpg_tfo->set_default_node_attributes(acl); |
412 | 410 | ||
@@ -658,15 +656,9 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg) | |||
658 | spin_lock_init(&lun->lun_sep_lock); | 656 | spin_lock_init(&lun->lun_sep_lock); |
659 | init_completion(&lun->lun_ref_comp); | 657 | init_completion(&lun->lun_ref_comp); |
660 | 658 | ||
661 | ret = percpu_ref_init(&lun->lun_ref, core_tpg_lun_ref_release); | ||
662 | if (ret < 0) | ||
663 | return ret; | ||
664 | |||
665 | ret = core_tpg_post_addlun(se_tpg, lun, lun_access, dev); | 659 | ret = core_tpg_post_addlun(se_tpg, lun, lun_access, dev); |
666 | if (ret < 0) { | 660 | if (ret < 0) |
667 | percpu_ref_cancel_init(&lun->lun_ref); | ||
668 | return ret; | 661 | return ret; |
669 | } | ||
670 | 662 | ||
671 | return 0; | 663 | return 0; |
672 | } | 664 | } |
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 268b62768f2b..34aacaaae14a 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c | |||
@@ -93,6 +93,7 @@ struct n_tty_data { | |||
93 | size_t canon_head; | 93 | size_t canon_head; |
94 | size_t echo_head; | 94 | size_t echo_head; |
95 | size_t echo_commit; | 95 | size_t echo_commit; |
96 | size_t echo_mark; | ||
96 | DECLARE_BITMAP(char_map, 256); | 97 | DECLARE_BITMAP(char_map, 256); |
97 | 98 | ||
98 | /* private to n_tty_receive_overrun (single-threaded) */ | 99 | /* private to n_tty_receive_overrun (single-threaded) */ |
@@ -336,6 +337,7 @@ static void reset_buffer_flags(struct n_tty_data *ldata) | |||
336 | { | 337 | { |
337 | ldata->read_head = ldata->canon_head = ldata->read_tail = 0; | 338 | ldata->read_head = ldata->canon_head = ldata->read_tail = 0; |
338 | ldata->echo_head = ldata->echo_tail = ldata->echo_commit = 0; | 339 | ldata->echo_head = ldata->echo_tail = ldata->echo_commit = 0; |
340 | ldata->echo_mark = 0; | ||
339 | ldata->line_start = 0; | 341 | ldata->line_start = 0; |
340 | 342 | ||
341 | ldata->erasing = 0; | 343 | ldata->erasing = 0; |
@@ -787,6 +789,7 @@ static void commit_echoes(struct tty_struct *tty) | |||
787 | size_t head; | 789 | size_t head; |
788 | 790 | ||
789 | head = ldata->echo_head; | 791 | head = ldata->echo_head; |
792 | ldata->echo_mark = head; | ||
790 | old = ldata->echo_commit - ldata->echo_tail; | 793 | old = ldata->echo_commit - ldata->echo_tail; |
791 | 794 | ||
792 | /* Process committed echoes if the accumulated # of bytes | 795 | /* Process committed echoes if the accumulated # of bytes |
@@ -811,10 +814,11 @@ static void process_echoes(struct tty_struct *tty) | |||
811 | size_t echoed; | 814 | size_t echoed; |
812 | 815 | ||
813 | if ((!L_ECHO(tty) && !L_ECHONL(tty)) || | 816 | if ((!L_ECHO(tty) && !L_ECHONL(tty)) || |
814 | ldata->echo_commit == ldata->echo_tail) | 817 | ldata->echo_mark == ldata->echo_tail) |
815 | return; | 818 | return; |
816 | 819 | ||
817 | mutex_lock(&ldata->output_lock); | 820 | mutex_lock(&ldata->output_lock); |
821 | ldata->echo_commit = ldata->echo_mark; | ||
818 | echoed = __process_echoes(tty); | 822 | echoed = __process_echoes(tty); |
819 | mutex_unlock(&ldata->output_lock); | 823 | mutex_unlock(&ldata->output_lock); |
820 | 824 | ||
@@ -822,6 +826,7 @@ static void process_echoes(struct tty_struct *tty) | |||
822 | tty->ops->flush_chars(tty); | 826 | tty->ops->flush_chars(tty); |
823 | } | 827 | } |
824 | 828 | ||
829 | /* NB: echo_mark and echo_head should be equivalent here */ | ||
825 | static void flush_echoes(struct tty_struct *tty) | 830 | static void flush_echoes(struct tty_struct *tty) |
826 | { | 831 | { |
827 | struct n_tty_data *ldata = tty->disc_data; | 832 | struct n_tty_data *ldata = tty->disc_data; |
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index 4658e3e0ec42..06525f10e364 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c | |||
@@ -96,7 +96,8 @@ static void dw8250_serial_out(struct uart_port *p, int offset, int value) | |||
96 | if (offset == UART_LCR) { | 96 | if (offset == UART_LCR) { |
97 | int tries = 1000; | 97 | int tries = 1000; |
98 | while (tries--) { | 98 | while (tries--) { |
99 | if (value == p->serial_in(p, UART_LCR)) | 99 | unsigned int lcr = p->serial_in(p, UART_LCR); |
100 | if ((value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR)) | ||
100 | return; | 101 | return; |
101 | dw8250_force_idle(p); | 102 | dw8250_force_idle(p); |
102 | writeb(value, p->membase + (UART_LCR << p->regshift)); | 103 | writeb(value, p->membase + (UART_LCR << p->regshift)); |
@@ -132,7 +133,8 @@ static void dw8250_serial_out32(struct uart_port *p, int offset, int value) | |||
132 | if (offset == UART_LCR) { | 133 | if (offset == UART_LCR) { |
133 | int tries = 1000; | 134 | int tries = 1000; |
134 | while (tries--) { | 135 | while (tries--) { |
135 | if (value == p->serial_in(p, UART_LCR)) | 136 | unsigned int lcr = p->serial_in(p, UART_LCR); |
137 | if ((value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR)) | ||
136 | return; | 138 | return; |
137 | dw8250_force_idle(p); | 139 | dw8250_force_idle(p); |
138 | writel(value, p->membase + (UART_LCR << p->regshift)); | 140 | writel(value, p->membase + (UART_LCR << p->regshift)); |
@@ -455,6 +457,8 @@ MODULE_DEVICE_TABLE(of, dw8250_of_match); | |||
455 | static const struct acpi_device_id dw8250_acpi_match[] = { | 457 | static const struct acpi_device_id dw8250_acpi_match[] = { |
456 | { "INT33C4", 0 }, | 458 | { "INT33C4", 0 }, |
457 | { "INT33C5", 0 }, | 459 | { "INT33C5", 0 }, |
460 | { "INT3434", 0 }, | ||
461 | { "INT3435", 0 }, | ||
458 | { "80860F0A", 0 }, | 462 | { "80860F0A", 0 }, |
459 | { }, | 463 | { }, |
460 | }; | 464 | }; |
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index e46e9f3f19b9..f619ad5b5eae 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c | |||
@@ -240,6 +240,7 @@ static irqreturn_t xuartps_isr(int irq, void *dev_id) | |||
240 | continue; | 240 | continue; |
241 | } | 241 | } |
242 | 242 | ||
243 | #ifdef SUPPORT_SYSRQ | ||
243 | /* | 244 | /* |
244 | * uart_handle_sysrq_char() doesn't work if | 245 | * uart_handle_sysrq_char() doesn't work if |
245 | * spinlocked, for some reason | 246 | * spinlocked, for some reason |
@@ -253,6 +254,7 @@ static irqreturn_t xuartps_isr(int irq, void *dev_id) | |||
253 | } | 254 | } |
254 | spin_lock(&port->lock); | 255 | spin_lock(&port->lock); |
255 | } | 256 | } |
257 | #endif | ||
256 | 258 | ||
257 | port->icount.rx++; | 259 | port->icount.rx++; |
258 | 260 | ||
diff --git a/drivers/tty/tty_ldsem.c b/drivers/tty/tty_ldsem.c index 22fad8ad5ac2..d8a55e87877f 100644 --- a/drivers/tty/tty_ldsem.c +++ b/drivers/tty/tty_ldsem.c | |||
@@ -86,11 +86,21 @@ static inline long ldsem_atomic_update(long delta, struct ld_semaphore *sem) | |||
86 | return atomic_long_add_return(delta, (atomic_long_t *)&sem->count); | 86 | return atomic_long_add_return(delta, (atomic_long_t *)&sem->count); |
87 | } | 87 | } |
88 | 88 | ||
89 | /* | ||
90 | * ldsem_cmpxchg() updates @*old with the last-known sem->count value. | ||
91 | * Returns 1 if count was successfully changed; @*old will have @new value. | ||
92 | * Returns 0 if count was not changed; @*old will have most recent sem->count | ||
93 | */ | ||
89 | static inline int ldsem_cmpxchg(long *old, long new, struct ld_semaphore *sem) | 94 | static inline int ldsem_cmpxchg(long *old, long new, struct ld_semaphore *sem) |
90 | { | 95 | { |
91 | long tmp = *old; | 96 | long tmp = atomic_long_cmpxchg(&sem->count, *old, new); |
92 | *old = atomic_long_cmpxchg(&sem->count, *old, new); | 97 | if (tmp == *old) { |
93 | return *old == tmp; | 98 | *old = new; |
99 | return 1; | ||
100 | } else { | ||
101 | *old = tmp; | ||
102 | return 0; | ||
103 | } | ||
94 | } | 104 | } |
95 | 105 | ||
96 | /* | 106 | /* |
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 5d8981c5235e..6e73f8cd60e5 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c | |||
@@ -642,6 +642,10 @@ static int ci_hdrc_probe(struct platform_device *pdev) | |||
642 | : CI_ROLE_GADGET; | 642 | : CI_ROLE_GADGET; |
643 | } | 643 | } |
644 | 644 | ||
645 | /* only update vbus status for peripheral */ | ||
646 | if (ci->role == CI_ROLE_GADGET) | ||
647 | ci_handle_vbus_change(ci); | ||
648 | |||
645 | ret = ci_role_start(ci, ci->role); | 649 | ret = ci_role_start(ci, ci->role); |
646 | if (ret) { | 650 | if (ret) { |
647 | dev_err(dev, "can't start %s role\n", ci_role(ci)->name); | 651 | dev_err(dev, "can't start %s role\n", ci_role(ci)->name); |
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 59e6020ea753..526cd77563d8 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c | |||
@@ -88,7 +88,8 @@ static int host_start(struct ci_hdrc *ci) | |||
88 | return ret; | 88 | return ret; |
89 | 89 | ||
90 | disable_reg: | 90 | disable_reg: |
91 | regulator_disable(ci->platdata->reg_vbus); | 91 | if (ci->platdata->reg_vbus) |
92 | regulator_disable(ci->platdata->reg_vbus); | ||
92 | 93 | ||
93 | put_hcd: | 94 | put_hcd: |
94 | usb_put_hcd(hcd); | 95 | usb_put_hcd(hcd); |
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index b34c81969cba..69d20fbb38a2 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
@@ -1795,9 +1795,6 @@ static int udc_start(struct ci_hdrc *ci) | |||
1795 | pm_runtime_no_callbacks(&ci->gadget.dev); | 1795 | pm_runtime_no_callbacks(&ci->gadget.dev); |
1796 | pm_runtime_enable(&ci->gadget.dev); | 1796 | pm_runtime_enable(&ci->gadget.dev); |
1797 | 1797 | ||
1798 | /* Update ci->vbus_active */ | ||
1799 | ci_handle_vbus_change(ci); | ||
1800 | |||
1801 | return retval; | 1798 | return retval; |
1802 | 1799 | ||
1803 | destroy_eps: | 1800 | destroy_eps: |
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index 4d387596f3f0..0b23a8639311 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c | |||
@@ -854,13 +854,11 @@ static int wdm_manage_power(struct usb_interface *intf, int on) | |||
854 | { | 854 | { |
855 | /* need autopm_get/put here to ensure the usbcore sees the new value */ | 855 | /* need autopm_get/put here to ensure the usbcore sees the new value */ |
856 | int rv = usb_autopm_get_interface(intf); | 856 | int rv = usb_autopm_get_interface(intf); |
857 | if (rv < 0) | ||
858 | goto err; | ||
859 | 857 | ||
860 | intf->needs_remote_wakeup = on; | 858 | intf->needs_remote_wakeup = on; |
861 | usb_autopm_put_interface(intf); | 859 | if (!rv) |
862 | err: | 860 | usb_autopm_put_interface(intf); |
863 | return rv; | 861 | return 0; |
864 | } | 862 | } |
865 | 863 | ||
866 | static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) | 864 | static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 74f9cf02da07..a49217ae3533 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -455,9 +455,6 @@ static int dwc3_probe(struct platform_device *pdev) | |||
455 | if (IS_ERR(regs)) | 455 | if (IS_ERR(regs)) |
456 | return PTR_ERR(regs); | 456 | return PTR_ERR(regs); |
457 | 457 | ||
458 | usb_phy_set_suspend(dwc->usb2_phy, 0); | ||
459 | usb_phy_set_suspend(dwc->usb3_phy, 0); | ||
460 | |||
461 | spin_lock_init(&dwc->lock); | 458 | spin_lock_init(&dwc->lock); |
462 | platform_set_drvdata(pdev, dwc); | 459 | platform_set_drvdata(pdev, dwc); |
463 | 460 | ||
@@ -488,6 +485,9 @@ static int dwc3_probe(struct platform_device *pdev) | |||
488 | goto err0; | 485 | goto err0; |
489 | } | 486 | } |
490 | 487 | ||
488 | usb_phy_set_suspend(dwc->usb2_phy, 0); | ||
489 | usb_phy_set_suspend(dwc->usb3_phy, 0); | ||
490 | |||
491 | ret = dwc3_event_buffers_setup(dwc); | 491 | ret = dwc3_event_buffers_setup(dwc); |
492 | if (ret) { | 492 | if (ret) { |
493 | dev_err(dwc->dev, "failed to setup event buffers\n"); | 493 | dev_err(dwc->dev, "failed to setup event buffers\n"); |
@@ -569,6 +569,8 @@ err2: | |||
569 | dwc3_event_buffers_cleanup(dwc); | 569 | dwc3_event_buffers_cleanup(dwc); |
570 | 570 | ||
571 | err1: | 571 | err1: |
572 | usb_phy_set_suspend(dwc->usb2_phy, 1); | ||
573 | usb_phy_set_suspend(dwc->usb3_phy, 1); | ||
572 | dwc3_core_exit(dwc); | 574 | dwc3_core_exit(dwc); |
573 | 575 | ||
574 | err0: | 576 | err0: |
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 418444ebb1b8..8c356af79409 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -136,23 +136,27 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver, | |||
136 | struct ohci_hcd *ohci; | 136 | struct ohci_hcd *ohci; |
137 | int retval; | 137 | int retval; |
138 | struct usb_hcd *hcd = NULL; | 138 | struct usb_hcd *hcd = NULL; |
139 | 139 | struct device *dev = &pdev->dev; | |
140 | if (pdev->num_resources != 2) { | 140 | struct resource *res; |
141 | pr_debug("hcd probe: invalid num_resources"); | 141 | int irq; |
142 | return -ENODEV; | 142 | |
143 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
144 | if (!res) { | ||
145 | dev_dbg(dev, "hcd probe: missing memory resource\n"); | ||
146 | return -ENXIO; | ||
143 | } | 147 | } |
144 | 148 | ||
145 | if ((pdev->resource[0].flags != IORESOURCE_MEM) | 149 | irq = platform_get_irq(pdev, 0); |
146 | || (pdev->resource[1].flags != IORESOURCE_IRQ)) { | 150 | if (irq < 0) { |
147 | pr_debug("hcd probe: invalid resource type\n"); | 151 | dev_dbg(dev, "hcd probe: missing irq resource\n"); |
148 | return -ENODEV; | 152 | return irq; |
149 | } | 153 | } |
150 | 154 | ||
151 | hcd = usb_create_hcd(driver, &pdev->dev, "at91"); | 155 | hcd = usb_create_hcd(driver, &pdev->dev, "at91"); |
152 | if (!hcd) | 156 | if (!hcd) |
153 | return -ENOMEM; | 157 | return -ENOMEM; |
154 | hcd->rsrc_start = pdev->resource[0].start; | 158 | hcd->rsrc_start = res->start; |
155 | hcd->rsrc_len = resource_size(&pdev->resource[0]); | 159 | hcd->rsrc_len = resource_size(res); |
156 | 160 | ||
157 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 161 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { |
158 | pr_debug("request_mem_region failed\n"); | 162 | pr_debug("request_mem_region failed\n"); |
@@ -199,7 +203,7 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver, | |||
199 | ohci->num_ports = board->ports; | 203 | ohci->num_ports = board->ports; |
200 | at91_start_hc(pdev); | 204 | at91_start_hc(pdev); |
201 | 205 | ||
202 | retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED); | 206 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
203 | if (retval == 0) | 207 | if (retval == 0) |
204 | return retval; | 208 | return retval; |
205 | 209 | ||
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index b8dffd59eb25..73f5208714a4 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -128,7 +128,12 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
128 | * any other sleep) on Haswell machines with LPT and LPT-LP | 128 | * any other sleep) on Haswell machines with LPT and LPT-LP |
129 | * with the new Intel BIOS | 129 | * with the new Intel BIOS |
130 | */ | 130 | */ |
131 | xhci->quirks |= XHCI_SPURIOUS_WAKEUP; | 131 | /* Limit the quirk to only known vendors, as this triggers |
132 | * yet another BIOS bug on some other machines | ||
133 | * https://bugzilla.kernel.org/show_bug.cgi?id=66171 | ||
134 | */ | ||
135 | if (pdev->subsystem_vendor == PCI_VENDOR_ID_HP) | ||
136 | xhci->quirks |= XHCI_SPURIOUS_WAKEUP; | ||
132 | } | 137 | } |
133 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && | 138 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && |
134 | pdev->device == PCI_DEVICE_ID_ASROCK_P67) { | 139 | pdev->device == PCI_DEVICE_ID_ASROCK_P67) { |
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 08e2f39027ec..2b41c636a52a 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig | |||
@@ -19,8 +19,9 @@ config AB8500_USB | |||
19 | in host mode, low speed. | 19 | in host mode, low speed. |
20 | 20 | ||
21 | config FSL_USB2_OTG | 21 | config FSL_USB2_OTG |
22 | bool "Freescale USB OTG Transceiver Driver" | 22 | tristate "Freescale USB OTG Transceiver Driver" |
23 | depends on USB_EHCI_FSL && USB_FSL_USB2 && PM_RUNTIME | 23 | depends on USB_EHCI_FSL && USB_FSL_USB2 && PM_RUNTIME |
24 | depends on USB | ||
24 | select USB_OTG | 25 | select USB_OTG |
25 | select USB_PHY | 26 | select USB_PHY |
26 | help | 27 | help |
@@ -29,6 +30,7 @@ config FSL_USB2_OTG | |||
29 | config ISP1301_OMAP | 30 | config ISP1301_OMAP |
30 | tristate "Philips ISP1301 with OMAP OTG" | 31 | tristate "Philips ISP1301 with OMAP OTG" |
31 | depends on I2C && ARCH_OMAP_OTG | 32 | depends on I2C && ARCH_OMAP_OTG |
33 | depends on USB | ||
32 | select USB_PHY | 34 | select USB_PHY |
33 | help | 35 | help |
34 | If you say yes here you get support for the Philips ISP1301 | 36 | If you say yes here you get support for the Philips ISP1301 |
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index 82232acf1ab6..bbe4f8e6e8d7 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c | |||
@@ -876,7 +876,7 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy, | |||
876 | 876 | ||
877 | tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start, | 877 | tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start, |
878 | resource_size(res)); | 878 | resource_size(res)); |
879 | if (!tegra_phy->regs) { | 879 | if (!tegra_phy->pad_regs) { |
880 | dev_err(&pdev->dev, "Failed to remap UTMI Pad regs\n"); | 880 | dev_err(&pdev->dev, "Failed to remap UTMI Pad regs\n"); |
881 | return -ENOMEM; | 881 | return -ENOMEM; |
882 | } | 882 | } |
diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c index 30e8a61552d4..bad57ce77ba5 100644 --- a/drivers/usb/phy/phy-twl6030-usb.c +++ b/drivers/usb/phy/phy-twl6030-usb.c | |||
@@ -127,7 +127,8 @@ static inline int twl6030_writeb(struct twl6030_usb *twl, u8 module, | |||
127 | 127 | ||
128 | static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address) | 128 | static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address) |
129 | { | 129 | { |
130 | u8 data, ret = 0; | 130 | u8 data; |
131 | int ret; | ||
131 | 132 | ||
132 | ret = twl_i2c_read_u8(module, &data, address); | 133 | ret = twl_i2c_read_u8(module, &data, address); |
133 | if (ret >= 0) | 134 | if (ret >= 0) |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 496b7e39d5be..cc7a24154490 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -251,6 +251,7 @@ static void option_instat_callback(struct urb *urb); | |||
251 | #define ZTE_PRODUCT_MF628 0x0015 | 251 | #define ZTE_PRODUCT_MF628 0x0015 |
252 | #define ZTE_PRODUCT_MF626 0x0031 | 252 | #define ZTE_PRODUCT_MF626 0x0031 |
253 | #define ZTE_PRODUCT_MC2718 0xffe8 | 253 | #define ZTE_PRODUCT_MC2718 0xffe8 |
254 | #define ZTE_PRODUCT_AC2726 0xfff1 | ||
254 | 255 | ||
255 | #define BENQ_VENDOR_ID 0x04a5 | 256 | #define BENQ_VENDOR_ID 0x04a5 |
256 | #define BENQ_PRODUCT_H10 0x4068 | 257 | #define BENQ_PRODUCT_H10 0x4068 |
@@ -1453,6 +1454,7 @@ static const struct usb_device_id option_ids[] = { | |||
1453 | { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) }, | 1454 | { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) }, |
1454 | { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) }, | 1455 | { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) }, |
1455 | { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) }, | 1456 | { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) }, |
1457 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, | ||
1456 | 1458 | ||
1457 | { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, | 1459 | { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, |
1458 | { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, | 1460 | { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, |
diff --git a/drivers/usb/serial/zte_ev.c b/drivers/usb/serial/zte_ev.c index fca4c752a4ed..eae2c873b39f 100644 --- a/drivers/usb/serial/zte_ev.c +++ b/drivers/usb/serial/zte_ev.c | |||
@@ -281,8 +281,7 @@ static const struct usb_device_id id_table[] = { | |||
281 | { USB_DEVICE(0x19d2, 0xfffd) }, | 281 | { USB_DEVICE(0x19d2, 0xfffd) }, |
282 | { USB_DEVICE(0x19d2, 0xfffc) }, | 282 | { USB_DEVICE(0x19d2, 0xfffc) }, |
283 | { USB_DEVICE(0x19d2, 0xfffb) }, | 283 | { USB_DEVICE(0x19d2, 0xfffb) }, |
284 | /* AC2726, AC8710_V3 */ | 284 | /* AC8710_V3 */ |
285 | { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xfff1, 0xff, 0xff, 0xff) }, | ||
286 | { USB_DEVICE(0x19d2, 0xfff6) }, | 285 | { USB_DEVICE(0x19d2, 0xfff6) }, |
287 | { USB_DEVICE(0x19d2, 0xfff7) }, | 286 | { USB_DEVICE(0x19d2, 0xfff7) }, |
288 | { USB_DEVICE(0x19d2, 0xfff8) }, | 287 | { USB_DEVICE(0x19d2, 0xfff8) }, |
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index c444654fc33f..5c4a95b516cf 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -285,7 +285,7 @@ static void update_balloon_size(struct virtio_balloon *vb) | |||
285 | { | 285 | { |
286 | __le32 actual = cpu_to_le32(vb->num_pages); | 286 | __le32 actual = cpu_to_le32(vb->num_pages); |
287 | 287 | ||
288 | virtio_cwrite(vb->vdev, struct virtio_balloon_config, num_pages, | 288 | virtio_cwrite(vb->vdev, struct virtio_balloon_config, actual, |
289 | &actual); | 289 | &actual); |
290 | } | 290 | } |
291 | 291 | ||
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 55ea73f7c70b..4c02e2b94103 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
@@ -350,17 +350,19 @@ static enum bp_state increase_reservation(unsigned long nr_pages) | |||
350 | 350 | ||
351 | pfn = page_to_pfn(page); | 351 | pfn = page_to_pfn(page); |
352 | 352 | ||
353 | set_phys_to_machine(pfn, frame_list[i]); | ||
354 | |||
355 | #ifdef CONFIG_XEN_HAVE_PVMMU | 353 | #ifdef CONFIG_XEN_HAVE_PVMMU |
356 | /* Link back into the page tables if not highmem. */ | 354 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { |
357 | if (xen_pv_domain() && !PageHighMem(page)) { | 355 | set_phys_to_machine(pfn, frame_list[i]); |
358 | int ret; | 356 | |
359 | ret = HYPERVISOR_update_va_mapping( | 357 | /* Link back into the page tables if not highmem. */ |
360 | (unsigned long)__va(pfn << PAGE_SHIFT), | 358 | if (!PageHighMem(page)) { |
361 | mfn_pte(frame_list[i], PAGE_KERNEL), | 359 | int ret; |
362 | 0); | 360 | ret = HYPERVISOR_update_va_mapping( |
363 | BUG_ON(ret); | 361 | (unsigned long)__va(pfn << PAGE_SHIFT), |
362 | mfn_pte(frame_list[i], PAGE_KERNEL), | ||
363 | 0); | ||
364 | BUG_ON(ret); | ||
365 | } | ||
364 | } | 366 | } |
365 | #endif | 367 | #endif |
366 | 368 | ||
@@ -378,7 +380,6 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) | |||
378 | enum bp_state state = BP_DONE; | 380 | enum bp_state state = BP_DONE; |
379 | unsigned long pfn, i; | 381 | unsigned long pfn, i; |
380 | struct page *page; | 382 | struct page *page; |
381 | struct page *scratch_page; | ||
382 | int ret; | 383 | int ret; |
383 | struct xen_memory_reservation reservation = { | 384 | struct xen_memory_reservation reservation = { |
384 | .address_bits = 0, | 385 | .address_bits = 0, |
@@ -411,27 +412,29 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) | |||
411 | 412 | ||
412 | scrub_page(page); | 413 | scrub_page(page); |
413 | 414 | ||
415 | #ifdef CONFIG_XEN_HAVE_PVMMU | ||
414 | /* | 416 | /* |
415 | * Ballooned out frames are effectively replaced with | 417 | * Ballooned out frames are effectively replaced with |
416 | * a scratch frame. Ensure direct mappings and the | 418 | * a scratch frame. Ensure direct mappings and the |
417 | * p2m are consistent. | 419 | * p2m are consistent. |
418 | */ | 420 | */ |
419 | scratch_page = get_balloon_scratch_page(); | ||
420 | #ifdef CONFIG_XEN_HAVE_PVMMU | ||
421 | if (xen_pv_domain() && !PageHighMem(page)) { | ||
422 | ret = HYPERVISOR_update_va_mapping( | ||
423 | (unsigned long)__va(pfn << PAGE_SHIFT), | ||
424 | pfn_pte(page_to_pfn(scratch_page), | ||
425 | PAGE_KERNEL_RO), 0); | ||
426 | BUG_ON(ret); | ||
427 | } | ||
428 | #endif | ||
429 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { | 421 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { |
430 | unsigned long p; | 422 | unsigned long p; |
423 | struct page *scratch_page = get_balloon_scratch_page(); | ||
424 | |||
425 | if (!PageHighMem(page)) { | ||
426 | ret = HYPERVISOR_update_va_mapping( | ||
427 | (unsigned long)__va(pfn << PAGE_SHIFT), | ||
428 | pfn_pte(page_to_pfn(scratch_page), | ||
429 | PAGE_KERNEL_RO), 0); | ||
430 | BUG_ON(ret); | ||
431 | } | ||
431 | p = page_to_pfn(scratch_page); | 432 | p = page_to_pfn(scratch_page); |
432 | __set_phys_to_machine(pfn, pfn_to_mfn(p)); | 433 | __set_phys_to_machine(pfn, pfn_to_mfn(p)); |
434 | |||
435 | put_balloon_scratch_page(); | ||
433 | } | 436 | } |
434 | put_balloon_scratch_page(); | 437 | #endif |
435 | 438 | ||
436 | balloon_append(pfn_to_page(pfn)); | 439 | balloon_append(pfn_to_page(pfn)); |
437 | } | 440 | } |
@@ -627,15 +630,17 @@ static int __init balloon_init(void) | |||
627 | if (!xen_domain()) | 630 | if (!xen_domain()) |
628 | return -ENODEV; | 631 | return -ENODEV; |
629 | 632 | ||
630 | for_each_online_cpu(cpu) | 633 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { |
631 | { | 634 | for_each_online_cpu(cpu) |
632 | per_cpu(balloon_scratch_page, cpu) = alloc_page(GFP_KERNEL); | 635 | { |
633 | if (per_cpu(balloon_scratch_page, cpu) == NULL) { | 636 | per_cpu(balloon_scratch_page, cpu) = alloc_page(GFP_KERNEL); |
634 | pr_warn("Failed to allocate balloon_scratch_page for cpu %d\n", cpu); | 637 | if (per_cpu(balloon_scratch_page, cpu) == NULL) { |
635 | return -ENOMEM; | 638 | pr_warn("Failed to allocate balloon_scratch_page for cpu %d\n", cpu); |
639 | return -ENOMEM; | ||
640 | } | ||
636 | } | 641 | } |
642 | register_cpu_notifier(&balloon_cpu_notifier); | ||
637 | } | 643 | } |
638 | register_cpu_notifier(&balloon_cpu_notifier); | ||
639 | 644 | ||
640 | pr_info("Initialising balloon driver\n"); | 645 | pr_info("Initialising balloon driver\n"); |
641 | 646 | ||
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 028387192b60..aa846a48f400 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
@@ -1176,7 +1176,8 @@ static int gnttab_setup(void) | |||
1176 | gnttab_shared.addr = xen_remap(xen_hvm_resume_frames, | 1176 | gnttab_shared.addr = xen_remap(xen_hvm_resume_frames, |
1177 | PAGE_SIZE * max_nr_gframes); | 1177 | PAGE_SIZE * max_nr_gframes); |
1178 | if (gnttab_shared.addr == NULL) { | 1178 | if (gnttab_shared.addr == NULL) { |
1179 | pr_warn("Failed to ioremap gnttab share frames!\n"); | 1179 | pr_warn("Failed to ioremap gnttab share frames (addr=0x%08lx)!\n", |
1180 | xen_hvm_resume_frames); | ||
1180 | return -ENOMEM; | 1181 | return -ENOMEM; |
1181 | } | 1182 | } |
1182 | } | 1183 | } |
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index 8e74590fa1bb..569a13b9e856 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c | |||
@@ -533,12 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma) | |||
533 | { | 533 | { |
534 | struct page **pages = vma->vm_private_data; | 534 | struct page **pages = vma->vm_private_data; |
535 | int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; | 535 | int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; |
536 | int rc; | ||
536 | 537 | ||
537 | if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages) | 538 | if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages) |
538 | return; | 539 | return; |
539 | 540 | ||
540 | xen_unmap_domain_mfn_range(vma, numpgs, pages); | 541 | rc = xen_unmap_domain_mfn_range(vma, numpgs, pages); |
541 | free_xenballooned_pages(numpgs, pages); | 542 | if (rc == 0) |
543 | free_xenballooned_pages(numpgs, pages); | ||
544 | else | ||
545 | pr_crit("unable to unmap MFN range: leaking %d pages. rc=%d\n", | ||
546 | numpgs, rc); | ||
542 | kfree(pages); | 547 | kfree(pages); |
543 | } | 548 | } |
544 | 549 | ||
@@ -244,9 +244,14 @@ static void aio_free_ring(struct kioctx *ctx) | |||
244 | int i; | 244 | int i; |
245 | 245 | ||
246 | for (i = 0; i < ctx->nr_pages; i++) { | 246 | for (i = 0; i < ctx->nr_pages; i++) { |
247 | struct page *page; | ||
247 | pr_debug("pid(%d) [%d] page->count=%d\n", current->pid, i, | 248 | pr_debug("pid(%d) [%d] page->count=%d\n", current->pid, i, |
248 | page_count(ctx->ring_pages[i])); | 249 | page_count(ctx->ring_pages[i])); |
249 | put_page(ctx->ring_pages[i]); | 250 | page = ctx->ring_pages[i]; |
251 | if (!page) | ||
252 | continue; | ||
253 | ctx->ring_pages[i] = NULL; | ||
254 | put_page(page); | ||
250 | } | 255 | } |
251 | 256 | ||
252 | put_aio_ring_file(ctx); | 257 | put_aio_ring_file(ctx); |
@@ -280,18 +285,38 @@ static int aio_migratepage(struct address_space *mapping, struct page *new, | |||
280 | unsigned long flags; | 285 | unsigned long flags; |
281 | int rc; | 286 | int rc; |
282 | 287 | ||
288 | rc = 0; | ||
289 | |||
290 | /* Make sure the old page hasn't already been changed */ | ||
291 | spin_lock(&mapping->private_lock); | ||
292 | ctx = mapping->private_data; | ||
293 | if (ctx) { | ||
294 | pgoff_t idx; | ||
295 | spin_lock_irqsave(&ctx->completion_lock, flags); | ||
296 | idx = old->index; | ||
297 | if (idx < (pgoff_t)ctx->nr_pages) { | ||
298 | if (ctx->ring_pages[idx] != old) | ||
299 | rc = -EAGAIN; | ||
300 | } else | ||
301 | rc = -EINVAL; | ||
302 | spin_unlock_irqrestore(&ctx->completion_lock, flags); | ||
303 | } else | ||
304 | rc = -EINVAL; | ||
305 | spin_unlock(&mapping->private_lock); | ||
306 | |||
307 | if (rc != 0) | ||
308 | return rc; | ||
309 | |||
283 | /* Writeback must be complete */ | 310 | /* Writeback must be complete */ |
284 | BUG_ON(PageWriteback(old)); | 311 | BUG_ON(PageWriteback(old)); |
285 | put_page(old); | 312 | get_page(new); |
286 | 313 | ||
287 | rc = migrate_page_move_mapping(mapping, new, old, NULL, mode); | 314 | rc = migrate_page_move_mapping(mapping, new, old, NULL, mode, 1); |
288 | if (rc != MIGRATEPAGE_SUCCESS) { | 315 | if (rc != MIGRATEPAGE_SUCCESS) { |
289 | get_page(old); | 316 | put_page(new); |
290 | return rc; | 317 | return rc; |
291 | } | 318 | } |
292 | 319 | ||
293 | get_page(new); | ||
294 | |||
295 | /* We can potentially race against kioctx teardown here. Use the | 320 | /* We can potentially race against kioctx teardown here. Use the |
296 | * address_space's private data lock to protect the mapping's | 321 | * address_space's private data lock to protect the mapping's |
297 | * private_data. | 322 | * private_data. |
@@ -303,13 +328,24 @@ static int aio_migratepage(struct address_space *mapping, struct page *new, | |||
303 | spin_lock_irqsave(&ctx->completion_lock, flags); | 328 | spin_lock_irqsave(&ctx->completion_lock, flags); |
304 | migrate_page_copy(new, old); | 329 | migrate_page_copy(new, old); |
305 | idx = old->index; | 330 | idx = old->index; |
306 | if (idx < (pgoff_t)ctx->nr_pages) | 331 | if (idx < (pgoff_t)ctx->nr_pages) { |
307 | ctx->ring_pages[idx] = new; | 332 | /* And only do the move if things haven't changed */ |
333 | if (ctx->ring_pages[idx] == old) | ||
334 | ctx->ring_pages[idx] = new; | ||
335 | else | ||
336 | rc = -EAGAIN; | ||
337 | } else | ||
338 | rc = -EINVAL; | ||
308 | spin_unlock_irqrestore(&ctx->completion_lock, flags); | 339 | spin_unlock_irqrestore(&ctx->completion_lock, flags); |
309 | } else | 340 | } else |
310 | rc = -EBUSY; | 341 | rc = -EBUSY; |
311 | spin_unlock(&mapping->private_lock); | 342 | spin_unlock(&mapping->private_lock); |
312 | 343 | ||
344 | if (rc == MIGRATEPAGE_SUCCESS) | ||
345 | put_page(old); | ||
346 | else | ||
347 | put_page(new); | ||
348 | |||
313 | return rc; | 349 | return rc; |
314 | } | 350 | } |
315 | #endif | 351 | #endif |
@@ -326,7 +362,7 @@ static int aio_setup_ring(struct kioctx *ctx) | |||
326 | struct aio_ring *ring; | 362 | struct aio_ring *ring; |
327 | unsigned nr_events = ctx->max_reqs; | 363 | unsigned nr_events = ctx->max_reqs; |
328 | struct mm_struct *mm = current->mm; | 364 | struct mm_struct *mm = current->mm; |
329 | unsigned long size, populate; | 365 | unsigned long size, unused; |
330 | int nr_pages; | 366 | int nr_pages; |
331 | int i; | 367 | int i; |
332 | struct file *file; | 368 | struct file *file; |
@@ -347,6 +383,20 @@ static int aio_setup_ring(struct kioctx *ctx) | |||
347 | return -EAGAIN; | 383 | return -EAGAIN; |
348 | } | 384 | } |
349 | 385 | ||
386 | ctx->aio_ring_file = file; | ||
387 | nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) | ||
388 | / sizeof(struct io_event); | ||
389 | |||
390 | ctx->ring_pages = ctx->internal_pages; | ||
391 | if (nr_pages > AIO_RING_PAGES) { | ||
392 | ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *), | ||
393 | GFP_KERNEL); | ||
394 | if (!ctx->ring_pages) { | ||
395 | put_aio_ring_file(ctx); | ||
396 | return -ENOMEM; | ||
397 | } | ||
398 | } | ||
399 | |||
350 | for (i = 0; i < nr_pages; i++) { | 400 | for (i = 0; i < nr_pages; i++) { |
351 | struct page *page; | 401 | struct page *page; |
352 | page = find_or_create_page(file->f_inode->i_mapping, | 402 | page = find_or_create_page(file->f_inode->i_mapping, |
@@ -358,19 +408,14 @@ static int aio_setup_ring(struct kioctx *ctx) | |||
358 | SetPageUptodate(page); | 408 | SetPageUptodate(page); |
359 | SetPageDirty(page); | 409 | SetPageDirty(page); |
360 | unlock_page(page); | 410 | unlock_page(page); |
411 | |||
412 | ctx->ring_pages[i] = page; | ||
361 | } | 413 | } |
362 | ctx->aio_ring_file = file; | 414 | ctx->nr_pages = i; |
363 | nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) | ||
364 | / sizeof(struct io_event); | ||
365 | 415 | ||
366 | ctx->ring_pages = ctx->internal_pages; | 416 | if (unlikely(i != nr_pages)) { |
367 | if (nr_pages > AIO_RING_PAGES) { | 417 | aio_free_ring(ctx); |
368 | ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *), | 418 | return -EAGAIN; |
369 | GFP_KERNEL); | ||
370 | if (!ctx->ring_pages) { | ||
371 | put_aio_ring_file(ctx); | ||
372 | return -ENOMEM; | ||
373 | } | ||
374 | } | 419 | } |
375 | 420 | ||
376 | ctx->mmap_size = nr_pages * PAGE_SIZE; | 421 | ctx->mmap_size = nr_pages * PAGE_SIZE; |
@@ -379,9 +424,9 @@ static int aio_setup_ring(struct kioctx *ctx) | |||
379 | down_write(&mm->mmap_sem); | 424 | down_write(&mm->mmap_sem); |
380 | ctx->mmap_base = do_mmap_pgoff(ctx->aio_ring_file, 0, ctx->mmap_size, | 425 | ctx->mmap_base = do_mmap_pgoff(ctx->aio_ring_file, 0, ctx->mmap_size, |
381 | PROT_READ | PROT_WRITE, | 426 | PROT_READ | PROT_WRITE, |
382 | MAP_SHARED | MAP_POPULATE, 0, &populate); | 427 | MAP_SHARED, 0, &unused); |
428 | up_write(&mm->mmap_sem); | ||
383 | if (IS_ERR((void *)ctx->mmap_base)) { | 429 | if (IS_ERR((void *)ctx->mmap_base)) { |
384 | up_write(&mm->mmap_sem); | ||
385 | ctx->mmap_size = 0; | 430 | ctx->mmap_size = 0; |
386 | aio_free_ring(ctx); | 431 | aio_free_ring(ctx); |
387 | return -EAGAIN; | 432 | return -EAGAIN; |
@@ -389,27 +434,6 @@ static int aio_setup_ring(struct kioctx *ctx) | |||
389 | 434 | ||
390 | pr_debug("mmap address: 0x%08lx\n", ctx->mmap_base); | 435 | pr_debug("mmap address: 0x%08lx\n", ctx->mmap_base); |
391 | 436 | ||
392 | /* We must do this while still holding mmap_sem for write, as we | ||
393 | * need to be protected against userspace attempting to mremap() | ||
394 | * or munmap() the ring buffer. | ||
395 | */ | ||
396 | ctx->nr_pages = get_user_pages(current, mm, ctx->mmap_base, nr_pages, | ||
397 | 1, 0, ctx->ring_pages, NULL); | ||
398 | |||
399 | /* Dropping the reference here is safe as the page cache will hold | ||
400 | * onto the pages for us. It is also required so that page migration | ||
401 | * can unmap the pages and get the right reference count. | ||
402 | */ | ||
403 | for (i = 0; i < ctx->nr_pages; i++) | ||
404 | put_page(ctx->ring_pages[i]); | ||
405 | |||
406 | up_write(&mm->mmap_sem); | ||
407 | |||
408 | if (unlikely(ctx->nr_pages != nr_pages)) { | ||
409 | aio_free_ring(ctx); | ||
410 | return -EAGAIN; | ||
411 | } | ||
412 | |||
413 | ctx->user_id = ctx->mmap_base; | 437 | ctx->user_id = ctx->mmap_base; |
414 | ctx->nr_events = nr_events; /* trusted copy */ | 438 | ctx->nr_events = nr_events; /* trusted copy */ |
415 | 439 | ||
@@ -652,7 +676,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) | |||
652 | aio_nr += ctx->max_reqs; | 676 | aio_nr += ctx->max_reqs; |
653 | spin_unlock(&aio_nr_lock); | 677 | spin_unlock(&aio_nr_lock); |
654 | 678 | ||
655 | percpu_ref_get(&ctx->users); /* io_setup() will drop this ref */ | 679 | percpu_ref_get(&ctx->users); /* io_setup() will drop this ref */ |
680 | percpu_ref_get(&ctx->reqs); /* free_ioctx_users() will drop this */ | ||
656 | 681 | ||
657 | err = ioctx_add_table(ctx, mm); | 682 | err = ioctx_add_table(ctx, mm); |
658 | if (err) | 683 | if (err) |
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 1e561c059539..ec3ba43b9faa 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c | |||
@@ -210,9 +210,13 @@ static int readpage_nounlock(struct file *filp, struct page *page) | |||
210 | if (err < 0) { | 210 | if (err < 0) { |
211 | SetPageError(page); | 211 | SetPageError(page); |
212 | goto out; | 212 | goto out; |
213 | } else if (err < PAGE_CACHE_SIZE) { | 213 | } else { |
214 | if (err < PAGE_CACHE_SIZE) { | ||
214 | /* zero fill remainder of page */ | 215 | /* zero fill remainder of page */ |
215 | zero_user_segment(page, err, PAGE_CACHE_SIZE); | 216 | zero_user_segment(page, err, PAGE_CACHE_SIZE); |
217 | } else { | ||
218 | flush_dcache_page(page); | ||
219 | } | ||
216 | } | 220 | } |
217 | SetPageUptodate(page); | 221 | SetPageUptodate(page); |
218 | 222 | ||
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 9a8e396aed89..278fd2891288 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
@@ -978,7 +978,6 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, | |||
978 | struct ceph_mds_reply_inode *ininfo; | 978 | struct ceph_mds_reply_inode *ininfo; |
979 | struct ceph_vino vino; | 979 | struct ceph_vino vino; |
980 | struct ceph_fs_client *fsc = ceph_sb_to_client(sb); | 980 | struct ceph_fs_client *fsc = ceph_sb_to_client(sb); |
981 | int i = 0; | ||
982 | int err = 0; | 981 | int err = 0; |
983 | 982 | ||
984 | dout("fill_trace %p is_dentry %d is_target %d\n", req, | 983 | dout("fill_trace %p is_dentry %d is_target %d\n", req, |
@@ -1039,6 +1038,29 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, | |||
1039 | } | 1038 | } |
1040 | } | 1039 | } |
1041 | 1040 | ||
1041 | if (rinfo->head->is_target) { | ||
1042 | vino.ino = le64_to_cpu(rinfo->targeti.in->ino); | ||
1043 | vino.snap = le64_to_cpu(rinfo->targeti.in->snapid); | ||
1044 | |||
1045 | in = ceph_get_inode(sb, vino); | ||
1046 | if (IS_ERR(in)) { | ||
1047 | err = PTR_ERR(in); | ||
1048 | goto done; | ||
1049 | } | ||
1050 | req->r_target_inode = in; | ||
1051 | |||
1052 | err = fill_inode(in, &rinfo->targeti, NULL, | ||
1053 | session, req->r_request_started, | ||
1054 | (le32_to_cpu(rinfo->head->result) == 0) ? | ||
1055 | req->r_fmode : -1, | ||
1056 | &req->r_caps_reservation); | ||
1057 | if (err < 0) { | ||
1058 | pr_err("fill_inode badness %p %llx.%llx\n", | ||
1059 | in, ceph_vinop(in)); | ||
1060 | goto done; | ||
1061 | } | ||
1062 | } | ||
1063 | |||
1042 | /* | 1064 | /* |
1043 | * ignore null lease/binding on snapdir ENOENT, or else we | 1065 | * ignore null lease/binding on snapdir ENOENT, or else we |
1044 | * will have trouble splicing in the virtual snapdir later | 1066 | * will have trouble splicing in the virtual snapdir later |
@@ -1108,7 +1130,6 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, | |||
1108 | ceph_dentry(req->r_old_dentry)->offset); | 1130 | ceph_dentry(req->r_old_dentry)->offset); |
1109 | 1131 | ||
1110 | dn = req->r_old_dentry; /* use old_dentry */ | 1132 | dn = req->r_old_dentry; /* use old_dentry */ |
1111 | in = dn->d_inode; | ||
1112 | } | 1133 | } |
1113 | 1134 | ||
1114 | /* null dentry? */ | 1135 | /* null dentry? */ |
@@ -1130,44 +1151,28 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, | |||
1130 | } | 1151 | } |
1131 | 1152 | ||
1132 | /* attach proper inode */ | 1153 | /* attach proper inode */ |
1133 | ininfo = rinfo->targeti.in; | 1154 | if (!dn->d_inode) { |
1134 | vino.ino = le64_to_cpu(ininfo->ino); | 1155 | ihold(in); |
1135 | vino.snap = le64_to_cpu(ininfo->snapid); | ||
1136 | in = dn->d_inode; | ||
1137 | if (!in) { | ||
1138 | in = ceph_get_inode(sb, vino); | ||
1139 | if (IS_ERR(in)) { | ||
1140 | pr_err("fill_trace bad get_inode " | ||
1141 | "%llx.%llx\n", vino.ino, vino.snap); | ||
1142 | err = PTR_ERR(in); | ||
1143 | d_drop(dn); | ||
1144 | goto done; | ||
1145 | } | ||
1146 | dn = splice_dentry(dn, in, &have_lease, true); | 1156 | dn = splice_dentry(dn, in, &have_lease, true); |
1147 | if (IS_ERR(dn)) { | 1157 | if (IS_ERR(dn)) { |
1148 | err = PTR_ERR(dn); | 1158 | err = PTR_ERR(dn); |
1149 | goto done; | 1159 | goto done; |
1150 | } | 1160 | } |
1151 | req->r_dentry = dn; /* may have spliced */ | 1161 | req->r_dentry = dn; /* may have spliced */ |
1152 | ihold(in); | 1162 | } else if (dn->d_inode && dn->d_inode != in) { |
1153 | } else if (ceph_ino(in) == vino.ino && | ||
1154 | ceph_snap(in) == vino.snap) { | ||
1155 | ihold(in); | ||
1156 | } else { | ||
1157 | dout(" %p links to %p %llx.%llx, not %llx.%llx\n", | 1163 | dout(" %p links to %p %llx.%llx, not %llx.%llx\n", |
1158 | dn, in, ceph_ino(in), ceph_snap(in), | 1164 | dn, dn->d_inode, ceph_vinop(dn->d_inode), |
1159 | vino.ino, vino.snap); | 1165 | ceph_vinop(in)); |
1160 | have_lease = false; | 1166 | have_lease = false; |
1161 | in = NULL; | ||
1162 | } | 1167 | } |
1163 | 1168 | ||
1164 | if (have_lease) | 1169 | if (have_lease) |
1165 | update_dentry_lease(dn, rinfo->dlease, session, | 1170 | update_dentry_lease(dn, rinfo->dlease, session, |
1166 | req->r_request_started); | 1171 | req->r_request_started); |
1167 | dout(" final dn %p\n", dn); | 1172 | dout(" final dn %p\n", dn); |
1168 | i++; | 1173 | } else if (!req->r_aborted && |
1169 | } else if ((req->r_op == CEPH_MDS_OP_LOOKUPSNAP || | 1174 | (req->r_op == CEPH_MDS_OP_LOOKUPSNAP || |
1170 | req->r_op == CEPH_MDS_OP_MKSNAP) && !req->r_aborted) { | 1175 | req->r_op == CEPH_MDS_OP_MKSNAP)) { |
1171 | struct dentry *dn = req->r_dentry; | 1176 | struct dentry *dn = req->r_dentry; |
1172 | 1177 | ||
1173 | /* fill out a snapdir LOOKUPSNAP dentry */ | 1178 | /* fill out a snapdir LOOKUPSNAP dentry */ |
@@ -1177,52 +1182,15 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, | |||
1177 | ininfo = rinfo->targeti.in; | 1182 | ininfo = rinfo->targeti.in; |
1178 | vino.ino = le64_to_cpu(ininfo->ino); | 1183 | vino.ino = le64_to_cpu(ininfo->ino); |
1179 | vino.snap = le64_to_cpu(ininfo->snapid); | 1184 | vino.snap = le64_to_cpu(ininfo->snapid); |
1180 | in = ceph_get_inode(sb, vino); | ||
1181 | if (IS_ERR(in)) { | ||
1182 | pr_err("fill_inode get_inode badness %llx.%llx\n", | ||
1183 | vino.ino, vino.snap); | ||
1184 | err = PTR_ERR(in); | ||
1185 | d_delete(dn); | ||
1186 | goto done; | ||
1187 | } | ||
1188 | dout(" linking snapped dir %p to dn %p\n", in, dn); | 1185 | dout(" linking snapped dir %p to dn %p\n", in, dn); |
1186 | ihold(in); | ||
1189 | dn = splice_dentry(dn, in, NULL, true); | 1187 | dn = splice_dentry(dn, in, NULL, true); |
1190 | if (IS_ERR(dn)) { | 1188 | if (IS_ERR(dn)) { |
1191 | err = PTR_ERR(dn); | 1189 | err = PTR_ERR(dn); |
1192 | goto done; | 1190 | goto done; |
1193 | } | 1191 | } |
1194 | req->r_dentry = dn; /* may have spliced */ | 1192 | req->r_dentry = dn; /* may have spliced */ |
1195 | ihold(in); | ||
1196 | rinfo->head->is_dentry = 1; /* fool notrace handlers */ | ||
1197 | } | ||
1198 | |||
1199 | if (rinfo->head->is_target) { | ||
1200 | vino.ino = le64_to_cpu(rinfo->targeti.in->ino); | ||
1201 | vino.snap = le64_to_cpu(rinfo->targeti.in->snapid); | ||
1202 | |||
1203 | if (in == NULL || ceph_ino(in) != vino.ino || | ||
1204 | ceph_snap(in) != vino.snap) { | ||
1205 | in = ceph_get_inode(sb, vino); | ||
1206 | if (IS_ERR(in)) { | ||
1207 | err = PTR_ERR(in); | ||
1208 | goto done; | ||
1209 | } | ||
1210 | } | ||
1211 | req->r_target_inode = in; | ||
1212 | |||
1213 | err = fill_inode(in, | ||
1214 | &rinfo->targeti, NULL, | ||
1215 | session, req->r_request_started, | ||
1216 | (le32_to_cpu(rinfo->head->result) == 0) ? | ||
1217 | req->r_fmode : -1, | ||
1218 | &req->r_caps_reservation); | ||
1219 | if (err < 0) { | ||
1220 | pr_err("fill_inode badness %p %llx.%llx\n", | ||
1221 | in, ceph_vinop(in)); | ||
1222 | goto done; | ||
1223 | } | ||
1224 | } | 1193 | } |
1225 | |||
1226 | done: | 1194 | done: |
1227 | dout("fill_trace done err=%d\n", err); | 1195 | dout("fill_trace done err=%d\n", err); |
1228 | return err; | 1196 | return err; |
@@ -1272,7 +1240,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req, | |||
1272 | struct qstr dname; | 1240 | struct qstr dname; |
1273 | struct dentry *dn; | 1241 | struct dentry *dn; |
1274 | struct inode *in; | 1242 | struct inode *in; |
1275 | int err = 0, i; | 1243 | int err = 0, ret, i; |
1276 | struct inode *snapdir = NULL; | 1244 | struct inode *snapdir = NULL; |
1277 | struct ceph_mds_request_head *rhead = req->r_request->front.iov_base; | 1245 | struct ceph_mds_request_head *rhead = req->r_request->front.iov_base; |
1278 | struct ceph_dentry_info *di; | 1246 | struct ceph_dentry_info *di; |
@@ -1305,6 +1273,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req, | |||
1305 | ceph_fill_dirfrag(parent->d_inode, rinfo->dir_dir); | 1273 | ceph_fill_dirfrag(parent->d_inode, rinfo->dir_dir); |
1306 | } | 1274 | } |
1307 | 1275 | ||
1276 | /* FIXME: release caps/leases if error occurs */ | ||
1308 | for (i = 0; i < rinfo->dir_nr; i++) { | 1277 | for (i = 0; i < rinfo->dir_nr; i++) { |
1309 | struct ceph_vino vino; | 1278 | struct ceph_vino vino; |
1310 | 1279 | ||
@@ -1329,9 +1298,10 @@ retry_lookup: | |||
1329 | err = -ENOMEM; | 1298 | err = -ENOMEM; |
1330 | goto out; | 1299 | goto out; |
1331 | } | 1300 | } |
1332 | err = ceph_init_dentry(dn); | 1301 | ret = ceph_init_dentry(dn); |
1333 | if (err < 0) { | 1302 | if (ret < 0) { |
1334 | dput(dn); | 1303 | dput(dn); |
1304 | err = ret; | ||
1335 | goto out; | 1305 | goto out; |
1336 | } | 1306 | } |
1337 | } else if (dn->d_inode && | 1307 | } else if (dn->d_inode && |
@@ -1351,9 +1321,6 @@ retry_lookup: | |||
1351 | spin_unlock(&parent->d_lock); | 1321 | spin_unlock(&parent->d_lock); |
1352 | } | 1322 | } |
1353 | 1323 | ||
1354 | di = dn->d_fsdata; | ||
1355 | di->offset = ceph_make_fpos(frag, i + r_readdir_offset); | ||
1356 | |||
1357 | /* inode */ | 1324 | /* inode */ |
1358 | if (dn->d_inode) { | 1325 | if (dn->d_inode) { |
1359 | in = dn->d_inode; | 1326 | in = dn->d_inode; |
@@ -1366,26 +1333,39 @@ retry_lookup: | |||
1366 | err = PTR_ERR(in); | 1333 | err = PTR_ERR(in); |
1367 | goto out; | 1334 | goto out; |
1368 | } | 1335 | } |
1369 | dn = splice_dentry(dn, in, NULL, false); | ||
1370 | if (IS_ERR(dn)) | ||
1371 | dn = NULL; | ||
1372 | } | 1336 | } |
1373 | 1337 | ||
1374 | if (fill_inode(in, &rinfo->dir_in[i], NULL, session, | 1338 | if (fill_inode(in, &rinfo->dir_in[i], NULL, session, |
1375 | req->r_request_started, -1, | 1339 | req->r_request_started, -1, |
1376 | &req->r_caps_reservation) < 0) { | 1340 | &req->r_caps_reservation) < 0) { |
1377 | pr_err("fill_inode badness on %p\n", in); | 1341 | pr_err("fill_inode badness on %p\n", in); |
1342 | if (!dn->d_inode) | ||
1343 | iput(in); | ||
1344 | d_drop(dn); | ||
1378 | goto next_item; | 1345 | goto next_item; |
1379 | } | 1346 | } |
1380 | if (dn) | 1347 | |
1381 | update_dentry_lease(dn, rinfo->dir_dlease[i], | 1348 | if (!dn->d_inode) { |
1382 | req->r_session, | 1349 | dn = splice_dentry(dn, in, NULL, false); |
1383 | req->r_request_started); | 1350 | if (IS_ERR(dn)) { |
1351 | err = PTR_ERR(dn); | ||
1352 | dn = NULL; | ||
1353 | goto next_item; | ||
1354 | } | ||
1355 | } | ||
1356 | |||
1357 | di = dn->d_fsdata; | ||
1358 | di->offset = ceph_make_fpos(frag, i + r_readdir_offset); | ||
1359 | |||
1360 | update_dentry_lease(dn, rinfo->dir_dlease[i], | ||
1361 | req->r_session, | ||
1362 | req->r_request_started); | ||
1384 | next_item: | 1363 | next_item: |
1385 | if (dn) | 1364 | if (dn) |
1386 | dput(dn); | 1365 | dput(dn); |
1387 | } | 1366 | } |
1388 | req->r_did_prepopulate = true; | 1367 | if (err == 0) |
1368 | req->r_did_prepopulate = true; | ||
1389 | 1369 | ||
1390 | out: | 1370 | out: |
1391 | if (snapdir) { | 1371 | if (snapdir) { |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 288534920fe5..20d6697bd638 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -1493,6 +1493,7 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type, | |||
1493 | sb->s_blocksize - offset : towrite; | 1493 | sb->s_blocksize - offset : towrite; |
1494 | 1494 | ||
1495 | tmp_bh.b_state = 0; | 1495 | tmp_bh.b_state = 0; |
1496 | tmp_bh.b_size = sb->s_blocksize; | ||
1496 | err = ext2_get_block(inode, blk, &tmp_bh, 1); | 1497 | err = ext2_get_block(inode, blk, &tmp_bh, 1); |
1497 | if (err < 0) | 1498 | if (err < 0) |
1498 | goto out; | 1499 | goto out; |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index e6185031c1cc..ece55565b9cd 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -268,6 +268,16 @@ struct ext4_io_submit { | |||
268 | /* Translate # of blks to # of clusters */ | 268 | /* Translate # of blks to # of clusters */ |
269 | #define EXT4_NUM_B2C(sbi, blks) (((blks) + (sbi)->s_cluster_ratio - 1) >> \ | 269 | #define EXT4_NUM_B2C(sbi, blks) (((blks) + (sbi)->s_cluster_ratio - 1) >> \ |
270 | (sbi)->s_cluster_bits) | 270 | (sbi)->s_cluster_bits) |
271 | /* Mask out the low bits to get the starting block of the cluster */ | ||
272 | #define EXT4_PBLK_CMASK(s, pblk) ((pblk) & \ | ||
273 | ~((ext4_fsblk_t) (s)->s_cluster_ratio - 1)) | ||
274 | #define EXT4_LBLK_CMASK(s, lblk) ((lblk) & \ | ||
275 | ~((ext4_lblk_t) (s)->s_cluster_ratio - 1)) | ||
276 | /* Get the cluster offset */ | ||
277 | #define EXT4_PBLK_COFF(s, pblk) ((pblk) & \ | ||
278 | ((ext4_fsblk_t) (s)->s_cluster_ratio - 1)) | ||
279 | #define EXT4_LBLK_COFF(s, lblk) ((lblk) & \ | ||
280 | ((ext4_lblk_t) (s)->s_cluster_ratio - 1)) | ||
271 | 281 | ||
272 | /* | 282 | /* |
273 | * Structure of a blocks group descriptor | 283 | * Structure of a blocks group descriptor |
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c index 17ac112ab101..3fe29de832c8 100644 --- a/fs/ext4/ext4_jbd2.c +++ b/fs/ext4/ext4_jbd2.c | |||
@@ -259,6 +259,15 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line, | |||
259 | if (WARN_ON_ONCE(err)) { | 259 | if (WARN_ON_ONCE(err)) { |
260 | ext4_journal_abort_handle(where, line, __func__, bh, | 260 | ext4_journal_abort_handle(where, line, __func__, bh, |
261 | handle, err); | 261 | handle, err); |
262 | ext4_error_inode(inode, where, line, | ||
263 | bh->b_blocknr, | ||
264 | "journal_dirty_metadata failed: " | ||
265 | "handle type %u started at line %u, " | ||
266 | "credits %u/%u, errcode %d", | ||
267 | handle->h_type, | ||
268 | handle->h_line_no, | ||
269 | handle->h_requested_credits, | ||
270 | handle->h_buffer_credits, err); | ||
262 | } | 271 | } |
263 | } else { | 272 | } else { |
264 | if (inode) | 273 | if (inode) |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 35f65cf4f318..4410cc3d6ee2 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -360,8 +360,10 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext) | |||
360 | { | 360 | { |
361 | ext4_fsblk_t block = ext4_ext_pblock(ext); | 361 | ext4_fsblk_t block = ext4_ext_pblock(ext); |
362 | int len = ext4_ext_get_actual_len(ext); | 362 | int len = ext4_ext_get_actual_len(ext); |
363 | ext4_lblk_t lblock = le32_to_cpu(ext->ee_block); | ||
364 | ext4_lblk_t last = lblock + len - 1; | ||
363 | 365 | ||
364 | if (len == 0) | 366 | if (lblock > last) |
365 | return 0; | 367 | return 0; |
366 | return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len); | 368 | return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len); |
367 | } | 369 | } |
@@ -387,11 +389,26 @@ static int ext4_valid_extent_entries(struct inode *inode, | |||
387 | if (depth == 0) { | 389 | if (depth == 0) { |
388 | /* leaf entries */ | 390 | /* leaf entries */ |
389 | struct ext4_extent *ext = EXT_FIRST_EXTENT(eh); | 391 | struct ext4_extent *ext = EXT_FIRST_EXTENT(eh); |
392 | struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es; | ||
393 | ext4_fsblk_t pblock = 0; | ||
394 | ext4_lblk_t lblock = 0; | ||
395 | ext4_lblk_t prev = 0; | ||
396 | int len = 0; | ||
390 | while (entries) { | 397 | while (entries) { |
391 | if (!ext4_valid_extent(inode, ext)) | 398 | if (!ext4_valid_extent(inode, ext)) |
392 | return 0; | 399 | return 0; |
400 | |||
401 | /* Check for overlapping extents */ | ||
402 | lblock = le32_to_cpu(ext->ee_block); | ||
403 | len = ext4_ext_get_actual_len(ext); | ||
404 | if ((lblock <= prev) && prev) { | ||
405 | pblock = ext4_ext_pblock(ext); | ||
406 | es->s_last_error_block = cpu_to_le64(pblock); | ||
407 | return 0; | ||
408 | } | ||
393 | ext++; | 409 | ext++; |
394 | entries--; | 410 | entries--; |
411 | prev = lblock + len - 1; | ||
395 | } | 412 | } |
396 | } else { | 413 | } else { |
397 | struct ext4_extent_idx *ext_idx = EXT_FIRST_INDEX(eh); | 414 | struct ext4_extent_idx *ext_idx = EXT_FIRST_INDEX(eh); |
@@ -1834,8 +1851,7 @@ static unsigned int ext4_ext_check_overlap(struct ext4_sb_info *sbi, | |||
1834 | depth = ext_depth(inode); | 1851 | depth = ext_depth(inode); |
1835 | if (!path[depth].p_ext) | 1852 | if (!path[depth].p_ext) |
1836 | goto out; | 1853 | goto out; |
1837 | b2 = le32_to_cpu(path[depth].p_ext->ee_block); | 1854 | b2 = EXT4_LBLK_CMASK(sbi, le32_to_cpu(path[depth].p_ext->ee_block)); |
1838 | b2 &= ~(sbi->s_cluster_ratio - 1); | ||
1839 | 1855 | ||
1840 | /* | 1856 | /* |
1841 | * get the next allocated block if the extent in the path | 1857 | * get the next allocated block if the extent in the path |
@@ -1845,7 +1861,7 @@ static unsigned int ext4_ext_check_overlap(struct ext4_sb_info *sbi, | |||
1845 | b2 = ext4_ext_next_allocated_block(path); | 1861 | b2 = ext4_ext_next_allocated_block(path); |
1846 | if (b2 == EXT_MAX_BLOCKS) | 1862 | if (b2 == EXT_MAX_BLOCKS) |
1847 | goto out; | 1863 | goto out; |
1848 | b2 &= ~(sbi->s_cluster_ratio - 1); | 1864 | b2 = EXT4_LBLK_CMASK(sbi, b2); |
1849 | } | 1865 | } |
1850 | 1866 | ||
1851 | /* check for wrap through zero on extent logical start block*/ | 1867 | /* check for wrap through zero on extent logical start block*/ |
@@ -2504,7 +2520,7 @@ static int ext4_remove_blocks(handle_t *handle, struct inode *inode, | |||
2504 | * extent, we have to mark the cluster as used (store negative | 2520 | * extent, we have to mark the cluster as used (store negative |
2505 | * cluster number in partial_cluster). | 2521 | * cluster number in partial_cluster). |
2506 | */ | 2522 | */ |
2507 | unaligned = pblk & (sbi->s_cluster_ratio - 1); | 2523 | unaligned = EXT4_PBLK_COFF(sbi, pblk); |
2508 | if (unaligned && (ee_len == num) && | 2524 | if (unaligned && (ee_len == num) && |
2509 | (*partial_cluster != -((long long)EXT4_B2C(sbi, pblk)))) | 2525 | (*partial_cluster != -((long long)EXT4_B2C(sbi, pblk)))) |
2510 | *partial_cluster = EXT4_B2C(sbi, pblk); | 2526 | *partial_cluster = EXT4_B2C(sbi, pblk); |
@@ -2598,7 +2614,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, | |||
2598 | * accidentally freeing it later on | 2614 | * accidentally freeing it later on |
2599 | */ | 2615 | */ |
2600 | pblk = ext4_ext_pblock(ex); | 2616 | pblk = ext4_ext_pblock(ex); |
2601 | if (pblk & (sbi->s_cluster_ratio - 1)) | 2617 | if (EXT4_PBLK_COFF(sbi, pblk)) |
2602 | *partial_cluster = | 2618 | *partial_cluster = |
2603 | -((long long)EXT4_B2C(sbi, pblk)); | 2619 | -((long long)EXT4_B2C(sbi, pblk)); |
2604 | ex--; | 2620 | ex--; |
@@ -3753,7 +3769,7 @@ int ext4_find_delalloc_cluster(struct inode *inode, ext4_lblk_t lblk) | |||
3753 | { | 3769 | { |
3754 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 3770 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
3755 | ext4_lblk_t lblk_start, lblk_end; | 3771 | ext4_lblk_t lblk_start, lblk_end; |
3756 | lblk_start = lblk & (~(sbi->s_cluster_ratio - 1)); | 3772 | lblk_start = EXT4_LBLK_CMASK(sbi, lblk); |
3757 | lblk_end = lblk_start + sbi->s_cluster_ratio - 1; | 3773 | lblk_end = lblk_start + sbi->s_cluster_ratio - 1; |
3758 | 3774 | ||
3759 | return ext4_find_delalloc_range(inode, lblk_start, lblk_end); | 3775 | return ext4_find_delalloc_range(inode, lblk_start, lblk_end); |
@@ -3812,9 +3828,9 @@ get_reserved_cluster_alloc(struct inode *inode, ext4_lblk_t lblk_start, | |||
3812 | trace_ext4_get_reserved_cluster_alloc(inode, lblk_start, num_blks); | 3828 | trace_ext4_get_reserved_cluster_alloc(inode, lblk_start, num_blks); |
3813 | 3829 | ||
3814 | /* Check towards left side */ | 3830 | /* Check towards left side */ |
3815 | c_offset = lblk_start & (sbi->s_cluster_ratio - 1); | 3831 | c_offset = EXT4_LBLK_COFF(sbi, lblk_start); |
3816 | if (c_offset) { | 3832 | if (c_offset) { |
3817 | lblk_from = lblk_start & (~(sbi->s_cluster_ratio - 1)); | 3833 | lblk_from = EXT4_LBLK_CMASK(sbi, lblk_start); |
3818 | lblk_to = lblk_from + c_offset - 1; | 3834 | lblk_to = lblk_from + c_offset - 1; |
3819 | 3835 | ||
3820 | if (ext4_find_delalloc_range(inode, lblk_from, lblk_to)) | 3836 | if (ext4_find_delalloc_range(inode, lblk_from, lblk_to)) |
@@ -3822,7 +3838,7 @@ get_reserved_cluster_alloc(struct inode *inode, ext4_lblk_t lblk_start, | |||
3822 | } | 3838 | } |
3823 | 3839 | ||
3824 | /* Now check towards right. */ | 3840 | /* Now check towards right. */ |
3825 | c_offset = (lblk_start + num_blks) & (sbi->s_cluster_ratio - 1); | 3841 | c_offset = EXT4_LBLK_COFF(sbi, lblk_start + num_blks); |
3826 | if (allocated_clusters && c_offset) { | 3842 | if (allocated_clusters && c_offset) { |
3827 | lblk_from = lblk_start + num_blks; | 3843 | lblk_from = lblk_start + num_blks; |
3828 | lblk_to = lblk_from + (sbi->s_cluster_ratio - c_offset) - 1; | 3844 | lblk_to = lblk_from + (sbi->s_cluster_ratio - c_offset) - 1; |
@@ -4030,7 +4046,7 @@ static int get_implied_cluster_alloc(struct super_block *sb, | |||
4030 | struct ext4_ext_path *path) | 4046 | struct ext4_ext_path *path) |
4031 | { | 4047 | { |
4032 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 4048 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
4033 | ext4_lblk_t c_offset = map->m_lblk & (sbi->s_cluster_ratio-1); | 4049 | ext4_lblk_t c_offset = EXT4_LBLK_COFF(sbi, map->m_lblk); |
4034 | ext4_lblk_t ex_cluster_start, ex_cluster_end; | 4050 | ext4_lblk_t ex_cluster_start, ex_cluster_end; |
4035 | ext4_lblk_t rr_cluster_start; | 4051 | ext4_lblk_t rr_cluster_start; |
4036 | ext4_lblk_t ee_block = le32_to_cpu(ex->ee_block); | 4052 | ext4_lblk_t ee_block = le32_to_cpu(ex->ee_block); |
@@ -4048,8 +4064,7 @@ static int get_implied_cluster_alloc(struct super_block *sb, | |||
4048 | (rr_cluster_start == ex_cluster_start)) { | 4064 | (rr_cluster_start == ex_cluster_start)) { |
4049 | if (rr_cluster_start == ex_cluster_end) | 4065 | if (rr_cluster_start == ex_cluster_end) |
4050 | ee_start += ee_len - 1; | 4066 | ee_start += ee_len - 1; |
4051 | map->m_pblk = (ee_start & ~(sbi->s_cluster_ratio - 1)) + | 4067 | map->m_pblk = EXT4_PBLK_CMASK(sbi, ee_start) + c_offset; |
4052 | c_offset; | ||
4053 | map->m_len = min(map->m_len, | 4068 | map->m_len = min(map->m_len, |
4054 | (unsigned) sbi->s_cluster_ratio - c_offset); | 4069 | (unsigned) sbi->s_cluster_ratio - c_offset); |
4055 | /* | 4070 | /* |
@@ -4203,7 +4218,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
4203 | */ | 4218 | */ |
4204 | map->m_flags &= ~EXT4_MAP_FROM_CLUSTER; | 4219 | map->m_flags &= ~EXT4_MAP_FROM_CLUSTER; |
4205 | newex.ee_block = cpu_to_le32(map->m_lblk); | 4220 | newex.ee_block = cpu_to_le32(map->m_lblk); |
4206 | cluster_offset = map->m_lblk & (sbi->s_cluster_ratio-1); | 4221 | cluster_offset = EXT4_LBLK_CMASK(sbi, map->m_lblk); |
4207 | 4222 | ||
4208 | /* | 4223 | /* |
4209 | * If we are doing bigalloc, check to see if the extent returned | 4224 | * If we are doing bigalloc, check to see if the extent returned |
@@ -4271,7 +4286,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
4271 | * needed so that future calls to get_implied_cluster_alloc() | 4286 | * needed so that future calls to get_implied_cluster_alloc() |
4272 | * work correctly. | 4287 | * work correctly. |
4273 | */ | 4288 | */ |
4274 | offset = map->m_lblk & (sbi->s_cluster_ratio - 1); | 4289 | offset = EXT4_LBLK_COFF(sbi, map->m_lblk); |
4275 | ar.len = EXT4_NUM_B2C(sbi, offset+allocated); | 4290 | ar.len = EXT4_NUM_B2C(sbi, offset+allocated); |
4276 | ar.goal -= offset; | 4291 | ar.goal -= offset; |
4277 | ar.logical -= offset; | 4292 | ar.logical -= offset; |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 075763474118..61d49ff22c81 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -1206,7 +1206,6 @@ static int ext4_journalled_write_end(struct file *file, | |||
1206 | */ | 1206 | */ |
1207 | static int ext4_da_reserve_metadata(struct inode *inode, ext4_lblk_t lblock) | 1207 | static int ext4_da_reserve_metadata(struct inode *inode, ext4_lblk_t lblock) |
1208 | { | 1208 | { |
1209 | int retries = 0; | ||
1210 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 1209 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
1211 | struct ext4_inode_info *ei = EXT4_I(inode); | 1210 | struct ext4_inode_info *ei = EXT4_I(inode); |
1212 | unsigned int md_needed; | 1211 | unsigned int md_needed; |
@@ -1218,7 +1217,6 @@ static int ext4_da_reserve_metadata(struct inode *inode, ext4_lblk_t lblock) | |||
1218 | * in order to allocate nrblocks | 1217 | * in order to allocate nrblocks |
1219 | * worse case is one extent per block | 1218 | * worse case is one extent per block |
1220 | */ | 1219 | */ |
1221 | repeat: | ||
1222 | spin_lock(&ei->i_block_reservation_lock); | 1220 | spin_lock(&ei->i_block_reservation_lock); |
1223 | /* | 1221 | /* |
1224 | * ext4_calc_metadata_amount() has side effects, which we have | 1222 | * ext4_calc_metadata_amount() has side effects, which we have |
@@ -1238,10 +1236,6 @@ repeat: | |||
1238 | ei->i_da_metadata_calc_len = save_len; | 1236 | ei->i_da_metadata_calc_len = save_len; |
1239 | ei->i_da_metadata_calc_last_lblock = save_last_lblock; | 1237 | ei->i_da_metadata_calc_last_lblock = save_last_lblock; |
1240 | spin_unlock(&ei->i_block_reservation_lock); | 1238 | spin_unlock(&ei->i_block_reservation_lock); |
1241 | if (ext4_should_retry_alloc(inode->i_sb, &retries)) { | ||
1242 | cond_resched(); | ||
1243 | goto repeat; | ||
1244 | } | ||
1245 | return -ENOSPC; | 1239 | return -ENOSPC; |
1246 | } | 1240 | } |
1247 | ei->i_reserved_meta_blocks += md_needed; | 1241 | ei->i_reserved_meta_blocks += md_needed; |
@@ -1255,7 +1249,6 @@ repeat: | |||
1255 | */ | 1249 | */ |
1256 | static int ext4_da_reserve_space(struct inode *inode, ext4_lblk_t lblock) | 1250 | static int ext4_da_reserve_space(struct inode *inode, ext4_lblk_t lblock) |
1257 | { | 1251 | { |
1258 | int retries = 0; | ||
1259 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 1252 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
1260 | struct ext4_inode_info *ei = EXT4_I(inode); | 1253 | struct ext4_inode_info *ei = EXT4_I(inode); |
1261 | unsigned int md_needed; | 1254 | unsigned int md_needed; |
@@ -1277,7 +1270,6 @@ static int ext4_da_reserve_space(struct inode *inode, ext4_lblk_t lblock) | |||
1277 | * in order to allocate nrblocks | 1270 | * in order to allocate nrblocks |
1278 | * worse case is one extent per block | 1271 | * worse case is one extent per block |
1279 | */ | 1272 | */ |
1280 | repeat: | ||
1281 | spin_lock(&ei->i_block_reservation_lock); | 1273 | spin_lock(&ei->i_block_reservation_lock); |
1282 | /* | 1274 | /* |
1283 | * ext4_calc_metadata_amount() has side effects, which we have | 1275 | * ext4_calc_metadata_amount() has side effects, which we have |
@@ -1297,10 +1289,6 @@ repeat: | |||
1297 | ei->i_da_metadata_calc_len = save_len; | 1289 | ei->i_da_metadata_calc_len = save_len; |
1298 | ei->i_da_metadata_calc_last_lblock = save_last_lblock; | 1290 | ei->i_da_metadata_calc_last_lblock = save_last_lblock; |
1299 | spin_unlock(&ei->i_block_reservation_lock); | 1291 | spin_unlock(&ei->i_block_reservation_lock); |
1300 | if (ext4_should_retry_alloc(inode->i_sb, &retries)) { | ||
1301 | cond_resched(); | ||
1302 | goto repeat; | ||
1303 | } | ||
1304 | dquot_release_reservation_block(inode, EXT4_C2B(sbi, 1)); | 1292 | dquot_release_reservation_block(inode, EXT4_C2B(sbi, 1)); |
1305 | return -ENOSPC; | 1293 | return -ENOSPC; |
1306 | } | 1294 | } |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 4d113efa024c..04a5c7504be9 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -3442,6 +3442,9 @@ static void ext4_mb_pa_callback(struct rcu_head *head) | |||
3442 | { | 3442 | { |
3443 | struct ext4_prealloc_space *pa; | 3443 | struct ext4_prealloc_space *pa; |
3444 | pa = container_of(head, struct ext4_prealloc_space, u.pa_rcu); | 3444 | pa = container_of(head, struct ext4_prealloc_space, u.pa_rcu); |
3445 | |||
3446 | BUG_ON(atomic_read(&pa->pa_count)); | ||
3447 | BUG_ON(pa->pa_deleted == 0); | ||
3445 | kmem_cache_free(ext4_pspace_cachep, pa); | 3448 | kmem_cache_free(ext4_pspace_cachep, pa); |
3446 | } | 3449 | } |
3447 | 3450 | ||
@@ -3455,11 +3458,13 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac, | |||
3455 | ext4_group_t grp; | 3458 | ext4_group_t grp; |
3456 | ext4_fsblk_t grp_blk; | 3459 | ext4_fsblk_t grp_blk; |
3457 | 3460 | ||
3458 | if (!atomic_dec_and_test(&pa->pa_count) || pa->pa_free != 0) | ||
3459 | return; | ||
3460 | |||
3461 | /* in this short window concurrent discard can set pa_deleted */ | 3461 | /* in this short window concurrent discard can set pa_deleted */ |
3462 | spin_lock(&pa->pa_lock); | 3462 | spin_lock(&pa->pa_lock); |
3463 | if (!atomic_dec_and_test(&pa->pa_count) || pa->pa_free != 0) { | ||
3464 | spin_unlock(&pa->pa_lock); | ||
3465 | return; | ||
3466 | } | ||
3467 | |||
3463 | if (pa->pa_deleted == 1) { | 3468 | if (pa->pa_deleted == 1) { |
3464 | spin_unlock(&pa->pa_lock); | 3469 | spin_unlock(&pa->pa_lock); |
3465 | return; | 3470 | return; |
@@ -4121,7 +4126,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac, | |||
4121 | ext4_get_group_no_and_offset(sb, goal, &group, &block); | 4126 | ext4_get_group_no_and_offset(sb, goal, &group, &block); |
4122 | 4127 | ||
4123 | /* set up allocation goals */ | 4128 | /* set up allocation goals */ |
4124 | ac->ac_b_ex.fe_logical = ar->logical & ~(sbi->s_cluster_ratio - 1); | 4129 | ac->ac_b_ex.fe_logical = EXT4_LBLK_CMASK(sbi, ar->logical); |
4125 | ac->ac_status = AC_STATUS_CONTINUE; | 4130 | ac->ac_status = AC_STATUS_CONTINUE; |
4126 | ac->ac_sb = sb; | 4131 | ac->ac_sb = sb; |
4127 | ac->ac_inode = ar->inode; | 4132 | ac->ac_inode = ar->inode; |
@@ -4663,7 +4668,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, | |||
4663 | * blocks at the beginning or the end unless we are explicitly | 4668 | * blocks at the beginning or the end unless we are explicitly |
4664 | * requested to avoid doing so. | 4669 | * requested to avoid doing so. |
4665 | */ | 4670 | */ |
4666 | overflow = block & (sbi->s_cluster_ratio - 1); | 4671 | overflow = EXT4_PBLK_COFF(sbi, block); |
4667 | if (overflow) { | 4672 | if (overflow) { |
4668 | if (flags & EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER) { | 4673 | if (flags & EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER) { |
4669 | overflow = sbi->s_cluster_ratio - overflow; | 4674 | overflow = sbi->s_cluster_ratio - overflow; |
@@ -4677,7 +4682,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, | |||
4677 | count += overflow; | 4682 | count += overflow; |
4678 | } | 4683 | } |
4679 | } | 4684 | } |
4680 | overflow = count & (sbi->s_cluster_ratio - 1); | 4685 | overflow = EXT4_LBLK_COFF(sbi, count); |
4681 | if (overflow) { | 4686 | if (overflow) { |
4682 | if (flags & EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER) { | 4687 | if (flags & EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER) { |
4683 | if (count > overflow) | 4688 | if (count > overflow) |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index c977f4e4e63b..1f7784de05b6 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -792,7 +792,7 @@ static void ext4_put_super(struct super_block *sb) | |||
792 | } | 792 | } |
793 | 793 | ||
794 | ext4_es_unregister_shrinker(sbi); | 794 | ext4_es_unregister_shrinker(sbi); |
795 | del_timer(&sbi->s_err_report); | 795 | del_timer_sync(&sbi->s_err_report); |
796 | ext4_release_system_zone(sb); | 796 | ext4_release_system_zone(sb); |
797 | ext4_mb_release(sb); | 797 | ext4_mb_release(sb); |
798 | ext4_ext_release(sb); | 798 | ext4_ext_release(sb); |
@@ -3316,11 +3316,19 @@ int ext4_calculate_overhead(struct super_block *sb) | |||
3316 | } | 3316 | } |
3317 | 3317 | ||
3318 | 3318 | ||
3319 | static ext4_fsblk_t ext4_calculate_resv_clusters(struct ext4_sb_info *sbi) | 3319 | static ext4_fsblk_t ext4_calculate_resv_clusters(struct super_block *sb) |
3320 | { | 3320 | { |
3321 | ext4_fsblk_t resv_clusters; | 3321 | ext4_fsblk_t resv_clusters; |
3322 | 3322 | ||
3323 | /* | 3323 | /* |
3324 | * There's no need to reserve anything when we aren't using extents. | ||
3325 | * The space estimates are exact, there are no unwritten extents, | ||
3326 | * hole punching doesn't need new metadata... This is needed especially | ||
3327 | * to keep ext2/3 backward compatibility. | ||
3328 | */ | ||
3329 | if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) | ||
3330 | return 0; | ||
3331 | /* | ||
3324 | * By default we reserve 2% or 4096 clusters, whichever is smaller. | 3332 | * By default we reserve 2% or 4096 clusters, whichever is smaller. |
3325 | * This should cover the situations where we can not afford to run | 3333 | * This should cover the situations where we can not afford to run |
3326 | * out of space like for example punch hole, or converting | 3334 | * out of space like for example punch hole, or converting |
@@ -3328,7 +3336,8 @@ static ext4_fsblk_t ext4_calculate_resv_clusters(struct ext4_sb_info *sbi) | |||
3328 | * allocation would require 1, or 2 blocks, higher numbers are | 3336 | * allocation would require 1, or 2 blocks, higher numbers are |
3329 | * very rare. | 3337 | * very rare. |
3330 | */ | 3338 | */ |
3331 | resv_clusters = ext4_blocks_count(sbi->s_es) >> sbi->s_cluster_bits; | 3339 | resv_clusters = ext4_blocks_count(EXT4_SB(sb)->s_es) >> |
3340 | EXT4_SB(sb)->s_cluster_bits; | ||
3332 | 3341 | ||
3333 | do_div(resv_clusters, 50); | 3342 | do_div(resv_clusters, 50); |
3334 | resv_clusters = min_t(ext4_fsblk_t, resv_clusters, 4096); | 3343 | resv_clusters = min_t(ext4_fsblk_t, resv_clusters, 4096); |
@@ -4071,10 +4080,10 @@ no_journal: | |||
4071 | "available"); | 4080 | "available"); |
4072 | } | 4081 | } |
4073 | 4082 | ||
4074 | err = ext4_reserve_clusters(sbi, ext4_calculate_resv_clusters(sbi)); | 4083 | err = ext4_reserve_clusters(sbi, ext4_calculate_resv_clusters(sb)); |
4075 | if (err) { | 4084 | if (err) { |
4076 | ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for " | 4085 | ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for " |
4077 | "reserved pool", ext4_calculate_resv_clusters(sbi)); | 4086 | "reserved pool", ext4_calculate_resv_clusters(sb)); |
4078 | goto failed_mount4a; | 4087 | goto failed_mount4a; |
4079 | } | 4088 | } |
4080 | 4089 | ||
@@ -4184,7 +4193,7 @@ failed_mount_wq: | |||
4184 | } | 4193 | } |
4185 | failed_mount3: | 4194 | failed_mount3: |
4186 | ext4_es_unregister_shrinker(sbi); | 4195 | ext4_es_unregister_shrinker(sbi); |
4187 | del_timer(&sbi->s_err_report); | 4196 | del_timer_sync(&sbi->s_err_report); |
4188 | if (sbi->s_flex_groups) | 4197 | if (sbi->s_flex_groups) |
4189 | ext4_kvfree(sbi->s_flex_groups); | 4198 | ext4_kvfree(sbi->s_flex_groups); |
4190 | percpu_counter_destroy(&sbi->s_freeclusters_counter); | 4199 | percpu_counter_destroy(&sbi->s_freeclusters_counter); |
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 52032647dd4a..5fa344afb49a 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c | |||
@@ -702,7 +702,7 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid) | |||
702 | read_lock(&journal->j_state_lock); | 702 | read_lock(&journal->j_state_lock); |
703 | #ifdef CONFIG_JBD2_DEBUG | 703 | #ifdef CONFIG_JBD2_DEBUG |
704 | if (!tid_geq(journal->j_commit_request, tid)) { | 704 | if (!tid_geq(journal->j_commit_request, tid)) { |
705 | printk(KERN_EMERG | 705 | printk(KERN_ERR |
706 | "%s: error: j_commit_request=%d, tid=%d\n", | 706 | "%s: error: j_commit_request=%d, tid=%d\n", |
707 | __func__, journal->j_commit_request, tid); | 707 | __func__, journal->j_commit_request, tid); |
708 | } | 708 | } |
@@ -718,10 +718,8 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid) | |||
718 | } | 718 | } |
719 | read_unlock(&journal->j_state_lock); | 719 | read_unlock(&journal->j_state_lock); |
720 | 720 | ||
721 | if (unlikely(is_journal_aborted(journal))) { | 721 | if (unlikely(is_journal_aborted(journal))) |
722 | printk(KERN_EMERG "journal commit I/O error\n"); | ||
723 | err = -EIO; | 722 | err = -EIO; |
724 | } | ||
725 | return err; | 723 | return err; |
726 | } | 724 | } |
727 | 725 | ||
@@ -1527,13 +1525,13 @@ static int journal_get_superblock(journal_t *journal) | |||
1527 | if (JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM) && | 1525 | if (JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM) && |
1528 | JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) { | 1526 | JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) { |
1529 | /* Can't have checksum v1 and v2 on at the same time! */ | 1527 | /* Can't have checksum v1 and v2 on at the same time! */ |
1530 | printk(KERN_ERR "JBD: Can't enable checksumming v1 and v2 " | 1528 | printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 " |
1531 | "at the same time!\n"); | 1529 | "at the same time!\n"); |
1532 | goto out; | 1530 | goto out; |
1533 | } | 1531 | } |
1534 | 1532 | ||
1535 | if (!jbd2_verify_csum_type(journal, sb)) { | 1533 | if (!jbd2_verify_csum_type(journal, sb)) { |
1536 | printk(KERN_ERR "JBD: Unknown checksum type\n"); | 1534 | printk(KERN_ERR "JBD2: Unknown checksum type\n"); |
1537 | goto out; | 1535 | goto out; |
1538 | } | 1536 | } |
1539 | 1537 | ||
@@ -1541,7 +1539,7 @@ static int journal_get_superblock(journal_t *journal) | |||
1541 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) { | 1539 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) { |
1542 | journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0); | 1540 | journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0); |
1543 | if (IS_ERR(journal->j_chksum_driver)) { | 1541 | if (IS_ERR(journal->j_chksum_driver)) { |
1544 | printk(KERN_ERR "JBD: Cannot load crc32c driver.\n"); | 1542 | printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n"); |
1545 | err = PTR_ERR(journal->j_chksum_driver); | 1543 | err = PTR_ERR(journal->j_chksum_driver); |
1546 | journal->j_chksum_driver = NULL; | 1544 | journal->j_chksum_driver = NULL; |
1547 | goto out; | 1545 | goto out; |
@@ -1550,7 +1548,7 @@ static int journal_get_superblock(journal_t *journal) | |||
1550 | 1548 | ||
1551 | /* Check superblock checksum */ | 1549 | /* Check superblock checksum */ |
1552 | if (!jbd2_superblock_csum_verify(journal, sb)) { | 1550 | if (!jbd2_superblock_csum_verify(journal, sb)) { |
1553 | printk(KERN_ERR "JBD: journal checksum error\n"); | 1551 | printk(KERN_ERR "JBD2: journal checksum error\n"); |
1554 | goto out; | 1552 | goto out; |
1555 | } | 1553 | } |
1556 | 1554 | ||
@@ -1836,7 +1834,7 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat, | |||
1836 | journal->j_chksum_driver = crypto_alloc_shash("crc32c", | 1834 | journal->j_chksum_driver = crypto_alloc_shash("crc32c", |
1837 | 0, 0); | 1835 | 0, 0); |
1838 | if (IS_ERR(journal->j_chksum_driver)) { | 1836 | if (IS_ERR(journal->j_chksum_driver)) { |
1839 | printk(KERN_ERR "JBD: Cannot load crc32c " | 1837 | printk(KERN_ERR "JBD2: Cannot load crc32c " |
1840 | "driver.\n"); | 1838 | "driver.\n"); |
1841 | journal->j_chksum_driver = NULL; | 1839 | journal->j_chksum_driver = NULL; |
1842 | return 0; | 1840 | return 0; |
@@ -2645,7 +2643,7 @@ static void __exit journal_exit(void) | |||
2645 | #ifdef CONFIG_JBD2_DEBUG | 2643 | #ifdef CONFIG_JBD2_DEBUG |
2646 | int n = atomic_read(&nr_journal_heads); | 2644 | int n = atomic_read(&nr_journal_heads); |
2647 | if (n) | 2645 | if (n) |
2648 | printk(KERN_EMERG "JBD2: leaked %d journal_heads!\n", n); | 2646 | printk(KERN_ERR "JBD2: leaked %d journal_heads!\n", n); |
2649 | #endif | 2647 | #endif |
2650 | jbd2_remove_jbd_stats_proc_entry(); | 2648 | jbd2_remove_jbd_stats_proc_entry(); |
2651 | jbd2_journal_destroy_caches(); | 2649 | jbd2_journal_destroy_caches(); |
diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index 3929c50428b1..3b6bb19d60b1 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c | |||
@@ -594,7 +594,7 @@ static int do_one_pass(journal_t *journal, | |||
594 | be32_to_cpu(tmp->h_sequence))) { | 594 | be32_to_cpu(tmp->h_sequence))) { |
595 | brelse(obh); | 595 | brelse(obh); |
596 | success = -EIO; | 596 | success = -EIO; |
597 | printk(KERN_ERR "JBD: Invalid " | 597 | printk(KERN_ERR "JBD2: Invalid " |
598 | "checksum recovering " | 598 | "checksum recovering " |
599 | "block %llu in log\n", | 599 | "block %llu in log\n", |
600 | blocknr); | 600 | blocknr); |
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 7aa9a32573bb..8360674c85bc 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c | |||
@@ -932,7 +932,7 @@ repeat: | |||
932 | jbd2_alloc(jh2bh(jh)->b_size, | 932 | jbd2_alloc(jh2bh(jh)->b_size, |
933 | GFP_NOFS); | 933 | GFP_NOFS); |
934 | if (!frozen_buffer) { | 934 | if (!frozen_buffer) { |
935 | printk(KERN_EMERG | 935 | printk(KERN_ERR |
936 | "%s: OOM for frozen_buffer\n", | 936 | "%s: OOM for frozen_buffer\n", |
937 | __func__); | 937 | __func__); |
938 | JBUFFER_TRACE(jh, "oom!"); | 938 | JBUFFER_TRACE(jh, "oom!"); |
@@ -1166,7 +1166,7 @@ repeat: | |||
1166 | if (!jh->b_committed_data) { | 1166 | if (!jh->b_committed_data) { |
1167 | committed_data = jbd2_alloc(jh2bh(jh)->b_size, GFP_NOFS); | 1167 | committed_data = jbd2_alloc(jh2bh(jh)->b_size, GFP_NOFS); |
1168 | if (!committed_data) { | 1168 | if (!committed_data) { |
1169 | printk(KERN_EMERG "%s: No memory for committed data\n", | 1169 | printk(KERN_ERR "%s: No memory for committed data\n", |
1170 | __func__); | 1170 | __func__); |
1171 | err = -ENOMEM; | 1171 | err = -ENOMEM; |
1172 | goto out; | 1172 | goto out; |
@@ -1290,7 +1290,10 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) | |||
1290 | * once a transaction -bzzz | 1290 | * once a transaction -bzzz |
1291 | */ | 1291 | */ |
1292 | jh->b_modified = 1; | 1292 | jh->b_modified = 1; |
1293 | J_ASSERT_JH(jh, handle->h_buffer_credits > 0); | 1293 | if (handle->h_buffer_credits <= 0) { |
1294 | ret = -ENOSPC; | ||
1295 | goto out_unlock_bh; | ||
1296 | } | ||
1294 | handle->h_buffer_credits--; | 1297 | handle->h_buffer_credits--; |
1295 | } | 1298 | } |
1296 | 1299 | ||
@@ -1305,7 +1308,7 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) | |||
1305 | JBUFFER_TRACE(jh, "fastpath"); | 1308 | JBUFFER_TRACE(jh, "fastpath"); |
1306 | if (unlikely(jh->b_transaction != | 1309 | if (unlikely(jh->b_transaction != |
1307 | journal->j_running_transaction)) { | 1310 | journal->j_running_transaction)) { |
1308 | printk(KERN_EMERG "JBD: %s: " | 1311 | printk(KERN_ERR "JBD2: %s: " |
1309 | "jh->b_transaction (%llu, %p, %u) != " | 1312 | "jh->b_transaction (%llu, %p, %u) != " |
1310 | "journal->j_running_transaction (%p, %u)", | 1313 | "journal->j_running_transaction (%p, %u)", |
1311 | journal->j_devname, | 1314 | journal->j_devname, |
@@ -1332,7 +1335,7 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) | |||
1332 | JBUFFER_TRACE(jh, "already on other transaction"); | 1335 | JBUFFER_TRACE(jh, "already on other transaction"); |
1333 | if (unlikely(jh->b_transaction != | 1336 | if (unlikely(jh->b_transaction != |
1334 | journal->j_committing_transaction)) { | 1337 | journal->j_committing_transaction)) { |
1335 | printk(KERN_EMERG "JBD: %s: " | 1338 | printk(KERN_ERR "JBD2: %s: " |
1336 | "jh->b_transaction (%llu, %p, %u) != " | 1339 | "jh->b_transaction (%llu, %p, %u) != " |
1337 | "journal->j_committing_transaction (%p, %u)", | 1340 | "journal->j_committing_transaction (%p, %u)", |
1338 | journal->j_devname, | 1341 | journal->j_devname, |
@@ -1345,7 +1348,7 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) | |||
1345 | ret = -EINVAL; | 1348 | ret = -EINVAL; |
1346 | } | 1349 | } |
1347 | if (unlikely(jh->b_next_transaction != transaction)) { | 1350 | if (unlikely(jh->b_next_transaction != transaction)) { |
1348 | printk(KERN_EMERG "JBD: %s: " | 1351 | printk(KERN_ERR "JBD2: %s: " |
1349 | "jh->b_next_transaction (%llu, %p, %u) != " | 1352 | "jh->b_next_transaction (%llu, %p, %u) != " |
1350 | "transaction (%p, %u)", | 1353 | "transaction (%p, %u)", |
1351 | journal->j_devname, | 1354 | journal->j_devname, |
@@ -1373,7 +1376,6 @@ out_unlock_bh: | |||
1373 | jbd2_journal_put_journal_head(jh); | 1376 | jbd2_journal_put_journal_head(jh); |
1374 | out: | 1377 | out: |
1375 | JBUFFER_TRACE(jh, "exit"); | 1378 | JBUFFER_TRACE(jh, "exit"); |
1376 | WARN_ON(ret); /* All errors are bugs, so dump the stack */ | ||
1377 | return ret; | 1379 | return ret; |
1378 | } | 1380 | } |
1379 | 1381 | ||
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index b8e93a40a5d3..78c3c2097787 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c | |||
@@ -443,8 +443,11 @@ int pstore_register(struct pstore_info *psi) | |||
443 | pstore_get_records(0); | 443 | pstore_get_records(0); |
444 | 444 | ||
445 | kmsg_dump_register(&pstore_dumper); | 445 | kmsg_dump_register(&pstore_dumper); |
446 | pstore_register_console(); | 446 | |
447 | pstore_register_ftrace(); | 447 | if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) { |
448 | pstore_register_console(); | ||
449 | pstore_register_ftrace(); | ||
450 | } | ||
448 | 451 | ||
449 | if (pstore_update_ms >= 0) { | 452 | if (pstore_update_ms >= 0) { |
450 | pstore_timer.expires = jiffies + | 453 | pstore_timer.expires = jiffies + |
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index b94f93685093..35e7d08fe629 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -609,7 +609,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
609 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; | 609 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
610 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; | 610 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; |
611 | struct sysfs_open_file *of; | 611 | struct sysfs_open_file *of; |
612 | bool has_read, has_write, has_mmap; | 612 | bool has_read, has_write; |
613 | int error = -EACCES; | 613 | int error = -EACCES; |
614 | 614 | ||
615 | /* need attr_sd for attr and ops, its parent for kobj */ | 615 | /* need attr_sd for attr and ops, its parent for kobj */ |
@@ -621,7 +621,6 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
621 | 621 | ||
622 | has_read = battr->read || battr->mmap; | 622 | has_read = battr->read || battr->mmap; |
623 | has_write = battr->write || battr->mmap; | 623 | has_write = battr->write || battr->mmap; |
624 | has_mmap = battr->mmap; | ||
625 | } else { | 624 | } else { |
626 | const struct sysfs_ops *ops = sysfs_file_ops(attr_sd); | 625 | const struct sysfs_ops *ops = sysfs_file_ops(attr_sd); |
627 | 626 | ||
@@ -633,7 +632,6 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
633 | 632 | ||
634 | has_read = ops->show; | 633 | has_read = ops->show; |
635 | has_write = ops->store; | 634 | has_write = ops->store; |
636 | has_mmap = false; | ||
637 | } | 635 | } |
638 | 636 | ||
639 | /* check perms and supported operations */ | 637 | /* check perms and supported operations */ |
@@ -661,9 +659,9 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
661 | * open file has a separate mutex, it's okay as long as those don't | 659 | * open file has a separate mutex, it's okay as long as those don't |
662 | * happen on the same file. At this point, we can't easily give | 660 | * happen on the same file. At this point, we can't easily give |
663 | * each file a separate locking class. Let's differentiate on | 661 | * each file a separate locking class. Let's differentiate on |
664 | * whether the file has mmap or not for now. | 662 | * whether the file is bin or not for now. |
665 | */ | 663 | */ |
666 | if (has_mmap) | 664 | if (sysfs_is_bin(attr_sd)) |
667 | mutex_init(&of->mutex); | 665 | mutex_init(&of->mutex); |
668 | else | 666 | else |
669 | mutex_init(&of->mutex); | 667 | mutex_init(&of->mutex); |
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 3ef11b22e750..3b2c14b6f0fb 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -1635,7 +1635,7 @@ xfs_bmap_last_extent( | |||
1635 | * blocks at the end of the file which do not start at the previous data block, | 1635 | * blocks at the end of the file which do not start at the previous data block, |
1636 | * we will try to align the new blocks at stripe unit boundaries. | 1636 | * we will try to align the new blocks at stripe unit boundaries. |
1637 | * | 1637 | * |
1638 | * Returns 0 in bma->aeof if the file (fork) is empty as any new write will be | 1638 | * Returns 1 in bma->aeof if the file (fork) is empty as any new write will be |
1639 | * at, or past the EOF. | 1639 | * at, or past the EOF. |
1640 | */ | 1640 | */ |
1641 | STATIC int | 1641 | STATIC int |
@@ -1650,9 +1650,14 @@ xfs_bmap_isaeof( | |||
1650 | bma->aeof = 0; | 1650 | bma->aeof = 0; |
1651 | error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec, | 1651 | error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec, |
1652 | &is_empty); | 1652 | &is_empty); |
1653 | if (error || is_empty) | 1653 | if (error) |
1654 | return error; | 1654 | return error; |
1655 | 1655 | ||
1656 | if (is_empty) { | ||
1657 | bma->aeof = 1; | ||
1658 | return 0; | ||
1659 | } | ||
1660 | |||
1656 | /* | 1661 | /* |
1657 | * Check if we are allocation or past the last extent, or at least into | 1662 | * Check if we are allocation or past the last extent, or at least into |
1658 | * the last delayed allocated extent. | 1663 | * the last delayed allocated extent. |
@@ -3643,10 +3648,19 @@ xfs_bmap_btalloc( | |||
3643 | int isaligned; | 3648 | int isaligned; |
3644 | int tryagain; | 3649 | int tryagain; |
3645 | int error; | 3650 | int error; |
3651 | int stripe_align; | ||
3646 | 3652 | ||
3647 | ASSERT(ap->length); | 3653 | ASSERT(ap->length); |
3648 | 3654 | ||
3649 | mp = ap->ip->i_mount; | 3655 | mp = ap->ip->i_mount; |
3656 | |||
3657 | /* stripe alignment for allocation is determined by mount parameters */ | ||
3658 | stripe_align = 0; | ||
3659 | if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC)) | ||
3660 | stripe_align = mp->m_swidth; | ||
3661 | else if (mp->m_dalign) | ||
3662 | stripe_align = mp->m_dalign; | ||
3663 | |||
3650 | align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0; | 3664 | align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0; |
3651 | if (unlikely(align)) { | 3665 | if (unlikely(align)) { |
3652 | error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, | 3666 | error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, |
@@ -3655,6 +3669,8 @@ xfs_bmap_btalloc( | |||
3655 | ASSERT(!error); | 3669 | ASSERT(!error); |
3656 | ASSERT(ap->length); | 3670 | ASSERT(ap->length); |
3657 | } | 3671 | } |
3672 | |||
3673 | |||
3658 | nullfb = *ap->firstblock == NULLFSBLOCK; | 3674 | nullfb = *ap->firstblock == NULLFSBLOCK; |
3659 | fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, *ap->firstblock); | 3675 | fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, *ap->firstblock); |
3660 | if (nullfb) { | 3676 | if (nullfb) { |
@@ -3730,7 +3746,7 @@ xfs_bmap_btalloc( | |||
3730 | */ | 3746 | */ |
3731 | if (!ap->flist->xbf_low && ap->aeof) { | 3747 | if (!ap->flist->xbf_low && ap->aeof) { |
3732 | if (!ap->offset) { | 3748 | if (!ap->offset) { |
3733 | args.alignment = mp->m_dalign; | 3749 | args.alignment = stripe_align; |
3734 | atype = args.type; | 3750 | atype = args.type; |
3735 | isaligned = 1; | 3751 | isaligned = 1; |
3736 | /* | 3752 | /* |
@@ -3755,13 +3771,13 @@ xfs_bmap_btalloc( | |||
3755 | * of minlen+alignment+slop doesn't go up | 3771 | * of minlen+alignment+slop doesn't go up |
3756 | * between the calls. | 3772 | * between the calls. |
3757 | */ | 3773 | */ |
3758 | if (blen > mp->m_dalign && blen <= args.maxlen) | 3774 | if (blen > stripe_align && blen <= args.maxlen) |
3759 | nextminlen = blen - mp->m_dalign; | 3775 | nextminlen = blen - stripe_align; |
3760 | else | 3776 | else |
3761 | nextminlen = args.minlen; | 3777 | nextminlen = args.minlen; |
3762 | if (nextminlen + mp->m_dalign > args.minlen + 1) | 3778 | if (nextminlen + stripe_align > args.minlen + 1) |
3763 | args.minalignslop = | 3779 | args.minalignslop = |
3764 | nextminlen + mp->m_dalign - | 3780 | nextminlen + stripe_align - |
3765 | args.minlen - 1; | 3781 | args.minlen - 1; |
3766 | else | 3782 | else |
3767 | args.minalignslop = 0; | 3783 | args.minalignslop = 0; |
@@ -3783,7 +3799,7 @@ xfs_bmap_btalloc( | |||
3783 | */ | 3799 | */ |
3784 | args.type = atype; | 3800 | args.type = atype; |
3785 | args.fsbno = ap->blkno; | 3801 | args.fsbno = ap->blkno; |
3786 | args.alignment = mp->m_dalign; | 3802 | args.alignment = stripe_align; |
3787 | args.minlen = nextminlen; | 3803 | args.minlen = nextminlen; |
3788 | args.minalignslop = 0; | 3804 | args.minalignslop = 0; |
3789 | isaligned = 1; | 3805 | isaligned = 1; |
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 5887e41c0323..1394106ed22d 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c | |||
@@ -1187,7 +1187,12 @@ xfs_zero_remaining_bytes( | |||
1187 | XFS_BUF_UNWRITE(bp); | 1187 | XFS_BUF_UNWRITE(bp); |
1188 | XFS_BUF_READ(bp); | 1188 | XFS_BUF_READ(bp); |
1189 | XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock)); | 1189 | XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock)); |
1190 | xfsbdstrat(mp, bp); | 1190 | |
1191 | if (XFS_FORCED_SHUTDOWN(mp)) { | ||
1192 | error = XFS_ERROR(EIO); | ||
1193 | break; | ||
1194 | } | ||
1195 | xfs_buf_iorequest(bp); | ||
1191 | error = xfs_buf_iowait(bp); | 1196 | error = xfs_buf_iowait(bp); |
1192 | if (error) { | 1197 | if (error) { |
1193 | xfs_buf_ioerror_alert(bp, | 1198 | xfs_buf_ioerror_alert(bp, |
@@ -1200,7 +1205,12 @@ xfs_zero_remaining_bytes( | |||
1200 | XFS_BUF_UNDONE(bp); | 1205 | XFS_BUF_UNDONE(bp); |
1201 | XFS_BUF_UNREAD(bp); | 1206 | XFS_BUF_UNREAD(bp); |
1202 | XFS_BUF_WRITE(bp); | 1207 | XFS_BUF_WRITE(bp); |
1203 | xfsbdstrat(mp, bp); | 1208 | |
1209 | if (XFS_FORCED_SHUTDOWN(mp)) { | ||
1210 | error = XFS_ERROR(EIO); | ||
1211 | break; | ||
1212 | } | ||
1213 | xfs_buf_iorequest(bp); | ||
1204 | error = xfs_buf_iowait(bp); | 1214 | error = xfs_buf_iowait(bp); |
1205 | if (error) { | 1215 | if (error) { |
1206 | xfs_buf_ioerror_alert(bp, | 1216 | xfs_buf_ioerror_alert(bp, |
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index c7f0b77dcb00..afe7645e4b2b 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c | |||
@@ -698,7 +698,11 @@ xfs_buf_read_uncached( | |||
698 | bp->b_flags |= XBF_READ; | 698 | bp->b_flags |= XBF_READ; |
699 | bp->b_ops = ops; | 699 | bp->b_ops = ops; |
700 | 700 | ||
701 | xfsbdstrat(target->bt_mount, bp); | 701 | if (XFS_FORCED_SHUTDOWN(target->bt_mount)) { |
702 | xfs_buf_relse(bp); | ||
703 | return NULL; | ||
704 | } | ||
705 | xfs_buf_iorequest(bp); | ||
702 | xfs_buf_iowait(bp); | 706 | xfs_buf_iowait(bp); |
703 | return bp; | 707 | return bp; |
704 | } | 708 | } |
@@ -1089,7 +1093,7 @@ xfs_bioerror( | |||
1089 | * This is meant for userdata errors; metadata bufs come with | 1093 | * This is meant for userdata errors; metadata bufs come with |
1090 | * iodone functions attached, so that we can track down errors. | 1094 | * iodone functions attached, so that we can track down errors. |
1091 | */ | 1095 | */ |
1092 | STATIC int | 1096 | int |
1093 | xfs_bioerror_relse( | 1097 | xfs_bioerror_relse( |
1094 | struct xfs_buf *bp) | 1098 | struct xfs_buf *bp) |
1095 | { | 1099 | { |
@@ -1152,7 +1156,7 @@ xfs_bwrite( | |||
1152 | ASSERT(xfs_buf_islocked(bp)); | 1156 | ASSERT(xfs_buf_islocked(bp)); |
1153 | 1157 | ||
1154 | bp->b_flags |= XBF_WRITE; | 1158 | bp->b_flags |= XBF_WRITE; |
1155 | bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q); | 1159 | bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q | XBF_WRITE_FAIL); |
1156 | 1160 | ||
1157 | xfs_bdstrat_cb(bp); | 1161 | xfs_bdstrat_cb(bp); |
1158 | 1162 | ||
@@ -1164,25 +1168,6 @@ xfs_bwrite( | |||
1164 | return error; | 1168 | return error; |
1165 | } | 1169 | } |
1166 | 1170 | ||
1167 | /* | ||
1168 | * Wrapper around bdstrat so that we can stop data from going to disk in case | ||
1169 | * we are shutting down the filesystem. Typically user data goes thru this | ||
1170 | * path; one of the exceptions is the superblock. | ||
1171 | */ | ||
1172 | void | ||
1173 | xfsbdstrat( | ||
1174 | struct xfs_mount *mp, | ||
1175 | struct xfs_buf *bp) | ||
1176 | { | ||
1177 | if (XFS_FORCED_SHUTDOWN(mp)) { | ||
1178 | trace_xfs_bdstrat_shut(bp, _RET_IP_); | ||
1179 | xfs_bioerror_relse(bp); | ||
1180 | return; | ||
1181 | } | ||
1182 | |||
1183 | xfs_buf_iorequest(bp); | ||
1184 | } | ||
1185 | |||
1186 | STATIC void | 1171 | STATIC void |
1187 | _xfs_buf_ioend( | 1172 | _xfs_buf_ioend( |
1188 | xfs_buf_t *bp, | 1173 | xfs_buf_t *bp, |
@@ -1516,6 +1501,12 @@ xfs_wait_buftarg( | |||
1516 | struct xfs_buf *bp; | 1501 | struct xfs_buf *bp; |
1517 | bp = list_first_entry(&dispose, struct xfs_buf, b_lru); | 1502 | bp = list_first_entry(&dispose, struct xfs_buf, b_lru); |
1518 | list_del_init(&bp->b_lru); | 1503 | list_del_init(&bp->b_lru); |
1504 | if (bp->b_flags & XBF_WRITE_FAIL) { | ||
1505 | xfs_alert(btp->bt_mount, | ||
1506 | "Corruption Alert: Buffer at block 0x%llx had permanent write failures!\n" | ||
1507 | "Please run xfs_repair to determine the extent of the problem.", | ||
1508 | (long long)bp->b_bn); | ||
1509 | } | ||
1519 | xfs_buf_rele(bp); | 1510 | xfs_buf_rele(bp); |
1520 | } | 1511 | } |
1521 | if (loop++ != 0) | 1512 | if (loop++ != 0) |
@@ -1799,7 +1790,7 @@ __xfs_buf_delwri_submit( | |||
1799 | 1790 | ||
1800 | blk_start_plug(&plug); | 1791 | blk_start_plug(&plug); |
1801 | list_for_each_entry_safe(bp, n, io_list, b_list) { | 1792 | list_for_each_entry_safe(bp, n, io_list, b_list) { |
1802 | bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_ASYNC); | 1793 | bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_ASYNC | XBF_WRITE_FAIL); |
1803 | bp->b_flags |= XBF_WRITE; | 1794 | bp->b_flags |= XBF_WRITE; |
1804 | 1795 | ||
1805 | if (!wait) { | 1796 | if (!wait) { |
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index e65683361017..1cf21a4a9f22 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h | |||
@@ -45,6 +45,7 @@ typedef enum { | |||
45 | #define XBF_ASYNC (1 << 4) /* initiator will not wait for completion */ | 45 | #define XBF_ASYNC (1 << 4) /* initiator will not wait for completion */ |
46 | #define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */ | 46 | #define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */ |
47 | #define XBF_STALE (1 << 6) /* buffer has been staled, do not find it */ | 47 | #define XBF_STALE (1 << 6) /* buffer has been staled, do not find it */ |
48 | #define XBF_WRITE_FAIL (1 << 24)/* async writes have failed on this buffer */ | ||
48 | 49 | ||
49 | /* I/O hints for the BIO layer */ | 50 | /* I/O hints for the BIO layer */ |
50 | #define XBF_SYNCIO (1 << 10)/* treat this buffer as synchronous I/O */ | 51 | #define XBF_SYNCIO (1 << 10)/* treat this buffer as synchronous I/O */ |
@@ -70,6 +71,7 @@ typedef unsigned int xfs_buf_flags_t; | |||
70 | { XBF_ASYNC, "ASYNC" }, \ | 71 | { XBF_ASYNC, "ASYNC" }, \ |
71 | { XBF_DONE, "DONE" }, \ | 72 | { XBF_DONE, "DONE" }, \ |
72 | { XBF_STALE, "STALE" }, \ | 73 | { XBF_STALE, "STALE" }, \ |
74 | { XBF_WRITE_FAIL, "WRITE_FAIL" }, \ | ||
73 | { XBF_SYNCIO, "SYNCIO" }, \ | 75 | { XBF_SYNCIO, "SYNCIO" }, \ |
74 | { XBF_FUA, "FUA" }, \ | 76 | { XBF_FUA, "FUA" }, \ |
75 | { XBF_FLUSH, "FLUSH" }, \ | 77 | { XBF_FLUSH, "FLUSH" }, \ |
@@ -80,6 +82,7 @@ typedef unsigned int xfs_buf_flags_t; | |||
80 | { _XBF_DELWRI_Q, "DELWRI_Q" }, \ | 82 | { _XBF_DELWRI_Q, "DELWRI_Q" }, \ |
81 | { _XBF_COMPOUND, "COMPOUND" } | 83 | { _XBF_COMPOUND, "COMPOUND" } |
82 | 84 | ||
85 | |||
83 | /* | 86 | /* |
84 | * Internal state flags. | 87 | * Internal state flags. |
85 | */ | 88 | */ |
@@ -269,9 +272,6 @@ extern void xfs_buf_unlock(xfs_buf_t *); | |||
269 | 272 | ||
270 | /* Buffer Read and Write Routines */ | 273 | /* Buffer Read and Write Routines */ |
271 | extern int xfs_bwrite(struct xfs_buf *bp); | 274 | extern int xfs_bwrite(struct xfs_buf *bp); |
272 | |||
273 | extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *); | ||
274 | |||
275 | extern void xfs_buf_ioend(xfs_buf_t *, int); | 275 | extern void xfs_buf_ioend(xfs_buf_t *, int); |
276 | extern void xfs_buf_ioerror(xfs_buf_t *, int); | 276 | extern void xfs_buf_ioerror(xfs_buf_t *, int); |
277 | extern void xfs_buf_ioerror_alert(struct xfs_buf *, const char *func); | 277 | extern void xfs_buf_ioerror_alert(struct xfs_buf *, const char *func); |
@@ -282,6 +282,8 @@ extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *, | |||
282 | #define xfs_buf_zero(bp, off, len) \ | 282 | #define xfs_buf_zero(bp, off, len) \ |
283 | xfs_buf_iomove((bp), (off), (len), NULL, XBRW_ZERO) | 283 | xfs_buf_iomove((bp), (off), (len), NULL, XBRW_ZERO) |
284 | 284 | ||
285 | extern int xfs_bioerror_relse(struct xfs_buf *); | ||
286 | |||
285 | static inline int xfs_buf_geterror(xfs_buf_t *bp) | 287 | static inline int xfs_buf_geterror(xfs_buf_t *bp) |
286 | { | 288 | { |
287 | return bp ? bp->b_error : ENOMEM; | 289 | return bp ? bp->b_error : ENOMEM; |
@@ -301,7 +303,8 @@ extern void xfs_buf_terminate(void); | |||
301 | 303 | ||
302 | #define XFS_BUF_ZEROFLAGS(bp) \ | 304 | #define XFS_BUF_ZEROFLAGS(bp) \ |
303 | ((bp)->b_flags &= ~(XBF_READ|XBF_WRITE|XBF_ASYNC| \ | 305 | ((bp)->b_flags &= ~(XBF_READ|XBF_WRITE|XBF_ASYNC| \ |
304 | XBF_SYNCIO|XBF_FUA|XBF_FLUSH)) | 306 | XBF_SYNCIO|XBF_FUA|XBF_FLUSH| \ |
307 | XBF_WRITE_FAIL)) | ||
305 | 308 | ||
306 | void xfs_buf_stale(struct xfs_buf *bp); | 309 | void xfs_buf_stale(struct xfs_buf *bp); |
307 | #define XFS_BUF_UNSTALE(bp) ((bp)->b_flags &= ~XBF_STALE) | 310 | #define XFS_BUF_UNSTALE(bp) ((bp)->b_flags &= ~XBF_STALE) |
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index a64f67ba25d3..2227b9b050bb 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
@@ -496,6 +496,14 @@ xfs_buf_item_unpin( | |||
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
499 | /* | ||
500 | * Buffer IO error rate limiting. Limit it to no more than 10 messages per 30 | ||
501 | * seconds so as to not spam logs too much on repeated detection of the same | ||
502 | * buffer being bad.. | ||
503 | */ | ||
504 | |||
505 | DEFINE_RATELIMIT_STATE(xfs_buf_write_fail_rl_state, 30 * HZ, 10); | ||
506 | |||
499 | STATIC uint | 507 | STATIC uint |
500 | xfs_buf_item_push( | 508 | xfs_buf_item_push( |
501 | struct xfs_log_item *lip, | 509 | struct xfs_log_item *lip, |
@@ -524,6 +532,14 @@ xfs_buf_item_push( | |||
524 | 532 | ||
525 | trace_xfs_buf_item_push(bip); | 533 | trace_xfs_buf_item_push(bip); |
526 | 534 | ||
535 | /* has a previous flush failed due to IO errors? */ | ||
536 | if ((bp->b_flags & XBF_WRITE_FAIL) && | ||
537 | ___ratelimit(&xfs_buf_write_fail_rl_state, "XFS:")) { | ||
538 | xfs_warn(bp->b_target->bt_mount, | ||
539 | "Detected failing async write on buffer block 0x%llx. Retrying async write.\n", | ||
540 | (long long)bp->b_bn); | ||
541 | } | ||
542 | |||
527 | if (!xfs_buf_delwri_queue(bp, buffer_list)) | 543 | if (!xfs_buf_delwri_queue(bp, buffer_list)) |
528 | rval = XFS_ITEM_FLUSHING; | 544 | rval = XFS_ITEM_FLUSHING; |
529 | xfs_buf_unlock(bp); | 545 | xfs_buf_unlock(bp); |
@@ -1096,8 +1112,9 @@ xfs_buf_iodone_callbacks( | |||
1096 | 1112 | ||
1097 | xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */ | 1113 | xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */ |
1098 | 1114 | ||
1099 | if (!XFS_BUF_ISSTALE(bp)) { | 1115 | if (!(bp->b_flags & (XBF_STALE|XBF_WRITE_FAIL))) { |
1100 | bp->b_flags |= XBF_WRITE | XBF_ASYNC | XBF_DONE; | 1116 | bp->b_flags |= XBF_WRITE | XBF_ASYNC | |
1117 | XBF_DONE | XBF_WRITE_FAIL; | ||
1101 | xfs_buf_iorequest(bp); | 1118 | xfs_buf_iorequest(bp); |
1102 | } else { | 1119 | } else { |
1103 | xfs_buf_relse(bp); | 1120 | xfs_buf_relse(bp); |
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index 56369d4509d5..48c7d18f68c3 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
@@ -2067,12 +2067,12 @@ xfs_dir2_node_lookup( | |||
2067 | */ | 2067 | */ |
2068 | int /* error */ | 2068 | int /* error */ |
2069 | xfs_dir2_node_removename( | 2069 | xfs_dir2_node_removename( |
2070 | xfs_da_args_t *args) /* operation arguments */ | 2070 | struct xfs_da_args *args) /* operation arguments */ |
2071 | { | 2071 | { |
2072 | xfs_da_state_blk_t *blk; /* leaf block */ | 2072 | struct xfs_da_state_blk *blk; /* leaf block */ |
2073 | int error; /* error return value */ | 2073 | int error; /* error return value */ |
2074 | int rval; /* operation return value */ | 2074 | int rval; /* operation return value */ |
2075 | xfs_da_state_t *state; /* btree cursor */ | 2075 | struct xfs_da_state *state; /* btree cursor */ |
2076 | 2076 | ||
2077 | trace_xfs_dir2_node_removename(args); | 2077 | trace_xfs_dir2_node_removename(args); |
2078 | 2078 | ||
@@ -2084,19 +2084,18 @@ xfs_dir2_node_removename( | |||
2084 | state->mp = args->dp->i_mount; | 2084 | state->mp = args->dp->i_mount; |
2085 | state->blocksize = state->mp->m_dirblksize; | 2085 | state->blocksize = state->mp->m_dirblksize; |
2086 | state->node_ents = state->mp->m_dir_node_ents; | 2086 | state->node_ents = state->mp->m_dir_node_ents; |
2087 | /* | 2087 | |
2088 | * Look up the entry we're deleting, set up the cursor. | 2088 | /* Look up the entry we're deleting, set up the cursor. */ |
2089 | */ | ||
2090 | error = xfs_da3_node_lookup_int(state, &rval); | 2089 | error = xfs_da3_node_lookup_int(state, &rval); |
2091 | if (error) | 2090 | if (error) |
2092 | rval = error; | 2091 | goto out_free; |
2093 | /* | 2092 | |
2094 | * Didn't find it, upper layer screwed up. | 2093 | /* Didn't find it, upper layer screwed up. */ |
2095 | */ | ||
2096 | if (rval != EEXIST) { | 2094 | if (rval != EEXIST) { |
2097 | xfs_da_state_free(state); | 2095 | error = rval; |
2098 | return rval; | 2096 | goto out_free; |
2099 | } | 2097 | } |
2098 | |||
2100 | blk = &state->path.blk[state->path.active - 1]; | 2099 | blk = &state->path.blk[state->path.active - 1]; |
2101 | ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC); | 2100 | ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC); |
2102 | ASSERT(state->extravalid); | 2101 | ASSERT(state->extravalid); |
@@ -2107,7 +2106,7 @@ xfs_dir2_node_removename( | |||
2107 | error = xfs_dir2_leafn_remove(args, blk->bp, blk->index, | 2106 | error = xfs_dir2_leafn_remove(args, blk->bp, blk->index, |
2108 | &state->extrablk, &rval); | 2107 | &state->extrablk, &rval); |
2109 | if (error) | 2108 | if (error) |
2110 | return error; | 2109 | goto out_free; |
2111 | /* | 2110 | /* |
2112 | * Fix the hash values up the btree. | 2111 | * Fix the hash values up the btree. |
2113 | */ | 2112 | */ |
@@ -2122,6 +2121,7 @@ xfs_dir2_node_removename( | |||
2122 | */ | 2121 | */ |
2123 | if (!error) | 2122 | if (!error) |
2124 | error = xfs_dir2_node_to_leaf(state); | 2123 | error = xfs_dir2_node_to_leaf(state); |
2124 | out_free: | ||
2125 | xfs_da_state_free(state); | 2125 | xfs_da_state_free(state); |
2126 | return error; | 2126 | return error; |
2127 | } | 2127 | } |
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 27e0e544e963..104455b8046c 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c | |||
@@ -618,7 +618,8 @@ xfs_setattr_nonsize( | |||
618 | } | 618 | } |
619 | if (!gid_eq(igid, gid)) { | 619 | if (!gid_eq(igid, gid)) { |
620 | if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_GQUOTA_ON(mp)) { | 620 | if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_GQUOTA_ON(mp)) { |
621 | ASSERT(!XFS_IS_PQUOTA_ON(mp)); | 621 | ASSERT(xfs_sb_version_has_pquotino(&mp->m_sb) || |
622 | !XFS_IS_PQUOTA_ON(mp)); | ||
622 | ASSERT(mask & ATTR_GID); | 623 | ASSERT(mask & ATTR_GID); |
623 | ASSERT(gdqp); | 624 | ASSERT(gdqp); |
624 | olddquot2 = xfs_qm_vop_chown(tp, ip, | 625 | olddquot2 = xfs_qm_vop_chown(tp, ip, |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index b6b669df40f3..eae16920655b 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -193,7 +193,10 @@ xlog_bread_noalign( | |||
193 | bp->b_io_length = nbblks; | 193 | bp->b_io_length = nbblks; |
194 | bp->b_error = 0; | 194 | bp->b_error = 0; |
195 | 195 | ||
196 | xfsbdstrat(log->l_mp, bp); | 196 | if (XFS_FORCED_SHUTDOWN(log->l_mp)) |
197 | return XFS_ERROR(EIO); | ||
198 | |||
199 | xfs_buf_iorequest(bp); | ||
197 | error = xfs_buf_iowait(bp); | 200 | error = xfs_buf_iowait(bp); |
198 | if (error) | 201 | if (error) |
199 | xfs_buf_ioerror_alert(bp, __func__); | 202 | xfs_buf_ioerror_alert(bp, __func__); |
@@ -4397,7 +4400,13 @@ xlog_do_recover( | |||
4397 | XFS_BUF_READ(bp); | 4400 | XFS_BUF_READ(bp); |
4398 | XFS_BUF_UNASYNC(bp); | 4401 | XFS_BUF_UNASYNC(bp); |
4399 | bp->b_ops = &xfs_sb_buf_ops; | 4402 | bp->b_ops = &xfs_sb_buf_ops; |
4400 | xfsbdstrat(log->l_mp, bp); | 4403 | |
4404 | if (XFS_FORCED_SHUTDOWN(log->l_mp)) { | ||
4405 | xfs_buf_relse(bp); | ||
4406 | return XFS_ERROR(EIO); | ||
4407 | } | ||
4408 | |||
4409 | xfs_buf_iorequest(bp); | ||
4401 | error = xfs_buf_iowait(bp); | 4410 | error = xfs_buf_iowait(bp); |
4402 | if (error) { | 4411 | if (error) { |
4403 | xfs_buf_ioerror_alert(bp, __func__); | 4412 | xfs_buf_ioerror_alert(bp, __func__); |
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 14a4996cfec6..dd88f0e27bd8 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c | |||
@@ -134,8 +134,6 @@ xfs_qm_dqpurge( | |||
134 | { | 134 | { |
135 | struct xfs_mount *mp = dqp->q_mount; | 135 | struct xfs_mount *mp = dqp->q_mount; |
136 | struct xfs_quotainfo *qi = mp->m_quotainfo; | 136 | struct xfs_quotainfo *qi = mp->m_quotainfo; |
137 | struct xfs_dquot *gdqp = NULL; | ||
138 | struct xfs_dquot *pdqp = NULL; | ||
139 | 137 | ||
140 | xfs_dqlock(dqp); | 138 | xfs_dqlock(dqp); |
141 | if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) { | 139 | if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) { |
@@ -143,21 +141,6 @@ xfs_qm_dqpurge( | |||
143 | return EAGAIN; | 141 | return EAGAIN; |
144 | } | 142 | } |
145 | 143 | ||
146 | /* | ||
147 | * If this quota has a hint attached, prepare for releasing it now. | ||
148 | */ | ||
149 | gdqp = dqp->q_gdquot; | ||
150 | if (gdqp) { | ||
151 | xfs_dqlock(gdqp); | ||
152 | dqp->q_gdquot = NULL; | ||
153 | } | ||
154 | |||
155 | pdqp = dqp->q_pdquot; | ||
156 | if (pdqp) { | ||
157 | xfs_dqlock(pdqp); | ||
158 | dqp->q_pdquot = NULL; | ||
159 | } | ||
160 | |||
161 | dqp->dq_flags |= XFS_DQ_FREEING; | 144 | dqp->dq_flags |= XFS_DQ_FREEING; |
162 | 145 | ||
163 | xfs_dqflock(dqp); | 146 | xfs_dqflock(dqp); |
@@ -206,11 +189,47 @@ xfs_qm_dqpurge( | |||
206 | XFS_STATS_DEC(xs_qm_dquot_unused); | 189 | XFS_STATS_DEC(xs_qm_dquot_unused); |
207 | 190 | ||
208 | xfs_qm_dqdestroy(dqp); | 191 | xfs_qm_dqdestroy(dqp); |
192 | return 0; | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | * Release the group or project dquot pointers the user dquots maybe carrying | ||
197 | * around as a hint, and proceed to purge the user dquot cache if requested. | ||
198 | */ | ||
199 | STATIC int | ||
200 | xfs_qm_dqpurge_hints( | ||
201 | struct xfs_dquot *dqp, | ||
202 | void *data) | ||
203 | { | ||
204 | struct xfs_dquot *gdqp = NULL; | ||
205 | struct xfs_dquot *pdqp = NULL; | ||
206 | uint flags = *((uint *)data); | ||
207 | |||
208 | xfs_dqlock(dqp); | ||
209 | if (dqp->dq_flags & XFS_DQ_FREEING) { | ||
210 | xfs_dqunlock(dqp); | ||
211 | return EAGAIN; | ||
212 | } | ||
213 | |||
214 | /* If this quota has a hint attached, prepare for releasing it now */ | ||
215 | gdqp = dqp->q_gdquot; | ||
216 | if (gdqp) | ||
217 | dqp->q_gdquot = NULL; | ||
218 | |||
219 | pdqp = dqp->q_pdquot; | ||
220 | if (pdqp) | ||
221 | dqp->q_pdquot = NULL; | ||
222 | |||
223 | xfs_dqunlock(dqp); | ||
209 | 224 | ||
210 | if (gdqp) | 225 | if (gdqp) |
211 | xfs_qm_dqput(gdqp); | 226 | xfs_qm_dqrele(gdqp); |
212 | if (pdqp) | 227 | if (pdqp) |
213 | xfs_qm_dqput(pdqp); | 228 | xfs_qm_dqrele(pdqp); |
229 | |||
230 | if (flags & XFS_QMOPT_UQUOTA) | ||
231 | return xfs_qm_dqpurge(dqp, NULL); | ||
232 | |||
214 | return 0; | 233 | return 0; |
215 | } | 234 | } |
216 | 235 | ||
@@ -222,8 +241,18 @@ xfs_qm_dqpurge_all( | |||
222 | struct xfs_mount *mp, | 241 | struct xfs_mount *mp, |
223 | uint flags) | 242 | uint flags) |
224 | { | 243 | { |
225 | if (flags & XFS_QMOPT_UQUOTA) | 244 | /* |
226 | xfs_qm_dquot_walk(mp, XFS_DQ_USER, xfs_qm_dqpurge, NULL); | 245 | * We have to release group/project dquot hint(s) from the user dquot |
246 | * at first if they are there, otherwise we would run into an infinite | ||
247 | * loop while walking through radix tree to purge other type of dquots | ||
248 | * since their refcount is not zero if the user dquot refers to them | ||
249 | * as hint. | ||
250 | * | ||
251 | * Call the special xfs_qm_dqpurge_hints() will end up go through the | ||
252 | * general xfs_qm_dqpurge() against user dquot cache if requested. | ||
253 | */ | ||
254 | xfs_qm_dquot_walk(mp, XFS_DQ_USER, xfs_qm_dqpurge_hints, &flags); | ||
255 | |||
227 | if (flags & XFS_QMOPT_GQUOTA) | 256 | if (flags & XFS_QMOPT_GQUOTA) |
228 | xfs_qm_dquot_walk(mp, XFS_DQ_GROUP, xfs_qm_dqpurge, NULL); | 257 | xfs_qm_dquot_walk(mp, XFS_DQ_GROUP, xfs_qm_dqpurge, NULL); |
229 | if (flags & XFS_QMOPT_PQUOTA) | 258 | if (flags & XFS_QMOPT_PQUOTA) |
@@ -2082,24 +2111,21 @@ xfs_qm_vop_create_dqattach( | |||
2082 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 2111 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
2083 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); | 2112 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); |
2084 | 2113 | ||
2085 | if (udqp) { | 2114 | if (udqp && XFS_IS_UQUOTA_ON(mp)) { |
2086 | ASSERT(ip->i_udquot == NULL); | 2115 | ASSERT(ip->i_udquot == NULL); |
2087 | ASSERT(XFS_IS_UQUOTA_ON(mp)); | ||
2088 | ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); | 2116 | ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); |
2089 | 2117 | ||
2090 | ip->i_udquot = xfs_qm_dqhold(udqp); | 2118 | ip->i_udquot = xfs_qm_dqhold(udqp); |
2091 | xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); | 2119 | xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); |
2092 | } | 2120 | } |
2093 | if (gdqp) { | 2121 | if (gdqp && XFS_IS_GQUOTA_ON(mp)) { |
2094 | ASSERT(ip->i_gdquot == NULL); | 2122 | ASSERT(ip->i_gdquot == NULL); |
2095 | ASSERT(XFS_IS_GQUOTA_ON(mp)); | ||
2096 | ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id)); | 2123 | ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id)); |
2097 | ip->i_gdquot = xfs_qm_dqhold(gdqp); | 2124 | ip->i_gdquot = xfs_qm_dqhold(gdqp); |
2098 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); | 2125 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); |
2099 | } | 2126 | } |
2100 | if (pdqp) { | 2127 | if (pdqp && XFS_IS_PQUOTA_ON(mp)) { |
2101 | ASSERT(ip->i_pdquot == NULL); | 2128 | ASSERT(ip->i_pdquot == NULL); |
2102 | ASSERT(XFS_IS_PQUOTA_ON(mp)); | ||
2103 | ASSERT(xfs_get_projid(ip) == be32_to_cpu(pdqp->q_core.d_id)); | 2129 | ASSERT(xfs_get_projid(ip) == be32_to_cpu(pdqp->q_core.d_id)); |
2104 | 2130 | ||
2105 | ip->i_pdquot = xfs_qm_dqhold(pdqp); | 2131 | ip->i_pdquot = xfs_qm_dqhold(pdqp); |
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index c035d11b7734..647b6f1d8923 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
@@ -314,7 +314,18 @@ xfs_trans_read_buf_map( | |||
314 | ASSERT(bp->b_iodone == NULL); | 314 | ASSERT(bp->b_iodone == NULL); |
315 | XFS_BUF_READ(bp); | 315 | XFS_BUF_READ(bp); |
316 | bp->b_ops = ops; | 316 | bp->b_ops = ops; |
317 | xfsbdstrat(tp->t_mountp, bp); | 317 | |
318 | /* | ||
319 | * XXX(hch): clean up the error handling here to be less | ||
320 | * of a mess.. | ||
321 | */ | ||
322 | if (XFS_FORCED_SHUTDOWN(mp)) { | ||
323 | trace_xfs_bdstrat_shut(bp, _RET_IP_); | ||
324 | xfs_bioerror_relse(bp); | ||
325 | } else { | ||
326 | xfs_buf_iorequest(bp); | ||
327 | } | ||
328 | |||
318 | error = xfs_buf_iowait(bp); | 329 | error = xfs_buf_iowait(bp); |
319 | if (error) { | 330 | if (error) { |
320 | xfs_buf_ioerror_alert(bp, __func__); | 331 | xfs_buf_ioerror_alert(bp, __func__); |
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index f330d28e4d0e..db0923458940 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h | |||
@@ -217,7 +217,7 @@ static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b) | |||
217 | #endif | 217 | #endif |
218 | 218 | ||
219 | #ifndef pte_accessible | 219 | #ifndef pte_accessible |
220 | # define pte_accessible(pte) ((void)(pte),1) | 220 | # define pte_accessible(mm, pte) ((void)(pte), 1) |
221 | #endif | 221 | #endif |
222 | 222 | ||
223 | #ifndef flush_tlb_fix_spurious_fault | 223 | #ifndef flush_tlb_fix_spurious_fault |
@@ -599,11 +599,10 @@ static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd) | |||
599 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 599 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
600 | barrier(); | 600 | barrier(); |
601 | #endif | 601 | #endif |
602 | if (pmd_none(pmdval)) | 602 | if (pmd_none(pmdval) || pmd_trans_huge(pmdval)) |
603 | return 1; | 603 | return 1; |
604 | if (unlikely(pmd_bad(pmdval))) { | 604 | if (unlikely(pmd_bad(pmdval))) { |
605 | if (!pmd_trans_huge(pmdval)) | 605 | pmd_clear_bad(pmd); |
606 | pmd_clear_bad(pmd); | ||
607 | return 1; | 606 | return 1; |
608 | } | 607 | } |
609 | return 0; | 608 | return 0; |
diff --git a/include/asm-generic/preempt.h b/include/asm-generic/preempt.h index ddf2b420ac8f..1cd3f5d767a8 100644 --- a/include/asm-generic/preempt.h +++ b/include/asm-generic/preempt.h | |||
@@ -3,13 +3,11 @@ | |||
3 | 3 | ||
4 | #include <linux/thread_info.h> | 4 | #include <linux/thread_info.h> |
5 | 5 | ||
6 | /* | 6 | #define PREEMPT_ENABLED (0) |
7 | * We mask the PREEMPT_NEED_RESCHED bit so as not to confuse all current users | 7 | |
8 | * that think a non-zero value indicates we cannot preempt. | ||
9 | */ | ||
10 | static __always_inline int preempt_count(void) | 8 | static __always_inline int preempt_count(void) |
11 | { | 9 | { |
12 | return current_thread_info()->preempt_count & ~PREEMPT_NEED_RESCHED; | 10 | return current_thread_info()->preempt_count; |
13 | } | 11 | } |
14 | 12 | ||
15 | static __always_inline int *preempt_count_ptr(void) | 13 | static __always_inline int *preempt_count_ptr(void) |
@@ -17,11 +15,6 @@ static __always_inline int *preempt_count_ptr(void) | |||
17 | return ¤t_thread_info()->preempt_count; | 15 | return ¤t_thread_info()->preempt_count; |
18 | } | 16 | } |
19 | 17 | ||
20 | /* | ||
21 | * We now loose PREEMPT_NEED_RESCHED and cause an extra reschedule; however the | ||
22 | * alternative is loosing a reschedule. Better schedule too often -- also this | ||
23 | * should be a very rare operation. | ||
24 | */ | ||
25 | static __always_inline void preempt_count_set(int pc) | 18 | static __always_inline void preempt_count_set(int pc) |
26 | { | 19 | { |
27 | *preempt_count_ptr() = pc; | 20 | *preempt_count_ptr() = pc; |
@@ -41,28 +34,17 @@ static __always_inline void preempt_count_set(int pc) | |||
41 | task_thread_info(p)->preempt_count = PREEMPT_ENABLED; \ | 34 | task_thread_info(p)->preempt_count = PREEMPT_ENABLED; \ |
42 | } while (0) | 35 | } while (0) |
43 | 36 | ||
44 | /* | ||
45 | * We fold the NEED_RESCHED bit into the preempt count such that | ||
46 | * preempt_enable() can decrement and test for needing to reschedule with a | ||
47 | * single instruction. | ||
48 | * | ||
49 | * We invert the actual bit, so that when the decrement hits 0 we know we both | ||
50 | * need to resched (the bit is cleared) and can resched (no preempt count). | ||
51 | */ | ||
52 | |||
53 | static __always_inline void set_preempt_need_resched(void) | 37 | static __always_inline void set_preempt_need_resched(void) |
54 | { | 38 | { |
55 | *preempt_count_ptr() &= ~PREEMPT_NEED_RESCHED; | ||
56 | } | 39 | } |
57 | 40 | ||
58 | static __always_inline void clear_preempt_need_resched(void) | 41 | static __always_inline void clear_preempt_need_resched(void) |
59 | { | 42 | { |
60 | *preempt_count_ptr() |= PREEMPT_NEED_RESCHED; | ||
61 | } | 43 | } |
62 | 44 | ||
63 | static __always_inline bool test_preempt_need_resched(void) | 45 | static __always_inline bool test_preempt_need_resched(void) |
64 | { | 46 | { |
65 | return !(*preempt_count_ptr() & PREEMPT_NEED_RESCHED); | 47 | return false; |
66 | } | 48 | } |
67 | 49 | ||
68 | /* | 50 | /* |
@@ -81,7 +63,12 @@ static __always_inline void __preempt_count_sub(int val) | |||
81 | 63 | ||
82 | static __always_inline bool __preempt_count_dec_and_test(void) | 64 | static __always_inline bool __preempt_count_dec_and_test(void) |
83 | { | 65 | { |
84 | return !--*preempt_count_ptr(); | 66 | /* |
67 | * Because of load-store architectures cannot do per-cpu atomic | ||
68 | * operations; we cannot use PREEMPT_NEED_RESCHED because it might get | ||
69 | * lost. | ||
70 | */ | ||
71 | return !--*preempt_count_ptr() && tif_need_resched(); | ||
85 | } | 72 | } |
86 | 73 | ||
87 | /* | 74 | /* |
@@ -89,7 +76,7 @@ static __always_inline bool __preempt_count_dec_and_test(void) | |||
89 | */ | 76 | */ |
90 | static __always_inline bool should_resched(void) | 77 | static __always_inline bool should_resched(void) |
91 | { | 78 | { |
92 | return unlikely(!*preempt_count_ptr()); | 79 | return unlikely(!preempt_count() && tif_need_resched()); |
93 | } | 80 | } |
94 | 81 | ||
95 | #ifdef CONFIG_PREEMPT | 82 | #ifdef CONFIG_PREEMPT |
diff --git a/include/linux/auxvec.h b/include/linux/auxvec.h index 669fef5c745a..3e0fbe441763 100644 --- a/include/linux/auxvec.h +++ b/include/linux/auxvec.h | |||
@@ -3,6 +3,6 @@ | |||
3 | 3 | ||
4 | #include <uapi/linux/auxvec.h> | 4 | #include <uapi/linux/auxvec.h> |
5 | 5 | ||
6 | #define AT_VECTOR_SIZE_BASE 19 /* NEW_AUX_ENT entries in auxiliary table */ | 6 | #define AT_VECTOR_SIZE_BASE 20 /* NEW_AUX_ENT entries in auxiliary table */ |
7 | /* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */ | 7 | /* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */ |
8 | #endif /* _LINUX_AUXVEC_H */ | 8 | #endif /* _LINUX_AUXVEC_H */ |
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 41cf0c399288..ed92b30a02fd 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #define LINUX_DMAENGINE_H | 22 | #define LINUX_DMAENGINE_H |
23 | 23 | ||
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include <linux/err.h> | ||
25 | #include <linux/uio.h> | 26 | #include <linux/uio.h> |
26 | #include <linux/bug.h> | 27 | #include <linux/bug.h> |
27 | #include <linux/scatterlist.h> | 28 | #include <linux/scatterlist.h> |
@@ -1040,6 +1041,8 @@ enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx); | |||
1040 | void dma_issue_pending_all(void); | 1041 | void dma_issue_pending_all(void); |
1041 | struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask, | 1042 | struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask, |
1042 | dma_filter_fn fn, void *fn_param); | 1043 | dma_filter_fn fn, void *fn_param); |
1044 | struct dma_chan *dma_request_slave_channel_reason(struct device *dev, | ||
1045 | const char *name); | ||
1043 | struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name); | 1046 | struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name); |
1044 | void dma_release_channel(struct dma_chan *chan); | 1047 | void dma_release_channel(struct dma_chan *chan); |
1045 | #else | 1048 | #else |
@@ -1063,6 +1066,11 @@ static inline struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask, | |||
1063 | { | 1066 | { |
1064 | return NULL; | 1067 | return NULL; |
1065 | } | 1068 | } |
1069 | static inline struct dma_chan *dma_request_slave_channel_reason( | ||
1070 | struct device *dev, const char *name) | ||
1071 | { | ||
1072 | return ERR_PTR(-ENODEV); | ||
1073 | } | ||
1066 | static inline struct dma_chan *dma_request_slave_channel(struct device *dev, | 1074 | static inline struct dma_chan *dma_request_slave_channel(struct device *dev, |
1067 | const char *name) | 1075 | const char *name) |
1068 | { | 1076 | { |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 0e23c26485f4..9b503376738f 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -418,6 +418,7 @@ enum { | |||
418 | ATA_HORKAGE_DUMP_ID = (1 << 16), /* dump IDENTIFY data */ | 418 | ATA_HORKAGE_DUMP_ID = (1 << 16), /* dump IDENTIFY data */ |
419 | ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17), /* Set max sects to 65535 */ | 419 | ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17), /* Set max sects to 65535 */ |
420 | ATA_HORKAGE_ATAPI_DMADIR = (1 << 18), /* device requires dmadir */ | 420 | ATA_HORKAGE_ATAPI_DMADIR = (1 << 18), /* device requires dmadir */ |
421 | ATA_HORKAGE_NO_NCQ_TRIM = (1 << 19), /* don't use queued TRIM */ | ||
421 | 422 | ||
422 | /* DMA mask for user DMA control: User visible values; DO NOT | 423 | /* DMA mask for user DMA control: User visible values; DO NOT |
423 | renumber */ | 424 | renumber */ |
diff --git a/include/linux/lockref.h b/include/linux/lockref.h index c8929c3832db..4bfde0e99ed5 100644 --- a/include/linux/lockref.h +++ b/include/linux/lockref.h | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | #define USE_CMPXCHG_LOCKREF \ | 20 | #define USE_CMPXCHG_LOCKREF \ |
21 | (IS_ENABLED(CONFIG_ARCH_USE_CMPXCHG_LOCKREF) && \ | 21 | (IS_ENABLED(CONFIG_ARCH_USE_CMPXCHG_LOCKREF) && \ |
22 | IS_ENABLED(CONFIG_SMP) && !BLOATED_SPINLOCKS) | 22 | IS_ENABLED(CONFIG_SMP) && SPINLOCK_SIZE <= 4) |
23 | 23 | ||
24 | struct lockref { | 24 | struct lockref { |
25 | union { | 25 | union { |
diff --git a/include/linux/math64.h b/include/linux/math64.h index 69ed5f5e9f6e..c45c089bfdac 100644 --- a/include/linux/math64.h +++ b/include/linux/math64.h | |||
@@ -133,4 +133,34 @@ __iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder) | |||
133 | return ret; | 133 | return ret; |
134 | } | 134 | } |
135 | 135 | ||
136 | #if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__) | ||
137 | |||
138 | #ifndef mul_u64_u32_shr | ||
139 | static inline u64 mul_u64_u32_shr(u64 a, u32 mul, unsigned int shift) | ||
140 | { | ||
141 | return (u64)(((unsigned __int128)a * mul) >> shift); | ||
142 | } | ||
143 | #endif /* mul_u64_u32_shr */ | ||
144 | |||
145 | #else | ||
146 | |||
147 | #ifndef mul_u64_u32_shr | ||
148 | static inline u64 mul_u64_u32_shr(u64 a, u32 mul, unsigned int shift) | ||
149 | { | ||
150 | u32 ah, al; | ||
151 | u64 ret; | ||
152 | |||
153 | al = a; | ||
154 | ah = a >> 32; | ||
155 | |||
156 | ret = ((u64)al * mul) >> shift; | ||
157 | if (ah) | ||
158 | ret += ((u64)ah * mul) << (32 - shift); | ||
159 | |||
160 | return ret; | ||
161 | } | ||
162 | #endif /* mul_u64_u32_shr */ | ||
163 | |||
164 | #endif | ||
165 | |||
136 | #endif /* _LINUX_MATH64_H */ | 166 | #endif /* _LINUX_MATH64_H */ |
diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h index cb49417f8ba9..22916c0f1ca4 100644 --- a/include/linux/mfd/arizona/registers.h +++ b/include/linux/mfd/arizona/registers.h | |||
@@ -139,6 +139,7 @@ | |||
139 | #define ARIZONA_INPUT_ENABLES_STATUS 0x301 | 139 | #define ARIZONA_INPUT_ENABLES_STATUS 0x301 |
140 | #define ARIZONA_INPUT_RATE 0x308 | 140 | #define ARIZONA_INPUT_RATE 0x308 |
141 | #define ARIZONA_INPUT_VOLUME_RAMP 0x309 | 141 | #define ARIZONA_INPUT_VOLUME_RAMP 0x309 |
142 | #define ARIZONA_HPF_CONTROL 0x30C | ||
142 | #define ARIZONA_IN1L_CONTROL 0x310 | 143 | #define ARIZONA_IN1L_CONTROL 0x310 |
143 | #define ARIZONA_ADC_DIGITAL_VOLUME_1L 0x311 | 144 | #define ARIZONA_ADC_DIGITAL_VOLUME_1L 0x311 |
144 | #define ARIZONA_DMIC1L_CONTROL 0x312 | 145 | #define ARIZONA_DMIC1L_CONTROL 0x312 |
@@ -160,6 +161,7 @@ | |||
160 | #define ARIZONA_IN4L_CONTROL 0x328 | 161 | #define ARIZONA_IN4L_CONTROL 0x328 |
161 | #define ARIZONA_ADC_DIGITAL_VOLUME_4L 0x329 | 162 | #define ARIZONA_ADC_DIGITAL_VOLUME_4L 0x329 |
162 | #define ARIZONA_DMIC4L_CONTROL 0x32A | 163 | #define ARIZONA_DMIC4L_CONTROL 0x32A |
164 | #define ARIZONA_IN4R_CONTROL 0x32C | ||
163 | #define ARIZONA_ADC_DIGITAL_VOLUME_4R 0x32D | 165 | #define ARIZONA_ADC_DIGITAL_VOLUME_4R 0x32D |
164 | #define ARIZONA_DMIC4R_CONTROL 0x32E | 166 | #define ARIZONA_DMIC4R_CONTROL 0x32E |
165 | #define ARIZONA_OUTPUT_ENABLES_1 0x400 | 167 | #define ARIZONA_OUTPUT_ENABLES_1 0x400 |
@@ -511,6 +513,38 @@ | |||
511 | #define ARIZONA_AIF2TX2MIX_INPUT_3_VOLUME 0x74D | 513 | #define ARIZONA_AIF2TX2MIX_INPUT_3_VOLUME 0x74D |
512 | #define ARIZONA_AIF2TX2MIX_INPUT_4_SOURCE 0x74E | 514 | #define ARIZONA_AIF2TX2MIX_INPUT_4_SOURCE 0x74E |
513 | #define ARIZONA_AIF2TX2MIX_INPUT_4_VOLUME 0x74F | 515 | #define ARIZONA_AIF2TX2MIX_INPUT_4_VOLUME 0x74F |
516 | #define ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE 0x750 | ||
517 | #define ARIZONA_AIF2TX3MIX_INPUT_1_VOLUME 0x751 | ||
518 | #define ARIZONA_AIF2TX3MIX_INPUT_2_SOURCE 0x752 | ||
519 | #define ARIZONA_AIF2TX3MIX_INPUT_2_VOLUME 0x753 | ||
520 | #define ARIZONA_AIF2TX3MIX_INPUT_3_SOURCE 0x754 | ||
521 | #define ARIZONA_AIF2TX3MIX_INPUT_3_VOLUME 0x755 | ||
522 | #define ARIZONA_AIF2TX3MIX_INPUT_4_SOURCE 0x756 | ||
523 | #define ARIZONA_AIF2TX3MIX_INPUT_4_VOLUME 0x757 | ||
524 | #define ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE 0x758 | ||
525 | #define ARIZONA_AIF2TX4MIX_INPUT_1_VOLUME 0x759 | ||
526 | #define ARIZONA_AIF2TX4MIX_INPUT_2_SOURCE 0x75A | ||
527 | #define ARIZONA_AIF2TX4MIX_INPUT_2_VOLUME 0x75B | ||
528 | #define ARIZONA_AIF2TX4MIX_INPUT_3_SOURCE 0x75C | ||
529 | #define ARIZONA_AIF2TX4MIX_INPUT_3_VOLUME 0x75D | ||
530 | #define ARIZONA_AIF2TX4MIX_INPUT_4_SOURCE 0x75E | ||
531 | #define ARIZONA_AIF2TX4MIX_INPUT_4_VOLUME 0x75F | ||
532 | #define ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE 0x760 | ||
533 | #define ARIZONA_AIF2TX5MIX_INPUT_1_VOLUME 0x761 | ||
534 | #define ARIZONA_AIF2TX5MIX_INPUT_2_SOURCE 0x762 | ||
535 | #define ARIZONA_AIF2TX5MIX_INPUT_2_VOLUME 0x763 | ||
536 | #define ARIZONA_AIF2TX5MIX_INPUT_3_SOURCE 0x764 | ||
537 | #define ARIZONA_AIF2TX5MIX_INPUT_3_VOLUME 0x765 | ||
538 | #define ARIZONA_AIF2TX5MIX_INPUT_4_SOURCE 0x766 | ||
539 | #define ARIZONA_AIF2TX5MIX_INPUT_4_VOLUME 0x767 | ||
540 | #define ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE 0x768 | ||
541 | #define ARIZONA_AIF2TX6MIX_INPUT_1_VOLUME 0x769 | ||
542 | #define ARIZONA_AIF2TX6MIX_INPUT_2_SOURCE 0x76A | ||
543 | #define ARIZONA_AIF2TX6MIX_INPUT_2_VOLUME 0x76B | ||
544 | #define ARIZONA_AIF2TX6MIX_INPUT_3_SOURCE 0x76C | ||
545 | #define ARIZONA_AIF2TX6MIX_INPUT_3_VOLUME 0x76D | ||
546 | #define ARIZONA_AIF2TX6MIX_INPUT_4_SOURCE 0x76E | ||
547 | #define ARIZONA_AIF2TX6MIX_INPUT_4_VOLUME 0x76F | ||
514 | #define ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE 0x780 | 548 | #define ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE 0x780 |
515 | #define ARIZONA_AIF3TX1MIX_INPUT_1_VOLUME 0x781 | 549 | #define ARIZONA_AIF3TX1MIX_INPUT_1_VOLUME 0x781 |
516 | #define ARIZONA_AIF3TX1MIX_INPUT_2_SOURCE 0x782 | 550 | #define ARIZONA_AIF3TX1MIX_INPUT_2_SOURCE 0x782 |
@@ -2293,8 +2327,18 @@ | |||
2293 | #define ARIZONA_IN_VI_RAMP_WIDTH 3 /* IN_VI_RAMP - [2:0] */ | 2327 | #define ARIZONA_IN_VI_RAMP_WIDTH 3 /* IN_VI_RAMP - [2:0] */ |
2294 | 2328 | ||
2295 | /* | 2329 | /* |
2330 | * R780 (0x30C) - HPF Control | ||
2331 | */ | ||
2332 | #define ARIZONA_IN_HPF_CUT_MASK 0x0007 /* IN_HPF_CUT [2:0] */ | ||
2333 | #define ARIZONA_IN_HPF_CUT_SHIFT 0 /* IN_HPF_CUT [2:0] */ | ||
2334 | #define ARIZONA_IN_HPF_CUT_WIDTH 3 /* IN_HPF_CUT [2:0] */ | ||
2335 | |||
2336 | /* | ||
2296 | * R784 (0x310) - IN1L Control | 2337 | * R784 (0x310) - IN1L Control |
2297 | */ | 2338 | */ |
2339 | #define ARIZONA_IN1L_HPF_MASK 0x8000 /* IN1L_HPF - [15] */ | ||
2340 | #define ARIZONA_IN1L_HPF_SHIFT 15 /* IN1L_HPF - [15] */ | ||
2341 | #define ARIZONA_IN1L_HPF_WIDTH 1 /* IN1L_HPF - [15] */ | ||
2298 | #define ARIZONA_IN1_OSR_MASK 0x6000 /* IN1_OSR - [14:13] */ | 2342 | #define ARIZONA_IN1_OSR_MASK 0x6000 /* IN1_OSR - [14:13] */ |
2299 | #define ARIZONA_IN1_OSR_SHIFT 13 /* IN1_OSR - [14:13] */ | 2343 | #define ARIZONA_IN1_OSR_SHIFT 13 /* IN1_OSR - [14:13] */ |
2300 | #define ARIZONA_IN1_OSR_WIDTH 2 /* IN1_OSR - [14:13] */ | 2344 | #define ARIZONA_IN1_OSR_WIDTH 2 /* IN1_OSR - [14:13] */ |
@@ -2333,6 +2377,9 @@ | |||
2333 | /* | 2377 | /* |
2334 | * R788 (0x314) - IN1R Control | 2378 | * R788 (0x314) - IN1R Control |
2335 | */ | 2379 | */ |
2380 | #define ARIZONA_IN1R_HPF_MASK 0x8000 /* IN1R_HPF - [15] */ | ||
2381 | #define ARIZONA_IN1R_HPF_SHIFT 15 /* IN1R_HPF - [15] */ | ||
2382 | #define ARIZONA_IN1R_HPF_WIDTH 1 /* IN1R_HPF - [15] */ | ||
2336 | #define ARIZONA_IN1R_PGA_VOL_MASK 0x00FE /* IN1R_PGA_VOL - [7:1] */ | 2383 | #define ARIZONA_IN1R_PGA_VOL_MASK 0x00FE /* IN1R_PGA_VOL - [7:1] */ |
2337 | #define ARIZONA_IN1R_PGA_VOL_SHIFT 1 /* IN1R_PGA_VOL - [7:1] */ | 2384 | #define ARIZONA_IN1R_PGA_VOL_SHIFT 1 /* IN1R_PGA_VOL - [7:1] */ |
2338 | #define ARIZONA_IN1R_PGA_VOL_WIDTH 7 /* IN1R_PGA_VOL - [7:1] */ | 2385 | #define ARIZONA_IN1R_PGA_VOL_WIDTH 7 /* IN1R_PGA_VOL - [7:1] */ |
@@ -2362,6 +2409,9 @@ | |||
2362 | /* | 2409 | /* |
2363 | * R792 (0x318) - IN2L Control | 2410 | * R792 (0x318) - IN2L Control |
2364 | */ | 2411 | */ |
2412 | #define ARIZONA_IN2L_HPF_MASK 0x8000 /* IN2L_HPF - [15] */ | ||
2413 | #define ARIZONA_IN2L_HPF_SHIFT 15 /* IN2L_HPF - [15] */ | ||
2414 | #define ARIZONA_IN2L_HPF_WIDTH 1 /* IN2L_HPF - [15] */ | ||
2365 | #define ARIZONA_IN2_OSR_MASK 0x6000 /* IN2_OSR - [14:13] */ | 2415 | #define ARIZONA_IN2_OSR_MASK 0x6000 /* IN2_OSR - [14:13] */ |
2366 | #define ARIZONA_IN2_OSR_SHIFT 13 /* IN2_OSR - [14:13] */ | 2416 | #define ARIZONA_IN2_OSR_SHIFT 13 /* IN2_OSR - [14:13] */ |
2367 | #define ARIZONA_IN2_OSR_WIDTH 2 /* IN2_OSR - [14:13] */ | 2417 | #define ARIZONA_IN2_OSR_WIDTH 2 /* IN2_OSR - [14:13] */ |
@@ -2400,6 +2450,9 @@ | |||
2400 | /* | 2450 | /* |
2401 | * R796 (0x31C) - IN2R Control | 2451 | * R796 (0x31C) - IN2R Control |
2402 | */ | 2452 | */ |
2453 | #define ARIZONA_IN2R_HPF_MASK 0x8000 /* IN2R_HPF - [15] */ | ||
2454 | #define ARIZONA_IN2R_HPF_SHIFT 15 /* IN2R_HPF - [15] */ | ||
2455 | #define ARIZONA_IN2R_HPF_WIDTH 1 /* IN2R_HPF - [15] */ | ||
2403 | #define ARIZONA_IN2R_PGA_VOL_MASK 0x00FE /* IN2R_PGA_VOL - [7:1] */ | 2456 | #define ARIZONA_IN2R_PGA_VOL_MASK 0x00FE /* IN2R_PGA_VOL - [7:1] */ |
2404 | #define ARIZONA_IN2R_PGA_VOL_SHIFT 1 /* IN2R_PGA_VOL - [7:1] */ | 2457 | #define ARIZONA_IN2R_PGA_VOL_SHIFT 1 /* IN2R_PGA_VOL - [7:1] */ |
2405 | #define ARIZONA_IN2R_PGA_VOL_WIDTH 7 /* IN2R_PGA_VOL - [7:1] */ | 2458 | #define ARIZONA_IN2R_PGA_VOL_WIDTH 7 /* IN2R_PGA_VOL - [7:1] */ |
@@ -2429,6 +2482,9 @@ | |||
2429 | /* | 2482 | /* |
2430 | * R800 (0x320) - IN3L Control | 2483 | * R800 (0x320) - IN3L Control |
2431 | */ | 2484 | */ |
2485 | #define ARIZONA_IN3L_HPF_MASK 0x8000 /* IN3L_HPF - [15] */ | ||
2486 | #define ARIZONA_IN3L_HPF_SHIFT 15 /* IN3L_HPF - [15] */ | ||
2487 | #define ARIZONA_IN3L_HPF_WIDTH 1 /* IN3L_HPF - [15] */ | ||
2432 | #define ARIZONA_IN3_OSR_MASK 0x6000 /* IN3_OSR - [14:13] */ | 2488 | #define ARIZONA_IN3_OSR_MASK 0x6000 /* IN3_OSR - [14:13] */ |
2433 | #define ARIZONA_IN3_OSR_SHIFT 13 /* IN3_OSR - [14:13] */ | 2489 | #define ARIZONA_IN3_OSR_SHIFT 13 /* IN3_OSR - [14:13] */ |
2434 | #define ARIZONA_IN3_OSR_WIDTH 2 /* IN3_OSR - [14:13] */ | 2490 | #define ARIZONA_IN3_OSR_WIDTH 2 /* IN3_OSR - [14:13] */ |
@@ -2467,6 +2523,9 @@ | |||
2467 | /* | 2523 | /* |
2468 | * R804 (0x324) - IN3R Control | 2524 | * R804 (0x324) - IN3R Control |
2469 | */ | 2525 | */ |
2526 | #define ARIZONA_IN3R_HPF_MASK 0x8000 /* IN3R_HPF - [15] */ | ||
2527 | #define ARIZONA_IN3R_HPF_SHIFT 15 /* IN3R_HPF - [15] */ | ||
2528 | #define ARIZONA_IN3R_HPF_WIDTH 1 /* IN3R_HPF - [15] */ | ||
2470 | #define ARIZONA_IN3R_PGA_VOL_MASK 0x00FE /* IN3R_PGA_VOL - [7:1] */ | 2529 | #define ARIZONA_IN3R_PGA_VOL_MASK 0x00FE /* IN3R_PGA_VOL - [7:1] */ |
2471 | #define ARIZONA_IN3R_PGA_VOL_SHIFT 1 /* IN3R_PGA_VOL - [7:1] */ | 2530 | #define ARIZONA_IN3R_PGA_VOL_SHIFT 1 /* IN3R_PGA_VOL - [7:1] */ |
2472 | #define ARIZONA_IN3R_PGA_VOL_WIDTH 7 /* IN3R_PGA_VOL - [7:1] */ | 2531 | #define ARIZONA_IN3R_PGA_VOL_WIDTH 7 /* IN3R_PGA_VOL - [7:1] */ |
@@ -2496,6 +2555,9 @@ | |||
2496 | /* | 2555 | /* |
2497 | * R808 (0x328) - IN4 Control | 2556 | * R808 (0x328) - IN4 Control |
2498 | */ | 2557 | */ |
2558 | #define ARIZONA_IN4L_HPF_MASK 0x8000 /* IN4L_HPF - [15] */ | ||
2559 | #define ARIZONA_IN4L_HPF_SHIFT 15 /* IN4L_HPF - [15] */ | ||
2560 | #define ARIZONA_IN4L_HPF_WIDTH 1 /* IN4L_HPF - [15] */ | ||
2499 | #define ARIZONA_IN4_OSR_MASK 0x6000 /* IN4_OSR - [14:13] */ | 2561 | #define ARIZONA_IN4_OSR_MASK 0x6000 /* IN4_OSR - [14:13] */ |
2500 | #define ARIZONA_IN4_OSR_SHIFT 13 /* IN4_OSR - [14:13] */ | 2562 | #define ARIZONA_IN4_OSR_SHIFT 13 /* IN4_OSR - [14:13] */ |
2501 | #define ARIZONA_IN4_OSR_WIDTH 2 /* IN4_OSR - [14:13] */ | 2563 | #define ARIZONA_IN4_OSR_WIDTH 2 /* IN4_OSR - [14:13] */ |
@@ -2526,6 +2588,13 @@ | |||
2526 | #define ARIZONA_IN4L_DMIC_DLY_WIDTH 6 /* IN4L_DMIC_DLY - [5:0] */ | 2588 | #define ARIZONA_IN4L_DMIC_DLY_WIDTH 6 /* IN4L_DMIC_DLY - [5:0] */ |
2527 | 2589 | ||
2528 | /* | 2590 | /* |
2591 | * R812 (0x32C) - IN4R Control | ||
2592 | */ | ||
2593 | #define ARIZONA_IN4R_HPF_MASK 0x8000 /* IN4R_HPF - [15] */ | ||
2594 | #define ARIZONA_IN4R_HPF_SHIFT 15 /* IN4R_HPF - [15] */ | ||
2595 | #define ARIZONA_IN4R_HPF_WIDTH 1 /* IN4R_HPF - [15] */ | ||
2596 | |||
2597 | /* | ||
2529 | * R813 (0x32D) - ADC Digital Volume 4R | 2598 | * R813 (0x32D) - ADC Digital Volume 4R |
2530 | */ | 2599 | */ |
2531 | #define ARIZONA_IN_VU 0x0200 /* IN_VU */ | 2600 | #define ARIZONA_IN_VU 0x0200 /* IN_VU */ |
@@ -3138,6 +3207,10 @@ | |||
3138 | /* | 3207 | /* |
3139 | * R1088 (0x440) - DRE Enable | 3208 | * R1088 (0x440) - DRE Enable |
3140 | */ | 3209 | */ |
3210 | #define ARIZONA_DRE3R_ENA 0x0020 /* DRE3R_ENA */ | ||
3211 | #define ARIZONA_DRE3R_ENA_MASK 0x0020 /* DRE3R_ENA */ | ||
3212 | #define ARIZONA_DRE3R_ENA_SHIFT 5 /* DRE3R_ENA */ | ||
3213 | #define ARIZONA_DRE3R_ENA_WIDTH 1 /* DRE3R_ENA */ | ||
3141 | #define ARIZONA_DRE3L_ENA 0x0010 /* DRE3L_ENA */ | 3214 | #define ARIZONA_DRE3L_ENA 0x0010 /* DRE3L_ENA */ |
3142 | #define ARIZONA_DRE3L_ENA_MASK 0x0010 /* DRE3L_ENA */ | 3215 | #define ARIZONA_DRE3L_ENA_MASK 0x0010 /* DRE3L_ENA */ |
3143 | #define ARIZONA_DRE3L_ENA_SHIFT 4 /* DRE3L_ENA */ | 3216 | #define ARIZONA_DRE3L_ENA_SHIFT 4 /* DRE3L_ENA */ |
@@ -3726,6 +3799,35 @@ | |||
3726 | #define ARIZONA_AIF2TX2_SLOT_WIDTH 6 /* AIF2TX2_SLOT - [5:0] */ | 3799 | #define ARIZONA_AIF2TX2_SLOT_WIDTH 6 /* AIF2TX2_SLOT - [5:0] */ |
3727 | 3800 | ||
3728 | /* | 3801 | /* |
3802 | * R1355 (0x54B) - AIF2 Frame Ctrl 5 | ||
3803 | */ | ||
3804 | #define ARIZONA_AIF2TX3_SLOT_MASK 0x003F /* AIF2TX3_SLOT - [5:0] */ | ||
3805 | #define ARIZONA_AIF2TX3_SLOT_SHIFT 0 /* AIF2TX3_SLOT - [5:0] */ | ||
3806 | #define ARIZONA_AIF2TX3_SLOT_WIDTH 6 /* AIF2TX3_SLOT - [5:0] */ | ||
3807 | |||
3808 | /* | ||
3809 | * R1356 (0x54C) - AIF2 Frame Ctrl 6 | ||
3810 | */ | ||
3811 | #define ARIZONA_AIF2TX4_SLOT_MASK 0x003F /* AIF2TX4_SLOT - [5:0] */ | ||
3812 | #define ARIZONA_AIF2TX4_SLOT_SHIFT 0 /* AIF2TX4_SLOT - [5:0] */ | ||
3813 | #define ARIZONA_AIF2TX4_SLOT_WIDTH 6 /* AIF2TX4_SLOT - [5:0] */ | ||
3814 | |||
3815 | |||
3816 | /* | ||
3817 | * R1357 (0x54D) - AIF2 Frame Ctrl 7 | ||
3818 | */ | ||
3819 | #define ARIZONA_AIF2TX5_SLOT_MASK 0x003F /* AIF2TX5_SLOT - [5:0] */ | ||
3820 | #define ARIZONA_AIF2TX5_SLOT_SHIFT 0 /* AIF2TX5_SLOT - [5:0] */ | ||
3821 | #define ARIZONA_AIF2TX5_SLOT_WIDTH 6 /* AIF2TX5_SLOT - [5:0] */ | ||
3822 | |||
3823 | /* | ||
3824 | * R1358 (0x54E) - AIF2 Frame Ctrl 8 | ||
3825 | */ | ||
3826 | #define ARIZONA_AIF2TX6_SLOT_MASK 0x003F /* AIF2TX6_SLOT - [5:0] */ | ||
3827 | #define ARIZONA_AIF2TX6_SLOT_SHIFT 0 /* AIF2TX6_SLOT - [5:0] */ | ||
3828 | #define ARIZONA_AIF2TX6_SLOT_WIDTH 6 /* AIF2TX6_SLOT - [5:0] */ | ||
3829 | |||
3830 | /* | ||
3729 | * R1361 (0x551) - AIF2 Frame Ctrl 11 | 3831 | * R1361 (0x551) - AIF2 Frame Ctrl 11 |
3730 | */ | 3832 | */ |
3731 | #define ARIZONA_AIF2RX1_SLOT_MASK 0x003F /* AIF2RX1_SLOT - [5:0] */ | 3833 | #define ARIZONA_AIF2RX1_SLOT_MASK 0x003F /* AIF2RX1_SLOT - [5:0] */ |
@@ -3740,8 +3842,52 @@ | |||
3740 | #define ARIZONA_AIF2RX2_SLOT_WIDTH 6 /* AIF2RX2_SLOT - [5:0] */ | 3842 | #define ARIZONA_AIF2RX2_SLOT_WIDTH 6 /* AIF2RX2_SLOT - [5:0] */ |
3741 | 3843 | ||
3742 | /* | 3844 | /* |
3845 | * R1363 (0x553) - AIF2 Frame Ctrl 13 | ||
3846 | */ | ||
3847 | #define ARIZONA_AIF2RX3_SLOT_MASK 0x003F /* AIF2RX3_SLOT - [5:0] */ | ||
3848 | #define ARIZONA_AIF2RX3_SLOT_SHIFT 0 /* AIF2RX3_SLOT - [5:0] */ | ||
3849 | #define ARIZONA_AIF2RX3_SLOT_WIDTH 6 /* AIF2RX3_SLOT - [5:0] */ | ||
3850 | |||
3851 | /* | ||
3852 | * R1364 (0x554) - AIF2 Frame Ctrl 14 | ||
3853 | */ | ||
3854 | #define ARIZONA_AIF2RX4_SLOT_MASK 0x003F /* AIF2RX4_SLOT - [5:0] */ | ||
3855 | #define ARIZONA_AIF2RX4_SLOT_SHIFT 0 /* AIF2RX4_SLOT - [5:0] */ | ||
3856 | #define ARIZONA_AIF2RX4_SLOT_WIDTH 6 /* AIF2RX4_SLOT - [5:0] */ | ||
3857 | |||
3858 | /* | ||
3859 | * R1365 (0x555) - AIF2 Frame Ctrl 15 | ||
3860 | */ | ||
3861 | #define ARIZONA_AIF2RX5_SLOT_MASK 0x003F /* AIF2RX5_SLOT - [5:0] */ | ||
3862 | #define ARIZONA_AIF2RX5_SLOT_SHIFT 0 /* AIF2RX5_SLOT - [5:0] */ | ||
3863 | #define ARIZONA_AIF2RX5_SLOT_WIDTH 6 /* AIF2RX5_SLOT - [5:0] */ | ||
3864 | |||
3865 | /* | ||
3866 | * R1366 (0x556) - AIF2 Frame Ctrl 16 | ||
3867 | */ | ||
3868 | #define ARIZONA_AIF2RX6_SLOT_MASK 0x003F /* AIF2RX6_SLOT - [5:0] */ | ||
3869 | #define ARIZONA_AIF2RX6_SLOT_SHIFT 0 /* AIF2RX6_SLOT - [5:0] */ | ||
3870 | #define ARIZONA_AIF2RX6_SLOT_WIDTH 6 /* AIF2RX6_SLOT - [5:0] */ | ||
3871 | |||
3872 | /* | ||
3743 | * R1369 (0x559) - AIF2 Tx Enables | 3873 | * R1369 (0x559) - AIF2 Tx Enables |
3744 | */ | 3874 | */ |
3875 | #define ARIZONA_AIF2TX6_ENA 0x0020 /* AIF2TX6_ENA */ | ||
3876 | #define ARIZONA_AIF2TX6_ENA_MASK 0x0020 /* AIF2TX6_ENA */ | ||
3877 | #define ARIZONA_AIF2TX6_ENA_SHIFT 5 /* AIF2TX6_ENA */ | ||
3878 | #define ARIZONA_AIF2TX6_ENA_WIDTH 1 /* AIF2TX6_ENA */ | ||
3879 | #define ARIZONA_AIF2TX5_ENA 0x0010 /* AIF2TX5_ENA */ | ||
3880 | #define ARIZONA_AIF2TX5_ENA_MASK 0x0010 /* AIF2TX5_ENA */ | ||
3881 | #define ARIZONA_AIF2TX5_ENA_SHIFT 4 /* AIF2TX5_ENA */ | ||
3882 | #define ARIZONA_AIF2TX5_ENA_WIDTH 1 /* AIF2TX5_ENA */ | ||
3883 | #define ARIZONA_AIF2TX4_ENA 0x0008 /* AIF2TX4_ENA */ | ||
3884 | #define ARIZONA_AIF2TX4_ENA_MASK 0x0008 /* AIF2TX4_ENA */ | ||
3885 | #define ARIZONA_AIF2TX4_ENA_SHIFT 3 /* AIF2TX4_ENA */ | ||
3886 | #define ARIZONA_AIF2TX4_ENA_WIDTH 1 /* AIF2TX4_ENA */ | ||
3887 | #define ARIZONA_AIF2TX3_ENA 0x0004 /* AIF2TX3_ENA */ | ||
3888 | #define ARIZONA_AIF2TX3_ENA_MASK 0x0004 /* AIF2TX3_ENA */ | ||
3889 | #define ARIZONA_AIF2TX3_ENA_SHIFT 2 /* AIF2TX3_ENA */ | ||
3890 | #define ARIZONA_AIF2TX3_ENA_WIDTH 1 /* AIF2TX3_ENA */ | ||
3745 | #define ARIZONA_AIF2TX2_ENA 0x0002 /* AIF2TX2_ENA */ | 3891 | #define ARIZONA_AIF2TX2_ENA 0x0002 /* AIF2TX2_ENA */ |
3746 | #define ARIZONA_AIF2TX2_ENA_MASK 0x0002 /* AIF2TX2_ENA */ | 3892 | #define ARIZONA_AIF2TX2_ENA_MASK 0x0002 /* AIF2TX2_ENA */ |
3747 | #define ARIZONA_AIF2TX2_ENA_SHIFT 1 /* AIF2TX2_ENA */ | 3893 | #define ARIZONA_AIF2TX2_ENA_SHIFT 1 /* AIF2TX2_ENA */ |
@@ -3754,6 +3900,22 @@ | |||
3754 | /* | 3900 | /* |
3755 | * R1370 (0x55A) - AIF2 Rx Enables | 3901 | * R1370 (0x55A) - AIF2 Rx Enables |
3756 | */ | 3902 | */ |
3903 | #define ARIZONA_AIF2RX6_ENA 0x0020 /* AIF2RX6_ENA */ | ||
3904 | #define ARIZONA_AIF2RX6_ENA_MASK 0x0020 /* AIF2RX6_ENA */ | ||
3905 | #define ARIZONA_AIF2RX6_ENA_SHIFT 5 /* AIF2RX6_ENA */ | ||
3906 | #define ARIZONA_AIF2RX6_ENA_WIDTH 1 /* AIF2RX6_ENA */ | ||
3907 | #define ARIZONA_AIF2RX5_ENA 0x0010 /* AIF2RX5_ENA */ | ||
3908 | #define ARIZONA_AIF2RX5_ENA_MASK 0x0010 /* AIF2RX5_ENA */ | ||
3909 | #define ARIZONA_AIF2RX5_ENA_SHIFT 4 /* AIF2RX5_ENA */ | ||
3910 | #define ARIZONA_AIF2RX5_ENA_WIDTH 1 /* AIF2RX5_ENA */ | ||
3911 | #define ARIZONA_AIF2RX4_ENA 0x0008 /* AIF2RX4_ENA */ | ||
3912 | #define ARIZONA_AIF2RX4_ENA_MASK 0x0008 /* AIF2RX4_ENA */ | ||
3913 | #define ARIZONA_AIF2RX4_ENA_SHIFT 3 /* AIF2RX4_ENA */ | ||
3914 | #define ARIZONA_AIF2RX4_ENA_WIDTH 1 /* AIF2RX4_ENA */ | ||
3915 | #define ARIZONA_AIF2RX3_ENA 0x0004 /* AIF2RX3_ENA */ | ||
3916 | #define ARIZONA_AIF2RX3_ENA_MASK 0x0004 /* AIF2RX3_ENA */ | ||
3917 | #define ARIZONA_AIF2RX3_ENA_SHIFT 2 /* AIF2RX3_ENA */ | ||
3918 | #define ARIZONA_AIF2RX3_ENA_WIDTH 1 /* AIF2RX3_ENA */ | ||
3757 | #define ARIZONA_AIF2RX2_ENA 0x0002 /* AIF2RX2_ENA */ | 3919 | #define ARIZONA_AIF2RX2_ENA 0x0002 /* AIF2RX2_ENA */ |
3758 | #define ARIZONA_AIF2RX2_ENA_MASK 0x0002 /* AIF2RX2_ENA */ | 3920 | #define ARIZONA_AIF2RX2_ENA_MASK 0x0002 /* AIF2RX2_ENA */ |
3759 | #define ARIZONA_AIF2RX2_ENA_SHIFT 1 /* AIF2RX2_ENA */ | 3921 | #define ARIZONA_AIF2RX2_ENA_SHIFT 1 /* AIF2RX2_ENA */ |
diff --git a/include/linux/migrate.h b/include/linux/migrate.h index f5096b58b20d..f015c059e159 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h | |||
@@ -55,7 +55,8 @@ extern int migrate_huge_page_move_mapping(struct address_space *mapping, | |||
55 | struct page *newpage, struct page *page); | 55 | struct page *newpage, struct page *page); |
56 | extern int migrate_page_move_mapping(struct address_space *mapping, | 56 | extern int migrate_page_move_mapping(struct address_space *mapping, |
57 | struct page *newpage, struct page *page, | 57 | struct page *newpage, struct page *page, |
58 | struct buffer_head *head, enum migrate_mode mode); | 58 | struct buffer_head *head, enum migrate_mode mode, |
59 | int extra_count); | ||
59 | #else | 60 | #else |
60 | 61 | ||
61 | static inline void putback_lru_pages(struct list_head *l) {} | 62 | static inline void putback_lru_pages(struct list_head *l) {} |
@@ -90,10 +91,19 @@ static inline int migrate_huge_page_move_mapping(struct address_space *mapping, | |||
90 | #endif /* CONFIG_MIGRATION */ | 91 | #endif /* CONFIG_MIGRATION */ |
91 | 92 | ||
92 | #ifdef CONFIG_NUMA_BALANCING | 93 | #ifdef CONFIG_NUMA_BALANCING |
94 | extern bool pmd_trans_migrating(pmd_t pmd); | ||
95 | extern void wait_migrate_huge_page(struct anon_vma *anon_vma, pmd_t *pmd); | ||
93 | extern int migrate_misplaced_page(struct page *page, | 96 | extern int migrate_misplaced_page(struct page *page, |
94 | struct vm_area_struct *vma, int node); | 97 | struct vm_area_struct *vma, int node); |
95 | extern bool migrate_ratelimited(int node); | 98 | extern bool migrate_ratelimited(int node); |
96 | #else | 99 | #else |
100 | static inline bool pmd_trans_migrating(pmd_t pmd) | ||
101 | { | ||
102 | return false; | ||
103 | } | ||
104 | static inline void wait_migrate_huge_page(struct anon_vma *anon_vma, pmd_t *pmd) | ||
105 | { | ||
106 | } | ||
97 | static inline int migrate_misplaced_page(struct page *page, | 107 | static inline int migrate_misplaced_page(struct page *page, |
98 | struct vm_area_struct *vma, int node) | 108 | struct vm_area_struct *vma, int node) |
99 | { | 109 | { |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 1cedd000cf29..35527173cf50 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -1317,7 +1317,7 @@ static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long a | |||
1317 | #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */ | 1317 | #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */ |
1318 | 1318 | ||
1319 | #if USE_SPLIT_PTE_PTLOCKS | 1319 | #if USE_SPLIT_PTE_PTLOCKS |
1320 | #if BLOATED_SPINLOCKS | 1320 | #if ALLOC_SPLIT_PTLOCKS |
1321 | extern bool ptlock_alloc(struct page *page); | 1321 | extern bool ptlock_alloc(struct page *page); |
1322 | extern void ptlock_free(struct page *page); | 1322 | extern void ptlock_free(struct page *page); |
1323 | 1323 | ||
@@ -1325,7 +1325,7 @@ static inline spinlock_t *ptlock_ptr(struct page *page) | |||
1325 | { | 1325 | { |
1326 | return page->ptl; | 1326 | return page->ptl; |
1327 | } | 1327 | } |
1328 | #else /* BLOATED_SPINLOCKS */ | 1328 | #else /* ALLOC_SPLIT_PTLOCKS */ |
1329 | static inline bool ptlock_alloc(struct page *page) | 1329 | static inline bool ptlock_alloc(struct page *page) |
1330 | { | 1330 | { |
1331 | return true; | 1331 | return true; |
@@ -1339,7 +1339,7 @@ static inline spinlock_t *ptlock_ptr(struct page *page) | |||
1339 | { | 1339 | { |
1340 | return &page->ptl; | 1340 | return &page->ptl; |
1341 | } | 1341 | } |
1342 | #endif /* BLOATED_SPINLOCKS */ | 1342 | #endif /* ALLOC_SPLIT_PTLOCKS */ |
1343 | 1343 | ||
1344 | static inline spinlock_t *pte_lockptr(struct mm_struct *mm, pmd_t *pmd) | 1344 | static inline spinlock_t *pte_lockptr(struct mm_struct *mm, pmd_t *pmd) |
1345 | { | 1345 | { |
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index bd299418a934..290901a8c1de 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h | |||
@@ -26,6 +26,7 @@ struct address_space; | |||
26 | #define USE_SPLIT_PTE_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS) | 26 | #define USE_SPLIT_PTE_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS) |
27 | #define USE_SPLIT_PMD_PTLOCKS (USE_SPLIT_PTE_PTLOCKS && \ | 27 | #define USE_SPLIT_PMD_PTLOCKS (USE_SPLIT_PTE_PTLOCKS && \ |
28 | IS_ENABLED(CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK)) | 28 | IS_ENABLED(CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK)) |
29 | #define ALLOC_SPLIT_PTLOCKS (SPINLOCK_SIZE > BITS_PER_LONG/8) | ||
29 | 30 | ||
30 | /* | 31 | /* |
31 | * Each physical page in the system has a struct page associated with | 32 | * Each physical page in the system has a struct page associated with |
@@ -155,7 +156,7 @@ struct page { | |||
155 | * system if PG_buddy is set. | 156 | * system if PG_buddy is set. |
156 | */ | 157 | */ |
157 | #if USE_SPLIT_PTE_PTLOCKS | 158 | #if USE_SPLIT_PTE_PTLOCKS |
158 | #if BLOATED_SPINLOCKS | 159 | #if ALLOC_SPLIT_PTLOCKS |
159 | spinlock_t *ptl; | 160 | spinlock_t *ptl; |
160 | #else | 161 | #else |
161 | spinlock_t ptl; | 162 | spinlock_t ptl; |
@@ -443,6 +444,14 @@ struct mm_struct { | |||
443 | /* numa_scan_seq prevents two threads setting pte_numa */ | 444 | /* numa_scan_seq prevents two threads setting pte_numa */ |
444 | int numa_scan_seq; | 445 | int numa_scan_seq; |
445 | #endif | 446 | #endif |
447 | #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) | ||
448 | /* | ||
449 | * An operation with batched TLB flushing is going on. Anything that | ||
450 | * can move process memory needs to flush the TLB when moving a | ||
451 | * PROT_NONE or PROT_NUMA mapped page. | ||
452 | */ | ||
453 | bool tlb_flush_pending; | ||
454 | #endif | ||
446 | struct uprobes_state uprobes_state; | 455 | struct uprobes_state uprobes_state; |
447 | }; | 456 | }; |
448 | 457 | ||
@@ -459,4 +468,45 @@ static inline cpumask_t *mm_cpumask(struct mm_struct *mm) | |||
459 | return mm->cpu_vm_mask_var; | 468 | return mm->cpu_vm_mask_var; |
460 | } | 469 | } |
461 | 470 | ||
471 | #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) | ||
472 | /* | ||
473 | * Memory barriers to keep this state in sync are graciously provided by | ||
474 | * the page table locks, outside of which no page table modifications happen. | ||
475 | * The barriers below prevent the compiler from re-ordering the instructions | ||
476 | * around the memory barriers that are already present in the code. | ||
477 | */ | ||
478 | static inline bool mm_tlb_flush_pending(struct mm_struct *mm) | ||
479 | { | ||
480 | barrier(); | ||
481 | return mm->tlb_flush_pending; | ||
482 | } | ||
483 | static inline void set_tlb_flush_pending(struct mm_struct *mm) | ||
484 | { | ||
485 | mm->tlb_flush_pending = true; | ||
486 | |||
487 | /* | ||
488 | * Guarantee that the tlb_flush_pending store does not leak into the | ||
489 | * critical section updating the page tables | ||
490 | */ | ||
491 | smp_mb__before_spinlock(); | ||
492 | } | ||
493 | /* Clearing is done after a TLB flush, which also provides a barrier. */ | ||
494 | static inline void clear_tlb_flush_pending(struct mm_struct *mm) | ||
495 | { | ||
496 | barrier(); | ||
497 | mm->tlb_flush_pending = false; | ||
498 | } | ||
499 | #else | ||
500 | static inline bool mm_tlb_flush_pending(struct mm_struct *mm) | ||
501 | { | ||
502 | return false; | ||
503 | } | ||
504 | static inline void set_tlb_flush_pending(struct mm_struct *mm) | ||
505 | { | ||
506 | } | ||
507 | static inline void clear_tlb_flush_pending(struct mm_struct *mm) | ||
508 | { | ||
509 | } | ||
510 | #endif | ||
511 | |||
462 | #endif /* _LINUX_MM_TYPES_H */ | 512 | #endif /* _LINUX_MM_TYPES_H */ |
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 57e890abe1f0..a5fc7d01aad6 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h | |||
@@ -69,6 +69,7 @@ | |||
69 | __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ | 69 | __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ |
70 | extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ | 70 | extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ |
71 | __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ | 71 | __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ |
72 | extern __PCPU_ATTRS(sec) __typeof__(type) name; \ | ||
72 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \ | 73 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \ |
73 | __typeof__(type) name | 74 | __typeof__(type) name |
74 | #else | 75 | #else |
diff --git a/include/linux/platform_data/asoc-ti-mcbsp.h b/include/linux/platform_data/asoc-ti-mcbsp.h index c78d90b28b19..3c73c045f8da 100644 --- a/include/linux/platform_data/asoc-ti-mcbsp.h +++ b/include/linux/platform_data/asoc-ti-mcbsp.h | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * arch/arm/plat-omap/include/mach/mcbsp.h | ||
3 | * | ||
4 | * Defines for Multi-Channel Buffered Serial Port | 2 | * Defines for Multi-Channel Buffered Serial Port |
5 | * | 3 | * |
6 | * Copyright (C) 2002 RidgeRun, Inc. | 4 | * Copyright (C) 2002 RidgeRun, Inc. |
@@ -21,8 +19,8 @@ | |||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 | * | 20 | * |
23 | */ | 21 | */ |
24 | #ifndef __ASM_ARCH_OMAP_MCBSP_H | 22 | #ifndef __ASOC_TI_MCBSP_H |
25 | #define __ASM_ARCH_OMAP_MCBSP_H | 23 | #define __ASOC_TI_MCBSP_H |
26 | 24 | ||
27 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
28 | #include <linux/clk.h> | 26 | #include <linux/clk.h> |
diff --git a/include/linux/platform_data/davinci_asp.h b/include/linux/platform_data/davinci_asp.h index 689a856b86f9..5245992b0367 100644 --- a/include/linux/platform_data/davinci_asp.h +++ b/include/linux/platform_data/davinci_asp.h | |||
@@ -92,6 +92,7 @@ enum { | |||
92 | MCASP_VERSION_1 = 0, /* DM646x */ | 92 | MCASP_VERSION_1 = 0, /* DM646x */ |
93 | MCASP_VERSION_2, /* DA8xx/OMAPL1x */ | 93 | MCASP_VERSION_2, /* DA8xx/OMAPL1x */ |
94 | MCASP_VERSION_3, /* TI81xx/AM33xx */ | 94 | MCASP_VERSION_3, /* TI81xx/AM33xx */ |
95 | MCASP_VERSION_4, /* DRA7xxx */ | ||
95 | }; | 96 | }; |
96 | 97 | ||
97 | enum mcbsp_clk_input_pin { | 98 | enum mcbsp_clk_input_pin { |
diff --git a/include/linux/pstore.h b/include/linux/pstore.h index abd437d0a8a7..ece0c6bbfcc5 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h | |||
@@ -51,6 +51,7 @@ struct pstore_info { | |||
51 | char *buf; | 51 | char *buf; |
52 | size_t bufsize; | 52 | size_t bufsize; |
53 | struct mutex read_mutex; /* serialize open/read/close */ | 53 | struct mutex read_mutex; /* serialize open/read/close */ |
54 | int flags; | ||
54 | int (*open)(struct pstore_info *psi); | 55 | int (*open)(struct pstore_info *psi); |
55 | int (*close)(struct pstore_info *psi); | 56 | int (*close)(struct pstore_info *psi); |
56 | ssize_t (*read)(u64 *id, enum pstore_type_id *type, | 57 | ssize_t (*read)(u64 *id, enum pstore_type_id *type, |
@@ -70,6 +71,8 @@ struct pstore_info { | |||
70 | void *data; | 71 | void *data; |
71 | }; | 72 | }; |
72 | 73 | ||
74 | #define PSTORE_FLAGS_FRAGILE 1 | ||
75 | |||
73 | #ifdef CONFIG_PSTORE | 76 | #ifdef CONFIG_PSTORE |
74 | extern int pstore_register(struct pstore_info *); | 77 | extern int pstore_register(struct pstore_info *); |
75 | extern bool pstore_cannot_block_path(enum kmsg_dump_reason reason); | 78 | extern bool pstore_cannot_block_path(enum kmsg_dump_reason reason); |
diff --git a/include/linux/reboot.h b/include/linux/reboot.h index 8e00f9f6f963..9e7db9e73cc1 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h | |||
@@ -43,6 +43,7 @@ extern int unregister_reboot_notifier(struct notifier_block *); | |||
43 | * Architecture-specific implementations of sys_reboot commands. | 43 | * Architecture-specific implementations of sys_reboot commands. |
44 | */ | 44 | */ |
45 | 45 | ||
46 | extern void migrate_to_reboot_cpu(void); | ||
46 | extern void machine_restart(char *cmd); | 47 | extern void machine_restart(char *cmd); |
47 | extern void machine_halt(void); | 48 | extern void machine_halt(void); |
48 | extern void machine_power_off(void); | 49 | extern void machine_power_off(void); |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 768b037dfacb..53f97eb8dbc7 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -440,8 +440,6 @@ struct task_cputime { | |||
440 | .sum_exec_runtime = 0, \ | 440 | .sum_exec_runtime = 0, \ |
441 | } | 441 | } |
442 | 442 | ||
443 | #define PREEMPT_ENABLED (PREEMPT_NEED_RESCHED) | ||
444 | |||
445 | #ifdef CONFIG_PREEMPT_COUNT | 443 | #ifdef CONFIG_PREEMPT_COUNT |
446 | #define PREEMPT_DISABLED (1 + PREEMPT_ENABLED) | 444 | #define PREEMPT_DISABLED (1 + PREEMPT_ENABLED) |
447 | #else | 445 | #else |
@@ -932,7 +930,8 @@ struct pipe_inode_info; | |||
932 | struct uts_namespace; | 930 | struct uts_namespace; |
933 | 931 | ||
934 | struct load_weight { | 932 | struct load_weight { |
935 | unsigned long weight, inv_weight; | 933 | unsigned long weight; |
934 | u32 inv_weight; | ||
936 | }; | 935 | }; |
937 | 936 | ||
938 | struct sched_avg { | 937 | struct sched_avg { |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 979874c627ee..61e1935c91b1 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -978,7 +978,7 @@ struct ib_uobject { | |||
978 | }; | 978 | }; |
979 | 979 | ||
980 | struct ib_udata { | 980 | struct ib_udata { |
981 | void __user *inbuf; | 981 | const void __user *inbuf; |
982 | void __user *outbuf; | 982 | void __user *outbuf; |
983 | size_t inlen; | 983 | size_t inlen; |
984 | size_t outlen; | 984 | size_t outlen; |
diff --git a/include/sound/cs42l52.h b/include/sound/cs42l52.h index 7c2be4a51894..bbabf84bdb44 100644 --- a/include/sound/cs42l52.h +++ b/include/sound/cs42l52.h | |||
@@ -16,17 +16,11 @@ struct cs42l52_platform_data { | |||
16 | /* MICBIAS Level. Check datasheet Pg48 */ | 16 | /* MICBIAS Level. Check datasheet Pg48 */ |
17 | unsigned int micbias_lvl; | 17 | unsigned int micbias_lvl; |
18 | 18 | ||
19 | /* MICA mode selection 0=Single 1=Differential */ | 19 | /* MICA mode selection Differential or Single-ended */ |
20 | unsigned int mica_cfg; | 20 | bool mica_diff_cfg; |
21 | 21 | ||
22 | /* MICB mode selection 0=Single 1=Differential */ | 22 | /* MICB mode selection Differential or Single-ended */ |
23 | unsigned int micb_cfg; | 23 | bool micb_diff_cfg; |
24 | |||
25 | /* MICA Select 0=MIC1A 1=MIC2A */ | ||
26 | unsigned int mica_sel; | ||
27 | |||
28 | /* MICB Select 0=MIC2A 1=MIC2B */ | ||
29 | unsigned int micb_sel; | ||
30 | 24 | ||
31 | /* Charge Pump Freq. Check datasheet Pg73 */ | 25 | /* Charge Pump Freq. Check datasheet Pg73 */ |
32 | unsigned int chgfreq; | 26 | unsigned int chgfreq; |
diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index 15017311f2e9..eb73a3a39ec2 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h | |||
@@ -114,6 +114,10 @@ void snd_dmaengine_pcm_set_config_from_dai_data( | |||
114 | * @compat_filter_fn: Will be used as the filter function when requesting a | 114 | * @compat_filter_fn: Will be used as the filter function when requesting a |
115 | * channel for platforms which do not use devicetree. The filter parameter | 115 | * channel for platforms which do not use devicetree. The filter parameter |
116 | * will be the DAI's DMA data. | 116 | * will be the DAI's DMA data. |
117 | * @dma_dev: If set, request DMA channel on this device rather than the DAI | ||
118 | * device. | ||
119 | * @chan_names: If set, these custom DMA channel names will be requested at | ||
120 | * registration time. | ||
117 | * @pcm_hardware: snd_pcm_hardware struct to be used for the PCM. | 121 | * @pcm_hardware: snd_pcm_hardware struct to be used for the PCM. |
118 | * @prealloc_buffer_size: Size of the preallocated audio buffer. | 122 | * @prealloc_buffer_size: Size of the preallocated audio buffer. |
119 | * | 123 | * |
@@ -130,6 +134,8 @@ struct snd_dmaengine_pcm_config { | |||
130 | struct snd_soc_pcm_runtime *rtd, | 134 | struct snd_soc_pcm_runtime *rtd, |
131 | struct snd_pcm_substream *substream); | 135 | struct snd_pcm_substream *substream); |
132 | dma_filter_fn compat_filter_fn; | 136 | dma_filter_fn compat_filter_fn; |
137 | struct device *dma_dev; | ||
138 | const char *chan_names[SNDRV_PCM_STREAM_LAST + 1]; | ||
133 | 139 | ||
134 | const struct snd_pcm_hardware *pcm_hardware; | 140 | const struct snd_pcm_hardware *pcm_hardware; |
135 | unsigned int prealloc_buffer_size; | 141 | unsigned int prealloc_buffer_size; |
@@ -140,6 +146,10 @@ int snd_dmaengine_pcm_register(struct device *dev, | |||
140 | unsigned int flags); | 146 | unsigned int flags); |
141 | void snd_dmaengine_pcm_unregister(struct device *dev); | 147 | void snd_dmaengine_pcm_unregister(struct device *dev); |
142 | 148 | ||
149 | int devm_snd_dmaengine_pcm_register(struct device *dev, | ||
150 | const struct snd_dmaengine_pcm_config *config, | ||
151 | unsigned int flags); | ||
152 | |||
143 | int snd_dmaengine_pcm_prepare_slave_config(struct snd_pcm_substream *substream, | 153 | int snd_dmaengine_pcm_prepare_slave_config(struct snd_pcm_substream *substream, |
144 | struct snd_pcm_hw_params *params, | 154 | struct snd_pcm_hw_params *params, |
145 | struct dma_slave_config *slave_config); | 155 | struct dma_slave_config *slave_config); |
diff --git a/include/sound/pcm_params.h b/include/sound/pcm_params.h index 37ae12e0ab06..6b1c78f05fab 100644 --- a/include/sound/pcm_params.h +++ b/include/sound/pcm_params.h | |||
@@ -354,4 +354,16 @@ params_period_bytes(const struct snd_pcm_hw_params *p) | |||
354 | params_channels(p)) / 8; | 354 | params_channels(p)) / 8; |
355 | } | 355 | } |
356 | 356 | ||
357 | static inline int | ||
358 | params_width(const struct snd_pcm_hw_params *p) | ||
359 | { | ||
360 | return snd_pcm_format_width(params_format(p)); | ||
361 | } | ||
362 | |||
363 | static inline int | ||
364 | params_physical_width(const struct snd_pcm_hw_params *p) | ||
365 | { | ||
366 | return snd_pcm_format_physical_width(params_format(p)); | ||
367 | } | ||
368 | |||
357 | #endif /* __SOUND_PCM_PARAMS_H */ | 369 | #endif /* __SOUND_PCM_PARAMS_H */ |
diff --git a/include/sound/rcar_snd.h b/include/sound/rcar_snd.h index 12afab18945d..e147498abe50 100644 --- a/include/sound/rcar_snd.h +++ b/include/sound/rcar_snd.h | |||
@@ -18,7 +18,7 @@ | |||
18 | #define RSND_GEN1_ADG 1 | 18 | #define RSND_GEN1_ADG 1 |
19 | #define RSND_GEN1_SSI 2 | 19 | #define RSND_GEN1_SSI 2 |
20 | 20 | ||
21 | #define RSND_GEN2_SRU 0 | 21 | #define RSND_GEN2_SCU 0 |
22 | #define RSND_GEN2_ADG 1 | 22 | #define RSND_GEN2_ADG 1 |
23 | #define RSND_GEN2_SSIU 2 | 23 | #define RSND_GEN2_SSIU 2 |
24 | #define RSND_GEN2_SSI 3 | 24 | #define RSND_GEN2_SSI 3 |
@@ -58,6 +58,7 @@ struct rsnd_ssi_platform_info { | |||
58 | 58 | ||
59 | struct rsnd_scu_platform_info { | 59 | struct rsnd_scu_platform_info { |
60 | u32 flags; | 60 | u32 flags; |
61 | u32 convert_rate; /* sampling rate convert */ | ||
61 | }; | 62 | }; |
62 | 63 | ||
63 | /* | 64 | /* |
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 800c101bb096..243d3b689699 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h | |||
@@ -220,6 +220,8 @@ struct snd_soc_dai_driver { | |||
220 | struct snd_soc_pcm_stream capture; | 220 | struct snd_soc_pcm_stream capture; |
221 | struct snd_soc_pcm_stream playback; | 221 | struct snd_soc_pcm_stream playback; |
222 | unsigned int symmetric_rates:1; | 222 | unsigned int symmetric_rates:1; |
223 | unsigned int symmetric_channels:1; | ||
224 | unsigned int symmetric_samplebits:1; | ||
223 | 225 | ||
224 | /* probe ordering - for components with runtime dependencies */ | 226 | /* probe ordering - for components with runtime dependencies */ |
225 | int probe_order; | 227 | int probe_order; |
@@ -244,6 +246,8 @@ struct snd_soc_dai { | |||
244 | unsigned int capture_active:1; /* stream is in use */ | 246 | unsigned int capture_active:1; /* stream is in use */ |
245 | unsigned int playback_active:1; /* stream is in use */ | 247 | unsigned int playback_active:1; /* stream is in use */ |
246 | unsigned int symmetric_rates:1; | 248 | unsigned int symmetric_rates:1; |
249 | unsigned int symmetric_channels:1; | ||
250 | unsigned int symmetric_samplebits:1; | ||
247 | struct snd_pcm_runtime *runtime; | 251 | struct snd_pcm_runtime *runtime; |
248 | unsigned int active; | 252 | unsigned int active; |
249 | unsigned char probed:1; | 253 | unsigned char probed:1; |
@@ -258,6 +262,8 @@ struct snd_soc_dai { | |||
258 | 262 | ||
259 | /* Symmetry data - only valid if symmetry is being enforced */ | 263 | /* Symmetry data - only valid if symmetry is being enforced */ |
260 | unsigned int rate; | 264 | unsigned int rate; |
265 | unsigned int channels; | ||
266 | unsigned int sample_bits; | ||
261 | 267 | ||
262 | /* parent platform/codec */ | 268 | /* parent platform/codec */ |
263 | struct snd_soc_platform *platform; | 269 | struct snd_soc_platform *platform; |
diff --git a/include/sound/soc.h b/include/sound/soc.h index 1f741cb24f33..5a049d969c59 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -334,9 +334,7 @@ struct snd_soc_jack_pin; | |||
334 | #include <sound/soc-dapm.h> | 334 | #include <sound/soc-dapm.h> |
335 | #include <sound/soc-dpcm.h> | 335 | #include <sound/soc-dpcm.h> |
336 | 336 | ||
337 | #ifdef CONFIG_GPIOLIB | ||
338 | struct snd_soc_jack_gpio; | 337 | struct snd_soc_jack_gpio; |
339 | #endif | ||
340 | 338 | ||
341 | typedef int (*hw_write_t)(void *,const char* ,int); | 339 | typedef int (*hw_write_t)(void *,const char* ,int); |
342 | 340 | ||
@@ -446,6 +444,17 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
446 | struct snd_soc_jack_gpio *gpios); | 444 | struct snd_soc_jack_gpio *gpios); |
447 | void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, | 445 | void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, |
448 | struct snd_soc_jack_gpio *gpios); | 446 | struct snd_soc_jack_gpio *gpios); |
447 | #else | ||
448 | static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | ||
449 | struct snd_soc_jack_gpio *gpios) | ||
450 | { | ||
451 | return 0; | ||
452 | } | ||
453 | |||
454 | static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, | ||
455 | struct snd_soc_jack_gpio *gpios) | ||
456 | { | ||
457 | } | ||
449 | #endif | 458 | #endif |
450 | 459 | ||
451 | /* codec register bit access */ | 460 | /* codec register bit access */ |
@@ -580,7 +589,6 @@ struct snd_soc_jack_zone { | |||
580 | * to provide more complex checks (eg, reading an | 589 | * to provide more complex checks (eg, reading an |
581 | * ADC). | 590 | * ADC). |
582 | */ | 591 | */ |
583 | #ifdef CONFIG_GPIOLIB | ||
584 | struct snd_soc_jack_gpio { | 592 | struct snd_soc_jack_gpio { |
585 | unsigned int gpio; | 593 | unsigned int gpio; |
586 | const char *name; | 594 | const char *name; |
@@ -594,7 +602,6 @@ struct snd_soc_jack_gpio { | |||
594 | 602 | ||
595 | int (*jack_status_check)(void); | 603 | int (*jack_status_check)(void); |
596 | }; | 604 | }; |
597 | #endif | ||
598 | 605 | ||
599 | struct snd_soc_jack { | 606 | struct snd_soc_jack { |
600 | struct mutex mutex; | 607 | struct mutex mutex; |
@@ -879,6 +886,8 @@ struct snd_soc_dai_link { | |||
879 | 886 | ||
880 | /* Symmetry requirements */ | 887 | /* Symmetry requirements */ |
881 | unsigned int symmetric_rates:1; | 888 | unsigned int symmetric_rates:1; |
889 | unsigned int symmetric_channels:1; | ||
890 | unsigned int symmetric_samplebits:1; | ||
882 | 891 | ||
883 | /* Do not create a PCM for this DAI link (Backend link) */ | 892 | /* Do not create a PCM for this DAI link (Backend link) */ |
884 | unsigned int no_pcm:1; | 893 | unsigned int no_pcm:1; |
diff --git a/include/sound/spear_dma.h b/include/sound/spear_dma.h index 1b365bfdfb37..65aca51fe255 100644 --- a/include/sound/spear_dma.h +++ b/include/sound/spear_dma.h | |||
@@ -29,7 +29,6 @@ struct spear_dma_data { | |||
29 | dma_addr_t addr; | 29 | dma_addr_t addr; |
30 | u32 max_burst; | 30 | u32 max_burst; |
31 | enum dma_slave_buswidth addr_width; | 31 | enum dma_slave_buswidth addr_width; |
32 | bool (*filter)(struct dma_chan *chan, void *slave); | ||
33 | }; | 32 | }; |
34 | 33 | ||
35 | #endif /* SPEAR_DMA_H */ | 34 | #endif /* SPEAR_DMA_H */ |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 45412a6afa69..321301c0a643 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
@@ -517,10 +517,6 @@ struct se_node_acl { | |||
517 | u32 acl_index; | 517 | u32 acl_index; |
518 | #define MAX_ACL_TAG_SIZE 64 | 518 | #define MAX_ACL_TAG_SIZE 64 |
519 | char acl_tag[MAX_ACL_TAG_SIZE]; | 519 | char acl_tag[MAX_ACL_TAG_SIZE]; |
520 | u64 num_cmds; | ||
521 | u64 read_bytes; | ||
522 | u64 write_bytes; | ||
523 | spinlock_t stats_lock; | ||
524 | /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */ | 520 | /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */ |
525 | atomic_t acl_pr_ref_count; | 521 | atomic_t acl_pr_ref_count; |
526 | struct se_dev_entry **device_list; | 522 | struct se_dev_entry **device_list; |
@@ -624,6 +620,7 @@ struct se_dev_attrib { | |||
624 | u32 unmap_granularity; | 620 | u32 unmap_granularity; |
625 | u32 unmap_granularity_alignment; | 621 | u32 unmap_granularity_alignment; |
626 | u32 max_write_same_len; | 622 | u32 max_write_same_len; |
623 | u32 max_bytes_per_io; | ||
627 | struct se_device *da_dev; | 624 | struct se_device *da_dev; |
628 | struct config_group da_group; | 625 | struct config_group da_group; |
629 | }; | 626 | }; |
diff --git a/include/uapi/drm/vmwgfx_drm.h b/include/uapi/drm/vmwgfx_drm.h index bcb0912afe7a..f854ca4a1372 100644 --- a/include/uapi/drm/vmwgfx_drm.h +++ b/include/uapi/drm/vmwgfx_drm.h | |||
@@ -75,6 +75,7 @@ | |||
75 | #define DRM_VMW_PARAM_FIFO_CAPS 4 | 75 | #define DRM_VMW_PARAM_FIFO_CAPS 4 |
76 | #define DRM_VMW_PARAM_MAX_FB_SIZE 5 | 76 | #define DRM_VMW_PARAM_MAX_FB_SIZE 5 |
77 | #define DRM_VMW_PARAM_FIFO_HW_VERSION 6 | 77 | #define DRM_VMW_PARAM_FIFO_HW_VERSION 6 |
78 | #define DRM_VMW_PARAM_MAX_SURF_MEMORY 7 | ||
78 | 79 | ||
79 | /** | 80 | /** |
80 | * struct drm_vmw_getparam_arg | 81 | * struct drm_vmw_getparam_arg |
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index e1802d6153ae..959d454f76a1 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h | |||
@@ -679,6 +679,7 @@ enum perf_event_type { | |||
679 | * | 679 | * |
680 | * { u64 weight; } && PERF_SAMPLE_WEIGHT | 680 | * { u64 weight; } && PERF_SAMPLE_WEIGHT |
681 | * { u64 data_src; } && PERF_SAMPLE_DATA_SRC | 681 | * { u64 data_src; } && PERF_SAMPLE_DATA_SRC |
682 | * { u64 transaction; } && PERF_SAMPLE_TRANSACTION | ||
682 | * }; | 683 | * }; |
683 | */ | 684 | */ |
684 | PERF_RECORD_SAMPLE = 9, | 685 | PERF_RECORD_SAMPLE = 9, |
diff --git a/include/xen/interface/io/blkif.h b/include/xen/interface/io/blkif.h index 65e12099ef89..ae665ac59c36 100644 --- a/include/xen/interface/io/blkif.h +++ b/include/xen/interface/io/blkif.h | |||
@@ -146,7 +146,7 @@ struct blkif_request_segment_aligned { | |||
146 | struct blkif_request_rw { | 146 | struct blkif_request_rw { |
147 | uint8_t nr_segments; /* number of segments */ | 147 | uint8_t nr_segments; /* number of segments */ |
148 | blkif_vdev_t handle; /* only for read/write requests */ | 148 | blkif_vdev_t handle; /* only for read/write requests */ |
149 | #ifdef CONFIG_X86_64 | 149 | #ifndef CONFIG_X86_32 |
150 | uint32_t _pad1; /* offsetof(blkif_request,u.rw.id) == 8 */ | 150 | uint32_t _pad1; /* offsetof(blkif_request,u.rw.id) == 8 */ |
151 | #endif | 151 | #endif |
152 | uint64_t id; /* private guest value, echoed in resp */ | 152 | uint64_t id; /* private guest value, echoed in resp */ |
@@ -163,7 +163,7 @@ struct blkif_request_discard { | |||
163 | uint8_t flag; /* BLKIF_DISCARD_SECURE or zero. */ | 163 | uint8_t flag; /* BLKIF_DISCARD_SECURE or zero. */ |
164 | #define BLKIF_DISCARD_SECURE (1<<0) /* ignored if discard-secure=0 */ | 164 | #define BLKIF_DISCARD_SECURE (1<<0) /* ignored if discard-secure=0 */ |
165 | blkif_vdev_t _pad1; /* only for read/write requests */ | 165 | blkif_vdev_t _pad1; /* only for read/write requests */ |
166 | #ifdef CONFIG_X86_64 | 166 | #ifndef CONFIG_X86_32 |
167 | uint32_t _pad2; /* offsetof(blkif_req..,u.discard.id)==8*/ | 167 | uint32_t _pad2; /* offsetof(blkif_req..,u.discard.id)==8*/ |
168 | #endif | 168 | #endif |
169 | uint64_t id; /* private guest value, echoed in resp */ | 169 | uint64_t id; /* private guest value, echoed in resp */ |
@@ -175,7 +175,7 @@ struct blkif_request_discard { | |||
175 | struct blkif_request_other { | 175 | struct blkif_request_other { |
176 | uint8_t _pad1; | 176 | uint8_t _pad1; |
177 | blkif_vdev_t _pad2; /* only for read/write requests */ | 177 | blkif_vdev_t _pad2; /* only for read/write requests */ |
178 | #ifdef CONFIG_X86_64 | 178 | #ifndef CONFIG_X86_32 |
179 | uint32_t _pad3; /* offsetof(blkif_req..,u.other.id)==8*/ | 179 | uint32_t _pad3; /* offsetof(blkif_req..,u.other.id)==8*/ |
180 | #endif | 180 | #endif |
181 | uint64_t id; /* private guest value, echoed in resp */ | 181 | uint64_t id; /* private guest value, echoed in resp */ |
@@ -184,7 +184,7 @@ struct blkif_request_other { | |||
184 | struct blkif_request_indirect { | 184 | struct blkif_request_indirect { |
185 | uint8_t indirect_op; | 185 | uint8_t indirect_op; |
186 | uint16_t nr_segments; | 186 | uint16_t nr_segments; |
187 | #ifdef CONFIG_X86_64 | 187 | #ifndef CONFIG_X86_32 |
188 | uint32_t _pad1; /* offsetof(blkif_...,u.indirect.id) == 8 */ | 188 | uint32_t _pad1; /* offsetof(blkif_...,u.indirect.id) == 8 */ |
189 | #endif | 189 | #endif |
190 | uint64_t id; | 190 | uint64_t id; |
@@ -192,7 +192,7 @@ struct blkif_request_indirect { | |||
192 | blkif_vdev_t handle; | 192 | blkif_vdev_t handle; |
193 | uint16_t _pad2; | 193 | uint16_t _pad2; |
194 | grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST]; | 194 | grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST]; |
195 | #ifdef CONFIG_X86_64 | 195 | #ifndef CONFIG_X86_32 |
196 | uint32_t _pad3; /* make it 64 byte aligned */ | 196 | uint32_t _pad3; /* make it 64 byte aligned */ |
197 | #else | 197 | #else |
198 | uint64_t _pad3; /* make it 64 byte aligned */ | 198 | uint64_t _pad3; /* make it 64 byte aligned */ |
diff --git a/init/Kconfig b/init/Kconfig index 79383d3aa5dc..4e5d96ab2034 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -809,6 +809,12 @@ config GENERIC_SCHED_CLOCK | |||
809 | config ARCH_SUPPORTS_NUMA_BALANCING | 809 | config ARCH_SUPPORTS_NUMA_BALANCING |
810 | bool | 810 | bool |
811 | 811 | ||
812 | # | ||
813 | # For architectures that know their GCC __int128 support is sound | ||
814 | # | ||
815 | config ARCH_SUPPORTS_INT128 | ||
816 | bool | ||
817 | |||
812 | # For architectures that (ab)use NUMA to represent different memory regions | 818 | # For architectures that (ab)use NUMA to represent different memory regions |
813 | # all cpu-local but of different latencies, such as SuperH. | 819 | # all cpu-local but of different latencies, such as SuperH. |
814 | # | 820 | # |
diff --git a/kernel/Makefile b/kernel/Makefile index bbaf7d59c1bb..bc010ee272b6 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -137,9 +137,10 @@ $(obj)/timeconst.h: $(obj)/hz.bc $(src)/timeconst.bc FORCE | |||
137 | ############################################################################### | 137 | ############################################################################### |
138 | ifeq ($(CONFIG_SYSTEM_TRUSTED_KEYRING),y) | 138 | ifeq ($(CONFIG_SYSTEM_TRUSTED_KEYRING),y) |
139 | X509_CERTIFICATES-y := $(wildcard *.x509) $(wildcard $(srctree)/*.x509) | 139 | X509_CERTIFICATES-y := $(wildcard *.x509) $(wildcard $(srctree)/*.x509) |
140 | X509_CERTIFICATES-$(CONFIG_MODULE_SIG) += signing_key.x509 | 140 | X509_CERTIFICATES-$(CONFIG_MODULE_SIG) += $(objtree)/signing_key.x509 |
141 | X509_CERTIFICATES := $(sort $(foreach CERT,$(X509_CERTIFICATES-y), \ | 141 | X509_CERTIFICATES-raw := $(sort $(foreach CERT,$(X509_CERTIFICATES-y), \ |
142 | $(or $(realpath $(CERT)),$(CERT)))) | 142 | $(or $(realpath $(CERT)),$(CERT)))) |
143 | X509_CERTIFICATES := $(subst $(realpath $(objtree))/,,$(X509_CERTIFICATES-raw)) | ||
143 | 144 | ||
144 | ifeq ($(X509_CERTIFICATES),) | 145 | ifeq ($(X509_CERTIFICATES),) |
145 | $(warning *** No X.509 certificates found ***) | 146 | $(warning *** No X.509 certificates found ***) |
@@ -164,9 +165,9 @@ $(obj)/x509_certificate_list: $(X509_CERTIFICATES) $(obj)/.x509.list | |||
164 | targets += $(obj)/.x509.list | 165 | targets += $(obj)/.x509.list |
165 | $(obj)/.x509.list: | 166 | $(obj)/.x509.list: |
166 | @echo $(X509_CERTIFICATES) >$@ | 167 | @echo $(X509_CERTIFICATES) >$@ |
168 | endif | ||
167 | 169 | ||
168 | clean-files := x509_certificate_list .x509.list | 170 | clean-files := x509_certificate_list .x509.list |
169 | endif | ||
170 | 171 | ||
171 | ifeq ($(CONFIG_MODULE_SIG),y) | 172 | ifeq ($(CONFIG_MODULE_SIG),y) |
172 | ############################################################################### | 173 | ############################################################################### |
diff --git a/kernel/bounds.c b/kernel/bounds.c index 5253204afdca..9fd4246b04b8 100644 --- a/kernel/bounds.c +++ b/kernel/bounds.c | |||
@@ -22,6 +22,6 @@ void foo(void) | |||
22 | #ifdef CONFIG_SMP | 22 | #ifdef CONFIG_SMP |
23 | DEFINE(NR_CPUS_BITS, ilog2(CONFIG_NR_CPUS)); | 23 | DEFINE(NR_CPUS_BITS, ilog2(CONFIG_NR_CPUS)); |
24 | #endif | 24 | #endif |
25 | DEFINE(BLOATED_SPINLOCKS, sizeof(spinlock_t) > sizeof(int)); | 25 | DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t)); |
26 | /* End of constants */ | 26 | /* End of constants */ |
27 | } | 27 | } |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 8b729c278b64..bc1dcabe9217 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -890,6 +890,16 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode) | |||
890 | struct cgroup *cgrp = dentry->d_fsdata; | 890 | struct cgroup *cgrp = dentry->d_fsdata; |
891 | 891 | ||
892 | BUG_ON(!(cgroup_is_dead(cgrp))); | 892 | BUG_ON(!(cgroup_is_dead(cgrp))); |
893 | |||
894 | /* | ||
895 | * XXX: cgrp->id is only used to look up css's. As cgroup | ||
896 | * and css's lifetimes will be decoupled, it should be made | ||
897 | * per-subsystem and moved to css->id so that lookups are | ||
898 | * successful until the target css is released. | ||
899 | */ | ||
900 | idr_remove(&cgrp->root->cgroup_idr, cgrp->id); | ||
901 | cgrp->id = -1; | ||
902 | |||
893 | call_rcu(&cgrp->rcu_head, cgroup_free_rcu); | 903 | call_rcu(&cgrp->rcu_head, cgroup_free_rcu); |
894 | } else { | 904 | } else { |
895 | struct cfent *cfe = __d_cfe(dentry); | 905 | struct cfent *cfe = __d_cfe(dentry); |
@@ -4268,6 +4278,7 @@ static void css_release(struct percpu_ref *ref) | |||
4268 | struct cgroup_subsys_state *css = | 4278 | struct cgroup_subsys_state *css = |
4269 | container_of(ref, struct cgroup_subsys_state, refcnt); | 4279 | container_of(ref, struct cgroup_subsys_state, refcnt); |
4270 | 4280 | ||
4281 | rcu_assign_pointer(css->cgroup->subsys[css->ss->subsys_id], NULL); | ||
4271 | call_rcu(&css->rcu_head, css_free_rcu_fn); | 4282 | call_rcu(&css->rcu_head, css_free_rcu_fn); |
4272 | } | 4283 | } |
4273 | 4284 | ||
@@ -4426,14 +4437,6 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4426 | list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children); | 4437 | list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children); |
4427 | root->number_of_cgroups++; | 4438 | root->number_of_cgroups++; |
4428 | 4439 | ||
4429 | /* each css holds a ref to the cgroup's dentry and the parent css */ | ||
4430 | for_each_root_subsys(root, ss) { | ||
4431 | struct cgroup_subsys_state *css = css_ar[ss->subsys_id]; | ||
4432 | |||
4433 | dget(dentry); | ||
4434 | css_get(css->parent); | ||
4435 | } | ||
4436 | |||
4437 | /* hold a ref to the parent's dentry */ | 4440 | /* hold a ref to the parent's dentry */ |
4438 | dget(parent->dentry); | 4441 | dget(parent->dentry); |
4439 | 4442 | ||
@@ -4445,6 +4448,13 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4445 | if (err) | 4448 | if (err) |
4446 | goto err_destroy; | 4449 | goto err_destroy; |
4447 | 4450 | ||
4451 | /* each css holds a ref to the cgroup's dentry and parent css */ | ||
4452 | dget(dentry); | ||
4453 | css_get(css->parent); | ||
4454 | |||
4455 | /* mark it consumed for error path */ | ||
4456 | css_ar[ss->subsys_id] = NULL; | ||
4457 | |||
4448 | if (ss->broken_hierarchy && !ss->warned_broken_hierarchy && | 4458 | if (ss->broken_hierarchy && !ss->warned_broken_hierarchy && |
4449 | parent->parent) { | 4459 | parent->parent) { |
4450 | pr_warning("cgroup: %s (%d) created nested cgroup for controller \"%s\" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.\n", | 4460 | pr_warning("cgroup: %s (%d) created nested cgroup for controller \"%s\" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.\n", |
@@ -4491,6 +4501,14 @@ err_free_cgrp: | |||
4491 | return err; | 4501 | return err; |
4492 | 4502 | ||
4493 | err_destroy: | 4503 | err_destroy: |
4504 | for_each_root_subsys(root, ss) { | ||
4505 | struct cgroup_subsys_state *css = css_ar[ss->subsys_id]; | ||
4506 | |||
4507 | if (css) { | ||
4508 | percpu_ref_cancel_init(&css->refcnt); | ||
4509 | ss->css_free(css); | ||
4510 | } | ||
4511 | } | ||
4494 | cgroup_destroy_locked(cgrp); | 4512 | cgroup_destroy_locked(cgrp); |
4495 | mutex_unlock(&cgroup_mutex); | 4513 | mutex_unlock(&cgroup_mutex); |
4496 | mutex_unlock(&dentry->d_inode->i_mutex); | 4514 | mutex_unlock(&dentry->d_inode->i_mutex); |
@@ -4652,8 +4670,12 @@ static int cgroup_destroy_locked(struct cgroup *cgrp) | |||
4652 | * will be invoked to perform the rest of destruction once the | 4670 | * will be invoked to perform the rest of destruction once the |
4653 | * percpu refs of all css's are confirmed to be killed. | 4671 | * percpu refs of all css's are confirmed to be killed. |
4654 | */ | 4672 | */ |
4655 | for_each_root_subsys(cgrp->root, ss) | 4673 | for_each_root_subsys(cgrp->root, ss) { |
4656 | kill_css(cgroup_css(cgrp, ss)); | 4674 | struct cgroup_subsys_state *css = cgroup_css(cgrp, ss); |
4675 | |||
4676 | if (css) | ||
4677 | kill_css(css); | ||
4678 | } | ||
4657 | 4679 | ||
4658 | /* | 4680 | /* |
4659 | * Mark @cgrp dead. This prevents further task migration and child | 4681 | * Mark @cgrp dead. This prevents further task migration and child |
@@ -4722,14 +4744,6 @@ static void cgroup_destroy_css_killed(struct cgroup *cgrp) | |||
4722 | /* delete this cgroup from parent->children */ | 4744 | /* delete this cgroup from parent->children */ |
4723 | list_del_rcu(&cgrp->sibling); | 4745 | list_del_rcu(&cgrp->sibling); |
4724 | 4746 | ||
4725 | /* | ||
4726 | * We should remove the cgroup object from idr before its grace | ||
4727 | * period starts, so we won't be looking up a cgroup while the | ||
4728 | * cgroup is being freed. | ||
4729 | */ | ||
4730 | idr_remove(&cgrp->root->cgroup_idr, cgrp->id); | ||
4731 | cgrp->id = -1; | ||
4732 | |||
4733 | dput(d); | 4747 | dput(d); |
4734 | 4748 | ||
4735 | set_bit(CGRP_RELEASABLE, &parent->flags); | 4749 | set_bit(CGRP_RELEASABLE, &parent->flags); |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 72348dc192c1..f5744010a8d2 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -1396,6 +1396,8 @@ event_sched_out(struct perf_event *event, | |||
1396 | if (event->state != PERF_EVENT_STATE_ACTIVE) | 1396 | if (event->state != PERF_EVENT_STATE_ACTIVE) |
1397 | return; | 1397 | return; |
1398 | 1398 | ||
1399 | perf_pmu_disable(event->pmu); | ||
1400 | |||
1399 | event->state = PERF_EVENT_STATE_INACTIVE; | 1401 | event->state = PERF_EVENT_STATE_INACTIVE; |
1400 | if (event->pending_disable) { | 1402 | if (event->pending_disable) { |
1401 | event->pending_disable = 0; | 1403 | event->pending_disable = 0; |
@@ -1412,6 +1414,8 @@ event_sched_out(struct perf_event *event, | |||
1412 | ctx->nr_freq--; | 1414 | ctx->nr_freq--; |
1413 | if (event->attr.exclusive || !cpuctx->active_oncpu) | 1415 | if (event->attr.exclusive || !cpuctx->active_oncpu) |
1414 | cpuctx->exclusive = 0; | 1416 | cpuctx->exclusive = 0; |
1417 | |||
1418 | perf_pmu_enable(event->pmu); | ||
1415 | } | 1419 | } |
1416 | 1420 | ||
1417 | static void | 1421 | static void |
@@ -1652,6 +1656,7 @@ event_sched_in(struct perf_event *event, | |||
1652 | struct perf_event_context *ctx) | 1656 | struct perf_event_context *ctx) |
1653 | { | 1657 | { |
1654 | u64 tstamp = perf_event_time(event); | 1658 | u64 tstamp = perf_event_time(event); |
1659 | int ret = 0; | ||
1655 | 1660 | ||
1656 | if (event->state <= PERF_EVENT_STATE_OFF) | 1661 | if (event->state <= PERF_EVENT_STATE_OFF) |
1657 | return 0; | 1662 | return 0; |
@@ -1674,10 +1679,13 @@ event_sched_in(struct perf_event *event, | |||
1674 | */ | 1679 | */ |
1675 | smp_wmb(); | 1680 | smp_wmb(); |
1676 | 1681 | ||
1682 | perf_pmu_disable(event->pmu); | ||
1683 | |||
1677 | if (event->pmu->add(event, PERF_EF_START)) { | 1684 | if (event->pmu->add(event, PERF_EF_START)) { |
1678 | event->state = PERF_EVENT_STATE_INACTIVE; | 1685 | event->state = PERF_EVENT_STATE_INACTIVE; |
1679 | event->oncpu = -1; | 1686 | event->oncpu = -1; |
1680 | return -EAGAIN; | 1687 | ret = -EAGAIN; |
1688 | goto out; | ||
1681 | } | 1689 | } |
1682 | 1690 | ||
1683 | event->tstamp_running += tstamp - event->tstamp_stopped; | 1691 | event->tstamp_running += tstamp - event->tstamp_stopped; |
@@ -1693,7 +1701,10 @@ event_sched_in(struct perf_event *event, | |||
1693 | if (event->attr.exclusive) | 1701 | if (event->attr.exclusive) |
1694 | cpuctx->exclusive = 1; | 1702 | cpuctx->exclusive = 1; |
1695 | 1703 | ||
1696 | return 0; | 1704 | out: |
1705 | perf_pmu_enable(event->pmu); | ||
1706 | |||
1707 | return ret; | ||
1697 | } | 1708 | } |
1698 | 1709 | ||
1699 | static int | 1710 | static int |
@@ -2743,6 +2754,8 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx, | |||
2743 | if (!event_filter_match(event)) | 2754 | if (!event_filter_match(event)) |
2744 | continue; | 2755 | continue; |
2745 | 2756 | ||
2757 | perf_pmu_disable(event->pmu); | ||
2758 | |||
2746 | hwc = &event->hw; | 2759 | hwc = &event->hw; |
2747 | 2760 | ||
2748 | if (hwc->interrupts == MAX_INTERRUPTS) { | 2761 | if (hwc->interrupts == MAX_INTERRUPTS) { |
@@ -2752,7 +2765,7 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx, | |||
2752 | } | 2765 | } |
2753 | 2766 | ||
2754 | if (!event->attr.freq || !event->attr.sample_freq) | 2767 | if (!event->attr.freq || !event->attr.sample_freq) |
2755 | continue; | 2768 | goto next; |
2756 | 2769 | ||
2757 | /* | 2770 | /* |
2758 | * stop the event and update event->count | 2771 | * stop the event and update event->count |
@@ -2774,6 +2787,8 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx, | |||
2774 | perf_adjust_period(event, period, delta, false); | 2787 | perf_adjust_period(event, period, delta, false); |
2775 | 2788 | ||
2776 | event->pmu->start(event, delta > 0 ? PERF_EF_RELOAD : 0); | 2789 | event->pmu->start(event, delta > 0 ? PERF_EF_RELOAD : 0); |
2790 | next: | ||
2791 | perf_pmu_enable(event->pmu); | ||
2777 | } | 2792 | } |
2778 | 2793 | ||
2779 | perf_pmu_enable(ctx->pmu); | 2794 | perf_pmu_enable(ctx->pmu); |
diff --git a/kernel/fork.c b/kernel/fork.c index 728d5be9548c..5721f0e3f2da 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -537,6 +537,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p) | |||
537 | spin_lock_init(&mm->page_table_lock); | 537 | spin_lock_init(&mm->page_table_lock); |
538 | mm_init_aio(mm); | 538 | mm_init_aio(mm); |
539 | mm_init_owner(mm, p); | 539 | mm_init_owner(mm, p); |
540 | clear_tlb_flush_pending(mm); | ||
540 | 541 | ||
541 | if (likely(!mm_alloc_pgd(mm))) { | 542 | if (likely(!mm_alloc_pgd(mm))) { |
542 | mm->def_flags = 0; | 543 | mm->def_flags = 0; |
diff --git a/kernel/freezer.c b/kernel/freezer.c index b462fa197517..aa6a8aadb911 100644 --- a/kernel/freezer.c +++ b/kernel/freezer.c | |||
@@ -19,6 +19,12 @@ EXPORT_SYMBOL(system_freezing_cnt); | |||
19 | bool pm_freezing; | 19 | bool pm_freezing; |
20 | bool pm_nosig_freezing; | 20 | bool pm_nosig_freezing; |
21 | 21 | ||
22 | /* | ||
23 | * Temporary export for the deadlock workaround in ata_scsi_hotplug(). | ||
24 | * Remove once the hack becomes unnecessary. | ||
25 | */ | ||
26 | EXPORT_SYMBOL_GPL(pm_freezing); | ||
27 | |||
22 | /* protects freezing and frozen transitions */ | 28 | /* protects freezing and frozen transitions */ |
23 | static DEFINE_SPINLOCK(freezer_lock); | 29 | static DEFINE_SPINLOCK(freezer_lock); |
24 | 30 | ||
diff --git a/kernel/kexec.c b/kernel/kexec.c index d0d8fca54065..9c970167e402 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
@@ -1680,6 +1680,7 @@ int kernel_kexec(void) | |||
1680 | { | 1680 | { |
1681 | kexec_in_progress = true; | 1681 | kexec_in_progress = true; |
1682 | kernel_restart_prepare(NULL); | 1682 | kernel_restart_prepare(NULL); |
1683 | migrate_to_reboot_cpu(); | ||
1683 | printk(KERN_EMERG "Starting new kernel\n"); | 1684 | printk(KERN_EMERG "Starting new kernel\n"); |
1684 | machine_shutdown(); | 1685 | machine_shutdown(); |
1685 | } | 1686 | } |
diff --git a/kernel/power/console.c b/kernel/power/console.c index 463aa6736751..eacb8bd8cab4 100644 --- a/kernel/power/console.c +++ b/kernel/power/console.c | |||
@@ -81,6 +81,7 @@ void pm_vt_switch_unregister(struct device *dev) | |||
81 | list_for_each_entry(tmp, &pm_vt_switch_list, head) { | 81 | list_for_each_entry(tmp, &pm_vt_switch_list, head) { |
82 | if (tmp->dev == dev) { | 82 | if (tmp->dev == dev) { |
83 | list_del(&tmp->head); | 83 | list_del(&tmp->head); |
84 | kfree(tmp); | ||
84 | break; | 85 | break; |
85 | } | 86 | } |
86 | } | 87 | } |
diff --git a/kernel/reboot.c b/kernel/reboot.c index f813b3474646..662c83fc16b7 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c | |||
@@ -104,7 +104,7 @@ int unregister_reboot_notifier(struct notifier_block *nb) | |||
104 | } | 104 | } |
105 | EXPORT_SYMBOL(unregister_reboot_notifier); | 105 | EXPORT_SYMBOL(unregister_reboot_notifier); |
106 | 106 | ||
107 | static void migrate_to_reboot_cpu(void) | 107 | void migrate_to_reboot_cpu(void) |
108 | { | 108 | { |
109 | /* The boot cpu is always logical cpu 0 */ | 109 | /* The boot cpu is always logical cpu 0 */ |
110 | int cpu = reboot_cpu; | 110 | int cpu = reboot_cpu; |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index e85cda20ab2b..a88f4a485c5e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -4902,6 +4902,7 @@ DEFINE_PER_CPU(struct sched_domain *, sd_asym); | |||
4902 | static void update_top_cache_domain(int cpu) | 4902 | static void update_top_cache_domain(int cpu) |
4903 | { | 4903 | { |
4904 | struct sched_domain *sd; | 4904 | struct sched_domain *sd; |
4905 | struct sched_domain *busy_sd = NULL; | ||
4905 | int id = cpu; | 4906 | int id = cpu; |
4906 | int size = 1; | 4907 | int size = 1; |
4907 | 4908 | ||
@@ -4909,9 +4910,9 @@ static void update_top_cache_domain(int cpu) | |||
4909 | if (sd) { | 4910 | if (sd) { |
4910 | id = cpumask_first(sched_domain_span(sd)); | 4911 | id = cpumask_first(sched_domain_span(sd)); |
4911 | size = cpumask_weight(sched_domain_span(sd)); | 4912 | size = cpumask_weight(sched_domain_span(sd)); |
4912 | sd = sd->parent; /* sd_busy */ | 4913 | busy_sd = sd->parent; /* sd_busy */ |
4913 | } | 4914 | } |
4914 | rcu_assign_pointer(per_cpu(sd_busy, cpu), sd); | 4915 | rcu_assign_pointer(per_cpu(sd_busy, cpu), busy_sd); |
4915 | 4916 | ||
4916 | rcu_assign_pointer(per_cpu(sd_llc, cpu), sd); | 4917 | rcu_assign_pointer(per_cpu(sd_llc, cpu), sd); |
4917 | per_cpu(sd_llc_size, cpu) = size; | 4918 | per_cpu(sd_llc_size, cpu) = size; |
@@ -5112,6 +5113,7 @@ build_overlap_sched_groups(struct sched_domain *sd, int cpu) | |||
5112 | * die on a /0 trap. | 5113 | * die on a /0 trap. |
5113 | */ | 5114 | */ |
5114 | sg->sgp->power = SCHED_POWER_SCALE * cpumask_weight(sg_span); | 5115 | sg->sgp->power = SCHED_POWER_SCALE * cpumask_weight(sg_span); |
5116 | sg->sgp->power_orig = sg->sgp->power; | ||
5115 | 5117 | ||
5116 | /* | 5118 | /* |
5117 | * Make sure the first group of this domain contains the | 5119 | * Make sure the first group of this domain contains the |
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index fd773ade1a31..c7395d97e4cb 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -178,59 +178,61 @@ void sched_init_granularity(void) | |||
178 | update_sysctl(); | 178 | update_sysctl(); |
179 | } | 179 | } |
180 | 180 | ||
181 | #if BITS_PER_LONG == 32 | 181 | #define WMULT_CONST (~0U) |
182 | # define WMULT_CONST (~0UL) | ||
183 | #else | ||
184 | # define WMULT_CONST (1UL << 32) | ||
185 | #endif | ||
186 | |||
187 | #define WMULT_SHIFT 32 | 182 | #define WMULT_SHIFT 32 |
188 | 183 | ||
189 | /* | 184 | static void __update_inv_weight(struct load_weight *lw) |
190 | * Shift right and round: | 185 | { |
191 | */ | 186 | unsigned long w; |
192 | #define SRR(x, y) (((x) + (1UL << ((y) - 1))) >> (y)) | 187 | |
188 | if (likely(lw->inv_weight)) | ||
189 | return; | ||
190 | |||
191 | w = scale_load_down(lw->weight); | ||
192 | |||
193 | if (BITS_PER_LONG > 32 && unlikely(w >= WMULT_CONST)) | ||
194 | lw->inv_weight = 1; | ||
195 | else if (unlikely(!w)) | ||
196 | lw->inv_weight = WMULT_CONST; | ||
197 | else | ||
198 | lw->inv_weight = WMULT_CONST / w; | ||
199 | } | ||
193 | 200 | ||
194 | /* | 201 | /* |
195 | * delta *= weight / lw | 202 | * delta_exec * weight / lw.weight |
203 | * OR | ||
204 | * (delta_exec * (weight * lw->inv_weight)) >> WMULT_SHIFT | ||
205 | * | ||
206 | * Either weight := NICE_0_LOAD and lw \e prio_to_wmult[], in which case | ||
207 | * we're guaranteed shift stays positive because inv_weight is guaranteed to | ||
208 | * fit 32 bits, and NICE_0_LOAD gives another 10 bits; therefore shift >= 22. | ||
209 | * | ||
210 | * Or, weight =< lw.weight (because lw.weight is the runqueue weight), thus | ||
211 | * weight/lw.weight <= 1, and therefore our shift will also be positive. | ||
196 | */ | 212 | */ |
197 | static unsigned long | 213 | static u64 __calc_delta(u64 delta_exec, unsigned long weight, struct load_weight *lw) |
198 | calc_delta_mine(unsigned long delta_exec, unsigned long weight, | ||
199 | struct load_weight *lw) | ||
200 | { | 214 | { |
201 | u64 tmp; | 215 | u64 fact = scale_load_down(weight); |
202 | 216 | int shift = WMULT_SHIFT; | |
203 | /* | ||
204 | * weight can be less than 2^SCHED_LOAD_RESOLUTION for task group sched | ||
205 | * entities since MIN_SHARES = 2. Treat weight as 1 if less than | ||
206 | * 2^SCHED_LOAD_RESOLUTION. | ||
207 | */ | ||
208 | if (likely(weight > (1UL << SCHED_LOAD_RESOLUTION))) | ||
209 | tmp = (u64)delta_exec * scale_load_down(weight); | ||
210 | else | ||
211 | tmp = (u64)delta_exec; | ||
212 | 217 | ||
213 | if (!lw->inv_weight) { | 218 | __update_inv_weight(lw); |
214 | unsigned long w = scale_load_down(lw->weight); | ||
215 | 219 | ||
216 | if (BITS_PER_LONG > 32 && unlikely(w >= WMULT_CONST)) | 220 | if (unlikely(fact >> 32)) { |
217 | lw->inv_weight = 1; | 221 | while (fact >> 32) { |
218 | else if (unlikely(!w)) | 222 | fact >>= 1; |
219 | lw->inv_weight = WMULT_CONST; | 223 | shift--; |
220 | else | 224 | } |
221 | lw->inv_weight = WMULT_CONST / w; | ||
222 | } | 225 | } |
223 | 226 | ||
224 | /* | 227 | /* hint to use a 32x32->64 mul */ |
225 | * Check whether we'd overflow the 64-bit multiplication: | 228 | fact = (u64)(u32)fact * lw->inv_weight; |
226 | */ | 229 | |
227 | if (unlikely(tmp > WMULT_CONST)) | 230 | while (fact >> 32) { |
228 | tmp = SRR(SRR(tmp, WMULT_SHIFT/2) * lw->inv_weight, | 231 | fact >>= 1; |
229 | WMULT_SHIFT/2); | 232 | shift--; |
230 | else | 233 | } |
231 | tmp = SRR(tmp * lw->inv_weight, WMULT_SHIFT); | ||
232 | 234 | ||
233 | return (unsigned long)min(tmp, (u64)(unsigned long)LONG_MAX); | 235 | return mul_u64_u32_shr(delta_exec, fact, shift); |
234 | } | 236 | } |
235 | 237 | ||
236 | 238 | ||
@@ -443,7 +445,7 @@ find_matching_se(struct sched_entity **se, struct sched_entity **pse) | |||
443 | #endif /* CONFIG_FAIR_GROUP_SCHED */ | 445 | #endif /* CONFIG_FAIR_GROUP_SCHED */ |
444 | 446 | ||
445 | static __always_inline | 447 | static __always_inline |
446 | void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, unsigned long delta_exec); | 448 | void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec); |
447 | 449 | ||
448 | /************************************************************** | 450 | /************************************************************** |
449 | * Scheduling class tree data structure manipulation methods: | 451 | * Scheduling class tree data structure manipulation methods: |
@@ -612,11 +614,10 @@ int sched_proc_update_handler(struct ctl_table *table, int write, | |||
612 | /* | 614 | /* |
613 | * delta /= w | 615 | * delta /= w |
614 | */ | 616 | */ |
615 | static inline unsigned long | 617 | static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se) |
616 | calc_delta_fair(unsigned long delta, struct sched_entity *se) | ||
617 | { | 618 | { |
618 | if (unlikely(se->load.weight != NICE_0_LOAD)) | 619 | if (unlikely(se->load.weight != NICE_0_LOAD)) |
619 | delta = calc_delta_mine(delta, NICE_0_LOAD, &se->load); | 620 | delta = __calc_delta(delta, NICE_0_LOAD, &se->load); |
620 | 621 | ||
621 | return delta; | 622 | return delta; |
622 | } | 623 | } |
@@ -665,7 +666,7 @@ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
665 | update_load_add(&lw, se->load.weight); | 666 | update_load_add(&lw, se->load.weight); |
666 | load = &lw; | 667 | load = &lw; |
667 | } | 668 | } |
668 | slice = calc_delta_mine(slice, se->load.weight, load); | 669 | slice = __calc_delta(slice, se->load.weight, load); |
669 | } | 670 | } |
670 | return slice; | 671 | return slice; |
671 | } | 672 | } |
@@ -703,47 +704,32 @@ void init_task_runnable_average(struct task_struct *p) | |||
703 | #endif | 704 | #endif |
704 | 705 | ||
705 | /* | 706 | /* |
706 | * Update the current task's runtime statistics. Skip current tasks that | 707 | * Update the current task's runtime statistics. |
707 | * are not in our scheduling class. | ||
708 | */ | 708 | */ |
709 | static inline void | ||
710 | __update_curr(struct cfs_rq *cfs_rq, struct sched_entity *curr, | ||
711 | unsigned long delta_exec) | ||
712 | { | ||
713 | unsigned long delta_exec_weighted; | ||
714 | |||
715 | schedstat_set(curr->statistics.exec_max, | ||
716 | max((u64)delta_exec, curr->statistics.exec_max)); | ||
717 | |||
718 | curr->sum_exec_runtime += delta_exec; | ||
719 | schedstat_add(cfs_rq, exec_clock, delta_exec); | ||
720 | delta_exec_weighted = calc_delta_fair(delta_exec, curr); | ||
721 | |||
722 | curr->vruntime += delta_exec_weighted; | ||
723 | update_min_vruntime(cfs_rq); | ||
724 | } | ||
725 | |||
726 | static void update_curr(struct cfs_rq *cfs_rq) | 709 | static void update_curr(struct cfs_rq *cfs_rq) |
727 | { | 710 | { |
728 | struct sched_entity *curr = cfs_rq->curr; | 711 | struct sched_entity *curr = cfs_rq->curr; |
729 | u64 now = rq_clock_task(rq_of(cfs_rq)); | 712 | u64 now = rq_clock_task(rq_of(cfs_rq)); |
730 | unsigned long delta_exec; | 713 | u64 delta_exec; |
731 | 714 | ||
732 | if (unlikely(!curr)) | 715 | if (unlikely(!curr)) |
733 | return; | 716 | return; |
734 | 717 | ||
735 | /* | 718 | delta_exec = now - curr->exec_start; |
736 | * Get the amount of time the current task was running | 719 | if (unlikely((s64)delta_exec <= 0)) |
737 | * since the last time we changed load (this cannot | ||
738 | * overflow on 32 bits): | ||
739 | */ | ||
740 | delta_exec = (unsigned long)(now - curr->exec_start); | ||
741 | if (!delta_exec) | ||
742 | return; | 720 | return; |
743 | 721 | ||
744 | __update_curr(cfs_rq, curr, delta_exec); | ||
745 | curr->exec_start = now; | 722 | curr->exec_start = now; |
746 | 723 | ||
724 | schedstat_set(curr->statistics.exec_max, | ||
725 | max(delta_exec, curr->statistics.exec_max)); | ||
726 | |||
727 | curr->sum_exec_runtime += delta_exec; | ||
728 | schedstat_add(cfs_rq, exec_clock, delta_exec); | ||
729 | |||
730 | curr->vruntime += calc_delta_fair(delta_exec, curr); | ||
731 | update_min_vruntime(cfs_rq); | ||
732 | |||
747 | if (entity_is_task(curr)) { | 733 | if (entity_is_task(curr)) { |
748 | struct task_struct *curtask = task_of(curr); | 734 | struct task_struct *curtask = task_of(curr); |
749 | 735 | ||
@@ -1752,6 +1738,13 @@ void task_numa_work(struct callback_head *work) | |||
1752 | (vma->vm_file && (vma->vm_flags & (VM_READ|VM_WRITE)) == (VM_READ))) | 1738 | (vma->vm_file && (vma->vm_flags & (VM_READ|VM_WRITE)) == (VM_READ))) |
1753 | continue; | 1739 | continue; |
1754 | 1740 | ||
1741 | /* | ||
1742 | * Skip inaccessible VMAs to avoid any confusion between | ||
1743 | * PROT_NONE and NUMA hinting ptes | ||
1744 | */ | ||
1745 | if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))) | ||
1746 | continue; | ||
1747 | |||
1755 | do { | 1748 | do { |
1756 | start = max(start, vma->vm_start); | 1749 | start = max(start, vma->vm_start); |
1757 | end = ALIGN(start + (pages << PAGE_SHIFT), HPAGE_SIZE); | 1750 | end = ALIGN(start + (pages << PAGE_SHIFT), HPAGE_SIZE); |
@@ -3015,8 +3008,7 @@ static void expire_cfs_rq_runtime(struct cfs_rq *cfs_rq) | |||
3015 | } | 3008 | } |
3016 | } | 3009 | } |
3017 | 3010 | ||
3018 | static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq, | 3011 | static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) |
3019 | unsigned long delta_exec) | ||
3020 | { | 3012 | { |
3021 | /* dock delta_exec before expiring quota (as it could span periods) */ | 3013 | /* dock delta_exec before expiring quota (as it could span periods) */ |
3022 | cfs_rq->runtime_remaining -= delta_exec; | 3014 | cfs_rq->runtime_remaining -= delta_exec; |
@@ -3034,7 +3026,7 @@ static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq, | |||
3034 | } | 3026 | } |
3035 | 3027 | ||
3036 | static __always_inline | 3028 | static __always_inline |
3037 | void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, unsigned long delta_exec) | 3029 | void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) |
3038 | { | 3030 | { |
3039 | if (!cfs_bandwidth_used() || !cfs_rq->runtime_enabled) | 3031 | if (!cfs_bandwidth_used() || !cfs_rq->runtime_enabled) |
3040 | return; | 3032 | return; |
@@ -3574,8 +3566,7 @@ static inline u64 cfs_rq_clock_task(struct cfs_rq *cfs_rq) | |||
3574 | return rq_clock_task(rq_of(cfs_rq)); | 3566 | return rq_clock_task(rq_of(cfs_rq)); |
3575 | } | 3567 | } |
3576 | 3568 | ||
3577 | static void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, | 3569 | static void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) {} |
3578 | unsigned long delta_exec) {} | ||
3579 | static void check_cfs_rq_runtime(struct cfs_rq *cfs_rq) {} | 3570 | static void check_cfs_rq_runtime(struct cfs_rq *cfs_rq) {} |
3580 | static void check_enqueue_throttle(struct cfs_rq *cfs_rq) {} | 3571 | static void check_enqueue_throttle(struct cfs_rq *cfs_rq) {} |
3581 | static __always_inline void return_cfs_rq_runtime(struct cfs_rq *cfs_rq) {} | 3572 | static __always_inline void return_cfs_rq_runtime(struct cfs_rq *cfs_rq) {} |
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 7d57275fc396..1c4065575fa2 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c | |||
@@ -901,6 +901,13 @@ inc_rt_prio_smp(struct rt_rq *rt_rq, int prio, int prev_prio) | |||
901 | { | 901 | { |
902 | struct rq *rq = rq_of_rt_rq(rt_rq); | 902 | struct rq *rq = rq_of_rt_rq(rt_rq); |
903 | 903 | ||
904 | #ifdef CONFIG_RT_GROUP_SCHED | ||
905 | /* | ||
906 | * Change rq's cpupri only if rt_rq is the top queue. | ||
907 | */ | ||
908 | if (&rq->rt != rt_rq) | ||
909 | return; | ||
910 | #endif | ||
904 | if (rq->online && prio < prev_prio) | 911 | if (rq->online && prio < prev_prio) |
905 | cpupri_set(&rq->rd->cpupri, rq->cpu, prio); | 912 | cpupri_set(&rq->rd->cpupri, rq->cpu, prio); |
906 | } | 913 | } |
@@ -910,6 +917,13 @@ dec_rt_prio_smp(struct rt_rq *rt_rq, int prio, int prev_prio) | |||
910 | { | 917 | { |
911 | struct rq *rq = rq_of_rt_rq(rt_rq); | 918 | struct rq *rq = rq_of_rt_rq(rt_rq); |
912 | 919 | ||
920 | #ifdef CONFIG_RT_GROUP_SCHED | ||
921 | /* | ||
922 | * Change rq's cpupri only if rt_rq is the top queue. | ||
923 | */ | ||
924 | if (&rq->rt != rt_rq) | ||
925 | return; | ||
926 | #endif | ||
913 | if (rq->online && rt_rq->highest_prio.curr != prev_prio) | 927 | if (rq->online && rt_rq->highest_prio.curr != prev_prio) |
914 | cpupri_set(&rq->rd->cpupri, rq->cpu, rt_rq->highest_prio.curr); | 928 | cpupri_set(&rq->rd->cpupri, rq->cpu, rt_rq->highest_prio.curr); |
915 | } | 929 | } |
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 0e9f9eaade2f..72a0f81dc5a8 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -775,7 +775,7 @@ static int ftrace_profile_init(void) | |||
775 | int cpu; | 775 | int cpu; |
776 | int ret = 0; | 776 | int ret = 0; |
777 | 777 | ||
778 | for_each_online_cpu(cpu) { | 778 | for_each_possible_cpu(cpu) { |
779 | ret = ftrace_profile_init_cpu(cpu); | 779 | ret = ftrace_profile_init_cpu(cpu); |
780 | if (ret) | 780 | if (ret) |
781 | break; | 781 | break; |
diff --git a/kernel/user.c b/kernel/user.c index a3a0dbfda329..c006131beb77 100644 --- a/kernel/user.c +++ b/kernel/user.c | |||
@@ -51,9 +51,9 @@ struct user_namespace init_user_ns = { | |||
51 | .owner = GLOBAL_ROOT_UID, | 51 | .owner = GLOBAL_ROOT_UID, |
52 | .group = GLOBAL_ROOT_GID, | 52 | .group = GLOBAL_ROOT_GID, |
53 | .proc_inum = PROC_USER_INIT_INO, | 53 | .proc_inum = PROC_USER_INIT_INO, |
54 | #ifdef CONFIG_KEYS_KERBEROS_CACHE | 54 | #ifdef CONFIG_PERSISTENT_KEYRINGS |
55 | .krb_cache_register_sem = | 55 | .persistent_keyring_register_sem = |
56 | __RWSEM_INITIALIZER(init_user_ns.krb_cache_register_sem), | 56 | __RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem), |
57 | #endif | 57 | #endif |
58 | }; | 58 | }; |
59 | EXPORT_SYMBOL_GPL(init_user_ns); | 59 | EXPORT_SYMBOL_GPL(init_user_ns); |
diff --git a/mm/Kconfig b/mm/Kconfig index eb69f352401d..723bbe04a0b0 100644 --- a/mm/Kconfig +++ b/mm/Kconfig | |||
@@ -543,7 +543,7 @@ config ZSWAP | |||
543 | 543 | ||
544 | config MEM_SOFT_DIRTY | 544 | config MEM_SOFT_DIRTY |
545 | bool "Track memory changes" | 545 | bool "Track memory changes" |
546 | depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY | 546 | depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY && PROC_FS |
547 | select PROC_PAGE_MONITOR | 547 | select PROC_PAGE_MONITOR |
548 | help | 548 | help |
549 | This option enables memory changes tracking by introducing a | 549 | This option enables memory changes tracking by introducing a |
diff --git a/mm/compaction.c b/mm/compaction.c index 805165bcd3dd..f58bcd016f43 100644 --- a/mm/compaction.c +++ b/mm/compaction.c | |||
@@ -134,6 +134,10 @@ static void update_pageblock_skip(struct compact_control *cc, | |||
134 | bool migrate_scanner) | 134 | bool migrate_scanner) |
135 | { | 135 | { |
136 | struct zone *zone = cc->zone; | 136 | struct zone *zone = cc->zone; |
137 | |||
138 | if (cc->ignore_skip_hint) | ||
139 | return; | ||
140 | |||
137 | if (!page) | 141 | if (!page) |
138 | return; | 142 | return; |
139 | 143 | ||
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 33a5dc492810..7de1bf85f683 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -882,6 +882,10 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, | |||
882 | ret = 0; | 882 | ret = 0; |
883 | goto out_unlock; | 883 | goto out_unlock; |
884 | } | 884 | } |
885 | |||
886 | /* mmap_sem prevents this happening but warn if that changes */ | ||
887 | WARN_ON(pmd_trans_migrating(pmd)); | ||
888 | |||
885 | if (unlikely(pmd_trans_splitting(pmd))) { | 889 | if (unlikely(pmd_trans_splitting(pmd))) { |
886 | /* split huge page running from under us */ | 890 | /* split huge page running from under us */ |
887 | spin_unlock(src_ptl); | 891 | spin_unlock(src_ptl); |
@@ -1243,6 +1247,10 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, | |||
1243 | if ((flags & FOLL_DUMP) && is_huge_zero_pmd(*pmd)) | 1247 | if ((flags & FOLL_DUMP) && is_huge_zero_pmd(*pmd)) |
1244 | return ERR_PTR(-EFAULT); | 1248 | return ERR_PTR(-EFAULT); |
1245 | 1249 | ||
1250 | /* Full NUMA hinting faults to serialise migration in fault paths */ | ||
1251 | if ((flags & FOLL_NUMA) && pmd_numa(*pmd)) | ||
1252 | goto out; | ||
1253 | |||
1246 | page = pmd_page(*pmd); | 1254 | page = pmd_page(*pmd); |
1247 | VM_BUG_ON(!PageHead(page)); | 1255 | VM_BUG_ON(!PageHead(page)); |
1248 | if (flags & FOLL_TOUCH) { | 1256 | if (flags & FOLL_TOUCH) { |
@@ -1295,6 +1303,17 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, | |||
1295 | if (unlikely(!pmd_same(pmd, *pmdp))) | 1303 | if (unlikely(!pmd_same(pmd, *pmdp))) |
1296 | goto out_unlock; | 1304 | goto out_unlock; |
1297 | 1305 | ||
1306 | /* | ||
1307 | * If there are potential migrations, wait for completion and retry | ||
1308 | * without disrupting NUMA hinting information. Do not relock and | ||
1309 | * check_same as the page may no longer be mapped. | ||
1310 | */ | ||
1311 | if (unlikely(pmd_trans_migrating(*pmdp))) { | ||
1312 | spin_unlock(ptl); | ||
1313 | wait_migrate_huge_page(vma->anon_vma, pmdp); | ||
1314 | goto out; | ||
1315 | } | ||
1316 | |||
1298 | page = pmd_page(pmd); | 1317 | page = pmd_page(pmd); |
1299 | BUG_ON(is_huge_zero_page(page)); | 1318 | BUG_ON(is_huge_zero_page(page)); |
1300 | page_nid = page_to_nid(page); | 1319 | page_nid = page_to_nid(page); |
@@ -1323,23 +1342,22 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, | |||
1323 | /* If the page was locked, there are no parallel migrations */ | 1342 | /* If the page was locked, there are no parallel migrations */ |
1324 | if (page_locked) | 1343 | if (page_locked) |
1325 | goto clear_pmdnuma; | 1344 | goto clear_pmdnuma; |
1345 | } | ||
1326 | 1346 | ||
1327 | /* | 1347 | /* Migration could have started since the pmd_trans_migrating check */ |
1328 | * Otherwise wait for potential migrations and retry. We do | 1348 | if (!page_locked) { |
1329 | * relock and check_same as the page may no longer be mapped. | ||
1330 | * As the fault is being retried, do not account for it. | ||
1331 | */ | ||
1332 | spin_unlock(ptl); | 1349 | spin_unlock(ptl); |
1333 | wait_on_page_locked(page); | 1350 | wait_on_page_locked(page); |
1334 | page_nid = -1; | 1351 | page_nid = -1; |
1335 | goto out; | 1352 | goto out; |
1336 | } | 1353 | } |
1337 | 1354 | ||
1338 | /* Page is misplaced, serialise migrations and parallel THP splits */ | 1355 | /* |
1356 | * Page is misplaced. Page lock serialises migrations. Acquire anon_vma | ||
1357 | * to serialises splits | ||
1358 | */ | ||
1339 | get_page(page); | 1359 | get_page(page); |
1340 | spin_unlock(ptl); | 1360 | spin_unlock(ptl); |
1341 | if (!page_locked) | ||
1342 | lock_page(page); | ||
1343 | anon_vma = page_lock_anon_vma_read(page); | 1361 | anon_vma = page_lock_anon_vma_read(page); |
1344 | 1362 | ||
1345 | /* Confirm the PMD did not change while page_table_lock was released */ | 1363 | /* Confirm the PMD did not change while page_table_lock was released */ |
@@ -1351,6 +1369,13 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, | |||
1351 | goto out_unlock; | 1369 | goto out_unlock; |
1352 | } | 1370 | } |
1353 | 1371 | ||
1372 | /* Bail if we fail to protect against THP splits for any reason */ | ||
1373 | if (unlikely(!anon_vma)) { | ||
1374 | put_page(page); | ||
1375 | page_nid = -1; | ||
1376 | goto clear_pmdnuma; | ||
1377 | } | ||
1378 | |||
1354 | /* | 1379 | /* |
1355 | * Migrate the THP to the requested node, returns with page unlocked | 1380 | * Migrate the THP to the requested node, returns with page unlocked |
1356 | * and pmd_numa cleared. | 1381 | * and pmd_numa cleared. |
@@ -1517,6 +1542,8 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, | |||
1517 | ret = 1; | 1542 | ret = 1; |
1518 | if (!prot_numa) { | 1543 | if (!prot_numa) { |
1519 | entry = pmdp_get_and_clear(mm, addr, pmd); | 1544 | entry = pmdp_get_and_clear(mm, addr, pmd); |
1545 | if (pmd_numa(entry)) | ||
1546 | entry = pmd_mknonnuma(entry); | ||
1520 | entry = pmd_modify(entry, newprot); | 1547 | entry = pmd_modify(entry, newprot); |
1521 | ret = HPAGE_PMD_NR; | 1548 | ret = HPAGE_PMD_NR; |
1522 | BUG_ON(pmd_write(entry)); | 1549 | BUG_ON(pmd_write(entry)); |
@@ -1531,7 +1558,7 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, | |||
1531 | */ | 1558 | */ |
1532 | if (!is_huge_zero_page(page) && | 1559 | if (!is_huge_zero_page(page) && |
1533 | !pmd_numa(*pmd)) { | 1560 | !pmd_numa(*pmd)) { |
1534 | entry = pmdp_get_and_clear(mm, addr, pmd); | 1561 | entry = *pmd; |
1535 | entry = pmd_mknuma(entry); | 1562 | entry = pmd_mknuma(entry); |
1536 | ret = HPAGE_PMD_NR; | 1563 | ret = HPAGE_PMD_NR; |
1537 | } | 1564 | } |
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index b7c171602ba1..db08af92c6fc 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c | |||
@@ -1505,10 +1505,16 @@ static int soft_offline_huge_page(struct page *page, int flags) | |||
1505 | if (ret > 0) | 1505 | if (ret > 0) |
1506 | ret = -EIO; | 1506 | ret = -EIO; |
1507 | } else { | 1507 | } else { |
1508 | set_page_hwpoison_huge_page(hpage); | 1508 | /* overcommit hugetlb page will be freed to buddy */ |
1509 | dequeue_hwpoisoned_huge_page(hpage); | 1509 | if (PageHuge(page)) { |
1510 | atomic_long_add(1 << compound_order(hpage), | 1510 | set_page_hwpoison_huge_page(hpage); |
1511 | &num_poisoned_pages); | 1511 | dequeue_hwpoisoned_huge_page(hpage); |
1512 | atomic_long_add(1 << compound_order(hpage), | ||
1513 | &num_poisoned_pages); | ||
1514 | } else { | ||
1515 | SetPageHWPoison(page); | ||
1516 | atomic_long_inc(&num_poisoned_pages); | ||
1517 | } | ||
1512 | } | 1518 | } |
1513 | return ret; | 1519 | return ret; |
1514 | } | 1520 | } |
diff --git a/mm/memory.c b/mm/memory.c index 5d9025f3b3e1..6768ce9e57d2 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -4271,7 +4271,7 @@ void copy_user_huge_page(struct page *dst, struct page *src, | |||
4271 | } | 4271 | } |
4272 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */ | 4272 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */ |
4273 | 4273 | ||
4274 | #if USE_SPLIT_PTE_PTLOCKS && BLOATED_SPINLOCKS | 4274 | #if USE_SPLIT_PTE_PTLOCKS && ALLOC_SPLIT_PTLOCKS |
4275 | bool ptlock_alloc(struct page *page) | 4275 | bool ptlock_alloc(struct page *page) |
4276 | { | 4276 | { |
4277 | spinlock_t *ptl; | 4277 | spinlock_t *ptl; |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index eca4a3129129..0cd2c4d4e270 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -1197,14 +1197,16 @@ static struct page *new_vma_page(struct page *page, unsigned long private, int * | |||
1197 | break; | 1197 | break; |
1198 | vma = vma->vm_next; | 1198 | vma = vma->vm_next; |
1199 | } | 1199 | } |
1200 | |||
1201 | if (PageHuge(page)) { | ||
1202 | if (vma) | ||
1203 | return alloc_huge_page_noerr(vma, address, 1); | ||
1204 | else | ||
1205 | return NULL; | ||
1206 | } | ||
1200 | /* | 1207 | /* |
1201 | * queue_pages_range() confirms that @page belongs to some vma, | 1208 | * if !vma, alloc_page_vma() will use task or system default policy |
1202 | * so vma shouldn't be NULL. | ||
1203 | */ | 1209 | */ |
1204 | BUG_ON(!vma); | ||
1205 | |||
1206 | if (PageHuge(page)) | ||
1207 | return alloc_huge_page_noerr(vma, address, 1); | ||
1208 | return alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address); | 1210 | return alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address); |
1209 | } | 1211 | } |
1210 | #else | 1212 | #else |
@@ -1318,7 +1320,7 @@ static long do_mbind(unsigned long start, unsigned long len, | |||
1318 | if (nr_failed && (flags & MPOL_MF_STRICT)) | 1320 | if (nr_failed && (flags & MPOL_MF_STRICT)) |
1319 | err = -EIO; | 1321 | err = -EIO; |
1320 | } else | 1322 | } else |
1321 | putback_lru_pages(&pagelist); | 1323 | putback_movable_pages(&pagelist); |
1322 | 1324 | ||
1323 | up_write(&mm->mmap_sem); | 1325 | up_write(&mm->mmap_sem); |
1324 | mpol_out: | 1326 | mpol_out: |
diff --git a/mm/migrate.c b/mm/migrate.c index bb940045fe85..9194375b2307 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/hugetlb_cgroup.h> | 36 | #include <linux/hugetlb_cgroup.h> |
37 | #include <linux/gfp.h> | 37 | #include <linux/gfp.h> |
38 | #include <linux/balloon_compaction.h> | 38 | #include <linux/balloon_compaction.h> |
39 | #include <linux/mmu_notifier.h> | ||
39 | 40 | ||
40 | #include <asm/tlbflush.h> | 41 | #include <asm/tlbflush.h> |
41 | 42 | ||
@@ -316,14 +317,15 @@ static inline bool buffer_migrate_lock_buffers(struct buffer_head *head, | |||
316 | */ | 317 | */ |
317 | int migrate_page_move_mapping(struct address_space *mapping, | 318 | int migrate_page_move_mapping(struct address_space *mapping, |
318 | struct page *newpage, struct page *page, | 319 | struct page *newpage, struct page *page, |
319 | struct buffer_head *head, enum migrate_mode mode) | 320 | struct buffer_head *head, enum migrate_mode mode, |
321 | int extra_count) | ||
320 | { | 322 | { |
321 | int expected_count = 0; | 323 | int expected_count = 1 + extra_count; |
322 | void **pslot; | 324 | void **pslot; |
323 | 325 | ||
324 | if (!mapping) { | 326 | if (!mapping) { |
325 | /* Anonymous page without mapping */ | 327 | /* Anonymous page without mapping */ |
326 | if (page_count(page) != 1) | 328 | if (page_count(page) != expected_count) |
327 | return -EAGAIN; | 329 | return -EAGAIN; |
328 | return MIGRATEPAGE_SUCCESS; | 330 | return MIGRATEPAGE_SUCCESS; |
329 | } | 331 | } |
@@ -333,7 +335,7 @@ int migrate_page_move_mapping(struct address_space *mapping, | |||
333 | pslot = radix_tree_lookup_slot(&mapping->page_tree, | 335 | pslot = radix_tree_lookup_slot(&mapping->page_tree, |
334 | page_index(page)); | 336 | page_index(page)); |
335 | 337 | ||
336 | expected_count = 2 + page_has_private(page); | 338 | expected_count += 1 + page_has_private(page); |
337 | if (page_count(page) != expected_count || | 339 | if (page_count(page) != expected_count || |
338 | radix_tree_deref_slot_protected(pslot, &mapping->tree_lock) != page) { | 340 | radix_tree_deref_slot_protected(pslot, &mapping->tree_lock) != page) { |
339 | spin_unlock_irq(&mapping->tree_lock); | 341 | spin_unlock_irq(&mapping->tree_lock); |
@@ -583,7 +585,7 @@ int migrate_page(struct address_space *mapping, | |||
583 | 585 | ||
584 | BUG_ON(PageWriteback(page)); /* Writeback must be complete */ | 586 | BUG_ON(PageWriteback(page)); /* Writeback must be complete */ |
585 | 587 | ||
586 | rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode); | 588 | rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0); |
587 | 589 | ||
588 | if (rc != MIGRATEPAGE_SUCCESS) | 590 | if (rc != MIGRATEPAGE_SUCCESS) |
589 | return rc; | 591 | return rc; |
@@ -610,7 +612,7 @@ int buffer_migrate_page(struct address_space *mapping, | |||
610 | 612 | ||
611 | head = page_buffers(page); | 613 | head = page_buffers(page); |
612 | 614 | ||
613 | rc = migrate_page_move_mapping(mapping, newpage, page, head, mode); | 615 | rc = migrate_page_move_mapping(mapping, newpage, page, head, mode, 0); |
614 | 616 | ||
615 | if (rc != MIGRATEPAGE_SUCCESS) | 617 | if (rc != MIGRATEPAGE_SUCCESS) |
616 | return rc; | 618 | return rc; |
@@ -1654,6 +1656,18 @@ int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) | |||
1654 | return 1; | 1656 | return 1; |
1655 | } | 1657 | } |
1656 | 1658 | ||
1659 | bool pmd_trans_migrating(pmd_t pmd) | ||
1660 | { | ||
1661 | struct page *page = pmd_page(pmd); | ||
1662 | return PageLocked(page); | ||
1663 | } | ||
1664 | |||
1665 | void wait_migrate_huge_page(struct anon_vma *anon_vma, pmd_t *pmd) | ||
1666 | { | ||
1667 | struct page *page = pmd_page(*pmd); | ||
1668 | wait_on_page_locked(page); | ||
1669 | } | ||
1670 | |||
1657 | /* | 1671 | /* |
1658 | * Attempt to migrate a misplaced page to the specified destination | 1672 | * Attempt to migrate a misplaced page to the specified destination |
1659 | * node. Caller is expected to have an elevated reference count on | 1673 | * node. Caller is expected to have an elevated reference count on |
@@ -1716,12 +1730,14 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, | |||
1716 | struct page *page, int node) | 1730 | struct page *page, int node) |
1717 | { | 1731 | { |
1718 | spinlock_t *ptl; | 1732 | spinlock_t *ptl; |
1719 | unsigned long haddr = address & HPAGE_PMD_MASK; | ||
1720 | pg_data_t *pgdat = NODE_DATA(node); | 1733 | pg_data_t *pgdat = NODE_DATA(node); |
1721 | int isolated = 0; | 1734 | int isolated = 0; |
1722 | struct page *new_page = NULL; | 1735 | struct page *new_page = NULL; |
1723 | struct mem_cgroup *memcg = NULL; | 1736 | struct mem_cgroup *memcg = NULL; |
1724 | int page_lru = page_is_file_cache(page); | 1737 | int page_lru = page_is_file_cache(page); |
1738 | unsigned long mmun_start = address & HPAGE_PMD_MASK; | ||
1739 | unsigned long mmun_end = mmun_start + HPAGE_PMD_SIZE; | ||
1740 | pmd_t orig_entry; | ||
1725 | 1741 | ||
1726 | /* | 1742 | /* |
1727 | * Rate-limit the amount of data that is being migrated to a node. | 1743 | * Rate-limit the amount of data that is being migrated to a node. |
@@ -1744,6 +1760,9 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, | |||
1744 | goto out_fail; | 1760 | goto out_fail; |
1745 | } | 1761 | } |
1746 | 1762 | ||
1763 | if (mm_tlb_flush_pending(mm)) | ||
1764 | flush_tlb_range(vma, mmun_start, mmun_end); | ||
1765 | |||
1747 | /* Prepare a page as a migration target */ | 1766 | /* Prepare a page as a migration target */ |
1748 | __set_page_locked(new_page); | 1767 | __set_page_locked(new_page); |
1749 | SetPageSwapBacked(new_page); | 1768 | SetPageSwapBacked(new_page); |
@@ -1755,9 +1774,12 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, | |||
1755 | WARN_ON(PageLRU(new_page)); | 1774 | WARN_ON(PageLRU(new_page)); |
1756 | 1775 | ||
1757 | /* Recheck the target PMD */ | 1776 | /* Recheck the target PMD */ |
1777 | mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); | ||
1758 | ptl = pmd_lock(mm, pmd); | 1778 | ptl = pmd_lock(mm, pmd); |
1759 | if (unlikely(!pmd_same(*pmd, entry))) { | 1779 | if (unlikely(!pmd_same(*pmd, entry) || page_count(page) != 2)) { |
1780 | fail_putback: | ||
1760 | spin_unlock(ptl); | 1781 | spin_unlock(ptl); |
1782 | mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); | ||
1761 | 1783 | ||
1762 | /* Reverse changes made by migrate_page_copy() */ | 1784 | /* Reverse changes made by migrate_page_copy() */ |
1763 | if (TestClearPageActive(new_page)) | 1785 | if (TestClearPageActive(new_page)) |
@@ -1774,7 +1796,8 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, | |||
1774 | putback_lru_page(page); | 1796 | putback_lru_page(page); |
1775 | mod_zone_page_state(page_zone(page), | 1797 | mod_zone_page_state(page_zone(page), |
1776 | NR_ISOLATED_ANON + page_lru, -HPAGE_PMD_NR); | 1798 | NR_ISOLATED_ANON + page_lru, -HPAGE_PMD_NR); |
1777 | goto out_fail; | 1799 | |
1800 | goto out_unlock; | ||
1778 | } | 1801 | } |
1779 | 1802 | ||
1780 | /* | 1803 | /* |
@@ -1786,16 +1809,35 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, | |||
1786 | */ | 1809 | */ |
1787 | mem_cgroup_prepare_migration(page, new_page, &memcg); | 1810 | mem_cgroup_prepare_migration(page, new_page, &memcg); |
1788 | 1811 | ||
1812 | orig_entry = *pmd; | ||
1789 | entry = mk_pmd(new_page, vma->vm_page_prot); | 1813 | entry = mk_pmd(new_page, vma->vm_page_prot); |
1790 | entry = pmd_mknonnuma(entry); | ||
1791 | entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); | ||
1792 | entry = pmd_mkhuge(entry); | 1814 | entry = pmd_mkhuge(entry); |
1815 | entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); | ||
1793 | 1816 | ||
1794 | pmdp_clear_flush(vma, haddr, pmd); | 1817 | /* |
1795 | set_pmd_at(mm, haddr, pmd, entry); | 1818 | * Clear the old entry under pagetable lock and establish the new PTE. |
1796 | page_add_new_anon_rmap(new_page, vma, haddr); | 1819 | * Any parallel GUP will either observe the old page blocking on the |
1820 | * page lock, block on the page table lock or observe the new page. | ||
1821 | * The SetPageUptodate on the new page and page_add_new_anon_rmap | ||
1822 | * guarantee the copy is visible before the pagetable update. | ||
1823 | */ | ||
1824 | flush_cache_range(vma, mmun_start, mmun_end); | ||
1825 | page_add_new_anon_rmap(new_page, vma, mmun_start); | ||
1826 | pmdp_clear_flush(vma, mmun_start, pmd); | ||
1827 | set_pmd_at(mm, mmun_start, pmd, entry); | ||
1828 | flush_tlb_range(vma, mmun_start, mmun_end); | ||
1797 | update_mmu_cache_pmd(vma, address, &entry); | 1829 | update_mmu_cache_pmd(vma, address, &entry); |
1830 | |||
1831 | if (page_count(page) != 2) { | ||
1832 | set_pmd_at(mm, mmun_start, pmd, orig_entry); | ||
1833 | flush_tlb_range(vma, mmun_start, mmun_end); | ||
1834 | update_mmu_cache_pmd(vma, address, &entry); | ||
1835 | page_remove_rmap(new_page); | ||
1836 | goto fail_putback; | ||
1837 | } | ||
1838 | |||
1798 | page_remove_rmap(page); | 1839 | page_remove_rmap(page); |
1840 | |||
1799 | /* | 1841 | /* |
1800 | * Finish the charge transaction under the page table lock to | 1842 | * Finish the charge transaction under the page table lock to |
1801 | * prevent split_huge_page() from dividing up the charge | 1843 | * prevent split_huge_page() from dividing up the charge |
@@ -1803,6 +1845,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, | |||
1803 | */ | 1845 | */ |
1804 | mem_cgroup_end_migration(memcg, page, new_page, true); | 1846 | mem_cgroup_end_migration(memcg, page, new_page, true); |
1805 | spin_unlock(ptl); | 1847 | spin_unlock(ptl); |
1848 | mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); | ||
1806 | 1849 | ||
1807 | unlock_page(new_page); | 1850 | unlock_page(new_page); |
1808 | unlock_page(page); | 1851 | unlock_page(page); |
@@ -1820,10 +1863,15 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, | |||
1820 | out_fail: | 1863 | out_fail: |
1821 | count_vm_events(PGMIGRATE_FAIL, HPAGE_PMD_NR); | 1864 | count_vm_events(PGMIGRATE_FAIL, HPAGE_PMD_NR); |
1822 | out_dropref: | 1865 | out_dropref: |
1823 | entry = pmd_mknonnuma(entry); | 1866 | ptl = pmd_lock(mm, pmd); |
1824 | set_pmd_at(mm, haddr, pmd, entry); | 1867 | if (pmd_same(*pmd, entry)) { |
1825 | update_mmu_cache_pmd(vma, address, &entry); | 1868 | entry = pmd_mknonnuma(entry); |
1869 | set_pmd_at(mm, mmun_start, pmd, entry); | ||
1870 | update_mmu_cache_pmd(vma, address, &entry); | ||
1871 | } | ||
1872 | spin_unlock(ptl); | ||
1826 | 1873 | ||
1874 | out_unlock: | ||
1827 | unlock_page(page); | 1875 | unlock_page(page); |
1828 | put_page(page); | 1876 | put_page(page); |
1829 | return 0; | 1877 | return 0; |
diff --git a/mm/mprotect.c b/mm/mprotect.c index 26667971c824..bb53a6591aea 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c | |||
@@ -52,17 +52,21 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd, | |||
52 | pte_t ptent; | 52 | pte_t ptent; |
53 | bool updated = false; | 53 | bool updated = false; |
54 | 54 | ||
55 | ptent = ptep_modify_prot_start(mm, addr, pte); | ||
56 | if (!prot_numa) { | 55 | if (!prot_numa) { |
56 | ptent = ptep_modify_prot_start(mm, addr, pte); | ||
57 | if (pte_numa(ptent)) | ||
58 | ptent = pte_mknonnuma(ptent); | ||
57 | ptent = pte_modify(ptent, newprot); | 59 | ptent = pte_modify(ptent, newprot); |
58 | updated = true; | 60 | updated = true; |
59 | } else { | 61 | } else { |
60 | struct page *page; | 62 | struct page *page; |
61 | 63 | ||
64 | ptent = *pte; | ||
62 | page = vm_normal_page(vma, addr, oldpte); | 65 | page = vm_normal_page(vma, addr, oldpte); |
63 | if (page) { | 66 | if (page) { |
64 | if (!pte_numa(oldpte)) { | 67 | if (!pte_numa(oldpte)) { |
65 | ptent = pte_mknuma(ptent); | 68 | ptent = pte_mknuma(ptent); |
69 | set_pte_at(mm, addr, pte, ptent); | ||
66 | updated = true; | 70 | updated = true; |
67 | } | 71 | } |
68 | } | 72 | } |
@@ -79,7 +83,10 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd, | |||
79 | 83 | ||
80 | if (updated) | 84 | if (updated) |
81 | pages++; | 85 | pages++; |
82 | ptep_modify_prot_commit(mm, addr, pte, ptent); | 86 | |
87 | /* Only !prot_numa always clears the pte */ | ||
88 | if (!prot_numa) | ||
89 | ptep_modify_prot_commit(mm, addr, pte, ptent); | ||
83 | } else if (IS_ENABLED(CONFIG_MIGRATION) && !pte_file(oldpte)) { | 90 | } else if (IS_ENABLED(CONFIG_MIGRATION) && !pte_file(oldpte)) { |
84 | swp_entry_t entry = pte_to_swp_entry(oldpte); | 91 | swp_entry_t entry = pte_to_swp_entry(oldpte); |
85 | 92 | ||
@@ -181,6 +188,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma, | |||
181 | BUG_ON(addr >= end); | 188 | BUG_ON(addr >= end); |
182 | pgd = pgd_offset(mm, addr); | 189 | pgd = pgd_offset(mm, addr); |
183 | flush_cache_range(vma, addr, end); | 190 | flush_cache_range(vma, addr, end); |
191 | set_tlb_flush_pending(mm); | ||
184 | do { | 192 | do { |
185 | next = pgd_addr_end(addr, end); | 193 | next = pgd_addr_end(addr, end); |
186 | if (pgd_none_or_clear_bad(pgd)) | 194 | if (pgd_none_or_clear_bad(pgd)) |
@@ -192,6 +200,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma, | |||
192 | /* Only flush the TLB if we actually modified any entries: */ | 200 | /* Only flush the TLB if we actually modified any entries: */ |
193 | if (pages) | 201 | if (pages) |
194 | flush_tlb_range(vma, start, end); | 202 | flush_tlb_range(vma, start, end); |
203 | clear_tlb_flush_pending(mm); | ||
195 | 204 | ||
196 | return pages; | 205 | return pages; |
197 | } | 206 | } |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 580a5f075ed0..5248fe070aa4 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1816,7 +1816,7 @@ static void zlc_clear_zones_full(struct zonelist *zonelist) | |||
1816 | 1816 | ||
1817 | static bool zone_local(struct zone *local_zone, struct zone *zone) | 1817 | static bool zone_local(struct zone *local_zone, struct zone *zone) |
1818 | { | 1818 | { |
1819 | return node_distance(local_zone->node, zone->node) == LOCAL_DISTANCE; | 1819 | return local_zone->node == zone->node; |
1820 | } | 1820 | } |
1821 | 1821 | ||
1822 | static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone) | 1822 | static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone) |
@@ -1913,18 +1913,17 @@ zonelist_scan: | |||
1913 | * page was allocated in should have no effect on the | 1913 | * page was allocated in should have no effect on the |
1914 | * time the page has in memory before being reclaimed. | 1914 | * time the page has in memory before being reclaimed. |
1915 | * | 1915 | * |
1916 | * When zone_reclaim_mode is enabled, try to stay in | 1916 | * Try to stay in local zones in the fastpath. If |
1917 | * local zones in the fastpath. If that fails, the | 1917 | * that fails, the slowpath is entered, which will do |
1918 | * slowpath is entered, which will do another pass | 1918 | * another pass starting with the local zones, but |
1919 | * starting with the local zones, but ultimately fall | 1919 | * ultimately fall back to remote zones that do not |
1920 | * back to remote zones that do not partake in the | 1920 | * partake in the fairness round-robin cycle of this |
1921 | * fairness round-robin cycle of this zonelist. | 1921 | * zonelist. |
1922 | */ | 1922 | */ |
1923 | if (alloc_flags & ALLOC_WMARK_LOW) { | 1923 | if (alloc_flags & ALLOC_WMARK_LOW) { |
1924 | if (zone_page_state(zone, NR_ALLOC_BATCH) <= 0) | 1924 | if (zone_page_state(zone, NR_ALLOC_BATCH) <= 0) |
1925 | continue; | 1925 | continue; |
1926 | if (zone_reclaim_mode && | 1926 | if (!zone_local(preferred_zone, zone)) |
1927 | !zone_local(preferred_zone, zone)) | ||
1928 | continue; | 1927 | continue; |
1929 | } | 1928 | } |
1930 | /* | 1929 | /* |
@@ -2390,7 +2389,7 @@ static void prepare_slowpath(gfp_t gfp_mask, unsigned int order, | |||
2390 | * thrash fairness information for zones that are not | 2389 | * thrash fairness information for zones that are not |
2391 | * actually part of this zonelist's round-robin cycle. | 2390 | * actually part of this zonelist's round-robin cycle. |
2392 | */ | 2391 | */ |
2393 | if (zone_reclaim_mode && !zone_local(preferred_zone, zone)) | 2392 | if (!zone_local(preferred_zone, zone)) |
2394 | continue; | 2393 | continue; |
2395 | mod_zone_page_state(zone, NR_ALLOC_BATCH, | 2394 | mod_zone_page_state(zone, NR_ALLOC_BATCH, |
2396 | high_wmark_pages(zone) - | 2395 | high_wmark_pages(zone) - |
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c index cbb38545d9d6..a8b919925934 100644 --- a/mm/pgtable-generic.c +++ b/mm/pgtable-generic.c | |||
@@ -110,9 +110,10 @@ int pmdp_clear_flush_young(struct vm_area_struct *vma, | |||
110 | pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long address, | 110 | pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long address, |
111 | pte_t *ptep) | 111 | pte_t *ptep) |
112 | { | 112 | { |
113 | struct mm_struct *mm = (vma)->vm_mm; | ||
113 | pte_t pte; | 114 | pte_t pte; |
114 | pte = ptep_get_and_clear((vma)->vm_mm, address, ptep); | 115 | pte = ptep_get_and_clear(mm, address, ptep); |
115 | if (pte_accessible(pte)) | 116 | if (pte_accessible(mm, pte)) |
116 | flush_tlb_page(vma, address); | 117 | flush_tlb_page(vma, address); |
117 | return pte; | 118 | return pte; |
118 | } | 119 | } |
@@ -191,6 +192,9 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp) | |||
191 | void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, | 192 | void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, |
192 | pmd_t *pmdp) | 193 | pmd_t *pmdp) |
193 | { | 194 | { |
195 | pmd_t entry = *pmdp; | ||
196 | if (pmd_numa(entry)) | ||
197 | entry = pmd_mknonnuma(entry); | ||
194 | set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(*pmdp)); | 198 | set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(*pmdp)); |
195 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); | 199 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
196 | } | 200 | } |
@@ -600,7 +600,11 @@ pte_t *__page_check_address(struct page *page, struct mm_struct *mm, | |||
600 | spinlock_t *ptl; | 600 | spinlock_t *ptl; |
601 | 601 | ||
602 | if (unlikely(PageHuge(page))) { | 602 | if (unlikely(PageHuge(page))) { |
603 | /* when pud is not present, pte will be NULL */ | ||
603 | pte = huge_pte_offset(mm, address); | 604 | pte = huge_pte_offset(mm, address); |
605 | if (!pte) | ||
606 | return NULL; | ||
607 | |||
604 | ptl = huge_pte_lockptr(page_hstate(page), mm, pte); | 608 | ptl = huge_pte_lockptr(page_hstate(page), mm, pte); |
605 | goto check; | 609 | goto check; |
606 | } | 610 | } |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index ca15f32821fb..36b1443f9ae4 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -1161,6 +1161,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, | |||
1161 | neigh->parms->reachable_time : | 1161 | neigh->parms->reachable_time : |
1162 | 0))); | 1162 | 0))); |
1163 | neigh->nud_state = new; | 1163 | neigh->nud_state = new; |
1164 | notify = 1; | ||
1164 | } | 1165 | } |
1165 | 1166 | ||
1166 | if (lladdr != neigh->ha) { | 1167 | if (lladdr != neigh->ha) { |
diff --git a/net/ipv4/netfilter/ipt_SYNPROXY.c b/net/ipv4/netfilter/ipt_SYNPROXY.c index f13bd91d9a56..a313c3fbeb46 100644 --- a/net/ipv4/netfilter/ipt_SYNPROXY.c +++ b/net/ipv4/netfilter/ipt_SYNPROXY.c | |||
@@ -423,6 +423,7 @@ static void synproxy_tg4_destroy(const struct xt_tgdtor_param *par) | |||
423 | static struct xt_target synproxy_tg4_reg __read_mostly = { | 423 | static struct xt_target synproxy_tg4_reg __read_mostly = { |
424 | .name = "SYNPROXY", | 424 | .name = "SYNPROXY", |
425 | .family = NFPROTO_IPV4, | 425 | .family = NFPROTO_IPV4, |
426 | .hooks = (1 << NF_INET_LOCAL_IN) | (1 << NF_INET_FORWARD), | ||
426 | .target = synproxy_tg4, | 427 | .target = synproxy_tg4, |
427 | .targetsize = sizeof(struct xt_synproxy_info), | 428 | .targetsize = sizeof(struct xt_synproxy_info), |
428 | .checkentry = synproxy_tg4_check, | 429 | .checkentry = synproxy_tg4_check, |
diff --git a/net/ipv4/netfilter/nft_reject_ipv4.c b/net/ipv4/netfilter/nft_reject_ipv4.c index fff5ba1a33b7..4a5e94ac314a 100644 --- a/net/ipv4/netfilter/nft_reject_ipv4.c +++ b/net/ipv4/netfilter/nft_reject_ipv4.c | |||
@@ -72,7 +72,7 @@ static int nft_reject_dump(struct sk_buff *skb, const struct nft_expr *expr) | |||
72 | { | 72 | { |
73 | const struct nft_reject *priv = nft_expr_priv(expr); | 73 | const struct nft_reject *priv = nft_expr_priv(expr); |
74 | 74 | ||
75 | if (nla_put_be32(skb, NFTA_REJECT_TYPE, priv->type)) | 75 | if (nla_put_be32(skb, NFTA_REJECT_TYPE, htonl(priv->type))) |
76 | goto nla_put_failure; | 76 | goto nla_put_failure; |
77 | 77 | ||
78 | switch (priv->type) { | 78 | switch (priv->type) { |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 62c19fdd102d..f140048334ce 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1600,20 +1600,15 @@ static void flush_stack(struct sock **stack, unsigned int count, | |||
1600 | } | 1600 | } |
1601 | 1601 | ||
1602 | /* For TCP sockets, sk_rx_dst is protected by socket lock | 1602 | /* For TCP sockets, sk_rx_dst is protected by socket lock |
1603 | * For UDP, we use sk_dst_lock to guard against concurrent changes. | 1603 | * For UDP, we use xchg() to guard against concurrent changes. |
1604 | */ | 1604 | */ |
1605 | static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst) | 1605 | static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst) |
1606 | { | 1606 | { |
1607 | struct dst_entry *old; | 1607 | struct dst_entry *old; |
1608 | 1608 | ||
1609 | spin_lock(&sk->sk_dst_lock); | 1609 | dst_hold(dst); |
1610 | old = sk->sk_rx_dst; | 1610 | old = xchg(&sk->sk_rx_dst, dst); |
1611 | if (likely(old != dst)) { | 1611 | dst_release(old); |
1612 | dst_hold(dst); | ||
1613 | sk->sk_rx_dst = dst; | ||
1614 | dst_release(old); | ||
1615 | } | ||
1616 | spin_unlock(&sk->sk_dst_lock); | ||
1617 | } | 1612 | } |
1618 | 1613 | ||
1619 | /* | 1614 | /* |
diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c index f78f41aca8e9..a0d17270117c 100644 --- a/net/ipv6/netfilter/ip6t_SYNPROXY.c +++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c | |||
@@ -446,6 +446,7 @@ static void synproxy_tg6_destroy(const struct xt_tgdtor_param *par) | |||
446 | static struct xt_target synproxy_tg6_reg __read_mostly = { | 446 | static struct xt_target synproxy_tg6_reg __read_mostly = { |
447 | .name = "SYNPROXY", | 447 | .name = "SYNPROXY", |
448 | .family = NFPROTO_IPV6, | 448 | .family = NFPROTO_IPV6, |
449 | .hooks = (1 << NF_INET_LOCAL_IN) | (1 << NF_INET_FORWARD), | ||
449 | .target = synproxy_tg6, | 450 | .target = synproxy_tg6, |
450 | .targetsize = sizeof(struct xt_synproxy_info), | 451 | .targetsize = sizeof(struct xt_synproxy_info), |
451 | .checkentry = synproxy_tg6_check, | 452 | .checkentry = synproxy_tg6_check, |
diff --git a/net/sctp/probe.c b/net/sctp/probe.c index 53c452efb40b..5e68b94ee640 100644 --- a/net/sctp/probe.c +++ b/net/sctp/probe.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <net/sctp/sctp.h> | 38 | #include <net/sctp/sctp.h> |
39 | #include <net/sctp/sm.h> | 39 | #include <net/sctp/sm.h> |
40 | 40 | ||
41 | MODULE_SOFTDEP("pre: sctp"); | ||
41 | MODULE_AUTHOR("Wei Yongjun <yjwei@cn.fujitsu.com>"); | 42 | MODULE_AUTHOR("Wei Yongjun <yjwei@cn.fujitsu.com>"); |
42 | MODULE_DESCRIPTION("SCTP snooper"); | 43 | MODULE_DESCRIPTION("SCTP snooper"); |
43 | MODULE_LICENSE("GPL"); | 44 | MODULE_LICENSE("GPL"); |
@@ -182,6 +183,20 @@ static struct jprobe sctp_recv_probe = { | |||
182 | .entry = jsctp_sf_eat_sack, | 183 | .entry = jsctp_sf_eat_sack, |
183 | }; | 184 | }; |
184 | 185 | ||
186 | static __init int sctp_setup_jprobe(void) | ||
187 | { | ||
188 | int ret = register_jprobe(&sctp_recv_probe); | ||
189 | |||
190 | if (ret) { | ||
191 | if (request_module("sctp")) | ||
192 | goto out; | ||
193 | ret = register_jprobe(&sctp_recv_probe); | ||
194 | } | ||
195 | |||
196 | out: | ||
197 | return ret; | ||
198 | } | ||
199 | |||
185 | static __init int sctpprobe_init(void) | 200 | static __init int sctpprobe_init(void) |
186 | { | 201 | { |
187 | int ret = -ENOMEM; | 202 | int ret = -ENOMEM; |
@@ -202,7 +217,7 @@ static __init int sctpprobe_init(void) | |||
202 | &sctpprobe_fops)) | 217 | &sctpprobe_fops)) |
203 | goto free_kfifo; | 218 | goto free_kfifo; |
204 | 219 | ||
205 | ret = register_jprobe(&sctp_recv_probe); | 220 | ret = sctp_setup_jprobe(); |
206 | if (ret) | 221 | if (ret) |
207 | goto remove_proc; | 222 | goto remove_proc; |
208 | 223 | ||
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index a0ca162e5bd5..a427623ee574 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -718,7 +718,9 @@ static int unix_autobind(struct socket *sock) | |||
718 | int err; | 718 | int err; |
719 | unsigned int retries = 0; | 719 | unsigned int retries = 0; |
720 | 720 | ||
721 | mutex_lock(&u->readlock); | 721 | err = mutex_lock_interruptible(&u->readlock); |
722 | if (err) | ||
723 | return err; | ||
722 | 724 | ||
723 | err = 0; | 725 | err = 0; |
724 | if (u->addr) | 726 | if (u->addr) |
@@ -877,7 +879,9 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
877 | goto out; | 879 | goto out; |
878 | addr_len = err; | 880 | addr_len = err; |
879 | 881 | ||
880 | mutex_lock(&u->readlock); | 882 | err = mutex_lock_interruptible(&u->readlock); |
883 | if (err) | ||
884 | goto out; | ||
881 | 885 | ||
882 | err = -EINVAL; | 886 | err = -EINVAL; |
883 | if (u->addr) | 887 | if (u->addr) |
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 32b10f53d0b4..2dcb37736d84 100644 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh | |||
@@ -82,7 +82,9 @@ kallsyms() | |||
82 | kallsymopt="${kallsymopt} --all-symbols" | 82 | kallsymopt="${kallsymopt} --all-symbols" |
83 | fi | 83 | fi |
84 | 84 | ||
85 | kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET" | 85 | if [ -n "${CONFIG_ARM}" ] && [ -n "${CONFIG_PAGE_OFFSET}" ]; then |
86 | kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET" | ||
87 | fi | ||
86 | 88 | ||
87 | local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \ | 89 | local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \ |
88 | ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}" | 90 | ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}" |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 419491d8e7d2..6625699f497c 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -4334,8 +4334,10 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
4334 | } | 4334 | } |
4335 | err = avc_has_perm(sk_sid, peer_sid, SECCLASS_PEER, | 4335 | err = avc_has_perm(sk_sid, peer_sid, SECCLASS_PEER, |
4336 | PEER__RECV, &ad); | 4336 | PEER__RECV, &ad); |
4337 | if (err) | 4337 | if (err) { |
4338 | selinux_netlbl_err(skb, err, 0); | 4338 | selinux_netlbl_err(skb, err, 0); |
4339 | return err; | ||
4340 | } | ||
4339 | } | 4341 | } |
4340 | 4342 | ||
4341 | if (secmark_active) { | 4343 | if (secmark_active) { |
@@ -5586,11 +5588,11 @@ static int selinux_setprocattr(struct task_struct *p, | |||
5586 | /* Check for ptracing, and update the task SID if ok. | 5588 | /* Check for ptracing, and update the task SID if ok. |
5587 | Otherwise, leave SID unchanged and fail. */ | 5589 | Otherwise, leave SID unchanged and fail. */ |
5588 | ptsid = 0; | 5590 | ptsid = 0; |
5589 | task_lock(p); | 5591 | rcu_read_lock(); |
5590 | tracer = ptrace_parent(p); | 5592 | tracer = ptrace_parent(p); |
5591 | if (tracer) | 5593 | if (tracer) |
5592 | ptsid = task_sid(tracer); | 5594 | ptsid = task_sid(tracer); |
5593 | task_unlock(p); | 5595 | rcu_read_unlock(); |
5594 | 5596 | ||
5595 | if (tracer) { | 5597 | if (tracer) { |
5596 | error = avc_has_perm(ptsid, sid, SECCLASS_PROCESS, | 5598 | error = avc_has_perm(ptsid, sid, SECCLASS_PROCESS, |
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 5138b8493051..d62ce483a443 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig | |||
@@ -31,8 +31,10 @@ config SND_SOC_GENERIC_DMAENGINE_PCM | |||
31 | select SND_DMAENGINE_PCM | 31 | select SND_DMAENGINE_PCM |
32 | 32 | ||
33 | # All the supported SoCs | 33 | # All the supported SoCs |
34 | source "sound/soc/adi/Kconfig" | ||
34 | source "sound/soc/atmel/Kconfig" | 35 | source "sound/soc/atmel/Kconfig" |
35 | source "sound/soc/au1x/Kconfig" | 36 | source "sound/soc/au1x/Kconfig" |
37 | source "sound/soc/bcm/Kconfig" | ||
36 | source "sound/soc/blackfin/Kconfig" | 38 | source "sound/soc/blackfin/Kconfig" |
37 | source "sound/soc/cirrus/Kconfig" | 39 | source "sound/soc/cirrus/Kconfig" |
38 | source "sound/soc/davinci/Kconfig" | 40 | source "sound/soc/davinci/Kconfig" |
@@ -42,7 +44,7 @@ source "sound/soc/jz4740/Kconfig" | |||
42 | source "sound/soc/nuc900/Kconfig" | 44 | source "sound/soc/nuc900/Kconfig" |
43 | source "sound/soc/omap/Kconfig" | 45 | source "sound/soc/omap/Kconfig" |
44 | source "sound/soc/kirkwood/Kconfig" | 46 | source "sound/soc/kirkwood/Kconfig" |
45 | source "sound/soc/mid-x86/Kconfig" | 47 | source "sound/soc/intel/Kconfig" |
46 | source "sound/soc/mxs/Kconfig" | 48 | source "sound/soc/mxs/Kconfig" |
47 | source "sound/soc/pxa/Kconfig" | 49 | source "sound/soc/pxa/Kconfig" |
48 | source "sound/soc/samsung/Kconfig" | 50 | source "sound/soc/samsung/Kconfig" |
diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 8b9e70105dd2..62a1822e77bf 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile | |||
@@ -8,15 +8,17 @@ endif | |||
8 | obj-$(CONFIG_SND_SOC) += snd-soc-core.o | 8 | obj-$(CONFIG_SND_SOC) += snd-soc-core.o |
9 | obj-$(CONFIG_SND_SOC) += codecs/ | 9 | obj-$(CONFIG_SND_SOC) += codecs/ |
10 | obj-$(CONFIG_SND_SOC) += generic/ | 10 | obj-$(CONFIG_SND_SOC) += generic/ |
11 | obj-$(CONFIG_SND_SOC) += adi/ | ||
11 | obj-$(CONFIG_SND_SOC) += atmel/ | 12 | obj-$(CONFIG_SND_SOC) += atmel/ |
12 | obj-$(CONFIG_SND_SOC) += au1x/ | 13 | obj-$(CONFIG_SND_SOC) += au1x/ |
14 | obj-$(CONFIG_SND_SOC) += bcm/ | ||
13 | obj-$(CONFIG_SND_SOC) += blackfin/ | 15 | obj-$(CONFIG_SND_SOC) += blackfin/ |
14 | obj-$(CONFIG_SND_SOC) += cirrus/ | 16 | obj-$(CONFIG_SND_SOC) += cirrus/ |
15 | obj-$(CONFIG_SND_SOC) += davinci/ | 17 | obj-$(CONFIG_SND_SOC) += davinci/ |
16 | obj-$(CONFIG_SND_SOC) += dwc/ | 18 | obj-$(CONFIG_SND_SOC) += dwc/ |
17 | obj-$(CONFIG_SND_SOC) += fsl/ | 19 | obj-$(CONFIG_SND_SOC) += fsl/ |
18 | obj-$(CONFIG_SND_SOC) += jz4740/ | 20 | obj-$(CONFIG_SND_SOC) += jz4740/ |
19 | obj-$(CONFIG_SND_SOC) += mid-x86/ | 21 | obj-$(CONFIG_SND_SOC) += intel/ |
20 | obj-$(CONFIG_SND_SOC) += mxs/ | 22 | obj-$(CONFIG_SND_SOC) += mxs/ |
21 | obj-$(CONFIG_SND_SOC) += nuc900/ | 23 | obj-$(CONFIG_SND_SOC) += nuc900/ |
22 | obj-$(CONFIG_SND_SOC) += omap/ | 24 | obj-$(CONFIG_SND_SOC) += omap/ |
diff --git a/sound/soc/adi/Kconfig b/sound/soc/adi/Kconfig new file mode 100644 index 000000000000..dd763f55edac --- /dev/null +++ b/sound/soc/adi/Kconfig | |||
@@ -0,0 +1,21 @@ | |||
1 | config SND_SOC_ADI | ||
2 | tristate "Audio support for Analog Devices reference designs" | ||
3 | depends on MICROBLAZE || ARCH_ZYNQ || COMPILE_TEST | ||
4 | help | ||
5 | Audio support for various reference designs by Analog Devices. | ||
6 | |||
7 | config SND_SOC_ADI_AXI_I2S | ||
8 | tristate "AXI-I2S support" | ||
9 | depends on SND_SOC_ADI | ||
10 | select SND_SOC_GENERIC_DMAENGINE_PCM | ||
11 | select REGMAP_MMIO | ||
12 | help | ||
13 | ASoC driver for the Analog Devices AXI-I2S softcore peripheral. | ||
14 | |||
15 | config SND_SOC_ADI_AXI_SPDIF | ||
16 | tristate "AXI-SPDIF support" | ||
17 | depends on SND_SOC_ADI | ||
18 | select SND_SOC_GENERIC_DMAENGINE_PCM | ||
19 | select REGMAP_MMIO | ||
20 | help | ||
21 | ASoC driver for the Analog Devices AXI-SPDIF softcore peripheral. | ||
diff --git a/sound/soc/adi/Makefile b/sound/soc/adi/Makefile new file mode 100644 index 000000000000..64456c1e5347 --- /dev/null +++ b/sound/soc/adi/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | snd-soc-adi-axi-i2s-objs := axi-i2s.o | ||
2 | snd-soc-adi-axi-spdif-objs := axi-spdif.o | ||
3 | |||
4 | obj-$(CONFIG_SND_SOC_ADI_AXI_I2S) += snd-soc-adi-axi-i2s.o | ||
5 | obj-$(CONFIG_SND_SOC_ADI_AXI_SPDIF) += snd-soc-adi-axi-spdif.o | ||
diff --git a/sound/soc/adi/axi-i2s.c b/sound/soc/adi/axi-i2s.c new file mode 100644 index 000000000000..7f91a86dd734 --- /dev/null +++ b/sound/soc/adi/axi-i2s.c | |||
@@ -0,0 +1,277 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012-2013, Analog Devices Inc. | ||
3 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
4 | * | ||
5 | * Licensed under the GPL-2. | ||
6 | */ | ||
7 | |||
8 | #include <linux/clk.h> | ||
9 | #include <linux/init.h> | ||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/of.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/regmap.h> | ||
15 | #include <linux/slab.h> | ||
16 | |||
17 | #include <sound/core.h> | ||
18 | #include <sound/pcm.h> | ||
19 | #include <sound/pcm_params.h> | ||
20 | #include <sound/soc.h> | ||
21 | #include <sound/dmaengine_pcm.h> | ||
22 | |||
23 | #define AXI_I2S_REG_RESET 0x00 | ||
24 | #define AXI_I2S_REG_CTRL 0x04 | ||
25 | #define AXI_I2S_REG_CLK_CTRL 0x08 | ||
26 | #define AXI_I2S_REG_STATUS 0x10 | ||
27 | |||
28 | #define AXI_I2S_REG_RX_FIFO 0x28 | ||
29 | #define AXI_I2S_REG_TX_FIFO 0x2C | ||
30 | |||
31 | #define AXI_I2S_RESET_GLOBAL BIT(0) | ||
32 | #define AXI_I2S_RESET_TX_FIFO BIT(1) | ||
33 | #define AXI_I2S_RESET_RX_FIFO BIT(2) | ||
34 | |||
35 | #define AXI_I2S_CTRL_TX_EN BIT(0) | ||
36 | #define AXI_I2S_CTRL_RX_EN BIT(1) | ||
37 | |||
38 | /* The frame size is configurable, but for now we always set it 64 bit */ | ||
39 | #define AXI_I2S_BITS_PER_FRAME 64 | ||
40 | |||
41 | struct axi_i2s { | ||
42 | struct regmap *regmap; | ||
43 | struct clk *clk; | ||
44 | struct clk *clk_ref; | ||
45 | |||
46 | struct snd_soc_dai_driver dai_driver; | ||
47 | |||
48 | struct snd_dmaengine_dai_dma_data capture_dma_data; | ||
49 | struct snd_dmaengine_dai_dma_data playback_dma_data; | ||
50 | |||
51 | struct snd_ratnum ratnum; | ||
52 | struct snd_pcm_hw_constraint_ratnums rate_constraints; | ||
53 | }; | ||
54 | |||
55 | static int axi_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | ||
56 | struct snd_soc_dai *dai) | ||
57 | { | ||
58 | struct axi_i2s *i2s = snd_soc_dai_get_drvdata(dai); | ||
59 | unsigned int mask, val; | ||
60 | |||
61 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
62 | mask = AXI_I2S_CTRL_RX_EN; | ||
63 | else | ||
64 | mask = AXI_I2S_CTRL_TX_EN; | ||
65 | |||
66 | switch (cmd) { | ||
67 | case SNDRV_PCM_TRIGGER_START: | ||
68 | case SNDRV_PCM_TRIGGER_RESUME: | ||
69 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
70 | val = mask; | ||
71 | break; | ||
72 | case SNDRV_PCM_TRIGGER_STOP: | ||
73 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
74 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
75 | val = 0; | ||
76 | break; | ||
77 | default: | ||
78 | return -EINVAL; | ||
79 | } | ||
80 | |||
81 | regmap_update_bits(i2s->regmap, AXI_I2S_REG_CTRL, mask, val); | ||
82 | |||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | static int axi_i2s_hw_params(struct snd_pcm_substream *substream, | ||
87 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | ||
88 | { | ||
89 | struct axi_i2s *i2s = snd_soc_dai_get_drvdata(dai); | ||
90 | unsigned int bclk_div, word_size; | ||
91 | unsigned int bclk_rate; | ||
92 | |||
93 | bclk_rate = params_rate(params) * AXI_I2S_BITS_PER_FRAME; | ||
94 | |||
95 | word_size = AXI_I2S_BITS_PER_FRAME / 2 - 1; | ||
96 | bclk_div = DIV_ROUND_UP(clk_get_rate(i2s->clk_ref), bclk_rate) / 2 - 1; | ||
97 | |||
98 | regmap_write(i2s->regmap, AXI_I2S_REG_CLK_CTRL, (word_size << 16) | | ||
99 | bclk_div); | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | static int axi_i2s_startup(struct snd_pcm_substream *substream, | ||
105 | struct snd_soc_dai *dai) | ||
106 | { | ||
107 | struct axi_i2s *i2s = snd_soc_dai_get_drvdata(dai); | ||
108 | uint32_t mask; | ||
109 | int ret; | ||
110 | |||
111 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
112 | mask = AXI_I2S_RESET_RX_FIFO; | ||
113 | else | ||
114 | mask = AXI_I2S_RESET_TX_FIFO; | ||
115 | |||
116 | regmap_write(i2s->regmap, AXI_I2S_REG_RESET, mask); | ||
117 | |||
118 | ret = snd_pcm_hw_constraint_ratnums(substream->runtime, 0, | ||
119 | SNDRV_PCM_HW_PARAM_RATE, | ||
120 | &i2s->rate_constraints); | ||
121 | if (ret) | ||
122 | return ret; | ||
123 | |||
124 | return clk_prepare_enable(i2s->clk_ref); | ||
125 | } | ||
126 | |||
127 | static void axi_i2s_shutdown(struct snd_pcm_substream *substream, | ||
128 | struct snd_soc_dai *dai) | ||
129 | { | ||
130 | struct axi_i2s *i2s = snd_soc_dai_get_drvdata(dai); | ||
131 | |||
132 | clk_disable_unprepare(i2s->clk_ref); | ||
133 | } | ||
134 | |||
135 | static int axi_i2s_dai_probe(struct snd_soc_dai *dai) | ||
136 | { | ||
137 | struct axi_i2s *i2s = snd_soc_dai_get_drvdata(dai); | ||
138 | |||
139 | snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data, | ||
140 | &i2s->capture_dma_data); | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | static const struct snd_soc_dai_ops axi_i2s_dai_ops = { | ||
146 | .startup = axi_i2s_startup, | ||
147 | .shutdown = axi_i2s_shutdown, | ||
148 | .trigger = axi_i2s_trigger, | ||
149 | .hw_params = axi_i2s_hw_params, | ||
150 | }; | ||
151 | |||
152 | static struct snd_soc_dai_driver axi_i2s_dai = { | ||
153 | .probe = axi_i2s_dai_probe, | ||
154 | .playback = { | ||
155 | .channels_min = 2, | ||
156 | .channels_max = 2, | ||
157 | .rates = SNDRV_PCM_RATE_KNOT, | ||
158 | .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_U32_LE, | ||
159 | }, | ||
160 | .capture = { | ||
161 | .channels_min = 2, | ||
162 | .channels_max = 2, | ||
163 | .rates = SNDRV_PCM_RATE_KNOT, | ||
164 | .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_U32_LE, | ||
165 | }, | ||
166 | .ops = &axi_i2s_dai_ops, | ||
167 | .symmetric_rates = 1, | ||
168 | }; | ||
169 | |||
170 | static const struct snd_soc_component_driver axi_i2s_component = { | ||
171 | .name = "axi-i2s", | ||
172 | }; | ||
173 | |||
174 | static const struct regmap_config axi_i2s_regmap_config = { | ||
175 | .reg_bits = 32, | ||
176 | .reg_stride = 4, | ||
177 | .val_bits = 32, | ||
178 | .max_register = AXI_I2S_REG_STATUS, | ||
179 | }; | ||
180 | |||
181 | static int axi_i2s_probe(struct platform_device *pdev) | ||
182 | { | ||
183 | struct resource *res; | ||
184 | struct axi_i2s *i2s; | ||
185 | void __iomem *base; | ||
186 | int ret; | ||
187 | |||
188 | i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); | ||
189 | if (!i2s) | ||
190 | return -ENOMEM; | ||
191 | |||
192 | platform_set_drvdata(pdev, i2s); | ||
193 | |||
194 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
195 | base = devm_ioremap_resource(&pdev->dev, res); | ||
196 | if (IS_ERR(base)) | ||
197 | return PTR_ERR(base); | ||
198 | |||
199 | i2s->regmap = devm_regmap_init_mmio(&pdev->dev, base, | ||
200 | &axi_i2s_regmap_config); | ||
201 | if (IS_ERR(i2s->regmap)) | ||
202 | return PTR_ERR(i2s->regmap); | ||
203 | |||
204 | i2s->clk = devm_clk_get(&pdev->dev, "axi"); | ||
205 | if (IS_ERR(i2s->clk)) | ||
206 | return PTR_ERR(i2s->clk); | ||
207 | |||
208 | i2s->clk_ref = devm_clk_get(&pdev->dev, "ref"); | ||
209 | if (IS_ERR(i2s->clk_ref)) | ||
210 | return PTR_ERR(i2s->clk_ref); | ||
211 | |||
212 | ret = clk_prepare_enable(i2s->clk); | ||
213 | if (ret) | ||
214 | return ret; | ||
215 | |||
216 | i2s->playback_dma_data.addr = res->start + AXI_I2S_REG_TX_FIFO; | ||
217 | i2s->playback_dma_data.addr_width = 4; | ||
218 | i2s->playback_dma_data.maxburst = 1; | ||
219 | |||
220 | i2s->capture_dma_data.addr = res->start + AXI_I2S_REG_RX_FIFO; | ||
221 | i2s->capture_dma_data.addr_width = 4; | ||
222 | i2s->capture_dma_data.maxburst = 1; | ||
223 | |||
224 | i2s->ratnum.num = clk_get_rate(i2s->clk_ref) / 2 / AXI_I2S_BITS_PER_FRAME; | ||
225 | i2s->ratnum.den_step = 1; | ||
226 | i2s->ratnum.den_min = 1; | ||
227 | i2s->ratnum.den_max = 64; | ||
228 | |||
229 | i2s->rate_constraints.rats = &i2s->ratnum; | ||
230 | i2s->rate_constraints.nrats = 1; | ||
231 | |||
232 | regmap_write(i2s->regmap, AXI_I2S_REG_RESET, AXI_I2S_RESET_GLOBAL); | ||
233 | |||
234 | ret = devm_snd_soc_register_component(&pdev->dev, &axi_i2s_component, | ||
235 | &axi_i2s_dai, 1); | ||
236 | if (ret) | ||
237 | goto err_clk_disable; | ||
238 | |||
239 | ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, | ||
240 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE); | ||
241 | if (ret) | ||
242 | goto err_clk_disable; | ||
243 | |||
244 | err_clk_disable: | ||
245 | clk_disable_unprepare(i2s->clk); | ||
246 | return ret; | ||
247 | } | ||
248 | |||
249 | static int axi_i2s_dev_remove(struct platform_device *pdev) | ||
250 | { | ||
251 | struct axi_i2s *i2s = platform_get_drvdata(pdev); | ||
252 | |||
253 | clk_disable_unprepare(i2s->clk); | ||
254 | |||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | static const struct of_device_id axi_i2s_of_match[] = { | ||
259 | { .compatible = "adi,axi-i2s-1.00.a", }, | ||
260 | {}, | ||
261 | }; | ||
262 | MODULE_DEVICE_TABLE(of, axi_i2s_of_match); | ||
263 | |||
264 | static struct platform_driver axi_i2s_driver = { | ||
265 | .driver = { | ||
266 | .name = "axi-i2s", | ||
267 | .owner = THIS_MODULE, | ||
268 | .of_match_table = axi_i2s_of_match, | ||
269 | }, | ||
270 | .probe = axi_i2s_probe, | ||
271 | .remove = axi_i2s_dev_remove, | ||
272 | }; | ||
273 | module_platform_driver(axi_i2s_driver); | ||
274 | |||
275 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
276 | MODULE_DESCRIPTION("AXI I2S driver"); | ||
277 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/adi/axi-spdif.c b/sound/soc/adi/axi-spdif.c new file mode 100644 index 000000000000..8db7a9920695 --- /dev/null +++ b/sound/soc/adi/axi-spdif.c | |||
@@ -0,0 +1,272 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012-2013, Analog Devices Inc. | ||
3 | * Author: Lars-Peter Clausen <lars@metafoo.de> | ||
4 | * | ||
5 | * Licensed under the GPL-2. | ||
6 | */ | ||
7 | |||
8 | #include <linux/init.h> | ||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/platform_device.h> | ||
12 | #include <linux/slab.h> | ||
13 | #include <linux/of.h> | ||
14 | #include <linux/clk.h> | ||
15 | #include <linux/regmap.h> | ||
16 | |||
17 | #include <sound/core.h> | ||
18 | #include <sound/pcm.h> | ||
19 | #include <sound/pcm_params.h> | ||
20 | #include <sound/soc.h> | ||
21 | #include <sound/initval.h> | ||
22 | #include <sound/dmaengine_pcm.h> | ||
23 | |||
24 | #define AXI_SPDIF_REG_CTRL 0x0 | ||
25 | #define AXI_SPDIF_REG_STAT 0x4 | ||
26 | #define AXI_SPDIF_REG_TX_FIFO 0xc | ||
27 | |||
28 | #define AXI_SPDIF_CTRL_TXDATA BIT(1) | ||
29 | #define AXI_SPDIF_CTRL_TXEN BIT(0) | ||
30 | #define AXI_SPDIF_CTRL_CLKDIV_OFFSET 8 | ||
31 | #define AXI_SPDIF_CTRL_CLKDIV_MASK (0xff << 8) | ||
32 | |||
33 | #define AXI_SPDIF_FREQ_44100 (0x0 << 6) | ||
34 | #define AXI_SPDIF_FREQ_48000 (0x1 << 6) | ||
35 | #define AXI_SPDIF_FREQ_32000 (0x2 << 6) | ||
36 | #define AXI_SPDIF_FREQ_NA (0x3 << 6) | ||
37 | |||
38 | struct axi_spdif { | ||
39 | struct regmap *regmap; | ||
40 | struct clk *clk; | ||
41 | struct clk *clk_ref; | ||
42 | |||
43 | struct snd_dmaengine_dai_dma_data dma_data; | ||
44 | |||
45 | struct snd_ratnum ratnum; | ||
46 | struct snd_pcm_hw_constraint_ratnums rate_constraints; | ||
47 | }; | ||
48 | |||
49 | static int axi_spdif_trigger(struct snd_pcm_substream *substream, int cmd, | ||
50 | struct snd_soc_dai *dai) | ||
51 | { | ||
52 | struct axi_spdif *spdif = snd_soc_dai_get_drvdata(dai); | ||
53 | unsigned int val; | ||
54 | |||
55 | switch (cmd) { | ||
56 | case SNDRV_PCM_TRIGGER_START: | ||
57 | case SNDRV_PCM_TRIGGER_RESUME: | ||
58 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
59 | val = AXI_SPDIF_CTRL_TXDATA; | ||
60 | break; | ||
61 | case SNDRV_PCM_TRIGGER_STOP: | ||
62 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
63 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
64 | val = 0; | ||
65 | break; | ||
66 | default: | ||
67 | return -EINVAL; | ||
68 | } | ||
69 | |||
70 | regmap_update_bits(spdif->regmap, AXI_SPDIF_REG_CTRL, | ||
71 | AXI_SPDIF_CTRL_TXDATA, val); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static int axi_spdif_hw_params(struct snd_pcm_substream *substream, | ||
77 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | ||
78 | { | ||
79 | struct axi_spdif *spdif = snd_soc_dai_get_drvdata(dai); | ||
80 | unsigned int rate = params_rate(params); | ||
81 | unsigned int clkdiv, stat; | ||
82 | |||
83 | switch (params_rate(params)) { | ||
84 | case 32000: | ||
85 | stat = AXI_SPDIF_FREQ_32000; | ||
86 | break; | ||
87 | case 44100: | ||
88 | stat = AXI_SPDIF_FREQ_44100; | ||
89 | break; | ||
90 | case 48000: | ||
91 | stat = AXI_SPDIF_FREQ_48000; | ||
92 | break; | ||
93 | default: | ||
94 | stat = AXI_SPDIF_FREQ_NA; | ||
95 | break; | ||
96 | } | ||
97 | |||
98 | clkdiv = DIV_ROUND_CLOSEST(clk_get_rate(spdif->clk_ref), | ||
99 | rate * 64 * 2) - 1; | ||
100 | clkdiv <<= AXI_SPDIF_CTRL_CLKDIV_OFFSET; | ||
101 | |||
102 | regmap_write(spdif->regmap, AXI_SPDIF_REG_STAT, stat); | ||
103 | regmap_update_bits(spdif->regmap, AXI_SPDIF_REG_CTRL, | ||
104 | AXI_SPDIF_CTRL_CLKDIV_MASK, clkdiv); | ||
105 | |||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | static int axi_spdif_dai_probe(struct snd_soc_dai *dai) | ||
110 | { | ||
111 | struct axi_spdif *spdif = snd_soc_dai_get_drvdata(dai); | ||
112 | |||
113 | snd_soc_dai_init_dma_data(dai, &spdif->dma_data, NULL); | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | static int axi_spdif_startup(struct snd_pcm_substream *substream, | ||
119 | struct snd_soc_dai *dai) | ||
120 | { | ||
121 | struct axi_spdif *spdif = snd_soc_dai_get_drvdata(dai); | ||
122 | int ret; | ||
123 | |||
124 | ret = snd_pcm_hw_constraint_ratnums(substream->runtime, 0, | ||
125 | SNDRV_PCM_HW_PARAM_RATE, | ||
126 | &spdif->rate_constraints); | ||
127 | if (ret) | ||
128 | return ret; | ||
129 | |||
130 | ret = clk_prepare_enable(spdif->clk_ref); | ||
131 | if (ret) | ||
132 | return ret; | ||
133 | |||
134 | regmap_update_bits(spdif->regmap, AXI_SPDIF_REG_CTRL, | ||
135 | AXI_SPDIF_CTRL_TXEN, AXI_SPDIF_CTRL_TXEN); | ||
136 | |||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | static void axi_spdif_shutdown(struct snd_pcm_substream *substream, | ||
141 | struct snd_soc_dai *dai) | ||
142 | { | ||
143 | struct axi_spdif *spdif = snd_soc_dai_get_drvdata(dai); | ||
144 | |||
145 | regmap_update_bits(spdif->regmap, AXI_SPDIF_REG_CTRL, | ||
146 | AXI_SPDIF_CTRL_TXEN, 0); | ||
147 | |||
148 | clk_disable_unprepare(spdif->clk_ref); | ||
149 | } | ||
150 | |||
151 | static const struct snd_soc_dai_ops axi_spdif_dai_ops = { | ||
152 | .startup = axi_spdif_startup, | ||
153 | .shutdown = axi_spdif_shutdown, | ||
154 | .trigger = axi_spdif_trigger, | ||
155 | .hw_params = axi_spdif_hw_params, | ||
156 | }; | ||
157 | |||
158 | static struct snd_soc_dai_driver axi_spdif_dai = { | ||
159 | .probe = axi_spdif_dai_probe, | ||
160 | .playback = { | ||
161 | .channels_min = 2, | ||
162 | .channels_max = 2, | ||
163 | .rates = SNDRV_PCM_RATE_KNOT, | ||
164 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
165 | }, | ||
166 | .ops = &axi_spdif_dai_ops, | ||
167 | }; | ||
168 | |||
169 | static const struct snd_soc_component_driver axi_spdif_component = { | ||
170 | .name = "axi-spdif", | ||
171 | }; | ||
172 | |||
173 | static const struct regmap_config axi_spdif_regmap_config = { | ||
174 | .reg_bits = 32, | ||
175 | .reg_stride = 4, | ||
176 | .val_bits = 32, | ||
177 | .max_register = AXI_SPDIF_REG_STAT, | ||
178 | }; | ||
179 | |||
180 | static int axi_spdif_probe(struct platform_device *pdev) | ||
181 | { | ||
182 | struct axi_spdif *spdif; | ||
183 | struct resource *res; | ||
184 | void __iomem *base; | ||
185 | int ret; | ||
186 | |||
187 | spdif = devm_kzalloc(&pdev->dev, sizeof(*spdif), GFP_KERNEL); | ||
188 | if (!spdif) | ||
189 | return -ENOMEM; | ||
190 | |||
191 | platform_set_drvdata(pdev, spdif); | ||
192 | |||
193 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
194 | base = devm_ioremap_resource(&pdev->dev, res); | ||
195 | if (IS_ERR(base)) | ||
196 | return PTR_ERR(base); | ||
197 | |||
198 | spdif->regmap = devm_regmap_init_mmio(&pdev->dev, base, | ||
199 | &axi_spdif_regmap_config); | ||
200 | if (IS_ERR(spdif->regmap)) | ||
201 | return PTR_ERR(spdif->regmap); | ||
202 | |||
203 | spdif->clk = devm_clk_get(&pdev->dev, "axi"); | ||
204 | if (IS_ERR(spdif->clk)) | ||
205 | return PTR_ERR(spdif->clk); | ||
206 | |||
207 | spdif->clk_ref = devm_clk_get(&pdev->dev, "ref"); | ||
208 | if (IS_ERR(spdif->clk_ref)) | ||
209 | return PTR_ERR(spdif->clk_ref); | ||
210 | |||
211 | ret = clk_prepare_enable(spdif->clk); | ||
212 | if (ret) | ||
213 | return ret; | ||
214 | |||
215 | spdif->dma_data.addr = res->start + AXI_SPDIF_REG_TX_FIFO; | ||
216 | spdif->dma_data.addr_width = 4; | ||
217 | spdif->dma_data.maxburst = 1; | ||
218 | |||
219 | spdif->ratnum.num = clk_get_rate(spdif->clk_ref) / 128; | ||
220 | spdif->ratnum.den_step = 1; | ||
221 | spdif->ratnum.den_min = 1; | ||
222 | spdif->ratnum.den_max = 64; | ||
223 | |||
224 | spdif->rate_constraints.rats = &spdif->ratnum; | ||
225 | spdif->rate_constraints.nrats = 1; | ||
226 | |||
227 | ret = devm_snd_soc_register_component(&pdev->dev, &axi_spdif_component, | ||
228 | &axi_spdif_dai, 1); | ||
229 | if (ret) | ||
230 | goto err_clk_disable; | ||
231 | |||
232 | ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, | ||
233 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE); | ||
234 | if (ret) | ||
235 | goto err_clk_disable; | ||
236 | |||
237 | return 0; | ||
238 | |||
239 | err_clk_disable: | ||
240 | clk_disable_unprepare(spdif->clk); | ||
241 | return ret; | ||
242 | } | ||
243 | |||
244 | static int axi_spdif_dev_remove(struct platform_device *pdev) | ||
245 | { | ||
246 | struct axi_spdif *spdif = platform_get_drvdata(pdev); | ||
247 | |||
248 | clk_disable_unprepare(spdif->clk); | ||
249 | |||
250 | return 0; | ||
251 | } | ||
252 | |||
253 | static const struct of_device_id axi_spdif_of_match[] = { | ||
254 | { .compatible = "adi,axi-spdif-tx-1.00.a", }, | ||
255 | {}, | ||
256 | }; | ||
257 | MODULE_DEVICE_TABLE(of, axi_spdif_of_match); | ||
258 | |||
259 | static struct platform_driver axi_spdif_driver = { | ||
260 | .driver = { | ||
261 | .name = "axi-spdif", | ||
262 | .owner = THIS_MODULE, | ||
263 | .of_match_table = axi_spdif_of_match, | ||
264 | }, | ||
265 | .probe = axi_spdif_probe, | ||
266 | .remove = axi_spdif_dev_remove, | ||
267 | }; | ||
268 | module_platform_driver(axi_spdif_driver); | ||
269 | |||
270 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
271 | MODULE_DESCRIPTION("AXI SPDIF driver"); | ||
272 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c index 7d6a9055874b..3188036a18f0 100644 --- a/sound/soc/atmel/sam9x5_wm8731.c +++ b/sound/soc/atmel/sam9x5_wm8731.c | |||
@@ -155,8 +155,6 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev) | |||
155 | of_node_put(codec_np); | 155 | of_node_put(codec_np); |
156 | of_node_put(cpu_np); | 156 | of_node_put(cpu_np); |
157 | 157 | ||
158 | platform_set_drvdata(pdev, card); | ||
159 | |||
160 | ret = snd_soc_register_card(card); | 158 | ret = snd_soc_register_card(card); |
161 | if (ret) { | 159 | if (ret) { |
162 | dev_err(&pdev->dev, | 160 | dev_err(&pdev->dev, |
diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index 3b4eafaf30d3..17a24d804734 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c | |||
@@ -65,19 +65,10 @@ struct au1xpsc_audio_dmadata { | |||
65 | #define AU1XPSC_PERIOD_MIN_BYTES 1024 | 65 | #define AU1XPSC_PERIOD_MIN_BYTES 1024 |
66 | #define AU1XPSC_BUFFER_MIN_BYTES 65536 | 66 | #define AU1XPSC_BUFFER_MIN_BYTES 65536 |
67 | 67 | ||
68 | #define AU1XPSC_PCM_FMTS \ | ||
69 | (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | \ | ||
70 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \ | ||
71 | SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE | \ | ||
72 | SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE | \ | ||
73 | SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE | \ | ||
74 | 0) | ||
75 | |||
76 | /* PCM hardware DMA capabilities - platform specific */ | 68 | /* PCM hardware DMA capabilities - platform specific */ |
77 | static const struct snd_pcm_hardware au1xpsc_pcm_hardware = { | 69 | static const struct snd_pcm_hardware au1xpsc_pcm_hardware = { |
78 | .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | | 70 | .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | |
79 | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BATCH, | 71 | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BATCH, |
80 | .formats = AU1XPSC_PCM_FMTS, | ||
81 | .period_bytes_min = AU1XPSC_PERIOD_MIN_BYTES, | 72 | .period_bytes_min = AU1XPSC_PERIOD_MIN_BYTES, |
82 | .period_bytes_max = 4096 * 1024 - 1, | 73 | .period_bytes_max = 4096 * 1024 - 1, |
83 | .periods_min = 2, | 74 | .periods_min = 2, |
diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c index befd1074f9bd..e920b60bf6c2 100644 --- a/sound/soc/au1x/dma.c +++ b/sound/soc/au1x/dma.c | |||
@@ -21,14 +21,6 @@ | |||
21 | 21 | ||
22 | #include "psc.h" | 22 | #include "psc.h" |
23 | 23 | ||
24 | #define ALCHEMY_PCM_FMTS \ | ||
25 | (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | \ | ||
26 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \ | ||
27 | SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE | \ | ||
28 | SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE | \ | ||
29 | SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE | \ | ||
30 | 0) | ||
31 | |||
32 | struct pcm_period { | 24 | struct pcm_period { |
33 | u32 start; | 25 | u32 start; |
34 | u32 relative_end; /* relative to start of buffer */ | 26 | u32 relative_end; /* relative to start of buffer */ |
@@ -171,12 +163,6 @@ static irqreturn_t au1000_dma_interrupt(int irq, void *ptr) | |||
171 | static const struct snd_pcm_hardware alchemy_pcm_hardware = { | 163 | static const struct snd_pcm_hardware alchemy_pcm_hardware = { |
172 | .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | | 164 | .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | |
173 | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BATCH, | 165 | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BATCH, |
174 | .formats = ALCHEMY_PCM_FMTS, | ||
175 | .rates = SNDRV_PCM_RATE_8000_192000, | ||
176 | .rate_min = SNDRV_PCM_RATE_8000, | ||
177 | .rate_max = SNDRV_PCM_RATE_192000, | ||
178 | .channels_min = 2, | ||
179 | .channels_max = 2, | ||
180 | .period_bytes_min = 1024, | 166 | .period_bytes_min = 1024, |
181 | .period_bytes_max = 16 * 1024 - 1, | 167 | .period_bytes_max = 16 * 1024 - 1, |
182 | .periods_min = 4, | 168 | .periods_min = 4, |
diff --git a/sound/soc/bcm/Kconfig b/sound/soc/bcm/Kconfig new file mode 100644 index 000000000000..3d82a29ce3a8 --- /dev/null +++ b/sound/soc/bcm/Kconfig | |||
@@ -0,0 +1,10 @@ | |||
1 | config SND_BCM2835_SOC_I2S | ||
2 | tristate "SoC Audio support for the Broadcom BCM2835 I2S module" | ||
3 | depends on ARCH_BCM2835 || COMPILE_TEST | ||
4 | select SND_SOC_DMAENGINE_PCM | ||
5 | select SND_SOC_GENERIC_DMAENGINE_PCM | ||
6 | select REGMAP_MMIO | ||
7 | help | ||
8 | Say Y or M if you want to add support for codecs attached to | ||
9 | the BCM2835 I2S interface. You will also need | ||
10 | to select the audio interfaces to support below. | ||
diff --git a/sound/soc/bcm/Makefile b/sound/soc/bcm/Makefile new file mode 100644 index 000000000000..bc816b71e5a4 --- /dev/null +++ b/sound/soc/bcm/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | # BCM2835 Platform Support | ||
2 | snd-soc-bcm2835-i2s-objs := bcm2835-i2s.o | ||
3 | |||
4 | obj-$(CONFIG_SND_BCM2835_SOC_I2S) += snd-soc-bcm2835-i2s.o | ||
5 | |||
diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c new file mode 100644 index 000000000000..2685fe4f8427 --- /dev/null +++ b/sound/soc/bcm/bcm2835-i2s.c | |||
@@ -0,0 +1,879 @@ | |||
1 | /* | ||
2 | * ALSA SoC I2S Audio Layer for Broadcom BCM2835 SoC | ||
3 | * | ||
4 | * Author: Florian Meier <florian.meier@koalo.de> | ||
5 | * Copyright 2013 | ||
6 | * | ||
7 | * Based on | ||
8 | * Raspberry Pi PCM I2S ALSA Driver | ||
9 | * Copyright (c) by Phil Poole 2013 | ||
10 | * | ||
11 | * ALSA SoC I2S (McBSP) Audio Layer for TI DAVINCI processor | ||
12 | * Vladimir Barinov, <vbarinov@embeddedalley.com> | ||
13 | * Copyright (C) 2007 MontaVista Software, Inc., <source@mvista.com> | ||
14 | * | ||
15 | * OMAP ALSA SoC DAI driver using McBSP port | ||
16 | * Copyright (C) 2008 Nokia Corporation | ||
17 | * Contact: Jarkko Nikula <jarkko.nikula@bitmer.com> | ||
18 | * Peter Ujfalusi <peter.ujfalusi@ti.com> | ||
19 | * | ||
20 | * Freescale SSI ALSA SoC Digital Audio Interface (DAI) driver | ||
21 | * Author: Timur Tabi <timur@freescale.com> | ||
22 | * Copyright 2007-2010 Freescale Semiconductor, Inc. | ||
23 | * | ||
24 | * This program is free software; you can redistribute it and/or | ||
25 | * modify it under the terms of the GNU General Public License | ||
26 | * version 2 as published by the Free Software Foundation. | ||
27 | * | ||
28 | * This program is distributed in the hope that it will be useful, but | ||
29 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
31 | * General Public License for more details. | ||
32 | */ | ||
33 | |||
34 | #include <linux/init.h> | ||
35 | #include <linux/module.h> | ||
36 | #include <linux/device.h> | ||
37 | #include <linux/slab.h> | ||
38 | #include <linux/delay.h> | ||
39 | #include <linux/io.h> | ||
40 | #include <linux/clk.h> | ||
41 | |||
42 | #include <sound/core.h> | ||
43 | #include <sound/pcm.h> | ||
44 | #include <sound/pcm_params.h> | ||
45 | #include <sound/initval.h> | ||
46 | #include <sound/soc.h> | ||
47 | #include <sound/dmaengine_pcm.h> | ||
48 | |||
49 | /* Clock registers */ | ||
50 | #define BCM2835_CLK_PCMCTL_REG 0x00 | ||
51 | #define BCM2835_CLK_PCMDIV_REG 0x04 | ||
52 | |||
53 | /* Clock register settings */ | ||
54 | #define BCM2835_CLK_PASSWD (0x5a000000) | ||
55 | #define BCM2835_CLK_PASSWD_MASK (0xff000000) | ||
56 | #define BCM2835_CLK_MASH(v) ((v) << 9) | ||
57 | #define BCM2835_CLK_FLIP BIT(8) | ||
58 | #define BCM2835_CLK_BUSY BIT(7) | ||
59 | #define BCM2835_CLK_KILL BIT(5) | ||
60 | #define BCM2835_CLK_ENAB BIT(4) | ||
61 | #define BCM2835_CLK_SRC(v) (v) | ||
62 | |||
63 | #define BCM2835_CLK_SHIFT (12) | ||
64 | #define BCM2835_CLK_DIVI(v) ((v) << BCM2835_CLK_SHIFT) | ||
65 | #define BCM2835_CLK_DIVF(v) (v) | ||
66 | #define BCM2835_CLK_DIVF_MASK (0xFFF) | ||
67 | |||
68 | enum { | ||
69 | BCM2835_CLK_MASH_0 = 0, | ||
70 | BCM2835_CLK_MASH_1, | ||
71 | BCM2835_CLK_MASH_2, | ||
72 | BCM2835_CLK_MASH_3, | ||
73 | }; | ||
74 | |||
75 | enum { | ||
76 | BCM2835_CLK_SRC_GND = 0, | ||
77 | BCM2835_CLK_SRC_OSC, | ||
78 | BCM2835_CLK_SRC_DBG0, | ||
79 | BCM2835_CLK_SRC_DBG1, | ||
80 | BCM2835_CLK_SRC_PLLA, | ||
81 | BCM2835_CLK_SRC_PLLC, | ||
82 | BCM2835_CLK_SRC_PLLD, | ||
83 | BCM2835_CLK_SRC_HDMI, | ||
84 | }; | ||
85 | |||
86 | /* Most clocks are not useable (freq = 0) */ | ||
87 | static const unsigned int bcm2835_clk_freq[BCM2835_CLK_SRC_HDMI+1] = { | ||
88 | [BCM2835_CLK_SRC_GND] = 0, | ||
89 | [BCM2835_CLK_SRC_OSC] = 19200000, | ||
90 | [BCM2835_CLK_SRC_DBG0] = 0, | ||
91 | [BCM2835_CLK_SRC_DBG1] = 0, | ||
92 | [BCM2835_CLK_SRC_PLLA] = 0, | ||
93 | [BCM2835_CLK_SRC_PLLC] = 0, | ||
94 | [BCM2835_CLK_SRC_PLLD] = 500000000, | ||
95 | [BCM2835_CLK_SRC_HDMI] = 0, | ||
96 | }; | ||
97 | |||
98 | /* I2S registers */ | ||
99 | #define BCM2835_I2S_CS_A_REG 0x00 | ||
100 | #define BCM2835_I2S_FIFO_A_REG 0x04 | ||
101 | #define BCM2835_I2S_MODE_A_REG 0x08 | ||
102 | #define BCM2835_I2S_RXC_A_REG 0x0c | ||
103 | #define BCM2835_I2S_TXC_A_REG 0x10 | ||
104 | #define BCM2835_I2S_DREQ_A_REG 0x14 | ||
105 | #define BCM2835_I2S_INTEN_A_REG 0x18 | ||
106 | #define BCM2835_I2S_INTSTC_A_REG 0x1c | ||
107 | #define BCM2835_I2S_GRAY_REG 0x20 | ||
108 | |||
109 | /* I2S register settings */ | ||
110 | #define BCM2835_I2S_STBY BIT(25) | ||
111 | #define BCM2835_I2S_SYNC BIT(24) | ||
112 | #define BCM2835_I2S_RXSEX BIT(23) | ||
113 | #define BCM2835_I2S_RXF BIT(22) | ||
114 | #define BCM2835_I2S_TXE BIT(21) | ||
115 | #define BCM2835_I2S_RXD BIT(20) | ||
116 | #define BCM2835_I2S_TXD BIT(19) | ||
117 | #define BCM2835_I2S_RXR BIT(18) | ||
118 | #define BCM2835_I2S_TXW BIT(17) | ||
119 | #define BCM2835_I2S_CS_RXERR BIT(16) | ||
120 | #define BCM2835_I2S_CS_TXERR BIT(15) | ||
121 | #define BCM2835_I2S_RXSYNC BIT(14) | ||
122 | #define BCM2835_I2S_TXSYNC BIT(13) | ||
123 | #define BCM2835_I2S_DMAEN BIT(9) | ||
124 | #define BCM2835_I2S_RXTHR(v) ((v) << 7) | ||
125 | #define BCM2835_I2S_TXTHR(v) ((v) << 5) | ||
126 | #define BCM2835_I2S_RXCLR BIT(4) | ||
127 | #define BCM2835_I2S_TXCLR BIT(3) | ||
128 | #define BCM2835_I2S_TXON BIT(2) | ||
129 | #define BCM2835_I2S_RXON BIT(1) | ||
130 | #define BCM2835_I2S_EN (1) | ||
131 | |||
132 | #define BCM2835_I2S_CLKDIS BIT(28) | ||
133 | #define BCM2835_I2S_PDMN BIT(27) | ||
134 | #define BCM2835_I2S_PDME BIT(26) | ||
135 | #define BCM2835_I2S_FRXP BIT(25) | ||
136 | #define BCM2835_I2S_FTXP BIT(24) | ||
137 | #define BCM2835_I2S_CLKM BIT(23) | ||
138 | #define BCM2835_I2S_CLKI BIT(22) | ||
139 | #define BCM2835_I2S_FSM BIT(21) | ||
140 | #define BCM2835_I2S_FSI BIT(20) | ||
141 | #define BCM2835_I2S_FLEN(v) ((v) << 10) | ||
142 | #define BCM2835_I2S_FSLEN(v) (v) | ||
143 | |||
144 | #define BCM2835_I2S_CHWEX BIT(15) | ||
145 | #define BCM2835_I2S_CHEN BIT(14) | ||
146 | #define BCM2835_I2S_CHPOS(v) ((v) << 4) | ||
147 | #define BCM2835_I2S_CHWID(v) (v) | ||
148 | #define BCM2835_I2S_CH1(v) ((v) << 16) | ||
149 | #define BCM2835_I2S_CH2(v) (v) | ||
150 | |||
151 | #define BCM2835_I2S_TX_PANIC(v) ((v) << 24) | ||
152 | #define BCM2835_I2S_RX_PANIC(v) ((v) << 16) | ||
153 | #define BCM2835_I2S_TX(v) ((v) << 8) | ||
154 | #define BCM2835_I2S_RX(v) (v) | ||
155 | |||
156 | #define BCM2835_I2S_INT_RXERR BIT(3) | ||
157 | #define BCM2835_I2S_INT_TXERR BIT(2) | ||
158 | #define BCM2835_I2S_INT_RXR BIT(1) | ||
159 | #define BCM2835_I2S_INT_TXW BIT(0) | ||
160 | |||
161 | /* I2S DMA interface */ | ||
162 | /* FIXME: Needs IOMMU support */ | ||
163 | #define BCM2835_VCMMU_SHIFT (0x7E000000 - 0x20000000) | ||
164 | |||
165 | /* General device struct */ | ||
166 | struct bcm2835_i2s_dev { | ||
167 | struct device *dev; | ||
168 | struct snd_dmaengine_dai_dma_data dma_data[2]; | ||
169 | unsigned int fmt; | ||
170 | unsigned int bclk_ratio; | ||
171 | |||
172 | struct regmap *i2s_regmap; | ||
173 | struct regmap *clk_regmap; | ||
174 | }; | ||
175 | |||
176 | static void bcm2835_i2s_start_clock(struct bcm2835_i2s_dev *dev) | ||
177 | { | ||
178 | /* Start the clock if in master mode */ | ||
179 | unsigned int master = dev->fmt & SND_SOC_DAIFMT_MASTER_MASK; | ||
180 | |||
181 | switch (master) { | ||
182 | case SND_SOC_DAIFMT_CBS_CFS: | ||
183 | case SND_SOC_DAIFMT_CBS_CFM: | ||
184 | regmap_update_bits(dev->clk_regmap, BCM2835_CLK_PCMCTL_REG, | ||
185 | BCM2835_CLK_PASSWD_MASK | BCM2835_CLK_ENAB, | ||
186 | BCM2835_CLK_PASSWD | BCM2835_CLK_ENAB); | ||
187 | break; | ||
188 | default: | ||
189 | break; | ||
190 | } | ||
191 | } | ||
192 | |||
193 | static void bcm2835_i2s_stop_clock(struct bcm2835_i2s_dev *dev) | ||
194 | { | ||
195 | uint32_t clkreg; | ||
196 | int timeout = 1000; | ||
197 | |||
198 | /* Stop clock */ | ||
199 | regmap_update_bits(dev->clk_regmap, BCM2835_CLK_PCMCTL_REG, | ||
200 | BCM2835_CLK_PASSWD_MASK | BCM2835_CLK_ENAB, | ||
201 | BCM2835_CLK_PASSWD); | ||
202 | |||
203 | /* Wait for the BUSY flag going down */ | ||
204 | while (--timeout) { | ||
205 | regmap_read(dev->clk_regmap, BCM2835_CLK_PCMCTL_REG, &clkreg); | ||
206 | if (!(clkreg & BCM2835_CLK_BUSY)) | ||
207 | break; | ||
208 | } | ||
209 | |||
210 | if (!timeout) { | ||
211 | /* KILL the clock */ | ||
212 | dev_err(dev->dev, "I2S clock didn't stop. Kill the clock!\n"); | ||
213 | regmap_update_bits(dev->clk_regmap, BCM2835_CLK_PCMCTL_REG, | ||
214 | BCM2835_CLK_KILL | BCM2835_CLK_PASSWD_MASK, | ||
215 | BCM2835_CLK_KILL | BCM2835_CLK_PASSWD); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | static void bcm2835_i2s_clear_fifos(struct bcm2835_i2s_dev *dev, | ||
220 | bool tx, bool rx) | ||
221 | { | ||
222 | int timeout = 1000; | ||
223 | uint32_t syncval; | ||
224 | uint32_t csreg; | ||
225 | uint32_t i2s_active_state; | ||
226 | uint32_t clkreg; | ||
227 | uint32_t clk_active_state; | ||
228 | uint32_t off; | ||
229 | uint32_t clr; | ||
230 | |||
231 | off = tx ? BCM2835_I2S_TXON : 0; | ||
232 | off |= rx ? BCM2835_I2S_RXON : 0; | ||
233 | |||
234 | clr = tx ? BCM2835_I2S_TXCLR : 0; | ||
235 | clr |= rx ? BCM2835_I2S_RXCLR : 0; | ||
236 | |||
237 | /* Backup the current state */ | ||
238 | regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &csreg); | ||
239 | i2s_active_state = csreg & (BCM2835_I2S_RXON | BCM2835_I2S_TXON); | ||
240 | |||
241 | regmap_read(dev->clk_regmap, BCM2835_CLK_PCMCTL_REG, &clkreg); | ||
242 | clk_active_state = clkreg & BCM2835_CLK_ENAB; | ||
243 | |||
244 | /* Start clock if not running */ | ||
245 | if (!clk_active_state) { | ||
246 | regmap_update_bits(dev->clk_regmap, BCM2835_CLK_PCMCTL_REG, | ||
247 | BCM2835_CLK_PASSWD_MASK | BCM2835_CLK_ENAB, | ||
248 | BCM2835_CLK_PASSWD | BCM2835_CLK_ENAB); | ||
249 | } | ||
250 | |||
251 | /* Stop I2S module */ | ||
252 | regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, off, 0); | ||
253 | |||
254 | /* | ||
255 | * Clear the FIFOs | ||
256 | * Requires at least 2 PCM clock cycles to take effect | ||
257 | */ | ||
258 | regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, clr, clr); | ||
259 | |||
260 | /* Wait for 2 PCM clock cycles */ | ||
261 | |||
262 | /* | ||
263 | * Toggle the SYNC flag. After 2 PCM clock cycles it can be read back | ||
264 | * FIXME: This does not seem to work for slave mode! | ||
265 | */ | ||
266 | regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &syncval); | ||
267 | syncval &= BCM2835_I2S_SYNC; | ||
268 | |||
269 | regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, | ||
270 | BCM2835_I2S_SYNC, ~syncval); | ||
271 | |||
272 | /* Wait for the SYNC flag changing it's state */ | ||
273 | while (--timeout) { | ||
274 | regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &csreg); | ||
275 | if ((csreg & BCM2835_I2S_SYNC) != syncval) | ||
276 | break; | ||
277 | } | ||
278 | |||
279 | if (!timeout) | ||
280 | dev_err(dev->dev, "I2S SYNC error!\n"); | ||
281 | |||
282 | /* Stop clock if it was not running before */ | ||
283 | if (!clk_active_state) | ||
284 | bcm2835_i2s_stop_clock(dev); | ||
285 | |||
286 | /* Restore I2S state */ | ||
287 | regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, | ||
288 | BCM2835_I2S_RXON | BCM2835_I2S_TXON, i2s_active_state); | ||
289 | } | ||
290 | |||
291 | static int bcm2835_i2s_set_dai_fmt(struct snd_soc_dai *dai, | ||
292 | unsigned int fmt) | ||
293 | { | ||
294 | struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); | ||
295 | dev->fmt = fmt; | ||
296 | return 0; | ||
297 | } | ||
298 | |||
299 | static int bcm2835_i2s_set_dai_bclk_ratio(struct snd_soc_dai *dai, | ||
300 | unsigned int ratio) | ||
301 | { | ||
302 | struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); | ||
303 | dev->bclk_ratio = ratio; | ||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream, | ||
308 | struct snd_pcm_hw_params *params, | ||
309 | struct snd_soc_dai *dai) | ||
310 | { | ||
311 | struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); | ||
312 | |||
313 | unsigned int sampling_rate = params_rate(params); | ||
314 | unsigned int data_length, data_delay, bclk_ratio; | ||
315 | unsigned int ch1pos, ch2pos, mode, format; | ||
316 | unsigned int mash = BCM2835_CLK_MASH_1; | ||
317 | unsigned int divi, divf, target_frequency; | ||
318 | int clk_src = -1; | ||
319 | unsigned int master = dev->fmt & SND_SOC_DAIFMT_MASTER_MASK; | ||
320 | bool bit_master = (master == SND_SOC_DAIFMT_CBS_CFS | ||
321 | || master == SND_SOC_DAIFMT_CBS_CFM); | ||
322 | |||
323 | bool frame_master = (master == SND_SOC_DAIFMT_CBS_CFS | ||
324 | || master == SND_SOC_DAIFMT_CBM_CFS); | ||
325 | uint32_t csreg; | ||
326 | |||
327 | /* | ||
328 | * If a stream is already enabled, | ||
329 | * the registers are already set properly. | ||
330 | */ | ||
331 | regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &csreg); | ||
332 | |||
333 | if (csreg & (BCM2835_I2S_TXON | BCM2835_I2S_RXON)) | ||
334 | return 0; | ||
335 | |||
336 | /* | ||
337 | * Adjust the data length according to the format. | ||
338 | * We prefill the half frame length with an integer | ||
339 | * divider of 2400 as explained at the clock settings. | ||
340 | * Maybe it is overwritten there, if the Integer mode | ||
341 | * does not apply. | ||
342 | */ | ||
343 | switch (params_format(params)) { | ||
344 | case SNDRV_PCM_FORMAT_S16_LE: | ||
345 | data_length = 16; | ||
346 | bclk_ratio = 40; | ||
347 | break; | ||
348 | case SNDRV_PCM_FORMAT_S32_LE: | ||
349 | data_length = 32; | ||
350 | bclk_ratio = 80; | ||
351 | break; | ||
352 | default: | ||
353 | return -EINVAL; | ||
354 | } | ||
355 | |||
356 | /* If bclk_ratio already set, use that one. */ | ||
357 | if (dev->bclk_ratio) | ||
358 | bclk_ratio = dev->bclk_ratio; | ||
359 | |||
360 | /* | ||
361 | * Clock Settings | ||
362 | * | ||
363 | * The target frequency of the bit clock is | ||
364 | * sampling rate * frame length | ||
365 | * | ||
366 | * Integer mode: | ||
367 | * Sampling rates that are multiples of 8000 kHz | ||
368 | * can be driven by the oscillator of 19.2 MHz | ||
369 | * with an integer divider as long as the frame length | ||
370 | * is an integer divider of 19200000/8000=2400 as set up above. | ||
371 | * This is no longer possible if the sampling rate | ||
372 | * is too high (e.g. 192 kHz), because the oscillator is too slow. | ||
373 | * | ||
374 | * MASH mode: | ||
375 | * For all other sampling rates, it is not possible to | ||
376 | * have an integer divider. Approximate the clock | ||
377 | * with the MASH module that induces a slight frequency | ||
378 | * variance. To minimize that it is best to have the fastest | ||
379 | * clock here. That is PLLD with 500 MHz. | ||
380 | */ | ||
381 | target_frequency = sampling_rate * bclk_ratio; | ||
382 | clk_src = BCM2835_CLK_SRC_OSC; | ||
383 | mash = BCM2835_CLK_MASH_0; | ||
384 | |||
385 | if (bcm2835_clk_freq[clk_src] % target_frequency == 0 | ||
386 | && bit_master && frame_master) { | ||
387 | divi = bcm2835_clk_freq[clk_src] / target_frequency; | ||
388 | divf = 0; | ||
389 | } else { | ||
390 | uint64_t dividend; | ||
391 | |||
392 | if (!dev->bclk_ratio) { | ||
393 | /* | ||
394 | * Overwrite bclk_ratio, because the | ||
395 | * above trick is not needed or can | ||
396 | * not be used. | ||
397 | */ | ||
398 | bclk_ratio = 2 * data_length; | ||
399 | } | ||
400 | |||
401 | target_frequency = sampling_rate * bclk_ratio; | ||
402 | |||
403 | clk_src = BCM2835_CLK_SRC_PLLD; | ||
404 | mash = BCM2835_CLK_MASH_1; | ||
405 | |||
406 | dividend = bcm2835_clk_freq[clk_src]; | ||
407 | dividend <<= BCM2835_CLK_SHIFT; | ||
408 | do_div(dividend, target_frequency); | ||
409 | divi = dividend >> BCM2835_CLK_SHIFT; | ||
410 | divf = dividend & BCM2835_CLK_DIVF_MASK; | ||
411 | } | ||
412 | |||
413 | /* Set clock divider */ | ||
414 | regmap_write(dev->clk_regmap, BCM2835_CLK_PCMDIV_REG, BCM2835_CLK_PASSWD | ||
415 | | BCM2835_CLK_DIVI(divi) | ||
416 | | BCM2835_CLK_DIVF(divf)); | ||
417 | |||
418 | /* Setup clock, but don't start it yet */ | ||
419 | regmap_write(dev->clk_regmap, BCM2835_CLK_PCMCTL_REG, BCM2835_CLK_PASSWD | ||
420 | | BCM2835_CLK_MASH(mash) | ||
421 | | BCM2835_CLK_SRC(clk_src)); | ||
422 | |||
423 | /* Setup the frame format */ | ||
424 | format = BCM2835_I2S_CHEN; | ||
425 | |||
426 | if (data_length > 24) | ||
427 | format |= BCM2835_I2S_CHWEX; | ||
428 | |||
429 | format |= BCM2835_I2S_CHWID((data_length-8)&0xf); | ||
430 | |||
431 | switch (dev->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
432 | case SND_SOC_DAIFMT_I2S: | ||
433 | data_delay = 1; | ||
434 | break; | ||
435 | default: | ||
436 | /* | ||
437 | * TODO | ||
438 | * Others are possible but are not implemented at the moment. | ||
439 | */ | ||
440 | dev_err(dev->dev, "%s:bad format\n", __func__); | ||
441 | return -EINVAL; | ||
442 | } | ||
443 | |||
444 | ch1pos = data_delay; | ||
445 | ch2pos = bclk_ratio / 2 + data_delay; | ||
446 | |||
447 | switch (params_channels(params)) { | ||
448 | case 2: | ||
449 | format = BCM2835_I2S_CH1(format) | BCM2835_I2S_CH2(format); | ||
450 | format |= BCM2835_I2S_CH1(BCM2835_I2S_CHPOS(ch1pos)); | ||
451 | format |= BCM2835_I2S_CH2(BCM2835_I2S_CHPOS(ch2pos)); | ||
452 | break; | ||
453 | default: | ||
454 | return -EINVAL; | ||
455 | } | ||
456 | |||
457 | /* | ||
458 | * Set format for both streams. | ||
459 | * We cannot set another frame length | ||
460 | * (and therefore word length) anyway, | ||
461 | * so the format will be the same. | ||
462 | */ | ||
463 | regmap_write(dev->i2s_regmap, BCM2835_I2S_RXC_A_REG, format); | ||
464 | regmap_write(dev->i2s_regmap, BCM2835_I2S_TXC_A_REG, format); | ||
465 | |||
466 | /* Setup the I2S mode */ | ||
467 | mode = 0; | ||
468 | |||
469 | if (data_length <= 16) { | ||
470 | /* | ||
471 | * Use frame packed mode (2 channels per 32 bit word) | ||
472 | * We cannot set another frame length in the second stream | ||
473 | * (and therefore word length) anyway, | ||
474 | * so the format will be the same. | ||
475 | */ | ||
476 | mode |= BCM2835_I2S_FTXP | BCM2835_I2S_FRXP; | ||
477 | } | ||
478 | |||
479 | mode |= BCM2835_I2S_FLEN(bclk_ratio - 1); | ||
480 | mode |= BCM2835_I2S_FSLEN(bclk_ratio / 2); | ||
481 | |||
482 | /* Master or slave? */ | ||
483 | switch (dev->fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
484 | case SND_SOC_DAIFMT_CBS_CFS: | ||
485 | /* CPU is master */ | ||
486 | break; | ||
487 | case SND_SOC_DAIFMT_CBM_CFS: | ||
488 | /* | ||
489 | * CODEC is bit clock master | ||
490 | * CPU is frame master | ||
491 | */ | ||
492 | mode |= BCM2835_I2S_CLKM; | ||
493 | break; | ||
494 | case SND_SOC_DAIFMT_CBS_CFM: | ||
495 | /* | ||
496 | * CODEC is frame master | ||
497 | * CPU is bit clock master | ||
498 | */ | ||
499 | mode |= BCM2835_I2S_FSM; | ||
500 | break; | ||
501 | case SND_SOC_DAIFMT_CBM_CFM: | ||
502 | /* CODEC is master */ | ||
503 | mode |= BCM2835_I2S_CLKM; | ||
504 | mode |= BCM2835_I2S_FSM; | ||
505 | break; | ||
506 | default: | ||
507 | dev_err(dev->dev, "%s:bad master\n", __func__); | ||
508 | return -EINVAL; | ||
509 | } | ||
510 | |||
511 | /* | ||
512 | * Invert clocks? | ||
513 | * | ||
514 | * The BCM approach seems to be inverted to the classical I2S approach. | ||
515 | */ | ||
516 | switch (dev->fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
517 | case SND_SOC_DAIFMT_NB_NF: | ||
518 | /* None. Therefore, both for BCM */ | ||
519 | mode |= BCM2835_I2S_CLKI; | ||
520 | mode |= BCM2835_I2S_FSI; | ||
521 | break; | ||
522 | case SND_SOC_DAIFMT_IB_IF: | ||
523 | /* Both. Therefore, none for BCM */ | ||
524 | break; | ||
525 | case SND_SOC_DAIFMT_NB_IF: | ||
526 | /* | ||
527 | * Invert only frame sync. Therefore, | ||
528 | * invert only bit clock for BCM | ||
529 | */ | ||
530 | mode |= BCM2835_I2S_CLKI; | ||
531 | break; | ||
532 | case SND_SOC_DAIFMT_IB_NF: | ||
533 | /* | ||
534 | * Invert only bit clock. Therefore, | ||
535 | * invert only frame sync for BCM | ||
536 | */ | ||
537 | mode |= BCM2835_I2S_FSI; | ||
538 | break; | ||
539 | default: | ||
540 | return -EINVAL; | ||
541 | } | ||
542 | |||
543 | regmap_write(dev->i2s_regmap, BCM2835_I2S_MODE_A_REG, mode); | ||
544 | |||
545 | /* Setup the DMA parameters */ | ||
546 | regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, | ||
547 | BCM2835_I2S_RXTHR(1) | ||
548 | | BCM2835_I2S_TXTHR(1) | ||
549 | | BCM2835_I2S_DMAEN, 0xffffffff); | ||
550 | |||
551 | regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_DREQ_A_REG, | ||
552 | BCM2835_I2S_TX_PANIC(0x10) | ||
553 | | BCM2835_I2S_RX_PANIC(0x30) | ||
554 | | BCM2835_I2S_TX(0x30) | ||
555 | | BCM2835_I2S_RX(0x20), 0xffffffff); | ||
556 | |||
557 | /* Clear FIFOs */ | ||
558 | bcm2835_i2s_clear_fifos(dev, true, true); | ||
559 | |||
560 | return 0; | ||
561 | } | ||
562 | |||
563 | static int bcm2835_i2s_prepare(struct snd_pcm_substream *substream, | ||
564 | struct snd_soc_dai *dai) | ||
565 | { | ||
566 | struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); | ||
567 | uint32_t cs_reg; | ||
568 | |||
569 | bcm2835_i2s_start_clock(dev); | ||
570 | |||
571 | /* | ||
572 | * Clear both FIFOs if the one that should be started | ||
573 | * is not empty at the moment. This should only happen | ||
574 | * after overrun. Otherwise, hw_params would have cleared | ||
575 | * the FIFO. | ||
576 | */ | ||
577 | regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &cs_reg); | ||
578 | |||
579 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK | ||
580 | && !(cs_reg & BCM2835_I2S_TXE)) | ||
581 | bcm2835_i2s_clear_fifos(dev, true, false); | ||
582 | else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE | ||
583 | && (cs_reg & BCM2835_I2S_RXD)) | ||
584 | bcm2835_i2s_clear_fifos(dev, false, true); | ||
585 | |||
586 | return 0; | ||
587 | } | ||
588 | |||
589 | static void bcm2835_i2s_stop(struct bcm2835_i2s_dev *dev, | ||
590 | struct snd_pcm_substream *substream, | ||
591 | struct snd_soc_dai *dai) | ||
592 | { | ||
593 | uint32_t mask; | ||
594 | |||
595 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
596 | mask = BCM2835_I2S_RXON; | ||
597 | else | ||
598 | mask = BCM2835_I2S_TXON; | ||
599 | |||
600 | regmap_update_bits(dev->i2s_regmap, | ||
601 | BCM2835_I2S_CS_A_REG, mask, 0); | ||
602 | |||
603 | /* Stop also the clock when not SND_SOC_DAIFMT_CONT */ | ||
604 | if (!dai->active && !(dev->fmt & SND_SOC_DAIFMT_CONT)) | ||
605 | bcm2835_i2s_stop_clock(dev); | ||
606 | } | ||
607 | |||
608 | static int bcm2835_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | ||
609 | struct snd_soc_dai *dai) | ||
610 | { | ||
611 | struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); | ||
612 | uint32_t mask; | ||
613 | |||
614 | switch (cmd) { | ||
615 | case SNDRV_PCM_TRIGGER_START: | ||
616 | case SNDRV_PCM_TRIGGER_RESUME: | ||
617 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
618 | bcm2835_i2s_start_clock(dev); | ||
619 | |||
620 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
621 | mask = BCM2835_I2S_RXON; | ||
622 | else | ||
623 | mask = BCM2835_I2S_TXON; | ||
624 | |||
625 | regmap_update_bits(dev->i2s_regmap, | ||
626 | BCM2835_I2S_CS_A_REG, mask, mask); | ||
627 | break; | ||
628 | |||
629 | case SNDRV_PCM_TRIGGER_STOP: | ||
630 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
631 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
632 | bcm2835_i2s_stop(dev, substream, dai); | ||
633 | break; | ||
634 | default: | ||
635 | return -EINVAL; | ||
636 | } | ||
637 | |||
638 | return 0; | ||
639 | } | ||
640 | |||
641 | static int bcm2835_i2s_startup(struct snd_pcm_substream *substream, | ||
642 | struct snd_soc_dai *dai) | ||
643 | { | ||
644 | struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); | ||
645 | |||
646 | if (dai->active) | ||
647 | return 0; | ||
648 | |||
649 | /* Should this still be running stop it */ | ||
650 | bcm2835_i2s_stop_clock(dev); | ||
651 | |||
652 | /* Enable PCM block */ | ||
653 | regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, | ||
654 | BCM2835_I2S_EN, BCM2835_I2S_EN); | ||
655 | |||
656 | /* | ||
657 | * Disable STBY. | ||
658 | * Requires at least 4 PCM clock cycles to take effect. | ||
659 | */ | ||
660 | regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, | ||
661 | BCM2835_I2S_STBY, BCM2835_I2S_STBY); | ||
662 | |||
663 | return 0; | ||
664 | } | ||
665 | |||
666 | static void bcm2835_i2s_shutdown(struct snd_pcm_substream *substream, | ||
667 | struct snd_soc_dai *dai) | ||
668 | { | ||
669 | struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); | ||
670 | |||
671 | bcm2835_i2s_stop(dev, substream, dai); | ||
672 | |||
673 | /* If both streams are stopped, disable module and clock */ | ||
674 | if (dai->active) | ||
675 | return; | ||
676 | |||
677 | /* Disable the module */ | ||
678 | regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, | ||
679 | BCM2835_I2S_EN, 0); | ||
680 | |||
681 | /* | ||
682 | * Stopping clock is necessary, because stop does | ||
683 | * not stop the clock when SND_SOC_DAIFMT_CONT | ||
684 | */ | ||
685 | bcm2835_i2s_stop_clock(dev); | ||
686 | } | ||
687 | |||
688 | static const struct snd_soc_dai_ops bcm2835_i2s_dai_ops = { | ||
689 | .startup = bcm2835_i2s_startup, | ||
690 | .shutdown = bcm2835_i2s_shutdown, | ||
691 | .prepare = bcm2835_i2s_prepare, | ||
692 | .trigger = bcm2835_i2s_trigger, | ||
693 | .hw_params = bcm2835_i2s_hw_params, | ||
694 | .set_fmt = bcm2835_i2s_set_dai_fmt, | ||
695 | .set_bclk_ratio = bcm2835_i2s_set_dai_bclk_ratio | ||
696 | }; | ||
697 | |||
698 | static int bcm2835_i2s_dai_probe(struct snd_soc_dai *dai) | ||
699 | { | ||
700 | struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); | ||
701 | |||
702 | snd_soc_dai_init_dma_data(dai, | ||
703 | &dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK], | ||
704 | &dev->dma_data[SNDRV_PCM_STREAM_CAPTURE]); | ||
705 | |||
706 | return 0; | ||
707 | } | ||
708 | |||
709 | static struct snd_soc_dai_driver bcm2835_i2s_dai = { | ||
710 | .name = "bcm2835-i2s", | ||
711 | .probe = bcm2835_i2s_dai_probe, | ||
712 | .playback = { | ||
713 | .channels_min = 2, | ||
714 | .channels_max = 2, | ||
715 | .rates = SNDRV_PCM_RATE_8000_192000, | ||
716 | .formats = SNDRV_PCM_FMTBIT_S16_LE | ||
717 | | SNDRV_PCM_FMTBIT_S32_LE | ||
718 | }, | ||
719 | .capture = { | ||
720 | .channels_min = 2, | ||
721 | .channels_max = 2, | ||
722 | .rates = SNDRV_PCM_RATE_8000_192000, | ||
723 | .formats = SNDRV_PCM_FMTBIT_S16_LE | ||
724 | | SNDRV_PCM_FMTBIT_S32_LE | ||
725 | }, | ||
726 | .ops = &bcm2835_i2s_dai_ops, | ||
727 | .symmetric_rates = 1 | ||
728 | }; | ||
729 | |||
730 | static bool bcm2835_i2s_volatile_reg(struct device *dev, unsigned int reg) | ||
731 | { | ||
732 | switch (reg) { | ||
733 | case BCM2835_I2S_CS_A_REG: | ||
734 | case BCM2835_I2S_FIFO_A_REG: | ||
735 | case BCM2835_I2S_INTSTC_A_REG: | ||
736 | case BCM2835_I2S_GRAY_REG: | ||
737 | return true; | ||
738 | default: | ||
739 | return false; | ||
740 | }; | ||
741 | } | ||
742 | |||
743 | static bool bcm2835_i2s_precious_reg(struct device *dev, unsigned int reg) | ||
744 | { | ||
745 | switch (reg) { | ||
746 | case BCM2835_I2S_FIFO_A_REG: | ||
747 | return true; | ||
748 | default: | ||
749 | return false; | ||
750 | }; | ||
751 | } | ||
752 | |||
753 | static bool bcm2835_clk_volatile_reg(struct device *dev, unsigned int reg) | ||
754 | { | ||
755 | switch (reg) { | ||
756 | case BCM2835_CLK_PCMCTL_REG: | ||
757 | return true; | ||
758 | default: | ||
759 | return false; | ||
760 | }; | ||
761 | } | ||
762 | |||
763 | static const struct regmap_config bcm2835_regmap_config[] = { | ||
764 | { | ||
765 | .reg_bits = 32, | ||
766 | .reg_stride = 4, | ||
767 | .val_bits = 32, | ||
768 | .max_register = BCM2835_I2S_GRAY_REG, | ||
769 | .precious_reg = bcm2835_i2s_precious_reg, | ||
770 | .volatile_reg = bcm2835_i2s_volatile_reg, | ||
771 | .cache_type = REGCACHE_RBTREE, | ||
772 | }, | ||
773 | { | ||
774 | .reg_bits = 32, | ||
775 | .reg_stride = 4, | ||
776 | .val_bits = 32, | ||
777 | .max_register = BCM2835_CLK_PCMDIV_REG, | ||
778 | .volatile_reg = bcm2835_clk_volatile_reg, | ||
779 | .cache_type = REGCACHE_RBTREE, | ||
780 | }, | ||
781 | }; | ||
782 | |||
783 | static const struct snd_soc_component_driver bcm2835_i2s_component = { | ||
784 | .name = "bcm2835-i2s-comp", | ||
785 | }; | ||
786 | |||
787 | static int bcm2835_i2s_probe(struct platform_device *pdev) | ||
788 | { | ||
789 | struct bcm2835_i2s_dev *dev; | ||
790 | int i; | ||
791 | int ret; | ||
792 | struct regmap *regmap[2]; | ||
793 | struct resource *mem[2]; | ||
794 | |||
795 | /* Request both ioareas */ | ||
796 | for (i = 0; i <= 1; i++) { | ||
797 | void __iomem *base; | ||
798 | |||
799 | mem[i] = platform_get_resource(pdev, IORESOURCE_MEM, i); | ||
800 | base = devm_ioremap_resource(&pdev->dev, mem[i]); | ||
801 | if (IS_ERR(base)) | ||
802 | return PTR_ERR(base); | ||
803 | |||
804 | regmap[i] = devm_regmap_init_mmio(&pdev->dev, base, | ||
805 | &bcm2835_regmap_config[i]); | ||
806 | if (IS_ERR(regmap[i])) | ||
807 | return PTR_ERR(regmap[i]); | ||
808 | } | ||
809 | |||
810 | dev = devm_kzalloc(&pdev->dev, sizeof(*dev), | ||
811 | GFP_KERNEL); | ||
812 | if (!dev) | ||
813 | return -ENOMEM; | ||
814 | |||
815 | dev->i2s_regmap = regmap[0]; | ||
816 | dev->clk_regmap = regmap[1]; | ||
817 | |||
818 | /* Set the DMA address */ | ||
819 | dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr = | ||
820 | (dma_addr_t)mem[0]->start + BCM2835_I2S_FIFO_A_REG | ||
821 | + BCM2835_VCMMU_SHIFT; | ||
822 | |||
823 | dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr = | ||
824 | (dma_addr_t)mem[0]->start + BCM2835_I2S_FIFO_A_REG | ||
825 | + BCM2835_VCMMU_SHIFT; | ||
826 | |||
827 | /* Set the bus width */ | ||
828 | dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr_width = | ||
829 | DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
830 | dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr_width = | ||
831 | DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
832 | |||
833 | /* Set burst */ | ||
834 | dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].maxburst = 2; | ||
835 | dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].maxburst = 2; | ||
836 | |||
837 | /* BCLK ratio - use default */ | ||
838 | dev->bclk_ratio = 0; | ||
839 | |||
840 | /* Store the pdev */ | ||
841 | dev->dev = &pdev->dev; | ||
842 | dev_set_drvdata(&pdev->dev, dev); | ||
843 | |||
844 | ret = devm_snd_soc_register_component(&pdev->dev, | ||
845 | &bcm2835_i2s_component, &bcm2835_i2s_dai, 1); | ||
846 | if (ret) { | ||
847 | dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); | ||
848 | return ret; | ||
849 | } | ||
850 | |||
851 | ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); | ||
852 | if (ret) { | ||
853 | dev_err(&pdev->dev, "Could not register PCM: %d\n", ret); | ||
854 | return ret; | ||
855 | } | ||
856 | |||
857 | return 0; | ||
858 | } | ||
859 | |||
860 | static const struct of_device_id bcm2835_i2s_of_match[] = { | ||
861 | { .compatible = "brcm,bcm2835-i2s", }, | ||
862 | {}, | ||
863 | }; | ||
864 | |||
865 | static struct platform_driver bcm2835_i2s_driver = { | ||
866 | .probe = bcm2835_i2s_probe, | ||
867 | .driver = { | ||
868 | .name = "bcm2835-i2s", | ||
869 | .owner = THIS_MODULE, | ||
870 | .of_match_table = bcm2835_i2s_of_match, | ||
871 | }, | ||
872 | }; | ||
873 | |||
874 | module_platform_driver(bcm2835_i2s_driver); | ||
875 | |||
876 | MODULE_ALIAS("platform:bcm2835-i2s"); | ||
877 | MODULE_DESCRIPTION("BCM2835 I2S interface"); | ||
878 | MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>"); | ||
879 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c index 1d4c676eb6cc..cdb8ee75ded9 100644 --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c +++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c | |||
@@ -107,7 +107,6 @@ static const struct snd_pcm_hardware bf5xx_pcm_hardware = { | |||
107 | #endif | 107 | #endif |
108 | SNDRV_PCM_INFO_BLOCK_TRANSFER, | 108 | SNDRV_PCM_INFO_BLOCK_TRANSFER, |
109 | 109 | ||
110 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
111 | .period_bytes_min = 32, | 110 | .period_bytes_min = 32, |
112 | .period_bytes_max = 0x10000, | 111 | .period_bytes_max = 0x10000, |
113 | .periods_min = 1, | 112 | .periods_min = 1, |
diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c index 2a5b43417fd5..a3881c4381c9 100644 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c | |||
@@ -52,9 +52,6 @@ static const struct snd_pcm_hardware bf5xx_pcm_hardware = { | |||
52 | .info = SNDRV_PCM_INFO_INTERLEAVED | | 52 | .info = SNDRV_PCM_INFO_INTERLEAVED | |
53 | SNDRV_PCM_INFO_MMAP_VALID | | 53 | SNDRV_PCM_INFO_MMAP_VALID | |
54 | SNDRV_PCM_INFO_BLOCK_TRANSFER, | 54 | SNDRV_PCM_INFO_BLOCK_TRANSFER, |
55 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | ||
56 | SNDRV_PCM_FMTBIT_S24_LE | | ||
57 | SNDRV_PCM_FMTBIT_S32_LE, | ||
58 | .period_bytes_min = 32, | 55 | .period_bytes_min = 32, |
59 | .period_bytes_max = 0x10000, | 56 | .period_bytes_max = 0x10000, |
60 | .periods_min = 1, | 57 | .periods_min = 1, |
diff --git a/sound/soc/cirrus/edb93xx.c b/sound/soc/cirrus/edb93xx.c index c43fb214558a..4f900efc437c 100644 --- a/sound/soc/cirrus/edb93xx.c +++ b/sound/soc/cirrus/edb93xx.c | |||
@@ -63,7 +63,7 @@ static struct snd_soc_ops edb93xx_ops = { | |||
63 | static struct snd_soc_dai_link edb93xx_dai = { | 63 | static struct snd_soc_dai_link edb93xx_dai = { |
64 | .name = "CS4271", | 64 | .name = "CS4271", |
65 | .stream_name = "CS4271 HiFi", | 65 | .stream_name = "CS4271 HiFi", |
66 | .platform_name = "ep93xx-pcm-audio", | 66 | .platform_name = "ep93xx-i2s", |
67 | .cpu_dai_name = "ep93xx-i2s", | 67 | .cpu_dai_name = "ep93xx-i2s", |
68 | .codec_name = "spi0.0", | 68 | .codec_name = "spi0.0", |
69 | .codec_dai_name = "cs4271-hifi", | 69 | .codec_dai_name = "cs4271-hifi", |
diff --git a/sound/soc/cirrus/ep93xx-ac97.c b/sound/soc/cirrus/ep93xx-ac97.c index efa75b5086a4..f30dadf85b99 100644 --- a/sound/soc/cirrus/ep93xx-ac97.c +++ b/sound/soc/cirrus/ep93xx-ac97.c | |||
@@ -19,11 +19,14 @@ | |||
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | 20 | ||
21 | #include <sound/core.h> | 21 | #include <sound/core.h> |
22 | #include <sound/dmaengine_pcm.h> | ||
22 | #include <sound/ac97_codec.h> | 23 | #include <sound/ac97_codec.h> |
23 | #include <sound/soc.h> | 24 | #include <sound/soc.h> |
24 | 25 | ||
25 | #include <linux/platform_data/dma-ep93xx.h> | 26 | #include <linux/platform_data/dma-ep93xx.h> |
26 | 27 | ||
28 | #include "ep93xx-pcm.h" | ||
29 | |||
27 | /* | 30 | /* |
28 | * Per channel (1-4) registers. | 31 | * Per channel (1-4) registers. |
29 | */ | 32 | */ |
@@ -95,6 +98,8 @@ struct ep93xx_ac97_info { | |||
95 | struct device *dev; | 98 | struct device *dev; |
96 | void __iomem *regs; | 99 | void __iomem *regs; |
97 | struct completion done; | 100 | struct completion done; |
101 | struct snd_dmaengine_dai_dma_data dma_params_rx; | ||
102 | struct snd_dmaengine_dai_dma_data dma_params_tx; | ||
98 | }; | 103 | }; |
99 | 104 | ||
100 | /* currently ALSA only supports a single AC97 device */ | 105 | /* currently ALSA only supports a single AC97 device */ |
@@ -315,8 +320,13 @@ static int ep93xx_ac97_trigger(struct snd_pcm_substream *substream, | |||
315 | 320 | ||
316 | static int ep93xx_ac97_dai_probe(struct snd_soc_dai *dai) | 321 | static int ep93xx_ac97_dai_probe(struct snd_soc_dai *dai) |
317 | { | 322 | { |
318 | dai->playback_dma_data = &ep93xx_ac97_pcm_out; | 323 | struct ep93xx_ac97_info *info = snd_soc_dai_get_drvdata(dai); |
319 | dai->capture_dma_data = &ep93xx_ac97_pcm_in; | 324 | |
325 | info->dma_params_tx.filter_data = &ep93xx_ac97_pcm_out; | ||
326 | info->dma_params_rx.filter_data = &ep93xx_ac97_pcm_in; | ||
327 | |||
328 | dai->playback_dma_data = &info->dma_params_tx; | ||
329 | dai->capture_dma_data = &info->dma_params_rx; | ||
320 | 330 | ||
321 | return 0; | 331 | return 0; |
322 | } | 332 | } |
@@ -394,8 +404,14 @@ static int ep93xx_ac97_probe(struct platform_device *pdev) | |||
394 | if (ret) | 404 | if (ret) |
395 | goto fail; | 405 | goto fail; |
396 | 406 | ||
407 | ret = devm_ep93xx_pcm_platform_register(&pdev->dev); | ||
408 | if (ret) | ||
409 | goto fail_unregister; | ||
410 | |||
397 | return 0; | 411 | return 0; |
398 | 412 | ||
413 | fail_unregister: | ||
414 | snd_soc_unregister_component(&pdev->dev); | ||
399 | fail: | 415 | fail: |
400 | ep93xx_ac97_info = NULL; | 416 | ep93xx_ac97_info = NULL; |
401 | snd_soc_set_ac97_ops(NULL); | 417 | snd_soc_set_ac97_ops(NULL); |
diff --git a/sound/soc/cirrus/ep93xx-i2s.c b/sound/soc/cirrus/ep93xx-i2s.c index a57643d6402f..943145f9d1b6 100644 --- a/sound/soc/cirrus/ep93xx-i2s.c +++ b/sound/soc/cirrus/ep93xx-i2s.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/io.h> | 21 | #include <linux/io.h> |
22 | 22 | ||
23 | #include <sound/core.h> | 23 | #include <sound/core.h> |
24 | #include <sound/dmaengine_pcm.h> | ||
24 | #include <sound/pcm.h> | 25 | #include <sound/pcm.h> |
25 | #include <sound/pcm_params.h> | 26 | #include <sound/pcm_params.h> |
26 | #include <sound/initval.h> | 27 | #include <sound/initval.h> |
@@ -30,6 +31,8 @@ | |||
30 | #include <mach/ep93xx-regs.h> | 31 | #include <mach/ep93xx-regs.h> |
31 | #include <linux/platform_data/dma-ep93xx.h> | 32 | #include <linux/platform_data/dma-ep93xx.h> |
32 | 33 | ||
34 | #include "ep93xx-pcm.h" | ||
35 | |||
33 | #define EP93XX_I2S_TXCLKCFG 0x00 | 36 | #define EP93XX_I2S_TXCLKCFG 0x00 |
34 | #define EP93XX_I2S_RXCLKCFG 0x04 | 37 | #define EP93XX_I2S_RXCLKCFG 0x04 |
35 | #define EP93XX_I2S_GLCTRL 0x0C | 38 | #define EP93XX_I2S_GLCTRL 0x0C |
@@ -61,6 +64,8 @@ struct ep93xx_i2s_info { | |||
61 | struct clk *sclk; | 64 | struct clk *sclk; |
62 | struct clk *lrclk; | 65 | struct clk *lrclk; |
63 | void __iomem *regs; | 66 | void __iomem *regs; |
67 | struct snd_dmaengine_dai_dma_data dma_params_rx; | ||
68 | struct snd_dmaengine_dai_dma_data dma_params_tx; | ||
64 | }; | 69 | }; |
65 | 70 | ||
66 | static struct ep93xx_dma_data ep93xx_i2s_dma_data[] = { | 71 | static struct ep93xx_dma_data ep93xx_i2s_dma_data[] = { |
@@ -140,8 +145,15 @@ static void ep93xx_i2s_disable(struct ep93xx_i2s_info *info, int stream) | |||
140 | 145 | ||
141 | static int ep93xx_i2s_dai_probe(struct snd_soc_dai *dai) | 146 | static int ep93xx_i2s_dai_probe(struct snd_soc_dai *dai) |
142 | { | 147 | { |
143 | dai->playback_dma_data = &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_PLAYBACK]; | 148 | struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); |
144 | dai->capture_dma_data = &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_CAPTURE]; | 149 | |
150 | info->dma_params_tx.filter_data = | ||
151 | &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_PLAYBACK]; | ||
152 | info->dma_params_rx.filter_data = | ||
153 | &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_CAPTURE]; | ||
154 | |||
155 | dai->playback_dma_data = &info->dma_params_tx; | ||
156 | dai->capture_dma_data = &info->dma_params_rx; | ||
145 | 157 | ||
146 | return 0; | 158 | return 0; |
147 | } | 159 | } |
@@ -405,8 +417,14 @@ static int ep93xx_i2s_probe(struct platform_device *pdev) | |||
405 | if (err) | 417 | if (err) |
406 | goto fail_put_lrclk; | 418 | goto fail_put_lrclk; |
407 | 419 | ||
420 | err = devm_ep93xx_pcm_platform_register(&pdev->dev); | ||
421 | if (err) | ||
422 | goto fail_unregister; | ||
423 | |||
408 | return 0; | 424 | return 0; |
409 | 425 | ||
426 | fail_unregister: | ||
427 | snd_soc_unregister_component(&pdev->dev); | ||
410 | fail_put_lrclk: | 428 | fail_put_lrclk: |
411 | clk_put(info->lrclk); | 429 | clk_put(info->lrclk); |
412 | fail_put_sclk: | 430 | fail_put_sclk: |
diff --git a/sound/soc/cirrus/ep93xx-pcm.c b/sound/soc/cirrus/ep93xx-pcm.c index cfe517e68009..5f664471d99e 100644 --- a/sound/soc/cirrus/ep93xx-pcm.c +++ b/sound/soc/cirrus/ep93xx-pcm.c | |||
@@ -23,20 +23,13 @@ | |||
23 | 23 | ||
24 | #include <linux/platform_data/dma-ep93xx.h> | 24 | #include <linux/platform_data/dma-ep93xx.h> |
25 | 25 | ||
26 | #include "ep93xx-pcm.h" | ||
27 | |||
26 | static const struct snd_pcm_hardware ep93xx_pcm_hardware = { | 28 | static const struct snd_pcm_hardware ep93xx_pcm_hardware = { |
27 | .info = (SNDRV_PCM_INFO_MMAP | | 29 | .info = (SNDRV_PCM_INFO_MMAP | |
28 | SNDRV_PCM_INFO_MMAP_VALID | | 30 | SNDRV_PCM_INFO_MMAP_VALID | |
29 | SNDRV_PCM_INFO_INTERLEAVED | | 31 | SNDRV_PCM_INFO_INTERLEAVED | |
30 | SNDRV_PCM_INFO_BLOCK_TRANSFER), | 32 | SNDRV_PCM_INFO_BLOCK_TRANSFER), |
31 | |||
32 | .rates = SNDRV_PCM_RATE_8000_192000, | ||
33 | .rate_min = SNDRV_PCM_RATE_8000, | ||
34 | .rate_max = SNDRV_PCM_RATE_192000, | ||
35 | |||
36 | .formats = (SNDRV_PCM_FMTBIT_S16_LE | | ||
37 | SNDRV_PCM_FMTBIT_S24_LE | | ||
38 | SNDRV_PCM_FMTBIT_S32_LE), | ||
39 | |||
40 | .buffer_bytes_max = 131072, | 33 | .buffer_bytes_max = 131072, |
41 | .period_bytes_min = 32, | 34 | .period_bytes_min = 32, |
42 | .period_bytes_max = 32768, | 35 | .period_bytes_max = 32768, |
@@ -57,53 +50,22 @@ static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param) | |||
57 | return false; | 50 | return false; |
58 | } | 51 | } |
59 | 52 | ||
60 | static struct dma_chan *ep93xx_compat_request_channel( | ||
61 | struct snd_soc_pcm_runtime *rtd, | ||
62 | struct snd_pcm_substream *substream) | ||
63 | { | ||
64 | struct snd_dmaengine_dai_dma_data *dma_data; | ||
65 | |||
66 | dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
67 | |||
68 | return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter, | ||
69 | dma_data); | ||
70 | } | ||
71 | |||
72 | static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = { | 53 | static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = { |
73 | .pcm_hardware = &ep93xx_pcm_hardware, | 54 | .pcm_hardware = &ep93xx_pcm_hardware, |
74 | .compat_filter_fn = ep93xx_pcm_dma_filter, | 55 | .compat_filter_fn = ep93xx_pcm_dma_filter, |
75 | .compat_request_channel = ep93xx_compat_request_channel, | ||
76 | .prealloc_buffer_size = 131072, | 56 | .prealloc_buffer_size = 131072, |
77 | }; | 57 | }; |
78 | 58 | ||
79 | static int ep93xx_soc_platform_probe(struct platform_device *pdev) | 59 | int devm_ep93xx_pcm_platform_register(struct device *dev) |
80 | { | 60 | { |
81 | return snd_dmaengine_pcm_register(&pdev->dev, | 61 | return devm_snd_dmaengine_pcm_register(dev, |
82 | &ep93xx_dmaengine_pcm_config, | 62 | &ep93xx_dmaengine_pcm_config, |
83 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | | 63 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | |
84 | SND_DMAENGINE_PCM_FLAG_NO_DT | | 64 | SND_DMAENGINE_PCM_FLAG_NO_DT | |
85 | SND_DMAENGINE_PCM_FLAG_COMPAT); | 65 | SND_DMAENGINE_PCM_FLAG_COMPAT); |
86 | } | 66 | } |
87 | 67 | EXPORT_SYMBOL_GPL(devm_ep93xx_pcm_platform_register); | |
88 | static int ep93xx_soc_platform_remove(struct platform_device *pdev) | ||
89 | { | ||
90 | snd_dmaengine_pcm_unregister(&pdev->dev); | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | static struct platform_driver ep93xx_pcm_driver = { | ||
95 | .driver = { | ||
96 | .name = "ep93xx-pcm-audio", | ||
97 | .owner = THIS_MODULE, | ||
98 | }, | ||
99 | |||
100 | .probe = ep93xx_soc_platform_probe, | ||
101 | .remove = ep93xx_soc_platform_remove, | ||
102 | }; | ||
103 | |||
104 | module_platform_driver(ep93xx_pcm_driver); | ||
105 | 68 | ||
106 | MODULE_AUTHOR("Ryan Mallon"); | 69 | MODULE_AUTHOR("Ryan Mallon"); |
107 | MODULE_DESCRIPTION("EP93xx ALSA PCM interface"); | 70 | MODULE_DESCRIPTION("EP93xx ALSA PCM interface"); |
108 | MODULE_LICENSE("GPL"); | 71 | MODULE_LICENSE("GPL"); |
109 | MODULE_ALIAS("platform:ep93xx-pcm-audio"); | ||
diff --git a/sound/soc/cirrus/ep93xx-pcm.h b/sound/soc/cirrus/ep93xx-pcm.h new file mode 100644 index 000000000000..b7a12a2fae9c --- /dev/null +++ b/sound/soc/cirrus/ep93xx-pcm.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #ifndef __EP93XX_PCM_H__ | ||
18 | #define __EP93XX_PCM_H__ | ||
19 | |||
20 | int devm_ep93xx_pcm_platform_register(struct device *dev); | ||
21 | |||
22 | #endif | ||
diff --git a/sound/soc/cirrus/simone.c b/sound/soc/cirrus/simone.c index 4d094d00c34a..822a19a89e74 100644 --- a/sound/soc/cirrus/simone.c +++ b/sound/soc/cirrus/simone.c | |||
@@ -27,7 +27,7 @@ static struct snd_soc_dai_link simone_dai = { | |||
27 | .cpu_dai_name = "ep93xx-ac97", | 27 | .cpu_dai_name = "ep93xx-ac97", |
28 | .codec_dai_name = "ac97-hifi", | 28 | .codec_dai_name = "ac97-hifi", |
29 | .codec_name = "ac97-codec", | 29 | .codec_name = "ac97-codec", |
30 | .platform_name = "ep93xx-pcm-audio", | 30 | .platform_name = "ep93xx-ac97", |
31 | }; | 31 | }; |
32 | 32 | ||
33 | static struct snd_soc_card snd_soc_simone = { | 33 | static struct snd_soc_card snd_soc_simone = { |
diff --git a/sound/soc/cirrus/snappercl15.c b/sound/soc/cirrus/snappercl15.c index 69041074f2c1..29238a7476dd 100644 --- a/sound/soc/cirrus/snappercl15.c +++ b/sound/soc/cirrus/snappercl15.c | |||
@@ -83,7 +83,7 @@ static struct snd_soc_dai_link snappercl15_dai = { | |||
83 | .cpu_dai_name = "ep93xx-i2s", | 83 | .cpu_dai_name = "ep93xx-i2s", |
84 | .codec_dai_name = "tlv320aic23-hifi", | 84 | .codec_dai_name = "tlv320aic23-hifi", |
85 | .codec_name = "tlv320aic23-codec.0-001a", | 85 | .codec_name = "tlv320aic23-codec.0-001a", |
86 | .platform_name = "ep93xx-pcm-audio", | 86 | .platform_name = "ep93xx-i2s", |
87 | .init = snappercl15_tlv320aic23_init, | 87 | .init = snappercl15_tlv320aic23_init, |
88 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF | | 88 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF | |
89 | SND_SOC_DAIFMT_CBS_CFS, | 89 | SND_SOC_DAIFMT_CBS_CFS, |
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index b33b45dfceec..983d087aa92a 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -163,8 +163,10 @@ config SND_SOC_WM_HUBS | |||
163 | config SND_SOC_WM_ADSP | 163 | config SND_SOC_WM_ADSP |
164 | tristate | 164 | tristate |
165 | default y if SND_SOC_WM5102=y | 165 | default y if SND_SOC_WM5102=y |
166 | default y if SND_SOC_WM5110=y | ||
166 | default y if SND_SOC_WM2200=y | 167 | default y if SND_SOC_WM2200=y |
167 | default m if SND_SOC_WM5102=m | 168 | default m if SND_SOC_WM5102=m |
169 | default m if SND_SOC_WM5110=m | ||
168 | default m if SND_SOC_WM2200=m | 170 | default m if SND_SOC_WM2200=m |
169 | 171 | ||
170 | config SND_SOC_AB8500_CODEC | 172 | config SND_SOC_AB8500_CODEC |
diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c index 9a92b7962f41..d7c983862cf0 100644 --- a/sound/soc/codecs/ad1836.c +++ b/sound/soc/codecs/ad1836.c | |||
@@ -179,6 +179,8 @@ static int ad1836_hw_params(struct snd_pcm_substream *substream, | |||
179 | case SNDRV_PCM_FORMAT_S32_LE: | 179 | case SNDRV_PCM_FORMAT_S32_LE: |
180 | word_len = AD1836_WORD_LEN_24; | 180 | word_len = AD1836_WORD_LEN_24; |
181 | break; | 181 | break; |
182 | default: | ||
183 | return -EINVAL; | ||
182 | } | 184 | } |
183 | 185 | ||
184 | regmap_update_bits(ad1836->regmap, AD1836_DAC_CTRL1, | 186 | regmap_update_bits(ad1836->regmap, AD1836_DAC_CTRL1, |
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index aea7e52cf714..12c27eb363dd 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c | |||
@@ -413,7 +413,7 @@ static struct spi_driver ad193x_spi_driver = { | |||
413 | }; | 413 | }; |
414 | #endif | 414 | #endif |
415 | 415 | ||
416 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 416 | #if IS_ENABLED(CONFIG_I2C) |
417 | 417 | ||
418 | static const struct regmap_config ad193x_i2c_regmap_config = { | 418 | static const struct regmap_config ad193x_i2c_regmap_config = { |
419 | .val_bits = 8, | 419 | .val_bits = 8, |
@@ -470,7 +470,7 @@ static int __init ad193x_modinit(void) | |||
470 | { | 470 | { |
471 | int ret; | 471 | int ret; |
472 | 472 | ||
473 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 473 | #if IS_ENABLED(CONFIG_I2C) |
474 | ret = i2c_add_driver(&ad193x_i2c_driver); | 474 | ret = i2c_add_driver(&ad193x_i2c_driver); |
475 | if (ret != 0) { | 475 | if (ret != 0) { |
476 | printk(KERN_ERR "Failed to register AD193X I2C driver: %d\n", | 476 | printk(KERN_ERR "Failed to register AD193X I2C driver: %d\n", |
@@ -495,7 +495,7 @@ static void __exit ad193x_modexit(void) | |||
495 | spi_unregister_driver(&ad193x_spi_driver); | 495 | spi_unregister_driver(&ad193x_spi_driver); |
496 | #endif | 496 | #endif |
497 | 497 | ||
498 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 498 | #if IS_ENABLED(CONFIG_I2C) |
499 | i2c_del_driver(&ad193x_i2c_driver); | 499 | i2c_del_driver(&ad193x_i2c_driver); |
500 | #endif | 500 | #endif |
501 | } | 501 | } |
diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c index 14a7c169d004..f7bf45552749 100644 --- a/sound/soc/codecs/adav80x.c +++ b/sound/soc/codecs/adav80x.c | |||
@@ -939,7 +939,7 @@ static struct spi_driver adav80x_spi_driver = { | |||
939 | }; | 939 | }; |
940 | #endif | 940 | #endif |
941 | 941 | ||
942 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 942 | #if IS_ENABLED(CONFIG_I2C) |
943 | static const struct regmap_config adav80x_i2c_regmap_config = { | 943 | static const struct regmap_config adav80x_i2c_regmap_config = { |
944 | .val_bits = 8, | 944 | .val_bits = 8, |
945 | .pad_bits = 1, | 945 | .pad_bits = 1, |
@@ -985,7 +985,7 @@ static int __init adav80x_init(void) | |||
985 | { | 985 | { |
986 | int ret = 0; | 986 | int ret = 0; |
987 | 987 | ||
988 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 988 | #if IS_ENABLED(CONFIG_I2C) |
989 | ret = i2c_add_driver(&adav80x_i2c_driver); | 989 | ret = i2c_add_driver(&adav80x_i2c_driver); |
990 | if (ret) | 990 | if (ret) |
991 | return ret; | 991 | return ret; |
@@ -1001,7 +1001,7 @@ module_init(adav80x_init); | |||
1001 | 1001 | ||
1002 | static void __exit adav80x_exit(void) | 1002 | static void __exit adav80x_exit(void) |
1003 | { | 1003 | { |
1004 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1004 | #if IS_ENABLED(CONFIG_I2C) |
1005 | i2c_del_driver(&adav80x_i2c_driver); | 1005 | i2c_del_driver(&adav80x_i2c_driver); |
1006 | #endif | 1006 | #endif |
1007 | #if defined(CONFIG_SPI_MASTER) | 1007 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c index 49cc5f6d6dba..94cbe508dd37 100644 --- a/sound/soc/codecs/ak4641.c +++ b/sound/soc/codecs/ak4641.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/gpio.h> | 17 | #include <linux/gpio.h> |
18 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
19 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
20 | #include <linux/regmap.h> | ||
20 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
21 | #include <sound/core.h> | 22 | #include <sound/core.h> |
22 | #include <sound/pcm.h> | 23 | #include <sound/pcm.h> |
@@ -30,6 +31,7 @@ | |||
30 | 31 | ||
31 | /* codec private data */ | 32 | /* codec private data */ |
32 | struct ak4641_priv { | 33 | struct ak4641_priv { |
34 | struct regmap *regmap; | ||
33 | unsigned int sysclk; | 35 | unsigned int sysclk; |
34 | int deemph; | 36 | int deemph; |
35 | int playback_fs; | 37 | int playback_fs; |
@@ -38,12 +40,12 @@ struct ak4641_priv { | |||
38 | /* | 40 | /* |
39 | * ak4641 register cache | 41 | * ak4641 register cache |
40 | */ | 42 | */ |
41 | static const u8 ak4641_reg[AK4641_CACHEREGNUM] = { | 43 | static const struct reg_default ak4641_reg_defaults[] = { |
42 | 0x00, 0x80, 0x00, 0x80, | 44 | { 0, 0x00 }, { 1, 0x80 }, { 2, 0x00 }, { 3, 0x80 }, |
43 | 0x02, 0x00, 0x11, 0x05, | 45 | { 4, 0x02 }, { 5, 0x00 }, { 6, 0x11 }, { 7, 0x05 }, |
44 | 0x00, 0x00, 0x36, 0x10, | 46 | { 8, 0x00 }, { 9, 0x00 }, { 10, 0x36 }, { 11, 0x10 }, |
45 | 0x00, 0x00, 0x57, 0x00, | 47 | { 12, 0x00 }, { 13, 0x00 }, { 14, 0x57 }, { 15, 0x00 }, |
46 | 0x88, 0x88, 0x08, 0x08 | 48 | { 16, 0x88 }, { 17, 0x88 }, { 18, 0x08 }, { 19, 0x08 } |
47 | }; | 49 | }; |
48 | 50 | ||
49 | static const int deemph_settings[] = {44100, 0, 48000, 32000}; | 51 | static const int deemph_settings[] = {44100, 0, 48000, 32000}; |
@@ -396,6 +398,7 @@ static int ak4641_mute(struct snd_soc_dai *dai, int mute) | |||
396 | static int ak4641_set_bias_level(struct snd_soc_codec *codec, | 398 | static int ak4641_set_bias_level(struct snd_soc_codec *codec, |
397 | enum snd_soc_bias_level level) | 399 | enum snd_soc_bias_level level) |
398 | { | 400 | { |
401 | struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); | ||
399 | struct ak4641_platform_data *pdata = codec->dev->platform_data; | 402 | struct ak4641_platform_data *pdata = codec->dev->platform_data; |
400 | int ret; | 403 | int ret; |
401 | 404 | ||
@@ -417,7 +420,7 @@ static int ak4641_set_bias_level(struct snd_soc_codec *codec, | |||
417 | gpio_set_value(pdata->gpio_npdn, 1); | 420 | gpio_set_value(pdata->gpio_npdn, 1); |
418 | mdelay(1); | 421 | mdelay(1); |
419 | 422 | ||
420 | ret = snd_soc_cache_sync(codec); | 423 | ret = regcache_sync(ak4641->regmap); |
421 | if (ret) { | 424 | if (ret) { |
422 | dev_err(codec->dev, | 425 | dev_err(codec->dev, |
423 | "Failed to sync cache: %d\n", ret); | 426 | "Failed to sync cache: %d\n", ret); |
@@ -433,7 +436,7 @@ static int ak4641_set_bias_level(struct snd_soc_codec *codec, | |||
433 | gpio_set_value(pdata->gpio_npdn, 0); | 436 | gpio_set_value(pdata->gpio_npdn, 0); |
434 | if (pdata && gpio_is_valid(pdata->gpio_power)) | 437 | if (pdata && gpio_is_valid(pdata->gpio_power)) |
435 | gpio_set_value(pdata->gpio_power, 0); | 438 | gpio_set_value(pdata->gpio_power, 0); |
436 | codec->cache_sync = 1; | 439 | regcache_mark_dirty(ak4641->regmap); |
437 | break; | 440 | break; |
438 | } | 441 | } |
439 | codec->dapm.bias_level = level; | 442 | codec->dapm.bias_level = level; |
@@ -518,7 +521,7 @@ static int ak4641_probe(struct snd_soc_codec *codec) | |||
518 | { | 521 | { |
519 | int ret; | 522 | int ret; |
520 | 523 | ||
521 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); | 524 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); |
522 | if (ret != 0) { | 525 | if (ret != 0) { |
523 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 526 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
524 | return ret; | 527 | return ret; |
@@ -550,12 +553,17 @@ static struct snd_soc_codec_driver soc_codec_dev_ak4641 = { | |||
550 | .dapm_routes = ak4641_audio_map, | 553 | .dapm_routes = ak4641_audio_map, |
551 | .num_dapm_routes = ARRAY_SIZE(ak4641_audio_map), | 554 | .num_dapm_routes = ARRAY_SIZE(ak4641_audio_map), |
552 | .set_bias_level = ak4641_set_bias_level, | 555 | .set_bias_level = ak4641_set_bias_level, |
553 | .reg_cache_size = ARRAY_SIZE(ak4641_reg), | ||
554 | .reg_word_size = sizeof(u8), | ||
555 | .reg_cache_default = ak4641_reg, | ||
556 | .reg_cache_step = 1, | ||
557 | }; | 556 | }; |
558 | 557 | ||
558 | static const struct regmap_config ak4641_regmap = { | ||
559 | .reg_bits = 8, | ||
560 | .val_bits = 8, | ||
561 | |||
562 | .max_register = AK4641_BTIF, | ||
563 | .reg_defaults = ak4641_reg_defaults, | ||
564 | .num_reg_defaults = ARRAY_SIZE(ak4641_reg_defaults), | ||
565 | .cache_type = REGCACHE_RBTREE, | ||
566 | }; | ||
559 | 567 | ||
560 | static int ak4641_i2c_probe(struct i2c_client *i2c, | 568 | static int ak4641_i2c_probe(struct i2c_client *i2c, |
561 | const struct i2c_device_id *id) | 569 | const struct i2c_device_id *id) |
@@ -569,6 +577,10 @@ static int ak4641_i2c_probe(struct i2c_client *i2c, | |||
569 | if (!ak4641) | 577 | if (!ak4641) |
570 | return -ENOMEM; | 578 | return -ENOMEM; |
571 | 579 | ||
580 | ak4641->regmap = devm_regmap_init_i2c(i2c, &ak4641_regmap); | ||
581 | if (IS_ERR(ak4641->regmap)) | ||
582 | return PTR_ERR(ak4641->regmap); | ||
583 | |||
572 | if (pdata) { | 584 | if (pdata) { |
573 | if (gpio_is_valid(pdata->gpio_power)) { | 585 | if (gpio_is_valid(pdata->gpio_power)) { |
574 | ret = gpio_request_one(pdata->gpio_power, | 586 | ret = gpio_request_one(pdata->gpio_power, |
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 090d499bb7eb..1f646c6e90c6 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/of_device.h> | 29 | #include <linux/of_device.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/regmap.h> | ||
31 | #include <sound/soc.h> | 32 | #include <sound/soc.h> |
32 | #include <sound/initval.h> | 33 | #include <sound/initval.h> |
33 | #include <sound/tlv.h> | 34 | #include <sound/tlv.h> |
@@ -198,30 +199,30 @@ static const struct snd_soc_dapm_route ak4642_intercon[] = { | |||
198 | /* | 199 | /* |
199 | * ak4642 register cache | 200 | * ak4642 register cache |
200 | */ | 201 | */ |
201 | static const u8 ak4642_reg[] = { | 202 | static const struct reg_default ak4642_reg[] = { |
202 | 0x00, 0x00, 0x01, 0x00, | 203 | { 0, 0x00 }, { 1, 0x00 }, { 2, 0x01 }, { 3, 0x00 }, |
203 | 0x02, 0x00, 0x00, 0x00, | 204 | { 4, 0x02 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x00 }, |
204 | 0xe1, 0xe1, 0x18, 0x00, | 205 | { 8, 0xe1 }, { 9, 0xe1 }, { 10, 0x18 }, { 11, 0x00 }, |
205 | 0xe1, 0x18, 0x11, 0x08, | 206 | { 12, 0xe1 }, { 13, 0x18 }, { 14, 0x11 }, { 15, 0x08 }, |
206 | 0x00, 0x00, 0x00, 0x00, | 207 | { 16, 0x00 }, { 17, 0x00 }, { 18, 0x00 }, { 19, 0x00 }, |
207 | 0x00, 0x00, 0x00, 0x00, | 208 | { 20, 0x00 }, { 21, 0x00 }, { 22, 0x00 }, { 23, 0x00 }, |
208 | 0x00, 0x00, 0x00, 0x00, | 209 | { 24, 0x00 }, { 25, 0x00 }, { 26, 0x00 }, { 27, 0x00 }, |
209 | 0x00, 0x00, 0x00, 0x00, | 210 | { 28, 0x00 }, { 29, 0x00 }, { 30, 0x00 }, { 31, 0x00 }, |
210 | 0x00, 0x00, 0x00, 0x00, | 211 | { 32, 0x00 }, { 33, 0x00 }, { 34, 0x00 }, { 35, 0x00 }, |
211 | 0x00, | 212 | { 36, 0x00 }, |
212 | }; | 213 | }; |
213 | 214 | ||
214 | static const u8 ak4648_reg[] = { | 215 | static const struct reg_default ak4648_reg[] = { |
215 | 0x00, 0x00, 0x01, 0x00, | 216 | { 0, 0x00 }, { 1, 0x00 }, { 2, 0x01 }, { 3, 0x00 }, |
216 | 0x02, 0x00, 0x00, 0x00, | 217 | { 4, 0x02 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x00 }, |
217 | 0xe1, 0xe1, 0x18, 0x00, | 218 | { 8, 0xe1 }, { 9, 0xe1 }, { 10, 0x18 }, { 11, 0x00 }, |
218 | 0xe1, 0x18, 0x11, 0xb8, | 219 | { 12, 0xe1 }, { 13, 0x18 }, { 14, 0x11 }, { 15, 0xb8 }, |
219 | 0x00, 0x00, 0x00, 0x00, | 220 | { 16, 0x00 }, { 17, 0x00 }, { 18, 0x00 }, { 19, 0x00 }, |
220 | 0x00, 0x00, 0x00, 0x00, | 221 | { 20, 0x00 }, { 21, 0x00 }, { 22, 0x00 }, { 23, 0x00 }, |
221 | 0x00, 0x00, 0x00, 0x00, | 222 | { 24, 0x00 }, { 25, 0x00 }, { 26, 0x00 }, { 27, 0x00 }, |
222 | 0x00, 0x00, 0x00, 0x00, | 223 | { 28, 0x00 }, { 29, 0x00 }, { 30, 0x00 }, { 31, 0x00 }, |
223 | 0x00, 0x00, 0x00, 0x00, | 224 | { 32, 0x00 }, { 33, 0x00 }, { 34, 0x00 }, { 35, 0x00 }, |
224 | 0x00, 0x88, 0x88, 0x08, | 225 | { 36, 0x00 }, { 37, 0x88 }, { 38, 0x88 }, { 39, 0x08 }, |
225 | }; | 226 | }; |
226 | 227 | ||
227 | static int ak4642_dai_startup(struct snd_pcm_substream *substream, | 228 | static int ak4642_dai_startup(struct snd_pcm_substream *substream, |
@@ -454,7 +455,10 @@ static struct snd_soc_dai_driver ak4642_dai = { | |||
454 | 455 | ||
455 | static int ak4642_resume(struct snd_soc_codec *codec) | 456 | static int ak4642_resume(struct snd_soc_codec *codec) |
456 | { | 457 | { |
457 | snd_soc_cache_sync(codec); | 458 | struct regmap *regmap = dev_get_regmap(codec->dev, NULL); |
459 | |||
460 | regcache_mark_dirty(regmap); | ||
461 | regcache_sync(regmap); | ||
458 | return 0; | 462 | return 0; |
459 | } | 463 | } |
460 | 464 | ||
@@ -463,15 +467,12 @@ static int ak4642_probe(struct snd_soc_codec *codec) | |||
463 | { | 467 | { |
464 | int ret; | 468 | int ret; |
465 | 469 | ||
466 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); | 470 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); |
467 | if (ret < 0) { | 471 | if (ret < 0) { |
468 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 472 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
469 | return ret; | 473 | return ret; |
470 | } | 474 | } |
471 | 475 | ||
472 | snd_soc_add_codec_controls(codec, ak4642_snd_controls, | ||
473 | ARRAY_SIZE(ak4642_snd_controls)); | ||
474 | |||
475 | ak4642_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 476 | ak4642_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
476 | 477 | ||
477 | return 0; | 478 | return 0; |
@@ -488,55 +489,59 @@ static struct snd_soc_codec_driver soc_codec_dev_ak4642 = { | |||
488 | .remove = ak4642_remove, | 489 | .remove = ak4642_remove, |
489 | .resume = ak4642_resume, | 490 | .resume = ak4642_resume, |
490 | .set_bias_level = ak4642_set_bias_level, | 491 | .set_bias_level = ak4642_set_bias_level, |
491 | .reg_cache_default = ak4642_reg, /* ak4642 reg */ | 492 | .controls = ak4642_snd_controls, |
492 | .reg_cache_size = ARRAY_SIZE(ak4642_reg), /* ak4642 reg */ | 493 | .num_controls = ARRAY_SIZE(ak4642_snd_controls), |
493 | .reg_word_size = sizeof(u8), | ||
494 | .dapm_widgets = ak4642_dapm_widgets, | 494 | .dapm_widgets = ak4642_dapm_widgets, |
495 | .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), | 495 | .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), |
496 | .dapm_routes = ak4642_intercon, | 496 | .dapm_routes = ak4642_intercon, |
497 | .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), | 497 | .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), |
498 | }; | 498 | }; |
499 | 499 | ||
500 | static struct snd_soc_codec_driver soc_codec_dev_ak4648 = { | 500 | static const struct regmap_config ak4642_regmap = { |
501 | .probe = ak4642_probe, | 501 | .reg_bits = 8, |
502 | .remove = ak4642_remove, | 502 | .val_bits = 8, |
503 | .resume = ak4642_resume, | 503 | .max_register = ARRAY_SIZE(ak4642_reg) + 1, |
504 | .set_bias_level = ak4642_set_bias_level, | 504 | .reg_defaults = ak4642_reg, |
505 | .reg_cache_default = ak4648_reg, /* ak4648 reg */ | 505 | .num_reg_defaults = ARRAY_SIZE(ak4642_reg), |
506 | .reg_cache_size = ARRAY_SIZE(ak4648_reg), /* ak4648 reg */ | 506 | }; |
507 | .reg_word_size = sizeof(u8), | 507 | |
508 | .dapm_widgets = ak4642_dapm_widgets, | 508 | static const struct regmap_config ak4648_regmap = { |
509 | .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), | 509 | .reg_bits = 8, |
510 | .dapm_routes = ak4642_intercon, | 510 | .val_bits = 8, |
511 | .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), | 511 | .max_register = ARRAY_SIZE(ak4648_reg) + 1, |
512 | .reg_defaults = ak4648_reg, | ||
513 | .num_reg_defaults = ARRAY_SIZE(ak4648_reg), | ||
512 | }; | 514 | }; |
513 | 515 | ||
514 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
515 | static struct of_device_id ak4642_of_match[]; | 516 | static struct of_device_id ak4642_of_match[]; |
516 | static int ak4642_i2c_probe(struct i2c_client *i2c, | 517 | static int ak4642_i2c_probe(struct i2c_client *i2c, |
517 | const struct i2c_device_id *id) | 518 | const struct i2c_device_id *id) |
518 | { | 519 | { |
519 | struct device_node *np = i2c->dev.of_node; | 520 | struct device_node *np = i2c->dev.of_node; |
520 | const struct snd_soc_codec_driver *driver; | 521 | const struct regmap_config *regmap_config = NULL; |
522 | struct regmap *regmap; | ||
521 | 523 | ||
522 | driver = NULL; | ||
523 | if (np) { | 524 | if (np) { |
524 | const struct of_device_id *of_id; | 525 | const struct of_device_id *of_id; |
525 | 526 | ||
526 | of_id = of_match_device(ak4642_of_match, &i2c->dev); | 527 | of_id = of_match_device(ak4642_of_match, &i2c->dev); |
527 | if (of_id) | 528 | if (of_id) |
528 | driver = of_id->data; | 529 | regmap_config = of_id->data; |
529 | } else { | 530 | } else { |
530 | driver = (struct snd_soc_codec_driver *)id->driver_data; | 531 | regmap_config = (const struct regmap_config *)id->driver_data; |
531 | } | 532 | } |
532 | 533 | ||
533 | if (!driver) { | 534 | if (!regmap_config) { |
534 | dev_err(&i2c->dev, "no driver\n"); | 535 | dev_err(&i2c->dev, "Unknown device type\n"); |
535 | return -EINVAL; | 536 | return -EINVAL; |
536 | } | 537 | } |
537 | 538 | ||
539 | regmap = devm_regmap_init_i2c(i2c, regmap_config); | ||
540 | if (IS_ERR(regmap)) | ||
541 | return PTR_ERR(regmap); | ||
542 | |||
538 | return snd_soc_register_codec(&i2c->dev, | 543 | return snd_soc_register_codec(&i2c->dev, |
539 | driver, &ak4642_dai, 1); | 544 | &soc_codec_dev_ak4642, &ak4642_dai, 1); |
540 | } | 545 | } |
541 | 546 | ||
542 | static int ak4642_i2c_remove(struct i2c_client *client) | 547 | static int ak4642_i2c_remove(struct i2c_client *client) |
@@ -546,17 +551,17 @@ static int ak4642_i2c_remove(struct i2c_client *client) | |||
546 | } | 551 | } |
547 | 552 | ||
548 | static struct of_device_id ak4642_of_match[] = { | 553 | static struct of_device_id ak4642_of_match[] = { |
549 | { .compatible = "asahi-kasei,ak4642", .data = &soc_codec_dev_ak4642}, | 554 | { .compatible = "asahi-kasei,ak4642", .data = &ak4642_regmap}, |
550 | { .compatible = "asahi-kasei,ak4643", .data = &soc_codec_dev_ak4642}, | 555 | { .compatible = "asahi-kasei,ak4643", .data = &ak4642_regmap}, |
551 | { .compatible = "asahi-kasei,ak4648", .data = &soc_codec_dev_ak4648}, | 556 | { .compatible = "asahi-kasei,ak4648", .data = &ak4648_regmap}, |
552 | {}, | 557 | {}, |
553 | }; | 558 | }; |
554 | MODULE_DEVICE_TABLE(of, ak4642_of_match); | 559 | MODULE_DEVICE_TABLE(of, ak4642_of_match); |
555 | 560 | ||
556 | static const struct i2c_device_id ak4642_i2c_id[] = { | 561 | static const struct i2c_device_id ak4642_i2c_id[] = { |
557 | { "ak4642", (kernel_ulong_t)&soc_codec_dev_ak4642 }, | 562 | { "ak4642", (kernel_ulong_t)&ak4642_regmap }, |
558 | { "ak4643", (kernel_ulong_t)&soc_codec_dev_ak4642 }, | 563 | { "ak4643", (kernel_ulong_t)&ak4642_regmap }, |
559 | { "ak4648", (kernel_ulong_t)&soc_codec_dev_ak4648 }, | 564 | { "ak4648", (kernel_ulong_t)&ak4648_regmap }, |
560 | { } | 565 | { } |
561 | }; | 566 | }; |
562 | MODULE_DEVICE_TABLE(i2c, ak4642_i2c_id); | 567 | MODULE_DEVICE_TABLE(i2c, ak4642_i2c_id); |
@@ -571,27 +576,8 @@ static struct i2c_driver ak4642_i2c_driver = { | |||
571 | .remove = ak4642_i2c_remove, | 576 | .remove = ak4642_i2c_remove, |
572 | .id_table = ak4642_i2c_id, | 577 | .id_table = ak4642_i2c_id, |
573 | }; | 578 | }; |
574 | #endif | ||
575 | |||
576 | static int __init ak4642_modinit(void) | ||
577 | { | ||
578 | int ret = 0; | ||
579 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
580 | ret = i2c_add_driver(&ak4642_i2c_driver); | ||
581 | #endif | ||
582 | return ret; | ||
583 | 579 | ||
584 | } | 580 | module_i2c_driver(ak4642_i2c_driver); |
585 | module_init(ak4642_modinit); | ||
586 | |||
587 | static void __exit ak4642_exit(void) | ||
588 | { | ||
589 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
590 | i2c_del_driver(&ak4642_i2c_driver); | ||
591 | #endif | ||
592 | |||
593 | } | ||
594 | module_exit(ak4642_exit); | ||
595 | 581 | ||
596 | MODULE_DESCRIPTION("Soc AK4642 driver"); | 582 | MODULE_DESCRIPTION("Soc AK4642 driver"); |
597 | MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>"); | 583 | MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>"); |
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index fea991031be1..e4295fee8f13 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c | |||
@@ -93,7 +93,7 @@ static int arizona_spk_ev(struct snd_soc_dapm_widget *w, | |||
93 | switch (event) { | 93 | switch (event) { |
94 | case SND_SOC_DAPM_PRE_PMU: | 94 | case SND_SOC_DAPM_PRE_PMU: |
95 | if (!priv->spk_ena && manual_ena) { | 95 | if (!priv->spk_ena && manual_ena) { |
96 | snd_soc_write(codec, 0x4f5, 0x25a); | 96 | regmap_write_async(arizona->regmap, 0x4f5, 0x25a); |
97 | priv->spk_ena_pending = true; | 97 | priv->spk_ena_pending = true; |
98 | } | 98 | } |
99 | break; | 99 | break; |
@@ -105,12 +105,13 @@ static int arizona_spk_ev(struct snd_soc_dapm_widget *w, | |||
105 | return -EBUSY; | 105 | return -EBUSY; |
106 | } | 106 | } |
107 | 107 | ||
108 | snd_soc_update_bits(codec, ARIZONA_OUTPUT_ENABLES_1, | 108 | regmap_update_bits_async(arizona->regmap, |
109 | 1 << w->shift, 1 << w->shift); | 109 | ARIZONA_OUTPUT_ENABLES_1, |
110 | 1 << w->shift, 1 << w->shift); | ||
110 | 111 | ||
111 | if (priv->spk_ena_pending) { | 112 | if (priv->spk_ena_pending) { |
112 | msleep(75); | 113 | msleep(75); |
113 | snd_soc_write(codec, 0x4f5, 0xda); | 114 | regmap_write_async(arizona->regmap, 0x4f5, 0xda); |
114 | priv->spk_ena_pending = false; | 115 | priv->spk_ena_pending = false; |
115 | priv->spk_ena++; | 116 | priv->spk_ena++; |
116 | } | 117 | } |
@@ -119,16 +120,19 @@ static int arizona_spk_ev(struct snd_soc_dapm_widget *w, | |||
119 | if (manual_ena) { | 120 | if (manual_ena) { |
120 | priv->spk_ena--; | 121 | priv->spk_ena--; |
121 | if (!priv->spk_ena) | 122 | if (!priv->spk_ena) |
122 | snd_soc_write(codec, 0x4f5, 0x25a); | 123 | regmap_write_async(arizona->regmap, |
124 | 0x4f5, 0x25a); | ||
123 | } | 125 | } |
124 | 126 | ||
125 | snd_soc_update_bits(codec, ARIZONA_OUTPUT_ENABLES_1, | 127 | regmap_update_bits_async(arizona->regmap, |
126 | 1 << w->shift, 0); | 128 | ARIZONA_OUTPUT_ENABLES_1, |
129 | 1 << w->shift, 0); | ||
127 | break; | 130 | break; |
128 | case SND_SOC_DAPM_POST_PMD: | 131 | case SND_SOC_DAPM_POST_PMD: |
129 | if (manual_ena) { | 132 | if (manual_ena) { |
130 | if (!priv->spk_ena) | 133 | if (!priv->spk_ena) |
131 | snd_soc_write(codec, 0x4f5, 0x0da); | 134 | regmap_write_async(arizona->regmap, |
135 | 0x4f5, 0x0da); | ||
132 | } | 136 | } |
133 | break; | 137 | break; |
134 | } | 138 | } |
@@ -292,6 +296,10 @@ const char *arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS] = { | |||
292 | "AIF1RX8", | 296 | "AIF1RX8", |
293 | "AIF2RX1", | 297 | "AIF2RX1", |
294 | "AIF2RX2", | 298 | "AIF2RX2", |
299 | "AIF2RX3", | ||
300 | "AIF2RX4", | ||
301 | "AIF2RX5", | ||
302 | "AIF2RX6", | ||
295 | "AIF3RX1", | 303 | "AIF3RX1", |
296 | "AIF3RX2", | 304 | "AIF3RX2", |
297 | "SLIMRX1", | 305 | "SLIMRX1", |
@@ -395,6 +403,10 @@ int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS] = { | |||
395 | 0x27, | 403 | 0x27, |
396 | 0x28, /* AIF2RX1 */ | 404 | 0x28, /* AIF2RX1 */ |
397 | 0x29, | 405 | 0x29, |
406 | 0x2a, | ||
407 | 0x2b, | ||
408 | 0x2c, | ||
409 | 0x2d, | ||
398 | 0x30, /* AIF3RX1 */ | 410 | 0x30, /* AIF3RX1 */ |
399 | 0x31, | 411 | 0x31, |
400 | 0x38, /* SLIMRX1 */ | 412 | 0x38, /* SLIMRX1 */ |
@@ -486,6 +498,22 @@ const int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE] = { | |||
486 | EXPORT_SYMBOL_GPL(arizona_rate_val); | 498 | EXPORT_SYMBOL_GPL(arizona_rate_val); |
487 | 499 | ||
488 | 500 | ||
501 | const struct soc_enum arizona_isrc_fsh[] = { | ||
502 | SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_1_CTRL_1, | ||
503 | ARIZONA_ISRC1_FSH_SHIFT, 0xf, | ||
504 | ARIZONA_RATE_ENUM_SIZE, | ||
505 | arizona_rate_text, arizona_rate_val), | ||
506 | SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_2_CTRL_1, | ||
507 | ARIZONA_ISRC2_FSH_SHIFT, 0xf, | ||
508 | ARIZONA_RATE_ENUM_SIZE, | ||
509 | arizona_rate_text, arizona_rate_val), | ||
510 | SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_3_CTRL_1, | ||
511 | ARIZONA_ISRC3_FSH_SHIFT, 0xf, | ||
512 | ARIZONA_RATE_ENUM_SIZE, | ||
513 | arizona_rate_text, arizona_rate_val), | ||
514 | }; | ||
515 | EXPORT_SYMBOL_GPL(arizona_isrc_fsh); | ||
516 | |||
489 | const struct soc_enum arizona_isrc_fsl[] = { | 517 | const struct soc_enum arizona_isrc_fsl[] = { |
490 | SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_1_CTRL_2, | 518 | SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_1_CTRL_2, |
491 | ARIZONA_ISRC1_FSL_SHIFT, 0xf, | 519 | ARIZONA_ISRC1_FSL_SHIFT, 0xf, |
@@ -502,6 +530,13 @@ const struct soc_enum arizona_isrc_fsl[] = { | |||
502 | }; | 530 | }; |
503 | EXPORT_SYMBOL_GPL(arizona_isrc_fsl); | 531 | EXPORT_SYMBOL_GPL(arizona_isrc_fsl); |
504 | 532 | ||
533 | const struct soc_enum arizona_asrc_rate1 = | ||
534 | SOC_VALUE_ENUM_SINGLE(ARIZONA_ASRC_RATE1, | ||
535 | ARIZONA_ASRC_RATE1_SHIFT, 0xf, | ||
536 | ARIZONA_RATE_ENUM_SIZE - 1, | ||
537 | arizona_rate_text, arizona_rate_val); | ||
538 | EXPORT_SYMBOL_GPL(arizona_asrc_rate1); | ||
539 | |||
505 | static const char *arizona_vol_ramp_text[] = { | 540 | static const char *arizona_vol_ramp_text[] = { |
506 | "0ms/6dB", "0.5ms/6dB", "1ms/6dB", "2ms/6dB", "4ms/6dB", "8ms/6dB", | 541 | "0ms/6dB", "0.5ms/6dB", "1ms/6dB", "2ms/6dB", "4ms/6dB", "8ms/6dB", |
507 | "15ms/6dB", "30ms/6dB", | 542 | "15ms/6dB", "30ms/6dB", |
@@ -560,6 +595,16 @@ const struct soc_enum arizona_ng_hold = | |||
560 | 4, arizona_ng_hold_text); | 595 | 4, arizona_ng_hold_text); |
561 | EXPORT_SYMBOL_GPL(arizona_ng_hold); | 596 | EXPORT_SYMBOL_GPL(arizona_ng_hold); |
562 | 597 | ||
598 | static const char * const arizona_in_hpf_cut_text[] = { | ||
599 | "2.5Hz", "5Hz", "10Hz", "20Hz", "40Hz" | ||
600 | }; | ||
601 | |||
602 | const struct soc_enum arizona_in_hpf_cut_enum = | ||
603 | SOC_ENUM_SINGLE(ARIZONA_HPF_CONTROL, ARIZONA_IN_HPF_CUT_SHIFT, | ||
604 | ARRAY_SIZE(arizona_in_hpf_cut_text), | ||
605 | arizona_in_hpf_cut_text); | ||
606 | EXPORT_SYMBOL_GPL(arizona_in_hpf_cut_enum); | ||
607 | |||
563 | static const char * const arizona_in_dmic_osr_text[] = { | 608 | static const char * const arizona_in_dmic_osr_text[] = { |
564 | "1.536MHz", "3.072MHz", "6.144MHz", | 609 | "1.536MHz", "3.072MHz", "6.144MHz", |
565 | }; | 610 | }; |
@@ -669,6 +714,7 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w, | |||
669 | int event) | 714 | int event) |
670 | { | 715 | { |
671 | struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); | 716 | struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); |
717 | struct arizona *arizona = priv->arizona; | ||
672 | unsigned int mask = 1 << w->shift; | 718 | unsigned int mask = 1 << w->shift; |
673 | unsigned int val; | 719 | unsigned int val; |
674 | 720 | ||
@@ -691,7 +737,8 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w, | |||
691 | if (priv->arizona->hpdet_magic) | 737 | if (priv->arizona->hpdet_magic) |
692 | val = 0; | 738 | val = 0; |
693 | 739 | ||
694 | snd_soc_update_bits(w->codec, ARIZONA_OUTPUT_ENABLES_1, mask, val); | 740 | regmap_update_bits_async(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1, |
741 | mask, val); | ||
695 | 742 | ||
696 | return arizona_out_ev(w, kcontrol, event); | 743 | return arizona_out_ev(w, kcontrol, event); |
697 | } | 744 | } |
@@ -846,6 +893,8 @@ EXPORT_SYMBOL_GPL(arizona_set_sysclk); | |||
846 | static int arizona_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | 893 | static int arizona_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
847 | { | 894 | { |
848 | struct snd_soc_codec *codec = dai->codec; | 895 | struct snd_soc_codec *codec = dai->codec; |
896 | struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
897 | struct arizona *arizona = priv->arizona; | ||
849 | int lrclk, bclk, mode, base; | 898 | int lrclk, bclk, mode, base; |
850 | 899 | ||
851 | base = dai->driver->base; | 900 | base = dai->driver->base; |
@@ -902,17 +951,19 @@ static int arizona_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
902 | return -EINVAL; | 951 | return -EINVAL; |
903 | } | 952 | } |
904 | 953 | ||
905 | snd_soc_update_bits(codec, base + ARIZONA_AIF_BCLK_CTRL, | 954 | regmap_update_bits_async(arizona->regmap, base + ARIZONA_AIF_BCLK_CTRL, |
906 | ARIZONA_AIF1_BCLK_INV | ARIZONA_AIF1_BCLK_MSTR, | 955 | ARIZONA_AIF1_BCLK_INV | |
907 | bclk); | 956 | ARIZONA_AIF1_BCLK_MSTR, |
908 | snd_soc_update_bits(codec, base + ARIZONA_AIF_TX_PIN_CTRL, | 957 | bclk); |
909 | ARIZONA_AIF1TX_LRCLK_INV | | 958 | regmap_update_bits_async(arizona->regmap, base + ARIZONA_AIF_TX_PIN_CTRL, |
910 | ARIZONA_AIF1TX_LRCLK_MSTR, lrclk); | 959 | ARIZONA_AIF1TX_LRCLK_INV | |
911 | snd_soc_update_bits(codec, base + ARIZONA_AIF_RX_PIN_CTRL, | 960 | ARIZONA_AIF1TX_LRCLK_MSTR, lrclk); |
912 | ARIZONA_AIF1RX_LRCLK_INV | | 961 | regmap_update_bits_async(arizona->regmap, |
913 | ARIZONA_AIF1RX_LRCLK_MSTR, lrclk); | 962 | base + ARIZONA_AIF_RX_PIN_CTRL, |
914 | snd_soc_update_bits(codec, base + ARIZONA_AIF_FORMAT, | 963 | ARIZONA_AIF1RX_LRCLK_INV | |
915 | ARIZONA_AIF1_FMT_MASK, mode); | 964 | ARIZONA_AIF1RX_LRCLK_MSTR, lrclk); |
965 | regmap_update_bits(arizona->regmap, base + ARIZONA_AIF_FORMAT, | ||
966 | ARIZONA_AIF1_FMT_MASK, mode); | ||
916 | 967 | ||
917 | return 0; | 968 | return 0; |
918 | } | 969 | } |
@@ -1164,18 +1215,22 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, | |||
1164 | if (ret != 0) | 1215 | if (ret != 0) |
1165 | return ret; | 1216 | return ret; |
1166 | 1217 | ||
1167 | snd_soc_update_bits(codec, base + ARIZONA_AIF_BCLK_CTRL, | 1218 | regmap_update_bits_async(arizona->regmap, |
1168 | ARIZONA_AIF1_BCLK_FREQ_MASK, bclk); | 1219 | base + ARIZONA_AIF_BCLK_CTRL, |
1169 | snd_soc_update_bits(codec, base + ARIZONA_AIF_TX_BCLK_RATE, | 1220 | ARIZONA_AIF1_BCLK_FREQ_MASK, bclk); |
1170 | ARIZONA_AIF1TX_BCPF_MASK, lrclk); | 1221 | regmap_update_bits_async(arizona->regmap, |
1171 | snd_soc_update_bits(codec, base + ARIZONA_AIF_RX_BCLK_RATE, | 1222 | base + ARIZONA_AIF_TX_BCLK_RATE, |
1172 | ARIZONA_AIF1RX_BCPF_MASK, lrclk); | 1223 | ARIZONA_AIF1TX_BCPF_MASK, lrclk); |
1173 | snd_soc_update_bits(codec, base + ARIZONA_AIF_FRAME_CTRL_1, | 1224 | regmap_update_bits_async(arizona->regmap, |
1174 | ARIZONA_AIF1TX_WL_MASK | | 1225 | base + ARIZONA_AIF_RX_BCLK_RATE, |
1175 | ARIZONA_AIF1TX_SLOT_LEN_MASK, frame); | 1226 | ARIZONA_AIF1RX_BCPF_MASK, lrclk); |
1176 | snd_soc_update_bits(codec, base + ARIZONA_AIF_FRAME_CTRL_2, | 1227 | regmap_update_bits_async(arizona->regmap, |
1177 | ARIZONA_AIF1RX_WL_MASK | | 1228 | base + ARIZONA_AIF_FRAME_CTRL_1, |
1178 | ARIZONA_AIF1RX_SLOT_LEN_MASK, frame); | 1229 | ARIZONA_AIF1TX_WL_MASK | |
1230 | ARIZONA_AIF1TX_SLOT_LEN_MASK, frame); | ||
1231 | regmap_update_bits(arizona->regmap, base + ARIZONA_AIF_FRAME_CTRL_2, | ||
1232 | ARIZONA_AIF1RX_WL_MASK | | ||
1233 | ARIZONA_AIF1RX_SLOT_LEN_MASK, frame); | ||
1179 | 1234 | ||
1180 | return 0; | 1235 | return 0; |
1181 | } | 1236 | } |
@@ -1428,31 +1483,31 @@ static void arizona_apply_fll(struct arizona *arizona, unsigned int base, | |||
1428 | struct arizona_fll_cfg *cfg, int source, | 1483 | struct arizona_fll_cfg *cfg, int source, |
1429 | bool sync) | 1484 | bool sync) |
1430 | { | 1485 | { |
1431 | regmap_update_bits(arizona->regmap, base + 3, | 1486 | regmap_update_bits_async(arizona->regmap, base + 3, |
1432 | ARIZONA_FLL1_THETA_MASK, cfg->theta); | 1487 | ARIZONA_FLL1_THETA_MASK, cfg->theta); |
1433 | regmap_update_bits(arizona->regmap, base + 4, | 1488 | regmap_update_bits_async(arizona->regmap, base + 4, |
1434 | ARIZONA_FLL1_LAMBDA_MASK, cfg->lambda); | 1489 | ARIZONA_FLL1_LAMBDA_MASK, cfg->lambda); |
1435 | regmap_update_bits(arizona->regmap, base + 5, | 1490 | regmap_update_bits_async(arizona->regmap, base + 5, |
1436 | ARIZONA_FLL1_FRATIO_MASK, | 1491 | ARIZONA_FLL1_FRATIO_MASK, |
1437 | cfg->fratio << ARIZONA_FLL1_FRATIO_SHIFT); | 1492 | cfg->fratio << ARIZONA_FLL1_FRATIO_SHIFT); |
1438 | regmap_update_bits(arizona->regmap, base + 6, | 1493 | regmap_update_bits_async(arizona->regmap, base + 6, |
1439 | ARIZONA_FLL1_CLK_REF_DIV_MASK | | 1494 | ARIZONA_FLL1_CLK_REF_DIV_MASK | |
1440 | ARIZONA_FLL1_CLK_REF_SRC_MASK, | 1495 | ARIZONA_FLL1_CLK_REF_SRC_MASK, |
1441 | cfg->refdiv << ARIZONA_FLL1_CLK_REF_DIV_SHIFT | | 1496 | cfg->refdiv << ARIZONA_FLL1_CLK_REF_DIV_SHIFT | |
1442 | source << ARIZONA_FLL1_CLK_REF_SRC_SHIFT); | 1497 | source << ARIZONA_FLL1_CLK_REF_SRC_SHIFT); |
1443 | 1498 | ||
1444 | if (sync) | 1499 | if (sync) |
1445 | regmap_update_bits(arizona->regmap, base + 0x7, | 1500 | regmap_update_bits_async(arizona->regmap, base + 0x7, |
1446 | ARIZONA_FLL1_GAIN_MASK, | 1501 | ARIZONA_FLL1_GAIN_MASK, |
1447 | cfg->gain << ARIZONA_FLL1_GAIN_SHIFT); | 1502 | cfg->gain << ARIZONA_FLL1_GAIN_SHIFT); |
1448 | else | 1503 | else |
1449 | regmap_update_bits(arizona->regmap, base + 0x9, | 1504 | regmap_update_bits_async(arizona->regmap, base + 0x9, |
1450 | ARIZONA_FLL1_GAIN_MASK, | 1505 | ARIZONA_FLL1_GAIN_MASK, |
1451 | cfg->gain << ARIZONA_FLL1_GAIN_SHIFT); | 1506 | cfg->gain << ARIZONA_FLL1_GAIN_SHIFT); |
1452 | 1507 | ||
1453 | regmap_update_bits(arizona->regmap, base + 2, | 1508 | regmap_update_bits_async(arizona->regmap, base + 2, |
1454 | ARIZONA_FLL1_CTRL_UPD | ARIZONA_FLL1_N_MASK, | 1509 | ARIZONA_FLL1_CTRL_UPD | ARIZONA_FLL1_N_MASK, |
1455 | ARIZONA_FLL1_CTRL_UPD | cfg->n); | 1510 | ARIZONA_FLL1_CTRL_UPD | cfg->n); |
1456 | } | 1511 | } |
1457 | 1512 | ||
1458 | static bool arizona_is_enabled_fll(struct arizona_fll *fll) | 1513 | static bool arizona_is_enabled_fll(struct arizona_fll *fll) |
@@ -1485,9 +1540,9 @@ static void arizona_enable_fll(struct arizona_fll *fll, | |||
1485 | */ | 1540 | */ |
1486 | if (fll->ref_src >= 0 && fll->ref_freq && | 1541 | if (fll->ref_src >= 0 && fll->ref_freq && |
1487 | fll->ref_src != fll->sync_src) { | 1542 | fll->ref_src != fll->sync_src) { |
1488 | regmap_update_bits(arizona->regmap, fll->base + 5, | 1543 | regmap_update_bits_async(arizona->regmap, fll->base + 5, |
1489 | ARIZONA_FLL1_OUTDIV_MASK, | 1544 | ARIZONA_FLL1_OUTDIV_MASK, |
1490 | ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); | 1545 | ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); |
1491 | 1546 | ||
1492 | arizona_apply_fll(arizona, fll->base, ref, fll->ref_src, | 1547 | arizona_apply_fll(arizona, fll->base, ref, fll->ref_src, |
1493 | false); | 1548 | false); |
@@ -1497,15 +1552,15 @@ static void arizona_enable_fll(struct arizona_fll *fll, | |||
1497 | use_sync = true; | 1552 | use_sync = true; |
1498 | } | 1553 | } |
1499 | } else if (fll->sync_src >= 0) { | 1554 | } else if (fll->sync_src >= 0) { |
1500 | regmap_update_bits(arizona->regmap, fll->base + 5, | 1555 | regmap_update_bits_async(arizona->regmap, fll->base + 5, |
1501 | ARIZONA_FLL1_OUTDIV_MASK, | 1556 | ARIZONA_FLL1_OUTDIV_MASK, |
1502 | sync->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); | 1557 | sync->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); |
1503 | 1558 | ||
1504 | arizona_apply_fll(arizona, fll->base, sync, | 1559 | arizona_apply_fll(arizona, fll->base, sync, |
1505 | fll->sync_src, false); | 1560 | fll->sync_src, false); |
1506 | 1561 | ||
1507 | regmap_update_bits(arizona->regmap, fll->base + 0x11, | 1562 | regmap_update_bits_async(arizona->regmap, fll->base + 0x11, |
1508 | ARIZONA_FLL1_SYNC_ENA, 0); | 1563 | ARIZONA_FLL1_SYNC_ENA, 0); |
1509 | } else { | 1564 | } else { |
1510 | arizona_fll_err(fll, "No clocks provided\n"); | 1565 | arizona_fll_err(fll, "No clocks provided\n"); |
1511 | return; | 1566 | return; |
@@ -1516,11 +1571,12 @@ static void arizona_enable_fll(struct arizona_fll *fll, | |||
1516 | * sync source. | 1571 | * sync source. |
1517 | */ | 1572 | */ |
1518 | if (use_sync && fll->sync_freq > 100000) | 1573 | if (use_sync && fll->sync_freq > 100000) |
1519 | regmap_update_bits(arizona->regmap, fll->base + 0x17, | 1574 | regmap_update_bits_async(arizona->regmap, fll->base + 0x17, |
1520 | ARIZONA_FLL1_SYNC_BW, 0); | 1575 | ARIZONA_FLL1_SYNC_BW, 0); |
1521 | else | 1576 | else |
1522 | regmap_update_bits(arizona->regmap, fll->base + 0x17, | 1577 | regmap_update_bits_async(arizona->regmap, fll->base + 0x17, |
1523 | ARIZONA_FLL1_SYNC_BW, ARIZONA_FLL1_SYNC_BW); | 1578 | ARIZONA_FLL1_SYNC_BW, |
1579 | ARIZONA_FLL1_SYNC_BW); | ||
1524 | 1580 | ||
1525 | if (!arizona_is_enabled_fll(fll)) | 1581 | if (!arizona_is_enabled_fll(fll)) |
1526 | pm_runtime_get(arizona->dev); | 1582 | pm_runtime_get(arizona->dev); |
@@ -1528,14 +1584,14 @@ static void arizona_enable_fll(struct arizona_fll *fll, | |||
1528 | /* Clear any pending completions */ | 1584 | /* Clear any pending completions */ |
1529 | try_wait_for_completion(&fll->ok); | 1585 | try_wait_for_completion(&fll->ok); |
1530 | 1586 | ||
1531 | regmap_update_bits(arizona->regmap, fll->base + 1, | 1587 | regmap_update_bits_async(arizona->regmap, fll->base + 1, |
1532 | ARIZONA_FLL1_FREERUN, 0); | 1588 | ARIZONA_FLL1_FREERUN, 0); |
1533 | regmap_update_bits(arizona->regmap, fll->base + 1, | 1589 | regmap_update_bits_async(arizona->regmap, fll->base + 1, |
1534 | ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); | 1590 | ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); |
1535 | if (use_sync) | 1591 | if (use_sync) |
1536 | regmap_update_bits(arizona->regmap, fll->base + 0x11, | 1592 | regmap_update_bits_async(arizona->regmap, fll->base + 0x11, |
1537 | ARIZONA_FLL1_SYNC_ENA, | 1593 | ARIZONA_FLL1_SYNC_ENA, |
1538 | ARIZONA_FLL1_SYNC_ENA); | 1594 | ARIZONA_FLL1_SYNC_ENA); |
1539 | 1595 | ||
1540 | ret = wait_for_completion_timeout(&fll->ok, | 1596 | ret = wait_for_completion_timeout(&fll->ok, |
1541 | msecs_to_jiffies(250)); | 1597 | msecs_to_jiffies(250)); |
@@ -1548,8 +1604,8 @@ static void arizona_disable_fll(struct arizona_fll *fll) | |||
1548 | struct arizona *arizona = fll->arizona; | 1604 | struct arizona *arizona = fll->arizona; |
1549 | bool change; | 1605 | bool change; |
1550 | 1606 | ||
1551 | regmap_update_bits(arizona->regmap, fll->base + 1, | 1607 | regmap_update_bits_async(arizona->regmap, fll->base + 1, |
1552 | ARIZONA_FLL1_FREERUN, ARIZONA_FLL1_FREERUN); | 1608 | ARIZONA_FLL1_FREERUN, ARIZONA_FLL1_FREERUN); |
1553 | regmap_update_bits_check(arizona->regmap, fll->base + 1, | 1609 | regmap_update_bits_check(arizona->regmap, fll->base + 1, |
1554 | ARIZONA_FLL1_ENA, 0, &change); | 1610 | ARIZONA_FLL1_ENA, 0, &change); |
1555 | regmap_update_bits(arizona->regmap, fll->base + 0x11, | 1611 | regmap_update_bits(arizona->regmap, fll->base + 0x11, |
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index 9e81b6392692..10b398477203 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h | |||
@@ -81,7 +81,7 @@ struct arizona_priv { | |||
81 | unsigned int spk_ena_pending:1; | 81 | unsigned int spk_ena_pending:1; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | #define ARIZONA_NUM_MIXER_INPUTS 99 | 84 | #define ARIZONA_NUM_MIXER_INPUTS 103 |
85 | 85 | ||
86 | extern const unsigned int arizona_mixer_tlv[]; | 86 | extern const unsigned int arizona_mixer_tlv[]; |
87 | extern const char *arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS]; | 87 | extern const char *arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS]; |
@@ -186,6 +186,8 @@ extern const char *arizona_rate_text[ARIZONA_RATE_ENUM_SIZE]; | |||
186 | extern const int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE]; | 186 | extern const int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE]; |
187 | 187 | ||
188 | extern const struct soc_enum arizona_isrc_fsl[]; | 188 | extern const struct soc_enum arizona_isrc_fsl[]; |
189 | extern const struct soc_enum arizona_isrc_fsh[]; | ||
190 | extern const struct soc_enum arizona_asrc_rate1; | ||
189 | 191 | ||
190 | extern const struct soc_enum arizona_in_vi_ramp; | 192 | extern const struct soc_enum arizona_in_vi_ramp; |
191 | extern const struct soc_enum arizona_in_vd_ramp; | 193 | extern const struct soc_enum arizona_in_vd_ramp; |
@@ -199,6 +201,7 @@ extern const struct soc_enum arizona_lhpf3_mode; | |||
199 | extern const struct soc_enum arizona_lhpf4_mode; | 201 | extern const struct soc_enum arizona_lhpf4_mode; |
200 | 202 | ||
201 | extern const struct soc_enum arizona_ng_hold; | 203 | extern const struct soc_enum arizona_ng_hold; |
204 | extern const struct soc_enum arizona_in_hpf_cut_enum; | ||
202 | extern const struct soc_enum arizona_in_dmic_osr[]; | 205 | extern const struct soc_enum arizona_in_dmic_osr[]; |
203 | 206 | ||
204 | extern int arizona_in_ev(struct snd_soc_dapm_widget *w, | 207 | extern int arizona_in_ev(struct snd_soc_dapm_widget *w, |
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index f6e953454bc0..ce05fd93dc74 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c | |||
@@ -675,7 +675,7 @@ static struct spi_driver cs4271_spi_driver = { | |||
675 | }; | 675 | }; |
676 | #endif /* defined(CONFIG_SPI_MASTER) */ | 676 | #endif /* defined(CONFIG_SPI_MASTER) */ |
677 | 677 | ||
678 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 678 | #if IS_ENABLED(CONFIG_I2C) |
679 | static const struct i2c_device_id cs4271_i2c_id[] = { | 679 | static const struct i2c_device_id cs4271_i2c_id[] = { |
680 | {"cs4271", 0}, | 680 | {"cs4271", 0}, |
681 | {} | 681 | {} |
@@ -728,7 +728,7 @@ static struct i2c_driver cs4271_i2c_driver = { | |||
728 | .probe = cs4271_i2c_probe, | 728 | .probe = cs4271_i2c_probe, |
729 | .remove = cs4271_i2c_remove, | 729 | .remove = cs4271_i2c_remove, |
730 | }; | 730 | }; |
731 | #endif /* defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) */ | 731 | #endif /* IS_ENABLED(CONFIG_I2C) */ |
732 | 732 | ||
733 | /* | 733 | /* |
734 | * We only register our serial bus driver here without | 734 | * We only register our serial bus driver here without |
@@ -741,7 +741,7 @@ static int __init cs4271_modinit(void) | |||
741 | { | 741 | { |
742 | int ret; | 742 | int ret; |
743 | 743 | ||
744 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 744 | #if IS_ENABLED(CONFIG_I2C) |
745 | ret = i2c_add_driver(&cs4271_i2c_driver); | 745 | ret = i2c_add_driver(&cs4271_i2c_driver); |
746 | if (ret) { | 746 | if (ret) { |
747 | pr_err("Failed to register CS4271 I2C driver: %d\n", ret); | 747 | pr_err("Failed to register CS4271 I2C driver: %d\n", ret); |
@@ -767,7 +767,7 @@ static void __exit cs4271_modexit(void) | |||
767 | spi_unregister_driver(&cs4271_spi_driver); | 767 | spi_unregister_driver(&cs4271_spi_driver); |
768 | #endif | 768 | #endif |
769 | 769 | ||
770 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 770 | #if IS_ENABLED(CONFIG_I2C) |
771 | i2c_del_driver(&cs4271_i2c_driver); | 771 | i2c_del_driver(&cs4271_i2c_driver); |
772 | #endif | 772 | #endif |
773 | } | 773 | } |
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c index 8b427c977083..0bac6d5a4ac8 100644 --- a/sound/soc/codecs/cs42l52.c +++ b/sound/soc/codecs/cs42l52.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/gpio.h> | 20 | #include <linux/of_gpio.h> |
21 | #include <linux/pm.h> | 21 | #include <linux/pm.h> |
22 | #include <linux/i2c.h> | 22 | #include <linux/i2c.h> |
23 | #include <linux/input.h> | 23 | #include <linux/input.h> |
@@ -50,7 +50,7 @@ struct cs42l52_private { | |||
50 | u8 mclksel; | 50 | u8 mclksel; |
51 | u32 mclk; | 51 | u32 mclk; |
52 | u8 flags; | 52 | u8 flags; |
53 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 53 | #if IS_ENABLED(CONFIG_INPUT) |
54 | struct input_dev *beep; | 54 | struct input_dev *beep; |
55 | struct work_struct beep_work; | 55 | struct work_struct beep_work; |
56 | int beep_rate; | 56 | int beep_rate; |
@@ -233,7 +233,7 @@ static const struct soc_enum mic_bias_level_enum = | |||
233 | SOC_ENUM_SINGLE(CS42L52_IFACE_CTL2, 0, | 233 | SOC_ENUM_SINGLE(CS42L52_IFACE_CTL2, 0, |
234 | ARRAY_SIZE(mic_bias_level_text), mic_bias_level_text); | 234 | ARRAY_SIZE(mic_bias_level_text), mic_bias_level_text); |
235 | 235 | ||
236 | static const char * const cs42l52_mic_text[] = { "Single", "Differential" }; | 236 | static const char * const cs42l52_mic_text[] = { "MIC1", "MIC2" }; |
237 | 237 | ||
238 | static const struct soc_enum mica_enum = | 238 | static const struct soc_enum mica_enum = |
239 | SOC_ENUM_SINGLE(CS42L52_MICA_CTL, 5, | 239 | SOC_ENUM_SINGLE(CS42L52_MICA_CTL, 5, |
@@ -243,12 +243,6 @@ static const struct soc_enum micb_enum = | |||
243 | SOC_ENUM_SINGLE(CS42L52_MICB_CTL, 5, | 243 | SOC_ENUM_SINGLE(CS42L52_MICB_CTL, 5, |
244 | ARRAY_SIZE(cs42l52_mic_text), cs42l52_mic_text); | 244 | ARRAY_SIZE(cs42l52_mic_text), cs42l52_mic_text); |
245 | 245 | ||
246 | static const struct snd_kcontrol_new mica_mux = | ||
247 | SOC_DAPM_ENUM("Left Mic Input Capture Mux", mica_enum); | ||
248 | |||
249 | static const struct snd_kcontrol_new micb_mux = | ||
250 | SOC_DAPM_ENUM("Right Mic Input Capture Mux", micb_enum); | ||
251 | |||
252 | static const char * const digital_output_mux_text[] = {"ADC", "DSP"}; | 246 | static const char * const digital_output_mux_text[] = {"ADC", "DSP"}; |
253 | 247 | ||
254 | static const struct soc_enum digital_output_mux_enum = | 248 | static const struct soc_enum digital_output_mux_enum = |
@@ -531,6 +525,30 @@ static const struct snd_kcontrol_new cs42l52_snd_controls[] = { | |||
531 | 525 | ||
532 | }; | 526 | }; |
533 | 527 | ||
528 | static const struct snd_kcontrol_new cs42l52_mica_controls[] = { | ||
529 | SOC_ENUM("MICA Select", mica_enum), | ||
530 | }; | ||
531 | |||
532 | static const struct snd_kcontrol_new cs42l52_micb_controls[] = { | ||
533 | SOC_ENUM("MICB Select", micb_enum), | ||
534 | }; | ||
535 | |||
536 | static int cs42l52_add_mic_controls(struct snd_soc_codec *codec) | ||
537 | { | ||
538 | struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); | ||
539 | struct cs42l52_platform_data *pdata = &cs42l52->pdata; | ||
540 | |||
541 | if (!pdata->mica_diff_cfg) | ||
542 | snd_soc_add_codec_controls(codec, cs42l52_mica_controls, | ||
543 | ARRAY_SIZE(cs42l52_mica_controls)); | ||
544 | |||
545 | if (!pdata->micb_diff_cfg) | ||
546 | snd_soc_add_codec_controls(codec, cs42l52_micb_controls, | ||
547 | ARRAY_SIZE(cs42l52_micb_controls)); | ||
548 | |||
549 | return 0; | ||
550 | } | ||
551 | |||
534 | static const struct snd_soc_dapm_widget cs42l52_dapm_widgets[] = { | 552 | static const struct snd_soc_dapm_widget cs42l52_dapm_widgets[] = { |
535 | 553 | ||
536 | SND_SOC_DAPM_INPUT("AIN1L"), | 554 | SND_SOC_DAPM_INPUT("AIN1L"), |
@@ -550,9 +568,6 @@ static const struct snd_soc_dapm_widget cs42l52_dapm_widgets[] = { | |||
550 | SND_SOC_DAPM_AIF_OUT("AIFOUTR", NULL, 0, | 568 | SND_SOC_DAPM_AIF_OUT("AIFOUTR", NULL, 0, |
551 | SND_SOC_NOPM, 0, 0), | 569 | SND_SOC_NOPM, 0, 0), |
552 | 570 | ||
553 | SND_SOC_DAPM_MUX("MICA Mux", SND_SOC_NOPM, 0, 0, &mica_mux), | ||
554 | SND_SOC_DAPM_MUX("MICB Mux", SND_SOC_NOPM, 0, 0, &micb_mux), | ||
555 | |||
556 | SND_SOC_DAPM_ADC("ADC Left", NULL, CS42L52_PWRCTL1, 1, 1), | 571 | SND_SOC_DAPM_ADC("ADC Left", NULL, CS42L52_PWRCTL1, 1, 1), |
557 | SND_SOC_DAPM_ADC("ADC Right", NULL, CS42L52_PWRCTL1, 2, 1), | 572 | SND_SOC_DAPM_ADC("ADC Right", NULL, CS42L52_PWRCTL1, 2, 1), |
558 | SND_SOC_DAPM_PGA("PGA Left", CS42L52_PWRCTL1, 3, 1, NULL, 0), | 573 | SND_SOC_DAPM_PGA("PGA Left", CS42L52_PWRCTL1, 3, 1, NULL, 0), |
@@ -953,7 +968,7 @@ static int cs42l52_resume(struct snd_soc_codec *codec) | |||
953 | return 0; | 968 | return 0; |
954 | } | 969 | } |
955 | 970 | ||
956 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 971 | #if IS_ENABLED(CONFIG_INPUT) |
957 | static int beep_rates[] = { | 972 | static int beep_rates[] = { |
958 | 261, 522, 585, 667, 706, 774, 889, 1000, | 973 | 261, 522, 585, 667, 706, 774, 889, 1000, |
959 | 1043, 1200, 1333, 1412, 1600, 1714, 2000, 2182 | 974 | 1043, 1200, 1333, 1412, 1600, 1714, 2000, 2182 |
@@ -1110,6 +1125,8 @@ static int cs42l52_probe(struct snd_soc_codec *codec) | |||
1110 | } | 1125 | } |
1111 | regcache_cache_only(cs42l52->regmap, true); | 1126 | regcache_cache_only(cs42l52->regmap, true); |
1112 | 1127 | ||
1128 | cs42l52_add_mic_controls(codec); | ||
1129 | |||
1113 | cs42l52_init_beep(codec); | 1130 | cs42l52_init_beep(codec); |
1114 | 1131 | ||
1115 | cs42l52_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1132 | cs42l52_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
@@ -1176,6 +1193,7 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client, | |||
1176 | int ret; | 1193 | int ret; |
1177 | unsigned int devid = 0; | 1194 | unsigned int devid = 0; |
1178 | unsigned int reg; | 1195 | unsigned int reg; |
1196 | u32 val32; | ||
1179 | 1197 | ||
1180 | cs42l52 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l52_private), | 1198 | cs42l52 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l52_private), |
1181 | GFP_KERNEL); | 1199 | GFP_KERNEL); |
@@ -1189,9 +1207,39 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client, | |||
1189 | dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); | 1207 | dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); |
1190 | return ret; | 1208 | return ret; |
1191 | } | 1209 | } |
1192 | 1210 | if (pdata) { | |
1193 | if (pdata) | 1211 | cs42l52->pdata = *pdata; |
1212 | } else { | ||
1213 | pdata = devm_kzalloc(&i2c_client->dev, | ||
1214 | sizeof(struct cs42l52_platform_data), | ||
1215 | GFP_KERNEL); | ||
1216 | if (!pdata) { | ||
1217 | dev_err(&i2c_client->dev, "could not allocate pdata\n"); | ||
1218 | return -ENOMEM; | ||
1219 | } | ||
1220 | if (i2c_client->dev.of_node) { | ||
1221 | if (of_property_read_bool(i2c_client->dev.of_node, | ||
1222 | "cirrus,mica-differential-cfg")) | ||
1223 | pdata->mica_diff_cfg = true; | ||
1224 | |||
1225 | if (of_property_read_bool(i2c_client->dev.of_node, | ||
1226 | "cirrus,micb-differential-cfg")) | ||
1227 | pdata->micb_diff_cfg = true; | ||
1228 | |||
1229 | if (of_property_read_u32(i2c_client->dev.of_node, | ||
1230 | "cirrus,micbias-lvl", &val32) >= 0) | ||
1231 | pdata->micbias_lvl = val32; | ||
1232 | |||
1233 | if (of_property_read_u32(i2c_client->dev.of_node, | ||
1234 | "cirrus,chgfreq-divisor", &val32) >= 0) | ||
1235 | pdata->chgfreq = val32; | ||
1236 | |||
1237 | pdata->reset_gpio = | ||
1238 | of_get_named_gpio(i2c_client->dev.of_node, | ||
1239 | "cirrus,reset-gpio", 0); | ||
1240 | } | ||
1194 | cs42l52->pdata = *pdata; | 1241 | cs42l52->pdata = *pdata; |
1242 | } | ||
1195 | 1243 | ||
1196 | if (cs42l52->pdata.reset_gpio) { | 1244 | if (cs42l52->pdata.reset_gpio) { |
1197 | ret = gpio_request_one(cs42l52->pdata.reset_gpio, | 1245 | ret = gpio_request_one(cs42l52->pdata.reset_gpio, |
@@ -1227,29 +1275,18 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client, | |||
1227 | reg & 0xFF); | 1275 | reg & 0xFF); |
1228 | 1276 | ||
1229 | /* Set Platform Data */ | 1277 | /* Set Platform Data */ |
1230 | if (cs42l52->pdata.mica_cfg) | 1278 | if (cs42l52->pdata.mica_diff_cfg) |
1231 | regmap_update_bits(cs42l52->regmap, CS42L52_MICA_CTL, | 1279 | regmap_update_bits(cs42l52->regmap, CS42L52_MICA_CTL, |
1232 | CS42L52_MIC_CTL_TYPE_MASK, | 1280 | CS42L52_MIC_CTL_TYPE_MASK, |
1233 | cs42l52->pdata.mica_cfg << | 1281 | cs42l52->pdata.mica_diff_cfg << |
1234 | CS42L52_MIC_CTL_TYPE_SHIFT); | 1282 | CS42L52_MIC_CTL_TYPE_SHIFT); |
1235 | 1283 | ||
1236 | if (cs42l52->pdata.micb_cfg) | 1284 | if (cs42l52->pdata.micb_diff_cfg) |
1237 | regmap_update_bits(cs42l52->regmap, CS42L52_MICB_CTL, | 1285 | regmap_update_bits(cs42l52->regmap, CS42L52_MICB_CTL, |
1238 | CS42L52_MIC_CTL_TYPE_MASK, | 1286 | CS42L52_MIC_CTL_TYPE_MASK, |
1239 | cs42l52->pdata.micb_cfg << | 1287 | cs42l52->pdata.micb_diff_cfg << |
1240 | CS42L52_MIC_CTL_TYPE_SHIFT); | 1288 | CS42L52_MIC_CTL_TYPE_SHIFT); |
1241 | 1289 | ||
1242 | if (cs42l52->pdata.mica_sel) | ||
1243 | regmap_update_bits(cs42l52->regmap, CS42L52_MICA_CTL, | ||
1244 | CS42L52_MIC_CTL_MIC_SEL_MASK, | ||
1245 | cs42l52->pdata.mica_sel << | ||
1246 | CS42L52_MIC_CTL_MIC_SEL_SHIFT); | ||
1247 | if (cs42l52->pdata.micb_sel) | ||
1248 | regmap_update_bits(cs42l52->regmap, CS42L52_MICB_CTL, | ||
1249 | CS42L52_MIC_CTL_MIC_SEL_MASK, | ||
1250 | cs42l52->pdata.micb_sel << | ||
1251 | CS42L52_MIC_CTL_MIC_SEL_SHIFT); | ||
1252 | |||
1253 | if (cs42l52->pdata.chgfreq) | 1290 | if (cs42l52->pdata.chgfreq) |
1254 | regmap_update_bits(cs42l52->regmap, CS42L52_CHARGE_PUMP, | 1291 | regmap_update_bits(cs42l52->regmap, CS42L52_CHARGE_PUMP, |
1255 | CS42L52_CHARGE_PUMP_MASK, | 1292 | CS42L52_CHARGE_PUMP_MASK, |
@@ -1274,6 +1311,13 @@ static int cs42l52_i2c_remove(struct i2c_client *client) | |||
1274 | return 0; | 1311 | return 0; |
1275 | } | 1312 | } |
1276 | 1313 | ||
1314 | static const struct of_device_id cs42l52_of_match[] = { | ||
1315 | { .compatible = "cirrus,cs42l52", }, | ||
1316 | {}, | ||
1317 | }; | ||
1318 | MODULE_DEVICE_TABLE(of, cs42l52_of_match); | ||
1319 | |||
1320 | |||
1277 | static const struct i2c_device_id cs42l52_id[] = { | 1321 | static const struct i2c_device_id cs42l52_id[] = { |
1278 | { "cs42l52", 0 }, | 1322 | { "cs42l52", 0 }, |
1279 | { } | 1323 | { } |
@@ -1284,6 +1328,7 @@ static struct i2c_driver cs42l52_i2c_driver = { | |||
1284 | .driver = { | 1328 | .driver = { |
1285 | .name = "cs42l52", | 1329 | .name = "cs42l52", |
1286 | .owner = THIS_MODULE, | 1330 | .owner = THIS_MODULE, |
1331 | .of_match_table = cs42l52_of_match, | ||
1287 | }, | 1332 | }, |
1288 | .id_table = cs42l52_id, | 1333 | .id_table = cs42l52_id, |
1289 | .probe = cs42l52_i2c_probe, | 1334 | .probe = cs42l52_i2c_probe, |
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index 9c1231456502..8166dcb2e4a3 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c | |||
@@ -1188,7 +1188,7 @@ static struct snd_soc_codec_driver soc_codec_dev_da7210 = { | |||
1188 | .num_dapm_routes = ARRAY_SIZE(da7210_audio_map), | 1188 | .num_dapm_routes = ARRAY_SIZE(da7210_audio_map), |
1189 | }; | 1189 | }; |
1190 | 1190 | ||
1191 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1191 | #if IS_ENABLED(CONFIG_I2C) |
1192 | 1192 | ||
1193 | static struct reg_default da7210_regmap_i2c_patch[] = { | 1193 | static struct reg_default da7210_regmap_i2c_patch[] = { |
1194 | 1194 | ||
@@ -1362,7 +1362,7 @@ static struct spi_driver da7210_spi_driver = { | |||
1362 | static int __init da7210_modinit(void) | 1362 | static int __init da7210_modinit(void) |
1363 | { | 1363 | { |
1364 | int ret = 0; | 1364 | int ret = 0; |
1365 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1365 | #if IS_ENABLED(CONFIG_I2C) |
1366 | ret = i2c_add_driver(&da7210_i2c_driver); | 1366 | ret = i2c_add_driver(&da7210_i2c_driver); |
1367 | #endif | 1367 | #endif |
1368 | #if defined(CONFIG_SPI_MASTER) | 1368 | #if defined(CONFIG_SPI_MASTER) |
@@ -1378,7 +1378,7 @@ module_init(da7210_modinit); | |||
1378 | 1378 | ||
1379 | static void __exit da7210_exit(void) | 1379 | static void __exit da7210_exit(void) |
1380 | { | 1380 | { |
1381 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1381 | #if IS_ENABLED(CONFIG_I2C) |
1382 | i2c_del_driver(&da7210_i2c_driver); | 1382 | i2c_del_driver(&da7210_i2c_driver); |
1383 | #endif | 1383 | #endif |
1384 | #if defined(CONFIG_SPI_MASTER) | 1384 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/hdmi.c b/sound/soc/codecs/hdmi.c index 68342b121c96..9cb1c7d3e1dc 100644 --- a/sound/soc/codecs/hdmi.c +++ b/sound/soc/codecs/hdmi.c | |||
@@ -20,6 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <sound/soc.h> | 22 | #include <sound/soc.h> |
23 | #include <linux/of_device.h> | ||
23 | 24 | ||
24 | #define DRV_NAME "hdmi-audio-codec" | 25 | #define DRV_NAME "hdmi-audio-codec" |
25 | 26 | ||
@@ -44,7 +45,7 @@ static struct snd_soc_dai_driver hdmi_codec_dai = { | |||
44 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | | 45 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | |
45 | SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, | 46 | SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, |
46 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | 47 | .formats = SNDRV_PCM_FMTBIT_S16_LE | |
47 | SNDRV_PCM_FMTBIT_S24_LE, | 48 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, |
48 | }, | 49 | }, |
49 | .capture = { | 50 | .capture = { |
50 | .stream_name = "Capture", | 51 | .stream_name = "Capture", |
@@ -60,6 +61,14 @@ static struct snd_soc_dai_driver hdmi_codec_dai = { | |||
60 | 61 | ||
61 | }; | 62 | }; |
62 | 63 | ||
64 | #ifdef CONFIG_OF | ||
65 | static const struct of_device_id hdmi_audio_codec_ids[] = { | ||
66 | { .compatible = "linux,hdmi-audio", }, | ||
67 | { } | ||
68 | }; | ||
69 | MODULE_DEVICE_TABLE(of, hdmi_audio_codec_ids); | ||
70 | #endif | ||
71 | |||
63 | static struct snd_soc_codec_driver hdmi_codec = { | 72 | static struct snd_soc_codec_driver hdmi_codec = { |
64 | .dapm_widgets = hdmi_widgets, | 73 | .dapm_widgets = hdmi_widgets, |
65 | .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets), | 74 | .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets), |
@@ -83,6 +92,7 @@ static struct platform_driver hdmi_codec_driver = { | |||
83 | .driver = { | 92 | .driver = { |
84 | .name = DRV_NAME, | 93 | .name = DRV_NAME, |
85 | .owner = THIS_MODULE, | 94 | .owner = THIS_MODULE, |
95 | .of_match_table = of_match_ptr(hdmi_audio_codec_ids), | ||
86 | }, | 96 | }, |
87 | 97 | ||
88 | .probe = hdmi_codec_probe, | 98 | .probe = hdmi_codec_probe, |
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 1f4093f3f3a1..0fcbe90f3ef2 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c | |||
@@ -115,6 +115,7 @@ struct sgtl5000_priv { | |||
115 | struct ldo_regulator *ldo; | 115 | struct ldo_regulator *ldo; |
116 | struct regmap *regmap; | 116 | struct regmap *regmap; |
117 | struct clk *mclk; | 117 | struct clk *mclk; |
118 | int revision; | ||
118 | }; | 119 | }; |
119 | 120 | ||
120 | /* | 121 | /* |
@@ -1285,41 +1286,45 @@ static int sgtl5000_replace_vddd_with_ldo(struct snd_soc_codec *codec) | |||
1285 | 1286 | ||
1286 | sgtl5000->supplies[VDDD].supply = LDO_CONSUMER_NAME; | 1287 | sgtl5000->supplies[VDDD].supply = LDO_CONSUMER_NAME; |
1287 | 1288 | ||
1288 | ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies), | ||
1289 | sgtl5000->supplies); | ||
1290 | |||
1291 | if (ret) { | ||
1292 | ldo_regulator_remove(codec); | ||
1293 | dev_err(codec->dev, "Failed to request supplies: %d\n", ret); | ||
1294 | return ret; | ||
1295 | } | ||
1296 | |||
1297 | dev_info(codec->dev, "Using internal LDO instead of VDDD\n"); | 1289 | dev_info(codec->dev, "Using internal LDO instead of VDDD\n"); |
1298 | return 0; | 1290 | return 0; |
1299 | } | 1291 | } |
1300 | 1292 | ||
1301 | static int sgtl5000_enable_regulators(struct snd_soc_codec *codec) | 1293 | static int sgtl5000_enable_regulators(struct snd_soc_codec *codec) |
1302 | { | 1294 | { |
1303 | int reg; | ||
1304 | int ret; | 1295 | int ret; |
1305 | int rev; | ||
1306 | int i; | 1296 | int i; |
1307 | int external_vddd = 0; | 1297 | int external_vddd = 0; |
1308 | struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); | 1298 | struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); |
1299 | struct regulator *vddd; | ||
1309 | 1300 | ||
1310 | for (i = 0; i < ARRAY_SIZE(sgtl5000->supplies); i++) | 1301 | for (i = 0; i < ARRAY_SIZE(sgtl5000->supplies); i++) |
1311 | sgtl5000->supplies[i].supply = supply_names[i]; | 1302 | sgtl5000->supplies[i].supply = supply_names[i]; |
1312 | 1303 | ||
1313 | ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies), | 1304 | /* External VDDD only works before revision 0x11 */ |
1314 | sgtl5000->supplies); | 1305 | if (sgtl5000->revision < 0x11) { |
1315 | if (!ret) | 1306 | vddd = regulator_get_optional(codec->dev, "VDDD"); |
1316 | external_vddd = 1; | 1307 | if (IS_ERR(vddd)) { |
1317 | else { | 1308 | /* See if it's just not registered yet */ |
1309 | if (PTR_ERR(vddd) == -EPROBE_DEFER) | ||
1310 | return -EPROBE_DEFER; | ||
1311 | } else { | ||
1312 | external_vddd = 1; | ||
1313 | regulator_put(vddd); | ||
1314 | } | ||
1315 | } | ||
1316 | |||
1317 | if (!external_vddd) { | ||
1318 | ret = sgtl5000_replace_vddd_with_ldo(codec); | 1318 | ret = sgtl5000_replace_vddd_with_ldo(codec); |
1319 | if (ret) | 1319 | if (ret) |
1320 | return ret; | 1320 | return ret; |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies), | ||
1324 | sgtl5000->supplies); | ||
1325 | if (ret) | ||
1326 | goto err_ldo_remove; | ||
1327 | |||
1323 | ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies), | 1328 | ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies), |
1324 | sgtl5000->supplies); | 1329 | sgtl5000->supplies); |
1325 | if (ret) | 1330 | if (ret) |
@@ -1328,47 +1333,13 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec) | |||
1328 | /* wait for all power rails bring up */ | 1333 | /* wait for all power rails bring up */ |
1329 | udelay(10); | 1334 | udelay(10); |
1330 | 1335 | ||
1331 | /* | ||
1332 | * workaround for revision 0x11 and later, | ||
1333 | * roll back to use internal LDO | ||
1334 | */ | ||
1335 | |||
1336 | ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, ®); | ||
1337 | if (ret) | ||
1338 | goto err_regulator_disable; | ||
1339 | |||
1340 | rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT; | ||
1341 | |||
1342 | if (external_vddd && rev >= 0x11) { | ||
1343 | /* disable all regulator first */ | ||
1344 | regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), | ||
1345 | sgtl5000->supplies); | ||
1346 | /* free VDDD regulator */ | ||
1347 | regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies), | ||
1348 | sgtl5000->supplies); | ||
1349 | |||
1350 | ret = sgtl5000_replace_vddd_with_ldo(codec); | ||
1351 | if (ret) | ||
1352 | return ret; | ||
1353 | |||
1354 | ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies), | ||
1355 | sgtl5000->supplies); | ||
1356 | if (ret) | ||
1357 | goto err_regulator_free; | ||
1358 | |||
1359 | /* wait for all power rails bring up */ | ||
1360 | udelay(10); | ||
1361 | } | ||
1362 | |||
1363 | return 0; | 1336 | return 0; |
1364 | 1337 | ||
1365 | err_regulator_disable: | ||
1366 | regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), | ||
1367 | sgtl5000->supplies); | ||
1368 | err_regulator_free: | 1338 | err_regulator_free: |
1369 | regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies), | 1339 | regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies), |
1370 | sgtl5000->supplies); | 1340 | sgtl5000->supplies); |
1371 | if (external_vddd) | 1341 | err_ldo_remove: |
1342 | if (!external_vddd) | ||
1372 | ldo_regulator_remove(codec); | 1343 | ldo_regulator_remove(codec); |
1373 | return ret; | 1344 | return ret; |
1374 | 1345 | ||
@@ -1566,6 +1537,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, | |||
1566 | 1537 | ||
1567 | rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT; | 1538 | rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT; |
1568 | dev_info(&client->dev, "sgtl5000 revision 0x%x\n", rev); | 1539 | dev_info(&client->dev, "sgtl5000 revision 0x%x\n", rev); |
1540 | sgtl5000->revision = rev; | ||
1569 | 1541 | ||
1570 | i2c_set_clientdata(client, sgtl5000); | 1542 | i2c_set_clientdata(client, sgtl5000); |
1571 | 1543 | ||
diff --git a/sound/soc/codecs/ssm2518.c b/sound/soc/codecs/ssm2518.c index 95aed552139a..cc8debce752f 100644 --- a/sound/soc/codecs/ssm2518.c +++ b/sound/soc/codecs/ssm2518.c | |||
@@ -549,13 +549,13 @@ static int ssm2518_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, | |||
549 | right_slot = 0; | 549 | right_slot = 0; |
550 | } else { | 550 | } else { |
551 | /* We assume the left channel < right channel */ | 551 | /* We assume the left channel < right channel */ |
552 | left_slot = ffs(tx_mask); | 552 | left_slot = __ffs(tx_mask); |
553 | tx_mask &= ~(1 << tx_mask); | 553 | tx_mask &= ~(1 << left_slot); |
554 | if (tx_mask == 0) { | 554 | if (tx_mask == 0) { |
555 | right_slot = left_slot; | 555 | right_slot = left_slot; |
556 | } else { | 556 | } else { |
557 | right_slot = ffs(tx_mask); | 557 | right_slot = __ffs(tx_mask); |
558 | tx_mask &= ~(1 << tx_mask); | 558 | tx_mask &= ~(1 << right_slot); |
559 | } | 559 | } |
560 | } | 560 | } |
561 | 561 | ||
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 492644e67ace..c6dd48561884 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c | |||
@@ -53,8 +53,6 @@ enum ssm2602_type { | |||
53 | struct ssm2602_priv { | 53 | struct ssm2602_priv { |
54 | unsigned int sysclk; | 54 | unsigned int sysclk; |
55 | struct snd_pcm_hw_constraint_list *sysclk_constraints; | 55 | struct snd_pcm_hw_constraint_list *sysclk_constraints; |
56 | struct snd_pcm_substream *master_substream; | ||
57 | struct snd_pcm_substream *slave_substream; | ||
58 | 56 | ||
59 | struct regmap *regmap; | 57 | struct regmap *regmap; |
60 | 58 | ||
@@ -277,11 +275,6 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream, | |||
277 | int srate = ssm2602_get_coeff(ssm2602->sysclk, params_rate(params)); | 275 | int srate = ssm2602_get_coeff(ssm2602->sysclk, params_rate(params)); |
278 | unsigned int iface; | 276 | unsigned int iface; |
279 | 277 | ||
280 | if (substream == ssm2602->slave_substream) { | ||
281 | dev_dbg(codec->dev, "Ignoring hw_params for slave substream\n"); | ||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | if (srate < 0) | 278 | if (srate < 0) |
286 | return srate; | 279 | return srate; |
287 | 280 | ||
@@ -314,33 +307,6 @@ static int ssm2602_startup(struct snd_pcm_substream *substream, | |||
314 | { | 307 | { |
315 | struct snd_soc_codec *codec = dai->codec; | 308 | struct snd_soc_codec *codec = dai->codec; |
316 | struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); | 309 | struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); |
317 | struct snd_pcm_runtime *master_runtime; | ||
318 | |||
319 | /* The DAI has shared clocks so if we already have a playback or | ||
320 | * capture going then constrain this substream to match it. | ||
321 | * TODO: the ssm2602 allows pairs of non-matching PB/REC rates | ||
322 | */ | ||
323 | if (ssm2602->master_substream) { | ||
324 | master_runtime = ssm2602->master_substream->runtime; | ||
325 | dev_dbg(codec->dev, "Constraining to %d bits at %dHz\n", | ||
326 | master_runtime->sample_bits, | ||
327 | master_runtime->rate); | ||
328 | |||
329 | if (master_runtime->rate != 0) | ||
330 | snd_pcm_hw_constraint_minmax(substream->runtime, | ||
331 | SNDRV_PCM_HW_PARAM_RATE, | ||
332 | master_runtime->rate, | ||
333 | master_runtime->rate); | ||
334 | |||
335 | if (master_runtime->sample_bits != 0) | ||
336 | snd_pcm_hw_constraint_minmax(substream->runtime, | ||
337 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, | ||
338 | master_runtime->sample_bits, | ||
339 | master_runtime->sample_bits); | ||
340 | |||
341 | ssm2602->slave_substream = substream; | ||
342 | } else | ||
343 | ssm2602->master_substream = substream; | ||
344 | 310 | ||
345 | if (ssm2602->sysclk_constraints) { | 311 | if (ssm2602->sysclk_constraints) { |
346 | snd_pcm_hw_constraint_list(substream->runtime, 0, | 312 | snd_pcm_hw_constraint_list(substream->runtime, 0, |
@@ -351,19 +317,6 @@ static int ssm2602_startup(struct snd_pcm_substream *substream, | |||
351 | return 0; | 317 | return 0; |
352 | } | 318 | } |
353 | 319 | ||
354 | static void ssm2602_shutdown(struct snd_pcm_substream *substream, | ||
355 | struct snd_soc_dai *dai) | ||
356 | { | ||
357 | struct snd_soc_codec *codec = dai->codec; | ||
358 | struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); | ||
359 | |||
360 | if (ssm2602->master_substream == substream) | ||
361 | ssm2602->master_substream = ssm2602->slave_substream; | ||
362 | |||
363 | ssm2602->slave_substream = NULL; | ||
364 | } | ||
365 | |||
366 | |||
367 | static int ssm2602_mute(struct snd_soc_dai *dai, int mute) | 320 | static int ssm2602_mute(struct snd_soc_dai *dai, int mute) |
368 | { | 321 | { |
369 | struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(dai->codec); | 322 | struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(dai->codec); |
@@ -530,7 +483,6 @@ static int ssm2602_set_bias_level(struct snd_soc_codec *codec, | |||
530 | static const struct snd_soc_dai_ops ssm2602_dai_ops = { | 483 | static const struct snd_soc_dai_ops ssm2602_dai_ops = { |
531 | .startup = ssm2602_startup, | 484 | .startup = ssm2602_startup, |
532 | .hw_params = ssm2602_hw_params, | 485 | .hw_params = ssm2602_hw_params, |
533 | .shutdown = ssm2602_shutdown, | ||
534 | .digital_mute = ssm2602_mute, | 486 | .digital_mute = ssm2602_mute, |
535 | .set_sysclk = ssm2602_set_dai_sysclk, | 487 | .set_sysclk = ssm2602_set_dai_sysclk, |
536 | .set_fmt = ssm2602_set_dai_fmt, | 488 | .set_fmt = ssm2602_set_dai_fmt, |
@@ -551,6 +503,8 @@ static struct snd_soc_dai_driver ssm2602_dai = { | |||
551 | .rates = SSM2602_RATES, | 503 | .rates = SSM2602_RATES, |
552 | .formats = SSM2602_FORMATS,}, | 504 | .formats = SSM2602_FORMATS,}, |
553 | .ops = &ssm2602_dai_ops, | 505 | .ops = &ssm2602_dai_ops, |
506 | .symmetric_rates = 1, | ||
507 | .symmetric_samplebits = 1, | ||
554 | }; | 508 | }; |
555 | 509 | ||
556 | static int ssm2602_suspend(struct snd_soc_codec *codec) | 510 | static int ssm2602_suspend(struct snd_soc_codec *codec) |
@@ -730,7 +684,7 @@ static struct spi_driver ssm2602_spi_driver = { | |||
730 | }; | 684 | }; |
731 | #endif | 685 | #endif |
732 | 686 | ||
733 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 687 | #if IS_ENABLED(CONFIG_I2C) |
734 | /* | 688 | /* |
735 | * ssm2602 2 wire address is determined by GPIO5 | 689 | * ssm2602 2 wire address is determined by GPIO5 |
736 | * state during powerup. | 690 | * state during powerup. |
@@ -797,7 +751,7 @@ static int __init ssm2602_modinit(void) | |||
797 | return ret; | 751 | return ret; |
798 | #endif | 752 | #endif |
799 | 753 | ||
800 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 754 | #if IS_ENABLED(CONFIG_I2C) |
801 | ret = i2c_add_driver(&ssm2602_i2c_driver); | 755 | ret = i2c_add_driver(&ssm2602_i2c_driver); |
802 | if (ret) | 756 | if (ret) |
803 | return ret; | 757 | return ret; |
@@ -813,7 +767,7 @@ static void __exit ssm2602_exit(void) | |||
813 | spi_unregister_driver(&ssm2602_spi_driver); | 767 | spi_unregister_driver(&ssm2602_spi_driver); |
814 | #endif | 768 | #endif |
815 | 769 | ||
816 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 770 | #if IS_ENABLED(CONFIG_I2C) |
817 | i2c_del_driver(&ssm2602_i2c_driver); | 771 | i2c_del_driver(&ssm2602_i2c_driver); |
818 | #endif | 772 | #endif |
819 | } | 773 | } |
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 546d16b7d38f..470fbfb4b386 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
@@ -350,16 +350,6 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { | |||
350 | DACL1_2_LLOPM_VOL, DACR1_2_RLOPM_VOL, | 350 | DACL1_2_LLOPM_VOL, DACR1_2_RLOPM_VOL, |
351 | 0, 118, 1, output_stage_tlv), | 351 | 0, 118, 1, output_stage_tlv), |
352 | 352 | ||
353 | SOC_DOUBLE_R_TLV("Mono Line2 Bypass Volume", | ||
354 | LINE2L_2_MONOLOPM_VOL, LINE2R_2_MONOLOPM_VOL, | ||
355 | 0, 118, 1, output_stage_tlv), | ||
356 | SOC_DOUBLE_R_TLV("Mono PGA Bypass Volume", | ||
357 | PGAL_2_MONOLOPM_VOL, PGAR_2_MONOLOPM_VOL, | ||
358 | 0, 118, 1, output_stage_tlv), | ||
359 | SOC_DOUBLE_R_TLV("Mono DAC Playback Volume", | ||
360 | DACL1_2_MONOLOPM_VOL, DACR1_2_MONOLOPM_VOL, | ||
361 | 0, 118, 1, output_stage_tlv), | ||
362 | |||
363 | SOC_DOUBLE_R_TLV("HP Line2 Bypass Volume", | 353 | SOC_DOUBLE_R_TLV("HP Line2 Bypass Volume", |
364 | LINE2L_2_HPLOUT_VOL, LINE2R_2_HPROUT_VOL, | 354 | LINE2L_2_HPLOUT_VOL, LINE2R_2_HPROUT_VOL, |
365 | 0, 118, 1, output_stage_tlv), | 355 | 0, 118, 1, output_stage_tlv), |
@@ -383,7 +373,6 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { | |||
383 | /* Output pin mute controls */ | 373 | /* Output pin mute controls */ |
384 | SOC_DOUBLE_R("Line Playback Switch", LLOPM_CTRL, RLOPM_CTRL, 3, | 374 | SOC_DOUBLE_R("Line Playback Switch", LLOPM_CTRL, RLOPM_CTRL, 3, |
385 | 0x01, 0), | 375 | 0x01, 0), |
386 | SOC_SINGLE("Mono Playback Switch", MONOLOPM_CTRL, 3, 0x01, 0), | ||
387 | SOC_DOUBLE_R("HP Playback Switch", HPLOUT_CTRL, HPROUT_CTRL, 3, | 376 | SOC_DOUBLE_R("HP Playback Switch", HPLOUT_CTRL, HPROUT_CTRL, 3, |
388 | 0x01, 0), | 377 | 0x01, 0), |
389 | SOC_DOUBLE_R("HPCOM Playback Switch", HPLCOM_CTRL, HPRCOM_CTRL, 3, | 378 | SOC_DOUBLE_R("HPCOM Playback Switch", HPLCOM_CTRL, HPRCOM_CTRL, 3, |
@@ -412,6 +401,20 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { | |||
412 | SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]), | 401 | SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]), |
413 | }; | 402 | }; |
414 | 403 | ||
404 | static const struct snd_kcontrol_new aic3x_mono_controls[] = { | ||
405 | SOC_DOUBLE_R_TLV("Mono Line2 Bypass Volume", | ||
406 | LINE2L_2_MONOLOPM_VOL, LINE2R_2_MONOLOPM_VOL, | ||
407 | 0, 118, 1, output_stage_tlv), | ||
408 | SOC_DOUBLE_R_TLV("Mono PGA Bypass Volume", | ||
409 | PGAL_2_MONOLOPM_VOL, PGAR_2_MONOLOPM_VOL, | ||
410 | 0, 118, 1, output_stage_tlv), | ||
411 | SOC_DOUBLE_R_TLV("Mono DAC Playback Volume", | ||
412 | DACL1_2_MONOLOPM_VOL, DACR1_2_MONOLOPM_VOL, | ||
413 | 0, 118, 1, output_stage_tlv), | ||
414 | |||
415 | SOC_SINGLE("Mono Playback Switch", MONOLOPM_CTRL, 3, 0x01, 0), | ||
416 | }; | ||
417 | |||
415 | /* | 418 | /* |
416 | * Class-D amplifier gain. From 0 to 18 dB in 6 dB steps | 419 | * Class-D amplifier gain. From 0 to 18 dB in 6 dB steps |
417 | */ | 420 | */ |
@@ -565,9 +568,6 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { | |||
565 | SND_SOC_DAPM_PGA("Right HP Out", HPROUT_CTRL, 0, 0, NULL, 0), | 568 | SND_SOC_DAPM_PGA("Right HP Out", HPROUT_CTRL, 0, 0, NULL, 0), |
566 | SND_SOC_DAPM_PGA("Right HP Com", HPRCOM_CTRL, 0, 0, NULL, 0), | 569 | SND_SOC_DAPM_PGA("Right HP Com", HPRCOM_CTRL, 0, 0, NULL, 0), |
567 | 570 | ||
568 | /* Mono Output */ | ||
569 | SND_SOC_DAPM_PGA("Mono Out", MONOLOPM_CTRL, 0, 0, NULL, 0), | ||
570 | |||
571 | /* Inputs to Left ADC */ | 571 | /* Inputs to Left ADC */ |
572 | SND_SOC_DAPM_ADC("Left ADC", "Left Capture", LINE1L_2_LADC_CTRL, 2, 0), | 572 | SND_SOC_DAPM_ADC("Left ADC", "Left Capture", LINE1L_2_LADC_CTRL, 2, 0), |
573 | SND_SOC_DAPM_MIXER("Left PGA Mixer", SND_SOC_NOPM, 0, 0, | 573 | SND_SOC_DAPM_MIXER("Left PGA Mixer", SND_SOC_NOPM, 0, 0, |
@@ -626,9 +626,6 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { | |||
626 | SND_SOC_DAPM_MIXER("Right Line Mixer", SND_SOC_NOPM, 0, 0, | 626 | SND_SOC_DAPM_MIXER("Right Line Mixer", SND_SOC_NOPM, 0, 0, |
627 | &aic3x_right_line_mixer_controls[0], | 627 | &aic3x_right_line_mixer_controls[0], |
628 | ARRAY_SIZE(aic3x_right_line_mixer_controls)), | 628 | ARRAY_SIZE(aic3x_right_line_mixer_controls)), |
629 | SND_SOC_DAPM_MIXER("Mono Mixer", SND_SOC_NOPM, 0, 0, | ||
630 | &aic3x_mono_mixer_controls[0], | ||
631 | ARRAY_SIZE(aic3x_mono_mixer_controls)), | ||
632 | SND_SOC_DAPM_MIXER("Left HP Mixer", SND_SOC_NOPM, 0, 0, | 629 | SND_SOC_DAPM_MIXER("Left HP Mixer", SND_SOC_NOPM, 0, 0, |
633 | &aic3x_left_hp_mixer_controls[0], | 630 | &aic3x_left_hp_mixer_controls[0], |
634 | ARRAY_SIZE(aic3x_left_hp_mixer_controls)), | 631 | ARRAY_SIZE(aic3x_left_hp_mixer_controls)), |
@@ -644,7 +641,6 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { | |||
644 | 641 | ||
645 | SND_SOC_DAPM_OUTPUT("LLOUT"), | 642 | SND_SOC_DAPM_OUTPUT("LLOUT"), |
646 | SND_SOC_DAPM_OUTPUT("RLOUT"), | 643 | SND_SOC_DAPM_OUTPUT("RLOUT"), |
647 | SND_SOC_DAPM_OUTPUT("MONO_LOUT"), | ||
648 | SND_SOC_DAPM_OUTPUT("HPLOUT"), | 644 | SND_SOC_DAPM_OUTPUT("HPLOUT"), |
649 | SND_SOC_DAPM_OUTPUT("HPROUT"), | 645 | SND_SOC_DAPM_OUTPUT("HPROUT"), |
650 | SND_SOC_DAPM_OUTPUT("HPLCOM"), | 646 | SND_SOC_DAPM_OUTPUT("HPLCOM"), |
@@ -666,6 +662,17 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { | |||
666 | SND_SOC_DAPM_OUTPUT("Detection"), | 662 | SND_SOC_DAPM_OUTPUT("Detection"), |
667 | }; | 663 | }; |
668 | 664 | ||
665 | static const struct snd_soc_dapm_widget aic3x_dapm_mono_widgets[] = { | ||
666 | /* Mono Output */ | ||
667 | SND_SOC_DAPM_PGA("Mono Out", MONOLOPM_CTRL, 0, 0, NULL, 0), | ||
668 | |||
669 | SND_SOC_DAPM_MIXER("Mono Mixer", SND_SOC_NOPM, 0, 0, | ||
670 | &aic3x_mono_mixer_controls[0], | ||
671 | ARRAY_SIZE(aic3x_mono_mixer_controls)), | ||
672 | |||
673 | SND_SOC_DAPM_OUTPUT("MONO_LOUT"), | ||
674 | }; | ||
675 | |||
669 | static const struct snd_soc_dapm_widget aic3007_dapm_widgets[] = { | 676 | static const struct snd_soc_dapm_widget aic3007_dapm_widgets[] = { |
670 | /* Class-D outputs */ | 677 | /* Class-D outputs */ |
671 | SND_SOC_DAPM_PGA("Left Class-D Out", CLASSD_CTRL, 3, 0, NULL, 0), | 678 | SND_SOC_DAPM_PGA("Left Class-D Out", CLASSD_CTRL, 3, 0, NULL, 0), |
@@ -754,17 +761,6 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
754 | {"Right Line Out", NULL, "Right DAC Mux"}, | 761 | {"Right Line Out", NULL, "Right DAC Mux"}, |
755 | {"RLOUT", NULL, "Right Line Out"}, | 762 | {"RLOUT", NULL, "Right Line Out"}, |
756 | 763 | ||
757 | /* Mono Output */ | ||
758 | {"Mono Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, | ||
759 | {"Mono Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, | ||
760 | {"Mono Mixer", "DACL1 Switch", "Left DAC Mux"}, | ||
761 | {"Mono Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, | ||
762 | {"Mono Mixer", "PGAR Bypass Switch", "Right PGA Mixer"}, | ||
763 | {"Mono Mixer", "DACR1 Switch", "Right DAC Mux"}, | ||
764 | |||
765 | {"Mono Out", NULL, "Mono Mixer"}, | ||
766 | {"MONO_LOUT", NULL, "Mono Out"}, | ||
767 | |||
768 | /* Left HP Output */ | 764 | /* Left HP Output */ |
769 | {"Left HP Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, | 765 | {"Left HP Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, |
770 | {"Left HP Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, | 766 | {"Left HP Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, |
@@ -820,6 +816,18 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
820 | {"HPRCOM", NULL, "Right HP Com"}, | 816 | {"HPRCOM", NULL, "Right HP Com"}, |
821 | }; | 817 | }; |
822 | 818 | ||
819 | static const struct snd_soc_dapm_route intercon_mono[] = { | ||
820 | /* Mono Output */ | ||
821 | {"Mono Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, | ||
822 | {"Mono Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, | ||
823 | {"Mono Mixer", "DACL1 Switch", "Left DAC Mux"}, | ||
824 | {"Mono Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, | ||
825 | {"Mono Mixer", "PGAR Bypass Switch", "Right PGA Mixer"}, | ||
826 | {"Mono Mixer", "DACR1 Switch", "Right DAC Mux"}, | ||
827 | {"Mono Out", NULL, "Mono Mixer"}, | ||
828 | {"MONO_LOUT", NULL, "Mono Out"}, | ||
829 | }; | ||
830 | |||
823 | static const struct snd_soc_dapm_route intercon_3007[] = { | 831 | static const struct snd_soc_dapm_route intercon_3007[] = { |
824 | /* Class-D outputs */ | 832 | /* Class-D outputs */ |
825 | {"Left Class-D Out", NULL, "Left Line Out"}, | 833 | {"Left Class-D Out", NULL, "Left Line Out"}, |
@@ -833,11 +841,20 @@ static int aic3x_add_widgets(struct snd_soc_codec *codec) | |||
833 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); | 841 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); |
834 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 842 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
835 | 843 | ||
836 | if (aic3x->model == AIC3X_MODEL_3007) { | 844 | switch (aic3x->model) { |
845 | case AIC3X_MODEL_3X: | ||
846 | case AIC3X_MODEL_33: | ||
847 | snd_soc_dapm_new_controls(dapm, aic3x_dapm_mono_widgets, | ||
848 | ARRAY_SIZE(aic3x_dapm_mono_widgets)); | ||
849 | snd_soc_dapm_add_routes(dapm, intercon_mono, | ||
850 | ARRAY_SIZE(intercon_mono)); | ||
851 | break; | ||
852 | case AIC3X_MODEL_3007: | ||
837 | snd_soc_dapm_new_controls(dapm, aic3007_dapm_widgets, | 853 | snd_soc_dapm_new_controls(dapm, aic3007_dapm_widgets, |
838 | ARRAY_SIZE(aic3007_dapm_widgets)); | 854 | ARRAY_SIZE(aic3007_dapm_widgets)); |
839 | snd_soc_dapm_add_routes(dapm, intercon_3007, | 855 | snd_soc_dapm_add_routes(dapm, intercon_3007, |
840 | ARRAY_SIZE(intercon_3007)); | 856 | ARRAY_SIZE(intercon_3007)); |
857 | break; | ||
841 | } | 858 | } |
842 | 859 | ||
843 | return 0; | 860 | return 0; |
@@ -1218,6 +1235,24 @@ static int aic3x_resume(struct snd_soc_codec *codec) | |||
1218 | return 0; | 1235 | return 0; |
1219 | } | 1236 | } |
1220 | 1237 | ||
1238 | static void aic3x_mono_init(struct snd_soc_codec *codec) | ||
1239 | { | ||
1240 | /* DAC to Mono Line Out default volume and route to Output mixer */ | ||
1241 | snd_soc_write(codec, DACL1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); | ||
1242 | snd_soc_write(codec, DACR1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); | ||
1243 | |||
1244 | /* unmute all outputs */ | ||
1245 | snd_soc_update_bits(codec, MONOLOPM_CTRL, UNMUTE, UNMUTE); | ||
1246 | |||
1247 | /* PGA to Mono Line Out default volume, disconnect from Output Mixer */ | ||
1248 | snd_soc_write(codec, PGAL_2_MONOLOPM_VOL, DEFAULT_VOL); | ||
1249 | snd_soc_write(codec, PGAR_2_MONOLOPM_VOL, DEFAULT_VOL); | ||
1250 | |||
1251 | /* Line2 to Mono Out default volume, disconnect from Output Mixer */ | ||
1252 | snd_soc_write(codec, LINE2L_2_MONOLOPM_VOL, DEFAULT_VOL); | ||
1253 | snd_soc_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); | ||
1254 | } | ||
1255 | |||
1221 | /* | 1256 | /* |
1222 | * initialise the AIC3X driver | 1257 | * initialise the AIC3X driver |
1223 | * register the mixer and dsp interfaces with the kernel | 1258 | * register the mixer and dsp interfaces with the kernel |
@@ -1241,14 +1276,10 @@ static int aic3x_init(struct snd_soc_codec *codec) | |||
1241 | /* DAC to Line Out default volume and route to Output mixer */ | 1276 | /* DAC to Line Out default volume and route to Output mixer */ |
1242 | snd_soc_write(codec, DACL1_2_LLOPM_VOL, DEFAULT_VOL | ROUTE_ON); | 1277 | snd_soc_write(codec, DACL1_2_LLOPM_VOL, DEFAULT_VOL | ROUTE_ON); |
1243 | snd_soc_write(codec, DACR1_2_RLOPM_VOL, DEFAULT_VOL | ROUTE_ON); | 1278 | snd_soc_write(codec, DACR1_2_RLOPM_VOL, DEFAULT_VOL | ROUTE_ON); |
1244 | /* DAC to Mono Line Out default volume and route to Output mixer */ | ||
1245 | snd_soc_write(codec, DACL1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); | ||
1246 | snd_soc_write(codec, DACR1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); | ||
1247 | 1279 | ||
1248 | /* unmute all outputs */ | 1280 | /* unmute all outputs */ |
1249 | snd_soc_update_bits(codec, LLOPM_CTRL, UNMUTE, UNMUTE); | 1281 | snd_soc_update_bits(codec, LLOPM_CTRL, UNMUTE, UNMUTE); |
1250 | snd_soc_update_bits(codec, RLOPM_CTRL, UNMUTE, UNMUTE); | 1282 | snd_soc_update_bits(codec, RLOPM_CTRL, UNMUTE, UNMUTE); |
1251 | snd_soc_update_bits(codec, MONOLOPM_CTRL, UNMUTE, UNMUTE); | ||
1252 | snd_soc_update_bits(codec, HPLOUT_CTRL, UNMUTE, UNMUTE); | 1283 | snd_soc_update_bits(codec, HPLOUT_CTRL, UNMUTE, UNMUTE); |
1253 | snd_soc_update_bits(codec, HPROUT_CTRL, UNMUTE, UNMUTE); | 1284 | snd_soc_update_bits(codec, HPROUT_CTRL, UNMUTE, UNMUTE); |
1254 | snd_soc_update_bits(codec, HPLCOM_CTRL, UNMUTE, UNMUTE); | 1285 | snd_soc_update_bits(codec, HPLCOM_CTRL, UNMUTE, UNMUTE); |
@@ -1269,9 +1300,6 @@ static int aic3x_init(struct snd_soc_codec *codec) | |||
1269 | /* PGA to Line Out default volume, disconnect from Output Mixer */ | 1300 | /* PGA to Line Out default volume, disconnect from Output Mixer */ |
1270 | snd_soc_write(codec, PGAL_2_LLOPM_VOL, DEFAULT_VOL); | 1301 | snd_soc_write(codec, PGAL_2_LLOPM_VOL, DEFAULT_VOL); |
1271 | snd_soc_write(codec, PGAR_2_RLOPM_VOL, DEFAULT_VOL); | 1302 | snd_soc_write(codec, PGAR_2_RLOPM_VOL, DEFAULT_VOL); |
1272 | /* PGA to Mono Line Out default volume, disconnect from Output Mixer */ | ||
1273 | snd_soc_write(codec, PGAL_2_MONOLOPM_VOL, DEFAULT_VOL); | ||
1274 | snd_soc_write(codec, PGAR_2_MONOLOPM_VOL, DEFAULT_VOL); | ||
1275 | 1303 | ||
1276 | /* Line2 to HP Bypass default volume, disconnect from Output Mixer */ | 1304 | /* Line2 to HP Bypass default volume, disconnect from Output Mixer */ |
1277 | snd_soc_write(codec, LINE2L_2_HPLOUT_VOL, DEFAULT_VOL); | 1305 | snd_soc_write(codec, LINE2L_2_HPLOUT_VOL, DEFAULT_VOL); |
@@ -1281,12 +1309,15 @@ static int aic3x_init(struct snd_soc_codec *codec) | |||
1281 | /* Line2 Line Out default volume, disconnect from Output Mixer */ | 1309 | /* Line2 Line Out default volume, disconnect from Output Mixer */ |
1282 | snd_soc_write(codec, LINE2L_2_LLOPM_VOL, DEFAULT_VOL); | 1310 | snd_soc_write(codec, LINE2L_2_LLOPM_VOL, DEFAULT_VOL); |
1283 | snd_soc_write(codec, LINE2R_2_RLOPM_VOL, DEFAULT_VOL); | 1311 | snd_soc_write(codec, LINE2R_2_RLOPM_VOL, DEFAULT_VOL); |
1284 | /* Line2 to Mono Out default volume, disconnect from Output Mixer */ | ||
1285 | snd_soc_write(codec, LINE2L_2_MONOLOPM_VOL, DEFAULT_VOL); | ||
1286 | snd_soc_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); | ||
1287 | 1312 | ||
1288 | if (aic3x->model == AIC3X_MODEL_3007) { | 1313 | switch (aic3x->model) { |
1314 | case AIC3X_MODEL_3X: | ||
1315 | case AIC3X_MODEL_33: | ||
1316 | aic3x_mono_init(codec); | ||
1317 | break; | ||
1318 | case AIC3X_MODEL_3007: | ||
1289 | snd_soc_write(codec, CLASSD_CTRL, 0); | 1319 | snd_soc_write(codec, CLASSD_CTRL, 0); |
1320 | break; | ||
1290 | } | 1321 | } |
1291 | 1322 | ||
1292 | return 0; | 1323 | return 0; |
@@ -1343,8 +1374,17 @@ static int aic3x_probe(struct snd_soc_codec *codec) | |||
1343 | (aic3x->setup->gpio_func[1] & 0xf) << 4); | 1374 | (aic3x->setup->gpio_func[1] & 0xf) << 4); |
1344 | } | 1375 | } |
1345 | 1376 | ||
1346 | if (aic3x->model == AIC3X_MODEL_3007) | 1377 | switch (aic3x->model) { |
1347 | snd_soc_add_codec_controls(codec, &aic3x_classd_amp_gain_ctrl, 1); | 1378 | case AIC3X_MODEL_3X: |
1379 | case AIC3X_MODEL_33: | ||
1380 | snd_soc_add_codec_controls(codec, aic3x_mono_controls, | ||
1381 | ARRAY_SIZE(aic3x_mono_controls)); | ||
1382 | break; | ||
1383 | case AIC3X_MODEL_3007: | ||
1384 | snd_soc_add_codec_controls(codec, | ||
1385 | &aic3x_classd_amp_gain_ctrl, 1); | ||
1386 | break; | ||
1387 | } | ||
1348 | 1388 | ||
1349 | /* set mic bias voltage */ | 1389 | /* set mic bias voltage */ |
1350 | switch (aic3x->micbias_vg) { | 1390 | switch (aic3x->micbias_vg) { |
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index f2f4bcb2ff71..0afe8bef6765 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c | |||
@@ -72,6 +72,7 @@ struct twl6040_data { | |||
72 | int hs_power_mode_locked; | 72 | int hs_power_mode_locked; |
73 | bool dl1_unmuted; | 73 | bool dl1_unmuted; |
74 | bool dl2_unmuted; | 74 | bool dl2_unmuted; |
75 | u8 dl12_cache[TWL6040_REG_HFRCTL - TWL6040_REG_HSLCTL + 1]; | ||
75 | unsigned int clk_in; | 76 | unsigned int clk_in; |
76 | unsigned int sysclk; | 77 | unsigned int sysclk; |
77 | struct twl6040_jack_data hs_jack; | 78 | struct twl6040_jack_data hs_jack; |
@@ -79,75 +80,6 @@ struct twl6040_data { | |||
79 | struct mutex mutex; | 80 | struct mutex mutex; |
80 | }; | 81 | }; |
81 | 82 | ||
82 | /* | ||
83 | * twl6040 register cache & default register settings | ||
84 | */ | ||
85 | static const u8 twl6040_reg[TWL6040_CACHEREGNUM] = { | ||
86 | 0x00, /* not used 0x00 */ | ||
87 | 0x4B, /* REG_ASICID 0x01 (ro) */ | ||
88 | 0x00, /* REG_ASICREV 0x02 (ro) */ | ||
89 | 0x00, /* REG_INTID 0x03 */ | ||
90 | 0x00, /* REG_INTMR 0x04 */ | ||
91 | 0x00, /* REG_NCPCTRL 0x05 */ | ||
92 | 0x00, /* REG_LDOCTL 0x06 */ | ||
93 | 0x60, /* REG_HPPLLCTL 0x07 */ | ||
94 | 0x00, /* REG_LPPLLCTL 0x08 */ | ||
95 | 0x4A, /* REG_LPPLLDIV 0x09 */ | ||
96 | 0x00, /* REG_AMICBCTL 0x0A */ | ||
97 | 0x00, /* REG_DMICBCTL 0x0B */ | ||
98 | 0x00, /* REG_MICLCTL 0x0C */ | ||
99 | 0x00, /* REG_MICRCTL 0x0D */ | ||
100 | 0x00, /* REG_MICGAIN 0x0E */ | ||
101 | 0x1B, /* REG_LINEGAIN 0x0F */ | ||
102 | 0x00, /* REG_HSLCTL 0x10 */ | ||
103 | 0x00, /* REG_HSRCTL 0x11 */ | ||
104 | 0x00, /* REG_HSGAIN 0x12 */ | ||
105 | 0x00, /* REG_EARCTL 0x13 */ | ||
106 | 0x00, /* REG_HFLCTL 0x14 */ | ||
107 | 0x00, /* REG_HFLGAIN 0x15 */ | ||
108 | 0x00, /* REG_HFRCTL 0x16 */ | ||
109 | 0x00, /* REG_HFRGAIN 0x17 */ | ||
110 | 0x00, /* REG_VIBCTLL 0x18 */ | ||
111 | 0x00, /* REG_VIBDATL 0x19 */ | ||
112 | 0x00, /* REG_VIBCTLR 0x1A */ | ||
113 | 0x00, /* REG_VIBDATR 0x1B */ | ||
114 | 0x00, /* REG_HKCTL1 0x1C */ | ||
115 | 0x00, /* REG_HKCTL2 0x1D */ | ||
116 | 0x00, /* REG_GPOCTL 0x1E */ | ||
117 | 0x00, /* REG_ALB 0x1F */ | ||
118 | 0x00, /* REG_DLB 0x20 */ | ||
119 | 0x00, /* not used 0x21 */ | ||
120 | 0x00, /* not used 0x22 */ | ||
121 | 0x00, /* not used 0x23 */ | ||
122 | 0x00, /* not used 0x24 */ | ||
123 | 0x00, /* not used 0x25 */ | ||
124 | 0x00, /* not used 0x26 */ | ||
125 | 0x00, /* not used 0x27 */ | ||
126 | 0x00, /* REG_TRIM1 0x28 */ | ||
127 | 0x00, /* REG_TRIM2 0x29 */ | ||
128 | 0x00, /* REG_TRIM3 0x2A */ | ||
129 | 0x00, /* REG_HSOTRIM 0x2B */ | ||
130 | 0x00, /* REG_HFOTRIM 0x2C */ | ||
131 | 0x09, /* REG_ACCCTL 0x2D */ | ||
132 | 0x00, /* REG_STATUS 0x2E (ro) */ | ||
133 | }; | ||
134 | |||
135 | /* List of registers to be restored after power up */ | ||
136 | static const int twl6040_restore_list[] = { | ||
137 | TWL6040_REG_MICLCTL, | ||
138 | TWL6040_REG_MICRCTL, | ||
139 | TWL6040_REG_MICGAIN, | ||
140 | TWL6040_REG_LINEGAIN, | ||
141 | TWL6040_REG_HSLCTL, | ||
142 | TWL6040_REG_HSRCTL, | ||
143 | TWL6040_REG_HSGAIN, | ||
144 | TWL6040_REG_EARCTL, | ||
145 | TWL6040_REG_HFLCTL, | ||
146 | TWL6040_REG_HFLGAIN, | ||
147 | TWL6040_REG_HFRCTL, | ||
148 | TWL6040_REG_HFRGAIN, | ||
149 | }; | ||
150 | |||
151 | /* set of rates for each pll: low-power and high-performance */ | 83 | /* set of rates for each pll: low-power and high-performance */ |
152 | static unsigned int lp_rates[] = { | 84 | static unsigned int lp_rates[] = { |
153 | 8000, | 85 | 8000, |
@@ -174,53 +106,33 @@ static struct snd_pcm_hw_constraint_list sysclk_constraints[] = { | |||
174 | { .count = ARRAY_SIZE(hp_rates), .list = hp_rates, }, | 106 | { .count = ARRAY_SIZE(hp_rates), .list = hp_rates, }, |
175 | }; | 107 | }; |
176 | 108 | ||
177 | /* | 109 | static unsigned int twl6040_read(struct snd_soc_codec *codec, unsigned int reg) |
178 | * read twl6040 register cache | ||
179 | */ | ||
180 | static inline unsigned int twl6040_read_reg_cache(struct snd_soc_codec *codec, | ||
181 | unsigned int reg) | ||
182 | { | ||
183 | u8 *cache = codec->reg_cache; | ||
184 | |||
185 | if (reg >= TWL6040_CACHEREGNUM) | ||
186 | return -EIO; | ||
187 | |||
188 | return cache[reg]; | ||
189 | } | ||
190 | |||
191 | /* | ||
192 | * write twl6040 register cache | ||
193 | */ | ||
194 | static inline void twl6040_write_reg_cache(struct snd_soc_codec *codec, | ||
195 | u8 reg, u8 value) | ||
196 | { | ||
197 | u8 *cache = codec->reg_cache; | ||
198 | |||
199 | if (reg >= TWL6040_CACHEREGNUM) | ||
200 | return; | ||
201 | cache[reg] = value; | ||
202 | } | ||
203 | |||
204 | /* | ||
205 | * read from twl6040 hardware register | ||
206 | */ | ||
207 | static int twl6040_read_reg_volatile(struct snd_soc_codec *codec, | ||
208 | unsigned int reg) | ||
209 | { | 110 | { |
111 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); | ||
210 | struct twl6040 *twl6040 = codec->control_data; | 112 | struct twl6040 *twl6040 = codec->control_data; |
211 | u8 value; | 113 | u8 value; |
212 | 114 | ||
213 | if (reg >= TWL6040_CACHEREGNUM) | 115 | if (reg >= TWL6040_CACHEREGNUM) |
214 | return -EIO; | 116 | return -EIO; |
215 | 117 | ||
216 | value = twl6040_reg_read(twl6040, reg); | 118 | switch (reg) { |
217 | twl6040_write_reg_cache(codec, reg, value); | 119 | case TWL6040_REG_HSLCTL: |
120 | case TWL6040_REG_HSRCTL: | ||
121 | case TWL6040_REG_EARCTL: | ||
122 | case TWL6040_REG_HFLCTL: | ||
123 | case TWL6040_REG_HFRCTL: | ||
124 | value = priv->dl12_cache[reg - TWL6040_REG_HSLCTL]; | ||
125 | break; | ||
126 | default: | ||
127 | value = twl6040_reg_read(twl6040, reg); | ||
128 | break; | ||
129 | } | ||
218 | 130 | ||
219 | return value; | 131 | return value; |
220 | } | 132 | } |
221 | 133 | ||
222 | static bool twl6040_is_path_unmuted(struct snd_soc_codec *codec, | 134 | static bool twl6040_can_write_to_chip(struct snd_soc_codec *codec, |
223 | unsigned int reg) | 135 | unsigned int reg) |
224 | { | 136 | { |
225 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); | 137 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); |
226 | 138 | ||
@@ -238,9 +150,24 @@ static bool twl6040_is_path_unmuted(struct snd_soc_codec *codec, | |||
238 | } | 150 | } |
239 | } | 151 | } |
240 | 152 | ||
241 | /* | 153 | static inline void twl6040_update_dl12_cache(struct snd_soc_codec *codec, |
242 | * write to the twl6040 register space | 154 | u8 reg, u8 value) |
243 | */ | 155 | { |
156 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); | ||
157 | |||
158 | switch (reg) { | ||
159 | case TWL6040_REG_HSLCTL: | ||
160 | case TWL6040_REG_HSRCTL: | ||
161 | case TWL6040_REG_EARCTL: | ||
162 | case TWL6040_REG_HFLCTL: | ||
163 | case TWL6040_REG_HFRCTL: | ||
164 | priv->dl12_cache[reg - TWL6040_REG_HSLCTL] = value; | ||
165 | break; | ||
166 | default: | ||
167 | break; | ||
168 | } | ||
169 | } | ||
170 | |||
244 | static int twl6040_write(struct snd_soc_codec *codec, | 171 | static int twl6040_write(struct snd_soc_codec *codec, |
245 | unsigned int reg, unsigned int value) | 172 | unsigned int reg, unsigned int value) |
246 | { | 173 | { |
@@ -249,8 +176,8 @@ static int twl6040_write(struct snd_soc_codec *codec, | |||
249 | if (reg >= TWL6040_CACHEREGNUM) | 176 | if (reg >= TWL6040_CACHEREGNUM) |
250 | return -EIO; | 177 | return -EIO; |
251 | 178 | ||
252 | twl6040_write_reg_cache(codec, reg, value); | 179 | twl6040_update_dl12_cache(codec, reg, value); |
253 | if (twl6040_is_path_unmuted(codec, reg)) | 180 | if (twl6040_can_write_to_chip(codec, reg)) |
254 | return twl6040_reg_write(twl6040, reg, value); | 181 | return twl6040_reg_write(twl6040, reg, value); |
255 | else | 182 | else |
256 | return 0; | 183 | return 0; |
@@ -258,45 +185,27 @@ static int twl6040_write(struct snd_soc_codec *codec, | |||
258 | 185 | ||
259 | static void twl6040_init_chip(struct snd_soc_codec *codec) | 186 | static void twl6040_init_chip(struct snd_soc_codec *codec) |
260 | { | 187 | { |
261 | struct twl6040 *twl6040 = codec->control_data; | 188 | twl6040_read(codec, TWL6040_REG_TRIM1); |
262 | u8 val; | 189 | twl6040_read(codec, TWL6040_REG_TRIM2); |
263 | 190 | twl6040_read(codec, TWL6040_REG_TRIM3); | |
264 | /* Update reg_cache: ASICREV, and TRIM values */ | 191 | twl6040_read(codec, TWL6040_REG_HSOTRIM); |
265 | val = twl6040_get_revid(twl6040); | 192 | twl6040_read(codec, TWL6040_REG_HFOTRIM); |
266 | twl6040_write_reg_cache(codec, TWL6040_REG_ASICREV, val); | ||
267 | |||
268 | twl6040_read_reg_volatile(codec, TWL6040_REG_TRIM1); | ||
269 | twl6040_read_reg_volatile(codec, TWL6040_REG_TRIM2); | ||
270 | twl6040_read_reg_volatile(codec, TWL6040_REG_TRIM3); | ||
271 | twl6040_read_reg_volatile(codec, TWL6040_REG_HSOTRIM); | ||
272 | twl6040_read_reg_volatile(codec, TWL6040_REG_HFOTRIM); | ||
273 | 193 | ||
274 | /* Change chip defaults */ | 194 | /* Change chip defaults */ |
275 | /* No imput selected for microphone amplifiers */ | 195 | /* No imput selected for microphone amplifiers */ |
276 | twl6040_write_reg_cache(codec, TWL6040_REG_MICLCTL, 0x18); | 196 | twl6040_write(codec, TWL6040_REG_MICLCTL, 0x18); |
277 | twl6040_write_reg_cache(codec, TWL6040_REG_MICRCTL, 0x18); | 197 | twl6040_write(codec, TWL6040_REG_MICRCTL, 0x18); |
278 | 198 | ||
279 | /* | 199 | /* |
280 | * We need to lower the default gain values, so the ramp code | 200 | * We need to lower the default gain values, so the ramp code |
281 | * can work correctly for the first playback. | 201 | * can work correctly for the first playback. |
282 | * This reduces the pop noise heard at the first playback. | 202 | * This reduces the pop noise heard at the first playback. |
283 | */ | 203 | */ |
284 | twl6040_write_reg_cache(codec, TWL6040_REG_HSGAIN, 0xff); | 204 | twl6040_write(codec, TWL6040_REG_HSGAIN, 0xff); |
285 | twl6040_write_reg_cache(codec, TWL6040_REG_EARCTL, 0x1e); | 205 | twl6040_write(codec, TWL6040_REG_EARCTL, 0x1e); |
286 | twl6040_write_reg_cache(codec, TWL6040_REG_HFLGAIN, 0x1d); | 206 | twl6040_write(codec, TWL6040_REG_HFLGAIN, 0x1d); |
287 | twl6040_write_reg_cache(codec, TWL6040_REG_HFRGAIN, 0x1d); | 207 | twl6040_write(codec, TWL6040_REG_HFRGAIN, 0x1d); |
288 | twl6040_write_reg_cache(codec, TWL6040_REG_LINEGAIN, 0); | 208 | twl6040_write(codec, TWL6040_REG_LINEGAIN, 0); |
289 | } | ||
290 | |||
291 | static void twl6040_restore_regs(struct snd_soc_codec *codec) | ||
292 | { | ||
293 | u8 *cache = codec->reg_cache; | ||
294 | int reg, i; | ||
295 | |||
296 | for (i = 0; i < ARRAY_SIZE(twl6040_restore_list); i++) { | ||
297 | reg = twl6040_restore_list[i]; | ||
298 | twl6040_write(codec, reg, cache[reg]); | ||
299 | } | ||
300 | } | 209 | } |
301 | 210 | ||
302 | /* set headset dac and driver power mode */ | 211 | /* set headset dac and driver power mode */ |
@@ -305,8 +214,8 @@ static int headset_power_mode(struct snd_soc_codec *codec, int high_perf) | |||
305 | int hslctl, hsrctl; | 214 | int hslctl, hsrctl; |
306 | int mask = TWL6040_HSDRVMODE | TWL6040_HSDACMODE; | 215 | int mask = TWL6040_HSDRVMODE | TWL6040_HSDACMODE; |
307 | 216 | ||
308 | hslctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSLCTL); | 217 | hslctl = twl6040_read(codec, TWL6040_REG_HSLCTL); |
309 | hsrctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSRCTL); | 218 | hsrctl = twl6040_read(codec, TWL6040_REG_HSRCTL); |
310 | 219 | ||
311 | if (high_perf) { | 220 | if (high_perf) { |
312 | hslctl &= ~mask; | 221 | hslctl &= ~mask; |
@@ -333,8 +242,8 @@ static int twl6040_hs_dac_event(struct snd_soc_dapm_widget *w, | |||
333 | * Both HS DAC need to be turned on (before the HS driver) and off at | 242 | * Both HS DAC need to be turned on (before the HS driver) and off at |
334 | * the same time. | 243 | * the same time. |
335 | */ | 244 | */ |
336 | hslctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSLCTL); | 245 | hslctl = twl6040_read(codec, TWL6040_REG_HSLCTL); |
337 | hsrctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSRCTL); | 246 | hsrctl = twl6040_read(codec, TWL6040_REG_HSRCTL); |
338 | if (SND_SOC_DAPM_EVENT_ON(event)) { | 247 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
339 | hslctl |= TWL6040_HSDACENA; | 248 | hslctl |= TWL6040_HSDACENA; |
340 | hsrctl |= TWL6040_HSDACENA; | 249 | hsrctl |= TWL6040_HSDACENA; |
@@ -379,7 +288,7 @@ static void twl6040_hs_jack_report(struct snd_soc_codec *codec, | |||
379 | mutex_lock(&priv->mutex); | 288 | mutex_lock(&priv->mutex); |
380 | 289 | ||
381 | /* Sync status */ | 290 | /* Sync status */ |
382 | status = twl6040_read_reg_volatile(codec, TWL6040_REG_STATUS); | 291 | status = twl6040_read(codec, TWL6040_REG_STATUS); |
383 | if (status & TWL6040_PLUGCOMP) | 292 | if (status & TWL6040_PLUGCOMP) |
384 | snd_soc_jack_report(jack, report, report); | 293 | snd_soc_jack_report(jack, report, report); |
385 | else | 294 | else |
@@ -431,7 +340,7 @@ static int twl6040_soc_dapm_put_vibra_enum(struct snd_kcontrol *kcontrol, | |||
431 | unsigned int val; | 340 | unsigned int val; |
432 | 341 | ||
433 | /* Do not allow changes while Input/FF efect is running */ | 342 | /* Do not allow changes while Input/FF efect is running */ |
434 | val = twl6040_read_reg_volatile(codec, e->reg); | 343 | val = twl6040_read(codec, e->reg); |
435 | if (val & TWL6040_VIBENA && !(val & TWL6040_VIBSEL)) | 344 | if (val & TWL6040_VIBENA && !(val & TWL6040_VIBSEL)) |
436 | return -EBUSY; | 345 | return -EBUSY; |
437 | 346 | ||
@@ -656,7 +565,7 @@ int twl6040_get_trim_value(struct snd_soc_codec *codec, enum twl6040_trim trim) | |||
656 | if (unlikely(trim >= TWL6040_TRIM_INVAL)) | 565 | if (unlikely(trim >= TWL6040_TRIM_INVAL)) |
657 | return -EINVAL; | 566 | return -EINVAL; |
658 | 567 | ||
659 | return twl6040_read_reg_cache(codec, TWL6040_REG_TRIM1 + trim); | 568 | return twl6040_read(codec, TWL6040_REG_TRIM1 + trim); |
660 | } | 569 | } |
661 | EXPORT_SYMBOL_GPL(twl6040_get_trim_value); | 570 | EXPORT_SYMBOL_GPL(twl6040_get_trim_value); |
662 | 571 | ||
@@ -931,8 +840,6 @@ static int twl6040_set_bias_level(struct snd_soc_codec *codec, | |||
931 | 840 | ||
932 | priv->codec_powered = 1; | 841 | priv->codec_powered = 1; |
933 | 842 | ||
934 | twl6040_restore_regs(codec); | ||
935 | |||
936 | /* Set external boost GPO */ | 843 | /* Set external boost GPO */ |
937 | twl6040_write(codec, TWL6040_REG_GPOCTL, 0x02); | 844 | twl6040_write(codec, TWL6040_REG_GPOCTL, 0x02); |
938 | break; | 845 | break; |
@@ -1053,9 +960,9 @@ static void twl6040_mute_path(struct snd_soc_codec *codec, enum twl6040_dai_id i | |||
1053 | 960 | ||
1054 | switch (id) { | 961 | switch (id) { |
1055 | case TWL6040_DAI_DL1: | 962 | case TWL6040_DAI_DL1: |
1056 | hslctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSLCTL); | 963 | hslctl = twl6040_read(codec, TWL6040_REG_HSLCTL); |
1057 | hsrctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSRCTL); | 964 | hsrctl = twl6040_read(codec, TWL6040_REG_HSRCTL); |
1058 | earctl = twl6040_read_reg_cache(codec, TWL6040_REG_EARCTL); | 965 | earctl = twl6040_read(codec, TWL6040_REG_EARCTL); |
1059 | 966 | ||
1060 | if (mute) { | 967 | if (mute) { |
1061 | /* Power down drivers and DACs */ | 968 | /* Power down drivers and DACs */ |
@@ -1071,8 +978,8 @@ static void twl6040_mute_path(struct snd_soc_codec *codec, enum twl6040_dai_id i | |||
1071 | priv->dl1_unmuted = !mute; | 978 | priv->dl1_unmuted = !mute; |
1072 | break; | 979 | break; |
1073 | case TWL6040_DAI_DL2: | 980 | case TWL6040_DAI_DL2: |
1074 | hflctl = twl6040_read_reg_cache(codec, TWL6040_REG_HFLCTL); | 981 | hflctl = twl6040_read(codec, TWL6040_REG_HFLCTL); |
1075 | hfrctl = twl6040_read_reg_cache(codec, TWL6040_REG_HFRCTL); | 982 | hfrctl = twl6040_read(codec, TWL6040_REG_HFRCTL); |
1076 | 983 | ||
1077 | if (mute) { | 984 | if (mute) { |
1078 | /* Power down drivers and DACs */ | 985 | /* Power down drivers and DACs */ |
@@ -1209,6 +1116,7 @@ static int twl6040_resume(struct snd_soc_codec *codec) | |||
1209 | static int twl6040_probe(struct snd_soc_codec *codec) | 1116 | static int twl6040_probe(struct snd_soc_codec *codec) |
1210 | { | 1117 | { |
1211 | struct twl6040_data *priv; | 1118 | struct twl6040_data *priv; |
1119 | struct twl6040 *twl6040 = dev_get_drvdata(codec->dev->parent); | ||
1212 | struct platform_device *pdev = container_of(codec->dev, | 1120 | struct platform_device *pdev = container_of(codec->dev, |
1213 | struct platform_device, dev); | 1121 | struct platform_device, dev); |
1214 | int ret = 0; | 1122 | int ret = 0; |
@@ -1220,7 +1128,7 @@ static int twl6040_probe(struct snd_soc_codec *codec) | |||
1220 | snd_soc_codec_set_drvdata(codec, priv); | 1128 | snd_soc_codec_set_drvdata(codec, priv); |
1221 | 1129 | ||
1222 | priv->codec = codec; | 1130 | priv->codec = codec; |
1223 | codec->control_data = dev_get_drvdata(codec->dev->parent); | 1131 | codec->control_data = twl6040; |
1224 | 1132 | ||
1225 | priv->plug_irq = platform_get_irq(pdev, 0); | 1133 | priv->plug_irq = platform_get_irq(pdev, 0); |
1226 | if (priv->plug_irq < 0) { | 1134 | if (priv->plug_irq < 0) { |
@@ -1240,10 +1148,10 @@ static int twl6040_probe(struct snd_soc_codec *codec) | |||
1240 | return ret; | 1148 | return ret; |
1241 | } | 1149 | } |
1242 | 1150 | ||
1151 | twl6040_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
1243 | twl6040_init_chip(codec); | 1152 | twl6040_init_chip(codec); |
1244 | 1153 | ||
1245 | /* power on device */ | 1154 | return 0; |
1246 | return twl6040_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
1247 | } | 1155 | } |
1248 | 1156 | ||
1249 | static int twl6040_remove(struct snd_soc_codec *codec) | 1157 | static int twl6040_remove(struct snd_soc_codec *codec) |
@@ -1261,12 +1169,9 @@ static struct snd_soc_codec_driver soc_codec_dev_twl6040 = { | |||
1261 | .remove = twl6040_remove, | 1169 | .remove = twl6040_remove, |
1262 | .suspend = twl6040_suspend, | 1170 | .suspend = twl6040_suspend, |
1263 | .resume = twl6040_resume, | 1171 | .resume = twl6040_resume, |
1264 | .read = twl6040_read_reg_cache, | 1172 | .read = twl6040_read, |
1265 | .write = twl6040_write, | 1173 | .write = twl6040_write, |
1266 | .set_bias_level = twl6040_set_bias_level, | 1174 | .set_bias_level = twl6040_set_bias_level, |
1267 | .reg_cache_size = ARRAY_SIZE(twl6040_reg), | ||
1268 | .reg_word_size = sizeof(u8), | ||
1269 | .reg_cache_default = twl6040_reg, | ||
1270 | .ignore_pmdown_time = true, | 1175 | .ignore_pmdown_time = true, |
1271 | 1176 | ||
1272 | .controls = twl6040_snd_controls, | 1177 | .controls = twl6040_snd_controls, |
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index fd0a314bc209..726df6d43c2b 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c | |||
@@ -794,7 +794,7 @@ static struct snd_soc_codec_driver soc_codec_dev_uda1380 = { | |||
794 | .num_dapm_routes = ARRAY_SIZE(uda1380_dapm_routes), | 794 | .num_dapm_routes = ARRAY_SIZE(uda1380_dapm_routes), |
795 | }; | 795 | }; |
796 | 796 | ||
797 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 797 | #if IS_ENABLED(CONFIG_I2C) |
798 | static int uda1380_i2c_probe(struct i2c_client *i2c, | 798 | static int uda1380_i2c_probe(struct i2c_client *i2c, |
799 | const struct i2c_device_id *id) | 799 | const struct i2c_device_id *id) |
800 | { | 800 | { |
@@ -840,7 +840,7 @@ static struct i2c_driver uda1380_i2c_driver = { | |||
840 | static int __init uda1380_modinit(void) | 840 | static int __init uda1380_modinit(void) |
841 | { | 841 | { |
842 | int ret = 0; | 842 | int ret = 0; |
843 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 843 | #if IS_ENABLED(CONFIG_I2C) |
844 | ret = i2c_add_driver(&uda1380_i2c_driver); | 844 | ret = i2c_add_driver(&uda1380_i2c_driver); |
845 | if (ret != 0) | 845 | if (ret != 0) |
846 | pr_err("Failed to register UDA1380 I2C driver: %d\n", ret); | 846 | pr_err("Failed to register UDA1380 I2C driver: %d\n", ret); |
@@ -851,7 +851,7 @@ module_init(uda1380_modinit); | |||
851 | 851 | ||
852 | static void __exit uda1380_exit(void) | 852 | static void __exit uda1380_exit(void) |
853 | { | 853 | { |
854 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 854 | #if IS_ENABLED(CONFIG_I2C) |
855 | i2c_del_driver(&uda1380_i2c_driver); | 855 | i2c_del_driver(&uda1380_i2c_driver); |
856 | #endif | 856 | #endif |
857 | } | 857 | } |
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index a08e8bf6d07c..ce9c8e14d4bd 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c | |||
@@ -601,8 +601,8 @@ static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w, | |||
601 | case SND_SOC_DAPM_POST_PMU: | 601 | case SND_SOC_DAPM_POST_PMU: |
602 | if (patch) | 602 | if (patch) |
603 | for (i = 0; i < patch_size; i++) | 603 | for (i = 0; i < patch_size; i++) |
604 | regmap_write(regmap, patch[i].reg, | 604 | regmap_write_async(regmap, patch[i].reg, |
605 | patch[i].def); | 605 | patch[i].def); |
606 | break; | 606 | break; |
607 | 607 | ||
608 | default: | 608 | default: |
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 0ab2dc296474..22bd7dd80bba 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c | |||
@@ -30,13 +30,51 @@ | |||
30 | #include <linux/mfd/arizona/registers.h> | 30 | #include <linux/mfd/arizona/registers.h> |
31 | 31 | ||
32 | #include "arizona.h" | 32 | #include "arizona.h" |
33 | #include "wm_adsp.h" | ||
33 | #include "wm5110.h" | 34 | #include "wm5110.h" |
34 | 35 | ||
36 | #define WM5110_NUM_ADSP 4 | ||
37 | |||
35 | struct wm5110_priv { | 38 | struct wm5110_priv { |
36 | struct arizona_priv core; | 39 | struct arizona_priv core; |
37 | struct arizona_fll fll[2]; | 40 | struct arizona_fll fll[2]; |
38 | }; | 41 | }; |
39 | 42 | ||
43 | static const struct wm_adsp_region wm5110_dsp1_regions[] = { | ||
44 | { .type = WMFW_ADSP2_PM, .base = 0x100000 }, | ||
45 | { .type = WMFW_ADSP2_ZM, .base = 0x180000 }, | ||
46 | { .type = WMFW_ADSP2_XM, .base = 0x190000 }, | ||
47 | { .type = WMFW_ADSP2_YM, .base = 0x1a8000 }, | ||
48 | }; | ||
49 | |||
50 | static const struct wm_adsp_region wm5110_dsp2_regions[] = { | ||
51 | { .type = WMFW_ADSP2_PM, .base = 0x200000 }, | ||
52 | { .type = WMFW_ADSP2_ZM, .base = 0x280000 }, | ||
53 | { .type = WMFW_ADSP2_XM, .base = 0x290000 }, | ||
54 | { .type = WMFW_ADSP2_YM, .base = 0x2a8000 }, | ||
55 | }; | ||
56 | |||
57 | static const struct wm_adsp_region wm5110_dsp3_regions[] = { | ||
58 | { .type = WMFW_ADSP2_PM, .base = 0x300000 }, | ||
59 | { .type = WMFW_ADSP2_ZM, .base = 0x380000 }, | ||
60 | { .type = WMFW_ADSP2_XM, .base = 0x390000 }, | ||
61 | { .type = WMFW_ADSP2_YM, .base = 0x3a8000 }, | ||
62 | }; | ||
63 | |||
64 | static const struct wm_adsp_region wm5110_dsp4_regions[] = { | ||
65 | { .type = WMFW_ADSP2_PM, .base = 0x400000 }, | ||
66 | { .type = WMFW_ADSP2_ZM, .base = 0x480000 }, | ||
67 | { .type = WMFW_ADSP2_XM, .base = 0x490000 }, | ||
68 | { .type = WMFW_ADSP2_YM, .base = 0x4a8000 }, | ||
69 | }; | ||
70 | |||
71 | static const struct wm_adsp_region *wm5110_dsp_regions[] = { | ||
72 | wm5110_dsp1_regions, | ||
73 | wm5110_dsp2_regions, | ||
74 | wm5110_dsp3_regions, | ||
75 | wm5110_dsp4_regions, | ||
76 | }; | ||
77 | |||
40 | static const struct reg_default wm5110_sysclk_revd_patch[] = { | 78 | static const struct reg_default wm5110_sysclk_revd_patch[] = { |
41 | { 0x3093, 0x1001 }, | 79 | { 0x3093, 0x1001 }, |
42 | { 0x30E3, 0x1301 }, | 80 | { 0x30E3, 0x1301 }, |
@@ -67,8 +105,8 @@ static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w, | |||
67 | case SND_SOC_DAPM_POST_PMU: | 105 | case SND_SOC_DAPM_POST_PMU: |
68 | if (patch) | 106 | if (patch) |
69 | for (i = 0; i < patch_size; i++) | 107 | for (i = 0; i < patch_size; i++) |
70 | regmap_write(regmap, patch[i].reg, | 108 | regmap_write_async(regmap, patch[i].reg, |
71 | patch[i].def); | 109 | patch[i].def); |
72 | break; | 110 | break; |
73 | 111 | ||
74 | default: | 112 | default: |
@@ -117,6 +155,25 @@ SOC_SINGLE_RANGE_TLV("IN3L Volume", ARIZONA_IN3L_CONTROL, | |||
117 | SOC_SINGLE_RANGE_TLV("IN3R Volume", ARIZONA_IN3R_CONTROL, | 155 | SOC_SINGLE_RANGE_TLV("IN3R Volume", ARIZONA_IN3R_CONTROL, |
118 | ARIZONA_IN3R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), | 156 | ARIZONA_IN3R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), |
119 | 157 | ||
158 | SOC_ENUM("IN HPF Cutoff Frequency", arizona_in_hpf_cut_enum), | ||
159 | |||
160 | SOC_SINGLE("IN1L HPF Switch", ARIZONA_IN1L_CONTROL, | ||
161 | ARIZONA_IN1L_HPF_SHIFT, 1, 0), | ||
162 | SOC_SINGLE("IN1R HPF Switch", ARIZONA_IN1R_CONTROL, | ||
163 | ARIZONA_IN1R_HPF_SHIFT, 1, 0), | ||
164 | SOC_SINGLE("IN2L HPF Switch", ARIZONA_IN2L_CONTROL, | ||
165 | ARIZONA_IN2L_HPF_SHIFT, 1, 0), | ||
166 | SOC_SINGLE("IN2R HPF Switch", ARIZONA_IN2R_CONTROL, | ||
167 | ARIZONA_IN2R_HPF_SHIFT, 1, 0), | ||
168 | SOC_SINGLE("IN3L HPF Switch", ARIZONA_IN3L_CONTROL, | ||
169 | ARIZONA_IN3L_HPF_SHIFT, 1, 0), | ||
170 | SOC_SINGLE("IN3R HPF Switch", ARIZONA_IN3R_CONTROL, | ||
171 | ARIZONA_IN3R_HPF_SHIFT, 1, 0), | ||
172 | SOC_SINGLE("IN4L HPF Switch", ARIZONA_IN4L_CONTROL, | ||
173 | ARIZONA_IN4L_HPF_SHIFT, 1, 0), | ||
174 | SOC_SINGLE("IN4R HPF Switch", ARIZONA_IN4R_CONTROL, | ||
175 | ARIZONA_IN4R_HPF_SHIFT, 1, 0), | ||
176 | |||
120 | SOC_SINGLE_TLV("IN1L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L, | 177 | SOC_SINGLE_TLV("IN1L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L, |
121 | ARIZONA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv), | 178 | ARIZONA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv), |
122 | SOC_SINGLE_TLV("IN1R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1R, | 179 | SOC_SINGLE_TLV("IN1R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1R, |
@@ -220,6 +277,14 @@ SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), | |||
220 | SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), | 277 | SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), |
221 | SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode), | 278 | SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode), |
222 | 279 | ||
280 | SOC_VALUE_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), | ||
281 | SOC_VALUE_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), | ||
282 | SOC_VALUE_ENUM("ISRC3 FSL", arizona_isrc_fsl[2]), | ||
283 | SOC_VALUE_ENUM("ISRC1 FSH", arizona_isrc_fsh[0]), | ||
284 | SOC_VALUE_ENUM("ISRC2 FSH", arizona_isrc_fsh[1]), | ||
285 | SOC_VALUE_ENUM("ISRC3 FSH", arizona_isrc_fsh[2]), | ||
286 | SOC_VALUE_ENUM("ASRC RATE 1", arizona_asrc_rate1), | ||
287 | |||
223 | ARIZONA_MIXER_CONTROLS("DSP1L", ARIZONA_DSP1LMIX_INPUT_1_SOURCE), | 288 | ARIZONA_MIXER_CONTROLS("DSP1L", ARIZONA_DSP1LMIX_INPUT_1_SOURCE), |
224 | ARIZONA_MIXER_CONTROLS("DSP1R", ARIZONA_DSP1RMIX_INPUT_1_SOURCE), | 289 | ARIZONA_MIXER_CONTROLS("DSP1R", ARIZONA_DSP1RMIX_INPUT_1_SOURCE), |
225 | ARIZONA_MIXER_CONTROLS("DSP2L", ARIZONA_DSP2LMIX_INPUT_1_SOURCE), | 290 | ARIZONA_MIXER_CONTROLS("DSP2L", ARIZONA_DSP2LMIX_INPUT_1_SOURCE), |
@@ -285,6 +350,13 @@ SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT, | |||
285 | SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT, | 350 | SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT, |
286 | ARIZONA_SPK2R_MUTE_SHIFT, 1, 1), | 351 | ARIZONA_SPK2R_MUTE_SHIFT, 1, 1), |
287 | 352 | ||
353 | SOC_DOUBLE("HPOUT1 DRE Switch", ARIZONA_DRE_ENABLE, | ||
354 | ARIZONA_DRE1L_ENA_SHIFT, ARIZONA_DRE1R_ENA_SHIFT, 1, 0), | ||
355 | SOC_DOUBLE("HPOUT2 DRE Switch", ARIZONA_DRE_ENABLE, | ||
356 | ARIZONA_DRE2L_ENA_SHIFT, ARIZONA_DRE2R_ENA_SHIFT, 1, 0), | ||
357 | SOC_DOUBLE("HPOUT3 DRE Switch", ARIZONA_DRE_ENABLE, | ||
358 | ARIZONA_DRE3L_ENA_SHIFT, ARIZONA_DRE3R_ENA_SHIFT, 1, 0), | ||
359 | |||
288 | SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp), | 360 | SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp), |
289 | SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp), | 361 | SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp), |
290 | 362 | ||
@@ -318,6 +390,10 @@ ARIZONA_MIXER_CONTROLS("AIF1TX8", ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE), | |||
318 | 390 | ||
319 | ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE), | 391 | ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE), |
320 | ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE), | 392 | ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE), |
393 | ARIZONA_MIXER_CONTROLS("AIF2TX3", ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE), | ||
394 | ARIZONA_MIXER_CONTROLS("AIF2TX4", ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE), | ||
395 | ARIZONA_MIXER_CONTROLS("AIF2TX5", ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE), | ||
396 | ARIZONA_MIXER_CONTROLS("AIF2TX6", ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE), | ||
321 | 397 | ||
322 | ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE), | 398 | ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE), |
323 | ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE), | 399 | ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE), |
@@ -347,6 +423,22 @@ ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE); | |||
347 | ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE); | 423 | ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE); |
348 | ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE); | 424 | ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE); |
349 | 425 | ||
426 | ARIZONA_MIXER_ENUMS(DSP1L, ARIZONA_DSP1LMIX_INPUT_1_SOURCE); | ||
427 | ARIZONA_MIXER_ENUMS(DSP1R, ARIZONA_DSP1RMIX_INPUT_1_SOURCE); | ||
428 | ARIZONA_DSP_AUX_ENUMS(DSP1, ARIZONA_DSP1AUX1MIX_INPUT_1_SOURCE); | ||
429 | |||
430 | ARIZONA_MIXER_ENUMS(DSP2L, ARIZONA_DSP2LMIX_INPUT_1_SOURCE); | ||
431 | ARIZONA_MIXER_ENUMS(DSP2R, ARIZONA_DSP2RMIX_INPUT_1_SOURCE); | ||
432 | ARIZONA_DSP_AUX_ENUMS(DSP2, ARIZONA_DSP2AUX1MIX_INPUT_1_SOURCE); | ||
433 | |||
434 | ARIZONA_MIXER_ENUMS(DSP3L, ARIZONA_DSP3LMIX_INPUT_1_SOURCE); | ||
435 | ARIZONA_MIXER_ENUMS(DSP3R, ARIZONA_DSP3RMIX_INPUT_1_SOURCE); | ||
436 | ARIZONA_DSP_AUX_ENUMS(DSP3, ARIZONA_DSP3AUX1MIX_INPUT_1_SOURCE); | ||
437 | |||
438 | ARIZONA_MIXER_ENUMS(DSP4L, ARIZONA_DSP4LMIX_INPUT_1_SOURCE); | ||
439 | ARIZONA_MIXER_ENUMS(DSP4R, ARIZONA_DSP4RMIX_INPUT_1_SOURCE); | ||
440 | ARIZONA_DSP_AUX_ENUMS(DSP4, ARIZONA_DSP4AUX1MIX_INPUT_1_SOURCE); | ||
441 | |||
350 | ARIZONA_MIXER_ENUMS(Mic, ARIZONA_MICMIX_INPUT_1_SOURCE); | 442 | ARIZONA_MIXER_ENUMS(Mic, ARIZONA_MICMIX_INPUT_1_SOURCE); |
351 | ARIZONA_MIXER_ENUMS(Noise, ARIZONA_NOISEMIX_INPUT_1_SOURCE); | 443 | ARIZONA_MIXER_ENUMS(Noise, ARIZONA_NOISEMIX_INPUT_1_SOURCE); |
352 | 444 | ||
@@ -377,6 +469,10 @@ ARIZONA_MIXER_ENUMS(AIF1TX8, ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE); | |||
377 | 469 | ||
378 | ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE); | 470 | ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE); |
379 | ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE); | 471 | ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE); |
472 | ARIZONA_MIXER_ENUMS(AIF2TX3, ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE); | ||
473 | ARIZONA_MIXER_ENUMS(AIF2TX4, ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE); | ||
474 | ARIZONA_MIXER_ENUMS(AIF2TX5, ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE); | ||
475 | ARIZONA_MIXER_ENUMS(AIF2TX6, ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE); | ||
380 | 476 | ||
381 | ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE); | 477 | ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE); |
382 | ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE); | 478 | ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE); |
@@ -395,6 +491,36 @@ ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE); | |||
395 | ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); | 491 | ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); |
396 | ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); | 492 | ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); |
397 | 493 | ||
494 | ARIZONA_MUX_ENUMS(ISRC1INT1, ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE); | ||
495 | ARIZONA_MUX_ENUMS(ISRC1INT2, ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE); | ||
496 | ARIZONA_MUX_ENUMS(ISRC1INT3, ARIZONA_ISRC1INT3MIX_INPUT_1_SOURCE); | ||
497 | ARIZONA_MUX_ENUMS(ISRC1INT4, ARIZONA_ISRC1INT4MIX_INPUT_1_SOURCE); | ||
498 | |||
499 | ARIZONA_MUX_ENUMS(ISRC1DEC1, ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE); | ||
500 | ARIZONA_MUX_ENUMS(ISRC1DEC2, ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE); | ||
501 | ARIZONA_MUX_ENUMS(ISRC1DEC3, ARIZONA_ISRC1DEC3MIX_INPUT_1_SOURCE); | ||
502 | ARIZONA_MUX_ENUMS(ISRC1DEC4, ARIZONA_ISRC1DEC4MIX_INPUT_1_SOURCE); | ||
503 | |||
504 | ARIZONA_MUX_ENUMS(ISRC2INT1, ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE); | ||
505 | ARIZONA_MUX_ENUMS(ISRC2INT2, ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE); | ||
506 | ARIZONA_MUX_ENUMS(ISRC2INT3, ARIZONA_ISRC2INT3MIX_INPUT_1_SOURCE); | ||
507 | ARIZONA_MUX_ENUMS(ISRC2INT4, ARIZONA_ISRC2INT4MIX_INPUT_1_SOURCE); | ||
508 | |||
509 | ARIZONA_MUX_ENUMS(ISRC2DEC1, ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE); | ||
510 | ARIZONA_MUX_ENUMS(ISRC2DEC2, ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE); | ||
511 | ARIZONA_MUX_ENUMS(ISRC2DEC3, ARIZONA_ISRC2DEC3MIX_INPUT_1_SOURCE); | ||
512 | ARIZONA_MUX_ENUMS(ISRC2DEC4, ARIZONA_ISRC2DEC4MIX_INPUT_1_SOURCE); | ||
513 | |||
514 | ARIZONA_MUX_ENUMS(ISRC3INT1, ARIZONA_ISRC3INT1MIX_INPUT_1_SOURCE); | ||
515 | ARIZONA_MUX_ENUMS(ISRC3INT2, ARIZONA_ISRC3INT2MIX_INPUT_1_SOURCE); | ||
516 | ARIZONA_MUX_ENUMS(ISRC3INT3, ARIZONA_ISRC3INT3MIX_INPUT_1_SOURCE); | ||
517 | ARIZONA_MUX_ENUMS(ISRC3INT4, ARIZONA_ISRC3INT4MIX_INPUT_1_SOURCE); | ||
518 | |||
519 | ARIZONA_MUX_ENUMS(ISRC3DEC1, ARIZONA_ISRC3DEC1MIX_INPUT_1_SOURCE); | ||
520 | ARIZONA_MUX_ENUMS(ISRC3DEC2, ARIZONA_ISRC3DEC2MIX_INPUT_1_SOURCE); | ||
521 | ARIZONA_MUX_ENUMS(ISRC3DEC3, ARIZONA_ISRC3DEC3MIX_INPUT_1_SOURCE); | ||
522 | ARIZONA_MUX_ENUMS(ISRC3DEC4, ARIZONA_ISRC3DEC4MIX_INPUT_1_SOURCE); | ||
523 | |||
398 | static const char *wm5110_aec_loopback_texts[] = { | 524 | static const char *wm5110_aec_loopback_texts[] = { |
399 | "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "HPOUT3L", "HPOUT3R", | 525 | "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "HPOUT3L", "HPOUT3R", |
400 | "SPKOUTL", "SPKOUTR", "SPKDAT1L", "SPKDAT1R", "SPKDAT2L", "SPKDAT2R", | 526 | "SPKOUTL", "SPKOUTR", "SPKDAT1L", "SPKDAT1R", "SPKDAT2L", "SPKDAT2R", |
@@ -535,6 +661,65 @@ SND_SOC_DAPM_PGA("ASRC2L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2L_ENA_SHIFT, 0, | |||
535 | SND_SOC_DAPM_PGA("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0, | 661 | SND_SOC_DAPM_PGA("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0, |
536 | NULL, 0), | 662 | NULL, 0), |
537 | 663 | ||
664 | WM_ADSP2("DSP1", 0), | ||
665 | WM_ADSP2("DSP2", 1), | ||
666 | WM_ADSP2("DSP3", 2), | ||
667 | WM_ADSP2("DSP4", 3), | ||
668 | |||
669 | SND_SOC_DAPM_PGA("ISRC1INT1", ARIZONA_ISRC_1_CTRL_3, | ||
670 | ARIZONA_ISRC1_INT0_ENA_SHIFT, 0, NULL, 0), | ||
671 | SND_SOC_DAPM_PGA("ISRC1INT2", ARIZONA_ISRC_1_CTRL_3, | ||
672 | ARIZONA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0), | ||
673 | SND_SOC_DAPM_PGA("ISRC1INT3", ARIZONA_ISRC_1_CTRL_3, | ||
674 | ARIZONA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0), | ||
675 | SND_SOC_DAPM_PGA("ISRC1INT4", ARIZONA_ISRC_1_CTRL_3, | ||
676 | ARIZONA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0), | ||
677 | |||
678 | SND_SOC_DAPM_PGA("ISRC1DEC1", ARIZONA_ISRC_1_CTRL_3, | ||
679 | ARIZONA_ISRC1_DEC0_ENA_SHIFT, 0, NULL, 0), | ||
680 | SND_SOC_DAPM_PGA("ISRC1DEC2", ARIZONA_ISRC_1_CTRL_3, | ||
681 | ARIZONA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0), | ||
682 | SND_SOC_DAPM_PGA("ISRC1DEC3", ARIZONA_ISRC_1_CTRL_3, | ||
683 | ARIZONA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0), | ||
684 | SND_SOC_DAPM_PGA("ISRC1DEC4", ARIZONA_ISRC_1_CTRL_3, | ||
685 | ARIZONA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0), | ||
686 | |||
687 | SND_SOC_DAPM_PGA("ISRC2INT1", ARIZONA_ISRC_2_CTRL_3, | ||
688 | ARIZONA_ISRC2_INT0_ENA_SHIFT, 0, NULL, 0), | ||
689 | SND_SOC_DAPM_PGA("ISRC2INT2", ARIZONA_ISRC_2_CTRL_3, | ||
690 | ARIZONA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0), | ||
691 | SND_SOC_DAPM_PGA("ISRC2INT3", ARIZONA_ISRC_2_CTRL_3, | ||
692 | ARIZONA_ISRC2_INT2_ENA_SHIFT, 0, NULL, 0), | ||
693 | SND_SOC_DAPM_PGA("ISRC2INT4", ARIZONA_ISRC_2_CTRL_3, | ||
694 | ARIZONA_ISRC2_INT3_ENA_SHIFT, 0, NULL, 0), | ||
695 | |||
696 | SND_SOC_DAPM_PGA("ISRC2DEC1", ARIZONA_ISRC_2_CTRL_3, | ||
697 | ARIZONA_ISRC2_DEC0_ENA_SHIFT, 0, NULL, 0), | ||
698 | SND_SOC_DAPM_PGA("ISRC2DEC2", ARIZONA_ISRC_2_CTRL_3, | ||
699 | ARIZONA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0), | ||
700 | SND_SOC_DAPM_PGA("ISRC2DEC3", ARIZONA_ISRC_2_CTRL_3, | ||
701 | ARIZONA_ISRC2_DEC2_ENA_SHIFT, 0, NULL, 0), | ||
702 | SND_SOC_DAPM_PGA("ISRC2DEC4", ARIZONA_ISRC_2_CTRL_3, | ||
703 | ARIZONA_ISRC2_DEC3_ENA_SHIFT, 0, NULL, 0), | ||
704 | |||
705 | SND_SOC_DAPM_PGA("ISRC3INT1", ARIZONA_ISRC_3_CTRL_3, | ||
706 | ARIZONA_ISRC3_INT0_ENA_SHIFT, 0, NULL, 0), | ||
707 | SND_SOC_DAPM_PGA("ISRC3INT2", ARIZONA_ISRC_3_CTRL_3, | ||
708 | ARIZONA_ISRC3_INT1_ENA_SHIFT, 0, NULL, 0), | ||
709 | SND_SOC_DAPM_PGA("ISRC3INT3", ARIZONA_ISRC_3_CTRL_3, | ||
710 | ARIZONA_ISRC3_INT2_ENA_SHIFT, 0, NULL, 0), | ||
711 | SND_SOC_DAPM_PGA("ISRC3INT4", ARIZONA_ISRC_3_CTRL_3, | ||
712 | ARIZONA_ISRC3_INT3_ENA_SHIFT, 0, NULL, 0), | ||
713 | |||
714 | SND_SOC_DAPM_PGA("ISRC3DEC1", ARIZONA_ISRC_3_CTRL_3, | ||
715 | ARIZONA_ISRC3_DEC0_ENA_SHIFT, 0, NULL, 0), | ||
716 | SND_SOC_DAPM_PGA("ISRC3DEC2", ARIZONA_ISRC_3_CTRL_3, | ||
717 | ARIZONA_ISRC3_DEC1_ENA_SHIFT, 0, NULL, 0), | ||
718 | SND_SOC_DAPM_PGA("ISRC3DEC3", ARIZONA_ISRC_3_CTRL_3, | ||
719 | ARIZONA_ISRC3_DEC2_ENA_SHIFT, 0, NULL, 0), | ||
720 | SND_SOC_DAPM_PGA("ISRC3DEC4", ARIZONA_ISRC_3_CTRL_3, | ||
721 | ARIZONA_ISRC3_DEC3_ENA_SHIFT, 0, NULL, 0), | ||
722 | |||
538 | SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, | 723 | SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, |
539 | ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, | 724 | ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, |
540 | &wm5110_aec_loopback_mux), | 725 | &wm5110_aec_loopback_mux), |
@@ -577,11 +762,27 @@ SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0, | |||
577 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0), | 762 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0), |
578 | SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0, | 763 | SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0, |
579 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0), | 764 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0), |
765 | SND_SOC_DAPM_AIF_OUT("AIF2TX3", NULL, 0, | ||
766 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX3_ENA_SHIFT, 0), | ||
767 | SND_SOC_DAPM_AIF_OUT("AIF2TX4", NULL, 0, | ||
768 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX4_ENA_SHIFT, 0), | ||
769 | SND_SOC_DAPM_AIF_OUT("AIF2TX5", NULL, 0, | ||
770 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX5_ENA_SHIFT, 0), | ||
771 | SND_SOC_DAPM_AIF_OUT("AIF2TX6", NULL, 0, | ||
772 | ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX6_ENA_SHIFT, 0), | ||
580 | 773 | ||
581 | SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0, | 774 | SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0, |
582 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0), | 775 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0), |
583 | SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0, | 776 | SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0, |
584 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0), | 777 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0), |
778 | SND_SOC_DAPM_AIF_IN("AIF2RX3", NULL, 0, | ||
779 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX3_ENA_SHIFT, 0), | ||
780 | SND_SOC_DAPM_AIF_IN("AIF2RX4", NULL, 0, | ||
781 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX4_ENA_SHIFT, 0), | ||
782 | SND_SOC_DAPM_AIF_IN("AIF2RX5", NULL, 0, | ||
783 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX5_ENA_SHIFT, 0), | ||
784 | SND_SOC_DAPM_AIF_IN("AIF2RX6", NULL, 0, | ||
785 | ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX6_ENA_SHIFT, 0), | ||
585 | 786 | ||
586 | SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0, | 787 | SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0, |
587 | ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, | 788 | ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, |
@@ -719,6 +920,10 @@ ARIZONA_MIXER_WIDGETS(AIF1TX8, "AIF1TX8"), | |||
719 | 920 | ||
720 | ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"), | 921 | ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"), |
721 | ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"), | 922 | ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"), |
923 | ARIZONA_MIXER_WIDGETS(AIF2TX3, "AIF2TX3"), | ||
924 | ARIZONA_MIXER_WIDGETS(AIF2TX4, "AIF2TX4"), | ||
925 | ARIZONA_MIXER_WIDGETS(AIF2TX5, "AIF2TX5"), | ||
926 | ARIZONA_MIXER_WIDGETS(AIF2TX6, "AIF2TX6"), | ||
722 | 927 | ||
723 | ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), | 928 | ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), |
724 | ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), | 929 | ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), |
@@ -737,6 +942,41 @@ ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"), | |||
737 | ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"), | 942 | ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"), |
738 | ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"), | 943 | ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"), |
739 | 944 | ||
945 | ARIZONA_DSP_WIDGETS(DSP1, "DSP1"), | ||
946 | ARIZONA_DSP_WIDGETS(DSP2, "DSP2"), | ||
947 | ARIZONA_DSP_WIDGETS(DSP3, "DSP3"), | ||
948 | ARIZONA_DSP_WIDGETS(DSP4, "DSP4"), | ||
949 | |||
950 | ARIZONA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"), | ||
951 | ARIZONA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"), | ||
952 | ARIZONA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"), | ||
953 | ARIZONA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"), | ||
954 | |||
955 | ARIZONA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"), | ||
956 | ARIZONA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"), | ||
957 | ARIZONA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"), | ||
958 | ARIZONA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"), | ||
959 | |||
960 | ARIZONA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"), | ||
961 | ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"), | ||
962 | ARIZONA_MUX_WIDGETS(ISRC2DEC3, "ISRC2DEC3"), | ||
963 | ARIZONA_MUX_WIDGETS(ISRC2DEC4, "ISRC2DEC4"), | ||
964 | |||
965 | ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"), | ||
966 | ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"), | ||
967 | ARIZONA_MUX_WIDGETS(ISRC2INT3, "ISRC2INT3"), | ||
968 | ARIZONA_MUX_WIDGETS(ISRC2INT4, "ISRC2INT4"), | ||
969 | |||
970 | ARIZONA_MUX_WIDGETS(ISRC3DEC1, "ISRC3DEC1"), | ||
971 | ARIZONA_MUX_WIDGETS(ISRC3DEC2, "ISRC3DEC2"), | ||
972 | ARIZONA_MUX_WIDGETS(ISRC3DEC3, "ISRC3DEC3"), | ||
973 | ARIZONA_MUX_WIDGETS(ISRC3DEC4, "ISRC3DEC4"), | ||
974 | |||
975 | ARIZONA_MUX_WIDGETS(ISRC3INT1, "ISRC3INT1"), | ||
976 | ARIZONA_MUX_WIDGETS(ISRC3INT2, "ISRC3INT2"), | ||
977 | ARIZONA_MUX_WIDGETS(ISRC3INT3, "ISRC3INT3"), | ||
978 | ARIZONA_MUX_WIDGETS(ISRC3INT4, "ISRC3INT4"), | ||
979 | |||
740 | SND_SOC_DAPM_OUTPUT("HPOUT1L"), | 980 | SND_SOC_DAPM_OUTPUT("HPOUT1L"), |
741 | SND_SOC_DAPM_OUTPUT("HPOUT1R"), | 981 | SND_SOC_DAPM_OUTPUT("HPOUT1R"), |
742 | SND_SOC_DAPM_OUTPUT("HPOUT2L"), | 982 | SND_SOC_DAPM_OUTPUT("HPOUT2L"), |
@@ -780,6 +1020,10 @@ SND_SOC_DAPM_OUTPUT("MICSUPP"), | |||
780 | { name, "AIF1RX8", "AIF1RX8" }, \ | 1020 | { name, "AIF1RX8", "AIF1RX8" }, \ |
781 | { name, "AIF2RX1", "AIF2RX1" }, \ | 1021 | { name, "AIF2RX1", "AIF2RX1" }, \ |
782 | { name, "AIF2RX2", "AIF2RX2" }, \ | 1022 | { name, "AIF2RX2", "AIF2RX2" }, \ |
1023 | { name, "AIF2RX3", "AIF2RX3" }, \ | ||
1024 | { name, "AIF2RX4", "AIF2RX4" }, \ | ||
1025 | { name, "AIF2RX5", "AIF2RX5" }, \ | ||
1026 | { name, "AIF2RX6", "AIF2RX6" }, \ | ||
783 | { name, "AIF3RX1", "AIF3RX1" }, \ | 1027 | { name, "AIF3RX1", "AIF3RX1" }, \ |
784 | { name, "AIF3RX2", "AIF3RX2" }, \ | 1028 | { name, "AIF3RX2", "AIF3RX2" }, \ |
785 | { name, "SLIMRX1", "SLIMRX1" }, \ | 1029 | { name, "SLIMRX1", "SLIMRX1" }, \ |
@@ -805,7 +1049,55 @@ SND_SOC_DAPM_OUTPUT("MICSUPP"), | |||
805 | { name, "ASRC1L", "ASRC1L" }, \ | 1049 | { name, "ASRC1L", "ASRC1L" }, \ |
806 | { name, "ASRC1R", "ASRC1R" }, \ | 1050 | { name, "ASRC1R", "ASRC1R" }, \ |
807 | { name, "ASRC2L", "ASRC2L" }, \ | 1051 | { name, "ASRC2L", "ASRC2L" }, \ |
808 | { name, "ASRC2R", "ASRC2R" } | 1052 | { name, "ASRC2R", "ASRC2R" }, \ |
1053 | { name, "ISRC1DEC1", "ISRC1DEC1" }, \ | ||
1054 | { name, "ISRC1DEC2", "ISRC1DEC2" }, \ | ||
1055 | { name, "ISRC1DEC3", "ISRC1DEC3" }, \ | ||
1056 | { name, "ISRC1DEC4", "ISRC1DEC4" }, \ | ||
1057 | { name, "ISRC1INT1", "ISRC1INT1" }, \ | ||
1058 | { name, "ISRC1INT2", "ISRC1INT2" }, \ | ||
1059 | { name, "ISRC1INT3", "ISRC1INT3" }, \ | ||
1060 | { name, "ISRC1INT4", "ISRC1INT4" }, \ | ||
1061 | { name, "ISRC2DEC1", "ISRC2DEC1" }, \ | ||
1062 | { name, "ISRC2DEC2", "ISRC2DEC2" }, \ | ||
1063 | { name, "ISRC2DEC3", "ISRC2DEC3" }, \ | ||
1064 | { name, "ISRC2DEC4", "ISRC2DEC4" }, \ | ||
1065 | { name, "ISRC2INT1", "ISRC2INT1" }, \ | ||
1066 | { name, "ISRC2INT2", "ISRC2INT2" }, \ | ||
1067 | { name, "ISRC2INT3", "ISRC2INT3" }, \ | ||
1068 | { name, "ISRC2INT4", "ISRC2INT4" }, \ | ||
1069 | { name, "ISRC3DEC1", "ISRC3DEC1" }, \ | ||
1070 | { name, "ISRC3DEC2", "ISRC3DEC2" }, \ | ||
1071 | { name, "ISRC3DEC3", "ISRC3DEC3" }, \ | ||
1072 | { name, "ISRC3DEC4", "ISRC3DEC4" }, \ | ||
1073 | { name, "ISRC3INT1", "ISRC3INT1" }, \ | ||
1074 | { name, "ISRC3INT2", "ISRC3INT2" }, \ | ||
1075 | { name, "ISRC3INT3", "ISRC3INT3" }, \ | ||
1076 | { name, "ISRC3INT4", "ISRC3INT4" }, \ | ||
1077 | { name, "DSP1.1", "DSP1" }, \ | ||
1078 | { name, "DSP1.2", "DSP1" }, \ | ||
1079 | { name, "DSP1.3", "DSP1" }, \ | ||
1080 | { name, "DSP1.4", "DSP1" }, \ | ||
1081 | { name, "DSP1.5", "DSP1" }, \ | ||
1082 | { name, "DSP1.6", "DSP1" }, \ | ||
1083 | { name, "DSP2.1", "DSP2" }, \ | ||
1084 | { name, "DSP2.2", "DSP2" }, \ | ||
1085 | { name, "DSP2.3", "DSP2" }, \ | ||
1086 | { name, "DSP2.4", "DSP2" }, \ | ||
1087 | { name, "DSP2.5", "DSP2" }, \ | ||
1088 | { name, "DSP2.6", "DSP2" }, \ | ||
1089 | { name, "DSP3.1", "DSP3" }, \ | ||
1090 | { name, "DSP3.2", "DSP3" }, \ | ||
1091 | { name, "DSP3.3", "DSP3" }, \ | ||
1092 | { name, "DSP3.4", "DSP3" }, \ | ||
1093 | { name, "DSP3.5", "DSP3" }, \ | ||
1094 | { name, "DSP3.6", "DSP3" }, \ | ||
1095 | { name, "DSP4.1", "DSP4" }, \ | ||
1096 | { name, "DSP4.2", "DSP4" }, \ | ||
1097 | { name, "DSP4.3", "DSP4" }, \ | ||
1098 | { name, "DSP4.4", "DSP4" }, \ | ||
1099 | { name, "DSP4.5", "DSP4" }, \ | ||
1100 | { name, "DSP4.6", "DSP4" } | ||
809 | 1101 | ||
810 | static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { | 1102 | static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { |
811 | { "AIF2 Capture", NULL, "DBVDD2" }, | 1103 | { "AIF2 Capture", NULL, "DBVDD2" }, |
@@ -877,9 +1169,17 @@ static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { | |||
877 | 1169 | ||
878 | { "AIF2 Capture", NULL, "AIF2TX1" }, | 1170 | { "AIF2 Capture", NULL, "AIF2TX1" }, |
879 | { "AIF2 Capture", NULL, "AIF2TX2" }, | 1171 | { "AIF2 Capture", NULL, "AIF2TX2" }, |
1172 | { "AIF2 Capture", NULL, "AIF2TX3" }, | ||
1173 | { "AIF2 Capture", NULL, "AIF2TX4" }, | ||
1174 | { "AIF2 Capture", NULL, "AIF2TX5" }, | ||
1175 | { "AIF2 Capture", NULL, "AIF2TX6" }, | ||
880 | 1176 | ||
881 | { "AIF2RX1", NULL, "AIF2 Playback" }, | 1177 | { "AIF2RX1", NULL, "AIF2 Playback" }, |
882 | { "AIF2RX2", NULL, "AIF2 Playback" }, | 1178 | { "AIF2RX2", NULL, "AIF2 Playback" }, |
1179 | { "AIF2RX3", NULL, "AIF2 Playback" }, | ||
1180 | { "AIF2RX4", NULL, "AIF2 Playback" }, | ||
1181 | { "AIF2RX5", NULL, "AIF2 Playback" }, | ||
1182 | { "AIF2RX6", NULL, "AIF2 Playback" }, | ||
883 | 1183 | ||
884 | { "AIF3 Capture", NULL, "AIF3TX1" }, | 1184 | { "AIF3 Capture", NULL, "AIF3TX1" }, |
885 | { "AIF3 Capture", NULL, "AIF3TX2" }, | 1185 | { "AIF3 Capture", NULL, "AIF3TX2" }, |
@@ -963,6 +1263,10 @@ static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { | |||
963 | 1263 | ||
964 | ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"), | 1264 | ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"), |
965 | ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"), | 1265 | ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"), |
1266 | ARIZONA_MIXER_ROUTES("AIF2TX3", "AIF2TX3"), | ||
1267 | ARIZONA_MIXER_ROUTES("AIF2TX4", "AIF2TX4"), | ||
1268 | ARIZONA_MIXER_ROUTES("AIF2TX5", "AIF2TX5"), | ||
1269 | ARIZONA_MIXER_ROUTES("AIF2TX6", "AIF2TX6"), | ||
966 | 1270 | ||
967 | ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"), | 1271 | ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"), |
968 | ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"), | 1272 | ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"), |
@@ -999,6 +1303,41 @@ static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { | |||
999 | ARIZONA_MUX_ROUTES("ASRC2L", "ASRC2L"), | 1303 | ARIZONA_MUX_ROUTES("ASRC2L", "ASRC2L"), |
1000 | ARIZONA_MUX_ROUTES("ASRC2R", "ASRC2R"), | 1304 | ARIZONA_MUX_ROUTES("ASRC2R", "ASRC2R"), |
1001 | 1305 | ||
1306 | ARIZONA_DSP_ROUTES("DSP1"), | ||
1307 | ARIZONA_DSP_ROUTES("DSP2"), | ||
1308 | ARIZONA_DSP_ROUTES("DSP3"), | ||
1309 | ARIZONA_DSP_ROUTES("DSP4"), | ||
1310 | |||
1311 | ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"), | ||
1312 | ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"), | ||
1313 | ARIZONA_MUX_ROUTES("ISRC1INT3", "ISRC1INT3"), | ||
1314 | ARIZONA_MUX_ROUTES("ISRC1INT4", "ISRC1INT4"), | ||
1315 | |||
1316 | ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"), | ||
1317 | ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"), | ||
1318 | ARIZONA_MUX_ROUTES("ISRC1DEC3", "ISRC1DEC3"), | ||
1319 | ARIZONA_MUX_ROUTES("ISRC1DEC4", "ISRC1DEC4"), | ||
1320 | |||
1321 | ARIZONA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"), | ||
1322 | ARIZONA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"), | ||
1323 | ARIZONA_MUX_ROUTES("ISRC2INT3", "ISRC2INT3"), | ||
1324 | ARIZONA_MUX_ROUTES("ISRC2INT4", "ISRC2INT4"), | ||
1325 | |||
1326 | ARIZONA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"), | ||
1327 | ARIZONA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"), | ||
1328 | ARIZONA_MUX_ROUTES("ISRC2DEC3", "ISRC2DEC3"), | ||
1329 | ARIZONA_MUX_ROUTES("ISRC2DEC4", "ISRC2DEC4"), | ||
1330 | |||
1331 | ARIZONA_MUX_ROUTES("ISRC3INT1", "ISRC3INT1"), | ||
1332 | ARIZONA_MUX_ROUTES("ISRC3INT2", "ISRC3INT2"), | ||
1333 | ARIZONA_MUX_ROUTES("ISRC3INT3", "ISRC3INT3"), | ||
1334 | ARIZONA_MUX_ROUTES("ISRC3INT4", "ISRC3INT4"), | ||
1335 | |||
1336 | ARIZONA_MUX_ROUTES("ISRC3DEC1", "ISRC3DEC1"), | ||
1337 | ARIZONA_MUX_ROUTES("ISRC3DEC2", "ISRC3DEC2"), | ||
1338 | ARIZONA_MUX_ROUTES("ISRC3DEC3", "ISRC3DEC3"), | ||
1339 | ARIZONA_MUX_ROUTES("ISRC3DEC4", "ISRC3DEC4"), | ||
1340 | |||
1002 | { "AEC Loopback", "HPOUT1L", "OUT1L" }, | 1341 | { "AEC Loopback", "HPOUT1L", "OUT1L" }, |
1003 | { "AEC Loopback", "HPOUT1R", "OUT1R" }, | 1342 | { "AEC Loopback", "HPOUT1R", "OUT1R" }, |
1004 | { "HPOUT1L", NULL, "OUT1L" }, | 1343 | { "HPOUT1L", NULL, "OUT1L" }, |
@@ -1095,14 +1434,14 @@ static struct snd_soc_dai_driver wm5110_dai[] = { | |||
1095 | .playback = { | 1434 | .playback = { |
1096 | .stream_name = "AIF2 Playback", | 1435 | .stream_name = "AIF2 Playback", |
1097 | .channels_min = 1, | 1436 | .channels_min = 1, |
1098 | .channels_max = 2, | 1437 | .channels_max = 6, |
1099 | .rates = WM5110_RATES, | 1438 | .rates = WM5110_RATES, |
1100 | .formats = WM5110_FORMATS, | 1439 | .formats = WM5110_FORMATS, |
1101 | }, | 1440 | }, |
1102 | .capture = { | 1441 | .capture = { |
1103 | .stream_name = "AIF2 Capture", | 1442 | .stream_name = "AIF2 Capture", |
1104 | .channels_min = 1, | 1443 | .channels_min = 1, |
1105 | .channels_max = 2, | 1444 | .channels_max = 6, |
1106 | .rates = WM5110_RATES, | 1445 | .rates = WM5110_RATES, |
1107 | .formats = WM5110_FORMATS, | 1446 | .formats = WM5110_FORMATS, |
1108 | }, | 1447 | }, |
@@ -1204,6 +1543,10 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec) | |||
1204 | arizona_init_spk(codec); | 1543 | arizona_init_spk(codec); |
1205 | arizona_init_gpio(codec); | 1544 | arizona_init_gpio(codec); |
1206 | 1545 | ||
1546 | ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 8); | ||
1547 | if (ret != 0) | ||
1548 | return ret; | ||
1549 | |||
1207 | snd_soc_dapm_disable_pin(&codec->dapm, "HAPTICS"); | 1550 | snd_soc_dapm_disable_pin(&codec->dapm, "HAPTICS"); |
1208 | 1551 | ||
1209 | priv->core.arizona->dapm = &codec->dapm; | 1552 | priv->core.arizona->dapm = &codec->dapm; |
@@ -1258,7 +1601,7 @@ static int wm5110_probe(struct platform_device *pdev) | |||
1258 | { | 1601 | { |
1259 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); | 1602 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); |
1260 | struct wm5110_priv *wm5110; | 1603 | struct wm5110_priv *wm5110; |
1261 | int i; | 1604 | int i, ret; |
1262 | 1605 | ||
1263 | wm5110 = devm_kzalloc(&pdev->dev, sizeof(struct wm5110_priv), | 1606 | wm5110 = devm_kzalloc(&pdev->dev, sizeof(struct wm5110_priv), |
1264 | GFP_KERNEL); | 1607 | GFP_KERNEL); |
@@ -1269,6 +1612,24 @@ static int wm5110_probe(struct platform_device *pdev) | |||
1269 | wm5110->core.arizona = arizona; | 1612 | wm5110->core.arizona = arizona; |
1270 | wm5110->core.num_inputs = 8; | 1613 | wm5110->core.num_inputs = 8; |
1271 | 1614 | ||
1615 | for (i = 0; i < WM5110_NUM_ADSP; i++) { | ||
1616 | wm5110->core.adsp[i].part = "wm5110"; | ||
1617 | wm5110->core.adsp[i].num = i + 1; | ||
1618 | wm5110->core.adsp[i].type = WMFW_ADSP2; | ||
1619 | wm5110->core.adsp[i].dev = arizona->dev; | ||
1620 | wm5110->core.adsp[i].regmap = arizona->regmap; | ||
1621 | |||
1622 | wm5110->core.adsp[i].base = ARIZONA_DSP1_CONTROL_1 | ||
1623 | + (0x100 * i); | ||
1624 | wm5110->core.adsp[i].mem = wm5110_dsp_regions[i]; | ||
1625 | wm5110->core.adsp[i].num_mems | ||
1626 | = ARRAY_SIZE(wm5110_dsp1_regions); | ||
1627 | |||
1628 | ret = wm_adsp2_init(&wm5110->core.adsp[i], false); | ||
1629 | if (ret != 0) | ||
1630 | return ret; | ||
1631 | } | ||
1632 | |||
1272 | for (i = 0; i < ARRAY_SIZE(wm5110->fll); i++) | 1633 | for (i = 0; i < ARRAY_SIZE(wm5110->fll); i++) |
1273 | wm5110->fll[i].vco_mult = 3; | 1634 | wm5110->fll[i].vco_mult = 3; |
1274 | 1635 | ||
@@ -1279,6 +1640,12 @@ static int wm5110_probe(struct platform_device *pdev) | |||
1279 | ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK, | 1640 | ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK, |
1280 | &wm5110->fll[1]); | 1641 | &wm5110->fll[1]); |
1281 | 1642 | ||
1643 | /* SR2 fixed at 8kHz, SR3 fixed at 16kHz */ | ||
1644 | regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_2, | ||
1645 | ARIZONA_SAMPLE_RATE_2_MASK, 0x11); | ||
1646 | regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_3, | ||
1647 | ARIZONA_SAMPLE_RATE_3_MASK, 0x12); | ||
1648 | |||
1282 | for (i = 0; i < ARRAY_SIZE(wm5110_dai); i++) | 1649 | for (i = 0; i < ARRAY_SIZE(wm5110_dai); i++) |
1283 | arizona_init_dai(&wm5110->core, i); | 1650 | arizona_init_dai(&wm5110->core, i); |
1284 | 1651 | ||
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index 6ed5433943ea..7df7d4572755 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c | |||
@@ -684,7 +684,7 @@ static struct spi_driver wm8510_spi_driver = { | |||
684 | }; | 684 | }; |
685 | #endif /* CONFIG_SPI_MASTER */ | 685 | #endif /* CONFIG_SPI_MASTER */ |
686 | 686 | ||
687 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 687 | #if IS_ENABLED(CONFIG_I2C) |
688 | static int wm8510_i2c_probe(struct i2c_client *i2c, | 688 | static int wm8510_i2c_probe(struct i2c_client *i2c, |
689 | const struct i2c_device_id *id) | 689 | const struct i2c_device_id *id) |
690 | { | 690 | { |
@@ -735,7 +735,7 @@ static struct i2c_driver wm8510_i2c_driver = { | |||
735 | static int __init wm8510_modinit(void) | 735 | static int __init wm8510_modinit(void) |
736 | { | 736 | { |
737 | int ret = 0; | 737 | int ret = 0; |
738 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 738 | #if IS_ENABLED(CONFIG_I2C) |
739 | ret = i2c_add_driver(&wm8510_i2c_driver); | 739 | ret = i2c_add_driver(&wm8510_i2c_driver); |
740 | if (ret != 0) { | 740 | if (ret != 0) { |
741 | printk(KERN_ERR "Failed to register WM8510 I2C driver: %d\n", | 741 | printk(KERN_ERR "Failed to register WM8510 I2C driver: %d\n", |
@@ -755,7 +755,7 @@ module_init(wm8510_modinit); | |||
755 | 755 | ||
756 | static void __exit wm8510_exit(void) | 756 | static void __exit wm8510_exit(void) |
757 | { | 757 | { |
758 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 758 | #if IS_ENABLED(CONFIG_I2C) |
759 | i2c_del_driver(&wm8510_i2c_driver); | 759 | i2c_del_driver(&wm8510_i2c_driver); |
760 | #endif | 760 | #endif |
761 | #if defined(CONFIG_SPI_MASTER) | 761 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c index 139bf9ac9407..74d106dc7667 100644 --- a/sound/soc/codecs/wm8523.c +++ b/sound/soc/codecs/wm8523.c | |||
@@ -452,7 +452,7 @@ static const struct regmap_config wm8523_regmap = { | |||
452 | .volatile_reg = wm8523_volatile_register, | 452 | .volatile_reg = wm8523_volatile_register, |
453 | }; | 453 | }; |
454 | 454 | ||
455 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 455 | #if IS_ENABLED(CONFIG_I2C) |
456 | static int wm8523_i2c_probe(struct i2c_client *i2c, | 456 | static int wm8523_i2c_probe(struct i2c_client *i2c, |
457 | const struct i2c_device_id *id) | 457 | const struct i2c_device_id *id) |
458 | { | 458 | { |
@@ -555,7 +555,7 @@ static struct i2c_driver wm8523_i2c_driver = { | |||
555 | static int __init wm8523_modinit(void) | 555 | static int __init wm8523_modinit(void) |
556 | { | 556 | { |
557 | int ret; | 557 | int ret; |
558 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 558 | #if IS_ENABLED(CONFIG_I2C) |
559 | ret = i2c_add_driver(&wm8523_i2c_driver); | 559 | ret = i2c_add_driver(&wm8523_i2c_driver); |
560 | if (ret != 0) { | 560 | if (ret != 0) { |
561 | printk(KERN_ERR "Failed to register WM8523 I2C driver: %d\n", | 561 | printk(KERN_ERR "Failed to register WM8523 I2C driver: %d\n", |
@@ -568,7 +568,7 @@ module_init(wm8523_modinit); | |||
568 | 568 | ||
569 | static void __exit wm8523_exit(void) | 569 | static void __exit wm8523_exit(void) |
570 | { | 570 | { |
571 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 571 | #if IS_ENABLED(CONFIG_I2C) |
572 | i2c_del_driver(&wm8523_i2c_driver); | 572 | i2c_del_driver(&wm8523_i2c_driver); |
573 | #endif | 573 | #endif |
574 | } | 574 | } |
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 08a414b57b1e..318989acbbe5 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c | |||
@@ -941,7 +941,7 @@ static const struct regmap_config wm8580_regmap = { | |||
941 | .volatile_reg = wm8580_volatile, | 941 | .volatile_reg = wm8580_volatile, |
942 | }; | 942 | }; |
943 | 943 | ||
944 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 944 | #if IS_ENABLED(CONFIG_I2C) |
945 | static int wm8580_i2c_probe(struct i2c_client *i2c, | 945 | static int wm8580_i2c_probe(struct i2c_client *i2c, |
946 | const struct i2c_device_id *id) | 946 | const struct i2c_device_id *id) |
947 | { | 947 | { |
@@ -1003,7 +1003,7 @@ static int __init wm8580_modinit(void) | |||
1003 | { | 1003 | { |
1004 | int ret = 0; | 1004 | int ret = 0; |
1005 | 1005 | ||
1006 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1006 | #if IS_ENABLED(CONFIG_I2C) |
1007 | ret = i2c_add_driver(&wm8580_i2c_driver); | 1007 | ret = i2c_add_driver(&wm8580_i2c_driver); |
1008 | if (ret != 0) { | 1008 | if (ret != 0) { |
1009 | pr_err("Failed to register WM8580 I2C driver: %d\n", ret); | 1009 | pr_err("Failed to register WM8580 I2C driver: %d\n", ret); |
@@ -1016,7 +1016,7 @@ module_init(wm8580_modinit); | |||
1016 | 1016 | ||
1017 | static void __exit wm8580_exit(void) | 1017 | static void __exit wm8580_exit(void) |
1018 | { | 1018 | { |
1019 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1019 | #if IS_ENABLED(CONFIG_I2C) |
1020 | i2c_del_driver(&wm8580_i2c_driver); | 1020 | i2c_del_driver(&wm8580_i2c_driver); |
1021 | #endif | 1021 | #endif |
1022 | } | 1022 | } |
diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c index 5b428b060d41..d99f948c513c 100644 --- a/sound/soc/codecs/wm8711.c +++ b/sound/soc/codecs/wm8711.c | |||
@@ -469,7 +469,7 @@ static struct spi_driver wm8711_spi_driver = { | |||
469 | }; | 469 | }; |
470 | #endif /* CONFIG_SPI_MASTER */ | 470 | #endif /* CONFIG_SPI_MASTER */ |
471 | 471 | ||
472 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 472 | #if IS_ENABLED(CONFIG_I2C) |
473 | static int wm8711_i2c_probe(struct i2c_client *client, | 473 | static int wm8711_i2c_probe(struct i2c_client *client, |
474 | const struct i2c_device_id *id) | 474 | const struct i2c_device_id *id) |
475 | { | 475 | { |
@@ -520,7 +520,7 @@ static struct i2c_driver wm8711_i2c_driver = { | |||
520 | static int __init wm8711_modinit(void) | 520 | static int __init wm8711_modinit(void) |
521 | { | 521 | { |
522 | int ret; | 522 | int ret; |
523 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 523 | #if IS_ENABLED(CONFIG_I2C) |
524 | ret = i2c_add_driver(&wm8711_i2c_driver); | 524 | ret = i2c_add_driver(&wm8711_i2c_driver); |
525 | if (ret != 0) { | 525 | if (ret != 0) { |
526 | printk(KERN_ERR "Failed to register WM8711 I2C driver: %d\n", | 526 | printk(KERN_ERR "Failed to register WM8711 I2C driver: %d\n", |
@@ -540,7 +540,7 @@ module_init(wm8711_modinit); | |||
540 | 540 | ||
541 | static void __exit wm8711_exit(void) | 541 | static void __exit wm8711_exit(void) |
542 | { | 542 | { |
543 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 543 | #if IS_ENABLED(CONFIG_I2C) |
544 | i2c_del_driver(&wm8711_i2c_driver); | 544 | i2c_del_driver(&wm8711_i2c_driver); |
545 | #endif | 545 | #endif |
546 | #if defined(CONFIG_SPI_MASTER) | 546 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c index c6a292dcded0..cd89033e84c0 100644 --- a/sound/soc/codecs/wm8728.c +++ b/sound/soc/codecs/wm8728.c | |||
@@ -320,7 +320,7 @@ static struct spi_driver wm8728_spi_driver = { | |||
320 | }; | 320 | }; |
321 | #endif /* CONFIG_SPI_MASTER */ | 321 | #endif /* CONFIG_SPI_MASTER */ |
322 | 322 | ||
323 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 323 | #if IS_ENABLED(CONFIG_I2C) |
324 | static int wm8728_i2c_probe(struct i2c_client *i2c, | 324 | static int wm8728_i2c_probe(struct i2c_client *i2c, |
325 | const struct i2c_device_id *id) | 325 | const struct i2c_device_id *id) |
326 | { | 326 | { |
@@ -371,7 +371,7 @@ static struct i2c_driver wm8728_i2c_driver = { | |||
371 | static int __init wm8728_modinit(void) | 371 | static int __init wm8728_modinit(void) |
372 | { | 372 | { |
373 | int ret = 0; | 373 | int ret = 0; |
374 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 374 | #if IS_ENABLED(CONFIG_I2C) |
375 | ret = i2c_add_driver(&wm8728_i2c_driver); | 375 | ret = i2c_add_driver(&wm8728_i2c_driver); |
376 | if (ret != 0) { | 376 | if (ret != 0) { |
377 | printk(KERN_ERR "Failed to register wm8728 I2C driver: %d\n", | 377 | printk(KERN_ERR "Failed to register wm8728 I2C driver: %d\n", |
@@ -391,7 +391,7 @@ module_init(wm8728_modinit); | |||
391 | 391 | ||
392 | static void __exit wm8728_exit(void) | 392 | static void __exit wm8728_exit(void) |
393 | { | 393 | { |
394 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 394 | #if IS_ENABLED(CONFIG_I2C) |
395 | i2c_del_driver(&wm8728_i2c_driver); | 395 | i2c_del_driver(&wm8728_i2c_driver); |
396 | #endif | 396 | #endif |
397 | #if defined(CONFIG_SPI_MASTER) | 397 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index bc7472c968e3..029720366ff8 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c | |||
@@ -732,7 +732,7 @@ static struct spi_driver wm8731_spi_driver = { | |||
732 | }; | 732 | }; |
733 | #endif /* CONFIG_SPI_MASTER */ | 733 | #endif /* CONFIG_SPI_MASTER */ |
734 | 734 | ||
735 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 735 | #if IS_ENABLED(CONFIG_I2C) |
736 | static int wm8731_i2c_probe(struct i2c_client *i2c, | 736 | static int wm8731_i2c_probe(struct i2c_client *i2c, |
737 | const struct i2c_device_id *id) | 737 | const struct i2c_device_id *id) |
738 | { | 738 | { |
@@ -791,7 +791,7 @@ static struct i2c_driver wm8731_i2c_driver = { | |||
791 | static int __init wm8731_modinit(void) | 791 | static int __init wm8731_modinit(void) |
792 | { | 792 | { |
793 | int ret = 0; | 793 | int ret = 0; |
794 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 794 | #if IS_ENABLED(CONFIG_I2C) |
795 | ret = i2c_add_driver(&wm8731_i2c_driver); | 795 | ret = i2c_add_driver(&wm8731_i2c_driver); |
796 | if (ret != 0) { | 796 | if (ret != 0) { |
797 | printk(KERN_ERR "Failed to register WM8731 I2C driver: %d\n", | 797 | printk(KERN_ERR "Failed to register WM8731 I2C driver: %d\n", |
@@ -811,7 +811,7 @@ module_init(wm8731_modinit); | |||
811 | 811 | ||
812 | static void __exit wm8731_exit(void) | 812 | static void __exit wm8731_exit(void) |
813 | { | 813 | { |
814 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 814 | #if IS_ENABLED(CONFIG_I2C) |
815 | i2c_del_driver(&wm8731_i2c_driver); | 815 | i2c_del_driver(&wm8731_i2c_driver); |
816 | #endif | 816 | #endif |
817 | #if defined(CONFIG_SPI_MASTER) | 817 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c index b18813cc7ba9..2895c8d3b5e4 100644 --- a/sound/soc/codecs/wm8741.c +++ b/sound/soc/codecs/wm8741.c | |||
@@ -500,7 +500,7 @@ static const struct regmap_config wm8741_regmap = { | |||
500 | .readable_reg = wm8741_readable, | 500 | .readable_reg = wm8741_readable, |
501 | }; | 501 | }; |
502 | 502 | ||
503 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 503 | #if IS_ENABLED(CONFIG_I2C) |
504 | static int wm8741_i2c_probe(struct i2c_client *i2c, | 504 | static int wm8741_i2c_probe(struct i2c_client *i2c, |
505 | const struct i2c_device_id *id) | 505 | const struct i2c_device_id *id) |
506 | { | 506 | { |
@@ -617,7 +617,7 @@ static int __init wm8741_modinit(void) | |||
617 | { | 617 | { |
618 | int ret = 0; | 618 | int ret = 0; |
619 | 619 | ||
620 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 620 | #if IS_ENABLED(CONFIG_I2C) |
621 | ret = i2c_add_driver(&wm8741_i2c_driver); | 621 | ret = i2c_add_driver(&wm8741_i2c_driver); |
622 | if (ret != 0) | 622 | if (ret != 0) |
623 | pr_err("Failed to register WM8741 I2C driver: %d\n", ret); | 623 | pr_err("Failed to register WM8741 I2C driver: %d\n", ret); |
@@ -639,7 +639,7 @@ static void __exit wm8741_exit(void) | |||
639 | #if defined(CONFIG_SPI_MASTER) | 639 | #if defined(CONFIG_SPI_MASTER) |
640 | spi_unregister_driver(&wm8741_spi_driver); | 640 | spi_unregister_driver(&wm8741_spi_driver); |
641 | #endif | 641 | #endif |
642 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 642 | #if IS_ENABLED(CONFIG_I2C) |
643 | i2c_del_driver(&wm8741_i2c_driver); | 643 | i2c_del_driver(&wm8741_i2c_driver); |
644 | #endif | 644 | #endif |
645 | } | 645 | } |
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 50d5ff616232..78616a638a55 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c | |||
@@ -816,7 +816,7 @@ static struct spi_driver wm8750_spi_driver = { | |||
816 | }; | 816 | }; |
817 | #endif /* CONFIG_SPI_MASTER */ | 817 | #endif /* CONFIG_SPI_MASTER */ |
818 | 818 | ||
819 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 819 | #if IS_ENABLED(CONFIG_I2C) |
820 | static int wm8750_i2c_probe(struct i2c_client *i2c, | 820 | static int wm8750_i2c_probe(struct i2c_client *i2c, |
821 | const struct i2c_device_id *id) | 821 | const struct i2c_device_id *id) |
822 | { | 822 | { |
@@ -868,7 +868,7 @@ static struct i2c_driver wm8750_i2c_driver = { | |||
868 | static int __init wm8750_modinit(void) | 868 | static int __init wm8750_modinit(void) |
869 | { | 869 | { |
870 | int ret = 0; | 870 | int ret = 0; |
871 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 871 | #if IS_ENABLED(CONFIG_I2C) |
872 | ret = i2c_add_driver(&wm8750_i2c_driver); | 872 | ret = i2c_add_driver(&wm8750_i2c_driver); |
873 | if (ret != 0) { | 873 | if (ret != 0) { |
874 | printk(KERN_ERR "Failed to register wm8750 I2C driver: %d\n", | 874 | printk(KERN_ERR "Failed to register wm8750 I2C driver: %d\n", |
@@ -888,7 +888,7 @@ module_init(wm8750_modinit); | |||
888 | 888 | ||
889 | static void __exit wm8750_exit(void) | 889 | static void __exit wm8750_exit(void) |
890 | { | 890 | { |
891 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 891 | #if IS_ENABLED(CONFIG_I2C) |
892 | i2c_del_driver(&wm8750_i2c_driver); | 892 | i2c_del_driver(&wm8750_i2c_driver); |
893 | #endif | 893 | #endif |
894 | #if defined(CONFIG_SPI_MASTER) | 894 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index d96ebf52d953..be85da93a268 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c | |||
@@ -1596,7 +1596,7 @@ static struct spi_driver wm8753_spi_driver = { | |||
1596 | }; | 1596 | }; |
1597 | #endif /* CONFIG_SPI_MASTER */ | 1597 | #endif /* CONFIG_SPI_MASTER */ |
1598 | 1598 | ||
1599 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1599 | #if IS_ENABLED(CONFIG_I2C) |
1600 | static int wm8753_i2c_probe(struct i2c_client *i2c, | 1600 | static int wm8753_i2c_probe(struct i2c_client *i2c, |
1601 | const struct i2c_device_id *id) | 1601 | const struct i2c_device_id *id) |
1602 | { | 1602 | { |
@@ -1653,7 +1653,7 @@ static struct i2c_driver wm8753_i2c_driver = { | |||
1653 | static int __init wm8753_modinit(void) | 1653 | static int __init wm8753_modinit(void) |
1654 | { | 1654 | { |
1655 | int ret = 0; | 1655 | int ret = 0; |
1656 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1656 | #if IS_ENABLED(CONFIG_I2C) |
1657 | ret = i2c_add_driver(&wm8753_i2c_driver); | 1657 | ret = i2c_add_driver(&wm8753_i2c_driver); |
1658 | if (ret != 0) { | 1658 | if (ret != 0) { |
1659 | printk(KERN_ERR "Failed to register wm8753 I2C driver: %d\n", | 1659 | printk(KERN_ERR "Failed to register wm8753 I2C driver: %d\n", |
@@ -1673,7 +1673,7 @@ module_init(wm8753_modinit); | |||
1673 | 1673 | ||
1674 | static void __exit wm8753_exit(void) | 1674 | static void __exit wm8753_exit(void) |
1675 | { | 1675 | { |
1676 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1676 | #if IS_ENABLED(CONFIG_I2C) |
1677 | i2c_del_driver(&wm8753_i2c_driver); | 1677 | i2c_del_driver(&wm8753_i2c_driver); |
1678 | #endif | 1678 | #endif |
1679 | #if defined(CONFIG_SPI_MASTER) | 1679 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c index 942d58e455f3..ef8246725232 100644 --- a/sound/soc/codecs/wm8776.c +++ b/sound/soc/codecs/wm8776.c | |||
@@ -532,7 +532,7 @@ static struct spi_driver wm8776_spi_driver = { | |||
532 | }; | 532 | }; |
533 | #endif /* CONFIG_SPI_MASTER */ | 533 | #endif /* CONFIG_SPI_MASTER */ |
534 | 534 | ||
535 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 535 | #if IS_ENABLED(CONFIG_I2C) |
536 | static int wm8776_i2c_probe(struct i2c_client *i2c, | 536 | static int wm8776_i2c_probe(struct i2c_client *i2c, |
537 | const struct i2c_device_id *id) | 537 | const struct i2c_device_id *id) |
538 | { | 538 | { |
@@ -584,7 +584,7 @@ static struct i2c_driver wm8776_i2c_driver = { | |||
584 | static int __init wm8776_modinit(void) | 584 | static int __init wm8776_modinit(void) |
585 | { | 585 | { |
586 | int ret = 0; | 586 | int ret = 0; |
587 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 587 | #if IS_ENABLED(CONFIG_I2C) |
588 | ret = i2c_add_driver(&wm8776_i2c_driver); | 588 | ret = i2c_add_driver(&wm8776_i2c_driver); |
589 | if (ret != 0) { | 589 | if (ret != 0) { |
590 | printk(KERN_ERR "Failed to register wm8776 I2C driver: %d\n", | 590 | printk(KERN_ERR "Failed to register wm8776 I2C driver: %d\n", |
@@ -604,7 +604,7 @@ module_init(wm8776_modinit); | |||
604 | 604 | ||
605 | static void __exit wm8776_exit(void) | 605 | static void __exit wm8776_exit(void) |
606 | { | 606 | { |
607 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 607 | #if IS_ENABLED(CONFIG_I2C) |
608 | i2c_del_driver(&wm8776_i2c_driver); | 608 | i2c_del_driver(&wm8776_i2c_driver); |
609 | #endif | 609 | #endif |
610 | #if defined(CONFIG_SPI_MASTER) | 610 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index 1704b1e119cb..9bc8206a6807 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c | |||
@@ -739,7 +739,7 @@ static struct spi_driver wm8804_spi_driver = { | |||
739 | }; | 739 | }; |
740 | #endif | 740 | #endif |
741 | 741 | ||
742 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 742 | #if IS_ENABLED(CONFIG_I2C) |
743 | static int wm8804_i2c_probe(struct i2c_client *i2c, | 743 | static int wm8804_i2c_probe(struct i2c_client *i2c, |
744 | const struct i2c_device_id *id) | 744 | const struct i2c_device_id *id) |
745 | { | 745 | { |
@@ -791,7 +791,7 @@ static int __init wm8804_modinit(void) | |||
791 | { | 791 | { |
792 | int ret = 0; | 792 | int ret = 0; |
793 | 793 | ||
794 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 794 | #if IS_ENABLED(CONFIG_I2C) |
795 | ret = i2c_add_driver(&wm8804_i2c_driver); | 795 | ret = i2c_add_driver(&wm8804_i2c_driver); |
796 | if (ret) { | 796 | if (ret) { |
797 | printk(KERN_ERR "Failed to register wm8804 I2C driver: %d\n", | 797 | printk(KERN_ERR "Failed to register wm8804 I2C driver: %d\n", |
@@ -811,7 +811,7 @@ module_init(wm8804_modinit); | |||
811 | 811 | ||
812 | static void __exit wm8804_exit(void) | 812 | static void __exit wm8804_exit(void) |
813 | { | 813 | { |
814 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 814 | #if IS_ENABLED(CONFIG_I2C) |
815 | i2c_del_driver(&wm8804_i2c_driver); | 815 | i2c_del_driver(&wm8804_i2c_driver); |
816 | #endif | 816 | #endif |
817 | #if defined(CONFIG_SPI_MASTER) | 817 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 734209e252c3..e98bc7038a08 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c | |||
@@ -1288,7 +1288,7 @@ static struct spi_driver wm8900_spi_driver = { | |||
1288 | }; | 1288 | }; |
1289 | #endif /* CONFIG_SPI_MASTER */ | 1289 | #endif /* CONFIG_SPI_MASTER */ |
1290 | 1290 | ||
1291 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1291 | #if IS_ENABLED(CONFIG_I2C) |
1292 | static int wm8900_i2c_probe(struct i2c_client *i2c, | 1292 | static int wm8900_i2c_probe(struct i2c_client *i2c, |
1293 | const struct i2c_device_id *id) | 1293 | const struct i2c_device_id *id) |
1294 | { | 1294 | { |
@@ -1338,7 +1338,7 @@ static struct i2c_driver wm8900_i2c_driver = { | |||
1338 | static int __init wm8900_modinit(void) | 1338 | static int __init wm8900_modinit(void) |
1339 | { | 1339 | { |
1340 | int ret = 0; | 1340 | int ret = 0; |
1341 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1341 | #if IS_ENABLED(CONFIG_I2C) |
1342 | ret = i2c_add_driver(&wm8900_i2c_driver); | 1342 | ret = i2c_add_driver(&wm8900_i2c_driver); |
1343 | if (ret != 0) { | 1343 | if (ret != 0) { |
1344 | printk(KERN_ERR "Failed to register wm8900 I2C driver: %d\n", | 1344 | printk(KERN_ERR "Failed to register wm8900 I2C driver: %d\n", |
@@ -1358,7 +1358,7 @@ module_init(wm8900_modinit); | |||
1358 | 1358 | ||
1359 | static void __exit wm8900_exit(void) | 1359 | static void __exit wm8900_exit(void) |
1360 | { | 1360 | { |
1361 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1361 | #if IS_ENABLED(CONFIG_I2C) |
1362 | i2c_del_driver(&wm8900_i2c_driver); | 1362 | i2c_del_driver(&wm8900_i2c_driver); |
1363 | #endif | 1363 | #endif |
1364 | #if defined(CONFIG_SPI_MASTER) | 1364 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c index b1591c61c254..b404c26c1753 100644 --- a/sound/soc/codecs/wm8940.c +++ b/sound/soc/codecs/wm8940.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/pm.h> | 29 | #include <linux/pm.h> |
30 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
31 | #include <linux/spi/spi.h> | 31 | #include <linux/regmap.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <sound/core.h> | 33 | #include <sound/core.h> |
34 | #include <sound/pcm.h> | 34 | #include <sound/pcm.h> |
@@ -41,78 +41,116 @@ | |||
41 | 41 | ||
42 | struct wm8940_priv { | 42 | struct wm8940_priv { |
43 | unsigned int sysclk; | 43 | unsigned int sysclk; |
44 | enum snd_soc_control_type control_type; | 44 | struct regmap *regmap; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | static int wm8940_volatile_register(struct snd_soc_codec *codec, | 47 | static bool wm8940_volatile_register(struct device *dev, unsigned int reg) |
48 | unsigned int reg) | ||
49 | { | 48 | { |
50 | switch (reg) { | 49 | switch (reg) { |
51 | case WM8940_SOFTRESET: | 50 | case WM8940_SOFTRESET: |
52 | return 1; | 51 | return true; |
53 | default: | 52 | default: |
54 | return 0; | 53 | return false; |
54 | } | ||
55 | } | ||
56 | |||
57 | static bool wm8940_readable_register(struct device *dev, unsigned int reg) | ||
58 | { | ||
59 | switch (reg) { | ||
60 | case WM8940_SOFTRESET: | ||
61 | case WM8940_POWER1: | ||
62 | case WM8940_POWER2: | ||
63 | case WM8940_POWER3: | ||
64 | case WM8940_IFACE: | ||
65 | case WM8940_COMPANDINGCTL: | ||
66 | case WM8940_CLOCK: | ||
67 | case WM8940_ADDCNTRL: | ||
68 | case WM8940_GPIO: | ||
69 | case WM8940_CTLINT: | ||
70 | case WM8940_DAC: | ||
71 | case WM8940_DACVOL: | ||
72 | case WM8940_ADC: | ||
73 | case WM8940_ADCVOL: | ||
74 | case WM8940_NOTCH1: | ||
75 | case WM8940_NOTCH2: | ||
76 | case WM8940_NOTCH3: | ||
77 | case WM8940_NOTCH4: | ||
78 | case WM8940_NOTCH5: | ||
79 | case WM8940_NOTCH6: | ||
80 | case WM8940_NOTCH7: | ||
81 | case WM8940_NOTCH8: | ||
82 | case WM8940_DACLIM1: | ||
83 | case WM8940_DACLIM2: | ||
84 | case WM8940_ALC1: | ||
85 | case WM8940_ALC2: | ||
86 | case WM8940_ALC3: | ||
87 | case WM8940_NOISEGATE: | ||
88 | case WM8940_PLLN: | ||
89 | case WM8940_PLLK1: | ||
90 | case WM8940_PLLK2: | ||
91 | case WM8940_PLLK3: | ||
92 | case WM8940_ALC4: | ||
93 | case WM8940_INPUTCTL: | ||
94 | case WM8940_PGAGAIN: | ||
95 | case WM8940_ADCBOOST: | ||
96 | case WM8940_OUTPUTCTL: | ||
97 | case WM8940_SPKMIX: | ||
98 | case WM8940_SPKVOL: | ||
99 | case WM8940_MONOMIX: | ||
100 | return true; | ||
101 | default: | ||
102 | return false; | ||
55 | } | 103 | } |
56 | } | 104 | } |
57 | 105 | ||
58 | static u16 wm8940_reg_defaults[] = { | 106 | static const struct reg_default wm8940_reg_defaults[] = { |
59 | 0x8940, /* Soft Reset */ | 107 | { 0x1, 0x0000 }, /* Power 1 */ |
60 | 0x0000, /* Power 1 */ | 108 | { 0x2, 0x0000 }, /* Power 2 */ |
61 | 0x0000, /* Power 2 */ | 109 | { 0x3, 0x0000 }, /* Power 3 */ |
62 | 0x0000, /* Power 3 */ | 110 | { 0x4, 0x0010 }, /* Interface Control */ |
63 | 0x0010, /* Interface Control */ | 111 | { 0x5, 0x0000 }, /* Companding Control */ |
64 | 0x0000, /* Companding Control */ | 112 | { 0x6, 0x0140 }, /* Clock Control */ |
65 | 0x0140, /* Clock Control */ | 113 | { 0x7, 0x0000 }, /* Additional Controls */ |
66 | 0x0000, /* Additional Controls */ | 114 | { 0x8, 0x0000 }, /* GPIO Control */ |
67 | 0x0000, /* GPIO Control */ | 115 | { 0x9, 0x0002 }, /* Auto Increment Control */ |
68 | 0x0002, /* Auto Increment Control */ | 116 | { 0xa, 0x0000 }, /* DAC Control */ |
69 | 0x0000, /* DAC Control */ | 117 | { 0xb, 0x00FF }, /* DAC Volume */ |
70 | 0x00FF, /* DAC Volume */ | 118 | |
71 | 0, | 119 | { 0xe, 0x0100 }, /* ADC Control */ |
72 | 0, | 120 | { 0xf, 0x00FF }, /* ADC Volume */ |
73 | 0x0100, /* ADC Control */ | 121 | { 0x10, 0x0000 }, /* Notch Filter 1 Control 1 */ |
74 | 0x00FF, /* ADC Volume */ | 122 | { 0x11, 0x0000 }, /* Notch Filter 1 Control 2 */ |
75 | 0x0000, /* Notch Filter 1 Control 1 */ | 123 | { 0x12, 0x0000 }, /* Notch Filter 2 Control 1 */ |
76 | 0x0000, /* Notch Filter 1 Control 2 */ | 124 | { 0x13, 0x0000 }, /* Notch Filter 2 Control 2 */ |
77 | 0x0000, /* Notch Filter 2 Control 1 */ | 125 | { 0x14, 0x0000 }, /* Notch Filter 3 Control 1 */ |
78 | 0x0000, /* Notch Filter 2 Control 2 */ | 126 | { 0x15, 0x0000 }, /* Notch Filter 3 Control 2 */ |
79 | 0x0000, /* Notch Filter 3 Control 1 */ | 127 | { 0x16, 0x0000 }, /* Notch Filter 4 Control 1 */ |
80 | 0x0000, /* Notch Filter 3 Control 2 */ | 128 | { 0x17, 0x0000 }, /* Notch Filter 4 Control 2 */ |
81 | 0x0000, /* Notch Filter 4 Control 1 */ | 129 | { 0x18, 0x0032 }, /* DAC Limit Control 1 */ |
82 | 0x0000, /* Notch Filter 4 Control 2 */ | 130 | { 0x19, 0x0000 }, /* DAC Limit Control 2 */ |
83 | 0x0032, /* DAC Limit Control 1 */ | 131 | |
84 | 0x0000, /* DAC Limit Control 2 */ | 132 | { 0x20, 0x0038 }, /* ALC Control 1 */ |
85 | 0, | 133 | { 0x21, 0x000B }, /* ALC Control 2 */ |
86 | 0, | 134 | { 0x22, 0x0032 }, /* ALC Control 3 */ |
87 | 0, | 135 | { 0x23, 0x0000 }, /* Noise Gate */ |
88 | 0, | 136 | { 0x24, 0x0041 }, /* PLLN */ |
89 | 0, | 137 | { 0x25, 0x000C }, /* PLLK1 */ |
90 | 0, | 138 | { 0x26, 0x0093 }, /* PLLK2 */ |
91 | 0x0038, /* ALC Control 1 */ | 139 | { 0x27, 0x00E9 }, /* PLLK3 */ |
92 | 0x000B, /* ALC Control 2 */ | 140 | |
93 | 0x0032, /* ALC Control 3 */ | 141 | { 0x2a, 0x0030 }, /* ALC Control 4 */ |
94 | 0x0000, /* Noise Gate */ | 142 | |
95 | 0x0041, /* PLLN */ | 143 | { 0x2c, 0x0002 }, /* Input Control */ |
96 | 0x000C, /* PLLK1 */ | 144 | { 0x2d, 0x0050 }, /* PGA Gain */ |
97 | 0x0093, /* PLLK2 */ | 145 | |
98 | 0x00E9, /* PLLK3 */ | 146 | { 0x2f, 0x0002 }, /* ADC Boost Control */ |
99 | 0, | 147 | |
100 | 0, | 148 | { 0x31, 0x0002 }, /* Output Control */ |
101 | 0x0030, /* ALC Control 4 */ | 149 | { 0x32, 0x0000 }, /* Speaker Mixer Control */ |
102 | 0, | 150 | |
103 | 0x0002, /* Input Control */ | 151 | { 0x36, 0x0079 }, /* Speaker Volume */ |
104 | 0x0050, /* PGA Gain */ | 152 | |
105 | 0, | 153 | { 0x38, 0x0000 }, /* Mono Mixer Control */ |
106 | 0x0002, /* ADC Boost Control */ | ||
107 | 0, | ||
108 | 0x0002, /* Output Control */ | ||
109 | 0x0000, /* Speaker Mixer Control */ | ||
110 | 0, | ||
111 | 0, | ||
112 | 0, | ||
113 | 0x0079, /* Speaker Volume */ | ||
114 | 0, | ||
115 | 0x0000, /* Mono Mixer Control */ | ||
116 | }; | 154 | }; |
117 | 155 | ||
118 | static const char *wm8940_companding[] = { "Off", "NC", "u-law", "A-law" }; | 156 | static const char *wm8940_companding[] = { "Off", "NC", "u-law", "A-law" }; |
@@ -264,7 +302,7 @@ static const struct snd_soc_dapm_widget wm8940_dapm_widgets[] = { | |||
264 | SND_SOC_DAPM_INPUT("AUX"), | 302 | SND_SOC_DAPM_INPUT("AUX"), |
265 | }; | 303 | }; |
266 | 304 | ||
267 | static const struct snd_soc_dapm_route audio_map[] = { | 305 | static const struct snd_soc_dapm_route wm8940_dapm_routes[] = { |
268 | /* Mono output mixer */ | 306 | /* Mono output mixer */ |
269 | {"Mono Mixer", "PCM Playback Switch", "DAC"}, | 307 | {"Mono Mixer", "PCM Playback Switch", "DAC"}, |
270 | {"Mono Mixer", "Aux Playback Switch", "Aux Input"}, | 308 | {"Mono Mixer", "Aux Playback Switch", "Aux Input"}, |
@@ -296,21 +334,6 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
296 | {"ADC", NULL, "Boost Mixer"}, | 334 | {"ADC", NULL, "Boost Mixer"}, |
297 | }; | 335 | }; |
298 | 336 | ||
299 | static int wm8940_add_widgets(struct snd_soc_codec *codec) | ||
300 | { | ||
301 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
302 | int ret; | ||
303 | |||
304 | ret = snd_soc_dapm_new_controls(dapm, wm8940_dapm_widgets, | ||
305 | ARRAY_SIZE(wm8940_dapm_widgets)); | ||
306 | if (ret) | ||
307 | goto error_ret; | ||
308 | ret = snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); | ||
309 | |||
310 | error_ret: | ||
311 | return ret; | ||
312 | } | ||
313 | |||
314 | #define wm8940_reset(c) snd_soc_write(c, WM8940_SOFTRESET, 0); | 337 | #define wm8940_reset(c) snd_soc_write(c, WM8940_SOFTRESET, 0); |
315 | 338 | ||
316 | static int wm8940_set_dai_fmt(struct snd_soc_dai *codec_dai, | 339 | static int wm8940_set_dai_fmt(struct snd_soc_dai *codec_dai, |
@@ -446,6 +469,7 @@ static int wm8940_mute(struct snd_soc_dai *dai, int mute) | |||
446 | static int wm8940_set_bias_level(struct snd_soc_codec *codec, | 469 | static int wm8940_set_bias_level(struct snd_soc_codec *codec, |
447 | enum snd_soc_bias_level level) | 470 | enum snd_soc_bias_level level) |
448 | { | 471 | { |
472 | struct wm8940_priv *wm8940 = snd_soc_codec_get_drvdata(codec); | ||
449 | u16 val; | 473 | u16 val; |
450 | u16 pwr_reg = snd_soc_read(codec, WM8940_POWER1) & 0x1F0; | 474 | u16 pwr_reg = snd_soc_read(codec, WM8940_POWER1) & 0x1F0; |
451 | int ret = 0; | 475 | int ret = 0; |
@@ -469,7 +493,7 @@ static int wm8940_set_bias_level(struct snd_soc_codec *codec, | |||
469 | break; | 493 | break; |
470 | case SND_SOC_BIAS_STANDBY: | 494 | case SND_SOC_BIAS_STANDBY: |
471 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { | 495 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
472 | ret = snd_soc_cache_sync(codec); | 496 | ret = regcache_sync(wm8940->regmap); |
473 | if (ret < 0) { | 497 | if (ret < 0) { |
474 | dev_err(codec->dev, "Failed to sync cache: %d\n", ret); | 498 | dev_err(codec->dev, "Failed to sync cache: %d\n", ret); |
475 | return ret; | 499 | return ret; |
@@ -684,12 +708,11 @@ static int wm8940_resume(struct snd_soc_codec *codec) | |||
684 | 708 | ||
685 | static int wm8940_probe(struct snd_soc_codec *codec) | 709 | static int wm8940_probe(struct snd_soc_codec *codec) |
686 | { | 710 | { |
687 | struct wm8940_priv *wm8940 = snd_soc_codec_get_drvdata(codec); | ||
688 | struct wm8940_setup_data *pdata = codec->dev->platform_data; | 711 | struct wm8940_setup_data *pdata = codec->dev->platform_data; |
689 | int ret; | 712 | int ret; |
690 | u16 reg; | 713 | u16 reg; |
691 | 714 | ||
692 | ret = snd_soc_codec_set_cache_io(codec, 8, 16, wm8940->control_type); | 715 | ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); |
693 | if (ret < 0) { | 716 | if (ret < 0) { |
694 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 717 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
695 | return ret; | 718 | return ret; |
@@ -716,11 +739,6 @@ static int wm8940_probe(struct snd_soc_codec *codec) | |||
716 | return ret; | 739 | return ret; |
717 | } | 740 | } |
718 | 741 | ||
719 | ret = snd_soc_add_codec_controls(codec, wm8940_snd_controls, | ||
720 | ARRAY_SIZE(wm8940_snd_controls)); | ||
721 | if (ret) | ||
722 | return ret; | ||
723 | ret = wm8940_add_widgets(codec); | ||
724 | return ret; | 742 | return ret; |
725 | } | 743 | } |
726 | 744 | ||
@@ -736,10 +754,24 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8940 = { | |||
736 | .suspend = wm8940_suspend, | 754 | .suspend = wm8940_suspend, |
737 | .resume = wm8940_resume, | 755 | .resume = wm8940_resume, |
738 | .set_bias_level = wm8940_set_bias_level, | 756 | .set_bias_level = wm8940_set_bias_level, |
739 | .reg_cache_size = ARRAY_SIZE(wm8940_reg_defaults), | 757 | .controls = wm8940_snd_controls, |
740 | .reg_word_size = sizeof(u16), | 758 | .num_controls = ARRAY_SIZE(wm8940_snd_controls), |
741 | .reg_cache_default = wm8940_reg_defaults, | 759 | .dapm_widgets = wm8940_dapm_widgets, |
742 | .volatile_register = wm8940_volatile_register, | 760 | .num_dapm_widgets = ARRAY_SIZE(wm8940_dapm_widgets), |
761 | .dapm_routes = wm8940_dapm_routes, | ||
762 | .num_dapm_routes = ARRAY_SIZE(wm8940_dapm_routes), | ||
763 | }; | ||
764 | |||
765 | static const struct regmap_config wm8940_regmap = { | ||
766 | .reg_bits = 8, | ||
767 | .val_bits = 16, | ||
768 | |||
769 | .max_register = WM8940_MONOMIX, | ||
770 | .reg_defaults = wm8940_reg_defaults, | ||
771 | .num_reg_defaults = ARRAY_SIZE(wm8940_reg_defaults), | ||
772 | |||
773 | .readable_reg = wm8940_readable_register, | ||
774 | .volatile_reg = wm8940_volatile_register, | ||
743 | }; | 775 | }; |
744 | 776 | ||
745 | static int wm8940_i2c_probe(struct i2c_client *i2c, | 777 | static int wm8940_i2c_probe(struct i2c_client *i2c, |
@@ -753,8 +785,11 @@ static int wm8940_i2c_probe(struct i2c_client *i2c, | |||
753 | if (wm8940 == NULL) | 785 | if (wm8940 == NULL) |
754 | return -ENOMEM; | 786 | return -ENOMEM; |
755 | 787 | ||
788 | wm8940->regmap = devm_regmap_init_i2c(i2c, &wm8940_regmap); | ||
789 | if (IS_ERR(wm8940->regmap)) | ||
790 | return PTR_ERR(wm8940->regmap); | ||
791 | |||
756 | i2c_set_clientdata(i2c, wm8940); | 792 | i2c_set_clientdata(i2c, wm8940); |
757 | wm8940->control_type = SND_SOC_I2C; | ||
758 | 793 | ||
759 | ret = snd_soc_register_codec(&i2c->dev, | 794 | ret = snd_soc_register_codec(&i2c->dev, |
760 | &soc_codec_dev_wm8940, &wm8940_dai, 1); | 795 | &soc_codec_dev_wm8940, &wm8940_dai, 1); |
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 0f17ed3e29f4..97db3b45b411 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c | |||
@@ -74,7 +74,7 @@ struct wm8962_priv { | |||
74 | struct regulator_bulk_data supplies[WM8962_NUM_SUPPLIES]; | 74 | struct regulator_bulk_data supplies[WM8962_NUM_SUPPLIES]; |
75 | struct notifier_block disable_nb[WM8962_NUM_SUPPLIES]; | 75 | struct notifier_block disable_nb[WM8962_NUM_SUPPLIES]; |
76 | 76 | ||
77 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 77 | #if IS_ENABLED(CONFIG_INPUT) |
78 | struct input_dev *beep; | 78 | struct input_dev *beep; |
79 | struct work_struct beep_work; | 79 | struct work_struct beep_work; |
80 | int beep_rate; | 80 | int beep_rate; |
@@ -3121,7 +3121,7 @@ int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) | |||
3121 | } | 3121 | } |
3122 | EXPORT_SYMBOL_GPL(wm8962_mic_detect); | 3122 | EXPORT_SYMBOL_GPL(wm8962_mic_detect); |
3123 | 3123 | ||
3124 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 3124 | #if IS_ENABLED(CONFIG_INPUT) |
3125 | static int beep_rates[] = { | 3125 | static int beep_rates[] = { |
3126 | 500, 1000, 2000, 4000, | 3126 | 500, 1000, 2000, 4000, |
3127 | }; | 3127 | }; |
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c index a2d01d10a5dd..15f45c7bd833 100644 --- a/sound/soc/codecs/wm8974.c +++ b/sound/soc/codecs/wm8974.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
19 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
20 | #include <linux/regmap.h> | ||
20 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
21 | #include <sound/core.h> | 22 | #include <sound/core.h> |
22 | #include <sound/pcm.h> | 23 | #include <sound/pcm.h> |
@@ -27,22 +28,22 @@ | |||
27 | 28 | ||
28 | #include "wm8974.h" | 29 | #include "wm8974.h" |
29 | 30 | ||
30 | static const u16 wm8974_reg[WM8974_CACHEREGNUM] = { | 31 | static const struct reg_default wm8974_reg_defaults[] = { |
31 | 0x0000, 0x0000, 0x0000, 0x0000, | 32 | { 0, 0x0000 }, { 1, 0x0000 }, { 2, 0x0000 }, { 3, 0x0000 }, |
32 | 0x0050, 0x0000, 0x0140, 0x0000, | 33 | { 4, 0x0050 }, { 5, 0x0000 }, { 6, 0x0140 }, { 7, 0x0000 }, |
33 | 0x0000, 0x0000, 0x0000, 0x00ff, | 34 | { 8, 0x0000 }, { 9, 0x0000 }, { 10, 0x0000 }, { 11, 0x00ff }, |
34 | 0x0000, 0x0000, 0x0100, 0x00ff, | 35 | { 12, 0x0000 }, { 13, 0x0000 }, { 14, 0x0100 }, { 15, 0x00ff }, |
35 | 0x0000, 0x0000, 0x012c, 0x002c, | 36 | { 16, 0x0000 }, { 17, 0x0000 }, { 18, 0x012c }, { 19, 0x002c }, |
36 | 0x002c, 0x002c, 0x002c, 0x0000, | 37 | { 20, 0x002c }, { 21, 0x002c }, { 22, 0x002c }, { 23, 0x0000 }, |
37 | 0x0032, 0x0000, 0x0000, 0x0000, | 38 | { 24, 0x0032 }, { 25, 0x0000 }, { 26, 0x0000 }, { 27, 0x0000 }, |
38 | 0x0000, 0x0000, 0x0000, 0x0000, | 39 | { 28, 0x0000 }, { 29, 0x0000 }, { 30, 0x0000 }, { 31, 0x0000 }, |
39 | 0x0038, 0x000b, 0x0032, 0x0000, | 40 | { 32, 0x0038 }, { 33, 0x000b }, { 34, 0x0032 }, { 35, 0x0000 }, |
40 | 0x0008, 0x000c, 0x0093, 0x00e9, | 41 | { 36, 0x0008 }, { 37, 0x000c }, { 38, 0x0093 }, { 39, 0x00e9 }, |
41 | 0x0000, 0x0000, 0x0000, 0x0000, | 42 | { 40, 0x0000 }, { 41, 0x0000 }, { 42, 0x0000 }, { 43, 0x0000 }, |
42 | 0x0003, 0x0010, 0x0000, 0x0000, | 43 | { 44, 0x0003 }, { 45, 0x0010 }, { 46, 0x0000 }, { 47, 0x0000 }, |
43 | 0x0000, 0x0002, 0x0000, 0x0000, | 44 | { 48, 0x0000 }, { 49, 0x0002 }, { 50, 0x0000 }, { 51, 0x0000 }, |
44 | 0x0000, 0x0000, 0x0039, 0x0000, | 45 | { 52, 0x0000 }, { 53, 0x0000 }, { 54, 0x0039 }, { 55, 0x0000 }, |
45 | 0x0000, | 46 | { 56, 0x0000 }, |
46 | }; | 47 | }; |
47 | 48 | ||
48 | #define WM8974_POWER1_BIASEN 0x08 | 49 | #define WM8974_POWER1_BIASEN 0x08 |
@@ -514,7 +515,7 @@ static int wm8974_set_bias_level(struct snd_soc_codec *codec, | |||
514 | power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; | 515 | power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; |
515 | 516 | ||
516 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { | 517 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
517 | snd_soc_cache_sync(codec); | 518 | regcache_sync(dev_get_regmap(codec->dev, NULL)); |
518 | 519 | ||
519 | /* Initial cap charge at VMID 5k */ | 520 | /* Initial cap charge at VMID 5k */ |
520 | snd_soc_write(codec, WM8974_POWER1, power1 | 0x3); | 521 | snd_soc_write(codec, WM8974_POWER1, power1 | 0x3); |
@@ -579,11 +580,20 @@ static int wm8974_resume(struct snd_soc_codec *codec) | |||
579 | return 0; | 580 | return 0; |
580 | } | 581 | } |
581 | 582 | ||
583 | static const struct regmap_config wm8974_regmap = { | ||
584 | .reg_bits = 7, | ||
585 | .val_bits = 9, | ||
586 | |||
587 | .max_register = WM8974_MONOMIX, | ||
588 | .reg_defaults = wm8974_reg_defaults, | ||
589 | .num_reg_defaults = ARRAY_SIZE(wm8974_reg_defaults), | ||
590 | }; | ||
591 | |||
582 | static int wm8974_probe(struct snd_soc_codec *codec) | 592 | static int wm8974_probe(struct snd_soc_codec *codec) |
583 | { | 593 | { |
584 | int ret = 0; | 594 | int ret = 0; |
585 | 595 | ||
586 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_I2C); | 596 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP); |
587 | if (ret < 0) { | 597 | if (ret < 0) { |
588 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 598 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
589 | return ret; | 599 | return ret; |
@@ -613,9 +623,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8974 = { | |||
613 | .suspend = wm8974_suspend, | 623 | .suspend = wm8974_suspend, |
614 | .resume = wm8974_resume, | 624 | .resume = wm8974_resume, |
615 | .set_bias_level = wm8974_set_bias_level, | 625 | .set_bias_level = wm8974_set_bias_level, |
616 | .reg_cache_size = ARRAY_SIZE(wm8974_reg), | ||
617 | .reg_word_size = sizeof(u16), | ||
618 | .reg_cache_default = wm8974_reg, | ||
619 | 626 | ||
620 | .controls = wm8974_snd_controls, | 627 | .controls = wm8974_snd_controls, |
621 | .num_controls = ARRAY_SIZE(wm8974_snd_controls), | 628 | .num_controls = ARRAY_SIZE(wm8974_snd_controls), |
@@ -628,8 +635,13 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8974 = { | |||
628 | static int wm8974_i2c_probe(struct i2c_client *i2c, | 635 | static int wm8974_i2c_probe(struct i2c_client *i2c, |
629 | const struct i2c_device_id *id) | 636 | const struct i2c_device_id *id) |
630 | { | 637 | { |
638 | struct regmap *regmap; | ||
631 | int ret; | 639 | int ret; |
632 | 640 | ||
641 | regmap = devm_regmap_init_i2c(i2c, &wm8974_regmap); | ||
642 | if (IS_ERR(regmap)) | ||
643 | return PTR_ERR(regmap); | ||
644 | |||
633 | ret = snd_soc_register_codec(&i2c->dev, | 645 | ret = snd_soc_register_codec(&i2c->dev, |
634 | &soc_codec_dev_wm8974, &wm8974_dai, 1); | 646 | &soc_codec_dev_wm8974, &wm8974_dai, 1); |
635 | 647 | ||
diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c index 18f2babe1090..271b517911a4 100644 --- a/sound/soc/codecs/wm8985.c +++ b/sound/soc/codecs/wm8985.c | |||
@@ -1148,7 +1148,7 @@ static struct spi_driver wm8985_spi_driver = { | |||
1148 | }; | 1148 | }; |
1149 | #endif | 1149 | #endif |
1150 | 1150 | ||
1151 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1151 | #if IS_ENABLED(CONFIG_I2C) |
1152 | static int wm8985_i2c_probe(struct i2c_client *i2c, | 1152 | static int wm8985_i2c_probe(struct i2c_client *i2c, |
1153 | const struct i2c_device_id *id) | 1153 | const struct i2c_device_id *id) |
1154 | { | 1154 | { |
@@ -1201,7 +1201,7 @@ static int __init wm8985_modinit(void) | |||
1201 | { | 1201 | { |
1202 | int ret = 0; | 1202 | int ret = 0; |
1203 | 1203 | ||
1204 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1204 | #if IS_ENABLED(CONFIG_I2C) |
1205 | ret = i2c_add_driver(&wm8985_i2c_driver); | 1205 | ret = i2c_add_driver(&wm8985_i2c_driver); |
1206 | if (ret) { | 1206 | if (ret) { |
1207 | printk(KERN_ERR "Failed to register wm8985 I2C driver: %d\n", | 1207 | printk(KERN_ERR "Failed to register wm8985 I2C driver: %d\n", |
@@ -1221,7 +1221,7 @@ module_init(wm8985_modinit); | |||
1221 | 1221 | ||
1222 | static void __exit wm8985_exit(void) | 1222 | static void __exit wm8985_exit(void) |
1223 | { | 1223 | { |
1224 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1224 | #if IS_ENABLED(CONFIG_I2C) |
1225 | i2c_del_driver(&wm8985_i2c_driver); | 1225 | i2c_del_driver(&wm8985_i2c_driver); |
1226 | #endif | 1226 | #endif |
1227 | #if defined(CONFIG_SPI_MASTER) | 1227 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c index 39b9acceb595..a55e1c2c382e 100644 --- a/sound/soc/codecs/wm8988.c +++ b/sound/soc/codecs/wm8988.c | |||
@@ -912,7 +912,7 @@ static struct spi_driver wm8988_spi_driver = { | |||
912 | }; | 912 | }; |
913 | #endif /* CONFIG_SPI_MASTER */ | 913 | #endif /* CONFIG_SPI_MASTER */ |
914 | 914 | ||
915 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 915 | #if IS_ENABLED(CONFIG_I2C) |
916 | static int wm8988_i2c_probe(struct i2c_client *i2c, | 916 | static int wm8988_i2c_probe(struct i2c_client *i2c, |
917 | const struct i2c_device_id *id) | 917 | const struct i2c_device_id *id) |
918 | { | 918 | { |
@@ -964,7 +964,7 @@ static struct i2c_driver wm8988_i2c_driver = { | |||
964 | static int __init wm8988_modinit(void) | 964 | static int __init wm8988_modinit(void) |
965 | { | 965 | { |
966 | int ret = 0; | 966 | int ret = 0; |
967 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 967 | #if IS_ENABLED(CONFIG_I2C) |
968 | ret = i2c_add_driver(&wm8988_i2c_driver); | 968 | ret = i2c_add_driver(&wm8988_i2c_driver); |
969 | if (ret != 0) { | 969 | if (ret != 0) { |
970 | printk(KERN_ERR "Failed to register WM8988 I2C driver: %d\n", | 970 | printk(KERN_ERR "Failed to register WM8988 I2C driver: %d\n", |
@@ -984,7 +984,7 @@ module_init(wm8988_modinit); | |||
984 | 984 | ||
985 | static void __exit wm8988_exit(void) | 985 | static void __exit wm8988_exit(void) |
986 | { | 986 | { |
987 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 987 | #if IS_ENABLED(CONFIG_I2C) |
988 | i2c_del_driver(&wm8988_i2c_driver); | 988 | i2c_del_driver(&wm8988_i2c_driver); |
989 | #endif | 989 | #endif |
990 | #if defined(CONFIG_SPI_MASTER) | 990 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index 4f05fb88bddf..0ccd4d8d043b 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
19 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
20 | #include <linux/regmap.h> | ||
20 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
21 | #include <sound/core.h> | 22 | #include <sound/core.h> |
22 | #include <sound/pcm.h> | 23 | #include <sound/pcm.h> |
@@ -30,13 +31,12 @@ | |||
30 | 31 | ||
31 | /* codec private data */ | 32 | /* codec private data */ |
32 | struct wm8990_priv { | 33 | struct wm8990_priv { |
33 | enum snd_soc_control_type control_type; | 34 | struct regmap *regmap; |
34 | unsigned int sysclk; | 35 | unsigned int sysclk; |
35 | unsigned int pcmclk; | 36 | unsigned int pcmclk; |
36 | }; | 37 | }; |
37 | 38 | ||
38 | static int wm8990_volatile_register(struct snd_soc_codec *codec, | 39 | static bool wm8990_volatile_register(struct device *dev, unsigned int reg) |
39 | unsigned int reg) | ||
40 | { | 40 | { |
41 | switch (reg) { | 41 | switch (reg) { |
42 | case WM8990_RESET: | 42 | case WM8990_RESET: |
@@ -46,71 +46,69 @@ static int wm8990_volatile_register(struct snd_soc_codec *codec, | |||
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | static const u16 wm8990_reg[] = { | 49 | static const struct reg_default wm8990_reg_defaults[] = { |
50 | 0x8990, /* R0 - Reset */ | 50 | { 1, 0x0000 }, /* R1 - Power Management (1) */ |
51 | 0x0000, /* R1 - Power Management (1) */ | 51 | { 2, 0x6000 }, /* R2 - Power Management (2) */ |
52 | 0x6000, /* R2 - Power Management (2) */ | 52 | { 3, 0x0000 }, /* R3 - Power Management (3) */ |
53 | 0x0000, /* R3 - Power Management (3) */ | 53 | { 4, 0x4050 }, /* R4 - Audio Interface (1) */ |
54 | 0x4050, /* R4 - Audio Interface (1) */ | 54 | { 5, 0x4000 }, /* R5 - Audio Interface (2) */ |
55 | 0x4000, /* R5 - Audio Interface (2) */ | 55 | { 6, 0x01C8 }, /* R6 - Clocking (1) */ |
56 | 0x01C8, /* R6 - Clocking (1) */ | 56 | { 7, 0x0000 }, /* R7 - Clocking (2) */ |
57 | 0x0000, /* R7 - Clocking (2) */ | 57 | { 8, 0x0040 }, /* R8 - Audio Interface (3) */ |
58 | 0x0040, /* R8 - Audio Interface (3) */ | 58 | { 9, 0x0040 }, /* R9 - Audio Interface (4) */ |
59 | 0x0040, /* R9 - Audio Interface (4) */ | 59 | { 10, 0x0004 }, /* R10 - DAC CTRL */ |
60 | 0x0004, /* R10 - DAC CTRL */ | 60 | { 11, 0x00C0 }, /* R11 - Left DAC Digital Volume */ |
61 | 0x00C0, /* R11 - Left DAC Digital Volume */ | 61 | { 12, 0x00C0 }, /* R12 - Right DAC Digital Volume */ |
62 | 0x00C0, /* R12 - Right DAC Digital Volume */ | 62 | { 13, 0x0000 }, /* R13 - Digital Side Tone */ |
63 | 0x0000, /* R13 - Digital Side Tone */ | 63 | { 14, 0x0100 }, /* R14 - ADC CTRL */ |
64 | 0x0100, /* R14 - ADC CTRL */ | 64 | { 15, 0x00C0 }, /* R15 - Left ADC Digital Volume */ |
65 | 0x00C0, /* R15 - Left ADC Digital Volume */ | 65 | { 16, 0x00C0 }, /* R16 - Right ADC Digital Volume */ |
66 | 0x00C0, /* R16 - Right ADC Digital Volume */ | 66 | |
67 | 0x0000, /* R17 */ | 67 | { 18, 0x0000 }, /* R18 - GPIO CTRL 1 */ |
68 | 0x0000, /* R18 - GPIO CTRL 1 */ | 68 | { 19, 0x1000 }, /* R19 - GPIO1 & GPIO2 */ |
69 | 0x1000, /* R19 - GPIO1 & GPIO2 */ | 69 | { 20, 0x1010 }, /* R20 - GPIO3 & GPIO4 */ |
70 | 0x1010, /* R20 - GPIO3 & GPIO4 */ | 70 | { 21, 0x1010 }, /* R21 - GPIO5 & GPIO6 */ |
71 | 0x1010, /* R21 - GPIO5 & GPIO6 */ | 71 | { 22, 0x8000 }, /* R22 - GPIOCTRL 2 */ |
72 | 0x8000, /* R22 - GPIOCTRL 2 */ | 72 | { 23, 0x0800 }, /* R23 - GPIO_POL */ |
73 | 0x0800, /* R23 - GPIO_POL */ | 73 | { 24, 0x008B }, /* R24 - Left Line Input 1&2 Volume */ |
74 | 0x008B, /* R24 - Left Line Input 1&2 Volume */ | 74 | { 25, 0x008B }, /* R25 - Left Line Input 3&4 Volume */ |
75 | 0x008B, /* R25 - Left Line Input 3&4 Volume */ | 75 | { 26, 0x008B }, /* R26 - Right Line Input 1&2 Volume */ |
76 | 0x008B, /* R26 - Right Line Input 1&2 Volume */ | 76 | { 27, 0x008B }, /* R27 - Right Line Input 3&4 Volume */ |
77 | 0x008B, /* R27 - Right Line Input 3&4 Volume */ | 77 | { 28, 0x0000 }, /* R28 - Left Output Volume */ |
78 | 0x0000, /* R28 - Left Output Volume */ | 78 | { 29, 0x0000 }, /* R29 - Right Output Volume */ |
79 | 0x0000, /* R29 - Right Output Volume */ | 79 | { 30, 0x0066 }, /* R30 - Line Outputs Volume */ |
80 | 0x0066, /* R30 - Line Outputs Volume */ | 80 | { 31, 0x0022 }, /* R31 - Out3/4 Volume */ |
81 | 0x0022, /* R31 - Out3/4 Volume */ | 81 | { 32, 0x0079 }, /* R32 - Left OPGA Volume */ |
82 | 0x0079, /* R32 - Left OPGA Volume */ | 82 | { 33, 0x0079 }, /* R33 - Right OPGA Volume */ |
83 | 0x0079, /* R33 - Right OPGA Volume */ | 83 | { 34, 0x0003 }, /* R34 - Speaker Volume */ |
84 | 0x0003, /* R34 - Speaker Volume */ | 84 | { 35, 0x0003 }, /* R35 - ClassD1 */ |
85 | 0x0003, /* R35 - ClassD1 */ | 85 | |
86 | 0x0000, /* R36 */ | 86 | { 37, 0x0100 }, /* R37 - ClassD3 */ |
87 | 0x0100, /* R37 - ClassD3 */ | 87 | { 38, 0x0079 }, /* R38 - ClassD4 */ |
88 | 0x0079, /* R38 - ClassD4 */ | 88 | { 39, 0x0000 }, /* R39 - Input Mixer1 */ |
89 | 0x0000, /* R39 - Input Mixer1 */ | 89 | { 40, 0x0000 }, /* R40 - Input Mixer2 */ |
90 | 0x0000, /* R40 - Input Mixer2 */ | 90 | { 41, 0x0000 }, /* R41 - Input Mixer3 */ |
91 | 0x0000, /* R41 - Input Mixer3 */ | 91 | { 42, 0x0000 }, /* R42 - Input Mixer4 */ |
92 | 0x0000, /* R42 - Input Mixer4 */ | 92 | { 43, 0x0000 }, /* R43 - Input Mixer5 */ |
93 | 0x0000, /* R43 - Input Mixer5 */ | 93 | { 44, 0x0000 }, /* R44 - Input Mixer6 */ |
94 | 0x0000, /* R44 - Input Mixer6 */ | 94 | { 45, 0x0000 }, /* R45 - Output Mixer1 */ |
95 | 0x0000, /* R45 - Output Mixer1 */ | 95 | { 46, 0x0000 }, /* R46 - Output Mixer2 */ |
96 | 0x0000, /* R46 - Output Mixer2 */ | 96 | { 47, 0x0000 }, /* R47 - Output Mixer3 */ |
97 | 0x0000, /* R47 - Output Mixer3 */ | 97 | { 48, 0x0000 }, /* R48 - Output Mixer4 */ |
98 | 0x0000, /* R48 - Output Mixer4 */ | 98 | { 49, 0x0000 }, /* R49 - Output Mixer5 */ |
99 | 0x0000, /* R49 - Output Mixer5 */ | 99 | { 50, 0x0000 }, /* R50 - Output Mixer6 */ |
100 | 0x0000, /* R50 - Output Mixer6 */ | 100 | { 51, 0x0180 }, /* R51 - Out3/4 Mixer */ |
101 | 0x0180, /* R51 - Out3/4 Mixer */ | 101 | { 52, 0x0000 }, /* R52 - Line Mixer1 */ |
102 | 0x0000, /* R52 - Line Mixer1 */ | 102 | { 53, 0x0000 }, /* R53 - Line Mixer2 */ |
103 | 0x0000, /* R53 - Line Mixer2 */ | 103 | { 54, 0x0000 }, /* R54 - Speaker Mixer */ |
104 | 0x0000, /* R54 - Speaker Mixer */ | 104 | { 55, 0x0000 }, /* R55 - Additional Control */ |
105 | 0x0000, /* R55 - Additional Control */ | 105 | { 56, 0x0000 }, /* R56 - AntiPOP1 */ |
106 | 0x0000, /* R56 - AntiPOP1 */ | 106 | { 57, 0x0000 }, /* R57 - AntiPOP2 */ |
107 | 0x0000, /* R57 - AntiPOP2 */ | 107 | { 58, 0x0000 }, /* R58 - MICBIAS */ |
108 | 0x0000, /* R58 - MICBIAS */ | 108 | |
109 | 0x0000, /* R59 */ | 109 | { 60, 0x0008 }, /* R60 - PLL1 */ |
110 | 0x0008, /* R60 - PLL1 */ | 110 | { 61, 0x0031 }, /* R61 - PLL2 */ |
111 | 0x0031, /* R61 - PLL2 */ | 111 | { 62, 0x0026 }, /* R62 - PLL3 */ |
112 | 0x0026, /* R62 - PLL3 */ | ||
113 | 0x0000, /* R63 - Driver internal */ | ||
114 | }; | 112 | }; |
115 | 113 | ||
116 | #define wm8990_reset(c) snd_soc_write(c, WM8990_RESET, 0) | 114 | #define wm8990_reset(c) snd_soc_write(c, WM8990_RESET, 0) |
@@ -376,32 +374,6 @@ SOC_SINGLE("RIN34 Mute Switch", WM8990_RIGHT_LINE_INPUT_3_4_VOLUME, | |||
376 | * _DAPM_ Controls | 374 | * _DAPM_ Controls |
377 | */ | 375 | */ |
378 | 376 | ||
379 | static int inmixer_event(struct snd_soc_dapm_widget *w, | ||
380 | struct snd_kcontrol *kcontrol, int event) | ||
381 | { | ||
382 | u16 reg, fakepower; | ||
383 | |||
384 | reg = snd_soc_read(w->codec, WM8990_POWER_MANAGEMENT_2); | ||
385 | fakepower = snd_soc_read(w->codec, WM8990_INTDRIVBITS); | ||
386 | |||
387 | if (fakepower & ((1 << WM8990_INMIXL_PWR_BIT) | | ||
388 | (1 << WM8990_AINLMUX_PWR_BIT))) { | ||
389 | reg |= WM8990_AINL_ENA; | ||
390 | } else { | ||
391 | reg &= ~WM8990_AINL_ENA; | ||
392 | } | ||
393 | |||
394 | if (fakepower & ((1 << WM8990_INMIXR_PWR_BIT) | | ||
395 | (1 << WM8990_AINRMUX_PWR_BIT))) { | ||
396 | reg |= WM8990_AINR_ENA; | ||
397 | } else { | ||
398 | reg &= ~WM8990_AINR_ENA; | ||
399 | } | ||
400 | snd_soc_write(w->codec, WM8990_POWER_MANAGEMENT_2, reg); | ||
401 | |||
402 | return 0; | ||
403 | } | ||
404 | |||
405 | static int outmixer_event(struct snd_soc_dapm_widget *w, | 377 | static int outmixer_event(struct snd_soc_dapm_widget *w, |
406 | struct snd_kcontrol *kcontrol, int event) | 378 | struct snd_kcontrol *kcontrol, int event) |
407 | { | 379 | { |
@@ -656,6 +628,11 @@ SND_SOC_DAPM_INPUT("RIN1"), | |||
656 | SND_SOC_DAPM_INPUT("RIN2"), | 628 | SND_SOC_DAPM_INPUT("RIN2"), |
657 | SND_SOC_DAPM_INPUT("Internal ADC Source"), | 629 | SND_SOC_DAPM_INPUT("Internal ADC Source"), |
658 | 630 | ||
631 | SND_SOC_DAPM_SUPPLY("INL", WM8990_POWER_MANAGEMENT_2, WM8990_AINL_ENA_BIT, 0, | ||
632 | NULL, 0), | ||
633 | SND_SOC_DAPM_SUPPLY("INR", WM8990_POWER_MANAGEMENT_2, WM8990_AINR_ENA_BIT, 0, | ||
634 | NULL, 0), | ||
635 | |||
659 | /* DACs */ | 636 | /* DACs */ |
660 | SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8990_POWER_MANAGEMENT_2, | 637 | SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8990_POWER_MANAGEMENT_2, |
661 | WM8990_ADCL_ENA_BIT, 0), | 638 | WM8990_ADCL_ENA_BIT, 0), |
@@ -677,26 +654,20 @@ SND_SOC_DAPM_MIXER("RIN34 PGA", WM8990_POWER_MANAGEMENT_2, WM8990_RIN34_ENA_BIT, | |||
677 | ARRAY_SIZE(wm8990_dapm_rin34_pga_controls)), | 654 | ARRAY_SIZE(wm8990_dapm_rin34_pga_controls)), |
678 | 655 | ||
679 | /* INMIXL */ | 656 | /* INMIXL */ |
680 | SND_SOC_DAPM_MIXER_E("INMIXL", WM8990_INTDRIVBITS, WM8990_INMIXL_PWR_BIT, 0, | 657 | SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0, |
681 | &wm8990_dapm_inmixl_controls[0], | 658 | &wm8990_dapm_inmixl_controls[0], |
682 | ARRAY_SIZE(wm8990_dapm_inmixl_controls), | 659 | ARRAY_SIZE(wm8990_dapm_inmixl_controls)), |
683 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
684 | 660 | ||
685 | /* AINLMUX */ | 661 | /* AINLMUX */ |
686 | SND_SOC_DAPM_MUX_E("AINLMUX", WM8990_INTDRIVBITS, WM8990_AINLMUX_PWR_BIT, 0, | 662 | SND_SOC_DAPM_MUX("AINLMUX", SND_SOC_NOPM, 0, 0, &wm8990_dapm_ainlmux_controls), |
687 | &wm8990_dapm_ainlmux_controls, inmixer_event, | ||
688 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
689 | 663 | ||
690 | /* INMIXR */ | 664 | /* INMIXR */ |
691 | SND_SOC_DAPM_MIXER_E("INMIXR", WM8990_INTDRIVBITS, WM8990_INMIXR_PWR_BIT, 0, | 665 | SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0, |
692 | &wm8990_dapm_inmixr_controls[0], | 666 | &wm8990_dapm_inmixr_controls[0], |
693 | ARRAY_SIZE(wm8990_dapm_inmixr_controls), | 667 | ARRAY_SIZE(wm8990_dapm_inmixr_controls)), |
694 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
695 | 668 | ||
696 | /* AINRMUX */ | 669 | /* AINRMUX */ |
697 | SND_SOC_DAPM_MUX_E("AINRMUX", WM8990_INTDRIVBITS, WM8990_AINRMUX_PWR_BIT, 0, | 670 | SND_SOC_DAPM_MUX("AINRMUX", SND_SOC_NOPM, 0, 0, &wm8990_dapm_ainrmux_controls), |
698 | &wm8990_dapm_ainrmux_controls, inmixer_event, | ||
699 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
700 | 671 | ||
701 | /* Output Side */ | 672 | /* Output Side */ |
702 | /* DACs */ | 673 | /* DACs */ |
@@ -787,7 +758,7 @@ SND_SOC_DAPM_OUTPUT("RON"), | |||
787 | SND_SOC_DAPM_OUTPUT("Internal DAC Sink"), | 758 | SND_SOC_DAPM_OUTPUT("Internal DAC Sink"), |
788 | }; | 759 | }; |
789 | 760 | ||
790 | static const struct snd_soc_dapm_route audio_map[] = { | 761 | static const struct snd_soc_dapm_route wm8990_dapm_routes[] = { |
791 | /* Make DACs turn on when playing even if not mixed into any outputs */ | 762 | /* Make DACs turn on when playing even if not mixed into any outputs */ |
792 | {"Internal DAC Sink", NULL, "Left DAC"}, | 763 | {"Internal DAC Sink", NULL, "Left DAC"}, |
793 | {"Internal DAC Sink", NULL, "Right DAC"}, | 764 | {"Internal DAC Sink", NULL, "Right DAC"}, |
@@ -796,6 +767,11 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
796 | {"Left ADC", NULL, "Internal ADC Source"}, | 767 | {"Left ADC", NULL, "Internal ADC Source"}, |
797 | {"Right ADC", NULL, "Internal ADC Source"}, | 768 | {"Right ADC", NULL, "Internal ADC Source"}, |
798 | 769 | ||
770 | {"AINLMUX", NULL, "INL"}, | ||
771 | {"INMIXL", NULL, "INL"}, | ||
772 | {"AINRMUX", NULL, "INR"}, | ||
773 | {"INMIXR", NULL, "INR"}, | ||
774 | |||
799 | /* Input Side */ | 775 | /* Input Side */ |
800 | /* LIN12 PGA */ | 776 | /* LIN12 PGA */ |
801 | {"LIN12 PGA", "LIN1 Switch", "LIN1"}, | 777 | {"LIN12 PGA", "LIN1 Switch", "LIN1"}, |
@@ -912,18 +888,6 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
912 | {"RON", NULL, "RONMIX"}, | 888 | {"RON", NULL, "RONMIX"}, |
913 | }; | 889 | }; |
914 | 890 | ||
915 | static int wm8990_add_widgets(struct snd_soc_codec *codec) | ||
916 | { | ||
917 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
918 | |||
919 | snd_soc_dapm_new_controls(dapm, wm8990_dapm_widgets, | ||
920 | ARRAY_SIZE(wm8990_dapm_widgets)); | ||
921 | /* set up the WM8990 audio map */ | ||
922 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); | ||
923 | |||
924 | return 0; | ||
925 | } | ||
926 | |||
927 | /* PLL divisors */ | 891 | /* PLL divisors */ |
928 | struct _pll_div { | 892 | struct _pll_div { |
929 | u32 div2; | 893 | u32 div2; |
@@ -1148,6 +1112,7 @@ static int wm8990_mute(struct snd_soc_dai *dai, int mute) | |||
1148 | static int wm8990_set_bias_level(struct snd_soc_codec *codec, | 1112 | static int wm8990_set_bias_level(struct snd_soc_codec *codec, |
1149 | enum snd_soc_bias_level level) | 1113 | enum snd_soc_bias_level level) |
1150 | { | 1114 | { |
1115 | struct wm8990_priv *wm8990 = snd_soc_codec_get_drvdata(codec); | ||
1151 | int ret; | 1116 | int ret; |
1152 | 1117 | ||
1153 | switch (level) { | 1118 | switch (level) { |
@@ -1162,7 +1127,7 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec, | |||
1162 | 1127 | ||
1163 | case SND_SOC_BIAS_STANDBY: | 1128 | case SND_SOC_BIAS_STANDBY: |
1164 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { | 1129 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
1165 | ret = snd_soc_cache_sync(codec); | 1130 | ret = regcache_sync(wm8990->regmap); |
1166 | if (ret < 0) { | 1131 | if (ret < 0) { |
1167 | dev_err(codec->dev, "Failed to sync cache: %d\n", ret); | 1132 | dev_err(codec->dev, "Failed to sync cache: %d\n", ret); |
1168 | return ret; | 1133 | return ret; |
@@ -1260,7 +1225,7 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec, | |||
1260 | /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ | 1225 | /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ |
1261 | snd_soc_write(codec, WM8990_ANTIPOP2, 0x0); | 1226 | snd_soc_write(codec, WM8990_ANTIPOP2, 0x0); |
1262 | 1227 | ||
1263 | codec->cache_sync = 1; | 1228 | regcache_mark_dirty(wm8990->regmap); |
1264 | break; | 1229 | break; |
1265 | } | 1230 | } |
1266 | 1231 | ||
@@ -1329,7 +1294,7 @@ static int wm8990_probe(struct snd_soc_codec *codec) | |||
1329 | { | 1294 | { |
1330 | int ret; | 1295 | int ret; |
1331 | 1296 | ||
1332 | ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); | 1297 | ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); |
1333 | if (ret < 0) { | 1298 | if (ret < 0) { |
1334 | printk(KERN_ERR "wm8990: failed to set cache I/O: %d\n", ret); | 1299 | printk(KERN_ERR "wm8990: failed to set cache I/O: %d\n", ret); |
1335 | return ret; | 1300 | return ret; |
@@ -1352,10 +1317,6 @@ static int wm8990_probe(struct snd_soc_codec *codec) | |||
1352 | snd_soc_write(codec, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); | 1317 | snd_soc_write(codec, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); |
1353 | snd_soc_write(codec, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); | 1318 | snd_soc_write(codec, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); |
1354 | 1319 | ||
1355 | snd_soc_add_codec_controls(codec, wm8990_snd_controls, | ||
1356 | ARRAY_SIZE(wm8990_snd_controls)); | ||
1357 | wm8990_add_widgets(codec); | ||
1358 | |||
1359 | return 0; | 1320 | return 0; |
1360 | } | 1321 | } |
1361 | 1322 | ||
@@ -1372,13 +1333,25 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8990 = { | |||
1372 | .suspend = wm8990_suspend, | 1333 | .suspend = wm8990_suspend, |
1373 | .resume = wm8990_resume, | 1334 | .resume = wm8990_resume, |
1374 | .set_bias_level = wm8990_set_bias_level, | 1335 | .set_bias_level = wm8990_set_bias_level, |
1375 | .reg_cache_size = ARRAY_SIZE(wm8990_reg), | 1336 | .controls = wm8990_snd_controls, |
1376 | .reg_word_size = sizeof(u16), | 1337 | .num_controls = ARRAY_SIZE(wm8990_snd_controls), |
1377 | .reg_cache_default = wm8990_reg, | 1338 | .dapm_widgets = wm8990_dapm_widgets, |
1378 | .volatile_register = wm8990_volatile_register, | 1339 | .num_dapm_widgets = ARRAY_SIZE(wm8990_dapm_widgets), |
1340 | .dapm_routes = wm8990_dapm_routes, | ||
1341 | .num_dapm_routes = ARRAY_SIZE(wm8990_dapm_routes), | ||
1342 | }; | ||
1343 | |||
1344 | static const struct regmap_config wm8990_regmap = { | ||
1345 | .reg_bits = 8, | ||
1346 | .val_bits = 16, | ||
1347 | |||
1348 | .max_register = WM8990_PLL3, | ||
1349 | .volatile_reg = wm8990_volatile_register, | ||
1350 | .reg_defaults = wm8990_reg_defaults, | ||
1351 | .num_reg_defaults = ARRAY_SIZE(wm8990_reg_defaults), | ||
1352 | .cache_type = REGCACHE_RBTREE, | ||
1379 | }; | 1353 | }; |
1380 | 1354 | ||
1381 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
1382 | static int wm8990_i2c_probe(struct i2c_client *i2c, | 1355 | static int wm8990_i2c_probe(struct i2c_client *i2c, |
1383 | const struct i2c_device_id *id) | 1356 | const struct i2c_device_id *id) |
1384 | { | 1357 | { |
@@ -1420,29 +1393,8 @@ static struct i2c_driver wm8990_i2c_driver = { | |||
1420 | .remove = wm8990_i2c_remove, | 1393 | .remove = wm8990_i2c_remove, |
1421 | .id_table = wm8990_i2c_id, | 1394 | .id_table = wm8990_i2c_id, |
1422 | }; | 1395 | }; |
1423 | #endif | ||
1424 | 1396 | ||
1425 | static int __init wm8990_modinit(void) | 1397 | module_i2c_driver(wm8990_i2c_driver); |
1426 | { | ||
1427 | int ret = 0; | ||
1428 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
1429 | ret = i2c_add_driver(&wm8990_i2c_driver); | ||
1430 | if (ret != 0) { | ||
1431 | printk(KERN_ERR "Failed to register wm8990 I2C driver: %d\n", | ||
1432 | ret); | ||
1433 | } | ||
1434 | #endif | ||
1435 | return ret; | ||
1436 | } | ||
1437 | module_init(wm8990_modinit); | ||
1438 | |||
1439 | static void __exit wm8990_exit(void) | ||
1440 | { | ||
1441 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
1442 | i2c_del_driver(&wm8990_i2c_driver); | ||
1443 | #endif | ||
1444 | } | ||
1445 | module_exit(wm8990_exit); | ||
1446 | 1398 | ||
1447 | MODULE_DESCRIPTION("ASoC WM8990 driver"); | 1399 | MODULE_DESCRIPTION("ASoC WM8990 driver"); |
1448 | MODULE_AUTHOR("Liam Girdwood"); | 1400 | MODULE_AUTHOR("Liam Girdwood"); |
diff --git a/sound/soc/codecs/wm8990.h b/sound/soc/codecs/wm8990.h index 77c98a4bfe9c..0e9c78040c4c 100644 --- a/sound/soc/codecs/wm8990.h +++ b/sound/soc/codecs/wm8990.h | |||
@@ -78,7 +78,6 @@ | |||
78 | #define WM8990_PLL1 0x3C | 78 | #define WM8990_PLL1 0x3C |
79 | #define WM8990_PLL2 0x3D | 79 | #define WM8990_PLL2 0x3D |
80 | #define WM8990_PLL3 0x3E | 80 | #define WM8990_PLL3 0x3E |
81 | #define WM8990_INTDRIVBITS 0x3F | ||
82 | 81 | ||
83 | #define WM8990_EXT_ACCESS_ENA 0x75 | 82 | #define WM8990_EXT_ACCESS_ENA 0x75 |
84 | #define WM8990_EXT_CTL1 0x7a | 83 | #define WM8990_EXT_CTL1 0x7a |
@@ -818,14 +817,6 @@ | |||
818 | */ | 817 | */ |
819 | #define WM8990_PLLK2_MASK 0x00FF /* PLLK2 - [7:0] */ | 818 | #define WM8990_PLLK2_MASK 0x00FF /* PLLK2 - [7:0] */ |
820 | 819 | ||
821 | /* | ||
822 | * R63 (0x3F) - Internal Driver Bits | ||
823 | */ | ||
824 | #define WM8990_INMIXL_PWR_BIT 0 | ||
825 | #define WM8990_AINLMUX_PWR_BIT 1 | ||
826 | #define WM8990_INMIXR_PWR_BIT 2 | ||
827 | #define WM8990_AINRMUX_PWR_BIT 3 | ||
828 | |||
829 | #define WM8990_MCLK_DIV 0 | 820 | #define WM8990_MCLK_DIV 0 |
830 | #define WM8990_DACCLK_DIV 1 | 821 | #define WM8990_DACCLK_DIV 1 |
831 | #define WM8990_ADCCLK_DIV 2 | 822 | #define WM8990_ADCCLK_DIV 2 |
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c index 3a39df7a3829..dba0306c42a5 100644 --- a/sound/soc/codecs/wm8991.c +++ b/sound/soc/codecs/wm8991.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/pm.h> | 19 | #include <linux/pm.h> |
20 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
21 | #include <linux/regmap.h> | ||
21 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
22 | #include <sound/core.h> | 23 | #include <sound/core.h> |
23 | #include <sound/pcm.h> | 24 | #include <sound/pcm.h> |
@@ -31,77 +32,84 @@ | |||
31 | #include "wm8991.h" | 32 | #include "wm8991.h" |
32 | 33 | ||
33 | struct wm8991_priv { | 34 | struct wm8991_priv { |
34 | enum snd_soc_control_type control_type; | 35 | struct regmap *regmap; |
35 | unsigned int pcmclk; | 36 | unsigned int pcmclk; |
36 | }; | 37 | }; |
37 | 38 | ||
38 | static const u16 wm8991_reg_defs[] = { | 39 | static const struct reg_default wm8991_reg_defaults[] = { |
39 | 0x8991, /* R0 - Reset */ | 40 | { 1, 0x0000 }, /* R1 - Power Management (1) */ |
40 | 0x0000, /* R1 - Power Management (1) */ | 41 | { 2, 0x6000 }, /* R2 - Power Management (2) */ |
41 | 0x6000, /* R2 - Power Management (2) */ | 42 | { 3, 0x0000 }, /* R3 - Power Management (3) */ |
42 | 0x0000, /* R3 - Power Management (3) */ | 43 | { 4, 0x4050 }, /* R4 - Audio Interface (1) */ |
43 | 0x4050, /* R4 - Audio Interface (1) */ | 44 | { 5, 0x4000 }, /* R5 - Audio Interface (2) */ |
44 | 0x4000, /* R5 - Audio Interface (2) */ | 45 | { 6, 0x01C8 }, /* R6 - Clocking (1) */ |
45 | 0x01C8, /* R6 - Clocking (1) */ | 46 | { 7, 0x0000 }, /* R7 - Clocking (2) */ |
46 | 0x0000, /* R7 - Clocking (2) */ | 47 | { 8, 0x0040 }, /* R8 - Audio Interface (3) */ |
47 | 0x0040, /* R8 - Audio Interface (3) */ | 48 | { 9, 0x0040 }, /* R9 - Audio Interface (4) */ |
48 | 0x0040, /* R9 - Audio Interface (4) */ | 49 | { 10, 0x0004 }, /* R10 - DAC CTRL */ |
49 | 0x0004, /* R10 - DAC CTRL */ | 50 | { 11, 0x00C0 }, /* R11 - Left DAC Digital Volume */ |
50 | 0x00C0, /* R11 - Left DAC Digital Volume */ | 51 | { 12, 0x00C0 }, /* R12 - Right DAC Digital Volume */ |
51 | 0x00C0, /* R12 - Right DAC Digital Volume */ | 52 | { 13, 0x0000 }, /* R13 - Digital Side Tone */ |
52 | 0x0000, /* R13 - Digital Side Tone */ | 53 | { 14, 0x0100 }, /* R14 - ADC CTRL */ |
53 | 0x0100, /* R14 - ADC CTRL */ | 54 | { 15, 0x00C0 }, /* R15 - Left ADC Digital Volume */ |
54 | 0x00C0, /* R15 - Left ADC Digital Volume */ | 55 | { 16, 0x00C0 }, /* R16 - Right ADC Digital Volume */ |
55 | 0x00C0, /* R16 - Right ADC Digital Volume */ | 56 | |
56 | 0x0000, /* R17 */ | 57 | { 18, 0x0000 }, /* R18 - GPIO CTRL 1 */ |
57 | 0x0000, /* R18 - GPIO CTRL 1 */ | 58 | { 19, 0x1000 }, /* R19 - GPIO1 & GPIO2 */ |
58 | 0x1000, /* R19 - GPIO1 & GPIO2 */ | 59 | { 20, 0x1010 }, /* R20 - GPIO3 & GPIO4 */ |
59 | 0x1010, /* R20 - GPIO3 & GPIO4 */ | 60 | { 21, 0x1010 }, /* R21 - GPIO5 & GPIO6 */ |
60 | 0x1010, /* R21 - GPIO5 & GPIO6 */ | 61 | { 22, 0x8000 }, /* R22 - GPIOCTRL 2 */ |
61 | 0x8000, /* R22 - GPIOCTRL 2 */ | 62 | { 23, 0x0800 }, /* R23 - GPIO_POL */ |
62 | 0x0800, /* R23 - GPIO_POL */ | 63 | { 24, 0x008B }, /* R24 - Left Line Input 1&2 Volume */ |
63 | 0x008B, /* R24 - Left Line Input 1&2 Volume */ | 64 | { 25, 0x008B }, /* R25 - Left Line Input 3&4 Volume */ |
64 | 0x008B, /* R25 - Left Line Input 3&4 Volume */ | 65 | { 26, 0x008B }, /* R26 - Right Line Input 1&2 Volume */ |
65 | 0x008B, /* R26 - Right Line Input 1&2 Volume */ | 66 | { 27, 0x008B }, /* R27 - Right Line Input 3&4 Volume */ |
66 | 0x008B, /* R27 - Right Line Input 3&4 Volume */ | 67 | { 28, 0x0000 }, /* R28 - Left Output Volume */ |
67 | 0x0000, /* R28 - Left Output Volume */ | 68 | { 29, 0x0000 }, /* R29 - Right Output Volume */ |
68 | 0x0000, /* R29 - Right Output Volume */ | 69 | { 30, 0x0066 }, /* R30 - Line Outputs Volume */ |
69 | 0x0066, /* R30 - Line Outputs Volume */ | 70 | { 31, 0x0022 }, /* R31 - Out3/4 Volume */ |
70 | 0x0022, /* R31 - Out3/4 Volume */ | 71 | { 32, 0x0079 }, /* R32 - Left OPGA Volume */ |
71 | 0x0079, /* R32 - Left OPGA Volume */ | 72 | { 33, 0x0079 }, /* R33 - Right OPGA Volume */ |
72 | 0x0079, /* R33 - Right OPGA Volume */ | 73 | { 34, 0x0003 }, /* R34 - Speaker Volume */ |
73 | 0x0003, /* R34 - Speaker Volume */ | 74 | { 35, 0x0003 }, /* R35 - ClassD1 */ |
74 | 0x0003, /* R35 - ClassD1 */ | 75 | |
75 | 0x0000, /* R36 */ | 76 | { 37, 0x0100 }, /* R37 - ClassD3 */ |
76 | 0x0100, /* R37 - ClassD3 */ | 77 | |
77 | 0x0000, /* R38 */ | 78 | { 39, 0x0000 }, /* R39 - Input Mixer1 */ |
78 | 0x0000, /* R39 - Input Mixer1 */ | 79 | { 40, 0x0000 }, /* R40 - Input Mixer2 */ |
79 | 0x0000, /* R40 - Input Mixer2 */ | 80 | { 41, 0x0000 }, /* R41 - Input Mixer3 */ |
80 | 0x0000, /* R41 - Input Mixer3 */ | 81 | { 42, 0x0000 }, /* R42 - Input Mixer4 */ |
81 | 0x0000, /* R42 - Input Mixer4 */ | 82 | { 43, 0x0000 }, /* R43 - Input Mixer5 */ |
82 | 0x0000, /* R43 - Input Mixer5 */ | 83 | { 44, 0x0000 }, /* R44 - Input Mixer6 */ |
83 | 0x0000, /* R44 - Input Mixer6 */ | 84 | { 45, 0x0000 }, /* R45 - Output Mixer1 */ |
84 | 0x0000, /* R45 - Output Mixer1 */ | 85 | { 46, 0x0000 }, /* R46 - Output Mixer2 */ |
85 | 0x0000, /* R46 - Output Mixer2 */ | 86 | { 47, 0x0000 }, /* R47 - Output Mixer3 */ |
86 | 0x0000, /* R47 - Output Mixer3 */ | 87 | { 48, 0x0000 }, /* R48 - Output Mixer4 */ |
87 | 0x0000, /* R48 - Output Mixer4 */ | 88 | { 49, 0x0000 }, /* R49 - Output Mixer5 */ |
88 | 0x0000, /* R49 - Output Mixer5 */ | 89 | { 50, 0x0000 }, /* R50 - Output Mixer6 */ |
89 | 0x0000, /* R50 - Output Mixer6 */ | 90 | { 51, 0x0180 }, /* R51 - Out3/4 Mixer */ |
90 | 0x0180, /* R51 - Out3/4 Mixer */ | 91 | { 52, 0x0000 }, /* R52 - Line Mixer1 */ |
91 | 0x0000, /* R52 - Line Mixer1 */ | 92 | { 53, 0x0000 }, /* R53 - Line Mixer2 */ |
92 | 0x0000, /* R53 - Line Mixer2 */ | 93 | { 54, 0x0000 }, /* R54 - Speaker Mixer */ |
93 | 0x0000, /* R54 - Speaker Mixer */ | 94 | { 55, 0x0000 }, /* R55 - Additional Control */ |
94 | 0x0000, /* R55 - Additional Control */ | 95 | { 56, 0x0000 }, /* R56 - AntiPOP1 */ |
95 | 0x0000, /* R56 - AntiPOP1 */ | 96 | { 57, 0x0000 }, /* R57 - AntiPOP2 */ |
96 | 0x0000, /* R57 - AntiPOP2 */ | 97 | { 58, 0x0000 }, /* R58 - MICBIAS */ |
97 | 0x0000, /* R58 - MICBIAS */ | 98 | |
98 | 0x0000, /* R59 */ | 99 | { 60, 0x0008 }, /* R60 - PLL1 */ |
99 | 0x0008, /* R60 - PLL1 */ | 100 | { 61, 0x0031 }, /* R61 - PLL2 */ |
100 | 0x0031, /* R61 - PLL2 */ | 101 | { 62, 0x0026 }, /* R62 - PLL3 */ |
101 | 0x0026, /* R62 - PLL3 */ | ||
102 | }; | 102 | }; |
103 | 103 | ||
104 | #define wm8991_reset(c) snd_soc_write(c, WM8991_RESET, 0) | 104 | static bool wm8991_volatile(struct device *dev, unsigned int reg) |
105 | { | ||
106 | switch (reg) { | ||
107 | case WM8991_RESET: | ||
108 | return true; | ||
109 | default: | ||
110 | return false; | ||
111 | } | ||
112 | } | ||
105 | 113 | ||
106 | static const unsigned int rec_mix_tlv[] = { | 114 | static const unsigned int rec_mix_tlv[] = { |
107 | TLV_DB_RANGE_HEAD(1), | 115 | TLV_DB_RANGE_HEAD(1), |
@@ -374,30 +382,6 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = { | |||
374 | /* | 382 | /* |
375 | * _DAPM_ Controls | 383 | * _DAPM_ Controls |
376 | */ | 384 | */ |
377 | static int inmixer_event(struct snd_soc_dapm_widget *w, | ||
378 | struct snd_kcontrol *kcontrol, int event) | ||
379 | { | ||
380 | u16 reg, fakepower; | ||
381 | |||
382 | reg = snd_soc_read(w->codec, WM8991_POWER_MANAGEMENT_2); | ||
383 | fakepower = snd_soc_read(w->codec, WM8991_INTDRIVBITS); | ||
384 | |||
385 | if (fakepower & ((1 << WM8991_INMIXL_PWR_BIT) | | ||
386 | (1 << WM8991_AINLMUX_PWR_BIT))) | ||
387 | reg |= WM8991_AINL_ENA; | ||
388 | else | ||
389 | reg &= ~WM8991_AINL_ENA; | ||
390 | |||
391 | if (fakepower & ((1 << WM8991_INMIXR_PWR_BIT) | | ||
392 | (1 << WM8991_AINRMUX_PWR_BIT))) | ||
393 | reg |= WM8991_AINR_ENA; | ||
394 | else | ||
395 | reg &= ~WM8991_AINR_ENA; | ||
396 | |||
397 | snd_soc_write(w->codec, WM8991_POWER_MANAGEMENT_2, reg); | ||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static int outmixer_event(struct snd_soc_dapm_widget *w, | 385 | static int outmixer_event(struct snd_soc_dapm_widget *w, |
402 | struct snd_kcontrol *kcontrol, int event) | 386 | struct snd_kcontrol *kcontrol, int event) |
403 | { | 387 | { |
@@ -655,6 +639,11 @@ static const struct snd_soc_dapm_widget wm8991_dapm_widgets[] = { | |||
655 | SND_SOC_DAPM_INPUT("RIN2"), | 639 | SND_SOC_DAPM_INPUT("RIN2"), |
656 | SND_SOC_DAPM_INPUT("Internal ADC Source"), | 640 | SND_SOC_DAPM_INPUT("Internal ADC Source"), |
657 | 641 | ||
642 | SND_SOC_DAPM_SUPPLY("INL", WM8991_POWER_MANAGEMENT_2, | ||
643 | WM8991_AINL_ENA_BIT, 0, NULL, 0), | ||
644 | SND_SOC_DAPM_SUPPLY("INR", WM8991_POWER_MANAGEMENT_2, | ||
645 | WM8991_AINR_ENA_BIT, 0, NULL, 0), | ||
646 | |||
658 | /* DACs */ | 647 | /* DACs */ |
659 | SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8991_POWER_MANAGEMENT_2, | 648 | SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8991_POWER_MANAGEMENT_2, |
660 | WM8991_ADCL_ENA_BIT, 0), | 649 | WM8991_ADCL_ENA_BIT, 0), |
@@ -676,26 +665,22 @@ static const struct snd_soc_dapm_widget wm8991_dapm_widgets[] = { | |||
676 | ARRAY_SIZE(wm8991_dapm_rin34_pga_controls)), | 665 | ARRAY_SIZE(wm8991_dapm_rin34_pga_controls)), |
677 | 666 | ||
678 | /* INMIXL */ | 667 | /* INMIXL */ |
679 | SND_SOC_DAPM_MIXER_E("INMIXL", WM8991_INTDRIVBITS, WM8991_INMIXL_PWR_BIT, 0, | 668 | SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0, |
680 | &wm8991_dapm_inmixl_controls[0], | 669 | &wm8991_dapm_inmixl_controls[0], |
681 | ARRAY_SIZE(wm8991_dapm_inmixl_controls), | 670 | ARRAY_SIZE(wm8991_dapm_inmixl_controls)), |
682 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
683 | 671 | ||
684 | /* AINLMUX */ | 672 | /* AINLMUX */ |
685 | SND_SOC_DAPM_MUX_E("AINLMUX", WM8991_INTDRIVBITS, WM8991_AINLMUX_PWR_BIT, 0, | 673 | SND_SOC_DAPM_MUX("AINLMUX", SND_SOC_NOPM, 0, 0, |
686 | &wm8991_dapm_ainlmux_controls, inmixer_event, | 674 | &wm8991_dapm_ainlmux_controls), |
687 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
688 | 675 | ||
689 | /* INMIXR */ | 676 | /* INMIXR */ |
690 | SND_SOC_DAPM_MIXER_E("INMIXR", WM8991_INTDRIVBITS, WM8991_INMIXR_PWR_BIT, 0, | 677 | SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0, |
691 | &wm8991_dapm_inmixr_controls[0], | 678 | &wm8991_dapm_inmixr_controls[0], |
692 | ARRAY_SIZE(wm8991_dapm_inmixr_controls), | 679 | ARRAY_SIZE(wm8991_dapm_inmixr_controls)), |
693 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
694 | 680 | ||
695 | /* AINRMUX */ | 681 | /* AINRMUX */ |
696 | SND_SOC_DAPM_MUX_E("AINRMUX", WM8991_INTDRIVBITS, WM8991_AINRMUX_PWR_BIT, 0, | 682 | SND_SOC_DAPM_MUX("AINRMUX", SND_SOC_NOPM, 0, 0, |
697 | &wm8991_dapm_ainrmux_controls, inmixer_event, | 683 | &wm8991_dapm_ainrmux_controls), |
698 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
699 | 684 | ||
700 | /* Output Side */ | 685 | /* Output Side */ |
701 | /* DACs */ | 686 | /* DACs */ |
@@ -787,7 +772,7 @@ static const struct snd_soc_dapm_widget wm8991_dapm_widgets[] = { | |||
787 | SND_SOC_DAPM_OUTPUT("Internal DAC Sink"), | 772 | SND_SOC_DAPM_OUTPUT("Internal DAC Sink"), |
788 | }; | 773 | }; |
789 | 774 | ||
790 | static const struct snd_soc_dapm_route audio_map[] = { | 775 | static const struct snd_soc_dapm_route wm8991_dapm_routes[] = { |
791 | /* Make DACs turn on when playing even if not mixed into any outputs */ | 776 | /* Make DACs turn on when playing even if not mixed into any outputs */ |
792 | {"Internal DAC Sink", NULL, "Left DAC"}, | 777 | {"Internal DAC Sink", NULL, "Left DAC"}, |
793 | {"Internal DAC Sink", NULL, "Right DAC"}, | 778 | {"Internal DAC Sink", NULL, "Right DAC"}, |
@@ -797,6 +782,10 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
797 | {"Right ADC", NULL, "Internal ADC Source"}, | 782 | {"Right ADC", NULL, "Internal ADC Source"}, |
798 | 783 | ||
799 | /* Input Side */ | 784 | /* Input Side */ |
785 | {"INMIXL", NULL, "INL"}, | ||
786 | {"AINLMUX", NULL, "INL"}, | ||
787 | {"INMIXR", NULL, "INR"}, | ||
788 | {"AINRMUX", NULL, "INR"}, | ||
800 | /* LIN12 PGA */ | 789 | /* LIN12 PGA */ |
801 | {"LIN12 PGA", "LIN1 Switch", "LIN1"}, | 790 | {"LIN12 PGA", "LIN1 Switch", "LIN1"}, |
802 | {"LIN12 PGA", "LIN2 Switch", "LIN2"}, | 791 | {"LIN12 PGA", "LIN2 Switch", "LIN2"}, |
@@ -1129,6 +1118,7 @@ static int wm8991_mute(struct snd_soc_dai *dai, int mute) | |||
1129 | static int wm8991_set_bias_level(struct snd_soc_codec *codec, | 1118 | static int wm8991_set_bias_level(struct snd_soc_codec *codec, |
1130 | enum snd_soc_bias_level level) | 1119 | enum snd_soc_bias_level level) |
1131 | { | 1120 | { |
1121 | struct wm8991_priv *wm8991 = snd_soc_codec_get_drvdata(codec); | ||
1132 | u16 val; | 1122 | u16 val; |
1133 | 1123 | ||
1134 | switch (level) { | 1124 | switch (level) { |
@@ -1144,7 +1134,7 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec, | |||
1144 | 1134 | ||
1145 | case SND_SOC_BIAS_STANDBY: | 1135 | case SND_SOC_BIAS_STANDBY: |
1146 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { | 1136 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
1147 | snd_soc_cache_sync(codec); | 1137 | regcache_sync(wm8991->regmap); |
1148 | /* Enable all output discharge bits */ | 1138 | /* Enable all output discharge bits */ |
1149 | snd_soc_write(codec, WM8991_ANTIPOP1, WM8991_DIS_LLINE | | 1139 | snd_soc_write(codec, WM8991_ANTIPOP1, WM8991_DIS_LLINE | |
1150 | WM8991_DIS_RLINE | WM8991_DIS_OUT3 | | 1140 | WM8991_DIS_RLINE | WM8991_DIS_OUT3 | |
@@ -1232,7 +1222,7 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec, | |||
1232 | 1222 | ||
1233 | /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ | 1223 | /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ |
1234 | snd_soc_write(codec, WM8991_ANTIPOP2, 0x0); | 1224 | snd_soc_write(codec, WM8991_ANTIPOP2, 0x0); |
1235 | codec->cache_sync = 1; | 1225 | regcache_mark_dirty(wm8991->regmap); |
1236 | break; | 1226 | break; |
1237 | } | 1227 | } |
1238 | 1228 | ||
@@ -1266,44 +1256,14 @@ static int wm8991_probe(struct snd_soc_codec *codec) | |||
1266 | 1256 | ||
1267 | wm8991 = snd_soc_codec_get_drvdata(codec); | 1257 | wm8991 = snd_soc_codec_get_drvdata(codec); |
1268 | 1258 | ||
1269 | ret = snd_soc_codec_set_cache_io(codec, 8, 16, wm8991->control_type); | 1259 | ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); |
1270 | if (ret < 0) { | 1260 | if (ret < 0) { |
1271 | dev_err(codec->dev, "Failed to set cache i/o: %d\n", ret); | 1261 | dev_err(codec->dev, "Failed to set cache i/o: %d\n", ret); |
1272 | return ret; | 1262 | return ret; |
1273 | } | 1263 | } |
1274 | 1264 | ||
1275 | ret = wm8991_reset(codec); | ||
1276 | if (ret < 0) { | ||
1277 | dev_err(codec->dev, "Failed to issue reset\n"); | ||
1278 | return ret; | ||
1279 | } | ||
1280 | |||
1281 | wm8991_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1265 | wm8991_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
1282 | 1266 | ||
1283 | snd_soc_update_bits(codec, WM8991_AUDIO_INTERFACE_4, | ||
1284 | WM8991_ALRCGPIO1, WM8991_ALRCGPIO1); | ||
1285 | |||
1286 | snd_soc_update_bits(codec, WM8991_GPIO1_GPIO2, | ||
1287 | WM8991_GPIO1_SEL_MASK, 1); | ||
1288 | |||
1289 | snd_soc_update_bits(codec, WM8991_POWER_MANAGEMENT_1, | ||
1290 | WM8991_VREF_ENA | WM8991_VMID_MODE_MASK, | ||
1291 | WM8991_VREF_ENA | WM8991_VMID_MODE_MASK); | ||
1292 | |||
1293 | snd_soc_update_bits(codec, WM8991_POWER_MANAGEMENT_2, | ||
1294 | WM8991_OPCLK_ENA, WM8991_OPCLK_ENA); | ||
1295 | |||
1296 | snd_soc_write(codec, WM8991_DAC_CTRL, 0); | ||
1297 | snd_soc_write(codec, WM8991_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); | ||
1298 | snd_soc_write(codec, WM8991_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); | ||
1299 | |||
1300 | snd_soc_add_codec_controls(codec, wm8991_snd_controls, | ||
1301 | ARRAY_SIZE(wm8991_snd_controls)); | ||
1302 | |||
1303 | snd_soc_dapm_new_controls(&codec->dapm, wm8991_dapm_widgets, | ||
1304 | ARRAY_SIZE(wm8991_dapm_widgets)); | ||
1305 | snd_soc_dapm_add_routes(&codec->dapm, audio_map, | ||
1306 | ARRAY_SIZE(audio_map)); | ||
1307 | return 0; | 1267 | return 0; |
1308 | } | 1268 | } |
1309 | 1269 | ||
@@ -1352,24 +1312,77 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8991 = { | |||
1352 | .suspend = wm8991_suspend, | 1312 | .suspend = wm8991_suspend, |
1353 | .resume = wm8991_resume, | 1313 | .resume = wm8991_resume, |
1354 | .set_bias_level = wm8991_set_bias_level, | 1314 | .set_bias_level = wm8991_set_bias_level, |
1355 | .reg_cache_size = WM8991_MAX_REGISTER + 1, | 1315 | .controls = wm8991_snd_controls, |
1356 | .reg_word_size = sizeof(u16), | 1316 | .num_controls = ARRAY_SIZE(wm8991_snd_controls), |
1357 | .reg_cache_default = wm8991_reg_defs | 1317 | .dapm_widgets = wm8991_dapm_widgets, |
1318 | .num_dapm_widgets = ARRAY_SIZE(wm8991_dapm_widgets), | ||
1319 | .dapm_routes = wm8991_dapm_routes, | ||
1320 | .num_dapm_routes = ARRAY_SIZE(wm8991_dapm_routes), | ||
1321 | }; | ||
1322 | |||
1323 | static const struct regmap_config wm8991_regmap = { | ||
1324 | .reg_bits = 8, | ||
1325 | .val_bits = 16, | ||
1326 | |||
1327 | .max_register = WM8991_PLL3, | ||
1328 | .volatile_reg = wm8991_volatile, | ||
1329 | .reg_defaults = wm8991_reg_defaults, | ||
1330 | .num_reg_defaults = ARRAY_SIZE(wm8991_reg_defaults), | ||
1331 | .cache_type = REGCACHE_RBTREE, | ||
1358 | }; | 1332 | }; |
1359 | 1333 | ||
1360 | static int wm8991_i2c_probe(struct i2c_client *i2c, | 1334 | static int wm8991_i2c_probe(struct i2c_client *i2c, |
1361 | const struct i2c_device_id *id) | 1335 | const struct i2c_device_id *id) |
1362 | { | 1336 | { |
1363 | struct wm8991_priv *wm8991; | 1337 | struct wm8991_priv *wm8991; |
1338 | unsigned int val; | ||
1364 | int ret; | 1339 | int ret; |
1365 | 1340 | ||
1366 | wm8991 = devm_kzalloc(&i2c->dev, sizeof(*wm8991), GFP_KERNEL); | 1341 | wm8991 = devm_kzalloc(&i2c->dev, sizeof(*wm8991), GFP_KERNEL); |
1367 | if (!wm8991) | 1342 | if (!wm8991) |
1368 | return -ENOMEM; | 1343 | return -ENOMEM; |
1369 | 1344 | ||
1370 | wm8991->control_type = SND_SOC_I2C; | 1345 | wm8991->regmap = devm_regmap_init_i2c(i2c, &wm8991_regmap); |
1346 | if (IS_ERR(wm8991->regmap)) | ||
1347 | return PTR_ERR(wm8991->regmap); | ||
1348 | |||
1371 | i2c_set_clientdata(i2c, wm8991); | 1349 | i2c_set_clientdata(i2c, wm8991); |
1372 | 1350 | ||
1351 | ret = regmap_read(wm8991->regmap, WM8991_RESET, &val); | ||
1352 | if (ret != 0) { | ||
1353 | dev_err(&i2c->dev, "Failed to read device ID: %d\n", ret); | ||
1354 | return ret; | ||
1355 | } | ||
1356 | if (val != 0x8991) { | ||
1357 | dev_err(&i2c->dev, "Device with ID %x is not a WM8991\n", val); | ||
1358 | return -EINVAL; | ||
1359 | } | ||
1360 | |||
1361 | ret = regmap_write(wm8991->regmap, WM8991_RESET, 0); | ||
1362 | if (ret < 0) { | ||
1363 | dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); | ||
1364 | return ret; | ||
1365 | } | ||
1366 | |||
1367 | regmap_update_bits(wm8991->regmap, WM8991_AUDIO_INTERFACE_4, | ||
1368 | WM8991_ALRCGPIO1, WM8991_ALRCGPIO1); | ||
1369 | |||
1370 | regmap_update_bits(wm8991->regmap, WM8991_GPIO1_GPIO2, | ||
1371 | WM8991_GPIO1_SEL_MASK, 1); | ||
1372 | |||
1373 | regmap_update_bits(wm8991->regmap, WM8991_POWER_MANAGEMENT_1, | ||
1374 | WM8991_VREF_ENA | WM8991_VMID_MODE_MASK, | ||
1375 | WM8991_VREF_ENA | WM8991_VMID_MODE_MASK); | ||
1376 | |||
1377 | regmap_update_bits(wm8991->regmap, WM8991_POWER_MANAGEMENT_2, | ||
1378 | WM8991_OPCLK_ENA, WM8991_OPCLK_ENA); | ||
1379 | |||
1380 | regmap_write(wm8991->regmap, WM8991_DAC_CTRL, 0); | ||
1381 | regmap_write(wm8991->regmap, WM8991_LEFT_OUTPUT_VOLUME, | ||
1382 | 0x50 | (1<<8)); | ||
1383 | regmap_write(wm8991->regmap, WM8991_RIGHT_OUTPUT_VOLUME, | ||
1384 | 0x50 | (1<<8)); | ||
1385 | |||
1373 | ret = snd_soc_register_codec(&i2c->dev, | 1386 | ret = snd_soc_register_codec(&i2c->dev, |
1374 | &soc_codec_dev_wm8991, &wm8991_dai, 1); | 1387 | &soc_codec_dev_wm8991, &wm8991_dai, 1); |
1375 | 1388 | ||
diff --git a/sound/soc/codecs/wm8991.h b/sound/soc/codecs/wm8991.h index 07707d8d7e20..08ed383303c0 100644 --- a/sound/soc/codecs/wm8991.h +++ b/sound/soc/codecs/wm8991.h | |||
@@ -76,7 +76,6 @@ | |||
76 | #define WM8991_PLL1 0x3C | 76 | #define WM8991_PLL1 0x3C |
77 | #define WM8991_PLL2 0x3D | 77 | #define WM8991_PLL2 0x3D |
78 | #define WM8991_PLL3 0x3E | 78 | #define WM8991_PLL3 0x3E |
79 | #define WM8991_INTDRIVBITS 0x3F | ||
80 | 79 | ||
81 | #define WM8991_REGISTER_COUNT 60 | 80 | #define WM8991_REGISTER_COUNT 60 |
82 | #define WM8991_MAX_REGISTER 0x3F | 81 | #define WM8991_MAX_REGISTER 0x3F |
@@ -807,14 +806,6 @@ | |||
807 | */ | 806 | */ |
808 | #define WM8991_PLLK2_MASK 0x00FF /* PLLK2 - [7:0] */ | 807 | #define WM8991_PLLK2_MASK 0x00FF /* PLLK2 - [7:0] */ |
809 | 808 | ||
810 | /* | ||
811 | * R63 (0x3F) - Internal Driver Bits | ||
812 | */ | ||
813 | #define WM8991_INMIXL_PWR_BIT 0 | ||
814 | #define WM8991_AINLMUX_PWR_BIT 1 | ||
815 | #define WM8991_INMIXR_PWR_BIT 2 | ||
816 | #define WM8991_AINRMUX_PWR_BIT 3 | ||
817 | |||
818 | #define WM8991_MCLK_DIV 0 | 809 | #define WM8991_MCLK_DIV 0 |
819 | #define WM8991_DACCLK_DIV 1 | 810 | #define WM8991_DACCLK_DIV 1 |
820 | #define WM8991_ADCCLK_DIV 2 | 811 | #define WM8991_ADCCLK_DIV 2 |
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 86426a117b07..b9be9cbc4603 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c | |||
@@ -4077,12 +4077,6 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) | |||
4077 | wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, | 4077 | wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, |
4078 | wm8994_temp_shut, "Thermal shutdown", codec); | 4078 | wm8994_temp_shut, "Thermal shutdown", codec); |
4079 | 4079 | ||
4080 | ret = wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, | ||
4081 | wm_hubs_dcs_done, "DC servo done", | ||
4082 | &wm8994->hubs); | ||
4083 | if (ret == 0) | ||
4084 | wm8994->hubs.dcs_done_irq = true; | ||
4085 | |||
4086 | switch (control->type) { | 4080 | switch (control->type) { |
4087 | case WM8994: | 4081 | case WM8994: |
4088 | if (wm8994->micdet_irq) { | 4082 | if (wm8994->micdet_irq) { |
@@ -4313,6 +4307,11 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) | |||
4313 | } | 4307 | } |
4314 | 4308 | ||
4315 | wm_hubs_add_analogue_routes(codec, 0, 0); | 4309 | wm_hubs_add_analogue_routes(codec, 0, 0); |
4310 | ret = wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, | ||
4311 | wm_hubs_dcs_done, "DC servo done", | ||
4312 | &wm8994->hubs); | ||
4313 | if (ret == 0) | ||
4314 | wm8994->hubs.dcs_done_irq = true; | ||
4316 | snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon)); | 4315 | snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon)); |
4317 | 4316 | ||
4318 | switch (control->type) { | 4317 | switch (control->type) { |
diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c index da2899e6c401..4300caff1783 100644 --- a/sound/soc/codecs/wm8995.c +++ b/sound/soc/codecs/wm8995.c | |||
@@ -2293,7 +2293,7 @@ static struct spi_driver wm8995_spi_driver = { | |||
2293 | }; | 2293 | }; |
2294 | #endif | 2294 | #endif |
2295 | 2295 | ||
2296 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 2296 | #if IS_ENABLED(CONFIG_I2C) |
2297 | static int wm8995_i2c_probe(struct i2c_client *i2c, | 2297 | static int wm8995_i2c_probe(struct i2c_client *i2c, |
2298 | const struct i2c_device_id *id) | 2298 | const struct i2c_device_id *id) |
2299 | { | 2299 | { |
@@ -2350,7 +2350,7 @@ static int __init wm8995_modinit(void) | |||
2350 | { | 2350 | { |
2351 | int ret = 0; | 2351 | int ret = 0; |
2352 | 2352 | ||
2353 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 2353 | #if IS_ENABLED(CONFIG_I2C) |
2354 | ret = i2c_add_driver(&wm8995_i2c_driver); | 2354 | ret = i2c_add_driver(&wm8995_i2c_driver); |
2355 | if (ret) { | 2355 | if (ret) { |
2356 | printk(KERN_ERR "Failed to register wm8995 I2C driver: %d\n", | 2356 | printk(KERN_ERR "Failed to register wm8995 I2C driver: %d\n", |
@@ -2371,7 +2371,7 @@ module_init(wm8995_modinit); | |||
2371 | 2371 | ||
2372 | static void __exit wm8995_exit(void) | 2372 | static void __exit wm8995_exit(void) |
2373 | { | 2373 | { |
2374 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 2374 | #if IS_ENABLED(CONFIG_I2C) |
2375 | i2c_del_driver(&wm8995_i2c_driver); | 2375 | i2c_del_driver(&wm8995_i2c_driver); |
2376 | #endif | 2376 | #endif |
2377 | #if defined(CONFIG_SPI_MASTER) | 2377 | #if defined(CONFIG_SPI_MASTER) |
diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 1392bb3c9254..555115ee2159 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c | |||
@@ -103,8 +103,8 @@ static int wm8997_sysclk_ev(struct snd_soc_dapm_widget *w, | |||
103 | case SND_SOC_DAPM_POST_PMU: | 103 | case SND_SOC_DAPM_POST_PMU: |
104 | if (patch) | 104 | if (patch) |
105 | for (i = 0; i < patch_size; i++) | 105 | for (i = 0; i < patch_size; i++) |
106 | regmap_write(regmap, patch[i].reg, | 106 | regmap_write_async(regmap, patch[i].reg, |
107 | patch[i].def); | 107 | patch[i].def); |
108 | break; | 108 | break; |
109 | default: | 109 | default: |
110 | break; | 110 | break; |
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index 630b3d776ec2..0982c1d38ec4 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c | |||
@@ -1326,7 +1326,7 @@ static const struct regmap_config wm9081_regmap = { | |||
1326 | .cache_type = REGCACHE_RBTREE, | 1326 | .cache_type = REGCACHE_RBTREE, |
1327 | }; | 1327 | }; |
1328 | 1328 | ||
1329 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1329 | #if IS_ENABLED(CONFIG_I2C) |
1330 | static int wm9081_i2c_probe(struct i2c_client *i2c, | 1330 | static int wm9081_i2c_probe(struct i2c_client *i2c, |
1331 | const struct i2c_device_id *id) | 1331 | const struct i2c_device_id *id) |
1332 | { | 1332 | { |
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 4fbcab63e61f..fb0c678939bf 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c | |||
@@ -1286,6 +1286,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp) | |||
1286 | reg = wm_adsp_region_to_reg(mem, | 1286 | reg = wm_adsp_region_to_reg(mem, |
1287 | reg); | 1287 | reg); |
1288 | reg += offset; | 1288 | reg += offset; |
1289 | break; | ||
1289 | } | 1290 | } |
1290 | } | 1291 | } |
1291 | 1292 | ||
@@ -1468,8 +1469,8 @@ static int wm_adsp2_ena(struct wm_adsp *dsp) | |||
1468 | unsigned int val; | 1469 | unsigned int val; |
1469 | int ret, count; | 1470 | int ret, count; |
1470 | 1471 | ||
1471 | ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, | 1472 | ret = regmap_update_bits_async(dsp->regmap, dsp->base + ADSP2_CONTROL, |
1472 | ADSP2_SYS_ENA, ADSP2_SYS_ENA); | 1473 | ADSP2_SYS_ENA, ADSP2_SYS_ENA); |
1473 | if (ret != 0) | 1474 | if (ret != 0) |
1474 | return ret; | 1475 | return ret; |
1475 | 1476 | ||
@@ -1492,7 +1493,6 @@ static int wm_adsp2_ena(struct wm_adsp *dsp) | |||
1492 | } | 1493 | } |
1493 | 1494 | ||
1494 | adsp_dbg(dsp, "RAM ready after %d polls\n", count); | 1495 | adsp_dbg(dsp, "RAM ready after %d polls\n", count); |
1495 | adsp_info(dsp, "RAM ready after %d polls\n", count); | ||
1496 | 1496 | ||
1497 | return 0; | 1497 | return 0; |
1498 | } | 1498 | } |
@@ -1525,9 +1525,9 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, | |||
1525 | val = (val & ARIZONA_SYSCLK_FREQ_MASK) | 1525 | val = (val & ARIZONA_SYSCLK_FREQ_MASK) |
1526 | >> ARIZONA_SYSCLK_FREQ_SHIFT; | 1526 | >> ARIZONA_SYSCLK_FREQ_SHIFT; |
1527 | 1527 | ||
1528 | ret = regmap_update_bits(dsp->regmap, | 1528 | ret = regmap_update_bits_async(dsp->regmap, |
1529 | dsp->base + ADSP2_CLOCKING, | 1529 | dsp->base + ADSP2_CLOCKING, |
1530 | ADSP2_CLK_SEL_MASK, val); | 1530 | ADSP2_CLK_SEL_MASK, val); |
1531 | if (ret != 0) { | 1531 | if (ret != 0) { |
1532 | adsp_err(dsp, "Failed to set clock rate: %d\n", | 1532 | adsp_err(dsp, "Failed to set clock rate: %d\n", |
1533 | ret); | 1533 | ret); |
@@ -1590,10 +1590,10 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w, | |||
1590 | if (ret != 0) | 1590 | if (ret != 0) |
1591 | goto err; | 1591 | goto err; |
1592 | 1592 | ||
1593 | ret = regmap_update_bits(dsp->regmap, | 1593 | ret = regmap_update_bits_async(dsp->regmap, |
1594 | dsp->base + ADSP2_CONTROL, | 1594 | dsp->base + ADSP2_CONTROL, |
1595 | ADSP2_CORE_ENA | ADSP2_START, | 1595 | ADSP2_CORE_ENA | ADSP2_START, |
1596 | ADSP2_CORE_ENA | ADSP2_START); | 1596 | ADSP2_CORE_ENA | ADSP2_START); |
1597 | if (ret != 0) | 1597 | if (ret != 0) |
1598 | goto err; | 1598 | goto err; |
1599 | 1599 | ||
diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig index 95970f5db3ec..a8ec1fc3e4d0 100644 --- a/sound/soc/davinci/Kconfig +++ b/sound/soc/davinci/Kconfig | |||
@@ -1,11 +1,6 @@ | |||
1 | config SND_DAVINCI_SOC | 1 | config SND_DAVINCI_SOC |
2 | tristate "SoC Audio for the TI DAVINCI or AM33XX chip" | 2 | tristate "SoC Audio for TI DAVINCI or AM33XX/AM43XX chips" |
3 | depends on ARCH_DAVINCI || SOC_AM33XX | 3 | depends on ARCH_DAVINCI || SOC_AM33XX || SOC_AM43XX |
4 | help | ||
5 | Platform driver for daVinci or AM33xx | ||
6 | Say Y or M if you want to add support for codecs attached to | ||
7 | the DAVINCI AC97, I2S, or McASP interface. You will also need | ||
8 | to select the audio interfaces to support below. | ||
9 | 4 | ||
10 | config SND_DAVINCI_SOC_I2S | 5 | config SND_DAVINCI_SOC_I2S |
11 | tristate | 6 | tristate |
@@ -16,11 +11,15 @@ config SND_DAVINCI_SOC_MCASP | |||
16 | config SND_DAVINCI_SOC_VCIF | 11 | config SND_DAVINCI_SOC_VCIF |
17 | tristate | 12 | tristate |
18 | 13 | ||
14 | config SND_DAVINCI_SOC_GENERIC_EVM | ||
15 | tristate | ||
16 | select SND_SOC_TLV320AIC3X | ||
17 | select SND_DAVINCI_SOC_MCASP | ||
18 | |||
19 | config SND_AM33XX_SOC_EVM | 19 | config SND_AM33XX_SOC_EVM |
20 | tristate "SoC Audio for the AM33XX chip based boards" | 20 | tristate "SoC Audio for the AM33XX chip based boards" |
21 | depends on SND_DAVINCI_SOC && SOC_AM33XX | 21 | depends on SND_DAVINCI_SOC && SOC_AM33XX |
22 | select SND_SOC_TLV320AIC3X | 22 | select SND_DAVINCI_SOC_GENERIC_EVM |
23 | select SND_DAVINCI_SOC_MCASP | ||
24 | help | 23 | help |
25 | Say Y or M if you want to add support for SoC audio on AM33XX | 24 | Say Y or M if you want to add support for SoC audio on AM33XX |
26 | boards using McASP and TLV320AIC3X codec. For example AM335X-EVM, | 25 | boards using McASP and TLV320AIC3X codec. For example AM335X-EVM, |
@@ -31,8 +30,7 @@ config SND_DAVINCI_SOC_EVM | |||
31 | tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM" | 30 | tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM" |
32 | depends on SND_DAVINCI_SOC | 31 | depends on SND_DAVINCI_SOC |
33 | depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM | 32 | depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM |
34 | select SND_DAVINCI_SOC_I2S | 33 | select SND_DAVINCI_SOC_GENERIC_EVM |
35 | select SND_SOC_TLV320AIC3X | ||
36 | help | 34 | help |
37 | Say Y if you want to add support for SoC audio on TI | 35 | Say Y if you want to add support for SoC audio on TI |
38 | DaVinci DM6446, DM355 or DM365 EVM platforms. | 36 | DaVinci DM6446, DM355 or DM365 EVM platforms. |
@@ -59,8 +57,7 @@ endchoice | |||
59 | config SND_DM6467_SOC_EVM | 57 | config SND_DM6467_SOC_EVM |
60 | tristate "SoC Audio support for DaVinci DM6467 EVM" | 58 | tristate "SoC Audio support for DaVinci DM6467 EVM" |
61 | depends on SND_DAVINCI_SOC && MACH_DAVINCI_DM6467_EVM | 59 | depends on SND_DAVINCI_SOC && MACH_DAVINCI_DM6467_EVM |
62 | select SND_DAVINCI_SOC_MCASP | 60 | select SND_DAVINCI_SOC_GENERIC_EVM |
63 | select SND_SOC_TLV320AIC3X | ||
64 | select SND_SOC_SPDIF | 61 | select SND_SOC_SPDIF |
65 | 62 | ||
66 | help | 63 | help |
@@ -69,8 +66,7 @@ config SND_DM6467_SOC_EVM | |||
69 | config SND_DA830_SOC_EVM | 66 | config SND_DA830_SOC_EVM |
70 | tristate "SoC Audio support for DA830/OMAP-L137 EVM" | 67 | tristate "SoC Audio support for DA830/OMAP-L137 EVM" |
71 | depends on SND_DAVINCI_SOC && MACH_DAVINCI_DA830_EVM | 68 | depends on SND_DAVINCI_SOC && MACH_DAVINCI_DA830_EVM |
72 | select SND_DAVINCI_SOC_MCASP | 69 | select SND_DAVINCI_SOC_GENERIC_EVM |
73 | select SND_SOC_TLV320AIC3X | ||
74 | 70 | ||
75 | help | 71 | help |
76 | Say Y if you want to add support for SoC audio on TI | 72 | Say Y if you want to add support for SoC audio on TI |
@@ -79,8 +75,7 @@ config SND_DA830_SOC_EVM | |||
79 | config SND_DA850_SOC_EVM | 75 | config SND_DA850_SOC_EVM |
80 | tristate "SoC Audio support for DA850/OMAP-L138 EVM" | 76 | tristate "SoC Audio support for DA850/OMAP-L138 EVM" |
81 | depends on SND_DAVINCI_SOC && MACH_DAVINCI_DA850_EVM | 77 | depends on SND_DAVINCI_SOC && MACH_DAVINCI_DA850_EVM |
82 | select SND_DAVINCI_SOC_MCASP | 78 | select SND_DAVINCI_SOC_GENERIC_EVM |
83 | select SND_SOC_TLV320AIC3X | ||
84 | help | 79 | help |
85 | Say Y if you want to add support for SoC audio on TI | 80 | Say Y if you want to add support for SoC audio on TI |
86 | DA850/OMAP-L138 EVM | 81 | DA850/OMAP-L138 EVM |
diff --git a/sound/soc/davinci/Makefile b/sound/soc/davinci/Makefile index bc81e79fc301..744d4d9a0184 100644 --- a/sound/soc/davinci/Makefile +++ b/sound/soc/davinci/Makefile | |||
@@ -9,11 +9,7 @@ obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o | |||
9 | obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o | 9 | obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o |
10 | obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o | 10 | obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o |
11 | 11 | ||
12 | # DAVINCI Machine Support | 12 | # Generic DAVINCI/AM33xx Machine Support |
13 | snd-soc-evm-objs := davinci-evm.o | 13 | snd-soc-evm-objs := davinci-evm.o |
14 | 14 | ||
15 | obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o | 15 | obj-$(CONFIG_SND_DAVINCI_SOC_GENERIC_EVM) += snd-soc-evm.o |
16 | obj-$(CONFIG_SND_AM33XX_SOC_EVM) += snd-soc-evm.o | ||
17 | obj-$(CONFIG_SND_DM6467_SOC_EVM) += snd-soc-evm.o | ||
18 | obj-$(CONFIG_SND_DA830_SOC_EVM) += snd-soc-evm.o | ||
19 | obj-$(CONFIG_SND_DA850_SOC_EVM) += snd-soc-evm.o | ||
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 623eb5e7c089..70ff3772079f 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c | |||
@@ -28,14 +28,11 @@ | |||
28 | 28 | ||
29 | #include "davinci-pcm.h" | 29 | #include "davinci-pcm.h" |
30 | #include "davinci-i2s.h" | 30 | #include "davinci-i2s.h" |
31 | #include "davinci-mcasp.h" | ||
32 | 31 | ||
33 | struct snd_soc_card_drvdata_davinci { | 32 | struct snd_soc_card_drvdata_davinci { |
34 | unsigned sysclk; | 33 | unsigned sysclk; |
35 | }; | 34 | }; |
36 | 35 | ||
37 | #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ | ||
38 | SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF) | ||
39 | static int evm_hw_params(struct snd_pcm_substream *substream, | 36 | static int evm_hw_params(struct snd_pcm_substream *substream, |
40 | struct snd_pcm_hw_params *params) | 37 | struct snd_pcm_hw_params *params) |
41 | { | 38 | { |
@@ -48,16 +45,6 @@ static int evm_hw_params(struct snd_pcm_substream *substream, | |||
48 | unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *) | 45 | unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *) |
49 | snd_soc_card_get_drvdata(soc_card))->sysclk; | 46 | snd_soc_card_get_drvdata(soc_card))->sysclk; |
50 | 47 | ||
51 | /* set codec DAI configuration */ | ||
52 | ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT); | ||
53 | if (ret < 0) | ||
54 | return ret; | ||
55 | |||
56 | /* set cpu DAI configuration */ | ||
57 | ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT); | ||
58 | if (ret < 0) | ||
59 | return ret; | ||
60 | |||
61 | /* set the codec system clock */ | 48 | /* set the codec system clock */ |
62 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT); | 49 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT); |
63 | if (ret < 0) | 50 | if (ret < 0) |
@@ -71,24 +58,10 @@ static int evm_hw_params(struct snd_pcm_substream *substream, | |||
71 | return 0; | 58 | return 0; |
72 | } | 59 | } |
73 | 60 | ||
74 | static int evm_spdif_hw_params(struct snd_pcm_substream *substream, | ||
75 | struct snd_pcm_hw_params *params) | ||
76 | { | ||
77 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
78 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
79 | |||
80 | /* set cpu DAI configuration */ | ||
81 | return snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT); | ||
82 | } | ||
83 | |||
84 | static struct snd_soc_ops evm_ops = { | 61 | static struct snd_soc_ops evm_ops = { |
85 | .hw_params = evm_hw_params, | 62 | .hw_params = evm_hw_params, |
86 | }; | 63 | }; |
87 | 64 | ||
88 | static struct snd_soc_ops evm_spdif_ops = { | ||
89 | .hw_params = evm_spdif_hw_params, | ||
90 | }; | ||
91 | |||
92 | /* davinci-evm machine dapm widgets */ | 65 | /* davinci-evm machine dapm widgets */ |
93 | static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { | 66 | static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { |
94 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | 67 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
@@ -165,6 +138,8 @@ static struct snd_soc_dai_link dm6446_evm_dai = { | |||
165 | .platform_name = "davinci-mcbsp", | 138 | .platform_name = "davinci-mcbsp", |
166 | .init = evm_aic3x_init, | 139 | .init = evm_aic3x_init, |
167 | .ops = &evm_ops, | 140 | .ops = &evm_ops, |
141 | .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | | ||
142 | SND_SOC_DAIFMT_IB_NF, | ||
168 | }; | 143 | }; |
169 | 144 | ||
170 | static struct snd_soc_dai_link dm355_evm_dai = { | 145 | static struct snd_soc_dai_link dm355_evm_dai = { |
@@ -176,6 +151,8 @@ static struct snd_soc_dai_link dm355_evm_dai = { | |||
176 | .platform_name = "davinci-mcbsp.1", | 151 | .platform_name = "davinci-mcbsp.1", |
177 | .init = evm_aic3x_init, | 152 | .init = evm_aic3x_init, |
178 | .ops = &evm_ops, | 153 | .ops = &evm_ops, |
154 | .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | | ||
155 | SND_SOC_DAIFMT_IB_NF, | ||
179 | }; | 156 | }; |
180 | 157 | ||
181 | static struct snd_soc_dai_link dm365_evm_dai = { | 158 | static struct snd_soc_dai_link dm365_evm_dai = { |
@@ -184,10 +161,12 @@ static struct snd_soc_dai_link dm365_evm_dai = { | |||
184 | .stream_name = "AIC3X", | 161 | .stream_name = "AIC3X", |
185 | .cpu_dai_name = "davinci-mcbsp", | 162 | .cpu_dai_name = "davinci-mcbsp", |
186 | .codec_dai_name = "tlv320aic3x-hifi", | 163 | .codec_dai_name = "tlv320aic3x-hifi", |
187 | .init = evm_aic3x_init, | ||
188 | .codec_name = "tlv320aic3x-codec.1-0018", | 164 | .codec_name = "tlv320aic3x-codec.1-0018", |
189 | .ops = &evm_ops, | ||
190 | .platform_name = "davinci-mcbsp", | 165 | .platform_name = "davinci-mcbsp", |
166 | .init = evm_aic3x_init, | ||
167 | .ops = &evm_ops, | ||
168 | .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | | ||
169 | SND_SOC_DAIFMT_IB_NF, | ||
191 | #elif defined(CONFIG_SND_DM365_VOICE_CODEC) | 170 | #elif defined(CONFIG_SND_DM365_VOICE_CODEC) |
192 | .name = "Voice Codec - CQ93VC", | 171 | .name = "Voice Codec - CQ93VC", |
193 | .stream_name = "CQ93", | 172 | .stream_name = "CQ93", |
@@ -208,6 +187,8 @@ static struct snd_soc_dai_link dm6467_evm_dai[] = { | |||
208 | .codec_name = "tlv320aic3x-codec.0-001a", | 187 | .codec_name = "tlv320aic3x-codec.0-001a", |
209 | .init = evm_aic3x_init, | 188 | .init = evm_aic3x_init, |
210 | .ops = &evm_ops, | 189 | .ops = &evm_ops, |
190 | .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | | ||
191 | SND_SOC_DAIFMT_IB_NF, | ||
211 | }, | 192 | }, |
212 | { | 193 | { |
213 | .name = "McASP", | 194 | .name = "McASP", |
@@ -216,7 +197,8 @@ static struct snd_soc_dai_link dm6467_evm_dai[] = { | |||
216 | .codec_dai_name = "dit-hifi", | 197 | .codec_dai_name = "dit-hifi", |
217 | .codec_name = "spdif_dit", | 198 | .codec_name = "spdif_dit", |
218 | .platform_name = "davinci-mcasp.1", | 199 | .platform_name = "davinci-mcasp.1", |
219 | .ops = &evm_spdif_ops, | 200 | .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | |
201 | SND_SOC_DAIFMT_IB_NF, | ||
220 | }, | 202 | }, |
221 | }; | 203 | }; |
222 | 204 | ||
@@ -229,6 +211,8 @@ static struct snd_soc_dai_link da830_evm_dai = { | |||
229 | .platform_name = "davinci-mcasp.1", | 211 | .platform_name = "davinci-mcasp.1", |
230 | .init = evm_aic3x_init, | 212 | .init = evm_aic3x_init, |
231 | .ops = &evm_ops, | 213 | .ops = &evm_ops, |
214 | .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | | ||
215 | SND_SOC_DAIFMT_IB_NF, | ||
232 | }; | 216 | }; |
233 | 217 | ||
234 | static struct snd_soc_dai_link da850_evm_dai = { | 218 | static struct snd_soc_dai_link da850_evm_dai = { |
@@ -240,6 +224,8 @@ static struct snd_soc_dai_link da850_evm_dai = { | |||
240 | .platform_name = "davinci-mcasp.0", | 224 | .platform_name = "davinci-mcasp.0", |
241 | .init = evm_aic3x_init, | 225 | .init = evm_aic3x_init, |
242 | .ops = &evm_ops, | 226 | .ops = &evm_ops, |
227 | .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | | ||
228 | SND_SOC_DAIFMT_IB_NF, | ||
243 | }; | 229 | }; |
244 | 230 | ||
245 | /* davinci dm6446 evm audio machine driver */ | 231 | /* davinci dm6446 evm audio machine driver */ |
@@ -336,6 +322,8 @@ static struct snd_soc_dai_link evm_dai_tlv320aic3x = { | |||
336 | .codec_dai_name = "tlv320aic3x-hifi", | 322 | .codec_dai_name = "tlv320aic3x-hifi", |
337 | .ops = &evm_ops, | 323 | .ops = &evm_ops, |
338 | .init = evm_aic3x_init, | 324 | .init = evm_aic3x_init, |
325 | .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | | ||
326 | SND_SOC_DAIFMT_IB_NF, | ||
339 | }; | 327 | }; |
340 | 328 | ||
341 | static const struct of_device_id davinci_evm_dt_ids[] = { | 329 | static const struct of_device_id davinci_evm_dt_ids[] = { |
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 71e14bb3a8cd..b7858bfa0295 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/clk.h> | ||
24 | #include <linux/pm_runtime.h> | 25 | #include <linux/pm_runtime.h> |
25 | #include <linux/of.h> | 26 | #include <linux/of.h> |
26 | #include <linux/of_platform.h> | 27 | #include <linux/of_platform.h> |
@@ -31,351 +32,147 @@ | |||
31 | #include <sound/pcm_params.h> | 32 | #include <sound/pcm_params.h> |
32 | #include <sound/initval.h> | 33 | #include <sound/initval.h> |
33 | #include <sound/soc.h> | 34 | #include <sound/soc.h> |
35 | #include <sound/dmaengine_pcm.h> | ||
34 | 36 | ||
35 | #include "davinci-pcm.h" | 37 | #include "davinci-pcm.h" |
36 | #include "davinci-mcasp.h" | 38 | #include "davinci-mcasp.h" |
37 | 39 | ||
38 | /* | 40 | struct davinci_mcasp { |
39 | * McASP register definitions | 41 | struct davinci_pcm_dma_params dma_params[2]; |
40 | */ | 42 | struct snd_dmaengine_dai_dma_data dma_data[2]; |
41 | #define DAVINCI_MCASP_PID_REG 0x00 | 43 | void __iomem *base; |
42 | #define DAVINCI_MCASP_PWREMUMGT_REG 0x04 | 44 | u32 fifo_base; |
43 | 45 | struct device *dev; | |
44 | #define DAVINCI_MCASP_PFUNC_REG 0x10 | ||
45 | #define DAVINCI_MCASP_PDIR_REG 0x14 | ||
46 | #define DAVINCI_MCASP_PDOUT_REG 0x18 | ||
47 | #define DAVINCI_MCASP_PDSET_REG 0x1c | ||
48 | |||
49 | #define DAVINCI_MCASP_PDCLR_REG 0x20 | ||
50 | |||
51 | #define DAVINCI_MCASP_TLGC_REG 0x30 | ||
52 | #define DAVINCI_MCASP_TLMR_REG 0x34 | ||
53 | |||
54 | #define DAVINCI_MCASP_GBLCTL_REG 0x44 | ||
55 | #define DAVINCI_MCASP_AMUTE_REG 0x48 | ||
56 | #define DAVINCI_MCASP_LBCTL_REG 0x4c | ||
57 | |||
58 | #define DAVINCI_MCASP_TXDITCTL_REG 0x50 | ||
59 | |||
60 | #define DAVINCI_MCASP_GBLCTLR_REG 0x60 | ||
61 | #define DAVINCI_MCASP_RXMASK_REG 0x64 | ||
62 | #define DAVINCI_MCASP_RXFMT_REG 0x68 | ||
63 | #define DAVINCI_MCASP_RXFMCTL_REG 0x6c | ||
64 | |||
65 | #define DAVINCI_MCASP_ACLKRCTL_REG 0x70 | ||
66 | #define DAVINCI_MCASP_AHCLKRCTL_REG 0x74 | ||
67 | #define DAVINCI_MCASP_RXTDM_REG 0x78 | ||
68 | #define DAVINCI_MCASP_EVTCTLR_REG 0x7c | ||
69 | |||
70 | #define DAVINCI_MCASP_RXSTAT_REG 0x80 | ||
71 | #define DAVINCI_MCASP_RXTDMSLOT_REG 0x84 | ||
72 | #define DAVINCI_MCASP_RXCLKCHK_REG 0x88 | ||
73 | #define DAVINCI_MCASP_REVTCTL_REG 0x8c | ||
74 | |||
75 | #define DAVINCI_MCASP_GBLCTLX_REG 0xa0 | ||
76 | #define DAVINCI_MCASP_TXMASK_REG 0xa4 | ||
77 | #define DAVINCI_MCASP_TXFMT_REG 0xa8 | ||
78 | #define DAVINCI_MCASP_TXFMCTL_REG 0xac | ||
79 | |||
80 | #define DAVINCI_MCASP_ACLKXCTL_REG 0xb0 | ||
81 | #define DAVINCI_MCASP_AHCLKXCTL_REG 0xb4 | ||
82 | #define DAVINCI_MCASP_TXTDM_REG 0xb8 | ||
83 | #define DAVINCI_MCASP_EVTCTLX_REG 0xbc | ||
84 | |||
85 | #define DAVINCI_MCASP_TXSTAT_REG 0xc0 | ||
86 | #define DAVINCI_MCASP_TXTDMSLOT_REG 0xc4 | ||
87 | #define DAVINCI_MCASP_TXCLKCHK_REG 0xc8 | ||
88 | #define DAVINCI_MCASP_XEVTCTL_REG 0xcc | ||
89 | |||
90 | /* Left(even TDM Slot) Channel Status Register File */ | ||
91 | #define DAVINCI_MCASP_DITCSRA_REG 0x100 | ||
92 | /* Right(odd TDM slot) Channel Status Register File */ | ||
93 | #define DAVINCI_MCASP_DITCSRB_REG 0x118 | ||
94 | /* Left(even TDM slot) User Data Register File */ | ||
95 | #define DAVINCI_MCASP_DITUDRA_REG 0x130 | ||
96 | /* Right(odd TDM Slot) User Data Register File */ | ||
97 | #define DAVINCI_MCASP_DITUDRB_REG 0x148 | ||
98 | |||
99 | /* Serializer n Control Register */ | ||
100 | #define DAVINCI_MCASP_XRSRCTL_BASE_REG 0x180 | ||
101 | #define DAVINCI_MCASP_XRSRCTL_REG(n) (DAVINCI_MCASP_XRSRCTL_BASE_REG + \ | ||
102 | (n << 2)) | ||
103 | |||
104 | /* Transmit Buffer for Serializer n */ | ||
105 | #define DAVINCI_MCASP_TXBUF_REG 0x200 | ||
106 | /* Receive Buffer for Serializer n */ | ||
107 | #define DAVINCI_MCASP_RXBUF_REG 0x280 | ||
108 | |||
109 | /* McASP FIFO Registers */ | ||
110 | #define DAVINCI_MCASP_WFIFOCTL (0x1010) | ||
111 | #define DAVINCI_MCASP_WFIFOSTS (0x1014) | ||
112 | #define DAVINCI_MCASP_RFIFOCTL (0x1018) | ||
113 | #define DAVINCI_MCASP_RFIFOSTS (0x101C) | ||
114 | #define MCASP_VER3_WFIFOCTL (0x1000) | ||
115 | #define MCASP_VER3_WFIFOSTS (0x1004) | ||
116 | #define MCASP_VER3_RFIFOCTL (0x1008) | ||
117 | #define MCASP_VER3_RFIFOSTS (0x100C) | ||
118 | |||
119 | /* | ||
120 | * DAVINCI_MCASP_PWREMUMGT_REG - Power Down and Emulation Management | ||
121 | * Register Bits | ||
122 | */ | ||
123 | #define MCASP_FREE BIT(0) | ||
124 | #define MCASP_SOFT BIT(1) | ||
125 | |||
126 | /* | ||
127 | * DAVINCI_MCASP_PFUNC_REG - Pin Function / GPIO Enable Register Bits | ||
128 | */ | ||
129 | #define AXR(n) (1<<n) | ||
130 | #define PFUNC_AMUTE BIT(25) | ||
131 | #define ACLKX BIT(26) | ||
132 | #define AHCLKX BIT(27) | ||
133 | #define AFSX BIT(28) | ||
134 | #define ACLKR BIT(29) | ||
135 | #define AHCLKR BIT(30) | ||
136 | #define AFSR BIT(31) | ||
137 | |||
138 | /* | ||
139 | * DAVINCI_MCASP_PDIR_REG - Pin Direction Register Bits | ||
140 | */ | ||
141 | #define AXR(n) (1<<n) | ||
142 | #define PDIR_AMUTE BIT(25) | ||
143 | #define ACLKX BIT(26) | ||
144 | #define AHCLKX BIT(27) | ||
145 | #define AFSX BIT(28) | ||
146 | #define ACLKR BIT(29) | ||
147 | #define AHCLKR BIT(30) | ||
148 | #define AFSR BIT(31) | ||
149 | |||
150 | /* | ||
151 | * DAVINCI_MCASP_TXDITCTL_REG - Transmit DIT Control Register Bits | ||
152 | */ | ||
153 | #define DITEN BIT(0) /* Transmit DIT mode enable/disable */ | ||
154 | #define VA BIT(2) | ||
155 | #define VB BIT(3) | ||
156 | |||
157 | /* | ||
158 | * DAVINCI_MCASP_TXFMT_REG - Transmit Bitstream Format Register Bits | ||
159 | */ | ||
160 | #define TXROT(val) (val) | ||
161 | #define TXSEL BIT(3) | ||
162 | #define TXSSZ(val) (val<<4) | ||
163 | #define TXPBIT(val) (val<<8) | ||
164 | #define TXPAD(val) (val<<13) | ||
165 | #define TXORD BIT(15) | ||
166 | #define FSXDLY(val) (val<<16) | ||
167 | |||
168 | /* | ||
169 | * DAVINCI_MCASP_RXFMT_REG - Receive Bitstream Format Register Bits | ||
170 | */ | ||
171 | #define RXROT(val) (val) | ||
172 | #define RXSEL BIT(3) | ||
173 | #define RXSSZ(val) (val<<4) | ||
174 | #define RXPBIT(val) (val<<8) | ||
175 | #define RXPAD(val) (val<<13) | ||
176 | #define RXORD BIT(15) | ||
177 | #define FSRDLY(val) (val<<16) | ||
178 | |||
179 | /* | ||
180 | * DAVINCI_MCASP_TXFMCTL_REG - Transmit Frame Control Register Bits | ||
181 | */ | ||
182 | #define FSXPOL BIT(0) | ||
183 | #define AFSXE BIT(1) | ||
184 | #define FSXDUR BIT(4) | ||
185 | #define FSXMOD(val) (val<<7) | ||
186 | |||
187 | /* | ||
188 | * DAVINCI_MCASP_RXFMCTL_REG - Receive Frame Control Register Bits | ||
189 | */ | ||
190 | #define FSRPOL BIT(0) | ||
191 | #define AFSRE BIT(1) | ||
192 | #define FSRDUR BIT(4) | ||
193 | #define FSRMOD(val) (val<<7) | ||
194 | |||
195 | /* | ||
196 | * DAVINCI_MCASP_ACLKXCTL_REG - Transmit Clock Control Register Bits | ||
197 | */ | ||
198 | #define ACLKXDIV(val) (val) | ||
199 | #define ACLKXE BIT(5) | ||
200 | #define TX_ASYNC BIT(6) | ||
201 | #define ACLKXPOL BIT(7) | ||
202 | #define ACLKXDIV_MASK 0x1f | ||
203 | |||
204 | /* | ||
205 | * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits | ||
206 | */ | ||
207 | #define ACLKRDIV(val) (val) | ||
208 | #define ACLKRE BIT(5) | ||
209 | #define RX_ASYNC BIT(6) | ||
210 | #define ACLKRPOL BIT(7) | ||
211 | #define ACLKRDIV_MASK 0x1f | ||
212 | |||
213 | /* | ||
214 | * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control | ||
215 | * Register Bits | ||
216 | */ | ||
217 | #define AHCLKXDIV(val) (val) | ||
218 | #define AHCLKXPOL BIT(14) | ||
219 | #define AHCLKXE BIT(15) | ||
220 | #define AHCLKXDIV_MASK 0xfff | ||
221 | 46 | ||
222 | /* | 47 | /* McASP specific data */ |
223 | * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control | 48 | int tdm_slots; |
224 | * Register Bits | 49 | u8 op_mode; |
225 | */ | 50 | u8 num_serializer; |
226 | #define AHCLKRDIV(val) (val) | 51 | u8 *serial_dir; |
227 | #define AHCLKRPOL BIT(14) | 52 | u8 version; |
228 | #define AHCLKRE BIT(15) | 53 | u16 bclk_lrclk_ratio; |
229 | #define AHCLKRDIV_MASK 0xfff | 54 | int streams; |
230 | 55 | ||
231 | /* | 56 | /* McASP FIFO related */ |
232 | * DAVINCI_MCASP_XRSRCTL_BASE_REG - Serializer Control Register Bits | 57 | u8 txnumevt; |
233 | */ | 58 | u8 rxnumevt; |
234 | #define MODE(val) (val) | ||
235 | #define DISMOD (val)(val<<2) | ||
236 | #define TXSTATE BIT(4) | ||
237 | #define RXSTATE BIT(5) | ||
238 | #define SRMOD_MASK 3 | ||
239 | #define SRMOD_INACTIVE 0 | ||
240 | |||
241 | /* | ||
242 | * DAVINCI_MCASP_LBCTL_REG - Loop Back Control Register Bits | ||
243 | */ | ||
244 | #define LBEN BIT(0) | ||
245 | #define LBORD BIT(1) | ||
246 | #define LBGENMODE(val) (val<<2) | ||
247 | 59 | ||
248 | /* | 60 | bool dat_port; |
249 | * DAVINCI_MCASP_TXTDMSLOT_REG - Transmit TDM Slot Register configuration | ||
250 | */ | ||
251 | #define TXTDMS(n) (1<<n) | ||
252 | |||
253 | /* | ||
254 | * DAVINCI_MCASP_RXTDMSLOT_REG - Receive TDM Slot Register configuration | ||
255 | */ | ||
256 | #define RXTDMS(n) (1<<n) | ||
257 | |||
258 | /* | ||
259 | * DAVINCI_MCASP_GBLCTL_REG - Global Control Register Bits | ||
260 | */ | ||
261 | #define RXCLKRST BIT(0) /* Receiver Clock Divider Reset */ | ||
262 | #define RXHCLKRST BIT(1) /* Receiver High Frequency Clock Divider */ | ||
263 | #define RXSERCLR BIT(2) /* Receiver Serializer Clear */ | ||
264 | #define RXSMRST BIT(3) /* Receiver State Machine Reset */ | ||
265 | #define RXFSRST BIT(4) /* Frame Sync Generator Reset */ | ||
266 | #define TXCLKRST BIT(8) /* Transmitter Clock Divider Reset */ | ||
267 | #define TXHCLKRST BIT(9) /* Transmitter High Frequency Clock Divider*/ | ||
268 | #define TXSERCLR BIT(10) /* Transmit Serializer Clear */ | ||
269 | #define TXSMRST BIT(11) /* Transmitter State Machine Reset */ | ||
270 | #define TXFSRST BIT(12) /* Frame Sync Generator Reset */ | ||
271 | 61 | ||
272 | /* | 62 | #ifdef CONFIG_PM_SLEEP |
273 | * DAVINCI_MCASP_AMUTE_REG - Mute Control Register Bits | 63 | struct { |
274 | */ | 64 | u32 txfmtctl; |
275 | #define MUTENA(val) (val) | 65 | u32 rxfmtctl; |
276 | #define MUTEINPOL BIT(2) | 66 | u32 txfmt; |
277 | #define MUTEINENA BIT(3) | 67 | u32 rxfmt; |
278 | #define MUTEIN BIT(4) | 68 | u32 aclkxctl; |
279 | #define MUTER BIT(5) | 69 | u32 aclkrctl; |
280 | #define MUTEX BIT(6) | 70 | u32 pdir; |
281 | #define MUTEFSR BIT(7) | 71 | } context; |
282 | #define MUTEFSX BIT(8) | 72 | #endif |
283 | #define MUTEBADCLKR BIT(9) | 73 | }; |
284 | #define MUTEBADCLKX BIT(10) | ||
285 | #define MUTERXDMAERR BIT(11) | ||
286 | #define MUTETXDMAERR BIT(12) | ||
287 | |||
288 | /* | ||
289 | * DAVINCI_MCASP_REVTCTL_REG - Receiver DMA Event Control Register bits | ||
290 | */ | ||
291 | #define RXDATADMADIS BIT(0) | ||
292 | |||
293 | /* | ||
294 | * DAVINCI_MCASP_XEVTCTL_REG - Transmitter DMA Event Control Register bits | ||
295 | */ | ||
296 | #define TXDATADMADIS BIT(0) | ||
297 | |||
298 | /* | ||
299 | * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits | ||
300 | */ | ||
301 | #define FIFO_ENABLE BIT(16) | ||
302 | #define NUMEVT_MASK (0xFF << 8) | ||
303 | #define NUMDMA_MASK (0xFF) | ||
304 | |||
305 | #define DAVINCI_MCASP_NUM_SERIALIZER 16 | ||
306 | 74 | ||
307 | static inline void mcasp_set_bits(void __iomem *reg, u32 val) | 75 | static inline void mcasp_set_bits(struct davinci_mcasp *mcasp, u32 offset, |
76 | u32 val) | ||
308 | { | 77 | { |
78 | void __iomem *reg = mcasp->base + offset; | ||
309 | __raw_writel(__raw_readl(reg) | val, reg); | 79 | __raw_writel(__raw_readl(reg) | val, reg); |
310 | } | 80 | } |
311 | 81 | ||
312 | static inline void mcasp_clr_bits(void __iomem *reg, u32 val) | 82 | static inline void mcasp_clr_bits(struct davinci_mcasp *mcasp, u32 offset, |
83 | u32 val) | ||
313 | { | 84 | { |
85 | void __iomem *reg = mcasp->base + offset; | ||
314 | __raw_writel((__raw_readl(reg) & ~(val)), reg); | 86 | __raw_writel((__raw_readl(reg) & ~(val)), reg); |
315 | } | 87 | } |
316 | 88 | ||
317 | static inline void mcasp_mod_bits(void __iomem *reg, u32 val, u32 mask) | 89 | static inline void mcasp_mod_bits(struct davinci_mcasp *mcasp, u32 offset, |
90 | u32 val, u32 mask) | ||
318 | { | 91 | { |
92 | void __iomem *reg = mcasp->base + offset; | ||
319 | __raw_writel((__raw_readl(reg) & ~mask) | val, reg); | 93 | __raw_writel((__raw_readl(reg) & ~mask) | val, reg); |
320 | } | 94 | } |
321 | 95 | ||
322 | static inline void mcasp_set_reg(void __iomem *reg, u32 val) | 96 | static inline void mcasp_set_reg(struct davinci_mcasp *mcasp, u32 offset, |
97 | u32 val) | ||
323 | { | 98 | { |
324 | __raw_writel(val, reg); | 99 | __raw_writel(val, mcasp->base + offset); |
325 | } | 100 | } |
326 | 101 | ||
327 | static inline u32 mcasp_get_reg(void __iomem *reg) | 102 | static inline u32 mcasp_get_reg(struct davinci_mcasp *mcasp, u32 offset) |
328 | { | 103 | { |
329 | return (unsigned int)__raw_readl(reg); | 104 | return (u32)__raw_readl(mcasp->base + offset); |
330 | } | 105 | } |
331 | 106 | ||
332 | static inline void mcasp_set_ctl_reg(void __iomem *regs, u32 val) | 107 | static void mcasp_set_ctl_reg(struct davinci_mcasp *mcasp, u32 ctl_reg, u32 val) |
333 | { | 108 | { |
334 | int i = 0; | 109 | int i = 0; |
335 | 110 | ||
336 | mcasp_set_bits(regs, val); | 111 | mcasp_set_bits(mcasp, ctl_reg, val); |
337 | 112 | ||
338 | /* programming GBLCTL needs to read back from GBLCTL and verfiy */ | 113 | /* programming GBLCTL needs to read back from GBLCTL and verfiy */ |
339 | /* loop count is to avoid the lock-up */ | 114 | /* loop count is to avoid the lock-up */ |
340 | for (i = 0; i < 1000; i++) { | 115 | for (i = 0; i < 1000; i++) { |
341 | if ((mcasp_get_reg(regs) & val) == val) | 116 | if ((mcasp_get_reg(mcasp, ctl_reg) & val) == val) |
342 | break; | 117 | break; |
343 | } | 118 | } |
344 | 119 | ||
345 | if (i == 1000 && ((mcasp_get_reg(regs) & val) != val)) | 120 | if (i == 1000 && ((mcasp_get_reg(mcasp, ctl_reg) & val) != val)) |
346 | printk(KERN_ERR "GBLCTL write error\n"); | 121 | printk(KERN_ERR "GBLCTL write error\n"); |
347 | } | 122 | } |
348 | 123 | ||
349 | static void mcasp_start_rx(struct davinci_audio_dev *dev) | 124 | static bool mcasp_is_synchronous(struct davinci_mcasp *mcasp) |
350 | { | 125 | { |
351 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXHCLKRST); | 126 | u32 rxfmctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG); |
352 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXCLKRST); | 127 | u32 aclkxctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG); |
353 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXSERCLR); | ||
354 | mcasp_set_reg(dev->base + DAVINCI_MCASP_RXBUF_REG, 0); | ||
355 | 128 | ||
356 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXSMRST); | 129 | return !(aclkxctl & TX_ASYNC) && rxfmctl & AFSRE; |
357 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXFSRST); | 130 | } |
358 | mcasp_set_reg(dev->base + DAVINCI_MCASP_RXBUF_REG, 0); | ||
359 | 131 | ||
360 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXSMRST); | 132 | static void mcasp_start_rx(struct davinci_mcasp *mcasp) |
361 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXFSRST); | 133 | { |
134 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXHCLKRST); | ||
135 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXCLKRST); | ||
136 | |||
137 | /* | ||
138 | * When ASYNC == 0 the transmit and receive sections operate | ||
139 | * synchronously from the transmit clock and frame sync. We need to make | ||
140 | * sure that the TX signlas are enabled when starting reception. | ||
141 | */ | ||
142 | if (mcasp_is_synchronous(mcasp)) { | ||
143 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST); | ||
144 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST); | ||
145 | } | ||
146 | |||
147 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXSERCLR); | ||
148 | mcasp_set_reg(mcasp, DAVINCI_MCASP_RXBUF_REG, 0); | ||
149 | |||
150 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXSMRST); | ||
151 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXFSRST); | ||
152 | mcasp_set_reg(mcasp, DAVINCI_MCASP_RXBUF_REG, 0); | ||
153 | |||
154 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXSMRST); | ||
155 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXFSRST); | ||
156 | |||
157 | if (mcasp_is_synchronous(mcasp)) | ||
158 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXFSRST); | ||
362 | } | 159 | } |
363 | 160 | ||
364 | static void mcasp_start_tx(struct davinci_audio_dev *dev) | 161 | static void mcasp_start_tx(struct davinci_mcasp *mcasp) |
365 | { | 162 | { |
366 | u8 offset = 0, i; | 163 | u8 offset = 0, i; |
367 | u32 cnt; | 164 | u32 cnt; |
368 | 165 | ||
369 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST); | 166 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST); |
370 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST); | 167 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST); |
371 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXSERCLR); | 168 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXSERCLR); |
372 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXBUF_REG, 0); | 169 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXBUF_REG, 0); |
373 | 170 | ||
374 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXSMRST); | 171 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXSMRST); |
375 | mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXFSRST); | 172 | mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXFSRST); |
376 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXBUF_REG, 0); | 173 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXBUF_REG, 0); |
377 | for (i = 0; i < dev->num_serializer; i++) { | 174 | for (i = 0; i < mcasp->num_serializer; i++) { |
378 | if (dev->serial_dir[i] == TX_MODE) { | 175 | if (mcasp->serial_dir[i] == TX_MODE) { |
379 | offset = i; | 176 | offset = i; |
380 | break; | 177 | break; |
381 | } | 178 | } |
@@ -383,156 +180,140 @@ static void mcasp_start_tx(struct davinci_audio_dev *dev) | |||
383 | 180 | ||
384 | /* wait for TX ready */ | 181 | /* wait for TX ready */ |
385 | cnt = 0; | 182 | cnt = 0; |
386 | while (!(mcasp_get_reg(dev->base + DAVINCI_MCASP_XRSRCTL_REG(offset)) & | 183 | while (!(mcasp_get_reg(mcasp, DAVINCI_MCASP_XRSRCTL_REG(offset)) & |
387 | TXSTATE) && (cnt < 100000)) | 184 | TXSTATE) && (cnt < 100000)) |
388 | cnt++; | 185 | cnt++; |
389 | 186 | ||
390 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXBUF_REG, 0); | 187 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXBUF_REG, 0); |
391 | } | 188 | } |
392 | 189 | ||
393 | static void davinci_mcasp_start(struct davinci_audio_dev *dev, int stream) | 190 | static void davinci_mcasp_start(struct davinci_mcasp *mcasp, int stream) |
394 | { | 191 | { |
192 | u32 reg; | ||
193 | |||
194 | mcasp->streams++; | ||
195 | |||
395 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 196 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
396 | if (dev->txnumevt) { /* enable FIFO */ | 197 | if (mcasp->txnumevt) { /* enable FIFO */ |
397 | switch (dev->version) { | 198 | reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET; |
398 | case MCASP_VERSION_3: | 199 | mcasp_clr_bits(mcasp, reg, FIFO_ENABLE); |
399 | mcasp_clr_bits(dev->base + MCASP_VER3_WFIFOCTL, | 200 | mcasp_set_bits(mcasp, reg, FIFO_ENABLE); |
400 | FIFO_ENABLE); | ||
401 | mcasp_set_bits(dev->base + MCASP_VER3_WFIFOCTL, | ||
402 | FIFO_ENABLE); | ||
403 | break; | ||
404 | default: | ||
405 | mcasp_clr_bits(dev->base + | ||
406 | DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE); | ||
407 | mcasp_set_bits(dev->base + | ||
408 | DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE); | ||
409 | } | ||
410 | } | 201 | } |
411 | mcasp_start_tx(dev); | 202 | mcasp_start_tx(mcasp); |
412 | } else { | 203 | } else { |
413 | if (dev->rxnumevt) { /* enable FIFO */ | 204 | if (mcasp->rxnumevt) { /* enable FIFO */ |
414 | switch (dev->version) { | 205 | reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET; |
415 | case MCASP_VERSION_3: | 206 | mcasp_clr_bits(mcasp, reg, FIFO_ENABLE); |
416 | mcasp_clr_bits(dev->base + MCASP_VER3_RFIFOCTL, | 207 | mcasp_set_bits(mcasp, reg, FIFO_ENABLE); |
417 | FIFO_ENABLE); | ||
418 | mcasp_set_bits(dev->base + MCASP_VER3_RFIFOCTL, | ||
419 | FIFO_ENABLE); | ||
420 | break; | ||
421 | default: | ||
422 | mcasp_clr_bits(dev->base + | ||
423 | DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE); | ||
424 | mcasp_set_bits(dev->base + | ||
425 | DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE); | ||
426 | } | ||
427 | } | 208 | } |
428 | mcasp_start_rx(dev); | 209 | mcasp_start_rx(mcasp); |
429 | } | 210 | } |
430 | } | 211 | } |
431 | 212 | ||
432 | static void mcasp_stop_rx(struct davinci_audio_dev *dev) | 213 | static void mcasp_stop_rx(struct davinci_mcasp *mcasp) |
433 | { | 214 | { |
434 | mcasp_set_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, 0); | 215 | /* |
435 | mcasp_set_reg(dev->base + DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF); | 216 | * In synchronous mode stop the TX clocks if no other stream is |
217 | * running | ||
218 | */ | ||
219 | if (mcasp_is_synchronous(mcasp) && !mcasp->streams) | ||
220 | mcasp_set_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, 0); | ||
221 | |||
222 | mcasp_set_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, 0); | ||
223 | mcasp_set_reg(mcasp, DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF); | ||
436 | } | 224 | } |
437 | 225 | ||
438 | static void mcasp_stop_tx(struct davinci_audio_dev *dev) | 226 | static void mcasp_stop_tx(struct davinci_mcasp *mcasp) |
439 | { | 227 | { |
440 | mcasp_set_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, 0); | 228 | u32 val = 0; |
441 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF); | 229 | |
230 | /* | ||
231 | * In synchronous mode keep TX clocks running if the capture stream is | ||
232 | * still running. | ||
233 | */ | ||
234 | if (mcasp_is_synchronous(mcasp) && mcasp->streams) | ||
235 | val = TXHCLKRST | TXCLKRST | TXFSRST; | ||
236 | |||
237 | mcasp_set_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, val); | ||
238 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF); | ||
442 | } | 239 | } |
443 | 240 | ||
444 | static void davinci_mcasp_stop(struct davinci_audio_dev *dev, int stream) | 241 | static void davinci_mcasp_stop(struct davinci_mcasp *mcasp, int stream) |
445 | { | 242 | { |
243 | u32 reg; | ||
244 | |||
245 | mcasp->streams--; | ||
246 | |||
446 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 247 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
447 | if (dev->txnumevt) { /* disable FIFO */ | 248 | if (mcasp->txnumevt) { /* disable FIFO */ |
448 | switch (dev->version) { | 249 | reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET; |
449 | case MCASP_VERSION_3: | 250 | mcasp_clr_bits(mcasp, reg, FIFO_ENABLE); |
450 | mcasp_clr_bits(dev->base + MCASP_VER3_WFIFOCTL, | ||
451 | FIFO_ENABLE); | ||
452 | break; | ||
453 | default: | ||
454 | mcasp_clr_bits(dev->base + | ||
455 | DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE); | ||
456 | } | ||
457 | } | 251 | } |
458 | mcasp_stop_tx(dev); | 252 | mcasp_stop_tx(mcasp); |
459 | } else { | 253 | } else { |
460 | if (dev->rxnumevt) { /* disable FIFO */ | 254 | if (mcasp->rxnumevt) { /* disable FIFO */ |
461 | switch (dev->version) { | 255 | reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET; |
462 | case MCASP_VERSION_3: | 256 | mcasp_clr_bits(mcasp, reg, FIFO_ENABLE); |
463 | mcasp_clr_bits(dev->base + MCASP_VER3_RFIFOCTL, | ||
464 | FIFO_ENABLE); | ||
465 | break; | ||
466 | |||
467 | default: | ||
468 | mcasp_clr_bits(dev->base + | ||
469 | DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE); | ||
470 | } | ||
471 | } | 257 | } |
472 | mcasp_stop_rx(dev); | 258 | mcasp_stop_rx(mcasp); |
473 | } | 259 | } |
474 | } | 260 | } |
475 | 261 | ||
476 | static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, | 262 | static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, |
477 | unsigned int fmt) | 263 | unsigned int fmt) |
478 | { | 264 | { |
479 | struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); | 265 | struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); |
480 | void __iomem *base = dev->base; | ||
481 | 266 | ||
482 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | 267 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
483 | case SND_SOC_DAIFMT_DSP_B: | 268 | case SND_SOC_DAIFMT_DSP_B: |
484 | case SND_SOC_DAIFMT_AC97: | 269 | case SND_SOC_DAIFMT_AC97: |
485 | mcasp_clr_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); | 270 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); |
486 | mcasp_clr_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); | 271 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); |
487 | break; | 272 | break; |
488 | default: | 273 | default: |
489 | /* configure a full-word SYNC pulse (LRCLK) */ | 274 | /* configure a full-word SYNC pulse (LRCLK) */ |
490 | mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); | 275 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); |
491 | mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); | 276 | mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); |
492 | 277 | ||
493 | /* make 1st data bit occur one ACLK cycle after the frame sync */ | 278 | /* make 1st data bit occur one ACLK cycle after the frame sync */ |
494 | mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, FSXDLY(1)); | 279 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, FSXDLY(1)); |
495 | mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, FSRDLY(1)); | 280 | mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, FSRDLY(1)); |
496 | break; | 281 | break; |
497 | } | 282 | } |
498 | 283 | ||
499 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 284 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
500 | case SND_SOC_DAIFMT_CBS_CFS: | 285 | case SND_SOC_DAIFMT_CBS_CFS: |
501 | /* codec is clock and frame slave */ | 286 | /* codec is clock and frame slave */ |
502 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); | 287 | mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); |
503 | mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE); | 288 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, AFSXE); |
504 | 289 | ||
505 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); | 290 | mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); |
506 | mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); | 291 | mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, AFSRE); |
507 | 292 | ||
508 | mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, | 293 | mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, ACLKX | ACLKR); |
509 | ACLKX | ACLKR); | 294 | mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AFSX | AFSR); |
510 | mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, | ||
511 | AFSX | AFSR); | ||
512 | break; | 295 | break; |
513 | case SND_SOC_DAIFMT_CBM_CFS: | 296 | case SND_SOC_DAIFMT_CBM_CFS: |
514 | /* codec is clock master and frame slave */ | 297 | /* codec is clock master and frame slave */ |
515 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); | 298 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); |
516 | mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE); | 299 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, AFSXE); |
517 | 300 | ||
518 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); | 301 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); |
519 | mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); | 302 | mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, AFSRE); |
520 | 303 | ||
521 | mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG, | 304 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, ACLKX | ACLKR); |
522 | ACLKX | ACLKR); | 305 | mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AFSX | AFSR); |
523 | mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, | ||
524 | AFSX | AFSR); | ||
525 | break; | 306 | break; |
526 | case SND_SOC_DAIFMT_CBM_CFM: | 307 | case SND_SOC_DAIFMT_CBM_CFM: |
527 | /* codec is clock and frame master */ | 308 | /* codec is clock and frame master */ |
528 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); | 309 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); |
529 | mcasp_clr_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE); | 310 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, AFSXE); |
530 | 311 | ||
531 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); | 312 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); |
532 | mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); | 313 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, AFSRE); |
533 | 314 | ||
534 | mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG, | 315 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, |
535 | ACLKX | AHCLKX | AFSX | ACLKR | AHCLKR | AFSR); | 316 | ACLKX | AHCLKX | AFSX | ACLKR | AHCLKR | AFSR); |
536 | break; | 317 | break; |
537 | 318 | ||
538 | default: | 319 | default: |
@@ -541,35 +322,35 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
541 | 322 | ||
542 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | 323 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { |
543 | case SND_SOC_DAIFMT_IB_NF: | 324 | case SND_SOC_DAIFMT_IB_NF: |
544 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); | 325 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); |
545 | mcasp_clr_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); | 326 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); |
546 | 327 | ||
547 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); | 328 | mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); |
548 | mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); | 329 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); |
549 | break; | 330 | break; |
550 | 331 | ||
551 | case SND_SOC_DAIFMT_NB_IF: | 332 | case SND_SOC_DAIFMT_NB_IF: |
552 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); | 333 | mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); |
553 | mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); | 334 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); |
554 | 335 | ||
555 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); | 336 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); |
556 | mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); | 337 | mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); |
557 | break; | 338 | break; |
558 | 339 | ||
559 | case SND_SOC_DAIFMT_IB_IF: | 340 | case SND_SOC_DAIFMT_IB_IF: |
560 | mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); | 341 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); |
561 | mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); | 342 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); |
562 | 343 | ||
563 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); | 344 | mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); |
564 | mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); | 345 | mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); |
565 | break; | 346 | break; |
566 | 347 | ||
567 | case SND_SOC_DAIFMT_NB_NF: | 348 | case SND_SOC_DAIFMT_NB_NF: |
568 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); | 349 | mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); |
569 | mcasp_clr_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); | 350 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); |
570 | 351 | ||
571 | mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); | 352 | mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); |
572 | mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); | 353 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); |
573 | break; | 354 | break; |
574 | 355 | ||
575 | default: | 356 | default: |
@@ -581,25 +362,25 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
581 | 362 | ||
582 | static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) | 363 | static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) |
583 | { | 364 | { |
584 | struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai); | 365 | struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); |
585 | 366 | ||
586 | switch (div_id) { | 367 | switch (div_id) { |
587 | case 0: /* MCLK divider */ | 368 | case 0: /* MCLK divider */ |
588 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, | 369 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, |
589 | AHCLKXDIV(div - 1), AHCLKXDIV_MASK); | 370 | AHCLKXDIV(div - 1), AHCLKXDIV_MASK); |
590 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, | 371 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, |
591 | AHCLKRDIV(div - 1), AHCLKRDIV_MASK); | 372 | AHCLKRDIV(div - 1), AHCLKRDIV_MASK); |
592 | break; | 373 | break; |
593 | 374 | ||
594 | case 1: /* BCLK divider */ | 375 | case 1: /* BCLK divider */ |
595 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG, | 376 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, |
596 | ACLKXDIV(div - 1), ACLKXDIV_MASK); | 377 | ACLKXDIV(div - 1), ACLKXDIV_MASK); |
597 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_ACLKRCTL_REG, | 378 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, |
598 | ACLKRDIV(div - 1), ACLKRDIV_MASK); | 379 | ACLKRDIV(div - 1), ACLKRDIV_MASK); |
599 | break; | 380 | break; |
600 | 381 | ||
601 | case 2: /* BCLK/LRCLK ratio */ | 382 | case 2: /* BCLK/LRCLK ratio */ |
602 | dev->bclk_lrclk_ratio = div; | 383 | mcasp->bclk_lrclk_ratio = div; |
603 | break; | 384 | break; |
604 | 385 | ||
605 | default: | 386 | default: |
@@ -612,22 +393,22 @@ static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div | |||
612 | static int davinci_mcasp_set_sysclk(struct snd_soc_dai *dai, int clk_id, | 393 | static int davinci_mcasp_set_sysclk(struct snd_soc_dai *dai, int clk_id, |
613 | unsigned int freq, int dir) | 394 | unsigned int freq, int dir) |
614 | { | 395 | { |
615 | struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai); | 396 | struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); |
616 | 397 | ||
617 | if (dir == SND_SOC_CLOCK_OUT) { | 398 | if (dir == SND_SOC_CLOCK_OUT) { |
618 | mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); | 399 | mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); |
619 | mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); | 400 | mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); |
620 | mcasp_set_bits(dev->base + DAVINCI_MCASP_PDIR_REG, AHCLKX); | 401 | mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AHCLKX); |
621 | } else { | 402 | } else { |
622 | mcasp_clr_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); | 403 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); |
623 | mcasp_clr_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); | 404 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); |
624 | mcasp_clr_bits(dev->base + DAVINCI_MCASP_PDIR_REG, AHCLKX); | 405 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AHCLKX); |
625 | } | 406 | } |
626 | 407 | ||
627 | return 0; | 408 | return 0; |
628 | } | 409 | } |
629 | 410 | ||
630 | static int davinci_config_channel_size(struct davinci_audio_dev *dev, | 411 | static int davinci_config_channel_size(struct davinci_mcasp *mcasp, |
631 | int word_length) | 412 | int word_length) |
632 | { | 413 | { |
633 | u32 fmt; | 414 | u32 fmt; |
@@ -644,71 +425,68 @@ static int davinci_config_channel_size(struct davinci_audio_dev *dev, | |||
644 | * both left and right channels), so it has to be divided by number of | 425 | * both left and right channels), so it has to be divided by number of |
645 | * tdm-slots (for I2S - divided by 2). | 426 | * tdm-slots (for I2S - divided by 2). |
646 | */ | 427 | */ |
647 | if (dev->bclk_lrclk_ratio) | 428 | if (mcasp->bclk_lrclk_ratio) |
648 | word_length = dev->bclk_lrclk_ratio / dev->tdm_slots; | 429 | word_length = mcasp->bclk_lrclk_ratio / mcasp->tdm_slots; |
649 | 430 | ||
650 | /* mapping of the XSSZ bit-field as described in the datasheet */ | 431 | /* mapping of the XSSZ bit-field as described in the datasheet */ |
651 | fmt = (word_length >> 1) - 1; | 432 | fmt = (word_length >> 1) - 1; |
652 | 433 | ||
653 | if (dev->op_mode != DAVINCI_MCASP_DIT_MODE) { | 434 | if (mcasp->op_mode != DAVINCI_MCASP_DIT_MODE) { |
654 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, | 435 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, RXSSZ(fmt), |
655 | RXSSZ(fmt), RXSSZ(0x0F)); | 436 | RXSSZ(0x0F)); |
656 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, | 437 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, TXSSZ(fmt), |
657 | TXSSZ(fmt), TXSSZ(0x0F)); | 438 | TXSSZ(0x0F)); |
658 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, | 439 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, TXROT(tx_rotate), |
659 | TXROT(tx_rotate), TXROT(7)); | 440 | TXROT(7)); |
660 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, | 441 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, RXROT(rx_rotate), |
661 | RXROT(rx_rotate), RXROT(7)); | 442 | RXROT(7)); |
662 | mcasp_set_reg(dev->base + DAVINCI_MCASP_RXMASK_REG, | 443 | mcasp_set_reg(mcasp, DAVINCI_MCASP_RXMASK_REG, mask); |
663 | mask); | ||
664 | } | 444 | } |
665 | 445 | ||
666 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXMASK_REG, mask); | 446 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXMASK_REG, mask); |
667 | 447 | ||
668 | return 0; | 448 | return 0; |
669 | } | 449 | } |
670 | 450 | ||
671 | static int davinci_hw_common_param(struct davinci_audio_dev *dev, int stream, | 451 | static int davinci_hw_common_param(struct davinci_mcasp *mcasp, int stream, |
672 | int channels) | 452 | int channels) |
673 | { | 453 | { |
674 | int i; | 454 | int i; |
675 | u8 tx_ser = 0; | 455 | u8 tx_ser = 0; |
676 | u8 rx_ser = 0; | 456 | u8 rx_ser = 0; |
677 | u8 ser; | 457 | u8 ser; |
678 | u8 slots = dev->tdm_slots; | 458 | u8 slots = mcasp->tdm_slots; |
679 | u8 max_active_serializers = (channels + slots - 1) / slots; | 459 | u8 max_active_serializers = (channels + slots - 1) / slots; |
460 | u32 reg; | ||
680 | /* Default configuration */ | 461 | /* Default configuration */ |
681 | mcasp_set_bits(dev->base + DAVINCI_MCASP_PWREMUMGT_REG, MCASP_SOFT); | 462 | if (mcasp->version != MCASP_VERSION_4) |
463 | mcasp_set_bits(mcasp, DAVINCI_MCASP_PWREMUMGT_REG, MCASP_SOFT); | ||
682 | 464 | ||
683 | /* All PINS as McASP */ | 465 | /* All PINS as McASP */ |
684 | mcasp_set_reg(dev->base + DAVINCI_MCASP_PFUNC_REG, 0x00000000); | 466 | mcasp_set_reg(mcasp, DAVINCI_MCASP_PFUNC_REG, 0x00000000); |
685 | 467 | ||
686 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 468 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
687 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF); | 469 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF); |
688 | mcasp_clr_bits(dev->base + DAVINCI_MCASP_XEVTCTL_REG, | 470 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_XEVTCTL_REG, TXDATADMADIS); |
689 | TXDATADMADIS); | ||
690 | } else { | 471 | } else { |
691 | mcasp_set_reg(dev->base + DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF); | 472 | mcasp_set_reg(mcasp, DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF); |
692 | mcasp_clr_bits(dev->base + DAVINCI_MCASP_REVTCTL_REG, | 473 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_REVTCTL_REG, RXDATADMADIS); |
693 | RXDATADMADIS); | ||
694 | } | 474 | } |
695 | 475 | ||
696 | for (i = 0; i < dev->num_serializer; i++) { | 476 | for (i = 0; i < mcasp->num_serializer; i++) { |
697 | mcasp_set_bits(dev->base + DAVINCI_MCASP_XRSRCTL_REG(i), | 477 | mcasp_set_bits(mcasp, DAVINCI_MCASP_XRSRCTL_REG(i), |
698 | dev->serial_dir[i]); | 478 | mcasp->serial_dir[i]); |
699 | if (dev->serial_dir[i] == TX_MODE && | 479 | if (mcasp->serial_dir[i] == TX_MODE && |
700 | tx_ser < max_active_serializers) { | 480 | tx_ser < max_active_serializers) { |
701 | mcasp_set_bits(dev->base + DAVINCI_MCASP_PDIR_REG, | 481 | mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AXR(i)); |
702 | AXR(i)); | ||
703 | tx_ser++; | 482 | tx_ser++; |
704 | } else if (dev->serial_dir[i] == RX_MODE && | 483 | } else if (mcasp->serial_dir[i] == RX_MODE && |
705 | rx_ser < max_active_serializers) { | 484 | rx_ser < max_active_serializers) { |
706 | mcasp_clr_bits(dev->base + DAVINCI_MCASP_PDIR_REG, | 485 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AXR(i)); |
707 | AXR(i)); | ||
708 | rx_ser++; | 486 | rx_ser++; |
709 | } else { | 487 | } else { |
710 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_XRSRCTL_REG(i), | 488 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_XRSRCTL_REG(i), |
711 | SRMOD_INACTIVE, SRMOD_MASK); | 489 | SRMOD_INACTIVE, SRMOD_MASK); |
712 | } | 490 | } |
713 | } | 491 | } |
714 | 492 | ||
@@ -718,127 +496,113 @@ static int davinci_hw_common_param(struct davinci_audio_dev *dev, int stream, | |||
718 | ser = rx_ser; | 496 | ser = rx_ser; |
719 | 497 | ||
720 | if (ser < max_active_serializers) { | 498 | if (ser < max_active_serializers) { |
721 | dev_warn(dev->dev, "stream has more channels (%d) than are " | 499 | dev_warn(mcasp->dev, "stream has more channels (%d) than are " |
722 | "enabled in mcasp (%d)\n", channels, ser * slots); | 500 | "enabled in mcasp (%d)\n", channels, ser * slots); |
723 | return -EINVAL; | 501 | return -EINVAL; |
724 | } | 502 | } |
725 | 503 | ||
726 | if (dev->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) { | 504 | if (mcasp->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) { |
727 | if (dev->txnumevt * tx_ser > 64) | 505 | if (mcasp->txnumevt * tx_ser > 64) |
728 | dev->txnumevt = 1; | 506 | mcasp->txnumevt = 1; |
729 | 507 | ||
730 | switch (dev->version) { | 508 | reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET; |
731 | case MCASP_VERSION_3: | 509 | mcasp_mod_bits(mcasp, reg, tx_ser, NUMDMA_MASK); |
732 | mcasp_mod_bits(dev->base + MCASP_VER3_WFIFOCTL, tx_ser, | 510 | mcasp_mod_bits(mcasp, reg, ((mcasp->txnumevt * tx_ser) << 8), |
733 | NUMDMA_MASK); | 511 | NUMEVT_MASK); |
734 | mcasp_mod_bits(dev->base + MCASP_VER3_WFIFOCTL, | ||
735 | ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK); | ||
736 | break; | ||
737 | default: | ||
738 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, | ||
739 | tx_ser, NUMDMA_MASK); | ||
740 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, | ||
741 | ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK); | ||
742 | } | ||
743 | } | 512 | } |
744 | 513 | ||
745 | if (dev->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) { | 514 | if (mcasp->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) { |
746 | if (dev->rxnumevt * rx_ser > 64) | 515 | if (mcasp->rxnumevt * rx_ser > 64) |
747 | dev->rxnumevt = 1; | 516 | mcasp->rxnumevt = 1; |
748 | switch (dev->version) { | 517 | |
749 | case MCASP_VERSION_3: | 518 | reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET; |
750 | mcasp_mod_bits(dev->base + MCASP_VER3_RFIFOCTL, rx_ser, | 519 | mcasp_mod_bits(mcasp, reg, rx_ser, NUMDMA_MASK); |
751 | NUMDMA_MASK); | 520 | mcasp_mod_bits(mcasp, reg, ((mcasp->rxnumevt * rx_ser) << 8), |
752 | mcasp_mod_bits(dev->base + MCASP_VER3_RFIFOCTL, | 521 | NUMEVT_MASK); |
753 | ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK); | ||
754 | break; | ||
755 | default: | ||
756 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, | ||
757 | rx_ser, NUMDMA_MASK); | ||
758 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, | ||
759 | ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK); | ||
760 | } | ||
761 | } | 522 | } |
762 | 523 | ||
763 | return 0; | 524 | return 0; |
764 | } | 525 | } |
765 | 526 | ||
766 | static void davinci_hw_param(struct davinci_audio_dev *dev, int stream) | 527 | static void davinci_hw_param(struct davinci_mcasp *mcasp, int stream) |
767 | { | 528 | { |
768 | int i, active_slots; | 529 | int i, active_slots; |
769 | u32 mask = 0; | 530 | u32 mask = 0; |
531 | u32 busel = 0; | ||
770 | 532 | ||
771 | active_slots = (dev->tdm_slots > 31) ? 32 : dev->tdm_slots; | 533 | active_slots = (mcasp->tdm_slots > 31) ? 32 : mcasp->tdm_slots; |
772 | for (i = 0; i < active_slots; i++) | 534 | for (i = 0; i < active_slots; i++) |
773 | mask |= (1 << i); | 535 | mask |= (1 << i); |
774 | 536 | ||
775 | mcasp_clr_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC); | 537 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC); |
538 | |||
539 | if (!mcasp->dat_port) | ||
540 | busel = TXSEL; | ||
776 | 541 | ||
777 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 542 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
778 | /* bit stream is MSB first with no delay */ | 543 | /* bit stream is MSB first with no delay */ |
779 | /* DSP_B mode */ | 544 | /* DSP_B mode */ |
780 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask); | 545 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, mask); |
781 | mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXORD); | 546 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, busel | TXORD); |
782 | 547 | ||
783 | if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32)) | 548 | if ((mcasp->tdm_slots >= 2) && (mcasp->tdm_slots <= 32)) |
784 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, | 549 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, |
785 | FSXMOD(dev->tdm_slots), FSXMOD(0x1FF)); | 550 | FSXMOD(mcasp->tdm_slots), FSXMOD(0x1FF)); |
786 | else | 551 | else |
787 | printk(KERN_ERR "playback tdm slot %d not supported\n", | 552 | printk(KERN_ERR "playback tdm slot %d not supported\n", |
788 | dev->tdm_slots); | 553 | mcasp->tdm_slots); |
789 | } else { | 554 | } else { |
790 | /* bit stream is MSB first with no delay */ | 555 | /* bit stream is MSB first with no delay */ |
791 | /* DSP_B mode */ | 556 | /* DSP_B mode */ |
792 | mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, RXORD); | 557 | mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, busel | RXORD); |
793 | mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask); | 558 | mcasp_set_reg(mcasp, DAVINCI_MCASP_RXTDM_REG, mask); |
794 | 559 | ||
795 | if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32)) | 560 | if ((mcasp->tdm_slots >= 2) && (mcasp->tdm_slots <= 32)) |
796 | mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, | 561 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, |
797 | FSRMOD(dev->tdm_slots), FSRMOD(0x1FF)); | 562 | FSRMOD(mcasp->tdm_slots), FSRMOD(0x1FF)); |
798 | else | 563 | else |
799 | printk(KERN_ERR "capture tdm slot %d not supported\n", | 564 | printk(KERN_ERR "capture tdm slot %d not supported\n", |
800 | dev->tdm_slots); | 565 | mcasp->tdm_slots); |
801 | } | 566 | } |
802 | } | 567 | } |
803 | 568 | ||
804 | /* S/PDIF */ | 569 | /* S/PDIF */ |
805 | static void davinci_hw_dit_param(struct davinci_audio_dev *dev) | 570 | static void davinci_hw_dit_param(struct davinci_mcasp *mcasp) |
806 | { | 571 | { |
807 | /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 | 572 | /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 |
808 | and LSB first */ | 573 | and LSB first */ |
809 | mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, | 574 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, TXROT(6) | TXSSZ(15)); |
810 | TXROT(6) | TXSSZ(15)); | ||
811 | 575 | ||
812 | /* Set TX frame synch : DIT Mode, 1 bit width, internal, rising edge */ | 576 | /* Set TX frame synch : DIT Mode, 1 bit width, internal, rising edge */ |
813 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXFMCTL_REG, | 577 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG, AFSXE | FSXMOD(0x180)); |
814 | AFSXE | FSXMOD(0x180)); | ||
815 | 578 | ||
816 | /* Set the TX tdm : for all the slots */ | 579 | /* Set the TX tdm : for all the slots */ |
817 | mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, 0xFFFFFFFF); | 580 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, 0xFFFFFFFF); |
818 | 581 | ||
819 | /* Set the TX clock controls : div = 1 and internal */ | 582 | /* Set the TX clock controls : div = 1 and internal */ |
820 | mcasp_set_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG, | 583 | mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE | TX_ASYNC); |
821 | ACLKXE | TX_ASYNC); | ||
822 | 584 | ||
823 | mcasp_clr_bits(dev->base + DAVINCI_MCASP_XEVTCTL_REG, TXDATADMADIS); | 585 | mcasp_clr_bits(mcasp, DAVINCI_MCASP_XEVTCTL_REG, TXDATADMADIS); |
824 | 586 | ||
825 | /* Only 44100 and 48000 are valid, both have the same setting */ | 587 | /* Only 44100 and 48000 are valid, both have the same setting */ |
826 | mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXDIV(3)); | 588 | mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXDIV(3)); |
827 | 589 | ||
828 | /* Enable the DIT */ | 590 | /* Enable the DIT */ |
829 | mcasp_set_bits(dev->base + DAVINCI_MCASP_TXDITCTL_REG, DITEN); | 591 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN); |
830 | } | 592 | } |
831 | 593 | ||
832 | static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, | 594 | static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, |
833 | struct snd_pcm_hw_params *params, | 595 | struct snd_pcm_hw_params *params, |
834 | struct snd_soc_dai *cpu_dai) | 596 | struct snd_soc_dai *cpu_dai) |
835 | { | 597 | { |
836 | struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); | 598 | struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); |
837 | struct davinci_pcm_dma_params *dma_params = | 599 | struct davinci_pcm_dma_params *dma_params = |
838 | &dev->dma_params[substream->stream]; | 600 | &mcasp->dma_params[substream->stream]; |
601 | struct snd_dmaengine_dai_dma_data *dma_data = | ||
602 | &mcasp->dma_data[substream->stream]; | ||
839 | int word_length; | 603 | int word_length; |
840 | u8 fifo_level; | 604 | u8 fifo_level; |
841 | u8 slots = dev->tdm_slots; | 605 | u8 slots = mcasp->tdm_slots; |
842 | u8 active_serializers; | 606 | u8 active_serializers; |
843 | int channels; | 607 | int channels; |
844 | struct snd_interval *pcm_channels = hw_param_interval(params, | 608 | struct snd_interval *pcm_channels = hw_param_interval(params, |
@@ -847,17 +611,17 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, | |||
847 | 611 | ||
848 | active_serializers = (channels + slots - 1) / slots; | 612 | active_serializers = (channels + slots - 1) / slots; |
849 | 613 | ||
850 | if (davinci_hw_common_param(dev, substream->stream, channels) == -EINVAL) | 614 | if (davinci_hw_common_param(mcasp, substream->stream, channels) == -EINVAL) |
851 | return -EINVAL; | 615 | return -EINVAL; |
852 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 616 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
853 | fifo_level = dev->txnumevt * active_serializers; | 617 | fifo_level = mcasp->txnumevt * active_serializers; |
854 | else | 618 | else |
855 | fifo_level = dev->rxnumevt * active_serializers; | 619 | fifo_level = mcasp->rxnumevt * active_serializers; |
856 | 620 | ||
857 | if (dev->op_mode == DAVINCI_MCASP_DIT_MODE) | 621 | if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE) |
858 | davinci_hw_dit_param(dev); | 622 | davinci_hw_dit_param(mcasp); |
859 | else | 623 | else |
860 | davinci_hw_param(dev, substream->stream); | 624 | davinci_hw_param(mcasp, substream->stream); |
861 | 625 | ||
862 | switch (params_format(params)) { | 626 | switch (params_format(params)) { |
863 | case SNDRV_PCM_FORMAT_U8: | 627 | case SNDRV_PCM_FORMAT_U8: |
@@ -891,13 +655,15 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, | |||
891 | return -EINVAL; | 655 | return -EINVAL; |
892 | } | 656 | } |
893 | 657 | ||
894 | if (dev->version == MCASP_VERSION_2 && !fifo_level) | 658 | if (mcasp->version == MCASP_VERSION_2 && !fifo_level) |
895 | dma_params->acnt = 4; | 659 | dma_params->acnt = 4; |
896 | else | 660 | else |
897 | dma_params->acnt = dma_params->data_type; | 661 | dma_params->acnt = dma_params->data_type; |
898 | 662 | ||
899 | dma_params->fifo_level = fifo_level; | 663 | dma_params->fifo_level = fifo_level; |
900 | davinci_config_channel_size(dev, word_length); | 664 | dma_data->maxburst = fifo_level; |
665 | |||
666 | davinci_config_channel_size(mcasp, word_length); | ||
901 | 667 | ||
902 | return 0; | 668 | return 0; |
903 | } | 669 | } |
@@ -905,29 +671,29 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, | |||
905 | static int davinci_mcasp_trigger(struct snd_pcm_substream *substream, | 671 | static int davinci_mcasp_trigger(struct snd_pcm_substream *substream, |
906 | int cmd, struct snd_soc_dai *cpu_dai) | 672 | int cmd, struct snd_soc_dai *cpu_dai) |
907 | { | 673 | { |
908 | struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); | 674 | struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); |
909 | int ret = 0; | 675 | int ret = 0; |
910 | 676 | ||
911 | switch (cmd) { | 677 | switch (cmd) { |
912 | case SNDRV_PCM_TRIGGER_RESUME: | 678 | case SNDRV_PCM_TRIGGER_RESUME: |
913 | case SNDRV_PCM_TRIGGER_START: | 679 | case SNDRV_PCM_TRIGGER_START: |
914 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 680 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
915 | ret = pm_runtime_get_sync(dev->dev); | 681 | ret = pm_runtime_get_sync(mcasp->dev); |
916 | if (IS_ERR_VALUE(ret)) | 682 | if (IS_ERR_VALUE(ret)) |
917 | dev_err(dev->dev, "pm_runtime_get_sync() failed\n"); | 683 | dev_err(mcasp->dev, "pm_runtime_get_sync() failed\n"); |
918 | davinci_mcasp_start(dev, substream->stream); | 684 | davinci_mcasp_start(mcasp, substream->stream); |
919 | break; | 685 | break; |
920 | 686 | ||
921 | case SNDRV_PCM_TRIGGER_SUSPEND: | 687 | case SNDRV_PCM_TRIGGER_SUSPEND: |
922 | davinci_mcasp_stop(dev, substream->stream); | 688 | davinci_mcasp_stop(mcasp, substream->stream); |
923 | ret = pm_runtime_put_sync(dev->dev); | 689 | ret = pm_runtime_put_sync(mcasp->dev); |
924 | if (IS_ERR_VALUE(ret)) | 690 | if (IS_ERR_VALUE(ret)) |
925 | dev_err(dev->dev, "pm_runtime_put_sync() failed\n"); | 691 | dev_err(mcasp->dev, "pm_runtime_put_sync() failed\n"); |
926 | break; | 692 | break; |
927 | 693 | ||
928 | case SNDRV_PCM_TRIGGER_STOP: | 694 | case SNDRV_PCM_TRIGGER_STOP: |
929 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 695 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
930 | davinci_mcasp_stop(dev, substream->stream); | 696 | davinci_mcasp_stop(mcasp, substream->stream); |
931 | break; | 697 | break; |
932 | 698 | ||
933 | default: | 699 | default: |
@@ -940,9 +706,14 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream, | |||
940 | static int davinci_mcasp_startup(struct snd_pcm_substream *substream, | 706 | static int davinci_mcasp_startup(struct snd_pcm_substream *substream, |
941 | struct snd_soc_dai *dai) | 707 | struct snd_soc_dai *dai) |
942 | { | 708 | { |
943 | struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai); | 709 | struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); |
710 | |||
711 | if (mcasp->version == MCASP_VERSION_4) | ||
712 | snd_soc_dai_set_dma_data(dai, substream, | ||
713 | &mcasp->dma_data[substream->stream]); | ||
714 | else | ||
715 | snd_soc_dai_set_dma_data(dai, substream, mcasp->dma_params); | ||
944 | 716 | ||
945 | snd_soc_dai_set_dma_data(dai, substream, dev->dma_params); | ||
946 | return 0; | 717 | return 0; |
947 | } | 718 | } |
948 | 719 | ||
@@ -955,6 +726,8 @@ static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = { | |||
955 | .set_sysclk = davinci_mcasp_set_sysclk, | 726 | .set_sysclk = davinci_mcasp_set_sysclk, |
956 | }; | 727 | }; |
957 | 728 | ||
729 | #define DAVINCI_MCASP_RATES SNDRV_PCM_RATE_8000_192000 | ||
730 | |||
958 | #define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \ | 731 | #define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \ |
959 | SNDRV_PCM_FMTBIT_U8 | \ | 732 | SNDRV_PCM_FMTBIT_U8 | \ |
960 | SNDRV_PCM_FMTBIT_S16_LE | \ | 733 | SNDRV_PCM_FMTBIT_S16_LE | \ |
@@ -985,7 +758,7 @@ static struct snd_soc_dai_driver davinci_mcasp_dai[] = { | |||
985 | 758 | ||
986 | }, | 759 | }, |
987 | { | 760 | { |
988 | "davinci-mcasp.1", | 761 | .name = "davinci-mcasp.1", |
989 | .playback = { | 762 | .playback = { |
990 | .channels_min = 1, | 763 | .channels_min = 1, |
991 | .channels_max = 384, | 764 | .channels_max = 384, |
@@ -1016,13 +789,20 @@ static struct snd_platform_data da830_mcasp_pdata = { | |||
1016 | .version = MCASP_VERSION_2, | 789 | .version = MCASP_VERSION_2, |
1017 | }; | 790 | }; |
1018 | 791 | ||
1019 | static struct snd_platform_data omap2_mcasp_pdata = { | 792 | static struct snd_platform_data am33xx_mcasp_pdata = { |
1020 | .tx_dma_offset = 0, | 793 | .tx_dma_offset = 0, |
1021 | .rx_dma_offset = 0, | 794 | .rx_dma_offset = 0, |
1022 | .asp_chan_q = EVENTQ_0, | 795 | .asp_chan_q = EVENTQ_0, |
1023 | .version = MCASP_VERSION_3, | 796 | .version = MCASP_VERSION_3, |
1024 | }; | 797 | }; |
1025 | 798 | ||
799 | static struct snd_platform_data dra7_mcasp_pdata = { | ||
800 | .tx_dma_offset = 0x200, | ||
801 | .rx_dma_offset = 0x284, | ||
802 | .asp_chan_q = EVENTQ_0, | ||
803 | .version = MCASP_VERSION_4, | ||
804 | }; | ||
805 | |||
1026 | static const struct of_device_id mcasp_dt_ids[] = { | 806 | static const struct of_device_id mcasp_dt_ids[] = { |
1027 | { | 807 | { |
1028 | .compatible = "ti,dm646x-mcasp-audio", | 808 | .compatible = "ti,dm646x-mcasp-audio", |
@@ -1034,12 +814,56 @@ static const struct of_device_id mcasp_dt_ids[] = { | |||
1034 | }, | 814 | }, |
1035 | { | 815 | { |
1036 | .compatible = "ti,am33xx-mcasp-audio", | 816 | .compatible = "ti,am33xx-mcasp-audio", |
1037 | .data = &omap2_mcasp_pdata, | 817 | .data = &am33xx_mcasp_pdata, |
818 | }, | ||
819 | { | ||
820 | .compatible = "ti,dra7-mcasp-audio", | ||
821 | .data = &dra7_mcasp_pdata, | ||
1038 | }, | 822 | }, |
1039 | { /* sentinel */ } | 823 | { /* sentinel */ } |
1040 | }; | 824 | }; |
1041 | MODULE_DEVICE_TABLE(of, mcasp_dt_ids); | 825 | MODULE_DEVICE_TABLE(of, mcasp_dt_ids); |
1042 | 826 | ||
827 | static int mcasp_reparent_fck(struct platform_device *pdev) | ||
828 | { | ||
829 | struct device_node *node = pdev->dev.of_node; | ||
830 | struct clk *gfclk, *parent_clk; | ||
831 | const char *parent_name; | ||
832 | int ret; | ||
833 | |||
834 | if (!node) | ||
835 | return 0; | ||
836 | |||
837 | parent_name = of_get_property(node, "fck_parent", NULL); | ||
838 | if (!parent_name) | ||
839 | return 0; | ||
840 | |||
841 | gfclk = clk_get(&pdev->dev, "fck"); | ||
842 | if (IS_ERR(gfclk)) { | ||
843 | dev_err(&pdev->dev, "failed to get fck\n"); | ||
844 | return PTR_ERR(gfclk); | ||
845 | } | ||
846 | |||
847 | parent_clk = clk_get(NULL, parent_name); | ||
848 | if (IS_ERR(parent_clk)) { | ||
849 | dev_err(&pdev->dev, "failed to get parent clock\n"); | ||
850 | ret = PTR_ERR(parent_clk); | ||
851 | goto err1; | ||
852 | } | ||
853 | |||
854 | ret = clk_set_parent(gfclk, parent_clk); | ||
855 | if (ret) { | ||
856 | dev_err(&pdev->dev, "failed to reparent fck\n"); | ||
857 | goto err2; | ||
858 | } | ||
859 | |||
860 | err2: | ||
861 | clk_put(parent_clk); | ||
862 | err1: | ||
863 | clk_put(gfclk); | ||
864 | return ret; | ||
865 | } | ||
866 | |||
1043 | static struct snd_platform_data *davinci_mcasp_set_pdata_from_of( | 867 | static struct snd_platform_data *davinci_mcasp_set_pdata_from_of( |
1044 | struct platform_device *pdev) | 868 | struct platform_device *pdev) |
1045 | { | 869 | { |
@@ -1152,7 +976,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
1152 | struct davinci_pcm_dma_params *dma_data; | 976 | struct davinci_pcm_dma_params *dma_data; |
1153 | struct resource *mem, *ioarea, *res, *dat; | 977 | struct resource *mem, *ioarea, *res, *dat; |
1154 | struct snd_platform_data *pdata; | 978 | struct snd_platform_data *pdata; |
1155 | struct davinci_audio_dev *dev; | 979 | struct davinci_mcasp *mcasp; |
1156 | int ret; | 980 | int ret; |
1157 | 981 | ||
1158 | if (!pdev->dev.platform_data && !pdev->dev.of_node) { | 982 | if (!pdev->dev.platform_data && !pdev->dev.of_node) { |
@@ -1160,9 +984,9 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
1160 | return -EINVAL; | 984 | return -EINVAL; |
1161 | } | 985 | } |
1162 | 986 | ||
1163 | dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_audio_dev), | 987 | mcasp = devm_kzalloc(&pdev->dev, sizeof(struct davinci_mcasp), |
1164 | GFP_KERNEL); | 988 | GFP_KERNEL); |
1165 | if (!dev) | 989 | if (!mcasp) |
1166 | return -ENOMEM; | 990 | return -ENOMEM; |
1167 | 991 | ||
1168 | pdata = davinci_mcasp_set_pdata_from_of(pdev); | 992 | pdata = davinci_mcasp_set_pdata_from_of(pdev); |
@@ -1173,7 +997,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
1173 | 997 | ||
1174 | mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); | 998 | mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); |
1175 | if (!mem) { | 999 | if (!mem) { |
1176 | dev_warn(dev->dev, | 1000 | dev_warn(mcasp->dev, |
1177 | "\"mpu\" mem resource not found, using index 0\n"); | 1001 | "\"mpu\" mem resource not found, using index 0\n"); |
1178 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1002 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1179 | if (!mem) { | 1003 | if (!mem) { |
@@ -1197,32 +1021,39 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
1197 | return ret; | 1021 | return ret; |
1198 | } | 1022 | } |
1199 | 1023 | ||
1200 | dev->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); | 1024 | mcasp->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); |
1201 | if (!dev->base) { | 1025 | if (!mcasp->base) { |
1202 | dev_err(&pdev->dev, "ioremap failed\n"); | 1026 | dev_err(&pdev->dev, "ioremap failed\n"); |
1203 | ret = -ENOMEM; | 1027 | ret = -ENOMEM; |
1204 | goto err_release_clk; | 1028 | goto err_release_clk; |
1205 | } | 1029 | } |
1206 | 1030 | ||
1207 | dev->op_mode = pdata->op_mode; | 1031 | mcasp->op_mode = pdata->op_mode; |
1208 | dev->tdm_slots = pdata->tdm_slots; | 1032 | mcasp->tdm_slots = pdata->tdm_slots; |
1209 | dev->num_serializer = pdata->num_serializer; | 1033 | mcasp->num_serializer = pdata->num_serializer; |
1210 | dev->serial_dir = pdata->serial_dir; | 1034 | mcasp->serial_dir = pdata->serial_dir; |
1211 | dev->version = pdata->version; | 1035 | mcasp->version = pdata->version; |
1212 | dev->txnumevt = pdata->txnumevt; | 1036 | mcasp->txnumevt = pdata->txnumevt; |
1213 | dev->rxnumevt = pdata->rxnumevt; | 1037 | mcasp->rxnumevt = pdata->rxnumevt; |
1214 | dev->dev = &pdev->dev; | 1038 | |
1039 | mcasp->dev = &pdev->dev; | ||
1215 | 1040 | ||
1216 | dat = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat"); | 1041 | dat = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat"); |
1217 | if (!dat) | 1042 | if (dat) |
1218 | dat = mem; | 1043 | mcasp->dat_port = true; |
1219 | 1044 | ||
1220 | dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; | 1045 | dma_data = &mcasp->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; |
1221 | dma_data->asp_chan_q = pdata->asp_chan_q; | 1046 | dma_data->asp_chan_q = pdata->asp_chan_q; |
1222 | dma_data->ram_chan_q = pdata->ram_chan_q; | 1047 | dma_data->ram_chan_q = pdata->ram_chan_q; |
1223 | dma_data->sram_pool = pdata->sram_pool; | 1048 | dma_data->sram_pool = pdata->sram_pool; |
1224 | dma_data->sram_size = pdata->sram_size_playback; | 1049 | dma_data->sram_size = pdata->sram_size_playback; |
1225 | dma_data->dma_addr = dat->start + pdata->tx_dma_offset; | 1050 | if (dat) |
1051 | dma_data->dma_addr = dat->start; | ||
1052 | else | ||
1053 | dma_data->dma_addr = mem->start + pdata->tx_dma_offset; | ||
1054 | |||
1055 | /* Unconditional dmaengine stuff */ | ||
1056 | mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr = dma_data->dma_addr; | ||
1226 | 1057 | ||
1227 | res = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 1058 | res = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
1228 | if (res) | 1059 | if (res) |
@@ -1230,12 +1061,26 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
1230 | else | 1061 | else |
1231 | dma_data->channel = pdata->tx_dma_channel; | 1062 | dma_data->channel = pdata->tx_dma_channel; |
1232 | 1063 | ||
1233 | dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]; | 1064 | dma_data = &mcasp->dma_params[SNDRV_PCM_STREAM_CAPTURE]; |
1234 | dma_data->asp_chan_q = pdata->asp_chan_q; | 1065 | dma_data->asp_chan_q = pdata->asp_chan_q; |
1235 | dma_data->ram_chan_q = pdata->ram_chan_q; | 1066 | dma_data->ram_chan_q = pdata->ram_chan_q; |
1236 | dma_data->sram_pool = pdata->sram_pool; | 1067 | dma_data->sram_pool = pdata->sram_pool; |
1237 | dma_data->sram_size = pdata->sram_size_capture; | 1068 | dma_data->sram_size = pdata->sram_size_capture; |
1238 | dma_data->dma_addr = dat->start + pdata->rx_dma_offset; | 1069 | if (dat) |
1070 | dma_data->dma_addr = dat->start; | ||
1071 | else | ||
1072 | dma_data->dma_addr = mem->start + pdata->rx_dma_offset; | ||
1073 | |||
1074 | /* Unconditional dmaengine stuff */ | ||
1075 | mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr = dma_data->dma_addr; | ||
1076 | |||
1077 | if (mcasp->version < MCASP_VERSION_3) { | ||
1078 | mcasp->fifo_base = DAVINCI_MCASP_V2_AFIFO_BASE; | ||
1079 | /* dma_data->dma_addr is pointing to the data port address */ | ||
1080 | mcasp->dat_port = true; | ||
1081 | } else { | ||
1082 | mcasp->fifo_base = DAVINCI_MCASP_V3_AFIFO_BASE; | ||
1083 | } | ||
1239 | 1084 | ||
1240 | res = platform_get_resource(pdev, IORESOURCE_DMA, 1); | 1085 | res = platform_get_resource(pdev, IORESOURCE_DMA, 1); |
1241 | if (res) | 1086 | if (res) |
@@ -1243,17 +1088,26 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
1243 | else | 1088 | else |
1244 | dma_data->channel = pdata->rx_dma_channel; | 1089 | dma_data->channel = pdata->rx_dma_channel; |
1245 | 1090 | ||
1246 | dev_set_drvdata(&pdev->dev, dev); | 1091 | /* Unconditional dmaengine stuff */ |
1092 | mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK].filter_data = "tx"; | ||
1093 | mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE].filter_data = "rx"; | ||
1094 | |||
1095 | dev_set_drvdata(&pdev->dev, mcasp); | ||
1096 | |||
1097 | mcasp_reparent_fck(pdev); | ||
1098 | |||
1247 | ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component, | 1099 | ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component, |
1248 | &davinci_mcasp_dai[pdata->op_mode], 1); | 1100 | &davinci_mcasp_dai[pdata->op_mode], 1); |
1249 | 1101 | ||
1250 | if (ret != 0) | 1102 | if (ret != 0) |
1251 | goto err_release_clk; | 1103 | goto err_release_clk; |
1252 | 1104 | ||
1253 | ret = davinci_soc_platform_register(&pdev->dev); | 1105 | if (mcasp->version != MCASP_VERSION_4) { |
1254 | if (ret) { | 1106 | ret = davinci_soc_platform_register(&pdev->dev); |
1255 | dev_err(&pdev->dev, "register PCM failed: %d\n", ret); | 1107 | if (ret) { |
1256 | goto err_unregister_component; | 1108 | dev_err(&pdev->dev, "register PCM failed: %d\n", ret); |
1109 | goto err_unregister_component; | ||
1110 | } | ||
1257 | } | 1111 | } |
1258 | 1112 | ||
1259 | return 0; | 1113 | return 0; |
@@ -1268,9 +1122,11 @@ err_release_clk: | |||
1268 | 1122 | ||
1269 | static int davinci_mcasp_remove(struct platform_device *pdev) | 1123 | static int davinci_mcasp_remove(struct platform_device *pdev) |
1270 | { | 1124 | { |
1125 | struct davinci_mcasp *mcasp = dev_get_drvdata(&pdev->dev); | ||
1271 | 1126 | ||
1272 | snd_soc_unregister_component(&pdev->dev); | 1127 | snd_soc_unregister_component(&pdev->dev); |
1273 | davinci_soc_platform_unregister(&pdev->dev); | 1128 | if (mcasp->version != MCASP_VERSION_4) |
1129 | davinci_soc_platform_unregister(&pdev->dev); | ||
1274 | 1130 | ||
1275 | pm_runtime_put_sync(&pdev->dev); | 1131 | pm_runtime_put_sync(&pdev->dev); |
1276 | pm_runtime_disable(&pdev->dev); | 1132 | pm_runtime_disable(&pdev->dev); |
@@ -1281,32 +1137,30 @@ static int davinci_mcasp_remove(struct platform_device *pdev) | |||
1281 | #ifdef CONFIG_PM_SLEEP | 1137 | #ifdef CONFIG_PM_SLEEP |
1282 | static int davinci_mcasp_suspend(struct device *dev) | 1138 | static int davinci_mcasp_suspend(struct device *dev) |
1283 | { | 1139 | { |
1284 | struct davinci_audio_dev *a = dev_get_drvdata(dev); | 1140 | struct davinci_mcasp *mcasp = dev_get_drvdata(dev); |
1285 | void __iomem *base = a->base; | ||
1286 | 1141 | ||
1287 | a->context.txfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_TXFMCTL_REG); | 1142 | mcasp->context.txfmtctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG); |
1288 | a->context.rxfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_RXFMCTL_REG); | 1143 | mcasp->context.rxfmtctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG); |
1289 | a->context.txfmt = mcasp_get_reg(base + DAVINCI_MCASP_TXFMT_REG); | 1144 | mcasp->context.txfmt = mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMT_REG); |
1290 | a->context.rxfmt = mcasp_get_reg(base + DAVINCI_MCASP_RXFMT_REG); | 1145 | mcasp->context.rxfmt = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMT_REG); |
1291 | a->context.aclkxctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKXCTL_REG); | 1146 | mcasp->context.aclkxctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG); |
1292 | a->context.aclkrctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKRCTL_REG); | 1147 | mcasp->context.aclkrctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKRCTL_REG); |
1293 | a->context.pdir = mcasp_get_reg(base + DAVINCI_MCASP_PDIR_REG); | 1148 | mcasp->context.pdir = mcasp_get_reg(mcasp, DAVINCI_MCASP_PDIR_REG); |
1294 | 1149 | ||
1295 | return 0; | 1150 | return 0; |
1296 | } | 1151 | } |
1297 | 1152 | ||
1298 | static int davinci_mcasp_resume(struct device *dev) | 1153 | static int davinci_mcasp_resume(struct device *dev) |
1299 | { | 1154 | { |
1300 | struct davinci_audio_dev *a = dev_get_drvdata(dev); | 1155 | struct davinci_mcasp *mcasp = dev_get_drvdata(dev); |
1301 | void __iomem *base = a->base; | 1156 | |
1302 | 1157 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG, mcasp->context.txfmtctl); | |
1303 | mcasp_set_reg(base + DAVINCI_MCASP_TXFMCTL_REG, a->context.txfmtctl); | 1158 | mcasp_set_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG, mcasp->context.rxfmtctl); |
1304 | mcasp_set_reg(base + DAVINCI_MCASP_RXFMCTL_REG, a->context.rxfmtctl); | 1159 | mcasp_set_reg(mcasp, DAVINCI_MCASP_TXFMT_REG, mcasp->context.txfmt); |
1305 | mcasp_set_reg(base + DAVINCI_MCASP_TXFMT_REG, a->context.txfmt); | 1160 | mcasp_set_reg(mcasp, DAVINCI_MCASP_RXFMT_REG, mcasp->context.rxfmt); |
1306 | mcasp_set_reg(base + DAVINCI_MCASP_RXFMT_REG, a->context.rxfmt); | 1161 | mcasp_set_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, mcasp->context.aclkxctl); |
1307 | mcasp_set_reg(base + DAVINCI_MCASP_ACLKXCTL_REG, a->context.aclkxctl); | 1162 | mcasp_set_reg(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, mcasp->context.aclkrctl); |
1308 | mcasp_set_reg(base + DAVINCI_MCASP_ACLKRCTL_REG, a->context.aclkrctl); | 1163 | mcasp_set_reg(mcasp, DAVINCI_MCASP_PDIR_REG, mcasp->context.pdir); |
1309 | mcasp_set_reg(base + DAVINCI_MCASP_PDIR_REG, a->context.pdir); | ||
1310 | 1164 | ||
1311 | return 0; | 1165 | return 0; |
1312 | } | 1166 | } |
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h index a2e27e1c32f3..8fed757d6087 100644 --- a/sound/soc/davinci/davinci-mcasp.h +++ b/sound/soc/davinci/davinci-mcasp.h | |||
@@ -18,43 +18,271 @@ | |||
18 | #ifndef DAVINCI_MCASP_H | 18 | #ifndef DAVINCI_MCASP_H |
19 | #define DAVINCI_MCASP_H | 19 | #define DAVINCI_MCASP_H |
20 | 20 | ||
21 | #include <linux/io.h> | 21 | /* |
22 | #include <linux/platform_data/davinci_asp.h> | 22 | * McASP register definitions |
23 | 23 | */ | |
24 | #include "davinci-pcm.h" | 24 | #define DAVINCI_MCASP_PID_REG 0x00 |
25 | 25 | #define DAVINCI_MCASP_PWREMUMGT_REG 0x04 | |
26 | #define DAVINCI_MCASP_RATES SNDRV_PCM_RATE_8000_192000 | 26 | |
27 | #define DAVINCI_MCASP_I2S_DAI 0 | 27 | #define DAVINCI_MCASP_PFUNC_REG 0x10 |
28 | #define DAVINCI_MCASP_DIT_DAI 1 | 28 | #define DAVINCI_MCASP_PDIR_REG 0x14 |
29 | 29 | #define DAVINCI_MCASP_PDOUT_REG 0x18 | |
30 | struct davinci_audio_dev { | 30 | #define DAVINCI_MCASP_PDSET_REG 0x1c |
31 | struct davinci_pcm_dma_params dma_params[2]; | 31 | |
32 | void __iomem *base; | 32 | #define DAVINCI_MCASP_PDCLR_REG 0x20 |
33 | struct device *dev; | 33 | |
34 | 34 | #define DAVINCI_MCASP_TLGC_REG 0x30 | |
35 | /* McASP specific data */ | 35 | #define DAVINCI_MCASP_TLMR_REG 0x34 |
36 | int tdm_slots; | 36 | |
37 | u8 op_mode; | 37 | #define DAVINCI_MCASP_GBLCTL_REG 0x44 |
38 | u8 num_serializer; | 38 | #define DAVINCI_MCASP_AMUTE_REG 0x48 |
39 | u8 *serial_dir; | 39 | #define DAVINCI_MCASP_LBCTL_REG 0x4c |
40 | u8 version; | 40 | |
41 | u16 bclk_lrclk_ratio; | 41 | #define DAVINCI_MCASP_TXDITCTL_REG 0x50 |
42 | 42 | ||
43 | /* McASP FIFO related */ | 43 | #define DAVINCI_MCASP_GBLCTLR_REG 0x60 |
44 | u8 txnumevt; | 44 | #define DAVINCI_MCASP_RXMASK_REG 0x64 |
45 | u8 rxnumevt; | 45 | #define DAVINCI_MCASP_RXFMT_REG 0x68 |
46 | 46 | #define DAVINCI_MCASP_RXFMCTL_REG 0x6c | |
47 | #ifdef CONFIG_PM_SLEEP | 47 | |
48 | struct { | 48 | #define DAVINCI_MCASP_ACLKRCTL_REG 0x70 |
49 | u32 txfmtctl; | 49 | #define DAVINCI_MCASP_AHCLKRCTL_REG 0x74 |
50 | u32 rxfmtctl; | 50 | #define DAVINCI_MCASP_RXTDM_REG 0x78 |
51 | u32 txfmt; | 51 | #define DAVINCI_MCASP_EVTCTLR_REG 0x7c |
52 | u32 rxfmt; | 52 | |
53 | u32 aclkxctl; | 53 | #define DAVINCI_MCASP_RXSTAT_REG 0x80 |
54 | u32 aclkrctl; | 54 | #define DAVINCI_MCASP_RXTDMSLOT_REG 0x84 |
55 | u32 pdir; | 55 | #define DAVINCI_MCASP_RXCLKCHK_REG 0x88 |
56 | } context; | 56 | #define DAVINCI_MCASP_REVTCTL_REG 0x8c |
57 | #endif | 57 | |
58 | }; | 58 | #define DAVINCI_MCASP_GBLCTLX_REG 0xa0 |
59 | #define DAVINCI_MCASP_TXMASK_REG 0xa4 | ||
60 | #define DAVINCI_MCASP_TXFMT_REG 0xa8 | ||
61 | #define DAVINCI_MCASP_TXFMCTL_REG 0xac | ||
62 | |||
63 | #define DAVINCI_MCASP_ACLKXCTL_REG 0xb0 | ||
64 | #define DAVINCI_MCASP_AHCLKXCTL_REG 0xb4 | ||
65 | #define DAVINCI_MCASP_TXTDM_REG 0xb8 | ||
66 | #define DAVINCI_MCASP_EVTCTLX_REG 0xbc | ||
67 | |||
68 | #define DAVINCI_MCASP_TXSTAT_REG 0xc0 | ||
69 | #define DAVINCI_MCASP_TXTDMSLOT_REG 0xc4 | ||
70 | #define DAVINCI_MCASP_TXCLKCHK_REG 0xc8 | ||
71 | #define DAVINCI_MCASP_XEVTCTL_REG 0xcc | ||
72 | |||
73 | /* Left(even TDM Slot) Channel Status Register File */ | ||
74 | #define DAVINCI_MCASP_DITCSRA_REG 0x100 | ||
75 | /* Right(odd TDM slot) Channel Status Register File */ | ||
76 | #define DAVINCI_MCASP_DITCSRB_REG 0x118 | ||
77 | /* Left(even TDM slot) User Data Register File */ | ||
78 | #define DAVINCI_MCASP_DITUDRA_REG 0x130 | ||
79 | /* Right(odd TDM Slot) User Data Register File */ | ||
80 | #define DAVINCI_MCASP_DITUDRB_REG 0x148 | ||
81 | |||
82 | /* Serializer n Control Register */ | ||
83 | #define DAVINCI_MCASP_XRSRCTL_BASE_REG 0x180 | ||
84 | #define DAVINCI_MCASP_XRSRCTL_REG(n) (DAVINCI_MCASP_XRSRCTL_BASE_REG + \ | ||
85 | (n << 2)) | ||
86 | |||
87 | /* Transmit Buffer for Serializer n */ | ||
88 | #define DAVINCI_MCASP_TXBUF_REG 0x200 | ||
89 | /* Receive Buffer for Serializer n */ | ||
90 | #define DAVINCI_MCASP_RXBUF_REG 0x280 | ||
91 | |||
92 | /* McASP FIFO Registers */ | ||
93 | #define DAVINCI_MCASP_V2_AFIFO_BASE (0x1010) | ||
94 | #define DAVINCI_MCASP_V3_AFIFO_BASE (0x1000) | ||
95 | |||
96 | /* FIFO register offsets from AFIFO base */ | ||
97 | #define MCASP_WFIFOCTL_OFFSET (0x0) | ||
98 | #define MCASP_WFIFOSTS_OFFSET (0x4) | ||
99 | #define MCASP_RFIFOCTL_OFFSET (0x8) | ||
100 | #define MCASP_RFIFOSTS_OFFSET (0xc) | ||
101 | |||
102 | /* | ||
103 | * DAVINCI_MCASP_PWREMUMGT_REG - Power Down and Emulation Management | ||
104 | * Register Bits | ||
105 | */ | ||
106 | #define MCASP_FREE BIT(0) | ||
107 | #define MCASP_SOFT BIT(1) | ||
108 | |||
109 | /* | ||
110 | * DAVINCI_MCASP_PFUNC_REG - Pin Function / GPIO Enable Register Bits | ||
111 | */ | ||
112 | #define AXR(n) (1<<n) | ||
113 | #define PFUNC_AMUTE BIT(25) | ||
114 | #define ACLKX BIT(26) | ||
115 | #define AHCLKX BIT(27) | ||
116 | #define AFSX BIT(28) | ||
117 | #define ACLKR BIT(29) | ||
118 | #define AHCLKR BIT(30) | ||
119 | #define AFSR BIT(31) | ||
120 | |||
121 | /* | ||
122 | * DAVINCI_MCASP_PDIR_REG - Pin Direction Register Bits | ||
123 | */ | ||
124 | #define AXR(n) (1<<n) | ||
125 | #define PDIR_AMUTE BIT(25) | ||
126 | #define ACLKX BIT(26) | ||
127 | #define AHCLKX BIT(27) | ||
128 | #define AFSX BIT(28) | ||
129 | #define ACLKR BIT(29) | ||
130 | #define AHCLKR BIT(30) | ||
131 | #define AFSR BIT(31) | ||
132 | |||
133 | /* | ||
134 | * DAVINCI_MCASP_TXDITCTL_REG - Transmit DIT Control Register Bits | ||
135 | */ | ||
136 | #define DITEN BIT(0) /* Transmit DIT mode enable/disable */ | ||
137 | #define VA BIT(2) | ||
138 | #define VB BIT(3) | ||
139 | |||
140 | /* | ||
141 | * DAVINCI_MCASP_TXFMT_REG - Transmit Bitstream Format Register Bits | ||
142 | */ | ||
143 | #define TXROT(val) (val) | ||
144 | #define TXSEL BIT(3) | ||
145 | #define TXSSZ(val) (val<<4) | ||
146 | #define TXPBIT(val) (val<<8) | ||
147 | #define TXPAD(val) (val<<13) | ||
148 | #define TXORD BIT(15) | ||
149 | #define FSXDLY(val) (val<<16) | ||
150 | |||
151 | /* | ||
152 | * DAVINCI_MCASP_RXFMT_REG - Receive Bitstream Format Register Bits | ||
153 | */ | ||
154 | #define RXROT(val) (val) | ||
155 | #define RXSEL BIT(3) | ||
156 | #define RXSSZ(val) (val<<4) | ||
157 | #define RXPBIT(val) (val<<8) | ||
158 | #define RXPAD(val) (val<<13) | ||
159 | #define RXORD BIT(15) | ||
160 | #define FSRDLY(val) (val<<16) | ||
161 | |||
162 | /* | ||
163 | * DAVINCI_MCASP_TXFMCTL_REG - Transmit Frame Control Register Bits | ||
164 | */ | ||
165 | #define FSXPOL BIT(0) | ||
166 | #define AFSXE BIT(1) | ||
167 | #define FSXDUR BIT(4) | ||
168 | #define FSXMOD(val) (val<<7) | ||
169 | |||
170 | /* | ||
171 | * DAVINCI_MCASP_RXFMCTL_REG - Receive Frame Control Register Bits | ||
172 | */ | ||
173 | #define FSRPOL BIT(0) | ||
174 | #define AFSRE BIT(1) | ||
175 | #define FSRDUR BIT(4) | ||
176 | #define FSRMOD(val) (val<<7) | ||
177 | |||
178 | /* | ||
179 | * DAVINCI_MCASP_ACLKXCTL_REG - Transmit Clock Control Register Bits | ||
180 | */ | ||
181 | #define ACLKXDIV(val) (val) | ||
182 | #define ACLKXE BIT(5) | ||
183 | #define TX_ASYNC BIT(6) | ||
184 | #define ACLKXPOL BIT(7) | ||
185 | #define ACLKXDIV_MASK 0x1f | ||
186 | |||
187 | /* | ||
188 | * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits | ||
189 | */ | ||
190 | #define ACLKRDIV(val) (val) | ||
191 | #define ACLKRE BIT(5) | ||
192 | #define RX_ASYNC BIT(6) | ||
193 | #define ACLKRPOL BIT(7) | ||
194 | #define ACLKRDIV_MASK 0x1f | ||
195 | |||
196 | /* | ||
197 | * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control | ||
198 | * Register Bits | ||
199 | */ | ||
200 | #define AHCLKXDIV(val) (val) | ||
201 | #define AHCLKXPOL BIT(14) | ||
202 | #define AHCLKXE BIT(15) | ||
203 | #define AHCLKXDIV_MASK 0xfff | ||
204 | |||
205 | /* | ||
206 | * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control | ||
207 | * Register Bits | ||
208 | */ | ||
209 | #define AHCLKRDIV(val) (val) | ||
210 | #define AHCLKRPOL BIT(14) | ||
211 | #define AHCLKRE BIT(15) | ||
212 | #define AHCLKRDIV_MASK 0xfff | ||
213 | |||
214 | /* | ||
215 | * DAVINCI_MCASP_XRSRCTL_BASE_REG - Serializer Control Register Bits | ||
216 | */ | ||
217 | #define MODE(val) (val) | ||
218 | #define DISMOD (val)(val<<2) | ||
219 | #define TXSTATE BIT(4) | ||
220 | #define RXSTATE BIT(5) | ||
221 | #define SRMOD_MASK 3 | ||
222 | #define SRMOD_INACTIVE 0 | ||
223 | |||
224 | /* | ||
225 | * DAVINCI_MCASP_LBCTL_REG - Loop Back Control Register Bits | ||
226 | */ | ||
227 | #define LBEN BIT(0) | ||
228 | #define LBORD BIT(1) | ||
229 | #define LBGENMODE(val) (val<<2) | ||
230 | |||
231 | /* | ||
232 | * DAVINCI_MCASP_TXTDMSLOT_REG - Transmit TDM Slot Register configuration | ||
233 | */ | ||
234 | #define TXTDMS(n) (1<<n) | ||
235 | |||
236 | /* | ||
237 | * DAVINCI_MCASP_RXTDMSLOT_REG - Receive TDM Slot Register configuration | ||
238 | */ | ||
239 | #define RXTDMS(n) (1<<n) | ||
240 | |||
241 | /* | ||
242 | * DAVINCI_MCASP_GBLCTL_REG - Global Control Register Bits | ||
243 | */ | ||
244 | #define RXCLKRST BIT(0) /* Receiver Clock Divider Reset */ | ||
245 | #define RXHCLKRST BIT(1) /* Receiver High Frequency Clock Divider */ | ||
246 | #define RXSERCLR BIT(2) /* Receiver Serializer Clear */ | ||
247 | #define RXSMRST BIT(3) /* Receiver State Machine Reset */ | ||
248 | #define RXFSRST BIT(4) /* Frame Sync Generator Reset */ | ||
249 | #define TXCLKRST BIT(8) /* Transmitter Clock Divider Reset */ | ||
250 | #define TXHCLKRST BIT(9) /* Transmitter High Frequency Clock Divider*/ | ||
251 | #define TXSERCLR BIT(10) /* Transmit Serializer Clear */ | ||
252 | #define TXSMRST BIT(11) /* Transmitter State Machine Reset */ | ||
253 | #define TXFSRST BIT(12) /* Frame Sync Generator Reset */ | ||
254 | |||
255 | /* | ||
256 | * DAVINCI_MCASP_AMUTE_REG - Mute Control Register Bits | ||
257 | */ | ||
258 | #define MUTENA(val) (val) | ||
259 | #define MUTEINPOL BIT(2) | ||
260 | #define MUTEINENA BIT(3) | ||
261 | #define MUTEIN BIT(4) | ||
262 | #define MUTER BIT(5) | ||
263 | #define MUTEX BIT(6) | ||
264 | #define MUTEFSR BIT(7) | ||
265 | #define MUTEFSX BIT(8) | ||
266 | #define MUTEBADCLKR BIT(9) | ||
267 | #define MUTEBADCLKX BIT(10) | ||
268 | #define MUTERXDMAERR BIT(11) | ||
269 | #define MUTETXDMAERR BIT(12) | ||
270 | |||
271 | /* | ||
272 | * DAVINCI_MCASP_REVTCTL_REG - Receiver DMA Event Control Register bits | ||
273 | */ | ||
274 | #define RXDATADMADIS BIT(0) | ||
275 | |||
276 | /* | ||
277 | * DAVINCI_MCASP_XEVTCTL_REG - Transmitter DMA Event Control Register bits | ||
278 | */ | ||
279 | #define TXDATADMADIS BIT(0) | ||
280 | |||
281 | /* | ||
282 | * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits | ||
283 | */ | ||
284 | #define FIFO_ENABLE BIT(16) | ||
285 | #define NUMEVT_MASK (0xFF << 8) | ||
286 | #define NUMDMA_MASK (0xFF) | ||
59 | 287 | ||
60 | #endif /* DAVINCI_MCASP_H */ | 288 | #endif /* DAVINCI_MCASP_H */ |
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index fb5d107f5603..14145cdf8a11 100644 --- a/sound/soc/davinci/davinci-pcm.c +++ b/sound/soc/davinci/davinci-pcm.c | |||
@@ -46,33 +46,11 @@ static void print_buf_info(int slot, char *name) | |||
46 | } | 46 | } |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #define DAVINCI_PCM_FMTBITS (\ | ||
50 | SNDRV_PCM_FMTBIT_S8 |\ | ||
51 | SNDRV_PCM_FMTBIT_U8 |\ | ||
52 | SNDRV_PCM_FMTBIT_S16_LE |\ | ||
53 | SNDRV_PCM_FMTBIT_S16_BE |\ | ||
54 | SNDRV_PCM_FMTBIT_U16_LE |\ | ||
55 | SNDRV_PCM_FMTBIT_U16_BE |\ | ||
56 | SNDRV_PCM_FMTBIT_S24_LE |\ | ||
57 | SNDRV_PCM_FMTBIT_S24_BE |\ | ||
58 | SNDRV_PCM_FMTBIT_U24_LE |\ | ||
59 | SNDRV_PCM_FMTBIT_U24_BE |\ | ||
60 | SNDRV_PCM_FMTBIT_S32_LE |\ | ||
61 | SNDRV_PCM_FMTBIT_S32_BE |\ | ||
62 | SNDRV_PCM_FMTBIT_U32_LE |\ | ||
63 | SNDRV_PCM_FMTBIT_U32_BE) | ||
64 | |||
65 | static struct snd_pcm_hardware pcm_hardware_playback = { | 49 | static struct snd_pcm_hardware pcm_hardware_playback = { |
66 | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 50 | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
67 | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | | 51 | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | |
68 | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME| | 52 | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME| |
69 | SNDRV_PCM_INFO_BATCH), | 53 | SNDRV_PCM_INFO_BATCH), |
70 | .formats = DAVINCI_PCM_FMTBITS, | ||
71 | .rates = SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT, | ||
72 | .rate_min = 8000, | ||
73 | .rate_max = 192000, | ||
74 | .channels_min = 2, | ||
75 | .channels_max = 384, | ||
76 | .buffer_bytes_max = 128 * 1024, | 54 | .buffer_bytes_max = 128 * 1024, |
77 | .period_bytes_min = 32, | 55 | .period_bytes_min = 32, |
78 | .period_bytes_max = 8 * 1024, | 56 | .period_bytes_max = 8 * 1024, |
@@ -86,12 +64,6 @@ static struct snd_pcm_hardware pcm_hardware_capture = { | |||
86 | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | | 64 | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | |
87 | SNDRV_PCM_INFO_PAUSE | | 65 | SNDRV_PCM_INFO_PAUSE | |
88 | SNDRV_PCM_INFO_BATCH), | 66 | SNDRV_PCM_INFO_BATCH), |
89 | .formats = DAVINCI_PCM_FMTBITS, | ||
90 | .rates = SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT, | ||
91 | .rate_min = 8000, | ||
92 | .rate_max = 192000, | ||
93 | .channels_min = 2, | ||
94 | .channels_max = 384, | ||
95 | .buffer_bytes_max = 128 * 1024, | 67 | .buffer_bytes_max = 128 * 1024, |
96 | .period_bytes_min = 32, | 68 | .period_bytes_min = 32, |
97 | .period_bytes_max = 8 * 1024, | 69 | .period_bytes_max = 8 * 1024, |
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index b7ab71f2ccc1..514c275c6108 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig | |||
@@ -1,3 +1,7 @@ | |||
1 | config SND_SOC_FSL_SAI | ||
2 | tristate | ||
3 | select SND_SOC_GENERIC_DMAENGINE_PCM | ||
4 | |||
1 | config SND_SOC_FSL_SSI | 5 | config SND_SOC_FSL_SSI |
2 | tristate | 6 | tristate |
3 | 7 | ||
@@ -197,7 +201,6 @@ config SND_SOC_IMX_SPDIF | |||
197 | tristate "SoC Audio support for i.MX boards with S/PDIF" | 201 | tristate "SoC Audio support for i.MX boards with S/PDIF" |
198 | select SND_SOC_IMX_PCM_DMA | 202 | select SND_SOC_IMX_PCM_DMA |
199 | select SND_SOC_FSL_SPDIF | 203 | select SND_SOC_FSL_SPDIF |
200 | select SND_SOC_SPDIF | ||
201 | select REGMAP_MMIO | 204 | select REGMAP_MMIO |
202 | help | 205 | help |
203 | SoC Audio support for i.MX boards with S/PDIF | 206 | SoC Audio support for i.MX boards with S/PDIF |
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 8db705b0fdf9..aaccbee17006 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile | |||
@@ -10,11 +10,13 @@ obj-$(CONFIG_SND_SOC_P1022_DS) += snd-soc-p1022-ds.o | |||
10 | snd-soc-p1022-rdk-objs := p1022_rdk.o | 10 | snd-soc-p1022-rdk-objs := p1022_rdk.o |
11 | obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o | 11 | obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o |
12 | 12 | ||
13 | # Freescale PowerPC SSI/DMA Platform Support | 13 | # Freescale SSI/DMA/SAI/SPDIF Support |
14 | snd-soc-fsl-sai-objs := fsl_sai.o | ||
14 | snd-soc-fsl-ssi-objs := fsl_ssi.o | 15 | snd-soc-fsl-ssi-objs := fsl_ssi.o |
15 | snd-soc-fsl-spdif-objs := fsl_spdif.o | 16 | snd-soc-fsl-spdif-objs := fsl_spdif.o |
16 | snd-soc-fsl-utils-objs := fsl_utils.o | 17 | snd-soc-fsl-utils-objs := fsl_utils.o |
17 | snd-soc-fsl-dma-objs := fsl_dma.o | 18 | snd-soc-fsl-dma-objs := fsl_dma.o |
19 | obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o | ||
18 | obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o | 20 | obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o |
19 | obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o | 21 | obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o |
20 | obj-$(CONFIG_SND_SOC_FSL_UTILS) += snd-soc-fsl-utils.o | 22 | obj-$(CONFIG_SND_SOC_FSL_UTILS) += snd-soc-fsl-utils.o |
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index fb9bb9eb5ca3..d570f8c81dc6 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c | |||
@@ -852,7 +852,7 @@ static void fsl_dma_free_dma_buffers(struct snd_pcm *pcm) | |||
852 | } | 852 | } |
853 | 853 | ||
854 | /** | 854 | /** |
855 | * find_ssi_node -- returns the SSI node that points to his DMA channel node | 855 | * find_ssi_node -- returns the SSI node that points to its DMA channel node |
856 | * | 856 | * |
857 | * Although this DMA driver attempts to operate independently of the other | 857 | * Although this DMA driver attempts to operate independently of the other |
858 | * devices, it still needs to determine some information about the SSI device | 858 | * devices, it still needs to determine some information about the SSI device |
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c new file mode 100644 index 000000000000..5d38a6749b9f --- /dev/null +++ b/sound/soc/fsl/fsl_sai.c | |||
@@ -0,0 +1,460 @@ | |||
1 | /* | ||
2 | * Freescale ALSA SoC Digital Audio Interface (SAI) driver. | ||
3 | * | ||
4 | * Copyright 2012-2013 Freescale Semiconductor, Inc. | ||
5 | * | ||
6 | * This program is free software, you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation, either version 2 of the License, or(at your | ||
9 | * option) any later version. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/clk.h> | ||
14 | #include <linux/delay.h> | ||
15 | #include <linux/dmaengine.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/of_address.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <sound/core.h> | ||
20 | #include <sound/dmaengine_pcm.h> | ||
21 | #include <sound/pcm_params.h> | ||
22 | |||
23 | #include "fsl_sai.h" | ||
24 | |||
25 | static inline u32 sai_readl(struct fsl_sai *sai, | ||
26 | const void __iomem *addr) | ||
27 | { | ||
28 | u32 val; | ||
29 | |||
30 | val = __raw_readl(addr); | ||
31 | |||
32 | if (likely(sai->big_endian_regs)) | ||
33 | val = be32_to_cpu(val); | ||
34 | else | ||
35 | val = le32_to_cpu(val); | ||
36 | rmb(); | ||
37 | |||
38 | return val; | ||
39 | } | ||
40 | |||
41 | static inline void sai_writel(struct fsl_sai *sai, | ||
42 | u32 val, void __iomem *addr) | ||
43 | { | ||
44 | wmb(); | ||
45 | if (likely(sai->big_endian_regs)) | ||
46 | val = cpu_to_be32(val); | ||
47 | else | ||
48 | val = cpu_to_le32(val); | ||
49 | |||
50 | __raw_writel(val, addr); | ||
51 | } | ||
52 | |||
53 | static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai, | ||
54 | int clk_id, unsigned int freq, int fsl_dir) | ||
55 | { | ||
56 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); | ||
57 | u32 val_cr2, reg_cr2; | ||
58 | |||
59 | if (fsl_dir == FSL_FMT_TRANSMITTER) | ||
60 | reg_cr2 = FSL_SAI_TCR2; | ||
61 | else | ||
62 | reg_cr2 = FSL_SAI_RCR2; | ||
63 | |||
64 | val_cr2 = sai_readl(sai, sai->base + reg_cr2); | ||
65 | switch (clk_id) { | ||
66 | case FSL_SAI_CLK_BUS: | ||
67 | val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK; | ||
68 | val_cr2 |= FSL_SAI_CR2_MSEL_BUS; | ||
69 | break; | ||
70 | case FSL_SAI_CLK_MAST1: | ||
71 | val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK; | ||
72 | val_cr2 |= FSL_SAI_CR2_MSEL_MCLK1; | ||
73 | break; | ||
74 | case FSL_SAI_CLK_MAST2: | ||
75 | val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK; | ||
76 | val_cr2 |= FSL_SAI_CR2_MSEL_MCLK2; | ||
77 | break; | ||
78 | case FSL_SAI_CLK_MAST3: | ||
79 | val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK; | ||
80 | val_cr2 |= FSL_SAI_CR2_MSEL_MCLK3; | ||
81 | break; | ||
82 | default: | ||
83 | return -EINVAL; | ||
84 | } | ||
85 | sai_writel(sai, val_cr2, sai->base + reg_cr2); | ||
86 | |||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | static int fsl_sai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | ||
91 | int clk_id, unsigned int freq, int dir) | ||
92 | { | ||
93 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); | ||
94 | int ret; | ||
95 | |||
96 | if (dir == SND_SOC_CLOCK_IN) | ||
97 | return 0; | ||
98 | |||
99 | ret = clk_prepare_enable(sai->clk); | ||
100 | if (ret) | ||
101 | return ret; | ||
102 | |||
103 | ret = fsl_sai_set_dai_sysclk_tr(cpu_dai, clk_id, freq, | ||
104 | FSL_FMT_TRANSMITTER); | ||
105 | if (ret) { | ||
106 | dev_err(cpu_dai->dev, "Cannot set tx sysclk: %d\n", ret); | ||
107 | goto err_clk; | ||
108 | } | ||
109 | |||
110 | ret = fsl_sai_set_dai_sysclk_tr(cpu_dai, clk_id, freq, | ||
111 | FSL_FMT_RECEIVER); | ||
112 | if (ret) { | ||
113 | dev_err(cpu_dai->dev, "Cannot set rx sysclk: %d\n", ret); | ||
114 | goto err_clk; | ||
115 | } | ||
116 | |||
117 | err_clk: | ||
118 | clk_disable_unprepare(sai->clk); | ||
119 | |||
120 | return ret; | ||
121 | } | ||
122 | |||
123 | static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai, | ||
124 | unsigned int fmt, int fsl_dir) | ||
125 | { | ||
126 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); | ||
127 | u32 val_cr2, val_cr4, reg_cr2, reg_cr4; | ||
128 | |||
129 | if (fsl_dir == FSL_FMT_TRANSMITTER) { | ||
130 | reg_cr2 = FSL_SAI_TCR2; | ||
131 | reg_cr4 = FSL_SAI_TCR4; | ||
132 | } else { | ||
133 | reg_cr2 = FSL_SAI_RCR2; | ||
134 | reg_cr4 = FSL_SAI_RCR4; | ||
135 | } | ||
136 | |||
137 | val_cr2 = sai_readl(sai, sai->base + reg_cr2); | ||
138 | val_cr4 = sai_readl(sai, sai->base + reg_cr4); | ||
139 | |||
140 | if (sai->big_endian_data) | ||
141 | val_cr4 &= ~FSL_SAI_CR4_MF; | ||
142 | else | ||
143 | val_cr4 |= FSL_SAI_CR4_MF; | ||
144 | |||
145 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
146 | case SND_SOC_DAIFMT_I2S: | ||
147 | val_cr4 |= FSL_SAI_CR4_FSE; | ||
148 | break; | ||
149 | default: | ||
150 | return -EINVAL; | ||
151 | } | ||
152 | |||
153 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
154 | case SND_SOC_DAIFMT_IB_IF: | ||
155 | val_cr4 |= FSL_SAI_CR4_FSP; | ||
156 | val_cr2 &= ~FSL_SAI_CR2_BCP; | ||
157 | break; | ||
158 | case SND_SOC_DAIFMT_IB_NF: | ||
159 | val_cr4 &= ~FSL_SAI_CR4_FSP; | ||
160 | val_cr2 &= ~FSL_SAI_CR2_BCP; | ||
161 | break; | ||
162 | case SND_SOC_DAIFMT_NB_IF: | ||
163 | val_cr4 |= FSL_SAI_CR4_FSP; | ||
164 | val_cr2 |= FSL_SAI_CR2_BCP; | ||
165 | break; | ||
166 | case SND_SOC_DAIFMT_NB_NF: | ||
167 | val_cr4 &= ~FSL_SAI_CR4_FSP; | ||
168 | val_cr2 |= FSL_SAI_CR2_BCP; | ||
169 | break; | ||
170 | default: | ||
171 | return -EINVAL; | ||
172 | } | ||
173 | |||
174 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
175 | case SND_SOC_DAIFMT_CBS_CFS: | ||
176 | val_cr2 |= FSL_SAI_CR2_BCD_MSTR; | ||
177 | val_cr4 |= FSL_SAI_CR4_FSD_MSTR; | ||
178 | break; | ||
179 | case SND_SOC_DAIFMT_CBM_CFM: | ||
180 | val_cr2 &= ~FSL_SAI_CR2_BCD_MSTR; | ||
181 | val_cr4 &= ~FSL_SAI_CR4_FSD_MSTR; | ||
182 | break; | ||
183 | default: | ||
184 | return -EINVAL; | ||
185 | } | ||
186 | |||
187 | sai_writel(sai, val_cr2, sai->base + reg_cr2); | ||
188 | sai_writel(sai, val_cr4, sai->base + reg_cr4); | ||
189 | |||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | static int fsl_sai_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | ||
194 | { | ||
195 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); | ||
196 | int ret; | ||
197 | |||
198 | ret = clk_prepare_enable(sai->clk); | ||
199 | if (ret) | ||
200 | return ret; | ||
201 | |||
202 | ret = fsl_sai_set_dai_fmt_tr(cpu_dai, fmt, FSL_FMT_TRANSMITTER); | ||
203 | if (ret) { | ||
204 | dev_err(cpu_dai->dev, "Cannot set tx format: %d\n", ret); | ||
205 | goto err_clk; | ||
206 | } | ||
207 | |||
208 | ret = fsl_sai_set_dai_fmt_tr(cpu_dai, fmt, FSL_FMT_RECEIVER); | ||
209 | if (ret) { | ||
210 | dev_err(cpu_dai->dev, "Cannot set rx format: %d\n", ret); | ||
211 | goto err_clk; | ||
212 | } | ||
213 | |||
214 | err_clk: | ||
215 | clk_disable_unprepare(sai->clk); | ||
216 | |||
217 | return ret; | ||
218 | } | ||
219 | |||
220 | static int fsl_sai_hw_params(struct snd_pcm_substream *substream, | ||
221 | struct snd_pcm_hw_params *params, | ||
222 | struct snd_soc_dai *cpu_dai) | ||
223 | { | ||
224 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); | ||
225 | u32 val_cr4, val_cr5, val_mr, reg_cr4, reg_cr5, reg_mr; | ||
226 | unsigned int channels = params_channels(params); | ||
227 | u32 word_width = snd_pcm_format_width(params_format(params)); | ||
228 | |||
229 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
230 | reg_cr4 = FSL_SAI_TCR4; | ||
231 | reg_cr5 = FSL_SAI_TCR5; | ||
232 | reg_mr = FSL_SAI_TMR; | ||
233 | } else { | ||
234 | reg_cr4 = FSL_SAI_RCR4; | ||
235 | reg_cr5 = FSL_SAI_RCR5; | ||
236 | reg_mr = FSL_SAI_RMR; | ||
237 | } | ||
238 | |||
239 | val_cr4 = sai_readl(sai, sai->base + reg_cr4); | ||
240 | val_cr4 &= ~FSL_SAI_CR4_SYWD_MASK; | ||
241 | val_cr4 &= ~FSL_SAI_CR4_FRSZ_MASK; | ||
242 | |||
243 | val_cr5 = sai_readl(sai, sai->base + reg_cr5); | ||
244 | val_cr5 &= ~FSL_SAI_CR5_WNW_MASK; | ||
245 | val_cr5 &= ~FSL_SAI_CR5_W0W_MASK; | ||
246 | val_cr5 &= ~FSL_SAI_CR5_FBT_MASK; | ||
247 | |||
248 | val_cr4 |= FSL_SAI_CR4_SYWD(word_width); | ||
249 | val_cr5 |= FSL_SAI_CR5_WNW(word_width); | ||
250 | val_cr5 |= FSL_SAI_CR5_W0W(word_width); | ||
251 | |||
252 | val_cr5 &= ~FSL_SAI_CR5_FBT_MASK; | ||
253 | if (sai->big_endian_data) | ||
254 | val_cr5 |= FSL_SAI_CR5_FBT(0); | ||
255 | else | ||
256 | val_cr5 |= FSL_SAI_CR5_FBT(word_width - 1); | ||
257 | |||
258 | val_cr4 |= FSL_SAI_CR4_FRSZ(channels); | ||
259 | val_mr = ~0UL - ((1 << channels) - 1); | ||
260 | |||
261 | sai_writel(sai, val_cr4, sai->base + reg_cr4); | ||
262 | sai_writel(sai, val_cr5, sai->base + reg_cr5); | ||
263 | sai_writel(sai, val_mr, sai->base + reg_mr); | ||
264 | |||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, | ||
269 | struct snd_soc_dai *cpu_dai) | ||
270 | { | ||
271 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); | ||
272 | u32 tcsr, rcsr, val_cr2, val_cr3, reg_cr3; | ||
273 | |||
274 | val_cr2 = sai_readl(sai, sai->base + FSL_SAI_TCR2); | ||
275 | val_cr2 &= ~FSL_SAI_CR2_SYNC; | ||
276 | sai_writel(sai, val_cr2, sai->base + FSL_SAI_TCR2); | ||
277 | |||
278 | val_cr2 = sai_readl(sai, sai->base + FSL_SAI_RCR2); | ||
279 | val_cr2 |= FSL_SAI_CR2_SYNC; | ||
280 | sai_writel(sai, val_cr2, sai->base + FSL_SAI_RCR2); | ||
281 | |||
282 | tcsr = sai_readl(sai, sai->base + FSL_SAI_TCSR); | ||
283 | rcsr = sai_readl(sai, sai->base + FSL_SAI_RCSR); | ||
284 | |||
285 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
286 | tcsr |= FSL_SAI_CSR_FRDE; | ||
287 | rcsr &= ~FSL_SAI_CSR_FRDE; | ||
288 | reg_cr3 = FSL_SAI_TCR3; | ||
289 | } else { | ||
290 | rcsr |= FSL_SAI_CSR_FRDE; | ||
291 | tcsr &= ~FSL_SAI_CSR_FRDE; | ||
292 | reg_cr3 = FSL_SAI_RCR3; | ||
293 | } | ||
294 | |||
295 | val_cr3 = sai_readl(sai, sai->base + reg_cr3); | ||
296 | |||
297 | switch (cmd) { | ||
298 | case SNDRV_PCM_TRIGGER_START: | ||
299 | case SNDRV_PCM_TRIGGER_RESUME: | ||
300 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
301 | tcsr |= FSL_SAI_CSR_TERE; | ||
302 | rcsr |= FSL_SAI_CSR_TERE; | ||
303 | val_cr3 |= FSL_SAI_CR3_TRCE; | ||
304 | |||
305 | sai_writel(sai, val_cr3, sai->base + reg_cr3); | ||
306 | sai_writel(sai, rcsr, sai->base + FSL_SAI_RCSR); | ||
307 | sai_writel(sai, tcsr, sai->base + FSL_SAI_TCSR); | ||
308 | break; | ||
309 | |||
310 | case SNDRV_PCM_TRIGGER_STOP: | ||
311 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
312 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
313 | if (!(cpu_dai->playback_active || cpu_dai->capture_active)) { | ||
314 | tcsr &= ~FSL_SAI_CSR_TERE; | ||
315 | rcsr &= ~FSL_SAI_CSR_TERE; | ||
316 | } | ||
317 | |||
318 | val_cr3 &= ~FSL_SAI_CR3_TRCE; | ||
319 | |||
320 | sai_writel(sai, tcsr, sai->base + FSL_SAI_TCSR); | ||
321 | sai_writel(sai, rcsr, sai->base + FSL_SAI_RCSR); | ||
322 | sai_writel(sai, val_cr3, sai->base + reg_cr3); | ||
323 | break; | ||
324 | default: | ||
325 | return -EINVAL; | ||
326 | } | ||
327 | |||
328 | return 0; | ||
329 | } | ||
330 | |||
331 | static int fsl_sai_startup(struct snd_pcm_substream *substream, | ||
332 | struct snd_soc_dai *cpu_dai) | ||
333 | { | ||
334 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); | ||
335 | |||
336 | return clk_prepare_enable(sai->clk); | ||
337 | } | ||
338 | |||
339 | static void fsl_sai_shutdown(struct snd_pcm_substream *substream, | ||
340 | struct snd_soc_dai *cpu_dai) | ||
341 | { | ||
342 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); | ||
343 | |||
344 | clk_disable_unprepare(sai->clk); | ||
345 | } | ||
346 | |||
347 | static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = { | ||
348 | .set_sysclk = fsl_sai_set_dai_sysclk, | ||
349 | .set_fmt = fsl_sai_set_dai_fmt, | ||
350 | .hw_params = fsl_sai_hw_params, | ||
351 | .trigger = fsl_sai_trigger, | ||
352 | .startup = fsl_sai_startup, | ||
353 | .shutdown = fsl_sai_shutdown, | ||
354 | }; | ||
355 | |||
356 | static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai) | ||
357 | { | ||
358 | struct fsl_sai *sai = dev_get_drvdata(cpu_dai->dev); | ||
359 | int ret; | ||
360 | |||
361 | ret = clk_prepare_enable(sai->clk); | ||
362 | if (ret) | ||
363 | return ret; | ||
364 | |||
365 | sai_writel(sai, 0x0, sai->base + FSL_SAI_RCSR); | ||
366 | sai_writel(sai, 0x0, sai->base + FSL_SAI_TCSR); | ||
367 | sai_writel(sai, FSL_SAI_MAXBURST_TX * 2, sai->base + FSL_SAI_TCR1); | ||
368 | sai_writel(sai, FSL_SAI_MAXBURST_RX - 1, sai->base + FSL_SAI_RCR1); | ||
369 | |||
370 | clk_disable_unprepare(sai->clk); | ||
371 | |||
372 | snd_soc_dai_init_dma_data(cpu_dai, &sai->dma_params_tx, | ||
373 | &sai->dma_params_rx); | ||
374 | |||
375 | snd_soc_dai_set_drvdata(cpu_dai, sai); | ||
376 | |||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | static struct snd_soc_dai_driver fsl_sai_dai = { | ||
381 | .probe = fsl_sai_dai_probe, | ||
382 | .playback = { | ||
383 | .channels_min = 1, | ||
384 | .channels_max = 2, | ||
385 | .rates = SNDRV_PCM_RATE_8000_96000, | ||
386 | .formats = FSL_SAI_FORMATS, | ||
387 | }, | ||
388 | .capture = { | ||
389 | .channels_min = 1, | ||
390 | .channels_max = 2, | ||
391 | .rates = SNDRV_PCM_RATE_8000_96000, | ||
392 | .formats = FSL_SAI_FORMATS, | ||
393 | }, | ||
394 | .ops = &fsl_sai_pcm_dai_ops, | ||
395 | }; | ||
396 | |||
397 | static const struct snd_soc_component_driver fsl_component = { | ||
398 | .name = "fsl-sai", | ||
399 | }; | ||
400 | |||
401 | static int fsl_sai_probe(struct platform_device *pdev) | ||
402 | { | ||
403 | struct device_node *np = pdev->dev.of_node; | ||
404 | struct fsl_sai *sai; | ||
405 | struct resource *res; | ||
406 | int ret; | ||
407 | |||
408 | sai = devm_kzalloc(&pdev->dev, sizeof(*sai), GFP_KERNEL); | ||
409 | if (!sai) | ||
410 | return -ENOMEM; | ||
411 | |||
412 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
413 | sai->base = devm_ioremap_resource(&pdev->dev, res); | ||
414 | if (IS_ERR(sai->base)) | ||
415 | return PTR_ERR(sai->base); | ||
416 | |||
417 | sai->clk = devm_clk_get(&pdev->dev, "sai"); | ||
418 | if (IS_ERR(sai->clk)) { | ||
419 | dev_err(&pdev->dev, "Cannot get SAI's clock\n"); | ||
420 | return PTR_ERR(sai->clk); | ||
421 | } | ||
422 | |||
423 | sai->dma_params_rx.addr = res->start + FSL_SAI_RDR; | ||
424 | sai->dma_params_tx.addr = res->start + FSL_SAI_TDR; | ||
425 | sai->dma_params_rx.maxburst = FSL_SAI_MAXBURST_RX; | ||
426 | sai->dma_params_tx.maxburst = FSL_SAI_MAXBURST_TX; | ||
427 | |||
428 | sai->big_endian_regs = of_property_read_bool(np, "big-endian-regs"); | ||
429 | sai->big_endian_data = of_property_read_bool(np, "big-endian-data"); | ||
430 | |||
431 | platform_set_drvdata(pdev, sai); | ||
432 | |||
433 | ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component, | ||
434 | &fsl_sai_dai, 1); | ||
435 | if (ret) | ||
436 | return ret; | ||
437 | |||
438 | return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, | ||
439 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE); | ||
440 | } | ||
441 | |||
442 | static const struct of_device_id fsl_sai_ids[] = { | ||
443 | { .compatible = "fsl,vf610-sai", }, | ||
444 | { /* sentinel */ } | ||
445 | }; | ||
446 | |||
447 | static struct platform_driver fsl_sai_driver = { | ||
448 | .probe = fsl_sai_probe, | ||
449 | .driver = { | ||
450 | .name = "fsl-sai", | ||
451 | .owner = THIS_MODULE, | ||
452 | .of_match_table = fsl_sai_ids, | ||
453 | }, | ||
454 | }; | ||
455 | module_platform_driver(fsl_sai_driver); | ||
456 | |||
457 | MODULE_DESCRIPTION("Freescale Soc SAI Interface"); | ||
458 | MODULE_AUTHOR("Xiubo Li, <Li.Xiubo@freescale.com>"); | ||
459 | MODULE_ALIAS("platform:fsl-sai"); | ||
460 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h new file mode 100644 index 000000000000..41bb62e69361 --- /dev/null +++ b/sound/soc/fsl/fsl_sai.h | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * Copyright 2012-2013 Freescale Semiconductor, Inc. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #ifndef __FSL_SAI_H | ||
10 | #define __FSL_SAI_H | ||
11 | |||
12 | #include <sound/dmaengine_pcm.h> | ||
13 | |||
14 | #define FSL_SAI_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ | ||
15 | SNDRV_PCM_FMTBIT_S20_3LE |\ | ||
16 | SNDRV_PCM_FMTBIT_S24_LE) | ||
17 | |||
18 | /* SAI Transmit/Recieve Control Register */ | ||
19 | #define FSL_SAI_TCSR 0x00 | ||
20 | #define FSL_SAI_RCSR 0x80 | ||
21 | #define FSL_SAI_CSR_TERE BIT(31) | ||
22 | #define FSL_SAI_CSR_FWF BIT(17) | ||
23 | #define FSL_SAI_CSR_FRIE BIT(8) | ||
24 | #define FSL_SAI_CSR_FRDE BIT(0) | ||
25 | |||
26 | /* SAI Transmit Data/FIFO/MASK Register */ | ||
27 | #define FSL_SAI_TDR 0x20 | ||
28 | #define FSL_SAI_TFR 0x40 | ||
29 | #define FSL_SAI_TMR 0x60 | ||
30 | |||
31 | /* SAI Recieve Data/FIFO/MASK Register */ | ||
32 | #define FSL_SAI_RDR 0xa0 | ||
33 | #define FSL_SAI_RFR 0xc0 | ||
34 | #define FSL_SAI_RMR 0xe0 | ||
35 | |||
36 | /* SAI Transmit and Recieve Configuration 1 Register */ | ||
37 | #define FSL_SAI_TCR1 0x04 | ||
38 | #define FSL_SAI_RCR1 0x84 | ||
39 | |||
40 | /* SAI Transmit and Recieve Configuration 2 Register */ | ||
41 | #define FSL_SAI_TCR2 0x08 | ||
42 | #define FSL_SAI_RCR2 0x88 | ||
43 | #define FSL_SAI_CR2_SYNC BIT(30) | ||
44 | #define FSL_SAI_CR2_MSEL_MASK (0xff << 26) | ||
45 | #define FSL_SAI_CR2_MSEL_BUS 0 | ||
46 | #define FSL_SAI_CR2_MSEL_MCLK1 BIT(26) | ||
47 | #define FSL_SAI_CR2_MSEL_MCLK2 BIT(27) | ||
48 | #define FSL_SAI_CR2_MSEL_MCLK3 (BIT(26) | BIT(27)) | ||
49 | #define FSL_SAI_CR2_BCP BIT(25) | ||
50 | #define FSL_SAI_CR2_BCD_MSTR BIT(24) | ||
51 | |||
52 | /* SAI Transmit and Recieve Configuration 3 Register */ | ||
53 | #define FSL_SAI_TCR3 0x0c | ||
54 | #define FSL_SAI_RCR3 0x8c | ||
55 | #define FSL_SAI_CR3_TRCE BIT(16) | ||
56 | #define FSL_SAI_CR3_WDFL(x) (x) | ||
57 | #define FSL_SAI_CR3_WDFL_MASK 0x1f | ||
58 | |||
59 | /* SAI Transmit and Recieve Configuration 4 Register */ | ||
60 | #define FSL_SAI_TCR4 0x10 | ||
61 | #define FSL_SAI_RCR4 0x90 | ||
62 | #define FSL_SAI_CR4_FRSZ(x) (((x) - 1) << 16) | ||
63 | #define FSL_SAI_CR4_FRSZ_MASK (0x1f << 16) | ||
64 | #define FSL_SAI_CR4_SYWD(x) (((x) - 1) << 8) | ||
65 | #define FSL_SAI_CR4_SYWD_MASK (0x1f << 8) | ||
66 | #define FSL_SAI_CR4_MF BIT(4) | ||
67 | #define FSL_SAI_CR4_FSE BIT(3) | ||
68 | #define FSL_SAI_CR4_FSP BIT(1) | ||
69 | #define FSL_SAI_CR4_FSD_MSTR BIT(0) | ||
70 | |||
71 | /* SAI Transmit and Recieve Configuration 5 Register */ | ||
72 | #define FSL_SAI_TCR5 0x14 | ||
73 | #define FSL_SAI_RCR5 0x94 | ||
74 | #define FSL_SAI_CR5_WNW(x) (((x) - 1) << 24) | ||
75 | #define FSL_SAI_CR5_WNW_MASK (0x1f << 24) | ||
76 | #define FSL_SAI_CR5_W0W(x) (((x) - 1) << 16) | ||
77 | #define FSL_SAI_CR5_W0W_MASK (0x1f << 16) | ||
78 | #define FSL_SAI_CR5_FBT(x) ((x) << 8) | ||
79 | #define FSL_SAI_CR5_FBT_MASK (0x1f << 8) | ||
80 | |||
81 | /* SAI type */ | ||
82 | #define FSL_SAI_DMA BIT(0) | ||
83 | #define FSL_SAI_USE_AC97 BIT(1) | ||
84 | #define FSL_SAI_NET BIT(2) | ||
85 | #define FSL_SAI_TRA_SYN BIT(3) | ||
86 | #define FSL_SAI_REC_SYN BIT(4) | ||
87 | #define FSL_SAI_USE_I2S_SLAVE BIT(5) | ||
88 | |||
89 | #define FSL_FMT_TRANSMITTER 0 | ||
90 | #define FSL_FMT_RECEIVER 1 | ||
91 | |||
92 | /* SAI clock sources */ | ||
93 | #define FSL_SAI_CLK_BUS 0 | ||
94 | #define FSL_SAI_CLK_MAST1 1 | ||
95 | #define FSL_SAI_CLK_MAST2 2 | ||
96 | #define FSL_SAI_CLK_MAST3 3 | ||
97 | |||
98 | /* SAI data transfer numbers per DMA request */ | ||
99 | #define FSL_SAI_MAXBURST_TX 6 | ||
100 | #define FSL_SAI_MAXBURST_RX 6 | ||
101 | |||
102 | struct fsl_sai { | ||
103 | struct clk *clk; | ||
104 | |||
105 | void __iomem *base; | ||
106 | |||
107 | bool big_endian_regs; | ||
108 | bool big_endian_data; | ||
109 | |||
110 | struct snd_dmaengine_dai_dma_data dma_params_rx; | ||
111 | struct snd_dmaengine_dai_dma_data dma_params_tx; | ||
112 | }; | ||
113 | |||
114 | #endif /* __FSL_SAI_H */ | ||
diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 55193a5596ca..4d075f1abe78 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c | |||
@@ -1181,13 +1181,6 @@ static int fsl_spdif_probe(struct platform_device *pdev) | |||
1181 | return ret; | 1181 | return ret; |
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | static int fsl_spdif_remove(struct platform_device *pdev) | ||
1185 | { | ||
1186 | imx_pcm_dma_exit(pdev); | ||
1187 | |||
1188 | return 0; | ||
1189 | } | ||
1190 | |||
1191 | static const struct of_device_id fsl_spdif_dt_ids[] = { | 1184 | static const struct of_device_id fsl_spdif_dt_ids[] = { |
1192 | { .compatible = "fsl,imx35-spdif", }, | 1185 | { .compatible = "fsl,imx35-spdif", }, |
1193 | {} | 1186 | {} |
@@ -1201,7 +1194,6 @@ static struct platform_driver fsl_spdif_driver = { | |||
1201 | .of_match_table = fsl_spdif_dt_ids, | 1194 | .of_match_table = fsl_spdif_dt_ids, |
1202 | }, | 1195 | }, |
1203 | .probe = fsl_spdif_probe, | 1196 | .probe = fsl_spdif_probe, |
1204 | .remove = fsl_spdif_remove, | ||
1205 | }; | 1197 | }; |
1206 | 1198 | ||
1207 | module_platform_driver(fsl_spdif_driver); | 1199 | module_platform_driver(fsl_spdif_driver); |
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 35e277379b86..b2ebaf811599 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/device.h> | 38 | #include <linux/device.h> |
39 | #include <linux/delay.h> | 39 | #include <linux/delay.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/spinlock.h> | ||
41 | #include <linux/of_address.h> | 42 | #include <linux/of_address.h> |
42 | #include <linux/of_irq.h> | 43 | #include <linux/of_irq.h> |
43 | #include <linux/of_platform.h> | 44 | #include <linux/of_platform.h> |
@@ -119,8 +120,6 @@ static inline void write_ssi_mask(u32 __iomem *addr, u32 clear, u32 set) | |||
119 | * @ssi: pointer to the SSI's registers | 120 | * @ssi: pointer to the SSI's registers |
120 | * @ssi_phys: physical address of the SSI registers | 121 | * @ssi_phys: physical address of the SSI registers |
121 | * @irq: IRQ of this SSI | 122 | * @irq: IRQ of this SSI |
122 | * @first_stream: pointer to the stream that was opened first | ||
123 | * @second_stream: pointer to second stream | ||
124 | * @playback: the number of playback streams opened | 123 | * @playback: the number of playback streams opened |
125 | * @capture: the number of capture streams opened | 124 | * @capture: the number of capture streams opened |
126 | * @cpu_dai: the CPU DAI for this device | 125 | * @cpu_dai: the CPU DAI for this device |
@@ -132,8 +131,6 @@ struct fsl_ssi_private { | |||
132 | struct ccsr_ssi __iomem *ssi; | 131 | struct ccsr_ssi __iomem *ssi; |
133 | dma_addr_t ssi_phys; | 132 | dma_addr_t ssi_phys; |
134 | unsigned int irq; | 133 | unsigned int irq; |
135 | struct snd_pcm_substream *first_stream; | ||
136 | struct snd_pcm_substream *second_stream; | ||
137 | unsigned int fifo_depth; | 134 | unsigned int fifo_depth; |
138 | struct snd_soc_dai_driver cpu_dai_drv; | 135 | struct snd_soc_dai_driver cpu_dai_drv; |
139 | struct device_attribute dev_attr; | 136 | struct device_attribute dev_attr; |
@@ -143,6 +140,10 @@ struct fsl_ssi_private { | |||
143 | bool ssi_on_imx; | 140 | bool ssi_on_imx; |
144 | bool imx_ac97; | 141 | bool imx_ac97; |
145 | bool use_dma; | 142 | bool use_dma; |
143 | bool baudclk_locked; | ||
144 | u8 i2s_mode; | ||
145 | spinlock_t baudclk_lock; | ||
146 | struct clk *baudclk; | ||
146 | struct clk *clk; | 147 | struct clk *clk; |
147 | struct snd_dmaengine_dai_dma_data dma_params_tx; | 148 | struct snd_dmaengine_dai_dma_data dma_params_tx; |
148 | struct snd_dmaengine_dai_dma_data dma_params_rx; | 149 | struct snd_dmaengine_dai_dma_data dma_params_rx; |
@@ -321,17 +322,46 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) | |||
321 | return ret; | 322 | return ret; |
322 | } | 323 | } |
323 | 324 | ||
325 | static void fsl_ssi_setup_ac97(struct fsl_ssi_private *ssi_private) | ||
326 | { | ||
327 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | ||
328 | |||
329 | /* | ||
330 | * Setup the clock control register | ||
331 | */ | ||
332 | write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), | ||
333 | &ssi->stccr); | ||
334 | write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), | ||
335 | &ssi->srccr); | ||
336 | |||
337 | /* | ||
338 | * Enable AC97 mode and startup the SSI | ||
339 | */ | ||
340 | write_ssi(CCSR_SSI_SACNT_AC97EN | CCSR_SSI_SACNT_FV, | ||
341 | &ssi->sacnt); | ||
342 | write_ssi(0xff, &ssi->saccdis); | ||
343 | write_ssi(0x300, &ssi->saccen); | ||
344 | |||
345 | /* | ||
346 | * Enable SSI, Transmit and Receive. AC97 has to communicate with the | ||
347 | * codec before a stream is started. | ||
348 | */ | ||
349 | write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN | | ||
350 | CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE); | ||
351 | |||
352 | write_ssi(CCSR_SSI_SOR_WAIT(3), &ssi->sor); | ||
353 | } | ||
354 | |||
324 | static int fsl_ssi_setup(struct fsl_ssi_private *ssi_private) | 355 | static int fsl_ssi_setup(struct fsl_ssi_private *ssi_private) |
325 | { | 356 | { |
326 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 357 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; |
327 | u8 i2s_mode; | ||
328 | u8 wm; | 358 | u8 wm; |
329 | int synchronous = ssi_private->cpu_dai_drv.symmetric_rates; | 359 | int synchronous = ssi_private->cpu_dai_drv.symmetric_rates; |
330 | 360 | ||
331 | if (ssi_private->imx_ac97) | 361 | if (ssi_private->imx_ac97) |
332 | i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL | CCSR_SSI_SCR_NET; | 362 | ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL | CCSR_SSI_SCR_NET; |
333 | else | 363 | else |
334 | i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE; | 364 | ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE; |
335 | 365 | ||
336 | /* | 366 | /* |
337 | * Section 16.5 of the MPC8610 reference manual says that the SSI needs | 367 | * Section 16.5 of the MPC8610 reference manual says that the SSI needs |
@@ -348,7 +378,7 @@ static int fsl_ssi_setup(struct fsl_ssi_private *ssi_private) | |||
348 | write_ssi_mask(&ssi->scr, | 378 | write_ssi_mask(&ssi->scr, |
349 | CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN, | 379 | CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN, |
350 | CCSR_SSI_SCR_TFR_CLK_DIS | | 380 | CCSR_SSI_SCR_TFR_CLK_DIS | |
351 | i2s_mode | | 381 | ssi_private->i2s_mode | |
352 | (synchronous ? CCSR_SSI_SCR_SYN : 0)); | 382 | (synchronous ? CCSR_SSI_SCR_SYN : 0)); |
353 | 383 | ||
354 | write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 | | 384 | write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 | |
@@ -387,31 +417,8 @@ static int fsl_ssi_setup(struct fsl_ssi_private *ssi_private) | |||
387 | * because it is also running without an active substream. Normally SSI | 417 | * because it is also running without an active substream. Normally SSI |
388 | * is only enabled when there is a substream. | 418 | * is only enabled when there is a substream. |
389 | */ | 419 | */ |
390 | if (ssi_private->imx_ac97) { | 420 | if (ssi_private->imx_ac97) |
391 | /* | 421 | fsl_ssi_setup_ac97(ssi_private); |
392 | * Setup the clock control register | ||
393 | */ | ||
394 | write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), | ||
395 | &ssi->stccr); | ||
396 | write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), | ||
397 | &ssi->srccr); | ||
398 | |||
399 | /* | ||
400 | * Enable AC97 mode and startup the SSI | ||
401 | */ | ||
402 | write_ssi(CCSR_SSI_SACNT_AC97EN | CCSR_SSI_SACNT_FV, | ||
403 | &ssi->sacnt); | ||
404 | write_ssi(0xff, &ssi->saccdis); | ||
405 | write_ssi(0x300, &ssi->saccen); | ||
406 | |||
407 | /* | ||
408 | * Enable SSI, Transmit and Receive | ||
409 | */ | ||
410 | write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN | | ||
411 | CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE); | ||
412 | |||
413 | write_ssi(CCSR_SSI_SOR_WAIT(3), &ssi->sor); | ||
414 | } | ||
415 | 422 | ||
416 | return 0; | 423 | return 0; |
417 | } | 424 | } |
@@ -431,53 +438,17 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, | |||
431 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 438 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
432 | struct fsl_ssi_private *ssi_private = | 439 | struct fsl_ssi_private *ssi_private = |
433 | snd_soc_dai_get_drvdata(rtd->cpu_dai); | 440 | snd_soc_dai_get_drvdata(rtd->cpu_dai); |
434 | int synchronous = ssi_private->cpu_dai_drv.symmetric_rates; | 441 | unsigned long flags; |
435 | 442 | ||
436 | /* | 443 | /* First, we only do fsl_ssi_setup() when SSI is going to be active. |
437 | * If this is the first stream opened, then request the IRQ | 444 | * Second, fsl_ssi_setup was already called by ac97_init earlier if |
438 | * and initialize the SSI registers. | 445 | * the driver is in ac97 mode. |
439 | */ | 446 | */ |
440 | if (!ssi_private->first_stream) { | 447 | if (!dai->active && !ssi_private->imx_ac97) { |
441 | ssi_private->first_stream = substream; | 448 | fsl_ssi_setup(ssi_private); |
442 | 449 | spin_lock_irqsave(&ssi_private->baudclk_lock, flags); | |
443 | /* | 450 | ssi_private->baudclk_locked = false; |
444 | * fsl_ssi_setup was already called by ac97_init earlier if | 451 | spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); |
445 | * the driver is in ac97 mode. | ||
446 | */ | ||
447 | if (!ssi_private->imx_ac97) | ||
448 | fsl_ssi_setup(ssi_private); | ||
449 | } else { | ||
450 | if (synchronous) { | ||
451 | struct snd_pcm_runtime *first_runtime = | ||
452 | ssi_private->first_stream->runtime; | ||
453 | /* | ||
454 | * This is the second stream open, and we're in | ||
455 | * synchronous mode, so we need to impose sample | ||
456 | * sample size constraints. This is because STCCR is | ||
457 | * used for playback and capture in synchronous mode, | ||
458 | * so there's no way to specify different word | ||
459 | * lengths. | ||
460 | * | ||
461 | * Note that this can cause a race condition if the | ||
462 | * second stream is opened before the first stream is | ||
463 | * fully initialized. We provide some protection by | ||
464 | * checking to make sure the first stream is | ||
465 | * initialized, but it's not perfect. ALSA sometimes | ||
466 | * re-initializes the driver with a different sample | ||
467 | * rate or size. If the second stream is opened | ||
468 | * before the first stream has received its final | ||
469 | * parameters, then the second stream may be | ||
470 | * constrained to the wrong sample rate or size. | ||
471 | */ | ||
472 | if (first_runtime->sample_bits) { | ||
473 | snd_pcm_hw_constraint_minmax(substream->runtime, | ||
474 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, | ||
475 | first_runtime->sample_bits, | ||
476 | first_runtime->sample_bits); | ||
477 | } | ||
478 | } | ||
479 | |||
480 | ssi_private->second_stream = substream; | ||
481 | } | 452 | } |
482 | 453 | ||
483 | return 0; | 454 | return 0; |
@@ -501,6 +472,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, | |||
501 | { | 472 | { |
502 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); | 473 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); |
503 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 474 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; |
475 | unsigned int channels = params_channels(hw_params); | ||
504 | unsigned int sample_size = | 476 | unsigned int sample_size = |
505 | snd_pcm_format_width(params_format(hw_params)); | 477 | snd_pcm_format_width(params_format(hw_params)); |
506 | u32 wl = CCSR_SSI_SxCCR_WL(sample_size); | 478 | u32 wl = CCSR_SSI_SxCCR_WL(sample_size); |
@@ -530,6 +502,248 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, | |||
530 | else | 502 | else |
531 | write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl); | 503 | write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl); |
532 | 504 | ||
505 | if (!ssi_private->imx_ac97) | ||
506 | write_ssi_mask(&ssi->scr, | ||
507 | CCSR_SSI_SCR_NET | CCSR_SSI_SCR_I2S_MODE_MASK, | ||
508 | channels == 1 ? 0 : ssi_private->i2s_mode); | ||
509 | |||
510 | return 0; | ||
511 | } | ||
512 | |||
513 | /** | ||
514 | * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format. | ||
515 | */ | ||
516 | static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | ||
517 | { | ||
518 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); | ||
519 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | ||
520 | u32 strcr = 0, stcr, srcr, scr, mask; | ||
521 | |||
522 | scr = read_ssi(&ssi->scr) & ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK); | ||
523 | scr |= CCSR_SSI_SCR_NET; | ||
524 | |||
525 | mask = CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR | | ||
526 | CCSR_SSI_STCR_TSCKP | CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TFSL | | ||
527 | CCSR_SSI_STCR_TEFS; | ||
528 | stcr = read_ssi(&ssi->stcr) & ~mask; | ||
529 | srcr = read_ssi(&ssi->srcr) & ~mask; | ||
530 | |||
531 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
532 | case SND_SOC_DAIFMT_I2S: | ||
533 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
534 | case SND_SOC_DAIFMT_CBS_CFS: | ||
535 | ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_MASTER; | ||
536 | break; | ||
537 | case SND_SOC_DAIFMT_CBM_CFM: | ||
538 | ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE; | ||
539 | break; | ||
540 | default: | ||
541 | return -EINVAL; | ||
542 | } | ||
543 | scr |= ssi_private->i2s_mode; | ||
544 | |||
545 | /* Data on rising edge of bclk, frame low, 1clk before data */ | ||
546 | strcr |= CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TSCKP | | ||
547 | CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TEFS; | ||
548 | break; | ||
549 | case SND_SOC_DAIFMT_LEFT_J: | ||
550 | /* Data on rising edge of bclk, frame high */ | ||
551 | strcr |= CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TSCKP; | ||
552 | break; | ||
553 | case SND_SOC_DAIFMT_DSP_A: | ||
554 | /* Data on rising edge of bclk, frame high, 1clk before data */ | ||
555 | strcr |= CCSR_SSI_STCR_TFSL | CCSR_SSI_STCR_TSCKP | | ||
556 | CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TEFS; | ||
557 | break; | ||
558 | case SND_SOC_DAIFMT_DSP_B: | ||
559 | /* Data on rising edge of bclk, frame high */ | ||
560 | strcr |= CCSR_SSI_STCR_TFSL | CCSR_SSI_STCR_TSCKP | | ||
561 | CCSR_SSI_STCR_TXBIT0; | ||
562 | break; | ||
563 | default: | ||
564 | return -EINVAL; | ||
565 | } | ||
566 | |||
567 | /* DAI clock inversion */ | ||
568 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
569 | case SND_SOC_DAIFMT_NB_NF: | ||
570 | /* Nothing to do for both normal cases */ | ||
571 | break; | ||
572 | case SND_SOC_DAIFMT_IB_NF: | ||
573 | /* Invert bit clock */ | ||
574 | strcr ^= CCSR_SSI_STCR_TSCKP; | ||
575 | break; | ||
576 | case SND_SOC_DAIFMT_NB_IF: | ||
577 | /* Invert frame clock */ | ||
578 | strcr ^= CCSR_SSI_STCR_TFSI; | ||
579 | break; | ||
580 | case SND_SOC_DAIFMT_IB_IF: | ||
581 | /* Invert both clocks */ | ||
582 | strcr ^= CCSR_SSI_STCR_TSCKP; | ||
583 | strcr ^= CCSR_SSI_STCR_TFSI; | ||
584 | break; | ||
585 | default: | ||
586 | return -EINVAL; | ||
587 | } | ||
588 | |||
589 | /* DAI clock master masks */ | ||
590 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
591 | case SND_SOC_DAIFMT_CBS_CFS: | ||
592 | strcr |= CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR; | ||
593 | scr |= CCSR_SSI_SCR_SYS_CLK_EN; | ||
594 | break; | ||
595 | case SND_SOC_DAIFMT_CBM_CFM: | ||
596 | scr &= ~CCSR_SSI_SCR_SYS_CLK_EN; | ||
597 | break; | ||
598 | default: | ||
599 | return -EINVAL; | ||
600 | } | ||
601 | |||
602 | stcr |= strcr; | ||
603 | srcr |= strcr; | ||
604 | |||
605 | if (ssi_private->cpu_dai_drv.symmetric_rates) { | ||
606 | /* Need to clear RXDIR when using SYNC mode */ | ||
607 | srcr &= ~CCSR_SSI_SRCR_RXDIR; | ||
608 | scr |= CCSR_SSI_SCR_SYN; | ||
609 | } | ||
610 | |||
611 | write_ssi(stcr, &ssi->stcr); | ||
612 | write_ssi(srcr, &ssi->srcr); | ||
613 | write_ssi(scr, &ssi->scr); | ||
614 | |||
615 | return 0; | ||
616 | } | ||
617 | |||
618 | /** | ||
619 | * fsl_ssi_set_dai_sysclk - configure Digital Audio Interface bit clock | ||
620 | * | ||
621 | * Note: This function can be only called when using SSI as DAI master | ||
622 | * | ||
623 | * Quick instruction for parameters: | ||
624 | * freq: Output BCLK frequency = samplerate * 32 (fixed) * channels | ||
625 | * dir: SND_SOC_CLOCK_OUT -> TxBCLK, SND_SOC_CLOCK_IN -> RxBCLK. | ||
626 | */ | ||
627 | static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | ||
628 | int clk_id, unsigned int freq, int dir) | ||
629 | { | ||
630 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); | ||
631 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | ||
632 | int synchronous = ssi_private->cpu_dai_drv.symmetric_rates, ret; | ||
633 | u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i; | ||
634 | unsigned long flags, clkrate, baudrate, tmprate; | ||
635 | u64 sub, savesub = 100000; | ||
636 | |||
637 | /* Don't apply it to any non-baudclk circumstance */ | ||
638 | if (IS_ERR(ssi_private->baudclk)) | ||
639 | return -EINVAL; | ||
640 | |||
641 | /* It should be already enough to divide clock by setting pm alone */ | ||
642 | psr = 0; | ||
643 | div2 = 0; | ||
644 | |||
645 | factor = (div2 + 1) * (7 * psr + 1) * 2; | ||
646 | |||
647 | for (i = 0; i < 255; i++) { | ||
648 | /* The bclk rate must be smaller than 1/5 sysclk rate */ | ||
649 | if (factor * (i + 1) < 5) | ||
650 | continue; | ||
651 | |||
652 | tmprate = freq * factor * (i + 2); | ||
653 | clkrate = clk_round_rate(ssi_private->baudclk, tmprate); | ||
654 | |||
655 | do_div(clkrate, factor); | ||
656 | afreq = (u32)clkrate / (i + 1); | ||
657 | |||
658 | if (freq == afreq) | ||
659 | sub = 0; | ||
660 | else if (freq / afreq == 1) | ||
661 | sub = freq - afreq; | ||
662 | else if (afreq / freq == 1) | ||
663 | sub = afreq - freq; | ||
664 | else | ||
665 | continue; | ||
666 | |||
667 | /* Calculate the fraction */ | ||
668 | sub *= 100000; | ||
669 | do_div(sub, freq); | ||
670 | |||
671 | if (sub < savesub) { | ||
672 | baudrate = tmprate; | ||
673 | savesub = sub; | ||
674 | pm = i; | ||
675 | } | ||
676 | |||
677 | /* We are lucky */ | ||
678 | if (savesub == 0) | ||
679 | break; | ||
680 | } | ||
681 | |||
682 | /* No proper pm found if it is still remaining the initial value */ | ||
683 | if (pm == 999) { | ||
684 | dev_err(cpu_dai->dev, "failed to handle the required sysclk\n"); | ||
685 | return -EINVAL; | ||
686 | } | ||
687 | |||
688 | stccr = CCSR_SSI_SxCCR_PM(pm + 1) | (div2 ? CCSR_SSI_SxCCR_DIV2 : 0) | | ||
689 | (psr ? CCSR_SSI_SxCCR_PSR : 0); | ||
690 | mask = CCSR_SSI_SxCCR_PM_MASK | CCSR_SSI_SxCCR_DIV2 | CCSR_SSI_SxCCR_PSR; | ||
691 | |||
692 | if (dir == SND_SOC_CLOCK_OUT || synchronous) | ||
693 | write_ssi_mask(&ssi->stccr, mask, stccr); | ||
694 | else | ||
695 | write_ssi_mask(&ssi->srccr, mask, stccr); | ||
696 | |||
697 | spin_lock_irqsave(&ssi_private->baudclk_lock, flags); | ||
698 | if (!ssi_private->baudclk_locked) { | ||
699 | ret = clk_set_rate(ssi_private->baudclk, baudrate); | ||
700 | if (ret) { | ||
701 | spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); | ||
702 | dev_err(cpu_dai->dev, "failed to set baudclk rate\n"); | ||
703 | return -EINVAL; | ||
704 | } | ||
705 | ssi_private->baudclk_locked = true; | ||
706 | } | ||
707 | spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); | ||
708 | |||
709 | return 0; | ||
710 | } | ||
711 | |||
712 | /** | ||
713 | * fsl_ssi_set_dai_tdm_slot - set TDM slot number | ||
714 | * | ||
715 | * Note: This function can be only called when using SSI as DAI master | ||
716 | */ | ||
717 | static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, | ||
718 | u32 rx_mask, int slots, int slot_width) | ||
719 | { | ||
720 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); | ||
721 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | ||
722 | u32 val; | ||
723 | |||
724 | /* The slot number should be >= 2 if using Network mode or I2S mode */ | ||
725 | val = read_ssi(&ssi->scr) & (CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_NET); | ||
726 | if (val && slots < 2) { | ||
727 | dev_err(cpu_dai->dev, "slot number should be >= 2 in I2S or NET\n"); | ||
728 | return -EINVAL; | ||
729 | } | ||
730 | |||
731 | write_ssi_mask(&ssi->stccr, CCSR_SSI_SxCCR_DC_MASK, | ||
732 | CCSR_SSI_SxCCR_DC(slots)); | ||
733 | write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_DC_MASK, | ||
734 | CCSR_SSI_SxCCR_DC(slots)); | ||
735 | |||
736 | /* The register SxMSKs needs SSI to provide essential clock due to | ||
737 | * hardware design. So we here temporarily enable SSI to set them. | ||
738 | */ | ||
739 | val = read_ssi(&ssi->scr) & CCSR_SSI_SCR_SSIEN; | ||
740 | write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN); | ||
741 | |||
742 | write_ssi(tx_mask, &ssi->stmsk); | ||
743 | write_ssi(rx_mask, &ssi->srmsk); | ||
744 | |||
745 | write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, val); | ||
746 | |||
533 | return 0; | 747 | return 0; |
534 | } | 748 | } |
535 | 749 | ||
@@ -549,6 +763,7 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, | |||
549 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai); | 763 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai); |
550 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; | 764 | struct ccsr_ssi __iomem *ssi = ssi_private->ssi; |
551 | unsigned int sier_bits; | 765 | unsigned int sier_bits; |
766 | unsigned long flags; | ||
552 | 767 | ||
553 | /* | 768 | /* |
554 | * Enable only the interrupts and DMA requests | 769 | * Enable only the interrupts and DMA requests |
@@ -589,8 +804,12 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, | |||
589 | write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_RE, 0); | 804 | write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_RE, 0); |
590 | 805 | ||
591 | if (!ssi_private->imx_ac97 && (read_ssi(&ssi->scr) & | 806 | if (!ssi_private->imx_ac97 && (read_ssi(&ssi->scr) & |
592 | (CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE)) == 0) | 807 | (CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE)) == 0) { |
593 | write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0); | 808 | write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0); |
809 | spin_lock_irqsave(&ssi_private->baudclk_lock, flags); | ||
810 | ssi_private->baudclk_locked = false; | ||
811 | spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); | ||
812 | } | ||
594 | break; | 813 | break; |
595 | 814 | ||
596 | default: | 815 | default: |
@@ -602,23 +821,6 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, | |||
602 | return 0; | 821 | return 0; |
603 | } | 822 | } |
604 | 823 | ||
605 | /** | ||
606 | * fsl_ssi_shutdown: shutdown the SSI | ||
607 | * | ||
608 | * Shutdown the SSI if there are no other substreams open. | ||
609 | */ | ||
610 | static void fsl_ssi_shutdown(struct snd_pcm_substream *substream, | ||
611 | struct snd_soc_dai *dai) | ||
612 | { | ||
613 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
614 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai); | ||
615 | |||
616 | if (ssi_private->first_stream == substream) | ||
617 | ssi_private->first_stream = ssi_private->second_stream; | ||
618 | |||
619 | ssi_private->second_stream = NULL; | ||
620 | } | ||
621 | |||
622 | static int fsl_ssi_dai_probe(struct snd_soc_dai *dai) | 824 | static int fsl_ssi_dai_probe(struct snd_soc_dai *dai) |
623 | { | 825 | { |
624 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(dai); | 826 | struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(dai); |
@@ -634,7 +836,9 @@ static int fsl_ssi_dai_probe(struct snd_soc_dai *dai) | |||
634 | static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { | 836 | static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { |
635 | .startup = fsl_ssi_startup, | 837 | .startup = fsl_ssi_startup, |
636 | .hw_params = fsl_ssi_hw_params, | 838 | .hw_params = fsl_ssi_hw_params, |
637 | .shutdown = fsl_ssi_shutdown, | 839 | .set_fmt = fsl_ssi_set_dai_fmt, |
840 | .set_sysclk = fsl_ssi_set_dai_sysclk, | ||
841 | .set_tdm_slot = fsl_ssi_set_dai_tdm_slot, | ||
638 | .trigger = fsl_ssi_trigger, | 842 | .trigger = fsl_ssi_trigger, |
639 | }; | 843 | }; |
640 | 844 | ||
@@ -642,14 +846,13 @@ static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { | |||
642 | static struct snd_soc_dai_driver fsl_ssi_dai_template = { | 846 | static struct snd_soc_dai_driver fsl_ssi_dai_template = { |
643 | .probe = fsl_ssi_dai_probe, | 847 | .probe = fsl_ssi_dai_probe, |
644 | .playback = { | 848 | .playback = { |
645 | /* The SSI does not support monaural audio. */ | 849 | .channels_min = 1, |
646 | .channels_min = 2, | ||
647 | .channels_max = 2, | 850 | .channels_max = 2, |
648 | .rates = FSLSSI_I2S_RATES, | 851 | .rates = FSLSSI_I2S_RATES, |
649 | .formats = FSLSSI_I2S_FORMATS, | 852 | .formats = FSLSSI_I2S_FORMATS, |
650 | }, | 853 | }, |
651 | .capture = { | 854 | .capture = { |
652 | .channels_min = 2, | 855 | .channels_min = 1, |
653 | .channels_max = 2, | 856 | .channels_max = 2, |
654 | .rates = FSLSSI_I2S_RATES, | 857 | .rates = FSLSSI_I2S_RATES, |
655 | .formats = FSLSSI_I2S_FORMATS, | 858 | .formats = FSLSSI_I2S_FORMATS, |
@@ -710,7 +913,6 @@ static int fsl_ssi_ac97_trigger(struct snd_pcm_substream *substream, int cmd, | |||
710 | 913 | ||
711 | static const struct snd_soc_dai_ops fsl_ssi_ac97_dai_ops = { | 914 | static const struct snd_soc_dai_ops fsl_ssi_ac97_dai_ops = { |
712 | .startup = fsl_ssi_startup, | 915 | .startup = fsl_ssi_startup, |
713 | .shutdown = fsl_ssi_shutdown, | ||
714 | .trigger = fsl_ssi_ac97_trigger, | 916 | .trigger = fsl_ssi_ac97_trigger, |
715 | }; | 917 | }; |
716 | 918 | ||
@@ -935,8 +1137,11 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
935 | } | 1137 | } |
936 | 1138 | ||
937 | /* Are the RX and the TX clocks locked? */ | 1139 | /* Are the RX and the TX clocks locked? */ |
938 | if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) | 1140 | if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) { |
939 | ssi_private->cpu_dai_drv.symmetric_rates = 1; | 1141 | ssi_private->cpu_dai_drv.symmetric_rates = 1; |
1142 | ssi_private->cpu_dai_drv.symmetric_channels = 1; | ||
1143 | ssi_private->cpu_dai_drv.symmetric_samplebits = 1; | ||
1144 | } | ||
940 | 1145 | ||
941 | /* Determine the FIFO depth. */ | 1146 | /* Determine the FIFO depth. */ |
942 | iprop = of_get_property(np, "fsl,fifo-depth", NULL); | 1147 | iprop = of_get_property(np, "fsl,fifo-depth", NULL); |
@@ -946,6 +1151,9 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
946 | /* Older 8610 DTs didn't have the fifo-depth property */ | 1151 | /* Older 8610 DTs didn't have the fifo-depth property */ |
947 | ssi_private->fifo_depth = 8; | 1152 | ssi_private->fifo_depth = 8; |
948 | 1153 | ||
1154 | ssi_private->baudclk_locked = false; | ||
1155 | spin_lock_init(&ssi_private->baudclk_lock); | ||
1156 | |||
949 | if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx21-ssi")) { | 1157 | if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx21-ssi")) { |
950 | u32 dma_events[2]; | 1158 | u32 dma_events[2]; |
951 | ssi_private->ssi_on_imx = true; | 1159 | ssi_private->ssi_on_imx = true; |
@@ -963,6 +1171,15 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
963 | goto error_irqmap; | 1171 | goto error_irqmap; |
964 | } | 1172 | } |
965 | 1173 | ||
1174 | /* For those SLAVE implementations, we ingore non-baudclk cases | ||
1175 | * and, instead, abandon MASTER mode that needs baud clock. | ||
1176 | */ | ||
1177 | ssi_private->baudclk = devm_clk_get(&pdev->dev, "baud"); | ||
1178 | if (IS_ERR(ssi_private->baudclk)) | ||
1179 | dev_warn(&pdev->dev, "could not get baud clock: %d\n", ret); | ||
1180 | else | ||
1181 | clk_prepare_enable(ssi_private->baudclk); | ||
1182 | |||
966 | /* | 1183 | /* |
967 | * We have burstsize be "fifo_depth - 2" to match the SSI | 1184 | * We have burstsize be "fifo_depth - 2" to match the SSI |
968 | * watermark setting in fsl_ssi_startup(). | 1185 | * watermark setting in fsl_ssi_startup(). |
@@ -1102,16 +1319,17 @@ done: | |||
1102 | return 0; | 1319 | return 0; |
1103 | 1320 | ||
1104 | error_dai: | 1321 | error_dai: |
1105 | if (ssi_private->ssi_on_imx) | ||
1106 | imx_pcm_dma_exit(pdev); | ||
1107 | snd_soc_unregister_component(&pdev->dev); | 1322 | snd_soc_unregister_component(&pdev->dev); |
1108 | 1323 | ||
1109 | error_dev: | 1324 | error_dev: |
1110 | device_remove_file(&pdev->dev, dev_attr); | 1325 | device_remove_file(&pdev->dev, dev_attr); |
1111 | 1326 | ||
1112 | error_clk: | 1327 | error_clk: |
1113 | if (ssi_private->ssi_on_imx) | 1328 | if (ssi_private->ssi_on_imx) { |
1329 | if (!IS_ERR(ssi_private->baudclk)) | ||
1330 | clk_disable_unprepare(ssi_private->baudclk); | ||
1114 | clk_disable_unprepare(ssi_private->clk); | 1331 | clk_disable_unprepare(ssi_private->clk); |
1332 | } | ||
1115 | 1333 | ||
1116 | error_irqmap: | 1334 | error_irqmap: |
1117 | irq_dispose_mapping(ssi_private->irq); | 1335 | irq_dispose_mapping(ssi_private->irq); |
@@ -1125,12 +1343,13 @@ static int fsl_ssi_remove(struct platform_device *pdev) | |||
1125 | 1343 | ||
1126 | if (!ssi_private->new_binding) | 1344 | if (!ssi_private->new_binding) |
1127 | platform_device_unregister(ssi_private->pdev); | 1345 | platform_device_unregister(ssi_private->pdev); |
1128 | if (ssi_private->ssi_on_imx) | ||
1129 | imx_pcm_dma_exit(pdev); | ||
1130 | snd_soc_unregister_component(&pdev->dev); | 1346 | snd_soc_unregister_component(&pdev->dev); |
1131 | device_remove_file(&pdev->dev, &ssi_private->dev_attr); | 1347 | device_remove_file(&pdev->dev, &ssi_private->dev_attr); |
1132 | if (ssi_private->ssi_on_imx) | 1348 | if (ssi_private->ssi_on_imx) { |
1349 | if (!IS_ERR(ssi_private->baudclk)) | ||
1350 | clk_disable_unprepare(ssi_private->baudclk); | ||
1133 | clk_disable_unprepare(ssi_private->clk); | 1351 | clk_disable_unprepare(ssi_private->clk); |
1352 | } | ||
1134 | irq_dispose_mapping(ssi_private->irq); | 1353 | irq_dispose_mapping(ssi_private->irq); |
1135 | 1354 | ||
1136 | return 0; | 1355 | return 0; |
diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h index e6b9a69e2a68..e6b63240a3d7 100644 --- a/sound/soc/fsl/fsl_ssi.h +++ b/sound/soc/fsl/fsl_ssi.h | |||
@@ -125,7 +125,9 @@ struct ccsr_ssi { | |||
125 | #define CCSR_SSI_SRCR_REFS 0x00000001 | 125 | #define CCSR_SSI_SRCR_REFS 0x00000001 |
126 | 126 | ||
127 | /* STCCR and SRCCR */ | 127 | /* STCCR and SRCCR */ |
128 | #define CCSR_SSI_SxCCR_DIV2_SHIFT 18 | ||
128 | #define CCSR_SSI_SxCCR_DIV2 0x00040000 | 129 | #define CCSR_SSI_SxCCR_DIV2 0x00040000 |
130 | #define CCSR_SSI_SxCCR_PSR_SHIFT 17 | ||
129 | #define CCSR_SSI_SxCCR_PSR 0x00020000 | 131 | #define CCSR_SSI_SxCCR_PSR 0x00020000 |
130 | #define CCSR_SSI_SxCCR_WL_SHIFT 13 | 132 | #define CCSR_SSI_SxCCR_WL_SHIFT 13 |
131 | #define CCSR_SSI_SxCCR_WL_MASK 0x0001E000 | 133 | #define CCSR_SSI_SxCCR_WL_MASK 0x0001E000 |
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index aee23077080a..c5e47f866b4b 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c | |||
@@ -61,16 +61,11 @@ static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = { | |||
61 | 61 | ||
62 | int imx_pcm_dma_init(struct platform_device *pdev) | 62 | int imx_pcm_dma_init(struct platform_device *pdev) |
63 | { | 63 | { |
64 | return snd_dmaengine_pcm_register(&pdev->dev, &imx_dmaengine_pcm_config, | 64 | return devm_snd_dmaengine_pcm_register(&pdev->dev, |
65 | &imx_dmaengine_pcm_config, | ||
65 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | | 66 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | |
66 | SND_DMAENGINE_PCM_FLAG_COMPAT); | 67 | SND_DMAENGINE_PCM_FLAG_COMPAT); |
67 | } | 68 | } |
68 | EXPORT_SYMBOL_GPL(imx_pcm_dma_init); | 69 | EXPORT_SYMBOL_GPL(imx_pcm_dma_init); |
69 | 70 | ||
70 | void imx_pcm_dma_exit(struct platform_device *pdev) | ||
71 | { | ||
72 | snd_dmaengine_pcm_unregister(&pdev->dev); | ||
73 | } | ||
74 | EXPORT_SYMBOL_GPL(imx_pcm_dma_exit); | ||
75 | |||
76 | MODULE_LICENSE("GPL"); | 71 | MODULE_LICENSE("GPL"); |
diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h index 5d5b73303e11..c79cb27473be 100644 --- a/sound/soc/fsl/imx-pcm.h +++ b/sound/soc/fsl/imx-pcm.h | |||
@@ -40,16 +40,11 @@ struct imx_pcm_fiq_params { | |||
40 | 40 | ||
41 | #if IS_ENABLED(CONFIG_SND_SOC_IMX_PCM_DMA) | 41 | #if IS_ENABLED(CONFIG_SND_SOC_IMX_PCM_DMA) |
42 | int imx_pcm_dma_init(struct platform_device *pdev); | 42 | int imx_pcm_dma_init(struct platform_device *pdev); |
43 | void imx_pcm_dma_exit(struct platform_device *pdev); | ||
44 | #else | 43 | #else |
45 | static inline int imx_pcm_dma_init(struct platform_device *pdev) | 44 | static inline int imx_pcm_dma_init(struct platform_device *pdev) |
46 | { | 45 | { |
47 | return -ENODEV; | 46 | return -ENODEV; |
48 | } | 47 | } |
49 | |||
50 | static inline void imx_pcm_dma_exit(struct platform_device *pdev) | ||
51 | { | ||
52 | } | ||
53 | #endif | 48 | #endif |
54 | 49 | ||
55 | #if IS_ENABLED(CONFIG_SND_SOC_IMX_PCM_FIQ) | 50 | #if IS_ENABLED(CONFIG_SND_SOC_IMX_PCM_FIQ) |
diff --git a/sound/soc/fsl/imx-spdif.c b/sound/soc/fsl/imx-spdif.c index 8499d5292f08..e1dc40143600 100644 --- a/sound/soc/fsl/imx-spdif.c +++ b/sound/soc/fsl/imx-spdif.c | |||
@@ -14,17 +14,15 @@ | |||
14 | #include <sound/soc.h> | 14 | #include <sound/soc.h> |
15 | 15 | ||
16 | struct imx_spdif_data { | 16 | struct imx_spdif_data { |
17 | struct snd_soc_dai_link dai[2]; | 17 | struct snd_soc_dai_link dai; |
18 | struct snd_soc_card card; | 18 | struct snd_soc_card card; |
19 | struct platform_device *txdev; | ||
20 | struct platform_device *rxdev; | ||
21 | }; | 19 | }; |
22 | 20 | ||
23 | static int imx_spdif_audio_probe(struct platform_device *pdev) | 21 | static int imx_spdif_audio_probe(struct platform_device *pdev) |
24 | { | 22 | { |
25 | struct device_node *spdif_np, *np = pdev->dev.of_node; | 23 | struct device_node *spdif_np, *np = pdev->dev.of_node; |
26 | struct imx_spdif_data *data; | 24 | struct imx_spdif_data *data; |
27 | int ret = 0, num_links = 0; | 25 | int ret = 0; |
28 | 26 | ||
29 | spdif_np = of_parse_phandle(np, "spdif-controller", 0); | 27 | spdif_np = of_parse_phandle(np, "spdif-controller", 0); |
30 | if (!spdif_np) { | 28 | if (!spdif_np) { |
@@ -35,74 +33,46 @@ static int imx_spdif_audio_probe(struct platform_device *pdev) | |||
35 | 33 | ||
36 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | 34 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); |
37 | if (!data) { | 35 | if (!data) { |
38 | dev_err(&pdev->dev, "failed to allocate memory\n"); | ||
39 | ret = -ENOMEM; | 36 | ret = -ENOMEM; |
40 | goto end; | 37 | goto end; |
41 | } | 38 | } |
42 | 39 | ||
43 | if (of_property_read_bool(np, "spdif-out")) { | 40 | data->dai.name = "S/PDIF PCM"; |
44 | data->dai[num_links].name = "S/PDIF TX"; | 41 | data->dai.stream_name = "S/PDIF PCM"; |
45 | data->dai[num_links].stream_name = "S/PDIF PCM Playback"; | 42 | data->dai.codec_dai_name = "snd-soc-dummy-dai"; |
46 | data->dai[num_links].codec_dai_name = "dit-hifi"; | 43 | data->dai.codec_name = "snd-soc-dummy"; |
47 | data->dai[num_links].codec_name = "spdif-dit"; | 44 | data->dai.cpu_of_node = spdif_np; |
48 | data->dai[num_links].cpu_of_node = spdif_np; | 45 | data->dai.platform_of_node = spdif_np; |
49 | data->dai[num_links].platform_of_node = spdif_np; | 46 | data->dai.playback_only = true; |
50 | num_links++; | 47 | data->dai.capture_only = true; |
51 | |||
52 | data->txdev = platform_device_register_simple("spdif-dit", -1, NULL, 0); | ||
53 | if (IS_ERR(data->txdev)) { | ||
54 | ret = PTR_ERR(data->txdev); | ||
55 | dev_err(&pdev->dev, "register dit failed: %d\n", ret); | ||
56 | goto end; | ||
57 | } | ||
58 | } | ||
59 | 48 | ||
60 | if (of_property_read_bool(np, "spdif-in")) { | 49 | if (of_property_read_bool(np, "spdif-out")) |
61 | data->dai[num_links].name = "S/PDIF RX"; | 50 | data->dai.capture_only = false; |
62 | data->dai[num_links].stream_name = "S/PDIF PCM Capture"; | 51 | |
63 | data->dai[num_links].codec_dai_name = "dir-hifi"; | 52 | if (of_property_read_bool(np, "spdif-in")) |
64 | data->dai[num_links].codec_name = "spdif-dir"; | 53 | data->dai.playback_only = false; |
65 | data->dai[num_links].cpu_of_node = spdif_np; | ||
66 | data->dai[num_links].platform_of_node = spdif_np; | ||
67 | num_links++; | ||
68 | |||
69 | data->rxdev = platform_device_register_simple("spdif-dir", -1, NULL, 0); | ||
70 | if (IS_ERR(data->rxdev)) { | ||
71 | ret = PTR_ERR(data->rxdev); | ||
72 | dev_err(&pdev->dev, "register dir failed: %d\n", ret); | ||
73 | goto error_dit; | ||
74 | } | ||
75 | } | ||
76 | 54 | ||
77 | if (!num_links) { | 55 | if (data->dai.playback_only && data->dai.capture_only) { |
78 | dev_err(&pdev->dev, "no enabled S/PDIF DAI link\n"); | 56 | dev_err(&pdev->dev, "no enabled S/PDIF DAI link\n"); |
79 | goto error_dir; | 57 | goto end; |
80 | } | 58 | } |
81 | 59 | ||
82 | data->card.dev = &pdev->dev; | 60 | data->card.dev = &pdev->dev; |
83 | data->card.num_links = num_links; | 61 | data->card.dai_link = &data->dai; |
84 | data->card.dai_link = data->dai; | 62 | data->card.num_links = 1; |
85 | 63 | ||
86 | ret = snd_soc_of_parse_card_name(&data->card, "model"); | 64 | ret = snd_soc_of_parse_card_name(&data->card, "model"); |
87 | if (ret) | 65 | if (ret) |
88 | goto error_dir; | 66 | goto end; |
89 | 67 | ||
90 | ret = devm_snd_soc_register_card(&pdev->dev, &data->card); | 68 | ret = devm_snd_soc_register_card(&pdev->dev, &data->card); |
91 | if (ret) { | 69 | if (ret) { |
92 | dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret); | 70 | dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret); |
93 | goto error_dir; | 71 | goto end; |
94 | } | 72 | } |
95 | 73 | ||
96 | platform_set_drvdata(pdev, data); | 74 | platform_set_drvdata(pdev, data); |
97 | 75 | ||
98 | goto end; | ||
99 | |||
100 | error_dir: | ||
101 | if (data->rxdev) | ||
102 | platform_device_unregister(data->rxdev); | ||
103 | error_dit: | ||
104 | if (data->txdev) | ||
105 | platform_device_unregister(data->txdev); | ||
106 | end: | 76 | end: |
107 | if (spdif_np) | 77 | if (spdif_np) |
108 | of_node_put(spdif_np); | 78 | of_node_put(spdif_np); |
@@ -110,18 +80,6 @@ end: | |||
110 | return ret; | 80 | return ret; |
111 | } | 81 | } |
112 | 82 | ||
113 | static int imx_spdif_audio_remove(struct platform_device *pdev) | ||
114 | { | ||
115 | struct imx_spdif_data *data = platform_get_drvdata(pdev); | ||
116 | |||
117 | if (data->rxdev) | ||
118 | platform_device_unregister(data->rxdev); | ||
119 | if (data->txdev) | ||
120 | platform_device_unregister(data->txdev); | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | static const struct of_device_id imx_spdif_dt_ids[] = { | 83 | static const struct of_device_id imx_spdif_dt_ids[] = { |
126 | { .compatible = "fsl,imx-audio-spdif", }, | 84 | { .compatible = "fsl,imx-audio-spdif", }, |
127 | { /* sentinel */ } | 85 | { /* sentinel */ } |
@@ -135,7 +93,6 @@ static struct platform_driver imx_spdif_driver = { | |||
135 | .of_match_table = imx_spdif_dt_ids, | 93 | .of_match_table = imx_spdif_dt_ids, |
136 | }, | 94 | }, |
137 | .probe = imx_spdif_audio_probe, | 95 | .probe = imx_spdif_audio_probe, |
138 | .remove = imx_spdif_audio_remove, | ||
139 | }; | 96 | }; |
140 | 97 | ||
141 | module_platform_driver(imx_spdif_driver); | 98 | module_platform_driver(imx_spdif_driver); |
diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index f5f248c91c16..df552fa1aa65 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c | |||
@@ -304,8 +304,7 @@ static int imx_ssi_trigger(struct snd_pcm_substream *substream, int cmd, | |||
304 | scr |= SSI_SCR_RE; | 304 | scr |= SSI_SCR_RE; |
305 | sier |= sier_bits; | 305 | sier |= sier_bits; |
306 | 306 | ||
307 | if (++ssi->enabled == 1) | 307 | scr |= SSI_SCR_SSIEN; |
308 | scr |= SSI_SCR_SSIEN; | ||
309 | 308 | ||
310 | break; | 309 | break; |
311 | 310 | ||
@@ -318,7 +317,7 @@ static int imx_ssi_trigger(struct snd_pcm_substream *substream, int cmd, | |||
318 | scr &= ~SSI_SCR_RE; | 317 | scr &= ~SSI_SCR_RE; |
319 | sier &= ~sier_bits; | 318 | sier &= ~sier_bits; |
320 | 319 | ||
321 | if (--ssi->enabled == 0) | 320 | if (!(scr & (SSI_SCR_TE | SSI_SCR_RE))) |
322 | scr &= ~SSI_SCR_SSIEN; | 321 | scr &= ~SSI_SCR_SSIEN; |
323 | 322 | ||
324 | break; | 323 | break; |
@@ -536,7 +535,9 @@ static int imx_ssi_probe(struct platform_device *pdev) | |||
536 | ret); | 535 | ret); |
537 | goto failed_clk; | 536 | goto failed_clk; |
538 | } | 537 | } |
539 | clk_prepare_enable(ssi->clk); | 538 | ret = clk_prepare_enable(ssi->clk); |
539 | if (ret) | ||
540 | goto failed_clk; | ||
540 | 541 | ||
541 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 542 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
542 | ssi->base = devm_ioremap_resource(&pdev->dev, res); | 543 | ssi->base = devm_ioremap_resource(&pdev->dev, res); |
@@ -624,9 +625,6 @@ static int imx_ssi_remove(struct platform_device *pdev) | |||
624 | { | 625 | { |
625 | struct imx_ssi *ssi = platform_get_drvdata(pdev); | 626 | struct imx_ssi *ssi = platform_get_drvdata(pdev); |
626 | 627 | ||
627 | if (!ssi->dma_init) | ||
628 | imx_pcm_dma_exit(pdev); | ||
629 | |||
630 | if (!ssi->fiq_init) | 628 | if (!ssi->fiq_init) |
631 | imx_pcm_fiq_exit(pdev); | 629 | imx_pcm_fiq_exit(pdev); |
632 | 630 | ||
diff --git a/sound/soc/fsl/imx-ssi.h b/sound/soc/fsl/imx-ssi.h index 560c40fc9ebb..be6562365b6a 100644 --- a/sound/soc/fsl/imx-ssi.h +++ b/sound/soc/fsl/imx-ssi.h | |||
@@ -213,7 +213,6 @@ struct imx_ssi { | |||
213 | 213 | ||
214 | int fiq_init; | 214 | int fiq_init; |
215 | int dma_init; | 215 | int dma_init; |
216 | int enabled; | ||
217 | }; | 216 | }; |
218 | 217 | ||
219 | #endif /* _IMX_SSI_H */ | 218 | #endif /* _IMX_SSI_H */ |
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index b2fbb7075a6c..c0d928138c88 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
@@ -8,7 +8,8 @@ | |||
8 | * it under the terms of the GNU General Public License version 2 as | 8 | * it under the terms of the GNU General Public License version 2 as |
9 | * published by the Free Software Foundation. | 9 | * published by the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | #include <linux/clk.h> | |
12 | #include <linux/of.h> | ||
12 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
13 | #include <linux/module.h> | 14 | #include <linux/module.h> |
14 | #include <sound/simple_card.h> | 15 | #include <sound/simple_card.h> |
@@ -24,7 +25,7 @@ static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, | |||
24 | 25 | ||
25 | daifmt |= set->fmt; | 26 | daifmt |= set->fmt; |
26 | 27 | ||
27 | if (!ret && daifmt) | 28 | if (daifmt) |
28 | ret = snd_soc_dai_set_fmt(dai, daifmt); | 29 | ret = snd_soc_dai_set_fmt(dai, daifmt); |
29 | 30 | ||
30 | if (ret == -ENOTSUPP) { | 31 | if (ret == -ENOTSUPP) { |
@@ -57,11 +58,170 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) | |||
57 | return 0; | 58 | return 0; |
58 | } | 59 | } |
59 | 60 | ||
61 | static int | ||
62 | asoc_simple_card_sub_parse_of(struct device_node *np, | ||
63 | struct asoc_simple_dai *dai, | ||
64 | struct device_node **node) | ||
65 | { | ||
66 | struct clk *clk; | ||
67 | int ret; | ||
68 | |||
69 | /* | ||
70 | * get node via "sound-dai = <&phandle port>" | ||
71 | * it will be used as xxx_of_node on soc_bind_dai_link() | ||
72 | */ | ||
73 | *node = of_parse_phandle(np, "sound-dai", 0); | ||
74 | if (!*node) | ||
75 | return -ENODEV; | ||
76 | |||
77 | /* get dai->name */ | ||
78 | ret = snd_soc_of_get_dai_name(np, &dai->name); | ||
79 | if (ret < 0) | ||
80 | goto parse_error; | ||
81 | |||
82 | /* | ||
83 | * bitclock-inversion, frame-inversion | ||
84 | * bitclock-master, frame-master | ||
85 | * and specific "format" if it has | ||
86 | */ | ||
87 | dai->fmt = snd_soc_of_parse_daifmt(np, NULL); | ||
88 | |||
89 | /* | ||
90 | * dai->sysclk come from | ||
91 | * "clocks = <&xxx>" (if system has common clock) | ||
92 | * or "system-clock-frequency = <xxx>" | ||
93 | * or device's module clock. | ||
94 | */ | ||
95 | if (of_property_read_bool(np, "clocks")) { | ||
96 | clk = of_clk_get(np, 0); | ||
97 | if (IS_ERR(clk)) { | ||
98 | ret = PTR_ERR(clk); | ||
99 | goto parse_error; | ||
100 | } | ||
101 | |||
102 | dai->sysclk = clk_get_rate(clk); | ||
103 | } else if (of_property_read_bool(np, "system-clock-frequency")) { | ||
104 | of_property_read_u32(np, | ||
105 | "system-clock-frequency", | ||
106 | &dai->sysclk); | ||
107 | } else { | ||
108 | clk = of_clk_get(*node, 0); | ||
109 | if (IS_ERR(clk)) { | ||
110 | ret = PTR_ERR(clk); | ||
111 | goto parse_error; | ||
112 | } | ||
113 | |||
114 | dai->sysclk = clk_get_rate(clk); | ||
115 | } | ||
116 | |||
117 | ret = 0; | ||
118 | |||
119 | parse_error: | ||
120 | of_node_put(*node); | ||
121 | |||
122 | return ret; | ||
123 | } | ||
124 | |||
125 | static int asoc_simple_card_parse_of(struct device_node *node, | ||
126 | struct asoc_simple_card_info *info, | ||
127 | struct device *dev, | ||
128 | struct device_node **of_cpu, | ||
129 | struct device_node **of_codec, | ||
130 | struct device_node **of_platform) | ||
131 | { | ||
132 | struct device_node *np; | ||
133 | char *name; | ||
134 | int ret; | ||
135 | |||
136 | /* get CPU/CODEC common format via simple-audio-card,format */ | ||
137 | info->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") & | ||
138 | (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK); | ||
139 | |||
140 | /* DAPM routes */ | ||
141 | ret = snd_soc_of_parse_audio_routing(&info->snd_card, | ||
142 | "simple-audio-routing"); | ||
143 | if (ret) | ||
144 | return ret; | ||
145 | |||
146 | /* CPU sub-node */ | ||
147 | ret = -EINVAL; | ||
148 | np = of_get_child_by_name(node, "simple-audio-card,cpu"); | ||
149 | if (np) | ||
150 | ret = asoc_simple_card_sub_parse_of(np, | ||
151 | &info->cpu_dai, | ||
152 | of_cpu); | ||
153 | if (ret < 0) | ||
154 | return ret; | ||
155 | |||
156 | /* CODEC sub-node */ | ||
157 | ret = -EINVAL; | ||
158 | np = of_get_child_by_name(node, "simple-audio-card,codec"); | ||
159 | if (np) | ||
160 | ret = asoc_simple_card_sub_parse_of(np, | ||
161 | &info->codec_dai, | ||
162 | of_codec); | ||
163 | if (ret < 0) | ||
164 | return ret; | ||
165 | |||
166 | if (!info->cpu_dai.name || !info->codec_dai.name) | ||
167 | return -EINVAL; | ||
168 | |||
169 | /* card name is created from CPU/CODEC dai name */ | ||
170 | name = devm_kzalloc(dev, | ||
171 | strlen(info->cpu_dai.name) + | ||
172 | strlen(info->codec_dai.name) + 2, | ||
173 | GFP_KERNEL); | ||
174 | sprintf(name, "%s-%s", info->cpu_dai.name, info->codec_dai.name); | ||
175 | info->name = info->card = name; | ||
176 | |||
177 | /* simple-card assumes platform == cpu */ | ||
178 | *of_platform = *of_cpu; | ||
179 | |||
180 | dev_dbg(dev, "card-name : %s\n", info->card); | ||
181 | dev_dbg(dev, "platform : %04x\n", info->daifmt); | ||
182 | dev_dbg(dev, "cpu : %s / %04x / %d\n", | ||
183 | info->cpu_dai.name, | ||
184 | info->cpu_dai.fmt, | ||
185 | info->cpu_dai.sysclk); | ||
186 | dev_dbg(dev, "codec : %s / %04x / %d\n", | ||
187 | info->codec_dai.name, | ||
188 | info->codec_dai.fmt, | ||
189 | info->codec_dai.sysclk); | ||
190 | |||
191 | return 0; | ||
192 | } | ||
193 | |||
60 | static int asoc_simple_card_probe(struct platform_device *pdev) | 194 | static int asoc_simple_card_probe(struct platform_device *pdev) |
61 | { | 195 | { |
62 | struct asoc_simple_card_info *cinfo = pdev->dev.platform_data; | 196 | struct asoc_simple_card_info *cinfo; |
197 | struct device_node *np = pdev->dev.of_node; | ||
198 | struct device_node *of_cpu, *of_codec, *of_platform; | ||
63 | struct device *dev = &pdev->dev; | 199 | struct device *dev = &pdev->dev; |
64 | 200 | ||
201 | cinfo = NULL; | ||
202 | of_cpu = NULL; | ||
203 | of_codec = NULL; | ||
204 | of_platform = NULL; | ||
205 | if (np && of_device_is_available(np)) { | ||
206 | cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL); | ||
207 | if (cinfo) { | ||
208 | int ret; | ||
209 | cinfo->snd_card.dev = &pdev->dev; | ||
210 | ret = asoc_simple_card_parse_of(np, cinfo, dev, | ||
211 | &of_cpu, | ||
212 | &of_codec, | ||
213 | &of_platform); | ||
214 | if (ret < 0) { | ||
215 | if (ret != -EPROBE_DEFER) | ||
216 | dev_err(dev, "parse error %d\n", ret); | ||
217 | return ret; | ||
218 | } | ||
219 | } | ||
220 | } else { | ||
221 | cinfo->snd_card.dev = &pdev->dev; | ||
222 | cinfo = pdev->dev.platform_data; | ||
223 | } | ||
224 | |||
65 | if (!cinfo) { | 225 | if (!cinfo) { |
66 | dev_err(dev, "no info for asoc-simple-card\n"); | 226 | dev_err(dev, "no info for asoc-simple-card\n"); |
67 | return -EINVAL; | 227 | return -EINVAL; |
@@ -69,10 +229,10 @@ static int asoc_simple_card_probe(struct platform_device *pdev) | |||
69 | 229 | ||
70 | if (!cinfo->name || | 230 | if (!cinfo->name || |
71 | !cinfo->card || | 231 | !cinfo->card || |
72 | !cinfo->codec || | 232 | !cinfo->codec_dai.name || |
73 | !cinfo->platform || | 233 | !(cinfo->codec || of_codec) || |
74 | !cinfo->cpu_dai.name || | 234 | !(cinfo->platform || of_platform) || |
75 | !cinfo->codec_dai.name) { | 235 | !(cinfo->cpu_dai.name || of_cpu)) { |
76 | dev_err(dev, "insufficient asoc_simple_card_info settings\n"); | 236 | dev_err(dev, "insufficient asoc_simple_card_info settings\n"); |
77 | return -EINVAL; | 237 | return -EINVAL; |
78 | } | 238 | } |
@@ -86,6 +246,9 @@ static int asoc_simple_card_probe(struct platform_device *pdev) | |||
86 | cinfo->snd_link.platform_name = cinfo->platform; | 246 | cinfo->snd_link.platform_name = cinfo->platform; |
87 | cinfo->snd_link.codec_name = cinfo->codec; | 247 | cinfo->snd_link.codec_name = cinfo->codec; |
88 | cinfo->snd_link.codec_dai_name = cinfo->codec_dai.name; | 248 | cinfo->snd_link.codec_dai_name = cinfo->codec_dai.name; |
249 | cinfo->snd_link.cpu_of_node = of_cpu; | ||
250 | cinfo->snd_link.codec_of_node = of_codec; | ||
251 | cinfo->snd_link.platform_of_node = of_platform; | ||
89 | cinfo->snd_link.init = asoc_simple_card_dai_init; | 252 | cinfo->snd_link.init = asoc_simple_card_dai_init; |
90 | 253 | ||
91 | /* | 254 | /* |
@@ -95,25 +258,23 @@ static int asoc_simple_card_probe(struct platform_device *pdev) | |||
95 | cinfo->snd_card.owner = THIS_MODULE; | 258 | cinfo->snd_card.owner = THIS_MODULE; |
96 | cinfo->snd_card.dai_link = &cinfo->snd_link; | 259 | cinfo->snd_card.dai_link = &cinfo->snd_link; |
97 | cinfo->snd_card.num_links = 1; | 260 | cinfo->snd_card.num_links = 1; |
98 | cinfo->snd_card.dev = &pdev->dev; | ||
99 | 261 | ||
100 | return snd_soc_register_card(&cinfo->snd_card); | 262 | return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card); |
101 | } | 263 | } |
102 | 264 | ||
103 | static int asoc_simple_card_remove(struct platform_device *pdev) | 265 | static const struct of_device_id asoc_simple_of_match[] = { |
104 | { | 266 | { .compatible = "simple-audio-card", }, |
105 | struct asoc_simple_card_info *cinfo = pdev->dev.platform_data; | 267 | {}, |
106 | 268 | }; | |
107 | return snd_soc_unregister_card(&cinfo->snd_card); | 269 | MODULE_DEVICE_TABLE(of, asoc_simple_of_match); |
108 | } | ||
109 | 270 | ||
110 | static struct platform_driver asoc_simple_card = { | 271 | static struct platform_driver asoc_simple_card = { |
111 | .driver = { | 272 | .driver = { |
112 | .name = "asoc-simple-card", | 273 | .name = "asoc-simple-card", |
113 | .owner = THIS_MODULE, | 274 | .owner = THIS_MODULE, |
275 | .of_match_table = asoc_simple_of_match, | ||
114 | }, | 276 | }, |
115 | .probe = asoc_simple_card_probe, | 277 | .probe = asoc_simple_card_probe, |
116 | .remove = asoc_simple_card_remove, | ||
117 | }; | 278 | }; |
118 | 279 | ||
119 | module_platform_driver(asoc_simple_card); | 280 | module_platform_driver(asoc_simple_card); |
diff --git a/sound/soc/mid-x86/Kconfig b/sound/soc/intel/Kconfig index 61c10bf503d2..61c10bf503d2 100644 --- a/sound/soc/mid-x86/Kconfig +++ b/sound/soc/intel/Kconfig | |||
diff --git a/sound/soc/mid-x86/Makefile b/sound/soc/intel/Makefile index 639883339465..639883339465 100644 --- a/sound/soc/mid-x86/Makefile +++ b/sound/soc/intel/Makefile | |||
diff --git a/sound/soc/mid-x86/mfld_machine.c b/sound/soc/intel/mfld_machine.c index d3d4c32434f7..d3d4c32434f7 100644 --- a/sound/soc/mid-x86/mfld_machine.c +++ b/sound/soc/intel/mfld_machine.c | |||
diff --git a/sound/soc/mid-x86/sst_dsp.h b/sound/soc/intel/sst_dsp.h index 0fce1de284ff..0fce1de284ff 100644 --- a/sound/soc/mid-x86/sst_dsp.h +++ b/sound/soc/intel/sst_dsp.h | |||
diff --git a/sound/soc/mid-x86/sst_platform.c b/sound/soc/intel/sst_platform.c index b6b5eb698d33..b6b5eb698d33 100644 --- a/sound/soc/mid-x86/sst_platform.c +++ b/sound/soc/intel/sst_platform.c | |||
diff --git a/sound/soc/mid-x86/sst_platform.h b/sound/soc/intel/sst_platform.h index cacc9066ec52..cacc9066ec52 100644 --- a/sound/soc/mid-x86/sst_platform.h +++ b/sound/soc/intel/sst_platform.h | |||
diff --git a/sound/soc/jz4740/Kconfig b/sound/soc/jz4740/Kconfig index 5351cba66c9e..29f76af5d963 100644 --- a/sound/soc/jz4740/Kconfig +++ b/sound/soc/jz4740/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config SND_JZ4740_SOC | 1 | config SND_JZ4740_SOC |
2 | tristate "SoC Audio for Ingenic JZ4740 SoC" | 2 | tristate "SoC Audio for Ingenic JZ4740 SoC" |
3 | depends on MACH_JZ4740 && SND_SOC | 3 | depends on MACH_JZ4740 && SND_SOC |
4 | select SND_SOC_GENERIC_DMAENGINE_PCM | ||
4 | help | 5 | help |
5 | Say Y or M if you want to add support for codecs attached to | 6 | Say Y or M if you want to add support for codecs attached to |
6 | the JZ4740 I2S interface. You will also need to select the audio | 7 | the JZ4740 I2S interface. You will also need to select the audio |
diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index 4c849a49c72a..8f220009e0f6 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c | |||
@@ -29,9 +29,11 @@ | |||
29 | #include <sound/pcm_params.h> | 29 | #include <sound/pcm_params.h> |
30 | #include <sound/soc.h> | 30 | #include <sound/soc.h> |
31 | #include <sound/initval.h> | 31 | #include <sound/initval.h> |
32 | #include <sound/dmaengine_pcm.h> | ||
33 | |||
34 | #include <asm/mach-jz4740/dma.h> | ||
32 | 35 | ||
33 | #include "jz4740-i2s.h" | 36 | #include "jz4740-i2s.h" |
34 | #include "jz4740-pcm.h" | ||
35 | 37 | ||
36 | #define JZ_REG_AIC_CONF 0x00 | 38 | #define JZ_REG_AIC_CONF 0x00 |
37 | #define JZ_REG_AIC_CTRL 0x04 | 39 | #define JZ_REG_AIC_CTRL 0x04 |
@@ -89,8 +91,8 @@ struct jz4740_i2s { | |||
89 | struct clk *clk_aic; | 91 | struct clk *clk_aic; |
90 | struct clk *clk_i2s; | 92 | struct clk *clk_i2s; |
91 | 93 | ||
92 | struct jz4740_pcm_config pcm_config_playback; | 94 | struct snd_dmaengine_dai_dma_data playback_dma_data; |
93 | struct jz4740_pcm_config pcm_config_capture; | 95 | struct snd_dmaengine_dai_dma_data capture_dma_data; |
94 | }; | 96 | }; |
95 | 97 | ||
96 | static inline uint32_t jz4740_i2s_read(const struct jz4740_i2s *i2s, | 98 | static inline uint32_t jz4740_i2s_read(const struct jz4740_i2s *i2s, |
@@ -233,8 +235,6 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, | |||
233 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | 235 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) |
234 | { | 236 | { |
235 | struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); | 237 | struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); |
236 | enum jz4740_dma_width dma_width; | ||
237 | struct jz4740_pcm_config *pcm_config; | ||
238 | unsigned int sample_size; | 238 | unsigned int sample_size; |
239 | uint32_t ctrl; | 239 | uint32_t ctrl; |
240 | 240 | ||
@@ -243,11 +243,9 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, | |||
243 | switch (params_format(params)) { | 243 | switch (params_format(params)) { |
244 | case SNDRV_PCM_FORMAT_S8: | 244 | case SNDRV_PCM_FORMAT_S8: |
245 | sample_size = 0; | 245 | sample_size = 0; |
246 | dma_width = JZ4740_DMA_WIDTH_8BIT; | ||
247 | break; | 246 | break; |
248 | case SNDRV_PCM_FORMAT_S16: | 247 | case SNDRV_PCM_FORMAT_S16: |
249 | sample_size = 1; | 248 | sample_size = 1; |
250 | dma_width = JZ4740_DMA_WIDTH_16BIT; | ||
251 | break; | 249 | break; |
252 | default: | 250 | default: |
253 | return -EINVAL; | 251 | return -EINVAL; |
@@ -260,22 +258,13 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, | |||
260 | ctrl |= JZ_AIC_CTRL_MONO_TO_STEREO; | 258 | ctrl |= JZ_AIC_CTRL_MONO_TO_STEREO; |
261 | else | 259 | else |
262 | ctrl &= ~JZ_AIC_CTRL_MONO_TO_STEREO; | 260 | ctrl &= ~JZ_AIC_CTRL_MONO_TO_STEREO; |
263 | |||
264 | pcm_config = &i2s->pcm_config_playback; | ||
265 | pcm_config->dma_config.dst_width = dma_width; | ||
266 | |||
267 | } else { | 261 | } else { |
268 | ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK; | 262 | ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK; |
269 | ctrl |= sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET; | 263 | ctrl |= sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET; |
270 | |||
271 | pcm_config = &i2s->pcm_config_capture; | ||
272 | pcm_config->dma_config.src_width = dma_width; | ||
273 | } | 264 | } |
274 | 265 | ||
275 | jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl); | 266 | jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl); |
276 | 267 | ||
277 | snd_soc_dai_set_dma_data(dai, substream, pcm_config); | ||
278 | |||
279 | return 0; | 268 | return 0; |
280 | } | 269 | } |
281 | 270 | ||
@@ -342,25 +331,19 @@ static int jz4740_i2s_resume(struct snd_soc_dai *dai) | |||
342 | 331 | ||
343 | static void jz4740_i2c_init_pcm_config(struct jz4740_i2s *i2s) | 332 | static void jz4740_i2c_init_pcm_config(struct jz4740_i2s *i2s) |
344 | { | 333 | { |
345 | struct jz4740_dma_config *dma_config; | 334 | struct snd_dmaengine_dai_dma_data *dma_data; |
346 | 335 | ||
347 | /* Playback */ | 336 | /* Playback */ |
348 | dma_config = &i2s->pcm_config_playback.dma_config; | 337 | dma_data = &i2s->playback_dma_data; |
349 | dma_config->src_width = JZ4740_DMA_WIDTH_32BIT; | 338 | dma_data->maxburst = 16; |
350 | dma_config->transfer_size = JZ4740_DMA_TRANSFER_SIZE_16BYTE; | 339 | dma_data->slave_id = JZ4740_DMA_TYPE_AIC_TRANSMIT; |
351 | dma_config->request_type = JZ4740_DMA_TYPE_AIC_TRANSMIT; | 340 | dma_data->addr = i2s->phys_base + JZ_REG_AIC_FIFO; |
352 | dma_config->flags = JZ4740_DMA_SRC_AUTOINC; | ||
353 | dma_config->mode = JZ4740_DMA_MODE_SINGLE; | ||
354 | i2s->pcm_config_playback.fifo_addr = i2s->phys_base + JZ_REG_AIC_FIFO; | ||
355 | 341 | ||
356 | /* Capture */ | 342 | /* Capture */ |
357 | dma_config = &i2s->pcm_config_capture.dma_config; | 343 | dma_data = &i2s->capture_dma_data; |
358 | dma_config->dst_width = JZ4740_DMA_WIDTH_32BIT; | 344 | dma_data->maxburst = 16; |
359 | dma_config->transfer_size = JZ4740_DMA_TRANSFER_SIZE_16BYTE; | 345 | dma_data->slave_id = JZ4740_DMA_TYPE_AIC_RECEIVE; |
360 | dma_config->request_type = JZ4740_DMA_TYPE_AIC_RECEIVE; | 346 | dma_data->addr = i2s->phys_base + JZ_REG_AIC_FIFO; |
361 | dma_config->flags = JZ4740_DMA_DST_AUTOINC; | ||
362 | dma_config->mode = JZ4740_DMA_MODE_SINGLE; | ||
363 | i2s->pcm_config_capture.fifo_addr = i2s->phys_base + JZ_REG_AIC_FIFO; | ||
364 | } | 347 | } |
365 | 348 | ||
366 | static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) | 349 | static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) |
@@ -371,6 +354,8 @@ static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) | |||
371 | clk_prepare_enable(i2s->clk_aic); | 354 | clk_prepare_enable(i2s->clk_aic); |
372 | 355 | ||
373 | jz4740_i2c_init_pcm_config(i2s); | 356 | jz4740_i2c_init_pcm_config(i2s); |
357 | snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data, | ||
358 | &i2s->capture_dma_data); | ||
374 | 359 | ||
375 | conf = (7 << JZ_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET) | | 360 | conf = (7 << JZ_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET) | |
376 | (8 << JZ_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET) | | 361 | (8 << JZ_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET) | |
@@ -432,91 +417,41 @@ static const struct snd_soc_component_driver jz4740_i2s_component = { | |||
432 | static int jz4740_i2s_dev_probe(struct platform_device *pdev) | 417 | static int jz4740_i2s_dev_probe(struct platform_device *pdev) |
433 | { | 418 | { |
434 | struct jz4740_i2s *i2s; | 419 | struct jz4740_i2s *i2s; |
420 | struct resource *mem; | ||
435 | int ret; | 421 | int ret; |
436 | 422 | ||
437 | i2s = kzalloc(sizeof(*i2s), GFP_KERNEL); | 423 | i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); |
438 | |||
439 | if (!i2s) | 424 | if (!i2s) |
440 | return -ENOMEM; | 425 | return -ENOMEM; |
441 | 426 | ||
442 | i2s->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 427 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
443 | if (!i2s->mem) { | 428 | i2s->base = devm_ioremap_resource(&pdev->dev, mem); |
444 | ret = -ENOENT; | 429 | if (IS_ERR(i2s->base)) |
445 | goto err_free; | 430 | return PTR_ERR(i2s->base); |
446 | } | ||
447 | |||
448 | i2s->mem = request_mem_region(i2s->mem->start, resource_size(i2s->mem), | ||
449 | pdev->name); | ||
450 | if (!i2s->mem) { | ||
451 | ret = -EBUSY; | ||
452 | goto err_free; | ||
453 | } | ||
454 | 431 | ||
455 | i2s->base = ioremap_nocache(i2s->mem->start, resource_size(i2s->mem)); | 432 | i2s->phys_base = mem->start; |
456 | if (!i2s->base) { | ||
457 | ret = -EBUSY; | ||
458 | goto err_release_mem_region; | ||
459 | } | ||
460 | 433 | ||
461 | i2s->phys_base = i2s->mem->start; | 434 | i2s->clk_aic = devm_clk_get(&pdev->dev, "aic"); |
435 | if (IS_ERR(i2s->clk_aic)) | ||
436 | return PTR_ERR(i2s->clk_aic); | ||
462 | 437 | ||
463 | i2s->clk_aic = clk_get(&pdev->dev, "aic"); | 438 | i2s->clk_i2s = devm_clk_get(&pdev->dev, "i2s"); |
464 | if (IS_ERR(i2s->clk_aic)) { | 439 | if (IS_ERR(i2s->clk_i2s)) |
465 | ret = PTR_ERR(i2s->clk_aic); | 440 | return PTR_ERR(i2s->clk_i2s); |
466 | goto err_iounmap; | ||
467 | } | ||
468 | |||
469 | i2s->clk_i2s = clk_get(&pdev->dev, "i2s"); | ||
470 | if (IS_ERR(i2s->clk_i2s)) { | ||
471 | ret = PTR_ERR(i2s->clk_i2s); | ||
472 | goto err_clk_put_aic; | ||
473 | } | ||
474 | 441 | ||
475 | platform_set_drvdata(pdev, i2s); | 442 | platform_set_drvdata(pdev, i2s); |
476 | ret = snd_soc_register_component(&pdev->dev, &jz4740_i2s_component, | ||
477 | &jz4740_i2s_dai, 1); | ||
478 | 443 | ||
479 | if (ret) { | 444 | ret = devm_snd_soc_register_component(&pdev->dev, |
480 | dev_err(&pdev->dev, "Failed to register DAI\n"); | 445 | &jz4740_i2s_component, &jz4740_i2s_dai, 1); |
481 | goto err_clk_put_i2s; | 446 | if (ret) |
482 | } | 447 | return ret; |
483 | |||
484 | return 0; | ||
485 | |||
486 | err_clk_put_i2s: | ||
487 | clk_put(i2s->clk_i2s); | ||
488 | err_clk_put_aic: | ||
489 | clk_put(i2s->clk_aic); | ||
490 | err_iounmap: | ||
491 | iounmap(i2s->base); | ||
492 | err_release_mem_region: | ||
493 | release_mem_region(i2s->mem->start, resource_size(i2s->mem)); | ||
494 | err_free: | ||
495 | kfree(i2s); | ||
496 | |||
497 | return ret; | ||
498 | } | ||
499 | 448 | ||
500 | static int jz4740_i2s_dev_remove(struct platform_device *pdev) | 449 | return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, |
501 | { | 450 | SND_DMAENGINE_PCM_FLAG_COMPAT); |
502 | struct jz4740_i2s *i2s = platform_get_drvdata(pdev); | ||
503 | |||
504 | snd_soc_unregister_component(&pdev->dev); | ||
505 | |||
506 | clk_put(i2s->clk_i2s); | ||
507 | clk_put(i2s->clk_aic); | ||
508 | |||
509 | iounmap(i2s->base); | ||
510 | release_mem_region(i2s->mem->start, resource_size(i2s->mem)); | ||
511 | |||
512 | kfree(i2s); | ||
513 | |||
514 | return 0; | ||
515 | } | 451 | } |
516 | 452 | ||
517 | static struct platform_driver jz4740_i2s_driver = { | 453 | static struct platform_driver jz4740_i2s_driver = { |
518 | .probe = jz4740_i2s_dev_probe, | 454 | .probe = jz4740_i2s_dev_probe, |
519 | .remove = jz4740_i2s_dev_remove, | ||
520 | .driver = { | 455 | .driver = { |
521 | .name = "jz4740-i2s", | 456 | .name = "jz4740-i2s", |
522 | .owner = THIS_MODULE, | 457 | .owner = THIS_MODULE, |
diff --git a/sound/soc/jz4740/jz4740-pcm.c b/sound/soc/jz4740/jz4740-pcm.c deleted file mode 100644 index 1d7ef28585e1..000000000000 --- a/sound/soc/jz4740/jz4740-pcm.c +++ /dev/null | |||
@@ -1,358 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of the GNU General Public License as published by the | ||
6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
7 | * option) any later version. | ||
8 | * | ||
9 | * You should have received a copy of the GNU General Public License along | ||
10 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
11 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/init.h> | ||
16 | #include <linux/interrupt.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/slab.h> | ||
21 | |||
22 | #include <linux/dma-mapping.h> | ||
23 | |||
24 | #include <sound/core.h> | ||
25 | #include <sound/pcm.h> | ||
26 | #include <sound/pcm_params.h> | ||
27 | #include <sound/soc.h> | ||
28 | |||
29 | #include <asm/mach-jz4740/dma.h> | ||
30 | #include "jz4740-pcm.h" | ||
31 | |||
32 | struct jz4740_runtime_data { | ||
33 | unsigned long dma_period; | ||
34 | dma_addr_t dma_start; | ||
35 | dma_addr_t dma_pos; | ||
36 | dma_addr_t dma_end; | ||
37 | |||
38 | struct jz4740_dma_chan *dma; | ||
39 | |||
40 | dma_addr_t fifo_addr; | ||
41 | }; | ||
42 | |||
43 | /* identify hardware playback capabilities */ | ||
44 | static const struct snd_pcm_hardware jz4740_pcm_hardware = { | ||
45 | .info = SNDRV_PCM_INFO_MMAP | | ||
46 | SNDRV_PCM_INFO_MMAP_VALID | | ||
47 | SNDRV_PCM_INFO_INTERLEAVED | | ||
48 | SNDRV_PCM_INFO_BLOCK_TRANSFER, | ||
49 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8, | ||
50 | |||
51 | .rates = SNDRV_PCM_RATE_8000_48000, | ||
52 | .channels_min = 1, | ||
53 | .channels_max = 2, | ||
54 | .period_bytes_min = 16, | ||
55 | .period_bytes_max = 2 * PAGE_SIZE, | ||
56 | .periods_min = 2, | ||
57 | .periods_max = 128, | ||
58 | .buffer_bytes_max = 128 * 2 * PAGE_SIZE, | ||
59 | .fifo_size = 32, | ||
60 | }; | ||
61 | |||
62 | static void jz4740_pcm_start_transfer(struct jz4740_runtime_data *prtd, | ||
63 | struct snd_pcm_substream *substream) | ||
64 | { | ||
65 | unsigned long count; | ||
66 | |||
67 | if (prtd->dma_pos == prtd->dma_end) | ||
68 | prtd->dma_pos = prtd->dma_start; | ||
69 | |||
70 | if (prtd->dma_pos + prtd->dma_period > prtd->dma_end) | ||
71 | count = prtd->dma_end - prtd->dma_pos; | ||
72 | else | ||
73 | count = prtd->dma_period; | ||
74 | |||
75 | jz4740_dma_disable(prtd->dma); | ||
76 | |||
77 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
78 | jz4740_dma_set_src_addr(prtd->dma, prtd->dma_pos); | ||
79 | jz4740_dma_set_dst_addr(prtd->dma, prtd->fifo_addr); | ||
80 | } else { | ||
81 | jz4740_dma_set_src_addr(prtd->dma, prtd->fifo_addr); | ||
82 | jz4740_dma_set_dst_addr(prtd->dma, prtd->dma_pos); | ||
83 | } | ||
84 | |||
85 | jz4740_dma_set_transfer_count(prtd->dma, count); | ||
86 | |||
87 | prtd->dma_pos += count; | ||
88 | |||
89 | jz4740_dma_enable(prtd->dma); | ||
90 | } | ||
91 | |||
92 | static void jz4740_pcm_dma_transfer_done(struct jz4740_dma_chan *dma, int err, | ||
93 | void *dev_id) | ||
94 | { | ||
95 | struct snd_pcm_substream *substream = dev_id; | ||
96 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
97 | struct jz4740_runtime_data *prtd = runtime->private_data; | ||
98 | |||
99 | snd_pcm_period_elapsed(substream); | ||
100 | |||
101 | jz4740_pcm_start_transfer(prtd, substream); | ||
102 | } | ||
103 | |||
104 | static int jz4740_pcm_hw_params(struct snd_pcm_substream *substream, | ||
105 | struct snd_pcm_hw_params *params) | ||
106 | { | ||
107 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
108 | struct jz4740_runtime_data *prtd = runtime->private_data; | ||
109 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
110 | struct jz4740_pcm_config *config; | ||
111 | |||
112 | config = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
113 | |||
114 | if (!config) | ||
115 | return 0; | ||
116 | |||
117 | if (!prtd->dma) { | ||
118 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
119 | prtd->dma = jz4740_dma_request(substream, "PCM Capture"); | ||
120 | else | ||
121 | prtd->dma = jz4740_dma_request(substream, "PCM Playback"); | ||
122 | } | ||
123 | |||
124 | if (!prtd->dma) | ||
125 | return -EBUSY; | ||
126 | |||
127 | jz4740_dma_configure(prtd->dma, &config->dma_config); | ||
128 | prtd->fifo_addr = config->fifo_addr; | ||
129 | |||
130 | jz4740_dma_set_complete_cb(prtd->dma, jz4740_pcm_dma_transfer_done); | ||
131 | |||
132 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); | ||
133 | runtime->dma_bytes = params_buffer_bytes(params); | ||
134 | |||
135 | prtd->dma_period = params_period_bytes(params); | ||
136 | prtd->dma_start = runtime->dma_addr; | ||
137 | prtd->dma_pos = prtd->dma_start; | ||
138 | prtd->dma_end = prtd->dma_start + runtime->dma_bytes; | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static int jz4740_pcm_hw_free(struct snd_pcm_substream *substream) | ||
144 | { | ||
145 | struct jz4740_runtime_data *prtd = substream->runtime->private_data; | ||
146 | |||
147 | snd_pcm_set_runtime_buffer(substream, NULL); | ||
148 | if (prtd->dma) { | ||
149 | jz4740_dma_free(prtd->dma); | ||
150 | prtd->dma = NULL; | ||
151 | } | ||
152 | |||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | static int jz4740_pcm_prepare(struct snd_pcm_substream *substream) | ||
157 | { | ||
158 | struct jz4740_runtime_data *prtd = substream->runtime->private_data; | ||
159 | |||
160 | if (!prtd->dma) | ||
161 | return -EBUSY; | ||
162 | |||
163 | prtd->dma_pos = prtd->dma_start; | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | static int jz4740_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
169 | { | ||
170 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
171 | struct jz4740_runtime_data *prtd = runtime->private_data; | ||
172 | |||
173 | switch (cmd) { | ||
174 | case SNDRV_PCM_TRIGGER_START: | ||
175 | case SNDRV_PCM_TRIGGER_RESUME: | ||
176 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
177 | jz4740_pcm_start_transfer(prtd, substream); | ||
178 | break; | ||
179 | case SNDRV_PCM_TRIGGER_STOP: | ||
180 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
181 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
182 | jz4740_dma_disable(prtd->dma); | ||
183 | break; | ||
184 | default: | ||
185 | break; | ||
186 | } | ||
187 | |||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | static snd_pcm_uframes_t jz4740_pcm_pointer(struct snd_pcm_substream *substream) | ||
192 | { | ||
193 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
194 | struct jz4740_runtime_data *prtd = runtime->private_data; | ||
195 | unsigned long byte_offset; | ||
196 | snd_pcm_uframes_t offset; | ||
197 | struct jz4740_dma_chan *dma = prtd->dma; | ||
198 | |||
199 | /* prtd->dma_pos points to the end of the current transfer. So by | ||
200 | * subtracting prdt->dma_start we get the offset to the end of the | ||
201 | * current period in bytes. By subtracting the residue of the transfer | ||
202 | * we get the current offset in bytes. */ | ||
203 | byte_offset = prtd->dma_pos - prtd->dma_start; | ||
204 | byte_offset -= jz4740_dma_get_residue(dma); | ||
205 | |||
206 | offset = bytes_to_frames(runtime, byte_offset); | ||
207 | if (offset >= runtime->buffer_size) | ||
208 | offset = 0; | ||
209 | |||
210 | return offset; | ||
211 | } | ||
212 | |||
213 | static int jz4740_pcm_open(struct snd_pcm_substream *substream) | ||
214 | { | ||
215 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
216 | struct jz4740_runtime_data *prtd; | ||
217 | |||
218 | prtd = kzalloc(sizeof(*prtd), GFP_KERNEL); | ||
219 | if (prtd == NULL) | ||
220 | return -ENOMEM; | ||
221 | |||
222 | snd_soc_set_runtime_hwparams(substream, &jz4740_pcm_hardware); | ||
223 | |||
224 | runtime->private_data = prtd; | ||
225 | |||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | static int jz4740_pcm_close(struct snd_pcm_substream *substream) | ||
230 | { | ||
231 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
232 | struct jz4740_runtime_data *prtd = runtime->private_data; | ||
233 | |||
234 | kfree(prtd); | ||
235 | |||
236 | return 0; | ||
237 | } | ||
238 | |||
239 | static int jz4740_pcm_mmap(struct snd_pcm_substream *substream, | ||
240 | struct vm_area_struct *vma) | ||
241 | { | ||
242 | return remap_pfn_range(vma, vma->vm_start, | ||
243 | substream->dma_buffer.addr >> PAGE_SHIFT, | ||
244 | vma->vm_end - vma->vm_start, vma->vm_page_prot); | ||
245 | } | ||
246 | |||
247 | static struct snd_pcm_ops jz4740_pcm_ops = { | ||
248 | .open = jz4740_pcm_open, | ||
249 | .close = jz4740_pcm_close, | ||
250 | .ioctl = snd_pcm_lib_ioctl, | ||
251 | .hw_params = jz4740_pcm_hw_params, | ||
252 | .hw_free = jz4740_pcm_hw_free, | ||
253 | .prepare = jz4740_pcm_prepare, | ||
254 | .trigger = jz4740_pcm_trigger, | ||
255 | .pointer = jz4740_pcm_pointer, | ||
256 | .mmap = jz4740_pcm_mmap, | ||
257 | }; | ||
258 | |||
259 | static int jz4740_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | ||
260 | { | ||
261 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | ||
262 | struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
263 | size_t size = jz4740_pcm_hardware.buffer_bytes_max; | ||
264 | |||
265 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
266 | buf->dev.dev = pcm->card->dev; | ||
267 | buf->private_data = NULL; | ||
268 | |||
269 | buf->area = dma_alloc_noncoherent(pcm->card->dev, size, | ||
270 | &buf->addr, GFP_KERNEL); | ||
271 | if (!buf->area) | ||
272 | return -ENOMEM; | ||
273 | |||
274 | buf->bytes = size; | ||
275 | |||
276 | return 0; | ||
277 | } | ||
278 | |||
279 | static void jz4740_pcm_free(struct snd_pcm *pcm) | ||
280 | { | ||
281 | struct snd_pcm_substream *substream; | ||
282 | struct snd_dma_buffer *buf; | ||
283 | int stream; | ||
284 | |||
285 | for (stream = 0; stream < SNDRV_PCM_STREAM_LAST; ++stream) { | ||
286 | substream = pcm->streams[stream].substream; | ||
287 | if (!substream) | ||
288 | continue; | ||
289 | |||
290 | buf = &substream->dma_buffer; | ||
291 | if (!buf->area) | ||
292 | continue; | ||
293 | |||
294 | dma_free_noncoherent(pcm->card->dev, buf->bytes, buf->area, | ||
295 | buf->addr); | ||
296 | buf->area = NULL; | ||
297 | } | ||
298 | } | ||
299 | |||
300 | static int jz4740_pcm_new(struct snd_soc_pcm_runtime *rtd) | ||
301 | { | ||
302 | struct snd_card *card = rtd->card->snd_card; | ||
303 | struct snd_pcm *pcm = rtd->pcm; | ||
304 | int ret; | ||
305 | |||
306 | ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); | ||
307 | if (ret) | ||
308 | return ret; | ||
309 | |||
310 | if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { | ||
311 | ret = jz4740_pcm_preallocate_dma_buffer(pcm, | ||
312 | SNDRV_PCM_STREAM_PLAYBACK); | ||
313 | if (ret) | ||
314 | goto err; | ||
315 | } | ||
316 | |||
317 | if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
318 | ret = jz4740_pcm_preallocate_dma_buffer(pcm, | ||
319 | SNDRV_PCM_STREAM_CAPTURE); | ||
320 | if (ret) | ||
321 | goto err; | ||
322 | } | ||
323 | |||
324 | err: | ||
325 | return ret; | ||
326 | } | ||
327 | |||
328 | static struct snd_soc_platform_driver jz4740_soc_platform = { | ||
329 | .ops = &jz4740_pcm_ops, | ||
330 | .pcm_new = jz4740_pcm_new, | ||
331 | .pcm_free = jz4740_pcm_free, | ||
332 | }; | ||
333 | |||
334 | static int jz4740_pcm_probe(struct platform_device *pdev) | ||
335 | { | ||
336 | return snd_soc_register_platform(&pdev->dev, &jz4740_soc_platform); | ||
337 | } | ||
338 | |||
339 | static int jz4740_pcm_remove(struct platform_device *pdev) | ||
340 | { | ||
341 | snd_soc_unregister_platform(&pdev->dev); | ||
342 | return 0; | ||
343 | } | ||
344 | |||
345 | static struct platform_driver jz4740_pcm_driver = { | ||
346 | .probe = jz4740_pcm_probe, | ||
347 | .remove = jz4740_pcm_remove, | ||
348 | .driver = { | ||
349 | .name = "jz4740-pcm-audio", | ||
350 | .owner = THIS_MODULE, | ||
351 | }, | ||
352 | }; | ||
353 | |||
354 | module_platform_driver(jz4740_pcm_driver); | ||
355 | |||
356 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | ||
357 | MODULE_DESCRIPTION("Ingenic SoC JZ4740 PCM driver"); | ||
358 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/jz4740/jz4740-pcm.h b/sound/soc/jz4740/jz4740-pcm.h deleted file mode 100644 index 1220cbb4382c..000000000000 --- a/sound/soc/jz4740/jz4740-pcm.h +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License version 2 as | ||
5 | * published by the Free Software Foundation. | ||
6 | */ | ||
7 | |||
8 | #ifndef _JZ4740_PCM_H | ||
9 | #define _JZ4740_PCM_H | ||
10 | |||
11 | #include <linux/dma-mapping.h> | ||
12 | #include <asm/mach-jz4740/dma.h> | ||
13 | |||
14 | |||
15 | struct jz4740_pcm_config { | ||
16 | struct jz4740_dma_config dma_config; | ||
17 | phys_addr_t fifo_addr; | ||
18 | }; | ||
19 | |||
20 | #endif | ||
diff --git a/sound/soc/jz4740/qi_lb60.c b/sound/soc/jz4740/qi_lb60.c index 55fd6b5df55f..82b5f37cd2c7 100644 --- a/sound/soc/jz4740/qi_lb60.c +++ b/sound/soc/jz4740/qi_lb60.c | |||
@@ -73,7 +73,7 @@ static struct snd_soc_dai_link qi_lb60_dai = { | |||
73 | .name = "jz4740", | 73 | .name = "jz4740", |
74 | .stream_name = "jz4740", | 74 | .stream_name = "jz4740", |
75 | .cpu_dai_name = "jz4740-i2s", | 75 | .cpu_dai_name = "jz4740-i2s", |
76 | .platform_name = "jz4740-pcm-audio", | 76 | .platform_name = "jz4740-i2s", |
77 | .codec_dai_name = "jz4740-hifi", | 77 | .codec_dai_name = "jz4740-hifi", |
78 | .codec_name = "jz4740-codec", | 78 | .codec_name = "jz4740-codec", |
79 | .init = qi_lb60_codec_init, | 79 | .init = qi_lb60_codec_init, |
diff --git a/sound/soc/mxs/mxs-pcm.c b/sound/soc/mxs/mxs-pcm.c index b16abbbf7764..04a6b0d60944 100644 --- a/sound/soc/mxs/mxs-pcm.c +++ b/sound/soc/mxs/mxs-pcm.c | |||
@@ -56,16 +56,10 @@ static const struct snd_dmaengine_pcm_config mxs_dmaengine_pcm_config = { | |||
56 | 56 | ||
57 | int mxs_pcm_platform_register(struct device *dev) | 57 | int mxs_pcm_platform_register(struct device *dev) |
58 | { | 58 | { |
59 | return snd_dmaengine_pcm_register(dev, &mxs_dmaengine_pcm_config, | 59 | return devm_snd_dmaengine_pcm_register(dev, &mxs_dmaengine_pcm_config, |
60 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | | 60 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | |
61 | SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX); | 61 | SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX); |
62 | } | 62 | } |
63 | EXPORT_SYMBOL_GPL(mxs_pcm_platform_register); | 63 | EXPORT_SYMBOL_GPL(mxs_pcm_platform_register); |
64 | 64 | ||
65 | void mxs_pcm_platform_unregister(struct device *dev) | ||
66 | { | ||
67 | snd_dmaengine_pcm_unregister(dev); | ||
68 | } | ||
69 | EXPORT_SYMBOL_GPL(mxs_pcm_platform_unregister); | ||
70 | |||
71 | MODULE_LICENSE("GPL"); | 65 | MODULE_LICENSE("GPL"); |
diff --git a/sound/soc/mxs/mxs-pcm.h b/sound/soc/mxs/mxs-pcm.h index bc685b67cac7..035ea0436ca5 100644 --- a/sound/soc/mxs/mxs-pcm.h +++ b/sound/soc/mxs/mxs-pcm.h | |||
@@ -20,6 +20,5 @@ | |||
20 | #define _MXS_PCM_H | 20 | #define _MXS_PCM_H |
21 | 21 | ||
22 | int mxs_pcm_platform_register(struct device *dev); | 22 | int mxs_pcm_platform_register(struct device *dev); |
23 | void mxs_pcm_platform_unregister(struct device *dev); | ||
24 | 23 | ||
25 | #endif | 24 | #endif |
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index 54e622acac33..231d7e7b0711 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c | |||
@@ -50,9 +50,9 @@ static struct mxs_saif *mxs_saif[2]; | |||
50 | * This also means that both SAIFs must operate at the same sample rate. | 50 | * This also means that both SAIFs must operate at the same sample rate. |
51 | * | 51 | * |
52 | * We abstract this as each saif has a master, the master could be | 52 | * We abstract this as each saif has a master, the master could be |
53 | * himself or other saifs. In the generic saif driver, saif does not need | 53 | * itself or other saifs. In the generic saif driver, saif does not need |
54 | * to know the different clkmux. Saif only needs to know who is his master | 54 | * to know the different clkmux. Saif only needs to know who is its master |
55 | * and operating his master to generate the proper clock rate for him. | 55 | * and operating its master to generate the proper clock rate for it. |
56 | * The master id is provided in mach-specific layer according to different | 56 | * The master id is provided in mach-specific layer according to different |
57 | * clkmux setting. | 57 | * clkmux setting. |
58 | */ | 58 | */ |
@@ -76,7 +76,7 @@ static int mxs_saif_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | |||
76 | * Since SAIF may work on EXTMASTER mode, IOW, it's working BITCLK&LRCLK | 76 | * Since SAIF may work on EXTMASTER mode, IOW, it's working BITCLK&LRCLK |
77 | * is provided by other SAIF, we provide a interface here to get its master | 77 | * is provided by other SAIF, we provide a interface here to get its master |
78 | * from its master_id. | 78 | * from its master_id. |
79 | * Note that the master could be himself. | 79 | * Note that the master could be itself. |
80 | */ | 80 | */ |
81 | static inline struct mxs_saif *mxs_saif_get_master(struct mxs_saif * saif) | 81 | static inline struct mxs_saif *mxs_saif_get_master(struct mxs_saif * saif) |
82 | { | 82 | { |
@@ -516,7 +516,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, | |||
516 | } | 516 | } |
517 | 517 | ||
518 | /* | 518 | /* |
519 | * If the saif's master is not himself, we also need to enable | 519 | * If the saif's master is not itself, we also need to enable |
520 | * itself clk for its internal basic logic to work. | 520 | * itself clk for its internal basic logic to work. |
521 | */ | 521 | */ |
522 | if (saif != master_saif) { | 522 | if (saif != master_saif) { |
@@ -804,13 +804,6 @@ static int mxs_saif_probe(struct platform_device *pdev) | |||
804 | return 0; | 804 | return 0; |
805 | } | 805 | } |
806 | 806 | ||
807 | static int mxs_saif_remove(struct platform_device *pdev) | ||
808 | { | ||
809 | mxs_pcm_platform_unregister(&pdev->dev); | ||
810 | |||
811 | return 0; | ||
812 | } | ||
813 | |||
814 | static const struct of_device_id mxs_saif_dt_ids[] = { | 807 | static const struct of_device_id mxs_saif_dt_ids[] = { |
815 | { .compatible = "fsl,imx28-saif", }, | 808 | { .compatible = "fsl,imx28-saif", }, |
816 | { /* sentinel */ } | 809 | { /* sentinel */ } |
@@ -819,7 +812,6 @@ MODULE_DEVICE_TABLE(of, mxs_saif_dt_ids); | |||
819 | 812 | ||
820 | static struct platform_driver mxs_saif_driver = { | 813 | static struct platform_driver mxs_saif_driver = { |
821 | .probe = mxs_saif_probe, | 814 | .probe = mxs_saif_probe, |
822 | .remove = mxs_saif_remove, | ||
823 | 815 | ||
824 | .driver = { | 816 | .driver = { |
825 | .name = "mxs-saif", | 817 | .name = "mxs-saif", |
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index 83433fdea32a..86c75384c3c8 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c | |||
@@ -36,10 +36,10 @@ static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) | |||
36 | 36 | ||
37 | if (mcbsp->pdata->reg_size == 2) { | 37 | if (mcbsp->pdata->reg_size == 2) { |
38 | ((u16 *)mcbsp->reg_cache)[reg] = (u16)val; | 38 | ((u16 *)mcbsp->reg_cache)[reg] = (u16)val; |
39 | __raw_writew((u16)val, addr); | 39 | writew_relaxed((u16)val, addr); |
40 | } else { | 40 | } else { |
41 | ((u32 *)mcbsp->reg_cache)[reg] = val; | 41 | ((u32 *)mcbsp->reg_cache)[reg] = val; |
42 | __raw_writel(val, addr); | 42 | writel_relaxed(val, addr); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
@@ -48,22 +48,22 @@ static int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg, bool from_cache) | |||
48 | void __iomem *addr = mcbsp->io_base + reg * mcbsp->pdata->reg_step; | 48 | void __iomem *addr = mcbsp->io_base + reg * mcbsp->pdata->reg_step; |
49 | 49 | ||
50 | if (mcbsp->pdata->reg_size == 2) { | 50 | if (mcbsp->pdata->reg_size == 2) { |
51 | return !from_cache ? __raw_readw(addr) : | 51 | return !from_cache ? readw_relaxed(addr) : |
52 | ((u16 *)mcbsp->reg_cache)[reg]; | 52 | ((u16 *)mcbsp->reg_cache)[reg]; |
53 | } else { | 53 | } else { |
54 | return !from_cache ? __raw_readl(addr) : | 54 | return !from_cache ? readl_relaxed(addr) : |
55 | ((u32 *)mcbsp->reg_cache)[reg]; | 55 | ((u32 *)mcbsp->reg_cache)[reg]; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | static void omap_mcbsp_st_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) | 59 | static void omap_mcbsp_st_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) |
60 | { | 60 | { |
61 | __raw_writel(val, mcbsp->st_data->io_base_st + reg); | 61 | writel_relaxed(val, mcbsp->st_data->io_base_st + reg); |
62 | } | 62 | } |
63 | 63 | ||
64 | static int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg) | 64 | static int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg) |
65 | { | 65 | { |
66 | return __raw_readl(mcbsp->st_data->io_base_st + reg); | 66 | return readl_relaxed(mcbsp->st_data->io_base_st + reg); |
67 | } | 67 | } |
68 | 68 | ||
69 | #define MCBSP_READ(mcbsp, reg) \ | 69 | #define MCBSP_READ(mcbsp, reg) \ |
diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c index 12e566be3793..1bd531d718f9 100644 --- a/sound/soc/omap/omap-dmic.c +++ b/sound/soc/omap/omap-dmic.c | |||
@@ -61,12 +61,12 @@ struct omap_dmic { | |||
61 | 61 | ||
62 | static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val) | 62 | static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val) |
63 | { | 63 | { |
64 | __raw_writel(val, dmic->io_base + reg); | 64 | writel_relaxed(val, dmic->io_base + reg); |
65 | } | 65 | } |
66 | 66 | ||
67 | static inline int omap_dmic_read(struct omap_dmic *dmic, u16 reg) | 67 | static inline int omap_dmic_read(struct omap_dmic *dmic, u16 reg) |
68 | { | 68 | { |
69 | return __raw_readl(dmic->io_base + reg); | 69 | return readl_relaxed(dmic->io_base + reg); |
70 | } | 70 | } |
71 | 71 | ||
72 | static inline void omap_dmic_start(struct omap_dmic *dmic) | 72 | static inline void omap_dmic_start(struct omap_dmic *dmic) |
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index cd9ee167959d..2f5b1536477e 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c | |||
@@ -74,12 +74,12 @@ struct omap_mcpdm { | |||
74 | 74 | ||
75 | static inline void omap_mcpdm_write(struct omap_mcpdm *mcpdm, u16 reg, u32 val) | 75 | static inline void omap_mcpdm_write(struct omap_mcpdm *mcpdm, u16 reg, u32 val) |
76 | { | 76 | { |
77 | __raw_writel(val, mcpdm->io_base + reg); | 77 | writel_relaxed(val, mcpdm->io_base + reg); |
78 | } | 78 | } |
79 | 79 | ||
80 | static inline int omap_mcpdm_read(struct omap_mcpdm *mcpdm, u16 reg) | 80 | static inline int omap_mcpdm_read(struct omap_mcpdm *mcpdm, u16 reg) |
81 | { | 81 | { |
82 | return __raw_readl(mcpdm->io_base + reg); | 82 | return readl_relaxed(mcpdm->io_base + reg); |
83 | } | 83 | } |
84 | 84 | ||
85 | #ifdef DEBUG | 85 | #ifdef DEBUG |
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index b8fa9862e54c..07b8b7bc9d20 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c | |||
@@ -45,8 +45,6 @@ static const struct snd_pcm_hardware omap_pcm_hardware = { | |||
45 | SNDRV_PCM_INFO_PAUSE | | 45 | SNDRV_PCM_INFO_PAUSE | |
46 | SNDRV_PCM_INFO_RESUME | | 46 | SNDRV_PCM_INFO_RESUME | |
47 | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, | 47 | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, |
48 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | ||
49 | SNDRV_PCM_FMTBIT_S32_LE, | ||
50 | .period_bytes_min = 32, | 48 | .period_bytes_min = 32, |
51 | .period_bytes_max = 64 * 1024, | 49 | .period_bytes_max = 64 * 1024, |
52 | .periods_min = 2, | 50 | .periods_min = 2, |
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index 4db74a083db1..6473052b6899 100644 --- a/sound/soc/pxa/Kconfig +++ b/sound/soc/pxa/Kconfig | |||
@@ -11,7 +11,7 @@ config SND_PXA2XX_SOC | |||
11 | config SND_MMP_SOC | 11 | config SND_MMP_SOC |
12 | bool "Soc Audio for Marvell MMP chips" | 12 | bool "Soc Audio for Marvell MMP chips" |
13 | depends on ARCH_MMP | 13 | depends on ARCH_MMP |
14 | select SND_DMAENGINE_PCM | 14 | select SND_SOC_GENERIC_DMAENGINE_PCM |
15 | select SND_ARM | 15 | select SND_ARM |
16 | help | 16 | help |
17 | Say Y if you want to add support for codecs attached to | 17 | Say Y if you want to add support for codecs attached to |
diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c index 7929e19b0ef5..5e8d81330173 100644 --- a/sound/soc/pxa/mmp-pcm.c +++ b/sound/soc/pxa/mmp-pcm.c | |||
@@ -36,14 +36,9 @@ struct mmp_dma_data { | |||
36 | SNDRV_PCM_INFO_PAUSE | \ | 36 | SNDRV_PCM_INFO_PAUSE | \ |
37 | SNDRV_PCM_INFO_RESUME) | 37 | SNDRV_PCM_INFO_RESUME) |
38 | 38 | ||
39 | #define MMP_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ | ||
40 | SNDRV_PCM_FMTBIT_S24_LE | \ | ||
41 | SNDRV_PCM_FMTBIT_S32_LE) | ||
42 | |||
43 | static struct snd_pcm_hardware mmp_pcm_hardware[] = { | 39 | static struct snd_pcm_hardware mmp_pcm_hardware[] = { |
44 | { | 40 | { |
45 | .info = MMP_PCM_INFO, | 41 | .info = MMP_PCM_INFO, |
46 | .formats = MMP_PCM_FORMATS, | ||
47 | .period_bytes_min = 1024, | 42 | .period_bytes_min = 1024, |
48 | .period_bytes_max = 2048, | 43 | .period_bytes_max = 2048, |
49 | .periods_min = 2, | 44 | .periods_min = 2, |
@@ -53,7 +48,6 @@ static struct snd_pcm_hardware mmp_pcm_hardware[] = { | |||
53 | }, | 48 | }, |
54 | { | 49 | { |
55 | .info = MMP_PCM_INFO, | 50 | .info = MMP_PCM_INFO, |
56 | .formats = MMP_PCM_FORMATS, | ||
57 | .period_bytes_min = 1024, | 51 | .period_bytes_min = 1024, |
58 | .period_bytes_max = 2048, | 52 | .period_bytes_max = 2048, |
59 | .periods_min = 2, | 53 | .periods_min = 2, |
@@ -67,27 +61,15 @@ static int mmp_pcm_hw_params(struct snd_pcm_substream *substream, | |||
67 | struct snd_pcm_hw_params *params) | 61 | struct snd_pcm_hw_params *params) |
68 | { | 62 | { |
69 | struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); | 63 | struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); |
70 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
71 | struct snd_dmaengine_dai_dma_data *dma_params; | ||
72 | struct dma_slave_config slave_config; | 64 | struct dma_slave_config slave_config; |
73 | int ret; | 65 | int ret; |
74 | 66 | ||
75 | dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | 67 | ret = |
76 | if (!dma_params) | 68 | snd_dmaengine_pcm_prepare_slave_config(substream, params, |
77 | return 0; | 69 | &slave_config); |
78 | |||
79 | ret = snd_hwparams_to_dma_slave_config(substream, params, &slave_config); | ||
80 | if (ret) | 70 | if (ret) |
81 | return ret; | 71 | return ret; |
82 | 72 | ||
83 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
84 | slave_config.dst_addr = dma_params->addr; | ||
85 | slave_config.dst_maxburst = 4; | ||
86 | } else { | ||
87 | slave_config.src_addr = dma_params->addr; | ||
88 | slave_config.src_maxburst = 4; | ||
89 | } | ||
90 | |||
91 | ret = dmaengine_slave_config(chan, &slave_config); | 73 | ret = dmaengine_slave_config(chan, &slave_config); |
92 | if (ret) | 74 | if (ret) |
93 | return ret; | 75 | return ret; |
diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c index d219880815c0..fb8461e1b1f6 100644 --- a/sound/soc/s6000/s6000-pcm.c +++ b/sound/soc/s6000/s6000-pcm.c | |||
@@ -33,13 +33,6 @@ static struct snd_pcm_hardware s6000_pcm_hardware = { | |||
33 | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 33 | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
34 | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | | 34 | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | |
35 | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_JOINT_DUPLEX), | 35 | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_JOINT_DUPLEX), |
36 | .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE), | ||
37 | .rates = (SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_5512 | \ | ||
38 | SNDRV_PCM_RATE_8000_192000), | ||
39 | .rate_min = 0, | ||
40 | .rate_max = 1562500, | ||
41 | .channels_min = 2, | ||
42 | .channels_max = 8, | ||
43 | .buffer_bytes_max = 0x7ffffff0, | 36 | .buffer_bytes_max = 0x7ffffff0, |
44 | .period_bytes_min = 16, | 37 | .period_bytes_min = 16, |
45 | .period_bytes_max = 0xfffff0, | 38 | .period_bytes_max = 0xfffff0, |
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig index 37459dfd168d..27930fc432dc 100644 --- a/sound/soc/samsung/Kconfig +++ b/sound/soc/samsung/Kconfig | |||
@@ -1,13 +1,22 @@ | |||
1 | config SND_SOC_SAMSUNG | 1 | config SND_SOC_SAMSUNG |
2 | tristate "ASoC support for Samsung" | 2 | tristate "ASoC support for Samsung" |
3 | depends on PLAT_SAMSUNG | 3 | depends on PLAT_SAMSUNG |
4 | select S3C64XX_DMA if ARCH_S3C64XX | 4 | select S3C2410_DMA if ARCH_S3C24XX |
5 | select S3C24XX_DMA if ARCH_S3C24XX | 5 | select S3C64XX_PL080 if ARCH_S3C64XX |
6 | select SND_S3C_DMA if !ARCH_S3C24XX | ||
7 | select SND_S3C_DMA_LEGACY if ARCH_S3C24XX | ||
8 | select SND_SOC_GENERIC_DMAENGINE_PCM if !ARCH_S3C24XX | ||
6 | help | 9 | help |
7 | Say Y or M if you want to add support for codecs attached to | 10 | Say Y or M if you want to add support for codecs attached to |
8 | the Samsung SoCs' Audio interfaces. You will also need to | 11 | the Samsung SoCs' Audio interfaces. You will also need to |
9 | select the audio interfaces to support below. | 12 | select the audio interfaces to support below. |
10 | 13 | ||
14 | config SND_S3C_DMA | ||
15 | tristate | ||
16 | |||
17 | config SND_S3C_DMA_LEGACY | ||
18 | tristate | ||
19 | |||
11 | config SND_S3C24XX_I2S | 20 | config SND_S3C24XX_I2S |
12 | tristate | 21 | tristate |
13 | select S3C2410_DMA | 22 | select S3C2410_DMA |
diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile index 709f6059ad67..86715d8efee6 100644 --- a/sound/soc/samsung/Makefile +++ b/sound/soc/samsung/Makefile | |||
@@ -1,5 +1,6 @@ | |||
1 | # S3c24XX Platform Support | 1 | # S3c24XX Platform Support |
2 | snd-soc-s3c24xx-objs := dma.o | 2 | snd-soc-s3c-dma-objs := dmaengine.o |
3 | snd-soc-s3c-dma-legacy-objs := dma.o | ||
3 | snd-soc-idma-objs := idma.o | 4 | snd-soc-idma-objs := idma.o |
4 | snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o | 5 | snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o |
5 | snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o | 6 | snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o |
@@ -9,7 +10,8 @@ snd-soc-samsung-spdif-objs := spdif.o | |||
9 | snd-soc-pcm-objs := pcm.o | 10 | snd-soc-pcm-objs := pcm.o |
10 | snd-soc-i2s-objs := i2s.o | 11 | snd-soc-i2s-objs := i2s.o |
11 | 12 | ||
12 | obj-$(CONFIG_SND_SOC_SAMSUNG) += snd-soc-s3c24xx.o | 13 | obj-$(CONFIG_SND_S3C_DMA) += snd-soc-s3c-dma.o |
14 | obj-$(CONFIG_SND_S3C_DMA_LEGACY) += snd-soc-s3c-dma-legacy.o | ||
13 | obj-$(CONFIG_SND_S3C24XX_I2S) += snd-soc-s3c24xx-i2s.o | 15 | obj-$(CONFIG_SND_S3C24XX_I2S) += snd-soc-s3c24xx-i2s.o |
14 | obj-$(CONFIG_SND_SAMSUNG_AC97) += snd-soc-ac97.o | 16 | obj-$(CONFIG_SND_SAMSUNG_AC97) += snd-soc-ac97.o |
15 | obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o | 17 | obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o |
diff --git a/sound/soc/samsung/ac97.c b/sound/soc/samsung/ac97.c index 350ba23a9893..4a88e36c82ec 100644 --- a/sound/soc/samsung/ac97.c +++ b/sound/soc/samsung/ac97.c | |||
@@ -221,24 +221,6 @@ static struct snd_ac97_bus_ops s3c_ac97_ops = { | |||
221 | .reset = s3c_ac97_cold_reset, | 221 | .reset = s3c_ac97_cold_reset, |
222 | }; | 222 | }; |
223 | 223 | ||
224 | static int s3c_ac97_hw_params(struct snd_pcm_substream *substream, | ||
225 | struct snd_pcm_hw_params *params, | ||
226 | struct snd_soc_dai *dai) | ||
227 | { | ||
228 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
229 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
230 | struct s3c_dma_params *dma_data; | ||
231 | |||
232 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
233 | dma_data = &s3c_ac97_pcm_out; | ||
234 | else | ||
235 | dma_data = &s3c_ac97_pcm_in; | ||
236 | |||
237 | snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data); | ||
238 | |||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd, | 224 | static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd, |
243 | struct snd_soc_dai *dai) | 225 | struct snd_soc_dai *dai) |
244 | { | 226 | { |
@@ -279,21 +261,6 @@ static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd, | |||
279 | return 0; | 261 | return 0; |
280 | } | 262 | } |
281 | 263 | ||
282 | static int s3c_ac97_hw_mic_params(struct snd_pcm_substream *substream, | ||
283 | struct snd_pcm_hw_params *params, | ||
284 | struct snd_soc_dai *dai) | ||
285 | { | ||
286 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
287 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
288 | |||
289 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
290 | return -ENODEV; | ||
291 | else | ||
292 | snd_soc_dai_set_dma_data(cpu_dai, substream, &s3c_ac97_mic_in); | ||
293 | |||
294 | return 0; | ||
295 | } | ||
296 | |||
297 | static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream, | 264 | static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream, |
298 | int cmd, struct snd_soc_dai *dai) | 265 | int cmd, struct snd_soc_dai *dai) |
299 | { | 266 | { |
@@ -329,15 +296,27 @@ static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream, | |||
329 | } | 296 | } |
330 | 297 | ||
331 | static const struct snd_soc_dai_ops s3c_ac97_dai_ops = { | 298 | static const struct snd_soc_dai_ops s3c_ac97_dai_ops = { |
332 | .hw_params = s3c_ac97_hw_params, | ||
333 | .trigger = s3c_ac97_trigger, | 299 | .trigger = s3c_ac97_trigger, |
334 | }; | 300 | }; |
335 | 301 | ||
336 | static const struct snd_soc_dai_ops s3c_ac97_mic_dai_ops = { | 302 | static const struct snd_soc_dai_ops s3c_ac97_mic_dai_ops = { |
337 | .hw_params = s3c_ac97_hw_mic_params, | ||
338 | .trigger = s3c_ac97_mic_trigger, | 303 | .trigger = s3c_ac97_mic_trigger, |
339 | }; | 304 | }; |
340 | 305 | ||
306 | static int s3c_ac97_dai_probe(struct snd_soc_dai *dai) | ||
307 | { | ||
308 | samsung_asoc_init_dma_data(dai, &s3c_ac97_pcm_out, &s3c_ac97_pcm_in); | ||
309 | |||
310 | return 0; | ||
311 | } | ||
312 | |||
313 | static int s3c_ac97_mic_dai_probe(struct snd_soc_dai *dai) | ||
314 | { | ||
315 | samsung_asoc_init_dma_data(dai, NULL, &s3c_ac97_mic_in); | ||
316 | |||
317 | return 0; | ||
318 | } | ||
319 | |||
341 | static struct snd_soc_dai_driver s3c_ac97_dai[] = { | 320 | static struct snd_soc_dai_driver s3c_ac97_dai[] = { |
342 | [S3C_AC97_DAI_PCM] = { | 321 | [S3C_AC97_DAI_PCM] = { |
343 | .name = "samsung-ac97", | 322 | .name = "samsung-ac97", |
@@ -354,6 +333,7 @@ static struct snd_soc_dai_driver s3c_ac97_dai[] = { | |||
354 | .channels_max = 2, | 333 | .channels_max = 2, |
355 | .rates = SNDRV_PCM_RATE_8000_48000, | 334 | .rates = SNDRV_PCM_RATE_8000_48000, |
356 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 335 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, |
336 | .probe = s3c_ac97_dai_probe, | ||
357 | .ops = &s3c_ac97_dai_ops, | 337 | .ops = &s3c_ac97_dai_ops, |
358 | }, | 338 | }, |
359 | [S3C_AC97_DAI_MIC] = { | 339 | [S3C_AC97_DAI_MIC] = { |
@@ -365,6 +345,7 @@ static struct snd_soc_dai_driver s3c_ac97_dai[] = { | |||
365 | .channels_max = 1, | 345 | .channels_max = 1, |
366 | .rates = SNDRV_PCM_RATE_8000_48000, | 346 | .rates = SNDRV_PCM_RATE_8000_48000, |
367 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 347 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, |
348 | .probe = s3c_ac97_mic_dai_probe, | ||
368 | .ops = &s3c_ac97_mic_dai_ops, | 349 | .ops = &s3c_ac97_mic_dai_ops, |
369 | }, | 350 | }, |
370 | }; | 351 | }; |
diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c index fe2748b494d4..dc09b71b7d9f 100644 --- a/sound/soc/samsung/dma.c +++ b/sound/soc/samsung/dma.c | |||
@@ -35,12 +35,6 @@ static const struct snd_pcm_hardware dma_hardware = { | |||
35 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 35 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
36 | SNDRV_PCM_INFO_MMAP | | 36 | SNDRV_PCM_INFO_MMAP | |
37 | SNDRV_PCM_INFO_MMAP_VALID, | 37 | SNDRV_PCM_INFO_MMAP_VALID, |
38 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | ||
39 | SNDRV_PCM_FMTBIT_U16_LE | | ||
40 | SNDRV_PCM_FMTBIT_U8 | | ||
41 | SNDRV_PCM_FMTBIT_S8, | ||
42 | .channels_min = 2, | ||
43 | .channels_max = 2, | ||
44 | .buffer_bytes_max = 128*1024, | 38 | .buffer_bytes_max = 128*1024, |
45 | .period_bytes_min = PAGE_SIZE, | 39 | .period_bytes_min = PAGE_SIZE, |
46 | .period_bytes_max = PAGE_SIZE*2, | 40 | .period_bytes_max = PAGE_SIZE*2, |
@@ -441,6 +435,14 @@ static struct snd_soc_platform_driver samsung_asoc_platform = { | |||
441 | .pcm_free = dma_free_dma_buffers, | 435 | .pcm_free = dma_free_dma_buffers, |
442 | }; | 436 | }; |
443 | 437 | ||
438 | void samsung_asoc_init_dma_data(struct snd_soc_dai *dai, | ||
439 | struct s3c_dma_params *playback, | ||
440 | struct s3c_dma_params *capture) | ||
441 | { | ||
442 | snd_soc_dai_init_dma_data(dai, playback, capture); | ||
443 | } | ||
444 | EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data); | ||
445 | |||
444 | int samsung_asoc_dma_platform_register(struct device *dev) | 446 | int samsung_asoc_dma_platform_register(struct device *dev) |
445 | { | 447 | { |
446 | return snd_soc_register_platform(dev, &samsung_asoc_platform); | 448 | return snd_soc_register_platform(dev, &samsung_asoc_platform); |
diff --git a/sound/soc/samsung/dma.h b/sound/soc/samsung/dma.h index 0e86315a3eaf..225e5378014e 100644 --- a/sound/soc/samsung/dma.h +++ b/sound/soc/samsung/dma.h | |||
@@ -12,6 +12,8 @@ | |||
12 | #ifndef _S3C_AUDIO_H | 12 | #ifndef _S3C_AUDIO_H |
13 | #define _S3C_AUDIO_H | 13 | #define _S3C_AUDIO_H |
14 | 14 | ||
15 | #include <sound/dmaengine_pcm.h> | ||
16 | |||
15 | struct s3c_dma_params { | 17 | struct s3c_dma_params { |
16 | struct s3c2410_dma_client *client; /* stream identifier */ | 18 | struct s3c2410_dma_client *client; /* stream identifier */ |
17 | int channel; /* Channel ID */ | 19 | int channel; /* Channel ID */ |
@@ -20,8 +22,12 @@ struct s3c_dma_params { | |||
20 | unsigned ch; | 22 | unsigned ch; |
21 | struct samsung_dma_ops *ops; | 23 | struct samsung_dma_ops *ops; |
22 | char *ch_name; | 24 | char *ch_name; |
25 | struct snd_dmaengine_dai_dma_data dma_data; | ||
23 | }; | 26 | }; |
24 | 27 | ||
28 | void samsung_asoc_init_dma_data(struct snd_soc_dai *dai, | ||
29 | struct s3c_dma_params *playback, | ||
30 | struct s3c_dma_params *capture); | ||
25 | int samsung_asoc_dma_platform_register(struct device *dev); | 31 | int samsung_asoc_dma_platform_register(struct device *dev); |
26 | void samsung_asoc_dma_platform_unregister(struct device *dev); | 32 | void samsung_asoc_dma_platform_unregister(struct device *dev); |
27 | 33 | ||
diff --git a/sound/soc/samsung/dmaengine.c b/sound/soc/samsung/dmaengine.c new file mode 100644 index 000000000000..3be479d51b9b --- /dev/null +++ b/sound/soc/samsung/dmaengine.c | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * dmaengine.c - Samsung dmaengine wrapper | ||
3 | * | ||
4 | * Author: Mark Brown <broonie@linaro.org> | ||
5 | * Copyright 2013 Linaro | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/amba/pl08x.h> | ||
20 | |||
21 | #include <sound/core.h> | ||
22 | #include <sound/pcm.h> | ||
23 | #include <sound/pcm_params.h> | ||
24 | #include <sound/dmaengine_pcm.h> | ||
25 | #include <sound/soc.h> | ||
26 | #include <sound/soc-dai.h> | ||
27 | |||
28 | #include "dma.h" | ||
29 | |||
30 | #ifdef CONFIG_ARCH_S3C64XX | ||
31 | #define filter_fn pl08x_filter_id | ||
32 | #else | ||
33 | #define filter_fn NULL | ||
34 | #endif | ||
35 | |||
36 | static const struct snd_dmaengine_pcm_config samsung_dmaengine_pcm_config = { | ||
37 | .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, | ||
38 | .compat_filter_fn = filter_fn, | ||
39 | }; | ||
40 | |||
41 | void samsung_asoc_init_dma_data(struct snd_soc_dai *dai, | ||
42 | struct s3c_dma_params *playback, | ||
43 | struct s3c_dma_params *capture) | ||
44 | { | ||
45 | struct snd_dmaengine_dai_dma_data *playback_data = NULL; | ||
46 | struct snd_dmaengine_dai_dma_data *capture_data = NULL; | ||
47 | |||
48 | if (playback) { | ||
49 | playback_data = &playback->dma_data; | ||
50 | playback_data->filter_data = (void *)playback->channel; | ||
51 | playback_data->chan_name = playback->ch_name; | ||
52 | playback_data->addr = playback->dma_addr; | ||
53 | playback_data->addr_width = playback->dma_size; | ||
54 | } | ||
55 | if (capture) { | ||
56 | capture_data = &capture->dma_data; | ||
57 | capture_data->filter_data = (void *)capture->channel; | ||
58 | capture_data->chan_name = capture->ch_name; | ||
59 | capture_data->addr = capture->dma_addr; | ||
60 | capture_data->addr_width = capture->dma_size; | ||
61 | } | ||
62 | |||
63 | snd_soc_dai_init_dma_data(dai, playback_data, capture_data); | ||
64 | } | ||
65 | EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data); | ||
66 | |||
67 | int samsung_asoc_dma_platform_register(struct device *dev) | ||
68 | { | ||
69 | return snd_dmaengine_pcm_register(dev, &samsung_dmaengine_pcm_config, | ||
70 | SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME | | ||
71 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | | ||
72 | SND_DMAENGINE_PCM_FLAG_COMPAT); | ||
73 | } | ||
74 | EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_register); | ||
75 | |||
76 | void samsung_asoc_dma_platform_unregister(struct device *dev) | ||
77 | { | ||
78 | return snd_dmaengine_pcm_unregister(dev); | ||
79 | } | ||
80 | EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_unregister); | ||
81 | |||
82 | MODULE_AUTHOR("Mark Brown <broonie@linaro.org>"); | ||
83 | MODULE_DESCRIPTION("Samsung dmaengine ASoC driver"); | ||
84 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index a5cbdb4f1655..92f64363427d 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c | |||
@@ -702,6 +702,8 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, | |||
702 | } | 702 | } |
703 | writel(mod, i2s->addr + I2SMOD); | 703 | writel(mod, i2s->addr + I2SMOD); |
704 | 704 | ||
705 | samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); | ||
706 | |||
705 | i2s->frmclk = params_rate(params); | 707 | i2s->frmclk = params_rate(params); |
706 | 708 | ||
707 | return 0; | 709 | return 0; |
@@ -946,8 +948,11 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) | |||
946 | struct i2s_dai *i2s = to_info(dai); | 948 | struct i2s_dai *i2s = to_info(dai); |
947 | struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; | 949 | struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; |
948 | 950 | ||
949 | if (other && other->clk) /* If this is probe on secondary */ | 951 | if (other && other->clk) { /* If this is probe on secondary */ |
952 | samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback, | ||
953 | NULL); | ||
950 | goto probe_exit; | 954 | goto probe_exit; |
955 | } | ||
951 | 956 | ||
952 | i2s->addr = ioremap(i2s->base, 0x100); | 957 | i2s->addr = ioremap(i2s->base, 0x100); |
953 | if (i2s->addr == NULL) { | 958 | if (i2s->addr == NULL) { |
@@ -963,7 +968,7 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) | |||
963 | } | 968 | } |
964 | clk_prepare_enable(i2s->clk); | 969 | clk_prepare_enable(i2s->clk); |
965 | 970 | ||
966 | snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); | 971 | samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); |
967 | 972 | ||
968 | if (other) { | 973 | if (other) { |
969 | other->addr = i2s->addr; | 974 | other->addr = i2s->addr; |
diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c index e4f318fc2f82..3d5cf1530b6f 100644 --- a/sound/soc/samsung/idma.c +++ b/sound/soc/samsung/idma.c | |||
@@ -35,14 +35,6 @@ static const struct snd_pcm_hardware idma_hardware = { | |||
35 | SNDRV_PCM_INFO_MMAP_VALID | | 35 | SNDRV_PCM_INFO_MMAP_VALID | |
36 | SNDRV_PCM_INFO_PAUSE | | 36 | SNDRV_PCM_INFO_PAUSE | |
37 | SNDRV_PCM_INFO_RESUME, | 37 | SNDRV_PCM_INFO_RESUME, |
38 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | ||
39 | SNDRV_PCM_FMTBIT_U16_LE | | ||
40 | SNDRV_PCM_FMTBIT_S24_LE | | ||
41 | SNDRV_PCM_FMTBIT_U24_LE | | ||
42 | SNDRV_PCM_FMTBIT_U8 | | ||
43 | SNDRV_PCM_FMTBIT_S8, | ||
44 | .channels_min = 2, | ||
45 | .channels_max = 2, | ||
46 | .buffer_bytes_max = MAX_IDMA_BUFFER, | 38 | .buffer_bytes_max = MAX_IDMA_BUFFER, |
47 | .period_bytes_min = 128, | 39 | .period_bytes_min = 128, |
48 | .period_bytes_max = MAX_IDMA_PERIOD, | 40 | .period_bytes_max = MAX_IDMA_PERIOD, |
diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c index e54256fc4b2c..6a5e4bf6ac96 100644 --- a/sound/soc/samsung/pcm.c +++ b/sound/soc/samsung/pcm.c | |||
@@ -275,7 +275,6 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream, | |||
275 | { | 275 | { |
276 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 276 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
277 | struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(rtd->cpu_dai); | 277 | struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(rtd->cpu_dai); |
278 | struct s3c_dma_params *dma_data; | ||
279 | void __iomem *regs = pcm->regs; | 278 | void __iomem *regs = pcm->regs; |
280 | struct clk *clk; | 279 | struct clk *clk; |
281 | int sclk_div, sync_div; | 280 | int sclk_div, sync_div; |
@@ -284,13 +283,6 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream, | |||
284 | 283 | ||
285 | dev_dbg(pcm->dev, "Entered %s\n", __func__); | 284 | dev_dbg(pcm->dev, "Entered %s\n", __func__); |
286 | 285 | ||
287 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
288 | dma_data = pcm->dma_playback; | ||
289 | else | ||
290 | dma_data = pcm->dma_capture; | ||
291 | |||
292 | snd_soc_dai_set_dma_data(rtd->cpu_dai, substream, dma_data); | ||
293 | |||
294 | /* Strictly check for sample size */ | 286 | /* Strictly check for sample size */ |
295 | switch (params_format(params)) { | 287 | switch (params_format(params)) { |
296 | case SNDRV_PCM_FORMAT_S16_LE: | 288 | case SNDRV_PCM_FORMAT_S16_LE: |
@@ -461,10 +453,20 @@ static const struct snd_soc_dai_ops s3c_pcm_dai_ops = { | |||
461 | .set_fmt = s3c_pcm_set_fmt, | 453 | .set_fmt = s3c_pcm_set_fmt, |
462 | }; | 454 | }; |
463 | 455 | ||
456 | static int s3c_pcm_dai_probe(struct snd_soc_dai *dai) | ||
457 | { | ||
458 | struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(dai); | ||
459 | |||
460 | snd_soc_dai_init_dma_data(dai, pcm->dma_playback, pcm->dma_capture); | ||
461 | |||
462 | return 0; | ||
463 | } | ||
464 | |||
464 | #define S3C_PCM_RATES SNDRV_PCM_RATE_8000_96000 | 465 | #define S3C_PCM_RATES SNDRV_PCM_RATE_8000_96000 |
465 | 466 | ||
466 | #define S3C_PCM_DAI_DECLARE \ | 467 | #define S3C_PCM_DAI_DECLARE \ |
467 | .symmetric_rates = 1, \ | 468 | .symmetric_rates = 1, \ |
469 | .probe = s3c_pcm_dai_probe, \ | ||
468 | .ops = &s3c_pcm_dai_ops, \ | 470 | .ops = &s3c_pcm_dai_ops, \ |
469 | .playback = { \ | 471 | .playback = { \ |
470 | .channels_min = 2, \ | 472 | .channels_min = 2, \ |
diff --git a/sound/soc/samsung/regs-ac97.h b/sound/soc/samsung/regs-ac97.h index c3878f7acb83..a71be45bbffc 100644 --- a/sound/soc/samsung/regs-ac97.h +++ b/sound/soc/samsung/regs-ac97.h | |||
@@ -1,5 +1,4 @@ | |||
1 | /* arch/arm/mach-s3c2410/include/mach/regs-ac97.h | 1 | /* |
2 | * | ||
3 | * Copyright (c) 2006 Simtec Electronics <linux@simtec.co.uk> | 2 | * Copyright (c) 2006 Simtec Electronics <linux@simtec.co.uk> |
4 | * http://www.simtec.co.uk/products/SWLINUX/ | 3 | * http://www.simtec.co.uk/products/SWLINUX/ |
5 | * | 4 | * |
@@ -10,8 +9,8 @@ | |||
10 | * S3C2440 AC97 Controller | 9 | * S3C2440 AC97 Controller |
11 | */ | 10 | */ |
12 | 11 | ||
13 | #ifndef __ASM_ARCH_REGS_AC97_H | 12 | #ifndef __SAMSUNG_REGS_AC97_H__ |
14 | #define __ASM_ARCH_REGS_AC97_H __FILE__ | 13 | #define __SAMSUNG_REGS_AC97_H__ |
15 | 14 | ||
16 | #define S3C_AC97_GLBCTRL (0x00) | 15 | #define S3C_AC97_GLBCTRL (0x00) |
17 | 16 | ||
@@ -64,4 +63,4 @@ | |||
64 | #define S3C_AC97_PCM_DATA (0x18) | 63 | #define S3C_AC97_PCM_DATA (0x18) |
65 | #define S3C_AC97_MIC_DATA (0x1C) | 64 | #define S3C_AC97_MIC_DATA (0x1C) |
66 | 65 | ||
67 | #endif /* __ASM_ARCH_REGS_AC97_H */ | 66 | #endif /* __SAMSUNG_REGS_AC97_H__ */ |
diff --git a/sound/soc/samsung/regs-iis.h b/sound/soc/samsung/regs-iis.h index a18d35e7a735..dc6cbbe9c4f0 100644 --- a/sound/soc/samsung/regs-iis.h +++ b/sound/soc/samsung/regs-iis.h | |||
@@ -1,5 +1,4 @@ | |||
1 | /* arch/arm/plat-samsung/include/plat/regs-iis.h | 1 | /* |
2 | * | ||
3 | * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk> | 2 | * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk> |
4 | * http://www.simtec.co.uk/products/SWLINUX/ | 3 | * http://www.simtec.co.uk/products/SWLINUX/ |
5 | * | 4 | * |
@@ -10,8 +9,8 @@ | |||
10 | * S3C2410 IIS register definition | 9 | * S3C2410 IIS register definition |
11 | */ | 10 | */ |
12 | 11 | ||
13 | #ifndef __ASM_ARCH_REGS_IIS_H | 12 | #ifndef __SAMSUNG_REGS_IIS_H__ |
14 | #define __ASM_ARCH_REGS_IIS_H | 13 | #define __SAMSUNG_REGS_IIS_H__ |
15 | 14 | ||
16 | #define S3C2410_IISCON (0x00) | 15 | #define S3C2410_IISCON (0x00) |
17 | 16 | ||
@@ -67,4 +66,4 @@ | |||
67 | 66 | ||
68 | #define S3C2410_IISFIFO (0x10) | 67 | #define S3C2410_IISFIFO (0x10) |
69 | 68 | ||
70 | #endif /* __ASM_ARCH_REGS_IIS_H */ | 69 | #endif /* __SAMSUNG_REGS_IIS_H__ */ |
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index b33ca7cd085b..6101055aae1d 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c | |||
@@ -232,9 +232,9 @@ struct fsi_stream { | |||
232 | * these are for DMAEngine | 232 | * these are for DMAEngine |
233 | */ | 233 | */ |
234 | struct dma_chan *chan; | 234 | struct dma_chan *chan; |
235 | struct sh_dmae_slave slave; /* see fsi_handler_init() */ | ||
236 | struct work_struct work; | 235 | struct work_struct work; |
237 | dma_addr_t dma; | 236 | dma_addr_t dma; |
237 | int dma_id; | ||
238 | int loop_cnt; | 238 | int loop_cnt; |
239 | int additional_pos; | 239 | int additional_pos; |
240 | }; | 240 | }; |
@@ -1410,15 +1410,6 @@ static void fsi_dma_do_work(struct work_struct *work) | |||
1410 | } | 1410 | } |
1411 | } | 1411 | } |
1412 | 1412 | ||
1413 | static bool fsi_dma_filter(struct dma_chan *chan, void *param) | ||
1414 | { | ||
1415 | struct sh_dmae_slave *slave = param; | ||
1416 | |||
1417 | chan->private = slave; | ||
1418 | |||
1419 | return true; | ||
1420 | } | ||
1421 | |||
1422 | static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io) | 1413 | static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io) |
1423 | { | 1414 | { |
1424 | schedule_work(&io->work); | 1415 | schedule_work(&io->work); |
@@ -1446,15 +1437,34 @@ static int fsi_dma_push_start_stop(struct fsi_priv *fsi, struct fsi_stream *io, | |||
1446 | static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io, struct device *dev) | 1437 | static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io, struct device *dev) |
1447 | { | 1438 | { |
1448 | dma_cap_mask_t mask; | 1439 | dma_cap_mask_t mask; |
1440 | int is_play = fsi_stream_is_play(fsi, io); | ||
1449 | 1441 | ||
1450 | dma_cap_zero(mask); | 1442 | dma_cap_zero(mask); |
1451 | dma_cap_set(DMA_SLAVE, mask); | 1443 | dma_cap_set(DMA_SLAVE, mask); |
1452 | 1444 | ||
1453 | io->chan = dma_request_channel(mask, fsi_dma_filter, &io->slave); | 1445 | io->chan = dma_request_slave_channel_compat(mask, |
1446 | shdma_chan_filter, (void *)io->dma_id, | ||
1447 | dev, is_play ? "tx" : "rx"); | ||
1448 | if (io->chan) { | ||
1449 | struct dma_slave_config cfg; | ||
1450 | int ret; | ||
1451 | |||
1452 | cfg.slave_id = io->dma_id; | ||
1453 | cfg.dst_addr = 0; /* use default addr */ | ||
1454 | cfg.src_addr = 0; /* use default addr */ | ||
1455 | cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; | ||
1456 | |||
1457 | ret = dmaengine_slave_config(io->chan, &cfg); | ||
1458 | if (ret < 0) { | ||
1459 | dma_release_channel(io->chan); | ||
1460 | io->chan = NULL; | ||
1461 | } | ||
1462 | } | ||
1463 | |||
1454 | if (!io->chan) { | 1464 | if (!io->chan) { |
1455 | 1465 | ||
1456 | /* switch to PIO handler */ | 1466 | /* switch to PIO handler */ |
1457 | if (fsi_stream_is_play(fsi, io)) | 1467 | if (is_play) |
1458 | fsi->playback.handler = &fsi_pio_push_handler; | 1468 | fsi->playback.handler = &fsi_pio_push_handler; |
1459 | else | 1469 | else |
1460 | fsi->capture.handler = &fsi_pio_pop_handler; | 1470 | fsi->capture.handler = &fsi_pio_pop_handler; |
@@ -1960,7 +1970,7 @@ static void fsi_handler_init(struct fsi_priv *fsi, | |||
1960 | fsi->capture.priv = fsi; | 1970 | fsi->capture.priv = fsi; |
1961 | 1971 | ||
1962 | if (info->tx_id) { | 1972 | if (info->tx_id) { |
1963 | fsi->playback.slave.shdma_slave.slave_id = info->tx_id; | 1973 | fsi->playback.dma_id = info->tx_id; |
1964 | fsi->playback.handler = &fsi_dma_push_handler; | 1974 | fsi->playback.handler = &fsi_dma_push_handler; |
1965 | } | 1975 | } |
1966 | } | 1976 | } |
diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index 9430097979a5..a53235c4d1b0 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c | |||
@@ -19,8 +19,8 @@ | |||
19 | struct rsnd_adg { | 19 | struct rsnd_adg { |
20 | struct clk *clk[CLKMAX]; | 20 | struct clk *clk[CLKMAX]; |
21 | 21 | ||
22 | int rate_of_441khz_div_6; | 22 | int rbga_rate_for_441khz_div_6; /* RBGA */ |
23 | int rate_of_48khz_div_6; | 23 | int rbgb_rate_for_48khz_div_6; /* RBGB */ |
24 | u32 ckr; | 24 | u32 ckr; |
25 | }; | 25 | }; |
26 | 26 | ||
@@ -30,41 +30,114 @@ struct rsnd_adg { | |||
30 | i++, (pos) = adg->clk[i]) | 30 | i++, (pos) = adg->clk[i]) |
31 | #define rsnd_priv_to_adg(priv) ((struct rsnd_adg *)(priv)->adg) | 31 | #define rsnd_priv_to_adg(priv) ((struct rsnd_adg *)(priv)->adg) |
32 | 32 | ||
33 | static enum rsnd_reg rsnd_adg_ssi_reg_get(int id) | 33 | static int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv, |
34 | struct rsnd_mod *mod, | ||
35 | unsigned int src_rate, | ||
36 | unsigned int dst_rate) | ||
34 | { | 37 | { |
35 | enum rsnd_reg reg; | 38 | struct rsnd_adg *adg = rsnd_priv_to_adg(priv); |
39 | struct device *dev = rsnd_priv_to_dev(priv); | ||
40 | int idx, sel, div, shift; | ||
41 | u32 mask, val; | ||
42 | int id = rsnd_mod_id(mod); | ||
43 | unsigned int sel_rate [] = { | ||
44 | clk_get_rate(adg->clk[CLKA]), /* 000: CLKA */ | ||
45 | clk_get_rate(adg->clk[CLKB]), /* 001: CLKB */ | ||
46 | clk_get_rate(adg->clk[CLKC]), /* 010: CLKC */ | ||
47 | 0, /* 011: MLBCLK (not used) */ | ||
48 | adg->rbga_rate_for_441khz_div_6,/* 100: RBGA */ | ||
49 | adg->rbgb_rate_for_48khz_div_6, /* 101: RBGB */ | ||
50 | }; | ||
51 | |||
52 | /* find div (= 1/128, 1/256, 1/512, 1/1024, 1/2048 */ | ||
53 | for (sel = 0; sel < ARRAY_SIZE(sel_rate); sel++) { | ||
54 | for (div = 128, idx = 0; | ||
55 | div <= 2048; | ||
56 | div *= 2, idx++) { | ||
57 | if (src_rate == sel_rate[sel] / div) { | ||
58 | val = (idx << 4) | sel; | ||
59 | goto find_rate; | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | dev_err(dev, "can't find convert src clk\n"); | ||
64 | return -EINVAL; | ||
65 | |||
66 | find_rate: | ||
67 | shift = (id % 4) * 8; | ||
68 | mask = 0xFF << shift; | ||
69 | val = val << shift; | ||
70 | |||
71 | dev_dbg(dev, "adg convert src clk = %02x\n", val); | ||
72 | |||
73 | switch (id / 4) { | ||
74 | case 0: | ||
75 | rsnd_mod_bset(mod, AUDIO_CLK_SEL3, mask, val); | ||
76 | break; | ||
77 | case 1: | ||
78 | rsnd_mod_bset(mod, AUDIO_CLK_SEL4, mask, val); | ||
79 | break; | ||
80 | case 2: | ||
81 | rsnd_mod_bset(mod, AUDIO_CLK_SEL5, mask, val); | ||
82 | break; | ||
83 | } | ||
84 | |||
85 | /* | ||
86 | * Gen1 doesn't need dst_rate settings, | ||
87 | * since it uses SSI WS pin. | ||
88 | * see also rsnd_src_set_route_if_gen1() | ||
89 | */ | ||
90 | |||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | int rsnd_adg_set_convert_clk(struct rsnd_priv *priv, | ||
95 | struct rsnd_mod *mod, | ||
96 | unsigned int src_rate, | ||
97 | unsigned int dst_rate) | ||
98 | { | ||
99 | if (rsnd_is_gen1(priv)) | ||
100 | return rsnd_adg_set_convert_clk_gen1(priv, mod, | ||
101 | src_rate, dst_rate); | ||
102 | |||
103 | return -EINVAL; | ||
104 | } | ||
105 | |||
106 | static void rsnd_adg_set_ssi_clk(struct rsnd_mod *mod, u32 val) | ||
107 | { | ||
108 | int id = rsnd_mod_id(mod); | ||
109 | int shift = (id % 4) * 8; | ||
110 | u32 mask = 0xFF << shift; | ||
111 | |||
112 | val = val << shift; | ||
36 | 113 | ||
37 | /* | 114 | /* |
38 | * SSI 8 is not connected to ADG. | 115 | * SSI 8 is not connected to ADG. |
39 | * it works with SSI 7 | 116 | * it works with SSI 7 |
40 | */ | 117 | */ |
41 | if (id == 8) | 118 | if (id == 8) |
42 | return RSND_REG_MAX; | 119 | return; |
43 | 120 | ||
44 | if (0 <= id && id <= 3) | 121 | switch (id / 4) { |
45 | reg = RSND_REG_AUDIO_CLK_SEL0; | 122 | case 0: |
46 | else if (4 <= id && id <= 7) | 123 | rsnd_mod_bset(mod, AUDIO_CLK_SEL0, mask, val); |
47 | reg = RSND_REG_AUDIO_CLK_SEL1; | 124 | break; |
48 | else | 125 | case 1: |
49 | reg = RSND_REG_AUDIO_CLK_SEL2; | 126 | rsnd_mod_bset(mod, AUDIO_CLK_SEL1, mask, val); |
50 | 127 | break; | |
51 | return reg; | 128 | case 2: |
129 | rsnd_mod_bset(mod, AUDIO_CLK_SEL2, mask, val); | ||
130 | break; | ||
131 | } | ||
52 | } | 132 | } |
53 | 133 | ||
54 | int rsnd_adg_ssi_clk_stop(struct rsnd_mod *mod) | 134 | int rsnd_adg_ssi_clk_stop(struct rsnd_mod *mod) |
55 | { | 135 | { |
56 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | ||
57 | enum rsnd_reg reg; | ||
58 | int id; | ||
59 | |||
60 | /* | 136 | /* |
61 | * "mod" = "ssi" here. | 137 | * "mod" = "ssi" here. |
62 | * we can get "ssi id" from mod | 138 | * we can get "ssi id" from mod |
63 | */ | 139 | */ |
64 | id = rsnd_mod_id(mod); | 140 | rsnd_adg_set_ssi_clk(mod, 0); |
65 | reg = rsnd_adg_ssi_reg_get(id); | ||
66 | |||
67 | rsnd_write(priv, mod, reg, 0); | ||
68 | 141 | ||
69 | return 0; | 142 | return 0; |
70 | } | 143 | } |
@@ -75,8 +148,7 @@ int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate) | |||
75 | struct rsnd_adg *adg = rsnd_priv_to_adg(priv); | 148 | struct rsnd_adg *adg = rsnd_priv_to_adg(priv); |
76 | struct device *dev = rsnd_priv_to_dev(priv); | 149 | struct device *dev = rsnd_priv_to_dev(priv); |
77 | struct clk *clk; | 150 | struct clk *clk; |
78 | enum rsnd_reg reg; | 151 | int i; |
79 | int id, shift, i; | ||
80 | u32 data; | 152 | u32 data; |
81 | int sel_table[] = { | 153 | int sel_table[] = { |
82 | [CLKA] = 0x1, | 154 | [CLKA] = 0x1, |
@@ -102,12 +174,12 @@ int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate) | |||
102 | /* | 174 | /* |
103 | * find 1/6 clock from BRGA/BRGB | 175 | * find 1/6 clock from BRGA/BRGB |
104 | */ | 176 | */ |
105 | if (rate == adg->rate_of_441khz_div_6) { | 177 | if (rate == adg->rbga_rate_for_441khz_div_6) { |
106 | data = 0x10; | 178 | data = 0x10; |
107 | goto found_clock; | 179 | goto found_clock; |
108 | } | 180 | } |
109 | 181 | ||
110 | if (rate == adg->rate_of_48khz_div_6) { | 182 | if (rate == adg->rbgb_rate_for_48khz_div_6) { |
111 | data = 0x20; | 183 | data = 0x20; |
112 | goto found_clock; | 184 | goto found_clock; |
113 | } | 185 | } |
@@ -125,19 +197,10 @@ found_clock: | |||
125 | * This "mod" = "ssi" here. | 197 | * This "mod" = "ssi" here. |
126 | * we can get "ssi id" from mod | 198 | * we can get "ssi id" from mod |
127 | */ | 199 | */ |
128 | id = rsnd_mod_id(mod); | 200 | rsnd_adg_set_ssi_clk(mod, data); |
129 | reg = rsnd_adg_ssi_reg_get(id); | ||
130 | |||
131 | dev_dbg(dev, "ADG: ssi%d selects clk%d = %d", id, i, rate); | ||
132 | |||
133 | /* | ||
134 | * Enable SSIx clock | ||
135 | */ | ||
136 | shift = (id % 4) * 8; | ||
137 | 201 | ||
138 | rsnd_bset(priv, mod, reg, | 202 | dev_dbg(dev, "ADG: ssi%d selects clk%d = %d", |
139 | 0xFF << shift, | 203 | rsnd_mod_id(mod), i, rate); |
140 | data << shift); | ||
141 | 204 | ||
142 | return 0; | 205 | return 0; |
143 | } | 206 | } |
@@ -166,8 +229,8 @@ static void rsnd_adg_ssi_clk_init(struct rsnd_priv *priv, struct rsnd_adg *adg) | |||
166 | * rsnd_adg_ssi_clk_try_start() | 229 | * rsnd_adg_ssi_clk_try_start() |
167 | */ | 230 | */ |
168 | ckr = 0; | 231 | ckr = 0; |
169 | adg->rate_of_441khz_div_6 = 0; | 232 | adg->rbga_rate_for_441khz_div_6 = 0; |
170 | adg->rate_of_48khz_div_6 = 0; | 233 | adg->rbgb_rate_for_48khz_div_6 = 0; |
171 | for_each_rsnd_clk(clk, adg, i) { | 234 | for_each_rsnd_clk(clk, adg, i) { |
172 | rate = clk_get_rate(clk); | 235 | rate = clk_get_rate(clk); |
173 | 236 | ||
@@ -175,14 +238,14 @@ static void rsnd_adg_ssi_clk_init(struct rsnd_priv *priv, struct rsnd_adg *adg) | |||
175 | continue; | 238 | continue; |
176 | 239 | ||
177 | /* RBGA */ | 240 | /* RBGA */ |
178 | if (!adg->rate_of_441khz_div_6 && (0 == rate % 44100)) { | 241 | if (!adg->rbga_rate_for_441khz_div_6 && (0 == rate % 44100)) { |
179 | adg->rate_of_441khz_div_6 = rate / 6; | 242 | adg->rbga_rate_for_441khz_div_6 = rate / 6; |
180 | ckr |= brg_table[i] << 20; | 243 | ckr |= brg_table[i] << 20; |
181 | } | 244 | } |
182 | 245 | ||
183 | /* RBGB */ | 246 | /* RBGB */ |
184 | if (!adg->rate_of_48khz_div_6 && (0 == rate % 48000)) { | 247 | if (!adg->rbgb_rate_for_48khz_div_6 && (0 == rate % 48000)) { |
185 | adg->rate_of_48khz_div_6 = rate / 6; | 248 | adg->rbgb_rate_for_48khz_div_6 = rate / 6; |
186 | ckr |= brg_table[i] << 16; | 249 | ckr |= brg_table[i] << 16; |
187 | } | 250 | } |
188 | } | 251 | } |
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index 61212ee97c28..add088bd4b2a 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c | |||
@@ -10,20 +10,6 @@ | |||
10 | */ | 10 | */ |
11 | #include "rsnd.h" | 11 | #include "rsnd.h" |
12 | 12 | ||
13 | struct rsnd_gen_ops { | ||
14 | int (*probe)(struct platform_device *pdev, | ||
15 | struct rcar_snd_info *info, | ||
16 | struct rsnd_priv *priv); | ||
17 | void (*remove)(struct platform_device *pdev, | ||
18 | struct rsnd_priv *priv); | ||
19 | int (*path_init)(struct rsnd_priv *priv, | ||
20 | struct rsnd_dai *rdai, | ||
21 | struct rsnd_dai_stream *io); | ||
22 | int (*path_exit)(struct rsnd_priv *priv, | ||
23 | struct rsnd_dai *rdai, | ||
24 | struct rsnd_dai_stream *io); | ||
25 | }; | ||
26 | |||
27 | struct rsnd_gen { | 13 | struct rsnd_gen { |
28 | void __iomem *base[RSND_BASE_MAX]; | 14 | void __iomem *base[RSND_BASE_MAX]; |
29 | 15 | ||
@@ -86,12 +72,28 @@ static struct regmap_bus rsnd_regmap_bus = { | |||
86 | .val_format_endian_default = REGMAP_ENDIAN_NATIVE, | 72 | .val_format_endian_default = REGMAP_ENDIAN_NATIVE, |
87 | }; | 73 | }; |
88 | 74 | ||
75 | static int rsnd_is_accessible_reg(struct rsnd_priv *priv, | ||
76 | struct rsnd_gen *gen, enum rsnd_reg reg) | ||
77 | { | ||
78 | if (!gen->regs[reg]) { | ||
79 | struct device *dev = rsnd_priv_to_dev(priv); | ||
80 | |||
81 | dev_err(dev, "unsupported register access %x\n", reg); | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | return 1; | ||
86 | } | ||
87 | |||
89 | u32 rsnd_read(struct rsnd_priv *priv, | 88 | u32 rsnd_read(struct rsnd_priv *priv, |
90 | struct rsnd_mod *mod, enum rsnd_reg reg) | 89 | struct rsnd_mod *mod, enum rsnd_reg reg) |
91 | { | 90 | { |
92 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | 91 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); |
93 | u32 val; | 92 | u32 val; |
94 | 93 | ||
94 | if (!rsnd_is_accessible_reg(priv, gen, reg)) | ||
95 | return 0; | ||
96 | |||
95 | regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val); | 97 | regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val); |
96 | 98 | ||
97 | return val; | 99 | return val; |
@@ -103,6 +105,9 @@ void rsnd_write(struct rsnd_priv *priv, | |||
103 | { | 105 | { |
104 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | 106 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); |
105 | 107 | ||
108 | if (!rsnd_is_accessible_reg(priv, gen, reg)) | ||
109 | return; | ||
110 | |||
106 | regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); | 111 | regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); |
107 | } | 112 | } |
108 | 113 | ||
@@ -111,21 +116,48 @@ void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, | |||
111 | { | 116 | { |
112 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | 117 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); |
113 | 118 | ||
119 | if (!rsnd_is_accessible_reg(priv, gen, reg)) | ||
120 | return; | ||
121 | |||
114 | regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod), | 122 | regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod), |
115 | mask, data); | 123 | mask, data); |
116 | } | 124 | } |
117 | 125 | ||
118 | /* | 126 | static int rsnd_gen_regmap_init(struct rsnd_priv *priv, |
119 | * Gen2 | 127 | struct rsnd_gen *gen, |
120 | * will be filled in the future | 128 | struct reg_field *regf) |
121 | */ | 129 | { |
130 | int i; | ||
131 | struct device *dev = rsnd_priv_to_dev(priv); | ||
132 | struct regmap_config regc; | ||
122 | 133 | ||
123 | /* | 134 | memset(®c, 0, sizeof(regc)); |
124 | * Gen1 | 135 | regc.reg_bits = 32; |
125 | */ | 136 | regc.val_bits = 32; |
126 | static int rsnd_gen1_path_init(struct rsnd_priv *priv, | 137 | |
127 | struct rsnd_dai *rdai, | 138 | gen->regmap = devm_regmap_init(dev, &rsnd_regmap_bus, priv, ®c); |
128 | struct rsnd_dai_stream *io) | 139 | if (IS_ERR(gen->regmap)) { |
140 | dev_err(dev, "regmap error %ld\n", PTR_ERR(gen->regmap)); | ||
141 | return PTR_ERR(gen->regmap); | ||
142 | } | ||
143 | |||
144 | for (i = 0; i < RSND_REG_MAX; i++) { | ||
145 | gen->regs[i] = NULL; | ||
146 | if (!regf[i].reg) | ||
147 | continue; | ||
148 | |||
149 | gen->regs[i] = devm_regmap_field_alloc(dev, gen->regmap, regf[i]); | ||
150 | if (IS_ERR(gen->regs[i])) | ||
151 | return PTR_ERR(gen->regs[i]); | ||
152 | |||
153 | } | ||
154 | |||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | int rsnd_gen_path_init(struct rsnd_priv *priv, | ||
159 | struct rsnd_dai *rdai, | ||
160 | struct rsnd_dai_stream *io) | ||
129 | { | 161 | { |
130 | struct rsnd_mod *mod; | 162 | struct rsnd_mod *mod; |
131 | int ret; | 163 | int ret; |
@@ -163,9 +195,9 @@ static int rsnd_gen1_path_init(struct rsnd_priv *priv, | |||
163 | return ret; | 195 | return ret; |
164 | } | 196 | } |
165 | 197 | ||
166 | static int rsnd_gen1_path_exit(struct rsnd_priv *priv, | 198 | int rsnd_gen_path_exit(struct rsnd_priv *priv, |
167 | struct rsnd_dai *rdai, | 199 | struct rsnd_dai *rdai, |
168 | struct rsnd_dai_stream *io) | 200 | struct rsnd_dai_stream *io) |
169 | { | 201 | { |
170 | struct rsnd_mod *mod, *n; | 202 | struct rsnd_mod *mod, *n; |
171 | int ret = 0; | 203 | int ret = 0; |
@@ -179,6 +211,94 @@ static int rsnd_gen1_path_exit(struct rsnd_priv *priv, | |||
179 | return ret; | 211 | return ret; |
180 | } | 212 | } |
181 | 213 | ||
214 | /* | ||
215 | * Gen2 | ||
216 | */ | ||
217 | |||
218 | /* single address mapping */ | ||
219 | #define RSND_GEN2_S_REG(gen, reg, id, offset) \ | ||
220 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN2_##reg, offset, 0, 10) | ||
221 | |||
222 | /* multi address mapping */ | ||
223 | #define RSND_GEN2_M_REG(gen, reg, id, offset, _id_offset) \ | ||
224 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN2_##reg, offset, _id_offset, 10) | ||
225 | |||
226 | static int rsnd_gen2_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) | ||
227 | { | ||
228 | struct reg_field regf[RSND_REG_MAX] = { | ||
229 | RSND_GEN2_S_REG(gen, SSIU, SSI_MODE0, 0x800), | ||
230 | RSND_GEN2_S_REG(gen, SSIU, SSI_MODE1, 0x804), | ||
231 | /* FIXME: it needs SSI_MODE2/3 in the future */ | ||
232 | RSND_GEN2_M_REG(gen, SSIU, INT_ENABLE, 0x18, 0x80), | ||
233 | |||
234 | RSND_GEN2_S_REG(gen, ADG, BRRA, 0x00), | ||
235 | RSND_GEN2_S_REG(gen, ADG, BRRB, 0x04), | ||
236 | RSND_GEN2_S_REG(gen, ADG, SSICKR, 0x08), | ||
237 | RSND_GEN2_S_REG(gen, ADG, AUDIO_CLK_SEL0, 0x0c), | ||
238 | RSND_GEN2_S_REG(gen, ADG, AUDIO_CLK_SEL1, 0x10), | ||
239 | RSND_GEN2_S_REG(gen, ADG, AUDIO_CLK_SEL2, 0x14), | ||
240 | |||
241 | RSND_GEN2_M_REG(gen, SSI, SSICR, 0x00, 0x40), | ||
242 | RSND_GEN2_M_REG(gen, SSI, SSISR, 0x04, 0x40), | ||
243 | RSND_GEN2_M_REG(gen, SSI, SSITDR, 0x08, 0x40), | ||
244 | RSND_GEN2_M_REG(gen, SSI, SSIRDR, 0x0c, 0x40), | ||
245 | RSND_GEN2_M_REG(gen, SSI, SSIWSR, 0x20, 0x40), | ||
246 | }; | ||
247 | |||
248 | return rsnd_gen_regmap_init(priv, gen, regf); | ||
249 | } | ||
250 | |||
251 | static int rsnd_gen2_probe(struct platform_device *pdev, | ||
252 | struct rcar_snd_info *info, | ||
253 | struct rsnd_priv *priv) | ||
254 | { | ||
255 | struct device *dev = rsnd_priv_to_dev(priv); | ||
256 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
257 | struct resource *scu_res; | ||
258 | struct resource *adg_res; | ||
259 | struct resource *ssiu_res; | ||
260 | struct resource *ssi_res; | ||
261 | int ret; | ||
262 | |||
263 | /* | ||
264 | * map address | ||
265 | */ | ||
266 | scu_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SCU); | ||
267 | adg_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_ADG); | ||
268 | ssiu_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SSIU); | ||
269 | ssi_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SSI); | ||
270 | |||
271 | gen->base[RSND_GEN2_SCU] = devm_ioremap_resource(dev, scu_res); | ||
272 | gen->base[RSND_GEN2_ADG] = devm_ioremap_resource(dev, adg_res); | ||
273 | gen->base[RSND_GEN2_SSIU] = devm_ioremap_resource(dev, ssiu_res); | ||
274 | gen->base[RSND_GEN2_SSI] = devm_ioremap_resource(dev, ssi_res); | ||
275 | if (IS_ERR(gen->base[RSND_GEN2_SCU]) || | ||
276 | IS_ERR(gen->base[RSND_GEN2_ADG]) || | ||
277 | IS_ERR(gen->base[RSND_GEN2_SSIU]) || | ||
278 | IS_ERR(gen->base[RSND_GEN2_SSI])) | ||
279 | return -ENODEV; | ||
280 | |||
281 | ret = rsnd_gen2_regmap_init(priv, gen); | ||
282 | if (ret < 0) | ||
283 | return ret; | ||
284 | |||
285 | dev_dbg(dev, "Gen2 device probed\n"); | ||
286 | dev_dbg(dev, "SRU : %08x => %p\n", scu_res->start, | ||
287 | gen->base[RSND_GEN2_SCU]); | ||
288 | dev_dbg(dev, "ADG : %08x => %p\n", adg_res->start, | ||
289 | gen->base[RSND_GEN2_ADG]); | ||
290 | dev_dbg(dev, "SSIU : %08x => %p\n", ssiu_res->start, | ||
291 | gen->base[RSND_GEN2_SSIU]); | ||
292 | dev_dbg(dev, "SSI : %08x => %p\n", ssi_res->start, | ||
293 | gen->base[RSND_GEN2_SSI]); | ||
294 | |||
295 | return 0; | ||
296 | } | ||
297 | |||
298 | /* | ||
299 | * Gen1 | ||
300 | */ | ||
301 | |||
182 | /* single address mapping */ | 302 | /* single address mapping */ |
183 | #define RSND_GEN1_S_REG(gen, reg, id, offset) \ | 303 | #define RSND_GEN1_S_REG(gen, reg, id, offset) \ |
184 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, 0, 9) | 304 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, 0, 9) |
@@ -189,19 +309,23 @@ static int rsnd_gen1_path_exit(struct rsnd_priv *priv, | |||
189 | 309 | ||
190 | static int rsnd_gen1_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) | 310 | static int rsnd_gen1_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) |
191 | { | 311 | { |
192 | int i; | ||
193 | struct device *dev = rsnd_priv_to_dev(priv); | ||
194 | struct regmap_config regc; | ||
195 | struct reg_field regf[RSND_REG_MAX] = { | 312 | struct reg_field regf[RSND_REG_MAX] = { |
196 | RSND_GEN1_S_REG(gen, SRU, SRC_ROUTE_SEL, 0x00), | 313 | RSND_GEN1_S_REG(gen, SRU, SRC_ROUTE_SEL, 0x00), |
197 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL0, 0x08), | 314 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL0, 0x08), |
198 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL1, 0x0c), | 315 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL1, 0x0c), |
199 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL2, 0x10), | 316 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL2, 0x10), |
200 | RSND_GEN1_S_REG(gen, SRU, SRC_CTRL, 0xc0), | 317 | RSND_GEN1_S_REG(gen, SRU, SRC_ROUTE_CTRL, 0xc0), |
201 | RSND_GEN1_S_REG(gen, SRU, SSI_MODE0, 0xD0), | 318 | RSND_GEN1_S_REG(gen, SRU, SSI_MODE0, 0xD0), |
202 | RSND_GEN1_S_REG(gen, SRU, SSI_MODE1, 0xD4), | 319 | RSND_GEN1_S_REG(gen, SRU, SSI_MODE1, 0xD4), |
203 | RSND_GEN1_M_REG(gen, SRU, BUSIF_MODE, 0x20, 0x4), | 320 | RSND_GEN1_M_REG(gen, SRU, BUSIF_MODE, 0x20, 0x4), |
204 | RSND_GEN1_M_REG(gen, SRU, BUSIF_ADINR, 0x214, 0x40), | 321 | RSND_GEN1_M_REG(gen, SRU, SRC_ROUTE_MODE0,0x50, 0x8), |
322 | RSND_GEN1_M_REG(gen, SRU, SRC_SWRSR, 0x200, 0x40), | ||
323 | RSND_GEN1_M_REG(gen, SRU, SRC_SRCIR, 0x204, 0x40), | ||
324 | RSND_GEN1_M_REG(gen, SRU, SRC_ADINR, 0x214, 0x40), | ||
325 | RSND_GEN1_M_REG(gen, SRU, SRC_IFSCR, 0x21c, 0x40), | ||
326 | RSND_GEN1_M_REG(gen, SRU, SRC_IFSVR, 0x220, 0x40), | ||
327 | RSND_GEN1_M_REG(gen, SRU, SRC_SRCCR, 0x224, 0x40), | ||
328 | RSND_GEN1_M_REG(gen, SRU, SRC_MNFSR, 0x228, 0x40), | ||
205 | 329 | ||
206 | RSND_GEN1_S_REG(gen, ADG, BRRA, 0x00), | 330 | RSND_GEN1_S_REG(gen, ADG, BRRA, 0x00), |
207 | RSND_GEN1_S_REG(gen, ADG, BRRB, 0x04), | 331 | RSND_GEN1_S_REG(gen, ADG, BRRB, 0x04), |
@@ -219,24 +343,7 @@ static int rsnd_gen1_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) | |||
219 | RSND_GEN1_M_REG(gen, SSI, SSIWSR, 0x20, 0x40), | 343 | RSND_GEN1_M_REG(gen, SSI, SSIWSR, 0x20, 0x40), |
220 | }; | 344 | }; |
221 | 345 | ||
222 | memset(®c, 0, sizeof(regc)); | 346 | return rsnd_gen_regmap_init(priv, gen, regf); |
223 | regc.reg_bits = 32; | ||
224 | regc.val_bits = 32; | ||
225 | |||
226 | gen->regmap = devm_regmap_init(dev, &rsnd_regmap_bus, priv, ®c); | ||
227 | if (IS_ERR(gen->regmap)) { | ||
228 | dev_err(dev, "regmap error %ld\n", PTR_ERR(gen->regmap)); | ||
229 | return PTR_ERR(gen->regmap); | ||
230 | } | ||
231 | |||
232 | for (i = 0; i < RSND_REG_MAX; i++) { | ||
233 | gen->regs[i] = devm_regmap_field_alloc(dev, gen->regmap, regf[i]); | ||
234 | if (IS_ERR(gen->regs[i])) | ||
235 | return PTR_ERR(gen->regs[i]); | ||
236 | |||
237 | } | ||
238 | |||
239 | return 0; | ||
240 | } | 347 | } |
241 | 348 | ||
242 | static int rsnd_gen1_probe(struct platform_device *pdev, | 349 | static int rsnd_gen1_probe(struct platform_device *pdev, |
@@ -281,45 +388,16 @@ static int rsnd_gen1_probe(struct platform_device *pdev, | |||
281 | 388 | ||
282 | } | 389 | } |
283 | 390 | ||
284 | static void rsnd_gen1_remove(struct platform_device *pdev, | ||
285 | struct rsnd_priv *priv) | ||
286 | { | ||
287 | } | ||
288 | |||
289 | static struct rsnd_gen_ops rsnd_gen1_ops = { | ||
290 | .probe = rsnd_gen1_probe, | ||
291 | .remove = rsnd_gen1_remove, | ||
292 | .path_init = rsnd_gen1_path_init, | ||
293 | .path_exit = rsnd_gen1_path_exit, | ||
294 | }; | ||
295 | |||
296 | /* | 391 | /* |
297 | * Gen | 392 | * Gen |
298 | */ | 393 | */ |
299 | int rsnd_gen_path_init(struct rsnd_priv *priv, | ||
300 | struct rsnd_dai *rdai, | ||
301 | struct rsnd_dai_stream *io) | ||
302 | { | ||
303 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
304 | |||
305 | return gen->ops->path_init(priv, rdai, io); | ||
306 | } | ||
307 | |||
308 | int rsnd_gen_path_exit(struct rsnd_priv *priv, | ||
309 | struct rsnd_dai *rdai, | ||
310 | struct rsnd_dai_stream *io) | ||
311 | { | ||
312 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
313 | |||
314 | return gen->ops->path_exit(priv, rdai, io); | ||
315 | } | ||
316 | |||
317 | int rsnd_gen_probe(struct platform_device *pdev, | 394 | int rsnd_gen_probe(struct platform_device *pdev, |
318 | struct rcar_snd_info *info, | 395 | struct rcar_snd_info *info, |
319 | struct rsnd_priv *priv) | 396 | struct rsnd_priv *priv) |
320 | { | 397 | { |
321 | struct device *dev = rsnd_priv_to_dev(priv); | 398 | struct device *dev = rsnd_priv_to_dev(priv); |
322 | struct rsnd_gen *gen; | 399 | struct rsnd_gen *gen; |
400 | int ret; | ||
323 | 401 | ||
324 | gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL); | 402 | gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL); |
325 | if (!gen) { | 403 | if (!gen) { |
@@ -327,23 +405,21 @@ int rsnd_gen_probe(struct platform_device *pdev, | |||
327 | return -ENOMEM; | 405 | return -ENOMEM; |
328 | } | 406 | } |
329 | 407 | ||
408 | priv->gen = gen; | ||
409 | |||
410 | ret = -ENODEV; | ||
330 | if (rsnd_is_gen1(priv)) | 411 | if (rsnd_is_gen1(priv)) |
331 | gen->ops = &rsnd_gen1_ops; | 412 | ret = rsnd_gen1_probe(pdev, info, priv); |
413 | else if (rsnd_is_gen2(priv)) | ||
414 | ret = rsnd_gen2_probe(pdev, info, priv); | ||
332 | 415 | ||
333 | if (!gen->ops) { | 416 | if (ret < 0) |
334 | dev_err(dev, "unknown generation R-Car sound device\n"); | 417 | dev_err(dev, "unknown generation R-Car sound device\n"); |
335 | return -ENODEV; | ||
336 | } | ||
337 | |||
338 | priv->gen = gen; | ||
339 | 418 | ||
340 | return gen->ops->probe(pdev, info, priv); | 419 | return ret; |
341 | } | 420 | } |
342 | 421 | ||
343 | void rsnd_gen_remove(struct platform_device *pdev, | 422 | void rsnd_gen_remove(struct platform_device *pdev, |
344 | struct rsnd_priv *priv) | 423 | struct rsnd_priv *priv) |
345 | { | 424 | { |
346 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
347 | |||
348 | gen->ops->remove(pdev, priv); | ||
349 | } | 425 | } |
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 9e463e50e7e6..4ca66cd899c8 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
@@ -31,16 +31,24 @@ | |||
31 | * see gen1/gen2 for detail | 31 | * see gen1/gen2 for detail |
32 | */ | 32 | */ |
33 | enum rsnd_reg { | 33 | enum rsnd_reg { |
34 | /* SRU/SCU */ | 34 | /* SRU/SCU/SSIU */ |
35 | RSND_REG_SRC_ROUTE_SEL, | 35 | RSND_REG_SRC_ROUTE_SEL, /* for Gen1 */ |
36 | RSND_REG_SRC_TMG_SEL0, | 36 | RSND_REG_SRC_TMG_SEL0, /* for Gen1 */ |
37 | RSND_REG_SRC_TMG_SEL1, | 37 | RSND_REG_SRC_TMG_SEL1, /* for Gen1 */ |
38 | RSND_REG_SRC_TMG_SEL2, | 38 | RSND_REG_SRC_TMG_SEL2, /* for Gen1 */ |
39 | RSND_REG_SRC_CTRL, | 39 | RSND_REG_SRC_ROUTE_CTRL, /* for Gen1 */ |
40 | RSND_REG_SSI_MODE0, | 40 | RSND_REG_SSI_MODE0, |
41 | RSND_REG_SSI_MODE1, | 41 | RSND_REG_SSI_MODE1, |
42 | RSND_REG_BUSIF_MODE, | 42 | RSND_REG_BUSIF_MODE, |
43 | RSND_REG_BUSIF_ADINR, | 43 | RSND_REG_INT_ENABLE, /* for Gen2 */ |
44 | RSND_REG_SRC_ROUTE_MODE0, | ||
45 | RSND_REG_SRC_SWRSR, | ||
46 | RSND_REG_SRC_SRCIR, | ||
47 | RSND_REG_SRC_ADINR, | ||
48 | RSND_REG_SRC_IFSCR, | ||
49 | RSND_REG_SRC_IFSVR, | ||
50 | RSND_REG_SRC_SRCCR, | ||
51 | RSND_REG_SRC_MNFSR, | ||
44 | 52 | ||
45 | /* ADG */ | 53 | /* ADG */ |
46 | RSND_REG_BRRA, | 54 | RSND_REG_BRRA, |
@@ -49,9 +57,9 @@ enum rsnd_reg { | |||
49 | RSND_REG_AUDIO_CLK_SEL0, | 57 | RSND_REG_AUDIO_CLK_SEL0, |
50 | RSND_REG_AUDIO_CLK_SEL1, | 58 | RSND_REG_AUDIO_CLK_SEL1, |
51 | RSND_REG_AUDIO_CLK_SEL2, | 59 | RSND_REG_AUDIO_CLK_SEL2, |
52 | RSND_REG_AUDIO_CLK_SEL3, | 60 | RSND_REG_AUDIO_CLK_SEL3, /* for Gen1 */ |
53 | RSND_REG_AUDIO_CLK_SEL4, | 61 | RSND_REG_AUDIO_CLK_SEL4, /* for Gen1 */ |
54 | RSND_REG_AUDIO_CLK_SEL5, | 62 | RSND_REG_AUDIO_CLK_SEL5, /* for Gen1 */ |
55 | 63 | ||
56 | /* SSI */ | 64 | /* SSI */ |
57 | RSND_REG_SSICR, | 65 | RSND_REG_SSICR, |
@@ -174,11 +182,11 @@ struct rsnd_dai { | |||
174 | struct rsnd_dai_stream playback; | 182 | struct rsnd_dai_stream playback; |
175 | struct rsnd_dai_stream capture; | 183 | struct rsnd_dai_stream capture; |
176 | 184 | ||
177 | int clk_master:1; | 185 | unsigned int clk_master:1; |
178 | int bit_clk_inv:1; | 186 | unsigned int bit_clk_inv:1; |
179 | int frm_clk_inv:1; | 187 | unsigned int frm_clk_inv:1; |
180 | int sys_delay:1; | 188 | unsigned int sys_delay:1; |
181 | int data_alignment:1; | 189 | unsigned int data_alignment:1; |
182 | }; | 190 | }; |
183 | 191 | ||
184 | #define rsnd_dai_nr(priv) ((priv)->dai_nr) | 192 | #define rsnd_dai_nr(priv) ((priv)->dai_nr) |
@@ -229,6 +237,10 @@ int rsnd_adg_probe(struct platform_device *pdev, | |||
229 | struct rsnd_priv *priv); | 237 | struct rsnd_priv *priv); |
230 | void rsnd_adg_remove(struct platform_device *pdev, | 238 | void rsnd_adg_remove(struct platform_device *pdev, |
231 | struct rsnd_priv *priv); | 239 | struct rsnd_priv *priv); |
240 | int rsnd_adg_set_convert_clk(struct rsnd_priv *priv, | ||
241 | struct rsnd_mod *mod, | ||
242 | unsigned int src_rate, | ||
243 | unsigned int dst_rate); | ||
232 | 244 | ||
233 | /* | 245 | /* |
234 | * R-Car sound priv | 246 | * R-Car sound priv |
@@ -282,6 +294,10 @@ void rsnd_scu_remove(struct platform_device *pdev, | |||
282 | struct rsnd_priv *priv); | 294 | struct rsnd_priv *priv); |
283 | struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id); | 295 | struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id); |
284 | bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod); | 296 | bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod); |
297 | unsigned int rsnd_scu_get_ssi_rate(struct rsnd_priv *priv, | ||
298 | struct rsnd_mod *ssi_mod, | ||
299 | struct snd_pcm_runtime *runtime); | ||
300 | |||
285 | #define rsnd_scu_nr(priv) ((priv)->scu_nr) | 301 | #define rsnd_scu_nr(priv) ((priv)->scu_nr) |
286 | 302 | ||
287 | /* | 303 | /* |
diff --git a/sound/soc/sh/rcar/scu.c b/sound/soc/sh/rcar/scu.c index fa8fa15860b9..9bb08bb1d455 100644 --- a/sound/soc/sh/rcar/scu.c +++ b/sound/soc/sh/rcar/scu.c | |||
@@ -13,9 +13,13 @@ | |||
13 | struct rsnd_scu { | 13 | struct rsnd_scu { |
14 | struct rsnd_scu_platform_info *info; /* rcar_snd.h */ | 14 | struct rsnd_scu_platform_info *info; /* rcar_snd.h */ |
15 | struct rsnd_mod mod; | 15 | struct rsnd_mod mod; |
16 | struct clk *clk; | ||
16 | }; | 17 | }; |
17 | 18 | ||
18 | #define rsnd_scu_mode_flags(p) ((p)->info->flags) | 19 | #define rsnd_scu_mode_flags(p) ((p)->info->flags) |
20 | #define rsnd_scu_convert_rate(p) ((p)->info->convert_rate) | ||
21 | |||
22 | #define RSND_SCU_NAME_SIZE 16 | ||
19 | 23 | ||
20 | /* | 24 | /* |
21 | * ADINR | 25 | * ADINR |
@@ -26,6 +30,15 @@ struct rsnd_scu { | |||
26 | #define OTBL_18 (6 << 16) | 30 | #define OTBL_18 (6 << 16) |
27 | #define OTBL_16 (8 << 16) | 31 | #define OTBL_16 (8 << 16) |
28 | 32 | ||
33 | /* | ||
34 | * image of SRC (Sampling Rate Converter) | ||
35 | * | ||
36 | * 96kHz <-> +-----+ 48kHz +-----+ 48kHz +-------+ | ||
37 | * 48kHz <-> | SRC | <------> | SSI | <-----> | codec | | ||
38 | * 44.1kHz <-> +-----+ +-----+ +-------+ | ||
39 | * ... | ||
40 | * | ||
41 | */ | ||
29 | 42 | ||
30 | #define rsnd_mod_to_scu(_mod) \ | 43 | #define rsnd_mod_to_scu(_mod) \ |
31 | container_of((_mod), struct rsnd_scu, mod) | 44 | container_of((_mod), struct rsnd_scu, mod) |
@@ -36,7 +49,8 @@ struct rsnd_scu { | |||
36 | ((pos) = (struct rsnd_scu *)(priv)->scu + i); \ | 49 | ((pos) = (struct rsnd_scu *)(priv)->scu + i); \ |
37 | i++) | 50 | i++) |
38 | 51 | ||
39 | static int rsnd_scu_set_route(struct rsnd_priv *priv, | 52 | /* Gen1 only */ |
53 | static int rsnd_src_set_route_if_gen1(struct rsnd_priv *priv, | ||
40 | struct rsnd_mod *mod, | 54 | struct rsnd_mod *mod, |
41 | struct rsnd_dai *rdai, | 55 | struct rsnd_dai *rdai, |
42 | struct rsnd_dai_stream *io) | 56 | struct rsnd_dai_stream *io) |
@@ -55,7 +69,7 @@ static int rsnd_scu_set_route(struct rsnd_priv *priv, | |||
55 | { 0x3, 28, }, /* 7 */ | 69 | { 0x3, 28, }, /* 7 */ |
56 | { 0x3, 30, }, /* 8 */ | 70 | { 0x3, 30, }, /* 8 */ |
57 | }; | 71 | }; |
58 | 72 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | |
59 | u32 mask; | 73 | u32 mask; |
60 | u32 val; | 74 | u32 val; |
61 | int shift; | 75 | int shift; |
@@ -85,9 +99,18 @@ static int rsnd_scu_set_route(struct rsnd_priv *priv, | |||
85 | */ | 99 | */ |
86 | shift = (id % 4) * 8; | 100 | shift = (id % 4) * 8; |
87 | mask = 0x1F << shift; | 101 | mask = 0x1F << shift; |
88 | if (8 == id) /* SRU8 is very special */ | 102 | |
103 | /* | ||
104 | * ADG is used as source clock if SRC was used, | ||
105 | * then, SSI WS is used as destination clock. | ||
106 | * SSI WS is used as source clock if SRC is not used | ||
107 | * (when playback, source/destination become reverse when capture) | ||
108 | */ | ||
109 | if (rsnd_scu_convert_rate(scu)) /* use ADG */ | ||
110 | val = 0; | ||
111 | else if (8 == id) /* use SSI WS, but SRU8 is special */ | ||
89 | val = id << shift; | 112 | val = id << shift; |
90 | else | 113 | else /* use SSI WS */ |
91 | val = (id + 1) << shift; | 114 | val = (id + 1) << shift; |
92 | 115 | ||
93 | switch (id / 4) { | 116 | switch (id / 4) { |
@@ -105,30 +128,45 @@ static int rsnd_scu_set_route(struct rsnd_priv *priv, | |||
105 | return 0; | 128 | return 0; |
106 | } | 129 | } |
107 | 130 | ||
108 | static int rsnd_scu_set_mode(struct rsnd_priv *priv, | 131 | unsigned int rsnd_scu_get_ssi_rate(struct rsnd_priv *priv, |
109 | struct rsnd_mod *mod, | 132 | struct rsnd_mod *ssi_mod, |
110 | struct rsnd_dai *rdai, | 133 | struct snd_pcm_runtime *runtime) |
111 | struct rsnd_dai_stream *io) | ||
112 | { | 134 | { |
113 | int id = rsnd_mod_id(mod); | 135 | struct rsnd_scu *scu; |
114 | u32 val; | 136 | unsigned int rate; |
115 | 137 | ||
116 | if (rsnd_is_gen1(priv)) { | 138 | /* this function is assuming SSI id = SCU id here */ |
117 | val = (1 << id); | 139 | scu = rsnd_mod_to_scu(rsnd_scu_mod_get(priv, rsnd_mod_id(ssi_mod))); |
118 | rsnd_mod_bset(mod, SRC_CTRL, val, val); | ||
119 | } | ||
120 | 140 | ||
121 | return 0; | 141 | /* |
142 | * return convert rate if SRC is used, | ||
143 | * otherwise, return runtime->rate as usual | ||
144 | */ | ||
145 | rate = rsnd_scu_convert_rate(scu); | ||
146 | if (!rate) | ||
147 | rate = runtime->rate; | ||
148 | |||
149 | return rate; | ||
122 | } | 150 | } |
123 | 151 | ||
124 | static int rsnd_scu_set_hpbif(struct rsnd_priv *priv, | 152 | static int rsnd_scu_convert_rate_ctrl(struct rsnd_priv *priv, |
125 | struct rsnd_mod *mod, | 153 | struct rsnd_mod *mod, |
126 | struct rsnd_dai *rdai, | 154 | struct rsnd_dai *rdai, |
127 | struct rsnd_dai_stream *io) | 155 | struct rsnd_dai_stream *io) |
128 | { | 156 | { |
129 | struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); | 157 | struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); |
158 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | ||
159 | u32 convert_rate = rsnd_scu_convert_rate(scu); | ||
130 | u32 adinr = runtime->channels; | 160 | u32 adinr = runtime->channels; |
131 | 161 | ||
162 | /* set/clear soft reset */ | ||
163 | rsnd_mod_write(mod, SRC_SWRSR, 0); | ||
164 | rsnd_mod_write(mod, SRC_SWRSR, 1); | ||
165 | |||
166 | /* Initialize the operation of the SRC internal circuits */ | ||
167 | rsnd_mod_write(mod, SRC_SRCIR, 1); | ||
168 | |||
169 | /* Set channel number and output bit length */ | ||
132 | switch (runtime->sample_bits) { | 170 | switch (runtime->sample_bits) { |
133 | case 16: | 171 | case 16: |
134 | adinr |= OTBL_16; | 172 | adinr |= OTBL_16; |
@@ -139,9 +177,81 @@ static int rsnd_scu_set_hpbif(struct rsnd_priv *priv, | |||
139 | default: | 177 | default: |
140 | return -EIO; | 178 | return -EIO; |
141 | } | 179 | } |
180 | rsnd_mod_write(mod, SRC_ADINR, adinr); | ||
181 | |||
182 | if (convert_rate) { | ||
183 | u32 fsrate = 0x0400000 / convert_rate * runtime->rate; | ||
184 | int ret; | ||
185 | |||
186 | /* Enable the initial value of IFS */ | ||
187 | rsnd_mod_write(mod, SRC_IFSCR, 1); | ||
188 | |||
189 | /* Set initial value of IFS */ | ||
190 | rsnd_mod_write(mod, SRC_IFSVR, fsrate); | ||
191 | |||
192 | /* Select SRC mode (fixed value) */ | ||
193 | rsnd_mod_write(mod, SRC_SRCCR, 0x00010110); | ||
194 | |||
195 | /* Set the restriction value of the FS ratio (98%) */ | ||
196 | rsnd_mod_write(mod, SRC_MNFSR, fsrate / 100 * 98); | ||
197 | |||
198 | if (rsnd_is_gen1(priv)) { | ||
199 | /* no SRC_BFSSR settings, since SRC_SRCCR::BUFMD is 0 */ | ||
200 | } | ||
142 | 201 | ||
202 | /* set convert clock */ | ||
203 | ret = rsnd_adg_set_convert_clk(priv, mod, | ||
204 | runtime->rate, | ||
205 | convert_rate); | ||
206 | if (ret < 0) | ||
207 | return ret; | ||
208 | } | ||
209 | |||
210 | /* Cancel the initialization and operate the SRC function */ | ||
211 | rsnd_mod_write(mod, SRC_SRCIR, 0); | ||
212 | |||
213 | /* use DMA transfer */ | ||
143 | rsnd_mod_write(mod, BUSIF_MODE, 1); | 214 | rsnd_mod_write(mod, BUSIF_MODE, 1); |
144 | rsnd_mod_write(mod, BUSIF_ADINR, adinr); | 215 | |
216 | return 0; | ||
217 | } | ||
218 | |||
219 | static int rsnd_scu_transfer_start(struct rsnd_priv *priv, | ||
220 | struct rsnd_mod *mod, | ||
221 | struct rsnd_dai *rdai, | ||
222 | struct rsnd_dai_stream *io) | ||
223 | { | ||
224 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | ||
225 | int id = rsnd_mod_id(mod); | ||
226 | u32 val; | ||
227 | |||
228 | if (rsnd_is_gen1(priv)) { | ||
229 | val = (1 << id); | ||
230 | rsnd_mod_bset(mod, SRC_ROUTE_CTRL, val, val); | ||
231 | } | ||
232 | |||
233 | if (rsnd_scu_convert_rate(scu)) | ||
234 | rsnd_mod_write(mod, SRC_ROUTE_MODE0, 1); | ||
235 | |||
236 | return 0; | ||
237 | } | ||
238 | |||
239 | static int rsnd_scu_transfer_stop(struct rsnd_priv *priv, | ||
240 | struct rsnd_mod *mod, | ||
241 | struct rsnd_dai *rdai, | ||
242 | struct rsnd_dai_stream *io) | ||
243 | { | ||
244 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | ||
245 | int id = rsnd_mod_id(mod); | ||
246 | u32 mask; | ||
247 | |||
248 | if (rsnd_is_gen1(priv)) { | ||
249 | mask = (1 << id); | ||
250 | rsnd_mod_bset(mod, SRC_ROUTE_CTRL, mask, 0); | ||
251 | } | ||
252 | |||
253 | if (rsnd_scu_convert_rate(scu)) | ||
254 | rsnd_mod_write(mod, SRC_ROUTE_MODE0, 0); | ||
145 | 255 | ||
146 | return 0; | 256 | return 0; |
147 | } | 257 | } |
@@ -159,6 +269,7 @@ static int rsnd_scu_start(struct rsnd_mod *mod, | |||
159 | struct rsnd_dai_stream *io) | 269 | struct rsnd_dai_stream *io) |
160 | { | 270 | { |
161 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | 271 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); |
272 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | ||
162 | struct device *dev = rsnd_priv_to_dev(priv); | 273 | struct device *dev = rsnd_priv_to_dev(priv); |
163 | int ret; | 274 | int ret; |
164 | 275 | ||
@@ -173,16 +284,19 @@ static int rsnd_scu_start(struct rsnd_mod *mod, | |||
173 | return 0; | 284 | return 0; |
174 | } | 285 | } |
175 | 286 | ||
287 | clk_enable(scu->clk); | ||
288 | |||
176 | /* it use DMA transter */ | 289 | /* it use DMA transter */ |
177 | ret = rsnd_scu_set_route(priv, mod, rdai, io); | 290 | |
291 | ret = rsnd_src_set_route_if_gen1(priv, mod, rdai, io); | ||
178 | if (ret < 0) | 292 | if (ret < 0) |
179 | return ret; | 293 | return ret; |
180 | 294 | ||
181 | ret = rsnd_scu_set_mode(priv, mod, rdai, io); | 295 | ret = rsnd_scu_convert_rate_ctrl(priv, mod, rdai, io); |
182 | if (ret < 0) | 296 | if (ret < 0) |
183 | return ret; | 297 | return ret; |
184 | 298 | ||
185 | ret = rsnd_scu_set_hpbif(priv, mod, rdai, io); | 299 | ret = rsnd_scu_transfer_start(priv, mod, rdai, io); |
186 | if (ret < 0) | 300 | if (ret < 0) |
187 | return ret; | 301 | return ret; |
188 | 302 | ||
@@ -191,9 +305,27 @@ static int rsnd_scu_start(struct rsnd_mod *mod, | |||
191 | return 0; | 305 | return 0; |
192 | } | 306 | } |
193 | 307 | ||
308 | static int rsnd_scu_stop(struct rsnd_mod *mod, | ||
309 | struct rsnd_dai *rdai, | ||
310 | struct rsnd_dai_stream *io) | ||
311 | { | ||
312 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | ||
313 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | ||
314 | |||
315 | if (!rsnd_scu_hpbif_is_enable(mod)) | ||
316 | return 0; | ||
317 | |||
318 | rsnd_scu_transfer_stop(priv, mod, rdai, io); | ||
319 | |||
320 | clk_disable(scu->clk); | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | |||
194 | static struct rsnd_mod_ops rsnd_scu_ops = { | 325 | static struct rsnd_mod_ops rsnd_scu_ops = { |
195 | .name = "scu", | 326 | .name = "scu", |
196 | .start = rsnd_scu_start, | 327 | .start = rsnd_scu_start, |
328 | .stop = rsnd_scu_stop, | ||
197 | }; | 329 | }; |
198 | 330 | ||
199 | struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id) | 331 | struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id) |
@@ -210,6 +342,8 @@ int rsnd_scu_probe(struct platform_device *pdev, | |||
210 | { | 342 | { |
211 | struct device *dev = rsnd_priv_to_dev(priv); | 343 | struct device *dev = rsnd_priv_to_dev(priv); |
212 | struct rsnd_scu *scu; | 344 | struct rsnd_scu *scu; |
345 | struct clk *clk; | ||
346 | char name[RSND_SCU_NAME_SIZE]; | ||
213 | int i, nr; | 347 | int i, nr; |
214 | 348 | ||
215 | /* | 349 | /* |
@@ -226,9 +360,16 @@ int rsnd_scu_probe(struct platform_device *pdev, | |||
226 | priv->scu = scu; | 360 | priv->scu = scu; |
227 | 361 | ||
228 | for_each_rsnd_scu(scu, priv, i) { | 362 | for_each_rsnd_scu(scu, priv, i) { |
363 | snprintf(name, RSND_SCU_NAME_SIZE, "scu.%d", i); | ||
364 | |||
365 | clk = devm_clk_get(dev, name); | ||
366 | if (IS_ERR(clk)) | ||
367 | return PTR_ERR(clk); | ||
368 | |||
229 | rsnd_mod_init(priv, &scu->mod, | 369 | rsnd_mod_init(priv, &scu->mod, |
230 | &rsnd_scu_ops, i); | 370 | &rsnd_scu_ops, i); |
231 | scu->info = &info->scu_info[i]; | 371 | scu->info = &info->scu_info[i]; |
372 | scu->clk = clk; | ||
232 | 373 | ||
233 | dev_dbg(dev, "SCU%d probed\n", i); | 374 | dev_dbg(dev, "SCU%d probed\n", i); |
234 | } | 375 | } |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 5ac20cd5e006..4b8cf7ca9d19 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
@@ -187,9 +187,10 @@ static void rsnd_ssi_status_check(struct rsnd_mod *mod, | |||
187 | } | 187 | } |
188 | 188 | ||
189 | static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi, | 189 | static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi, |
190 | unsigned int rate) | 190 | struct rsnd_dai_stream *io) |
191 | { | 191 | { |
192 | struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod); | 192 | struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod); |
193 | struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); | ||
193 | struct device *dev = rsnd_priv_to_dev(priv); | 194 | struct device *dev = rsnd_priv_to_dev(priv); |
194 | int i, j, ret; | 195 | int i, j, ret; |
195 | int adg_clk_div_table[] = { | 196 | int adg_clk_div_table[] = { |
@@ -199,6 +200,7 @@ static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi, | |||
199 | 1, 2, 4, 8, 16, 6, 12, | 200 | 1, 2, 4, 8, 16, 6, 12, |
200 | }; | 201 | }; |
201 | unsigned int main_rate; | 202 | unsigned int main_rate; |
203 | unsigned int rate = rsnd_scu_get_ssi_rate(priv, &ssi->mod, runtime); | ||
202 | 204 | ||
203 | /* | 205 | /* |
204 | * Find best clock, and try to start ADG | 206 | * Find best clock, and try to start ADG |
@@ -209,7 +211,7 @@ static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi, | |||
209 | /* | 211 | /* |
210 | * this driver is assuming that | 212 | * this driver is assuming that |
211 | * system word is 64fs (= 2 x 32bit) | 213 | * system word is 64fs (= 2 x 32bit) |
212 | * see rsnd_ssi_start() | 214 | * see rsnd_ssi_init() |
213 | */ | 215 | */ |
214 | main_rate = rate / adg_clk_div_table[i] | 216 | main_rate = rate / adg_clk_div_table[i] |
215 | * 32 * 2 * ssi_clk_mul_table[j]; | 217 | * 32 * 2 * ssi_clk_mul_table[j]; |
@@ -251,14 +253,10 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, | |||
251 | clk_enable(ssi->clk); | 253 | clk_enable(ssi->clk); |
252 | 254 | ||
253 | if (rsnd_rdai_is_clk_master(rdai)) { | 255 | if (rsnd_rdai_is_clk_master(rdai)) { |
254 | struct snd_pcm_runtime *runtime; | ||
255 | |||
256 | runtime = rsnd_io_to_runtime(io); | ||
257 | |||
258 | if (rsnd_ssi_clk_from_parent(ssi)) | 256 | if (rsnd_ssi_clk_from_parent(ssi)) |
259 | rsnd_ssi_hw_start(ssi->parent, rdai, io); | 257 | rsnd_ssi_hw_start(ssi->parent, rdai, io); |
260 | else | 258 | else |
261 | rsnd_ssi_master_clk_start(ssi, runtime->rate); | 259 | rsnd_ssi_master_clk_start(ssi, io); |
262 | } | 260 | } |
263 | } | 261 | } |
264 | 262 | ||
@@ -457,6 +455,10 @@ static int rsnd_ssi_pio_start(struct rsnd_mod *mod, | |||
457 | /* enable PIO IRQ */ | 455 | /* enable PIO IRQ */ |
458 | ssi->cr_etc = UIEN | OIEN | DIEN; | 456 | ssi->cr_etc = UIEN | OIEN | DIEN; |
459 | 457 | ||
458 | /* enable PIO interrupt if gen2 */ | ||
459 | if (rsnd_is_gen2(priv)) | ||
460 | rsnd_mod_write(&ssi->mod, INT_ENABLE, 0x0f000000); | ||
461 | |||
460 | rsnd_ssi_hw_start(ssi, rdai, io); | 462 | rsnd_ssi_hw_start(ssi, rdai, io); |
461 | 463 | ||
462 | dev_dbg(dev, "%s.%d start\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); | 464 | dev_dbg(dev, "%s.%d start\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); |
@@ -650,7 +652,7 @@ int rsnd_ssi_probe(struct platform_device *pdev, | |||
650 | 652 | ||
651 | snprintf(name, RSND_SSI_NAME_SIZE, "ssi.%d", i); | 653 | snprintf(name, RSND_SSI_NAME_SIZE, "ssi.%d", i); |
652 | 654 | ||
653 | clk = clk_get(dev, name); | 655 | clk = devm_clk_get(dev, name); |
654 | if (IS_ERR(clk)) | 656 | if (IS_ERR(clk)) |
655 | return PTR_ERR(clk); | 657 | return PTR_ERR(clk); |
656 | 658 | ||
@@ -711,7 +713,6 @@ void rsnd_ssi_remove(struct platform_device *pdev, | |||
711 | int i; | 713 | int i; |
712 | 714 | ||
713 | for_each_rsnd_ssi(ssi, priv, i) { | 715 | for_each_rsnd_ssi(ssi, priv, i) { |
714 | clk_put(ssi->clk); | ||
715 | if (rsnd_ssi_dma_available(ssi)) | 716 | if (rsnd_ssi_dma_available(ssi)) |
716 | rsnd_dma_quit(priv, rsnd_mod_to_dma(&ssi->mod)); | 717 | rsnd_dma_quit(priv, rsnd_mod_to_dma(&ssi->mod)); |
717 | } | 718 | } |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a66783e13a9c..be88df5eeaf7 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -4617,10 +4617,14 @@ int snd_soc_of_get_dai_name(struct device_node *of_node, | |||
4617 | 4617 | ||
4618 | if (id < 0 || id >= pos->num_dai) { | 4618 | if (id < 0 || id >= pos->num_dai) { |
4619 | ret = -EINVAL; | 4619 | ret = -EINVAL; |
4620 | } else { | 4620 | break; |
4621 | *dai_name = pos->dai_drv[id].name; | ||
4622 | ret = 0; | ||
4623 | } | 4621 | } |
4622 | |||
4623 | ret = 0; | ||
4624 | |||
4625 | *dai_name = pos->dai_drv[id].name; | ||
4626 | if (!*dai_name) | ||
4627 | *dai_name = pos->name; | ||
4624 | } | 4628 | } |
4625 | 4629 | ||
4626 | break; | 4630 | break; |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index dcade130157f..67e63ab1f11e 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -2868,6 +2868,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |||
2868 | unsigned int val; | 2868 | unsigned int val; |
2869 | int connect, change; | 2869 | int connect, change; |
2870 | struct snd_soc_dapm_update update; | 2870 | struct snd_soc_dapm_update update; |
2871 | int ret = 0; | ||
2871 | 2872 | ||
2872 | if (snd_soc_volsw_is_stereo(mc)) | 2873 | if (snd_soc_volsw_is_stereo(mc)) |
2873 | dev_warn(codec->dapm.dev, | 2874 | dev_warn(codec->dapm.dev, |
@@ -2901,12 +2902,16 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |||
2901 | card->update = &update; | 2902 | card->update = &update; |
2902 | } | 2903 | } |
2903 | 2904 | ||
2904 | soc_dapm_mixer_update_power(card, kcontrol, connect); | 2905 | ret = soc_dapm_mixer_update_power(card, kcontrol, connect); |
2905 | 2906 | ||
2906 | card->update = NULL; | 2907 | card->update = NULL; |
2907 | } | 2908 | } |
2908 | 2909 | ||
2909 | mutex_unlock(&card->dapm_mutex); | 2910 | mutex_unlock(&card->dapm_mutex); |
2911 | |||
2912 | if (ret > 0) | ||
2913 | soc_dpcm_runtime_update(card); | ||
2914 | |||
2910 | return change; | 2915 | return change; |
2911 | } | 2916 | } |
2912 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw); | 2917 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw); |
@@ -2955,6 +2960,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, | |||
2955 | unsigned int val, mux, change; | 2960 | unsigned int val, mux, change; |
2956 | unsigned int mask; | 2961 | unsigned int mask; |
2957 | struct snd_soc_dapm_update update; | 2962 | struct snd_soc_dapm_update update; |
2963 | int ret = 0; | ||
2958 | 2964 | ||
2959 | if (ucontrol->value.enumerated.item[0] > e->max - 1) | 2965 | if (ucontrol->value.enumerated.item[0] > e->max - 1) |
2960 | return -EINVAL; | 2966 | return -EINVAL; |
@@ -2978,12 +2984,16 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, | |||
2978 | update.val = val; | 2984 | update.val = val; |
2979 | card->update = &update; | 2985 | card->update = &update; |
2980 | 2986 | ||
2981 | soc_dapm_mux_update_power(card, kcontrol, mux, e); | 2987 | ret = soc_dapm_mux_update_power(card, kcontrol, mux, e); |
2982 | 2988 | ||
2983 | card->update = NULL; | 2989 | card->update = NULL; |
2984 | } | 2990 | } |
2985 | 2991 | ||
2986 | mutex_unlock(&card->dapm_mutex); | 2992 | mutex_unlock(&card->dapm_mutex); |
2993 | |||
2994 | if (ret > 0) | ||
2995 | soc_dpcm_runtime_update(card); | ||
2996 | |||
2987 | return change; | 2997 | return change; |
2988 | } | 2998 | } |
2989 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double); | 2999 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double); |
@@ -3019,6 +3029,7 @@ int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol, | |||
3019 | struct soc_enum *e = | 3029 | struct soc_enum *e = |
3020 | (struct soc_enum *)kcontrol->private_value; | 3030 | (struct soc_enum *)kcontrol->private_value; |
3021 | int change; | 3031 | int change; |
3032 | int ret = 0; | ||
3022 | 3033 | ||
3023 | if (ucontrol->value.enumerated.item[0] >= e->max) | 3034 | if (ucontrol->value.enumerated.item[0] >= e->max) |
3024 | return -EINVAL; | 3035 | return -EINVAL; |
@@ -3028,9 +3039,13 @@ int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol, | |||
3028 | value = ucontrol->value.enumerated.item[0]; | 3039 | value = ucontrol->value.enumerated.item[0]; |
3029 | change = dapm_kcontrol_set_value(kcontrol, value); | 3040 | change = dapm_kcontrol_set_value(kcontrol, value); |
3030 | if (change) | 3041 | if (change) |
3031 | soc_dapm_mux_update_power(card, kcontrol, value, e); | 3042 | ret = soc_dapm_mux_update_power(card, kcontrol, value, e); |
3032 | 3043 | ||
3033 | mutex_unlock(&card->dapm_mutex); | 3044 | mutex_unlock(&card->dapm_mutex); |
3045 | |||
3046 | if (ret > 0) | ||
3047 | soc_dpcm_runtime_update(card); | ||
3048 | |||
3034 | return change; | 3049 | return change; |
3035 | } | 3050 | } |
3036 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_virt); | 3051 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_virt); |
@@ -3097,6 +3112,7 @@ int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, | |||
3097 | unsigned int val, mux, change; | 3112 | unsigned int val, mux, change; |
3098 | unsigned int mask; | 3113 | unsigned int mask; |
3099 | struct snd_soc_dapm_update update; | 3114 | struct snd_soc_dapm_update update; |
3115 | int ret = 0; | ||
3100 | 3116 | ||
3101 | if (ucontrol->value.enumerated.item[0] > e->max - 1) | 3117 | if (ucontrol->value.enumerated.item[0] > e->max - 1) |
3102 | return -EINVAL; | 3118 | return -EINVAL; |
@@ -3120,12 +3136,16 @@ int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, | |||
3120 | update.val = val; | 3136 | update.val = val; |
3121 | card->update = &update; | 3137 | card->update = &update; |
3122 | 3138 | ||
3123 | soc_dapm_mux_update_power(card, kcontrol, mux, e); | 3139 | ret = soc_dapm_mux_update_power(card, kcontrol, mux, e); |
3124 | 3140 | ||
3125 | card->update = NULL; | 3141 | card->update = NULL; |
3126 | } | 3142 | } |
3127 | 3143 | ||
3128 | mutex_unlock(&card->dapm_mutex); | 3144 | mutex_unlock(&card->dapm_mutex); |
3145 | |||
3146 | if (ret > 0) | ||
3147 | soc_dpcm_runtime_update(card); | ||
3148 | |||
3129 | return change; | 3149 | return change; |
3130 | } | 3150 | } |
3131 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double); | 3151 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double); |
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c index 3449c1e909ae..7ac745df1412 100644 --- a/sound/soc/soc-devres.c +++ b/sound/soc/soc-devres.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/moduleparam.h> | 13 | #include <linux/moduleparam.h> |
14 | #include <sound/soc.h> | 14 | #include <sound/soc.h> |
15 | #include <sound/dmaengine_pcm.h> | ||
15 | 16 | ||
16 | static void devm_component_release(struct device *dev, void *res) | 17 | static void devm_component_release(struct device *dev, void *res) |
17 | { | 18 | { |
@@ -84,3 +85,43 @@ int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card) | |||
84 | return ret; | 85 | return ret; |
85 | } | 86 | } |
86 | EXPORT_SYMBOL_GPL(devm_snd_soc_register_card); | 87 | EXPORT_SYMBOL_GPL(devm_snd_soc_register_card); |
88 | |||
89 | #ifdef CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM | ||
90 | |||
91 | static void devm_dmaengine_pcm_release(struct device *dev, void *res) | ||
92 | { | ||
93 | snd_dmaengine_pcm_unregister(*(struct device **)res); | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration | ||
98 | * @dev: The parent device for the PCM device | ||
99 | * @config: Platform specific PCM configuration | ||
100 | * @flags: Platform specific quirks | ||
101 | * | ||
102 | * Register a dmaengine based PCM device with automatic unregistration when the | ||
103 | * device is unregistered. | ||
104 | */ | ||
105 | int devm_snd_dmaengine_pcm_register(struct device *dev, | ||
106 | const struct snd_dmaengine_pcm_config *config, unsigned int flags) | ||
107 | { | ||
108 | struct device **ptr; | ||
109 | int ret; | ||
110 | |||
111 | ptr = devres_alloc(devm_dmaengine_pcm_release, sizeof(*ptr), GFP_KERNEL); | ||
112 | if (!ptr) | ||
113 | return -ENOMEM; | ||
114 | |||
115 | ret = snd_dmaengine_pcm_register(dev, config, flags); | ||
116 | if (ret == 0) { | ||
117 | *ptr = dev; | ||
118 | devres_add(dev, ptr); | ||
119 | } else { | ||
120 | devres_free(ptr); | ||
121 | } | ||
122 | |||
123 | return ret; | ||
124 | } | ||
125 | EXPORT_SYMBOL_GPL(devm_snd_dmaengine_pcm_register); | ||
126 | |||
127 | #endif | ||
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 41949af3baae..2a6c569d991f 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c | |||
@@ -137,6 +137,9 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea | |||
137 | hw.buffer_bytes_max = SIZE_MAX; | 137 | hw.buffer_bytes_max = SIZE_MAX; |
138 | hw.fifo_size = dma_data->fifo_size; | 138 | hw.fifo_size = dma_data->fifo_size; |
139 | 139 | ||
140 | if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) | ||
141 | hw.info |= SNDRV_PCM_INFO_BATCH; | ||
142 | |||
140 | ret = dma_get_slave_caps(chan, &dma_caps); | 143 | ret = dma_get_slave_caps(chan, &dma_caps); |
141 | if (ret == 0) { | 144 | if (ret == 0) { |
142 | if (dma_caps.cmd_pause) | 145 | if (dma_caps.cmd_pause) |
@@ -284,25 +287,54 @@ static const char * const dmaengine_pcm_dma_channel_names[] = { | |||
284 | [SNDRV_PCM_STREAM_CAPTURE] = "rx", | 287 | [SNDRV_PCM_STREAM_CAPTURE] = "rx", |
285 | }; | 288 | }; |
286 | 289 | ||
287 | static void dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm, | 290 | static int dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm, |
288 | struct device *dev) | 291 | struct device *dev, const struct snd_dmaengine_pcm_config *config) |
289 | { | 292 | { |
290 | unsigned int i; | 293 | unsigned int i; |
294 | const char *name; | ||
295 | struct dma_chan *chan; | ||
291 | 296 | ||
292 | if ((pcm->flags & (SND_DMAENGINE_PCM_FLAG_NO_DT | | 297 | if ((pcm->flags & (SND_DMAENGINE_PCM_FLAG_NO_DT | |
293 | SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) || | 298 | SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) || |
294 | !dev->of_node) | 299 | !dev->of_node) |
295 | return; | 300 | return 0; |
301 | |||
302 | if (config && config->dma_dev) { | ||
303 | /* | ||
304 | * If this warning is seen, it probably means that your Linux | ||
305 | * device structure does not match your HW device structure. | ||
306 | * It would be best to refactor the Linux device structure to | ||
307 | * correctly match the HW structure. | ||
308 | */ | ||
309 | dev_warn(dev, "DMA channels sourced from device %s", | ||
310 | dev_name(config->dma_dev)); | ||
311 | dev = config->dma_dev; | ||
312 | } | ||
296 | 313 | ||
297 | if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) { | 314 | for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; |
298 | pcm->chan[0] = dma_request_slave_channel(dev, "rx-tx"); | 315 | i++) { |
299 | pcm->chan[1] = pcm->chan[0]; | 316 | if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) |
300 | } else { | 317 | name = "rx-tx"; |
301 | for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { | 318 | else |
302 | pcm->chan[i] = dma_request_slave_channel(dev, | 319 | name = dmaengine_pcm_dma_channel_names[i]; |
303 | dmaengine_pcm_dma_channel_names[i]); | 320 | if (config && config->chan_names[i]) |
321 | name = config->chan_names[i]; | ||
322 | chan = dma_request_slave_channel_reason(dev, name); | ||
323 | if (IS_ERR(chan)) { | ||
324 | if (PTR_ERR(chan) == -EPROBE_DEFER) | ||
325 | return -EPROBE_DEFER; | ||
326 | pcm->chan[i] = NULL; | ||
327 | } else { | ||
328 | pcm->chan[i] = chan; | ||
304 | } | 329 | } |
330 | if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) | ||
331 | break; | ||
305 | } | 332 | } |
333 | |||
334 | if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) | ||
335 | pcm->chan[1] = pcm->chan[0]; | ||
336 | |||
337 | return 0; | ||
306 | } | 338 | } |
307 | 339 | ||
308 | static void dmaengine_pcm_release_chan(struct dmaengine_pcm *pcm) | 340 | static void dmaengine_pcm_release_chan(struct dmaengine_pcm *pcm) |
@@ -338,7 +370,9 @@ int snd_dmaengine_pcm_register(struct device *dev, | |||
338 | pcm->config = config; | 370 | pcm->config = config; |
339 | pcm->flags = flags; | 371 | pcm->flags = flags; |
340 | 372 | ||
341 | dmaengine_pcm_request_chan_of(pcm, dev); | 373 | ret = dmaengine_pcm_request_chan_of(pcm, dev, config); |
374 | if (ret) | ||
375 | goto err_free_dma; | ||
342 | 376 | ||
343 | if (flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) | 377 | if (flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) |
344 | ret = snd_soc_add_platform(dev, &pcm->platform, | 378 | ret = snd_soc_add_platform(dev, &pcm->platform, |
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 4f11d23f2062..aa886cca3ecf 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c | |||
@@ -99,14 +99,14 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, | |||
99 | config.val_bits = data_bits; | 99 | config.val_bits = data_bits; |
100 | 100 | ||
101 | switch (control) { | 101 | switch (control) { |
102 | #if defined(CONFIG_REGMAP_I2C) || defined(CONFIG_REGMAP_I2C_MODULE) | 102 | #if IS_ENABLED(CONFIG_REGMAP_I2C) |
103 | case SND_SOC_I2C: | 103 | case SND_SOC_I2C: |
104 | codec->control_data = regmap_init_i2c(to_i2c_client(codec->dev), | 104 | codec->control_data = regmap_init_i2c(to_i2c_client(codec->dev), |
105 | &config); | 105 | &config); |
106 | break; | 106 | break; |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | #if defined(CONFIG_REGMAP_SPI) || defined(CONFIG_REGMAP_SPI_MODULE) | 109 | #if IS_ENABLED(CONFIG_REGMAP_SPI) |
110 | case SND_SOC_SPI: | 110 | case SND_SOC_SPI: |
111 | codec->control_data = regmap_init_spi(to_spi_device(codec->dev), | 111 | codec->control_data = regmap_init_spi(to_spi_device(codec->dev), |
112 | &config); | 112 | &config); |
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 891b9a9bcbf8..604e7e9a2ef8 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c | |||
@@ -84,35 +84,117 @@ static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream, | |||
84 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 84 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
85 | int ret; | 85 | int ret; |
86 | 86 | ||
87 | if (!soc_dai->driver->symmetric_rates && | 87 | if (soc_dai->rate && (soc_dai->driver->symmetric_rates || |
88 | !rtd->dai_link->symmetric_rates) | 88 | rtd->dai_link->symmetric_rates)) { |
89 | return 0; | 89 | dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %dHz rate\n", |
90 | soc_dai->rate); | ||
91 | |||
92 | ret = snd_pcm_hw_constraint_minmax(substream->runtime, | ||
93 | SNDRV_PCM_HW_PARAM_RATE, | ||
94 | soc_dai->rate, soc_dai->rate); | ||
95 | if (ret < 0) { | ||
96 | dev_err(soc_dai->dev, | ||
97 | "ASoC: Unable to apply rate constraint: %d\n", | ||
98 | ret); | ||
99 | return ret; | ||
100 | } | ||
101 | } | ||
90 | 102 | ||
91 | /* This can happen if multiple streams are starting simultaneously - | 103 | if (soc_dai->channels && (soc_dai->driver->symmetric_channels || |
92 | * the second can need to get its constraints before the first has | 104 | rtd->dai_link->symmetric_channels)) { |
93 | * picked a rate. Complain and allow the application to carry on. | 105 | dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %d channel(s)\n", |
94 | */ | 106 | soc_dai->channels); |
95 | if (!soc_dai->rate) { | 107 | |
96 | dev_warn(soc_dai->dev, | 108 | ret = snd_pcm_hw_constraint_minmax(substream->runtime, |
97 | "ASoC: Not enforcing symmetric_rates due to race\n"); | 109 | SNDRV_PCM_HW_PARAM_CHANNELS, |
98 | return 0; | 110 | soc_dai->channels, |
111 | soc_dai->channels); | ||
112 | if (ret < 0) { | ||
113 | dev_err(soc_dai->dev, | ||
114 | "ASoC: Unable to apply channel symmetry constraint: %d\n", | ||
115 | ret); | ||
116 | return ret; | ||
117 | } | ||
99 | } | 118 | } |
100 | 119 | ||
101 | dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %dHz rate\n", soc_dai->rate); | 120 | if (soc_dai->sample_bits && (soc_dai->driver->symmetric_samplebits || |
121 | rtd->dai_link->symmetric_samplebits)) { | ||
122 | dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %d sample bits\n", | ||
123 | soc_dai->sample_bits); | ||
102 | 124 | ||
103 | ret = snd_pcm_hw_constraint_minmax(substream->runtime, | 125 | ret = snd_pcm_hw_constraint_minmax(substream->runtime, |
104 | SNDRV_PCM_HW_PARAM_RATE, | 126 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, |
105 | soc_dai->rate, soc_dai->rate); | 127 | soc_dai->sample_bits, |
106 | if (ret < 0) { | 128 | soc_dai->sample_bits); |
107 | dev_err(soc_dai->dev, | 129 | if (ret < 0) { |
108 | "ASoC: Unable to apply rate symmetry constraint: %d\n", | 130 | dev_err(soc_dai->dev, |
109 | ret); | 131 | "ASoC: Unable to apply sample bits symmetry constraint: %d\n", |
110 | return ret; | 132 | ret); |
133 | return ret; | ||
134 | } | ||
111 | } | 135 | } |
112 | 136 | ||
113 | return 0; | 137 | return 0; |
114 | } | 138 | } |
115 | 139 | ||
140 | static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, | ||
141 | struct snd_pcm_hw_params *params) | ||
142 | { | ||
143 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
144 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
145 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
146 | unsigned int rate, channels, sample_bits, symmetry; | ||
147 | |||
148 | rate = params_rate(params); | ||
149 | channels = params_channels(params); | ||
150 | sample_bits = snd_pcm_format_physical_width(params_format(params)); | ||
151 | |||
152 | /* reject unmatched parameters when applying symmetry */ | ||
153 | symmetry = cpu_dai->driver->symmetric_rates || | ||
154 | codec_dai->driver->symmetric_rates || | ||
155 | rtd->dai_link->symmetric_rates; | ||
156 | if (symmetry && cpu_dai->rate && cpu_dai->rate != rate) { | ||
157 | dev_err(rtd->dev, "ASoC: unmatched rate symmetry: %d - %d\n", | ||
158 | cpu_dai->rate, rate); | ||
159 | return -EINVAL; | ||
160 | } | ||
161 | |||
162 | symmetry = cpu_dai->driver->symmetric_channels || | ||
163 | codec_dai->driver->symmetric_channels || | ||
164 | rtd->dai_link->symmetric_channels; | ||
165 | if (symmetry && cpu_dai->channels && cpu_dai->channels != channels) { | ||
166 | dev_err(rtd->dev, "ASoC: unmatched channel symmetry: %d - %d\n", | ||
167 | cpu_dai->channels, channels); | ||
168 | return -EINVAL; | ||
169 | } | ||
170 | |||
171 | symmetry = cpu_dai->driver->symmetric_samplebits || | ||
172 | codec_dai->driver->symmetric_samplebits || | ||
173 | rtd->dai_link->symmetric_samplebits; | ||
174 | if (symmetry && cpu_dai->sample_bits && cpu_dai->sample_bits != sample_bits) { | ||
175 | dev_err(rtd->dev, "ASoC: unmatched sample bits symmetry: %d - %d\n", | ||
176 | cpu_dai->sample_bits, sample_bits); | ||
177 | return -EINVAL; | ||
178 | } | ||
179 | |||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream) | ||
184 | { | ||
185 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
186 | struct snd_soc_dai_driver *cpu_driver = rtd->cpu_dai->driver; | ||
187 | struct snd_soc_dai_driver *codec_driver = rtd->codec_dai->driver; | ||
188 | struct snd_soc_dai_link *link = rtd->dai_link; | ||
189 | |||
190 | return cpu_driver->symmetric_rates || codec_driver->symmetric_rates || | ||
191 | link->symmetric_rates || cpu_driver->symmetric_channels || | ||
192 | codec_driver->symmetric_channels || link->symmetric_channels || | ||
193 | cpu_driver->symmetric_samplebits || | ||
194 | codec_driver->symmetric_samplebits || | ||
195 | link->symmetric_samplebits; | ||
196 | } | ||
197 | |||
116 | /* | 198 | /* |
117 | * List of sample sizes that might go over the bus for parameter | 199 | * List of sample sizes that might go over the bus for parameter |
118 | * application. There ought to be a wildcard sample size for things | 200 | * application. There ought to be a wildcard sample size for things |
@@ -249,6 +331,9 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
249 | &cpu_dai_drv->capture); | 331 | &cpu_dai_drv->capture); |
250 | } | 332 | } |
251 | 333 | ||
334 | if (soc_pcm_has_symmetry(substream)) | ||
335 | runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX; | ||
336 | |||
252 | ret = -EINVAL; | 337 | ret = -EINVAL; |
253 | if (!runtime->hw.rates) { | 338 | if (!runtime->hw.rates) { |
254 | printk(KERN_ERR "ASoC: %s <-> %s No matching rates\n", | 339 | printk(KERN_ERR "ASoC: %s <-> %s No matching rates\n", |
@@ -396,11 +481,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) | |||
396 | if (!codec_dai->active) | 481 | if (!codec_dai->active) |
397 | codec_dai->rate = 0; | 482 | codec_dai->rate = 0; |
398 | 483 | ||
399 | /* Muting the DAC suppresses artifacts caused during digital | ||
400 | * shutdown, for example from stopping clocks. | ||
401 | */ | ||
402 | snd_soc_dai_digital_mute(codec_dai, 1, substream->stream); | ||
403 | |||
404 | if (cpu_dai->driver->ops->shutdown) | 484 | if (cpu_dai->driver->ops->shutdown) |
405 | cpu_dai->driver->ops->shutdown(substream, cpu_dai); | 485 | cpu_dai->driver->ops->shutdown(substream, cpu_dai); |
406 | 486 | ||
@@ -531,6 +611,10 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
531 | 611 | ||
532 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 612 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
533 | 613 | ||
614 | ret = soc_pcm_params_symmetry(substream, params); | ||
615 | if (ret) | ||
616 | goto out; | ||
617 | |||
534 | if (rtd->dai_link->ops && rtd->dai_link->ops->hw_params) { | 618 | if (rtd->dai_link->ops && rtd->dai_link->ops->hw_params) { |
535 | ret = rtd->dai_link->ops->hw_params(substream, params); | 619 | ret = rtd->dai_link->ops->hw_params(substream, params); |
536 | if (ret < 0) { | 620 | if (ret < 0) { |
@@ -567,9 +651,16 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
567 | } | 651 | } |
568 | } | 652 | } |
569 | 653 | ||
570 | /* store the rate for each DAIs */ | 654 | /* store the parameters for each DAIs */ |
571 | cpu_dai->rate = params_rate(params); | 655 | cpu_dai->rate = params_rate(params); |
656 | cpu_dai->channels = params_channels(params); | ||
657 | cpu_dai->sample_bits = | ||
658 | snd_pcm_format_physical_width(params_format(params)); | ||
659 | |||
572 | codec_dai->rate = params_rate(params); | 660 | codec_dai->rate = params_rate(params); |
661 | codec_dai->channels = params_channels(params); | ||
662 | codec_dai->sample_bits = | ||
663 | snd_pcm_format_physical_width(params_format(params)); | ||
573 | 664 | ||
574 | out: | 665 | out: |
575 | mutex_unlock(&rtd->pcm_mutex); | 666 | mutex_unlock(&rtd->pcm_mutex); |
@@ -604,6 +695,19 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) | |||
604 | 695 | ||
605 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 696 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
606 | 697 | ||
698 | /* clear the corresponding DAIs parameters when going to be inactive */ | ||
699 | if (cpu_dai->active == 1) { | ||
700 | cpu_dai->rate = 0; | ||
701 | cpu_dai->channels = 0; | ||
702 | cpu_dai->sample_bits = 0; | ||
703 | } | ||
704 | |||
705 | if (codec_dai->active == 1) { | ||
706 | codec_dai->rate = 0; | ||
707 | codec_dai->channels = 0; | ||
708 | codec_dai->sample_bits = 0; | ||
709 | } | ||
710 | |||
607 | /* apply codec digital mute */ | 711 | /* apply codec digital mute */ |
608 | if ((playback && codec_dai->playback_active == 1) || | 712 | if ((playback && codec_dai->playback_active == 1) || |
609 | (!playback && codec_dai->capture_active == 1)) | 713 | (!playback && codec_dai->capture_active == 1)) |
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index 5e633659c1b3..6ebdfd9a1a1d 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c | |||
@@ -59,10 +59,6 @@ int snd_soc_params_to_bclk(struct snd_pcm_hw_params *params) | |||
59 | EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk); | 59 | EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk); |
60 | 60 | ||
61 | static const struct snd_pcm_hardware dummy_dma_hardware = { | 61 | static const struct snd_pcm_hardware dummy_dma_hardware = { |
62 | .formats = 0xffffffff, | ||
63 | .channels_min = 1, | ||
64 | .channels_max = UINT_MAX, | ||
65 | |||
66 | /* Random values to keep userspace happy when checking constraints */ | 62 | /* Random values to keep userspace happy when checking constraints */ |
67 | .info = SNDRV_PCM_INFO_INTERLEAVED | | 63 | .info = SNDRV_PCM_INFO_INTERLEAVED | |
68 | SNDRV_PCM_INFO_BLOCK_TRANSFER, | 64 | SNDRV_PCM_INFO_BLOCK_TRANSFER, |
diff --git a/sound/soc/spear/spdif_in.c b/sound/soc/spear/spdif_in.c index 21a8c954af1c..4ab442a63d7e 100644 --- a/sound/soc/spear/spdif_in.c +++ b/sound/soc/spear/spdif_in.c | |||
@@ -18,12 +18,14 @@ | |||
18 | #include <linux/ioport.h> | 18 | #include <linux/ioport.h> |
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <sound/dmaengine_pcm.h> | ||
21 | #include <sound/pcm.h> | 22 | #include <sound/pcm.h> |
22 | #include <sound/pcm_params.h> | 23 | #include <sound/pcm_params.h> |
23 | #include <sound/soc.h> | 24 | #include <sound/soc.h> |
24 | #include <sound/spear_dma.h> | 25 | #include <sound/spear_dma.h> |
25 | #include <sound/spear_spdif.h> | 26 | #include <sound/spear_spdif.h> |
26 | #include "spdif_in_regs.h" | 27 | #include "spdif_in_regs.h" |
28 | #include "spear_pcm.h" | ||
27 | 29 | ||
28 | struct spdif_in_params { | 30 | struct spdif_in_params { |
29 | u32 format; | 31 | u32 format; |
@@ -37,6 +39,8 @@ struct spdif_in_dev { | |||
37 | struct device *dev; | 39 | struct device *dev; |
38 | void (*reset_perip)(void); | 40 | void (*reset_perip)(void); |
39 | int irq; | 41 | int irq; |
42 | struct snd_dmaengine_dai_dma_data dma_params_rx; | ||
43 | struct snd_dmaengine_pcm_config config; | ||
40 | }; | 44 | }; |
41 | 45 | ||
42 | static void spdif_in_configure(struct spdif_in_dev *host) | 46 | static void spdif_in_configure(struct spdif_in_dev *host) |
@@ -53,7 +57,8 @@ static int spdif_in_dai_probe(struct snd_soc_dai *dai) | |||
53 | { | 57 | { |
54 | struct spdif_in_dev *host = snd_soc_dai_get_drvdata(dai); | 58 | struct spdif_in_dev *host = snd_soc_dai_get_drvdata(dai); |
55 | 59 | ||
56 | dai->capture_dma_data = &host->dma_params; | 60 | host->dma_params_rx.filter_data = &host->dma_params; |
61 | dai->capture_dma_data = &host->dma_params_rx; | ||
57 | 62 | ||
58 | return 0; | 63 | return 0; |
59 | } | 64 | } |
@@ -244,7 +249,6 @@ static int spdif_in_probe(struct platform_device *pdev) | |||
244 | host->dma_params.addr = res_fifo->start; | 249 | host->dma_params.addr = res_fifo->start; |
245 | host->dma_params.max_burst = 16; | 250 | host->dma_params.max_burst = 16; |
246 | host->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | 251 | host->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
247 | host->dma_params.filter = pdata->filter; | ||
248 | host->reset_perip = pdata->reset_perip; | 252 | host->reset_perip = pdata->reset_perip; |
249 | 253 | ||
250 | host->dev = &pdev->dev; | 254 | host->dev = &pdev->dev; |
@@ -257,8 +261,13 @@ static int spdif_in_probe(struct platform_device *pdev) | |||
257 | return ret; | 261 | return ret; |
258 | } | 262 | } |
259 | 263 | ||
260 | return devm_snd_soc_register_component(&pdev->dev, &spdif_in_component, | 264 | ret = devm_snd_soc_register_component(&pdev->dev, &spdif_in_component, |
261 | &spdif_in_dai, 1); | 265 | &spdif_in_dai, 1); |
266 | if (ret) | ||
267 | return ret; | ||
268 | |||
269 | return devm_spear_pcm_platform_register(&pdev->dev, &host->config, | ||
270 | pdata->filter); | ||
262 | } | 271 | } |
263 | 272 | ||
264 | static struct platform_driver spdif_in_driver = { | 273 | static struct platform_driver spdif_in_driver = { |
diff --git a/sound/soc/spear/spdif_out.c b/sound/soc/spear/spdif_out.c index b6ef6f78dc78..fe99f461aff0 100644 --- a/sound/soc/spear/spdif_out.c +++ b/sound/soc/spear/spdif_out.c | |||
@@ -18,10 +18,12 @@ | |||
18 | #include <linux/ioport.h> | 18 | #include <linux/ioport.h> |
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <sound/dmaengine_pcm.h> | ||
21 | #include <sound/soc.h> | 22 | #include <sound/soc.h> |
22 | #include <sound/spear_dma.h> | 23 | #include <sound/spear_dma.h> |
23 | #include <sound/spear_spdif.h> | 24 | #include <sound/spear_spdif.h> |
24 | #include "spdif_out_regs.h" | 25 | #include "spdif_out_regs.h" |
26 | #include "spear_pcm.h" | ||
25 | 27 | ||
26 | struct spdif_out_params { | 28 | struct spdif_out_params { |
27 | u32 rate; | 29 | u32 rate; |
@@ -35,6 +37,8 @@ struct spdif_out_dev { | |||
35 | struct spdif_out_params saved_params; | 37 | struct spdif_out_params saved_params; |
36 | u32 running; | 38 | u32 running; |
37 | void __iomem *io_base; | 39 | void __iomem *io_base; |
40 | struct snd_dmaengine_dai_dma_data dma_params_tx; | ||
41 | struct snd_dmaengine_pcm_config config; | ||
38 | }; | 42 | }; |
39 | 43 | ||
40 | static void spdif_out_configure(struct spdif_out_dev *host) | 44 | static void spdif_out_configure(struct spdif_out_dev *host) |
@@ -244,7 +248,8 @@ static int spdif_soc_dai_probe(struct snd_soc_dai *dai) | |||
244 | { | 248 | { |
245 | struct spdif_out_dev *host = snd_soc_dai_get_drvdata(dai); | 249 | struct spdif_out_dev *host = snd_soc_dai_get_drvdata(dai); |
246 | 250 | ||
247 | dai->playback_dma_data = &host->dma_params; | 251 | host->dma_params_tx.filter_data = &host->dma_params; |
252 | dai->playback_dma_data = &host->dma_params_tx; | ||
248 | 253 | ||
249 | return snd_soc_add_dai_controls(dai, spdif_out_controls, | 254 | return snd_soc_add_dai_controls(dai, spdif_out_controls, |
250 | ARRAY_SIZE(spdif_out_controls)); | 255 | ARRAY_SIZE(spdif_out_controls)); |
@@ -280,6 +285,7 @@ static int spdif_out_probe(struct platform_device *pdev) | |||
280 | struct spdif_out_dev *host; | 285 | struct spdif_out_dev *host; |
281 | struct spear_spdif_platform_data *pdata; | 286 | struct spear_spdif_platform_data *pdata; |
282 | struct resource *res; | 287 | struct resource *res; |
288 | int ret; | ||
283 | 289 | ||
284 | host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); | 290 | host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); |
285 | if (!host) { | 291 | if (!host) { |
@@ -302,12 +308,16 @@ static int spdif_out_probe(struct platform_device *pdev) | |||
302 | host->dma_params.addr = res->start + SPDIF_OUT_FIFO_DATA; | 308 | host->dma_params.addr = res->start + SPDIF_OUT_FIFO_DATA; |
303 | host->dma_params.max_burst = 16; | 309 | host->dma_params.max_burst = 16; |
304 | host->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | 310 | host->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
305 | host->dma_params.filter = pdata->filter; | ||
306 | 311 | ||
307 | dev_set_drvdata(&pdev->dev, host); | 312 | dev_set_drvdata(&pdev->dev, host); |
308 | 313 | ||
309 | return devm_snd_soc_register_component(&pdev->dev, &spdif_out_component, | 314 | ret = devm_snd_soc_register_component(&pdev->dev, &spdif_out_component, |
310 | &spdif_out_dai, 1); | 315 | &spdif_out_dai, 1); |
316 | if (ret) | ||
317 | return ret; | ||
318 | |||
319 | return devm_spear_pcm_platform_register(&pdev->dev, &host->config, | ||
320 | pdata->filter); | ||
311 | } | 321 | } |
312 | 322 | ||
313 | #ifdef CONFIG_PM | 323 | #ifdef CONFIG_PM |
diff --git a/sound/soc/spear/spear_pcm.c b/sound/soc/spear/spear_pcm.c index 4707f2b862c3..0e5a8f35d0ad 100644 --- a/sound/soc/spear/spear_pcm.c +++ b/sound/soc/spear/spear_pcm.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <sound/pcm.h> | 18 | #include <sound/pcm.h> |
19 | #include <sound/soc.h> | 19 | #include <sound/soc.h> |
20 | #include <sound/spear_dma.h> | 20 | #include <sound/spear_dma.h> |
21 | #include "spear_pcm.h" | ||
21 | 22 | ||
22 | static const struct snd_pcm_hardware spear_pcm_hardware = { | 23 | static const struct snd_pcm_hardware spear_pcm_hardware = { |
23 | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 24 | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
@@ -31,49 +32,24 @@ static const struct snd_pcm_hardware spear_pcm_hardware = { | |||
31 | .fifo_size = 0, /* fifo size in bytes */ | 32 | .fifo_size = 0, /* fifo size in bytes */ |
32 | }; | 33 | }; |
33 | 34 | ||
34 | static struct dma_chan *spear_pcm_request_chan(struct snd_soc_pcm_runtime *rtd, | ||
35 | struct snd_pcm_substream *substream) | ||
36 | { | ||
37 | struct spear_dma_data *dma_data; | ||
38 | |||
39 | dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
40 | |||
41 | return snd_dmaengine_pcm_request_channel(dma_data->filter, dma_data); | ||
42 | } | ||
43 | |||
44 | static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = { | 35 | static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = { |
45 | .pcm_hardware = &spear_pcm_hardware, | 36 | .pcm_hardware = &spear_pcm_hardware, |
46 | .compat_request_channel = spear_pcm_request_chan, | ||
47 | .prealloc_buffer_size = 16 * 1024, | 37 | .prealloc_buffer_size = 16 * 1024, |
48 | }; | 38 | }; |
49 | 39 | ||
50 | static int spear_soc_platform_probe(struct platform_device *pdev) | 40 | int devm_spear_pcm_platform_register(struct device *dev, |
41 | struct snd_dmaengine_pcm_config *config, | ||
42 | bool (*filter)(struct dma_chan *chan, void *slave)) | ||
51 | { | 43 | { |
52 | return snd_dmaengine_pcm_register(&pdev->dev, | 44 | *config = spear_dmaengine_pcm_config; |
53 | &spear_dmaengine_pcm_config, | 45 | config->compat_filter_fn = filter; |
46 | |||
47 | return snd_dmaengine_pcm_register(dev, config, | ||
54 | SND_DMAENGINE_PCM_FLAG_NO_DT | | 48 | SND_DMAENGINE_PCM_FLAG_NO_DT | |
55 | SND_DMAENGINE_PCM_FLAG_COMPAT); | 49 | SND_DMAENGINE_PCM_FLAG_COMPAT); |
56 | } | 50 | } |
57 | 51 | EXPORT_SYMBOL_GPL(devm_spear_pcm_platform_register); | |
58 | static int spear_soc_platform_remove(struct platform_device *pdev) | ||
59 | { | ||
60 | snd_dmaengine_pcm_unregister(&pdev->dev); | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static struct platform_driver spear_pcm_driver = { | ||
65 | .driver = { | ||
66 | .name = "spear-pcm-audio", | ||
67 | .owner = THIS_MODULE, | ||
68 | }, | ||
69 | |||
70 | .probe = spear_soc_platform_probe, | ||
71 | .remove = spear_soc_platform_remove, | ||
72 | }; | ||
73 | |||
74 | module_platform_driver(spear_pcm_driver); | ||
75 | 52 | ||
76 | MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>"); | 53 | MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>"); |
77 | MODULE_DESCRIPTION("SPEAr PCM DMA module"); | 54 | MODULE_DESCRIPTION("SPEAr PCM DMA module"); |
78 | MODULE_LICENSE("GPL"); | 55 | MODULE_LICENSE("GPL"); |
79 | MODULE_ALIAS("platform:spear-pcm-audio"); | ||
diff --git a/sound/soc/spear/spear_pcm.h b/sound/soc/spear/spear_pcm.h new file mode 100644 index 000000000000..9b0ca62d6f02 --- /dev/null +++ b/sound/soc/spear/spear_pcm.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #ifndef __SPEAR_PCM_H__ | ||
18 | #define __SPEAR_PCM_H__ | ||
19 | |||
20 | int devm_spear_pcm_platform_register(struct device *dev, | ||
21 | struct snd_dmaengine_pcm_config *config, | ||
22 | bool (*filter)(struct dma_chan *chan, void *slave)); | ||
23 | |||
24 | #endif | ||
diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index 8fc653ca3ab4..65a85f542521 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig | |||
@@ -116,3 +116,13 @@ config SND_SOC_TEGRA_ALC5632 | |||
116 | help | 116 | help |
117 | Say Y or M here if you want to add support for SoC audio on the | 117 | Say Y or M here if you want to add support for SoC audio on the |
118 | Toshiba AC100 netbook. | 118 | Toshiba AC100 netbook. |
119 | |||
120 | config SND_SOC_TEGRA_MAX98090 | ||
121 | tristate "SoC Audio support for Tegra boards using a MAX98090 codec" | ||
122 | depends on SND_SOC_TEGRA && I2C && GPIOLIB | ||
123 | select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC | ||
124 | select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC | ||
125 | select SND_SOC_MAX98090 | ||
126 | help | ||
127 | Say Y or M here if you want to add support for SoC audio on Tegra | ||
128 | boards using the MAX98090 codec, such as Venice2. | ||
diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile index 21d2550a08a4..5ae588cd96c4 100644 --- a/sound/soc/tegra/Makefile +++ b/sound/soc/tegra/Makefile | |||
@@ -24,6 +24,7 @@ snd-soc-tegra-wm8903-objs := tegra_wm8903.o | |||
24 | snd-soc-tegra-wm9712-objs := tegra_wm9712.o | 24 | snd-soc-tegra-wm9712-objs := tegra_wm9712.o |
25 | snd-soc-tegra-trimslice-objs := trimslice.o | 25 | snd-soc-tegra-trimslice-objs := trimslice.o |
26 | snd-soc-tegra-alc5632-objs := tegra_alc5632.o | 26 | snd-soc-tegra-alc5632-objs := tegra_alc5632.o |
27 | snd-soc-tegra-max98090-objs := tegra_max98090.o | ||
27 | 28 | ||
28 | obj-$(CONFIG_SND_SOC_TEGRA_RT5640) += snd-soc-tegra-rt5640.o | 29 | obj-$(CONFIG_SND_SOC_TEGRA_RT5640) += snd-soc-tegra-rt5640.o |
29 | obj-$(CONFIG_SND_SOC_TEGRA_WM8753) += snd-soc-tegra-wm8753.o | 30 | obj-$(CONFIG_SND_SOC_TEGRA_WM8753) += snd-soc-tegra-wm8753.o |
@@ -31,3 +32,4 @@ obj-$(CONFIG_SND_SOC_TEGRA_WM8903) += snd-soc-tegra-wm8903.o | |||
31 | obj-$(CONFIG_SND_SOC_TEGRA_WM9712) += snd-soc-tegra-wm9712.o | 32 | obj-$(CONFIG_SND_SOC_TEGRA_WM9712) += snd-soc-tegra-wm9712.o |
32 | obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += snd-soc-tegra-trimslice.o | 33 | obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += snd-soc-tegra-trimslice.o |
33 | obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o | 34 | obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o |
35 | obj-$(CONFIG_SND_SOC_TEGRA_MAX98090) += snd-soc-tegra-max98090.o | ||
diff --git a/sound/soc/tegra/tegra20_ac97.c b/sound/soc/tegra/tegra20_ac97.c index ae27bcd586d2..088518d7694a 100644 --- a/sound/soc/tegra/tegra20_ac97.c +++ b/sound/soc/tegra/tegra20_ac97.c | |||
@@ -404,7 +404,7 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev) | |||
404 | ret = snd_soc_set_ac97_ops(&tegra20_ac97_ops); | 404 | ret = snd_soc_set_ac97_ops(&tegra20_ac97_ops); |
405 | if (ret) { | 405 | if (ret) { |
406 | dev_err(&pdev->dev, "Failed to set AC'97 ops: %d\n", ret); | 406 | dev_err(&pdev->dev, "Failed to set AC'97 ops: %d\n", ret); |
407 | goto err_asoc_utils_fini; | 407 | goto err_clk_disable_unprepare; |
408 | } | 408 | } |
409 | 409 | ||
410 | ret = snd_soc_register_component(&pdev->dev, &tegra20_ac97_component, | 410 | ret = snd_soc_register_component(&pdev->dev, &tegra20_ac97_component, |
@@ -412,7 +412,7 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev) | |||
412 | if (ret) { | 412 | if (ret) { |
413 | dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); | 413 | dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); |
414 | ret = -ENOMEM; | 414 | ret = -ENOMEM; |
415 | goto err_asoc_utils_fini; | 415 | goto err_clk_disable_unprepare; |
416 | } | 416 | } |
417 | 417 | ||
418 | ret = tegra_pcm_platform_register(&pdev->dev); | 418 | ret = tegra_pcm_platform_register(&pdev->dev); |
@@ -428,6 +428,8 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev) | |||
428 | 428 | ||
429 | err_unregister_component: | 429 | err_unregister_component: |
430 | snd_soc_unregister_component(&pdev->dev); | 430 | snd_soc_unregister_component(&pdev->dev); |
431 | err_clk_disable_unprepare: | ||
432 | clk_disable_unprepare(ac97->clk_ac97); | ||
431 | err_asoc_utils_fini: | 433 | err_asoc_utils_fini: |
432 | tegra_asoc_utils_fini(&ac97->util_data); | 434 | tegra_asoc_utils_fini(&ac97->util_data); |
433 | err_clk_put: | 435 | err_clk_put: |
diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c new file mode 100644 index 000000000000..0283cfb7c031 --- /dev/null +++ b/sound/soc/tegra/tegra_max98090.c | |||
@@ -0,0 +1,275 @@ | |||
1 | /* | ||
2 | * Tegra machine ASoC driver for boards using a MAX90809 CODEC. | ||
3 | * | ||
4 | * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | * | ||
18 | * Based on code copyright/by: | ||
19 | * | ||
20 | * Copyright (C) 2010-2012 - NVIDIA, Inc. | ||
21 | * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.lauchpad.net> | ||
22 | * (c) 2009, 2010 Nvidia Graphics Pvt. Ltd. | ||
23 | * Copyright 2007 Wolfson Microelectronics PLC. | ||
24 | */ | ||
25 | |||
26 | #include <linux/module.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/gpio.h> | ||
30 | #include <linux/of_gpio.h> | ||
31 | |||
32 | #include <sound/core.h> | ||
33 | #include <sound/jack.h> | ||
34 | #include <sound/pcm.h> | ||
35 | #include <sound/pcm_params.h> | ||
36 | #include <sound/soc.h> | ||
37 | |||
38 | #include "tegra_asoc_utils.h" | ||
39 | |||
40 | #define DRV_NAME "tegra-snd-max98090" | ||
41 | |||
42 | struct tegra_max98090 { | ||
43 | struct tegra_asoc_utils_data util_data; | ||
44 | int gpio_hp_det; | ||
45 | }; | ||
46 | |||
47 | static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream, | ||
48 | struct snd_pcm_hw_params *params) | ||
49 | { | ||
50 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
51 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
52 | struct snd_soc_codec *codec = codec_dai->codec; | ||
53 | struct snd_soc_card *card = codec->card; | ||
54 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); | ||
55 | int srate, mclk; | ||
56 | int err; | ||
57 | |||
58 | srate = params_rate(params); | ||
59 | switch (srate) { | ||
60 | case 8000: | ||
61 | case 16000: | ||
62 | case 24000: | ||
63 | case 32000: | ||
64 | case 48000: | ||
65 | case 64000: | ||
66 | case 96000: | ||
67 | mclk = 12288000; | ||
68 | break; | ||
69 | case 11025: | ||
70 | case 22050: | ||
71 | case 44100: | ||
72 | case 88200: | ||
73 | mclk = 11289600; | ||
74 | break; | ||
75 | default: | ||
76 | mclk = 12000000; | ||
77 | break; | ||
78 | } | ||
79 | |||
80 | err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk); | ||
81 | if (err < 0) { | ||
82 | dev_err(card->dev, "Can't configure clocks\n"); | ||
83 | return err; | ||
84 | } | ||
85 | |||
86 | err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, | ||
87 | SND_SOC_CLOCK_IN); | ||
88 | if (err < 0) { | ||
89 | dev_err(card->dev, "codec_dai clock not set\n"); | ||
90 | return err; | ||
91 | } | ||
92 | |||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static struct snd_soc_ops tegra_max98090_ops = { | ||
97 | .hw_params = tegra_max98090_asoc_hw_params, | ||
98 | }; | ||
99 | |||
100 | static struct snd_soc_jack tegra_max98090_hp_jack; | ||
101 | |||
102 | static struct snd_soc_jack_pin tegra_max98090_hp_jack_pins[] = { | ||
103 | { | ||
104 | .pin = "Headphones", | ||
105 | .mask = SND_JACK_HEADPHONE, | ||
106 | }, | ||
107 | }; | ||
108 | |||
109 | static struct snd_soc_jack_gpio tegra_max98090_hp_jack_gpio = { | ||
110 | .name = "Headphone detection", | ||
111 | .report = SND_JACK_HEADPHONE, | ||
112 | .debounce_time = 150, | ||
113 | .invert = 1, | ||
114 | }; | ||
115 | |||
116 | static const struct snd_soc_dapm_widget tegra_max98090_dapm_widgets[] = { | ||
117 | SND_SOC_DAPM_HP("Headphones", NULL), | ||
118 | SND_SOC_DAPM_SPK("Speakers", NULL), | ||
119 | SND_SOC_DAPM_MIC("Mic Jack", NULL), | ||
120 | }; | ||
121 | |||
122 | static const struct snd_kcontrol_new tegra_max98090_controls[] = { | ||
123 | SOC_DAPM_PIN_SWITCH("Speakers"), | ||
124 | }; | ||
125 | |||
126 | static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) | ||
127 | { | ||
128 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
129 | struct snd_soc_codec *codec = codec_dai->codec; | ||
130 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(codec->card); | ||
131 | |||
132 | if (gpio_is_valid(machine->gpio_hp_det)) { | ||
133 | snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, | ||
134 | &tegra_max98090_hp_jack); | ||
135 | snd_soc_jack_add_pins(&tegra_max98090_hp_jack, | ||
136 | ARRAY_SIZE(tegra_max98090_hp_jack_pins), | ||
137 | tegra_max98090_hp_jack_pins); | ||
138 | |||
139 | tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det; | ||
140 | snd_soc_jack_add_gpios(&tegra_max98090_hp_jack, | ||
141 | 1, | ||
142 | &tegra_max98090_hp_jack_gpio); | ||
143 | } | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | static struct snd_soc_dai_link tegra_max98090_dai = { | ||
149 | .name = "max98090", | ||
150 | .stream_name = "max98090 PCM", | ||
151 | .codec_dai_name = "HiFi", | ||
152 | .init = tegra_max98090_asoc_init, | ||
153 | .ops = &tegra_max98090_ops, | ||
154 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | ||
155 | SND_SOC_DAIFMT_CBS_CFS, | ||
156 | }; | ||
157 | |||
158 | static struct snd_soc_card snd_soc_tegra_max98090 = { | ||
159 | .name = "tegra-max98090", | ||
160 | .owner = THIS_MODULE, | ||
161 | .dai_link = &tegra_max98090_dai, | ||
162 | .num_links = 1, | ||
163 | .controls = tegra_max98090_controls, | ||
164 | .num_controls = ARRAY_SIZE(tegra_max98090_controls), | ||
165 | .dapm_widgets = tegra_max98090_dapm_widgets, | ||
166 | .num_dapm_widgets = ARRAY_SIZE(tegra_max98090_dapm_widgets), | ||
167 | .fully_routed = true, | ||
168 | }; | ||
169 | |||
170 | static int tegra_max98090_probe(struct platform_device *pdev) | ||
171 | { | ||
172 | struct device_node *np = pdev->dev.of_node; | ||
173 | struct snd_soc_card *card = &snd_soc_tegra_max98090; | ||
174 | struct tegra_max98090 *machine; | ||
175 | int ret; | ||
176 | |||
177 | machine = devm_kzalloc(&pdev->dev, | ||
178 | sizeof(struct tegra_max98090), GFP_KERNEL); | ||
179 | if (!machine) { | ||
180 | dev_err(&pdev->dev, "Can't allocate tegra_max98090\n"); | ||
181 | return -ENOMEM; | ||
182 | } | ||
183 | |||
184 | card->dev = &pdev->dev; | ||
185 | platform_set_drvdata(pdev, card); | ||
186 | snd_soc_card_set_drvdata(card, machine); | ||
187 | |||
188 | machine->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0); | ||
189 | if (machine->gpio_hp_det == -EPROBE_DEFER) | ||
190 | return -EPROBE_DEFER; | ||
191 | |||
192 | ret = snd_soc_of_parse_card_name(card, "nvidia,model"); | ||
193 | if (ret) | ||
194 | goto err; | ||
195 | |||
196 | ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); | ||
197 | if (ret) | ||
198 | goto err; | ||
199 | |||
200 | tegra_max98090_dai.codec_of_node = of_parse_phandle(np, | ||
201 | "nvidia,audio-codec", 0); | ||
202 | if (!tegra_max98090_dai.codec_of_node) { | ||
203 | dev_err(&pdev->dev, | ||
204 | "Property 'nvidia,audio-codec' missing or invalid\n"); | ||
205 | ret = -EINVAL; | ||
206 | goto err; | ||
207 | } | ||
208 | |||
209 | tegra_max98090_dai.cpu_of_node = of_parse_phandle(np, | ||
210 | "nvidia,i2s-controller", 0); | ||
211 | if (!tegra_max98090_dai.cpu_of_node) { | ||
212 | dev_err(&pdev->dev, | ||
213 | "Property 'nvidia,i2s-controller' missing or invalid\n"); | ||
214 | ret = -EINVAL; | ||
215 | goto err; | ||
216 | } | ||
217 | |||
218 | tegra_max98090_dai.platform_of_node = tegra_max98090_dai.cpu_of_node; | ||
219 | |||
220 | ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); | ||
221 | if (ret) | ||
222 | goto err; | ||
223 | |||
224 | ret = snd_soc_register_card(card); | ||
225 | if (ret) { | ||
226 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", | ||
227 | ret); | ||
228 | goto err_fini_utils; | ||
229 | } | ||
230 | |||
231 | return 0; | ||
232 | |||
233 | err_fini_utils: | ||
234 | tegra_asoc_utils_fini(&machine->util_data); | ||
235 | err: | ||
236 | return ret; | ||
237 | } | ||
238 | |||
239 | static int tegra_max98090_remove(struct platform_device *pdev) | ||
240 | { | ||
241 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
242 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); | ||
243 | |||
244 | snd_soc_jack_free_gpios(&tegra_max98090_hp_jack, 1, | ||
245 | &tegra_max98090_hp_jack_gpio); | ||
246 | |||
247 | snd_soc_unregister_card(card); | ||
248 | |||
249 | tegra_asoc_utils_fini(&machine->util_data); | ||
250 | |||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | static const struct of_device_id tegra_max98090_of_match[] = { | ||
255 | { .compatible = "nvidia,tegra-audio-max98090", }, | ||
256 | {}, | ||
257 | }; | ||
258 | |||
259 | static struct platform_driver tegra_max98090_driver = { | ||
260 | .driver = { | ||
261 | .name = DRV_NAME, | ||
262 | .owner = THIS_MODULE, | ||
263 | .pm = &snd_soc_pm_ops, | ||
264 | .of_match_table = tegra_max98090_of_match, | ||
265 | }, | ||
266 | .probe = tegra_max98090_probe, | ||
267 | .remove = tegra_max98090_remove, | ||
268 | }; | ||
269 | module_platform_driver(tegra_max98090_driver); | ||
270 | |||
271 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); | ||
272 | MODULE_DESCRIPTION("Tegra max98090 machine ASoC driver"); | ||
273 | MODULE_LICENSE("GPL v2"); | ||
274 | MODULE_ALIAS("platform:" DRV_NAME); | ||
275 | MODULE_DEVICE_TABLE(of, tegra_max98090_of_match); | ||
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c index 7b2d23ba69b3..c09ffd18791b 100644 --- a/sound/soc/tegra/tegra_pcm.c +++ b/sound/soc/tegra/tegra_pcm.c | |||
@@ -42,9 +42,6 @@ static const struct snd_pcm_hardware tegra_pcm_hardware = { | |||
42 | .info = SNDRV_PCM_INFO_MMAP | | 42 | .info = SNDRV_PCM_INFO_MMAP | |
43 | SNDRV_PCM_INFO_MMAP_VALID | | 43 | SNDRV_PCM_INFO_MMAP_VALID | |
44 | SNDRV_PCM_INFO_INTERLEAVED, | 44 | SNDRV_PCM_INFO_INTERLEAVED, |
45 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
46 | .channels_min = 2, | ||
47 | .channels_max = 2, | ||
48 | .period_bytes_min = 1024, | 45 | .period_bytes_min = 1024, |
49 | .period_bytes_max = PAGE_SIZE, | 46 | .period_bytes_max = PAGE_SIZE, |
50 | .periods_min = 2, | 47 | .periods_min = 2, |
diff --git a/sound/soc/tegra/tegra_wm9712.c b/sound/soc/tegra/tegra_wm9712.c index 5e119630b0e0..45b57892b6a5 100644 --- a/sound/soc/tegra/tegra_wm9712.c +++ b/sound/soc/tegra/tegra_wm9712.c | |||
@@ -55,7 +55,6 @@ static int tegra_wm9712_init(struct snd_soc_pcm_runtime *rtd) | |||
55 | static struct snd_soc_dai_link tegra_wm9712_dai = { | 55 | static struct snd_soc_dai_link tegra_wm9712_dai = { |
56 | .name = "AC97 HiFi", | 56 | .name = "AC97 HiFi", |
57 | .stream_name = "AC97 HiFi", | 57 | .stream_name = "AC97 HiFi", |
58 | .cpu_dai_name = "tegra20-ac97", | ||
59 | .codec_dai_name = "wm9712-hifi", | 58 | .codec_dai_name = "wm9712-hifi", |
60 | .codec_name = "wm9712-codec", | 59 | .codec_name = "wm9712-codec", |
61 | .init = tegra_wm9712_init, | 60 | .init = tegra_wm9712_init, |
diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index fbd077f4de72..f0829de28708 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c | |||
@@ -40,11 +40,6 @@ static const struct snd_pcm_hardware txx9aclc_pcm_hardware = { | |||
40 | .info = SNDRV_PCM_INFO_INTERLEAVED | | 40 | .info = SNDRV_PCM_INFO_INTERLEAVED | |
41 | SNDRV_PCM_INFO_BATCH | | 41 | SNDRV_PCM_INFO_BATCH | |
42 | SNDRV_PCM_INFO_PAUSE, | 42 | SNDRV_PCM_INFO_PAUSE, |
43 | #ifdef __BIG_ENDIAN | ||
44 | .formats = SNDRV_PCM_FMTBIT_S16_BE, | ||
45 | #else | ||
46 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
47 | #endif | ||
48 | .period_bytes_min = 1024, | 43 | .period_bytes_min = 1024, |
49 | .period_bytes_max = 8 * 1024, | 44 | .period_bytes_max = 8 * 1024, |
50 | .periods_min = 2, | 45 | .periods_min = 2, |
diff --git a/tools/power/cpupower/utils/cpupower-set.c b/tools/power/cpupower/utils/cpupower-set.c index dc4de3762111..bcf1d2f0b791 100644 --- a/tools/power/cpupower/utils/cpupower-set.c +++ b/tools/power/cpupower/utils/cpupower-set.c | |||
@@ -18,9 +18,9 @@ | |||
18 | #include "helpers/bitmask.h" | 18 | #include "helpers/bitmask.h" |
19 | 19 | ||
20 | static struct option set_opts[] = { | 20 | static struct option set_opts[] = { |
21 | { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'}, | 21 | { .name = "perf-bias", .has_arg = required_argument, .flag = NULL, .val = 'b'}, |
22 | { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'}, | 22 | { .name = "sched-mc", .has_arg = required_argument, .flag = NULL, .val = 'm'}, |
23 | { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'}, | 23 | { .name = "sched-smt", .has_arg = required_argument, .flag = NULL, .val = 's'}, |
24 | { }, | 24 | { }, |
25 | }; | 25 | }; |
26 | 26 | ||