| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * wm8940.c -- WM8940 ALSA Soc Audio driver |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * Based on wm8510.c |
|---|
| 7 | 8 | * Copyright 2006 Wolfson Microelectronics PLC. |
|---|
| 8 | 9 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
|---|
| 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 | 10 | * |
|---|
| 14 | 11 | * Not currently handled: |
|---|
| 15 | 12 | * Notch filter control |
|---|
| .. | .. |
|---|
| 340 | 337 | unsigned int fmt) |
|---|
| 341 | 338 | { |
|---|
| 342 | 339 | struct snd_soc_component *component = codec_dai->component; |
|---|
| 343 | | - u16 iface = snd_soc_component_read32(component, WM8940_IFACE) & 0xFE67; |
|---|
| 344 | | - u16 clk = snd_soc_component_read32(component, WM8940_CLOCK) & 0x1fe; |
|---|
| 340 | + u16 iface = snd_soc_component_read(component, WM8940_IFACE) & 0xFE67; |
|---|
| 341 | + u16 clk = snd_soc_component_read(component, WM8940_CLOCK) & 0x1fe; |
|---|
| 345 | 342 | |
|---|
| 346 | 343 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
|---|
| 347 | 344 | case SND_SOC_DAIFMT_CBM_CFM: |
|---|
| .. | .. |
|---|
| 395 | 392 | struct snd_soc_dai *dai) |
|---|
| 396 | 393 | { |
|---|
| 397 | 394 | struct snd_soc_component *component = dai->component; |
|---|
| 398 | | - u16 iface = snd_soc_component_read32(component, WM8940_IFACE) & 0xFD9F; |
|---|
| 399 | | - u16 addcntrl = snd_soc_component_read32(component, WM8940_ADDCNTRL) & 0xFFF1; |
|---|
| 400 | | - u16 companding = snd_soc_component_read32(component, |
|---|
| 395 | + u16 iface = snd_soc_component_read(component, WM8940_IFACE) & 0xFD9F; |
|---|
| 396 | + u16 addcntrl = snd_soc_component_read(component, WM8940_ADDCNTRL) & 0xFFF1; |
|---|
| 397 | + u16 companding = snd_soc_component_read(component, |
|---|
| 401 | 398 | WM8940_COMPANDINGCTL) & 0xFFDF; |
|---|
| 402 | 399 | int ret; |
|---|
| 403 | 400 | |
|---|
| .. | .. |
|---|
| 455 | 452 | return ret; |
|---|
| 456 | 453 | } |
|---|
| 457 | 454 | |
|---|
| 458 | | -static int wm8940_mute(struct snd_soc_dai *dai, int mute) |
|---|
| 455 | +static int wm8940_mute(struct snd_soc_dai *dai, int mute, int direction) |
|---|
| 459 | 456 | { |
|---|
| 460 | 457 | struct snd_soc_component *component = dai->component; |
|---|
| 461 | | - u16 mute_reg = snd_soc_component_read32(component, WM8940_DAC) & 0xffbf; |
|---|
| 458 | + u16 mute_reg = snd_soc_component_read(component, WM8940_DAC) & 0xffbf; |
|---|
| 462 | 459 | |
|---|
| 463 | 460 | if (mute) |
|---|
| 464 | 461 | mute_reg |= 0x40; |
|---|
| .. | .. |
|---|
| 471 | 468 | { |
|---|
| 472 | 469 | struct wm8940_priv *wm8940 = snd_soc_component_get_drvdata(component); |
|---|
| 473 | 470 | u16 val; |
|---|
| 474 | | - u16 pwr_reg = snd_soc_component_read32(component, WM8940_POWER1) & 0x1F0; |
|---|
| 471 | + u16 pwr_reg = snd_soc_component_read(component, WM8940_POWER1) & 0x1F0; |
|---|
| 475 | 472 | int ret = 0; |
|---|
| 476 | 473 | |
|---|
| 477 | 474 | switch (level) { |
|---|
| .. | .. |
|---|
| 479 | 476 | /* ensure bufioen and biasen */ |
|---|
| 480 | 477 | pwr_reg |= (1 << 2) | (1 << 3); |
|---|
| 481 | 478 | /* Enable thermal shutdown */ |
|---|
| 482 | | - val = snd_soc_component_read32(component, WM8940_OUTPUTCTL); |
|---|
| 479 | + val = snd_soc_component_read(component, WM8940_OUTPUTCTL); |
|---|
| 483 | 480 | ret = snd_soc_component_write(component, WM8940_OUTPUTCTL, val | 0x2); |
|---|
| 484 | 481 | if (ret) |
|---|
| 485 | 482 | break; |
|---|
| .. | .. |
|---|
| 580 | 577 | u16 reg; |
|---|
| 581 | 578 | |
|---|
| 582 | 579 | /* Turn off PLL */ |
|---|
| 583 | | - reg = snd_soc_component_read32(component, WM8940_POWER1); |
|---|
| 580 | + reg = snd_soc_component_read(component, WM8940_POWER1); |
|---|
| 584 | 581 | snd_soc_component_write(component, WM8940_POWER1, reg & 0x1df); |
|---|
| 585 | 582 | |
|---|
| 586 | 583 | if (freq_in == 0 || freq_out == 0) { |
|---|
| 587 | 584 | /* Clock CODEC directly from MCLK */ |
|---|
| 588 | | - reg = snd_soc_component_read32(component, WM8940_CLOCK); |
|---|
| 585 | + reg = snd_soc_component_read(component, WM8940_CLOCK); |
|---|
| 589 | 586 | snd_soc_component_write(component, WM8940_CLOCK, reg & 0x0ff); |
|---|
| 590 | 587 | /* Pll power down */ |
|---|
| 591 | 588 | snd_soc_component_write(component, WM8940_PLLN, (1 << 7)); |
|---|
| .. | .. |
|---|
| 604 | 601 | snd_soc_component_write(component, WM8940_PLLK2, (pll_div.k >> 9) & 0x1ff); |
|---|
| 605 | 602 | snd_soc_component_write(component, WM8940_PLLK3, pll_div.k & 0x1ff); |
|---|
| 606 | 603 | /* Enable the PLL */ |
|---|
| 607 | | - reg = snd_soc_component_read32(component, WM8940_POWER1); |
|---|
| 604 | + reg = snd_soc_component_read(component, WM8940_POWER1); |
|---|
| 608 | 605 | snd_soc_component_write(component, WM8940_POWER1, reg | 0x020); |
|---|
| 609 | 606 | |
|---|
| 610 | 607 | /* Run CODEC from PLL instead of MCLK */ |
|---|
| 611 | | - reg = snd_soc_component_read32(component, WM8940_CLOCK); |
|---|
| 608 | + reg = snd_soc_component_read(component, WM8940_CLOCK); |
|---|
| 612 | 609 | snd_soc_component_write(component, WM8940_CLOCK, reg | 0x100); |
|---|
| 613 | 610 | |
|---|
| 614 | 611 | return 0; |
|---|
| .. | .. |
|---|
| 641 | 638 | |
|---|
| 642 | 639 | switch (div_id) { |
|---|
| 643 | 640 | case WM8940_BCLKDIV: |
|---|
| 644 | | - reg = snd_soc_component_read32(component, WM8940_CLOCK) & 0xFFE3; |
|---|
| 641 | + reg = snd_soc_component_read(component, WM8940_CLOCK) & 0xFFE3; |
|---|
| 645 | 642 | ret = snd_soc_component_write(component, WM8940_CLOCK, reg | (div << 2)); |
|---|
| 646 | 643 | break; |
|---|
| 647 | 644 | case WM8940_MCLKDIV: |
|---|
| 648 | | - reg = snd_soc_component_read32(component, WM8940_CLOCK) & 0xFF1F; |
|---|
| 645 | + reg = snd_soc_component_read(component, WM8940_CLOCK) & 0xFF1F; |
|---|
| 649 | 646 | ret = snd_soc_component_write(component, WM8940_CLOCK, reg | (div << 5)); |
|---|
| 650 | 647 | break; |
|---|
| 651 | 648 | case WM8940_OPCLKDIV: |
|---|
| 652 | | - reg = snd_soc_component_read32(component, WM8940_GPIO) & 0xFFCF; |
|---|
| 649 | + reg = snd_soc_component_read(component, WM8940_GPIO) & 0xFFCF; |
|---|
| 653 | 650 | ret = snd_soc_component_write(component, WM8940_GPIO, reg | (div << 4)); |
|---|
| 654 | 651 | break; |
|---|
| 655 | 652 | } |
|---|
| .. | .. |
|---|
| 667 | 664 | static const struct snd_soc_dai_ops wm8940_dai_ops = { |
|---|
| 668 | 665 | .hw_params = wm8940_i2s_hw_params, |
|---|
| 669 | 666 | .set_sysclk = wm8940_set_dai_sysclk, |
|---|
| 670 | | - .digital_mute = wm8940_mute, |
|---|
| 667 | + .mute_stream = wm8940_mute, |
|---|
| 671 | 668 | .set_fmt = wm8940_set_dai_fmt, |
|---|
| 672 | 669 | .set_clkdiv = wm8940_set_dai_clkdiv, |
|---|
| 673 | 670 | .set_pll = wm8940_set_dai_pll, |
|---|
| 671 | + .no_capture_mute = 1, |
|---|
| 674 | 672 | }; |
|---|
| 675 | 673 | |
|---|
| 676 | 674 | static struct snd_soc_dai_driver wm8940_dai = { |
|---|
| .. | .. |
|---|
| 714 | 712 | if (!pdata) |
|---|
| 715 | 713 | dev_warn(component->dev, "No platform data supplied\n"); |
|---|
| 716 | 714 | else { |
|---|
| 717 | | - reg = snd_soc_component_read32(component, WM8940_OUTPUTCTL); |
|---|
| 715 | + reg = snd_soc_component_read(component, WM8940_OUTPUTCTL); |
|---|
| 718 | 716 | ret = snd_soc_component_write(component, WM8940_OUTPUTCTL, reg | pdata->vroi); |
|---|
| 719 | 717 | if (ret < 0) |
|---|
| 720 | 718 | return ret; |
|---|