1 // SPDX-License-Identifier: GPL-2.0 2 // 3 // rt700.c -- rt700 ALSA SoC audio driver 4 // 5 // Copyright(c) 2019 Realtek Semiconductor Corp. 6 // 7 // 8 9 #include <linux/module.h> 10 #include <linux/moduleparam.h> 11 #include <linux/kernel.h> 12 #include <linux/init.h> 13 #include <linux/delay.h> 14 #include <linux/pm_runtime.h> 15 #include <linux/pm.h> 16 #include <linux/soundwire/sdw.h> 17 #include <linux/regmap.h> 18 #include <linux/slab.h> 19 #include <sound/core.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/initval.h> 25 #include <sound/tlv.h> 26 #include <sound/hda_verbs.h> 27 #include <sound/jack.h> 28 29 #include "rt700.h" 30 31 static int rt700_index_write(struct regmap *regmap, 32 unsigned int reg, unsigned int value) 33 { 34 int ret; 35 unsigned int addr = (RT700_PRIV_INDEX_W_H << 8) | reg; 36 37 ret = regmap_write(regmap, addr, value); 38 if (ret < 0) 39 pr_err("Failed to set private value: %06x <= %04x ret=%d\n", 40 addr, value, ret); 41 42 return ret; 43 } 44 45 static int rt700_index_read(struct regmap *regmap, 46 unsigned int reg, unsigned int *value) 47 { 48 int ret; 49 unsigned int addr = (RT700_PRIV_INDEX_W_H << 8) | reg; 50 51 *value = 0; 52 ret = regmap_read(regmap, addr, value); 53 if (ret < 0) 54 pr_err("Failed to get private value: %06x => %04x ret=%d\n", 55 addr, *value, ret); 56 57 return ret; 58 } 59 60 static unsigned int rt700_button_detect(struct rt700_priv *rt700) 61 { 62 unsigned int btn_type = 0, val80, val81; 63 int ret; 64 65 ret = rt700_index_read(rt700->regmap, RT700_IRQ_FLAG_TABLE1, &val80); 66 if (ret < 0) 67 goto read_error; 68 ret = rt700_index_read(rt700->regmap, RT700_IRQ_FLAG_TABLE2, &val81); 69 if (ret < 0) 70 goto read_error; 71 72 val80 &= 0x0381; 73 val81 &= 0xff00; 74 75 switch (val80) { 76 case 0x0200: 77 case 0x0100: 78 case 0x0080: 79 btn_type |= SND_JACK_BTN_0; 80 break; 81 case 0x0001: 82 btn_type |= SND_JACK_BTN_3; 83 break; 84 } 85 switch (val81) { 86 case 0x8000: 87 case 0x4000: 88 case 0x2000: 89 btn_type |= SND_JACK_BTN_1; 90 break; 91 case 0x1000: 92 case 0x0800: 93 case 0x0400: 94 btn_type |= SND_JACK_BTN_2; 95 break; 96 case 0x0200: 97 case 0x0100: 98 btn_type |= SND_JACK_BTN_3; 99 break; 100 } 101 read_error: 102 return btn_type; 103 } 104 105 static int rt700_headset_detect(struct rt700_priv *rt700) 106 { 107 unsigned int buf, loop = 0; 108 int ret; 109 unsigned int jack_status = 0, reg; 110 111 ret = rt700_index_read(rt700->regmap, 112 RT700_COMBO_JACK_AUTO_CTL2, &buf); 113 if (ret < 0) 114 goto io_error; 115 116 while (loop < 500 && 117 (buf & RT700_COMBOJACK_AUTO_DET_STATUS) == 0) { 118 loop++; 119 120 usleep_range(9000, 10000); 121 ret = rt700_index_read(rt700->regmap, 122 RT700_COMBO_JACK_AUTO_CTL2, &buf); 123 if (ret < 0) 124 goto io_error; 125 126 reg = RT700_VERB_GET_PIN_SENSE | RT700_HP_OUT; 127 ret = regmap_read(rt700->regmap, reg, &jack_status); 128 if ((jack_status & (1 << 31)) == 0) 129 goto remove_error; 130 } 131 132 if (loop >= 500) 133 goto to_error; 134 135 if (buf & RT700_COMBOJACK_AUTO_DET_TRS) 136 rt700->jack_type = SND_JACK_HEADPHONE; 137 else if ((buf & RT700_COMBOJACK_AUTO_DET_CTIA) || 138 (buf & RT700_COMBOJACK_AUTO_DET_OMTP)) 139 rt700->jack_type = SND_JACK_HEADSET; 140 141 return 0; 142 143 to_error: 144 ret = -ETIMEDOUT; 145 pr_err_ratelimited("Time-out error in %s\n", __func__); 146 return ret; 147 io_error: 148 pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret); 149 return ret; 150 remove_error: 151 pr_err_ratelimited("Jack removal in %s\n", __func__); 152 return -ENODEV; 153 } 154 155 static void rt700_jack_detect_handler(struct work_struct *work) 156 { 157 struct rt700_priv *rt700 = 158 container_of(work, struct rt700_priv, jack_detect_work.work); 159 int btn_type = 0, ret; 160 unsigned int jack_status = 0, reg; 161 162 if (!rt700->hs_jack) 163 return; 164 165 if (!rt700->component->card->instantiated) 166 return; 167 168 reg = RT700_VERB_GET_PIN_SENSE | RT700_HP_OUT; 169 ret = regmap_read(rt700->regmap, reg, &jack_status); 170 if (ret < 0) 171 goto io_error; 172 173 /* pin attached */ 174 if (jack_status & (1 << 31)) { 175 /* jack in */ 176 if (rt700->jack_type == 0) { 177 ret = rt700_headset_detect(rt700); 178 if (ret < 0) 179 return; 180 if (rt700->jack_type == SND_JACK_HEADSET) 181 btn_type = rt700_button_detect(rt700); 182 } else if (rt700->jack_type == SND_JACK_HEADSET) { 183 /* jack is already in, report button event */ 184 btn_type = rt700_button_detect(rt700); 185 } 186 } else { 187 /* jack out */ 188 rt700->jack_type = 0; 189 } 190 191 dev_dbg(&rt700->slave->dev, 192 "in %s, jack_type=0x%x\n", __func__, rt700->jack_type); 193 dev_dbg(&rt700->slave->dev, 194 "in %s, btn_type=0x%x\n", __func__, btn_type); 195 196 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type | btn_type, 197 SND_JACK_HEADSET | 198 SND_JACK_BTN_0 | SND_JACK_BTN_1 | 199 SND_JACK_BTN_2 | SND_JACK_BTN_3); 200 201 if (btn_type) { 202 /* button released */ 203 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type, 204 SND_JACK_HEADSET | 205 SND_JACK_BTN_0 | SND_JACK_BTN_1 | 206 SND_JACK_BTN_2 | SND_JACK_BTN_3); 207 208 mod_delayed_work(system_power_efficient_wq, 209 &rt700->jack_btn_check_work, msecs_to_jiffies(200)); 210 } 211 212 return; 213 214 io_error: 215 pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret); 216 } 217 218 static void rt700_btn_check_handler(struct work_struct *work) 219 { 220 struct rt700_priv *rt700 = container_of(work, struct rt700_priv, 221 jack_btn_check_work.work); 222 int btn_type = 0, ret; 223 unsigned int jack_status = 0, reg; 224 225 reg = RT700_VERB_GET_PIN_SENSE | RT700_HP_OUT; 226 ret = regmap_read(rt700->regmap, reg, &jack_status); 227 if (ret < 0) 228 goto io_error; 229 230 /* pin attached */ 231 if (jack_status & (1 << 31)) { 232 if (rt700->jack_type == SND_JACK_HEADSET) { 233 /* jack is already in, report button event */ 234 btn_type = rt700_button_detect(rt700); 235 } 236 } else { 237 rt700->jack_type = 0; 238 } 239 240 /* cbj comparator */ 241 ret = rt700_index_read(rt700->regmap, RT700_COMBO_JACK_AUTO_CTL2, ®); 242 if (ret < 0) 243 goto io_error; 244 245 if ((reg & 0xf0) == 0xf0) 246 btn_type = 0; 247 248 dev_dbg(&rt700->slave->dev, 249 "%s, btn_type=0x%x\n", __func__, btn_type); 250 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type | btn_type, 251 SND_JACK_HEADSET | 252 SND_JACK_BTN_0 | SND_JACK_BTN_1 | 253 SND_JACK_BTN_2 | SND_JACK_BTN_3); 254 255 if (btn_type) { 256 /* button released */ 257 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type, 258 SND_JACK_HEADSET | 259 SND_JACK_BTN_0 | SND_JACK_BTN_1 | 260 SND_JACK_BTN_2 | SND_JACK_BTN_3); 261 262 mod_delayed_work(system_power_efficient_wq, 263 &rt700->jack_btn_check_work, msecs_to_jiffies(200)); 264 } 265 266 return; 267 268 io_error: 269 pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret); 270 } 271 272 static void rt700_jack_init(struct rt700_priv *rt700) 273 { 274 struct snd_soc_dapm_context *dapm = 275 snd_soc_component_get_dapm(rt700->component); 276 277 /* power on */ 278 if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) 279 regmap_write(rt700->regmap, 280 RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0); 281 282 if (rt700->hs_jack) { 283 /* Enable Jack Detection */ 284 regmap_write(rt700->regmap, 285 RT700_SET_MIC2_UNSOLICITED_ENABLE, 0x82); 286 regmap_write(rt700->regmap, 287 RT700_SET_HP_UNSOLICITED_ENABLE, 0x81); 288 regmap_write(rt700->regmap, 289 RT700_SET_INLINE_UNSOLICITED_ENABLE, 0x83); 290 rt700_index_write(rt700->regmap, 0x10, 0x2420); 291 rt700_index_write(rt700->regmap, 0x19, 0x2e11); 292 293 dev_dbg(&rt700->slave->dev, "in %s enable\n", __func__); 294 295 mod_delayed_work(system_power_efficient_wq, 296 &rt700->jack_detect_work, msecs_to_jiffies(250)); 297 } else { 298 regmap_write(rt700->regmap, 299 RT700_SET_MIC2_UNSOLICITED_ENABLE, 0x00); 300 regmap_write(rt700->regmap, 301 RT700_SET_HP_UNSOLICITED_ENABLE, 0x00); 302 regmap_write(rt700->regmap, 303 RT700_SET_INLINE_UNSOLICITED_ENABLE, 0x00); 304 305 dev_dbg(&rt700->slave->dev, "in %s disable\n", __func__); 306 } 307 308 /* power off */ 309 if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) 310 regmap_write(rt700->regmap, 311 RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3); 312 } 313 314 static int rt700_set_jack_detect(struct snd_soc_component *component, 315 struct snd_soc_jack *hs_jack, void *data) 316 { 317 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 318 319 rt700->hs_jack = hs_jack; 320 321 if (!rt700->hw_init) { 322 dev_dbg(&rt700->slave->dev, 323 "%s hw_init not ready yet\n", __func__); 324 return 0; 325 } 326 327 rt700_jack_init(rt700); 328 329 return 0; 330 } 331 332 static void rt700_get_gain(struct rt700_priv *rt700, unsigned int addr_h, 333 unsigned int addr_l, unsigned int val_h, 334 unsigned int *r_val, unsigned int *l_val) 335 { 336 /* R Channel */ 337 *r_val = (val_h << 8); 338 regmap_read(rt700->regmap, addr_l, r_val); 339 340 /* L Channel */ 341 val_h |= 0x20; 342 *l_val = (val_h << 8); 343 regmap_read(rt700->regmap, addr_h, l_val); 344 } 345 346 /* For Verb-Set Amplifier Gain (Verb ID = 3h) */ 347 static int rt700_set_amp_gain_put(struct snd_kcontrol *kcontrol, 348 struct snd_ctl_elem_value *ucontrol) 349 { 350 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); 351 struct snd_soc_dapm_context *dapm = 352 snd_soc_component_get_dapm(component); 353 struct soc_mixer_control *mc = 354 (struct soc_mixer_control *)kcontrol->private_value; 355 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 356 unsigned int addr_h, addr_l, val_h, val_ll, val_lr; 357 unsigned int read_ll, read_rl; 358 int i; 359 360 /* Can't use update bit function, so read the original value first */ 361 addr_h = mc->reg; 362 addr_l = mc->rreg; 363 if (mc->shift == RT700_DIR_OUT_SFT) /* output */ 364 val_h = 0x80; 365 else /* input */ 366 val_h = 0x0; 367 368 rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll); 369 370 /* L Channel */ 371 if (mc->invert) { 372 /* for mute */ 373 val_ll = (mc->max - ucontrol->value.integer.value[0]) << 7; 374 /* keep gain */ 375 read_ll = read_ll & 0x7f; 376 val_ll |= read_ll; 377 } else { 378 /* for gain */ 379 val_ll = ((ucontrol->value.integer.value[0]) & 0x7f); 380 if (val_ll > mc->max) 381 val_ll = mc->max; 382 /* keep mute status */ 383 read_ll = read_ll & 0x80; 384 val_ll |= read_ll; 385 } 386 387 if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) 388 regmap_write(rt700->regmap, 389 RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0); 390 391 /* R Channel */ 392 if (mc->invert) { 393 /* for mute */ 394 val_lr = (mc->max - ucontrol->value.integer.value[1]) << 7; 395 /* keep gain */ 396 read_rl = read_rl & 0x7f; 397 val_lr |= read_rl; 398 } else { 399 /* for gain */ 400 val_lr = ((ucontrol->value.integer.value[1]) & 0x7f); 401 if (val_lr > mc->max) 402 val_lr = mc->max; 403 /* keep mute status */ 404 read_rl = read_rl & 0x80; 405 val_lr |= read_rl; 406 } 407 408 for (i = 0; i < 3; i++) { /* retry 3 times at most */ 409 if (val_ll == val_lr) { 410 /* Set both L/R channels at the same time */ 411 val_h = (1 << mc->shift) | (3 << 4); 412 regmap_write(rt700->regmap, 413 addr_h, (val_h << 8 | val_ll)); 414 regmap_write(rt700->regmap, 415 addr_l, (val_h << 8 | val_ll)); 416 } else { 417 /* Lch*/ 418 val_h = (1 << mc->shift) | (1 << 5); 419 regmap_write(rt700->regmap, 420 addr_h, (val_h << 8 | val_ll)); 421 422 /* Rch */ 423 val_h = (1 << mc->shift) | (1 << 4); 424 regmap_write(rt700->regmap, 425 addr_l, (val_h << 8 | val_lr)); 426 } 427 /* check result */ 428 if (mc->shift == RT700_DIR_OUT_SFT) /* output */ 429 val_h = 0x80; 430 else /* input */ 431 val_h = 0x0; 432 433 rt700_get_gain(rt700, addr_h, addr_l, val_h, 434 &read_rl, &read_ll); 435 if (read_rl == val_lr && read_ll == val_ll) 436 break; 437 } 438 439 if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) 440 regmap_write(rt700->regmap, 441 RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3); 442 return 0; 443 } 444 445 static int rt700_set_amp_gain_get(struct snd_kcontrol *kcontrol, 446 struct snd_ctl_elem_value *ucontrol) 447 { 448 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); 449 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 450 struct soc_mixer_control *mc = 451 (struct soc_mixer_control *)kcontrol->private_value; 452 unsigned int addr_h, addr_l, val_h; 453 unsigned int read_ll, read_rl; 454 455 addr_h = mc->reg; 456 addr_l = mc->rreg; 457 if (mc->shift == RT700_DIR_OUT_SFT) /* output */ 458 val_h = 0x80; 459 else /* input */ 460 val_h = 0x0; 461 462 rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll); 463 464 if (mc->invert) { 465 /* for mute status */ 466 read_ll = !((read_ll & 0x80) >> RT700_MUTE_SFT); 467 read_rl = !((read_rl & 0x80) >> RT700_MUTE_SFT); 468 } else { 469 /* for gain */ 470 read_ll = read_ll & 0x7f; 471 read_rl = read_rl & 0x7f; 472 } 473 ucontrol->value.integer.value[0] = read_ll; 474 ucontrol->value.integer.value[1] = read_rl; 475 476 return 0; 477 } 478 479 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6525, 75, 0); 480 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1725, 75, 0); 481 static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0); 482 483 static const struct snd_kcontrol_new rt700_snd_controls[] = { 484 SOC_DOUBLE_R_EXT_TLV("DAC Front Playback Volume", 485 RT700_SET_GAIN_DAC1_H, RT700_SET_GAIN_DAC1_L, 486 RT700_DIR_OUT_SFT, 0x57, 0, 487 rt700_set_amp_gain_get, rt700_set_amp_gain_put, out_vol_tlv), 488 SOC_DOUBLE_R_EXT("ADC 08 Capture Switch", 489 RT700_SET_GAIN_ADC2_H, RT700_SET_GAIN_ADC2_L, 490 RT700_DIR_IN_SFT, 1, 1, 491 rt700_set_amp_gain_get, rt700_set_amp_gain_put), 492 SOC_DOUBLE_R_EXT("ADC 09 Capture Switch", 493 RT700_SET_GAIN_ADC1_H, RT700_SET_GAIN_ADC1_L, 494 RT700_DIR_IN_SFT, 1, 1, 495 rt700_set_amp_gain_get, rt700_set_amp_gain_put), 496 SOC_DOUBLE_R_EXT_TLV("ADC 08 Capture Volume", 497 RT700_SET_GAIN_ADC2_H, RT700_SET_GAIN_ADC2_L, 498 RT700_DIR_IN_SFT, 0x3f, 0, 499 rt700_set_amp_gain_get, rt700_set_amp_gain_put, in_vol_tlv), 500 SOC_DOUBLE_R_EXT_TLV("ADC 09 Capture Volume", 501 RT700_SET_GAIN_ADC1_H, RT700_SET_GAIN_ADC1_L, 502 RT700_DIR_IN_SFT, 0x3f, 0, 503 rt700_set_amp_gain_get, rt700_set_amp_gain_put, in_vol_tlv), 504 SOC_DOUBLE_R_EXT_TLV("AMIC Volume", 505 RT700_SET_GAIN_AMIC_H, RT700_SET_GAIN_AMIC_L, 506 RT700_DIR_IN_SFT, 3, 0, 507 rt700_set_amp_gain_get, rt700_set_amp_gain_put, mic_vol_tlv), 508 }; 509 510 static int rt700_mux_get(struct snd_kcontrol *kcontrol, 511 struct snd_ctl_elem_value *ucontrol) 512 { 513 struct snd_soc_component *component = 514 snd_soc_dapm_kcontrol_component(kcontrol); 515 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 516 unsigned int reg, val = 0, nid; 517 int ret; 518 519 if (strstr(ucontrol->id.name, "HPO Mux")) 520 nid = RT700_HP_OUT; 521 else if (strstr(ucontrol->id.name, "ADC 22 Mux")) 522 nid = RT700_MIXER_IN1; 523 else if (strstr(ucontrol->id.name, "ADC 23 Mux")) 524 nid = RT700_MIXER_IN2; 525 else 526 return -EINVAL; 527 528 /* vid = 0xf01 */ 529 reg = RT700_VERB_SET_CONNECT_SEL | nid; 530 ret = regmap_read(rt700->regmap, reg, &val); 531 if (ret < 0) 532 return ret; 533 534 ucontrol->value.enumerated.item[0] = val; 535 536 return 0; 537 } 538 539 static int rt700_mux_put(struct snd_kcontrol *kcontrol, 540 struct snd_ctl_elem_value *ucontrol) 541 { 542 struct snd_soc_component *component = 543 snd_soc_dapm_kcontrol_component(kcontrol); 544 struct snd_soc_dapm_context *dapm = 545 snd_soc_dapm_kcontrol_dapm(kcontrol); 546 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 547 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 548 unsigned int *item = ucontrol->value.enumerated.item; 549 unsigned int val, val2 = 0, change, reg, nid; 550 int ret; 551 552 if (item[0] >= e->items) 553 return -EINVAL; 554 555 if (strstr(ucontrol->id.name, "HPO Mux")) 556 nid = RT700_HP_OUT; 557 else if (strstr(ucontrol->id.name, "ADC 22 Mux")) 558 nid = RT700_MIXER_IN1; 559 else if (strstr(ucontrol->id.name, "ADC 23 Mux")) 560 nid = RT700_MIXER_IN2; 561 else 562 return -EINVAL; 563 564 /* Verb ID = 0x701h */ 565 val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; 566 567 reg = RT700_VERB_SET_CONNECT_SEL | nid; 568 ret = regmap_read(rt700->regmap, reg, &val2); 569 if (ret < 0) 570 return ret; 571 572 if (val == val2) 573 change = 0; 574 else 575 change = 1; 576 577 if (change) { 578 reg = RT700_VERB_SET_CONNECT_SEL | nid; 579 regmap_write(rt700->regmap, reg, val); 580 } 581 582 snd_soc_dapm_mux_update_power(dapm, kcontrol, 583 item[0], e, NULL); 584 585 return change; 586 } 587 588 static const char * const adc_mux_text[] = { 589 "MIC2", 590 "LINE1", 591 "LINE2", 592 "DMIC", 593 }; 594 595 static SOC_ENUM_SINGLE_DECL( 596 rt700_adc22_enum, SND_SOC_NOPM, 0, adc_mux_text); 597 598 static SOC_ENUM_SINGLE_DECL( 599 rt700_adc23_enum, SND_SOC_NOPM, 0, adc_mux_text); 600 601 static const struct snd_kcontrol_new rt700_adc22_mux = 602 SOC_DAPM_ENUM_EXT("ADC 22 Mux", rt700_adc22_enum, 603 rt700_mux_get, rt700_mux_put); 604 605 static const struct snd_kcontrol_new rt700_adc23_mux = 606 SOC_DAPM_ENUM_EXT("ADC 23 Mux", rt700_adc23_enum, 607 rt700_mux_get, rt700_mux_put); 608 609 static const char * const out_mux_text[] = { 610 "Front", 611 "Surround", 612 }; 613 614 static SOC_ENUM_SINGLE_DECL( 615 rt700_hp_enum, SND_SOC_NOPM, 0, out_mux_text); 616 617 static const struct snd_kcontrol_new rt700_hp_mux = 618 SOC_DAPM_ENUM_EXT("HP Mux", rt700_hp_enum, 619 rt700_mux_get, rt700_mux_put); 620 621 static int rt700_dac_front_event(struct snd_soc_dapm_widget *w, 622 struct snd_kcontrol *kcontrol, int event) 623 { 624 struct snd_soc_component *component = 625 snd_soc_dapm_to_component(w->dapm); 626 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 627 628 switch (event) { 629 case SND_SOC_DAPM_POST_PMU: 630 regmap_write(rt700->regmap, 631 RT700_SET_STREAMID_DAC1, 0x10); 632 break; 633 case SND_SOC_DAPM_PRE_PMD: 634 regmap_write(rt700->regmap, 635 RT700_SET_STREAMID_DAC1, 0x00); 636 break; 637 } 638 return 0; 639 } 640 641 static int rt700_dac_surround_event(struct snd_soc_dapm_widget *w, 642 struct snd_kcontrol *kcontrol, int event) 643 { 644 struct snd_soc_component *component = 645 snd_soc_dapm_to_component(w->dapm); 646 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 647 648 switch (event) { 649 case SND_SOC_DAPM_POST_PMU: 650 regmap_write(rt700->regmap, 651 RT700_SET_STREAMID_DAC2, 0x10); 652 break; 653 case SND_SOC_DAPM_PRE_PMD: 654 regmap_write(rt700->regmap, 655 RT700_SET_STREAMID_DAC2, 0x00); 656 break; 657 } 658 return 0; 659 } 660 661 static int rt700_adc_09_event(struct snd_soc_dapm_widget *w, 662 struct snd_kcontrol *kcontrol, int event) 663 { 664 struct snd_soc_component *component = 665 snd_soc_dapm_to_component(w->dapm); 666 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 667 668 switch (event) { 669 case SND_SOC_DAPM_POST_PMU: 670 regmap_write(rt700->regmap, 671 RT700_SET_STREAMID_ADC1, 0x10); 672 break; 673 case SND_SOC_DAPM_PRE_PMD: 674 regmap_write(rt700->regmap, 675 RT700_SET_STREAMID_ADC1, 0x00); 676 break; 677 } 678 return 0; 679 } 680 681 static int rt700_adc_08_event(struct snd_soc_dapm_widget *w, 682 struct snd_kcontrol *kcontrol, int event) 683 { 684 struct snd_soc_component *component = 685 snd_soc_dapm_to_component(w->dapm); 686 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 687 688 switch (event) { 689 case SND_SOC_DAPM_POST_PMU: 690 regmap_write(rt700->regmap, 691 RT700_SET_STREAMID_ADC2, 0x10); 692 break; 693 case SND_SOC_DAPM_PRE_PMD: 694 regmap_write(rt700->regmap, 695 RT700_SET_STREAMID_ADC2, 0x00); 696 break; 697 } 698 return 0; 699 } 700 701 static int rt700_hpo_mux_event(struct snd_soc_dapm_widget *w, 702 struct snd_kcontrol *kcontrol, int event) 703 { 704 struct snd_soc_component *component = 705 snd_soc_dapm_to_component(w->dapm); 706 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 707 unsigned int val_h = (1 << RT700_DIR_OUT_SFT) | (0x3 << 4); 708 unsigned int val_l; 709 710 switch (event) { 711 case SND_SOC_DAPM_POST_PMU: 712 val_l = 0x00; 713 regmap_write(rt700->regmap, 714 RT700_SET_GAIN_HP_H, (val_h << 8 | val_l)); 715 break; 716 case SND_SOC_DAPM_PRE_PMD: 717 val_l = (1 << RT700_MUTE_SFT); 718 regmap_write(rt700->regmap, 719 RT700_SET_GAIN_HP_H, (val_h << 8 | val_l)); 720 usleep_range(50000, 55000); 721 break; 722 } 723 return 0; 724 } 725 726 static int rt700_spk_pga_event(struct snd_soc_dapm_widget *w, 727 struct snd_kcontrol *kcontrol, int event) 728 { 729 struct snd_soc_component *component = 730 snd_soc_dapm_to_component(w->dapm); 731 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 732 unsigned int val_h = (1 << RT700_DIR_OUT_SFT) | (0x3 << 4); 733 unsigned int val_l; 734 735 switch (event) { 736 case SND_SOC_DAPM_POST_PMU: 737 val_l = 0x00; 738 regmap_write(rt700->regmap, 739 RT700_SET_GAIN_SPK_H, (val_h << 8 | val_l)); 740 break; 741 case SND_SOC_DAPM_PRE_PMD: 742 val_l = (1 << RT700_MUTE_SFT); 743 regmap_write(rt700->regmap, 744 RT700_SET_GAIN_SPK_H, (val_h << 8 | val_l)); 745 break; 746 } 747 return 0; 748 } 749 750 static const struct snd_soc_dapm_widget rt700_dapm_widgets[] = { 751 SND_SOC_DAPM_OUTPUT("HP"), 752 SND_SOC_DAPM_OUTPUT("SPK"), 753 SND_SOC_DAPM_INPUT("DMIC1"), 754 SND_SOC_DAPM_INPUT("DMIC2"), 755 SND_SOC_DAPM_INPUT("MIC2"), 756 SND_SOC_DAPM_INPUT("LINE1"), 757 SND_SOC_DAPM_INPUT("LINE2"), 758 SND_SOC_DAPM_DAC_E("DAC Front", NULL, SND_SOC_NOPM, 0, 0, 759 rt700_dac_front_event, 760 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 761 SND_SOC_DAPM_DAC_E("DAC Surround", NULL, SND_SOC_NOPM, 0, 0, 762 rt700_dac_surround_event, 763 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 764 SND_SOC_DAPM_MUX_E("HPO Mux", SND_SOC_NOPM, 0, 0, &rt700_hp_mux, 765 rt700_hpo_mux_event, 766 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 767 SND_SOC_DAPM_PGA_E("SPK PGA", SND_SOC_NOPM, 0, 0, NULL, 0, 768 rt700_spk_pga_event, 769 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 770 SND_SOC_DAPM_ADC_E("ADC 09", NULL, SND_SOC_NOPM, 0, 0, 771 rt700_adc_09_event, 772 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 773 SND_SOC_DAPM_ADC_E("ADC 08", NULL, SND_SOC_NOPM, 0, 0, 774 rt700_adc_08_event, 775 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 776 SND_SOC_DAPM_MUX("ADC 22 Mux", SND_SOC_NOPM, 0, 0, 777 &rt700_adc22_mux), 778 SND_SOC_DAPM_MUX("ADC 23 Mux", SND_SOC_NOPM, 0, 0, 779 &rt700_adc23_mux), 780 SND_SOC_DAPM_AIF_IN("DP1RX", "DP1 Playback", 0, SND_SOC_NOPM, 0, 0), 781 SND_SOC_DAPM_AIF_IN("DP3RX", "DP3 Playback", 0, SND_SOC_NOPM, 0, 0), 782 SND_SOC_DAPM_AIF_OUT("DP2TX", "DP2 Capture", 0, SND_SOC_NOPM, 0, 0), 783 SND_SOC_DAPM_AIF_OUT("DP4TX", "DP4 Capture", 0, SND_SOC_NOPM, 0, 0), 784 }; 785 786 static const struct snd_soc_dapm_route rt700_audio_map[] = { 787 {"DAC Front", NULL, "DP1RX"}, 788 {"DAC Surround", NULL, "DP3RX"}, 789 {"DP2TX", NULL, "ADC 09"}, 790 {"DP4TX", NULL, "ADC 08"}, 791 {"ADC 09", NULL, "ADC 22 Mux"}, 792 {"ADC 08", NULL, "ADC 23 Mux"}, 793 {"ADC 22 Mux", "DMIC", "DMIC1"}, 794 {"ADC 22 Mux", "LINE1", "LINE1"}, 795 {"ADC 22 Mux", "LINE2", "LINE2"}, 796 {"ADC 22 Mux", "MIC2", "MIC2"}, 797 {"ADC 23 Mux", "DMIC", "DMIC2"}, 798 {"ADC 23 Mux", "LINE1", "LINE1"}, 799 {"ADC 23 Mux", "LINE2", "LINE2"}, 800 {"ADC 23 Mux", "MIC2", "MIC2"}, 801 {"HPO Mux", "Front", "DAC Front"}, 802 {"HPO Mux", "Surround", "DAC Surround"}, 803 {"HP", NULL, "HPO Mux"}, 804 {"SPK PGA", NULL, "DAC Front"}, 805 {"SPK", NULL, "SPK PGA"}, 806 }; 807 808 static int rt700_probe(struct snd_soc_component *component) 809 { 810 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 811 812 rt700->component = component; 813 814 return 0; 815 } 816 817 static int rt700_set_bias_level(struct snd_soc_component *component, 818 enum snd_soc_bias_level level) 819 { 820 struct snd_soc_dapm_context *dapm = 821 snd_soc_component_get_dapm(component); 822 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 823 824 switch (level) { 825 case SND_SOC_BIAS_PREPARE: 826 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { 827 regmap_write(rt700->regmap, 828 RT700_SET_AUDIO_POWER_STATE, 829 AC_PWRST_D0); 830 } 831 break; 832 833 case SND_SOC_BIAS_STANDBY: 834 regmap_write(rt700->regmap, 835 RT700_SET_AUDIO_POWER_STATE, 836 AC_PWRST_D3); 837 break; 838 839 default: 840 break; 841 } 842 dapm->bias_level = level; 843 return 0; 844 } 845 846 static const struct snd_soc_component_driver soc_codec_dev_rt700 = { 847 .probe = rt700_probe, 848 .set_bias_level = rt700_set_bias_level, 849 .controls = rt700_snd_controls, 850 .num_controls = ARRAY_SIZE(rt700_snd_controls), 851 .dapm_widgets = rt700_dapm_widgets, 852 .num_dapm_widgets = ARRAY_SIZE(rt700_dapm_widgets), 853 .dapm_routes = rt700_audio_map, 854 .num_dapm_routes = ARRAY_SIZE(rt700_audio_map), 855 .set_jack = rt700_set_jack_detect, 856 .endianness = 1, 857 }; 858 859 static int rt700_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream, 860 int direction) 861 { 862 struct sdw_stream_data *stream; 863 864 if (!sdw_stream) 865 return 0; 866 867 stream = kzalloc(sizeof(*stream), GFP_KERNEL); 868 if (!stream) 869 return -ENOMEM; 870 871 stream->sdw_stream = sdw_stream; 872 873 /* Use tx_mask or rx_mask to configure stream tag and set dma_data */ 874 if (direction == SNDRV_PCM_STREAM_PLAYBACK) 875 dai->playback_dma_data = stream; 876 else 877 dai->capture_dma_data = stream; 878 879 return 0; 880 } 881 882 static void rt700_shutdown(struct snd_pcm_substream *substream, 883 struct snd_soc_dai *dai) 884 { 885 struct sdw_stream_data *stream; 886 887 stream = snd_soc_dai_get_dma_data(dai, substream); 888 snd_soc_dai_set_dma_data(dai, substream, NULL); 889 kfree(stream); 890 } 891 892 static int rt700_pcm_hw_params(struct snd_pcm_substream *substream, 893 struct snd_pcm_hw_params *params, 894 struct snd_soc_dai *dai) 895 { 896 struct snd_soc_component *component = dai->component; 897 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 898 struct sdw_stream_config stream_config; 899 struct sdw_port_config port_config; 900 enum sdw_data_direction direction; 901 struct sdw_stream_data *stream; 902 int retval, port, num_channels; 903 unsigned int val = 0; 904 905 dev_dbg(dai->dev, "%s %s", __func__, dai->name); 906 stream = snd_soc_dai_get_dma_data(dai, substream); 907 908 if (!stream) 909 return -EINVAL; 910 911 if (!rt700->slave) 912 return -EINVAL; 913 914 /* SoundWire specific configuration */ 915 /* This code assumes port 1 for playback and port 2 for capture */ 916 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 917 direction = SDW_DATA_DIR_RX; 918 port = 1; 919 } else { 920 direction = SDW_DATA_DIR_TX; 921 port = 2; 922 } 923 924 switch (dai->id) { 925 case RT700_AIF1: 926 break; 927 case RT700_AIF2: 928 port += 2; 929 break; 930 default: 931 dev_err(component->dev, "Invalid DAI id %d\n", dai->id); 932 return -EINVAL; 933 } 934 935 stream_config.frame_rate = params_rate(params); 936 stream_config.ch_count = params_channels(params); 937 stream_config.bps = snd_pcm_format_width(params_format(params)); 938 stream_config.direction = direction; 939 940 num_channels = params_channels(params); 941 port_config.ch_mask = (1 << (num_channels)) - 1; 942 port_config.num = port; 943 944 retval = sdw_stream_add_slave(rt700->slave, &stream_config, 945 &port_config, 1, stream->sdw_stream); 946 if (retval) { 947 dev_err(dai->dev, "Unable to configure port\n"); 948 return retval; 949 } 950 951 if (params_channels(params) <= 16) { 952 /* bit 3:0 Number of Channel */ 953 val |= (params_channels(params) - 1); 954 } else { 955 dev_err(component->dev, "Unsupported channels %d\n", 956 params_channels(params)); 957 return -EINVAL; 958 } 959 960 switch (params_width(params)) { 961 /* bit 6:4 Bits per Sample */ 962 case 8: 963 break; 964 case 16: 965 val |= (0x1 << 4); 966 break; 967 case 20: 968 val |= (0x2 << 4); 969 break; 970 case 24: 971 val |= (0x3 << 4); 972 break; 973 case 32: 974 val |= (0x4 << 4); 975 break; 976 default: 977 return -EINVAL; 978 } 979 980 /* 48Khz */ 981 regmap_write(rt700->regmap, RT700_DAC_FORMAT_H, val); 982 regmap_write(rt700->regmap, RT700_ADC_FORMAT_H, val); 983 984 return retval; 985 } 986 987 static int rt700_pcm_hw_free(struct snd_pcm_substream *substream, 988 struct snd_soc_dai *dai) 989 { 990 struct snd_soc_component *component = dai->component; 991 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); 992 struct sdw_stream_data *stream = 993 snd_soc_dai_get_dma_data(dai, substream); 994 995 if (!rt700->slave) 996 return -EINVAL; 997 998 sdw_stream_remove_slave(rt700->slave, stream->sdw_stream); 999 return 0; 1000 } 1001 1002 #define RT700_STEREO_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) 1003 #define RT700_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ 1004 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) 1005 1006 static const struct snd_soc_dai_ops rt700_ops = { 1007 .hw_params = rt700_pcm_hw_params, 1008 .hw_free = rt700_pcm_hw_free, 1009 .set_stream = rt700_set_sdw_stream, 1010 .shutdown = rt700_shutdown, 1011 }; 1012 1013 static struct snd_soc_dai_driver rt700_dai[] = { 1014 { 1015 .name = "rt700-aif1", 1016 .id = RT700_AIF1, 1017 .playback = { 1018 .stream_name = "DP1 Playback", 1019 .channels_min = 1, 1020 .channels_max = 2, 1021 .rates = RT700_STEREO_RATES, 1022 .formats = RT700_FORMATS, 1023 }, 1024 .capture = { 1025 .stream_name = "DP2 Capture", 1026 .channels_min = 1, 1027 .channels_max = 2, 1028 .rates = RT700_STEREO_RATES, 1029 .formats = RT700_FORMATS, 1030 }, 1031 .ops = &rt700_ops, 1032 }, 1033 { 1034 .name = "rt700-aif2", 1035 .id = RT700_AIF2, 1036 .playback = { 1037 .stream_name = "DP3 Playback", 1038 .channels_min = 1, 1039 .channels_max = 2, 1040 .rates = RT700_STEREO_RATES, 1041 .formats = RT700_FORMATS, 1042 }, 1043 .capture = { 1044 .stream_name = "DP4 Capture", 1045 .channels_min = 1, 1046 .channels_max = 2, 1047 .rates = RT700_STEREO_RATES, 1048 .formats = RT700_FORMATS, 1049 }, 1050 .ops = &rt700_ops, 1051 }, 1052 }; 1053 1054 /* Bus clock frequency */ 1055 #define RT700_CLK_FREQ_9600000HZ 9600000 1056 #define RT700_CLK_FREQ_12000000HZ 12000000 1057 #define RT700_CLK_FREQ_6000000HZ 6000000 1058 #define RT700_CLK_FREQ_4800000HZ 4800000 1059 #define RT700_CLK_FREQ_2400000HZ 2400000 1060 #define RT700_CLK_FREQ_12288000HZ 12288000 1061 1062 int rt700_clock_config(struct device *dev) 1063 { 1064 struct rt700_priv *rt700 = dev_get_drvdata(dev); 1065 unsigned int clk_freq, value; 1066 1067 clk_freq = (rt700->params.curr_dr_freq >> 1); 1068 1069 switch (clk_freq) { 1070 case RT700_CLK_FREQ_12000000HZ: 1071 value = 0x0; 1072 break; 1073 case RT700_CLK_FREQ_6000000HZ: 1074 value = 0x1; 1075 break; 1076 case RT700_CLK_FREQ_9600000HZ: 1077 value = 0x2; 1078 break; 1079 case RT700_CLK_FREQ_4800000HZ: 1080 value = 0x3; 1081 break; 1082 case RT700_CLK_FREQ_2400000HZ: 1083 value = 0x4; 1084 break; 1085 case RT700_CLK_FREQ_12288000HZ: 1086 value = 0x5; 1087 break; 1088 default: 1089 return -EINVAL; 1090 } 1091 1092 regmap_write(rt700->regmap, 0xe0, value); 1093 regmap_write(rt700->regmap, 0xf0, value); 1094 1095 dev_dbg(dev, "%s complete, clk_freq=%d\n", __func__, clk_freq); 1096 1097 return 0; 1098 } 1099 1100 int rt700_init(struct device *dev, struct regmap *sdw_regmap, 1101 struct regmap *regmap, struct sdw_slave *slave) 1102 1103 { 1104 struct rt700_priv *rt700; 1105 int ret; 1106 1107 rt700 = devm_kzalloc(dev, sizeof(*rt700), GFP_KERNEL); 1108 if (!rt700) 1109 return -ENOMEM; 1110 1111 dev_set_drvdata(dev, rt700); 1112 rt700->slave = slave; 1113 rt700->sdw_regmap = sdw_regmap; 1114 rt700->regmap = regmap; 1115 1116 mutex_init(&rt700->disable_irq_lock); 1117 1118 /* 1119 * Mark hw_init to false 1120 * HW init will be performed when device reports present 1121 */ 1122 rt700->hw_init = false; 1123 rt700->first_hw_init = false; 1124 1125 ret = devm_snd_soc_register_component(dev, 1126 &soc_codec_dev_rt700, 1127 rt700_dai, 1128 ARRAY_SIZE(rt700_dai)); 1129 1130 dev_dbg(&slave->dev, "%s\n", __func__); 1131 1132 return ret; 1133 } 1134 1135 int rt700_io_init(struct device *dev, struct sdw_slave *slave) 1136 { 1137 struct rt700_priv *rt700 = dev_get_drvdata(dev); 1138 1139 rt700->disable_irq = false; 1140 1141 if (rt700->hw_init) 1142 return 0; 1143 1144 if (rt700->first_hw_init) { 1145 regcache_cache_only(rt700->regmap, false); 1146 regcache_cache_bypass(rt700->regmap, true); 1147 } 1148 1149 /* 1150 * PM runtime is only enabled when a Slave reports as Attached 1151 */ 1152 if (!rt700->first_hw_init) { 1153 /* set autosuspend parameters */ 1154 pm_runtime_set_autosuspend_delay(&slave->dev, 3000); 1155 pm_runtime_use_autosuspend(&slave->dev); 1156 1157 /* update count of parent 'active' children */ 1158 pm_runtime_set_active(&slave->dev); 1159 1160 /* make sure the device does not suspend immediately */ 1161 pm_runtime_mark_last_busy(&slave->dev); 1162 1163 pm_runtime_enable(&slave->dev); 1164 } 1165 1166 pm_runtime_get_noresume(&slave->dev); 1167 1168 /* reset */ 1169 regmap_write(rt700->regmap, 0xff01, 0x0000); 1170 regmap_write(rt700->regmap, 0x7520, 0x001a); 1171 regmap_write(rt700->regmap, 0x7420, 0xc003); 1172 1173 /* power on */ 1174 regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0); 1175 /* Set Pin Widget */ 1176 regmap_write(rt700->regmap, RT700_SET_PIN_HP, 0x40); 1177 regmap_write(rt700->regmap, RT700_SET_PIN_SPK, 0x40); 1178 regmap_write(rt700->regmap, RT700_SET_EAPD_SPK, RT700_EAPD_HIGH); 1179 regmap_write(rt700->regmap, RT700_SET_PIN_DMIC1, 0x20); 1180 regmap_write(rt700->regmap, RT700_SET_PIN_DMIC2, 0x20); 1181 regmap_write(rt700->regmap, RT700_SET_PIN_MIC2, 0x20); 1182 1183 /* Set Configuration Default */ 1184 regmap_write(rt700->regmap, 0x4f12, 0x91); 1185 regmap_write(rt700->regmap, 0x4e12, 0xd6); 1186 regmap_write(rt700->regmap, 0x4d12, 0x11); 1187 regmap_write(rt700->regmap, 0x4c12, 0x20); 1188 regmap_write(rt700->regmap, 0x4f13, 0x91); 1189 regmap_write(rt700->regmap, 0x4e13, 0xd6); 1190 regmap_write(rt700->regmap, 0x4d13, 0x11); 1191 regmap_write(rt700->regmap, 0x4c13, 0x21); 1192 1193 regmap_write(rt700->regmap, 0x4f19, 0x02); 1194 regmap_write(rt700->regmap, 0x4e19, 0xa1); 1195 regmap_write(rt700->regmap, 0x4d19, 0x90); 1196 regmap_write(rt700->regmap, 0x4c19, 0x80); 1197 1198 /* Enable Line2 */ 1199 regmap_write(rt700->regmap, 0x371b, 0x40); 1200 regmap_write(rt700->regmap, 0x731b, 0xb0); 1201 regmap_write(rt700->regmap, 0x839b, 0x00); 1202 1203 /* Set index */ 1204 rt700_index_write(rt700->regmap, 0x4a, 0x201b); 1205 rt700_index_write(rt700->regmap, 0x45, 0x5089); 1206 rt700_index_write(rt700->regmap, 0x6b, 0x5064); 1207 rt700_index_write(rt700->regmap, 0x48, 0xd249); 1208 1209 /* Finish Initial Settings, set power to D3 */ 1210 regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3); 1211 1212 if (!rt700->first_hw_init) { 1213 INIT_DELAYED_WORK(&rt700->jack_detect_work, 1214 rt700_jack_detect_handler); 1215 INIT_DELAYED_WORK(&rt700->jack_btn_check_work, 1216 rt700_btn_check_handler); 1217 } 1218 1219 /* 1220 * if set_jack callback occurred early than io_init, 1221 * we set up the jack detection function now 1222 */ 1223 if (rt700->hs_jack) 1224 rt700_jack_init(rt700); 1225 1226 if (rt700->first_hw_init) { 1227 regcache_cache_bypass(rt700->regmap, false); 1228 regcache_mark_dirty(rt700->regmap); 1229 } else 1230 rt700->first_hw_init = true; 1231 1232 /* Mark Slave initialization complete */ 1233 rt700->hw_init = true; 1234 1235 pm_runtime_mark_last_busy(&slave->dev); 1236 pm_runtime_put_autosuspend(&slave->dev); 1237 1238 dev_dbg(&slave->dev, "%s hw_init complete\n", __func__); 1239 1240 return 0; 1241 } 1242 1243 MODULE_DESCRIPTION("ASoC RT700 driver SDW"); 1244 MODULE_AUTHOR("Shuming Fan <shumingf@realtek.com>"); 1245 MODULE_LICENSE("GPL v2"); 1246