1 // SPDX-License-Identifier: GPL-2.0-only
3 * ak4641.c -- AK4641 ALSA Soc Audio driver
5 * Copyright (C) 2008 Harald Welte <laforge@gnufiish.org>
6 * Copyright (C) 2011 Dmitry Artamonow <mad_soft@inbox.ru>
8 * Based on ak4535.c by Richard Purdie
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
14 #include <linux/gpio.h>
16 #include <linux/i2c.h>
17 #include <linux/regmap.h>
18 #include <linux/slab.h>
19 #include <sound/core.h>
20 #include <sound/pcm.h>
21 #include <sound/pcm_params.h>
22 #include <sound/soc.h>
23 #include <sound/initval.h>
24 #include <sound/tlv.h>
25 #include <sound/ak4641.h>
27 /* AK4641 register space */
28 #define AK4641_PM1 0x00
29 #define AK4641_PM2 0x01
30 #define AK4641_SIG1 0x02
31 #define AK4641_SIG2 0x03
32 #define AK4641_MODE1 0x04
33 #define AK4641_MODE2 0x05
34 #define AK4641_DAC 0x06
35 #define AK4641_MIC 0x07
36 #define AK4641_TIMER 0x08
37 #define AK4641_ALC1 0x09
38 #define AK4641_ALC2 0x0a
39 #define AK4641_PGA 0x0b
40 #define AK4641_LATT 0x0c
41 #define AK4641_RATT 0x0d
42 #define AK4641_VOL 0x0e
43 #define AK4641_STATUS 0x0f
44 #define AK4641_EQLO 0x10
45 #define AK4641_EQMID 0x11
46 #define AK4641_EQHI 0x12
47 #define AK4641_BTIF 0x13
49 /* codec private data */
51 struct regmap
*regmap
;
58 * ak4641 register cache
60 static const struct reg_default ak4641_reg_defaults
[] = {
61 { 0, 0x00 }, { 1, 0x80 }, { 2, 0x00 }, { 3, 0x80 },
62 { 4, 0x02 }, { 5, 0x00 }, { 6, 0x11 }, { 7, 0x05 },
63 { 8, 0x00 }, { 9, 0x00 }, { 10, 0x36 }, { 11, 0x10 },
64 { 12, 0x00 }, { 13, 0x00 }, { 14, 0x57 }, { 15, 0x00 },
65 { 16, 0x88 }, { 17, 0x88 }, { 18, 0x08 }, { 19, 0x08 }
68 static const int deemph_settings
[] = {44100, 0, 48000, 32000};
70 static int ak4641_set_deemph(struct snd_soc_component
*component
)
72 struct ak4641_priv
*ak4641
= snd_soc_component_get_drvdata(component
);
75 for (i
= 0 ; i
< ARRAY_SIZE(deemph_settings
); i
++) {
76 /* if deemphasis is on, select the nearest available rate */
77 if (ak4641
->deemph
&& deemph_settings
[i
] != 0 &&
78 abs(deemph_settings
[i
] - ak4641
->playback_fs
) <
79 abs(deemph_settings
[best
] - ak4641
->playback_fs
))
82 if (!ak4641
->deemph
&& deemph_settings
[i
] == 0)
86 dev_dbg(component
->dev
, "Set deemphasis %d\n", best
);
88 return snd_soc_component_update_bits(component
, AK4641_DAC
, 0x3, best
);
91 static int ak4641_put_deemph(struct snd_kcontrol
*kcontrol
,
92 struct snd_ctl_elem_value
*ucontrol
)
94 struct snd_soc_component
*component
= snd_soc_kcontrol_component(kcontrol
);
95 struct ak4641_priv
*ak4641
= snd_soc_component_get_drvdata(component
);
96 int deemph
= ucontrol
->value
.integer
.value
[0];
101 ak4641
->deemph
= deemph
;
103 return ak4641_set_deemph(component
);
106 static int ak4641_get_deemph(struct snd_kcontrol
*kcontrol
,
107 struct snd_ctl_elem_value
*ucontrol
)
109 struct snd_soc_component
*component
= snd_soc_kcontrol_component(kcontrol
);
110 struct ak4641_priv
*ak4641
= snd_soc_component_get_drvdata(component
);
112 ucontrol
->value
.integer
.value
[0] = ak4641
->deemph
;
116 static const char *ak4641_mono_out
[] = {"(L + R)/2", "Hi-Z"};
117 static const char *ak4641_hp_out
[] = {"Stereo", "Mono"};
118 static const char *ak4641_mic_select
[] = {"Internal", "External"};
119 static const char *ak4641_mic_or_dac
[] = {"Microphone", "Voice DAC"};
122 static const DECLARE_TLV_DB_SCALE(mono_gain_tlv
, -1700, 2300, 0);
123 static const DECLARE_TLV_DB_SCALE(mic_boost_tlv
, 0, 2000, 0);
124 static const DECLARE_TLV_DB_SCALE(eq_tlv
, -1050, 150, 0);
125 static const DECLARE_TLV_DB_SCALE(master_tlv
, -12750, 50, 0);
126 static const DECLARE_TLV_DB_SCALE(mic_stereo_sidetone_tlv
, -2700, 300, 0);
127 static const DECLARE_TLV_DB_SCALE(mic_mono_sidetone_tlv
, -400, 400, 0);
128 static const DECLARE_TLV_DB_SCALE(capture_tlv
, -800, 50, 0);
129 static const DECLARE_TLV_DB_SCALE(alc_tlv
, -800, 50, 0);
130 static const DECLARE_TLV_DB_SCALE(aux_in_tlv
, -2100, 300, 0);
133 static SOC_ENUM_SINGLE_DECL(ak4641_mono_out_enum
,
134 AK4641_SIG1
, 6, ak4641_mono_out
);
135 static SOC_ENUM_SINGLE_DECL(ak4641_hp_out_enum
,
136 AK4641_MODE2
, 2, ak4641_hp_out
);
137 static SOC_ENUM_SINGLE_DECL(ak4641_mic_select_enum
,
138 AK4641_MIC
, 1, ak4641_mic_select
);
139 static SOC_ENUM_SINGLE_DECL(ak4641_mic_or_dac_enum
,
140 AK4641_BTIF
, 4, ak4641_mic_or_dac
);
142 static const struct snd_kcontrol_new ak4641_snd_controls
[] = {
143 SOC_ENUM("Mono 1 Output", ak4641_mono_out_enum
),
144 SOC_SINGLE_TLV("Mono 1 Gain Volume", AK4641_SIG1
, 7, 1, 1,
146 SOC_ENUM("Headphone Output", ak4641_hp_out_enum
),
147 SOC_SINGLE_BOOL_EXT("Playback Deemphasis Switch", 0,
148 ak4641_get_deemph
, ak4641_put_deemph
),
150 SOC_SINGLE_TLV("Mic Boost Volume", AK4641_MIC
, 0, 1, 0, mic_boost_tlv
),
152 SOC_SINGLE("ALC Operation Time", AK4641_TIMER
, 0, 3, 0),
153 SOC_SINGLE("ALC Recovery Time", AK4641_TIMER
, 2, 3, 0),
154 SOC_SINGLE("ALC ZC Time", AK4641_TIMER
, 4, 3, 0),
156 SOC_SINGLE("ALC 1 Switch", AK4641_ALC1
, 5, 1, 0),
158 SOC_SINGLE_TLV("ALC Volume", AK4641_ALC2
, 0, 71, 0, alc_tlv
),
159 SOC_SINGLE("Left Out Enable Switch", AK4641_SIG2
, 1, 1, 0),
160 SOC_SINGLE("Right Out Enable Switch", AK4641_SIG2
, 0, 1, 0),
162 SOC_SINGLE_TLV("Capture Volume", AK4641_PGA
, 0, 71, 0, capture_tlv
),
164 SOC_DOUBLE_R_TLV("Master Playback Volume", AK4641_LATT
,
165 AK4641_RATT
, 0, 255, 1, master_tlv
),
167 SOC_SINGLE_TLV("AUX In Volume", AK4641_VOL
, 0, 15, 0, aux_in_tlv
),
169 SOC_SINGLE("Equalizer Switch", AK4641_DAC
, 2, 1, 0),
170 SOC_SINGLE_TLV("EQ1 100 Hz Volume", AK4641_EQLO
, 0, 15, 1, eq_tlv
),
171 SOC_SINGLE_TLV("EQ2 250 Hz Volume", AK4641_EQLO
, 4, 15, 1, eq_tlv
),
172 SOC_SINGLE_TLV("EQ3 1 kHz Volume", AK4641_EQMID
, 0, 15, 1, eq_tlv
),
173 SOC_SINGLE_TLV("EQ4 3.5 kHz Volume", AK4641_EQMID
, 4, 15, 1, eq_tlv
),
174 SOC_SINGLE_TLV("EQ5 10 kHz Volume", AK4641_EQHI
, 0, 15, 1, eq_tlv
),
178 static const struct snd_kcontrol_new ak4641_mono1_mixer_controls
[] = {
179 SOC_DAPM_SINGLE_TLV("Mic Mono Sidetone Volume", AK4641_VOL
, 7, 1, 0,
180 mic_mono_sidetone_tlv
),
181 SOC_DAPM_SINGLE("Mic Mono Sidetone Switch", AK4641_SIG1
, 4, 1, 0),
182 SOC_DAPM_SINGLE("Mono Playback Switch", AK4641_SIG1
, 5, 1, 0),
186 static const struct snd_kcontrol_new ak4641_stereo_mixer_controls
[] = {
187 SOC_DAPM_SINGLE_TLV("Mic Sidetone Volume", AK4641_VOL
, 4, 7, 0,
188 mic_stereo_sidetone_tlv
),
189 SOC_DAPM_SINGLE("Mic Sidetone Switch", AK4641_SIG2
, 4, 1, 0),
190 SOC_DAPM_SINGLE("Playback Switch", AK4641_SIG2
, 7, 1, 0),
191 SOC_DAPM_SINGLE("Aux Bypass Switch", AK4641_SIG2
, 5, 1, 0),
195 static const struct snd_kcontrol_new ak4641_input_mixer_controls
[] = {
196 SOC_DAPM_SINGLE("Mic Capture Switch", AK4641_MIC
, 2, 1, 0),
197 SOC_DAPM_SINGLE("Aux Capture Switch", AK4641_MIC
, 5, 1, 0),
201 static const struct snd_kcontrol_new ak4641_mic_mux_control
=
202 SOC_DAPM_ENUM("Mic Select", ak4641_mic_select_enum
);
205 static const struct snd_kcontrol_new ak4641_input_mux_control
=
206 SOC_DAPM_ENUM("Input Select", ak4641_mic_or_dac_enum
);
209 static const struct snd_kcontrol_new ak4641_mono2_control
=
210 SOC_DAPM_SINGLE("Switch", AK4641_SIG1
, 0, 1, 0);
212 /* ak4641 dapm widgets */
213 static const struct snd_soc_dapm_widget ak4641_dapm_widgets
[] = {
214 SND_SOC_DAPM_MIXER("Stereo Mixer", SND_SOC_NOPM
, 0, 0,
215 &ak4641_stereo_mixer_controls
[0],
216 ARRAY_SIZE(ak4641_stereo_mixer_controls
)),
217 SND_SOC_DAPM_MIXER("Mono1 Mixer", SND_SOC_NOPM
, 0, 0,
218 &ak4641_mono1_mixer_controls
[0],
219 ARRAY_SIZE(ak4641_mono1_mixer_controls
)),
220 SND_SOC_DAPM_MIXER("Input Mixer", SND_SOC_NOPM
, 0, 0,
221 &ak4641_input_mixer_controls
[0],
222 ARRAY_SIZE(ak4641_input_mixer_controls
)),
223 SND_SOC_DAPM_MUX("Mic Mux", SND_SOC_NOPM
, 0, 0,
224 &ak4641_mic_mux_control
),
225 SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM
, 0, 0,
226 &ak4641_input_mux_control
),
227 SND_SOC_DAPM_SWITCH("Mono 2 Enable", SND_SOC_NOPM
, 0, 0,
228 &ak4641_mono2_control
),
230 SND_SOC_DAPM_OUTPUT("LOUT"),
231 SND_SOC_DAPM_OUTPUT("ROUT"),
232 SND_SOC_DAPM_OUTPUT("MOUT1"),
233 SND_SOC_DAPM_OUTPUT("MOUT2"),
234 SND_SOC_DAPM_OUTPUT("MICOUT"),
236 SND_SOC_DAPM_ADC("ADC", "HiFi Capture", AK4641_PM1
, 0, 0),
237 SND_SOC_DAPM_PGA("Mic", AK4641_PM1
, 1, 0, NULL
, 0),
238 SND_SOC_DAPM_PGA("AUX In", AK4641_PM1
, 2, 0, NULL
, 0),
239 SND_SOC_DAPM_PGA("Mono Out", AK4641_PM1
, 3, 0, NULL
, 0),
240 SND_SOC_DAPM_PGA("Line Out", AK4641_PM1
, 4, 0, NULL
, 0),
242 SND_SOC_DAPM_DAC("DAC", "HiFi Playback", AK4641_PM2
, 0, 0),
243 SND_SOC_DAPM_PGA("Mono Out 2", AK4641_PM2
, 3, 0, NULL
, 0),
245 SND_SOC_DAPM_ADC("Voice ADC", "Voice Capture", AK4641_BTIF
, 0, 0),
246 SND_SOC_DAPM_DAC("Voice DAC", "Voice Playback", AK4641_BTIF
, 1, 0),
248 SND_SOC_DAPM_MICBIAS("Mic Int Bias", AK4641_MIC
, 3, 0),
249 SND_SOC_DAPM_MICBIAS("Mic Ext Bias", AK4641_MIC
, 4, 0),
251 SND_SOC_DAPM_INPUT("MICIN"),
252 SND_SOC_DAPM_INPUT("MICEXT"),
253 SND_SOC_DAPM_INPUT("AUX"),
254 SND_SOC_DAPM_INPUT("AIN"),
257 static const struct snd_soc_dapm_route ak4641_audio_map
[] = {
259 {"Stereo Mixer", "Playback Switch", "DAC"},
260 {"Stereo Mixer", "Mic Sidetone Switch", "Input Mux"},
261 {"Stereo Mixer", "Aux Bypass Switch", "AUX In"},
264 {"Mono1 Mixer", "Mic Mono Sidetone Switch", "Input Mux"},
265 {"Mono1 Mixer", "Mono Playback Switch", "DAC"},
268 {"Mic", NULL
, "AIN"},
269 {"Mic Mux", "Internal", "Mic Int Bias"},
270 {"Mic Mux", "External", "Mic Ext Bias"},
271 {"Mic Int Bias", NULL
, "MICIN"},
272 {"Mic Ext Bias", NULL
, "MICEXT"},
273 {"MICOUT", NULL
, "Mic Mux"},
276 {"Input Mux", "Microphone", "Mic"},
277 {"Input Mux", "Voice DAC", "Voice DAC"},
280 {"LOUT", NULL
, "Line Out"},
281 {"ROUT", NULL
, "Line Out"},
282 {"Line Out", NULL
, "Stereo Mixer"},
285 {"MOUT1", NULL
, "Mono Out"},
286 {"Mono Out", NULL
, "Mono1 Mixer"},
289 {"MOUT2", NULL
, "Mono 2 Enable"},
290 {"Mono 2 Enable", "Switch", "Mono Out 2"},
291 {"Mono Out 2", NULL
, "Stereo Mixer"},
293 {"Voice ADC", NULL
, "Mono 2 Enable"},
296 {"AUX In", NULL
, "AUX"},
299 {"ADC", NULL
, "Input Mixer"},
300 {"Input Mixer", "Mic Capture Switch", "Mic"},
301 {"Input Mixer", "Aux Capture Switch", "AUX In"},
304 static int ak4641_set_dai_sysclk(struct snd_soc_dai
*codec_dai
,
305 int clk_id
, unsigned int freq
, int dir
)
307 struct snd_soc_component
*component
= codec_dai
->component
;
308 struct ak4641_priv
*ak4641
= snd_soc_component_get_drvdata(component
);
310 ak4641
->sysclk
= freq
;
314 static int ak4641_i2s_hw_params(struct snd_pcm_substream
*substream
,
315 struct snd_pcm_hw_params
*params
,
316 struct snd_soc_dai
*dai
)
318 struct snd_soc_component
*component
= dai
->component
;
319 struct ak4641_priv
*ak4641
= snd_soc_component_get_drvdata(component
);
320 int rate
= params_rate(params
), fs
= 256;
324 fs
= ak4641
->sysclk
/ rate
;
340 dev_err(component
->dev
, "Error: unsupported fs=%d\n", fs
);
344 snd_soc_component_update_bits(component
, AK4641_MODE2
, (0x3 << 5), mode2
);
346 /* Update de-emphasis filter for the new rate */
347 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
348 ak4641
->playback_fs
= rate
;
349 ak4641_set_deemph(component
);
355 static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai
*codec_dai
,
358 struct snd_soc_component
*component
= codec_dai
->component
;
362 /* interface format */
363 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
364 case SND_SOC_DAIFMT_I2S
:
367 case SND_SOC_DAIFMT_LEFT_J
:
370 case SND_SOC_DAIFMT_DSP_A
: /* MSB after FRM */
373 case SND_SOC_DAIFMT_DSP_B
: /* MSB during FRM */
380 ret
= snd_soc_component_update_bits(component
, AK4641_BTIF
, (0x3 << 5), btif
);
387 static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai
*codec_dai
,
390 struct snd_soc_component
*component
= codec_dai
->component
;
393 /* interface format */
394 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
395 case SND_SOC_DAIFMT_I2S
:
398 case SND_SOC_DAIFMT_LEFT_J
:
405 return snd_soc_component_write(component
, AK4641_MODE1
, mode1
);
408 static int ak4641_mute(struct snd_soc_dai
*dai
, int mute
)
410 struct snd_soc_component
*component
= dai
->component
;
412 return snd_soc_component_update_bits(component
, AK4641_DAC
, 0x20, mute
? 0x20 : 0);
415 static int ak4641_set_bias_level(struct snd_soc_component
*component
,
416 enum snd_soc_bias_level level
)
418 struct ak4641_priv
*ak4641
= snd_soc_component_get_drvdata(component
);
419 struct ak4641_platform_data
*pdata
= component
->dev
->platform_data
;
423 case SND_SOC_BIAS_ON
:
425 snd_soc_component_update_bits(component
, AK4641_DAC
, 0x20, 0);
427 case SND_SOC_BIAS_PREPARE
:
429 snd_soc_component_update_bits(component
, AK4641_DAC
, 0x20, 0x20);
431 case SND_SOC_BIAS_STANDBY
:
432 if (snd_soc_component_get_bias_level(component
) == SND_SOC_BIAS_OFF
) {
433 if (pdata
&& gpio_is_valid(pdata
->gpio_power
))
434 gpio_set_value(pdata
->gpio_power
, 1);
436 if (pdata
&& gpio_is_valid(pdata
->gpio_npdn
))
437 gpio_set_value(pdata
->gpio_npdn
, 1);
440 ret
= regcache_sync(ak4641
->regmap
);
442 dev_err(component
->dev
,
443 "Failed to sync cache: %d\n", ret
);
447 snd_soc_component_update_bits(component
, AK4641_PM1
, 0x80, 0x80);
448 snd_soc_component_update_bits(component
, AK4641_PM2
, 0x80, 0);
450 case SND_SOC_BIAS_OFF
:
451 snd_soc_component_update_bits(component
, AK4641_PM1
, 0x80, 0);
452 if (pdata
&& gpio_is_valid(pdata
->gpio_npdn
))
453 gpio_set_value(pdata
->gpio_npdn
, 0);
454 if (pdata
&& gpio_is_valid(pdata
->gpio_power
))
455 gpio_set_value(pdata
->gpio_power
, 0);
456 regcache_mark_dirty(ak4641
->regmap
);
462 #define AK4641_RATES (SNDRV_PCM_RATE_8000_48000)
463 #define AK4641_RATES_BT (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
464 SNDRV_PCM_RATE_16000)
465 #define AK4641_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
467 static const struct snd_soc_dai_ops ak4641_i2s_dai_ops
= {
468 .hw_params
= ak4641_i2s_hw_params
,
469 .set_fmt
= ak4641_i2s_set_dai_fmt
,
470 .digital_mute
= ak4641_mute
,
471 .set_sysclk
= ak4641_set_dai_sysclk
,
474 static const struct snd_soc_dai_ops ak4641_pcm_dai_ops
= {
475 .hw_params
= NULL
, /* rates are controlled by BT chip */
476 .set_fmt
= ak4641_pcm_set_dai_fmt
,
477 .digital_mute
= ak4641_mute
,
478 .set_sysclk
= ak4641_set_dai_sysclk
,
481 static struct snd_soc_dai_driver ak4641_dai
[] = {
483 .name
= "ak4641-hifi",
486 .stream_name
= "HiFi Playback",
489 .rates
= AK4641_RATES
,
490 .formats
= AK4641_FORMATS
,
493 .stream_name
= "HiFi Capture",
496 .rates
= AK4641_RATES
,
497 .formats
= AK4641_FORMATS
,
499 .ops
= &ak4641_i2s_dai_ops
,
500 .symmetric_rates
= 1,
503 .name
= "ak4641-voice",
506 .stream_name
= "Voice Playback",
509 .rates
= AK4641_RATES_BT
,
510 .formats
= AK4641_FORMATS
,
513 .stream_name
= "Voice Capture",
516 .rates
= AK4641_RATES_BT
,
517 .formats
= AK4641_FORMATS
,
519 .ops
= &ak4641_pcm_dai_ops
,
520 .symmetric_rates
= 1,
524 static const struct snd_soc_component_driver soc_component_dev_ak4641
= {
525 .controls
= ak4641_snd_controls
,
526 .num_controls
= ARRAY_SIZE(ak4641_snd_controls
),
527 .dapm_widgets
= ak4641_dapm_widgets
,
528 .num_dapm_widgets
= ARRAY_SIZE(ak4641_dapm_widgets
),
529 .dapm_routes
= ak4641_audio_map
,
530 .num_dapm_routes
= ARRAY_SIZE(ak4641_audio_map
),
531 .set_bias_level
= ak4641_set_bias_level
,
532 .suspend_bias_off
= 1,
534 .use_pmdown_time
= 1,
536 .non_legacy_dai_naming
= 1,
539 static const struct regmap_config ak4641_regmap
= {
543 .max_register
= AK4641_BTIF
,
544 .reg_defaults
= ak4641_reg_defaults
,
545 .num_reg_defaults
= ARRAY_SIZE(ak4641_reg_defaults
),
546 .cache_type
= REGCACHE_RBTREE
,
549 static int ak4641_i2c_probe(struct i2c_client
*i2c
,
550 const struct i2c_device_id
*id
)
552 struct ak4641_platform_data
*pdata
= i2c
->dev
.platform_data
;
553 struct ak4641_priv
*ak4641
;
556 ak4641
= devm_kzalloc(&i2c
->dev
, sizeof(struct ak4641_priv
),
561 ak4641
->regmap
= devm_regmap_init_i2c(i2c
, &ak4641_regmap
);
562 if (IS_ERR(ak4641
->regmap
))
563 return PTR_ERR(ak4641
->regmap
);
566 if (gpio_is_valid(pdata
->gpio_power
)) {
567 ret
= gpio_request_one(pdata
->gpio_power
,
568 GPIOF_OUT_INIT_LOW
, "ak4641 power");
572 if (gpio_is_valid(pdata
->gpio_npdn
)) {
573 ret
= gpio_request_one(pdata
->gpio_npdn
,
574 GPIOF_OUT_INIT_LOW
, "ak4641 npdn");
578 udelay(1); /* > 150 ns */
579 gpio_set_value(pdata
->gpio_npdn
, 1);
583 i2c_set_clientdata(i2c
, ak4641
);
585 ret
= devm_snd_soc_register_component(&i2c
->dev
,
586 &soc_component_dev_ak4641
,
587 ak4641_dai
, ARRAY_SIZE(ak4641_dai
));
595 if (gpio_is_valid(pdata
->gpio_power
))
596 gpio_set_value(pdata
->gpio_power
, 0);
597 if (gpio_is_valid(pdata
->gpio_npdn
))
598 gpio_free(pdata
->gpio_npdn
);
601 if (pdata
&& gpio_is_valid(pdata
->gpio_power
))
602 gpio_free(pdata
->gpio_power
);
607 static int ak4641_i2c_remove(struct i2c_client
*i2c
)
609 struct ak4641_platform_data
*pdata
= i2c
->dev
.platform_data
;
612 if (gpio_is_valid(pdata
->gpio_power
)) {
613 gpio_set_value(pdata
->gpio_power
, 0);
614 gpio_free(pdata
->gpio_power
);
616 if (gpio_is_valid(pdata
->gpio_npdn
))
617 gpio_free(pdata
->gpio_npdn
);
623 static const struct i2c_device_id ak4641_i2c_id
[] = {
627 MODULE_DEVICE_TABLE(i2c
, ak4641_i2c_id
);
629 static struct i2c_driver ak4641_i2c_driver
= {
633 .probe
= ak4641_i2c_probe
,
634 .remove
= ak4641_i2c_remove
,
635 .id_table
= ak4641_i2c_id
,
638 module_i2c_driver(ak4641_i2c_driver
);
640 MODULE_DESCRIPTION("SoC AK4641 driver");
641 MODULE_AUTHOR("Harald Welte <laforge@gnufiish.org>");
642 MODULE_LICENSE("GPL");