| .. | .. |
|---|
| 12 | 12 | #include <linux/of_device.h> |
|---|
| 13 | 13 | #include <linux/of_gpio.h> |
|---|
| 14 | 14 | #include <linux/pm_runtime.h> |
|---|
| 15 | +#include <linux/regulator/consumer.h> |
|---|
| 15 | 16 | #include <linux/slab.h> |
|---|
| 16 | 17 | #include <sound/initval.h> |
|---|
| 17 | 18 | #include <sound/pcm_params.h> |
|---|
| .. | .. |
|---|
| 21 | 22 | |
|---|
| 22 | 23 | #include "ak4458.h" |
|---|
| 23 | 24 | |
|---|
| 25 | +#define AK4458_NUM_SUPPLIES 2 |
|---|
| 26 | +static const char *ak4458_supply_names[AK4458_NUM_SUPPLIES] = { |
|---|
| 27 | + "DVDD", |
|---|
| 28 | + "AVDD", |
|---|
| 29 | +}; |
|---|
| 30 | + |
|---|
| 31 | +enum ak4458_type { |
|---|
| 32 | + AK4458 = 0, |
|---|
| 33 | + AK4497 = 1, |
|---|
| 34 | +}; |
|---|
| 35 | + |
|---|
| 36 | +struct ak4458_drvdata { |
|---|
| 37 | + struct snd_soc_dai_driver *dai_drv; |
|---|
| 38 | + const struct snd_soc_component_driver *comp_drv; |
|---|
| 39 | + enum ak4458_type type; |
|---|
| 40 | +}; |
|---|
| 41 | + |
|---|
| 24 | 42 | /* AK4458 Codec Private Data */ |
|---|
| 25 | 43 | struct ak4458_priv { |
|---|
| 44 | + struct regulator_bulk_data supplies[AK4458_NUM_SUPPLIES]; |
|---|
| 45 | + const struct ak4458_drvdata *drvdata; |
|---|
| 26 | 46 | struct device *dev; |
|---|
| 27 | 47 | struct regmap *regmap; |
|---|
| 28 | 48 | struct gpio_desc *reset_gpiod; |
|---|
| .. | .. |
|---|
| 32 | 52 | int fmt; |
|---|
| 33 | 53 | int slots; |
|---|
| 34 | 54 | int slot_width; |
|---|
| 55 | + u32 dsd_path; /* For ak4497 */ |
|---|
| 35 | 56 | }; |
|---|
| 36 | 57 | |
|---|
| 37 | 58 | static const struct reg_default ak4458_reg_defaults[] = { |
|---|
| .. | .. |
|---|
| 258 | 279 | {"AK4458 AOUTD", NULL, "AK4458 DAC4"}, |
|---|
| 259 | 280 | }; |
|---|
| 260 | 281 | |
|---|
| 282 | +/* ak4497 controls */ |
|---|
| 283 | +static const struct snd_kcontrol_new ak4497_snd_controls[] = { |
|---|
| 284 | + SOC_DOUBLE_R_TLV("DAC Playback Volume", AK4458_03_LCHATT, |
|---|
| 285 | + AK4458_04_RCHATT, 0, 0xFF, 0, dac_tlv), |
|---|
| 286 | + SOC_ENUM("AK4497 De-emphasis Response DAC", ak4458_dac1_dem_enum), |
|---|
| 287 | + SOC_ENUM_EXT("AK4497 Digital Filter Setting", ak4458_digfil_enum, |
|---|
| 288 | + get_digfil, set_digfil), |
|---|
| 289 | + SOC_ENUM("AK4497 Inverting Enable of DZFB", ak4458_dzfb_enum), |
|---|
| 290 | + SOC_ENUM("AK4497 Sound Mode", ak4458_sm_enum), |
|---|
| 291 | + SOC_ENUM("AK4497 Attenuation transition Time Setting", |
|---|
| 292 | + ak4458_ats_enum), |
|---|
| 293 | +}; |
|---|
| 294 | + |
|---|
| 295 | +/* ak4497 dapm widgets */ |
|---|
| 296 | +static const struct snd_soc_dapm_widget ak4497_dapm_widgets[] = { |
|---|
| 297 | + SND_SOC_DAPM_DAC("AK4497 DAC", NULL, AK4458_0A_CONTROL6, 2, 0), |
|---|
| 298 | + SND_SOC_DAPM_AIF_IN("AK4497 SDTI", "Playback", 0, SND_SOC_NOPM, 0, 0), |
|---|
| 299 | + SND_SOC_DAPM_OUTPUT("AK4497 AOUT"), |
|---|
| 300 | +}; |
|---|
| 301 | + |
|---|
| 302 | +/* ak4497 dapm routes */ |
|---|
| 303 | +static const struct snd_soc_dapm_route ak4497_intercon[] = { |
|---|
| 304 | + {"AK4497 DAC", NULL, "AK4497 SDTI"}, |
|---|
| 305 | + {"AK4497 AOUT", NULL, "AK4497 DAC"}, |
|---|
| 306 | + |
|---|
| 307 | +}; |
|---|
| 308 | + |
|---|
| 261 | 309 | static int ak4458_rstn_control(struct snd_soc_component *component, int bit) |
|---|
| 262 | 310 | { |
|---|
| 263 | 311 | int ret; |
|---|
| .. | .. |
|---|
| 285 | 333 | struct snd_soc_component *component = dai->component; |
|---|
| 286 | 334 | struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); |
|---|
| 287 | 335 | int pcm_width = max(params_physical_width(params), ak4458->slot_width); |
|---|
| 288 | | - int nfs1; |
|---|
| 289 | | - u8 format; |
|---|
| 336 | + u8 format, dsdsel0, dsdsel1; |
|---|
| 337 | + int nfs1, dsd_bclk; |
|---|
| 290 | 338 | |
|---|
| 291 | 339 | nfs1 = params_rate(params); |
|---|
| 292 | 340 | ak4458->fs = nfs1; |
|---|
| 341 | + |
|---|
| 342 | + /* calculate bit clock */ |
|---|
| 343 | + switch (params_format(params)) { |
|---|
| 344 | + case SNDRV_PCM_FORMAT_DSD_U8: |
|---|
| 345 | + case SNDRV_PCM_FORMAT_DSD_U16_LE: |
|---|
| 346 | + case SNDRV_PCM_FORMAT_DSD_U16_BE: |
|---|
| 347 | + case SNDRV_PCM_FORMAT_DSD_U32_LE: |
|---|
| 348 | + case SNDRV_PCM_FORMAT_DSD_U32_BE: |
|---|
| 349 | + dsd_bclk = nfs1 * params_physical_width(params); |
|---|
| 350 | + switch (dsd_bclk) { |
|---|
| 351 | + case 2822400: |
|---|
| 352 | + dsdsel0 = 0; |
|---|
| 353 | + dsdsel1 = 0; |
|---|
| 354 | + break; |
|---|
| 355 | + case 5644800: |
|---|
| 356 | + dsdsel0 = 1; |
|---|
| 357 | + dsdsel1 = 0; |
|---|
| 358 | + break; |
|---|
| 359 | + case 11289600: |
|---|
| 360 | + dsdsel0 = 0; |
|---|
| 361 | + dsdsel1 = 1; |
|---|
| 362 | + break; |
|---|
| 363 | + case 22579200: |
|---|
| 364 | + if (ak4458->drvdata->type == AK4497) { |
|---|
| 365 | + dsdsel0 = 1; |
|---|
| 366 | + dsdsel1 = 1; |
|---|
| 367 | + } else { |
|---|
| 368 | + dev_err(dai->dev, "DSD512 not supported.\n"); |
|---|
| 369 | + return -EINVAL; |
|---|
| 370 | + } |
|---|
| 371 | + break; |
|---|
| 372 | + default: |
|---|
| 373 | + dev_err(dai->dev, "Unsupported dsd bclk.\n"); |
|---|
| 374 | + return -EINVAL; |
|---|
| 375 | + } |
|---|
| 376 | + |
|---|
| 377 | + snd_soc_component_update_bits(component, AK4458_06_DSD1, |
|---|
| 378 | + AK4458_DSDSEL_MASK, dsdsel0); |
|---|
| 379 | + snd_soc_component_update_bits(component, AK4458_09_DSD2, |
|---|
| 380 | + AK4458_DSDSEL_MASK, dsdsel1); |
|---|
| 381 | + break; |
|---|
| 382 | + } |
|---|
| 293 | 383 | |
|---|
| 294 | 384 | /* Master Clock Frequency Auto Setting Mode Enable */ |
|---|
| 295 | 385 | snd_soc_component_update_bits(component, AK4458_00_CONTROL1, 0x80, 0x80); |
|---|
| .. | .. |
|---|
| 313 | 403 | format = AK4458_DIF_32BIT_LSB; |
|---|
| 314 | 404 | break; |
|---|
| 315 | 405 | case SND_SOC_DAIFMT_DSP_B: |
|---|
| 406 | + format = AK4458_DIF_32BIT_MSB; |
|---|
| 407 | + break; |
|---|
| 408 | + case SND_SOC_DAIFMT_PDM: |
|---|
| 316 | 409 | format = AK4458_DIF_32BIT_MSB; |
|---|
| 317 | 410 | break; |
|---|
| 318 | 411 | default: |
|---|
| .. | .. |
|---|
| 353 | 446 | case SND_SOC_DAIFMT_LEFT_J: |
|---|
| 354 | 447 | case SND_SOC_DAIFMT_RIGHT_J: |
|---|
| 355 | 448 | case SND_SOC_DAIFMT_DSP_B: |
|---|
| 449 | + case SND_SOC_DAIFMT_PDM: |
|---|
| 356 | 450 | ak4458->fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; |
|---|
| 357 | 451 | break; |
|---|
| 358 | 452 | default: |
|---|
| .. | .. |
|---|
| 360 | 454 | fmt & SND_SOC_DAIFMT_FORMAT_MASK); |
|---|
| 361 | 455 | return -EINVAL; |
|---|
| 362 | 456 | } |
|---|
| 457 | + |
|---|
| 458 | + /* DSD mode */ |
|---|
| 459 | + snd_soc_component_update_bits(component, AK4458_02_CONTROL3, |
|---|
| 460 | + AK4458_DP_MASK, |
|---|
| 461 | + ak4458->fmt == SND_SOC_DAIFMT_PDM ? |
|---|
| 462 | + AK4458_DP_MASK : 0); |
|---|
| 363 | 463 | |
|---|
| 364 | 464 | ak4458_rstn_control(component, 0); |
|---|
| 365 | 465 | ak4458_rstn_control(component, 1); |
|---|
| .. | .. |
|---|
| 369 | 469 | |
|---|
| 370 | 470 | static const int att_speed[] = { 4080, 2040, 510, 255 }; |
|---|
| 371 | 471 | |
|---|
| 372 | | -static int ak4458_set_dai_mute(struct snd_soc_dai *dai, int mute) |
|---|
| 472 | +static int ak4458_set_dai_mute(struct snd_soc_dai *dai, int mute, int direction) |
|---|
| 373 | 473 | { |
|---|
| 374 | 474 | struct snd_soc_component *component = dai->component; |
|---|
| 375 | 475 | struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); |
|---|
| 376 | | - int nfs, ndt, ret, reg; |
|---|
| 476 | + int nfs, ndt, reg; |
|---|
| 377 | 477 | int ats; |
|---|
| 378 | 478 | |
|---|
| 379 | 479 | nfs = ak4458->fs; |
|---|
| 380 | 480 | |
|---|
| 381 | | - reg = snd_soc_component_read32(component, AK4458_0B_CONTROL7); |
|---|
| 481 | + reg = snd_soc_component_read(component, AK4458_0B_CONTROL7); |
|---|
| 382 | 482 | ats = (reg & AK4458_ATS_MASK) >> AK4458_ATS_SHIFT; |
|---|
| 383 | 483 | |
|---|
| 384 | 484 | ndt = att_speed[ats] / (nfs / 1000); |
|---|
| 385 | 485 | |
|---|
| 386 | 486 | if (mute) { |
|---|
| 387 | | - ret = snd_soc_component_update_bits(component, AK4458_01_CONTROL2, 0x01, 1); |
|---|
| 487 | + snd_soc_component_update_bits(component, AK4458_01_CONTROL2, 0x01, 1); |
|---|
| 388 | 488 | mdelay(ndt); |
|---|
| 389 | 489 | if (ak4458->mute_gpiod) |
|---|
| 390 | 490 | gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); |
|---|
| 391 | 491 | } else { |
|---|
| 392 | 492 | if (ak4458->mute_gpiod) |
|---|
| 393 | 493 | gpiod_set_value_cansleep(ak4458->mute_gpiod, 0); |
|---|
| 394 | | - ret = snd_soc_component_update_bits(component, AK4458_01_CONTROL2, 0x01, 0); |
|---|
| 494 | + snd_soc_component_update_bits(component, AK4458_01_CONTROL2, 0x01, 0); |
|---|
| 395 | 495 | mdelay(ndt); |
|---|
| 396 | 496 | } |
|---|
| 397 | 497 | |
|---|
| .. | .. |
|---|
| 432 | 532 | |
|---|
| 433 | 533 | #define AK4458_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ |
|---|
| 434 | 534 | SNDRV_PCM_FMTBIT_S24_LE |\ |
|---|
| 435 | | - SNDRV_PCM_FMTBIT_S32_LE) |
|---|
| 535 | + SNDRV_PCM_FMTBIT_S32_LE |\ |
|---|
| 536 | + SNDRV_PCM_FMTBIT_DSD_U8 |\ |
|---|
| 537 | + SNDRV_PCM_FMTBIT_DSD_U16_LE |\ |
|---|
| 538 | + SNDRV_PCM_FMTBIT_DSD_U32_LE) |
|---|
| 436 | 539 | |
|---|
| 437 | 540 | static const unsigned int ak4458_rates[] = { |
|---|
| 438 | 541 | 8000, 11025, 16000, 22050, |
|---|
| .. | .. |
|---|
| 459 | 562 | return ret; |
|---|
| 460 | 563 | } |
|---|
| 461 | 564 | |
|---|
| 462 | | -static struct snd_soc_dai_ops ak4458_dai_ops = { |
|---|
| 565 | +static const struct snd_soc_dai_ops ak4458_dai_ops = { |
|---|
| 463 | 566 | .startup = ak4458_startup, |
|---|
| 464 | 567 | .hw_params = ak4458_hw_params, |
|---|
| 465 | 568 | .set_fmt = ak4458_set_dai_fmt, |
|---|
| 466 | | - .digital_mute = ak4458_set_dai_mute, |
|---|
| 569 | + .mute_stream = ak4458_set_dai_mute, |
|---|
| 467 | 570 | .set_tdm_slot = ak4458_set_tdm_slot, |
|---|
| 571 | + .no_capture_mute = 1, |
|---|
| 468 | 572 | }; |
|---|
| 469 | 573 | |
|---|
| 470 | 574 | static struct snd_soc_dai_driver ak4458_dai = { |
|---|
| .. | .. |
|---|
| 479 | 583 | .ops = &ak4458_dai_ops, |
|---|
| 480 | 584 | }; |
|---|
| 481 | 585 | |
|---|
| 482 | | -static void ak4458_power_off(struct ak4458_priv *ak4458) |
|---|
| 483 | | -{ |
|---|
| 484 | | - if (ak4458->reset_gpiod) { |
|---|
| 485 | | - gpiod_set_value_cansleep(ak4458->reset_gpiod, 0); |
|---|
| 486 | | - usleep_range(1000, 2000); |
|---|
| 487 | | - } |
|---|
| 488 | | -} |
|---|
| 586 | +static struct snd_soc_dai_driver ak4497_dai = { |
|---|
| 587 | + .name = "ak4497-aif", |
|---|
| 588 | + .playback = { |
|---|
| 589 | + .stream_name = "Playback", |
|---|
| 590 | + .channels_min = 1, |
|---|
| 591 | + .channels_max = 2, |
|---|
| 592 | + .rates = SNDRV_PCM_RATE_KNOT, |
|---|
| 593 | + .formats = AK4458_FORMATS, |
|---|
| 594 | + }, |
|---|
| 595 | + .ops = &ak4458_dai_ops, |
|---|
| 596 | +}; |
|---|
| 489 | 597 | |
|---|
| 490 | | -static void ak4458_power_on(struct ak4458_priv *ak4458) |
|---|
| 598 | +static void ak4458_reset(struct ak4458_priv *ak4458, bool active) |
|---|
| 491 | 599 | { |
|---|
| 492 | 600 | if (ak4458->reset_gpiod) { |
|---|
| 493 | | - gpiod_set_value_cansleep(ak4458->reset_gpiod, 1); |
|---|
| 601 | + gpiod_set_value_cansleep(ak4458->reset_gpiod, active); |
|---|
| 494 | 602 | usleep_range(1000, 2000); |
|---|
| 495 | 603 | } |
|---|
| 496 | 604 | } |
|---|
| .. | .. |
|---|
| 504 | 612 | if (ak4458->mute_gpiod) |
|---|
| 505 | 613 | gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); |
|---|
| 506 | 614 | |
|---|
| 507 | | - ak4458_power_on(ak4458); |
|---|
| 615 | + ak4458_reset(ak4458, false); |
|---|
| 508 | 616 | |
|---|
| 509 | 617 | ret = snd_soc_component_update_bits(component, AK4458_00_CONTROL1, |
|---|
| 510 | 618 | 0x80, 0x80); /* ACKS bit = 1; 10000000 */ |
|---|
| 511 | 619 | if (ret < 0) |
|---|
| 512 | 620 | return ret; |
|---|
| 621 | + |
|---|
| 622 | + if (ak4458->drvdata->type == AK4497) { |
|---|
| 623 | + ret = snd_soc_component_update_bits(component, AK4458_09_DSD2, |
|---|
| 624 | + 0x4, (ak4458->dsd_path << 2)); |
|---|
| 625 | + if (ret < 0) |
|---|
| 626 | + return ret; |
|---|
| 627 | + } |
|---|
| 513 | 628 | |
|---|
| 514 | 629 | return ak4458_rstn_control(component, 1); |
|---|
| 515 | 630 | } |
|---|
| .. | .. |
|---|
| 527 | 642 | { |
|---|
| 528 | 643 | struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); |
|---|
| 529 | 644 | |
|---|
| 530 | | - ak4458_power_off(ak4458); |
|---|
| 645 | + ak4458_reset(ak4458, true); |
|---|
| 531 | 646 | } |
|---|
| 532 | 647 | |
|---|
| 533 | 648 | #ifdef CONFIG_PM |
|---|
| .. | .. |
|---|
| 537 | 652 | |
|---|
| 538 | 653 | regcache_cache_only(ak4458->regmap, true); |
|---|
| 539 | 654 | |
|---|
| 540 | | - ak4458_power_off(ak4458); |
|---|
| 655 | + ak4458_reset(ak4458, true); |
|---|
| 541 | 656 | |
|---|
| 542 | 657 | if (ak4458->mute_gpiod) |
|---|
| 543 | 658 | gpiod_set_value_cansleep(ak4458->mute_gpiod, 0); |
|---|
| 544 | 659 | |
|---|
| 660 | + regulator_bulk_disable(ARRAY_SIZE(ak4458->supplies), |
|---|
| 661 | + ak4458->supplies); |
|---|
| 545 | 662 | return 0; |
|---|
| 546 | 663 | } |
|---|
| 547 | 664 | |
|---|
| 548 | 665 | static int __maybe_unused ak4458_runtime_resume(struct device *dev) |
|---|
| 549 | 666 | { |
|---|
| 550 | 667 | struct ak4458_priv *ak4458 = dev_get_drvdata(dev); |
|---|
| 668 | + int ret; |
|---|
| 669 | + |
|---|
| 670 | + ret = regulator_bulk_enable(ARRAY_SIZE(ak4458->supplies), |
|---|
| 671 | + ak4458->supplies); |
|---|
| 672 | + if (ret != 0) { |
|---|
| 673 | + dev_err(ak4458->dev, "Failed to enable supplies: %d\n", ret); |
|---|
| 674 | + return ret; |
|---|
| 675 | + } |
|---|
| 551 | 676 | |
|---|
| 552 | 677 | if (ak4458->mute_gpiod) |
|---|
| 553 | 678 | gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); |
|---|
| 554 | 679 | |
|---|
| 555 | | - ak4458_power_off(ak4458); |
|---|
| 556 | | - ak4458_power_on(ak4458); |
|---|
| 680 | + ak4458_reset(ak4458, true); |
|---|
| 681 | + ak4458_reset(ak4458, false); |
|---|
| 557 | 682 | |
|---|
| 558 | 683 | regcache_cache_only(ak4458->regmap, false); |
|---|
| 559 | 684 | regcache_mark_dirty(ak4458->regmap); |
|---|
| .. | .. |
|---|
| 577 | 702 | .non_legacy_dai_naming = 1, |
|---|
| 578 | 703 | }; |
|---|
| 579 | 704 | |
|---|
| 705 | +static const struct snd_soc_component_driver soc_codec_dev_ak4497 = { |
|---|
| 706 | + .probe = ak4458_probe, |
|---|
| 707 | + .remove = ak4458_remove, |
|---|
| 708 | + .controls = ak4497_snd_controls, |
|---|
| 709 | + .num_controls = ARRAY_SIZE(ak4497_snd_controls), |
|---|
| 710 | + .dapm_widgets = ak4497_dapm_widgets, |
|---|
| 711 | + .num_dapm_widgets = ARRAY_SIZE(ak4497_dapm_widgets), |
|---|
| 712 | + .dapm_routes = ak4497_intercon, |
|---|
| 713 | + .num_dapm_routes = ARRAY_SIZE(ak4497_intercon), |
|---|
| 714 | + .idle_bias_on = 1, |
|---|
| 715 | + .use_pmdown_time = 1, |
|---|
| 716 | + .endianness = 1, |
|---|
| 717 | + .non_legacy_dai_naming = 1, |
|---|
| 718 | +}; |
|---|
| 719 | + |
|---|
| 580 | 720 | static const struct regmap_config ak4458_regmap = { |
|---|
| 581 | 721 | .reg_bits = 8, |
|---|
| 582 | 722 | .val_bits = 8, |
|---|
| .. | .. |
|---|
| 585 | 725 | .reg_defaults = ak4458_reg_defaults, |
|---|
| 586 | 726 | .num_reg_defaults = ARRAY_SIZE(ak4458_reg_defaults), |
|---|
| 587 | 727 | .cache_type = REGCACHE_RBTREE, |
|---|
| 728 | +}; |
|---|
| 729 | + |
|---|
| 730 | +static const struct ak4458_drvdata ak4458_drvdata = { |
|---|
| 731 | + .dai_drv = &ak4458_dai, |
|---|
| 732 | + .comp_drv = &soc_codec_dev_ak4458, |
|---|
| 733 | + .type = AK4458, |
|---|
| 734 | +}; |
|---|
| 735 | + |
|---|
| 736 | +static const struct ak4458_drvdata ak4497_drvdata = { |
|---|
| 737 | + .dai_drv = &ak4497_dai, |
|---|
| 738 | + .comp_drv = &soc_codec_dev_ak4497, |
|---|
| 739 | + .type = AK4497, |
|---|
| 588 | 740 | }; |
|---|
| 589 | 741 | |
|---|
| 590 | 742 | static const struct dev_pm_ops ak4458_pm = { |
|---|
| .. | .. |
|---|
| 596 | 748 | static int ak4458_i2c_probe(struct i2c_client *i2c) |
|---|
| 597 | 749 | { |
|---|
| 598 | 750 | struct ak4458_priv *ak4458; |
|---|
| 599 | | - int ret; |
|---|
| 751 | + int ret, i; |
|---|
| 600 | 752 | |
|---|
| 601 | 753 | ak4458 = devm_kzalloc(&i2c->dev, sizeof(*ak4458), GFP_KERNEL); |
|---|
| 602 | 754 | if (!ak4458) |
|---|
| .. | .. |
|---|
| 609 | 761 | i2c_set_clientdata(i2c, ak4458); |
|---|
| 610 | 762 | ak4458->dev = &i2c->dev; |
|---|
| 611 | 763 | |
|---|
| 764 | + ak4458->drvdata = of_device_get_match_data(&i2c->dev); |
|---|
| 765 | + |
|---|
| 612 | 766 | ak4458->reset_gpiod = devm_gpiod_get_optional(ak4458->dev, "reset", |
|---|
| 613 | 767 | GPIOD_OUT_LOW); |
|---|
| 614 | 768 | if (IS_ERR(ak4458->reset_gpiod)) |
|---|
| .. | .. |
|---|
| 619 | 773 | if (IS_ERR(ak4458->mute_gpiod)) |
|---|
| 620 | 774 | return PTR_ERR(ak4458->mute_gpiod); |
|---|
| 621 | 775 | |
|---|
| 622 | | - ret = devm_snd_soc_register_component(ak4458->dev, &soc_codec_dev_ak4458, |
|---|
| 623 | | - &ak4458_dai, 1); |
|---|
| 776 | + /* Optional property for ak4497 */ |
|---|
| 777 | + of_property_read_u32(i2c->dev.of_node, "dsd-path", &ak4458->dsd_path); |
|---|
| 778 | + |
|---|
| 779 | + for (i = 0; i < ARRAY_SIZE(ak4458->supplies); i++) |
|---|
| 780 | + ak4458->supplies[i].supply = ak4458_supply_names[i]; |
|---|
| 781 | + |
|---|
| 782 | + ret = devm_regulator_bulk_get(ak4458->dev, ARRAY_SIZE(ak4458->supplies), |
|---|
| 783 | + ak4458->supplies); |
|---|
| 784 | + if (ret != 0) { |
|---|
| 785 | + dev_err(ak4458->dev, "Failed to request supplies: %d\n", ret); |
|---|
| 786 | + return ret; |
|---|
| 787 | + } |
|---|
| 788 | + |
|---|
| 789 | + ret = devm_snd_soc_register_component(ak4458->dev, |
|---|
| 790 | + ak4458->drvdata->comp_drv, |
|---|
| 791 | + ak4458->drvdata->dai_drv, 1); |
|---|
| 624 | 792 | if (ret < 0) { |
|---|
| 625 | 793 | dev_err(ak4458->dev, "Failed to register CODEC: %d\n", ret); |
|---|
| 626 | 794 | return ret; |
|---|
| 627 | 795 | } |
|---|
| 628 | 796 | |
|---|
| 629 | 797 | pm_runtime_enable(&i2c->dev); |
|---|
| 798 | + regcache_cache_only(ak4458->regmap, true); |
|---|
| 630 | 799 | |
|---|
| 631 | 800 | return 0; |
|---|
| 632 | 801 | } |
|---|
| .. | .. |
|---|
| 639 | 808 | } |
|---|
| 640 | 809 | |
|---|
| 641 | 810 | static const struct of_device_id ak4458_of_match[] = { |
|---|
| 642 | | - { .compatible = "asahi-kasei,ak4458", }, |
|---|
| 811 | + { .compatible = "asahi-kasei,ak4458", .data = &ak4458_drvdata}, |
|---|
| 812 | + { .compatible = "asahi-kasei,ak4497", .data = &ak4497_drvdata}, |
|---|
| 643 | 813 | { }, |
|---|
| 644 | 814 | }; |
|---|
| 645 | 815 | MODULE_DEVICE_TABLE(of, ak4458_of_match); |
|---|