Lines Matching +full:pci +full:- +full:dev
1 // SPDX-License-Identifier: GPL-2.0+
3 * AMD Yellow Carp ACP PCI Driver
8 #include <linux/pci.h>
45 return -ETIMEDOUT; in acp6x_power_on()
69 return -ETIMEDOUT; in acp6x_reset()
133 val = acp6x_readl(adata->acp6x_base + ACP_EXTERNAL_INTR_STAT); in acp6x_irq_handler()
135 yc_pdm_data = dev_get_drvdata(&adata->pdev[0]->dev); in acp6x_irq_handler()
136 acp6x_writel(BIT(PDM_DMA_STAT), adata->acp6x_base + ACP_EXTERNAL_INTR_STAT); in acp6x_irq_handler()
137 if (yc_pdm_data->capture_stream) in acp6x_irq_handler()
138 snd_pcm_period_elapsed(yc_pdm_data->capture_stream); in acp6x_irq_handler()
144 static int snd_acp6x_probe(struct pci_dev *pci, in snd_acp6x_probe() argument
157 switch (pci->revision) { in snd_acp6x_probe()
162 dev_dbg(&pci->dev, "acp6x pci device not found\n"); in snd_acp6x_probe()
163 return -ENODEV; in snd_acp6x_probe()
165 if (pci_enable_device(pci)) { in snd_acp6x_probe()
166 dev_err(&pci->dev, "pci_enable_device failed\n"); in snd_acp6x_probe()
167 return -ENODEV; in snd_acp6x_probe()
170 ret = pci_request_regions(pci, "AMD ACP3x audio"); in snd_acp6x_probe()
172 dev_err(&pci->dev, "pci_request_regions failed\n"); in snd_acp6x_probe()
176 adata = devm_kzalloc(&pci->dev, sizeof(struct acp6x_dev_data), in snd_acp6x_probe()
179 ret = -ENOMEM; in snd_acp6x_probe()
183 addr = pci_resource_start(pci, 0); in snd_acp6x_probe()
184 adata->acp6x_base = devm_ioremap(&pci->dev, addr, in snd_acp6x_probe()
185 pci_resource_len(pci, 0)); in snd_acp6x_probe()
186 if (!adata->acp6x_base) { in snd_acp6x_probe()
187 ret = -ENOMEM; in snd_acp6x_probe()
190 pci_set_master(pci); in snd_acp6x_probe()
191 pci_set_drvdata(pci, adata); in snd_acp6x_probe()
192 ret = acp6x_init(adata->acp6x_base); in snd_acp6x_probe()
195 val = acp6x_readl(adata->acp6x_base + ACP_PIN_CONFIG); in snd_acp6x_probe()
203 dev_info(&pci->dev, "Audio Mode %d\n", val); in snd_acp6x_probe()
206 adata->res = devm_kzalloc(&pci->dev, in snd_acp6x_probe()
209 if (!adata->res) { in snd_acp6x_probe()
210 ret = -ENOMEM; in snd_acp6x_probe()
214 adata->res->name = "acp_iomem"; in snd_acp6x_probe()
215 adata->res->flags = IORESOURCE_MEM; in snd_acp6x_probe()
216 adata->res->start = addr; in snd_acp6x_probe()
217 adata->res->end = addr + (ACP6x_REG_END - ACP6x_REG_START); in snd_acp6x_probe()
219 adata->acp6x_audio_mode = ACP6x_PDM_MODE; in snd_acp6x_probe()
224 pdevinfo[0].parent = &pci->dev; in snd_acp6x_probe()
226 pdevinfo[0].res = adata->res; in snd_acp6x_probe()
228 pdevinfo[1].name = "dmic-codec"; in snd_acp6x_probe()
230 pdevinfo[1].parent = &pci->dev; in snd_acp6x_probe()
234 pdevinfo[2].parent = &pci->dev; in snd_acp6x_probe()
237 adata->pdev[index] = in snd_acp6x_probe()
239 if (IS_ERR(adata->pdev[index])) { in snd_acp6x_probe()
240 dev_err(&pci->dev, "cannot register %s device\n", in snd_acp6x_probe()
242 ret = PTR_ERR(adata->pdev[index]); in snd_acp6x_probe()
248 ret = devm_request_irq(&pci->dev, pci->irq, acp6x_irq_handler, in snd_acp6x_probe()
251 dev_err(&pci->dev, "ACP PCI IRQ request failed\n"); in snd_acp6x_probe()
254 pm_runtime_set_autosuspend_delay(&pci->dev, ACP_SUSPEND_DELAY_MS); in snd_acp6x_probe()
255 pm_runtime_use_autosuspend(&pci->dev); in snd_acp6x_probe()
256 pm_runtime_put_noidle(&pci->dev); in snd_acp6x_probe()
257 pm_runtime_allow(&pci->dev); in snd_acp6x_probe()
261 for (--index; index >= 0; index--) in snd_acp6x_probe()
262 platform_device_unregister(adata->pdev[index]); in snd_acp6x_probe()
264 if (acp6x_deinit(adata->acp6x_base)) in snd_acp6x_probe()
265 dev_err(&pci->dev, "ACP de-init failed\n"); in snd_acp6x_probe()
267 pci_release_regions(pci); in snd_acp6x_probe()
269 pci_disable_device(pci); in snd_acp6x_probe()
274 static int __maybe_unused snd_acp6x_suspend(struct device *dev) in snd_acp6x_suspend() argument
279 adata = dev_get_drvdata(dev); in snd_acp6x_suspend()
280 ret = acp6x_deinit(adata->acp6x_base); in snd_acp6x_suspend()
282 dev_err(dev, "ACP de-init failed\n"); in snd_acp6x_suspend()
286 static int __maybe_unused snd_acp6x_resume(struct device *dev) in snd_acp6x_resume() argument
291 adata = dev_get_drvdata(dev); in snd_acp6x_resume()
292 ret = acp6x_init(adata->acp6x_base); in snd_acp6x_resume()
294 dev_err(dev, "ACP init failed\n"); in snd_acp6x_resume()
303 static void snd_acp6x_remove(struct pci_dev *pci) in snd_acp6x_remove() argument
308 adata = pci_get_drvdata(pci); in snd_acp6x_remove()
309 if (adata->acp6x_audio_mode == ACP6x_PDM_MODE) { in snd_acp6x_remove()
311 platform_device_unregister(adata->pdev[index]); in snd_acp6x_remove()
313 ret = acp6x_deinit(adata->acp6x_base); in snd_acp6x_remove()
315 dev_err(&pci->dev, "ACP de-init failed\n"); in snd_acp6x_remove()
316 pm_runtime_forbid(&pci->dev); in snd_acp6x_remove()
317 pm_runtime_get_noresume(&pci->dev); in snd_acp6x_remove()
318 pci_release_regions(pci); in snd_acp6x_remove()
319 pci_disable_device(pci); in snd_acp6x_remove()
328 MODULE_DEVICE_TABLE(pci, snd_acp6x_ids);
343 MODULE_DESCRIPTION("AMD ACP Yellow Carp PCI driver");