Lines Matching +full:pci +full:- +full:dev
1 // SPDX-License-Identifier: GPL-2.0+
3 // AMD ACP PCI Driver
7 #include <linux/pci.h>
27 void __iomem *acp3x_base = adata->acp3x_base; in acp3x_power_on()
47 rv_writel(adata->pme_en, acp3x_base + mmACP_PME_EN); in acp3x_power_on()
52 return -ETIMEDOUT; in acp3x_power_on()
76 return -ETIMEDOUT; in acp3x_reset()
94 void __iomem *acp3x_base = adata->acp3x_base; in acp3x_init()
127 static int snd_acp3x_probe(struct pci_dev *pci, in snd_acp3x_probe() argument
137 if (pci->revision != 0x00) in snd_acp3x_probe()
138 return -ENODEV; in snd_acp3x_probe()
140 if (pci_enable_device(pci)) { in snd_acp3x_probe()
141 dev_err(&pci->dev, "pci_enable_device failed\n"); in snd_acp3x_probe()
142 return -ENODEV; in snd_acp3x_probe()
145 ret = pci_request_regions(pci, "AMD ACP3x audio"); in snd_acp3x_probe()
147 dev_err(&pci->dev, "pci_request_regions failed\n"); in snd_acp3x_probe()
151 adata = devm_kzalloc(&pci->dev, sizeof(struct acp3x_dev_data), in snd_acp3x_probe()
154 ret = -ENOMEM; in snd_acp3x_probe()
160 addr = pci_resource_start(pci, 0); in snd_acp3x_probe()
161 adata->acp3x_base = devm_ioremap(&pci->dev, addr, in snd_acp3x_probe()
162 pci_resource_len(pci, 0)); in snd_acp3x_probe()
163 if (!adata->acp3x_base) { in snd_acp3x_probe()
164 ret = -ENOMEM; in snd_acp3x_probe()
167 pci_set_master(pci); in snd_acp3x_probe()
168 pci_set_drvdata(pci, adata); in snd_acp3x_probe()
170 adata->pme_en = rv_readl(adata->acp3x_base + mmACP_PME_EN); in snd_acp3x_probe()
175 val = rv_readl(adata->acp3x_base + mmACP_I2S_PIN_CONFIG); in snd_acp3x_probe()
178 adata->res = devm_kzalloc(&pci->dev, in snd_acp3x_probe()
181 if (!adata->res) { in snd_acp3x_probe()
182 ret = -ENOMEM; in snd_acp3x_probe()
186 adata->res[0].name = "acp3x_i2s_iomem"; in snd_acp3x_probe()
187 adata->res[0].flags = IORESOURCE_MEM; in snd_acp3x_probe()
188 adata->res[0].start = addr; in snd_acp3x_probe()
189 adata->res[0].end = addr + (ACP3x_REG_END - ACP3x_REG_START); in snd_acp3x_probe()
191 adata->res[1].name = "acp3x_i2s_sp"; in snd_acp3x_probe()
192 adata->res[1].flags = IORESOURCE_MEM; in snd_acp3x_probe()
193 adata->res[1].start = addr + ACP3x_I2STDM_REG_START; in snd_acp3x_probe()
194 adata->res[1].end = addr + ACP3x_I2STDM_REG_END; in snd_acp3x_probe()
196 adata->res[2].name = "acp3x_i2s_bt"; in snd_acp3x_probe()
197 adata->res[2].flags = IORESOURCE_MEM; in snd_acp3x_probe()
198 adata->res[2].start = addr + ACP3x_BT_TDM_REG_START; in snd_acp3x_probe()
199 adata->res[2].end = addr + ACP3x_BT_TDM_REG_END; in snd_acp3x_probe()
201 adata->res[3].name = "acp3x_i2s_irq"; in snd_acp3x_probe()
202 adata->res[3].flags = IORESOURCE_IRQ; in snd_acp3x_probe()
203 adata->res[3].start = pci->irq; in snd_acp3x_probe()
204 adata->res[3].end = adata->res[3].start; in snd_acp3x_probe()
206 adata->acp3x_audio_mode = ACP3x_I2S_MODE; in snd_acp3x_probe()
211 pdevinfo[0].parent = &pci->dev; in snd_acp3x_probe()
213 pdevinfo[0].res = &adata->res[0]; in snd_acp3x_probe()
219 pdevinfo[1].parent = &pci->dev; in snd_acp3x_probe()
221 pdevinfo[1].res = &adata->res[1]; in snd_acp3x_probe()
225 pdevinfo[2].parent = &pci->dev; in snd_acp3x_probe()
227 pdevinfo[2].res = &adata->res[1]; in snd_acp3x_probe()
231 pdevinfo[3].parent = &pci->dev; in snd_acp3x_probe()
233 pdevinfo[3].res = &adata->res[2]; in snd_acp3x_probe()
235 adata->pdev[i] = in snd_acp3x_probe()
237 if (IS_ERR(adata->pdev[i])) { in snd_acp3x_probe()
238 dev_err(&pci->dev, "cannot register %s device\n", in snd_acp3x_probe()
240 ret = PTR_ERR(adata->pdev[i]); in snd_acp3x_probe()
246 dev_info(&pci->dev, "ACP audio mode : %d\n", val); in snd_acp3x_probe()
249 pm_runtime_set_autosuspend_delay(&pci->dev, 2000); in snd_acp3x_probe()
250 pm_runtime_use_autosuspend(&pci->dev); in snd_acp3x_probe()
251 pm_runtime_put_noidle(&pci->dev); in snd_acp3x_probe()
252 pm_runtime_allow(&pci->dev); in snd_acp3x_probe()
258 platform_device_unregister(adata->pdev[i]); in snd_acp3x_probe()
260 if (acp3x_deinit(adata->acp3x_base)) in snd_acp3x_probe()
261 dev_err(&pci->dev, "ACP de-init failed\n"); in snd_acp3x_probe()
263 pci_release_regions(pci); in snd_acp3x_probe()
265 pci_disable_device(pci); in snd_acp3x_probe()
270 static int snd_acp3x_suspend(struct device *dev) in snd_acp3x_suspend() argument
275 adata = dev_get_drvdata(dev); in snd_acp3x_suspend()
276 ret = acp3x_deinit(adata->acp3x_base); in snd_acp3x_suspend()
278 dev_err(dev, "ACP de-init failed\n"); in snd_acp3x_suspend()
280 dev_dbg(dev, "ACP de-initialized\n"); in snd_acp3x_suspend()
285 static int snd_acp3x_resume(struct device *dev) in snd_acp3x_resume() argument
290 adata = dev_get_drvdata(dev); in snd_acp3x_resume()
293 dev_err(dev, "ACP init failed\n"); in snd_acp3x_resume()
305 static void snd_acp3x_remove(struct pci_dev *pci) in snd_acp3x_remove() argument
310 adata = pci_get_drvdata(pci); in snd_acp3x_remove()
311 if (adata->acp3x_audio_mode == ACP3x_I2S_MODE) { in snd_acp3x_remove()
313 platform_device_unregister(adata->pdev[i]); in snd_acp3x_remove()
315 ret = acp3x_deinit(adata->acp3x_base); in snd_acp3x_remove()
317 dev_err(&pci->dev, "ACP de-init failed\n"); in snd_acp3x_remove()
318 pm_runtime_forbid(&pci->dev); in snd_acp3x_remove()
319 pm_runtime_get_noresume(&pci->dev); in snd_acp3x_remove()
320 pci_release_regions(pci); in snd_acp3x_remove()
321 pci_disable_device(pci); in snd_acp3x_remove()
330 MODULE_DEVICE_TABLE(pci, snd_acp3x_ids);
346 MODULE_DESCRIPTION("AMD ACP3x PCI driver");