From patchwork Mon Jan 20 10:13:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 13944991 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2076.outbound.protection.outlook.com [40.107.92.76]) (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 A9EFF1DF268; Mon, 20 Jan 2025 10:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737368053; cv=fail; b=PjJzQHwqzzf0J5GltKHKUxKAKLpaKmEBHKxjxXyM5/lt9UlChgqcYY/jxjAGilmV90W93qjGLFX+5si9Jx4PfXTgzy/+hJLBFF6SARi8izuaril5N7+jsv2c5HQj6OlPqxnUnz1BM71q8ZB6cxaGqc2XVaHdkGrVsPzURo7vDRg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737368053; c=relaxed/simple; bh=2mxFfcIffpKTSyLdlghabe4haSladRl1CKXokc98jM4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QQWsNd5OiBGmlJQMw/bDWFjbxcYE7ssb5S8Zmi6RJDe1KhWjCabzuIhmeyeYApQLdsZZsW4n9+goJD1YkddWc4CrhJFkmq+YhlUaI5nhm+FsYQySKZFh/IsLOFfapB6eIr5Zbp5Lgy5Cgk4KeLd61A1EZLqKx4ca+jQXhg3lr6w= 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=AAghmSWe; arc=fail smtp.client-ip=40.107.92.76 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="AAghmSWe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yxFY/txHTOkBfgaypi6RpT9a/P8bNDpmfB8yiTIrphsr5yB7bXITy2YIMxxr0TA4kSfK8Sb4FXTRvoT8CenmalNVgG05JYpHQxxF6MY3vWDjGKMjy0jfaCFPpdQ+C0L68VeU+7tFi6gVxKjNuMbJp+nhyJrt8vSHsvLgSn5VQDbb9NAQCrmjlRv42luLIqH3jst2yzZyeU70GQGd/WMSSEVHEAoZjQ7Sg5wApBr6tl/6+8l92+/IvW72rOQvH3I4cx7wtj1R91AGqswCgWlShxmNeN9MGK8J//KK6rTZzd1yV9EtVpe7ahG6c6ePQVYZVPxoYXp3KR6Zu+EmL+TahA== 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=jbFLIc86qhZtS6AqFt18YG5NxzDnVKEfEU/tjDTJ7Aw=; b=lxz68Z+TYF5lTe9yF/lovYunRdzrIxAt1S1PAywuNlGb1xqAt5nbkmG2qzn1R+eOQquDQEXkGqOONaaK1Qfqioslq/OTljfWo3HfDM52II67ryLRL4RD9b5d/DpcMY4gnxFnowWaSCVT1hrbdRWYg81bWla80YWv09lGZOeagZYN94pyNl/+9WOOJKD4KjlHJ8BSJ6D1VQwIX5SNQ7LE0aG8OuhbCjSSHu1MAd+epUfvzRc56Y6XY/kdkJwiCK4oKXF+VmuxrY3iVgc2/d6blB1cyRta9ynKDTI6nJdcJjX7zYhv71cEa7M1Sr1EOTTgc6Mj3NywCx8naqIuUu03Fg== 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=jbFLIc86qhZtS6AqFt18YG5NxzDnVKEfEU/tjDTJ7Aw=; b=AAghmSWeunZ19E7tM7JyJvtxzosXZa7XXCAyo9Zzn1IftKXZkuTt9NDqjT0kZi44yyip/B7OY40C53j+DMBoRAR47MerVW4aEhYL9rwX5FspES1/0xVxQWT/hoE5wpUl9YYsyClDfTF0CSl68X8er9B2LnOVON/CrTnzt1IdQ+k= Received: from MN2PR16CA0006.namprd16.prod.outlook.com (2603:10b6:208:134::19) by SA3PR12MB7879.namprd12.prod.outlook.com (2603:10b6:806:306::5) 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:14:08 +0000 Received: from BN3PEPF0000B373.namprd21.prod.outlook.com (2603:10b6:208:134:cafe::50) by MN2PR16CA0006.outlook.office365.com (2603:10b6:208:134::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8356.16 via Frontend Transport; Mon, 20 Jan 2025 10:14:07 +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 BN3PEPF0000B373.mail.protection.outlook.com (10.167.243.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8398.0 via Frontend Transport; Mon, 20 Jan 2025 10:14:07 +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:14:04 -0600 From: Vijendar Mukunda To: CC: , , , , , , , , , , "Vijendar Mukunda" Subject: [PATCH V2 7/7] soundwire: amd: add soundwire host wake interrupt enable/disable sequence Date: Mon, 20 Jan 2025 15:43:29 +0530 Message-ID: <20250120101329.3713017-8-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250120101329.3713017-1-Vijendar.Mukunda@amd.com> References: <20250120101329.3713017-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B373:EE_|SA3PR12MB7879:EE_ X-MS-Office365-Filtering-Correlation-Id: c6eb9e7a-6849-478e-d23d-08dd393b2d01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: Hw3j0RtrPdGR55k3tGdkHAHv2TLk7cCeefRRpSj0VC12JTLyKc5ZVVlOkPM5gUT5rove8K2BTTrr8L+v1rwXRsV+NaKgr4ksCBL53ohxHaKbij1hCFUIt/u5GonsqNXq04qz1ygT7Gv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ArXr7Ey7PAI5H/EgzTQIewiQ56DNBVylGjzCPM30LLgQDBdH1FqS1SJ/2pcZyokEUSJ1ZIpiin8ygXk0GvfGJ+k5bwxpjIBqxhm5Gf6k3SFscniz+GajeurMiW9V94K7/gZdkL8JqAXpq9eBAlAT/AIPR89mGg5U2L4RK6+ZWtiEJM0EnlpV3spQjKN6Q/2FdkY3ZczEqLEZySxq+GKXGxGhrlQYsNXj5ennrLumWdlIJzkZEtg03qcp/IDbKvsafLGk+7AxChUbXD4J9KQOG3niMPSn4ditAF4iJBVy/c4c= 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)(36860700013)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2025 10:14:07.6801 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6eb9e7a-6849-478e-d23d-08dd393b2d01 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: BN3PEPF0000B373.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7879 For wake event, SoundWire host wake interrupt will be asserted based on below pre-conditions for ACP7.0 & ACP7.1 platforms. - ACP device should be in D0 state. - SoundWire manager instance should be in D3 state. - SoundWire manager device state should be set to D3. - ACP_PME_EN should be set to 1. Implement code changes to enable/disable SoundWire host wake interrupt mask during suspend and resume as per design flow for ACP7.0 & ACP7.1 platforms. Signed-off-by: Vijendar Mukunda --- drivers/soundwire/amd_manager.c | 58 +++++++++++++++++++++++++++++++++ drivers/soundwire/amd_manager.h | 2 ++ 2 files changed, 60 insertions(+) diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c index 03c9e15dce5b..161d963c80e6 100644 --- a/drivers/soundwire/amd_manager.c +++ b/drivers/soundwire/amd_manager.c @@ -166,6 +166,34 @@ static int amd_sdw_set_device_state(struct amd_sdw_manager *amd_manager, u32 tar return 0; } +static int amd_sdw_host_wake_enable(struct amd_sdw_manager *amd_manager, bool enable) +{ + u32 intr_cntl1; + u32 sdw_host_wake_irq_mask; + + if (!amd_manager->wake_en_mask) + return 0; + + switch (amd_manager->instance) { + case ACP_SDW0: + sdw_host_wake_irq_mask = AMD_SDW0_HOST_WAKE_INTR_MASK; + break; + case ACP_SDW1: + sdw_host_wake_irq_mask = AMD_SDW1_HOST_WAKE_INTR_MASK; + break; + default: + return -EINVAL; + } + + intr_cntl1 = readl(amd_manager->acp_mmio + ACP_EXTERNAL_INTR_CNTL(ACP_SDW1)); + if (enable) + intr_cntl1 |= sdw_host_wake_irq_mask; + else + intr_cntl1 &= ~sdw_host_wake_irq_mask; + writel(intr_cntl1, amd_manager->acp_mmio + ACP_EXTERNAL_INTR_CNTL(ACP_SDW1)); + return 0; +} + static void amd_sdw_ctl_word_prep(u32 *lower_word, u32 *upper_word, struct sdw_msg *msg, int cmd_offset) { @@ -1186,11 +1214,21 @@ static int __maybe_unused amd_suspend(struct device *dev) if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { amd_sdw_wake_enable(amd_manager, false); + if (amd_manager->acp_rev >= ACP70_PCI_REV_ID) { + ret = amd_sdw_host_wake_enable(amd_manager, false); + if (ret) + return ret; + } ret = amd_sdw_clock_stop(amd_manager); if (ret) return ret; } else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { amd_sdw_wake_enable(amd_manager, false); + if (amd_manager->acp_rev >= ACP70_PCI_REV_ID) { + ret = amd_sdw_host_wake_enable(amd_manager, false); + if (ret) + return ret; + } /* * As per hardware programming sequence on AMD platforms, * clock stop should be invoked first before powering-off @@ -1224,11 +1262,21 @@ static int __maybe_unused amd_suspend_runtime(struct device *dev) } if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { amd_sdw_wake_enable(amd_manager, true); + if (amd_manager->acp_rev >= ACP70_PCI_REV_ID) { + ret = amd_sdw_host_wake_enable(amd_manager, true); + if (ret) + return ret; + } ret = amd_sdw_clock_stop(amd_manager); if (ret) return ret; } else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { amd_sdw_wake_enable(amd_manager, true); + if (amd_manager->acp_rev >= ACP70_PCI_REV_ID) { + ret = amd_sdw_host_wake_enable(amd_manager, true); + if (ret) + return ret; + } ret = amd_sdw_clock_stop(amd_manager); if (ret) return ret; @@ -1269,8 +1317,18 @@ static int __maybe_unused amd_resume_runtime(struct device *dev) ret = amd_sdw_clock_stop_exit(amd_manager); if (ret) return ret; + if (amd_manager->acp_rev >= ACP70_PCI_REV_ID) { + ret = amd_sdw_host_wake_enable(amd_manager, false); + if (ret) + return ret; + } } else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { writel(0x00, amd_manager->acp_mmio + ACP_SW_WAKE_EN(amd_manager->instance)); + if (amd_manager->acp_rev >= ACP70_PCI_REV_ID) { + ret = amd_sdw_host_wake_enable(amd_manager, false); + if (ret) + return ret; + } val = readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); if (val) { val |= AMD_SDW_CLK_RESUME_REQ; diff --git a/drivers/soundwire/amd_manager.h b/drivers/soundwire/amd_manager.h index 1d5e94371f81..6cc916b0c820 100644 --- a/drivers/soundwire/amd_manager.h +++ b/drivers/soundwire/amd_manager.h @@ -194,6 +194,8 @@ #define AMD_SDW_CLK_RESUME_DONE 3 #define AMD_SDW_WAKE_STAT_MASK BIT(16) #define AMD_SDW_WAKE_INTR_MASK BIT(16) +#define AMD_SDW0_HOST_WAKE_INTR_MASK BIT(22) +#define AMD_SDW1_HOST_WAKE_INTR_MASK BIT(23) #define AMD_SDW_DEVICE_STATE 0x1430 #define AMD_SDW0_DEVICE_STATE_MASK GENMASK(1, 0) #define AMD_SDW1_DEVICE_STATE_MASK GENMASK(3, 2)