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: amd: ps: add machine select and register code

Add machine select logic for SoundWire interface and create a machine
device node based on ACP PDM/SoundWire configuration.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Link: https://msgid.link/r/20240214104014.1144668-5-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Vijendar Mukunda and committed by
Mark Brown
bbf3e614 c76f3b1f

+84 -1
+4
sound/soc/amd/ps/acp63.h
··· 219 219 * @pdm_dev: ACP PDM controller platform device 220 220 * @dmic_codec: platform device for DMIC Codec 221 221 * sdw_dma_dev: platform device for SoundWire DMA controller 222 + * @mach_dev: platform device for machine driver to support ACP PDM/SoundWire configuration 222 223 * @acp_lock: used to protect acp common registers 223 224 * @info: SoundWire AMD information found in ACPI tables 224 225 * @sdw: SoundWire context for all SoundWire manager instances 226 + * @machine: ACPI machines for SoundWire interface 225 227 * @is_sdw_dev: flag set to true when any SoundWire manager instances are available 226 228 * @is_pdm_dev: flag set to true when ACP PDM controller exists 227 229 * @is_pdm_config: flat set to true when PDM configuration is selected from BIOS ··· 241 239 struct platform_device *pdm_dev; 242 240 struct platform_device *dmic_codec_dev; 243 241 struct platform_device *sdw_dma_dev; 242 + struct platform_device *mach_dev; 244 243 struct mutex acp_lock; /* protect shared registers */ 245 244 struct sdw_amd_acpi_info info; 246 245 /* sdw context allocated by SoundWire driver */ 247 246 struct sdw_amd_ctx *sdw; 247 + struct snd_soc_acpi_mach *machines; 248 248 bool is_sdw_dev; 249 249 bool is_pdm_dev; 250 250 bool is_pdm_config;
+80 -1
sound/soc/amd/ps/pci-ps.c
··· 17 17 #include <linux/pm_runtime.h> 18 18 #include <linux/iopoll.h> 19 19 #include <linux/soundwire/sdw_amd.h> 20 + #include "../mach-config.h" 20 21 21 22 #include "acp63.h" 22 23 ··· 282 281 283 282 return 0; 284 283 } 284 + 285 + static struct snd_soc_acpi_mach *acp63_sdw_machine_select(struct device *dev) 286 + { 287 + struct snd_soc_acpi_mach *mach; 288 + const struct snd_soc_acpi_link_adr *link; 289 + struct acp63_dev_data *acp_data = dev_get_drvdata(dev); 290 + int ret, i; 291 + 292 + if (acp_data->info.count) { 293 + ret = sdw_amd_get_slave_info(acp_data->sdw); 294 + if (ret) { 295 + dev_dbg(dev, "failed to read slave information\n"); 296 + return NULL; 297 + } 298 + for (mach = acp_data->machines; mach; mach++) { 299 + if (!mach->links) 300 + break; 301 + link = mach->links; 302 + for (i = 0; i < acp_data->info.count && link->num_adr; link++, i++) { 303 + if (!snd_soc_acpi_sdw_link_slaves_found(dev, link, 304 + acp_data->sdw->ids, 305 + acp_data->sdw->num_slaves)) 306 + break; 307 + } 308 + if (i == acp_data->info.count || !link->num_adr) 309 + break; 310 + } 311 + if (mach && mach->link_mask) { 312 + mach->mach_params.links = mach->links; 313 + mach->mach_params.link_mask = mach->link_mask; 314 + return mach; 315 + } 316 + } 317 + dev_dbg(dev, "No SoundWire machine driver found\n"); 318 + return NULL; 319 + } 285 320 #else 286 321 static int acp_scan_sdw_devices(struct device *dev, u64 addr) 287 322 { ··· 333 296 { 334 297 return 0; 335 298 } 299 + 300 + static struct snd_soc_acpi_mach *acp63_sdw_machine_select(struct device *dev) 301 + { 302 + return NULL; 303 + } 336 304 #endif 305 + 306 + static int acp63_machine_register(struct device *dev) 307 + { 308 + struct snd_soc_acpi_mach *mach; 309 + struct acp63_dev_data *adata = dev_get_drvdata(dev); 310 + int size; 311 + 312 + if (adata->is_sdw_dev && adata->is_sdw_config) { 313 + size = sizeof(*adata->machines); 314 + mach = acp63_sdw_machine_select(dev); 315 + if (mach) { 316 + adata->mach_dev = platform_device_register_data(dev, mach->drv_name, 317 + PLATFORM_DEVID_NONE, mach, 318 + size); 319 + if (IS_ERR(adata->mach_dev)) { 320 + dev_err(dev, 321 + "cannot register Machine device for SoundWire Interface\n"); 322 + return PTR_ERR(adata->mach_dev); 323 + } 324 + } 325 + 326 + } else if (adata->is_pdm_dev && !adata->is_sdw_dev && adata->is_pdm_config) { 327 + adata->mach_dev = platform_device_register_data(dev, "acp_ps_mach", 328 + PLATFORM_DEVID_NONE, NULL, 0); 329 + if (IS_ERR(adata->mach_dev)) { 330 + dev_err(dev, "cannot register amd_ps_mach device\n"); 331 + return PTR_ERR(adata->mach_dev); 332 + } 333 + } 334 + return 0; 335 + } 337 336 338 337 static int get_acp63_device_config(struct pci_dev *pci, struct acp63_dev_data *acp_data) 339 338 { ··· 599 526 dev_err(&pci->dev, "ACP platform devices creation failed\n"); 600 527 goto de_init; 601 528 } 602 - 529 + ret = acp63_machine_register(&pci->dev); 530 + if (ret) { 531 + dev_err(&pci->dev, "ACP machine register failed\n"); 532 + goto de_init; 533 + } 603 534 skip_pdev_creation: 604 535 device_set_wakeup_enable(&pci->dev, true); 605 536 pm_runtime_set_autosuspend_delay(&pci->dev, ACP_SUSPEND_DELAY_MS); ··· 717 640 platform_device_unregister(adata->pdm_dev); 718 641 platform_device_unregister(adata->dmic_codec_dev); 719 642 } 643 + if (adata->mach_dev) 644 + platform_device_unregister(adata->mach_dev); 720 645 ret = acp63_deinit(adata->acp63_base, &pci->dev); 721 646 if (ret) 722 647 dev_err(&pci->dev, "ACP de-init failed\n");