2 * CS4270 ALSA SoC (ASoC) codec driver
4 * Author: Timur Tabi <timur@freescale.com>
6 * Copyright 2007 Freescale Semiconductor, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
11 * This is an ASoC device driver for the Cirrus Logic CS4270 codec.
13 * Current features/limitations:
15 * 1) Software mode is supported. Stand-alone mode is not supported.
16 * 2) Only I2C is supported, not SPI
17 * 3) Only Master mode is supported, not Slave.
18 * 4) The machine driver's 'startup' function must call
19 * cs4270_set_dai_sysclk() with the value of MCLK.
20 * 5) Only I2S and left-justified modes are supported
21 * 6) Power management is not supported
22 * 7) The only supported control is volume and hardware mute (if enabled)
25 #include <linux/module.h>
26 #include <linux/platform_device.h>
27 #include <sound/core.h>
28 #include <sound/soc.h>
29 #include <sound/initval.h>
30 #include <linux/i2c.h>
34 /* Private data for the CS4270 */
35 struct cs4270_private
{
36 unsigned int mclk
; /* Input frequency of the MCLK pin */
37 unsigned int mode
; /* The mode (I2S or left-justified) */
41 * The codec isn't really big-endian or little-endian, since the I2S
42 * interface requires data to be sent serially with the MSbit first.
43 * However, to support BE and LE I2S devices, we specify both here. That
44 * way, ALSA will always match the bit patterns.
46 #define CS4270_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
47 SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \
48 SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE | \
49 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE | \
50 SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | \
51 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE)
53 /* CS4270 registers addresses */
54 #define CS4270_CHIPID 0x01 /* Chip ID */
55 #define CS4270_PWRCTL 0x02 /* Power Control */
56 #define CS4270_MODE 0x03 /* Mode Control */
57 #define CS4270_FORMAT 0x04 /* Serial Format, ADC/DAC Control */
58 #define CS4270_TRANS 0x05 /* Transition Control */
59 #define CS4270_MUTE 0x06 /* Mute Control */
60 #define CS4270_VOLA 0x07 /* DAC Channel A Volume Control */
61 #define CS4270_VOLB 0x08 /* DAC Channel B Volume Control */
63 #define CS4270_FIRSTREG 0x01
64 #define CS4270_LASTREG 0x08
65 #define CS4270_NUMREGS (CS4270_LASTREG - CS4270_FIRSTREG + 1)
67 /* Bit masks for the CS4270 registers */
68 #define CS4270_CHIPID_ID 0xF0
69 #define CS4270_CHIPID_REV 0x0F
70 #define CS4270_PWRCTL_FREEZE 0x80
71 #define CS4270_PWRCTL_PDN_ADC 0x20
72 #define CS4270_PWRCTL_PDN_DAC 0x02
73 #define CS4270_PWRCTL_PDN 0x01
74 #define CS4270_MODE_SPEED_MASK 0x30
75 #define CS4270_MODE_1X 0x00
76 #define CS4270_MODE_2X 0x10
77 #define CS4270_MODE_4X 0x20
78 #define CS4270_MODE_SLAVE 0x30
79 #define CS4270_MODE_DIV_MASK 0x0E
80 #define CS4270_MODE_DIV1 0x00
81 #define CS4270_MODE_DIV15 0x02
82 #define CS4270_MODE_DIV2 0x04
83 #define CS4270_MODE_DIV3 0x06
84 #define CS4270_MODE_DIV4 0x08
85 #define CS4270_MODE_POPGUARD 0x01
86 #define CS4270_FORMAT_FREEZE_A 0x80
87 #define CS4270_FORMAT_FREEZE_B 0x40
88 #define CS4270_FORMAT_LOOPBACK 0x20
89 #define CS4270_FORMAT_DAC_MASK 0x18
90 #define CS4270_FORMAT_DAC_LJ 0x00
91 #define CS4270_FORMAT_DAC_I2S 0x08
92 #define CS4270_FORMAT_DAC_RJ16 0x18
93 #define CS4270_FORMAT_DAC_RJ24 0x10
94 #define CS4270_FORMAT_ADC_MASK 0x01
95 #define CS4270_FORMAT_ADC_LJ 0x00
96 #define CS4270_FORMAT_ADC_I2S 0x01
97 #define CS4270_TRANS_ONE_VOL 0x80
98 #define CS4270_TRANS_SOFT 0x40
99 #define CS4270_TRANS_ZERO 0x20
100 #define CS4270_TRANS_INV_ADC_A 0x08
101 #define CS4270_TRANS_INV_ADC_B 0x10
102 #define CS4270_TRANS_INV_DAC_A 0x02
103 #define CS4270_TRANS_INV_DAC_B 0x04
104 #define CS4270_TRANS_DEEMPH 0x01
105 #define CS4270_MUTE_AUTO 0x20
106 #define CS4270_MUTE_ADC_A 0x08
107 #define CS4270_MUTE_ADC_B 0x10
108 #define CS4270_MUTE_POLARITY 0x04
109 #define CS4270_MUTE_DAC_A 0x01
110 #define CS4270_MUTE_DAC_B 0x02
113 * Clock Ratio Selection for Master Mode with I2C enabled
115 * The data for this chart is taken from Table 5 of the CS4270 reference
118 * This table is used to determine how to program the Mode Control register.
119 * It is also used by cs4270_set_dai_sysclk() to tell ALSA which sampling
120 * rates the CS4270 currently supports.
122 * Each element in this array corresponds to the ratios in mclk_ratios[].
123 * These two arrays need to be in sync.
125 * 'speed_mode' is the corresponding bit pattern to be written to the
126 * MODE bits of the Mode Control Register
128 * 'mclk' is the corresponding bit pattern to be wirten to the MCLK bits of
129 * the Mode Control Register.
131 * In situations where a single ratio is represented by multiple speed
132 * modes, we favor the slowest speed. E.g, for a ratio of 128, we pick
133 * double-speed instead of quad-speed. However, the CS4270 errata states
134 * that Divide-By-1.5 can cause failures, so we avoid that mode where
137 * ERRATA: There is an errata for the CS4270 where divide-by-1.5 does not
138 * work if VD = 3.3V. If this effects you, select the
139 * CONFIG_SND_SOC_CS4270_VD33_ERRATA Kconfig option, and the driver will
140 * never select any sample rates that require divide-by-1.5.
146 } cs4270_mode_ratios
[] = {
147 {64, CS4270_MODE_4X
, CS4270_MODE_DIV1
},
148 #ifndef CONFIG_SND_SOC_CS4270_VD33_ERRATA
149 {96, CS4270_MODE_4X
, CS4270_MODE_DIV15
},
151 {128, CS4270_MODE_2X
, CS4270_MODE_DIV1
},
152 {192, CS4270_MODE_4X
, CS4270_MODE_DIV3
},
153 {256, CS4270_MODE_1X
, CS4270_MODE_DIV1
},
154 {384, CS4270_MODE_2X
, CS4270_MODE_DIV3
},
155 {512, CS4270_MODE_1X
, CS4270_MODE_DIV2
},
156 {768, CS4270_MODE_1X
, CS4270_MODE_DIV3
},
157 {1024, CS4270_MODE_1X
, CS4270_MODE_DIV4
}
160 /* The number of MCLK/LRCK ratios supported by the CS4270 */
161 #define NUM_MCLK_RATIOS ARRAY_SIZE(cs4270_mode_ratios)
164 * Determine the CS4270 samples rates.
166 * 'freq' is the input frequency to MCLK. The other parameters are ignored.
168 * The value of MCLK is used to determine which sample rates are supported
169 * by the CS4270. The ratio of MCLK / Fs must be equal to one of nine
170 * support values: 64, 96, 128, 192, 256, 384, 512, 768, and 1024.
172 * This function calculates the nine ratios and determines which ones match
173 * a standard sample rate. If there's a match, then it is added to the list
174 * of support sample rates.
176 * This function must be called by the machine driver's 'startup' function,
177 * otherwise the list of supported sample rates will not be available in
180 * Note that in stand-alone mode, the sample rate is determined by input
181 * pins M0, M1, MDIV1, and MDIV2. Also in stand-alone mode, divide-by-3
182 * is not a programmable option. However, divide-by-3 is not an available
183 * option in stand-alone mode. This cases two problems: a ratio of 768 is
184 * not available (it requires divide-by-3) and B) ratios 192 and 384 can
185 * only be selected with divide-by-1.5, but there is an errate that make
186 * this selection difficult.
188 * In addition, there is no mechanism for communicating with the machine
189 * driver what the input settings can be. This would need to be implemented
190 * for stand-alone mode to work.
192 static int cs4270_set_dai_sysclk(struct snd_soc_dai
*codec_dai
,
193 int clk_id
, unsigned int freq
, int dir
)
195 struct snd_soc_codec
*codec
= codec_dai
->codec
;
196 struct cs4270_private
*cs4270
= codec
->private_data
;
197 unsigned int rates
= 0;
198 unsigned int rate_min
= -1;
199 unsigned int rate_max
= 0;
204 for (i
= 0; i
< NUM_MCLK_RATIOS
; i
++) {
205 unsigned int rate
= freq
/ cs4270_mode_ratios
[i
].ratio
;
206 rates
|= snd_pcm_rate_to_rate_bit(rate
);
212 /* FIXME: soc should support a rate list */
213 rates
&= ~SNDRV_PCM_RATE_KNOT
;
216 printk(KERN_ERR
"cs4270: could not find a valid sample rate\n");
220 codec_dai
->playback
.rates
= rates
;
221 codec_dai
->playback
.rate_min
= rate_min
;
222 codec_dai
->playback
.rate_max
= rate_max
;
224 codec_dai
->capture
.rates
= rates
;
225 codec_dai
->capture
.rate_min
= rate_min
;
226 codec_dai
->capture
.rate_max
= rate_max
;
232 * Configure the codec for the selected audio format
234 * This function takes a bitmask of SND_SOC_DAIFMT_x bits and programs the
237 * Currently, this function only supports SND_SOC_DAIFMT_I2S and
238 * SND_SOC_DAIFMT_LEFT_J. The CS4270 codec also supports right-justified
239 * data for playback only, but ASoC currently does not support different
240 * formats for playback vs. record.
242 static int cs4270_set_dai_fmt(struct snd_soc_dai
*codec_dai
,
245 struct snd_soc_codec
*codec
= codec_dai
->codec
;
246 struct cs4270_private
*cs4270
= codec
->private_data
;
249 switch (format
& SND_SOC_DAIFMT_FORMAT_MASK
) {
250 case SND_SOC_DAIFMT_I2S
:
251 case SND_SOC_DAIFMT_LEFT_J
:
252 cs4270
->mode
= format
& SND_SOC_DAIFMT_FORMAT_MASK
;
255 printk(KERN_ERR
"cs4270: invalid DAI format\n");
263 * Pre-fill the CS4270 register cache.
265 * We use the auto-increment feature of the CS4270 to read all registers in
268 static int cs4270_fill_cache(struct snd_soc_codec
*codec
)
270 u8
*cache
= codec
->reg_cache
;
271 struct i2c_client
*i2c_client
= codec
->control_data
;
274 length
= i2c_smbus_read_i2c_block_data(i2c_client
,
275 CS4270_FIRSTREG
| 0x80, CS4270_NUMREGS
, cache
);
277 if (length
!= CS4270_NUMREGS
) {
278 printk(KERN_ERR
"cs4270: I2C read failure, addr=0x%x\n",
287 * Read from the CS4270 register cache.
289 * This CS4270 registers are cached to avoid excessive I2C I/O operations.
290 * After the initial read to pre-fill the cache, the CS4270 never updates
291 * the register values, so we won't have a cache coherncy problem.
293 static unsigned int cs4270_read_reg_cache(struct snd_soc_codec
*codec
,
296 u8
*cache
= codec
->reg_cache
;
298 if ((reg
< CS4270_FIRSTREG
) || (reg
> CS4270_LASTREG
))
301 return cache
[reg
- CS4270_FIRSTREG
];
305 * Write to a CS4270 register via the I2C bus.
307 * This function writes the given value to the given CS4270 register, and
308 * also updates the register cache.
310 * Note that we don't use the hw_write function pointer of snd_soc_codec.
311 * That's because it's too clunky: the hw_write_t prototype does not match
312 * i2c_smbus_write_byte_data(), and it's just another layer of overhead.
314 static int cs4270_i2c_write(struct snd_soc_codec
*codec
, unsigned int reg
,
317 u8
*cache
= codec
->reg_cache
;
319 if ((reg
< CS4270_FIRSTREG
) || (reg
> CS4270_LASTREG
))
322 /* Only perform an I2C operation if the new value is different */
323 if (cache
[reg
- CS4270_FIRSTREG
] != value
) {
324 struct i2c_client
*client
= codec
->control_data
;
325 if (i2c_smbus_write_byte_data(client
, reg
, value
)) {
326 printk(KERN_ERR
"cs4270: I2C write failed\n");
330 /* We've written to the hardware, so update the cache */
331 cache
[reg
- CS4270_FIRSTREG
] = value
;
338 * Program the CS4270 with the given hardware parameters.
340 * The .ops functions are used to provide board-specific data, like
341 * input frequencies, to this driver. This function takes that information,
342 * combines it with the hardware parameters provided, and programs the
343 * hardware accordingly.
345 static int cs4270_hw_params(struct snd_pcm_substream
*substream
,
346 struct snd_pcm_hw_params
*params
,
347 struct snd_soc_dai
*dai
)
349 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
350 struct snd_soc_device
*socdev
= rtd
->socdev
;
351 struct snd_soc_codec
*codec
= socdev
->codec
;
352 struct cs4270_private
*cs4270
= codec
->private_data
;
359 /* Figure out which MCLK/LRCK ratio to use */
361 rate
= params_rate(params
); /* Sampling rate, in Hz */
362 ratio
= cs4270
->mclk
/ rate
; /* MCLK/LRCK ratio */
364 for (i
= 0; i
< NUM_MCLK_RATIOS
; i
++) {
365 if (cs4270_mode_ratios
[i
].ratio
== ratio
)
369 if (i
== NUM_MCLK_RATIOS
) {
370 /* We did not find a matching ratio */
371 printk(KERN_ERR
"cs4270: could not find matching ratio\n");
375 /* Freeze and power-down the codec */
377 ret
= snd_soc_write(codec
, CS4270_PWRCTL
, CS4270_PWRCTL_FREEZE
|
378 CS4270_PWRCTL_PDN_ADC
| CS4270_PWRCTL_PDN_DAC
|
381 printk(KERN_ERR
"cs4270: I2C write failed\n");
385 /* Program the mode control register */
387 reg
= snd_soc_read(codec
, CS4270_MODE
);
388 reg
&= ~(CS4270_MODE_SPEED_MASK
| CS4270_MODE_DIV_MASK
);
389 reg
|= cs4270_mode_ratios
[i
].speed_mode
| cs4270_mode_ratios
[i
].mclk
;
391 ret
= snd_soc_write(codec
, CS4270_MODE
, reg
);
393 printk(KERN_ERR
"cs4270: I2C write failed\n");
397 /* Program the format register */
399 reg
= snd_soc_read(codec
, CS4270_FORMAT
);
400 reg
&= ~(CS4270_FORMAT_DAC_MASK
| CS4270_FORMAT_ADC_MASK
);
402 switch (cs4270
->mode
) {
403 case SND_SOC_DAIFMT_I2S
:
404 reg
|= CS4270_FORMAT_DAC_I2S
| CS4270_FORMAT_ADC_I2S
;
406 case SND_SOC_DAIFMT_LEFT_J
:
407 reg
|= CS4270_FORMAT_DAC_LJ
| CS4270_FORMAT_ADC_LJ
;
410 printk(KERN_ERR
"cs4270: unknown format\n");
414 ret
= snd_soc_write(codec
, CS4270_FORMAT
, reg
);
416 printk(KERN_ERR
"cs4270: I2C write failed\n");
420 /* Disable auto-mute. This feature appears to be buggy, because in
421 some situations, auto-mute will not deactivate when it should. */
423 reg
= snd_soc_read(codec
, CS4270_MUTE
);
424 reg
&= ~CS4270_MUTE_AUTO
;
425 ret
= snd_soc_write(codec
, CS4270_MUTE
, reg
);
427 printk(KERN_ERR
"cs4270: I2C write failed\n");
431 /* Disable automatic volume control. It's enabled by default, and
432 * it causes volume change commands to be delayed, sometimes until
433 * after playback has started.
436 reg
= cs4270_read_reg_cache(codec
, CS4270_TRANS
);
437 reg
&= ~(CS4270_TRANS_SOFT
| CS4270_TRANS_ZERO
);
438 ret
= cs4270_i2c_write(codec
, CS4270_TRANS
, reg
);
440 printk(KERN_ERR
"I2C write failed\n");
444 /* Thaw and power-up the codec */
446 ret
= snd_soc_write(codec
, CS4270_PWRCTL
, 0);
448 printk(KERN_ERR
"cs4270: I2C write failed\n");
455 #ifdef CONFIG_SND_SOC_CS4270_HWMUTE
457 * Set the CS4270 external mute
459 * This function toggles the mute bits in the MUTE register. The CS4270's
460 * mute capability is intended for external muting circuitry, so if the
461 * board does not have the MUTEA or MUTEB pins connected to such circuitry,
462 * then this function will do nothing.
464 static int cs4270_mute(struct snd_soc_dai
*dai
, int mute
)
466 struct snd_soc_codec
*codec
= dai
->codec
;
469 reg6
= snd_soc_read(codec
, CS4270_MUTE
);
472 reg6
|= CS4270_MUTE_ADC_A
| CS4270_MUTE_ADC_B
|
473 CS4270_MUTE_DAC_A
| CS4270_MUTE_DAC_B
;
475 reg6
&= ~(CS4270_MUTE_ADC_A
| CS4270_MUTE_ADC_B
|
476 CS4270_MUTE_DAC_A
| CS4270_MUTE_DAC_B
);
478 return snd_soc_write(codec
, CS4270_MUTE
, reg6
);
481 #define cs4270_mute NULL
484 /* A list of non-DAPM controls that the CS4270 supports */
485 static const struct snd_kcontrol_new cs4270_snd_controls
[] = {
486 SOC_DOUBLE_R("Master Playback Volume",
487 CS4270_VOLA
, CS4270_VOLB
, 0, 0xFF, 1)
491 * Global variable to store socdev for i2c probe function.
493 * If struct i2c_driver had a private_data field, we wouldn't need to use
494 * cs4270_socdec. This is the only way to pass the socdev structure to
495 * cs4270_i2c_probe().
497 * The real solution to cs4270_socdev is to create a mechanism
498 * that maps I2C addresses to snd_soc_device structures. Perhaps the
499 * creation of the snd_soc_device object should be moved out of
500 * cs4270_probe() and into cs4270_i2c_probe(), but that would make this
501 * driver dependent on I2C. The CS4270 supports "stand-alone" mode, whereby
502 * the chip is *not* connected to the I2C bus, but is instead configured via
505 static struct snd_soc_device
*cs4270_socdev
;
508 * Initialize the I2C interface of the CS4270
510 * This function is called for whenever the I2C subsystem finds a device
511 * at a particular address.
513 * Note: snd_soc_new_pcms() must be called before this function can be called,
514 * because of snd_ctl_add().
516 static int cs4270_i2c_probe(struct i2c_client
*i2c_client
,
517 const struct i2c_device_id
*id
)
519 struct snd_soc_device
*socdev
= cs4270_socdev
;
520 struct snd_soc_codec
*codec
= socdev
->codec
;
524 /* Probing all possible addresses has one drawback: if there are
525 multiple CS4270s on the bus, then you cannot specify which
526 socdev is matched with which CS4270. For now, we just reject
527 this I2C device if the socdev already has one attached. */
528 if (codec
->control_data
)
531 /* Note: codec_dai->codec is NULL here */
533 codec
->reg_cache
= kzalloc(CS4270_NUMREGS
, GFP_KERNEL
);
534 if (!codec
->reg_cache
) {
535 printk(KERN_ERR
"cs4270: could not allocate register cache\n");
540 /* Verify that we have a CS4270 */
542 ret
= i2c_smbus_read_byte_data(i2c_client
, CS4270_CHIPID
);
544 printk(KERN_ERR
"cs4270: failed to read I2C\n");
547 /* The top four bits of the chip ID should be 1100. */
548 if ((ret
& 0xF0) != 0xC0) {
549 /* The device at this address is not a CS4270 codec */
554 printk(KERN_INFO
"cs4270: found device at I2C address %X\n",
556 printk(KERN_INFO
"cs4270: hardware revision %X\n", ret
& 0xF);
558 codec
->control_data
= i2c_client
;
559 codec
->read
= cs4270_read_reg_cache
;
560 codec
->write
= cs4270_i2c_write
;
561 codec
->reg_cache_size
= CS4270_NUMREGS
;
563 /* The I2C interface is set up, so pre-fill our register cache */
565 ret
= cs4270_fill_cache(codec
);
567 printk(KERN_ERR
"cs4270: failed to fill register cache\n");
571 /* Add the non-DAPM controls */
573 for (i
= 0; i
< ARRAY_SIZE(cs4270_snd_controls
); i
++) {
574 struct snd_kcontrol
*kctrl
=
575 snd_soc_cnew(&cs4270_snd_controls
[i
], codec
, NULL
);
577 ret
= snd_ctl_add(codec
->card
, kctrl
);
582 i2c_set_clientdata(i2c_client
, codec
);
587 codec
->control_data
= NULL
;
589 kfree(codec
->reg_cache
);
590 codec
->reg_cache
= NULL
;
591 codec
->reg_cache_size
= 0;
596 static const struct i2c_device_id cs4270_id
[] = {
600 MODULE_DEVICE_TABLE(i2c
, cs4270_id
);
602 static struct i2c_driver cs4270_i2c_driver
= {
605 .owner
= THIS_MODULE
,
607 .id_table
= cs4270_id
,
608 .probe
= cs4270_i2c_probe
,
611 struct snd_soc_dai cs4270_dai
= {
614 .stream_name
= "Playback",
618 .formats
= CS4270_FORMATS
,
621 .stream_name
= "Capture",
625 .formats
= CS4270_FORMATS
,
628 EXPORT_SYMBOL_GPL(cs4270_dai
);
631 * ASoC probe function
633 * This function is called when the machine driver calls
634 * platform_device_add().
636 static int cs4270_probe(struct platform_device
*pdev
)
638 struct snd_soc_device
*socdev
= platform_get_drvdata(pdev
);
639 struct snd_soc_codec
*codec
;
642 printk(KERN_INFO
"CS4270 ALSA SoC Codec\n");
644 /* Allocate enough space for the snd_soc_codec structure
645 and our private data together. */
646 codec
= kzalloc(ALIGN(sizeof(struct snd_soc_codec
), 4) +
647 sizeof(struct cs4270_private
), GFP_KERNEL
);
649 printk(KERN_ERR
"cs4270: Could not allocate codec structure\n");
653 mutex_init(&codec
->mutex
);
654 INIT_LIST_HEAD(&codec
->dapm_widgets
);
655 INIT_LIST_HEAD(&codec
->dapm_paths
);
657 codec
->name
= "CS4270";
658 codec
->owner
= THIS_MODULE
;
659 codec
->dai
= &cs4270_dai
;
661 codec
->private_data
= (void *) codec
+
662 ALIGN(sizeof(struct snd_soc_codec
), 4);
664 socdev
->codec
= codec
;
668 ret
= snd_soc_new_pcms(socdev
, SNDRV_DEFAULT_IDX1
, SNDRV_DEFAULT_STR1
);
670 printk(KERN_ERR
"cs4270: failed to create PCMs\n");
671 goto error_free_codec
;
674 cs4270_socdev
= socdev
;
676 ret
= i2c_add_driver(&cs4270_i2c_driver
);
678 printk(KERN_ERR
"cs4270: failed to attach driver");
679 goto error_free_pcms
;
682 /* Did we find a CS4270 on the I2C bus? */
683 if (!codec
->control_data
) {
684 printk(KERN_ERR
"cs4270: failed to attach driver");
685 goto error_del_driver
;
688 /* Initialize codec ops */
689 cs4270_dai
.ops
.hw_params
= cs4270_hw_params
;
690 cs4270_dai
.ops
.set_sysclk
= cs4270_set_dai_sysclk
;
691 cs4270_dai
.ops
.set_fmt
= cs4270_set_dai_fmt
;
692 cs4270_dai
.ops
.digital_mute
= cs4270_mute
;
694 ret
= snd_soc_init_card(socdev
);
696 printk(KERN_ERR
"cs4270: failed to register card\n");
697 goto error_del_driver
;
703 i2c_del_driver(&cs4270_i2c_driver
);
706 snd_soc_free_pcms(socdev
);
709 kfree(socdev
->codec
);
710 socdev
->codec
= NULL
;
715 static int cs4270_remove(struct platform_device
*pdev
)
717 struct snd_soc_device
*socdev
= platform_get_drvdata(pdev
);
719 snd_soc_free_pcms(socdev
);
721 i2c_del_driver(&cs4270_i2c_driver
);
723 kfree(socdev
->codec
);
724 socdev
->codec
= NULL
;
730 * ASoC codec device structure
732 * Assign this variable to the codec_dev field of the machine driver's
733 * snd_soc_device structure.
735 struct snd_soc_codec_device soc_codec_device_cs4270
= {
736 .probe
= cs4270_probe
,
737 .remove
= cs4270_remove
739 EXPORT_SYMBOL_GPL(soc_codec_device_cs4270
);
741 static int __init
cs4270_init(void)
743 return snd_soc_register_dai(&cs4270_dai
);
745 module_init(cs4270_init
);
747 static void __exit
cs4270_exit(void)
749 snd_soc_unregister_dai(&cs4270_dai
);
751 module_exit(cs4270_exit
);
753 MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
754 MODULE_DESCRIPTION("Cirrus Logic CS4270 ALSA SoC Codec Driver");
755 MODULE_LICENSE("GPL");