| .. | .. | 
|---|
|  | 1 | +// SPDX-License-Identifier: GPL-2.0-only | 
|---|
| 1 | 2 | /* | 
|---|
| 2 | 3 | *  skl.c - Implementation of ASoC Intel SKL HD Audio driver | 
|---|
| 3 | 4 | * | 
|---|
| .. | .. | 
|---|
| 8 | 9 | *  Copyright (c) 2004 Takashi Iwai <tiwai@suse.de> | 
|---|
| 9 | 10 | *                     PeiSen Hou <pshou@realtek.com.tw> | 
|---|
| 10 | 11 | *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
|---|
| 11 |  | - * | 
|---|
| 12 |  | - *  This program is free software; you can redistribute it and/or modify | 
|---|
| 13 |  | - *  it under the terms of the GNU General Public License as published by | 
|---|
| 14 |  | - *  the Free Software Foundation; version 2 of the License. | 
|---|
| 15 |  | - * | 
|---|
| 16 |  | - *  This program is distributed in the hope that it will be useful, but | 
|---|
| 17 |  | - *  WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 18 |  | - *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 19 |  | - *  General Public License for more details. | 
|---|
| 20 | 12 | * | 
|---|
| 21 | 13 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
|---|
| 22 | 14 | */ | 
|---|
| .. | .. | 
|---|
| 33 | 25 | #include <sound/hda_register.h> | 
|---|
| 34 | 26 | #include <sound/hdaudio.h> | 
|---|
| 35 | 27 | #include <sound/hda_i915.h> | 
|---|
|  | 28 | +#include <sound/hda_codec.h> | 
|---|
|  | 29 | +#include <sound/intel-nhlt.h> | 
|---|
|  | 30 | +#include <sound/intel-dsp-config.h> | 
|---|
| 36 | 31 | #include "skl.h" | 
|---|
| 37 | 32 | #include "skl-sst-dsp.h" | 
|---|
| 38 | 33 | #include "skl-sst-ipc.h" | 
|---|
|  | 34 | + | 
|---|
|  | 35 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) | 
|---|
|  | 36 | +#include "../../../soc/codecs/hdac_hda.h" | 
|---|
|  | 37 | +#endif | 
|---|
|  | 38 | +static int skl_pci_binding; | 
|---|
|  | 39 | +module_param_named(pci_binding, skl_pci_binding, int, 0444); | 
|---|
|  | 40 | +MODULE_PARM_DESC(pci_binding, "PCI binding (0=auto, 1=only legacy, 2=only asoc"); | 
|---|
| 39 | 41 |  | 
|---|
| 40 | 42 | /* | 
|---|
| 41 | 43 | * initialize the PCI registers | 
|---|
| .. | .. | 
|---|
| 51 | 53 | pci_write_config_byte(pci, reg, data); | 
|---|
| 52 | 54 | } | 
|---|
| 53 | 55 |  | 
|---|
| 54 |  | -static void skl_init_pci(struct skl *skl) | 
|---|
|  | 56 | +static void skl_init_pci(struct skl_dev *skl) | 
|---|
| 55 | 57 | { | 
|---|
| 56 | 58 | struct hdac_bus *bus = skl_to_bus(skl); | 
|---|
| 57 | 59 |  | 
|---|
| .. | .. | 
|---|
| 128 | 130 | struct hdac_ext_link *hlink; | 
|---|
| 129 | 131 | int ret; | 
|---|
| 130 | 132 |  | 
|---|
|  | 133 | +	snd_hdac_set_codec_wakeup(bus, true); | 
|---|
| 131 | 134 | skl_enable_miscbdcge(bus->dev, false); | 
|---|
| 132 | 135 | ret = snd_hdac_bus_init_chip(bus, full_reset); | 
|---|
| 133 | 136 |  | 
|---|
| 134 | 137 | /* Reset stream-to-link mapping */ | 
|---|
| 135 | 138 | list_for_each_entry(hlink, &bus->hlink_list, list) | 
|---|
| 136 |  | -		bus->io_ops->reg_writel(0, hlink->ml_addr + AZX_REG_ML_LOSIDV); | 
|---|
|  | 139 | +		writel(0, hlink->ml_addr + AZX_REG_ML_LOSIDV); | 
|---|
| 137 | 140 |  | 
|---|
| 138 | 141 | skl_enable_miscbdcge(bus->dev, true); | 
|---|
|  | 142 | +	snd_hdac_set_codec_wakeup(bus, false); | 
|---|
| 139 | 143 |  | 
|---|
| 140 | 144 | return ret; | 
|---|
| 141 | 145 | } | 
|---|
| .. | .. | 
|---|
| 183 | 187 |  | 
|---|
| 184 | 188 | dev_dbg(bus->dev, "D0I3C register = 0x%x\n", | 
|---|
| 185 | 189 | snd_hdac_chip_readb(bus, VS_D0I3C)); | 
|---|
|  | 190 | +} | 
|---|
|  | 191 | + | 
|---|
|  | 192 | +/** | 
|---|
|  | 193 | + * skl_dum_set - set DUM bit in EM2 register | 
|---|
|  | 194 | + * @bus: HD-audio core bus | 
|---|
|  | 195 | + * | 
|---|
|  | 196 | + * Addresses incorrect position reporting for capture streams. | 
|---|
|  | 197 | + * Used on device power up. | 
|---|
|  | 198 | + */ | 
|---|
|  | 199 | +static void skl_dum_set(struct hdac_bus *bus) | 
|---|
|  | 200 | +{ | 
|---|
|  | 201 | +	/* For the DUM bit to be set, CRST needs to be out of reset state */ | 
|---|
|  | 202 | +	if (!(snd_hdac_chip_readb(bus, GCTL) & AZX_GCTL_RESET)) { | 
|---|
|  | 203 | +		skl_enable_miscbdcge(bus->dev, false); | 
|---|
|  | 204 | +		snd_hdac_bus_exit_link_reset(bus); | 
|---|
|  | 205 | +		skl_enable_miscbdcge(bus->dev, true); | 
|---|
|  | 206 | +	} | 
|---|
|  | 207 | + | 
|---|
|  | 208 | +	snd_hdac_chip_updatel(bus, VS_EM2, AZX_VS_EM2_DUM, AZX_VS_EM2_DUM); | 
|---|
| 186 | 209 | } | 
|---|
| 187 | 210 |  | 
|---|
| 188 | 211 | /* called from IRQ */ | 
|---|
| .. | .. | 
|---|
| 234 | 257 |  | 
|---|
| 235 | 258 | static int skl_acquire_irq(struct hdac_bus *bus, int do_disconnect) | 
|---|
| 236 | 259 | { | 
|---|
| 237 |  | -	struct skl *skl = bus_to_skl(bus); | 
|---|
|  | 260 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
| 238 | 261 | int ret; | 
|---|
| 239 | 262 |  | 
|---|
| 240 | 263 | ret = request_threaded_irq(skl->pci->irq, skl_interrupt, | 
|---|
| .. | .. | 
|---|
| 258 | 281 | { | 
|---|
| 259 | 282 | struct pci_dev *pci = to_pci_dev(dev); | 
|---|
| 260 | 283 | struct hdac_bus *bus = pci_get_drvdata(pci); | 
|---|
| 261 |  | -	struct skl *skl = bus_to_skl(bus); | 
|---|
|  | 284 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
| 262 | 285 |  | 
|---|
| 263 | 286 | return skl_suspend_late_dsp(skl); | 
|---|
| 264 | 287 | } | 
|---|
| .. | .. | 
|---|
| 266 | 289 | #ifdef CONFIG_PM | 
|---|
| 267 | 290 | static int _skl_suspend(struct hdac_bus *bus) | 
|---|
| 268 | 291 | { | 
|---|
| 269 |  | -	struct skl *skl = bus_to_skl(bus); | 
|---|
|  | 292 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
| 270 | 293 | struct pci_dev *pci = to_pci_dev(bus->dev); | 
|---|
| 271 | 294 | int ret; | 
|---|
| 272 | 295 |  | 
|---|
| .. | .. | 
|---|
| 289 | 312 |  | 
|---|
| 290 | 313 | static int _skl_resume(struct hdac_bus *bus) | 
|---|
| 291 | 314 | { | 
|---|
| 292 |  | -	struct skl *skl = bus_to_skl(bus); | 
|---|
|  | 315 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
| 293 | 316 |  | 
|---|
| 294 | 317 | skl_init_pci(skl); | 
|---|
|  | 318 | +	skl_dum_set(bus); | 
|---|
| 295 | 319 | skl_init_chip(bus, true); | 
|---|
| 296 | 320 |  | 
|---|
| 297 | 321 | return skl_resume_dsp(skl); | 
|---|
| .. | .. | 
|---|
| 306 | 330 | { | 
|---|
| 307 | 331 | struct pci_dev *pci = to_pci_dev(dev); | 
|---|
| 308 | 332 | struct hdac_bus *bus = pci_get_drvdata(pci); | 
|---|
| 309 |  | -	struct skl *skl  = bus_to_skl(bus); | 
|---|
| 310 |  | -	int ret = 0; | 
|---|
|  | 333 | +	struct skl_dev *skl  = bus_to_skl(bus); | 
|---|
|  | 334 | +	int ret; | 
|---|
| 311 | 335 |  | 
|---|
| 312 | 336 | /* | 
|---|
| 313 | 337 | * Do not suspend if streams which are marked ignore suspend are | 
|---|
| .. | .. | 
|---|
| 326 | 350 | ret = _skl_suspend(bus); | 
|---|
| 327 | 351 | if (ret < 0) | 
|---|
| 328 | 352 | return ret; | 
|---|
| 329 |  | -		skl->skl_sst->fw_loaded = false; | 
|---|
|  | 353 | +		skl->fw_loaded = false; | 
|---|
| 330 | 354 | } | 
|---|
| 331 | 355 |  | 
|---|
| 332 |  | -	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { | 
|---|
| 333 |  | -		ret = snd_hdac_display_power(bus, false); | 
|---|
| 334 |  | -		if (ret < 0) | 
|---|
| 335 |  | -			dev_err(bus->dev, | 
|---|
| 336 |  | -				"Cannot turn OFF display power on i915\n"); | 
|---|
| 337 |  | -	} | 
|---|
| 338 |  | - | 
|---|
| 339 |  | -	return ret; | 
|---|
|  | 356 | +	return 0; | 
|---|
| 340 | 357 | } | 
|---|
| 341 | 358 |  | 
|---|
| 342 | 359 | static int skl_resume(struct device *dev) | 
|---|
| 343 | 360 | { | 
|---|
| 344 | 361 | struct pci_dev *pci = to_pci_dev(dev); | 
|---|
| 345 | 362 | struct hdac_bus *bus = pci_get_drvdata(pci); | 
|---|
| 346 |  | -	struct skl *skl  = bus_to_skl(bus); | 
|---|
| 347 |  | -	struct hdac_ext_link *hlink = NULL; | 
|---|
|  | 363 | +	struct skl_dev *skl  = bus_to_skl(bus); | 
|---|
|  | 364 | +	struct hdac_ext_link *hlink; | 
|---|
| 348 | 365 | int ret; | 
|---|
| 349 |  | - | 
|---|
| 350 |  | -	/* Turned OFF in HDMI codec driver after codec reconfiguration */ | 
|---|
| 351 |  | -	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { | 
|---|
| 352 |  | -		ret = snd_hdac_display_power(bus, true); | 
|---|
| 353 |  | -		if (ret < 0) { | 
|---|
| 354 |  | -			dev_err(bus->dev, | 
|---|
| 355 |  | -				"Cannot turn on display power on i915\n"); | 
|---|
| 356 |  | -			return ret; | 
|---|
| 357 |  | -		} | 
|---|
| 358 |  | -	} | 
|---|
| 359 | 366 |  | 
|---|
| 360 | 367 | /* | 
|---|
| 361 | 368 | * resume only when we are not in suspend active, otherwise need to | 
|---|
| .. | .. | 
|---|
| 428 | 435 | */ | 
|---|
| 429 | 436 | static int skl_free(struct hdac_bus *bus) | 
|---|
| 430 | 437 | { | 
|---|
| 431 |  | -	struct skl *skl  = bus_to_skl(bus); | 
|---|
|  | 438 | +	struct skl_dev *skl  = bus_to_skl(bus); | 
|---|
| 432 | 439 |  | 
|---|
| 433 | 440 | skl->init_done = 0; /* to be sure */ | 
|---|
| 434 | 441 |  | 
|---|
| 435 |  | -	snd_hdac_ext_stop_streams(bus); | 
|---|
|  | 442 | +	snd_hdac_stop_streams_and_chip(bus); | 
|---|
| 436 | 443 |  | 
|---|
| 437 | 444 | if (bus->irq >= 0) | 
|---|
| 438 | 445 | free_irq(bus->irq, (void *)bus); | 
|---|
| .. | .. | 
|---|
| 448 | 455 |  | 
|---|
| 449 | 456 | snd_hdac_ext_bus_exit(bus); | 
|---|
| 450 | 457 |  | 
|---|
| 451 |  | -	cancel_work_sync(&skl->probe_work); | 
|---|
| 452 |  | -	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) | 
|---|
|  | 458 | +	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { | 
|---|
|  | 459 | +		snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); | 
|---|
| 453 | 460 | snd_hdac_i915_exit(bus); | 
|---|
|  | 461 | +	} | 
|---|
| 454 | 462 |  | 
|---|
| 455 | 463 | return 0; | 
|---|
| 456 | 464 | } | 
|---|
| .. | .. | 
|---|
| 472 | 480 | {.name = "ssp5_sclkfs"}, | 
|---|
| 473 | 481 | }; | 
|---|
| 474 | 482 |  | 
|---|
| 475 |  | -static int skl_find_machine(struct skl *skl, void *driver_data) | 
|---|
|  | 483 | +static struct snd_soc_acpi_mach *skl_find_hda_machine(struct skl_dev *skl, | 
|---|
|  | 484 | +					struct snd_soc_acpi_mach *machines) | 
|---|
|  | 485 | +{ | 
|---|
|  | 486 | +	struct snd_soc_acpi_mach *mach; | 
|---|
|  | 487 | + | 
|---|
|  | 488 | +	/* point to common table */ | 
|---|
|  | 489 | +	mach = snd_soc_acpi_intel_hda_machines; | 
|---|
|  | 490 | + | 
|---|
|  | 491 | +	/* all entries in the machine table use the same firmware */ | 
|---|
|  | 492 | +	mach->fw_filename = machines->fw_filename; | 
|---|
|  | 493 | + | 
|---|
|  | 494 | +	return mach; | 
|---|
|  | 495 | +} | 
|---|
|  | 496 | + | 
|---|
|  | 497 | +static int skl_find_machine(struct skl_dev *skl, void *driver_data) | 
|---|
| 476 | 498 | { | 
|---|
| 477 | 499 | struct hdac_bus *bus = skl_to_bus(skl); | 
|---|
| 478 | 500 | struct snd_soc_acpi_mach *mach = driver_data; | 
|---|
| 479 | 501 | struct skl_machine_pdata *pdata; | 
|---|
| 480 | 502 |  | 
|---|
| 481 | 503 | mach = snd_soc_acpi_find_machine(mach); | 
|---|
| 482 |  | -	if (mach == NULL) { | 
|---|
| 483 |  | -		dev_err(bus->dev, "No matching machine driver found\n"); | 
|---|
| 484 |  | -		return -ENODEV; | 
|---|
|  | 504 | +	if (!mach) { | 
|---|
|  | 505 | +		dev_dbg(bus->dev, "No matching I2S machine driver found\n"); | 
|---|
|  | 506 | +		mach = skl_find_hda_machine(skl, driver_data); | 
|---|
|  | 507 | +		if (!mach) { | 
|---|
|  | 508 | +			dev_err(bus->dev, "No matching machine driver found\n"); | 
|---|
|  | 509 | +			return -ENODEV; | 
|---|
|  | 510 | +		} | 
|---|
| 485 | 511 | } | 
|---|
| 486 | 512 |  | 
|---|
| 487 | 513 | skl->mach = mach; | 
|---|
| .. | .. | 
|---|
| 490 | 516 |  | 
|---|
| 491 | 517 | if (pdata) { | 
|---|
| 492 | 518 | skl->use_tplg_pcm = pdata->use_tplg_pcm; | 
|---|
| 493 |  | -		pdata->dmic_num = skl_get_dmic_geo(skl); | 
|---|
|  | 519 | +		mach->mach_params.dmic_num = | 
|---|
|  | 520 | +			intel_nhlt_get_dmic_geo(&skl->pci->dev, | 
|---|
|  | 521 | +						skl->nhlt); | 
|---|
| 494 | 522 | } | 
|---|
| 495 | 523 |  | 
|---|
| 496 | 524 | return 0; | 
|---|
| 497 | 525 | } | 
|---|
| 498 | 526 |  | 
|---|
| 499 |  | -static int skl_machine_device_register(struct skl *skl) | 
|---|
|  | 527 | +static int skl_machine_device_register(struct skl_dev *skl) | 
|---|
| 500 | 528 | { | 
|---|
| 501 |  | -	struct hdac_bus *bus = skl_to_bus(skl); | 
|---|
| 502 | 529 | struct snd_soc_acpi_mach *mach = skl->mach; | 
|---|
|  | 530 | +	struct hdac_bus *bus = skl_to_bus(skl); | 
|---|
| 503 | 531 | struct platform_device *pdev; | 
|---|
| 504 | 532 | int ret; | 
|---|
| 505 | 533 |  | 
|---|
| .. | .. | 
|---|
| 509 | 537 | return -EIO; | 
|---|
| 510 | 538 | } | 
|---|
| 511 | 539 |  | 
|---|
|  | 540 | +	mach->mach_params.platform = dev_name(bus->dev); | 
|---|
|  | 541 | +	mach->mach_params.codec_mask = bus->codec_mask; | 
|---|
|  | 542 | + | 
|---|
|  | 543 | +	ret = platform_device_add_data(pdev, (const void *)mach, sizeof(*mach)); | 
|---|
|  | 544 | +	if (ret) { | 
|---|
|  | 545 | +		dev_err(bus->dev, "failed to add machine device platform data\n"); | 
|---|
|  | 546 | +		platform_device_put(pdev); | 
|---|
|  | 547 | +		return ret; | 
|---|
|  | 548 | +	} | 
|---|
|  | 549 | + | 
|---|
| 512 | 550 | ret = platform_device_add(pdev); | 
|---|
| 513 | 551 | if (ret) { | 
|---|
| 514 | 552 | dev_err(bus->dev, "failed to add machine device\n"); | 
|---|
| .. | .. | 
|---|
| 516 | 554 | return -EIO; | 
|---|
| 517 | 555 | } | 
|---|
| 518 | 556 |  | 
|---|
| 519 |  | -	if (mach->pdata) | 
|---|
| 520 |  | -		dev_set_drvdata(&pdev->dev, mach->pdata); | 
|---|
| 521 | 557 |  | 
|---|
| 522 | 558 | skl->i2s_dev = pdev; | 
|---|
| 523 | 559 |  | 
|---|
| 524 | 560 | return 0; | 
|---|
| 525 | 561 | } | 
|---|
| 526 | 562 |  | 
|---|
| 527 |  | -static void skl_machine_device_unregister(struct skl *skl) | 
|---|
|  | 563 | +static void skl_machine_device_unregister(struct skl_dev *skl) | 
|---|
| 528 | 564 | { | 
|---|
| 529 | 565 | if (skl->i2s_dev) | 
|---|
| 530 | 566 | platform_device_unregister(skl->i2s_dev); | 
|---|
| 531 | 567 | } | 
|---|
| 532 | 568 |  | 
|---|
| 533 |  | -static int skl_dmic_device_register(struct skl *skl) | 
|---|
|  | 569 | +static int skl_dmic_device_register(struct skl_dev *skl) | 
|---|
| 534 | 570 | { | 
|---|
| 535 | 571 | struct hdac_bus *bus = skl_to_bus(skl); | 
|---|
| 536 | 572 | struct platform_device *pdev; | 
|---|
| .. | .. | 
|---|
| 554 | 590 | return 0; | 
|---|
| 555 | 591 | } | 
|---|
| 556 | 592 |  | 
|---|
| 557 |  | -static void skl_dmic_device_unregister(struct skl *skl) | 
|---|
|  | 593 | +static void skl_dmic_device_unregister(struct skl_dev *skl) | 
|---|
| 558 | 594 | { | 
|---|
| 559 | 595 | if (skl->dmic_dev) | 
|---|
| 560 | 596 | platform_device_unregister(skl->dmic_dev); | 
|---|
| .. | .. | 
|---|
| 592 | 628 | } | 
|---|
| 593 | 629 | } | 
|---|
| 594 | 630 |  | 
|---|
| 595 |  | -static int skl_clock_device_register(struct skl *skl) | 
|---|
|  | 631 | +static int skl_clock_device_register(struct skl_dev *skl) | 
|---|
| 596 | 632 | { | 
|---|
| 597 | 633 | struct platform_device_info pdevinfo = {NULL}; | 
|---|
| 598 | 634 | struct skl_clk_pdata *clk_pdata; | 
|---|
|  | 635 | + | 
|---|
|  | 636 | +	if (!skl->nhlt) | 
|---|
|  | 637 | +		return 0; | 
|---|
| 599 | 638 |  | 
|---|
| 600 | 639 | clk_pdata = devm_kzalloc(&skl->pci->dev, sizeof(*clk_pdata), | 
|---|
| 601 | 640 | GFP_KERNEL); | 
|---|
| .. | .. | 
|---|
| 622 | 661 | return PTR_ERR_OR_ZERO(skl->clk_dev); | 
|---|
| 623 | 662 | } | 
|---|
| 624 | 663 |  | 
|---|
| 625 |  | -static void skl_clock_device_unregister(struct skl *skl) | 
|---|
|  | 664 | +static void skl_clock_device_unregister(struct skl_dev *skl) | 
|---|
| 626 | 665 | { | 
|---|
| 627 | 666 | if (skl->clk_dev) | 
|---|
| 628 | 667 | platform_device_unregister(skl->clk_dev); | 
|---|
| 629 | 668 | } | 
|---|
|  | 669 | + | 
|---|
|  | 670 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) | 
|---|
|  | 671 | + | 
|---|
|  | 672 | +#define IDISP_INTEL_VENDOR_ID	0x80860000 | 
|---|
|  | 673 | + | 
|---|
|  | 674 | +/* | 
|---|
|  | 675 | + * load the legacy codec driver | 
|---|
|  | 676 | + */ | 
|---|
|  | 677 | +static void load_codec_module(struct hda_codec *codec) | 
|---|
|  | 678 | +{ | 
|---|
|  | 679 | +#ifdef MODULE | 
|---|
|  | 680 | +	char modalias[MODULE_NAME_LEN]; | 
|---|
|  | 681 | +	const char *mod = NULL; | 
|---|
|  | 682 | + | 
|---|
|  | 683 | +	snd_hdac_codec_modalias(&codec->core, modalias, sizeof(modalias)); | 
|---|
|  | 684 | +	mod = modalias; | 
|---|
|  | 685 | +	dev_dbg(&codec->core.dev, "loading %s codec module\n", mod); | 
|---|
|  | 686 | +	request_module(mod); | 
|---|
|  | 687 | +#endif | 
|---|
|  | 688 | +} | 
|---|
|  | 689 | + | 
|---|
|  | 690 | +#endif /* CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC */ | 
|---|
| 630 | 691 |  | 
|---|
| 631 | 692 | /* | 
|---|
| 632 | 693 | * Probe the given codec address | 
|---|
| .. | .. | 
|---|
| 636 | 697 | unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) | | 
|---|
| 637 | 698 | (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID; | 
|---|
| 638 | 699 | unsigned int res = -1; | 
|---|
| 639 |  | -	struct skl *skl = bus_to_skl(bus); | 
|---|
|  | 700 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
|  | 701 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) | 
|---|
|  | 702 | +	struct hdac_hda_priv *hda_codec; | 
|---|
|  | 703 | +	int err; | 
|---|
|  | 704 | +#endif | 
|---|
| 640 | 705 | struct hdac_device *hdev; | 
|---|
| 641 | 706 |  | 
|---|
| 642 | 707 | mutex_lock(&bus->cmd_mutex); | 
|---|
| .. | .. | 
|---|
| 645 | 710 | mutex_unlock(&bus->cmd_mutex); | 
|---|
| 646 | 711 | if (res == -1) | 
|---|
| 647 | 712 | return -EIO; | 
|---|
| 648 |  | -	dev_dbg(bus->dev, "codec #%d probed OK\n", addr); | 
|---|
|  | 713 | +	dev_dbg(bus->dev, "codec #%d probed OK: %x\n", addr, res); | 
|---|
| 649 | 714 |  | 
|---|
|  | 715 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) | 
|---|
|  | 716 | +	hda_codec = devm_kzalloc(&skl->pci->dev, sizeof(*hda_codec), | 
|---|
|  | 717 | +				 GFP_KERNEL); | 
|---|
|  | 718 | +	if (!hda_codec) | 
|---|
|  | 719 | +		return -ENOMEM; | 
|---|
|  | 720 | + | 
|---|
|  | 721 | +	hda_codec->codec.bus = skl_to_hbus(skl); | 
|---|
|  | 722 | +	hdev = &hda_codec->codec.core; | 
|---|
|  | 723 | + | 
|---|
|  | 724 | +	err = snd_hdac_ext_bus_device_init(bus, addr, hdev, HDA_DEV_ASOC); | 
|---|
|  | 725 | +	if (err < 0) | 
|---|
|  | 726 | +		return err; | 
|---|
|  | 727 | + | 
|---|
|  | 728 | +	/* use legacy bus only for HDA codecs, idisp uses ext bus */ | 
|---|
|  | 729 | +	if ((res & 0xFFFF0000) != IDISP_INTEL_VENDOR_ID) { | 
|---|
|  | 730 | +		hdev->type = HDA_DEV_LEGACY; | 
|---|
|  | 731 | +		load_codec_module(&hda_codec->codec); | 
|---|
|  | 732 | +	} | 
|---|
|  | 733 | +	return 0; | 
|---|
|  | 734 | +#else | 
|---|
| 650 | 735 | hdev = devm_kzalloc(&skl->pci->dev, sizeof(*hdev), GFP_KERNEL); | 
|---|
| 651 | 736 | if (!hdev) | 
|---|
| 652 | 737 | return -ENOMEM; | 
|---|
| 653 | 738 |  | 
|---|
| 654 |  | -	return snd_hdac_ext_bus_device_init(bus, addr, hdev); | 
|---|
|  | 739 | +	return snd_hdac_ext_bus_device_init(bus, addr, hdev, HDA_DEV_ASOC); | 
|---|
|  | 740 | +#endif /* CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC */ | 
|---|
| 655 | 741 | } | 
|---|
| 656 | 742 |  | 
|---|
| 657 | 743 | /* Codec initialization */ | 
|---|
| .. | .. | 
|---|
| 687 | 773 | } | 
|---|
| 688 | 774 | } | 
|---|
| 689 | 775 |  | 
|---|
| 690 |  | -static const struct hdac_bus_ops bus_core_ops = { | 
|---|
| 691 |  | -	.command = snd_hdac_bus_send_cmd, | 
|---|
| 692 |  | -	.get_response = snd_hdac_bus_get_response, | 
|---|
| 693 |  | -}; | 
|---|
| 694 |  | - | 
|---|
| 695 | 776 | static int skl_i915_init(struct hdac_bus *bus) | 
|---|
| 696 | 777 | { | 
|---|
| 697 | 778 | int err; | 
|---|
| .. | .. | 
|---|
| 704 | 785 | if (err < 0) | 
|---|
| 705 | 786 | return err; | 
|---|
| 706 | 787 |  | 
|---|
| 707 |  | -	err = snd_hdac_display_power(bus, true); | 
|---|
| 708 |  | -	if (err < 0) | 
|---|
| 709 |  | -		dev_err(bus->dev, "Cannot turn on display power on i915\n"); | 
|---|
|  | 788 | +	snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true); | 
|---|
| 710 | 789 |  | 
|---|
| 711 |  | -	return err; | 
|---|
|  | 790 | +	return 0; | 
|---|
| 712 | 791 | } | 
|---|
| 713 | 792 |  | 
|---|
| 714 | 793 | static void skl_probe_work(struct work_struct *work) | 
|---|
| 715 | 794 | { | 
|---|
| 716 |  | -	struct skl *skl = container_of(work, struct skl, probe_work); | 
|---|
|  | 795 | +	struct skl_dev *skl = container_of(work, struct skl_dev, probe_work); | 
|---|
| 717 | 796 | struct hdac_bus *bus = skl_to_bus(skl); | 
|---|
| 718 |  | -	struct hdac_ext_link *hlink = NULL; | 
|---|
|  | 797 | +	struct hdac_ext_link *hlink; | 
|---|
| 719 | 798 | int err; | 
|---|
| 720 | 799 |  | 
|---|
| 721 | 800 | if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { | 
|---|
| .. | .. | 
|---|
| 723 | 802 | if (err < 0) | 
|---|
| 724 | 803 | return; | 
|---|
| 725 | 804 | } | 
|---|
|  | 805 | + | 
|---|
|  | 806 | +	skl_init_pci(skl); | 
|---|
|  | 807 | +	skl_dum_set(bus); | 
|---|
| 726 | 808 |  | 
|---|
| 727 | 809 | err = skl_init_chip(bus, true); | 
|---|
| 728 | 810 | if (err < 0) { | 
|---|
| .. | .. | 
|---|
| 741 | 823 | err = skl_platform_register(bus->dev); | 
|---|
| 742 | 824 | if (err < 0) { | 
|---|
| 743 | 825 | dev_err(bus->dev, "platform register failed: %d\n", err); | 
|---|
| 744 |  | -		return; | 
|---|
|  | 826 | +		goto out_err; | 
|---|
| 745 | 827 | } | 
|---|
| 746 | 828 |  | 
|---|
| 747 |  | -	if (bus->ppcap) { | 
|---|
| 748 |  | -		err = skl_machine_device_register(skl); | 
|---|
| 749 |  | -		if (err < 0) { | 
|---|
| 750 |  | -			dev_err(bus->dev, "machine register failed: %d\n", err); | 
|---|
| 751 |  | -			goto out_err; | 
|---|
| 752 |  | -		} | 
|---|
|  | 829 | +	err = skl_machine_device_register(skl); | 
|---|
|  | 830 | +	if (err < 0) { | 
|---|
|  | 831 | +		dev_err(bus->dev, "machine register failed: %d\n", err); | 
|---|
|  | 832 | +		goto out_err; | 
|---|
| 753 | 833 | } | 
|---|
| 754 | 834 |  | 
|---|
| 755 | 835 | /* | 
|---|
| .. | .. | 
|---|
| 758 | 838 | list_for_each_entry(hlink, &bus->hlink_list, list) | 
|---|
| 759 | 839 | snd_hdac_ext_bus_link_put(bus, hlink); | 
|---|
| 760 | 840 |  | 
|---|
| 761 |  | -	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { | 
|---|
| 762 |  | -		err = snd_hdac_display_power(bus, false); | 
|---|
| 763 |  | -		if (err < 0) { | 
|---|
| 764 |  | -			dev_err(bus->dev, "Cannot turn off display power on i915\n"); | 
|---|
| 765 |  | -			skl_machine_device_unregister(skl); | 
|---|
| 766 |  | -			return; | 
|---|
| 767 |  | -		} | 
|---|
| 768 |  | -	} | 
|---|
|  | 841 | +	if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) | 
|---|
|  | 842 | +		snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); | 
|---|
| 769 | 843 |  | 
|---|
| 770 | 844 | /* configure PM */ | 
|---|
| 771 | 845 | pm_runtime_put_noidle(bus->dev); | 
|---|
| .. | .. | 
|---|
| 776 | 850 |  | 
|---|
| 777 | 851 | out_err: | 
|---|
| 778 | 852 | if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) | 
|---|
| 779 |  | -		err = snd_hdac_display_power(bus, false); | 
|---|
|  | 853 | +		snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); | 
|---|
| 780 | 854 | } | 
|---|
| 781 | 855 |  | 
|---|
| 782 | 856 | /* | 
|---|
| 783 | 857 | * constructor | 
|---|
| 784 | 858 | */ | 
|---|
| 785 | 859 | static int skl_create(struct pci_dev *pci, | 
|---|
| 786 |  | -		      const struct hdac_io_ops *io_ops, | 
|---|
| 787 |  | -		      struct skl **rskl) | 
|---|
|  | 860 | +		      struct skl_dev **rskl) | 
|---|
| 788 | 861 | { | 
|---|
| 789 |  | -	struct skl *skl; | 
|---|
|  | 862 | +	struct hdac_ext_bus_ops *ext_ops = NULL; | 
|---|
|  | 863 | +	struct skl_dev *skl; | 
|---|
| 790 | 864 | struct hdac_bus *bus; | 
|---|
| 791 |  | - | 
|---|
|  | 865 | +	struct hda_bus *hbus; | 
|---|
| 792 | 866 | int err; | 
|---|
| 793 | 867 |  | 
|---|
| 794 | 868 | *rskl = NULL; | 
|---|
| .. | .. | 
|---|
| 803 | 877 | return -ENOMEM; | 
|---|
| 804 | 878 | } | 
|---|
| 805 | 879 |  | 
|---|
|  | 880 | +	hbus = skl_to_hbus(skl); | 
|---|
| 806 | 881 | bus = skl_to_bus(skl); | 
|---|
| 807 |  | -	snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, io_ops, NULL); | 
|---|
|  | 882 | + | 
|---|
|  | 883 | +	INIT_LIST_HEAD(&skl->ppl_list); | 
|---|
|  | 884 | +	INIT_LIST_HEAD(&skl->bind_list); | 
|---|
|  | 885 | + | 
|---|
|  | 886 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) | 
|---|
|  | 887 | +	ext_ops = snd_soc_hdac_hda_get_ops(); | 
|---|
|  | 888 | +#endif | 
|---|
|  | 889 | +	snd_hdac_ext_bus_init(bus, &pci->dev, NULL, ext_ops); | 
|---|
| 808 | 890 | bus->use_posbuf = 1; | 
|---|
| 809 | 891 | skl->pci = pci; | 
|---|
| 810 | 892 | INIT_WORK(&skl->probe_work, skl_probe_work); | 
|---|
| 811 | 893 | bus->bdl_pos_adj = 0; | 
|---|
|  | 894 | + | 
|---|
|  | 895 | +	mutex_init(&hbus->prepare_mutex); | 
|---|
|  | 896 | +	hbus->pci = pci; | 
|---|
|  | 897 | +	hbus->mixer_assigned = -1; | 
|---|
|  | 898 | +	hbus->modelname = "sklbus"; | 
|---|
| 812 | 899 |  | 
|---|
| 813 | 900 | *rskl = skl; | 
|---|
| 814 | 901 |  | 
|---|
| .. | .. | 
|---|
| 817 | 904 |  | 
|---|
| 818 | 905 | static int skl_first_init(struct hdac_bus *bus) | 
|---|
| 819 | 906 | { | 
|---|
| 820 |  | -	struct skl *skl = bus_to_skl(bus); | 
|---|
|  | 907 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
| 821 | 908 | struct pci_dev *pci = skl->pci; | 
|---|
| 822 | 909 | int err; | 
|---|
| 823 | 910 | unsigned short gcap; | 
|---|
| .. | .. | 
|---|
| 834 | 921 | return -ENXIO; | 
|---|
| 835 | 922 | } | 
|---|
| 836 | 923 |  | 
|---|
| 837 |  | -	snd_hdac_bus_reset_link(bus, true); | 
|---|
| 838 |  | - | 
|---|
| 839 | 924 | snd_hdac_bus_parse_capabilities(bus); | 
|---|
|  | 925 | + | 
|---|
|  | 926 | +	/* check if PPCAP exists */ | 
|---|
|  | 927 | +	if (!bus->ppcap) { | 
|---|
|  | 928 | +		dev_err(bus->dev, "bus ppcap not set, HDAudio or DSP not present?\n"); | 
|---|
|  | 929 | +		return -ENODEV; | 
|---|
|  | 930 | +	} | 
|---|
| 840 | 931 |  | 
|---|
| 841 | 932 | if (skl_acquire_irq(bus, 0) < 0) | 
|---|
| 842 | 933 | return -EBUSY; | 
|---|
| .. | .. | 
|---|
| 847 | 938 | gcap = snd_hdac_chip_readw(bus, GCAP); | 
|---|
| 848 | 939 | dev_dbg(bus->dev, "chipset global capabilities = 0x%x\n", gcap); | 
|---|
| 849 | 940 |  | 
|---|
|  | 941 | +	/* read number of streams from GCAP register */ | 
|---|
|  | 942 | +	cp_streams = (gcap >> 8) & 0x0f; | 
|---|
|  | 943 | +	pb_streams = (gcap >> 12) & 0x0f; | 
|---|
|  | 944 | + | 
|---|
|  | 945 | +	if (!pb_streams && !cp_streams) { | 
|---|
|  | 946 | +		dev_err(bus->dev, "no streams found in GCAP definitions?\n"); | 
|---|
|  | 947 | +		return -EIO; | 
|---|
|  | 948 | +	} | 
|---|
|  | 949 | + | 
|---|
|  | 950 | +	bus->num_streams = cp_streams + pb_streams; | 
|---|
|  | 951 | + | 
|---|
| 850 | 952 | /* allow 64bit DMA address if supported by H/W */ | 
|---|
| 851 | 953 | if (!dma_set_mask(bus->dev, DMA_BIT_MASK(64))) { | 
|---|
| 852 | 954 | dma_set_coherent_mask(bus->dev, DMA_BIT_MASK(64)); | 
|---|
| .. | .. | 
|---|
| 854 | 956 | dma_set_mask(bus->dev, DMA_BIT_MASK(32)); | 
|---|
| 855 | 957 | dma_set_coherent_mask(bus->dev, DMA_BIT_MASK(32)); | 
|---|
| 856 | 958 | } | 
|---|
| 857 |  | - | 
|---|
| 858 |  | -	/* read number of streams from GCAP register */ | 
|---|
| 859 |  | -	cp_streams = (gcap >> 8) & 0x0f; | 
|---|
| 860 |  | -	pb_streams = (gcap >> 12) & 0x0f; | 
|---|
| 861 |  | - | 
|---|
| 862 |  | -	if (!pb_streams && !cp_streams) | 
|---|
| 863 |  | -		return -EIO; | 
|---|
| 864 |  | - | 
|---|
| 865 |  | -	bus->num_streams = cp_streams + pb_streams; | 
|---|
| 866 | 959 |  | 
|---|
| 867 | 960 | /* initialize streams */ | 
|---|
| 868 | 961 | snd_hdac_ext_stream_init_all | 
|---|
| .. | .. | 
|---|
| 875 | 968 | if (err < 0) | 
|---|
| 876 | 969 | return err; | 
|---|
| 877 | 970 |  | 
|---|
| 878 |  | -	/* initialize chip */ | 
|---|
| 879 |  | -	skl_init_pci(skl); | 
|---|
| 880 |  | - | 
|---|
| 881 |  | -	return skl_init_chip(bus, true); | 
|---|
|  | 971 | +	return 0; | 
|---|
| 882 | 972 | } | 
|---|
| 883 | 973 |  | 
|---|
| 884 | 974 | static int skl_probe(struct pci_dev *pci, | 
|---|
| 885 | 975 | const struct pci_device_id *pci_id) | 
|---|
| 886 | 976 | { | 
|---|
| 887 |  | -	struct skl *skl; | 
|---|
|  | 977 | +	struct skl_dev *skl; | 
|---|
| 888 | 978 | struct hdac_bus *bus = NULL; | 
|---|
| 889 | 979 | int err; | 
|---|
| 890 | 980 |  | 
|---|
|  | 981 | +	switch (skl_pci_binding) { | 
|---|
|  | 982 | +	case SND_SKL_PCI_BIND_AUTO: | 
|---|
|  | 983 | +		err = snd_intel_dsp_driver_probe(pci); | 
|---|
|  | 984 | +		if (err != SND_INTEL_DSP_DRIVER_ANY && | 
|---|
|  | 985 | +		    err != SND_INTEL_DSP_DRIVER_SST) | 
|---|
|  | 986 | +			return -ENODEV; | 
|---|
|  | 987 | +		break; | 
|---|
|  | 988 | +	case SND_SKL_PCI_BIND_LEGACY: | 
|---|
|  | 989 | +		dev_info(&pci->dev, "Module parameter forced binding with HDAudio legacy, aborting probe\n"); | 
|---|
|  | 990 | +		return -ENODEV; | 
|---|
|  | 991 | +	case SND_SKL_PCI_BIND_ASOC: | 
|---|
|  | 992 | +		dev_info(&pci->dev, "Module parameter forced binding with SKL driver, bypassed detection logic\n"); | 
|---|
|  | 993 | +		break; | 
|---|
|  | 994 | +	default: | 
|---|
|  | 995 | +		dev_err(&pci->dev, "invalid value for skl_pci_binding module parameter, ignored\n"); | 
|---|
|  | 996 | +		break; | 
|---|
|  | 997 | +	} | 
|---|
|  | 998 | + | 
|---|
| 891 | 999 | /* we use ext core ops, so provide NULL for ops here */ | 
|---|
| 892 |  | -	err = skl_create(pci, NULL, &skl); | 
|---|
|  | 1000 | +	err = skl_create(pci, &skl); | 
|---|
| 893 | 1001 | if (err < 0) | 
|---|
| 894 | 1002 | return err; | 
|---|
| 895 | 1003 |  | 
|---|
| 896 | 1004 | bus = skl_to_bus(skl); | 
|---|
| 897 | 1005 |  | 
|---|
| 898 | 1006 | err = skl_first_init(bus); | 
|---|
| 899 |  | -	if (err < 0) | 
|---|
|  | 1007 | +	if (err < 0) { | 
|---|
|  | 1008 | +		dev_err(bus->dev, "skl_first_init failed with err: %d\n", err); | 
|---|
| 900 | 1009 | goto out_free; | 
|---|
|  | 1010 | +	} | 
|---|
| 901 | 1011 |  | 
|---|
| 902 | 1012 | skl->pci_id = pci->device; | 
|---|
| 903 | 1013 |  | 
|---|
| 904 | 1014 | device_disable_async_suspend(bus->dev); | 
|---|
| 905 | 1015 |  | 
|---|
| 906 |  | -	skl->nhlt = skl_nhlt_init(bus->dev); | 
|---|
|  | 1016 | +	skl->nhlt = intel_nhlt_init(bus->dev); | 
|---|
| 907 | 1017 |  | 
|---|
| 908 | 1018 | if (skl->nhlt == NULL) { | 
|---|
|  | 1019 | +#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) | 
|---|
|  | 1020 | +		dev_err(bus->dev, "no nhlt info found\n"); | 
|---|
| 909 | 1021 | err = -ENODEV; | 
|---|
| 910 | 1022 | goto out_free; | 
|---|
|  | 1023 | +#else | 
|---|
|  | 1024 | +		dev_warn(bus->dev, "no nhlt info found, continuing to try to enable HDAudio codec\n"); | 
|---|
|  | 1025 | +#endif | 
|---|
|  | 1026 | +	} else { | 
|---|
|  | 1027 | + | 
|---|
|  | 1028 | +		err = skl_nhlt_create_sysfs(skl); | 
|---|
|  | 1029 | +		if (err < 0) { | 
|---|
|  | 1030 | +			dev_err(bus->dev, "skl_nhlt_create_sysfs failed with err: %d\n", err); | 
|---|
|  | 1031 | +			goto out_nhlt_free; | 
|---|
|  | 1032 | +		} | 
|---|
|  | 1033 | + | 
|---|
|  | 1034 | +		skl_nhlt_update_topology_bin(skl); | 
|---|
|  | 1035 | + | 
|---|
|  | 1036 | +		/* create device for dsp clk */ | 
|---|
|  | 1037 | +		err = skl_clock_device_register(skl); | 
|---|
|  | 1038 | +		if (err < 0) { | 
|---|
|  | 1039 | +			dev_err(bus->dev, "skl_clock_device_register failed with err: %d\n", err); | 
|---|
|  | 1040 | +			goto out_clk_free; | 
|---|
|  | 1041 | +		} | 
|---|
| 911 | 1042 | } | 
|---|
| 912 |  | - | 
|---|
| 913 |  | -	err = skl_nhlt_create_sysfs(skl); | 
|---|
| 914 |  | -	if (err < 0) | 
|---|
| 915 |  | -		goto out_nhlt_free; | 
|---|
| 916 |  | - | 
|---|
| 917 |  | -	skl_nhlt_update_topology_bin(skl); | 
|---|
| 918 | 1043 |  | 
|---|
| 919 | 1044 | pci_set_drvdata(skl->pci, bus); | 
|---|
| 920 | 1045 |  | 
|---|
| 921 |  | -	/* check if dsp is there */ | 
|---|
| 922 |  | -	if (bus->ppcap) { | 
|---|
| 923 |  | -		/* create device for dsp clk */ | 
|---|
| 924 |  | -		err = skl_clock_device_register(skl); | 
|---|
| 925 |  | -		if (err < 0) | 
|---|
| 926 |  | -			goto out_clk_free; | 
|---|
| 927 | 1046 |  | 
|---|
| 928 |  | -		err = skl_find_machine(skl, (void *)pci_id->driver_data); | 
|---|
| 929 |  | -		if (err < 0) | 
|---|
| 930 |  | -			goto out_nhlt_free; | 
|---|
| 931 |  | - | 
|---|
| 932 |  | -		err = skl_init_dsp(skl); | 
|---|
| 933 |  | -		if (err < 0) { | 
|---|
| 934 |  | -			dev_dbg(bus->dev, "error failed to register dsp\n"); | 
|---|
| 935 |  | -			goto out_nhlt_free; | 
|---|
| 936 |  | -		} | 
|---|
| 937 |  | -		skl->skl_sst->enable_miscbdcge = skl_enable_miscbdcge; | 
|---|
| 938 |  | -		skl->skl_sst->clock_power_gating = skl_clock_power_gating; | 
|---|
|  | 1047 | +	err = skl_find_machine(skl, (void *)pci_id->driver_data); | 
|---|
|  | 1048 | +	if (err < 0) { | 
|---|
|  | 1049 | +		dev_err(bus->dev, "skl_find_machine failed with err: %d\n", err); | 
|---|
|  | 1050 | +		goto out_nhlt_free; | 
|---|
| 939 | 1051 | } | 
|---|
|  | 1052 | + | 
|---|
|  | 1053 | +	err = skl_init_dsp(skl); | 
|---|
|  | 1054 | +	if (err < 0) { | 
|---|
|  | 1055 | +		dev_dbg(bus->dev, "error failed to register dsp\n"); | 
|---|
|  | 1056 | +		goto out_nhlt_free; | 
|---|
|  | 1057 | +	} | 
|---|
|  | 1058 | +	skl->enable_miscbdcge = skl_enable_miscbdcge; | 
|---|
|  | 1059 | +	skl->clock_power_gating = skl_clock_power_gating; | 
|---|
|  | 1060 | + | 
|---|
| 940 | 1061 | if (bus->mlcap) | 
|---|
| 941 | 1062 | snd_hdac_ext_bus_get_ml_capabilities(bus); | 
|---|
| 942 | 1063 |  | 
|---|
| 943 |  | -	snd_hdac_bus_stop_chip(bus); | 
|---|
| 944 |  | - | 
|---|
| 945 | 1064 | /* create device for soc dmic */ | 
|---|
| 946 | 1065 | err = skl_dmic_device_register(skl); | 
|---|
| 947 |  | -	if (err < 0) | 
|---|
|  | 1066 | +	if (err < 0) { | 
|---|
|  | 1067 | +		dev_err(bus->dev, "skl_dmic_device_register failed with err: %d\n", err); | 
|---|
| 948 | 1068 | goto out_dsp_free; | 
|---|
|  | 1069 | +	} | 
|---|
| 949 | 1070 |  | 
|---|
| 950 | 1071 | schedule_work(&skl->probe_work); | 
|---|
| 951 | 1072 |  | 
|---|
| .. | .. | 
|---|
| 956 | 1077 | out_clk_free: | 
|---|
| 957 | 1078 | skl_clock_device_unregister(skl); | 
|---|
| 958 | 1079 | out_nhlt_free: | 
|---|
| 959 |  | -	skl_nhlt_free(skl->nhlt); | 
|---|
|  | 1080 | +	if (skl->nhlt) | 
|---|
|  | 1081 | +		intel_nhlt_free(skl->nhlt); | 
|---|
| 960 | 1082 | out_free: | 
|---|
| 961 | 1083 | skl_free(bus); | 
|---|
| 962 | 1084 |  | 
|---|
| .. | .. | 
|---|
| 968 | 1090 | struct hdac_bus *bus = pci_get_drvdata(pci); | 
|---|
| 969 | 1091 | struct hdac_stream *s; | 
|---|
| 970 | 1092 | struct hdac_ext_stream *stream; | 
|---|
| 971 |  | -	struct skl *skl; | 
|---|
|  | 1093 | +	struct skl_dev *skl; | 
|---|
| 972 | 1094 |  | 
|---|
| 973 | 1095 | if (!bus) | 
|---|
| 974 | 1096 | return; | 
|---|
| .. | .. | 
|---|
| 978 | 1100 | if (!skl->init_done) | 
|---|
| 979 | 1101 | return; | 
|---|
| 980 | 1102 |  | 
|---|
| 981 |  | -	snd_hdac_ext_stop_streams(bus); | 
|---|
|  | 1103 | +	snd_hdac_stop_streams(bus); | 
|---|
|  | 1104 | +	snd_hdac_ext_bus_link_power_down_all(bus); | 
|---|
|  | 1105 | +	skl_dsp_sleep(skl->dsp); | 
|---|
|  | 1106 | + | 
|---|
| 982 | 1107 | list_for_each_entry(s, &bus->stream_list, list) { | 
|---|
| 983 | 1108 | stream = stream_to_hdac_ext_stream(s); | 
|---|
| 984 | 1109 | snd_hdac_ext_stream_decouple(bus, stream, false); | 
|---|
| .. | .. | 
|---|
| 990 | 1115 | static void skl_remove(struct pci_dev *pci) | 
|---|
| 991 | 1116 | { | 
|---|
| 992 | 1117 | struct hdac_bus *bus = pci_get_drvdata(pci); | 
|---|
| 993 |  | -	struct skl *skl = bus_to_skl(bus); | 
|---|
|  | 1118 | +	struct skl_dev *skl = bus_to_skl(bus); | 
|---|
| 994 | 1119 |  | 
|---|
| 995 |  | -	release_firmware(skl->tplg); | 
|---|
|  | 1120 | +	cancel_work_sync(&skl->probe_work); | 
|---|
| 996 | 1121 |  | 
|---|
| 997 | 1122 | pm_runtime_get_noresume(&pci->dev); | 
|---|
| 998 | 1123 |  | 
|---|
| 999 | 1124 | /* codec removal, invoke bus_device_remove */ | 
|---|
| 1000 | 1125 | snd_hdac_ext_bus_device_remove(bus); | 
|---|
| 1001 | 1126 |  | 
|---|
| 1002 |  | -	skl->debugfs = NULL; | 
|---|
| 1003 | 1127 | skl_platform_unregister(&pci->dev); | 
|---|
| 1004 | 1128 | skl_free_dsp(skl); | 
|---|
| 1005 | 1129 | skl_machine_device_unregister(skl); | 
|---|
| 1006 | 1130 | skl_dmic_device_unregister(skl); | 
|---|
| 1007 | 1131 | skl_clock_device_unregister(skl); | 
|---|
| 1008 | 1132 | skl_nhlt_remove_sysfs(skl); | 
|---|
| 1009 |  | -	skl_nhlt_free(skl->nhlt); | 
|---|
|  | 1133 | +	if (skl->nhlt) | 
|---|
|  | 1134 | +		intel_nhlt_free(skl->nhlt); | 
|---|
| 1010 | 1135 | skl_free(bus); | 
|---|
| 1011 | 1136 | dev_set_drvdata(&pci->dev, NULL); | 
|---|
| 1012 | 1137 | } | 
|---|
| 1013 | 1138 |  | 
|---|
| 1014 | 1139 | /* PCI IDs */ | 
|---|
| 1015 | 1140 | static const struct pci_device_id skl_ids[] = { | 
|---|
|  | 1141 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKL) | 
|---|
| 1016 | 1142 | /* Sunrise Point-LP */ | 
|---|
| 1017 | 1143 | { PCI_DEVICE(0x8086, 0x9d70), | 
|---|
| 1018 | 1144 | .driver_data = (unsigned long)&snd_soc_acpi_intel_skl_machines}, | 
|---|
|  | 1145 | +#endif | 
|---|
|  | 1146 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL) | 
|---|
| 1019 | 1147 | /* BXT-P */ | 
|---|
| 1020 | 1148 | { PCI_DEVICE(0x8086, 0x5a98), | 
|---|
| 1021 | 1149 | .driver_data = (unsigned long)&snd_soc_acpi_intel_bxt_machines}, | 
|---|
|  | 1150 | +#endif | 
|---|
|  | 1151 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_KBL) | 
|---|
| 1022 | 1152 | /* KBL */ | 
|---|
| 1023 | 1153 | { PCI_DEVICE(0x8086, 0x9D71), | 
|---|
| 1024 | 1154 | .driver_data = (unsigned long)&snd_soc_acpi_intel_kbl_machines}, | 
|---|
|  | 1155 | +#endif | 
|---|
|  | 1156 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_GLK) | 
|---|
| 1025 | 1157 | /* GLK */ | 
|---|
| 1026 | 1158 | { PCI_DEVICE(0x8086, 0x3198), | 
|---|
| 1027 | 1159 | .driver_data = (unsigned long)&snd_soc_acpi_intel_glk_machines}, | 
|---|
|  | 1160 | +#endif | 
|---|
|  | 1161 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CNL) | 
|---|
| 1028 | 1162 | /* CNL */ | 
|---|
| 1029 | 1163 | { PCI_DEVICE(0x8086, 0x9dc8), | 
|---|
| 1030 | 1164 | .driver_data = (unsigned long)&snd_soc_acpi_intel_cnl_machines}, | 
|---|
|  | 1165 | +#endif | 
|---|
|  | 1166 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CFL) | 
|---|
|  | 1167 | +	/* CFL */ | 
|---|
|  | 1168 | +	{ PCI_DEVICE(0x8086, 0xa348), | 
|---|
|  | 1169 | +		.driver_data = (unsigned long)&snd_soc_acpi_intel_cnl_machines}, | 
|---|
|  | 1170 | +#endif | 
|---|
|  | 1171 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CML_LP) | 
|---|
|  | 1172 | +	/* CML-LP */ | 
|---|
|  | 1173 | +	{ PCI_DEVICE(0x8086, 0x02c8), | 
|---|
|  | 1174 | +		.driver_data = (unsigned long)&snd_soc_acpi_intel_cnl_machines}, | 
|---|
|  | 1175 | +#endif | 
|---|
|  | 1176 | +#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CML_H) | 
|---|
|  | 1177 | +	/* CML-H */ | 
|---|
|  | 1178 | +	{ PCI_DEVICE(0x8086, 0x06c8), | 
|---|
|  | 1179 | +		.driver_data = (unsigned long)&snd_soc_acpi_intel_cnl_machines}, | 
|---|
|  | 1180 | +#endif | 
|---|
| 1031 | 1181 | { 0, } | 
|---|
| 1032 | 1182 | }; | 
|---|
| 1033 | 1183 | MODULE_DEVICE_TABLE(pci, skl_ids); | 
|---|