Lines Matching +full:pci +full:- +full:dev
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
11 * Generic PCI interface for ACP device
16 #include <linux/pci.h>
22 #include "../mach-config.h"
35 .end = ACP3x_REG_END - ACP3x_REG_START,
47 static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) in acp_pci_probe() argument
50 struct device *dev = &pci->dev; in acp_pci_probe() local
57 flag = snd_amd_acp_find_config(pci); in acp_pci_probe()
59 return -ENODEV; in acp_pci_probe()
61 chip = devm_kzalloc(&pci->dev, sizeof(*chip), GFP_KERNEL); in acp_pci_probe()
63 return -ENOMEM; in acp_pci_probe()
65 if (pci_enable_device(pci)) in acp_pci_probe()
66 return dev_err_probe(&pci->dev, -ENODEV, in acp_pci_probe()
69 ret = pci_request_regions(pci, "AMD ACP3x audio"); in acp_pci_probe()
71 dev_err(&pci->dev, "pci_request_regions failed\n"); in acp_pci_probe()
72 ret = -ENOMEM; in acp_pci_probe()
76 pci_set_master(pci); in acp_pci_probe()
81 switch (pci->revision) { in acp_pci_probe()
83 chip->name = "acp_asoc_renoir"; in acp_pci_probe()
84 chip->acp_rev = ACP3X_DEV; in acp_pci_probe()
87 chip->name = "acp_asoc_rembrandt"; in acp_pci_probe()
88 chip->acp_rev = ACP6X_DEV; in acp_pci_probe()
91 dev_err(dev, "Unsupported device revision:0x%x\n", pci->revision); in acp_pci_probe()
92 ret = -EINVAL; in acp_pci_probe()
96 dmic_dev = platform_device_register_data(dev, "dmic-codec", PLATFORM_DEVID_NONE, NULL, 0); in acp_pci_probe()
98 dev_err(dev, "failed to create DMIC device\n"); in acp_pci_probe()
103 addr = pci_resource_start(pci, 0); in acp_pci_probe()
104 chip->base = devm_ioremap(&pci->dev, addr, pci_resource_len(pci, 0)); in acp_pci_probe()
105 if (!chip->base) { in acp_pci_probe()
106 ret = -ENOMEM; in acp_pci_probe()
114 res = devm_kcalloc(&pci->dev, num_res, sizeof(struct resource), GFP_KERNEL); in acp_pci_probe()
116 ret = -ENOMEM; in acp_pci_probe()
121 res[i].name = res_acp->name; in acp_pci_probe()
122 res[i].flags = res_acp->flags; in acp_pci_probe()
123 res[i].start = addr + res_acp->start; in acp_pci_probe()
124 res[i].end = addr + res_acp->end; in acp_pci_probe()
125 if (res_acp->flags == IORESOURCE_IRQ) { in acp_pci_probe()
126 res[i].start = pci->irq; in acp_pci_probe()
133 pdevinfo.name = chip->name; in acp_pci_probe()
135 pdevinfo.parent = &pci->dev; in acp_pci_probe()
143 dev_err(&pci->dev, "cannot register %s device\n", pdevinfo.name); in acp_pci_probe()
147 chip->chip_pdev = pdev; in acp_pci_probe()
148 dev_set_drvdata(&pci->dev, chip); in acp_pci_probe()
149 pm_runtime_set_autosuspend_delay(&pci->dev, 2000); in acp_pci_probe()
150 pm_runtime_use_autosuspend(&pci->dev); in acp_pci_probe()
151 pm_runtime_put_noidle(&pci->dev); in acp_pci_probe()
152 pm_runtime_allow(&pci->dev); in acp_pci_probe()
158 pci_release_regions(pci); in acp_pci_probe()
160 pci_disable_device(pci); in acp_pci_probe()
165 static int __maybe_unused snd_acp_suspend(struct device *dev) in snd_acp_suspend() argument
170 chip = dev_get_drvdata(dev); in snd_acp_suspend()
171 ret = acp_deinit(chip->base); in snd_acp_suspend()
173 dev_err(dev, "ACP de-init failed\n"); in snd_acp_suspend()
177 static int __maybe_unused snd_acp_resume(struct device *dev) in snd_acp_resume() argument
184 chip = dev_get_drvdata(dev); in snd_acp_resume()
187 dev_err(dev, "ACP init failed\n"); in snd_acp_resume()
188 if (chip->chip_pdev) { in snd_acp_resume()
189 child = chip->chip_pdev->dev; in snd_acp_resume()
202 static void acp_pci_remove(struct pci_dev *pci) in acp_pci_remove() argument
207 chip = pci_get_drvdata(pci); in acp_pci_remove()
208 pm_runtime_forbid(&pci->dev); in acp_pci_remove()
209 pm_runtime_get_noresume(&pci->dev); in acp_pci_remove()
214 ret = acp_deinit(chip->base); in acp_pci_remove()
216 dev_err(&pci->dev, "ACP de-init failed\n"); in acp_pci_remove()
219 /* PCI IDs */
224 MODULE_DEVICE_TABLE(pci, acp_pci_ids);