2 * wm8731.c -- WM8731 ALSA SoC Audio driver
4 * Copyright 2005 Openedhand Ltd.
5 * Copyright 2006-12 Wolfson Microelectronics, plc
7 * Author: Richard Purdie <richard@openedhand.com>
9 * Based on wm8753.c by Liam Girdwood
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/module.h>
17 #include <linux/moduleparam.h>
18 #include <linux/init.h>
19 #include <linux/delay.h>
21 #include <linux/i2c.h>
22 #include <linux/slab.h>
23 #include <linux/regmap.h>
24 #include <linux/regulator/consumer.h>
25 #include <linux/spi/spi.h>
26 #include <linux/of_device.h>
27 #include <linux/mutex.h>
28 #include <sound/core.h>
29 #include <sound/pcm.h>
30 #include <sound/pcm_params.h>
31 #include <sound/soc.h>
32 #include <sound/initval.h>
33 #include <sound/tlv.h>
37 #define WM8731_NUM_SUPPLIES 4
38 static const char *wm8731_supply_names
[WM8731_NUM_SUPPLIES
] = {
45 /* codec private data */
47 struct regmap
*regmap
;
48 struct regulator_bulk_data supplies
[WM8731_NUM_SUPPLIES
];
49 const struct snd_pcm_hw_constraint_list
*constraints
;
60 * wm8731 register cache
62 static const struct reg_default wm8731_reg_defaults
[] = {
75 static bool wm8731_volatile(struct device
*dev
, unsigned int reg
)
77 return reg
== WM8731_RESET
;
80 static bool wm8731_writeable(struct device
*dev
, unsigned int reg
)
82 return reg
<= WM8731_RESET
;
85 #define wm8731_reset(c) snd_soc_write(c, WM8731_RESET, 0)
87 static const char *wm8731_input_select
[] = {"Line In", "Mic"};
89 static SOC_ENUM_SINGLE_DECL(wm8731_insel_enum
,
90 WM8731_APANA
, 2, wm8731_input_select
);
92 static int wm8731_deemph
[] = { 0, 32000, 44100, 48000 };
94 static int wm8731_set_deemph(struct snd_soc_codec
*codec
)
96 struct wm8731_priv
*wm8731
= snd_soc_codec_get_drvdata(codec
);
99 /* If we're using deemphasis select the nearest available sample
102 if (wm8731
->deemph
) {
104 for (i
= 2; i
< ARRAY_SIZE(wm8731_deemph
); i
++) {
105 if (abs(wm8731_deemph
[i
] - wm8731
->playback_fs
) <
106 abs(wm8731_deemph
[best
] - wm8731
->playback_fs
))
116 dev_dbg(codec
->dev
, "Set deemphasis %d (%dHz)\n",
117 best
, wm8731_deemph
[best
]);
119 return snd_soc_update_bits(codec
, WM8731_APDIGI
, 0x6, val
);
122 static int wm8731_get_deemph(struct snd_kcontrol
*kcontrol
,
123 struct snd_ctl_elem_value
*ucontrol
)
125 struct snd_soc_codec
*codec
= snd_soc_kcontrol_codec(kcontrol
);
126 struct wm8731_priv
*wm8731
= snd_soc_codec_get_drvdata(codec
);
128 ucontrol
->value
.enumerated
.item
[0] = wm8731
->deemph
;
133 static int wm8731_put_deemph(struct snd_kcontrol
*kcontrol
,
134 struct snd_ctl_elem_value
*ucontrol
)
136 struct snd_soc_codec
*codec
= snd_soc_kcontrol_codec(kcontrol
);
137 struct wm8731_priv
*wm8731
= snd_soc_codec_get_drvdata(codec
);
138 int deemph
= ucontrol
->value
.enumerated
.item
[0];
144 mutex_lock(&wm8731
->lock
);
145 if (wm8731
->deemph
!= deemph
) {
146 wm8731
->deemph
= deemph
;
148 wm8731_set_deemph(codec
);
152 mutex_unlock(&wm8731
->lock
);
157 static const DECLARE_TLV_DB_SCALE(in_tlv
, -3450, 150, 0);
158 static const DECLARE_TLV_DB_SCALE(sidetone_tlv
, -1500, 300, 0);
159 static const DECLARE_TLV_DB_SCALE(out_tlv
, -12100, 100, 1);
160 static const DECLARE_TLV_DB_SCALE(mic_tlv
, 0, 2000, 0);
162 static const struct snd_kcontrol_new wm8731_snd_controls
[] = {
164 SOC_DOUBLE_R_TLV("Master Playback Volume", WM8731_LOUT1V
, WM8731_ROUT1V
,
166 SOC_DOUBLE_R("Master Playback ZC Switch", WM8731_LOUT1V
, WM8731_ROUT1V
,
169 SOC_DOUBLE_R_TLV("Capture Volume", WM8731_LINVOL
, WM8731_RINVOL
, 0, 31, 0,
171 SOC_DOUBLE_R("Line Capture Switch", WM8731_LINVOL
, WM8731_RINVOL
, 7, 1, 1),
173 SOC_SINGLE_TLV("Mic Boost Volume", WM8731_APANA
, 0, 1, 0, mic_tlv
),
174 SOC_SINGLE("Mic Capture Switch", WM8731_APANA
, 1, 1, 1),
176 SOC_SINGLE_TLV("Sidetone Playback Volume", WM8731_APANA
, 6, 3, 1,
179 SOC_SINGLE("ADC High Pass Filter Switch", WM8731_APDIGI
, 0, 1, 1),
180 SOC_SINGLE("Store DC Offset Switch", WM8731_APDIGI
, 4, 1, 0),
182 SOC_SINGLE_BOOL_EXT("Playback Deemphasis Switch", 0,
183 wm8731_get_deemph
, wm8731_put_deemph
),
187 static const struct snd_kcontrol_new wm8731_output_mixer_controls
[] = {
188 SOC_DAPM_SINGLE("Line Bypass Switch", WM8731_APANA
, 3, 1, 0),
189 SOC_DAPM_SINGLE("Mic Sidetone Switch", WM8731_APANA
, 5, 1, 0),
190 SOC_DAPM_SINGLE("HiFi Playback Switch", WM8731_APANA
, 4, 1, 0),
194 static const struct snd_kcontrol_new wm8731_input_mux_controls
=
195 SOC_DAPM_ENUM("Input Select", wm8731_insel_enum
);
197 static const struct snd_soc_dapm_widget wm8731_dapm_widgets
[] = {
198 SND_SOC_DAPM_SUPPLY("ACTIVE",WM8731_ACTIVE
, 0, 0, NULL
, 0),
199 SND_SOC_DAPM_SUPPLY("OSC", WM8731_PWR
, 5, 1, NULL
, 0),
200 SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR
, 4, 1,
201 &wm8731_output_mixer_controls
[0],
202 ARRAY_SIZE(wm8731_output_mixer_controls
)),
203 SND_SOC_DAPM_DAC("DAC", "HiFi Playback", WM8731_PWR
, 3, 1),
204 SND_SOC_DAPM_OUTPUT("LOUT"),
205 SND_SOC_DAPM_OUTPUT("LHPOUT"),
206 SND_SOC_DAPM_OUTPUT("ROUT"),
207 SND_SOC_DAPM_OUTPUT("RHPOUT"),
208 SND_SOC_DAPM_ADC("ADC", "HiFi Capture", WM8731_PWR
, 2, 1),
209 SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM
, 0, 0, &wm8731_input_mux_controls
),
210 SND_SOC_DAPM_PGA("Line Input", WM8731_PWR
, 0, 1, NULL
, 0),
211 SND_SOC_DAPM_MICBIAS("Mic Bias", WM8731_PWR
, 1, 1),
212 SND_SOC_DAPM_INPUT("MICIN"),
213 SND_SOC_DAPM_INPUT("RLINEIN"),
214 SND_SOC_DAPM_INPUT("LLINEIN"),
217 static int wm8731_check_osc(struct snd_soc_dapm_widget
*source
,
218 struct snd_soc_dapm_widget
*sink
)
220 struct wm8731_priv
*wm8731
= snd_soc_codec_get_drvdata(source
->codec
);
222 return wm8731
->sysclk_type
== WM8731_SYSCLK_XTAL
;
225 static const struct snd_soc_dapm_route wm8731_intercon
[] = {
226 {"DAC", NULL
, "OSC", wm8731_check_osc
},
227 {"ADC", NULL
, "OSC", wm8731_check_osc
},
228 {"DAC", NULL
, "ACTIVE"},
229 {"ADC", NULL
, "ACTIVE"},
232 {"Output Mixer", "Line Bypass Switch", "Line Input"},
233 {"Output Mixer", "HiFi Playback Switch", "DAC"},
234 {"Output Mixer", "Mic Sidetone Switch", "Mic Bias"},
237 {"RHPOUT", NULL
, "Output Mixer"},
238 {"ROUT", NULL
, "Output Mixer"},
239 {"LHPOUT", NULL
, "Output Mixer"},
240 {"LOUT", NULL
, "Output Mixer"},
243 {"Input Mux", "Line In", "Line Input"},
244 {"Input Mux", "Mic", "Mic Bias"},
245 {"ADC", NULL
, "Input Mux"},
248 {"Line Input", NULL
, "LLINEIN"},
249 {"Line Input", NULL
, "RLINEIN"},
250 {"Mic Bias", NULL
, "MICIN"},
262 /* codec mclk clock divider coefficients */
263 static const struct _coeff_div coeff_div
[] = {
265 {12288000, 48000, 256, 0x0, 0x0, 0x0},
266 {18432000, 48000, 384, 0x0, 0x1, 0x0},
267 {12000000, 48000, 250, 0x0, 0x0, 0x1},
270 {12288000, 32000, 384, 0x6, 0x0, 0x0},
271 {18432000, 32000, 576, 0x6, 0x1, 0x0},
272 {12000000, 32000, 375, 0x6, 0x0, 0x1},
275 {12288000, 8000, 1536, 0x3, 0x0, 0x0},
276 {18432000, 8000, 2304, 0x3, 0x1, 0x0},
277 {11289600, 8000, 1408, 0xb, 0x0, 0x0},
278 {16934400, 8000, 2112, 0xb, 0x1, 0x0},
279 {12000000, 8000, 1500, 0x3, 0x0, 0x1},
282 {12288000, 96000, 128, 0x7, 0x0, 0x0},
283 {18432000, 96000, 192, 0x7, 0x1, 0x0},
284 {12000000, 96000, 125, 0x7, 0x0, 0x1},
287 {11289600, 44100, 256, 0x8, 0x0, 0x0},
288 {16934400, 44100, 384, 0x8, 0x1, 0x0},
289 {12000000, 44100, 272, 0x8, 0x1, 0x1},
292 {11289600, 88200, 128, 0xf, 0x0, 0x0},
293 {16934400, 88200, 192, 0xf, 0x1, 0x0},
294 {12000000, 88200, 136, 0xf, 0x1, 0x1},
297 /* rates constraints */
298 static const unsigned int wm8731_rates_12000000
[] = {
299 8000, 32000, 44100, 48000, 96000, 88200,
302 static const unsigned int wm8731_rates_12288000_18432000
[] = {
303 8000, 32000, 48000, 96000,
306 static const unsigned int wm8731_rates_11289600_16934400
[] = {
310 static const struct snd_pcm_hw_constraint_list wm8731_constraints_12000000
= {
311 .list
= wm8731_rates_12000000
,
312 .count
= ARRAY_SIZE(wm8731_rates_12000000
),
316 struct snd_pcm_hw_constraint_list wm8731_constraints_12288000_18432000
= {
317 .list
= wm8731_rates_12288000_18432000
,
318 .count
= ARRAY_SIZE(wm8731_rates_12288000_18432000
),
322 struct snd_pcm_hw_constraint_list wm8731_constraints_11289600_16934400
= {
323 .list
= wm8731_rates_11289600_16934400
,
324 .count
= ARRAY_SIZE(wm8731_rates_11289600_16934400
),
327 static inline int get_coeff(int mclk
, int rate
)
331 for (i
= 0; i
< ARRAY_SIZE(coeff_div
); i
++) {
332 if (coeff_div
[i
].rate
== rate
&& coeff_div
[i
].mclk
== mclk
)
338 static int wm8731_hw_params(struct snd_pcm_substream
*substream
,
339 struct snd_pcm_hw_params
*params
,
340 struct snd_soc_dai
*dai
)
342 struct snd_soc_codec
*codec
= dai
->codec
;
343 struct wm8731_priv
*wm8731
= snd_soc_codec_get_drvdata(codec
);
344 u16 iface
= snd_soc_read(codec
, WM8731_IFACE
) & 0xfff3;
345 int i
= get_coeff(wm8731
->sysclk
, params_rate(params
));
346 u16 srate
= (coeff_div
[i
].sr
<< 2) |
347 (coeff_div
[i
].bosr
<< 1) | coeff_div
[i
].usb
;
349 wm8731
->playback_fs
= params_rate(params
);
351 snd_soc_write(codec
, WM8731_SRATE
, srate
);
354 switch (params_width(params
)) {
365 wm8731_set_deemph(codec
);
367 snd_soc_write(codec
, WM8731_IFACE
, iface
);
371 static int wm8731_mute(struct snd_soc_dai
*dai
, int mute
)
373 struct snd_soc_codec
*codec
= dai
->codec
;
374 u16 mute_reg
= snd_soc_read(codec
, WM8731_APDIGI
) & 0xfff7;
377 snd_soc_write(codec
, WM8731_APDIGI
, mute_reg
| 0x8);
379 snd_soc_write(codec
, WM8731_APDIGI
, mute_reg
);
383 static int wm8731_set_dai_sysclk(struct snd_soc_dai
*codec_dai
,
384 int clk_id
, unsigned int freq
, int dir
)
386 struct snd_soc_codec
*codec
= codec_dai
->codec
;
387 struct wm8731_priv
*wm8731
= snd_soc_codec_get_drvdata(codec
);
390 case WM8731_SYSCLK_XTAL
:
391 case WM8731_SYSCLK_MCLK
:
392 wm8731
->sysclk_type
= clk_id
;
400 wm8731
->constraints
= NULL
;
403 wm8731
->constraints
= &wm8731_constraints_12000000
;
407 wm8731
->constraints
= &wm8731_constraints_12288000_18432000
;
411 wm8731
->constraints
= &wm8731_constraints_11289600_16934400
;
417 wm8731
->sysclk
= freq
;
419 snd_soc_dapm_sync(&codec
->dapm
);
425 static int wm8731_set_dai_fmt(struct snd_soc_dai
*codec_dai
,
428 struct snd_soc_codec
*codec
= codec_dai
->codec
;
431 /* set master/slave audio interface */
432 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
433 case SND_SOC_DAIFMT_CBM_CFM
:
436 case SND_SOC_DAIFMT_CBS_CFS
:
442 /* interface format */
443 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
444 case SND_SOC_DAIFMT_I2S
:
447 case SND_SOC_DAIFMT_RIGHT_J
:
449 case SND_SOC_DAIFMT_LEFT_J
:
452 case SND_SOC_DAIFMT_DSP_A
:
455 case SND_SOC_DAIFMT_DSP_B
:
462 /* clock inversion */
463 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
464 case SND_SOC_DAIFMT_NB_NF
:
466 case SND_SOC_DAIFMT_IB_IF
:
469 case SND_SOC_DAIFMT_IB_NF
:
472 case SND_SOC_DAIFMT_NB_IF
:
480 snd_soc_write(codec
, WM8731_IFACE
, iface
);
484 static int wm8731_set_bias_level(struct snd_soc_codec
*codec
,
485 enum snd_soc_bias_level level
)
487 struct wm8731_priv
*wm8731
= snd_soc_codec_get_drvdata(codec
);
492 case SND_SOC_BIAS_ON
:
494 case SND_SOC_BIAS_PREPARE
:
496 case SND_SOC_BIAS_STANDBY
:
497 if (codec
->dapm
.bias_level
== SND_SOC_BIAS_OFF
) {
498 ret
= regulator_bulk_enable(ARRAY_SIZE(wm8731
->supplies
),
503 regcache_sync(wm8731
->regmap
);
506 /* Clear PWROFF, gate CLKOUT, everything else as-is */
507 reg
= snd_soc_read(codec
, WM8731_PWR
) & 0xff7f;
508 snd_soc_write(codec
, WM8731_PWR
, reg
| 0x0040);
510 case SND_SOC_BIAS_OFF
:
511 snd_soc_write(codec
, WM8731_PWR
, 0xffff);
512 regulator_bulk_disable(ARRAY_SIZE(wm8731
->supplies
),
514 regcache_mark_dirty(wm8731
->regmap
);
517 codec
->dapm
.bias_level
= level
;
521 static int wm8731_startup(struct snd_pcm_substream
*substream
,
522 struct snd_soc_dai
*dai
)
524 struct wm8731_priv
*wm8731
= snd_soc_codec_get_drvdata(dai
->codec
);
526 if (wm8731
->constraints
)
527 snd_pcm_hw_constraint_list(substream
->runtime
, 0,
528 SNDRV_PCM_HW_PARAM_RATE
,
529 wm8731
->constraints
);
534 #define WM8731_RATES SNDRV_PCM_RATE_8000_96000
536 #define WM8731_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
537 SNDRV_PCM_FMTBIT_S24_LE)
539 static const struct snd_soc_dai_ops wm8731_dai_ops
= {
540 .startup
= wm8731_startup
,
541 .hw_params
= wm8731_hw_params
,
542 .digital_mute
= wm8731_mute
,
543 .set_sysclk
= wm8731_set_dai_sysclk
,
544 .set_fmt
= wm8731_set_dai_fmt
,
547 static struct snd_soc_dai_driver wm8731_dai
= {
548 .name
= "wm8731-hifi",
550 .stream_name
= "Playback",
553 .rates
= WM8731_RATES
,
554 .formats
= WM8731_FORMATS
,},
556 .stream_name
= "Capture",
559 .rates
= WM8731_RATES
,
560 .formats
= WM8731_FORMATS
,},
561 .ops
= &wm8731_dai_ops
,
562 .symmetric_rates
= 1,
565 static int wm8731_probe(struct snd_soc_codec
*codec
)
567 struct wm8731_priv
*wm8731
= snd_soc_codec_get_drvdata(codec
);
570 for (i
= 0; i
< ARRAY_SIZE(wm8731
->supplies
); i
++)
571 wm8731
->supplies
[i
].supply
= wm8731_supply_names
[i
];
573 ret
= devm_regulator_bulk_get(codec
->dev
, ARRAY_SIZE(wm8731
->supplies
),
576 dev_err(codec
->dev
, "Failed to request supplies: %d\n", ret
);
580 ret
= regulator_bulk_enable(ARRAY_SIZE(wm8731
->supplies
),
583 dev_err(codec
->dev
, "Failed to enable supplies: %d\n", ret
);
587 ret
= wm8731_reset(codec
);
589 dev_err(codec
->dev
, "Failed to issue reset: %d\n", ret
);
590 goto err_regulator_enable
;
593 wm8731_set_bias_level(codec
, SND_SOC_BIAS_STANDBY
);
595 /* Latch the update bits */
596 snd_soc_update_bits(codec
, WM8731_LOUT1V
, 0x100, 0);
597 snd_soc_update_bits(codec
, WM8731_ROUT1V
, 0x100, 0);
598 snd_soc_update_bits(codec
, WM8731_LINVOL
, 0x100, 0);
599 snd_soc_update_bits(codec
, WM8731_RINVOL
, 0x100, 0);
601 /* Disable bypass path by default */
602 snd_soc_update_bits(codec
, WM8731_APANA
, 0x8, 0);
604 /* Regulators will have been enabled by bias management */
605 regulator_bulk_disable(ARRAY_SIZE(wm8731
->supplies
), wm8731
->supplies
);
609 err_regulator_enable
:
610 regulator_bulk_disable(ARRAY_SIZE(wm8731
->supplies
), wm8731
->supplies
);
615 /* power down chip */
616 static int wm8731_remove(struct snd_soc_codec
*codec
)
618 struct wm8731_priv
*wm8731
= snd_soc_codec_get_drvdata(codec
);
620 regulator_bulk_disable(ARRAY_SIZE(wm8731
->supplies
), wm8731
->supplies
);
625 static struct snd_soc_codec_driver soc_codec_dev_wm8731
= {
626 .probe
= wm8731_probe
,
627 .remove
= wm8731_remove
,
628 .set_bias_level
= wm8731_set_bias_level
,
629 .suspend_bias_off
= true,
631 .dapm_widgets
= wm8731_dapm_widgets
,
632 .num_dapm_widgets
= ARRAY_SIZE(wm8731_dapm_widgets
),
633 .dapm_routes
= wm8731_intercon
,
634 .num_dapm_routes
= ARRAY_SIZE(wm8731_intercon
),
635 .controls
= wm8731_snd_controls
,
636 .num_controls
= ARRAY_SIZE(wm8731_snd_controls
),
639 static const struct of_device_id wm8731_of_match
[] = {
640 { .compatible
= "wlf,wm8731", },
644 MODULE_DEVICE_TABLE(of
, wm8731_of_match
);
646 static const struct regmap_config wm8731_regmap
= {
650 .max_register
= WM8731_RESET
,
651 .volatile_reg
= wm8731_volatile
,
652 .writeable_reg
= wm8731_writeable
,
654 .cache_type
= REGCACHE_RBTREE
,
655 .reg_defaults
= wm8731_reg_defaults
,
656 .num_reg_defaults
= ARRAY_SIZE(wm8731_reg_defaults
),
659 #if defined(CONFIG_SPI_MASTER)
660 static int wm8731_spi_probe(struct spi_device
*spi
)
662 struct wm8731_priv
*wm8731
;
665 wm8731
= devm_kzalloc(&spi
->dev
, sizeof(*wm8731
), GFP_KERNEL
);
669 mutex_init(&wm8731
->lock
);
671 wm8731
->regmap
= devm_regmap_init_spi(spi
, &wm8731_regmap
);
672 if (IS_ERR(wm8731
->regmap
)) {
673 ret
= PTR_ERR(wm8731
->regmap
);
674 dev_err(&spi
->dev
, "Failed to allocate register map: %d\n",
679 spi_set_drvdata(spi
, wm8731
);
681 ret
= snd_soc_register_codec(&spi
->dev
,
682 &soc_codec_dev_wm8731
, &wm8731_dai
, 1);
684 dev_err(&spi
->dev
, "Failed to register CODEC: %d\n", ret
);
691 static int wm8731_spi_remove(struct spi_device
*spi
)
693 snd_soc_unregister_codec(&spi
->dev
);
697 static struct spi_driver wm8731_spi_driver
= {
700 .owner
= THIS_MODULE
,
701 .of_match_table
= wm8731_of_match
,
703 .probe
= wm8731_spi_probe
,
704 .remove
= wm8731_spi_remove
,
706 #endif /* CONFIG_SPI_MASTER */
708 #if IS_ENABLED(CONFIG_I2C)
709 static int wm8731_i2c_probe(struct i2c_client
*i2c
,
710 const struct i2c_device_id
*id
)
712 struct wm8731_priv
*wm8731
;
715 wm8731
= devm_kzalloc(&i2c
->dev
, sizeof(struct wm8731_priv
),
720 mutex_init(&wm8731
->lock
);
722 wm8731
->regmap
= devm_regmap_init_i2c(i2c
, &wm8731_regmap
);
723 if (IS_ERR(wm8731
->regmap
)) {
724 ret
= PTR_ERR(wm8731
->regmap
);
725 dev_err(&i2c
->dev
, "Failed to allocate register map: %d\n",
730 i2c_set_clientdata(i2c
, wm8731
);
732 ret
= snd_soc_register_codec(&i2c
->dev
,
733 &soc_codec_dev_wm8731
, &wm8731_dai
, 1);
735 dev_err(&i2c
->dev
, "Failed to register CODEC: %d\n", ret
);
742 static int wm8731_i2c_remove(struct i2c_client
*client
)
744 snd_soc_unregister_codec(&client
->dev
);
748 static const struct i2c_device_id wm8731_i2c_id
[] = {
752 MODULE_DEVICE_TABLE(i2c
, wm8731_i2c_id
);
754 static struct i2c_driver wm8731_i2c_driver
= {
757 .owner
= THIS_MODULE
,
758 .of_match_table
= wm8731_of_match
,
760 .probe
= wm8731_i2c_probe
,
761 .remove
= wm8731_i2c_remove
,
762 .id_table
= wm8731_i2c_id
,
766 static int __init
wm8731_modinit(void)
769 #if IS_ENABLED(CONFIG_I2C)
770 ret
= i2c_add_driver(&wm8731_i2c_driver
);
772 printk(KERN_ERR
"Failed to register WM8731 I2C driver: %d\n",
776 #if defined(CONFIG_SPI_MASTER)
777 ret
= spi_register_driver(&wm8731_spi_driver
);
779 printk(KERN_ERR
"Failed to register WM8731 SPI driver: %d\n",
785 module_init(wm8731_modinit
);
787 static void __exit
wm8731_exit(void)
789 #if IS_ENABLED(CONFIG_I2C)
790 i2c_del_driver(&wm8731_i2c_driver
);
792 #if defined(CONFIG_SPI_MASTER)
793 spi_unregister_driver(&wm8731_spi_driver
);
796 module_exit(wm8731_exit
);
798 MODULE_DESCRIPTION("ASoC WM8731 driver");
799 MODULE_AUTHOR("Richard Purdie");
800 MODULE_LICENSE("GPL");