Lines Matching +full:pci +full:- +full:dev
1 // SPDX-License-Identifier: GPL-2.0+
3 // AMD Vangogh ACP PCI Driver
7 #include <linux/pci.h>
45 return -ETIMEDOUT; in acp5x_power_on()
69 return -ETIMEDOUT; in acp5x_reset()
123 static int snd_acp5x_probe(struct pci_dev *pci, in snd_acp5x_probe() argument
133 flag = snd_amd_acp_find_config(pci); in snd_acp5x_probe()
135 return -ENODEV; in snd_acp5x_probe()
138 if (pci->revision != 0x50) in snd_acp5x_probe()
139 return -ENODEV; in snd_acp5x_probe()
141 if (pci_enable_device(pci)) { in snd_acp5x_probe()
142 dev_err(&pci->dev, "pci_enable_device failed\n"); in snd_acp5x_probe()
143 return -ENODEV; in snd_acp5x_probe()
146 ret = pci_request_regions(pci, "AMD ACP5x audio"); in snd_acp5x_probe()
148 dev_err(&pci->dev, "pci_request_regions failed\n"); in snd_acp5x_probe()
152 adata = devm_kzalloc(&pci->dev, sizeof(struct acp5x_dev_data), in snd_acp5x_probe()
155 ret = -ENOMEM; in snd_acp5x_probe()
158 addr = pci_resource_start(pci, 0); in snd_acp5x_probe()
159 adata->acp5x_base = devm_ioremap(&pci->dev, addr, in snd_acp5x_probe()
160 pci_resource_len(pci, 0)); in snd_acp5x_probe()
161 if (!adata->acp5x_base) { in snd_acp5x_probe()
162 ret = -ENOMEM; in snd_acp5x_probe()
165 pci_set_master(pci); in snd_acp5x_probe()
166 pci_set_drvdata(pci, adata); in snd_acp5x_probe()
167 ret = acp5x_init(adata->acp5x_base); in snd_acp5x_probe()
171 val = acp_readl(adata->acp5x_base + ACP_PIN_CONFIG); in snd_acp5x_probe()
174 adata->res = devm_kzalloc(&pci->dev, in snd_acp5x_probe()
177 if (!adata->res) { in snd_acp5x_probe()
178 ret = -ENOMEM; in snd_acp5x_probe()
182 adata->res[0].name = "acp5x_i2s_iomem"; in snd_acp5x_probe()
183 adata->res[0].flags = IORESOURCE_MEM; in snd_acp5x_probe()
184 adata->res[0].start = addr; in snd_acp5x_probe()
185 adata->res[0].end = addr + (ACP5x_REG_END - ACP5x_REG_START); in snd_acp5x_probe()
187 adata->res[1].name = "acp5x_i2s_sp"; in snd_acp5x_probe()
188 adata->res[1].flags = IORESOURCE_MEM; in snd_acp5x_probe()
189 adata->res[1].start = addr + ACP5x_I2STDM_REG_START; in snd_acp5x_probe()
190 adata->res[1].end = addr + ACP5x_I2STDM_REG_END; in snd_acp5x_probe()
192 adata->res[2].name = "acp5x_i2s_hs"; in snd_acp5x_probe()
193 adata->res[2].flags = IORESOURCE_MEM; in snd_acp5x_probe()
194 adata->res[2].start = addr + ACP5x_HS_TDM_REG_START; in snd_acp5x_probe()
195 adata->res[2].end = addr + ACP5x_HS_TDM_REG_END; in snd_acp5x_probe()
197 adata->res[3].name = "acp5x_i2s_irq"; in snd_acp5x_probe()
198 adata->res[3].flags = IORESOURCE_IRQ; in snd_acp5x_probe()
199 adata->res[3].start = pci->irq; in snd_acp5x_probe()
200 adata->res[3].end = adata->res[3].start; in snd_acp5x_probe()
202 adata->acp5x_audio_mode = ACP5x_I2S_MODE; in snd_acp5x_probe()
207 pdevinfo[0].parent = &pci->dev; in snd_acp5x_probe()
209 pdevinfo[0].res = &adata->res[0]; in snd_acp5x_probe()
215 pdevinfo[1].parent = &pci->dev; in snd_acp5x_probe()
217 pdevinfo[1].res = &adata->res[1]; in snd_acp5x_probe()
221 pdevinfo[2].parent = &pci->dev; in snd_acp5x_probe()
223 pdevinfo[2].res = &adata->res[2]; in snd_acp5x_probe()
227 pdevinfo[3].parent = &pci->dev; in snd_acp5x_probe()
229 adata->pdev[i] = in snd_acp5x_probe()
231 if (IS_ERR(adata->pdev[i])) { in snd_acp5x_probe()
232 dev_err(&pci->dev, "cannot register %s device\n", in snd_acp5x_probe()
234 ret = PTR_ERR(adata->pdev[i]); in snd_acp5x_probe()
240 dev_info(&pci->dev, "ACP audio mode : %d\n", val); in snd_acp5x_probe()
242 pm_runtime_set_autosuspend_delay(&pci->dev, 2000); in snd_acp5x_probe()
243 pm_runtime_use_autosuspend(&pci->dev); in snd_acp5x_probe()
244 pm_runtime_put_noidle(&pci->dev); in snd_acp5x_probe()
245 pm_runtime_allow(&pci->dev); in snd_acp5x_probe()
249 for (--i; i >= 0; i--) in snd_acp5x_probe()
250 platform_device_unregister(adata->pdev[i]); in snd_acp5x_probe()
252 if (acp5x_deinit(adata->acp5x_base)) in snd_acp5x_probe()
253 dev_err(&pci->dev, "ACP de-init failed\n"); in snd_acp5x_probe()
255 pci_release_regions(pci); in snd_acp5x_probe()
257 pci_disable_device(pci); in snd_acp5x_probe()
262 static int __maybe_unused snd_acp5x_suspend(struct device *dev) in snd_acp5x_suspend() argument
267 adata = dev_get_drvdata(dev); in snd_acp5x_suspend()
268 ret = acp5x_deinit(adata->acp5x_base); in snd_acp5x_suspend()
270 dev_err(dev, "ACP de-init failed\n"); in snd_acp5x_suspend()
272 dev_dbg(dev, "ACP de-initialized\n"); in snd_acp5x_suspend()
277 static int __maybe_unused snd_acp5x_resume(struct device *dev) in snd_acp5x_resume() argument
282 adata = dev_get_drvdata(dev); in snd_acp5x_resume()
283 ret = acp5x_init(adata->acp5x_base); in snd_acp5x_resume()
285 dev_err(dev, "ACP init failed\n"); in snd_acp5x_resume()
297 static void snd_acp5x_remove(struct pci_dev *pci) in snd_acp5x_remove() argument
302 adata = pci_get_drvdata(pci); in snd_acp5x_remove()
303 if (adata->acp5x_audio_mode == ACP5x_I2S_MODE) { in snd_acp5x_remove()
305 platform_device_unregister(adata->pdev[i]); in snd_acp5x_remove()
307 ret = acp5x_deinit(adata->acp5x_base); in snd_acp5x_remove()
309 dev_err(&pci->dev, "ACP de-init failed\n"); in snd_acp5x_remove()
310 pm_runtime_forbid(&pci->dev); in snd_acp5x_remove()
311 pm_runtime_get_noresume(&pci->dev); in snd_acp5x_remove()
312 pci_release_regions(pci); in snd_acp5x_remove()
313 pci_disable_device(pci); in snd_acp5x_remove()
322 MODULE_DEVICE_TABLE(pci, snd_acp5x_ids);
337 MODULE_DESCRIPTION("AMD Vangogh ACP PCI driver");