Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * cx20442.c -- CX20442 ALSA Soc Audio driver |
| 3 | * |
| 4 | * Copyright 2009 Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> |
| 5 | * |
| 6 | * Initially based on sound/soc/codecs/wm8400.c |
| 7 | * Copyright 2008, 2009 Wolfson Microelectronics PLC. |
| 8 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the |
| 12 | * Free Software Foundation; either version 2 of the License, or (at your |
| 13 | * option) any later version. |
| 14 | */ |
| 15 | |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 16 | #include <linux/tty.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 17 | #include <linux/slab.h> |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 18 | |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 19 | #include <sound/core.h> |
| 20 | #include <sound/initval.h> |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 21 | #include <sound/soc.h> |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 22 | |
| 23 | #include "cx20442.h" |
| 24 | |
| 25 | |
| 26 | struct cx20442_priv { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 27 | enum snd_soc_control_type control_type; |
| 28 | void *control_data; |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | #define CX20442_PM 0x0 |
| 32 | |
| 33 | #define CX20442_TELIN 0 |
| 34 | #define CX20442_TELOUT 1 |
| 35 | #define CX20442_MIC 2 |
| 36 | #define CX20442_SPKOUT 3 |
| 37 | #define CX20442_AGC 4 |
| 38 | |
| 39 | static const struct snd_soc_dapm_widget cx20442_dapm_widgets[] = { |
| 40 | SND_SOC_DAPM_OUTPUT("TELOUT"), |
| 41 | SND_SOC_DAPM_OUTPUT("SPKOUT"), |
| 42 | SND_SOC_DAPM_OUTPUT("AGCOUT"), |
| 43 | |
| 44 | SND_SOC_DAPM_MIXER("SPKOUT Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 45 | |
| 46 | SND_SOC_DAPM_PGA("TELOUT Amp", CX20442_PM, CX20442_TELOUT, 0, NULL, 0), |
| 47 | SND_SOC_DAPM_PGA("SPKOUT Amp", CX20442_PM, CX20442_SPKOUT, 0, NULL, 0), |
| 48 | SND_SOC_DAPM_PGA("SPKOUT AGC", CX20442_PM, CX20442_AGC, 0, NULL, 0), |
| 49 | |
| 50 | SND_SOC_DAPM_DAC("DAC", "Playback", SND_SOC_NOPM, 0, 0), |
| 51 | SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0), |
| 52 | |
| 53 | SND_SOC_DAPM_MIXER("Input Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 54 | |
| 55 | SND_SOC_DAPM_MICBIAS("TELIN Bias", CX20442_PM, CX20442_TELIN, 0), |
| 56 | SND_SOC_DAPM_MICBIAS("MIC Bias", CX20442_PM, CX20442_MIC, 0), |
| 57 | |
| 58 | SND_SOC_DAPM_PGA("MIC AGC", CX20442_PM, CX20442_AGC, 0, NULL, 0), |
| 59 | |
| 60 | SND_SOC_DAPM_INPUT("TELIN"), |
| 61 | SND_SOC_DAPM_INPUT("MIC"), |
| 62 | SND_SOC_DAPM_INPUT("AGCIN"), |
| 63 | }; |
| 64 | |
| 65 | static const struct snd_soc_dapm_route cx20442_audio_map[] = { |
| 66 | {"TELOUT", NULL, "TELOUT Amp"}, |
| 67 | |
| 68 | {"SPKOUT", NULL, "SPKOUT Mixer"}, |
| 69 | {"SPKOUT Mixer", NULL, "SPKOUT Amp"}, |
| 70 | |
| 71 | {"TELOUT Amp", NULL, "DAC"}, |
| 72 | {"SPKOUT Amp", NULL, "DAC"}, |
| 73 | |
| 74 | {"SPKOUT Mixer", NULL, "SPKOUT AGC"}, |
| 75 | {"SPKOUT AGC", NULL, "AGCIN"}, |
| 76 | |
| 77 | {"AGCOUT", NULL, "MIC AGC"}, |
| 78 | {"MIC AGC", NULL, "MIC"}, |
| 79 | |
| 80 | {"MIC Bias", NULL, "MIC"}, |
| 81 | {"Input Mixer", NULL, "MIC Bias"}, |
| 82 | |
| 83 | {"TELIN Bias", NULL, "TELIN"}, |
| 84 | {"Input Mixer", NULL, "TELIN Bias"}, |
| 85 | |
| 86 | {"ADC", NULL, "Input Mixer"}, |
| 87 | }; |
| 88 | |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 89 | static unsigned int cx20442_read_reg_cache(struct snd_soc_codec *codec, |
| 90 | unsigned int reg) |
| 91 | { |
| 92 | u8 *reg_cache = codec->reg_cache; |
| 93 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 94 | if (reg >= codec->driver->reg_cache_size) |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 95 | return -EINVAL; |
| 96 | |
| 97 | return reg_cache[reg]; |
| 98 | } |
| 99 | |
| 100 | enum v253_vls { |
| 101 | V253_VLS_NONE = 0, |
| 102 | V253_VLS_T, |
| 103 | V253_VLS_L, |
| 104 | V253_VLS_LT, |
| 105 | V253_VLS_S, |
| 106 | V253_VLS_ST, |
| 107 | V253_VLS_M, |
| 108 | V253_VLS_MST, |
| 109 | V253_VLS_S1, |
| 110 | V253_VLS_S1T, |
| 111 | V253_VLS_MS1T, |
| 112 | V253_VLS_M1, |
| 113 | V253_VLS_M1ST, |
| 114 | V253_VLS_M1S1T, |
| 115 | V253_VLS_H, |
| 116 | V253_VLS_HT, |
| 117 | V253_VLS_MS, |
| 118 | V253_VLS_MS1, |
| 119 | V253_VLS_M1S, |
| 120 | V253_VLS_M1S1, |
| 121 | V253_VLS_TEST, |
| 122 | }; |
| 123 | |
| 124 | static int cx20442_pm_to_v253_vls(u8 value) |
| 125 | { |
Janusz Krzysztofik | b84eab0 | 2009-07-28 20:24:12 +0200 | [diff] [blame] | 126 | switch (value & ~(1 << CX20442_AGC)) { |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 127 | case 0: |
| 128 | return V253_VLS_T; |
| 129 | case (1 << CX20442_SPKOUT): |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 130 | case (1 << CX20442_MIC): |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 131 | case (1 << CX20442_SPKOUT) | (1 << CX20442_MIC): |
| 132 | return V253_VLS_M1S1; |
| 133 | case (1 << CX20442_TELOUT): |
| 134 | case (1 << CX20442_TELIN): |
| 135 | case (1 << CX20442_TELOUT) | (1 << CX20442_TELIN): |
| 136 | return V253_VLS_L; |
| 137 | case (1 << CX20442_TELOUT) | (1 << CX20442_MIC): |
| 138 | return V253_VLS_NONE; |
| 139 | } |
| 140 | return -EINVAL; |
| 141 | } |
| 142 | static int cx20442_pm_to_v253_vsp(u8 value) |
| 143 | { |
Janusz Krzysztofik | b84eab0 | 2009-07-28 20:24:12 +0200 | [diff] [blame] | 144 | switch (value & ~(1 << CX20442_AGC)) { |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 145 | case (1 << CX20442_SPKOUT): |
| 146 | case (1 << CX20442_MIC): |
| 147 | case (1 << CX20442_SPKOUT) | (1 << CX20442_MIC): |
| 148 | return (bool)(value & (1 << CX20442_AGC)); |
| 149 | } |
| 150 | return (value & (1 << CX20442_AGC)) ? -EINVAL : 0; |
| 151 | } |
| 152 | |
| 153 | static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg, |
| 154 | unsigned int value) |
| 155 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 156 | struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 157 | u8 *reg_cache = codec->reg_cache; |
| 158 | int vls, vsp, old, len; |
| 159 | char buf[18]; |
| 160 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 161 | if (reg >= codec->driver->reg_cache_size) |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 162 | return -EINVAL; |
| 163 | |
Janusz Krzysztofik | b84eab0 | 2009-07-28 20:24:12 +0200 | [diff] [blame] | 164 | /* hw_write and control_data pointers required for talking to the modem |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 165 | * are expected to be set by the line discipline initialization code */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 166 | if (!codec->hw_write || !cx20442->control_data) |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 167 | return -EIO; |
| 168 | |
| 169 | old = reg_cache[reg]; |
| 170 | reg_cache[reg] = value; |
| 171 | |
| 172 | vls = cx20442_pm_to_v253_vls(value); |
| 173 | if (vls < 0) |
| 174 | return vls; |
| 175 | |
| 176 | vsp = cx20442_pm_to_v253_vsp(value); |
Janusz Krzysztofik | b84eab0 | 2009-07-28 20:24:12 +0200 | [diff] [blame] | 177 | if (vsp < 0) |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 178 | return vsp; |
| 179 | |
| 180 | if ((vls == V253_VLS_T) || |
| 181 | (vls == cx20442_pm_to_v253_vls(old))) { |
| 182 | if (vsp == cx20442_pm_to_v253_vsp(old)) |
| 183 | return 0; |
| 184 | len = snprintf(buf, ARRAY_SIZE(buf), "at+vsp=%d\r", vsp); |
| 185 | } else if (vsp == cx20442_pm_to_v253_vsp(old)) |
| 186 | len = snprintf(buf, ARRAY_SIZE(buf), "at+vls=%d\r", vls); |
| 187 | else |
| 188 | len = snprintf(buf, ARRAY_SIZE(buf), |
| 189 | "at+vls=%d;+vsp=%d\r", vls, vsp); |
| 190 | |
| 191 | if (unlikely(len > (ARRAY_SIZE(buf) - 1))) |
| 192 | return -ENOMEM; |
| 193 | |
Janusz Krzysztofik | 4977b03 | 2009-08-06 12:24:54 +0200 | [diff] [blame] | 194 | dev_dbg(codec->dev, "%s: %s\n", __func__, buf); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 195 | if (codec->hw_write(cx20442->control_data, buf, len) != len) |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 196 | return -EIO; |
| 197 | |
| 198 | return 0; |
| 199 | } |
| 200 | |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 201 | |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 202 | /* |
| 203 | * Line discpline related code |
| 204 | * |
| 205 | * Any of the callback functions below can be used in two ways: |
| 206 | * 1) registerd by a machine driver as one of line discipline operations, |
| 207 | * 2) called from a machine's provided line discipline callback function |
| 208 | * in case when extra machine specific code must be run as well. |
| 209 | */ |
| 210 | |
| 211 | /* Modem init: echo off, digital speaker off, quiet off, voice mode */ |
| 212 | static const char *v253_init = "ate0m0q0+fclass=8\r"; |
| 213 | |
| 214 | /* Line discipline .open() */ |
| 215 | static int v253_open(struct tty_struct *tty) |
| 216 | { |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 217 | int ret, len = strlen(v253_init); |
| 218 | |
| 219 | /* Doesn't make sense without write callback */ |
| 220 | if (!tty->ops->write) |
| 221 | return -EINVAL; |
| 222 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 223 | /* Won't work if no codec pointer has been passed by a card driver */ |
| 224 | if (!tty->disc_data) |
| 225 | return -ENODEV; |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 226 | |
| 227 | if (tty->ops->write(tty, v253_init, len) != len) { |
| 228 | ret = -EIO; |
| 229 | goto err; |
| 230 | } |
| 231 | /* Actual setup will be performed after the modem responds. */ |
| 232 | return 0; |
| 233 | err: |
| 234 | tty->disc_data = NULL; |
| 235 | return ret; |
| 236 | } |
| 237 | |
| 238 | /* Line discipline .close() */ |
| 239 | static void v253_close(struct tty_struct *tty) |
| 240 | { |
| 241 | struct snd_soc_codec *codec = tty->disc_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 242 | struct cx20442_priv *cx20442; |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 243 | |
| 244 | tty->disc_data = NULL; |
| 245 | |
| 246 | if (!codec) |
| 247 | return; |
| 248 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 249 | cx20442 = snd_soc_codec_get_drvdata(codec); |
| 250 | |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 251 | /* Prevent the codec driver from further accessing the modem */ |
| 252 | codec->hw_write = NULL; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 253 | cx20442->control_data = NULL; |
Jarkko Nikula | 3a45b86 | 2010-11-05 20:35:21 +0200 | [diff] [blame] | 254 | codec->card->pop_time = 0; |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | /* Line discipline .hangup() */ |
| 258 | static int v253_hangup(struct tty_struct *tty) |
| 259 | { |
| 260 | v253_close(tty); |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | /* Line discipline .receive_buf() */ |
Linus Torvalds | bb3d6bf | 2011-06-04 07:00:50 +0900 | [diff] [blame^] | 265 | static void v253_receive(struct tty_struct *tty, |
| 266 | const unsigned char *cp, char *fp, int count) |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 267 | { |
| 268 | struct snd_soc_codec *codec = tty->disc_data; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 269 | struct cx20442_priv *cx20442; |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 270 | |
| 271 | if (!codec) |
Linus Torvalds | bb3d6bf | 2011-06-04 07:00:50 +0900 | [diff] [blame^] | 272 | return; |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 273 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 274 | cx20442 = snd_soc_codec_get_drvdata(codec); |
| 275 | |
| 276 | if (!cx20442->control_data) { |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 277 | /* First modem response, complete setup procedure */ |
| 278 | |
| 279 | /* Set up codec driver access to modem controls */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 280 | cx20442->control_data = tty; |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 281 | codec->hw_write = (hw_write_t)tty->ops->write; |
Jarkko Nikula | 3a45b86 | 2010-11-05 20:35:21 +0200 | [diff] [blame] | 282 | codec->card->pop_time = 1; |
Janusz Krzysztofik | ad120da | 2009-07-29 12:24:46 +0200 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | |
| 286 | /* Line discipline .write_wakeup() */ |
| 287 | static void v253_wakeup(struct tty_struct *tty) |
| 288 | { |
| 289 | } |
| 290 | |
| 291 | struct tty_ldisc_ops v253_ops = { |
| 292 | .magic = TTY_LDISC_MAGIC, |
| 293 | .name = "cx20442", |
| 294 | .owner = THIS_MODULE, |
| 295 | .open = v253_open, |
| 296 | .close = v253_close, |
| 297 | .hangup = v253_hangup, |
| 298 | .receive_buf = v253_receive, |
| 299 | .write_wakeup = v253_wakeup, |
| 300 | }; |
| 301 | EXPORT_SYMBOL_GPL(v253_ops); |
| 302 | |
| 303 | |
| 304 | /* |
| 305 | * Codec DAI |
| 306 | */ |
| 307 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 308 | static struct snd_soc_dai_driver cx20442_dai = { |
Janusz Krzysztofik | 5394637 | 2010-08-19 15:15:50 +0200 | [diff] [blame] | 309 | .name = "cx20442-voice", |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 310 | .playback = { |
| 311 | .stream_name = "Playback", |
| 312 | .channels_min = 1, |
| 313 | .channels_max = 1, |
| 314 | .rates = SNDRV_PCM_RATE_8000, |
| 315 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 316 | }, |
| 317 | .capture = { |
| 318 | .stream_name = "Capture", |
| 319 | .channels_min = 1, |
| 320 | .channels_max = 1, |
| 321 | .rates = SNDRV_PCM_RATE_8000, |
| 322 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 323 | }, |
| 324 | }; |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 325 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 326 | static int cx20442_codec_probe(struct snd_soc_codec *codec) |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 327 | { |
| 328 | struct cx20442_priv *cx20442; |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 329 | |
| 330 | cx20442 = kzalloc(sizeof(struct cx20442_priv), GFP_KERNEL); |
| 331 | if (cx20442 == NULL) |
| 332 | return -ENOMEM; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 333 | snd_soc_codec_set_drvdata(codec, cx20442); |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 334 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 335 | cx20442->control_data = NULL; |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 336 | codec->hw_write = NULL; |
Jarkko Nikula | 3a45b86 | 2010-11-05 20:35:21 +0200 | [diff] [blame] | 337 | codec->card->pop_time = 0; |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 338 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 339 | return 0; |
| 340 | } |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 341 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 342 | /* power down chip */ |
| 343 | static int cx20442_codec_remove(struct snd_soc_codec *codec) |
| 344 | { |
| 345 | struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); |
| 346 | |
| 347 | if (cx20442->control_data) { |
| 348 | struct tty_struct *tty = cx20442->control_data; |
| 349 | tty_hangup(tty); |
| 350 | } |
| 351 | |
| 352 | kfree(cx20442); |
| 353 | return 0; |
| 354 | } |
| 355 | |
Janusz Krzysztofik | 8e6bfb9 | 2011-02-10 13:24:32 +0100 | [diff] [blame] | 356 | static const u8 cx20442_reg; |
Janusz Krzysztofik | f019ee5 | 2011-02-01 13:01:17 +0100 | [diff] [blame] | 357 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 358 | static struct snd_soc_codec_driver cx20442_codec_dev = { |
| 359 | .probe = cx20442_codec_probe, |
| 360 | .remove = cx20442_codec_remove, |
Janusz Krzysztofik | f019ee5 | 2011-02-01 13:01:17 +0100 | [diff] [blame] | 361 | .reg_cache_default = &cx20442_reg, |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 362 | .reg_cache_size = 1, |
| 363 | .reg_word_size = sizeof(u8), |
| 364 | .read = cx20442_read_reg_cache, |
| 365 | .write = cx20442_write, |
Lu Guanqun | 51fb1a8 | 2011-03-30 21:53:09 +0800 | [diff] [blame] | 366 | .dapm_widgets = cx20442_dapm_widgets, |
| 367 | .num_dapm_widgets = ARRAY_SIZE(cx20442_dapm_widgets), |
| 368 | .dapm_routes = cx20442_audio_map, |
| 369 | .num_dapm_routes = ARRAY_SIZE(cx20442_audio_map), |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 370 | }; |
| 371 | |
| 372 | static int cx20442_platform_probe(struct platform_device *pdev) |
| 373 | { |
| 374 | return snd_soc_register_codec(&pdev->dev, |
| 375 | &cx20442_codec_dev, &cx20442_dai, 1); |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | static int __exit cx20442_platform_remove(struct platform_device *pdev) |
| 379 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 380 | snd_soc_unregister_codec(&pdev->dev); |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | static struct platform_driver cx20442_platform_driver = { |
| 385 | .driver = { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 386 | .name = "cx20442-codec", |
Janusz Krzysztofik | 459dc35 | 2009-07-22 05:22:28 +0200 | [diff] [blame] | 387 | .owner = THIS_MODULE, |
| 388 | }, |
| 389 | .probe = cx20442_platform_probe, |
| 390 | .remove = __exit_p(cx20442_platform_remove), |
| 391 | }; |
| 392 | |
| 393 | static int __init cx20442_init(void) |
| 394 | { |
| 395 | return platform_driver_register(&cx20442_platform_driver); |
| 396 | } |
| 397 | module_init(cx20442_init); |
| 398 | |
| 399 | static void __exit cx20442_exit(void) |
| 400 | { |
| 401 | platform_driver_unregister(&cx20442_platform_driver); |
| 402 | } |
| 403 | module_exit(cx20442_exit); |
| 404 | |
| 405 | MODULE_DESCRIPTION("ASoC CX20442-11 voice modem codec driver"); |
| 406 | MODULE_AUTHOR("Janusz Krzysztofik"); |
| 407 | MODULE_LICENSE("GPL"); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 408 | MODULE_ALIAS("platform:cx20442-codec"); |