aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2015-04-12 14:48:29 -0400
committerMark Brown <broonie@kernel.org>2015-04-12 14:48:29 -0400
commit89a88dd3d6823f46bfb1405c4b358f89d5526cd6 (patch)
treea1b6550b08da296aa14e8f59fe97ada6c67d5f63
parent3eaecb4b50693378bb55cc633992e7f72be35687 (diff)
parentd7e3281b52fea8917fb4a7a5b09df5e6a9d2850c (diff)
Merge tag 'asoc-v4.1' into asoc-next
ASoC: Changes for v4.1 A selection of changes for v4.1 so far. The main things are: - Move of jack registration to the card where it belongs. - Support for DAPM routes specified by both the machine driver and DT. # gpg: Signature made Thu 05 Mar 2015 01:10:27 GMT using RSA key ID 5D5487D0 # gpg: WARNING: digest algorithm MD5 is deprecated # gpg: please see https://gnupg.org/faq/weak-digest-algos.html for more information # gpg: Oops: keyid_from_fingerprint: no pubkey # gpg: Good signature from "Mark Brown <broonie@sirena.org.uk>" # gpg: aka "Mark Brown <broonie@debian.org>" # gpg: aka "Mark Brown <broonie@kernel.org>" # gpg: aka "Mark Brown <broonie@tardis.ed.ac.uk>" # gpg: aka "Mark Brown <broonie@linaro.org>" # gpg: aka "Mark Brown <Mark.Brown@linaro.org>"
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt1
-rw-r--r--include/sound/pcm_params.h7
-rw-r--r--include/sound/soc.h16
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.c111
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.h1
-rw-r--r--sound/soc/codecs/Kconfig18
-rw-r--r--sound/soc/codecs/Makefile4
-rw-r--r--sound/soc/codecs/adau1977.c17
-rw-r--r--sound/soc/codecs/cs35l32.c19
-rw-r--r--sound/soc/codecs/cs4265.c19
-rw-r--r--sound/soc/codecs/max98357a.c11
-rw-r--r--sound/soc/codecs/pcm512x.c178
-rw-r--r--sound/soc/codecs/rt286.c17
-rw-r--r--sound/soc/codecs/rt5670.h3
-rw-r--r--sound/soc/codecs/rt5677.c44
-rw-r--r--sound/soc/codecs/rt5677.h6
-rw-r--r--sound/soc/codecs/sn95031.c14
-rw-r--r--sound/soc/codecs/sn95031.h3
-rw-r--r--sound/soc/codecs/sta350.c30
-rw-r--r--sound/soc/codecs/tas2552.c13
-rw-r--r--sound/soc/codecs/wm8804-i2c.c64
-rw-r--r--sound/soc/codecs/wm8804-spi.c56
-rw-r--r--sound/soc/codecs/wm8804.c281
-rw-r--r--sound/soc/codecs/wm8804.h7
-rw-r--r--sound/soc/codecs/wm_adsp.c13
-rw-r--r--sound/soc/davinci/Kconfig18
-rw-r--r--sound/soc/davinci/Makefile2
-rw-r--r--sound/soc/davinci/davinci-i2s.c67
-rw-r--r--sound/soc/davinci/davinci-mcasp.c99
-rw-r--r--sound/soc/davinci/davinci-pcm.c861
-rw-r--r--sound/soc/davinci/davinci-pcm.h41
-rw-r--r--sound/soc/davinci/davinci-vcif.c55
-rw-r--r--sound/soc/fsl/fsl-asoc-card.c6
-rw-r--r--sound/soc/fsl/imx-es8328.c6
-rw-r--r--sound/soc/fsl/wm1133-ev1.c12
-rw-r--r--sound/soc/generic/simple-card.c20
-rw-r--r--sound/soc/intel/broadwell.c16
-rw-r--r--sound/soc/intel/byt-max98090.c11
-rw-r--r--sound/soc/intel/bytcr_dpcm_rt5640.c4
-rw-r--r--sound/soc/intel/cht_bsw_rt5645.c16
-rw-r--r--sound/soc/intel/cht_bsw_rt5672.c9
-rw-r--r--sound/soc/intel/haswell.c4
-rw-r--r--sound/soc/intel/mfld_machine.c24
-rw-r--r--sound/soc/intel/sst-mfld-platform-pcm.c60
-rw-r--r--sound/soc/intel/sst-mfld-platform.h1
-rw-r--r--sound/soc/intel/sst/sst.c128
-rw-r--r--sound/soc/intel/sst/sst.h12
-rw-r--r--sound/soc/intel/sst/sst_drv_interface.c65
-rw-r--r--sound/soc/intel/sst/sst_loader.c10
-rw-r--r--sound/soc/omap/Kconfig4
-rw-r--r--sound/soc/omap/ams-delta.c4
-rw-r--r--sound/soc/omap/omap-abe-twl6040.c10
-rw-r--r--sound/soc/omap/omap-pcm.c21
-rw-r--r--sound/soc/omap/omap-twl4030.c12
-rw-r--r--sound/soc/omap/rx51.c6
-rw-r--r--sound/soc/pxa/hx4700.c11
-rw-r--r--sound/soc/pxa/palm27x.c11
-rw-r--r--sound/soc/pxa/ttc-dkb.c15
-rw-r--r--sound/soc/pxa/z2.c10
-rw-r--r--sound/soc/samsung/h1940_uda1380.c9
-rw-r--r--sound/soc/samsung/littlemill.c12
-rw-r--r--sound/soc/samsung/lowland.c14
-rw-r--r--sound/soc/samsung/rx1950_uda1380.c9
-rw-r--r--sound/soc/samsung/smartq_wm8987.c11
-rw-r--r--sound/soc/samsung/speyside.c14
-rw-r--r--sound/soc/samsung/tobermory.c13
-rw-r--r--sound/soc/soc-core.c16
-rw-r--r--sound/soc/soc-jack.c42
-rw-r--r--sound/soc/soc-pcm.c1
-rw-r--r--sound/soc/tegra/tegra_alc5632.c9
-rw-r--r--sound/soc/tegra/tegra_max98090.c26
-rw-r--r--sound/soc/tegra/tegra_rt5640.c10
-rw-r--r--sound/soc/tegra/tegra_rt5677.c14
-rw-r--r--sound/soc/tegra/tegra_wm8903.c18
74 files changed, 1170 insertions, 1652 deletions
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt
index c949abc2992f..c3495beba358 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt
@@ -18,6 +18,7 @@ Required properties:
18 * Headphones 18 * Headphones
19 * Speakers 19 * Speakers
20 * Mic Jack 20 * Mic Jack
21 * Int Mic
21 22
22- nvidia,i2s-controller : The phandle of the Tegra I2S controller that's 23- nvidia,i2s-controller : The phandle of the Tegra I2S controller that's
23 connected to the CODEC. 24 connected to the CODEC.
diff --git a/include/sound/pcm_params.h b/include/sound/pcm_params.h
index 3c45f3924ba7..c704357775fc 100644
--- a/include/sound/pcm_params.h
+++ b/include/sound/pcm_params.h
@@ -366,4 +366,11 @@ static inline int params_physical_width(const struct snd_pcm_hw_params *p)
366 return snd_pcm_format_physical_width(params_format(p)); 366 return snd_pcm_format_physical_width(params_format(p));
367} 367}
368 368
369static inline void
370params_set_format(struct snd_pcm_hw_params *p, snd_pcm_format_t fmt)
371{
372 snd_mask_set(hw_param_mask(p, SNDRV_PCM_HW_PARAM_FORMAT),
373 (__force int)fmt);
374}
375
369#endif /* __SOUND_PCM_PARAMS_H */ 376#endif /* __SOUND_PCM_PARAMS_H */
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 0d1ade195628..bc6cfabc0e35 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -450,8 +450,10 @@ int soc_dai_hw_params(struct snd_pcm_substream *substream,
450 struct snd_soc_dai *dai); 450 struct snd_soc_dai *dai);
451 451
452/* Jack reporting */ 452/* Jack reporting */
453int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, 453int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
454 struct snd_soc_jack *jack); 454 struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
455 unsigned int num_pins);
456
455void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); 457void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
456int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, 458int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
457 struct snd_soc_jack_pin *pins); 459 struct snd_soc_jack_pin *pins);
@@ -659,7 +661,7 @@ struct snd_soc_jack_gpio {
659struct snd_soc_jack { 661struct snd_soc_jack {
660 struct mutex mutex; 662 struct mutex mutex;
661 struct snd_jack *jack; 663 struct snd_jack *jack;
662 struct snd_soc_codec *codec; 664 struct snd_soc_card *card;
663 struct list_head pins; 665 struct list_head pins;
664 int status; 666 int status;
665 struct blocking_notifier_head notifier; 667 struct blocking_notifier_head notifier;
@@ -954,6 +956,9 @@ struct snd_soc_dai_link {
954 unsigned int symmetric_channels:1; 956 unsigned int symmetric_channels:1;
955 unsigned int symmetric_samplebits:1; 957 unsigned int symmetric_samplebits:1;
956 958
959 /* Mark this pcm with non atomic ops */
960 bool nonatomic;
961
957 /* Do not create a PCM for this DAI link (Backend link) */ 962 /* Do not create a PCM for this DAI link (Backend link) */
958 unsigned int no_pcm:1; 963 unsigned int no_pcm:1;
959 964
@@ -1071,11 +1076,16 @@ struct snd_soc_card {
1071 1076
1072 /* 1077 /*
1073 * Card-specific routes and widgets. 1078 * Card-specific routes and widgets.
1079 * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
1074 */ 1080 */
1075 const struct snd_soc_dapm_widget *dapm_widgets; 1081 const struct snd_soc_dapm_widget *dapm_widgets;
1076 int num_dapm_widgets; 1082 int num_dapm_widgets;
1077 const struct snd_soc_dapm_route *dapm_routes; 1083 const struct snd_soc_dapm_route *dapm_routes;
1078 int num_dapm_routes; 1084 int num_dapm_routes;
1085 const struct snd_soc_dapm_widget *of_dapm_widgets;
1086 int num_of_dapm_widgets;
1087 const struct snd_soc_dapm_route *of_dapm_routes;
1088 int num_of_dapm_routes;
1079 bool fully_routed; 1089 bool fully_routed;
1080 1090
1081 struct work_struct deferred_resume_work; 1091 struct work_struct deferred_resume_work;
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index fb0b7e8b08ff..841d05946b88 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -187,6 +187,94 @@ static irqreturn_t atmel_ssc_interrupt(int irq, void *dev_id)
187 return IRQ_HANDLED; 187 return IRQ_HANDLED;
188} 188}
189 189
190/*
191 * When the bit clock is input, limit the maximum rate according to the
192 * Serial Clock Ratio Considerations section from the SSC documentation:
193 *
194 * The Transmitter and the Receiver can be programmed to operate
195 * with the clock signals provided on either the TK or RK pins.
196 * This allows the SSC to support many slave-mode data transfers.
197 * In this case, the maximum clock speed allowed on the RK pin is:
198 * - Peripheral clock divided by 2 if Receiver Frame Synchro is input
199 * - Peripheral clock divided by 3 if Receiver Frame Synchro is output
200 * In addition, the maximum clock speed allowed on the TK pin is:
201 * - Peripheral clock divided by 6 if Transmit Frame Synchro is input
202 * - Peripheral clock divided by 2 if Transmit Frame Synchro is output
203 *
204 * When the bit clock is output, limit the rate according to the
205 * SSC divider restrictions.
206 */
207static int atmel_ssc_hw_rule_rate(struct snd_pcm_hw_params *params,
208 struct snd_pcm_hw_rule *rule)
209{
210 struct atmel_ssc_info *ssc_p = rule->private;
211 struct ssc_device *ssc = ssc_p->ssc;
212 struct snd_interval *i = hw_param_interval(params, rule->var);
213 struct snd_interval t;
214 struct snd_ratnum r = {
215 .den_min = 1,
216 .den_max = 4095,
217 .den_step = 1,
218 };
219 unsigned int num = 0, den = 0;
220 int frame_size;
221 int mck_div = 2;
222 int ret;
223
224 frame_size = snd_soc_params_to_frame_size(params);
225 if (frame_size < 0)
226 return frame_size;
227
228 switch (ssc_p->daifmt & SND_SOC_DAIFMT_MASTER_MASK) {
229 case SND_SOC_DAIFMT_CBM_CFS:
230 if ((ssc_p->dir_mask & SSC_DIR_MASK_CAPTURE)
231 && ssc->clk_from_rk_pin)
232 /* Receiver Frame Synchro (i.e. capture)
233 * is output (format is _CFS) and the RK pin
234 * is used for input (format is _CBM_).
235 */
236 mck_div = 3;
237 break;
238
239 case SND_SOC_DAIFMT_CBM_CFM:
240 if ((ssc_p->dir_mask & SSC_DIR_MASK_PLAYBACK)
241 && !ssc->clk_from_rk_pin)
242 /* Transmit Frame Synchro (i.e. playback)
243 * is input (format is _CFM) and the TK pin
244 * is used for input (format _CBM_ but not
245 * using the RK pin).
246 */
247 mck_div = 6;
248 break;
249 }
250
251 switch (ssc_p->daifmt & SND_SOC_DAIFMT_MASTER_MASK) {
252 case SND_SOC_DAIFMT_CBS_CFS:
253 r.num = ssc_p->mck_rate / mck_div / frame_size;
254
255 ret = snd_interval_ratnum(i, 1, &r, &num, &den);
256 if (ret >= 0 && den && rule->var == SNDRV_PCM_HW_PARAM_RATE) {
257 params->rate_num = num;
258 params->rate_den = den;
259 }
260 break;
261
262 case SND_SOC_DAIFMT_CBM_CFS:
263 case SND_SOC_DAIFMT_CBM_CFM:
264 t.min = 8000;
265 t.max = ssc_p->mck_rate / mck_div / frame_size;
266 t.openmin = t.openmax = 0;
267 t.integer = 0;
268 ret = snd_interval_refine(i, &t);
269 break;
270
271 default:
272 ret = -EINVAL;
273 break;
274 }
275
276 return ret;
277}
190 278
191/*-------------------------------------------------------------------------*\ 279/*-------------------------------------------------------------------------*\
192 * DAI functions 280 * DAI functions
@@ -200,6 +288,7 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream,
200 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id]; 288 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id];
201 struct atmel_pcm_dma_params *dma_params; 289 struct atmel_pcm_dma_params *dma_params;
202 int dir, dir_mask; 290 int dir, dir_mask;
291 int ret;
203 292
204 pr_debug("atmel_ssc_startup: SSC_SR=0x%u\n", 293 pr_debug("atmel_ssc_startup: SSC_SR=0x%u\n",
205 ssc_readl(ssc_p->ssc->regs, SR)); 294 ssc_readl(ssc_p->ssc->regs, SR));
@@ -207,6 +296,7 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream,
207 /* Enable PMC peripheral clock for this SSC */ 296 /* Enable PMC peripheral clock for this SSC */
208 pr_debug("atmel_ssc_dai: Starting clock\n"); 297 pr_debug("atmel_ssc_dai: Starting clock\n");
209 clk_enable(ssc_p->ssc->clk); 298 clk_enable(ssc_p->ssc->clk);
299 ssc_p->mck_rate = clk_get_rate(ssc_p->ssc->clk);
210 300
211 /* Reset the SSC to keep it at a clean status */ 301 /* Reset the SSC to keep it at a clean status */
212 ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); 302 ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST));
@@ -219,6 +309,17 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream,
219 dir_mask = SSC_DIR_MASK_CAPTURE; 309 dir_mask = SSC_DIR_MASK_CAPTURE;
220 } 310 }
221 311
312 ret = snd_pcm_hw_rule_add(substream->runtime, 0,
313 SNDRV_PCM_HW_PARAM_RATE,
314 atmel_ssc_hw_rule_rate,
315 ssc_p,
316 SNDRV_PCM_HW_PARAM_FRAME_BITS,
317 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
318 if (ret < 0) {
319 dev_err(dai->dev, "Failed to specify rate rule: %d\n", ret);
320 return ret;
321 }
322
222 dma_params = &ssc_dma_params[dai->id][dir]; 323 dma_params = &ssc_dma_params[dai->id][dir];
223 dma_params->ssc = ssc_p->ssc; 324 dma_params->ssc = ssc_p->ssc;
224 dma_params->substream = substream; 325 dma_params->substream = substream;
@@ -783,8 +884,6 @@ static int atmel_ssc_resume(struct snd_soc_dai *cpu_dai)
783# define atmel_ssc_resume NULL 884# define atmel_ssc_resume NULL
784#endif /* CONFIG_PM */ 885#endif /* CONFIG_PM */
785 886
786#define ATMEL_SSC_RATES (SNDRV_PCM_RATE_8000_96000)
787
788#define ATMEL_SSC_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |\ 887#define ATMEL_SSC_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |\
789 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 888 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
790 889
@@ -804,12 +903,16 @@ static struct snd_soc_dai_driver atmel_ssc_dai = {
804 .playback = { 903 .playback = {
805 .channels_min = 1, 904 .channels_min = 1,
806 .channels_max = 2, 905 .channels_max = 2,
807 .rates = ATMEL_SSC_RATES, 906 .rates = SNDRV_PCM_RATE_CONTINUOUS,
907 .rate_min = 8000,
908 .rate_max = 384000,
808 .formats = ATMEL_SSC_FORMATS,}, 909 .formats = ATMEL_SSC_FORMATS,},
809 .capture = { 910 .capture = {
810 .channels_min = 1, 911 .channels_min = 1,
811 .channels_max = 2, 912 .channels_max = 2,
812 .rates = ATMEL_SSC_RATES, 913 .rates = SNDRV_PCM_RATE_CONTINUOUS,
914 .rate_min = 8000,
915 .rate_max = 384000,
813 .formats = ATMEL_SSC_FORMATS,}, 916 .formats = ATMEL_SSC_FORMATS,},
814 .ops = &atmel_ssc_dai_ops, 917 .ops = &atmel_ssc_dai_ops,
815}; 918};
diff --git a/sound/soc/atmel/atmel_ssc_dai.h b/sound/soc/atmel/atmel_ssc_dai.h
index b1f08d511495..80b153857a88 100644
--- a/sound/soc/atmel/atmel_ssc_dai.h
+++ b/sound/soc/atmel/atmel_ssc_dai.h
@@ -115,6 +115,7 @@ struct atmel_ssc_info {
115 unsigned short rcmr_period; 115 unsigned short rcmr_period;
116 struct atmel_pcm_dma_params *dma_params[2]; 116 struct atmel_pcm_dma_params *dma_params[2];
117 struct atmel_ssc_state ssc_state; 117 struct atmel_ssc_state ssc_state;
118 unsigned long mck_rate;
118}; 119};
119 120
120int atmel_ssc_set_audio(int ssc_id); 121int atmel_ssc_set_audio(int ssc_id);
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index ea9f0e31f9d4..0bddd929837f 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -141,7 +141,8 @@ config SND_SOC_ALL_CODECS
141 select SND_SOC_WM8770 if SPI_MASTER 141 select SND_SOC_WM8770 if SPI_MASTER
142 select SND_SOC_WM8776 if SND_SOC_I2C_AND_SPI 142 select SND_SOC_WM8776 if SND_SOC_I2C_AND_SPI
143 select SND_SOC_WM8782 143 select SND_SOC_WM8782
144 select SND_SOC_WM8804 if SND_SOC_I2C_AND_SPI 144 select SND_SOC_WM8804_I2C if I2C
145 select SND_SOC_WM8804_SPI if SPI_MASTER
145 select SND_SOC_WM8900 if I2C 146 select SND_SOC_WM8900 if I2C
146 select SND_SOC_WM8903 if I2C 147 select SND_SOC_WM8903 if I2C
147 select SND_SOC_WM8904 if I2C 148 select SND_SOC_WM8904 if I2C
@@ -744,8 +745,19 @@ config SND_SOC_WM8782
744 tristate 745 tristate
745 746
746config SND_SOC_WM8804 747config SND_SOC_WM8804
747 tristate "Wolfson Microelectronics WM8804 S/PDIF transceiver" 748 tristate
748 depends on SND_SOC_I2C_AND_SPI 749
750config SND_SOC_WM8804_I2C
751 tristate "Wolfson Microelectronics WM8804 S/PDIF transceiver I2C"
752 depends on I2C
753 select SND_SOC_WM8804
754 select REGMAP_I2C
755
756config SND_SOC_WM8804_SPI
757 tristate "Wolfson Microelectronics WM8804 S/PDIF transceiver SPI"
758 depends on SPI_MASTER
759 select SND_SOC_WM8804
760 select REGMAP_SPI
749 761
750config SND_SOC_WM8900 762config SND_SOC_WM8900
751 tristate 763 tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 69b8666d187a..7acb6c174cb4 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -145,6 +145,8 @@ snd-soc-wm8770-objs := wm8770.o
145snd-soc-wm8776-objs := wm8776.o 145snd-soc-wm8776-objs := wm8776.o
146snd-soc-wm8782-objs := wm8782.o 146snd-soc-wm8782-objs := wm8782.o
147snd-soc-wm8804-objs := wm8804.o 147snd-soc-wm8804-objs := wm8804.o
148snd-soc-wm8804-i2c-objs := wm8804-i2c.o
149snd-soc-wm8804-spi-objs := wm8804-spi.o
148snd-soc-wm8900-objs := wm8900.o 150snd-soc-wm8900-objs := wm8900.o
149snd-soc-wm8903-objs := wm8903.o 151snd-soc-wm8903-objs := wm8903.o
150snd-soc-wm8904-objs := wm8904.o 152snd-soc-wm8904-objs := wm8904.o
@@ -323,6 +325,8 @@ obj-$(CONFIG_SND_SOC_WM8770) += snd-soc-wm8770.o
323obj-$(CONFIG_SND_SOC_WM8776) += snd-soc-wm8776.o 325obj-$(CONFIG_SND_SOC_WM8776) += snd-soc-wm8776.o
324obj-$(CONFIG_SND_SOC_WM8782) += snd-soc-wm8782.o 326obj-$(CONFIG_SND_SOC_WM8782) += snd-soc-wm8782.o
325obj-$(CONFIG_SND_SOC_WM8804) += snd-soc-wm8804.o 327obj-$(CONFIG_SND_SOC_WM8804) += snd-soc-wm8804.o
328obj-$(CONFIG_SND_SOC_WM8804_I2C) += snd-soc-wm8804-i2c.o
329obj-$(CONFIG_SND_SOC_WM8804_SPI) += snd-soc-wm8804-spi.o
326obj-$(CONFIG_SND_SOC_WM8900) += snd-soc-wm8900.o 330obj-$(CONFIG_SND_SOC_WM8900) += snd-soc-wm8900.o
327obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o 331obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o
328obj-$(CONFIG_SND_SOC_WM8904) += snd-soc-wm8904.o 332obj-$(CONFIG_SND_SOC_WM8904) += snd-soc-wm8904.o
diff --git a/sound/soc/codecs/adau1977.c b/sound/soc/codecs/adau1977.c
index 70ab35744aba..7ad8e156e2df 100644
--- a/sound/soc/codecs/adau1977.c
+++ b/sound/soc/codecs/adau1977.c
@@ -938,22 +938,15 @@ int adau1977_probe(struct device *dev, struct regmap *regmap,
938 adau1977->dvdd_reg = NULL; 938 adau1977->dvdd_reg = NULL;
939 } 939 }
940 940
941 adau1977->reset_gpio = devm_gpiod_get(dev, "reset"); 941 adau1977->reset_gpio = devm_gpiod_get_optional(dev, "reset",
942 if (IS_ERR(adau1977->reset_gpio)) { 942 GPIOD_OUT_LOW);
943 ret = PTR_ERR(adau1977->reset_gpio); 943 if (IS_ERR(adau1977->reset_gpio))
944 if (ret != -ENOENT && ret != -ENOSYS) 944 return PTR_ERR(adau1977->reset_gpio);
945 return PTR_ERR(adau1977->reset_gpio);
946 adau1977->reset_gpio = NULL;
947 }
948 945
949 dev_set_drvdata(dev, adau1977); 946 dev_set_drvdata(dev, adau1977);
950 947
951 if (adau1977->reset_gpio) { 948 if (adau1977->reset_gpio)
952 ret = gpiod_direction_output(adau1977->reset_gpio, 0);
953 if (ret)
954 return ret;
955 ndelay(100); 949 ndelay(100);
956 }
957 950
958 ret = adau1977_power_enable(adau1977); 951 ret = adau1977_power_enable(adau1977);
959 if (ret) 952 if (ret)
diff --git a/sound/soc/codecs/cs35l32.c b/sound/soc/codecs/cs35l32.c
index f2b8aad21274..60598b230341 100644
--- a/sound/soc/codecs/cs35l32.c
+++ b/sound/soc/codecs/cs35l32.c
@@ -437,20 +437,13 @@ static int cs35l32_i2c_probe(struct i2c_client *i2c_client,
437 } 437 }
438 438
439 /* Reset the Device */ 439 /* Reset the Device */
440 cs35l32->reset_gpio = devm_gpiod_get(&i2c_client->dev, 440 cs35l32->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev,
441 "reset-gpios"); 441 "reset", GPIOD_OUT_LOW);
442 if (IS_ERR(cs35l32->reset_gpio)) { 442 if (IS_ERR(cs35l32->reset_gpio))
443 ret = PTR_ERR(cs35l32->reset_gpio); 443 return PTR_ERR(cs35l32->reset_gpio);
444 if (ret != -ENOENT && ret != -ENOSYS) 444
445 return ret; 445 if (cs35l32->reset_gpio)
446
447 cs35l32->reset_gpio = NULL;
448 } else {
449 ret = gpiod_direction_output(cs35l32->reset_gpio, 0);
450 if (ret)
451 return ret;
452 gpiod_set_value_cansleep(cs35l32->reset_gpio, 1); 446 gpiod_set_value_cansleep(cs35l32->reset_gpio, 1);
453 }
454 447
455 /* initialize codec */ 448 /* initialize codec */
456 ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_AB, &reg); 449 ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_AB, &reg);
diff --git a/sound/soc/codecs/cs4265.c b/sound/soc/codecs/cs4265.c
index ce6086835ebd..cac48ddf3ba6 100644
--- a/sound/soc/codecs/cs4265.c
+++ b/sound/soc/codecs/cs4265.c
@@ -605,21 +605,14 @@ static int cs4265_i2c_probe(struct i2c_client *i2c_client,
605 return ret; 605 return ret;
606 } 606 }
607 607
608 cs4265->reset_gpio = devm_gpiod_get(&i2c_client->dev, 608 cs4265->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev,
609 "reset-gpios"); 609 "reset", GPIOD_OUT_LOW);
610 if (IS_ERR(cs4265->reset_gpio)) { 610 if (IS_ERR(cs4265->reset_gpio))
611 ret = PTR_ERR(cs4265->reset_gpio); 611 return PTR_ERR(cs4265->reset_gpio);
612 if (ret != -ENOENT && ret != -ENOSYS) 612
613 return ret; 613 if (cs4265->reset_gpio) {
614
615 cs4265->reset_gpio = NULL;
616 } else {
617 ret = gpiod_direction_output(cs4265->reset_gpio, 0);
618 if (ret)
619 return ret;
620 mdelay(1); 614 mdelay(1);
621 gpiod_set_value_cansleep(cs4265->reset_gpio, 1); 615 gpiod_set_value_cansleep(cs4265->reset_gpio, 1);
622
623 } 616 }
624 617
625 i2c_set_clientdata(i2c_client, cs4265); 618 i2c_set_clientdata(i2c_client, cs4265);
diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c
index e9e6efbc21dd..bf3e933ee895 100644
--- a/sound/soc/codecs/max98357a.c
+++ b/sound/soc/codecs/max98357a.c
@@ -26,8 +26,6 @@
26#include <sound/soc-dai.h> 26#include <sound/soc-dai.h>
27#include <sound/soc-dapm.h> 27#include <sound/soc-dapm.h>
28 28
29#define DRV_NAME "max98357a"
30
31static int max98357a_daiops_trigger(struct snd_pcm_substream *substream, 29static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
32 int cmd, struct snd_soc_dai *dai) 30 int cmd, struct snd_soc_dai *dai)
33{ 31{
@@ -87,9 +85,9 @@ static struct snd_soc_dai_ops max98357a_dai_ops = {
87}; 85};
88 86
89static struct snd_soc_dai_driver max98357a_dai_driver = { 87static struct snd_soc_dai_driver max98357a_dai_driver = {
90 .name = DRV_NAME, 88 .name = "HiFi",
91 .playback = { 89 .playback = {
92 .stream_name = DRV_NAME "-playback", 90 .stream_name = "HiFi Playback",
93 .formats = SNDRV_PCM_FMTBIT_S16 | 91 .formats = SNDRV_PCM_FMTBIT_S16 |
94 SNDRV_PCM_FMTBIT_S24 | 92 SNDRV_PCM_FMTBIT_S24 |
95 SNDRV_PCM_FMTBIT_S32, 93 SNDRV_PCM_FMTBIT_S32,
@@ -127,7 +125,7 @@ static int max98357a_platform_remove(struct platform_device *pdev)
127 125
128#ifdef CONFIG_OF 126#ifdef CONFIG_OF
129static const struct of_device_id max98357a_device_id[] = { 127static const struct of_device_id max98357a_device_id[] = {
130 { .compatible = "maxim," DRV_NAME, }, 128 { .compatible = "maxim,max98357a" },
131 {} 129 {}
132}; 130};
133MODULE_DEVICE_TABLE(of, max98357a_device_id); 131MODULE_DEVICE_TABLE(of, max98357a_device_id);
@@ -135,7 +133,7 @@ MODULE_DEVICE_TABLE(of, max98357a_device_id);
135 133
136static struct platform_driver max98357a_platform_driver = { 134static struct platform_driver max98357a_platform_driver = {
137 .driver = { 135 .driver = {
138 .name = DRV_NAME, 136 .name = "max98357a",
139 .of_match_table = of_match_ptr(max98357a_device_id), 137 .of_match_table = of_match_ptr(max98357a_device_id),
140 }, 138 },
141 .probe = max98357a_platform_probe, 139 .probe = max98357a_platform_probe,
@@ -145,4 +143,3 @@ module_platform_driver(max98357a_platform_driver);
145 143
146MODULE_DESCRIPTION("Maxim MAX98357A Codec Driver"); 144MODULE_DESCRIPTION("Maxim MAX98357A Codec Driver");
147MODULE_LICENSE("GPL v2"); 145MODULE_LICENSE("GPL v2");
148MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 8c09e3ffdcaa..5a30fdd0da00 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -54,6 +54,9 @@ struct pcm512x_priv {
54 int pll_d; 54 int pll_d;
55 int pll_p; 55 int pll_p;
56 unsigned long real_pll; 56 unsigned long real_pll;
57 unsigned long overclock_pll;
58 unsigned long overclock_dac;
59 unsigned long overclock_dsp;
57}; 60};
58 61
59/* 62/*
@@ -224,6 +227,90 @@ static bool pcm512x_volatile(struct device *dev, unsigned int reg)
224 } 227 }
225} 228}
226 229
230static int pcm512x_overclock_pll_get(struct snd_kcontrol *kcontrol,
231 struct snd_ctl_elem_value *ucontrol)
232{
233 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
234 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
235
236 ucontrol->value.integer.value[0] = pcm512x->overclock_pll;
237 return 0;
238}
239
240static int pcm512x_overclock_pll_put(struct snd_kcontrol *kcontrol,
241 struct snd_ctl_elem_value *ucontrol)
242{
243 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
244 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
245
246 switch (codec->dapm.bias_level) {
247 case SND_SOC_BIAS_OFF:
248 case SND_SOC_BIAS_STANDBY:
249 break;
250 default:
251 return -EBUSY;
252 }
253
254 pcm512x->overclock_pll = ucontrol->value.integer.value[0];
255 return 0;
256}
257
258static int pcm512x_overclock_dsp_get(struct snd_kcontrol *kcontrol,
259 struct snd_ctl_elem_value *ucontrol)
260{
261 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
262 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
263
264 ucontrol->value.integer.value[0] = pcm512x->overclock_dsp;
265 return 0;
266}
267
268static int pcm512x_overclock_dsp_put(struct snd_kcontrol *kcontrol,
269 struct snd_ctl_elem_value *ucontrol)
270{
271 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
272 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
273
274 switch (codec->dapm.bias_level) {
275 case SND_SOC_BIAS_OFF:
276 case SND_SOC_BIAS_STANDBY:
277 break;
278 default:
279 return -EBUSY;
280 }
281
282 pcm512x->overclock_dsp = ucontrol->value.integer.value[0];
283 return 0;
284}
285
286static int pcm512x_overclock_dac_get(struct snd_kcontrol *kcontrol,
287 struct snd_ctl_elem_value *ucontrol)
288{
289 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
290 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
291
292 ucontrol->value.integer.value[0] = pcm512x->overclock_dac;
293 return 0;
294}
295
296static int pcm512x_overclock_dac_put(struct snd_kcontrol *kcontrol,
297 struct snd_ctl_elem_value *ucontrol)
298{
299 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
300 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
301
302 switch (codec->dapm.bias_level) {
303 case SND_SOC_BIAS_OFF:
304 case SND_SOC_BIAS_STANDBY:
305 break;
306 default:
307 return -EBUSY;
308 }
309
310 pcm512x->overclock_dac = ucontrol->value.integer.value[0];
311 return 0;
312}
313
227static const DECLARE_TLV_DB_SCALE(digital_tlv, -10350, 50, 1); 314static const DECLARE_TLV_DB_SCALE(digital_tlv, -10350, 50, 1);
228static const DECLARE_TLV_DB_SCALE(analog_tlv, -600, 600, 0); 315static const DECLARE_TLV_DB_SCALE(analog_tlv, -600, 600, 0);
229static const DECLARE_TLV_DB_SCALE(boost_tlv, 0, 80, 0); 316static const DECLARE_TLV_DB_SCALE(boost_tlv, 0, 80, 0);
@@ -328,6 +415,13 @@ SOC_ENUM("Volume Ramp Up Rate", pcm512x_vnuf),
328SOC_ENUM("Volume Ramp Up Step", pcm512x_vnus), 415SOC_ENUM("Volume Ramp Up Step", pcm512x_vnus),
329SOC_ENUM("Volume Ramp Down Emergency Rate", pcm512x_vedf), 416SOC_ENUM("Volume Ramp Down Emergency Rate", pcm512x_vedf),
330SOC_ENUM("Volume Ramp Down Emergency Step", pcm512x_veds), 417SOC_ENUM("Volume Ramp Down Emergency Step", pcm512x_veds),
418
419SOC_SINGLE_EXT("Max Overclock PLL", SND_SOC_NOPM, 0, 20, 0,
420 pcm512x_overclock_pll_get, pcm512x_overclock_pll_put),
421SOC_SINGLE_EXT("Max Overclock DSP", SND_SOC_NOPM, 0, 40, 0,
422 pcm512x_overclock_dsp_get, pcm512x_overclock_dsp_put),
423SOC_SINGLE_EXT("Max Overclock DAC", SND_SOC_NOPM, 0, 40, 0,
424 pcm512x_overclock_dac_get, pcm512x_overclock_dac_put),
331}; 425};
332 426
333static const struct snd_soc_dapm_widget pcm512x_dapm_widgets[] = { 427static const struct snd_soc_dapm_widget pcm512x_dapm_widgets[] = {
@@ -346,6 +440,45 @@ static const struct snd_soc_dapm_route pcm512x_dapm_routes[] = {
346 { "OUTR", NULL, "DACR" }, 440 { "OUTR", NULL, "DACR" },
347}; 441};
348 442
443static unsigned long pcm512x_pll_max(struct pcm512x_priv *pcm512x)
444{
445 return 25000000 + 25000000 * pcm512x->overclock_pll / 100;
446}
447
448static unsigned long pcm512x_dsp_max(struct pcm512x_priv *pcm512x)
449{
450 return 50000000 + 50000000 * pcm512x->overclock_dsp / 100;
451}
452
453static unsigned long pcm512x_dac_max(struct pcm512x_priv *pcm512x,
454 unsigned long rate)
455{
456 return rate + rate * pcm512x->overclock_dac / 100;
457}
458
459static unsigned long pcm512x_sck_max(struct pcm512x_priv *pcm512x)
460{
461 if (!pcm512x->pll_out)
462 return 25000000;
463 return pcm512x_pll_max(pcm512x);
464}
465
466static unsigned long pcm512x_ncp_target(struct pcm512x_priv *pcm512x,
467 unsigned long dac_rate)
468{
469 /*
470 * If the DAC is not actually overclocked, use the good old
471 * NCP target rate...
472 */
473 if (dac_rate <= 6144000)
474 return 1536000;
475 /*
476 * ...but if the DAC is in fact overclocked, bump the NCP target
477 * rate to get the recommended dividers even when overclocking.
478 */
479 return pcm512x_dac_max(pcm512x, 1536000);
480}
481
349static const u32 pcm512x_dai_rates[] = { 482static const u32 pcm512x_dai_rates[] = {
350 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 483 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000,
351 88200, 96000, 176400, 192000, 384000, 484 88200, 96000, 176400, 192000, 384000,
@@ -359,6 +492,7 @@ static const struct snd_pcm_hw_constraint_list constraints_slave = {
359static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params, 492static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params,
360 struct snd_pcm_hw_rule *rule) 493 struct snd_pcm_hw_rule *rule)
361{ 494{
495 struct pcm512x_priv *pcm512x = rule->private;
362 struct snd_interval ranges[2]; 496 struct snd_interval ranges[2];
363 int frame_size; 497 int frame_size;
364 498
@@ -377,7 +511,7 @@ static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params,
377 */ 511 */
378 memset(ranges, 0, sizeof(ranges)); 512 memset(ranges, 0, sizeof(ranges));
379 ranges[0].min = 8000; 513 ranges[0].min = 8000;
380 ranges[0].max = 25000000 / frame_size / 2; 514 ranges[0].max = pcm512x_sck_max(pcm512x) / frame_size / 2;
381 ranges[1].min = DIV_ROUND_UP(16000000, frame_size); 515 ranges[1].min = DIV_ROUND_UP(16000000, frame_size);
382 ranges[1].max = 384000; 516 ranges[1].max = 384000;
383 break; 517 break;
@@ -408,7 +542,7 @@ static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream,
408 return snd_pcm_hw_rule_add(substream->runtime, 0, 542 return snd_pcm_hw_rule_add(substream->runtime, 0,
409 SNDRV_PCM_HW_PARAM_RATE, 543 SNDRV_PCM_HW_PARAM_RATE,
410 pcm512x_hw_rule_rate, 544 pcm512x_hw_rule_rate,
411 NULL, 545 pcm512x,
412 SNDRV_PCM_HW_PARAM_FRAME_BITS, 546 SNDRV_PCM_HW_PARAM_FRAME_BITS,
413 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 547 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
414 548
@@ -517,6 +651,8 @@ static unsigned long pcm512x_find_sck(struct snd_soc_dai *dai,
517 unsigned long bclk_rate) 651 unsigned long bclk_rate)
518{ 652{
519 struct device *dev = dai->dev; 653 struct device *dev = dai->dev;
654 struct snd_soc_codec *codec = dai->codec;
655 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
520 unsigned long sck_rate; 656 unsigned long sck_rate;
521 int pow2; 657 int pow2;
522 658
@@ -527,9 +663,10 @@ static unsigned long pcm512x_find_sck(struct snd_soc_dai *dai,
527 * as many factors of 2 as possible, as that makes it easier 663 * as many factors of 2 as possible, as that makes it easier
528 * to find a fast DAC rate 664 * to find a fast DAC rate
529 */ 665 */
530 pow2 = 1 << fls((25000000 - 16000000) / bclk_rate); 666 pow2 = 1 << fls((pcm512x_pll_max(pcm512x) - 16000000) / bclk_rate);
531 for (; pow2; pow2 >>= 1) { 667 for (; pow2; pow2 >>= 1) {
532 sck_rate = rounddown(25000000, bclk_rate * pow2); 668 sck_rate = rounddown(pcm512x_pll_max(pcm512x),
669 bclk_rate * pow2);
533 if (sck_rate >= 16000000) 670 if (sck_rate >= 16000000)
534 break; 671 break;
535 } 672 }
@@ -678,7 +815,7 @@ static unsigned long pcm512x_pllin_dac_rate(struct snd_soc_dai *dai,
678 return 0; /* futile, quit early */ 815 return 0; /* futile, quit early */
679 816
680 /* run DAC no faster than 6144000 Hz */ 817 /* run DAC no faster than 6144000 Hz */
681 for (dac_rate = rounddown(6144000, osr_rate); 818 for (dac_rate = rounddown(pcm512x_dac_max(pcm512x, 6144000), osr_rate);
682 dac_rate; 819 dac_rate;
683 dac_rate -= osr_rate) { 820 dac_rate -= osr_rate) {
684 821
@@ -805,7 +942,7 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai,
805 osr_rate = 16 * sample_rate; 942 osr_rate = 16 * sample_rate;
806 943
807 /* run DSP no faster than 50 MHz */ 944 /* run DSP no faster than 50 MHz */
808 dsp_div = mck_rate > 50000000 ? 2 : 1; 945 dsp_div = mck_rate > pcm512x_dsp_max(pcm512x) ? 2 : 1;
809 946
810 dac_rate = pcm512x_pllin_dac_rate(dai, osr_rate, pllin_rate); 947 dac_rate = pcm512x_pllin_dac_rate(dai, osr_rate, pllin_rate);
811 if (dac_rate) { 948 if (dac_rate) {
@@ -836,7 +973,8 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai,
836 dacsrc_rate = pllin_rate; 973 dacsrc_rate = pllin_rate;
837 } else { 974 } else {
838 /* run DAC no faster than 6144000 Hz */ 975 /* run DAC no faster than 6144000 Hz */
839 unsigned long dac_mul = 6144000 / osr_rate; 976 unsigned long dac_mul = pcm512x_dac_max(pcm512x, 6144000)
977 / osr_rate;
840 unsigned long sck_mul = sck_rate / osr_rate; 978 unsigned long sck_mul = sck_rate / osr_rate;
841 979
842 for (; dac_mul; dac_mul--) { 980 for (; dac_mul; dac_mul--) {
@@ -863,28 +1001,30 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai,
863 dacsrc_rate = sck_rate; 1001 dacsrc_rate = sck_rate;
864 } 1002 }
865 1003
1004 osr_div = DIV_ROUND_CLOSEST(dac_rate, osr_rate);
1005 if (osr_div > 128) {
1006 dev_err(dev, "Failed to find OSR divider\n");
1007 return -EINVAL;
1008 }
1009
866 dac_div = DIV_ROUND_CLOSEST(dacsrc_rate, dac_rate); 1010 dac_div = DIV_ROUND_CLOSEST(dacsrc_rate, dac_rate);
867 if (dac_div > 128) { 1011 if (dac_div > 128) {
868 dev_err(dev, "Failed to find DAC divider\n"); 1012 dev_err(dev, "Failed to find DAC divider\n");
869 return -EINVAL; 1013 return -EINVAL;
870 } 1014 }
1015 dac_rate = dacsrc_rate / dac_div;
871 1016
872 ncp_div = DIV_ROUND_CLOSEST(dacsrc_rate / dac_div, 1536000); 1017 ncp_div = DIV_ROUND_CLOSEST(dac_rate,
873 if (ncp_div > 128 || dacsrc_rate / dac_div / ncp_div > 2048000) { 1018 pcm512x_ncp_target(pcm512x, dac_rate));
1019 if (ncp_div > 128 || dac_rate / ncp_div > 2048000) {
874 /* run NCP no faster than 2048000 Hz, but why? */ 1020 /* run NCP no faster than 2048000 Hz, but why? */
875 ncp_div = DIV_ROUND_UP(dacsrc_rate / dac_div, 2048000); 1021 ncp_div = DIV_ROUND_UP(dac_rate, 2048000);
876 if (ncp_div > 128) { 1022 if (ncp_div > 128) {
877 dev_err(dev, "Failed to find NCP divider\n"); 1023 dev_err(dev, "Failed to find NCP divider\n");
878 return -EINVAL; 1024 return -EINVAL;
879 } 1025 }
880 } 1026 }
881 1027
882 osr_div = DIV_ROUND_CLOSEST(dac_rate, osr_rate);
883 if (osr_div > 128) {
884 dev_err(dev, "Failed to find OSR divider\n");
885 return -EINVAL;
886 }
887
888 idac = mck_rate / (dsp_div * sample_rate); 1028 idac = mck_rate / (dsp_div * sample_rate);
889 1029
890 ret = regmap_write(pcm512x->regmap, PCM512x_DSP_CLKDIV, dsp_div - 1); 1030 ret = regmap_write(pcm512x->regmap, PCM512x_DSP_CLKDIV, dsp_div - 1);
@@ -937,11 +1077,11 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai,
937 return ret; 1077 return ret;
938 } 1078 }
939 1079
940 if (sample_rate <= 48000) 1080 if (sample_rate <= pcm512x_dac_max(pcm512x, 48000))
941 fssp = PCM512x_FSSP_48KHZ; 1081 fssp = PCM512x_FSSP_48KHZ;
942 else if (sample_rate <= 96000) 1082 else if (sample_rate <= pcm512x_dac_max(pcm512x, 96000))
943 fssp = PCM512x_FSSP_96KHZ; 1083 fssp = PCM512x_FSSP_96KHZ;
944 else if (sample_rate <= 192000) 1084 else if (sample_rate <= pcm512x_dac_max(pcm512x, 192000))
945 fssp = PCM512x_FSSP_192KHZ; 1085 fssp = PCM512x_FSSP_192KHZ;
946 else 1086 else
947 fssp = PCM512x_FSSP_384KHZ; 1087 fssp = PCM512x_FSSP_384KHZ;
diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index 9b541e52da8c..826037090c83 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -395,9 +395,20 @@ int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
395 395
396 rt286->jack = jack; 396 rt286->jack = jack;
397 397
398 /* Send an initial empty report */ 398 if (jack) {
399 snd_soc_jack_report(rt286->jack, 0, 399 /* enable IRQ */
400 SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); 400 if (rt286->jack->status | SND_JACK_HEADPHONE)
401 snd_soc_dapm_force_enable_pin(&codec->dapm, "LDO1");
402 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x2);
403 /* Send an initial empty report */
404 snd_soc_jack_report(rt286->jack, rt286->jack->status,
405 SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
406 } else {
407 /* disable IRQ */
408 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x0);
409 snd_soc_dapm_disable_pin(&codec->dapm, "LDO1");
410 }
411 snd_soc_dapm_sync(&codec->dapm);
401 412
402 return 0; 413 return 0;
403} 414}
diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h
index 21f8e18c13c4..0a67adbcfbc3 100644
--- a/sound/soc/codecs/rt5670.h
+++ b/sound/soc/codecs/rt5670.h
@@ -1950,17 +1950,20 @@ enum {
1950}; 1950};
1951 1951
1952enum { 1952enum {
1953 RT5670_DMIC1_DISABLED,
1953 RT5670_DMIC_DATA_GPIO6, 1954 RT5670_DMIC_DATA_GPIO6,
1954 RT5670_DMIC_DATA_IN2P, 1955 RT5670_DMIC_DATA_IN2P,
1955 RT5670_DMIC_DATA_GPIO7, 1956 RT5670_DMIC_DATA_GPIO7,
1956}; 1957};
1957 1958
1958enum { 1959enum {
1960 RT5670_DMIC2_DISABLED,
1959 RT5670_DMIC_DATA_GPIO8, 1961 RT5670_DMIC_DATA_GPIO8,
1960 RT5670_DMIC_DATA_IN3N, 1962 RT5670_DMIC_DATA_IN3N,
1961}; 1963};
1962 1964
1963enum { 1965enum {
1966 RT5670_DMIC3_DISABLED,
1964 RT5670_DMIC_DATA_GPIO9, 1967 RT5670_DMIC_DATA_GPIO9,
1965 RT5670_DMIC_DATA_GPIO10, 1968 RT5670_DMIC_DATA_GPIO10,
1966 RT5670_DMIC_DATA_GPIO5, 1969 RT5670_DMIC_DATA_GPIO5,
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index fb9c20eace3f..c2a6e4091357 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -718,11 +718,24 @@ static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on)
718 RT5677_LDO1_SEL_MASK, 0x0); 718 RT5677_LDO1_SEL_MASK, 0x0);
719 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, 719 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
720 RT5677_PWR_LDO1, RT5677_PWR_LDO1); 720 RT5677_PWR_LDO1, RT5677_PWR_LDO1);
721 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, 721 switch (rt5677->type) {
722 RT5677_MCLK_SRC_MASK, RT5677_MCLK2_SRC); 722 case RT5677:
723 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2, 723 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
724 RT5677_PLL2_PR_SRC_MASK | RT5677_DSP_CLK_SRC_MASK, 724 RT5677_MCLK_SRC_MASK, RT5677_MCLK2_SRC);
725 RT5677_PLL2_PR_SRC_MCLK2 | RT5677_DSP_CLK_SRC_BYPASS); 725 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
726 RT5677_PLL2_PR_SRC_MASK |
727 RT5677_DSP_CLK_SRC_MASK,
728 RT5677_PLL2_PR_SRC_MCLK2 |
729 RT5677_DSP_CLK_SRC_BYPASS);
730 break;
731 case RT5676:
732 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
733 RT5677_DSP_CLK_SRC_MASK,
734 RT5677_DSP_CLK_SRC_BYPASS);
735 break;
736 default:
737 break;
738 }
726 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff); 739 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff);
727 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd); 740 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd);
728 rt5677_set_dsp_mode(codec, true); 741 rt5677_set_dsp_mode(codec, true);
@@ -4500,10 +4513,10 @@ static int rt5677_suspend(struct snd_soc_codec *codec)
4500 if (!rt5677->dsp_vad_en) { 4513 if (!rt5677->dsp_vad_en) {
4501 regcache_cache_only(rt5677->regmap, true); 4514 regcache_cache_only(rt5677->regmap, true);
4502 regcache_mark_dirty(rt5677->regmap); 4515 regcache_mark_dirty(rt5677->regmap);
4503 }
4504 4516
4505 if (gpio_is_valid(rt5677->pow_ldo2)) 4517 if (gpio_is_valid(rt5677->pow_ldo2))
4506 gpio_set_value_cansleep(rt5677->pow_ldo2, 0); 4518 gpio_set_value_cansleep(rt5677->pow_ldo2, 0);
4519 }
4507 4520
4508 return 0; 4521 return 0;
4509} 4522}
@@ -4512,12 +4525,12 @@ static int rt5677_resume(struct snd_soc_codec *codec)
4512{ 4525{
4513 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 4526 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4514 4527
4515 if (gpio_is_valid(rt5677->pow_ldo2)) {
4516 gpio_set_value_cansleep(rt5677->pow_ldo2, 1);
4517 msleep(10);
4518 }
4519
4520 if (!rt5677->dsp_vad_en) { 4528 if (!rt5677->dsp_vad_en) {
4529 if (gpio_is_valid(rt5677->pow_ldo2)) {
4530 gpio_set_value_cansleep(rt5677->pow_ldo2, 1);
4531 msleep(10);
4532 }
4533
4521 regcache_cache_only(rt5677->regmap, false); 4534 regcache_cache_only(rt5677->regmap, false);
4522 regcache_sync(rt5677->regmap); 4535 regcache_sync(rt5677->regmap);
4523 } 4536 }
@@ -4733,7 +4746,8 @@ static const struct regmap_config rt5677_regmap = {
4733}; 4746};
4734 4747
4735static const struct i2c_device_id rt5677_i2c_id[] = { 4748static const struct i2c_device_id rt5677_i2c_id[] = {
4736 { "rt5677", 0 }, 4749 { "rt5677", RT5677 },
4750 { "rt5676", RT5676 },
4737 { } 4751 { }
4738}; 4752};
4739MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); 4753MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
@@ -4850,6 +4864,8 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
4850 4864
4851 i2c_set_clientdata(i2c, rt5677); 4865 i2c_set_clientdata(i2c, rt5677);
4852 4866
4867 rt5677->type = id->driver_data;
4868
4853 if (pdata) 4869 if (pdata)
4854 rt5677->pdata = *pdata; 4870 rt5677->pdata = *pdata;
4855 4871
diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h
index c0a625f290cc..07df96b43f59 100644
--- a/sound/soc/codecs/rt5677.h
+++ b/sound/soc/codecs/rt5677.h
@@ -1665,6 +1665,11 @@ enum {
1665 RT5677_IRQ_JD3, 1665 RT5677_IRQ_JD3,
1666}; 1666};
1667 1667
1668enum rt5677_type {
1669 RT5677,
1670 RT5676,
1671};
1672
1668struct rt5677_priv { 1673struct rt5677_priv {
1669 struct snd_soc_codec *codec; 1674 struct snd_soc_codec *codec;
1670 struct rt5677_platform_data pdata; 1675 struct rt5677_platform_data pdata;
@@ -1681,6 +1686,7 @@ struct rt5677_priv {
1681 int pll_in; 1686 int pll_in;
1682 int pll_out; 1687 int pll_out;
1683 int pow_ldo2; /* POW_LDO2 pin */ 1688 int pow_ldo2; /* POW_LDO2 pin */
1689 enum rt5677_type type;
1684#ifdef CONFIG_GPIOLIB 1690#ifdef CONFIG_GPIOLIB
1685 struct gpio_chip gpio_chip; 1691 struct gpio_chip gpio_chip;
1686#endif 1692#endif
diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c
index 82095d6cd070..7947c0ebb1ed 100644
--- a/sound/soc/codecs/sn95031.c
+++ b/sound/soc/codecs/sn95031.c
@@ -783,19 +783,21 @@ static inline void sn95031_enable_jack_btn(struct snd_soc_codec *codec)
783 snd_soc_write(codec, SN95031_BTNCTRL2, 0x01); 783 snd_soc_write(codec, SN95031_BTNCTRL2, 0x01);
784} 784}
785 785
786static int sn95031_get_headset_state(struct snd_soc_jack *mfld_jack) 786static int sn95031_get_headset_state(struct snd_soc_codec *codec,
787 struct snd_soc_jack *mfld_jack)
787{ 788{
788 int micbias = sn95031_get_mic_bias(mfld_jack->codec); 789 int micbias = sn95031_get_mic_bias(codec);
789 790
790 int jack_type = snd_soc_jack_get_type(mfld_jack, micbias); 791 int jack_type = snd_soc_jack_get_type(mfld_jack, micbias);
791 792
792 pr_debug("jack type detected = %d\n", jack_type); 793 pr_debug("jack type detected = %d\n", jack_type);
793 if (jack_type == SND_JACK_HEADSET) 794 if (jack_type == SND_JACK_HEADSET)
794 sn95031_enable_jack_btn(mfld_jack->codec); 795 sn95031_enable_jack_btn(codec);
795 return jack_type; 796 return jack_type;
796} 797}
797 798
798void sn95031_jack_detection(struct mfld_jack_data *jack_data) 799void sn95031_jack_detection(struct snd_soc_codec *codec,
800 struct mfld_jack_data *jack_data)
799{ 801{
800 unsigned int status; 802 unsigned int status;
801 unsigned int mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET; 803 unsigned int mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET;
@@ -809,11 +811,11 @@ void sn95031_jack_detection(struct mfld_jack_data *jack_data)
809 status = SND_JACK_HEADSET | SND_JACK_BTN_1; 811 status = SND_JACK_HEADSET | SND_JACK_BTN_1;
810 } else if (jack_data->intr_id & 0x4) { 812 } else if (jack_data->intr_id & 0x4) {
811 pr_debug("headset or headphones inserted\n"); 813 pr_debug("headset or headphones inserted\n");
812 status = sn95031_get_headset_state(jack_data->mfld_jack); 814 status = sn95031_get_headset_state(codec, jack_data->mfld_jack);
813 } else if (jack_data->intr_id & 0x8) { 815 } else if (jack_data->intr_id & 0x8) {
814 pr_debug("headset or headphones removed\n"); 816 pr_debug("headset or headphones removed\n");
815 status = 0; 817 status = 0;
816 sn95031_disable_jack_btn(jack_data->mfld_jack->codec); 818 sn95031_disable_jack_btn(codec);
817 } else { 819 } else {
818 pr_err("unidentified interrupt\n"); 820 pr_err("unidentified interrupt\n");
819 return; 821 return;
diff --git a/sound/soc/codecs/sn95031.h b/sound/soc/codecs/sn95031.h
index 20376d234fb8..7651fe4e6a45 100644
--- a/sound/soc/codecs/sn95031.h
+++ b/sound/soc/codecs/sn95031.h
@@ -127,6 +127,7 @@ struct mfld_jack_data {
127 struct snd_soc_jack *mfld_jack; 127 struct snd_soc_jack *mfld_jack;
128}; 128};
129 129
130extern void sn95031_jack_detection(struct mfld_jack_data *jack_data); 130extern void sn95031_jack_detection(struct snd_soc_codec *codec,
131 struct mfld_jack_data *jack_data);
131 132
132#endif 133#endif
diff --git a/sound/soc/codecs/sta350.c b/sound/soc/codecs/sta350.c
index bda2ee18769e..669e3228241e 100644
--- a/sound/soc/codecs/sta350.c
+++ b/sound/soc/codecs/sta350.c
@@ -1213,27 +1213,15 @@ static int sta350_i2c_probe(struct i2c_client *i2c,
1213#endif 1213#endif
1214 1214
1215 /* GPIOs */ 1215 /* GPIOs */
1216 sta350->gpiod_nreset = devm_gpiod_get(dev, "reset"); 1216 sta350->gpiod_nreset = devm_gpiod_get_optional(dev, "reset",
1217 if (IS_ERR(sta350->gpiod_nreset)) { 1217 GPIOD_OUT_LOW);
1218 ret = PTR_ERR(sta350->gpiod_nreset); 1218 if (IS_ERR(sta350->gpiod_nreset))
1219 if (ret != -ENOENT && ret != -ENOSYS) 1219 return PTR_ERR(sta350->gpiod_nreset);
1220 return ret; 1220
1221 1221 sta350->gpiod_power_down = devm_gpiod_get(dev, "power-down",
1222 sta350->gpiod_nreset = NULL; 1222 GPIOD_OUT_LOW);
1223 } else { 1223 if (IS_ERR(sta350->gpiod_power_down))
1224 gpiod_direction_output(sta350->gpiod_nreset, 0); 1224 return PTR_ERR(sta350->gpiod_power_down);
1225 }
1226
1227 sta350->gpiod_power_down = devm_gpiod_get(dev, "power-down");
1228 if (IS_ERR(sta350->gpiod_power_down)) {
1229 ret = PTR_ERR(sta350->gpiod_power_down);
1230 if (ret != -ENOENT && ret != -ENOSYS)
1231 return ret;
1232
1233 sta350->gpiod_power_down = NULL;
1234 } else {
1235 gpiod_direction_output(sta350->gpiod_power_down, 0);
1236 }
1237 1225
1238 /* regulators */ 1226 /* regulators */
1239 for (i = 0; i < ARRAY_SIZE(sta350->supplies); i++) 1227 for (i = 0; i < ARRAY_SIZE(sta350->supplies); i++)
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
index ae23acdd2708..dfb4ff5cc9ea 100644
--- a/sound/soc/codecs/tas2552.c
+++ b/sound/soc/codecs/tas2552.c
@@ -485,16 +485,9 @@ static int tas2552_probe(struct i2c_client *client,
485 if (data == NULL) 485 if (data == NULL)
486 return -ENOMEM; 486 return -ENOMEM;
487 487
488 data->enable_gpio = devm_gpiod_get(dev, "enable"); 488 data->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
489 if (IS_ERR(data->enable_gpio)) { 489 if (IS_ERR(data->enable_gpio))
490 ret = PTR_ERR(data->enable_gpio); 490 return PTR_ERR(data->enable_gpio);
491 if (ret != -ENOENT && ret != -ENOSYS)
492 return ret;
493
494 data->enable_gpio = NULL;
495 } else {
496 gpiod_direction_output(data->enable_gpio, 0);
497 }
498 491
499 data->tas2552_client = client; 492 data->tas2552_client = client;
500 data->regmap = devm_regmap_init_i2c(client, &tas2552_regmap_config); 493 data->regmap = devm_regmap_init_i2c(client, &tas2552_regmap_config);
diff --git a/sound/soc/codecs/wm8804-i2c.c b/sound/soc/codecs/wm8804-i2c.c
new file mode 100644
index 000000000000..5bd4af2b4059
--- /dev/null
+++ b/sound/soc/codecs/wm8804-i2c.c
@@ -0,0 +1,64 @@
1/*
2 * wm8804-i2c.c -- WM8804 S/PDIF transceiver driver - I2C
3 *
4 * Copyright 2015 Cirrus Logic Inc
5 *
6 * Author: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/i2c.h>
16
17#include "wm8804.h"
18
19static int wm8804_i2c_probe(struct i2c_client *i2c,
20 const struct i2c_device_id *id)
21{
22 struct regmap *regmap;
23
24 regmap = devm_regmap_init_i2c(i2c, &wm8804_regmap_config);
25 if (IS_ERR(regmap))
26 return PTR_ERR(regmap);
27
28 return wm8804_probe(&i2c->dev, regmap);
29}
30
31static int wm8804_i2c_remove(struct i2c_client *i2c)
32{
33 wm8804_remove(&i2c->dev);
34 return 0;
35}
36
37static const struct i2c_device_id wm8804_i2c_id[] = {
38 { "wm8804", 0 },
39 { }
40};
41MODULE_DEVICE_TABLE(i2c, wm8804_i2c_id);
42
43static const struct of_device_id wm8804_of_match[] = {
44 { .compatible = "wlf,wm8804", },
45 { }
46};
47MODULE_DEVICE_TABLE(of, wm8804_of_match);
48
49static struct i2c_driver wm8804_i2c_driver = {
50 .driver = {
51 .name = "wm8804",
52 .owner = THIS_MODULE,
53 .of_match_table = wm8804_of_match,
54 },
55 .probe = wm8804_i2c_probe,
56 .remove = wm8804_i2c_remove,
57 .id_table = wm8804_i2c_id
58};
59
60module_i2c_driver(wm8804_i2c_driver);
61
62MODULE_DESCRIPTION("ASoC WM8804 driver - I2C");
63MODULE_AUTHOR("Charles Keepax <ckeepax@opensource.wolfsonmicro.com>");
64MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm8804-spi.c b/sound/soc/codecs/wm8804-spi.c
new file mode 100644
index 000000000000..287e11e90794
--- /dev/null
+++ b/sound/soc/codecs/wm8804-spi.c
@@ -0,0 +1,56 @@
1/*
2 * wm8804-spi.c -- WM8804 S/PDIF transceiver driver - SPI
3 *
4 * Copyright 2015 Cirrus Logic Inc
5 *
6 * Author: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/spi/spi.h>
16
17#include "wm8804.h"
18
19static int wm8804_spi_probe(struct spi_device *spi)
20{
21 struct regmap *regmap;
22
23 regmap = devm_regmap_init_spi(spi, &wm8804_regmap_config);
24 if (IS_ERR(regmap))
25 return PTR_ERR(regmap);
26
27 return wm8804_probe(&spi->dev, regmap);
28}
29
30static int wm8804_spi_remove(struct spi_device *spi)
31{
32 wm8804_remove(&spi->dev);
33 return 0;
34}
35
36static const struct of_device_id wm8804_of_match[] = {
37 { .compatible = "wlf,wm8804", },
38 { }
39};
40MODULE_DEVICE_TABLE(of, wm8804_of_match);
41
42static struct spi_driver wm8804_spi_driver = {
43 .driver = {
44 .name = "wm8804",
45 .owner = THIS_MODULE,
46 .of_match_table = wm8804_of_match,
47 },
48 .probe = wm8804_spi_probe,
49 .remove = wm8804_spi_remove
50};
51
52module_spi_driver(wm8804_spi_driver);
53
54MODULE_DESCRIPTION("ASoC WM8804 driver - SPI");
55MODULE_AUTHOR("Charles Keepax <ckeepax@opensource.wolfsonmicro.com>");
56MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
index b2b0e68f707e..1bd4ace29594 100644
--- a/sound/soc/codecs/wm8804.c
+++ b/sound/soc/codecs/wm8804.c
@@ -15,10 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/pm.h> 17#include <linux/pm.h>
18#include <linux/i2c.h>
19#include <linux/of_device.h> 18#include <linux/of_device.h>
20#include <linux/spi/spi.h>
21#include <linux/regmap.h>
22#include <linux/regulator/consumer.h> 19#include <linux/regulator/consumer.h>
23#include <linux/slab.h> 20#include <linux/slab.h>
24#include <sound/core.h> 21#include <sound/core.h>
@@ -185,9 +182,9 @@ static bool wm8804_volatile(struct device *dev, unsigned int reg)
185 } 182 }
186} 183}
187 184
188static int wm8804_reset(struct snd_soc_codec *codec) 185static int wm8804_reset(struct wm8804_priv *wm8804)
189{ 186{
190 return snd_soc_write(codec, WM8804_RST_DEVID1, 0x0); 187 return regmap_write(wm8804->regmap, WM8804_RST_DEVID1, 0x0);
191} 188}
192 189
193static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 190static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
@@ -518,100 +515,6 @@ static int wm8804_set_bias_level(struct snd_soc_codec *codec,
518 return 0; 515 return 0;
519} 516}
520 517
521static int wm8804_remove(struct snd_soc_codec *codec)
522{
523 struct wm8804_priv *wm8804;
524 int i;
525
526 wm8804 = snd_soc_codec_get_drvdata(codec);
527
528 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); ++i)
529 regulator_unregister_notifier(wm8804->supplies[i].consumer,
530 &wm8804->disable_nb[i]);
531 return 0;
532}
533
534static int wm8804_probe(struct snd_soc_codec *codec)
535{
536 struct wm8804_priv *wm8804;
537 int i, id1, id2, ret;
538
539 wm8804 = snd_soc_codec_get_drvdata(codec);
540
541 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++)
542 wm8804->supplies[i].supply = wm8804_supply_names[i];
543
544 ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8804->supplies),
545 wm8804->supplies);
546 if (ret) {
547 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
548 return ret;
549 }
550
551 wm8804->disable_nb[0].notifier_call = wm8804_regulator_event_0;
552 wm8804->disable_nb[1].notifier_call = wm8804_regulator_event_1;
553
554 /* This should really be moved into the regulator core */
555 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++) {
556 ret = regulator_register_notifier(wm8804->supplies[i].consumer,
557 &wm8804->disable_nb[i]);
558 if (ret != 0) {
559 dev_err(codec->dev,
560 "Failed to register regulator notifier: %d\n",
561 ret);
562 }
563 }
564
565 ret = regulator_bulk_enable(ARRAY_SIZE(wm8804->supplies),
566 wm8804->supplies);
567 if (ret) {
568 dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
569 return ret;
570 }
571
572 id1 = snd_soc_read(codec, WM8804_RST_DEVID1);
573 if (id1 < 0) {
574 dev_err(codec->dev, "Failed to read device ID: %d\n", id1);
575 ret = id1;
576 goto err_reg_enable;
577 }
578
579 id2 = snd_soc_read(codec, WM8804_DEVID2);
580 if (id2 < 0) {
581 dev_err(codec->dev, "Failed to read device ID: %d\n", id2);
582 ret = id2;
583 goto err_reg_enable;
584 }
585
586 id2 = (id2 << 8) | id1;
587
588 if (id2 != 0x8805) {
589 dev_err(codec->dev, "Invalid device ID: %#x\n", id2);
590 ret = -EINVAL;
591 goto err_reg_enable;
592 }
593
594 ret = snd_soc_read(codec, WM8804_DEVREV);
595 if (ret < 0) {
596 dev_err(codec->dev, "Failed to read device revision: %d\n",
597 ret);
598 goto err_reg_enable;
599 }
600 dev_info(codec->dev, "revision %c\n", ret + 'A');
601
602 ret = wm8804_reset(codec);
603 if (ret < 0) {
604 dev_err(codec->dev, "Failed to issue reset: %d\n", ret);
605 goto err_reg_enable;
606 }
607
608 return 0;
609
610err_reg_enable:
611 regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), wm8804->supplies);
612 return ret;
613}
614
615static const struct snd_soc_dai_ops wm8804_dai_ops = { 518static const struct snd_soc_dai_ops wm8804_dai_ops = {
616 .hw_params = wm8804_hw_params, 519 .hw_params = wm8804_hw_params,
617 .set_fmt = wm8804_set_fmt, 520 .set_fmt = wm8804_set_fmt,
@@ -649,8 +552,6 @@ static struct snd_soc_dai_driver wm8804_dai = {
649}; 552};
650 553
651static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = { 554static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = {
652 .probe = wm8804_probe,
653 .remove = wm8804_remove,
654 .set_bias_level = wm8804_set_bias_level, 555 .set_bias_level = wm8804_set_bias_level,
655 .idle_bias_off = true, 556 .idle_bias_off = true,
656 557
@@ -658,13 +559,7 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = {
658 .num_controls = ARRAY_SIZE(wm8804_snd_controls), 559 .num_controls = ARRAY_SIZE(wm8804_snd_controls),
659}; 560};
660 561
661static const struct of_device_id wm8804_of_match[] = { 562const struct regmap_config wm8804_regmap_config = {
662 { .compatible = "wlf,wm8804", },
663 { }
664};
665MODULE_DEVICE_TABLE(of, wm8804_of_match);
666
667static const struct regmap_config wm8804_regmap_config = {
668 .reg_bits = 8, 563 .reg_bits = 8,
669 .val_bits = 8, 564 .val_bits = 8,
670 565
@@ -675,128 +570,110 @@ static const struct regmap_config wm8804_regmap_config = {
675 .reg_defaults = wm8804_reg_defaults, 570 .reg_defaults = wm8804_reg_defaults,
676 .num_reg_defaults = ARRAY_SIZE(wm8804_reg_defaults), 571 .num_reg_defaults = ARRAY_SIZE(wm8804_reg_defaults),
677}; 572};
573EXPORT_SYMBOL_GPL(wm8804_regmap_config);
678 574
679#if defined(CONFIG_SPI_MASTER) 575int wm8804_probe(struct device *dev, struct regmap *regmap)
680static int wm8804_spi_probe(struct spi_device *spi)
681{ 576{
682 struct wm8804_priv *wm8804; 577 struct wm8804_priv *wm8804;
683 int ret; 578 unsigned int id1, id2;
579 int i, ret;
684 580
685 wm8804 = devm_kzalloc(&spi->dev, sizeof *wm8804, GFP_KERNEL); 581 wm8804 = devm_kzalloc(dev, sizeof(*wm8804), GFP_KERNEL);
686 if (!wm8804) 582 if (!wm8804)
687 return -ENOMEM; 583 return -ENOMEM;
688 584
689 wm8804->regmap = devm_regmap_init_spi(spi, &wm8804_regmap_config); 585 dev_set_drvdata(dev, wm8804);
690 if (IS_ERR(wm8804->regmap)) { 586
691 ret = PTR_ERR(wm8804->regmap); 587 wm8804->regmap = regmap;
588
589 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++)
590 wm8804->supplies[i].supply = wm8804_supply_names[i];
591
592 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(wm8804->supplies),
593 wm8804->supplies);
594 if (ret) {
595 dev_err(dev, "Failed to request supplies: %d\n", ret);
692 return ret; 596 return ret;
693 } 597 }
694 598
695 spi_set_drvdata(spi, wm8804); 599 wm8804->disable_nb[0].notifier_call = wm8804_regulator_event_0;
600 wm8804->disable_nb[1].notifier_call = wm8804_regulator_event_1;
696 601
697 ret = snd_soc_register_codec(&spi->dev, 602 /* This should really be moved into the regulator core */
698 &soc_codec_dev_wm8804, &wm8804_dai, 1); 603 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++) {
604 ret = regulator_register_notifier(wm8804->supplies[i].consumer,
605 &wm8804->disable_nb[i]);
606 if (ret != 0) {
607 dev_err(dev,
608 "Failed to register regulator notifier: %d\n",
609 ret);
610 }
611 }
699 612
700 return ret; 613 ret = regulator_bulk_enable(ARRAY_SIZE(wm8804->supplies),
701} 614 wm8804->supplies);
615 if (ret) {
616 dev_err(dev, "Failed to enable supplies: %d\n", ret);
617 goto err_reg_enable;
618 }
702 619
703static int wm8804_spi_remove(struct spi_device *spi) 620 ret = regmap_read(regmap, WM8804_RST_DEVID1, &id1);
704{ 621 if (ret < 0) {
705 snd_soc_unregister_codec(&spi->dev); 622 dev_err(dev, "Failed to read device ID: %d\n", ret);
706 return 0; 623 goto err_reg_enable;
707} 624 }
708 625
709static struct spi_driver wm8804_spi_driver = { 626 ret = regmap_read(regmap, WM8804_DEVID2, &id2);
710 .driver = { 627 if (ret < 0) {
711 .name = "wm8804", 628 dev_err(dev, "Failed to read device ID: %d\n", ret);
712 .owner = THIS_MODULE, 629 goto err_reg_enable;
713 .of_match_table = wm8804_of_match, 630 }
714 },
715 .probe = wm8804_spi_probe,
716 .remove = wm8804_spi_remove
717};
718#endif
719 631
720#if IS_ENABLED(CONFIG_I2C) 632 id2 = (id2 << 8) | id1;
721static int wm8804_i2c_probe(struct i2c_client *i2c,
722 const struct i2c_device_id *id)
723{
724 struct wm8804_priv *wm8804;
725 int ret;
726 633
727 wm8804 = devm_kzalloc(&i2c->dev, sizeof *wm8804, GFP_KERNEL); 634 if (id2 != 0x8805) {
728 if (!wm8804) 635 dev_err(dev, "Invalid device ID: %#x\n", id2);
729 return -ENOMEM; 636 ret = -EINVAL;
637 goto err_reg_enable;
638 }
730 639
731 wm8804->regmap = devm_regmap_init_i2c(i2c, &wm8804_regmap_config); 640 ret = regmap_read(regmap, WM8804_DEVREV, &id1);
732 if (IS_ERR(wm8804->regmap)) { 641 if (ret < 0) {
733 ret = PTR_ERR(wm8804->regmap); 642 dev_err(dev, "Failed to read device revision: %d\n",
734 return ret; 643 ret);
644 goto err_reg_enable;
735 } 645 }
646 dev_info(dev, "revision %c\n", id1 + 'A');
736 647
737 i2c_set_clientdata(i2c, wm8804); 648 ret = wm8804_reset(wm8804);
649 if (ret < 0) {
650 dev_err(dev, "Failed to issue reset: %d\n", ret);
651 goto err_reg_enable;
652 }
738 653
739 ret = snd_soc_register_codec(&i2c->dev, 654 return snd_soc_register_codec(dev, &soc_codec_dev_wm8804,
740 &soc_codec_dev_wm8804, &wm8804_dai, 1); 655 &wm8804_dai, 1);
656
657err_reg_enable:
658 regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), wm8804->supplies);
741 return ret; 659 return ret;
742} 660}
661EXPORT_SYMBOL_GPL(wm8804_probe);
743 662
744static int wm8804_i2c_remove(struct i2c_client *i2c) 663void wm8804_remove(struct device *dev)
745{ 664{
746 snd_soc_unregister_codec(&i2c->dev); 665 struct wm8804_priv *wm8804;
747 return 0; 666 int i;
748}
749
750static const struct i2c_device_id wm8804_i2c_id[] = {
751 { "wm8804", 0 },
752 { }
753};
754MODULE_DEVICE_TABLE(i2c, wm8804_i2c_id);
755
756static struct i2c_driver wm8804_i2c_driver = {
757 .driver = {
758 .name = "wm8804",
759 .owner = THIS_MODULE,
760 .of_match_table = wm8804_of_match,
761 },
762 .probe = wm8804_i2c_probe,
763 .remove = wm8804_i2c_remove,
764 .id_table = wm8804_i2c_id
765};
766#endif
767 667
768static int __init wm8804_modinit(void) 668 wm8804 = dev_get_drvdata(dev);
769{
770 int ret = 0;
771 669
772#if IS_ENABLED(CONFIG_I2C) 670 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); ++i)
773 ret = i2c_add_driver(&wm8804_i2c_driver); 671 regulator_unregister_notifier(wm8804->supplies[i].consumer,
774 if (ret) { 672 &wm8804->disable_nb[i]);
775 printk(KERN_ERR "Failed to register wm8804 I2C driver: %d\n",
776 ret);
777 }
778#endif
779#if defined(CONFIG_SPI_MASTER)
780 ret = spi_register_driver(&wm8804_spi_driver);
781 if (ret != 0) {
782 printk(KERN_ERR "Failed to register wm8804 SPI driver: %d\n",
783 ret);
784 }
785#endif
786 return ret;
787}
788module_init(wm8804_modinit);
789 673
790static void __exit wm8804_exit(void) 674 snd_soc_unregister_codec(dev);
791{
792#if IS_ENABLED(CONFIG_I2C)
793 i2c_del_driver(&wm8804_i2c_driver);
794#endif
795#if defined(CONFIG_SPI_MASTER)
796 spi_unregister_driver(&wm8804_spi_driver);
797#endif
798} 675}
799module_exit(wm8804_exit); 676EXPORT_SYMBOL_GPL(wm8804_remove);
800 677
801MODULE_DESCRIPTION("ASoC WM8804 driver"); 678MODULE_DESCRIPTION("ASoC WM8804 driver");
802MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>"); 679MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>");
diff --git a/sound/soc/codecs/wm8804.h b/sound/soc/codecs/wm8804.h
index e72d4f4ba6b1..a39a2563dc67 100644
--- a/sound/soc/codecs/wm8804.h
+++ b/sound/soc/codecs/wm8804.h
@@ -13,6 +13,8 @@
13#ifndef _WM8804_H 13#ifndef _WM8804_H
14#define _WM8804_H 14#define _WM8804_H
15 15
16#include <linux/regmap.h>
17
16/* 18/*
17 * Register values. 19 * Register values.
18 */ 20 */
@@ -62,4 +64,9 @@
62#define WM8804_MCLKDIV_256FS 0 64#define WM8804_MCLKDIV_256FS 0
63#define WM8804_MCLKDIV_128FS 1 65#define WM8804_MCLKDIV_128FS 1
64 66
67extern const struct regmap_config wm8804_regmap_config;
68
69int wm8804_probe(struct device *dev, struct regmap *regmap);
70void wm8804_remove(struct device *dev);
71
65#endif /* _WM8804_H */ 72#endif /* _WM8804_H */
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index ff67b334065b..d01c2095452f 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -420,10 +420,9 @@ static int wm_coeff_put(struct snd_kcontrol *kcontrol,
420 420
421 memcpy(ctl->cache, p, ctl->len); 421 memcpy(ctl->cache, p, ctl->len);
422 422
423 if (!ctl->enabled) { 423 ctl->set = 1;
424 ctl->set = 1; 424 if (!ctl->enabled)
425 return 0; 425 return 0;
426 }
427 426
428 return wm_coeff_write_control(kcontrol, p, ctl->len); 427 return wm_coeff_write_control(kcontrol, p, ctl->len);
429} 428}
@@ -1185,7 +1184,6 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
1185 int ret, pos, blocks, type, offset, reg; 1184 int ret, pos, blocks, type, offset, reg;
1186 char *file; 1185 char *file;
1187 struct wm_adsp_buf *buf; 1186 struct wm_adsp_buf *buf;
1188 int tmp;
1189 1187
1190 file = kzalloc(PAGE_SIZE, GFP_KERNEL); 1188 file = kzalloc(PAGE_SIZE, GFP_KERNEL);
1191 if (file == NULL) 1189 if (file == NULL)
@@ -1335,12 +1333,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
1335 } 1333 }
1336 } 1334 }
1337 1335
1338 tmp = le32_to_cpu(blk->len) % 4; 1336 pos += (le32_to_cpu(blk->len) + sizeof(*blk) + 3) & ~0x03;
1339 if (tmp)
1340 pos += le32_to_cpu(blk->len) + (4 - tmp) + sizeof(*blk);
1341 else
1342 pos += le32_to_cpu(blk->len) + sizeof(*blk);
1343
1344 blocks++; 1337 blocks++;
1345 } 1338 }
1346 1339
diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig
index 2b81ca418d2a..3736d9aabc56 100644
--- a/sound/soc/davinci/Kconfig
+++ b/sound/soc/davinci/Kconfig
@@ -1,14 +1,16 @@
1config SND_DAVINCI_SOC 1config SND_DAVINCI_SOC
2 tristate "SoC Audio for TI DAVINCI" 2 tristate
3 depends on ARCH_DAVINCI 3 depends on ARCH_DAVINCI
4 select SND_EDMA_SOC
4 5
5config SND_EDMA_SOC 6config SND_EDMA_SOC
6 tristate "SoC Audio for Texas Instruments chips using eDMA (AM33XX/43XX)" 7 tristate "SoC Audio for Texas Instruments chips using eDMA"
7 depends on SOC_AM33XX || SOC_AM43XX 8 depends on SOC_AM33XX || SOC_AM43XX || ARCH_DAVINCI
8 select SND_SOC_GENERIC_DMAENGINE_PCM 9 select SND_SOC_GENERIC_DMAENGINE_PCM
9 help 10 help
10 Say Y or M here if you want audio support for TI SoC which uses eDMA. 11 Say Y or M here if you want audio support for TI SoC which uses eDMA.
11 The following line of SoCs are supported by this platform driver: 12 The following line of SoCs are supported by this platform driver:
13 - daVinci devices
12 - AM335x 14 - AM335x
13 - AM437x/AM438x 15 - AM437x/AM438x
14 16
@@ -17,7 +19,7 @@ config SND_DAVINCI_SOC_I2S
17 19
18config SND_DAVINCI_SOC_MCASP 20config SND_DAVINCI_SOC_MCASP
19 tristate "Multichannel Audio Serial Port (McASP) support" 21 tristate "Multichannel Audio Serial Port (McASP) support"
20 depends on SND_DAVINCI_SOC || SND_OMAP_SOC || SND_EDMA_SOC 22 depends on SND_OMAP_SOC || SND_EDMA_SOC
21 help 23 help
22 Say Y or M here if you want to have support for McASP IP found in 24 Say Y or M here if you want to have support for McASP IP found in
23 various Texas Instruments SoCs like: 25 various Texas Instruments SoCs like:
@@ -45,7 +47,7 @@ config SND_AM33XX_SOC_EVM
45 47
46config SND_DAVINCI_SOC_EVM 48config SND_DAVINCI_SOC_EVM
47 tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM" 49 tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM"
48 depends on SND_DAVINCI_SOC && I2C 50 depends on SND_EDMA_SOC && I2C
49 depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM 51 depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM
50 select SND_DAVINCI_SOC_GENERIC_EVM 52 select SND_DAVINCI_SOC_GENERIC_EVM
51 help 53 help
@@ -73,7 +75,7 @@ endchoice
73 75
74config SND_DM6467_SOC_EVM 76config SND_DM6467_SOC_EVM
75 tristate "SoC Audio support for DaVinci DM6467 EVM" 77 tristate "SoC Audio support for DaVinci DM6467 EVM"
76 depends on SND_DAVINCI_SOC && MACH_DAVINCI_DM6467_EVM && I2C 78 depends on SND_EDMA_SOC && MACH_DAVINCI_DM6467_EVM && I2C
77 select SND_DAVINCI_SOC_GENERIC_EVM 79 select SND_DAVINCI_SOC_GENERIC_EVM
78 select SND_SOC_SPDIF 80 select SND_SOC_SPDIF
79 81
@@ -82,7 +84,7 @@ config SND_DM6467_SOC_EVM
82 84
83config SND_DA830_SOC_EVM 85config SND_DA830_SOC_EVM
84 tristate "SoC Audio support for DA830/OMAP-L137 EVM" 86 tristate "SoC Audio support for DA830/OMAP-L137 EVM"
85 depends on SND_DAVINCI_SOC && MACH_DAVINCI_DA830_EVM && I2C 87 depends on SND_EDMA_SOC && MACH_DAVINCI_DA830_EVM && I2C
86 select SND_DAVINCI_SOC_GENERIC_EVM 88 select SND_DAVINCI_SOC_GENERIC_EVM
87 89
88 help 90 help
@@ -91,7 +93,7 @@ config SND_DA830_SOC_EVM
91 93
92config SND_DA850_SOC_EVM 94config SND_DA850_SOC_EVM
93 tristate "SoC Audio support for DA850/OMAP-L138 EVM" 95 tristate "SoC Audio support for DA850/OMAP-L138 EVM"
94 depends on SND_DAVINCI_SOC && MACH_DAVINCI_DA850_EVM && I2C 96 depends on SND_EDMA_SOC && MACH_DAVINCI_DA850_EVM && I2C
95 select SND_DAVINCI_SOC_GENERIC_EVM 97 select SND_DAVINCI_SOC_GENERIC_EVM
96 help 98 help
97 Say Y if you want to add support for SoC audio on TI 99 Say Y if you want to add support for SoC audio on TI
diff --git a/sound/soc/davinci/Makefile b/sound/soc/davinci/Makefile
index 09bf2ba92d38..f883933c1a19 100644
--- a/sound/soc/davinci/Makefile
+++ b/sound/soc/davinci/Makefile
@@ -1,11 +1,9 @@
1# DAVINCI Platform Support 1# DAVINCI Platform Support
2snd-soc-davinci-objs := davinci-pcm.o
3snd-soc-edma-objs := edma-pcm.o 2snd-soc-edma-objs := edma-pcm.o
4snd-soc-davinci-i2s-objs := davinci-i2s.o 3snd-soc-davinci-i2s-objs := davinci-i2s.o
5snd-soc-davinci-mcasp-objs:= davinci-mcasp.o 4snd-soc-davinci-mcasp-objs:= davinci-mcasp.o
6snd-soc-davinci-vcif-objs:= davinci-vcif.o 5snd-soc-davinci-vcif-objs:= davinci-vcif.o
7 6
8obj-$(CONFIG_SND_DAVINCI_SOC) += snd-soc-davinci.o
9obj-$(CONFIG_SND_EDMA_SOC) += snd-soc-edma.o 7obj-$(CONFIG_SND_EDMA_SOC) += snd-soc-edma.o
10obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o 8obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o
11obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o 9obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index 15fb28fc8e1b..56cb4d95637d 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -23,8 +23,9 @@
23#include <sound/pcm_params.h> 23#include <sound/pcm_params.h>
24#include <sound/initval.h> 24#include <sound/initval.h>
25#include <sound/soc.h> 25#include <sound/soc.h>
26#include <sound/dmaengine_pcm.h>
26 27
27#include "davinci-pcm.h" 28#include "edma-pcm.h"
28#include "davinci-i2s.h" 29#include "davinci-i2s.h"
29 30
30 31
@@ -122,7 +123,8 @@ static const unsigned char double_fmt[SNDRV_PCM_FORMAT_S32_LE + 1] = {
122 123
123struct davinci_mcbsp_dev { 124struct davinci_mcbsp_dev {
124 struct device *dev; 125 struct device *dev;
125 struct davinci_pcm_dma_params dma_params[2]; 126 struct snd_dmaengine_dai_dma_data dma_data[2];
127 int dma_request[2];
126 void __iomem *base; 128 void __iomem *base;
127#define MOD_DSP_A 0 129#define MOD_DSP_A 0
128#define MOD_DSP_B 1 130#define MOD_DSP_B 1
@@ -419,8 +421,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
419 struct snd_soc_dai *dai) 421 struct snd_soc_dai *dai)
420{ 422{
421 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai); 423 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
422 struct davinci_pcm_dma_params *dma_params =
423 &dev->dma_params[substream->stream];
424 struct snd_interval *i = NULL; 424 struct snd_interval *i = NULL;
425 int mcbsp_word_length, master; 425 int mcbsp_word_length, master;
426 unsigned int rcr, xcr, srgr, clk_div, freq, framesize; 426 unsigned int rcr, xcr, srgr, clk_div, freq, framesize;
@@ -532,8 +532,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
532 return -EINVAL; 532 return -EINVAL;
533 } 533 }
534 } 534 }
535 dma_params->acnt = dma_params->data_type = data_type[fmt];
536 dma_params->fifo_level = 0;
537 mcbsp_word_length = asp_word_length[fmt]; 535 mcbsp_word_length = asp_word_length[fmt];
538 536
539 switch (master) { 537 switch (master) {
@@ -600,15 +598,6 @@ static int davinci_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
600 return ret; 598 return ret;
601} 599}
602 600
603static int davinci_i2s_startup(struct snd_pcm_substream *substream,
604 struct snd_soc_dai *dai)
605{
606 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
607
608 snd_soc_dai_set_dma_data(dai, substream, dev->dma_params);
609 return 0;
610}
611
612static void davinci_i2s_shutdown(struct snd_pcm_substream *substream, 601static void davinci_i2s_shutdown(struct snd_pcm_substream *substream,
613 struct snd_soc_dai *dai) 602 struct snd_soc_dai *dai)
614{ 603{
@@ -620,7 +609,6 @@ static void davinci_i2s_shutdown(struct snd_pcm_substream *substream,
620#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 609#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000
621 610
622static const struct snd_soc_dai_ops davinci_i2s_dai_ops = { 611static const struct snd_soc_dai_ops davinci_i2s_dai_ops = {
623 .startup = davinci_i2s_startup,
624 .shutdown = davinci_i2s_shutdown, 612 .shutdown = davinci_i2s_shutdown,
625 .prepare = davinci_i2s_prepare, 613 .prepare = davinci_i2s_prepare,
626 .trigger = davinci_i2s_trigger, 614 .trigger = davinci_i2s_trigger,
@@ -630,7 +618,18 @@ static const struct snd_soc_dai_ops davinci_i2s_dai_ops = {
630 618
631}; 619};
632 620
621static int davinci_i2s_dai_probe(struct snd_soc_dai *dai)
622{
623 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
624
625 dai->playback_dma_data = &dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
626 dai->capture_dma_data = &dev->dma_data[SNDRV_PCM_STREAM_CAPTURE];
627
628 return 0;
629}
630
633static struct snd_soc_dai_driver davinci_i2s_dai = { 631static struct snd_soc_dai_driver davinci_i2s_dai = {
632 .probe = davinci_i2s_dai_probe,
634 .playback = { 633 .playback = {
635 .channels_min = 2, 634 .channels_min = 2,
636 .channels_max = 2, 635 .channels_max = 2,
@@ -651,11 +650,9 @@ static const struct snd_soc_component_driver davinci_i2s_component = {
651 650
652static int davinci_i2s_probe(struct platform_device *pdev) 651static int davinci_i2s_probe(struct platform_device *pdev)
653{ 652{
654 struct snd_platform_data *pdata = pdev->dev.platform_data;
655 struct davinci_mcbsp_dev *dev; 653 struct davinci_mcbsp_dev *dev;
656 struct resource *mem, *ioarea, *res; 654 struct resource *mem, *ioarea, *res;
657 enum dma_event_q asp_chan_q = EVENTQ_0; 655 int *dma;
658 enum dma_event_q ram_chan_q = EVENTQ_1;
659 int ret; 656 int ret;
660 657
661 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 658 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -676,22 +673,6 @@ static int davinci_i2s_probe(struct platform_device *pdev)
676 GFP_KERNEL); 673 GFP_KERNEL);
677 if (!dev) 674 if (!dev)
678 return -ENOMEM; 675 return -ENOMEM;
679 if (pdata) {
680 dev->enable_channel_combine = pdata->enable_channel_combine;
681 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].sram_size =
682 pdata->sram_size_playback;
683 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].sram_size =
684 pdata->sram_size_capture;
685 dev->clk_input_pin = pdata->clk_input_pin;
686 dev->i2s_accurate_sck = pdata->i2s_accurate_sck;
687 asp_chan_q = pdata->asp_chan_q;
688 ram_chan_q = pdata->ram_chan_q;
689 }
690
691 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].asp_chan_q = asp_chan_q;
692 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].ram_chan_q = ram_chan_q;
693 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].asp_chan_q = asp_chan_q;
694 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].ram_chan_q = ram_chan_q;
695 676
696 dev->clk = clk_get(&pdev->dev, NULL); 677 dev->clk = clk_get(&pdev->dev, NULL);
697 if (IS_ERR(dev->clk)) 678 if (IS_ERR(dev->clk))
@@ -705,10 +686,10 @@ static int davinci_i2s_probe(struct platform_device *pdev)
705 goto err_release_clk; 686 goto err_release_clk;
706 } 687 }
707 688
708 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].dma_addr = 689 dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr =
709 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DXR_REG); 690 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DXR_REG);
710 691
711 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].dma_addr = 692 dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr =
712 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DRR_REG); 693 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DRR_REG);
713 694
714 /* first TX, then RX */ 695 /* first TX, then RX */
@@ -718,7 +699,9 @@ static int davinci_i2s_probe(struct platform_device *pdev)
718 ret = -ENXIO; 699 ret = -ENXIO;
719 goto err_release_clk; 700 goto err_release_clk;
720 } 701 }
721 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].channel = res->start; 702 dma = &dev->dma_request[SNDRV_PCM_STREAM_PLAYBACK];
703 *dma = res->start;
704 dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].filter_data = dma;
722 705
723 res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 706 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
724 if (!res) { 707 if (!res) {
@@ -726,9 +709,11 @@ static int davinci_i2s_probe(struct platform_device *pdev)
726 ret = -ENXIO; 709 ret = -ENXIO;
727 goto err_release_clk; 710 goto err_release_clk;
728 } 711 }
729 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].channel = res->start; 712 dma = &dev->dma_request[SNDRV_PCM_STREAM_CAPTURE];
730 dev->dev = &pdev->dev; 713 *dma = res->start;
714 dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].filter_data = dma;
731 715
716 dev->dev = &pdev->dev;
732 dev_set_drvdata(&pdev->dev, dev); 717 dev_set_drvdata(&pdev->dev, dev);
733 718
734 ret = snd_soc_register_component(&pdev->dev, &davinci_i2s_component, 719 ret = snd_soc_register_component(&pdev->dev, &davinci_i2s_component,
@@ -736,7 +721,7 @@ static int davinci_i2s_probe(struct platform_device *pdev)
736 if (ret != 0) 721 if (ret != 0)
737 goto err_release_clk; 722 goto err_release_clk;
738 723
739 ret = davinci_soc_platform_register(&pdev->dev); 724 ret = edma_pcm_platform_register(&pdev->dev);
740 if (ret) { 725 if (ret) {
741 dev_err(&pdev->dev, "register PCM failed: %d\n", ret); 726 dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
742 goto err_unregister_component; 727 goto err_unregister_component;
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index de3b155a5011..0c882995a357 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -26,6 +26,7 @@
26#include <linux/of.h> 26#include <linux/of.h>
27#include <linux/of_platform.h> 27#include <linux/of_platform.h>
28#include <linux/of_device.h> 28#include <linux/of_device.h>
29#include <linux/platform_data/davinci_asp.h>
29 30
30#include <sound/asoundef.h> 31#include <sound/asoundef.h>
31#include <sound/core.h> 32#include <sound/core.h>
@@ -36,7 +37,6 @@
36#include <sound/dmaengine_pcm.h> 37#include <sound/dmaengine_pcm.h>
37#include <sound/omap-pcm.h> 38#include <sound/omap-pcm.h>
38 39
39#include "davinci-pcm.h"
40#include "edma-pcm.h" 40#include "edma-pcm.h"
41#include "davinci-mcasp.h" 41#include "davinci-mcasp.h"
42 42
@@ -65,7 +65,6 @@ struct davinci_mcasp_context {
65}; 65};
66 66
67struct davinci_mcasp { 67struct davinci_mcasp {
68 struct davinci_pcm_dma_params dma_params[2];
69 struct snd_dmaengine_dai_dma_data dma_data[2]; 68 struct snd_dmaengine_dai_dma_data dma_data[2];
70 void __iomem *base; 69 void __iomem *base;
71 u32 fifo_base; 70 u32 fifo_base;
@@ -82,6 +81,7 @@ struct davinci_mcasp {
82 u16 bclk_lrclk_ratio; 81 u16 bclk_lrclk_ratio;
83 int streams; 82 int streams;
84 u32 irq_request[2]; 83 u32 irq_request[2];
84 int dma_request[2];
85 85
86 int sysclk_freq; 86 int sysclk_freq;
87 bool bclk_master; 87 bool bclk_master;
@@ -441,6 +441,18 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
441 mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AFSX | AFSR); 441 mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AFSX | AFSR);
442 mcasp->bclk_master = 1; 442 mcasp->bclk_master = 1;
443 break; 443 break;
444 case SND_SOC_DAIFMT_CBS_CFM:
445 /* codec is clock slave and frame master */
446 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
447 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, AFSXE);
448
449 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
450 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
451
452 mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, ACLKX | ACLKR);
453 mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AFSX | AFSR);
454 mcasp->bclk_master = 1;
455 break;
444 case SND_SOC_DAIFMT_CBM_CFS: 456 case SND_SOC_DAIFMT_CBM_CFS:
445 /* codec is clock master and frame slave */ 457 /* codec is clock master and frame slave */
446 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); 458 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
@@ -631,7 +643,6 @@ static int davinci_config_channel_size(struct davinci_mcasp *mcasp,
631static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, 643static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
632 int period_words, int channels) 644 int period_words, int channels)
633{ 645{
634 struct davinci_pcm_dma_params *dma_params = &mcasp->dma_params[stream];
635 struct snd_dmaengine_dai_dma_data *dma_data = &mcasp->dma_data[stream]; 646 struct snd_dmaengine_dai_dma_data *dma_data = &mcasp->dma_data[stream];
636 int i; 647 int i;
637 u8 tx_ser = 0; 648 u8 tx_ser = 0;
@@ -699,10 +710,8 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
699 * For example if three serializers are enabled the DMA 710 * For example if three serializers are enabled the DMA
700 * need to transfer three words per DMA request. 711 * need to transfer three words per DMA request.
701 */ 712 */
702 dma_params->fifo_level = active_serializers;
703 dma_data->maxburst = active_serializers; 713 dma_data->maxburst = active_serializers;
704 } else { 714 } else {
705 dma_params->fifo_level = 0;
706 dma_data->maxburst = 0; 715 dma_data->maxburst = 0;
707 } 716 }
708 return 0; 717 return 0;
@@ -734,7 +743,6 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
734 /* Configure the burst size for platform drivers */ 743 /* Configure the burst size for platform drivers */
735 if (numevt == 1) 744 if (numevt == 1)
736 numevt = 0; 745 numevt = 0;
737 dma_params->fifo_level = numevt;
738 dma_data->maxburst = numevt; 746 dma_data->maxburst = numevt;
739 747
740 return 0; 748 return 0;
@@ -860,8 +868,6 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
860 struct snd_soc_dai *cpu_dai) 868 struct snd_soc_dai *cpu_dai)
861{ 869{
862 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); 870 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai);
863 struct davinci_pcm_dma_params *dma_params =
864 &mcasp->dma_params[substream->stream];
865 int word_length; 871 int word_length;
866 int channels = params_channels(params); 872 int channels = params_channels(params);
867 int period_size = params_period_size(params); 873 int period_size = params_period_size(params);
@@ -902,31 +908,26 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
902 switch (params_format(params)) { 908 switch (params_format(params)) {
903 case SNDRV_PCM_FORMAT_U8: 909 case SNDRV_PCM_FORMAT_U8:
904 case SNDRV_PCM_FORMAT_S8: 910 case SNDRV_PCM_FORMAT_S8:
905 dma_params->data_type = 1;
906 word_length = 8; 911 word_length = 8;
907 break; 912 break;
908 913
909 case SNDRV_PCM_FORMAT_U16_LE: 914 case SNDRV_PCM_FORMAT_U16_LE:
910 case SNDRV_PCM_FORMAT_S16_LE: 915 case SNDRV_PCM_FORMAT_S16_LE:
911 dma_params->data_type = 2;
912 word_length = 16; 916 word_length = 16;
913 break; 917 break;
914 918
915 case SNDRV_PCM_FORMAT_U24_3LE: 919 case SNDRV_PCM_FORMAT_U24_3LE:
916 case SNDRV_PCM_FORMAT_S24_3LE: 920 case SNDRV_PCM_FORMAT_S24_3LE:
917 dma_params->data_type = 3;
918 word_length = 24; 921 word_length = 24;
919 break; 922 break;
920 923
921 case SNDRV_PCM_FORMAT_U24_LE: 924 case SNDRV_PCM_FORMAT_U24_LE:
922 case SNDRV_PCM_FORMAT_S24_LE: 925 case SNDRV_PCM_FORMAT_S24_LE:
923 dma_params->data_type = 4;
924 word_length = 24; 926 word_length = 24;
925 break; 927 break;
926 928
927 case SNDRV_PCM_FORMAT_U32_LE: 929 case SNDRV_PCM_FORMAT_U32_LE:
928 case SNDRV_PCM_FORMAT_S32_LE: 930 case SNDRV_PCM_FORMAT_S32_LE:
929 dma_params->data_type = 4;
930 word_length = 32; 931 word_length = 32;
931 break; 932 break;
932 933
@@ -935,11 +936,6 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
935 return -EINVAL; 936 return -EINVAL;
936 } 937 }
937 938
938 if (mcasp->version == MCASP_VERSION_2 && !dma_params->fifo_level)
939 dma_params->acnt = 4;
940 else
941 dma_params->acnt = dma_params->data_type;
942
943 davinci_config_channel_size(mcasp, word_length); 939 davinci_config_channel_size(mcasp, word_length);
944 940
945 if (mcasp->op_mode == DAVINCI_MCASP_IIS_MODE) 941 if (mcasp->op_mode == DAVINCI_MCASP_IIS_MODE)
@@ -1043,17 +1039,8 @@ static int davinci_mcasp_dai_probe(struct snd_soc_dai *dai)
1043{ 1039{
1044 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); 1040 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai);
1045 1041
1046 if (mcasp->version >= MCASP_VERSION_3) { 1042 dai->playback_dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
1047 /* Using dmaengine PCM */ 1043 dai->capture_dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE];
1048 dai->playback_dma_data =
1049 &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
1050 dai->capture_dma_data =
1051 &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE];
1052 } else {
1053 /* Using davinci-pcm */
1054 dai->playback_dma_data = mcasp->dma_params;
1055 dai->capture_dma_data = mcasp->dma_params;
1056 }
1057 1044
1058 return 0; 1045 return 0;
1059} 1046}
@@ -1172,28 +1159,24 @@ static const struct snd_soc_component_driver davinci_mcasp_component = {
1172static struct davinci_mcasp_pdata dm646x_mcasp_pdata = { 1159static struct davinci_mcasp_pdata dm646x_mcasp_pdata = {
1173 .tx_dma_offset = 0x400, 1160 .tx_dma_offset = 0x400,
1174 .rx_dma_offset = 0x400, 1161 .rx_dma_offset = 0x400,
1175 .asp_chan_q = EVENTQ_0,
1176 .version = MCASP_VERSION_1, 1162 .version = MCASP_VERSION_1,
1177}; 1163};
1178 1164
1179static struct davinci_mcasp_pdata da830_mcasp_pdata = { 1165static struct davinci_mcasp_pdata da830_mcasp_pdata = {
1180 .tx_dma_offset = 0x2000, 1166 .tx_dma_offset = 0x2000,
1181 .rx_dma_offset = 0x2000, 1167 .rx_dma_offset = 0x2000,
1182 .asp_chan_q = EVENTQ_0,
1183 .version = MCASP_VERSION_2, 1168 .version = MCASP_VERSION_2,
1184}; 1169};
1185 1170
1186static struct davinci_mcasp_pdata am33xx_mcasp_pdata = { 1171static struct davinci_mcasp_pdata am33xx_mcasp_pdata = {
1187 .tx_dma_offset = 0, 1172 .tx_dma_offset = 0,
1188 .rx_dma_offset = 0, 1173 .rx_dma_offset = 0,
1189 .asp_chan_q = EVENTQ_0,
1190 .version = MCASP_VERSION_3, 1174 .version = MCASP_VERSION_3,
1191}; 1175};
1192 1176
1193static struct davinci_mcasp_pdata dra7_mcasp_pdata = { 1177static struct davinci_mcasp_pdata dra7_mcasp_pdata = {
1194 .tx_dma_offset = 0x200, 1178 .tx_dma_offset = 0x200,
1195 .rx_dma_offset = 0x284, 1179 .rx_dma_offset = 0x284,
1196 .asp_chan_q = EVENTQ_0,
1197 .version = MCASP_VERSION_4, 1180 .version = MCASP_VERSION_4,
1198}; 1181};
1199 1182
@@ -1370,12 +1353,12 @@ nodata:
1370 1353
1371static int davinci_mcasp_probe(struct platform_device *pdev) 1354static int davinci_mcasp_probe(struct platform_device *pdev)
1372{ 1355{
1373 struct davinci_pcm_dma_params *dma_params;
1374 struct snd_dmaengine_dai_dma_data *dma_data; 1356 struct snd_dmaengine_dai_dma_data *dma_data;
1375 struct resource *mem, *ioarea, *res, *dat; 1357 struct resource *mem, *ioarea, *res, *dat;
1376 struct davinci_mcasp_pdata *pdata; 1358 struct davinci_mcasp_pdata *pdata;
1377 struct davinci_mcasp *mcasp; 1359 struct davinci_mcasp *mcasp;
1378 char *irq_name; 1360 char *irq_name;
1361 int *dma;
1379 int irq; 1362 int irq;
1380 int ret; 1363 int ret;
1381 1364
@@ -1509,59 +1492,45 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1509 if (dat) 1492 if (dat)
1510 mcasp->dat_port = true; 1493 mcasp->dat_port = true;
1511 1494
1512 dma_params = &mcasp->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
1513 dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK]; 1495 dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
1514 dma_params->asp_chan_q = pdata->asp_chan_q;
1515 dma_params->ram_chan_q = pdata->ram_chan_q;
1516 dma_params->sram_pool = pdata->sram_pool;
1517 dma_params->sram_size = pdata->sram_size_playback;
1518 if (dat) 1496 if (dat)
1519 dma_params->dma_addr = dat->start; 1497 dma_data->addr = dat->start;
1520 else 1498 else
1521 dma_params->dma_addr = mem->start + pdata->tx_dma_offset; 1499 dma_data->addr = mem->start + pdata->tx_dma_offset;
1522
1523 /* Unconditional dmaengine stuff */
1524 dma_data->addr = dma_params->dma_addr;
1525 1500
1501 dma = &mcasp->dma_request[SNDRV_PCM_STREAM_PLAYBACK];
1526 res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 1502 res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
1527 if (res) 1503 if (res)
1528 dma_params->channel = res->start; 1504 *dma = res->start;
1529 else 1505 else
1530 dma_params->channel = pdata->tx_dma_channel; 1506 *dma = pdata->tx_dma_channel;
1531 1507
1532 /* dmaengine filter data for DT and non-DT boot */ 1508 /* dmaengine filter data for DT and non-DT boot */
1533 if (pdev->dev.of_node) 1509 if (pdev->dev.of_node)
1534 dma_data->filter_data = "tx"; 1510 dma_data->filter_data = "tx";
1535 else 1511 else
1536 dma_data->filter_data = &dma_params->channel; 1512 dma_data->filter_data = dma;
1537 1513
1538 /* RX is not valid in DIT mode */ 1514 /* RX is not valid in DIT mode */
1539 if (mcasp->op_mode != DAVINCI_MCASP_DIT_MODE) { 1515 if (mcasp->op_mode != DAVINCI_MCASP_DIT_MODE) {
1540 dma_params = &mcasp->dma_params[SNDRV_PCM_STREAM_CAPTURE];
1541 dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE]; 1516 dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE];
1542 dma_params->asp_chan_q = pdata->asp_chan_q;
1543 dma_params->ram_chan_q = pdata->ram_chan_q;
1544 dma_params->sram_pool = pdata->sram_pool;
1545 dma_params->sram_size = pdata->sram_size_capture;
1546 if (dat) 1517 if (dat)
1547 dma_params->dma_addr = dat->start; 1518 dma_data->addr = dat->start;
1548 else 1519 else
1549 dma_params->dma_addr = mem->start + pdata->rx_dma_offset; 1520 dma_data->addr = mem->start + pdata->rx_dma_offset;
1550
1551 /* Unconditional dmaengine stuff */
1552 dma_data->addr = dma_params->dma_addr;
1553 1521
1522 dma = &mcasp->dma_request[SNDRV_PCM_STREAM_CAPTURE];
1554 res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 1523 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
1555 if (res) 1524 if (res)
1556 dma_params->channel = res->start; 1525 *dma = res->start;
1557 else 1526 else
1558 dma_params->channel = pdata->rx_dma_channel; 1527 *dma = pdata->rx_dma_channel;
1559 1528
1560 /* dmaengine filter data for DT and non-DT boot */ 1529 /* dmaengine filter data for DT and non-DT boot */
1561 if (pdev->dev.of_node) 1530 if (pdev->dev.of_node)
1562 dma_data->filter_data = "rx"; 1531 dma_data->filter_data = "rx";
1563 else 1532 else
1564 dma_data->filter_data = &dma_params->channel; 1533 dma_data->filter_data = dma;
1565 } 1534 }
1566 1535
1567 if (mcasp->version < MCASP_VERSION_3) { 1536 if (mcasp->version < MCASP_VERSION_3) {
@@ -1584,17 +1553,11 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1584 goto err; 1553 goto err;
1585 1554
1586 switch (mcasp->version) { 1555 switch (mcasp->version) {
1587#if IS_BUILTIN(CONFIG_SND_DAVINCI_SOC) || \
1588 (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \
1589 IS_MODULE(CONFIG_SND_DAVINCI_SOC))
1590 case MCASP_VERSION_1:
1591 case MCASP_VERSION_2:
1592 ret = davinci_soc_platform_register(&pdev->dev);
1593 break;
1594#endif
1595#if IS_BUILTIN(CONFIG_SND_EDMA_SOC) || \ 1556#if IS_BUILTIN(CONFIG_SND_EDMA_SOC) || \
1596 (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \ 1557 (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \
1597 IS_MODULE(CONFIG_SND_EDMA_SOC)) 1558 IS_MODULE(CONFIG_SND_EDMA_SOC))
1559 case MCASP_VERSION_1:
1560 case MCASP_VERSION_2:
1598 case MCASP_VERSION_3: 1561 case MCASP_VERSION_3:
1599 ret = edma_pcm_platform_register(&pdev->dev); 1562 ret = edma_pcm_platform_register(&pdev->dev);
1600 break; 1563 break;
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
deleted file mode 100644
index 7809e9d935fc..000000000000
--- a/sound/soc/davinci/davinci-pcm.c
+++ /dev/null
@@ -1,861 +0,0 @@
1/*
2 * ALSA PCM interface for the TI DAVINCI processor
3 *
4 * Author: Vladimir Barinov, <vbarinov@embeddedalley.com>
5 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 * added SRAM ping/pong (C) 2008 Troy Kisky <troy.kisky@boundarydevices.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/slab.h>
17#include <linux/dma-mapping.h>
18#include <linux/kernel.h>
19#include <linux/genalloc.h>
20#include <linux/platform_data/edma.h>
21
22#include <sound/core.h>
23#include <sound/pcm.h>
24#include <sound/pcm_params.h>
25#include <sound/soc.h>
26
27#include <asm/dma.h>
28
29#include "davinci-pcm.h"
30
31#ifdef DEBUG
32static void print_buf_info(int slot, char *name)
33{
34 struct edmacc_param p;
35 if (slot < 0)
36 return;
37 edma_read_slot(slot, &p);
38 printk(KERN_DEBUG "%s: 0x%x, opt=%x, src=%x, a_b_cnt=%x dst=%x\n",
39 name, slot, p.opt, p.src, p.a_b_cnt, p.dst);
40 printk(KERN_DEBUG " src_dst_bidx=%x link_bcntrld=%x src_dst_cidx=%x ccnt=%x\n",
41 p.src_dst_bidx, p.link_bcntrld, p.src_dst_cidx, p.ccnt);
42}
43#else
44static void print_buf_info(int slot, char *name)
45{
46}
47#endif
48
49static struct snd_pcm_hardware pcm_hardware_playback = {
50 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
51 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
52 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME|
53 SNDRV_PCM_INFO_BATCH),
54 .buffer_bytes_max = 128 * 1024,
55 .period_bytes_min = 32,
56 .period_bytes_max = 8 * 1024,
57 .periods_min = 16,
58 .periods_max = 255,
59 .fifo_size = 0,
60};
61
62static struct snd_pcm_hardware pcm_hardware_capture = {
63 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
64 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
65 SNDRV_PCM_INFO_PAUSE |
66 SNDRV_PCM_INFO_BATCH),
67 .buffer_bytes_max = 128 * 1024,
68 .period_bytes_min = 32,
69 .period_bytes_max = 8 * 1024,
70 .periods_min = 16,
71 .periods_max = 255,
72 .fifo_size = 0,
73};
74
75/*
76 * How ping/pong works....
77 *
78 * Playback:
79 * ram_params - copys 2*ping_size from start of SDRAM to iram,
80 * links to ram_link2
81 * ram_link2 - copys rest of SDRAM to iram in ping_size units,
82 * links to ram_link
83 * ram_link - copys entire SDRAM to iram in ping_size uints,
84 * links to self
85 *
86 * asp_params - same as asp_link[0]
87 * asp_link[0] - copys from lower half of iram to asp port
88 * links to asp_link[1], triggers iram copy event on completion
89 * asp_link[1] - copys from upper half of iram to asp port
90 * links to asp_link[0], triggers iram copy event on completion
91 * triggers interrupt only needed to let upper SOC levels update position
92 * in stream on completion
93 *
94 * When playback is started:
95 * ram_params started
96 * asp_params started
97 *
98 * Capture:
99 * ram_params - same as ram_link,
100 * links to ram_link
101 * ram_link - same as playback
102 * links to self
103 *
104 * asp_params - same as playback
105 * asp_link[0] - same as playback
106 * asp_link[1] - same as playback
107 *
108 * When capture is started:
109 * asp_params started
110 */
111struct davinci_runtime_data {
112 spinlock_t lock;
113 int period; /* current DMA period */
114 int asp_channel; /* Master DMA channel */
115 int asp_link[2]; /* asp parameter link channel, ping/pong */
116 struct davinci_pcm_dma_params *params; /* DMA params */
117 int ram_channel;
118 int ram_link;
119 int ram_link2;
120 struct edmacc_param asp_params;
121 struct edmacc_param ram_params;
122};
123
124static void davinci_pcm_period_elapsed(struct snd_pcm_substream *substream)
125{
126 struct davinci_runtime_data *prtd = substream->runtime->private_data;
127 struct snd_pcm_runtime *runtime = substream->runtime;
128
129 prtd->period++;
130 if (unlikely(prtd->period >= runtime->periods))
131 prtd->period = 0;
132}
133
134static void davinci_pcm_period_reset(struct snd_pcm_substream *substream)
135{
136 struct davinci_runtime_data *prtd = substream->runtime->private_data;
137
138 prtd->period = 0;
139}
140/*
141 * Not used with ping/pong
142 */
143static void davinci_pcm_enqueue_dma(struct snd_pcm_substream *substream)
144{
145 struct davinci_runtime_data *prtd = substream->runtime->private_data;
146 struct snd_pcm_runtime *runtime = substream->runtime;
147 unsigned int period_size;
148 unsigned int dma_offset;
149 dma_addr_t dma_pos;
150 dma_addr_t src, dst;
151 unsigned short src_bidx, dst_bidx;
152 unsigned short src_cidx, dst_cidx;
153 unsigned int data_type;
154 unsigned short acnt;
155 unsigned int count;
156 unsigned int fifo_level;
157
158 period_size = snd_pcm_lib_period_bytes(substream);
159 dma_offset = prtd->period * period_size;
160 dma_pos = runtime->dma_addr + dma_offset;
161 fifo_level = prtd->params->fifo_level;
162
163 pr_debug("davinci_pcm: audio_set_dma_params_play channel = %d "
164 "dma_ptr = %x period_size=%x\n", prtd->asp_link[0], dma_pos,
165 period_size);
166
167 data_type = prtd->params->data_type;
168 count = period_size / data_type;
169 if (fifo_level)
170 count /= fifo_level;
171
172 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
173 src = dma_pos;
174 dst = prtd->params->dma_addr;
175 src_bidx = data_type;
176 dst_bidx = 4;
177 src_cidx = data_type * fifo_level;
178 dst_cidx = 0;
179 } else {
180 src = prtd->params->dma_addr;
181 dst = dma_pos;
182 src_bidx = 0;
183 dst_bidx = data_type;
184 src_cidx = 0;
185 dst_cidx = data_type * fifo_level;
186 }
187
188 acnt = prtd->params->acnt;
189 edma_set_src(prtd->asp_link[0], src, INCR, W8BIT);
190 edma_set_dest(prtd->asp_link[0], dst, INCR, W8BIT);
191
192 edma_set_src_index(prtd->asp_link[0], src_bidx, src_cidx);
193 edma_set_dest_index(prtd->asp_link[0], dst_bidx, dst_cidx);
194
195 if (!fifo_level)
196 edma_set_transfer_params(prtd->asp_link[0], acnt, count, 1, 0,
197 ASYNC);
198 else
199 edma_set_transfer_params(prtd->asp_link[0], acnt,
200 fifo_level,
201 count, fifo_level,
202 ABSYNC);
203}
204
205static void davinci_pcm_dma_irq(unsigned link, u16 ch_status, void *data)
206{
207 struct snd_pcm_substream *substream = data;
208 struct davinci_runtime_data *prtd = substream->runtime->private_data;
209
210 print_buf_info(prtd->ram_channel, "i ram_channel");
211 pr_debug("davinci_pcm: link=%d, status=0x%x\n", link, ch_status);
212
213 if (unlikely(ch_status != EDMA_DMA_COMPLETE))
214 return;
215
216 if (snd_pcm_running(substream)) {
217 spin_lock(&prtd->lock);
218 if (prtd->ram_channel < 0) {
219 /* No ping/pong must fix up link dma data*/
220 davinci_pcm_enqueue_dma(substream);
221 }
222 davinci_pcm_period_elapsed(substream);
223 spin_unlock(&prtd->lock);
224 snd_pcm_period_elapsed(substream);
225 }
226}
227
228#ifdef CONFIG_GENERIC_ALLOCATOR
229static int allocate_sram(struct snd_pcm_substream *substream,
230 struct gen_pool *sram_pool, unsigned size,
231 struct snd_pcm_hardware *ppcm)
232{
233 struct snd_dma_buffer *buf = &substream->dma_buffer;
234 struct snd_dma_buffer *iram_dma = NULL;
235 dma_addr_t iram_phys = 0;
236 void *iram_virt = NULL;
237
238 if (buf->private_data || !size)
239 return 0;
240
241 ppcm->period_bytes_max = size;
242 iram_virt = gen_pool_dma_alloc(sram_pool, size, &iram_phys);
243 if (!iram_virt)
244 goto exit1;
245 iram_dma = kzalloc(sizeof(*iram_dma), GFP_KERNEL);
246 if (!iram_dma)
247 goto exit2;
248 iram_dma->area = iram_virt;
249 iram_dma->addr = iram_phys;
250 memset(iram_dma->area, 0, size);
251 iram_dma->bytes = size;
252 buf->private_data = iram_dma;
253 return 0;
254exit2:
255 if (iram_virt)
256 gen_pool_free(sram_pool, (unsigned)iram_virt, size);
257exit1:
258 return -ENOMEM;
259}
260
261static void davinci_free_sram(struct snd_pcm_substream *substream,
262 struct snd_dma_buffer *iram_dma)
263{
264 struct davinci_runtime_data *prtd = substream->runtime->private_data;
265 struct gen_pool *sram_pool = prtd->params->sram_pool;
266
267 gen_pool_free(sram_pool, (unsigned) iram_dma->area, iram_dma->bytes);
268}
269#else
270static int allocate_sram(struct snd_pcm_substream *substream,
271 struct gen_pool *sram_pool, unsigned size,
272 struct snd_pcm_hardware *ppcm)
273{
274 return 0;
275}
276
277static void davinci_free_sram(struct snd_pcm_substream *substream,
278 struct snd_dma_buffer *iram_dma)
279{
280}
281#endif
282
283/*
284 * Only used with ping/pong.
285 * This is called after runtime->dma_addr, period_bytes and data_type are valid
286 */
287static int ping_pong_dma_setup(struct snd_pcm_substream *substream)
288{
289 unsigned short ram_src_cidx, ram_dst_cidx;
290 struct snd_pcm_runtime *runtime = substream->runtime;
291 struct davinci_runtime_data *prtd = runtime->private_data;
292 struct snd_dma_buffer *iram_dma =
293 (struct snd_dma_buffer *)substream->dma_buffer.private_data;
294 struct davinci_pcm_dma_params *params = prtd->params;
295 unsigned int data_type = params->data_type;
296 unsigned int acnt = params->acnt;
297 /* divide by 2 for ping/pong */
298 unsigned int ping_size = snd_pcm_lib_period_bytes(substream) >> 1;
299 unsigned int fifo_level = prtd->params->fifo_level;
300 unsigned int count;
301 if ((data_type == 0) || (data_type > 4)) {
302 printk(KERN_ERR "%s: data_type=%i\n", __func__, data_type);
303 return -EINVAL;
304 }
305 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
306 dma_addr_t asp_src_pong = iram_dma->addr + ping_size;
307 ram_src_cidx = ping_size;
308 ram_dst_cidx = -ping_size;
309 edma_set_src(prtd->asp_link[1], asp_src_pong, INCR, W8BIT);
310
311 edma_set_src_index(prtd->asp_link[0], data_type,
312 data_type * fifo_level);
313 edma_set_src_index(prtd->asp_link[1], data_type,
314 data_type * fifo_level);
315
316 edma_set_src(prtd->ram_link, runtime->dma_addr, INCR, W32BIT);
317 } else {
318 dma_addr_t asp_dst_pong = iram_dma->addr + ping_size;
319 ram_src_cidx = -ping_size;
320 ram_dst_cidx = ping_size;
321 edma_set_dest(prtd->asp_link[1], asp_dst_pong, INCR, W8BIT);
322
323 edma_set_dest_index(prtd->asp_link[0], data_type,
324 data_type * fifo_level);
325 edma_set_dest_index(prtd->asp_link[1], data_type,
326 data_type * fifo_level);
327
328 edma_set_dest(prtd->ram_link, runtime->dma_addr, INCR, W32BIT);
329 }
330
331 if (!fifo_level) {
332 count = ping_size / data_type;
333 edma_set_transfer_params(prtd->asp_link[0], acnt, count,
334 1, 0, ASYNC);
335 edma_set_transfer_params(prtd->asp_link[1], acnt, count,
336 1, 0, ASYNC);
337 } else {
338 count = ping_size / (data_type * fifo_level);
339 edma_set_transfer_params(prtd->asp_link[0], acnt, fifo_level,
340 count, fifo_level, ABSYNC);
341 edma_set_transfer_params(prtd->asp_link[1], acnt, fifo_level,
342 count, fifo_level, ABSYNC);
343 }
344
345 edma_set_src_index(prtd->ram_link, ping_size, ram_src_cidx);
346 edma_set_dest_index(prtd->ram_link, ping_size, ram_dst_cidx);
347 edma_set_transfer_params(prtd->ram_link, ping_size, 2,
348 runtime->periods, 2, ASYNC);
349
350 /* init master params */
351 edma_read_slot(prtd->asp_link[0], &prtd->asp_params);
352 edma_read_slot(prtd->ram_link, &prtd->ram_params);
353 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
354 struct edmacc_param p_ram;
355 /* Copy entire iram buffer before playback started */
356 prtd->ram_params.a_b_cnt = (1 << 16) | (ping_size << 1);
357 /* 0 dst_bidx */
358 prtd->ram_params.src_dst_bidx = (ping_size << 1);
359 /* 0 dst_cidx */
360 prtd->ram_params.src_dst_cidx = (ping_size << 1);
361 prtd->ram_params.ccnt = 1;
362
363 /* Skip 1st period */
364 edma_read_slot(prtd->ram_link, &p_ram);
365 p_ram.src += (ping_size << 1);
366 p_ram.ccnt -= 1;
367 edma_write_slot(prtd->ram_link2, &p_ram);
368 /*
369 * When 1st started, ram -> iram dma channel will fill the
370 * entire iram. Then, whenever a ping/pong asp buffer finishes,
371 * 1/2 iram will be filled.
372 */
373 prtd->ram_params.link_bcntrld =
374 EDMA_CHAN_SLOT(prtd->ram_link2) << 5;
375 }
376 return 0;
377}
378
379/* 1 asp tx or rx channel using 2 parameter channels
380 * 1 ram to/from iram channel using 1 parameter channel
381 *
382 * Playback
383 * ram copy channel kicks off first,
384 * 1st ram copy of entire iram buffer completion kicks off asp channel
385 * asp tcc always kicks off ram copy of 1/2 iram buffer
386 *
387 * Record
388 * asp channel starts, tcc kicks off ram copy
389 */
390static int request_ping_pong(struct snd_pcm_substream *substream,
391 struct davinci_runtime_data *prtd,
392 struct snd_dma_buffer *iram_dma)
393{
394 dma_addr_t asp_src_ping;
395 dma_addr_t asp_dst_ping;
396 int ret;
397 struct davinci_pcm_dma_params *params = prtd->params;
398
399 /* Request ram master channel */
400 ret = prtd->ram_channel = edma_alloc_channel(EDMA_CHANNEL_ANY,
401 davinci_pcm_dma_irq, substream,
402 prtd->params->ram_chan_q);
403 if (ret < 0)
404 goto exit1;
405
406 /* Request ram link channel */
407 ret = prtd->ram_link = edma_alloc_slot(
408 EDMA_CTLR(prtd->ram_channel), EDMA_SLOT_ANY);
409 if (ret < 0)
410 goto exit2;
411
412 ret = prtd->asp_link[1] = edma_alloc_slot(
413 EDMA_CTLR(prtd->asp_channel), EDMA_SLOT_ANY);
414 if (ret < 0)
415 goto exit3;
416
417 prtd->ram_link2 = -1;
418 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
419 ret = prtd->ram_link2 = edma_alloc_slot(
420 EDMA_CTLR(prtd->ram_channel), EDMA_SLOT_ANY);
421 if (ret < 0)
422 goto exit4;
423 }
424 /* circle ping-pong buffers */
425 edma_link(prtd->asp_link[0], prtd->asp_link[1]);
426 edma_link(prtd->asp_link[1], prtd->asp_link[0]);
427 /* circle ram buffers */
428 edma_link(prtd->ram_link, prtd->ram_link);
429
430 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
431 asp_src_ping = iram_dma->addr;
432 asp_dst_ping = params->dma_addr; /* fifo */
433 } else {
434 asp_src_ping = params->dma_addr; /* fifo */
435 asp_dst_ping = iram_dma->addr;
436 }
437 /* ping */
438 edma_set_src(prtd->asp_link[0], asp_src_ping, INCR, W16BIT);
439 edma_set_dest(prtd->asp_link[0], asp_dst_ping, INCR, W16BIT);
440 edma_set_src_index(prtd->asp_link[0], 0, 0);
441 edma_set_dest_index(prtd->asp_link[0], 0, 0);
442
443 edma_read_slot(prtd->asp_link[0], &prtd->asp_params);
444 prtd->asp_params.opt &= ~(TCCMODE | EDMA_TCC(0x3f) | TCINTEN);
445 prtd->asp_params.opt |= TCCHEN |
446 EDMA_TCC(prtd->ram_channel & 0x3f);
447 edma_write_slot(prtd->asp_link[0], &prtd->asp_params);
448
449 /* pong */
450 edma_set_src(prtd->asp_link[1], asp_src_ping, INCR, W16BIT);
451 edma_set_dest(prtd->asp_link[1], asp_dst_ping, INCR, W16BIT);
452 edma_set_src_index(prtd->asp_link[1], 0, 0);
453 edma_set_dest_index(prtd->asp_link[1], 0, 0);
454
455 edma_read_slot(prtd->asp_link[1], &prtd->asp_params);
456 prtd->asp_params.opt &= ~(TCCMODE | EDMA_TCC(0x3f));
457 /* interrupt after every pong completion */
458 prtd->asp_params.opt |= TCINTEN | TCCHEN |
459 EDMA_TCC(prtd->ram_channel & 0x3f);
460 edma_write_slot(prtd->asp_link[1], &prtd->asp_params);
461
462 /* ram */
463 edma_set_src(prtd->ram_link, iram_dma->addr, INCR, W32BIT);
464 edma_set_dest(prtd->ram_link, iram_dma->addr, INCR, W32BIT);
465 pr_debug("%s: audio dma channels/slots in use for ram:%u %u %u,"
466 "for asp:%u %u %u\n", __func__,
467 prtd->ram_channel, prtd->ram_link, prtd->ram_link2,
468 prtd->asp_channel, prtd->asp_link[0],
469 prtd->asp_link[1]);
470 return 0;
471exit4:
472 edma_free_channel(prtd->asp_link[1]);
473 prtd->asp_link[1] = -1;
474exit3:
475 edma_free_channel(prtd->ram_link);
476 prtd->ram_link = -1;
477exit2:
478 edma_free_channel(prtd->ram_channel);
479 prtd->ram_channel = -1;
480exit1:
481 return ret;
482}
483
484static int davinci_pcm_dma_request(struct snd_pcm_substream *substream)
485{
486 struct snd_dma_buffer *iram_dma;
487 struct davinci_runtime_data *prtd = substream->runtime->private_data;
488 struct davinci_pcm_dma_params *params = prtd->params;
489 int ret;
490
491 if (!params)
492 return -ENODEV;
493
494 /* Request asp master DMA channel */
495 ret = prtd->asp_channel = edma_alloc_channel(params->channel,
496 davinci_pcm_dma_irq, substream,
497 prtd->params->asp_chan_q);
498 if (ret < 0)
499 goto exit1;
500
501 /* Request asp link channels */
502 ret = prtd->asp_link[0] = edma_alloc_slot(
503 EDMA_CTLR(prtd->asp_channel), EDMA_SLOT_ANY);
504 if (ret < 0)
505 goto exit2;
506
507 iram_dma = (struct snd_dma_buffer *)substream->dma_buffer.private_data;
508 if (iram_dma) {
509 if (request_ping_pong(substream, prtd, iram_dma) == 0)
510 return 0;
511 printk(KERN_WARNING "%s: dma channel allocation failed,"
512 "not using sram\n", __func__);
513 }
514
515 /* Issue transfer completion IRQ when the channel completes a
516 * transfer, then always reload from the same slot (by a kind
517 * of loopback link). The completion IRQ handler will update
518 * the reload slot with a new buffer.
519 *
520 * REVISIT save p_ram here after setting up everything except
521 * the buffer and its length (ccnt) ... use it as a template
522 * so davinci_pcm_enqueue_dma() takes less time in IRQ.
523 */
524 edma_read_slot(prtd->asp_link[0], &prtd->asp_params);
525 prtd->asp_params.opt |= TCINTEN |
526 EDMA_TCC(EDMA_CHAN_SLOT(prtd->asp_channel));
527 prtd->asp_params.link_bcntrld = EDMA_CHAN_SLOT(prtd->asp_link[0]) << 5;
528 edma_write_slot(prtd->asp_link[0], &prtd->asp_params);
529 return 0;
530exit2:
531 edma_free_channel(prtd->asp_channel);
532 prtd->asp_channel = -1;
533exit1:
534 return ret;
535}
536
537static int davinci_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
538{
539 struct davinci_runtime_data *prtd = substream->runtime->private_data;
540 int ret = 0;
541
542 spin_lock(&prtd->lock);
543
544 switch (cmd) {
545 case SNDRV_PCM_TRIGGER_START:
546 edma_start(prtd->asp_channel);
547 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
548 prtd->ram_channel >= 0) {
549 /* copy 1st iram buffer */
550 edma_start(prtd->ram_channel);
551 }
552 break;
553 case SNDRV_PCM_TRIGGER_RESUME:
554 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
555 edma_resume(prtd->asp_channel);
556 break;
557 case SNDRV_PCM_TRIGGER_STOP:
558 case SNDRV_PCM_TRIGGER_SUSPEND:
559 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
560 edma_pause(prtd->asp_channel);
561 break;
562 default:
563 ret = -EINVAL;
564 break;
565 }
566
567 spin_unlock(&prtd->lock);
568
569 return ret;
570}
571
572static int davinci_pcm_prepare(struct snd_pcm_substream *substream)
573{
574 struct davinci_runtime_data *prtd = substream->runtime->private_data;
575
576 davinci_pcm_period_reset(substream);
577 if (prtd->ram_channel >= 0) {
578 int ret = ping_pong_dma_setup(substream);
579 if (ret < 0)
580 return ret;
581
582 edma_write_slot(prtd->ram_channel, &prtd->ram_params);
583 edma_write_slot(prtd->asp_channel, &prtd->asp_params);
584
585 print_buf_info(prtd->ram_channel, "ram_channel");
586 print_buf_info(prtd->ram_link, "ram_link");
587 print_buf_info(prtd->ram_link2, "ram_link2");
588 print_buf_info(prtd->asp_channel, "asp_channel");
589 print_buf_info(prtd->asp_link[0], "asp_link[0]");
590 print_buf_info(prtd->asp_link[1], "asp_link[1]");
591
592 /*
593 * There is a phase offset of 2 periods between the position
594 * used by dma setup and the position reported in the pointer
595 * function.
596 *
597 * The phase offset, when not using ping-pong buffers, is due to
598 * the two consecutive calls to davinci_pcm_enqueue_dma() below.
599 *
600 * Whereas here, with ping-pong buffers, the phase is due to
601 * there being an entire buffer transfer complete before the
602 * first dma completion event triggers davinci_pcm_dma_irq().
603 */
604 davinci_pcm_period_elapsed(substream);
605 davinci_pcm_period_elapsed(substream);
606
607 return 0;
608 }
609 davinci_pcm_enqueue_dma(substream);
610 davinci_pcm_period_elapsed(substream);
611
612 /* Copy self-linked parameter RAM entry into master channel */
613 edma_read_slot(prtd->asp_link[0], &prtd->asp_params);
614 edma_write_slot(prtd->asp_channel, &prtd->asp_params);
615 davinci_pcm_enqueue_dma(substream);
616 davinci_pcm_period_elapsed(substream);
617
618 return 0;
619}
620
621static snd_pcm_uframes_t
622davinci_pcm_pointer(struct snd_pcm_substream *substream)
623{
624 struct snd_pcm_runtime *runtime = substream->runtime;
625 struct davinci_runtime_data *prtd = runtime->private_data;
626 unsigned int offset;
627 int asp_count;
628 unsigned int period_size = snd_pcm_lib_period_bytes(substream);
629
630 /*
631 * There is a phase offset of 2 periods between the position used by dma
632 * setup and the position reported in the pointer function. Either +2 in
633 * the dma setup or -2 here in the pointer function (with wrapping,
634 * both) accounts for this offset -- choose the latter since it makes
635 * the first-time setup clearer.
636 */
637 spin_lock(&prtd->lock);
638 asp_count = prtd->period - 2;
639 spin_unlock(&prtd->lock);
640
641 if (asp_count < 0)
642 asp_count += runtime->periods;
643 asp_count *= period_size;
644
645 offset = bytes_to_frames(runtime, asp_count);
646 if (offset >= runtime->buffer_size)
647 offset = 0;
648
649 return offset;
650}
651
652static int davinci_pcm_open(struct snd_pcm_substream *substream)
653{
654 struct snd_pcm_runtime *runtime = substream->runtime;
655 struct davinci_runtime_data *prtd;
656 struct snd_pcm_hardware *ppcm;
657 int ret = 0;
658 struct snd_soc_pcm_runtime *rtd = substream->private_data;
659 struct davinci_pcm_dma_params *pa;
660 struct davinci_pcm_dma_params *params;
661
662 pa = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
663 if (!pa)
664 return -ENODEV;
665 params = &pa[substream->stream];
666
667 ppcm = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
668 &pcm_hardware_playback : &pcm_hardware_capture;
669 allocate_sram(substream, params->sram_pool, params->sram_size, ppcm);
670 snd_soc_set_runtime_hwparams(substream, ppcm);
671 /* ensure that buffer size is a multiple of period size */
672 ret = snd_pcm_hw_constraint_integer(runtime,
673 SNDRV_PCM_HW_PARAM_PERIODS);
674 if (ret < 0)
675 return ret;
676
677 prtd = kzalloc(sizeof(struct davinci_runtime_data), GFP_KERNEL);
678 if (prtd == NULL)
679 return -ENOMEM;
680
681 spin_lock_init(&prtd->lock);
682 prtd->params = params;
683 prtd->asp_channel = -1;
684 prtd->asp_link[0] = prtd->asp_link[1] = -1;
685 prtd->ram_channel = -1;
686 prtd->ram_link = -1;
687 prtd->ram_link2 = -1;
688
689 runtime->private_data = prtd;
690
691 ret = davinci_pcm_dma_request(substream);
692 if (ret) {
693 printk(KERN_ERR "davinci_pcm: Failed to get dma channels\n");
694 kfree(prtd);
695 }
696
697 return ret;
698}
699
700static int davinci_pcm_close(struct snd_pcm_substream *substream)
701{
702 struct snd_pcm_runtime *runtime = substream->runtime;
703 struct davinci_runtime_data *prtd = runtime->private_data;
704
705 if (prtd->ram_channel >= 0)
706 edma_stop(prtd->ram_channel);
707 if (prtd->asp_channel >= 0)
708 edma_stop(prtd->asp_channel);
709 if (prtd->asp_link[0] >= 0)
710 edma_unlink(prtd->asp_link[0]);
711 if (prtd->asp_link[1] >= 0)
712 edma_unlink(prtd->asp_link[1]);
713 if (prtd->ram_link >= 0)
714 edma_unlink(prtd->ram_link);
715
716 if (prtd->asp_link[0] >= 0)
717 edma_free_slot(prtd->asp_link[0]);
718 if (prtd->asp_link[1] >= 0)
719 edma_free_slot(prtd->asp_link[1]);
720 if (prtd->asp_channel >= 0)
721 edma_free_channel(prtd->asp_channel);
722 if (prtd->ram_link >= 0)
723 edma_free_slot(prtd->ram_link);
724 if (prtd->ram_link2 >= 0)
725 edma_free_slot(prtd->ram_link2);
726 if (prtd->ram_channel >= 0)
727 edma_free_channel(prtd->ram_channel);
728
729 kfree(prtd);
730
731 return 0;
732}
733
734static int davinci_pcm_hw_params(struct snd_pcm_substream *substream,
735 struct snd_pcm_hw_params *hw_params)
736{
737 return snd_pcm_lib_malloc_pages(substream,
738 params_buffer_bytes(hw_params));
739}
740
741static int davinci_pcm_hw_free(struct snd_pcm_substream *substream)
742{
743 return snd_pcm_lib_free_pages(substream);
744}
745
746static int davinci_pcm_mmap(struct snd_pcm_substream *substream,
747 struct vm_area_struct *vma)
748{
749 struct snd_pcm_runtime *runtime = substream->runtime;
750
751 return dma_mmap_writecombine(substream->pcm->card->dev, vma,
752 runtime->dma_area,
753 runtime->dma_addr,
754 runtime->dma_bytes);
755}
756
757static struct snd_pcm_ops davinci_pcm_ops = {
758 .open = davinci_pcm_open,
759 .close = davinci_pcm_close,
760 .ioctl = snd_pcm_lib_ioctl,
761 .hw_params = davinci_pcm_hw_params,
762 .hw_free = davinci_pcm_hw_free,
763 .prepare = davinci_pcm_prepare,
764 .trigger = davinci_pcm_trigger,
765 .pointer = davinci_pcm_pointer,
766 .mmap = davinci_pcm_mmap,
767};
768
769static int davinci_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream,
770 size_t size)
771{
772 struct snd_pcm_substream *substream = pcm->streams[stream].substream;
773 struct snd_dma_buffer *buf = &substream->dma_buffer;
774
775 buf->dev.type = SNDRV_DMA_TYPE_DEV;
776 buf->dev.dev = pcm->card->dev;
777 buf->private_data = NULL;
778 buf->area = dma_alloc_writecombine(pcm->card->dev, size,
779 &buf->addr, GFP_KERNEL);
780
781 pr_debug("davinci_pcm: preallocate_dma_buffer: area=%p, addr=%p, "
782 "size=%d\n", (void *) buf->area, (void *) buf->addr, size);
783
784 if (!buf->area)
785 return -ENOMEM;
786
787 buf->bytes = size;
788 return 0;
789}
790
791static void davinci_pcm_free(struct snd_pcm *pcm)
792{
793 struct snd_pcm_substream *substream;
794 struct snd_dma_buffer *buf;
795 int stream;
796
797 for (stream = 0; stream < 2; stream++) {
798 struct snd_dma_buffer *iram_dma;
799 substream = pcm->streams[stream].substream;
800 if (!substream)
801 continue;
802
803 buf = &substream->dma_buffer;
804 if (!buf->area)
805 continue;
806
807 dma_free_writecombine(pcm->card->dev, buf->bytes,
808 buf->area, buf->addr);
809 buf->area = NULL;
810 iram_dma = buf->private_data;
811 if (iram_dma) {
812 davinci_free_sram(substream, iram_dma);
813 kfree(iram_dma);
814 }
815 }
816}
817
818static int davinci_pcm_new(struct snd_soc_pcm_runtime *rtd)
819{
820 struct snd_card *card = rtd->card->snd_card;
821 struct snd_pcm *pcm = rtd->pcm;
822 int ret;
823
824 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
825 if (ret)
826 return ret;
827
828 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
829 ret = davinci_pcm_preallocate_dma_buffer(pcm,
830 SNDRV_PCM_STREAM_PLAYBACK,
831 pcm_hardware_playback.buffer_bytes_max);
832 if (ret)
833 return ret;
834 }
835
836 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
837 ret = davinci_pcm_preallocate_dma_buffer(pcm,
838 SNDRV_PCM_STREAM_CAPTURE,
839 pcm_hardware_capture.buffer_bytes_max);
840 if (ret)
841 return ret;
842 }
843
844 return 0;
845}
846
847static struct snd_soc_platform_driver davinci_soc_platform = {
848 .ops = &davinci_pcm_ops,
849 .pcm_new = davinci_pcm_new,
850 .pcm_free = davinci_pcm_free,
851};
852
853int davinci_soc_platform_register(struct device *dev)
854{
855 return devm_snd_soc_register_platform(dev, &davinci_soc_platform);
856}
857EXPORT_SYMBOL_GPL(davinci_soc_platform_register);
858
859MODULE_AUTHOR("Vladimir Barinov");
860MODULE_DESCRIPTION("TI DAVINCI PCM DMA module");
861MODULE_LICENSE("GPL");
diff --git a/sound/soc/davinci/davinci-pcm.h b/sound/soc/davinci/davinci-pcm.h
deleted file mode 100644
index 0fe2346a9aa2..000000000000
--- a/sound/soc/davinci/davinci-pcm.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * ALSA PCM interface for the TI DAVINCI processor
3 *
4 * Author: Vladimir Barinov, <vbarinov@embeddedalley.com>
5 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _DAVINCI_PCM_H
13#define _DAVINCI_PCM_H
14
15#include <linux/genalloc.h>
16#include <linux/platform_data/davinci_asp.h>
17#include <linux/platform_data/edma.h>
18
19struct davinci_pcm_dma_params {
20 int channel; /* sync dma channel ID */
21 unsigned short acnt;
22 dma_addr_t dma_addr; /* device physical address for DMA */
23 unsigned sram_size;
24 struct gen_pool *sram_pool; /* SRAM gen_pool for ping pong */
25 enum dma_event_q asp_chan_q; /* event queue number for ASP channel */
26 enum dma_event_q ram_chan_q; /* event queue number for RAM channel */
27 unsigned char data_type; /* xfer data type */
28 unsigned char convert_mono_stereo;
29 unsigned int fifo_level;
30};
31
32#if IS_ENABLED(CONFIG_SND_DAVINCI_SOC)
33int davinci_soc_platform_register(struct device *dev);
34#else
35static inline int davinci_soc_platform_register(struct device *dev)
36{
37 return 0;
38}
39#endif /* CONFIG_SND_DAVINCI_SOC */
40
41#endif
diff --git a/sound/soc/davinci/davinci-vcif.c b/sound/soc/davinci/davinci-vcif.c
index 5bee04279ebe..fabd05f24aeb 100644
--- a/sound/soc/davinci/davinci-vcif.c
+++ b/sound/soc/davinci/davinci-vcif.c
@@ -33,8 +33,9 @@
33#include <sound/pcm_params.h> 33#include <sound/pcm_params.h>
34#include <sound/initval.h> 34#include <sound/initval.h>
35#include <sound/soc.h> 35#include <sound/soc.h>
36#include <sound/dmaengine_pcm.h>
36 37
37#include "davinci-pcm.h" 38#include "edma-pcm.h"
38#include "davinci-i2s.h" 39#include "davinci-i2s.h"
39 40
40#define MOD_REG_BIT(val, mask, set) do { \ 41#define MOD_REG_BIT(val, mask, set) do { \
@@ -47,7 +48,8 @@
47 48
48struct davinci_vcif_dev { 49struct davinci_vcif_dev {
49 struct davinci_vc *davinci_vc; 50 struct davinci_vc *davinci_vc;
50 struct davinci_pcm_dma_params dma_params[2]; 51 struct snd_dmaengine_dai_dma_data dma_data[2];
52 int dma_request[2];
51}; 53};
52 54
53static void davinci_vcif_start(struct snd_pcm_substream *substream) 55static void davinci_vcif_start(struct snd_pcm_substream *substream)
@@ -93,8 +95,6 @@ static int davinci_vcif_hw_params(struct snd_pcm_substream *substream,
93{ 95{
94 struct davinci_vcif_dev *davinci_vcif_dev = snd_soc_dai_get_drvdata(dai); 96 struct davinci_vcif_dev *davinci_vcif_dev = snd_soc_dai_get_drvdata(dai);
95 struct davinci_vc *davinci_vc = davinci_vcif_dev->davinci_vc; 97 struct davinci_vc *davinci_vc = davinci_vcif_dev->davinci_vc;
96 struct davinci_pcm_dma_params *dma_params =
97 &davinci_vcif_dev->dma_params[substream->stream];
98 u32 w; 98 u32 w;
99 99
100 /* Restart the codec before setup */ 100 /* Restart the codec before setup */
@@ -113,16 +113,12 @@ static int davinci_vcif_hw_params(struct snd_pcm_substream *substream,
113 /* Determine xfer data type */ 113 /* Determine xfer data type */
114 switch (params_format(params)) { 114 switch (params_format(params)) {
115 case SNDRV_PCM_FORMAT_U8: 115 case SNDRV_PCM_FORMAT_U8:
116 dma_params->data_type = 0;
117
118 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | 116 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 |
119 DAVINCI_VC_CTRL_RD_UNSIGNED | 117 DAVINCI_VC_CTRL_RD_UNSIGNED |
120 DAVINCI_VC_CTRL_WD_BITS_8 | 118 DAVINCI_VC_CTRL_WD_BITS_8 |
121 DAVINCI_VC_CTRL_WD_UNSIGNED, 1); 119 DAVINCI_VC_CTRL_WD_UNSIGNED, 1);
122 break; 120 break;
123 case SNDRV_PCM_FORMAT_S8: 121 case SNDRV_PCM_FORMAT_S8:
124 dma_params->data_type = 1;
125
126 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | 122 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 |
127 DAVINCI_VC_CTRL_WD_BITS_8, 1); 123 DAVINCI_VC_CTRL_WD_BITS_8, 1);
128 124
@@ -130,8 +126,6 @@ static int davinci_vcif_hw_params(struct snd_pcm_substream *substream,
130 DAVINCI_VC_CTRL_WD_UNSIGNED, 0); 126 DAVINCI_VC_CTRL_WD_UNSIGNED, 0);
131 break; 127 break;
132 case SNDRV_PCM_FORMAT_S16_LE: 128 case SNDRV_PCM_FORMAT_S16_LE:
133 dma_params->data_type = 2;
134
135 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | 129 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 |
136 DAVINCI_VC_CTRL_RD_UNSIGNED | 130 DAVINCI_VC_CTRL_RD_UNSIGNED |
137 DAVINCI_VC_CTRL_WD_BITS_8 | 131 DAVINCI_VC_CTRL_WD_BITS_8 |
@@ -142,8 +136,6 @@ static int davinci_vcif_hw_params(struct snd_pcm_substream *substream,
142 return -EINVAL; 136 return -EINVAL;
143 } 137 }
144 138
145 dma_params->acnt = dma_params->data_type;
146
147 writel(w, davinci_vc->base + DAVINCI_VC_CTRL); 139 writel(w, davinci_vc->base + DAVINCI_VC_CTRL);
148 140
149 return 0; 141 return 0;
@@ -172,24 +164,25 @@ static int davinci_vcif_trigger(struct snd_pcm_substream *substream, int cmd,
172 return ret; 164 return ret;
173} 165}
174 166
175static int davinci_vcif_startup(struct snd_pcm_substream *substream,
176 struct snd_soc_dai *dai)
177{
178 struct davinci_vcif_dev *dev = snd_soc_dai_get_drvdata(dai);
179
180 snd_soc_dai_set_dma_data(dai, substream, dev->dma_params);
181 return 0;
182}
183
184#define DAVINCI_VCIF_RATES SNDRV_PCM_RATE_8000_48000 167#define DAVINCI_VCIF_RATES SNDRV_PCM_RATE_8000_48000
185 168
186static const struct snd_soc_dai_ops davinci_vcif_dai_ops = { 169static const struct snd_soc_dai_ops davinci_vcif_dai_ops = {
187 .startup = davinci_vcif_startup,
188 .trigger = davinci_vcif_trigger, 170 .trigger = davinci_vcif_trigger,
189 .hw_params = davinci_vcif_hw_params, 171 .hw_params = davinci_vcif_hw_params,
190}; 172};
191 173
174static int davinci_vcif_dai_probe(struct snd_soc_dai *dai)
175{
176 struct davinci_vcif_dev *dev = snd_soc_dai_get_drvdata(dai);
177
178 dai->playback_dma_data = &dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
179 dai->capture_dma_data = &dev->dma_data[SNDRV_PCM_STREAM_CAPTURE];
180
181 return 0;
182}
183
192static struct snd_soc_dai_driver davinci_vcif_dai = { 184static struct snd_soc_dai_driver davinci_vcif_dai = {
185 .probe = davinci_vcif_dai_probe,
193 .playback = { 186 .playback = {
194 .channels_min = 1, 187 .channels_min = 1,
195 .channels_max = 2, 188 .channels_max = 2,
@@ -225,16 +218,16 @@ static int davinci_vcif_probe(struct platform_device *pdev)
225 218
226 /* DMA tx params */ 219 /* DMA tx params */
227 davinci_vcif_dev->davinci_vc = davinci_vc; 220 davinci_vcif_dev->davinci_vc = davinci_vc;
228 davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].channel = 221 davinci_vcif_dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].filter_data =
229 davinci_vc->davinci_vcif.dma_tx_channel; 222 &davinci_vc->davinci_vcif.dma_tx_channel;
230 davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].dma_addr = 223 davinci_vcif_dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr =
231 davinci_vc->davinci_vcif.dma_tx_addr; 224 davinci_vc->davinci_vcif.dma_tx_addr;
232 225
233 /* DMA rx params */ 226 /* DMA rx params */
234 davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].channel = 227 davinci_vcif_dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].filter_data =
235 davinci_vc->davinci_vcif.dma_rx_channel; 228 &davinci_vc->davinci_vcif.dma_rx_channel;
236 davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].dma_addr = 229 davinci_vcif_dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr =
237 davinci_vc->davinci_vcif.dma_rx_addr; 230 davinci_vc->davinci_vcif.dma_rx_addr;
238 231
239 dev_set_drvdata(&pdev->dev, davinci_vcif_dev); 232 dev_set_drvdata(&pdev->dev, davinci_vcif_dev);
240 233
@@ -245,7 +238,7 @@ static int davinci_vcif_probe(struct platform_device *pdev)
245 return ret; 238 return ret;
246 } 239 }
247 240
248 ret = davinci_soc_platform_register(&pdev->dev); 241 ret = edma_pcm_platform_register(&pdev->dev);
249 if (ret) { 242 if (ret) {
250 dev_err(&pdev->dev, "register PCM failed: %d\n", ret); 243 dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
251 snd_soc_unregister_component(&pdev->dev); 244 snd_soc_unregister_component(&pdev->dev);
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 3f6959c8e2f7..de438871040b 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -512,6 +512,12 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
512 memcpy(priv->dai_link, fsl_asoc_card_dai, 512 memcpy(priv->dai_link, fsl_asoc_card_dai,
513 sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link)); 513 sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link));
514 514
515 ret = snd_soc_of_parse_audio_routing(&priv->card, "audio-routing");
516 if (ret) {
517 dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret);
518 goto asrc_fail;
519 }
520
515 /* Normal DAI Link */ 521 /* Normal DAI Link */
516 priv->dai_link[0].cpu_of_node = cpu_np; 522 priv->dai_link[0].cpu_of_node = cpu_np;
517 priv->dai_link[0].codec_of_node = codec_np; 523 priv->dai_link[0].codec_of_node = codec_np;
diff --git a/sound/soc/fsl/imx-es8328.c b/sound/soc/fsl/imx-es8328.c
index f8cf10e16ce9..20e7400e2611 100644
--- a/sound/soc/fsl/imx-es8328.c
+++ b/sound/soc/fsl/imx-es8328.c
@@ -53,9 +53,9 @@ static int imx_es8328_dai_init(struct snd_soc_pcm_runtime *rtd)
53 53
54 /* Headphone jack detection */ 54 /* Headphone jack detection */
55 if (gpio_is_valid(data->jack_gpio)) { 55 if (gpio_is_valid(data->jack_gpio)) {
56 ret = snd_soc_jack_new(rtd->codec, "Headphone", 56 ret = snd_soc_card_jack_new(rtd->card, "Headphone",
57 SND_JACK_HEADPHONE | SND_JACK_BTN_0, 57 SND_JACK_HEADPHONE | SND_JACK_BTN_0,
58 &headset_jack); 58 &headset_jack, NULL, 0);
59 if (ret) 59 if (ret)
60 return ret; 60 return ret;
61 61
diff --git a/sound/soc/fsl/wm1133-ev1.c b/sound/soc/fsl/wm1133-ev1.c
index a958937ab405..0653aa83c927 100644
--- a/sound/soc/fsl/wm1133-ev1.c
+++ b/sound/soc/fsl/wm1133-ev1.c
@@ -205,16 +205,14 @@ static int wm1133_ev1_init(struct snd_soc_pcm_runtime *rtd)
205 struct snd_soc_dapm_context *dapm = &codec->dapm; 205 struct snd_soc_dapm_context *dapm = &codec->dapm;
206 206
207 /* Headphone jack detection */ 207 /* Headphone jack detection */
208 snd_soc_jack_new(codec, "Headphone", SND_JACK_HEADPHONE, &hp_jack); 208 snd_soc_card_jack_new(rtd->card, "Headphone", SND_JACK_HEADPHONE,
209 snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins), 209 &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins));
210 hp_jack_pins);
211 wm8350_hp_jack_detect(codec, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE); 210 wm8350_hp_jack_detect(codec, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE);
212 211
213 /* Microphone jack detection */ 212 /* Microphone jack detection */
214 snd_soc_jack_new(codec, "Microphone", 213 snd_soc_card_jack_new(rtd->card, "Microphone",
215 SND_JACK_MICROPHONE | SND_JACK_BTN_0, &mic_jack); 214 SND_JACK_MICROPHONE | SND_JACK_BTN_0, &mic_jack,
216 snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins), 215 mic_jack_pins, ARRAY_SIZE(mic_jack_pins));
217 mic_jack_pins);
218 wm8350_mic_jack_detect(codec, &mic_jack, SND_JACK_MICROPHONE, 216 wm8350_mic_jack_detect(codec, &mic_jack, SND_JACK_MICROPHONE,
219 SND_JACK_BTN_0); 217 SND_JACK_BTN_0);
220 218
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index fb550b5869d2..c49a408fc7a6 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -176,11 +176,11 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
176 return ret; 176 return ret;
177 177
178 if (gpio_is_valid(priv->gpio_hp_det)) { 178 if (gpio_is_valid(priv->gpio_hp_det)) {
179 snd_soc_jack_new(codec->codec, "Headphones", SND_JACK_HEADPHONE, 179 snd_soc_card_jack_new(rtd->card, "Headphones",
180 &simple_card_hp_jack); 180 SND_JACK_HEADPHONE,
181 snd_soc_jack_add_pins(&simple_card_hp_jack, 181 &simple_card_hp_jack,
182 ARRAY_SIZE(simple_card_hp_jack_pins), 182 simple_card_hp_jack_pins,
183 simple_card_hp_jack_pins); 183 ARRAY_SIZE(simple_card_hp_jack_pins));
184 184
185 simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det; 185 simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det;
186 simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert; 186 simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert;
@@ -189,11 +189,11 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
189 } 189 }
190 190
191 if (gpio_is_valid(priv->gpio_mic_det)) { 191 if (gpio_is_valid(priv->gpio_mic_det)) {
192 snd_soc_jack_new(codec->codec, "Mic Jack", SND_JACK_MICROPHONE, 192 snd_soc_card_jack_new(rtd->card, "Mic Jack",
193 &simple_card_mic_jack); 193 SND_JACK_MICROPHONE,
194 snd_soc_jack_add_pins(&simple_card_mic_jack, 194 &simple_card_mic_jack,
195 ARRAY_SIZE(simple_card_mic_jack_pins), 195 simple_card_mic_jack_pins,
196 simple_card_mic_jack_pins); 196 ARRAY_SIZE(simple_card_mic_jack_pins));
197 simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det; 197 simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det;
198 simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert; 198 simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert;
199 snd_soc_jack_add_gpios(&simple_card_mic_jack, 1, 199 snd_soc_jack_add_gpios(&simple_card_mic_jack, 1,
diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c
index 9cf7d01479ad..fc5542034b9b 100644
--- a/sound/soc/intel/broadwell.c
+++ b/sound/soc/intel/broadwell.c
@@ -80,15 +80,9 @@ static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd)
80{ 80{
81 struct snd_soc_codec *codec = rtd->codec; 81 struct snd_soc_codec *codec = rtd->codec;
82 int ret = 0; 82 int ret = 0;
83 ret = snd_soc_jack_new(codec, "Headset", 83 ret = snd_soc_card_jack_new(rtd->card, "Headset",
84 SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset); 84 SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset,
85 85 broadwell_headset_pins, ARRAY_SIZE(broadwell_headset_pins));
86 if (ret)
87 return ret;
88
89 ret = snd_soc_jack_add_pins(&broadwell_headset,
90 ARRAY_SIZE(broadwell_headset_pins),
91 broadwell_headset_pins);
92 if (ret) 86 if (ret)
93 return ret; 87 return ret;
94 88
@@ -110,9 +104,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
110 channels->min = channels->max = 2; 104 channels->min = channels->max = 2;
111 105
112 /* set SSP0 to 16 bit */ 106 /* set SSP0 to 16 bit */
113 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 107 params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
114 SNDRV_PCM_HW_PARAM_FIRST_MASK],
115 SNDRV_PCM_FORMAT_S16_LE);
116 return 0; 108 return 0;
117} 109}
118 110
diff --git a/sound/soc/intel/byt-max98090.c b/sound/soc/intel/byt-max98090.c
index 9832afe7d22c..d8b1f038da1c 100644
--- a/sound/soc/intel/byt-max98090.c
+++ b/sound/soc/intel/byt-max98090.c
@@ -84,7 +84,6 @@ static struct snd_soc_jack_gpio hs_jack_gpios[] = {
84static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime) 84static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime)
85{ 85{
86 int ret; 86 int ret;
87 struct snd_soc_codec *codec = runtime->codec;
88 struct snd_soc_card *card = runtime->card; 87 struct snd_soc_card *card = runtime->card;
89 struct byt_max98090_private *drv = snd_soc_card_get_drvdata(card); 88 struct byt_max98090_private *drv = snd_soc_card_get_drvdata(card);
90 struct snd_soc_jack *jack = &drv->jack; 89 struct snd_soc_jack *jack = &drv->jack;
@@ -100,13 +99,9 @@ static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime)
100 } 99 }
101 100
102 /* Enable jack detection */ 101 /* Enable jack detection */
103 ret = snd_soc_jack_new(codec, "Headset", 102 ret = snd_soc_card_jack_new(runtime->card, "Headset",
104 SND_JACK_LINEOUT | SND_JACK_HEADSET, jack); 103 SND_JACK_LINEOUT | SND_JACK_HEADSET, jack,
105 if (ret) 104 hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
106 return ret;
107
108 ret = snd_soc_jack_add_pins(jack, ARRAY_SIZE(hs_jack_pins),
109 hs_jack_pins);
110 if (ret) 105 if (ret)
111 return ret; 106 return ret;
112 107
diff --git a/sound/soc/intel/bytcr_dpcm_rt5640.c b/sound/soc/intel/bytcr_dpcm_rt5640.c
index 59308629043e..3b262d01c1b3 100644
--- a/sound/soc/intel/bytcr_dpcm_rt5640.c
+++ b/sound/soc/intel/bytcr_dpcm_rt5640.c
@@ -113,9 +113,7 @@ static int byt_codec_fixup(struct snd_soc_pcm_runtime *rtd,
113 channels->min = channels->max = 2; 113 channels->min = channels->max = 2;
114 114
115 /* set SSP2 to 24-bit */ 115 /* set SSP2 to 24-bit */
116 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 116 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
117 SNDRV_PCM_HW_PARAM_FIRST_MASK],
118 SNDRV_PCM_FORMAT_S24_LE);
119 return 0; 117 return 0;
120} 118}
121 119
diff --git a/sound/soc/intel/cht_bsw_rt5645.c b/sound/soc/intel/cht_bsw_rt5645.c
index bd29617a9ab9..012227997ed9 100644
--- a/sound/soc/intel/cht_bsw_rt5645.c
+++ b/sound/soc/intel/cht_bsw_rt5645.c
@@ -169,17 +169,17 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
169 return ret; 169 return ret;
170 } 170 }
171 171
172 ret = snd_soc_jack_new(codec, "Headphone Jack", 172 ret = snd_soc_card_jack_new(runtime->card, "Headphone Jack",
173 SND_JACK_HEADPHONE, 173 SND_JACK_HEADPHONE, &ctx->hp_jack,
174 &ctx->hp_jack); 174 NULL, 0);
175 if (ret) { 175 if (ret) {
176 dev_err(runtime->dev, "HP jack creation failed %d\n", ret); 176 dev_err(runtime->dev, "HP jack creation failed %d\n", ret);
177 return ret; 177 return ret;
178 } 178 }
179 179
180 ret = snd_soc_jack_new(codec, "Mic Jack", 180 ret = snd_soc_card_jack_new(runtime->card, "Mic Jack",
181 SND_JACK_MICROPHONE, 181 SND_JACK_MICROPHONE, &ctx->mic_jack,
182 &ctx->mic_jack); 182 NULL, 0);
183 if (ret) { 183 if (ret) {
184 dev_err(runtime->dev, "Mic jack creation failed %d\n", ret); 184 dev_err(runtime->dev, "Mic jack creation failed %d\n", ret);
185 return ret; 185 return ret;
@@ -203,9 +203,7 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
203 channels->min = channels->max = 2; 203 channels->min = channels->max = 2;
204 204
205 /* set SSP2 to 24-bit */ 205 /* set SSP2 to 24-bit */
206 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 206 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
207 SNDRV_PCM_HW_PARAM_FIRST_MASK],
208 SNDRV_PCM_FORMAT_S24_LE);
209 return 0; 207 return 0;
210} 208}
211 209
diff --git a/sound/soc/intel/cht_bsw_rt5672.c b/sound/soc/intel/cht_bsw_rt5672.c
index ff016621583a..bc8dcacd5e6a 100644
--- a/sound/soc/intel/cht_bsw_rt5672.c
+++ b/sound/soc/intel/cht_bsw_rt5672.c
@@ -178,9 +178,7 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
178 channels->min = channels->max = 2; 178 channels->min = channels->max = 2;
179 179
180 /* set SSP2 to 24-bit */ 180 /* set SSP2 to 24-bit */
181 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 181 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
182 SNDRV_PCM_HW_PARAM_FIRST_MASK],
183 SNDRV_PCM_FORMAT_S24_LE);
184 return 0; 182 return 0;
185} 183}
186 184
@@ -217,7 +215,7 @@ static struct snd_soc_dai_link cht_dailink[] = {
217 .codec_dai_name = "snd-soc-dummy-dai", 215 .codec_dai_name = "snd-soc-dummy-dai",
218 .codec_name = "snd-soc-dummy", 216 .codec_name = "snd-soc-dummy",
219 .platform_name = "sst-mfld-platform", 217 .platform_name = "sst-mfld-platform",
220 .ignore_suspend = 1, 218 .nonatomic = true,
221 .dynamic = 1, 219 .dynamic = 1,
222 .dpcm_playback = 1, 220 .dpcm_playback = 1,
223 .dpcm_capture = 1, 221 .dpcm_capture = 1,
@@ -240,13 +238,13 @@ static struct snd_soc_dai_link cht_dailink[] = {
240 .cpu_dai_name = "ssp2-port", 238 .cpu_dai_name = "ssp2-port",
241 .platform_name = "sst-mfld-platform", 239 .platform_name = "sst-mfld-platform",
242 .no_pcm = 1, 240 .no_pcm = 1,
241 .nonatomic = true,
243 .codec_dai_name = "rt5670-aif1", 242 .codec_dai_name = "rt5670-aif1",
244 .codec_name = "i2c-10EC5670:00", 243 .codec_name = "i2c-10EC5670:00",
245 .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF 244 .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF
246 | SND_SOC_DAIFMT_CBS_CFS, 245 | SND_SOC_DAIFMT_CBS_CFS,
247 .init = cht_codec_init, 246 .init = cht_codec_init,
248 .be_hw_params_fixup = cht_codec_fixup, 247 .be_hw_params_fixup = cht_codec_fixup,
249 .ignore_suspend = 1,
250 .dpcm_playback = 1, 248 .dpcm_playback = 1,
251 .dpcm_capture = 1, 249 .dpcm_capture = 1,
252 .ops = &cht_be_ssp2_ops, 250 .ops = &cht_be_ssp2_ops,
@@ -285,7 +283,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
285static struct platform_driver snd_cht_mc_driver = { 283static struct platform_driver snd_cht_mc_driver = {
286 .driver = { 284 .driver = {
287 .name = "cht-bsw-rt5672", 285 .name = "cht-bsw-rt5672",
288 .pm = &snd_soc_pm_ops,
289 }, 286 },
290 .probe = snd_cht_mc_probe, 287 .probe = snd_cht_mc_probe,
291}; 288};
diff --git a/sound/soc/intel/haswell.c b/sound/soc/intel/haswell.c
index 35edf51a52aa..00fddd3f5dfb 100644
--- a/sound/soc/intel/haswell.c
+++ b/sound/soc/intel/haswell.c
@@ -56,9 +56,7 @@ static int haswell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
56 channels->min = channels->max = 2; 56 channels->min = channels->max = 2;
57 57
58 /* set SSP0 to 16 bit */ 58 /* set SSP0 to 16 bit */
59 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 59 params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
60 SNDRV_PCM_HW_PARAM_FIRST_MASK],
61 SNDRV_PCM_FORMAT_S16_LE);
62 return 0; 60 return 0;
63} 61}
64 62
diff --git a/sound/soc/intel/mfld_machine.c b/sound/soc/intel/mfld_machine.c
index 90b7a57713a0..49c09a0add79 100644
--- a/sound/soc/intel/mfld_machine.c
+++ b/sound/soc/intel/mfld_machine.c
@@ -228,10 +228,13 @@ static void mfld_jack_check(unsigned int intr_status)
228{ 228{
229 struct mfld_jack_data jack_data; 229 struct mfld_jack_data jack_data;
230 230
231 if (!mfld_codec)
232 return;
233
231 jack_data.mfld_jack = &mfld_jack; 234 jack_data.mfld_jack = &mfld_jack;
232 jack_data.intr_id = intr_status; 235 jack_data.intr_id = intr_status;
233 236
234 sn95031_jack_detection(&jack_data); 237 sn95031_jack_detection(mfld_codec, &jack_data);
235 /* TODO: add american headset detection post gpiolib support */ 238 /* TODO: add american headset detection post gpiolib support */
236} 239}
237 240
@@ -240,8 +243,6 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
240 struct snd_soc_dapm_context *dapm = &runtime->card->dapm; 243 struct snd_soc_dapm_context *dapm = &runtime->card->dapm;
241 int ret_val; 244 int ret_val;
242 245
243 mfld_codec = runtime->codec;
244
245 /* default is earpiece pin, userspace sets it explcitly */ 246 /* default is earpiece pin, userspace sets it explcitly */
246 snd_soc_dapm_disable_pin(dapm, "Headphones"); 247 snd_soc_dapm_disable_pin(dapm, "Headphones");
247 /* default is lineout NC, userspace sets it explcitly */ 248 /* default is lineout NC, userspace sets it explcitly */
@@ -254,20 +255,15 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
254 snd_soc_dapm_disable_pin(dapm, "LINEINR"); 255 snd_soc_dapm_disable_pin(dapm, "LINEINR");
255 256
256 /* Headset and button jack detection */ 257 /* Headset and button jack detection */
257 ret_val = snd_soc_jack_new(mfld_codec, "Intel(R) MID Audio Jack", 258 ret_val = snd_soc_card_jack_new(runtime->card,
258 SND_JACK_HEADSET | SND_JACK_BTN_0 | 259 "Intel(R) MID Audio Jack", SND_JACK_HEADSET |
259 SND_JACK_BTN_1, &mfld_jack); 260 SND_JACK_BTN_0 | SND_JACK_BTN_1, &mfld_jack,
261 mfld_jack_pins, ARRAY_SIZE(mfld_jack_pins));
260 if (ret_val) { 262 if (ret_val) {
261 pr_err("jack creation failed\n"); 263 pr_err("jack creation failed\n");
262 return ret_val; 264 return ret_val;
263 } 265 }
264 266
265 ret_val = snd_soc_jack_add_pins(&mfld_jack,
266 ARRAY_SIZE(mfld_jack_pins), mfld_jack_pins);
267 if (ret_val) {
268 pr_err("adding jack pins failed\n");
269 return ret_val;
270 }
271 ret_val = snd_soc_jack_add_zones(&mfld_jack, 267 ret_val = snd_soc_jack_add_zones(&mfld_jack,
272 ARRAY_SIZE(mfld_zones), mfld_zones); 268 ARRAY_SIZE(mfld_zones), mfld_zones);
273 if (ret_val) { 269 if (ret_val) {
@@ -275,6 +271,8 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
275 return ret_val; 271 return ret_val;
276 } 272 }
277 273
274 mfld_codec = runtime->codec;
275
278 /* we want to check if anything is inserted at boot, 276 /* we want to check if anything is inserted at boot,
279 * so send a fake event to codec and it will read adc 277 * so send a fake event to codec and it will read adc
280 * to find if anything is there or not */ 278 * to find if anything is there or not */
@@ -359,8 +357,6 @@ static irqreturn_t snd_mfld_jack_detection(int irq, void *data)
359{ 357{
360 struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data; 358 struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data;
361 359
362 if (mfld_jack.codec == NULL)
363 return IRQ_HANDLED;
364 mfld_jack_check(mc_drv_ctx->interrupt_status); 360 mfld_jack_check(mc_drv_ctx->interrupt_status);
365 361
366 return IRQ_HANDLED; 362 return IRQ_HANDLED;
diff --git a/sound/soc/intel/sst-mfld-platform-pcm.c b/sound/soc/intel/sst-mfld-platform-pcm.c
index 7523cbef8780..2fbaf2c75d17 100644
--- a/sound/soc/intel/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/sst-mfld-platform-pcm.c
@@ -594,11 +594,13 @@ static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream,
594 ret_val = stream->ops->stream_drop(sst->dev, str_id); 594 ret_val = stream->ops->stream_drop(sst->dev, str_id);
595 break; 595 break;
596 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 596 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
597 case SNDRV_PCM_TRIGGER_SUSPEND:
597 dev_dbg(rtd->dev, "sst: in pause\n"); 598 dev_dbg(rtd->dev, "sst: in pause\n");
598 status = SST_PLATFORM_PAUSED; 599 status = SST_PLATFORM_PAUSED;
599 ret_val = stream->ops->stream_pause(sst->dev, str_id); 600 ret_val = stream->ops->stream_pause(sst->dev, str_id);
600 break; 601 break;
601 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 602 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
603 case SNDRV_PCM_TRIGGER_RESUME:
602 dev_dbg(rtd->dev, "sst: in pause release\n"); 604 dev_dbg(rtd->dev, "sst: in pause release\n");
603 status = SST_PLATFORM_RUNNING; 605 status = SST_PLATFORM_RUNNING;
604 ret_val = stream->ops->stream_pause_release(sst->dev, str_id); 606 ret_val = stream->ops->stream_pause_release(sst->dev, str_id);
@@ -665,6 +667,9 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
665 667
666static int sst_soc_probe(struct snd_soc_platform *platform) 668static int sst_soc_probe(struct snd_soc_platform *platform)
667{ 669{
670 struct sst_data *drv = dev_get_drvdata(platform->dev);
671
672 drv->soc_card = platform->component.card;
668 return sst_dsp_init_v2_dpcm(platform); 673 return sst_dsp_init_v2_dpcm(platform);
669} 674}
670 675
@@ -727,9 +732,64 @@ static int sst_platform_remove(struct platform_device *pdev)
727 return 0; 732 return 0;
728} 733}
729 734
735#ifdef CONFIG_PM_SLEEP
736
737static int sst_soc_prepare(struct device *dev)
738{
739 struct sst_data *drv = dev_get_drvdata(dev);
740 int i;
741
742 /* suspend all pcms first */
743 snd_soc_suspend(drv->soc_card->dev);
744 snd_soc_poweroff(drv->soc_card->dev);
745
746 /* set the SSPs to idle */
747 for (i = 0; i < drv->soc_card->num_rtd; i++) {
748 struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
749
750 if (dai->active) {
751 send_ssp_cmd(dai, dai->name, 0);
752 sst_handle_vb_timer(dai, false);
753 }
754 }
755
756 return 0;
757}
758
759static void sst_soc_complete(struct device *dev)
760{
761 struct sst_data *drv = dev_get_drvdata(dev);
762 int i;
763
764 /* restart SSPs */
765 for (i = 0; i < drv->soc_card->num_rtd; i++) {
766 struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
767
768 if (dai->active) {
769 sst_handle_vb_timer(dai, true);
770 send_ssp_cmd(dai, dai->name, 1);
771 }
772 }
773 snd_soc_resume(drv->soc_card->dev);
774}
775
776#else
777
778#define sst_soc_prepare NULL
779#define sst_soc_complete NULL
780
781#endif
782
783
784static const struct dev_pm_ops sst_platform_pm = {
785 .prepare = sst_soc_prepare,
786 .complete = sst_soc_complete,
787};
788
730static struct platform_driver sst_platform_driver = { 789static struct platform_driver sst_platform_driver = {
731 .driver = { 790 .driver = {
732 .name = "sst-mfld-platform", 791 .name = "sst-mfld-platform",
792 .pm = &sst_platform_pm,
733 }, 793 },
734 .probe = sst_platform_probe, 794 .probe = sst_platform_probe,
735 .remove = sst_platform_remove, 795 .remove = sst_platform_remove,
diff --git a/sound/soc/intel/sst-mfld-platform.h b/sound/soc/intel/sst-mfld-platform.h
index 79c8d1246a8f..9094314be2b0 100644
--- a/sound/soc/intel/sst-mfld-platform.h
+++ b/sound/soc/intel/sst-mfld-platform.h
@@ -174,6 +174,7 @@ struct sst_data {
174 struct sst_platform_data *pdata; 174 struct sst_platform_data *pdata;
175 struct snd_sst_bytes_v2 *byte_stream; 175 struct snd_sst_bytes_v2 *byte_stream;
176 struct mutex lock; 176 struct mutex lock;
177 struct snd_soc_card *soc_card;
177}; 178};
178int sst_register_dsp(struct sst_device *sst); 179int sst_register_dsp(struct sst_device *sst);
179int sst_unregister_dsp(struct sst_device *sst); 180int sst_unregister_dsp(struct sst_device *sst);
diff --git a/sound/soc/intel/sst/sst.c b/sound/soc/intel/sst/sst.c
index 11c578651c1c..1a7eeec444b1 100644
--- a/sound/soc/intel/sst/sst.c
+++ b/sound/soc/intel/sst/sst.c
@@ -423,23 +423,135 @@ static int intel_sst_runtime_suspend(struct device *dev)
423 return ret; 423 return ret;
424} 424}
425 425
426static int intel_sst_runtime_resume(struct device *dev) 426static int intel_sst_suspend(struct device *dev)
427{ 427{
428 int ret = 0;
429 struct intel_sst_drv *ctx = dev_get_drvdata(dev); 428 struct intel_sst_drv *ctx = dev_get_drvdata(dev);
429 struct sst_fw_save *fw_save;
430 int i, ret = 0;
430 431
431 if (ctx->sst_state == SST_RESET) { 432 /* check first if we are already in SW reset */
432 ret = sst_load_fw(ctx); 433 if (ctx->sst_state == SST_RESET)
433 if (ret) { 434 return 0;
434 dev_err(dev, "FW download fail %d\n", ret); 435
435 sst_set_fw_state_locked(ctx, SST_RESET); 436 /*
437 * check if any stream is active and running
438 * they should already by suspend by soc_suspend
439 */
440 for (i = 1; i <= ctx->info.max_streams; i++) {
441 struct stream_info *stream = &ctx->streams[i];
442
443 if (stream->status == STREAM_RUNNING) {
444 dev_err(dev, "stream %d is running, cant susupend, abort\n", i);
445 return -EBUSY;
436 } 446 }
437 } 447 }
448 synchronize_irq(ctx->irq_num);
449 flush_workqueue(ctx->post_msg_wq);
450
451 /* Move the SST state to Reset */
452 sst_set_fw_state_locked(ctx, SST_RESET);
453
454 /* tell DSP we are suspending */
455 if (ctx->ops->save_dsp_context(ctx))
456 return -EBUSY;
457
458 /* save the memories */
459 fw_save = kzalloc(sizeof(*fw_save), GFP_KERNEL);
460 if (!fw_save)
461 return -ENOMEM;
462 fw_save->iram = kzalloc(ctx->iram_end - ctx->iram_base, GFP_KERNEL);
463 if (!fw_save->iram) {
464 ret = -ENOMEM;
465 goto iram;
466 }
467 fw_save->dram = kzalloc(ctx->dram_end - ctx->dram_base, GFP_KERNEL);
468 if (!fw_save->dram) {
469 ret = -ENOMEM;
470 goto dram;
471 }
472 fw_save->sram = kzalloc(SST_MAILBOX_SIZE, GFP_KERNEL);
473 if (!fw_save->sram) {
474 ret = -ENOMEM;
475 goto sram;
476 }
477
478 fw_save->ddr = kzalloc(ctx->ddr_end - ctx->ddr_base, GFP_KERNEL);
479 if (!fw_save->ddr) {
480 ret = -ENOMEM;
481 goto ddr;
482 }
483
484 memcpy32_fromio(fw_save->iram, ctx->iram, ctx->iram_end - ctx->iram_base);
485 memcpy32_fromio(fw_save->dram, ctx->dram, ctx->dram_end - ctx->dram_base);
486 memcpy32_fromio(fw_save->sram, ctx->mailbox, SST_MAILBOX_SIZE);
487 memcpy32_fromio(fw_save->ddr, ctx->ddr, ctx->ddr_end - ctx->ddr_base);
488
489 ctx->fw_save = fw_save;
490 ctx->ops->reset(ctx);
491 return 0;
492ddr:
493 kfree(fw_save->sram);
494sram:
495 kfree(fw_save->dram);
496dram:
497 kfree(fw_save->iram);
498iram:
499 kfree(fw_save);
500 return ret;
501}
502
503static int intel_sst_resume(struct device *dev)
504{
505 struct intel_sst_drv *ctx = dev_get_drvdata(dev);
506 struct sst_fw_save *fw_save = ctx->fw_save;
507 int ret = 0;
508 struct sst_block *block;
509
510 if (!fw_save)
511 return 0;
512
513 sst_set_fw_state_locked(ctx, SST_FW_LOADING);
514
515 /* we have to restore the memory saved */
516 ctx->ops->reset(ctx);
517
518 ctx->fw_save = NULL;
519
520 memcpy32_toio(ctx->iram, fw_save->iram, ctx->iram_end - ctx->iram_base);
521 memcpy32_toio(ctx->dram, fw_save->dram, ctx->dram_end - ctx->dram_base);
522 memcpy32_toio(ctx->mailbox, fw_save->sram, SST_MAILBOX_SIZE);
523 memcpy32_toio(ctx->ddr, fw_save->ddr, ctx->ddr_end - ctx->ddr_base);
524
525 kfree(fw_save->sram);
526 kfree(fw_save->dram);
527 kfree(fw_save->iram);
528 kfree(fw_save->ddr);
529 kfree(fw_save);
530
531 block = sst_create_block(ctx, 0, FW_DWNL_ID);
532 if (block == NULL)
533 return -ENOMEM;
534
535
536 /* start and wait for ack */
537 ctx->ops->start(ctx);
538 ret = sst_wait_timeout(ctx, block);
539 if (ret) {
540 dev_err(ctx->dev, "fw download failed %d\n", ret);
541 /* FW download failed due to timeout */
542 ret = -EBUSY;
543
544 } else {
545 sst_set_fw_state_locked(ctx, SST_FW_RUNNING);
546 }
547
548 sst_free_block(ctx, block);
438 return ret; 549 return ret;
439} 550}
440 551
441const struct dev_pm_ops intel_sst_pm = { 552const struct dev_pm_ops intel_sst_pm = {
553 .suspend = intel_sst_suspend,
554 .resume = intel_sst_resume,
442 .runtime_suspend = intel_sst_runtime_suspend, 555 .runtime_suspend = intel_sst_runtime_suspend,
443 .runtime_resume = intel_sst_runtime_resume,
444}; 556};
445EXPORT_SYMBOL_GPL(intel_sst_pm); 557EXPORT_SYMBOL_GPL(intel_sst_pm);
diff --git a/sound/soc/intel/sst/sst.h b/sound/soc/intel/sst/sst.h
index 562bc483d6b7..3f493862e98d 100644
--- a/sound/soc/intel/sst/sst.h
+++ b/sound/soc/intel/sst/sst.h
@@ -337,6 +337,13 @@ struct sst_shim_regs64 {
337 u64 csr2; 337 u64 csr2;
338}; 338};
339 339
340struct sst_fw_save {
341 void *iram;
342 void *dram;
343 void *sram;
344 void *ddr;
345};
346
340/** 347/**
341 * struct intel_sst_drv - driver ops 348 * struct intel_sst_drv - driver ops
342 * 349 *
@@ -428,6 +435,8 @@ struct intel_sst_drv {
428 * persistent till worker thread gets called 435 * persistent till worker thread gets called
429 */ 436 */
430 char firmware_name[FW_NAME_SIZE]; 437 char firmware_name[FW_NAME_SIZE];
438
439 struct sst_fw_save *fw_save;
431}; 440};
432 441
433/* misc definitions */ 442/* misc definitions */
@@ -544,4 +553,7 @@ int sst_alloc_drv_context(struct intel_sst_drv **ctx,
544int sst_context_init(struct intel_sst_drv *ctx); 553int sst_context_init(struct intel_sst_drv *ctx);
545void sst_context_cleanup(struct intel_sst_drv *ctx); 554void sst_context_cleanup(struct intel_sst_drv *ctx);
546void sst_configure_runtime_pm(struct intel_sst_drv *ctx); 555void sst_configure_runtime_pm(struct intel_sst_drv *ctx);
556void memcpy32_toio(void __iomem *dst, const void *src, int count);
557void memcpy32_fromio(void *dst, const void __iomem *src, int count);
558
547#endif 559#endif
diff --git a/sound/soc/intel/sst/sst_drv_interface.c b/sound/soc/intel/sst/sst_drv_interface.c
index 5f75ef3cdd22..f0e4b99b3aeb 100644
--- a/sound/soc/intel/sst/sst_drv_interface.c
+++ b/sound/soc/intel/sst/sst_drv_interface.c
@@ -138,12 +138,36 @@ int sst_get_stream(struct intel_sst_drv *ctx,
138static int sst_power_control(struct device *dev, bool state) 138static int sst_power_control(struct device *dev, bool state)
139{ 139{
140 struct intel_sst_drv *ctx = dev_get_drvdata(dev); 140 struct intel_sst_drv *ctx = dev_get_drvdata(dev);
141 141 int ret = 0;
142 dev_dbg(ctx->dev, "state:%d", state); 142 int usage_count = 0;
143 if (state == true) 143
144 return pm_runtime_get_sync(dev); 144#ifdef CONFIG_PM
145 else 145 usage_count = atomic_read(&dev->power.usage_count);
146#else
147 usage_count = 1;
148#endif
149
150 if (state == true) {
151 ret = pm_runtime_get_sync(dev);
152
153 dev_dbg(ctx->dev, "Enable: pm usage count: %d\n", usage_count);
154 if (ret < 0) {
155 dev_err(ctx->dev, "Runtime get failed with err: %d\n", ret);
156 return ret;
157 }
158 if ((ctx->sst_state == SST_RESET) && (usage_count == 1)) {
159 ret = sst_load_fw(ctx);
160 if (ret) {
161 dev_err(dev, "FW download fail %d\n", ret);
162 sst_set_fw_state_locked(ctx, SST_RESET);
163 ret = sst_pm_runtime_put(ctx);
164 }
165 }
166 } else {
167 dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", usage_count);
146 return sst_pm_runtime_put(ctx); 168 return sst_pm_runtime_put(ctx);
169 }
170 return ret;
147} 171}
148 172
149/* 173/*
@@ -572,6 +596,35 @@ static int sst_stream_drop(struct device *dev, int str_id)
572 return sst_drop_stream(ctx, str_id); 596 return sst_drop_stream(ctx, str_id);
573} 597}
574 598
599static int sst_stream_pause(struct device *dev, int str_id)
600{
601 struct stream_info *str_info;
602 struct intel_sst_drv *ctx = dev_get_drvdata(dev);
603
604 if (ctx->sst_state != SST_FW_RUNNING)
605 return 0;
606
607 str_info = get_stream_info(ctx, str_id);
608 if (!str_info)
609 return -EINVAL;
610
611 return sst_pause_stream(ctx, str_id);
612}
613
614static int sst_stream_resume(struct device *dev, int str_id)
615{
616 struct stream_info *str_info;
617 struct intel_sst_drv *ctx = dev_get_drvdata(dev);
618
619 if (ctx->sst_state != SST_FW_RUNNING)
620 return 0;
621
622 str_info = get_stream_info(ctx, str_id);
623 if (!str_info)
624 return -EINVAL;
625 return sst_resume_stream(ctx, str_id);
626}
627
575static int sst_stream_init(struct device *dev, struct pcm_stream_info *str_info) 628static int sst_stream_init(struct device *dev, struct pcm_stream_info *str_info)
576{ 629{
577 int str_id = 0; 630 int str_id = 0;
@@ -633,6 +686,8 @@ static struct sst_ops pcm_ops = {
633 .stream_init = sst_stream_init, 686 .stream_init = sst_stream_init,
634 .stream_start = sst_stream_start, 687 .stream_start = sst_stream_start,
635 .stream_drop = sst_stream_drop, 688 .stream_drop = sst_stream_drop,
689 .stream_pause = sst_stream_pause,
690 .stream_pause_release = sst_stream_resume,
636 .stream_read_tstamp = sst_read_timestamp, 691 .stream_read_tstamp = sst_read_timestamp,
637 .send_byte_stream = sst_send_byte_stream, 692 .send_byte_stream = sst_send_byte_stream,
638 .close = sst_close_pcm_stream, 693 .close = sst_close_pcm_stream,
diff --git a/sound/soc/intel/sst/sst_loader.c b/sound/soc/intel/sst/sst_loader.c
index 7888cd707853..e88907ae8b15 100644
--- a/sound/soc/intel/sst/sst_loader.c
+++ b/sound/soc/intel/sst/sst_loader.c
@@ -39,7 +39,15 @@
39#include "sst.h" 39#include "sst.h"
40#include "../sst-dsp.h" 40#include "../sst-dsp.h"
41 41
42static inline void memcpy32_toio(void __iomem *dst, const void *src, int count) 42void memcpy32_toio(void __iomem *dst, const void *src, int count)
43{
44 /* __iowrite32_copy uses 32-bit count values so divide by 4 for
45 * right count in words
46 */
47 __iowrite32_copy(dst, src, count/4);
48}
49
50void memcpy32_fromio(void *dst, const void __iomem *src, int count)
43{ 51{
44 /* __iowrite32_copy uses 32-bit count values so divide by 4 for 52 /* __iowrite32_copy uses 32-bit count values so divide by 4 for
45 * right count in words 53 * right count in words
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
index a2cd3486ac55..e7c78b0406b5 100644
--- a/sound/soc/omap/Kconfig
+++ b/sound/soc/omap/Kconfig
@@ -100,17 +100,19 @@ config SND_OMAP_SOC_OMAP_TWL4030
100 100
101config SND_OMAP_SOC_OMAP_ABE_TWL6040 101config SND_OMAP_SOC_OMAP_ABE_TWL6040
102 tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec" 102 tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec"
103 depends on TWL6040_CORE && SND_OMAP_SOC && (ARCH_OMAP4 || COMPILE_TEST) 103 depends on TWL6040_CORE && SND_OMAP_SOC && (ARCH_OMAP4 || SOC_OMAP5 || COMPILE_TEST)
104 select SND_OMAP_SOC_DMIC 104 select SND_OMAP_SOC_DMIC
105 select SND_OMAP_SOC_MCPDM 105 select SND_OMAP_SOC_MCPDM
106 select SND_SOC_TWL6040 106 select SND_SOC_TWL6040
107 select SND_SOC_DMIC 107 select SND_SOC_DMIC
108 select COMMON_CLK_PALMAS if SOC_OMAP5
108 help 109 help
109 Say Y if you want to add support for SoC audio on OMAP boards using 110 Say Y if you want to add support for SoC audio on OMAP boards using
110 ABE and twl6040 codec. This driver currently supports: 111 ABE and twl6040 codec. This driver currently supports:
111 - SDP4430/Blaze boards 112 - SDP4430/Blaze boards
112 - PandaBoard (4430) 113 - PandaBoard (4430)
113 - PandaBoardES (4460) 114 - PandaBoardES (4460)
115 - omap5-uevm (5432)
114 116
115config SND_OMAP_SOC_OMAP3_PANDORA 117config SND_OMAP_SOC_OMAP3_PANDORA
116 tristate "SoC Audio support for OMAP3 Pandora" 118 tristate "SoC Audio support for OMAP3 Pandora"
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index 706613077c15..16cc95fa4573 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -479,8 +479,8 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
479 479
480 /* Add hook switch - can be used to control the codec from userspace 480 /* Add hook switch - can be used to control the codec from userspace
481 * even if line discipline fails */ 481 * even if line discipline fails */
482 ret = snd_soc_jack_new(rtd->codec, "hook_switch", 482 ret = snd_soc_card_jack_new(card, "hook_switch", SND_JACK_HEADSET,
483 SND_JACK_HEADSET, &ams_delta_hook_switch); 483 &ams_delta_hook_switch, NULL, 0);
484 if (ret) 484 if (ret)
485 dev_warn(card->dev, 485 dev_warn(card->dev,
486 "Failed to allocate resources for hook switch, " 486 "Failed to allocate resources for hook switch, "
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index b9c65f1ad5a8..0843a68f277c 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -182,17 +182,17 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
182 182
183 /* Headset jack detection only if it is supported */ 183 /* Headset jack detection only if it is supported */
184 if (priv->jack_detection) { 184 if (priv->jack_detection) {
185 ret = snd_soc_jack_new(codec, "Headset Jack", 185 ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
186 SND_JACK_HEADSET, &hs_jack); 186 SND_JACK_HEADSET, &hs_jack,
187 hs_jack_pins,
188 ARRAY_SIZE(hs_jack_pins));
187 if (ret) 189 if (ret)
188 return ret; 190 return ret;
189 191
190 ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
191 hs_jack_pins);
192 twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); 192 twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
193 } 193 }
194 194
195 return ret; 195 return 0;
196} 196}
197 197
198static const struct snd_soc_dapm_route dmic_audio_map[] = { 198static const struct snd_soc_dapm_route dmic_audio_map[] = {
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 1343ecbf0bd5..6bb623a2a4df 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -39,7 +39,7 @@
39#define pcm_omap1510() 0 39#define pcm_omap1510() 0
40#endif 40#endif
41 41
42static const struct snd_pcm_hardware omap_pcm_hardware = { 42static struct snd_pcm_hardware omap_pcm_hardware = {
43 .info = SNDRV_PCM_INFO_MMAP | 43 .info = SNDRV_PCM_INFO_MMAP |
44 SNDRV_PCM_INFO_MMAP_VALID | 44 SNDRV_PCM_INFO_MMAP_VALID |
45 SNDRV_PCM_INFO_INTERLEAVED | 45 SNDRV_PCM_INFO_INTERLEAVED |
@@ -53,6 +53,24 @@ static const struct snd_pcm_hardware omap_pcm_hardware = {
53 .buffer_bytes_max = 128 * 1024, 53 .buffer_bytes_max = 128 * 1024,
54}; 54};
55 55
56/* sDMA supports only 1, 2, and 4 byte transfer elements. */
57static void omap_pcm_limit_supported_formats(void)
58{
59 int i;
60
61 for (i = 0; i < SNDRV_PCM_FORMAT_LAST; i++) {
62 switch (snd_pcm_format_physical_width(i)) {
63 case 8:
64 case 16:
65 case 32:
66 omap_pcm_hardware.formats |= (1LL << i);
67 break;
68 default:
69 break;
70 }
71 }
72}
73
56/* this may get called several times by oss emulation */ 74/* this may get called several times by oss emulation */
57static int omap_pcm_hw_params(struct snd_pcm_substream *substream, 75static int omap_pcm_hw_params(struct snd_pcm_substream *substream,
58 struct snd_pcm_hw_params *params) 76 struct snd_pcm_hw_params *params)
@@ -235,6 +253,7 @@ static struct snd_soc_platform_driver omap_soc_platform = {
235 253
236int omap_pcm_platform_register(struct device *dev) 254int omap_pcm_platform_register(struct device *dev)
237{ 255{
256 omap_pcm_limit_supported_formats();
238 return devm_snd_soc_register_platform(dev, &omap_soc_platform); 257 return devm_snd_soc_register_platform(dev, &omap_soc_platform);
239} 258}
240EXPORT_SYMBOL_GPL(omap_pcm_platform_register); 259EXPORT_SYMBOL_GPL(omap_pcm_platform_register);
diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c
index fb1f6bb87cd4..3673ada43bfb 100644
--- a/sound/soc/omap/omap-twl4030.c
+++ b/sound/soc/omap/omap-twl4030.c
@@ -170,14 +170,10 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd)
170 if (priv->jack_detect > 0) { 170 if (priv->jack_detect > 0) {
171 hs_jack_gpios[0].gpio = priv->jack_detect; 171 hs_jack_gpios[0].gpio = priv->jack_detect;
172 172
173 ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, 173 ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
174 &priv->hs_jack); 174 SND_JACK_HEADSET, &priv->hs_jack,
175 if (ret) 175 hs_jack_pins,
176 return ret; 176 ARRAY_SIZE(hs_jack_pins));
177
178 ret = snd_soc_jack_add_pins(&priv->hs_jack,
179 ARRAY_SIZE(hs_jack_pins),
180 hs_jack_pins);
181 if (ret) 177 if (ret)
182 return ret; 178 return ret;
183 179
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c
index 7f299357c2d2..c2ddf0fbfa28 100644
--- a/sound/soc/omap/rx51.c
+++ b/sound/soc/omap/rx51.c
@@ -311,9 +311,9 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
311 } 311 }
312 312
313 /* AV jack detection */ 313 /* AV jack detection */
314 err = snd_soc_jack_new(codec, "AV Jack", 314 err = snd_soc_card_jack_new(rtd->card, "AV Jack",
315 SND_JACK_HEADSET | SND_JACK_VIDEOOUT, 315 SND_JACK_HEADSET | SND_JACK_VIDEOOUT,
316 &rx51_av_jack); 316 &rx51_av_jack, NULL, 0);
317 if (err) { 317 if (err) {
318 dev_err(card->dev, "Failed to add AV Jack\n"); 318 dev_err(card->dev, "Failed to add AV Jack\n");
319 return err; 319 return err;
diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c
index 73eb5ddf9753..9f8be7cd567e 100644
--- a/sound/soc/pxa/hx4700.c
+++ b/sound/soc/pxa/hx4700.c
@@ -126,17 +126,12 @@ static const struct snd_soc_dapm_route hx4700_audio_map[] = {
126 */ 126 */
127static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd) 127static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd)
128{ 128{
129 struct snd_soc_codec *codec = rtd->codec;
130 int err; 129 int err;
131 130
132 /* Jack detection API stuff */ 131 /* Jack detection API stuff */
133 err = snd_soc_jack_new(codec, "Headphone Jack", 132 err = snd_soc_card_jack_new(rtd->card, "Headphone Jack",
134 SND_JACK_HEADPHONE, &hs_jack); 133 SND_JACK_HEADPHONE, &hs_jack, hs_jack_pin,
135 if (err) 134 ARRAY_SIZE(hs_jack_pin));
136 return err;
137
138 err = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pin),
139 hs_jack_pin);
140 if (err) 135 if (err)
141 return err; 136 return err;
142 137
diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c
index 910336c5ebeb..c20bbc042425 100644
--- a/sound/soc/pxa/palm27x.c
+++ b/sound/soc/pxa/palm27x.c
@@ -75,17 +75,12 @@ static struct snd_soc_card palm27x_asoc;
75 75
76static int palm27x_ac97_init(struct snd_soc_pcm_runtime *rtd) 76static int palm27x_ac97_init(struct snd_soc_pcm_runtime *rtd)
77{ 77{
78 struct snd_soc_codec *codec = rtd->codec;
79 int err; 78 int err;
80 79
81 /* Jack detection API stuff */ 80 /* Jack detection API stuff */
82 err = snd_soc_jack_new(codec, "Headphone Jack", 81 err = snd_soc_card_jack_new(rtd->card, "Headphone Jack",
83 SND_JACK_HEADPHONE, &hs_jack); 82 SND_JACK_HEADPHONE, &hs_jack, hs_jack_pins,
84 if (err) 83 ARRAY_SIZE(hs_jack_pins));
85 return err;
86
87 err = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
88 hs_jack_pins);
89 if (err) 84 if (err)
90 return err; 85 return err;
91 86
diff --git a/sound/soc/pxa/ttc-dkb.c b/sound/soc/pxa/ttc-dkb.c
index 5001dbb9b257..1753c7d9e760 100644
--- a/sound/soc/pxa/ttc-dkb.c
+++ b/sound/soc/pxa/ttc-dkb.c
@@ -78,15 +78,12 @@ static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
78 struct snd_soc_codec *codec = rtd->codec; 78 struct snd_soc_codec *codec = rtd->codec;
79 79
80 /* Headset jack detection */ 80 /* Headset jack detection */
81 snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE 81 snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE |
82 | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2, 82 SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2,
83 &hs_jack); 83 &hs_jack, hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
84 snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), 84 snd_soc_card_jack_new(rtd->card, "Microphone Jack", SND_JACK_MICROPHONE,
85 hs_jack_pins); 85 &mic_jack, mic_jack_pins,
86 snd_soc_jack_new(codec, "Microphone Jack", SND_JACK_MICROPHONE, 86 ARRAY_SIZE(mic_jack_pins));
87 &mic_jack);
88 snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins),
89 mic_jack_pins);
90 87
91 /* headphone, microphone detection & headset short detection */ 88 /* headphone, microphone detection & headset short detection */
92 pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE, 89 pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE,
diff --git a/sound/soc/pxa/z2.c b/sound/soc/pxa/z2.c
index 76ccb172d0a7..bcbfbe8303f7 100644
--- a/sound/soc/pxa/z2.c
+++ b/sound/soc/pxa/z2.c
@@ -143,13 +143,9 @@ static int z2_wm8750_init(struct snd_soc_pcm_runtime *rtd)
143 snd_soc_dapm_disable_pin(dapm, "MONO1"); 143 snd_soc_dapm_disable_pin(dapm, "MONO1");
144 144
145 /* Jack detection API stuff */ 145 /* Jack detection API stuff */
146 ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, 146 ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET,
147 &hs_jack); 147 &hs_jack, hs_jack_pins,
148 if (ret) 148 ARRAY_SIZE(hs_jack_pins));
149 goto err;
150
151 ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
152 hs_jack_pins);
153 if (ret) 149 if (ret)
154 goto err; 150 goto err;
155 151
diff --git a/sound/soc/samsung/h1940_uda1380.c b/sound/soc/samsung/h1940_uda1380.c
index 59b044255b78..c72e9fb26658 100644
--- a/sound/soc/samsung/h1940_uda1380.c
+++ b/sound/soc/samsung/h1940_uda1380.c
@@ -162,13 +162,8 @@ static struct platform_device *s3c24xx_snd_device;
162 162
163static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd) 163static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
164{ 164{
165 struct snd_soc_codec *codec = rtd->codec; 165 snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE,
166 166 &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins));
167 snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
168 &hp_jack);
169
170 snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
171 hp_jack_pins);
172 167
173 snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), 168 snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
174 hp_jack_gpios); 169 hp_jack_gpios);
diff --git a/sound/soc/samsung/littlemill.c b/sound/soc/samsung/littlemill.c
index 141519c21e21..31a820eb0ac3 100644
--- a/sound/soc/samsung/littlemill.c
+++ b/sound/soc/samsung/littlemill.c
@@ -260,12 +260,12 @@ static int littlemill_late_probe(struct snd_soc_card *card)
260 if (ret < 0) 260 if (ret < 0)
261 return ret; 261 return ret;
262 262
263 ret = snd_soc_jack_new(codec, "Headset", 263 ret = snd_soc_card_jack_new(card, "Headset",
264 SND_JACK_HEADSET | SND_JACK_MECHANICAL | 264 SND_JACK_HEADSET | SND_JACK_MECHANICAL |
265 SND_JACK_BTN_0 | SND_JACK_BTN_1 | 265 SND_JACK_BTN_0 | SND_JACK_BTN_1 |
266 SND_JACK_BTN_2 | SND_JACK_BTN_3 | 266 SND_JACK_BTN_2 | SND_JACK_BTN_3 |
267 SND_JACK_BTN_4 | SND_JACK_BTN_5, 267 SND_JACK_BTN_4 | SND_JACK_BTN_5,
268 &littlemill_headset); 268 &littlemill_headset, NULL, 0);
269 if (ret) 269 if (ret)
270 return ret; 270 return ret;
271 271
diff --git a/sound/soc/samsung/lowland.c b/sound/soc/samsung/lowland.c
index 243dea7ba38f..5f156093101e 100644
--- a/sound/soc/samsung/lowland.c
+++ b/sound/soc/samsung/lowland.c
@@ -56,16 +56,10 @@ static int lowland_wm5100_init(struct snd_soc_pcm_runtime *rtd)
56 return ret; 56 return ret;
57 } 57 }
58 58
59 ret = snd_soc_jack_new(codec, "Headset", 59 ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_LINEOUT |
60 SND_JACK_LINEOUT | SND_JACK_HEADSET | 60 SND_JACK_HEADSET | SND_JACK_BTN_0,
61 SND_JACK_BTN_0, 61 &lowland_headset, lowland_headset_pins,
62 &lowland_headset); 62 ARRAY_SIZE(lowland_headset_pins));
63 if (ret)
64 return ret;
65
66 ret = snd_soc_jack_add_pins(&lowland_headset,
67 ARRAY_SIZE(lowland_headset_pins),
68 lowland_headset_pins);
69 if (ret) 63 if (ret)
70 return ret; 64 return ret;
71 65
diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c
index 873f2cb4bebe..35e37c457f1f 100644
--- a/sound/soc/samsung/rx1950_uda1380.c
+++ b/sound/soc/samsung/rx1950_uda1380.c
@@ -211,13 +211,8 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream,
211 211
212static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd) 212static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)
213{ 213{
214 struct snd_soc_codec *codec = rtd->codec; 214 snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE,
215 215 &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins));
216 snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
217 &hp_jack);
218
219 snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
220 hp_jack_pins);
221 216
222 snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), 217 snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
223 hp_jack_gpios); 218 hp_jack_gpios);
diff --git a/sound/soc/samsung/smartq_wm8987.c b/sound/soc/samsung/smartq_wm8987.c
index 8291d2a5f152..dfbe2db1c407 100644
--- a/sound/soc/samsung/smartq_wm8987.c
+++ b/sound/soc/samsung/smartq_wm8987.c
@@ -151,13 +151,10 @@ static int smartq_wm8987_init(struct snd_soc_pcm_runtime *rtd)
151 snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); 151 snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
152 152
153 /* Headphone jack detection */ 153 /* Headphone jack detection */
154 err = snd_soc_jack_new(codec, "Headphone Jack", 154 err = snd_soc_card_jack_new(rtd->card, "Headphone Jack",
155 SND_JACK_HEADPHONE, &smartq_jack); 155 SND_JACK_HEADPHONE, &smartq_jack,
156 if (err) 156 smartq_jack_pins,
157 return err; 157 ARRAY_SIZE(smartq_jack_pins));
158
159 err = snd_soc_jack_add_pins(&smartq_jack, ARRAY_SIZE(smartq_jack_pins),
160 smartq_jack_pins);
161 if (err) 158 if (err)
162 return err; 159 return err;
163 160
diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c
index 5ec7c52282f2..2dcb988bdff2 100644
--- a/sound/soc/samsung/speyside.c
+++ b/sound/soc/samsung/speyside.c
@@ -153,16 +153,10 @@ static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd)
153 pr_err("Failed to request HP_SEL GPIO: %d\n", ret); 153 pr_err("Failed to request HP_SEL GPIO: %d\n", ret);
154 gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity); 154 gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity);
155 155
156 ret = snd_soc_jack_new(codec, "Headset", 156 ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_LINEOUT |
157 SND_JACK_LINEOUT | SND_JACK_HEADSET | 157 SND_JACK_HEADSET | SND_JACK_BTN_0,
158 SND_JACK_BTN_0, 158 &speyside_headset, speyside_headset_pins,
159 &speyside_headset); 159 ARRAY_SIZE(speyside_headset_pins));
160 if (ret)
161 return ret;
162
163 ret = snd_soc_jack_add_pins(&speyside_headset,
164 ARRAY_SIZE(speyside_headset_pins),
165 speyside_headset_pins);
166 if (ret) 160 if (ret)
167 return ret; 161 return ret;
168 162
diff --git a/sound/soc/samsung/tobermory.c b/sound/soc/samsung/tobermory.c
index 9c80506527c4..85ccfb7188cb 100644
--- a/sound/soc/samsung/tobermory.c
+++ b/sound/soc/samsung/tobermory.c
@@ -179,15 +179,10 @@ static int tobermory_late_probe(struct snd_soc_card *card)
179 if (ret < 0) 179 if (ret < 0)
180 return ret; 180 return ret;
181 181
182 ret = snd_soc_jack_new(codec, "Headset", 182 ret = snd_soc_card_jack_new(card, "Headset", SND_JACK_HEADSET |
183 SND_JACK_HEADSET | SND_JACK_BTN_0, 183 SND_JACK_BTN_0, &tobermory_headset,
184 &tobermory_headset); 184 tobermory_headset_pins,
185 if (ret) 185 ARRAY_SIZE(tobermory_headset_pins));
186 return ret;
187
188 ret = snd_soc_jack_add_pins(&tobermory_headset,
189 ARRAY_SIZE(tobermory_headset_pins),
190 tobermory_headset_pins);
191 if (ret) 186 if (ret)
192 return ret; 187 return ret;
193 188
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index e5c990889dcc..07aa54385ae0 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1578,6 +1578,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1578 snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets, 1578 snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets,
1579 card->num_dapm_widgets); 1579 card->num_dapm_widgets);
1580 1580
1581 if (card->of_dapm_widgets)
1582 snd_soc_dapm_new_controls(&card->dapm, card->of_dapm_widgets,
1583 card->num_of_dapm_widgets);
1584
1581 /* initialise the sound card only once */ 1585 /* initialise the sound card only once */
1582 if (card->probe) { 1586 if (card->probe) {
1583 ret = card->probe(card); 1587 ret = card->probe(card);
@@ -1633,6 +1637,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1633 snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes, 1637 snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
1634 card->num_dapm_routes); 1638 card->num_dapm_routes);
1635 1639
1640 if (card->of_dapm_routes)
1641 snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
1642 card->num_of_dapm_routes);
1643
1636 for (i = 0; i < card->num_links; i++) { 1644 for (i = 0; i < card->num_links; i++) {
1637 if (card->dai_link[i].dai_fmt) 1645 if (card->dai_link[i].dai_fmt)
1638 snd_soc_runtime_set_dai_fmt(&card->rtd[i], 1646 snd_soc_runtime_set_dai_fmt(&card->rtd[i],
@@ -3242,8 +3250,8 @@ int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
3242 widgets[i].name = wname; 3250 widgets[i].name = wname;
3243 } 3251 }
3244 3252
3245 card->dapm_widgets = widgets; 3253 card->of_dapm_widgets = widgets;
3246 card->num_dapm_widgets = num_widgets; 3254 card->num_of_dapm_widgets = num_widgets;
3247 3255
3248 return 0; 3256 return 0;
3249} 3257}
@@ -3327,8 +3335,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3327 } 3335 }
3328 } 3336 }
3329 3337
3330 card->num_dapm_routes = num_routes; 3338 card->num_of_dapm_routes = num_routes;
3331 card->dapm_routes = routes; 3339 card->of_dapm_routes = routes;
3332 3340
3333 return 0; 3341 return 0;
3334} 3342}
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 4380dcc064a5..9f60c25c4568 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -22,30 +22,42 @@
22#include <trace/events/asoc.h> 22#include <trace/events/asoc.h>
23 23
24/** 24/**
25 * snd_soc_jack_new - Create a new jack 25 * snd_soc_card_jack_new - Create a new jack
26 * @codec: ASoC codec 26 * @card: ASoC card
27 * @id: an identifying string for this jack 27 * @id: an identifying string for this jack
28 * @type: a bitmask of enum snd_jack_type values that can be detected by 28 * @type: a bitmask of enum snd_jack_type values that can be detected by
29 * this jack 29 * this jack
30 * @jack: structure to use for the jack 30 * @jack: structure to use for the jack
31 * @pins: Array of jack pins to be added to the jack or NULL
32 * @num_pins: Number of elements in the @pins array
31 * 33 *
32 * Creates a new jack object. 34 * Creates a new jack object.
33 * 35 *
34 * Returns zero if successful, or a negative error code on failure. 36 * Returns zero if successful, or a negative error code on failure.
35 * On success jack will be initialised. 37 * On success jack will be initialised.
36 */ 38 */
37int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, 39int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
38 struct snd_soc_jack *jack) 40 struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
41 unsigned int num_pins)
39{ 42{
43 int ret;
44
40 mutex_init(&jack->mutex); 45 mutex_init(&jack->mutex);
41 jack->codec = codec; 46 jack->card = card;
42 INIT_LIST_HEAD(&jack->pins); 47 INIT_LIST_HEAD(&jack->pins);
43 INIT_LIST_HEAD(&jack->jack_zones); 48 INIT_LIST_HEAD(&jack->jack_zones);
44 BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); 49 BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);
45 50
46 return snd_jack_new(codec->component.card->snd_card, id, type, &jack->jack); 51 ret = snd_jack_new(card->snd_card, id, type, &jack->jack);
52 if (ret)
53 return ret;
54
55 if (num_pins)
56 return snd_soc_jack_add_pins(jack, num_pins, pins);
57
58 return 0;
47} 59}
48EXPORT_SYMBOL_GPL(snd_soc_jack_new); 60EXPORT_SYMBOL_GPL(snd_soc_card_jack_new);
49 61
50/** 62/**
51 * snd_soc_jack_report - Report the current status for a jack 63 * snd_soc_jack_report - Report the current status for a jack
@@ -63,7 +75,6 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_new);
63 */ 75 */
64void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) 76void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
65{ 77{
66 struct snd_soc_codec *codec;
67 struct snd_soc_dapm_context *dapm; 78 struct snd_soc_dapm_context *dapm;
68 struct snd_soc_jack_pin *pin; 79 struct snd_soc_jack_pin *pin;
69 unsigned int sync = 0; 80 unsigned int sync = 0;
@@ -74,8 +85,7 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
74 if (!jack) 85 if (!jack)
75 return; 86 return;
76 87
77 codec = jack->codec; 88 dapm = &jack->card->dapm;
78 dapm = &codec->dapm;
79 89
80 mutex_lock(&jack->mutex); 90 mutex_lock(&jack->mutex);
81 91
@@ -175,12 +185,12 @@ int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
175 185
176 for (i = 0; i < count; i++) { 186 for (i = 0; i < count; i++) {
177 if (!pins[i].pin) { 187 if (!pins[i].pin) {
178 dev_err(jack->codec->dev, "ASoC: No name for pin %d\n", 188 dev_err(jack->card->dev, "ASoC: No name for pin %d\n",
179 i); 189 i);
180 return -EINVAL; 190 return -EINVAL;
181 } 191 }
182 if (!pins[i].mask) { 192 if (!pins[i].mask) {
183 dev_err(jack->codec->dev, "ASoC: No mask for pin %d" 193 dev_err(jack->card->dev, "ASoC: No mask for pin %d"
184 " (%s)\n", i, pins[i].pin); 194 " (%s)\n", i, pins[i].pin);
185 return -EINVAL; 195 return -EINVAL;
186 } 196 }
@@ -260,7 +270,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
260static irqreturn_t gpio_handler(int irq, void *data) 270static irqreturn_t gpio_handler(int irq, void *data)
261{ 271{
262 struct snd_soc_jack_gpio *gpio = data; 272 struct snd_soc_jack_gpio *gpio = data;
263 struct device *dev = gpio->jack->codec->component.card->dev; 273 struct device *dev = gpio->jack->card->dev;
264 274
265 trace_snd_soc_jack_irq(gpio->name); 275 trace_snd_soc_jack_irq(gpio->name);
266 276
@@ -299,7 +309,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
299 309
300 for (i = 0; i < count; i++) { 310 for (i = 0; i < count; i++) {
301 if (!gpios[i].name) { 311 if (!gpios[i].name) {
302 dev_err(jack->codec->dev, 312 dev_err(jack->card->dev,
303 "ASoC: No name for gpio at index %d\n", i); 313 "ASoC: No name for gpio at index %d\n", i);
304 ret = -EINVAL; 314 ret = -EINVAL;
305 goto undo; 315 goto undo;
@@ -320,7 +330,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
320 } else { 330 } else {
321 /* legacy GPIO number */ 331 /* legacy GPIO number */
322 if (!gpio_is_valid(gpios[i].gpio)) { 332 if (!gpio_is_valid(gpios[i].gpio)) {
323 dev_err(jack->codec->dev, 333 dev_err(jack->card->dev,
324 "ASoC: Invalid gpio %d\n", 334 "ASoC: Invalid gpio %d\n",
325 gpios[i].gpio); 335 gpios[i].gpio);
326 ret = -EINVAL; 336 ret = -EINVAL;
@@ -350,7 +360,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
350 if (gpios[i].wake) { 360 if (gpios[i].wake) {
351 ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1); 361 ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1);
352 if (ret != 0) 362 if (ret != 0)
353 dev_err(jack->codec->dev, 363 dev_err(jack->card->dev,
354 "ASoC: Failed to mark GPIO at index %d as wake source: %d\n", 364 "ASoC: Failed to mark GPIO at index %d as wake source: %d\n",
355 i, ret); 365 i, ret);
356 } 366 }
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 6b0136e7cb88..6e3781e88f9a 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2511,6 +2511,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2511 /* DAPM dai link stream work */ 2511 /* DAPM dai link stream work */
2512 INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); 2512 INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work);
2513 2513
2514 pcm->nonatomic = rtd->dai_link->nonatomic;
2514 rtd->pcm = pcm; 2515 rtd->pcm = pcm;
2515 pcm->private_data = rtd; 2516 pcm->private_data = rtd;
2516 2517
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
index 769aca2fc5f5..6dcd06a966c7 100644
--- a/sound/soc/tegra/tegra_alc5632.c
+++ b/sound/soc/tegra/tegra_alc5632.c
@@ -106,11 +106,10 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd)
106 struct snd_soc_dapm_context *dapm = &codec->dapm; 106 struct snd_soc_dapm_context *dapm = &codec->dapm;
107 struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(rtd->card); 107 struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(rtd->card);
108 108
109 snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, 109 snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET,
110 &tegra_alc5632_hs_jack); 110 &tegra_alc5632_hs_jack,
111 snd_soc_jack_add_pins(&tegra_alc5632_hs_jack, 111 tegra_alc5632_hs_jack_pins,
112 ARRAY_SIZE(tegra_alc5632_hs_jack_pins), 112 ARRAY_SIZE(tegra_alc5632_hs_jack_pins));
113 tegra_alc5632_hs_jack_pins);
114 113
115 if (gpio_is_valid(machine->gpio_hp_det)) { 114 if (gpio_is_valid(machine->gpio_hp_det)) {
116 tegra_alc5632_hp_jack_gpio.gpio = machine->gpio_hp_det; 115 tegra_alc5632_hp_jack_gpio.gpio = machine->gpio_hp_det;
diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c
index af3fb997b752..902da36581d1 100644
--- a/sound/soc/tegra/tegra_max98090.c
+++ b/sound/soc/tegra/tegra_max98090.c
@@ -133,24 +133,26 @@ static const struct snd_soc_dapm_widget tegra_max98090_dapm_widgets[] = {
133 SND_SOC_DAPM_HP("Headphones", NULL), 133 SND_SOC_DAPM_HP("Headphones", NULL),
134 SND_SOC_DAPM_SPK("Speakers", NULL), 134 SND_SOC_DAPM_SPK("Speakers", NULL),
135 SND_SOC_DAPM_MIC("Mic Jack", NULL), 135 SND_SOC_DAPM_MIC("Mic Jack", NULL),
136 SND_SOC_DAPM_MIC("Int Mic", NULL),
136}; 137};
137 138
138static const struct snd_kcontrol_new tegra_max98090_controls[] = { 139static const struct snd_kcontrol_new tegra_max98090_controls[] = {
140 SOC_DAPM_PIN_SWITCH("Headphones"),
139 SOC_DAPM_PIN_SWITCH("Speakers"), 141 SOC_DAPM_PIN_SWITCH("Speakers"),
142 SOC_DAPM_PIN_SWITCH("Mic Jack"),
143 SOC_DAPM_PIN_SWITCH("Int Mic"),
140}; 144};
141 145
142static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) 146static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
143{ 147{
144 struct snd_soc_dai *codec_dai = rtd->codec_dai;
145 struct snd_soc_codec *codec = codec_dai->codec;
146 struct tegra_max98090 *machine = snd_soc_card_get_drvdata(rtd->card); 148 struct tegra_max98090 *machine = snd_soc_card_get_drvdata(rtd->card);
147 149
148 if (gpio_is_valid(machine->gpio_hp_det)) { 150 if (gpio_is_valid(machine->gpio_hp_det)) {
149 snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, 151 snd_soc_card_jack_new(rtd->card, "Headphones",
150 &tegra_max98090_hp_jack); 152 SND_JACK_HEADPHONE,
151 snd_soc_jack_add_pins(&tegra_max98090_hp_jack, 153 &tegra_max98090_hp_jack,
152 ARRAY_SIZE(tegra_max98090_hp_jack_pins), 154 tegra_max98090_hp_jack_pins,
153 tegra_max98090_hp_jack_pins); 155 ARRAY_SIZE(tegra_max98090_hp_jack_pins));
154 156
155 tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det; 157 tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det;
156 snd_soc_jack_add_gpios(&tegra_max98090_hp_jack, 158 snd_soc_jack_add_gpios(&tegra_max98090_hp_jack,
@@ -159,11 +161,11 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
159 } 161 }
160 162
161 if (gpio_is_valid(machine->gpio_mic_det)) { 163 if (gpio_is_valid(machine->gpio_mic_det)) {
162 snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, 164 snd_soc_card_jack_new(rtd->card, "Mic Jack",
163 &tegra_max98090_mic_jack); 165 SND_JACK_MICROPHONE,
164 snd_soc_jack_add_pins(&tegra_max98090_mic_jack, 166 &tegra_max98090_mic_jack,
165 ARRAY_SIZE(tegra_max98090_mic_jack_pins), 167 tegra_max98090_mic_jack_pins,
166 tegra_max98090_mic_jack_pins); 168 ARRAY_SIZE(tegra_max98090_mic_jack_pins));
167 169
168 tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det; 170 tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det;
169 snd_soc_jack_add_gpios(&tegra_max98090_mic_jack, 171 snd_soc_jack_add_gpios(&tegra_max98090_mic_jack,
diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c
index ed759a3076b8..773daecaa5e8 100644
--- a/sound/soc/tegra/tegra_rt5640.c
+++ b/sound/soc/tegra/tegra_rt5640.c
@@ -108,15 +108,11 @@ static const struct snd_kcontrol_new tegra_rt5640_controls[] = {
108 108
109static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd) 109static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd)
110{ 110{
111 struct snd_soc_dai *codec_dai = rtd->codec_dai;
112 struct snd_soc_codec *codec = codec_dai->codec;
113 struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(rtd->card); 111 struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(rtd->card);
114 112
115 snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, 113 snd_soc_card_jack_new(rtd->card, "Headphones", SND_JACK_HEADPHONE,
116 &tegra_rt5640_hp_jack); 114 &tegra_rt5640_hp_jack, tegra_rt5640_hp_jack_pins,
117 snd_soc_jack_add_pins(&tegra_rt5640_hp_jack, 115 ARRAY_SIZE(tegra_rt5640_hp_jack_pins));
118 ARRAY_SIZE(tegra_rt5640_hp_jack_pins),
119 tegra_rt5640_hp_jack_pins);
120 116
121 if (gpio_is_valid(machine->gpio_hp_det)) { 117 if (gpio_is_valid(machine->gpio_hp_det)) {
122 tegra_rt5640_hp_jack_gpio.gpio = machine->gpio_hp_det; 118 tegra_rt5640_hp_jack_gpio.gpio = machine->gpio_hp_det;
diff --git a/sound/soc/tegra/tegra_rt5677.c b/sound/soc/tegra/tegra_rt5677.c
index e4cf978a6e3a..68d8b67e79c1 100644
--- a/sound/soc/tegra/tegra_rt5677.c
+++ b/sound/soc/tegra/tegra_rt5677.c
@@ -146,10 +146,9 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd)
146 struct snd_soc_dapm_context *dapm = &codec->dapm; 146 struct snd_soc_dapm_context *dapm = &codec->dapm;
147 struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(rtd->card); 147 struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(rtd->card);
148 148
149 snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, 149 snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE,
150 &tegra_rt5677_hp_jack); 150 &tegra_rt5677_hp_jack,
151 snd_soc_jack_add_pins(&tegra_rt5677_hp_jack, 1, 151 &tegra_rt5677_hp_jack_pins, 1);
152 &tegra_rt5677_hp_jack_pins);
153 152
154 if (gpio_is_valid(machine->gpio_hp_det)) { 153 if (gpio_is_valid(machine->gpio_hp_det)) {
155 tegra_rt5677_hp_jack_gpio.gpio = machine->gpio_hp_det; 154 tegra_rt5677_hp_jack_gpio.gpio = machine->gpio_hp_det;
@@ -158,10 +157,9 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd)
158 } 157 }
159 158
160 159
161 snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, 160 snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE,
162 &tegra_rt5677_mic_jack); 161 &tegra_rt5677_mic_jack,
163 snd_soc_jack_add_pins(&tegra_rt5677_mic_jack, 1, 162 &tegra_rt5677_mic_jack_pins, 1);
164 &tegra_rt5677_mic_jack_pins);
165 163
166 if (gpio_is_valid(machine->gpio_mic_present)) { 164 if (gpio_is_valid(machine->gpio_mic_present)) {
167 tegra_rt5677_mic_jack_gpio.gpio = machine->gpio_mic_present; 165 tegra_rt5677_mic_jack_gpio.gpio = machine->gpio_mic_present;
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
index e52420dae2b4..4a95b70f0cf0 100644
--- a/sound/soc/tegra/tegra_wm8903.c
+++ b/sound/soc/tegra/tegra_wm8903.c
@@ -177,21 +177,19 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
177 177
178 if (gpio_is_valid(machine->gpio_hp_det)) { 178 if (gpio_is_valid(machine->gpio_hp_det)) {
179 tegra_wm8903_hp_jack_gpio.gpio = machine->gpio_hp_det; 179 tegra_wm8903_hp_jack_gpio.gpio = machine->gpio_hp_det;
180 snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, 180 snd_soc_card_jack_new(rtd->card, "Headphone Jack",
181 &tegra_wm8903_hp_jack); 181 SND_JACK_HEADPHONE, &tegra_wm8903_hp_jack,
182 snd_soc_jack_add_pins(&tegra_wm8903_hp_jack, 182 tegra_wm8903_hp_jack_pins,
183 ARRAY_SIZE(tegra_wm8903_hp_jack_pins), 183 ARRAY_SIZE(tegra_wm8903_hp_jack_pins));
184 tegra_wm8903_hp_jack_pins);
185 snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack, 184 snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack,
186 1, 185 1,
187 &tegra_wm8903_hp_jack_gpio); 186 &tegra_wm8903_hp_jack_gpio);
188 } 187 }
189 188
190 snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, 189 snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE,
191 &tegra_wm8903_mic_jack); 190 &tegra_wm8903_mic_jack,
192 snd_soc_jack_add_pins(&tegra_wm8903_mic_jack, 191 tegra_wm8903_mic_jack_pins,
193 ARRAY_SIZE(tegra_wm8903_mic_jack_pins), 192 ARRAY_SIZE(tegra_wm8903_mic_jack_pins));
194 tegra_wm8903_mic_jack_pins);
195 wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, 193 wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE,
196 0); 194 0);
197 195