From patchwork Thu Dec 19 05:48:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13914496 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2041.outbound.protection.outlook.com [40.107.220.41]) (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 4DC08217717; Thu, 19 Dec 2024 05:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734587498; cv=fail; b=m2aZMVVr2qlQeJqeTufXIyY8HydtNTf8WjHBi+0joswzBkiyUT1kAaXOhD+8aK/m+AdlMqjyEytCtYWhof2VPEoRSFTSj/lmAQtGMg+5JVThZmqJhWo7IlFN5rnevQ9ga9FnbK2SEZejX2OiKakf5RzCRiXoKl66oV4V+QQ4qE0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734587498; c=relaxed/simple; bh=WwekW25sM31HWqRtWcjTLS6n/Ap8nkhiErzQ/Hlq37Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=spqgH4fLeja/Ydle9xRAPbmg0wrlumTrd/ec7oiIdnBTb4xP4A4l9+MOSkc7gkZY/SSjPUmY77P1DLOzOaMZm/aGnVtMDvpRvrdK47mfy1n5WPVNG+ukCdVawuRGpdCAycMv1OowdDeDIemQnLPk3LIauLhMDKM5/nH3mFIixYc= 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=XAnPcTh6; arc=fail smtp.client-ip=40.107.220.41 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="XAnPcTh6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EMgD+odk6hMdkwwdvssBuszOL68PVvvZW/n93pz/Clft/GthoD9tBOEzcnpv0NGedEdyfjOexRdBkRZyOJN6CbdTSJtRYbP81XfhVn64eexADvtx5QFNrnTfZrkxP9EH5ElMozuSPyEvP2kEL8J04omdNtJJftBmYcoRZn23UEHRc6m/qHH2Nr7hgtLQsw6Gs9Bp7Ah3wp5p7QSU03hzXkYmTZQZbrvPJqV1svNn+b4qhKRWvg+JVk6z92L3bQVdTisq2faPBoZJt1L3qiwSq0bMTj/d9e0z8kYsH+5MxXcMH701+JsrhK3aB6KfVR0xMklV9laC1HNyNsxO/7ctgQ== 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=kJQi71sXiDZNgwfIvXoSLGbmEiJoWJQjzWCC2CVlwxw=; b=YACvnVnD+oZbvS3Qa2GmU2QDZa3rACKit78pcukZENufZn5/yk4j/uK+0r9GoTDfbGTz6+pVBbHbtACRJCE7SElQwYewhUzmpIA37Sn7VuFLYD1vrUTKDE+osyLDulx5SRU5afjo74rg3hKA9YhpZPPRlq7tkZYRZ8i16uW+eBlbAJg/1c3SzAy3p1yuqqS/wf7o/0mIpMNJALRUFAePr2+rJpEHYRsq9i4VggJ6oJgHurOUbM4sLXRJamKhTBkgMenrMavWwVIvv1SZnxisX5VboCCdvcp77+BYwEYXaUAkSkgAbizbQiErdB3kVJDfnOFe+YCrmqkOjhKWzXMVgg== 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=kJQi71sXiDZNgwfIvXoSLGbmEiJoWJQjzWCC2CVlwxw=; b=XAnPcTh6GNzbZuMKvM+muM6LGGNqjULBi+zg2JcA0sOBsFYdPmgfHuErtYJSoDIt9bSt/rbJJOavI5ALRWvQsUTJL5gJ4J1vex9cK9uw2rsqWAtWxcypGjyZq3rrOy7zP08xgNn2IocqVvVr7Si3pmF1ogyhyDPML8Oo9TNZEVY= Received: from CH2PR15CA0027.namprd15.prod.outlook.com (2603:10b6:610:51::37) by DS0PR12MB6630.namprd12.prod.outlook.com (2603:10b6:8:d2::22) 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:33 +0000 Received: from CH1PEPF0000AD7F.namprd04.prod.outlook.com (2603:10b6:610:51:cafe::e3) by CH2PR15CA0027.outlook.office365.com (2603:10b6:610:51::37) 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:33 +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 CH1PEPF0000AD7F.mail.protection.outlook.com (10.167.244.88) 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:33 +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:29 -0600 From: Vijendar Mukunda To: CC: , , , , , , , , , , Vijendar Mukunda Subject: [PATCH 13/21] ASoC: amd: acp70: add acp pdm driver pm ops Date: Thu, 19 Dec 2024 11:18:49 +0530 Message-ID: <20241219054857.2070420-14-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: CH1PEPF0000AD7F:EE_|DS0PR12MB6630:EE_ X-MS-Office365-Filtering-Correlation-Id: 3fd298ba-ef32-4534-c3c7-08dd1ff13155 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: O7KmXvVEqyR56puyU1BXtCGPGA1i2qZoT9qVn62SXb6MtzGxJPBu2YUtQ09UwBlFzsnw/5muzAVdEz9NPObwm+aToHQSJ6jHg4HzUSPEE+AMDTB722YdRSh7vbhS3EHD4X1GE1bzLjZVOxJpKxw7wz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dd30ofY3nRQdZDBejwcC4QbJrHLmPyZiclhYrufntcRkF3CJ424mRxTEf8lbYLe4SrdZ1n2AGNWvFI/28YAUzJXYmFp5enF5ZTmeyT5RKT/asNZXoNn4BGY45wKDItZmppMnNUpENunpZeOei+swhvlUmjdlNynd4p8P8+8nPYNMfxM5XHV20AqpnL+i/ATGVaEVK0/zXtiSJYlGFc3xe1K9iKYqJVM4jrqiuPEmgTZoC0mY/HbMHQkqyNDu6eSz4YgRwvr3oahG/ytPdWuFfyI2npYg= 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)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 05:51:33.0980 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3fd298ba-ef32-4534-c3c7-08dd1ff13155 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: CH1PEPF0000AD7F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6630 Add acp pdm driver pm ops for ACP7.0 & ACP7.1 platforms. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/acp70/acp70-pdm-dma.c | 57 +++++++++++++++++++++++++++++ sound/soc/amd/acp70/acp70.h | 3 ++ 2 files changed, 60 insertions(+) diff --git a/sound/soc/amd/acp70/acp70-pdm-dma.c b/sound/soc/amd/acp70/acp70-pdm-dma.c index 197214e68489..0d24c9ed917f 100644 --- a/sound/soc/amd/acp70/acp70-pdm-dma.c +++ b/sound/soc/amd/acp70/acp70-pdm-dma.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "acp70.h" @@ -388,13 +389,69 @@ static int acp70_pdm_audio_probe(struct platform_device *pdev) return -ENODEV; } + pm_runtime_set_autosuspend_delay(&pdev->dev, ACP_SUSPEND_DELAY_MS); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_mark_last_busy(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); return 0; } +static void acp70_pdm_audio_remove(struct platform_device *pdev) +{ + pm_runtime_disable(&pdev->dev); +} + +static int __maybe_unused acp70_pdm_resume(struct device *dev) +{ + struct pdm_dev_data *adata; + struct snd_pcm_runtime *runtime; + struct pdm_stream_instance *rtd; + u32 period_bytes, buffer_len; + + adata = dev_get_drvdata(dev); + if (adata->capture_stream && adata->capture_stream->runtime) { + runtime = adata->capture_stream->runtime; + rtd = runtime->private_data; + period_bytes = frames_to_bytes(runtime, runtime->period_size); + buffer_len = frames_to_bytes(runtime, runtime->buffer_size); + acp70_config_dma(rtd, SNDRV_PCM_STREAM_CAPTURE); + acp70_init_pdm_ring_buffer(PDM_MEM_WINDOW_START, buffer_len, + period_bytes, adata->acp70_base); + } + acp70_enable_pdm_interrupts(adata); + return 0; +} + +static int __maybe_unused acp70_pdm_suspend(struct device *dev) +{ + struct pdm_dev_data *adata; + + adata = dev_get_drvdata(dev); + acp70_disable_pdm_interrupts(adata); + return 0; +} + +static int __maybe_unused acp70_pdm_runtime_resume(struct device *dev) +{ + struct pdm_dev_data *adata; + + adata = dev_get_drvdata(dev); + acp70_enable_pdm_interrupts(adata); + return 0; +} + +static const struct dev_pm_ops acp70_pdm_pm_ops = { + SET_RUNTIME_PM_OPS(acp70_pdm_suspend, acp70_pdm_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(acp70_pdm_suspend, acp70_pdm_resume) +}; + static struct platform_driver acp70_pdm_dma_driver = { .probe = acp70_pdm_audio_probe, + .remove = acp70_pdm_audio_remove, .driver = { .name = "acp70_pdm_dma", + .pm = &acp70_pdm_pm_ops, }, }; diff --git a/sound/soc/amd/acp70/acp70.h b/sound/soc/amd/acp70/acp70.h index d5ab606adedc..1d8e670264fc 100644 --- a/sound/soc/amd/acp70/acp70.h +++ b/sound/soc/amd/acp70/acp70.h @@ -133,6 +133,9 @@ #define SDW_MAX_BUFFER (SDW_PLAYBACK_MAX_PERIOD_SIZE * SDW_PLAYBACK_MAX_NUM_PERIODS) #define SDW_MIN_BUFFER SDW_MAX_BUFFER +/* time in ms for runtime suspend delay */ +#define ACP_SUSPEND_DELAY_MS 2000 + enum acp_config { ACP_CONFIG_0 = 0, ACP_CONFIG_1,