0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/module.h>
0011 #include <linux/errno.h>
0012 #include <linux/device.h>
0013 #include <linux/i2c.h>
0014 #include <linux/pm_runtime.h>
0015 #include <linux/regmap.h>
0016 #include <linux/slab.h>
0017 #include <linux/regulator/consumer.h>
0018 #include <linux/delay.h>
0019
0020 #include <sound/pcm.h>
0021 #include <sound/pcm_params.h>
0022 #include <sound/soc.h>
0023 #include <sound/soc-dapm.h>
0024 #include <sound/tlv.h>
0025
0026 #include "tas5720.h"
0027
0028
0029 #define TAS5720_FAULT_CHECK_INTERVAL 200
0030
0031 enum tas572x_type {
0032 TAS5720,
0033 TAS5722,
0034 };
0035
0036 static const char * const tas5720_supply_names[] = {
0037 "dvdd",
0038 "pvdd",
0039 };
0040
0041 #define TAS5720_NUM_SUPPLIES ARRAY_SIZE(tas5720_supply_names)
0042
0043 struct tas5720_data {
0044 struct snd_soc_component *component;
0045 struct regmap *regmap;
0046 struct i2c_client *tas5720_client;
0047 enum tas572x_type devtype;
0048 struct regulator_bulk_data supplies[TAS5720_NUM_SUPPLIES];
0049 struct delayed_work fault_check_work;
0050 unsigned int last_fault;
0051 };
0052
0053 static int tas5720_hw_params(struct snd_pcm_substream *substream,
0054 struct snd_pcm_hw_params *params,
0055 struct snd_soc_dai *dai)
0056 {
0057 struct snd_soc_component *component = dai->component;
0058 unsigned int rate = params_rate(params);
0059 bool ssz_ds;
0060 int ret;
0061
0062 switch (rate) {
0063 case 44100:
0064 case 48000:
0065 ssz_ds = false;
0066 break;
0067 case 88200:
0068 case 96000:
0069 ssz_ds = true;
0070 break;
0071 default:
0072 dev_err(component->dev, "unsupported sample rate: %u\n", rate);
0073 return -EINVAL;
0074 }
0075
0076 ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG,
0077 TAS5720_SSZ_DS, ssz_ds);
0078 if (ret < 0) {
0079 dev_err(component->dev, "error setting sample rate: %d\n", ret);
0080 return ret;
0081 }
0082
0083 return 0;
0084 }
0085
0086 static int tas5720_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
0087 {
0088 struct snd_soc_component *component = dai->component;
0089 u8 serial_format;
0090 int ret;
0091
0092 if ((fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) != SND_SOC_DAIFMT_CBC_CFC) {
0093 dev_vdbg(component->dev, "DAI clocking invalid\n");
0094 return -EINVAL;
0095 }
0096
0097 switch (fmt & (SND_SOC_DAIFMT_FORMAT_MASK |
0098 SND_SOC_DAIFMT_INV_MASK)) {
0099 case (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF):
0100
0101 serial_format = TAS5720_SAIF_I2S;
0102 break;
0103 case (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF):
0104
0105
0106
0107
0108
0109
0110
0111 serial_format = TAS5720_SAIF_I2S;
0112 break;
0113 case (SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF):
0114
0115
0116
0117
0118
0119
0120 serial_format = TAS5720_SAIF_LEFTJ;
0121 break;
0122 case (SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF):
0123
0124 serial_format = TAS5720_SAIF_LEFTJ;
0125 break;
0126 default:
0127 dev_vdbg(component->dev, "DAI Format is not found\n");
0128 return -EINVAL;
0129 }
0130
0131 ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG,
0132 TAS5720_SAIF_FORMAT_MASK,
0133 serial_format);
0134 if (ret < 0) {
0135 dev_err(component->dev, "error setting SAIF format: %d\n", ret);
0136 return ret;
0137 }
0138
0139 return 0;
0140 }
0141
0142 static int tas5720_set_dai_tdm_slot(struct snd_soc_dai *dai,
0143 unsigned int tx_mask, unsigned int rx_mask,
0144 int slots, int slot_width)
0145 {
0146 struct snd_soc_component *component = dai->component;
0147 struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
0148 unsigned int first_slot;
0149 int ret;
0150
0151 if (!tx_mask) {
0152 dev_err(component->dev, "tx masks must not be 0\n");
0153 return -EINVAL;
0154 }
0155
0156
0157
0158
0159
0160
0161 first_slot = __ffs(tx_mask);
0162
0163 if (first_slot > 7) {
0164 dev_err(component->dev, "slot selection out of bounds (%u)\n",
0165 first_slot);
0166 return -EINVAL;
0167 }
0168
0169
0170 ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG,
0171 TAS5720_TDM_CFG_SRC, TAS5720_TDM_CFG_SRC);
0172 if (ret < 0)
0173 goto error_snd_soc_component_update_bits;
0174
0175
0176 ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL2_REG,
0177 TAS5720_TDM_SLOT_SEL_MASK, first_slot);
0178 if (ret < 0)
0179 goto error_snd_soc_component_update_bits;
0180
0181
0182 switch (tas5720->devtype) {
0183 case TAS5722:
0184 ret = snd_soc_component_update_bits(component, TAS5722_DIGITAL_CTRL2_REG,
0185 TAS5722_TDM_SLOT_16B,
0186 slot_width == 16 ?
0187 TAS5722_TDM_SLOT_16B : 0);
0188 if (ret < 0)
0189 goto error_snd_soc_component_update_bits;
0190 break;
0191 default:
0192 break;
0193 }
0194
0195 return 0;
0196
0197 error_snd_soc_component_update_bits:
0198 dev_err(component->dev, "error configuring TDM mode: %d\n", ret);
0199 return ret;
0200 }
0201
0202 static int tas5720_mute(struct snd_soc_dai *dai, int mute, int direction)
0203 {
0204 struct snd_soc_component *component = dai->component;
0205 int ret;
0206
0207 ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL2_REG,
0208 TAS5720_MUTE, mute ? TAS5720_MUTE : 0);
0209 if (ret < 0) {
0210 dev_err(component->dev, "error (un-)muting device: %d\n", ret);
0211 return ret;
0212 }
0213
0214 return 0;
0215 }
0216
0217 static void tas5720_fault_check_work(struct work_struct *work)
0218 {
0219 struct tas5720_data *tas5720 = container_of(work, struct tas5720_data,
0220 fault_check_work.work);
0221 struct device *dev = tas5720->component->dev;
0222 unsigned int curr_fault;
0223 int ret;
0224
0225 ret = regmap_read(tas5720->regmap, TAS5720_FAULT_REG, &curr_fault);
0226 if (ret < 0) {
0227 dev_err(dev, "failed to read FAULT register: %d\n", ret);
0228 goto out;
0229 }
0230
0231
0232 curr_fault &= TAS5720_OCE | TAS5720_DCE | TAS5720_OTE;
0233
0234
0235
0236
0237
0238
0239
0240 if ((curr_fault & TAS5720_OCE) && !(tas5720->last_fault & TAS5720_OCE))
0241 dev_crit(dev, "experienced an over current hardware fault\n");
0242
0243 if ((curr_fault & TAS5720_DCE) && !(tas5720->last_fault & TAS5720_DCE))
0244 dev_crit(dev, "experienced a DC detection fault\n");
0245
0246 if ((curr_fault & TAS5720_OTE) && !(tas5720->last_fault & TAS5720_OTE))
0247 dev_crit(dev, "experienced an over temperature fault\n");
0248
0249
0250 tas5720->last_fault = curr_fault;
0251
0252 if (!curr_fault)
0253 goto out;
0254
0255
0256
0257
0258
0259
0260
0261 ret = regmap_write_bits(tas5720->regmap, TAS5720_POWER_CTRL_REG,
0262 TAS5720_SDZ, 0);
0263 if (ret < 0)
0264 dev_err(dev, "failed to write POWER_CTRL register: %d\n", ret);
0265
0266 ret = regmap_write_bits(tas5720->regmap, TAS5720_POWER_CTRL_REG,
0267 TAS5720_SDZ, TAS5720_SDZ);
0268 if (ret < 0)
0269 dev_err(dev, "failed to write POWER_CTRL register: %d\n", ret);
0270
0271 out:
0272
0273 schedule_delayed_work(&tas5720->fault_check_work,
0274 msecs_to_jiffies(TAS5720_FAULT_CHECK_INTERVAL));
0275 }
0276
0277 static int tas5720_codec_probe(struct snd_soc_component *component)
0278 {
0279 struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
0280 unsigned int device_id, expected_device_id;
0281 int ret;
0282
0283 tas5720->component = component;
0284
0285 ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies),
0286 tas5720->supplies);
0287 if (ret != 0) {
0288 dev_err(component->dev, "failed to enable supplies: %d\n", ret);
0289 return ret;
0290 }
0291
0292
0293
0294
0295
0296
0297 ret = regmap_read(tas5720->regmap, TAS5720_DEVICE_ID_REG, &device_id);
0298 if (ret < 0) {
0299 dev_err(component->dev, "failed to read device ID register: %d\n",
0300 ret);
0301 goto probe_fail;
0302 }
0303
0304 switch (tas5720->devtype) {
0305 case TAS5720:
0306 expected_device_id = TAS5720_DEVICE_ID;
0307 break;
0308 case TAS5722:
0309 expected_device_id = TAS5722_DEVICE_ID;
0310 break;
0311 default:
0312 dev_err(component->dev, "unexpected private driver data\n");
0313 return -EINVAL;
0314 }
0315
0316 if (device_id != expected_device_id)
0317 dev_warn(component->dev, "wrong device ID. expected: %u read: %u\n",
0318 expected_device_id, device_id);
0319
0320
0321 ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL2_REG,
0322 TAS5720_MUTE, TAS5720_MUTE);
0323 if (ret < 0)
0324 goto error_snd_soc_component_update_bits;
0325
0326
0327
0328
0329
0330
0331
0332 ret = snd_soc_component_update_bits(component, TAS5720_POWER_CTRL_REG,
0333 TAS5720_SDZ, 0);
0334 if (ret < 0)
0335 goto error_snd_soc_component_update_bits;
0336
0337 INIT_DELAYED_WORK(&tas5720->fault_check_work, tas5720_fault_check_work);
0338
0339 return 0;
0340
0341 error_snd_soc_component_update_bits:
0342 dev_err(component->dev, "error configuring device registers: %d\n", ret);
0343
0344 probe_fail:
0345 regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies),
0346 tas5720->supplies);
0347 return ret;
0348 }
0349
0350 static void tas5720_codec_remove(struct snd_soc_component *component)
0351 {
0352 struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
0353 int ret;
0354
0355 cancel_delayed_work_sync(&tas5720->fault_check_work);
0356
0357 ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies),
0358 tas5720->supplies);
0359 if (ret < 0)
0360 dev_err(component->dev, "failed to disable supplies: %d\n", ret);
0361 };
0362
0363 static int tas5720_dac_event(struct snd_soc_dapm_widget *w,
0364 struct snd_kcontrol *kcontrol, int event)
0365 {
0366 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
0367 struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
0368 int ret;
0369
0370 if (event & SND_SOC_DAPM_POST_PMU) {
0371
0372 ret = snd_soc_component_update_bits(component, TAS5720_POWER_CTRL_REG,
0373 TAS5720_SDZ, TAS5720_SDZ);
0374 if (ret < 0) {
0375 dev_err(component->dev, "error waking component: %d\n", ret);
0376 return ret;
0377 }
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387 msleep(25);
0388
0389
0390 tas5720->last_fault = 0;
0391 schedule_delayed_work(&tas5720->fault_check_work,
0392 msecs_to_jiffies(TAS5720_FAULT_CHECK_INTERVAL));
0393 } else if (event & SND_SOC_DAPM_PRE_PMD) {
0394
0395 cancel_delayed_work_sync(&tas5720->fault_check_work);
0396
0397
0398 ret = snd_soc_component_update_bits(component, TAS5720_POWER_CTRL_REG,
0399 TAS5720_SDZ, 0);
0400 if (ret < 0) {
0401 dev_err(component->dev, "error shutting down component: %d\n",
0402 ret);
0403 return ret;
0404 }
0405 }
0406
0407 return 0;
0408 }
0409
0410 #ifdef CONFIG_PM
0411 static int tas5720_suspend(struct snd_soc_component *component)
0412 {
0413 struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
0414 int ret;
0415
0416 regcache_cache_only(tas5720->regmap, true);
0417 regcache_mark_dirty(tas5720->regmap);
0418
0419 ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies),
0420 tas5720->supplies);
0421 if (ret < 0)
0422 dev_err(component->dev, "failed to disable supplies: %d\n", ret);
0423
0424 return ret;
0425 }
0426
0427 static int tas5720_resume(struct snd_soc_component *component)
0428 {
0429 struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
0430 int ret;
0431
0432 ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies),
0433 tas5720->supplies);
0434 if (ret < 0) {
0435 dev_err(component->dev, "failed to enable supplies: %d\n", ret);
0436 return ret;
0437 }
0438
0439 regcache_cache_only(tas5720->regmap, false);
0440
0441 ret = regcache_sync(tas5720->regmap);
0442 if (ret < 0) {
0443 dev_err(component->dev, "failed to sync regcache: %d\n", ret);
0444 return ret;
0445 }
0446
0447 return 0;
0448 }
0449 #else
0450 #define tas5720_suspend NULL
0451 #define tas5720_resume NULL
0452 #endif
0453
0454 static bool tas5720_is_volatile_reg(struct device *dev, unsigned int reg)
0455 {
0456 switch (reg) {
0457 case TAS5720_DEVICE_ID_REG:
0458 case TAS5720_FAULT_REG:
0459 return true;
0460 default:
0461 return false;
0462 }
0463 }
0464
0465 static const struct regmap_config tas5720_regmap_config = {
0466 .reg_bits = 8,
0467 .val_bits = 8,
0468
0469 .max_register = TAS5720_MAX_REG,
0470 .cache_type = REGCACHE_RBTREE,
0471 .volatile_reg = tas5720_is_volatile_reg,
0472 };
0473
0474 static const struct regmap_config tas5722_regmap_config = {
0475 .reg_bits = 8,
0476 .val_bits = 8,
0477
0478 .max_register = TAS5722_MAX_REG,
0479 .cache_type = REGCACHE_RBTREE,
0480 .volatile_reg = tas5720_is_volatile_reg,
0481 };
0482
0483
0484
0485
0486
0487 static const DECLARE_TLV_DB_RANGE(dac_analog_tlv,
0488 0x0, 0x0, TLV_DB_SCALE_ITEM(1920, 0, 0),
0489 0x1, 0x1, TLV_DB_SCALE_ITEM(2070, 0, 0),
0490 0x2, 0x2, TLV_DB_SCALE_ITEM(2350, 0, 0),
0491 0x3, 0x3, TLV_DB_SCALE_ITEM(2630, 0, 0),
0492 );
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502 static DECLARE_TLV_DB_SCALE(tas5720_dac_tlv, -10350, 50, 0);
0503 static DECLARE_TLV_DB_SCALE(tas5722_dac_tlv, -10350, 25, 0);
0504
0505 static int tas5722_volume_get(struct snd_kcontrol *kcontrol,
0506 struct snd_ctl_elem_value *ucontrol)
0507 {
0508 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
0509 unsigned int val;
0510
0511 val = snd_soc_component_read(component, TAS5720_VOLUME_CTRL_REG);
0512 ucontrol->value.integer.value[0] = val << 1;
0513
0514 val = snd_soc_component_read(component, TAS5722_DIGITAL_CTRL2_REG);
0515 ucontrol->value.integer.value[0] |= val & TAS5722_VOL_CONTROL_LSB;
0516
0517 return 0;
0518 }
0519
0520 static int tas5722_volume_set(struct snd_kcontrol *kcontrol,
0521 struct snd_ctl_elem_value *ucontrol)
0522 {
0523 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
0524 unsigned int sel = ucontrol->value.integer.value[0];
0525
0526 snd_soc_component_write(component, TAS5720_VOLUME_CTRL_REG, sel >> 1);
0527 snd_soc_component_update_bits(component, TAS5722_DIGITAL_CTRL2_REG,
0528 TAS5722_VOL_CONTROL_LSB, sel);
0529
0530 return 0;
0531 }
0532
0533 static const struct snd_kcontrol_new tas5720_snd_controls[] = {
0534 SOC_SINGLE_TLV("Speaker Driver Playback Volume",
0535 TAS5720_VOLUME_CTRL_REG, 0, 0xff, 0, tas5720_dac_tlv),
0536 SOC_SINGLE_TLV("Speaker Driver Analog Gain", TAS5720_ANALOG_CTRL_REG,
0537 TAS5720_ANALOG_GAIN_SHIFT, 3, 0, dac_analog_tlv),
0538 };
0539
0540 static const struct snd_kcontrol_new tas5722_snd_controls[] = {
0541 SOC_SINGLE_EXT_TLV("Speaker Driver Playback Volume",
0542 0, 0, 511, 0,
0543 tas5722_volume_get, tas5722_volume_set,
0544 tas5722_dac_tlv),
0545 SOC_SINGLE_TLV("Speaker Driver Analog Gain", TAS5720_ANALOG_CTRL_REG,
0546 TAS5720_ANALOG_GAIN_SHIFT, 3, 0, dac_analog_tlv),
0547 };
0548
0549 static const struct snd_soc_dapm_widget tas5720_dapm_widgets[] = {
0550 SND_SOC_DAPM_AIF_IN("DAC IN", "Playback", 0, SND_SOC_NOPM, 0, 0),
0551 SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0, tas5720_dac_event,
0552 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
0553 SND_SOC_DAPM_OUTPUT("OUT")
0554 };
0555
0556 static const struct snd_soc_dapm_route tas5720_audio_map[] = {
0557 { "DAC", NULL, "DAC IN" },
0558 { "OUT", NULL, "DAC" },
0559 };
0560
0561 static const struct snd_soc_component_driver soc_component_dev_tas5720 = {
0562 .probe = tas5720_codec_probe,
0563 .remove = tas5720_codec_remove,
0564 .suspend = tas5720_suspend,
0565 .resume = tas5720_resume,
0566 .controls = tas5720_snd_controls,
0567 .num_controls = ARRAY_SIZE(tas5720_snd_controls),
0568 .dapm_widgets = tas5720_dapm_widgets,
0569 .num_dapm_widgets = ARRAY_SIZE(tas5720_dapm_widgets),
0570 .dapm_routes = tas5720_audio_map,
0571 .num_dapm_routes = ARRAY_SIZE(tas5720_audio_map),
0572 .idle_bias_on = 1,
0573 .use_pmdown_time = 1,
0574 .endianness = 1,
0575 };
0576
0577 static const struct snd_soc_component_driver soc_component_dev_tas5722 = {
0578 .probe = tas5720_codec_probe,
0579 .remove = tas5720_codec_remove,
0580 .suspend = tas5720_suspend,
0581 .resume = tas5720_resume,
0582 .controls = tas5722_snd_controls,
0583 .num_controls = ARRAY_SIZE(tas5722_snd_controls),
0584 .dapm_widgets = tas5720_dapm_widgets,
0585 .num_dapm_widgets = ARRAY_SIZE(tas5720_dapm_widgets),
0586 .dapm_routes = tas5720_audio_map,
0587 .num_dapm_routes = ARRAY_SIZE(tas5720_audio_map),
0588 .idle_bias_on = 1,
0589 .use_pmdown_time = 1,
0590 .endianness = 1,
0591 };
0592
0593
0594 #define TAS5720_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
0595 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
0596
0597
0598 #define TAS5720_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE |\
0599 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE)
0600
0601 static const struct snd_soc_dai_ops tas5720_speaker_dai_ops = {
0602 .hw_params = tas5720_hw_params,
0603 .set_fmt = tas5720_set_dai_fmt,
0604 .set_tdm_slot = tas5720_set_dai_tdm_slot,
0605 .mute_stream = tas5720_mute,
0606 .no_capture_mute = 1,
0607 };
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620 static struct snd_soc_dai_driver tas5720_dai[] = {
0621 {
0622 .name = "tas5720-amplifier",
0623 .playback = {
0624 .stream_name = "Playback",
0625 .channels_min = 1,
0626 .channels_max = 2,
0627 .rates = TAS5720_RATES,
0628 .formats = TAS5720_FORMATS,
0629 },
0630 .ops = &tas5720_speaker_dai_ops,
0631 },
0632 };
0633
0634 static const struct i2c_device_id tas5720_id[] = {
0635 { "tas5720", TAS5720 },
0636 { "tas5722", TAS5722 },
0637 { }
0638 };
0639 MODULE_DEVICE_TABLE(i2c, tas5720_id);
0640
0641 static int tas5720_probe(struct i2c_client *client)
0642 {
0643 struct device *dev = &client->dev;
0644 struct tas5720_data *data;
0645 const struct regmap_config *regmap_config;
0646 const struct i2c_device_id *id;
0647 int ret;
0648 int i;
0649
0650 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
0651 if (!data)
0652 return -ENOMEM;
0653
0654 id = i2c_match_id(tas5720_id, client);
0655 data->tas5720_client = client;
0656 data->devtype = id->driver_data;
0657
0658 switch (id->driver_data) {
0659 case TAS5720:
0660 regmap_config = &tas5720_regmap_config;
0661 break;
0662 case TAS5722:
0663 regmap_config = &tas5722_regmap_config;
0664 break;
0665 default:
0666 dev_err(dev, "unexpected private driver data\n");
0667 return -EINVAL;
0668 }
0669 data->regmap = devm_regmap_init_i2c(client, regmap_config);
0670 if (IS_ERR(data->regmap)) {
0671 ret = PTR_ERR(data->regmap);
0672 dev_err(dev, "failed to allocate register map: %d\n", ret);
0673 return ret;
0674 }
0675
0676 for (i = 0; i < ARRAY_SIZE(data->supplies); i++)
0677 data->supplies[i].supply = tas5720_supply_names[i];
0678
0679 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies),
0680 data->supplies);
0681 if (ret != 0) {
0682 dev_err(dev, "failed to request supplies: %d\n", ret);
0683 return ret;
0684 }
0685
0686 dev_set_drvdata(dev, data);
0687
0688 switch (id->driver_data) {
0689 case TAS5720:
0690 ret = devm_snd_soc_register_component(&client->dev,
0691 &soc_component_dev_tas5720,
0692 tas5720_dai,
0693 ARRAY_SIZE(tas5720_dai));
0694 break;
0695 case TAS5722:
0696 ret = devm_snd_soc_register_component(&client->dev,
0697 &soc_component_dev_tas5722,
0698 tas5720_dai,
0699 ARRAY_SIZE(tas5720_dai));
0700 break;
0701 default:
0702 dev_err(dev, "unexpected private driver data\n");
0703 return -EINVAL;
0704 }
0705 if (ret < 0) {
0706 dev_err(dev, "failed to register component: %d\n", ret);
0707 return ret;
0708 }
0709
0710 return 0;
0711 }
0712
0713 #if IS_ENABLED(CONFIG_OF)
0714 static const struct of_device_id tas5720_of_match[] = {
0715 { .compatible = "ti,tas5720", },
0716 { .compatible = "ti,tas5722", },
0717 { },
0718 };
0719 MODULE_DEVICE_TABLE(of, tas5720_of_match);
0720 #endif
0721
0722 static struct i2c_driver tas5720_i2c_driver = {
0723 .driver = {
0724 .name = "tas5720",
0725 .of_match_table = of_match_ptr(tas5720_of_match),
0726 },
0727 .probe_new = tas5720_probe,
0728 .id_table = tas5720_id,
0729 };
0730
0731 module_i2c_driver(tas5720_i2c_driver);
0732
0733 MODULE_AUTHOR("Andreas Dannenberg <dannenberg@ti.com>");
0734 MODULE_DESCRIPTION("TAS5720 Audio amplifier driver");
0735 MODULE_LICENSE("GPL");