diff options
| author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2018-01-28 22:06:52 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2018-02-12 04:42:03 -0500 |
| commit | 3e32a3ff800b71c84796a89479a6ea89eee0803e (patch) | |
| tree | ad570c7ec14fc838409b55355913dd1ca1606da0 /sound | |
| parent | 7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff) | |
ASoC: wm8974: replace codec to component
Now we can replace Codec to Component. Let's do it.
Note:
xxx_codec_xxx() -> xxx_component_xxx()
.idle_bias_off = 0 -> .idle_bias_on = 1
.ignore_pmdown_time = 0 -> .use_pmdown_time = 1
- -> .endianness = 1
- -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
| -rw-r--r-- | sound/soc/codecs/wm8974.c | 143 |
1 files changed, 68 insertions, 75 deletions
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c index d414ddd6e197..43edaf8cd276 100644 --- a/sound/soc/codecs/wm8974.c +++ b/sound/soc/codecs/wm8974.c | |||
| @@ -54,7 +54,7 @@ static const struct reg_default wm8974_reg_defaults[] = { | |||
| 54 | #define WM8974_POWER1_BIASEN 0x08 | 54 | #define WM8974_POWER1_BIASEN 0x08 |
| 55 | #define WM8974_POWER1_BUFIOEN 0x04 | 55 | #define WM8974_POWER1_BUFIOEN 0x04 |
| 56 | 56 | ||
| 57 | #define wm8974_reset(c) snd_soc_write(c, WM8974_RESET, 0) | 57 | #define wm8974_reset(c) snd_soc_component_write(c, WM8974_RESET, 0) |
| 58 | 58 | ||
| 59 | static const char *wm8974_companding[] = {"Off", "NC", "u-law", "A-law" }; | 59 | static const char *wm8974_companding[] = {"Off", "NC", "u-law", "A-law" }; |
| 60 | static const char *wm8974_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz" }; | 60 | static const char *wm8974_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz" }; |
| @@ -324,33 +324,33 @@ static void pll_factors(struct pll_ *pll_div, | |||
| 324 | static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | 324 | static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, |
| 325 | int source, unsigned int freq_in, unsigned int freq_out) | 325 | int source, unsigned int freq_in, unsigned int freq_out) |
| 326 | { | 326 | { |
| 327 | struct snd_soc_codec *codec = codec_dai->codec; | 327 | struct snd_soc_component *component = codec_dai->component; |
| 328 | struct pll_ pll_div; | 328 | struct pll_ pll_div; |
| 329 | u16 reg; | 329 | u16 reg; |
| 330 | 330 | ||
| 331 | if (freq_in == 0 || freq_out == 0) { | 331 | if (freq_in == 0 || freq_out == 0) { |
| 332 | /* Clock CODEC directly from MCLK */ | 332 | /* Clock CODEC directly from MCLK */ |
| 333 | reg = snd_soc_read(codec, WM8974_CLOCK); | 333 | reg = snd_soc_component_read32(component, WM8974_CLOCK); |
| 334 | snd_soc_write(codec, WM8974_CLOCK, reg & 0x0ff); | 334 | snd_soc_component_write(component, WM8974_CLOCK, reg & 0x0ff); |
| 335 | 335 | ||
| 336 | /* Turn off PLL */ | 336 | /* Turn off PLL */ |
| 337 | reg = snd_soc_read(codec, WM8974_POWER1); | 337 | reg = snd_soc_component_read32(component, WM8974_POWER1); |
| 338 | snd_soc_write(codec, WM8974_POWER1, reg & 0x1df); | 338 | snd_soc_component_write(component, WM8974_POWER1, reg & 0x1df); |
| 339 | return 0; | 339 | return 0; |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | pll_factors(&pll_div, freq_out, freq_in); | 342 | pll_factors(&pll_div, freq_out, freq_in); |
| 343 | 343 | ||
| 344 | snd_soc_write(codec, WM8974_PLLN, (pll_div.pre_div << 4) | pll_div.n); | 344 | snd_soc_component_write(component, WM8974_PLLN, (pll_div.pre_div << 4) | pll_div.n); |
| 345 | snd_soc_write(codec, WM8974_PLLK1, pll_div.k >> 18); | 345 | snd_soc_component_write(component, WM8974_PLLK1, pll_div.k >> 18); |
| 346 | snd_soc_write(codec, WM8974_PLLK2, (pll_div.k >> 9) & 0x1ff); | 346 | snd_soc_component_write(component, WM8974_PLLK2, (pll_div.k >> 9) & 0x1ff); |
| 347 | snd_soc_write(codec, WM8974_PLLK3, pll_div.k & 0x1ff); | 347 | snd_soc_component_write(component, WM8974_PLLK3, pll_div.k & 0x1ff); |
| 348 | reg = snd_soc_read(codec, WM8974_POWER1); | 348 | reg = snd_soc_component_read32(component, WM8974_POWER1); |
| 349 | snd_soc_write(codec, WM8974_POWER1, reg | 0x020); | 349 | snd_soc_component_write(component, WM8974_POWER1, reg | 0x020); |
| 350 | 350 | ||
| 351 | /* Run CODEC from PLL instead of MCLK */ | 351 | /* Run CODEC from PLL instead of MCLK */ |
| 352 | reg = snd_soc_read(codec, WM8974_CLOCK); | 352 | reg = snd_soc_component_read32(component, WM8974_CLOCK); |
| 353 | snd_soc_write(codec, WM8974_CLOCK, reg | 0x100); | 353 | snd_soc_component_write(component, WM8974_CLOCK, reg | 0x100); |
| 354 | 354 | ||
| 355 | return 0; | 355 | return 0; |
| 356 | } | 356 | } |
| @@ -361,21 +361,21 @@ static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
| 361 | static int wm8974_set_dai_clkdiv(struct snd_soc_dai *codec_dai, | 361 | static int wm8974_set_dai_clkdiv(struct snd_soc_dai *codec_dai, |
| 362 | int div_id, int div) | 362 | int div_id, int div) |
| 363 | { | 363 | { |
| 364 | struct snd_soc_codec *codec = codec_dai->codec; | 364 | struct snd_soc_component *component = codec_dai->component; |
| 365 | u16 reg; | 365 | u16 reg; |
| 366 | 366 | ||
| 367 | switch (div_id) { | 367 | switch (div_id) { |
| 368 | case WM8974_OPCLKDIV: | 368 | case WM8974_OPCLKDIV: |
| 369 | reg = snd_soc_read(codec, WM8974_GPIO) & 0x1cf; | 369 | reg = snd_soc_component_read32(component, WM8974_GPIO) & 0x1cf; |
| 370 | snd_soc_write(codec, WM8974_GPIO, reg | div); | 370 | snd_soc_component_write(component, WM8974_GPIO, reg | div); |
| 371 | break; | 371 | break; |
| 372 | case WM8974_MCLKDIV: | 372 | case WM8974_MCLKDIV: |
| 373 | reg = snd_soc_read(codec, WM8974_CLOCK) & 0x11f; | 373 | reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x11f; |
| 374 | snd_soc_write(codec, WM8974_CLOCK, reg | div); | 374 | snd_soc_component_write(component, WM8974_CLOCK, reg | div); |
| 375 | break; | 375 | break; |
| 376 | case WM8974_BCLKDIV: | 376 | case WM8974_BCLKDIV: |
| 377 | reg = snd_soc_read(codec, WM8974_CLOCK) & 0x1e3; | 377 | reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1e3; |
| 378 | snd_soc_write(codec, WM8974_CLOCK, reg | div); | 378 | snd_soc_component_write(component, WM8974_CLOCK, reg | div); |
| 379 | break; | 379 | break; |
| 380 | default: | 380 | default: |
| 381 | return -EINVAL; | 381 | return -EINVAL; |
| @@ -418,8 +418,8 @@ static unsigned int wm8974_get_mclkdiv(unsigned int f_in, unsigned int f_out, | |||
| 418 | 418 | ||
| 419 | static int wm8974_update_clocks(struct snd_soc_dai *dai) | 419 | static int wm8974_update_clocks(struct snd_soc_dai *dai) |
| 420 | { | 420 | { |
| 421 | struct snd_soc_codec *codec = dai->codec; | 421 | struct snd_soc_component *component = dai->component; |
| 422 | struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); | 422 | struct wm8974_priv *priv = snd_soc_component_get_drvdata(component); |
| 423 | unsigned int fs256; | 423 | unsigned int fs256; |
| 424 | unsigned int fpll = 0; | 424 | unsigned int fpll = 0; |
| 425 | unsigned int f; | 425 | unsigned int f; |
| @@ -446,8 +446,8 @@ static int wm8974_update_clocks(struct snd_soc_dai *dai) | |||
| 446 | static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, | 446 | static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, |
| 447 | unsigned int freq, int dir) | 447 | unsigned int freq, int dir) |
| 448 | { | 448 | { |
| 449 | struct snd_soc_codec *codec = dai->codec; | 449 | struct snd_soc_component *component = dai->component; |
| 450 | struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); | 450 | struct wm8974_priv *priv = snd_soc_component_get_drvdata(component); |
| 451 | 451 | ||
| 452 | if (dir != SND_SOC_CLOCK_IN) | 452 | if (dir != SND_SOC_CLOCK_IN) |
| 453 | return -EINVAL; | 453 | return -EINVAL; |
| @@ -460,9 +460,9 @@ static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, | |||
| 460 | static int wm8974_set_dai_fmt(struct snd_soc_dai *codec_dai, | 460 | static int wm8974_set_dai_fmt(struct snd_soc_dai *codec_dai, |
| 461 | unsigned int fmt) | 461 | unsigned int fmt) |
| 462 | { | 462 | { |
| 463 | struct snd_soc_codec *codec = codec_dai->codec; | 463 | struct snd_soc_component *component = codec_dai->component; |
| 464 | u16 iface = 0; | 464 | u16 iface = 0; |
| 465 | u16 clk = snd_soc_read(codec, WM8974_CLOCK) & 0x1fe; | 465 | u16 clk = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1fe; |
| 466 | 466 | ||
| 467 | /* set master/slave audio interface */ | 467 | /* set master/slave audio interface */ |
| 468 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 468 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| @@ -509,8 +509,8 @@ static int wm8974_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
| 509 | return -EINVAL; | 509 | return -EINVAL; |
| 510 | } | 510 | } |
| 511 | 511 | ||
| 512 | snd_soc_write(codec, WM8974_IFACE, iface); | 512 | snd_soc_component_write(component, WM8974_IFACE, iface); |
| 513 | snd_soc_write(codec, WM8974_CLOCK, clk); | 513 | snd_soc_component_write(component, WM8974_CLOCK, clk); |
| 514 | return 0; | 514 | return 0; |
| 515 | } | 515 | } |
| 516 | 516 | ||
| @@ -518,10 +518,10 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 518 | struct snd_pcm_hw_params *params, | 518 | struct snd_pcm_hw_params *params, |
| 519 | struct snd_soc_dai *dai) | 519 | struct snd_soc_dai *dai) |
| 520 | { | 520 | { |
| 521 | struct snd_soc_codec *codec = dai->codec; | 521 | struct snd_soc_component *component = dai->component; |
| 522 | struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); | 522 | struct wm8974_priv *priv = snd_soc_component_get_drvdata(component); |
| 523 | u16 iface = snd_soc_read(codec, WM8974_IFACE) & 0x19f; | 523 | u16 iface = snd_soc_component_read32(component, WM8974_IFACE) & 0x19f; |
| 524 | u16 adn = snd_soc_read(codec, WM8974_ADD) & 0x1f1; | 524 | u16 adn = snd_soc_component_read32(component, WM8974_ADD) & 0x1f1; |
| 525 | int err; | 525 | int err; |
| 526 | 526 | ||
| 527 | priv->fs = params_rate(params); | 527 | priv->fs = params_rate(params); |
| @@ -566,55 +566,55 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 566 | break; | 566 | break; |
| 567 | } | 567 | } |
| 568 | 568 | ||
| 569 | snd_soc_write(codec, WM8974_IFACE, iface); | 569 | snd_soc_component_write(component, WM8974_IFACE, iface); |
| 570 | snd_soc_write(codec, WM8974_ADD, adn); | 570 | snd_soc_component_write(component, WM8974_ADD, adn); |
| 571 | return 0; | 571 | return 0; |
| 572 | } | 572 | } |
| 573 | 573 | ||
| 574 | static int wm8974_mute(struct snd_soc_dai *dai, int mute) | 574 | static int wm8974_mute(struct snd_soc_dai *dai, int mute) |
| 575 | { | 575 | { |
| 576 | struct snd_soc_codec *codec = dai->codec; | 576 | struct snd_soc_component *component = dai->component; |
| 577 | u16 mute_reg = snd_soc_read(codec, WM8974_DAC) & 0xffbf; | 577 | u16 mute_reg = snd_soc_component_read32(component, WM8974_DAC) & 0xffbf; |
| 578 | 578 | ||
| 579 | if (mute) | 579 | if (mute) |
| 580 | snd_soc_write(codec, WM8974_DAC, mute_reg | 0x40); | 580 | snd_soc_component_write(component, WM8974_DAC, mute_reg | 0x40); |
| 581 | else | 581 | else |
| 582 | snd_soc_write(codec, WM8974_DAC, mute_reg); | 582 | snd_soc_component_write(component, WM8974_DAC, mute_reg); |
| 583 | return 0; | 583 | return 0; |
| 584 | } | 584 | } |
| 585 | 585 | ||
| 586 | /* liam need to make this lower power with dapm */ | 586 | /* liam need to make this lower power with dapm */ |
| 587 | static int wm8974_set_bias_level(struct snd_soc_codec *codec, | 587 | static int wm8974_set_bias_level(struct snd_soc_component *component, |
| 588 | enum snd_soc_bias_level level) | 588 | enum snd_soc_bias_level level) |
| 589 | { | 589 | { |
| 590 | u16 power1 = snd_soc_read(codec, WM8974_POWER1) & ~0x3; | 590 | u16 power1 = snd_soc_component_read32(component, WM8974_POWER1) & ~0x3; |
| 591 | 591 | ||
| 592 | switch (level) { | 592 | switch (level) { |
| 593 | case SND_SOC_BIAS_ON: | 593 | case SND_SOC_BIAS_ON: |
| 594 | case SND_SOC_BIAS_PREPARE: | 594 | case SND_SOC_BIAS_PREPARE: |
| 595 | power1 |= 0x1; /* VMID 50k */ | 595 | power1 |= 0x1; /* VMID 50k */ |
| 596 | snd_soc_write(codec, WM8974_POWER1, power1); | 596 | snd_soc_component_write(component, WM8974_POWER1, power1); |
| 597 | break; | 597 | break; |
| 598 | 598 | ||
| 599 | case SND_SOC_BIAS_STANDBY: | 599 | case SND_SOC_BIAS_STANDBY: |
| 600 | power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; | 600 | power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; |
| 601 | 601 | ||
| 602 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { | 602 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { |
| 603 | regcache_sync(dev_get_regmap(codec->dev, NULL)); | 603 | regcache_sync(dev_get_regmap(component->dev, NULL)); |
| 604 | 604 | ||
| 605 | /* Initial cap charge at VMID 5k */ | 605 | /* Initial cap charge at VMID 5k */ |
| 606 | snd_soc_write(codec, WM8974_POWER1, power1 | 0x3); | 606 | snd_soc_component_write(component, WM8974_POWER1, power1 | 0x3); |
| 607 | mdelay(100); | 607 | mdelay(100); |
| 608 | } | 608 | } |
| 609 | 609 | ||
| 610 | power1 |= 0x2; /* VMID 500k */ | 610 | power1 |= 0x2; /* VMID 500k */ |
| 611 | snd_soc_write(codec, WM8974_POWER1, power1); | 611 | snd_soc_component_write(component, WM8974_POWER1, power1); |
| 612 | break; | 612 | break; |
| 613 | 613 | ||
| 614 | case SND_SOC_BIAS_OFF: | 614 | case SND_SOC_BIAS_OFF: |
| 615 | snd_soc_write(codec, WM8974_POWER1, 0); | 615 | snd_soc_component_write(component, WM8974_POWER1, 0); |
| 616 | snd_soc_write(codec, WM8974_POWER2, 0); | 616 | snd_soc_component_write(component, WM8974_POWER2, 0); |
| 617 | snd_soc_write(codec, WM8974_POWER3, 0); | 617 | snd_soc_component_write(component, WM8974_POWER3, 0); |
| 618 | break; | 618 | break; |
| 619 | } | 619 | } |
| 620 | 620 | ||
| @@ -663,32 +663,33 @@ static const struct regmap_config wm8974_regmap = { | |||
| 663 | .cache_type = REGCACHE_FLAT, | 663 | .cache_type = REGCACHE_FLAT, |
| 664 | }; | 664 | }; |
| 665 | 665 | ||
| 666 | static int wm8974_probe(struct snd_soc_codec *codec) | 666 | static int wm8974_probe(struct snd_soc_component *component) |
| 667 | { | 667 | { |
| 668 | int ret = 0; | 668 | int ret = 0; |
| 669 | 669 | ||
| 670 | ret = wm8974_reset(codec); | 670 | ret = wm8974_reset(component); |
| 671 | if (ret < 0) { | 671 | if (ret < 0) { |
| 672 | dev_err(codec->dev, "Failed to issue reset\n"); | 672 | dev_err(component->dev, "Failed to issue reset\n"); |
| 673 | return ret; | 673 | return ret; |
| 674 | } | 674 | } |
| 675 | 675 | ||
| 676 | return 0; | 676 | return 0; |
| 677 | } | 677 | } |
| 678 | 678 | ||
| 679 | static const struct snd_soc_codec_driver soc_codec_dev_wm8974 = { | 679 | static const struct snd_soc_component_driver soc_component_dev_wm8974 = { |
| 680 | .probe = wm8974_probe, | 680 | .probe = wm8974_probe, |
| 681 | .set_bias_level = wm8974_set_bias_level, | 681 | .set_bias_level = wm8974_set_bias_level, |
| 682 | .suspend_bias_off = true, | 682 | .controls = wm8974_snd_controls, |
| 683 | 683 | .num_controls = ARRAY_SIZE(wm8974_snd_controls), | |
| 684 | .component_driver = { | 684 | .dapm_widgets = wm8974_dapm_widgets, |
| 685 | .controls = wm8974_snd_controls, | 685 | .num_dapm_widgets = ARRAY_SIZE(wm8974_dapm_widgets), |
| 686 | .num_controls = ARRAY_SIZE(wm8974_snd_controls), | 686 | .dapm_routes = wm8974_dapm_routes, |
| 687 | .dapm_widgets = wm8974_dapm_widgets, | 687 | .num_dapm_routes = ARRAY_SIZE(wm8974_dapm_routes), |
| 688 | .num_dapm_widgets = ARRAY_SIZE(wm8974_dapm_widgets), | 688 | .suspend_bias_off = 1, |
| 689 | .dapm_routes = wm8974_dapm_routes, | 689 | .idle_bias_on = 1, |
| 690 | .num_dapm_routes = ARRAY_SIZE(wm8974_dapm_routes), | 690 | .use_pmdown_time = 1, |
| 691 | }, | 691 | .endianness = 1, |
| 692 | .non_legacy_dai_naming = 1, | ||
| 692 | }; | 693 | }; |
| 693 | 694 | ||
| 694 | static int wm8974_i2c_probe(struct i2c_client *i2c, | 695 | static int wm8974_i2c_probe(struct i2c_client *i2c, |
| @@ -708,19 +709,12 @@ static int wm8974_i2c_probe(struct i2c_client *i2c, | |||
| 708 | if (IS_ERR(regmap)) | 709 | if (IS_ERR(regmap)) |
| 709 | return PTR_ERR(regmap); | 710 | return PTR_ERR(regmap); |
| 710 | 711 | ||
| 711 | ret = snd_soc_register_codec(&i2c->dev, | 712 | ret = devm_snd_soc_register_component(&i2c->dev, |
| 712 | &soc_codec_dev_wm8974, &wm8974_dai, 1); | 713 | &soc_component_dev_wm8974, &wm8974_dai, 1); |
| 713 | 714 | ||
| 714 | return ret; | 715 | return ret; |
| 715 | } | 716 | } |
| 716 | 717 | ||
| 717 | static int wm8974_i2c_remove(struct i2c_client *client) | ||
| 718 | { | ||
| 719 | snd_soc_unregister_codec(&client->dev); | ||
| 720 | |||
| 721 | return 0; | ||
| 722 | } | ||
| 723 | |||
| 724 | static const struct i2c_device_id wm8974_i2c_id[] = { | 718 | static const struct i2c_device_id wm8974_i2c_id[] = { |
| 725 | { "wm8974", 0 }, | 719 | { "wm8974", 0 }, |
| 726 | { } | 720 | { } |
| @@ -739,7 +733,6 @@ static struct i2c_driver wm8974_i2c_driver = { | |||
| 739 | .of_match_table = wm8974_of_match, | 733 | .of_match_table = wm8974_of_match, |
| 740 | }, | 734 | }, |
| 741 | .probe = wm8974_i2c_probe, | 735 | .probe = wm8974_i2c_probe, |
| 742 | .remove = wm8974_i2c_remove, | ||
| 743 | .id_table = wm8974_i2c_id, | 736 | .id_table = wm8974_i2c_id, |
| 744 | }; | 737 | }; |
| 745 | 738 | ||
