Lines Matching +full:pci +full:- +full:dev

1 // SPDX-License-Identifier: GPL-2.0+
3 // AMD Renoir ACP PCI Driver
7 #include <linux/pci.h>
24 * dmic_acpi_check = -1 - Use ACPI/DMI method to detect the DMIC hardware presence at runtime
25 * = 0 - Skip the DMIC device creation and return probe failure
26 * = 1 - Force DMIC support
30 MODULE_PARM_DESC(dmic_acpi_check, "Digital microphone presence (-1=auto, 0=none, 1=force)");
59 return -ETIMEDOUT; in rn_acp_power_on()
76 return -ETIMEDOUT; in rn_acp_power_off()
100 return -ETIMEDOUT; in rn_acp_reset()
168 /* Lenovo IdeaPad S340-14API */
205 static int snd_rn_acp_probe(struct pci_dev *pci, in snd_rn_acp_probe() argument
220 flag = snd_amd_acp_find_config(pci); in snd_rn_acp_probe()
222 return -ENODEV; in snd_rn_acp_probe()
225 if (pci->revision != 0x01) in snd_rn_acp_probe()
226 return -ENODEV; in snd_rn_acp_probe()
228 if (pci_enable_device(pci)) { in snd_rn_acp_probe()
229 dev_err(&pci->dev, "pci_enable_device failed\n"); in snd_rn_acp_probe()
230 return -ENODEV; in snd_rn_acp_probe()
233 ret = pci_request_regions(pci, "AMD ACP3x audio"); in snd_rn_acp_probe()
235 dev_err(&pci->dev, "pci_request_regions failed\n"); in snd_rn_acp_probe()
239 adata = devm_kzalloc(&pci->dev, sizeof(struct acp_dev_data), in snd_rn_acp_probe()
242 ret = -ENOMEM; in snd_rn_acp_probe()
247 ret = pci_enable_msi(pci); in snd_rn_acp_probe()
255 addr = pci_resource_start(pci, 0); in snd_rn_acp_probe()
256 adata->acp_base = devm_ioremap(&pci->dev, addr, in snd_rn_acp_probe()
257 pci_resource_len(pci, 0)); in snd_rn_acp_probe()
258 if (!adata->acp_base) { in snd_rn_acp_probe()
259 ret = -ENOMEM; in snd_rn_acp_probe()
262 pci_set_master(pci); in snd_rn_acp_probe()
263 pci_set_drvdata(pci, adata); in snd_rn_acp_probe()
264 ret = rn_acp_init(adata->acp_base); in snd_rn_acp_probe()
269 ret = -ENODEV; in snd_rn_acp_probe()
273 handle = ACPI_HANDLE(&pci->dev); in snd_rn_acp_probe()
276 ret = -ENODEV; in snd_rn_acp_probe()
280 ret = -ENODEV; in snd_rn_acp_probe()
285 if (dmi_id && !dmi_id->driver_data) { in snd_rn_acp_probe()
286 dev_info(&pci->dev, "ACPI settings override using DMI (ACP mic is not present)"); in snd_rn_acp_probe()
287 ret = -ENODEV; in snd_rn_acp_probe()
292 adata->res = devm_kzalloc(&pci->dev, in snd_rn_acp_probe()
295 if (!adata->res) { in snd_rn_acp_probe()
296 ret = -ENOMEM; in snd_rn_acp_probe()
300 adata->res[0].name = "acp_pdm_iomem"; in snd_rn_acp_probe()
301 adata->res[0].flags = IORESOURCE_MEM; in snd_rn_acp_probe()
302 adata->res[0].start = addr; in snd_rn_acp_probe()
303 adata->res[0].end = addr + (ACP_REG_END - ACP_REG_START); in snd_rn_acp_probe()
304 adata->res[1].name = "acp_pdm_irq"; in snd_rn_acp_probe()
305 adata->res[1].flags = IORESOURCE_IRQ; in snd_rn_acp_probe()
306 adata->res[1].start = pci->irq; in snd_rn_acp_probe()
307 adata->res[1].end = pci->irq; in snd_rn_acp_probe()
312 pdevinfo[0].parent = &pci->dev; in snd_rn_acp_probe()
314 pdevinfo[0].res = adata->res; in snd_rn_acp_probe()
318 pdevinfo[1].name = "dmic-codec"; in snd_rn_acp_probe()
320 pdevinfo[1].parent = &pci->dev; in snd_rn_acp_probe()
323 pdevinfo[2].parent = &pci->dev; in snd_rn_acp_probe()
325 adata->pdev[index] = in snd_rn_acp_probe()
327 if (IS_ERR(adata->pdev[index])) { in snd_rn_acp_probe()
328 dev_err(&pci->dev, "cannot register %s device\n", in snd_rn_acp_probe()
330 ret = PTR_ERR(adata->pdev[index]); in snd_rn_acp_probe()
334 pm_runtime_set_autosuspend_delay(&pci->dev, ACP_SUSPEND_DELAY_MS); in snd_rn_acp_probe()
335 pm_runtime_use_autosuspend(&pci->dev); in snd_rn_acp_probe()
336 pm_runtime_put_noidle(&pci->dev); in snd_rn_acp_probe()
337 pm_runtime_allow(&pci->dev); in snd_rn_acp_probe()
342 platform_device_unregister(adata->pdev[index]); in snd_rn_acp_probe()
344 if (rn_acp_deinit(adata->acp_base)) in snd_rn_acp_probe()
345 dev_err(&pci->dev, "ACP de-init failed\n"); in snd_rn_acp_probe()
347 pci_disable_msi(pci); in snd_rn_acp_probe()
349 pci_release_regions(pci); in snd_rn_acp_probe()
351 pci_disable_device(pci); in snd_rn_acp_probe()
356 static int snd_rn_acp_suspend(struct device *dev) in snd_rn_acp_suspend() argument
361 adata = dev_get_drvdata(dev); in snd_rn_acp_suspend()
362 ret = rn_acp_deinit(adata->acp_base); in snd_rn_acp_suspend()
364 dev_err(dev, "ACP de-init failed\n"); in snd_rn_acp_suspend()
366 dev_dbg(dev, "ACP de-initialized\n"); in snd_rn_acp_suspend()
371 static int snd_rn_acp_resume(struct device *dev) in snd_rn_acp_resume() argument
376 adata = dev_get_drvdata(dev); in snd_rn_acp_resume()
377 ret = rn_acp_init(adata->acp_base); in snd_rn_acp_resume()
379 dev_err(dev, "ACP init failed\n"); in snd_rn_acp_resume()
394 static void snd_rn_acp_remove(struct pci_dev *pci) in snd_rn_acp_remove() argument
399 adata = pci_get_drvdata(pci); in snd_rn_acp_remove()
401 platform_device_unregister(adata->pdev[index]); in snd_rn_acp_remove()
402 ret = rn_acp_deinit(adata->acp_base); in snd_rn_acp_remove()
404 dev_err(&pci->dev, "ACP de-init failed\n"); in snd_rn_acp_remove()
405 pm_runtime_forbid(&pci->dev); in snd_rn_acp_remove()
406 pm_runtime_get_noresume(&pci->dev); in snd_rn_acp_remove()
407 pci_disable_msi(pci); in snd_rn_acp_remove()
408 pci_release_regions(pci); in snd_rn_acp_remove()
409 pci_disable_device(pci); in snd_rn_acp_remove()
418 MODULE_DEVICE_TABLE(pci, snd_rn_acp_ids);
433 MODULE_DESCRIPTION("AMD ACP Renoir PCI driver");