2 * File: sound/soc/codecs/ssm2602.c
3 * Author: Cliff Cai <Cliff.Cai@analog.com>
5 * Created: Tue June 06 2008
6 * Description: Driver for ssm2602 sound chip
9 * Copyright 2008 Analog Devices Inc.
11 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, see the file COPYING, or write
25 * to the Free Software Foundation, Inc.,
26 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #include <linux/module.h>
30 #include <linux/moduleparam.h>
31 #include <linux/init.h>
32 #include <linux/delay.h>
34 #include <linux/i2c.h>
35 #include <linux/spi/spi.h>
36 #include <linux/platform_device.h>
37 #include <linux/slab.h>
38 #include <sound/core.h>
39 #include <sound/pcm.h>
40 #include <sound/pcm_params.h>
41 #include <sound/soc.h>
42 #include <sound/initval.h>
46 #define SSM2602_VERSION "0.1"
53 /* codec private data */
56 enum snd_soc_control_type control_type
;
57 struct snd_pcm_substream
*master_substream
;
58 struct snd_pcm_substream
*slave_substream
;
60 enum ssm2602_type type
;
64 * ssm2602 register cache
65 * We can't read the ssm2602 register space when we are
66 * using 2 wire for device control, so we cache them instead.
67 * There is no point in caching the reset register
69 static const u16 ssm2602_reg
[SSM2602_CACHEREGNUM
] = {
70 0x0097, 0x0097, 0x0079, 0x0079,
71 0x000a, 0x0008, 0x009f, 0x000a,
75 #define ssm2602_reset(c) snd_soc_write(c, SSM2602_RESET, 0)
77 /*Appending several "None"s just for OSS mixer use*/
78 static const char *ssm2602_input_select
[] = {
79 "Line", "Mic", "None", "None", "None",
80 "None", "None", "None",
83 static const char *ssm2602_deemph
[] = {"None", "32Khz", "44.1Khz", "48Khz"};
85 static const struct soc_enum ssm2602_enum
[] = {
86 SOC_ENUM_SINGLE(SSM2602_APANA
, 2, 2, ssm2602_input_select
),
87 SOC_ENUM_SINGLE(SSM2602_APDIGI
, 1, 4, ssm2602_deemph
),
90 static const struct snd_kcontrol_new ssm260x_snd_controls
[] = {
91 SOC_DOUBLE_R("Capture Volume", SSM2602_LINVOL
, SSM2602_RINVOL
, 0, 31, 0),
92 SOC_DOUBLE_R("Capture Switch", SSM2602_LINVOL
, SSM2602_RINVOL
, 7, 1, 1),
94 SOC_SINGLE("ADC High Pass Filter Switch", SSM2602_APDIGI
, 0, 1, 1),
95 SOC_SINGLE("Store DC Offset Switch", SSM2602_APDIGI
, 4, 1, 0),
97 SOC_ENUM("Playback De-emphasis", ssm2602_enum
[1]),
100 static const struct snd_kcontrol_new ssm2602_snd_controls
[] = {
101 SOC_DOUBLE_R("Master Playback Volume", SSM2602_LOUT1V
, SSM2602_ROUT1V
,
103 SOC_DOUBLE_R("Master Playback ZC Switch", SSM2602_LOUT1V
, SSM2602_ROUT1V
,
106 SOC_SINGLE("Sidetone Playback Volume", SSM2602_APANA
, 6, 3, 1),
108 SOC_SINGLE("Mic Boost (+20dB)", SSM2602_APANA
, 0, 1, 0),
109 SOC_SINGLE("Mic Boost2 (+20dB)", SSM2602_APANA
, 8, 1, 0),
110 SOC_SINGLE("Mic Switch", SSM2602_APANA
, 1, 1, 1),
114 static const struct snd_kcontrol_new ssm260x_output_mixer_controls
[] = {
115 SOC_DAPM_SINGLE("Line Bypass Switch", SSM2602_APANA
, 3, 1, 0),
116 SOC_DAPM_SINGLE("HiFi Playback Switch", SSM2602_APANA
, 4, 1, 0),
117 SOC_DAPM_SINGLE("Mic Sidetone Switch", SSM2602_APANA
, 5, 1, 0),
121 static const struct snd_kcontrol_new ssm2602_input_mux_controls
=
122 SOC_DAPM_ENUM("Input Select", ssm2602_enum
[0]);
124 static const struct snd_soc_dapm_widget ssm260x_dapm_widgets
[] = {
125 SND_SOC_DAPM_DAC("DAC", "HiFi Playback", SSM2602_PWR
, 3, 1),
126 SND_SOC_DAPM_ADC("ADC", "HiFi Capture", SSM2602_PWR
, 2, 1),
127 SND_SOC_DAPM_PGA("Line Input", SSM2602_PWR
, 0, 1, NULL
, 0),
129 SND_SOC_DAPM_OUTPUT("LOUT"),
130 SND_SOC_DAPM_OUTPUT("ROUT"),
131 SND_SOC_DAPM_INPUT("RLINEIN"),
132 SND_SOC_DAPM_INPUT("LLINEIN"),
135 static const struct snd_soc_dapm_widget ssm2602_dapm_widgets
[] = {
136 SND_SOC_DAPM_MIXER("Output Mixer", SSM2602_PWR
, 4, 1,
137 ssm260x_output_mixer_controls
,
138 ARRAY_SIZE(ssm260x_output_mixer_controls
)),
140 SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM
, 0, 0, &ssm2602_input_mux_controls
),
141 SND_SOC_DAPM_MICBIAS("Mic Bias", SSM2602_PWR
, 1, 1),
143 SND_SOC_DAPM_OUTPUT("LHPOUT"),
144 SND_SOC_DAPM_OUTPUT("RHPOUT"),
145 SND_SOC_DAPM_INPUT("MICIN"),
148 static const struct snd_soc_dapm_widget ssm2604_dapm_widgets
[] = {
149 SND_SOC_DAPM_MIXER("Output Mixer", SND_SOC_NOPM
, 0, 0,
150 ssm260x_output_mixer_controls
,
151 ARRAY_SIZE(ssm260x_output_mixer_controls
) - 1), /* Last element is the mic */
154 static const struct snd_soc_dapm_route ssm260x_routes
[] = {
155 {"Output Mixer", "Line Bypass Switch", "Line Input"},
156 {"Output Mixer", "HiFi Playback Switch", "DAC"},
158 {"ROUT", NULL
, "Output Mixer"},
159 {"LOUT", NULL
, "Output Mixer"},
161 {"Line Input", NULL
, "LLINEIN"},
162 {"Line Input", NULL
, "RLINEIN"},
165 static const struct snd_soc_dapm_route ssm2602_routes
[] = {
166 {"Output Mixer", "Mic Sidetone Switch", "Mic Bias"},
168 {"RHPOUT", NULL
, "Output Mixer"},
169 {"LHPOUT", NULL
, "Output Mixer"},
171 {"Input Mux", "Line", "Line Input"},
172 {"Input Mux", "Mic", "Mic Bias"},
173 {"ADC", NULL
, "Input Mux"},
175 {"Mic Bias", NULL
, "MICIN"},
178 static const struct snd_soc_dapm_route ssm2604_routes
[] = {
179 {"ADC", NULL
, "Line Input"},
182 struct ssm2602_coeff
{
188 #define SSM2602_COEFF_SRATE(sr, bosr, usb) (((sr) << 2) | ((bosr) << 1) | (usb))
190 /* codec mclk clock coefficients */
191 static const struct ssm2602_coeff ssm2602_coeff_table
[] = {
193 {12288000, 48000, SSM2602_COEFF_SRATE(0x0, 0x0, 0x0)},
194 {18432000, 48000, SSM2602_COEFF_SRATE(0x0, 0x1, 0x0)},
195 {12000000, 48000, SSM2602_COEFF_SRATE(0x0, 0x0, 0x1)},
198 {12288000, 32000, SSM2602_COEFF_SRATE(0x6, 0x0, 0x0)},
199 {18432000, 32000, SSM2602_COEFF_SRATE(0x6, 0x1, 0x0)},
200 {12000000, 32000, SSM2602_COEFF_SRATE(0x6, 0x0, 0x1)},
203 {12288000, 8000, SSM2602_COEFF_SRATE(0x3, 0x0, 0x0)},
204 {18432000, 8000, SSM2602_COEFF_SRATE(0x3, 0x1, 0x0)},
205 {11289600, 8000, SSM2602_COEFF_SRATE(0xb, 0x0, 0x0)},
206 {16934400, 8000, SSM2602_COEFF_SRATE(0xb, 0x1, 0x0)},
207 {12000000, 8000, SSM2602_COEFF_SRATE(0x3, 0x0, 0x1)},
210 {12288000, 96000, SSM2602_COEFF_SRATE(0x7, 0x0, 0x0)},
211 {18432000, 96000, SSM2602_COEFF_SRATE(0x7, 0x1, 0x0)},
212 {12000000, 96000, SSM2602_COEFF_SRATE(0x7, 0x0, 0x1)},
215 {11289600, 44100, SSM2602_COEFF_SRATE(0x8, 0x0, 0x0)},
216 {16934400, 44100, SSM2602_COEFF_SRATE(0x8, 0x1, 0x0)},
217 {12000000, 44100, SSM2602_COEFF_SRATE(0x8, 0x1, 0x1)},
220 {11289600, 88200, SSM2602_COEFF_SRATE(0xf, 0x0, 0x0)},
221 {16934400, 88200, SSM2602_COEFF_SRATE(0xf, 0x1, 0x0)},
222 {12000000, 88200, SSM2602_COEFF_SRATE(0xf, 0x1, 0x1)},
225 static inline int ssm2602_get_coeff(int mclk
, int rate
)
229 for (i
= 0; i
< ARRAY_SIZE(ssm2602_coeff_table
); i
++) {
230 if (ssm2602_coeff_table
[i
].rate
== rate
&&
231 ssm2602_coeff_table
[i
].mclk
== mclk
)
232 return ssm2602_coeff_table
[i
].srate
;
237 static int ssm2602_hw_params(struct snd_pcm_substream
*substream
,
238 struct snd_pcm_hw_params
*params
,
239 struct snd_soc_dai
*dai
)
241 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
242 struct snd_soc_codec
*codec
= rtd
->codec
;
243 struct ssm2602_priv
*ssm2602
= snd_soc_codec_get_drvdata(codec
);
244 u16 iface
= snd_soc_read(codec
, SSM2602_IFACE
) & 0xfff3;
245 int srate
= ssm2602_get_coeff(ssm2602
->sysclk
, params_rate(params
));
247 if (substream
== ssm2602
->slave_substream
) {
248 dev_dbg(codec
->dev
, "Ignoring hw_params for slave substream\n");
255 snd_soc_write(codec
, SSM2602_ACTIVE
, 0);
256 snd_soc_write(codec
, SSM2602_SRATE
, srate
);
259 switch (params_format(params
)) {
260 case SNDRV_PCM_FORMAT_S16_LE
:
262 case SNDRV_PCM_FORMAT_S20_3LE
:
265 case SNDRV_PCM_FORMAT_S24_LE
:
268 case SNDRV_PCM_FORMAT_S32_LE
:
272 snd_soc_write(codec
, SSM2602_IFACE
, iface
);
273 snd_soc_write(codec
, SSM2602_ACTIVE
, ACTIVE_ACTIVATE_CODEC
);
277 static int ssm2602_startup(struct snd_pcm_substream
*substream
,
278 struct snd_soc_dai
*dai
)
280 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
281 struct snd_soc_codec
*codec
= rtd
->codec
;
282 struct ssm2602_priv
*ssm2602
= snd_soc_codec_get_drvdata(codec
);
283 struct i2c_client
*i2c
= codec
->control_data
;
284 struct snd_pcm_runtime
*master_runtime
;
286 /* The DAI has shared clocks so if we already have a playback or
287 * capture going then constrain this substream to match it.
288 * TODO: the ssm2602 allows pairs of non-matching PB/REC rates
290 if (ssm2602
->master_substream
) {
291 master_runtime
= ssm2602
->master_substream
->runtime
;
292 dev_dbg(&i2c
->dev
, "Constraining to %d bits at %dHz\n",
293 master_runtime
->sample_bits
,
294 master_runtime
->rate
);
296 if (master_runtime
->rate
!= 0)
297 snd_pcm_hw_constraint_minmax(substream
->runtime
,
298 SNDRV_PCM_HW_PARAM_RATE
,
299 master_runtime
->rate
,
300 master_runtime
->rate
);
302 if (master_runtime
->sample_bits
!= 0)
303 snd_pcm_hw_constraint_minmax(substream
->runtime
,
304 SNDRV_PCM_HW_PARAM_SAMPLE_BITS
,
305 master_runtime
->sample_bits
,
306 master_runtime
->sample_bits
);
308 ssm2602
->slave_substream
= substream
;
310 ssm2602
->master_substream
= substream
;
315 static int ssm2602_pcm_prepare(struct snd_pcm_substream
*substream
,
316 struct snd_soc_dai
*dai
)
318 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
319 struct snd_soc_codec
*codec
= rtd
->codec
;
321 snd_soc_write(codec
, SSM2602_ACTIVE
, ACTIVE_ACTIVATE_CODEC
);
326 static void ssm2602_shutdown(struct snd_pcm_substream
*substream
,
327 struct snd_soc_dai
*dai
)
329 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
330 struct snd_soc_codec
*codec
= rtd
->codec
;
331 struct ssm2602_priv
*ssm2602
= snd_soc_codec_get_drvdata(codec
);
335 snd_soc_write(codec
, SSM2602_ACTIVE
, 0);
337 if (ssm2602
->master_substream
== substream
)
338 ssm2602
->master_substream
= ssm2602
->slave_substream
;
340 ssm2602
->slave_substream
= NULL
;
343 static int ssm2602_mute(struct snd_soc_dai
*dai
, int mute
)
345 struct snd_soc_codec
*codec
= dai
->codec
;
346 u16 mute_reg
= snd_soc_read(codec
, SSM2602_APDIGI
) & ~APDIGI_ENABLE_DAC_MUTE
;
348 snd_soc_write(codec
, SSM2602_APDIGI
,
349 mute_reg
| APDIGI_ENABLE_DAC_MUTE
);
351 snd_soc_write(codec
, SSM2602_APDIGI
, mute_reg
);
355 static int ssm2602_set_dai_sysclk(struct snd_soc_dai
*codec_dai
,
356 int clk_id
, unsigned int freq
, int dir
)
358 struct snd_soc_codec
*codec
= codec_dai
->codec
;
359 struct ssm2602_priv
*ssm2602
= snd_soc_codec_get_drvdata(codec
);
366 ssm2602
->sysclk
= freq
;
372 static int ssm2602_set_dai_fmt(struct snd_soc_dai
*codec_dai
,
375 struct snd_soc_codec
*codec
= codec_dai
->codec
;
378 /* set master/slave audio interface */
379 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
380 case SND_SOC_DAIFMT_CBM_CFM
:
383 case SND_SOC_DAIFMT_CBS_CFS
:
389 /* interface format */
390 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
391 case SND_SOC_DAIFMT_I2S
:
394 case SND_SOC_DAIFMT_RIGHT_J
:
396 case SND_SOC_DAIFMT_LEFT_J
:
399 case SND_SOC_DAIFMT_DSP_A
:
402 case SND_SOC_DAIFMT_DSP_B
:
409 /* clock inversion */
410 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
411 case SND_SOC_DAIFMT_NB_NF
:
413 case SND_SOC_DAIFMT_IB_IF
:
416 case SND_SOC_DAIFMT_IB_NF
:
419 case SND_SOC_DAIFMT_NB_IF
:
427 snd_soc_write(codec
, SSM2602_IFACE
, iface
);
431 static int ssm2602_set_bias_level(struct snd_soc_codec
*codec
,
432 enum snd_soc_bias_level level
)
434 u16 reg
= snd_soc_read(codec
, SSM2602_PWR
) & 0xff7f;
437 case SND_SOC_BIAS_ON
:
438 /* vref/mid, osc on, dac unmute */
439 snd_soc_write(codec
, SSM2602_PWR
, reg
);
441 case SND_SOC_BIAS_PREPARE
:
443 case SND_SOC_BIAS_STANDBY
:
444 /* everything off except vref/vmid, */
445 snd_soc_write(codec
, SSM2602_PWR
, reg
| PWR_CLK_OUT_PDN
);
447 case SND_SOC_BIAS_OFF
:
448 /* everything off, dac mute, inactive */
449 snd_soc_write(codec
, SSM2602_ACTIVE
, 0);
450 snd_soc_write(codec
, SSM2602_PWR
, 0xffff);
454 codec
->dapm
.bias_level
= level
;
458 #define SSM2602_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_32000 |\
459 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
460 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
462 #define SSM2602_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
463 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
465 static struct snd_soc_dai_ops ssm2602_dai_ops
= {
466 .startup
= ssm2602_startup
,
467 .prepare
= ssm2602_pcm_prepare
,
468 .hw_params
= ssm2602_hw_params
,
469 .shutdown
= ssm2602_shutdown
,
470 .digital_mute
= ssm2602_mute
,
471 .set_sysclk
= ssm2602_set_dai_sysclk
,
472 .set_fmt
= ssm2602_set_dai_fmt
,
475 static struct snd_soc_dai_driver ssm2602_dai
= {
476 .name
= "ssm2602-hifi",
478 .stream_name
= "Playback",
481 .rates
= SSM2602_RATES
,
482 .formats
= SSM2602_FORMATS
,},
484 .stream_name
= "Capture",
487 .rates
= SSM2602_RATES
,
488 .formats
= SSM2602_FORMATS
,},
489 .ops
= &ssm2602_dai_ops
,
492 static int ssm2602_suspend(struct snd_soc_codec
*codec
, pm_message_t state
)
494 ssm2602_set_bias_level(codec
, SND_SOC_BIAS_OFF
);
498 static int ssm2602_resume(struct snd_soc_codec
*codec
)
500 snd_soc_cache_sync(codec
);
502 ssm2602_set_bias_level(codec
, SND_SOC_BIAS_STANDBY
);
507 static int ssm2602_probe(struct snd_soc_codec
*codec
)
509 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
512 reg
= snd_soc_read(codec
, SSM2602_LOUT1V
);
513 snd_soc_write(codec
, SSM2602_LOUT1V
, reg
| LOUT1V_LRHP_BOTH
);
514 reg
= snd_soc_read(codec
, SSM2602_ROUT1V
);
515 snd_soc_write(codec
, SSM2602_ROUT1V
, reg
| ROUT1V_RLHP_BOTH
);
517 ret
= snd_soc_add_controls(codec
, ssm2602_snd_controls
,
518 ARRAY_SIZE(ssm2602_snd_controls
));
522 ret
= snd_soc_dapm_new_controls(dapm
, ssm2602_dapm_widgets
,
523 ARRAY_SIZE(ssm2602_dapm_widgets
));
527 return snd_soc_dapm_add_routes(dapm
, ssm2602_routes
,
528 ARRAY_SIZE(ssm2602_routes
));
531 static int ssm2604_probe(struct snd_soc_codec
*codec
)
533 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
536 ret
= snd_soc_dapm_new_controls(dapm
, ssm2604_dapm_widgets
,
537 ARRAY_SIZE(ssm2604_dapm_widgets
));
541 return snd_soc_dapm_add_routes(dapm
, ssm2604_routes
,
542 ARRAY_SIZE(ssm2604_routes
));
545 static int ssm260x_probe(struct snd_soc_codec
*codec
)
547 struct ssm2602_priv
*ssm2602
= snd_soc_codec_get_drvdata(codec
);
550 pr_info("ssm2602 Audio Codec %s", SSM2602_VERSION
);
552 ret
= snd_soc_codec_set_cache_io(codec
, 7, 9, ssm2602
->control_type
);
554 dev_err(codec
->dev
, "Failed to set cache I/O: %d\n", ret
);
558 ret
= ssm2602_reset(codec
);
560 dev_err(codec
->dev
, "Failed to issue reset: %d\n", ret
);
564 /* set the update bits */
565 reg
= snd_soc_read(codec
, SSM2602_LINVOL
);
566 snd_soc_write(codec
, SSM2602_LINVOL
, reg
| LINVOL_LRIN_BOTH
);
567 reg
= snd_soc_read(codec
, SSM2602_RINVOL
);
568 snd_soc_write(codec
, SSM2602_RINVOL
, reg
| RINVOL_RLIN_BOTH
);
569 /*select Line in as default input*/
570 snd_soc_write(codec
, SSM2602_APANA
, APANA_SELECT_DAC
|
571 APANA_ENABLE_MIC_BOOST
);
573 switch (ssm2602
->type
) {
575 ret
= ssm2602_probe(codec
);
578 ret
= ssm2604_probe(codec
);
585 /* remove everything here */
586 static int ssm2602_remove(struct snd_soc_codec
*codec
)
588 ssm2602_set_bias_level(codec
, SND_SOC_BIAS_OFF
);
592 static struct snd_soc_codec_driver soc_codec_dev_ssm2602
= {
593 .probe
= ssm260x_probe
,
594 .remove
= ssm2602_remove
,
595 .suspend
= ssm2602_suspend
,
596 .resume
= ssm2602_resume
,
597 .set_bias_level
= ssm2602_set_bias_level
,
598 .reg_cache_size
= ARRAY_SIZE(ssm2602_reg
),
599 .reg_word_size
= sizeof(u16
),
600 .reg_cache_default
= ssm2602_reg
,
602 .controls
= ssm260x_snd_controls
,
603 .num_controls
= ARRAY_SIZE(ssm260x_snd_controls
),
604 .dapm_widgets
= ssm260x_dapm_widgets
,
605 .num_dapm_widgets
= ARRAY_SIZE(ssm260x_dapm_widgets
),
606 .dapm_routes
= ssm260x_routes
,
607 .num_dapm_routes
= ARRAY_SIZE(ssm260x_routes
),
610 #if defined(CONFIG_SPI_MASTER)
611 static int __devinit
ssm2602_spi_probe(struct spi_device
*spi
)
613 struct ssm2602_priv
*ssm2602
;
616 ssm2602
= kzalloc(sizeof(struct ssm2602_priv
), GFP_KERNEL
);
620 spi_set_drvdata(spi
, ssm2602
);
621 ssm2602
->control_type
= SND_SOC_SPI
;
622 ssm2602
->type
= SSM2602
;
624 ret
= snd_soc_register_codec(&spi
->dev
,
625 &soc_codec_dev_ssm2602
, &ssm2602_dai
, 1);
631 static int __devexit
ssm2602_spi_remove(struct spi_device
*spi
)
633 snd_soc_unregister_codec(&spi
->dev
);
634 kfree(spi_get_drvdata(spi
));
638 static struct spi_driver ssm2602_spi_driver
= {
641 .owner
= THIS_MODULE
,
643 .probe
= ssm2602_spi_probe
,
644 .remove
= __devexit_p(ssm2602_spi_remove
),
648 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
650 * ssm2602 2 wire address is determined by GPIO5
651 * state during powerup.
655 static int __devinit
ssm2602_i2c_probe(struct i2c_client
*i2c
,
656 const struct i2c_device_id
*id
)
658 struct ssm2602_priv
*ssm2602
;
661 ssm2602
= kzalloc(sizeof(struct ssm2602_priv
), GFP_KERNEL
);
665 i2c_set_clientdata(i2c
, ssm2602
);
666 ssm2602
->control_type
= SND_SOC_I2C
;
667 ssm2602
->type
= id
->driver_data
;
669 ret
= snd_soc_register_codec(&i2c
->dev
,
670 &soc_codec_dev_ssm2602
, &ssm2602_dai
, 1);
676 static int __devexit
ssm2602_i2c_remove(struct i2c_client
*client
)
678 snd_soc_unregister_codec(&client
->dev
);
679 kfree(i2c_get_clientdata(client
));
683 static const struct i2c_device_id ssm2602_i2c_id
[] = {
684 { "ssm2602", SSM2602
},
685 { "ssm2603", SSM2602
},
686 { "ssm2604", SSM2604
},
689 MODULE_DEVICE_TABLE(i2c
, ssm2602_i2c_id
);
691 /* corgi i2c codec control layer */
692 static struct i2c_driver ssm2602_i2c_driver
= {
695 .owner
= THIS_MODULE
,
697 .probe
= ssm2602_i2c_probe
,
698 .remove
= __devexit_p(ssm2602_i2c_remove
),
699 .id_table
= ssm2602_i2c_id
,
704 static int __init
ssm2602_modinit(void)
708 #if defined(CONFIG_SPI_MASTER)
709 ret
= spi_register_driver(&ssm2602_spi_driver
);
714 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
715 ret
= i2c_add_driver(&ssm2602_i2c_driver
);
722 module_init(ssm2602_modinit
);
724 static void __exit
ssm2602_exit(void)
726 #if defined(CONFIG_SPI_MASTER)
727 spi_unregister_driver(&ssm2602_spi_driver
);
730 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
731 i2c_del_driver(&ssm2602_i2c_driver
);
734 module_exit(ssm2602_exit
);
736 MODULE_DESCRIPTION("ASoC SSM2602/SSM2603/SSM2604 driver");
737 MODULE_AUTHOR("Cliff Cai");
738 MODULE_LICENSE("GPL");