1ec25a3b1SAjit Kumar Pandey // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2ec25a3b1SAjit Kumar Pandey //
3ec25a3b1SAjit Kumar Pandey // This file is provided under a dual BSD/GPLv2 license. When using or
4ec25a3b1SAjit Kumar Pandey // redistributing this file, you may do so under either license.
5ec25a3b1SAjit Kumar Pandey //
6ec25a3b1SAjit Kumar Pandey // Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved.
7ec25a3b1SAjit Kumar Pandey //
8ec25a3b1SAjit Kumar Pandey // Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
9ec25a3b1SAjit Kumar Pandey
10ec25a3b1SAjit Kumar Pandey /*
11ec25a3b1SAjit Kumar Pandey * PCI interface for Renoir ACP device
12ec25a3b1SAjit Kumar Pandey */
13ec25a3b1SAjit Kumar Pandey
14ec25a3b1SAjit Kumar Pandey #include <linux/module.h>
15ec25a3b1SAjit Kumar Pandey #include <linux/pci.h>
16ec25a3b1SAjit Kumar Pandey #include <linux/platform_device.h>
17ec25a3b1SAjit Kumar Pandey #include <sound/sof.h>
18ec25a3b1SAjit Kumar Pandey #include <sound/soc-acpi.h>
19ec25a3b1SAjit Kumar Pandey
20ec25a3b1SAjit Kumar Pandey #include "../ops.h"
21ec25a3b1SAjit Kumar Pandey #include "../sof-pci-dev.h"
22ec25a3b1SAjit Kumar Pandey #include "../../amd/mach-config.h"
23ec25a3b1SAjit Kumar Pandey #include "acp.h"
244da6b033SAjit Kumar Pandey #include "acp-dsp-offset.h"
25ec25a3b1SAjit Kumar Pandey
26ec25a3b1SAjit Kumar Pandey #define ACP3x_REG_START 0x1240000
27ec25a3b1SAjit Kumar Pandey #define ACP3x_REG_END 0x125C000
28*8278aa8eSV sujith kumar Reddy #define ACP3X_FUTURE_REG_ACLK_0 0x1860
29ec25a3b1SAjit Kumar Pandey
30f063eba3SAjit Kumar Pandey static const struct sof_amd_acp_desc renoir_chip_info = {
314da6b033SAjit Kumar Pandey .rev = 3,
32f063eba3SAjit Kumar Pandey .host_bridge_id = HOST_BRIDGE_CZN,
334da6b033SAjit Kumar Pandey .pgfsm_base = ACP3X_PGFSM_BASE,
344da6b033SAjit Kumar Pandey .ext_intr_stat = ACP3X_EXT_INTR_STAT,
354da6b033SAjit Kumar Pandey .dsp_intr_base = ACP3X_DSP_SW_INTR_BASE,
364da6b033SAjit Kumar Pandey .sram_pte_offset = ACP3X_SRAM_PTE_OFFSET,
374da6b033SAjit Kumar Pandey .hw_semaphore_offset = ACP3X_AXI2DAGB_SEM_0,
384da6b033SAjit Kumar Pandey .acp_clkmux_sel = ACP3X_CLKMUX_SEL,
39*8278aa8eSV sujith kumar Reddy .probe_reg_offset = ACP3X_FUTURE_REG_ACLK_0,
40f063eba3SAjit Kumar Pandey };
41f063eba3SAjit Kumar Pandey
42ec25a3b1SAjit Kumar Pandey static const struct sof_dev_desc renoir_desc = {
43ec25a3b1SAjit Kumar Pandey .machines = snd_soc_acpi_amd_sof_machines,
44b585692fSAjit Kumar Pandey .use_acpi_target_states = true,
45ec25a3b1SAjit Kumar Pandey .resindex_lpe_base = 0,
46ec25a3b1SAjit Kumar Pandey .resindex_pcicfg_base = -1,
47ec25a3b1SAjit Kumar Pandey .resindex_imr_base = -1,
48ec25a3b1SAjit Kumar Pandey .irqindex_host_ipc = -1,
49f063eba3SAjit Kumar Pandey .chip_info = &renoir_chip_info,
500cf8ff05SPierre-Louis Bossart .ipc_supported_mask = BIT(SOF_IPC),
510cf8ff05SPierre-Louis Bossart .ipc_default = SOF_IPC,
52a3757915SPierre-Louis Bossart .default_fw_path = {
53a3757915SPierre-Louis Bossart [SOF_IPC] = "amd/sof",
54a3757915SPierre-Louis Bossart },
55a3757915SPierre-Louis Bossart .default_tplg_path = {
56a3757915SPierre-Louis Bossart [SOF_IPC] = "amd/sof-tplg",
57a3757915SPierre-Louis Bossart },
58a97abb3cSPierre-Louis Bossart .default_fw_filename = {
59a97abb3cSPierre-Louis Bossart [SOF_IPC] = "sof-rn.ri",
60a97abb3cSPierre-Louis Bossart },
61ec25a3b1SAjit Kumar Pandey .nocodec_tplg_filename = "sof-acp.tplg",
62ec25a3b1SAjit Kumar Pandey .ops = &sof_renoir_ops,
634da6b033SAjit Kumar Pandey .ops_init = sof_renoir_ops_init,
64ec25a3b1SAjit Kumar Pandey };
65ec25a3b1SAjit Kumar Pandey
acp_pci_rn_probe(struct pci_dev * pci,const struct pci_device_id * pci_id)66ec25a3b1SAjit Kumar Pandey static int acp_pci_rn_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
67ec25a3b1SAjit Kumar Pandey {
6856e00814SVijendar Mukunda unsigned int flag;
69ec25a3b1SAjit Kumar Pandey
701d4a8463SVenkata Prasad Potturu if (pci->revision != ACP_RN_PCI_ID)
711d4a8463SVenkata Prasad Potturu return -ENODEV;
721d4a8463SVenkata Prasad Potturu
73ec25a3b1SAjit Kumar Pandey flag = snd_amd_acp_find_config(pci);
74ec25a3b1SAjit Kumar Pandey if (flag != FLAG_AMD_SOF && flag != FLAG_AMD_SOF_ONLY_DMIC)
75ec25a3b1SAjit Kumar Pandey return -ENODEV;
76ec25a3b1SAjit Kumar Pandey
77dd6bdd8bSVijendar Mukunda return sof_pci_probe(pci, pci_id);
78ec25a3b1SAjit Kumar Pandey };
79ec25a3b1SAjit Kumar Pandey
acp_pci_rn_remove(struct pci_dev * pci)80ec25a3b1SAjit Kumar Pandey static void acp_pci_rn_remove(struct pci_dev *pci)
81ec25a3b1SAjit Kumar Pandey {
82ec25a3b1SAjit Kumar Pandey return sof_pci_remove(pci);
83ec25a3b1SAjit Kumar Pandey }
84ec25a3b1SAjit Kumar Pandey
85ec25a3b1SAjit Kumar Pandey /* PCI IDs */
86ec25a3b1SAjit Kumar Pandey static const struct pci_device_id rn_pci_ids[] = {
87ec25a3b1SAjit Kumar Pandey { PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_PCI_DEV_ID),
88ec25a3b1SAjit Kumar Pandey .driver_data = (unsigned long)&renoir_desc},
89ec25a3b1SAjit Kumar Pandey { 0, }
90ec25a3b1SAjit Kumar Pandey };
91ec25a3b1SAjit Kumar Pandey MODULE_DEVICE_TABLE(pci, rn_pci_ids);
92ec25a3b1SAjit Kumar Pandey
93ec25a3b1SAjit Kumar Pandey /* pci_driver definition */
94ec25a3b1SAjit Kumar Pandey static struct pci_driver snd_sof_pci_amd_rn_driver = {
95ec25a3b1SAjit Kumar Pandey .name = KBUILD_MODNAME,
96ec25a3b1SAjit Kumar Pandey .id_table = rn_pci_ids,
97ec25a3b1SAjit Kumar Pandey .probe = acp_pci_rn_probe,
98ec25a3b1SAjit Kumar Pandey .remove = acp_pci_rn_remove,
99b585692fSAjit Kumar Pandey .driver = {
100b585692fSAjit Kumar Pandey .pm = &sof_pci_pm,
101b585692fSAjit Kumar Pandey },
102ec25a3b1SAjit Kumar Pandey };
103ec25a3b1SAjit Kumar Pandey module_pci_driver(snd_sof_pci_amd_rn_driver);
104ec25a3b1SAjit Kumar Pandey
105ec25a3b1SAjit Kumar Pandey MODULE_LICENSE("Dual BSD/GPL");
106ec25a3b1SAjit Kumar Pandey MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON);
107ec25a3b1SAjit Kumar Pandey MODULE_IMPORT_NS(SND_SOC_SOF_PCI_DEV);
108