aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r--sound/soc/codecs/88pm860x-codec.c4
-rw-r--r--sound/soc/codecs/Kconfig21
-rw-r--r--sound/soc/codecs/Makefile8
-rw-r--r--sound/soc/codecs/ad1980.c36
-rw-r--r--sound/soc/codecs/adau1373.c1
-rw-r--r--sound/soc/codecs/adau1701.c1
-rw-r--r--sound/soc/codecs/adau1761-i2c.c1
-rw-r--r--sound/soc/codecs/adau1781-i2c.c1
-rw-r--r--sound/soc/codecs/adau1977-i2c.c1
-rw-r--r--sound/soc/codecs/adav803.c1
-rw-r--r--sound/soc/codecs/adav80x.c3
-rw-r--r--sound/soc/codecs/ak4535.c1
-rw-r--r--sound/soc/codecs/ak4641.c1
-rw-r--r--sound/soc/codecs/ak4642.c34
-rw-r--r--sound/soc/codecs/ak4671.c1
-rw-r--r--sound/soc/codecs/alc5623.c1
-rw-r--r--sound/soc/codecs/alc5632.c3
-rw-r--r--sound/soc/codecs/arizona.c129
-rw-r--r--sound/soc/codecs/arizona.h20
-rw-r--r--sound/soc/codecs/cs35l32.c60
-rw-r--r--sound/soc/codecs/cs35l32.h2
-rw-r--r--sound/soc/codecs/cs4265.c29
-rw-r--r--sound/soc/codecs/cs4270.c1
-rw-r--r--sound/soc/codecs/cs4271-i2c.c1
-rw-r--r--sound/soc/codecs/cs42l51-i2c.c1
-rw-r--r--sound/soc/codecs/cs42l52.c58
-rw-r--r--sound/soc/codecs/cs42l56.c50
-rw-r--r--sound/soc/codecs/cs42l73.c101
-rw-r--r--sound/soc/codecs/cs42xx8-i2c.c4
-rw-r--r--sound/soc/codecs/cs42xx8.c19
-rw-r--r--sound/soc/codecs/cs42xx8.h1
-rw-r--r--sound/soc/codecs/cs4349.c392
-rw-r--r--sound/soc/codecs/cs4349.h136
-rw-r--r--sound/soc/codecs/da7210.c7
-rw-r--r--sound/soc/codecs/da7213.c3
-rw-r--r--sound/soc/codecs/da732x.c15
-rw-r--r--sound/soc/codecs/da9055.c4
-rw-r--r--sound/soc/codecs/gtm601.c95
-rw-r--r--sound/soc/codecs/ics43432.c76
-rw-r--r--sound/soc/codecs/isabelle.c11
-rw-r--r--sound/soc/codecs/lm4857.c1
-rw-r--r--sound/soc/codecs/lm49453.c19
-rw-r--r--sound/soc/codecs/max9768.c64
-rw-r--r--sound/soc/codecs/max98088.c306
-rw-r--r--sound/soc/codecs/max98088.h2
-rw-r--r--sound/soc/codecs/max98090.c129
-rw-r--r--sound/soc/codecs/max98090.h1
-rw-r--r--sound/soc/codecs/max98095.c319
-rw-r--r--sound/soc/codecs/max98357a.c25
-rw-r--r--sound/soc/codecs/max9850.c1
-rw-r--r--sound/soc/codecs/max9877.c19
-rw-r--r--sound/soc/codecs/max98925.c4
-rw-r--r--sound/soc/codecs/mc13783.c6
-rw-r--r--sound/soc/codecs/ml26124.c3
-rw-r--r--sound/soc/codecs/pcm1681.c16
-rw-r--r--sound/soc/codecs/pcm512x-i2c.c1
-rw-r--r--sound/soc/codecs/rl6231.c104
-rw-r--r--sound/soc/codecs/rl6231.h1
-rw-r--r--sound/soc/codecs/rt286.c11
-rw-r--r--sound/soc/codecs/rt298.c1271
-rw-r--r--sound/soc/codecs/rt298.h206
-rw-r--r--sound/soc/codecs/rt5631.c1
-rw-r--r--sound/soc/codecs/rt5640.c52
-rw-r--r--sound/soc/codecs/rt5645.c439
-rw-r--r--sound/soc/codecs/rt5645.h31
-rw-r--r--sound/soc/codecs/rt5651.c12
-rw-r--r--sound/soc/codecs/rt5670.c14
-rw-r--r--sound/soc/codecs/rt5677-spi.c233
-rw-r--r--sound/soc/codecs/rt5677-spi.h8
-rw-r--r--sound/soc/codecs/rt5677.c152
-rw-r--r--sound/soc/codecs/rt5677.h5
-rw-r--r--sound/soc/codecs/sgtl5000.c1
-rw-r--r--sound/soc/codecs/sgtl5000.h2
-rw-r--r--sound/soc/codecs/si476x.c2
-rw-r--r--sound/soc/codecs/sirf-audio-codec.c4
-rw-r--r--sound/soc/codecs/ssm2518.c10
-rw-r--r--sound/soc/codecs/ssm2602-i2c.c1
-rw-r--r--sound/soc/codecs/ssm4567.c42
-rw-r--r--sound/soc/codecs/sta32x.c1
-rw-r--r--sound/soc/codecs/sta350.c1
-rw-r--r--sound/soc/codecs/sta529.c4
-rw-r--r--sound/soc/codecs/stac9766.c57
-rw-r--r--sound/soc/codecs/tas2552.c5
-rw-r--r--sound/soc/codecs/tas5086.c1
-rw-r--r--sound/soc/codecs/tas571x.c2
-rw-r--r--sound/soc/codecs/tfa9879.c3
-rw-r--r--sound/soc/codecs/tlv320aic31xx.c3
-rw-r--r--sound/soc/codecs/tlv320aic32x4.c1
-rw-r--r--sound/soc/codecs/tlv320aic3x.c3
-rw-r--r--sound/soc/codecs/tlv320dac33.c1
-rw-r--r--sound/soc/codecs/tpa6130a2.c1
-rw-r--r--sound/soc/codecs/ts3a227e.c48
-rw-r--r--sound/soc/codecs/uda1380.c1
-rw-r--r--sound/soc/codecs/wm1250-ev1.c1
-rw-r--r--sound/soc/codecs/wm2000.c1
-rw-r--r--sound/soc/codecs/wm2200.c7
-rw-r--r--sound/soc/codecs/wm5100.c5
-rw-r--r--sound/soc/codecs/wm5102.c27
-rw-r--r--sound/soc/codecs/wm5110.c30
-rw-r--r--sound/soc/codecs/wm8510.c2
-rw-r--r--sound/soc/codecs/wm8523.c2
-rw-r--r--sound/soc/codecs/wm8580.c2
-rw-r--r--sound/soc/codecs/wm8711.c1
-rw-r--r--sound/soc/codecs/wm8728.c1
-rw-r--r--sound/soc/codecs/wm8731.c1
-rw-r--r--sound/soc/codecs/wm8737.c1
-rw-r--r--sound/soc/codecs/wm8741.c1
-rw-r--r--sound/soc/codecs/wm8750.c1
-rw-r--r--sound/soc/codecs/wm8753.c1
-rw-r--r--sound/soc/codecs/wm8776.c1
-rw-r--r--sound/soc/codecs/wm8804-i2c.c1
-rw-r--r--sound/soc/codecs/wm8900.c1
-rw-r--r--sound/soc/codecs/wm8903.c1
-rw-r--r--sound/soc/codecs/wm8904.c1
-rw-r--r--sound/soc/codecs/wm8940.c1
-rw-r--r--sound/soc/codecs/wm8955.c1
-rw-r--r--sound/soc/codecs/wm8960.c1
-rw-r--r--sound/soc/codecs/wm8961.c1
-rw-r--r--sound/soc/codecs/wm8962.c7
-rw-r--r--sound/soc/codecs/wm8971.c1
-rw-r--r--sound/soc/codecs/wm8974.c1
-rw-r--r--sound/soc/codecs/wm8978.c1
-rw-r--r--sound/soc/codecs/wm8983.c1
-rw-r--r--sound/soc/codecs/wm8985.c1
-rw-r--r--sound/soc/codecs/wm8988.c1
-rw-r--r--sound/soc/codecs/wm8990.c1
-rw-r--r--sound/soc/codecs/wm8991.c1
-rw-r--r--sound/soc/codecs/wm8993.c5
-rw-r--r--sound/soc/codecs/wm8994.c18
-rw-r--r--sound/soc/codecs/wm8995.c1
-rw-r--r--sound/soc/codecs/wm8996.c3
-rw-r--r--sound/soc/codecs/wm8997.c20
-rw-r--r--sound/soc/codecs/wm9081.c3
-rw-r--r--sound/soc/codecs/wm9090.c1
-rw-r--r--sound/soc/codecs/wm9705.c40
-rw-r--r--sound/soc/codecs/wm9712.c45
-rw-r--r--sound/soc/codecs/wm9713.c48
-rw-r--r--sound/soc/codecs/wm9713.h2
138 files changed, 3393 insertions, 1885 deletions
diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c
index 38b3dad9d48a..4d91a6aa696b 100644
--- a/sound/soc/codecs/88pm860x-codec.c
+++ b/sound/soc/codecs/88pm860x-codec.c
@@ -1028,10 +1028,8 @@ static int pm860x_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1028 1028
1029 if (dir == PM860X_CLK_DIR_OUT) 1029 if (dir == PM860X_CLK_DIR_OUT)
1030 pm860x->dir = PM860X_CLK_DIR_OUT; 1030 pm860x->dir = PM860X_CLK_DIR_OUT;
1031 else { 1031 else /* Slave mode is not supported */
1032 pm860x->dir = PM860X_CLK_DIR_IN;
1033 return -EINVAL; 1032 return -EINVAL;
1034 }
1035 1033
1036 return 0; 1034 return 0;
1037} 1035}
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index e20834818bcb..0c9733ecd17f 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -53,6 +53,7 @@ config SND_SOC_ALL_CODECS
53 select SND_SOC_CS4271_I2C if I2C 53 select SND_SOC_CS4271_I2C if I2C
54 select SND_SOC_CS4271_SPI if SPI_MASTER 54 select SND_SOC_CS4271_SPI if SPI_MASTER
55 select SND_SOC_CS42XX8_I2C if I2C 55 select SND_SOC_CS42XX8_I2C if I2C
56 select SND_SOC_CS4349 if I2C
56 select SND_SOC_CX20442 if TTY 57 select SND_SOC_CX20442 if TTY
57 select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI 58 select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI
58 select SND_SOC_DA7213 if I2C 59 select SND_SOC_DA7213 if I2C
@@ -62,6 +63,8 @@ config SND_SOC_ALL_CODECS
62 select SND_SOC_BT_SCO 63 select SND_SOC_BT_SCO
63 select SND_SOC_ES8328_SPI if SPI_MASTER 64 select SND_SOC_ES8328_SPI if SPI_MASTER
64 select SND_SOC_ES8328_I2C if I2C 65 select SND_SOC_ES8328_I2C if I2C
66 select SND_SOC_GTM601
67 select SND_SOC_ICS43432
65 select SND_SOC_ISABELLE if I2C 68 select SND_SOC_ISABELLE if I2C
66 select SND_SOC_JZ4740_CODEC 69 select SND_SOC_JZ4740_CODEC
67 select SND_SOC_LM4857 if I2C 70 select SND_SOC_LM4857 if I2C
@@ -83,6 +86,7 @@ config SND_SOC_ALL_CODECS
83 select SND_SOC_PCM512x_I2C if I2C 86 select SND_SOC_PCM512x_I2C if I2C
84 select SND_SOC_PCM512x_SPI if SPI_MASTER 87 select SND_SOC_PCM512x_SPI if SPI_MASTER
85 select SND_SOC_RT286 if I2C 88 select SND_SOC_RT286 if I2C
89 select SND_SOC_RT298 if I2C
86 select SND_SOC_RT5631 if I2C 90 select SND_SOC_RT5631 if I2C
87 select SND_SOC_RT5640 if I2C 91 select SND_SOC_RT5640 if I2C
88 select SND_SOC_RT5645 if I2C 92 select SND_SOC_RT5645 if I2C
@@ -404,6 +408,11 @@ config SND_SOC_CS42XX8_I2C
404 select SND_SOC_CS42XX8 408 select SND_SOC_CS42XX8
405 select REGMAP_I2C 409 select REGMAP_I2C
406 410
411# Cirrus Logic CS4349 HiFi DAC
412config SND_SOC_CS4349
413 tristate "Cirrus Logic CS4349 CODEC"
414 depends on I2C
415
407config SND_SOC_CX20442 416config SND_SOC_CX20442
408 tristate 417 tristate
409 depends on TTY 418 depends on TTY
@@ -447,6 +456,12 @@ config SND_SOC_ES8328_SPI
447 tristate 456 tristate
448 select SND_SOC_ES8328 457 select SND_SOC_ES8328
449 458
459config SND_SOC_GTM601
460 tristate 'GTM601 UMTS modem audio codec'
461
462config SND_SOC_ICS43432
463 tristate
464
450config SND_SOC_ISABELLE 465config SND_SOC_ISABELLE
451 tristate 466 tristate
452 467
@@ -513,12 +528,18 @@ config SND_SOC_RL6231
513config SND_SOC_RL6347A 528config SND_SOC_RL6347A
514 tristate 529 tristate
515 default y if SND_SOC_RT286=y 530 default y if SND_SOC_RT286=y
531 default y if SND_SOC_RT298=y
516 default m if SND_SOC_RT286=m 532 default m if SND_SOC_RT286=m
533 default m if SND_SOC_RT298=m
517 534
518config SND_SOC_RT286 535config SND_SOC_RT286
519 tristate 536 tristate
520 depends on I2C 537 depends on I2C
521 538
539config SND_SOC_RT298
540 tristate
541 depends on I2C
542
522config SND_SOC_RT5631 543config SND_SOC_RT5631
523 tristate "Realtek ALC5631/RT5631 CODEC" 544 tristate "Realtek ALC5631/RT5631 CODEC"
524 depends on I2C 545 depends on I2C
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 7b4ce1b6e624..4a32077954ae 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -45,6 +45,7 @@ snd-soc-cs4271-i2c-objs := cs4271-i2c.o
45snd-soc-cs4271-spi-objs := cs4271-spi.o 45snd-soc-cs4271-spi-objs := cs4271-spi.o
46snd-soc-cs42xx8-objs := cs42xx8.o 46snd-soc-cs42xx8-objs := cs42xx8.o
47snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o 47snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o
48snd-soc-cs4349-objs := cs4349.o
48snd-soc-cx20442-objs := cx20442.o 49snd-soc-cx20442-objs := cx20442.o
49snd-soc-da7210-objs := da7210.o 50snd-soc-da7210-objs := da7210.o
50snd-soc-da7213-objs := da7213.o 51snd-soc-da7213-objs := da7213.o
@@ -55,6 +56,8 @@ snd-soc-dmic-objs := dmic.o
55snd-soc-es8328-objs := es8328.o 56snd-soc-es8328-objs := es8328.o
56snd-soc-es8328-i2c-objs := es8328-i2c.o 57snd-soc-es8328-i2c-objs := es8328-i2c.o
57snd-soc-es8328-spi-objs := es8328-spi.o 58snd-soc-es8328-spi-objs := es8328-spi.o
59snd-soc-gtm601-objs := gtm601.o
60snd-soc-ics43432-objs := ics43432.o
58snd-soc-isabelle-objs := isabelle.o 61snd-soc-isabelle-objs := isabelle.o
59snd-soc-jz4740-codec-objs := jz4740.o 62snd-soc-jz4740-codec-objs := jz4740.o
60snd-soc-l3-objs := l3.o 63snd-soc-l3-objs := l3.o
@@ -79,6 +82,7 @@ snd-soc-pcm512x-spi-objs := pcm512x-spi.o
79snd-soc-rl6231-objs := rl6231.o 82snd-soc-rl6231-objs := rl6231.o
80snd-soc-rl6347a-objs := rl6347a.o 83snd-soc-rl6347a-objs := rl6347a.o
81snd-soc-rt286-objs := rt286.o 84snd-soc-rt286-objs := rt286.o
85snd-soc-rt298-objs := rt298.o
82snd-soc-rt5631-objs := rt5631.o 86snd-soc-rt5631-objs := rt5631.o
83snd-soc-rt5640-objs := rt5640.o 87snd-soc-rt5640-objs := rt5640.o
84snd-soc-rt5645-objs := rt5645.o 88snd-soc-rt5645-objs := rt5645.o
@@ -233,6 +237,7 @@ obj-$(CONFIG_SND_SOC_CS4271_I2C) += snd-soc-cs4271-i2c.o
233obj-$(CONFIG_SND_SOC_CS4271_SPI) += snd-soc-cs4271-spi.o 237obj-$(CONFIG_SND_SOC_CS4271_SPI) += snd-soc-cs4271-spi.o
234obj-$(CONFIG_SND_SOC_CS42XX8) += snd-soc-cs42xx8.o 238obj-$(CONFIG_SND_SOC_CS42XX8) += snd-soc-cs42xx8.o
235obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o 239obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o
240obj-$(CONFIG_SND_SOC_CS4349) += snd-soc-cs4349.o
236obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o 241obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o
237obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o 242obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o
238obj-$(CONFIG_SND_SOC_DA7213) += snd-soc-da7213.o 243obj-$(CONFIG_SND_SOC_DA7213) += snd-soc-da7213.o
@@ -243,6 +248,8 @@ obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o
243obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o 248obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o
244obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o 249obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
245obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o 250obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
251obj-$(CONFIG_SND_SOC_GTM601) += snd-soc-gtm601.o
252obj-$(CONFIG_SND_SOC_ICS43432) += snd-soc-ics43432.o
246obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o 253obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o
247obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o 254obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o
248obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o 255obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o
@@ -267,6 +274,7 @@ obj-$(CONFIG_SND_SOC_PCM512x_SPI) += snd-soc-pcm512x-spi.o
267obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o 274obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o
268obj-$(CONFIG_SND_SOC_RL6347A) += snd-soc-rl6347a.o 275obj-$(CONFIG_SND_SOC_RL6347A) += snd-soc-rl6347a.o
269obj-$(CONFIG_SND_SOC_RT286) += snd-soc-rt286.o 276obj-$(CONFIG_SND_SOC_RT286) += snd-soc-rt286.o
277obj-$(CONFIG_SND_SOC_RT298) += snd-soc-rt298.o
270obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o 278obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o
271obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o 279obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o
272obj-$(CONFIG_SND_SOC_RT5645) += snd-soc-rt5645.o 280obj-$(CONFIG_SND_SOC_RT5645) += snd-soc-rt5645.o
diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c
index 3cc69a626454..9ef20dbccbe3 100644
--- a/sound/soc/codecs/ad1980.c
+++ b/sound/soc/codecs/ad1980.c
@@ -202,19 +202,21 @@ static struct snd_soc_dai_driver ad1980_dai = {
202 .formats = SND_SOC_STD_AC97_FMTS, }, 202 .formats = SND_SOC_STD_AC97_FMTS, },
203}; 203};
204 204
205#define AD1980_VENDOR_ID 0x41445300
206#define AD1980_VENDOR_MASK 0xffffff00
207
205static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) 208static int ad1980_reset(struct snd_soc_codec *codec, int try_warm)
206{ 209{
207 struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); 210 struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
208 unsigned int retry_cnt = 0; 211 unsigned int retry_cnt = 0;
212 int ret;
209 213
210 do { 214 do {
211 if (try_warm && soc_ac97_ops->warm_reset) { 215 ret = snd_ac97_reset(ac97, true, AD1980_VENDOR_ID,
212 soc_ac97_ops->warm_reset(ac97); 216 AD1980_VENDOR_MASK);
213 if (snd_soc_read(codec, AC97_RESET) == 0x0090) 217 if (ret >= 0)
214 return 1; 218 return 0;
215 }
216 219
217 soc_ac97_ops->reset(ac97);
218 /* 220 /*
219 * Set bit 16slot in register 74h, then every slot will has only 221 * Set bit 16slot in register 74h, then every slot will has only
220 * 16 bits. This command is sent out in 20bit mode, in which 222 * 16 bits. This command is sent out in 20bit mode, in which
@@ -223,8 +225,6 @@ static int ad1980_reset(struct snd_soc_codec *codec, int try_warm)
223 */ 225 */
224 snd_soc_write(codec, AC97_AD_SERIAL_CFG, 0x9900); 226 snd_soc_write(codec, AC97_AD_SERIAL_CFG, 0x9900);
225 227
226 if (snd_soc_read(codec, AC97_RESET) == 0x0090)
227 return 0;
228 } while (retry_cnt++ < 10); 228 } while (retry_cnt++ < 10);
229 229
230 dev_err(codec->dev, "Failed to reset: AC97 link error\n"); 230 dev_err(codec->dev, "Failed to reset: AC97 link error\n");
@@ -240,7 +240,7 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
240 u16 vendor_id2; 240 u16 vendor_id2;
241 u16 ext_status; 241 u16 ext_status;
242 242
243 ac97 = snd_soc_new_ac97_codec(codec); 243 ac97 = snd_soc_new_ac97_codec(codec, 0, 0);
244 if (IS_ERR(ac97)) { 244 if (IS_ERR(ac97)) {
245 ret = PTR_ERR(ac97); 245 ret = PTR_ERR(ac97);
246 dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); 246 dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret);
@@ -260,22 +260,10 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
260 if (ret < 0) 260 if (ret < 0)
261 goto reset_err; 261 goto reset_err;
262 262
263 /* Read out vendor ID to make sure it is ad1980 */
264 if (snd_soc_read(codec, AC97_VENDOR_ID1) != 0x4144) {
265 ret = -ENODEV;
266 goto reset_err;
267 }
268
269 vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2); 263 vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2);
270 264 if (vendor_id2 == 0x5374) {
271 if (vendor_id2 != 0x5370) { 265 dev_warn(codec->dev,
272 if (vendor_id2 != 0x5374) { 266 "Found AD1981 - only 2/2 IN/OUT Channels supported\n");
273 ret = -ENODEV;
274 goto reset_err;
275 } else {
276 dev_warn(codec->dev,
277 "Found AD1981 - only 2/2 IN/OUT Channels supported\n");
278 }
279 } 267 }
280 268
281 /* unmute captures and playbacks volume */ 269 /* unmute captures and playbacks volume */
diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c
index a43160254929..6c96860f46de 100644
--- a/sound/soc/codecs/adau1373.c
+++ b/sound/soc/codecs/adau1373.c
@@ -1534,7 +1534,6 @@ MODULE_DEVICE_TABLE(i2c, adau1373_i2c_id);
1534static struct i2c_driver adau1373_i2c_driver = { 1534static struct i2c_driver adau1373_i2c_driver = {
1535 .driver = { 1535 .driver = {
1536 .name = "adau1373", 1536 .name = "adau1373",
1537 .owner = THIS_MODULE,
1538 }, 1537 },
1539 .probe = adau1373_i2c_probe, 1538 .probe = adau1373_i2c_probe,
1540 .remove = adau1373_i2c_remove, 1539 .remove = adau1373_i2c_remove,
diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
index ff7f846e3b76..de53c0d7bf10 100644
--- a/sound/soc/codecs/adau1701.c
+++ b/sound/soc/codecs/adau1701.c
@@ -915,7 +915,6 @@ MODULE_DEVICE_TABLE(i2c, adau1701_i2c_id);
915static struct i2c_driver adau1701_i2c_driver = { 915static struct i2c_driver adau1701_i2c_driver = {
916 .driver = { 916 .driver = {
917 .name = "adau1701", 917 .name = "adau1701",
918 .owner = THIS_MODULE,
919 .of_match_table = of_match_ptr(adau1701_dt_ids), 918 .of_match_table = of_match_ptr(adau1701_dt_ids),
920 }, 919 },
921 .probe = adau1701_i2c_probe, 920 .probe = adau1701_i2c_probe,
diff --git a/sound/soc/codecs/adau1761-i2c.c b/sound/soc/codecs/adau1761-i2c.c
index 862796dec693..348ccb17d3cc 100644
--- a/sound/soc/codecs/adau1761-i2c.c
+++ b/sound/soc/codecs/adau1761-i2c.c
@@ -47,7 +47,6 @@ MODULE_DEVICE_TABLE(i2c, adau1761_i2c_ids);
47static struct i2c_driver adau1761_i2c_driver = { 47static struct i2c_driver adau1761_i2c_driver = {
48 .driver = { 48 .driver = {
49 .name = "adau1761", 49 .name = "adau1761",
50 .owner = THIS_MODULE,
51 }, 50 },
52 .probe = adau1761_i2c_probe, 51 .probe = adau1761_i2c_probe,
53 .remove = adau1761_i2c_remove, 52 .remove = adau1761_i2c_remove,
diff --git a/sound/soc/codecs/adau1781-i2c.c b/sound/soc/codecs/adau1781-i2c.c
index 2ce4362ccec1..0e32bba92339 100644
--- a/sound/soc/codecs/adau1781-i2c.c
+++ b/sound/soc/codecs/adau1781-i2c.c
@@ -45,7 +45,6 @@ MODULE_DEVICE_TABLE(i2c, adau1781_i2c_ids);
45static struct i2c_driver adau1781_i2c_driver = { 45static struct i2c_driver adau1781_i2c_driver = {
46 .driver = { 46 .driver = {
47 .name = "adau1781", 47 .name = "adau1781",
48 .owner = THIS_MODULE,
49 }, 48 },
50 .probe = adau1781_i2c_probe, 49 .probe = adau1781_i2c_probe,
51 .remove = adau1781_i2c_remove, 50 .remove = adau1781_i2c_remove,
diff --git a/sound/soc/codecs/adau1977-i2c.c b/sound/soc/codecs/adau1977-i2c.c
index 9700e8c838c9..21e7394a972a 100644
--- a/sound/soc/codecs/adau1977-i2c.c
+++ b/sound/soc/codecs/adau1977-i2c.c
@@ -46,7 +46,6 @@ MODULE_DEVICE_TABLE(i2c, adau1977_i2c_ids);
46static struct i2c_driver adau1977_i2c_driver = { 46static struct i2c_driver adau1977_i2c_driver = {
47 .driver = { 47 .driver = {
48 .name = "adau1977", 48 .name = "adau1977",
49 .owner = THIS_MODULE,
50 }, 49 },
51 .probe = adau1977_i2c_probe, 50 .probe = adau1977_i2c_probe,
52 .remove = adau1977_i2c_remove, 51 .remove = adau1977_i2c_remove,
diff --git a/sound/soc/codecs/adav803.c b/sound/soc/codecs/adav803.c
index 66d9fce34e62..52881faedcf6 100644
--- a/sound/soc/codecs/adav803.c
+++ b/sound/soc/codecs/adav803.c
@@ -36,7 +36,6 @@ static int adav803_remove(struct i2c_client *client)
36static struct i2c_driver adav803_driver = { 36static struct i2c_driver adav803_driver = {
37 .driver = { 37 .driver = {
38 .name = "adav803", 38 .name = "adav803",
39 .owner = THIS_MODULE,
40 }, 39 },
41 .probe = adav803_probe, 40 .probe = adav803_probe,
42 .remove = adav803_remove, 41 .remove = adav803_remove,
diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c
index 36d842570745..198c924551b7 100644
--- a/sound/soc/codecs/adav80x.c
+++ b/sound/soc/codecs/adav80x.c
@@ -113,7 +113,7 @@
113 113
114#define ADAV80X_PLL_OUTE_SYSCLKPD(x) BIT(2 - (x)) 114#define ADAV80X_PLL_OUTE_SYSCLKPD(x) BIT(2 - (x))
115 115
116static struct reg_default adav80x_reg_defaults[] = { 116static const struct reg_default adav80x_reg_defaults[] = {
117 { ADAV80X_PLAYBACK_CTRL, 0x01 }, 117 { ADAV80X_PLAYBACK_CTRL, 0x01 },
118 { ADAV80X_AUX_IN_CTRL, 0x01 }, 118 { ADAV80X_AUX_IN_CTRL, 0x01 },
119 { ADAV80X_REC_CTRL, 0x02 }, 119 { ADAV80X_REC_CTRL, 0x02 },
@@ -865,7 +865,6 @@ const struct regmap_config adav80x_regmap_config = {
865 .val_bits = 8, 865 .val_bits = 8,
866 .pad_bits = 1, 866 .pad_bits = 1,
867 .reg_bits = 7, 867 .reg_bits = 7,
868 .read_flag_mask = 0x01,
869 868
870 .max_register = ADAV80X_PLL_OUTE, 869 .max_register = ADAV80X_PLL_OUTE,
871 870
diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c
index 8670861e5bec..54428c64387b 100644
--- a/sound/soc/codecs/ak4535.c
+++ b/sound/soc/codecs/ak4535.c
@@ -444,7 +444,6 @@ MODULE_DEVICE_TABLE(i2c, ak4535_i2c_id);
444static struct i2c_driver ak4535_i2c_driver = { 444static struct i2c_driver ak4535_i2c_driver = {
445 .driver = { 445 .driver = {
446 .name = "ak4535", 446 .name = "ak4535",
447 .owner = THIS_MODULE,
448 }, 447 },
449 .probe = ak4535_i2c_probe, 448 .probe = ak4535_i2c_probe,
450 .remove = ak4535_i2c_remove, 449 .remove = ak4535_i2c_remove,
diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c
index 2d0ff4595ea0..b14176f8d884 100644
--- a/sound/soc/codecs/ak4641.c
+++ b/sound/soc/codecs/ak4641.c
@@ -609,7 +609,6 @@ MODULE_DEVICE_TABLE(i2c, ak4641_i2c_id);
609static struct i2c_driver ak4641_i2c_driver = { 609static struct i2c_driver ak4641_i2c_driver = {
610 .driver = { 610 .driver = {
611 .name = "ak4641", 611 .name = "ak4641",
612 .owner = THIS_MODULE,
613 }, 612 },
614 .probe = ak4641_i2c_probe, 613 .probe = ak4641_i2c_probe,
615 .remove = ak4641_i2c_remove, 614 .remove = ak4641_i2c_remove,
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 7c0f6552c229..4a90143d0e90 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -64,12 +64,15 @@
64#define FIL1_0 0x1c 64#define FIL1_0 0x1c
65#define FIL1_1 0x1d 65#define FIL1_1 0x1d
66#define FIL1_2 0x1e 66#define FIL1_2 0x1e
67#define FIL1_3 0x1f 67#define FIL1_3 0x1f /* The maximum valid register for ak4642 */
68#define PW_MGMT4 0x20 68#define PW_MGMT4 0x20
69#define MD_CTL5 0x21 69#define MD_CTL5 0x21
70#define LO_MS 0x22 70#define LO_MS 0x22
71#define HP_MS 0x23 71#define HP_MS 0x23
72#define SPK_MS 0x24 72#define SPK_MS 0x24 /* The maximum valid register for ak4643 */
73#define EQ_FBEQAB 0x25
74#define EQ_FBEQCD 0x26
75#define EQ_FBEQE 0x27 /* The maximum valid register for ak4648 */
73 76
74/* PW_MGMT1*/ 77/* PW_MGMT1*/
75#define PMVCM (1 << 6) /* VCOM Power Management */ 78#define PMVCM (1 << 6) /* VCOM Power Management */
@@ -241,7 +244,7 @@ static const struct snd_soc_dapm_route ak4642_intercon[] = {
241/* 244/*
242 * ak4642 register cache 245 * ak4642 register cache
243 */ 246 */
244static const struct reg_default ak4642_reg[] = { 247static const struct reg_default ak4643_reg[] = {
245 { 0, 0x00 }, { 1, 0x00 }, { 2, 0x01 }, { 3, 0x00 }, 248 { 0, 0x00 }, { 1, 0x00 }, { 2, 0x01 }, { 3, 0x00 },
246 { 4, 0x02 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x00 }, 249 { 4, 0x02 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x00 },
247 { 8, 0xe1 }, { 9, 0xe1 }, { 10, 0x18 }, { 11, 0x00 }, 250 { 8, 0xe1 }, { 9, 0xe1 }, { 10, 0x18 }, { 11, 0x00 },
@@ -254,6 +257,14 @@ static const struct reg_default ak4642_reg[] = {
254 { 36, 0x00 }, 257 { 36, 0x00 },
255}; 258};
256 259
260/* The default settings for 0x0 ~ 0x1f registers are the same for ak4642
261 and ak4643. So we reuse the ak4643 reg_default for ak4642.
262 The valid registers for ak4642 are 0x0 ~ 0x1f which is a subset of ak4643,
263 so define NUM_AK4642_REG_DEFAULTS for ak4642.
264*/
265#define ak4642_reg ak4643_reg
266#define NUM_AK4642_REG_DEFAULTS (FIL1_3 + 1)
267
257static const struct reg_default ak4648_reg[] = { 268static const struct reg_default ak4648_reg[] = {
258 { 0, 0x00 }, { 1, 0x00 }, { 2, 0x01 }, { 3, 0x00 }, 269 { 0, 0x00 }, { 1, 0x00 }, { 2, 0x01 }, { 3, 0x00 },
259 { 4, 0x02 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x00 }, 270 { 4, 0x02 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x00 },
@@ -535,15 +546,23 @@ static struct snd_soc_codec_driver soc_codec_dev_ak4642 = {
535static const struct regmap_config ak4642_regmap = { 546static const struct regmap_config ak4642_regmap = {
536 .reg_bits = 8, 547 .reg_bits = 8,
537 .val_bits = 8, 548 .val_bits = 8,
538 .max_register = ARRAY_SIZE(ak4642_reg) + 1, 549 .max_register = FIL1_3,
539 .reg_defaults = ak4642_reg, 550 .reg_defaults = ak4642_reg,
540 .num_reg_defaults = ARRAY_SIZE(ak4642_reg), 551 .num_reg_defaults = NUM_AK4642_REG_DEFAULTS,
552};
553
554static const struct regmap_config ak4643_regmap = {
555 .reg_bits = 8,
556 .val_bits = 8,
557 .max_register = SPK_MS,
558 .reg_defaults = ak4643_reg,
559 .num_reg_defaults = ARRAY_SIZE(ak4643_reg),
541}; 560};
542 561
543static const struct regmap_config ak4648_regmap = { 562static const struct regmap_config ak4648_regmap = {
544 .reg_bits = 8, 563 .reg_bits = 8,
545 .val_bits = 8, 564 .val_bits = 8,
546 .max_register = ARRAY_SIZE(ak4648_reg) + 1, 565 .max_register = EQ_FBEQE,
547 .reg_defaults = ak4648_reg, 566 .reg_defaults = ak4648_reg,
548 .num_reg_defaults = ARRAY_SIZE(ak4648_reg), 567 .num_reg_defaults = ARRAY_SIZE(ak4648_reg),
549}; 568};
@@ -553,7 +572,7 @@ static const struct ak4642_drvdata ak4642_drvdata = {
553}; 572};
554 573
555static const struct ak4642_drvdata ak4643_drvdata = { 574static const struct ak4642_drvdata ak4643_drvdata = {
556 .regmap_config = &ak4642_regmap, 575 .regmap_config = &ak4643_regmap,
557}; 576};
558 577
559static const struct ak4642_drvdata ak4648_drvdata = { 578static const struct ak4642_drvdata ak4648_drvdata = {
@@ -626,7 +645,6 @@ MODULE_DEVICE_TABLE(i2c, ak4642_i2c_id);
626static struct i2c_driver ak4642_i2c_driver = { 645static struct i2c_driver ak4642_i2c_driver = {
627 .driver = { 646 .driver = {
628 .name = "ak4642-codec", 647 .name = "ak4642-codec",
629 .owner = THIS_MODULE,
630 .of_match_table = ak4642_of_match, 648 .of_match_table = ak4642_of_match,
631 }, 649 },
632 .probe = ak4642_i2c_probe, 650 .probe = ak4642_i2c_probe,
diff --git a/sound/soc/codecs/ak4671.c b/sound/soc/codecs/ak4671.c
index 0e59063aeb6f..c73a9f6914b6 100644
--- a/sound/soc/codecs/ak4671.c
+++ b/sound/soc/codecs/ak4671.c
@@ -663,7 +663,6 @@ MODULE_DEVICE_TABLE(i2c, ak4671_i2c_id);
663static struct i2c_driver ak4671_i2c_driver = { 663static struct i2c_driver ak4671_i2c_driver = {
664 .driver = { 664 .driver = {
665 .name = "ak4671-codec", 665 .name = "ak4671-codec",
666 .owner = THIS_MODULE,
667 }, 666 },
668 .probe = ak4671_i2c_probe, 667 .probe = ak4671_i2c_probe,
669 .remove = ak4671_i2c_remove, 668 .remove = ak4671_i2c_remove,
diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c
index 0fc24e0d518c..cf99c4e90acc 100644
--- a/sound/soc/codecs/alc5623.c
+++ b/sound/soc/codecs/alc5623.c
@@ -1085,7 +1085,6 @@ MODULE_DEVICE_TABLE(of, alc5623_of_match);
1085static struct i2c_driver alc5623_i2c_driver = { 1085static struct i2c_driver alc5623_i2c_driver = {
1086 .driver = { 1086 .driver = {
1087 .name = "alc562x-codec", 1087 .name = "alc562x-codec",
1088 .owner = THIS_MODULE,
1089 .of_match_table = of_match_ptr(alc5623_of_match), 1088 .of_match_table = of_match_ptr(alc5623_of_match),
1090 }, 1089 },
1091 .probe = alc5623_i2c_probe, 1090 .probe = alc5623_i2c_probe,
diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c
index 607a63b9705f..ef6de511dc7e 100644
--- a/sound/soc/codecs/alc5632.c
+++ b/sound/soc/codecs/alc5632.c
@@ -35,7 +35,7 @@
35/* 35/*
36 * ALC5632 register cache 36 * ALC5632 register cache
37 */ 37 */
38static struct reg_default alc5632_reg_defaults[] = { 38static const struct reg_default alc5632_reg_defaults[] = {
39 { 2, 0x8080 }, /* R2 - Speaker Output Volume */ 39 { 2, 0x8080 }, /* R2 - Speaker Output Volume */
40 { 4, 0x8080 }, /* R4 - Headphone Output Volume */ 40 { 4, 0x8080 }, /* R4 - Headphone Output Volume */
41 { 6, 0x8080 }, /* R6 - AUXOUT Volume */ 41 { 6, 0x8080 }, /* R6 - AUXOUT Volume */
@@ -1183,7 +1183,6 @@ MODULE_DEVICE_TABLE(of, alc5632_of_match);
1183static struct i2c_driver alc5632_i2c_driver = { 1183static struct i2c_driver alc5632_i2c_driver = {
1184 .driver = { 1184 .driver = {
1185 .name = "alc5632", 1185 .name = "alc5632",
1186 .owner = THIS_MODULE,
1187 .of_match_table = of_match_ptr(alc5632_of_match), 1186 .of_match_table = of_match_ptr(alc5632_of_match),
1188 }, 1187 },
1189 .probe = alc5632_i2c_probe, 1188 .probe = alc5632_i2c_probe,
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 802e05eae3e9..8a2221ab3d10 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1366,7 +1366,7 @@ static void arizona_wm5102_set_dac_comp(struct snd_soc_codec *codec,
1366{ 1366{
1367 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); 1367 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
1368 struct arizona *arizona = priv->arizona; 1368 struct arizona *arizona = priv->arizona;
1369 struct reg_default dac_comp[] = { 1369 struct reg_sequence dac_comp[] = {
1370 { 0x80, 0x3 }, 1370 { 0x80, 0x3 },
1371 { ARIZONA_DAC_COMP_1, 0 }, 1371 { ARIZONA_DAC_COMP_1, 0 },
1372 { ARIZONA_DAC_COMP_2, 0 }, 1372 { ARIZONA_DAC_COMP_2, 0 },
@@ -1504,7 +1504,7 @@ static int arizona_hw_params(struct snd_pcm_substream *substream,
1504 else 1504 else
1505 rates = &arizona_48k_bclk_rates[0]; 1505 rates = &arizona_48k_bclk_rates[0];
1506 1506
1507 wl = snd_pcm_format_width(params_format(params)); 1507 wl = params_width(params);
1508 1508
1509 if (tdm_slots) { 1509 if (tdm_slots) {
1510 arizona_aif_dbg(dai, "Configuring for %d %d bit TDM slots\n", 1510 arizona_aif_dbg(dai, "Configuring for %d %d bit TDM slots\n",
@@ -1756,17 +1756,6 @@ int arizona_init_dai(struct arizona_priv *priv, int id)
1756} 1756}
1757EXPORT_SYMBOL_GPL(arizona_init_dai); 1757EXPORT_SYMBOL_GPL(arizona_init_dai);
1758 1758
1759static irqreturn_t arizona_fll_clock_ok(int irq, void *data)
1760{
1761 struct arizona_fll *fll = data;
1762
1763 arizona_fll_dbg(fll, "clock OK\n");
1764
1765 complete(&fll->ok);
1766
1767 return IRQ_HANDLED;
1768}
1769
1770static struct { 1759static struct {
1771 unsigned int min; 1760 unsigned int min;
1772 unsigned int max; 1761 unsigned int max;
@@ -2048,17 +2037,18 @@ static int arizona_is_enabled_fll(struct arizona_fll *fll)
2048static int arizona_enable_fll(struct arizona_fll *fll) 2037static int arizona_enable_fll(struct arizona_fll *fll)
2049{ 2038{
2050 struct arizona *arizona = fll->arizona; 2039 struct arizona *arizona = fll->arizona;
2051 unsigned long time_left;
2052 bool use_sync = false; 2040 bool use_sync = false;
2053 int already_enabled = arizona_is_enabled_fll(fll); 2041 int already_enabled = arizona_is_enabled_fll(fll);
2054 struct arizona_fll_cfg cfg; 2042 struct arizona_fll_cfg cfg;
2043 int i;
2044 unsigned int val;
2055 2045
2056 if (already_enabled < 0) 2046 if (already_enabled < 0)
2057 return already_enabled; 2047 return already_enabled;
2058 2048
2059 if (already_enabled) { 2049 if (already_enabled) {
2060 /* Facilitate smooth refclk across the transition */ 2050 /* Facilitate smooth refclk across the transition */
2061 regmap_update_bits_async(fll->arizona->regmap, fll->base + 0x7, 2051 regmap_update_bits_async(fll->arizona->regmap, fll->base + 0x9,
2062 ARIZONA_FLL1_GAIN_MASK, 0); 2052 ARIZONA_FLL1_GAIN_MASK, 0);
2063 regmap_update_bits_async(fll->arizona->regmap, fll->base + 1, 2053 regmap_update_bits_async(fll->arizona->regmap, fll->base + 1,
2064 ARIZONA_FLL1_FREERUN, 2054 ARIZONA_FLL1_FREERUN,
@@ -2110,9 +2100,6 @@ static int arizona_enable_fll(struct arizona_fll *fll)
2110 if (!already_enabled) 2100 if (!already_enabled)
2111 pm_runtime_get(arizona->dev); 2101 pm_runtime_get(arizona->dev);
2112 2102
2113 /* Clear any pending completions */
2114 try_wait_for_completion(&fll->ok);
2115
2116 regmap_update_bits_async(arizona->regmap, fll->base + 1, 2103 regmap_update_bits_async(arizona->regmap, fll->base + 1,
2117 ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); 2104 ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA);
2118 if (use_sync) 2105 if (use_sync)
@@ -2124,10 +2111,24 @@ static int arizona_enable_fll(struct arizona_fll *fll)
2124 regmap_update_bits_async(arizona->regmap, fll->base + 1, 2111 regmap_update_bits_async(arizona->regmap, fll->base + 1,
2125 ARIZONA_FLL1_FREERUN, 0); 2112 ARIZONA_FLL1_FREERUN, 0);
2126 2113
2127 time_left = wait_for_completion_timeout(&fll->ok, 2114 arizona_fll_dbg(fll, "Waiting for FLL lock...\n");
2128 msecs_to_jiffies(250)); 2115 val = 0;
2129 if (time_left == 0) 2116 for (i = 0; i < 15; i++) {
2117 if (i < 5)
2118 usleep_range(200, 400);
2119 else
2120 msleep(20);
2121
2122 regmap_read(arizona->regmap,
2123 ARIZONA_INTERRUPT_RAW_STATUS_5,
2124 &val);
2125 if (val & (ARIZONA_FLL1_CLOCK_OK_STS << (fll->id - 1)))
2126 break;
2127 }
2128 if (i == 15)
2130 arizona_fll_warn(fll, "Timed out waiting for lock\n"); 2129 arizona_fll_warn(fll, "Timed out waiting for lock\n");
2130 else
2131 arizona_fll_dbg(fll, "FLL locked (%d polls)\n", i);
2131 2132
2132 return 0; 2133 return 0;
2133} 2134}
@@ -2212,11 +2213,8 @@ EXPORT_SYMBOL_GPL(arizona_set_fll);
2212int arizona_init_fll(struct arizona *arizona, int id, int base, int lock_irq, 2213int arizona_init_fll(struct arizona *arizona, int id, int base, int lock_irq,
2213 int ok_irq, struct arizona_fll *fll) 2214 int ok_irq, struct arizona_fll *fll)
2214{ 2215{
2215 int ret;
2216 unsigned int val; 2216 unsigned int val;
2217 2217
2218 init_completion(&fll->ok);
2219
2220 fll->id = id; 2218 fll->id = id;
2221 fll->base = base; 2219 fll->base = base;
2222 fll->arizona = arizona; 2220 fll->arizona = arizona;
@@ -2238,13 +2236,6 @@ int arizona_init_fll(struct arizona *arizona, int id, int base, int lock_irq,
2238 snprintf(fll->clock_ok_name, sizeof(fll->clock_ok_name), 2236 snprintf(fll->clock_ok_name, sizeof(fll->clock_ok_name),
2239 "FLL%d clock OK", id); 2237 "FLL%d clock OK", id);
2240 2238
2241 ret = arizona_request_irq(arizona, ok_irq, fll->clock_ok_name,
2242 arizona_fll_clock_ok, fll);
2243 if (ret != 0) {
2244 dev_err(arizona->dev, "Failed to get FLL%d clock OK IRQ: %d\n",
2245 id, ret);
2246 }
2247
2248 regmap_update_bits(arizona->regmap, fll->base + 1, 2239 regmap_update_bits(arizona->regmap, fll->base + 1,
2249 ARIZONA_FLL1_FREERUN, 0); 2240 ARIZONA_FLL1_FREERUN, 0);
2250 2241
@@ -2313,6 +2304,82 @@ const struct snd_kcontrol_new arizona_adsp2_rate_controls[] = {
2313}; 2304};
2314EXPORT_SYMBOL_GPL(arizona_adsp2_rate_controls); 2305EXPORT_SYMBOL_GPL(arizona_adsp2_rate_controls);
2315 2306
2307static bool arizona_eq_filter_unstable(bool mode, __be16 _a, __be16 _b)
2308{
2309 s16 a = be16_to_cpu(_a);
2310 s16 b = be16_to_cpu(_b);
2311
2312 if (!mode) {
2313 return abs(a) >= 4096;
2314 } else {
2315 if (abs(b) >= 4096)
2316 return true;
2317
2318 return (abs((a << 16) / (4096 - b)) >= 4096 << 4);
2319 }
2320}
2321
2322int arizona_eq_coeff_put(struct snd_kcontrol *kcontrol,
2323 struct snd_ctl_elem_value *ucontrol)
2324{
2325 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
2326 struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
2327 struct soc_bytes *params = (void *)kcontrol->private_value;
2328 unsigned int val;
2329 __be16 *data;
2330 int len;
2331 int ret;
2332
2333 len = params->num_regs * regmap_get_val_bytes(arizona->regmap);
2334
2335 data = kmemdup(ucontrol->value.bytes.data, len, GFP_KERNEL | GFP_DMA);
2336 if (!data)
2337 return -ENOMEM;
2338
2339 data[0] &= cpu_to_be16(ARIZONA_EQ1_B1_MODE);
2340
2341 if (arizona_eq_filter_unstable(!!data[0], data[1], data[2]) ||
2342 arizona_eq_filter_unstable(true, data[4], data[5]) ||
2343 arizona_eq_filter_unstable(true, data[8], data[9]) ||
2344 arizona_eq_filter_unstable(true, data[12], data[13]) ||
2345 arizona_eq_filter_unstable(false, data[16], data[17])) {
2346 dev_err(arizona->dev, "Rejecting unstable EQ coefficients\n");
2347 ret = -EINVAL;
2348 goto out;
2349 }
2350
2351 ret = regmap_read(arizona->regmap, params->base, &val);
2352 if (ret != 0)
2353 goto out;
2354
2355 val &= ~ARIZONA_EQ1_B1_MODE;
2356 data[0] |= cpu_to_be16(val);
2357
2358 ret = regmap_raw_write(arizona->regmap, params->base, data, len);
2359
2360out:
2361 kfree(data);
2362 return ret;
2363}
2364EXPORT_SYMBOL_GPL(arizona_eq_coeff_put);
2365
2366int arizona_lhpf_coeff_put(struct snd_kcontrol *kcontrol,
2367 struct snd_ctl_elem_value *ucontrol)
2368{
2369 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
2370 struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
2371 __be16 *data = (__be16 *)ucontrol->value.bytes.data;
2372 s16 val = be16_to_cpu(*data);
2373
2374 if (abs(val) >= 4096) {
2375 dev_err(arizona->dev, "Rejecting unstable LHPF coefficients\n");
2376 return -EINVAL;
2377 }
2378
2379 return snd_soc_bytes_put(kcontrol, ucontrol);
2380}
2381EXPORT_SYMBOL_GPL(arizona_lhpf_coeff_put);
2382
2316MODULE_DESCRIPTION("ASoC Wolfson Arizona class device support"); 2383MODULE_DESCRIPTION("ASoC Wolfson Arizona class device support");
2317MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 2384MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
2318MODULE_LICENSE("GPL"); 2385MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index 43deb0462309..ada0a418ff4b 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -194,6 +194,20 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
194 ARIZONA_MIXER_ROUTES(name " Preloader", name "L"), \ 194 ARIZONA_MIXER_ROUTES(name " Preloader", name "L"), \
195 ARIZONA_MIXER_ROUTES(name " Preloader", name "R") 195 ARIZONA_MIXER_ROUTES(name " Preloader", name "R")
196 196
197#define ARIZONA_EQ_CONTROL(xname, xbase) \
198{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
199 .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
200 .put = arizona_eq_coeff_put, .private_value = \
201 ((unsigned long)&(struct soc_bytes) { .base = xbase, \
202 .num_regs = 20, .mask = ~ARIZONA_EQ1_B1_MODE }) }
203
204#define ARIZONA_LHPF_CONTROL(xname, xbase) \
205{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
206 .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
207 .put = arizona_lhpf_coeff_put, .private_value = \
208 ((unsigned long)&(struct soc_bytes) { .base = xbase, \
209 .num_regs = 1 }) }
210
197#define ARIZONA_RATE_ENUM_SIZE 4 211#define ARIZONA_RATE_ENUM_SIZE 4
198extern const char *arizona_rate_text[ARIZONA_RATE_ENUM_SIZE]; 212extern const char *arizona_rate_text[ARIZONA_RATE_ENUM_SIZE];
199extern const int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE]; 213extern const int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE];
@@ -229,6 +243,11 @@ extern int arizona_hp_ev(struct snd_soc_dapm_widget *w,
229 struct snd_kcontrol *kcontrol, 243 struct snd_kcontrol *kcontrol,
230 int event); 244 int event);
231 245
246extern int arizona_eq_coeff_put(struct snd_kcontrol *kcontrol,
247 struct snd_ctl_elem_value *ucontrol);
248extern int arizona_lhpf_coeff_put(struct snd_kcontrol *kcontrol,
249 struct snd_ctl_elem_value *ucontrol);
250
232extern int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id, 251extern int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id,
233 int source, unsigned int freq, int dir); 252 int source, unsigned int freq, int dir);
234 253
@@ -242,7 +261,6 @@ struct arizona_fll {
242 int id; 261 int id;
243 unsigned int base; 262 unsigned int base;
244 unsigned int vco_mult; 263 unsigned int vco_mult;
245 struct completion ok;
246 264
247 unsigned int fout; 265 unsigned int fout;
248 int sync_src; 266 int sync_src;
diff --git a/sound/soc/codecs/cs35l32.c b/sound/soc/codecs/cs35l32.c
index 8f40025b7e7c..44c30fe3e315 100644
--- a/sound/soc/codecs/cs35l32.c
+++ b/sound/soc/codecs/cs35l32.c
@@ -74,33 +74,8 @@ static const struct reg_default cs35l32_reg_defaults[] = {
74static bool cs35l32_readable_register(struct device *dev, unsigned int reg) 74static bool cs35l32_readable_register(struct device *dev, unsigned int reg)
75{ 75{
76 switch (reg) { 76 switch (reg) {
77 case CS35L32_DEVID_AB: 77 case CS35L32_DEVID_AB ... CS35L32_AUDIO_LED_MNGR:
78 case CS35L32_DEVID_CD: 78 case CS35L32_ADSP_CTL ... CS35L32_FLASH_INHIBIT:
79 case CS35L32_DEVID_E:
80 case CS35L32_FAB_ID:
81 case CS35L32_REV_ID:
82 case CS35L32_PWRCTL1:
83 case CS35L32_PWRCTL2:
84 case CS35L32_CLK_CTL:
85 case CS35L32_BATT_THRESHOLD:
86 case CS35L32_VMON:
87 case CS35L32_BST_CPCP_CTL:
88 case CS35L32_IMON_SCALING:
89 case CS35L32_AUDIO_LED_MNGR:
90 case CS35L32_ADSP_CTL:
91 case CS35L32_CLASSD_CTL:
92 case CS35L32_PROTECT_CTL:
93 case CS35L32_INT_MASK_1:
94 case CS35L32_INT_MASK_2:
95 case CS35L32_INT_MASK_3:
96 case CS35L32_INT_STATUS_1:
97 case CS35L32_INT_STATUS_2:
98 case CS35L32_INT_STATUS_3:
99 case CS35L32_LED_STATUS:
100 case CS35L32_FLASH_MODE:
101 case CS35L32_MOVIE_MODE:
102 case CS35L32_FLASH_TIMER:
103 case CS35L32_FLASH_INHIBIT:
104 return true; 79 return true;
105 default: 80 default:
106 return false; 81 return false;
@@ -110,15 +85,8 @@ static bool cs35l32_readable_register(struct device *dev, unsigned int reg)
110static bool cs35l32_volatile_register(struct device *dev, unsigned int reg) 85static bool cs35l32_volatile_register(struct device *dev, unsigned int reg)
111{ 86{
112 switch (reg) { 87 switch (reg) {
113 case CS35L32_DEVID_AB: 88 case CS35L32_DEVID_AB ... CS35L32_REV_ID:
114 case CS35L32_DEVID_CD: 89 case CS35L32_INT_STATUS_1 ... CS35L32_LED_STATUS:
115 case CS35L32_DEVID_E:
116 case CS35L32_FAB_ID:
117 case CS35L32_REV_ID:
118 case CS35L32_INT_STATUS_1:
119 case CS35L32_INT_STATUS_2:
120 case CS35L32_INT_STATUS_3:
121 case CS35L32_LED_STATUS:
122 return true; 90 return true;
123 default: 91 default:
124 return false; 92 return false;
@@ -128,10 +96,7 @@ static bool cs35l32_volatile_register(struct device *dev, unsigned int reg)
128static bool cs35l32_precious_register(struct device *dev, unsigned int reg) 96static bool cs35l32_precious_register(struct device *dev, unsigned int reg)
129{ 97{
130 switch (reg) { 98 switch (reg) {
131 case CS35L32_INT_STATUS_1: 99 case CS35L32_INT_STATUS_1 ... CS35L32_LED_STATUS:
132 case CS35L32_INT_STATUS_2:
133 case CS35L32_INT_STATUS_3:
134 case CS35L32_LED_STATUS:
135 return true; 100 return true;
136 default: 101 default:
137 return false; 102 return false;
@@ -276,7 +241,7 @@ static const struct snd_soc_codec_driver soc_codec_dev_cs35l32 = {
276}; 241};
277 242
278/* Current and threshold powerup sequence Pg37 in datasheet */ 243/* Current and threshold powerup sequence Pg37 in datasheet */
279static const struct reg_default cs35l32_monitor_patch[] = { 244static const struct reg_sequence cs35l32_monitor_patch[] = {
280 245
281 { 0x00, 0x99 }, 246 { 0x00, 0x99 },
282 { 0x48, 0x17 }, 247 { 0x48, 0x17 },
@@ -441,8 +406,7 @@ static int cs35l32_i2c_probe(struct i2c_client *i2c_client,
441 if (IS_ERR(cs35l32->reset_gpio)) 406 if (IS_ERR(cs35l32->reset_gpio))
442 return PTR_ERR(cs35l32->reset_gpio); 407 return PTR_ERR(cs35l32->reset_gpio);
443 408
444 if (cs35l32->reset_gpio) 409 gpiod_set_value_cansleep(cs35l32->reset_gpio, 1);
445 gpiod_set_value_cansleep(cs35l32->reset_gpio, 1);
446 410
447 /* initialize codec */ 411 /* initialize codec */
448 ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_AB, &reg); 412 ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_AB, &reg);
@@ -536,8 +500,7 @@ static int cs35l32_i2c_remove(struct i2c_client *i2c_client)
536 snd_soc_unregister_codec(&i2c_client->dev); 500 snd_soc_unregister_codec(&i2c_client->dev);
537 501
538 /* Hold down reset */ 502 /* Hold down reset */
539 if (cs35l32->reset_gpio) 503 gpiod_set_value_cansleep(cs35l32->reset_gpio, 0);
540 gpiod_set_value_cansleep(cs35l32->reset_gpio, 0);
541 504
542 return 0; 505 return 0;
543} 506}
@@ -551,8 +514,7 @@ static int cs35l32_runtime_suspend(struct device *dev)
551 regcache_mark_dirty(cs35l32->regmap); 514 regcache_mark_dirty(cs35l32->regmap);
552 515
553 /* Hold down reset */ 516 /* Hold down reset */
554 if (cs35l32->reset_gpio) 517 gpiod_set_value_cansleep(cs35l32->reset_gpio, 0);
555 gpiod_set_value_cansleep(cs35l32->reset_gpio, 0);
556 518
557 /* remove power */ 519 /* remove power */
558 regulator_bulk_disable(ARRAY_SIZE(cs35l32->supplies), 520 regulator_bulk_disable(ARRAY_SIZE(cs35l32->supplies),
@@ -575,8 +537,7 @@ static int cs35l32_runtime_resume(struct device *dev)
575 return ret; 537 return ret;
576 } 538 }
577 539
578 if (cs35l32->reset_gpio) 540 gpiod_set_value_cansleep(cs35l32->reset_gpio, 1);
579 gpiod_set_value_cansleep(cs35l32->reset_gpio, 1);
580 541
581 regcache_cache_only(cs35l32->regmap, false); 542 regcache_cache_only(cs35l32->regmap, false);
582 regcache_sync(cs35l32->regmap); 543 regcache_sync(cs35l32->regmap);
@@ -607,7 +568,6 @@ MODULE_DEVICE_TABLE(i2c, cs35l32_id);
607static struct i2c_driver cs35l32_i2c_driver = { 568static struct i2c_driver cs35l32_i2c_driver = {
608 .driver = { 569 .driver = {
609 .name = "cs35l32", 570 .name = "cs35l32",
610 .owner = THIS_MODULE,
611 .pm = &cs35l32_runtime_pm, 571 .pm = &cs35l32_runtime_pm,
612 .of_match_table = cs35l32_of_match, 572 .of_match_table = cs35l32_of_match,
613 }, 573 },
diff --git a/sound/soc/codecs/cs35l32.h b/sound/soc/codecs/cs35l32.h
index 31ab804a22bc..1d6c2508cd41 100644
--- a/sound/soc/codecs/cs35l32.h
+++ b/sound/soc/codecs/cs35l32.h
@@ -80,7 +80,7 @@ struct cs35l32_platform_data {
80#define CS35L32_GAIN_MGR_MASK 0x08 80#define CS35L32_GAIN_MGR_MASK 0x08
81#define CS35L32_ADSP_SHARE_MASK 0x08 81#define CS35L32_ADSP_SHARE_MASK 0x08
82#define CS35L32_ADSP_DATACFG_MASK 0x30 82#define CS35L32_ADSP_DATACFG_MASK 0x30
83#define CS35L32_SDOUT_3ST 0x80 83#define CS35L32_SDOUT_3ST 0x08
84#define CS35L32_BATT_REC_MASK 0x0E 84#define CS35L32_BATT_REC_MASK 0x0E
85#define CS35L32_BATT_THRESH_MASK 0x30 85#define CS35L32_BATT_THRESH_MASK 0x30
86 86
diff --git a/sound/soc/codecs/cs4265.c b/sound/soc/codecs/cs4265.c
index d7ec4756e45b..55db19ddc5ff 100644
--- a/sound/soc/codecs/cs4265.c
+++ b/sound/soc/codecs/cs4265.c
@@ -60,23 +60,7 @@ static const struct reg_default cs4265_reg_defaults[] = {
60static bool cs4265_readable_register(struct device *dev, unsigned int reg) 60static bool cs4265_readable_register(struct device *dev, unsigned int reg)
61{ 61{
62 switch (reg) { 62 switch (reg) {
63 case CS4265_PWRCTL: 63 case CS4265_CHIP_ID ... CS4265_SPDIF_CTL2:
64 case CS4265_DAC_CTL:
65 case CS4265_ADC_CTL:
66 case CS4265_MCLK_FREQ:
67 case CS4265_SIG_SEL:
68 case CS4265_CHB_PGA_CTL:
69 case CS4265_CHA_PGA_CTL:
70 case CS4265_ADC_CTL2:
71 case CS4265_DAC_CHA_VOL:
72 case CS4265_DAC_CHB_VOL:
73 case CS4265_DAC_CTL2:
74 case CS4265_SPDIF_CTL1:
75 case CS4265_SPDIF_CTL2:
76 case CS4265_INT_MASK:
77 case CS4265_STATUS_MODE_MSB:
78 case CS4265_STATUS_MODE_LSB:
79 case CS4265_CHIP_ID:
80 return true; 64 return true;
81 default: 65 default:
82 return false; 66 return false;
@@ -457,14 +441,14 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream,
457 case SND_SOC_DAIFMT_RIGHT_J: 441 case SND_SOC_DAIFMT_RIGHT_J:
458 if (params_width(params) == 16) { 442 if (params_width(params) == 16) {
459 snd_soc_update_bits(codec, CS4265_DAC_CTL, 443 snd_soc_update_bits(codec, CS4265_DAC_CTL,
460 CS4265_DAC_CTL_DIF, (1 << 5)); 444 CS4265_DAC_CTL_DIF, (2 << 4));
461 snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, 445 snd_soc_update_bits(codec, CS4265_SPDIF_CTL2,
462 CS4265_SPDIF_CTL2_DIF, (1 << 7)); 446 CS4265_SPDIF_CTL2_DIF, (2 << 6));
463 } else { 447 } else {
464 snd_soc_update_bits(codec, CS4265_DAC_CTL, 448 snd_soc_update_bits(codec, CS4265_DAC_CTL,
465 CS4265_DAC_CTL_DIF, (3 << 5)); 449 CS4265_DAC_CTL_DIF, (3 << 4));
466 snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, 450 snd_soc_update_bits(codec, CS4265_SPDIF_CTL2,
467 CS4265_SPDIF_CTL2_DIF, (1 << 7)); 451 CS4265_SPDIF_CTL2_DIF, (3 << 6));
468 } 452 }
469 break; 453 break;
470 case SND_SOC_DAIFMT_LEFT_J: 454 case SND_SOC_DAIFMT_LEFT_J:
@@ -473,7 +457,7 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream,
473 snd_soc_update_bits(codec, CS4265_ADC_CTL, 457 snd_soc_update_bits(codec, CS4265_ADC_CTL,
474 CS4265_ADC_DIF, 0); 458 CS4265_ADC_DIF, 0);
475 snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, 459 snd_soc_update_bits(codec, CS4265_SPDIF_CTL2,
476 CS4265_SPDIF_CTL2_DIF, (1 << 6)); 460 CS4265_SPDIF_CTL2_DIF, 0);
477 461
478 break; 462 break;
479 default: 463 default:
@@ -658,7 +642,6 @@ MODULE_DEVICE_TABLE(i2c, cs4265_id);
658static struct i2c_driver cs4265_i2c_driver = { 642static struct i2c_driver cs4265_i2c_driver = {
659 .driver = { 643 .driver = {
660 .name = "cs4265", 644 .name = "cs4265",
661 .owner = THIS_MODULE,
662 .of_match_table = cs4265_of_match, 645 .of_match_table = cs4265_of_match,
663 }, 646 },
664 .id_table = cs4265_id, 647 .id_table = cs4265_id,
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index e6d4ff9fd992..e07807d96b68 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -751,7 +751,6 @@ MODULE_DEVICE_TABLE(i2c, cs4270_id);
751static struct i2c_driver cs4270_i2c_driver = { 751static struct i2c_driver cs4270_i2c_driver = {
752 .driver = { 752 .driver = {
753 .name = "cs4270", 753 .name = "cs4270",
754 .owner = THIS_MODULE,
755 .of_match_table = cs4270_of_match, 754 .of_match_table = cs4270_of_match,
756 }, 755 },
757 .id_table = cs4270_id, 756 .id_table = cs4270_id,
diff --git a/sound/soc/codecs/cs4271-i2c.c b/sound/soc/codecs/cs4271-i2c.c
index b264da030340..dcb3223d7d8f 100644
--- a/sound/soc/codecs/cs4271-i2c.c
+++ b/sound/soc/codecs/cs4271-i2c.c
@@ -48,7 +48,6 @@ MODULE_DEVICE_TABLE(i2c, cs4271_i2c_id);
48static struct i2c_driver cs4271_i2c_driver = { 48static struct i2c_driver cs4271_i2c_driver = {
49 .driver = { 49 .driver = {
50 .name = "cs4271", 50 .name = "cs4271",
51 .owner = THIS_MODULE,
52 .of_match_table = of_match_ptr(cs4271_dt_ids), 51 .of_match_table = of_match_ptr(cs4271_dt_ids),
53 }, 52 },
54 .probe = cs4271_i2c_probe, 53 .probe = cs4271_i2c_probe,
diff --git a/sound/soc/codecs/cs42l51-i2c.c b/sound/soc/codecs/cs42l51-i2c.c
index c40428f25ba5..9bad478474fa 100644
--- a/sound/soc/codecs/cs42l51-i2c.c
+++ b/sound/soc/codecs/cs42l51-i2c.c
@@ -45,7 +45,6 @@ static int cs42l51_i2c_remove(struct i2c_client *i2c)
45static struct i2c_driver cs42l51_i2c_driver = { 45static struct i2c_driver cs42l51_i2c_driver = {
46 .driver = { 46 .driver = {
47 .name = "cs42l51", 47 .name = "cs42l51",
48 .owner = THIS_MODULE,
49 .of_match_table = cs42l51_of_match, 48 .of_match_table = cs42l51_of_match,
50 }, 49 },
51 .probe = cs42l51_i2c_probe, 50 .probe = cs42l51_i2c_probe,
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 4de52c9957ac..b256424d3f9a 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -110,58 +110,7 @@ static const struct reg_default cs42l52_reg_defaults[] = {
110static bool cs42l52_readable_register(struct device *dev, unsigned int reg) 110static bool cs42l52_readable_register(struct device *dev, unsigned int reg)
111{ 111{
112 switch (reg) { 112 switch (reg) {
113 case CS42L52_CHIP: 113 case CS42L52_CHIP ... CS42L52_CHARGE_PUMP:
114 case CS42L52_PWRCTL1:
115 case CS42L52_PWRCTL2:
116 case CS42L52_PWRCTL3:
117 case CS42L52_CLK_CTL:
118 case CS42L52_IFACE_CTL1:
119 case CS42L52_IFACE_CTL2:
120 case CS42L52_ADC_PGA_A:
121 case CS42L52_ADC_PGA_B:
122 case CS42L52_ANALOG_HPF_CTL:
123 case CS42L52_ADC_HPF_FREQ:
124 case CS42L52_ADC_MISC_CTL:
125 case CS42L52_PB_CTL1:
126 case CS42L52_MISC_CTL:
127 case CS42L52_PB_CTL2:
128 case CS42L52_MICA_CTL:
129 case CS42L52_MICB_CTL:
130 case CS42L52_PGAA_CTL:
131 case CS42L52_PGAB_CTL:
132 case CS42L52_PASSTHRUA_VOL:
133 case CS42L52_PASSTHRUB_VOL:
134 case CS42L52_ADCA_VOL:
135 case CS42L52_ADCB_VOL:
136 case CS42L52_ADCA_MIXER_VOL:
137 case CS42L52_ADCB_MIXER_VOL:
138 case CS42L52_PCMA_MIXER_VOL:
139 case CS42L52_PCMB_MIXER_VOL:
140 case CS42L52_BEEP_FREQ:
141 case CS42L52_BEEP_VOL:
142 case CS42L52_BEEP_TONE_CTL:
143 case CS42L52_TONE_CTL:
144 case CS42L52_MASTERA_VOL:
145 case CS42L52_MASTERB_VOL:
146 case CS42L52_HPA_VOL:
147 case CS42L52_HPB_VOL:
148 case CS42L52_SPKA_VOL:
149 case CS42L52_SPKB_VOL:
150 case CS42L52_ADC_PCM_MIXER:
151 case CS42L52_LIMITER_CTL1:
152 case CS42L52_LIMITER_CTL2:
153 case CS42L52_LIMITER_AT_RATE:
154 case CS42L52_ALC_CTL:
155 case CS42L52_ALC_RATE:
156 case CS42L52_ALC_THRESHOLD:
157 case CS42L52_NOISE_GATE_CTL:
158 case CS42L52_CLK_STATUS:
159 case CS42L52_BATT_COMPEN:
160 case CS42L52_BATT_LEVEL:
161 case CS42L52_SPK_STATUS:
162 case CS42L52_TEM_CTL:
163 case CS42L52_THE_FOLDBACK:
164 case CS42L52_CHARGE_PUMP:
165 return true; 114 return true;
166 default: 115 default:
167 return false; 116 return false;
@@ -919,7 +868,7 @@ static int cs42l52_set_bias_level(struct snd_soc_codec *codec,
919 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_U20_3LE | \ 868 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_U20_3LE | \
920 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U24_LE) 869 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U24_LE)
921 870
922static struct snd_soc_dai_ops cs42l52_ops = { 871static const struct snd_soc_dai_ops cs42l52_ops = {
923 .hw_params = cs42l52_pcm_hw_params, 872 .hw_params = cs42l52_pcm_hw_params,
924 .digital_mute = cs42l52_digital_mute, 873 .digital_mute = cs42l52_digital_mute,
925 .set_fmt = cs42l52_set_fmt, 874 .set_fmt = cs42l52_set_fmt,
@@ -1118,7 +1067,7 @@ static const struct snd_soc_codec_driver soc_codec_dev_cs42l52 = {
1118}; 1067};
1119 1068
1120/* Current and threshold powerup sequence Pg37 */ 1069/* Current and threshold powerup sequence Pg37 */
1121static const struct reg_default cs42l52_threshold_patch[] = { 1070static const struct reg_sequence cs42l52_threshold_patch[] = {
1122 1071
1123 { 0x00, 0x99 }, 1072 { 0x00, 0x99 },
1124 { 0x3E, 0xBA }, 1073 { 0x3E, 0xBA },
@@ -1285,7 +1234,6 @@ MODULE_DEVICE_TABLE(i2c, cs42l52_id);
1285static struct i2c_driver cs42l52_i2c_driver = { 1234static struct i2c_driver cs42l52_i2c_driver = {
1286 .driver = { 1235 .driver = {
1287 .name = "cs42l52", 1236 .name = "cs42l52",
1288 .owner = THIS_MODULE,
1289 .of_match_table = cs42l52_of_match, 1237 .of_match_table = cs42l52_of_match,
1290 }, 1238 },
1291 .id_table = cs42l52_id, 1239 .id_table = cs42l52_id,
diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c
index 1e11ba45a79f..52fe7a5ac408 100644
--- a/sound/soc/codecs/cs42l56.c
+++ b/sound/soc/codecs/cs42l56.c
@@ -115,52 +115,7 @@ static const struct reg_default cs42l56_reg_defaults[] = {
115static bool cs42l56_readable_register(struct device *dev, unsigned int reg) 115static bool cs42l56_readable_register(struct device *dev, unsigned int reg)
116{ 116{
117 switch (reg) { 117 switch (reg) {
118 case CS42L56_CHIP_ID_1: 118 case CS42L56_CHIP_ID_1 ... CS42L56_LIM_ATTACK_RATE:
119 case CS42L56_CHIP_ID_2:
120 case CS42L56_PWRCTL_1:
121 case CS42L56_PWRCTL_2:
122 case CS42L56_CLKCTL_1:
123 case CS42L56_CLKCTL_2:
124 case CS42L56_SERIAL_FMT:
125 case CS42L56_CLASSH_CTL:
126 case CS42L56_MISC_CTL:
127 case CS42L56_INT_STATUS:
128 case CS42L56_PLAYBACK_CTL:
129 case CS42L56_DSP_MUTE_CTL:
130 case CS42L56_ADCA_MIX_VOLUME:
131 case CS42L56_ADCB_MIX_VOLUME:
132 case CS42L56_PCMA_MIX_VOLUME:
133 case CS42L56_PCMB_MIX_VOLUME:
134 case CS42L56_ANAINPUT_ADV_VOLUME:
135 case CS42L56_DIGINPUT_ADV_VOLUME:
136 case CS42L56_MASTER_A_VOLUME:
137 case CS42L56_MASTER_B_VOLUME:
138 case CS42L56_BEEP_FREQ_ONTIME:
139 case CS42L56_BEEP_FREQ_OFFTIME:
140 case CS42L56_BEEP_TONE_CFG:
141 case CS42L56_TONE_CTL:
142 case CS42L56_CHAN_MIX_SWAP:
143 case CS42L56_AIN_REFCFG_ADC_MUX:
144 case CS42L56_HPF_CTL:
145 case CS42L56_MISC_ADC_CTL:
146 case CS42L56_GAIN_BIAS_CTL:
147 case CS42L56_PGAA_MUX_VOLUME:
148 case CS42L56_PGAB_MUX_VOLUME:
149 case CS42L56_ADCA_ATTENUATOR:
150 case CS42L56_ADCB_ATTENUATOR:
151 case CS42L56_ALC_EN_ATTACK_RATE:
152 case CS42L56_ALC_RELEASE_RATE:
153 case CS42L56_ALC_THRESHOLD:
154 case CS42L56_NOISE_GATE_CTL:
155 case CS42L56_ALC_LIM_SFT_ZC:
156 case CS42L56_AMUTE_HPLO_MUX:
157 case CS42L56_HPA_VOLUME:
158 case CS42L56_HPB_VOLUME:
159 case CS42L56_LOA_VOLUME:
160 case CS42L56_LOB_VOLUME:
161 case CS42L56_LIM_THRESHOLD_CTL:
162 case CS42L56_LIM_CTL_RELEASE_RATE:
163 case CS42L56_LIM_ATTACK_RATE:
164 return true; 119 return true;
165 default: 120 default:
166 return false; 121 return false;
@@ -989,7 +944,7 @@ static int cs42l56_set_bias_level(struct snd_soc_codec *codec,
989 SNDRV_PCM_FMTBIT_S32_LE) 944 SNDRV_PCM_FMTBIT_S32_LE)
990 945
991 946
992static struct snd_soc_dai_ops cs42l56_ops = { 947static const struct snd_soc_dai_ops cs42l56_ops = {
993 .hw_params = cs42l56_pcm_hw_params, 948 .hw_params = cs42l56_pcm_hw_params,
994 .digital_mute = cs42l56_digital_mute, 949 .digital_mute = cs42l56_digital_mute,
995 .set_fmt = cs42l56_set_dai_fmt, 950 .set_fmt = cs42l56_set_dai_fmt,
@@ -1408,7 +1363,6 @@ MODULE_DEVICE_TABLE(i2c, cs42l56_id);
1408static struct i2c_driver cs42l56_i2c_driver = { 1363static struct i2c_driver cs42l56_i2c_driver = {
1409 .driver = { 1364 .driver = {
1410 .name = "cs42l56", 1365 .name = "cs42l56",
1411 .owner = THIS_MODULE,
1412 .of_match_table = cs42l56_of_match, 1366 .of_match_table = cs42l56_of_match,
1413 }, 1367 },
1414 .id_table = cs42l56_id, 1368 .id_table = cs42l56_id,
diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c
index b7853b9d3a60..a8f468689d26 100644
--- a/sound/soc/codecs/cs42l73.c
+++ b/sound/soc/codecs/cs42l73.c
@@ -153,100 +153,8 @@ static bool cs42l73_volatile_register(struct device *dev, unsigned int reg)
153static bool cs42l73_readable_register(struct device *dev, unsigned int reg) 153static bool cs42l73_readable_register(struct device *dev, unsigned int reg)
154{ 154{
155 switch (reg) { 155 switch (reg) {
156 case CS42L73_DEVID_AB: 156 case CS42L73_DEVID_AB ... CS42L73_DEVID_E:
157 case CS42L73_DEVID_CD: 157 case CS42L73_REVID ... CS42L73_IM2:
158 case CS42L73_DEVID_E:
159 case CS42L73_REVID:
160 case CS42L73_PWRCTL1:
161 case CS42L73_PWRCTL2:
162 case CS42L73_PWRCTL3:
163 case CS42L73_CPFCHC:
164 case CS42L73_OLMBMSDC:
165 case CS42L73_DMMCC:
166 case CS42L73_XSPC:
167 case CS42L73_XSPMMCC:
168 case CS42L73_ASPC:
169 case CS42L73_ASPMMCC:
170 case CS42L73_VSPC:
171 case CS42L73_VSPMMCC:
172 case CS42L73_VXSPFS:
173 case CS42L73_MIOPC:
174 case CS42L73_ADCIPC:
175 case CS42L73_MICAPREPGAAVOL:
176 case CS42L73_MICBPREPGABVOL:
177 case CS42L73_IPADVOL:
178 case CS42L73_IPBDVOL:
179 case CS42L73_PBDC:
180 case CS42L73_HLADVOL:
181 case CS42L73_HLBDVOL:
182 case CS42L73_SPKDVOL:
183 case CS42L73_ESLDVOL:
184 case CS42L73_HPAAVOL:
185 case CS42L73_HPBAVOL:
186 case CS42L73_LOAAVOL:
187 case CS42L73_LOBAVOL:
188 case CS42L73_STRINV:
189 case CS42L73_XSPINV:
190 case CS42L73_ASPINV:
191 case CS42L73_VSPINV:
192 case CS42L73_LIMARATEHL:
193 case CS42L73_LIMRRATEHL:
194 case CS42L73_LMAXHL:
195 case CS42L73_LIMARATESPK:
196 case CS42L73_LIMRRATESPK:
197 case CS42L73_LMAXSPK:
198 case CS42L73_LIMARATEESL:
199 case CS42L73_LIMRRATEESL:
200 case CS42L73_LMAXESL:
201 case CS42L73_ALCARATE:
202 case CS42L73_ALCRRATE:
203 case CS42L73_ALCMINMAX:
204 case CS42L73_NGCAB:
205 case CS42L73_ALCNGMC:
206 case CS42L73_MIXERCTL:
207 case CS42L73_HLAIPAA:
208 case CS42L73_HLBIPBA:
209 case CS42L73_HLAXSPAA:
210 case CS42L73_HLBXSPBA:
211 case CS42L73_HLAASPAA:
212 case CS42L73_HLBASPBA:
213 case CS42L73_HLAVSPMA:
214 case CS42L73_HLBVSPMA:
215 case CS42L73_XSPAIPAA:
216 case CS42L73_XSPBIPBA:
217 case CS42L73_XSPAXSPAA:
218 case CS42L73_XSPBXSPBA:
219 case CS42L73_XSPAASPAA:
220 case CS42L73_XSPAASPBA:
221 case CS42L73_XSPAVSPMA:
222 case CS42L73_XSPBVSPMA:
223 case CS42L73_ASPAIPAA:
224 case CS42L73_ASPBIPBA:
225 case CS42L73_ASPAXSPAA:
226 case CS42L73_ASPBXSPBA:
227 case CS42L73_ASPAASPAA:
228 case CS42L73_ASPBASPBA:
229 case CS42L73_ASPAVSPMA:
230 case CS42L73_ASPBVSPMA:
231 case CS42L73_VSPAIPAA:
232 case CS42L73_VSPBIPBA:
233 case CS42L73_VSPAXSPAA:
234 case CS42L73_VSPBXSPBA:
235 case CS42L73_VSPAASPAA:
236 case CS42L73_VSPBASPBA:
237 case CS42L73_VSPAVSPMA:
238 case CS42L73_VSPBVSPMA:
239 case CS42L73_MMIXCTL:
240 case CS42L73_SPKMIPMA:
241 case CS42L73_SPKMXSPA:
242 case CS42L73_SPKMASPA:
243 case CS42L73_SPKMVSPMA:
244 case CS42L73_ESLMIPMA:
245 case CS42L73_ESLMXSPA:
246 case CS42L73_ESLMASPA:
247 case CS42L73_ESLMVSPMA:
248 case CS42L73_IM1:
249 case CS42L73_IM2:
250 return true; 158 return true;
251 default: 159 default:
252 return false; 160 return false;
@@ -1236,8 +1144,8 @@ static int cs42l73_set_tristate(struct snd_soc_dai *dai, int tristate)
1236 struct snd_soc_codec *codec = dai->codec; 1144 struct snd_soc_codec *codec = dai->codec;
1237 int id = dai->id; 1145 int id = dai->id;
1238 1146
1239 return snd_soc_update_bits(codec, CS42L73_SPC(id), 1147 return snd_soc_update_bits(codec, CS42L73_SPC(id), CS42L73_SP_3ST,
1240 0x7F, tristate << 7); 1148 tristate << 7);
1241} 1149}
1242 1150
1243static const struct snd_pcm_hw_constraint_list constraints_12_24 = { 1151static const struct snd_pcm_hw_constraint_list constraints_12_24 = {
@@ -1491,7 +1399,6 @@ MODULE_DEVICE_TABLE(i2c, cs42l73_id);
1491static struct i2c_driver cs42l73_i2c_driver = { 1399static struct i2c_driver cs42l73_i2c_driver = {
1492 .driver = { 1400 .driver = {
1493 .name = "cs42l73", 1401 .name = "cs42l73",
1494 .owner = THIS_MODULE,
1495 .of_match_table = cs42l73_of_match, 1402 .of_match_table = cs42l73_of_match,
1496 }, 1403 },
1497 .id_table = cs42l73_id, 1404 .id_table = cs42l73_id,
diff --git a/sound/soc/codecs/cs42xx8-i2c.c b/sound/soc/codecs/cs42xx8-i2c.c
index 657dce27eade..800c1d549347 100644
--- a/sound/soc/codecs/cs42xx8-i2c.c
+++ b/sound/soc/codecs/cs42xx8-i2c.c
@@ -20,7 +20,7 @@
20static int cs42xx8_i2c_probe(struct i2c_client *i2c, 20static int cs42xx8_i2c_probe(struct i2c_client *i2c,
21 const struct i2c_device_id *id) 21 const struct i2c_device_id *id)
22{ 22{
23 u32 ret = cs42xx8_probe(&i2c->dev, 23 int ret = cs42xx8_probe(&i2c->dev,
24 devm_regmap_init_i2c(i2c, &cs42xx8_regmap_config)); 24 devm_regmap_init_i2c(i2c, &cs42xx8_regmap_config));
25 if (ret) 25 if (ret)
26 return ret; 26 return ret;
@@ -49,8 +49,8 @@ MODULE_DEVICE_TABLE(i2c, cs42xx8_i2c_id);
49static struct i2c_driver cs42xx8_i2c_driver = { 49static struct i2c_driver cs42xx8_i2c_driver = {
50 .driver = { 50 .driver = {
51 .name = "cs42xx8", 51 .name = "cs42xx8",
52 .owner = THIS_MODULE,
53 .pm = &cs42xx8_pm, 52 .pm = &cs42xx8_pm,
53 .of_match_table = cs42xx8_of_match,
54 }, 54 },
55 .probe = cs42xx8_i2c_probe, 55 .probe = cs42xx8_i2c_probe,
56 .remove = cs42xx8_i2c_remove, 56 .remove = cs42xx8_i2c_remove,
diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c
index e1d46862e81f..d562e1b9a5d1 100644
--- a/sound/soc/codecs/cs42xx8.c
+++ b/sound/soc/codecs/cs42xx8.c
@@ -425,7 +425,7 @@ const struct cs42xx8_driver_data cs42888_data = {
425}; 425};
426EXPORT_SYMBOL_GPL(cs42888_data); 426EXPORT_SYMBOL_GPL(cs42888_data);
427 427
428static const struct of_device_id cs42xx8_of_match[] = { 428const struct of_device_id cs42xx8_of_match[] = {
429 { .compatible = "cirrus,cs42448", .data = &cs42448_data, }, 429 { .compatible = "cirrus,cs42448", .data = &cs42448_data, },
430 { .compatible = "cirrus,cs42888", .data = &cs42888_data, }, 430 { .compatible = "cirrus,cs42888", .data = &cs42888_data, },
431 { /* sentinel */ } 431 { /* sentinel */ }
@@ -435,16 +435,24 @@ EXPORT_SYMBOL_GPL(cs42xx8_of_match);
435 435
436int cs42xx8_probe(struct device *dev, struct regmap *regmap) 436int cs42xx8_probe(struct device *dev, struct regmap *regmap)
437{ 437{
438 const struct of_device_id *of_id = of_match_device(cs42xx8_of_match, dev); 438 const struct of_device_id *of_id;
439 struct cs42xx8_priv *cs42xx8; 439 struct cs42xx8_priv *cs42xx8;
440 int ret, val, i; 440 int ret, val, i;
441 441
442 if (IS_ERR(regmap)) {
443 ret = PTR_ERR(regmap);
444 dev_err(dev, "failed to allocate regmap: %d\n", ret);
445 return ret;
446 }
447
442 cs42xx8 = devm_kzalloc(dev, sizeof(*cs42xx8), GFP_KERNEL); 448 cs42xx8 = devm_kzalloc(dev, sizeof(*cs42xx8), GFP_KERNEL);
443 if (cs42xx8 == NULL) 449 if (cs42xx8 == NULL)
444 return -ENOMEM; 450 return -ENOMEM;
445 451
452 cs42xx8->regmap = regmap;
446 dev_set_drvdata(dev, cs42xx8); 453 dev_set_drvdata(dev, cs42xx8);
447 454
455 of_id = of_match_device(cs42xx8_of_match, dev);
448 if (of_id) 456 if (of_id)
449 cs42xx8->drvdata = of_id->data; 457 cs42xx8->drvdata = of_id->data;
450 458
@@ -482,13 +490,6 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap)
482 /* Make sure hardware reset done */ 490 /* Make sure hardware reset done */
483 msleep(5); 491 msleep(5);
484 492
485 cs42xx8->regmap = regmap;
486 if (IS_ERR(cs42xx8->regmap)) {
487 ret = PTR_ERR(cs42xx8->regmap);
488 dev_err(dev, "failed to allocate regmap: %d\n", ret);
489 goto err_enable;
490 }
491
492 /* 493 /*
493 * We haven't marked the chip revision as volatile due to 494 * We haven't marked the chip revision as volatile due to
494 * sharing a register with the right input volume; explicitly 495 * sharing a register with the right input volume; explicitly
diff --git a/sound/soc/codecs/cs42xx8.h b/sound/soc/codecs/cs42xx8.h
index b2c10e537ef6..d36c61b6df74 100644
--- a/sound/soc/codecs/cs42xx8.h
+++ b/sound/soc/codecs/cs42xx8.h
@@ -22,6 +22,7 @@ extern const struct dev_pm_ops cs42xx8_pm;
22extern const struct cs42xx8_driver_data cs42448_data; 22extern const struct cs42xx8_driver_data cs42448_data;
23extern const struct cs42xx8_driver_data cs42888_data; 23extern const struct cs42xx8_driver_data cs42888_data;
24extern const struct regmap_config cs42xx8_regmap_config; 24extern const struct regmap_config cs42xx8_regmap_config;
25extern const struct of_device_id cs42xx8_of_match[];
25int cs42xx8_probe(struct device *dev, struct regmap *regmap); 26int cs42xx8_probe(struct device *dev, struct regmap *regmap);
26 27
27/* CS42888 register map */ 28/* CS42888 register map */
diff --git a/sound/soc/codecs/cs4349.c b/sound/soc/codecs/cs4349.c
new file mode 100644
index 000000000000..0ac8fc5ed4ae
--- /dev/null
+++ b/sound/soc/codecs/cs4349.c
@@ -0,0 +1,392 @@
1/*
2 * cs4349.c -- CS4349 ALSA Soc Audio driver
3 *
4 * Copyright 2015 Cirrus Logic, Inc.
5 *
6 * Authors: Tim Howe <Tim.Howe@cirrus.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/gpio.h>
19#include <linux/gpio/consumer.h>
20#include <linux/platform_device.h>
21#include <linux/pm.h>
22#include <linux/i2c.h>
23#include <linux/of_device.h>
24#include <linux/regmap.h>
25#include <linux/slab.h>
26#include <sound/core.h>
27#include <sound/pcm.h>
28#include <sound/pcm_params.h>
29#include <sound/soc.h>
30#include <sound/soc-dapm.h>
31#include <sound/initval.h>
32#include <sound/tlv.h>
33#include "cs4349.h"
34
35
36static const struct reg_default cs4349_reg_defaults[] = {
37 { 2, 0x00 }, /* r02 - Mode Control */
38 { 3, 0x09 }, /* r03 - Volume, Mixing and Inversion Control */
39 { 4, 0x81 }, /* r04 - Mute Control */
40 { 5, 0x00 }, /* r05 - Channel A Volume Control */
41 { 6, 0x00 }, /* r06 - Channel B Volume Control */
42 { 7, 0xB1 }, /* r07 - Ramp and Filter Control */
43 { 8, 0x1C }, /* r08 - Misc. Control */
44};
45
46/* Private data for the CS4349 */
47struct cs4349_private {
48 struct regmap *regmap;
49 struct gpio_desc *reset_gpio;
50 unsigned int mode;
51 int rate;
52};
53
54static bool cs4349_readable_register(struct device *dev, unsigned int reg)
55{
56 switch (reg) {
57 case CS4349_CHIPID ... CS4349_MISC:
58 return true;
59 default:
60 return false;
61 }
62}
63
64static bool cs4349_writeable_register(struct device *dev, unsigned int reg)
65{
66 switch (reg) {
67 case CS4349_MODE ... CS4349_MISC:
68 return true;
69 default:
70 return false;
71 }
72}
73
74static int cs4349_set_dai_fmt(struct snd_soc_dai *codec_dai,
75 unsigned int format)
76{
77 struct snd_soc_codec *codec = codec_dai->codec;
78 struct cs4349_private *cs4349 = snd_soc_codec_get_drvdata(codec);
79 unsigned int fmt;
80
81 fmt = format & SND_SOC_DAIFMT_FORMAT_MASK;
82
83 switch (fmt) {
84 case SND_SOC_DAIFMT_I2S:
85 case SND_SOC_DAIFMT_LEFT_J:
86 case SND_SOC_DAIFMT_RIGHT_J:
87 cs4349->mode = format & SND_SOC_DAIFMT_FORMAT_MASK;
88 break;
89 default:
90 return -EINVAL;
91 }
92
93 return 0;
94}
95
96static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream,
97 struct snd_pcm_hw_params *params,
98 struct snd_soc_dai *dai)
99{
100 struct snd_soc_codec *codec = dai->codec;
101 struct cs4349_private *cs4349 = snd_soc_codec_get_drvdata(codec);
102 int fmt, ret;
103
104 cs4349->rate = params_rate(params);
105
106 switch (cs4349->mode) {
107 case SND_SOC_DAIFMT_I2S:
108 fmt = DIF_I2S;
109 break;
110 case SND_SOC_DAIFMT_LEFT_J:
111 fmt = DIF_LEFT_JST;
112 break;
113 case SND_SOC_DAIFMT_RIGHT_J:
114 switch (params_width(params)) {
115 case 16:
116 fmt = DIF_RGHT_JST16;
117 break;
118 case 24:
119 fmt = DIF_RGHT_JST24;
120 break;
121 default:
122 return -EINVAL;
123 }
124 break;
125 default:
126 return -EINVAL;
127 }
128
129 ret = snd_soc_update_bits(codec, CS4349_MODE, DIF_MASK,
130 MODE_FORMAT(fmt));
131 if (ret < 0)
132 return ret;
133
134 return 0;
135}
136
137static int cs4349_digital_mute(struct snd_soc_dai *dai, int mute)
138{
139 struct snd_soc_codec *codec = dai->codec;
140 int reg;
141
142 reg = 0;
143 if (mute)
144 reg = MUTE_AB_MASK;
145
146 return snd_soc_update_bits(codec, CS4349_MUTE, MUTE_AB_MASK, reg);
147}
148
149static DECLARE_TLV_DB_SCALE(dig_tlv, -12750, 50, 0);
150
151static const char * const chan_mix_texts[] = {
152 "Mute", "MuteA", "MuteA SwapB", "MuteA MonoB", "SwapA MuteB",
153 "BothR", "Swap", "SwapA MonoB", "MuteB", "Normal", "BothL",
154 "MonoB", "MonoA MuteB", "MonoA", "MonoA SwapB", "Mono",
155 /*Normal == Channel A = Left, Channel B = Right*/
156};
157
158static const char * const fm_texts[] = {
159 "Auto", "Single", "Double", "Quad",
160};
161
162static const char * const deemph_texts[] = {
163 "None", "44.1k", "48k", "32k",
164};
165
166static const char * const softr_zeroc_texts[] = {
167 "Immediate", "Zero Cross", "Soft Ramp", "SR on ZC",
168};
169
170static int deemph_values[] = {
171 0, 4, 8, 12,
172};
173
174static int softr_zeroc_values[] = {
175 0, 64, 128, 192,
176};
177
178static const struct soc_enum chan_mix_enum =
179 SOC_ENUM_SINGLE(CS4349_VMI, 0,
180 ARRAY_SIZE(chan_mix_texts),
181 chan_mix_texts);
182
183static const struct soc_enum fm_mode_enum =
184 SOC_ENUM_SINGLE(CS4349_MODE, 0,
185 ARRAY_SIZE(fm_texts),
186 fm_texts);
187
188static SOC_VALUE_ENUM_SINGLE_DECL(deemph_enum, CS4349_MODE, 0, DEM_MASK,
189 deemph_texts, deemph_values);
190
191static SOC_VALUE_ENUM_SINGLE_DECL(softr_zeroc_enum, CS4349_RMPFLT, 0,
192 SR_ZC_MASK, softr_zeroc_texts,
193 softr_zeroc_values);
194
195static const struct snd_kcontrol_new cs4349_snd_controls[] = {
196 SOC_DOUBLE_R_TLV("Master Playback Volume",
197 CS4349_VOLA, CS4349_VOLB, 0, 0xFF, 1, dig_tlv),
198 SOC_ENUM("Functional Mode", fm_mode_enum),
199 SOC_ENUM("De-Emphasis Control", deemph_enum),
200 SOC_ENUM("Soft Ramp Zero Cross Control", softr_zeroc_enum),
201 SOC_ENUM("Channel Mixer", chan_mix_enum),
202 SOC_SINGLE("VolA = VolB Switch", CS4349_VMI, 7, 1, 0),
203 SOC_SINGLE("InvertA Switch", CS4349_VMI, 6, 1, 0),
204 SOC_SINGLE("InvertB Switch", CS4349_VMI, 5, 1, 0),
205 SOC_SINGLE("Auto-Mute Switch", CS4349_MUTE, 7, 1, 0),
206 SOC_SINGLE("MUTEC A = B Switch", CS4349_MUTE, 5, 1, 0),
207 SOC_SINGLE("Soft Ramp Up Switch", CS4349_RMPFLT, 5, 1, 0),
208 SOC_SINGLE("Soft Ramp Down Switch", CS4349_RMPFLT, 4, 1, 0),
209 SOC_SINGLE("Slow Roll Off Filter Switch", CS4349_RMPFLT, 2, 1, 0),
210 SOC_SINGLE("Freeze Switch", CS4349_MISC, 5, 1, 0),
211 SOC_SINGLE("Popguard Switch", CS4349_MISC, 4, 1, 0),
212};
213
214static const struct snd_soc_dapm_widget cs4349_dapm_widgets[] = {
215 SND_SOC_DAPM_DAC("HiFi DAC", NULL, SND_SOC_NOPM, 0, 0),
216
217 SND_SOC_DAPM_OUTPUT("OutputA"),
218 SND_SOC_DAPM_OUTPUT("OutputB"),
219};
220
221static const struct snd_soc_dapm_route cs4349_routes[] = {
222 {"DAC Playback", NULL, "OutputA"},
223 {"DAC Playback", NULL, "OutputB"},
224
225 {"OutputA", NULL, "HiFi DAC"},
226 {"OutputB", NULL, "HiFi DAC"},
227};
228
229#define CS4349_PCM_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
230 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \
231 SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE | \
232 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE | \
233 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | \
234 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE | \
235 SNDRV_PCM_FMTBIT_S32_LE)
236
237#define CS4349_PCM_RATES SNDRV_PCM_RATE_8000_192000
238
239static const struct snd_soc_dai_ops cs4349_dai_ops = {
240 .hw_params = cs4349_pcm_hw_params,
241 .set_fmt = cs4349_set_dai_fmt,
242 .digital_mute = cs4349_digital_mute,
243};
244
245static struct snd_soc_dai_driver cs4349_dai = {
246 .name = "cs4349_hifi",
247 .playback = {
248 .stream_name = "DAC Playback",
249 .channels_min = 1,
250 .channels_max = 2,
251 .rates = CS4349_PCM_RATES,
252 .formats = CS4349_PCM_FORMATS,
253 },
254 .ops = &cs4349_dai_ops,
255 .symmetric_rates = 1,
256};
257
258static struct snd_soc_codec_driver soc_codec_dev_cs4349 = {
259 .controls = cs4349_snd_controls,
260 .num_controls = ARRAY_SIZE(cs4349_snd_controls),
261
262 .dapm_widgets = cs4349_dapm_widgets,
263 .num_dapm_widgets = ARRAY_SIZE(cs4349_dapm_widgets),
264 .dapm_routes = cs4349_routes,
265 .num_dapm_routes = ARRAY_SIZE(cs4349_routes),
266};
267
268static const struct regmap_config cs4349_regmap = {
269 .reg_bits = 8,
270 .val_bits = 8,
271
272 .max_register = CS4349_MISC,
273 .reg_defaults = cs4349_reg_defaults,
274 .num_reg_defaults = ARRAY_SIZE(cs4349_reg_defaults),
275 .readable_reg = cs4349_readable_register,
276 .writeable_reg = cs4349_writeable_register,
277 .cache_type = REGCACHE_RBTREE,
278};
279
280static int cs4349_i2c_probe(struct i2c_client *client,
281 const struct i2c_device_id *id)
282{
283 struct cs4349_private *cs4349;
284 int ret;
285
286 cs4349 = devm_kzalloc(&client->dev, sizeof(*cs4349), GFP_KERNEL);
287 if (!cs4349)
288 return -ENOMEM;
289
290 cs4349->regmap = devm_regmap_init_i2c(client, &cs4349_regmap);
291 if (IS_ERR(cs4349->regmap)) {
292 ret = PTR_ERR(cs4349->regmap);
293 dev_err(&client->dev, "regmap_init() failed: %d\n", ret);
294 return ret;
295 }
296
297 /* Reset the Device */
298 cs4349->reset_gpio = devm_gpiod_get_optional(&client->dev,
299 "reset", GPIOD_OUT_LOW);
300 if (IS_ERR(cs4349->reset_gpio))
301 return PTR_ERR(cs4349->reset_gpio);
302
303 gpiod_set_value_cansleep(cs4349->reset_gpio, 1);
304
305 i2c_set_clientdata(client, cs4349);
306
307 return snd_soc_register_codec(&client->dev, &soc_codec_dev_cs4349,
308 &cs4349_dai, 1);
309}
310
311static int cs4349_i2c_remove(struct i2c_client *client)
312{
313 struct cs4349_private *cs4349 = i2c_get_clientdata(client);
314
315 snd_soc_unregister_codec(&client->dev);
316
317 /* Hold down reset */
318 gpiod_set_value_cansleep(cs4349->reset_gpio, 0);
319
320 return 0;
321}
322
323#ifdef CONFIG_PM
324static int cs4349_runtime_suspend(struct device *dev)
325{
326 struct cs4349_private *cs4349 = dev_get_drvdata(dev);
327 int ret;
328
329 ret = regmap_update_bits(cs4349->regmap, CS4349_MISC, PWR_DWN, PWR_DWN);
330 if (ret < 0)
331 return ret;
332
333 regcache_cache_only(cs4349->regmap, true);
334
335 /* Hold down reset */
336 gpiod_set_value_cansleep(cs4349->reset_gpio, 0);
337
338 return 0;
339}
340
341static int cs4349_runtime_resume(struct device *dev)
342{
343 struct cs4349_private *cs4349 = dev_get_drvdata(dev);
344 int ret;
345
346 ret = regmap_update_bits(cs4349->regmap, CS4349_MISC, PWR_DWN, 0);
347 if (ret < 0)
348 return ret;
349
350 gpiod_set_value_cansleep(cs4349->reset_gpio, 1);
351
352 regcache_cache_only(cs4349->regmap, false);
353 regcache_sync(cs4349->regmap);
354
355 return 0;
356}
357#endif
358
359static const struct dev_pm_ops cs4349_runtime_pm = {
360 SET_RUNTIME_PM_OPS(cs4349_runtime_suspend, cs4349_runtime_resume,
361 NULL)
362};
363
364static const struct of_device_id cs4349_of_match[] = {
365 { .compatible = "cirrus,cs4349", },
366 {},
367};
368
369MODULE_DEVICE_TABLE(of, cs4349_of_match);
370
371static const struct i2c_device_id cs4349_i2c_id[] = {
372 {"cs4349", 0},
373 {}
374};
375
376MODULE_DEVICE_TABLE(i2c, cs4349_i2c_id);
377
378static struct i2c_driver cs4349_i2c_driver = {
379 .driver = {
380 .name = "cs4349",
381 .of_match_table = cs4349_of_match,
382 },
383 .id_table = cs4349_i2c_id,
384 .probe = cs4349_i2c_probe,
385 .remove = cs4349_i2c_remove,
386};
387
388module_i2c_driver(cs4349_i2c_driver);
389
390MODULE_AUTHOR("Tim Howe <tim.howe@cirrus.com>");
391MODULE_DESCRIPTION("Cirrus Logic CS4349 ALSA SoC Codec Driver");
392MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/cs4349.h b/sound/soc/codecs/cs4349.h
new file mode 100644
index 000000000000..d58c06a25358
--- /dev/null
+++ b/sound/soc/codecs/cs4349.h
@@ -0,0 +1,136 @@
1/*
2 * ALSA SoC CS4349 codec driver
3 *
4 * Copyright 2015 Cirrus Logic, Inc.
5 *
6 * Author: Tim Howe <Tim.Howe@cirrus.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 */
18
19#ifndef __CS4349_H__
20#define __CS4349_H__
21
22/* CS4349 registers addresses */
23#define CS4349_CHIPID 0x01 /* Device and Rev ID, Read Only */
24#define CS4349_MODE 0x02 /* Mode Control */
25#define CS4349_VMI 0x03 /* Volume, Mixing, Inversion Control */
26#define CS4349_MUTE 0x04 /* Mute Control */
27#define CS4349_VOLA 0x05 /* DAC Channel A Volume Control */
28#define CS4349_VOLB 0x06 /* DAC Channel B Volume Control */
29#define CS4349_RMPFLT 0x07 /* Ramp and Filter Control */
30#define CS4349_MISC 0x08 /* Power Down,Freeze Control,Pop Stop*/
31
32#define CS4349_I2C_INCR 0x80
33
34
35/* Device and Revision ID */
36#define CS4349_REVA 0xF0 /* Rev A */
37#define CS4349_REVB 0xF1 /* Rev B */
38#define CS4349_REVC2 0xFF /* Rev C2 */
39
40
41/* PDN_DONE Poll Maximum
42 * If soft ramp is set it will take much longer to power down
43 * the system.
44 */
45#define PDN_POLL_MAX 900
46
47
48/* Bitfield Definitions */
49
50/* CS4349_MODE */
51/* (Digital Interface Format, De-Emphasis Control, Functional Mode */
52#define DIF2 (1 << 6)
53#define DIF1 (1 << 5)
54#define DIF0 (1 << 4)
55#define DEM1 (1 << 3)
56#define DEM0 (1 << 2)
57#define FM1 (1 << 1)
58#define DIF_LEFT_JST 0x00
59#define DIF_I2S 0x01
60#define DIF_RGHT_JST16 0x02
61#define DIF_RGHT_JST24 0x03
62#define DIF_TDM0 0x04
63#define DIF_TDM1 0x05
64#define DIF_TDM2 0x06
65#define DIF_TDM3 0x07
66#define DIF_MASK 0x70
67#define MODE_FORMAT(x) (((x)&7)<<4)
68#define DEM_MASK 0x0C
69#define NO_DEM 0x00
70#define DEM_441 0x04
71#define DEM_48K 0x08
72#define DEM_32K 0x0C
73#define FM_AUTO 0x00
74#define FM_SNGL 0x01
75#define FM_DBL 0x02
76#define FM_QUAD 0x03
77#define FM_SNGL_MIN 30000
78#define FM_SNGL_MAX 54000
79#define FM_DBL_MAX 108000
80#define FM_QUAD_MAX 216000
81#define FM_MASK 0x03
82
83/* CS4349_VMI (VMI = Volume, Mixing and Inversion Controls) */
84#define VOLBISA (1 << 7)
85#define VOLAISB (1 << 7)
86/* INVERT_A only available for Left Jstfd, Right Jstfd16 and Right Jstfd24 */
87#define INVERT_A (1 << 6)
88/* INVERT_B only available for Left Jstfd, Right Jstfd16 and Right Jstfd24 */
89#define INVERT_B (1 << 5)
90#define ATAPI3 (1 << 3)
91#define ATAPI2 (1 << 2)
92#define ATAPI1 (1 << 1)
93#define ATAPI0 (1 << 0)
94#define MUTEAB 0x00
95#define MUTEA_RIGHTB 0x01
96#define MUTEA_LEFTB 0x02
97#define MUTEA_SUMLRDIV2B 0x03
98#define RIGHTA_MUTEB 0x04
99#define RIGHTA_RIGHTB 0x05
100#define RIGHTA_LEFTB 0x06
101#define RIGHTA_SUMLRDIV2B 0x07
102#define LEFTA_MUTEB 0x08
103#define LEFTA_RIGHTB 0x09 /* Default */
104#define LEFTA_LEFTB 0x0A
105#define LEFTA_SUMLRDIV2B 0x0B
106#define SUMLRDIV2A_MUTEB 0x0C
107#define SUMLRDIV2A_RIGHTB 0x0D
108#define SUMLRDIV2A_LEFTB 0x0E
109#define SUMLRDIV2_AB 0x0F
110#define CHMIX_MASK 0x0F
111
112/* CS4349_MUTE */
113#define AUTOMUTE (1 << 7)
114#define MUTEC_AB (1 << 5)
115#define MUTE_A (1 << 4)
116#define MUTE_B (1 << 3)
117#define MUTE_AB_MASK 0x18
118
119/* CS4349_RMPFLT (Ramp and Filter Control) */
120#define SCZ1 (1 << 7)
121#define SCZ0 (1 << 6)
122#define RMP_UP (1 << 5)
123#define RMP_DN (1 << 4)
124#define FILT_SEL (1 << 2)
125#define IMMDT_CHNG 0x31
126#define ZEROCRSS 0x71
127#define SOFT_RMP 0xB1
128#define SFTRMP_ZEROCRSS 0xF1
129#define SR_ZC_MASK 0xC0
130
131/* CS4349_MISC */
132#define PWR_DWN (1 << 7)
133#define FREEZE (1 << 5)
134#define POPG_EN (1 << 4)
135
136#endif /* __CS4349_H__ */
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c
index 21810e5f3321..c7b3e927c606 100644
--- a/sound/soc/codecs/da7210.c
+++ b/sound/soc/codecs/da7210.c
@@ -680,7 +680,7 @@ struct da7210_priv {
680 int master; 680 int master;
681}; 681};
682 682
683static struct reg_default da7210_reg_defaults[] = { 683static const struct reg_default da7210_reg_defaults[] = {
684 { 0x00, 0x00 }, 684 { 0x00, 0x00 },
685 { 0x01, 0x11 }, 685 { 0x01, 0x11 },
686 { 0x03, 0x00 }, 686 { 0x03, 0x00 },
@@ -1182,7 +1182,7 @@ static struct snd_soc_codec_driver soc_codec_dev_da7210 = {
1182 1182
1183#if IS_ENABLED(CONFIG_I2C) 1183#if IS_ENABLED(CONFIG_I2C)
1184 1184
1185static struct reg_default da7210_regmap_i2c_patch[] = { 1185static const struct reg_sequence da7210_regmap_i2c_patch[] = {
1186 1186
1187 /* System controller master disable */ 1187 /* System controller master disable */
1188 { DA7210_STARTUP1, 0x00 }, 1188 { DA7210_STARTUP1, 0x00 },
@@ -1259,7 +1259,6 @@ MODULE_DEVICE_TABLE(i2c, da7210_i2c_id);
1259static struct i2c_driver da7210_i2c_driver = { 1259static struct i2c_driver da7210_i2c_driver = {
1260 .driver = { 1260 .driver = {
1261 .name = "da7210", 1261 .name = "da7210",
1262 .owner = THIS_MODULE,
1263 }, 1262 },
1264 .probe = da7210_i2c_probe, 1263 .probe = da7210_i2c_probe,
1265 .remove = da7210_i2c_remove, 1264 .remove = da7210_i2c_remove,
@@ -1269,7 +1268,7 @@ static struct i2c_driver da7210_i2c_driver = {
1269 1268
1270#if defined(CONFIG_SPI_MASTER) 1269#if defined(CONFIG_SPI_MASTER)
1271 1270
1272static struct reg_default da7210_regmap_spi_patch[] = { 1271static const struct reg_sequence da7210_regmap_spi_patch[] = {
1273 /* Dummy read to give two pulses over nCS for SPI */ 1272 /* Dummy read to give two pulses over nCS for SPI */
1274 { DA7210_AUX2, 0x00 }, 1273 { DA7210_AUX2, 0x00 },
1275 { DA7210_AUX2, 0x00 }, 1274 { DA7210_AUX2, 0x00 },
diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c
index 238e48a3a4fe..47fc3bec8a9c 100644
--- a/sound/soc/codecs/da7213.c
+++ b/sound/soc/codecs/da7213.c
@@ -954,7 +954,7 @@ static const struct snd_soc_dapm_route da7213_audio_map[] = {
954 {"LINE", NULL, "Lineout PGA"}, 954 {"LINE", NULL, "Lineout PGA"},
955}; 955};
956 956
957static struct reg_default da7213_reg_defaults[] = { 957static const struct reg_default da7213_reg_defaults[] = {
958 { DA7213_DIG_ROUTING_DAI, 0x10 }, 958 { DA7213_DIG_ROUTING_DAI, 0x10 },
959 { DA7213_SR, 0x0A }, 959 { DA7213_SR, 0x0A },
960 { DA7213_REFERENCES, 0x80 }, 960 { DA7213_REFERENCES, 0x80 },
@@ -1585,7 +1585,6 @@ MODULE_DEVICE_TABLE(i2c, da7213_i2c_id);
1585static struct i2c_driver da7213_i2c_driver = { 1585static struct i2c_driver da7213_i2c_driver = {
1586 .driver = { 1586 .driver = {
1587 .name = "da7213", 1587 .name = "da7213",
1588 .owner = THIS_MODULE,
1589 }, 1588 },
1590 .probe = da7213_i2c_probe, 1589 .probe = da7213_i2c_probe,
1591 .remove = da7213_remove, 1590 .remove = da7213_remove,
diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c
index 207523686bd5..1d5a89c5164b 100644
--- a/sound/soc/codecs/da732x.c
+++ b/sound/soc/codecs/da732x.c
@@ -43,7 +43,7 @@ struct da732x_priv {
43/* 43/*
44 * da732x register cache - default settings 44 * da732x register cache - default settings
45 */ 45 */
46static struct reg_default da732x_reg_cache[] = { 46static const struct reg_default da732x_reg_cache[] = {
47 { DA732X_REG_REF1 , 0x02 }, 47 { DA732X_REG_REF1 , 0x02 },
48 { DA732X_REG_BIAS_EN , 0x80 }, 48 { DA732X_REG_BIAS_EN , 0x80 },
49 { DA732X_REG_BIAS1 , 0x00 }, 49 { DA732X_REG_BIAS1 , 0x00 },
@@ -1196,13 +1196,7 @@ static int da732x_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
1196#define DA732X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ 1196#define DA732X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
1197 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 1197 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
1198 1198
1199static struct snd_soc_dai_ops da732x_dai1_ops = { 1199static const struct snd_soc_dai_ops da732x_dai_ops = {
1200 .hw_params = da732x_hw_params,
1201 .set_fmt = da732x_set_dai_fmt,
1202 .set_sysclk = da732x_set_dai_sysclk,
1203};
1204
1205static struct snd_soc_dai_ops da732x_dai2_ops = {
1206 .hw_params = da732x_hw_params, 1200 .hw_params = da732x_hw_params,
1207 .set_fmt = da732x_set_dai_fmt, 1201 .set_fmt = da732x_set_dai_fmt,
1208 .set_sysclk = da732x_set_dai_sysclk, 1202 .set_sysclk = da732x_set_dai_sysclk,
@@ -1227,7 +1221,7 @@ static struct snd_soc_dai_driver da732x_dai[] = {
1227 .rates = DA732X_RATES, 1221 .rates = DA732X_RATES,
1228 .formats = DA732X_FORMATS, 1222 .formats = DA732X_FORMATS,
1229 }, 1223 },
1230 .ops = &da732x_dai1_ops, 1224 .ops = &da732x_dai_ops,
1231 }, 1225 },
1232 { 1226 {
1233 .name = "DA732X_AIFB", 1227 .name = "DA732X_AIFB",
@@ -1247,7 +1241,7 @@ static struct snd_soc_dai_driver da732x_dai[] = {
1247 .rates = DA732X_RATES, 1241 .rates = DA732X_RATES,
1248 .formats = DA732X_FORMATS, 1242 .formats = DA732X_FORMATS,
1249 }, 1243 },
1250 .ops = &da732x_dai2_ops, 1244 .ops = &da732x_dai_ops,
1251 }, 1245 },
1252}; 1246};
1253 1247
@@ -1572,7 +1566,6 @@ MODULE_DEVICE_TABLE(i2c, da732x_i2c_id);
1572static struct i2c_driver da732x_i2c_driver = { 1566static struct i2c_driver da732x_i2c_driver = {
1573 .driver = { 1567 .driver = {
1574 .name = "da7320", 1568 .name = "da7320",
1575 .owner = THIS_MODULE,
1576 }, 1569 },
1577 .probe = da732x_i2c_probe, 1570 .probe = da732x_i2c_probe,
1578 .remove = da732x_i2c_remove, 1571 .remove = da732x_i2c_remove,
diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c
index 66bb446473b8..19635d830b47 100644
--- a/sound/soc/codecs/da9055.c
+++ b/sound/soc/codecs/da9055.c
@@ -948,7 +948,7 @@ struct da9055_priv {
948 struct da9055_platform_data *pdata; 948 struct da9055_platform_data *pdata;
949}; 949};
950 950
951static struct reg_default da9055_reg_defaults[] = { 951static const struct reg_default da9055_reg_defaults[] = {
952 { 0x21, 0x10 }, 952 { 0x21, 0x10 },
953 { 0x22, 0x0A }, 953 { 0x22, 0x0A },
954 { 0x23, 0x00 }, 954 { 0x23, 0x00 },
@@ -1533,12 +1533,12 @@ static const struct of_device_id da9055_of_match[] = {
1533 { .compatible = "dlg,da9055-codec", }, 1533 { .compatible = "dlg,da9055-codec", },
1534 { } 1534 { }
1535}; 1535};
1536MODULE_DEVICE_TABLE(of, da9055_of_match);
1536 1537
1537/* I2C codec control layer */ 1538/* I2C codec control layer */
1538static struct i2c_driver da9055_i2c_driver = { 1539static struct i2c_driver da9055_i2c_driver = {
1539 .driver = { 1540 .driver = {
1540 .name = "da9055-codec", 1541 .name = "da9055-codec",
1541 .owner = THIS_MODULE,
1542 .of_match_table = of_match_ptr(da9055_of_match), 1542 .of_match_table = of_match_ptr(da9055_of_match),
1543 }, 1543 },
1544 .probe = da9055_i2c_probe, 1544 .probe = da9055_i2c_probe,
diff --git a/sound/soc/codecs/gtm601.c b/sound/soc/codecs/gtm601.c
new file mode 100644
index 000000000000..0b80052996d3
--- /dev/null
+++ b/sound/soc/codecs/gtm601.c
@@ -0,0 +1,95 @@
1/*
2 * This is a simple driver for the GTM601 Voice PCM interface
3 *
4 * Copyright (C) 2015 Goldelico GmbH
5 *
6 * Author: Marek Belisko <marek@goldelico.com>
7 *
8 * Based on wm8727.c driver
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/init.h>
16#include <linux/slab.h>
17#include <linux/module.h>
18#include <linux/kernel.h>
19#include <linux/device.h>
20#include <sound/core.h>
21#include <sound/pcm.h>
22#include <sound/ac97_codec.h>
23#include <sound/initval.h>
24#include <sound/soc.h>
25
26static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = {
27 SND_SOC_DAPM_OUTPUT("AOUT"),
28 SND_SOC_DAPM_INPUT("AIN"),
29};
30
31static const struct snd_soc_dapm_route gtm601_dapm_routes[] = {
32 { "AOUT", NULL, "Playback" },
33 { "Capture", NULL, "AIN" },
34};
35
36static struct snd_soc_dai_driver gtm601_dai = {
37 .name = "gtm601",
38 .playback = {
39 .stream_name = "Playback",
40 .channels_min = 1,
41 .channels_max = 1,
42 .rates = SNDRV_PCM_RATE_8000,
43 .formats = SNDRV_PCM_FMTBIT_S16_LE,
44 },
45 .capture = {
46 .stream_name = "Capture",
47 .channels_min = 1,
48 .channels_max = 1,
49 .rates = SNDRV_PCM_RATE_8000,
50 .formats = SNDRV_PCM_FMTBIT_S16_LE,
51 },
52};
53
54static const struct snd_soc_codec_driver soc_codec_dev_gtm601 = {
55 .dapm_widgets = gtm601_dapm_widgets,
56 .num_dapm_widgets = ARRAY_SIZE(gtm601_dapm_widgets),
57 .dapm_routes = gtm601_dapm_routes,
58 .num_dapm_routes = ARRAY_SIZE(gtm601_dapm_routes),
59};
60
61static int gtm601_platform_probe(struct platform_device *pdev)
62{
63 return snd_soc_register_codec(&pdev->dev,
64 &soc_codec_dev_gtm601, &gtm601_dai, 1);
65}
66
67static int gtm601_platform_remove(struct platform_device *pdev)
68{
69 snd_soc_unregister_codec(&pdev->dev);
70 return 0;
71}
72
73#if defined(CONFIG_OF)
74static const struct of_device_id gtm601_codec_of_match[] = {
75 { .compatible = "option,gtm601", },
76 {},
77};
78MODULE_DEVICE_TABLE(of, gtm601_codec_of_match);
79#endif
80
81static struct platform_driver gtm601_codec_driver = {
82 .driver = {
83 .name = "gtm601",
84 .of_match_table = of_match_ptr(gtm601_codec_of_match),
85 },
86 .probe = gtm601_platform_probe,
87 .remove = gtm601_platform_remove,
88};
89
90module_platform_driver(gtm601_codec_driver);
91
92MODULE_DESCRIPTION("ASoC gtm601 driver");
93MODULE_AUTHOR("Marek Belisko <marek@goldelico.com>");
94MODULE_LICENSE("GPL");
95MODULE_ALIAS("platform:gtm601");
diff --git a/sound/soc/codecs/ics43432.c b/sound/soc/codecs/ics43432.c
new file mode 100644
index 000000000000..dd850b93938d
--- /dev/null
+++ b/sound/soc/codecs/ics43432.c
@@ -0,0 +1,76 @@
1/*
2 * I2S MEMS microphone driver for InvenSense ICS-43432
3 *
4 * - Non configurable.
5 * - I2S interface, 64 BCLs per frame, 32 bits per channel, 24 bit data
6 *
7 * Copyright (c) 2015 Axis Communications AB
8 *
9 * Licensed under GPL v2.
10 */
11
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/slab.h>
15#include <sound/core.h>
16#include <sound/pcm.h>
17#include <sound/pcm_params.h>
18#include <sound/soc.h>
19#include <sound/initval.h>
20#include <sound/tlv.h>
21
22#define ICS43432_RATE_MIN 7190 /* Hz, from data sheet */
23#define ICS43432_RATE_MAX 52800 /* Hz, from data sheet */
24
25#define ICS43432_FORMATS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32)
26
27static struct snd_soc_dai_driver ics43432_dai = {
28 .name = "ics43432-hifi",
29 .capture = {
30 .stream_name = "Capture",
31 .channels_min = 1,
32 .channels_max = 2,
33 .rate_min = ICS43432_RATE_MIN,
34 .rate_max = ICS43432_RATE_MAX,
35 .rates = SNDRV_PCM_RATE_CONTINUOUS,
36 .formats = ICS43432_FORMATS,
37 },
38};
39
40static struct snd_soc_codec_driver ics43432_codec_driver = {
41};
42
43static int ics43432_probe(struct platform_device *pdev)
44{
45 return snd_soc_register_codec(&pdev->dev, &ics43432_codec_driver,
46 &ics43432_dai, 1);
47}
48
49static int ics43432_remove(struct platform_device *pdev)
50{
51 snd_soc_unregister_codec(&pdev->dev);
52 return 0;
53}
54
55#ifdef CONFIG_OF
56static const struct of_device_id ics43432_ids[] = {
57 { .compatible = "invensense,ics43432", },
58 { }
59};
60MODULE_DEVICE_TABLE(of, ics43432_ids);
61#endif
62
63static struct platform_driver ics43432_driver = {
64 .driver = {
65 .name = "ics43432",
66 .of_match_table = of_match_ptr(ics43432_ids),
67 },
68 .probe = ics43432_probe,
69 .remove = ics43432_remove,
70};
71
72module_platform_driver(ics43432_driver);
73
74MODULE_DESCRIPTION("ASoC ICS43432 driver");
75MODULE_AUTHOR("Ricard Wanderlof <ricardw@axis.com>");
76MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/isabelle.c b/sound/soc/codecs/isabelle.c
index ebd90283c960..be448373d39a 100644
--- a/sound/soc/codecs/isabelle.c
+++ b/sound/soc/codecs/isabelle.c
@@ -33,7 +33,7 @@
33 33
34 34
35/* Register default values for ISABELLE driver. */ 35/* Register default values for ISABELLE driver. */
36static struct reg_default isabelle_reg_defs[] = { 36static const struct reg_default isabelle_reg_defs[] = {
37 { 0, 0x00 }, 37 { 0, 0x00 },
38 { 1, 0x00 }, 38 { 1, 0x00 },
39 { 2, 0x00 }, 39 { 2, 0x00 },
@@ -1016,25 +1016,25 @@ static int isabelle_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
1016#define ISABELLE_FORMATS (SNDRV_PCM_FMTBIT_S20_3LE |\ 1016#define ISABELLE_FORMATS (SNDRV_PCM_FMTBIT_S20_3LE |\
1017 SNDRV_PCM_FMTBIT_S32_LE) 1017 SNDRV_PCM_FMTBIT_S32_LE)
1018 1018
1019static struct snd_soc_dai_ops isabelle_hs_dai_ops = { 1019static const struct snd_soc_dai_ops isabelle_hs_dai_ops = {
1020 .hw_params = isabelle_hw_params, 1020 .hw_params = isabelle_hw_params,
1021 .set_fmt = isabelle_set_dai_fmt, 1021 .set_fmt = isabelle_set_dai_fmt,
1022 .digital_mute = isabelle_hs_mute, 1022 .digital_mute = isabelle_hs_mute,
1023}; 1023};
1024 1024
1025static struct snd_soc_dai_ops isabelle_hf_dai_ops = { 1025static const struct snd_soc_dai_ops isabelle_hf_dai_ops = {
1026 .hw_params = isabelle_hw_params, 1026 .hw_params = isabelle_hw_params,
1027 .set_fmt = isabelle_set_dai_fmt, 1027 .set_fmt = isabelle_set_dai_fmt,
1028 .digital_mute = isabelle_hf_mute, 1028 .digital_mute = isabelle_hf_mute,
1029}; 1029};
1030 1030
1031static struct snd_soc_dai_ops isabelle_line_dai_ops = { 1031static const struct snd_soc_dai_ops isabelle_line_dai_ops = {
1032 .hw_params = isabelle_hw_params, 1032 .hw_params = isabelle_hw_params,
1033 .set_fmt = isabelle_set_dai_fmt, 1033 .set_fmt = isabelle_set_dai_fmt,
1034 .digital_mute = isabelle_line_mute, 1034 .digital_mute = isabelle_line_mute,
1035}; 1035};
1036 1036
1037static struct snd_soc_dai_ops isabelle_ul_dai_ops = { 1037static const struct snd_soc_dai_ops isabelle_ul_dai_ops = {
1038 .hw_params = isabelle_hw_params, 1038 .hw_params = isabelle_hw_params,
1039 .set_fmt = isabelle_set_dai_fmt, 1039 .set_fmt = isabelle_set_dai_fmt,
1040}; 1040};
@@ -1149,7 +1149,6 @@ MODULE_DEVICE_TABLE(i2c, isabelle_i2c_id);
1149static struct i2c_driver isabelle_i2c_driver = { 1149static struct i2c_driver isabelle_i2c_driver = {
1150 .driver = { 1150 .driver = {
1151 .name = "isabelle", 1151 .name = "isabelle",
1152 .owner = THIS_MODULE,
1153 }, 1152 },
1154 .probe = isabelle_i2c_probe, 1153 .probe = isabelle_i2c_probe,
1155 .remove = isabelle_i2c_remove, 1154 .remove = isabelle_i2c_remove,
diff --git a/sound/soc/codecs/lm4857.c b/sound/soc/codecs/lm4857.c
index 99ffc49aa779..558de1053f73 100644
--- a/sound/soc/codecs/lm4857.c
+++ b/sound/soc/codecs/lm4857.c
@@ -142,7 +142,6 @@ MODULE_DEVICE_TABLE(i2c, lm4857_i2c_id);
142static struct i2c_driver lm4857_i2c_driver = { 142static struct i2c_driver lm4857_i2c_driver = {
143 .driver = { 143 .driver = {
144 .name = "lm4857", 144 .name = "lm4857",
145 .owner = THIS_MODULE,
146 }, 145 },
147 .probe = lm4857_i2c_probe, 146 .probe = lm4857_i2c_probe,
148 .id_table = lm4857_i2c_id, 147 .id_table = lm4857_i2c_id,
diff --git a/sound/soc/codecs/lm49453.c b/sound/soc/codecs/lm49453.c
index 6600aa0a33dc..9af5640e3446 100644
--- a/sound/soc/codecs/lm49453.c
+++ b/sound/soc/codecs/lm49453.c
@@ -30,7 +30,7 @@
30#include <asm/div64.h> 30#include <asm/div64.h>
31#include "lm49453.h" 31#include "lm49453.h"
32 32
33static struct reg_default lm49453_reg_defs[] = { 33static const struct reg_default lm49453_reg_defs[] = {
34 { 0, 0x00 }, 34 { 0, 0x00 },
35 { 1, 0x00 }, 35 { 1, 0x00 },
36 { 2, 0x00 }, 36 { 2, 0x00 },
@@ -188,7 +188,6 @@ static struct reg_default lm49453_reg_defs[] = {
188/* codec private data */ 188/* codec private data */
189struct lm49453_priv { 189struct lm49453_priv {
190 struct regmap *regmap; 190 struct regmap *regmap;
191 int fs_rate;
192}; 191};
193 192
194/* capture path controls */ 193/* capture path controls */
@@ -1112,13 +1111,10 @@ static int lm49453_hw_params(struct snd_pcm_substream *substream,
1112 struct snd_soc_dai *dai) 1111 struct snd_soc_dai *dai)
1113{ 1112{
1114 struct snd_soc_codec *codec = dai->codec; 1113 struct snd_soc_codec *codec = dai->codec;
1115 struct lm49453_priv *lm49453 = snd_soc_codec_get_drvdata(codec);
1116 u16 clk_div = 0; 1114 u16 clk_div = 0;
1117 1115
1118 lm49453->fs_rate = params_rate(params);
1119
1120 /* Setting DAC clock dividers based on substream sample rate. */ 1116 /* Setting DAC clock dividers based on substream sample rate. */
1121 switch (lm49453->fs_rate) { 1117 switch (params_rate(params)) {
1122 case 8000: 1118 case 8000:
1123 case 16000: 1119 case 16000:
1124 case 32000: 1120 case 32000:
@@ -1291,35 +1287,35 @@ static int lm49453_set_bias_level(struct snd_soc_codec *codec,
1291#define LM49453_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 1287#define LM49453_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
1292 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 1288 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
1293 1289
1294static struct snd_soc_dai_ops lm49453_headset_dai_ops = { 1290static const struct snd_soc_dai_ops lm49453_headset_dai_ops = {
1295 .hw_params = lm49453_hw_params, 1291 .hw_params = lm49453_hw_params,
1296 .set_sysclk = lm49453_set_dai_sysclk, 1292 .set_sysclk = lm49453_set_dai_sysclk,
1297 .set_fmt = lm49453_set_dai_fmt, 1293 .set_fmt = lm49453_set_dai_fmt,
1298 .digital_mute = lm49453_hp_mute, 1294 .digital_mute = lm49453_hp_mute,
1299}; 1295};
1300 1296
1301static struct snd_soc_dai_ops lm49453_speaker_dai_ops = { 1297static const struct snd_soc_dai_ops lm49453_speaker_dai_ops = {
1302 .hw_params = lm49453_hw_params, 1298 .hw_params = lm49453_hw_params,
1303 .set_sysclk = lm49453_set_dai_sysclk, 1299 .set_sysclk = lm49453_set_dai_sysclk,
1304 .set_fmt = lm49453_set_dai_fmt, 1300 .set_fmt = lm49453_set_dai_fmt,
1305 .digital_mute = lm49453_ls_mute, 1301 .digital_mute = lm49453_ls_mute,
1306}; 1302};
1307 1303
1308static struct snd_soc_dai_ops lm49453_haptic_dai_ops = { 1304static const struct snd_soc_dai_ops lm49453_haptic_dai_ops = {
1309 .hw_params = lm49453_hw_params, 1305 .hw_params = lm49453_hw_params,
1310 .set_sysclk = lm49453_set_dai_sysclk, 1306 .set_sysclk = lm49453_set_dai_sysclk,
1311 .set_fmt = lm49453_set_dai_fmt, 1307 .set_fmt = lm49453_set_dai_fmt,
1312 .digital_mute = lm49453_ha_mute, 1308 .digital_mute = lm49453_ha_mute,
1313}; 1309};
1314 1310
1315static struct snd_soc_dai_ops lm49453_ep_dai_ops = { 1311static const struct snd_soc_dai_ops lm49453_ep_dai_ops = {
1316 .hw_params = lm49453_hw_params, 1312 .hw_params = lm49453_hw_params,
1317 .set_sysclk = lm49453_set_dai_sysclk, 1313 .set_sysclk = lm49453_set_dai_sysclk,
1318 .set_fmt = lm49453_set_dai_fmt, 1314 .set_fmt = lm49453_set_dai_fmt,
1319 .digital_mute = lm49453_ep_mute, 1315 .digital_mute = lm49453_ep_mute,
1320}; 1316};
1321 1317
1322static struct snd_soc_dai_ops lm49453_lineout_dai_ops = { 1318static const struct snd_soc_dai_ops lm49453_lineout_dai_ops = {
1323 .hw_params = lm49453_hw_params, 1319 .hw_params = lm49453_hw_params,
1324 .set_sysclk = lm49453_set_dai_sysclk, 1320 .set_sysclk = lm49453_set_dai_sysclk,
1325 .set_fmt = lm49453_set_dai_fmt, 1321 .set_fmt = lm49453_set_dai_fmt,
@@ -1460,7 +1456,6 @@ MODULE_DEVICE_TABLE(i2c, lm49453_i2c_id);
1460static struct i2c_driver lm49453_i2c_driver = { 1456static struct i2c_driver lm49453_i2c_driver = {
1461 .driver = { 1457 .driver = {
1462 .name = "lm49453", 1458 .name = "lm49453",
1463 .owner = THIS_MODULE,
1464 }, 1459 },
1465 .probe = lm49453_i2c_probe, 1460 .probe = lm49453_i2c_probe,
1466 .remove = lm49453_i2c_remove, 1461 .remove = lm49453_i2c_remove,
diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c
index e1c196a41930..bd41128c6f0b 100644
--- a/sound/soc/codecs/max9768.c
+++ b/sound/soc/codecs/max9768.c
@@ -35,7 +35,7 @@ struct max9768 {
35 u32 flags; 35 u32 flags;
36}; 36};
37 37
38static struct reg_default max9768_default_regs[] = { 38static const struct reg_default max9768_default_regs[] = {
39 { 0, 0 }, 39 { 0, 0 },
40 { 3, MAX9768_CTRL_FILTERLESS}, 40 { 3, MAX9768_CTRL_FILTERLESS},
41}; 41};
@@ -43,8 +43,8 @@ static struct reg_default max9768_default_regs[] = {
43static int max9768_get_gpio(struct snd_kcontrol *kcontrol, 43static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
44 struct snd_ctl_elem_value *ucontrol) 44 struct snd_ctl_elem_value *ucontrol)
45{ 45{
46 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 46 struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
47 struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); 47 struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
48 int val = gpio_get_value_cansleep(max9768->mute_gpio); 48 int val = gpio_get_value_cansleep(max9768->mute_gpio);
49 49
50 ucontrol->value.integer.value[0] = !val; 50 ucontrol->value.integer.value[0] = !val;
@@ -55,8 +55,8 @@ static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
55static int max9768_set_gpio(struct snd_kcontrol *kcontrol, 55static int max9768_set_gpio(struct snd_kcontrol *kcontrol,
56 struct snd_ctl_elem_value *ucontrol) 56 struct snd_ctl_elem_value *ucontrol)
57{ 57{
58 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 58 struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
59 struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); 59 struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
60 60
61 gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]); 61 gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]);
62 62
@@ -130,19 +130,20 @@ static const struct snd_soc_dapm_route max9768_dapm_routes[] = {
130 { "OUT-", NULL, "IN" }, 130 { "OUT-", NULL, "IN" },
131}; 131};
132 132
133static int max9768_probe(struct snd_soc_codec *codec) 133static int max9768_probe(struct snd_soc_component *component)
134{ 134{
135 struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); 135 struct max9768 *max9768 = snd_soc_component_get_drvdata(component);
136 int ret; 136 int ret;
137 137
138 if (max9768->flags & MAX9768_FLAG_CLASSIC_PWM) { 138 if (max9768->flags & MAX9768_FLAG_CLASSIC_PWM) {
139 ret = snd_soc_write(codec, MAX9768_CTRL, MAX9768_CTRL_PWM); 139 ret = regmap_write(max9768->regmap, MAX9768_CTRL,
140 MAX9768_CTRL_PWM);
140 if (ret) 141 if (ret)
141 return ret; 142 return ret;
142 } 143 }
143 144
144 if (gpio_is_valid(max9768->mute_gpio)) { 145 if (gpio_is_valid(max9768->mute_gpio)) {
145 ret = snd_soc_add_codec_controls(codec, max9768_mute, 146 ret = snd_soc_add_component_controls(component, max9768_mute,
146 ARRAY_SIZE(max9768_mute)); 147 ARRAY_SIZE(max9768_mute));
147 if (ret) 148 if (ret)
148 return ret; 149 return ret;
@@ -151,7 +152,7 @@ static int max9768_probe(struct snd_soc_codec *codec)
151 return 0; 152 return 0;
152} 153}
153 154
154static struct snd_soc_codec_driver max9768_codec_driver = { 155static struct snd_soc_component_driver max9768_component_driver = {
155 .probe = max9768_probe, 156 .probe = max9768_probe,
156 .controls = max9768_volume, 157 .controls = max9768_volume,
157 .num_controls = ARRAY_SIZE(max9768_volume), 158 .num_controls = ARRAY_SIZE(max9768_volume),
@@ -183,11 +184,13 @@ static int max9768_i2c_probe(struct i2c_client *client,
183 184
184 if (pdata) { 185 if (pdata) {
185 /* Mute on powerup to avoid clicks */ 186 /* Mute on powerup to avoid clicks */
186 err = gpio_request_one(pdata->mute_gpio, GPIOF_INIT_HIGH, "MAX9768 Mute"); 187 err = devm_gpio_request_one(&client->dev, pdata->mute_gpio,
188 GPIOF_INIT_HIGH, "MAX9768 Mute");
187 max9768->mute_gpio = err ?: pdata->mute_gpio; 189 max9768->mute_gpio = err ?: pdata->mute_gpio;
188 190
189 /* Activate chip by releasing shutdown, enables I2C */ 191 /* Activate chip by releasing shutdown, enables I2C */
190 err = gpio_request_one(pdata->shdn_gpio, GPIOF_INIT_HIGH, "MAX9768 Shutdown"); 192 err = devm_gpio_request_one(&client->dev, pdata->shdn_gpio,
193 GPIOF_INIT_HIGH, "MAX9768 Shutdown");
191 max9768->shdn_gpio = err ?: pdata->shdn_gpio; 194 max9768->shdn_gpio = err ?: pdata->shdn_gpio;
192 195
193 max9768->flags = pdata->flags; 196 max9768->flags = pdata->flags;
@@ -199,38 +202,11 @@ static int max9768_i2c_probe(struct i2c_client *client,
199 i2c_set_clientdata(client, max9768); 202 i2c_set_clientdata(client, max9768);
200 203
201 max9768->regmap = devm_regmap_init_i2c(client, &max9768_i2c_regmap_config); 204 max9768->regmap = devm_regmap_init_i2c(client, &max9768_i2c_regmap_config);
202 if (IS_ERR(max9768->regmap)) { 205 if (IS_ERR(max9768->regmap))
203 err = PTR_ERR(max9768->regmap); 206 return PTR_ERR(max9768->regmap);
204 goto err_gpio_free;
205 }
206
207 err = snd_soc_register_codec(&client->dev, &max9768_codec_driver, NULL, 0);
208 if (err)
209 goto err_gpio_free;
210
211 return 0;
212
213 err_gpio_free:
214 if (gpio_is_valid(max9768->shdn_gpio))
215 gpio_free(max9768->shdn_gpio);
216 if (gpio_is_valid(max9768->mute_gpio))
217 gpio_free(max9768->mute_gpio);
218
219 return err;
220}
221
222static int max9768_i2c_remove(struct i2c_client *client)
223{
224 struct max9768 *max9768 = i2c_get_clientdata(client);
225 207
226 snd_soc_unregister_codec(&client->dev); 208 return devm_snd_soc_register_component(&client->dev,
227 209 &max9768_component_driver, NULL, 0);
228 if (gpio_is_valid(max9768->shdn_gpio))
229 gpio_free(max9768->shdn_gpio);
230 if (gpio_is_valid(max9768->mute_gpio))
231 gpio_free(max9768->mute_gpio);
232
233 return 0;
234} 210}
235 211
236static const struct i2c_device_id max9768_i2c_id[] = { 212static const struct i2c_device_id max9768_i2c_id[] = {
@@ -242,10 +218,8 @@ MODULE_DEVICE_TABLE(i2c, max9768_i2c_id);
242static struct i2c_driver max9768_i2c_driver = { 218static struct i2c_driver max9768_i2c_driver = {
243 .driver = { 219 .driver = {
244 .name = "max9768", 220 .name = "max9768",
245 .owner = THIS_MODULE,
246 }, 221 },
247 .probe = max9768_i2c_probe, 222 .probe = max9768_i2c_probe,
248 .remove = max9768_i2c_remove,
249 .id_table = max9768_i2c_id, 223 .id_table = max9768_i2c_id,
250}; 224};
251module_i2c_driver(max9768_i2c_driver); 225module_i2c_driver(max9768_i2c_driver);
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index d0f45348bfbb..2c2df1790fd3 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -258,292 +258,36 @@ static const struct reg_default max98088_reg[] = {
258 { 0xc9, 0x00 }, /* C9 DAI2 biquad */ 258 { 0xc9, 0x00 }, /* C9 DAI2 biquad */
259}; 259};
260 260
261static struct {
262 int readable;
263 int writable;
264 int vol;
265} max98088_access[M98088_REG_CNT] = {
266 { 0xFF, 0xFF, 1 }, /* 00 IRQ status */
267 { 0xFF, 0x00, 1 }, /* 01 MIC status */
268 { 0xFF, 0x00, 1 }, /* 02 jack status */
269 { 0x1F, 0x1F, 1 }, /* 03 battery voltage */
270 { 0xFF, 0xFF, 0 }, /* 04 */
271 { 0xFF, 0xFF, 0 }, /* 05 */
272 { 0xFF, 0xFF, 0 }, /* 06 */
273 { 0xFF, 0xFF, 0 }, /* 07 */
274 { 0xFF, 0xFF, 0 }, /* 08 */
275 { 0xFF, 0xFF, 0 }, /* 09 */
276 { 0xFF, 0xFF, 0 }, /* 0A */
277 { 0xFF, 0xFF, 0 }, /* 0B */
278 { 0xFF, 0xFF, 0 }, /* 0C */
279 { 0xFF, 0xFF, 0 }, /* 0D */
280 { 0xFF, 0xFF, 0 }, /* 0E */
281 { 0xFF, 0xFF, 0 }, /* 0F interrupt enable */
282
283 { 0xFF, 0xFF, 0 }, /* 10 master clock */
284 { 0xFF, 0xFF, 0 }, /* 11 DAI1 clock mode */
285 { 0xFF, 0xFF, 0 }, /* 12 DAI1 clock control */
286 { 0xFF, 0xFF, 0 }, /* 13 DAI1 clock control */
287 { 0xFF, 0xFF, 0 }, /* 14 DAI1 format */
288 { 0xFF, 0xFF, 0 }, /* 15 DAI1 clock */
289 { 0xFF, 0xFF, 0 }, /* 16 DAI1 config */
290 { 0xFF, 0xFF, 0 }, /* 17 DAI1 TDM */
291 { 0xFF, 0xFF, 0 }, /* 18 DAI1 filters */
292 { 0xFF, 0xFF, 0 }, /* 19 DAI2 clock mode */
293 { 0xFF, 0xFF, 0 }, /* 1A DAI2 clock control */
294 { 0xFF, 0xFF, 0 }, /* 1B DAI2 clock control */
295 { 0xFF, 0xFF, 0 }, /* 1C DAI2 format */
296 { 0xFF, 0xFF, 0 }, /* 1D DAI2 clock */
297 { 0xFF, 0xFF, 0 }, /* 1E DAI2 config */
298 { 0xFF, 0xFF, 0 }, /* 1F DAI2 TDM */
299
300 { 0xFF, 0xFF, 0 }, /* 20 DAI2 filters */
301 { 0xFF, 0xFF, 0 }, /* 21 data config */
302 { 0xFF, 0xFF, 0 }, /* 22 DAC mixer */
303 { 0xFF, 0xFF, 0 }, /* 23 left ADC mixer */
304 { 0xFF, 0xFF, 0 }, /* 24 right ADC mixer */
305 { 0xFF, 0xFF, 0 }, /* 25 left HP mixer */
306 { 0xFF, 0xFF, 0 }, /* 26 right HP mixer */
307 { 0xFF, 0xFF, 0 }, /* 27 HP control */
308 { 0xFF, 0xFF, 0 }, /* 28 left REC mixer */
309 { 0xFF, 0xFF, 0 }, /* 29 right REC mixer */
310 { 0xFF, 0xFF, 0 }, /* 2A REC control */
311 { 0xFF, 0xFF, 0 }, /* 2B left SPK mixer */
312 { 0xFF, 0xFF, 0 }, /* 2C right SPK mixer */
313 { 0xFF, 0xFF, 0 }, /* 2D SPK control */
314 { 0xFF, 0xFF, 0 }, /* 2E sidetone */
315 { 0xFF, 0xFF, 0 }, /* 2F DAI1 playback level */
316
317 { 0xFF, 0xFF, 0 }, /* 30 DAI1 playback level */
318 { 0xFF, 0xFF, 0 }, /* 31 DAI2 playback level */
319 { 0xFF, 0xFF, 0 }, /* 32 DAI2 playbakc level */
320 { 0xFF, 0xFF, 0 }, /* 33 left ADC level */
321 { 0xFF, 0xFF, 0 }, /* 34 right ADC level */
322 { 0xFF, 0xFF, 0 }, /* 35 MIC1 level */
323 { 0xFF, 0xFF, 0 }, /* 36 MIC2 level */
324 { 0xFF, 0xFF, 0 }, /* 37 INA level */
325 { 0xFF, 0xFF, 0 }, /* 38 INB level */
326 { 0xFF, 0xFF, 0 }, /* 39 left HP volume */
327 { 0xFF, 0xFF, 0 }, /* 3A right HP volume */
328 { 0xFF, 0xFF, 0 }, /* 3B left REC volume */
329 { 0xFF, 0xFF, 0 }, /* 3C right REC volume */
330 { 0xFF, 0xFF, 0 }, /* 3D left SPK volume */
331 { 0xFF, 0xFF, 0 }, /* 3E right SPK volume */
332 { 0xFF, 0xFF, 0 }, /* 3F MIC config */
333
334 { 0xFF, 0xFF, 0 }, /* 40 MIC threshold */
335 { 0xFF, 0xFF, 0 }, /* 41 excursion limiter filter */
336 { 0xFF, 0xFF, 0 }, /* 42 excursion limiter threshold */
337 { 0xFF, 0xFF, 0 }, /* 43 ALC */
338 { 0xFF, 0xFF, 0 }, /* 44 power limiter threshold */
339 { 0xFF, 0xFF, 0 }, /* 45 power limiter config */
340 { 0xFF, 0xFF, 0 }, /* 46 distortion limiter config */
341 { 0xFF, 0xFF, 0 }, /* 47 audio input */
342 { 0xFF, 0xFF, 0 }, /* 48 microphone */
343 { 0xFF, 0xFF, 0 }, /* 49 level control */
344 { 0xFF, 0xFF, 0 }, /* 4A bypass switches */
345 { 0xFF, 0xFF, 0 }, /* 4B jack detect */
346 { 0xFF, 0xFF, 0 }, /* 4C input enable */
347 { 0xFF, 0xFF, 0 }, /* 4D output enable */
348 { 0xFF, 0xFF, 0 }, /* 4E bias control */
349 { 0xFF, 0xFF, 0 }, /* 4F DAC power */
350
351 { 0xFF, 0xFF, 0 }, /* 50 DAC power */
352 { 0xFF, 0xFF, 0 }, /* 51 system */
353 { 0xFF, 0xFF, 0 }, /* 52 DAI1 EQ1 */
354 { 0xFF, 0xFF, 0 }, /* 53 DAI1 EQ1 */
355 { 0xFF, 0xFF, 0 }, /* 54 DAI1 EQ1 */
356 { 0xFF, 0xFF, 0 }, /* 55 DAI1 EQ1 */
357 { 0xFF, 0xFF, 0 }, /* 56 DAI1 EQ1 */
358 { 0xFF, 0xFF, 0 }, /* 57 DAI1 EQ1 */
359 { 0xFF, 0xFF, 0 }, /* 58 DAI1 EQ1 */
360 { 0xFF, 0xFF, 0 }, /* 59 DAI1 EQ1 */
361 { 0xFF, 0xFF, 0 }, /* 5A DAI1 EQ1 */
362 { 0xFF, 0xFF, 0 }, /* 5B DAI1 EQ1 */
363 { 0xFF, 0xFF, 0 }, /* 5C DAI1 EQ2 */
364 { 0xFF, 0xFF, 0 }, /* 5D DAI1 EQ2 */
365 { 0xFF, 0xFF, 0 }, /* 5E DAI1 EQ2 */
366 { 0xFF, 0xFF, 0 }, /* 5F DAI1 EQ2 */
367
368 { 0xFF, 0xFF, 0 }, /* 60 DAI1 EQ2 */
369 { 0xFF, 0xFF, 0 }, /* 61 DAI1 EQ2 */
370 { 0xFF, 0xFF, 0 }, /* 62 DAI1 EQ2 */
371 { 0xFF, 0xFF, 0 }, /* 63 DAI1 EQ2 */
372 { 0xFF, 0xFF, 0 }, /* 64 DAI1 EQ2 */
373 { 0xFF, 0xFF, 0 }, /* 65 DAI1 EQ2 */
374 { 0xFF, 0xFF, 0 }, /* 66 DAI1 EQ3 */
375 { 0xFF, 0xFF, 0 }, /* 67 DAI1 EQ3 */
376 { 0xFF, 0xFF, 0 }, /* 68 DAI1 EQ3 */
377 { 0xFF, 0xFF, 0 }, /* 69 DAI1 EQ3 */
378 { 0xFF, 0xFF, 0 }, /* 6A DAI1 EQ3 */
379 { 0xFF, 0xFF, 0 }, /* 6B DAI1 EQ3 */
380 { 0xFF, 0xFF, 0 }, /* 6C DAI1 EQ3 */
381 { 0xFF, 0xFF, 0 }, /* 6D DAI1 EQ3 */
382 { 0xFF, 0xFF, 0 }, /* 6E DAI1 EQ3 */
383 { 0xFF, 0xFF, 0 }, /* 6F DAI1 EQ3 */
384
385 { 0xFF, 0xFF, 0 }, /* 70 DAI1 EQ4 */
386 { 0xFF, 0xFF, 0 }, /* 71 DAI1 EQ4 */
387 { 0xFF, 0xFF, 0 }, /* 72 DAI1 EQ4 */
388 { 0xFF, 0xFF, 0 }, /* 73 DAI1 EQ4 */
389 { 0xFF, 0xFF, 0 }, /* 74 DAI1 EQ4 */
390 { 0xFF, 0xFF, 0 }, /* 75 DAI1 EQ4 */
391 { 0xFF, 0xFF, 0 }, /* 76 DAI1 EQ4 */
392 { 0xFF, 0xFF, 0 }, /* 77 DAI1 EQ4 */
393 { 0xFF, 0xFF, 0 }, /* 78 DAI1 EQ4 */
394 { 0xFF, 0xFF, 0 }, /* 79 DAI1 EQ4 */
395 { 0xFF, 0xFF, 0 }, /* 7A DAI1 EQ5 */
396 { 0xFF, 0xFF, 0 }, /* 7B DAI1 EQ5 */
397 { 0xFF, 0xFF, 0 }, /* 7C DAI1 EQ5 */
398 { 0xFF, 0xFF, 0 }, /* 7D DAI1 EQ5 */
399 { 0xFF, 0xFF, 0 }, /* 7E DAI1 EQ5 */
400 { 0xFF, 0xFF, 0 }, /* 7F DAI1 EQ5 */
401
402 { 0xFF, 0xFF, 0 }, /* 80 DAI1 EQ5 */
403 { 0xFF, 0xFF, 0 }, /* 81 DAI1 EQ5 */
404 { 0xFF, 0xFF, 0 }, /* 82 DAI1 EQ5 */
405 { 0xFF, 0xFF, 0 }, /* 83 DAI1 EQ5 */
406 { 0xFF, 0xFF, 0 }, /* 84 DAI2 EQ1 */
407 { 0xFF, 0xFF, 0 }, /* 85 DAI2 EQ1 */
408 { 0xFF, 0xFF, 0 }, /* 86 DAI2 EQ1 */
409 { 0xFF, 0xFF, 0 }, /* 87 DAI2 EQ1 */
410 { 0xFF, 0xFF, 0 }, /* 88 DAI2 EQ1 */
411 { 0xFF, 0xFF, 0 }, /* 89 DAI2 EQ1 */
412 { 0xFF, 0xFF, 0 }, /* 8A DAI2 EQ1 */
413 { 0xFF, 0xFF, 0 }, /* 8B DAI2 EQ1 */
414 { 0xFF, 0xFF, 0 }, /* 8C DAI2 EQ1 */
415 { 0xFF, 0xFF, 0 }, /* 8D DAI2 EQ1 */
416 { 0xFF, 0xFF, 0 }, /* 8E DAI2 EQ2 */
417 { 0xFF, 0xFF, 0 }, /* 8F DAI2 EQ2 */
418
419 { 0xFF, 0xFF, 0 }, /* 90 DAI2 EQ2 */
420 { 0xFF, 0xFF, 0 }, /* 91 DAI2 EQ2 */
421 { 0xFF, 0xFF, 0 }, /* 92 DAI2 EQ2 */
422 { 0xFF, 0xFF, 0 }, /* 93 DAI2 EQ2 */
423 { 0xFF, 0xFF, 0 }, /* 94 DAI2 EQ2 */
424 { 0xFF, 0xFF, 0 }, /* 95 DAI2 EQ2 */
425 { 0xFF, 0xFF, 0 }, /* 96 DAI2 EQ2 */
426 { 0xFF, 0xFF, 0 }, /* 97 DAI2 EQ2 */
427 { 0xFF, 0xFF, 0 }, /* 98 DAI2 EQ3 */
428 { 0xFF, 0xFF, 0 }, /* 99 DAI2 EQ3 */
429 { 0xFF, 0xFF, 0 }, /* 9A DAI2 EQ3 */
430 { 0xFF, 0xFF, 0 }, /* 9B DAI2 EQ3 */
431 { 0xFF, 0xFF, 0 }, /* 9C DAI2 EQ3 */
432 { 0xFF, 0xFF, 0 }, /* 9D DAI2 EQ3 */
433 { 0xFF, 0xFF, 0 }, /* 9E DAI2 EQ3 */
434 { 0xFF, 0xFF, 0 }, /* 9F DAI2 EQ3 */
435
436 { 0xFF, 0xFF, 0 }, /* A0 DAI2 EQ3 */
437 { 0xFF, 0xFF, 0 }, /* A1 DAI2 EQ3 */
438 { 0xFF, 0xFF, 0 }, /* A2 DAI2 EQ4 */
439 { 0xFF, 0xFF, 0 }, /* A3 DAI2 EQ4 */
440 { 0xFF, 0xFF, 0 }, /* A4 DAI2 EQ4 */
441 { 0xFF, 0xFF, 0 }, /* A5 DAI2 EQ4 */
442 { 0xFF, 0xFF, 0 }, /* A6 DAI2 EQ4 */
443 { 0xFF, 0xFF, 0 }, /* A7 DAI2 EQ4 */
444 { 0xFF, 0xFF, 0 }, /* A8 DAI2 EQ4 */
445 { 0xFF, 0xFF, 0 }, /* A9 DAI2 EQ4 */
446 { 0xFF, 0xFF, 0 }, /* AA DAI2 EQ4 */
447 { 0xFF, 0xFF, 0 }, /* AB DAI2 EQ4 */
448 { 0xFF, 0xFF, 0 }, /* AC DAI2 EQ5 */
449 { 0xFF, 0xFF, 0 }, /* AD DAI2 EQ5 */
450 { 0xFF, 0xFF, 0 }, /* AE DAI2 EQ5 */
451 { 0xFF, 0xFF, 0 }, /* AF DAI2 EQ5 */
452
453 { 0xFF, 0xFF, 0 }, /* B0 DAI2 EQ5 */
454 { 0xFF, 0xFF, 0 }, /* B1 DAI2 EQ5 */
455 { 0xFF, 0xFF, 0 }, /* B2 DAI2 EQ5 */
456 { 0xFF, 0xFF, 0 }, /* B3 DAI2 EQ5 */
457 { 0xFF, 0xFF, 0 }, /* B4 DAI2 EQ5 */
458 { 0xFF, 0xFF, 0 }, /* B5 DAI2 EQ5 */
459 { 0xFF, 0xFF, 0 }, /* B6 DAI1 biquad */
460 { 0xFF, 0xFF, 0 }, /* B7 DAI1 biquad */
461 { 0xFF, 0xFF, 0 }, /* B8 DAI1 biquad */
462 { 0xFF, 0xFF, 0 }, /* B9 DAI1 biquad */
463 { 0xFF, 0xFF, 0 }, /* BA DAI1 biquad */
464 { 0xFF, 0xFF, 0 }, /* BB DAI1 biquad */
465 { 0xFF, 0xFF, 0 }, /* BC DAI1 biquad */
466 { 0xFF, 0xFF, 0 }, /* BD DAI1 biquad */
467 { 0xFF, 0xFF, 0 }, /* BE DAI1 biquad */
468 { 0xFF, 0xFF, 0 }, /* BF DAI1 biquad */
469
470 { 0xFF, 0xFF, 0 }, /* C0 DAI2 biquad */
471 { 0xFF, 0xFF, 0 }, /* C1 DAI2 biquad */
472 { 0xFF, 0xFF, 0 }, /* C2 DAI2 biquad */
473 { 0xFF, 0xFF, 0 }, /* C3 DAI2 biquad */
474 { 0xFF, 0xFF, 0 }, /* C4 DAI2 biquad */
475 { 0xFF, 0xFF, 0 }, /* C5 DAI2 biquad */
476 { 0xFF, 0xFF, 0 }, /* C6 DAI2 biquad */
477 { 0xFF, 0xFF, 0 }, /* C7 DAI2 biquad */
478 { 0xFF, 0xFF, 0 }, /* C8 DAI2 biquad */
479 { 0xFF, 0xFF, 0 }, /* C9 DAI2 biquad */
480 { 0x00, 0x00, 0 }, /* CA */
481 { 0x00, 0x00, 0 }, /* CB */
482 { 0x00, 0x00, 0 }, /* CC */
483 { 0x00, 0x00, 0 }, /* CD */
484 { 0x00, 0x00, 0 }, /* CE */
485 { 0x00, 0x00, 0 }, /* CF */
486
487 { 0x00, 0x00, 0 }, /* D0 */
488 { 0x00, 0x00, 0 }, /* D1 */
489 { 0x00, 0x00, 0 }, /* D2 */
490 { 0x00, 0x00, 0 }, /* D3 */
491 { 0x00, 0x00, 0 }, /* D4 */
492 { 0x00, 0x00, 0 }, /* D5 */
493 { 0x00, 0x00, 0 }, /* D6 */
494 { 0x00, 0x00, 0 }, /* D7 */
495 { 0x00, 0x00, 0 }, /* D8 */
496 { 0x00, 0x00, 0 }, /* D9 */
497 { 0x00, 0x00, 0 }, /* DA */
498 { 0x00, 0x00, 0 }, /* DB */
499 { 0x00, 0x00, 0 }, /* DC */
500 { 0x00, 0x00, 0 }, /* DD */
501 { 0x00, 0x00, 0 }, /* DE */
502 { 0x00, 0x00, 0 }, /* DF */
503
504 { 0x00, 0x00, 0 }, /* E0 */
505 { 0x00, 0x00, 0 }, /* E1 */
506 { 0x00, 0x00, 0 }, /* E2 */
507 { 0x00, 0x00, 0 }, /* E3 */
508 { 0x00, 0x00, 0 }, /* E4 */
509 { 0x00, 0x00, 0 }, /* E5 */
510 { 0x00, 0x00, 0 }, /* E6 */
511 { 0x00, 0x00, 0 }, /* E7 */
512 { 0x00, 0x00, 0 }, /* E8 */
513 { 0x00, 0x00, 0 }, /* E9 */
514 { 0x00, 0x00, 0 }, /* EA */
515 { 0x00, 0x00, 0 }, /* EB */
516 { 0x00, 0x00, 0 }, /* EC */
517 { 0x00, 0x00, 0 }, /* ED */
518 { 0x00, 0x00, 0 }, /* EE */
519 { 0x00, 0x00, 0 }, /* EF */
520
521 { 0x00, 0x00, 0 }, /* F0 */
522 { 0x00, 0x00, 0 }, /* F1 */
523 { 0x00, 0x00, 0 }, /* F2 */
524 { 0x00, 0x00, 0 }, /* F3 */
525 { 0x00, 0x00, 0 }, /* F4 */
526 { 0x00, 0x00, 0 }, /* F5 */
527 { 0x00, 0x00, 0 }, /* F6 */
528 { 0x00, 0x00, 0 }, /* F7 */
529 { 0x00, 0x00, 0 }, /* F8 */
530 { 0x00, 0x00, 0 }, /* F9 */
531 { 0x00, 0x00, 0 }, /* FA */
532 { 0x00, 0x00, 0 }, /* FB */
533 { 0x00, 0x00, 0 }, /* FC */
534 { 0x00, 0x00, 0 }, /* FD */
535 { 0x00, 0x00, 0 }, /* FE */
536 { 0xFF, 0x00, 1 }, /* FF */
537};
538
539static bool max98088_readable_register(struct device *dev, unsigned int reg) 261static bool max98088_readable_register(struct device *dev, unsigned int reg)
540{ 262{
541 return max98088_access[reg].readable; 263 switch (reg) {
264 case M98088_REG_00_IRQ_STATUS ... 0xC9:
265 case M98088_REG_FF_REV_ID:
266 return true;
267 default:
268 return false;
269 }
270}
271
272static bool max98088_writeable_register(struct device *dev, unsigned int reg)
273{
274 switch (reg) {
275 case M98088_REG_03_BATTERY_VOLTAGE ... 0xC9:
276 return true;
277 default:
278 return false;
279 }
542} 280}
543 281
544static bool max98088_volatile_register(struct device *dev, unsigned int reg) 282static bool max98088_volatile_register(struct device *dev, unsigned int reg)
545{ 283{
546 return max98088_access[reg].vol; 284 switch (reg) {
285 case M98088_REG_00_IRQ_STATUS ... M98088_REG_03_BATTERY_VOLTAGE:
286 case M98088_REG_FF_REV_ID:
287 return true;
288 default:
289 return false;
290 }
547} 291}
548 292
549static const struct regmap_config max98088_regmap = { 293static const struct regmap_config max98088_regmap = {
@@ -551,6 +295,7 @@ static const struct regmap_config max98088_regmap = {
551 .val_bits = 8, 295 .val_bits = 8,
552 296
553 .readable_reg = max98088_readable_register, 297 .readable_reg = max98088_readable_register,
298 .writeable_reg = max98088_writeable_register,
554 .volatile_reg = max98088_volatile_register, 299 .volatile_reg = max98088_volatile_register,
555 .max_register = 0xff, 300 .max_register = 0xff,
556 301
@@ -2011,7 +1756,6 @@ MODULE_DEVICE_TABLE(i2c, max98088_i2c_id);
2011static struct i2c_driver max98088_i2c_driver = { 1756static struct i2c_driver max98088_i2c_driver = {
2012 .driver = { 1757 .driver = {
2013 .name = "max98088", 1758 .name = "max98088",
2014 .owner = THIS_MODULE,
2015 }, 1759 },
2016 .probe = max98088_i2c_probe, 1760 .probe = max98088_i2c_probe,
2017 .remove = max98088_i2c_remove, 1761 .remove = max98088_i2c_remove,
diff --git a/sound/soc/codecs/max98088.h b/sound/soc/codecs/max98088.h
index be89a4f4aab8..efa39bf46742 100644
--- a/sound/soc/codecs/max98088.h
+++ b/sound/soc/codecs/max98088.h
@@ -16,7 +16,7 @@
16 */ 16 */
17#define M98088_REG_00_IRQ_STATUS 0x00 17#define M98088_REG_00_IRQ_STATUS 0x00
18#define M98088_REG_01_MIC_STATUS 0x01 18#define M98088_REG_01_MIC_STATUS 0x01
19#define M98088_REG_02_JACK_STAUS 0x02 19#define M98088_REG_02_JACK_STATUS 0x02
20#define M98088_REG_03_BATTERY_VOLTAGE 0x03 20#define M98088_REG_03_BATTERY_VOLTAGE 0x03
21#define M98088_REG_0F_IRQ_ENABLE 0x0F 21#define M98088_REG_0F_IRQ_ENABLE 0x0F
22#define M98088_REG_10_SYS_CLK 0x10 22#define M98088_REG_10_SYS_CLK 0x10
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 78268f0514e9..cdf534e7a285 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -267,75 +267,8 @@ static bool max98090_volatile_register(struct device *dev, unsigned int reg)
267static bool max98090_readable_register(struct device *dev, unsigned int reg) 267static bool max98090_readable_register(struct device *dev, unsigned int reg)
268{ 268{
269 switch (reg) { 269 switch (reg) {
270 case M98090_REG_DEVICE_STATUS: 270 case M98090_REG_DEVICE_STATUS ... M98090_REG_INTERRUPT_S:
271 case M98090_REG_JACK_STATUS: 271 case M98090_REG_LINE_INPUT_CONFIG ... 0xD1:
272 case M98090_REG_INTERRUPT_S:
273 case M98090_REG_RESERVED:
274 case M98090_REG_LINE_INPUT_CONFIG:
275 case M98090_REG_LINE_INPUT_LEVEL:
276 case M98090_REG_INPUT_MODE:
277 case M98090_REG_MIC1_INPUT_LEVEL:
278 case M98090_REG_MIC2_INPUT_LEVEL:
279 case M98090_REG_MIC_BIAS_VOLTAGE:
280 case M98090_REG_DIGITAL_MIC_ENABLE:
281 case M98090_REG_DIGITAL_MIC_CONFIG:
282 case M98090_REG_LEFT_ADC_MIXER:
283 case M98090_REG_RIGHT_ADC_MIXER:
284 case M98090_REG_LEFT_ADC_LEVEL:
285 case M98090_REG_RIGHT_ADC_LEVEL:
286 case M98090_REG_ADC_BIQUAD_LEVEL:
287 case M98090_REG_ADC_SIDETONE:
288 case M98090_REG_SYSTEM_CLOCK:
289 case M98090_REG_CLOCK_MODE:
290 case M98090_REG_CLOCK_RATIO_NI_MSB:
291 case M98090_REG_CLOCK_RATIO_NI_LSB:
292 case M98090_REG_CLOCK_RATIO_MI_MSB:
293 case M98090_REG_CLOCK_RATIO_MI_LSB:
294 case M98090_REG_MASTER_MODE:
295 case M98090_REG_INTERFACE_FORMAT:
296 case M98090_REG_TDM_CONTROL:
297 case M98090_REG_TDM_FORMAT:
298 case M98090_REG_IO_CONFIGURATION:
299 case M98090_REG_FILTER_CONFIG:
300 case M98090_REG_DAI_PLAYBACK_LEVEL:
301 case M98090_REG_DAI_PLAYBACK_LEVEL_EQ:
302 case M98090_REG_LEFT_HP_MIXER:
303 case M98090_REG_RIGHT_HP_MIXER:
304 case M98090_REG_HP_CONTROL:
305 case M98090_REG_LEFT_HP_VOLUME:
306 case M98090_REG_RIGHT_HP_VOLUME:
307 case M98090_REG_LEFT_SPK_MIXER:
308 case M98090_REG_RIGHT_SPK_MIXER:
309 case M98090_REG_SPK_CONTROL:
310 case M98090_REG_LEFT_SPK_VOLUME:
311 case M98090_REG_RIGHT_SPK_VOLUME:
312 case M98090_REG_DRC_TIMING:
313 case M98090_REG_DRC_COMPRESSOR:
314 case M98090_REG_DRC_EXPANDER:
315 case M98090_REG_DRC_GAIN:
316 case M98090_REG_RCV_LOUTL_MIXER:
317 case M98090_REG_RCV_LOUTL_CONTROL:
318 case M98090_REG_RCV_LOUTL_VOLUME:
319 case M98090_REG_LOUTR_MIXER:
320 case M98090_REG_LOUTR_CONTROL:
321 case M98090_REG_LOUTR_VOLUME:
322 case M98090_REG_JACK_DETECT:
323 case M98090_REG_INPUT_ENABLE:
324 case M98090_REG_OUTPUT_ENABLE:
325 case M98090_REG_LEVEL_CONTROL:
326 case M98090_REG_DSP_FILTER_ENABLE:
327 case M98090_REG_BIAS_CONTROL:
328 case M98090_REG_DAC_CONTROL:
329 case M98090_REG_ADC_CONTROL:
330 case M98090_REG_DEVICE_SHUTDOWN:
331 case M98090_REG_EQUALIZER_BASE ... M98090_REG_EQUALIZER_BASE + 0x68:
332 case M98090_REG_RECORD_BIQUAD_BASE ... M98090_REG_RECORD_BIQUAD_BASE + 0x0E:
333 case M98090_REG_DMIC3_VOLUME:
334 case M98090_REG_DMIC4_VOLUME:
335 case M98090_REG_DMIC34_BQ_PREATTEN:
336 case M98090_REG_RECORD_TDM_SLOT:
337 case M98090_REG_SAMPLE_RATE:
338 case M98090_REG_DMIC34_BIQUAD_BASE ... M98090_REG_DMIC34_BIQUAD_BASE + 0x0E:
339 case M98090_REG_REVISION_ID: 272 case M98090_REG_REVISION_ID:
340 return true; 273 return true;
341 default: 274 default:
@@ -850,6 +783,19 @@ static int max98090_micinput_event(struct snd_soc_dapm_widget *w,
850 return 0; 783 return 0;
851} 784}
852 785
786static int max98090_shdn_event(struct snd_soc_dapm_widget *w,
787 struct snd_kcontrol *kcontrol, int event)
788{
789 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
790 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
791
792 if (event & SND_SOC_DAPM_POST_PMU)
793 max98090->shdn_pending = true;
794
795 return 0;
796
797}
798
853static const char *mic1_mux_text[] = { "IN12", "IN56" }; 799static const char *mic1_mux_text[] = { "IN12", "IN56" };
854 800
855static SOC_ENUM_SINGLE_DECL(mic1_mux_enum, 801static SOC_ENUM_SINGLE_DECL(mic1_mux_enum,
@@ -1158,9 +1104,11 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = {
1158 SND_SOC_DAPM_SUPPLY("SDOEN", M98090_REG_IO_CONFIGURATION, 1104 SND_SOC_DAPM_SUPPLY("SDOEN", M98090_REG_IO_CONFIGURATION,
1159 M98090_SDOEN_SHIFT, 0, NULL, 0), 1105 M98090_SDOEN_SHIFT, 0, NULL, 0),
1160 SND_SOC_DAPM_SUPPLY("DMICL_ENA", M98090_REG_DIGITAL_MIC_ENABLE, 1106 SND_SOC_DAPM_SUPPLY("DMICL_ENA", M98090_REG_DIGITAL_MIC_ENABLE,
1161 M98090_DIGMICL_SHIFT, 0, NULL, 0), 1107 M98090_DIGMICL_SHIFT, 0, max98090_shdn_event,
1108 SND_SOC_DAPM_POST_PMU),
1162 SND_SOC_DAPM_SUPPLY("DMICR_ENA", M98090_REG_DIGITAL_MIC_ENABLE, 1109 SND_SOC_DAPM_SUPPLY("DMICR_ENA", M98090_REG_DIGITAL_MIC_ENABLE,
1163 M98090_DIGMICR_SHIFT, 0, NULL, 0), 1110 M98090_DIGMICR_SHIFT, 0, max98090_shdn_event,
1111 SND_SOC_DAPM_POST_PMU),
1164 SND_SOC_DAPM_SUPPLY("AHPF", M98090_REG_FILTER_CONFIG, 1112 SND_SOC_DAPM_SUPPLY("AHPF", M98090_REG_FILTER_CONFIG,
1165 M98090_AHPF_SHIFT, 0, NULL, 0), 1113 M98090_AHPF_SHIFT, 0, NULL, 0),
1166 1114
@@ -1205,10 +1153,12 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = {
1205 &max98090_right_adc_mixer_controls[0], 1153 &max98090_right_adc_mixer_controls[0],
1206 ARRAY_SIZE(max98090_right_adc_mixer_controls)), 1154 ARRAY_SIZE(max98090_right_adc_mixer_controls)),
1207 1155
1208 SND_SOC_DAPM_ADC("ADCL", NULL, M98090_REG_INPUT_ENABLE, 1156 SND_SOC_DAPM_ADC_E("ADCL", NULL, M98090_REG_INPUT_ENABLE,
1209 M98090_ADLEN_SHIFT, 0), 1157 M98090_ADLEN_SHIFT, 0, max98090_shdn_event,
1210 SND_SOC_DAPM_ADC("ADCR", NULL, M98090_REG_INPUT_ENABLE, 1158 SND_SOC_DAPM_POST_PMU),
1211 M98090_ADREN_SHIFT, 0), 1159 SND_SOC_DAPM_ADC_E("ADCR", NULL, M98090_REG_INPUT_ENABLE,
1160 M98090_ADREN_SHIFT, 0, max98090_shdn_event,
1161 SND_SOC_DAPM_POST_PMU),
1212 1162
1213 SND_SOC_DAPM_AIF_OUT("AIFOUTL", "HiFi Capture", 0, 1163 SND_SOC_DAPM_AIF_OUT("AIFOUTL", "HiFi Capture", 0,
1214 SND_SOC_NOPM, 0, 0), 1164 SND_SOC_NOPM, 0, 0),
@@ -1801,10 +1751,13 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec,
1801 if (IS_ERR(max98090->mclk)) 1751 if (IS_ERR(max98090->mclk))
1802 break; 1752 break;
1803 1753
1804 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) 1754 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) {
1805 clk_disable_unprepare(max98090->mclk); 1755 clk_disable_unprepare(max98090->mclk);
1806 else 1756 } else {
1807 clk_prepare_enable(max98090->mclk); 1757 ret = clk_prepare_enable(max98090->mclk);
1758 if (ret)
1759 return ret;
1760 }
1808 break; 1761 break;
1809 1762
1810 case SND_SOC_BIAS_STANDBY: 1763 case SND_SOC_BIAS_STANDBY:
@@ -2383,7 +2336,7 @@ EXPORT_SYMBOL_GPL(max98090_mic_detect);
2383#define MAX98090_RATES SNDRV_PCM_RATE_8000_96000 2336#define MAX98090_RATES SNDRV_PCM_RATE_8000_96000
2384#define MAX98090_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) 2337#define MAX98090_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
2385 2338
2386static struct snd_soc_dai_ops max98090_dai_ops = { 2339static const struct snd_soc_dai_ops max98090_dai_ops = {
2387 .set_sysclk = max98090_dai_set_sysclk, 2340 .set_sysclk = max98090_dai_set_sysclk,
2388 .set_fmt = max98090_dai_set_fmt, 2341 .set_fmt = max98090_dai_set_fmt,
2389 .set_tdm_slot = max98090_set_tdm_slot, 2342 .set_tdm_slot = max98090_set_tdm_slot,
@@ -2536,9 +2489,26 @@ static int max98090_remove(struct snd_soc_codec *codec)
2536 return 0; 2489 return 0;
2537} 2490}
2538 2491
2492static void max98090_seq_notifier(struct snd_soc_dapm_context *dapm,
2493 enum snd_soc_dapm_type event, int subseq)
2494{
2495 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm);
2496 struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
2497
2498 if (max98090->shdn_pending) {
2499 snd_soc_update_bits(codec, M98090_REG_DEVICE_SHUTDOWN,
2500 M98090_SHDNN_MASK, 0);
2501 msleep(40);
2502 snd_soc_update_bits(codec, M98090_REG_DEVICE_SHUTDOWN,
2503 M98090_SHDNN_MASK, M98090_SHDNN_MASK);
2504 max98090->shdn_pending = false;
2505 }
2506}
2507
2539static struct snd_soc_codec_driver soc_codec_dev_max98090 = { 2508static struct snd_soc_codec_driver soc_codec_dev_max98090 = {
2540 .probe = max98090_probe, 2509 .probe = max98090_probe,
2541 .remove = max98090_remove, 2510 .remove = max98090_remove,
2511 .seq_notifier = max98090_seq_notifier,
2542 .set_bias_level = max98090_set_bias_level, 2512 .set_bias_level = max98090_set_bias_level,
2543}; 2513};
2544 2514
@@ -2714,7 +2684,6 @@ MODULE_DEVICE_TABLE(acpi, max98090_acpi_match);
2714static struct i2c_driver max98090_i2c_driver = { 2684static struct i2c_driver max98090_i2c_driver = {
2715 .driver = { 2685 .driver = {
2716 .name = "max98090", 2686 .name = "max98090",
2717 .owner = THIS_MODULE,
2718 .pm = &max98090_pm, 2687 .pm = &max98090_pm,
2719 .of_match_table = of_match_ptr(max98090_of_match), 2688 .of_match_table = of_match_ptr(max98090_of_match),
2720 .acpi_match_table = ACPI_PTR(max98090_acpi_match), 2689 .acpi_match_table = ACPI_PTR(max98090_acpi_match),
diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h
index 21ff743f5af2..bc610d9a9ecb 100644
--- a/sound/soc/codecs/max98090.h
+++ b/sound/soc/codecs/max98090.h
@@ -1543,6 +1543,7 @@ struct max98090_priv {
1543 unsigned int pa2en; 1543 unsigned int pa2en;
1544 unsigned int sidetone; 1544 unsigned int sidetone;
1545 bool master; 1545 bool master;
1546 bool shdn_pending;
1546}; 1547};
1547 1548
1548int max98090_mic_detect(struct snd_soc_codec *codec, 1549int max98090_mic_detect(struct snd_soc_codec *codec,
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index 9a46d3dcf703..ad4909e17327 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -202,300 +202,36 @@ static const struct reg_default max98095_reg_def[] = {
202 { 0xff, 0x00 }, /* FF */ 202 { 0xff, 0x00 }, /* FF */
203}; 203};
204 204
205static struct {
206 int readable;
207 int writable;
208} max98095_access[M98095_REG_CNT] = {
209 { 0x00, 0x00 }, /* 00 */
210 { 0xFF, 0x00 }, /* 01 */
211 { 0xFF, 0x00 }, /* 02 */
212 { 0xFF, 0x00 }, /* 03 */
213 { 0xFF, 0x00 }, /* 04 */
214 { 0xFF, 0x00 }, /* 05 */
215 { 0xFF, 0x00 }, /* 06 */
216 { 0xFF, 0x00 }, /* 07 */
217 { 0xFF, 0x00 }, /* 08 */
218 { 0xFF, 0x00 }, /* 09 */
219 { 0xFF, 0x00 }, /* 0A */
220 { 0xFF, 0x00 }, /* 0B */
221 { 0xFF, 0x00 }, /* 0C */
222 { 0xFF, 0x00 }, /* 0D */
223 { 0xFF, 0x00 }, /* 0E */
224 { 0xFF, 0x9F }, /* 0F */
225 { 0xFF, 0xFF }, /* 10 */
226 { 0xFF, 0xFF }, /* 11 */
227 { 0xFF, 0xFF }, /* 12 */
228 { 0xFF, 0xFF }, /* 13 */
229 { 0xFF, 0xFF }, /* 14 */
230 { 0xFF, 0xFF }, /* 15 */
231 { 0xFF, 0xFF }, /* 16 */
232 { 0xFF, 0xFF }, /* 17 */
233 { 0xFF, 0xFF }, /* 18 */
234 { 0xFF, 0xFF }, /* 19 */
235 { 0xFF, 0xFF }, /* 1A */
236 { 0xFF, 0xFF }, /* 1B */
237 { 0xFF, 0xFF }, /* 1C */
238 { 0xFF, 0xFF }, /* 1D */
239 { 0xFF, 0x77 }, /* 1E */
240 { 0xFF, 0x77 }, /* 1F */
241 { 0xFF, 0x77 }, /* 20 */
242 { 0xFF, 0x77 }, /* 21 */
243 { 0xFF, 0x77 }, /* 22 */
244 { 0xFF, 0x77 }, /* 23 */
245 { 0xFF, 0xFF }, /* 24 */
246 { 0xFF, 0x7F }, /* 25 */
247 { 0xFF, 0x31 }, /* 26 */
248 { 0xFF, 0xFF }, /* 27 */
249 { 0xFF, 0xFF }, /* 28 */
250 { 0xFF, 0xFF }, /* 29 */
251 { 0xFF, 0xF7 }, /* 2A */
252 { 0xFF, 0x2F }, /* 2B */
253 { 0xFF, 0xEF }, /* 2C */
254 { 0xFF, 0xFF }, /* 2D */
255 { 0xFF, 0xFF }, /* 2E */
256 { 0xFF, 0xFF }, /* 2F */
257 { 0xFF, 0xFF }, /* 30 */
258 { 0xFF, 0xFF }, /* 31 */
259 { 0xFF, 0xFF }, /* 32 */
260 { 0xFF, 0xFF }, /* 33 */
261 { 0xFF, 0xF7 }, /* 34 */
262 { 0xFF, 0x2F }, /* 35 */
263 { 0xFF, 0xCF }, /* 36 */
264 { 0xFF, 0xFF }, /* 37 */
265 { 0xFF, 0xFF }, /* 38 */
266 { 0xFF, 0xFF }, /* 39 */
267 { 0xFF, 0xFF }, /* 3A */
268 { 0xFF, 0xFF }, /* 3B */
269 { 0xFF, 0xFF }, /* 3C */
270 { 0xFF, 0xFF }, /* 3D */
271 { 0xFF, 0xF7 }, /* 3E */
272 { 0xFF, 0x2F }, /* 3F */
273 { 0xFF, 0xCF }, /* 40 */
274 { 0xFF, 0xFF }, /* 41 */
275 { 0xFF, 0x77 }, /* 42 */
276 { 0xFF, 0xFF }, /* 43 */
277 { 0xFF, 0xFF }, /* 44 */
278 { 0xFF, 0xFF }, /* 45 */
279 { 0xFF, 0xFF }, /* 46 */
280 { 0xFF, 0xFF }, /* 47 */
281 { 0xFF, 0xFF }, /* 48 */
282 { 0xFF, 0x0F }, /* 49 */
283 { 0xFF, 0xFF }, /* 4A */
284 { 0xFF, 0xFF }, /* 4B */
285 { 0xFF, 0x3F }, /* 4C */
286 { 0xFF, 0x3F }, /* 4D */
287 { 0xFF, 0x3F }, /* 4E */
288 { 0xFF, 0xFF }, /* 4F */
289 { 0xFF, 0x7F }, /* 50 */
290 { 0xFF, 0x7F }, /* 51 */
291 { 0xFF, 0x0F }, /* 52 */
292 { 0xFF, 0x3F }, /* 53 */
293 { 0xFF, 0x3F }, /* 54 */
294 { 0xFF, 0x3F }, /* 55 */
295 { 0xFF, 0xFF }, /* 56 */
296 { 0xFF, 0xFF }, /* 57 */
297 { 0xFF, 0xBF }, /* 58 */
298 { 0xFF, 0x1F }, /* 59 */
299 { 0xFF, 0xBF }, /* 5A */
300 { 0xFF, 0x1F }, /* 5B */
301 { 0xFF, 0xBF }, /* 5C */
302 { 0xFF, 0x3F }, /* 5D */
303 { 0xFF, 0x3F }, /* 5E */
304 { 0xFF, 0x7F }, /* 5F */
305 { 0xFF, 0x7F }, /* 60 */
306 { 0xFF, 0x47 }, /* 61 */
307 { 0xFF, 0x9F }, /* 62 */
308 { 0xFF, 0x9F }, /* 63 */
309 { 0xFF, 0x9F }, /* 64 */
310 { 0xFF, 0x9F }, /* 65 */
311 { 0xFF, 0x9F }, /* 66 */
312 { 0xFF, 0xBF }, /* 67 */
313 { 0xFF, 0xBF }, /* 68 */
314 { 0xFF, 0xFF }, /* 69 */
315 { 0xFF, 0xFF }, /* 6A */
316 { 0xFF, 0x7F }, /* 6B */
317 { 0xFF, 0xF7 }, /* 6C */
318 { 0xFF, 0xFF }, /* 6D */
319 { 0xFF, 0xFF }, /* 6E */
320 { 0xFF, 0x1F }, /* 6F */
321 { 0xFF, 0xF7 }, /* 70 */
322 { 0xFF, 0xFF }, /* 71 */
323 { 0xFF, 0xFF }, /* 72 */
324 { 0xFF, 0x1F }, /* 73 */
325 { 0xFF, 0xF7 }, /* 74 */
326 { 0xFF, 0xFF }, /* 75 */
327 { 0xFF, 0xFF }, /* 76 */
328 { 0xFF, 0x1F }, /* 77 */
329 { 0xFF, 0xF7 }, /* 78 */
330 { 0xFF, 0xFF }, /* 79 */
331 { 0xFF, 0xFF }, /* 7A */
332 { 0xFF, 0x1F }, /* 7B */
333 { 0xFF, 0xF7 }, /* 7C */
334 { 0xFF, 0xFF }, /* 7D */
335 { 0xFF, 0xFF }, /* 7E */
336 { 0xFF, 0x1F }, /* 7F */
337 { 0xFF, 0xF7 }, /* 80 */
338 { 0xFF, 0xFF }, /* 81 */
339 { 0xFF, 0xFF }, /* 82 */
340 { 0xFF, 0x1F }, /* 83 */
341 { 0xFF, 0x7F }, /* 84 */
342 { 0xFF, 0x0F }, /* 85 */
343 { 0xFF, 0xD8 }, /* 86 */
344 { 0xFF, 0xFF }, /* 87 */
345 { 0xFF, 0xEF }, /* 88 */
346 { 0xFF, 0xFE }, /* 89 */
347 { 0xFF, 0xFE }, /* 8A */
348 { 0xFF, 0xFF }, /* 8B */
349 { 0xFF, 0xFF }, /* 8C */
350 { 0xFF, 0x3F }, /* 8D */
351 { 0xFF, 0xFF }, /* 8E */
352 { 0xFF, 0x3F }, /* 8F */
353 { 0xFF, 0x8F }, /* 90 */
354 { 0xFF, 0xFF }, /* 91 */
355 { 0xFF, 0x3F }, /* 92 */
356 { 0xFF, 0xFF }, /* 93 */
357 { 0xFF, 0xFF }, /* 94 */
358 { 0xFF, 0x0F }, /* 95 */
359 { 0xFF, 0x3F }, /* 96 */
360 { 0xFF, 0x8C }, /* 97 */
361 { 0x00, 0x00 }, /* 98 */
362 { 0x00, 0x00 }, /* 99 */
363 { 0x00, 0x00 }, /* 9A */
364 { 0x00, 0x00 }, /* 9B */
365 { 0x00, 0x00 }, /* 9C */
366 { 0x00, 0x00 }, /* 9D */
367 { 0x00, 0x00 }, /* 9E */
368 { 0x00, 0x00 }, /* 9F */
369 { 0x00, 0x00 }, /* A0 */
370 { 0x00, 0x00 }, /* A1 */
371 { 0x00, 0x00 }, /* A2 */
372 { 0x00, 0x00 }, /* A3 */
373 { 0x00, 0x00 }, /* A4 */
374 { 0x00, 0x00 }, /* A5 */
375 { 0x00, 0x00 }, /* A6 */
376 { 0x00, 0x00 }, /* A7 */
377 { 0x00, 0x00 }, /* A8 */
378 { 0x00, 0x00 }, /* A9 */
379 { 0x00, 0x00 }, /* AA */
380 { 0x00, 0x00 }, /* AB */
381 { 0x00, 0x00 }, /* AC */
382 { 0x00, 0x00 }, /* AD */
383 { 0x00, 0x00 }, /* AE */
384 { 0x00, 0x00 }, /* AF */
385 { 0x00, 0x00 }, /* B0 */
386 { 0x00, 0x00 }, /* B1 */
387 { 0x00, 0x00 }, /* B2 */
388 { 0x00, 0x00 }, /* B3 */
389 { 0x00, 0x00 }, /* B4 */
390 { 0x00, 0x00 }, /* B5 */
391 { 0x00, 0x00 }, /* B6 */
392 { 0x00, 0x00 }, /* B7 */
393 { 0x00, 0x00 }, /* B8 */
394 { 0x00, 0x00 }, /* B9 */
395 { 0x00, 0x00 }, /* BA */
396 { 0x00, 0x00 }, /* BB */
397 { 0x00, 0x00 }, /* BC */
398 { 0x00, 0x00 }, /* BD */
399 { 0x00, 0x00 }, /* BE */
400 { 0x00, 0x00 }, /* BF */
401 { 0x00, 0x00 }, /* C0 */
402 { 0x00, 0x00 }, /* C1 */
403 { 0x00, 0x00 }, /* C2 */
404 { 0x00, 0x00 }, /* C3 */
405 { 0x00, 0x00 }, /* C4 */
406 { 0x00, 0x00 }, /* C5 */
407 { 0x00, 0x00 }, /* C6 */
408 { 0x00, 0x00 }, /* C7 */
409 { 0x00, 0x00 }, /* C8 */
410 { 0x00, 0x00 }, /* C9 */
411 { 0x00, 0x00 }, /* CA */
412 { 0x00, 0x00 }, /* CB */
413 { 0x00, 0x00 }, /* CC */
414 { 0x00, 0x00 }, /* CD */
415 { 0x00, 0x00 }, /* CE */
416 { 0x00, 0x00 }, /* CF */
417 { 0x00, 0x00 }, /* D0 */
418 { 0x00, 0x00 }, /* D1 */
419 { 0x00, 0x00 }, /* D2 */
420 { 0x00, 0x00 }, /* D3 */
421 { 0x00, 0x00 }, /* D4 */
422 { 0x00, 0x00 }, /* D5 */
423 { 0x00, 0x00 }, /* D6 */
424 { 0x00, 0x00 }, /* D7 */
425 { 0x00, 0x00 }, /* D8 */
426 { 0x00, 0x00 }, /* D9 */
427 { 0x00, 0x00 }, /* DA */
428 { 0x00, 0x00 }, /* DB */
429 { 0x00, 0x00 }, /* DC */
430 { 0x00, 0x00 }, /* DD */
431 { 0x00, 0x00 }, /* DE */
432 { 0x00, 0x00 }, /* DF */
433 { 0x00, 0x00 }, /* E0 */
434 { 0x00, 0x00 }, /* E1 */
435 { 0x00, 0x00 }, /* E2 */
436 { 0x00, 0x00 }, /* E3 */
437 { 0x00, 0x00 }, /* E4 */
438 { 0x00, 0x00 }, /* E5 */
439 { 0x00, 0x00 }, /* E6 */
440 { 0x00, 0x00 }, /* E7 */
441 { 0x00, 0x00 }, /* E8 */
442 { 0x00, 0x00 }, /* E9 */
443 { 0x00, 0x00 }, /* EA */
444 { 0x00, 0x00 }, /* EB */
445 { 0x00, 0x00 }, /* EC */
446 { 0x00, 0x00 }, /* ED */
447 { 0x00, 0x00 }, /* EE */
448 { 0x00, 0x00 }, /* EF */
449 { 0x00, 0x00 }, /* F0 */
450 { 0x00, 0x00 }, /* F1 */
451 { 0x00, 0x00 }, /* F2 */
452 { 0x00, 0x00 }, /* F3 */
453 { 0x00, 0x00 }, /* F4 */
454 { 0x00, 0x00 }, /* F5 */
455 { 0x00, 0x00 }, /* F6 */
456 { 0x00, 0x00 }, /* F7 */
457 { 0x00, 0x00 }, /* F8 */
458 { 0x00, 0x00 }, /* F9 */
459 { 0x00, 0x00 }, /* FA */
460 { 0x00, 0x00 }, /* FB */
461 { 0x00, 0x00 }, /* FC */
462 { 0x00, 0x00 }, /* FD */
463 { 0x00, 0x00 }, /* FE */
464 { 0xFF, 0x00 }, /* FF */
465};
466
467static bool max98095_readable(struct device *dev, unsigned int reg) 205static bool max98095_readable(struct device *dev, unsigned int reg)
468{ 206{
469 if (reg >= M98095_REG_CNT) 207 switch (reg) {
470 return 0; 208 case M98095_001_HOST_INT_STS ... M98095_097_PWR_SYS:
471 return max98095_access[reg].readable != 0; 209 case M98095_0FF_REV_ID:
210 return true;
211 default:
212 return false;
213 }
472} 214}
473 215
474static bool max98095_volatile(struct device *dev, unsigned int reg) 216static bool max98095_writeable(struct device *dev, unsigned int reg)
475{ 217{
476 if (reg > M98095_REG_MAX_CACHED)
477 return 1;
478
479 switch (reg) { 218 switch (reg) {
480 case M98095_000_HOST_DATA: 219 case M98095_00F_HOST_CFG ... M98095_097_PWR_SYS:
481 case M98095_001_HOST_INT_STS: 220 return true;
482 case M98095_002_HOST_RSP_STS: 221 default:
483 case M98095_003_HOST_CMD_STS: 222 return false;
484 case M98095_004_CODEC_STS:
485 case M98095_005_DAI1_ALC_STS:
486 case M98095_006_DAI2_ALC_STS:
487 case M98095_007_JACK_AUTO_STS:
488 case M98095_008_JACK_MANUAL_STS:
489 case M98095_009_JACK_VBAT_STS:
490 case M98095_00A_ACC_ADC_STS:
491 case M98095_00B_MIC_NG_AGC_STS:
492 case M98095_00C_SPK_L_VOLT_STS:
493 case M98095_00D_SPK_R_VOLT_STS:
494 case M98095_00E_TEMP_SENSOR_STS:
495 return 1;
496 } 223 }
224}
497 225
498 return 0; 226static bool max98095_volatile(struct device *dev, unsigned int reg)
227{
228 switch (reg) {
229 case M98095_000_HOST_DATA ... M98095_00E_TEMP_SENSOR_STS:
230 case M98095_REG_MAX_CACHED + 1 ... M98095_0FF_REV_ID:
231 return true;
232 default:
233 return false;
234 }
499} 235}
500 236
501static const struct regmap_config max98095_regmap = { 237static const struct regmap_config max98095_regmap = {
@@ -508,6 +244,7 @@ static const struct regmap_config max98095_regmap = {
508 .cache_type = REGCACHE_RBTREE, 244 .cache_type = REGCACHE_RBTREE,
509 245
510 .readable_reg = max98095_readable, 246 .readable_reg = max98095_readable,
247 .writeable_reg = max98095_writeable,
511 .volatile_reg = max98095_volatile, 248 .volatile_reg = max98095_volatile,
512}; 249};
513 250
@@ -1653,10 +1390,13 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec,
1653 if (IS_ERR(max98095->mclk)) 1390 if (IS_ERR(max98095->mclk))
1654 break; 1391 break;
1655 1392
1656 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) 1393 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) {
1657 clk_disable_unprepare(max98095->mclk); 1394 clk_disable_unprepare(max98095->mclk);
1658 else 1395 } else {
1659 clk_prepare_enable(max98095->mclk); 1396 ret = clk_prepare_enable(max98095->mclk);
1397 if (ret)
1398 return ret;
1399 }
1660 break; 1400 break;
1661 1401
1662 case SND_SOC_BIAS_STANDBY: 1402 case SND_SOC_BIAS_STANDBY:
@@ -2431,7 +2171,6 @@ MODULE_DEVICE_TABLE(of, max98095_of_match);
2431static struct i2c_driver max98095_i2c_driver = { 2171static struct i2c_driver max98095_i2c_driver = {
2432 .driver = { 2172 .driver = {
2433 .name = "max98095", 2173 .name = "max98095",
2434 .owner = THIS_MODULE,
2435 .of_match_table = of_match_ptr(max98095_of_match), 2174 .of_match_table = of_match_ptr(max98095_of_match),
2436 }, 2175 },
2437 .probe = max98095_i2c_probe, 2176 .probe = max98095_i2c_probe,
diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c
index 3a2fda08a893..f5e3dce2633a 100644
--- a/sound/soc/codecs/max98357a.c
+++ b/sound/soc/codecs/max98357a.c
@@ -31,6 +31,9 @@ static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
31{ 31{
32 struct gpio_desc *sdmode = snd_soc_dai_get_drvdata(dai); 32 struct gpio_desc *sdmode = snd_soc_dai_get_drvdata(dai);
33 33
34 if (!sdmode)
35 return 0;
36
34 switch (cmd) { 37 switch (cmd) {
35 case SNDRV_PCM_TRIGGER_START: 38 case SNDRV_PCM_TRIGGER_START:
36 case SNDRV_PCM_TRIGGER_RESUME: 39 case SNDRV_PCM_TRIGGER_RESUME:
@@ -48,24 +51,21 @@ static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
48} 51}
49 52
50static const struct snd_soc_dapm_widget max98357a_dapm_widgets[] = { 53static const struct snd_soc_dapm_widget max98357a_dapm_widgets[] = {
51 SND_SOC_DAPM_DAC("SDMode", NULL, SND_SOC_NOPM, 0, 0),
52 SND_SOC_DAPM_OUTPUT("Speaker"), 54 SND_SOC_DAPM_OUTPUT("Speaker"),
53}; 55};
54 56
55static const struct snd_soc_dapm_route max98357a_dapm_routes[] = { 57static const struct snd_soc_dapm_route max98357a_dapm_routes[] = {
56 {"Speaker", NULL, "SDMode"}, 58 {"Speaker", NULL, "HiFi Playback"},
57}; 59};
58 60
59static int max98357a_codec_probe(struct snd_soc_codec *codec) 61static int max98357a_codec_probe(struct snd_soc_codec *codec)
60{ 62{
61 struct gpio_desc *sdmode; 63 struct gpio_desc *sdmode;
62 64
63 sdmode = devm_gpiod_get(codec->dev, "sdmode", GPIOD_OUT_LOW); 65 sdmode = devm_gpiod_get_optional(codec->dev, "sdmode", GPIOD_OUT_LOW);
64 if (IS_ERR(sdmode)) { 66 if (IS_ERR(sdmode))
65 dev_err(codec->dev, "%s() unable to get sdmode GPIO: %ld\n",
66 __func__, PTR_ERR(sdmode));
67 return PTR_ERR(sdmode); 67 return PTR_ERR(sdmode);
68 } 68
69 snd_soc_codec_set_drvdata(codec, sdmode); 69 snd_soc_codec_set_drvdata(codec, sdmode);
70 70
71 return 0; 71 return 0;
@@ -79,7 +79,7 @@ static struct snd_soc_codec_driver max98357a_codec_driver = {
79 .num_dapm_routes = ARRAY_SIZE(max98357a_dapm_routes), 79 .num_dapm_routes = ARRAY_SIZE(max98357a_dapm_routes),
80}; 80};
81 81
82static struct snd_soc_dai_ops max98357a_dai_ops = { 82static const struct snd_soc_dai_ops max98357a_dai_ops = {
83 .trigger = max98357a_daiops_trigger, 83 .trigger = max98357a_daiops_trigger,
84}; 84};
85 85
@@ -104,15 +104,8 @@ static struct snd_soc_dai_driver max98357a_dai_driver = {
104 104
105static int max98357a_platform_probe(struct platform_device *pdev) 105static int max98357a_platform_probe(struct platform_device *pdev)
106{ 106{
107 int ret; 107 return snd_soc_register_codec(&pdev->dev, &max98357a_codec_driver,
108
109 ret = snd_soc_register_codec(&pdev->dev, &max98357a_codec_driver,
110 &max98357a_dai_driver, 1); 108 &max98357a_dai_driver, 1);
111 if (ret)
112 dev_err(&pdev->dev, "%s() error registering codec driver: %d\n",
113 __func__, ret);
114
115 return ret;
116} 109}
117 110
118static int max98357a_platform_remove(struct platform_device *pdev) 111static int max98357a_platform_remove(struct platform_device *pdev)
diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c
index 481d58f1cb3f..7c990521638c 100644
--- a/sound/soc/codecs/max9850.c
+++ b/sound/soc/codecs/max9850.c
@@ -352,7 +352,6 @@ MODULE_DEVICE_TABLE(i2c, max9850_i2c_id);
352static struct i2c_driver max9850_i2c_driver = { 352static struct i2c_driver max9850_i2c_driver = {
353 .driver = { 353 .driver = {
354 .name = "max9850", 354 .name = "max9850",
355 .owner = THIS_MODULE,
356 }, 355 },
357 .probe = max9850_i2c_probe, 356 .probe = max9850_i2c_probe,
358 .remove = max9850_i2c_remove, 357 .remove = max9850_i2c_remove,
diff --git a/sound/soc/codecs/max9877.c b/sound/soc/codecs/max9877.c
index 29549cdbf4c1..fb448dde018d 100644
--- a/sound/soc/codecs/max9877.c
+++ b/sound/soc/codecs/max9877.c
@@ -20,9 +20,7 @@
20 20
21#include "max9877.h" 21#include "max9877.h"
22 22
23static struct regmap *regmap; 23static const struct reg_default max9877_regs[] = {
24
25static struct reg_default max9877_regs[] = {
26 { 0, 0x40 }, 24 { 0, 0x40 },
27 { 1, 0x00 }, 25 { 1, 0x00 },
28 { 2, 0x00 }, 26 { 2, 0x00 },
@@ -123,7 +121,7 @@ static const struct snd_soc_dapm_route max9877_dapm_routes[] = {
123 { "HPR", NULL, "SHDN" }, 121 { "HPR", NULL, "SHDN" },
124}; 122};
125 123
126static const struct snd_soc_codec_driver max9877_codec = { 124static const struct snd_soc_component_driver max9877_component_driver = {
127 .controls = max9877_controls, 125 .controls = max9877_controls,
128 .num_controls = ARRAY_SIZE(max9877_controls), 126 .num_controls = ARRAY_SIZE(max9877_controls),
129 127
@@ -145,6 +143,7 @@ static const struct regmap_config max9877_regmap = {
145static int max9877_i2c_probe(struct i2c_client *client, 143static int max9877_i2c_probe(struct i2c_client *client,
146 const struct i2c_device_id *id) 144 const struct i2c_device_id *id)
147{ 145{
146 struct regmap *regmap;
148 int i; 147 int i;
149 148
150 regmap = devm_regmap_init_i2c(client, &max9877_regmap); 149 regmap = devm_regmap_init_i2c(client, &max9877_regmap);
@@ -155,14 +154,8 @@ static int max9877_i2c_probe(struct i2c_client *client,
155 for (i = 0; i < ARRAY_SIZE(max9877_regs); i++) 154 for (i = 0; i < ARRAY_SIZE(max9877_regs); i++)
156 regmap_write(regmap, max9877_regs[i].reg, max9877_regs[i].def); 155 regmap_write(regmap, max9877_regs[i].reg, max9877_regs[i].def);
157 156
158 return snd_soc_register_codec(&client->dev, &max9877_codec, NULL, 0); 157 return devm_snd_soc_register_component(&client->dev,
159} 158 &max9877_component_driver, NULL, 0);
160
161static int max9877_i2c_remove(struct i2c_client *client)
162{
163 snd_soc_unregister_codec(&client->dev);
164
165 return 0;
166} 159}
167 160
168static const struct i2c_device_id max9877_i2c_id[] = { 161static const struct i2c_device_id max9877_i2c_id[] = {
@@ -174,10 +167,8 @@ MODULE_DEVICE_TABLE(i2c, max9877_i2c_id);
174static struct i2c_driver max9877_i2c_driver = { 167static struct i2c_driver max9877_i2c_driver = {
175 .driver = { 168 .driver = {
176 .name = "max9877", 169 .name = "max9877",
177 .owner = THIS_MODULE,
178 }, 170 },
179 .probe = max9877_i2c_probe, 171 .probe = max9877_i2c_probe,
180 .remove = max9877_i2c_remove,
181 .id_table = max9877_i2c_id, 172 .id_table = max9877_i2c_id,
182}; 173};
183 174
diff --git a/sound/soc/codecs/max98925.c b/sound/soc/codecs/max98925.c
index aad664225dc3..ebb648aea8c6 100644
--- a/sound/soc/codecs/max98925.c
+++ b/sound/soc/codecs/max98925.c
@@ -271,8 +271,6 @@ static inline int max98925_rate_value(struct snd_soc_codec *codec,
271 break; 271 break;
272 } 272 }
273 } 273 }
274 dev_dbg(codec->dev, "%s: sample rate is %d, returning %d\n",
275 __func__, rate_table[i].rate, *value);
276 return ret; 274 return ret;
277} 275}
278 276
@@ -523,7 +521,6 @@ static int max98925_probe(struct snd_soc_codec *codec)
523 struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); 521 struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec);
524 522
525 max98925->codec = codec; 523 max98925->codec = codec;
526 codec->control_data = max98925->regmap;
527 regmap_write(max98925->regmap, MAX98925_GLOBAL_ENABLE, 0x00); 524 regmap_write(max98925->regmap, MAX98925_GLOBAL_ENABLE, 0x00);
528 /* It's not the default but we need to set DAI_DLY */ 525 /* It's not the default but we need to set DAI_DLY */
529 regmap_write(max98925->regmap, 526 regmap_write(max98925->regmap,
@@ -639,7 +636,6 @@ MODULE_DEVICE_TABLE(of, max98925_of_match);
639static struct i2c_driver max98925_i2c_driver = { 636static struct i2c_driver max98925_i2c_driver = {
640 .driver = { 637 .driver = {
641 .name = "max98925", 638 .name = "max98925",
642 .owner = THIS_MODULE,
643 .of_match_table = of_match_ptr(max98925_of_match), 639 .of_match_table = of_match_ptr(max98925_of_match),
644 .pm = NULL, 640 .pm = NULL,
645 }, 641 },
diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c
index 3d44fc50e4d0..3e770cbe7f0f 100644
--- a/sound/soc/codecs/mc13783.c
+++ b/sound/soc/codecs/mc13783.c
@@ -650,14 +650,14 @@ static int mc13783_remove(struct snd_soc_codec *codec)
650#define MC13783_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 650#define MC13783_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
651 SNDRV_PCM_FMTBIT_S24_LE) 651 SNDRV_PCM_FMTBIT_S24_LE)
652 652
653static struct snd_soc_dai_ops mc13783_ops_dac = { 653static const struct snd_soc_dai_ops mc13783_ops_dac = {
654 .hw_params = mc13783_pcm_hw_params_dac, 654 .hw_params = mc13783_pcm_hw_params_dac,
655 .set_fmt = mc13783_set_fmt_async, 655 .set_fmt = mc13783_set_fmt_async,
656 .set_sysclk = mc13783_set_sysclk_dac, 656 .set_sysclk = mc13783_set_sysclk_dac,
657 .set_tdm_slot = mc13783_set_tdm_slot_dac, 657 .set_tdm_slot = mc13783_set_tdm_slot_dac,
658}; 658};
659 659
660static struct snd_soc_dai_ops mc13783_ops_codec = { 660static const struct snd_soc_dai_ops mc13783_ops_codec = {
661 .hw_params = mc13783_pcm_hw_params_codec, 661 .hw_params = mc13783_pcm_hw_params_codec,
662 .set_fmt = mc13783_set_fmt_async, 662 .set_fmt = mc13783_set_fmt_async,
663 .set_sysclk = mc13783_set_sysclk_codec, 663 .set_sysclk = mc13783_set_sysclk_codec,
@@ -698,7 +698,7 @@ static struct snd_soc_dai_driver mc13783_dai_async[] = {
698 }, 698 },
699}; 699};
700 700
701static struct snd_soc_dai_ops mc13783_ops_sync = { 701static const struct snd_soc_dai_ops mc13783_ops_sync = {
702 .hw_params = mc13783_pcm_hw_params_sync, 702 .hw_params = mc13783_pcm_hw_params_sync,
703 .set_fmt = mc13783_set_fmt_sync, 703 .set_fmt = mc13783_set_fmt_sync,
704 .set_sysclk = mc13783_set_sysclk_sync, 704 .set_sysclk = mc13783_set_sysclk_sync,
diff --git a/sound/soc/codecs/ml26124.c b/sound/soc/codecs/ml26124.c
index b74118e019fb..f561c78b9e0e 100644
--- a/sound/soc/codecs/ml26124.c
+++ b/sound/soc/codecs/ml26124.c
@@ -199,7 +199,7 @@ static const struct clk_coeff coeff_div[] = {
199 {12288000, 48000, 0xc, 0x0, 0x30, 0x0, 0x4}, 199 {12288000, 48000, 0xc, 0x0, 0x30, 0x0, 0x4},
200}; 200};
201 201
202static struct reg_default ml26124_reg[] = { 202static const struct reg_default ml26124_reg[] = {
203 /* CLOCK control Register */ 203 /* CLOCK control Register */
204 {0x00, 0x00 }, /* Sampling Rate */ 204 {0x00, 0x00 }, /* Sampling Rate */
205 {0x02, 0x00}, /* PLL NL */ 205 {0x02, 0x00}, /* PLL NL */
@@ -597,7 +597,6 @@ MODULE_DEVICE_TABLE(i2c, ml26124_i2c_id);
597static struct i2c_driver ml26124_i2c_driver = { 597static struct i2c_driver ml26124_i2c_driver = {
598 .driver = { 598 .driver = {
599 .name = "ml26124", 599 .name = "ml26124",
600 .owner = THIS_MODULE,
601 }, 600 },
602 .probe = ml26124_i2c_probe, 601 .probe = ml26124_i2c_probe,
603 .remove = ml26124_i2c_remove, 602 .remove = ml26124_i2c_remove,
diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c
index 477e13d30971..58325234285c 100644
--- a/sound/soc/codecs/pcm1681.c
+++ b/sound/soc/codecs/pcm1681.c
@@ -95,17 +95,22 @@ static int pcm1681_set_deemph(struct snd_soc_codec *codec)
95 struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); 95 struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec);
96 int i = 0, val = -1, enable = 0; 96 int i = 0, val = -1, enable = 0;
97 97
98 if (priv->deemph) 98 if (priv->deemph) {
99 for (i = 0; i < ARRAY_SIZE(pcm1681_deemph); i++) 99 for (i = 0; i < ARRAY_SIZE(pcm1681_deemph); i++) {
100 if (pcm1681_deemph[i] == priv->rate) 100 if (pcm1681_deemph[i] == priv->rate) {
101 val = i; 101 val = i;
102 break;
103 }
104 }
105 }
102 106
103 if (val != -1) { 107 if (val != -1) {
104 regmap_update_bits(priv->regmap, PCM1681_DEEMPH_CONTROL, 108 regmap_update_bits(priv->regmap, PCM1681_DEEMPH_CONTROL,
105 PCM1681_DEEMPH_RATE_MASK, val); 109 PCM1681_DEEMPH_RATE_MASK, val << 3);
106 enable = 1; 110 enable = 1;
107 } else 111 } else {
108 enable = 0; 112 enable = 0;
113 }
109 114
110 /* enable/disable deemphasis functionality */ 115 /* enable/disable deemphasis functionality */
111 return regmap_update_bits(priv->regmap, PCM1681_DEEMPH_CONTROL, 116 return regmap_update_bits(priv->regmap, PCM1681_DEEMPH_CONTROL,
@@ -330,7 +335,6 @@ static int pcm1681_i2c_remove(struct i2c_client *client)
330static struct i2c_driver pcm1681_i2c_driver = { 335static struct i2c_driver pcm1681_i2c_driver = {
331 .driver = { 336 .driver = {
332 .name = "pcm1681", 337 .name = "pcm1681",
333 .owner = THIS_MODULE,
334 .of_match_table = of_match_ptr(pcm1681_dt_ids), 338 .of_match_table = of_match_ptr(pcm1681_dt_ids),
335 }, 339 },
336 .id_table = pcm1681_i2c_id, 340 .id_table = pcm1681_i2c_id,
diff --git a/sound/soc/codecs/pcm512x-i2c.c b/sound/soc/codecs/pcm512x-i2c.c
index dcdfac0ffeb1..dbff416e38be 100644
--- a/sound/soc/codecs/pcm512x-i2c.c
+++ b/sound/soc/codecs/pcm512x-i2c.c
@@ -67,7 +67,6 @@ static struct i2c_driver pcm512x_i2c_driver = {
67 .id_table = pcm512x_i2c_id, 67 .id_table = pcm512x_i2c_id,
68 .driver = { 68 .driver = {
69 .name = "pcm512x", 69 .name = "pcm512x",
70 .owner = THIS_MODULE,
71 .of_match_table = pcm512x_of_match, 70 .of_match_table = pcm512x_of_match,
72 .pm = &pcm512x_pm_ops, 71 .pm = &pcm512x_pm_ops,
73 }, 72 },
diff --git a/sound/soc/codecs/rl6231.c b/sound/soc/codecs/rl6231.c
index 56650d6c2f53..aca479fa7670 100644
--- a/sound/soc/codecs/rl6231.c
+++ b/sound/soc/codecs/rl6231.c
@@ -11,38 +11,98 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/regmap.h>
14 15
15#include "rl6231.h" 16#include "rl6231.h"
16 17
17/** 18/**
18 * rl6231_calc_dmic_clk - Calculate the parameter of dmic. 19 * rl6231_get_pre_div - Return the value of pre divider.
20 *
21 * @map: map for setting.
22 * @reg: register.
23 * @sft: shift.
24 *
25 * Return the value of pre divider from given register value.
26 * Return negative error code for unexpected register value.
27 */
28int rl6231_get_pre_div(struct regmap *map, unsigned int reg, int sft)
29{
30 int pd, val;
31
32 regmap_read(map, reg, &val);
33
34 val = (val >> sft) & 0x7;
35
36 switch (val) {
37 case 0:
38 case 1:
39 case 2:
40 case 3:
41 pd = val + 1;
42 break;
43 case 4:
44 pd = 6;
45 break;
46 case 5:
47 pd = 8;
48 break;
49 case 6:
50 pd = 12;
51 break;
52 case 7:
53 pd = 16;
54 break;
55 default:
56 pd = -EINVAL;
57 break;
58 }
59
60 return pd;
61}
62EXPORT_SYMBOL_GPL(rl6231_get_pre_div);
63
64/**
65 * rl6231_calc_dmic_clk - Calculate the frequency divider parameter of dmic.
19 * 66 *
20 * @rate: base clock rate. 67 * @rate: base clock rate.
21 * 68 *
22 * Choose dmic clock between 1MHz and 3MHz. 69 * Choose divider parameter that gives the highest possible DMIC frequency in
23 * It is better for clock to approximate 3MHz. 70 * 1MHz - 3MHz range.
24 */ 71 */
25int rl6231_calc_dmic_clk(int rate) 72int rl6231_calc_dmic_clk(int rate)
26{ 73{
27 int div[] = {2, 3, 4, 6, 8, 12}, idx = -EINVAL; 74 int div[] = {2, 3, 4, 6, 8, 12};
28 int i, red, bound, temp; 75 int i;
76
77 if (rate < 1000000 * div[0]) {
78 pr_warn("Base clock rate %d is too low\n", rate);
79 return -EINVAL;
80 }
29 81
30 red = 3000000 * 12;
31 for (i = 0; i < ARRAY_SIZE(div); i++) { 82 for (i = 0; i < ARRAY_SIZE(div); i++) {
32 bound = div[i] * 3000000; 83 /* find divider that gives DMIC frequency below 3MHz */
33 if (rate > bound) 84 if (3000000 * div[i] >= rate)
34 continue; 85 return i;
35 temp = bound - rate;
36 if (temp < red) {
37 red = temp;
38 idx = i;
39 }
40 } 86 }
41 87
42 return idx; 88 pr_warn("Base clock rate %d is too high\n", rate);
89 return -EINVAL;
43} 90}
44EXPORT_SYMBOL_GPL(rl6231_calc_dmic_clk); 91EXPORT_SYMBOL_GPL(rl6231_calc_dmic_clk);
45 92
93struct pll_calc_map {
94 unsigned int pll_in;
95 unsigned int pll_out;
96 int k;
97 int n;
98 int m;
99 bool m_bp;
100};
101
102static const struct pll_calc_map pll_preset_table[] = {
103 {19200000, 24576000, 3, 30, 3, false},
104};
105
46/** 106/**
47 * rl6231_pll_calc - Calcualte PLL M/N/K code. 107 * rl6231_pll_calc - Calcualte PLL M/N/K code.
48 * @freq_in: external clock provided to codec. 108 * @freq_in: external clock provided to codec.
@@ -57,7 +117,7 @@ int rl6231_pll_calc(const unsigned int freq_in,
57 const unsigned int freq_out, struct rl6231_pll_code *pll_code) 117 const unsigned int freq_out, struct rl6231_pll_code *pll_code)
58{ 118{
59 int max_n = RL6231_PLL_N_MAX, max_m = RL6231_PLL_M_MAX; 119 int max_n = RL6231_PLL_N_MAX, max_m = RL6231_PLL_M_MAX;
60 int k, red, n_t, pll_out, in_t, out_t; 120 int i, k, red, n_t, pll_out, in_t, out_t;
61 int n = 0, m = 0, m_t = 0; 121 int n = 0, m = 0, m_t = 0;
62 int red_t = abs(freq_out - freq_in); 122 int red_t = abs(freq_out - freq_in);
63 bool bypass = false; 123 bool bypass = false;
@@ -65,6 +125,18 @@ int rl6231_pll_calc(const unsigned int freq_in,
65 if (RL6231_PLL_INP_MAX < freq_in || RL6231_PLL_INP_MIN > freq_in) 125 if (RL6231_PLL_INP_MAX < freq_in || RL6231_PLL_INP_MIN > freq_in)
66 return -EINVAL; 126 return -EINVAL;
67 127
128 for (i = 0; i < ARRAY_SIZE(pll_preset_table); i++) {
129 if (freq_in == pll_preset_table[i].pll_in &&
130 freq_out == pll_preset_table[i].pll_out) {
131 k = pll_preset_table[i].k;
132 m = pll_preset_table[i].m;
133 n = pll_preset_table[i].n;
134 bypass = pll_preset_table[i].m_bp;
135 pr_debug("Use preset PLL parameter table\n");
136 goto code_find;
137 }
138 }
139
68 k = 100000000 / freq_out - 2; 140 k = 100000000 / freq_out - 2;
69 if (k > RL6231_PLL_K_MAX) 141 if (k > RL6231_PLL_K_MAX)
70 k = RL6231_PLL_K_MAX; 142 k = RL6231_PLL_K_MAX;
diff --git a/sound/soc/codecs/rl6231.h b/sound/soc/codecs/rl6231.h
index 0f7b057ed736..4c77b441fba2 100644
--- a/sound/soc/codecs/rl6231.h
+++ b/sound/soc/codecs/rl6231.h
@@ -30,5 +30,6 @@ int rl6231_calc_dmic_clk(int rate);
30int rl6231_pll_calc(const unsigned int freq_in, 30int rl6231_pll_calc(const unsigned int freq_in,
31 const unsigned int freq_out, struct rl6231_pll_code *pll_code); 31 const unsigned int freq_out, struct rl6231_pll_code *pll_code);
32int rl6231_get_clk_info(int sclk, int rate); 32int rl6231_get_clk_info(int sclk, int rate);
33int rl6231_get_pre_div(struct regmap *map, unsigned int reg, int sft);
33 34
34#endif /* __RL6231_H__ */ 35#endif /* __RL6231_H__ */
diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index 5c43e263b2c1..bd9365885f73 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -38,7 +38,7 @@
38#define RT288_VENDOR_ID 0x10ec0288 38#define RT288_VENDOR_ID 0x10ec0288
39 39
40struct rt286_priv { 40struct rt286_priv {
41 struct reg_default *index_cache; 41 const struct reg_default *index_cache;
42 int index_cache_size; 42 int index_cache_size;
43 struct regmap *regmap; 43 struct regmap *regmap;
44 struct snd_soc_codec *codec; 44 struct snd_soc_codec *codec;
@@ -50,7 +50,7 @@ struct rt286_priv {
50 int clk_id; 50 int clk_id;
51}; 51};
52 52
53static struct reg_default rt286_index_def[] = { 53static const struct reg_default rt286_index_def[] = {
54 { 0x01, 0xaaaa }, 54 { 0x01, 0xaaaa },
55 { 0x02, 0x8aaa }, 55 { 0x02, 0x8aaa },
56 { 0x03, 0x0002 }, 56 { 0x03, 0x0002 },
@@ -1108,7 +1108,7 @@ static const struct acpi_device_id rt286_acpi_match[] = {
1108}; 1108};
1109MODULE_DEVICE_TABLE(acpi, rt286_acpi_match); 1109MODULE_DEVICE_TABLE(acpi, rt286_acpi_match);
1110 1110
1111static struct dmi_system_id force_combo_jack_table[] = { 1111static const struct dmi_system_id force_combo_jack_table[] = {
1112 { 1112 {
1113 .ident = "Intel Wilson Beach", 1113 .ident = "Intel Wilson Beach",
1114 .matches = { 1114 .matches = {
@@ -1118,7 +1118,7 @@ static struct dmi_system_id force_combo_jack_table[] = {
1118 { } 1118 { }
1119}; 1119};
1120 1120
1121static struct dmi_system_id dmi_dell_dino[] = { 1121static const struct dmi_system_id dmi_dell_dino[] = {
1122 { 1122 {
1123 .ident = "Dell Dino", 1123 .ident = "Dell Dino",
1124 .matches = { 1124 .matches = {
@@ -1157,7 +1157,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
1157 } 1157 }
1158 if (val != RT286_VENDOR_ID && val != RT288_VENDOR_ID) { 1158 if (val != RT286_VENDOR_ID && val != RT288_VENDOR_ID) {
1159 dev_err(&i2c->dev, 1159 dev_err(&i2c->dev,
1160 "Device with ID register %x is not rt286\n", val); 1160 "Device with ID register %#x is not rt286\n", val);
1161 return -ENODEV; 1161 return -ENODEV;
1162 } 1162 }
1163 1163
@@ -1259,7 +1259,6 @@ static int rt286_i2c_remove(struct i2c_client *i2c)
1259static struct i2c_driver rt286_i2c_driver = { 1259static struct i2c_driver rt286_i2c_driver = {
1260 .driver = { 1260 .driver = {
1261 .name = "rt286", 1261 .name = "rt286",
1262 .owner = THIS_MODULE,
1263 .acpi_match_table = ACPI_PTR(rt286_acpi_match), 1262 .acpi_match_table = ACPI_PTR(rt286_acpi_match),
1264 }, 1263 },
1265 .probe = rt286_i2c_probe, 1264 .probe = rt286_i2c_probe,
diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c
new file mode 100644
index 000000000000..3c2f0f8d6266
--- /dev/null
+++ b/sound/soc/codecs/rt298.c
@@ -0,0 +1,1271 @@
1/*
2 * rt298.c -- RT298 ALSA SoC audio codec driver
3 *
4 * Copyright 2015 Realtek Semiconductor Corp.
5 * Author: Bard Liao <bardliao@realtek.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#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/init.h>
15#include <linux/delay.h>
16#include <linux/pm.h>
17#include <linux/i2c.h>
18#include <linux/platform_device.h>
19#include <linux/spi/spi.h>
20#include <linux/acpi.h>
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/pcm_params.h>
24#include <sound/soc.h>
25#include <sound/soc-dapm.h>
26#include <sound/initval.h>
27#include <sound/tlv.h>
28#include <sound/jack.h>
29#include <linux/workqueue.h>
30#include <sound/rt298.h>
31#include <sound/hda_verbs.h>
32
33#include "rl6347a.h"
34#include "rt298.h"
35
36#define RT298_VENDOR_ID 0x10ec0298
37
38struct rt298_priv {
39 struct reg_default *index_cache;
40 int index_cache_size;
41 struct regmap *regmap;
42 struct snd_soc_codec *codec;
43 struct rt298_platform_data pdata;
44 struct i2c_client *i2c;
45 struct snd_soc_jack *jack;
46 struct delayed_work jack_detect_work;
47 int sys_clk;
48 int clk_id;
49 int is_hp_in;
50};
51
52static struct reg_default rt298_index_def[] = {
53 { 0x01, 0xaaaa },
54 { 0x02, 0x8aaa },
55 { 0x03, 0x0002 },
56 { 0x04, 0xaf01 },
57 { 0x08, 0x000d },
58 { 0x09, 0xd810 },
59 { 0x0a, 0x0120 },
60 { 0x0b, 0x0000 },
61 { 0x0d, 0x2800 },
62 { 0x0f, 0x0000 },
63 { 0x19, 0x0a17 },
64 { 0x20, 0x0020 },
65 { 0x33, 0x0208 },
66 { 0x46, 0x0300 },
67 { 0x49, 0x0004 },
68 { 0x4f, 0x50e9 },
69 { 0x50, 0x2000 },
70 { 0x63, 0x2902 },
71 { 0x67, 0x1111 },
72 { 0x68, 0x1016 },
73 { 0x69, 0x273f },
74};
75#define INDEX_CACHE_SIZE ARRAY_SIZE(rt298_index_def)
76
77static const struct reg_default rt298_reg[] = {
78 { 0x00170500, 0x00000400 },
79 { 0x00220000, 0x00000031 },
80 { 0x00239000, 0x0000007f },
81 { 0x0023a000, 0x0000007f },
82 { 0x00270500, 0x00000400 },
83 { 0x00370500, 0x00000400 },
84 { 0x00870500, 0x00000400 },
85 { 0x00920000, 0x00000031 },
86 { 0x00935000, 0x000000c3 },
87 { 0x00936000, 0x000000c3 },
88 { 0x00970500, 0x00000400 },
89 { 0x00b37000, 0x00000097 },
90 { 0x00b37200, 0x00000097 },
91 { 0x00b37300, 0x00000097 },
92 { 0x00c37000, 0x00000000 },
93 { 0x00c37100, 0x00000080 },
94 { 0x01270500, 0x00000400 },
95 { 0x01370500, 0x00000400 },
96 { 0x01371f00, 0x411111f0 },
97 { 0x01439000, 0x00000080 },
98 { 0x0143a000, 0x00000080 },
99 { 0x01470700, 0x00000000 },
100 { 0x01470500, 0x00000400 },
101 { 0x01470c00, 0x00000000 },
102 { 0x01470100, 0x00000000 },
103 { 0x01837000, 0x00000000 },
104 { 0x01870500, 0x00000400 },
105 { 0x02050000, 0x00000000 },
106 { 0x02139000, 0x00000080 },
107 { 0x0213a000, 0x00000080 },
108 { 0x02170100, 0x00000000 },
109 { 0x02170500, 0x00000400 },
110 { 0x02170700, 0x00000000 },
111 { 0x02270100, 0x00000000 },
112 { 0x02370100, 0x00000000 },
113 { 0x01870700, 0x00000020 },
114 { 0x00830000, 0x000000c3 },
115 { 0x00930000, 0x000000c3 },
116 { 0x01270700, 0x00000000 },
117};
118
119static bool rt298_volatile_register(struct device *dev, unsigned int reg)
120{
121 switch (reg) {
122 case 0 ... 0xff:
123 case RT298_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID):
124 case RT298_GET_HP_SENSE:
125 case RT298_GET_MIC1_SENSE:
126 case RT298_PROC_COEF:
127 case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT298_MIC1, 0):
128 case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT298_SPK_OUT, 0):
129 case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT298_HP_OUT, 0):
130 return true;
131 default:
132 return true;
133 }
134
135
136}
137
138static bool rt298_readable_register(struct device *dev, unsigned int reg)
139{
140 switch (reg) {
141 case 0 ... 0xff:
142 case RT298_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID):
143 case RT298_GET_HP_SENSE:
144 case RT298_GET_MIC1_SENSE:
145 case RT298_SET_AUDIO_POWER:
146 case RT298_SET_HPO_POWER:
147 case RT298_SET_SPK_POWER:
148 case RT298_SET_DMIC1_POWER:
149 case RT298_SPK_MUX:
150 case RT298_HPO_MUX:
151 case RT298_ADC0_MUX:
152 case RT298_ADC1_MUX:
153 case RT298_SET_MIC1:
154 case RT298_SET_PIN_HPO:
155 case RT298_SET_PIN_SPK:
156 case RT298_SET_PIN_DMIC1:
157 case RT298_SPK_EAPD:
158 case RT298_SET_AMP_GAIN_HPO:
159 case RT298_SET_DMIC2_DEFAULT:
160 case RT298_DACL_GAIN:
161 case RT298_DACR_GAIN:
162 case RT298_ADCL_GAIN:
163 case RT298_ADCR_GAIN:
164 case RT298_MIC_GAIN:
165 case RT298_SPOL_GAIN:
166 case RT298_SPOR_GAIN:
167 case RT298_HPOL_GAIN:
168 case RT298_HPOR_GAIN:
169 case RT298_F_DAC_SWITCH:
170 case RT298_F_RECMIX_SWITCH:
171 case RT298_REC_MIC_SWITCH:
172 case RT298_REC_I2S_SWITCH:
173 case RT298_REC_LINE_SWITCH:
174 case RT298_REC_BEEP_SWITCH:
175 case RT298_DAC_FORMAT:
176 case RT298_ADC_FORMAT:
177 case RT298_COEF_INDEX:
178 case RT298_PROC_COEF:
179 case RT298_SET_AMP_GAIN_ADC_IN1:
180 case RT298_SET_AMP_GAIN_ADC_IN2:
181 case RT298_SET_POWER(RT298_DAC_OUT1):
182 case RT298_SET_POWER(RT298_DAC_OUT2):
183 case RT298_SET_POWER(RT298_ADC_IN1):
184 case RT298_SET_POWER(RT298_ADC_IN2):
185 case RT298_SET_POWER(RT298_DMIC2):
186 case RT298_SET_POWER(RT298_MIC1):
187 case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT298_MIC1, 0):
188 case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT298_SPK_OUT, 0):
189 case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT298_HP_OUT, 0):
190 return true;
191 default:
192 return false;
193 }
194}
195
196#ifdef CONFIG_PM
197static void rt298_index_sync(struct snd_soc_codec *codec)
198{
199 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
200 int i;
201
202 for (i = 0; i < INDEX_CACHE_SIZE; i++) {
203 snd_soc_write(codec, rt298->index_cache[i].reg,
204 rt298->index_cache[i].def);
205 }
206}
207#endif
208
209static int rt298_support_power_controls[] = {
210 RT298_DAC_OUT1,
211 RT298_DAC_OUT2,
212 RT298_ADC_IN1,
213 RT298_ADC_IN2,
214 RT298_MIC1,
215 RT298_DMIC1,
216 RT298_DMIC2,
217 RT298_SPK_OUT,
218 RT298_HP_OUT,
219};
220#define RT298_POWER_REG_LEN ARRAY_SIZE(rt298_support_power_controls)
221
222static int rt298_jack_detect(struct rt298_priv *rt298, bool *hp, bool *mic)
223{
224 struct snd_soc_dapm_context *dapm;
225 unsigned int val, buf;
226
227 *hp = false;
228 *mic = false;
229
230 if (!rt298->codec)
231 return -EINVAL;
232
233 dapm = snd_soc_codec_get_dapm(rt298->codec);
234
235 if (rt298->pdata.cbj_en) {
236 regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf);
237 *hp = buf & 0x80000000;
238 if (*hp == rt298->is_hp_in)
239 return -1;
240 rt298->is_hp_in = *hp;
241 if (*hp) {
242 /* power on HV,VERF */
243 regmap_update_bits(rt298->regmap,
244 RT298_DC_GAIN, 0x200, 0x200);
245
246 snd_soc_dapm_force_enable_pin(dapm, "HV");
247 snd_soc_dapm_force_enable_pin(dapm, "VREF");
248 /* power LDO1 */
249 snd_soc_dapm_force_enable_pin(dapm, "LDO1");
250 snd_soc_dapm_sync(dapm);
251
252 regmap_write(rt298->regmap, RT298_SET_MIC1, 0x24);
253 msleep(50);
254
255 regmap_update_bits(rt298->regmap,
256 RT298_CBJ_CTRL1, 0xfcc0, 0xd400);
257 msleep(300);
258 regmap_read(rt298->regmap, RT298_CBJ_CTRL2, &val);
259
260 if (0x0070 == (val & 0x0070)) {
261 *mic = true;
262 } else {
263 regmap_update_bits(rt298->regmap,
264 RT298_CBJ_CTRL1, 0xfcc0, 0xe400);
265 msleep(300);
266 regmap_read(rt298->regmap,
267 RT298_CBJ_CTRL2, &val);
268 if (0x0070 == (val & 0x0070))
269 *mic = true;
270 else
271 *mic = false;
272 }
273 regmap_update_bits(rt298->regmap,
274 RT298_DC_GAIN, 0x200, 0x0);
275
276 } else {
277 *mic = false;
278 regmap_write(rt298->regmap, RT298_SET_MIC1, 0x20);
279 }
280 } else {
281 regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf);
282 *hp = buf & 0x80000000;
283 regmap_read(rt298->regmap, RT298_GET_MIC1_SENSE, &buf);
284 *mic = buf & 0x80000000;
285 }
286
287 snd_soc_dapm_disable_pin(dapm, "HV");
288 snd_soc_dapm_disable_pin(dapm, "VREF");
289 if (!*hp)
290 snd_soc_dapm_disable_pin(dapm, "LDO1");
291 snd_soc_dapm_sync(dapm);
292
293 pr_debug("*hp = %d *mic = %d\n", *hp, *mic);
294
295 return 0;
296}
297
298static void rt298_jack_detect_work(struct work_struct *work)
299{
300 struct rt298_priv *rt298 =
301 container_of(work, struct rt298_priv, jack_detect_work.work);
302 int status = 0;
303 bool hp = false;
304 bool mic = false;
305
306 if (rt298_jack_detect(rt298, &hp, &mic) < 0)
307 return;
308
309 if (hp == true)
310 status |= SND_JACK_HEADPHONE;
311
312 if (mic == true)
313 status |= SND_JACK_MICROPHONE;
314
315 snd_soc_jack_report(rt298->jack, status,
316 SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
317}
318
319int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
320{
321 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
322
323 rt298->jack = jack;
324
325 /* Send an initial empty report */
326 snd_soc_jack_report(rt298->jack, 0,
327 SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
328
329 return 0;
330}
331EXPORT_SYMBOL_GPL(rt298_mic_detect);
332
333static int is_mclk_mode(struct snd_soc_dapm_widget *source,
334 struct snd_soc_dapm_widget *sink)
335{
336 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
337 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
338
339 if (rt298->clk_id == RT298_SCLK_S_MCLK)
340 return 1;
341 else
342 return 0;
343}
344
345static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6350, 50, 0);
346static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0);
347
348static const struct snd_kcontrol_new rt298_snd_controls[] = {
349 SOC_DOUBLE_R_TLV("DAC0 Playback Volume", RT298_DACL_GAIN,
350 RT298_DACR_GAIN, 0, 0x7f, 0, out_vol_tlv),
351 SOC_DOUBLE_R_TLV("ADC0 Capture Volume", RT298_ADCL_GAIN,
352 RT298_ADCR_GAIN, 0, 0x7f, 0, out_vol_tlv),
353 SOC_SINGLE_TLV("AMIC Volume", RT298_MIC_GAIN,
354 0, 0x3, 0, mic_vol_tlv),
355 SOC_DOUBLE_R("Speaker Playback Switch", RT298_SPOL_GAIN,
356 RT298_SPOR_GAIN, RT298_MUTE_SFT, 1, 1),
357};
358
359/* Digital Mixer */
360static const struct snd_kcontrol_new rt298_front_mix[] = {
361 SOC_DAPM_SINGLE("DAC Switch", RT298_F_DAC_SWITCH,
362 RT298_MUTE_SFT, 1, 1),
363 SOC_DAPM_SINGLE("RECMIX Switch", RT298_F_RECMIX_SWITCH,
364 RT298_MUTE_SFT, 1, 1),
365};
366
367/* Analog Input Mixer */
368static const struct snd_kcontrol_new rt298_rec_mix[] = {
369 SOC_DAPM_SINGLE("Mic1 Switch", RT298_REC_MIC_SWITCH,
370 RT298_MUTE_SFT, 1, 1),
371 SOC_DAPM_SINGLE("I2S Switch", RT298_REC_I2S_SWITCH,
372 RT298_MUTE_SFT, 1, 1),
373 SOC_DAPM_SINGLE("Line1 Switch", RT298_REC_LINE_SWITCH,
374 RT298_MUTE_SFT, 1, 1),
375 SOC_DAPM_SINGLE("Beep Switch", RT298_REC_BEEP_SWITCH,
376 RT298_MUTE_SFT, 1, 1),
377};
378
379static const struct snd_kcontrol_new spo_enable_control =
380 SOC_DAPM_SINGLE("Switch", RT298_SET_PIN_SPK,
381 RT298_SET_PIN_SFT, 1, 0);
382
383static const struct snd_kcontrol_new hpol_enable_control =
384 SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT298_HPOL_GAIN,
385 RT298_MUTE_SFT, 1, 1);
386
387static const struct snd_kcontrol_new hpor_enable_control =
388 SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT298_HPOR_GAIN,
389 RT298_MUTE_SFT, 1, 1);
390
391/* ADC0 source */
392static const char * const rt298_adc_src[] = {
393 "Mic", "RECMIX", "Dmic"
394};
395
396static const int rt298_adc_values[] = {
397 0, 4, 5,
398};
399
400static SOC_VALUE_ENUM_SINGLE_DECL(
401 rt298_adc0_enum, RT298_ADC0_MUX, RT298_ADC_SEL_SFT,
402 RT298_ADC_SEL_MASK, rt298_adc_src, rt298_adc_values);
403
404static const struct snd_kcontrol_new rt298_adc0_mux =
405 SOC_DAPM_ENUM("ADC 0 source", rt298_adc0_enum);
406
407static SOC_VALUE_ENUM_SINGLE_DECL(
408 rt298_adc1_enum, RT298_ADC1_MUX, RT298_ADC_SEL_SFT,
409 RT298_ADC_SEL_MASK, rt298_adc_src, rt298_adc_values);
410
411static const struct snd_kcontrol_new rt298_adc1_mux =
412 SOC_DAPM_ENUM("ADC 1 source", rt298_adc1_enum);
413
414static const char * const rt298_dac_src[] = {
415 "Front", "Surround"
416};
417/* HP-OUT source */
418static SOC_ENUM_SINGLE_DECL(rt298_hpo_enum, RT298_HPO_MUX,
419 0, rt298_dac_src);
420
421static const struct snd_kcontrol_new rt298_hpo_mux =
422SOC_DAPM_ENUM("HPO source", rt298_hpo_enum);
423
424/* SPK-OUT source */
425static SOC_ENUM_SINGLE_DECL(rt298_spo_enum, RT298_SPK_MUX,
426 0, rt298_dac_src);
427
428static const struct snd_kcontrol_new rt298_spo_mux =
429SOC_DAPM_ENUM("SPO source", rt298_spo_enum);
430
431static int rt298_spk_event(struct snd_soc_dapm_widget *w,
432 struct snd_kcontrol *kcontrol, int event)
433{
434 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
435
436 switch (event) {
437 case SND_SOC_DAPM_POST_PMU:
438 snd_soc_write(codec,
439 RT298_SPK_EAPD, RT298_SET_EAPD_HIGH);
440 break;
441 case SND_SOC_DAPM_PRE_PMD:
442 snd_soc_write(codec,
443 RT298_SPK_EAPD, RT298_SET_EAPD_LOW);
444 break;
445
446 default:
447 return 0;
448 }
449
450 return 0;
451}
452
453static int rt298_set_dmic1_event(struct snd_soc_dapm_widget *w,
454 struct snd_kcontrol *kcontrol, int event)
455{
456 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
457
458 switch (event) {
459 case SND_SOC_DAPM_POST_PMU:
460 snd_soc_write(codec, RT298_SET_PIN_DMIC1, 0x20);
461 break;
462 case SND_SOC_DAPM_PRE_PMD:
463 snd_soc_write(codec, RT298_SET_PIN_DMIC1, 0);
464 break;
465 default:
466 return 0;
467 }
468
469 return 0;
470}
471
472static int rt298_adc_event(struct snd_soc_dapm_widget *w,
473 struct snd_kcontrol *kcontrol, int event)
474{
475 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
476 unsigned int nid;
477
478 nid = (w->reg >> 20) & 0xff;
479
480 switch (event) {
481 case SND_SOC_DAPM_POST_PMU:
482 snd_soc_update_bits(codec,
483 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0),
484 0x7080, 0x7000);
485 break;
486 case SND_SOC_DAPM_PRE_PMD:
487 snd_soc_update_bits(codec,
488 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0),
489 0x7080, 0x7080);
490 break;
491 default:
492 return 0;
493 }
494
495 return 0;
496}
497
498static int rt298_mic1_event(struct snd_soc_dapm_widget *w,
499 struct snd_kcontrol *kcontrol, int event)
500{
501 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
502
503 switch (event) {
504 case SND_SOC_DAPM_PRE_PMU:
505 snd_soc_update_bits(codec,
506 RT298_A_BIAS_CTRL3, 0xc000, 0x8000);
507 snd_soc_update_bits(codec,
508 RT298_A_BIAS_CTRL2, 0xc000, 0x8000);
509 break;
510 case SND_SOC_DAPM_POST_PMD:
511 snd_soc_update_bits(codec,
512 RT298_A_BIAS_CTRL3, 0xc000, 0x0000);
513 snd_soc_update_bits(codec,
514 RT298_A_BIAS_CTRL2, 0xc000, 0x0000);
515 break;
516 default:
517 return 0;
518 }
519
520 return 0;
521}
522
523static int rt298_vref_event(struct snd_soc_dapm_widget *w,
524 struct snd_kcontrol *kcontrol, int event)
525{
526 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
527
528 switch (event) {
529 case SND_SOC_DAPM_PRE_PMU:
530 snd_soc_update_bits(codec,
531 RT298_CBJ_CTRL1, 0x0400, 0x0000);
532 mdelay(50);
533 break;
534 default:
535 return 0;
536 }
537
538 return 0;
539}
540
541static const struct snd_soc_dapm_widget rt298_dapm_widgets[] = {
542
543 SND_SOC_DAPM_SUPPLY_S("HV", 1, RT298_POWER_CTRL1,
544 12, 1, NULL, 0),
545 SND_SOC_DAPM_SUPPLY("VREF", RT298_POWER_CTRL1,
546 0, 1, rt298_vref_event, SND_SOC_DAPM_PRE_PMU),
547 SND_SOC_DAPM_SUPPLY_S("BG_MBIAS", 1, RT298_POWER_CTRL2,
548 1, 0, NULL, 0),
549 SND_SOC_DAPM_SUPPLY_S("LDO1", 1, RT298_POWER_CTRL2,
550 2, 0, NULL, 0),
551 SND_SOC_DAPM_SUPPLY_S("LDO2", 1, RT298_POWER_CTRL2,
552 3, 0, NULL, 0),
553 SND_SOC_DAPM_SUPPLY_S("VREF1", 1, RT298_POWER_CTRL2,
554 4, 1, NULL, 0),
555 SND_SOC_DAPM_SUPPLY_S("LV", 2, RT298_POWER_CTRL1,
556 13, 1, NULL, 0),
557
558
559 SND_SOC_DAPM_SUPPLY("MCLK MODE", RT298_PLL_CTRL1,
560 5, 0, NULL, 0),
561 SND_SOC_DAPM_SUPPLY("MIC1 Input Buffer", SND_SOC_NOPM,
562 0, 0, rt298_mic1_event, SND_SOC_DAPM_PRE_PMU |
563 SND_SOC_DAPM_POST_PMD),
564
565 /* Input Lines */
566 SND_SOC_DAPM_INPUT("DMIC1 Pin"),
567 SND_SOC_DAPM_INPUT("DMIC2 Pin"),
568 SND_SOC_DAPM_INPUT("MIC1"),
569 SND_SOC_DAPM_INPUT("LINE1"),
570 SND_SOC_DAPM_INPUT("Beep"),
571
572 /* DMIC */
573 SND_SOC_DAPM_PGA_E("DMIC1", RT298_SET_POWER(RT298_DMIC1), 0, 1,
574 NULL, 0, rt298_set_dmic1_event,
575 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
576 SND_SOC_DAPM_PGA("DMIC2", RT298_SET_POWER(RT298_DMIC2), 0, 1,
577 NULL, 0),
578 SND_SOC_DAPM_SUPPLY("DMIC Receiver", SND_SOC_NOPM,
579 0, 0, NULL, 0),
580
581 /* REC Mixer */
582 SND_SOC_DAPM_MIXER("RECMIX", SND_SOC_NOPM, 0, 0,
583 rt298_rec_mix, ARRAY_SIZE(rt298_rec_mix)),
584
585 /* ADCs */
586 SND_SOC_DAPM_ADC("ADC 0", NULL, SND_SOC_NOPM, 0, 0),
587 SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM, 0, 0),
588
589 /* ADC Mux */
590 SND_SOC_DAPM_MUX_E("ADC 0 Mux", RT298_SET_POWER(RT298_ADC_IN1), 0, 1,
591 &rt298_adc0_mux, rt298_adc_event, SND_SOC_DAPM_PRE_PMD |
592 SND_SOC_DAPM_POST_PMU),
593 SND_SOC_DAPM_MUX_E("ADC 1 Mux", RT298_SET_POWER(RT298_ADC_IN2), 0, 1,
594 &rt298_adc1_mux, rt298_adc_event, SND_SOC_DAPM_PRE_PMD |
595 SND_SOC_DAPM_POST_PMU),
596
597 /* Audio Interface */
598 SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
599 SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
600 SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
601 SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
602
603 /* Output Side */
604 /* DACs */
605 SND_SOC_DAPM_DAC("DAC 0", NULL, SND_SOC_NOPM, 0, 0),
606 SND_SOC_DAPM_DAC("DAC 1", NULL, SND_SOC_NOPM, 0, 0),
607
608 /* Output Mux */
609 SND_SOC_DAPM_MUX("SPK Mux", SND_SOC_NOPM, 0, 0, &rt298_spo_mux),
610 SND_SOC_DAPM_MUX("HPO Mux", SND_SOC_NOPM, 0, 0, &rt298_hpo_mux),
611
612 SND_SOC_DAPM_SUPPLY("HP Power", RT298_SET_PIN_HPO,
613 RT298_SET_PIN_SFT, 0, NULL, 0),
614
615 /* Output Mixer */
616 SND_SOC_DAPM_MIXER("Front", RT298_SET_POWER(RT298_DAC_OUT1), 0, 1,
617 rt298_front_mix, ARRAY_SIZE(rt298_front_mix)),
618 SND_SOC_DAPM_PGA("Surround", RT298_SET_POWER(RT298_DAC_OUT2), 0, 1,
619 NULL, 0),
620
621 /* Output Pga */
622 SND_SOC_DAPM_SWITCH_E("SPO", SND_SOC_NOPM, 0, 0,
623 &spo_enable_control, rt298_spk_event,
624 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
625 SND_SOC_DAPM_SWITCH("HPO L", SND_SOC_NOPM, 0, 0,
626 &hpol_enable_control),
627 SND_SOC_DAPM_SWITCH("HPO R", SND_SOC_NOPM, 0, 0,
628 &hpor_enable_control),
629
630 /* Output Lines */
631 SND_SOC_DAPM_OUTPUT("SPOL"),
632 SND_SOC_DAPM_OUTPUT("SPOR"),
633 SND_SOC_DAPM_OUTPUT("HPO Pin"),
634 SND_SOC_DAPM_OUTPUT("SPDIF"),
635};
636
637static const struct snd_soc_dapm_route rt298_dapm_routes[] = {
638
639 {"ADC 0", NULL, "MCLK MODE", is_mclk_mode},
640 {"ADC 1", NULL, "MCLK MODE", is_mclk_mode},
641 {"Front", NULL, "MCLK MODE", is_mclk_mode},
642 {"Surround", NULL, "MCLK MODE", is_mclk_mode},
643
644 {"HP Power", NULL, "LDO1"},
645 {"HP Power", NULL, "LDO2"},
646 {"HP Power", NULL, "LV"},
647 {"HP Power", NULL, "VREF1"},
648 {"HP Power", NULL, "BG_MBIAS"},
649
650 {"MIC1", NULL, "LDO1"},
651 {"MIC1", NULL, "LDO2"},
652 {"MIC1", NULL, "HV"},
653 {"MIC1", NULL, "LV"},
654 {"MIC1", NULL, "VREF"},
655 {"MIC1", NULL, "VREF1"},
656 {"MIC1", NULL, "BG_MBIAS"},
657 {"MIC1", NULL, "MIC1 Input Buffer"},
658
659 {"SPO", NULL, "LDO1"},
660 {"SPO", NULL, "LDO2"},
661 {"SPO", NULL, "HV"},
662 {"SPO", NULL, "LV"},
663 {"SPO", NULL, "VREF"},
664 {"SPO", NULL, "VREF1"},
665 {"SPO", NULL, "BG_MBIAS"},
666
667 {"DMIC1", NULL, "DMIC1 Pin"},
668 {"DMIC2", NULL, "DMIC2 Pin"},
669 {"DMIC1", NULL, "DMIC Receiver"},
670 {"DMIC2", NULL, "DMIC Receiver"},
671
672 {"RECMIX", "Beep Switch", "Beep"},
673 {"RECMIX", "Line1 Switch", "LINE1"},
674 {"RECMIX", "Mic1 Switch", "MIC1"},
675
676 {"ADC 0 Mux", "Dmic", "DMIC1"},
677 {"ADC 0 Mux", "RECMIX", "RECMIX"},
678 {"ADC 0 Mux", "Mic", "MIC1"},
679 {"ADC 1 Mux", "Dmic", "DMIC2"},
680 {"ADC 1 Mux", "RECMIX", "RECMIX"},
681 {"ADC 1 Mux", "Mic", "MIC1"},
682
683 {"ADC 0", NULL, "ADC 0 Mux"},
684 {"ADC 1", NULL, "ADC 1 Mux"},
685
686 {"AIF1TX", NULL, "ADC 0"},
687 {"AIF2TX", NULL, "ADC 1"},
688
689 {"DAC 0", NULL, "AIF1RX"},
690 {"DAC 1", NULL, "AIF2RX"},
691
692 {"Front", "DAC Switch", "DAC 0"},
693 {"Front", "RECMIX Switch", "RECMIX"},
694
695 {"Surround", NULL, "DAC 1"},
696
697 {"SPK Mux", "Front", "Front"},
698 {"SPK Mux", "Surround", "Surround"},
699
700 {"HPO Mux", "Front", "Front"},
701 {"HPO Mux", "Surround", "Surround"},
702
703 {"SPO", "Switch", "SPK Mux"},
704 {"HPO L", "Switch", "HPO Mux"},
705 {"HPO R", "Switch", "HPO Mux"},
706 {"HPO L", NULL, "HP Power"},
707 {"HPO R", NULL, "HP Power"},
708
709 {"SPOL", NULL, "SPO"},
710 {"SPOR", NULL, "SPO"},
711 {"HPO Pin", NULL, "HPO L"},
712 {"HPO Pin", NULL, "HPO R"},
713};
714
715static int rt298_hw_params(struct snd_pcm_substream *substream,
716 struct snd_pcm_hw_params *params,
717 struct snd_soc_dai *dai)
718{
719 struct snd_soc_codec *codec = dai->codec;
720 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
721 unsigned int val = 0;
722 int d_len_code;
723
724 switch (params_rate(params)) {
725 /* bit 14 0:48K 1:44.1K */
726 case 44100:
727 case 48000:
728 break;
729 default:
730 dev_err(codec->dev, "Unsupported sample rate %d\n",
731 params_rate(params));
732 return -EINVAL;
733 }
734 switch (rt298->sys_clk) {
735 case 12288000:
736 case 24576000:
737 if (params_rate(params) != 48000) {
738 dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n",
739 params_rate(params), rt298->sys_clk);
740 return -EINVAL;
741 }
742 break;
743 case 11289600:
744 case 22579200:
745 if (params_rate(params) != 44100) {
746 dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n",
747 params_rate(params), rt298->sys_clk);
748 return -EINVAL;
749 }
750 break;
751 }
752
753 if (params_channels(params) <= 16) {
754 /* bit 3:0 Number of Channel */
755 val |= (params_channels(params) - 1);
756 } else {
757 dev_err(codec->dev, "Unsupported channels %d\n",
758 params_channels(params));
759 return -EINVAL;
760 }
761
762 d_len_code = 0;
763 switch (params_width(params)) {
764 /* bit 6:4 Bits per Sample */
765 case 16:
766 d_len_code = 0;
767 val |= (0x1 << 4);
768 break;
769 case 32:
770 d_len_code = 2;
771 val |= (0x4 << 4);
772 break;
773 case 20:
774 d_len_code = 1;
775 val |= (0x2 << 4);
776 break;
777 case 24:
778 d_len_code = 2;
779 val |= (0x3 << 4);
780 break;
781 case 8:
782 d_len_code = 3;
783 break;
784 default:
785 return -EINVAL;
786 }
787
788 snd_soc_update_bits(codec,
789 RT298_I2S_CTRL1, 0x0018, d_len_code << 3);
790 dev_dbg(codec->dev, "format val = 0x%x\n", val);
791
792 snd_soc_update_bits(codec, RT298_DAC_FORMAT, 0x407f, val);
793 snd_soc_update_bits(codec, RT298_ADC_FORMAT, 0x407f, val);
794
795 return 0;
796}
797
798static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
799{
800 struct snd_soc_codec *codec = dai->codec;
801
802 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
803 case SND_SOC_DAIFMT_CBM_CFM:
804 snd_soc_update_bits(codec,
805 RT298_I2S_CTRL1, 0x800, 0x800);
806 break;
807 case SND_SOC_DAIFMT_CBS_CFS:
808 snd_soc_update_bits(codec,
809 RT298_I2S_CTRL1, 0x800, 0x0);
810 break;
811 default:
812 return -EINVAL;
813 }
814
815 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
816 case SND_SOC_DAIFMT_I2S:
817 snd_soc_update_bits(codec,
818 RT298_I2S_CTRL1, 0x300, 0x0);
819 break;
820 case SND_SOC_DAIFMT_LEFT_J:
821 snd_soc_update_bits(codec,
822 RT298_I2S_CTRL1, 0x300, 0x1 << 8);
823 break;
824 case SND_SOC_DAIFMT_DSP_A:
825 snd_soc_update_bits(codec,
826 RT298_I2S_CTRL1, 0x300, 0x2 << 8);
827 break;
828 case SND_SOC_DAIFMT_DSP_B:
829 snd_soc_update_bits(codec,
830 RT298_I2S_CTRL1, 0x300, 0x3 << 8);
831 break;
832 default:
833 return -EINVAL;
834 }
835 /* bit 15 Stream Type 0:PCM 1:Non-PCM */
836 snd_soc_update_bits(codec, RT298_DAC_FORMAT, 0x8000, 0);
837 snd_soc_update_bits(codec, RT298_ADC_FORMAT, 0x8000, 0);
838
839 return 0;
840}
841
842static int rt298_set_dai_sysclk(struct snd_soc_dai *dai,
843 int clk_id, unsigned int freq, int dir)
844{
845 struct snd_soc_codec *codec = dai->codec;
846 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
847
848 dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq);
849
850 if (RT298_SCLK_S_MCLK == clk_id) {
851 snd_soc_update_bits(codec,
852 RT298_I2S_CTRL2, 0x0100, 0x0);
853 snd_soc_update_bits(codec,
854 RT298_PLL_CTRL1, 0x20, 0x20);
855 } else {
856 snd_soc_update_bits(codec,
857 RT298_I2S_CTRL2, 0x0100, 0x0100);
858 snd_soc_update_bits(codec,
859 RT298_PLL_CTRL, 0x4, 0x4);
860 snd_soc_update_bits(codec,
861 RT298_PLL_CTRL1, 0x20, 0x0);
862 }
863
864 switch (freq) {
865 case 19200000:
866 if (RT298_SCLK_S_MCLK == clk_id) {
867 dev_err(codec->dev, "Should not use MCLK\n");
868 return -EINVAL;
869 }
870 snd_soc_update_bits(codec,
871 RT298_I2S_CTRL2, 0x40, 0x40);
872 break;
873 case 24000000:
874 if (RT298_SCLK_S_MCLK == clk_id) {
875 dev_err(codec->dev, "Should not use MCLK\n");
876 return -EINVAL;
877 }
878 snd_soc_update_bits(codec,
879 RT298_I2S_CTRL2, 0x40, 0x0);
880 break;
881 case 12288000:
882 case 11289600:
883 snd_soc_update_bits(codec,
884 RT298_I2S_CTRL2, 0x8, 0x0);
885 snd_soc_update_bits(codec,
886 RT298_CLK_DIV, 0xfc1e, 0x0004);
887 break;
888 case 24576000:
889 case 22579200:
890 snd_soc_update_bits(codec,
891 RT298_I2S_CTRL2, 0x8, 0x8);
892 snd_soc_update_bits(codec,
893 RT298_CLK_DIV, 0xfc1e, 0x5406);
894 break;
895 default:
896 dev_err(codec->dev, "Unsupported system clock\n");
897 return -EINVAL;
898 }
899
900 rt298->sys_clk = freq;
901 rt298->clk_id = clk_id;
902
903 return 0;
904}
905
906static int rt298_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
907{
908 struct snd_soc_codec *codec = dai->codec;
909
910 dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio);
911 if (50 == ratio)
912 snd_soc_update_bits(codec,
913 RT298_I2S_CTRL1, 0x1000, 0x1000);
914 else
915 snd_soc_update_bits(codec,
916 RT298_I2S_CTRL1, 0x1000, 0x0);
917
918
919 return 0;
920}
921
922static int rt298_set_bias_level(struct snd_soc_codec *codec,
923 enum snd_soc_bias_level level)
924{
925 switch (level) {
926 case SND_SOC_BIAS_PREPARE:
927 if (SND_SOC_BIAS_STANDBY ==
928 snd_soc_codec_get_bias_level(codec)) {
929 snd_soc_write(codec,
930 RT298_SET_AUDIO_POWER, AC_PWRST_D0);
931 snd_soc_update_bits(codec, 0x0d, 0x200, 0x200);
932 snd_soc_update_bits(codec, 0x52, 0x80, 0x0);
933 mdelay(20);
934 snd_soc_update_bits(codec, 0x0d, 0x200, 0x0);
935 snd_soc_update_bits(codec, 0x52, 0x80, 0x80);
936 }
937 break;
938
939 case SND_SOC_BIAS_ON:
940 mdelay(30);
941 snd_soc_update_bits(codec,
942 RT298_CBJ_CTRL1, 0x0400, 0x0400);
943
944 break;
945
946 case SND_SOC_BIAS_STANDBY:
947 snd_soc_write(codec,
948 RT298_SET_AUDIO_POWER, AC_PWRST_D3);
949 snd_soc_update_bits(codec,
950 RT298_CBJ_CTRL1, 0x0400, 0x0000);
951 break;
952
953 default:
954 break;
955 }
956
957 return 0;
958}
959
960static irqreturn_t rt298_irq(int irq, void *data)
961{
962 struct rt298_priv *rt298 = data;
963 bool hp = false;
964 bool mic = false;
965 int ret, status = 0;
966
967 ret = rt298_jack_detect(rt298, &hp, &mic);
968
969 /* Clear IRQ */
970 regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x1, 0x1);
971
972 if (ret == 0) {
973 if (hp == true)
974 status |= SND_JACK_HEADPHONE;
975
976 if (mic == true)
977 status |= SND_JACK_MICROPHONE;
978
979 snd_soc_jack_report(rt298->jack, status,
980 SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
981
982 pm_wakeup_event(&rt298->i2c->dev, 300);
983 }
984
985 return IRQ_HANDLED;
986}
987
988static int rt298_probe(struct snd_soc_codec *codec)
989{
990 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
991
992 rt298->codec = codec;
993
994 if (rt298->i2c->irq) {
995 regmap_update_bits(rt298->regmap,
996 RT298_IRQ_CTRL, 0x2, 0x2);
997
998 INIT_DELAYED_WORK(&rt298->jack_detect_work,
999 rt298_jack_detect_work);
1000 schedule_delayed_work(&rt298->jack_detect_work,
1001 msecs_to_jiffies(1250));
1002 }
1003
1004 return 0;
1005}
1006
1007static int rt298_remove(struct snd_soc_codec *codec)
1008{
1009 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
1010
1011 cancel_delayed_work_sync(&rt298->jack_detect_work);
1012
1013 return 0;
1014}
1015
1016#ifdef CONFIG_PM
1017static int rt298_suspend(struct snd_soc_codec *codec)
1018{
1019 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
1020
1021 rt298->is_hp_in = -1;
1022 regcache_cache_only(rt298->regmap, true);
1023 regcache_mark_dirty(rt298->regmap);
1024
1025 return 0;
1026}
1027
1028static int rt298_resume(struct snd_soc_codec *codec)
1029{
1030 struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec);
1031
1032 regcache_cache_only(rt298->regmap, false);
1033 rt298_index_sync(codec);
1034 regcache_sync(rt298->regmap);
1035
1036 return 0;
1037}
1038#else
1039#define rt298_suspend NULL
1040#define rt298_resume NULL
1041#endif
1042
1043#define RT298_STEREO_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
1044#define RT298_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
1045 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
1046
1047static const struct snd_soc_dai_ops rt298_aif_dai_ops = {
1048 .hw_params = rt298_hw_params,
1049 .set_fmt = rt298_set_dai_fmt,
1050 .set_sysclk = rt298_set_dai_sysclk,
1051 .set_bclk_ratio = rt298_set_bclk_ratio,
1052};
1053
1054static struct snd_soc_dai_driver rt298_dai[] = {
1055 {
1056 .name = "rt298-aif1",
1057 .id = RT298_AIF1,
1058 .playback = {
1059 .stream_name = "AIF1 Playback",
1060 .channels_min = 1,
1061 .channels_max = 2,
1062 .rates = RT298_STEREO_RATES,
1063 .formats = RT298_FORMATS,
1064 },
1065 .capture = {
1066 .stream_name = "AIF1 Capture",
1067 .channels_min = 1,
1068 .channels_max = 2,
1069 .rates = RT298_STEREO_RATES,
1070 .formats = RT298_FORMATS,
1071 },
1072 .ops = &rt298_aif_dai_ops,
1073 .symmetric_rates = 1,
1074 },
1075 {
1076 .name = "rt298-aif2",
1077 .id = RT298_AIF2,
1078 .playback = {
1079 .stream_name = "AIF2 Playback",
1080 .channels_min = 1,
1081 .channels_max = 2,
1082 .rates = RT298_STEREO_RATES,
1083 .formats = RT298_FORMATS,
1084 },
1085 .capture = {
1086 .stream_name = "AIF2 Capture",
1087 .channels_min = 1,
1088 .channels_max = 2,
1089 .rates = RT298_STEREO_RATES,
1090 .formats = RT298_FORMATS,
1091 },
1092 .ops = &rt298_aif_dai_ops,
1093 .symmetric_rates = 1,
1094 },
1095
1096};
1097
1098static struct snd_soc_codec_driver soc_codec_dev_rt298 = {
1099 .probe = rt298_probe,
1100 .remove = rt298_remove,
1101 .suspend = rt298_suspend,
1102 .resume = rt298_resume,
1103 .set_bias_level = rt298_set_bias_level,
1104 .idle_bias_off = true,
1105 .controls = rt298_snd_controls,
1106 .num_controls = ARRAY_SIZE(rt298_snd_controls),
1107 .dapm_widgets = rt298_dapm_widgets,
1108 .num_dapm_widgets = ARRAY_SIZE(rt298_dapm_widgets),
1109 .dapm_routes = rt298_dapm_routes,
1110 .num_dapm_routes = ARRAY_SIZE(rt298_dapm_routes),
1111};
1112
1113static const struct regmap_config rt298_regmap = {
1114 .reg_bits = 32,
1115 .val_bits = 32,
1116 .max_register = 0x02370100,
1117 .volatile_reg = rt298_volatile_register,
1118 .readable_reg = rt298_readable_register,
1119 .reg_write = rl6347a_hw_write,
1120 .reg_read = rl6347a_hw_read,
1121 .cache_type = REGCACHE_RBTREE,
1122 .reg_defaults = rt298_reg,
1123 .num_reg_defaults = ARRAY_SIZE(rt298_reg),
1124};
1125
1126static const struct i2c_device_id rt298_i2c_id[] = {
1127 {"rt298", 0},
1128 {}
1129};
1130MODULE_DEVICE_TABLE(i2c, rt298_i2c_id);
1131
1132static const struct acpi_device_id rt298_acpi_match[] = {
1133 { "INT343A", 0 },
1134 {},
1135};
1136MODULE_DEVICE_TABLE(acpi, rt298_acpi_match);
1137
1138static int rt298_i2c_probe(struct i2c_client *i2c,
1139 const struct i2c_device_id *id)
1140{
1141 struct rt298_platform_data *pdata = dev_get_platdata(&i2c->dev);
1142 struct rt298_priv *rt298;
1143 struct device *dev = &i2c->dev;
1144 const struct acpi_device_id *acpiid;
1145 int i, ret;
1146
1147 rt298 = devm_kzalloc(&i2c->dev, sizeof(*rt298),
1148 GFP_KERNEL);
1149 if (NULL == rt298)
1150 return -ENOMEM;
1151
1152 rt298->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt298_regmap);
1153 if (IS_ERR(rt298->regmap)) {
1154 ret = PTR_ERR(rt298->regmap);
1155 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
1156 ret);
1157 return ret;
1158 }
1159
1160 regmap_read(rt298->regmap,
1161 RT298_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &ret);
1162 if (ret != RT298_VENDOR_ID) {
1163 dev_err(&i2c->dev,
1164 "Device with ID register %#x is not rt298\n", ret);
1165 return -ENODEV;
1166 }
1167
1168 rt298->index_cache = rt298_index_def;
1169 rt298->index_cache_size = INDEX_CACHE_SIZE;
1170 rt298->i2c = i2c;
1171 i2c_set_clientdata(i2c, rt298);
1172
1173 /* restore codec default */
1174 for (i = 0; i < INDEX_CACHE_SIZE; i++)
1175 regmap_write(rt298->regmap, rt298->index_cache[i].reg,
1176 rt298->index_cache[i].def);
1177 for (i = 0; i < ARRAY_SIZE(rt298_reg); i++)
1178 regmap_write(rt298->regmap, rt298_reg[i].reg,
1179 rt298_reg[i].def);
1180
1181 if (pdata)
1182 rt298->pdata = *pdata;
1183
1184 /* enable jack combo mode on supported devices */
1185 acpiid = acpi_match_device(dev->driver->acpi_match_table, dev);
1186 if (acpiid) {
1187 rt298->pdata = *(struct rt298_platform_data *)
1188 acpiid->driver_data;
1189 }
1190
1191 /* VREF Charging */
1192 regmap_update_bits(rt298->regmap, 0x04, 0x80, 0x80);
1193 regmap_update_bits(rt298->regmap, 0x1b, 0x860, 0x860);
1194 /* Vref2 */
1195 regmap_update_bits(rt298->regmap, 0x08, 0x20, 0x20);
1196
1197 regmap_write(rt298->regmap, RT298_SET_AUDIO_POWER, AC_PWRST_D3);
1198
1199 for (i = 0; i < RT298_POWER_REG_LEN; i++)
1200 regmap_write(rt298->regmap,
1201 RT298_SET_POWER(rt298_support_power_controls[i]),
1202 AC_PWRST_D1);
1203
1204 if (!rt298->pdata.cbj_en) {
1205 regmap_write(rt298->regmap, RT298_CBJ_CTRL2, 0x0000);
1206 regmap_write(rt298->regmap, RT298_MIC1_DET_CTRL, 0x0816);
1207 regmap_update_bits(rt298->regmap,
1208 RT298_CBJ_CTRL1, 0xf000, 0xb000);
1209 } else {
1210 regmap_update_bits(rt298->regmap,
1211 RT298_CBJ_CTRL1, 0xf000, 0x5000);
1212 }
1213
1214 mdelay(10);
1215
1216 if (!rt298->pdata.gpio2_en)
1217 regmap_write(rt298->regmap, RT298_SET_DMIC2_DEFAULT, 0x4000);
1218 else
1219 regmap_write(rt298->regmap, RT298_SET_DMIC2_DEFAULT, 0);
1220
1221 mdelay(10);
1222
1223 regmap_write(rt298->regmap, RT298_MISC_CTRL1, 0x0000);
1224 regmap_update_bits(rt298->regmap,
1225 RT298_WIND_FILTER_CTRL, 0x0082, 0x0082);
1226 regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x2);
1227 rt298->is_hp_in = -1;
1228
1229 if (rt298->i2c->irq) {
1230 ret = request_threaded_irq(rt298->i2c->irq, NULL, rt298_irq,
1231 IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt298", rt298);
1232 if (ret != 0) {
1233 dev_err(&i2c->dev,
1234 "Failed to reguest IRQ: %d\n", ret);
1235 return ret;
1236 }
1237 }
1238
1239 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt298,
1240 rt298_dai, ARRAY_SIZE(rt298_dai));
1241
1242 return ret;
1243}
1244
1245static int rt298_i2c_remove(struct i2c_client *i2c)
1246{
1247 struct rt298_priv *rt298 = i2c_get_clientdata(i2c);
1248
1249 if (i2c->irq)
1250 free_irq(i2c->irq, rt298);
1251 snd_soc_unregister_codec(&i2c->dev);
1252
1253 return 0;
1254}
1255
1256
1257static struct i2c_driver rt298_i2c_driver = {
1258 .driver = {
1259 .name = "rt298",
1260 .acpi_match_table = ACPI_PTR(rt298_acpi_match),
1261 },
1262 .probe = rt298_i2c_probe,
1263 .remove = rt298_i2c_remove,
1264 .id_table = rt298_i2c_id,
1265};
1266
1267module_i2c_driver(rt298_i2c_driver);
1268
1269MODULE_DESCRIPTION("ASoC RT298 driver");
1270MODULE_AUTHOR("Bard Liao <bardliao@realtek.com>");
1271MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/rt298.h b/sound/soc/codecs/rt298.h
new file mode 100644
index 000000000000..31da16265f2b
--- /dev/null
+++ b/sound/soc/codecs/rt298.h
@@ -0,0 +1,206 @@
1/*
2 * rt298.h -- RT298 ALSA SoC audio driver
3 *
4 * Copyright 2011 Realtek Microelectronics
5 * Author: Johnny Hsu <johnnyhsu@realtek.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 __RT298_H__
13#define __RT298_H__
14
15#define VERB_CMD(V, N, D) ((N << 20) | (V << 8) | D)
16
17#define RT298_AUDIO_FUNCTION_GROUP 0x01
18#define RT298_DAC_OUT1 0x02
19#define RT298_DAC_OUT2 0x03
20#define RT298_DIG_CVT 0x06
21#define RT298_ADC_IN1 0x09
22#define RT298_ADC_IN2 0x08
23#define RT298_MIXER_IN 0x0b
24#define RT298_MIXER_OUT1 0x0c
25#define RT298_MIXER_OUT2 0x0d
26#define RT298_DMIC1 0x12
27#define RT298_DMIC2 0x13
28#define RT298_SPK_OUT 0x14
29#define RT298_MIC1 0x18
30#define RT298_LINE1 0x1a
31#define RT298_BEEP 0x1d
32#define RT298_SPDIF 0x1e
33#define RT298_VENDOR_REGISTERS 0x20
34#define RT298_HP_OUT 0x21
35#define RT298_MIXER_IN1 0x22
36#define RT298_MIXER_IN2 0x23
37
38#define RT298_SET_PIN_SFT 6
39#define RT298_SET_PIN_ENABLE 0x40
40#define RT298_SET_PIN_DISABLE 0
41#define RT298_SET_EAPD_HIGH 0x2
42#define RT298_SET_EAPD_LOW 0
43
44#define RT298_MUTE_SFT 7
45
46/* Verb commands */
47#define RT298_GET_PARAM(NID, PARAM) VERB_CMD(AC_VERB_PARAMETERS, NID, PARAM)
48#define RT298_SET_POWER(NID) VERB_CMD(AC_VERB_SET_POWER_STATE, NID, 0)
49#define RT298_SET_AUDIO_POWER RT298_SET_POWER(RT298_AUDIO_FUNCTION_GROUP)
50#define RT298_SET_HPO_POWER RT298_SET_POWER(RT298_HP_OUT)
51#define RT298_SET_SPK_POWER RT298_SET_POWER(RT298_SPK_OUT)
52#define RT298_SET_DMIC1_POWER RT298_SET_POWER(RT298_DMIC1)
53#define RT298_SPK_MUX\
54 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT298_SPK_OUT, 0)
55#define RT298_HPO_MUX\
56 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT298_HP_OUT, 0)
57#define RT298_ADC0_MUX\
58 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT298_MIXER_IN1, 0)
59#define RT298_ADC1_MUX\
60 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT298_MIXER_IN2, 0)
61#define RT298_SET_MIC1\
62 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT298_MIC1, 0)
63#define RT298_SET_PIN_HPO\
64 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT298_HP_OUT, 0)
65#define RT298_SET_PIN_SPK\
66 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT298_SPK_OUT, 0)
67#define RT298_SET_PIN_DMIC1\
68 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT298_DMIC1, 0)
69#define RT298_SET_PIN_SPDIF\
70 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT298_SPDIF, 0)
71#define RT298_SET_PIN_DIG_CVT\
72 VERB_CMD(AC_VERB_SET_DIGI_CONVERT_1, RT298_DIG_CVT, 0)
73#define RT298_SPK_EAPD\
74 VERB_CMD(AC_VERB_SET_EAPD_BTLENABLE, RT298_SPK_OUT, 0)
75#define RT298_SET_AMP_GAIN_HPO\
76 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_HP_OUT, 0)
77#define RT298_SET_AMP_GAIN_ADC_IN1\
78 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_ADC_IN1, 0)
79#define RT298_SET_AMP_GAIN_ADC_IN2\
80 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_ADC_IN2, 0)
81#define RT298_GET_HP_SENSE\
82 VERB_CMD(AC_VERB_GET_PIN_SENSE, RT298_HP_OUT, 0)
83#define RT298_GET_MIC1_SENSE\
84 VERB_CMD(AC_VERB_GET_PIN_SENSE, RT298_MIC1, 0)
85#define RT298_SET_DMIC2_DEFAULT\
86 VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, RT298_DMIC2, 0)
87#define RT298_SET_SPDIF_DEFAULT\
88 VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, RT298_SPDIF, 0)
89#define RT298_DACL_GAIN\
90 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_DAC_OUT1, 0xa000)
91#define RT298_DACR_GAIN\
92 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_DAC_OUT1, 0x9000)
93#define RT298_ADCL_GAIN\
94 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_ADC_IN1, 0x6000)
95#define RT298_ADCR_GAIN\
96 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_ADC_IN1, 0x5000)
97#define RT298_MIC_GAIN\
98 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIC1, 0x7000)
99#define RT298_SPOL_GAIN\
100 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_SPK_OUT, 0xa000)
101#define RT298_SPOR_GAIN\
102 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_SPK_OUT, 0x9000)
103#define RT298_HPOL_GAIN\
104 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_HP_OUT, 0xa000)
105#define RT298_HPOR_GAIN\
106 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_HP_OUT, 0x9000)
107#define RT298_F_DAC_SWITCH\
108 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_OUT1, 0x7000)
109#define RT298_F_RECMIX_SWITCH\
110 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_OUT1, 0x7100)
111#define RT298_REC_MIC_SWITCH\
112 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_IN, 0x7000)
113#define RT298_REC_I2S_SWITCH\
114 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_IN, 0x7100)
115#define RT298_REC_LINE_SWITCH\
116 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_IN, 0x7200)
117#define RT298_REC_BEEP_SWITCH\
118 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_IN, 0x7300)
119#define RT298_DAC_FORMAT\
120 VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT298_DAC_OUT1, 0)
121#define RT298_ADC_FORMAT\
122 VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT298_ADC_IN1, 0)
123#define RT298_COEF_INDEX\
124 VERB_CMD(AC_VERB_SET_COEF_INDEX, RT298_VENDOR_REGISTERS, 0)
125#define RT298_PROC_COEF\
126 VERB_CMD(AC_VERB_SET_PROC_COEF, RT298_VENDOR_REGISTERS, 0)
127
128/* Index registers */
129#define RT298_A_BIAS_CTRL1 0x01
130#define RT298_A_BIAS_CTRL2 0x02
131#define RT298_POWER_CTRL1 0x03
132#define RT298_A_BIAS_CTRL3 0x04
133#define RT298_POWER_CTRL2 0x08
134#define RT298_I2S_CTRL1 0x09
135#define RT298_I2S_CTRL2 0x0a
136#define RT298_CLK_DIV 0x0b
137#define RT298_DC_GAIN 0x0d
138#define RT298_POWER_CTRL3 0x0f
139#define RT298_MIC1_DET_CTRL 0x19
140#define RT298_MISC_CTRL1 0x20
141#define RT298_IRQ_CTRL 0x33
142#define RT298_WIND_FILTER_CTRL 0x46
143#define RT298_PLL_CTRL1 0x49
144#define RT298_CBJ_CTRL1 0x4f
145#define RT298_CBJ_CTRL2 0x50
146#define RT298_PLL_CTRL 0x63
147#define RT298_DEPOP_CTRL1 0x66
148#define RT298_DEPOP_CTRL2 0x67
149#define RT298_DEPOP_CTRL3 0x68
150#define RT298_DEPOP_CTRL4 0x69
151
152/* SPDIF (0x06) */
153#define RT298_SPDIF_SEL_SFT 0
154#define RT298_SPDIF_SEL_PCM0 0
155#define RT298_SPDIF_SEL_PCM1 1
156#define RT298_SPDIF_SEL_SPOUT 2
157#define RT298_SPDIF_SEL_PP 3
158
159/* RECMIX (0x0b) */
160#define RT298_M_REC_BEEP_SFT 0
161#define RT298_M_REC_LINE1_SFT 1
162#define RT298_M_REC_MIC1_SFT 2
163#define RT298_M_REC_I2S_SFT 3
164
165/* Front (0x0c) */
166#define RT298_M_FRONT_DAC_SFT 0
167#define RT298_M_FRONT_REC_SFT 1
168
169/* SPK-OUT (0x14) */
170#define RT298_M_SPK_MUX_SFT 14
171#define RT298_SPK_SEL_MASK 0x1
172#define RT298_SPK_SEL_SFT 0
173#define RT298_SPK_SEL_F 0
174#define RT298_SPK_SEL_S 1
175
176/* HP-OUT (0x21) */
177#define RT298_M_HP_MUX_SFT 14
178#define RT298_HP_SEL_MASK 0x1
179#define RT298_HP_SEL_SFT 0
180#define RT298_HP_SEL_F 0
181#define RT298_HP_SEL_S 1
182
183/* ADC (0x22) (0x23) */
184#define RT298_ADC_SEL_MASK 0x7
185#define RT298_ADC_SEL_SFT 0
186#define RT298_ADC_SEL_SURR 0
187#define RT298_ADC_SEL_FRONT 1
188#define RT298_ADC_SEL_DMIC 2
189#define RT298_ADC_SEL_BEEP 4
190#define RT298_ADC_SEL_LINE1 5
191#define RT298_ADC_SEL_I2S 6
192#define RT298_ADC_SEL_MIC1 7
193
194#define RT298_SCLK_S_MCLK 0
195#define RT298_SCLK_S_PLL 1
196
197enum {
198 RT298_AIF1,
199 RT298_AIF2,
200 RT298_AIFS,
201};
202
203int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack);
204
205#endif /* __RT298_H__ */
206
diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c
index 058167c80d71..d8771020299d 100644
--- a/sound/soc/codecs/rt5631.c
+++ b/sound/soc/codecs/rt5631.c
@@ -1725,7 +1725,6 @@ static int rt5631_i2c_remove(struct i2c_client *client)
1725static struct i2c_driver rt5631_i2c_driver = { 1725static struct i2c_driver rt5631_i2c_driver = {
1726 .driver = { 1726 .driver = {
1727 .name = "rt5631", 1727 .name = "rt5631",
1728 .owner = THIS_MODULE,
1729 .of_match_table = of_match_ptr(rt5631_i2c_dt_ids), 1728 .of_match_table = of_match_ptr(rt5631_i2c_dt_ids),
1730 }, 1729 },
1731 .probe = rt5631_i2c_probe, 1730 .probe = rt5631_i2c_probe,
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index 9bc78e57513d..b4139d3da334 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -51,7 +51,7 @@ static const struct regmap_range_cfg rt5640_ranges[] = {
51 .window_len = 0x1, }, 51 .window_len = 0x1, },
52}; 52};
53 53
54static const struct reg_default init_list[] = { 54static const struct reg_sequence init_list[] = {
55 {RT5640_PR_BASE + 0x3d, 0x3600}, 55 {RT5640_PR_BASE + 0x3d, 0x3600},
56 {RT5640_PR_BASE + 0x12, 0x0aa8}, 56 {RT5640_PR_BASE + 0x12, 0x0aa8},
57 {RT5640_PR_BASE + 0x14, 0x0aaa}, 57 {RT5640_PR_BASE + 0x14, 0x0aaa},
@@ -459,10 +459,11 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
459{ 459{
460 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 460 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
461 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); 461 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
462 int idx = -EINVAL; 462 int idx, rate;
463
464 idx = rl6231_calc_dmic_clk(rt5640->sysclk);
465 463
464 rate = rt5640->sysclk / rl6231_get_pre_div(rt5640->regmap,
465 RT5640_ADDA_CLK1, RT5640_I2S_PD1_SFT);
466 idx = rl6231_calc_dmic_clk(rate);
466 if (idx < 0) 467 if (idx < 0)
467 dev_err(codec->dev, "Failed to set DMIC clock\n"); 468 dev_err(codec->dev, "Failed to set DMIC clock\n");
468 else 469 else
@@ -984,6 +985,35 @@ static int rt5640_hp_event(struct snd_soc_dapm_widget *w,
984 return 0; 985 return 0;
985} 986}
986 987
988static int rt5640_lout_event(struct snd_soc_dapm_widget *w,
989 struct snd_kcontrol *kcontrol, int event)
990{
991 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
992
993 switch (event) {
994 case SND_SOC_DAPM_POST_PMU:
995 hp_amp_power_on(codec);
996 snd_soc_update_bits(codec, RT5640_PWR_ANLG1,
997 RT5640_PWR_LM, RT5640_PWR_LM);
998 snd_soc_update_bits(codec, RT5640_OUTPUT,
999 RT5640_L_MUTE | RT5640_R_MUTE, 0);
1000 break;
1001
1002 case SND_SOC_DAPM_PRE_PMD:
1003 snd_soc_update_bits(codec, RT5640_OUTPUT,
1004 RT5640_L_MUTE | RT5640_R_MUTE,
1005 RT5640_L_MUTE | RT5640_R_MUTE);
1006 snd_soc_update_bits(codec, RT5640_PWR_ANLG1,
1007 RT5640_PWR_LM, 0);
1008 break;
1009
1010 default:
1011 return 0;
1012 }
1013
1014 return 0;
1015}
1016
987static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w, 1017static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w,
988 struct snd_kcontrol *kcontrol, int event) 1018 struct snd_kcontrol *kcontrol, int event)
989{ 1019{
@@ -1179,13 +1209,16 @@ static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] = {
1179 0, rt5640_spo_l_mix, ARRAY_SIZE(rt5640_spo_l_mix)), 1209 0, rt5640_spo_l_mix, ARRAY_SIZE(rt5640_spo_l_mix)),
1180 SND_SOC_DAPM_MIXER("SPOR MIX", SND_SOC_NOPM, 0, 1210 SND_SOC_DAPM_MIXER("SPOR MIX", SND_SOC_NOPM, 0,
1181 0, rt5640_spo_r_mix, ARRAY_SIZE(rt5640_spo_r_mix)), 1211 0, rt5640_spo_r_mix, ARRAY_SIZE(rt5640_spo_r_mix)),
1182 SND_SOC_DAPM_MIXER("LOUT MIX", RT5640_PWR_ANLG1, RT5640_PWR_LM_BIT, 0, 1212 SND_SOC_DAPM_MIXER("LOUT MIX", SND_SOC_NOPM, 0, 0,
1183 rt5640_lout_mix, ARRAY_SIZE(rt5640_lout_mix)), 1213 rt5640_lout_mix, ARRAY_SIZE(rt5640_lout_mix)),
1184 SND_SOC_DAPM_SUPPLY_S("Improve HP Amp Drv", 1, SND_SOC_NOPM, 1214 SND_SOC_DAPM_SUPPLY_S("Improve HP Amp Drv", 1, SND_SOC_NOPM,
1185 0, 0, rt5640_hp_power_event, SND_SOC_DAPM_POST_PMU), 1215 0, 0, rt5640_hp_power_event, SND_SOC_DAPM_POST_PMU),
1186 SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0, 1216 SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0,
1187 rt5640_hp_event, 1217 rt5640_hp_event,
1188 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 1218 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
1219 SND_SOC_DAPM_PGA_S("LOUT amp", 1, SND_SOC_NOPM, 0, 0,
1220 rt5640_lout_event,
1221 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
1189 SND_SOC_DAPM_SUPPLY("HP L Amp", RT5640_PWR_ANLG1, 1222 SND_SOC_DAPM_SUPPLY("HP L Amp", RT5640_PWR_ANLG1,
1190 RT5640_PWR_HP_L_BIT, 0, NULL, 0), 1223 RT5640_PWR_HP_L_BIT, 0, NULL, 0),
1191 SND_SOC_DAPM_SUPPLY("HP R Amp", RT5640_PWR_ANLG1, 1224 SND_SOC_DAPM_SUPPLY("HP R Amp", RT5640_PWR_ANLG1,
@@ -1500,8 +1533,10 @@ static const struct snd_soc_dapm_route rt5640_dapm_routes[] = {
1500 {"HP R Playback", "Switch", "HP Amp"}, 1533 {"HP R Playback", "Switch", "HP Amp"},
1501 {"HPOL", NULL, "HP L Playback"}, 1534 {"HPOL", NULL, "HP L Playback"},
1502 {"HPOR", NULL, "HP R Playback"}, 1535 {"HPOR", NULL, "HP R Playback"},
1503 {"LOUTL", NULL, "LOUT MIX"}, 1536
1504 {"LOUTR", NULL, "LOUT MIX"}, 1537 {"LOUT amp", NULL, "LOUT MIX"},
1538 {"LOUTL", NULL, "LOUT amp"},
1539 {"LOUTR", NULL, "LOUT amp"},
1505}; 1540};
1506 1541
1507static const struct snd_soc_dapm_route rt5640_specific_dapm_routes[] = { 1542static const struct snd_soc_dapm_route rt5640_specific_dapm_routes[] = {
@@ -2207,7 +2242,7 @@ static int rt5640_i2c_probe(struct i2c_client *i2c,
2207 regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val); 2242 regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val);
2208 if (val != RT5640_DEVICE_ID) { 2243 if (val != RT5640_DEVICE_ID) {
2209 dev_err(&i2c->dev, 2244 dev_err(&i2c->dev,
2210 "Device with ID register %x is not rt5640/39\n", val); 2245 "Device with ID register %#x is not rt5640/39\n", val);
2211 return -ENODEV; 2246 return -ENODEV;
2212 } 2247 }
2213 2248
@@ -2242,7 +2277,6 @@ static int rt5640_i2c_remove(struct i2c_client *i2c)
2242static struct i2c_driver rt5640_i2c_driver = { 2277static struct i2c_driver rt5640_i2c_driver = {
2243 .driver = { 2278 .driver = {
2244 .name = "rt5640", 2279 .name = "rt5640",
2245 .owner = THIS_MODULE,
2246 .acpi_match_table = ACPI_PTR(rt5640_acpi_match), 2280 .acpi_match_table = ACPI_PTR(rt5640_acpi_match),
2247 .of_match_table = of_match_ptr(rt5640_of_match), 2281 .of_match_table = of_match_ptr(rt5640_of_match),
2248 }, 2282 },
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 9ce311e088fc..1e70736cc970 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -21,6 +21,7 @@
21#include <linux/gpio/consumer.h> 21#include <linux/gpio/consumer.h>
22#include <linux/acpi.h> 22#include <linux/acpi.h>
23#include <linux/dmi.h> 23#include <linux/dmi.h>
24#include <linux/regulator/consumer.h>
24#include <sound/core.h> 25#include <sound/core.h>
25#include <sound/pcm.h> 26#include <sound/pcm.h>
26#include <sound/pcm_params.h> 27#include <sound/pcm_params.h>
@@ -54,7 +55,7 @@ static const struct regmap_range_cfg rt5645_ranges[] = {
54 }, 55 },
55}; 56};
56 57
57static const struct reg_default init_list[] = { 58static const struct reg_sequence init_list[] = {
58 {RT5645_PR_BASE + 0x3d, 0x3600}, 59 {RT5645_PR_BASE + 0x3d, 0x3600},
59 {RT5645_PR_BASE + 0x1c, 0xfd20}, 60 {RT5645_PR_BASE + 0x1c, 0xfd20},
60 {RT5645_PR_BASE + 0x20, 0x611f}, 61 {RT5645_PR_BASE + 0x20, 0x611f},
@@ -63,7 +64,7 @@ static const struct reg_default init_list[] = {
63}; 64};
64#define RT5645_INIT_REG_LEN ARRAY_SIZE(init_list) 65#define RT5645_INIT_REG_LEN ARRAY_SIZE(init_list)
65 66
66static const struct reg_default rt5650_init_list[] = { 67static const struct reg_sequence rt5650_init_list[] = {
67 {0xf6, 0x0100}, 68 {0xf6, 0x0100},
68}; 69};
69 70
@@ -223,6 +224,39 @@ static const struct reg_default rt5645_reg[] = {
223 { 0xff, 0x6308 }, 224 { 0xff, 0x6308 },
224}; 225};
225 226
227static const char *const rt5645_supply_names[] = {
228 "avdd",
229 "cpvdd",
230};
231
232struct rt5645_priv {
233 struct snd_soc_codec *codec;
234 struct rt5645_platform_data pdata;
235 struct regmap *regmap;
236 struct i2c_client *i2c;
237 struct gpio_desc *gpiod_hp_det;
238 struct snd_soc_jack *hp_jack;
239 struct snd_soc_jack *mic_jack;
240 struct snd_soc_jack *btn_jack;
241 struct delayed_work jack_detect_work;
242 struct regulator_bulk_data supplies[ARRAY_SIZE(rt5645_supply_names)];
243
244 int codec_type;
245 int sysclk;
246 int sysclk_src;
247 int lrck[RT5645_AIFS];
248 int bclk[RT5645_AIFS];
249 int master[RT5645_AIFS];
250
251 int pll_src;
252 int pll_in;
253 int pll_out;
254
255 int jack_type;
256 bool en_button_func;
257 bool hp_on;
258};
259
226static int rt5645_reset(struct snd_soc_codec *codec) 260static int rt5645_reset(struct snd_soc_codec *codec)
227{ 261{
228 return snd_soc_write(codec, RT5645_RESET, 0); 262 return snd_soc_write(codec, RT5645_RESET, 0);
@@ -360,6 +394,7 @@ static bool rt5645_readable_register(struct device *dev, unsigned int reg)
360 case RT5645_DEPOP_M1: 394 case RT5645_DEPOP_M1:
361 case RT5645_DEPOP_M2: 395 case RT5645_DEPOP_M2:
362 case RT5645_DEPOP_M3: 396 case RT5645_DEPOP_M3:
397 case RT5645_CHARGE_PUMP:
363 case RT5645_MICBIAS: 398 case RT5645_MICBIAS:
364 case RT5645_A_JD_CTRL1: 399 case RT5645_A_JD_CTRL1:
365 case RT5645_VAD_CTRL4: 400 case RT5645_VAD_CTRL4:
@@ -510,10 +545,11 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
510{ 545{
511 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 546 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
512 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); 547 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec);
513 int idx = -EINVAL; 548 int idx, rate;
514
515 idx = rl6231_calc_dmic_clk(rt5645->sysclk);
516 549
550 rate = rt5645->sysclk / rl6231_get_pre_div(rt5645->regmap,
551 RT5645_ADDA_CLK1, RT5645_I2S_PD1_SFT);
552 idx = rl6231_calc_dmic_clk(rate);
517 if (idx < 0) 553 if (idx < 0)
518 dev_err(codec->dev, "Failed to set DMIC clock\n"); 554 dev_err(codec->dev, "Failed to set DMIC clock\n");
519 else 555 else
@@ -1331,15 +1367,23 @@ static void hp_amp_power(struct snd_soc_codec *codec, int on)
1331 if (on) { 1367 if (on) {
1332 if (hp_amp_power_count <= 0) { 1368 if (hp_amp_power_count <= 0) {
1333 if (rt5645->codec_type == CODEC_TYPE_RT5650) { 1369 if (rt5645->codec_type == CODEC_TYPE_RT5650) {
1370 snd_soc_write(codec, RT5645_DEPOP_M2, 0x3100);
1334 snd_soc_write(codec, RT5645_CHARGE_PUMP, 1371 snd_soc_write(codec, RT5645_CHARGE_PUMP,
1335 0x0e06); 1372 0x0e06);
1336 snd_soc_write(codec, RT5645_DEPOP_M1, 0x001d); 1373 snd_soc_write(codec, RT5645_DEPOP_M1, 0x000d);
1374 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1375 RT5645_HP_DCC_INT1, 0x9f01);
1376 msleep(20);
1377 snd_soc_update_bits(codec, RT5645_DEPOP_M1,
1378 RT5645_HP_CO_MASK, RT5645_HP_CO_EN);
1337 regmap_write(rt5645->regmap, RT5645_PR_BASE + 1379 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1338 0x3e, 0x7400); 1380 0x3e, 0x7400);
1339 snd_soc_write(codec, RT5645_DEPOP_M3, 0x0737); 1381 snd_soc_write(codec, RT5645_DEPOP_M3, 0x0737);
1340 regmap_write(rt5645->regmap, RT5645_PR_BASE + 1382 regmap_write(rt5645->regmap, RT5645_PR_BASE +
1341 RT5645_MAMP_INT_REG2, 0xfc00); 1383 RT5645_MAMP_INT_REG2, 0xfc00);
1342 snd_soc_write(codec, RT5645_DEPOP_M2, 0x1140); 1384 snd_soc_write(codec, RT5645_DEPOP_M2, 0x1140);
1385 mdelay(5);
1386 rt5645->hp_on = true;
1343 } else { 1387 } else {
1344 /* depop parameters */ 1388 /* depop parameters */
1345 snd_soc_update_bits(codec, RT5645_DEPOP_M2, 1389 snd_soc_update_bits(codec, RT5645_DEPOP_M2,
@@ -1553,6 +1597,27 @@ static int rt5645_bst2_event(struct snd_soc_dapm_widget *w,
1553 return 0; 1597 return 0;
1554} 1598}
1555 1599
1600static int rt5650_hp_event(struct snd_soc_dapm_widget *w,
1601 struct snd_kcontrol *k, int event)
1602{
1603 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1604 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec);
1605
1606 switch (event) {
1607 case SND_SOC_DAPM_POST_PMU:
1608 if (rt5645->hp_on) {
1609 msleep(100);
1610 rt5645->hp_on = false;
1611 }
1612 break;
1613
1614 default:
1615 return 0;
1616 }
1617
1618 return 0;
1619}
1620
1556static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = { 1621static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = {
1557 SND_SOC_DAPM_SUPPLY("LDO2", RT5645_PWR_MIXER, 1622 SND_SOC_DAPM_SUPPLY("LDO2", RT5645_PWR_MIXER,
1558 RT5645_PWR_LDO2_BIT, 0, NULL, 0), 1623 RT5645_PWR_LDO2_BIT, 0, NULL, 0),
@@ -1697,15 +1762,6 @@ static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = {
1697 SND_SOC_DAPM_PGA("IF1_ADC4", SND_SOC_NOPM, 0, 0, NULL, 0), 1762 SND_SOC_DAPM_PGA("IF1_ADC4", SND_SOC_NOPM, 0, 0, NULL, 0),
1698 1763
1699 /* IF1 2 Mux */ 1764 /* IF1 2 Mux */
1700 SND_SOC_DAPM_MUX("RT5645 IF1 ADC1 Swap Mux", SND_SOC_NOPM,
1701 0, 0, &rt5645_if1_adc1_in_mux),
1702 SND_SOC_DAPM_MUX("RT5645 IF1 ADC2 Swap Mux", SND_SOC_NOPM,
1703 0, 0, &rt5645_if1_adc2_in_mux),
1704 SND_SOC_DAPM_MUX("RT5645 IF1 ADC3 Swap Mux", SND_SOC_NOPM,
1705 0, 0, &rt5645_if1_adc3_in_mux),
1706 SND_SOC_DAPM_MUX("RT5645 IF1 ADC Mux", SND_SOC_NOPM,
1707 0, 0, &rt5645_if1_adc_in_mux),
1708
1709 SND_SOC_DAPM_MUX("IF2 ADC Mux", SND_SOC_NOPM, 1765 SND_SOC_DAPM_MUX("IF2 ADC Mux", SND_SOC_NOPM,
1710 0, 0, &rt5645_if2_adc_in_mux), 1766 0, 0, &rt5645_if2_adc_in_mux),
1711 1767
@@ -1716,14 +1772,6 @@ static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = {
1716 SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0), 1772 SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0),
1717 SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0), 1773 SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0),
1718 SND_SOC_DAPM_PGA("IF1 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0), 1774 SND_SOC_DAPM_PGA("IF1 DAC3", SND_SOC_NOPM, 0, 0, NULL, 0),
1719 SND_SOC_DAPM_MUX("RT5645 IF1 DAC1 L Mux", SND_SOC_NOPM, 0, 0,
1720 &rt5645_if1_dac0_tdm_sel_mux),
1721 SND_SOC_DAPM_MUX("RT5645 IF1 DAC1 R Mux", SND_SOC_NOPM, 0, 0,
1722 &rt5645_if1_dac1_tdm_sel_mux),
1723 SND_SOC_DAPM_MUX("RT5645 IF1 DAC2 L Mux", SND_SOC_NOPM, 0, 0,
1724 &rt5645_if1_dac2_tdm_sel_mux),
1725 SND_SOC_DAPM_MUX("RT5645 IF1 DAC2 R Mux", SND_SOC_NOPM, 0, 0,
1726 &rt5645_if1_dac3_tdm_sel_mux),
1727 SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), 1775 SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
1728 SND_SOC_DAPM_PGA("IF1 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0), 1776 SND_SOC_DAPM_PGA("IF1 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
1729 SND_SOC_DAPM_PGA("IF1 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0), 1777 SND_SOC_DAPM_PGA("IF1 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
@@ -1854,6 +1902,26 @@ static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = {
1854 SND_SOC_DAPM_OUTPUT("PDM1R"), 1902 SND_SOC_DAPM_OUTPUT("PDM1R"),
1855 SND_SOC_DAPM_OUTPUT("SPOL"), 1903 SND_SOC_DAPM_OUTPUT("SPOL"),
1856 SND_SOC_DAPM_OUTPUT("SPOR"), 1904 SND_SOC_DAPM_OUTPUT("SPOR"),
1905 SND_SOC_DAPM_POST("DAPM_POST", rt5650_hp_event),
1906};
1907
1908static const struct snd_soc_dapm_widget rt5645_specific_dapm_widgets[] = {
1909 SND_SOC_DAPM_MUX("RT5645 IF1 DAC1 L Mux", SND_SOC_NOPM, 0, 0,
1910 &rt5645_if1_dac0_tdm_sel_mux),
1911 SND_SOC_DAPM_MUX("RT5645 IF1 DAC1 R Mux", SND_SOC_NOPM, 0, 0,
1912 &rt5645_if1_dac1_tdm_sel_mux),
1913 SND_SOC_DAPM_MUX("RT5645 IF1 DAC2 L Mux", SND_SOC_NOPM, 0, 0,
1914 &rt5645_if1_dac2_tdm_sel_mux),
1915 SND_SOC_DAPM_MUX("RT5645 IF1 DAC2 R Mux", SND_SOC_NOPM, 0, 0,
1916 &rt5645_if1_dac3_tdm_sel_mux),
1917 SND_SOC_DAPM_MUX("RT5645 IF1 ADC Mux", SND_SOC_NOPM,
1918 0, 0, &rt5645_if1_adc_in_mux),
1919 SND_SOC_DAPM_MUX("RT5645 IF1 ADC1 Swap Mux", SND_SOC_NOPM,
1920 0, 0, &rt5645_if1_adc1_in_mux),
1921 SND_SOC_DAPM_MUX("RT5645 IF1 ADC2 Swap Mux", SND_SOC_NOPM,
1922 0, 0, &rt5645_if1_adc2_in_mux),
1923 SND_SOC_DAPM_MUX("RT5645 IF1 ADC3 Swap Mux", SND_SOC_NOPM,
1924 0, 0, &rt5645_if1_adc3_in_mux),
1857}; 1925};
1858 1926
1859static const struct snd_soc_dapm_widget rt5650_specific_dapm_widgets[] = { 1927static const struct snd_soc_dapm_widget rt5650_specific_dapm_widgets[] = {
@@ -2642,7 +2710,7 @@ static int rt5645_set_bias_level(struct snd_soc_codec *codec,
2642 2710
2643 switch (level) { 2711 switch (level) {
2644 case SND_SOC_BIAS_PREPARE: 2712 case SND_SOC_BIAS_PREPARE:
2645 if (SND_SOC_BIAS_STANDBY == codec->dapm.bias_level) { 2713 if (SND_SOC_BIAS_STANDBY == snd_soc_codec_get_bias_level(codec)) {
2646 snd_soc_update_bits(codec, RT5645_PWR_ANLG1, 2714 snd_soc_update_bits(codec, RT5645_PWR_ANLG1,
2647 RT5645_PWR_VREF1 | RT5645_PWR_MB | 2715 RT5645_PWR_VREF1 | RT5645_PWR_MB |
2648 RT5645_PWR_BG | RT5645_PWR_VREF2, 2716 RT5645_PWR_BG | RT5645_PWR_VREF2,
@@ -2686,94 +2754,15 @@ static int rt5645_set_bias_level(struct snd_soc_codec *codec,
2686 return 0; 2754 return 0;
2687} 2755}
2688 2756
2689static int rt5650_calibration(struct rt5645_priv *rt5645)
2690{
2691 int val, i;
2692 int ret = -1;
2693
2694 regcache_cache_bypass(rt5645->regmap, true);
2695 regmap_write(rt5645->regmap, RT5645_RESET, 0);
2696 regmap_write(rt5645->regmap, RT5645_GEN_CTRL3, 0x0800);
2697 regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_CHOP_DAC_ADC,
2698 0x3600);
2699 regmap_write(rt5645->regmap, RT5645_PR_BASE + 0x25, 0x7000);
2700 regmap_write(rt5645->regmap, RT5645_I2S1_SDP, 0x8008);
2701 /* headset type */
2702 regmap_write(rt5645->regmap, RT5645_GEN_CTRL1, 0x2061);
2703 regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0006);
2704 regmap_write(rt5645->regmap, RT5645_PWR_ANLG1, 0x2012);
2705 regmap_write(rt5645->regmap, RT5645_PWR_MIXER, 0x0002);
2706 regmap_write(rt5645->regmap, RT5645_PWR_VOL, 0x0020);
2707 regmap_write(rt5645->regmap, RT5645_JD_CTRL3, 0x00f0);
2708 regmap_write(rt5645->regmap, RT5645_IN1_CTRL1, 0x0006);
2709 regmap_write(rt5645->regmap, RT5645_IN1_CTRL2, 0x1827);
2710 regmap_write(rt5645->regmap, RT5645_IN1_CTRL2, 0x0827);
2711 msleep(400);
2712 /* Inline command */
2713 regmap_write(rt5645->regmap, RT5645_DEPOP_M1, 0x0001);
2714 regmap_write(rt5645->regmap, RT5650_4BTN_IL_CMD2, 0xc000);
2715 regmap_write(rt5645->regmap, RT5650_4BTN_IL_CMD1, 0x0008);
2716 /* Calbration */
2717 regmap_write(rt5645->regmap, RT5645_GLB_CLK, 0x8000);
2718 regmap_write(rt5645->regmap, RT5645_DEPOP_M1, 0x0000);
2719 regmap_write(rt5645->regmap, RT5650_4BTN_IL_CMD2, 0xc000);
2720 regmap_write(rt5645->regmap, RT5650_4BTN_IL_CMD1, 0x0008);
2721 regmap_write(rt5645->regmap, RT5645_PWR_DIG2, 0x8800);
2722 regmap_write(rt5645->regmap, RT5645_PWR_ANLG1, 0xe8fa);
2723 regmap_write(rt5645->regmap, RT5645_PWR_ANLG2, 0x8c04);
2724 regmap_write(rt5645->regmap, RT5645_DEPOP_M2, 0x3100);
2725 regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0e06);
2726 regmap_write(rt5645->regmap, RT5645_BASS_BACK, 0x8a13);
2727 regmap_write(rt5645->regmap, RT5645_GEN_CTRL3, 0x0820);
2728 regmap_write(rt5645->regmap, RT5645_DEPOP_M1, 0x000d);
2729 /* Power on and Calbration */
2730 regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_HP_DCC_INT1,
2731 0x9f01);
2732 msleep(200);
2733 for (i = 0; i < 5; i++) {
2734 regmap_read(rt5645->regmap, RT5645_PR_BASE + 0x7a, &val);
2735 if (val != 0 && val != 0x3f3f) {
2736 ret = 0;
2737 break;
2738 }
2739 msleep(50);
2740 }
2741 pr_debug("%s: PR-7A = 0x%x\n", __func__, val);
2742
2743 /* mute */
2744 regmap_write(rt5645->regmap, RT5645_PR_BASE + 0x3e, 0x7400);
2745 regmap_write(rt5645->regmap, RT5645_DEPOP_M3, 0x0737);
2746 regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_MAMP_INT_REG2,
2747 0xfc00);
2748 regmap_write(rt5645->regmap, RT5645_DEPOP_M2, 0x1140);
2749 regmap_write(rt5645->regmap, RT5645_DEPOP_M1, 0x0000);
2750 regmap_write(rt5645->regmap, RT5645_GEN_CTRL2, 0x4020);
2751 regmap_write(rt5645->regmap, RT5645_PWR_ANLG2, 0x0006);
2752 regmap_write(rt5645->regmap, RT5645_PWR_DIG2, 0x0000);
2753 msleep(350);
2754
2755 regcache_cache_bypass(rt5645->regmap, false);
2756
2757 return ret;
2758}
2759
2760static void rt5645_enable_push_button_irq(struct snd_soc_codec *codec, 2757static void rt5645_enable_push_button_irq(struct snd_soc_codec *codec,
2761 bool enable) 2758 bool enable)
2762{ 2759{
2763 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); 2760 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
2764 2761
2765 if (enable) { 2762 if (enable) {
2766 snd_soc_dapm_mutex_lock(&codec->dapm); 2763 snd_soc_dapm_force_enable_pin(dapm, "ADC L power");
2767 snd_soc_dapm_force_enable_pin_unlocked(&codec->dapm, 2764 snd_soc_dapm_force_enable_pin(dapm, "ADC R power");
2768 "ADC L power"); 2765 snd_soc_dapm_sync(dapm);
2769 snd_soc_dapm_force_enable_pin_unlocked(&codec->dapm,
2770 "ADC R power");
2771 snd_soc_dapm_force_enable_pin_unlocked(&codec->dapm,
2772 "LDO2");
2773 snd_soc_dapm_force_enable_pin_unlocked(&codec->dapm,
2774 "Mic Det Power");
2775 snd_soc_dapm_sync_unlocked(&codec->dapm);
2776 snd_soc_dapm_mutex_unlock(&codec->dapm);
2777 2766
2778 snd_soc_update_bits(codec, 2767 snd_soc_update_bits(codec,
2779 RT5645_INT_IRQ_ST, 0x8, 0x8); 2768 RT5645_INT_IRQ_ST, 0x8, 0x8);
@@ -2786,36 +2775,26 @@ static void rt5645_enable_push_button_irq(struct snd_soc_codec *codec,
2786 snd_soc_update_bits(codec, RT5650_4BTN_IL_CMD2, 0x8000, 0x0); 2775 snd_soc_update_bits(codec, RT5650_4BTN_IL_CMD2, 0x8000, 0x0);
2787 snd_soc_update_bits(codec, RT5645_INT_IRQ_ST, 0x8, 0x0); 2776 snd_soc_update_bits(codec, RT5645_INT_IRQ_ST, 0x8, 0x0);
2788 2777
2789 snd_soc_dapm_mutex_lock(&codec->dapm); 2778 snd_soc_dapm_disable_pin(dapm, "ADC L power");
2790 snd_soc_dapm_disable_pin_unlocked(&codec->dapm, 2779 snd_soc_dapm_disable_pin(dapm, "ADC R power");
2791 "ADC L power"); 2780 snd_soc_dapm_sync(dapm);
2792 snd_soc_dapm_disable_pin_unlocked(&codec->dapm,
2793 "ADC R power");
2794 if (rt5645->pdata.jd_mode == 0)
2795 snd_soc_dapm_disable_pin_unlocked(&codec->dapm,
2796 "LDO2");
2797 snd_soc_dapm_disable_pin_unlocked(&codec->dapm,
2798 "Mic Det Power");
2799 snd_soc_dapm_sync_unlocked(&codec->dapm);
2800 snd_soc_dapm_mutex_unlock(&codec->dapm);
2801 } 2781 }
2802} 2782}
2803 2783
2804static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) 2784static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert)
2805{ 2785{
2786 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
2806 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); 2787 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec);
2807 unsigned int val; 2788 unsigned int val;
2808 2789
2809 if (jack_insert) { 2790 if (jack_insert) {
2810 regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0006); 2791 regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0006);
2811 2792
2812 if (codec->component.card->instantiated) { 2793 /* for jack type detect */
2813 /* for jack type detect */ 2794 snd_soc_dapm_force_enable_pin(dapm, "LDO2");
2814 snd_soc_dapm_force_enable_pin(&codec->dapm, "LDO2"); 2795 snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power");
2815 snd_soc_dapm_force_enable_pin(&codec->dapm, 2796 snd_soc_dapm_sync(dapm);
2816 "Mic Det Power"); 2797 if (!dapm->card->instantiated) {
2817 snd_soc_dapm_sync(&codec->dapm);
2818 } else {
2819 /* Power up necessary bits for JD if dapm is 2798 /* Power up necessary bits for JD if dapm is
2820 not ready yet */ 2799 not ready yet */
2821 regmap_update_bits(rt5645->regmap, RT5645_PWR_ANLG1, 2800 regmap_update_bits(rt5645->regmap, RT5645_PWR_ANLG1,
@@ -2828,14 +2807,15 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert)
2828 } 2807 }
2829 2808
2830 regmap_write(rt5645->regmap, RT5645_JD_CTRL3, 0x00f0); 2809 regmap_write(rt5645->regmap, RT5645_JD_CTRL3, 0x00f0);
2831 regmap_write(rt5645->regmap, RT5645_IN1_CTRL1, 0x0006); 2810 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2,
2832 regmap_update_bits(rt5645->regmap, 2811 RT5645_CBJ_MN_JD, RT5645_CBJ_MN_JD);
2833 RT5645_IN1_CTRL2, 0x1000, 0x1000); 2812 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1,
2813 RT5645_CBJ_BST1_EN, RT5645_CBJ_BST1_EN);
2834 msleep(100); 2814 msleep(100);
2835 regmap_update_bits(rt5645->regmap, 2815 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2,
2836 RT5645_IN1_CTRL2, 0x1000, 0x0000); 2816 RT5645_CBJ_MN_JD, 0);
2837 2817
2838 msleep(450); 2818 msleep(600);
2839 regmap_read(rt5645->regmap, RT5645_IN1_CTRL3, &val); 2819 regmap_read(rt5645->regmap, RT5645_IN1_CTRL3, &val);
2840 val &= 0x7; 2820 val &= 0x7;
2841 dev_dbg(codec->dev, "val = %d\n", val); 2821 dev_dbg(codec->dev, "val = %d\n", val);
@@ -2846,43 +2826,46 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert)
2846 rt5645_enable_push_button_irq(codec, true); 2826 rt5645_enable_push_button_irq(codec, true);
2847 } 2827 }
2848 } else { 2828 } else {
2849 if (codec->component.card->instantiated) { 2829 snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
2850 snd_soc_dapm_disable_pin(&codec->dapm, 2830 snd_soc_dapm_sync(dapm);
2851 "Mic Det Power");
2852 snd_soc_dapm_sync(&codec->dapm);
2853 } else
2854 regmap_update_bits(rt5645->regmap,
2855 RT5645_PWR_VOL, RT5645_PWR_MIC_DET, 0);
2856 rt5645->jack_type = SND_JACK_HEADPHONE; 2831 rt5645->jack_type = SND_JACK_HEADPHONE;
2857 } 2832 }
2858 2833
2834 snd_soc_update_bits(codec, RT5645_CHARGE_PUMP, 0x0300, 0x0200);
2835 snd_soc_write(codec, RT5645_DEPOP_M1, 0x001d);
2836 snd_soc_write(codec, RT5645_DEPOP_M1, 0x0001);
2859 } else { /* jack out */ 2837 } else { /* jack out */
2860 rt5645->jack_type = 0; 2838 rt5645->jack_type = 0;
2839
2840 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2,
2841 RT5645_CBJ_MN_JD, RT5645_CBJ_MN_JD);
2842 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1,
2843 RT5645_CBJ_BST1_EN, 0);
2844
2861 if (rt5645->en_button_func) 2845 if (rt5645->en_button_func)
2862 rt5645_enable_push_button_irq(codec, false); 2846 rt5645_enable_push_button_irq(codec, false);
2863 else { 2847
2864 if (codec->component.card->instantiated) { 2848 if (rt5645->pdata.jd_mode == 0)
2865 if (rt5645->pdata.jd_mode == 0) 2849 snd_soc_dapm_disable_pin(dapm, "LDO2");
2866 snd_soc_dapm_disable_pin(&codec->dapm, 2850 snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
2867 "LDO2"); 2851 snd_soc_dapm_sync(dapm);
2868 snd_soc_dapm_disable_pin(&codec->dapm,
2869 "Mic Det Power");
2870 snd_soc_dapm_sync(&codec->dapm);
2871 } else {
2872 if (rt5645->pdata.jd_mode == 0)
2873 regmap_update_bits(rt5645->regmap,
2874 RT5645_PWR_MIXER,
2875 RT5645_PWR_LDO2, 0);
2876 regmap_update_bits(rt5645->regmap,
2877 RT5645_PWR_VOL, RT5645_PWR_MIC_DET, 0);
2878 }
2879 }
2880 } 2852 }
2881 2853
2882 return rt5645->jack_type; 2854 return rt5645->jack_type;
2883} 2855}
2884 2856
2885static int rt5645_irq_detection(struct rt5645_priv *rt5645); 2857static int rt5645_button_detect(struct snd_soc_codec *codec)
2858{
2859 int btn_type, val;
2860
2861 val = snd_soc_read(codec, RT5650_4BTN_IL_CMD1);
2862 pr_debug("val=0x%x\n", val);
2863 btn_type = val & 0xfff0;
2864 snd_soc_write(codec, RT5650_4BTN_IL_CMD1, val);
2865
2866 return btn_type;
2867}
2868
2886static irqreturn_t rt5645_irq(int irq, void *data); 2869static irqreturn_t rt5645_irq(int irq, void *data);
2887 2870
2888int rt5645_set_jack_detect(struct snd_soc_codec *codec, 2871int rt5645_set_jack_detect(struct snd_soc_codec *codec,
@@ -2913,36 +2896,11 @@ static void rt5645_jack_detect_work(struct work_struct *work)
2913{ 2896{
2914 struct rt5645_priv *rt5645 = 2897 struct rt5645_priv *rt5645 =
2915 container_of(work, struct rt5645_priv, jack_detect_work.work); 2898 container_of(work, struct rt5645_priv, jack_detect_work.work);
2916
2917 rt5645_irq_detection(rt5645);
2918}
2919
2920static irqreturn_t rt5645_irq(int irq, void *data)
2921{
2922 struct rt5645_priv *rt5645 = data;
2923
2924 queue_delayed_work(system_power_efficient_wq,
2925 &rt5645->jack_detect_work, msecs_to_jiffies(250));
2926
2927 return IRQ_HANDLED;
2928}
2929
2930static int rt5645_button_detect(struct snd_soc_codec *codec)
2931{
2932 int btn_type, val;
2933
2934 val = snd_soc_read(codec, RT5650_4BTN_IL_CMD1);
2935 pr_debug("val=0x%x\n", val);
2936 btn_type = val & 0xfff0;
2937 snd_soc_write(codec, RT5650_4BTN_IL_CMD1, val);
2938
2939 return btn_type;
2940}
2941
2942static int rt5645_irq_detection(struct rt5645_priv *rt5645)
2943{
2944 int val, btn_type, gpio_state = 0, report = 0; 2899 int val, btn_type, gpio_state = 0, report = 0;
2945 2900
2901 if (!rt5645->codec)
2902 return;
2903
2946 switch (rt5645->pdata.jd_mode) { 2904 switch (rt5645->pdata.jd_mode) {
2947 case 0: /* Not using rt5645 JD */ 2905 case 0: /* Not using rt5645 JD */
2948 if (rt5645->gpiod_hp_det) { 2906 if (rt5645->gpiod_hp_det) {
@@ -2955,7 +2913,7 @@ static int rt5645_irq_detection(struct rt5645_priv *rt5645)
2955 report, SND_JACK_HEADPHONE); 2913 report, SND_JACK_HEADPHONE);
2956 snd_soc_jack_report(rt5645->mic_jack, 2914 snd_soc_jack_report(rt5645->mic_jack,
2957 report, SND_JACK_MICROPHONE); 2915 report, SND_JACK_MICROPHONE);
2958 return report; 2916 return;
2959 case 1: /* 2 port */ 2917 case 1: /* 2 port */
2960 val = snd_soc_read(rt5645->codec, RT5645_A_JD_CTRL1) & 0x0070; 2918 val = snd_soc_read(rt5645->codec, RT5645_A_JD_CTRL1) & 0x0070;
2961 break; 2919 break;
@@ -3037,27 +2995,39 @@ static int rt5645_irq_detection(struct rt5645_priv *rt5645)
3037 snd_soc_jack_report(rt5645->btn_jack, 2995 snd_soc_jack_report(rt5645->btn_jack,
3038 report, SND_JACK_BTN_0 | SND_JACK_BTN_1 | 2996 report, SND_JACK_BTN_0 | SND_JACK_BTN_1 |
3039 SND_JACK_BTN_2 | SND_JACK_BTN_3); 2997 SND_JACK_BTN_2 | SND_JACK_BTN_3);
2998}
2999
3000static irqreturn_t rt5645_irq(int irq, void *data)
3001{
3002 struct rt5645_priv *rt5645 = data;
3003
3004 queue_delayed_work(system_power_efficient_wq,
3005 &rt5645->jack_detect_work, msecs_to_jiffies(250));
3040 3006
3041 return report; 3007 return IRQ_HANDLED;
3042} 3008}
3043 3009
3044static int rt5645_probe(struct snd_soc_codec *codec) 3010static int rt5645_probe(struct snd_soc_codec *codec)
3045{ 3011{
3012 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
3046 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); 3013 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec);
3047 3014
3048 rt5645->codec = codec; 3015 rt5645->codec = codec;
3049 3016
3050 switch (rt5645->codec_type) { 3017 switch (rt5645->codec_type) {
3051 case CODEC_TYPE_RT5645: 3018 case CODEC_TYPE_RT5645:
3052 snd_soc_dapm_add_routes(&codec->dapm, 3019 snd_soc_dapm_new_controls(dapm,
3020 rt5645_specific_dapm_widgets,
3021 ARRAY_SIZE(rt5645_specific_dapm_widgets));
3022 snd_soc_dapm_add_routes(dapm,
3053 rt5645_specific_dapm_routes, 3023 rt5645_specific_dapm_routes,
3054 ARRAY_SIZE(rt5645_specific_dapm_routes)); 3024 ARRAY_SIZE(rt5645_specific_dapm_routes));
3055 break; 3025 break;
3056 case CODEC_TYPE_RT5650: 3026 case CODEC_TYPE_RT5650:
3057 snd_soc_dapm_new_controls(&codec->dapm, 3027 snd_soc_dapm_new_controls(dapm,
3058 rt5650_specific_dapm_widgets, 3028 rt5650_specific_dapm_widgets,
3059 ARRAY_SIZE(rt5650_specific_dapm_widgets)); 3029 ARRAY_SIZE(rt5650_specific_dapm_widgets));
3060 snd_soc_dapm_add_routes(&codec->dapm, 3030 snd_soc_dapm_add_routes(dapm,
3061 rt5650_specific_dapm_routes, 3031 rt5650_specific_dapm_routes,
3062 ARRAY_SIZE(rt5650_specific_dapm_routes)); 3032 ARRAY_SIZE(rt5650_specific_dapm_routes));
3063 break; 3033 break;
@@ -3067,9 +3037,9 @@ static int rt5645_probe(struct snd_soc_codec *codec)
3067 3037
3068 /* for JD function */ 3038 /* for JD function */
3069 if (rt5645->pdata.jd_mode) { 3039 if (rt5645->pdata.jd_mode) {
3070 snd_soc_dapm_force_enable_pin(&codec->dapm, "JD Power"); 3040 snd_soc_dapm_force_enable_pin(dapm, "JD Power");
3071 snd_soc_dapm_force_enable_pin(&codec->dapm, "LDO2"); 3041 snd_soc_dapm_force_enable_pin(dapm, "LDO2");
3072 snd_soc_dapm_sync(&codec->dapm); 3042 snd_soc_dapm_sync(dapm);
3073 } 3043 }
3074 3044
3075 return 0; 3045 return 0;
@@ -3110,7 +3080,7 @@ static int rt5645_resume(struct snd_soc_codec *codec)
3110#define RT5645_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ 3080#define RT5645_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
3111 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) 3081 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
3112 3082
3113static struct snd_soc_dai_ops rt5645_aif_dai_ops = { 3083static const struct snd_soc_dai_ops rt5645_aif_dai_ops = {
3114 .hw_params = rt5645_hw_params, 3084 .hw_params = rt5645_hw_params,
3115 .set_fmt = rt5645_set_dai_fmt, 3085 .set_fmt = rt5645_set_dai_fmt,
3116 .set_sysclk = rt5645_set_dai_sysclk, 3086 .set_sysclk = rt5645_set_dai_sysclk,
@@ -3221,7 +3191,7 @@ static int strago_quirk_cb(const struct dmi_system_id *id)
3221 return 1; 3191 return 1;
3222} 3192}
3223 3193
3224static struct dmi_system_id dmi_platform_intel_braswell[] = { 3194static const struct dmi_system_id dmi_platform_intel_braswell[] = {
3225 { 3195 {
3226 .ident = "Intel Strago", 3196 .ident = "Intel Strago",
3227 .callback = strago_quirk_cb, 3197 .callback = strago_quirk_cb,
@@ -3229,6 +3199,13 @@ static struct dmi_system_id dmi_platform_intel_braswell[] = {
3229 DMI_MATCH(DMI_PRODUCT_NAME, "Strago"), 3199 DMI_MATCH(DMI_PRODUCT_NAME, "Strago"),
3230 }, 3200 },
3231 }, 3201 },
3202 {
3203 .ident = "Google Celes",
3204 .callback = strago_quirk_cb,
3205 .matches = {
3206 DMI_MATCH(DMI_PRODUCT_NAME, "Celes"),
3207 },
3208 },
3232 { } 3209 { }
3233}; 3210};
3234 3211
@@ -3251,7 +3228,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
3251{ 3228{
3252 struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev); 3229 struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev);
3253 struct rt5645_priv *rt5645; 3230 struct rt5645_priv *rt5645;
3254 int ret; 3231 int ret, i;
3255 unsigned int val; 3232 unsigned int val;
3256 3233
3257 rt5645 = devm_kzalloc(&i2c->dev, sizeof(struct rt5645_priv), 3234 rt5645 = devm_kzalloc(&i2c->dev, sizeof(struct rt5645_priv),
@@ -3285,6 +3262,24 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
3285 return ret; 3262 return ret;
3286 } 3263 }
3287 3264
3265 for (i = 0; i < ARRAY_SIZE(rt5645->supplies); i++)
3266 rt5645->supplies[i].supply = rt5645_supply_names[i];
3267
3268 ret = devm_regulator_bulk_get(&i2c->dev,
3269 ARRAY_SIZE(rt5645->supplies),
3270 rt5645->supplies);
3271 if (ret) {
3272 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
3273 return ret;
3274 }
3275
3276 ret = regulator_bulk_enable(ARRAY_SIZE(rt5645->supplies),
3277 rt5645->supplies);
3278 if (ret) {
3279 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
3280 return ret;
3281 }
3282
3288 regmap_read(rt5645->regmap, RT5645_VENDOR_ID2, &val); 3283 regmap_read(rt5645->regmap, RT5645_VENDOR_ID2, &val);
3289 3284
3290 switch (val) { 3285 switch (val) {
@@ -3296,16 +3291,10 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
3296 break; 3291 break;
3297 default: 3292 default:
3298 dev_err(&i2c->dev, 3293 dev_err(&i2c->dev,
3299 "Device with ID register %x is not rt5645 or rt5650\n", 3294 "Device with ID register %#x is not rt5645 or rt5650\n",
3300 val); 3295 val);
3301 return -ENODEV; 3296 ret = -ENODEV;
3302 } 3297 goto err_enable;
3303
3304 if (rt5645->codec_type == CODEC_TYPE_RT5650) {
3305 ret = rt5650_calibration(rt5645);
3306
3307 if (ret < 0)
3308 pr_err("calibration failed!\n");
3309 } 3298 }
3310 3299
3311 regmap_write(rt5645->regmap, RT5645_RESET, 0); 3300 regmap_write(rt5645->regmap, RT5645_RESET, 0);
@@ -3338,6 +3327,8 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
3338 break; 3327 break;
3339 3328
3340 case RT5645_DMIC_DATA_GPIO5: 3329 case RT5645_DMIC_DATA_GPIO5:
3330 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
3331 RT5645_I2S2_DAC_PIN_MASK, RT5645_I2S2_DAC_PIN_GPIO);
3341 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, 3332 regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1,
3342 RT5645_DMIC_1_DP_MASK, RT5645_DMIC_1_DP_GPIO5); 3333 RT5645_DMIC_1_DP_MASK, RT5645_DMIC_1_DP_GPIO5);
3343 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, 3334 regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1,
@@ -3393,8 +3384,6 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
3393 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3, 3384 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3,
3394 RT5645_IRQ_CLK_GATE_CTRL, 3385 RT5645_IRQ_CLK_GATE_CTRL,
3395 RT5645_IRQ_CLK_GATE_CTRL); 3386 RT5645_IRQ_CLK_GATE_CTRL);
3396 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1,
3397 RT5645_CBJ_BST1_EN, RT5645_CBJ_BST1_EN);
3398 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS, 3387 regmap_update_bits(rt5645->regmap, RT5645_MICBIAS,
3399 RT5645_IRQ_CLK_INT, RT5645_IRQ_CLK_INT); 3388 RT5645_IRQ_CLK_INT, RT5645_IRQ_CLK_INT);
3400 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, 3389 regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
@@ -3434,12 +3423,25 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
3434 ret = request_threaded_irq(rt5645->i2c->irq, NULL, rt5645_irq, 3423 ret = request_threaded_irq(rt5645->i2c->irq, NULL, rt5645_irq,
3435 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING 3424 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
3436 | IRQF_ONESHOT, "rt5645", rt5645); 3425 | IRQF_ONESHOT, "rt5645", rt5645);
3437 if (ret) 3426 if (ret) {
3438 dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret); 3427 dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret);
3428 goto err_enable;
3429 }
3439 } 3430 }
3440 3431
3441 return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5645, 3432 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5645,
3442 rt5645_dai, ARRAY_SIZE(rt5645_dai)); 3433 rt5645_dai, ARRAY_SIZE(rt5645_dai));
3434 if (ret)
3435 goto err_irq;
3436
3437 return 0;
3438
3439err_irq:
3440 if (rt5645->i2c->irq)
3441 free_irq(rt5645->i2c->irq, rt5645);
3442err_enable:
3443 regulator_bulk_disable(ARRAY_SIZE(rt5645->supplies), rt5645->supplies);
3444 return ret;
3443} 3445}
3444 3446
3445static int rt5645_i2c_remove(struct i2c_client *i2c) 3447static int rt5645_i2c_remove(struct i2c_client *i2c)
@@ -3452,18 +3454,31 @@ static int rt5645_i2c_remove(struct i2c_client *i2c)
3452 cancel_delayed_work_sync(&rt5645->jack_detect_work); 3454 cancel_delayed_work_sync(&rt5645->jack_detect_work);
3453 3455
3454 snd_soc_unregister_codec(&i2c->dev); 3456 snd_soc_unregister_codec(&i2c->dev);
3457 regulator_bulk_disable(ARRAY_SIZE(rt5645->supplies), rt5645->supplies);
3455 3458
3456 return 0; 3459 return 0;
3457} 3460}
3458 3461
3462static void rt5645_i2c_shutdown(struct i2c_client *i2c)
3463{
3464 struct rt5645_priv *rt5645 = i2c_get_clientdata(i2c);
3465
3466 regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3,
3467 RT5645_RING2_SLEEVE_GND, RT5645_RING2_SLEEVE_GND);
3468 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2, RT5645_CBJ_MN_JD,
3469 RT5645_CBJ_MN_JD);
3470 regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1, RT5645_CBJ_BST1_EN,
3471 0);
3472}
3473
3459static struct i2c_driver rt5645_i2c_driver = { 3474static struct i2c_driver rt5645_i2c_driver = {
3460 .driver = { 3475 .driver = {
3461 .name = "rt5645", 3476 .name = "rt5645",
3462 .owner = THIS_MODULE,
3463 .acpi_match_table = ACPI_PTR(rt5645_acpi_match), 3477 .acpi_match_table = ACPI_PTR(rt5645_acpi_match),
3464 }, 3478 },
3465 .probe = rt5645_i2c_probe, 3479 .probe = rt5645_i2c_probe,
3466 .remove = rt5645_i2c_remove, 3480 .remove = rt5645_i2c_remove,
3481 .shutdown = rt5645_i2c_shutdown,
3467 .id_table = rt5645_i2c_id, 3482 .id_table = rt5645_i2c_id,
3468}; 3483};
3469module_i2c_driver(rt5645_i2c_driver); 3484module_i2c_driver(rt5645_i2c_driver);
diff --git a/sound/soc/codecs/rt5645.h b/sound/soc/codecs/rt5645.h
index 0353a6a273ab..0e4cfc6ac649 100644
--- a/sound/soc/codecs/rt5645.h
+++ b/sound/soc/codecs/rt5645.h
@@ -1693,6 +1693,10 @@
1693#define RT5645_GP6_PIN_SFT 6 1693#define RT5645_GP6_PIN_SFT 6
1694#define RT5645_GP6_PIN_GPIO6 (0x0 << 6) 1694#define RT5645_GP6_PIN_GPIO6 (0x0 << 6)
1695#define RT5645_GP6_PIN_DMIC2_SDA (0x1 << 6) 1695#define RT5645_GP6_PIN_DMIC2_SDA (0x1 << 6)
1696#define RT5645_I2S2_DAC_PIN_MASK (0x1 << 4)
1697#define RT5645_I2S2_DAC_PIN_SFT 4
1698#define RT5645_I2S2_DAC_PIN_I2S (0x0 << 4)
1699#define RT5645_I2S2_DAC_PIN_GPIO (0x1 << 4)
1696#define RT5645_GP8_PIN_MASK (0x1 << 3) 1700#define RT5645_GP8_PIN_MASK (0x1 << 3)
1697#define RT5645_GP8_PIN_SFT 3 1701#define RT5645_GP8_PIN_SFT 3
1698#define RT5645_GP8_PIN_GPIO8 (0x0 << 3) 1702#define RT5645_GP8_PIN_GPIO8 (0x0 << 3)
@@ -2111,6 +2115,7 @@ enum {
2111#define RT5645_JD_PSV_MODE (0x1 << 12) 2115#define RT5645_JD_PSV_MODE (0x1 << 12)
2112#define RT5645_IRQ_CLK_GATE_CTRL (0x1 << 11) 2116#define RT5645_IRQ_CLK_GATE_CTRL (0x1 << 11)
2113#define RT5645_MICINDET_MANU (0x1 << 7) 2117#define RT5645_MICINDET_MANU (0x1 << 7)
2118#define RT5645_RING2_SLEEVE_GND (0x1 << 5)
2114 2119
2115/* Vendor ID (0xfd) */ 2120/* Vendor ID (0xfd) */
2116#define RT5645_VER_C 0x2 2121#define RT5645_VER_C 0x2
@@ -2177,32 +2182,6 @@ enum {
2177int rt5645_sel_asrc_clk_src(struct snd_soc_codec *codec, 2182int rt5645_sel_asrc_clk_src(struct snd_soc_codec *codec,
2178 unsigned int filter_mask, unsigned int clk_src); 2183 unsigned int filter_mask, unsigned int clk_src);
2179 2184
2180struct rt5645_priv {
2181 struct snd_soc_codec *codec;
2182 struct rt5645_platform_data pdata;
2183 struct regmap *regmap;
2184 struct i2c_client *i2c;
2185 struct gpio_desc *gpiod_hp_det;
2186 struct snd_soc_jack *hp_jack;
2187 struct snd_soc_jack *mic_jack;
2188 struct snd_soc_jack *btn_jack;
2189 struct delayed_work jack_detect_work;
2190
2191 int codec_type;
2192 int sysclk;
2193 int sysclk_src;
2194 int lrck[RT5645_AIFS];
2195 int bclk[RT5645_AIFS];
2196 int master[RT5645_AIFS];
2197
2198 int pll_src;
2199 int pll_in;
2200 int pll_out;
2201
2202 int jack_type;
2203 bool en_button_func;
2204};
2205
2206int rt5645_set_jack_detect(struct snd_soc_codec *codec, 2185int rt5645_set_jack_detect(struct snd_soc_codec *codec,
2207 struct snd_soc_jack *hp_jack, struct snd_soc_jack *mic_jack, 2186 struct snd_soc_jack *hp_jack, struct snd_soc_jack *mic_jack,
2208 struct snd_soc_jack *btn_jack); 2187 struct snd_soc_jack *btn_jack);
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c
index a3506e193abc..8f7159ba6ca2 100644
--- a/sound/soc/codecs/rt5651.c
+++ b/sound/soc/codecs/rt5651.c
@@ -46,7 +46,7 @@ static const struct regmap_range_cfg rt5651_ranges[] = {
46 .window_len = 0x1, }, 46 .window_len = 0x1, },
47}; 47};
48 48
49static struct reg_default init_list[] = { 49static const struct reg_sequence init_list[] = {
50 {RT5651_PR_BASE + 0x3d, 0x3e00}, 50 {RT5651_PR_BASE + 0x3d, 0x3e00},
51}; 51};
52 52
@@ -378,10 +378,11 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
378{ 378{
379 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 379 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
380 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); 380 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec);
381 int idx = -EINVAL; 381 int idx, rate;
382
383 idx = rl6231_calc_dmic_clk(rt5651->sysclk);
384 382
383 rate = rt5651->sysclk / rl6231_get_pre_div(rt5651->regmap,
384 RT5651_ADDA_CLK1, RT5651_I2S_PD1_SFT);
385 idx = rl6231_calc_dmic_clk(rate);
385 if (idx < 0) 386 if (idx < 0)
386 dev_err(codec->dev, "Failed to set DMIC clock\n"); 387 dev_err(codec->dev, "Failed to set DMIC clock\n");
387 else 388 else
@@ -1769,7 +1770,7 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
1769 regmap_read(rt5651->regmap, RT5651_DEVICE_ID, &ret); 1770 regmap_read(rt5651->regmap, RT5651_DEVICE_ID, &ret);
1770 if (ret != RT5651_DEVICE_ID_VALUE) { 1771 if (ret != RT5651_DEVICE_ID_VALUE) {
1771 dev_err(&i2c->dev, 1772 dev_err(&i2c->dev,
1772 "Device with ID register %x is not rt5651\n", ret); 1773 "Device with ID register %#x is not rt5651\n", ret);
1773 return -ENODEV; 1774 return -ENODEV;
1774 } 1775 }
1775 1776
@@ -1806,7 +1807,6 @@ static int rt5651_i2c_remove(struct i2c_client *i2c)
1806static struct i2c_driver rt5651_i2c_driver = { 1807static struct i2c_driver rt5651_i2c_driver = {
1807 .driver = { 1808 .driver = {
1808 .name = "rt5651", 1809 .name = "rt5651",
1809 .owner = THIS_MODULE,
1810 }, 1810 },
1811 .probe = rt5651_i2c_probe, 1811 .probe = rt5651_i2c_probe,
1812 .remove = rt5651_i2c_remove, 1812 .remove = rt5651_i2c_remove,
diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
index a9123d414178..177748af94fc 100644
--- a/sound/soc/codecs/rt5670.c
+++ b/sound/soc/codecs/rt5670.c
@@ -51,7 +51,7 @@ static const struct regmap_range_cfg rt5670_ranges[] = {
51 .window_len = 0x1, }, 51 .window_len = 0x1, },
52}; 52};
53 53
54static const struct reg_default init_list[] = { 54static const struct reg_sequence init_list[] = {
55 { RT5670_PR_BASE + 0x14, 0x9a8a }, 55 { RT5670_PR_BASE + 0x14, 0x9a8a },
56 { RT5670_PR_BASE + 0x38, 0x3ba1 }, 56 { RT5670_PR_BASE + 0x38, 0x3ba1 },
57 { RT5670_PR_BASE + 0x3d, 0x3640 }, 57 { RT5670_PR_BASE + 0x3d, 0x3640 },
@@ -683,10 +683,11 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
683{ 683{
684 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 684 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
685 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); 685 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec);
686 int idx = -EINVAL; 686 int idx, rate;
687
688 idx = rl6231_calc_dmic_clk(rt5670->sysclk);
689 687
688 rate = rt5670->sysclk / rl6231_get_pre_div(rt5670->regmap,
689 RT5670_ADDA_CLK1, RT5670_I2S_PD1_SFT);
690 idx = rl6231_calc_dmic_clk(rate);
690 if (idx < 0) 691 if (idx < 0)
691 dev_err(codec->dev, "Failed to set DMIC clock\n"); 692 dev_err(codec->dev, "Failed to set DMIC clock\n");
692 else 693 else
@@ -2720,7 +2721,7 @@ static int rt5670_resume(struct snd_soc_codec *codec)
2720#define RT5670_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ 2721#define RT5670_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
2721 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) 2722 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
2722 2723
2723static struct snd_soc_dai_ops rt5670_aif_dai_ops = { 2724static const struct snd_soc_dai_ops rt5670_aif_dai_ops = {
2724 .hw_params = rt5670_hw_params, 2725 .hw_params = rt5670_hw_params,
2725 .set_fmt = rt5670_set_dai_fmt, 2726 .set_fmt = rt5670_set_dai_fmt,
2726 .set_sysclk = rt5670_set_dai_sysclk, 2727 .set_sysclk = rt5670_set_dai_sysclk,
@@ -2863,7 +2864,7 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
2863 regmap_read(rt5670->regmap, RT5670_VENDOR_ID2, &val); 2864 regmap_read(rt5670->regmap, RT5670_VENDOR_ID2, &val);
2864 if (val != RT5670_DEVICE_ID) { 2865 if (val != RT5670_DEVICE_ID) {
2865 dev_err(&i2c->dev, 2866 dev_err(&i2c->dev,
2866 "Device with ID register %x is not rt5670/72\n", val); 2867 "Device with ID register %#x is not rt5670/72\n", val);
2867 return -ENODEV; 2868 return -ENODEV;
2868 } 2869 }
2869 2870
@@ -3043,7 +3044,6 @@ static int rt5670_i2c_remove(struct i2c_client *i2c)
3043static struct i2c_driver rt5670_i2c_driver = { 3044static struct i2c_driver rt5670_i2c_driver = {
3044 .driver = { 3045 .driver = {
3045 .name = "rt5670", 3046 .name = "rt5670",
3046 .owner = THIS_MODULE,
3047 .acpi_match_table = ACPI_PTR(rt5670_acpi_match), 3047 .acpi_match_table = ACPI_PTR(rt5670_acpi_match),
3048 }, 3048 },
3049 .probe = rt5670_i2c_probe, 3049 .probe = rt5670_i2c_probe,
diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c
index ef6348cb9157..3505aafbade4 100644
--- a/sound/soc/codecs/rt5677-spi.c
+++ b/sound/soc/codecs/rt5677-spi.c
@@ -31,84 +31,197 @@
31 31
32#include "rt5677-spi.h" 32#include "rt5677-spi.h"
33 33
34#define RT5677_SPI_BURST_LEN 240
35#define RT5677_SPI_HEADER 5
36#define RT5677_SPI_FREQ 6000000
37
38/* The AddressPhase and DataPhase of SPI commands are MSB first on the wire.
39 * DataPhase word size of 16-bit commands is 2 bytes.
40 * DataPhase word size of 32-bit commands is 4 bytes.
41 * DataPhase word size of burst commands is 8 bytes.
42 * The DSP CPU is little-endian.
43 */
44#define RT5677_SPI_WRITE_BURST 0x5
45#define RT5677_SPI_READ_BURST 0x4
46#define RT5677_SPI_WRITE_32 0x3
47#define RT5677_SPI_READ_32 0x2
48#define RT5677_SPI_WRITE_16 0x1
49#define RT5677_SPI_READ_16 0x0
50
34static struct spi_device *g_spi; 51static struct spi_device *g_spi;
52static DEFINE_MUTEX(spi_mutex);
35 53
36/** 54/* Select a suitable transfer command for the next transfer to ensure
37 * rt5677_spi_write - Write data to SPI. 55 * the transfer address is always naturally aligned while minimizing
38 * @txbuf: Data Buffer for writing. 56 * the total number of transfers required.
39 * @len: Data length. 57 *
58 * 3 transfer commands are available:
59 * RT5677_SPI_READ/WRITE_16: Transfer 2 bytes
60 * RT5677_SPI_READ/WRITE_32: Transfer 4 bytes
61 * RT5677_SPI_READ/WRITE_BURST: Transfer any multiples of 8 bytes
62 *
63 * For example, reading 260 bytes at 0x60030002 uses the following commands:
64 * 0x60030002 RT5677_SPI_READ_16 2 bytes
65 * 0x60030004 RT5677_SPI_READ_32 4 bytes
66 * 0x60030008 RT5677_SPI_READ_BURST 240 bytes
67 * 0x600300F8 RT5677_SPI_READ_BURST 8 bytes
68 * 0x60030100 RT5677_SPI_READ_32 4 bytes
69 * 0x60030104 RT5677_SPI_READ_16 2 bytes
40 * 70 *
71 * Input:
72 * @read: true for read commands; false for write commands
73 * @align: alignment of the next transfer address
74 * @remain: number of bytes remaining to transfer
41 * 75 *
42 * Returns true for success. 76 * Output:
77 * @len: number of bytes to transfer with the selected command
78 * Returns the selected command
43 */ 79 */
44int rt5677_spi_write(u8 *txbuf, size_t len) 80static u8 rt5677_spi_select_cmd(bool read, u32 align, u32 remain, u32 *len)
45{ 81{
46 int status; 82 u8 cmd;
47 83
48 status = spi_write(g_spi, txbuf, len); 84 if (align == 2 || align == 6 || remain == 2) {
49 85 cmd = RT5677_SPI_READ_16;
50 if (status) 86 *len = 2;
51 dev_err(&g_spi->dev, "rt5677_spi_write error %d\n", status); 87 } else if (align == 4 || remain <= 6) {
52 88 cmd = RT5677_SPI_READ_32;
53 return status; 89 *len = 4;
90 } else {
91 cmd = RT5677_SPI_READ_BURST;
92 *len = min_t(u32, remain & ~7, RT5677_SPI_BURST_LEN);
93 }
94 return read ? cmd : cmd + 1;
54} 95}
55EXPORT_SYMBOL_GPL(rt5677_spi_write);
56 96
57/** 97/* Copy dstlen bytes from src to dst, while reversing byte order for each word.
58 * rt5677_spi_burst_write - Write data to SPI by rt5677 dsp memory address. 98 * If srclen < dstlen, zeros are padded.
59 * @addr: Start address.
60 * @txbuf: Data Buffer for writng.
61 * @len: Data length, it must be a multiple of 8.
62 *
63 *
64 * Returns true for success.
65 */ 99 */
66int rt5677_spi_burst_write(u32 addr, const struct firmware *fw) 100static void rt5677_spi_reverse(u8 *dst, u32 dstlen, const u8 *src, u32 srclen)
67{ 101{
68 u8 spi_cmd = RT5677_SPI_CMD_BURST_WRITE; 102 u32 w, i, si;
69 u8 *write_buf; 103 u32 word_size = min_t(u32, dstlen, 8);
70 unsigned int i, end, offset = 0; 104
71 105 for (w = 0; w < dstlen; w += word_size) {
72 write_buf = kmalloc(RT5677_SPI_BUF_LEN + 6, GFP_KERNEL); 106 for (i = 0; i < word_size; i++) {
73 107 si = w + word_size - i - 1;
74 if (write_buf == NULL) 108 dst[w + i] = si < srclen ? src[si] : 0;
75 return -ENOMEM;
76
77 while (offset < fw->size) {
78 if (offset + RT5677_SPI_BUF_LEN <= fw->size)
79 end = RT5677_SPI_BUF_LEN;
80 else
81 end = fw->size % RT5677_SPI_BUF_LEN;
82
83 write_buf[0] = spi_cmd;
84 write_buf[1] = ((addr + offset) & 0xff000000) >> 24;
85 write_buf[2] = ((addr + offset) & 0x00ff0000) >> 16;
86 write_buf[3] = ((addr + offset) & 0x0000ff00) >> 8;
87 write_buf[4] = ((addr + offset) & 0x000000ff) >> 0;
88
89 for (i = 0; i < end; i += 8) {
90 write_buf[i + 12] = fw->data[offset + i + 0];
91 write_buf[i + 11] = fw->data[offset + i + 1];
92 write_buf[i + 10] = fw->data[offset + i + 2];
93 write_buf[i + 9] = fw->data[offset + i + 3];
94 write_buf[i + 8] = fw->data[offset + i + 4];
95 write_buf[i + 7] = fw->data[offset + i + 5];
96 write_buf[i + 6] = fw->data[offset + i + 6];
97 write_buf[i + 5] = fw->data[offset + i + 7];
98 } 109 }
110 }
111}
99 112
100 write_buf[end + 5] = spi_cmd; 113/* Read DSP address space using SPI. addr and len have to be 2-byte aligned. */
114int rt5677_spi_read(u32 addr, void *rxbuf, size_t len)
115{
116 u32 offset;
117 int status = 0;
118 struct spi_transfer t[2];
119 struct spi_message m;
120 /* +4 bytes is for the DummyPhase following the AddressPhase */
121 u8 header[RT5677_SPI_HEADER + 4];
122 u8 body[RT5677_SPI_BURST_LEN];
123 u8 spi_cmd;
124 u8 *cb = rxbuf;
125
126 if (!g_spi)
127 return -ENODEV;
128
129 if ((addr & 1) || (len & 1)) {
130 dev_err(&g_spi->dev, "Bad read align 0x%x(%zu)\n", addr, len);
131 return -EACCES;
132 }
101 133
102 rt5677_spi_write(write_buf, end + 6); 134 memset(t, 0, sizeof(t));
135 t[0].tx_buf = header;
136 t[0].len = sizeof(header);
137 t[0].speed_hz = RT5677_SPI_FREQ;
138 t[1].rx_buf = body;
139 t[1].speed_hz = RT5677_SPI_FREQ;
140 spi_message_init_with_transfers(&m, t, ARRAY_SIZE(t));
141
142 for (offset = 0; offset < len; offset += t[1].len) {
143 spi_cmd = rt5677_spi_select_cmd(true, (addr + offset) & 7,
144 len - offset, &t[1].len);
145
146 /* Construct SPI message header */
147 header[0] = spi_cmd;
148 header[1] = ((addr + offset) & 0xff000000) >> 24;
149 header[2] = ((addr + offset) & 0x00ff0000) >> 16;
150 header[3] = ((addr + offset) & 0x0000ff00) >> 8;
151 header[4] = ((addr + offset) & 0x000000ff) >> 0;
152
153 mutex_lock(&spi_mutex);
154 status |= spi_sync(g_spi, &m);
155 mutex_unlock(&spi_mutex);
156
157 /* Copy data back to caller buffer */
158 rt5677_spi_reverse(cb + offset, t[1].len, body, t[1].len);
159 }
160 return status;
161}
162EXPORT_SYMBOL_GPL(rt5677_spi_read);
103 163
104 offset += RT5677_SPI_BUF_LEN; 164/* Write DSP address space using SPI. addr has to be 2-byte aligned.
165 * If len is not 2-byte aligned, an extra byte of zero is written at the end
166 * as padding.
167 */
168int rt5677_spi_write(u32 addr, const void *txbuf, size_t len)
169{
170 u32 offset, len_with_pad = len;
171 int status = 0;
172 struct spi_transfer t;
173 struct spi_message m;
174 /* +1 byte is for the DummyPhase following the DataPhase */
175 u8 buf[RT5677_SPI_HEADER + RT5677_SPI_BURST_LEN + 1];
176 u8 *body = buf + RT5677_SPI_HEADER;
177 u8 spi_cmd;
178 const u8 *cb = txbuf;
179
180 if (!g_spi)
181 return -ENODEV;
182
183 if (addr & 1) {
184 dev_err(&g_spi->dev, "Bad write align 0x%x(%zu)\n", addr, len);
185 return -EACCES;
105 } 186 }
106 187
107 kfree(write_buf); 188 if (len & 1)
189 len_with_pad = len + 1;
190
191 memset(&t, 0, sizeof(t));
192 t.tx_buf = buf;
193 t.speed_hz = RT5677_SPI_FREQ;
194 spi_message_init_with_transfers(&m, &t, 1);
195
196 for (offset = 0; offset < len_with_pad;) {
197 spi_cmd = rt5677_spi_select_cmd(false, (addr + offset) & 7,
198 len_with_pad - offset, &t.len);
199
200 /* Construct SPI message header */
201 buf[0] = spi_cmd;
202 buf[1] = ((addr + offset) & 0xff000000) >> 24;
203 buf[2] = ((addr + offset) & 0x00ff0000) >> 16;
204 buf[3] = ((addr + offset) & 0x0000ff00) >> 8;
205 buf[4] = ((addr + offset) & 0x000000ff) >> 0;
206
207 /* Fetch data from caller buffer */
208 rt5677_spi_reverse(body, t.len, cb + offset, len - offset);
209 offset += t.len;
210 t.len += RT5677_SPI_HEADER + 1;
211
212 mutex_lock(&spi_mutex);
213 status |= spi_sync(g_spi, &m);
214 mutex_unlock(&spi_mutex);
215 }
216 return status;
217}
218EXPORT_SYMBOL_GPL(rt5677_spi_write);
108 219
109 return 0; 220int rt5677_spi_write_firmware(u32 addr, const struct firmware *fw)
221{
222 return rt5677_spi_write(addr, fw->data, fw->size);
110} 223}
111EXPORT_SYMBOL_GPL(rt5677_spi_burst_write); 224EXPORT_SYMBOL_GPL(rt5677_spi_write_firmware);
112 225
113static int rt5677_spi_probe(struct spi_device *spi) 226static int rt5677_spi_probe(struct spi_device *spi)
114{ 227{
diff --git a/sound/soc/codecs/rt5677-spi.h b/sound/soc/codecs/rt5677-spi.h
index ec41b2b3b2ca..662db16cfb6a 100644
--- a/sound/soc/codecs/rt5677-spi.h
+++ b/sound/soc/codecs/rt5677-spi.h
@@ -12,10 +12,8 @@
12#ifndef __RT5677_SPI_H__ 12#ifndef __RT5677_SPI_H__
13#define __RT5677_SPI_H__ 13#define __RT5677_SPI_H__
14 14
15#define RT5677_SPI_BUF_LEN 240 15int rt5677_spi_read(u32 addr, void *rxbuf, size_t len);
16#define RT5677_SPI_CMD_BURST_WRITE 0x05 16int rt5677_spi_write(u32 addr, const void *txbuf, size_t len);
17 17int rt5677_spi_write_firmware(u32 addr, const struct firmware *fw);
18int rt5677_spi_write(u8 *txbuf, size_t len);
19int rt5677_spi_burst_write(u32 addr, const struct firmware *fw);
20 18
21#endif /* __RT5677_SPI_H__ */ 19#endif /* __RT5677_SPI_H__ */
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 31d969ac1192..b7de51b09c35 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -15,13 +15,12 @@
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/of_gpio.h>
19#include <linux/regmap.h> 18#include <linux/regmap.h>
20#include <linux/i2c.h> 19#include <linux/i2c.h>
21#include <linux/platform_device.h> 20#include <linux/platform_device.h>
22#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
23#include <linux/firmware.h> 22#include <linux/firmware.h>
24#include <linux/gpio.h> 23#include <linux/property.h>
25#include <sound/core.h> 24#include <sound/core.h>
26#include <sound/pcm.h> 25#include <sound/pcm.h>
27#include <sound/pcm_params.h> 26#include <sound/pcm_params.h>
@@ -54,7 +53,7 @@ static const struct regmap_range_cfg rt5677_ranges[] = {
54 }, 53 },
55}; 54};
56 55
57static const struct reg_default init_list[] = { 56static const struct reg_sequence init_list[] = {
58 {RT5677_ASRC_12, 0x0018}, 57 {RT5677_ASRC_12, 0x0018},
59 {RT5677_PR_BASE + 0x3d, 0x364d}, 58 {RT5677_PR_BASE + 0x3d, 0x364d},
60 {RT5677_PR_BASE + 0x17, 0x4fc0}, 59 {RT5677_PR_BASE + 0x17, 0x4fc0},
@@ -746,14 +745,14 @@ static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on)
746 ret = request_firmware(&rt5677->fw1, RT5677_FIRMWARE1, 745 ret = request_firmware(&rt5677->fw1, RT5677_FIRMWARE1,
747 codec->dev); 746 codec->dev);
748 if (ret == 0) { 747 if (ret == 0) {
749 rt5677_spi_burst_write(0x50000000, rt5677->fw1); 748 rt5677_spi_write_firmware(0x50000000, rt5677->fw1);
750 release_firmware(rt5677->fw1); 749 release_firmware(rt5677->fw1);
751 } 750 }
752 751
753 ret = request_firmware(&rt5677->fw2, RT5677_FIRMWARE2, 752 ret = request_firmware(&rt5677->fw2, RT5677_FIRMWARE2,
754 codec->dev); 753 codec->dev);
755 if (ret == 0) { 754 if (ret == 0) {
756 rt5677_spi_burst_write(0x60000000, rt5677->fw2); 755 rt5677_spi_write_firmware(0x60000000, rt5677->fw2);
757 release_firmware(rt5677->fw2); 756 release_firmware(rt5677->fw2);
758 } 757 }
759 758
@@ -917,8 +916,11 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
917{ 916{
918 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 917 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
919 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 918 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
920 int idx = rl6231_calc_dmic_clk(rt5677->lrck[RT5677_AIF1] << 8); 919 int idx, rate;
921 920
921 rate = rt5677->sysclk / rl6231_get_pre_div(rt5677->regmap,
922 RT5677_CLK_TREE_CTRL1, RT5677_I2S_PD1_SFT);
923 idx = rl6231_calc_dmic_clk(rate);
922 if (idx < 0) 924 if (idx < 0)
923 dev_err(codec->dev, "Failed to set DMIC clock\n"); 925 dev_err(codec->dev, "Failed to set DMIC clock\n");
924 else 926 else
@@ -4764,10 +4766,8 @@ static int rt5677_remove(struct snd_soc_codec *codec)
4764 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 4766 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4765 4767
4766 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); 4768 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
4767 if (gpio_is_valid(rt5677->pow_ldo2)) 4769 gpiod_set_value_cansleep(rt5677->pow_ldo2, 0);
4768 gpio_set_value_cansleep(rt5677->pow_ldo2, 0); 4770 gpiod_set_value_cansleep(rt5677->reset_pin, 0);
4769 if (gpio_is_valid(rt5677->reset_pin))
4770 gpio_set_value_cansleep(rt5677->reset_pin, 0);
4771 4771
4772 return 0; 4772 return 0;
4773} 4773}
@@ -4781,10 +4781,8 @@ static int rt5677_suspend(struct snd_soc_codec *codec)
4781 regcache_cache_only(rt5677->regmap, true); 4781 regcache_cache_only(rt5677->regmap, true);
4782 regcache_mark_dirty(rt5677->regmap); 4782 regcache_mark_dirty(rt5677->regmap);
4783 4783
4784 if (gpio_is_valid(rt5677->pow_ldo2)) 4784 gpiod_set_value_cansleep(rt5677->pow_ldo2, 0);
4785 gpio_set_value_cansleep(rt5677->pow_ldo2, 0); 4785 gpiod_set_value_cansleep(rt5677->reset_pin, 0);
4786 if (gpio_is_valid(rt5677->reset_pin))
4787 gpio_set_value_cansleep(rt5677->reset_pin, 0);
4788 } 4786 }
4789 4787
4790 return 0; 4788 return 0;
@@ -4795,12 +4793,9 @@ static int rt5677_resume(struct snd_soc_codec *codec)
4795 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 4793 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4796 4794
4797 if (!rt5677->dsp_vad_en) { 4795 if (!rt5677->dsp_vad_en) {
4798 if (gpio_is_valid(rt5677->pow_ldo2)) 4796 gpiod_set_value_cansleep(rt5677->pow_ldo2, 1);
4799 gpio_set_value_cansleep(rt5677->pow_ldo2, 1); 4797 gpiod_set_value_cansleep(rt5677->reset_pin, 1);
4800 if (gpio_is_valid(rt5677->reset_pin)) 4798 if (rt5677->pow_ldo2 || rt5677->reset_pin)
4801 gpio_set_value_cansleep(rt5677->reset_pin, 1);
4802 if (gpio_is_valid(rt5677->pow_ldo2) ||
4803 gpio_is_valid(rt5677->reset_pin))
4804 msleep(10); 4799 msleep(10);
4805 4800
4806 regcache_cache_only(rt5677->regmap, false); 4801 regcache_cache_only(rt5677->regmap, false);
@@ -4863,7 +4858,7 @@ static int rt5677_write(void *context, unsigned int reg, unsigned int val)
4863#define RT5677_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ 4858#define RT5677_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
4864 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) 4859 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
4865 4860
4866static struct snd_soc_dai_ops rt5677_aif_dai_ops = { 4861static const struct snd_soc_dai_ops rt5677_aif_dai_ops = {
4867 .hw_params = rt5677_hw_params, 4862 .hw_params = rt5677_hw_params,
4868 .set_fmt = rt5677_set_dai_fmt, 4863 .set_fmt = rt5677_set_dai_fmt,
4869 .set_sysclk = rt5677_set_dai_sysclk, 4864 .set_sysclk = rt5677_set_dai_sysclk,
@@ -5024,45 +5019,29 @@ static const struct i2c_device_id rt5677_i2c_id[] = {
5024}; 5019};
5025MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); 5020MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
5026 5021
5027static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) 5022static void rt5677_read_device_properties(struct rt5677_priv *rt5677,
5023 struct device *dev)
5028{ 5024{
5029 rt5677->pdata.in1_diff = of_property_read_bool(np, 5025 rt5677->pdata.in1_diff = device_property_read_bool(dev,
5030 "realtek,in1-differential"); 5026 "realtek,in1-differential");
5031 rt5677->pdata.in2_diff = of_property_read_bool(np, 5027 rt5677->pdata.in2_diff = device_property_read_bool(dev,
5032 "realtek,in2-differential"); 5028 "realtek,in2-differential");
5033 rt5677->pdata.lout1_diff = of_property_read_bool(np, 5029 rt5677->pdata.lout1_diff = device_property_read_bool(dev,
5034 "realtek,lout1-differential"); 5030 "realtek,lout1-differential");
5035 rt5677->pdata.lout2_diff = of_property_read_bool(np, 5031 rt5677->pdata.lout2_diff = device_property_read_bool(dev,
5036 "realtek,lout2-differential"); 5032 "realtek,lout2-differential");
5037 rt5677->pdata.lout3_diff = of_property_read_bool(np, 5033 rt5677->pdata.lout3_diff = device_property_read_bool(dev,
5038 "realtek,lout3-differential"); 5034 "realtek,lout3-differential");
5039 5035
5040 rt5677->pow_ldo2 = of_get_named_gpio(np, 5036 device_property_read_u8_array(dev, "realtek,gpio-config",
5041 "realtek,pow-ldo2-gpio", 0); 5037 rt5677->pdata.gpio_config, RT5677_GPIO_NUM);
5042 rt5677->reset_pin = of_get_named_gpio(np, 5038
5043 "realtek,reset-gpio", 0); 5039 device_property_read_u32(dev, "realtek,jd1-gpio",
5044 5040 &rt5677->pdata.jd1_gpio);
5045 /* 5041 device_property_read_u32(dev, "realtek,jd2-gpio",
5046 * POW_LDO2 is optional (it may be statically tied on the board). 5042 &rt5677->pdata.jd2_gpio);
5047 * -ENOENT means that the property doesn't exist, i.e. there is no 5043 device_property_read_u32(dev, "realtek,jd3-gpio",
5048 * GPIO, so is not an error. Any other error code means the property 5044 &rt5677->pdata.jd3_gpio);
5049 * exists, but could not be parsed.
5050 */
5051 if (!gpio_is_valid(rt5677->pow_ldo2) &&
5052 (rt5677->pow_ldo2 != -ENOENT))
5053 return rt5677->pow_ldo2;
5054 if (!gpio_is_valid(rt5677->reset_pin) &&
5055 (rt5677->reset_pin != -ENOENT))
5056 return rt5677->reset_pin;
5057
5058 of_property_read_u8_array(np, "realtek,gpio-config",
5059 rt5677->pdata.gpio_config, RT5677_GPIO_NUM);
5060
5061 of_property_read_u32(np, "realtek,jd1-gpio", &rt5677->pdata.jd1_gpio);
5062 of_property_read_u32(np, "realtek,jd2-gpio", &rt5677->pdata.jd2_gpio);
5063 of_property_read_u32(np, "realtek,jd3-gpio", &rt5677->pdata.jd3_gpio);
5064
5065 return 0;
5066} 5045}
5067 5046
5068static struct regmap_irq rt5677_irqs[] = { 5047static struct regmap_irq rt5677_irqs[] = {
@@ -5145,43 +5124,29 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
5145 5124
5146 if (pdata) 5125 if (pdata)
5147 rt5677->pdata = *pdata; 5126 rt5677->pdata = *pdata;
5127 else
5128 rt5677_read_device_properties(rt5677, &i2c->dev);
5148 5129
5149 if (i2c->dev.of_node) { 5130 /* pow-ldo2 and reset are optional. The codec pins may be statically
5150 ret = rt5677_parse_dt(rt5677, i2c->dev.of_node); 5131 * connected on the board without gpios. If the gpio device property
5151 if (ret) { 5132 * isn't specified, devm_gpiod_get_optional returns NULL.
5152 dev_err(&i2c->dev, "Failed to parse device tree: %d\n", 5133 */
5153 ret); 5134 rt5677->pow_ldo2 = devm_gpiod_get_optional(&i2c->dev,
5154 return ret; 5135 "realtek,pow-ldo2", GPIOD_OUT_HIGH);
5155 } 5136 if (IS_ERR(rt5677->pow_ldo2)) {
5156 } else { 5137 ret = PTR_ERR(rt5677->pow_ldo2);
5157 rt5677->pow_ldo2 = -EINVAL; 5138 dev_err(&i2c->dev, "Failed to request POW_LDO2: %d\n", ret);
5158 rt5677->reset_pin = -EINVAL; 5139 return ret;
5159 }
5160
5161 if (gpio_is_valid(rt5677->pow_ldo2)) {
5162 ret = devm_gpio_request_one(&i2c->dev, rt5677->pow_ldo2,
5163 GPIOF_OUT_INIT_HIGH,
5164 "RT5677 POW_LDO2");
5165 if (ret < 0) {
5166 dev_err(&i2c->dev, "Failed to request POW_LDO2 %d: %d\n",
5167 rt5677->pow_ldo2, ret);
5168 return ret;
5169 }
5170 } 5140 }
5171 5141 rt5677->reset_pin = devm_gpiod_get_optional(&i2c->dev,
5172 if (gpio_is_valid(rt5677->reset_pin)) { 5142 "realtek,reset", GPIOD_OUT_HIGH);
5173 ret = devm_gpio_request_one(&i2c->dev, rt5677->reset_pin, 5143 if (IS_ERR(rt5677->reset_pin)) {
5174 GPIOF_OUT_INIT_HIGH, 5144 ret = PTR_ERR(rt5677->reset_pin);
5175 "RT5677 RESET"); 5145 dev_err(&i2c->dev, "Failed to request RESET: %d\n", ret);
5176 if (ret < 0) { 5146 return ret;
5177 dev_err(&i2c->dev, "Failed to request RESET %d: %d\n",
5178 rt5677->reset_pin, ret);
5179 return ret;
5180 }
5181 } 5147 }
5182 5148
5183 if (gpio_is_valid(rt5677->pow_ldo2) || 5149 if (rt5677->pow_ldo2 || rt5677->reset_pin) {
5184 gpio_is_valid(rt5677->reset_pin)) {
5185 /* Wait a while until I2C bus becomes available. The datasheet 5150 /* Wait a while until I2C bus becomes available. The datasheet
5186 * does not specify the exact we should wait but startup 5151 * does not specify the exact we should wait but startup
5187 * sequence mentiones at least a few milliseconds. 5152 * sequence mentiones at least a few milliseconds.
@@ -5209,7 +5174,7 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
5209 regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val); 5174 regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val);
5210 if (val != RT5677_DEVICE_ID) { 5175 if (val != RT5677_DEVICE_ID) {
5211 dev_err(&i2c->dev, 5176 dev_err(&i2c->dev,
5212 "Device with ID register %x is not rt5677\n", val); 5177 "Device with ID register %#x is not rt5677\n", val);
5213 return -ENODEV; 5178 return -ENODEV;
5214 } 5179 }
5215 5180
@@ -5273,7 +5238,6 @@ static int rt5677_i2c_remove(struct i2c_client *i2c)
5273static struct i2c_driver rt5677_i2c_driver = { 5238static struct i2c_driver rt5677_i2c_driver = {
5274 .driver = { 5239 .driver = {
5275 .name = "rt5677", 5240 .name = "rt5677",
5276 .owner = THIS_MODULE,
5277 }, 5241 },
5278 .probe = rt5677_i2c_probe, 5242 .probe = rt5677_i2c_probe,
5279 .remove = rt5677_i2c_remove, 5243 .remove = rt5677_i2c_remove,
diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h
index 7eca38a23255..d46855a42c40 100644
--- a/sound/soc/codecs/rt5677.h
+++ b/sound/soc/codecs/rt5677.h
@@ -14,6 +14,7 @@
14 14
15#include <sound/rt5677.h> 15#include <sound/rt5677.h>
16#include <linux/gpio/driver.h> 16#include <linux/gpio/driver.h>
17#include <linux/gpio/consumer.h>
17 18
18/* Info */ 19/* Info */
19#define RT5677_RESET 0x00 20#define RT5677_RESET 0x00
@@ -1775,8 +1776,8 @@ struct rt5677_priv {
1775 int pll_src; 1776 int pll_src;
1776 int pll_in; 1777 int pll_in;
1777 int pll_out; 1778 int pll_out;
1778 int pow_ldo2; /* POW_LDO2 pin */ 1779 struct gpio_desc *pow_ldo2; /* POW_LDO2 pin */
1779 int reset_pin; /* RESET pin */ 1780 struct gpio_desc *reset_pin; /* RESET pin */
1780 enum rt5677_type type; 1781 enum rt5677_type type;
1781#ifdef CONFIG_GPIOLIB 1782#ifdef CONFIG_GPIOLIB
1782 struct gpio_chip gpio_chip; 1783 struct gpio_chip gpio_chip;
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index e673f6ceb521..f3e646757215 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -1601,7 +1601,6 @@ MODULE_DEVICE_TABLE(of, sgtl5000_dt_ids);
1601static struct i2c_driver sgtl5000_i2c_driver = { 1601static struct i2c_driver sgtl5000_i2c_driver = {
1602 .driver = { 1602 .driver = {
1603 .name = "sgtl5000", 1603 .name = "sgtl5000",
1604 .owner = THIS_MODULE,
1605 .of_match_table = sgtl5000_dt_ids, 1604 .of_match_table = sgtl5000_dt_ids,
1606 }, 1605 },
1607 .probe = sgtl5000_i2c_probe, 1606 .probe = sgtl5000_i2c_probe,
diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h
index bd7a344bf8c5..1c317de26176 100644
--- a/sound/soc/codecs/sgtl5000.h
+++ b/sound/soc/codecs/sgtl5000.h
@@ -275,7 +275,7 @@
275#define SGTL5000_BIAS_CTRL_MASK 0x000e 275#define SGTL5000_BIAS_CTRL_MASK 0x000e
276#define SGTL5000_BIAS_CTRL_SHIFT 1 276#define SGTL5000_BIAS_CTRL_SHIFT 1
277#define SGTL5000_BIAS_CTRL_WIDTH 3 277#define SGTL5000_BIAS_CTRL_WIDTH 3
278#define SGTL5000_SMALL_POP 0 278#define SGTL5000_SMALL_POP 1
279 279
280/* 280/*
281 * SGTL5000_CHIP_MIC_CTRL 281 * SGTL5000_CHIP_MIC_CTRL
diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c
index 3e72964280c6..a8402d0af0ea 100644
--- a/sound/soc/codecs/si476x.c
+++ b/sound/soc/codecs/si476x.c
@@ -208,7 +208,7 @@ out:
208 return err; 208 return err;
209} 209}
210 210
211static struct snd_soc_dai_ops si476x_dai_ops = { 211static const struct snd_soc_dai_ops si476x_dai_ops = {
212 .hw_params = si476x_codec_hw_params, 212 .hw_params = si476x_codec_hw_params,
213 .set_fmt = si476x_codec_set_dai_fmt, 213 .set_fmt = si476x_codec_set_dai_fmt,
214}; 214};
diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c
index 29cb44256044..6bfd25c289d1 100644
--- a/sound/soc/codecs/sirf-audio-codec.c
+++ b/sound/soc/codecs/sirf-audio-codec.c
@@ -370,11 +370,11 @@ static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream,
370 return 0; 370 return 0;
371} 371}
372 372
373struct snd_soc_dai_ops sirf_audio_codec_dai_ops = { 373static const struct snd_soc_dai_ops sirf_audio_codec_dai_ops = {
374 .trigger = sirf_audio_codec_trigger, 374 .trigger = sirf_audio_codec_trigger,
375}; 375};
376 376
377struct snd_soc_dai_driver sirf_audio_codec_dai = { 377static struct snd_soc_dai_driver sirf_audio_codec_dai = {
378 .name = "sirf-audio-codec", 378 .name = "sirf-audio-codec",
379 .playback = { 379 .playback = {
380 .stream_name = "Playback", 380 .stream_name = "Playback",
diff --git a/sound/soc/codecs/ssm2518.c b/sound/soc/codecs/ssm2518.c
index f30de7639bb9..ddb0203fc649 100644
--- a/sound/soc/codecs/ssm2518.c
+++ b/sound/soc/codecs/ssm2518.c
@@ -806,6 +806,14 @@ static int ssm2518_i2c_remove(struct i2c_client *client)
806 return 0; 806 return 0;
807} 807}
808 808
809#ifdef CONFIG_OF
810static const struct of_device_id ssm2518_dt_ids[] = {
811 { .compatible = "adi,ssm2518", },
812 { }
813};
814MODULE_DEVICE_TABLE(of, ssm2518_dt_ids);
815#endif
816
809static const struct i2c_device_id ssm2518_i2c_ids[] = { 817static const struct i2c_device_id ssm2518_i2c_ids[] = {
810 { "ssm2518", 0 }, 818 { "ssm2518", 0 },
811 { } 819 { }
@@ -815,7 +823,7 @@ MODULE_DEVICE_TABLE(i2c, ssm2518_i2c_ids);
815static struct i2c_driver ssm2518_driver = { 823static struct i2c_driver ssm2518_driver = {
816 .driver = { 824 .driver = {
817 .name = "ssm2518", 825 .name = "ssm2518",
818 .owner = THIS_MODULE, 826 .of_match_table = of_match_ptr(ssm2518_dt_ids),
819 }, 827 },
820 .probe = ssm2518_i2c_probe, 828 .probe = ssm2518_i2c_probe,
821 .remove = ssm2518_i2c_remove, 829 .remove = ssm2518_i2c_remove,
diff --git a/sound/soc/codecs/ssm2602-i2c.c b/sound/soc/codecs/ssm2602-i2c.c
index 0d9779d6bfda..173ba85ff59e 100644
--- a/sound/soc/codecs/ssm2602-i2c.c
+++ b/sound/soc/codecs/ssm2602-i2c.c
@@ -52,7 +52,6 @@ MODULE_DEVICE_TABLE(of, ssm2602_of_match);
52static struct i2c_driver ssm2602_i2c_driver = { 52static struct i2c_driver ssm2602_i2c_driver = {
53 .driver = { 53 .driver = {
54 .name = "ssm2602", 54 .name = "ssm2602",
55 .owner = THIS_MODULE,
56 .of_match_table = ssm2602_of_match, 55 .of_match_table = ssm2602_of_match,
57 }, 56 },
58 .probe = ssm2602_i2c_probe, 57 .probe = ssm2602_i2c_probe,
diff --git a/sound/soc/codecs/ssm4567.c b/sound/soc/codecs/ssm4567.c
index 938d2cb6d78b..e619d5651b09 100644
--- a/sound/soc/codecs/ssm4567.c
+++ b/sound/soc/codecs/ssm4567.c
@@ -10,6 +10,7 @@
10 * Licensed under the GPL-2. 10 * Licensed under the GPL-2.
11 */ 11 */
12 12
13#include <linux/acpi.h>
13#include <linux/module.h> 14#include <linux/module.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/i2c.h> 16#include <linux/i2c.h>
@@ -173,6 +174,12 @@ static const struct snd_soc_dapm_widget ssm4567_dapm_widgets[] = {
173 SND_SOC_DAPM_SWITCH("Amplifier Boost", SSM4567_REG_POWER_CTRL, 3, 1, 174 SND_SOC_DAPM_SWITCH("Amplifier Boost", SSM4567_REG_POWER_CTRL, 3, 1,
174 &ssm4567_amplifier_boost_control), 175 &ssm4567_amplifier_boost_control),
175 176
177 SND_SOC_DAPM_SIGGEN("Sense"),
178
179 SND_SOC_DAPM_PGA("Current Sense", SSM4567_REG_POWER_CTRL, 4, 1, NULL, 0),
180 SND_SOC_DAPM_PGA("Voltage Sense", SSM4567_REG_POWER_CTRL, 5, 1, NULL, 0),
181 SND_SOC_DAPM_PGA("VBAT Sense", SSM4567_REG_POWER_CTRL, 6, 1, NULL, 0),
182
176 SND_SOC_DAPM_OUTPUT("OUT"), 183 SND_SOC_DAPM_OUTPUT("OUT"),
177}; 184};
178 185
@@ -180,6 +187,13 @@ static const struct snd_soc_dapm_route ssm4567_routes[] = {
180 { "OUT", NULL, "Amplifier Boost" }, 187 { "OUT", NULL, "Amplifier Boost" },
181 { "Amplifier Boost", "Switch", "DAC" }, 188 { "Amplifier Boost", "Switch", "DAC" },
182 { "OUT", NULL, "DAC" }, 189 { "OUT", NULL, "DAC" },
190
191 { "Current Sense", NULL, "Sense" },
192 { "Voltage Sense", NULL, "Sense" },
193 { "VBAT Sense", NULL, "Sense" },
194 { "Capture Sense", NULL, "Current Sense" },
195 { "Capture Sense", NULL, "Voltage Sense" },
196 { "Capture Sense", NULL, "VBAT Sense" },
183}; 197};
184 198
185static int ssm4567_hw_params(struct snd_pcm_substream *substream, 199static int ssm4567_hw_params(struct snd_pcm_substream *substream,
@@ -315,7 +329,13 @@ static int ssm4567_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
315 if (invert_fclk) 329 if (invert_fclk)
316 ctrl1 |= SSM4567_SAI_CTRL_1_FSYNC; 330 ctrl1 |= SSM4567_SAI_CTRL_1_FSYNC;
317 331
318 return regmap_write(ssm4567->regmap, SSM4567_REG_SAI_CTRL_1, ctrl1); 332 return regmap_update_bits(ssm4567->regmap, SSM4567_REG_SAI_CTRL_1,
333 SSM4567_SAI_CTRL_1_BCLK |
334 SSM4567_SAI_CTRL_1_FSYNC |
335 SSM4567_SAI_CTRL_1_LJ |
336 SSM4567_SAI_CTRL_1_TDM |
337 SSM4567_SAI_CTRL_1_PDM,
338 ctrl1);
319} 339}
320 340
321static int ssm4567_set_power(struct ssm4567 *ssm4567, bool enable) 341static int ssm4567_set_power(struct ssm4567 *ssm4567, bool enable)
@@ -381,6 +401,14 @@ static struct snd_soc_dai_driver ssm4567_dai = {
381 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | 401 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
382 SNDRV_PCM_FMTBIT_S32, 402 SNDRV_PCM_FMTBIT_S32,
383 }, 403 },
404 .capture = {
405 .stream_name = "Capture Sense",
406 .channels_min = 1,
407 .channels_max = 1,
408 .rates = SNDRV_PCM_RATE_8000_192000,
409 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
410 SNDRV_PCM_FMTBIT_S32,
411 },
384 .ops = &ssm4567_dai_ops, 412 .ops = &ssm4567_dai_ops,
385}; 413};
386 414
@@ -450,10 +478,20 @@ static const struct i2c_device_id ssm4567_i2c_ids[] = {
450}; 478};
451MODULE_DEVICE_TABLE(i2c, ssm4567_i2c_ids); 479MODULE_DEVICE_TABLE(i2c, ssm4567_i2c_ids);
452 480
481#ifdef CONFIG_ACPI
482
483static const struct acpi_device_id ssm4567_acpi_match[] = {
484 { "INT343B", 0 },
485 {},
486};
487MODULE_DEVICE_TABLE(acpi, ssm4567_acpi_match);
488
489#endif
490
453static struct i2c_driver ssm4567_driver = { 491static struct i2c_driver ssm4567_driver = {
454 .driver = { 492 .driver = {
455 .name = "ssm4567", 493 .name = "ssm4567",
456 .owner = THIS_MODULE, 494 .acpi_match_table = ACPI_PTR(ssm4567_acpi_match),
457 }, 495 },
458 .probe = ssm4567_i2c_probe, 496 .probe = ssm4567_i2c_probe,
459 .remove = ssm4567_i2c_remove, 497 .remove = ssm4567_i2c_remove,
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
index 60eff36260cb..a9844b2ac829 100644
--- a/sound/soc/codecs/sta32x.c
+++ b/sound/soc/codecs/sta32x.c
@@ -1144,7 +1144,6 @@ MODULE_DEVICE_TABLE(i2c, sta32x_i2c_id);
1144static struct i2c_driver sta32x_i2c_driver = { 1144static struct i2c_driver sta32x_i2c_driver = {
1145 .driver = { 1145 .driver = {
1146 .name = "sta32x", 1146 .name = "sta32x",
1147 .owner = THIS_MODULE,
1148 .of_match_table = of_match_ptr(st32x_dt_ids), 1147 .of_match_table = of_match_ptr(st32x_dt_ids),
1149 }, 1148 },
1150 .probe = sta32x_i2c_probe, 1149 .probe = sta32x_i2c_probe,
diff --git a/sound/soc/codecs/sta350.c b/sound/soc/codecs/sta350.c
index bd819a3f205a..33a4612f0a07 100644
--- a/sound/soc/codecs/sta350.c
+++ b/sound/soc/codecs/sta350.c
@@ -1264,7 +1264,6 @@ MODULE_DEVICE_TABLE(i2c, sta350_i2c_id);
1264static struct i2c_driver sta350_i2c_driver = { 1264static struct i2c_driver sta350_i2c_driver = {
1265 .driver = { 1265 .driver = {
1266 .name = "sta350", 1266 .name = "sta350",
1267 .owner = THIS_MODULE,
1268 .of_match_table = of_match_ptr(st350_dt_ids), 1267 .of_match_table = of_match_ptr(st350_dt_ids),
1269 }, 1268 },
1270 .probe = sta350_i2c_probe, 1269 .probe = sta350_i2c_probe,
diff --git a/sound/soc/codecs/sta529.c b/sound/soc/codecs/sta529.c
index 4f70378b2cfb..2cdaca943a8c 100644
--- a/sound/soc/codecs/sta529.c
+++ b/sound/soc/codecs/sta529.c
@@ -339,9 +339,6 @@ static int sta529_i2c_probe(struct i2c_client *i2c,
339 struct sta529 *sta529; 339 struct sta529 *sta529;
340 int ret; 340 int ret;
341 341
342 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
343 return -EINVAL;
344
345 sta529 = devm_kzalloc(&i2c->dev, sizeof(struct sta529), GFP_KERNEL); 342 sta529 = devm_kzalloc(&i2c->dev, sizeof(struct sta529), GFP_KERNEL);
346 if (!sta529) 343 if (!sta529)
347 return -ENOMEM; 344 return -ENOMEM;
@@ -379,7 +376,6 @@ MODULE_DEVICE_TABLE(i2c, sta529_i2c_id);
379static struct i2c_driver sta529_i2c_driver = { 376static struct i2c_driver sta529_i2c_driver = {
380 .driver = { 377 .driver = {
381 .name = "sta529", 378 .name = "sta529",
382 .owner = THIS_MODULE,
383 }, 379 },
384 .probe = sta529_i2c_probe, 380 .probe = sta529_i2c_probe,
385 .remove = sta529_i2c_remove, 381 .remove = sta529_i2c_remove,
diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c
index ed4cca7f6779..0945c51df003 100644
--- a/sound/soc/codecs/stac9766.c
+++ b/sound/soc/codecs/stac9766.c
@@ -28,6 +28,9 @@
28 28
29#include "stac9766.h" 29#include "stac9766.h"
30 30
31#define STAC9766_VENDOR_ID 0x83847666
32#define STAC9766_VENDOR_ID_MASK 0xffffffff
33
31/* 34/*
32 * STAC9766 register cache 35 * STAC9766 register cache
33 */ 36 */
@@ -239,45 +242,12 @@ static int stac9766_set_bias_level(struct snd_soc_codec *codec,
239 return 0; 242 return 0;
240} 243}
241 244
242static int stac9766_reset(struct snd_soc_codec *codec, int try_warm)
243{
244 struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
245
246 if (try_warm && soc_ac97_ops->warm_reset) {
247 soc_ac97_ops->warm_reset(ac97);
248 if (stac9766_ac97_read(codec, 0) == stac9766_reg[0])
249 return 1;
250 }
251
252 soc_ac97_ops->reset(ac97);
253 if (soc_ac97_ops->warm_reset)
254 soc_ac97_ops->warm_reset(ac97);
255 if (stac9766_ac97_read(codec, 0) != stac9766_reg[0])
256 return -EIO;
257 return 0;
258}
259
260static int stac9766_codec_resume(struct snd_soc_codec *codec) 245static int stac9766_codec_resume(struct snd_soc_codec *codec)
261{ 246{
262 struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); 247 struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
263 u16 id, reset;
264 248
265 reset = 0; 249 return snd_ac97_reset(ac97, true, STAC9766_VENDOR_ID,
266 /* give the codec an AC97 warm reset to start the link */ 250 STAC9766_VENDOR_ID_MASK);
267reset:
268 if (reset > 5) {
269 dev_err(codec->dev, "Failed to resume\n");
270 return -EIO;
271 }
272 ac97->bus->ops->warm_reset(ac97);
273 id = soc_ac97_ops->read(ac97, AC97_VENDOR_ID2);
274 if (id != 0x4c13) {
275 stac9766_reset(codec, 0);
276 reset++;
277 goto reset;
278 }
279
280 return 0;
281} 251}
282 252
283static const struct snd_soc_dai_ops stac9766_dai_ops_analog = { 253static const struct snd_soc_dai_ops stac9766_dai_ops_analog = {
@@ -330,28 +300,15 @@ static struct snd_soc_dai_driver stac9766_dai[] = {
330static int stac9766_codec_probe(struct snd_soc_codec *codec) 300static int stac9766_codec_probe(struct snd_soc_codec *codec)
331{ 301{
332 struct snd_ac97 *ac97; 302 struct snd_ac97 *ac97;
333 int ret = 0;
334 303
335 ac97 = snd_soc_new_ac97_codec(codec); 304 ac97 = snd_soc_new_ac97_codec(codec, STAC9766_VENDOR_ID,
305 STAC9766_VENDOR_ID_MASK);
336 if (IS_ERR(ac97)) 306 if (IS_ERR(ac97))
337 return PTR_ERR(ac97); 307 return PTR_ERR(ac97);
338 308
339 snd_soc_codec_set_drvdata(codec, ac97); 309 snd_soc_codec_set_drvdata(codec, ac97);
340 310
341 /* do a cold reset for the controller and then try
342 * a warm reset followed by an optional cold reset for codec */
343 stac9766_reset(codec, 0);
344 ret = stac9766_reset(codec, 1);
345 if (ret < 0) {
346 dev_err(codec->dev, "Failed to reset: AC97 link error\n");
347 goto codec_err;
348 }
349
350 return 0; 311 return 0;
351
352codec_err:
353 snd_soc_free_ac97_codec(ac97);
354 return ret;
355} 312}
356 313
357static int stac9766_codec_remove(struct snd_soc_codec *codec) 314static int stac9766_codec_remove(struct snd_soc_codec *codec)
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
index 4f25a7d0efa2..2f6a65afe5d2 100644
--- a/sound/soc/codecs/tas2552.c
+++ b/sound/soc/codecs/tas2552.c
@@ -38,7 +38,7 @@
38 38
39#include "tas2552.h" 39#include "tas2552.h"
40 40
41static struct reg_default tas2552_reg_defs[] = { 41static const struct reg_default tas2552_reg_defs[] = {
42 {TAS2552_CFG_1, 0x22}, 42 {TAS2552_CFG_1, 0x22},
43 {TAS2552_CFG_3, 0x80}, 43 {TAS2552_CFG_3, 0x80},
44 {TAS2552_DOUT, 0x00}, 44 {TAS2552_DOUT, 0x00},
@@ -520,7 +520,7 @@ static const struct dev_pm_ops tas2552_pm = {
520 NULL) 520 NULL)
521}; 521};
522 522
523static struct snd_soc_dai_ops tas2552_speaker_dai_ops = { 523static const struct snd_soc_dai_ops tas2552_speaker_dai_ops = {
524 .hw_params = tas2552_hw_params, 524 .hw_params = tas2552_hw_params,
525 .prepare = tas2552_prepare, 525 .prepare = tas2552_prepare,
526 .set_sysclk = tas2552_set_dai_sysclk, 526 .set_sysclk = tas2552_set_dai_sysclk,
@@ -769,7 +769,6 @@ MODULE_DEVICE_TABLE(of, tas2552_of_match);
769static struct i2c_driver tas2552_i2c_driver = { 769static struct i2c_driver tas2552_i2c_driver = {
770 .driver = { 770 .driver = {
771 .name = "tas2552", 771 .name = "tas2552",
772 .owner = THIS_MODULE,
773 .of_match_table = of_match_ptr(tas2552_of_match), 772 .of_match_table = of_match_ptr(tas2552_of_match),
774 .pm = &tas2552_pm, 773 .pm = &tas2552_pm,
775 }, 774 },
diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c
index 32942bed34b1..0a49fc851577 100644
--- a/sound/soc/codecs/tas5086.c
+++ b/sound/soc/codecs/tas5086.c
@@ -994,7 +994,6 @@ static int tas5086_i2c_remove(struct i2c_client *i2c)
994static struct i2c_driver tas5086_i2c_driver = { 994static struct i2c_driver tas5086_i2c_driver = {
995 .driver = { 995 .driver = {
996 .name = "tas5086", 996 .name = "tas5086",
997 .owner = THIS_MODULE,
998 .of_match_table = of_match_ptr(tas5086_dt_ids), 997 .of_match_table = of_match_ptr(tas5086_dt_ids),
999 }, 998 },
1000 .id_table = tas5086_i2c_id, 999 .id_table = tas5086_i2c_id,
diff --git a/sound/soc/codecs/tas571x.c b/sound/soc/codecs/tas571x.c
index 85bcc374c8e8..39307ad41a34 100644
--- a/sound/soc/codecs/tas571x.c
+++ b/sound/soc/codecs/tas571x.c
@@ -179,7 +179,7 @@ static int tas571x_set_bias_level(struct snd_soc_codec *codec,
179 case SND_SOC_BIAS_PREPARE: 179 case SND_SOC_BIAS_PREPARE:
180 break; 180 break;
181 case SND_SOC_BIAS_STANDBY: 181 case SND_SOC_BIAS_STANDBY:
182 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 182 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
183 if (!IS_ERR(priv->mclk)) { 183 if (!IS_ERR(priv->mclk)) {
184 ret = clk_prepare_enable(priv->mclk); 184 ret = clk_prepare_enable(priv->mclk);
185 if (ret) { 185 if (ret) {
diff --git a/sound/soc/codecs/tfa9879.c b/sound/soc/codecs/tfa9879.c
index aab0af681e8c..cb5310d89c0f 100644
--- a/sound/soc/codecs/tfa9879.c
+++ b/sound/soc/codecs/tfa9879.c
@@ -160,7 +160,7 @@ static int tfa9879_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
160 return 0; 160 return 0;
161} 161}
162 162
163static struct reg_default tfa9879_regs[] = { 163static const struct reg_default tfa9879_regs[] = {
164 { TFA9879_DEVICE_CONTROL, 0x0000 }, /* 0x00 */ 164 { TFA9879_DEVICE_CONTROL, 0x0000 }, /* 0x00 */
165 { TFA9879_SERIAL_INTERFACE_1, 0x0a18 }, /* 0x01 */ 165 { TFA9879_SERIAL_INTERFACE_1, 0x0a18 }, /* 0x01 */
166 { TFA9879_PCM_IOM2_FORMAT_1, 0x0007 }, /* 0x02 */ 166 { TFA9879_PCM_IOM2_FORMAT_1, 0x0007 }, /* 0x02 */
@@ -314,7 +314,6 @@ MODULE_DEVICE_TABLE(i2c, tfa9879_i2c_id);
314static struct i2c_driver tfa9879_i2c_driver = { 314static struct i2c_driver tfa9879_i2c_driver = {
315 .driver = { 315 .driver = {
316 .name = "tfa9879", 316 .name = "tfa9879",
317 .owner = THIS_MODULE,
318 }, 317 },
319 .probe = tfa9879_i2c_probe, 318 .probe = tfa9879_i2c_probe,
320 .remove = tfa9879_i2c_remove, 319 .remove = tfa9879_i2c_remove,
diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c
index c4c960f592a1..ee4def4f819f 100644
--- a/sound/soc/codecs/tlv320aic31xx.c
+++ b/sound/soc/codecs/tlv320aic31xx.c
@@ -1121,7 +1121,7 @@ static struct snd_soc_codec_driver soc_codec_driver_aic31xx = {
1121 .num_dapm_routes = ARRAY_SIZE(aic31xx_audio_map), 1121 .num_dapm_routes = ARRAY_SIZE(aic31xx_audio_map),
1122}; 1122};
1123 1123
1124static struct snd_soc_dai_ops aic31xx_dai_ops = { 1124static const struct snd_soc_dai_ops aic31xx_dai_ops = {
1125 .hw_params = aic31xx_hw_params, 1125 .hw_params = aic31xx_hw_params,
1126 .set_sysclk = aic31xx_set_dai_sysclk, 1126 .set_sysclk = aic31xx_set_dai_sysclk,
1127 .set_fmt = aic31xx_set_dai_fmt, 1127 .set_fmt = aic31xx_set_dai_fmt,
@@ -1283,7 +1283,6 @@ MODULE_DEVICE_TABLE(i2c, aic31xx_i2c_id);
1283static struct i2c_driver aic31xx_i2c_driver = { 1283static struct i2c_driver aic31xx_i2c_driver = {
1284 .driver = { 1284 .driver = {
1285 .name = "tlv320aic31xx-codec", 1285 .name = "tlv320aic31xx-codec",
1286 .owner = THIS_MODULE,
1287 .of_match_table = of_match_ptr(tlv320aic31xx_of_match), 1286 .of_match_table = of_match_ptr(tlv320aic31xx_of_match),
1288 }, 1287 },
1289 .probe = aic31xx_i2c_probe, 1288 .probe = aic31xx_i2c_probe,
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index ad6cb90e5f9b..f2d3191961e1 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -871,7 +871,6 @@ MODULE_DEVICE_TABLE(of, aic32x4_of_id);
871static struct i2c_driver aic32x4_i2c_driver = { 871static struct i2c_driver aic32x4_i2c_driver = {
872 .driver = { 872 .driver = {
873 .name = "tlv320aic32x4", 873 .name = "tlv320aic32x4",
874 .owner = THIS_MODULE,
875 .of_match_table = aic32x4_of_id, 874 .of_match_table = aic32x4_of_id,
876 }, 875 },
877 .probe = aic32x4_i2c_probe, 876 .probe = aic32x4_i2c_probe,
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index a7cf19b53fb2..1a82b19b2644 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1668,7 +1668,7 @@ static const struct i2c_device_id aic3x_i2c_id[] = {
1668}; 1668};
1669MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id); 1669MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
1670 1670
1671static const struct reg_default aic3007_class_d[] = { 1671static const struct reg_sequence aic3007_class_d[] = {
1672 /* Class-D speaker driver init; datasheet p. 46 */ 1672 /* Class-D speaker driver init; datasheet p. 46 */
1673 { AIC3X_PAGE_SELECT, 0x0D }, 1673 { AIC3X_PAGE_SELECT, 0x0D },
1674 { 0xD, 0x0D }, 1674 { 0xD, 0x0D },
@@ -1825,7 +1825,6 @@ MODULE_DEVICE_TABLE(of, tlv320aic3x_of_match);
1825static struct i2c_driver aic3x_i2c_driver = { 1825static struct i2c_driver aic3x_i2c_driver = {
1826 .driver = { 1826 .driver = {
1827 .name = "tlv320aic3x-codec", 1827 .name = "tlv320aic3x-codec",
1828 .owner = THIS_MODULE,
1829 .of_match_table = of_match_ptr(tlv320aic3x_of_match), 1828 .of_match_table = of_match_ptr(tlv320aic3x_of_match),
1830 }, 1829 },
1831 .probe = aic3x_i2c_probe, 1830 .probe = aic3x_i2c_probe,
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index d67a311f0e75..781398fb2841 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -1585,7 +1585,6 @@ MODULE_DEVICE_TABLE(i2c, tlv320dac33_i2c_id);
1585static struct i2c_driver tlv320dac33_i2c_driver = { 1585static struct i2c_driver tlv320dac33_i2c_driver = {
1586 .driver = { 1586 .driver = {
1587 .name = "tlv320dac33-codec", 1587 .name = "tlv320dac33-codec",
1588 .owner = THIS_MODULE,
1589 }, 1588 },
1590 .probe = dac33_i2c_probe, 1589 .probe = dac33_i2c_probe,
1591 .remove = dac33_i2c_remove, 1590 .remove = dac33_i2c_remove,
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index 6fac9e034c48..265c4c38804d 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -488,7 +488,6 @@ MODULE_DEVICE_TABLE(of, tpa6130a2_of_match);
488static struct i2c_driver tpa6130a2_i2c_driver = { 488static struct i2c_driver tpa6130a2_i2c_driver = {
489 .driver = { 489 .driver = {
490 .name = "tpa6130a2", 490 .name = "tpa6130a2",
491 .owner = THIS_MODULE,
492 .of_match_table = of_match_ptr(tpa6130a2_of_match), 491 .of_match_table = of_match_ptr(tpa6130a2_of_match),
493 }, 492 },
494 .probe = tpa6130a2_probe, 493 .probe = tpa6130a2_probe,
diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c
index 12232d7db4c5..43568435c208 100644
--- a/sound/soc/codecs/ts3a227e.c
+++ b/sound/soc/codecs/ts3a227e.c
@@ -23,11 +23,13 @@
23#include "ts3a227e.h" 23#include "ts3a227e.h"
24 24
25struct ts3a227e { 25struct ts3a227e {
26 struct device *dev;
26 struct regmap *regmap; 27 struct regmap *regmap;
27 struct snd_soc_jack *jack; 28 struct snd_soc_jack *jack;
28 bool plugged; 29 bool plugged;
29 bool mic_present; 30 bool mic_present;
30 unsigned int buttons_held; 31 unsigned int buttons_held;
32 int irq;
31}; 33};
32 34
33/* Button values to be reported on the jack */ 35/* Button values to be reported on the jack */
@@ -189,16 +191,28 @@ static irqreturn_t ts3a227e_interrupt(int irq, void *data)
189 struct ts3a227e *ts3a227e = (struct ts3a227e *)data; 191 struct ts3a227e *ts3a227e = (struct ts3a227e *)data;
190 struct regmap *regmap = ts3a227e->regmap; 192 struct regmap *regmap = ts3a227e->regmap;
191 unsigned int int_reg, kp_int_reg, acc_reg, i; 193 unsigned int int_reg, kp_int_reg, acc_reg, i;
194 struct device *dev = ts3a227e->dev;
195 int ret;
192 196
193 /* Check for plug/unplug. */ 197 /* Check for plug/unplug. */
194 regmap_read(regmap, TS3A227E_REG_INTERRUPT, &int_reg); 198 ret = regmap_read(regmap, TS3A227E_REG_INTERRUPT, &int_reg);
199 if (ret) {
200 dev_err(dev, "failed to clear interrupt ret=%d\n", ret);
201 return IRQ_NONE;
202 }
203
195 if (int_reg & (DETECTION_COMPLETE_EVENT | INS_REM_EVENT)) { 204 if (int_reg & (DETECTION_COMPLETE_EVENT | INS_REM_EVENT)) {
196 regmap_read(regmap, TS3A227E_REG_ACCESSORY_STATUS, &acc_reg); 205 regmap_read(regmap, TS3A227E_REG_ACCESSORY_STATUS, &acc_reg);
197 ts3a227e_new_jack_state(ts3a227e, acc_reg); 206 ts3a227e_new_jack_state(ts3a227e, acc_reg);
198 } 207 }
199 208
200 /* Report any key events. */ 209 /* Report any key events. */
201 regmap_read(regmap, TS3A227E_REG_KP_INTERRUPT, &kp_int_reg); 210 ret = regmap_read(regmap, TS3A227E_REG_KP_INTERRUPT, &kp_int_reg);
211 if (ret) {
212 dev_err(dev, "failed to clear key interrupt ret=%d\n", ret);
213 return IRQ_NONE;
214 }
215
202 for (i = 0; i < TS3A227E_NUM_BUTTONS; i++) { 216 for (i = 0; i < TS3A227E_NUM_BUTTONS; i++) {
203 if (kp_int_reg & PRESS_MASK(i)) 217 if (kp_int_reg & PRESS_MASK(i))
204 ts3a227e->buttons_held |= (1 << i); 218 ts3a227e->buttons_held |= (1 << i);
@@ -283,6 +297,8 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
283 return -ENOMEM; 297 return -ENOMEM;
284 298
285 i2c_set_clientdata(i2c, ts3a227e); 299 i2c_set_clientdata(i2c, ts3a227e);
300 ts3a227e->dev = dev;
301 ts3a227e->irq = i2c->irq;
286 302
287 ts3a227e->regmap = devm_regmap_init_i2c(i2c, &ts3a227e_regmap_config); 303 ts3a227e->regmap = devm_regmap_init_i2c(i2c, &ts3a227e_regmap_config);
288 if (IS_ERR(ts3a227e->regmap)) 304 if (IS_ERR(ts3a227e->regmap))
@@ -320,6 +336,32 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
320 return 0; 336 return 0;
321} 337}
322 338
339#ifdef CONFIG_PM_SLEEP
340static int ts3a227e_suspend(struct device *dev)
341{
342 struct ts3a227e *ts3a227e = dev_get_drvdata(dev);
343
344 dev_dbg(ts3a227e->dev, "suspend disable irq\n");
345 disable_irq(ts3a227e->irq);
346
347 return 0;
348}
349
350static int ts3a227e_resume(struct device *dev)
351{
352 struct ts3a227e *ts3a227e = dev_get_drvdata(dev);
353
354 dev_dbg(ts3a227e->dev, "resume enable irq\n");
355 enable_irq(ts3a227e->irq);
356
357 return 0;
358}
359#endif
360
361static const struct dev_pm_ops ts3a227e_pm = {
362 SET_SYSTEM_SLEEP_PM_OPS(ts3a227e_suspend, ts3a227e_resume)
363};
364
323static const struct i2c_device_id ts3a227e_i2c_ids[] = { 365static const struct i2c_device_id ts3a227e_i2c_ids[] = {
324 { "ts3a227e", 0 }, 366 { "ts3a227e", 0 },
325 { } 367 { }
@@ -335,7 +377,7 @@ MODULE_DEVICE_TABLE(of, ts3a227e_of_match);
335static struct i2c_driver ts3a227e_driver = { 377static struct i2c_driver ts3a227e_driver = {
336 .driver = { 378 .driver = {
337 .name = "ts3a227e", 379 .name = "ts3a227e",
338 .owner = THIS_MODULE, 380 .pm = &ts3a227e_pm,
339 .of_match_table = of_match_ptr(ts3a227e_of_match), 381 .of_match_table = of_match_ptr(ts3a227e_of_match),
340 }, 382 },
341 .probe = ts3a227e_i2c_probe, 383 .probe = ts3a227e_i2c_probe,
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index 6e159f59d219..5cafb16ccf1a 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -810,7 +810,6 @@ MODULE_DEVICE_TABLE(i2c, uda1380_i2c_id);
810static struct i2c_driver uda1380_i2c_driver = { 810static struct i2c_driver uda1380_i2c_driver = {
811 .driver = { 811 .driver = {
812 .name = "uda1380-codec", 812 .name = "uda1380-codec",
813 .owner = THIS_MODULE,
814 }, 813 },
815 .probe = uda1380_i2c_probe, 814 .probe = uda1380_i2c_probe,
816 .remove = uda1380_i2c_remove, 815 .remove = uda1380_i2c_remove,
diff --git a/sound/soc/codecs/wm1250-ev1.c b/sound/soc/codecs/wm1250-ev1.c
index 048f00568260..ec45c5b220b1 100644
--- a/sound/soc/codecs/wm1250-ev1.c
+++ b/sound/soc/codecs/wm1250-ev1.c
@@ -251,7 +251,6 @@ MODULE_DEVICE_TABLE(i2c, wm1250_ev1_i2c_id);
251static struct i2c_driver wm1250_ev1_i2c_driver = { 251static struct i2c_driver wm1250_ev1_i2c_driver = {
252 .driver = { 252 .driver = {
253 .name = "wm1250-ev1", 253 .name = "wm1250-ev1",
254 .owner = THIS_MODULE,
255 }, 254 },
256 .probe = wm1250_ev1_probe, 255 .probe = wm1250_ev1_probe,
257 .remove = wm1250_ev1_remove, 256 .remove = wm1250_ev1_remove,
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
index 21d5402e343f..786abd02b140 100644
--- a/sound/soc/codecs/wm2000.c
+++ b/sound/soc/codecs/wm2000.c
@@ -942,7 +942,6 @@ MODULE_DEVICE_TABLE(i2c, wm2000_i2c_id);
942static struct i2c_driver wm2000_i2c_driver = { 942static struct i2c_driver wm2000_i2c_driver = {
943 .driver = { 943 .driver = {
944 .name = "wm2000", 944 .name = "wm2000",
945 .owner = THIS_MODULE,
946 }, 945 },
947 .probe = wm2000_i2c_probe, 946 .probe = wm2000_i2c_probe,
948 .remove = wm2000_i2c_remove, 947 .remove = wm2000_i2c_remove,
diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c
index c83083285e53..35199fc1f6ca 100644
--- a/sound/soc/codecs/wm2200.c
+++ b/sound/soc/codecs/wm2200.c
@@ -166,7 +166,7 @@ static const struct wm_adsp_region wm2200_dsp2_regions[] = {
166 { .type = WMFW_ADSP1_ZM, .base = WM2200_DSP2_ZM_BASE }, 166 { .type = WMFW_ADSP1_ZM, .base = WM2200_DSP2_ZM_BASE },
167}; 167};
168 168
169static struct reg_default wm2200_reg_defaults[] = { 169static const struct reg_default wm2200_reg_defaults[] = {
170 { 0x000B, 0x0000 }, /* R11 - Tone Generator 1 */ 170 { 0x000B, 0x0000 }, /* R11 - Tone Generator 1 */
171 { 0x0102, 0x0000 }, /* R258 - Clocking 3 */ 171 { 0x0102, 0x0000 }, /* R258 - Clocking 3 */
172 { 0x0103, 0x0011 }, /* R259 - Clocking 4 */ 172 { 0x0103, 0x0011 }, /* R259 - Clocking 4 */
@@ -897,7 +897,7 @@ static bool wm2200_readable_register(struct device *dev, unsigned int reg)
897 } 897 }
898} 898}
899 899
900static const struct reg_default wm2200_reva_patch[] = { 900static const struct reg_sequence wm2200_reva_patch[] = {
901 { 0x07, 0x0003 }, 901 { 0x07, 0x0003 },
902 { 0x102, 0x0200 }, 902 { 0x102, 0x0200 },
903 { 0x203, 0x0084 }, 903 { 0x203, 0x0084 },
@@ -2481,7 +2481,7 @@ static int wm2200_runtime_resume(struct device *dev)
2481} 2481}
2482#endif 2482#endif
2483 2483
2484static struct dev_pm_ops wm2200_pm = { 2484static const struct dev_pm_ops wm2200_pm = {
2485 SET_RUNTIME_PM_OPS(wm2200_runtime_suspend, wm2200_runtime_resume, 2485 SET_RUNTIME_PM_OPS(wm2200_runtime_suspend, wm2200_runtime_resume,
2486 NULL) 2486 NULL)
2487}; 2487};
@@ -2495,7 +2495,6 @@ MODULE_DEVICE_TABLE(i2c, wm2200_i2c_id);
2495static struct i2c_driver wm2200_i2c_driver = { 2495static struct i2c_driver wm2200_i2c_driver = {
2496 .driver = { 2496 .driver = {
2497 .name = "wm2200", 2497 .name = "wm2200",
2498 .owner = THIS_MODULE,
2499 .pm = &wm2200_pm, 2498 .pm = &wm2200_pm,
2500 }, 2499 },
2501 .probe = wm2200_i2c_probe, 2500 .probe = wm2200_i2c_probe,
diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c
index 4c10cd88c1af..3695b1dcbaf7 100644
--- a/sound/soc/codecs/wm5100.c
+++ b/sound/soc/codecs/wm5100.c
@@ -1247,7 +1247,7 @@ static const struct snd_soc_dapm_route wm5100_dapm_routes[] = {
1247 { "PWM2", NULL, "PWM2 Driver" }, 1247 { "PWM2", NULL, "PWM2 Driver" },
1248}; 1248};
1249 1249
1250static const struct reg_default wm5100_reva_patches[] = { 1250static const struct reg_sequence wm5100_reva_patches[] = {
1251 { WM5100_AUDIO_IF_1_10, 0 }, 1251 { WM5100_AUDIO_IF_1_10, 0 },
1252 { WM5100_AUDIO_IF_1_11, 1 }, 1252 { WM5100_AUDIO_IF_1_11, 1 },
1253 { WM5100_AUDIO_IF_1_12, 2 }, 1253 { WM5100_AUDIO_IF_1_12, 2 },
@@ -2708,7 +2708,7 @@ static int wm5100_runtime_resume(struct device *dev)
2708} 2708}
2709#endif 2709#endif
2710 2710
2711static struct dev_pm_ops wm5100_pm = { 2711static const struct dev_pm_ops wm5100_pm = {
2712 SET_RUNTIME_PM_OPS(wm5100_runtime_suspend, wm5100_runtime_resume, 2712 SET_RUNTIME_PM_OPS(wm5100_runtime_suspend, wm5100_runtime_resume,
2713 NULL) 2713 NULL)
2714}; 2714};
@@ -2722,7 +2722,6 @@ MODULE_DEVICE_TABLE(i2c, wm5100_i2c_id);
2722static struct i2c_driver wm5100_i2c_driver = { 2722static struct i2c_driver wm5100_i2c_driver = {
2723 .driver = { 2723 .driver = {
2724 .name = "wm5100", 2724 .name = "wm5100",
2725 .owner = THIS_MODULE,
2726 .pm = &wm5100_pm, 2725 .pm = &wm5100_pm,
2727 }, 2726 },
2728 .probe = wm5100_i2c_probe, 2727 .probe = wm5100_i2c_probe,
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index d097f09e50f2..64637d1cf4e5 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -788,8 +788,7 @@ ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
788ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), 788ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
789ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), 789ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
790 790
791SND_SOC_BYTES("EQ1 Coefficients", ARIZONA_EQ1_3, 19), 791ARIZONA_EQ_CONTROL("EQ1 Coefficients", ARIZONA_EQ1_2),
792SOC_SINGLE("EQ1 Mode Switch", ARIZONA_EQ1_2, ARIZONA_EQ1_B1_MODE, 1, 0),
793SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, 792SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
794 24, 0, eq_tlv), 793 24, 0, eq_tlv),
795SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT, 794SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
@@ -801,8 +800,7 @@ SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT,
801SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT, 800SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT,
802 24, 0, eq_tlv), 801 24, 0, eq_tlv),
803 802
804SND_SOC_BYTES("EQ2 Coefficients", ARIZONA_EQ2_3, 19), 803ARIZONA_EQ_CONTROL("EQ2 Coefficients", ARIZONA_EQ2_2),
805SOC_SINGLE("EQ2 Mode Switch", ARIZONA_EQ2_2, ARIZONA_EQ2_B1_MODE, 1, 0),
806SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT, 804SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT,
807 24, 0, eq_tlv), 805 24, 0, eq_tlv),
808SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT, 806SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT,
@@ -814,8 +812,7 @@ SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT,
814SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT, 812SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT,
815 24, 0, eq_tlv), 813 24, 0, eq_tlv),
816 814
817SND_SOC_BYTES("EQ3 Coefficients", ARIZONA_EQ3_3, 19), 815ARIZONA_EQ_CONTROL("EQ3 Coefficients", ARIZONA_EQ3_2),
818SOC_SINGLE("EQ3 Mode Switch", ARIZONA_EQ3_2, ARIZONA_EQ3_B1_MODE, 1, 0),
819SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT, 816SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT,
820 24, 0, eq_tlv), 817 24, 0, eq_tlv),
821SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT, 818SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT,
@@ -827,8 +824,7 @@ SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT,
827SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT, 824SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT,
828 24, 0, eq_tlv), 825 24, 0, eq_tlv),
829 826
830SND_SOC_BYTES("EQ4 Coefficients", ARIZONA_EQ4_3, 19), 827ARIZONA_EQ_CONTROL("EQ4 Coefficients", ARIZONA_EQ4_2),
831SOC_SINGLE("EQ4 Mode Switch", ARIZONA_EQ4_2, ARIZONA_EQ4_B1_MODE, 1, 0),
832SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT, 828SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT,
833 24, 0, eq_tlv), 829 24, 0, eq_tlv),
834SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT, 830SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT,
@@ -851,10 +847,10 @@ ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
851ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE), 847ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
852ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE), 848ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
853 849
854SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1), 850ARIZONA_LHPF_CONTROL("LHPF1 Coefficients", ARIZONA_HPLPF1_2),
855SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1), 851ARIZONA_LHPF_CONTROL("LHPF2 Coefficients", ARIZONA_HPLPF2_2),
856SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1), 852ARIZONA_LHPF_CONTROL("LHPF3 Coefficients", ARIZONA_HPLPF3_2),
857SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1), 853ARIZONA_LHPF_CONTROL("LHPF4 Coefficients", ARIZONA_HPLPF4_2),
858 854
859ARIZONA_MIXER_CONTROLS("DSP1L", ARIZONA_DSP1LMIX_INPUT_1_SOURCE), 855ARIZONA_MIXER_CONTROLS("DSP1L", ARIZONA_DSP1LMIX_INPUT_1_SOURCE),
860ARIZONA_MIXER_CONTROLS("DSP1R", ARIZONA_DSP1RMIX_INPUT_1_SOURCE), 856ARIZONA_MIXER_CONTROLS("DSP1R", ARIZONA_DSP1RMIX_INPUT_1_SOURCE),
@@ -1883,7 +1879,7 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec)
1883 ret = snd_soc_add_codec_controls(codec, 1879 ret = snd_soc_add_codec_controls(codec,
1884 arizona_adsp2_rate_controls, 1); 1880 arizona_adsp2_rate_controls, 1);
1885 if (ret) 1881 if (ret)
1886 return ret; 1882 goto err_adsp2_codec_probe;
1887 1883
1888 arizona_init_spk(codec); 1884 arizona_init_spk(codec);
1889 arizona_init_gpio(codec); 1885 arizona_init_gpio(codec);
@@ -1893,6 +1889,11 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec)
1893 priv->core.arizona->dapm = dapm; 1889 priv->core.arizona->dapm = dapm;
1894 1890
1895 return 0; 1891 return 0;
1892
1893err_adsp2_codec_probe:
1894 wm_adsp2_codec_remove(&priv->core.adsp[0], codec);
1895
1896 return ret;
1896} 1897}
1897 1898
1898static int wm5102_codec_remove(struct snd_soc_codec *codec) 1899static int wm5102_codec_remove(struct snd_soc_codec *codec)
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index 709fcc6169d8..2d1168c768d9 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -247,8 +247,7 @@ ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
247ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), 247ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
248ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), 248ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
249 249
250SND_SOC_BYTES("EQ1 Coefficients", ARIZONA_EQ1_3, 19), 250ARIZONA_EQ_CONTROL("EQ1 Coefficients", ARIZONA_EQ1_2),
251SOC_SINGLE("EQ1 Mode Switch", ARIZONA_EQ1_2, ARIZONA_EQ1_B1_MODE, 1, 0),
252SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, 251SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
253 24, 0, eq_tlv), 252 24, 0, eq_tlv),
254SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT, 253SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
@@ -260,8 +259,7 @@ SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT,
260SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT, 259SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT,
261 24, 0, eq_tlv), 260 24, 0, eq_tlv),
262 261
263SND_SOC_BYTES("EQ2 Coefficients", ARIZONA_EQ2_3, 19), 262ARIZONA_EQ_CONTROL("EQ2 Coefficients", ARIZONA_EQ2_2),
264SOC_SINGLE("EQ2 Mode Switch", ARIZONA_EQ2_2, ARIZONA_EQ2_B1_MODE, 1, 0),
265SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT, 263SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT,
266 24, 0, eq_tlv), 264 24, 0, eq_tlv),
267SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT, 265SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT,
@@ -273,8 +271,7 @@ SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT,
273SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT, 271SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT,
274 24, 0, eq_tlv), 272 24, 0, eq_tlv),
275 273
276SND_SOC_BYTES("EQ3 Coefficients", ARIZONA_EQ3_3, 19), 274ARIZONA_EQ_CONTROL("EQ3 Coefficients", ARIZONA_EQ3_2),
277SOC_SINGLE("EQ3 Mode Switch", ARIZONA_EQ3_2, ARIZONA_EQ3_B1_MODE, 1, 0),
278SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT, 275SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT,
279 24, 0, eq_tlv), 276 24, 0, eq_tlv),
280SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT, 277SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT,
@@ -286,8 +283,7 @@ SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT,
286SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT, 283SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT,
287 24, 0, eq_tlv), 284 24, 0, eq_tlv),
288 285
289SND_SOC_BYTES("EQ4 Coefficients", ARIZONA_EQ4_3, 19), 286ARIZONA_EQ_CONTROL("EQ4 Coefficients", ARIZONA_EQ4_2),
290SOC_SINGLE("EQ4 Mode Switch", ARIZONA_EQ4_2, ARIZONA_EQ4_B1_MODE, 1, 0),
291SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT, 287SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT,
292 24, 0, eq_tlv), 288 24, 0, eq_tlv),
293SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT, 289SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT,
@@ -314,10 +310,10 @@ ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
314ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE), 310ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
315ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE), 311ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
316 312
317SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1), 313ARIZONA_LHPF_CONTROL("LHPF1 Coefficients", ARIZONA_HPLPF1_2),
318SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1), 314ARIZONA_LHPF_CONTROL("LHPF2 Coefficients", ARIZONA_HPLPF2_2),
319SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1), 315ARIZONA_LHPF_CONTROL("LHPF3 Coefficients", ARIZONA_HPLPF3_2),
320SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1), 316ARIZONA_LHPF_CONTROL("LHPF4 Coefficients", ARIZONA_HPLPF4_2),
321 317
322SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode), 318SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
323SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), 319SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
@@ -1611,18 +1607,24 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec)
1611 for (i = 0; i < WM5110_NUM_ADSP; ++i) { 1607 for (i = 0; i < WM5110_NUM_ADSP; ++i) {
1612 ret = wm_adsp2_codec_probe(&priv->core.adsp[i], codec); 1608 ret = wm_adsp2_codec_probe(&priv->core.adsp[i], codec);
1613 if (ret) 1609 if (ret)
1614 return ret; 1610 goto err_adsp2_codec_probe;
1615 } 1611 }
1616 1612
1617 ret = snd_soc_add_codec_controls(codec, 1613 ret = snd_soc_add_codec_controls(codec,
1618 arizona_adsp2_rate_controls, 1614 arizona_adsp2_rate_controls,
1619 WM5110_NUM_ADSP); 1615 WM5110_NUM_ADSP);
1620 if (ret) 1616 if (ret)
1621 return ret; 1617 goto err_adsp2_codec_probe;
1622 1618
1623 snd_soc_dapm_disable_pin(dapm, "HAPTICS"); 1619 snd_soc_dapm_disable_pin(dapm, "HAPTICS");
1624 1620
1625 return 0; 1621 return 0;
1622
1623err_adsp2_codec_probe:
1624 for (--i; i >= 0; --i)
1625 wm_adsp2_codec_remove(&priv->core.adsp[i], codec);
1626
1627 return ret;
1626} 1628}
1627 1629
1628static int wm5110_codec_remove(struct snd_soc_codec *codec) 1630static int wm5110_codec_remove(struct snd_soc_codec *codec)
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c
index dac5beb4d023..b098a83a44d8 100644
--- a/sound/soc/codecs/wm8510.c
+++ b/sound/soc/codecs/wm8510.c
@@ -598,6 +598,7 @@ static const struct of_device_id wm8510_of_match[] = {
598 { .compatible = "wlf,wm8510" }, 598 { .compatible = "wlf,wm8510" },
599 { }, 599 { },
600}; 600};
601MODULE_DEVICE_TABLE(of, wm8510_of_match);
601 602
602static const struct regmap_config wm8510_regmap = { 603static const struct regmap_config wm8510_regmap = {
603 .reg_bits = 7, 604 .reg_bits = 7,
@@ -690,7 +691,6 @@ MODULE_DEVICE_TABLE(i2c, wm8510_i2c_id);
690static struct i2c_driver wm8510_i2c_driver = { 691static struct i2c_driver wm8510_i2c_driver = {
691 .driver = { 692 .driver = {
692 .name = "wm8510", 693 .name = "wm8510",
693 .owner = THIS_MODULE,
694 .of_match_table = wm8510_of_match, 694 .of_match_table = wm8510_of_match,
695 }, 695 },
696 .probe = wm8510_i2c_probe, 696 .probe = wm8510_i2c_probe,
diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c
index 43ea8ae5f871..aa287a3965e7 100644
--- a/sound/soc/codecs/wm8523.c
+++ b/sound/soc/codecs/wm8523.c
@@ -430,6 +430,7 @@ static const struct of_device_id wm8523_of_match[] = {
430 { .compatible = "wlf,wm8523" }, 430 { .compatible = "wlf,wm8523" },
431 { }, 431 { },
432}; 432};
433MODULE_DEVICE_TABLE(of, wm8523_of_match);
433 434
434static const struct regmap_config wm8523_regmap = { 435static const struct regmap_config wm8523_regmap = {
435 .reg_bits = 8, 436 .reg_bits = 8,
@@ -534,7 +535,6 @@ MODULE_DEVICE_TABLE(i2c, wm8523_i2c_id);
534static struct i2c_driver wm8523_i2c_driver = { 535static struct i2c_driver wm8523_i2c_driver = {
535 .driver = { 536 .driver = {
536 .name = "wm8523", 537 .name = "wm8523",
537 .owner = THIS_MODULE,
538 .of_match_table = wm8523_of_match, 538 .of_match_table = wm8523_of_match,
539 }, 539 },
540 .probe = wm8523_i2c_probe, 540 .probe = wm8523_i2c_probe,
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c
index 759a7928ac3e..66602bf02f6e 100644
--- a/sound/soc/codecs/wm8580.c
+++ b/sound/soc/codecs/wm8580.c
@@ -916,6 +916,7 @@ static const struct of_device_id wm8580_of_match[] = {
916 { .compatible = "wlf,wm8580" }, 916 { .compatible = "wlf,wm8580" },
917 { }, 917 { },
918}; 918};
919MODULE_DEVICE_TABLE(of, wm8580_of_match);
919 920
920static const struct regmap_config wm8580_regmap = { 921static const struct regmap_config wm8580_regmap = {
921 .reg_bits = 7, 922 .reg_bits = 7,
@@ -978,7 +979,6 @@ MODULE_DEVICE_TABLE(i2c, wm8580_i2c_id);
978static struct i2c_driver wm8580_i2c_driver = { 979static struct i2c_driver wm8580_i2c_driver = {
979 .driver = { 980 .driver = {
980 .name = "wm8580", 981 .name = "wm8580",
981 .owner = THIS_MODULE,
982 .of_match_table = wm8580_of_match, 982 .of_match_table = wm8580_of_match,
983 }, 983 },
984 .probe = wm8580_i2c_probe, 984 .probe = wm8580_i2c_probe,
diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c
index cc8251f09f8a..44b9e0ae7451 100644
--- a/sound/soc/codecs/wm8711.c
+++ b/sound/soc/codecs/wm8711.c
@@ -478,7 +478,6 @@ MODULE_DEVICE_TABLE(i2c, wm8711_i2c_id);
478static struct i2c_driver wm8711_i2c_driver = { 478static struct i2c_driver wm8711_i2c_driver = {
479 .driver = { 479 .driver = {
480 .name = "wm8711", 480 .name = "wm8711",
481 .owner = THIS_MODULE,
482 .of_match_table = wm8711_of_match, 481 .of_match_table = wm8711_of_match,
483 }, 482 },
484 .probe = wm8711_i2c_probe, 483 .probe = wm8711_i2c_probe,
diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c
index f1a173e6ec33..cd7b02413ccf 100644
--- a/sound/soc/codecs/wm8728.c
+++ b/sound/soc/codecs/wm8728.c
@@ -319,7 +319,6 @@ MODULE_DEVICE_TABLE(i2c, wm8728_i2c_id);
319static struct i2c_driver wm8728_i2c_driver = { 319static struct i2c_driver wm8728_i2c_driver = {
320 .driver = { 320 .driver = {
321 .name = "wm8728", 321 .name = "wm8728",
322 .owner = THIS_MODULE,
323 .of_match_table = wm8728_of_match, 322 .of_match_table = wm8728_of_match,
324 }, 323 },
325 .probe = wm8728_i2c_probe, 324 .probe = wm8728_i2c_probe,
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 915ea11ad4b6..4846842522f3 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -789,7 +789,6 @@ MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id);
789static struct i2c_driver wm8731_i2c_driver = { 789static struct i2c_driver wm8731_i2c_driver = {
790 .driver = { 790 .driver = {
791 .name = "wm8731", 791 .name = "wm8731",
792 .owner = THIS_MODULE,
793 .of_match_table = wm8731_of_match, 792 .of_match_table = wm8731_of_match,
794 }, 793 },
795 .probe = wm8731_i2c_probe, 794 .probe = wm8731_i2c_probe,
diff --git a/sound/soc/codecs/wm8737.c b/sound/soc/codecs/wm8737.c
index 6ad606fd8b69..b54a7b78f562 100644
--- a/sound/soc/codecs/wm8737.c
+++ b/sound/soc/codecs/wm8737.c
@@ -657,7 +657,6 @@ MODULE_DEVICE_TABLE(i2c, wm8737_i2c_id);
657static struct i2c_driver wm8737_i2c_driver = { 657static struct i2c_driver wm8737_i2c_driver = {
658 .driver = { 658 .driver = {
659 .name = "wm8737", 659 .name = "wm8737",
660 .owner = THIS_MODULE,
661 .of_match_table = wm8737_of_match, 660 .of_match_table = wm8737_of_match,
662 }, 661 },
663 .probe = wm8737_i2c_probe, 662 .probe = wm8737_i2c_probe,
diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c
index b34623786e35..430fa7ded713 100644
--- a/sound/soc/codecs/wm8741.c
+++ b/sound/soc/codecs/wm8741.c
@@ -633,7 +633,6 @@ MODULE_DEVICE_TABLE(i2c, wm8741_i2c_id);
633static struct i2c_driver wm8741_i2c_driver = { 633static struct i2c_driver wm8741_i2c_driver = {
634 .driver = { 634 .driver = {
635 .name = "wm8741", 635 .name = "wm8741",
636 .owner = THIS_MODULE,
637 .of_match_table = wm8741_of_match, 636 .of_match_table = wm8741_of_match,
638 }, 637 },
639 .probe = wm8741_i2c_probe, 638 .probe = wm8741_i2c_probe,
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 56d89b0865fa..873933a7966f 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -826,7 +826,6 @@ MODULE_DEVICE_TABLE(i2c, wm8750_i2c_id);
826static struct i2c_driver wm8750_i2c_driver = { 826static struct i2c_driver wm8750_i2c_driver = {
827 .driver = { 827 .driver = {
828 .name = "wm8750", 828 .name = "wm8750",
829 .owner = THIS_MODULE,
830 .of_match_table = wm8750_of_match, 829 .of_match_table = wm8750_of_match,
831 }, 830 },
832 .probe = wm8750_i2c_probe, 831 .probe = wm8750_i2c_probe,
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index feb2997a377a..b5e50ffbf99f 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -1609,7 +1609,6 @@ MODULE_DEVICE_TABLE(i2c, wm8753_i2c_id);
1609static struct i2c_driver wm8753_i2c_driver = { 1609static struct i2c_driver wm8753_i2c_driver = {
1610 .driver = { 1610 .driver = {
1611 .name = "wm8753", 1611 .name = "wm8753",
1612 .owner = THIS_MODULE,
1613 .of_match_table = wm8753_of_match, 1612 .of_match_table = wm8753_of_match,
1614 }, 1613 },
1615 .probe = wm8753_i2c_probe, 1614 .probe = wm8753_i2c_probe,
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index ece9b4456767..592866dd60c7 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -536,7 +536,6 @@ MODULE_DEVICE_TABLE(i2c, wm8776_i2c_id);
536static struct i2c_driver wm8776_i2c_driver = { 536static struct i2c_driver wm8776_i2c_driver = {
537 .driver = { 537 .driver = {
538 .name = "wm8776", 538 .name = "wm8776",
539 .owner = THIS_MODULE,
540 .of_match_table = wm8776_of_match, 539 .of_match_table = wm8776_of_match,
541 }, 540 },
542 .probe = wm8776_i2c_probe, 541 .probe = wm8776_i2c_probe,
diff --git a/sound/soc/codecs/wm8804-i2c.c b/sound/soc/codecs/wm8804-i2c.c
index 6596f5f3a0c3..f27464c2c5ba 100644
--- a/sound/soc/codecs/wm8804-i2c.c
+++ b/sound/soc/codecs/wm8804-i2c.c
@@ -49,7 +49,6 @@ MODULE_DEVICE_TABLE(of, wm8804_of_match);
49static struct i2c_driver wm8804_i2c_driver = { 49static struct i2c_driver wm8804_i2c_driver = {
50 .driver = { 50 .driver = {
51 .name = "wm8804", 51 .name = "wm8804",
52 .owner = THIS_MODULE,
53 .pm = &wm8804_pm, 52 .pm = &wm8804_pm,
54 .of_match_table = wm8804_of_match, 53 .of_match_table = wm8804_of_match,
55 }, 54 },
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c
index f3759ec5a863..98900aa66dc3 100644
--- a/sound/soc/codecs/wm8900.c
+++ b/sound/soc/codecs/wm8900.c
@@ -1312,7 +1312,6 @@ MODULE_DEVICE_TABLE(i2c, wm8900_i2c_id);
1312static struct i2c_driver wm8900_i2c_driver = { 1312static struct i2c_driver wm8900_i2c_driver = {
1313 .driver = { 1313 .driver = {
1314 .name = "wm8900", 1314 .name = "wm8900",
1315 .owner = THIS_MODULE,
1316 }, 1315 },
1317 .probe = wm8900_i2c_probe, 1316 .probe = wm8900_i2c_probe,
1318 .remove = wm8900_i2c_remove, 1317 .remove = wm8900_i2c_remove,
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index b5322c1544fb..b011253459af 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -2193,7 +2193,6 @@ MODULE_DEVICE_TABLE(i2c, wm8903_i2c_id);
2193static struct i2c_driver wm8903_i2c_driver = { 2193static struct i2c_driver wm8903_i2c_driver = {
2194 .driver = { 2194 .driver = {
2195 .name = "wm8903", 2195 .name = "wm8903",
2196 .owner = THIS_MODULE,
2197 .of_match_table = wm8903_of_match, 2196 .of_match_table = wm8903_of_match,
2198 }, 2197 },
2199 .probe = wm8903_i2c_probe, 2198 .probe = wm8903_i2c_probe,
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index 265a4a58a2d1..145f5f9d581b 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -2292,7 +2292,6 @@ MODULE_DEVICE_TABLE(i2c, wm8904_i2c_id);
2292static struct i2c_driver wm8904_i2c_driver = { 2292static struct i2c_driver wm8904_i2c_driver = {
2293 .driver = { 2293 .driver = {
2294 .name = "wm8904", 2294 .name = "wm8904",
2295 .owner = THIS_MODULE,
2296 .of_match_table = of_match_ptr(wm8904_of_match), 2295 .of_match_table = of_match_ptr(wm8904_of_match),
2297 }, 2296 },
2298 .probe = wm8904_i2c_probe, 2297 .probe = wm8904_i2c_probe,
diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c
index 98ef0ba5c2a4..f6f9395ea38e 100644
--- a/sound/soc/codecs/wm8940.c
+++ b/sound/soc/codecs/wm8940.c
@@ -787,7 +787,6 @@ MODULE_DEVICE_TABLE(i2c, wm8940_i2c_id);
787static struct i2c_driver wm8940_i2c_driver = { 787static struct i2c_driver wm8940_i2c_driver = {
788 .driver = { 788 .driver = {
789 .name = "wm8940", 789 .name = "wm8940",
790 .owner = THIS_MODULE,
791 }, 790 },
792 .probe = wm8940_i2c_probe, 791 .probe = wm8940_i2c_probe,
793 .remove = wm8940_i2c_remove, 792 .remove = wm8940_i2c_remove,
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c
index 2d591c24704b..12e4435f00f8 100644
--- a/sound/soc/codecs/wm8955.c
+++ b/sound/soc/codecs/wm8955.c
@@ -1009,7 +1009,6 @@ MODULE_DEVICE_TABLE(i2c, wm8955_i2c_id);
1009static struct i2c_driver wm8955_i2c_driver = { 1009static struct i2c_driver wm8955_i2c_driver = {
1010 .driver = { 1010 .driver = {
1011 .name = "wm8955", 1011 .name = "wm8955",
1012 .owner = THIS_MODULE,
1013 }, 1012 },
1014 .probe = wm8955_i2c_probe, 1013 .probe = wm8955_i2c_probe,
1015 .remove = wm8955_i2c_remove, 1014 .remove = wm8955_i2c_remove,
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index 94c5c4681ce5..1ed0720b41f0 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -1216,7 +1216,6 @@ MODULE_DEVICE_TABLE(of, wm8960_of_match);
1216static struct i2c_driver wm8960_i2c_driver = { 1216static struct i2c_driver wm8960_i2c_driver = {
1217 .driver = { 1217 .driver = {
1218 .name = "wm8960", 1218 .name = "wm8960",
1219 .owner = THIS_MODULE,
1220 .of_match_table = wm8960_of_match, 1219 .of_match_table = wm8960_of_match,
1221 }, 1220 },
1222 .probe = wm8960_i2c_probe, 1221 .probe = wm8960_i2c_probe,
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c
index a057662632ff..20a010344fd5 100644
--- a/sound/soc/codecs/wm8961.c
+++ b/sound/soc/codecs/wm8961.c
@@ -982,7 +982,6 @@ MODULE_DEVICE_TABLE(i2c, wm8961_i2c_id);
982static struct i2c_driver wm8961_i2c_driver = { 982static struct i2c_driver wm8961_i2c_driver = {
983 .driver = { 983 .driver = {
984 .name = "wm8961", 984 .name = "wm8961",
985 .owner = THIS_MODULE,
986 }, 985 },
987 .probe = wm8961_i2c_probe, 986 .probe = wm8961_i2c_probe,
988 .remove = wm8961_i2c_remove, 987 .remove = wm8961_i2c_remove,
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index c5748fd4f296..5c01707d4999 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -113,7 +113,7 @@ WM8962_REGULATOR_EVENT(5)
113WM8962_REGULATOR_EVENT(6) 113WM8962_REGULATOR_EVENT(6)
114WM8962_REGULATOR_EVENT(7) 114WM8962_REGULATOR_EVENT(7)
115 115
116static struct reg_default wm8962_reg[] = { 116static const struct reg_default wm8962_reg[] = {
117 { 0, 0x009F }, /* R0 - Left Input volume */ 117 { 0, 0x009F }, /* R0 - Left Input volume */
118 { 1, 0x049F }, /* R1 - Right Input volume */ 118 { 1, 0x049F }, /* R1 - Right Input volume */
119 { 2, 0x0000 }, /* R2 - HPOUTL volume */ 119 { 2, 0x0000 }, /* R2 - HPOUTL volume */
@@ -3495,7 +3495,7 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8962 = {
3495}; 3495};
3496 3496
3497/* Improve power consumption for IN4 DC measurement mode */ 3497/* Improve power consumption for IN4 DC measurement mode */
3498static const struct reg_default wm8962_dc_measure[] = { 3498static const struct reg_sequence wm8962_dc_measure[] = {
3499 { 0xfd, 0x1 }, 3499 { 0xfd, 0x1 },
3500 { 0xcc, 0x40 }, 3500 { 0xcc, 0x40 },
3501 { 0xfd, 0 }, 3501 { 0xfd, 0 },
@@ -3859,7 +3859,7 @@ static int wm8962_runtime_suspend(struct device *dev)
3859} 3859}
3860#endif 3860#endif
3861 3861
3862static struct dev_pm_ops wm8962_pm = { 3862static const struct dev_pm_ops wm8962_pm = {
3863 SET_RUNTIME_PM_OPS(wm8962_runtime_suspend, wm8962_runtime_resume, NULL) 3863 SET_RUNTIME_PM_OPS(wm8962_runtime_suspend, wm8962_runtime_resume, NULL)
3864}; 3864};
3865 3865
@@ -3878,7 +3878,6 @@ MODULE_DEVICE_TABLE(of, wm8962_of_match);
3878static struct i2c_driver wm8962_i2c_driver = { 3878static struct i2c_driver wm8962_i2c_driver = {
3879 .driver = { 3879 .driver = {
3880 .name = "wm8962", 3880 .name = "wm8962",
3881 .owner = THIS_MODULE,
3882 .of_match_table = wm8962_of_match, 3881 .of_match_table = wm8962_of_match,
3883 .pm = &wm8962_pm, 3882 .pm = &wm8962_pm,
3884 }, 3883 },
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c
index b51184c4e816..2cdde32c43c6 100644
--- a/sound/soc/codecs/wm8971.c
+++ b/sound/soc/codecs/wm8971.c
@@ -710,7 +710,6 @@ MODULE_DEVICE_TABLE(i2c, wm8971_i2c_id);
710static struct i2c_driver wm8971_i2c_driver = { 710static struct i2c_driver wm8971_i2c_driver = {
711 .driver = { 711 .driver = {
712 .name = "wm8971", 712 .name = "wm8971",
713 .owner = THIS_MODULE,
714 }, 713 },
715 .probe = wm8971_i2c_probe, 714 .probe = wm8971_i2c_probe,
716 .remove = wm8971_i2c_remove, 715 .remove = wm8971_i2c_remove,
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c
index 33b16a7ba82e..0a60677397b3 100644
--- a/sound/soc/codecs/wm8974.c
+++ b/sound/soc/codecs/wm8974.c
@@ -634,7 +634,6 @@ MODULE_DEVICE_TABLE(i2c, wm8974_i2c_id);
634static struct i2c_driver wm8974_i2c_driver = { 634static struct i2c_driver wm8974_i2c_driver = {
635 .driver = { 635 .driver = {
636 .name = "wm8974", 636 .name = "wm8974",
637 .owner = THIS_MODULE,
638 }, 637 },
639 .probe = wm8974_i2c_probe, 638 .probe = wm8974_i2c_probe,
640 .remove = wm8974_i2c_remove, 639 .remove = wm8974_i2c_remove,
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index cfc8cdf49970..d36d6001fbb7 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -1072,7 +1072,6 @@ MODULE_DEVICE_TABLE(i2c, wm8978_i2c_id);
1072static struct i2c_driver wm8978_i2c_driver = { 1072static struct i2c_driver wm8978_i2c_driver = {
1073 .driver = { 1073 .driver = {
1074 .name = "wm8978", 1074 .name = "wm8978",
1075 .owner = THIS_MODULE,
1076 }, 1075 },
1077 .probe = wm8978_i2c_probe, 1076 .probe = wm8978_i2c_probe,
1078 .remove = wm8978_i2c_remove, 1077 .remove = wm8978_i2c_remove,
diff --git a/sound/soc/codecs/wm8983.c b/sound/soc/codecs/wm8983.c
index 2fdd2c6cc09d..f6861cc4c321 100644
--- a/sound/soc/codecs/wm8983.c
+++ b/sound/soc/codecs/wm8983.c
@@ -1133,7 +1133,6 @@ MODULE_DEVICE_TABLE(i2c, wm8983_i2c_id);
1133static struct i2c_driver wm8983_i2c_driver = { 1133static struct i2c_driver wm8983_i2c_driver = {
1134 .driver = { 1134 .driver = {
1135 .name = "wm8983", 1135 .name = "wm8983",
1136 .owner = THIS_MODULE,
1137 }, 1136 },
1138 .probe = wm8983_i2c_probe, 1137 .probe = wm8983_i2c_probe,
1139 .remove = wm8983_i2c_remove, 1138 .remove = wm8983_i2c_remove,
diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c
index 8a85f5004d41..9c3c1517a4f3 100644
--- a/sound/soc/codecs/wm8985.c
+++ b/sound/soc/codecs/wm8985.c
@@ -1144,7 +1144,6 @@ MODULE_DEVICE_TABLE(i2c, wm8985_i2c_id);
1144static struct i2c_driver wm8985_i2c_driver = { 1144static struct i2c_driver wm8985_i2c_driver = {
1145 .driver = { 1145 .driver = {
1146 .name = "wm8985", 1146 .name = "wm8985",
1147 .owner = THIS_MODULE,
1148 }, 1147 },
1149 .probe = wm8985_i2c_probe, 1148 .probe = wm8985_i2c_probe,
1150 .remove = wm8985_i2c_remove, 1149 .remove = wm8985_i2c_remove,
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c
index f13a995af277..c88ce99ce9e1 100644
--- a/sound/soc/codecs/wm8988.c
+++ b/sound/soc/codecs/wm8988.c
@@ -919,7 +919,6 @@ MODULE_DEVICE_TABLE(i2c, wm8988_i2c_id);
919static struct i2c_driver wm8988_i2c_driver = { 919static struct i2c_driver wm8988_i2c_driver = {
920 .driver = { 920 .driver = {
921 .name = "wm8988", 921 .name = "wm8988",
922 .owner = THIS_MODULE,
923 }, 922 },
924 .probe = wm8988_i2c_probe, 923 .probe = wm8988_i2c_probe,
925 .remove = wm8988_i2c_remove, 924 .remove = wm8988_i2c_remove,
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c
index 1993fd2a6f15..83d72d8bc51b 100644
--- a/sound/soc/codecs/wm8990.c
+++ b/sound/soc/codecs/wm8990.c
@@ -1356,7 +1356,6 @@ MODULE_DEVICE_TABLE(i2c, wm8990_i2c_id);
1356static struct i2c_driver wm8990_i2c_driver = { 1356static struct i2c_driver wm8990_i2c_driver = {
1357 .driver = { 1357 .driver = {
1358 .name = "wm8990", 1358 .name = "wm8990",
1359 .owner = THIS_MODULE,
1360 }, 1359 },
1361 .probe = wm8990_i2c_probe, 1360 .probe = wm8990_i2c_probe,
1362 .remove = wm8990_i2c_remove, 1361 .remove = wm8990_i2c_remove,
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c
index 44a677720828..709d16e338d9 100644
--- a/sound/soc/codecs/wm8991.c
+++ b/sound/soc/codecs/wm8991.c
@@ -1363,7 +1363,6 @@ MODULE_DEVICE_TABLE(i2c, wm8991_i2c_id);
1363static struct i2c_driver wm8991_i2c_driver = { 1363static struct i2c_driver wm8991_i2c_driver = {
1364 .driver = { 1364 .driver = {
1365 .name = "wm8991", 1365 .name = "wm8991",
1366 .owner = THIS_MODULE,
1367 }, 1366 },
1368 .probe = wm8991_i2c_probe, 1367 .probe = wm8991_i2c_probe,
1369 .remove = wm8991_i2c_remove, 1368 .remove = wm8991_i2c_remove,
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c
index 8a8db8605dc2..ac9efd63dbef 100644
--- a/sound/soc/codecs/wm8993.c
+++ b/sound/soc/codecs/wm8993.c
@@ -41,7 +41,7 @@ static const char *wm8993_supply_names[WM8993_NUM_SUPPLIES] = {
41 "SPKVDD", 41 "SPKVDD",
42}; 42};
43 43
44static struct reg_default wm8993_reg_defaults[] = { 44static const struct reg_default wm8993_reg_defaults[] = {
45 { 1, 0x0000 }, /* R1 - Power Management (1) */ 45 { 1, 0x0000 }, /* R1 - Power Management (1) */
46 { 2, 0x6000 }, /* R2 - Power Management (2) */ 46 { 2, 0x6000 }, /* R2 - Power Management (2) */
47 { 3, 0x0000 }, /* R3 - Power Management (3) */ 47 { 3, 0x0000 }, /* R3 - Power Management (3) */
@@ -1595,7 +1595,7 @@ static int wm8993_resume(struct snd_soc_codec *codec)
1595#endif 1595#endif
1596 1596
1597/* Tune DC servo configuration */ 1597/* Tune DC servo configuration */
1598static struct reg_default wm8993_regmap_patch[] = { 1598static const struct reg_sequence wm8993_regmap_patch[] = {
1599 { 0x44, 3 }, 1599 { 0x44, 3 },
1600 { 0x56, 3 }, 1600 { 0x56, 3 },
1601 { 0x44, 0 }, 1601 { 0x44, 0 },
@@ -1742,7 +1742,6 @@ MODULE_DEVICE_TABLE(i2c, wm8993_i2c_id);
1742static struct i2c_driver wm8993_i2c_driver = { 1742static struct i2c_driver wm8993_i2c_driver = {
1743 .driver = { 1743 .driver = {
1744 .name = "wm8993", 1744 .name = "wm8993",
1745 .owner = THIS_MODULE,
1746 }, 1745 },
1747 .probe = wm8993_i2c_probe, 1746 .probe = wm8993_i2c_probe,
1748 .remove = wm8993_i2c_remove, 1747 .remove = wm8993_i2c_remove,
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 962e1d31a629..2ccbb322df77 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -1942,14 +1942,16 @@ static const struct snd_soc_dapm_route intercon[] = {
1942 { "AIF2ADCDAT", NULL, "AIF2ADC Mux" }, 1942 { "AIF2ADCDAT", NULL, "AIF2ADC Mux" },
1943 1943
1944 /* AIF3 output */ 1944 /* AIF3 output */
1945 { "AIF3ADCDAT", "AIF1ADCDAT", "AIF1ADC1L" }, 1945 { "AIF3ADC Mux", "AIF1ADCDAT", "AIF1ADC1L" },
1946 { "AIF3ADCDAT", "AIF1ADCDAT", "AIF1ADC1R" }, 1946 { "AIF3ADC Mux", "AIF1ADCDAT", "AIF1ADC1R" },
1947 { "AIF3ADCDAT", "AIF1ADCDAT", "AIF1ADC2L" }, 1947 { "AIF3ADC Mux", "AIF1ADCDAT", "AIF1ADC2L" },
1948 { "AIF3ADCDAT", "AIF1ADCDAT", "AIF1ADC2R" }, 1948 { "AIF3ADC Mux", "AIF1ADCDAT", "AIF1ADC2R" },
1949 { "AIF3ADCDAT", "AIF2ADCDAT", "AIF2ADCL" }, 1949 { "AIF3ADC Mux", "AIF2ADCDAT", "AIF2ADCL" },
1950 { "AIF3ADCDAT", "AIF2ADCDAT", "AIF2ADCR" }, 1950 { "AIF3ADC Mux", "AIF2ADCDAT", "AIF2ADCR" },
1951 { "AIF3ADCDAT", "AIF2DACDAT", "AIF2DACL" }, 1951 { "AIF3ADC Mux", "AIF2DACDAT", "AIF2DACL" },
1952 { "AIF3ADCDAT", "AIF2DACDAT", "AIF2DACR" }, 1952 { "AIF3ADC Mux", "AIF2DACDAT", "AIF2DACR" },
1953
1954 { "AIF3ADCDAT", NULL, "AIF3ADC Mux" },
1953 1955
1954 /* Loopback */ 1956 /* Loopback */
1955 { "AIF1 Loopback", "ADCDAT", "AIF1ADCDAT" }, 1957 { "AIF1 Loopback", "ADCDAT", "AIF1ADCDAT" },
diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c
index 505b65f5734f..eda52a96c1fa 100644
--- a/sound/soc/codecs/wm8995.c
+++ b/sound/soc/codecs/wm8995.c
@@ -2298,7 +2298,6 @@ MODULE_DEVICE_TABLE(i2c, wm8995_i2c_id);
2298static struct i2c_driver wm8995_i2c_driver = { 2298static struct i2c_driver wm8995_i2c_driver = {
2299 .driver = { 2299 .driver = {
2300 .name = "wm8995", 2300 .name = "wm8995",
2301 .owner = THIS_MODULE,
2302 }, 2301 },
2303 .probe = wm8995_i2c_probe, 2302 .probe = wm8995_i2c_probe,
2304 .remove = wm8995_i2c_remove, 2303 .remove = wm8995_i2c_remove,
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c
index 3dd063f682b2..66c09556da79 100644
--- a/sound/soc/codecs/wm8996.c
+++ b/sound/soc/codecs/wm8996.c
@@ -117,7 +117,7 @@ WM8996_REGULATOR_EVENT(0)
117WM8996_REGULATOR_EVENT(1) 117WM8996_REGULATOR_EVENT(1)
118WM8996_REGULATOR_EVENT(2) 118WM8996_REGULATOR_EVENT(2)
119 119
120static struct reg_default wm8996_reg[] = { 120static const struct reg_default wm8996_reg[] = {
121 { WM8996_POWER_MANAGEMENT_1, 0x0 }, 121 { WM8996_POWER_MANAGEMENT_1, 0x0 },
122 { WM8996_POWER_MANAGEMENT_2, 0x0 }, 122 { WM8996_POWER_MANAGEMENT_2, 0x0 },
123 { WM8996_POWER_MANAGEMENT_3, 0x0 }, 123 { WM8996_POWER_MANAGEMENT_3, 0x0 },
@@ -3100,7 +3100,6 @@ MODULE_DEVICE_TABLE(i2c, wm8996_i2c_id);
3100static struct i2c_driver wm8996_i2c_driver = { 3100static struct i2c_driver wm8996_i2c_driver = {
3101 .driver = { 3101 .driver = {
3102 .name = "wm8996", 3102 .name = "wm8996",
3103 .owner = THIS_MODULE,
3104 }, 3103 },
3105 .probe = wm8996_i2c_probe, 3104 .probe = wm8996_i2c_probe,
3106 .remove = wm8996_i2c_remove, 3105 .remove = wm8996_i2c_remove,
diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c
index 4134dc7e1243..b4dba3a02aba 100644
--- a/sound/soc/codecs/wm8997.c
+++ b/sound/soc/codecs/wm8997.c
@@ -174,8 +174,7 @@ ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
174ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), 174ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
175ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), 175ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
176 176
177SND_SOC_BYTES("EQ1 Coefficients", ARIZONA_EQ1_3, 19), 177ARIZONA_EQ_CONTROL("EQ1 Coefficients", ARIZONA_EQ1_2),
178SOC_SINGLE("EQ1 Mode Switch", ARIZONA_EQ1_2, ARIZONA_EQ1_B1_MODE, 1, 0),
179SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, 178SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
180 24, 0, eq_tlv), 179 24, 0, eq_tlv),
181SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT, 180SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
@@ -187,8 +186,7 @@ SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT,
187SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT, 186SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT,
188 24, 0, eq_tlv), 187 24, 0, eq_tlv),
189 188
190SND_SOC_BYTES("EQ2 Coefficients", ARIZONA_EQ2_3, 19), 189ARIZONA_EQ_CONTROL("EQ2 Coefficients", ARIZONA_EQ2_2),
191SOC_SINGLE("EQ2 Mode Switch", ARIZONA_EQ2_2, ARIZONA_EQ2_B1_MODE, 1, 0),
192SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT, 190SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT,
193 24, 0, eq_tlv), 191 24, 0, eq_tlv),
194SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT, 192SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT,
@@ -200,8 +198,7 @@ SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT,
200SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT, 198SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT,
201 24, 0, eq_tlv), 199 24, 0, eq_tlv),
202 200
203SND_SOC_BYTES("EQ3 Coefficients", ARIZONA_EQ3_3, 19), 201ARIZONA_EQ_CONTROL("EQ3 Coefficients", ARIZONA_EQ3_2),
204SOC_SINGLE("EQ3 Mode Switch", ARIZONA_EQ3_2, ARIZONA_EQ3_B1_MODE, 1, 0),
205SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT, 202SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT,
206 24, 0, eq_tlv), 203 24, 0, eq_tlv),
207SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT, 204SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT,
@@ -213,8 +210,7 @@ SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT,
213SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT, 210SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT,
214 24, 0, eq_tlv), 211 24, 0, eq_tlv),
215 212
216SND_SOC_BYTES("EQ4 Coefficients", ARIZONA_EQ4_3, 19), 213ARIZONA_EQ_CONTROL("EQ4 Coefficients", ARIZONA_EQ4_2),
217SOC_SINGLE("EQ4 Mode Switch", ARIZONA_EQ4_2, ARIZONA_EQ4_B1_MODE, 1, 0),
218SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT, 214SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT,
219 24, 0, eq_tlv), 215 24, 0, eq_tlv),
220SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT, 216SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT,
@@ -242,10 +238,10 @@ SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
242SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), 238SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
243SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode), 239SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode),
244 240
245SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1), 241ARIZONA_LHPF_CONTROL("LHPF1 Coefficients", ARIZONA_HPLPF1_2),
246SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1), 242ARIZONA_LHPF_CONTROL("LHPF2 Coefficients", ARIZONA_HPLPF2_2),
247SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1), 243ARIZONA_LHPF_CONTROL("LHPF3 Coefficients", ARIZONA_HPLPF3_2),
248SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1), 244ARIZONA_LHPF_CONTROL("LHPF4 Coefficients", ARIZONA_HPLPF4_2),
249 245
250SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), 246SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]),
251SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), 247SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]),
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c
index 8a8b1c0f9142..45223a20331f 100644
--- a/sound/soc/codecs/wm9081.c
+++ b/sound/soc/codecs/wm9081.c
@@ -30,7 +30,7 @@
30#include <sound/wm9081.h> 30#include <sound/wm9081.h>
31#include "wm9081.h" 31#include "wm9081.h"
32 32
33static struct reg_default wm9081_reg[] = { 33static const struct reg_default wm9081_reg[] = {
34 { 2, 0x00B9 }, /* R2 - Analogue Lineout */ 34 { 2, 0x00B9 }, /* R2 - Analogue Lineout */
35 { 3, 0x00B9 }, /* R3 - Analogue Speaker PGA */ 35 { 3, 0x00B9 }, /* R3 - Analogue Speaker PGA */
36 { 4, 0x0001 }, /* R4 - VMID Control */ 36 { 4, 0x0001 }, /* R4 - VMID Control */
@@ -1378,7 +1378,6 @@ MODULE_DEVICE_TABLE(i2c, wm9081_i2c_id);
1378static struct i2c_driver wm9081_i2c_driver = { 1378static struct i2c_driver wm9081_i2c_driver = {
1379 .driver = { 1379 .driver = {
1380 .name = "wm9081", 1380 .name = "wm9081",
1381 .owner = THIS_MODULE,
1382 }, 1381 },
1383 .probe = wm9081_i2c_probe, 1382 .probe = wm9081_i2c_probe,
1384 .remove = wm9081_i2c_remove, 1383 .remove = wm9081_i2c_remove,
diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c
index 13d23fc797db..12baf725d4a5 100644
--- a/sound/soc/codecs/wm9090.c
+++ b/sound/soc/codecs/wm9090.c
@@ -636,7 +636,6 @@ MODULE_DEVICE_TABLE(i2c, wm9090_id);
636static struct i2c_driver wm9090_i2c_driver = { 636static struct i2c_driver wm9090_i2c_driver = {
637 .driver = { 637 .driver = {
638 .name = "wm9090", 638 .name = "wm9090",
639 .owner = THIS_MODULE,
640 }, 639 },
641 .probe = wm9090_i2c_probe, 640 .probe = wm9090_i2c_probe,
642 .remove = wm9090_i2c_remove, 641 .remove = wm9090_i2c_remove,
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c
index 5cc457ef8894..744842c76a60 100644
--- a/sound/soc/codecs/wm9705.c
+++ b/sound/soc/codecs/wm9705.c
@@ -22,6 +22,9 @@
22 22
23#include "wm9705.h" 23#include "wm9705.h"
24 24
25#define WM9705_VENDOR_ID 0x574d4c05
26#define WM9705_VENDOR_ID_MASK 0xffffffff
27
25/* 28/*
26 * WM9705 register cache 29 * WM9705 register cache
27 */ 30 */
@@ -293,21 +296,6 @@ static struct snd_soc_dai_driver wm9705_dai[] = {
293 } 296 }
294}; 297};
295 298
296static int wm9705_reset(struct snd_soc_codec *codec)
297{
298 struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
299
300 if (soc_ac97_ops->reset) {
301 soc_ac97_ops->reset(ac97);
302 if (ac97_read(codec, 0) == wm9705_reg[0])
303 return 0; /* Success */
304 }
305
306 dev_err(codec->dev, "Failed to reset: AC97 link error\n");
307
308 return -EIO;
309}
310
311#ifdef CONFIG_PM 299#ifdef CONFIG_PM
312static int wm9705_soc_suspend(struct snd_soc_codec *codec) 300static int wm9705_soc_suspend(struct snd_soc_codec *codec)
313{ 301{
@@ -324,7 +312,8 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)
324 int i, ret; 312 int i, ret;
325 u16 *cache = codec->reg_cache; 313 u16 *cache = codec->reg_cache;
326 314
327 ret = wm9705_reset(codec); 315 ret = snd_ac97_reset(ac97, true, WM9705_VENDOR_ID,
316 WM9705_VENDOR_ID_MASK);
328 if (ret < 0) 317 if (ret < 0)
329 return ret; 318 return ret;
330 319
@@ -342,30 +331,17 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)
342static int wm9705_soc_probe(struct snd_soc_codec *codec) 331static int wm9705_soc_probe(struct snd_soc_codec *codec)
343{ 332{
344 struct snd_ac97 *ac97; 333 struct snd_ac97 *ac97;
345 int ret = 0;
346 334
347 ac97 = snd_soc_alloc_ac97_codec(codec); 335 ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID,
336 WM9705_VENDOR_ID_MASK);
348 if (IS_ERR(ac97)) { 337 if (IS_ERR(ac97)) {
349 ret = PTR_ERR(ac97);
350 dev_err(codec->dev, "Failed to register AC97 codec\n"); 338 dev_err(codec->dev, "Failed to register AC97 codec\n");
351 return ret; 339 return PTR_ERR(ac97);
352 } 340 }
353 341
354 ret = wm9705_reset(codec);
355 if (ret)
356 goto err_put_device;
357
358 ret = device_add(&ac97->dev);
359 if (ret)
360 goto err_put_device;
361
362 snd_soc_codec_set_drvdata(codec, ac97); 342 snd_soc_codec_set_drvdata(codec, ac97);
363 343
364 return 0; 344 return 0;
365
366err_put_device:
367 put_device(&ac97->dev);
368 return ret;
369} 345}
370 346
371static int wm9705_soc_remove(struct snd_soc_codec *codec) 347static int wm9705_soc_remove(struct snd_soc_codec *codec)
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index 1fda104dfc45..488a92224249 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -23,6 +23,9 @@
23#include <sound/tlv.h> 23#include <sound/tlv.h>
24#include "wm9712.h" 24#include "wm9712.h"
25 25
26#define WM9712_VENDOR_ID 0x574d4c12
27#define WM9712_VENDOR_ID_MASK 0xffffffff
28
26struct wm9712_priv { 29struct wm9712_priv {
27 struct snd_ac97 *ac97; 30 struct snd_ac97 *ac97;
28 unsigned int hp_mixer[2]; 31 unsigned int hp_mixer[2];
@@ -613,35 +616,14 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec,
613 return 0; 616 return 0;
614} 617}
615 618
616static int wm9712_reset(struct snd_soc_codec *codec, int try_warm)
617{
618 struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
619
620 if (try_warm && soc_ac97_ops->warm_reset) {
621 soc_ac97_ops->warm_reset(wm9712->ac97);
622 if (ac97_read(codec, 0) == wm9712_reg[0])
623 return 1;
624 }
625
626 soc_ac97_ops->reset(wm9712->ac97);
627 if (soc_ac97_ops->warm_reset)
628 soc_ac97_ops->warm_reset(wm9712->ac97);
629 if (ac97_read(codec, 0) != wm9712_reg[0])
630 goto err;
631 return 0;
632
633err:
634 dev_err(codec->dev, "Failed to reset: AC97 link error\n");
635 return -EIO;
636}
637
638static int wm9712_soc_resume(struct snd_soc_codec *codec) 619static int wm9712_soc_resume(struct snd_soc_codec *codec)
639{ 620{
640 struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); 621 struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
641 int i, ret; 622 int i, ret;
642 u16 *cache = codec->reg_cache; 623 u16 *cache = codec->reg_cache;
643 624
644 ret = wm9712_reset(codec, 1); 625 ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID,
626 WM9712_VENDOR_ID_MASK);
645 if (ret < 0) 627 if (ret < 0)
646 return ret; 628 return ret;
647 629
@@ -663,31 +645,20 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec)
663static int wm9712_soc_probe(struct snd_soc_codec *codec) 645static int wm9712_soc_probe(struct snd_soc_codec *codec)
664{ 646{
665 struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); 647 struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
666 int ret = 0; 648 int ret;
667 649
668 wm9712->ac97 = snd_soc_alloc_ac97_codec(codec); 650 wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID,
651 WM9712_VENDOR_ID_MASK);
669 if (IS_ERR(wm9712->ac97)) { 652 if (IS_ERR(wm9712->ac97)) {
670 ret = PTR_ERR(wm9712->ac97); 653 ret = PTR_ERR(wm9712->ac97);
671 dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); 654 dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret);
672 return ret; 655 return ret;
673 } 656 }
674 657
675 ret = wm9712_reset(codec, 0);
676 if (ret < 0)
677 goto err_put_device;
678
679 ret = device_add(&wm9712->ac97->dev);
680 if (ret)
681 goto err_put_device;
682
683 /* set alc mux to none */ 658 /* set alc mux to none */
684 ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000); 659 ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000);
685 660
686 return 0; 661 return 0;
687
688err_put_device:
689 put_device(&wm9712->ac97->dev);
690 return ret;
691} 662}
692 663
693static int wm9712_soc_remove(struct snd_soc_codec *codec) 664static int wm9712_soc_remove(struct snd_soc_codec *codec)
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
index 89cd2d6f57c0..955e6511af56 100644
--- a/sound/soc/codecs/wm9713.c
+++ b/sound/soc/codecs/wm9713.c
@@ -29,6 +29,9 @@
29 29
30#include "wm9713.h" 30#include "wm9713.h"
31 31
32#define WM9713_VENDOR_ID 0x574d4c13
33#define WM9713_VENDOR_ID_MASK 0xffffffff
34
32struct wm9713_priv { 35struct wm9713_priv {
33 struct snd_ac97 *ac97; 36 struct snd_ac97 *ac97;
34 u32 pll_in; /* PLL input frequency */ 37 u32 pll_in; /* PLL input frequency */
@@ -1123,28 +1126,6 @@ static struct snd_soc_dai_driver wm9713_dai[] = {
1123 }, 1126 },
1124}; 1127};
1125 1128
1126int wm9713_reset(struct snd_soc_codec *codec, int try_warm)
1127{
1128 struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
1129
1130 if (try_warm && soc_ac97_ops->warm_reset) {
1131 soc_ac97_ops->warm_reset(wm9713->ac97);
1132 if (ac97_read(codec, 0) == wm9713_reg[0])
1133 return 1;
1134 }
1135
1136 soc_ac97_ops->reset(wm9713->ac97);
1137 if (soc_ac97_ops->warm_reset)
1138 soc_ac97_ops->warm_reset(wm9713->ac97);
1139 if (ac97_read(codec, 0) != wm9713_reg[0]) {
1140 dev_err(codec->dev, "Failed to reset: AC97 link error\n");
1141 return -EIO;
1142 }
1143
1144 return 0;
1145}
1146EXPORT_SYMBOL_GPL(wm9713_reset);
1147
1148static int wm9713_set_bias_level(struct snd_soc_codec *codec, 1129static int wm9713_set_bias_level(struct snd_soc_codec *codec,
1149 enum snd_soc_bias_level level) 1130 enum snd_soc_bias_level level)
1150{ 1131{
@@ -1196,7 +1177,8 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec)
1196 int i, ret; 1177 int i, ret;
1197 u16 *cache = codec->reg_cache; 1178 u16 *cache = codec->reg_cache;
1198 1179
1199 ret = wm9713_reset(codec, 1); 1180 ret = snd_ac97_reset(wm9713->ac97, true, WM9713_VENDOR_ID,
1181 WM9713_VENDOR_ID_MASK);
1200 if (ret < 0) 1182 if (ret < 0)
1201 return ret; 1183 return ret;
1202 1184
@@ -1222,32 +1204,18 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec)
1222static int wm9713_soc_probe(struct snd_soc_codec *codec) 1204static int wm9713_soc_probe(struct snd_soc_codec *codec)
1223{ 1205{
1224 struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); 1206 struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
1225 int ret = 0, reg; 1207 int reg;
1226 1208
1227 wm9713->ac97 = snd_soc_alloc_ac97_codec(codec); 1209 wm9713->ac97 = snd_soc_new_ac97_codec(codec, WM9713_VENDOR_ID,
1210 WM9713_VENDOR_ID_MASK);
1228 if (IS_ERR(wm9713->ac97)) 1211 if (IS_ERR(wm9713->ac97))
1229 return PTR_ERR(wm9713->ac97); 1212 return PTR_ERR(wm9713->ac97);
1230 1213
1231 /* do a cold reset for the controller and then try
1232 * a warm reset followed by an optional cold reset for codec */
1233 wm9713_reset(codec, 0);
1234 ret = wm9713_reset(codec, 1);
1235 if (ret < 0)
1236 goto err_put_device;
1237
1238 ret = device_add(&wm9713->ac97->dev);
1239 if (ret)
1240 goto err_put_device;
1241
1242 /* unmute the adc - move to kcontrol */ 1214 /* unmute the adc - move to kcontrol */
1243 reg = ac97_read(codec, AC97_CD) & 0x7fff; 1215 reg = ac97_read(codec, AC97_CD) & 0x7fff;
1244 ac97_write(codec, AC97_CD, reg); 1216 ac97_write(codec, AC97_CD, reg);
1245 1217
1246 return 0; 1218 return 0;
1247
1248err_put_device:
1249 put_device(&wm9713->ac97->dev);
1250 return ret;
1251} 1219}
1252 1220
1253static int wm9713_soc_remove(struct snd_soc_codec *codec) 1221static int wm9713_soc_remove(struct snd_soc_codec *codec)
diff --git a/sound/soc/codecs/wm9713.h b/sound/soc/codecs/wm9713.h
index 793da863a03d..53df11b1f727 100644
--- a/sound/soc/codecs/wm9713.h
+++ b/sound/soc/codecs/wm9713.h
@@ -45,6 +45,4 @@
45#define WM9713_DAI_AC97_AUX 1 45#define WM9713_DAI_AC97_AUX 1
46#define WM9713_DAI_PCM_VOICE 2 46#define WM9713_DAI_PCM_VOICE 2
47 47
48int wm9713_reset(struct snd_soc_codec *codec, int try_warm);
49
50#endif 48#endif