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_component
*component
= snd_soc_dapm_to_component(w
->dapm
);
70 struct tas6424_data
*tas6424
= snd_soc_component_get_drvdata(component
);
72 dev_dbg(component
->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_component
*component
= dai
->component
;
109 unsigned int rate
= params_rate(params
);
110 unsigned int width
= params_width(params
);
113 dev_dbg(component
->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(component
->dev
, "unsupported sample rate: %u\n", rate
);
132 sap_ctrl
|= TAS6424_SAP_TDM_SLOT_SZ_16
;
137 dev_err(component
->dev
, "unsupported sample width: %u\n", width
);
141 snd_soc_component_update_bits(component
, 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_component
*component
= dai
->component
;
152 u8 serial_format
= 0;
154 dev_dbg(component
->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(component
->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(component
->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(component
->dev
, "Invalid DAI interface format\n");
198 snd_soc_component_update_bits(component
, 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_component
*component
= dai
->component
;
209 unsigned int first_slot
, last_slot
;
210 bool sap_tdm_slot_last
;
212 dev_dbg(component
->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(component
->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(component
->dev
, "tdm mask must start at slot 0 or 4\n");
243 snd_soc_component_update_bits(component
, 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_component
*component
= dai
->component
;
254 dev_dbg(component
->dev
, "%s() mute=%d\n", __func__
, mute
);
257 val
= TAS6424_ALL_STATE_MUTE
;
259 val
= TAS6424_ALL_STATE_PLAY
;
261 snd_soc_component_write(component
, TAS6424_CH_STATE_CTRL
, val
);
266 static int tas6424_power_off(struct snd_soc_component
*component
)
268 struct tas6424_data
*tas6424
= snd_soc_component_get_drvdata(component
);
271 snd_soc_component_write(component
, 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(component
->dev
, "failed to disable supplies: %d\n", ret
);
286 static int tas6424_power_on(struct snd_soc_component
*component
)
288 struct tas6424_data
*tas6424
= snd_soc_component_get_drvdata(component
);
291 ret
= regulator_bulk_enable(ARRAY_SIZE(tas6424
->supplies
),
294 dev_err(component
->dev
, "failed to enable supplies: %d\n", ret
);
298 regcache_cache_only(tas6424
->regmap
, false);
300 ret
= regcache_sync(tas6424
->regmap
);
302 dev_err(component
->dev
, "failed to sync regcache: %d\n", ret
);
306 snd_soc_component_write(component
, 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_component
*component
,
317 enum snd_soc_bias_level level
)
319 dev_dbg(component
->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_component_get_bias_level(component
) == SND_SOC_BIAS_OFF
)
327 tas6424_power_on(component
);
329 case SND_SOC_BIAS_OFF
:
330 tas6424_power_off(component
);
337 static struct snd_soc_component_driver soc_codec_dev_tas6424
= {
338 .set_bias_level
= tas6424_set_bias_level
,
339 .controls
= tas6424_snd_controls
,
340 .num_controls
= ARRAY_SIZE(tas6424_snd_controls
),
341 .dapm_widgets
= tas6424_dapm_widgets
,
342 .num_dapm_widgets
= ARRAY_SIZE(tas6424_dapm_widgets
),
343 .dapm_routes
= tas6424_audio_map
,
344 .num_dapm_routes
= ARRAY_SIZE(tas6424_audio_map
),
345 .use_pmdown_time
= 1,
347 .non_legacy_dai_naming
= 1,
350 static struct snd_soc_dai_ops tas6424_speaker_dai_ops
= {
351 .hw_params
= tas6424_hw_params
,
352 .set_fmt
= tas6424_set_dai_fmt
,
353 .set_tdm_slot
= tas6424_set_dai_tdm_slot
,
354 .digital_mute
= tas6424_mute
,
357 static struct snd_soc_dai_driver tas6424_dai
[] = {
359 .name
= "tas6424-amplifier",
361 .stream_name
= "Playback",
364 .rates
= TAS6424_RATES
,
365 .formats
= TAS6424_FORMATS
,
367 .ops
= &tas6424_speaker_dai_ops
,
371 static void tas6424_fault_check_work(struct work_struct
*work
)
373 struct tas6424_data
*tas6424
= container_of(work
, struct tas6424_data
,
374 fault_check_work
.work
);
375 struct device
*dev
= tas6424
->dev
;
379 ret
= regmap_read(tas6424
->regmap
, TAS6424_GLOB_FAULT1
, ®
);
381 dev_err(dev
, "failed to read FAULT1 register: %d\n", ret
);
386 * Ignore any clock faults as there is no clean way to check for them.
387 * We would need to start checking for those faults *after* the SAIF
388 * stream has been setup, and stop checking *before* the stream is
389 * stopped to avoid any false-positives. However there are no
390 * appropriate hooks to monitor these events.
392 reg
&= TAS6424_FAULT_PVDD_OV
|
393 TAS6424_FAULT_VBAT_OV
|
394 TAS6424_FAULT_PVDD_UV
|
395 TAS6424_FAULT_VBAT_UV
;
398 goto check_global_fault2_reg
;
401 * Only flag errors once for a given occurrence. This is needed as
402 * the TAS6424 will take time clearing the fault condition internally
403 * during which we don't want to bombard the system with the same
404 * error message over and over.
406 if ((reg
& TAS6424_FAULT_PVDD_OV
) && !(tas6424
->last_fault1
& TAS6424_FAULT_PVDD_OV
))
407 dev_crit(dev
, "experienced a PVDD overvoltage fault\n");
409 if ((reg
& TAS6424_FAULT_VBAT_OV
) && !(tas6424
->last_fault1
& TAS6424_FAULT_VBAT_OV
))
410 dev_crit(dev
, "experienced a VBAT overvoltage fault\n");
412 if ((reg
& TAS6424_FAULT_PVDD_UV
) && !(tas6424
->last_fault1
& TAS6424_FAULT_PVDD_UV
))
413 dev_crit(dev
, "experienced a PVDD undervoltage fault\n");
415 if ((reg
& TAS6424_FAULT_VBAT_UV
) && !(tas6424
->last_fault1
& TAS6424_FAULT_VBAT_UV
))
416 dev_crit(dev
, "experienced a VBAT undervoltage fault\n");
418 /* Store current fault1 value so we can detect any changes next time */
419 tas6424
->last_fault1
= reg
;
421 check_global_fault2_reg
:
422 ret
= regmap_read(tas6424
->regmap
, TAS6424_GLOB_FAULT2
, ®
);
424 dev_err(dev
, "failed to read FAULT2 register: %d\n", ret
);
428 reg
&= TAS6424_FAULT_OTSD
|
429 TAS6424_FAULT_OTSD_CH1
|
430 TAS6424_FAULT_OTSD_CH2
|
431 TAS6424_FAULT_OTSD_CH3
|
432 TAS6424_FAULT_OTSD_CH4
;
437 if ((reg
& TAS6424_FAULT_OTSD
) && !(tas6424
->last_fault2
& TAS6424_FAULT_OTSD
))
438 dev_crit(dev
, "experienced a global overtemp shutdown\n");
440 if ((reg
& TAS6424_FAULT_OTSD_CH1
) && !(tas6424
->last_fault2
& TAS6424_FAULT_OTSD_CH1
))
441 dev_crit(dev
, "experienced an overtemp shutdown on CH1\n");
443 if ((reg
& TAS6424_FAULT_OTSD_CH2
) && !(tas6424
->last_fault2
& TAS6424_FAULT_OTSD_CH2
))
444 dev_crit(dev
, "experienced an overtemp shutdown on CH2\n");
446 if ((reg
& TAS6424_FAULT_OTSD_CH3
) && !(tas6424
->last_fault2
& TAS6424_FAULT_OTSD_CH3
))
447 dev_crit(dev
, "experienced an overtemp shutdown on CH3\n");
449 if ((reg
& TAS6424_FAULT_OTSD_CH4
) && !(tas6424
->last_fault2
& TAS6424_FAULT_OTSD_CH4
))
450 dev_crit(dev
, "experienced an overtemp shutdown on CH4\n");
452 /* Store current fault2 value so we can detect any changes next time */
453 tas6424
->last_fault2
= reg
;
456 ret
= regmap_read(tas6424
->regmap
, TAS6424_WARN
, ®
);
458 dev_err(dev
, "failed to read WARN register: %d\n", ret
);
462 reg
&= TAS6424_WARN_VDD_UV
|
463 TAS6424_WARN_VDD_POR
|
464 TAS6424_WARN_VDD_OTW
|
465 TAS6424_WARN_VDD_OTW_CH1
|
466 TAS6424_WARN_VDD_OTW_CH2
|
467 TAS6424_WARN_VDD_OTW_CH3
|
468 TAS6424_WARN_VDD_OTW_CH4
;
473 if ((reg
& TAS6424_WARN_VDD_UV
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_UV
))
474 dev_warn(dev
, "experienced a VDD under voltage condition\n");
476 if ((reg
& TAS6424_WARN_VDD_POR
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_POR
))
477 dev_warn(dev
, "experienced a VDD POR condition\n");
479 if ((reg
& TAS6424_WARN_VDD_OTW
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_OTW
))
480 dev_warn(dev
, "experienced a global overtemp warning\n");
482 if ((reg
& TAS6424_WARN_VDD_OTW_CH1
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_OTW_CH1
))
483 dev_warn(dev
, "experienced an overtemp warning on CH1\n");
485 if ((reg
& TAS6424_WARN_VDD_OTW_CH2
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_OTW_CH2
))
486 dev_warn(dev
, "experienced an overtemp warning on CH2\n");
488 if ((reg
& TAS6424_WARN_VDD_OTW_CH3
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_OTW_CH3
))
489 dev_warn(dev
, "experienced an overtemp warning on CH3\n");
491 if ((reg
& TAS6424_WARN_VDD_OTW_CH4
) && !(tas6424
->last_warn
& TAS6424_WARN_VDD_OTW_CH4
))
492 dev_warn(dev
, "experienced an overtemp warning on CH4\n");
494 /* Store current warn value so we can detect any changes next time */
495 tas6424
->last_warn
= reg
;
497 /* Clear any faults by toggling the CLEAR_FAULT control bit */
498 ret
= regmap_write_bits(tas6424
->regmap
, TAS6424_MISC_CTRL3
,
499 TAS6424_CLEAR_FAULT
, TAS6424_CLEAR_FAULT
);
501 dev_err(dev
, "failed to write MISC_CTRL3 register: %d\n", ret
);
503 ret
= regmap_write_bits(tas6424
->regmap
, TAS6424_MISC_CTRL3
,
504 TAS6424_CLEAR_FAULT
, 0);
506 dev_err(dev
, "failed to write MISC_CTRL3 register: %d\n", ret
);
509 /* Schedule the next fault check at the specified interval */
510 schedule_delayed_work(&tas6424
->fault_check_work
,
511 msecs_to_jiffies(TAS6424_FAULT_CHECK_INTERVAL
));
514 static const struct reg_default tas6424_reg_defaults
[] = {
515 { TAS6424_MODE_CTRL
, 0x00 },
516 { TAS6424_MISC_CTRL1
, 0x32 },
517 { TAS6424_MISC_CTRL2
, 0x62 },
518 { TAS6424_SAP_CTRL
, 0x04 },
519 { TAS6424_CH_STATE_CTRL
, 0x55 },
520 { TAS6424_CH1_VOL_CTRL
, 0xcf },
521 { TAS6424_CH2_VOL_CTRL
, 0xcf },
522 { TAS6424_CH3_VOL_CTRL
, 0xcf },
523 { TAS6424_CH4_VOL_CTRL
, 0xcf },
524 { TAS6424_DC_DIAG_CTRL1
, 0x00 },
525 { TAS6424_DC_DIAG_CTRL2
, 0x11 },
526 { TAS6424_DC_DIAG_CTRL3
, 0x11 },
527 { TAS6424_PIN_CTRL
, 0xff },
528 { TAS6424_AC_DIAG_CTRL1
, 0x00 },
529 { TAS6424_MISC_CTRL3
, 0x00 },
530 { TAS6424_CLIP_CTRL
, 0x01 },
531 { TAS6424_CLIP_WINDOW
, 0x14 },
532 { TAS6424_CLIP_WARN
, 0x00 },
533 { TAS6424_CBC_STAT
, 0x00 },
534 { TAS6424_MISC_CTRL4
, 0x40 },
537 static bool tas6424_is_writable_reg(struct device
*dev
, unsigned int reg
)
540 case TAS6424_MODE_CTRL
:
541 case TAS6424_MISC_CTRL1
:
542 case TAS6424_MISC_CTRL2
:
543 case TAS6424_SAP_CTRL
:
544 case TAS6424_CH_STATE_CTRL
:
545 case TAS6424_CH1_VOL_CTRL
:
546 case TAS6424_CH2_VOL_CTRL
:
547 case TAS6424_CH3_VOL_CTRL
:
548 case TAS6424_CH4_VOL_CTRL
:
549 case TAS6424_DC_DIAG_CTRL1
:
550 case TAS6424_DC_DIAG_CTRL2
:
551 case TAS6424_DC_DIAG_CTRL3
:
552 case TAS6424_PIN_CTRL
:
553 case TAS6424_AC_DIAG_CTRL1
:
554 case TAS6424_MISC_CTRL3
:
555 case TAS6424_CLIP_CTRL
:
556 case TAS6424_CLIP_WINDOW
:
557 case TAS6424_CLIP_WARN
:
558 case TAS6424_CBC_STAT
:
559 case TAS6424_MISC_CTRL4
:
566 static bool tas6424_is_volatile_reg(struct device
*dev
, unsigned int reg
)
569 case TAS6424_DC_LOAD_DIAG_REP12
:
570 case TAS6424_DC_LOAD_DIAG_REP34
:
571 case TAS6424_DC_LOAD_DIAG_REPLO
:
572 case TAS6424_CHANNEL_STATE
:
573 case TAS6424_CHANNEL_FAULT
:
574 case TAS6424_GLOB_FAULT1
:
575 case TAS6424_GLOB_FAULT2
:
577 case TAS6424_AC_LOAD_DIAG_REP1
:
578 case TAS6424_AC_LOAD_DIAG_REP2
:
579 case TAS6424_AC_LOAD_DIAG_REP3
:
580 case TAS6424_AC_LOAD_DIAG_REP4
:
587 static const struct regmap_config tas6424_regmap_config
= {
591 .writeable_reg
= tas6424_is_writable_reg
,
592 .volatile_reg
= tas6424_is_volatile_reg
,
594 .max_register
= TAS6424_MAX
,
595 .reg_defaults
= tas6424_reg_defaults
,
596 .num_reg_defaults
= ARRAY_SIZE(tas6424_reg_defaults
),
597 .cache_type
= REGCACHE_RBTREE
,
600 #if IS_ENABLED(CONFIG_OF)
601 static const struct of_device_id tas6424_of_ids
[] = {
602 { .compatible
= "ti,tas6424", },
605 MODULE_DEVICE_TABLE(of
, tas6424_of_ids
);
608 static int tas6424_i2c_probe(struct i2c_client
*client
,
609 const struct i2c_device_id
*id
)
611 struct device
*dev
= &client
->dev
;
612 struct tas6424_data
*tas6424
;
616 tas6424
= devm_kzalloc(dev
, sizeof(*tas6424
), GFP_KERNEL
);
619 dev_set_drvdata(dev
, tas6424
);
623 tas6424
->regmap
= devm_regmap_init_i2c(client
, &tas6424_regmap_config
);
624 if (IS_ERR(tas6424
->regmap
)) {
625 ret
= PTR_ERR(tas6424
->regmap
);
626 dev_err(dev
, "unable to allocate register map: %d\n", ret
);
630 for (i
= 0; i
< ARRAY_SIZE(tas6424
->supplies
); i
++)
631 tas6424
->supplies
[i
].supply
= tas6424_supply_names
[i
];
632 ret
= devm_regulator_bulk_get(dev
, ARRAY_SIZE(tas6424
->supplies
),
635 dev_err(dev
, "unable to request supplies: %d\n", ret
);
639 ret
= regulator_bulk_enable(ARRAY_SIZE(tas6424
->supplies
),
642 dev_err(dev
, "unable to enable supplies: %d\n", ret
);
646 /* Reset device to establish well-defined startup state */
647 ret
= regmap_update_bits(tas6424
->regmap
, TAS6424_MODE_CTRL
,
648 TAS6424_RESET
, TAS6424_RESET
);
650 dev_err(dev
, "unable to reset device: %d\n", ret
);
654 INIT_DELAYED_WORK(&tas6424
->fault_check_work
, tas6424_fault_check_work
);
656 ret
= devm_snd_soc_register_component(dev
, &soc_codec_dev_tas6424
,
657 tas6424_dai
, ARRAY_SIZE(tas6424_dai
));
659 dev_err(dev
, "unable to register codec: %d\n", ret
);
666 static int tas6424_i2c_remove(struct i2c_client
*client
)
668 struct device
*dev
= &client
->dev
;
669 struct tas6424_data
*tas6424
= dev_get_drvdata(dev
);
672 cancel_delayed_work_sync(&tas6424
->fault_check_work
);
674 ret
= regulator_bulk_disable(ARRAY_SIZE(tas6424
->supplies
),
677 dev_err(dev
, "unable to disable supplies: %d\n", ret
);
684 static const struct i2c_device_id tas6424_i2c_ids
[] = {
688 MODULE_DEVICE_TABLE(i2c
, tas6424_i2c_ids
);
690 static struct i2c_driver tas6424_i2c_driver
= {
693 .of_match_table
= of_match_ptr(tas6424_of_ids
),
695 .probe
= tas6424_i2c_probe
,
696 .remove
= tas6424_i2c_remove
,
697 .id_table
= tas6424_i2c_ids
,
699 module_i2c_driver(tas6424_i2c_driver
);
701 MODULE_AUTHOR("Andreas Dannenberg <dannenberg@ti.com>");
702 MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
703 MODULE_DESCRIPTION("TAS6424 Audio amplifier driver");
704 MODULE_LICENSE("GPL v2");