.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * rt5631.c -- RT5631 ALSA Soc Audio driver |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Author: flove <flove@realtek.com> |
---|
7 | 8 | * |
---|
8 | 9 | * Based on WM8753.c |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or modify |
---|
11 | | - * it under the terms of the GNU General Public License version 2 as |
---|
12 | | - * published by the Free Software Foundation. |
---|
13 | | - * |
---|
14 | 10 | */ |
---|
15 | 11 | #include <linux/module.h> |
---|
16 | 12 | #include <linux/moduleparam.h> |
---|
.. | .. |
---|
68 | 64 | { RT5631_PSEUDO_SPATL_CTRL, 0x0553 }, |
---|
69 | 65 | }; |
---|
70 | 66 | |
---|
71 | | -/** |
---|
| 67 | +/* |
---|
72 | 68 | * rt5631_write_index - write index register of 2nd layer |
---|
73 | 69 | */ |
---|
74 | 70 | static void rt5631_write_index(struct snd_soc_component *component, |
---|
.. | .. |
---|
78 | 74 | snd_soc_component_write(component, RT5631_INDEX_DATA, value); |
---|
79 | 75 | } |
---|
80 | 76 | |
---|
81 | | -/** |
---|
| 77 | +/* |
---|
82 | 78 | * rt5631_read_index - read index register of 2nd layer |
---|
83 | 79 | */ |
---|
84 | 80 | static unsigned int rt5631_read_index(struct snd_soc_component *component, |
---|
.. | .. |
---|
87 | 83 | unsigned int value; |
---|
88 | 84 | |
---|
89 | 85 | snd_soc_component_write(component, RT5631_INDEX_ADD, reg); |
---|
90 | | - value = snd_soc_component_read32(component, RT5631_INDEX_DATA); |
---|
| 86 | + value = snd_soc_component_read(component, RT5631_INDEX_DATA); |
---|
91 | 87 | |
---|
92 | 88 | return value; |
---|
93 | 89 | } |
---|
.. | .. |
---|
289 | 285 | struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); |
---|
290 | 286 | unsigned int reg; |
---|
291 | 287 | |
---|
292 | | - reg = snd_soc_component_read32(component, RT5631_GLOBAL_CLK_CTRL); |
---|
| 288 | + reg = snd_soc_component_read(component, RT5631_GLOBAL_CLK_CTRL); |
---|
293 | 289 | return reg & RT5631_SYSCLK_SOUR_SEL_PLL; |
---|
294 | 290 | } |
---|
295 | 291 | |
---|
.. | .. |
---|
307 | 303 | struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); |
---|
308 | 304 | unsigned int reg; |
---|
309 | 305 | |
---|
310 | | - reg = snd_soc_component_read32(component, RT5631_OUTMIXER_L_CTRL); |
---|
| 306 | + reg = snd_soc_component_read(component, RT5631_OUTMIXER_L_CTRL); |
---|
311 | 307 | return !(reg & RT5631_M_DAC_L_TO_OUTMIXER_L); |
---|
312 | 308 | } |
---|
313 | 309 | |
---|
.. | .. |
---|
317 | 313 | struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); |
---|
318 | 314 | unsigned int reg; |
---|
319 | 315 | |
---|
320 | | - reg = snd_soc_component_read32(component, RT5631_OUTMIXER_R_CTRL); |
---|
| 316 | + reg = snd_soc_component_read(component, RT5631_OUTMIXER_R_CTRL); |
---|
321 | 317 | return !(reg & RT5631_M_DAC_R_TO_OUTMIXER_R); |
---|
322 | 318 | } |
---|
323 | 319 | |
---|
.. | .. |
---|
327 | 323 | struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); |
---|
328 | 324 | unsigned int reg; |
---|
329 | 325 | |
---|
330 | | - reg = snd_soc_component_read32(component, RT5631_SPK_MIXER_CTRL); |
---|
| 326 | + reg = snd_soc_component_read(component, RT5631_SPK_MIXER_CTRL); |
---|
331 | 327 | return !(reg & RT5631_M_DAC_L_TO_SPKMIXER_L); |
---|
332 | 328 | } |
---|
333 | 329 | |
---|
.. | .. |
---|
337 | 333 | struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); |
---|
338 | 334 | unsigned int reg; |
---|
339 | 335 | |
---|
340 | | - reg = snd_soc_component_read32(component, RT5631_SPK_MIXER_CTRL); |
---|
| 336 | + reg = snd_soc_component_read(component, RT5631_SPK_MIXER_CTRL); |
---|
341 | 337 | return !(reg & RT5631_M_DAC_R_TO_SPKMIXER_R); |
---|
342 | 338 | } |
---|
343 | 339 | |
---|
.. | .. |
---|
347 | 343 | struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); |
---|
348 | 344 | unsigned int reg; |
---|
349 | 345 | |
---|
350 | | - reg = snd_soc_component_read32(component, RT5631_ADC_REC_MIXER); |
---|
| 346 | + reg = snd_soc_component_read(component, RT5631_ADC_REC_MIXER); |
---|
351 | 347 | return !(reg & RT5631_M_MIC1_TO_RECMIXER_L); |
---|
352 | 348 | } |
---|
353 | 349 | |
---|
.. | .. |
---|
357 | 353 | struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); |
---|
358 | 354 | unsigned int reg; |
---|
359 | 355 | |
---|
360 | | - reg = snd_soc_component_read32(component, RT5631_ADC_REC_MIXER); |
---|
| 356 | + reg = snd_soc_component_read(component, RT5631_ADC_REC_MIXER); |
---|
361 | 357 | return !(reg & RT5631_M_MIC2_TO_RECMIXER_R); |
---|
362 | 358 | } |
---|
363 | 359 | |
---|
364 | 360 | /** |
---|
365 | 361 | * onebit_depop_power_stage - auto depop in power stage. |
---|
| 362 | + * @component: ASoC component |
---|
366 | 363 | * @enable: power on/off |
---|
367 | 364 | * |
---|
368 | 365 | * When power on/off headphone, the depop sequence is done by hardware. |
---|
.. | .. |
---|
376 | 373 | RT5631_EN_ONE_BIT_DEPOP, 0); |
---|
377 | 374 | |
---|
378 | 375 | /* keep soft volume and zero crossing setting */ |
---|
379 | | - soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL); |
---|
| 376 | + soft_vol = snd_soc_component_read(component, RT5631_SOFT_VOL_CTRL); |
---|
380 | 377 | snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0); |
---|
381 | | - hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2); |
---|
| 378 | + hp_zc = snd_soc_component_read(component, RT5631_INT_ST_IRQ_CTRL_2); |
---|
382 | 379 | snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); |
---|
383 | 380 | if (enable) { |
---|
384 | 381 | /* config one-bit depop parameter */ |
---|
.. | .. |
---|
401 | 398 | |
---|
402 | 399 | /** |
---|
403 | 400 | * onebit_depop_mute_stage - auto depop in mute stage. |
---|
| 401 | + * @component: ASoC component |
---|
404 | 402 | * @enable: mute/unmute |
---|
405 | 403 | * |
---|
406 | 404 | * When mute/unmute headphone, the depop sequence is done by hardware. |
---|
.. | .. |
---|
414 | 412 | RT5631_EN_ONE_BIT_DEPOP, 0); |
---|
415 | 413 | |
---|
416 | 414 | /* keep soft volume and zero crossing setting */ |
---|
417 | | - soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL); |
---|
| 415 | + soft_vol = snd_soc_component_read(component, RT5631_SOFT_VOL_CTRL); |
---|
418 | 416 | snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0); |
---|
419 | | - hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2); |
---|
| 417 | + hp_zc = snd_soc_component_read(component, RT5631_INT_ST_IRQ_CTRL_2); |
---|
420 | 418 | snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); |
---|
421 | 419 | if (enable) { |
---|
422 | 420 | schedule_timeout_uninterruptible(msecs_to_jiffies(10)); |
---|
.. | .. |
---|
439 | 437 | |
---|
440 | 438 | /** |
---|
441 | 439 | * onebit_depop_power_stage - step by step depop sequence in power stage. |
---|
| 440 | + * @component: ASoC component |
---|
442 | 441 | * @enable: power on/off |
---|
443 | 442 | * |
---|
444 | 443 | * When power on/off headphone, the depop sequence is done in step by step. |
---|
.. | .. |
---|
452 | 451 | RT5631_EN_ONE_BIT_DEPOP, RT5631_EN_ONE_BIT_DEPOP); |
---|
453 | 452 | |
---|
454 | 453 | /* keep soft volume and zero crossing setting */ |
---|
455 | | - soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL); |
---|
| 454 | + soft_vol = snd_soc_component_read(component, RT5631_SOFT_VOL_CTRL); |
---|
456 | 455 | snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0); |
---|
457 | | - hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2); |
---|
| 456 | + hp_zc = snd_soc_component_read(component, RT5631_INT_ST_IRQ_CTRL_2); |
---|
458 | 457 | snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); |
---|
459 | 458 | if (enable) { |
---|
460 | 459 | /* config depop sequence parameter */ |
---|
.. | .. |
---|
511 | 510 | |
---|
512 | 511 | /** |
---|
513 | 512 | * depop_seq_mute_stage - step by step depop sequence in mute stage. |
---|
| 513 | + * @component: ASoC component |
---|
514 | 514 | * @enable: mute/unmute |
---|
515 | 515 | * |
---|
516 | 516 | * When mute/unmute headphone, the depop sequence is done in step by step. |
---|
.. | .. |
---|
524 | 524 | RT5631_EN_ONE_BIT_DEPOP, RT5631_EN_ONE_BIT_DEPOP); |
---|
525 | 525 | |
---|
526 | 526 | /* keep soft volume and zero crossing setting */ |
---|
527 | | - soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL); |
---|
| 527 | + soft_vol = snd_soc_component_read(component, RT5631_SOFT_VOL_CTRL); |
---|
528 | 528 | snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0); |
---|
529 | | - hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2); |
---|
| 529 | + hp_zc = snd_soc_component_read(component, RT5631_INT_ST_IRQ_CTRL_2); |
---|
530 | 530 | snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); |
---|
531 | 531 | if (enable) { |
---|
532 | 532 | schedule_timeout_uninterruptible(msecs_to_jiffies(10)); |
---|
.. | .. |
---|
1695 | 1695 | .reg_defaults = rt5631_reg, |
---|
1696 | 1696 | .num_reg_defaults = ARRAY_SIZE(rt5631_reg), |
---|
1697 | 1697 | .cache_type = REGCACHE_RBTREE, |
---|
| 1698 | + .use_single_read = true, |
---|
| 1699 | + .use_single_write = true, |
---|
1698 | 1700 | }; |
---|
1699 | 1701 | |
---|
1700 | 1702 | static int rt5631_i2c_probe(struct i2c_client *i2c, |
---|