From patchwork Thu Dec 19 05:48:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13914498 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2049.outbound.protection.outlook.com [40.107.220.49]) (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 650CE218589; Thu, 19 Dec 2024 05:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734587506; cv=fail; b=apGEzfkOjVztuX+oWZm2cmvri6KmGtv4SCiCshFe9NfzZKGyhrjMh47MB0sMynfmYsHjJqxlEN5IZ0SfIwx75BSavPJKh1yr1doDIRD1ujEgsy/UA+JwcKcs8TdQsxI81q6k4CcytdYccXFVj4Oo/CpxzKMhKf0I3nzVvXqq4z8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734587506; c=relaxed/simple; bh=AB6y6aUGKAIcu/7XQQX9E2MkkO8GRA/yMdNiZrdQ8M0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sCzS4i/r0IeQmEl0gvVJ5Tepgz9wALulop1+ABT35I7ZYoB1CrAsrfzDHjirlgDlU02iRQ7JMnEgB2RN/bRaFes5+S+tuzPPWmkBFx5Syi+YFXDERnCQDv0piFo/FJBXjBYbQPgApEAvNxGqxXsj58SOSbrxOPVHdeKk+x+kj28= 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=OaDVN5CG; arc=fail smtp.client-ip=40.107.220.49 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="OaDVN5CG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mMYVPucyyE/LOECddeDgqUIDAjEbal0kFl1fq/fvCqHH400Y0HAEYOJ+7CCzo/Uq7uNP9DFspx+03TPDTkrSWn+imwsL2N4eHpacGEySSrOtW/jDB7lzJ+gbX51LeNyfUVLBQ1t+4Y5HAj0xu4JaZOl/OOykXBWVItxI3we499dNgW+Ieihf92hBoaK3vcEBXhXri1PH24uKM4hfH/NWZrC3/Rg25HmC79PjefuO8v3Ugo6TPsLtFlC2vnTxNJ6ZeMVXkJS2ESIDJ9zVw0T27wHVFIrzbUPOP532v+Pe/krTiXburHl0CIvEvJ8/CY9wzkeNaVSwTtrAs4iU+Ywm0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=hV+Tox7gKmYWATNT5Lh70sD5S3ZwApVIAEgawlfLhPY=; b=enVTINtNsG3XeHwk8py6Q9OAGBfZgBK7wLoacU3nSs7FIKfy722G/9CmKFVdGeE2vfO+QVUASaFefxiQ28uW4Zft8OSlTpJYVkWsUg+qYIFdvgEKxc+AfrzMdwDOXaWBBbDpxSv0QWFlVB2q8SPOva0w2l3uUhrBooSM7LkI8rLMGZfvyNLnxAYaoh17WlF99rEPH0Rnu2g78H2XMxBL8ZwzICFWl5TRpYWkgDd9/rtxeMqlhsL06f76ZUP75cAHiIcUkT/qAIc6sJsjq1toPFRxWm+7/A7k41iwD/kV2wjzoVbNz+Ux2iKqhkhoAw4pr30XBgleh1OP6ZunHnpegw== 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=hV+Tox7gKmYWATNT5Lh70sD5S3ZwApVIAEgawlfLhPY=; b=OaDVN5CGOWdrs3S09oNDdkcP5xNMNDOgRCzNVZMR3Y1uXQCGRucCLDOsvNEFPc1UHd2Z+xYze4aoksLxNgCjFvUjxZl8oya4ELEa3TXf1cEZTDbJtQ3rzQmSOcNU2KH9VZFRoVUv7pZAUOBcaAtB582dkxSYgKJ82yTexX5OmVw= Received: from CH2PR18CA0056.namprd18.prod.outlook.com (2603:10b6:610:55::36) by MW4PR12MB6778.namprd12.prod.outlook.com (2603:10b6:303:1e8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Thu, 19 Dec 2024 05:51:40 +0000 Received: from CH1PEPF0000AD81.namprd04.prod.outlook.com (2603:10b6:610:55:cafe::47) by CH2PR18CA0056.outlook.office365.com (2603:10b6:610:55::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.24 via Frontend Transport; Thu, 19 Dec 2024 05:51:39 +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 CH1PEPF0000AD81.mail.protection.outlook.com (10.167.244.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8251.15 via Frontend Transport; Thu, 19 Dec 2024 05:51:39 +0000 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) 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.39; Wed, 18 Dec 2024 23:51:36 -0600 From: Vijendar Mukunda To: CC: , , , , , , , , , , Vijendar Mukunda Subject: [PATCH 15/21] ASoC: amd: acp70: add acp driver pm ops support Date: Thu, 19 Dec 2024 11:18:51 +0530 Message-ID: <20241219054857.2070420-16-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241219054857.2070420-1-Vijendar.Mukunda@amd.com> References: <20241219054857.2070420-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD81:EE_|MW4PR12MB6778:EE_ X-MS-Office365-Filtering-Correlation-Id: 25f1d138-9ae0-4dba-6719-08dd1ff13563 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: lpzUXEugqxl1p8WS8kC2/2N1MhOUr5qKVBbAA3wSQcmuBG2QwNeFXs5tCE/5oGhFSG+RNuvKEusSyUIi973RyQ5DWwCHTIM4du5/MCskfZiBpyEBR+lznq2kvhF2hOvje9mfdSP01zzP5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Ff1TL8a+0Pw+pb6M4mZE/qWCs9E0OICiiEiUxEhHCXGT0VcTcbSlUiXiREcQa7BSpaEsZ7Nk0Iehv67hId8SIqYafeLMLAEfswXuwEVGE03gcBqrUEkPetJfQMihJ5zY1SmvrBLLerDu3CoM5ERwp6OPiOsM5m3krJZFNvYOPCoMrWpgOOa6JxaWGPZaaEZGk2OukbjT2lCuRm7IlyWfrcxAHLdRrlem62gEoiAhCR58pG6OO/k5wUcKJ9c9QxIfBxh9gqg4HCh8LoELelWRwaWliVbPyICyFZ9QHiOWKng= 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:(13230040)(82310400026)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 05:51:39.8983 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25f1d138-9ae0-4dba-6719-08dd1ff13563 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: CH1PEPF0000AD81.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6778 Add pm ops support for ACP7.0 PCI driver. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/acp70/acp70.h | 4 ++ sound/soc/amd/acp70/pci-acp70.c | 106 ++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) diff --git a/sound/soc/amd/acp70/acp70.h b/sound/soc/amd/acp70/acp70.h index 1d8e670264fc..1b5661a86352 100644 --- a/sound/soc/amd/acp70/acp70.h +++ b/sound/soc/amd/acp70/acp70.h @@ -60,6 +60,8 @@ #define ACP_SDW0_STAT BIT(21) #define ACP_SDW1_STAT BIT(2) +#define ACP_SDW0_PME_STAT BIT(26) +#define ACP_SDW1_PME_STAT BIT(27) #define ACP_ERROR_IRQ BIT(29) #define ACP_AUDIO0_TX_THRESHOLD 0x1c @@ -247,6 +249,7 @@ struct sdw_dma_dev_data { * @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 */ struct acp70_dev_data { @@ -268,6 +271,7 @@ struct acp70_dev_data { bool is_pdm_dev; bool is_pdm_config; bool is_sdw_config; + bool sdw_en_stat; }; int snd_amd_acp_find_config(struct pci_dev *pci); diff --git a/sound/soc/amd/acp70/pci-acp70.c b/sound/soc/amd/acp70/pci-acp70.c index e732a680c092..3cca18612ef1 100644 --- a/sound/soc/amd/acp70/pci-acp70.c +++ b/sound/soc/amd/acp70/pci-acp70.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "../mach-config.h" #include "acp70.h" @@ -554,6 +555,10 @@ static int snd_acp70_probe(struct pci_dev *pci, goto de_init; } skip_pdev_creation: + pm_runtime_set_autosuspend_delay(&pci->dev, ACP_SUSPEND_DELAY_MS); + pm_runtime_use_autosuspend(&pci->dev); + pm_runtime_put_noidle(&pci->dev); + pm_runtime_allow(&pci->dev); return 0; de_init: if (acp70_deinit(adata->acp70_base, &pci->dev)) @@ -566,6 +571,102 @@ static int snd_acp70_probe(struct pci_dev *pci, return ret; } +static bool check_acp_sdw_enable_status(struct acp70_dev_data *adata) +{ + u32 sdw0_en, sdw1_en; + + sdw0_en = readl(adata->acp70_base + ACP_SW0_EN); + sdw1_en = readl(adata->acp70_base + ACP_SW1_EN); + return (sdw0_en || sdw1_en); +} + +static void handle_acp70_sdw_pme_event(struct device *dev) +{ + struct amd_sdw_manager *amd_manager; + struct acp70_dev_data *adata; + u32 ext_intr_stat1; + + adata = dev_get_drvdata(dev); + ext_intr_stat1 = readl(adata->acp70_base + ACP_EXTERNAL_INTR_STAT1); + dev_dbg(dev, "ext_intr_stat1: 0x%x\n", ext_intr_stat1); + if (ext_intr_stat1 & ACP_SDW0_PME_STAT) { + amd_manager = dev_get_drvdata(&adata->sdw->pdev[0]->dev); + if (amd_manager) + pm_request_resume(amd_manager->dev); + } + + if (ext_intr_stat1 & ACP_SDW1_PME_STAT) { + amd_manager = dev_get_drvdata(&adata->sdw->pdev[1]->dev); + if (amd_manager) + pm_request_resume(amd_manager->dev); + } +} + +static int __maybe_unused snd_acp70_suspend(struct device *dev) +{ + struct acp70_dev_data *adata; + int ret; + + adata = dev_get_drvdata(dev); + writel(0x1, adata->acp70_base + ACP_PME_EN); + if (adata->is_sdw_dev) { + adata->sdw_en_stat = check_acp_sdw_enable_status(adata); + if (adata->sdw_en_stat) + return 0; + } + ret = acp70_deinit(adata->acp70_base, dev); + if (ret) + dev_err(dev, "ACP de-init failed\n"); + + return ret; +} + +static int __maybe_unused snd_acp70_runtime_resume(struct device *dev) +{ + struct acp70_dev_data *adata; + int ret; + + adata = dev_get_drvdata(dev); + writel(0x1, adata->acp70_base + ACP_PME_EN); + + if (adata->sdw_en_stat) + return 0; + + ret = acp70_init(adata->acp70_base, dev); + if (ret) { + dev_err(dev, "ACP init failed\n"); + return ret; + } + + if (!adata->sdw_en_stat) + handle_acp70_sdw_pme_event(dev); + + return 0; +} + +static int __maybe_unused snd_acp70_resume(struct device *dev) +{ + struct acp70_dev_data *adata; + int ret; + + adata = dev_get_drvdata(dev); + writel(0x1, adata->acp70_base + ACP_PME_EN); + + if (adata->sdw_en_stat) + return 0; + + ret = acp70_init(adata->acp70_base, dev); + if (ret) + dev_err(dev, "ACP init failed\n"); + + return ret; +} + +static const struct dev_pm_ops acp70_pm_ops = { + SET_RUNTIME_PM_OPS(snd_acp70_suspend, snd_acp70_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(snd_acp70_suspend, snd_acp70_resume) +}; + static void snd_acp70_remove(struct pci_dev *pci) { struct acp70_dev_data *adata; @@ -583,6 +684,8 @@ static void snd_acp70_remove(struct pci_dev *pci) ret = acp70_deinit(adata->acp70_base, &pci->dev); if (ret) dev_err(&pci->dev, "ACP de-init failed\n"); + pm_runtime_forbid(&pci->dev); + pm_runtime_get_noresume(&pci->dev); pci_release_regions(pci); pci_disable_device(pci); } @@ -600,6 +703,9 @@ static struct pci_driver ps_acp70_driver = { .id_table = snd_acp70_ids, .probe = snd_acp70_probe, .remove = snd_acp70_remove, + .driver = { + .pm = &acp70_pm_ops, + } }; module_pci_driver(ps_acp70_driver);