1 // SPDX-License-Identifier: GPL-2.0 2 // Driver for the Texas Instruments TAS2780 Mono 3 // Audio amplifier 4 // Copyright (C) 2022 Texas Instruments Inc. 5 6 #include <linux/module.h> 7 #include <linux/err.h> 8 #include <linux/pm.h> 9 #include <linux/i2c.h> 10 #include <linux/gpio.h> 11 #include <linux/gpio/consumer.h> 12 #include <linux/regmap.h> 13 #include <linux/of.h> 14 #include <linux/of_gpio.h> 15 #include <sound/soc.h> 16 #include <sound/pcm.h> 17 #include <sound/pcm_params.h> 18 #include <sound/tlv.h> 19 20 #include "tas2780.h" 21 22 struct tas2780_priv { 23 struct snd_soc_component *component; 24 struct gpio_desc *reset_gpio; 25 struct regmap *regmap; 26 struct device *dev; 27 int v_sense_slot; 28 int i_sense_slot; 29 }; 30 31 static void tas2780_reset(struct tas2780_priv *tas2780) 32 { 33 int ret = 0; 34 35 if (tas2780->reset_gpio) { 36 gpiod_set_value_cansleep(tas2780->reset_gpio, 0); 37 usleep_range(2000, 2050); 38 gpiod_set_value_cansleep(tas2780->reset_gpio, 1); 39 usleep_range(2000, 2050); 40 } 41 42 ret = snd_soc_component_write(tas2780->component, TAS2780_SW_RST, 43 TAS2780_RST); 44 if (ret) 45 dev_err(tas2780->dev, "%s:errCode:0x%x Reset error!\n", 46 __func__, ret); 47 } 48 49 #ifdef CONFIG_PM 50 static int tas2780_codec_suspend(struct snd_soc_component *component) 51 { 52 struct tas2780_priv *tas2780 = 53 snd_soc_component_get_drvdata(component); 54 int ret = 0; 55 56 ret = snd_soc_component_update_bits(component, TAS2780_PWR_CTRL, 57 TAS2780_PWR_CTRL_MASK, TAS2780_PWR_CTRL_SHUTDOWN); 58 if (ret < 0) { 59 dev_err(tas2780->dev, "%s:errCode:0x%0x:power down error\n", 60 __func__, ret); 61 goto err; 62 } 63 ret = 0; 64 regcache_cache_only(tas2780->regmap, true); 65 regcache_mark_dirty(tas2780->regmap); 66 err: 67 return ret; 68 } 69 70 static int tas2780_codec_resume(struct snd_soc_component *component) 71 { 72 struct tas2780_priv *tas2780 = 73 snd_soc_component_get_drvdata(component); 74 int ret; 75 76 ret = snd_soc_component_update_bits(component, TAS2780_PWR_CTRL, 77 TAS2780_PWR_CTRL_MASK, TAS2780_PWR_CTRL_ACTIVE); 78 79 if (ret < 0) { 80 dev_err(tas2780->dev, "%s:errCode:0x%0x:power down error\n", 81 __func__, ret); 82 goto err; 83 } 84 regcache_cache_only(tas2780->regmap, false); 85 ret = regcache_sync(tas2780->regmap); 86 err: 87 return ret; 88 } 89 #endif 90 91 static const char * const tas2780_ASI1_src[] = { 92 "I2C offset", "Left", "Right", "LeftRightDiv2", 93 }; 94 95 static SOC_ENUM_SINGLE_DECL( 96 tas2780_ASI1_src_enum, TAS2780_TDM_CFG2, 4, tas2780_ASI1_src); 97 98 static const struct snd_kcontrol_new tas2780_asi1_mux = 99 SOC_DAPM_ENUM("ASI1 Source", tas2780_ASI1_src_enum); 100 101 static const struct snd_kcontrol_new isense_switch = 102 SOC_DAPM_SINGLE("Switch", TAS2780_PWR_CTRL, 103 TAS2780_ISENSE_POWER_EN, 1, 1); 104 static const struct snd_kcontrol_new vsense_switch = 105 SOC_DAPM_SINGLE("Switch", TAS2780_PWR_CTRL, 106 TAS2780_VSENSE_POWER_EN, 1, 1); 107 108 static const struct snd_soc_dapm_widget tas2780_dapm_widgets[] = { 109 SND_SOC_DAPM_AIF_IN("ASI1", "ASI1 Playback", 0, SND_SOC_NOPM, 0, 0), 110 SND_SOC_DAPM_MUX("ASI1 Sel", SND_SOC_NOPM, 0, 0, &tas2780_asi1_mux), 111 SND_SOC_DAPM_SWITCH("ISENSE", TAS2780_PWR_CTRL, 112 TAS2780_ISENSE_POWER_EN, 1, &isense_switch), 113 SND_SOC_DAPM_SWITCH("VSENSE", TAS2780_PWR_CTRL, 114 TAS2780_VSENSE_POWER_EN, 1, &vsense_switch), 115 SND_SOC_DAPM_OUTPUT("OUT"), 116 SND_SOC_DAPM_SIGGEN("VMON"), 117 SND_SOC_DAPM_SIGGEN("IMON") 118 }; 119 120 static const struct snd_soc_dapm_route tas2780_audio_map[] = { 121 {"ASI1 Sel", "I2C offset", "ASI1"}, 122 {"ASI1 Sel", "Left", "ASI1"}, 123 {"ASI1 Sel", "Right", "ASI1"}, 124 {"ASI1 Sel", "LeftRightDiv2", "ASI1"}, 125 {"OUT", NULL, "ASI1 Sel"}, 126 {"ISENSE", "Switch", "IMON"}, 127 {"VSENSE", "Switch", "VMON"}, 128 }; 129 130 static int tas2780_mute(struct snd_soc_dai *dai, int mute, int direction) 131 { 132 struct snd_soc_component *component = dai->component; 133 struct tas2780_priv *tas2780 = 134 snd_soc_component_get_drvdata(component); 135 int ret = 0; 136 137 ret = snd_soc_component_update_bits(component, TAS2780_PWR_CTRL, 138 TAS2780_PWR_CTRL_MASK, 139 mute ? TAS2780_PWR_CTRL_MUTE : 0); 140 if (ret < 0) { 141 dev_err(tas2780->dev, "%s: Failed to set powercontrol\n", 142 __func__); 143 goto err; 144 } 145 ret = 0; 146 err: 147 return ret; 148 } 149 150 static int tas2780_set_bitwidth(struct tas2780_priv *tas2780, int bitwidth) 151 { 152 struct snd_soc_component *component = tas2780->component; 153 int sense_en; 154 int val; 155 int ret; 156 int slot_size; 157 158 switch (bitwidth) { 159 case SNDRV_PCM_FORMAT_S16_LE: 160 ret = snd_soc_component_update_bits(component, 161 TAS2780_TDM_CFG2, 162 TAS2780_TDM_CFG2_RXW_MASK, 163 TAS2780_TDM_CFG2_RXW_16BITS); 164 slot_size = TAS2780_TDM_CFG2_RXS_16BITS; 165 break; 166 case SNDRV_PCM_FORMAT_S24_LE: 167 ret = snd_soc_component_update_bits(component, 168 TAS2780_TDM_CFG2, 169 TAS2780_TDM_CFG2_RXW_MASK, 170 TAS2780_TDM_CFG2_RXW_24BITS); 171 slot_size = TAS2780_TDM_CFG2_RXS_24BITS; 172 break; 173 case SNDRV_PCM_FORMAT_S32_LE: 174 ret = snd_soc_component_update_bits(component, 175 TAS2780_TDM_CFG2, 176 TAS2780_TDM_CFG2_RXW_MASK, 177 TAS2780_TDM_CFG2_RXW_32BITS); 178 slot_size = TAS2780_TDM_CFG2_RXS_32BITS; 179 break; 180 181 default: 182 ret = -EINVAL; 183 } 184 185 if (ret < 0) { 186 dev_err(tas2780->dev, "%s:errCode:0x%x set bitwidth error\n", 187 __func__, ret); 188 goto err; 189 } 190 191 ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG2, 192 TAS2780_TDM_CFG2_RXS_MASK, slot_size); 193 if (ret < 0) { 194 dev_err(tas2780->dev, 195 "%s:errCode:0x%x set RX slot size error\n", 196 __func__, ret); 197 goto err; 198 } 199 200 val = snd_soc_component_read(tas2780->component, TAS2780_PWR_CTRL); 201 if (val < 0) { 202 dev_err(tas2780->dev, "%s:errCode:0x%x read PWR_CTRL error\n", 203 __func__, val); 204 ret = val; 205 goto err; 206 } 207 208 if (val & (1 << TAS2780_VSENSE_POWER_EN)) 209 sense_en = 0; 210 else 211 sense_en = TAS2780_TDM_CFG5_VSNS_ENABLE; 212 213 ret = snd_soc_component_update_bits(tas2780->component, 214 TAS2780_TDM_CFG5, TAS2780_TDM_CFG5_VSNS_ENABLE, sense_en); 215 if (ret < 0) { 216 dev_err(tas2780->dev, "%s:errCode:0x%x enable vSNS error\n", 217 __func__, ret); 218 goto err; 219 } 220 221 if (val & (1 << TAS2780_ISENSE_POWER_EN)) 222 sense_en = 0; 223 else 224 sense_en = TAS2780_TDM_CFG6_ISNS_ENABLE; 225 226 ret = snd_soc_component_update_bits(tas2780->component, 227 TAS2780_TDM_CFG6, TAS2780_TDM_CFG6_ISNS_ENABLE, sense_en); 228 if (ret < 0) { 229 dev_err(tas2780->dev, "%s:errCode:0x%x enable iSNS error\n", 230 __func__, ret); 231 goto err; 232 } 233 ret = 0; 234 err: 235 return ret; 236 } 237 238 static int tas2780_set_samplerate( 239 struct tas2780_priv *tas2780, int samplerate) 240 { 241 struct snd_soc_component *component = tas2780->component; 242 int ramp_rate_val; 243 int ret; 244 245 switch (samplerate) { 246 case 48000: 247 ramp_rate_val = TAS2780_TDM_CFG0_SMP_48KHZ | 248 TAS2780_TDM_CFG0_44_1_48KHZ; 249 break; 250 case 44100: 251 ramp_rate_val = TAS2780_TDM_CFG0_SMP_44_1KHZ | 252 TAS2780_TDM_CFG0_44_1_48KHZ; 253 break; 254 case 96000: 255 ramp_rate_val = TAS2780_TDM_CFG0_SMP_48KHZ | 256 TAS2780_TDM_CFG0_88_2_96KHZ; 257 break; 258 case 88200: 259 ramp_rate_val = TAS2780_TDM_CFG0_SMP_44_1KHZ | 260 TAS2780_TDM_CFG0_88_2_96KHZ; 261 break; 262 default: 263 return -EINVAL; 264 } 265 ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG0, 266 TAS2780_TDM_CFG0_SMP_MASK | TAS2780_TDM_CFG0_MASK, 267 ramp_rate_val); 268 if (ret < 0) { 269 dev_err(tas2780->dev, 270 "%s:errCode:0x%x Failed to set ramp_rate_val\n", 271 __func__, ret); 272 goto err; 273 } 274 ret = 0; 275 err: 276 return ret; 277 } 278 279 static int tas2780_hw_params(struct snd_pcm_substream *substream, 280 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 281 { 282 struct snd_soc_component *component = dai->component; 283 struct tas2780_priv *tas2780 = 284 snd_soc_component_get_drvdata(component); 285 int ret; 286 287 ret = tas2780_set_bitwidth(tas2780, params_format(params)); 288 if (ret < 0) 289 return ret; 290 291 return tas2780_set_samplerate(tas2780, params_rate(params)); 292 } 293 294 static int tas2780_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 295 { 296 struct snd_soc_component *component = dai->component; 297 struct tas2780_priv *tas2780 = 298 snd_soc_component_get_drvdata(component); 299 u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0; 300 int iface; 301 int ret = 0; 302 303 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 304 case SND_SOC_DAIFMT_NB_NF: 305 asi_cfg_1 = TAS2780_TDM_CFG1_RX_RISING; 306 break; 307 case SND_SOC_DAIFMT_IB_NF: 308 asi_cfg_1 = TAS2780_TDM_CFG1_RX_FALLING; 309 break; 310 default: 311 dev_err(tas2780->dev, "ASI format Inverse is not found\n"); 312 return -EINVAL; 313 } 314 315 ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG1, 316 TAS2780_TDM_CFG1_RX_MASK, asi_cfg_1); 317 if (ret < 0) { 318 dev_err(tas2780->dev, 319 "%s:errCode:0x%x Failed to set asi_cfg_1\n", 320 __func__, ret); 321 goto err; 322 } 323 324 if (((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S) 325 || ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) 326 == SND_SOC_DAIFMT_DSP_A)){ 327 iface = TAS2780_TDM_CFG2_SCFG_I2S; 328 tdm_rx_start_slot = 1; 329 } else { 330 if (((fmt & SND_SOC_DAIFMT_FORMAT_MASK) 331 == SND_SOC_DAIFMT_DSP_B) 332 || ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) 333 == SND_SOC_DAIFMT_LEFT_J)) { 334 iface = TAS2780_TDM_CFG2_SCFG_LEFT_J; 335 tdm_rx_start_slot = 0; 336 } else { 337 dev_err(tas2780->dev, 338 "%s:DAI Format is not found, fmt=0x%x\n", 339 __func__, fmt); 340 ret = -EINVAL; 341 goto err; 342 } 343 } 344 ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG1, 345 TAS2780_TDM_CFG1_MASK, 346 (tdm_rx_start_slot << TAS2780_TDM_CFG1_51_SHIFT)); 347 if (ret < 0) { 348 dev_err(tas2780->dev, 349 "%s:errCode:0x%x Failed to set tdm_rx_start_slot\n", 350 __func__, ret); 351 goto err; 352 } 353 354 ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG2, 355 TAS2780_TDM_CFG2_SCFG_MASK, iface); 356 if (ret < 0) { 357 dev_err(tas2780->dev, "%s:errCode:0x%x Failed to set iface\n", 358 __func__, ret); 359 goto err; 360 } 361 ret = 0; 362 err: 363 return ret; 364 } 365 366 static int tas2780_set_dai_tdm_slot(struct snd_soc_dai *dai, 367 unsigned int tx_mask, 368 unsigned int rx_mask, 369 int slots, int slot_width) 370 { 371 struct snd_soc_component *component = dai->component; 372 struct tas2780_priv *tas2780 = 373 snd_soc_component_get_drvdata(component); 374 int left_slot, right_slot; 375 int slots_cfg; 376 int slot_size; 377 int ret = 0; 378 379 if (tx_mask == 0 || rx_mask != 0) 380 return -EINVAL; 381 382 left_slot = __ffs(tx_mask); 383 tx_mask &= ~(1 << left_slot); 384 if (tx_mask == 0) { 385 right_slot = left_slot; 386 } else { 387 right_slot = __ffs(tx_mask); 388 tx_mask &= ~(1 << right_slot); 389 } 390 391 if (tx_mask != 0 || left_slot >= slots || right_slot >= slots) 392 return -EINVAL; 393 394 slots_cfg = (right_slot << TAS2780_TDM_CFG3_RXS_SHIFT) | left_slot; 395 ret = snd_soc_component_write(component, TAS2780_TDM_CFG3, slots_cfg); 396 if (ret) { 397 dev_err(tas2780->dev, 398 "%s:errCode:0x%x Failed to set slots_cfg\n", 399 __func__, ret); 400 goto err; 401 } 402 403 switch (slot_width) { 404 case 16: 405 slot_size = TAS2780_TDM_CFG2_RXS_16BITS; 406 break; 407 case 24: 408 slot_size = TAS2780_TDM_CFG2_RXS_24BITS; 409 break; 410 case 32: 411 slot_size = TAS2780_TDM_CFG2_RXS_32BITS; 412 break; 413 default: 414 ret = -EINVAL; 415 goto err; 416 } 417 418 ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG2, 419 TAS2780_TDM_CFG2_RXS_MASK, slot_size); 420 if (ret < 0) { 421 dev_err(tas2780->dev, 422 "%s:errCode:0x%x Failed to set slot_size\n", 423 __func__, ret); 424 goto err; 425 } 426 427 ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG5, 428 TAS2780_TDM_CFG5_50_MASK, tas2780->v_sense_slot); 429 if (ret < 0) { 430 dev_err(tas2780->dev, 431 "%s:errCode:0x%x Failed to set v_sense_slot\n", 432 __func__, ret); 433 goto err; 434 } 435 436 ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG6, 437 TAS2780_TDM_CFG6_50_MASK, tas2780->i_sense_slot); 438 if (ret < 0) { 439 dev_err(tas2780->dev, 440 "%s:errCode:0x%x Failed to set i_sense_slot\n", 441 __func__, ret); 442 goto err; 443 } 444 ret = 0; 445 err: 446 return ret; 447 } 448 449 static const struct snd_soc_dai_ops tas2780_dai_ops = { 450 .mute_stream = tas2780_mute, 451 .hw_params = tas2780_hw_params, 452 .set_fmt = tas2780_set_fmt, 453 .set_tdm_slot = tas2780_set_dai_tdm_slot, 454 .no_capture_mute = 1, 455 }; 456 457 #define TAS2780_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 458 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 459 460 #define TAS2780_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\ 461 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_88200) 462 463 static struct snd_soc_dai_driver tas2780_dai_driver[] = { 464 { 465 .name = "tas2780 ASI1", 466 .id = 0, 467 .playback = { 468 .stream_name = "ASI1 Playback", 469 .channels_min = 2, 470 .channels_max = 2, 471 .rates = TAS2780_RATES, 472 .formats = TAS2780_FORMATS, 473 }, 474 .capture = { 475 .stream_name = "ASI1 Capture", 476 .channels_min = 1, 477 .channels_max = 2, 478 .rates = TAS2780_RATES, 479 .formats = TAS2780_FORMATS, 480 }, 481 .ops = &tas2780_dai_ops, 482 .symmetric_rate = 1, 483 }, 484 }; 485 486 static int tas2780_codec_probe(struct snd_soc_component *component) 487 { 488 struct tas2780_priv *tas2780 = 489 snd_soc_component_get_drvdata(component); 490 int ret = 0; 491 492 tas2780->component = component; 493 494 tas2780_reset(tas2780); 495 ret = snd_soc_component_update_bits(component, 496 TAS2780_IC_CFG, TAS2780_IC_CFG_MASK, 497 TAS2780_IC_CFG_ENABLE); 498 if (ret < 0) 499 dev_err(tas2780->dev, "%s:errCode:0x%0x\n", 500 __func__, ret); 501 502 return ret; 503 } 504 505 static DECLARE_TLV_DB_SCALE(tas2780_digital_tlv, 1100, 50, 0); 506 static DECLARE_TLV_DB_SCALE(tas2780_playback_volume, -10000, 50, 0); 507 508 static const struct snd_kcontrol_new tas2780_snd_controls[] = { 509 SOC_SINGLE_TLV("Speaker Volume", TAS2780_DVC, 0, 510 TAS2780_DVC_MAX, 1, tas2780_playback_volume), 511 SOC_SINGLE_TLV("Amp Gain Volume", TAS2780_CHNL_0, 0, 0x14, 0, 512 tas2780_digital_tlv), 513 }; 514 515 static const struct snd_soc_component_driver soc_component_driver_tas2780 = { 516 .probe = tas2780_codec_probe, 517 #ifdef CONFIG_PM 518 .suspend = tas2780_codec_suspend, 519 .resume = tas2780_codec_resume, 520 #endif 521 .controls = tas2780_snd_controls, 522 .num_controls = ARRAY_SIZE(tas2780_snd_controls), 523 .dapm_widgets = tas2780_dapm_widgets, 524 .num_dapm_widgets = ARRAY_SIZE(tas2780_dapm_widgets), 525 .dapm_routes = tas2780_audio_map, 526 .num_dapm_routes = ARRAY_SIZE(tas2780_audio_map), 527 .idle_bias_on = 1, 528 .endianness = 1, 529 }; 530 531 static const struct reg_default tas2780_reg_defaults[] = { 532 { TAS2780_PAGE, 0x00 }, 533 { TAS2780_SW_RST, 0x00 }, 534 { TAS2780_PWR_CTRL, 0x1a }, 535 { TAS2780_DVC, 0x00 }, 536 { TAS2780_CHNL_0, 0x00 }, 537 { TAS2780_TDM_CFG0, 0x09 }, 538 { TAS2780_TDM_CFG1, 0x02 }, 539 { TAS2780_TDM_CFG2, 0x0a }, 540 { TAS2780_TDM_CFG3, 0x10 }, 541 { TAS2780_TDM_CFG5, 0x42 }, 542 }; 543 544 static const struct regmap_range_cfg tas2780_regmap_ranges[] = { 545 { 546 .range_min = 0, 547 .range_max = 1 * 128, 548 .selector_reg = TAS2780_PAGE, 549 .selector_mask = 0xff, 550 .selector_shift = 0, 551 .window_start = 0, 552 .window_len = 128, 553 }, 554 }; 555 556 static const struct regmap_config tas2780_i2c_regmap = { 557 .reg_bits = 8, 558 .val_bits = 8, 559 .reg_defaults = tas2780_reg_defaults, 560 .num_reg_defaults = ARRAY_SIZE(tas2780_reg_defaults), 561 .cache_type = REGCACHE_RBTREE, 562 .ranges = tas2780_regmap_ranges, 563 .num_ranges = ARRAY_SIZE(tas2780_regmap_ranges), 564 .max_register = 1 * 128, 565 }; 566 567 static int tas2780_parse_dt(struct device *dev, struct tas2780_priv *tas2780) 568 { 569 int ret = 0; 570 571 tas2780->reset_gpio = devm_gpiod_get_optional(tas2780->dev, "reset", 572 GPIOD_OUT_HIGH); 573 if (IS_ERR(tas2780->reset_gpio)) { 574 if (PTR_ERR(tas2780->reset_gpio) == -EPROBE_DEFER) { 575 tas2780->reset_gpio = NULL; 576 return -EPROBE_DEFER; 577 } 578 } 579 580 ret = fwnode_property_read_u32(dev->fwnode, "ti,imon-slot-no", 581 &tas2780->i_sense_slot); 582 if (ret) 583 tas2780->i_sense_slot = 0; 584 585 ret = fwnode_property_read_u32(dev->fwnode, "ti,vmon-slot-no", 586 &tas2780->v_sense_slot); 587 if (ret) 588 tas2780->v_sense_slot = 2; 589 590 return 0; 591 } 592 593 static int tas2780_i2c_probe(struct i2c_client *client) 594 { 595 struct tas2780_priv *tas2780; 596 int result; 597 598 tas2780 = devm_kzalloc(&client->dev, sizeof(struct tas2780_priv), 599 GFP_KERNEL); 600 if (!tas2780) 601 return -ENOMEM; 602 tas2780->dev = &client->dev; 603 i2c_set_clientdata(client, tas2780); 604 dev_set_drvdata(&client->dev, tas2780); 605 606 tas2780->regmap = devm_regmap_init_i2c(client, &tas2780_i2c_regmap); 607 if (IS_ERR(tas2780->regmap)) { 608 result = PTR_ERR(tas2780->regmap); 609 dev_err(&client->dev, "Failed to allocate register map: %d\n", 610 result); 611 return result; 612 } 613 614 if (client->dev.of_node) { 615 result = tas2780_parse_dt(&client->dev, tas2780); 616 if (result) { 617 dev_err(tas2780->dev, 618 "%s: Failed to parse devicetree\n", __func__); 619 return result; 620 } 621 } 622 623 return devm_snd_soc_register_component(tas2780->dev, 624 &soc_component_driver_tas2780, tas2780_dai_driver, 625 ARRAY_SIZE(tas2780_dai_driver)); 626 } 627 628 static const struct i2c_device_id tas2780_i2c_id[] = { 629 { "tas2780", 0}, 630 { } 631 }; 632 MODULE_DEVICE_TABLE(i2c, tas2780_i2c_id); 633 634 #if defined(CONFIG_OF) 635 static const struct of_device_id tas2780_of_match[] = { 636 { .compatible = "ti,tas2780" }, 637 {}, 638 }; 639 MODULE_DEVICE_TABLE(of, tas2780_of_match); 640 #endif 641 642 static struct i2c_driver tas2780_i2c_driver = { 643 .driver = { 644 .name = "tas2780", 645 .of_match_table = of_match_ptr(tas2780_of_match), 646 }, 647 .probe = tas2780_i2c_probe, 648 .id_table = tas2780_i2c_id, 649 }; 650 module_i2c_driver(tas2780_i2c_driver); 651 652 MODULE_AUTHOR("Raphael Xu <raphael-xu@ti.com>"); 653 MODULE_DESCRIPTION("TAS2780 I2C Smart Amplifier driver"); 654 MODULE_LICENSE("GPL"); 655