From patchwork Wed Feb 14 10:40:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 200893 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1121153dyb; Wed, 14 Feb 2024 02:41:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV2jQBPiTDwXv8z6JvzUwxqIt/ZCoWCzHxiRV2uvyHvLwQUu2ZVlM1z/9e8laD/P4q9m4ounOoZY9hvYC7z3bw2TNVrWA== X-Google-Smtp-Source: AGHT+IHwI1tRtL9897V/12LGUYlXWElM0k3xvDrRTG3zZmDdDBngv114PP780+yCzSmcOem5PBpn X-Received: by 2002:a05:6512:47a:b0:511:8cb2:2f82 with SMTP id x26-20020a056512047a00b005118cb22f82mr1565876lfd.44.1707907264873; Wed, 14 Feb 2024 02:41:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTj4saTtDhiAsp0+wASrKrawbAT4jndZTCAOVXrml6TfU/EaMx5xLnlKGn7MqveigAYIou9JS1SqdlIm/Kv39rIgfuFA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dv19-20020a170906b81300b00a3d25387530si930241ejb.368.2024.02.14.02.41.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 02:41:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=JrfAXeRO; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-65062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4A0CA1F230EE for ; Wed, 14 Feb 2024 10:41:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23E7619473; Wed, 14 Feb 2024 10:40:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="JrfAXeRO" Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2073.outbound.protection.outlook.com [40.107.96.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26A1117543; Wed, 14 Feb 2024 10:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907238; cv=fail; b=fJ+998kd7jIfFFb0xrUpG1cRkmZof7/Ll/XGZYqF/eJ/9UVd8B+YhZtfrG0VGl9zw27cCxBHPmQGPH4r/s/+Yh/hE6eK+riTE2y7YcO2gYWAUGtFqt+TBJMxMlxlszEJ7xMwE1K5vN1hwINbvxNLaI1LTN+EOqqZXqjMuxwrEEE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907238; c=relaxed/simple; bh=KiRUhiXNkrqEbk9MsELgK/UZKEb9ywA04Zw3Q6SvgBM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Z2YlKuuLRkLR1m4/Rou/GrsW0EW7NgoxhyMcSjKIzERRzCc2xydtlztwNJ9MLjfPXZJgiyn4smzLYTUgQh+C4LoO8WnU7mOwTF5ofXEwZOcnOa9rG6vMhc/pZyxBF4Sh9aGBZe5UvZiGbnhgKd4VgeQaPCLxknVIIbZj7YaGW/M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=JrfAXeRO; arc=fail smtp.client-ip=40.107.96.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T4gsMPkGNEHpd1+WWX0INZaucmq2nTxuXeSX6Ybd/BuqWUAFYwnenY+RxhX1NLTBaolB0uBA/H2vbM33uyjOdAhp3BqGosu0GEeh2uLxcH/65mjdrXBNBjvwaDxrptxMTFVZVwFyGgp30OGAE6TLYAG4IBXo8POjLHkKYOMXsncKd25w0kPhJUvCmNKpRwEilM1j/sWgT2dtbZnQIigje4RrVtA2Ful5caTiyY7fcZ8lHOI0cOm7l9YmJhEsRcO4WUwaeP/O8hwkhBAsWMfoIuMdL8+6iZyDy+u6DgT53zPDzsfyRQ933mMzsADT+DOZeoy5M4o5dvQY6MVKg6AkAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JmNHY+JFIU9aBiXzGwh7sfFVz0C2synAQYrNH6fYGio=; b=JVUH1Vd26Amx1vfKzgtaHL110Z1756dpE1Fnsc0Br1aCFlDDlogKEpobLR23hb91d+5tbvoNbezBNle2aiBFqz5jhhXLxq2Ou5qoKbqgUwSlMUsgCzAVjyJ33s+SvVonXxbEe7ensTqXcyeNUeOp5cN5hPP6uWdbOc+lDa8rKFOO2gP6Npiu3th0UtPfOVf89UvL/SA+jTdeZJARm8kRugGE6oOyMBfiH68EcpdZlSwZ0TByiHjoOnxKQrwmLxiH9ZA0tseqwS/RAbqgbnAThkCWUJijuWxK2E66CXB+W2xbc61Wn5NEjH5MFchv+q2fmIOHGl6gOq95dX0X1okbKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JmNHY+JFIU9aBiXzGwh7sfFVz0C2synAQYrNH6fYGio=; b=JrfAXeRObpjhiLC7VnBYWLyule6IlnNUEKTJhSecyZkb7WxEowMVZkEGgBucv97dfuLAP8UXGDwQugL1B6+Mg+/i02L5ieUL9CeE+32L+kuFYRQ+naLBuJutwHnvsNxFZN3pqGdIOY5aotHBMwMJsV5jf7uCbUDbivBXf0KC8JQ= Received: from MW4P223CA0013.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::18) by SA0PR12MB4382.namprd12.prod.outlook.com (2603:10b6:806:9a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.27; Wed, 14 Feb 2024 10:40:32 +0000 Received: from CO1PEPF000044F0.namprd05.prod.outlook.com (2603:10b6:303:80:cafe::39) by MW4P223CA0013.outlook.office365.com (2603:10b6:303:80::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.39 via Frontend Transport; Wed, 14 Feb 2024 10:40:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044F0.mail.protection.outlook.com (10.167.241.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7292.25 via Frontend Transport; Wed, 14 Feb 2024 10:40:30 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 14 Feb 2024 04:40:29 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Wed, 14 Feb 2024 04:40:20 -0600 From: Vijendar Mukunda To: CC: , , , , , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Arnd Bergmann , "Cristian Ciocaltea" , Lucas Tanure , Syed Saba Kareem , Carlos Bilbao , Mario Limonciello , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [PATCH 1/5] ASoC: amd: ps: refactor acp device configuration read logic Date: Wed, 14 Feb 2024 16:10:01 +0530 Message-ID: <20240214104014.1144668-1-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F0:EE_|SA0PR12MB4382:EE_ X-MS-Office365-Filtering-Correlation-Id: 0265def9-00cf-4a97-ab53-08dc2d495df6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: phiTRaMD/BFHJjuvd/20L0+JtD6u+rJ4tG5fanZgXS9aFknIIHPZ6bdZ9rkvOe0zVIQb/eePAmJ7iDnCS0ZGSKzQhuE4tH7qR4PR/s5wJyOCrkdlEPGFCCVkmX5CW3nKQg5g6rcv810y5lQuesUsIyf8U0mkZBu6zoETQd4gkvwtPU6HJE827jJHvtcspU1/K2mzQGz1qHz0sHxD8tan/X9HTYLgKE6X5iRpGtE6xyswteewCfg2VlwSopzh5Iiqv7V5kVPRvsKXyRkx6rDJKenM9XymlPgQ0keRSYIidxZH34qSEtaVRYwAQYP+E6yR4p+h97n5tgz6TT6BlSr7gMNwwFbPqEmGMvREb2Uv1b0hTQQTUbRWHBuYDPvqmjQ0zGabTVMpQsH5k58Xiq+QET9kJB0nvHaECw3VuAH4Z2FSmyq0UPfi8XANcKsyiRAm7VoqjVoyRyk+VjxndX2vq8T+6dSzB9rU5LZssTMN7JBIwfLoB4VvmBBctysFw/HnNF8tdCTDI8AYG7g4RYeoxxIYiZ6X+LSKJNKo1NjTUpLk3nXJzSr6iwM61fUMKmicHNh4xrbA3kYRvdXjfePWDKYu9VMxNG+icqFd5ItlOak= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(136003)(376002)(346002)(39860400002)(230922051799003)(64100799003)(451199024)(1800799012)(82310400011)(186009)(46966006)(36840700001)(40470700004)(2906002)(30864003)(7416002)(5660300002)(478600001)(7696005)(86362001)(83380400001)(41300700001)(36756003)(426003)(2616005)(26005)(1076003)(336012)(4326008)(54906003)(70586007)(8936002)(8676002)(6916009)(70206006)(6666004)(316002)(82740400003)(81166007)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2024 10:40:30.9889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0265def9-00cf-4a97-ab53-08dc2d495df6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4382 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790870567807411537 X-GMAIL-MSGID: 1790870567807411537 Refactor acp device configuration read logic and use common function to scan SoundWire devices. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/Kconfig | 17 ++++ sound/soc/amd/ps/acp63.h | 11 +++ sound/soc/amd/ps/pci-ps.c | 176 +++++++++++--------------------------- 3 files changed, 78 insertions(+), 126 deletions(-) diff --git a/sound/soc/amd/Kconfig b/sound/soc/amd/Kconfig index 273688c05317..fa74635cee08 100644 --- a/sound/soc/amd/Kconfig +++ b/sound/soc/amd/Kconfig @@ -132,9 +132,26 @@ config SND_SOC_AMD_RPL_ACP6x Say m if you have such a device. If unsure select "N". +config SND_SOC_AMD_SOUNDWIRE_LINK_BASELINE + tristate + select SOUNDWIRE_AMD if SND_SOC_AMD_SOUNDWIRE != n + select SND_AMD_SOUNDWIRE_ACPI if ACPI + +config SND_SOC_AMD_SOUNDWIRE + tristate "Support for SoundWire based AMD platforms" + default SND_SOC_AMD_SOUNDWIRE_LINK_BASELINE + depends on SND_SOC_AMD_SOUNDWIRE_LINK_BASELINE + depends on ACPI && SOUNDWIRE + depends on !(SOUNDWIRE=m && SND_SOC_AMD_SOUNDWIRE_LINK_BASELINE=y) + help + This adds support for SoundWire for AMD platforms. + Say Y if you want to enable SoundWire links with SOF. + If unsure select "N". + config SND_SOC_AMD_PS tristate "AMD Audio Coprocessor-v6.3 Pink Sardine support" select SND_AMD_ACP_CONFIG + select SND_SOC_AMD_SOUNDWIRE_LINK_BASELINE depends on X86 && PCI && ACPI help This option enables Audio Coprocessor i.e ACP v6.3 support on diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index 8b853b8d0219..123b9ade69d4 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -5,6 +5,7 @@ * Copyright (C) 2022, 2023 Advanced Micro Devices, Inc. All rights reserved. */ +#include #include #define ACP_DEVICE_ID 0x15E2 @@ -263,6 +264,11 @@ struct sdw_dma_ring_buf_reg { * @sdw0_dev_index: SoundWire Manager-0 platform device index * @sdw1_dev_index: SoundWire Manager-1 platform device index * @sdw_dma_dev_index: SoundWire DMA controller platform device index + * @info: SoundWire AMD information found in ACPI tables + * @is_sdw_dev: flag set to true when any SoundWire manager instances are available + * @is_pdm_dev: flag set to true when ACP PDM controller exists + * @is_pdm_config: flat set to true when PDM configuration is selected from BIOS + * @is_sdw_config: flag set to true when SDW configuration is selected from BIOS * @sdw0-dma_intr_stat: DMA interrupt status array for SoundWire manager-SW0 instance * @sdw_dma_intr_stat: DMA interrupt status array for SoundWire manager-SW1 instance * @acp_reset: flag set to true when bus reset is applied across all @@ -282,6 +288,11 @@ struct acp63_dev_data { u16 sdw0_dev_index; u16 sdw1_dev_index; u16 sdw_dma_dev_index; + struct sdw_amd_acpi_info info; + bool is_sdw_dev; + bool is_pdm_dev; + bool is_pdm_config; + bool is_sdw_config; u16 sdw0_dma_intr_stat[ACP63_SDW0_DMA_MAX_STREAMS]; u16 sdw1_dma_intr_stat[ACP63_SDW1_DMA_MAX_STREAMS]; bool acp_reset; diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c index 5927eef04170..c97e418a88ce 100644 --- a/sound/soc/amd/ps/pci-ps.c +++ b/sound/soc/amd/ps/pci-ps.c @@ -237,122 +237,51 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) return IRQ_NONE; } -static int sdw_amd_scan_controller(struct device *dev) +#if IS_ENABLED(CONFIG_SND_SOC_AMD_SOUNDWIRE) +static int acp_scan_sdw_devices(struct device *dev, u64 addr) { + struct acpi_device *sdw_dev; struct acp63_dev_data *acp_data; - struct fwnode_handle *link; - char name[32]; - u32 sdw_manager_bitmap; - u8 count = 0; - u32 acp_sdw_power_mode = 0; - int index; - int ret; acp_data = dev_get_drvdata(dev); - /* - * Current implementation is based on MIPI DisCo 2.0 spec. - * Found controller, find links supported. - */ - ret = fwnode_property_read_u32_array((acp_data->sdw_fw_node), "mipi-sdw-manager-list", - &sdw_manager_bitmap, 1); - - if (ret) { - dev_dbg(dev, "Failed to read mipi-sdw-manager-list: %d\n", ret); - return -EINVAL; - } - count = hweight32(sdw_manager_bitmap); - /* Check count is within bounds */ - if (count > AMD_SDW_MAX_MANAGERS) { - dev_err(dev, "Manager count %d exceeds max %d\n", count, AMD_SDW_MAX_MANAGERS); - return -EINVAL; - } + if (!addr) + return -ENODEV; - if (!count) { - dev_dbg(dev, "No SoundWire Managers detected\n"); - return -EINVAL; - } - dev_dbg(dev, "ACPI reports %d SoundWire Manager devices\n", count); - acp_data->sdw_manager_count = count; - for (index = 0; index < count; index++) { - scnprintf(name, sizeof(name), "mipi-sdw-link-%d-subproperties", index); - link = fwnode_get_named_child_node(acp_data->sdw_fw_node, name); - if (!link) { - dev_err(dev, "Manager node %s not found\n", name); - return -EIO; - } + sdw_dev = acpi_find_child_device(ACPI_COMPANION(dev), addr, 0); + if (!sdw_dev) + return -ENODEV; - ret = fwnode_property_read_u32(link, "amd-sdw-power-mode", &acp_sdw_power_mode); - if (ret) - return ret; - /* - * when SoundWire configuration is selected from acp pin config, - * based on manager instances count, acp init/de-init sequence should be - * executed as part of PM ops only when Bus reset is applied for the active - * SoundWire manager instances. - */ - if (acp_sdw_power_mode != AMD_SDW_POWER_OFF_MODE) { - acp_data->acp_reset = false; - return 0; - } - } + acp_data->info.handle = sdw_dev->handle; + acp_data->info.count = AMD_SDW_MAX_MANAGERS; + return amd_sdw_scan_controller(&acp_data->info); +} +#else +static int acp_scan_sdw_devices(struct device *dev, u64 addr) +{ return 0; } +#endif -static int get_acp63_device_config(u32 config, struct pci_dev *pci, struct acp63_dev_data *acp_data) +static int get_acp63_device_config(struct pci_dev *pci, struct acp63_dev_data *acp_data) { - struct acpi_device *dmic_dev; - struct acpi_device *sdw_dev; + struct acpi_device *pdm_dev; const union acpi_object *obj; + u32 config; bool is_dmic_dev = false; bool is_sdw_dev = false; int ret; - dmic_dev = acpi_find_child_device(ACPI_COMPANION(&pci->dev), ACP63_DMIC_ADDR, 0); - if (dmic_dev) { - /* is_dmic_dev flag will be set when ACP PDM controller device exists */ - if (!acpi_dev_get_property(dmic_dev, "acp-audio-device-type", - ACPI_TYPE_INTEGER, &obj) && - obj->integer.value == ACP_DMIC_DEV) - is_dmic_dev = true; - } - - sdw_dev = acpi_find_child_device(ACPI_COMPANION(&pci->dev), ACP63_SDW_ADDR, 0); - if (sdw_dev) { - acp_data->sdw_fw_node = acpi_fwnode_handle(sdw_dev); - ret = sdw_amd_scan_controller(&pci->dev); - /* is_sdw_dev flag will be set when SoundWire Manager device exists */ - if (!ret) - is_sdw_dev = true; - } - if (!is_dmic_dev && !is_sdw_dev) - return -ENODEV; - dev_dbg(&pci->dev, "Audio Mode %d\n", config); + config = readl(acp_data->acp63_base + ACP_PIN_CONFIG); switch (config) { case ACP_CONFIG_4: case ACP_CONFIG_5: case ACP_CONFIG_10: case ACP_CONFIG_11: - if (is_dmic_dev) { - acp_data->pdev_config = ACP63_PDM_DEV_CONFIG; - acp_data->pdev_count = ACP63_PDM_MODE_DEVS; - } + acp_data->is_pdm_config = true; break; case ACP_CONFIG_2: case ACP_CONFIG_3: - if (is_sdw_dev) { - switch (acp_data->sdw_manager_count) { - case 1: - acp_data->pdev_config = ACP63_SDW_DEV_CONFIG; - acp_data->pdev_count = ACP63_SDW0_MODE_DEVS; - break; - case 2: - acp_data->pdev_config = ACP63_SDW_DEV_CONFIG; - acp_data->pdev_count = ACP63_SDW0_SDW1_MODE_DEVS; - break; - default: - return -EINVAL; - } - } + acp_data->is_sdw_config = true; break; case ACP_CONFIG_6: case ACP_CONFIG_7: @@ -360,40 +289,36 @@ static int get_acp63_device_config(u32 config, struct pci_dev *pci, struct acp63 case ACP_CONFIG_8: case ACP_CONFIG_13: case ACP_CONFIG_14: - if (is_dmic_dev && is_sdw_dev) { - switch (acp_data->sdw_manager_count) { - case 1: - acp_data->pdev_config = ACP63_SDW_PDM_DEV_CONFIG; - acp_data->pdev_count = ACP63_SDW0_PDM_MODE_DEVS; - break; - case 2: - acp_data->pdev_config = ACP63_SDW_PDM_DEV_CONFIG; - acp_data->pdev_count = ACP63_SDW0_SDW1_PDM_MODE_DEVS; - break; - default: - return -EINVAL; - } - } else if (is_dmic_dev) { - acp_data->pdev_config = ACP63_PDM_DEV_CONFIG; - acp_data->pdev_count = ACP63_PDM_MODE_DEVS; - } else if (is_sdw_dev) { - switch (acp_data->sdw_manager_count) { - case 1: - acp_data->pdev_config = ACP63_SDW_DEV_CONFIG; - acp_data->pdev_count = ACP63_SDW0_MODE_DEVS; - break; - case 2: - acp_data->pdev_config = ACP63_SDW_DEV_CONFIG; - acp_data->pdev_count = ACP63_SDW0_SDW1_MODE_DEVS; - break; - default: - return -EINVAL; - } - } + acp_data->is_pdm_config = true; + acp_data->is_sdw_config = true; break; default: break; } + + if (acp_data->is_pdm_config) { + pdm_dev = acpi_find_child_device(ACPI_COMPANION(&pci->dev), ACP63_DMIC_ADDR, 0); + if (pdm_dev) { + /* is_dmic_dev flag will be set when ACP PDM controller device exists */ + if (!acpi_dev_get_property(pdm_dev, "acp-audio-device-type", + ACPI_TYPE_INTEGER, &obj) && + obj->integer.value == ACP_DMIC_DEV) + is_dmic_dev = true; + } + } + + if (acp_data->is_sdw_config) { + ret = acp_scan_sdw_devices(&pci->dev, ACP63_SDW_ADDR); + if (!ret && acp_data->info.link_mask) + is_sdw_dev = true; + } + + acp_data->is_pdm_dev = is_dmic_dev; + acp_data->is_sdw_dev = is_sdw_dev; + if (!is_dmic_dev && !is_sdw_dev) { + dev_dbg(&pci->dev, "No PDM or SoundWire manager devices found\n"); + return -ENODEV; + } return 0; } @@ -576,7 +501,6 @@ static int snd_acp63_probe(struct pci_dev *pci, struct acp63_dev_data *adata; u32 addr; u32 irqflags, flag; - int val; int ret; irqflags = IRQF_SHARED; @@ -637,8 +561,7 @@ static int snd_acp63_probe(struct pci_dev *pci, dev_err(&pci->dev, "ACP PCI IRQ request failed\n"); goto de_init; } - val = readl(adata->acp63_base + ACP_PIN_CONFIG); - ret = get_acp63_device_config(val, pci, adata); + ret = get_acp63_device_config(pci, adata); /* ACP PCI driver probe should be continued even PDM or SoundWire Devices are not found */ if (ret) { dev_dbg(&pci->dev, "get acp device config failed:%d\n", ret); @@ -740,4 +663,5 @@ module_pci_driver(ps_acp63_driver); MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); MODULE_AUTHOR("Syed.SabaKareem@amd.com"); MODULE_DESCRIPTION("AMD ACP Pink Sardine PCI driver"); +MODULE_IMPORT_NS(SND_AMD_SOUNDWIRE_ACPI); MODULE_LICENSE("GPL v2"); From patchwork Wed Feb 14 10:40:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 200894 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1121409dyb; Wed, 14 Feb 2024 02:41:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXe7CgCqAugdM3VNggJWqAkk+qJaZYL+D+9Me9clo+9Wi5lkW10RJzR5GnUXelxS/ROb6Y7ri93WSeB/7gLK5mG24AheA== X-Google-Smtp-Source: AGHT+IGQOdN0HWi0+IXhcGFeEPAuA11PdxNibjPmBD8ZwfZIFpUm5Nu6IQGgOU1nNrGok58nhSlV X-Received: by 2002:a05:620a:1665:b0:787:273e:229e with SMTP id d5-20020a05620a166500b00787273e229emr2327236qko.68.1707907310674; Wed, 14 Feb 2024 02:41:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+XEjyP/7jXpZzbE3B2uCgliO9rqb5GTZebkNSpoNpOgPTjffBwdRJnRlofgOvLuGYT6b2kCnBYQ+l9HTT0c1/jD/P5A== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id vw4-20020a05620a564400b00783fb7d5b15si5965601qkn.506.2024.02.14.02.41.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 02:41:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Q68FfLxe; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-65063-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65063-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8E99D1C27726 for ; Wed, 14 Feb 2024 10:41:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7743E199D9; Wed, 14 Feb 2024 10:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Q68FfLxe" Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2070.outbound.protection.outlook.com [40.107.212.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB9EC1865C; Wed, 14 Feb 2024 10:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907252; cv=fail; b=e2Rk5KlHwXVu44O3zlxu5bl1lxY4AQjgOuT19xfQROUJBIf0txDGEM58NGyKGPVmlZR7bFyyGyYWARFW/mi5y+DHoOjzCRzQ/6OsIHTnf0FuAGmbO4KuFGhLN2Ayv2CltguQpXHyZCvoPYlSCrtTKzA2D8pDW6e10LuBpiijwz4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907252; c=relaxed/simple; bh=Xxyi0Cbq8a1/kLAy0H3uOMyM+ziuEQ/cmLkrkuBUPHE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hjwl/DOXczloZ4jhplsF2SLf991usQXFxV+OgyQuE1HKfSlmBpv2vjo4A/HxHEiEKAq8NQNF6MIoDynH+JHKc6wCIb7jsh4Qr7RYBO7CdtpmsDMjBpMJ4KkNdBcg3Zh7jf+ANTb21eX5NclPPUpdcsrwUBZ5oM9qAgi7H6+qpeI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Q68FfLxe; arc=fail smtp.client-ip=40.107.212.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mK4SQo7F/ZWEcYiwORSFKXuM19VLsSgIuinJBOebbs1cD1eNH7jgwL8toOc/SUOg5fJDuTw9B3ahbvI7n7IuBNkCf/NFJYZ2nevsdtumLd4OSXsoiRGK9IvgDlnhvdx3tlbbzPLkoqAQK+bocRhw1nBcNcziU9c5yhA6VQPB5kKD/QisRK+eK0IjhIQXtMFaaKkUkV77tmyg7P3WTC8bCDyXHtck3eER3qWTQHv5zKkbN0ntmp/3+IKFHUC+XEkPfkJfnrHMQ/QK7YRCPKI1VA0DQvllziFR8LTK6qpExtYaLDJiuoXAHPzKA41/MhaE62TsQ/VhVqzk4HSShbcAnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bmKb5m3sVhwQEwpSMpdRyg/LzslDWgf2918PndYEHrU=; b=TPv3MyP+iom7Qmn+c8qOpWzT72qpw1FsX2hXwGMdPT43v+lp3+RDnqfnxaGPdsi/LP4pEtJOtY7Yj0EvZOeR+LZyBWGIzj4foHMACBEwtZtNBlSBY2LGDRayS564FUPZs9TAb/ZpFW094mYQ8og1hgPqhlpIpV0dA5mq2GJsTNg2YRYYi8pJJhMjJzkZngI2EJKgHVdQOf9mIaA4hepTiapSuK4zOHEnuUFrimyj0RgPUxct2GiGoqx9vrgdS1J0QDnA7/G2Of+aVHu87qiX6BnBd5DHZb9JqcqTei12s3g7quRs/6kVwy0T5nXWRjNbofG8W3onC4J025Vmgj2Ohg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bmKb5m3sVhwQEwpSMpdRyg/LzslDWgf2918PndYEHrU=; b=Q68FfLxebawSM/ESRQ6cPjtW19wmBatiIvr9+xWBqLaTUieLMWSJYlBPSOaWFe2njMjCe0wFWRgB4ZQFmhCEP484GMnt9QXP7Gr74JoWvESYpHvljx7L/vrza5GV85RNVpfna7Y2aFBRr3USBuR8fsslXPrxsbLnA+4Ap9sHE38= Received: from CH2PR11CA0025.namprd11.prod.outlook.com (2603:10b6:610:54::35) by IA1PR12MB6020.namprd12.prod.outlook.com (2603:10b6:208:3d4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.24; Wed, 14 Feb 2024 10:40:46 +0000 Received: from DS3PEPF000099D5.namprd04.prod.outlook.com (2603:10b6:610:54:cafe::1f) by CH2PR11CA0025.outlook.office365.com (2603:10b6:610:54::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.35 via Frontend Transport; Wed, 14 Feb 2024 10:40:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D5.mail.protection.outlook.com (10.167.17.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7292.25 via Frontend Transport; Wed, 14 Feb 2024 10:40:46 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 14 Feb 2024 04:40:45 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 14 Feb 2024 02:40:44 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Wed, 14 Feb 2024 04:40:35 -0600 From: Vijendar Mukunda To: CC: , , , , , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Syed Saba Kareem , Carlos Bilbao , Mario Limonciello , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [PATCH 2/5] ASoC: amd: ps: refactor acp child platform device creation code Date: Wed, 14 Feb 2024 16:10:02 +0530 Message-ID: <20240214104014.1144668-2-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214104014.1144668-1-Vijendar.Mukunda@amd.com> References: <20240214104014.1144668-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D5:EE_|IA1PR12MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: a1dc3a00-6c86-4bad-d78c-08dc2d4966f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rvHuuBxk7pXm5aCYbLvsA+5/xNp1T0eC+Yqb/58mDmwT+uvbNwSN7Hvkro08Z8KO7sugtANKHMc+lEi9K0xRybOdQN56Eib0rkzzh49b+/DuKfcIA6aD2BQ8Vk8QIHjnjzakxJQqIckAOVUV+WA07G6L9l1u8JwPU8XkRWz4ft/bAtk3HopYqi9zLZFvsadj/sisUF6JK7X+W0vB2nw8nXoHZxjlxnU9kW9xvEopIpBpK0Qtr7L7IeIIXY4xZzNSaND7GCKI1j1vhvb1gNbYyr4cdVx/41y9GULBa2+EVnz5xO7ano/D4dfyhka3x8hbeXSU5/CUNX804sGBEEXZpUPWIWv3OEmtjSVlb+jKDsgrAeL2Et8HILcyl9T1nEZ2Dw98ewLzajEH1uEFy6ik+0ruEAC5z5trBgCachrcKuU36eS7tuWLd7LIIS4XPTWUitw68JYlExfpcn/PE2WG9vvLiNYKHseJvrd1xdIHJ6q/Am92PMF3wfAjPLLfdH4ut8H3PqZ78fIMf0ITtwCuyw/343OO4/efR4HyH0a12C4u5eGkAdmAa9k/ke7nH+Xw1De2vnzs5XWka1rCtbnmnLT5n+0Flvw+/WULo7RgVu0= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(396003)(346002)(376002)(39860400002)(230922051799003)(230273577357003)(64100799003)(186009)(1800799012)(451199024)(82310400011)(46966006)(40470700004)(36840700001)(82740400003)(81166007)(356005)(5660300002)(41300700001)(83380400001)(86362001)(30864003)(70206006)(8676002)(36756003)(336012)(70586007)(8936002)(4326008)(2906002)(426003)(54906003)(6666004)(6916009)(1076003)(316002)(478600001)(2616005)(26005)(7696005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2024 10:40:46.1052 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1dc3a00-6c86-4bad-d78c-08dc2d4966f6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6020 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790870616604816446 X-GMAIL-MSGID: 1790870616604816446 Refactor ACP child platform device creation code based on acp config. Use common SoundWire manager functions for device probe and exit sequences. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/acp63.h | 69 +++-------- sound/soc/amd/ps/pci-ps.c | 237 +++++++++++++++++--------------------- 2 files changed, 116 insertions(+), 190 deletions(-) diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index 123b9ade69d4..b2fd554d50d2 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -11,7 +11,6 @@ #define ACP_DEVICE_ID 0x15E2 #define ACP63_REG_START 0x1240000 #define ACP63_REG_END 0x1250200 -#define ACP63_DEVS 5 #define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001 #define ACP_PGFSM_CNTL_POWER_ON_MASK 1 @@ -56,32 +55,6 @@ #define ACP_DMIC_DEV 2 -/* ACP63_PDM_MODE_DEVS corresponds to platform devices count for ACP PDM configuration */ -#define ACP63_PDM_MODE_DEVS 3 - -/* - * ACP63_SDW0_MODE_DEVS corresponds to platform devices count for - * SW0 SoundWire manager instance configuration - */ -#define ACP63_SDW0_MODE_DEVS 2 - -/* - * ACP63_SDW0_SDW1_MODE_DEVS corresponds to platform devices count for SW0 + SW1 SoundWire manager - * instances configuration - */ -#define ACP63_SDW0_SDW1_MODE_DEVS 3 - -/* - * ACP63_SDW0_PDM_MODE_DEVS corresponds to platform devices count for SW0 manager - * instance + ACP PDM controller configuration - */ -#define ACP63_SDW0_PDM_MODE_DEVS 4 - -/* - * ACP63_SDW0_SDW1_PDM_MODE_DEVS corresponds to platform devices count for - * SW0 + SW1 SoundWire manager instances + ACP PDM controller configuration - */ -#define ACP63_SDW0_SDW1_PDM_MODE_DEVS 5 #define ACP63_DMIC_ADDR 2 #define ACP63_SDW_ADDR 5 #define AMD_SDW_MAX_MANAGERS 2 @@ -89,17 +62,6 @@ /* time in ms for acp timeout */ #define ACP_TIMEOUT 500 -/* ACP63_PDM_DEV_CONFIG corresponds to platform device configuration for ACP PDM controller */ -#define ACP63_PDM_DEV_CONFIG BIT(0) - -/* ACP63_SDW_DEV_CONFIG corresponds to platform device configuration for SDW manager instances */ -#define ACP63_SDW_DEV_CONFIG BIT(1) - -/* - * ACP63_SDW_PDM_DEV_CONFIG corresponds to platform device configuration for ACP PDM + SoundWire - * manager instance combination. - */ -#define ACP63_SDW_PDM_DEV_CONFIG GENMASK(1, 0) #define ACP_SDW0_STAT BIT(21) #define ACP_SDW1_STAT BIT(2) #define ACP_ERROR_IRQ BIT(29) @@ -254,21 +216,18 @@ struct sdw_dma_ring_buf_reg { * struct acp63_dev_data - acp pci driver context * @acp63_base: acp mmio base * @res: resource - * @pdev: array of child platform device node structures + * @pdm_dev: ACP PDM controller platform device + * @dmic_codec: platform device for DMIC Codec + * sdw_dma_dev: platform device for SoundWire DMA controller * @acp_lock: used to protect acp common registers - * @sdw_fw_node: SoundWire controller fw node handle - * @pdev_config: platform device configuration - * @pdev_count: platform devices count - * @pdm_dev_index: pdm platform device index - * @sdw_manager_count: SoundWire manager instance count - * @sdw0_dev_index: SoundWire Manager-0 platform device index - * @sdw1_dev_index: SoundWire Manager-1 platform device index - * @sdw_dma_dev_index: SoundWire DMA controller platform device index * @info: SoundWire AMD information found in ACPI tables + * @sdw: SoundWire context for all SoundWire manager instances * @is_sdw_dev: flag set to true when any SoundWire manager instances are available * @is_pdm_dev: flag set to true when ACP PDM controller exists * @is_pdm_config: flat set to true when PDM configuration is selected from BIOS * @is_sdw_config: flag set to true when SDW configuration is selected from BIOS + * @addr: pci ioremap address + * @reg_range: ACP reigister range * @sdw0-dma_intr_stat: DMA interrupt status array for SoundWire manager-SW0 instance * @sdw_dma_intr_stat: DMA interrupt status array for SoundWire manager-SW1 instance * @acp_reset: flag set to true when bus reset is applied across all @@ -278,21 +237,19 @@ struct sdw_dma_ring_buf_reg { struct acp63_dev_data { void __iomem *acp63_base; struct resource *res; - struct platform_device *pdev[ACP63_DEVS]; + struct platform_device *pdm_dev; + struct platform_device *dmic_codec_dev; + struct platform_device *sdw_dma_dev; struct mutex acp_lock; /* protect shared registers */ - struct fwnode_handle *sdw_fw_node; - u16 pdev_config; - u16 pdev_count; - u16 pdm_dev_index; - u8 sdw_manager_count; - u16 sdw0_dev_index; - u16 sdw1_dev_index; - u16 sdw_dma_dev_index; struct sdw_amd_acpi_info info; + /* sdw context allocated by SoundWire driver */ + struct sdw_amd_ctx *sdw; bool is_sdw_dev; bool is_pdm_dev; bool is_pdm_config; bool is_sdw_config; + u32 addr; + u32 reg_range; u16 sdw0_dma_intr_stat[ACP63_SDW0_DMA_MAX_STREAMS]; u16 sdw1_dma_intr_stat[ACP63_SDW1_DMA_MAX_STREAMS]; bool acp_reset; diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c index c97e418a88ce..b7cb3f98707f 100644 --- a/sound/soc/amd/ps/pci-ps.c +++ b/sound/soc/amd/ps/pci-ps.c @@ -104,10 +104,8 @@ static irqreturn_t acp63_irq_thread(int irq, void *context) struct sdw_dma_dev_data *sdw_dma_data; struct acp63_dev_data *adata = context; u32 stream_index; - u16 pdev_index; - pdev_index = adata->sdw_dma_dev_index; - sdw_dma_data = dev_get_drvdata(&adata->pdev[pdev_index]->dev); + sdw_dma_data = dev_get_drvdata(&adata->sdw_dma_dev->dev); for (stream_index = 0; stream_index < ACP63_SDW0_DMA_MAX_STREAMS; stream_index++) { if (adata->sdw0_dma_intr_stat[stream_index]) { @@ -135,7 +133,6 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) u32 stream_id = 0; u16 irq_flag = 0; u16 sdw_dma_irq_flag = 0; - u16 pdev_index; u16 index; adata = dev_id; @@ -149,8 +146,7 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) ext_intr_stat = readl(adata->acp63_base + ACP_EXTERNAL_INTR_STAT); if (ext_intr_stat & ACP_SDW0_STAT) { writel(ACP_SDW0_STAT, adata->acp63_base + ACP_EXTERNAL_INTR_STAT); - pdev_index = adata->sdw0_dev_index; - amd_manager = dev_get_drvdata(&adata->pdev[pdev_index]->dev); + amd_manager = dev_get_drvdata(&adata->sdw->pdev[0]->dev); if (amd_manager) schedule_work(&amd_manager->amd_sdw_irq_thread); irq_flag = 1; @@ -159,8 +155,7 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) ext_intr_stat1 = readl(adata->acp63_base + ACP_EXTERNAL_INTR_STAT1); if (ext_intr_stat1 & ACP_SDW1_STAT) { writel(ACP_SDW1_STAT, adata->acp63_base + ACP_EXTERNAL_INTR_STAT1); - pdev_index = adata->sdw1_dev_index; - amd_manager = dev_get_drvdata(&adata->pdev[pdev_index]->dev); + amd_manager = dev_get_drvdata(&adata->sdw->pdev[1]->dev); if (amd_manager) schedule_work(&amd_manager->amd_sdw_irq_thread); irq_flag = 1; @@ -176,8 +171,7 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) } if (ext_intr_stat & BIT(PDM_DMA_STAT)) { - pdev_index = adata->pdm_dev_index; - ps_pdm_data = dev_get_drvdata(&adata->pdev[pdev_index]->dev); + ps_pdm_data = dev_get_drvdata(&adata->pdm_dev->dev); writel(BIT(PDM_DMA_STAT), adata->acp63_base + ACP_EXTERNAL_INTR_STAT); if (ps_pdm_data->capture_stream) snd_pcm_period_elapsed(ps_pdm_data->capture_stream); @@ -255,11 +249,53 @@ static int acp_scan_sdw_devices(struct device *dev, u64 addr) acp_data->info.count = AMD_SDW_MAX_MANAGERS; return amd_sdw_scan_controller(&acp_data->info); } + +static int amd_sdw_probe(struct device *dev) +{ + struct acp63_dev_data *acp_data; + struct sdw_amd_res sdw_res; + int ret; + + acp_data = dev_get_drvdata(dev); + memset(&sdw_res, 0, sizeof(sdw_res)); + sdw_res.addr = acp_data->addr; + sdw_res.reg_range = acp_data->reg_range; + sdw_res.handle = acp_data->info.handle; + sdw_res.parent = dev; + sdw_res.dev = dev; + sdw_res.acp_lock = &acp_data->acp_lock; + sdw_res.count = acp_data->info.count; + sdw_res.mmio_base = acp_data->acp63_base; + sdw_res.link_mask = acp_data->info.link_mask; + ret = sdw_amd_probe(&sdw_res, &acp_data->sdw); + if (ret) + dev_err(dev, "error: SoundWire probe failed\n"); + return ret; +} + +static int amd_sdw_exit(struct acp63_dev_data *acp_data) +{ + if (acp_data->sdw) + sdw_amd_exit(acp_data->sdw); + acp_data->sdw = NULL; + + return 0; +} #else static int acp_scan_sdw_devices(struct device *dev, u64 addr) { return 0; } + +static int amd_sdw_probe(struct device *dev) +{ + return 0; +} + +static int amd_sdw_exit(struct acp63_dev_data *acp_data) +{ + return 0; +} #endif static int get_acp63_device_config(struct pci_dev *pci, struct acp63_dev_data *acp_data) @@ -343,17 +379,13 @@ static void acp63_fill_platform_dev_info(struct platform_device_info *pdevinfo, static int create_acp63_platform_devs(struct pci_dev *pci, struct acp63_dev_data *adata, u32 addr) { - struct acp_sdw_pdata *sdw_pdata; - struct platform_device_info pdevinfo[ACP63_DEVS]; + struct platform_device_info pdevinfo; struct device *parent; - int index; int ret; parent = &pci->dev; - dev_dbg(&pci->dev, - "%s pdev_config:0x%x pdev_count:0x%x\n", __func__, adata->pdev_config, - adata->pdev_count); - if (adata->pdev_config) { + + if (adata->is_sdw_dev || adata->is_pdm_dev) { adata->res = devm_kzalloc(&pci->dev, sizeof(struct resource), GFP_KERNEL); if (!adata->res) { ret = -ENOMEM; @@ -365,130 +397,57 @@ static int create_acp63_platform_devs(struct pci_dev *pci, struct acp63_dev_data memset(&pdevinfo, 0, sizeof(pdevinfo)); } - switch (adata->pdev_config) { - case ACP63_PDM_DEV_CONFIG: - adata->pdm_dev_index = 0; - acp63_fill_platform_dev_info(&pdevinfo[0], parent, NULL, "acp_ps_pdm_dma", + if (adata->is_pdm_dev && adata->is_pdm_config) { + acp63_fill_platform_dev_info(&pdevinfo, parent, NULL, "acp_ps_pdm_dma", 0, adata->res, 1, NULL, 0); - acp63_fill_platform_dev_info(&pdevinfo[1], parent, NULL, "dmic-codec", - 0, NULL, 0, NULL, 0); - acp63_fill_platform_dev_info(&pdevinfo[2], parent, NULL, "acp_ps_mach", - 0, NULL, 0, NULL, 0); - break; - case ACP63_SDW_DEV_CONFIG: - if (adata->pdev_count == ACP63_SDW0_MODE_DEVS) { - sdw_pdata = devm_kzalloc(&pci->dev, sizeof(struct acp_sdw_pdata), - GFP_KERNEL); - if (!sdw_pdata) { - ret = -ENOMEM; - goto de_init; - } - sdw_pdata->instance = 0; - sdw_pdata->acp_sdw_lock = &adata->acp_lock; - adata->sdw0_dev_index = 0; - adata->sdw_dma_dev_index = 1; - acp63_fill_platform_dev_info(&pdevinfo[0], parent, adata->sdw_fw_node, - "amd_sdw_manager", 0, adata->res, 1, - sdw_pdata, sizeof(struct acp_sdw_pdata)); - acp63_fill_platform_dev_info(&pdevinfo[1], parent, NULL, "amd_ps_sdw_dma", - 0, adata->res, 1, NULL, 0); - } else if (adata->pdev_count == ACP63_SDW0_SDW1_MODE_DEVS) { - sdw_pdata = devm_kzalloc(&pci->dev, sizeof(struct acp_sdw_pdata) * 2, - GFP_KERNEL); - if (!sdw_pdata) { - ret = -ENOMEM; - goto de_init; - } - - sdw_pdata[0].instance = 0; - sdw_pdata[1].instance = 1; - sdw_pdata[0].acp_sdw_lock = &adata->acp_lock; - sdw_pdata[1].acp_sdw_lock = &adata->acp_lock; - sdw_pdata->acp_sdw_lock = &adata->acp_lock; - adata->sdw0_dev_index = 0; - adata->sdw1_dev_index = 1; - adata->sdw_dma_dev_index = 2; - acp63_fill_platform_dev_info(&pdevinfo[0], parent, adata->sdw_fw_node, - "amd_sdw_manager", 0, adata->res, 1, - &sdw_pdata[0], sizeof(struct acp_sdw_pdata)); - acp63_fill_platform_dev_info(&pdevinfo[1], parent, adata->sdw_fw_node, - "amd_sdw_manager", 1, adata->res, 1, - &sdw_pdata[1], sizeof(struct acp_sdw_pdata)); - acp63_fill_platform_dev_info(&pdevinfo[2], parent, NULL, "amd_ps_sdw_dma", - 0, adata->res, 1, NULL, 0); + adata->pdm_dev = platform_device_register_full(&pdevinfo); + if (IS_ERR(adata->pdm_dev)) { + dev_err(&pci->dev, + "cannot register %s device\n", pdevinfo.name); + ret = PTR_ERR(adata->pdm_dev); + goto de_init; } - break; - case ACP63_SDW_PDM_DEV_CONFIG: - if (adata->pdev_count == ACP63_SDW0_PDM_MODE_DEVS) { - sdw_pdata = devm_kzalloc(&pci->dev, sizeof(struct acp_sdw_pdata), - GFP_KERNEL); - if (!sdw_pdata) { - ret = -ENOMEM; - goto de_init; - } - - sdw_pdata->instance = 0; - sdw_pdata->acp_sdw_lock = &adata->acp_lock; - adata->pdm_dev_index = 0; - adata->sdw0_dev_index = 1; - adata->sdw_dma_dev_index = 2; - acp63_fill_platform_dev_info(&pdevinfo[0], parent, NULL, "acp_ps_pdm_dma", - 0, adata->res, 1, NULL, 0); - acp63_fill_platform_dev_info(&pdevinfo[1], parent, adata->sdw_fw_node, - "amd_sdw_manager", 0, adata->res, 1, - sdw_pdata, sizeof(struct acp_sdw_pdata)); - acp63_fill_platform_dev_info(&pdevinfo[2], parent, NULL, "amd_ps_sdw_dma", - 0, adata->res, 1, NULL, 0); - acp63_fill_platform_dev_info(&pdevinfo[3], parent, NULL, "dmic-codec", - 0, NULL, 0, NULL, 0); - } else if (adata->pdev_count == ACP63_SDW0_SDW1_PDM_MODE_DEVS) { - sdw_pdata = devm_kzalloc(&pci->dev, sizeof(struct acp_sdw_pdata) * 2, - GFP_KERNEL); - if (!sdw_pdata) { - ret = -ENOMEM; - goto de_init; - } - sdw_pdata[0].instance = 0; - sdw_pdata[1].instance = 1; - sdw_pdata[0].acp_sdw_lock = &adata->acp_lock; - sdw_pdata[1].acp_sdw_lock = &adata->acp_lock; - adata->pdm_dev_index = 0; - adata->sdw0_dev_index = 1; - adata->sdw1_dev_index = 2; - adata->sdw_dma_dev_index = 3; - acp63_fill_platform_dev_info(&pdevinfo[0], parent, NULL, "acp_ps_pdm_dma", - 0, adata->res, 1, NULL, 0); - acp63_fill_platform_dev_info(&pdevinfo[1], parent, adata->sdw_fw_node, - "amd_sdw_manager", 0, adata->res, 1, - &sdw_pdata[0], sizeof(struct acp_sdw_pdata)); - acp63_fill_platform_dev_info(&pdevinfo[2], parent, adata->sdw_fw_node, - "amd_sdw_manager", 1, adata->res, 1, - &sdw_pdata[1], sizeof(struct acp_sdw_pdata)); - acp63_fill_platform_dev_info(&pdevinfo[3], parent, NULL, "amd_ps_sdw_dma", - 0, adata->res, 1, NULL, 0); - acp63_fill_platform_dev_info(&pdevinfo[4], parent, NULL, "dmic-codec", - 0, NULL, 0, NULL, 0); + memset(&pdevinfo, 0, sizeof(pdevinfo)); + acp63_fill_platform_dev_info(&pdevinfo, parent, NULL, "dmic-codec", + 0, NULL, 0, NULL, 0); + adata->dmic_codec_dev = platform_device_register_full(&pdevinfo); + if (IS_ERR(adata->dmic_codec_dev)) { + dev_err(&pci->dev, + "cannot register %s device\n", pdevinfo.name); + ret = PTR_ERR(adata->dmic_codec_dev); + goto unregister_pdm_dev; } - break; - default: - dev_dbg(&pci->dev, "No PDM or SoundWire manager devices found\n"); - return 0; } + if (adata->is_sdw_dev && adata->is_sdw_config) { + ret = amd_sdw_probe(&pci->dev); + if (ret) { + if (adata->is_pdm_dev) + goto unregister_dmic_codec_dev; + else + goto de_init; + } + memset(&pdevinfo, 0, sizeof(pdevinfo)); + acp63_fill_platform_dev_info(&pdevinfo, parent, NULL, "amd_ps_sdw_dma", + 0, adata->res, 1, NULL, 0); - for (index = 0; index < adata->pdev_count; index++) { - adata->pdev[index] = platform_device_register_full(&pdevinfo[index]); - if (IS_ERR(adata->pdev[index])) { + adata->sdw_dma_dev = platform_device_register_full(&pdevinfo); + if (IS_ERR(adata->sdw_dma_dev)) { dev_err(&pci->dev, - "cannot register %s device\n", pdevinfo[index].name); - ret = PTR_ERR(adata->pdev[index]); - goto unregister_devs; + "cannot register %s device\n", pdevinfo.name); + ret = PTR_ERR(adata->sdw_dma_dev); + if (adata->is_pdm_dev) + goto unregister_dmic_codec_dev; + else + goto de_init; } } + return 0; -unregister_devs: - for (--index; index >= 0; index--) - platform_device_unregister(adata->pdev[index]); +unregister_dmic_codec_dev: + platform_device_unregister(adata->dmic_codec_dev); +unregister_pdm_dev: + platform_device_unregister(adata->pdm_dev); de_init: if (acp63_deinit(adata->acp63_base, &pci->dev)) dev_err(&pci->dev, "ACP de-init failed\n"); @@ -542,6 +501,8 @@ static int snd_acp63_probe(struct pci_dev *pci, ret = -ENOMEM; goto release_regions; } + adata->addr = addr; + adata->reg_range = ACP63_REG_END - ACP63_REG_START; /* * By default acp_reset flag is set to true. i.e acp_deinit() and acp_init() * will be invoked for all ACP configurations during suspend/resume callbacks. @@ -572,6 +533,7 @@ static int snd_acp63_probe(struct pci_dev *pci, dev_err(&pci->dev, "ACP platform devices creation failed\n"); goto de_init; } + skip_pdev_creation: device_set_wakeup_enable(&pci->dev, true); pm_runtime_set_autosuspend_delay(&pci->dev, ACP_SUSPEND_DELAY_MS); @@ -626,11 +588,17 @@ static const struct dev_pm_ops acp63_pm_ops = { static void snd_acp63_remove(struct pci_dev *pci) { struct acp63_dev_data *adata; - int ret, index; + int ret; adata = pci_get_drvdata(pci); - for (index = 0; index < adata->pdev_count; index++) - platform_device_unregister(adata->pdev[index]); + if (adata->sdw) { + amd_sdw_exit(adata); + platform_device_unregister(adata->sdw_dma_dev); + } + if (adata->is_pdm_dev) { + platform_device_unregister(adata->pdm_dev); + platform_device_unregister(adata->dmic_codec_dev); + } ret = acp63_deinit(adata->acp63_base, &pci->dev); if (ret) dev_err(&pci->dev, "ACP de-init failed\n"); @@ -663,5 +631,6 @@ module_pci_driver(ps_acp63_driver); MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); MODULE_AUTHOR("Syed.SabaKareem@amd.com"); MODULE_DESCRIPTION("AMD ACP Pink Sardine PCI driver"); +MODULE_IMPORT_NS(SOUNDWIRE_AMD_INIT); MODULE_IMPORT_NS(SND_AMD_SOUNDWIRE_ACPI); MODULE_LICENSE("GPL v2"); From patchwork Wed Feb 14 10:40:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 200895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1121471dyb; Wed, 14 Feb 2024 02:41:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWNn1NC2xCM4vbpt9fJBVpC051wJBXM6Zt3GQC6QZRAoeW9645QpP3Sasf9C5xOwbVzid7z62r8HT2unxkqdhYVvXE+9Q== X-Google-Smtp-Source: AGHT+IF4TmP7IWIN0PYyBMPACe9QX/BRpr1ZFrI5hKuIO+MPPpj06YqlrYvQGR6EWdlFjA8VhqPh X-Received: by 2002:a05:620a:24d0:b0:785:c2ee:4131 with SMTP id m16-20020a05620a24d000b00785c2ee4131mr3013419qkn.5.1707907316582; Wed, 14 Feb 2024 02:41:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXn6umL7AKLIZEnV6krjs+I6YEm3MvapilIKngDB11bgbdOteLkoTwbb2akrLeUroabHgwePnTQUoNhyaystPD1FxAENA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y20-20020a05620a44d400b007858c70db7dsi11736975qkp.601.2024.02.14.02.41.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 02:41:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65064-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="AEaFl/zq"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-65064-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65064-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9C0BE1C22F5A for ; Wed, 14 Feb 2024 10:41:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A120C18E2F; Wed, 14 Feb 2024 10:41:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AEaFl/zq" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2085.outbound.protection.outlook.com [40.107.94.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32C451AAA9; Wed, 14 Feb 2024 10:41:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907266; cv=fail; b=r6cSpli1BRYHnv3rGQePvhpii3ga7gGVvfi4LvMUAfd+lda3oS4UCVbPNUjLXXcwFS2NvcR/GuVArnoNWEV1Js19FaGvbE0PLWP6H0UCfVWplckUpKMiHq3Luqq3G2QdxIn8PNgkH5yfFPh7qXcvPpPBJFGlAH2vSb99pGMm/lI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907266; c=relaxed/simple; bh=7GGyMLEmrKyv1Dfla83PwBrwUZjtTfLvANUynd8clGE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=suS869lWIReNAgJmalUnyWyC8Vr1BFvRMI/l1alrV4FOXloId5yF8SrykY8bde1ZXwJwUmT2Hn6Ap0yUAc1qWJMgCuaJ/LIukCLoFsMtE2qCN34g2J3+XLDttVOgRpsCQNzxm88W3rkrkZJT83RaFfGDO7CeNMEULDTS1e7ehok= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=AEaFl/zq; arc=fail smtp.client-ip=40.107.94.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nkMLW38ZwfwaU7v0zV1pzZlCp+AAtVPm/psY4ENZdKHga1BRv+EyZeM3tvgbIZpwh8+hclwKTokjrFVa/eR2hMoQFPSJ33O2dL6WqoA5dndtHq7zs8JjR+snj/BYkOO41JplLy/EW4Jcfn2p/kXUdaEUBGGawwI3OsWgG4aF903wMonsWwFqJ2Td67nshjB4YDSzlQ4s3ZYHkARLlt82f9bWQ8DKX/gs3xVXlCx2f8mbi88iTDQhbxhdO1I6Lm53cPe3Iq4QycdDaKmoKHnaf7wGBFLoLpy4qI4tAML2B3GNY0EkiH32CS5HrHMiVdGVAK/ao28cubryYgUFtcKIgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ap7PtlHEPoDBQ0VbLhy3Dz2qryEYO951wa7bkPP/0P8=; b=U9Hg/vJ42wgFqtEmxbIiw5bZEU5gv+Lc5/9Tq+WyfQmBgcg7zRbpUD/w2i0SeJ7iPxXA++qi6MfmAUYS3a/RLrI7pSx4S4LdKKzBC9BdLmtYI9m+LYDvv+4q6QmmnkjuQKwG/ghbYrEJ4zOyx76gUsSR+OBIzNHdyg0brWsPdFj3su6RXvYNlEdkoi30GL5OMayqbUp36F+PWAlKLJBW5WQP9pPDux0sVmCRdmsorfjeIC0HKoWb6FBwOMKlIRAMxGK9fPFQ0m1Kn2FVcC7g9q8G+F4xTzLpSEZVIU1VLRNH8wIJCqLZ9w6WIcI7/L1yqI1WjmwEPgHj0/koykrF8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ap7PtlHEPoDBQ0VbLhy3Dz2qryEYO951wa7bkPP/0P8=; b=AEaFl/zq0r9ben/KpTymQ0MXo1Lg8DsI9o0x5CDg/ghVgEbkKFOpaih9EFXdDyUnNW560XVdNsTNj8bNY8ZUtN/BgX2O0LGisZMKN4j0ABgUrj4iskm1Q0fGA/xM3R4ZLqP7MvyMu67+nFhWWq0LKMBG7O/rqzOSg1nJgKlW+ig= Received: from DS7PR03CA0268.namprd03.prod.outlook.com (2603:10b6:5:3b3::33) by DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25; Wed, 14 Feb 2024 10:41:01 +0000 Received: from CY4PEPF0000EE38.namprd03.prod.outlook.com (2603:10b6:5:3b3:cafe::43) by DS7PR03CA0268.outlook.office365.com (2603:10b6:5:3b3::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.26 via Frontend Transport; Wed, 14 Feb 2024 10:41:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE38.mail.protection.outlook.com (10.167.242.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Wed, 14 Feb 2024 10:41:01 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 14 Feb 2024 04:41:00 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 14 Feb 2024 02:40:59 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Wed, 14 Feb 2024 04:40:51 -0600 From: Vijendar Mukunda To: CC: , , , , , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Syed Saba Kareem , Carlos Bilbao , Mario Limonciello , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [PATCH 3/5] ASoC: amd: ps: remove acp_reset flag Date: Wed, 14 Feb 2024 16:10:03 +0530 Message-ID: <20240214104014.1144668-3-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214104014.1144668-1-Vijendar.Mukunda@amd.com> References: <20240214104014.1144668-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE38:EE_|DS0PR12MB7726:EE_ X-MS-Office365-Filtering-Correlation-Id: ff13c1c8-2353-45aa-132e-08dc2d496fe8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oVGqQlsmL0XR4AuHxN2XEJd+1ZbSBAI2Z0EUa7QkJGoAppic99R7A6/+2NfMc0qd7QoSZtJ71bD/xmum870HFL6gbxkLGKfwp/lDep8c4TXiweiffC2vs0oL6CQM+zmn376k0nhhxPt48wefxXB6inbhv622vrLskK9exdM9Cy0e4zoFwIY704mFg5Kp7tqqebCuOlDxE4t0GtQL6HVp/H5eeLkpZTDdnnFXaXBA0CKHHY6wUj38fJCeygoY//ht/LICbOF/VvFLppFYBEFycqD0zB5QQsBRRFM+XZ0nr3dR/UAsHM4fYJ/GsW3GwlpO+Gj0Ppf7W2YkQ/b9SLHpdr3DPp4/RJRn9TnHuKn2swiiCjKpFDNq33uTO2O5MHgPM1v6jphxh4O2AyTIfJhTijuJl6PM31wH14/qJdGzeAMi5cobF7c0vbHDo7XOU8Dcrr9OUNYsMU18SQAywVb4aziaRvsh3fSqo6qDzMyyvpPg18HjuWYoll40Y4+p4tplsextewsB3gANDPONkUDEGxbFQFJYBOkbeBLVR1YOL/IvETCD6Q6P6xYBcMjnOr4kzqY8JYi6FtV4jQcKa1Wfe/XtDQmGyLO15rs6E47UWDs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(396003)(376002)(39860400002)(136003)(230922051799003)(64100799003)(451199024)(186009)(82310400011)(1800799012)(36840700001)(40470700004)(46966006)(2906002)(1076003)(2616005)(41300700001)(478600001)(26005)(83380400001)(70206006)(426003)(4326008)(8936002)(6916009)(70586007)(336012)(8676002)(7696005)(5660300002)(36756003)(81166007)(54906003)(316002)(6666004)(356005)(82740400003)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2024 10:41:01.0923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff13c1c8-2353-45aa-132e-08dc2d496fe8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE38.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7726 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790870622227661980 X-GMAIL-MSGID: 1790870622227661980 The earlier acp_reset flag is set to true in two instances as mentioned below. 1. When active SoundWire manager instances power mode is set to Power off mode when SoundWire configuration is selected. 2. For other acp configurations As code being refactored and common function being used for scanning SoundWire controller, acp_reset flag update logic is dropped. Instead of it, check the SoundWire manager instance enable state, based on it update sdw_en_stat flag which will be used to apply ACP init/de-init sequence during suspend/resume callbacks based on flag set value when SoundWire configuration is selected. For other acp configurations, acp init/de-init will be called by default. Refactor existing pm ops logic for SoundWire configuration and use sdw_en_stat flag for invoking acp init/de-init sequence. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/acp63.h | 5 ++--- sound/soc/amd/ps/pci-ps.c | 44 +++++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index b2fd554d50d2..fb4261f7fa4b 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -226,12 +226,11 @@ struct sdw_dma_ring_buf_reg { * @is_pdm_dev: flag set to true when ACP PDM controller exists * @is_pdm_config: flat set to true when PDM configuration is selected from BIOS * @is_sdw_config: flag set to true when SDW configuration is selected from BIOS + * @sdw_en_stat: flag set to true when any one of the SoundWire manager instance is enabled * @addr: pci ioremap address * @reg_range: ACP reigister range * @sdw0-dma_intr_stat: DMA interrupt status array for SoundWire manager-SW0 instance * @sdw_dma_intr_stat: DMA interrupt status array for SoundWire manager-SW1 instance - * @acp_reset: flag set to true when bus reset is applied across all - * the active SoundWire manager instances */ struct acp63_dev_data { @@ -248,11 +247,11 @@ struct acp63_dev_data { bool is_pdm_dev; bool is_pdm_config; bool is_sdw_config; + bool sdw_en_stat; u32 addr; u32 reg_range; u16 sdw0_dma_intr_stat[ACP63_SDW0_DMA_MAX_STREAMS]; u16 sdw1_dma_intr_stat[ACP63_SDW1_DMA_MAX_STREAMS]; - bool acp_reset; }; int snd_amd_acp_find_config(struct pci_dev *pci); diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c index b7cb3f98707f..c141397a2cac 100644 --- a/sound/soc/amd/ps/pci-ps.c +++ b/sound/soc/amd/ps/pci-ps.c @@ -503,13 +503,6 @@ static int snd_acp63_probe(struct pci_dev *pci, } adata->addr = addr; adata->reg_range = ACP63_REG_END - ACP63_REG_START; - /* - * By default acp_reset flag is set to true. i.e acp_deinit() and acp_init() - * will be invoked for all ACP configurations during suspend/resume callbacks. - * This flag should be set to false only when SoundWire manager power mode - * set to ClockStopMode. - */ - adata->acp_reset = true; pci_set_master(pci); pci_set_drvdata(pci, adata); mutex_init(&adata->acp_lock); @@ -552,31 +545,46 @@ static int snd_acp63_probe(struct pci_dev *pci, return ret; } +static bool check_acp_sdw_enable_status(struct acp63_dev_data *adata) +{ + u32 sdw0_en, sdw1_en; + + sdw0_en = readl(adata->acp63_base + ACP_SW0_EN); + sdw1_en = readl(adata->acp63_base + ACP_SW1_EN); + return (sdw0_en || sdw1_en); +} + static int __maybe_unused snd_acp63_suspend(struct device *dev) { struct acp63_dev_data *adata; - int ret = 0; + int ret; adata = dev_get_drvdata(dev); - if (adata->acp_reset) { - ret = acp63_deinit(adata->acp63_base, dev); - if (ret) - dev_err(dev, "ACP de-init failed\n"); + if (adata->is_sdw_dev) { + adata->sdw_en_stat = check_acp_sdw_enable_status(adata); + if (adata->sdw_en_stat) + return 0; } + ret = acp63_deinit(adata->acp63_base, dev); + if (ret) + dev_err(dev, "ACP de-init failed\n"); + return ret; } static int __maybe_unused snd_acp63_resume(struct device *dev) { struct acp63_dev_data *adata; - int ret = 0; + int ret; adata = dev_get_drvdata(dev); - if (adata->acp_reset) { - ret = acp63_init(adata->acp63_base, dev); - if (ret) - dev_err(dev, "ACP init failed\n"); - } + if (adata->sdw_en_stat) + return 0; + + ret = acp63_init(adata->acp63_base, dev); + if (ret) + dev_err(dev, "ACP init failed\n"); + return ret; } From patchwork Wed Feb 14 10:40:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 200902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1127432dyb; Wed, 14 Feb 2024 02:57:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUl9UYL1sgkKK3ERK9wIf8T8HVkvnxNYCbr7grUIrIoCFNRt/IZhNn3nYRmeXbDRCZAE4g4BwNoBIAirwcoXCP3IennLg== X-Google-Smtp-Source: AGHT+IFDq7CWVDFtq5f85GkayyQPFNd2emFqJP93VEk8c3m/vaZ9EYIAzA1A3fgGgF8JqyVHk+E+ X-Received: by 2002:aa7:8759:0:b0:6e0:d77b:5939 with SMTP id g25-20020aa78759000000b006e0d77b5939mr1675184pfo.33.1707908234065; Wed, 14 Feb 2024 02:57:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUDZgUPi45JQ1H10QnpIRMFJTCAW/1ZW5s8KoosllppUXyrzwdN/fdvQrPUnfoKpSfnncvyDZsOaTanQXigbdYc4YzbBg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id c15-20020aa78e0f000000b006ddc2ac59c9si8160192pfr.391.2024.02.14.02.57.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 02:57:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=1GkmcT8S; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-65065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65065-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0B9A2B233F2 for ; Wed, 14 Feb 2024 10:41:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E0D01947D; Wed, 14 Feb 2024 10:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="1GkmcT8S" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ECDB1865A; Wed, 14 Feb 2024 10:41:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907281; cv=fail; b=ZPelbj4gEcYEalwRul0nOszqlDGIzpLAKITRk3ZcsrspVflx1NZbfRJfyv8SB0rrT4CS6s7JaKtiWLz6YhagImvs0Ag1b+8MfZUVglMHFmFqgk3UKy/6GnNxcaya68mKZIeN3nUx8NkWHI5WaBaYmKPxTNrx/tczoClWPuOKrak= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907281; c=relaxed/simple; bh=SvUkgTi5JfhK1HxO/PAd9xfvyBzsM+QFkYFoGHobaOQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WgfletMbJxfLVhu3lz08K64X7zyG5LFQVijW0btyfwwU3FCDA/Zl3cbxOhXAk3momhbuegpn6L+Kqk45F4cRyypMloBlCWOP+yVveOZwOn+7sDOLyUBD9wmvJdWhhFasK2Ir9WfjKWaqqof57rY3ScKkT2S9R4XKoeWSFfUPRdA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=1GkmcT8S; arc=fail smtp.client-ip=40.107.243.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I/nH/85d7eulMWW7z2M75OoqeWTSHPE08QPxNWm3je1tFSqGFaxMMm/YqaWcYVAyQFzzx0j596GAWuMCW8/tA4t/GtFdhiOYS5L3/hQ3TYu+uUmLsiMzka62u0HME02VXodZQdbc4Lnh7zwWz0kMoWBxztv+jqt+H61G8ECipKqK1Brx+gP2ytWQQQopMHkQwSnQ+l/50ShnD44Y6zh+teXRc+j/0XBb4Cnfk5rjuIKmfDOeOjs3dsAk5qqwQXB2Fj9VNeOPp/BO1yXU+54Avf9ci8aAAIc71LMWcjaWQbgcDwM9pXetApa+Qky/f4gEkZOFE9QOnSazH75Zjf+BAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HQpQQYT6OrmbToSwagJxnARrdplGpGJeYqq668FVBxo=; b=DhXq6uznkkznv+Rd3DiDfmsUlJHGUBjYejZyvmcuQPZKMfZ2txu6k9fkRTi0mr77F8kZqtuCfV1BVSX/50KC+845DvxkvmlTPGpU6yArZht3Gzg1CR7KIFZuaSnOFnrbpFEHP2gOm5pXQS/+SdrOJr+Xt63bYJOzyd7YHvrw8Dr2Hnj4SHLLPX5hXaivjPQtMWN3gdbw2WuPWj4TuBPLFsOohn1cQa7QJXinHZjkr61FqC/7aoIior3QM3oOTgHBMsr7zI50gAp074pIo8+AYyJvtSJDjbm64rT+z9nfUg7VWY5y/raGR49xZj8jpzhbNEHlt5v4gZM1o+p/NhHzYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HQpQQYT6OrmbToSwagJxnARrdplGpGJeYqq668FVBxo=; b=1GkmcT8StI2Vnjt3XVMu9bulJU7Km7Ufsfxftdsgu0bZDz+I6uD0cJ5MzXp7XZTMGBIu9iv8Mfh4t26+JpYYRsvktbo+OW1/3hHyLbAD0cE+O969FF3l1dOcAHCPQCmrvxAdrUO2OqUOsEFjetKxCQ0O8gGJy2JBE3OpX0qE71Q= Received: from MW4PR03CA0313.namprd03.prod.outlook.com (2603:10b6:303:dd::18) by PH0PR12MB5646.namprd12.prod.outlook.com (2603:10b6:510:143::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.24; Wed, 14 Feb 2024 10:41:17 +0000 Received: from CO1PEPF000044F1.namprd05.prod.outlook.com (2603:10b6:303:dd:cafe::fb) by MW4PR03CA0313.outlook.office365.com (2603:10b6:303:dd::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.26 via Frontend Transport; Wed, 14 Feb 2024 10:41:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044F1.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7292.25 via Frontend Transport; Wed, 14 Feb 2024 10:41:16 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 14 Feb 2024 04:41:11 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Wed, 14 Feb 2024 04:41:03 -0600 From: Vijendar Mukunda To: CC: , , , , , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Syed Saba Kareem , Mario Limonciello , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [PATCH 4/5] ASoC: amd: ps: fix for acp pme wake for soundwire configuration Date: Wed, 14 Feb 2024 16:10:04 +0530 Message-ID: <20240214104014.1144668-4-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214104014.1144668-1-Vijendar.Mukunda@amd.com> References: <20240214104014.1144668-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F1:EE_|PH0PR12MB5646:EE_ X-MS-Office365-Filtering-Correlation-Id: fe7b4919-e121-48b5-4e62-08dc2d49795b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S0VZaxBlWsRZkWh9DMLSuNCBJMKZVRSNcYn5FaoLp31VBf0K0DDEf0mcnsFK48DZUZc763xM6ETdL+mrC66ayX4ViqhipWlyA/7373AuA50W3eGecRZhyKQG+eYC0++BydZWOA7i68Fi6AbMeHU1l5E8U56oU+hezXSRWmLIiWUTj8gEz+kdmB88l7JjZJBvrDuoKrveAXa/oFet0Zk/4Edg3HTi7MMaXb7ov3aO/9SIps86QmhmRA0UYIXz17+4CLjNvcSa73yd4wESZ7ZfYiTCOFPBY54Xfrq1AGpNOh3xXQPu+yeiaY5PFHMaT/Pni9zEvx/9bBXbvwgggwK/eysR9YxT9CrYy2+wF4iApmQNL97jxqsm4VnEhA66e8Yrahl6n84H+PQa7VQUm3JnTFdm+HbKkdox/XX+LAE/gp1mDPy9HxECjaV0R4d4/WZ/6tzExGG0DuEq4HU0Q4ZoDHDNisy0tR/2jmYV58UKjDfpc43ZAvOcJ9SotNJzka0MhhsMLmVbBQTe3j4C0ErvOdiaJuvVj41TfYxUeYD7K+7V1tmF1yn9IMnnNnqa7xvTNWPjWXAGwi6plOXSmbxtXA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(136003)(396003)(346002)(39860400002)(230922051799003)(82310400011)(64100799003)(186009)(451199024)(1800799012)(40470700004)(36840700001)(46966006)(2616005)(41300700001)(356005)(26005)(82740400003)(81166007)(336012)(478600001)(4326008)(6916009)(5660300002)(8676002)(8936002)(1076003)(70586007)(426003)(83380400001)(7696005)(2906002)(316002)(54906003)(36756003)(70206006)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2024 10:41:16.9313 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe7b4919-e121-48b5-4e62-08dc2d49795b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5646 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790871584350721728 X-GMAIL-MSGID: 1790871584350721728 Consider the below scenario, When ACP and SoundWire managers are in D3 state and SoundWire manager power off mode is selected and acp and SoundWire manager instances are in runtime suspended state. In this case, for the ACP PME wake event, the ACP PCI driver should resume SoundWire manager devices based on wake enable status set. Add code for handling ACP PME wake event for runtime suspend scenario when SoundWire power off mode is selected. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/pci-ps.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c index c141397a2cac..c42660245019 100644 --- a/sound/soc/amd/ps/pci-ps.c +++ b/sound/soc/amd/ps/pci-ps.c @@ -554,6 +554,19 @@ static bool check_acp_sdw_enable_status(struct acp63_dev_data *adata) return (sdw0_en || sdw1_en); } +static void handle_acp63_sdw_pme_event(struct acp63_dev_data *adata) +{ + u32 val; + + val = readl(adata->acp63_base + ACP_SW0_WAKE_EN); + if (val && adata->sdw->pdev[0]) + pm_request_resume(&adata->sdw->pdev[0]->dev); + + val = readl(adata->acp63_base + ACP_SW1_WAKE_EN); + if (val && adata->sdw->pdev[1]) + pm_request_resume(&adata->sdw->pdev[1]->dev); +} + static int __maybe_unused snd_acp63_suspend(struct device *dev) { struct acp63_dev_data *adata; @@ -572,6 +585,26 @@ static int __maybe_unused snd_acp63_suspend(struct device *dev) return ret; } +static int __maybe_unused snd_acp63_runtime_resume(struct device *dev) +{ + struct acp63_dev_data *adata; + int ret; + + adata = dev_get_drvdata(dev); + if (adata->sdw_en_stat) + return 0; + + ret = acp63_init(adata->acp63_base, dev); + if (ret) { + dev_err(dev, "ACP init failed\n"); + return ret; + } + + if (!adata->sdw_en_stat) + handle_acp63_sdw_pme_event(adata); + return 0; +} + static int __maybe_unused snd_acp63_resume(struct device *dev) { struct acp63_dev_data *adata; @@ -589,7 +622,7 @@ static int __maybe_unused snd_acp63_resume(struct device *dev) } static const struct dev_pm_ops acp63_pm_ops = { - SET_RUNTIME_PM_OPS(snd_acp63_suspend, snd_acp63_resume, NULL) + SET_RUNTIME_PM_OPS(snd_acp63_suspend, snd_acp63_runtime_resume, NULL) SET_SYSTEM_SLEEP_PM_OPS(snd_acp63_suspend, snd_acp63_resume) }; From patchwork Wed Feb 14 10:40:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 200903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1127528dyb; Wed, 14 Feb 2024 02:57:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUDUSJzjrQxCuPTqQhXc8U5fM/TkX7r/RPwHBrNTBBYuCqW8MPaJ29n3przm55618kCr/ax0miLihr2jhVmDluNhWBdrQ== X-Google-Smtp-Source: AGHT+IHumLVuRXuM4TVTV5uVZwxeTz4NvUOyjfNYZhqoLtKr1a99mWEntvNFklFtWDe+oA9IYcmj X-Received: by 2002:a05:6358:5396:b0:176:9bfd:d08d with SMTP id z22-20020a056358539600b001769bfdd08dmr2205460rwe.11.1707908249093; Wed, 14 Feb 2024 02:57:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV5Swtn7Kdn6UPX1ulg+g0KFxAGIRVdUwW7L9tt5T2qzeLd0n+Srrdll6oC/utrn74pwzRyzjgdPBzsnV0DrlH7mS+/8g== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id eb3-20020a056a004c8300b006e0338e3d3bsi8333564pfb.196.2024.02.14.02.57.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 02:57:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Cc+kckfn; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-65066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65066-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 917A3B23BE9 for ; Wed, 14 Feb 2024 10:42:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD5BA18E2E; Wed, 14 Feb 2024 10:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Cc+kckfn" Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2050.outbound.protection.outlook.com [40.107.243.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 499CC199B9; Wed, 14 Feb 2024 10:41:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907295; cv=fail; b=mF0IKgVMCQdbiocuBKkdR2WlbRmp5rtDlwMSZ0IcA0jQjhk7j7WDIwXpAxREGHdl3xnwet2ZtGjs4Cpjd3wYmkowu5vyWPO/kyarWiLYcd+R33aTtpUpHY0gxwlDe+XijkTRBgOnxAkrI01TreJev7x0H2P5k34jzJGeE9xRcug= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907295; c=relaxed/simple; bh=80XaQIdJt5Hn2ceeiCmLP8bhIedeJGu/EXa0a2Z38eA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ke7HvdhzVB+hyIq0DqrnUU5aHUpT4BS5L7nyR65Qmnxm2oEzekuq9myn6yfUuOlLCFVkOpr+e41lnd1LKsfSKa1gF4aBX3H8kCfuUoTkf5KpnL1gr+X/IM7wGqZudvXlCABSfcz9oRq/wKJ9Tou37FoZ28VI2gS+GAkMNcWEpdE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Cc+kckfn; arc=fail smtp.client-ip=40.107.243.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cwllMQjk1MXRYt+CD+jDxFQGs+Sj+pTIgaXV225NvReJCgzsgHHdrmuB0WecIhg5b4kGIQAvplcNzyo5mKIOxHp/Cv/kRg2pS4DdnlnE5Ubpu/U6EZ2u5PuhaVD3YQo8YQxwlY9bdpYMQ8zRmfW2xFGy78WYlEBeQ72BeJ5WEMee+LeOtCVa16Dls+RvvoaOQBLc1V34PfB78ERpY41/N1p0zITzBLBN3OTInvD8BhA9vqjpn1qK5DhkgvTu5SpPUrueoGBCU/IFTNGu0HdAacyZ4AqqTOHMtJFXEB1D2nOzTNz5Is8xW7RT0NSwNt3Yy1dq156jlhear7+9MiuGUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xgimMXS9vuppJuC7eO5AdWn9o5Lmar7dDoeXfFI30KM=; b=L8cgDdqjJ7BzSzomwcaAQAHbAwBw2sEv3atPORWvKzuJXYRS1vKdlEpbOryhA/YwOL8iIuCZmetJOOLErd2/1yFOOYXL+GUqGq76iJOypJ80dtwTtsB8SqLG6CQFAa4xFd27+V/wEG4AS1ThaGDUStZiwi9LT83l79qYOnPLkdsNaoXlY4MfQsLhP6umr6cp5OwetTnvUvArk+TqUiorecYWQIaETMbW8b4gDqI4KroWvfSB9FoBeCqyPSGj4l3dkcFDAQC0c1bbFQ3kAMptx/EHHQhly6DZz+OUw1YGVlov2XBOyt2A2YYVDmXQYGGa5+sG89NRvUbbLalGrw6o4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xgimMXS9vuppJuC7eO5AdWn9o5Lmar7dDoeXfFI30KM=; b=Cc+kckfnf2iBc+d2viQ8QUC3T1Di+b5DlpYn02Zq0bj/w+HYDllcf5SgwB51Ff4DigdhNaZ8kgxIYiQltdiYtmyubXIzlzppsK4bMmT6oJXMb1w+wP3+oBTdLN2JWLnz5bBvYnjVEWpTznZmEteTazhko1ac+Wk+8KN61Dl2H9I= Received: from CYZPR20CA0004.namprd20.prod.outlook.com (2603:10b6:930:a2::29) by CH2PR12MB4940.namprd12.prod.outlook.com (2603:10b6:610:65::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.29; Wed, 14 Feb 2024 10:41:28 +0000 Received: from CY4PEPF0000EE3F.namprd03.prod.outlook.com (2603:10b6:930:a2:cafe::f1) by CYZPR20CA0004.outlook.office365.com (2603:10b6:930:a2::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.40 via Frontend Transport; Wed, 14 Feb 2024 10:41:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE3F.mail.protection.outlook.com (10.167.242.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Wed, 14 Feb 2024 10:41:27 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 14 Feb 2024 04:41:26 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Wed, 14 Feb 2024 04:41:17 -0600 From: Vijendar Mukunda To: CC: , , , , , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Syed Saba Kareem , Carlos Bilbao , Mario Limonciello , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [PATCH 5/5] ASoC: amd: ps: add machine select and register code Date: Wed, 14 Feb 2024 16:10:05 +0530 Message-ID: <20240214104014.1144668-5-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214104014.1144668-1-Vijendar.Mukunda@amd.com> References: <20240214104014.1144668-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3F:EE_|CH2PR12MB4940:EE_ X-MS-Office365-Filtering-Correlation-Id: 10e69bf7-93c4-48d7-5e32-08dc2d497fe1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xXKOLrDN5lBx8cB7Var5zoYFPKDeRCCVMFi77Bi2ZA1ViJ6QGe3vAi0ut15iqOr8EaoCpg/a6cTZk2imbw82e7UEBI+9kUD5SQZdbub8DCcxTijFCVT+QesxXEPiXRLzJEoM3KirVxRkGYBMbXI+BUSyZwVkIqXThie5UpJFw6DRemLYRws/jni6RXMbgx1cfwdkM03Xi7Ex3nV8sXmKGQO+Z0o3CJINpi1T3+pKcHkv9QHI8YJrpaGKpchvV+tV9cy2pKjLJHdgKF+Jtxt6zPWepjUy7p1zjCHrqegc90mR3m9T/ebLWlLPvm4v6z3IAi1pEi50wa9tOMWLaPPsKmHp75GnWt+0l0eTuNRuGvQ3uhQBgMysYchi2aeNHhV+GIYQfsmobCDl5AlxP3tPzOFw5v7HI7pfPuWycPmXWrgzkascnObFxUaFAP5GU5kR431DQYu3eBmskEwasbRy5UG50V5JrYyDy5+42+ImKdAN0pKjFOlf9TF7w/NaRyLd26K/uMYVxenqL60DgMkiMfdFdflmHAKeYlxNLxTxXjdTxliKe9bl0Rgr2chRFFH1uewIAeur50QZPY7wteNsKI8N+sUQpBxu7U88uvLZJuQ= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(376002)(39860400002)(396003)(136003)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(82310400011)(36840700001)(46966006)(40470700004)(5660300002)(8936002)(8676002)(4326008)(6916009)(70206006)(70586007)(2906002)(83380400001)(26005)(1076003)(336012)(426003)(82740400003)(81166007)(356005)(36756003)(86362001)(54906003)(6666004)(316002)(2616005)(41300700001)(7696005)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2024 10:41:27.8137 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10e69bf7-93c4-48d7-5e32-08dc2d497fe1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE3F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4940 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790871599889044404 X-GMAIL-MSGID: 1790871599889044404 Add machine select logic for SoundWire interface and create a machine device node based on ACP PDM/SoundWire configuration. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/acp63.h | 4 ++ sound/soc/amd/ps/pci-ps.c | 81 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index fb4261f7fa4b..65433184d03e 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -219,9 +219,11 @@ struct sdw_dma_ring_buf_reg { * @pdm_dev: ACP PDM controller platform device * @dmic_codec: platform device for DMIC Codec * sdw_dma_dev: platform device for SoundWire DMA controller + * @mach_dev: platform device for machine driver to support ACP PDM/SoundWire configuration * @acp_lock: used to protect acp common registers * @info: SoundWire AMD information found in ACPI tables * @sdw: SoundWire context for all SoundWire manager instances + * @machine: ACPI machines for SoundWire interface * @is_sdw_dev: flag set to true when any SoundWire manager instances are available * @is_pdm_dev: flag set to true when ACP PDM controller exists * @is_pdm_config: flat set to true when PDM configuration is selected from BIOS @@ -239,10 +241,12 @@ struct acp63_dev_data { struct platform_device *pdm_dev; struct platform_device *dmic_codec_dev; struct platform_device *sdw_dma_dev; + struct platform_device *mach_dev; struct mutex acp_lock; /* protect shared registers */ struct sdw_amd_acpi_info info; /* sdw context allocated by SoundWire driver */ struct sdw_amd_ctx *sdw; + struct snd_soc_acpi_mach *machines; bool is_sdw_dev; bool is_pdm_dev; bool is_pdm_config; diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c index c42660245019..205bca95aa06 100644 --- a/sound/soc/amd/ps/pci-ps.c +++ b/sound/soc/amd/ps/pci-ps.c @@ -17,6 +17,7 @@ #include #include #include +#include "../mach-config.h" #include "acp63.h" @@ -281,6 +282,42 @@ static int amd_sdw_exit(struct acp63_dev_data *acp_data) return 0; } + +static struct snd_soc_acpi_mach *acp63_sdw_machine_select(struct device *dev) +{ + struct snd_soc_acpi_mach *mach; + const struct snd_soc_acpi_link_adr *link; + struct acp63_dev_data *acp_data = dev_get_drvdata(dev); + int ret, i; + + if (acp_data->info.count) { + ret = sdw_amd_get_slave_info(acp_data->sdw); + if (ret) { + dev_dbg(dev, "failed to read slave information\n"); + return NULL; + } + for (mach = acp_data->machines; mach; mach++) { + if (!mach->links) + break; + link = mach->links; + for (i = 0; i < acp_data->info.count && link->num_adr; link++, i++) { + if (!snd_soc_acpi_sdw_link_slaves_found(dev, link, + acp_data->sdw->ids, + acp_data->sdw->num_slaves)) + break; + } + if (i == acp_data->info.count || !link->num_adr) + break; + } + if (mach && mach->link_mask) { + mach->mach_params.links = mach->links; + mach->mach_params.link_mask = mach->link_mask; + return mach; + } + } + dev_dbg(dev, "No SoundWire machine driver found\n"); + return NULL; +} #else static int acp_scan_sdw_devices(struct device *dev, u64 addr) { @@ -296,8 +333,44 @@ static int amd_sdw_exit(struct acp63_dev_data *acp_data) { return 0; } + +static struct snd_soc_acpi_mach *acp63_sdw_machine_select(struct device *dev) +{ + return NULL; +} #endif +static int acp63_machine_register(struct device *dev) +{ + struct snd_soc_acpi_mach *mach; + struct acp63_dev_data *adata = dev_get_drvdata(dev); + int size; + + if (adata->is_sdw_dev && adata->is_sdw_config) { + size = sizeof(*adata->machines); + mach = acp63_sdw_machine_select(dev); + if (mach) { + adata->mach_dev = platform_device_register_data(dev, mach->drv_name, + PLATFORM_DEVID_NONE, mach, + size); + if (IS_ERR(adata->mach_dev)) { + dev_err(dev, + "cannot register Machine device for SoundWire Interface\n"); + return PTR_ERR(adata->mach_dev); + } + } + + } else if (adata->is_pdm_dev && !adata->is_sdw_dev && adata->is_pdm_config) { + adata->mach_dev = platform_device_register_data(dev, "acp_ps_mach", + PLATFORM_DEVID_NONE, NULL, 0); + if (IS_ERR(adata->mach_dev)) { + dev_err(dev, "cannot register amd_ps_mach device\n"); + return PTR_ERR(adata->mach_dev); + } + } + return 0; +} + static int get_acp63_device_config(struct pci_dev *pci, struct acp63_dev_data *acp_data) { struct acpi_device *pdm_dev; @@ -526,7 +599,11 @@ static int snd_acp63_probe(struct pci_dev *pci, dev_err(&pci->dev, "ACP platform devices creation failed\n"); goto de_init; } - + ret = acp63_machine_register(&pci->dev); + if (ret) { + dev_err(&pci->dev, "ACP machine register failed\n"); + goto de_init; + } skip_pdev_creation: device_set_wakeup_enable(&pci->dev, true); pm_runtime_set_autosuspend_delay(&pci->dev, ACP_SUSPEND_DELAY_MS); @@ -640,6 +717,8 @@ static void snd_acp63_remove(struct pci_dev *pci) platform_device_unregister(adata->pdm_dev); platform_device_unregister(adata->dmic_codec_dev); } + if (adata->mach_dev) + platform_device_unregister(adata->mach_dev); ret = acp63_deinit(adata->acp63_base, &pci->dev); if (ret) dev_err(&pci->dev, "ACP de-init failed\n");