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