From patchwork Mon Jan 22 09:24:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 764678 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 00BB0C47DAF for ; Mon, 22 Jan 2024 09:26:02 +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 3551B85D; Mon, 22 Jan 2024 10:25:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3551B85D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705915556; bh=c8pyGPpBIPuuzo3IuY/HnWAHT2Hq/EMvv52T1XmEyBE=; 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=VlNrdeLvZW5Yq1iQRpREFgmAd2n0JIH3tC48lYu4IXQlx/8DY2NO9Q/SU2dCeN0LH ypKaeK4rnxy5XB6YT4CTTmwmMObVXexjl7SIIt7Qj0rsZk/WbduKZLqsVWhd3HzxKy Hpg1dCgYdYqImR4MUlW4EUwNzpXDuL50pHzg0HfU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 02D66F805C9; Mon, 22 Jan 2024 10:25: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 82165F805C8; Mon, 22 Jan 2024 10:25:16 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C8DF3F8028D; Mon, 22 Jan 2024 10:25:13 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20600.outbound.protection.outlook.com [IPv6:2a01:111:f403:2416::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 8D63EF805AC for ; Mon, 22 Jan 2024 10:25:04 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8D63EF805AC 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=ccy0XWIH ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jtdgBJI9GKUgbCUz+av+Bn3DDIVgIaZLO6rRd0OPpbWsBRZmcOoESWg+XvpluwhtDD+9m6Cs1h3XaAv0DbuQrMse0PTaT65v9CxpUdQ95jUp4Iudz3u/XWiDOyts/KvOE5kNjQ7rzW/50YMiMxxeLRgt4d6HIWZuvBDm/0xbLwu+ckQFF73f4SZHg98zb2qTPYoOyY3ldRBij8HaDOaP3Yb2pghWgkQmEDFxdL2A0aYD5QQ8ppibQNgwQ9xN5L/uRLwOmI7rpz+eYquoQKDAbkQoxHcDtc079A5KNJGfu2zAOW1d3vH1uNwTmXIJzT2ImRGwdLLptOKMd3Hlc1g5Qg== 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=fOhMtVCesN+ur8N0oWmzRRCxIH3/QbXj3Wrd5lQ7D7M=; b=DqfwXob22F6tejRoTHsWwOuf9R24lL6FllbnharuTTVNWeSXFJBSiEudCAmoTP2tyJe3DC6Qs8VGn3mR0VBz88oFGeVPyQ5Iqhbr0yWIdjNJ0i/GFtYYWk2gS8m+pIkNzWs3Va8AxcRBVQgyR2agLzuBylabt71NdxbBbqBfnhHcVBFUxv3iZJ7yN1czIIeOvK5TkzvQfeIbeUd29R1Eal/NdL4rZdDzFBcrkk9Ux0ofRXI7zYgEhDBKkd+H6F2kZJK88kpThaYQ426VUKd8egjTVye/0pYGKgOY7tu9RMpwNvKaCBkpYtsz2cRePh1+Ltt3YAi+P2ZGPNHG5dgkng== 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=fOhMtVCesN+ur8N0oWmzRRCxIH3/QbXj3Wrd5lQ7D7M=; b=ccy0XWIHwdx55C7icibTtE2g1HdxbICt33l5qv7URqjSRxTNMaxh8hUpj0CFb0bDa+yJX4tXcAdI68zRA64fEnCpV1UWJv4fNswmzZJVoikTYLsS51GAtj/Em4aLndaxxFZL6SEdWa25JyT1AZ1B0nszFEfjxq6UfWbuP6gAlI0= Received: from DS7PR03CA0248.namprd03.prod.outlook.com (2603:10b6:5:3b3::13) by IA1PR12MB6434.namprd12.prod.outlook.com (2603:10b6:208:3ae::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.29; Mon, 22 Jan 2024 09:24:58 +0000 Received: from CY4PEPF0000E9D5.namprd05.prod.outlook.com (2603:10b6:5:3b3:cafe::fe) by DS7PR03CA0248.outlook.office365.com (2603:10b6:5:3b3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.34 via Frontend Transport; Mon, 22 Jan 2024 09:24:58 +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 CY4PEPF0000E9D5.mail.protection.outlook.com (10.167.241.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.14 via Frontend Transport; Mon, 22 Jan 2024 09:24:58 +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; Mon, 22 Jan 2024 03:24: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; Mon, 22 Jan 2024 03:24: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; Mon, 22 Jan 2024 03:24:52 -0600 From: Vijendar Mukunda To: , CC: , , , , , , , Vijendar Mukunda , 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 V3 01/13] ASoC/soundwire: implement generic api for scanning amd soundwire controller Date: Mon, 22 Jan 2024 14:54:23 +0530 Message-ID: <20240122092435.3791175-2-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> References: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D5:EE_|IA1PR12MB6434:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b101eb4-cef1-4455-b6b9-08dc1b2c00a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RX9tVpMF6yuX5/957+0a6Ey/qjvo36YyOGglkDZCAD0oaUtNdv4rImteq7uAGzwNg6Mx9YrH4Ar4AUqxMstPVI3I28D2l2RySTEOUPnPLv9AG49i4UGhYoHwAsGSj0BeDjHpFYmkz5ApyGCxQVNjchTZh+h+hOEhi0NDQ4Q/TReqUOGcniLsI1WIa3/8dPbm7L/ANmFWW+sFkJjyR7RBAtHugFZ/urX1ANCp2lgb4iszPKOtiRsyBq5NW5ur6mLQBAxbsrJcY8gjQZQLFJRbxNg60LeDBZ4iMP5gF9qsCIHwR7p+SF/SDm1jI/5MadCQZWJWNx9UvNr5D/g/cWDyPHlBwDeDhbkByZLVqM+firrTEdOxP82Wo1AzvC64wTOgUHnkSE0pkYaJxIsYi44S01HS+dU9Ds2nrNMhnSjk7X52a7sY8z52LYveP04M2zBq/chFgMxqtI7iqPJ78MtDF+UdKL+3/0xG6J0/d1XIuuUCSNlhBKqmye2gKUWVg4cIq0chiSaXGogTusGN5yFfBJJLYUr7lR4drjwKz9RzuH5CA6SyfRRbJvpe8OROcm0X2ta2uD2bR8bgVIKPMvy6vq2PLQ+6OGE8nQIgaX9aLmnP0vVEIce4FTxntGzkkEQ6UZOHghuGp2jLL74TIKAwuWw6WvNR7RX68zf5jU1JSQogv7D2Vpd30/XpFzLirXSTPp1E4uG7MXh2x7X/Ib4riAJmAbF7U0bRQJJXkoladkHu7fBqXvRyyT5wxM8d4p/viNVhH5wy3yLyDiFxMUKazTi54gqVnPpkgL5ImGhIr08= 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)(396003)(346002)(376002)(136003)(39860400002)(230922051799003)(1800799012)(186009)(64100799003)(82310400011)(451199024)(46966006)(40470700004)(36840700001)(81166007)(356005)(82740400003)(86362001)(36756003)(316002)(110136005)(478600001)(70206006)(54906003)(7696005)(70586007)(6666004)(2906002)(8936002)(8676002)(7416002)(5660300002)(4326008)(47076005)(41300700001)(40480700001)(36860700001)(1076003)(426003)(336012)(26005)(83380400001)(40460700003)(2616005)(41533002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2024 09:24:58.2004 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b101eb4-cef1-4455-b6b9-08dc1b2c00a2 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: CY4PEPF0000E9D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6434 Message-ID-Hash: XG6M22WGRGKI2CKSTAHHLOXR2TYOA7RH X-Message-ID-Hash: XG6M22WGRGKI2CKSTAHHLOXR2TYOA7RH 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 generic function for scanning SoundWire controller. Same function will be used for legacy and sof stack for AMD platforms. Signed-off-by: Vijendar Mukunda Acked-by: Vinod Koul --- 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 Mon Jan 22 09:24:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 764677 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 EE0EEC4725D for ; Mon, 22 Jan 2024 09:26:30 +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 C9CD7B65; Mon, 22 Jan 2024 10:26:18 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C9CD7B65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705915588; bh=I48p3FJYrdqBq+qB7J9cth7qpgrcQCD76Ylex+9CBRo=; 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=qZWWDNTVn6yp7o7qYA01vsBOJZXiMdY9rnoiv50fFIwEbesJE2qe9SWUsf5y+8qt0 qiOZVzW9/Wjmt1Ui8tNidvxujBctR67dA8mzhZ6G0rhbweyYNKxQzNgHd9zQJEdqN9 RzfNxvpdV/9QU5WKRBEajMaM5HAasvuCDMeZcAac= Received: by alsa1.perex.cz (Postfix, from userid 50401) id AAD07F80587; Mon, 22 Jan 2024 10:25:50 +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 4014AF80571; Mon, 22 Jan 2024 10:25:50 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 58A7AF8028D; Mon, 22 Jan 2024 10:25:47 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::601]) (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 D7C2AF80149 for ; Mon, 22 Jan 2024 10:25:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D7C2AF80149 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=QMaZS1gH ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OU6aYVBYQdBVQvgZrhmYIyKkMf3NRxi5XlKHsOITLtXIkMyagU8uSWc+YqX+CN73zgVEjbzYItXAeP5PBN2JWDa5YagutR+fSwuu/ubH4rfPanYB/4NQmzmu983sopy/qQLcPTEBO36dcU44s/B0AjB8XbOwxNNN9phmaTmNz0vvj95bpELkXoKBSRwHIFpfmxwUwDOQSE0wTvlFcTOQTAmE6pyZUUTKjY+l2kYOUpRCRo3PTjBoQNLr1qinnViSxGZEDrR5bMqrFc16DRkPSfgtAgy0npxGYq8SSMJh64TNqJ90JA4xJKqiKsSOYW+2HZwUK6ka3wxlD8VMR6nyZw== 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=x3rsuiLG/ffVyByi+S/ebYQm2FWLXFkmTlfmDuiOlks=; b=k68Gzw+W5km37pdDZEVUJ/DzQaya4tkx7N4ErpDw9AUZUKcE9Cw2Oh0DKK0QcL8eEaHhDR9tP/O6q4ARGJbcw6HZf8ytXPNNtgUkHAoNMUIpHTq2WI65OzVoGusUJxyYAP30mdl+smulX3zNYO2bUuColSs8qUqx/ZMbWBhHaMJ/yCc9JBnCSwMnxnAj3bkjr1mo8+vkL+GCLkVlGS20EhZZ0aQzqFtGQ7sXE/iSQrPPc8rct+RHfDT8JUkfhQAUGUrrrkrFNDh4cQrBhQhg1HnhwNjiIbuoJ2ViXT1WA+y9cIeMwlnIxLxiynBanmQlrdOr+luId/ggkPuWWRHVZQ== 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=x3rsuiLG/ffVyByi+S/ebYQm2FWLXFkmTlfmDuiOlks=; b=QMaZS1gHF1uoxTEb/H90Sx9e/wVmpsrMswfGNgLF6Umo1RhllYUTCN9hi1f7h+Lv54XG7k0FTODneGJ0U+LxDioMNuuQhF2+tohS7FJwB2haRcO+kA2OyAPFa5kAP8xJPK4tjAxszCBm+wNH3qqwr+KeDHAygDsPPRQocZNRxwk= Received: from DS7PR03CA0253.namprd03.prod.outlook.com (2603:10b6:5:3b3::18) by DS7PR12MB5911.namprd12.prod.outlook.com (2603:10b6:8:7c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.32; Mon, 22 Jan 2024 09:25:28 +0000 Received: from CY4PEPF0000E9D5.namprd05.prod.outlook.com (2603:10b6:5:3b3:cafe::5b) by DS7PR03CA0253.outlook.office365.com (2603:10b6:5:3b3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.32 via Frontend Transport; Mon, 22 Jan 2024 09:25:28 +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 CY4PEPF0000E9D5.mail.protection.outlook.com (10.167.241.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.14 via Frontend Transport; Mon, 22 Jan 2024 09:25:27 +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; Mon, 22 Jan 2024 03:25:18 -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; Mon, 22 Jan 2024 03:25:07 -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; Mon, 22 Jan 2024 03:25:04 -0600 From: Vijendar Mukunda To: , CC: , , , , , , , Vijendar Mukunda , Sanyog Kale , open list Subject: [PATCH V3 03/13] soundwire: amd: refactor amd soundwire manager device node creation Date: Mon, 22 Jan 2024 14:54:25 +0530 Message-ID: <20240122092435.3791175-4-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> References: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D5:EE_|DS7PR12MB5911:EE_ X-MS-Office365-Filtering-Correlation-Id: 68a690c4-ca42-4303-88cc-08dc1b2c124d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eZjORHLe1mM/dBckF9VVAhO1BIapO/XzoCkeYU2dvowxQxPvN6Vz5Eh/LXON0srY/q7c49Oex8308HnqBWVRzTmComMts2cPR/LwMiW2bkh8njBRZsZXFxCZfWNU+JvSXMQyoQBsWQCHHVIvYv68RgnGO6r3KOhUgUgJXA7FjbjvU6iim04/edOZwlYedO/igmqZsf+qgykwND8G3aM5jK/2Qc03kQsiMMXsirlHVWraZM1i0SnJkwXgJmS7+GvKBPfenfMXNu7kjxdbChzJgpqj9GeWxk8YaPBEIBXQYrlaTD3QABY+hqNKAtBIusdZPVXiPwY54dPHOhjgXiB8x+OGDw4QppJ7BADPby5UKKelx5r4LfFfESGpnEIWVVlI/tT+GRckWbfPF1UJYxEmlX7RqfK0hr+5bEgs+hpPwR/JmXS/k8LGd9xV/KXnLOucYcdLk1i11Ich5cqETwZ8/zR6gU5HCxWwfpmwjb+4wdDNEiyiqW53XY5g/Azdbjd7B5qsbc8zkxboR+zFrSlMHbIloRgwS8AKTYkuCjlSvNAzpJ9YS9Ajbmffs8V1ToPnpQ3GfgVqCQct0g30b8wA7SOgP0wud72RMs7udf+IN33soP22Q6/3uVhEkulgOtf+1lqy4eFFQcaO4ZvhUvU5Sjsoggx/tbZV4tTQLLvnSe/21ivsl+zxpS1TaHxC3shnibPsrqJrOeB12D5jKAWzHKuJsitMAmzswwYG5yTMzpm6x9nSAdeTWzx2ZuFRPQRlT0hpMubM7W3WO+BPvS8kEQ== 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)(136003)(376002)(396003)(346002)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(82310400011)(46966006)(40470700004)(36840700001)(356005)(26005)(1076003)(426003)(7696005)(336012)(6666004)(2616005)(36860700001)(83380400001)(5660300002)(2906002)(47076005)(30864003)(8936002)(8676002)(70586007)(54906003)(478600001)(316002)(70206006)(4326008)(110136005)(41300700001)(81166007)(86362001)(82740400003)(36756003)(40480700001)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2024 09:25:27.8256 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68a690c4-ca42-4303-88cc-08dc1b2c124d 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: CY4PEPF0000E9D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5911 Message-ID-Hash: WN5ZC4WLIKGDP6V2H4DYKRHV3VTORPEL X-Message-ID-Hash: WN5ZC4WLIKGDP6V2H4DYKRHV3VTORPEL 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 afa2d83b7e69..0fcf8f8545b1 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 56b4117c087a..1e5ff4c46365 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 Mon Jan 22 09:24:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 764676 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 572CFC4725D for ; Mon, 22 Jan 2024 09:27:04 +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 BC1EEE64; Mon, 22 Jan 2024 10:26:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BC1EEE64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705915622; bh=IFEot5bHMABYq7lhA8Lmyy1rUd/zj2YzvOCv6zifuJw=; 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=hq7Ng0oBVnwnHqecjSrKXaSEAa/dTHifOI/aY+e621hSox370fcj17IaAnkLBmHbd wcbzfyDF0TIiAQD1WoymjmZDqCUOnZKt8zMUK0DvBv5tfFbMqTUYSlNgN9ldhDjCM8 IoBxW3x8KoRRdJeH+z6tAWijEzfDrspaNbzbqz8g= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C998EF805AE; Mon, 22 Jan 2024 10:26:06 +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 3114EF8060B; Mon, 22 Jan 2024 10:26:06 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 02C03F805B3; Mon, 22 Jan 2024 10:25:58 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20601.outbound.protection.outlook.com [IPv6:2a01:111:f403:2412::601]) (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 0C27DF8022B for ; Mon, 22 Jan 2024 10:25:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0C27DF8022B 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=Lr7Tn8dp ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CnLF3ZhCqFhZSitIdoI27GL1eMCZYOPelX7bTjNcfAoJmuoJ4W1eJUDmPcJtOfFxlSVb4J1Zw1NxB03+PCecy3V/K9pEplAUFOjtk4RQwJmt4EpznREg9an38cgFPYgYd0U6tfVWuqmox2VdY6GJJwsxjUcURZb1k4pORL3+ZFzX0zxg2IQv0Rv3uEN47qFdcYQM7pUZo3YDkT+F8idlXPKUIh1zuJN3rt8O3HgFnPCbaX9kKM2RDVIXvk8KzpPgliOXU+6Ip0W5Jmnox5bxse1SAwuClqT1SMK2Y8UG3XMJ4Hi42sfwXf7onPFbkwIlLQhrdhAEI/9jQrfCiezKkg== 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=CFdBQFK594SUzT/rZ/nQ4zQ3K2GAlXJIQYpqFZzwPoU=; b=Zaa/B5KYA+XotM+Y3QUVFwNYEPR01H8y/EFnglGYx6vyyvbB6d04wMaQ5RjM4wzezPtJQcRydhTsMqUzJllgfQ97GkQ+WDJtB9m1Yydq3MIwNEqJSRAnKuc17U0qUvWW+Ij6L5mWqke4HrZsk9yTI/z9gpy+71A5YD2SfTwZaSRRH3Du5wTnh1xF3xHU2emh3eKpdcstYWhFiBm3dRsVvVK0EFci1+0Evt/XAMQ53kgP355fL4R1RyVASFnm+zOt9hArS/TyvwP0UmV//BUpBztSvNkJVFt+N/OGNi5CvTpinYzHEo336vLXHbMyokKRIO+pzyvnEB3AJIVwgabipw== 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=CFdBQFK594SUzT/rZ/nQ4zQ3K2GAlXJIQYpqFZzwPoU=; b=Lr7Tn8dptst+NG1nVETogNvZ4woSjIT//Q0uJyyUu8ZDIpUZtsuW+NxX2M+WrlDXGxryjHGooFQojPkk3F4uJ4RyqYZDAB6CP0O6eaZ0LsFjHdiT5PWMaExEE9hZ21MIgZKTTF/F4ZQttG8vTCSYkHmMenpdwGL8InEFx+mxxJo= Received: from CH5P223CA0012.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:1f3::26) by PH7PR12MB6466.namprd12.prod.outlook.com (2603:10b6:510:1f6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.34; Mon, 22 Jan 2024 09:25:28 +0000 Received: from DS3PEPF000099D8.namprd04.prod.outlook.com (2603:10b6:610:1f3:cafe::49) by CH5P223CA0012.outlook.office365.com (2603:10b6:610:1f3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.32 via Frontend Transport; Mon, 22 Jan 2024 09:25:28 +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 DS3PEPF000099D8.mail.protection.outlook.com (10.167.17.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Mon, 22 Jan 2024 09:25:27 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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; Mon, 22 Jan 2024 03:25:18 -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; Mon, 22 Jan 2024 03:25:11 -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; Mon, 22 Jan 2024 03:25:07 -0600 From: Vijendar Mukunda To: , CC: , , , , , , , Vijendar Mukunda , Sanyog Kale , open list Subject: [PATCH V3 04/13] soundwire: amd: implement function to extract slave information Date: Mon, 22 Jan 2024 14:54:26 +0530 Message-ID: <20240122092435.3791175-5-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> References: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D8:EE_|PH7PR12MB6466:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f33a64d-0b9b-4216-a226-08dc1b2c1247 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ljlIOA0tTWFqZ1JqznuU+QUakOBtVpuT+H3n8y9F7y9Qfs3Z6ctt+fzqXfXeO0MFUAeWY5EYiMkW33mpKa7Poic9sOgljIdgxj0mv6t834yCZ9YaDqh7erADc7F1xR39ZShlTaZn+JGvJCJKYYRdFAokUOfdHcwPTtOiiKKkj6N5dOvxUKlo28AQHD4yhyZB9MvbB+xafzI/dWdRKF7PiSvXUAmCL5vBG7Ex2F5RuLvD7huHEQqJkzQZ+O+KXs5NTqozxQkWYhMg0s7/RmrGNR9LngSxjpu7xTEe6UpNifSRSQvfJB/lJ5o7LEq2z+JgKZFmb5lQ/4lBz/mCLAsPIWRp1ax700D7dnqNBC+xxexTe59++VSYvzdqjKV8qNGWLmBmf5NSDv0ltwrE6HtEe8WgKX7LBZfjIubk5ym2DgO3A1z3RN24YpnwXxYpk5/XOK+FmbHu7aaSqm+4tz9CTP0EdGKFoVScQWxq35WKzlaX3SywcAVr/UXEPobjVja8vfcFZevDXUBLwI+FUFShlODXkidO5HgeO9Cz0I+Fqs6twOe3WBtaJJx8V65Z5t5L6Rk0M6cpULTopc/3WCusFGZ76xVaFcDReRbvW8IOaGyPNw21ZlNOysGBfKCyWREKx2WiwzdQEkNIrR6RMvi+3FOvCtAwpq5wAZWseTtvVw/EsmbSng4zDiFWt3HNlhOXZ9gNThaiKCBUp7XUhgze4W/Q0OFIcXi35gJkiVnu55fmCnVD+AnL9VsKIItr7ikBXJNV1wLR0ZuecF+XsRl5VA== 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)(136003)(376002)(39860400002)(396003)(230922051799003)(451199024)(64100799003)(186009)(82310400011)(1800799012)(46966006)(40470700004)(36840700001)(478600001)(6666004)(7696005)(110136005)(70206006)(70586007)(8676002)(8936002)(316002)(54906003)(47076005)(36860700001)(1076003)(26005)(426003)(336012)(2616005)(2906002)(4326008)(5660300002)(41300700001)(36756003)(81166007)(356005)(82740400003)(86362001)(40460700003)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2024 09:25:27.8181 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f33a64d-0b9b-4216-a226-08dc1b2c1247 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: DS3PEPF000099D8.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6466 Message-ID-Hash: 4TU3MEMBHTI3AILXGT4DUO2APIAO6NS6 X-Message-ID-Hash: 4TU3MEMBHTI3AILXGT4DUO2APIAO6NS6 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 1e5ff4c46365..ae53664f87cb 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 Mon Jan 22 09:24:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 764675 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 4FE22C4725D for ; Mon, 22 Jan 2024 09:27:44 +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 16502950; Mon, 22 Jan 2024 10:27:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 16502950 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705915662; bh=70tYyohuzJBuHeIMEu8qAErJX0isonNJlXcOljksQBU=; 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=BtVP0jn41+Zn9GcH7PZeHIImzuPCqTj8vyg91KwAKJahYzki61VYA6uWubir0CRu5 5Sejh4Oejk0HqC1fAfYxtg6OS/xuo9cqdsp4u9FBhsPN2AzObw6CgOsBiDM0GNOs+w 0mxaH2hVw1notiFl5+E5aaEezkvrodaPIBVHMKBc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B295DF8065A; Mon, 22 Jan 2024 10:26:16 +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 D5BE0F80684; Mon, 22 Jan 2024 10:26:15 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 617FEF805F9; Mon, 22 Jan 2024 10:26:12 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20606.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::606]) (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 E99A8F8055B; Mon, 22 Jan 2024 10:25:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E99A8F8055B 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=0fp898Np ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d8pvzLppyGVh8bOyM4XfogG9LJ8/rpl1w0kM8mHJA9f9a+cRKZZoEtNSC9Kru9hAwjgYrqRaHhK9KRGt+AbMY5VmMs/ft2Qk2VDmtOC/xyTXplvmdg6cjbYTeVB5/oNY4vuhZhJcvv+IcDtRJmwVzD+48LoL7ZyMTLQLCvjk1eKcRYJE8hpEEb9cNrJryTDi1k8mQ+MOY8eNXrTM5iJjABbcyZsd3TfAP415uAMMB5nm6DUaiWh7vZFYUotmOQPascEcrj1h5HleHHyAO59Vlhf5huE38QTmSJNWp7Updh0271iE51WLXBzEpCHEsp4dOQVkpUTK92lZop94L0kQEw== 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=iPSeyilKf/cXmG/NxJWYvCl8JCuQwE4ZkMoEtRKBym9V/g1PxcqUMsvgo2UMtBUHpdjouJseGClaKgFaN6z9ZvX4R/whHLNScujKQ3siKLijfMq7YGem6LNbdCJiRp0PrYPVGwS+YJMhIczCvwAmhwD+JCFYXuG5ScDzWW/05Zfcjk8ujZOZ/5Mp+RNPMP6JyjD9LbAZ2wKth+fAFdZ6t5dDpjtjDLcZ3nvjNVT0o3D26/ib0LjIe60QXqBH4j2GNdxJmhi1dm3OMY7c/mvGEwJLhiFaAPNdRzfppVhtGXKj33Fu0dH3hj+Od38kRqhzSOG/WyqfuQlZrw78Nvnd6Q== 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=0fp898Np1gB5p/fy3pPSrjM2oa1fq48BDzb9zK7+WFxHkf/t7EKT/a1M4sVwfT0sDA+kcNBeD2qIL9K35phGtHAkxx3wAd3uyz9nNn7mUvQkl7S2lUuC8ZF+qdcFnRKOvpZVkdYYC17RFZN0B1DZXIgw86FMnHr2zdNlSLMShf4= Received: from DM6PR10CA0028.namprd10.prod.outlook.com (2603:10b6:5:60::41) by IA0PR12MB7776.namprd12.prod.outlook.com (2603:10b6:208:430::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.32; Mon, 22 Jan 2024 09:25:38 +0000 Received: from CY4PEPF0000EE32.namprd05.prod.outlook.com (2603:10b6:5:60:cafe::40) by DM6PR10CA0028.outlook.office365.com (2603:10b6:5:60::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.33 via Frontend Transport; Mon, 22 Jan 2024 09:25:38 +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 CY4PEPF0000EE32.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Mon, 22 Jan 2024 09:25:38 +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; Mon, 22 Jan 2024 03:25:37 -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; Mon, 22 Jan 2024 03:25:37 -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; Mon, 22 Jan 2024 03:25:31 -0600 From: Vijendar Mukunda To: , CC: , , , , , , , Vijendar Mukunda , Liam Girdwood , Peter Ujfalusi , 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 V3 07/13] ASoC: SOF: amd: add code for invoking soundwire manager helper functions Date: Mon, 22 Jan 2024 14:54:29 +0530 Message-ID: <20240122092435.3791175-8-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> References: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE32:EE_|IA0PR12MB7776:EE_ X-MS-Office365-Filtering-Correlation-Id: a0c8a35e-de0b-4c28-78ef-08dc1b2c1878 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K0W0tvCgKNfoq1HEq0Zc6v+mjnYFZNbkfDCoNS1DNfPtM6ZbrmO1r86KSJH+f7Xif/fHpqSiJNPOe955cj3dD8tuCaWc6fQmxyfzo3o5mxpP6e7NKlVeqpbw2QBK84vZAVQrUho4UXLsCY5s8mf1e0N4uiU7GnBPIGk8V5aULWH5K0mLCb4/nj+nE6oE9hANH01fWHTdAvIZ0M2M4oHRMIfFk+HOQHof2JrUNvkAwwpw5s8Ag06zIV2+CFJ0V1EMGSKpe7hh6Y+MbAXzp6mI78T+gysvo6ZfEIgO511Ih5AwuWi6V32sVVXrZ8Wp6qfy4Vrj2YxG7Et6Rh/CtIf0kHfgCgzsTTU69D+UFA1y++JEmkZVS7U4Gx3WezOXXKQlzT5SlifgqxhwLmRcjaKpAKhtOFUdlK+ErgqL7KNgxeKIyvyMpca1orrvX5g8wEZa/P4T6G6Fmp2QFvtRXfI2H0wWmmhR/jgV046hKqXxb4u9IxEW8c3j2jBeoPUfPnoU2asdPcbrVGg7PvrsVcnlNXTcfuwdGexsHY4wcNtQax64mf78OV6F6tIKZGnlHrDpFkb2eT8kyTbE1XMn3XM2R6EateV47BakurtT6cbRgEVXv0H1q6zijYJcFzhl/uC4aq1Fhf0c/vZhYU9heLfjSBQJBYW4rHqgn+G2cwvEBJiDl3S6IwXONIOgYEAfwPAv0rkQZtGRCaTZWju9kCoWZ+3y1p6Jh9ClYyUuQanpReXYBKfFF/I7ahbkPXWyxjWQBouzCLop5GcdsG2j6fpucQ== 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)(376002)(136003)(230922051799003)(64100799003)(186009)(82310400011)(451199024)(1800799012)(36840700001)(40470700004)(46966006)(83380400001)(47076005)(26005)(336012)(2616005)(426003)(1076003)(82740400003)(36860700001)(4326008)(8676002)(8936002)(5660300002)(478600001)(2906002)(7416002)(41300700001)(7696005)(54906003)(70586007)(70206006)(316002)(110136005)(36756003)(356005)(81166007)(86362001)(40480700001)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2024 09:25:38.1889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0c8a35e-de0b-4c28-78ef-08dc1b2c1878 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: CY4PEPF0000EE32.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7776 Message-ID-Hash: 34F4CAWAPOK45TA6ZQ6F5CQGRZKUK5HJ X-Message-ID-Hash: 34F4CAWAPOK45TA6ZQ6F5CQGRZKUK5HJ 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: 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 Mon Jan 22 09:24:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 764674 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 C7E12C47DAF for ; Mon, 22 Jan 2024 09:28:09 +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 B27567F1; Mon, 22 Jan 2024 10:27:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B27567F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705915687; bh=6Oh0AeqAs3GSRQ7LlJY6ezIsZ7gv2kjaHXykuOEAlAk=; 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=Vb2klzkKRT9lnN1ipl6iIyA2j/7QCvT87FvHcggxWJSR6l187JPxHdK8ruRVj1eA5 oYTDfsXRwA9kHDmwNRAoMaEiOa+Q9MxAjVFkueTIHXK7atCt8lsAWasaN07Pdpq3rJ 6EalDw76cTddZILaJrn2KEefbjZDGBOUuq4A6u1k= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D1115F80685; Mon, 22 Jan 2024 10:26:47 +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 3CE8DF8068F; Mon, 22 Jan 2024 10:26:47 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 30E4EF8057A; Mon, 22 Jan 2024 10:26:40 +0100 (CET) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20600.outbound.protection.outlook.com [IPv6:2a01:111:f403:2408::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 AE47BF805BF; Mon, 22 Jan 2024 10:26:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AE47BF805BF 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=X0wrMtiO ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cA9XNmCar8AQkkDXNIJVUXHw5sl50yAVDMJQv161/TzMvYR8x6EYp7PdXJ5zLUdUbd0UTb9qF01gqCX1Oh/y50LsiBgVNOwFx/ikAYfGVvopp1DNfZkttnOCNSBhWtynBBWt4gQ06PzoXQQKwz8MZBfcWmJP9m3AFFCRbtelt8Y2WTg1CZ5IiPcy+8QRnP/5A9pYPDlBMkXrbCHoGluAhnfB1afNIlJ0fH6boAmtf5DeRVNKVUnRt4NMoZyypSFaJka+/AXRJr6A2/dM+aWXy3U1vCqzOa3m+SqBZkG+Sn7rVm30x82mEAscEvFsu8ajj4mxHGdLdmDKM3wwR21IKw== 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=AsK9Db0ex62Uu40cnVjS6Lhi73vfEnPjeA5SsOXjAxpiqk/OquCxOiXZYjhiyVhSlQaP/amxHiGb+COmIRyZku4BhECbFfEd1taI/tqCw+axGO1QZwNcCpUw/0rzJ4HldQrShZsty0r3yu+ULvzq2wjy9EC/6UUMLAgUheRrjJlWNWKtfJ5syxBfXIPhHI5GpiqtKt45cW0aEAlb52L0yG3bVuEP6IRgvxmv3CAYxTONWSLL9omsjD+CBfed1WD7k4Z0gbVc045oDIg7IjBSAgHBpedrGTB/wU6vnm0yBZthYt1jH5S8ny6+BJcjQLii+QINfknyqABQ+Xn5Qo17Vw== 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=X0wrMtiOcljcVROipQDoEiYqQIXWguQfOXlFs0xUSmFhQW6q+LOHtPNhIvcVAxs+NXzi4jakiNKIOWDCIc6Z4I9IeOJMO82g9OroxzPOxfdKxC0TJwMeHjYJfGilVDm5zAmDvukMg1rCbmVMIZAknlnjB5Y+LumlSx3cHCBdWQQ= Received: from DM6PR21CA0029.namprd21.prod.outlook.com (2603:10b6:5:174::39) by SJ2PR12MB8875.namprd12.prod.outlook.com (2603:10b6:a03:543::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.34; Mon, 22 Jan 2024 09:26:02 +0000 Received: from CY4PEPF0000EE30.namprd05.prod.outlook.com (2603:10b6:5:174:cafe::67) by DM6PR21CA0029.outlook.office365.com (2603:10b6:5:174::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.6 via Frontend Transport; Mon, 22 Jan 2024 09:26:02 +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 CY4PEPF0000EE30.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Mon, 22 Jan 2024 09:26:01 +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; Mon, 22 Jan 2024 03:26:00 -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; Mon, 22 Jan 2024 03:25:55 -0600 From: Vijendar Mukunda To: , CC: , , , , , , , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Peter Ujfalusi , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , 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 V3 09/13] ASoC: SOF: amd: Add Soundwire DAI configuration support for AMD platforms Date: Mon, 22 Jan 2024 14:54:31 +0530 Message-ID: <20240122092435.3791175-10-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> References: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE30:EE_|SJ2PR12MB8875:EE_ X-MS-Office365-Filtering-Correlation-Id: a70e9a03-f69a-44cd-dd41-08dc1b2c26a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z+bS0DTjmPyW7sFRgu0tgUYGBm+sjusq9C6Sr5/s/NzmSLq9IeY4G9zZ7LjzhR3E3ai8QgplBfBj/RMzctsZKfFK2GENGuTdO4N89nAtC7gMiFmNAsKUbke3PwVyV54yAosF3sXMrk/OPw/+RDkRrd8d4KbVysC0QUb0J+KeHrHrVYOaOg9eT1DZCAIv/1n7JQxcjtsBZECc3cji+V+RU98vZvibrnUpVxmkwGEI0BazNjckspxbgHcYzZjYYkYoJVTusqf/KK/zPhJAv7UiB79JERuoVOcgFchi63KSxlXkuQnvUByGp+dIf7m+Dsefsyq7C56M/PALXUTdTjUYhKb0YPP1ShDiJDhZoEfrkX3gS0pQywx1nwzraN1ti4efAUmfrOGkVAozySeVv0asTH3U/gwZFGEdH/Ztf+p4OImhht1s+Ysa1MFzVHj+uSHlQ0HWgzl9LtjXN69ORac/T/0f6kfyvHxGaJ/Hu4Y1FM5a0RRSB5q16XCfWUhATxEXB88fq7Zb/lfQfmfKAYCZoXxbrjVjrlVduBbK9OxZHVGdPIWttj5FAdaYLvJxK4+7WhFonBu+awYlLOTjJ6ceVIV2sP1AzKasOxbXHYBTE7LMb9GtDU9WAqEjoN9m3BvBbWZuQrEouAa0drCdoSUwBbRR63khkn53a/mTHdn89aHARwHQh6T5iDEab2zCEkQopI8xi4RD5zqZfRoj/dnOkq8GlBKSD6JYixCF9jTaY50rnG+ctpKOuIIoli7Cpe0v4c28+tIami9f8dZox6QlBw== 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)(39860400002)(136003)(376002)(346002)(230922051799003)(82310400011)(451199024)(64100799003)(186009)(1800799012)(36840700001)(40470700004)(46966006)(81166007)(356005)(82740400003)(36756003)(40460700003)(40480700001)(86362001)(83380400001)(336012)(426003)(1076003)(26005)(2616005)(316002)(70206006)(70586007)(8676002)(8936002)(54906003)(7696005)(478600001)(6666004)(110136005)(47076005)(36860700001)(2906002)(41300700001)(4326008)(5660300002)(7416002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2024 09:26:01.9654 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a70e9a03-f69a-44cd-dd41-08dc1b2c26a6 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: CY4PEPF0000EE30.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8875 Message-ID-Hash: DOYJEKKRHESVVTRPJXJWGBRQ5VLQ227R X-Message-ID-Hash: DOYJEKKRHESVVTRPJXJWGBRQ5VLQ227R 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: 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 Mon Jan 22 09:24:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 764673 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 B2CEAC4725D for ; Mon, 22 Jan 2024 09:28:54 +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 DC047DF6; Mon, 22 Jan 2024 10:28:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DC047DF6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705915733; bh=ymemvslKkhYGpyHpqh6Q/7RrSZIdxNF0MnFMcoOfCNo=; 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=pir33SVe5QwBkXC8Ryq4ENcoWhXTgdhXCnkSO/zvzWxC7zSl1dQuix6spmPX3YX3R Jl8g79cqer04/3FCjAYtf+s1XmDlSBJcz4lVxh8V1S7S1LAaNdRRKK68+1/e8EDfNN Das2m28ocrhlWRMyfCWIpa2shtseDCLagmJgz9cI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 71349F8064F; Mon, 22 Jan 2024 10:27:31 +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 803D4F80671; Mon, 22 Jan 2024 10:27:31 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DA2B2F805E2; Mon, 22 Jan 2024 10:27:27 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20601.outbound.protection.outlook.com [IPv6:2a01:111:f403:2405::601]) (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 12F92F8028D; Mon, 22 Jan 2024 10:26:31 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 12F92F8028D 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=VvEsQEFn ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YrVYa/gOKEJPLN5FTm8eBd4gn2hDhEud1vYrUdu0F8dIWKoBHyhtLgbZ8dBcLjKJk3OIagQBcNFRRrsyAfahI7t6X/T99cPNul86pgSDj/KXjtj+8gSxSW69sSWRqR1+B9r5TeN28jWV9TVZbvLCNfaNcNGmvHoZi7dNcOXVOu+0eJm5Y6GeffJnBeN4pUSgmLMe5tB3WuXlV28zSDfYa/znu1BTnaHEQJx3Qe0X4D+fxrf/aTkFp0wf5f+XkhcIaNAYQjuHN9iH2v5khbxOO80iHX3PcKC5jtBvOHfQ7Th7vG7rexY5qXNZR/o+L0U7ZKajuCPDkfWxJFGVDFImiw== 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=OzBftTZBzT9hxmN4PKmDnaBsdwNdTA6LnIYcCvmMJAhrn5MMLCygeXhZ6RgazmqhAWDg1gaLZAULohAJ6fsxDWiYJnVvrk2Z6Ae5guirIKgb1cUkXuCINBemDkXsnTjaJDuJk6Yl9fwIFwICj8Ww4zax0olDJcQnNWPdqWZ3rrhlTdOq14J1FjmBavTMVVttDNTaausU/ZwwVkTCZicfLYrifjBej3YS9UE68WXzeESiNSFY+43S+iEB5I451vSa0kU7qR4LHgX9DLNv6S1izni2CfDux0C8dbKQz4g4aQEEZH2prr/yAbCnIc0Pr1VOfHqbFyim+rJOV5tVvt6AOQ== 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=VvEsQEFnQCxbeoplpyosBHcHKHhcm1UvEnLTVe9Rymwd0dhwE7yD9GA5WO+mmrwOa/RjCg9M8UomGjAR8Bje4XBPYFyarZO3VV2C5x+SFn/wihVHxma8BGdPzr52rlVElH50Q9+DGZizE4SwgB0B9gv6TJi9LiYqdc5lybYVd4E= Received: from DS7PR03CA0261.namprd03.prod.outlook.com (2603:10b6:5:3b3::26) by BL1PR12MB5364.namprd12.prod.outlook.com (2603:10b6:208:314::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.34; Mon, 22 Jan 2024 09:26:27 +0000 Received: from CY4PEPF0000E9D5.namprd05.prod.outlook.com (2603:10b6:5:3b3:cafe::ce) by DS7PR03CA0261.outlook.office365.com (2603:10b6:5:3b3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.32 via Frontend Transport; Mon, 22 Jan 2024 09:26:27 +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 CY4PEPF0000E9D5.mail.protection.outlook.com (10.167.241.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.14 via Frontend Transport; Mon, 22 Jan 2024 09:26:26 +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; Mon, 22 Jan 2024 03:26:25 -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; Mon, 22 Jan 2024 03:26:20 -0600 From: Vijendar Mukunda To: , CC: , , , , , , , Vijendar Mukunda , Liam Girdwood , Peter Ujfalusi , 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 V3 11/13] ASoC: SOF: amd: update descriptor fields for acp6.3 based platform Date: Mon, 22 Jan 2024 14:54:33 +0530 Message-ID: <20240122092435.3791175-12-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> References: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D5:EE_|BL1PR12MB5364:EE_ X-MS-Office365-Filtering-Correlation-Id: 515f1ce4-10f2-40b1-7ca8-08dc1b2c3592 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xvkfuzRopq1jcnbeebO2N6B8XbHpeCY05Ch1iBkip/ESuBtnfmlrciky2mt7JPZ3OGMgwzc4ZKhEJxwsA66KQfux3gX1qrxjlqqMwmz0hsNuYqTnzYxDWi/EhXYD70bNrIoR5uy3qdouOxaTKrjp8S4xhRrtIgZzcFeessiklNG3bbShfCfZ877GYDXVJd54gDcevYZJ0ES8+7mAmYxssDB6gHn/DdznnsI/3cviIipVYy4AFdzjJx3+YuOHeTr067pcD1irk92gcVpd4oBrvuOO8yTu5oks257j87h107VqM8lX8jZSIydRchiAZg440ur5dmXojcDeebL7Yiv/BjtjTX/kFmilQoYAdNrNHUOGnQvRhA7FSzY+E8f0q2EBpi25QrmTjzkc1FPA05IpUaT7JrB4xarvLzVm9KHjN/Qsichd5Lppw84gF6jE52jcfbRvQAZUkae3qkqUzTpTUDY/XaSzVTwN889IVZ0kTaXQQubtYbFchAB7wVIdeqvZfGiGwsMZmBxPOSNV72QGlIy/YvAqTzyQBzALCIGgYdqpnKIpTFkIyKUvUpISucitZjUbjb5Kq9iQuQfUb3jVC5SW0B+BtjwmvK2kgPntotK2bhVOBmFhu1qaP6BwxSvHPxSkAghAsb+KDcPRZIbxLYa7FZZO6s/OhNTBL5eFlJh7VoWOZkliMLiK3FDYRAQnSr6vwQCO97h4iz93uvE7VCuygeDBKs2BgxtRMlbcfb9bonve2R8GRqAhaMS+/fskUd7i23jKZNYg4vhauJlyeU/ZpM1V2ALVI2aY1nplAn+iKuO70NmvYUAMxhgyZPqG 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)(396003)(346002)(376002)(136003)(230173577357003)(230273577357003)(230922051799003)(1800799012)(82310400011)(64100799003)(186009)(451199024)(46966006)(40470700004)(36840700001)(40480700001)(40460700003)(2906002)(7416002)(5660300002)(15650500001)(8936002)(8676002)(4326008)(70206006)(70586007)(54906003)(110136005)(6666004)(7696005)(41300700001)(36860700001)(316002)(82740400003)(356005)(81166007)(478600001)(36756003)(86362001)(47076005)(426003)(336012)(26005)(2616005)(1076003)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2024 09:26:26.9977 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 515f1ce4-10f2-40b1-7ca8-08dc1b2c3592 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: CY4PEPF0000E9D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5364 Message-ID-Hash: ZWM4NYELHLOKAMDXBDDZMRP6LOT4VFUF X-Message-ID-Hash: ZWM4NYELHLOKAMDXBDDZMRP6LOT4VFUF 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: 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 Mon Jan 22 09:24:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 764672 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 1B87DC4725D for ; Mon, 22 Jan 2024 09:29:44 +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 0DDDEB71; Mon, 22 Jan 2024 10:29:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0DDDEB71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1705915782; bh=uowzxZRevTt9WCAROFCeIie7vPjduaXYhxvsHTUycdg=; 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=Cho5dW+aBavL4gJdudSiK1SfOy/15ahddqFtXPNj568qt2BVUORapmIA1+FTB+Ey+ yb2QfR902UpCffsTgxSpw57Tm28BanmavbnvF6Rcm0kidr/SlrbWinbHpFTmwNV0aU 6jzOODq03hr5BMtvTfDYJp9Dpf3LJIbkXEcsjWOo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id AB3B2F805F5; Mon, 22 Jan 2024 10:28:12 +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 D501AF805B5; Mon, 22 Jan 2024 10:28:11 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 49D9CF805AC; Mon, 22 Jan 2024 10:28:04 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2062c.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::62c]) (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 6A53CF8069C; Mon, 22 Jan 2024 10:26:54 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6A53CF8069C 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=lgPh+jGo ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LEvjCtyQHlnX6X15f9Et6DmsVVMmVAllPpWBc4fOyFXvLXFjz0/ODRqWcMb8rQwftTGq+NFxoX9zz4Hk/H7BdEGY5Me+96xk9S6qoy9utAEv2JeX8oXFUojslNDRtUwshapnxCpHK5KwbKHg9j6Dmr92rRoXAgN3ooz6PgMbI2gd1Mam0HowOuNpKpCoIcmWDrlkLRZ8y0ioV1kIvEHWOcBYa7Xe2wLG5GnP2FMG8UlEJbB8s/ozoPQw90r+402KaMIidXd879g0CyAeH2s5VvTNcy0Q04uf7Q4t46Plo/A3Amb1tYzW0RiJV8nUUm3Z76intLRDkgFl57A4rbTXoA== 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=kaVyKDAkwJditzMfvUSymLDFbGXFyocajcZ1h4FuNOdvEK9innHZmOAMajTE7Pa3Jcn5wPcs6q6+zF+N+DJMbFTlyGdbW4oYKqpIR0veiMPvehbdjSnSwnQlB3N2VkblFugzwiyYSSlrniSzVIjFnRBcgSa8Epes8mAZW3IYlTlWgyvu40FiSf/KUSuC51FMH31v8vrrmomFMJNMDJ1tI+W6jr6PpTHG66e4zDyn1LEkdZFWWteedIq62oKzwH1Iu+/d6Qt15mkbUN9moAuBZhD1M6tBlrppkg6d0GK+qnMywDH208IBUba5CqZ3kJ+fwn0GRp8+dO/a+cQ1TOT3Xg== 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=lgPh+jGofiGnAJ+mC6eUYSgCTEaUyMuOP2oAtqCtQ77sidTBXsBgiyI6T4uY2Vv6nxnjqtaqPQOr70z8rG/B+XfNNy/GSrktyuLZU+/nF/MAOCXm1DvLYwVPKMLrvRxX+zHSjOrKv50cJfQ3PU1xTbSUviRwPk9UmUa7HJ1Vq3w= Received: from CY5PR19CA0041.namprd19.prod.outlook.com (2603:10b6:930:1a::8) by SA1PR12MB7272.namprd12.prod.outlook.com (2603:10b6:806:2b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.32; Mon, 22 Jan 2024 09:26:50 +0000 Received: from CY4PEPF0000E9DB.namprd05.prod.outlook.com (2603:10b6:930:1a:cafe::67) by CY5PR19CA0041.outlook.office365.com (2603:10b6:930:1a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.32 via Frontend Transport; Mon, 22 Jan 2024 09:26:50 +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 CY4PEPF0000E9DB.mail.protection.outlook.com (10.167.241.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.14 via Frontend Transport; Mon, 22 Jan 2024 09:26:50 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Mon, 22 Jan 2024 03:26:49 -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; Mon, 22 Jan 2024 01:26:49 -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; Mon, 22 Jan 2024 03:26:43 -0600 From: Vijendar Mukunda To: , CC: , , , , , , , Vijendar Mukunda , Liam Girdwood , Peter Ujfalusi , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , Mastan Katragadda , 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 V3 13/13] ASoC: SOF: amd: refactor acp driver pm ops Date: Mon, 22 Jan 2024 14:54:35 +0530 Message-ID: <20240122092435.3791175-14-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> References: <20240122092435.3791175-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DB:EE_|SA1PR12MB7272:EE_ X-MS-Office365-Filtering-Correlation-Id: 0274d9ef-2ccc-483f-5b6f-08dc1b2c435b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ne7pNAKK763a1RynHtuPYRevU5x9XOF7p2om3eDphF4t+yvx8fBO/yrgg1cBRbihbHQ1Q+OaVO6jucOcC3tf+pqitj/c8YP4lRfZJMHC/EcdGdIWPBnAhInXLAocSZX5s3+W5CFMB8YdxuBpIprI2iVmCZCBYITNiCNRGDbUBwl1f/oE4O6bi67K3kwPqgePuoraCvaiMLM/zrT0uZ0No+tQ/LhseSJfdjQ5uM5TpWqVLBFfJJFqQhjON7xOYlpDZ4BvmzXw7XSxUR3RmGmJV883q5SipsSEqdW2clBYuwNAmMsP87xQ0iHAYpKBEPUjXpI9mXs0Z5qSZhZRUO/KUcwaKUpC8QH3rQZ/DBNNW9061kQzSsOOWH+95aTUWyEOGFphV2uQAKQa8a/8+lnOZP1fAH2UK052YK1Nlt/2EXg+sxlulkaOCJLyq4on+3j6wGFak4vpJdoJJ5OCZNIpPUCUqrXanu7cgy7usI9TiAGI3KPNGVYo7CgwhpmjbMjYoyZ8M21IU7n3P7unJ1LzcXpSUUoAqqeSyq298E5ZNIu56Ww/o+bPNopNXwpbB1GHFlszr/hvR9HZsliS3pOKSg3hEsENJpaH/Pl2BCvWNptKa72+F1o/sKBIqjqliH9hiYltKaksdJ3YHl/YoFZHlD8iElWaeGll20mnklLzUkk7ET7zBLCPT1bNtoIFv0588K4Pj92qVIARd8Sdi/Xnm/Yn7b5hNpTd71d+zOJnOssuuCPg5MYQjh1EBzOCSb+hSgjSbTZTam1vWCRCxXDYKA== 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)(376002)(136003)(346002)(39860400002)(396003)(230922051799003)(64100799003)(186009)(1800799012)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(36860700001)(47076005)(41300700001)(86362001)(36756003)(82740400003)(336012)(81166007)(356005)(83380400001)(478600001)(8936002)(8676002)(4326008)(6666004)(7696005)(316002)(110136005)(54906003)(70206006)(70586007)(7416002)(426003)(5660300002)(26005)(2906002)(2616005)(1076003)(40480700001)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2024 09:26:50.1245 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0274d9ef-2ccc-483f-5b6f-08dc1b2c435b 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: CY4PEPF0000E9DB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7272 Message-ID-Hash: K3HFDGAOVG5BYKB5TRBVDSYDWTOLXPFG X-Message-ID-Hash: K3HFDGAOVG5BYKB5TRBVDSYDWTOLXPFG 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 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);