1 // SPDX-License-Identifier: GPL-2.0
3 * ALSA SoC Texas Instruments TAS6424 Quad-Channel Audio Amplifier
5 * Copyright (C) 2016-2017 Texas Instruments Incorporated - http://www.ti.com/
6 * Author: Andreas Dannenberg <dannenberg@ti.com>
7 * Andrew F. Davis <afd@ti.com>
10 #include <linux/module.h>
11 #include <linux/errno.h>
12 #include <linux/device.h>
13 #include <linux/i2c.h>
14 #include <linux/pm_runtime.h>
15 #include <linux/regmap.h>
16 #include <linux/slab.h>
17 #include <linux/regulator/consumer.h>
18 #include <linux/delay.h>
20 #include <sound/pcm.h>
21 #include <sound/pcm_params.h>
22 #include <sound/soc.h>
23 #include <sound/soc-dapm.h>
24 #include <sound/tlv.h>
28 /* Define how often to check (and clear) the fault status register (in ms) */
29 #define TAS6424_FAULT_CHECK_INTERVAL 200
31 static const char * const tas6424_supply_names
[] = {
32 "dvdd", /* Digital power supply. Connect to 3.3-V supply. */
33 "vbat", /* Supply used for higher voltage analog circuits. */
34 "pvdd", /* Class-D amp output FETs supply. */
36 #define TAS6424_NUM_SUPPLIES ARRAY_SIZE(tas6424_supply_names)
40 struct regmap
*regmap
;
41 struct regulator_bulk_data supplies
[TAS6424_NUM_SUPPLIES
];
42 struct delayed_work fault_check_work
;
43 unsigned int last_fault1
;
44 unsigned int last_fault2
;
45 unsigned int last_warn
;
49 * DAC digital volumes. From -103.5 to 24 dB in 0.5 dB steps. Note that
50 * setting the gain below -100 dB (register value <0x7) is effectively a MUTE
51 * as per device datasheet.
53 static DECLARE_TLV_DB_SCALE(dac_tlv
, -10350, 50, 0);
55 static const struct snd_kcontrol_new tas6424_snd_controls
[] = {
56 SOC_SINGLE_TLV("Speaker Driver CH1 Playback Volume",
57 TAS6424_CH1_VOL_CTRL
, 0, 0xff, 0, dac_tlv
),
58 SOC_SINGLE_TLV("Speaker Driver CH2 Playback Volume",
59 TAS6424_CH2_VOL_CTRL
, 0, 0xff, 0, dac_tlv
),
60 SOC_SINGLE_TLV("Speaker Driver CH3 Playback Volume",
61 TAS6424_CH3_VOL_CTRL
, 0, 0xff, 0, dac_tlv
),
62 SOC_SINGLE_TLV("Speaker Driver CH4 Playback Volume",
63 TAS6424_CH4_VOL_CTRL
, 0, 0xff, 0, dac_tlv
),
66 static int tas6424_dac_event(struct snd_soc_dapm_widget
*w
,
67 struct snd_kcontrol
*kcontrol
, int event
)
69 struct snd_soc_codec
*codec
= snd_soc_dapm_to_codec(w
->dapm
);
70 struct tas6424_data
*tas6424
= snd_soc_codec_get_drvdata(codec
);
72 dev_dbg(codec
->dev
, "%s() event=0x%0x\n", __func__
, event
);
74 if (event
& SND_SOC_DAPM_POST_PMU
) {
75 /* Observe codec shutdown-to-active time */
78 /* Turn on TAS6424 periodic fault checking/handling */
79 tas6424
->last_fault1
= 0;
80 tas6424
->last_fault2
= 0;
81 tas6424
->last_warn
= 0;
82 schedule_delayed_work(&tas6424
->fault_check_work
,
83 msecs_to_jiffies(TAS6424_FAULT_CHECK_INTERVAL
));
84 } else if (event
& SND_SOC_DAPM_PRE_PMD
) {
85 /* Disable TAS6424 periodic fault checking/handling */
86 cancel_delayed_work_sync(&tas6424
->fault_check_work
);
92 static const struct snd_soc_dapm_widget tas6424_dapm_widgets
[] = {
93 SND_SOC_DAPM_AIF_IN("DAC IN", "Playback", 0, SND_SOC_NOPM
, 0, 0),
94 SND_SOC_DAPM_DAC_E("DAC", NULL
, SND_SOC_NOPM
, 0, 0, tas6424_dac_event
,
95 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_PRE_PMD
),
96 SND_SOC_DAPM_OUTPUT("OUT")
99 static const struct snd_soc_dapm_route tas6424_audio_map
[] = {
100 { "DAC", NULL
, "DAC IN" },
101 { "OUT", NULL
, "DAC" },
104 static int tas6424_hw_params(struct snd_pcm_substream
*substream
,
105 struct snd_pcm_hw_params
*params
,
106 struct snd_soc_dai
*dai
)
108 struct snd_soc_codec
*codec
= dai
->codec
;
109 unsigned int rate
= params_rate(params
);
110 unsigned int width
= params_width(params
);
113 dev_dbg(codec
->dev
, "%s() rate=%u width=%u\n", __func__
, rate
, width
);
117 sap_ctrl
|= TAS6424_SAP_RATE_44100
;
120 sap_ctrl
|= TAS6424_SAP_RATE_48000
;
123 sap_ctrl
|= TAS6424_SAP_RATE_96000
;
126 dev_err(codec
->dev
, "unsupported sample rate: %u\n", rate
);
132 sap_ctrl
|= TAS6424_SAP_TDM_SLOT_SZ_16
;
137 dev_err(codec
->dev
, "unsupported sample width: %u\n", width
);
141 snd_soc_update_bits(codec
, TAS6424_SAP_CTRL
,
142 TAS6424_SAP_RATE_MASK
|
143 TAS6424_SAP_TDM_SLOT_SZ_16
,
149 static int tas6424_set_dai_fmt(struct snd_soc_dai
*dai
, unsigned int fmt
)
151 struct snd_soc_codec
*codec
= dai
->codec
;
152 u8 serial_format
= 0;
154 dev_dbg(codec
->dev
, "%s() fmt=0x%0x\n", __func__
, fmt
);
157 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
158 case SND_SOC_DAIFMT_CBS_CFS
:
161 dev_err(codec
->dev
, "Invalid DAI master/slave interface\n");
165 /* signal polarity */
166 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
167 case SND_SOC_DAIFMT_NB_NF
:
170 dev_err(codec
->dev
, "Invalid DAI clock signal polarity\n");
174 /* interface format */
175 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
176 case SND_SOC_DAIFMT_I2S
:
177 serial_format
|= TAS6424_SAP_I2S
;
179 case SND_SOC_DAIFMT_DSP_A
:
180 serial_format
|= TAS6424_SAP_DSP
;
182 case SND_SOC_DAIFMT_DSP_B
:
184 * We can use the fact that the TAS6424 does not care about the
185 * LRCLK duty cycle during TDM to receive DSP_B formatted data
186 * in LEFTJ mode (no delaying of the 1st data bit).
188 serial_format
|= TAS6424_SAP_LEFTJ
;
190 case SND_SOC_DAIFMT_LEFT_J
:
191 serial_format
|= TAS6424_SAP_LEFTJ
;
194 dev_err(codec
->dev
, "Invalid DAI interface format\n");
198 snd_soc_update_bits(codec
, TAS6424_SAP_CTRL
,
199 TAS6424_SAP_FMT_MASK
, serial_format
);
204 static int tas6424_set_dai_tdm_slot(struct snd_soc_dai
*dai
,
205 unsigned int tx_mask
, unsigned int rx_mask
,
206 int slots
, int slot_width
)
208 struct snd_soc_codec
*codec
= dai
->codec
;
209 unsigned int first_slot
, last_slot
;
210 bool sap_tdm_slot_last
;
212 dev_dbg(codec
->dev
, "%s() tx_mask=%d rx_mask=%d\n", __func__
,
215 if (!tx_mask
|| !rx_mask
)
216 return 0; /* nothing needed to disable TDM mode */
219 * Determine the first slot and last slot that is being requested so
220 * we'll be able to more easily enforce certain constraints as the
221 * TAS6424's TDM interface is not fully configurable.
223 first_slot
= __ffs(tx_mask
);
224 last_slot
= __fls(rx_mask
);
226 if (last_slot
- first_slot
!= 4) {
227 dev_err(codec
->dev
, "tdm mask must cover 4 contiguous slots\n");
231 switch (first_slot
) {
233 sap_tdm_slot_last
= false;
236 sap_tdm_slot_last
= true;
239 dev_err(codec
->dev
, "tdm mask must start at slot 0 or 4\n");
243 snd_soc_update_bits(codec
, TAS6424_SAP_CTRL
, TAS6424_SAP_TDM_SLOT_LAST
,
244 sap_tdm_slot_last
? TAS6424_SAP_TDM_SLOT_LAST
: 0);
249 static int tas6424_mute(struct snd_soc_dai
*dai
, int mute
)
251 struct snd_soc_codec
*codec
= dai
->codec
;
254 dev_dbg(codec
->dev
, "%s() mute=%d\n", __func__
, mute
);
257 val
= TAS6424_ALL_STATE_MUTE
;
259 val
= TAS6424_ALL_STATE_PLAY
;
261 snd_soc_write(codec
, TAS6424_CH_STATE_CTRL
, val
);
266 static int tas6424_power_off(struct snd_soc_codec
*codec
)
268 struct tas6424_data
*tas6424
= snd_soc_codec_get_drvdata(codec
);
271 snd_soc_write(codec
, TAS6424_CH_STATE_CTRL
, TAS6424_ALL_STATE_HIZ
);
273 regcache_cache_only(tas6424
->regmap
, true);
274 regcache_mark_dirty(tas6424
->regmap
);
276 ret
= regulator_bulk_disable(ARRAY_SIZE(tas6424
->supplies
),
279 dev_err(codec
->dev
, "failed to disable supplies: %d\n", ret
);
286 static int tas6424_power_on(struct snd_soc_codec
*codec
)
288 struct tas6424_data
*tas6424
= snd_soc_codec_get_drvdata(codec
);
291 ret
= regulator_bulk_enable(ARRAY_SIZE(tas6424
->supplies
),
294 dev_err(codec
->dev
, "failed to enable supplies: %d\n", ret
);
298 regcache_cache_only(tas6424
->regmap
, false);
300 ret
= regcache_sync(tas6424
->regmap
);
302 dev_err(codec
->dev
, "failed to sync regcache: %d\n", ret
);
306 snd_soc_write(codec
, TAS6424_CH_STATE_CTRL
, TAS6424_ALL_STATE_MUTE
);
308 /* any time we come out of HIZ, the output channels automatically run DC
309 * load diagnostics, wait here until this completes
316 static int tas6424_set_bias_level(struct snd_soc_codec
*codec
,
317 enum snd_soc_bias_level level
)
319 dev_dbg(codec
->dev
, "%s() level=%d\n", __func__
, level
);
322 case SND_SOC_BIAS_ON
:
323 case SND_SOC_BIAS_PREPARE
:
325 case SND_SOC_BIAS_STANDBY
:
326 if (snd_soc_codec_get_bias_level(codec
) == SND_SOC_BIAS_OFF
)
327 tas6424_power_on(codec
);
329 case SND_SOC_BIAS_OFF
:
330 tas6424_power_off(codec
);
337 static struct snd_soc_codec_driver soc_codec_dev_tas6424
= {
338 .set_bias_level
= tas6424_set_bias_level
,
339 .idle_bias_off
= true,
341 .component_driver
= {
342 .controls
= tas6424_snd_controls
,
343 .num_controls
= ARRAY_SIZE(tas6424_snd_controls
),
344 .dapm_widgets
= tas6424_dapm_widgets
,
345 .num_dapm_widgets
= ARRAY_SIZE(tas6424_dapm_widgets
),
346 .dapm_routes
= tas6424_audio_map
,
347 .num_dapm_routes
= ARRAY_SIZE(tas6424_audio_map
),
351 static struct snd_soc_dai_ops tas6424_speaker_dai_ops
= {
352 .hw_params
= tas6424_hw_params
,
353 .set_fmt
= tas6424_set_dai_fmt
,
354 .set_tdm_slot
= tas6424_set_dai_tdm_slot
,
355 .digital_mute
= tas6424_mute
,
358 static struct snd_soc_dai_driver tas6424_dai
[] = {
360 .name
= "tas6424-amplifier",
362 .stream_name
= "Playback",
365 .rates
= TAS6424_RATES
,
366 .formats
= TAS6424_FORMATS
,
368 .ops
= &tas6424_speaker_dai_ops
,
372 static void tas6424_fault_check_work(struct work_struct
*work
)
374 struct tas6424_data
*tas6424
= container_of(work
, struct tas6424_data
,
375 fault_check_work
.work
);
376 struct device
*dev
= tas6424
->dev
;
380 ret
= regmap_read(tas6424
->regmap
, TAS6424_GLOB_FAULT1
, ®
);
382 dev_err(dev
, "failed to read FAULT1 register: %d\n", ret
);
387 * Ignore any clock faults as there is no clean way to check for them.
388 * We would need to start checking for those faults *after* the SAIF
389 * stream has been setup, and stop checking *before* the stream is
390 * stopped to avoid any false-positives. However there are no
391 * appropriate hooks to monitor these events.
393 reg
&= TAS6424_FAULT_PVDD_OV
|
394 TAS6424_FAULT_VBAT_OV
|
395 TAS6424_FAULT_PVDD_UV
|
396 TAS6424_FAULT_VBAT_UV
;
399 goto check_global_fault2_reg
;
402 * Only flag errors once for a given occurrence. This is needed as
403 * the TAS6424 will take time clearing the fault condition internally
404 * during which we don't want to bombard the system with the same
405 * error message over and over.
407 if ((reg
& TAS6424_FAULT_PVDD_OV
) && !(tas6424
->last_fault1
& TAS6424_FAULT_PVDD_OV
))
408 dev_crit(dev
, "experienced a PVDD overvoltage fault\n");
410 if ((reg
& TAS6424_FAULT_VBAT_OV
) && !(tas6424
->last_fault1
& TAS6424_FAULT_VBAT_OV
))
411 dev_crit(dev
, "experienced a VBAT overvoltage fault\n");
413 if ((reg
& TAS6424_FAULT_PVDD_UV
) && !(tas6424
->last_fault1
& TAS6424_FAULT_PVDD_UV
))
414 dev_crit(dev
, "experienced a PVDD undervoltage fault\n");
416 if ((reg
& TAS6424_FAULT_VBAT_UV
) && !(tas6424
->last_fault1
& TAS6424_FAULT_VBAT_UV
))
417 dev_crit(dev
, "experienced a VBAT undervoltage fault\n");
419 /* Store current fault1 value so we can detect any changes next time */
420 tas6424
->last_fault1
= reg
;
422 check_global_fault2_reg
:
423 ret
= regmap_read(tas6424
->regmap
, TAS6424_GLOB_FAULT2
, ®
);
425 dev_err(dev
, "failed to read FAULT2 register: %d\n", ret
);
429 reg
&= TAS6424_FAULT_OTSD
|
430 TAS6424_FAULT_OTSD_CH1
|
431 TAS6424_FAULT_OTSD_CH2
|
432 TAS6424_FAULT_OTSD_CH3
|
433 TAS6424_FAULT_OTSD_CH4
;
438 if ((reg
& TAS6424_FAULT_OTSD
) && !(tas6424
->last_fault2
& TAS6424_FAULT_OTSD
))
439 dev_crit(dev
, "experienced a global overtemp shutdown\n");
441 if ((reg
& TAS6424_FAULT_OTSD_CH1
) && !(tas6424
->last_fault2
& TAS6424_FAULT_OTSD_CH1
))
442 dev_crit(dev
, "experienced an overtemp shutdown on CH1\n");
444 if ((reg
& TAS6424_FAULT_OTSD_CH2
) && !(tas6424
->last_fault2
& TAS6424_FAULT_OTSD_CH2
))
445 dev_crit(dev
, "experienced an overtemp shutdown on CH2\n");
447 if ((reg
& TAS6424_FAULT_OTSD_CH3
) && !(tas6424
->last_fault2
& TAS6424_FAULT_OTSD_CH3
))
448 dev_crit(dev
, "experienced an overtemp shutdown on CH3\n");
450 if ((reg
& TAS6424_FAULT_OTSD_CH4
) && !(tas6424
->last_fault2
& TAS6424_FAULT_OTSD_CH4
))
451 dev_crit(dev
, "experienced an overtemp shutdown on CH4\n");
453 /* Store current fault2 value so we can detect any changes next time */
454 tas6424
->last_fault2
= reg
;
457 ret
= regmap_read(tas6424
->regmap
, TAS6424_WARN
, ®
);
459 dev_err(dev
, "failed to read WARN register: %d\n", ret
);
463 reg
&= TAS6424_WARN_VDD_UV
|
464 TAS6424_WARN_VDD_POR
|
465 TAS6424_WARN_VDD_OTW
|
466 TAS6424_WARN_VDD_OTW_CH1
|
467 TAS6424_WARN_VDD_OTW_CH2
|
468 TAS6424_WARN_VDD_OTW_CH3
|
469 TAS6424_WARN_VDD_OTW_CH4
;
474 if ((reg
& TAS6424_WARN_VDD_UV
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_UV
))
475 dev_warn(dev
, "experienced a VDD under voltage condition\n");
477 if ((reg
& TAS6424_WARN_VDD_POR
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_POR
))
478 dev_warn(dev
, "experienced a VDD POR condition\n");
480 if ((reg
& TAS6424_WARN_VDD_OTW
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_OTW
))
481 dev_warn(dev
, "experienced a global overtemp warning\n");
483 if ((reg
& TAS6424_WARN_VDD_OTW_CH1
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_OTW_CH1
))
484 dev_warn(dev
, "experienced an overtemp warning on CH1\n");
486 if ((reg
& TAS6424_WARN_VDD_OTW_CH2
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_OTW_CH2
))
487 dev_warn(dev
, "experienced an overtemp warning on CH2\n");
489 if ((reg
& TAS6424_WARN_VDD_OTW_CH3
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_OTW_CH3
))
490 dev_warn(dev
, "experienced an overtemp warning on CH3\n");
492 if ((reg
& TAS6424_WARN_VDD_OTW_CH4
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_OTW_CH4
))
493 dev_warn(dev
, "experienced an overtemp warning on CH4\n");
495 /* Store current warn value so we can detect any changes next time */
496 tas6424
->last_warn
= reg
;
498 /* Clear any faults by toggling the CLEAR_FAULT control bit */
499 ret
= regmap_write_bits(tas6424
->regmap
, TAS6424_MISC_CTRL3
,
500 TAS6424_CLEAR_FAULT
, TAS6424_CLEAR_FAULT
);
502 dev_err(dev
, "failed to write MISC_CTRL3 register: %d\n", ret
);
504 ret
= regmap_write_bits(tas6424
->regmap
, TAS6424_MISC_CTRL3
,
505 TAS6424_CLEAR_FAULT
, 0);
507 dev_err(dev
, "failed to write MISC_CTRL3 register: %d\n", ret
);
510 /* Schedule the next fault check at the specified interval */
511 schedule_delayed_work(&tas6424
->fault_check_work
,
512 msecs_to_jiffies(TAS6424_FAULT_CHECK_INTERVAL
));
515 static const struct reg_default tas6424_reg_defaults
[] = {
516 { TAS6424_MODE_CTRL
, 0x00 },
517 { TAS6424_MISC_CTRL1
, 0x32 },
518 { TAS6424_MISC_CTRL2
, 0x62 },
519 { TAS6424_SAP_CTRL
, 0x04 },
520 { TAS6424_CH_STATE_CTRL
, 0x55 },
521 { TAS6424_CH1_VOL_CTRL
, 0xcf },
522 { TAS6424_CH2_VOL_CTRL
, 0xcf },
523 { TAS6424_CH3_VOL_CTRL
, 0xcf },
524 { TAS6424_CH4_VOL_CTRL
, 0xcf },
525 { TAS6424_DC_DIAG_CTRL1
, 0x00 },
526 { TAS6424_DC_DIAG_CTRL2
, 0x11 },
527 { TAS6424_DC_DIAG_CTRL3
, 0x11 },
528 { TAS6424_PIN_CTRL
, 0xff },
529 { TAS6424_AC_DIAG_CTRL1
, 0x00 },
530 { TAS6424_MISC_CTRL3
, 0x00 },
531 { TAS6424_CLIP_CTRL
, 0x01 },
532 { TAS6424_CLIP_WINDOW
, 0x14 },
533 { TAS6424_CLIP_WARN
, 0x00 },
534 { TAS6424_CBC_STAT
, 0x00 },
535 { TAS6424_MISC_CTRL4
, 0x40 },
538 static bool tas6424_is_writable_reg(struct device
*dev
, unsigned int reg
)
541 case TAS6424_MODE_CTRL
:
542 case TAS6424_MISC_CTRL1
:
543 case TAS6424_MISC_CTRL2
:
544 case TAS6424_SAP_CTRL
:
545 case TAS6424_CH_STATE_CTRL
:
546 case TAS6424_CH1_VOL_CTRL
:
547 case TAS6424_CH2_VOL_CTRL
:
548 case TAS6424_CH3_VOL_CTRL
:
549 case TAS6424_CH4_VOL_CTRL
:
550 case TAS6424_DC_DIAG_CTRL1
:
551 case TAS6424_DC_DIAG_CTRL2
:
552 case TAS6424_DC_DIAG_CTRL3
:
553 case TAS6424_PIN_CTRL
:
554 case TAS6424_AC_DIAG_CTRL1
:
555 case TAS6424_MISC_CTRL3
:
556 case TAS6424_CLIP_CTRL
:
557 case TAS6424_CLIP_WINDOW
:
558 case TAS6424_CLIP_WARN
:
559 case TAS6424_CBC_STAT
:
560 case TAS6424_MISC_CTRL4
:
567 static bool tas6424_is_volatile_reg(struct device
*dev
, unsigned int reg
)
570 case TAS6424_DC_LOAD_DIAG_REP12
:
571 case TAS6424_DC_LOAD_DIAG_REP34
:
572 case TAS6424_DC_LOAD_DIAG_REPLO
:
573 case TAS6424_CHANNEL_STATE
:
574 case TAS6424_CHANNEL_FAULT
:
575 case TAS6424_GLOB_FAULT1
:
576 case TAS6424_GLOB_FAULT2
:
578 case TAS6424_AC_LOAD_DIAG_REP1
:
579 case TAS6424_AC_LOAD_DIAG_REP2
:
580 case TAS6424_AC_LOAD_DIAG_REP3
:
581 case TAS6424_AC_LOAD_DIAG_REP4
:
588 static const struct regmap_config tas6424_regmap_config
= {
592 .writeable_reg
= tas6424_is_writable_reg
,
593 .volatile_reg
= tas6424_is_volatile_reg
,
595 .max_register
= TAS6424_MAX
,
596 .reg_defaults
= tas6424_reg_defaults
,
597 .num_reg_defaults
= ARRAY_SIZE(tas6424_reg_defaults
),
598 .cache_type
= REGCACHE_RBTREE
,
601 #if IS_ENABLED(CONFIG_OF)
602 static const struct of_device_id tas6424_of_ids
[] = {
603 { .compatible
= "ti,tas6424", },
606 MODULE_DEVICE_TABLE(of
, tas6424_of_ids
);
609 static int tas6424_i2c_probe(struct i2c_client
*client
,
610 const struct i2c_device_id
*id
)
612 struct device
*dev
= &client
->dev
;
613 struct tas6424_data
*tas6424
;
617 tas6424
= devm_kzalloc(dev
, sizeof(*tas6424
), GFP_KERNEL
);
620 dev_set_drvdata(dev
, tas6424
);
624 tas6424
->regmap
= devm_regmap_init_i2c(client
, &tas6424_regmap_config
);
625 if (IS_ERR(tas6424
->regmap
)) {
626 ret
= PTR_ERR(tas6424
->regmap
);
627 dev_err(dev
, "unable to allocate register map: %d\n", ret
);
631 for (i
= 0; i
< ARRAY_SIZE(tas6424
->supplies
); i
++)
632 tas6424
->supplies
[i
].supply
= tas6424_supply_names
[i
];
633 ret
= devm_regulator_bulk_get(dev
, ARRAY_SIZE(tas6424
->supplies
),
636 dev_err(dev
, "unable to request supplies: %d\n", ret
);
640 ret
= regulator_bulk_enable(ARRAY_SIZE(tas6424
->supplies
),
643 dev_err(dev
, "unable to enable supplies: %d\n", ret
);
647 /* Reset device to establish well-defined startup state */
648 ret
= regmap_update_bits(tas6424
->regmap
, TAS6424_MODE_CTRL
,
649 TAS6424_RESET
, TAS6424_RESET
);
651 dev_err(dev
, "unable to reset device: %d\n", ret
);
655 INIT_DELAYED_WORK(&tas6424
->fault_check_work
, tas6424_fault_check_work
);
657 ret
= snd_soc_register_codec(dev
, &soc_codec_dev_tas6424
,
658 tas6424_dai
, ARRAY_SIZE(tas6424_dai
));
660 dev_err(dev
, "unable to register codec: %d\n", ret
);
667 static int tas6424_i2c_remove(struct i2c_client
*client
)
669 struct device
*dev
= &client
->dev
;
670 struct tas6424_data
*tas6424
= dev_get_drvdata(dev
);
673 snd_soc_unregister_codec(dev
);
675 cancel_delayed_work_sync(&tas6424
->fault_check_work
);
677 ret
= regulator_bulk_disable(ARRAY_SIZE(tas6424
->supplies
),
680 dev_err(dev
, "unable to disable supplies: %d\n", ret
);
687 static const struct i2c_device_id tas6424_i2c_ids
[] = {
691 MODULE_DEVICE_TABLE(i2c
, tas6424_i2c_ids
);
693 static struct i2c_driver tas6424_i2c_driver
= {
696 .of_match_table
= of_match_ptr(tas6424_of_ids
),
698 .probe
= tas6424_i2c_probe
,
699 .remove
= tas6424_i2c_remove
,
700 .id_table
= tas6424_i2c_ids
,
702 module_i2c_driver(tas6424_i2c_driver
);
704 MODULE_AUTHOR("Andreas Dannenberg <dannenberg@ti.com>");
705 MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
706 MODULE_DESCRIPTION("TAS6424 Audio amplifier driver");
707 MODULE_LICENSE("GPL v2");