Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 1 | /* |
| 2 | * ad1980.c -- ALSA Soc AD1980 codec support |
| 3 | * |
| 4 | * Copyright: Analog Device Inc. |
| 5 | * Author: Roy Huang <roy.huang@analog.com> |
| 6 | * Cliff Cai <cliff.cai@analog.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the |
| 10 | * Free Software Foundation; either version 2 of the License, or (at your |
| 11 | * option) any later version. |
| 12 | */ |
| 13 | |
Sonic Zhang | 2e2211a | 2010-08-07 12:06:07 -0400 | [diff] [blame] | 14 | /* |
| 15 | * WARNING: |
| 16 | * |
| 17 | * Because Analog Devices Inc. discontinued the ad1980 sound chip since |
| 18 | * Sep. 2009, this ad1980 driver is not maintained, tested and supported |
| 19 | * by ADI now. |
| 20 | */ |
| 21 | |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 22 | #include <linux/init.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 23 | #include <linux/slab.h> |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 24 | #include <linux/module.h> |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 25 | #include <linux/kernel.h> |
| 26 | #include <linux/device.h> |
Lars-Peter Clausen | 82d1463 | 2014-11-18 19:45:53 +0100 | [diff] [blame] | 27 | #include <linux/regmap.h> |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 28 | #include <sound/core.h> |
| 29 | #include <sound/pcm.h> |
| 30 | #include <sound/ac97_codec.h> |
| 31 | #include <sound/initval.h> |
| 32 | #include <sound/soc.h> |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 33 | |
Lars-Peter Clausen | 82d1463 | 2014-11-18 19:45:53 +0100 | [diff] [blame] | 34 | static const struct reg_default ad1980_reg_defaults[] = { |
| 35 | { 0x02, 0x8000 }, |
| 36 | { 0x04, 0x8000 }, |
| 37 | { 0x06, 0x8000 }, |
| 38 | { 0x0c, 0x8008 }, |
| 39 | { 0x0e, 0x8008 }, |
| 40 | { 0x10, 0x8808 }, |
| 41 | { 0x12, 0x8808 }, |
| 42 | { 0x16, 0x8808 }, |
| 43 | { 0x18, 0x8808 }, |
| 44 | { 0x1a, 0x0000 }, |
| 45 | { 0x1c, 0x8000 }, |
| 46 | { 0x20, 0x0000 }, |
| 47 | { 0x28, 0x03c7 }, |
| 48 | { 0x2c, 0xbb80 }, |
| 49 | { 0x2e, 0xbb80 }, |
| 50 | { 0x30, 0xbb80 }, |
| 51 | { 0x32, 0xbb80 }, |
| 52 | { 0x36, 0x8080 }, |
| 53 | { 0x38, 0x8080 }, |
| 54 | { 0x3a, 0x2000 }, |
| 55 | { 0x60, 0x0000 }, |
| 56 | { 0x62, 0x0000 }, |
| 57 | { 0x72, 0x0000 }, |
| 58 | { 0x74, 0x1001 }, |
| 59 | { 0x76, 0x0000 }, |
| 60 | }; |
| 61 | |
| 62 | static bool ad1980_readable_reg(struct device *dev, unsigned int reg) |
| 63 | { |
| 64 | switch (reg) { |
| 65 | case AC97_RESET ... AC97_MASTER_MONO: |
| 66 | case AC97_PHONE ... AC97_CD: |
| 67 | case AC97_AUX ... AC97_GENERAL_PURPOSE: |
| 68 | case AC97_POWERDOWN ... AC97_PCM_LR_ADC_RATE: |
| 69 | case AC97_SPDIF: |
| 70 | case AC97_CODEC_CLASS_REV: |
| 71 | case AC97_PCI_SVID: |
| 72 | case AC97_AD_CODEC_CFG: |
| 73 | case AC97_AD_JACK_SPDIF: |
| 74 | case AC97_AD_SERIAL_CFG: |
| 75 | case AC97_VENDOR_ID1: |
| 76 | case AC97_VENDOR_ID2: |
| 77 | return true; |
| 78 | default: |
| 79 | return false; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | static bool ad1980_writeable_reg(struct device *dev, unsigned int reg) |
| 84 | { |
| 85 | switch (reg) { |
| 86 | case AC97_VENDOR_ID1: |
| 87 | case AC97_VENDOR_ID2: |
| 88 | return false; |
| 89 | default: |
| 90 | return ad1980_readable_reg(dev, reg); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | static const struct regmap_config ad1980_regmap_config = { |
| 95 | .reg_bits = 16, |
| 96 | .reg_stride = 2, |
| 97 | .val_bits = 16, |
| 98 | .max_register = 0x7e, |
| 99 | .cache_type = REGCACHE_RBTREE, |
| 100 | |
| 101 | .volatile_reg = regmap_ac97_default_volatile, |
| 102 | .readable_reg = ad1980_readable_reg, |
| 103 | .writeable_reg = ad1980_writeable_reg, |
| 104 | |
| 105 | .reg_defaults = ad1980_reg_defaults, |
| 106 | .num_reg_defaults = ARRAY_SIZE(ad1980_reg_defaults), |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | static const char *ad1980_rec_sel[] = {"Mic", "CD", "NC", "AUX", "Line", |
| 110 | "Stereo Mix", "Mono Mix", "Phone"}; |
| 111 | |
Takashi Iwai | 901bb6c | 2014-02-18 09:56:40 +0100 | [diff] [blame] | 112 | static SOC_ENUM_DOUBLE_DECL(ad1980_cap_src, |
| 113 | AC97_REC_SEL, 8, 0, ad1980_rec_sel); |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 114 | |
| 115 | static const struct snd_kcontrol_new ad1980_snd_ac97_controls[] = { |
| 116 | SOC_DOUBLE("Master Playback Volume", AC97_MASTER, 8, 0, 31, 1), |
| 117 | SOC_SINGLE("Master Playback Switch", AC97_MASTER, 15, 1, 1), |
| 118 | |
| 119 | SOC_DOUBLE("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1), |
| 120 | SOC_SINGLE("Headphone Playback Switch", AC97_HEADPHONE, 15, 1, 1), |
| 121 | |
| 122 | SOC_DOUBLE("PCM Playback Volume", AC97_PCM, 8, 0, 31, 1), |
| 123 | SOC_SINGLE("PCM Playback Switch", AC97_PCM, 15, 1, 1), |
| 124 | |
| 125 | SOC_DOUBLE("PCM Capture Volume", AC97_REC_GAIN, 8, 0, 31, 0), |
| 126 | SOC_SINGLE("PCM Capture Switch", AC97_REC_GAIN, 15, 1, 1), |
| 127 | |
| 128 | SOC_SINGLE("Mono Playback Volume", AC97_MASTER_MONO, 0, 31, 1), |
| 129 | SOC_SINGLE("Mono Playback Switch", AC97_MASTER_MONO, 15, 1, 1), |
| 130 | |
| 131 | SOC_SINGLE("Phone Capture Volume", AC97_PHONE, 0, 31, 1), |
| 132 | SOC_SINGLE("Phone Capture Switch", AC97_PHONE, 15, 1, 1), |
| 133 | |
| 134 | SOC_SINGLE("Mic Volume", AC97_MIC, 0, 31, 1), |
| 135 | SOC_SINGLE("Mic Switch", AC97_MIC, 15, 1, 1), |
| 136 | |
| 137 | SOC_SINGLE("Stereo Mic Switch", AC97_AD_MISC, 6, 1, 0), |
| 138 | SOC_DOUBLE("Line HP Swap Switch", AC97_AD_MISC, 10, 5, 1, 0), |
| 139 | |
| 140 | SOC_DOUBLE("Surround Playback Volume", AC97_SURROUND_MASTER, 8, 0, 31, 1), |
| 141 | SOC_DOUBLE("Surround Playback Switch", AC97_SURROUND_MASTER, 15, 7, 1, 1), |
| 142 | |
Cliff Cai | 9905ed3 | 2008-11-18 16:18:16 +0800 | [diff] [blame] | 143 | SOC_DOUBLE("Center/LFE Playback Volume", AC97_CENTER_LFE_MASTER, 8, 0, 31, 1), |
| 144 | SOC_DOUBLE("Center/LFE Playback Switch", AC97_CENTER_LFE_MASTER, 15, 7, 1, 1), |
| 145 | |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 146 | SOC_ENUM("Capture Source", ad1980_cap_src), |
| 147 | |
| 148 | SOC_SINGLE("Mic Boost Switch", AC97_MIC, 6, 1, 0), |
| 149 | }; |
| 150 | |
Mark Brown | 9e7e474 | 2013-08-06 23:51:12 +0100 | [diff] [blame] | 151 | static const struct snd_soc_dapm_widget ad1980_dapm_widgets[] = { |
| 152 | SND_SOC_DAPM_INPUT("MIC1"), |
| 153 | SND_SOC_DAPM_INPUT("MIC2"), |
| 154 | SND_SOC_DAPM_INPUT("CD_L"), |
| 155 | SND_SOC_DAPM_INPUT("CD_R"), |
| 156 | SND_SOC_DAPM_INPUT("AUX_L"), |
| 157 | SND_SOC_DAPM_INPUT("AUX_R"), |
| 158 | SND_SOC_DAPM_INPUT("LINE_IN_L"), |
| 159 | SND_SOC_DAPM_INPUT("LINE_IN_R"), |
| 160 | |
| 161 | SND_SOC_DAPM_OUTPUT("LFE_OUT"), |
| 162 | SND_SOC_DAPM_OUTPUT("CENTER_OUT"), |
| 163 | SND_SOC_DAPM_OUTPUT("LINE_OUT_L"), |
| 164 | SND_SOC_DAPM_OUTPUT("LINE_OUT_R"), |
| 165 | SND_SOC_DAPM_OUTPUT("MONO_OUT"), |
| 166 | SND_SOC_DAPM_OUTPUT("HP_OUT_L"), |
| 167 | SND_SOC_DAPM_OUTPUT("HP_OUT_R"), |
| 168 | }; |
| 169 | |
| 170 | static const struct snd_soc_dapm_route ad1980_dapm_routes[] = { |
| 171 | { "Capture", NULL, "MIC1" }, |
| 172 | { "Capture", NULL, "MIC2" }, |
| 173 | { "Capture", NULL, "CD_L" }, |
| 174 | { "Capture", NULL, "CD_R" }, |
| 175 | { "Capture", NULL, "AUX_L" }, |
| 176 | { "Capture", NULL, "AUX_R" }, |
| 177 | { "Capture", NULL, "LINE_IN_L" }, |
| 178 | { "Capture", NULL, "LINE_IN_R" }, |
| 179 | |
| 180 | { "LFE_OUT", NULL, "Playback" }, |
| 181 | { "CENTER_OUT", NULL, "Playback" }, |
| 182 | { "LINE_OUT_L", NULL, "Playback" }, |
| 183 | { "LINE_OUT_R", NULL, "Playback" }, |
| 184 | { "MONO_OUT", NULL, "Playback" }, |
| 185 | { "HP_OUT_L", NULL, "Playback" }, |
| 186 | { "HP_OUT_R", NULL, "Playback" }, |
| 187 | }; |
| 188 | |
Mark Brown | de535a5 | 2010-10-06 16:20:07 -0700 | [diff] [blame] | 189 | static struct snd_soc_dai_driver ad1980_dai = { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 190 | .name = "ad1980-hifi", |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 191 | .playback = { |
| 192 | .stream_name = "Playback", |
| 193 | .channels_min = 2, |
Cliff Cai | 9905ed3 | 2008-11-18 16:18:16 +0800 | [diff] [blame] | 194 | .channels_max = 6, |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 195 | .rates = SNDRV_PCM_RATE_48000, |
Mark Brown | 33f503c | 2009-05-02 12:24:55 +0100 | [diff] [blame] | 196 | .formats = SND_SOC_STD_AC97_FMTS, }, |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 197 | .capture = { |
| 198 | .stream_name = "Capture", |
| 199 | .channels_min = 2, |
| 200 | .channels_max = 2, |
| 201 | .rates = SNDRV_PCM_RATE_48000, |
Mark Brown | 33f503c | 2009-05-02 12:24:55 +0100 | [diff] [blame] | 202 | .formats = SND_SOC_STD_AC97_FMTS, }, |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 203 | }; |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 204 | |
| 205 | static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) |
| 206 | { |
Lars-Peter Clausen | 358a8bb | 2014-11-10 22:41:53 +0100 | [diff] [blame] | 207 | struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); |
Lars-Peter Clausen | cf7b71f4 | 2014-05-20 14:23:10 +0200 | [diff] [blame] | 208 | unsigned int retry_cnt = 0; |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 209 | |
Lars-Peter Clausen | cf7b71f4 | 2014-05-20 14:23:10 +0200 | [diff] [blame] | 210 | do { |
| 211 | if (try_warm && soc_ac97_ops->warm_reset) { |
Lars-Peter Clausen | 358a8bb | 2014-11-10 22:41:53 +0100 | [diff] [blame] | 212 | soc_ac97_ops->warm_reset(ac97); |
Lars-Peter Clausen | 17bb577 | 2014-11-18 19:45:54 +0100 | [diff] [blame] | 213 | if (snd_soc_read(codec, AC97_RESET) == 0x0090) |
Lars-Peter Clausen | cf7b71f4 | 2014-05-20 14:23:10 +0200 | [diff] [blame] | 214 | return 1; |
| 215 | } |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 216 | |
Lars-Peter Clausen | 358a8bb | 2014-11-10 22:41:53 +0100 | [diff] [blame] | 217 | soc_ac97_ops->reset(ac97); |
Lars-Peter Clausen | cf7b71f4 | 2014-05-20 14:23:10 +0200 | [diff] [blame] | 218 | /* |
| 219 | * 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 |
| 221 | * case the first nibble of data is eaten by the addr. (Tag is |
| 222 | * always 16 bit) |
| 223 | */ |
Lars-Peter Clausen | 17bb577 | 2014-11-18 19:45:54 +0100 | [diff] [blame] | 224 | snd_soc_write(codec, AC97_AD_SERIAL_CFG, 0x9900); |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 225 | |
Lars-Peter Clausen | 17bb577 | 2014-11-18 19:45:54 +0100 | [diff] [blame] | 226 | if (snd_soc_read(codec, AC97_RESET) == 0x0090) |
Lars-Peter Clausen | cf7b71f4 | 2014-05-20 14:23:10 +0200 | [diff] [blame] | 227 | return 0; |
| 228 | } while (retry_cnt++ < 10); |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 229 | |
Lars-Peter Clausen | e5adb6c | 2014-10-30 21:00:59 +0100 | [diff] [blame] | 230 | dev_err(codec->dev, "Failed to reset: AC97 link error\n"); |
| 231 | |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 232 | return -EIO; |
| 233 | } |
| 234 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 235 | static int ad1980_soc_probe(struct snd_soc_codec *codec) |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 236 | { |
Lars-Peter Clausen | 358a8bb | 2014-11-10 22:41:53 +0100 | [diff] [blame] | 237 | struct snd_ac97 *ac97; |
Lars-Peter Clausen | 82d1463 | 2014-11-18 19:45:53 +0100 | [diff] [blame] | 238 | struct regmap *regmap; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 239 | int ret; |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 240 | u16 vendor_id2; |
Cliff Cai | 9905ed3 | 2008-11-18 16:18:16 +0800 | [diff] [blame] | 241 | u16 ext_status; |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 242 | |
Lars-Peter Clausen | 358a8bb | 2014-11-10 22:41:53 +0100 | [diff] [blame] | 243 | ac97 = snd_soc_new_ac97_codec(codec); |
| 244 | if (IS_ERR(ac97)) { |
| 245 | ret = PTR_ERR(ac97); |
| 246 | dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 247 | return ret; |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 248 | } |
| 249 | |
Lars-Peter Clausen | 82d1463 | 2014-11-18 19:45:53 +0100 | [diff] [blame] | 250 | regmap = regmap_init_ac97(ac97, &ad1980_regmap_config); |
| 251 | if (IS_ERR(regmap)) { |
| 252 | ret = PTR_ERR(regmap); |
| 253 | goto err_free_ac97; |
| 254 | } |
| 255 | |
| 256 | snd_soc_codec_init_regmap(codec, regmap); |
Lars-Peter Clausen | 358a8bb | 2014-11-10 22:41:53 +0100 | [diff] [blame] | 257 | snd_soc_codec_set_drvdata(codec, ac97); |
| 258 | |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 259 | ret = ad1980_reset(codec, 0); |
Lars-Peter Clausen | e5adb6c | 2014-10-30 21:00:59 +0100 | [diff] [blame] | 260 | if (ret < 0) |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 261 | goto reset_err; |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 262 | |
| 263 | /* Read out vendor ID to make sure it is ad1980 */ |
Lars-Peter Clausen | 17bb577 | 2014-11-18 19:45:54 +0100 | [diff] [blame] | 264 | if (snd_soc_read(codec, AC97_VENDOR_ID1) != 0x4144) { |
Axel Lin | 0f73644 | 2011-09-06 10:37:48 +0800 | [diff] [blame] | 265 | ret = -ENODEV; |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 266 | goto reset_err; |
Axel Lin | 0f73644 | 2011-09-06 10:37:48 +0800 | [diff] [blame] | 267 | } |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 268 | |
Lars-Peter Clausen | 17bb577 | 2014-11-18 19:45:54 +0100 | [diff] [blame] | 269 | vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2); |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 270 | |
| 271 | if (vendor_id2 != 0x5370) { |
Axel Lin | 0f73644 | 2011-09-06 10:37:48 +0800 | [diff] [blame] | 272 | if (vendor_id2 != 0x5374) { |
| 273 | ret = -ENODEV; |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 274 | goto reset_err; |
Axel Lin | 0f73644 | 2011-09-06 10:37:48 +0800 | [diff] [blame] | 275 | } else { |
Lars-Peter Clausen | e5adb6c | 2014-10-30 21:00:59 +0100 | [diff] [blame] | 276 | dev_warn(codec->dev, |
| 277 | "Found AD1981 - only 2/2 IN/OUT Channels supported\n"); |
Axel Lin | 0f73644 | 2011-09-06 10:37:48 +0800 | [diff] [blame] | 278 | } |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 279 | } |
| 280 | |
Cliff Cai | 9905ed3 | 2008-11-18 16:18:16 +0800 | [diff] [blame] | 281 | /* unmute captures and playbacks volume */ |
Lars-Peter Clausen | 17bb577 | 2014-11-18 19:45:54 +0100 | [diff] [blame] | 282 | snd_soc_write(codec, AC97_MASTER, 0x0000); |
| 283 | snd_soc_write(codec, AC97_PCM, 0x0000); |
| 284 | snd_soc_write(codec, AC97_REC_GAIN, 0x0000); |
| 285 | snd_soc_write(codec, AC97_CENTER_LFE_MASTER, 0x0000); |
| 286 | snd_soc_write(codec, AC97_SURROUND_MASTER, 0x0000); |
Cliff Cai | 9905ed3 | 2008-11-18 16:18:16 +0800 | [diff] [blame] | 287 | |
| 288 | /*power on LFE/CENTER/Surround DACs*/ |
Lars-Peter Clausen | 17bb577 | 2014-11-18 19:45:54 +0100 | [diff] [blame] | 289 | ext_status = snd_soc_read(codec, AC97_EXTENDED_STATUS); |
| 290 | snd_soc_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 291 | |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 292 | return 0; |
| 293 | |
| 294 | reset_err: |
Lars-Peter Clausen | 82d1463 | 2014-11-18 19:45:53 +0100 | [diff] [blame] | 295 | snd_soc_codec_exit_regmap(codec); |
| 296 | err_free_ac97: |
Lars-Peter Clausen | 358a8bb | 2014-11-10 22:41:53 +0100 | [diff] [blame] | 297 | snd_soc_free_ac97_codec(ac97); |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 298 | return ret; |
| 299 | } |
| 300 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 301 | static int ad1980_soc_remove(struct snd_soc_codec *codec) |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 302 | { |
Lars-Peter Clausen | 358a8bb | 2014-11-10 22:41:53 +0100 | [diff] [blame] | 303 | struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); |
| 304 | |
Lars-Peter Clausen | 82d1463 | 2014-11-18 19:45:53 +0100 | [diff] [blame] | 305 | snd_soc_codec_exit_regmap(codec); |
Lars-Peter Clausen | 358a8bb | 2014-11-10 22:41:53 +0100 | [diff] [blame] | 306 | snd_soc_free_ac97_codec(ac97); |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 307 | return 0; |
| 308 | } |
| 309 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 310 | static struct snd_soc_codec_driver soc_codec_dev_ad1980 = { |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 311 | .probe = ad1980_soc_probe, |
| 312 | .remove = ad1980_soc_remove, |
Mark Brown | 9e7e474 | 2013-08-06 23:51:12 +0100 | [diff] [blame] | 313 | |
Lars-Peter Clausen | 6ce13d6 | 2014-10-30 21:01:00 +0100 | [diff] [blame] | 314 | .controls = ad1980_snd_ac97_controls, |
| 315 | .num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls), |
Mark Brown | 9e7e474 | 2013-08-06 23:51:12 +0100 | [diff] [blame] | 316 | .dapm_widgets = ad1980_dapm_widgets, |
| 317 | .num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets), |
| 318 | .dapm_routes = ad1980_dapm_routes, |
| 319 | .num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes), |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 320 | }; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 321 | |
Bill Pemberton | 7a79e94 | 2012-12-07 09:26:37 -0500 | [diff] [blame] | 322 | static int ad1980_probe(struct platform_device *pdev) |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 323 | { |
| 324 | return snd_soc_register_codec(&pdev->dev, |
| 325 | &soc_codec_dev_ad1980, &ad1980_dai, 1); |
| 326 | } |
| 327 | |
Bill Pemberton | 7a79e94 | 2012-12-07 09:26:37 -0500 | [diff] [blame] | 328 | static int ad1980_remove(struct platform_device *pdev) |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 329 | { |
| 330 | snd_soc_unregister_codec(&pdev->dev); |
| 331 | return 0; |
| 332 | } |
| 333 | |
| 334 | static struct platform_driver ad1980_codec_driver = { |
| 335 | .driver = { |
Mike Frysinger | 1afa98b | 2011-03-27 00:44:13 -0400 | [diff] [blame] | 336 | .name = "ad1980", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 337 | }, |
| 338 | |
| 339 | .probe = ad1980_probe, |
Bill Pemberton | 7a79e94 | 2012-12-07 09:26:37 -0500 | [diff] [blame] | 340 | .remove = ad1980_remove, |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 341 | }; |
| 342 | |
Mark Brown | 5bbcc3c | 2011-11-23 22:52:08 +0000 | [diff] [blame] | 343 | module_platform_driver(ad1980_codec_driver); |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 344 | |
Sonic Zhang | 2e2211a | 2010-08-07 12:06:07 -0400 | [diff] [blame] | 345 | MODULE_DESCRIPTION("ASoC ad1980 driver (Obsolete)"); |
Cliff Cai | 5f57dc8 | 2008-07-29 11:42:34 +0100 | [diff] [blame] | 346 | MODULE_AUTHOR("Roy Huang, Cliff Cai"); |
| 347 | MODULE_LICENSE("GPL"); |