Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: Add DMIC support for the AMD RPL platform

Merge series from Mingyou Chen <qby140326@gmail.com>:

Add DMIC support for the AMD RPL platforma.

+19 -309
-10
sound/soc/amd/Kconfig
··· 122 122 123 123 source "sound/soc/amd/acp/Kconfig" 124 124 125 - config SND_SOC_AMD_RPL_ACP6x 126 - tristate "AMD Audio Coprocessor-v6.2 RPL support" 127 - depends on X86 && PCI 128 - help 129 - This option enables Audio Coprocessor i.e. ACP v6.2 support on 130 - AMD RPL platform. By enabling this flag build will be 131 - triggered for ACP PCI driver. 132 - Say m if you have such a device. 133 - If unsure select "N". 134 - 135 125 config SND_SOC_AMD_ACP63_TOPLEVEL 136 126 tristate "support for AMD platforms with ACP version >= 6.3" 137 127 default SND_AMD_ACP_CONFIG
-1
sound/soc/amd/Makefile
··· 17 17 obj-$(CONFIG_SND_SOC_AMD_ACP6x) += yc/ 18 18 obj-$(CONFIG_SND_AMD_ACP_CONFIG) += acp/ 19 19 obj-$(CONFIG_SND_AMD_ACP_CONFIG) += snd-acp-config.o 20 - obj-$(CONFIG_SND_SOC_AMD_RPL_ACP6x) += rpl/ 21 20 obj-$(CONFIG_SND_SOC_AMD_PS) += ps/
-5
sound/soc/amd/rpl/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0+ 2 - # RPL platform Support 3 - snd-rpl-pci-acp6x-y := rpl-pci-acp6x.o 4 - 5 - obj-$(CONFIG_SND_SOC_AMD_RPL_ACP6x) += snd-rpl-pci-acp6x.o
-227
sound/soc/amd/rpl/rpl-pci-acp6x.c
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 2 - /* 3 - * AMD RPL ACP PCI Driver 4 - * 5 - * Copyright 2022 Advanced Micro Devices, Inc. 6 - */ 7 - 8 - #include <linux/pci.h> 9 - #include <linux/module.h> 10 - #include <linux/io.h> 11 - #include <linux/delay.h> 12 - #include <linux/platform_device.h> 13 - #include <linux/pm_runtime.h> 14 - 15 - #include "rpl_acp6x.h" 16 - 17 - struct rpl_dev_data { 18 - void __iomem *acp6x_base; 19 - }; 20 - 21 - static int rpl_power_on(void __iomem *acp_base) 22 - { 23 - u32 val; 24 - int timeout; 25 - 26 - val = rpl_acp_readl(acp_base + ACP_PGFSM_STATUS); 27 - 28 - if (!val) 29 - return val; 30 - 31 - if ((val & ACP_PGFSM_STATUS_MASK) != ACP_POWER_ON_IN_PROGRESS) 32 - rpl_acp_writel(ACP_PGFSM_CNTL_POWER_ON_MASK, acp_base + ACP_PGFSM_CONTROL); 33 - timeout = 0; 34 - while (++timeout < 500) { 35 - val = rpl_acp_readl(acp_base + ACP_PGFSM_STATUS); 36 - if (!val) 37 - return 0; 38 - udelay(1); 39 - } 40 - return -ETIMEDOUT; 41 - } 42 - 43 - static int rpl_reset(void __iomem *acp_base) 44 - { 45 - u32 val; 46 - int timeout; 47 - 48 - rpl_acp_writel(1, acp_base + ACP_SOFT_RESET); 49 - timeout = 0; 50 - while (++timeout < 500) { 51 - val = rpl_acp_readl(acp_base + ACP_SOFT_RESET); 52 - if (val & ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK) 53 - break; 54 - cpu_relax(); 55 - } 56 - rpl_acp_writel(0, acp_base + ACP_SOFT_RESET); 57 - timeout = 0; 58 - while (++timeout < 500) { 59 - val = rpl_acp_readl(acp_base + ACP_SOFT_RESET); 60 - if (!val) 61 - return 0; 62 - cpu_relax(); 63 - } 64 - return -ETIMEDOUT; 65 - } 66 - 67 - static int rpl_init(void __iomem *acp_base) 68 - { 69 - int ret; 70 - 71 - /* power on */ 72 - ret = rpl_power_on(acp_base); 73 - if (ret) { 74 - pr_err("ACP power on failed\n"); 75 - return ret; 76 - } 77 - rpl_acp_writel(0x01, acp_base + ACP_CONTROL); 78 - /* Reset */ 79 - ret = rpl_reset(acp_base); 80 - if (ret) { 81 - pr_err("ACP reset failed\n"); 82 - return ret; 83 - } 84 - rpl_acp_writel(0x03, acp_base + ACP_CLKMUX_SEL); 85 - return 0; 86 - } 87 - 88 - static int rpl_deinit(void __iomem *acp_base) 89 - { 90 - int ret; 91 - 92 - /* Reset */ 93 - ret = rpl_reset(acp_base); 94 - if (ret) { 95 - pr_err("ACP reset failed\n"); 96 - return ret; 97 - } 98 - rpl_acp_writel(0x00, acp_base + ACP_CLKMUX_SEL); 99 - rpl_acp_writel(0x00, acp_base + ACP_CONTROL); 100 - return 0; 101 - } 102 - 103 - static int snd_rpl_probe(struct pci_dev *pci, 104 - const struct pci_device_id *pci_id) 105 - { 106 - struct rpl_dev_data *adata; 107 - u32 addr; 108 - int ret; 109 - 110 - /* RPL device check */ 111 - switch (pci->revision) { 112 - case 0x62: 113 - break; 114 - default: 115 - dev_dbg(&pci->dev, "acp6x pci device not found\n"); 116 - return -ENODEV; 117 - } 118 - if (pci_enable_device(pci)) { 119 - dev_err(&pci->dev, "pci_enable_device failed\n"); 120 - return -ENODEV; 121 - } 122 - 123 - ret = pci_request_regions(pci, "AMD ACP6x audio"); 124 - if (ret < 0) { 125 - dev_err(&pci->dev, "pci_request_regions failed\n"); 126 - goto disable_pci; 127 - } 128 - 129 - adata = devm_kzalloc(&pci->dev, sizeof(struct rpl_dev_data), 130 - GFP_KERNEL); 131 - if (!adata) { 132 - ret = -ENOMEM; 133 - goto release_regions; 134 - } 135 - 136 - addr = pci_resource_start(pci, 0); 137 - adata->acp6x_base = devm_ioremap(&pci->dev, addr, 138 - pci_resource_len(pci, 0)); 139 - if (!adata->acp6x_base) { 140 - ret = -ENOMEM; 141 - goto release_regions; 142 - } 143 - pci_set_master(pci); 144 - pci_set_drvdata(pci, adata); 145 - ret = rpl_init(adata->acp6x_base); 146 - if (ret) 147 - goto release_regions; 148 - pm_runtime_set_autosuspend_delay(&pci->dev, ACP_SUSPEND_DELAY_MS); 149 - pm_runtime_use_autosuspend(&pci->dev); 150 - pm_runtime_put_noidle(&pci->dev); 151 - pm_runtime_allow(&pci->dev); 152 - 153 - return 0; 154 - release_regions: 155 - pci_release_regions(pci); 156 - disable_pci: 157 - pci_disable_device(pci); 158 - 159 - return ret; 160 - } 161 - 162 - static int snd_rpl_suspend(struct device *dev) 163 - { 164 - struct rpl_dev_data *adata; 165 - int ret; 166 - 167 - adata = dev_get_drvdata(dev); 168 - ret = rpl_deinit(adata->acp6x_base); 169 - if (ret) 170 - dev_err(dev, "ACP de-init failed\n"); 171 - return ret; 172 - } 173 - 174 - static int snd_rpl_resume(struct device *dev) 175 - { 176 - struct rpl_dev_data *adata; 177 - int ret; 178 - 179 - adata = dev_get_drvdata(dev); 180 - ret = rpl_init(adata->acp6x_base); 181 - if (ret) 182 - dev_err(dev, "ACP init failed\n"); 183 - return ret; 184 - } 185 - 186 - static const struct dev_pm_ops rpl_pm = { 187 - RUNTIME_PM_OPS(snd_rpl_suspend, snd_rpl_resume, NULL) 188 - SYSTEM_SLEEP_PM_OPS(snd_rpl_suspend, snd_rpl_resume) 189 - }; 190 - 191 - static void snd_rpl_remove(struct pci_dev *pci) 192 - { 193 - struct rpl_dev_data *adata; 194 - int ret; 195 - 196 - adata = pci_get_drvdata(pci); 197 - ret = rpl_deinit(adata->acp6x_base); 198 - if (ret) 199 - dev_err(&pci->dev, "ACP de-init failed\n"); 200 - pm_runtime_forbid(&pci->dev); 201 - pm_runtime_get_noresume(&pci->dev); 202 - pci_release_regions(pci); 203 - pci_disable_device(pci); 204 - } 205 - 206 - static const struct pci_device_id snd_rpl_ids[] = { 207 - { PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_DEVICE_ID), 208 - .class = PCI_CLASS_MULTIMEDIA_OTHER << 8, 209 - .class_mask = 0xffffff }, 210 - { 0, }, 211 - }; 212 - MODULE_DEVICE_TABLE(pci, snd_rpl_ids); 213 - 214 - static struct pci_driver rpl_acp6x_driver = { 215 - .name = KBUILD_MODNAME, 216 - .id_table = snd_rpl_ids, 217 - .probe = snd_rpl_probe, 218 - .remove = snd_rpl_remove, 219 - .driver = { 220 - .pm = pm_ptr(&rpl_pm), 221 - } 222 - }; 223 - 224 - module_pci_driver(rpl_acp6x_driver); 225 - 226 - MODULE_DESCRIPTION("AMD ACP RPL PCI driver"); 227 - MODULE_LICENSE("GPL v2");
-36
sound/soc/amd/rpl/rpl_acp6x.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0+ */ 2 - /* 3 - * AMD ACP Driver 4 - * 5 - * Copyright (C) 2021 Advanced Micro Devices, Inc. All rights reserved. 6 - */ 7 - 8 - #include "rpl_acp6x_chip_offset_byte.h" 9 - 10 - #define ACP_DEVICE_ID 0x15E2 11 - #define ACP6x_PHY_BASE_ADDRESS 0x1240000 12 - 13 - #define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001 14 - #define ACP_PGFSM_CNTL_POWER_ON_MASK 1 15 - #define ACP_PGFSM_CNTL_POWER_OFF_MASK 0 16 - #define ACP_PGFSM_STATUS_MASK 3 17 - #define ACP_POWERED_ON 0 18 - #define ACP_POWER_ON_IN_PROGRESS 1 19 - #define ACP_POWERED_OFF 2 20 - #define ACP_POWER_OFF_IN_PROGRESS 3 21 - 22 - #define DELAY_US 5 23 - #define ACP_COUNTER 20000 24 - 25 - /* time in ms for runtime suspend delay */ 26 - #define ACP_SUSPEND_DELAY_MS 2000 27 - 28 - static inline u32 rpl_acp_readl(void __iomem *base_addr) 29 - { 30 - return readl(base_addr - ACP6x_PHY_BASE_ADDRESS); 31 - } 32 - 33 - static inline void rpl_acp_writel(u32 val, void __iomem *base_addr) 34 - { 35 - writel(val, base_addr - ACP6x_PHY_BASE_ADDRESS); 36 - }
-30
sound/soc/amd/rpl/rpl_acp6x_chip_offset_byte.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0+ */ 2 - /* 3 - * AMD ACP 6.2 Register Documentation 4 - * 5 - * Copyright 2022 Advanced Micro Devices, Inc. 6 - */ 7 - 8 - #ifndef _rpl_acp6x_OFFSET_HEADER 9 - #define _rpl_acp6x_OFFSET_HEADER 10 - 11 - /* Registers from ACP_CLKRST block */ 12 - #define ACP_SOFT_RESET 0x1241000 13 - #define ACP_CONTROL 0x1241004 14 - #define ACP_STATUS 0x1241008 15 - #define ACP_DYNAMIC_CG_MASTER_CONTROL 0x1241010 16 - #define ACP_PGFSM_CONTROL 0x124101C 17 - #define ACP_PGFSM_STATUS 0x1241020 18 - #define ACP_CLKMUX_SEL 0x1241024 19 - 20 - /* Registers from ACP_AON block */ 21 - #define ACP_PME_EN 0x1241400 22 - #define ACP_DEVICE_STATE 0x1241404 23 - #define AZ_DEVICE_STATE 0x1241408 24 - #define ACP_PIN_CONFIG 0x1241440 25 - #define ACP_PAD_PULLUP_CTRL 0x1241444 26 - #define ACP_PAD_PULLDOWN_CTRL 0x1241448 27 - #define ACP_PAD_DRIVE_STRENGTH_CTRL 0x124144C 28 - #define ACP_PAD_SCHMEN_CTRL 0x1241450 29 - 30 - #endif
+7
sound/soc/amd/yc/acp6x-mach.c
··· 48 48 { 49 49 .driver_data = &acp6x_card, 50 50 .matches = { 51 + DMI_MATCH(DMI_BOARD_VENDOR, "Lecoo"), 52 + DMI_MATCH(DMI_PRODUCT_NAME, "Bellator N176"), 53 + } 54 + }, 55 + { 56 + .driver_data = &acp6x_card, 57 + .matches = { 51 58 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Inc."), 52 59 DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5525"), 53 60 }
+12
sound/soc/amd/yc/pci-acp6x.c
··· 163 163 switch (pci->revision) { 164 164 case 0x60: 165 165 case 0x6f: 166 + case 0x62: /* RPL */ 166 167 break; 167 168 default: 168 169 dev_dbg(&pci->dev, "acp6x pci device not found\n"); ··· 209 208 case ACP_CONFIG_15: 210 209 dev_info(&pci->dev, "Audio Mode %d\n", val); 211 210 break; 211 + case ACP_CONFIG_10: 212 + case ACP_CONFIG_11: 213 + case ACP_CONFIG_12: 214 + case ACP_CONFIG_13: 215 + case ACP_CONFIG_14: 216 + /* PIN 10 to 14 is reserve for RPL */ 217 + if (pci->revision == 0x62) { 218 + dev_info(&pci->dev, "RPL Audio Mode %d\n", val); 219 + break; 220 + } 221 + fallthrough; 212 222 default: 213 223 adata->res = devm_kzalloc(&pci->dev, 214 224 sizeof(struct resource),