Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branches 'asoc/topic/ad1836', 'asoc/topic/ad193x', 'asoc/topic/adav80x', 'asoc/topic/adsp', 'asoc/topic/ak4641', 'asoc/topic/ak4642', 'asoc/topic/arizona', 'asoc/topic/atmel', 'asoc/topic/au1x', 'asoc/topic/axi', 'asoc/topic/bcm2835', 'asoc/topic/blackfin', 'asoc/topic/cs4271', 'asoc/topic/cs42l52', 'asoc/topic/da7210', 'asoc/topic/davinci', 'asoc/topic/ep93xx', 'asoc/topic/fsl', 'asoc/topic/fsl-mxs', 'asoc/topic/generic', 'asoc/topic/hdmi', 'asoc/topic/jack', 'asoc/topic/jz4740', 'asoc/topic/max98090', 'asoc/topic/mxs', 'asoc/topic/omap', 'asoc/topic/pxa', 'asoc/topic/rcar', 'asoc/topic/s6000', 'asoc/topic/sai', 'asoc/topic/samsung', 'asoc/topic/sgtl5000', 'asoc/topic/spear', 'asoc/topic/ssm2518', 'asoc/topic/ssm2602', 'asoc/topic/tegra', 'asoc/topic/tlv320aic3x', 'asoc/topic/twl6040', 'asoc/topic/txx9', 'asoc/topic/uda1380', 'asoc/topic/width', 'asoc/topic/wm8510', 'asoc/topic/wm8523', 'asoc/topic/wm8580', 'asoc/topic/wm8711', 'asoc/topic/wm8728', 'asoc/topic/wm8731', 'asoc/topic/wm8741', 'asoc/topic/wm8750', 'asoc/topic/wm8753', 'asoc/topic/wm8776', 'asoc/topic/wm8804', 'asoc/topic/wm8900', 'asoc/topic/wm8901', 'asoc/topic/wm8940', 'asoc/topic/wm8962', 'asoc/topic/wm8974', 'asoc/topic/wm8985', 'asoc/topic/wm8988', 'asoc/topic/wm8990', 'asoc/topic/wm8991', 'asoc/topic/wm8994', 'asoc/topic/wm8995', 'asoc/topic/wm9081' and 'asoc/topic/x86' into asoc-next

+6676 -3712
+31
Documentation/devicetree/bindings/sound/adi,axi-i2s.txt
··· 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 + };
+30
Documentation/devicetree/bindings/sound/adi,axi-spdif-tx.txt
··· 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 + };
+25
Documentation/devicetree/bindings/sound/bcm2835-i2s.txt
··· 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 + };
+46
Documentation/devicetree/bindings/sound/cs42l52.txt
··· 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 + };
+4 -2
Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
··· 4 4 - compatible : 5 5 "ti,dm646x-mcasp-audio" : for DM646x platforms 6 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 10 - reg : Should contain reg specifiers for the entries in the reg-names property. 10 11 - reg-names : Should contain: ··· 37 36 - pinctrl-0: Should specify pin control group used for this controller. 38 37 - pinctrl-names: Should contain only one value - "default", for more details 39 38 please refer to pinctrl-bindings.txt 40 - 39 + - fck_parent : Should contain a valid clock name which will be used as parent 40 + for the McASP fck 41 41 42 42 Example: 43 43
+40
Documentation/devicetree/bindings/sound/fsl-sai.txt
··· 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 + };
+17
Documentation/devicetree/bindings/sound/hdmi.txt
··· 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 + };
+43
Documentation/devicetree/bindings/sound/max98090.txt
··· 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 + };
+51
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt
··· 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 + };
+11 -2
Documentation/devicetree/bindings/sound/simple-card.txt
··· 9 9 Optional properties: 10 10 11 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" 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 + 14 19 Required subnodes: 15 20 16 21 - simple-audio-card,cpu : CPU sub-node ··· 43 38 sound { 44 39 compatible = "simple-audio-card"; 45 40 simple-audio-card,format = "left_j"; 41 + simple-audio-routing = 42 + "MIC_IN", "Mic Jack", 43 + "Headphone Jack", "HP_OUT", 44 + "Ext Spk", "LINE_OUT"; 46 45 47 46 simple-audio-card,cpu { 48 47 sound-dai = <&sh_fsi2 0>;
+1
arch/arm/Kconfig
··· 723 723 bool "Samsung S3C64XX" 724 724 select ARCH_HAS_CPUFREQ 725 725 select ARCH_REQUIRE_GPIOLIB 726 + select ARM_AMBA 726 727 select ARM_VIC 727 728 select CLKDEV_LOOKUP 728 729 select CLKSRC_SAMSUNG_PWM
+4 -3
arch/arm/mach-s3c64xx/Kconfig
··· 17 17 help 18 18 Enable S3C6410 CPU support 19 19 20 - config S3C64XX_DMA 21 - bool "S3C64XX DMA" 22 - select S3C_DMA 20 + config S3C64XX_PL080 21 + bool "S3C64XX DMA using generic PL08x driver" 22 + select AMBA_PL08X 23 + select SAMSUNG_DMADEV 23 24 24 25 config S3C64XX_SETUP_SDHCI 25 26 bool
+1 -1
arch/arm/mach-s3c64xx/Makefile
··· 26 26 27 27 # DMA support 28 28 29 - obj-$(CONFIG_S3C64XX_DMA) += dma.o 29 + obj-$(CONFIG_S3C64XX_PL080) += pl080.o 30 30 31 31 # Device support 32 32
+5
arch/arm/mach-s3c64xx/common.h
··· 58 58 static inline int s3c64xx_pm_late_initcall(void) { return 0; } 59 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 66 #endif /* __ARCH_ARM_MACH_S3C64XX_COMMON_H */
-762
arch/arm/mach-s3c64xx/dma.c
··· 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);
+41 -101
arch/arm/mach-s3c64xx/include/mach/dma.h
··· 11 11 #ifndef __ASM_ARCH_DMA_H 12 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 15 16 - /* see mach-s3c2410/dma.h for notes on dma channel numbers */ 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") 17 33 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 - */ 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") 49 + 22 50 enum dma_ch { 23 - /* DMA0/SDMA0 */ 24 - DMACH_UART0 = 0, 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, 51 + DMACH_MAX = 32 52 + }; 40 53 41 - /* DMA1/SDMA1 */ 42 - DMACH_PCM1_TX = 16, 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 */ 54 + struct s3c2410_dma_client { 55 + char *name; 59 56 }; 60 57 61 58 static inline bool samsung_dma_has_circular(void) ··· 62 65 63 66 static inline bool samsung_dma_is_dmadev(void) 64 67 { 65 - return false; 68 + return true; 66 69 } 67 - #define S3C2410_DMAF_CIRCULAR (1 << 0) 68 70 69 - #include <plat/dma.h> 70 - 71 - #define DMACH_LOW_LEVEL (1<<28) /* use this to specifiy hardware ch no */ 72 - 73 - struct s3c64xx_dma_buff; 74 - 75 - /** s3c64xx_dma_buff - S3C64XX DMA buffer descriptor 76 - * @next: Pointer to next buffer in queue or ring. 77 - * @pw: Client provided identifier 78 - * @lli: Pointer to hardware descriptor this buffer is associated with. 79 - * @lli_dma: Hardare address of the descriptor. 80 - */ 81 - struct s3c64xx_dma_buff { 82 - struct s3c64xx_dma_buff *next; 83 - 84 - void *pw; 85 - struct pl080s_lli *lli; 86 - dma_addr_t lli_dma; 87 - }; 88 - 89 - struct s3c64xx_dmac; 90 - 91 - struct s3c2410_dma_chan { 92 - unsigned char number; /* number of this dma channel */ 93 - unsigned char in_use; /* channel allocated */ 94 - unsigned char bit; /* bit for enable/disable/etc */ 95 - unsigned char hw_width; 96 - unsigned char peripheral; 97 - 98 - unsigned int flags; 99 - enum dma_data_direction source; 100 - 101 - 102 - dma_addr_t dev_addr; 103 - 104 - struct s3c2410_dma_client *client; 105 - struct s3c64xx_dmac *dmac; /* pointer to controller */ 106 - 107 - void __iomem *regs; 108 - 109 - /* cdriver callbacks */ 110 - s3c2410_dma_cbfn_t callback_fn; /* buffer done callback */ 111 - s3c2410_dma_opfn_t op_fn; /* channel op callback */ 112 - 113 - /* buffer list and information */ 114 - struct s3c64xx_dma_buff *curr; /* current dma buffer */ 115 - struct s3c64xx_dma_buff *next; /* next buffer to load */ 116 - struct s3c64xx_dma_buff *end; /* end of queue */ 117 - 118 - /* note, when channel is running in circular mode, curr is the 119 - * first buffer enqueued, end is the last and curr is where the 120 - * last buffer-done event is set-at. The buffers are not freed 121 - * and the last buffer hardware descriptor points back to the 122 - * first. 123 - */ 124 - }; 125 - 126 - #include <plat/dma-core.h> 71 + #include <linux/amba/pl08x.h> 72 + #include <plat/dma-ops.h> 127 73 128 74 #endif /* __ASM_ARCH_IRQ_H */
+244
arch/arm/mach-s3c64xx/pl080.c
··· 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);
+8 -2
arch/arm/plat-samsung/devs.c
··· 1468 1468 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio; 1469 1469 #if defined(CONFIG_PL330_DMA) 1470 1470 pd.filter = pl330_filter; 1471 + #elif defined(CONFIG_S3C64XX_PL080) 1472 + pd.filter = pl08x_filter_id; 1471 1473 #elif defined(CONFIG_S3C24XX_DMAC) 1472 1474 pd.filter = s3c24xx_dma_filter; 1473 1475 #endif ··· 1511 1509 pd.num_cs = num_cs; 1512 1510 pd.src_clk_nr = src_clk_nr; 1513 1511 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio; 1514 - #ifdef CONFIG_PL330_DMA 1512 + #if defined(CONFIG_PL330_DMA) 1515 1513 pd.filter = pl330_filter; 1514 + #elif defined(CONFIG_S3C64XX_PL080) 1515 + pd.filter = pl08x_filter_id; 1516 1516 #endif 1517 1517 1518 1518 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1); ··· 1554 1550 pd.num_cs = num_cs; 1555 1551 pd.src_clk_nr = src_clk_nr; 1556 1552 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio; 1557 - #ifdef CONFIG_PL330_DMA 1553 + #if defined(CONFIG_PL330_DMA) 1558 1554 pd.filter = pl330_filter; 1555 + #elif defined(CONFIG_S3C64XX_PL080) 1556 + pd.filter = pl08x_filter_id; 1559 1557 #endif 1560 1558 1561 1559 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi2);
+7 -1
arch/arm/plat-samsung/dma-ops.c
··· 18 18 19 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 27 static unsigned samsung_dmadev_request(enum dma_ch dma_ch, 22 28 struct samsung_dma_req *param, 23 29 struct device *dev, char *ch_name) ··· 36 30 if (dev->of_node) 37 31 return (unsigned)dma_request_slave_channel(dev, ch_name); 38 32 else 39 - return (unsigned)dma_request_channel(mask, pl330_filter, 33 + return (unsigned)dma_request_channel(mask, dma_filter, 40 34 (void *)dma_ch); 41 35 } 42 36
+2 -2
drivers/clk/samsung/clk-s3c64xx.c
··· 331 331 ALIAS(HCLK_HSMMC1, "s3c-sdhci.1", "mmc_busclk.0"), 332 332 ALIAS(HCLK_HSMMC0, "s3c-sdhci.0", "hsmmc"), 333 333 ALIAS(HCLK_HSMMC0, "s3c-sdhci.0", "mmc_busclk.0"), 334 - ALIAS(HCLK_DMA1, NULL, "dma1"), 335 - ALIAS(HCLK_DMA0, NULL, "dma0"), 334 + ALIAS(HCLK_DMA1, "dma-pl080s.1", "apb_pclk"), 335 + ALIAS(HCLK_DMA0, "dma-pl080s.0", "apb_pclk"), 336 336 ALIAS(HCLK_CAMIF, "s3c-camif", "camif"), 337 337 ALIAS(HCLK_LCD, "s3c-fb", "lcd"), 338 338 ALIAS(PCLK_SPI1, "s3c6410-spi.1", "spi"),
+89 -3
drivers/mfd/twl6040.c
··· 44 44 #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) 45 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 95 static bool twl6040_has_vibra(struct device_node *node) 48 96 { 49 97 #ifdef CONFIG_OF ··· 286 238 if (twl6040->power_count++) 287 239 goto out; 288 240 241 + /* Allow writes to the chip */ 242 + regcache_cache_only(twl6040->regmap, false); 243 + 289 244 if (gpio_is_valid(twl6040->audpwron)) { 290 245 /* use automatic power-up sequence */ 291 246 ret = twl6040_power_up_automatic(twl6040); ··· 304 253 goto out; 305 254 } 306 255 } 256 + 257 + /* Sync with the HW */ 258 + regcache_sync(twl6040->regmap); 259 + 307 260 /* Default PLL configuration after power up */ 308 261 twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL; 309 262 twl6040->sysclk = 19200000; ··· 334 279 /* use manual power-down sequence */ 335 280 twl6040_power_down_manual(twl6040); 336 281 } 282 + 283 + /* Set regmap to cache only and mark it as dirty */ 284 + regcache_cache_only(twl6040->regmap, true); 285 + regcache_mark_dirty(twl6040->regmap); 286 + 337 287 twl6040->sysclk = 0; 338 288 twl6040->mclk = 0; 339 289 } ··· 550 490 static bool twl6040_volatile_reg(struct device *dev, unsigned int reg) 551 491 { 552 492 switch (reg) { 553 - case TWL6040_REG_VIBCTLL: 554 - case TWL6040_REG_VIBCTLR: 555 - case TWL6040_REG_INTMR: 493 + case TWL6040_REG_ASICID: 494 + case TWL6040_REG_ASICREV: 495 + case TWL6040_REG_INTID: 496 + case TWL6040_REG_LPPLLCTL: 497 + case TWL6040_REG_HPPLLCTL: 498 + case TWL6040_REG_STATUS: 499 + return true; 500 + default: 501 + return false; 502 + } 503 + } 504 + 505 + static bool twl6040_writeable_reg(struct device *dev, unsigned int reg) 506 + { 507 + switch (reg) { 508 + case TWL6040_REG_ASICID: 509 + case TWL6040_REG_ASICREV: 510 + case TWL6040_REG_STATUS: 556 511 return false; 557 512 default: 558 513 return true; ··· 577 502 static struct regmap_config twl6040_regmap_config = { 578 503 .reg_bits = 8, 579 504 .val_bits = 8, 505 + 506 + .reg_defaults = twl6040_defaults, 507 + .num_reg_defaults = ARRAY_SIZE(twl6040_defaults), 508 + 580 509 .max_register = TWL6040_REG_STATUS, /* 0x2e */ 581 510 582 511 .readable_reg = twl6040_readable_reg, 583 512 .volatile_reg = twl6040_volatile_reg, 513 + .writeable_reg = twl6040_writeable_reg, 584 514 585 515 .cache_type = REGCACHE_RBTREE, 586 516 }; ··· 704 624 705 625 /* dual-access registers controlled by I2C only */ 706 626 twl6040_set_bits(twl6040, TWL6040_REG_ACCCTL, TWL6040_I2CSEL); 627 + regmap_register_patch(twl6040->regmap, twl6040_patch, 628 + ARRAY_SIZE(twl6040_patch)); 707 629 708 630 /* 709 631 * The main functionality of twl6040 to provide audio on OMAP4+ systems. ··· 737 655 cell = &twl6040->cells[children]; 738 656 cell->name = "twl6040-gpo"; 739 657 children++; 658 + 659 + /* The chip is powered down so mark regmap to cache only and dirty */ 660 + regcache_cache_only(twl6040->regmap, true); 661 + regcache_mark_dirty(twl6040->regmap); 740 662 741 663 ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children, 742 664 NULL, 0, NULL);
+135 -4
drivers/mfd/wm5110-tables.c
··· 14 14 15 15 #include <linux/mfd/arizona/core.h> 16 16 #include <linux/mfd/arizona/registers.h> 17 + #include <linux/device.h> 17 18 18 19 #include "arizona.h" 19 20 ··· 525 524 { 0x00000300, 0x0000 }, /* R768 - Input Enables */ 526 525 { 0x00000308, 0x0000 }, /* R776 - Input Rate */ 527 526 { 0x00000309, 0x0022 }, /* R777 - Input Volume Ramp */ 527 + { 0x0000030C, 0x0002 }, /* R780 - HPF Control */ 528 528 { 0x00000310, 0x2080 }, /* R784 - IN1L Control */ 529 529 { 0x00000311, 0x0180 }, /* R785 - ADC Digital Volume 1L */ 530 530 { 0x00000312, 0x0000 }, /* R786 - DMIC1L Control */ ··· 547 545 { 0x00000328, 0x2000 }, /* R808 - IN4L Control */ 548 546 { 0x00000329, 0x0180 }, /* R809 - ADC Digital Volume 4L */ 549 547 { 0x0000032A, 0x0000 }, /* R810 - DMIC4L Control */ 548 + { 0x0000032C, 0x0000 }, /* R812 - IN4R Control */ 550 549 { 0x0000032D, 0x0180 }, /* R813 - ADC Digital Volume 4R */ 551 550 { 0x0000032E, 0x0000 }, /* R814 - DMIC4R Control */ 552 551 { 0x00000400, 0x0000 }, /* R1024 - Output Enables 1 */ ··· 601 598 { 0x0000043D, 0x0180 }, /* R1085 - DAC Digital Volume 6R */ 602 599 { 0x0000043E, 0x0080 }, /* R1086 - DAC Volume Limit 6R */ 603 600 { 0x0000043F, 0x0800 }, /* R1087 - Noise Gate Select 6R */ 601 + { 0x00000440, 0x8FFF }, /* R1088 - DRE Enable */ 604 602 { 0x00000450, 0x0000 }, /* R1104 - DAC AEC Control 1 */ 605 603 { 0x00000458, 0x0000 }, /* R1112 - Noise Gate Control */ 606 604 { 0x00000480, 0x0040 }, /* R1152 - Class W ANC Threshold 1 */ ··· 886 882 { 0x0000074D, 0x0080 }, /* R1869 - AIF2TX2MIX Input 3 Volume */ 887 883 { 0x0000074E, 0x0000 }, /* R1870 - AIF2TX2MIX Input 4 Source */ 888 884 { 0x0000074F, 0x0080 }, /* R1871 - AIF2TX2MIX Input 4 Volume */ 885 + { 0x00000750, 0x0000 }, /* R1872 - AIF2TX3MIX Input 1 Source */ 886 + { 0x00000751, 0x0080 }, /* R1873 - AIF2TX3MIX Input 1 Volume */ 887 + { 0x00000752, 0x0000 }, /* R1874 - AIF2TX3MIX Input 2 Source */ 888 + { 0x00000753, 0x0080 }, /* R1875 - AIF2TX3MIX Input 2 Volume */ 889 + { 0x00000754, 0x0000 }, /* R1876 - AIF2TX3MIX Input 3 Source */ 890 + { 0x00000755, 0x0080 }, /* R1877 - AIF2TX3MIX Input 3 Volume */ 891 + { 0x00000756, 0x0000 }, /* R1878 - AIF2TX3MIX Input 4 Source */ 892 + { 0x00000757, 0x0080 }, /* R1879 - AIF2TX3MIX Input 4 Volume */ 893 + { 0x00000758, 0x0000 }, /* R1880 - AIF2TX4MIX Input 1 Source */ 894 + { 0x00000759, 0x0080 }, /* R1881 - AIF2TX4MIX Input 1 Volume */ 895 + { 0x0000075A, 0x0000 }, /* R1882 - AIF2TX4MIX Input 2 Source */ 896 + { 0x0000075B, 0x0080 }, /* R1883 - AIF2TX4MIX Input 2 Volume */ 897 + { 0x0000075C, 0x0000 }, /* R1884 - AIF2TX4MIX Input 3 Source */ 898 + { 0x0000075D, 0x0080 }, /* R1885 - AIF2TX4MIX Input 3 Volume */ 899 + { 0x0000075E, 0x0000 }, /* R1886 - AIF2TX4MIX Input 4 Source */ 900 + { 0x0000075F, 0x0080 }, /* R1887 - AIF2TX4MIX Input 4 Volume */ 901 + { 0x00000760, 0x0000 }, /* R1888 - AIF2TX5MIX Input 1 Source */ 902 + { 0x00000761, 0x0080 }, /* R1889 - AIF2TX5MIX Input 1 Volume */ 903 + { 0x00000762, 0x0000 }, /* R1890 - AIF2TX5MIX Input 2 Source */ 904 + { 0x00000763, 0x0080 }, /* R1891 - AIF2TX5MIX Input 2 Volume */ 905 + { 0x00000764, 0x0000 }, /* R1892 - AIF2TX5MIX Input 3 Source */ 906 + { 0x00000765, 0x0080 }, /* R1893 - AIF2TX5MIX Input 3 Volume */ 907 + { 0x00000766, 0x0000 }, /* R1894 - AIF2TX5MIX Input 4 Source */ 908 + { 0x00000767, 0x0080 }, /* R1895 - AIF2TX5MIX Input 4 Volume */ 909 + { 0x00000768, 0x0000 }, /* R1896 - AIF2TX6MIX Input 1 Source */ 910 + { 0x00000769, 0x0080 }, /* R1897 - AIF2TX6MIX Input 1 Volume */ 911 + { 0x0000076A, 0x0000 }, /* R1898 - AIF2TX6MIX Input 2 Source */ 912 + { 0x0000076B, 0x0080 }, /* R1899 - AIF2TX6MIX Input 2 Volume */ 913 + { 0x0000076C, 0x0000 }, /* R1900 - AIF2TX6MIX Input 3 Source */ 914 + { 0x0000076D, 0x0080 }, /* R1901 - AIF2TX6MIX Input 3 Volume */ 915 + { 0x0000076E, 0x0000 }, /* R1902 - AIF2TX6MIX Input 4 Source */ 916 + { 0x0000076F, 0x0080 }, /* R1903 - AIF2TX6MIX Input 4 Volume */ 889 917 { 0x00000780, 0x0000 }, /* R1920 - AIF3TX1MIX Input 1 Source */ 890 918 { 0x00000781, 0x0080 }, /* R1921 - AIF3TX1MIX Input 1 Volume */ 891 919 { 0x00000782, 0x0000 }, /* R1922 - AIF3TX1MIX Input 2 Source */ ··· 1378 1342 { 0x00001404, 0x0000 }, /* R5124 - DSP4 Status 1 */ 1379 1343 }; 1380 1344 1345 + static bool wm5110_is_rev_b_adsp_memory(unsigned int reg) 1346 + { 1347 + if ((reg >= 0x100000 && reg < 0x103000) || 1348 + (reg >= 0x180000 && reg < 0x181000) || 1349 + (reg >= 0x190000 && reg < 0x192000) || 1350 + (reg >= 0x1a8000 && reg < 0x1a9000) || 1351 + (reg >= 0x200000 && reg < 0x209000) || 1352 + (reg >= 0x280000 && reg < 0x281000) || 1353 + (reg >= 0x290000 && reg < 0x29a000) || 1354 + (reg >= 0x2a8000 && reg < 0x2aa000) || 1355 + (reg >= 0x300000 && reg < 0x30f000) || 1356 + (reg >= 0x380000 && reg < 0x382000) || 1357 + (reg >= 0x390000 && reg < 0x39e000) || 1358 + (reg >= 0x3a8000 && reg < 0x3b6000) || 1359 + (reg >= 0x400000 && reg < 0x403000) || 1360 + (reg >= 0x480000 && reg < 0x481000) || 1361 + (reg >= 0x490000 && reg < 0x492000) || 1362 + (reg >= 0x4a8000 && reg < 0x4a9000)) 1363 + return true; 1364 + else 1365 + return false; 1366 + } 1367 + 1368 + static bool wm5110_is_rev_d_adsp_memory(unsigned int reg) 1369 + { 1370 + if ((reg >= 0x100000 && reg < 0x106000) || 1371 + (reg >= 0x180000 && reg < 0x182000) || 1372 + (reg >= 0x190000 && reg < 0x198000) || 1373 + (reg >= 0x1a8000 && reg < 0x1aa000) || 1374 + (reg >= 0x200000 && reg < 0x20f000) || 1375 + (reg >= 0x280000 && reg < 0x282000) || 1376 + (reg >= 0x290000 && reg < 0x29c000) || 1377 + (reg >= 0x2a6000 && reg < 0x2b4000) || 1378 + (reg >= 0x300000 && reg < 0x30f000) || 1379 + (reg >= 0x380000 && reg < 0x382000) || 1380 + (reg >= 0x390000 && reg < 0x3a2000) || 1381 + (reg >= 0x3a6000 && reg < 0x3b4000) || 1382 + (reg >= 0x400000 && reg < 0x406000) || 1383 + (reg >= 0x480000 && reg < 0x482000) || 1384 + (reg >= 0x490000 && reg < 0x498000) || 1385 + (reg >= 0x4a8000 && reg < 0x4aa000)) 1386 + return true; 1387 + else 1388 + return false; 1389 + } 1390 + 1391 + static bool wm5110_is_adsp_memory(struct device *dev, unsigned int reg) 1392 + { 1393 + struct arizona *arizona = dev_get_drvdata(dev); 1394 + 1395 + switch (arizona->rev) { 1396 + case 0 ... 2: 1397 + return wm5110_is_rev_b_adsp_memory(reg); 1398 + default: 1399 + return wm5110_is_rev_d_adsp_memory(reg); 1400 + } 1401 + } 1402 + 1381 1403 static bool wm5110_readable_register(struct device *dev, unsigned int reg) 1382 1404 { 1383 1405 switch (reg) { ··· 1554 1460 case ARIZONA_INPUT_ENABLES_STATUS: 1555 1461 case ARIZONA_INPUT_RATE: 1556 1462 case ARIZONA_INPUT_VOLUME_RAMP: 1463 + case ARIZONA_HPF_CONTROL: 1557 1464 case ARIZONA_IN1L_CONTROL: 1558 1465 case ARIZONA_ADC_DIGITAL_VOLUME_1L: 1559 1466 case ARIZONA_DMIC1L_CONTROL: ··· 1576 1481 case ARIZONA_IN4L_CONTROL: 1577 1482 case ARIZONA_ADC_DIGITAL_VOLUME_4L: 1578 1483 case ARIZONA_DMIC4L_CONTROL: 1484 + case ARIZONA_IN4R_CONTROL: 1579 1485 case ARIZONA_ADC_DIGITAL_VOLUME_4R: 1580 1486 case ARIZONA_DMIC4R_CONTROL: 1581 1487 case ARIZONA_OUTPUT_ENABLES_1: ··· 1632 1536 case ARIZONA_DAC_DIGITAL_VOLUME_6R: 1633 1537 case ARIZONA_DAC_VOLUME_LIMIT_6R: 1634 1538 case ARIZONA_NOISE_GATE_SELECT_6R: 1539 + case ARIZONA_DRE_ENABLE: 1635 1540 case ARIZONA_DAC_AEC_CONTROL_1: 1636 1541 case ARIZONA_NOISE_GATE_CONTROL: 1637 1542 case ARIZONA_PDM_SPK1_CTRL_1: ··· 1917 1820 case ARIZONA_AIF2TX2MIX_INPUT_3_VOLUME: 1918 1821 case ARIZONA_AIF2TX2MIX_INPUT_4_SOURCE: 1919 1822 case ARIZONA_AIF2TX2MIX_INPUT_4_VOLUME: 1823 + case ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE: 1824 + case ARIZONA_AIF2TX3MIX_INPUT_1_VOLUME: 1825 + case ARIZONA_AIF2TX3MIX_INPUT_2_SOURCE: 1826 + case ARIZONA_AIF2TX3MIX_INPUT_2_VOLUME: 1827 + case ARIZONA_AIF2TX3MIX_INPUT_3_SOURCE: 1828 + case ARIZONA_AIF2TX3MIX_INPUT_3_VOLUME: 1829 + case ARIZONA_AIF2TX3MIX_INPUT_4_SOURCE: 1830 + case ARIZONA_AIF2TX3MIX_INPUT_4_VOLUME: 1831 + case ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE: 1832 + case ARIZONA_AIF2TX4MIX_INPUT_1_VOLUME: 1833 + case ARIZONA_AIF2TX4MIX_INPUT_2_SOURCE: 1834 + case ARIZONA_AIF2TX4MIX_INPUT_2_VOLUME: 1835 + case ARIZONA_AIF2TX4MIX_INPUT_3_SOURCE: 1836 + case ARIZONA_AIF2TX4MIX_INPUT_3_VOLUME: 1837 + case ARIZONA_AIF2TX4MIX_INPUT_4_SOURCE: 1838 + case ARIZONA_AIF2TX4MIX_INPUT_4_VOLUME: 1839 + case ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE: 1840 + case ARIZONA_AIF2TX5MIX_INPUT_1_VOLUME: 1841 + case ARIZONA_AIF2TX5MIX_INPUT_2_SOURCE: 1842 + case ARIZONA_AIF2TX5MIX_INPUT_2_VOLUME: 1843 + case ARIZONA_AIF2TX5MIX_INPUT_3_SOURCE: 1844 + case ARIZONA_AIF2TX5MIX_INPUT_3_VOLUME: 1845 + case ARIZONA_AIF2TX5MIX_INPUT_4_SOURCE: 1846 + case ARIZONA_AIF2TX5MIX_INPUT_4_VOLUME: 1847 + case ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE: 1848 + case ARIZONA_AIF2TX6MIX_INPUT_1_VOLUME: 1849 + case ARIZONA_AIF2TX6MIX_INPUT_2_SOURCE: 1850 + case ARIZONA_AIF2TX6MIX_INPUT_2_VOLUME: 1851 + case ARIZONA_AIF2TX6MIX_INPUT_3_SOURCE: 1852 + case ARIZONA_AIF2TX6MIX_INPUT_3_VOLUME: 1853 + case ARIZONA_AIF2TX6MIX_INPUT_4_SOURCE: 1854 + case ARIZONA_AIF2TX6MIX_INPUT_4_VOLUME: 1920 1855 case ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE: 1921 1856 case ARIZONA_AIF3TX1MIX_INPUT_1_VOLUME: 1922 1857 case ARIZONA_AIF3TX1MIX_INPUT_2_SOURCE: ··· 2460 2331 case ARIZONA_DSP4_SCRATCH_3: 2461 2332 return true; 2462 2333 default: 2463 - return false; 2334 + return wm5110_is_adsp_memory(dev, reg); 2464 2335 } 2465 2336 } 2466 2337 ··· 2536 2407 case ARIZONA_DSP4_SCRATCH_3: 2537 2408 return true; 2538 2409 default: 2539 - return false; 2410 + return wm5110_is_adsp_memory(dev, reg); 2540 2411 } 2541 2412 } 2413 + 2414 + #define WM5110_MAX_REGISTER 0x4a9fff 2542 2415 2543 2416 const struct regmap_config wm5110_spi_regmap = { 2544 2417 .reg_bits = 32, 2545 2418 .pad_bits = 16, 2546 2419 .val_bits = 16, 2547 2420 2548 - .max_register = ARIZONA_DSP1_STATUS_2, 2421 + .max_register = WM5110_MAX_REGISTER, 2549 2422 .readable_reg = wm5110_readable_register, 2550 2423 .volatile_reg = wm5110_volatile_register, 2551 2424 ··· 2561 2430 .reg_bits = 32, 2562 2431 .val_bits = 16, 2563 2432 2564 - .max_register = ARIZONA_DSP1_STATUS_2, 2433 + .max_register = WM5110_MAX_REGISTER, 2565 2434 .readable_reg = wm5110_readable_register, 2566 2435 .volatile_reg = wm5110_volatile_register, 2567 2436
+1 -1
drivers/spi/Kconfig
··· 395 395 config SPI_S3C64XX 396 396 tristate "Samsung S3C64XX series type SPI" 397 397 depends on PLAT_SAMSUNG 398 - select S3C64XX_DMA if ARCH_S3C64XX 398 + select S3C64XX_PL080 if ARCH_S3C64XX 399 399 help 400 400 SPI driver for Samsung S3C64XX and newer SoCs. 401 401
+162
include/linux/mfd/arizona/registers.h
··· 139 139 #define ARIZONA_INPUT_ENABLES_STATUS 0x301 140 140 #define ARIZONA_INPUT_RATE 0x308 141 141 #define ARIZONA_INPUT_VOLUME_RAMP 0x309 142 + #define ARIZONA_HPF_CONTROL 0x30C 142 143 #define ARIZONA_IN1L_CONTROL 0x310 143 144 #define ARIZONA_ADC_DIGITAL_VOLUME_1L 0x311 144 145 #define ARIZONA_DMIC1L_CONTROL 0x312 ··· 161 160 #define ARIZONA_IN4L_CONTROL 0x328 162 161 #define ARIZONA_ADC_DIGITAL_VOLUME_4L 0x329 163 162 #define ARIZONA_DMIC4L_CONTROL 0x32A 163 + #define ARIZONA_IN4R_CONTROL 0x32C 164 164 #define ARIZONA_ADC_DIGITAL_VOLUME_4R 0x32D 165 165 #define ARIZONA_DMIC4R_CONTROL 0x32E 166 166 #define ARIZONA_OUTPUT_ENABLES_1 0x400 ··· 513 511 #define ARIZONA_AIF2TX2MIX_INPUT_3_VOLUME 0x74D 514 512 #define ARIZONA_AIF2TX2MIX_INPUT_4_SOURCE 0x74E 515 513 #define ARIZONA_AIF2TX2MIX_INPUT_4_VOLUME 0x74F 514 + #define ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE 0x750 515 + #define ARIZONA_AIF2TX3MIX_INPUT_1_VOLUME 0x751 516 + #define ARIZONA_AIF2TX3MIX_INPUT_2_SOURCE 0x752 517 + #define ARIZONA_AIF2TX3MIX_INPUT_2_VOLUME 0x753 518 + #define ARIZONA_AIF2TX3MIX_INPUT_3_SOURCE 0x754 519 + #define ARIZONA_AIF2TX3MIX_INPUT_3_VOLUME 0x755 520 + #define ARIZONA_AIF2TX3MIX_INPUT_4_SOURCE 0x756 521 + #define ARIZONA_AIF2TX3MIX_INPUT_4_VOLUME 0x757 522 + #define ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE 0x758 523 + #define ARIZONA_AIF2TX4MIX_INPUT_1_VOLUME 0x759 524 + #define ARIZONA_AIF2TX4MIX_INPUT_2_SOURCE 0x75A 525 + #define ARIZONA_AIF2TX4MIX_INPUT_2_VOLUME 0x75B 526 + #define ARIZONA_AIF2TX4MIX_INPUT_3_SOURCE 0x75C 527 + #define ARIZONA_AIF2TX4MIX_INPUT_3_VOLUME 0x75D 528 + #define ARIZONA_AIF2TX4MIX_INPUT_4_SOURCE 0x75E 529 + #define ARIZONA_AIF2TX4MIX_INPUT_4_VOLUME 0x75F 530 + #define ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE 0x760 531 + #define ARIZONA_AIF2TX5MIX_INPUT_1_VOLUME 0x761 532 + #define ARIZONA_AIF2TX5MIX_INPUT_2_SOURCE 0x762 533 + #define ARIZONA_AIF2TX5MIX_INPUT_2_VOLUME 0x763 534 + #define ARIZONA_AIF2TX5MIX_INPUT_3_SOURCE 0x764 535 + #define ARIZONA_AIF2TX5MIX_INPUT_3_VOLUME 0x765 536 + #define ARIZONA_AIF2TX5MIX_INPUT_4_SOURCE 0x766 537 + #define ARIZONA_AIF2TX5MIX_INPUT_4_VOLUME 0x767 538 + #define ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE 0x768 539 + #define ARIZONA_AIF2TX6MIX_INPUT_1_VOLUME 0x769 540 + #define ARIZONA_AIF2TX6MIX_INPUT_2_SOURCE 0x76A 541 + #define ARIZONA_AIF2TX6MIX_INPUT_2_VOLUME 0x76B 542 + #define ARIZONA_AIF2TX6MIX_INPUT_3_SOURCE 0x76C 543 + #define ARIZONA_AIF2TX6MIX_INPUT_3_VOLUME 0x76D 544 + #define ARIZONA_AIF2TX6MIX_INPUT_4_SOURCE 0x76E 545 + #define ARIZONA_AIF2TX6MIX_INPUT_4_VOLUME 0x76F 516 546 #define ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE 0x780 517 547 #define ARIZONA_AIF3TX1MIX_INPUT_1_VOLUME 0x781 518 548 #define ARIZONA_AIF3TX1MIX_INPUT_2_SOURCE 0x782 ··· 2327 2293 #define ARIZONA_IN_VI_RAMP_WIDTH 3 /* IN_VI_RAMP - [2:0] */ 2328 2294 2329 2295 /* 2296 + * R780 (0x30C) - HPF Control 2297 + */ 2298 + #define ARIZONA_IN_HPF_CUT_MASK 0x0007 /* IN_HPF_CUT [2:0] */ 2299 + #define ARIZONA_IN_HPF_CUT_SHIFT 0 /* IN_HPF_CUT [2:0] */ 2300 + #define ARIZONA_IN_HPF_CUT_WIDTH 3 /* IN_HPF_CUT [2:0] */ 2301 + 2302 + /* 2330 2303 * R784 (0x310) - IN1L Control 2331 2304 */ 2305 + #define ARIZONA_IN1L_HPF_MASK 0x8000 /* IN1L_HPF - [15] */ 2306 + #define ARIZONA_IN1L_HPF_SHIFT 15 /* IN1L_HPF - [15] */ 2307 + #define ARIZONA_IN1L_HPF_WIDTH 1 /* IN1L_HPF - [15] */ 2332 2308 #define ARIZONA_IN1_OSR_MASK 0x6000 /* IN1_OSR - [14:13] */ 2333 2309 #define ARIZONA_IN1_OSR_SHIFT 13 /* IN1_OSR - [14:13] */ 2334 2310 #define ARIZONA_IN1_OSR_WIDTH 2 /* IN1_OSR - [14:13] */ ··· 2377 2333 /* 2378 2334 * R788 (0x314) - IN1R Control 2379 2335 */ 2336 + #define ARIZONA_IN1R_HPF_MASK 0x8000 /* IN1R_HPF - [15] */ 2337 + #define ARIZONA_IN1R_HPF_SHIFT 15 /* IN1R_HPF - [15] */ 2338 + #define ARIZONA_IN1R_HPF_WIDTH 1 /* IN1R_HPF - [15] */ 2380 2339 #define ARIZONA_IN1R_PGA_VOL_MASK 0x00FE /* IN1R_PGA_VOL - [7:1] */ 2381 2340 #define ARIZONA_IN1R_PGA_VOL_SHIFT 1 /* IN1R_PGA_VOL - [7:1] */ 2382 2341 #define ARIZONA_IN1R_PGA_VOL_WIDTH 7 /* IN1R_PGA_VOL - [7:1] */ ··· 2409 2362 /* 2410 2363 * R792 (0x318) - IN2L Control 2411 2364 */ 2365 + #define ARIZONA_IN2L_HPF_MASK 0x8000 /* IN2L_HPF - [15] */ 2366 + #define ARIZONA_IN2L_HPF_SHIFT 15 /* IN2L_HPF - [15] */ 2367 + #define ARIZONA_IN2L_HPF_WIDTH 1 /* IN2L_HPF - [15] */ 2412 2368 #define ARIZONA_IN2_OSR_MASK 0x6000 /* IN2_OSR - [14:13] */ 2413 2369 #define ARIZONA_IN2_OSR_SHIFT 13 /* IN2_OSR - [14:13] */ 2414 2370 #define ARIZONA_IN2_OSR_WIDTH 2 /* IN2_OSR - [14:13] */ ··· 2450 2400 /* 2451 2401 * R796 (0x31C) - IN2R Control 2452 2402 */ 2403 + #define ARIZONA_IN2R_HPF_MASK 0x8000 /* IN2R_HPF - [15] */ 2404 + #define ARIZONA_IN2R_HPF_SHIFT 15 /* IN2R_HPF - [15] */ 2405 + #define ARIZONA_IN2R_HPF_WIDTH 1 /* IN2R_HPF - [15] */ 2453 2406 #define ARIZONA_IN2R_PGA_VOL_MASK 0x00FE /* IN2R_PGA_VOL - [7:1] */ 2454 2407 #define ARIZONA_IN2R_PGA_VOL_SHIFT 1 /* IN2R_PGA_VOL - [7:1] */ 2455 2408 #define ARIZONA_IN2R_PGA_VOL_WIDTH 7 /* IN2R_PGA_VOL - [7:1] */ ··· 2482 2429 /* 2483 2430 * R800 (0x320) - IN3L Control 2484 2431 */ 2432 + #define ARIZONA_IN3L_HPF_MASK 0x8000 /* IN3L_HPF - [15] */ 2433 + #define ARIZONA_IN3L_HPF_SHIFT 15 /* IN3L_HPF - [15] */ 2434 + #define ARIZONA_IN3L_HPF_WIDTH 1 /* IN3L_HPF - [15] */ 2485 2435 #define ARIZONA_IN3_OSR_MASK 0x6000 /* IN3_OSR - [14:13] */ 2486 2436 #define ARIZONA_IN3_OSR_SHIFT 13 /* IN3_OSR - [14:13] */ 2487 2437 #define ARIZONA_IN3_OSR_WIDTH 2 /* IN3_OSR - [14:13] */ ··· 2523 2467 /* 2524 2468 * R804 (0x324) - IN3R Control 2525 2469 */ 2470 + #define ARIZONA_IN3R_HPF_MASK 0x8000 /* IN3R_HPF - [15] */ 2471 + #define ARIZONA_IN3R_HPF_SHIFT 15 /* IN3R_HPF - [15] */ 2472 + #define ARIZONA_IN3R_HPF_WIDTH 1 /* IN3R_HPF - [15] */ 2526 2473 #define ARIZONA_IN3R_PGA_VOL_MASK 0x00FE /* IN3R_PGA_VOL - [7:1] */ 2527 2474 #define ARIZONA_IN3R_PGA_VOL_SHIFT 1 /* IN3R_PGA_VOL - [7:1] */ 2528 2475 #define ARIZONA_IN3R_PGA_VOL_WIDTH 7 /* IN3R_PGA_VOL - [7:1] */ ··· 2555 2496 /* 2556 2497 * R808 (0x328) - IN4 Control 2557 2498 */ 2499 + #define ARIZONA_IN4L_HPF_MASK 0x8000 /* IN4L_HPF - [15] */ 2500 + #define ARIZONA_IN4L_HPF_SHIFT 15 /* IN4L_HPF - [15] */ 2501 + #define ARIZONA_IN4L_HPF_WIDTH 1 /* IN4L_HPF - [15] */ 2558 2502 #define ARIZONA_IN4_OSR_MASK 0x6000 /* IN4_OSR - [14:13] */ 2559 2503 #define ARIZONA_IN4_OSR_SHIFT 13 /* IN4_OSR - [14:13] */ 2560 2504 #define ARIZONA_IN4_OSR_WIDTH 2 /* IN4_OSR - [14:13] */ ··· 2586 2524 #define ARIZONA_IN4L_DMIC_DLY_MASK 0x003F /* IN4L_DMIC_DLY - [5:0] */ 2587 2525 #define ARIZONA_IN4L_DMIC_DLY_SHIFT 0 /* IN4L_DMIC_DLY - [5:0] */ 2588 2526 #define ARIZONA_IN4L_DMIC_DLY_WIDTH 6 /* IN4L_DMIC_DLY - [5:0] */ 2527 + 2528 + /* 2529 + * R812 (0x32C) - IN4R Control 2530 + */ 2531 + #define ARIZONA_IN4R_HPF_MASK 0x8000 /* IN4R_HPF - [15] */ 2532 + #define ARIZONA_IN4R_HPF_SHIFT 15 /* IN4R_HPF - [15] */ 2533 + #define ARIZONA_IN4R_HPF_WIDTH 1 /* IN4R_HPF - [15] */ 2589 2534 2590 2535 /* 2591 2536 * R813 (0x32D) - ADC Digital Volume 4R ··· 3207 3138 /* 3208 3139 * R1088 (0x440) - DRE Enable 3209 3140 */ 3141 + #define ARIZONA_DRE3R_ENA 0x0020 /* DRE3R_ENA */ 3142 + #define ARIZONA_DRE3R_ENA_MASK 0x0020 /* DRE3R_ENA */ 3143 + #define ARIZONA_DRE3R_ENA_SHIFT 5 /* DRE3R_ENA */ 3144 + #define ARIZONA_DRE3R_ENA_WIDTH 1 /* DRE3R_ENA */ 3210 3145 #define ARIZONA_DRE3L_ENA 0x0010 /* DRE3L_ENA */ 3211 3146 #define ARIZONA_DRE3L_ENA_MASK 0x0010 /* DRE3L_ENA */ 3212 3147 #define ARIZONA_DRE3L_ENA_SHIFT 4 /* DRE3L_ENA */ ··· 3799 3726 #define ARIZONA_AIF2TX2_SLOT_WIDTH 6 /* AIF2TX2_SLOT - [5:0] */ 3800 3727 3801 3728 /* 3729 + * R1355 (0x54B) - AIF2 Frame Ctrl 5 3730 + */ 3731 + #define ARIZONA_AIF2TX3_SLOT_MASK 0x003F /* AIF2TX3_SLOT - [5:0] */ 3732 + #define ARIZONA_AIF2TX3_SLOT_SHIFT 0 /* AIF2TX3_SLOT - [5:0] */ 3733 + #define ARIZONA_AIF2TX3_SLOT_WIDTH 6 /* AIF2TX3_SLOT - [5:0] */ 3734 + 3735 + /* 3736 + * R1356 (0x54C) - AIF2 Frame Ctrl 6 3737 + */ 3738 + #define ARIZONA_AIF2TX4_SLOT_MASK 0x003F /* AIF2TX4_SLOT - [5:0] */ 3739 + #define ARIZONA_AIF2TX4_SLOT_SHIFT 0 /* AIF2TX4_SLOT - [5:0] */ 3740 + #define ARIZONA_AIF2TX4_SLOT_WIDTH 6 /* AIF2TX4_SLOT - [5:0] */ 3741 + 3742 + 3743 + /* 3744 + * R1357 (0x54D) - AIF2 Frame Ctrl 7 3745 + */ 3746 + #define ARIZONA_AIF2TX5_SLOT_MASK 0x003F /* AIF2TX5_SLOT - [5:0] */ 3747 + #define ARIZONA_AIF2TX5_SLOT_SHIFT 0 /* AIF2TX5_SLOT - [5:0] */ 3748 + #define ARIZONA_AIF2TX5_SLOT_WIDTH 6 /* AIF2TX5_SLOT - [5:0] */ 3749 + 3750 + /* 3751 + * R1358 (0x54E) - AIF2 Frame Ctrl 8 3752 + */ 3753 + #define ARIZONA_AIF2TX6_SLOT_MASK 0x003F /* AIF2TX6_SLOT - [5:0] */ 3754 + #define ARIZONA_AIF2TX6_SLOT_SHIFT 0 /* AIF2TX6_SLOT - [5:0] */ 3755 + #define ARIZONA_AIF2TX6_SLOT_WIDTH 6 /* AIF2TX6_SLOT - [5:0] */ 3756 + 3757 + /* 3802 3758 * R1361 (0x551) - AIF2 Frame Ctrl 11 3803 3759 */ 3804 3760 #define ARIZONA_AIF2RX1_SLOT_MASK 0x003F /* AIF2RX1_SLOT - [5:0] */ ··· 3842 3740 #define ARIZONA_AIF2RX2_SLOT_WIDTH 6 /* AIF2RX2_SLOT - [5:0] */ 3843 3741 3844 3742 /* 3743 + * R1363 (0x553) - AIF2 Frame Ctrl 13 3744 + */ 3745 + #define ARIZONA_AIF2RX3_SLOT_MASK 0x003F /* AIF2RX3_SLOT - [5:0] */ 3746 + #define ARIZONA_AIF2RX3_SLOT_SHIFT 0 /* AIF2RX3_SLOT - [5:0] */ 3747 + #define ARIZONA_AIF2RX3_SLOT_WIDTH 6 /* AIF2RX3_SLOT - [5:0] */ 3748 + 3749 + /* 3750 + * R1364 (0x554) - AIF2 Frame Ctrl 14 3751 + */ 3752 + #define ARIZONA_AIF2RX4_SLOT_MASK 0x003F /* AIF2RX4_SLOT - [5:0] */ 3753 + #define ARIZONA_AIF2RX4_SLOT_SHIFT 0 /* AIF2RX4_SLOT - [5:0] */ 3754 + #define ARIZONA_AIF2RX4_SLOT_WIDTH 6 /* AIF2RX4_SLOT - [5:0] */ 3755 + 3756 + /* 3757 + * R1365 (0x555) - AIF2 Frame Ctrl 15 3758 + */ 3759 + #define ARIZONA_AIF2RX5_SLOT_MASK 0x003F /* AIF2RX5_SLOT - [5:0] */ 3760 + #define ARIZONA_AIF2RX5_SLOT_SHIFT 0 /* AIF2RX5_SLOT - [5:0] */ 3761 + #define ARIZONA_AIF2RX5_SLOT_WIDTH 6 /* AIF2RX5_SLOT - [5:0] */ 3762 + 3763 + /* 3764 + * R1366 (0x556) - AIF2 Frame Ctrl 16 3765 + */ 3766 + #define ARIZONA_AIF2RX6_SLOT_MASK 0x003F /* AIF2RX6_SLOT - [5:0] */ 3767 + #define ARIZONA_AIF2RX6_SLOT_SHIFT 0 /* AIF2RX6_SLOT - [5:0] */ 3768 + #define ARIZONA_AIF2RX6_SLOT_WIDTH 6 /* AIF2RX6_SLOT - [5:0] */ 3769 + 3770 + /* 3845 3771 * R1369 (0x559) - AIF2 Tx Enables 3846 3772 */ 3773 + #define ARIZONA_AIF2TX6_ENA 0x0020 /* AIF2TX6_ENA */ 3774 + #define ARIZONA_AIF2TX6_ENA_MASK 0x0020 /* AIF2TX6_ENA */ 3775 + #define ARIZONA_AIF2TX6_ENA_SHIFT 5 /* AIF2TX6_ENA */ 3776 + #define ARIZONA_AIF2TX6_ENA_WIDTH 1 /* AIF2TX6_ENA */ 3777 + #define ARIZONA_AIF2TX5_ENA 0x0010 /* AIF2TX5_ENA */ 3778 + #define ARIZONA_AIF2TX5_ENA_MASK 0x0010 /* AIF2TX5_ENA */ 3779 + #define ARIZONA_AIF2TX5_ENA_SHIFT 4 /* AIF2TX5_ENA */ 3780 + #define ARIZONA_AIF2TX5_ENA_WIDTH 1 /* AIF2TX5_ENA */ 3781 + #define ARIZONA_AIF2TX4_ENA 0x0008 /* AIF2TX4_ENA */ 3782 + #define ARIZONA_AIF2TX4_ENA_MASK 0x0008 /* AIF2TX4_ENA */ 3783 + #define ARIZONA_AIF2TX4_ENA_SHIFT 3 /* AIF2TX4_ENA */ 3784 + #define ARIZONA_AIF2TX4_ENA_WIDTH 1 /* AIF2TX4_ENA */ 3785 + #define ARIZONA_AIF2TX3_ENA 0x0004 /* AIF2TX3_ENA */ 3786 + #define ARIZONA_AIF2TX3_ENA_MASK 0x0004 /* AIF2TX3_ENA */ 3787 + #define ARIZONA_AIF2TX3_ENA_SHIFT 2 /* AIF2TX3_ENA */ 3788 + #define ARIZONA_AIF2TX3_ENA_WIDTH 1 /* AIF2TX3_ENA */ 3847 3789 #define ARIZONA_AIF2TX2_ENA 0x0002 /* AIF2TX2_ENA */ 3848 3790 #define ARIZONA_AIF2TX2_ENA_MASK 0x0002 /* AIF2TX2_ENA */ 3849 3791 #define ARIZONA_AIF2TX2_ENA_SHIFT 1 /* AIF2TX2_ENA */ ··· 3900 3754 /* 3901 3755 * R1370 (0x55A) - AIF2 Rx Enables 3902 3756 */ 3757 + #define ARIZONA_AIF2RX6_ENA 0x0020 /* AIF2RX6_ENA */ 3758 + #define ARIZONA_AIF2RX6_ENA_MASK 0x0020 /* AIF2RX6_ENA */ 3759 + #define ARIZONA_AIF2RX6_ENA_SHIFT 5 /* AIF2RX6_ENA */ 3760 + #define ARIZONA_AIF2RX6_ENA_WIDTH 1 /* AIF2RX6_ENA */ 3761 + #define ARIZONA_AIF2RX5_ENA 0x0010 /* AIF2RX5_ENA */ 3762 + #define ARIZONA_AIF2RX5_ENA_MASK 0x0010 /* AIF2RX5_ENA */ 3763 + #define ARIZONA_AIF2RX5_ENA_SHIFT 4 /* AIF2RX5_ENA */ 3764 + #define ARIZONA_AIF2RX5_ENA_WIDTH 1 /* AIF2RX5_ENA */ 3765 + #define ARIZONA_AIF2RX4_ENA 0x0008 /* AIF2RX4_ENA */ 3766 + #define ARIZONA_AIF2RX4_ENA_MASK 0x0008 /* AIF2RX4_ENA */ 3767 + #define ARIZONA_AIF2RX4_ENA_SHIFT 3 /* AIF2RX4_ENA */ 3768 + #define ARIZONA_AIF2RX4_ENA_WIDTH 1 /* AIF2RX4_ENA */ 3769 + #define ARIZONA_AIF2RX3_ENA 0x0004 /* AIF2RX3_ENA */ 3770 + #define ARIZONA_AIF2RX3_ENA_MASK 0x0004 /* AIF2RX3_ENA */ 3771 + #define ARIZONA_AIF2RX3_ENA_SHIFT 2 /* AIF2RX3_ENA */ 3772 + #define ARIZONA_AIF2RX3_ENA_WIDTH 1 /* AIF2RX3_ENA */ 3903 3773 #define ARIZONA_AIF2RX2_ENA 0x0002 /* AIF2RX2_ENA */ 3904 3774 #define ARIZONA_AIF2RX2_ENA_MASK 0x0002 /* AIF2RX2_ENA */ 3905 3775 #define ARIZONA_AIF2RX2_ENA_SHIFT 1 /* AIF2RX2_ENA */
+2 -4
include/linux/platform_data/asoc-ti-mcbsp.h
··· 1 1 /* 2 - * arch/arm/plat-omap/include/mach/mcbsp.h 3 - * 4 2 * Defines for Multi-Channel Buffered Serial Port 5 3 * 6 4 * Copyright (C) 2002 RidgeRun, Inc. ··· 19 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 22 * 21 23 */ 22 - #ifndef __ASM_ARCH_OMAP_MCBSP_H 23 - #define __ASM_ARCH_OMAP_MCBSP_H 24 + #ifndef __ASOC_TI_MCBSP_H 25 + #define __ASOC_TI_MCBSP_H 24 26 25 27 #include <linux/spinlock.h> 26 28 #include <linux/clk.h>
+1
include/linux/platform_data/davinci_asp.h
··· 92 92 MCASP_VERSION_1 = 0, /* DM646x */ 93 93 MCASP_VERSION_2, /* DA8xx/OMAPL1x */ 94 94 MCASP_VERSION_3, /* TI81xx/AM33xx */ 95 + MCASP_VERSION_4, /* DRA7xxx */ 95 96 }; 96 97 97 98 enum mcbsp_clk_input_pin {
+4 -10
include/sound/cs42l52.h
··· 16 16 /* MICBIAS Level. Check datasheet Pg48 */ 17 17 unsigned int micbias_lvl; 18 18 19 - /* MICA mode selection 0=Single 1=Differential */ 20 - unsigned int mica_cfg; 19 + /* MICA mode selection Differential or Single-ended */ 20 + bool mica_diff_cfg; 21 21 22 - /* MICB mode selection 0=Single 1=Differential */ 23 - unsigned int micb_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; 22 + /* MICB mode selection Differential or Single-ended */ 23 + bool micb_diff_cfg; 30 24 31 25 /* Charge Pump Freq. Check datasheet Pg73 */ 32 26 unsigned int chgfreq;
+12
include/sound/pcm_params.h
··· 354 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 369 #endif /* __SOUND_PCM_PARAMS_H */
+2 -1
include/sound/rcar_snd.h
··· 18 18 #define RSND_GEN1_ADG 1 19 19 #define RSND_GEN1_SSI 2 20 20 21 - #define RSND_GEN2_SRU 0 21 + #define RSND_GEN2_SCU 0 22 22 #define RSND_GEN2_ADG 1 23 23 #define RSND_GEN2_SSIU 2 24 24 #define RSND_GEN2_SSI 3 ··· 58 58 59 59 struct rsnd_scu_platform_info { 60 60 u32 flags; 61 + u32 convert_rate; /* sampling rate convert */ 61 62 }; 62 63 63 64 /*
+11 -4
include/sound/soc.h
··· 334 334 #include <sound/soc-dapm.h> 335 335 #include <sound/soc-dpcm.h> 336 336 337 - #ifdef CONFIG_GPIOLIB 338 337 struct snd_soc_jack_gpio; 339 - #endif 340 338 341 339 typedef int (*hw_write_t)(void *,const char* ,int); 342 340 ··· 444 446 struct snd_soc_jack_gpio *gpios); 445 447 void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, 446 448 struct snd_soc_jack_gpio *gpios); 449 + #else 450 + static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, 451 + struct snd_soc_jack_gpio *gpios) 452 + { 453 + return 0; 454 + } 455 + 456 + static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, 457 + struct snd_soc_jack_gpio *gpios) 458 + { 459 + } 447 460 #endif 448 461 449 462 /* codec register bit access */ ··· 589 580 * to provide more complex checks (eg, reading an 590 581 * ADC). 591 582 */ 592 - #ifdef CONFIG_GPIOLIB 593 583 struct snd_soc_jack_gpio { 594 584 unsigned int gpio; 595 585 const char *name; ··· 602 594 603 595 int (*jack_status_check)(void); 604 596 }; 605 - #endif 606 597 607 598 struct snd_soc_jack { 608 599 struct mutex mutex;
-1
include/sound/spear_dma.h
··· 29 29 dma_addr_t addr; 30 30 u32 max_burst; 31 31 enum dma_slave_buswidth addr_width; 32 - bool (*filter)(struct dma_chan *chan, void *slave); 33 32 }; 34 33 35 34 #endif /* SPEAR_DMA_H */
+3 -1
sound/soc/Kconfig
··· 31 31 select SND_DMAENGINE_PCM 32 32 33 33 # All the supported SoCs 34 + source "sound/soc/adi/Kconfig" 34 35 source "sound/soc/atmel/Kconfig" 35 36 source "sound/soc/au1x/Kconfig" 37 + source "sound/soc/bcm/Kconfig" 36 38 source "sound/soc/blackfin/Kconfig" 37 39 source "sound/soc/cirrus/Kconfig" 38 40 source "sound/soc/davinci/Kconfig" ··· 44 42 source "sound/soc/nuc900/Kconfig" 45 43 source "sound/soc/omap/Kconfig" 46 44 source "sound/soc/kirkwood/Kconfig" 47 - source "sound/soc/mid-x86/Kconfig" 45 + source "sound/soc/intel/Kconfig" 48 46 source "sound/soc/mxs/Kconfig" 49 47 source "sound/soc/pxa/Kconfig" 50 48 source "sound/soc/samsung/Kconfig"
+3 -1
sound/soc/Makefile
··· 8 8 obj-$(CONFIG_SND_SOC) += snd-soc-core.o 9 9 obj-$(CONFIG_SND_SOC) += codecs/ 10 10 obj-$(CONFIG_SND_SOC) += generic/ 11 + obj-$(CONFIG_SND_SOC) += adi/ 11 12 obj-$(CONFIG_SND_SOC) += atmel/ 12 13 obj-$(CONFIG_SND_SOC) += au1x/ 14 + obj-$(CONFIG_SND_SOC) += bcm/ 13 15 obj-$(CONFIG_SND_SOC) += blackfin/ 14 16 obj-$(CONFIG_SND_SOC) += cirrus/ 15 17 obj-$(CONFIG_SND_SOC) += davinci/ 16 18 obj-$(CONFIG_SND_SOC) += dwc/ 17 19 obj-$(CONFIG_SND_SOC) += fsl/ 18 20 obj-$(CONFIG_SND_SOC) += jz4740/ 19 - obj-$(CONFIG_SND_SOC) += mid-x86/ 21 + obj-$(CONFIG_SND_SOC) += intel/ 20 22 obj-$(CONFIG_SND_SOC) += mxs/ 21 23 obj-$(CONFIG_SND_SOC) += nuc900/ 22 24 obj-$(CONFIG_SND_SOC) += omap/
+21
sound/soc/adi/Kconfig
··· 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.
+5
sound/soc/adi/Makefile
··· 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
+277
sound/soc/adi/axi-i2s.c
··· 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");
+272
sound/soc/adi/axi-spdif.c
··· 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");
-2
sound/soc/atmel/sam9x5_wm8731.c
··· 155 155 of_node_put(codec_np); 156 156 of_node_put(cpu_np); 157 157 158 - platform_set_drvdata(pdev, card); 159 - 160 158 ret = snd_soc_register_card(card); 161 159 if (ret) { 162 160 dev_err(&pdev->dev,
-9
sound/soc/au1x/dbdma2.c
··· 65 65 #define AU1XPSC_PERIOD_MIN_BYTES 1024 66 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 68 /* PCM hardware DMA capabilities - platform specific */ 77 69 static const struct snd_pcm_hardware au1xpsc_pcm_hardware = { 78 70 .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | 79 71 SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BATCH, 80 - .formats = AU1XPSC_PCM_FMTS, 81 72 .period_bytes_min = AU1XPSC_PERIOD_MIN_BYTES, 82 73 .period_bytes_max = 4096 * 1024 - 1, 83 74 .periods_min = 2,
-14
sound/soc/au1x/dma.c
··· 21 21 22 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 24 struct pcm_period { 33 25 u32 start; 34 26 u32 relative_end; /* relative to start of buffer */ ··· 163 171 static const struct snd_pcm_hardware alchemy_pcm_hardware = { 164 172 .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | 165 173 SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BATCH, 166 - .formats = ALCHEMY_PCM_FMTS, 167 - .rates = SNDRV_PCM_RATE_8000_192000, 168 - .rate_min = SNDRV_PCM_RATE_8000, 169 - .rate_max = SNDRV_PCM_RATE_192000, 170 - .channels_min = 2, 171 - .channels_max = 2, 172 174 .period_bytes_min = 1024, 173 175 .period_bytes_max = 16 * 1024 - 1, 174 176 .periods_min = 4,
+10
sound/soc/bcm/Kconfig
··· 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.
+5
sound/soc/bcm/Makefile
··· 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 +
+879
sound/soc/bcm/bcm2835-i2s.c
··· 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");
-1
sound/soc/blackfin/bf5xx-ac97-pcm.c
··· 107 107 #endif 108 108 SNDRV_PCM_INFO_BLOCK_TRANSFER, 109 109 110 - .formats = SNDRV_PCM_FMTBIT_S16_LE, 111 110 .period_bytes_min = 32, 112 111 .period_bytes_max = 0x10000, 113 112 .periods_min = 1,
-3
sound/soc/blackfin/bf5xx-i2s-pcm.c
··· 52 52 .info = SNDRV_PCM_INFO_INTERLEAVED | 53 53 SNDRV_PCM_INFO_MMAP_VALID | 54 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 55 .period_bytes_min = 32, 59 56 .period_bytes_max = 0x10000, 60 57 .periods_min = 1,
+1 -1
sound/soc/cirrus/edb93xx.c
··· 63 63 static struct snd_soc_dai_link edb93xx_dai = { 64 64 .name = "CS4271", 65 65 .stream_name = "CS4271 HiFi", 66 - .platform_name = "ep93xx-pcm-audio", 66 + .platform_name = "ep93xx-i2s", 67 67 .cpu_dai_name = "ep93xx-i2s", 68 68 .codec_name = "spi0.0", 69 69 .codec_dai_name = "cs4271-hifi",
+18 -2
sound/soc/cirrus/ep93xx-ac97.c
··· 19 19 #include <linux/slab.h> 20 20 21 21 #include <sound/core.h> 22 + #include <sound/dmaengine_pcm.h> 22 23 #include <sound/ac97_codec.h> 23 24 #include <sound/soc.h> 24 25 25 26 #include <linux/platform_data/dma-ep93xx.h> 27 + 28 + #include "ep93xx-pcm.h" 26 29 27 30 /* 28 31 * Per channel (1-4) registers. ··· 98 95 struct device *dev; 99 96 void __iomem *regs; 100 97 struct completion done; 98 + struct snd_dmaengine_dai_dma_data dma_params_rx; 99 + struct snd_dmaengine_dai_dma_data dma_params_tx; 101 100 }; 102 101 103 102 /* currently ALSA only supports a single AC97 device */ ··· 320 315 321 316 static int ep93xx_ac97_dai_probe(struct snd_soc_dai *dai) 322 317 { 323 - dai->playback_dma_data = &ep93xx_ac97_pcm_out; 324 - dai->capture_dma_data = &ep93xx_ac97_pcm_in; 318 + struct ep93xx_ac97_info *info = snd_soc_dai_get_drvdata(dai); 319 + 320 + info->dma_params_tx.filter_data = &ep93xx_ac97_pcm_out; 321 + info->dma_params_rx.filter_data = &ep93xx_ac97_pcm_in; 322 + 323 + dai->playback_dma_data = &info->dma_params_tx; 324 + dai->capture_dma_data = &info->dma_params_rx; 325 325 326 326 return 0; 327 327 } ··· 404 394 if (ret) 405 395 goto fail; 406 396 397 + ret = devm_ep93xx_pcm_platform_register(&pdev->dev); 398 + if (ret) 399 + goto fail_unregister; 400 + 407 401 return 0; 408 402 403 + fail_unregister: 404 + snd_soc_unregister_component(&pdev->dev); 409 405 fail: 410 406 ep93xx_ac97_info = NULL; 411 407 snd_soc_set_ac97_ops(NULL);
+20 -2
sound/soc/cirrus/ep93xx-i2s.c
··· 21 21 #include <linux/io.h> 22 22 23 23 #include <sound/core.h> 24 + #include <sound/dmaengine_pcm.h> 24 25 #include <sound/pcm.h> 25 26 #include <sound/pcm_params.h> 26 27 #include <sound/initval.h> ··· 30 29 #include <mach/hardware.h> 31 30 #include <mach/ep93xx-regs.h> 32 31 #include <linux/platform_data/dma-ep93xx.h> 32 + 33 + #include "ep93xx-pcm.h" 33 34 34 35 #define EP93XX_I2S_TXCLKCFG 0x00 35 36 #define EP93XX_I2S_RXCLKCFG 0x04 ··· 64 61 struct clk *sclk; 65 62 struct clk *lrclk; 66 63 void __iomem *regs; 64 + struct snd_dmaengine_dai_dma_data dma_params_rx; 65 + struct snd_dmaengine_dai_dma_data dma_params_tx; 67 66 }; 68 67 69 68 static struct ep93xx_dma_data ep93xx_i2s_dma_data[] = { ··· 145 140 146 141 static int ep93xx_i2s_dai_probe(struct snd_soc_dai *dai) 147 142 { 148 - dai->playback_dma_data = &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_PLAYBACK]; 149 - dai->capture_dma_data = &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_CAPTURE]; 143 + struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); 144 + 145 + info->dma_params_tx.filter_data = 146 + &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_PLAYBACK]; 147 + info->dma_params_rx.filter_data = 148 + &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_CAPTURE]; 149 + 150 + dai->playback_dma_data = &info->dma_params_tx; 151 + dai->capture_dma_data = &info->dma_params_rx; 150 152 151 153 return 0; 152 154 } ··· 417 405 if (err) 418 406 goto fail_put_lrclk; 419 407 408 + err = devm_ep93xx_pcm_platform_register(&pdev->dev); 409 + if (err) 410 + goto fail_unregister; 411 + 420 412 return 0; 421 413 414 + fail_unregister: 415 + snd_soc_unregister_component(&pdev->dev); 422 416 fail_put_lrclk: 423 417 clk_put(info->lrclk); 424 418 fail_put_sclk:
+5 -43
sound/soc/cirrus/ep93xx-pcm.c
··· 23 23 24 24 #include <linux/platform_data/dma-ep93xx.h> 25 25 26 + #include "ep93xx-pcm.h" 27 + 26 28 static const struct snd_pcm_hardware ep93xx_pcm_hardware = { 27 29 .info = (SNDRV_PCM_INFO_MMAP | 28 30 SNDRV_PCM_INFO_MMAP_VALID | 29 31 SNDRV_PCM_INFO_INTERLEAVED | 30 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 33 .buffer_bytes_max = 131072, 41 34 .period_bytes_min = 32, 42 35 .period_bytes_max = 32768, ··· 50 57 return false; 51 58 } 52 59 53 - static struct dma_chan *ep93xx_compat_request_channel( 54 - struct snd_soc_pcm_runtime *rtd, 55 - struct snd_pcm_substream *substream) 56 - { 57 - struct snd_dmaengine_dai_dma_data *dma_data; 58 - 59 - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 60 - 61 - return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter, 62 - dma_data); 63 - } 64 - 65 60 static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = { 66 61 .pcm_hardware = &ep93xx_pcm_hardware, 67 62 .compat_filter_fn = ep93xx_pcm_dma_filter, 68 - .compat_request_channel = ep93xx_compat_request_channel, 69 63 .prealloc_buffer_size = 131072, 70 64 }; 71 65 72 - static int ep93xx_soc_platform_probe(struct platform_device *pdev) 66 + int devm_ep93xx_pcm_platform_register(struct device *dev) 73 67 { 74 - return snd_dmaengine_pcm_register(&pdev->dev, 68 + return devm_snd_dmaengine_pcm_register(dev, 75 69 &ep93xx_dmaengine_pcm_config, 76 70 SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | 77 71 SND_DMAENGINE_PCM_FLAG_NO_DT | 78 72 SND_DMAENGINE_PCM_FLAG_COMPAT); 79 73 } 80 - 81 - static int ep93xx_soc_platform_remove(struct platform_device *pdev) 82 - { 83 - snd_dmaengine_pcm_unregister(&pdev->dev); 84 - return 0; 85 - } 86 - 87 - static struct platform_driver ep93xx_pcm_driver = { 88 - .driver = { 89 - .name = "ep93xx-pcm-audio", 90 - .owner = THIS_MODULE, 91 - }, 92 - 93 - .probe = ep93xx_soc_platform_probe, 94 - .remove = ep93xx_soc_platform_remove, 95 - }; 96 - 97 - module_platform_driver(ep93xx_pcm_driver); 74 + EXPORT_SYMBOL_GPL(devm_ep93xx_pcm_platform_register); 98 75 99 76 MODULE_AUTHOR("Ryan Mallon"); 100 77 MODULE_DESCRIPTION("EP93xx ALSA PCM interface"); 101 78 MODULE_LICENSE("GPL"); 102 - MODULE_ALIAS("platform:ep93xx-pcm-audio");
+22
sound/soc/cirrus/ep93xx-pcm.h
··· 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
+1 -1
sound/soc/cirrus/simone.c
··· 27 27 .cpu_dai_name = "ep93xx-ac97", 28 28 .codec_dai_name = "ac97-hifi", 29 29 .codec_name = "ac97-codec", 30 - .platform_name = "ep93xx-pcm-audio", 30 + .platform_name = "ep93xx-ac97", 31 31 }; 32 32 33 33 static struct snd_soc_card snd_soc_simone = {
+1 -1
sound/soc/cirrus/snappercl15.c
··· 83 83 .cpu_dai_name = "ep93xx-i2s", 84 84 .codec_dai_name = "tlv320aic23-hifi", 85 85 .codec_name = "tlv320aic23-codec.0-001a", 86 - .platform_name = "ep93xx-pcm-audio", 86 + .platform_name = "ep93xx-i2s", 87 87 .init = snappercl15_tlv320aic23_init, 88 88 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF | 89 89 SND_SOC_DAIFMT_CBS_CFS,
+2
sound/soc/codecs/Kconfig
··· 163 163 config SND_SOC_WM_ADSP 164 164 tristate 165 165 default y if SND_SOC_WM5102=y 166 + default y if SND_SOC_WM5110=y 166 167 default y if SND_SOC_WM2200=y 167 168 default m if SND_SOC_WM5102=m 169 + default m if SND_SOC_WM5110=m 168 170 default m if SND_SOC_WM2200=m 169 171 170 172 config SND_SOC_AB8500_CODEC
+2
sound/soc/codecs/ad1836.c
··· 179 179 case SNDRV_PCM_FORMAT_S32_LE: 180 180 word_len = AD1836_WORD_LEN_24; 181 181 break; 182 + default: 183 + return -EINVAL; 182 184 } 183 185 184 186 regmap_update_bits(ad1836->regmap, AD1836_DAC_CTRL1,
+3 -3
sound/soc/codecs/ad193x.c
··· 413 413 }; 414 414 #endif 415 415 416 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 416 + #if IS_ENABLED(CONFIG_I2C) 417 417 418 418 static const struct regmap_config ad193x_i2c_regmap_config = { 419 419 .val_bits = 8, ··· 470 470 { 471 471 int ret; 472 472 473 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 473 + #if IS_ENABLED(CONFIG_I2C) 474 474 ret = i2c_add_driver(&ad193x_i2c_driver); 475 475 if (ret != 0) { 476 476 printk(KERN_ERR "Failed to register AD193X I2C driver: %d\n", ··· 495 495 spi_unregister_driver(&ad193x_spi_driver); 496 496 #endif 497 497 498 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 498 + #if IS_ENABLED(CONFIG_I2C) 499 499 i2c_del_driver(&ad193x_i2c_driver); 500 500 #endif 501 501 }
+3 -3
sound/soc/codecs/adav80x.c
··· 939 939 }; 940 940 #endif 941 941 942 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 942 + #if IS_ENABLED(CONFIG_I2C) 943 943 static const struct regmap_config adav80x_i2c_regmap_config = { 944 944 .val_bits = 8, 945 945 .pad_bits = 1, ··· 985 985 { 986 986 int ret = 0; 987 987 988 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 988 + #if IS_ENABLED(CONFIG_I2C) 989 989 ret = i2c_add_driver(&adav80x_i2c_driver); 990 990 if (ret) 991 991 return ret; ··· 1001 1001 1002 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 1005 i2c_del_driver(&adav80x_i2c_driver); 1006 1006 #endif 1007 1007 #if defined(CONFIG_SPI_MASTER)
+25 -13
sound/soc/codecs/ak4641.c
··· 17 17 #include <linux/gpio.h> 18 18 #include <linux/pm.h> 19 19 #include <linux/i2c.h> 20 + #include <linux/regmap.h> 20 21 #include <linux/slab.h> 21 22 #include <sound/core.h> 22 23 #include <sound/pcm.h> ··· 31 30 32 31 /* codec private data */ 33 32 struct ak4641_priv { 33 + struct regmap *regmap; 34 34 unsigned int sysclk; 35 35 int deemph; 36 36 int playback_fs; ··· 40 38 /* 41 39 * ak4641 register cache 42 40 */ 43 - static const u8 ak4641_reg[AK4641_CACHEREGNUM] = { 44 - 0x00, 0x80, 0x00, 0x80, 45 - 0x02, 0x00, 0x11, 0x05, 46 - 0x00, 0x00, 0x36, 0x10, 47 - 0x00, 0x00, 0x57, 0x00, 48 - 0x88, 0x88, 0x08, 0x08 41 + static const struct reg_default ak4641_reg_defaults[] = { 42 + { 0, 0x00 }, { 1, 0x80 }, { 2, 0x00 }, { 3, 0x80 }, 43 + { 4, 0x02 }, { 5, 0x00 }, { 6, 0x11 }, { 7, 0x05 }, 44 + { 8, 0x00 }, { 9, 0x00 }, { 10, 0x36 }, { 11, 0x10 }, 45 + { 12, 0x00 }, { 13, 0x00 }, { 14, 0x57 }, { 15, 0x00 }, 46 + { 16, 0x88 }, { 17, 0x88 }, { 18, 0x08 }, { 19, 0x08 } 49 47 }; 50 48 51 49 static const int deemph_settings[] = {44100, 0, 48000, 32000}; ··· 398 396 static int ak4641_set_bias_level(struct snd_soc_codec *codec, 399 397 enum snd_soc_bias_level level) 400 398 { 399 + struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); 401 400 struct ak4641_platform_data *pdata = codec->dev->platform_data; 402 401 int ret; 403 402 ··· 420 417 gpio_set_value(pdata->gpio_npdn, 1); 421 418 mdelay(1); 422 419 423 - ret = snd_soc_cache_sync(codec); 420 + ret = regcache_sync(ak4641->regmap); 424 421 if (ret) { 425 422 dev_err(codec->dev, 426 423 "Failed to sync cache: %d\n", ret); ··· 436 433 gpio_set_value(pdata->gpio_npdn, 0); 437 434 if (pdata && gpio_is_valid(pdata->gpio_power)) 438 435 gpio_set_value(pdata->gpio_power, 0); 439 - codec->cache_sync = 1; 436 + regcache_mark_dirty(ak4641->regmap); 440 437 break; 441 438 } 442 439 codec->dapm.bias_level = level; ··· 521 518 { 522 519 int ret; 523 520 524 - ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); 521 + ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); 525 522 if (ret != 0) { 526 523 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 527 524 return ret; ··· 553 550 .dapm_routes = ak4641_audio_map, 554 551 .num_dapm_routes = ARRAY_SIZE(ak4641_audio_map), 555 552 .set_bias_level = ak4641_set_bias_level, 556 - .reg_cache_size = ARRAY_SIZE(ak4641_reg), 557 - .reg_word_size = sizeof(u8), 558 - .reg_cache_default = ak4641_reg, 559 - .reg_cache_step = 1, 560 553 }; 561 554 555 + static const struct regmap_config ak4641_regmap = { 556 + .reg_bits = 8, 557 + .val_bits = 8, 558 + 559 + .max_register = AK4641_BTIF, 560 + .reg_defaults = ak4641_reg_defaults, 561 + .num_reg_defaults = ARRAY_SIZE(ak4641_reg_defaults), 562 + .cache_type = REGCACHE_RBTREE, 563 + }; 562 564 563 565 static int ak4641_i2c_probe(struct i2c_client *i2c, 564 566 const struct i2c_device_id *id) ··· 576 568 GFP_KERNEL); 577 569 if (!ak4641) 578 570 return -ENOMEM; 571 + 572 + ak4641->regmap = devm_regmap_init_i2c(i2c, &ak4641_regmap); 573 + if (IS_ERR(ak4641->regmap)) 574 + return PTR_ERR(ak4641->regmap); 579 575 580 576 if (pdata) { 581 577 if (gpio_is_valid(pdata->gpio_power)) {
+62 -76
sound/soc/codecs/ak4642.c
··· 28 28 #include <linux/slab.h> 29 29 #include <linux/of_device.h> 30 30 #include <linux/module.h> 31 + #include <linux/regmap.h> 31 32 #include <sound/soc.h> 32 33 #include <sound/initval.h> 33 34 #include <sound/tlv.h> ··· 199 198 /* 200 199 * ak4642 register cache 201 200 */ 202 - static const u8 ak4642_reg[] = { 203 - 0x00, 0x00, 0x01, 0x00, 204 - 0x02, 0x00, 0x00, 0x00, 205 - 0xe1, 0xe1, 0x18, 0x00, 206 - 0xe1, 0x18, 0x11, 0x08, 207 - 0x00, 0x00, 0x00, 0x00, 208 - 0x00, 0x00, 0x00, 0x00, 209 - 0x00, 0x00, 0x00, 0x00, 210 - 0x00, 0x00, 0x00, 0x00, 211 - 0x00, 0x00, 0x00, 0x00, 212 - 0x00, 201 + static const struct reg_default ak4642_reg[] = { 202 + { 0, 0x00 }, { 1, 0x00 }, { 2, 0x01 }, { 3, 0x00 }, 203 + { 4, 0x02 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x00 }, 204 + { 8, 0xe1 }, { 9, 0xe1 }, { 10, 0x18 }, { 11, 0x00 }, 205 + { 12, 0xe1 }, { 13, 0x18 }, { 14, 0x11 }, { 15, 0x08 }, 206 + { 16, 0x00 }, { 17, 0x00 }, { 18, 0x00 }, { 19, 0x00 }, 207 + { 20, 0x00 }, { 21, 0x00 }, { 22, 0x00 }, { 23, 0x00 }, 208 + { 24, 0x00 }, { 25, 0x00 }, { 26, 0x00 }, { 27, 0x00 }, 209 + { 28, 0x00 }, { 29, 0x00 }, { 30, 0x00 }, { 31, 0x00 }, 210 + { 32, 0x00 }, { 33, 0x00 }, { 34, 0x00 }, { 35, 0x00 }, 211 + { 36, 0x00 }, 213 212 }; 214 213 215 - static const u8 ak4648_reg[] = { 216 - 0x00, 0x00, 0x01, 0x00, 217 - 0x02, 0x00, 0x00, 0x00, 218 - 0xe1, 0xe1, 0x18, 0x00, 219 - 0xe1, 0x18, 0x11, 0xb8, 220 - 0x00, 0x00, 0x00, 0x00, 221 - 0x00, 0x00, 0x00, 0x00, 222 - 0x00, 0x00, 0x00, 0x00, 223 - 0x00, 0x00, 0x00, 0x00, 224 - 0x00, 0x00, 0x00, 0x00, 225 - 0x00, 0x88, 0x88, 0x08, 214 + static const struct reg_default ak4648_reg[] = { 215 + { 0, 0x00 }, { 1, 0x00 }, { 2, 0x01 }, { 3, 0x00 }, 216 + { 4, 0x02 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x00 }, 217 + { 8, 0xe1 }, { 9, 0xe1 }, { 10, 0x18 }, { 11, 0x00 }, 218 + { 12, 0xe1 }, { 13, 0x18 }, { 14, 0x11 }, { 15, 0xb8 }, 219 + { 16, 0x00 }, { 17, 0x00 }, { 18, 0x00 }, { 19, 0x00 }, 220 + { 20, 0x00 }, { 21, 0x00 }, { 22, 0x00 }, { 23, 0x00 }, 221 + { 24, 0x00 }, { 25, 0x00 }, { 26, 0x00 }, { 27, 0x00 }, 222 + { 28, 0x00 }, { 29, 0x00 }, { 30, 0x00 }, { 31, 0x00 }, 223 + { 32, 0x00 }, { 33, 0x00 }, { 34, 0x00 }, { 35, 0x00 }, 224 + { 36, 0x00 }, { 37, 0x88 }, { 38, 0x88 }, { 39, 0x08 }, 226 225 }; 227 226 228 227 static int ak4642_dai_startup(struct snd_pcm_substream *substream, ··· 455 454 456 455 static int ak4642_resume(struct snd_soc_codec *codec) 457 456 { 458 - snd_soc_cache_sync(codec); 457 + struct regmap *regmap = dev_get_regmap(codec->dev, NULL); 458 + 459 + regcache_mark_dirty(regmap); 460 + regcache_sync(regmap); 459 461 return 0; 460 462 } 461 463 ··· 467 463 { 468 464 int ret; 469 465 470 - ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); 466 + ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); 471 467 if (ret < 0) { 472 468 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 473 469 return ret; 474 470 } 475 - 476 - snd_soc_add_codec_controls(codec, ak4642_snd_controls, 477 - ARRAY_SIZE(ak4642_snd_controls)); 478 471 479 472 ak4642_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 480 473 ··· 489 488 .remove = ak4642_remove, 490 489 .resume = ak4642_resume, 491 490 .set_bias_level = ak4642_set_bias_level, 492 - .reg_cache_default = ak4642_reg, /* ak4642 reg */ 493 - .reg_cache_size = ARRAY_SIZE(ak4642_reg), /* ak4642 reg */ 494 - .reg_word_size = sizeof(u8), 491 + .controls = ak4642_snd_controls, 492 + .num_controls = ARRAY_SIZE(ak4642_snd_controls), 495 493 .dapm_widgets = ak4642_dapm_widgets, 496 494 .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), 497 495 .dapm_routes = ak4642_intercon, 498 496 .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), 499 497 }; 500 498 501 - static struct snd_soc_codec_driver soc_codec_dev_ak4648 = { 502 - .probe = ak4642_probe, 503 - .remove = ak4642_remove, 504 - .resume = ak4642_resume, 505 - .set_bias_level = ak4642_set_bias_level, 506 - .reg_cache_default = ak4648_reg, /* ak4648 reg */ 507 - .reg_cache_size = ARRAY_SIZE(ak4648_reg), /* ak4648 reg */ 508 - .reg_word_size = sizeof(u8), 509 - .dapm_widgets = ak4642_dapm_widgets, 510 - .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), 511 - .dapm_routes = ak4642_intercon, 512 - .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), 499 + static const struct regmap_config ak4642_regmap = { 500 + .reg_bits = 8, 501 + .val_bits = 8, 502 + .max_register = ARRAY_SIZE(ak4642_reg) + 1, 503 + .reg_defaults = ak4642_reg, 504 + .num_reg_defaults = ARRAY_SIZE(ak4642_reg), 513 505 }; 514 506 515 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 507 + static const struct regmap_config ak4648_regmap = { 508 + .reg_bits = 8, 509 + .val_bits = 8, 510 + .max_register = ARRAY_SIZE(ak4648_reg) + 1, 511 + .reg_defaults = ak4648_reg, 512 + .num_reg_defaults = ARRAY_SIZE(ak4648_reg), 513 + }; 514 + 516 515 static struct of_device_id ak4642_of_match[]; 517 516 static int ak4642_i2c_probe(struct i2c_client *i2c, 518 517 const struct i2c_device_id *id) 519 518 { 520 519 struct device_node *np = i2c->dev.of_node; 521 - const struct snd_soc_codec_driver *driver; 520 + const struct regmap_config *regmap_config = NULL; 521 + struct regmap *regmap; 522 522 523 - driver = NULL; 524 523 if (np) { 525 524 const struct of_device_id *of_id; 526 525 527 526 of_id = of_match_device(ak4642_of_match, &i2c->dev); 528 527 if (of_id) 529 - driver = of_id->data; 528 + regmap_config = of_id->data; 530 529 } else { 531 - driver = (struct snd_soc_codec_driver *)id->driver_data; 530 + regmap_config = (const struct regmap_config *)id->driver_data; 532 531 } 533 532 534 - if (!driver) { 535 - dev_err(&i2c->dev, "no driver\n"); 533 + if (!regmap_config) { 534 + dev_err(&i2c->dev, "Unknown device type\n"); 536 535 return -EINVAL; 537 536 } 538 537 538 + regmap = devm_regmap_init_i2c(i2c, regmap_config); 539 + if (IS_ERR(regmap)) 540 + return PTR_ERR(regmap); 541 + 539 542 return snd_soc_register_codec(&i2c->dev, 540 - driver, &ak4642_dai, 1); 543 + &soc_codec_dev_ak4642, &ak4642_dai, 1); 541 544 } 542 545 543 546 static int ak4642_i2c_remove(struct i2c_client *client) ··· 551 546 } 552 547 553 548 static struct of_device_id ak4642_of_match[] = { 554 - { .compatible = "asahi-kasei,ak4642", .data = &soc_codec_dev_ak4642}, 555 - { .compatible = "asahi-kasei,ak4643", .data = &soc_codec_dev_ak4642}, 556 - { .compatible = "asahi-kasei,ak4648", .data = &soc_codec_dev_ak4648}, 549 + { .compatible = "asahi-kasei,ak4642", .data = &ak4642_regmap}, 550 + { .compatible = "asahi-kasei,ak4643", .data = &ak4642_regmap}, 551 + { .compatible = "asahi-kasei,ak4648", .data = &ak4648_regmap}, 557 552 {}, 558 553 }; 559 554 MODULE_DEVICE_TABLE(of, ak4642_of_match); 560 555 561 556 static const struct i2c_device_id ak4642_i2c_id[] = { 562 - { "ak4642", (kernel_ulong_t)&soc_codec_dev_ak4642 }, 563 - { "ak4643", (kernel_ulong_t)&soc_codec_dev_ak4642 }, 564 - { "ak4648", (kernel_ulong_t)&soc_codec_dev_ak4648 }, 557 + { "ak4642", (kernel_ulong_t)&ak4642_regmap }, 558 + { "ak4643", (kernel_ulong_t)&ak4642_regmap }, 559 + { "ak4648", (kernel_ulong_t)&ak4648_regmap }, 565 560 { } 566 561 }; 567 562 MODULE_DEVICE_TABLE(i2c, ak4642_i2c_id); ··· 576 571 .remove = ak4642_i2c_remove, 577 572 .id_table = ak4642_i2c_id, 578 573 }; 579 - #endif 580 574 581 - static int __init ak4642_modinit(void) 582 - { 583 - int ret = 0; 584 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 585 - ret = i2c_add_driver(&ak4642_i2c_driver); 586 - #endif 587 - return ret; 588 - 589 - } 590 - module_init(ak4642_modinit); 591 - 592 - static void __exit ak4642_exit(void) 593 - { 594 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 595 - i2c_del_driver(&ak4642_i2c_driver); 596 - #endif 597 - 598 - } 599 - module_exit(ak4642_exit); 575 + module_i2c_driver(ak4642_i2c_driver); 600 576 601 577 MODULE_DESCRIPTION("Soc AK4642 driver"); 602 578 MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>");
+130 -74
sound/soc/codecs/arizona.c
··· 93 93 switch (event) { 94 94 case SND_SOC_DAPM_PRE_PMU: 95 95 if (!priv->spk_ena && manual_ena) { 96 - snd_soc_write(codec, 0x4f5, 0x25a); 96 + regmap_write_async(arizona->regmap, 0x4f5, 0x25a); 97 97 priv->spk_ena_pending = true; 98 98 } 99 99 break; ··· 105 105 return -EBUSY; 106 106 } 107 107 108 - snd_soc_update_bits(codec, ARIZONA_OUTPUT_ENABLES_1, 109 - 1 << w->shift, 1 << w->shift); 108 + regmap_update_bits_async(arizona->regmap, 109 + ARIZONA_OUTPUT_ENABLES_1, 110 + 1 << w->shift, 1 << w->shift); 110 111 111 112 if (priv->spk_ena_pending) { 112 113 msleep(75); 113 - snd_soc_write(codec, 0x4f5, 0xda); 114 + regmap_write_async(arizona->regmap, 0x4f5, 0xda); 114 115 priv->spk_ena_pending = false; 115 116 priv->spk_ena++; 116 117 } ··· 120 119 if (manual_ena) { 121 120 priv->spk_ena--; 122 121 if (!priv->spk_ena) 123 - snd_soc_write(codec, 0x4f5, 0x25a); 122 + regmap_write_async(arizona->regmap, 123 + 0x4f5, 0x25a); 124 124 } 125 125 126 - snd_soc_update_bits(codec, ARIZONA_OUTPUT_ENABLES_1, 127 - 1 << w->shift, 0); 126 + regmap_update_bits_async(arizona->regmap, 127 + ARIZONA_OUTPUT_ENABLES_1, 128 + 1 << w->shift, 0); 128 129 break; 129 130 case SND_SOC_DAPM_POST_PMD: 130 131 if (manual_ena) { 131 132 if (!priv->spk_ena) 132 - snd_soc_write(codec, 0x4f5, 0x0da); 133 + regmap_write_async(arizona->regmap, 134 + 0x4f5, 0x0da); 133 135 } 134 136 break; 135 137 } ··· 296 292 "AIF1RX8", 297 293 "AIF2RX1", 298 294 "AIF2RX2", 295 + "AIF2RX3", 296 + "AIF2RX4", 297 + "AIF2RX5", 298 + "AIF2RX6", 299 299 "AIF3RX1", 300 300 "AIF3RX2", 301 301 "SLIMRX1", ··· 403 395 0x27, 404 396 0x28, /* AIF2RX1 */ 405 397 0x29, 398 + 0x2a, 399 + 0x2b, 400 + 0x2c, 401 + 0x2d, 406 402 0x30, /* AIF3RX1 */ 407 403 0x31, 408 404 0x38, /* SLIMRX1 */ ··· 498 486 EXPORT_SYMBOL_GPL(arizona_rate_val); 499 487 500 488 489 + const struct soc_enum arizona_isrc_fsh[] = { 490 + SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_1_CTRL_1, 491 + ARIZONA_ISRC1_FSH_SHIFT, 0xf, 492 + ARIZONA_RATE_ENUM_SIZE, 493 + arizona_rate_text, arizona_rate_val), 494 + SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_2_CTRL_1, 495 + ARIZONA_ISRC2_FSH_SHIFT, 0xf, 496 + ARIZONA_RATE_ENUM_SIZE, 497 + arizona_rate_text, arizona_rate_val), 498 + SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_3_CTRL_1, 499 + ARIZONA_ISRC3_FSH_SHIFT, 0xf, 500 + ARIZONA_RATE_ENUM_SIZE, 501 + arizona_rate_text, arizona_rate_val), 502 + }; 503 + EXPORT_SYMBOL_GPL(arizona_isrc_fsh); 504 + 501 505 const struct soc_enum arizona_isrc_fsl[] = { 502 506 SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_1_CTRL_2, 503 507 ARIZONA_ISRC1_FSL_SHIFT, 0xf, ··· 529 501 arizona_rate_text, arizona_rate_val), 530 502 }; 531 503 EXPORT_SYMBOL_GPL(arizona_isrc_fsl); 504 + 505 + const struct soc_enum arizona_asrc_rate1 = 506 + SOC_VALUE_ENUM_SINGLE(ARIZONA_ASRC_RATE1, 507 + ARIZONA_ASRC_RATE1_SHIFT, 0xf, 508 + ARIZONA_RATE_ENUM_SIZE - 1, 509 + arizona_rate_text, arizona_rate_val); 510 + EXPORT_SYMBOL_GPL(arizona_asrc_rate1); 532 511 533 512 static const char *arizona_vol_ramp_text[] = { 534 513 "0ms/6dB", "0.5ms/6dB", "1ms/6dB", "2ms/6dB", "4ms/6dB", "8ms/6dB", ··· 594 559 SOC_ENUM_SINGLE(ARIZONA_NOISE_GATE_CONTROL, ARIZONA_NGATE_HOLD_SHIFT, 595 560 4, arizona_ng_hold_text); 596 561 EXPORT_SYMBOL_GPL(arizona_ng_hold); 562 + 563 + static const char * const arizona_in_hpf_cut_text[] = { 564 + "2.5Hz", "5Hz", "10Hz", "20Hz", "40Hz" 565 + }; 566 + 567 + const struct soc_enum arizona_in_hpf_cut_enum = 568 + SOC_ENUM_SINGLE(ARIZONA_HPF_CONTROL, ARIZONA_IN_HPF_CUT_SHIFT, 569 + ARRAY_SIZE(arizona_in_hpf_cut_text), 570 + arizona_in_hpf_cut_text); 571 + EXPORT_SYMBOL_GPL(arizona_in_hpf_cut_enum); 597 572 598 573 static const char * const arizona_in_dmic_osr_text[] = { 599 574 "1.536MHz", "3.072MHz", "6.144MHz", ··· 714 669 int event) 715 670 { 716 671 struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); 672 + struct arizona *arizona = priv->arizona; 717 673 unsigned int mask = 1 << w->shift; 718 674 unsigned int val; 719 675 ··· 737 691 if (priv->arizona->hpdet_magic) 738 692 val = 0; 739 693 740 - snd_soc_update_bits(w->codec, ARIZONA_OUTPUT_ENABLES_1, mask, val); 694 + regmap_update_bits_async(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1, 695 + mask, val); 741 696 742 697 return arizona_out_ev(w, kcontrol, event); 743 698 } ··· 893 846 static int arizona_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 894 847 { 895 848 struct snd_soc_codec *codec = dai->codec; 849 + struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); 850 + struct arizona *arizona = priv->arizona; 896 851 int lrclk, bclk, mode, base; 897 852 898 853 base = dai->driver->base; ··· 951 902 return -EINVAL; 952 903 } 953 904 954 - snd_soc_update_bits(codec, base + ARIZONA_AIF_BCLK_CTRL, 955 - ARIZONA_AIF1_BCLK_INV | ARIZONA_AIF1_BCLK_MSTR, 956 - bclk); 957 - snd_soc_update_bits(codec, base + ARIZONA_AIF_TX_PIN_CTRL, 958 - ARIZONA_AIF1TX_LRCLK_INV | 959 - ARIZONA_AIF1TX_LRCLK_MSTR, lrclk); 960 - snd_soc_update_bits(codec, base + ARIZONA_AIF_RX_PIN_CTRL, 961 - ARIZONA_AIF1RX_LRCLK_INV | 962 - ARIZONA_AIF1RX_LRCLK_MSTR, lrclk); 963 - snd_soc_update_bits(codec, base + ARIZONA_AIF_FORMAT, 964 - ARIZONA_AIF1_FMT_MASK, mode); 905 + regmap_update_bits_async(arizona->regmap, base + ARIZONA_AIF_BCLK_CTRL, 906 + ARIZONA_AIF1_BCLK_INV | 907 + ARIZONA_AIF1_BCLK_MSTR, 908 + bclk); 909 + regmap_update_bits_async(arizona->regmap, base + ARIZONA_AIF_TX_PIN_CTRL, 910 + ARIZONA_AIF1TX_LRCLK_INV | 911 + ARIZONA_AIF1TX_LRCLK_MSTR, lrclk); 912 + regmap_update_bits_async(arizona->regmap, 913 + base + ARIZONA_AIF_RX_PIN_CTRL, 914 + ARIZONA_AIF1RX_LRCLK_INV | 915 + ARIZONA_AIF1RX_LRCLK_MSTR, lrclk); 916 + regmap_update_bits(arizona->regmap, base + ARIZONA_AIF_FORMAT, 917 + ARIZONA_AIF1_FMT_MASK, mode); 965 918 966 919 return 0; 967 920 } ··· 1215 1164 if (ret != 0) 1216 1165 return ret; 1217 1166 1218 - snd_soc_update_bits(codec, base + ARIZONA_AIF_BCLK_CTRL, 1219 - ARIZONA_AIF1_BCLK_FREQ_MASK, bclk); 1220 - snd_soc_update_bits(codec, base + ARIZONA_AIF_TX_BCLK_RATE, 1221 - ARIZONA_AIF1TX_BCPF_MASK, lrclk); 1222 - snd_soc_update_bits(codec, base + ARIZONA_AIF_RX_BCLK_RATE, 1223 - ARIZONA_AIF1RX_BCPF_MASK, lrclk); 1224 - snd_soc_update_bits(codec, base + ARIZONA_AIF_FRAME_CTRL_1, 1225 - ARIZONA_AIF1TX_WL_MASK | 1226 - ARIZONA_AIF1TX_SLOT_LEN_MASK, frame); 1227 - snd_soc_update_bits(codec, base + ARIZONA_AIF_FRAME_CTRL_2, 1228 - ARIZONA_AIF1RX_WL_MASK | 1229 - ARIZONA_AIF1RX_SLOT_LEN_MASK, frame); 1167 + regmap_update_bits_async(arizona->regmap, 1168 + base + ARIZONA_AIF_BCLK_CTRL, 1169 + ARIZONA_AIF1_BCLK_FREQ_MASK, bclk); 1170 + regmap_update_bits_async(arizona->regmap, 1171 + base + ARIZONA_AIF_TX_BCLK_RATE, 1172 + ARIZONA_AIF1TX_BCPF_MASK, lrclk); 1173 + regmap_update_bits_async(arizona->regmap, 1174 + base + ARIZONA_AIF_RX_BCLK_RATE, 1175 + ARIZONA_AIF1RX_BCPF_MASK, lrclk); 1176 + regmap_update_bits_async(arizona->regmap, 1177 + base + ARIZONA_AIF_FRAME_CTRL_1, 1178 + ARIZONA_AIF1TX_WL_MASK | 1179 + ARIZONA_AIF1TX_SLOT_LEN_MASK, frame); 1180 + regmap_update_bits(arizona->regmap, base + ARIZONA_AIF_FRAME_CTRL_2, 1181 + ARIZONA_AIF1RX_WL_MASK | 1182 + ARIZONA_AIF1RX_SLOT_LEN_MASK, frame); 1230 1183 1231 1184 return 0; 1232 1185 } ··· 1483 1428 struct arizona_fll_cfg *cfg, int source, 1484 1429 bool sync) 1485 1430 { 1486 - regmap_update_bits(arizona->regmap, base + 3, 1487 - ARIZONA_FLL1_THETA_MASK, cfg->theta); 1488 - regmap_update_bits(arizona->regmap, base + 4, 1489 - ARIZONA_FLL1_LAMBDA_MASK, cfg->lambda); 1490 - regmap_update_bits(arizona->regmap, base + 5, 1491 - ARIZONA_FLL1_FRATIO_MASK, 1492 - cfg->fratio << ARIZONA_FLL1_FRATIO_SHIFT); 1493 - regmap_update_bits(arizona->regmap, base + 6, 1494 - ARIZONA_FLL1_CLK_REF_DIV_MASK | 1495 - ARIZONA_FLL1_CLK_REF_SRC_MASK, 1496 - cfg->refdiv << ARIZONA_FLL1_CLK_REF_DIV_SHIFT | 1497 - source << ARIZONA_FLL1_CLK_REF_SRC_SHIFT); 1431 + regmap_update_bits_async(arizona->regmap, base + 3, 1432 + ARIZONA_FLL1_THETA_MASK, cfg->theta); 1433 + regmap_update_bits_async(arizona->regmap, base + 4, 1434 + ARIZONA_FLL1_LAMBDA_MASK, cfg->lambda); 1435 + regmap_update_bits_async(arizona->regmap, base + 5, 1436 + ARIZONA_FLL1_FRATIO_MASK, 1437 + cfg->fratio << ARIZONA_FLL1_FRATIO_SHIFT); 1438 + regmap_update_bits_async(arizona->regmap, base + 6, 1439 + ARIZONA_FLL1_CLK_REF_DIV_MASK | 1440 + ARIZONA_FLL1_CLK_REF_SRC_MASK, 1441 + cfg->refdiv << ARIZONA_FLL1_CLK_REF_DIV_SHIFT | 1442 + source << ARIZONA_FLL1_CLK_REF_SRC_SHIFT); 1498 1443 1499 1444 if (sync) 1500 - regmap_update_bits(arizona->regmap, base + 0x7, 1501 - ARIZONA_FLL1_GAIN_MASK, 1502 - cfg->gain << ARIZONA_FLL1_GAIN_SHIFT); 1445 + regmap_update_bits_async(arizona->regmap, base + 0x7, 1446 + ARIZONA_FLL1_GAIN_MASK, 1447 + cfg->gain << ARIZONA_FLL1_GAIN_SHIFT); 1503 1448 else 1504 - regmap_update_bits(arizona->regmap, base + 0x9, 1505 - ARIZONA_FLL1_GAIN_MASK, 1506 - cfg->gain << ARIZONA_FLL1_GAIN_SHIFT); 1449 + regmap_update_bits_async(arizona->regmap, base + 0x9, 1450 + ARIZONA_FLL1_GAIN_MASK, 1451 + cfg->gain << ARIZONA_FLL1_GAIN_SHIFT); 1507 1452 1508 - regmap_update_bits(arizona->regmap, base + 2, 1509 - ARIZONA_FLL1_CTRL_UPD | ARIZONA_FLL1_N_MASK, 1510 - ARIZONA_FLL1_CTRL_UPD | cfg->n); 1453 + regmap_update_bits_async(arizona->regmap, base + 2, 1454 + ARIZONA_FLL1_CTRL_UPD | ARIZONA_FLL1_N_MASK, 1455 + ARIZONA_FLL1_CTRL_UPD | cfg->n); 1511 1456 } 1512 1457 1513 1458 static bool arizona_is_enabled_fll(struct arizona_fll *fll) ··· 1540 1485 */ 1541 1486 if (fll->ref_src >= 0 && fll->ref_freq && 1542 1487 fll->ref_src != fll->sync_src) { 1543 - regmap_update_bits(arizona->regmap, fll->base + 5, 1544 - ARIZONA_FLL1_OUTDIV_MASK, 1545 - ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); 1488 + regmap_update_bits_async(arizona->regmap, fll->base + 5, 1489 + ARIZONA_FLL1_OUTDIV_MASK, 1490 + ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); 1546 1491 1547 1492 arizona_apply_fll(arizona, fll->base, ref, fll->ref_src, 1548 1493 false); ··· 1552 1497 use_sync = true; 1553 1498 } 1554 1499 } else if (fll->sync_src >= 0) { 1555 - regmap_update_bits(arizona->regmap, fll->base + 5, 1556 - ARIZONA_FLL1_OUTDIV_MASK, 1557 - sync->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); 1500 + regmap_update_bits_async(arizona->regmap, fll->base + 5, 1501 + ARIZONA_FLL1_OUTDIV_MASK, 1502 + sync->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); 1558 1503 1559 1504 arizona_apply_fll(arizona, fll->base, sync, 1560 1505 fll->sync_src, false); 1561 1506 1562 - regmap_update_bits(arizona->regmap, fll->base + 0x11, 1563 - ARIZONA_FLL1_SYNC_ENA, 0); 1507 + regmap_update_bits_async(arizona->regmap, fll->base + 0x11, 1508 + ARIZONA_FLL1_SYNC_ENA, 0); 1564 1509 } else { 1565 1510 arizona_fll_err(fll, "No clocks provided\n"); 1566 1511 return; ··· 1571 1516 * sync source. 1572 1517 */ 1573 1518 if (use_sync && fll->sync_freq > 100000) 1574 - regmap_update_bits(arizona->regmap, fll->base + 0x17, 1575 - ARIZONA_FLL1_SYNC_BW, 0); 1519 + regmap_update_bits_async(arizona->regmap, fll->base + 0x17, 1520 + ARIZONA_FLL1_SYNC_BW, 0); 1576 1521 else 1577 - regmap_update_bits(arizona->regmap, fll->base + 0x17, 1578 - ARIZONA_FLL1_SYNC_BW, ARIZONA_FLL1_SYNC_BW); 1522 + regmap_update_bits_async(arizona->regmap, fll->base + 0x17, 1523 + ARIZONA_FLL1_SYNC_BW, 1524 + ARIZONA_FLL1_SYNC_BW); 1579 1525 1580 1526 if (!arizona_is_enabled_fll(fll)) 1581 1527 pm_runtime_get(arizona->dev); ··· 1584 1528 /* Clear any pending completions */ 1585 1529 try_wait_for_completion(&fll->ok); 1586 1530 1587 - regmap_update_bits(arizona->regmap, fll->base + 1, 1588 - ARIZONA_FLL1_FREERUN, 0); 1589 - regmap_update_bits(arizona->regmap, fll->base + 1, 1590 - ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); 1531 + regmap_update_bits_async(arizona->regmap, fll->base + 1, 1532 + ARIZONA_FLL1_FREERUN, 0); 1533 + regmap_update_bits_async(arizona->regmap, fll->base + 1, 1534 + ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); 1591 1535 if (use_sync) 1592 - regmap_update_bits(arizona->regmap, fll->base + 0x11, 1593 - ARIZONA_FLL1_SYNC_ENA, 1594 - ARIZONA_FLL1_SYNC_ENA); 1536 + regmap_update_bits_async(arizona->regmap, fll->base + 0x11, 1537 + ARIZONA_FLL1_SYNC_ENA, 1538 + ARIZONA_FLL1_SYNC_ENA); 1595 1539 1596 1540 ret = wait_for_completion_timeout(&fll->ok, 1597 1541 msecs_to_jiffies(250)); ··· 1604 1548 struct arizona *arizona = fll->arizona; 1605 1549 bool change; 1606 1550 1607 - regmap_update_bits(arizona->regmap, fll->base + 1, 1608 - ARIZONA_FLL1_FREERUN, ARIZONA_FLL1_FREERUN); 1551 + regmap_update_bits_async(arizona->regmap, fll->base + 1, 1552 + ARIZONA_FLL1_FREERUN, ARIZONA_FLL1_FREERUN); 1609 1553 regmap_update_bits_check(arizona->regmap, fll->base + 1, 1610 1554 ARIZONA_FLL1_ENA, 0, &change); 1611 1555 regmap_update_bits(arizona->regmap, fll->base + 0x11,
+4 -1
sound/soc/codecs/arizona.h
··· 81 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 86 extern const unsigned int arizona_mixer_tlv[]; 87 87 extern const char *arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS]; ··· 186 186 extern const int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE]; 187 187 188 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 192 extern const struct soc_enum arizona_in_vi_ramp; 191 193 extern const struct soc_enum arizona_in_vd_ramp; ··· 201 199 extern const struct soc_enum arizona_lhpf4_mode; 202 200 203 201 extern const struct soc_enum arizona_ng_hold; 202 + extern const struct soc_enum arizona_in_hpf_cut_enum; 204 203 extern const struct soc_enum arizona_in_dmic_osr[]; 205 204 206 205 extern int arizona_in_ev(struct snd_soc_dapm_widget *w,
+4 -4
sound/soc/codecs/cs4271.c
··· 675 675 }; 676 676 #endif /* defined(CONFIG_SPI_MASTER) */ 677 677 678 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 678 + #if IS_ENABLED(CONFIG_I2C) 679 679 static const struct i2c_device_id cs4271_i2c_id[] = { 680 680 {"cs4271", 0}, 681 681 {} ··· 728 728 .probe = cs4271_i2c_probe, 729 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 734 * We only register our serial bus driver here without ··· 741 741 { 742 742 int ret; 743 743 744 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 744 + #if IS_ENABLED(CONFIG_I2C) 745 745 ret = i2c_add_driver(&cs4271_i2c_driver); 746 746 if (ret) { 747 747 pr_err("Failed to register CS4271 I2C driver: %d\n", ret); ··· 767 767 spi_unregister_driver(&cs4271_spi_driver); 768 768 #endif 769 769 770 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 770 + #if IS_ENABLED(CONFIG_I2C) 771 771 i2c_del_driver(&cs4271_i2c_driver); 772 772 #endif 773 773 }
+75 -30
sound/soc/codecs/cs42l52.c
··· 17 17 #include <linux/kernel.h> 18 18 #include <linux/init.h> 19 19 #include <linux/delay.h> 20 - #include <linux/gpio.h> 20 + #include <linux/of_gpio.h> 21 21 #include <linux/pm.h> 22 22 #include <linux/i2c.h> 23 23 #include <linux/input.h> ··· 50 50 u8 mclksel; 51 51 u32 mclk; 52 52 u8 flags; 53 - #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) 53 + #if IS_ENABLED(CONFIG_INPUT) 54 54 struct input_dev *beep; 55 55 struct work_struct beep_work; 56 56 int beep_rate; ··· 233 233 SOC_ENUM_SINGLE(CS42L52_IFACE_CTL2, 0, 234 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 238 static const struct soc_enum mica_enum = 239 239 SOC_ENUM_SINGLE(CS42L52_MICA_CTL, 5, ··· 242 242 static const struct soc_enum micb_enum = 243 243 SOC_ENUM_SINGLE(CS42L52_MICB_CTL, 5, 244 244 ARRAY_SIZE(cs42l52_mic_text), cs42l52_mic_text); 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 245 252 246 static const char * const digital_output_mux_text[] = {"ADC", "DSP"}; 253 247 ··· 525 531 526 532 }; 527 533 534 + static const struct snd_kcontrol_new cs42l52_mica_controls[] = { 535 + SOC_ENUM("MICA Select", mica_enum), 536 + }; 537 + 538 + static const struct snd_kcontrol_new cs42l52_micb_controls[] = { 539 + SOC_ENUM("MICB Select", micb_enum), 540 + }; 541 + 542 + static int cs42l52_add_mic_controls(struct snd_soc_codec *codec) 543 + { 544 + struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); 545 + struct cs42l52_platform_data *pdata = &cs42l52->pdata; 546 + 547 + if (!pdata->mica_diff_cfg) 548 + snd_soc_add_codec_controls(codec, cs42l52_mica_controls, 549 + ARRAY_SIZE(cs42l52_mica_controls)); 550 + 551 + if (!pdata->micb_diff_cfg) 552 + snd_soc_add_codec_controls(codec, cs42l52_micb_controls, 553 + ARRAY_SIZE(cs42l52_micb_controls)); 554 + 555 + return 0; 556 + } 557 + 528 558 static const struct snd_soc_dapm_widget cs42l52_dapm_widgets[] = { 529 559 530 560 SND_SOC_DAPM_INPUT("AIN1L"), ··· 567 549 SND_SOC_NOPM, 0, 0), 568 550 SND_SOC_DAPM_AIF_OUT("AIFOUTR", NULL, 0, 569 551 SND_SOC_NOPM, 0, 0), 570 - 571 - SND_SOC_DAPM_MUX("MICA Mux", SND_SOC_NOPM, 0, 0, &mica_mux), 572 - SND_SOC_DAPM_MUX("MICB Mux", SND_SOC_NOPM, 0, 0, &micb_mux), 573 552 574 553 SND_SOC_DAPM_ADC("ADC Left", NULL, CS42L52_PWRCTL1, 1, 1), 575 554 SND_SOC_DAPM_ADC("ADC Right", NULL, CS42L52_PWRCTL1, 2, 1), ··· 968 953 return 0; 969 954 } 970 955 971 - #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) 956 + #if IS_ENABLED(CONFIG_INPUT) 972 957 static int beep_rates[] = { 973 958 261, 522, 585, 667, 706, 774, 889, 1000, 974 959 1043, 1200, 1333, 1412, 1600, 1714, 2000, 2182 ··· 1125 1110 } 1126 1111 regcache_cache_only(cs42l52->regmap, true); 1127 1112 1113 + cs42l52_add_mic_controls(codec); 1114 + 1128 1115 cs42l52_init_beep(codec); 1129 1116 1130 1117 cs42l52_set_bias_level(codec, SND_SOC_BIAS_STANDBY); ··· 1193 1176 int ret; 1194 1177 unsigned int devid = 0; 1195 1178 unsigned int reg; 1179 + u32 val32; 1196 1180 1197 1181 cs42l52 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l52_private), 1198 1182 GFP_KERNEL); ··· 1207 1189 dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); 1208 1190 return ret; 1209 1191 } 1210 - 1211 - if (pdata) 1192 + if (pdata) { 1212 1193 cs42l52->pdata = *pdata; 1194 + } else { 1195 + pdata = devm_kzalloc(&i2c_client->dev, 1196 + sizeof(struct cs42l52_platform_data), 1197 + GFP_KERNEL); 1198 + if (!pdata) { 1199 + dev_err(&i2c_client->dev, "could not allocate pdata\n"); 1200 + return -ENOMEM; 1201 + } 1202 + if (i2c_client->dev.of_node) { 1203 + if (of_property_read_bool(i2c_client->dev.of_node, 1204 + "cirrus,mica-differential-cfg")) 1205 + pdata->mica_diff_cfg = true; 1206 + 1207 + if (of_property_read_bool(i2c_client->dev.of_node, 1208 + "cirrus,micb-differential-cfg")) 1209 + pdata->micb_diff_cfg = true; 1210 + 1211 + if (of_property_read_u32(i2c_client->dev.of_node, 1212 + "cirrus,micbias-lvl", &val32) >= 0) 1213 + pdata->micbias_lvl = val32; 1214 + 1215 + if (of_property_read_u32(i2c_client->dev.of_node, 1216 + "cirrus,chgfreq-divisor", &val32) >= 0) 1217 + pdata->chgfreq = val32; 1218 + 1219 + pdata->reset_gpio = 1220 + of_get_named_gpio(i2c_client->dev.of_node, 1221 + "cirrus,reset-gpio", 0); 1222 + } 1223 + cs42l52->pdata = *pdata; 1224 + } 1213 1225 1214 1226 if (cs42l52->pdata.reset_gpio) { 1215 1227 ret = gpio_request_one(cs42l52->pdata.reset_gpio, ··· 1275 1227 reg & 0xFF); 1276 1228 1277 1229 /* Set Platform Data */ 1278 - if (cs42l52->pdata.mica_cfg) 1230 + if (cs42l52->pdata.mica_diff_cfg) 1279 1231 regmap_update_bits(cs42l52->regmap, CS42L52_MICA_CTL, 1280 1232 CS42L52_MIC_CTL_TYPE_MASK, 1281 - cs42l52->pdata.mica_cfg << 1233 + cs42l52->pdata.mica_diff_cfg << 1282 1234 CS42L52_MIC_CTL_TYPE_SHIFT); 1283 1235 1284 - if (cs42l52->pdata.micb_cfg) 1236 + if (cs42l52->pdata.micb_diff_cfg) 1285 1237 regmap_update_bits(cs42l52->regmap, CS42L52_MICB_CTL, 1286 1238 CS42L52_MIC_CTL_TYPE_MASK, 1287 - cs42l52->pdata.micb_cfg << 1239 + cs42l52->pdata.micb_diff_cfg << 1288 1240 CS42L52_MIC_CTL_TYPE_SHIFT); 1289 - 1290 - if (cs42l52->pdata.mica_sel) 1291 - regmap_update_bits(cs42l52->regmap, CS42L52_MICA_CTL, 1292 - CS42L52_MIC_CTL_MIC_SEL_MASK, 1293 - cs42l52->pdata.mica_sel << 1294 - CS42L52_MIC_CTL_MIC_SEL_SHIFT); 1295 - if (cs42l52->pdata.micb_sel) 1296 - regmap_update_bits(cs42l52->regmap, CS42L52_MICB_CTL, 1297 - CS42L52_MIC_CTL_MIC_SEL_MASK, 1298 - cs42l52->pdata.micb_sel << 1299 - CS42L52_MIC_CTL_MIC_SEL_SHIFT); 1300 1241 1301 1242 if (cs42l52->pdata.chgfreq) 1302 1243 regmap_update_bits(cs42l52->regmap, CS42L52_CHARGE_PUMP, ··· 1311 1274 return 0; 1312 1275 } 1313 1276 1277 + static const struct of_device_id cs42l52_of_match[] = { 1278 + { .compatible = "cirrus,cs42l52", }, 1279 + {}, 1280 + }; 1281 + MODULE_DEVICE_TABLE(of, cs42l52_of_match); 1282 + 1283 + 1314 1284 static const struct i2c_device_id cs42l52_id[] = { 1315 1285 { "cs42l52", 0 }, 1316 1286 { } ··· 1328 1284 .driver = { 1329 1285 .name = "cs42l52", 1330 1286 .owner = THIS_MODULE, 1287 + .of_match_table = cs42l52_of_match, 1331 1288 }, 1332 1289 .id_table = cs42l52_id, 1333 1290 .probe = cs42l52_i2c_probe,
+3 -3
sound/soc/codecs/da7210.c
··· 1188 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 1193 static struct reg_default da7210_regmap_i2c_patch[] = { 1194 1194 ··· 1362 1362 static int __init da7210_modinit(void) 1363 1363 { 1364 1364 int ret = 0; 1365 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1365 + #if IS_ENABLED(CONFIG_I2C) 1366 1366 ret = i2c_add_driver(&da7210_i2c_driver); 1367 1367 #endif 1368 1368 #if defined(CONFIG_SPI_MASTER) ··· 1378 1378 1379 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 1382 i2c_del_driver(&da7210_i2c_driver); 1383 1383 #endif 1384 1384 #if defined(CONFIG_SPI_MASTER)
+11 -1
sound/soc/codecs/hdmi.c
··· 20 20 */ 21 21 #include <linux/module.h> 22 22 #include <sound/soc.h> 23 + #include <linux/of_device.h> 23 24 24 25 #define DRV_NAME "hdmi-audio-codec" 25 26 ··· 45 44 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | 46 45 SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, 47 46 .formats = SNDRV_PCM_FMTBIT_S16_LE | 48 - SNDRV_PCM_FMTBIT_S24_LE, 47 + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, 49 48 }, 50 49 .capture = { 51 50 .stream_name = "Capture", ··· 60 59 }, 61 60 62 61 }; 62 + 63 + #ifdef CONFIG_OF 64 + static const struct of_device_id hdmi_audio_codec_ids[] = { 65 + { .compatible = "linux,hdmi-audio", }, 66 + { } 67 + }; 68 + MODULE_DEVICE_TABLE(of, hdmi_audio_codec_ids); 69 + #endif 63 70 64 71 static struct snd_soc_codec_driver hdmi_codec = { 65 72 .dapm_widgets = hdmi_widgets, ··· 92 83 .driver = { 93 84 .name = DRV_NAME, 94 85 .owner = THIS_MODULE, 86 + .of_match_table = of_match_ptr(hdmi_audio_codec_ids), 95 87 }, 96 88 97 89 .probe = hdmi_codec_probe,
+24 -52
sound/soc/codecs/sgtl5000.c
··· 115 115 struct ldo_regulator *ldo; 116 116 struct regmap *regmap; 117 117 struct clk *mclk; 118 + int revision; 118 119 }; 119 120 120 121 /* ··· 1286 1285 1287 1286 sgtl5000->supplies[VDDD].supply = LDO_CONSUMER_NAME; 1288 1287 1289 - ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies), 1290 - sgtl5000->supplies); 1291 - 1292 - if (ret) { 1293 - ldo_regulator_remove(codec); 1294 - dev_err(codec->dev, "Failed to request supplies: %d\n", ret); 1295 - return ret; 1296 - } 1297 - 1298 1288 dev_info(codec->dev, "Using internal LDO instead of VDDD\n"); 1299 1289 return 0; 1300 1290 } 1301 1291 1302 1292 static int sgtl5000_enable_regulators(struct snd_soc_codec *codec) 1303 1293 { 1304 - int reg; 1305 1294 int ret; 1306 - int rev; 1307 1295 int i; 1308 1296 int external_vddd = 0; 1309 1297 struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); 1298 + struct regulator *vddd; 1310 1299 1311 1300 for (i = 0; i < ARRAY_SIZE(sgtl5000->supplies); i++) 1312 1301 sgtl5000->supplies[i].supply = supply_names[i]; 1313 1302 1314 - ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies), 1315 - sgtl5000->supplies); 1316 - if (!ret) 1317 - external_vddd = 1; 1318 - else { 1303 + /* External VDDD only works before revision 0x11 */ 1304 + if (sgtl5000->revision < 0x11) { 1305 + vddd = regulator_get_optional(codec->dev, "VDDD"); 1306 + if (IS_ERR(vddd)) { 1307 + /* See if it's just not registered yet */ 1308 + if (PTR_ERR(vddd) == -EPROBE_DEFER) 1309 + return -EPROBE_DEFER; 1310 + } else { 1311 + external_vddd = 1; 1312 + regulator_put(vddd); 1313 + } 1314 + } 1315 + 1316 + if (!external_vddd) { 1319 1317 ret = sgtl5000_replace_vddd_with_ldo(codec); 1320 1318 if (ret) 1321 1319 return ret; 1322 1320 } 1321 + 1322 + ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies), 1323 + sgtl5000->supplies); 1324 + if (ret) 1325 + goto err_ldo_remove; 1323 1326 1324 1327 ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies), 1325 1328 sgtl5000->supplies); ··· 1333 1328 /* wait for all power rails bring up */ 1334 1329 udelay(10); 1335 1330 1336 - /* 1337 - * workaround for revision 0x11 and later, 1338 - * roll back to use internal LDO 1339 - */ 1340 - 1341 - ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, &reg); 1342 - if (ret) 1343 - goto err_regulator_disable; 1344 - 1345 - rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT; 1346 - 1347 - if (external_vddd && rev >= 0x11) { 1348 - /* disable all regulator first */ 1349 - regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), 1350 - sgtl5000->supplies); 1351 - /* free VDDD regulator */ 1352 - regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies), 1353 - sgtl5000->supplies); 1354 - 1355 - ret = sgtl5000_replace_vddd_with_ldo(codec); 1356 - if (ret) 1357 - return ret; 1358 - 1359 - ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies), 1360 - sgtl5000->supplies); 1361 - if (ret) 1362 - goto err_regulator_free; 1363 - 1364 - /* wait for all power rails bring up */ 1365 - udelay(10); 1366 - } 1367 - 1368 1331 return 0; 1369 1332 1370 - err_regulator_disable: 1371 - regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), 1372 - sgtl5000->supplies); 1373 1333 err_regulator_free: 1374 1334 regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies), 1375 1335 sgtl5000->supplies); 1376 - if (external_vddd) 1336 + err_ldo_remove: 1337 + if (!external_vddd) 1377 1338 ldo_regulator_remove(codec); 1378 1339 return ret; 1379 1340 ··· 1537 1566 1538 1567 rev = (reg & SGTL5000_REVID_MASK) >> SGTL5000_REVID_SHIFT; 1539 1568 dev_info(&client->dev, "sgtl5000 revision 0x%x\n", rev); 1569 + sgtl5000->revision = rev; 1540 1570 1541 1571 i2c_set_clientdata(client, sgtl5000); 1542 1572
+4 -4
sound/soc/codecs/ssm2518.c
··· 549 549 right_slot = 0; 550 550 } else { 551 551 /* We assume the left channel < right channel */ 552 - left_slot = ffs(tx_mask); 553 - tx_mask &= ~(1 << tx_mask); 552 + left_slot = __ffs(tx_mask); 553 + tx_mask &= ~(1 << left_slot); 554 554 if (tx_mask == 0) { 555 555 right_slot = left_slot; 556 556 } else { 557 - right_slot = ffs(tx_mask); 558 - tx_mask &= ~(1 << tx_mask); 557 + right_slot = __ffs(tx_mask); 558 + tx_mask &= ~(1 << right_slot); 559 559 } 560 560 } 561 561
+5 -51
sound/soc/codecs/ssm2602.c
··· 53 53 struct ssm2602_priv { 54 54 unsigned int sysclk; 55 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 57 struct regmap *regmap; 60 58 ··· 275 277 int srate = ssm2602_get_coeff(ssm2602->sysclk, params_rate(params)); 276 278 unsigned int iface; 277 279 278 - if (substream == ssm2602->slave_substream) { 279 - dev_dbg(codec->dev, "Ignoring hw_params for slave substream\n"); 280 - return 0; 281 - } 282 - 283 280 if (srate < 0) 284 281 return srate; 285 282 ··· 307 314 { 308 315 struct snd_soc_codec *codec = dai->codec; 309 316 struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); 310 - struct snd_pcm_runtime *master_runtime; 311 - 312 - /* The DAI has shared clocks so if we already have a playback or 313 - * capture going then constrain this substream to match it. 314 - * TODO: the ssm2602 allows pairs of non-matching PB/REC rates 315 - */ 316 - if (ssm2602->master_substream) { 317 - master_runtime = ssm2602->master_substream->runtime; 318 - dev_dbg(codec->dev, "Constraining to %d bits at %dHz\n", 319 - master_runtime->sample_bits, 320 - master_runtime->rate); 321 - 322 - if (master_runtime->rate != 0) 323 - snd_pcm_hw_constraint_minmax(substream->runtime, 324 - SNDRV_PCM_HW_PARAM_RATE, 325 - master_runtime->rate, 326 - master_runtime->rate); 327 - 328 - if (master_runtime->sample_bits != 0) 329 - snd_pcm_hw_constraint_minmax(substream->runtime, 330 - SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 331 - master_runtime->sample_bits, 332 - master_runtime->sample_bits); 333 - 334 - ssm2602->slave_substream = substream; 335 - } else 336 - ssm2602->master_substream = substream; 337 317 338 318 if (ssm2602->sysclk_constraints) { 339 319 snd_pcm_hw_constraint_list(substream->runtime, 0, ··· 316 350 317 351 return 0; 318 352 } 319 - 320 - static void ssm2602_shutdown(struct snd_pcm_substream *substream, 321 - struct snd_soc_dai *dai) 322 - { 323 - struct snd_soc_codec *codec = dai->codec; 324 - struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); 325 - 326 - if (ssm2602->master_substream == substream) 327 - ssm2602->master_substream = ssm2602->slave_substream; 328 - 329 - ssm2602->slave_substream = NULL; 330 - } 331 - 332 353 333 354 static int ssm2602_mute(struct snd_soc_dai *dai, int mute) 334 355 { ··· 483 530 static const struct snd_soc_dai_ops ssm2602_dai_ops = { 484 531 .startup = ssm2602_startup, 485 532 .hw_params = ssm2602_hw_params, 486 - .shutdown = ssm2602_shutdown, 487 533 .digital_mute = ssm2602_mute, 488 534 .set_sysclk = ssm2602_set_dai_sysclk, 489 535 .set_fmt = ssm2602_set_dai_fmt, ··· 503 551 .rates = SSM2602_RATES, 504 552 .formats = SSM2602_FORMATS,}, 505 553 .ops = &ssm2602_dai_ops, 554 + .symmetric_rates = 1, 555 + .symmetric_samplebits = 1, 506 556 }; 507 557 508 558 static int ssm2602_suspend(struct snd_soc_codec *codec) ··· 684 730 }; 685 731 #endif 686 732 687 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 733 + #if IS_ENABLED(CONFIG_I2C) 688 734 /* 689 735 * ssm2602 2 wire address is determined by GPIO5 690 736 * state during powerup. ··· 751 797 return ret; 752 798 #endif 753 799 754 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 800 + #if IS_ENABLED(CONFIG_I2C) 755 801 ret = i2c_add_driver(&ssm2602_i2c_driver); 756 802 if (ret) 757 803 return ret; ··· 767 813 spi_unregister_driver(&ssm2602_spi_driver); 768 814 #endif 769 815 770 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 816 + #if IS_ENABLED(CONFIG_I2C) 771 817 i2c_del_driver(&ssm2602_i2c_driver); 772 818 #endif 773 819 }
+83 -43
sound/soc/codecs/tlv320aic3x.c
··· 350 350 DACL1_2_LLOPM_VOL, DACR1_2_RLOPM_VOL, 351 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 353 SOC_DOUBLE_R_TLV("HP Line2 Bypass Volume", 364 354 LINE2L_2_HPLOUT_VOL, LINE2R_2_HPROUT_VOL, 365 355 0, 118, 1, output_stage_tlv), ··· 373 383 /* Output pin mute controls */ 374 384 SOC_DOUBLE_R("Line Playback Switch", LLOPM_CTRL, RLOPM_CTRL, 3, 375 385 0x01, 0), 376 - SOC_SINGLE("Mono Playback Switch", MONOLOPM_CTRL, 3, 0x01, 0), 377 386 SOC_DOUBLE_R("HP Playback Switch", HPLOUT_CTRL, HPROUT_CTRL, 3, 378 387 0x01, 0), 379 388 SOC_DOUBLE_R("HPCOM Playback Switch", HPLCOM_CTRL, HPRCOM_CTRL, 3, ··· 399 410 SOC_DOUBLE_R("PGA Capture Switch", LADC_VOL, RADC_VOL, 7, 0x01, 1), 400 411 401 412 SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]), 413 + }; 414 + 415 + static const struct snd_kcontrol_new aic3x_mono_controls[] = { 416 + SOC_DOUBLE_R_TLV("Mono Line2 Bypass Volume", 417 + LINE2L_2_MONOLOPM_VOL, LINE2R_2_MONOLOPM_VOL, 418 + 0, 118, 1, output_stage_tlv), 419 + SOC_DOUBLE_R_TLV("Mono PGA Bypass Volume", 420 + PGAL_2_MONOLOPM_VOL, PGAR_2_MONOLOPM_VOL, 421 + 0, 118, 1, output_stage_tlv), 422 + SOC_DOUBLE_R_TLV("Mono DAC Playback Volume", 423 + DACL1_2_MONOLOPM_VOL, DACR1_2_MONOLOPM_VOL, 424 + 0, 118, 1, output_stage_tlv), 425 + 426 + SOC_SINGLE("Mono Playback Switch", MONOLOPM_CTRL, 3, 0x01, 0), 402 427 }; 403 428 404 429 /* ··· 568 565 SND_SOC_DAPM_PGA("Right HP Out", HPROUT_CTRL, 0, 0, NULL, 0), 569 566 SND_SOC_DAPM_PGA("Right HP Com", HPRCOM_CTRL, 0, 0, NULL, 0), 570 567 571 - /* Mono Output */ 572 - SND_SOC_DAPM_PGA("Mono Out", MONOLOPM_CTRL, 0, 0, NULL, 0), 573 - 574 568 /* Inputs to Left ADC */ 575 569 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", LINE1L_2_LADC_CTRL, 2, 0), 576 570 SND_SOC_DAPM_MIXER("Left PGA Mixer", SND_SOC_NOPM, 0, 0, ··· 626 626 SND_SOC_DAPM_MIXER("Right Line Mixer", SND_SOC_NOPM, 0, 0, 627 627 &aic3x_right_line_mixer_controls[0], 628 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 629 SND_SOC_DAPM_MIXER("Left HP Mixer", SND_SOC_NOPM, 0, 0, 633 630 &aic3x_left_hp_mixer_controls[0], 634 631 ARRAY_SIZE(aic3x_left_hp_mixer_controls)), ··· 641 644 642 645 SND_SOC_DAPM_OUTPUT("LLOUT"), 643 646 SND_SOC_DAPM_OUTPUT("RLOUT"), 644 - SND_SOC_DAPM_OUTPUT("MONO_LOUT"), 645 647 SND_SOC_DAPM_OUTPUT("HPLOUT"), 646 648 SND_SOC_DAPM_OUTPUT("HPROUT"), 647 649 SND_SOC_DAPM_OUTPUT("HPLCOM"), ··· 660 664 * widgets. 661 665 */ 662 666 SND_SOC_DAPM_OUTPUT("Detection"), 667 + }; 668 + 669 + static const struct snd_soc_dapm_widget aic3x_dapm_mono_widgets[] = { 670 + /* Mono Output */ 671 + SND_SOC_DAPM_PGA("Mono Out", MONOLOPM_CTRL, 0, 0, NULL, 0), 672 + 673 + SND_SOC_DAPM_MIXER("Mono Mixer", SND_SOC_NOPM, 0, 0, 674 + &aic3x_mono_mixer_controls[0], 675 + ARRAY_SIZE(aic3x_mono_mixer_controls)), 676 + 677 + SND_SOC_DAPM_OUTPUT("MONO_LOUT"), 663 678 }; 664 679 665 680 static const struct snd_soc_dapm_widget aic3007_dapm_widgets[] = { ··· 761 754 {"Right Line Out", NULL, "Right DAC Mux"}, 762 755 {"RLOUT", NULL, "Right Line Out"}, 763 756 764 - /* Mono Output */ 765 - {"Mono Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, 766 - {"Mono Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, 767 - {"Mono Mixer", "DACL1 Switch", "Left DAC Mux"}, 768 - {"Mono Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, 769 - {"Mono Mixer", "PGAR Bypass Switch", "Right PGA Mixer"}, 770 - {"Mono Mixer", "DACR1 Switch", "Right DAC Mux"}, 771 - 772 - {"Mono Out", NULL, "Mono Mixer"}, 773 - {"MONO_LOUT", NULL, "Mono Out"}, 774 - 775 757 /* Left HP Output */ 776 758 {"Left HP Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, 777 759 {"Left HP Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, ··· 816 820 {"HPRCOM", NULL, "Right HP Com"}, 817 821 }; 818 822 823 + static const struct snd_soc_dapm_route intercon_mono[] = { 824 + /* Mono Output */ 825 + {"Mono Mixer", "Line2L Bypass Switch", "Left Line2L Mux"}, 826 + {"Mono Mixer", "PGAL Bypass Switch", "Left PGA Mixer"}, 827 + {"Mono Mixer", "DACL1 Switch", "Left DAC Mux"}, 828 + {"Mono Mixer", "Line2R Bypass Switch", "Right Line2R Mux"}, 829 + {"Mono Mixer", "PGAR Bypass Switch", "Right PGA Mixer"}, 830 + {"Mono Mixer", "DACR1 Switch", "Right DAC Mux"}, 831 + {"Mono Out", NULL, "Mono Mixer"}, 832 + {"MONO_LOUT", NULL, "Mono Out"}, 833 + }; 834 + 819 835 static const struct snd_soc_dapm_route intercon_3007[] = { 820 836 /* Class-D outputs */ 821 837 {"Left Class-D Out", NULL, "Left Line Out"}, ··· 841 833 struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); 842 834 struct snd_soc_dapm_context *dapm = &codec->dapm; 843 835 844 - if (aic3x->model == AIC3X_MODEL_3007) { 836 + switch (aic3x->model) { 837 + case AIC3X_MODEL_3X: 838 + case AIC3X_MODEL_33: 839 + snd_soc_dapm_new_controls(dapm, aic3x_dapm_mono_widgets, 840 + ARRAY_SIZE(aic3x_dapm_mono_widgets)); 841 + snd_soc_dapm_add_routes(dapm, intercon_mono, 842 + ARRAY_SIZE(intercon_mono)); 843 + break; 844 + case AIC3X_MODEL_3007: 845 845 snd_soc_dapm_new_controls(dapm, aic3007_dapm_widgets, 846 846 ARRAY_SIZE(aic3007_dapm_widgets)); 847 847 snd_soc_dapm_add_routes(dapm, intercon_3007, 848 848 ARRAY_SIZE(intercon_3007)); 849 + break; 849 850 } 850 851 851 852 return 0; ··· 1235 1218 return 0; 1236 1219 } 1237 1220 1221 + static void aic3x_mono_init(struct snd_soc_codec *codec) 1222 + { 1223 + /* DAC to Mono Line Out default volume and route to Output mixer */ 1224 + snd_soc_write(codec, DACL1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); 1225 + snd_soc_write(codec, DACR1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); 1226 + 1227 + /* unmute all outputs */ 1228 + snd_soc_update_bits(codec, MONOLOPM_CTRL, UNMUTE, UNMUTE); 1229 + 1230 + /* PGA to Mono Line Out default volume, disconnect from Output Mixer */ 1231 + snd_soc_write(codec, PGAL_2_MONOLOPM_VOL, DEFAULT_VOL); 1232 + snd_soc_write(codec, PGAR_2_MONOLOPM_VOL, DEFAULT_VOL); 1233 + 1234 + /* Line2 to Mono Out default volume, disconnect from Output Mixer */ 1235 + snd_soc_write(codec, LINE2L_2_MONOLOPM_VOL, DEFAULT_VOL); 1236 + snd_soc_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); 1237 + } 1238 + 1238 1239 /* 1239 1240 * initialise the AIC3X driver 1240 1241 * register the mixer and dsp interfaces with the kernel ··· 1276 1241 /* DAC to Line Out default volume and route to Output mixer */ 1277 1242 snd_soc_write(codec, DACL1_2_LLOPM_VOL, DEFAULT_VOL | ROUTE_ON); 1278 1243 snd_soc_write(codec, DACR1_2_RLOPM_VOL, DEFAULT_VOL | ROUTE_ON); 1279 - /* DAC to Mono Line Out default volume and route to Output mixer */ 1280 - snd_soc_write(codec, DACL1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); 1281 - snd_soc_write(codec, DACR1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); 1282 1244 1283 1245 /* unmute all outputs */ 1284 1246 snd_soc_update_bits(codec, LLOPM_CTRL, UNMUTE, UNMUTE); 1285 1247 snd_soc_update_bits(codec, RLOPM_CTRL, UNMUTE, UNMUTE); 1286 - snd_soc_update_bits(codec, MONOLOPM_CTRL, UNMUTE, UNMUTE); 1287 1248 snd_soc_update_bits(codec, HPLOUT_CTRL, UNMUTE, UNMUTE); 1288 1249 snd_soc_update_bits(codec, HPROUT_CTRL, UNMUTE, UNMUTE); 1289 1250 snd_soc_update_bits(codec, HPLCOM_CTRL, UNMUTE, UNMUTE); ··· 1300 1269 /* PGA to Line Out default volume, disconnect from Output Mixer */ 1301 1270 snd_soc_write(codec, PGAL_2_LLOPM_VOL, DEFAULT_VOL); 1302 1271 snd_soc_write(codec, PGAR_2_RLOPM_VOL, DEFAULT_VOL); 1303 - /* PGA to Mono Line Out default volume, disconnect from Output Mixer */ 1304 - snd_soc_write(codec, PGAL_2_MONOLOPM_VOL, DEFAULT_VOL); 1305 - snd_soc_write(codec, PGAR_2_MONOLOPM_VOL, DEFAULT_VOL); 1306 1272 1307 1273 /* Line2 to HP Bypass default volume, disconnect from Output Mixer */ 1308 1274 snd_soc_write(codec, LINE2L_2_HPLOUT_VOL, DEFAULT_VOL); ··· 1309 1281 /* Line2 Line Out default volume, disconnect from Output Mixer */ 1310 1282 snd_soc_write(codec, LINE2L_2_LLOPM_VOL, DEFAULT_VOL); 1311 1283 snd_soc_write(codec, LINE2R_2_RLOPM_VOL, DEFAULT_VOL); 1312 - /* Line2 to Mono Out default volume, disconnect from Output Mixer */ 1313 - snd_soc_write(codec, LINE2L_2_MONOLOPM_VOL, DEFAULT_VOL); 1314 - snd_soc_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); 1315 1284 1316 - if (aic3x->model == AIC3X_MODEL_3007) { 1285 + switch (aic3x->model) { 1286 + case AIC3X_MODEL_3X: 1287 + case AIC3X_MODEL_33: 1288 + aic3x_mono_init(codec); 1289 + break; 1290 + case AIC3X_MODEL_3007: 1317 1291 snd_soc_write(codec, CLASSD_CTRL, 0); 1292 + break; 1318 1293 } 1319 1294 1320 1295 return 0; ··· 1374 1343 (aic3x->setup->gpio_func[1] & 0xf) << 4); 1375 1344 } 1376 1345 1377 - if (aic3x->model == AIC3X_MODEL_3007) 1378 - snd_soc_add_codec_controls(codec, &aic3x_classd_amp_gain_ctrl, 1); 1346 + switch (aic3x->model) { 1347 + case AIC3X_MODEL_3X: 1348 + case AIC3X_MODEL_33: 1349 + snd_soc_add_codec_controls(codec, aic3x_mono_controls, 1350 + ARRAY_SIZE(aic3x_mono_controls)); 1351 + break; 1352 + case AIC3X_MODEL_3007: 1353 + snd_soc_add_codec_controls(codec, 1354 + &aic3x_classd_amp_gain_ctrl, 1); 1355 + break; 1356 + } 1379 1357 1380 1358 /* set mic bias voltage */ 1381 1359 switch (aic3x->micbias_vg) {
+66 -161
sound/soc/codecs/twl6040.c
··· 72 72 int hs_power_mode_locked; 73 73 bool dl1_unmuted; 74 74 bool dl2_unmuted; 75 + u8 dl12_cache[TWL6040_REG_HFRCTL - TWL6040_REG_HSLCTL + 1]; 75 76 unsigned int clk_in; 76 77 unsigned int sysclk; 77 78 struct twl6040_jack_data hs_jack; 78 79 struct snd_soc_codec *codec; 79 80 struct mutex mutex; 80 - }; 81 - 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 81 }; 150 82 151 83 /* set of rates for each pll: low-power and high-performance */ ··· 106 174 { .count = ARRAY_SIZE(hp_rates), .list = hp_rates, }, 107 175 }; 108 176 109 - /* 110 - * read twl6040 register cache 111 - */ 112 - static inline unsigned int twl6040_read_reg_cache(struct snd_soc_codec *codec, 113 - unsigned int reg) 177 + static unsigned int twl6040_read(struct snd_soc_codec *codec, unsigned int reg) 114 178 { 115 - u8 *cache = codec->reg_cache; 116 - 117 - if (reg >= TWL6040_CACHEREGNUM) 118 - return -EIO; 119 - 120 - return cache[reg]; 121 - } 122 - 123 - /* 124 - * write twl6040 register cache 125 - */ 126 - static inline void twl6040_write_reg_cache(struct snd_soc_codec *codec, 127 - u8 reg, u8 value) 128 - { 129 - u8 *cache = codec->reg_cache; 130 - 131 - if (reg >= TWL6040_CACHEREGNUM) 132 - return; 133 - cache[reg] = value; 134 - } 135 - 136 - /* 137 - * read from twl6040 hardware register 138 - */ 139 - static int twl6040_read_reg_volatile(struct snd_soc_codec *codec, 140 - unsigned int reg) 141 - { 179 + struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); 142 180 struct twl6040 *twl6040 = codec->control_data; 143 181 u8 value; 144 182 145 183 if (reg >= TWL6040_CACHEREGNUM) 146 184 return -EIO; 147 185 148 - value = twl6040_reg_read(twl6040, reg); 149 - twl6040_write_reg_cache(codec, reg, value); 186 + switch (reg) { 187 + case TWL6040_REG_HSLCTL: 188 + case TWL6040_REG_HSRCTL: 189 + case TWL6040_REG_EARCTL: 190 + case TWL6040_REG_HFLCTL: 191 + case TWL6040_REG_HFRCTL: 192 + value = priv->dl12_cache[reg - TWL6040_REG_HSLCTL]; 193 + break; 194 + default: 195 + value = twl6040_reg_read(twl6040, reg); 196 + break; 197 + } 150 198 151 199 return value; 152 200 } 153 201 154 - static bool twl6040_is_path_unmuted(struct snd_soc_codec *codec, 155 - unsigned int reg) 202 + static bool twl6040_can_write_to_chip(struct snd_soc_codec *codec, 203 + unsigned int reg) 156 204 { 157 205 struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); 158 206 ··· 150 238 } 151 239 } 152 240 153 - /* 154 - * write to the twl6040 register space 155 - */ 241 + static inline void twl6040_update_dl12_cache(struct snd_soc_codec *codec, 242 + u8 reg, u8 value) 243 + { 244 + struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); 245 + 246 + switch (reg) { 247 + case TWL6040_REG_HSLCTL: 248 + case TWL6040_REG_HSRCTL: 249 + case TWL6040_REG_EARCTL: 250 + case TWL6040_REG_HFLCTL: 251 + case TWL6040_REG_HFRCTL: 252 + priv->dl12_cache[reg - TWL6040_REG_HSLCTL] = value; 253 + break; 254 + default: 255 + break; 256 + } 257 + } 258 + 156 259 static int twl6040_write(struct snd_soc_codec *codec, 157 260 unsigned int reg, unsigned int value) 158 261 { ··· 176 249 if (reg >= TWL6040_CACHEREGNUM) 177 250 return -EIO; 178 251 179 - twl6040_write_reg_cache(codec, reg, value); 180 - if (twl6040_is_path_unmuted(codec, reg)) 252 + twl6040_update_dl12_cache(codec, reg, value); 253 + if (twl6040_can_write_to_chip(codec, reg)) 181 254 return twl6040_reg_write(twl6040, reg, value); 182 255 else 183 256 return 0; ··· 185 258 186 259 static void twl6040_init_chip(struct snd_soc_codec *codec) 187 260 { 188 - struct twl6040 *twl6040 = codec->control_data; 189 - u8 val; 190 - 191 - /* Update reg_cache: ASICREV, and TRIM values */ 192 - val = twl6040_get_revid(twl6040); 193 - twl6040_write_reg_cache(codec, TWL6040_REG_ASICREV, val); 194 - 195 - twl6040_read_reg_volatile(codec, TWL6040_REG_TRIM1); 196 - twl6040_read_reg_volatile(codec, TWL6040_REG_TRIM2); 197 - twl6040_read_reg_volatile(codec, TWL6040_REG_TRIM3); 198 - twl6040_read_reg_volatile(codec, TWL6040_REG_HSOTRIM); 199 - twl6040_read_reg_volatile(codec, TWL6040_REG_HFOTRIM); 261 + twl6040_read(codec, TWL6040_REG_TRIM1); 262 + twl6040_read(codec, TWL6040_REG_TRIM2); 263 + twl6040_read(codec, TWL6040_REG_TRIM3); 264 + twl6040_read(codec, TWL6040_REG_HSOTRIM); 265 + twl6040_read(codec, TWL6040_REG_HFOTRIM); 200 266 201 267 /* Change chip defaults */ 202 268 /* No imput selected for microphone amplifiers */ 203 - twl6040_write_reg_cache(codec, TWL6040_REG_MICLCTL, 0x18); 204 - twl6040_write_reg_cache(codec, TWL6040_REG_MICRCTL, 0x18); 269 + twl6040_write(codec, TWL6040_REG_MICLCTL, 0x18); 270 + twl6040_write(codec, TWL6040_REG_MICRCTL, 0x18); 205 271 206 272 /* 207 273 * We need to lower the default gain values, so the ramp code 208 274 * can work correctly for the first playback. 209 275 * This reduces the pop noise heard at the first playback. 210 276 */ 211 - twl6040_write_reg_cache(codec, TWL6040_REG_HSGAIN, 0xff); 212 - twl6040_write_reg_cache(codec, TWL6040_REG_EARCTL, 0x1e); 213 - twl6040_write_reg_cache(codec, TWL6040_REG_HFLGAIN, 0x1d); 214 - twl6040_write_reg_cache(codec, TWL6040_REG_HFRGAIN, 0x1d); 215 - twl6040_write_reg_cache(codec, TWL6040_REG_LINEGAIN, 0); 216 - } 217 - 218 - static void twl6040_restore_regs(struct snd_soc_codec *codec) 219 - { 220 - u8 *cache = codec->reg_cache; 221 - int reg, i; 222 - 223 - for (i = 0; i < ARRAY_SIZE(twl6040_restore_list); i++) { 224 - reg = twl6040_restore_list[i]; 225 - twl6040_write(codec, reg, cache[reg]); 226 - } 277 + twl6040_write(codec, TWL6040_REG_HSGAIN, 0xff); 278 + twl6040_write(codec, TWL6040_REG_EARCTL, 0x1e); 279 + twl6040_write(codec, TWL6040_REG_HFLGAIN, 0x1d); 280 + twl6040_write(codec, TWL6040_REG_HFRGAIN, 0x1d); 281 + twl6040_write(codec, TWL6040_REG_LINEGAIN, 0); 227 282 } 228 283 229 284 /* set headset dac and driver power mode */ ··· 214 305 int hslctl, hsrctl; 215 306 int mask = TWL6040_HSDRVMODE | TWL6040_HSDACMODE; 216 307 217 - hslctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSLCTL); 218 - hsrctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSRCTL); 308 + hslctl = twl6040_read(codec, TWL6040_REG_HSLCTL); 309 + hsrctl = twl6040_read(codec, TWL6040_REG_HSRCTL); 219 310 220 311 if (high_perf) { 221 312 hslctl &= ~mask; ··· 242 333 * Both HS DAC need to be turned on (before the HS driver) and off at 243 334 * the same time. 244 335 */ 245 - hslctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSLCTL); 246 - hsrctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSRCTL); 336 + hslctl = twl6040_read(codec, TWL6040_REG_HSLCTL); 337 + hsrctl = twl6040_read(codec, TWL6040_REG_HSRCTL); 247 338 if (SND_SOC_DAPM_EVENT_ON(event)) { 248 339 hslctl |= TWL6040_HSDACENA; 249 340 hsrctl |= TWL6040_HSDACENA; ··· 288 379 mutex_lock(&priv->mutex); 289 380 290 381 /* Sync status */ 291 - status = twl6040_read_reg_volatile(codec, TWL6040_REG_STATUS); 382 + status = twl6040_read(codec, TWL6040_REG_STATUS); 292 383 if (status & TWL6040_PLUGCOMP) 293 384 snd_soc_jack_report(jack, report, report); 294 385 else ··· 340 431 unsigned int val; 341 432 342 433 /* Do not allow changes while Input/FF efect is running */ 343 - val = twl6040_read_reg_volatile(codec, e->reg); 434 + val = twl6040_read(codec, e->reg); 344 435 if (val & TWL6040_VIBENA && !(val & TWL6040_VIBSEL)) 345 436 return -EBUSY; 346 437 ··· 565 656 if (unlikely(trim >= TWL6040_TRIM_INVAL)) 566 657 return -EINVAL; 567 658 568 - return twl6040_read_reg_cache(codec, TWL6040_REG_TRIM1 + trim); 659 + return twl6040_read(codec, TWL6040_REG_TRIM1 + trim); 569 660 } 570 661 EXPORT_SYMBOL_GPL(twl6040_get_trim_value); 571 662 ··· 840 931 841 932 priv->codec_powered = 1; 842 933 843 - twl6040_restore_regs(codec); 844 - 845 934 /* Set external boost GPO */ 846 935 twl6040_write(codec, TWL6040_REG_GPOCTL, 0x02); 847 936 break; ··· 960 1053 961 1054 switch (id) { 962 1055 case TWL6040_DAI_DL1: 963 - hslctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSLCTL); 964 - hsrctl = twl6040_read_reg_cache(codec, TWL6040_REG_HSRCTL); 965 - earctl = twl6040_read_reg_cache(codec, TWL6040_REG_EARCTL); 1056 + hslctl = twl6040_read(codec, TWL6040_REG_HSLCTL); 1057 + hsrctl = twl6040_read(codec, TWL6040_REG_HSRCTL); 1058 + earctl = twl6040_read(codec, TWL6040_REG_EARCTL); 966 1059 967 1060 if (mute) { 968 1061 /* Power down drivers and DACs */ ··· 978 1071 priv->dl1_unmuted = !mute; 979 1072 break; 980 1073 case TWL6040_DAI_DL2: 981 - hflctl = twl6040_read_reg_cache(codec, TWL6040_REG_HFLCTL); 982 - hfrctl = twl6040_read_reg_cache(codec, TWL6040_REG_HFRCTL); 1074 + hflctl = twl6040_read(codec, TWL6040_REG_HFLCTL); 1075 + hfrctl = twl6040_read(codec, TWL6040_REG_HFRCTL); 983 1076 984 1077 if (mute) { 985 1078 /* Power down drivers and DACs */ ··· 1116 1209 static int twl6040_probe(struct snd_soc_codec *codec) 1117 1210 { 1118 1211 struct twl6040_data *priv; 1212 + struct twl6040 *twl6040 = dev_get_drvdata(codec->dev->parent); 1119 1213 struct platform_device *pdev = container_of(codec->dev, 1120 1214 struct platform_device, dev); 1121 1215 int ret = 0; ··· 1128 1220 snd_soc_codec_set_drvdata(codec, priv); 1129 1221 1130 1222 priv->codec = codec; 1131 - codec->control_data = dev_get_drvdata(codec->dev->parent); 1223 + codec->control_data = twl6040; 1132 1224 1133 1225 priv->plug_irq = platform_get_irq(pdev, 0); 1134 1226 if (priv->plug_irq < 0) { ··· 1148 1240 return ret; 1149 1241 } 1150 1242 1243 + twl6040_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1151 1244 twl6040_init_chip(codec); 1152 1245 1153 - /* power on device */ 1154 - return twl6040_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1246 + return 0; 1155 1247 } 1156 1248 1157 1249 static int twl6040_remove(struct snd_soc_codec *codec) ··· 1169 1261 .remove = twl6040_remove, 1170 1262 .suspend = twl6040_suspend, 1171 1263 .resume = twl6040_resume, 1172 - .read = twl6040_read_reg_cache, 1264 + .read = twl6040_read, 1173 1265 .write = twl6040_write, 1174 1266 .set_bias_level = twl6040_set_bias_level, 1175 - .reg_cache_size = ARRAY_SIZE(twl6040_reg), 1176 - .reg_word_size = sizeof(u8), 1177 - .reg_cache_default = twl6040_reg, 1178 1267 .ignore_pmdown_time = true, 1179 1268 1180 1269 .controls = twl6040_snd_controls,
+3 -3
sound/soc/codecs/uda1380.c
··· 794 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 798 static int uda1380_i2c_probe(struct i2c_client *i2c, 799 799 const struct i2c_device_id *id) 800 800 { ··· 840 840 static int __init uda1380_modinit(void) 841 841 { 842 842 int ret = 0; 843 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 843 + #if IS_ENABLED(CONFIG_I2C) 844 844 ret = i2c_add_driver(&uda1380_i2c_driver); 845 845 if (ret != 0) 846 846 pr_err("Failed to register UDA1380 I2C driver: %d\n", ret); ··· 851 851 852 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 855 i2c_del_driver(&uda1380_i2c_driver); 856 856 #endif 857 857 }
+2 -2
sound/soc/codecs/wm5102.c
··· 601 601 case SND_SOC_DAPM_POST_PMU: 602 602 if (patch) 603 603 for (i = 0; i < patch_size; i++) 604 - regmap_write(regmap, patch[i].reg, 605 - patch[i].def); 604 + regmap_write_async(regmap, patch[i].reg, 605 + patch[i].def); 606 606 break; 607 607 608 608 default:
+373 -6
sound/soc/codecs/wm5110.c
··· 30 30 #include <linux/mfd/arizona/registers.h> 31 31 32 32 #include "arizona.h" 33 + #include "wm_adsp.h" 33 34 #include "wm5110.h" 35 + 36 + #define WM5110_NUM_ADSP 4 34 37 35 38 struct wm5110_priv { 36 39 struct arizona_priv core; 37 40 struct arizona_fll fll[2]; 41 + }; 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, 38 76 }; 39 77 40 78 static const struct reg_default wm5110_sysclk_revd_patch[] = { ··· 105 67 case SND_SOC_DAPM_POST_PMU: 106 68 if (patch) 107 69 for (i = 0; i < patch_size; i++) 108 - regmap_write(regmap, patch[i].reg, 109 - patch[i].def); 70 + regmap_write_async(regmap, patch[i].reg, 71 + patch[i].def); 110 72 break; 111 73 112 74 default: ··· 154 116 ARIZONA_IN3L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), 155 117 SOC_SINGLE_RANGE_TLV("IN3R Volume", ARIZONA_IN3R_CONTROL, 156 118 ARIZONA_IN3R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), 119 + 120 + SOC_ENUM("IN HPF Cutoff Frequency", arizona_in_hpf_cut_enum), 121 + 122 + SOC_SINGLE("IN1L HPF Switch", ARIZONA_IN1L_CONTROL, 123 + ARIZONA_IN1L_HPF_SHIFT, 1, 0), 124 + SOC_SINGLE("IN1R HPF Switch", ARIZONA_IN1R_CONTROL, 125 + ARIZONA_IN1R_HPF_SHIFT, 1, 0), 126 + SOC_SINGLE("IN2L HPF Switch", ARIZONA_IN2L_CONTROL, 127 + ARIZONA_IN2L_HPF_SHIFT, 1, 0), 128 + SOC_SINGLE("IN2R HPF Switch", ARIZONA_IN2R_CONTROL, 129 + ARIZONA_IN2R_HPF_SHIFT, 1, 0), 130 + SOC_SINGLE("IN3L HPF Switch", ARIZONA_IN3L_CONTROL, 131 + ARIZONA_IN3L_HPF_SHIFT, 1, 0), 132 + SOC_SINGLE("IN3R HPF Switch", ARIZONA_IN3R_CONTROL, 133 + ARIZONA_IN3R_HPF_SHIFT, 1, 0), 134 + SOC_SINGLE("IN4L HPF Switch", ARIZONA_IN4L_CONTROL, 135 + ARIZONA_IN4L_HPF_SHIFT, 1, 0), 136 + SOC_SINGLE("IN4R HPF Switch", ARIZONA_IN4R_CONTROL, 137 + ARIZONA_IN4R_HPF_SHIFT, 1, 0), 157 138 158 139 SOC_SINGLE_TLV("IN1L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L, 159 140 ARIZONA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv), ··· 277 220 SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), 278 221 SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode), 279 222 223 + SOC_VALUE_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), 224 + SOC_VALUE_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), 225 + SOC_VALUE_ENUM("ISRC3 FSL", arizona_isrc_fsl[2]), 226 + SOC_VALUE_ENUM("ISRC1 FSH", arizona_isrc_fsh[0]), 227 + SOC_VALUE_ENUM("ISRC2 FSH", arizona_isrc_fsh[1]), 228 + SOC_VALUE_ENUM("ISRC3 FSH", arizona_isrc_fsh[2]), 229 + SOC_VALUE_ENUM("ASRC RATE 1", arizona_asrc_rate1), 230 + 280 231 ARIZONA_MIXER_CONTROLS("DSP1L", ARIZONA_DSP1LMIX_INPUT_1_SOURCE), 281 232 ARIZONA_MIXER_CONTROLS("DSP1R", ARIZONA_DSP1RMIX_INPUT_1_SOURCE), 282 233 ARIZONA_MIXER_CONTROLS("DSP2L", ARIZONA_DSP2LMIX_INPUT_1_SOURCE), ··· 350 285 SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT, 351 286 ARIZONA_SPK2R_MUTE_SHIFT, 1, 1), 352 287 288 + SOC_DOUBLE("HPOUT1 DRE Switch", ARIZONA_DRE_ENABLE, 289 + ARIZONA_DRE1L_ENA_SHIFT, ARIZONA_DRE1R_ENA_SHIFT, 1, 0), 290 + SOC_DOUBLE("HPOUT2 DRE Switch", ARIZONA_DRE_ENABLE, 291 + ARIZONA_DRE2L_ENA_SHIFT, ARIZONA_DRE2R_ENA_SHIFT, 1, 0), 292 + SOC_DOUBLE("HPOUT3 DRE Switch", ARIZONA_DRE_ENABLE, 293 + ARIZONA_DRE3L_ENA_SHIFT, ARIZONA_DRE3R_ENA_SHIFT, 1, 0), 294 + 353 295 SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp), 354 296 SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp), 355 297 ··· 390 318 391 319 ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE), 392 320 ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE), 321 + ARIZONA_MIXER_CONTROLS("AIF2TX3", ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE), 322 + ARIZONA_MIXER_CONTROLS("AIF2TX4", ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE), 323 + ARIZONA_MIXER_CONTROLS("AIF2TX5", ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE), 324 + ARIZONA_MIXER_CONTROLS("AIF2TX6", ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE), 393 325 394 326 ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE), 395 327 ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE), ··· 422 346 ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE); 423 347 ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE); 424 348 ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE); 349 + 350 + ARIZONA_MIXER_ENUMS(DSP1L, ARIZONA_DSP1LMIX_INPUT_1_SOURCE); 351 + ARIZONA_MIXER_ENUMS(DSP1R, ARIZONA_DSP1RMIX_INPUT_1_SOURCE); 352 + ARIZONA_DSP_AUX_ENUMS(DSP1, ARIZONA_DSP1AUX1MIX_INPUT_1_SOURCE); 353 + 354 + ARIZONA_MIXER_ENUMS(DSP2L, ARIZONA_DSP2LMIX_INPUT_1_SOURCE); 355 + ARIZONA_MIXER_ENUMS(DSP2R, ARIZONA_DSP2RMIX_INPUT_1_SOURCE); 356 + ARIZONA_DSP_AUX_ENUMS(DSP2, ARIZONA_DSP2AUX1MIX_INPUT_1_SOURCE); 357 + 358 + ARIZONA_MIXER_ENUMS(DSP3L, ARIZONA_DSP3LMIX_INPUT_1_SOURCE); 359 + ARIZONA_MIXER_ENUMS(DSP3R, ARIZONA_DSP3RMIX_INPUT_1_SOURCE); 360 + ARIZONA_DSP_AUX_ENUMS(DSP3, ARIZONA_DSP3AUX1MIX_INPUT_1_SOURCE); 361 + 362 + ARIZONA_MIXER_ENUMS(DSP4L, ARIZONA_DSP4LMIX_INPUT_1_SOURCE); 363 + ARIZONA_MIXER_ENUMS(DSP4R, ARIZONA_DSP4RMIX_INPUT_1_SOURCE); 364 + ARIZONA_DSP_AUX_ENUMS(DSP4, ARIZONA_DSP4AUX1MIX_INPUT_1_SOURCE); 425 365 426 366 ARIZONA_MIXER_ENUMS(Mic, ARIZONA_MICMIX_INPUT_1_SOURCE); 427 367 ARIZONA_MIXER_ENUMS(Noise, ARIZONA_NOISEMIX_INPUT_1_SOURCE); ··· 469 377 470 378 ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE); 471 379 ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE); 380 + ARIZONA_MIXER_ENUMS(AIF2TX3, ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE); 381 + ARIZONA_MIXER_ENUMS(AIF2TX4, ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE); 382 + ARIZONA_MIXER_ENUMS(AIF2TX5, ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE); 383 + ARIZONA_MIXER_ENUMS(AIF2TX6, ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE); 472 384 473 385 ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE); 474 386 ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE); ··· 490 394 ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE); 491 395 ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); 492 396 ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); 397 + 398 + ARIZONA_MUX_ENUMS(ISRC1INT1, ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE); 399 + ARIZONA_MUX_ENUMS(ISRC1INT2, ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE); 400 + ARIZONA_MUX_ENUMS(ISRC1INT3, ARIZONA_ISRC1INT3MIX_INPUT_1_SOURCE); 401 + ARIZONA_MUX_ENUMS(ISRC1INT4, ARIZONA_ISRC1INT4MIX_INPUT_1_SOURCE); 402 + 403 + ARIZONA_MUX_ENUMS(ISRC1DEC1, ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE); 404 + ARIZONA_MUX_ENUMS(ISRC1DEC2, ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE); 405 + ARIZONA_MUX_ENUMS(ISRC1DEC3, ARIZONA_ISRC1DEC3MIX_INPUT_1_SOURCE); 406 + ARIZONA_MUX_ENUMS(ISRC1DEC4, ARIZONA_ISRC1DEC4MIX_INPUT_1_SOURCE); 407 + 408 + ARIZONA_MUX_ENUMS(ISRC2INT1, ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE); 409 + ARIZONA_MUX_ENUMS(ISRC2INT2, ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE); 410 + ARIZONA_MUX_ENUMS(ISRC2INT3, ARIZONA_ISRC2INT3MIX_INPUT_1_SOURCE); 411 + ARIZONA_MUX_ENUMS(ISRC2INT4, ARIZONA_ISRC2INT4MIX_INPUT_1_SOURCE); 412 + 413 + ARIZONA_MUX_ENUMS(ISRC2DEC1, ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE); 414 + ARIZONA_MUX_ENUMS(ISRC2DEC2, ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE); 415 + ARIZONA_MUX_ENUMS(ISRC2DEC3, ARIZONA_ISRC2DEC3MIX_INPUT_1_SOURCE); 416 + ARIZONA_MUX_ENUMS(ISRC2DEC4, ARIZONA_ISRC2DEC4MIX_INPUT_1_SOURCE); 417 + 418 + ARIZONA_MUX_ENUMS(ISRC3INT1, ARIZONA_ISRC3INT1MIX_INPUT_1_SOURCE); 419 + ARIZONA_MUX_ENUMS(ISRC3INT2, ARIZONA_ISRC3INT2MIX_INPUT_1_SOURCE); 420 + ARIZONA_MUX_ENUMS(ISRC3INT3, ARIZONA_ISRC3INT3MIX_INPUT_1_SOURCE); 421 + ARIZONA_MUX_ENUMS(ISRC3INT4, ARIZONA_ISRC3INT4MIX_INPUT_1_SOURCE); 422 + 423 + ARIZONA_MUX_ENUMS(ISRC3DEC1, ARIZONA_ISRC3DEC1MIX_INPUT_1_SOURCE); 424 + ARIZONA_MUX_ENUMS(ISRC3DEC2, ARIZONA_ISRC3DEC2MIX_INPUT_1_SOURCE); 425 + ARIZONA_MUX_ENUMS(ISRC3DEC3, ARIZONA_ISRC3DEC3MIX_INPUT_1_SOURCE); 426 + ARIZONA_MUX_ENUMS(ISRC3DEC4, ARIZONA_ISRC3DEC4MIX_INPUT_1_SOURCE); 493 427 494 428 static const char *wm5110_aec_loopback_texts[] = { 495 429 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "HPOUT3L", "HPOUT3R", ··· 661 535 SND_SOC_DAPM_PGA("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0, 662 536 NULL, 0), 663 537 538 + WM_ADSP2("DSP1", 0), 539 + WM_ADSP2("DSP2", 1), 540 + WM_ADSP2("DSP3", 2), 541 + WM_ADSP2("DSP4", 3), 542 + 543 + SND_SOC_DAPM_PGA("ISRC1INT1", ARIZONA_ISRC_1_CTRL_3, 544 + ARIZONA_ISRC1_INT0_ENA_SHIFT, 0, NULL, 0), 545 + SND_SOC_DAPM_PGA("ISRC1INT2", ARIZONA_ISRC_1_CTRL_3, 546 + ARIZONA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0), 547 + SND_SOC_DAPM_PGA("ISRC1INT3", ARIZONA_ISRC_1_CTRL_3, 548 + ARIZONA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0), 549 + SND_SOC_DAPM_PGA("ISRC1INT4", ARIZONA_ISRC_1_CTRL_3, 550 + ARIZONA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0), 551 + 552 + SND_SOC_DAPM_PGA("ISRC1DEC1", ARIZONA_ISRC_1_CTRL_3, 553 + ARIZONA_ISRC1_DEC0_ENA_SHIFT, 0, NULL, 0), 554 + SND_SOC_DAPM_PGA("ISRC1DEC2", ARIZONA_ISRC_1_CTRL_3, 555 + ARIZONA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0), 556 + SND_SOC_DAPM_PGA("ISRC1DEC3", ARIZONA_ISRC_1_CTRL_3, 557 + ARIZONA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0), 558 + SND_SOC_DAPM_PGA("ISRC1DEC4", ARIZONA_ISRC_1_CTRL_3, 559 + ARIZONA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0), 560 + 561 + SND_SOC_DAPM_PGA("ISRC2INT1", ARIZONA_ISRC_2_CTRL_3, 562 + ARIZONA_ISRC2_INT0_ENA_SHIFT, 0, NULL, 0), 563 + SND_SOC_DAPM_PGA("ISRC2INT2", ARIZONA_ISRC_2_CTRL_3, 564 + ARIZONA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0), 565 + SND_SOC_DAPM_PGA("ISRC2INT3", ARIZONA_ISRC_2_CTRL_3, 566 + ARIZONA_ISRC2_INT2_ENA_SHIFT, 0, NULL, 0), 567 + SND_SOC_DAPM_PGA("ISRC2INT4", ARIZONA_ISRC_2_CTRL_3, 568 + ARIZONA_ISRC2_INT3_ENA_SHIFT, 0, NULL, 0), 569 + 570 + SND_SOC_DAPM_PGA("ISRC2DEC1", ARIZONA_ISRC_2_CTRL_3, 571 + ARIZONA_ISRC2_DEC0_ENA_SHIFT, 0, NULL, 0), 572 + SND_SOC_DAPM_PGA("ISRC2DEC2", ARIZONA_ISRC_2_CTRL_3, 573 + ARIZONA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0), 574 + SND_SOC_DAPM_PGA("ISRC2DEC3", ARIZONA_ISRC_2_CTRL_3, 575 + ARIZONA_ISRC2_DEC2_ENA_SHIFT, 0, NULL, 0), 576 + SND_SOC_DAPM_PGA("ISRC2DEC4", ARIZONA_ISRC_2_CTRL_3, 577 + ARIZONA_ISRC2_DEC3_ENA_SHIFT, 0, NULL, 0), 578 + 579 + SND_SOC_DAPM_PGA("ISRC3INT1", ARIZONA_ISRC_3_CTRL_3, 580 + ARIZONA_ISRC3_INT0_ENA_SHIFT, 0, NULL, 0), 581 + SND_SOC_DAPM_PGA("ISRC3INT2", ARIZONA_ISRC_3_CTRL_3, 582 + ARIZONA_ISRC3_INT1_ENA_SHIFT, 0, NULL, 0), 583 + SND_SOC_DAPM_PGA("ISRC3INT3", ARIZONA_ISRC_3_CTRL_3, 584 + ARIZONA_ISRC3_INT2_ENA_SHIFT, 0, NULL, 0), 585 + SND_SOC_DAPM_PGA("ISRC3INT4", ARIZONA_ISRC_3_CTRL_3, 586 + ARIZONA_ISRC3_INT3_ENA_SHIFT, 0, NULL, 0), 587 + 588 + SND_SOC_DAPM_PGA("ISRC3DEC1", ARIZONA_ISRC_3_CTRL_3, 589 + ARIZONA_ISRC3_DEC0_ENA_SHIFT, 0, NULL, 0), 590 + SND_SOC_DAPM_PGA("ISRC3DEC2", ARIZONA_ISRC_3_CTRL_3, 591 + ARIZONA_ISRC3_DEC1_ENA_SHIFT, 0, NULL, 0), 592 + SND_SOC_DAPM_PGA("ISRC3DEC3", ARIZONA_ISRC_3_CTRL_3, 593 + ARIZONA_ISRC3_DEC2_ENA_SHIFT, 0, NULL, 0), 594 + SND_SOC_DAPM_PGA("ISRC3DEC4", ARIZONA_ISRC_3_CTRL_3, 595 + ARIZONA_ISRC3_DEC3_ENA_SHIFT, 0, NULL, 0), 596 + 664 597 SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, 665 598 ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, 666 599 &wm5110_aec_loopback_mux), ··· 762 577 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0), 763 578 SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0, 764 579 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0), 580 + SND_SOC_DAPM_AIF_OUT("AIF2TX3", NULL, 0, 581 + ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX3_ENA_SHIFT, 0), 582 + SND_SOC_DAPM_AIF_OUT("AIF2TX4", NULL, 0, 583 + ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX4_ENA_SHIFT, 0), 584 + SND_SOC_DAPM_AIF_OUT("AIF2TX5", NULL, 0, 585 + ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX5_ENA_SHIFT, 0), 586 + SND_SOC_DAPM_AIF_OUT("AIF2TX6", NULL, 0, 587 + ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX6_ENA_SHIFT, 0), 765 588 766 589 SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0, 767 590 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0), 768 591 SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0, 769 592 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0), 593 + SND_SOC_DAPM_AIF_IN("AIF2RX3", NULL, 0, 594 + ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX3_ENA_SHIFT, 0), 595 + SND_SOC_DAPM_AIF_IN("AIF2RX4", NULL, 0, 596 + ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX4_ENA_SHIFT, 0), 597 + SND_SOC_DAPM_AIF_IN("AIF2RX5", NULL, 0, 598 + ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX5_ENA_SHIFT, 0), 599 + SND_SOC_DAPM_AIF_IN("AIF2RX6", NULL, 0, 600 + ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX6_ENA_SHIFT, 0), 770 601 771 602 SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0, 772 603 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, ··· 920 719 921 720 ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"), 922 721 ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"), 722 + ARIZONA_MIXER_WIDGETS(AIF2TX3, "AIF2TX3"), 723 + ARIZONA_MIXER_WIDGETS(AIF2TX4, "AIF2TX4"), 724 + ARIZONA_MIXER_WIDGETS(AIF2TX5, "AIF2TX5"), 725 + ARIZONA_MIXER_WIDGETS(AIF2TX6, "AIF2TX6"), 923 726 924 727 ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), 925 728 ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), ··· 941 736 ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"), 942 737 ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"), 943 738 ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"), 739 + 740 + ARIZONA_DSP_WIDGETS(DSP1, "DSP1"), 741 + ARIZONA_DSP_WIDGETS(DSP2, "DSP2"), 742 + ARIZONA_DSP_WIDGETS(DSP3, "DSP3"), 743 + ARIZONA_DSP_WIDGETS(DSP4, "DSP4"), 744 + 745 + ARIZONA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"), 746 + ARIZONA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"), 747 + ARIZONA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"), 748 + ARIZONA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"), 749 + 750 + ARIZONA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"), 751 + ARIZONA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"), 752 + ARIZONA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"), 753 + ARIZONA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"), 754 + 755 + ARIZONA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"), 756 + ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"), 757 + ARIZONA_MUX_WIDGETS(ISRC2DEC3, "ISRC2DEC3"), 758 + ARIZONA_MUX_WIDGETS(ISRC2DEC4, "ISRC2DEC4"), 759 + 760 + ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"), 761 + ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"), 762 + ARIZONA_MUX_WIDGETS(ISRC2INT3, "ISRC2INT3"), 763 + ARIZONA_MUX_WIDGETS(ISRC2INT4, "ISRC2INT4"), 764 + 765 + ARIZONA_MUX_WIDGETS(ISRC3DEC1, "ISRC3DEC1"), 766 + ARIZONA_MUX_WIDGETS(ISRC3DEC2, "ISRC3DEC2"), 767 + ARIZONA_MUX_WIDGETS(ISRC3DEC3, "ISRC3DEC3"), 768 + ARIZONA_MUX_WIDGETS(ISRC3DEC4, "ISRC3DEC4"), 769 + 770 + ARIZONA_MUX_WIDGETS(ISRC3INT1, "ISRC3INT1"), 771 + ARIZONA_MUX_WIDGETS(ISRC3INT2, "ISRC3INT2"), 772 + ARIZONA_MUX_WIDGETS(ISRC3INT3, "ISRC3INT3"), 773 + ARIZONA_MUX_WIDGETS(ISRC3INT4, "ISRC3INT4"), 944 774 945 775 SND_SOC_DAPM_OUTPUT("HPOUT1L"), 946 776 SND_SOC_DAPM_OUTPUT("HPOUT1R"), ··· 1020 780 { name, "AIF1RX8", "AIF1RX8" }, \ 1021 781 { name, "AIF2RX1", "AIF2RX1" }, \ 1022 782 { name, "AIF2RX2", "AIF2RX2" }, \ 783 + { name, "AIF2RX3", "AIF2RX3" }, \ 784 + { name, "AIF2RX4", "AIF2RX4" }, \ 785 + { name, "AIF2RX5", "AIF2RX5" }, \ 786 + { name, "AIF2RX6", "AIF2RX6" }, \ 1023 787 { name, "AIF3RX1", "AIF3RX1" }, \ 1024 788 { name, "AIF3RX2", "AIF3RX2" }, \ 1025 789 { name, "SLIMRX1", "SLIMRX1" }, \ ··· 1049 805 { name, "ASRC1L", "ASRC1L" }, \ 1050 806 { name, "ASRC1R", "ASRC1R" }, \ 1051 807 { name, "ASRC2L", "ASRC2L" }, \ 1052 - { name, "ASRC2R", "ASRC2R" } 808 + { name, "ASRC2R", "ASRC2R" }, \ 809 + { name, "ISRC1DEC1", "ISRC1DEC1" }, \ 810 + { name, "ISRC1DEC2", "ISRC1DEC2" }, \ 811 + { name, "ISRC1DEC3", "ISRC1DEC3" }, \ 812 + { name, "ISRC1DEC4", "ISRC1DEC4" }, \ 813 + { name, "ISRC1INT1", "ISRC1INT1" }, \ 814 + { name, "ISRC1INT2", "ISRC1INT2" }, \ 815 + { name, "ISRC1INT3", "ISRC1INT3" }, \ 816 + { name, "ISRC1INT4", "ISRC1INT4" }, \ 817 + { name, "ISRC2DEC1", "ISRC2DEC1" }, \ 818 + { name, "ISRC2DEC2", "ISRC2DEC2" }, \ 819 + { name, "ISRC2DEC3", "ISRC2DEC3" }, \ 820 + { name, "ISRC2DEC4", "ISRC2DEC4" }, \ 821 + { name, "ISRC2INT1", "ISRC2INT1" }, \ 822 + { name, "ISRC2INT2", "ISRC2INT2" }, \ 823 + { name, "ISRC2INT3", "ISRC2INT3" }, \ 824 + { name, "ISRC2INT4", "ISRC2INT4" }, \ 825 + { name, "ISRC3DEC1", "ISRC3DEC1" }, \ 826 + { name, "ISRC3DEC2", "ISRC3DEC2" }, \ 827 + { name, "ISRC3DEC3", "ISRC3DEC3" }, \ 828 + { name, "ISRC3DEC4", "ISRC3DEC4" }, \ 829 + { name, "ISRC3INT1", "ISRC3INT1" }, \ 830 + { name, "ISRC3INT2", "ISRC3INT2" }, \ 831 + { name, "ISRC3INT3", "ISRC3INT3" }, \ 832 + { name, "ISRC3INT4", "ISRC3INT4" }, \ 833 + { name, "DSP1.1", "DSP1" }, \ 834 + { name, "DSP1.2", "DSP1" }, \ 835 + { name, "DSP1.3", "DSP1" }, \ 836 + { name, "DSP1.4", "DSP1" }, \ 837 + { name, "DSP1.5", "DSP1" }, \ 838 + { name, "DSP1.6", "DSP1" }, \ 839 + { name, "DSP2.1", "DSP2" }, \ 840 + { name, "DSP2.2", "DSP2" }, \ 841 + { name, "DSP2.3", "DSP2" }, \ 842 + { name, "DSP2.4", "DSP2" }, \ 843 + { name, "DSP2.5", "DSP2" }, \ 844 + { name, "DSP2.6", "DSP2" }, \ 845 + { name, "DSP3.1", "DSP3" }, \ 846 + { name, "DSP3.2", "DSP3" }, \ 847 + { name, "DSP3.3", "DSP3" }, \ 848 + { name, "DSP3.4", "DSP3" }, \ 849 + { name, "DSP3.5", "DSP3" }, \ 850 + { name, "DSP3.6", "DSP3" }, \ 851 + { name, "DSP4.1", "DSP4" }, \ 852 + { name, "DSP4.2", "DSP4" }, \ 853 + { name, "DSP4.3", "DSP4" }, \ 854 + { name, "DSP4.4", "DSP4" }, \ 855 + { name, "DSP4.5", "DSP4" }, \ 856 + { name, "DSP4.6", "DSP4" } 1053 857 1054 858 static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { 1055 859 { "AIF2 Capture", NULL, "DBVDD2" }, ··· 1169 877 1170 878 { "AIF2 Capture", NULL, "AIF2TX1" }, 1171 879 { "AIF2 Capture", NULL, "AIF2TX2" }, 880 + { "AIF2 Capture", NULL, "AIF2TX3" }, 881 + { "AIF2 Capture", NULL, "AIF2TX4" }, 882 + { "AIF2 Capture", NULL, "AIF2TX5" }, 883 + { "AIF2 Capture", NULL, "AIF2TX6" }, 1172 884 1173 885 { "AIF2RX1", NULL, "AIF2 Playback" }, 1174 886 { "AIF2RX2", NULL, "AIF2 Playback" }, 887 + { "AIF2RX3", NULL, "AIF2 Playback" }, 888 + { "AIF2RX4", NULL, "AIF2 Playback" }, 889 + { "AIF2RX5", NULL, "AIF2 Playback" }, 890 + { "AIF2RX6", NULL, "AIF2 Playback" }, 1175 891 1176 892 { "AIF3 Capture", NULL, "AIF3TX1" }, 1177 893 { "AIF3 Capture", NULL, "AIF3TX2" }, ··· 1263 963 1264 964 ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"), 1265 965 ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"), 966 + ARIZONA_MIXER_ROUTES("AIF2TX3", "AIF2TX3"), 967 + ARIZONA_MIXER_ROUTES("AIF2TX4", "AIF2TX4"), 968 + ARIZONA_MIXER_ROUTES("AIF2TX5", "AIF2TX5"), 969 + ARIZONA_MIXER_ROUTES("AIF2TX6", "AIF2TX6"), 1266 970 1267 971 ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"), 1268 972 ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"), ··· 1302 998 ARIZONA_MUX_ROUTES("ASRC1R", "ASRC1R"), 1303 999 ARIZONA_MUX_ROUTES("ASRC2L", "ASRC2L"), 1304 1000 ARIZONA_MUX_ROUTES("ASRC2R", "ASRC2R"), 1001 + 1002 + ARIZONA_DSP_ROUTES("DSP1"), 1003 + ARIZONA_DSP_ROUTES("DSP2"), 1004 + ARIZONA_DSP_ROUTES("DSP3"), 1005 + ARIZONA_DSP_ROUTES("DSP4"), 1006 + 1007 + ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"), 1008 + ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"), 1009 + ARIZONA_MUX_ROUTES("ISRC1INT3", "ISRC1INT3"), 1010 + ARIZONA_MUX_ROUTES("ISRC1INT4", "ISRC1INT4"), 1011 + 1012 + ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"), 1013 + ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"), 1014 + ARIZONA_MUX_ROUTES("ISRC1DEC3", "ISRC1DEC3"), 1015 + ARIZONA_MUX_ROUTES("ISRC1DEC4", "ISRC1DEC4"), 1016 + 1017 + ARIZONA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"), 1018 + ARIZONA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"), 1019 + ARIZONA_MUX_ROUTES("ISRC2INT3", "ISRC2INT3"), 1020 + ARIZONA_MUX_ROUTES("ISRC2INT4", "ISRC2INT4"), 1021 + 1022 + ARIZONA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"), 1023 + ARIZONA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"), 1024 + ARIZONA_MUX_ROUTES("ISRC2DEC3", "ISRC2DEC3"), 1025 + ARIZONA_MUX_ROUTES("ISRC2DEC4", "ISRC2DEC4"), 1026 + 1027 + ARIZONA_MUX_ROUTES("ISRC3INT1", "ISRC3INT1"), 1028 + ARIZONA_MUX_ROUTES("ISRC3INT2", "ISRC3INT2"), 1029 + ARIZONA_MUX_ROUTES("ISRC3INT3", "ISRC3INT3"), 1030 + ARIZONA_MUX_ROUTES("ISRC3INT4", "ISRC3INT4"), 1031 + 1032 + ARIZONA_MUX_ROUTES("ISRC3DEC1", "ISRC3DEC1"), 1033 + ARIZONA_MUX_ROUTES("ISRC3DEC2", "ISRC3DEC2"), 1034 + ARIZONA_MUX_ROUTES("ISRC3DEC3", "ISRC3DEC3"), 1035 + ARIZONA_MUX_ROUTES("ISRC3DEC4", "ISRC3DEC4"), 1305 1036 1306 1037 { "AEC Loopback", "HPOUT1L", "OUT1L" }, 1307 1038 { "AEC Loopback", "HPOUT1R", "OUT1R" }, ··· 1434 1095 .playback = { 1435 1096 .stream_name = "AIF2 Playback", 1436 1097 .channels_min = 1, 1437 - .channels_max = 2, 1098 + .channels_max = 6, 1438 1099 .rates = WM5110_RATES, 1439 1100 .formats = WM5110_FORMATS, 1440 1101 }, 1441 1102 .capture = { 1442 1103 .stream_name = "AIF2 Capture", 1443 1104 .channels_min = 1, 1444 - .channels_max = 2, 1105 + .channels_max = 6, 1445 1106 .rates = WM5110_RATES, 1446 1107 .formats = WM5110_FORMATS, 1447 1108 }, ··· 1543 1204 arizona_init_spk(codec); 1544 1205 arizona_init_gpio(codec); 1545 1206 1207 + ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 8); 1208 + if (ret != 0) 1209 + return ret; 1210 + 1546 1211 snd_soc_dapm_disable_pin(&codec->dapm, "HAPTICS"); 1547 1212 1548 1213 priv->core.arizona->dapm = &codec->dapm; ··· 1601 1258 { 1602 1259 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 1603 1260 struct wm5110_priv *wm5110; 1604 - int i; 1261 + int i, ret; 1605 1262 1606 1263 wm5110 = devm_kzalloc(&pdev->dev, sizeof(struct wm5110_priv), 1607 1264 GFP_KERNEL); ··· 1612 1269 wm5110->core.arizona = arizona; 1613 1270 wm5110->core.num_inputs = 8; 1614 1271 1272 + for (i = 0; i < WM5110_NUM_ADSP; i++) { 1273 + wm5110->core.adsp[i].part = "wm5110"; 1274 + wm5110->core.adsp[i].num = i + 1; 1275 + wm5110->core.adsp[i].type = WMFW_ADSP2; 1276 + wm5110->core.adsp[i].dev = arizona->dev; 1277 + wm5110->core.adsp[i].regmap = arizona->regmap; 1278 + 1279 + wm5110->core.adsp[i].base = ARIZONA_DSP1_CONTROL_1 1280 + + (0x100 * i); 1281 + wm5110->core.adsp[i].mem = wm5110_dsp_regions[i]; 1282 + wm5110->core.adsp[i].num_mems 1283 + = ARRAY_SIZE(wm5110_dsp1_regions); 1284 + 1285 + ret = wm_adsp2_init(&wm5110->core.adsp[i], false); 1286 + if (ret != 0) 1287 + return ret; 1288 + } 1289 + 1615 1290 for (i = 0; i < ARRAY_SIZE(wm5110->fll); i++) 1616 1291 wm5110->fll[i].vco_mult = 3; 1617 1292 ··· 1639 1278 arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1, 1640 1279 ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK, 1641 1280 &wm5110->fll[1]); 1281 + 1282 + /* SR2 fixed at 8kHz, SR3 fixed at 16kHz */ 1283 + regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_2, 1284 + ARIZONA_SAMPLE_RATE_2_MASK, 0x11); 1285 + regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_3, 1286 + ARIZONA_SAMPLE_RATE_3_MASK, 0x12); 1642 1287 1643 1288 for (i = 0; i < ARRAY_SIZE(wm5110_dai); i++) 1644 1289 arizona_init_dai(&wm5110->core, i);
+3 -3
sound/soc/codecs/wm8510.c
··· 684 684 }; 685 685 #endif /* CONFIG_SPI_MASTER */ 686 686 687 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 687 + #if IS_ENABLED(CONFIG_I2C) 688 688 static int wm8510_i2c_probe(struct i2c_client *i2c, 689 689 const struct i2c_device_id *id) 690 690 { ··· 735 735 static int __init wm8510_modinit(void) 736 736 { 737 737 int ret = 0; 738 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 738 + #if IS_ENABLED(CONFIG_I2C) 739 739 ret = i2c_add_driver(&wm8510_i2c_driver); 740 740 if (ret != 0) { 741 741 printk(KERN_ERR "Failed to register WM8510 I2C driver: %d\n", ··· 755 755 756 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 759 i2c_del_driver(&wm8510_i2c_driver); 760 760 #endif 761 761 #if defined(CONFIG_SPI_MASTER)
+3 -3
sound/soc/codecs/wm8523.c
··· 452 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 456 static int wm8523_i2c_probe(struct i2c_client *i2c, 457 457 const struct i2c_device_id *id) 458 458 { ··· 555 555 static int __init wm8523_modinit(void) 556 556 { 557 557 int ret; 558 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 558 + #if IS_ENABLED(CONFIG_I2C) 559 559 ret = i2c_add_driver(&wm8523_i2c_driver); 560 560 if (ret != 0) { 561 561 printk(KERN_ERR "Failed to register WM8523 I2C driver: %d\n", ··· 568 568 569 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 572 i2c_del_driver(&wm8523_i2c_driver); 573 573 #endif 574 574 }
+3 -3
sound/soc/codecs/wm8580.c
··· 941 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 945 static int wm8580_i2c_probe(struct i2c_client *i2c, 946 946 const struct i2c_device_id *id) 947 947 { ··· 1003 1003 { 1004 1004 int ret = 0; 1005 1005 1006 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1006 + #if IS_ENABLED(CONFIG_I2C) 1007 1007 ret = i2c_add_driver(&wm8580_i2c_driver); 1008 1008 if (ret != 0) { 1009 1009 pr_err("Failed to register WM8580 I2C driver: %d\n", ret); ··· 1016 1016 1017 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 1020 i2c_del_driver(&wm8580_i2c_driver); 1021 1021 #endif 1022 1022 }
+3 -3
sound/soc/codecs/wm8711.c
··· 469 469 }; 470 470 #endif /* CONFIG_SPI_MASTER */ 471 471 472 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 472 + #if IS_ENABLED(CONFIG_I2C) 473 473 static int wm8711_i2c_probe(struct i2c_client *client, 474 474 const struct i2c_device_id *id) 475 475 { ··· 520 520 static int __init wm8711_modinit(void) 521 521 { 522 522 int ret; 523 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 523 + #if IS_ENABLED(CONFIG_I2C) 524 524 ret = i2c_add_driver(&wm8711_i2c_driver); 525 525 if (ret != 0) { 526 526 printk(KERN_ERR "Failed to register WM8711 I2C driver: %d\n", ··· 540 540 541 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 544 i2c_del_driver(&wm8711_i2c_driver); 545 545 #endif 546 546 #if defined(CONFIG_SPI_MASTER)
+3 -3
sound/soc/codecs/wm8728.c
··· 320 320 }; 321 321 #endif /* CONFIG_SPI_MASTER */ 322 322 323 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 323 + #if IS_ENABLED(CONFIG_I2C) 324 324 static int wm8728_i2c_probe(struct i2c_client *i2c, 325 325 const struct i2c_device_id *id) 326 326 { ··· 371 371 static int __init wm8728_modinit(void) 372 372 { 373 373 int ret = 0; 374 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 374 + #if IS_ENABLED(CONFIG_I2C) 375 375 ret = i2c_add_driver(&wm8728_i2c_driver); 376 376 if (ret != 0) { 377 377 printk(KERN_ERR "Failed to register wm8728 I2C driver: %d\n", ··· 391 391 392 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 395 i2c_del_driver(&wm8728_i2c_driver); 396 396 #endif 397 397 #if defined(CONFIG_SPI_MASTER)
+3 -3
sound/soc/codecs/wm8731.c
··· 732 732 }; 733 733 #endif /* CONFIG_SPI_MASTER */ 734 734 735 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 735 + #if IS_ENABLED(CONFIG_I2C) 736 736 static int wm8731_i2c_probe(struct i2c_client *i2c, 737 737 const struct i2c_device_id *id) 738 738 { ··· 791 791 static int __init wm8731_modinit(void) 792 792 { 793 793 int ret = 0; 794 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 794 + #if IS_ENABLED(CONFIG_I2C) 795 795 ret = i2c_add_driver(&wm8731_i2c_driver); 796 796 if (ret != 0) { 797 797 printk(KERN_ERR "Failed to register WM8731 I2C driver: %d\n", ··· 811 811 812 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 815 i2c_del_driver(&wm8731_i2c_driver); 816 816 #endif 817 817 #if defined(CONFIG_SPI_MASTER)
+3 -3
sound/soc/codecs/wm8741.c
··· 500 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 504 static int wm8741_i2c_probe(struct i2c_client *i2c, 505 505 const struct i2c_device_id *id) 506 506 { ··· 617 617 { 618 618 int ret = 0; 619 619 620 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 620 + #if IS_ENABLED(CONFIG_I2C) 621 621 ret = i2c_add_driver(&wm8741_i2c_driver); 622 622 if (ret != 0) 623 623 pr_err("Failed to register WM8741 I2C driver: %d\n", ret); ··· 639 639 #if defined(CONFIG_SPI_MASTER) 640 640 spi_unregister_driver(&wm8741_spi_driver); 641 641 #endif 642 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 642 + #if IS_ENABLED(CONFIG_I2C) 643 643 i2c_del_driver(&wm8741_i2c_driver); 644 644 #endif 645 645 }
+3 -3
sound/soc/codecs/wm8750.c
··· 816 816 }; 817 817 #endif /* CONFIG_SPI_MASTER */ 818 818 819 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 819 + #if IS_ENABLED(CONFIG_I2C) 820 820 static int wm8750_i2c_probe(struct i2c_client *i2c, 821 821 const struct i2c_device_id *id) 822 822 { ··· 868 868 static int __init wm8750_modinit(void) 869 869 { 870 870 int ret = 0; 871 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 871 + #if IS_ENABLED(CONFIG_I2C) 872 872 ret = i2c_add_driver(&wm8750_i2c_driver); 873 873 if (ret != 0) { 874 874 printk(KERN_ERR "Failed to register wm8750 I2C driver: %d\n", ··· 888 888 889 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 892 i2c_del_driver(&wm8750_i2c_driver); 893 893 #endif 894 894 #if defined(CONFIG_SPI_MASTER)
+3 -3
sound/soc/codecs/wm8753.c
··· 1596 1596 }; 1597 1597 #endif /* CONFIG_SPI_MASTER */ 1598 1598 1599 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1599 + #if IS_ENABLED(CONFIG_I2C) 1600 1600 static int wm8753_i2c_probe(struct i2c_client *i2c, 1601 1601 const struct i2c_device_id *id) 1602 1602 { ··· 1653 1653 static int __init wm8753_modinit(void) 1654 1654 { 1655 1655 int ret = 0; 1656 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1656 + #if IS_ENABLED(CONFIG_I2C) 1657 1657 ret = i2c_add_driver(&wm8753_i2c_driver); 1658 1658 if (ret != 0) { 1659 1659 printk(KERN_ERR "Failed to register wm8753 I2C driver: %d\n", ··· 1673 1673 1674 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 1677 i2c_del_driver(&wm8753_i2c_driver); 1678 1678 #endif 1679 1679 #if defined(CONFIG_SPI_MASTER)
+3 -3
sound/soc/codecs/wm8776.c
··· 532 532 }; 533 533 #endif /* CONFIG_SPI_MASTER */ 534 534 535 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 535 + #if IS_ENABLED(CONFIG_I2C) 536 536 static int wm8776_i2c_probe(struct i2c_client *i2c, 537 537 const struct i2c_device_id *id) 538 538 { ··· 584 584 static int __init wm8776_modinit(void) 585 585 { 586 586 int ret = 0; 587 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 587 + #if IS_ENABLED(CONFIG_I2C) 588 588 ret = i2c_add_driver(&wm8776_i2c_driver); 589 589 if (ret != 0) { 590 590 printk(KERN_ERR "Failed to register wm8776 I2C driver: %d\n", ··· 604 604 605 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 608 i2c_del_driver(&wm8776_i2c_driver); 609 609 #endif 610 610 #if defined(CONFIG_SPI_MASTER)
+3 -3
sound/soc/codecs/wm8804.c
··· 739 739 }; 740 740 #endif 741 741 742 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 742 + #if IS_ENABLED(CONFIG_I2C) 743 743 static int wm8804_i2c_probe(struct i2c_client *i2c, 744 744 const struct i2c_device_id *id) 745 745 { ··· 791 791 { 792 792 int ret = 0; 793 793 794 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 794 + #if IS_ENABLED(CONFIG_I2C) 795 795 ret = i2c_add_driver(&wm8804_i2c_driver); 796 796 if (ret) { 797 797 printk(KERN_ERR "Failed to register wm8804 I2C driver: %d\n", ··· 811 811 812 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 815 i2c_del_driver(&wm8804_i2c_driver); 816 816 #endif 817 817 #if defined(CONFIG_SPI_MASTER)
+3 -3
sound/soc/codecs/wm8900.c
··· 1288 1288 }; 1289 1289 #endif /* CONFIG_SPI_MASTER */ 1290 1290 1291 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1291 + #if IS_ENABLED(CONFIG_I2C) 1292 1292 static int wm8900_i2c_probe(struct i2c_client *i2c, 1293 1293 const struct i2c_device_id *id) 1294 1294 { ··· 1338 1338 static int __init wm8900_modinit(void) 1339 1339 { 1340 1340 int ret = 0; 1341 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1341 + #if IS_ENABLED(CONFIG_I2C) 1342 1342 ret = i2c_add_driver(&wm8900_i2c_driver); 1343 1343 if (ret != 0) { 1344 1344 printk(KERN_ERR "Failed to register wm8900 I2C driver: %d\n", ··· 1358 1358 1359 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 1362 i2c_del_driver(&wm8900_i2c_driver); 1363 1363 #endif 1364 1364 #if defined(CONFIG_SPI_MASTER)
+128 -93
sound/soc/codecs/wm8940.c
··· 28 28 #include <linux/delay.h> 29 29 #include <linux/pm.h> 30 30 #include <linux/i2c.h> 31 - #include <linux/spi/spi.h> 31 + #include <linux/regmap.h> 32 32 #include <linux/slab.h> 33 33 #include <sound/core.h> 34 34 #include <sound/pcm.h> ··· 41 41 42 42 struct wm8940_priv { 43 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, 48 - unsigned int reg) 47 + static bool wm8940_volatile_register(struct device *dev, unsigned int reg) 49 48 { 50 49 switch (reg) { 51 50 case WM8940_SOFTRESET: 52 - return 1; 51 + return true; 53 52 default: 54 - return 0; 53 + return false; 55 54 } 56 55 } 57 56 58 - static u16 wm8940_reg_defaults[] = { 59 - 0x8940, /* Soft Reset */ 60 - 0x0000, /* Power 1 */ 61 - 0x0000, /* Power 2 */ 62 - 0x0000, /* Power 3 */ 63 - 0x0010, /* Interface Control */ 64 - 0x0000, /* Companding Control */ 65 - 0x0140, /* Clock Control */ 66 - 0x0000, /* Additional Controls */ 67 - 0x0000, /* GPIO Control */ 68 - 0x0002, /* Auto Increment Control */ 69 - 0x0000, /* DAC Control */ 70 - 0x00FF, /* DAC Volume */ 71 - 0, 72 - 0, 73 - 0x0100, /* ADC Control */ 74 - 0x00FF, /* ADC Volume */ 75 - 0x0000, /* Notch Filter 1 Control 1 */ 76 - 0x0000, /* Notch Filter 1 Control 2 */ 77 - 0x0000, /* Notch Filter 2 Control 1 */ 78 - 0x0000, /* Notch Filter 2 Control 2 */ 79 - 0x0000, /* Notch Filter 3 Control 1 */ 80 - 0x0000, /* Notch Filter 3 Control 2 */ 81 - 0x0000, /* Notch Filter 4 Control 1 */ 82 - 0x0000, /* Notch Filter 4 Control 2 */ 83 - 0x0032, /* DAC Limit Control 1 */ 84 - 0x0000, /* DAC Limit Control 2 */ 85 - 0, 86 - 0, 87 - 0, 88 - 0, 89 - 0, 90 - 0, 91 - 0x0038, /* ALC Control 1 */ 92 - 0x000B, /* ALC Control 2 */ 93 - 0x0032, /* ALC Control 3 */ 94 - 0x0000, /* Noise Gate */ 95 - 0x0041, /* PLLN */ 96 - 0x000C, /* PLLK1 */ 97 - 0x0093, /* PLLK2 */ 98 - 0x00E9, /* PLLK3 */ 99 - 0, 100 - 0, 101 - 0x0030, /* ALC Control 4 */ 102 - 0, 103 - 0x0002, /* Input Control */ 104 - 0x0050, /* PGA Gain */ 105 - 0, 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 */ 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; 103 + } 104 + } 105 + 106 + static const struct reg_default wm8940_reg_defaults[] = { 107 + { 0x1, 0x0000 }, /* Power 1 */ 108 + { 0x2, 0x0000 }, /* Power 2 */ 109 + { 0x3, 0x0000 }, /* Power 3 */ 110 + { 0x4, 0x0010 }, /* Interface Control */ 111 + { 0x5, 0x0000 }, /* Companding Control */ 112 + { 0x6, 0x0140 }, /* Clock Control */ 113 + { 0x7, 0x0000 }, /* Additional Controls */ 114 + { 0x8, 0x0000 }, /* GPIO Control */ 115 + { 0x9, 0x0002 }, /* Auto Increment Control */ 116 + { 0xa, 0x0000 }, /* DAC Control */ 117 + { 0xb, 0x00FF }, /* DAC Volume */ 118 + 119 + { 0xe, 0x0100 }, /* ADC Control */ 120 + { 0xf, 0x00FF }, /* ADC Volume */ 121 + { 0x10, 0x0000 }, /* Notch Filter 1 Control 1 */ 122 + { 0x11, 0x0000 }, /* Notch Filter 1 Control 2 */ 123 + { 0x12, 0x0000 }, /* Notch Filter 2 Control 1 */ 124 + { 0x13, 0x0000 }, /* Notch Filter 2 Control 2 */ 125 + { 0x14, 0x0000 }, /* Notch Filter 3 Control 1 */ 126 + { 0x15, 0x0000 }, /* Notch Filter 3 Control 2 */ 127 + { 0x16, 0x0000 }, /* Notch Filter 4 Control 1 */ 128 + { 0x17, 0x0000 }, /* Notch Filter 4 Control 2 */ 129 + { 0x18, 0x0032 }, /* DAC Limit Control 1 */ 130 + { 0x19, 0x0000 }, /* DAC Limit Control 2 */ 131 + 132 + { 0x20, 0x0038 }, /* ALC Control 1 */ 133 + { 0x21, 0x000B }, /* ALC Control 2 */ 134 + { 0x22, 0x0032 }, /* ALC Control 3 */ 135 + { 0x23, 0x0000 }, /* Noise Gate */ 136 + { 0x24, 0x0041 }, /* PLLN */ 137 + { 0x25, 0x000C }, /* PLLK1 */ 138 + { 0x26, 0x0093 }, /* PLLK2 */ 139 + { 0x27, 0x00E9 }, /* PLLK3 */ 140 + 141 + { 0x2a, 0x0030 }, /* ALC Control 4 */ 142 + 143 + { 0x2c, 0x0002 }, /* Input Control */ 144 + { 0x2d, 0x0050 }, /* PGA Gain */ 145 + 146 + { 0x2f, 0x0002 }, /* ADC Boost Control */ 147 + 148 + { 0x31, 0x0002 }, /* Output Control */ 149 + { 0x32, 0x0000 }, /* Speaker Mixer Control */ 150 + 151 + { 0x36, 0x0079 }, /* Speaker Volume */ 152 + 153 + { 0x38, 0x0000 }, /* Mono Mixer Control */ 116 154 }; 117 155 118 156 static const char *wm8940_companding[] = { "Off", "NC", "u-law", "A-law" }; ··· 302 264 SND_SOC_DAPM_INPUT("AUX"), 303 265 }; 304 266 305 - static const struct snd_soc_dapm_route audio_map[] = { 267 + static const struct snd_soc_dapm_route wm8940_dapm_routes[] = { 306 268 /* Mono output mixer */ 307 269 {"Mono Mixer", "PCM Playback Switch", "DAC"}, 308 270 {"Mono Mixer", "Aux Playback Switch", "Aux Input"}, ··· 333 295 334 296 {"ADC", NULL, "Boost Mixer"}, 335 297 }; 336 - 337 - static int wm8940_add_widgets(struct snd_soc_codec *codec) 338 - { 339 - struct snd_soc_dapm_context *dapm = &codec->dapm; 340 - int ret; 341 - 342 - ret = snd_soc_dapm_new_controls(dapm, wm8940_dapm_widgets, 343 - ARRAY_SIZE(wm8940_dapm_widgets)); 344 - if (ret) 345 - goto error_ret; 346 - ret = snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); 347 - 348 - error_ret: 349 - return ret; 350 - } 351 298 352 299 #define wm8940_reset(c) snd_soc_write(c, WM8940_SOFTRESET, 0); 353 300 ··· 469 446 static int wm8940_set_bias_level(struct snd_soc_codec *codec, 470 447 enum snd_soc_bias_level level) 471 448 { 449 + struct wm8940_priv *wm8940 = snd_soc_codec_get_drvdata(codec); 472 450 u16 val; 473 451 u16 pwr_reg = snd_soc_read(codec, WM8940_POWER1) & 0x1F0; 474 452 int ret = 0; ··· 493 469 break; 494 470 case SND_SOC_BIAS_STANDBY: 495 471 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 496 - ret = snd_soc_cache_sync(codec); 472 + ret = regcache_sync(wm8940->regmap); 497 473 if (ret < 0) { 498 474 dev_err(codec->dev, "Failed to sync cache: %d\n", ret); 499 475 return ret; ··· 708 684 709 685 static int wm8940_probe(struct snd_soc_codec *codec) 710 686 { 711 - struct wm8940_priv *wm8940 = snd_soc_codec_get_drvdata(codec); 712 687 struct wm8940_setup_data *pdata = codec->dev->platform_data; 713 688 int ret; 714 689 u16 reg; 715 690 716 - ret = snd_soc_codec_set_cache_io(codec, 8, 16, wm8940->control_type); 691 + ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); 717 692 if (ret < 0) { 718 693 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 719 694 return ret; ··· 739 716 return ret; 740 717 } 741 718 742 - ret = snd_soc_add_codec_controls(codec, wm8940_snd_controls, 743 - ARRAY_SIZE(wm8940_snd_controls)); 744 - if (ret) 745 - return ret; 746 - ret = wm8940_add_widgets(codec); 747 719 return ret; 748 720 } 749 721 ··· 754 736 .suspend = wm8940_suspend, 755 737 .resume = wm8940_resume, 756 738 .set_bias_level = wm8940_set_bias_level, 757 - .reg_cache_size = ARRAY_SIZE(wm8940_reg_defaults), 758 - .reg_word_size = sizeof(u16), 759 - .reg_cache_default = wm8940_reg_defaults, 760 - .volatile_register = wm8940_volatile_register, 739 + .controls = wm8940_snd_controls, 740 + .num_controls = ARRAY_SIZE(wm8940_snd_controls), 741 + .dapm_widgets = wm8940_dapm_widgets, 742 + .num_dapm_widgets = ARRAY_SIZE(wm8940_dapm_widgets), 743 + .dapm_routes = wm8940_dapm_routes, 744 + .num_dapm_routes = ARRAY_SIZE(wm8940_dapm_routes), 745 + }; 746 + 747 + static const struct regmap_config wm8940_regmap = { 748 + .reg_bits = 8, 749 + .val_bits = 16, 750 + 751 + .max_register = WM8940_MONOMIX, 752 + .reg_defaults = wm8940_reg_defaults, 753 + .num_reg_defaults = ARRAY_SIZE(wm8940_reg_defaults), 754 + 755 + .readable_reg = wm8940_readable_register, 756 + .volatile_reg = wm8940_volatile_register, 761 757 }; 762 758 763 759 static int wm8940_i2c_probe(struct i2c_client *i2c, ··· 785 753 if (wm8940 == NULL) 786 754 return -ENOMEM; 787 755 756 + wm8940->regmap = devm_regmap_init_i2c(i2c, &wm8940_regmap); 757 + if (IS_ERR(wm8940->regmap)) 758 + return PTR_ERR(wm8940->regmap); 759 + 788 760 i2c_set_clientdata(i2c, wm8940); 789 - wm8940->control_type = SND_SOC_I2C; 790 761 791 762 ret = snd_soc_register_codec(&i2c->dev, 792 763 &soc_codec_dev_wm8940, &wm8940_dai, 1);
+2 -2
sound/soc/codecs/wm8962.c
··· 74 74 struct regulator_bulk_data supplies[WM8962_NUM_SUPPLIES]; 75 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 78 struct input_dev *beep; 79 79 struct work_struct beep_work; 80 80 int beep_rate; ··· 3121 3121 } 3122 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 3125 static int beep_rates[] = { 3126 3126 500, 1000, 2000, 4000, 3127 3127 };
+33 -21
sound/soc/codecs/wm8974.c
··· 17 17 #include <linux/delay.h> 18 18 #include <linux/pm.h> 19 19 #include <linux/i2c.h> 20 + #include <linux/regmap.h> 20 21 #include <linux/slab.h> 21 22 #include <sound/core.h> 22 23 #include <sound/pcm.h> ··· 28 27 29 28 #include "wm8974.h" 30 29 31 - static const u16 wm8974_reg[WM8974_CACHEREGNUM] = { 32 - 0x0000, 0x0000, 0x0000, 0x0000, 33 - 0x0050, 0x0000, 0x0140, 0x0000, 34 - 0x0000, 0x0000, 0x0000, 0x00ff, 35 - 0x0000, 0x0000, 0x0100, 0x00ff, 36 - 0x0000, 0x0000, 0x012c, 0x002c, 37 - 0x002c, 0x002c, 0x002c, 0x0000, 38 - 0x0032, 0x0000, 0x0000, 0x0000, 39 - 0x0000, 0x0000, 0x0000, 0x0000, 40 - 0x0038, 0x000b, 0x0032, 0x0000, 41 - 0x0008, 0x000c, 0x0093, 0x00e9, 42 - 0x0000, 0x0000, 0x0000, 0x0000, 43 - 0x0003, 0x0010, 0x0000, 0x0000, 44 - 0x0000, 0x0002, 0x0000, 0x0000, 45 - 0x0000, 0x0000, 0x0039, 0x0000, 46 - 0x0000, 30 + static const struct reg_default wm8974_reg_defaults[] = { 31 + { 0, 0x0000 }, { 1, 0x0000 }, { 2, 0x0000 }, { 3, 0x0000 }, 32 + { 4, 0x0050 }, { 5, 0x0000 }, { 6, 0x0140 }, { 7, 0x0000 }, 33 + { 8, 0x0000 }, { 9, 0x0000 }, { 10, 0x0000 }, { 11, 0x00ff }, 34 + { 12, 0x0000 }, { 13, 0x0000 }, { 14, 0x0100 }, { 15, 0x00ff }, 35 + { 16, 0x0000 }, { 17, 0x0000 }, { 18, 0x012c }, { 19, 0x002c }, 36 + { 20, 0x002c }, { 21, 0x002c }, { 22, 0x002c }, { 23, 0x0000 }, 37 + { 24, 0x0032 }, { 25, 0x0000 }, { 26, 0x0000 }, { 27, 0x0000 }, 38 + { 28, 0x0000 }, { 29, 0x0000 }, { 30, 0x0000 }, { 31, 0x0000 }, 39 + { 32, 0x0038 }, { 33, 0x000b }, { 34, 0x0032 }, { 35, 0x0000 }, 40 + { 36, 0x0008 }, { 37, 0x000c }, { 38, 0x0093 }, { 39, 0x00e9 }, 41 + { 40, 0x0000 }, { 41, 0x0000 }, { 42, 0x0000 }, { 43, 0x0000 }, 42 + { 44, 0x0003 }, { 45, 0x0010 }, { 46, 0x0000 }, { 47, 0x0000 }, 43 + { 48, 0x0000 }, { 49, 0x0002 }, { 50, 0x0000 }, { 51, 0x0000 }, 44 + { 52, 0x0000 }, { 53, 0x0000 }, { 54, 0x0039 }, { 55, 0x0000 }, 45 + { 56, 0x0000 }, 47 46 }; 48 47 49 48 #define WM8974_POWER1_BIASEN 0x08 ··· 515 514 power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; 516 515 517 516 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 518 - snd_soc_cache_sync(codec); 517 + regcache_sync(dev_get_regmap(codec->dev, NULL)); 519 518 520 519 /* Initial cap charge at VMID 5k */ 521 520 snd_soc_write(codec, WM8974_POWER1, power1 | 0x3); ··· 580 579 return 0; 581 580 } 582 581 582 + static const struct regmap_config wm8974_regmap = { 583 + .reg_bits = 7, 584 + .val_bits = 9, 585 + 586 + .max_register = WM8974_MONOMIX, 587 + .reg_defaults = wm8974_reg_defaults, 588 + .num_reg_defaults = ARRAY_SIZE(wm8974_reg_defaults), 589 + }; 590 + 583 591 static int wm8974_probe(struct snd_soc_codec *codec) 584 592 { 585 593 int ret = 0; 586 594 587 - ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_I2C); 595 + ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP); 588 596 if (ret < 0) { 589 597 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 590 598 return ret; ··· 623 613 .suspend = wm8974_suspend, 624 614 .resume = wm8974_resume, 625 615 .set_bias_level = wm8974_set_bias_level, 626 - .reg_cache_size = ARRAY_SIZE(wm8974_reg), 627 - .reg_word_size = sizeof(u16), 628 - .reg_cache_default = wm8974_reg, 629 616 630 617 .controls = wm8974_snd_controls, 631 618 .num_controls = ARRAY_SIZE(wm8974_snd_controls), ··· 635 628 static int wm8974_i2c_probe(struct i2c_client *i2c, 636 629 const struct i2c_device_id *id) 637 630 { 631 + struct regmap *regmap; 638 632 int ret; 633 + 634 + regmap = devm_regmap_init_i2c(i2c, &wm8974_regmap); 635 + if (IS_ERR(regmap)) 636 + return PTR_ERR(regmap); 639 637 640 638 ret = snd_soc_register_codec(&i2c->dev, 641 639 &soc_codec_dev_wm8974, &wm8974_dai, 1);
+3 -3
sound/soc/codecs/wm8985.c
··· 1148 1148 }; 1149 1149 #endif 1150 1150 1151 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1151 + #if IS_ENABLED(CONFIG_I2C) 1152 1152 static int wm8985_i2c_probe(struct i2c_client *i2c, 1153 1153 const struct i2c_device_id *id) 1154 1154 { ··· 1201 1201 { 1202 1202 int ret = 0; 1203 1203 1204 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1204 + #if IS_ENABLED(CONFIG_I2C) 1205 1205 ret = i2c_add_driver(&wm8985_i2c_driver); 1206 1206 if (ret) { 1207 1207 printk(KERN_ERR "Failed to register wm8985 I2C driver: %d\n", ··· 1221 1221 1222 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 1225 i2c_del_driver(&wm8985_i2c_driver); 1226 1226 #endif 1227 1227 #if defined(CONFIG_SPI_MASTER)
+3 -3
sound/soc/codecs/wm8988.c
··· 912 912 }; 913 913 #endif /* CONFIG_SPI_MASTER */ 914 914 915 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 915 + #if IS_ENABLED(CONFIG_I2C) 916 916 static int wm8988_i2c_probe(struct i2c_client *i2c, 917 917 const struct i2c_device_id *id) 918 918 { ··· 964 964 static int __init wm8988_modinit(void) 965 965 { 966 966 int ret = 0; 967 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 967 + #if IS_ENABLED(CONFIG_I2C) 968 968 ret = i2c_add_driver(&wm8988_i2c_driver); 969 969 if (ret != 0) { 970 970 printk(KERN_ERR "Failed to register WM8988 I2C driver: %d\n", ··· 984 984 985 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 988 i2c_del_driver(&wm8988_i2c_driver); 989 989 #endif 990 990 #if defined(CONFIG_SPI_MASTER)
+105 -153
sound/soc/codecs/wm8990.c
··· 17 17 #include <linux/delay.h> 18 18 #include <linux/pm.h> 19 19 #include <linux/i2c.h> 20 + #include <linux/regmap.h> 20 21 #include <linux/slab.h> 21 22 #include <sound/core.h> 22 23 #include <sound/pcm.h> ··· 31 30 32 31 /* codec private data */ 33 32 struct wm8990_priv { 34 - enum snd_soc_control_type control_type; 33 + struct regmap *regmap; 35 34 unsigned int sysclk; 36 35 unsigned int pcmclk; 37 36 }; 38 37 39 - static int wm8990_volatile_register(struct snd_soc_codec *codec, 40 - unsigned int reg) 38 + static bool wm8990_volatile_register(struct device *dev, unsigned int reg) 41 39 { 42 40 switch (reg) { 43 41 case WM8990_RESET: ··· 46 46 } 47 47 } 48 48 49 - static const u16 wm8990_reg[] = { 50 - 0x8990, /* R0 - Reset */ 51 - 0x0000, /* R1 - Power Management (1) */ 52 - 0x6000, /* R2 - Power Management (2) */ 53 - 0x0000, /* R3 - Power Management (3) */ 54 - 0x4050, /* R4 - Audio Interface (1) */ 55 - 0x4000, /* R5 - Audio Interface (2) */ 56 - 0x01C8, /* R6 - Clocking (1) */ 57 - 0x0000, /* R7 - Clocking (2) */ 58 - 0x0040, /* R8 - Audio Interface (3) */ 59 - 0x0040, /* R9 - Audio Interface (4) */ 60 - 0x0004, /* R10 - DAC CTRL */ 61 - 0x00C0, /* R11 - Left DAC Digital Volume */ 62 - 0x00C0, /* R12 - Right DAC Digital Volume */ 63 - 0x0000, /* R13 - Digital Side Tone */ 64 - 0x0100, /* R14 - ADC CTRL */ 65 - 0x00C0, /* R15 - Left ADC Digital Volume */ 66 - 0x00C0, /* R16 - Right ADC Digital Volume */ 67 - 0x0000, /* R17 */ 68 - 0x0000, /* R18 - GPIO CTRL 1 */ 69 - 0x1000, /* R19 - GPIO1 & GPIO2 */ 70 - 0x1010, /* R20 - GPIO3 & GPIO4 */ 71 - 0x1010, /* R21 - GPIO5 & GPIO6 */ 72 - 0x8000, /* R22 - GPIOCTRL 2 */ 73 - 0x0800, /* R23 - GPIO_POL */ 74 - 0x008B, /* R24 - Left Line Input 1&2 Volume */ 75 - 0x008B, /* R25 - Left Line Input 3&4 Volume */ 76 - 0x008B, /* R26 - Right Line Input 1&2 Volume */ 77 - 0x008B, /* R27 - Right Line Input 3&4 Volume */ 78 - 0x0000, /* R28 - Left Output Volume */ 79 - 0x0000, /* R29 - Right Output Volume */ 80 - 0x0066, /* R30 - Line Outputs Volume */ 81 - 0x0022, /* R31 - Out3/4 Volume */ 82 - 0x0079, /* R32 - Left OPGA Volume */ 83 - 0x0079, /* R33 - Right OPGA Volume */ 84 - 0x0003, /* R34 - Speaker Volume */ 85 - 0x0003, /* R35 - ClassD1 */ 86 - 0x0000, /* R36 */ 87 - 0x0100, /* R37 - ClassD3 */ 88 - 0x0079, /* R38 - ClassD4 */ 89 - 0x0000, /* R39 - Input Mixer1 */ 90 - 0x0000, /* R40 - Input Mixer2 */ 91 - 0x0000, /* R41 - Input Mixer3 */ 92 - 0x0000, /* R42 - Input Mixer4 */ 93 - 0x0000, /* R43 - Input Mixer5 */ 94 - 0x0000, /* R44 - Input Mixer6 */ 95 - 0x0000, /* R45 - Output Mixer1 */ 96 - 0x0000, /* R46 - Output Mixer2 */ 97 - 0x0000, /* R47 - Output Mixer3 */ 98 - 0x0000, /* R48 - Output Mixer4 */ 99 - 0x0000, /* R49 - Output Mixer5 */ 100 - 0x0000, /* R50 - Output Mixer6 */ 101 - 0x0180, /* R51 - Out3/4 Mixer */ 102 - 0x0000, /* R52 - Line Mixer1 */ 103 - 0x0000, /* R53 - Line Mixer2 */ 104 - 0x0000, /* R54 - Speaker Mixer */ 105 - 0x0000, /* R55 - Additional Control */ 106 - 0x0000, /* R56 - AntiPOP1 */ 107 - 0x0000, /* R57 - AntiPOP2 */ 108 - 0x0000, /* R58 - MICBIAS */ 109 - 0x0000, /* R59 */ 110 - 0x0008, /* R60 - PLL1 */ 111 - 0x0031, /* R61 - PLL2 */ 112 - 0x0026, /* R62 - PLL3 */ 113 - 0x0000, /* R63 - Driver internal */ 49 + static const struct reg_default wm8990_reg_defaults[] = { 50 + { 1, 0x0000 }, /* R1 - Power Management (1) */ 51 + { 2, 0x6000 }, /* R2 - Power Management (2) */ 52 + { 3, 0x0000 }, /* R3 - Power Management (3) */ 53 + { 4, 0x4050 }, /* R4 - Audio Interface (1) */ 54 + { 5, 0x4000 }, /* R5 - Audio Interface (2) */ 55 + { 6, 0x01C8 }, /* R6 - Clocking (1) */ 56 + { 7, 0x0000 }, /* R7 - Clocking (2) */ 57 + { 8, 0x0040 }, /* R8 - Audio Interface (3) */ 58 + { 9, 0x0040 }, /* R9 - Audio Interface (4) */ 59 + { 10, 0x0004 }, /* R10 - DAC CTRL */ 60 + { 11, 0x00C0 }, /* R11 - Left DAC Digital Volume */ 61 + { 12, 0x00C0 }, /* R12 - Right DAC Digital Volume */ 62 + { 13, 0x0000 }, /* R13 - Digital Side Tone */ 63 + { 14, 0x0100 }, /* R14 - ADC CTRL */ 64 + { 15, 0x00C0 }, /* R15 - Left ADC Digital Volume */ 65 + { 16, 0x00C0 }, /* R16 - Right ADC Digital Volume */ 66 + 67 + { 18, 0x0000 }, /* R18 - GPIO CTRL 1 */ 68 + { 19, 0x1000 }, /* R19 - GPIO1 & GPIO2 */ 69 + { 20, 0x1010 }, /* R20 - GPIO3 & GPIO4 */ 70 + { 21, 0x1010 }, /* R21 - GPIO5 & GPIO6 */ 71 + { 22, 0x8000 }, /* R22 - GPIOCTRL 2 */ 72 + { 23, 0x0800 }, /* R23 - GPIO_POL */ 73 + { 24, 0x008B }, /* R24 - Left Line Input 1&2 Volume */ 74 + { 25, 0x008B }, /* R25 - Left Line Input 3&4 Volume */ 75 + { 26, 0x008B }, /* R26 - Right Line Input 1&2 Volume */ 76 + { 27, 0x008B }, /* R27 - Right Line Input 3&4 Volume */ 77 + { 28, 0x0000 }, /* R28 - Left Output Volume */ 78 + { 29, 0x0000 }, /* R29 - Right Output Volume */ 79 + { 30, 0x0066 }, /* R30 - Line Outputs Volume */ 80 + { 31, 0x0022 }, /* R31 - Out3/4 Volume */ 81 + { 32, 0x0079 }, /* R32 - Left OPGA Volume */ 82 + { 33, 0x0079 }, /* R33 - Right OPGA Volume */ 83 + { 34, 0x0003 }, /* R34 - Speaker Volume */ 84 + { 35, 0x0003 }, /* R35 - ClassD1 */ 85 + 86 + { 37, 0x0100 }, /* R37 - ClassD3 */ 87 + { 38, 0x0079 }, /* R38 - ClassD4 */ 88 + { 39, 0x0000 }, /* R39 - Input Mixer1 */ 89 + { 40, 0x0000 }, /* R40 - Input Mixer2 */ 90 + { 41, 0x0000 }, /* R41 - Input Mixer3 */ 91 + { 42, 0x0000 }, /* R42 - Input Mixer4 */ 92 + { 43, 0x0000 }, /* R43 - Input Mixer5 */ 93 + { 44, 0x0000 }, /* R44 - Input Mixer6 */ 94 + { 45, 0x0000 }, /* R45 - Output Mixer1 */ 95 + { 46, 0x0000 }, /* R46 - Output Mixer2 */ 96 + { 47, 0x0000 }, /* R47 - Output Mixer3 */ 97 + { 48, 0x0000 }, /* R48 - Output Mixer4 */ 98 + { 49, 0x0000 }, /* R49 - Output Mixer5 */ 99 + { 50, 0x0000 }, /* R50 - Output Mixer6 */ 100 + { 51, 0x0180 }, /* R51 - Out3/4 Mixer */ 101 + { 52, 0x0000 }, /* R52 - Line Mixer1 */ 102 + { 53, 0x0000 }, /* R53 - Line Mixer2 */ 103 + { 54, 0x0000 }, /* R54 - Speaker Mixer */ 104 + { 55, 0x0000 }, /* R55 - Additional Control */ 105 + { 56, 0x0000 }, /* R56 - AntiPOP1 */ 106 + { 57, 0x0000 }, /* R57 - AntiPOP2 */ 107 + { 58, 0x0000 }, /* R58 - MICBIAS */ 108 + 109 + { 60, 0x0008 }, /* R60 - PLL1 */ 110 + { 61, 0x0031 }, /* R61 - PLL2 */ 111 + { 62, 0x0026 }, /* R62 - PLL3 */ 114 112 }; 115 113 116 114 #define wm8990_reset(c) snd_soc_write(c, WM8990_RESET, 0) ··· 374 376 * _DAPM_ Controls 375 377 */ 376 378 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, WM8990_POWER_MANAGEMENT_2); 383 - fakepower = snd_soc_read(w->codec, WM8990_INTDRIVBITS); 384 - 385 - if (fakepower & ((1 << WM8990_INMIXL_PWR_BIT) | 386 - (1 << WM8990_AINLMUX_PWR_BIT))) { 387 - reg |= WM8990_AINL_ENA; 388 - } else { 389 - reg &= ~WM8990_AINL_ENA; 390 - } 391 - 392 - if (fakepower & ((1 << WM8990_INMIXR_PWR_BIT) | 393 - (1 << WM8990_AINRMUX_PWR_BIT))) { 394 - reg |= WM8990_AINR_ENA; 395 - } else { 396 - reg &= ~WM8990_AINR_ENA; 397 - } 398 - snd_soc_write(w->codec, WM8990_POWER_MANAGEMENT_2, reg); 399 - 400 - return 0; 401 - } 402 - 403 379 static int outmixer_event(struct snd_soc_dapm_widget *w, 404 380 struct snd_kcontrol *kcontrol, int event) 405 381 { ··· 628 656 SND_SOC_DAPM_INPUT("RIN2"), 629 657 SND_SOC_DAPM_INPUT("Internal ADC Source"), 630 658 659 + SND_SOC_DAPM_SUPPLY("INL", WM8990_POWER_MANAGEMENT_2, WM8990_AINL_ENA_BIT, 0, 660 + NULL, 0), 661 + SND_SOC_DAPM_SUPPLY("INR", WM8990_POWER_MANAGEMENT_2, WM8990_AINR_ENA_BIT, 0, 662 + NULL, 0), 663 + 631 664 /* DACs */ 632 665 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8990_POWER_MANAGEMENT_2, 633 666 WM8990_ADCL_ENA_BIT, 0), ··· 654 677 ARRAY_SIZE(wm8990_dapm_rin34_pga_controls)), 655 678 656 679 /* INMIXL */ 657 - SND_SOC_DAPM_MIXER_E("INMIXL", WM8990_INTDRIVBITS, WM8990_INMIXL_PWR_BIT, 0, 680 + SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0, 658 681 &wm8990_dapm_inmixl_controls[0], 659 - ARRAY_SIZE(wm8990_dapm_inmixl_controls), 660 - inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 682 + ARRAY_SIZE(wm8990_dapm_inmixl_controls)), 661 683 662 684 /* AINLMUX */ 663 - SND_SOC_DAPM_MUX_E("AINLMUX", WM8990_INTDRIVBITS, WM8990_AINLMUX_PWR_BIT, 0, 664 - &wm8990_dapm_ainlmux_controls, inmixer_event, 665 - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 685 + SND_SOC_DAPM_MUX("AINLMUX", SND_SOC_NOPM, 0, 0, &wm8990_dapm_ainlmux_controls), 666 686 667 687 /* INMIXR */ 668 - SND_SOC_DAPM_MIXER_E("INMIXR", WM8990_INTDRIVBITS, WM8990_INMIXR_PWR_BIT, 0, 688 + SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0, 669 689 &wm8990_dapm_inmixr_controls[0], 670 - ARRAY_SIZE(wm8990_dapm_inmixr_controls), 671 - inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 690 + ARRAY_SIZE(wm8990_dapm_inmixr_controls)), 672 691 673 692 /* AINRMUX */ 674 - SND_SOC_DAPM_MUX_E("AINRMUX", WM8990_INTDRIVBITS, WM8990_AINRMUX_PWR_BIT, 0, 675 - &wm8990_dapm_ainrmux_controls, inmixer_event, 676 - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 693 + SND_SOC_DAPM_MUX("AINRMUX", SND_SOC_NOPM, 0, 0, &wm8990_dapm_ainrmux_controls), 677 694 678 695 /* Output Side */ 679 696 /* DACs */ ··· 758 787 SND_SOC_DAPM_OUTPUT("Internal DAC Sink"), 759 788 }; 760 789 761 - static const struct snd_soc_dapm_route audio_map[] = { 790 + static const struct snd_soc_dapm_route wm8990_dapm_routes[] = { 762 791 /* Make DACs turn on when playing even if not mixed into any outputs */ 763 792 {"Internal DAC Sink", NULL, "Left DAC"}, 764 793 {"Internal DAC Sink", NULL, "Right DAC"}, ··· 766 795 /* Make ADCs turn on when recording even if not mixed from any inputs */ 767 796 {"Left ADC", NULL, "Internal ADC Source"}, 768 797 {"Right ADC", NULL, "Internal ADC Source"}, 798 + 799 + {"AINLMUX", NULL, "INL"}, 800 + {"INMIXL", NULL, "INL"}, 801 + {"AINRMUX", NULL, "INR"}, 802 + {"INMIXR", NULL, "INR"}, 769 803 770 804 /* Input Side */ 771 805 /* LIN12 PGA */ ··· 887 911 {"ROP", NULL, "ROPMIX"}, 888 912 {"RON", NULL, "RONMIX"}, 889 913 }; 890 - 891 - static int wm8990_add_widgets(struct snd_soc_codec *codec) 892 - { 893 - struct snd_soc_dapm_context *dapm = &codec->dapm; 894 - 895 - snd_soc_dapm_new_controls(dapm, wm8990_dapm_widgets, 896 - ARRAY_SIZE(wm8990_dapm_widgets)); 897 - /* set up the WM8990 audio map */ 898 - snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); 899 - 900 - return 0; 901 - } 902 914 903 915 /* PLL divisors */ 904 916 struct _pll_div { ··· 1112 1148 static int wm8990_set_bias_level(struct snd_soc_codec *codec, 1113 1149 enum snd_soc_bias_level level) 1114 1150 { 1151 + struct wm8990_priv *wm8990 = snd_soc_codec_get_drvdata(codec); 1115 1152 int ret; 1116 1153 1117 1154 switch (level) { ··· 1127 1162 1128 1163 case SND_SOC_BIAS_STANDBY: 1129 1164 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 1130 - ret = snd_soc_cache_sync(codec); 1165 + ret = regcache_sync(wm8990->regmap); 1131 1166 if (ret < 0) { 1132 1167 dev_err(codec->dev, "Failed to sync cache: %d\n", ret); 1133 1168 return ret; ··· 1225 1260 /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ 1226 1261 snd_soc_write(codec, WM8990_ANTIPOP2, 0x0); 1227 1262 1228 - codec->cache_sync = 1; 1263 + regcache_mark_dirty(wm8990->regmap); 1229 1264 break; 1230 1265 } 1231 1266 ··· 1294 1329 { 1295 1330 int ret; 1296 1331 1297 - ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); 1332 + ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); 1298 1333 if (ret < 0) { 1299 1334 printk(KERN_ERR "wm8990: failed to set cache I/O: %d\n", ret); 1300 1335 return ret; ··· 1317 1352 snd_soc_write(codec, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); 1318 1353 snd_soc_write(codec, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); 1319 1354 1320 - snd_soc_add_codec_controls(codec, wm8990_snd_controls, 1321 - ARRAY_SIZE(wm8990_snd_controls)); 1322 - wm8990_add_widgets(codec); 1323 - 1324 1355 return 0; 1325 1356 } 1326 1357 ··· 1333 1372 .suspend = wm8990_suspend, 1334 1373 .resume = wm8990_resume, 1335 1374 .set_bias_level = wm8990_set_bias_level, 1336 - .reg_cache_size = ARRAY_SIZE(wm8990_reg), 1337 - .reg_word_size = sizeof(u16), 1338 - .reg_cache_default = wm8990_reg, 1339 - .volatile_register = wm8990_volatile_register, 1375 + .controls = wm8990_snd_controls, 1376 + .num_controls = ARRAY_SIZE(wm8990_snd_controls), 1377 + .dapm_widgets = wm8990_dapm_widgets, 1378 + .num_dapm_widgets = ARRAY_SIZE(wm8990_dapm_widgets), 1379 + .dapm_routes = wm8990_dapm_routes, 1380 + .num_dapm_routes = ARRAY_SIZE(wm8990_dapm_routes), 1340 1381 }; 1341 1382 1342 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1383 + static const struct regmap_config wm8990_regmap = { 1384 + .reg_bits = 8, 1385 + .val_bits = 16, 1386 + 1387 + .max_register = WM8990_PLL3, 1388 + .volatile_reg = wm8990_volatile_register, 1389 + .reg_defaults = wm8990_reg_defaults, 1390 + .num_reg_defaults = ARRAY_SIZE(wm8990_reg_defaults), 1391 + .cache_type = REGCACHE_RBTREE, 1392 + }; 1393 + 1343 1394 static int wm8990_i2c_probe(struct i2c_client *i2c, 1344 1395 const struct i2c_device_id *id) 1345 1396 { ··· 1393 1420 .remove = wm8990_i2c_remove, 1394 1421 .id_table = wm8990_i2c_id, 1395 1422 }; 1396 - #endif 1397 1423 1398 - static int __init wm8990_modinit(void) 1399 - { 1400 - int ret = 0; 1401 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1402 - ret = i2c_add_driver(&wm8990_i2c_driver); 1403 - if (ret != 0) { 1404 - printk(KERN_ERR "Failed to register wm8990 I2C driver: %d\n", 1405 - ret); 1406 - } 1407 - #endif 1408 - return ret; 1409 - } 1410 - module_init(wm8990_modinit); 1411 - 1412 - static void __exit wm8990_exit(void) 1413 - { 1414 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 1415 - i2c_del_driver(&wm8990_i2c_driver); 1416 - #endif 1417 - } 1418 - module_exit(wm8990_exit); 1424 + module_i2c_driver(wm8990_i2c_driver); 1419 1425 1420 1426 MODULE_DESCRIPTION("ASoC WM8990 driver"); 1421 1427 MODULE_AUTHOR("Liam Girdwood");
-9
sound/soc/codecs/wm8990.h
··· 78 78 #define WM8990_PLL1 0x3C 79 79 #define WM8990_PLL2 0x3D 80 80 #define WM8990_PLL3 0x3E 81 - #define WM8990_INTDRIVBITS 0x3F 82 81 83 82 #define WM8990_EXT_ACCESS_ENA 0x75 84 83 #define WM8990_EXT_CTL1 0x7a ··· 816 817 * R62 (0x3E) - PLL3 817 818 */ 818 819 #define WM8990_PLLK2_MASK 0x00FF /* PLLK2 - [7:0] */ 819 - 820 - /* 821 - * R63 (0x3F) - Internal Driver Bits 822 - */ 823 - #define WM8990_INMIXL_PWR_BIT 0 824 - #define WM8990_AINLMUX_PWR_BIT 1 825 - #define WM8990_INMIXR_PWR_BIT 2 826 - #define WM8990_AINRMUX_PWR_BIT 3 827 820 828 821 #define WM8990_MCLK_DIV 0 829 822 #define WM8990_DACCLK_DIV 1
+153 -140
sound/soc/codecs/wm8991.c
··· 18 18 #include <linux/delay.h> 19 19 #include <linux/pm.h> 20 20 #include <linux/i2c.h> 21 + #include <linux/regmap.h> 21 22 #include <linux/slab.h> 22 23 #include <sound/core.h> 23 24 #include <sound/pcm.h> ··· 32 31 #include "wm8991.h" 33 32 34 33 struct wm8991_priv { 35 - enum snd_soc_control_type control_type; 34 + struct regmap *regmap; 36 35 unsigned int pcmclk; 37 36 }; 38 37 39 - static const u16 wm8991_reg_defs[] = { 40 - 0x8991, /* R0 - Reset */ 41 - 0x0000, /* R1 - Power Management (1) */ 42 - 0x6000, /* R2 - Power Management (2) */ 43 - 0x0000, /* R3 - Power Management (3) */ 44 - 0x4050, /* R4 - Audio Interface (1) */ 45 - 0x4000, /* R5 - Audio Interface (2) */ 46 - 0x01C8, /* R6 - Clocking (1) */ 47 - 0x0000, /* R7 - Clocking (2) */ 48 - 0x0040, /* R8 - Audio Interface (3) */ 49 - 0x0040, /* R9 - Audio Interface (4) */ 50 - 0x0004, /* R10 - DAC CTRL */ 51 - 0x00C0, /* R11 - Left DAC Digital Volume */ 52 - 0x00C0, /* R12 - Right DAC Digital Volume */ 53 - 0x0000, /* R13 - Digital Side Tone */ 54 - 0x0100, /* R14 - ADC CTRL */ 55 - 0x00C0, /* R15 - Left ADC Digital Volume */ 56 - 0x00C0, /* R16 - Right ADC Digital Volume */ 57 - 0x0000, /* R17 */ 58 - 0x0000, /* R18 - GPIO CTRL 1 */ 59 - 0x1000, /* R19 - GPIO1 & GPIO2 */ 60 - 0x1010, /* R20 - GPIO3 & GPIO4 */ 61 - 0x1010, /* R21 - GPIO5 & GPIO6 */ 62 - 0x8000, /* R22 - GPIOCTRL 2 */ 63 - 0x0800, /* R23 - GPIO_POL */ 64 - 0x008B, /* R24 - Left Line Input 1&2 Volume */ 65 - 0x008B, /* R25 - Left Line Input 3&4 Volume */ 66 - 0x008B, /* R26 - Right Line Input 1&2 Volume */ 67 - 0x008B, /* R27 - Right Line Input 3&4 Volume */ 68 - 0x0000, /* R28 - Left Output Volume */ 69 - 0x0000, /* R29 - Right Output Volume */ 70 - 0x0066, /* R30 - Line Outputs Volume */ 71 - 0x0022, /* R31 - Out3/4 Volume */ 72 - 0x0079, /* R32 - Left OPGA Volume */ 73 - 0x0079, /* R33 - Right OPGA Volume */ 74 - 0x0003, /* R34 - Speaker Volume */ 75 - 0x0003, /* R35 - ClassD1 */ 76 - 0x0000, /* R36 */ 77 - 0x0100, /* R37 - ClassD3 */ 78 - 0x0000, /* R38 */ 79 - 0x0000, /* R39 - Input Mixer1 */ 80 - 0x0000, /* R40 - Input Mixer2 */ 81 - 0x0000, /* R41 - Input Mixer3 */ 82 - 0x0000, /* R42 - Input Mixer4 */ 83 - 0x0000, /* R43 - Input Mixer5 */ 84 - 0x0000, /* R44 - Input Mixer6 */ 85 - 0x0000, /* R45 - Output Mixer1 */ 86 - 0x0000, /* R46 - Output Mixer2 */ 87 - 0x0000, /* R47 - Output Mixer3 */ 88 - 0x0000, /* R48 - Output Mixer4 */ 89 - 0x0000, /* R49 - Output Mixer5 */ 90 - 0x0000, /* R50 - Output Mixer6 */ 91 - 0x0180, /* R51 - Out3/4 Mixer */ 92 - 0x0000, /* R52 - Line Mixer1 */ 93 - 0x0000, /* R53 - Line Mixer2 */ 94 - 0x0000, /* R54 - Speaker Mixer */ 95 - 0x0000, /* R55 - Additional Control */ 96 - 0x0000, /* R56 - AntiPOP1 */ 97 - 0x0000, /* R57 - AntiPOP2 */ 98 - 0x0000, /* R58 - MICBIAS */ 99 - 0x0000, /* R59 */ 100 - 0x0008, /* R60 - PLL1 */ 101 - 0x0031, /* R61 - PLL2 */ 102 - 0x0026, /* R62 - PLL3 */ 38 + static const struct reg_default wm8991_reg_defaults[] = { 39 + { 1, 0x0000 }, /* R1 - Power Management (1) */ 40 + { 2, 0x6000 }, /* R2 - Power Management (2) */ 41 + { 3, 0x0000 }, /* R3 - Power Management (3) */ 42 + { 4, 0x4050 }, /* R4 - Audio Interface (1) */ 43 + { 5, 0x4000 }, /* R5 - Audio Interface (2) */ 44 + { 6, 0x01C8 }, /* R6 - Clocking (1) */ 45 + { 7, 0x0000 }, /* R7 - Clocking (2) */ 46 + { 8, 0x0040 }, /* R8 - Audio Interface (3) */ 47 + { 9, 0x0040 }, /* R9 - Audio Interface (4) */ 48 + { 10, 0x0004 }, /* R10 - DAC CTRL */ 49 + { 11, 0x00C0 }, /* R11 - Left DAC Digital Volume */ 50 + { 12, 0x00C0 }, /* R12 - Right DAC Digital Volume */ 51 + { 13, 0x0000 }, /* R13 - Digital Side Tone */ 52 + { 14, 0x0100 }, /* R14 - ADC CTRL */ 53 + { 15, 0x00C0 }, /* R15 - Left ADC Digital Volume */ 54 + { 16, 0x00C0 }, /* R16 - Right ADC Digital Volume */ 55 + 56 + { 18, 0x0000 }, /* R18 - GPIO CTRL 1 */ 57 + { 19, 0x1000 }, /* R19 - GPIO1 & GPIO2 */ 58 + { 20, 0x1010 }, /* R20 - GPIO3 & GPIO4 */ 59 + { 21, 0x1010 }, /* R21 - GPIO5 & GPIO6 */ 60 + { 22, 0x8000 }, /* R22 - GPIOCTRL 2 */ 61 + { 23, 0x0800 }, /* R23 - GPIO_POL */ 62 + { 24, 0x008B }, /* R24 - Left Line Input 1&2 Volume */ 63 + { 25, 0x008B }, /* R25 - Left Line Input 3&4 Volume */ 64 + { 26, 0x008B }, /* R26 - Right Line Input 1&2 Volume */ 65 + { 27, 0x008B }, /* R27 - Right Line Input 3&4 Volume */ 66 + { 28, 0x0000 }, /* R28 - Left Output Volume */ 67 + { 29, 0x0000 }, /* R29 - Right Output Volume */ 68 + { 30, 0x0066 }, /* R30 - Line Outputs Volume */ 69 + { 31, 0x0022 }, /* R31 - Out3/4 Volume */ 70 + { 32, 0x0079 }, /* R32 - Left OPGA Volume */ 71 + { 33, 0x0079 }, /* R33 - Right OPGA Volume */ 72 + { 34, 0x0003 }, /* R34 - Speaker Volume */ 73 + { 35, 0x0003 }, /* R35 - ClassD1 */ 74 + 75 + { 37, 0x0100 }, /* R37 - ClassD3 */ 76 + 77 + { 39, 0x0000 }, /* R39 - Input Mixer1 */ 78 + { 40, 0x0000 }, /* R40 - Input Mixer2 */ 79 + { 41, 0x0000 }, /* R41 - Input Mixer3 */ 80 + { 42, 0x0000 }, /* R42 - Input Mixer4 */ 81 + { 43, 0x0000 }, /* R43 - Input Mixer5 */ 82 + { 44, 0x0000 }, /* R44 - Input Mixer6 */ 83 + { 45, 0x0000 }, /* R45 - Output Mixer1 */ 84 + { 46, 0x0000 }, /* R46 - Output Mixer2 */ 85 + { 47, 0x0000 }, /* R47 - Output Mixer3 */ 86 + { 48, 0x0000 }, /* R48 - Output Mixer4 */ 87 + { 49, 0x0000 }, /* R49 - Output Mixer5 */ 88 + { 50, 0x0000 }, /* R50 - Output Mixer6 */ 89 + { 51, 0x0180 }, /* R51 - Out3/4 Mixer */ 90 + { 52, 0x0000 }, /* R52 - Line Mixer1 */ 91 + { 53, 0x0000 }, /* R53 - Line Mixer2 */ 92 + { 54, 0x0000 }, /* R54 - Speaker Mixer */ 93 + { 55, 0x0000 }, /* R55 - Additional Control */ 94 + { 56, 0x0000 }, /* R56 - AntiPOP1 */ 95 + { 57, 0x0000 }, /* R57 - AntiPOP2 */ 96 + { 58, 0x0000 }, /* R58 - MICBIAS */ 97 + 98 + { 60, 0x0008 }, /* R60 - PLL1 */ 99 + { 61, 0x0031 }, /* R61 - PLL2 */ 100 + { 62, 0x0026 }, /* R62 - PLL3 */ 103 101 }; 104 102 105 - #define wm8991_reset(c) snd_soc_write(c, WM8991_RESET, 0) 103 + static bool wm8991_volatile(struct device *dev, unsigned int reg) 104 + { 105 + switch (reg) { 106 + case WM8991_RESET: 107 + return true; 108 + default: 109 + return false; 110 + } 111 + } 106 112 107 113 static const unsigned int rec_mix_tlv[] = { 108 114 TLV_DB_RANGE_HEAD(1), ··· 382 374 /* 383 375 * _DAPM_ Controls 384 376 */ 385 - static int inmixer_event(struct snd_soc_dapm_widget *w, 386 - struct snd_kcontrol *kcontrol, int event) 387 - { 388 - u16 reg, fakepower; 389 - 390 - reg = snd_soc_read(w->codec, WM8991_POWER_MANAGEMENT_2); 391 - fakepower = snd_soc_read(w->codec, WM8991_INTDRIVBITS); 392 - 393 - if (fakepower & ((1 << WM8991_INMIXL_PWR_BIT) | 394 - (1 << WM8991_AINLMUX_PWR_BIT))) 395 - reg |= WM8991_AINL_ENA; 396 - else 397 - reg &= ~WM8991_AINL_ENA; 398 - 399 - if (fakepower & ((1 << WM8991_INMIXR_PWR_BIT) | 400 - (1 << WM8991_AINRMUX_PWR_BIT))) 401 - reg |= WM8991_AINR_ENA; 402 - else 403 - reg &= ~WM8991_AINR_ENA; 404 - 405 - snd_soc_write(w->codec, WM8991_POWER_MANAGEMENT_2, reg); 406 - return 0; 407 - } 408 - 409 377 static int outmixer_event(struct snd_soc_dapm_widget *w, 410 378 struct snd_kcontrol *kcontrol, int event) 411 379 { ··· 639 655 SND_SOC_DAPM_INPUT("RIN2"), 640 656 SND_SOC_DAPM_INPUT("Internal ADC Source"), 641 657 658 + SND_SOC_DAPM_SUPPLY("INL", WM8991_POWER_MANAGEMENT_2, 659 + WM8991_AINL_ENA_BIT, 0, NULL, 0), 660 + SND_SOC_DAPM_SUPPLY("INR", WM8991_POWER_MANAGEMENT_2, 661 + WM8991_AINR_ENA_BIT, 0, NULL, 0), 662 + 642 663 /* DACs */ 643 664 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8991_POWER_MANAGEMENT_2, 644 665 WM8991_ADCL_ENA_BIT, 0), ··· 665 676 ARRAY_SIZE(wm8991_dapm_rin34_pga_controls)), 666 677 667 678 /* INMIXL */ 668 - SND_SOC_DAPM_MIXER_E("INMIXL", WM8991_INTDRIVBITS, WM8991_INMIXL_PWR_BIT, 0, 679 + SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0, 669 680 &wm8991_dapm_inmixl_controls[0], 670 - ARRAY_SIZE(wm8991_dapm_inmixl_controls), 671 - inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 681 + ARRAY_SIZE(wm8991_dapm_inmixl_controls)), 672 682 673 683 /* AINLMUX */ 674 - SND_SOC_DAPM_MUX_E("AINLMUX", WM8991_INTDRIVBITS, WM8991_AINLMUX_PWR_BIT, 0, 675 - &wm8991_dapm_ainlmux_controls, inmixer_event, 676 - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 684 + SND_SOC_DAPM_MUX("AINLMUX", SND_SOC_NOPM, 0, 0, 685 + &wm8991_dapm_ainlmux_controls), 677 686 678 687 /* INMIXR */ 679 - SND_SOC_DAPM_MIXER_E("INMIXR", WM8991_INTDRIVBITS, WM8991_INMIXR_PWR_BIT, 0, 688 + SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0, 680 689 &wm8991_dapm_inmixr_controls[0], 681 - ARRAY_SIZE(wm8991_dapm_inmixr_controls), 682 - inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 690 + ARRAY_SIZE(wm8991_dapm_inmixr_controls)), 683 691 684 692 /* AINRMUX */ 685 - SND_SOC_DAPM_MUX_E("AINRMUX", WM8991_INTDRIVBITS, WM8991_AINRMUX_PWR_BIT, 0, 686 - &wm8991_dapm_ainrmux_controls, inmixer_event, 687 - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 693 + SND_SOC_DAPM_MUX("AINRMUX", SND_SOC_NOPM, 0, 0, 694 + &wm8991_dapm_ainrmux_controls), 688 695 689 696 /* Output Side */ 690 697 /* DACs */ ··· 772 787 SND_SOC_DAPM_OUTPUT("Internal DAC Sink"), 773 788 }; 774 789 775 - static const struct snd_soc_dapm_route audio_map[] = { 790 + static const struct snd_soc_dapm_route wm8991_dapm_routes[] = { 776 791 /* Make DACs turn on when playing even if not mixed into any outputs */ 777 792 {"Internal DAC Sink", NULL, "Left DAC"}, 778 793 {"Internal DAC Sink", NULL, "Right DAC"}, ··· 782 797 {"Right ADC", NULL, "Internal ADC Source"}, 783 798 784 799 /* Input Side */ 800 + {"INMIXL", NULL, "INL"}, 801 + {"AINLMUX", NULL, "INL"}, 802 + {"INMIXR", NULL, "INR"}, 803 + {"AINRMUX", NULL, "INR"}, 785 804 /* LIN12 PGA */ 786 805 {"LIN12 PGA", "LIN1 Switch", "LIN1"}, 787 806 {"LIN12 PGA", "LIN2 Switch", "LIN2"}, ··· 1118 1129 static int wm8991_set_bias_level(struct snd_soc_codec *codec, 1119 1130 enum snd_soc_bias_level level) 1120 1131 { 1132 + struct wm8991_priv *wm8991 = snd_soc_codec_get_drvdata(codec); 1121 1133 u16 val; 1122 1134 1123 1135 switch (level) { ··· 1134 1144 1135 1145 case SND_SOC_BIAS_STANDBY: 1136 1146 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 1137 - snd_soc_cache_sync(codec); 1147 + regcache_sync(wm8991->regmap); 1138 1148 /* Enable all output discharge bits */ 1139 1149 snd_soc_write(codec, WM8991_ANTIPOP1, WM8991_DIS_LLINE | 1140 1150 WM8991_DIS_RLINE | WM8991_DIS_OUT3 | ··· 1222 1232 1223 1233 /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ 1224 1234 snd_soc_write(codec, WM8991_ANTIPOP2, 0x0); 1225 - codec->cache_sync = 1; 1235 + regcache_mark_dirty(wm8991->regmap); 1226 1236 break; 1227 1237 } 1228 1238 ··· 1256 1266 1257 1267 wm8991 = snd_soc_codec_get_drvdata(codec); 1258 1268 1259 - ret = snd_soc_codec_set_cache_io(codec, 8, 16, wm8991->control_type); 1269 + ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); 1260 1270 if (ret < 0) { 1261 1271 dev_err(codec->dev, "Failed to set cache i/o: %d\n", ret); 1262 1272 return ret; 1263 1273 } 1264 1274 1265 - ret = wm8991_reset(codec); 1266 - if (ret < 0) { 1267 - dev_err(codec->dev, "Failed to issue reset\n"); 1268 - return ret; 1269 - } 1270 - 1271 1275 wm8991_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1272 1276 1273 - snd_soc_update_bits(codec, WM8991_AUDIO_INTERFACE_4, 1274 - WM8991_ALRCGPIO1, WM8991_ALRCGPIO1); 1275 - 1276 - snd_soc_update_bits(codec, WM8991_GPIO1_GPIO2, 1277 - WM8991_GPIO1_SEL_MASK, 1); 1278 - 1279 - snd_soc_update_bits(codec, WM8991_POWER_MANAGEMENT_1, 1280 - WM8991_VREF_ENA | WM8991_VMID_MODE_MASK, 1281 - WM8991_VREF_ENA | WM8991_VMID_MODE_MASK); 1282 - 1283 - snd_soc_update_bits(codec, WM8991_POWER_MANAGEMENT_2, 1284 - WM8991_OPCLK_ENA, WM8991_OPCLK_ENA); 1285 - 1286 - snd_soc_write(codec, WM8991_DAC_CTRL, 0); 1287 - snd_soc_write(codec, WM8991_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); 1288 - snd_soc_write(codec, WM8991_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); 1289 - 1290 - snd_soc_add_codec_controls(codec, wm8991_snd_controls, 1291 - ARRAY_SIZE(wm8991_snd_controls)); 1292 - 1293 - snd_soc_dapm_new_controls(&codec->dapm, wm8991_dapm_widgets, 1294 - ARRAY_SIZE(wm8991_dapm_widgets)); 1295 - snd_soc_dapm_add_routes(&codec->dapm, audio_map, 1296 - ARRAY_SIZE(audio_map)); 1297 1277 return 0; 1298 1278 } 1299 1279 ··· 1312 1352 .suspend = wm8991_suspend, 1313 1353 .resume = wm8991_resume, 1314 1354 .set_bias_level = wm8991_set_bias_level, 1315 - .reg_cache_size = WM8991_MAX_REGISTER + 1, 1316 - .reg_word_size = sizeof(u16), 1317 - .reg_cache_default = wm8991_reg_defs 1355 + .controls = wm8991_snd_controls, 1356 + .num_controls = ARRAY_SIZE(wm8991_snd_controls), 1357 + .dapm_widgets = wm8991_dapm_widgets, 1358 + .num_dapm_widgets = ARRAY_SIZE(wm8991_dapm_widgets), 1359 + .dapm_routes = wm8991_dapm_routes, 1360 + .num_dapm_routes = ARRAY_SIZE(wm8991_dapm_routes), 1361 + }; 1362 + 1363 + static const struct regmap_config wm8991_regmap = { 1364 + .reg_bits = 8, 1365 + .val_bits = 16, 1366 + 1367 + .max_register = WM8991_PLL3, 1368 + .volatile_reg = wm8991_volatile, 1369 + .reg_defaults = wm8991_reg_defaults, 1370 + .num_reg_defaults = ARRAY_SIZE(wm8991_reg_defaults), 1371 + .cache_type = REGCACHE_RBTREE, 1318 1372 }; 1319 1373 1320 1374 static int wm8991_i2c_probe(struct i2c_client *i2c, 1321 1375 const struct i2c_device_id *id) 1322 1376 { 1323 1377 struct wm8991_priv *wm8991; 1378 + unsigned int val; 1324 1379 int ret; 1325 1380 1326 1381 wm8991 = devm_kzalloc(&i2c->dev, sizeof(*wm8991), GFP_KERNEL); 1327 1382 if (!wm8991) 1328 1383 return -ENOMEM; 1329 1384 1330 - wm8991->control_type = SND_SOC_I2C; 1385 + wm8991->regmap = devm_regmap_init_i2c(i2c, &wm8991_regmap); 1386 + if (IS_ERR(wm8991->regmap)) 1387 + return PTR_ERR(wm8991->regmap); 1388 + 1331 1389 i2c_set_clientdata(i2c, wm8991); 1390 + 1391 + ret = regmap_read(wm8991->regmap, WM8991_RESET, &val); 1392 + if (ret != 0) { 1393 + dev_err(&i2c->dev, "Failed to read device ID: %d\n", ret); 1394 + return ret; 1395 + } 1396 + if (val != 0x8991) { 1397 + dev_err(&i2c->dev, "Device with ID %x is not a WM8991\n", val); 1398 + return -EINVAL; 1399 + } 1400 + 1401 + ret = regmap_write(wm8991->regmap, WM8991_RESET, 0); 1402 + if (ret < 0) { 1403 + dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); 1404 + return ret; 1405 + } 1406 + 1407 + regmap_update_bits(wm8991->regmap, WM8991_AUDIO_INTERFACE_4, 1408 + WM8991_ALRCGPIO1, WM8991_ALRCGPIO1); 1409 + 1410 + regmap_update_bits(wm8991->regmap, WM8991_GPIO1_GPIO2, 1411 + WM8991_GPIO1_SEL_MASK, 1); 1412 + 1413 + regmap_update_bits(wm8991->regmap, WM8991_POWER_MANAGEMENT_1, 1414 + WM8991_VREF_ENA | WM8991_VMID_MODE_MASK, 1415 + WM8991_VREF_ENA | WM8991_VMID_MODE_MASK); 1416 + 1417 + regmap_update_bits(wm8991->regmap, WM8991_POWER_MANAGEMENT_2, 1418 + WM8991_OPCLK_ENA, WM8991_OPCLK_ENA); 1419 + 1420 + regmap_write(wm8991->regmap, WM8991_DAC_CTRL, 0); 1421 + regmap_write(wm8991->regmap, WM8991_LEFT_OUTPUT_VOLUME, 1422 + 0x50 | (1<<8)); 1423 + regmap_write(wm8991->regmap, WM8991_RIGHT_OUTPUT_VOLUME, 1424 + 0x50 | (1<<8)); 1332 1425 1333 1426 ret = snd_soc_register_codec(&i2c->dev, 1334 1427 &soc_codec_dev_wm8991, &wm8991_dai, 1);
-9
sound/soc/codecs/wm8991.h
··· 76 76 #define WM8991_PLL1 0x3C 77 77 #define WM8991_PLL2 0x3D 78 78 #define WM8991_PLL3 0x3E 79 - #define WM8991_INTDRIVBITS 0x3F 80 79 81 80 #define WM8991_REGISTER_COUNT 60 82 81 #define WM8991_MAX_REGISTER 0x3F ··· 805 806 * R62 (0x3E) - PLL3 806 807 */ 807 808 #define WM8991_PLLK2_MASK 0x00FF /* PLLK2 - [7:0] */ 808 - 809 - /* 810 - * R63 (0x3F) - Internal Driver Bits 811 - */ 812 - #define WM8991_INMIXL_PWR_BIT 0 813 - #define WM8991_AINLMUX_PWR_BIT 1 814 - #define WM8991_INMIXR_PWR_BIT 2 815 - #define WM8991_AINRMUX_PWR_BIT 3 816 809 817 810 #define WM8991_MCLK_DIV 0 818 811 #define WM8991_DACCLK_DIV 1
+5 -6
sound/soc/codecs/wm8994.c
··· 4077 4077 wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, 4078 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 4080 switch (control->type) { 4087 4081 case WM8994: 4088 4082 if (wm8994->micdet_irq) { ··· 4307 4313 } 4308 4314 4309 4315 wm_hubs_add_analogue_routes(codec, 0, 0); 4316 + ret = wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, 4317 + wm_hubs_dcs_done, "DC servo done", 4318 + &wm8994->hubs); 4319 + if (ret == 0) 4320 + wm8994->hubs.dcs_done_irq = true; 4310 4321 snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon)); 4311 4322 4312 4323 switch (control->type) {
+3 -3
sound/soc/codecs/wm8995.c
··· 2293 2293 }; 2294 2294 #endif 2295 2295 2296 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 2296 + #if IS_ENABLED(CONFIG_I2C) 2297 2297 static int wm8995_i2c_probe(struct i2c_client *i2c, 2298 2298 const struct i2c_device_id *id) 2299 2299 { ··· 2350 2350 { 2351 2351 int ret = 0; 2352 2352 2353 - #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 2353 + #if IS_ENABLED(CONFIG_I2C) 2354 2354 ret = i2c_add_driver(&wm8995_i2c_driver); 2355 2355 if (ret) { 2356 2356 printk(KERN_ERR "Failed to register wm8995 I2C driver: %d\n", ··· 2371 2371 2372 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 2375 i2c_del_driver(&wm8995_i2c_driver); 2376 2376 #endif 2377 2377 #if defined(CONFIG_SPI_MASTER)
+2 -2
sound/soc/codecs/wm8997.c
··· 103 103 case SND_SOC_DAPM_POST_PMU: 104 104 if (patch) 105 105 for (i = 0; i < patch_size; i++) 106 - regmap_write(regmap, patch[i].reg, 107 - patch[i].def); 106 + regmap_write_async(regmap, patch[i].reg, 107 + patch[i].def); 108 108 break; 109 109 default: 110 110 break;
+1 -1
sound/soc/codecs/wm9081.c
··· 1326 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 1330 static int wm9081_i2c_probe(struct i2c_client *i2c, 1331 1331 const struct i2c_device_id *id) 1332 1332 {
+10 -10
sound/soc/codecs/wm_adsp.c
··· 1286 1286 reg = wm_adsp_region_to_reg(mem, 1287 1287 reg); 1288 1288 reg += offset; 1289 + break; 1289 1290 } 1290 1291 } 1291 1292 ··· 1469 1468 unsigned int val; 1470 1469 int ret, count; 1471 1470 1472 - ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, 1473 - ADSP2_SYS_ENA, ADSP2_SYS_ENA); 1471 + ret = regmap_update_bits_async(dsp->regmap, dsp->base + ADSP2_CONTROL, 1472 + ADSP2_SYS_ENA, ADSP2_SYS_ENA); 1474 1473 if (ret != 0) 1475 1474 return ret; 1476 1475 ··· 1493 1492 } 1494 1493 1495 1494 adsp_dbg(dsp, "RAM ready after %d polls\n", count); 1496 - adsp_info(dsp, "RAM ready after %d polls\n", count); 1497 1495 1498 1496 return 0; 1499 1497 } ··· 1525 1525 val = (val & ARIZONA_SYSCLK_FREQ_MASK) 1526 1526 >> ARIZONA_SYSCLK_FREQ_SHIFT; 1527 1527 1528 - ret = regmap_update_bits(dsp->regmap, 1529 - dsp->base + ADSP2_CLOCKING, 1530 - ADSP2_CLK_SEL_MASK, val); 1528 + ret = regmap_update_bits_async(dsp->regmap, 1529 + dsp->base + ADSP2_CLOCKING, 1530 + ADSP2_CLK_SEL_MASK, val); 1531 1531 if (ret != 0) { 1532 1532 adsp_err(dsp, "Failed to set clock rate: %d\n", 1533 1533 ret); ··· 1590 1590 if (ret != 0) 1591 1591 goto err; 1592 1592 1593 - ret = regmap_update_bits(dsp->regmap, 1594 - dsp->base + ADSP2_CONTROL, 1595 - ADSP2_CORE_ENA | ADSP2_START, 1596 - ADSP2_CORE_ENA | ADSP2_START); 1593 + ret = regmap_update_bits_async(dsp->regmap, 1594 + dsp->base + ADSP2_CONTROL, 1595 + ADSP2_CORE_ENA | ADSP2_START, 1596 + ADSP2_CORE_ENA | ADSP2_START); 1597 1597 if (ret != 0) 1598 1598 goto err; 1599 1599
+12 -17
sound/soc/davinci/Kconfig
··· 1 1 config SND_DAVINCI_SOC 2 - tristate "SoC Audio for the TI DAVINCI or AM33XX chip" 3 - depends on ARCH_DAVINCI || SOC_AM33XX 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. 2 + tristate "SoC Audio for TI DAVINCI or AM33XX/AM43XX chips" 3 + depends on ARCH_DAVINCI || SOC_AM33XX || SOC_AM43XX 9 4 10 5 config SND_DAVINCI_SOC_I2S 11 6 tristate ··· 11 16 config SND_DAVINCI_SOC_VCIF 12 17 tristate 13 18 19 + config SND_DAVINCI_SOC_GENERIC_EVM 20 + tristate 21 + select SND_SOC_TLV320AIC3X 22 + select SND_DAVINCI_SOC_MCASP 23 + 14 24 config SND_AM33XX_SOC_EVM 15 25 tristate "SoC Audio for the AM33XX chip based boards" 16 26 depends on SND_DAVINCI_SOC && SOC_AM33XX 17 - select SND_SOC_TLV320AIC3X 18 - select SND_DAVINCI_SOC_MCASP 27 + select SND_DAVINCI_SOC_GENERIC_EVM 19 28 help 20 29 Say Y or M if you want to add support for SoC audio on AM33XX 21 30 boards using McASP and TLV320AIC3X codec. For example AM335X-EVM, ··· 30 31 tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM" 31 32 depends on SND_DAVINCI_SOC 32 33 depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM 33 - select SND_DAVINCI_SOC_I2S 34 - select SND_SOC_TLV320AIC3X 34 + select SND_DAVINCI_SOC_GENERIC_EVM 35 35 help 36 36 Say Y if you want to add support for SoC audio on TI 37 37 DaVinci DM6446, DM355 or DM365 EVM platforms. ··· 57 59 config SND_DM6467_SOC_EVM 58 60 tristate "SoC Audio support for DaVinci DM6467 EVM" 59 61 depends on SND_DAVINCI_SOC && MACH_DAVINCI_DM6467_EVM 60 - select SND_DAVINCI_SOC_MCASP 61 - select SND_SOC_TLV320AIC3X 62 + select SND_DAVINCI_SOC_GENERIC_EVM 62 63 select SND_SOC_SPDIF 63 64 64 65 help ··· 66 69 config SND_DA830_SOC_EVM 67 70 tristate "SoC Audio support for DA830/OMAP-L137 EVM" 68 71 depends on SND_DAVINCI_SOC && MACH_DAVINCI_DA830_EVM 69 - select SND_DAVINCI_SOC_MCASP 70 - select SND_SOC_TLV320AIC3X 72 + select SND_DAVINCI_SOC_GENERIC_EVM 71 73 72 74 help 73 75 Say Y if you want to add support for SoC audio on TI ··· 75 79 config SND_DA850_SOC_EVM 76 80 tristate "SoC Audio support for DA850/OMAP-L138 EVM" 77 81 depends on SND_DAVINCI_SOC && MACH_DAVINCI_DA850_EVM 78 - select SND_DAVINCI_SOC_MCASP 79 - select SND_SOC_TLV320AIC3X 82 + select SND_DAVINCI_SOC_GENERIC_EVM 80 83 help 81 84 Say Y if you want to add support for SoC audio on TI 82 85 DA850/OMAP-L138 EVM
+2 -6
sound/soc/davinci/Makefile
··· 9 9 obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o 10 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 13 snd-soc-evm-objs := davinci-evm.o 14 14 15 - obj-$(CONFIG_SND_DAVINCI_SOC_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 15 + obj-$(CONFIG_SND_DAVINCI_SOC_GENERIC_EVM) += snd-soc-evm.o
+18 -30
sound/soc/davinci/davinci-evm.c
··· 28 28 29 29 #include "davinci-pcm.h" 30 30 #include "davinci-i2s.h" 31 - #include "davinci-mcasp.h" 32 31 33 32 struct snd_soc_card_drvdata_davinci { 34 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 36 static int evm_hw_params(struct snd_pcm_substream *substream, 40 37 struct snd_pcm_hw_params *params) 41 38 { ··· 44 47 int ret = 0; 45 48 unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *) 46 49 snd_soc_card_get_drvdata(soc_card))->sysclk; 47 - 48 - /* set codec DAI configuration */ 49 - ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT); 50 - if (ret < 0) 51 - return ret; 52 - 53 - /* set cpu DAI configuration */ 54 - ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT); 55 - if (ret < 0) 56 - return ret; 57 50 58 51 /* set the codec system clock */ 59 52 ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT); ··· 58 71 return 0; 59 72 } 60 73 61 - static int evm_spdif_hw_params(struct snd_pcm_substream *substream, 62 - struct snd_pcm_hw_params *params) 63 - { 64 - struct snd_soc_pcm_runtime *rtd = substream->private_data; 65 - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 66 - 67 - /* set cpu DAI configuration */ 68 - return snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT); 69 - } 70 - 71 74 static struct snd_soc_ops evm_ops = { 72 75 .hw_params = evm_hw_params, 73 - }; 74 - 75 - static struct snd_soc_ops evm_spdif_ops = { 76 - .hw_params = evm_spdif_hw_params, 77 76 }; 78 77 79 78 /* davinci-evm machine dapm widgets */ ··· 138 165 .platform_name = "davinci-mcbsp", 139 166 .init = evm_aic3x_init, 140 167 .ops = &evm_ops, 168 + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | 169 + SND_SOC_DAIFMT_IB_NF, 141 170 }; 142 171 143 172 static struct snd_soc_dai_link dm355_evm_dai = { ··· 151 176 .platform_name = "davinci-mcbsp.1", 152 177 .init = evm_aic3x_init, 153 178 .ops = &evm_ops, 179 + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | 180 + SND_SOC_DAIFMT_IB_NF, 154 181 }; 155 182 156 183 static struct snd_soc_dai_link dm365_evm_dai = { ··· 161 184 .stream_name = "AIC3X", 162 185 .cpu_dai_name = "davinci-mcbsp", 163 186 .codec_dai_name = "tlv320aic3x-hifi", 164 - .init = evm_aic3x_init, 165 187 .codec_name = "tlv320aic3x-codec.1-0018", 166 - .ops = &evm_ops, 167 188 .platform_name = "davinci-mcbsp", 189 + .init = evm_aic3x_init, 190 + .ops = &evm_ops, 191 + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | 192 + SND_SOC_DAIFMT_IB_NF, 168 193 #elif defined(CONFIG_SND_DM365_VOICE_CODEC) 169 194 .name = "Voice Codec - CQ93VC", 170 195 .stream_name = "CQ93", ··· 187 208 .codec_name = "tlv320aic3x-codec.0-001a", 188 209 .init = evm_aic3x_init, 189 210 .ops = &evm_ops, 211 + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | 212 + SND_SOC_DAIFMT_IB_NF, 190 213 }, 191 214 { 192 215 .name = "McASP", ··· 197 216 .codec_dai_name = "dit-hifi", 198 217 .codec_name = "spdif_dit", 199 218 .platform_name = "davinci-mcasp.1", 200 - .ops = &evm_spdif_ops, 219 + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | 220 + SND_SOC_DAIFMT_IB_NF, 201 221 }, 202 222 }; 203 223 ··· 211 229 .platform_name = "davinci-mcasp.1", 212 230 .init = evm_aic3x_init, 213 231 .ops = &evm_ops, 232 + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | 233 + SND_SOC_DAIFMT_IB_NF, 214 234 }; 215 235 216 236 static struct snd_soc_dai_link da850_evm_dai = { ··· 224 240 .platform_name = "davinci-mcasp.0", 225 241 .init = evm_aic3x_init, 226 242 .ops = &evm_ops, 243 + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | 244 + SND_SOC_DAIFMT_IB_NF, 227 245 }; 228 246 229 247 /* davinci dm6446 evm audio machine driver */ ··· 322 336 .codec_dai_name = "tlv320aic3x-hifi", 323 337 .ops = &evm_ops, 324 338 .init = evm_aic3x_init, 339 + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | 340 + SND_SOC_DAIFMT_IB_NF, 325 341 }; 326 342 327 343 static const struct of_device_id davinci_evm_dt_ids[] = {
+435 -581
sound/soc/davinci/davinci-mcasp.c
··· 21 21 #include <linux/slab.h> 22 22 #include <linux/delay.h> 23 23 #include <linux/io.h> 24 + #include <linux/clk.h> 24 25 #include <linux/pm_runtime.h> 25 26 #include <linux/of.h> 26 27 #include <linux/of_platform.h> ··· 32 31 #include <sound/pcm_params.h> 33 32 #include <sound/initval.h> 34 33 #include <sound/soc.h> 34 + #include <sound/dmaengine_pcm.h> 35 35 36 36 #include "davinci-pcm.h" 37 37 #include "davinci-mcasp.h" 38 38 39 - /* 40 - * McASP register definitions 41 - */ 42 - #define DAVINCI_MCASP_PID_REG 0x00 43 - #define DAVINCI_MCASP_PWREMUMGT_REG 0x04 39 + struct davinci_mcasp { 40 + struct davinci_pcm_dma_params dma_params[2]; 41 + struct snd_dmaengine_dai_dma_data dma_data[2]; 42 + void __iomem *base; 43 + u32 fifo_base; 44 + struct device *dev; 44 45 45 - #define DAVINCI_MCASP_PFUNC_REG 0x10 46 - #define DAVINCI_MCASP_PDIR_REG 0x14 47 - #define DAVINCI_MCASP_PDOUT_REG 0x18 48 - #define DAVINCI_MCASP_PDSET_REG 0x1c 46 + /* McASP specific data */ 47 + int tdm_slots; 48 + u8 op_mode; 49 + u8 num_serializer; 50 + u8 *serial_dir; 51 + u8 version; 52 + u16 bclk_lrclk_ratio; 53 + int streams; 49 54 50 - #define DAVINCI_MCASP_PDCLR_REG 0x20 55 + /* McASP FIFO related */ 56 + u8 txnumevt; 57 + u8 rxnumevt; 51 58 52 - #define DAVINCI_MCASP_TLGC_REG 0x30 53 - #define DAVINCI_MCASP_TLMR_REG 0x34 59 + bool dat_port; 54 60 55 - #define DAVINCI_MCASP_GBLCTL_REG 0x44 56 - #define DAVINCI_MCASP_AMUTE_REG 0x48 57 - #define DAVINCI_MCASP_LBCTL_REG 0x4c 61 + #ifdef CONFIG_PM_SLEEP 62 + struct { 63 + u32 txfmtctl; 64 + u32 rxfmtctl; 65 + u32 txfmt; 66 + u32 rxfmt; 67 + u32 aclkxctl; 68 + u32 aclkrctl; 69 + u32 pdir; 70 + } context; 71 + #endif 72 + }; 58 73 59 - #define DAVINCI_MCASP_TXDITCTL_REG 0x50 60 - 61 - #define DAVINCI_MCASP_GBLCTLR_REG 0x60 62 - #define DAVINCI_MCASP_RXMASK_REG 0x64 63 - #define DAVINCI_MCASP_RXFMT_REG 0x68 64 - #define DAVINCI_MCASP_RXFMCTL_REG 0x6c 65 - 66 - #define DAVINCI_MCASP_ACLKRCTL_REG 0x70 67 - #define DAVINCI_MCASP_AHCLKRCTL_REG 0x74 68 - #define DAVINCI_MCASP_RXTDM_REG 0x78 69 - #define DAVINCI_MCASP_EVTCTLR_REG 0x7c 70 - 71 - #define DAVINCI_MCASP_RXSTAT_REG 0x80 72 - #define DAVINCI_MCASP_RXTDMSLOT_REG 0x84 73 - #define DAVINCI_MCASP_RXCLKCHK_REG 0x88 74 - #define DAVINCI_MCASP_REVTCTL_REG 0x8c 75 - 76 - #define DAVINCI_MCASP_GBLCTLX_REG 0xa0 77 - #define DAVINCI_MCASP_TXMASK_REG 0xa4 78 - #define DAVINCI_MCASP_TXFMT_REG 0xa8 79 - #define DAVINCI_MCASP_TXFMCTL_REG 0xac 80 - 81 - #define DAVINCI_MCASP_ACLKXCTL_REG 0xb0 82 - #define DAVINCI_MCASP_AHCLKXCTL_REG 0xb4 83 - #define DAVINCI_MCASP_TXTDM_REG 0xb8 84 - #define DAVINCI_MCASP_EVTCTLX_REG 0xbc 85 - 86 - #define DAVINCI_MCASP_TXSTAT_REG 0xc0 87 - #define DAVINCI_MCASP_TXTDMSLOT_REG 0xc4 88 - #define DAVINCI_MCASP_TXCLKCHK_REG 0xc8 89 - #define DAVINCI_MCASP_XEVTCTL_REG 0xcc 90 - 91 - /* Left(even TDM Slot) Channel Status Register File */ 92 - #define DAVINCI_MCASP_DITCSRA_REG 0x100 93 - /* Right(odd TDM slot) Channel Status Register File */ 94 - #define DAVINCI_MCASP_DITCSRB_REG 0x118 95 - /* Left(even TDM slot) User Data Register File */ 96 - #define DAVINCI_MCASP_DITUDRA_REG 0x130 97 - /* Right(odd TDM Slot) User Data Register File */ 98 - #define DAVINCI_MCASP_DITUDRB_REG 0x148 99 - 100 - /* Serializer n Control Register */ 101 - #define DAVINCI_MCASP_XRSRCTL_BASE_REG 0x180 102 - #define DAVINCI_MCASP_XRSRCTL_REG(n) (DAVINCI_MCASP_XRSRCTL_BASE_REG + \ 103 - (n << 2)) 104 - 105 - /* Transmit Buffer for Serializer n */ 106 - #define DAVINCI_MCASP_TXBUF_REG 0x200 107 - /* Receive Buffer for Serializer n */ 108 - #define DAVINCI_MCASP_RXBUF_REG 0x280 109 - 110 - /* McASP FIFO Registers */ 111 - #define DAVINCI_MCASP_WFIFOCTL (0x1010) 112 - #define DAVINCI_MCASP_WFIFOSTS (0x1014) 113 - #define DAVINCI_MCASP_RFIFOCTL (0x1018) 114 - #define DAVINCI_MCASP_RFIFOSTS (0x101C) 115 - #define MCASP_VER3_WFIFOCTL (0x1000) 116 - #define MCASP_VER3_WFIFOSTS (0x1004) 117 - #define MCASP_VER3_RFIFOCTL (0x1008) 118 - #define MCASP_VER3_RFIFOSTS (0x100C) 119 - 120 - /* 121 - * DAVINCI_MCASP_PWREMUMGT_REG - Power Down and Emulation Management 122 - * Register Bits 123 - */ 124 - #define MCASP_FREE BIT(0) 125 - #define MCASP_SOFT BIT(1) 126 - 127 - /* 128 - * DAVINCI_MCASP_PFUNC_REG - Pin Function / GPIO Enable Register Bits 129 - */ 130 - #define AXR(n) (1<<n) 131 - #define PFUNC_AMUTE BIT(25) 132 - #define ACLKX BIT(26) 133 - #define AHCLKX BIT(27) 134 - #define AFSX BIT(28) 135 - #define ACLKR BIT(29) 136 - #define AHCLKR BIT(30) 137 - #define AFSR BIT(31) 138 - 139 - /* 140 - * DAVINCI_MCASP_PDIR_REG - Pin Direction Register Bits 141 - */ 142 - #define AXR(n) (1<<n) 143 - #define PDIR_AMUTE BIT(25) 144 - #define ACLKX BIT(26) 145 - #define AHCLKX BIT(27) 146 - #define AFSX BIT(28) 147 - #define ACLKR BIT(29) 148 - #define AHCLKR BIT(30) 149 - #define AFSR BIT(31) 150 - 151 - /* 152 - * DAVINCI_MCASP_TXDITCTL_REG - Transmit DIT Control Register Bits 153 - */ 154 - #define DITEN BIT(0) /* Transmit DIT mode enable/disable */ 155 - #define VA BIT(2) 156 - #define VB BIT(3) 157 - 158 - /* 159 - * DAVINCI_MCASP_TXFMT_REG - Transmit Bitstream Format Register Bits 160 - */ 161 - #define TXROT(val) (val) 162 - #define TXSEL BIT(3) 163 - #define TXSSZ(val) (val<<4) 164 - #define TXPBIT(val) (val<<8) 165 - #define TXPAD(val) (val<<13) 166 - #define TXORD BIT(15) 167 - #define FSXDLY(val) (val<<16) 168 - 169 - /* 170 - * DAVINCI_MCASP_RXFMT_REG - Receive Bitstream Format Register Bits 171 - */ 172 - #define RXROT(val) (val) 173 - #define RXSEL BIT(3) 174 - #define RXSSZ(val) (val<<4) 175 - #define RXPBIT(val) (val<<8) 176 - #define RXPAD(val) (val<<13) 177 - #define RXORD BIT(15) 178 - #define FSRDLY(val) (val<<16) 179 - 180 - /* 181 - * DAVINCI_MCASP_TXFMCTL_REG - Transmit Frame Control Register Bits 182 - */ 183 - #define FSXPOL BIT(0) 184 - #define AFSXE BIT(1) 185 - #define FSXDUR BIT(4) 186 - #define FSXMOD(val) (val<<7) 187 - 188 - /* 189 - * DAVINCI_MCASP_RXFMCTL_REG - Receive Frame Control Register Bits 190 - */ 191 - #define FSRPOL BIT(0) 192 - #define AFSRE BIT(1) 193 - #define FSRDUR BIT(4) 194 - #define FSRMOD(val) (val<<7) 195 - 196 - /* 197 - * DAVINCI_MCASP_ACLKXCTL_REG - Transmit Clock Control Register Bits 198 - */ 199 - #define ACLKXDIV(val) (val) 200 - #define ACLKXE BIT(5) 201 - #define TX_ASYNC BIT(6) 202 - #define ACLKXPOL BIT(7) 203 - #define ACLKXDIV_MASK 0x1f 204 - 205 - /* 206 - * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits 207 - */ 208 - #define ACLKRDIV(val) (val) 209 - #define ACLKRE BIT(5) 210 - #define RX_ASYNC BIT(6) 211 - #define ACLKRPOL BIT(7) 212 - #define ACLKRDIV_MASK 0x1f 213 - 214 - /* 215 - * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control 216 - * Register Bits 217 - */ 218 - #define AHCLKXDIV(val) (val) 219 - #define AHCLKXPOL BIT(14) 220 - #define AHCLKXE BIT(15) 221 - #define AHCLKXDIV_MASK 0xfff 222 - 223 - /* 224 - * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control 225 - * Register Bits 226 - */ 227 - #define AHCLKRDIV(val) (val) 228 - #define AHCLKRPOL BIT(14) 229 - #define AHCLKRE BIT(15) 230 - #define AHCLKRDIV_MASK 0xfff 231 - 232 - /* 233 - * DAVINCI_MCASP_XRSRCTL_BASE_REG - Serializer Control Register Bits 234 - */ 235 - #define MODE(val) (val) 236 - #define DISMOD (val)(val<<2) 237 - #define TXSTATE BIT(4) 238 - #define RXSTATE BIT(5) 239 - #define SRMOD_MASK 3 240 - #define SRMOD_INACTIVE 0 241 - 242 - /* 243 - * DAVINCI_MCASP_LBCTL_REG - Loop Back Control Register Bits 244 - */ 245 - #define LBEN BIT(0) 246 - #define LBORD BIT(1) 247 - #define LBGENMODE(val) (val<<2) 248 - 249 - /* 250 - * DAVINCI_MCASP_TXTDMSLOT_REG - Transmit TDM Slot Register configuration 251 - */ 252 - #define TXTDMS(n) (1<<n) 253 - 254 - /* 255 - * DAVINCI_MCASP_RXTDMSLOT_REG - Receive TDM Slot Register configuration 256 - */ 257 - #define RXTDMS(n) (1<<n) 258 - 259 - /* 260 - * DAVINCI_MCASP_GBLCTL_REG - Global Control Register Bits 261 - */ 262 - #define RXCLKRST BIT(0) /* Receiver Clock Divider Reset */ 263 - #define RXHCLKRST BIT(1) /* Receiver High Frequency Clock Divider */ 264 - #define RXSERCLR BIT(2) /* Receiver Serializer Clear */ 265 - #define RXSMRST BIT(3) /* Receiver State Machine Reset */ 266 - #define RXFSRST BIT(4) /* Frame Sync Generator Reset */ 267 - #define TXCLKRST BIT(8) /* Transmitter Clock Divider Reset */ 268 - #define TXHCLKRST BIT(9) /* Transmitter High Frequency Clock Divider*/ 269 - #define TXSERCLR BIT(10) /* Transmit Serializer Clear */ 270 - #define TXSMRST BIT(11) /* Transmitter State Machine Reset */ 271 - #define TXFSRST BIT(12) /* Frame Sync Generator Reset */ 272 - 273 - /* 274 - * DAVINCI_MCASP_AMUTE_REG - Mute Control Register Bits 275 - */ 276 - #define MUTENA(val) (val) 277 - #define MUTEINPOL BIT(2) 278 - #define MUTEINENA BIT(3) 279 - #define MUTEIN BIT(4) 280 - #define MUTER BIT(5) 281 - #define MUTEX BIT(6) 282 - #define MUTEFSR BIT(7) 283 - #define MUTEFSX BIT(8) 284 - #define MUTEBADCLKR BIT(9) 285 - #define MUTEBADCLKX BIT(10) 286 - #define MUTERXDMAERR BIT(11) 287 - #define MUTETXDMAERR BIT(12) 288 - 289 - /* 290 - * DAVINCI_MCASP_REVTCTL_REG - Receiver DMA Event Control Register bits 291 - */ 292 - #define RXDATADMADIS BIT(0) 293 - 294 - /* 295 - * DAVINCI_MCASP_XEVTCTL_REG - Transmitter DMA Event Control Register bits 296 - */ 297 - #define TXDATADMADIS BIT(0) 298 - 299 - /* 300 - * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits 301 - */ 302 - #define FIFO_ENABLE BIT(16) 303 - #define NUMEVT_MASK (0xFF << 8) 304 - #define NUMDMA_MASK (0xFF) 305 - 306 - #define DAVINCI_MCASP_NUM_SERIALIZER 16 307 - 308 - static inline void mcasp_set_bits(void __iomem *reg, u32 val) 74 + static inline void mcasp_set_bits(struct davinci_mcasp *mcasp, u32 offset, 75 + u32 val) 309 76 { 77 + void __iomem *reg = mcasp->base + offset; 310 78 __raw_writel(__raw_readl(reg) | val, reg); 311 79 } 312 80 313 - static inline void mcasp_clr_bits(void __iomem *reg, u32 val) 81 + static inline void mcasp_clr_bits(struct davinci_mcasp *mcasp, u32 offset, 82 + u32 val) 314 83 { 84 + void __iomem *reg = mcasp->base + offset; 315 85 __raw_writel((__raw_readl(reg) & ~(val)), reg); 316 86 } 317 87 318 - static inline void mcasp_mod_bits(void __iomem *reg, u32 val, u32 mask) 88 + static inline void mcasp_mod_bits(struct davinci_mcasp *mcasp, u32 offset, 89 + u32 val, u32 mask) 319 90 { 91 + void __iomem *reg = mcasp->base + offset; 320 92 __raw_writel((__raw_readl(reg) & ~mask) | val, reg); 321 93 } 322 94 323 - static inline void mcasp_set_reg(void __iomem *reg, u32 val) 95 + static inline void mcasp_set_reg(struct davinci_mcasp *mcasp, u32 offset, 96 + u32 val) 324 97 { 325 - __raw_writel(val, reg); 98 + __raw_writel(val, mcasp->base + offset); 326 99 } 327 100 328 - static inline u32 mcasp_get_reg(void __iomem *reg) 101 + static inline u32 mcasp_get_reg(struct davinci_mcasp *mcasp, u32 offset) 329 102 { 330 - return (unsigned int)__raw_readl(reg); 103 + return (u32)__raw_readl(mcasp->base + offset); 331 104 } 332 105 333 - static inline void mcasp_set_ctl_reg(void __iomem *regs, u32 val) 106 + static void mcasp_set_ctl_reg(struct davinci_mcasp *mcasp, u32 ctl_reg, u32 val) 334 107 { 335 108 int i = 0; 336 109 337 - mcasp_set_bits(regs, val); 110 + mcasp_set_bits(mcasp, ctl_reg, val); 338 111 339 112 /* programming GBLCTL needs to read back from GBLCTL and verfiy */ 340 113 /* loop count is to avoid the lock-up */ 341 114 for (i = 0; i < 1000; i++) { 342 - if ((mcasp_get_reg(regs) & val) == val) 115 + if ((mcasp_get_reg(mcasp, ctl_reg) & val) == val) 343 116 break; 344 117 } 345 118 346 - if (i == 1000 && ((mcasp_get_reg(regs) & val) != val)) 119 + if (i == 1000 && ((mcasp_get_reg(mcasp, ctl_reg) & val) != val)) 347 120 printk(KERN_ERR "GBLCTL write error\n"); 348 121 } 349 122 350 - static void mcasp_start_rx(struct davinci_audio_dev *dev) 123 + static bool mcasp_is_synchronous(struct davinci_mcasp *mcasp) 351 124 { 352 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXHCLKRST); 353 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXCLKRST); 354 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXSERCLR); 355 - mcasp_set_reg(dev->base + DAVINCI_MCASP_RXBUF_REG, 0); 125 + u32 rxfmctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG); 126 + u32 aclkxctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG); 356 127 357 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXSMRST); 358 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXFSRST); 359 - mcasp_set_reg(dev->base + DAVINCI_MCASP_RXBUF_REG, 0); 360 - 361 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXSMRST); 362 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXFSRST); 128 + return !(aclkxctl & TX_ASYNC) && rxfmctl & AFSRE; 363 129 } 364 130 365 - static void mcasp_start_tx(struct davinci_audio_dev *dev) 131 + static void mcasp_start_rx(struct davinci_mcasp *mcasp) 132 + { 133 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXHCLKRST); 134 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXCLKRST); 135 + 136 + /* 137 + * When ASYNC == 0 the transmit and receive sections operate 138 + * synchronously from the transmit clock and frame sync. We need to make 139 + * sure that the TX signlas are enabled when starting reception. 140 + */ 141 + if (mcasp_is_synchronous(mcasp)) { 142 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST); 143 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST); 144 + } 145 + 146 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXSERCLR); 147 + mcasp_set_reg(mcasp, DAVINCI_MCASP_RXBUF_REG, 0); 148 + 149 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXSMRST); 150 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXFSRST); 151 + mcasp_set_reg(mcasp, DAVINCI_MCASP_RXBUF_REG, 0); 152 + 153 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXSMRST); 154 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, RXFSRST); 155 + 156 + if (mcasp_is_synchronous(mcasp)) 157 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXFSRST); 158 + } 159 + 160 + static void mcasp_start_tx(struct davinci_mcasp *mcasp) 366 161 { 367 162 u8 offset = 0, i; 368 163 u32 cnt; 369 164 370 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST); 371 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST); 372 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXSERCLR); 373 - mcasp_set_reg(dev->base + DAVINCI_MCASP_TXBUF_REG, 0); 165 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST); 166 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST); 167 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXSERCLR); 168 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXBUF_REG, 0); 374 169 375 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXSMRST); 376 - mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXFSRST); 377 - mcasp_set_reg(dev->base + DAVINCI_MCASP_TXBUF_REG, 0); 378 - for (i = 0; i < dev->num_serializer; i++) { 379 - if (dev->serial_dir[i] == TX_MODE) { 170 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXSMRST); 171 + mcasp_set_ctl_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, TXFSRST); 172 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXBUF_REG, 0); 173 + for (i = 0; i < mcasp->num_serializer; i++) { 174 + if (mcasp->serial_dir[i] == TX_MODE) { 380 175 offset = i; 381 176 break; 382 177 } ··· 180 383 181 384 /* wait for TX ready */ 182 385 cnt = 0; 183 - while (!(mcasp_get_reg(dev->base + DAVINCI_MCASP_XRSRCTL_REG(offset)) & 386 + while (!(mcasp_get_reg(mcasp, DAVINCI_MCASP_XRSRCTL_REG(offset)) & 184 387 TXSTATE) && (cnt < 100000)) 185 388 cnt++; 186 389 187 - mcasp_set_reg(dev->base + DAVINCI_MCASP_TXBUF_REG, 0); 390 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXBUF_REG, 0); 188 391 } 189 392 190 - static void davinci_mcasp_start(struct davinci_audio_dev *dev, int stream) 393 + static void davinci_mcasp_start(struct davinci_mcasp *mcasp, int stream) 191 394 { 395 + u32 reg; 396 + 397 + mcasp->streams++; 398 + 192 399 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 193 - if (dev->txnumevt) { /* enable FIFO */ 194 - switch (dev->version) { 195 - case MCASP_VERSION_3: 196 - mcasp_clr_bits(dev->base + MCASP_VER3_WFIFOCTL, 197 - FIFO_ENABLE); 198 - mcasp_set_bits(dev->base + MCASP_VER3_WFIFOCTL, 199 - FIFO_ENABLE); 200 - break; 201 - default: 202 - mcasp_clr_bits(dev->base + 203 - DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE); 204 - mcasp_set_bits(dev->base + 205 - DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE); 206 - } 400 + if (mcasp->txnumevt) { /* enable FIFO */ 401 + reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET; 402 + mcasp_clr_bits(mcasp, reg, FIFO_ENABLE); 403 + mcasp_set_bits(mcasp, reg, FIFO_ENABLE); 207 404 } 208 - mcasp_start_tx(dev); 405 + mcasp_start_tx(mcasp); 209 406 } else { 210 - if (dev->rxnumevt) { /* enable FIFO */ 211 - switch (dev->version) { 212 - case MCASP_VERSION_3: 213 - mcasp_clr_bits(dev->base + MCASP_VER3_RFIFOCTL, 214 - FIFO_ENABLE); 215 - mcasp_set_bits(dev->base + MCASP_VER3_RFIFOCTL, 216 - FIFO_ENABLE); 217 - break; 218 - default: 219 - mcasp_clr_bits(dev->base + 220 - DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE); 221 - mcasp_set_bits(dev->base + 222 - DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE); 223 - } 407 + if (mcasp->rxnumevt) { /* enable FIFO */ 408 + reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET; 409 + mcasp_clr_bits(mcasp, reg, FIFO_ENABLE); 410 + mcasp_set_bits(mcasp, reg, FIFO_ENABLE); 224 411 } 225 - mcasp_start_rx(dev); 412 + mcasp_start_rx(mcasp); 226 413 } 227 414 } 228 415 229 - static void mcasp_stop_rx(struct davinci_audio_dev *dev) 416 + static void mcasp_stop_rx(struct davinci_mcasp *mcasp) 230 417 { 231 - mcasp_set_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, 0); 232 - mcasp_set_reg(dev->base + DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF); 418 + /* 419 + * In synchronous mode stop the TX clocks if no other stream is 420 + * running 421 + */ 422 + if (mcasp_is_synchronous(mcasp) && !mcasp->streams) 423 + mcasp_set_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, 0); 424 + 425 + mcasp_set_reg(mcasp, DAVINCI_MCASP_GBLCTLR_REG, 0); 426 + mcasp_set_reg(mcasp, DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF); 233 427 } 234 428 235 - static void mcasp_stop_tx(struct davinci_audio_dev *dev) 429 + static void mcasp_stop_tx(struct davinci_mcasp *mcasp) 236 430 { 237 - mcasp_set_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, 0); 238 - mcasp_set_reg(dev->base + DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF); 431 + u32 val = 0; 432 + 433 + /* 434 + * In synchronous mode keep TX clocks running if the capture stream is 435 + * still running. 436 + */ 437 + if (mcasp_is_synchronous(mcasp) && mcasp->streams) 438 + val = TXHCLKRST | TXCLKRST | TXFSRST; 439 + 440 + mcasp_set_reg(mcasp, DAVINCI_MCASP_GBLCTLX_REG, val); 441 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF); 239 442 } 240 443 241 - static void davinci_mcasp_stop(struct davinci_audio_dev *dev, int stream) 444 + static void davinci_mcasp_stop(struct davinci_mcasp *mcasp, int stream) 242 445 { 446 + u32 reg; 447 + 448 + mcasp->streams--; 449 + 243 450 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 244 - if (dev->txnumevt) { /* disable FIFO */ 245 - switch (dev->version) { 246 - case MCASP_VERSION_3: 247 - mcasp_clr_bits(dev->base + MCASP_VER3_WFIFOCTL, 248 - FIFO_ENABLE); 249 - break; 250 - default: 251 - mcasp_clr_bits(dev->base + 252 - DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE); 253 - } 451 + if (mcasp->txnumevt) { /* disable FIFO */ 452 + reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET; 453 + mcasp_clr_bits(mcasp, reg, FIFO_ENABLE); 254 454 } 255 - mcasp_stop_tx(dev); 455 + mcasp_stop_tx(mcasp); 256 456 } else { 257 - if (dev->rxnumevt) { /* disable FIFO */ 258 - switch (dev->version) { 259 - case MCASP_VERSION_3: 260 - mcasp_clr_bits(dev->base + MCASP_VER3_RFIFOCTL, 261 - FIFO_ENABLE); 262 - break; 263 - 264 - default: 265 - mcasp_clr_bits(dev->base + 266 - DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE); 267 - } 457 + if (mcasp->rxnumevt) { /* disable FIFO */ 458 + reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET; 459 + mcasp_clr_bits(mcasp, reg, FIFO_ENABLE); 268 460 } 269 - mcasp_stop_rx(dev); 461 + mcasp_stop_rx(mcasp); 270 462 } 271 463 } 272 464 273 465 static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, 274 466 unsigned int fmt) 275 467 { 276 - struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); 277 - void __iomem *base = dev->base; 468 + struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); 278 469 279 470 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 280 471 case SND_SOC_DAIFMT_DSP_B: 281 472 case SND_SOC_DAIFMT_AC97: 282 - mcasp_clr_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); 283 - mcasp_clr_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); 473 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); 474 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); 284 475 break; 285 476 default: 286 477 /* configure a full-word SYNC pulse (LRCLK) */ 287 - mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); 288 - mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); 478 + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); 479 + mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); 289 480 290 481 /* make 1st data bit occur one ACLK cycle after the frame sync */ 291 - mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, FSXDLY(1)); 292 - mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, FSRDLY(1)); 482 + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, FSXDLY(1)); 483 + mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, FSRDLY(1)); 293 484 break; 294 485 } 295 486 296 487 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 297 488 case SND_SOC_DAIFMT_CBS_CFS: 298 489 /* codec is clock and frame slave */ 299 - mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); 300 - mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE); 490 + mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); 491 + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, AFSXE); 301 492 302 - mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); 303 - mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); 493 + mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); 494 + mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, AFSRE); 304 495 305 - mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, 306 - ACLKX | ACLKR); 307 - mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, 308 - AFSX | AFSR); 496 + mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, ACLKX | ACLKR); 497 + mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AFSX | AFSR); 309 498 break; 310 499 case SND_SOC_DAIFMT_CBM_CFS: 311 500 /* codec is clock master and frame slave */ 312 - mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); 313 - mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE); 501 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); 502 + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, AFSXE); 314 503 315 - mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); 316 - mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); 504 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); 505 + mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, AFSRE); 317 506 318 - mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG, 319 - ACLKX | ACLKR); 320 - mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, 321 - AFSX | AFSR); 507 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, ACLKX | ACLKR); 508 + mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AFSX | AFSR); 322 509 break; 323 510 case SND_SOC_DAIFMT_CBM_CFM: 324 511 /* codec is clock and frame master */ 325 - mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); 326 - mcasp_clr_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE); 512 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); 513 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, AFSXE); 327 514 328 - mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); 329 - mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); 515 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); 516 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, AFSRE); 330 517 331 - mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG, 332 - ACLKX | AHCLKX | AFSX | ACLKR | AHCLKR | AFSR); 518 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, 519 + ACLKX | AHCLKX | AFSX | ACLKR | AHCLKR | AFSR); 333 520 break; 334 521 335 522 default: ··· 322 541 323 542 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 324 543 case SND_SOC_DAIFMT_IB_NF: 325 - mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 326 - mcasp_clr_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 544 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 545 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 327 546 328 - mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 329 - mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 547 + mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 548 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 330 549 break; 331 550 332 551 case SND_SOC_DAIFMT_NB_IF: 333 - mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 334 - mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 552 + mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 553 + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 335 554 336 - mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 337 - mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 555 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 556 + mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 338 557 break; 339 558 340 559 case SND_SOC_DAIFMT_IB_IF: 341 - mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 342 - mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 560 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 561 + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 343 562 344 - mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 345 - mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 563 + mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 564 + mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 346 565 break; 347 566 348 567 case SND_SOC_DAIFMT_NB_NF: 349 - mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 350 - mcasp_clr_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 568 + mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 569 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 351 570 352 - mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 353 - mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 571 + mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 572 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 354 573 break; 355 574 356 575 default: ··· 362 581 363 582 static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) 364 583 { 365 - struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai); 584 + struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); 366 585 367 586 switch (div_id) { 368 587 case 0: /* MCLK divider */ 369 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, 588 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, 370 589 AHCLKXDIV(div - 1), AHCLKXDIV_MASK); 371 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, 590 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, 372 591 AHCLKRDIV(div - 1), AHCLKRDIV_MASK); 373 592 break; 374 593 375 594 case 1: /* BCLK divider */ 376 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG, 595 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, 377 596 ACLKXDIV(div - 1), ACLKXDIV_MASK); 378 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_ACLKRCTL_REG, 597 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, 379 598 ACLKRDIV(div - 1), ACLKRDIV_MASK); 380 599 break; 381 600 382 601 case 2: /* BCLK/LRCLK ratio */ 383 - dev->bclk_lrclk_ratio = div; 602 + mcasp->bclk_lrclk_ratio = div; 384 603 break; 385 604 386 605 default: ··· 393 612 static int davinci_mcasp_set_sysclk(struct snd_soc_dai *dai, int clk_id, 394 613 unsigned int freq, int dir) 395 614 { 396 - struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai); 615 + struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); 397 616 398 617 if (dir == SND_SOC_CLOCK_OUT) { 399 - mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); 400 - mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); 401 - mcasp_set_bits(dev->base + DAVINCI_MCASP_PDIR_REG, AHCLKX); 618 + mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); 619 + mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); 620 + mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AHCLKX); 402 621 } else { 403 - mcasp_clr_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); 404 - mcasp_clr_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); 405 - mcasp_clr_bits(dev->base + DAVINCI_MCASP_PDIR_REG, AHCLKX); 622 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); 623 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); 624 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AHCLKX); 406 625 } 407 626 408 627 return 0; 409 628 } 410 629 411 - static int davinci_config_channel_size(struct davinci_audio_dev *dev, 630 + static int davinci_config_channel_size(struct davinci_mcasp *mcasp, 412 631 int word_length) 413 632 { 414 633 u32 fmt; ··· 425 644 * both left and right channels), so it has to be divided by number of 426 645 * tdm-slots (for I2S - divided by 2). 427 646 */ 428 - if (dev->bclk_lrclk_ratio) 429 - word_length = dev->bclk_lrclk_ratio / dev->tdm_slots; 647 + if (mcasp->bclk_lrclk_ratio) 648 + word_length = mcasp->bclk_lrclk_ratio / mcasp->tdm_slots; 430 649 431 650 /* mapping of the XSSZ bit-field as described in the datasheet */ 432 651 fmt = (word_length >> 1) - 1; 433 652 434 - if (dev->op_mode != DAVINCI_MCASP_DIT_MODE) { 435 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, 436 - RXSSZ(fmt), RXSSZ(0x0F)); 437 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, 438 - TXSSZ(fmt), TXSSZ(0x0F)); 439 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, 440 - TXROT(tx_rotate), TXROT(7)); 441 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, 442 - RXROT(rx_rotate), RXROT(7)); 443 - mcasp_set_reg(dev->base + DAVINCI_MCASP_RXMASK_REG, 444 - mask); 653 + if (mcasp->op_mode != DAVINCI_MCASP_DIT_MODE) { 654 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, RXSSZ(fmt), 655 + RXSSZ(0x0F)); 656 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, TXSSZ(fmt), 657 + TXSSZ(0x0F)); 658 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, TXROT(tx_rotate), 659 + TXROT(7)); 660 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, RXROT(rx_rotate), 661 + RXROT(7)); 662 + mcasp_set_reg(mcasp, DAVINCI_MCASP_RXMASK_REG, mask); 445 663 } 446 664 447 - mcasp_set_reg(dev->base + DAVINCI_MCASP_TXMASK_REG, mask); 665 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXMASK_REG, mask); 448 666 449 667 return 0; 450 668 } 451 669 452 - static int davinci_hw_common_param(struct davinci_audio_dev *dev, int stream, 670 + static int davinci_hw_common_param(struct davinci_mcasp *mcasp, int stream, 453 671 int channels) 454 672 { 455 673 int i; 456 674 u8 tx_ser = 0; 457 675 u8 rx_ser = 0; 458 676 u8 ser; 459 - u8 slots = dev->tdm_slots; 677 + u8 slots = mcasp->tdm_slots; 460 678 u8 max_active_serializers = (channels + slots - 1) / slots; 679 + u32 reg; 461 680 /* Default configuration */ 462 - mcasp_set_bits(dev->base + DAVINCI_MCASP_PWREMUMGT_REG, MCASP_SOFT); 681 + if (mcasp->version != MCASP_VERSION_4) 682 + mcasp_set_bits(mcasp, DAVINCI_MCASP_PWREMUMGT_REG, MCASP_SOFT); 463 683 464 684 /* All PINS as McASP */ 465 - mcasp_set_reg(dev->base + DAVINCI_MCASP_PFUNC_REG, 0x00000000); 685 + mcasp_set_reg(mcasp, DAVINCI_MCASP_PFUNC_REG, 0x00000000); 466 686 467 687 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 468 - mcasp_set_reg(dev->base + DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF); 469 - mcasp_clr_bits(dev->base + DAVINCI_MCASP_XEVTCTL_REG, 470 - TXDATADMADIS); 688 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF); 689 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_XEVTCTL_REG, TXDATADMADIS); 471 690 } else { 472 - mcasp_set_reg(dev->base + DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF); 473 - mcasp_clr_bits(dev->base + DAVINCI_MCASP_REVTCTL_REG, 474 - RXDATADMADIS); 691 + mcasp_set_reg(mcasp, DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF); 692 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_REVTCTL_REG, RXDATADMADIS); 475 693 } 476 694 477 - for (i = 0; i < dev->num_serializer; i++) { 478 - mcasp_set_bits(dev->base + DAVINCI_MCASP_XRSRCTL_REG(i), 479 - dev->serial_dir[i]); 480 - if (dev->serial_dir[i] == TX_MODE && 695 + for (i = 0; i < mcasp->num_serializer; i++) { 696 + mcasp_set_bits(mcasp, DAVINCI_MCASP_XRSRCTL_REG(i), 697 + mcasp->serial_dir[i]); 698 + if (mcasp->serial_dir[i] == TX_MODE && 481 699 tx_ser < max_active_serializers) { 482 - mcasp_set_bits(dev->base + DAVINCI_MCASP_PDIR_REG, 483 - AXR(i)); 700 + mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AXR(i)); 484 701 tx_ser++; 485 - } else if (dev->serial_dir[i] == RX_MODE && 702 + } else if (mcasp->serial_dir[i] == RX_MODE && 486 703 rx_ser < max_active_serializers) { 487 - mcasp_clr_bits(dev->base + DAVINCI_MCASP_PDIR_REG, 488 - AXR(i)); 704 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AXR(i)); 489 705 rx_ser++; 490 706 } else { 491 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_XRSRCTL_REG(i), 492 - SRMOD_INACTIVE, SRMOD_MASK); 707 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_XRSRCTL_REG(i), 708 + SRMOD_INACTIVE, SRMOD_MASK); 493 709 } 494 710 } 495 711 ··· 496 718 ser = rx_ser; 497 719 498 720 if (ser < max_active_serializers) { 499 - dev_warn(dev->dev, "stream has more channels (%d) than are " 721 + dev_warn(mcasp->dev, "stream has more channels (%d) than are " 500 722 "enabled in mcasp (%d)\n", channels, ser * slots); 501 723 return -EINVAL; 502 724 } 503 725 504 - if (dev->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) { 505 - if (dev->txnumevt * tx_ser > 64) 506 - dev->txnumevt = 1; 726 + if (mcasp->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) { 727 + if (mcasp->txnumevt * tx_ser > 64) 728 + mcasp->txnumevt = 1; 507 729 508 - switch (dev->version) { 509 - case MCASP_VERSION_3: 510 - mcasp_mod_bits(dev->base + MCASP_VER3_WFIFOCTL, tx_ser, 511 - NUMDMA_MASK); 512 - mcasp_mod_bits(dev->base + MCASP_VER3_WFIFOCTL, 513 - ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK); 514 - break; 515 - default: 516 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, 517 - tx_ser, NUMDMA_MASK); 518 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, 519 - ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK); 520 - } 730 + reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET; 731 + mcasp_mod_bits(mcasp, reg, tx_ser, NUMDMA_MASK); 732 + mcasp_mod_bits(mcasp, reg, ((mcasp->txnumevt * tx_ser) << 8), 733 + NUMEVT_MASK); 521 734 } 522 735 523 - if (dev->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) { 524 - if (dev->rxnumevt * rx_ser > 64) 525 - dev->rxnumevt = 1; 526 - switch (dev->version) { 527 - case MCASP_VERSION_3: 528 - mcasp_mod_bits(dev->base + MCASP_VER3_RFIFOCTL, rx_ser, 529 - NUMDMA_MASK); 530 - mcasp_mod_bits(dev->base + MCASP_VER3_RFIFOCTL, 531 - ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK); 532 - break; 533 - default: 534 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, 535 - rx_ser, NUMDMA_MASK); 536 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, 537 - ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK); 538 - } 736 + if (mcasp->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) { 737 + if (mcasp->rxnumevt * rx_ser > 64) 738 + mcasp->rxnumevt = 1; 739 + 740 + reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET; 741 + mcasp_mod_bits(mcasp, reg, rx_ser, NUMDMA_MASK); 742 + mcasp_mod_bits(mcasp, reg, ((mcasp->rxnumevt * rx_ser) << 8), 743 + NUMEVT_MASK); 539 744 } 540 745 541 746 return 0; 542 747 } 543 748 544 - static void davinci_hw_param(struct davinci_audio_dev *dev, int stream) 749 + static void davinci_hw_param(struct davinci_mcasp *mcasp, int stream) 545 750 { 546 751 int i, active_slots; 547 752 u32 mask = 0; 753 + u32 busel = 0; 548 754 549 - active_slots = (dev->tdm_slots > 31) ? 32 : dev->tdm_slots; 755 + active_slots = (mcasp->tdm_slots > 31) ? 32 : mcasp->tdm_slots; 550 756 for (i = 0; i < active_slots; i++) 551 757 mask |= (1 << i); 552 758 553 - mcasp_clr_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC); 759 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC); 760 + 761 + if (!mcasp->dat_port) 762 + busel = TXSEL; 554 763 555 764 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 556 765 /* bit stream is MSB first with no delay */ 557 766 /* DSP_B mode */ 558 - mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask); 559 - mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXORD); 767 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, mask); 768 + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, busel | TXORD); 560 769 561 - if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32)) 562 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, 563 - FSXMOD(dev->tdm_slots), FSXMOD(0x1FF)); 770 + if ((mcasp->tdm_slots >= 2) && (mcasp->tdm_slots <= 32)) 771 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, 772 + FSXMOD(mcasp->tdm_slots), FSXMOD(0x1FF)); 564 773 else 565 774 printk(KERN_ERR "playback tdm slot %d not supported\n", 566 - dev->tdm_slots); 775 + mcasp->tdm_slots); 567 776 } else { 568 777 /* bit stream is MSB first with no delay */ 569 778 /* DSP_B mode */ 570 - mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, RXORD); 571 - mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask); 779 + mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, busel | RXORD); 780 + mcasp_set_reg(mcasp, DAVINCI_MCASP_RXTDM_REG, mask); 572 781 573 - if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32)) 574 - mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, 575 - FSRMOD(dev->tdm_slots), FSRMOD(0x1FF)); 782 + if ((mcasp->tdm_slots >= 2) && (mcasp->tdm_slots <= 32)) 783 + mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, 784 + FSRMOD(mcasp->tdm_slots), FSRMOD(0x1FF)); 576 785 else 577 786 printk(KERN_ERR "capture tdm slot %d not supported\n", 578 - dev->tdm_slots); 787 + mcasp->tdm_slots); 579 788 } 580 789 } 581 790 582 791 /* S/PDIF */ 583 - static void davinci_hw_dit_param(struct davinci_audio_dev *dev) 792 + static void davinci_hw_dit_param(struct davinci_mcasp *mcasp) 584 793 { 585 794 /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 586 795 and LSB first */ 587 - mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, 588 - TXROT(6) | TXSSZ(15)); 796 + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, TXROT(6) | TXSSZ(15)); 589 797 590 798 /* Set TX frame synch : DIT Mode, 1 bit width, internal, rising edge */ 591 - mcasp_set_reg(dev->base + DAVINCI_MCASP_TXFMCTL_REG, 592 - AFSXE | FSXMOD(0x180)); 799 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG, AFSXE | FSXMOD(0x180)); 593 800 594 801 /* Set the TX tdm : for all the slots */ 595 - mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, 0xFFFFFFFF); 802 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, 0xFFFFFFFF); 596 803 597 804 /* Set the TX clock controls : div = 1 and internal */ 598 - mcasp_set_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG, 599 - ACLKXE | TX_ASYNC); 805 + mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE | TX_ASYNC); 600 806 601 - mcasp_clr_bits(dev->base + DAVINCI_MCASP_XEVTCTL_REG, TXDATADMADIS); 807 + mcasp_clr_bits(mcasp, DAVINCI_MCASP_XEVTCTL_REG, TXDATADMADIS); 602 808 603 809 /* Only 44100 and 48000 are valid, both have the same setting */ 604 - mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXDIV(3)); 810 + mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXDIV(3)); 605 811 606 812 /* Enable the DIT */ 607 - mcasp_set_bits(dev->base + DAVINCI_MCASP_TXDITCTL_REG, DITEN); 813 + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN); 608 814 } 609 815 610 816 static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, 611 817 struct snd_pcm_hw_params *params, 612 818 struct snd_soc_dai *cpu_dai) 613 819 { 614 - struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); 820 + struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); 615 821 struct davinci_pcm_dma_params *dma_params = 616 - &dev->dma_params[substream->stream]; 822 + &mcasp->dma_params[substream->stream]; 823 + struct snd_dmaengine_dai_dma_data *dma_data = 824 + &mcasp->dma_data[substream->stream]; 617 825 int word_length; 618 826 u8 fifo_level; 619 - u8 slots = dev->tdm_slots; 827 + u8 slots = mcasp->tdm_slots; 620 828 u8 active_serializers; 621 829 int channels; 622 830 struct snd_interval *pcm_channels = hw_param_interval(params, ··· 611 847 612 848 active_serializers = (channels + slots - 1) / slots; 613 849 614 - if (davinci_hw_common_param(dev, substream->stream, channels) == -EINVAL) 850 + if (davinci_hw_common_param(mcasp, substream->stream, channels) == -EINVAL) 615 851 return -EINVAL; 616 852 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 617 - fifo_level = dev->txnumevt * active_serializers; 853 + fifo_level = mcasp->txnumevt * active_serializers; 618 854 else 619 - fifo_level = dev->rxnumevt * active_serializers; 855 + fifo_level = mcasp->rxnumevt * active_serializers; 620 856 621 - if (dev->op_mode == DAVINCI_MCASP_DIT_MODE) 622 - davinci_hw_dit_param(dev); 857 + if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE) 858 + davinci_hw_dit_param(mcasp); 623 859 else 624 - davinci_hw_param(dev, substream->stream); 860 + davinci_hw_param(mcasp, substream->stream); 625 861 626 862 switch (params_format(params)) { 627 863 case SNDRV_PCM_FORMAT_U8: ··· 655 891 return -EINVAL; 656 892 } 657 893 658 - if (dev->version == MCASP_VERSION_2 && !fifo_level) 894 + if (mcasp->version == MCASP_VERSION_2 && !fifo_level) 659 895 dma_params->acnt = 4; 660 896 else 661 897 dma_params->acnt = dma_params->data_type; 662 898 663 899 dma_params->fifo_level = fifo_level; 664 - davinci_config_channel_size(dev, word_length); 900 + dma_data->maxburst = fifo_level; 901 + 902 + davinci_config_channel_size(mcasp, word_length); 665 903 666 904 return 0; 667 905 } ··· 671 905 static int davinci_mcasp_trigger(struct snd_pcm_substream *substream, 672 906 int cmd, struct snd_soc_dai *cpu_dai) 673 907 { 674 - struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); 908 + struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); 675 909 int ret = 0; 676 910 677 911 switch (cmd) { 678 912 case SNDRV_PCM_TRIGGER_RESUME: 679 913 case SNDRV_PCM_TRIGGER_START: 680 914 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 681 - ret = pm_runtime_get_sync(dev->dev); 915 + ret = pm_runtime_get_sync(mcasp->dev); 682 916 if (IS_ERR_VALUE(ret)) 683 - dev_err(dev->dev, "pm_runtime_get_sync() failed\n"); 684 - davinci_mcasp_start(dev, substream->stream); 917 + dev_err(mcasp->dev, "pm_runtime_get_sync() failed\n"); 918 + davinci_mcasp_start(mcasp, substream->stream); 685 919 break; 686 920 687 921 case SNDRV_PCM_TRIGGER_SUSPEND: 688 - davinci_mcasp_stop(dev, substream->stream); 689 - ret = pm_runtime_put_sync(dev->dev); 922 + davinci_mcasp_stop(mcasp, substream->stream); 923 + ret = pm_runtime_put_sync(mcasp->dev); 690 924 if (IS_ERR_VALUE(ret)) 691 - dev_err(dev->dev, "pm_runtime_put_sync() failed\n"); 925 + dev_err(mcasp->dev, "pm_runtime_put_sync() failed\n"); 692 926 break; 693 927 694 928 case SNDRV_PCM_TRIGGER_STOP: 695 929 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 696 - davinci_mcasp_stop(dev, substream->stream); 930 + davinci_mcasp_stop(mcasp, substream->stream); 697 931 break; 698 932 699 933 default: ··· 706 940 static int davinci_mcasp_startup(struct snd_pcm_substream *substream, 707 941 struct snd_soc_dai *dai) 708 942 { 709 - struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai); 943 + struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); 710 944 711 - snd_soc_dai_set_dma_data(dai, substream, dev->dma_params); 945 + if (mcasp->version == MCASP_VERSION_4) 946 + snd_soc_dai_set_dma_data(dai, substream, 947 + &mcasp->dma_data[substream->stream]); 948 + else 949 + snd_soc_dai_set_dma_data(dai, substream, mcasp->dma_params); 950 + 712 951 return 0; 713 952 } 714 953 ··· 725 954 .set_clkdiv = davinci_mcasp_set_clkdiv, 726 955 .set_sysclk = davinci_mcasp_set_sysclk, 727 956 }; 957 + 958 + #define DAVINCI_MCASP_RATES SNDRV_PCM_RATE_8000_192000 728 959 729 960 #define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \ 730 961 SNDRV_PCM_FMTBIT_U8 | \ ··· 758 985 759 986 }, 760 987 { 761 - "davinci-mcasp.1", 988 + .name = "davinci-mcasp.1", 762 989 .playback = { 763 990 .channels_min = 1, 764 991 .channels_max = 384, ··· 789 1016 .version = MCASP_VERSION_2, 790 1017 }; 791 1018 792 - static struct snd_platform_data omap2_mcasp_pdata = { 1019 + static struct snd_platform_data am33xx_mcasp_pdata = { 793 1020 .tx_dma_offset = 0, 794 1021 .rx_dma_offset = 0, 795 1022 .asp_chan_q = EVENTQ_0, 796 1023 .version = MCASP_VERSION_3, 1024 + }; 1025 + 1026 + static struct snd_platform_data dra7_mcasp_pdata = { 1027 + .tx_dma_offset = 0x200, 1028 + .rx_dma_offset = 0x284, 1029 + .asp_chan_q = EVENTQ_0, 1030 + .version = MCASP_VERSION_4, 797 1031 }; 798 1032 799 1033 static const struct of_device_id mcasp_dt_ids[] = { ··· 814 1034 }, 815 1035 { 816 1036 .compatible = "ti,am33xx-mcasp-audio", 817 - .data = &omap2_mcasp_pdata, 1037 + .data = &am33xx_mcasp_pdata, 1038 + }, 1039 + { 1040 + .compatible = "ti,dra7-mcasp-audio", 1041 + .data = &dra7_mcasp_pdata, 818 1042 }, 819 1043 { /* sentinel */ } 820 1044 }; 821 1045 MODULE_DEVICE_TABLE(of, mcasp_dt_ids); 1046 + 1047 + static int mcasp_reparent_fck(struct platform_device *pdev) 1048 + { 1049 + struct device_node *node = pdev->dev.of_node; 1050 + struct clk *gfclk, *parent_clk; 1051 + const char *parent_name; 1052 + int ret; 1053 + 1054 + if (!node) 1055 + return 0; 1056 + 1057 + parent_name = of_get_property(node, "fck_parent", NULL); 1058 + if (!parent_name) 1059 + return 0; 1060 + 1061 + gfclk = clk_get(&pdev->dev, "fck"); 1062 + if (IS_ERR(gfclk)) { 1063 + dev_err(&pdev->dev, "failed to get fck\n"); 1064 + return PTR_ERR(gfclk); 1065 + } 1066 + 1067 + parent_clk = clk_get(NULL, parent_name); 1068 + if (IS_ERR(parent_clk)) { 1069 + dev_err(&pdev->dev, "failed to get parent clock\n"); 1070 + ret = PTR_ERR(parent_clk); 1071 + goto err1; 1072 + } 1073 + 1074 + ret = clk_set_parent(gfclk, parent_clk); 1075 + if (ret) { 1076 + dev_err(&pdev->dev, "failed to reparent fck\n"); 1077 + goto err2; 1078 + } 1079 + 1080 + err2: 1081 + clk_put(parent_clk); 1082 + err1: 1083 + clk_put(gfclk); 1084 + return ret; 1085 + } 822 1086 823 1087 static struct snd_platform_data *davinci_mcasp_set_pdata_from_of( 824 1088 struct platform_device *pdev) ··· 976 1152 struct davinci_pcm_dma_params *dma_data; 977 1153 struct resource *mem, *ioarea, *res, *dat; 978 1154 struct snd_platform_data *pdata; 979 - struct davinci_audio_dev *dev; 1155 + struct davinci_mcasp *mcasp; 980 1156 int ret; 981 1157 982 1158 if (!pdev->dev.platform_data && !pdev->dev.of_node) { ··· 984 1160 return -EINVAL; 985 1161 } 986 1162 987 - dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_audio_dev), 1163 + mcasp = devm_kzalloc(&pdev->dev, sizeof(struct davinci_mcasp), 988 1164 GFP_KERNEL); 989 - if (!dev) 1165 + if (!mcasp) 990 1166 return -ENOMEM; 991 1167 992 1168 pdata = davinci_mcasp_set_pdata_from_of(pdev); ··· 997 1173 998 1174 mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); 999 1175 if (!mem) { 1000 - dev_warn(dev->dev, 1176 + dev_warn(mcasp->dev, 1001 1177 "\"mpu\" mem resource not found, using index 0\n"); 1002 1178 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1003 1179 if (!mem) { ··· 1021 1197 return ret; 1022 1198 } 1023 1199 1024 - dev->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); 1025 - if (!dev->base) { 1200 + mcasp->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); 1201 + if (!mcasp->base) { 1026 1202 dev_err(&pdev->dev, "ioremap failed\n"); 1027 1203 ret = -ENOMEM; 1028 1204 goto err_release_clk; 1029 1205 } 1030 1206 1031 - dev->op_mode = pdata->op_mode; 1032 - dev->tdm_slots = pdata->tdm_slots; 1033 - dev->num_serializer = pdata->num_serializer; 1034 - dev->serial_dir = pdata->serial_dir; 1035 - dev->version = pdata->version; 1036 - dev->txnumevt = pdata->txnumevt; 1037 - dev->rxnumevt = pdata->rxnumevt; 1038 - dev->dev = &pdev->dev; 1207 + mcasp->op_mode = pdata->op_mode; 1208 + mcasp->tdm_slots = pdata->tdm_slots; 1209 + mcasp->num_serializer = pdata->num_serializer; 1210 + mcasp->serial_dir = pdata->serial_dir; 1211 + mcasp->version = pdata->version; 1212 + mcasp->txnumevt = pdata->txnumevt; 1213 + mcasp->rxnumevt = pdata->rxnumevt; 1214 + 1215 + mcasp->dev = &pdev->dev; 1039 1216 1040 1217 dat = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat"); 1041 - if (!dat) 1042 - dat = mem; 1218 + if (dat) 1219 + mcasp->dat_port = true; 1043 1220 1044 - dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; 1221 + dma_data = &mcasp->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; 1045 1222 dma_data->asp_chan_q = pdata->asp_chan_q; 1046 1223 dma_data->ram_chan_q = pdata->ram_chan_q; 1047 1224 dma_data->sram_pool = pdata->sram_pool; 1048 1225 dma_data->sram_size = pdata->sram_size_playback; 1049 - dma_data->dma_addr = dat->start + pdata->tx_dma_offset; 1226 + if (dat) 1227 + dma_data->dma_addr = dat->start; 1228 + else 1229 + dma_data->dma_addr = mem->start + pdata->tx_dma_offset; 1230 + 1231 + /* Unconditional dmaengine stuff */ 1232 + mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr = dma_data->dma_addr; 1050 1233 1051 1234 res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 1052 1235 if (res) ··· 1061 1230 else 1062 1231 dma_data->channel = pdata->tx_dma_channel; 1063 1232 1064 - dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]; 1233 + dma_data = &mcasp->dma_params[SNDRV_PCM_STREAM_CAPTURE]; 1065 1234 dma_data->asp_chan_q = pdata->asp_chan_q; 1066 1235 dma_data->ram_chan_q = pdata->ram_chan_q; 1067 1236 dma_data->sram_pool = pdata->sram_pool; 1068 1237 dma_data->sram_size = pdata->sram_size_capture; 1069 - dma_data->dma_addr = dat->start + pdata->rx_dma_offset; 1238 + if (dat) 1239 + dma_data->dma_addr = dat->start; 1240 + else 1241 + dma_data->dma_addr = mem->start + pdata->rx_dma_offset; 1242 + 1243 + /* Unconditional dmaengine stuff */ 1244 + mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr = dma_data->dma_addr; 1245 + 1246 + if (mcasp->version < MCASP_VERSION_3) { 1247 + mcasp->fifo_base = DAVINCI_MCASP_V2_AFIFO_BASE; 1248 + /* dma_data->dma_addr is pointing to the data port address */ 1249 + mcasp->dat_port = true; 1250 + } else { 1251 + mcasp->fifo_base = DAVINCI_MCASP_V3_AFIFO_BASE; 1252 + } 1070 1253 1071 1254 res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 1072 1255 if (res) ··· 1088 1243 else 1089 1244 dma_data->channel = pdata->rx_dma_channel; 1090 1245 1091 - dev_set_drvdata(&pdev->dev, dev); 1246 + /* Unconditional dmaengine stuff */ 1247 + mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK].filter_data = "tx"; 1248 + mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE].filter_data = "rx"; 1249 + 1250 + dev_set_drvdata(&pdev->dev, mcasp); 1251 + 1252 + mcasp_reparent_fck(pdev); 1253 + 1092 1254 ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component, 1093 1255 &davinci_mcasp_dai[pdata->op_mode], 1); 1094 1256 1095 1257 if (ret != 0) 1096 1258 goto err_release_clk; 1097 1259 1098 - ret = davinci_soc_platform_register(&pdev->dev); 1099 - if (ret) { 1100 - dev_err(&pdev->dev, "register PCM failed: %d\n", ret); 1101 - goto err_unregister_component; 1260 + if (mcasp->version != MCASP_VERSION_4) { 1261 + ret = davinci_soc_platform_register(&pdev->dev); 1262 + if (ret) { 1263 + dev_err(&pdev->dev, "register PCM failed: %d\n", ret); 1264 + goto err_unregister_component; 1265 + } 1102 1266 } 1103 1267 1104 1268 return 0; ··· 1122 1268 1123 1269 static int davinci_mcasp_remove(struct platform_device *pdev) 1124 1270 { 1271 + struct davinci_mcasp *mcasp = dev_get_drvdata(&pdev->dev); 1125 1272 1126 1273 snd_soc_unregister_component(&pdev->dev); 1127 - davinci_soc_platform_unregister(&pdev->dev); 1274 + if (mcasp->version != MCASP_VERSION_4) 1275 + davinci_soc_platform_unregister(&pdev->dev); 1128 1276 1129 1277 pm_runtime_put_sync(&pdev->dev); 1130 1278 pm_runtime_disable(&pdev->dev); ··· 1137 1281 #ifdef CONFIG_PM_SLEEP 1138 1282 static int davinci_mcasp_suspend(struct device *dev) 1139 1283 { 1140 - struct davinci_audio_dev *a = dev_get_drvdata(dev); 1141 - void __iomem *base = a->base; 1284 + struct davinci_mcasp *mcasp = dev_get_drvdata(dev); 1142 1285 1143 - a->context.txfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_TXFMCTL_REG); 1144 - a->context.rxfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_RXFMCTL_REG); 1145 - a->context.txfmt = mcasp_get_reg(base + DAVINCI_MCASP_TXFMT_REG); 1146 - a->context.rxfmt = mcasp_get_reg(base + DAVINCI_MCASP_RXFMT_REG); 1147 - a->context.aclkxctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKXCTL_REG); 1148 - a->context.aclkrctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKRCTL_REG); 1149 - a->context.pdir = mcasp_get_reg(base + DAVINCI_MCASP_PDIR_REG); 1286 + mcasp->context.txfmtctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG); 1287 + mcasp->context.rxfmtctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG); 1288 + mcasp->context.txfmt = mcasp_get_reg(mcasp, DAVINCI_MCASP_TXFMT_REG); 1289 + mcasp->context.rxfmt = mcasp_get_reg(mcasp, DAVINCI_MCASP_RXFMT_REG); 1290 + mcasp->context.aclkxctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG); 1291 + mcasp->context.aclkrctl = mcasp_get_reg(mcasp, DAVINCI_MCASP_ACLKRCTL_REG); 1292 + mcasp->context.pdir = mcasp_get_reg(mcasp, DAVINCI_MCASP_PDIR_REG); 1150 1293 1151 1294 return 0; 1152 1295 } 1153 1296 1154 1297 static int davinci_mcasp_resume(struct device *dev) 1155 1298 { 1156 - struct davinci_audio_dev *a = dev_get_drvdata(dev); 1157 - void __iomem *base = a->base; 1299 + struct davinci_mcasp *mcasp = dev_get_drvdata(dev); 1158 1300 1159 - mcasp_set_reg(base + DAVINCI_MCASP_TXFMCTL_REG, a->context.txfmtctl); 1160 - mcasp_set_reg(base + DAVINCI_MCASP_RXFMCTL_REG, a->context.rxfmtctl); 1161 - mcasp_set_reg(base + DAVINCI_MCASP_TXFMT_REG, a->context.txfmt); 1162 - mcasp_set_reg(base + DAVINCI_MCASP_RXFMT_REG, a->context.rxfmt); 1163 - mcasp_set_reg(base + DAVINCI_MCASP_ACLKXCTL_REG, a->context.aclkxctl); 1164 - mcasp_set_reg(base + DAVINCI_MCASP_ACLKRCTL_REG, a->context.aclkrctl); 1165 - mcasp_set_reg(base + DAVINCI_MCASP_PDIR_REG, a->context.pdir); 1301 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXFMCTL_REG, mcasp->context.txfmtctl); 1302 + mcasp_set_reg(mcasp, DAVINCI_MCASP_RXFMCTL_REG, mcasp->context.rxfmtctl); 1303 + mcasp_set_reg(mcasp, DAVINCI_MCASP_TXFMT_REG, mcasp->context.txfmt); 1304 + mcasp_set_reg(mcasp, DAVINCI_MCASP_RXFMT_REG, mcasp->context.rxfmt); 1305 + mcasp_set_reg(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, mcasp->context.aclkxctl); 1306 + mcasp_set_reg(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, mcasp->context.aclkrctl); 1307 + mcasp_set_reg(mcasp, DAVINCI_MCASP_PDIR_REG, mcasp->context.pdir); 1166 1308 1167 1309 return 0; 1168 1310 }
+260 -32
sound/soc/davinci/davinci-mcasp.h
··· 18 18 #ifndef DAVINCI_MCASP_H 19 19 #define DAVINCI_MCASP_H 20 20 21 - #include <linux/io.h> 22 - #include <linux/platform_data/davinci_asp.h> 21 + /* 22 + * McASP register definitions 23 + */ 24 + #define DAVINCI_MCASP_PID_REG 0x00 25 + #define DAVINCI_MCASP_PWREMUMGT_REG 0x04 23 26 24 - #include "davinci-pcm.h" 27 + #define DAVINCI_MCASP_PFUNC_REG 0x10 28 + #define DAVINCI_MCASP_PDIR_REG 0x14 29 + #define DAVINCI_MCASP_PDOUT_REG 0x18 30 + #define DAVINCI_MCASP_PDSET_REG 0x1c 25 31 26 - #define DAVINCI_MCASP_RATES SNDRV_PCM_RATE_8000_192000 27 - #define DAVINCI_MCASP_I2S_DAI 0 28 - #define DAVINCI_MCASP_DIT_DAI 1 32 + #define DAVINCI_MCASP_PDCLR_REG 0x20 29 33 30 - struct davinci_audio_dev { 31 - struct davinci_pcm_dma_params dma_params[2]; 32 - void __iomem *base; 33 - struct device *dev; 34 + #define DAVINCI_MCASP_TLGC_REG 0x30 35 + #define DAVINCI_MCASP_TLMR_REG 0x34 34 36 35 - /* McASP specific data */ 36 - int tdm_slots; 37 - u8 op_mode; 38 - u8 num_serializer; 39 - u8 *serial_dir; 40 - u8 version; 41 - u16 bclk_lrclk_ratio; 37 + #define DAVINCI_MCASP_GBLCTL_REG 0x44 38 + #define DAVINCI_MCASP_AMUTE_REG 0x48 39 + #define DAVINCI_MCASP_LBCTL_REG 0x4c 42 40 43 - /* McASP FIFO related */ 44 - u8 txnumevt; 45 - u8 rxnumevt; 41 + #define DAVINCI_MCASP_TXDITCTL_REG 0x50 46 42 47 - #ifdef CONFIG_PM_SLEEP 48 - struct { 49 - u32 txfmtctl; 50 - u32 rxfmtctl; 51 - u32 txfmt; 52 - u32 rxfmt; 53 - u32 aclkxctl; 54 - u32 aclkrctl; 55 - u32 pdir; 56 - } context; 57 - #endif 58 - }; 43 + #define DAVINCI_MCASP_GBLCTLR_REG 0x60 44 + #define DAVINCI_MCASP_RXMASK_REG 0x64 45 + #define DAVINCI_MCASP_RXFMT_REG 0x68 46 + #define DAVINCI_MCASP_RXFMCTL_REG 0x6c 47 + 48 + #define DAVINCI_MCASP_ACLKRCTL_REG 0x70 49 + #define DAVINCI_MCASP_AHCLKRCTL_REG 0x74 50 + #define DAVINCI_MCASP_RXTDM_REG 0x78 51 + #define DAVINCI_MCASP_EVTCTLR_REG 0x7c 52 + 53 + #define DAVINCI_MCASP_RXSTAT_REG 0x80 54 + #define DAVINCI_MCASP_RXTDMSLOT_REG 0x84 55 + #define DAVINCI_MCASP_RXCLKCHK_REG 0x88 56 + #define DAVINCI_MCASP_REVTCTL_REG 0x8c 57 + 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 288 #endif /* DAVINCI_MCASP_H */
-28
sound/soc/davinci/davinci-pcm.c
··· 46 46 } 47 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 49 static struct snd_pcm_hardware pcm_hardware_playback = { 66 50 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | 67 51 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | 68 52 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME| 69 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 54 .buffer_bytes_max = 128 * 1024, 77 55 .period_bytes_min = 32, 78 56 .period_bytes_max = 8 * 1024, ··· 64 86 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | 65 87 SNDRV_PCM_INFO_PAUSE | 66 88 SNDRV_PCM_INFO_BATCH), 67 - .formats = DAVINCI_PCM_FMTBITS, 68 - .rates = SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT, 69 - .rate_min = 8000, 70 - .rate_max = 192000, 71 - .channels_min = 2, 72 - .channels_max = 384, 73 89 .buffer_bytes_max = 128 * 1024, 74 90 .period_bytes_min = 32, 75 91 .period_bytes_max = 8 * 1024,
+4
sound/soc/fsl/Kconfig
··· 1 + config SND_SOC_FSL_SAI 2 + tristate 3 + select SND_SOC_GENERIC_DMAENGINE_PCM 4 + 1 5 config SND_SOC_FSL_SSI 2 6 tristate 3 7
+3 -1
sound/soc/fsl/Makefile
··· 10 10 snd-soc-p1022-rdk-objs := p1022_rdk.o 11 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 15 snd-soc-fsl-ssi-objs := fsl_ssi.o 15 16 snd-soc-fsl-spdif-objs := fsl_spdif.o 16 17 snd-soc-fsl-utils-objs := fsl_utils.o 17 18 snd-soc-fsl-dma-objs := fsl_dma.o 19 + obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o 18 20 obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o 19 21 obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o 20 22 obj-$(CONFIG_SND_SOC_FSL_UTILS) += snd-soc-fsl-utils.o
+1 -1
sound/soc/fsl/fsl_dma.c
··· 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 857 * Although this DMA driver attempts to operate independently of the other 858 858 * devices, it still needs to determine some information about the SSI device
+460
sound/soc/fsl/fsl_sai.c
··· 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");
+114
sound/soc/fsl/fsl_sai.h
··· 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 */
-8
sound/soc/fsl/fsl_spdif.c
··· 1181 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 1184 static const struct of_device_id fsl_spdif_dt_ids[] = { 1192 1185 { .compatible = "fsl,imx35-spdif", }, 1193 1186 {} ··· 1194 1201 .of_match_table = fsl_spdif_dt_ids, 1195 1202 }, 1196 1203 .probe = fsl_spdif_probe, 1197 - .remove = fsl_spdif_remove, 1198 1204 }; 1199 1205 1200 1206 module_platform_driver(fsl_spdif_driver);
+327 -108
sound/soc/fsl/fsl_ssi.c
··· 38 38 #include <linux/device.h> 39 39 #include <linux/delay.h> 40 40 #include <linux/slab.h> 41 + #include <linux/spinlock.h> 41 42 #include <linux/of_address.h> 42 43 #include <linux/of_irq.h> 43 44 #include <linux/of_platform.h> ··· 120 119 * @ssi: pointer to the SSI's registers 121 120 * @ssi_phys: physical address of the SSI registers 122 121 * @irq: IRQ of this SSI 123 - * @first_stream: pointer to the stream that was opened first 124 - * @second_stream: pointer to second stream 125 122 * @playback: the number of playback streams opened 126 123 * @capture: the number of capture streams opened 127 124 * @cpu_dai: the CPU DAI for this device ··· 131 132 struct ccsr_ssi __iomem *ssi; 132 133 dma_addr_t ssi_phys; 133 134 unsigned int irq; 134 - struct snd_pcm_substream *first_stream; 135 - struct snd_pcm_substream *second_stream; 136 135 unsigned int fifo_depth; 137 136 struct snd_soc_dai_driver cpu_dai_drv; 138 137 struct device_attribute dev_attr; ··· 140 143 bool ssi_on_imx; 141 144 bool imx_ac97; 142 145 bool use_dma; 146 + bool baudclk_locked; 147 + u8 i2s_mode; 148 + spinlock_t baudclk_lock; 149 + struct clk *baudclk; 143 150 struct clk *clk; 144 151 struct snd_dmaengine_dai_dma_data dma_params_tx; 145 152 struct snd_dmaengine_dai_dma_data dma_params_rx; ··· 322 321 return ret; 323 322 } 324 323 324 + static void fsl_ssi_setup_ac97(struct fsl_ssi_private *ssi_private) 325 + { 326 + struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 327 + 328 + /* 329 + * Setup the clock control register 330 + */ 331 + write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), 332 + &ssi->stccr); 333 + write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), 334 + &ssi->srccr); 335 + 336 + /* 337 + * Enable AC97 mode and startup the SSI 338 + */ 339 + write_ssi(CCSR_SSI_SACNT_AC97EN | CCSR_SSI_SACNT_FV, 340 + &ssi->sacnt); 341 + write_ssi(0xff, &ssi->saccdis); 342 + write_ssi(0x300, &ssi->saccen); 343 + 344 + /* 345 + * Enable SSI, Transmit and Receive. AC97 has to communicate with the 346 + * codec before a stream is started. 347 + */ 348 + write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN | 349 + CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE); 350 + 351 + write_ssi(CCSR_SSI_SOR_WAIT(3), &ssi->sor); 352 + } 353 + 325 354 static int fsl_ssi_setup(struct fsl_ssi_private *ssi_private) 326 355 { 327 356 struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 328 - u8 i2s_mode; 329 357 u8 wm; 330 358 int synchronous = ssi_private->cpu_dai_drv.symmetric_rates; 331 359 332 360 if (ssi_private->imx_ac97) 333 - i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL | CCSR_SSI_SCR_NET; 361 + ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL | CCSR_SSI_SCR_NET; 334 362 else 335 - i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE; 363 + ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE; 336 364 337 365 /* 338 366 * Section 16.5 of the MPC8610 reference manual says that the SSI needs ··· 378 348 write_ssi_mask(&ssi->scr, 379 349 CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN, 380 350 CCSR_SSI_SCR_TFR_CLK_DIS | 381 - i2s_mode | 351 + ssi_private->i2s_mode | 382 352 (synchronous ? CCSR_SSI_SCR_SYN : 0)); 383 353 384 354 write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 | ··· 417 387 * because it is also running without an active substream. Normally SSI 418 388 * is only enabled when there is a substream. 419 389 */ 420 - if (ssi_private->imx_ac97) { 421 - /* 422 - * Setup the clock control register 423 - */ 424 - write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), 425 - &ssi->stccr); 426 - write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13), 427 - &ssi->srccr); 428 - 429 - /* 430 - * Enable AC97 mode and startup the SSI 431 - */ 432 - write_ssi(CCSR_SSI_SACNT_AC97EN | CCSR_SSI_SACNT_FV, 433 - &ssi->sacnt); 434 - write_ssi(0xff, &ssi->saccdis); 435 - write_ssi(0x300, &ssi->saccen); 436 - 437 - /* 438 - * Enable SSI, Transmit and Receive 439 - */ 440 - write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN | 441 - CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE); 442 - 443 - write_ssi(CCSR_SSI_SOR_WAIT(3), &ssi->sor); 444 - } 390 + if (ssi_private->imx_ac97) 391 + fsl_ssi_setup_ac97(ssi_private); 445 392 446 393 return 0; 447 394 } ··· 438 431 struct snd_soc_pcm_runtime *rtd = substream->private_data; 439 432 struct fsl_ssi_private *ssi_private = 440 433 snd_soc_dai_get_drvdata(rtd->cpu_dai); 441 - int synchronous = ssi_private->cpu_dai_drv.symmetric_rates; 434 + unsigned long flags; 442 435 443 - /* 444 - * If this is the first stream opened, then request the IRQ 445 - * and initialize the SSI registers. 436 + /* First, we only do fsl_ssi_setup() when SSI is going to be active. 437 + * Second, fsl_ssi_setup was already called by ac97_init earlier if 438 + * the driver is in ac97 mode. 446 439 */ 447 - if (!ssi_private->first_stream) { 448 - ssi_private->first_stream = substream; 449 - 450 - /* 451 - * fsl_ssi_setup was already called by ac97_init earlier if 452 - * the driver is in ac97 mode. 453 - */ 454 - if (!ssi_private->imx_ac97) 455 - fsl_ssi_setup(ssi_private); 456 - } else { 457 - if (synchronous) { 458 - struct snd_pcm_runtime *first_runtime = 459 - ssi_private->first_stream->runtime; 460 - /* 461 - * This is the second stream open, and we're in 462 - * synchronous mode, so we need to impose sample 463 - * sample size constraints. This is because STCCR is 464 - * used for playback and capture in synchronous mode, 465 - * so there's no way to specify different word 466 - * lengths. 467 - * 468 - * Note that this can cause a race condition if the 469 - * second stream is opened before the first stream is 470 - * fully initialized. We provide some protection by 471 - * checking to make sure the first stream is 472 - * initialized, but it's not perfect. ALSA sometimes 473 - * re-initializes the driver with a different sample 474 - * rate or size. If the second stream is opened 475 - * before the first stream has received its final 476 - * parameters, then the second stream may be 477 - * constrained to the wrong sample rate or size. 478 - */ 479 - if (first_runtime->sample_bits) { 480 - snd_pcm_hw_constraint_minmax(substream->runtime, 481 - SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 482 - first_runtime->sample_bits, 483 - first_runtime->sample_bits); 484 - } 485 - } 486 - 487 - ssi_private->second_stream = substream; 440 + if (!dai->active && !ssi_private->imx_ac97) { 441 + fsl_ssi_setup(ssi_private); 442 + spin_lock_irqsave(&ssi_private->baudclk_lock, flags); 443 + ssi_private->baudclk_locked = false; 444 + spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); 488 445 } 489 446 490 447 return 0; ··· 472 501 { 473 502 struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); 474 503 struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 504 + unsigned int channels = params_channels(hw_params); 475 505 unsigned int sample_size = 476 506 snd_pcm_format_width(params_format(hw_params)); 477 507 u32 wl = CCSR_SSI_SxCCR_WL(sample_size); ··· 502 530 else 503 531 write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl); 504 532 533 + if (!ssi_private->imx_ac97) 534 + write_ssi_mask(&ssi->scr, 535 + CCSR_SSI_SCR_NET | CCSR_SSI_SCR_I2S_MODE_MASK, 536 + channels == 1 ? 0 : ssi_private->i2s_mode); 537 + 538 + return 0; 539 + } 540 + 541 + /** 542 + * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format. 543 + */ 544 + static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) 545 + { 546 + struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); 547 + struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 548 + u32 strcr = 0, stcr, srcr, scr, mask; 549 + 550 + scr = read_ssi(&ssi->scr) & ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK); 551 + scr |= CCSR_SSI_SCR_NET; 552 + 553 + mask = CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR | 554 + CCSR_SSI_STCR_TSCKP | CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TFSL | 555 + CCSR_SSI_STCR_TEFS; 556 + stcr = read_ssi(&ssi->stcr) & ~mask; 557 + srcr = read_ssi(&ssi->srcr) & ~mask; 558 + 559 + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 560 + case SND_SOC_DAIFMT_I2S: 561 + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 562 + case SND_SOC_DAIFMT_CBS_CFS: 563 + ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_MASTER; 564 + break; 565 + case SND_SOC_DAIFMT_CBM_CFM: 566 + ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE; 567 + break; 568 + default: 569 + return -EINVAL; 570 + } 571 + scr |= ssi_private->i2s_mode; 572 + 573 + /* Data on rising edge of bclk, frame low, 1clk before data */ 574 + strcr |= CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TSCKP | 575 + CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TEFS; 576 + break; 577 + case SND_SOC_DAIFMT_LEFT_J: 578 + /* Data on rising edge of bclk, frame high */ 579 + strcr |= CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TSCKP; 580 + break; 581 + case SND_SOC_DAIFMT_DSP_A: 582 + /* Data on rising edge of bclk, frame high, 1clk before data */ 583 + strcr |= CCSR_SSI_STCR_TFSL | CCSR_SSI_STCR_TSCKP | 584 + CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TEFS; 585 + break; 586 + case SND_SOC_DAIFMT_DSP_B: 587 + /* Data on rising edge of bclk, frame high */ 588 + strcr |= CCSR_SSI_STCR_TFSL | CCSR_SSI_STCR_TSCKP | 589 + CCSR_SSI_STCR_TXBIT0; 590 + break; 591 + default: 592 + return -EINVAL; 593 + } 594 + 595 + /* DAI clock inversion */ 596 + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 597 + case SND_SOC_DAIFMT_NB_NF: 598 + /* Nothing to do for both normal cases */ 599 + break; 600 + case SND_SOC_DAIFMT_IB_NF: 601 + /* Invert bit clock */ 602 + strcr ^= CCSR_SSI_STCR_TSCKP; 603 + break; 604 + case SND_SOC_DAIFMT_NB_IF: 605 + /* Invert frame clock */ 606 + strcr ^= CCSR_SSI_STCR_TFSI; 607 + break; 608 + case SND_SOC_DAIFMT_IB_IF: 609 + /* Invert both clocks */ 610 + strcr ^= CCSR_SSI_STCR_TSCKP; 611 + strcr ^= CCSR_SSI_STCR_TFSI; 612 + break; 613 + default: 614 + return -EINVAL; 615 + } 616 + 617 + /* DAI clock master masks */ 618 + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 619 + case SND_SOC_DAIFMT_CBS_CFS: 620 + strcr |= CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR; 621 + scr |= CCSR_SSI_SCR_SYS_CLK_EN; 622 + break; 623 + case SND_SOC_DAIFMT_CBM_CFM: 624 + scr &= ~CCSR_SSI_SCR_SYS_CLK_EN; 625 + break; 626 + default: 627 + return -EINVAL; 628 + } 629 + 630 + stcr |= strcr; 631 + srcr |= strcr; 632 + 633 + if (ssi_private->cpu_dai_drv.symmetric_rates) { 634 + /* Need to clear RXDIR when using SYNC mode */ 635 + srcr &= ~CCSR_SSI_SRCR_RXDIR; 636 + scr |= CCSR_SSI_SCR_SYN; 637 + } 638 + 639 + write_ssi(stcr, &ssi->stcr); 640 + write_ssi(srcr, &ssi->srcr); 641 + write_ssi(scr, &ssi->scr); 642 + 643 + return 0; 644 + } 645 + 646 + /** 647 + * fsl_ssi_set_dai_sysclk - configure Digital Audio Interface bit clock 648 + * 649 + * Note: This function can be only called when using SSI as DAI master 650 + * 651 + * Quick instruction for parameters: 652 + * freq: Output BCLK frequency = samplerate * 32 (fixed) * channels 653 + * dir: SND_SOC_CLOCK_OUT -> TxBCLK, SND_SOC_CLOCK_IN -> RxBCLK. 654 + */ 655 + static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, 656 + int clk_id, unsigned int freq, int dir) 657 + { 658 + struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); 659 + struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 660 + int synchronous = ssi_private->cpu_dai_drv.symmetric_rates, ret; 661 + u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i; 662 + unsigned long flags, clkrate, baudrate, tmprate; 663 + u64 sub, savesub = 100000; 664 + 665 + /* Don't apply it to any non-baudclk circumstance */ 666 + if (IS_ERR(ssi_private->baudclk)) 667 + return -EINVAL; 668 + 669 + /* It should be already enough to divide clock by setting pm alone */ 670 + psr = 0; 671 + div2 = 0; 672 + 673 + factor = (div2 + 1) * (7 * psr + 1) * 2; 674 + 675 + for (i = 0; i < 255; i++) { 676 + /* The bclk rate must be smaller than 1/5 sysclk rate */ 677 + if (factor * (i + 1) < 5) 678 + continue; 679 + 680 + tmprate = freq * factor * (i + 2); 681 + clkrate = clk_round_rate(ssi_private->baudclk, tmprate); 682 + 683 + do_div(clkrate, factor); 684 + afreq = (u32)clkrate / (i + 1); 685 + 686 + if (freq == afreq) 687 + sub = 0; 688 + else if (freq / afreq == 1) 689 + sub = freq - afreq; 690 + else if (afreq / freq == 1) 691 + sub = afreq - freq; 692 + else 693 + continue; 694 + 695 + /* Calculate the fraction */ 696 + sub *= 100000; 697 + do_div(sub, freq); 698 + 699 + if (sub < savesub) { 700 + baudrate = tmprate; 701 + savesub = sub; 702 + pm = i; 703 + } 704 + 705 + /* We are lucky */ 706 + if (savesub == 0) 707 + break; 708 + } 709 + 710 + /* No proper pm found if it is still remaining the initial value */ 711 + if (pm == 999) { 712 + dev_err(cpu_dai->dev, "failed to handle the required sysclk\n"); 713 + return -EINVAL; 714 + } 715 + 716 + stccr = CCSR_SSI_SxCCR_PM(pm + 1) | (div2 ? CCSR_SSI_SxCCR_DIV2 : 0) | 717 + (psr ? CCSR_SSI_SxCCR_PSR : 0); 718 + mask = CCSR_SSI_SxCCR_PM_MASK | CCSR_SSI_SxCCR_DIV2 | CCSR_SSI_SxCCR_PSR; 719 + 720 + if (dir == SND_SOC_CLOCK_OUT || synchronous) 721 + write_ssi_mask(&ssi->stccr, mask, stccr); 722 + else 723 + write_ssi_mask(&ssi->srccr, mask, stccr); 724 + 725 + spin_lock_irqsave(&ssi_private->baudclk_lock, flags); 726 + if (!ssi_private->baudclk_locked) { 727 + ret = clk_set_rate(ssi_private->baudclk, baudrate); 728 + if (ret) { 729 + spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); 730 + dev_err(cpu_dai->dev, "failed to set baudclk rate\n"); 731 + return -EINVAL; 732 + } 733 + ssi_private->baudclk_locked = true; 734 + } 735 + spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); 736 + 737 + return 0; 738 + } 739 + 740 + /** 741 + * fsl_ssi_set_dai_tdm_slot - set TDM slot number 742 + * 743 + * Note: This function can be only called when using SSI as DAI master 744 + */ 745 + static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, 746 + u32 rx_mask, int slots, int slot_width) 747 + { 748 + struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); 749 + struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 750 + u32 val; 751 + 752 + /* The slot number should be >= 2 if using Network mode or I2S mode */ 753 + val = read_ssi(&ssi->scr) & (CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_NET); 754 + if (val && slots < 2) { 755 + dev_err(cpu_dai->dev, "slot number should be >= 2 in I2S or NET\n"); 756 + return -EINVAL; 757 + } 758 + 759 + write_ssi_mask(&ssi->stccr, CCSR_SSI_SxCCR_DC_MASK, 760 + CCSR_SSI_SxCCR_DC(slots)); 761 + write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_DC_MASK, 762 + CCSR_SSI_SxCCR_DC(slots)); 763 + 764 + /* The register SxMSKs needs SSI to provide essential clock due to 765 + * hardware design. So we here temporarily enable SSI to set them. 766 + */ 767 + val = read_ssi(&ssi->scr) & CCSR_SSI_SCR_SSIEN; 768 + write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN); 769 + 770 + write_ssi(tx_mask, &ssi->stmsk); 771 + write_ssi(rx_mask, &ssi->srmsk); 772 + 773 + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, val); 774 + 505 775 return 0; 506 776 } 507 777 ··· 763 549 struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai); 764 550 struct ccsr_ssi __iomem *ssi = ssi_private->ssi; 765 551 unsigned int sier_bits; 552 + unsigned long flags; 766 553 767 554 /* 768 555 * Enable only the interrupts and DMA requests ··· 804 589 write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_RE, 0); 805 590 806 591 if (!ssi_private->imx_ac97 && (read_ssi(&ssi->scr) & 807 - (CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE)) == 0) 592 + (CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE)) == 0) { 808 593 write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0); 594 + spin_lock_irqsave(&ssi_private->baudclk_lock, flags); 595 + ssi_private->baudclk_locked = false; 596 + spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); 597 + } 809 598 break; 810 599 811 600 default: ··· 819 600 write_ssi(sier_bits, &ssi->sier); 820 601 821 602 return 0; 822 - } 823 - 824 - /** 825 - * fsl_ssi_shutdown: shutdown the SSI 826 - * 827 - * Shutdown the SSI if there are no other substreams open. 828 - */ 829 - static void fsl_ssi_shutdown(struct snd_pcm_substream *substream, 830 - struct snd_soc_dai *dai) 831 - { 832 - struct snd_soc_pcm_runtime *rtd = substream->private_data; 833 - struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai); 834 - 835 - if (ssi_private->first_stream == substream) 836 - ssi_private->first_stream = ssi_private->second_stream; 837 - 838 - ssi_private->second_stream = NULL; 839 603 } 840 604 841 605 static int fsl_ssi_dai_probe(struct snd_soc_dai *dai) ··· 836 634 static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { 837 635 .startup = fsl_ssi_startup, 838 636 .hw_params = fsl_ssi_hw_params, 839 - .shutdown = fsl_ssi_shutdown, 637 + .set_fmt = fsl_ssi_set_dai_fmt, 638 + .set_sysclk = fsl_ssi_set_dai_sysclk, 639 + .set_tdm_slot = fsl_ssi_set_dai_tdm_slot, 840 640 .trigger = fsl_ssi_trigger, 841 641 }; 842 642 ··· 846 642 static struct snd_soc_dai_driver fsl_ssi_dai_template = { 847 643 .probe = fsl_ssi_dai_probe, 848 644 .playback = { 849 - /* The SSI does not support monaural audio. */ 850 - .channels_min = 2, 645 + .channels_min = 1, 851 646 .channels_max = 2, 852 647 .rates = FSLSSI_I2S_RATES, 853 648 .formats = FSLSSI_I2S_FORMATS, 854 649 }, 855 650 .capture = { 856 - .channels_min = 2, 651 + .channels_min = 1, 857 652 .channels_max = 2, 858 653 .rates = FSLSSI_I2S_RATES, 859 654 .formats = FSLSSI_I2S_FORMATS, ··· 913 710 914 711 static const struct snd_soc_dai_ops fsl_ssi_ac97_dai_ops = { 915 712 .startup = fsl_ssi_startup, 916 - .shutdown = fsl_ssi_shutdown, 917 713 .trigger = fsl_ssi_ac97_trigger, 918 714 }; 919 715 ··· 1137 935 } 1138 936 1139 937 /* Are the RX and the TX clocks locked? */ 1140 - if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) 938 + if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) { 1141 939 ssi_private->cpu_dai_drv.symmetric_rates = 1; 940 + ssi_private->cpu_dai_drv.symmetric_channels = 1; 941 + ssi_private->cpu_dai_drv.symmetric_samplebits = 1; 942 + } 1142 943 1143 944 /* Determine the FIFO depth. */ 1144 945 iprop = of_get_property(np, "fsl,fifo-depth", NULL); ··· 1150 945 else 1151 946 /* Older 8610 DTs didn't have the fifo-depth property */ 1152 947 ssi_private->fifo_depth = 8; 948 + 949 + ssi_private->baudclk_locked = false; 950 + spin_lock_init(&ssi_private->baudclk_lock); 1153 951 1154 952 if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx21-ssi")) { 1155 953 u32 dma_events[2]; ··· 1170 962 ret); 1171 963 goto error_irqmap; 1172 964 } 965 + 966 + /* For those SLAVE implementations, we ingore non-baudclk cases 967 + * and, instead, abandon MASTER mode that needs baud clock. 968 + */ 969 + ssi_private->baudclk = devm_clk_get(&pdev->dev, "baud"); 970 + if (IS_ERR(ssi_private->baudclk)) 971 + dev_warn(&pdev->dev, "could not get baud clock: %d\n", ret); 972 + else 973 + clk_prepare_enable(ssi_private->baudclk); 1173 974 1174 975 /* 1175 976 * We have burstsize be "fifo_depth - 2" to match the SSI ··· 1319 1102 return 0; 1320 1103 1321 1104 error_dai: 1322 - if (ssi_private->ssi_on_imx) 1323 - imx_pcm_dma_exit(pdev); 1324 1105 snd_soc_unregister_component(&pdev->dev); 1325 1106 1326 1107 error_dev: 1327 1108 device_remove_file(&pdev->dev, dev_attr); 1328 1109 1329 1110 error_clk: 1330 - if (ssi_private->ssi_on_imx) 1111 + if (ssi_private->ssi_on_imx) { 1112 + if (!IS_ERR(ssi_private->baudclk)) 1113 + clk_disable_unprepare(ssi_private->baudclk); 1331 1114 clk_disable_unprepare(ssi_private->clk); 1115 + } 1332 1116 1333 1117 error_irqmap: 1334 1118 irq_dispose_mapping(ssi_private->irq); ··· 1343 1125 1344 1126 if (!ssi_private->new_binding) 1345 1127 platform_device_unregister(ssi_private->pdev); 1346 - if (ssi_private->ssi_on_imx) 1347 - imx_pcm_dma_exit(pdev); 1348 1128 snd_soc_unregister_component(&pdev->dev); 1349 1129 device_remove_file(&pdev->dev, &ssi_private->dev_attr); 1350 - if (ssi_private->ssi_on_imx) 1130 + if (ssi_private->ssi_on_imx) { 1131 + if (!IS_ERR(ssi_private->baudclk)) 1132 + clk_disable_unprepare(ssi_private->baudclk); 1351 1133 clk_disable_unprepare(ssi_private->clk); 1134 + } 1352 1135 irq_dispose_mapping(ssi_private->irq); 1353 1136 1354 1137 return 0;
+2
sound/soc/fsl/fsl_ssi.h
··· 125 125 #define CCSR_SSI_SRCR_REFS 0x00000001 126 126 127 127 /* STCCR and SRCCR */ 128 + #define CCSR_SSI_SxCCR_DIV2_SHIFT 18 128 129 #define CCSR_SSI_SxCCR_DIV2 0x00040000 130 + #define CCSR_SSI_SxCCR_PSR_SHIFT 17 129 131 #define CCSR_SSI_SxCCR_PSR 0x00020000 130 132 #define CCSR_SSI_SxCCR_WL_SHIFT 13 131 133 #define CCSR_SSI_SxCCR_WL_MASK 0x0001E000
+2 -7
sound/soc/fsl/imx-pcm-dma.c
··· 61 61 62 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 66 SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | 66 67 SND_DMAENGINE_PCM_FLAG_COMPAT); 67 68 } 68 69 EXPORT_SYMBOL_GPL(imx_pcm_dma_init); 69 - 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 70 76 71 MODULE_LICENSE("GPL");
-5
sound/soc/fsl/imx-pcm.h
··· 40 40 41 41 #if IS_ENABLED(CONFIG_SND_SOC_IMX_PCM_DMA) 42 42 int imx_pcm_dma_init(struct platform_device *pdev); 43 - void imx_pcm_dma_exit(struct platform_device *pdev); 44 43 #else 45 44 static inline int imx_pcm_dma_init(struct platform_device *pdev) 46 45 { 47 46 return -ENODEV; 48 - } 49 - 50 - static inline void imx_pcm_dma_exit(struct platform_device *pdev) 51 - { 52 47 } 53 48 #endif 54 49
-1
sound/soc/fsl/imx-spdif.c
··· 33 33 34 34 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 35 35 if (!data) { 36 - dev_err(&pdev->dev, "failed to allocate memory\n"); 37 36 ret = -ENOMEM; 38 37 goto end; 39 38 }
+5 -7
sound/soc/fsl/imx-ssi.c
··· 304 304 scr |= SSI_SCR_RE; 305 305 sier |= sier_bits; 306 306 307 - if (++ssi->enabled == 1) 308 - scr |= SSI_SCR_SSIEN; 307 + scr |= SSI_SCR_SSIEN; 309 308 310 309 break; 311 310 ··· 317 318 scr &= ~SSI_SCR_RE; 318 319 sier &= ~sier_bits; 319 320 320 - if (--ssi->enabled == 0) 321 + if (!(scr & (SSI_SCR_TE | SSI_SCR_RE))) 321 322 scr &= ~SSI_SCR_SSIEN; 322 323 323 324 break; ··· 535 536 ret); 536 537 goto failed_clk; 537 538 } 538 - clk_prepare_enable(ssi->clk); 539 + ret = clk_prepare_enable(ssi->clk); 540 + if (ret) 541 + goto failed_clk; 539 542 540 543 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 541 544 ssi->base = devm_ioremap_resource(&pdev->dev, res); ··· 624 623 static int imx_ssi_remove(struct platform_device *pdev) 625 624 { 626 625 struct imx_ssi *ssi = platform_get_drvdata(pdev); 627 - 628 - if (!ssi->dma_init) 629 - imx_pcm_dma_exit(pdev); 630 626 631 627 if (!ssi->fiq_init) 632 628 imx_pcm_fiq_exit(pdev);
-1
sound/soc/fsl/imx-ssi.h
··· 213 213 214 214 int fiq_init; 215 215 int dma_init; 216 - int enabled; 217 216 }; 218 217 219 218 #endif /* _IMX_SSI_H */
+29 -15
sound/soc/generic/simple-card.c
··· 25 25 26 26 daifmt |= set->fmt; 27 27 28 - if (!ret && daifmt) 28 + if (daifmt) 29 29 ret = snd_soc_dai_set_fmt(dai, daifmt); 30 30 31 31 if (ret == -ENOTSUPP) { ··· 90 90 * dai->sysclk come from 91 91 * "clocks = <&xxx>" (if system has common clock) 92 92 * or "system-clock-frequency = <xxx>" 93 + * or device's module clock. 93 94 */ 94 - clk = of_clk_get(np, 0); 95 - if (IS_ERR(clk)) 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")) { 96 104 of_property_read_u32(np, 97 105 "system-clock-frequency", 98 106 &dai->sysclk); 99 - else 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 + 100 114 dai->sysclk = clk_get_rate(clk); 115 + } 101 116 102 117 ret = 0; 103 118 ··· 131 116 { 132 117 struct device_node *np; 133 118 char *name; 134 - int ret = 0; 119 + int ret; 135 120 136 121 /* get CPU/CODEC common format via simple-audio-card,format */ 137 122 info->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") & 138 123 (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK); 124 + 125 + /* DAPM routes */ 126 + ret = snd_soc_of_parse_audio_routing(&info->snd_card, 127 + "simple-audio-routing"); 128 + if (ret) 129 + return ret; 139 130 140 131 /* CPU sub-node */ 141 132 ret = -EINVAL; ··· 206 185 cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL); 207 186 if (cinfo) { 208 187 int ret; 188 + cinfo->snd_card.dev = &pdev->dev; 209 189 ret = asoc_simple_card_parse_of(np, cinfo, dev, 210 190 &of_cpu, 211 191 &of_codec, ··· 218 196 } 219 197 } 220 198 } else { 199 + cinfo->snd_card.dev = &pdev->dev; 221 200 cinfo = pdev->dev.platform_data; 222 201 } 223 202 ··· 258 235 cinfo->snd_card.owner = THIS_MODULE; 259 236 cinfo->snd_card.dai_link = &cinfo->snd_link; 260 237 cinfo->snd_card.num_links = 1; 261 - cinfo->snd_card.dev = &pdev->dev; 262 238 263 - return snd_soc_register_card(&cinfo->snd_card); 264 - } 265 - 266 - static int asoc_simple_card_remove(struct platform_device *pdev) 267 - { 268 - struct asoc_simple_card_info *cinfo = pdev->dev.platform_data; 269 - 270 - return snd_soc_unregister_card(&cinfo->snd_card); 239 + return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card); 271 240 } 272 241 273 242 static const struct of_device_id asoc_simple_of_match[] = { ··· 275 260 .of_match_table = asoc_simple_of_match, 276 261 }, 277 262 .probe = asoc_simple_card_probe, 278 - .remove = asoc_simple_card_remove, 279 263 }; 280 264 281 265 module_platform_driver(asoc_simple_card);
+1
sound/soc/jz4740/Kconfig
··· 1 1 config SND_JZ4740_SOC 2 2 tristate "SoC Audio for Ingenic JZ4740 SoC" 3 3 depends on MACH_JZ4740 && SND_SOC 4 + select SND_SOC_GENERIC_DMAENGINE_PCM 4 5 help 5 6 Say Y or M if you want to add support for codecs attached to 6 7 the JZ4740 I2S interface. You will also need to select the audio
+35 -100
sound/soc/jz4740/jz4740-i2s.c
··· 29 29 #include <sound/pcm_params.h> 30 30 #include <sound/soc.h> 31 31 #include <sound/initval.h> 32 + #include <sound/dmaengine_pcm.h> 33 + 34 + #include <asm/mach-jz4740/dma.h> 32 35 33 36 #include "jz4740-i2s.h" 34 - #include "jz4740-pcm.h" 35 37 36 38 #define JZ_REG_AIC_CONF 0x00 37 39 #define JZ_REG_AIC_CTRL 0x04 ··· 91 89 struct clk *clk_aic; 92 90 struct clk *clk_i2s; 93 91 94 - struct jz4740_pcm_config pcm_config_playback; 95 - struct jz4740_pcm_config pcm_config_capture; 92 + struct snd_dmaengine_dai_dma_data playback_dma_data; 93 + struct snd_dmaengine_dai_dma_data capture_dma_data; 96 94 }; 97 95 98 96 static inline uint32_t jz4740_i2s_read(const struct jz4740_i2s *i2s, ··· 235 233 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 236 234 { 237 235 struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); 238 - enum jz4740_dma_width dma_width; 239 - struct jz4740_pcm_config *pcm_config; 240 236 unsigned int sample_size; 241 237 uint32_t ctrl; 242 238 ··· 243 243 switch (params_format(params)) { 244 244 case SNDRV_PCM_FORMAT_S8: 245 245 sample_size = 0; 246 - dma_width = JZ4740_DMA_WIDTH_8BIT; 247 246 break; 248 247 case SNDRV_PCM_FORMAT_S16: 249 248 sample_size = 1; 250 - dma_width = JZ4740_DMA_WIDTH_16BIT; 251 249 break; 252 250 default: 253 251 return -EINVAL; ··· 258 260 ctrl |= JZ_AIC_CTRL_MONO_TO_STEREO; 259 261 else 260 262 ctrl &= ~JZ_AIC_CTRL_MONO_TO_STEREO; 261 - 262 - pcm_config = &i2s->pcm_config_playback; 263 - pcm_config->dma_config.dst_width = dma_width; 264 - 265 263 } else { 266 264 ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK; 267 265 ctrl |= sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET; 268 - 269 - pcm_config = &i2s->pcm_config_capture; 270 - pcm_config->dma_config.src_width = dma_width; 271 266 } 272 267 273 268 jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl); 274 - 275 - snd_soc_dai_set_dma_data(dai, substream, pcm_config); 276 269 277 270 return 0; 278 271 } ··· 331 342 332 343 static void jz4740_i2c_init_pcm_config(struct jz4740_i2s *i2s) 333 344 { 334 - struct jz4740_dma_config *dma_config; 345 + struct snd_dmaengine_dai_dma_data *dma_data; 335 346 336 347 /* Playback */ 337 - dma_config = &i2s->pcm_config_playback.dma_config; 338 - dma_config->src_width = JZ4740_DMA_WIDTH_32BIT; 339 - dma_config->transfer_size = JZ4740_DMA_TRANSFER_SIZE_16BYTE; 340 - dma_config->request_type = JZ4740_DMA_TYPE_AIC_TRANSMIT; 341 - dma_config->flags = JZ4740_DMA_SRC_AUTOINC; 342 - dma_config->mode = JZ4740_DMA_MODE_SINGLE; 343 - i2s->pcm_config_playback.fifo_addr = i2s->phys_base + JZ_REG_AIC_FIFO; 348 + dma_data = &i2s->playback_dma_data; 349 + dma_data->maxburst = 16; 350 + dma_data->slave_id = JZ4740_DMA_TYPE_AIC_TRANSMIT; 351 + dma_data->addr = i2s->phys_base + JZ_REG_AIC_FIFO; 344 352 345 353 /* Capture */ 346 - dma_config = &i2s->pcm_config_capture.dma_config; 347 - dma_config->dst_width = JZ4740_DMA_WIDTH_32BIT; 348 - dma_config->transfer_size = JZ4740_DMA_TRANSFER_SIZE_16BYTE; 349 - dma_config->request_type = JZ4740_DMA_TYPE_AIC_RECEIVE; 350 - dma_config->flags = JZ4740_DMA_DST_AUTOINC; 351 - dma_config->mode = JZ4740_DMA_MODE_SINGLE; 352 - i2s->pcm_config_capture.fifo_addr = i2s->phys_base + JZ_REG_AIC_FIFO; 354 + dma_data = &i2s->capture_dma_data; 355 + dma_data->maxburst = 16; 356 + dma_data->slave_id = JZ4740_DMA_TYPE_AIC_RECEIVE; 357 + dma_data->addr = i2s->phys_base + JZ_REG_AIC_FIFO; 353 358 } 354 359 355 360 static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) ··· 354 371 clk_prepare_enable(i2s->clk_aic); 355 372 356 373 jz4740_i2c_init_pcm_config(i2s); 374 + snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data, 375 + &i2s->capture_dma_data); 357 376 358 377 conf = (7 << JZ_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET) | 359 378 (8 << JZ_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET) | ··· 417 432 static int jz4740_i2s_dev_probe(struct platform_device *pdev) 418 433 { 419 434 struct jz4740_i2s *i2s; 435 + struct resource *mem; 420 436 int ret; 421 437 422 - i2s = kzalloc(sizeof(*i2s), GFP_KERNEL); 423 - 438 + i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); 424 439 if (!i2s) 425 440 return -ENOMEM; 426 441 427 - i2s->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 428 - if (!i2s->mem) { 429 - ret = -ENOENT; 430 - goto err_free; 431 - } 442 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 443 + i2s->base = devm_ioremap_resource(&pdev->dev, mem); 444 + if (IS_ERR(i2s->base)) 445 + return PTR_ERR(i2s->base); 432 446 433 - i2s->mem = request_mem_region(i2s->mem->start, resource_size(i2s->mem), 434 - pdev->name); 435 - if (!i2s->mem) { 436 - ret = -EBUSY; 437 - goto err_free; 438 - } 447 + i2s->phys_base = mem->start; 439 448 440 - i2s->base = ioremap_nocache(i2s->mem->start, resource_size(i2s->mem)); 441 - if (!i2s->base) { 442 - ret = -EBUSY; 443 - goto err_release_mem_region; 444 - } 449 + i2s->clk_aic = devm_clk_get(&pdev->dev, "aic"); 450 + if (IS_ERR(i2s->clk_aic)) 451 + return PTR_ERR(i2s->clk_aic); 445 452 446 - i2s->phys_base = i2s->mem->start; 447 - 448 - i2s->clk_aic = clk_get(&pdev->dev, "aic"); 449 - if (IS_ERR(i2s->clk_aic)) { 450 - ret = PTR_ERR(i2s->clk_aic); 451 - goto err_iounmap; 452 - } 453 - 454 - i2s->clk_i2s = clk_get(&pdev->dev, "i2s"); 455 - if (IS_ERR(i2s->clk_i2s)) { 456 - ret = PTR_ERR(i2s->clk_i2s); 457 - goto err_clk_put_aic; 458 - } 453 + i2s->clk_i2s = devm_clk_get(&pdev->dev, "i2s"); 454 + if (IS_ERR(i2s->clk_i2s)) 455 + return PTR_ERR(i2s->clk_i2s); 459 456 460 457 platform_set_drvdata(pdev, i2s); 461 - ret = snd_soc_register_component(&pdev->dev, &jz4740_i2s_component, 462 - &jz4740_i2s_dai, 1); 463 458 464 - if (ret) { 465 - dev_err(&pdev->dev, "Failed to register DAI\n"); 466 - goto err_clk_put_i2s; 467 - } 459 + ret = devm_snd_soc_register_component(&pdev->dev, 460 + &jz4740_i2s_component, &jz4740_i2s_dai, 1); 461 + if (ret) 462 + return ret; 468 463 469 - return 0; 470 - 471 - err_clk_put_i2s: 472 - clk_put(i2s->clk_i2s); 473 - err_clk_put_aic: 474 - clk_put(i2s->clk_aic); 475 - err_iounmap: 476 - iounmap(i2s->base); 477 - err_release_mem_region: 478 - release_mem_region(i2s->mem->start, resource_size(i2s->mem)); 479 - err_free: 480 - kfree(i2s); 481 - 482 - return ret; 483 - } 484 - 485 - static int jz4740_i2s_dev_remove(struct platform_device *pdev) 486 - { 487 - struct jz4740_i2s *i2s = platform_get_drvdata(pdev); 488 - 489 - snd_soc_unregister_component(&pdev->dev); 490 - 491 - clk_put(i2s->clk_i2s); 492 - clk_put(i2s->clk_aic); 493 - 494 - iounmap(i2s->base); 495 - release_mem_region(i2s->mem->start, resource_size(i2s->mem)); 496 - 497 - kfree(i2s); 498 - 499 - return 0; 464 + return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 465 + SND_DMAENGINE_PCM_FLAG_COMPAT); 500 466 } 501 467 502 468 static struct platform_driver jz4740_i2s_driver = { 503 469 .probe = jz4740_i2s_dev_probe, 504 - .remove = jz4740_i2s_dev_remove, 505 470 .driver = { 506 471 .name = "jz4740-i2s", 507 472 .owner = THIS_MODULE,
-358
sound/soc/jz4740/jz4740-pcm.c
··· 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");
-20
sound/soc/jz4740/jz4740-pcm.h
··· 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
+1 -1
sound/soc/jz4740/qi_lb60.c
··· 73 73 .name = "jz4740", 74 74 .stream_name = "jz4740", 75 75 .cpu_dai_name = "jz4740-i2s", 76 - .platform_name = "jz4740-pcm-audio", 76 + .platform_name = "jz4740-i2s", 77 77 .codec_dai_name = "jz4740-hifi", 78 78 .codec_name = "jz4740-codec", 79 79 .init = qi_lb60_codec_init,
sound/soc/mid-x86/Kconfig sound/soc/intel/Kconfig
sound/soc/mid-x86/Makefile sound/soc/intel/Makefile
sound/soc/mid-x86/mfld_machine.c sound/soc/intel/mfld_machine.c
sound/soc/mid-x86/sst_dsp.h sound/soc/intel/sst_dsp.h
sound/soc/mid-x86/sst_platform.c sound/soc/intel/sst_platform.c
sound/soc/mid-x86/sst_platform.h sound/soc/intel/sst_platform.h
+1 -7
sound/soc/mxs/mxs-pcm.c
··· 56 56 57 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 60 SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | 61 61 SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX); 62 62 } 63 63 EXPORT_SYMBOL_GPL(mxs_pcm_platform_register); 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 64 71 65 MODULE_LICENSE("GPL");
-1
sound/soc/mxs/mxs-pcm.h
··· 20 20 #define _MXS_PCM_H 21 21 22 22 int mxs_pcm_platform_register(struct device *dev); 23 - void mxs_pcm_platform_unregister(struct device *dev); 24 23 25 24 #endif
+5 -13
sound/soc/mxs/mxs-saif.c
··· 50 50 * This also means that both SAIFs must operate at the same sample rate. 51 51 * 52 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 54 - * to know the different clkmux. Saif only needs to know who is his master 55 - * and operating his master to generate the proper clock rate for him. 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 its master 55 + * and operating its master to generate the proper clock rate for it. 56 56 * The master id is provided in mach-specific layer according to different 57 57 * clkmux setting. 58 58 */ ··· 76 76 * Since SAIF may work on EXTMASTER mode, IOW, it's working BITCLK&LRCLK 77 77 * is provided by other SAIF, we provide a interface here to get its master 78 78 * from its master_id. 79 - * Note that the master could be himself. 79 + * Note that the master could be itself. 80 80 */ 81 81 static inline struct mxs_saif *mxs_saif_get_master(struct mxs_saif * saif) 82 82 { ··· 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 520 * itself clk for its internal basic logic to work. 521 521 */ 522 522 if (saif != master_saif) { ··· 804 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 807 static const struct of_device_id mxs_saif_dt_ids[] = { 815 808 { .compatible = "fsl,imx28-saif", }, 816 809 { /* sentinel */ } ··· 812 819 813 820 static struct platform_driver mxs_saif_driver = { 814 821 .probe = mxs_saif_probe, 815 - .remove = mxs_saif_remove, 816 822 817 823 .driver = { 818 824 .name = "mxs-saif",
+6 -6
sound/soc/omap/mcbsp.c
··· 36 36 37 37 if (mcbsp->pdata->reg_size == 2) { 38 38 ((u16 *)mcbsp->reg_cache)[reg] = (u16)val; 39 - __raw_writew((u16)val, addr); 39 + writew_relaxed((u16)val, addr); 40 40 } else { 41 41 ((u32 *)mcbsp->reg_cache)[reg] = val; 42 - __raw_writel(val, addr); 42 + writel_relaxed(val, addr); 43 43 } 44 44 } 45 45 ··· 48 48 void __iomem *addr = mcbsp->io_base + reg * mcbsp->pdata->reg_step; 49 49 50 50 if (mcbsp->pdata->reg_size == 2) { 51 - return !from_cache ? __raw_readw(addr) : 51 + return !from_cache ? readw_relaxed(addr) : 52 52 ((u16 *)mcbsp->reg_cache)[reg]; 53 53 } else { 54 - return !from_cache ? __raw_readl(addr) : 54 + return !from_cache ? readl_relaxed(addr) : 55 55 ((u32 *)mcbsp->reg_cache)[reg]; 56 56 } 57 57 } 58 58 59 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 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 69 #define MCBSP_READ(mcbsp, reg) \
+2 -2
sound/soc/omap/omap-dmic.c
··· 61 61 62 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 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 72 static inline void omap_dmic_start(struct omap_dmic *dmic)
+2 -2
sound/soc/omap/omap-mcpdm.c
··· 74 74 75 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 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 85 #ifdef DEBUG
-2
sound/soc/omap/omap-pcm.c
··· 45 45 SNDRV_PCM_INFO_PAUSE | 46 46 SNDRV_PCM_INFO_RESUME | 47 47 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, 48 - .formats = SNDRV_PCM_FMTBIT_S16_LE | 49 - SNDRV_PCM_FMTBIT_S32_LE, 50 48 .period_bytes_min = 32, 51 49 .period_bytes_max = 64 * 1024, 52 50 .periods_min = 2,
+1 -1
sound/soc/pxa/Kconfig
··· 11 11 config SND_MMP_SOC 12 12 bool "Soc Audio for Marvell MMP chips" 13 13 depends on ARCH_MMP 14 - select SND_DMAENGINE_PCM 14 + select SND_SOC_GENERIC_DMAENGINE_PCM 15 15 select SND_ARM 16 16 help 17 17 Say Y if you want to add support for codecs attached to
+3 -21
sound/soc/pxa/mmp-pcm.c
··· 36 36 SNDRV_PCM_INFO_PAUSE | \ 37 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 39 static struct snd_pcm_hardware mmp_pcm_hardware[] = { 44 40 { 45 41 .info = MMP_PCM_INFO, 46 - .formats = MMP_PCM_FORMATS, 47 42 .period_bytes_min = 1024, 48 43 .period_bytes_max = 2048, 49 44 .periods_min = 2, ··· 48 53 }, 49 54 { 50 55 .info = MMP_PCM_INFO, 51 - .formats = MMP_PCM_FORMATS, 52 56 .period_bytes_min = 1024, 53 57 .period_bytes_max = 2048, 54 58 .periods_min = 2, ··· 61 67 struct snd_pcm_hw_params *params) 62 68 { 63 69 struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); 64 - struct snd_soc_pcm_runtime *rtd = substream->private_data; 65 - struct snd_dmaengine_dai_dma_data *dma_params; 66 70 struct dma_slave_config slave_config; 67 71 int ret; 68 72 69 - dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 70 - if (!dma_params) 71 - return 0; 72 - 73 - ret = snd_hwparams_to_dma_slave_config(substream, params, &slave_config); 73 + ret = 74 + snd_dmaengine_pcm_prepare_slave_config(substream, params, 75 + &slave_config); 74 76 if (ret) 75 77 return ret; 76 - 77 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 78 - slave_config.dst_addr = dma_params->addr; 79 - slave_config.dst_maxburst = 4; 80 - } else { 81 - slave_config.src_addr = dma_params->addr; 82 - slave_config.src_maxburst = 4; 83 - } 84 78 85 79 ret = dmaengine_slave_config(chan, &slave_config); 86 80 if (ret)
-7
sound/soc/s6000/s6000-pcm.c
··· 33 33 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | 34 34 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | 35 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 36 .buffer_bytes_max = 0x7ffffff0, 44 37 .period_bytes_min = 16, 45 38 .period_bytes_max = 0xfffff0,
+11 -2
sound/soc/samsung/Kconfig
··· 1 1 config SND_SOC_SAMSUNG 2 2 tristate "ASoC support for Samsung" 3 3 depends on PLAT_SAMSUNG 4 - select S3C64XX_DMA if ARCH_S3C64XX 5 - select S3C24XX_DMA if ARCH_S3C24XX 4 + select S3C2410_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 9 help 7 10 Say Y or M if you want to add support for codecs attached to 8 11 the Samsung SoCs' Audio interfaces. You will also need to 9 12 select the audio interfaces to support below. 13 + 14 + config SND_S3C_DMA 15 + tristate 16 + 17 + config SND_S3C_DMA_LEGACY 18 + tristate 10 19 11 20 config SND_S3C24XX_I2S 12 21 tristate
+4 -2
sound/soc/samsung/Makefile
··· 1 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 4 snd-soc-idma-objs := idma.o 4 5 snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o 5 6 snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o ··· 10 9 snd-soc-pcm-objs := pcm.o 11 10 snd-soc-i2s-objs := i2s.o 12 11 13 - obj-$(CONFIG_SND_SOC_SAMSUNG) += snd-soc-s3c24xx.o 12 + obj-$(CONFIG_SND_S3C_DMA) += snd-soc-s3c-dma.o 13 + obj-$(CONFIG_SND_S3C_DMA_LEGACY) += snd-soc-s3c-dma-legacy.o 14 14 obj-$(CONFIG_SND_S3C24XX_I2S) += snd-soc-s3c24xx-i2s.o 15 15 obj-$(CONFIG_SND_SAMSUNG_AC97) += snd-soc-ac97.o 16 16 obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o
+16 -35
sound/soc/samsung/ac97.c
··· 221 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 224 static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd, 243 225 struct snd_soc_dai *dai) 244 226 { ··· 261 279 return 0; 262 280 } 263 281 264 - static int s3c_ac97_hw_mic_params(struct snd_pcm_substream *substream, 265 - struct snd_pcm_hw_params *params, 266 - struct snd_soc_dai *dai) 267 - { 268 - struct snd_soc_pcm_runtime *rtd = substream->private_data; 269 - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 270 - 271 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 272 - return -ENODEV; 273 - else 274 - snd_soc_dai_set_dma_data(cpu_dai, substream, &s3c_ac97_mic_in); 275 - 276 - return 0; 277 - } 278 - 279 282 static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream, 280 283 int cmd, struct snd_soc_dai *dai) 281 284 { ··· 296 329 } 297 330 298 331 static const struct snd_soc_dai_ops s3c_ac97_dai_ops = { 299 - .hw_params = s3c_ac97_hw_params, 300 332 .trigger = s3c_ac97_trigger, 301 333 }; 302 334 303 335 static const struct snd_soc_dai_ops s3c_ac97_mic_dai_ops = { 304 - .hw_params = s3c_ac97_hw_mic_params, 305 336 .trigger = s3c_ac97_mic_trigger, 306 337 }; 338 + 339 + static int s3c_ac97_dai_probe(struct snd_soc_dai *dai) 340 + { 341 + samsung_asoc_init_dma_data(dai, &s3c_ac97_pcm_out, &s3c_ac97_pcm_in); 342 + 343 + return 0; 344 + } 345 + 346 + static int s3c_ac97_mic_dai_probe(struct snd_soc_dai *dai) 347 + { 348 + samsung_asoc_init_dma_data(dai, NULL, &s3c_ac97_mic_in); 349 + 350 + return 0; 351 + } 307 352 308 353 static struct snd_soc_dai_driver s3c_ac97_dai[] = { 309 354 [S3C_AC97_DAI_PCM] = { ··· 333 354 .channels_max = 2, 334 355 .rates = SNDRV_PCM_RATE_8000_48000, 335 356 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 357 + .probe = s3c_ac97_dai_probe, 336 358 .ops = &s3c_ac97_dai_ops, 337 359 }, 338 360 [S3C_AC97_DAI_MIC] = { ··· 345 365 .channels_max = 1, 346 366 .rates = SNDRV_PCM_RATE_8000_48000, 347 367 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 368 + .probe = s3c_ac97_mic_dai_probe, 348 369 .ops = &s3c_ac97_mic_dai_ops, 349 370 }, 350 371 };
+8 -6
sound/soc/samsung/dma.c
··· 35 35 SNDRV_PCM_INFO_BLOCK_TRANSFER | 36 36 SNDRV_PCM_INFO_MMAP | 37 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 38 .buffer_bytes_max = 128*1024, 45 39 .period_bytes_min = PAGE_SIZE, 46 40 .period_bytes_max = PAGE_SIZE*2, ··· 434 440 .pcm_new = dma_new, 435 441 .pcm_free = dma_free_dma_buffers, 436 442 }; 443 + 444 + void samsung_asoc_init_dma_data(struct snd_soc_dai *dai, 445 + struct s3c_dma_params *playback, 446 + struct s3c_dma_params *capture) 447 + { 448 + snd_soc_dai_init_dma_data(dai, playback, capture); 449 + } 450 + EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data); 437 451 438 452 int samsung_asoc_dma_platform_register(struct device *dev) 439 453 {
+6
sound/soc/samsung/dma.h
··· 12 12 #ifndef _S3C_AUDIO_H 13 13 #define _S3C_AUDIO_H 14 14 15 + #include <sound/dmaengine_pcm.h> 16 + 15 17 struct s3c_dma_params { 16 18 struct s3c2410_dma_client *client; /* stream identifier */ 17 19 int channel; /* Channel ID */ ··· 22 20 unsigned ch; 23 21 struct samsung_dma_ops *ops; 24 22 char *ch_name; 23 + struct snd_dmaengine_dai_dma_data dma_data; 25 24 }; 26 25 26 + void samsung_asoc_init_dma_data(struct snd_soc_dai *dai, 27 + struct s3c_dma_params *playback, 28 + struct s3c_dma_params *capture); 27 29 int samsung_asoc_dma_platform_register(struct device *dev); 28 30 void samsung_asoc_dma_platform_unregister(struct device *dev); 29 31
+84
sound/soc/samsung/dmaengine.c
··· 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");
+7 -2
sound/soc/samsung/i2s.c
··· 702 702 } 703 703 writel(mod, i2s->addr + I2SMOD); 704 704 705 + samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); 706 + 705 707 i2s->frmclk = params_rate(params); 706 708 707 709 return 0; ··· 948 946 struct i2s_dai *i2s = to_info(dai); 949 947 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; 950 948 951 - if (other && other->clk) /* If this is probe on secondary */ 949 + if (other && other->clk) { /* If this is probe on secondary */ 950 + samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback, 951 + NULL); 952 952 goto probe_exit; 953 + } 953 954 954 955 i2s->addr = ioremap(i2s->base, 0x100); 955 956 if (i2s->addr == NULL) { ··· 968 963 } 969 964 clk_prepare_enable(i2s->clk); 970 965 971 - snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); 966 + samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); 972 967 973 968 if (other) { 974 969 other->addr = i2s->addr;
-8
sound/soc/samsung/idma.c
··· 35 35 SNDRV_PCM_INFO_MMAP_VALID | 36 36 SNDRV_PCM_INFO_PAUSE | 37 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 38 .buffer_bytes_max = MAX_IDMA_BUFFER, 47 39 .period_bytes_min = 128, 48 40 .period_bytes_max = MAX_IDMA_PERIOD,
+10 -8
sound/soc/samsung/pcm.c
··· 275 275 { 276 276 struct snd_soc_pcm_runtime *rtd = substream->private_data; 277 277 struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(rtd->cpu_dai); 278 - struct s3c_dma_params *dma_data; 279 278 void __iomem *regs = pcm->regs; 280 279 struct clk *clk; 281 280 int sclk_div, sync_div; ··· 282 283 u32 clkctl; 283 284 284 285 dev_dbg(pcm->dev, "Entered %s\n", __func__); 285 - 286 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 287 - dma_data = pcm->dma_playback; 288 - else 289 - dma_data = pcm->dma_capture; 290 - 291 - snd_soc_dai_set_dma_data(rtd->cpu_dai, substream, dma_data); 292 286 293 287 /* Strictly check for sample size */ 294 288 switch (params_format(params)) { ··· 453 461 .set_fmt = s3c_pcm_set_fmt, 454 462 }; 455 463 464 + static int s3c_pcm_dai_probe(struct snd_soc_dai *dai) 465 + { 466 + struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(dai); 467 + 468 + snd_soc_dai_init_dma_data(dai, pcm->dma_playback, pcm->dma_capture); 469 + 470 + return 0; 471 + } 472 + 456 473 #define S3C_PCM_RATES SNDRV_PCM_RATE_8000_96000 457 474 458 475 #define S3C_PCM_DAI_DECLARE \ 459 476 .symmetric_rates = 1, \ 477 + .probe = s3c_pcm_dai_probe, \ 460 478 .ops = &s3c_pcm_dai_ops, \ 461 479 .playback = { \ 462 480 .channels_min = 2, \
+4 -5
sound/soc/samsung/regs-ac97.h
··· 1 - /* arch/arm/mach-s3c2410/include/mach/regs-ac97.h 2 - * 1 + /* 3 2 * Copyright (c) 2006 Simtec Electronics <linux@simtec.co.uk> 4 3 * http://www.simtec.co.uk/products/SWLINUX/ 5 4 * ··· 9 10 * S3C2440 AC97 Controller 10 11 */ 11 12 12 - #ifndef __ASM_ARCH_REGS_AC97_H 13 - #define __ASM_ARCH_REGS_AC97_H __FILE__ 13 + #ifndef __SAMSUNG_REGS_AC97_H__ 14 + #define __SAMSUNG_REGS_AC97_H__ 14 15 15 16 #define S3C_AC97_GLBCTRL (0x00) 16 17 ··· 63 64 #define S3C_AC97_PCM_DATA (0x18) 64 65 #define S3C_AC97_MIC_DATA (0x1C) 65 66 66 - #endif /* __ASM_ARCH_REGS_AC97_H */ 67 + #endif /* __SAMSUNG_REGS_AC97_H__ */
+4 -5
sound/soc/samsung/regs-iis.h
··· 1 - /* arch/arm/plat-samsung/include/plat/regs-iis.h 2 - * 1 + /* 3 2 * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk> 4 3 * http://www.simtec.co.uk/products/SWLINUX/ 5 4 * ··· 9 10 * S3C2410 IIS register definition 10 11 */ 11 12 12 - #ifndef __ASM_ARCH_REGS_IIS_H 13 - #define __ASM_ARCH_REGS_IIS_H 13 + #ifndef __SAMSUNG_REGS_IIS_H__ 14 + #define __SAMSUNG_REGS_IIS_H__ 14 15 15 16 #define S3C2410_IISCON (0x00) 16 17 ··· 66 67 67 68 #define S3C2410_IISFIFO (0x10) 68 69 69 - #endif /* __ASM_ARCH_REGS_IIS_H */ 70 + #endif /* __SAMSUNG_REGS_IIS_H__ */
+23 -13
sound/soc/sh/fsi.c
··· 232 232 * these are for DMAEngine 233 233 */ 234 234 struct dma_chan *chan; 235 - struct sh_dmae_slave slave; /* see fsi_handler_init() */ 236 235 struct work_struct work; 237 236 dma_addr_t dma; 237 + int dma_id; 238 238 int loop_cnt; 239 239 int additional_pos; 240 240 }; ··· 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 1413 static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io) 1423 1414 { 1424 1415 schedule_work(&io->work); ··· 1437 1446 static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io, struct device *dev) 1438 1447 { 1439 1448 dma_cap_mask_t mask; 1449 + int is_play = fsi_stream_is_play(fsi, io); 1440 1450 1441 1451 dma_cap_zero(mask); 1442 1452 dma_cap_set(DMA_SLAVE, mask); 1443 1453 1444 - io->chan = dma_request_channel(mask, fsi_dma_filter, &io->slave); 1454 + io->chan = dma_request_slave_channel_compat(mask, 1455 + shdma_chan_filter, (void *)io->dma_id, 1456 + dev, is_play ? "tx" : "rx"); 1457 + if (io->chan) { 1458 + struct dma_slave_config cfg; 1459 + int ret; 1460 + 1461 + cfg.slave_id = io->dma_id; 1462 + cfg.dst_addr = 0; /* use default addr */ 1463 + cfg.src_addr = 0; /* use default addr */ 1464 + cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; 1465 + 1466 + ret = dmaengine_slave_config(io->chan, &cfg); 1467 + if (ret < 0) { 1468 + dma_release_channel(io->chan); 1469 + io->chan = NULL; 1470 + } 1471 + } 1472 + 1445 1473 if (!io->chan) { 1446 1474 1447 1475 /* switch to PIO handler */ 1448 - if (fsi_stream_is_play(fsi, io)) 1476 + if (is_play) 1449 1477 fsi->playback.handler = &fsi_pio_push_handler; 1450 1478 else 1451 1479 fsi->capture.handler = &fsi_pio_pop_handler; ··· 1970 1960 fsi->capture.priv = fsi; 1971 1961 1972 1962 if (info->tx_id) { 1973 - fsi->playback.slave.shdma_slave.slave_id = info->tx_id; 1963 + fsi->playback.dma_id = info->tx_id; 1974 1964 fsi->playback.handler = &fsi_dma_push_handler; 1975 1965 } 1976 1966 }
+106 -43
sound/soc/sh/rcar/adg.c
··· 19 19 struct rsnd_adg { 20 20 struct clk *clk[CLKMAX]; 21 21 22 - int rate_of_441khz_div_6; 23 - int rate_of_48khz_div_6; 22 + int rbga_rate_for_441khz_div_6; /* RBGA */ 23 + int rbgb_rate_for_48khz_div_6; /* RBGB */ 24 24 u32 ckr; 25 25 }; 26 26 ··· 30 30 i++, (pos) = adg->clk[i]) 31 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 115 * SSI 8 is not connected to ADG. 39 116 * it works with SSI 7 40 117 */ 41 118 if (id == 8) 42 - return RSND_REG_MAX; 119 + return; 43 120 44 - if (0 <= id && id <= 3) 45 - reg = RSND_REG_AUDIO_CLK_SEL0; 46 - else if (4 <= id && id <= 7) 47 - reg = RSND_REG_AUDIO_CLK_SEL1; 48 - else 49 - reg = RSND_REG_AUDIO_CLK_SEL2; 50 - 51 - return reg; 121 + switch (id / 4) { 122 + case 0: 123 + rsnd_mod_bset(mod, AUDIO_CLK_SEL0, mask, val); 124 + break; 125 + case 1: 126 + rsnd_mod_bset(mod, AUDIO_CLK_SEL1, mask, val); 127 + break; 128 + case 2: 129 + rsnd_mod_bset(mod, AUDIO_CLK_SEL2, mask, val); 130 + break; 131 + } 52 132 } 53 133 54 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 137 * "mod" = "ssi" here. 62 138 * we can get "ssi id" from mod 63 139 */ 64 - id = rsnd_mod_id(mod); 65 - reg = rsnd_adg_ssi_reg_get(id); 66 - 67 - rsnd_write(priv, mod, reg, 0); 140 + rsnd_adg_set_ssi_clk(mod, 0); 68 141 69 142 return 0; 70 143 } ··· 148 75 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); 149 76 struct device *dev = rsnd_priv_to_dev(priv); 150 77 struct clk *clk; 151 - enum rsnd_reg reg; 152 - int id, shift, i; 78 + int i; 153 79 u32 data; 154 80 int sel_table[] = { 155 81 [CLKA] = 0x1, ··· 174 102 /* 175 103 * find 1/6 clock from BRGA/BRGB 176 104 */ 177 - if (rate == adg->rate_of_441khz_div_6) { 105 + if (rate == adg->rbga_rate_for_441khz_div_6) { 178 106 data = 0x10; 179 107 goto found_clock; 180 108 } 181 109 182 - if (rate == adg->rate_of_48khz_div_6) { 110 + if (rate == adg->rbgb_rate_for_48khz_div_6) { 183 111 data = 0x20; 184 112 goto found_clock; 185 113 } ··· 197 125 * This "mod" = "ssi" here. 198 126 * we can get "ssi id" from mod 199 127 */ 200 - id = rsnd_mod_id(mod); 201 - reg = rsnd_adg_ssi_reg_get(id); 128 + rsnd_adg_set_ssi_clk(mod, data); 202 129 203 - dev_dbg(dev, "ADG: ssi%d selects clk%d = %d", id, i, rate); 204 - 205 - /* 206 - * Enable SSIx clock 207 - */ 208 - shift = (id % 4) * 8; 209 - 210 - rsnd_bset(priv, mod, reg, 211 - 0xFF << shift, 212 - data << shift); 130 + dev_dbg(dev, "ADG: ssi%d selects clk%d = %d", 131 + rsnd_mod_id(mod), i, rate); 213 132 214 133 return 0; 215 134 } ··· 229 166 * rsnd_adg_ssi_clk_try_start() 230 167 */ 231 168 ckr = 0; 232 - adg->rate_of_441khz_div_6 = 0; 233 - adg->rate_of_48khz_div_6 = 0; 169 + adg->rbga_rate_for_441khz_div_6 = 0; 170 + adg->rbgb_rate_for_48khz_div_6 = 0; 234 171 for_each_rsnd_clk(clk, adg, i) { 235 172 rate = clk_get_rate(clk); 236 173 ··· 238 175 continue; 239 176 240 177 /* RBGA */ 241 - if (!adg->rate_of_441khz_div_6 && (0 == rate % 44100)) { 242 - adg->rate_of_441khz_div_6 = rate / 6; 178 + if (!adg->rbga_rate_for_441khz_div_6 && (0 == rate % 44100)) { 179 + adg->rbga_rate_for_441khz_div_6 = rate / 6; 243 180 ckr |= brg_table[i] << 20; 244 181 } 245 182 246 183 /* RBGB */ 247 - if (!adg->rate_of_48khz_div_6 && (0 == rate % 48000)) { 248 - adg->rate_of_48khz_div_6 = rate / 6; 184 + if (!adg->rbgb_rate_for_48khz_div_6 && (0 == rate % 48000)) { 185 + adg->rbgb_rate_for_48khz_div_6 = rate / 6; 249 186 ckr |= brg_table[i] << 16; 250 187 } 251 188 }
+168 -92
sound/soc/sh/rcar/gen.c
··· 10 10 */ 11 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 13 struct rsnd_gen { 28 14 void __iomem *base[RSND_BASE_MAX]; 29 15 ··· 72 86 .val_format_endian_default = REGMAP_ENDIAN_NATIVE, 73 87 }; 74 88 89 + static int rsnd_is_accessible_reg(struct rsnd_priv *priv, 90 + struct rsnd_gen *gen, enum rsnd_reg reg) 91 + { 92 + if (!gen->regs[reg]) { 93 + struct device *dev = rsnd_priv_to_dev(priv); 94 + 95 + dev_err(dev, "unsupported register access %x\n", reg); 96 + return 0; 97 + } 98 + 99 + return 1; 100 + } 101 + 75 102 u32 rsnd_read(struct rsnd_priv *priv, 76 103 struct rsnd_mod *mod, enum rsnd_reg reg) 77 104 { 78 105 struct rsnd_gen *gen = rsnd_priv_to_gen(priv); 79 106 u32 val; 107 + 108 + if (!rsnd_is_accessible_reg(priv, gen, reg)) 109 + return 0; 80 110 81 111 regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val); 82 112 ··· 105 103 { 106 104 struct rsnd_gen *gen = rsnd_priv_to_gen(priv); 107 105 106 + if (!rsnd_is_accessible_reg(priv, gen, reg)) 107 + return; 108 + 108 109 regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); 109 110 } 110 111 ··· 116 111 { 117 112 struct rsnd_gen *gen = rsnd_priv_to_gen(priv); 118 113 114 + if (!rsnd_is_accessible_reg(priv, gen, reg)) 115 + return; 116 + 119 117 regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod), 120 118 mask, data); 121 119 } 122 120 123 - /* 124 - * Gen2 125 - * will be filled in the future 126 - */ 121 + static int rsnd_gen_regmap_init(struct rsnd_priv *priv, 122 + struct rsnd_gen *gen, 123 + struct reg_field *regf) 124 + { 125 + int i; 126 + struct device *dev = rsnd_priv_to_dev(priv); 127 + struct regmap_config regc; 127 128 128 - /* 129 - * Gen1 130 - */ 131 - static int rsnd_gen1_path_init(struct rsnd_priv *priv, 132 - struct rsnd_dai *rdai, 133 - struct rsnd_dai_stream *io) 129 + memset(&regc, 0, sizeof(regc)); 130 + regc.reg_bits = 32; 131 + regc.val_bits = 32; 132 + 133 + gen->regmap = devm_regmap_init(dev, &rsnd_regmap_bus, priv, &regc); 134 + if (IS_ERR(gen->regmap)) { 135 + dev_err(dev, "regmap error %ld\n", PTR_ERR(gen->regmap)); 136 + return PTR_ERR(gen->regmap); 137 + } 138 + 139 + for (i = 0; i < RSND_REG_MAX; i++) { 140 + gen->regs[i] = NULL; 141 + if (!regf[i].reg) 142 + continue; 143 + 144 + gen->regs[i] = devm_regmap_field_alloc(dev, gen->regmap, regf[i]); 145 + if (IS_ERR(gen->regs[i])) 146 + return PTR_ERR(gen->regs[i]); 147 + 148 + } 149 + 150 + return 0; 151 + } 152 + 153 + int rsnd_gen_path_init(struct rsnd_priv *priv, 154 + struct rsnd_dai *rdai, 155 + struct rsnd_dai_stream *io) 134 156 { 135 157 struct rsnd_mod *mod; 136 158 int ret; ··· 195 163 return ret; 196 164 } 197 165 198 - static int rsnd_gen1_path_exit(struct rsnd_priv *priv, 199 - struct rsnd_dai *rdai, 200 - struct rsnd_dai_stream *io) 166 + int rsnd_gen_path_exit(struct rsnd_priv *priv, 167 + struct rsnd_dai *rdai, 168 + struct rsnd_dai_stream *io) 201 169 { 202 170 struct rsnd_mod *mod, *n; 203 171 int ret = 0; ··· 211 179 return ret; 212 180 } 213 181 182 + /* 183 + * Gen2 184 + */ 185 + 186 + /* single address mapping */ 187 + #define RSND_GEN2_S_REG(gen, reg, id, offset) \ 188 + RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN2_##reg, offset, 0, 10) 189 + 190 + /* multi address mapping */ 191 + #define RSND_GEN2_M_REG(gen, reg, id, offset, _id_offset) \ 192 + RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN2_##reg, offset, _id_offset, 10) 193 + 194 + static int rsnd_gen2_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) 195 + { 196 + struct reg_field regf[RSND_REG_MAX] = { 197 + RSND_GEN2_S_REG(gen, SSIU, SSI_MODE0, 0x800), 198 + RSND_GEN2_S_REG(gen, SSIU, SSI_MODE1, 0x804), 199 + /* FIXME: it needs SSI_MODE2/3 in the future */ 200 + RSND_GEN2_M_REG(gen, SSIU, INT_ENABLE, 0x18, 0x80), 201 + 202 + RSND_GEN2_S_REG(gen, ADG, BRRA, 0x00), 203 + RSND_GEN2_S_REG(gen, ADG, BRRB, 0x04), 204 + RSND_GEN2_S_REG(gen, ADG, SSICKR, 0x08), 205 + RSND_GEN2_S_REG(gen, ADG, AUDIO_CLK_SEL0, 0x0c), 206 + RSND_GEN2_S_REG(gen, ADG, AUDIO_CLK_SEL1, 0x10), 207 + RSND_GEN2_S_REG(gen, ADG, AUDIO_CLK_SEL2, 0x14), 208 + 209 + RSND_GEN2_M_REG(gen, SSI, SSICR, 0x00, 0x40), 210 + RSND_GEN2_M_REG(gen, SSI, SSISR, 0x04, 0x40), 211 + RSND_GEN2_M_REG(gen, SSI, SSITDR, 0x08, 0x40), 212 + RSND_GEN2_M_REG(gen, SSI, SSIRDR, 0x0c, 0x40), 213 + RSND_GEN2_M_REG(gen, SSI, SSIWSR, 0x20, 0x40), 214 + }; 215 + 216 + return rsnd_gen_regmap_init(priv, gen, regf); 217 + } 218 + 219 + static int rsnd_gen2_probe(struct platform_device *pdev, 220 + struct rcar_snd_info *info, 221 + struct rsnd_priv *priv) 222 + { 223 + struct device *dev = rsnd_priv_to_dev(priv); 224 + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); 225 + struct resource *scu_res; 226 + struct resource *adg_res; 227 + struct resource *ssiu_res; 228 + struct resource *ssi_res; 229 + int ret; 230 + 231 + /* 232 + * map address 233 + */ 234 + scu_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SCU); 235 + adg_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_ADG); 236 + ssiu_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SSIU); 237 + ssi_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SSI); 238 + 239 + gen->base[RSND_GEN2_SCU] = devm_ioremap_resource(dev, scu_res); 240 + gen->base[RSND_GEN2_ADG] = devm_ioremap_resource(dev, adg_res); 241 + gen->base[RSND_GEN2_SSIU] = devm_ioremap_resource(dev, ssiu_res); 242 + gen->base[RSND_GEN2_SSI] = devm_ioremap_resource(dev, ssi_res); 243 + if (IS_ERR(gen->base[RSND_GEN2_SCU]) || 244 + IS_ERR(gen->base[RSND_GEN2_ADG]) || 245 + IS_ERR(gen->base[RSND_GEN2_SSIU]) || 246 + IS_ERR(gen->base[RSND_GEN2_SSI])) 247 + return -ENODEV; 248 + 249 + ret = rsnd_gen2_regmap_init(priv, gen); 250 + if (ret < 0) 251 + return ret; 252 + 253 + dev_dbg(dev, "Gen2 device probed\n"); 254 + dev_dbg(dev, "SRU : %08x => %p\n", scu_res->start, 255 + gen->base[RSND_GEN2_SCU]); 256 + dev_dbg(dev, "ADG : %08x => %p\n", adg_res->start, 257 + gen->base[RSND_GEN2_ADG]); 258 + dev_dbg(dev, "SSIU : %08x => %p\n", ssiu_res->start, 259 + gen->base[RSND_GEN2_SSIU]); 260 + dev_dbg(dev, "SSI : %08x => %p\n", ssi_res->start, 261 + gen->base[RSND_GEN2_SSI]); 262 + 263 + return 0; 264 + } 265 + 266 + /* 267 + * Gen1 268 + */ 269 + 214 270 /* single address mapping */ 215 271 #define RSND_GEN1_S_REG(gen, reg, id, offset) \ 216 272 RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, 0, 9) ··· 309 189 310 190 static int rsnd_gen1_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) 311 191 { 312 - int i; 313 - struct device *dev = rsnd_priv_to_dev(priv); 314 - struct regmap_config regc; 315 192 struct reg_field regf[RSND_REG_MAX] = { 316 193 RSND_GEN1_S_REG(gen, SRU, SRC_ROUTE_SEL, 0x00), 317 194 RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL0, 0x08), 318 195 RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL1, 0x0c), 319 196 RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL2, 0x10), 320 - RSND_GEN1_S_REG(gen, SRU, SRC_CTRL, 0xc0), 197 + RSND_GEN1_S_REG(gen, SRU, SRC_ROUTE_CTRL, 0xc0), 321 198 RSND_GEN1_S_REG(gen, SRU, SSI_MODE0, 0xD0), 322 199 RSND_GEN1_S_REG(gen, SRU, SSI_MODE1, 0xD4), 323 200 RSND_GEN1_M_REG(gen, SRU, BUSIF_MODE, 0x20, 0x4), 324 - RSND_GEN1_M_REG(gen, SRU, BUSIF_ADINR, 0x214, 0x40), 201 + RSND_GEN1_M_REG(gen, SRU, SRC_ROUTE_MODE0,0x50, 0x8), 202 + RSND_GEN1_M_REG(gen, SRU, SRC_SWRSR, 0x200, 0x40), 203 + RSND_GEN1_M_REG(gen, SRU, SRC_SRCIR, 0x204, 0x40), 204 + RSND_GEN1_M_REG(gen, SRU, SRC_ADINR, 0x214, 0x40), 205 + RSND_GEN1_M_REG(gen, SRU, SRC_IFSCR, 0x21c, 0x40), 206 + RSND_GEN1_M_REG(gen, SRU, SRC_IFSVR, 0x220, 0x40), 207 + RSND_GEN1_M_REG(gen, SRU, SRC_SRCCR, 0x224, 0x40), 208 + RSND_GEN1_M_REG(gen, SRU, SRC_MNFSR, 0x228, 0x40), 325 209 326 210 RSND_GEN1_S_REG(gen, ADG, BRRA, 0x00), 327 211 RSND_GEN1_S_REG(gen, ADG, BRRB, 0x04), ··· 343 219 RSND_GEN1_M_REG(gen, SSI, SSIWSR, 0x20, 0x40), 344 220 }; 345 221 346 - memset(&regc, 0, sizeof(regc)); 347 - regc.reg_bits = 32; 348 - regc.val_bits = 32; 349 - 350 - gen->regmap = devm_regmap_init(dev, &rsnd_regmap_bus, priv, &regc); 351 - if (IS_ERR(gen->regmap)) { 352 - dev_err(dev, "regmap error %ld\n", PTR_ERR(gen->regmap)); 353 - return PTR_ERR(gen->regmap); 354 - } 355 - 356 - for (i = 0; i < RSND_REG_MAX; i++) { 357 - gen->regs[i] = devm_regmap_field_alloc(dev, gen->regmap, regf[i]); 358 - if (IS_ERR(gen->regs[i])) 359 - return PTR_ERR(gen->regs[i]); 360 - 361 - } 362 - 363 - return 0; 222 + return rsnd_gen_regmap_init(priv, gen, regf); 364 223 } 365 224 366 225 static int rsnd_gen1_probe(struct platform_device *pdev, ··· 388 281 389 282 } 390 283 391 - static void rsnd_gen1_remove(struct platform_device *pdev, 392 - struct rsnd_priv *priv) 393 - { 394 - } 395 - 396 - static struct rsnd_gen_ops rsnd_gen1_ops = { 397 - .probe = rsnd_gen1_probe, 398 - .remove = rsnd_gen1_remove, 399 - .path_init = rsnd_gen1_path_init, 400 - .path_exit = rsnd_gen1_path_exit, 401 - }; 402 - 403 284 /* 404 285 * Gen 405 286 */ 406 - int rsnd_gen_path_init(struct rsnd_priv *priv, 407 - struct rsnd_dai *rdai, 408 - struct rsnd_dai_stream *io) 409 - { 410 - struct rsnd_gen *gen = rsnd_priv_to_gen(priv); 411 - 412 - return gen->ops->path_init(priv, rdai, io); 413 - } 414 - 415 - int rsnd_gen_path_exit(struct rsnd_priv *priv, 416 - struct rsnd_dai *rdai, 417 - struct rsnd_dai_stream *io) 418 - { 419 - struct rsnd_gen *gen = rsnd_priv_to_gen(priv); 420 - 421 - return gen->ops->path_exit(priv, rdai, io); 422 - } 423 - 424 287 int rsnd_gen_probe(struct platform_device *pdev, 425 288 struct rcar_snd_info *info, 426 289 struct rsnd_priv *priv) 427 290 { 428 291 struct device *dev = rsnd_priv_to_dev(priv); 429 292 struct rsnd_gen *gen; 293 + int ret; 430 294 431 295 gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL); 432 296 if (!gen) { ··· 405 327 return -ENOMEM; 406 328 } 407 329 408 - if (rsnd_is_gen1(priv)) 409 - gen->ops = &rsnd_gen1_ops; 410 - 411 - if (!gen->ops) { 412 - dev_err(dev, "unknown generation R-Car sound device\n"); 413 - return -ENODEV; 414 - } 415 - 416 330 priv->gen = gen; 417 331 418 - return gen->ops->probe(pdev, info, priv); 332 + ret = -ENODEV; 333 + if (rsnd_is_gen1(priv)) 334 + ret = rsnd_gen1_probe(pdev, info, priv); 335 + else if (rsnd_is_gen2(priv)) 336 + ret = rsnd_gen2_probe(pdev, info, priv); 337 + 338 + if (ret < 0) 339 + dev_err(dev, "unknown generation R-Car sound device\n"); 340 + 341 + return ret; 419 342 } 420 343 421 344 void rsnd_gen_remove(struct platform_device *pdev, 422 345 struct rsnd_priv *priv) 423 346 { 424 - struct rsnd_gen *gen = rsnd_priv_to_gen(priv); 425 - 426 - gen->ops->remove(pdev, priv); 427 347 }
+31 -15
sound/soc/sh/rcar/rsnd.h
··· 31 31 * see gen1/gen2 for detail 32 32 */ 33 33 enum rsnd_reg { 34 - /* SRU/SCU */ 35 - RSND_REG_SRC_ROUTE_SEL, 36 - RSND_REG_SRC_TMG_SEL0, 37 - RSND_REG_SRC_TMG_SEL1, 38 - RSND_REG_SRC_TMG_SEL2, 39 - RSND_REG_SRC_CTRL, 34 + /* SRU/SCU/SSIU */ 35 + RSND_REG_SRC_ROUTE_SEL, /* for Gen1 */ 36 + RSND_REG_SRC_TMG_SEL0, /* for Gen1 */ 37 + RSND_REG_SRC_TMG_SEL1, /* for Gen1 */ 38 + RSND_REG_SRC_TMG_SEL2, /* for Gen1 */ 39 + RSND_REG_SRC_ROUTE_CTRL, /* for Gen1 */ 40 40 RSND_REG_SSI_MODE0, 41 41 RSND_REG_SSI_MODE1, 42 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 53 /* ADG */ 46 54 RSND_REG_BRRA, ··· 57 49 RSND_REG_AUDIO_CLK_SEL0, 58 50 RSND_REG_AUDIO_CLK_SEL1, 59 51 RSND_REG_AUDIO_CLK_SEL2, 60 - RSND_REG_AUDIO_CLK_SEL3, 61 - RSND_REG_AUDIO_CLK_SEL4, 62 - RSND_REG_AUDIO_CLK_SEL5, 52 + RSND_REG_AUDIO_CLK_SEL3, /* for Gen1 */ 53 + RSND_REG_AUDIO_CLK_SEL4, /* for Gen1 */ 54 + RSND_REG_AUDIO_CLK_SEL5, /* for Gen1 */ 63 55 64 56 /* SSI */ 65 57 RSND_REG_SSICR, ··· 182 174 struct rsnd_dai_stream playback; 183 175 struct rsnd_dai_stream capture; 184 176 185 - int clk_master:1; 186 - int bit_clk_inv:1; 187 - int frm_clk_inv:1; 188 - int sys_delay:1; 189 - int data_alignment:1; 177 + unsigned int clk_master:1; 178 + unsigned int bit_clk_inv:1; 179 + unsigned int frm_clk_inv:1; 180 + unsigned int sys_delay:1; 181 + unsigned int data_alignment:1; 190 182 }; 191 183 192 184 #define rsnd_dai_nr(priv) ((priv)->dai_nr) ··· 237 229 struct rsnd_priv *priv); 238 230 void rsnd_adg_remove(struct platform_device *pdev, 239 231 struct rsnd_priv *priv); 232 + int rsnd_adg_set_convert_clk(struct rsnd_priv *priv, 233 + struct rsnd_mod *mod, 234 + unsigned int src_rate, 235 + unsigned int dst_rate); 240 236 241 237 /* 242 238 * R-Car sound priv ··· 294 282 struct rsnd_priv *priv); 295 283 struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id); 296 284 bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod); 285 + unsigned int rsnd_scu_get_ssi_rate(struct rsnd_priv *priv, 286 + struct rsnd_mod *ssi_mod, 287 + struct snd_pcm_runtime *runtime); 288 + 297 289 #define rsnd_scu_nr(priv) ((priv)->scu_nr) 298 290 299 291 /*
+161 -20
sound/soc/sh/rcar/scu.c
··· 13 13 struct rsnd_scu { 14 14 struct rsnd_scu_platform_info *info; /* rcar_snd.h */ 15 15 struct rsnd_mod mod; 16 + struct clk *clk; 16 17 }; 17 18 18 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 25 * ADINR ··· 30 26 #define OTBL_18 (6 << 16) 31 27 #define OTBL_16 (8 << 16) 32 28 29 + /* 30 + * image of SRC (Sampling Rate Converter) 31 + * 32 + * 96kHz <-> +-----+ 48kHz +-----+ 48kHz +-------+ 33 + * 48kHz <-> | SRC | <------> | SSI | <-----> | codec | 34 + * 44.1kHz <-> +-----+ +-----+ +-------+ 35 + * ... 36 + * 37 + */ 33 38 34 39 #define rsnd_mod_to_scu(_mod) \ 35 40 container_of((_mod), struct rsnd_scu, mod) ··· 49 36 ((pos) = (struct rsnd_scu *)(priv)->scu + i); \ 50 37 i++) 51 38 52 - static int rsnd_scu_set_route(struct rsnd_priv *priv, 39 + /* Gen1 only */ 40 + static int rsnd_src_set_route_if_gen1(struct rsnd_priv *priv, 53 41 struct rsnd_mod *mod, 54 42 struct rsnd_dai *rdai, 55 43 struct rsnd_dai_stream *io) ··· 69 55 { 0x3, 28, }, /* 7 */ 70 56 { 0x3, 30, }, /* 8 */ 71 57 }; 72 - 58 + struct rsnd_scu *scu = rsnd_mod_to_scu(mod); 73 59 u32 mask; 74 60 u32 val; 75 61 int shift; ··· 99 85 */ 100 86 shift = (id % 4) * 8; 101 87 mask = 0x1F << shift; 102 - if (8 == id) /* SRU8 is very special */ 88 + 89 + /* 90 + * ADG is used as source clock if SRC was used, 91 + * then, SSI WS is used as destination clock. 92 + * SSI WS is used as source clock if SRC is not used 93 + * (when playback, source/destination become reverse when capture) 94 + */ 95 + if (rsnd_scu_convert_rate(scu)) /* use ADG */ 96 + val = 0; 97 + else if (8 == id) /* use SSI WS, but SRU8 is special */ 103 98 val = id << shift; 104 - else 99 + else /* use SSI WS */ 105 100 val = (id + 1) << shift; 106 101 107 102 switch (id / 4) { ··· 128 105 return 0; 129 106 } 130 107 131 - static int rsnd_scu_set_mode(struct rsnd_priv *priv, 132 - struct rsnd_mod *mod, 133 - struct rsnd_dai *rdai, 134 - struct rsnd_dai_stream *io) 108 + unsigned int rsnd_scu_get_ssi_rate(struct rsnd_priv *priv, 109 + struct rsnd_mod *ssi_mod, 110 + struct snd_pcm_runtime *runtime) 135 111 { 136 - int id = rsnd_mod_id(mod); 137 - u32 val; 112 + struct rsnd_scu *scu; 113 + unsigned int rate; 138 114 139 - if (rsnd_is_gen1(priv)) { 140 - val = (1 << id); 141 - rsnd_mod_bset(mod, SRC_CTRL, val, val); 142 - } 115 + /* this function is assuming SSI id = SCU id here */ 116 + scu = rsnd_mod_to_scu(rsnd_scu_mod_get(priv, rsnd_mod_id(ssi_mod))); 143 117 144 - return 0; 118 + /* 119 + * return convert rate if SRC is used, 120 + * otherwise, return runtime->rate as usual 121 + */ 122 + rate = rsnd_scu_convert_rate(scu); 123 + if (!rate) 124 + rate = runtime->rate; 125 + 126 + return rate; 145 127 } 146 128 147 - static int rsnd_scu_set_hpbif(struct rsnd_priv *priv, 129 + static int rsnd_scu_convert_rate_ctrl(struct rsnd_priv *priv, 148 130 struct rsnd_mod *mod, 149 131 struct rsnd_dai *rdai, 150 132 struct rsnd_dai_stream *io) 151 133 { 152 134 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 135 + struct rsnd_scu *scu = rsnd_mod_to_scu(mod); 136 + u32 convert_rate = rsnd_scu_convert_rate(scu); 153 137 u32 adinr = runtime->channels; 154 138 139 + /* set/clear soft reset */ 140 + rsnd_mod_write(mod, SRC_SWRSR, 0); 141 + rsnd_mod_write(mod, SRC_SWRSR, 1); 142 + 143 + /* Initialize the operation of the SRC internal circuits */ 144 + rsnd_mod_write(mod, SRC_SRCIR, 1); 145 + 146 + /* Set channel number and output bit length */ 155 147 switch (runtime->sample_bits) { 156 148 case 16: 157 149 adinr |= OTBL_16; ··· 177 139 default: 178 140 return -EIO; 179 141 } 142 + rsnd_mod_write(mod, SRC_ADINR, adinr); 180 143 144 + if (convert_rate) { 145 + u32 fsrate = 0x0400000 / convert_rate * runtime->rate; 146 + int ret; 147 + 148 + /* Enable the initial value of IFS */ 149 + rsnd_mod_write(mod, SRC_IFSCR, 1); 150 + 151 + /* Set initial value of IFS */ 152 + rsnd_mod_write(mod, SRC_IFSVR, fsrate); 153 + 154 + /* Select SRC mode (fixed value) */ 155 + rsnd_mod_write(mod, SRC_SRCCR, 0x00010110); 156 + 157 + /* Set the restriction value of the FS ratio (98%) */ 158 + rsnd_mod_write(mod, SRC_MNFSR, fsrate / 100 * 98); 159 + 160 + if (rsnd_is_gen1(priv)) { 161 + /* no SRC_BFSSR settings, since SRC_SRCCR::BUFMD is 0 */ 162 + } 163 + 164 + /* set convert clock */ 165 + ret = rsnd_adg_set_convert_clk(priv, mod, 166 + runtime->rate, 167 + convert_rate); 168 + if (ret < 0) 169 + return ret; 170 + } 171 + 172 + /* Cancel the initialization and operate the SRC function */ 173 + rsnd_mod_write(mod, SRC_SRCIR, 0); 174 + 175 + /* use DMA transfer */ 181 176 rsnd_mod_write(mod, BUSIF_MODE, 1); 182 - rsnd_mod_write(mod, BUSIF_ADINR, adinr); 177 + 178 + return 0; 179 + } 180 + 181 + static int rsnd_scu_transfer_start(struct rsnd_priv *priv, 182 + struct rsnd_mod *mod, 183 + struct rsnd_dai *rdai, 184 + struct rsnd_dai_stream *io) 185 + { 186 + struct rsnd_scu *scu = rsnd_mod_to_scu(mod); 187 + int id = rsnd_mod_id(mod); 188 + u32 val; 189 + 190 + if (rsnd_is_gen1(priv)) { 191 + val = (1 << id); 192 + rsnd_mod_bset(mod, SRC_ROUTE_CTRL, val, val); 193 + } 194 + 195 + if (rsnd_scu_convert_rate(scu)) 196 + rsnd_mod_write(mod, SRC_ROUTE_MODE0, 1); 197 + 198 + return 0; 199 + } 200 + 201 + static int rsnd_scu_transfer_stop(struct rsnd_priv *priv, 202 + struct rsnd_mod *mod, 203 + struct rsnd_dai *rdai, 204 + struct rsnd_dai_stream *io) 205 + { 206 + struct rsnd_scu *scu = rsnd_mod_to_scu(mod); 207 + int id = rsnd_mod_id(mod); 208 + u32 mask; 209 + 210 + if (rsnd_is_gen1(priv)) { 211 + mask = (1 << id); 212 + rsnd_mod_bset(mod, SRC_ROUTE_CTRL, mask, 0); 213 + } 214 + 215 + if (rsnd_scu_convert_rate(scu)) 216 + rsnd_mod_write(mod, SRC_ROUTE_MODE0, 0); 183 217 184 218 return 0; 185 219 } ··· 269 159 struct rsnd_dai_stream *io) 270 160 { 271 161 struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 162 + struct rsnd_scu *scu = rsnd_mod_to_scu(mod); 272 163 struct device *dev = rsnd_priv_to_dev(priv); 273 164 int ret; 274 165 ··· 284 173 return 0; 285 174 } 286 175 176 + clk_enable(scu->clk); 177 + 287 178 /* it use DMA transter */ 288 - ret = rsnd_scu_set_route(priv, mod, rdai, io); 179 + 180 + ret = rsnd_src_set_route_if_gen1(priv, mod, rdai, io); 289 181 if (ret < 0) 290 182 return ret; 291 183 292 - ret = rsnd_scu_set_mode(priv, mod, rdai, io); 184 + ret = rsnd_scu_convert_rate_ctrl(priv, mod, rdai, io); 293 185 if (ret < 0) 294 186 return ret; 295 187 296 - ret = rsnd_scu_set_hpbif(priv, mod, rdai, io); 188 + ret = rsnd_scu_transfer_start(priv, mod, rdai, io); 297 189 if (ret < 0) 298 190 return ret; 299 191 ··· 305 191 return 0; 306 192 } 307 193 194 + static int rsnd_scu_stop(struct rsnd_mod *mod, 195 + struct rsnd_dai *rdai, 196 + struct rsnd_dai_stream *io) 197 + { 198 + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 199 + struct rsnd_scu *scu = rsnd_mod_to_scu(mod); 200 + 201 + if (!rsnd_scu_hpbif_is_enable(mod)) 202 + return 0; 203 + 204 + rsnd_scu_transfer_stop(priv, mod, rdai, io); 205 + 206 + clk_disable(scu->clk); 207 + 208 + return 0; 209 + } 210 + 308 211 static struct rsnd_mod_ops rsnd_scu_ops = { 309 212 .name = "scu", 310 213 .start = rsnd_scu_start, 214 + .stop = rsnd_scu_stop, 311 215 }; 312 216 313 217 struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id) ··· 342 210 { 343 211 struct device *dev = rsnd_priv_to_dev(priv); 344 212 struct rsnd_scu *scu; 213 + struct clk *clk; 214 + char name[RSND_SCU_NAME_SIZE]; 345 215 int i, nr; 346 216 347 217 /* ··· 360 226 priv->scu = scu; 361 227 362 228 for_each_rsnd_scu(scu, priv, i) { 229 + snprintf(name, RSND_SCU_NAME_SIZE, "scu.%d", i); 230 + 231 + clk = devm_clk_get(dev, name); 232 + if (IS_ERR(clk)) 233 + return PTR_ERR(clk); 234 + 363 235 rsnd_mod_init(priv, &scu->mod, 364 236 &rsnd_scu_ops, i); 365 237 scu->info = &info->scu_info[i]; 238 + scu->clk = clk; 366 239 367 240 dev_dbg(dev, "SCU%d probed\n", i); 368 241 }
+10 -9
sound/soc/sh/rcar/ssi.c
··· 187 187 } 188 188 189 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 192 struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod); 193 + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 193 194 struct device *dev = rsnd_priv_to_dev(priv); 194 195 int i, j, ret; 195 196 int adg_clk_div_table[] = { ··· 200 199 1, 2, 4, 8, 16, 6, 12, 201 200 }; 202 201 unsigned int main_rate; 202 + unsigned int rate = rsnd_scu_get_ssi_rate(priv, &ssi->mod, runtime); 203 203 204 204 /* 205 205 * Find best clock, and try to start ADG ··· 211 209 /* 212 210 * this driver is assuming that 213 211 * system word is 64fs (= 2 x 32bit) 214 - * see rsnd_ssi_start() 212 + * see rsnd_ssi_init() 215 213 */ 216 214 main_rate = rate / adg_clk_div_table[i] 217 215 * 32 * 2 * ssi_clk_mul_table[j]; ··· 253 251 clk_enable(ssi->clk); 254 252 255 253 if (rsnd_rdai_is_clk_master(rdai)) { 256 - struct snd_pcm_runtime *runtime; 257 - 258 - runtime = rsnd_io_to_runtime(io); 259 - 260 254 if (rsnd_ssi_clk_from_parent(ssi)) 261 255 rsnd_ssi_hw_start(ssi->parent, rdai, io); 262 256 else 263 - rsnd_ssi_master_clk_start(ssi, runtime->rate); 257 + rsnd_ssi_master_clk_start(ssi, io); 264 258 } 265 259 } 266 260 ··· 455 457 /* enable PIO IRQ */ 456 458 ssi->cr_etc = UIEN | OIEN | DIEN; 457 459 460 + /* enable PIO interrupt if gen2 */ 461 + if (rsnd_is_gen2(priv)) 462 + rsnd_mod_write(&ssi->mod, INT_ENABLE, 0x0f000000); 463 + 458 464 rsnd_ssi_hw_start(ssi, rdai, io); 459 465 460 466 dev_dbg(dev, "%s.%d start\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); ··· 652 650 653 651 snprintf(name, RSND_SSI_NAME_SIZE, "ssi.%d", i); 654 652 655 - clk = clk_get(dev, name); 653 + clk = devm_clk_get(dev, name); 656 654 if (IS_ERR(clk)) 657 655 return PTR_ERR(clk); 658 656 ··· 713 711 int i; 714 712 715 713 for_each_rsnd_ssi(ssi, priv, i) { 716 - clk_put(ssi->clk); 717 714 if (rsnd_ssi_dma_available(ssi)) 718 715 rsnd_dma_quit(priv, rsnd_mod_to_dma(&ssi->mod)); 719 716 }
+13 -4
sound/soc/spear/spdif_in.c
··· 18 18 #include <linux/ioport.h> 19 19 #include <linux/module.h> 20 20 #include <linux/platform_device.h> 21 + #include <sound/dmaengine_pcm.h> 21 22 #include <sound/pcm.h> 22 23 #include <sound/pcm_params.h> 23 24 #include <sound/soc.h> 24 25 #include <sound/spear_dma.h> 25 26 #include <sound/spear_spdif.h> 26 27 #include "spdif_in_regs.h" 28 + #include "spear_pcm.h" 27 29 28 30 struct spdif_in_params { 29 31 u32 format; ··· 39 37 struct device *dev; 40 38 void (*reset_perip)(void); 41 39 int irq; 40 + struct snd_dmaengine_dai_dma_data dma_params_rx; 41 + struct snd_dmaengine_pcm_config config; 42 42 }; 43 43 44 44 static void spdif_in_configure(struct spdif_in_dev *host) ··· 57 53 { 58 54 struct spdif_in_dev *host = snd_soc_dai_get_drvdata(dai); 59 55 60 - dai->capture_dma_data = &host->dma_params; 56 + host->dma_params_rx.filter_data = &host->dma_params; 57 + dai->capture_dma_data = &host->dma_params_rx; 61 58 62 59 return 0; 63 60 } ··· 249 244 host->dma_params.addr = res_fifo->start; 250 245 host->dma_params.max_burst = 16; 251 246 host->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 252 - host->dma_params.filter = pdata->filter; 253 247 host->reset_perip = pdata->reset_perip; 254 248 255 249 host->dev = &pdev->dev; ··· 261 257 return ret; 262 258 } 263 259 264 - return devm_snd_soc_register_component(&pdev->dev, &spdif_in_component, 265 - &spdif_in_dai, 1); 260 + ret = devm_snd_soc_register_component(&pdev->dev, &spdif_in_component, 261 + &spdif_in_dai, 1); 262 + if (ret) 263 + return ret; 264 + 265 + return devm_spear_pcm_platform_register(&pdev->dev, &host->config, 266 + pdata->filter); 266 267 } 267 268 268 269 static struct platform_driver spdif_in_driver = {
+14 -4
sound/soc/spear/spdif_out.c
··· 18 18 #include <linux/ioport.h> 19 19 #include <linux/module.h> 20 20 #include <linux/platform_device.h> 21 + #include <sound/dmaengine_pcm.h> 21 22 #include <sound/soc.h> 22 23 #include <sound/spear_dma.h> 23 24 #include <sound/spear_spdif.h> 24 25 #include "spdif_out_regs.h" 26 + #include "spear_pcm.h" 25 27 26 28 struct spdif_out_params { 27 29 u32 rate; ··· 37 35 struct spdif_out_params saved_params; 38 36 u32 running; 39 37 void __iomem *io_base; 38 + struct snd_dmaengine_dai_dma_data dma_params_tx; 39 + struct snd_dmaengine_pcm_config config; 40 40 }; 41 41 42 42 static void spdif_out_configure(struct spdif_out_dev *host) ··· 248 244 { 249 245 struct spdif_out_dev *host = snd_soc_dai_get_drvdata(dai); 250 246 251 - dai->playback_dma_data = &host->dma_params; 247 + host->dma_params_tx.filter_data = &host->dma_params; 248 + dai->playback_dma_data = &host->dma_params_tx; 252 249 253 250 return snd_soc_add_dai_controls(dai, spdif_out_controls, 254 251 ARRAY_SIZE(spdif_out_controls)); ··· 285 280 struct spdif_out_dev *host; 286 281 struct spear_spdif_platform_data *pdata; 287 282 struct resource *res; 283 + int ret; 288 284 289 285 host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); 290 286 if (!host) { ··· 308 302 host->dma_params.addr = res->start + SPDIF_OUT_FIFO_DATA; 309 303 host->dma_params.max_burst = 16; 310 304 host->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 311 - host->dma_params.filter = pdata->filter; 312 305 313 306 dev_set_drvdata(&pdev->dev, host); 314 307 315 - return devm_snd_soc_register_component(&pdev->dev, &spdif_out_component, 316 - &spdif_out_dai, 1); 308 + ret = devm_snd_soc_register_component(&pdev->dev, &spdif_out_component, 309 + &spdif_out_dai, 1); 310 + if (ret) 311 + return ret; 312 + 313 + return devm_spear_pcm_platform_register(&pdev->dev, &host->config, 314 + pdata->filter); 317 315 } 318 316 319 317 #ifdef CONFIG_PM
+9 -33
sound/soc/spear/spear_pcm.c
··· 18 18 #include <sound/pcm.h> 19 19 #include <sound/soc.h> 20 20 #include <sound/spear_dma.h> 21 + #include "spear_pcm.h" 21 22 22 23 static const struct snd_pcm_hardware spear_pcm_hardware = { 23 24 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | ··· 32 31 .fifo_size = 0, /* fifo size in bytes */ 33 32 }; 34 33 35 - static struct dma_chan *spear_pcm_request_chan(struct snd_soc_pcm_runtime *rtd, 36 - struct snd_pcm_substream *substream) 37 - { 38 - struct spear_dma_data *dma_data; 39 - 40 - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 41 - 42 - return snd_dmaengine_pcm_request_channel(dma_data->filter, dma_data); 43 - } 44 - 45 34 static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = { 46 35 .pcm_hardware = &spear_pcm_hardware, 47 - .compat_request_channel = spear_pcm_request_chan, 48 36 .prealloc_buffer_size = 16 * 1024, 49 37 }; 50 38 51 - static int spear_soc_platform_probe(struct platform_device *pdev) 39 + int devm_spear_pcm_platform_register(struct device *dev, 40 + struct snd_dmaengine_pcm_config *config, 41 + bool (*filter)(struct dma_chan *chan, void *slave)) 52 42 { 53 - return snd_dmaengine_pcm_register(&pdev->dev, 54 - &spear_dmaengine_pcm_config, 43 + *config = spear_dmaengine_pcm_config; 44 + config->compat_filter_fn = filter; 45 + 46 + return snd_dmaengine_pcm_register(dev, config, 55 47 SND_DMAENGINE_PCM_FLAG_NO_DT | 56 48 SND_DMAENGINE_PCM_FLAG_COMPAT); 57 49 } 58 - 59 - static int spear_soc_platform_remove(struct platform_device *pdev) 60 - { 61 - snd_dmaengine_pcm_unregister(&pdev->dev); 62 - return 0; 63 - } 64 - 65 - static struct platform_driver spear_pcm_driver = { 66 - .driver = { 67 - .name = "spear-pcm-audio", 68 - .owner = THIS_MODULE, 69 - }, 70 - 71 - .probe = spear_soc_platform_probe, 72 - .remove = spear_soc_platform_remove, 73 - }; 74 - 75 - module_platform_driver(spear_pcm_driver); 50 + EXPORT_SYMBOL_GPL(devm_spear_pcm_platform_register); 76 51 77 52 MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>"); 78 53 MODULE_DESCRIPTION("SPEAr PCM DMA module"); 79 54 MODULE_LICENSE("GPL"); 80 - MODULE_ALIAS("platform:spear-pcm-audio");
+24
sound/soc/spear/spear_pcm.h
··· 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
+10
sound/soc/tegra/Kconfig
··· 116 116 help 117 117 Say Y or M here if you want to add support for SoC audio on the 118 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.
+2
sound/soc/tegra/Makefile
··· 24 24 snd-soc-tegra-wm9712-objs := tegra_wm9712.o 25 25 snd-soc-tegra-trimslice-objs := trimslice.o 26 26 snd-soc-tegra-alc5632-objs := tegra_alc5632.o 27 + snd-soc-tegra-max98090-objs := tegra_max98090.o 27 28 28 29 obj-$(CONFIG_SND_SOC_TEGRA_RT5640) += snd-soc-tegra-rt5640.o 29 30 obj-$(CONFIG_SND_SOC_TEGRA_WM8753) += snd-soc-tegra-wm8753.o ··· 32 31 obj-$(CONFIG_SND_SOC_TEGRA_WM9712) += snd-soc-tegra-wm9712.o 33 32 obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += snd-soc-tegra-trimslice.o 34 33 obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o 34 + obj-$(CONFIG_SND_SOC_TEGRA_MAX98090) += snd-soc-tegra-max98090.o
+4 -2
sound/soc/tegra/tegra20_ac97.c
··· 404 404 ret = snd_soc_set_ac97_ops(&tegra20_ac97_ops); 405 405 if (ret) { 406 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 410 ret = snd_soc_register_component(&pdev->dev, &tegra20_ac97_component, ··· 412 412 if (ret) { 413 413 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); 414 414 ret = -ENOMEM; 415 - goto err_asoc_utils_fini; 415 + goto err_clk_disable_unprepare; 416 416 } 417 417 418 418 ret = tegra_pcm_platform_register(&pdev->dev); ··· 428 428 429 429 err_unregister_component: 430 430 snd_soc_unregister_component(&pdev->dev); 431 + err_clk_disable_unprepare: 432 + clk_disable_unprepare(ac97->clk_ac97); 431 433 err_asoc_utils_fini: 432 434 tegra_asoc_utils_fini(&ac97->util_data); 433 435 err_clk_put:
+275
sound/soc/tegra/tegra_max98090.c
··· 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);
-3
sound/soc/tegra/tegra_pcm.c
··· 42 42 .info = SNDRV_PCM_INFO_MMAP | 43 43 SNDRV_PCM_INFO_MMAP_VALID | 44 44 SNDRV_PCM_INFO_INTERLEAVED, 45 - .formats = SNDRV_PCM_FMTBIT_S16_LE, 46 - .channels_min = 2, 47 - .channels_max = 2, 48 45 .period_bytes_min = 1024, 49 46 .period_bytes_max = PAGE_SIZE, 50 47 .periods_min = 2,
-1
sound/soc/tegra/tegra_wm9712.c
··· 55 55 static struct snd_soc_dai_link tegra_wm9712_dai = { 56 56 .name = "AC97 HiFi", 57 57 .stream_name = "AC97 HiFi", 58 - .cpu_dai_name = "tegra20-ac97", 59 58 .codec_dai_name = "wm9712-hifi", 60 59 .codec_name = "wm9712-codec", 61 60 .init = tegra_wm9712_init,
-5
sound/soc/txx9/txx9aclc.c
··· 40 40 .info = SNDRV_PCM_INFO_INTERLEAVED | 41 41 SNDRV_PCM_INFO_BATCH | 42 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 43 .period_bytes_min = 1024, 49 44 .period_bytes_max = 8 * 1024, 50 45 .periods_min = 2,