From patchwork Mon Jan 20 10:01:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 13944969 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 E508E1DFD9D; Mon, 20 Jan 2025 10:02:34 +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=1737367357; cv=fail; b=jXrT+A0xoZOO5nVPex6o9z+ynRewdSpZZKLu5bvOv6iLuF59hE4EK5YgI0oneutnTMJsTDtykQvZH8Fs4gv+o04fPsxsxaATpGa4VQ6yacLKS+X4a7tChDOdaB6MRF9QV+lGEqGrAGoNekyBqhn7k9OoPj0I5O3QsUwLbxy24U4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737367357; c=relaxed/simple; bh=WwekW25sM31HWqRtWcjTLS6n/Ap8nkhiErzQ/Hlq37Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=beetZGiZK1zdYDdp841wdrwpCqxpicwyHaeUdOCEfobgQbM/cvMd1taJSrREOmWovwZzc7HEqVQjUk3SVfm/bslGweG9WyW6uzY7qu3J+LJottGI80Ng+vaFtngWJRoMwe00XAM1ljfLzXLTf5lxPzXqUOVfWMuJM2i+hkpDjlg= 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=Xd3WpdqO; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Xd3WpdqO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZDbsGSNxVtHFMFhmpxxQRkMRZ6/x7GYFZ8fZ6s2BZxJHBOM5KZw+xfECEMYng1DnGcqv/DQ0LKIsK69WLsPMtaxOb7tQImgyLwiJ1Zxh1qkps7ThQ9mwqMnIp09CE2pSXbFYeGF3CXWplX4ejWWNkcrm2nN9YYMRRQ6V88sP0H9nX8reAMPXu64RP0t+mkDixmcaaP/tsOOh2Pb07xrPv+euKgrIQXe7fqeJVkl2nOT1oH4q9CeVbPWvCr1kVGdm2+AMetm0OYNGIK7qB4toiEgCAVVqgPHn9Oxt4348QnpG2rmLT1tvhBRXBIEqAw2JAt1wz9Gw1Kf/sdOYZixCHQ== 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=P7k1/Y/vBih/cGNZP6lIN9FOgLPRT2plk9gHtZptIgW3ww4zxgEzMlNN89DOXtC4h+lLrkJ+AyOw1UI5g16OUm3N5nlELsqPHaDYI/DiB298Tw9C13NS4YKGZaptO9exv1AvqAy04KoO2ymPn685/GgoEkUqfO/DSTN2eD15bLwIzsyrNJUrV+dE789rWo39ZdQ1RWf1BU7DFyrUNKxHHsXTkLX9yfN7CY0P4qSeX2MFQQha+UV5tfir/ZuQDZ18re+y0PQ3dkvEvPX4HLOUmZs3DROz8h5KeXzJRDQ1xpLwHWD3ANVVF6UazvfnGuh4WpTZYDT6BcnpO2mekvLEPw== 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=Xd3WpdqOfkygrDDZF4bpaa+e665UXdoH0GSlTvoaVNNSL1SRw5Snmt6pJ7+svAgmW+0niZjnRZKcz+io/ekwdW3JfU+DDpB9j5q0XzC7vaiMMLvo34nlLdEpcIJZQJUS7WLK3q7SxIHwcFxCx3DvoLkM4DHhWObwgDOJDyIfmI8= Received: from CH0PR03CA0246.namprd03.prod.outlook.com (2603:10b6:610:e5::11) by PH7PR12MB7377.namprd12.prod.outlook.com (2603:10b6:510:20c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.20; Mon, 20 Jan 2025 10:02:31 +0000 Received: from CH1PEPF0000AD82.namprd04.prod.outlook.com (2603:10b6:610:e5:cafe::20) by CH0PR03CA0246.outlook.office365.com (2603:10b6:610:e5::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.22 via Frontend Transport; Mon, 20 Jan 2025 10:02:30 +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 CH1PEPF0000AD82.mail.protection.outlook.com (10.167.244.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Mon, 20 Jan 2025 10:02:30 +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; Mon, 20 Jan 2025 04:02:27 -0600 From: Vijendar Mukunda To: CC: , , , , , , , , , , Vijendar Mukunda Subject: [PATCH V2 13/23] ASoC: amd: acp70: add acp pdm driver pm ops Date: Mon, 20 Jan 2025 15:31:20 +0530 Message-ID: <20250120100130.3710412-14-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250120100130.3710412-1-Vijendar.Mukunda@amd.com> References: <20250120100130.3710412-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: CH1PEPF0000AD82:EE_|PH7PR12MB7377:EE_ X-MS-Office365-Filtering-Correlation-Id: 04081284-cfdc-4240-99c6-08dd39398dab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: P0UcPCkZV3F0tWTeBidSuZmrRFxhy0+j5Wz8sQ1m2SH7S43Ul7FxRu4s4n0n8yWpt/3aaQC6k3rmopNAkCXaQN68hwtV6Th4+l3+SxV+DMvnnzwUgM8FeB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+REdSn6yQ+UIy1+0/uJ9Lypfzt0yhsggY4A3HKPCYR3XvR1WGxn7QrfetB35xeY0GiXOK9t5Ce9gNw636AAhQAM604umJk5DeZdDwrvWs9X85BmA3i7apRjlAojhdPkm+28ZCpvcghKrCNZbozqbpPmlrIz0Nuq3SOh1yFrRAcl0bjgkDqDKqkWN65VjAv+k9ec0b1/a/mKnUGiPlXhsrAkyNOA2pP1WZsS1fK1l9kXEa3JBKeW4mZgt7JQWfcdZTeiTPz5oEukpTG+gINIdZE3jUGxpGmbzj/eOvMeFnMWvVKZe+mIWj/NMSE= 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)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2025 10:02:30.8449 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04081284-cfdc-4240-99c6-08dd39398dab 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: CH1PEPF0000AD82.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7377 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,