From patchwork Thu Dec 21 07:35:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501262 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) (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 94EF211735; Thu, 21 Dec 2023 07:36:25 +0000 (UTC) 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="ms9exYsz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GaprQO9U5H31ZApSI+N1Lo+abByXHT0saIKKqifGlIIyWw9fMzOZMjnnPK9E7q2VPZi/17NOy2uB6LzEelswC4KFHtTrdd1r/g7+TOtKk5FgRq3iBcj4bGZsW30FQxixB685jVwE+z1cgiy10fTzkQnwH0yxkRgT5VUB+TidCf7rrXygvsKQR020LkKaywZfSpFQdDDJ+PXV9oNjY8WmvypUA1mdZGUP9U9VHyL/0wHxmCsw3WrmbJLXkWsADpup9odHkNNNcrLWTNoZLo+kh0x9Pyf0XuyODnOSt5YGWEqpOLfTosa8nU/uCQ/453FMo3cambRy9+ftqXV9RYUU1g== 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=3I5faMlbiK2WABI1X3s7NUbtTh8LQQWNgrQ5ilX7d0Y=; b=KKo/rwI5IsVGfPGmBElJJLGgJUwSVpCpMznRSZQjD1IghyOHmtrcr6zujnBtYAX7CQXNyJ86z0yZf+qrV0LOinl2bDFrPmQavi9oHPygiX+FJbu1Hc1GOBYzTg8GQWSFkdmaj5iYT6Z94iVlMJeEve1xTmhwHqpqL+26n8FFaKZZX4t2cFDdTAA84fkorm2dSF/KZxLYlvTLezHobWaVjTXWWSWi10yD1F7toeKTfnYa3WeeZEkeABAkn8a6MtK1jfJ560sMVramB13+asSKa/tev1yPG6mwwCB9I0OtyCGIR3EIgVMFDTyrwDCUqGZ75WsTpyC62UI99pEz+LCxKg== 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=3I5faMlbiK2WABI1X3s7NUbtTh8LQQWNgrQ5ilX7d0Y=; b=ms9exYsz2BsvY+xu0C8uBaznJvA+OPuilwNDkLhNbI4woCkhUFp86+n1Oi88QnC4JoAAbiumrQaPvpg53a/AnK61ne5a3IW+IJBCULyr4gkKd4ee1c+GHx/Lf5o6nGzX4T6xzyDOlvH0vWg5BAIhHjh7ZjA3Z/ymzZftLx2a4/k= Received: from MW4PR04CA0214.namprd04.prod.outlook.com (2603:10b6:303:87::9) by DS7PR12MB8084.namprd12.prod.outlook.com (2603:10b6:8:ef::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.21; Thu, 21 Dec 2023 07:36:23 +0000 Received: from CO1PEPF000044FB.namprd21.prod.outlook.com (2603:10b6:303:87:cafe::f3) by MW4PR04CA0214.outlook.office365.com (2603:10b6:303:87::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:36:22 +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 CO1PEPF000044FB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:36:22 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.34; Thu, 21 Dec 2023 01:36:22 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 21 Dec 2023 01:36:21 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:36:16 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Bard Liao , Sanyog Kale , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , "Syed Saba Kareem" , Arnd Bergmann , "Marian Postevca" , open list , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." Subject: [PATCH 01/12] ASoC/soundwire: implement generic api for scanning amd soundwire controller Date: Thu, 21 Dec 2023 13:05:47 +0530 Message-ID: <20231221073558.3181911-2-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FB:EE_|DS7PR12MB8084:EE_ X-MS-Office365-Filtering-Correlation-Id: c6c8e2cc-70d1-4d77-dafa-08dc01f787f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KxH1s/lZtLf5FuPf++KZnlwktaPhnjTk8IFgRziT+7s2xDV9qDJ/gYz5l+xdqh2q5RqCLtegGmlsZleLbNNdj0dNANOBBkp1tKnloCeIU0EKtQt/CCscYvfdqgabiE74Hb7ojEIWCUM4KpofdT5AOs/p8vfWbCrgGTND+l5T4jkp7W9FDaTkD/ngiwoIKhPI1gm/4Y9If4Wum4LqCLzdD8oD+I4LR1SFiKY2e6EFMsjKWOILqtEtzfBTdp+uITjevFmMo4IxgjYda49xKgLdm0eB2wNeTrN6NPVPLc2Pmxnrdj/Lb8628rDBqP8lXARVlRWb+bN1oPiLqKU/fOoof1Sqs4JFxcozkm0yaFvpK7vpYZwGmP3gIxWktBxsbbZoguDW65wbKtIteZ2IQMZj9PjxdKkksdo8rQnVR47Cq4GvibRtmyZ8JtGnP4Aj+9OqvHDcpblJELZOAwNfv1fQfAmAhvkQ03qLrPZtYpsgxQAbjE/I43ec5kU1Av1dyQMGYMWR6471+2fQWE8pdM6TTDkCvI1FeScZDzlq++JmkRlyDbLV/kfcHcsFGhnhzEsBlB7eR7vIhHom3qjUYiwaq9xnN6aDVtfb0h/gemO5wzcOhf5PtipaQhunF+yPTyBI9wdWtFBe5iyUD61/d44eNCIQFy51Uofv/V3Uu6fEjqP/TWLcxIREfWwR0hEc1R6EfInklQDtsZFarQZ+5DFVszWjfkXe9RevO3OldjNtet9GMhExYCQsZ9IPv6Rf9VKUGE9bcMITRs53Xn+1fnrLkfTb0849VZFuuS1nP4gQPq8= 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)(376002)(39860400002)(136003)(346002)(230922051799003)(82310400011)(1800799012)(186009)(64100799003)(451199024)(36840700001)(46966006)(40470700004)(6666004)(478600001)(54906003)(110136005)(316002)(8676002)(8936002)(70586007)(70206006)(83380400001)(36860700001)(47076005)(7696005)(1076003)(26005)(336012)(426003)(2616005)(41300700001)(2906002)(7416002)(4326008)(5660300002)(40480700001)(86362001)(36756003)(82740400003)(81166007)(356005)(40460700003)(41533002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:36:22.7464 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6c8e2cc-70d1-4d77-dafa-08dc01f787f0 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: CO1PEPF000044FB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8084 Implement generic function for scanning SoundWire controller. Same function will be used for legacy and sof stack for AMD platforms. Signed-off-by: Vijendar Mukunda --- include/linux/soundwire/sdw_amd.h | 15 ++++++++ sound/soc/amd/acp/Kconfig | 7 ++++ sound/soc/amd/acp/Makefile | 2 + sound/soc/amd/acp/amd-sdw-acpi.c | 62 +++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 sound/soc/amd/acp/amd-sdw-acpi.c diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h index ceecad74aef9..41dd64941cef 100644 --- a/include/linux/soundwire/sdw_amd.h +++ b/include/linux/soundwire/sdw_amd.h @@ -6,6 +6,7 @@ #ifndef __SDW_AMD_H #define __SDW_AMD_H +#include #include /* AMD pm_runtime quirk definitions */ @@ -106,4 +107,18 @@ struct amd_sdw_manager { struct sdw_amd_dai_runtime **dai_runtime_array; }; + +/** + * struct sdw_amd_acpi_info - Soundwire AMD information found in ACPI tables + * @handle: ACPI controller handle + * @count: maximum no of soundwire manager links supported on AMD platform. + * @link_mask: bit-wise mask listing links enabled by BIOS menu + */ +struct sdw_amd_acpi_info { + acpi_handle handle; + int count; + u32 link_mask; +}; + +int amd_sdw_scan_controller(struct sdw_amd_acpi_info *info); #endif diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index 84c963241dc5..b3105ba9c3a3 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -101,6 +101,13 @@ config SND_SOC_AMD_MACH_COMMON help This option enables common Machine driver module for ACP. +config SND_AMD_SOUNDWIRE_ACPI + tristate "AMD SoundWire ACPI Support" + depends on ACPI + help + This options enables ACPI helper functions for SoundWire + interface for AMD platforms. + config SND_SOC_AMD_LEGACY_MACH tristate "AMD Legacy Machine Driver Support" depends on X86 && PCI && I2C diff --git a/sound/soc/amd/acp/Makefile b/sound/soc/amd/acp/Makefile index ff5f7893b81e..1fd581a2aa33 100644 --- a/sound/soc/amd/acp/Makefile +++ b/sound/soc/amd/acp/Makefile @@ -10,6 +10,7 @@ snd-acp-i2s-objs := acp-i2s.o snd-acp-pdm-objs := acp-pdm.o snd-acp-legacy-common-objs := acp-legacy-common.o snd-acp-pci-objs := acp-pci.o +snd-amd-sdw-acpi-objs := amd-sdw-acpi.o #platform specific driver snd-acp-renoir-objs := acp-renoir.o @@ -33,6 +34,7 @@ obj-$(CONFIG_SND_AMD_ASOC_REMBRANDT) += snd-acp-rembrandt.o obj-$(CONFIG_SND_AMD_ASOC_ACP63) += snd-acp63.o obj-$(CONFIG_SND_AMD_ASOC_ACP70) += snd-acp70.o +obj-$(CONFIG_SND_AMD_SOUNDWIRE_ACPI) += snd-amd-sdw-acpi.o obj-$(CONFIG_SND_SOC_AMD_MACH_COMMON) += snd-acp-mach.o obj-$(CONFIG_SND_SOC_AMD_LEGACY_MACH) += snd-acp-legacy-mach.o obj-$(CONFIG_SND_SOC_AMD_SOF_MACH) += snd-acp-sof-mach.o diff --git a/sound/soc/amd/acp/amd-sdw-acpi.c b/sound/soc/amd/acp/amd-sdw-acpi.c new file mode 100644 index 000000000000..babd841d3296 --- /dev/null +++ b/sound/soc/amd/acp/amd-sdw-acpi.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// This file is provided under a dual BSD/GPLv2 license. When using or +// redistributing this file, you may do so under either license. +// +// Copyright(c) 2023 Advanced Micro Devices, Inc. All rights reserved. +// +// Authors: Vijendar Mukunda + +/* + * SDW AMD ACPI scan helper function + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int amd_sdw_scan_controller(struct sdw_amd_acpi_info *info) +{ + struct acpi_device *adev = acpi_fetch_acpi_dev(info->handle); + u32 sdw_bitmap = 0; + u8 count = 0; + int ret; + + if (!adev) + return -EINVAL; + + /* Found controller, find links supported */ + ret = fwnode_property_read_u32_array(acpi_fwnode_handle(adev), + "mipi-sdw-manager-list", &sdw_bitmap, 1); + if (ret) { + dev_err(&adev->dev, + "Failed to read mipi-sdw-manager-list: %d\n", ret); + return -EINVAL; + } + count = hweight32(sdw_bitmap); + /* Check count is within bounds */ + if (count > info->count) { + dev_err(&adev->dev, "Manager count %d exceeds max %d\n", + count, info->count); + return -EINVAL; + } + + if (!count) { + dev_dbg(&adev->dev, "No SoundWire Managers detected\n"); + return -EINVAL; + } + dev_dbg(&adev->dev, "ACPI reports %d SoundWire Manager devices\n", count); + info->link_mask = sdw_bitmap; + return 0; +} +EXPORT_SYMBOL_NS(amd_sdw_scan_controller, SND_AMD_SOUNDWIRE_ACPI); + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_DESCRIPTION("AMD SoundWire ACPI helpers"); From patchwork Thu Dec 21 07:35:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501284 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A38A9C35274 for ; Thu, 21 Dec 2023 07:42:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0906183B; Thu, 21 Dec 2023 08:42:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0906183B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1703144556; bh=OvLDLxq/doYg35Hllw4Wot456GesI6VGj5IEFHywSQg=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=sCMcKoGAnoar5rxUexle6mLmtdhpdgIqULTQ36Wb40knjtjae1F250DNml1oS8f8S xLsiI/eO5QbrRyFvhZt+m03EScD+WWLSCDHBSDwjVZUdBTO0cgOzXDz1R07FApLYsP PeUQtI6uKjd49k1XkQmWJDx0wnmaTlP20A5ZGgjQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A93B5F805F5; Thu, 21 Dec 2023 08:41:21 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 5344BF80611; Thu, 21 Dec 2023 08:41:20 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4FAFBF8024E; Thu, 21 Dec 2023 08:37:03 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060a.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::60a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DEECBF8057F for ; Thu, 21 Dec 2023 08:36:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DEECBF8057F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=s1aH1OPQ ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a8uEmlLkNIBkb0qWZ/lIFajuPMLGbX6nmEw4HMMxX0OnMzXgJ9zq7g5mu9Jqo1ZLwf4T1jTFwMqTL6OZnWfLbJrTO0+g5skZ+FsNDdRUXu/RVykHlAfSAMGltSMomu5ngah2knJJi+SUvCyXDtWrFqzYex+dMby66SA8ob7LMFere7gsfCcOXGgAjhfjPIThslwthSjJuKOmfGMOhnD3WbEC+qpB8PwFZNhcFGmF3OmGCA5ixZC0ydIf3hZm7YxPthFJc6prM43JihKPwCbfVI744eb+KZDXXXRp3azSWFyEZKrxg+8VZlDu+d3tmgHlo+d9Q3XOJWKBAAStjrCmfw== 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=DNkiQy7d9ubHatMOO4iZXXJ6XCkfuXv2+WmQtqx7LIQ=; b=bmiZ4ArE3HKVsHFvSNJUtjX2SKSEwYbCJmpmDlNQIaWNAY18vSHVwi1fOCToEdJRPp6/4HAB5N3MoQ3xqWLMcLZsTvFGdZr0JN+Uhw486s3rpVTeQN9NHNAZbeVOqcpVl3FJtCtNQaxHtxqHr7e6rsEuwPAdmrMOJbu4rAqCS/yX2ZmGDWAWWLKTyg/MSEB7Yfln6//Ocl1oT8fOIV1WtpIXbJ7q9GOYey7ULNe+idGOzuwme0+917Jbup3O9ngnG2fnI9ihO30oh9YBF/Swk6cZBrtAFDaN78orL8Dl8RCKQnvt9fPWwvuvVhsagjXVE1gP2bHeJ1t6x0vIldLjZQ== 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=DNkiQy7d9ubHatMOO4iZXXJ6XCkfuXv2+WmQtqx7LIQ=; b=s1aH1OPQlrluf5jHPcROIt4U+BOuZpu/P01sMMknn03OaxZ+QlypKnGcMkkhqpFAJervGqCPDzeSqpYi1VIqDwpLfssd2fjZSq1oDhvEEDeqzsyuXHmm95ylV82HLcvivSMqGjZAdPQaWeBGjb8E4dqKSbU+xYp/0WMu32J3Fes= Received: from MW4P223CA0012.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::17) by CY8PR12MB7433.namprd12.prod.outlook.com (2603:10b6:930:53::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18; Thu, 21 Dec 2023 07:36:30 +0000 Received: from CO1PEPF000044F8.namprd21.prod.outlook.com (2603:10b6:303:80:cafe::6e) by MW4P223CA0012.outlook.office365.com (2603:10b6:303:80::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.19 via Frontend Transport; Thu, 21 Dec 2023 07:36: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044F8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:36:29 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.34; Thu, 21 Dec 2023 01:36:29 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 21 Dec 2023 01:36:28 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:36:25 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Bard Liao , Sanyog Kale , open list Subject: [PATCH 02/12] drivers: soundwire: refactor amd soundwire manager device node creation Date: Thu, 21 Dec 2023 13:05:48 +0530 Message-ID: <20231221073558.3181911-3-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F8:EE_|CY8PR12MB7433:EE_ X-MS-Office365-Filtering-Correlation-Id: 8370ecf6-f2d8-46f3-f4bc-08dc01f78c31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: soqEQs0aSk7f8rwu7hZWvYcJGfuuD87kUXpb31erRXUVm5THYwotJXR5GDyf7pPAQoZp6wIdrEcY3z7heO3c1uZS6+AUph5QOz5+O7FOPnGy4n4B1mJiLSC/WUxGp4rDGUffZ+3xgCPI8HGn8KKndetoRFoUQjjK0LyaMnllw3DqBcJReOEufrTNWZUKntY59tMdAqtHuzVMy3wXpwcxYHaL1gFYXl0xj4V6BtA+ScwvCfmi6KXQDOif5ynLhreBaBBgSB7oVPV1ENTr9tqVVEtiS0kJP5cW+3H+hvKtRQFL/LwQcqb02owsGqvIURD6RO0DRG5Fw5d8ed+baQeD4KuutGcBzdINY1/kwK+AycJULQlkalyuMRchRXNJdFUsRL6j7z1TNEBWYpxHZpvo35db58uhbPczfe6aj7Mt3+UlUoiWOKn5ZSKa+gTVJOwwA0OV7az8rRaDG3OMzFbunZWbn5Et6I328JWtMN8lx2WgDtuNjeyDDZJ5DAZQ9vEnBEP9VUcUfnyer8lOKAJbpVkcgPhlaIkoBdBqsa8Sn/2SDpZfH0kkdL3CKmp1Ox7L+MMNXhb9cuHNds5FWb4BXIk48oZxwQD5pTX0Vb+gfwEYiW3SSdmOJ4b0nk8BpwQdOpkLRBrfd1Zx0UIoUyPioVl64QfL3hWkv6Aa5APSSlmnlM/5knLES8QKWqjR/vh0s6N5zyIzQEVIxb0jwmFygyK9m7Kvy/12qTHTdbRl8BUy5VwzE7twYUt1Qh5xvBirWgTSiRdq6VwzIub5JxMlaQ== 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)(39860400002)(396003)(346002)(136003)(376002)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(82310400011)(40470700004)(36840700001)(46966006)(356005)(2906002)(82740400003)(81166007)(30864003)(36756003)(41300700001)(86362001)(316002)(26005)(6666004)(2616005)(336012)(478600001)(1076003)(40480700001)(54906003)(83380400001)(70206006)(110136005)(426003)(8936002)(36860700001)(70586007)(40460700003)(5660300002)(47076005)(7696005)(8676002)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:36:29.8995 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8370ecf6-f2d8-46f3-f4bc-08dc01f78c31 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: CO1PEPF000044F8.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7433 Message-ID-Hash: 6BJWCSWSRW6GZ4DIHOOW5ZWSIQNB2YB7 X-Message-ID-Hash: 6BJWCSWSRW6GZ4DIHOOW5ZWSIQNB2YB7 X-MailFrom: Vijendar.Mukunda@amd.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Refactor amd SoundWire manager device node creation logic and implement generic functions to have a common functionality for SoundWire manager platform device creation, start and exit sequence for both legacy(NO DSP) and SOF stack for AMD platforms. These functions will be invoked from legacy and SOF stack. Signed-off-by: Vijendar Mukunda --- drivers/soundwire/Makefile | 2 +- drivers/soundwire/amd_init.c | 147 ++++++++++++++++++++++++++++++ drivers/soundwire/amd_init.h | 13 +++ drivers/soundwire/amd_manager.c | 16 +--- include/linux/soundwire/sdw_amd.h | 54 ++++++++++- 5 files changed, 218 insertions(+), 14 deletions(-) create mode 100644 drivers/soundwire/amd_init.c create mode 100644 drivers/soundwire/amd_init.h diff --git a/drivers/soundwire/Makefile b/drivers/soundwire/Makefile index 657f5888a77b..e80a2c2cf3e7 100644 --- a/drivers/soundwire/Makefile +++ b/drivers/soundwire/Makefile @@ -20,7 +20,7 @@ soundwire-bus-y += irq.o endif #AMD driver -soundwire-amd-y := amd_manager.o +soundwire-amd-y := amd_init.o amd_manager.o obj-$(CONFIG_SOUNDWIRE_AMD) += soundwire-amd.o #Cadence Objs diff --git a/drivers/soundwire/amd_init.c b/drivers/soundwire/amd_init.c new file mode 100644 index 000000000000..d732ab0bfd59 --- /dev/null +++ b/drivers/soundwire/amd_init.c @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) +/* + * SoundWire AMD Manager Initialize routines + * + * Initializes and creates SDW devices based on ACPI and Hardware values + * + * Copyright 2023 Advanced Micro Devices, Inc. + */ + +#include +#include +#include +#include +#include + +#include "amd_init.h" + +static int sdw_amd_cleanup(struct sdw_amd_ctx *ctx) +{ + int i; + + for (i = 0; i < ctx->count; i++) { + if (!(ctx->link_mask & BIT(i))) + continue; + platform_device_unregister(ctx->pdev[i]); + } + + return 0; +} + +static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) +{ + struct sdw_amd_ctx *ctx; + struct acpi_device *adev; + struct resource *sdw_res; + struct acp_sdw_pdata sdw_pdata[2]; + struct platform_device_info pdevinfo[2]; + u32 link_mask; + int count, index; + + if (!res) + return NULL; + + adev = acpi_fetch_acpi_dev(res->handle); + if (!adev) + return NULL; + + if (!res->count) + return NULL; + + count = res->count; + dev_dbg(&adev->dev, "Creating %d SDW Link devices\n", count); + + /* + * we need to alloc/free memory manually and can't use devm: + * this routine may be called from a workqueue, and not from + * the parent .probe. + * If devm_ was used, the memory might never be freed on errors. + */ + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return NULL; + + ctx->count = count; + ctx->link_mask = res->link_mask; + sdw_res = kzalloc(sizeof(*sdw_res), GFP_KERNEL); + if (!sdw_res) { + kfree(ctx); + return NULL; + } + sdw_res->flags = IORESOURCE_MEM; + sdw_res->start = res->addr; + sdw_res->end = res->addr + res->reg_range; + memset(&pdevinfo, 0, sizeof(pdevinfo)); + link_mask = ctx->link_mask; + for (index = 0; index < count; index++) { + if (!(link_mask & BIT(index))) + continue; + + sdw_pdata[index].instance = index; + sdw_pdata[index].acp_sdw_lock = res->acp_lock; + pdevinfo[index].name = "amd_sdw_manager"; + pdevinfo[index].id = index; + pdevinfo[index].parent = res->parent; + pdevinfo[index].num_res = 1; + pdevinfo[index].res = sdw_res; + pdevinfo[index].data = &sdw_pdata[index]; + pdevinfo[index].size_data = sizeof(struct acp_sdw_pdata); + pdevinfo[index].fwnode = acpi_fwnode_handle(adev); + ctx->pdev[index] = platform_device_register_full(&pdevinfo[index]); + if (IS_ERR(ctx->pdev[index])) + goto err; + } + kfree(sdw_res); + return ctx; +err: + while (index--) { + if (!(link_mask & BIT(index))) + continue; + + platform_device_unregister(ctx->pdev[index]); + } + + kfree(sdw_res); + kfree(ctx); + return NULL; +} + +static int sdw_amd_startup(struct sdw_amd_ctx *ctx) +{ + struct amd_sdw_manager *amd_manager; + int i, ret; + + /* Startup SDW Manager devices */ + for (i = 0; i < ctx->count; i++) { + if (!(ctx->link_mask & BIT(i))) + continue; + amd_manager = dev_get_drvdata(&ctx->pdev[i]->dev); + ret = amd_sdw_manager_start(amd_manager); + if (ret) + return ret; + } + + return 0; +} + +int sdw_amd_probe(struct sdw_amd_res *res, struct sdw_amd_ctx **sdw_ctx) +{ + *sdw_ctx = sdw_amd_probe_controller(res); + if (!*sdw_ctx) + return -ENODEV; + + return sdw_amd_startup(*sdw_ctx); +} +EXPORT_SYMBOL_NS(sdw_amd_probe, SOUNDWIRE_AMD_INIT); + +void sdw_amd_exit(struct sdw_amd_ctx *ctx) +{ + sdw_amd_cleanup(ctx); + kfree(ctx->ids); + kfree(ctx); +} +EXPORT_SYMBOL_NS(sdw_amd_exit, SOUNDWIRE_AMD_INIT); + +MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); +MODULE_DESCRIPTION("AMD SoundWire Init Library"); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/soundwire/amd_init.h b/drivers/soundwire/amd_init.h new file mode 100644 index 000000000000..f710703ffae9 --- /dev/null +++ b/drivers/soundwire/amd_init.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ +/* + * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. + */ + +#ifndef __AMD_INIT_H +#define __AMD_INIT_H + +#include + +int amd_sdw_manager_start(struct amd_sdw_manager *amd_manager); + +#endif diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c index 3a99f6dcdfaf..c27b0b0f33a6 100644 --- a/drivers/soundwire/amd_manager.c +++ b/drivers/soundwire/amd_manager.c @@ -19,6 +19,7 @@ #include #include #include "bus.h" +#include "amd_init.h" #include "amd_manager.h" #define DRV_NAME "amd_sdw_manager" @@ -864,10 +865,8 @@ static void amd_sdw_irq_thread(struct work_struct *work) writel(0x00, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_0TO7); } -static void amd_sdw_probe_work(struct work_struct *work) +int amd_sdw_manager_start(struct amd_sdw_manager *amd_manager) { - struct amd_sdw_manager *amd_manager = container_of(work, struct amd_sdw_manager, - probe_work); struct sdw_master_prop *prop; int ret; @@ -876,11 +875,11 @@ static void amd_sdw_probe_work(struct work_struct *work) amd_enable_sdw_pads(amd_manager); ret = amd_init_sdw_manager(amd_manager); if (ret) - return; + return ret; amd_enable_sdw_interrupts(amd_manager); ret = amd_enable_sdw_manager(amd_manager); if (ret) - return; + return ret; amd_sdw_set_frameshape(amd_manager); } /* Enable runtime PM */ @@ -889,6 +888,7 @@ static void amd_sdw_probe_work(struct work_struct *work) pm_runtime_mark_last_busy(amd_manager->dev); pm_runtime_set_active(amd_manager->dev); pm_runtime_enable(amd_manager->dev); + return 0; } static int amd_sdw_manager_probe(struct platform_device *pdev) @@ -964,11 +964,6 @@ static int amd_sdw_manager_probe(struct platform_device *pdev) dev_set_drvdata(dev, amd_manager); INIT_WORK(&amd_manager->amd_sdw_irq_thread, amd_sdw_irq_thread); INIT_WORK(&amd_manager->amd_sdw_work, amd_sdw_update_slave_status_work); - INIT_WORK(&amd_manager->probe_work, amd_sdw_probe_work); - /* - * Instead of having lengthy probe sequence, use deferred probe. - */ - schedule_work(&amd_manager->probe_work); return 0; } @@ -978,7 +973,6 @@ static void amd_sdw_manager_remove(struct platform_device *pdev) int ret; pm_runtime_disable(&pdev->dev); - cancel_work_sync(&amd_manager->probe_work); amd_disable_sdw_interrupts(amd_manager); sdw_bus_master_delete(&amd_manager->bus); ret = amd_disable_sdw_manager(amd_manager); diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h index 41dd64941cef..064174c2f401 100644 --- a/include/linux/soundwire/sdw_amd.h +++ b/include/linux/soundwire/sdw_amd.h @@ -26,6 +26,7 @@ #define AMD_SDW_POWER_OFF_MODE 2 #define ACP_SDW0 0 #define ACP_SDW1 1 +#define AMD_SDW_MAX_MANAGER_COUNT 2 struct acp_sdw_pdata { u16 instance; @@ -63,7 +64,6 @@ struct sdw_amd_dai_runtime { * @reg_mask: register mask structure per manager instance * @amd_sdw_irq_thread: SoundWire manager irq workqueue * @amd_sdw_work: peripheral status work queue - * @probe_work: SoundWire manager probe workqueue * @acp_sdw_lock: mutex to protect acp share register access * @status: peripheral devices status array * @num_din_ports: number of input ports @@ -87,7 +87,6 @@ struct amd_sdw_manager { struct sdw_manager_reg_mask *reg_mask; struct work_struct amd_sdw_irq_thread; struct work_struct amd_sdw_work; - struct work_struct probe_work; /* mutex to protect acp common register access */ struct mutex *acp_sdw_lock; @@ -120,5 +119,56 @@ struct sdw_amd_acpi_info { u32 link_mask; }; +/** + * struct sdw_amd_ctx - context allocated by the controller + * driver probe + * @count: link count + * @num_slaves: total number of devices exposed across all enabled links + * @link_mask: bit-wise mask listing SoundWire links reported by the + * Controller + * @ids: array of slave_id, representing Slaves exposed across all enabled + * links + * @pdev: platform device structure + */ +struct sdw_amd_ctx { + int count; + int num_slaves; + u32 link_mask; + struct sdw_extended_slave_id *ids; + struct platform_device *pdev[AMD_SDW_MAX_MANAGER_COUNT]; +}; + +/** + * struct sdw_amd_res - Soundwire AMD global resource structure, + * typically populated by the DSP driver/Legacy driver + * + * @addr: acp pci device resource start address + * @reg_range: ACP register range + * @link_mask: bit-wise mask listing links selected by the DSP driver/ + * legacy driver + * @count: link count + * @mmio_base: mmio base of SoundWire registers + * @handle: ACPI parent handle + * @parent: parent device + * @dev: device implementing hwparams and free callbacks + * @acp_lock: mutex protecting acp common registers access + */ +struct sdw_amd_res { + u32 addr; + u32 reg_range; + u32 link_mask; + int count; + void __iomem *mmio_base; + acpi_handle handle; + struct device *parent; + struct device *dev; + /* use to protect acp common registers access */ + struct mutex *acp_lock; +}; + +int sdw_amd_probe(struct sdw_amd_res *res, struct sdw_amd_ctx **ctx); + +void sdw_amd_exit(struct sdw_amd_ctx *ctx); + int amd_sdw_scan_controller(struct sdw_amd_acpi_info *info); #endif From patchwork Thu Dec 21 07:35:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501282 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04D2CC35274 for ; Thu, 21 Dec 2023 07:41:59 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1A85EDEE; Thu, 21 Dec 2023 08:41:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1A85EDEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1703144517; bh=f6k1esCWpoCCKJZym1dKSAHw+3D05/b7pbioiZCCgrY=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=VC3wqm26fPk1CREq/CQa+G6k9aV7tWGi59sZmaMXGcjTR0z45KzPE+JgLEZNcdjyT yQiljzOqU5VrttNCCwj/XonvU5NA+PgvEdQS86rEkSpHc++VQtq/zGCeHXDJm1hlkv 4IjOyU0ezamEfF72E5QBo/sUmPop1dkK9Eu9Z7Aw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id DC8FDF805D4; Thu, 21 Dec 2023 08:41:13 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 17577F805C5; Thu, 21 Dec 2023 08:41:13 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C31ECF80563; Thu, 21 Dec 2023 08:36:49 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::600]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C53C7F80568 for ; Thu, 21 Dec 2023 08:36:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C53C7F80568 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=BeB+wngG ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fxBLw8OmMR6Muk2mQkPXvwbqCG/yCJX+YlRx8OJbwQqnsPFrfZ4BIHYsTSb1ejklBig+xfl74zAQLeD1M0W3Q6PNPmGhijYcnRCAQV1zTBLWzm+qiAv7523CXYUFvYRY2DQ/1tk0qOFkgcikgGDGi6G7Ic2vUI78NwCmVw1+i/fuZ0FAI5CaOOdLFaYHRNtDbq7vtW8ZE/G+umtx8jr5xgmNy/DBhBvz5m6RC6t6T8NuPDR+cKWogFZKHdlkAm21tqSCX0z2irl2YO4eJjPm9fKcgkKEntZvz7SJh08pQwvf01WusNLqLNtD+w4bCQZy7225yqkkJxk7JPeHe1pOfQ== 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=7jHejUbx5Ovbg4p8oogFnHCki7XL5gTAqXfCeasFBH4=; b=gEBZcXrSwvFzNDkBaTk4xK5epY9lQMXkwI8T1iZhLZAF7LfSzIFnyLH4MuzGQZswI/d9PCE4aD2Cod5Mcascg8yrjXrC/KCRepZIujnvK1PswWq6gNtdRI/c2m8D81g/zVuLzui0poUfsjeD6xv4eH7BE26liH9wO+fcpKzB0vv0v/MofNwjB7j4cpUF4Y9o+RddaoT1kmVatxC6n9l22hAuuUwtXbLLagdP8NjPR58FFSw/j2e7pIXep/7j6R0GdekeuFZIbDJmcTTYs4k8GmCV+esagbmVWRBtgzSC4+DsXsV/SHwgWNQsYYtfQ31rqA338ooCKLtELv0MoMyT7w== 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=7jHejUbx5Ovbg4p8oogFnHCki7XL5gTAqXfCeasFBH4=; b=BeB+wngGTHB3tTovpxiMv/xDeMQLom+dvCBNh0JLsQcyjV+0gDVzBRf/PLuHuR5VxbmXwfNGWNUGzOVm/bCNiEShSdad6uiNtbGot0M5sq8J7HzpVQd62LQ1YFwHqkk0g2FtxkuU7A+w4qcJ6opswwPozKHVF278CwR7pbHl1ZU= Received: from MW4P223CA0020.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::25) by CY5PR12MB6035.namprd12.prod.outlook.com (2603:10b6:930:2d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.21; Thu, 21 Dec 2023 07:36:34 +0000 Received: from CO1PEPF000044FD.namprd21.prod.outlook.com (2603:10b6:303:80:cafe::b6) by MW4P223CA0020.outlook.office365.com (2603:10b6:303:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.21 via Frontend Transport; Thu, 21 Dec 2023 07:36: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044FD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:36:33 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.34; Thu, 21 Dec 2023 01:36:32 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 21 Dec 2023 01:36:32 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:36:29 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Bard Liao , Sanyog Kale , open list Subject: [PATCH 03/12] drivers: soundwire: implement function to extract slave information Date: Thu, 21 Dec 2023 13:05:49 +0530 Message-ID: <20231221073558.3181911-4-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FD:EE_|CY5PR12MB6035:EE_ X-MS-Office365-Filtering-Correlation-Id: 46573ef6-dbf8-4b8e-74c9-08dc01f78e74 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y1OdD4PVzGqEBNPBtlt7v5kdWjTXmSwMqXs1uN+3cyj8P8qyNKLzAIuZA2DsA4A171KCmgwaW0GOkUtWhooan8TVPGBZU7e2gS3j5UEQDk55EQOg51KhA7vCWg9ddjjvzrMxPFuOwQsOrThm9ljK5gd+P641Z46DlCxDYQD2e0tGnSfyXzZzPXrXnmbugCGfVsVoAm6BmCVVY/TDpOZ62wzFWGMjIkh49lf+PhE2iOVS7TF1WFXBo5SyWghyObNHpN+P98EIi7GEWdnIO5F8Wa5S6lvAg5C6TypYqcGUFrzvhcPpElMEf+7oZuKZgbNDv0zQlTCQDJvc++c9P0LijnqTE/zuqUEPscyEEcOkGfFMprI8vDz5Sp6b4khk0dhOo2LYWoi34BmbhftJLa0iMwkvhNNtSNF03uHhByUC0dDaxzRrp9a+4b1+Ja1VCvgiFlCpam39MLIrPZM5Enbtj7/arSVK8dJhu3chcbVn0izgLNDbGmRZnRh++jDf9S3WmBlbnGpCLBqOmTwEO1uni1xG5yycW2wX9YqAVg9T1j18NkwtUoFwItCZoPLiiG7ZVhSWYafqVCp1CTkAjryIhUhSfD/9+bDBlY/vQT8OnDzCTbKhQsjQMEUjWiHI0w7hYwDb5+1mBe/SjoUbiTFfAaMCBr9MUpK5RhtjkGpfm72UojNfFga9jV6P22kd1qNuXor3zhvDatqIimc2V6P5O85dzDlygXIWBZasrHgb0Ls2NFHJKY842vEWQOveE5id5zRii5Dd8ylwLornFCrZ/g== 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)(39860400002)(396003)(346002)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(82310400011)(36840700001)(40470700004)(46966006)(110136005)(70206006)(70586007)(40480700001)(54906003)(316002)(8936002)(8676002)(4326008)(40460700003)(81166007)(336012)(426003)(47076005)(26005)(1076003)(82740400003)(2616005)(41300700001)(5660300002)(36756003)(86362001)(356005)(7696005)(6666004)(2906002)(36860700001)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:36:33.6595 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46573ef6-dbf8-4b8e-74c9-08dc01f78e74 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: CO1PEPF000044FD.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6035 Message-ID-Hash: 3SY2KYLNSY36XAFJ3S5YI63PD4BSNRDF X-Message-ID-Hash: 3SY2KYLNSY36XAFJ3S5YI63PD4BSNRDF X-MailFrom: Vijendar.Mukunda@amd.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Implement function to extract slaves information connected on the bus. This information is required during machine select logic. This function will be called from machine select logic code. Signed-off-by: Vijendar Mukunda --- drivers/soundwire/amd_init.c | 43 +++++++++++++++++++++++++++++++ include/linux/soundwire/sdw_amd.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/drivers/soundwire/amd_init.c b/drivers/soundwire/amd_init.c index d732ab0bfd59..5c9569d9ad01 100644 --- a/drivers/soundwire/amd_init.c +++ b/drivers/soundwire/amd_init.c @@ -142,6 +142,49 @@ void sdw_amd_exit(struct sdw_amd_ctx *ctx) } EXPORT_SYMBOL_NS(sdw_amd_exit, SOUNDWIRE_AMD_INIT); +int sdw_amd_get_slave_info(struct sdw_amd_ctx *ctx) +{ + struct amd_sdw_manager *amd_manager; + struct sdw_bus *bus; + struct sdw_slave *slave; + struct list_head *node; + int index; + int i = 0; + int num_slaves = 0; + + for (index = 0; index < ctx->count; index++) { + if (!(ctx->link_mask & BIT(index))) + continue; + amd_manager = dev_get_drvdata(&ctx->pdev[index]->dev); + if (!amd_manager) + return -ENODEV; + bus = &amd_manager->bus; + /* Calculate number of slaves */ + list_for_each(node, &bus->slaves) + num_slaves++; + } + + ctx->ids = kcalloc(num_slaves, sizeof(*ctx->ids), GFP_KERNEL); + if (!ctx->ids) + return -ENOMEM; + ctx->num_slaves = num_slaves; + for (index = 0; index < ctx->count; index++) { + if (!(ctx->link_mask & BIT(index))) + continue; + amd_manager = dev_get_drvdata(&ctx->pdev[index]->dev); + if (amd_manager) { + bus = &amd_manager->bus; + list_for_each_entry(slave, &bus->slaves, node) { + ctx->ids[i].id = slave->id; + ctx->ids[i].link_id = bus->link_id; + i++; + } + } + } + return 0; +} +EXPORT_SYMBOL_NS(sdw_amd_get_slave_info, SOUNDWIRE_AMD_INIT); + MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); MODULE_DESCRIPTION("AMD SoundWire Init Library"); MODULE_LICENSE("Dual BSD/GPL"); diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h index 064174c2f401..47b6cea356ff 100644 --- a/include/linux/soundwire/sdw_amd.h +++ b/include/linux/soundwire/sdw_amd.h @@ -170,5 +170,7 @@ int sdw_amd_probe(struct sdw_amd_res *res, struct sdw_amd_ctx **ctx); void sdw_amd_exit(struct sdw_amd_ctx *ctx); +int sdw_amd_get_slave_info(struct sdw_amd_ctx *ctx); + int amd_sdw_scan_controller(struct sdw_amd_acpi_info *info); #endif From patchwork Thu Dec 21 07:35:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FC1CC35274 for ; Thu, 21 Dec 2023 07:42:18 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1942B83E; Thu, 21 Dec 2023 08:42:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1942B83E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1703144536; bh=J+iF9w6aZH2FTqz6TdB/AyP0yC+a7HiilaCc+82lGsg=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=NUrla1d/yIKL5UNtU47SnrIsHIycDrnlRZPhIiDIAufqrvTDWihvejv/hwf8efVog fT89F6bsrIGzpxtPTeoi9CgmUs0V7/NLZ///JgNb8YUhEafZ3ckt4erIpIcj2i7D4X hmmCXmm8S51yLAtQtdlytmCN8plJ8u6+kfOgO/C8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B0A2DF805E7; Thu, 21 Dec 2023 08:41:17 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id ABE4DF805C3; Thu, 21 Dec 2023 08:41:16 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1F6E4F8024E; Thu, 21 Dec 2023 08:37:02 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on20610.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8c::610]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C69B3F8057B for ; Thu, 21 Dec 2023 08:36:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C69B3F8057B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=RIiG0cie ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RtzWD/rK50ghZZK8oR9AK676qsaruKKBrx+iuOJH+NTyzBgVZVl5MbuFywHY87N5d3gnJjYuhyUC2xUG0OXXS6yAqGcOjDV3DGSr0RnPa6TCAiWszvWtoPd57GpGbymK0p8FFG8EAckhriImChJ8/llTI6DtgvurTVmpDz+nIahq2EjhlllSZl/HQBSKPzEQ2mK//1zY7FTh2y0zrf1Fmk4Ax88GTztwigLzQdjs1g/t5eJUN5S3UGWXdqYR1C/KLorIg8ctILIL2FbgGY7YlpvxAzKHiSDVLgAqoudu/VVus0YJz83dJ0rDkgYOZNQ7dqOBMIxD9FhXWWIsK8fRNA== 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=IJivtawyCIrVrea1lU5RWMl9WYBMO7S57Sz2cNATNV8=; b=JABzHpha6WSCr1zmeE4KjX5kBitE3xExdLW7xsIYrf1hRLYrTysGpo8hqQk42p3JssY1/B5VquTdGdDnKyg2NTMEWV96BHu41qvTFmO56Mry9bVYfXil5s1QDCCWy9emE+Lm2oA1fIUvS1bHuCDey6y/72k7FDpZJ6t2KeDE6e7rL3MLEIQ7wY9DHT+Xuzd0ttXniFIA4yY5ypsrV5PZ1Z49dM8uIHsBB5QLR01HmjnKKUknr35fyiQ99emaO9W1dxCZTyDqtE4d46uaOyWYwHJqHQBFhXAziRRRgMYMW9PHLo/Geln4p2uYlnqMyKMOQsJBXqqKJkFAwZyu6Kudyg== 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=IJivtawyCIrVrea1lU5RWMl9WYBMO7S57Sz2cNATNV8=; b=RIiG0cie6WUvuOyUFFWONklkiioqh6Y4i1yfce1x9hnzp1OjcbDRSyzLI9z0G46ZYmfw/koi+wKFvX3O76yxyTw7PXJqCStUjxsmPX0XxilcM/3WIFRwTKk/MxV/s/YfjzIjIPvwhIyE9BKPJYslxLH4wjxR07Xoz4lcmduiD8A= Received: from MW4PR03CA0178.namprd03.prod.outlook.com (2603:10b6:303:8d::33) by DS0PR12MB8501.namprd12.prod.outlook.com (2603:10b6:8:15d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.20; Thu, 21 Dec 2023 07:36:37 +0000 Received: from CO1PEPF000044FA.namprd21.prod.outlook.com (2603:10b6:303:8d:cafe::81) by MW4PR03CA0178.outlook.office365.com (2603:10b6:303:8d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.20 via Frontend Transport; Thu, 21 Dec 2023 07:36:37 +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 CO1PEPF000044FA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:36:37 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.34; Thu, 21 Dec 2023 01:36:36 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.32; Wed, 20 Dec 2023 23:36:36 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:36:33 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Bard Liao , Sanyog Kale , open list Subject: [PATCH 04/12] drivers: soundwire: refactor soundwire pads enable Date: Thu, 21 Dec 2023 13:05:50 +0530 Message-ID: <20231221073558.3181911-5-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FA:EE_|DS0PR12MB8501:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ffba4a4-290b-4d32-bf9b-08dc01f7908e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fZhh7KrVhyKZiFv12ld/b5lW8NoguxCLyh0ahkGc699naxHEyaoijahaYVQU22bSyTZEtNuwZHCxjQqT1SIPTDpbsJYgijswl7JMGqDFPRyV4kp/jLhZ6S/eBjxnjAFrfQFE60noAFiEnvPIWbr6nvXnresDoz7wNHJDndhpnjFPxdJgSAkAmfWP2BLFL0c231AaXyS6NOcYoboes2tcODCx4wGWGZBuB4GNOMNYbLSy42T9pLSnrjOrS8R4KqQ8xW2NHq+G2maLZZgn5SecQG4FJ9rxTrb0oslaGfjNyJD21iNtPLFJ/l6G6hSmx/xeKNIsafCaBXK0+JL1ZibqRJKExZWKYU88SZpULe6zGQ1QI3Hmug5tyONXH65n/W+N/bxUbAfWOy/h/zjwTiYlfFclq5HmLseVgthT+mil7sNaB3dvo8Bsl1W4dvRvHYVuAQ/ciDAS4AKoNNe+x8Y1Gyg9/hr7O1CpXhg6NhZA5f8uoBA7qoPKJMG8GZ89OT48sqsiAqBRZcWN1UqNV/EQvmsCelXkrd7CrStnvRbZAPaovQNauRT3DZWlJXcFN3TRCZDMzwYqWfVTJlK/qM2kW5Xtgel0FqIE7VvKcE+xU8XcyouyAlNsxlNxAH4tPT0FrYLmOcwLs2YLuVVisCbSh9MLyTlT/iQGTv8oWf6+akIgdFHOEol7G8XkGAeii1B9X/A4U7eqgKPS5/zkAhozsRNczKk2T6iQMQx6kN1UprXIEgRZT8OiAc8uo6Ri9P+Z2DdiZJ9/lywrLbTA/kOPlQ== 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)(376002)(39860400002)(136003)(346002)(230922051799003)(82310400011)(1800799012)(186009)(64100799003)(451199024)(36840700001)(46966006)(40470700004)(6666004)(478600001)(54906003)(110136005)(316002)(8676002)(8936002)(70586007)(70206006)(83380400001)(36860700001)(47076005)(7696005)(1076003)(26005)(336012)(426003)(2616005)(41300700001)(2906002)(4326008)(5660300002)(40480700001)(86362001)(36756003)(82740400003)(81166007)(356005)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:36:37.2029 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ffba4a4-290b-4d32-bf9b-08dc01f7908e 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: CO1PEPF000044FA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8501 Message-ID-Hash: WUBA7MU6JHXMULXP557JG4MRXGBYKULW X-Message-ID-Hash: WUBA7MU6JHXMULXP557JG4MRXGBYKULW X-MailFrom: Vijendar.Mukunda@amd.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: As sdw pads enable sequence is executed only once, invoke it from probe sequence. Program required pads for both manager instances based on link_mask during probe sequence. This will avoid acquiring mutex lock. Remove unnecessary delay after programming ACP_SW_PAD_KEEPER_EN register. Signed-off-by: Vijendar Mukunda --- drivers/soundwire/amd_init.c | 45 +++++++++++++++++++++++++++++++++ drivers/soundwire/amd_manager.c | 18 ------------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/drivers/soundwire/amd_init.c b/drivers/soundwire/amd_init.c index 5c9569d9ad01..b3b3c7266384 100644 --- a/drivers/soundwire/amd_init.c +++ b/drivers/soundwire/amd_init.c @@ -15,6 +15,47 @@ #include "amd_init.h" +#define ACP_PAD_PULLDOWN_CTRL 0x0001448 +#define ACP_SW_PAD_KEEPER_EN 0x0001454 +#define AMD_SDW_PAD_PULLDOWN_CTRL_ENABLE_MASK 0x7f9a +#define AMD_SDW0_PAD_PULLDOWN_CTRL_ENABLE_MASK 0x7f9f +#define AMD_SDW1_PAD_PULLDOWN_CTRL_ENABLE_MASK 0x7ffa +#define AMD_SDW0_PAD_EN_MASK 1 +#define AMD_SDW1_PAD_EN_MASK 0x10 +#define AMD_SDW_PAD_EN_MASK (AMD_SDW0_PAD_EN_MASK | AMD_SDW1_PAD_EN_MASK) + +static int amd_enable_sdw_pads(void __iomem *mmio, u32 link_mask, struct device *dev) +{ + u32 val; + u32 pad_keeper_en_mask, pad_pulldown_ctrl_mask; + + switch (link_mask) { + case 1: + pad_keeper_en_mask = AMD_SDW0_PAD_EN_MASK; + pad_pulldown_ctrl_mask = AMD_SDW0_PAD_PULLDOWN_CTRL_ENABLE_MASK; + break; + case 2: + pad_keeper_en_mask = AMD_SDW1_PAD_EN_MASK; + pad_pulldown_ctrl_mask = AMD_SDW1_PAD_PULLDOWN_CTRL_ENABLE_MASK; + break; + case 3: + pad_keeper_en_mask = AMD_SDW_PAD_EN_MASK; + pad_pulldown_ctrl_mask = AMD_SDW_PAD_PULLDOWN_CTRL_ENABLE_MASK; + break; + default: + dev_err(dev, "No SDW Links are enabled\n"); + return -ENODEV; + } + + val = readl(mmio + ACP_SW_PAD_KEEPER_EN); + val |= pad_keeper_en_mask; + writel(val, mmio + ACP_SW_PAD_KEEPER_EN); + val = readl(mmio + ACP_PAD_PULLDOWN_CTRL); + val &= pad_pulldown_ctrl_mask; + writel(val, mmio + ACP_PAD_PULLDOWN_CTRL); + return 0; +} + static int sdw_amd_cleanup(struct sdw_amd_ctx *ctx) { int i; @@ -37,6 +78,7 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) struct platform_device_info pdevinfo[2]; u32 link_mask; int count, index; + int ret; if (!res) return NULL; @@ -50,6 +92,9 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res) count = res->count; dev_dbg(&adev->dev, "Creating %d SDW Link devices\n", count); + ret = amd_enable_sdw_pads(res->mmio_base, res->link_mask, res->parent); + if (ret) + return NULL; /* * we need to alloc/free memory manually and can't use devm: diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c index c27b0b0f33a6..1427cccfc309 100644 --- a/drivers/soundwire/amd_manager.c +++ b/drivers/soundwire/amd_manager.c @@ -26,23 +26,6 @@ #define to_amd_sdw(b) container_of(b, struct amd_sdw_manager, bus) -static void amd_enable_sdw_pads(struct amd_sdw_manager *amd_manager) -{ - u32 sw_pad_pulldown_val; - u32 val; - - mutex_lock(amd_manager->acp_sdw_lock); - val = readl(amd_manager->acp_mmio + ACP_SW_PAD_KEEPER_EN); - val |= amd_manager->reg_mask->sw_pad_enable_mask; - writel(val, amd_manager->acp_mmio + ACP_SW_PAD_KEEPER_EN); - usleep_range(1000, 1500); - - sw_pad_pulldown_val = readl(amd_manager->acp_mmio + ACP_PAD_PULLDOWN_CTRL); - sw_pad_pulldown_val &= amd_manager->reg_mask->sw_pad_pulldown_mask; - writel(sw_pad_pulldown_val, amd_manager->acp_mmio + ACP_PAD_PULLDOWN_CTRL); - mutex_unlock(amd_manager->acp_sdw_lock); -} - static int amd_init_sdw_manager(struct amd_sdw_manager *amd_manager) { u32 val; @@ -872,7 +855,6 @@ int amd_sdw_manager_start(struct amd_sdw_manager *amd_manager) prop = &amd_manager->bus.prop; if (!prop->hw_disabled) { - amd_enable_sdw_pads(amd_manager); ret = amd_init_sdw_manager(amd_manager); if (ret) return ret; From patchwork Thu Dec 21 07:35:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0A05C35274 for ; Thu, 21 Dec 2023 07:42:42 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 88B11DED; Thu, 21 Dec 2023 08:42:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 88B11DED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1703144560; bh=BN4tU62dJl+0242lq1ua8xwJotsC7B+s4ExUp1yyJI4=; h=From:To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=n7bIrONzXPmpJFRM+FiUdEnjM1FYSbCWDQmxq+bl9XheW2p4TZS0XQ1X3VN/1L0y0 McQum8IvtxntZdTVLcPTEIQG8Y+RTLjOZCvoT7K7pqJyn1MRNQuTivJIOZ0ZB0X+tn mlrJMQja0aGrcp/qtZc0DMOxqAayIKH7g2T1dFUI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E43D8F80616; Thu, 21 Dec 2023 08:41:23 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 8A843F80635; Thu, 21 Dec 2023 08:41:22 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DB37FF80425; Thu, 21 Dec 2023 08:37:24 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20600.outbound.protection.outlook.com [IPv6:2a01:111:f403:2009::600]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 528E1F800BD for ; Thu, 21 Dec 2023 08:37:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 528E1F800BD Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=uQWdPyTQ ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O2lD03/uqhzsJSnGwW7F0zyXpBpHUzDXnAQ+sHQw7ikVQzk2almW9f1syp6fLSicML6q+l3d0itD43zUt7ksLErAbSrnJ5FoYjZd3mRrlJawXEqkM3p6VMRodmlXzEQCdVz5/BnUguGOBzrmgkkBGeYBw3ALNfFpRRMOnQV5+nEsYvamlnx/IydhFD3TOOr7XtPR5RQ0ftbkiDYv5LGZmpok4oA9/rYbOvE3ISPGRB/L9GoReo+pw4tqlMeAM4c7nze0fUVeLOKjHVnbyHR8UNvgdvHQxmQt+2DqkbebcZ0CW51SOjjybmYc7ULi4/CeRgbnjGNVUZfwiUIq6Er3ZQ== 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=rQUoh6Ydpzpbpil2mIC9G9IQW2pvBd6dLFDc4nbKJIo=; b=fc798MUCyw+sThWmeLZ6qixQ8FG0CYGEbDvPlx0j0VFSRHRxC99QHjP0jLYPuEBi9TGr0y/WKsnXTk7f57Vt0C81BNVnUzuE4SFDLUASNKsPm0f8DzaVHwgpimTjVnz92EttAHeIwN6InPfXtAojCE8DuaZAPD0qLtFHsdiL+Il2sDFnjnHXtcW40wAEjQxBHja5mALNa+tZK6fDYfOLSv6xZkrnknckrQD+IpdanWW3oWdvzO+KSLBRFYglHOAEh0gp9bNH3DBp2su2XsZdVAIuUrBsKKRC55/OqaADUB4ciBQxdt7HvFJwuhhQN8Z0neRb8TRYOX7enVcndzId0Q== 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=rQUoh6Ydpzpbpil2mIC9G9IQW2pvBd6dLFDc4nbKJIo=; b=uQWdPyTQzHKSNXsYyrab+fQ5qqchSsLsBKQv8wec9KwKuoWjMwuOYYyMWewBmUkZ91CtoXwzwqOYJXbIV/pTrjFstZbnrOC54ao8IJL2s9FGIyQPa+8N59Urh6TTkmHa1MZjbOQI7u5YK1S2Tn9pLxjFq69ZNilUuIoWD1duDvg= Received: from MW4P221CA0017.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::22) by LV8PR12MB9083.namprd12.prod.outlook.com (2603:10b6:408:18c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.20; Thu, 21 Dec 2023 07:37:08 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2603:10b6:303:8b:cafe::43) by MW4P221CA0017.outlook.office365.com (2603:10b6:303:8b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:37: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:37:07 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.34; Thu, 21 Dec 2023 01:37:01 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 21 Dec 2023 01:36:50 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:36:36 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Bard Liao , Sanyog Kale , open list Subject: [PATCH 05/12] drivers: soundwire: refactor register mask structure Date: Thu, 21 Dec 2023 13:05:51 +0530 Message-ID: <20231221073558.3181911-6-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F9:EE_|LV8PR12MB9083:EE_ X-MS-Office365-Filtering-Correlation-Id: 049a6f55-036b-4dc4-2539-08dc01f7a277 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5q+VxYnVHQz4ZNw+WmuIoDcAqHHr6kG/cZwBN/z7+60OfrpzB8eugalKW794ynk5lSvA20WD0AXaQowzWT9ZJFMnvYHlAXp6LkmuaWStVEjmIeb/l+A/4siSEWlf34ICUl5bFcay2RBTOy0riFHBLDEPC4tpUXB+c64imPCr5ItHczKPeUinK+32GfNtFdvWnsugEklzhQm1tePvT9HO9IGtotJCNBs/6TIiUXmLP16SdOXUnPR1VXiOVwSoeAAVJVhAiDer9DTHHvECdlVDsZ2ENlEYSmwQg2tzxUjtlzNZzJRdsRDxn4u4gE1Y1cU69G9CsbtPkDpwkGpubejS+cNQU0nxC8bldRiCw4pxWp7u21UIQ3bYYPxK+WxvB8eCkXNywaLnBzrUFE7t/jjgAyyfk4SWdyjFNfO+Ts4zqc77EsaU3sFq3ZmZ+iBtHXTMnRkCDIEN9UjWFg3OLzigaz9nJG42L6zGzTjhcIsCDQNoZhYK1J19dgxy+IPJMVIzQEcnk+CT1mlDmNU1+o0yL/gPCThQ9ji+Tpg2FOtK4Sg+nyg1ywwSv06fJY/u2FBXygUZ99b8K8zq5qOAjgcYy81OszL7g46V4KnFShVvGQbbGL9aaNJxxnCdPWvmMdEirqMf/ptAB6rvm0tpHRkBd+MYVVCcSm3lxzc1EQ0+9gi4lhluwbbQh9Pn/kZnDfOVQzAv5v0DepIM8eiSJ6GoH+FdImWqJ4J/BihhsaqPRdUhIhbYl5LuCPGPbTKkpU7kRYmRdwsAcOS4bFmVfC0VtSQzvglHNw5shzqYQQxMYScxV7QkAHmXSsLQ5dNd4N5H 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)(376002)(39860400002)(136003)(346002)(230273577357003)(230922051799003)(230173577357003)(82310400011)(1800799012)(186009)(64100799003)(451199024)(36840700001)(46966006)(40470700004)(6666004)(478600001)(54906003)(110136005)(316002)(8676002)(8936002)(70586007)(70206006)(83380400001)(36860700001)(47076005)(7696005)(1076003)(26005)(336012)(426003)(2616005)(41300700001)(2906002)(4326008)(5660300002)(40480700001)(86362001)(36756003)(82740400003)(81166007)(356005)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:37:07.2472 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 049a6f55-036b-4dc4-2539-08dc01f7a277 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: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9083 Message-ID-Hash: VQPBBNNRYAZXOJZUBJNLNCAFZFQX6Q3F X-Message-ID-Hash: VQPBBNNRYAZXOJZUBJNLNCAFZFQX6Q3F X-MailFrom: Vijendar.Mukunda@amd.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: register mask array structure is no longer needed as except interrupt control masks, rest of the register masks are not used in code. use array for interrupt masks instead of structure. Signed-off-by: Vijendar Mukunda --- drivers/soundwire/amd_manager.c | 7 ++----- drivers/soundwire/amd_manager.h | 12 ++---------- include/linux/soundwire/sdw_amd.h | 8 -------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c index 1427cccfc309..36dab5099989 100644 --- a/drivers/soundwire/amd_manager.c +++ b/drivers/soundwire/amd_manager.c @@ -86,12 +86,11 @@ static int amd_disable_sdw_manager(struct amd_sdw_manager *amd_manager) static void amd_enable_sdw_interrupts(struct amd_sdw_manager *amd_manager) { - struct sdw_manager_reg_mask *reg_mask = amd_manager->reg_mask; u32 val; mutex_lock(amd_manager->acp_sdw_lock); val = readl(amd_manager->acp_mmio + ACP_EXTERNAL_INTR_CNTL(amd_manager->instance)); - val |= reg_mask->acp_sdw_intr_mask; + val |= sdw_manager_reg_mask_array[amd_manager->instance]; writel(val, amd_manager->acp_mmio + ACP_EXTERNAL_INTR_CNTL(amd_manager->instance)); mutex_unlock(amd_manager->acp_sdw_lock); @@ -104,12 +103,11 @@ static void amd_enable_sdw_interrupts(struct amd_sdw_manager *amd_manager) static void amd_disable_sdw_interrupts(struct amd_sdw_manager *amd_manager) { - struct sdw_manager_reg_mask *reg_mask = amd_manager->reg_mask; u32 val; mutex_lock(amd_manager->acp_sdw_lock); val = readl(amd_manager->acp_mmio + ACP_EXTERNAL_INTR_CNTL(amd_manager->instance)); - val &= ~reg_mask->acp_sdw_intr_mask; + val &= ~sdw_manager_reg_mask_array[amd_manager->instance]; writel(val, amd_manager->acp_mmio + ACP_EXTERNAL_INTR_CNTL(amd_manager->instance)); mutex_unlock(amd_manager->acp_sdw_lock); @@ -922,7 +920,6 @@ static int amd_sdw_manager_probe(struct platform_device *pdev) return -EINVAL; } - amd_manager->reg_mask = &sdw_manager_reg_mask_array[amd_manager->instance]; params = &amd_manager->bus.params; params->max_dr_freq = AMD_SDW_DEFAULT_CLK_FREQ * 2; params->curr_dr_freq = AMD_SDW_DEFAULT_CLK_FREQ * 2; diff --git a/drivers/soundwire/amd_manager.h b/drivers/soundwire/amd_manager.h index 5f040151a259..82c3183ab215 100644 --- a/drivers/soundwire/amd_manager.h +++ b/drivers/soundwire/amd_manager.h @@ -243,16 +243,8 @@ static struct sdw_manager_dp_reg sdw1_manager_dp_reg[AMD_SDW1_MAX_DAI] = { ACP_SW_AUDIO1_RX_OFFSET, ACP_SW_AUDIO1_RX_CHANNEL_ENABLE_DP0} }; -static struct sdw_manager_reg_mask sdw_manager_reg_mask_array[2] = { - { - AMD_SDW0_PAD_KEEPER_EN_MASK, - AMD_SDW0_PAD_PULLDOWN_CTRL_ENABLE_MASK, - AMD_SDW0_EXT_INTR_MASK - }, - { - AMD_SDW1_PAD_KEEPER_EN_MASK, - AMD_SDW1_PAD_PULLDOWN_CTRL_ENABLE_MASK, +static u32 sdw_manager_reg_mask_array[AMD_SDW_MAX_MANAGER_COUNT] = { + AMD_SDW0_EXT_INTR_MASK, AMD_SDW1_EXT_INTR_MASK - } }; #endif diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h index 47b6cea356ff..56dab6fc9d3a 100644 --- a/include/linux/soundwire/sdw_amd.h +++ b/include/linux/soundwire/sdw_amd.h @@ -34,12 +34,6 @@ struct acp_sdw_pdata { struct mutex *acp_sdw_lock; }; -struct sdw_manager_reg_mask { - u32 sw_pad_enable_mask; - u32 sw_pad_pulldown_mask; - u32 acp_sdw_intr_mask; -}; - /** * struct sdw_amd_dai_runtime: AMD sdw dai runtime data * @@ -61,7 +55,6 @@ struct sdw_amd_dai_runtime { * @dev: linux device * @mmio: SoundWire registers mmio base * @acp_mmio: acp registers mmio base - * @reg_mask: register mask structure per manager instance * @amd_sdw_irq_thread: SoundWire manager irq workqueue * @amd_sdw_work: peripheral status work queue * @acp_sdw_lock: mutex to protect acp share register access @@ -84,7 +77,6 @@ struct amd_sdw_manager { void __iomem *mmio; void __iomem *acp_mmio; - struct sdw_manager_reg_mask *reg_mask; struct work_struct amd_sdw_irq_thread; struct work_struct amd_sdw_work; /* mutex to protect acp common register access */ From patchwork Thu Dec 21 07:35:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501263 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.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 B49D4156F4; Thu, 21 Dec 2023 07:37:12 +0000 (UTC) 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="qbDmbI1P" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D4ZynnNxe3S5IW0N+2X4YAkw0qJ5AOA9HFMIgPErfEzxmpHudjkDk/V9SR87thhsAzyfzKc1PpiviHOIgjcHvCe85ttoTv0SRdcmweghjFb+GsWahK0ELdX8FIFR2UtDIvtmLqaCQjiEtLh0LJtu6wka4upsHg6cG2lS8DU+nKbOtqg1CNA+/VQcYE3pKUpkwbzmxS9svKvMlCjbkR1tcleOZBeGb9TllwY1RL4dOIBO6UYDoNUl1vHkG8B2blBeuuHhu8FHPZxzS4kkS6NoWCFyAiqCY0rnxi2j+6JsQl77jPxSMhkEQ7+LhvRLk9lTS+LZuyVM7U8VzTd0C4aykw== 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=1zC5WRwtu6+qO+9CXnFzJPWrGYlpkczne7vfVG5jg8k=; b=QyU0OT3n1NI2ljX24auyS0cIE4UtY9zSBhs7oJWmCgDTHtKjxm4EV75exYCc0PYifXwWMaXL8NsPFrQX6Cg97y3bEAxtK88smXPryn6inR3XrTB7tLgTsCn8rf8xDGY7wL0QX11AVsd9MjrPPLbUfRRAQDyQ8bBoQ45cHRtJElSIVBLcSk87NO+vp4eSJGAZdxGt1FsnvBOICVXmgzzSngg7GD++zC+Djw298mddS62HSiNFZLg1VoFvwhjdbXuFePQnlmLFhk/j/CNwf7x+au0gAwxl5TrVsJ9f2po20nbagHE3rfpZmX22RmejMvdYLefGr0EOkEQ39Uyg9+dv6Q== 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=1zC5WRwtu6+qO+9CXnFzJPWrGYlpkczne7vfVG5jg8k=; b=qbDmbI1PcKJn+0wEM0tjVs9bUF2d17Y6d2QZGx+4Zp1RVJ2kaCqeWPn1JbHCaEraxYjvdB8dr+uh6JLn7Q67OvHblLHnskEA1WSNbtBTf6YzbgJtZoSCJjCprfYwrjFuojQk+SVU3Ms7GZVCDZw+kYcTxkWKT8bpo2T8kkl48X0= Received: from MW4P221CA0011.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::16) by CYXPR12MB9441.namprd12.prod.outlook.com (2603:10b6:930:dc::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.21; Thu, 21 Dec 2023 07:37:10 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2603:10b6:303:8b:cafe::af) by MW4P221CA0011.outlook.office365.com (2603:10b6:303:8b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:37:09 +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 CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:37:09 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.34; Thu, 21 Dec 2023 01:37:06 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:37:00 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Liam Girdwood , "Peter Ujfalusi" , Bard Liao , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , V sujith kumar Reddy , Mastan Katragadda , Rander Wang , "moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS" , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [PATCH 06/12] ASoC: SOF: amd: add code for invoking soundwire manager helper functions Date: Thu, 21 Dec 2023 13:05:52 +0530 Message-ID: <20231221073558.3181911-7-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F9:EE_|CYXPR12MB9441:EE_ X-MS-Office365-Filtering-Correlation-Id: be8c48d1-3219-47e4-2744-08dc01f7a3fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XXhC2YtbLZzv4semc72s98UUNH9rwA10zDLk2S1VZLKopXlU3T8iSM4vQFyf4Q3kTExowrHkP4FLMzJ2JAjO+y+3CS1rhIJbG0NDAm7cTEFkapkvJ71JLemlj4/6lDE9WwmwFpoBZvVhYAKNTnsiC4GNeAk9OrVUxSJpgjjOGLRVoMb51ADO3Dz0LSu9WjUIwGW6zCdFCvMcqHi0dEeb7I0YQCAzE4QLBuCRASDxU6h/vKaDZIS8rtQsPfAFlN9br+accJBqgey5qiHB3ggzS6an7E0EQq324TBq09eak+Cc6sR9O5IK6WLhaItS/6XIQS6bl8m9BqN+j3CGssd7WB+pF0QOCfUOWl+au7/t6ZuGY8E3Z8lhj8X6PEUS2KI45QS2ckYFHb3dWFqudGWw44MeqoAEmaKsScE1P9LbS4qgaYgBlMyrgOq7AxpZjM6mDXpj/1G4R0zAXLM3NL5QJt0UH1dmC25UuL0mM2nMrnNKDlkNFa6nKg83P3jgXhFpnTN3b4+cMQyz895fvKbyMRoW6fyH2oQ0Q1lkFD47ku8ZfXGfkvoOdFjB15l9Vqw+wWj53ttILqQCm6DpgBIC2mi3pMAXVdRSha5eopwgv3jkf28c1UneCvhmvV7OAhIgy/I5F8qw1eiXLA+/3g5IQimAcU3jEW5ll97sW5EBVw6qL3nEtLSLSDz2tSez9tzo2r4d6WT9nSQw9Rho0pPTmNdXSWK2wlC0yATpkyegAuK7MbCEHlUUD3XgfNweCz8iXru9zFcwF1FsWe2oY7Rkfw== 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)(39860400002)(396003)(346002)(230922051799003)(186009)(451199024)(1800799012)(82310400011)(64100799003)(46966006)(40470700004)(36840700001)(1076003)(2616005)(7696005)(426003)(336012)(83380400001)(26005)(86362001)(4326008)(8676002)(8936002)(41300700001)(2906002)(5660300002)(36756003)(7416002)(110136005)(70586007)(316002)(54906003)(70206006)(6666004)(478600001)(47076005)(81166007)(36860700001)(40480700001)(82740400003)(356005)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:37:09.8097 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be8c48d1-3219-47e4-2744-08dc01f7a3fe 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: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR12MB9441 Add code for invoking Soundwire manager helper functions when SoundWire configuration is selected. Signed-off-by: Vijendar Mukunda --- sound/soc/sof/amd/Kconfig | 17 +++++++ sound/soc/sof/amd/acp.c | 99 ++++++++++++++++++++++++++++++++++++++- sound/soc/sof/amd/acp.h | 15 +++++- 3 files changed, 129 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/amd/Kconfig b/sound/soc/sof/amd/Kconfig index 19c5e27a193f..1cea1d75130c 100644 --- a/sound/soc/sof/amd/Kconfig +++ b/sound/soc/sof/amd/Kconfig @@ -60,6 +60,23 @@ config SND_SOC_SOF_ACP_PROBES This option is not user-selectable but automatically handled by 'select' statements at a higher level +config SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE + tristate + select SOUNDWIRE_AMD if SND_SOC_SOF_AMD_SOUNDWIRE != n + select SND_AMD_SOUNDWIRE_ACPI if ACPI + +config SND_SOC_SOF_AMD_SOUNDWIRE + tristate "SOF support for SoundWire based AMD platforms" + default SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE + depends on SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE + depends on ACPI && SOUNDWIRE + depends on !(SOUNDWIRE=m && SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE=y) + help + This adds support for SoundWire with Sound Open Firmware + for AMD platforms. + Say Y if you want to enable SoundWire links with SOF. + If unsure select "N". + config SND_SOC_SOF_AMD_ACP63 tristate "SOF support for ACP6.3 platform" depends on SND_SOC_SOF_PCI diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c index 32a741fcb84f..f24cd6b7490f 100644 --- a/sound/soc/sof/amd/acp.c +++ b/sound/soc/sof/amd/acp.c @@ -491,6 +491,81 @@ int amd_sof_acp_resume(struct snd_sof_dev *sdev) } EXPORT_SYMBOL_NS(amd_sof_acp_resume, SND_SOC_SOF_AMD_COMMON); +#if IS_ENABLED(CONFIG_SND_SOC_SOF_AMD_SOUNDWIRE) +static int acp_sof_scan_sdw_devices(struct snd_sof_dev *sdev, u64 addr) +{ + struct acpi_device *sdw_dev; + struct acp_dev_data *acp_data; + const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata); + + if (!addr) + return -ENODEV; + + acp_data = sdev->pdata->hw_pdata; + sdw_dev = acpi_find_child_device(ACPI_COMPANION(sdev->dev), addr, 0); + if (!sdw_dev) + return -ENODEV; + + acp_data->info.handle = sdw_dev->handle; + acp_data->info.count = desc->sdw_max_link_count; + + return amd_sdw_scan_controller(&acp_data->info); +} + +static int amd_sof_sdw_probe(struct snd_sof_dev *sdev) +{ + struct acp_dev_data *acp_data; + struct sdw_amd_res sdw_res; + int ret; + + acp_data = sdev->pdata->hw_pdata; + + 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 = sdev->dev; + sdw_res.dev = sdev->dev; + sdw_res.acp_lock = &acp_data->acp_lock; + sdw_res.count = acp_data->info.count; + sdw_res.link_mask = acp_data->info.link_mask; + sdw_res.mmio_base = sdev->bar[ACP_DSP_BAR]; + + ret = sdw_amd_probe(&sdw_res, &acp_data->sdw); + if (ret) + dev_err(sdev->dev, "SoundWire probe failed\n"); + return ret; +} + +static int amd_sof_sdw_exit(struct snd_sof_dev *sdev) +{ + struct acp_dev_data *acp_data; + + acp_data = sdev->pdata->hw_pdata; + if (acp_data->sdw) + sdw_amd_exit(acp_data->sdw); + acp_data->sdw = NULL; + + return 0; +} + +#else +static int acp_sof_scan_sdw_devices(struct snd_sof_dev *sdev, u64 addr) +{ + return 0; +} + +static int amd_sof_sdw_probe(struct snd_sof_dev *sdev) +{ + return 0; +} + +static int amd_sof_sdw_exit(struct snd_sof_dev *sdev) +{ + return 0; +} +#endif + int amd_sof_acp_probe(struct snd_sof_dev *sdev) { struct pci_dev *pci = to_pci_dev(sdev->dev); @@ -527,7 +602,9 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) } pci_set_master(pci); - + adata->addr = addr; + adata->reg_range = chip->reg_end_addr - chip->reg_start_addr; + mutex_init(&adata->acp_lock); sdev->pdata->hw_pdata = adata; adata->smn_dev = pci_get_device(PCI_VENDOR_ID_AMD, chip->host_bridge_id, NULL); if (!adata->smn_dev) { @@ -549,6 +626,21 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) if (ret < 0) goto free_ipc_irq; + /* scan SoundWire capabilities exposed by DSDT */ + ret = acp_sof_scan_sdw_devices(sdev, chip->sdw_acpi_dev_addr); + if (ret < 0) { + dev_dbg(sdev->dev, "skipping SoundWire, not detected with ACPI scan\n"); + goto skip_soundwire; + } + ret = amd_sof_sdw_probe(sdev); + if (ret < 0) { + dev_err(sdev->dev, "error: SoundWire probe error\n"); + free_irq(sdev->ipc_irq, sdev); + pci_dev_put(adata->smn_dev); + return ret; + } + +skip_soundwire: sdev->dsp_box.offset = 0; sdev->dsp_box.size = BOX_SIZE_512; @@ -596,6 +688,9 @@ void amd_sof_acp_remove(struct snd_sof_dev *sdev) if (adata->smn_dev) pci_dev_put(adata->smn_dev); + if (adata->sdw) + amd_sof_sdw_exit(sdev); + if (sdev->ipc_irq) free_irq(sdev->ipc_irq, sdev); @@ -607,4 +702,6 @@ void amd_sof_acp_remove(struct snd_sof_dev *sdev) EXPORT_SYMBOL_NS(amd_sof_acp_remove, SND_SOC_SOF_AMD_COMMON); MODULE_DESCRIPTION("AMD ACP sof driver"); +MODULE_IMPORT_NS(SOUNDWIRE_AMD_INIT); +MODULE_IMPORT_NS(SND_AMD_SOUNDWIRE_ACPI); MODULE_LICENSE("Dual BSD/GPL"); diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index c645aee216fd..e88d01330ec7 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -12,7 +12,7 @@ #define __SOF_AMD_ACP_H #include - +#include #include "../sof-priv.h" #include "../sof-audio.h" @@ -191,6 +191,10 @@ struct sof_amd_acp_desc { u32 acp_clkmux_sel; u32 fusion_dsp_offset; u32 probe_reg_offset; + u32 reg_start_addr; + u32 reg_end_addr; + u32 sdw_max_link_count; + u64 sdw_acpi_dev_addr; }; /* Common device data struct for ACP devices */ @@ -199,6 +203,12 @@ struct acp_dev_data { const struct firmware *fw_dbin; /* DMIC device */ struct platform_device *dmic_dev; + /* mutex lock to protect ACP common registers access */ + struct mutex acp_lock; + /* ACPI information stored between scan and probe steps */ + struct sdw_amd_acpi_info info; + /* sdw context allocated by SoundWire driver */ + struct sdw_amd_ctx *sdw; unsigned int fw_bin_size; unsigned int fw_data_bin_size; unsigned int fw_sram_data_bin_size; @@ -207,6 +217,9 @@ struct acp_dev_data { const char *fw_sram_data_bin; u32 fw_bin_page_count; u32 fw_data_bin_page_count; + u32 addr; + u32 reg_range; + u32 blk_type; dma_addr_t sha_dma_addr; u8 *bin_buf; dma_addr_t dma_addr; From patchwork Thu Dec 21 07:35:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501264 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2086.outbound.protection.outlook.com [40.107.237.86]) (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 C9E4325552; Thu, 21 Dec 2023 07:37:28 +0000 (UTC) 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="K+8wJO1O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=idGDYvN6OGOKgNwecAwd3YURusAQB5arKr41X4M33yWvXAh9815RzahL/6rPGuk90cRXKpHNbXL7P/9is1vJq9Sd+GVt4PR6n7NIBcnE0YBZgymtpzTgFmjeeBvZkYq8srz7gpnQciN6fCxHjV/+qQ7UFmpWA1jTw8Gxrp8Fg6SShLqitqZlJzsY6kmWM8xRURIMsZFzMazviOoFGOQq/+9d/qVSFdqqiLWXsvWjBq+MRsha3W9Q6m+K6FhMIr4hHhMjUKaZmrHx1ex29gmN/JE+T3v3Y94tSS5oEgn1TgcRjtVu+BmnUsY59Vd3k+W5j3WkE2xC0Hzj0VPszloF2Q== 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=WmSvbdZheoMbrfrMOra1kGeyoKcwdWWrtw+v++Bk0J8=; b=T7NqL3SJ5SRE6KTcC39eXGslEJvClsp171bxlkw1pQMxDvY01wC5km6KrvfsSrfxSiEtb9LRTf7d3mXfYh3auDtYRhsk5dYEvB41szAFJVDmYQiGLBlyNEoZfAspNi5I+65dXjY0GOaeSV8D8CvWwUFO7YuMY5mKRe88dgJyIGXD07edC7m4N+5NC4xCWokBzMIWnd5gDnVUymZmqt+GygwluvkYWpWF4wkgdPWJnsoZQEfdIxyJxA8eSYnXh3EdGtJj+YPGCKxEKRKgtuShRC7+TGo17KY79yXQ+XV22vRa6Lg9X7zxb8pwrcNi82n/YiOy3/15OlmuYGBpuBRT5w== 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=WmSvbdZheoMbrfrMOra1kGeyoKcwdWWrtw+v++Bk0J8=; b=K+8wJO1OoQ/qPeQo4cFFZLO/naJcWEc6Zz4r+6Ye/Q7KTahYmpCqAJCnRtfQp2vCDa82SAOpdioDrEeHikT78sdzHFFE4Xclb3R+roU/7FFNx1AgUwSmZtwM7mnjTlaia59SonxT/BeXvAVJZ0zgWpzDG5At3CWq/382t7P+nl0= Received: from CYZPR14CA0020.namprd14.prod.outlook.com (2603:10b6:930:8f::25) by SJ2PR12MB9210.namprd12.prod.outlook.com (2603:10b6:a03:561::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18; Thu, 21 Dec 2023 07:37:23 +0000 Received: from CY4PEPF0000EE3E.namprd03.prod.outlook.com (2603:10b6:930:8f:cafe::9f) by CYZPR14CA0020.outlook.office365.com (2603:10b6:930:8f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.20 via Frontend Transport; Thu, 21 Dec 2023 07:37:23 +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 CY4PEPF0000EE3E.mail.protection.outlook.com (10.167.242.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Thu, 21 Dec 2023 07:37:22 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.34; Thu, 21 Dec 2023 01:37:22 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 21 Dec 2023 01:37:21 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:37:16 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Liam Girdwood , "Peter Ujfalusi" , Bard Liao , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , V sujith kumar Reddy , Mastan Katragadda , Rander Wang , "moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS" , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [PATCH 07/12] ASoC: SOF: amd: add interrupt handling for SoundWire manager devices Date: Thu, 21 Dec 2023 13:05:53 +0530 Message-ID: <20231221073558.3181911-8-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3E:EE_|SJ2PR12MB9210:EE_ X-MS-Office365-Filtering-Correlation-Id: c6e70158-ac61-4326-ad05-08dc01f7abb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TkAvHtYrVg4CMoGUe4gEz1kdzBfAI7Tz99qjoDP8AN/aOcwofVw7oyvwGuP/vlQricW+FnYBROh6F8LEFtSzrD6S0CW5q8qr/LDEfuIXaUWnWsboh8j3ZXlKO3KsyJeEnA4koA8laQjot6INjWrPESx0XB1Sm8MX5SiKTelSteN0HwSKZo3nall+xxnjVD9aK7mw2Da/6kyDvXTnx5ReUELYzu5jeIAmSKltfjDa6PBexEyw9bnsIBqOQoYbUSWQcc6YfQ0zTTzyMjrtR6g/1ZxAKg86eDqjDUiCbFxDMEX5pc8k6e9ekvLW88iosz6fgnqAbcZ5eeYxGxxH8d7zWDg722928EHqpHU4itQPKhqXtuCelL2/O6AjsMZQa+rq+v1AFAGmUDze0bMDsFE9LSH0KsB0dHpFK1cRTKozbMRzVdH/4rxa9ddb89ae2+SuWJ3hilvRmQgXCnv/2bGllmekZ/RH0JGnQUdTpngO4Et7ExT27UjDcwN6a8aOAukBaai0Ml9s0HPcGGhoBMD3Ni2PXPzYt2KQBeOuuVAG2wylitHy4NurRPa9p2lIK4xl2s7X2AIGY2aHd+zoKVMWqbeUNuohx9aN3P2lDAm4xEzz9FFf5bkC6JsUfXn4t3B8H4WsTorU+BKOositpXtbeW1ROivdsQUP8Bbj1/B69l9I4pcEAknPwuywz02yh2pRs5W/IR6Q/IX/ci8V0iKC8TBkMQxWNFAvki+ggcSUn9C9ZvTXhBDTNB/xvL3z0GFHRU0u/+OPiiD+PdQ6DfHM9w== 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)(64100799003)(82310400011)(451199024)(186009)(36840700001)(46966006)(40470700004)(40480700001)(36756003)(40460700003)(1076003)(26005)(7416002)(8676002)(8936002)(2616005)(7696005)(478600001)(54906003)(70206006)(6666004)(2906002)(110136005)(316002)(47076005)(336012)(36860700001)(4326008)(41300700001)(5660300002)(83380400001)(426003)(81166007)(86362001)(70586007)(356005)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:37:22.8230 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6e70158-ac61-4326-ad05-08dc01f7abb8 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: CY4PEPF0000EE3E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9210 Add support for interrupt handling for soundwire manager platform devices. Signed-off-by: Vijendar Mukunda --- sound/soc/sof/amd/acp-dsp-offset.h | 4 ++++ sound/soc/sof/amd/acp.c | 38 +++++++++++++++++++++++++++++- sound/soc/sof/amd/acp.h | 5 ++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/amd/acp-dsp-offset.h b/sound/soc/sof/amd/acp-dsp-offset.h index a913f1cc4c80..7ba6492b8e99 100644 --- a/sound/soc/sof/amd/acp-dsp-offset.h +++ b/sound/soc/sof/amd/acp-dsp-offset.h @@ -78,6 +78,10 @@ #define ACP5X_AXI2DAGB_SEM_0 0x1884 #define ACP6X_AXI2DAGB_SEM_0 0x1874 +/* ACP common registers to report errors related to I2S & SoundWire interfaces */ +#define ACP_SW0_I2S_ERROR_REASON 0x18B4 +#define ACP_SW1_I2S_ERROR_REASON 0x1A50 + /* Registers from ACP_SHA block */ #define ACP_SHA_DSP_FW_QUALIFIER 0x1C70 #define ACP_SHA_DMA_CMD 0x1CB0 diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c index f24cd6b7490f..7a34faae9889 100644 --- a/sound/soc/sof/amd/acp.c +++ b/sound/soc/sof/amd/acp.c @@ -375,10 +375,13 @@ static irqreturn_t acp_irq_thread(int irq, void *context) static irqreturn_t acp_irq_handler(int irq, void *dev_id) { + struct amd_sdw_manager *amd_manager; struct snd_sof_dev *sdev = dev_id; const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata); + struct acp_dev_data *adata = sdev->pdata->hw_pdata; unsigned int base = desc->dsp_intr_base; unsigned int val; + int irq_flag = 0; val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, base + DSP_SW_INTR_STAT_OFFSET); if (val & ACP_DSP_TO_HOST_IRQ) { @@ -387,7 +390,38 @@ static irqreturn_t acp_irq_handler(int irq, void *dev_id) return IRQ_WAKE_THREAD; } - return IRQ_NONE; + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, desc->ext_intr_stat); + if (val & ACP_SDW0_IRQ_MASK) { + amd_manager = dev_get_drvdata(&adata->sdw->pdev[0]->dev); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, desc->ext_intr_stat, ACP_SDW0_IRQ_MASK); + if (amd_manager) + schedule_work(&amd_manager->amd_sdw_irq_thread); + irq_flag = 1; + } + + if (val & ACP_ERROR_IRQ_MASK) { + snd_sof_dsp_write(sdev, ACP_DSP_BAR, desc->ext_intr_stat, ACP_ERROR_IRQ_MASK); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, base + ACP_SW0_I2S_ERROR_REASON, 0); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, base + ACP_SW1_I2S_ERROR_REASON, 0); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, base + ACP_ERROR_STATUS, 0); + irq_flag = 1; + } + + if (desc->ext_intr_stat1) { + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, desc->ext_intr_stat1); + if (val & ACP_SDW1_IRQ_MASK) { + amd_manager = dev_get_drvdata(&adata->sdw->pdev[1]->dev); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, desc->ext_intr_stat1, + ACP_SDW1_IRQ_MASK); + if (amd_manager) + schedule_work(&amd_manager->amd_sdw_irq_thread); + irq_flag = 1; + } + } + if (irq_flag) + return IRQ_HANDLED; + else + return IRQ_NONE; } static int acp_power_on(struct snd_sof_dev *sdev) @@ -443,6 +477,8 @@ static int acp_reset(struct snd_sof_dev *sdev) if (desc->ext_intr_enb) snd_sof_dsp_write(sdev, ACP_DSP_BAR, desc->ext_intr_enb, 0x01); + if (desc->ext_intr_cntl) + snd_sof_dsp_write(sdev, ACP_DSP_BAR, desc->ext_intr_cntl, ACP_ERROR_IRQ_MASK); return ret; } diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index e88d01330ec7..2058dae32659 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -93,6 +93,9 @@ #define PROBE_STATUS_BIT BIT(31) #define ACP_FIRMWARE_SIGNATURE 0x100 +#define ACP_ERROR_IRQ_MASK BIT(29) +#define ACP_SDW0_IRQ_MASK BIT(21) +#define ACP_SDW1_IRQ_MASK BIT(2) #define ACP_DEFAULT_SRAM_LENGTH 0x00080000 #define ACP_SRAM_PAGE_COUNT 128 @@ -184,7 +187,9 @@ struct sof_amd_acp_desc { unsigned int host_bridge_id; u32 pgfsm_base; u32 ext_intr_enb; + u32 ext_intr_cntl; u32 ext_intr_stat; + u32 ext_intr_stat1; u32 dsp_intr_base; u32 sram_pte_offset; u32 hw_semaphore_offset; From patchwork Thu Dec 21 07:35:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501265 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) (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 C45732CCD5; Thu, 21 Dec 2023 07:37:35 +0000 (UTC) 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="SMmWoVT2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E9f2AtxDNlVZTJU1GyH2xXLp2TWOEYu6Qv7SFwNO1iLil2OBNOGhJytWgDF5S7e+NNQ5JlRYB7JzuixiTir8HGIDgTYifMEFm0MYKyTAPHFj3dsF0TcGa+U3CCjDDDFZh07OYIavCcmQSxtDTkGA11MtI2PVfTy8lc9owiTEGBF3S34vrveXax9GzgMIilKYh7SoeYI+VIOs5Ds4YWu9iNsdlTr7OnL2O/P5oXAFiiucOFvYORARC3La/P8hzHed4mYhcMcJwW1NwtMmgbEL15wzXv7Pw3JEq4870BZv3Ml/8O99cNvQoSeHQy09DidB/Pr1h+HFd+y16SnnnTGmHA== 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=iPqL8D8sIUEJdIE9QqRF4FLGLmz9V6QPJ3PtGhXMEUs=; b=oJHAVPvU7U5mNGqokA5Mi9p7/6Q2Rj5Ajgau3+gzzsJP50/fDRFF5AG68MQ6YvGkABeDBnaIFxu6ODZxdoG7pcGoSuozduJsvaMZR8mKj5GUimb+QQuTnMMXUSHl6VlOAbb09Z2NjNSm5h/GpEQ9aIqCSIwH1b8+QPjb6LC19H1OfI/chyA62w+FtZmdyjrwqW4PhrKfFMc2EkAysKSZFo0WzTL6BttbwWCKbi1IP8QaJpBV6Uo8nCyPj3GXIF7MJOaqo1nDHCrJ9Y2roDgVmZQz0xa3+X8E9SyPGV1OPOh+blEo5TL/IO74LjthUR8M5G3Th58slfZC5HdPdeQBIw== 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=iPqL8D8sIUEJdIE9QqRF4FLGLmz9V6QPJ3PtGhXMEUs=; b=SMmWoVT2nz1EOPyvm4KEOF64A03ERPiH83csBJmZ3bGkKBdpqSauuxbZmy0DYE2DbEjbqjHntCMp5WkIk024mezR4F+T9Ae6/fSqduWFy78wbjJcNb/7DQ8snNyDkkehlI0yhL7rd6+BfpTTFxH7N//hgrUs4Gv749EFNkeLHWk= Received: from MW4P223CA0013.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::18) by CYYPR12MB8891.namprd12.prod.outlook.com (2603:10b6:930:c0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.38; Thu, 21 Dec 2023 07:37:33 +0000 Received: from CO1PEPF000044F8.namprd21.prod.outlook.com (2603:10b6:303:80:cafe::84) 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.7113.20 via Frontend Transport; Thu, 21 Dec 2023 07:37:32 +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 CO1PEPF000044F8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:37:32 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.34; Thu, 21 Dec 2023 01:37:31 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.32; Wed, 20 Dec 2023 23:37:31 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:37:25 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Liam Girdwood , "Jaroslav Kysela" , Takashi Iwai , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Rander Wang , Jyri Sarha , Curtis Malainey , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list , "moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS" Subject: [PATCH 08/12] ASoC: SOF: amd: Add Soundwire DAI configuration support for AMD platforms Date: Thu, 21 Dec 2023 13:05:54 +0530 Message-ID: <20231221073558.3181911-9-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F8:EE_|CYYPR12MB8891:EE_ X-MS-Office365-Filtering-Correlation-Id: c11d4c3e-4c01-46c2-c138-08dc01f7b166 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zl3+WeUYdqYcvWqlZLKjEB5JdV8IE4CnI7ulcaqb6wo4tuKz6lTEVYyWOoQIimAWTcNGr14nEO6N5RFLzQZQfWAfJcYXOn8yyvgUI4uiPLqFrSD5QHrKZ2U3thuoivGikUcJbqcqhjSms/MfZi9uyoPhkMtBZPFG2i+E4dJd2FY6ynw3NbHXUXmet9tmEIku9rni3QlK2Eprv2V6y3yBDFRE9gu/TTq0ES3V/1XoZY8wp04u+A36Wu1j5KcbqiDumP0yDD24IUkudiimUSwNM1qxRJi1Y3yrPJ/FMH+/sdr6riljSKrF/MrDqSjGeWV3MLyxY4SJ4B3F9/WGWi7LOutQb2YlDdCH3PgxDjAmWGYnh8sE0pFbcGt2MLSuhJGfU3gitLU4RqUmwRiMxXiIlDJZOn4+dSHAWDKGuu2HouMdMiDy7eQeyKAkNvG2mn/aRm1Gl4jZk3SiUd3J+Hsr+CJZCQxMOzl8BlzlmKAhY8Qtg7wHrP5uT1f3T14DDviz8y/Sm6id2m8OnRnxWkPRHTngx8rs7a5Gpc9x40mqEBZAMKXkCul1Y4OcM9EnqSl2hkxZLf/iWHdNF6PWNkocG9adURG4HysSJMASyiEyCjb3IhUEMChtiSFbTNrtqYz16Z7joYfcIJNVqjtv6e7Ka8j0QD//m0X4MvcZjBySI9PESvinCSBAfGfJxw0Q8fP4WAwmpDJETqFsEhry5nrhnEvf3QJE1hFte4u3oSM8RGtmx3HwdYNg324Hl8vZHiAkSZrkcG1llQHZalaY2vU2ow== 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)(346002)(376002)(136003)(39860400002)(396003)(230922051799003)(82310400011)(451199024)(64100799003)(1800799012)(186009)(36840700001)(46966006)(40470700004)(40480700001)(40460700003)(336012)(1076003)(7696005)(6666004)(426003)(2616005)(26005)(82740400003)(83380400001)(81166007)(356005)(2906002)(86362001)(36756003)(41300700001)(36860700001)(8936002)(110136005)(8676002)(5660300002)(47076005)(7416002)(4326008)(478600001)(70206006)(54906003)(70586007)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:37:32.2900 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c11d4c3e-4c01-46c2-c138-08dc01f7b166 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: CO1PEPF000044F8.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8891 Add support for configuring AMD Soundwire DAI from topology. Signed-off-by: Vijendar Mukunda --- include/sound/sof/dai-amd.h | 7 ++++++ include/sound/sof/dai.h | 2 ++ include/uapi/sound/sof/tokens.h | 4 ++++ sound/soc/sof/ipc3-pcm.c | 25 +++++++++++++++++++++ sound/soc/sof/ipc3-topology.c | 40 +++++++++++++++++++++++++++++++++ sound/soc/sof/sof-audio.h | 1 + sound/soc/sof/topology.c | 5 +++++ 7 files changed, 84 insertions(+) diff --git a/include/sound/sof/dai-amd.h b/include/sound/sof/dai-amd.h index 9df7ac824efe..59cd014392c1 100644 --- a/include/sound/sof/dai-amd.h +++ b/include/sound/sof/dai-amd.h @@ -26,4 +26,11 @@ struct sof_ipc_dai_acpdmic_params { uint32_t pdm_ch; } __packed; +/* ACP_SDW Configuration Request - SOF_IPC_DAI_AMD_SDW_CONFIG */ +struct sof_ipc_dai_acp_sdw_params { + struct sof_ipc_hdr hdr; + u32 rate; + u32 channels; +} __packed; + #endif diff --git a/include/sound/sof/dai.h b/include/sound/sof/dai.h index 4773a5f616a4..0764a80c17a9 100644 --- a/include/sound/sof/dai.h +++ b/include/sound/sof/dai.h @@ -89,6 +89,7 @@ enum sof_ipc_dai_type { SOF_DAI_AMD_SP_VIRTUAL, /**< AMD ACP SP VIRTUAL */ SOF_DAI_AMD_HS_VIRTUAL, /**< AMD ACP HS VIRTUAL */ SOF_DAI_IMX_MICFIL, /** < i.MX MICFIL PDM */ + SOF_DAI_AMD_SDW, /**< AMD ACP SDW */ }; /* general purpose DAI configuration */ @@ -119,6 +120,7 @@ struct sof_ipc_dai_config { struct sof_ipc_dai_acp_params acphs; struct sof_ipc_dai_mtk_afe_params afe; struct sof_ipc_dai_micfil_params micfil; + struct sof_ipc_dai_acp_sdw_params acp_sdw; }; } __packed; diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h index ee5708934614..6bf00c09d30d 100644 --- a/include/uapi/sound/sof/tokens.h +++ b/include/uapi/sound/sof/tokens.h @@ -218,4 +218,8 @@ #define SOF_TKN_IMX_MICFIL_RATE 2000 #define SOF_TKN_IMX_MICFIL_CH 2001 +/* ACP SDW */ +#define SOF_TKN_AMD_ACP_SDW_RATE 2100 +#define SOF_TKN_AMD_ACP_SDW_CH 2101 + #endif diff --git a/sound/soc/sof/ipc3-pcm.c b/sound/soc/sof/ipc3-pcm.c index 330f04bcd75d..35769dd7905e 100644 --- a/sound/soc/sof/ipc3-pcm.c +++ b/sound/soc/sof/ipc3-pcm.c @@ -395,6 +395,31 @@ static int sof_ipc3_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, dev_dbg(component->dev, "MICFIL PDM channels_min: %d channels_max: %d\n", channels->min, channels->max); break; + case SOF_DAI_AMD_SDW: + /* change the default trigger sequence as per HW implementation */ + for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) { + struct snd_soc_pcm_runtime *fe = dpcm->fe; + + fe->dai_link->trigger[SNDRV_PCM_STREAM_PLAYBACK] = + SND_SOC_DPCM_TRIGGER_POST; + } + + for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) { + struct snd_soc_pcm_runtime *fe = dpcm->fe; + + fe->dai_link->trigger[SNDRV_PCM_STREAM_CAPTURE] = + SND_SOC_DPCM_TRIGGER_POST; + } + rate->min = private->dai_config->acp_sdw.rate; + rate->max = private->dai_config->acp_sdw.rate; + channels->min = private->dai_config->acp_sdw.channels; + channels->max = private->dai_config->acp_sdw.channels; + + dev_dbg(component->dev, + "AMD_SDW rate_min: %d rate_max: %d\n", rate->min, rate->max); + dev_dbg(component->dev, "AMD_SDW channels_min: %d channels_max: %d\n", + channels->min, channels->max); + break; default: dev_err(component->dev, "Invalid DAI type %d\n", private->dai_config->type); break; diff --git a/sound/soc/sof/ipc3-topology.c b/sound/soc/sof/ipc3-topology.c index a8832a1c1a24..0970dbdfa78a 100644 --- a/sound/soc/sof/ipc3-topology.c +++ b/sound/soc/sof/ipc3-topology.c @@ -298,6 +298,14 @@ static const struct sof_topology_token micfil_pdm_tokens[] = { offsetof(struct sof_ipc_dai_micfil_params, pdm_ch)}, }; +/* ACP_SDW */ +static const struct sof_topology_token acp_sdw_tokens[] = { + {SOF_TKN_AMD_ACP_SDW_RATE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, + offsetof(struct sof_ipc_dai_acp_sdw_params, rate)}, + {SOF_TKN_AMD_ACP_SDW_CH, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, + offsetof(struct sof_ipc_dai_acp_sdw_params, channels)}, +}; + /* Core tokens */ static const struct sof_topology_token core_tokens[] = { {SOF_TKN_COMP_CORE_ID, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, @@ -336,6 +344,7 @@ static const struct sof_token_info ipc3_token_list[SOF_TOKEN_COUNT] = { [SOF_ACPI2S_TOKENS] = {"ACPI2S tokens", acpi2s_tokens, ARRAY_SIZE(acpi2s_tokens)}, [SOF_MICFIL_TOKENS] = {"MICFIL PDM tokens", micfil_pdm_tokens, ARRAY_SIZE(micfil_pdm_tokens)}, + [SOF_ACP_SDW_TOKENS] = {"ACP_SDW tokens", acp_sdw_tokens, ARRAY_SIZE(acp_sdw_tokens)}, }; /** @@ -1315,6 +1324,34 @@ static int sof_link_acp_hs_load(struct snd_soc_component *scomp, struct snd_sof_ return 0; } +static int sof_link_acp_sdw_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink, + struct sof_ipc_dai_config *config, struct snd_sof_dai *dai) +{ + struct sof_dai_private_data *private = dai->private; + u32 size = sizeof(*config); + int ret; + + /* parse the required set of ACP_SDW tokens based on num_hw_cfgs */ + ret = sof_update_ipc_object(scomp, &config->acp_sdw, SOF_ACP_SDW_TOKENS, slink->tuples, + slink->num_tuples, size, slink->num_hw_configs); + if (ret < 0) + return ret; + + /* init IPC */ + config->hdr.size = size; + dev_dbg(scomp->dev, "ACP SDW config rate %d channels %d\n", + config->acp_sdw.rate, config->acp_sdw.channels); + + /* set config for all DAI's with name matching the link name */ + dai->number_configs = 1; + dai->current_config = 0; + private->dai_config = kmemdup(config, size, GFP_KERNEL); + if (!private->dai_config) + return -ENOMEM; + + return 0; +} + static int sof_link_afe_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink, struct sof_ipc_dai_config *config, struct snd_sof_dai *dai) { @@ -1629,6 +1666,9 @@ static int sof_ipc3_widget_setup_comp_dai(struct snd_sof_widget *swidget) case SOF_DAI_MEDIATEK_AFE: ret = sof_link_afe_load(scomp, slink, config, dai); break; + case SOF_DAI_AMD_SDW: + ret = sof_link_acp_sdw_load(scomp, slink, config, dai); + break; default: break; } diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 8874ee5f557f..f98242a404db 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -276,6 +276,7 @@ enum sof_tokens { SOF_ACPDMIC_TOKENS, SOF_ACPI2S_TOKENS, SOF_MICFIL_TOKENS, + SOF_ACP_SDW_TOKENS, /* this should be the last */ SOF_TOKEN_COUNT, diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 617a225fff24..25fb0d1443b6 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -297,6 +297,7 @@ static const struct sof_dai_types sof_dais[] = { {"ACPSP_VIRTUAL", SOF_DAI_AMD_SP_VIRTUAL}, {"ACPHS_VIRTUAL", SOF_DAI_AMD_HS_VIRTUAL}, {"MICFIL", SOF_DAI_IMX_MICFIL}, + {"ACP_SDW", SOF_DAI_AMD_SDW}, }; @@ -1968,6 +1969,10 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, struct snd_ token_id = SOF_MICFIL_TOKENS; num_tuples += token_list[SOF_MICFIL_TOKENS].count; break; + case SOF_DAI_AMD_SDW: + token_id = SOF_ACP_SDW_TOKENS; + num_tuples += token_list[SOF_ACP_SDW_TOKENS].count; + break; default: break; } From patchwork Thu Dec 21 07:35:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501278 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2054.outbound.protection.outlook.com [40.107.102.54]) (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 D5E46156CE; Thu, 21 Dec 2023 07:37:46 +0000 (UTC) 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="CKcfAvLa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d7PO54kfXFup4K8kfvqkOjltFEBAzCUgY6k1fPHnSDo6gMpMjoTiOibYXTFEViE/g1Io5rG0CoCWsgsRPIB5pfNkdevLKBgub/gK0ucpYdMP1LPeslwUUCfQNNPwKEYMKCQpb9ngCYO7YwMtBZ07xU9Jizi5WajhMW2ROdtf/EoZ4JJYfZ7hR4210cdMDc1rpXDJSP3tFQPsWFp6bbA1ZMoxDW9vWUsixg0j5h91pjmwFI5zpcHiM+g8RXPgoPYXBXLe8f6m5t0+yWDG8Y4vyFQt1h/df3XxbtzA2dAeTV71cJwCd95szmpx5K0GAxyL4Yf5KakaRZztEvSdabbqOQ== 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=+omCGRhppcTZgY3hpYmOov+emvix6/ZrChbQ00XGnbg=; b=R/v9OYooEy1XnRKrY44Z47gUJpITtULC7N4U1hgfdUER1KP4+5/RaRSdnAK5BA1JAimxBla8eordDz8/BUa432OoEeRi242XnhqFXlaMJV1BcaSWhCx07FBEMMOB0uHmLPX/lME7T8BNh+STdLVHyWeb3WqCINubwebqrLiHCzGAHfw5tHLhYm7nnPlQZfMPU9VVlaNK3diIlB2Gi+oOr8eDzQbncBcPEZsB0FTjuKez+MR/cuJlHAOgJWw26xDjtQFp0kGO57FgFqWgDXTr7w34foNHR0UIWEy5aB4bCTfGvUe9xj2ydcZ6XV4yqB7G9oVqfQjPAp6wmmN52EnkZA== 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=+omCGRhppcTZgY3hpYmOov+emvix6/ZrChbQ00XGnbg=; b=CKcfAvLaSwpXm2IH4Rgh+sYisr4QR988HRbRqSfTqWPo2ji13BV0N0/9MoDZRLQsSziAAE4CwVX2GpYoeFKr2n2LDFwNXKSexLM+I8QFZ/BZBt23o+tqao/zjGA2AfLCIMbQkfz0RNUpFbWVUoGl2OC7STfojmFu9jadWfq4aKQ= Received: from MW4PR03CA0196.namprd03.prod.outlook.com (2603:10b6:303:b8::21) by PH7PR12MB6666.namprd12.prod.outlook.com (2603:10b6:510:1a8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18; Thu, 21 Dec 2023 07:37:41 +0000 Received: from CO1PEPF000044F7.namprd21.prod.outlook.com (2603:10b6:303:b8:cafe::e) by MW4PR03CA0196.outlook.office365.com (2603:10b6:303:b8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:37:41 +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 CO1PEPF000044F7.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.18 via Frontend Transport; Thu, 21 Dec 2023 07:37:41 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.34; Thu, 21 Dec 2023 01:37:40 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:37:34 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Liam Girdwood , "Peter Ujfalusi" , Bard Liao , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , V sujith kumar Reddy , Wang Jinchao , "moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS" , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [PATCH 09/12] ASoC: SOF: amd: add machine select logic for soundwire based platforms Date: Thu, 21 Dec 2023 13:05:55 +0530 Message-ID: <20231221073558.3181911-10-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F7:EE_|PH7PR12MB6666:EE_ X-MS-Office365-Filtering-Correlation-Id: c5c2faf2-435d-4f80-4e64-08dc01f7b6a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gKf+Zl+StYnmutEYoiNIJ+8OK8APXOOhKbLYqqO9056yazzUbuILCOJSCfUcvH2w+SQxoHf07W5rdJECoxK7Z+RcQTc1LMp5hV9HwkRX3u/6p7BbwcCr3cSFGKZbFvcSVP5NadPMcjWLLAangJOeM+jdwJfcEHeYf9F7CQpsbEbHpR6XRtE3KK+n45mbViXpmEqktS8/T+ps0FNLs9Ew+hFzOoZxkPN0bkXgq0GNdgS2Ave/9/0xTR+zulP9B81oWbg4CoAHK2Zbzoxf+jd4wtgij+ofM3fyOZFoSyA0WJFS0PuxixQpbm7jdjYacMtlZOx30SGjVABeHUd2P8bfB2zX5Q5PDZ88wtfDNdEZ+t1Ed0MKkCeBFRW+DwX7Wkb1bcFxoSomaZmNVU0HOsAifXBpJ/rfPlpFfnVu7b13Sume9oe2eWd2rpVxmjCb7Zx2QX6ceb3hNjh28xwEF7RbXpnseFdTVai0YcXtl/EAutZBJTc4fDylZfp0gEmxBeyg9z/+wQ3qbZ5HCgtFI/733SmWn4aA77YdLm8dmLkWWPFVPY/0mSHzuOQmscBXsFvHwLFTo/WdXlirwtH5a8YzNCNnc4Abtxfz1a4GTWNjBHyX25E3eWPSmcpiYuMHm0d7xaknjvaqaMUdiZzQKkEcOdVIbisko6W9PR5k8tuVLZxldrtnzdbDzqFNNVkdADqBWnlwg1WhKifI1VERX8nn9VpWpxCLiMGkd0ILAdeiKosAQUw5OF5FoCS0DotPmntfXRL0Lf7ROqhB2BCI5DgsKg== 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)(39860400002)(136003)(396003)(346002)(376002)(230922051799003)(82310400011)(186009)(1800799012)(64100799003)(451199024)(46966006)(40470700004)(36840700001)(5660300002)(40480700001)(7416002)(8936002)(8676002)(4326008)(2906002)(316002)(54906003)(40460700003)(70586007)(70206006)(110136005)(478600001)(36860700001)(36756003)(47076005)(41300700001)(6666004)(426003)(26005)(336012)(1076003)(2616005)(7696005)(86362001)(81166007)(82740400003)(356005)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:37:41.1147 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5c2faf2-435d-4f80-4e64-08dc01f7b6a9 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: CO1PEPF000044F7.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6666 Add machine select logic for soundwire endpoints for AMD platforms. Signed-off-by: Vijendar Mukunda --- sound/soc/sof/amd/acp-common.c | 65 +++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/sound/soc/sof/amd/acp-common.c b/sound/soc/sof/amd/acp-common.c index 2d72c6d55dc8..0fc4e20ec673 100644 --- a/sound/soc/sof/amd/acp-common.c +++ b/sound/soc/sof/amd/acp-common.c @@ -118,16 +118,72 @@ void amd_sof_dump(struct snd_sof_dev *sdev, u32 flags) &panic_info, stack, AMD_STACK_DUMP_SIZE); } +#if IS_ENABLED(CONFIG_SND_SOC_SOF_AMD_SOUNDWIRE) +static int amd_sof_sdw_get_slave_info(struct snd_sof_dev *sdev) +{ + struct acp_dev_data *acp_data = sdev->pdata->hw_pdata; + + return sdw_amd_get_slave_info(acp_data->sdw); +} + +static struct snd_soc_acpi_mach *amd_sof_sdw_machine_select(struct snd_sof_dev *sdev) +{ + struct snd_soc_acpi_mach *mach; + const struct snd_soc_acpi_link_adr *link; + struct acp_dev_data *acp_data = sdev->pdata->hw_pdata; + int ret, i; + + if (acp_data->info.count) { + ret = amd_sof_sdw_get_slave_info(sdev); + if (ret) { + dev_info(sdev->dev, "failed to read slave information\n"); + return NULL; + } + for (mach = sdev->pdata->desc->alt_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(sdev->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; + mach->mach_params.platform = dev_name(sdev->dev); + return mach; + } + } + dev_info(sdev->dev, "No SoundWire machine driver found\n"); + return NULL; +} + +#else +static struct snd_soc_acpi_mach *amd_sof_sdw_machine_select(struct snd_sof_dev *sdev) +{ + return NULL; +} +#endif + struct snd_soc_acpi_mach *amd_sof_machine_select(struct snd_sof_dev *sdev) { struct snd_sof_pdata *sof_pdata = sdev->pdata; const struct sof_dev_desc *desc = sof_pdata->desc; - struct snd_soc_acpi_mach *mach; + struct snd_soc_acpi_mach *mach = NULL; - mach = snd_soc_acpi_find_machine(desc->machines); + if (desc->machines) + mach = snd_soc_acpi_find_machine(desc->machines); if (!mach) { - dev_warn(sdev->dev, "No matching ASoC machine driver found\n"); - return NULL; + mach = amd_sof_sdw_machine_select(sdev); + if (!mach) { + dev_warn(sdev->dev, "No matching ASoC machine driver found\n"); + return NULL; + } } sof_pdata->tplg_filename = mach->sof_tplg_filename; @@ -204,5 +260,6 @@ EXPORT_SYMBOL_NS(sof_acp_common_ops, SND_SOC_SOF_AMD_COMMON); MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON); MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA); +MODULE_IMPORT_NS(SOUNDWIRE_AMD_INIT); MODULE_DESCRIPTION("ACP SOF COMMON Driver"); MODULE_LICENSE("Dual BSD/GPL"); From patchwork Thu Dec 21 07:35:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501279 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2083.outbound.protection.outlook.com [40.107.220.83]) (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 A58D9446A2; Thu, 21 Dec 2023 07:38:03 +0000 (UTC) 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="aIB8VC8E" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JtSm4O9WNekSyKL60PjQqIeOjuy6JX65pw2k9doB5Ik85u8IHTYPWLeepPEUcT0qCopBpFs9sUa4+B3cZ0AptoWqTugO2+KryZBVHcuzDPNCtWN9vmBYiHxovapDdXlggddVU2xtAAqZ9y24qG5yWKDBqkKzu3OhQYgWWQaSu4CA9WLtNbVLa9hxyHU3HBsav2zwUL+CMlzxBaal5m50Orw5rtol/2qqFJERXu71KEP7hnyGSZmIwayPppZwU6rYZyAC7dNCK8G3X3QtxHwGxinBaNYhUtGnZFFm29mN38lQBL8vDLVS8VmOZPkawQCWpH5uVd3BMaTdzChle+1nUw== 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=jtvoCZz8VSf1VRSZDCxvonKGlPrjlVR/2Z+SSopunkg=; b=SE8MEU31jUowFh0ahUYPPluhWpKF3frH+mnUJL7LzUiZgQAQwQ4bna0qe8QprmuzTVGnunwb77cqNf5ou2cies3EHnRULk39ZnDHMmM08Mr+mo/8l6rF3WYOwcIEaxE6ApQQiz0Vib2nGF6+PvSIarRl2NhdG+YR56UV4zc3j+BB6WAl7NxvF3sq6ghSt7x96DY14XY//BR+MUwta76e+psM0O84hl6bKHvqlFmvo5UI7kSV3gzCJ3DkNQPFLsosqwip3OwJST4gIa6AODTh6oDCAM6nhKcUPFJHS8olCVTB3muKquQjJv9f41UvIxXJ5MePg+8Xy1hzqLguith+Vw== 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=jtvoCZz8VSf1VRSZDCxvonKGlPrjlVR/2Z+SSopunkg=; b=aIB8VC8Exjp8qTFU7tOL8tZ7ItNPAlYa8qn+gONbvmeCG6ZEhLmwdRoIR+tdDeVmrFfxxKNCfvpc82qf1eXtpt09jaVmiCpluBk8Xo6GfVSYTqbMFh8aDxPCY3sxxUsfEJUXUJhf1oc7XQtVVe3rsdLzbKmfR8vIOo6yJ5sObFQ= Received: from CY8P220CA0028.NAMP220.PROD.OUTLOOK.COM (2603:10b6:930:47::12) by CH3PR12MB7738.namprd12.prod.outlook.com (2603:10b6:610:14e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.21; Thu, 21 Dec 2023 07:37:59 +0000 Received: from CY4PEPF0000FCC0.namprd03.prod.outlook.com (2603:10b6:930:47:cafe::99) by CY8P220CA0028.outlook.office365.com (2603:10b6:930:47::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.20 via Frontend Transport; Thu, 21 Dec 2023 07:37:59 +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 CY4PEPF0000FCC0.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.20 via Frontend Transport; Thu, 21 Dec 2023 07:37:59 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.34; Thu, 21 Dec 2023 01:37:57 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 21 Dec 2023 01:37:57 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:37:51 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Liam Girdwood , "Peter Ujfalusi" , Bard Liao , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , V sujith kumar Reddy , Mastan Katragadda , Rander Wang , "moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS" , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [PATCH 10/12] ASoC: SOF: amd: update descriptor fields for acp6.3 based platform Date: Thu, 21 Dec 2023 13:05:56 +0530 Message-ID: <20231221073558.3181911-11-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC0:EE_|CH3PR12MB7738:EE_ X-MS-Office365-Filtering-Correlation-Id: fa26796d-d5ae-405a-a296-08dc01f7c164 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z79PAJLc0vkq6lpUnf+yT6OVMZrIVAlalyNPxwv8M6t2oFB0bGInnONV0fjbwltQ07Trbbw5CW9stSt7JcjpOtPKvb7lTVE/sRhlSOkpO57VtIdSPc6mggjuE0pgaB2BZph1fda1XQus1Y7TIRtHIo4tGxv07jdv2WVLVTM2d14U+0TbfOVrUwalTE6JsmBFUVTODQmFIJVv2fvEvpV/03EwGlkgnj01YxJuVG8VKoJYm3z9Xb9a5hOt/bKdJo3uXD7Lwzp28R6EcnZH5Z6KMRtaILncVJKNjPcwFCDFmXewsisM9fjFkYAcalwLvm8YpvML9YA+/t7Kmm0jGMIPcLpteT3sQbu4xweL06JwU7n1nv2UWaS4IR4HGQhAHhU1D0KhbwVE3RIpKFjiUTRgBOLg4VDs30kD2pFbmlRHmAboxzHroaTCJb9u4bjhgyGx3y5SwxeoLvNi9qVZDNmyyMbWgU50hXvJtXkyKBDlombRACznQYwd3nwOD+5dySFejWE84WCUEcC8V5RQluFiriSTfGUkHcPNiMjKAEBZSJi2G0tAGqpoIGdHd/MIfGnb+ARrdlcakYjGJhqH7Mv46d/OVT6kX9IPTK8tBnWsUdK2kXq0xz1NJmISE98UIIh976cZACcjbN3L8PCbkOafyL8NzJBORmyjuZZ5XFZRiy0DiPYifZiRIMC9uzZHZfSrR/qtTsKl1rvwnoa9KFomO/cQq667jtc3H+iFEUEoziepIIW3ODWCR9CbDKF9WL4VY4YFWSsG6F6LanQY00DbBalLf0v7LVzK4FHe4sN9VcN00PBOanxKttWi5Zyh/wy9 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)(39860400002)(346002)(136003)(396003)(376002)(230922051799003)(230173577357003)(230273577357003)(1800799012)(186009)(82310400011)(451199024)(64100799003)(36840700001)(40470700004)(46966006)(70586007)(70206006)(110136005)(1076003)(54906003)(26005)(2616005)(40480700001)(36860700001)(40460700003)(478600001)(83380400001)(8676002)(4326008)(8936002)(316002)(336012)(426003)(7696005)(36756003)(15650500001)(7416002)(47076005)(5660300002)(2906002)(356005)(81166007)(82740400003)(41300700001)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:37:59.1978 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa26796d-d5ae-405a-a296-08dc01f7c164 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: CY4PEPF0000FCC0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7738 Update acp descriptor fields for acp6.3 version based platform. Signed-off-by: Vijendar Mukunda --- sound/soc/sof/amd/acp-dsp-offset.h | 3 +++ sound/soc/sof/amd/acp.h | 2 ++ sound/soc/sof/amd/pci-acp63.c | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/sound/soc/sof/amd/acp-dsp-offset.h b/sound/soc/sof/amd/acp-dsp-offset.h index 7ba6492b8e99..c1bdc028a61a 100644 --- a/sound/soc/sof/amd/acp-dsp-offset.h +++ b/sound/soc/sof/amd/acp-dsp-offset.h @@ -65,7 +65,10 @@ /* Registers from ACP_INTR block */ #define ACP3X_EXT_INTR_STAT 0x1808 #define ACP5X_EXT_INTR_STAT 0x1808 +#define ACP6X_EXTERNAL_INTR_ENB 0x1A00 +#define ACP6X_EXTERNAL_INTR_CNTL 0x1A04 #define ACP6X_EXT_INTR_STAT 0x1A0C +#define ACP6X_EXT_INTR_STAT1 0x1A10 #define ACP3X_DSP_SW_INTR_BASE 0x1814 #define ACP5X_DSP_SW_INTR_BASE 0x1814 diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index 2058dae32659..e94713d7ff1d 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -96,8 +96,10 @@ #define ACP_ERROR_IRQ_MASK BIT(29) #define ACP_SDW0_IRQ_MASK BIT(21) #define ACP_SDW1_IRQ_MASK BIT(2) +#define SDW_ACPI_ADDR_ACP63 5 #define ACP_DEFAULT_SRAM_LENGTH 0x00080000 #define ACP_SRAM_PAGE_COUNT 128 +#define ACP6X_SDW_MAX_MANAGER_COUNT 2 enum clock_source { ACP_CLOCK_96M = 0, diff --git a/sound/soc/sof/amd/pci-acp63.c b/sound/soc/sof/amd/pci-acp63.c index bceb94ac80a9..eeaa12cceb23 100644 --- a/sound/soc/sof/amd/pci-acp63.c +++ b/sound/soc/sof/amd/pci-acp63.c @@ -31,12 +31,19 @@ static const struct sof_amd_acp_desc acp63_chip_info = { .rev = 6, .host_bridge_id = HOST_BRIDGE_ACP63, .pgfsm_base = ACP6X_PGFSM_BASE, + .ext_intr_enb = ACP6X_EXTERNAL_INTR_ENB, + .ext_intr_cntl = ACP6X_EXTERNAL_INTR_CNTL, .ext_intr_stat = ACP6X_EXT_INTR_STAT, + .ext_intr_stat1 = ACP6X_EXT_INTR_STAT1, .dsp_intr_base = ACP6X_DSP_SW_INTR_BASE, .sram_pte_offset = ACP6X_SRAM_PTE_OFFSET, .hw_semaphore_offset = ACP6X_AXI2DAGB_SEM_0, .fusion_dsp_offset = ACP6X_DSP_FUSION_RUNSTALL, .probe_reg_offset = ACP6X_FUTURE_REG_ACLK_0, + .sdw_max_link_count = ACP6X_SDW_MAX_MANAGER_COUNT, + .sdw_acpi_dev_addr = SDW_ACPI_ADDR_ACP63, + .reg_start_addr = ACP6x_REG_START, + .reg_end_addr = ACP6x_REG_END, }; static const struct sof_dev_desc acp63_desc = { From patchwork Thu Dec 21 07:35:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501280 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.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 75EF3433DE; Thu, 21 Dec 2023 07:38:09 +0000 (UTC) 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="LSs13XA/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CA+GaS5+aTJqcWJMX9pmP318S+9JT8cH+ztmhmgwi96xR6KfHldIolyT9uO4aXZJKUw4R+PX6xHiRxsCTnBJSyLQc50EkcjpelHoGdnWr73IcDW1KifmDXC5ui583BJf6Ymw234b6EIShqtKdYCcOLm7Z0C/aCv50Ll71FCSwKl5LDq6Sr0FLOAAjn267HXLdIYm65xUHUJsGghmpgLMjZgUAu1TUxGInB2U/ekLGLkRCocajVbWg/0cLNaMlfCmk5YhnTkU77je93SOqBtKv7s80HpKIrPE0lQ0EFw7xWAl5xUH/DC/wU1i74XLvT5Hr/LDEzA5Xx7Ixur857QhiQ== 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=TM5IfcLFOV5I+4SsS+sfeBeWW0qVpPfMyKw8GVqZb7k=; b=Bs4rpIjyEhEGze6fHZG0rnwGOjSJGwud5PzfefpYOK3yzPDttMK3Jy3vLhLge3dvJw0blMAOZw57DpxLK8WRmGlF6TRXjajxklaO3+7m0pPev1gj3hziY45P4vCyZwLLwTFDXlizqsu4QI4D48PhGG3q0SFEjUv0joUmLGIV9zN67AzcwX5D+J2LBflI4ffOiu4c18GAlw+MxNKcRNKqpmC3aEQnLNBaT52mDfWPoEg/bthSqv3LJpv4hQzXH4M3ecDJlr7X40cieX+buDIT6ocIuLUSZQlE+TAnfE/4AmT7V/rwRJC8vgvG/Oy3jh6cZ0oiynq8/9uQ4BULH7BRzg== 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=TM5IfcLFOV5I+4SsS+sfeBeWW0qVpPfMyKw8GVqZb7k=; b=LSs13XA/YNABkdYHFn2KAYm07HypxBxM/23MELayuvz1xqB5CHT9AOmqsE3ohkyxlVD5ovHsino+YIOf4lhFOdSX9VxbL7S/5ql0+SuU9gjF4Gq1H/OzK/G9wF+u012z7CzufmIGGdW26xoxINGXLusAhbz9zwspr0xFCQrFEy4= Received: from SA9P221CA0001.NAMP221.PROD.OUTLOOK.COM (2603:10b6:806:25::6) by DM4PR12MB5117.namprd12.prod.outlook.com (2603:10b6:5:390::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18; Thu, 21 Dec 2023 07:38:06 +0000 Received: from SN1PEPF0002BA51.namprd03.prod.outlook.com (2603:10b6:806:25:cafe::50) by SA9P221CA0001.outlook.office365.com (2603:10b6:806:25::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.20 via Frontend Transport; Thu, 21 Dec 2023 07:38:06 +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 SN1PEPF0002BA51.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Thu, 21 Dec 2023 07:38:06 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.34; Thu, 21 Dec 2023 01:38:06 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:38:00 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Liam Girdwood , "Peter Ujfalusi" , Bard Liao , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , V sujith kumar Reddy , "moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS" , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , "open list" Subject: [PATCH 11/12] ASoC: SOF: amd: select soundwire dependency flag for acp6.3 based platform Date: Thu, 21 Dec 2023 13:05:57 +0530 Message-ID: <20231221073558.3181911-12-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA51:EE_|DM4PR12MB5117:EE_ X-MS-Office365-Filtering-Correlation-Id: d811e0d1-b37b-4c79-ac3a-08dc01f7c5b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L16iV3L2uvGjc8YnrXcA1Mav1SszGu57GFfLCue8k93x/Eu5n5G83uXxhob70nbISPHvX6PCwiMmFa69od6BetNsQIvLWbrhcvGfO3464IpugtX1RBld2yMhNDyA+laBLM/Db7r33Q+FsFy9NOQPCAT2qlen4AWnyxtMVo4fxrjfUvjbWHc34KzBlZzf8kGQHbPdayYqOVNiA++UnrWuChm8rIbD0D6KwDhuvwyHpFfaQmEKld7upKOvNVgGzum94i9HkiniPqJl3Kiz60st3V6frLhRcuTVSVx/Ct18WyNBCWq23Gzhb04W7psdYJXUDbXc4gMJ+qQCHhQ3unR90Y3EKKm4m76hDHryq7fwQMEmQ8IiaCkvlow1r1vo8vN3330edDedSaoRSutaS9+CC+ufT+HJQ0JTqrUS+pO735E2giqJYnTzT36DRdggSOpBGe3/Qt+RbHWGe7k9JoeG+hU6BM7R/Tl/0Frmklmk6J8OuT72U8OgZJHr7gHD/3YiD5qvX1F32tzL31TXAdiCbLQKKqlmB0g31a2lKbXbGLhDh6Qox3B4nRu/P/DEi1pm+0/gZI7OznKXj28EkIc6OQ9BzfRzyVbVJhUYB3LCOXBMHF6u1NOT5qjHoJ0n5YU7n600yyA0sj4k82eynnRRtKuaWETuQPNmU0EGI10IR2ZhoErq0Jf6OSeh0VpD9ZPR6UVx6xx3oqVx8EQWRhMzT2vnzwbxXK58m2iU9jTckTJ7vZuZpyvTqKBfCS4JkfsLMdvvSS2WlKvz5FN4pTFNBA== 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)(39860400002)(396003)(346002)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(82310400011)(40470700004)(46966006)(36840700001)(478600001)(110136005)(70586007)(70206006)(316002)(6666004)(82740400003)(356005)(81166007)(36756003)(41300700001)(86362001)(7696005)(1076003)(26005)(4326008)(5660300002)(336012)(426003)(36860700001)(7416002)(2616005)(8936002)(4744005)(47076005)(54906003)(2906002)(8676002)(40480700001)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:38:06.4579 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d811e0d1-b37b-4c79-ac3a-08dc01f7c5b3 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: SN1PEPF0002BA51.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5117 Select SoundWire dependency flag for acp6.3 based platform for SoundWire configuration. Signed-off-by: Vijendar Mukunda --- sound/soc/sof/amd/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/sof/amd/Kconfig b/sound/soc/sof/amd/Kconfig index 1cea1d75130c..c3bbe6c70fb2 100644 --- a/sound/soc/sof/amd/Kconfig +++ b/sound/soc/sof/amd/Kconfig @@ -81,6 +81,7 @@ config SND_SOC_SOF_AMD_ACP63 tristate "SOF support for ACP6.3 platform" depends on SND_SOC_SOF_PCI select SND_SOC_SOF_AMD_COMMON + select SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE help Select this option for SOF support on AMD ACP6.3 version based platforms. From patchwork Thu Dec 21 07:35:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13501281 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2083.outbound.protection.outlook.com [40.107.101.83]) (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 13820495F3; Thu, 21 Dec 2023 07:38:25 +0000 (UTC) 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="vp7j2qne" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mNRU3n3DIwfwp/K8eiWUyCDAdf1mvyhWesEJWpqoLwAayDWy9KAXZFFjwN/5u69Rtw3NogHa7q8jX+LR8/YTBqI2xpSFxzOGhgVWsy47/rOkDzpy1N3LfhGivMHhZsTqdK5IfFL4qYY5MnTSNHDaJVjrSqOSzplssYPcb3U9Rz7xoZwNJa3N+yxSQTMeDx6mefjOHpULRi3jbIA2z3Am/pKDekKer1rfQ597ojD7ZNUu4rlObP2DHocC5TRkV4YkkVTWgynqX1sxRAbZxxqv+FsIpU6BwCyJuCl2TAcjzcjBSh6M7DUhk4P4BvYBKR0FQgOEG76EMyRHWQ0omU6c/Q== 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=UhoVkhy8GN1PdZmnmv/uRV5zVwbIdlO+MnLOz/NKjrs=; b=g0HAc+en8V7zxRIzS9eWHmcqKlQx9RFCG+PTo9ApkfZsaUIRN4h0vrOK9zbGbMv8sK4HWC1PvLp2rIo9UXPW2698HAf/fqw6C+5jMXJ2x9ozTf9GJS55fjDN2HpV/xPIPj+XNlkCyOVSc9fb1JCclp6QE7zMq+ovSRKaqQmTzw8i5ejnc2Pnke8ABCF/LOXpwducRjKPEZHxd/O33GZ/kGs3kg+UbT6OhZS3Zdaz4a4LRLxmWXbReoRW3UT58WorcXrvbTnNrSIT500SkE/0J+lby9+zkfO7E0FwsJYmx74fBXFrwbG8L8s+v+QpHOuCEY5KGkVog9H9K1Ty21hDkg== 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=UhoVkhy8GN1PdZmnmv/uRV5zVwbIdlO+MnLOz/NKjrs=; b=vp7j2qne5fRNAJEaHDJ4iVnxeg1e55AUhZ2s00Rbhystfdni6lVLHgl+9sllGzyrCIpGWwcDmpWTwzCUKlLHJn0eJbY2f7d5FNN5nli36tHtXF57L+2DwNuMCnC29WCcCWxX0CTr5t13joyGKy15wZYXIUY3EZoEUe80/YkDjrA= Received: from CY8P220CA0037.NAMP220.PROD.OUTLOOK.COM (2603:10b6:930:47::7) by MW3PR12MB4537.namprd12.prod.outlook.com (2603:10b6:303:5b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.21; Thu, 21 Dec 2023 07:38:22 +0000 Received: from CY4PEPF0000FCC0.namprd03.prod.outlook.com (2603:10b6:930:47:cafe::67) by CY8P220CA0037.outlook.office365.com (2603:10b6:930:47::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.34 via Frontend Transport; Thu, 21 Dec 2023 07:38:22 +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 CY4PEPF0000FCC0.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.20 via Frontend Transport; Thu, 21 Dec 2023 07:38:22 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.34; Thu, 21 Dec 2023 01:38:21 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Thu, 21 Dec 2023 01:38:16 -0600 From: Vijendar Mukunda To: , CC: , , , , , , Vijendar Mukunda , Liam Girdwood , "Peter Ujfalusi" , Bard Liao , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , V sujith kumar Reddy , Mastan Katragadda , "moderated list:SOUND - SOUND OPEN FIRMWARE (SOF) DRIVERS" , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [PATCH 12/12] ASoC: SOF: amd: refactor acp driver pm ops Date: Thu, 21 Dec 2023 13:05:58 +0530 Message-ID: <20231221073558.3181911-13-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221073558.3181911-1-Vijendar.Mukunda@amd.com> References: <20231221073558.3181911-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-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC0:EE_|MW3PR12MB4537:EE_ X-MS-Office365-Filtering-Correlation-Id: 27416ca7-9879-4428-c77e-08dc01f7cf17 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jvzqAxXPL+FHHHiEu2pUl0Lp6iPAyK47l037LGeD18AP/U7enSln5TkPirD+08JAmqhw3r4JldBSrOwW963dUgkFYZCPbNN0/yuYkjLZ+ma3WuX1rZ7QFEGhIK39F/8CF6lx0vh+/aBK5B0V8n4JB3oy2ACGZPebvRAReww4heFi27u5ybpZMkmSjRdfQbEssCP93qC7tM6HXOofH3cK9hc9tWCQC8Sqz46Ty3sGdUCaZ0XJmdkJeUxdC/CZkXnuz8ebTvP3/4DPGdh7yM6w95JhV6pm5YoE0//yjcGrR8mzt/Jab4QoBmkFfZaRG8zMNx+LPtMW42CUH73/AjOscLUSDw5FGjARd/WdFEpGYKOtG37xcLeECv5oYWbjcyYdFZhY9OHxiemn3BvuSpoQWxW7qorIq+dvpnuIG2sOFpb5Nvr/U6uzmA5xLJBnAm4kXa4F3AqnMgahWlPl/9h1a5PZTfpj7tLOeknUEotAcaCrp1sQPy9IznkrcIG/b9aLOlF57xccQIb8YW63093PEkh0bD+7nM1JTVt7Ef6pAcVuJwYS12S15D3ogcyUlyNI5DYMjruLW0mYhNMeDExMSM7ZBZ+eWxlAmb8tUfyPZPipjn8ZNTlhi0gNlPnHWL6mmRXaQjE2CIhYVLPMMJrQauKalzL8ZMO0b3tWSIDaEoZPsN61Cec0eNSJ1m6F2ItJ4/kqj0y7EwvtgOEkPsbOlX06r/yuvYm+FP/Y3Oigc8HCUIgjpLi6cEmyqMpcRsg2aQsN3rfWkJ/w0tmxBz5TqQ== 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)(39860400002)(136003)(376002)(230922051799003)(451199024)(82310400011)(64100799003)(1800799012)(186009)(46966006)(40470700004)(36840700001)(2906002)(6666004)(86362001)(36756003)(356005)(7696005)(478600001)(7416002)(36860700001)(26005)(83380400001)(47076005)(1076003)(82740400003)(2616005)(336012)(81166007)(426003)(41300700001)(5660300002)(54906003)(110136005)(70206006)(70586007)(40480700001)(316002)(4326008)(8676002)(8936002)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 07:38:22.1666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27416ca7-9879-4428-c77e-08dc01f7cf17 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: CY4PEPF0000FCC0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4537 Refactor acp driver pm ops to support SoundWire interface. When SoundWire configuration is enabled, In case of ClockStopMode, DSP soft reset should be applied and for rest of the scenarios acp init/deinit sequence should be invoked. Signed-off-by: Vijendar Mukunda --- sound/soc/sof/amd/acp-dsp-offset.h | 3 ++ sound/soc/sof/amd/acp.c | 65 +++++++++++++++++++++++++++--- sound/soc/sof/amd/acp.h | 4 ++ 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/sound/soc/sof/amd/acp-dsp-offset.h b/sound/soc/sof/amd/acp-dsp-offset.h index c1bdc028a61a..59afbe2e0f42 100644 --- a/sound/soc/sof/amd/acp-dsp-offset.h +++ b/sound/soc/sof/amd/acp-dsp-offset.h @@ -103,4 +103,7 @@ /* Cache window registers */ #define ACP_DSP0_CACHE_OFFSET0 0x0420 #define ACP_DSP0_CACHE_SIZE0 0x0424 + +#define ACP_SW0_EN 0x3000 +#define ACP_SW1_EN 0x3C00 #endif diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c index 7a34faae9889..920fead2d93d 100644 --- a/sound/soc/sof/amd/acp.c +++ b/sound/soc/sof/amd/acp.c @@ -482,6 +482,31 @@ static int acp_reset(struct snd_sof_dev *sdev) return ret; } +static int acp_dsp_reset(struct snd_sof_dev *sdev) +{ + unsigned int val; + int ret; + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SOFT_RESET, ACP_DSP_ASSERT_RESET); + + ret = snd_sof_dsp_read_poll_timeout(sdev, ACP_DSP_BAR, ACP_SOFT_RESET, val, + val & ACP_DSP_SOFT_RESET_DONE_MASK, + ACP_REG_POLL_INTERVAL, ACP_REG_POLL_TIMEOUT_US); + if (ret < 0) { + dev_err(sdev->dev, "timeout asserting reset\n"); + return ret; + } + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SOFT_RESET, ACP_DSP_RELEASE_RESET); + + ret = snd_sof_dsp_read_poll_timeout(sdev, ACP_DSP_BAR, ACP_SOFT_RESET, val, !val, + ACP_REG_POLL_INTERVAL, ACP_REG_POLL_TIMEOUT_US); + if (ret < 0) + dev_err(sdev->dev, "timeout in releasing reset\n"); + + return ret; +} + static int acp_init(struct snd_sof_dev *sdev) { int ret; @@ -498,10 +523,34 @@ static int acp_init(struct snd_sof_dev *sdev) return acp_reset(sdev); } +static bool check_acp_sdw_enable_status(struct snd_sof_dev *sdev) +{ + struct acp_dev_data *acp_data; + u32 sdw0_en, sdw1_en; + + acp_data = sdev->pdata->hw_pdata; + if (!acp_data->sdw) + return false; + + sdw0_en = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SW0_EN); + sdw1_en = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SW1_EN); + acp_data->sdw_en_stat = sdw0_en || sdw1_en; + return acp_data->sdw_en_stat; +} + int amd_sof_acp_suspend(struct snd_sof_dev *sdev, u32 target_state) { int ret; + /* When acp_reset() function is invoked, it will apply ACP SOFT reset and + * DSP reset. ACP Soft reset sequence will cause all ACP IP registers will + * be reset to default values which will break the ClockStop Mode functionality. + * Add a condition check to apply DSP reset when SoundWire ClockStop mode + * is selected. For the rest of the scenarios, apply acp reset sequence. + */ + if (check_acp_sdw_enable_status(sdev)) + return acp_dsp_reset(sdev); + ret = acp_reset(sdev); if (ret) { dev_err(sdev->dev, "ACP Reset failed\n"); @@ -517,13 +566,19 @@ EXPORT_SYMBOL_NS(amd_sof_acp_suspend, SND_SOC_SOF_AMD_COMMON); int amd_sof_acp_resume(struct snd_sof_dev *sdev) { int ret; + struct acp_dev_data *acp_data; - ret = acp_init(sdev); - if (ret) { - dev_err(sdev->dev, "ACP Init failed\n"); - return ret; + acp_data = sdev->pdata->hw_pdata; + if (!acp_data->sdw_en_stat) { + ret = acp_init(sdev); + if (ret) { + dev_err(sdev->dev, "ACP Init failed\n"); + return ret; + } + return acp_memory_init(sdev); + } else { + return acp_dsp_reset(sdev); } - return acp_memory_init(sdev); } EXPORT_SYMBOL_NS(amd_sof_acp_resume, SND_SOC_SOF_AMD_COMMON); diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index e94713d7ff1d..947068da39b5 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -31,6 +31,9 @@ #define ACP_ASSERT_RESET 0x01 #define ACP_RELEASE_RESET 0x00 #define ACP_SOFT_RESET_DONE_MASK 0x00010001 +#define ACP_DSP_ASSERT_RESET 0x04 +#define ACP_DSP_RELEASE_RESET 0x00 +#define ACP_DSP_SOFT_RESET_DONE_MASK 0x00050004 #define ACP_DSP_INTR_EN_MASK 0x00000001 #define ACP3X_SRAM_PTE_OFFSET 0x02050000 @@ -242,6 +245,7 @@ struct acp_dev_data { bool enable_fw_debug; bool is_dram_in_use; bool is_sram_in_use; + bool sdw_en_stat; }; void memcpy_to_scratch(struct snd_sof_dev *sdev, u32 offset, unsigned int *src, size_t bytes);