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 28ec25a3b1SAjit Kumar Pandey 29f063eba3SAjit Kumar Pandey static const struct sof_amd_acp_desc renoir_chip_info = { 304da6b033SAjit Kumar Pandey .rev = 3, 31f063eba3SAjit Kumar Pandey .host_bridge_id = HOST_BRIDGE_CZN, 324da6b033SAjit Kumar Pandey .pgfsm_base = ACP3X_PGFSM_BASE, 334da6b033SAjit Kumar Pandey .ext_intr_stat = ACP3X_EXT_INTR_STAT, 344da6b033SAjit Kumar Pandey .dsp_intr_base = ACP3X_DSP_SW_INTR_BASE, 354da6b033SAjit Kumar Pandey .sram_pte_offset = ACP3X_SRAM_PTE_OFFSET, 364da6b033SAjit Kumar Pandey .hw_semaphore_offset = ACP3X_AXI2DAGB_SEM_0, 374da6b033SAjit Kumar Pandey .acp_clkmux_sel = ACP3X_CLKMUX_SEL, 38f063eba3SAjit Kumar Pandey }; 39f063eba3SAjit Kumar Pandey 40ec25a3b1SAjit Kumar Pandey static const struct sof_dev_desc renoir_desc = { 41ec25a3b1SAjit Kumar Pandey .machines = snd_soc_acpi_amd_sof_machines, 42b585692fSAjit Kumar Pandey .use_acpi_target_states = true, 43ec25a3b1SAjit Kumar Pandey .resindex_lpe_base = 0, 44ec25a3b1SAjit Kumar Pandey .resindex_pcicfg_base = -1, 45ec25a3b1SAjit Kumar Pandey .resindex_imr_base = -1, 46ec25a3b1SAjit Kumar Pandey .irqindex_host_ipc = -1, 47f063eba3SAjit Kumar Pandey .chip_info = &renoir_chip_info, 480cf8ff05SPierre-Louis Bossart .ipc_supported_mask = BIT(SOF_IPC), 490cf8ff05SPierre-Louis Bossart .ipc_default = SOF_IPC, 50a3757915SPierre-Louis Bossart .default_fw_path = { 51a3757915SPierre-Louis Bossart [SOF_IPC] = "amd/sof", 52a3757915SPierre-Louis Bossart }, 53a3757915SPierre-Louis Bossart .default_tplg_path = { 54a3757915SPierre-Louis Bossart [SOF_IPC] = "amd/sof-tplg", 55a3757915SPierre-Louis Bossart }, 56a97abb3cSPierre-Louis Bossart .default_fw_filename = { 57a97abb3cSPierre-Louis Bossart [SOF_IPC] = "sof-rn.ri", 58a97abb3cSPierre-Louis Bossart }, 59ec25a3b1SAjit Kumar Pandey .nocodec_tplg_filename = "sof-acp.tplg", 60ec25a3b1SAjit Kumar Pandey .ops = &sof_renoir_ops, 614da6b033SAjit Kumar Pandey .ops_init = sof_renoir_ops_init, 62ec25a3b1SAjit Kumar Pandey }; 63ec25a3b1SAjit Kumar Pandey 64ec25a3b1SAjit Kumar Pandey static int acp_pci_rn_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 65ec25a3b1SAjit Kumar Pandey { 6656e00814SVijendar Mukunda unsigned int flag; 67ec25a3b1SAjit Kumar Pandey 68*1d4a8463SVenkata Prasad Potturu if (pci->revision != ACP_RN_PCI_ID) 69*1d4a8463SVenkata Prasad Potturu return -ENODEV; 70*1d4a8463SVenkata Prasad Potturu 71ec25a3b1SAjit Kumar Pandey flag = snd_amd_acp_find_config(pci); 72ec25a3b1SAjit Kumar Pandey if (flag != FLAG_AMD_SOF && flag != FLAG_AMD_SOF_ONLY_DMIC) 73ec25a3b1SAjit Kumar Pandey return -ENODEV; 74ec25a3b1SAjit Kumar Pandey 75dd6bdd8bSVijendar Mukunda return sof_pci_probe(pci, pci_id); 76ec25a3b1SAjit Kumar Pandey }; 77ec25a3b1SAjit Kumar Pandey 78ec25a3b1SAjit Kumar Pandey static void acp_pci_rn_remove(struct pci_dev *pci) 79ec25a3b1SAjit Kumar Pandey { 80ec25a3b1SAjit Kumar Pandey return sof_pci_remove(pci); 81ec25a3b1SAjit Kumar Pandey } 82ec25a3b1SAjit Kumar Pandey 83ec25a3b1SAjit Kumar Pandey /* PCI IDs */ 84ec25a3b1SAjit Kumar Pandey static const struct pci_device_id rn_pci_ids[] = { 85ec25a3b1SAjit Kumar Pandey { PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_PCI_DEV_ID), 86ec25a3b1SAjit Kumar Pandey .driver_data = (unsigned long)&renoir_desc}, 87ec25a3b1SAjit Kumar Pandey { 0, } 88ec25a3b1SAjit Kumar Pandey }; 89ec25a3b1SAjit Kumar Pandey MODULE_DEVICE_TABLE(pci, rn_pci_ids); 90ec25a3b1SAjit Kumar Pandey 91ec25a3b1SAjit Kumar Pandey /* pci_driver definition */ 92ec25a3b1SAjit Kumar Pandey static struct pci_driver snd_sof_pci_amd_rn_driver = { 93ec25a3b1SAjit Kumar Pandey .name = KBUILD_MODNAME, 94ec25a3b1SAjit Kumar Pandey .id_table = rn_pci_ids, 95ec25a3b1SAjit Kumar Pandey .probe = acp_pci_rn_probe, 96ec25a3b1SAjit Kumar Pandey .remove = acp_pci_rn_remove, 97b585692fSAjit Kumar Pandey .driver = { 98b585692fSAjit Kumar Pandey .pm = &sof_pci_pm, 99b585692fSAjit Kumar Pandey }, 100ec25a3b1SAjit Kumar Pandey }; 101ec25a3b1SAjit Kumar Pandey module_pci_driver(snd_sof_pci_amd_rn_driver); 102ec25a3b1SAjit Kumar Pandey 103ec25a3b1SAjit Kumar Pandey MODULE_LICENSE("Dual BSD/GPL"); 104ec25a3b1SAjit Kumar Pandey MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON); 105ec25a3b1SAjit Kumar Pandey MODULE_IMPORT_NS(SND_SOC_SOF_PCI_DEV); 106