From patchwork Wed Jan 11 09:02:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096284 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 AC9CEC46467 for ; Wed, 11 Jan 2023 09:01:17 +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 628A06F28; Wed, 11 Jan 2023 10:00:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 628A06F28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427670; bh=jFHNyCoIB4bVFdA0M0XMnjYFN7OazNmFQCC1F2vzdD8=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=itMIMrEPFbuf6qSRuzCvyahm819dH5/4W2YHaBz8ico3G6LkoMtFtyHPgi8SiIL0b WJtDN0NM0J9CI7+nqcAaNm+7XSBotZoO1uEL6C9ARHMukNF1BvtZHj5M/blYvFDL0c mg3cSL2g0tAwqLZSMk0ELntmQd3zExKMWgfFCDuU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4BA0BF8053A; Wed, 11 Jan 2023 09:59:56 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6852BF8053D; Wed, 11 Jan 2023 09:59:54 +0100 (CET) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2068.outbound.protection.outlook.com [40.107.100.68]) (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 B4E1EF80425 for ; Wed, 11 Jan 2023 09:59:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B4E1EF80425 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=oZV6AvKy ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UgI7gqT0zopG0iP5SOs66U9E92v4oeZqs1SFk7hFB5OCI2FFYOw6RrAvN2VS2B3j2K21QgZL+wgcmhAPVOIKNrfRYiTYEsOUr4+W67fFmEqSAgzJKk999sLwKN5rQ+oaERs2pQGDglgZ7TW12nNk70Q4I7C6/qV9kwZyb4a1LMC4jIE2banxtUcLDhX2Qcd6r6mSyQnfBx06xDiPtgQ4wzhjkxLpbn+OlwzLeH9KeV6bovl6WkwiguLevuO5sN7M5Dgf1ru4ytY8JKTqzkMZAy+tgXp2GQI/2ed7oXnVEKZdeDFWgzEEgDon22R4XAsBVCDUy3qVsZaiBnDuT6mRrw== 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=Q6IcGvT1XU3poCPoNix67Q5LWFB6cWRxV3vvrQ2T+Bc=; b=Lb1/NUm8mIRzFVcEpSMdXP/fgwow8cWGS4K7PvTMtQ+1YUBlvoHQ2A7+DU+E4yRaZhFiZmc9pjF1s9cJGr2rv3ivhsDJdZByx3mM5MmHVv3CKJMDJoNrc8sTx2/zwF+W/YjfSJ35MdnnSYwps0UjM+FBhG5JSSzNSH1/vtRnGmmBdnfxRUmE9dmWttIu/M37wzeD2QtXMRrLLKTU3d7wke6E8jTq0HtK7K01+fOYmJIThWfhjpZ9e0FAkX1KW4e3q5qvOjqYEsKYtS9pylSsfQoVrNRM+3306Mz006LmwxVPr8I/MCKg/M1HYGdjtQAEDLndvdMMbxi2V1fdnfLJQw== 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 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=Q6IcGvT1XU3poCPoNix67Q5LWFB6cWRxV3vvrQ2T+Bc=; b=oZV6AvKynDzD43oFdqnyORCGJzcN1r7HUlHyF8Wh7S22D8/F6PP0QuG3qVjP4gKmyubRZp99FS53FppMZrsiPJ5fxsrvOUce5uUYsJNSQVU0P4sYKo50gracPMpN4tPGl6xhflsmT+Fk5ZK9NoFzlSzir887bVw1auQvWtTIUhA= Received: from DS7PR03CA0199.namprd03.prod.outlook.com (2603:10b6:5:3b6::24) by MW3PR12MB4569.namprd12.prod.outlook.com (2603:10b6:303:57::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 08:59:46 +0000 Received: from DS1PEPF0000B078.namprd05.prod.outlook.com (2603:10b6:5:3b6:cafe::d4) by DS7PR03CA0199.outlook.office365.com (2603:10b6:5:3b6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 08:59:45 +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 DS1PEPF0000B078.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.6002.11 via Frontend Transport; Wed, 11 Jan 2023 08:59:45 +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.2375.34; Wed, 11 Jan 2023 02:59:45 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 00:59:44 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 02:59:39 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 01/19] ASoC: amd: ps: create platform devices based on acp config Date: Wed, 11 Jan 2023 14:32:04 +0530 Message-ID: <20230111090222.2016499-2-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B078:EE_|MW3PR12MB4569:EE_ X-MS-Office365-Filtering-Correlation-Id: 2cebad8d-3c06-4e8a-fcef-08daf3b22fc3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: agZsCNK6LeWvLr3WeYq7OTbTG1qsY03yJWx4AhKjJahZMjVkv2MgyOIfOFSh6h2exT+b2laNs15L5Au3dgiN/hgbPYLvH3BN+OIWsLN1aRGzJJFG/NhBCvx4IRVlX6WIS2fGV/wpXOFLZiypLy5OxOBy2rCsi5ETHJvGS/6Ud0ffgDkW1/XWBO18DFT3bMio7kMgSDDAfuIl9QRjuaSSAQu0A9CiDK7PlXlyXFzicc9BR0cdTZaA3zqMEMDP+oeMRl3b1u/evEPdiOqsGwAz6OKuhaPkrOYDGTt3j4WTmrY//HB6bqDe+ZJ8sq+a9EasPwrEQwAs0tHQzgMIY5WZ7QdehIz2Ip8Ic9b7vdwmdoO8RiA3GKZmfmHFn2rq2ZEtKxGdIqLUJXlknghmburuXhR8DRjf27tJYdIQ9QPW96SRA88qFXHdG6gzFWzsWCHwenYXi591OoHBmdnpBPUOtJBjKhHon0CMDTKVInNzJp6I6NzBnGEVf1ZLnCKPm//XWWtb5rK86xo6yccCMHNv8y8BjgSIQ7Yzn6k4x/0YW206bL7Ihh76L/tb/7gHvpPQNDuiP1H52rC4Zr5CvbENcQxbFErPY7MKwyL6CugnbmL78yFhOowYFPYp5K7fze5E2XGO6poNi+265t5RZfz7rlbOrI11BOsPzCE0gFjizFP9USILAAQmfH9w06IxT1CZcyS+olgf0uJA69YsPyw0oVJzK/B6bf+9kRIYXp+JYMA= 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:(13230022)(4636009)(136003)(396003)(346002)(376002)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(30864003)(1076003)(7416002)(40480700001)(316002)(5660300002)(186003)(7696005)(26005)(478600001)(2616005)(41300700001)(426003)(47076005)(70586007)(54906003)(70206006)(4326008)(8676002)(110136005)(336012)(82310400005)(8936002)(83380400001)(40460700003)(86362001)(36756003)(6666004)(36860700001)(82740400003)(2906002)(356005)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 08:59:45.6510 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2cebad8d-3c06-4e8a-fcef-08daf3b22fc3 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: DS1PEPF0000B078.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4569 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Pierre-Louis Bossart , Liam Girdwood , Nathan Chancellor , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Sanyog Kale , Bard Liao , Syed Saba Kareem Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Create platform devices for sdw controllers and PDM controller based on ACP pin config selection and ACPI fw handle for pink sardine platform. Signed-off-by: Vijendar Mukunda Signed-off-by: Mastan Katragadda --- include/linux/soundwire/sdw_amd.h | 18 +++ sound/soc/amd/ps/acp63.h | 24 ++- sound/soc/amd/ps/pci-ps.c | 248 ++++++++++++++++++++++++++++-- 3 files changed, 277 insertions(+), 13 deletions(-) create mode 100644 include/linux/soundwire/sdw_amd.h diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h new file mode 100644 index 000000000000..f0123815af46 --- /dev/null +++ b/include/linux/soundwire/sdw_amd.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. + */ + +#ifndef __SDW_AMD_H +#define __SDW_AMD_H + +#include + +#define AMD_SDW_CLK_STOP_MODE 1 +#define AMD_SDW_POWER_OFF_MODE 2 + +struct acp_sdw_pdata { + u16 instance; + struct mutex *sdw_lock; +}; +#endif diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index b7535c7d093f..ed979e6d0c1d 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -10,7 +10,7 @@ #define ACP_DEVICE_ID 0x15E2 #define ACP63_REG_START 0x1240000 #define ACP63_REG_END 0x1250200 -#define ACP63_DEVS 3 +#define ACP63_DEVS 5 #define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001 #define ACP_PGFSM_CNTL_POWER_ON_MASK 1 @@ -55,8 +55,14 @@ #define ACP63_DMIC_ADDR 2 #define ACP63_PDM_MODE_DEVS 3 -#define ACP63_PDM_DEV_MASK 1 #define ACP_DMIC_DEV 2 +#define ACP63_SDW0_MODE_DEVS 2 +#define ACP63_SDW0_SDW1_MODE_DEVS 3 +#define ACP63_SDW0_PDM_MODE_DEVS 4 +#define ACP63_SDW0_SDW1_PDM_MODE_DEVS 5 +#define ACP63_DMIC_ADDR 2 +#define ACP63_SDW_ADDR 5 +#define AMD_SDW_MAX_CONTROLLERS 2 enum acp_config { ACP_CONFIG_0 = 0, @@ -77,6 +83,12 @@ enum acp_config { ACP_CONFIG_15, }; +enum acp_pdev_mask { + ACP63_PDM_DEV_MASK = 1, + ACP63_SDW_DEV_MASK, + ACP63_SDW_PDM_DEV_MASK, +}; + struct pdm_stream_instance { u16 num_pages; u16 channels; @@ -107,7 +119,15 @@ struct acp63_dev_data { struct resource *res; struct platform_device *pdev[ACP63_DEVS]; struct mutex acp_lock; /* protect shared registers */ + struct fwnode_handle *sdw_fw_node; u16 pdev_mask; u16 pdev_count; u16 pdm_dev_index; + u8 sdw_master_count; + u16 sdw0_dev_index; + u16 sdw1_dev_index; + u16 sdw_dma_dev_index; + bool is_dmic_dev; + bool is_sdw_dev; + bool acp_sdw_power_off; }; diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c index e86f23d97584..85154cf0b2a2 100644 --- a/sound/soc/amd/ps/pci-ps.c +++ b/sound/soc/amd/ps/pci-ps.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "acp63.h" @@ -134,12 +135,68 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) return IRQ_NONE; } -static void get_acp63_device_config(u32 config, struct pci_dev *pci, - struct acp63_dev_data *acp_data) +static int sdw_amd_scan_controller(struct device *dev) +{ + struct acp63_dev_data *acp_data; + struct fwnode_handle *link; + char name[32]; + u8 count = 0; + u32 acp_sdw_power_mode = 0; + int index; + int ret; + + acp_data = dev_get_drvdata(dev); + acp_data->acp_sdw_power_off = true; + /* Found controller, find links supported */ + ret = fwnode_property_read_u8_array((acp_data->sdw_fw_node), + "mipi-sdw-master-count", &count, 1); + + if (ret) { + dev_err(dev, + "Failed to read mipi-sdw-master-count: %d\n", ret); + return -EINVAL; + } + + /* Check count is within bounds */ + if (count > AMD_SDW_MAX_CONTROLLERS) { + dev_err(dev, "Controller count %d exceeds max %d\n", + count, AMD_SDW_MAX_CONTROLLERS); + return -EINVAL; + } + + if (!count) { + dev_warn(dev, "No SoundWire controllers detected\n"); + return -EINVAL; + } + dev_dbg(dev, "ACPI reports %d Soundwire Controller devices\n", count); + acp_data->sdw_master_count = count; + for (index = 0; index < count; index++) { + snprintf(name, sizeof(name), "mipi-sdw-link-%d-subproperties", index); + link = fwnode_get_named_child_node(acp_data->sdw_fw_node, name); + if (!link) { + dev_err(dev, "Master node %s not found\n", name); + return -EIO; + } + + fwnode_property_read_u32(link, "amd-sdw-power-mode", + &acp_sdw_power_mode); + if (acp_sdw_power_mode != AMD_SDW_POWER_OFF_MODE) + acp_data->acp_sdw_power_off = false; + } + return 0; +} + +static int get_acp63_device_config(u32 config, struct pci_dev *pci, struct acp63_dev_data *acp_data) { struct acpi_device *dmic_dev; + struct acpi_device *sdw_dev; + struct device *dev; const union acpi_object *obj; bool is_dmic_dev = false; + bool is_sdw_dev = false; + int ret; + + dev = &pci->dev; dmic_dev = acpi_find_child_device(ACPI_COMPANION(&pci->dev), ACP63_DMIC_ADDR, 0); if (dmic_dev) { @@ -149,22 +206,84 @@ static void get_acp63_device_config(u32 config, struct pci_dev *pci, is_dmic_dev = true; } + sdw_dev = acpi_find_child_device(ACPI_COMPANION(&pci->dev), ACP63_SDW_ADDR, 0); + if (sdw_dev) { + is_sdw_dev = true; + acp_data->sdw_fw_node = acpi_fwnode_handle(sdw_dev); + ret = sdw_amd_scan_controller(dev); + if (ret) + return ret; + } + + dev_dbg(&pci->dev, "Audio Mode %d\n", config); switch (config) { - case ACP_CONFIG_0: - case ACP_CONFIG_1: + case ACP_CONFIG_4: + case ACP_CONFIG_5: + case ACP_CONFIG_10: + case ACP_CONFIG_11: + if (is_dmic_dev) { + acp_data->pdev_mask = ACP63_PDM_DEV_MASK; + acp_data->pdev_count = ACP63_PDM_MODE_DEVS; + } + break; case ACP_CONFIG_2: case ACP_CONFIG_3: - case ACP_CONFIG_9: - case ACP_CONFIG_15: - dev_dbg(&pci->dev, "Audio Mode %d\n", config); + if (is_sdw_dev) { + switch (acp_data->sdw_master_count) { + case 1: + acp_data->pdev_mask = ACP63_SDW_DEV_MASK; + acp_data->pdev_count = ACP63_SDW0_MODE_DEVS; + break; + case 2: + acp_data->pdev_mask = ACP63_SDW_DEV_MASK; + acp_data->pdev_count = ACP63_SDW0_SDW1_MODE_DEVS; + break; + default: + return -EINVAL; + } + } break; - default: - if (is_dmic_dev) { + case ACP_CONFIG_6: + case ACP_CONFIG_7: + case ACP_CONFIG_12: + case ACP_CONFIG_8: + case ACP_CONFIG_13: + case ACP_CONFIG_14: + if (is_dmic_dev && is_sdw_dev) { + switch (acp_data->sdw_master_count) { + case 1: + acp_data->pdev_mask = ACP63_SDW_PDM_DEV_MASK; + acp_data->pdev_count = ACP63_SDW0_PDM_MODE_DEVS; + break; + case 2: + acp_data->pdev_mask = ACP63_SDW_PDM_DEV_MASK; + acp_data->pdev_count = ACP63_SDW0_SDW1_PDM_MODE_DEVS; + break; + default: + return -EINVAL; + } + } else if (is_dmic_dev) { acp_data->pdev_mask = ACP63_PDM_DEV_MASK; acp_data->pdev_count = ACP63_PDM_MODE_DEVS; + } else if (is_sdw_dev) { + switch (acp_data->sdw_master_count) { + case 1: + acp_data->pdev_mask = ACP63_SDW_DEV_MASK; + acp_data->pdev_count = ACP63_SDW0_MODE_DEVS; + break; + case 2: + acp_data->pdev_mask = ACP63_SDW_DEV_MASK; + acp_data->pdev_count = ACP63_SDW0_SDW1_MODE_DEVS; + break; + default: + return -EINVAL; + } } break; + default: + break; } + return 0; } static void acp63_fill_platform_dev_info(struct platform_device_info *pdevinfo, @@ -188,6 +307,7 @@ static void acp63_fill_platform_dev_info(struct platform_device_info *pdevinfo, static int create_acp63_platform_devs(struct pci_dev *pci, struct acp63_dev_data *adata, u32 addr) { + struct acp_sdw_pdata *sdw_pdata; struct platform_device_info pdevinfo[ACP63_DEVS]; struct device *parent; int index; @@ -220,8 +340,110 @@ static int create_acp63_platform_devs(struct pci_dev *pci, struct acp63_dev_data acp63_fill_platform_dev_info(&pdevinfo[2], parent, NULL, "acp_ps_mach", 0, NULL, 0, NULL, 0); break; + case ACP63_SDW_DEV_MASK: + if (adata->pdev_count == ACP63_SDW0_MODE_DEVS) { + sdw_pdata = devm_kzalloc(&pci->dev, sizeof(struct acp_sdw_pdata), + GFP_KERNEL); + if (!sdw_pdata) { + ret = -ENOMEM; + goto de_init; + } + + sdw_pdata->instance = 0; + sdw_pdata->sdw_lock = &adata->acp_lock; + adata->sdw0_dev_index = 0; + adata->sdw_dma_dev_index = 1; + acp63_fill_platform_dev_info(&pdevinfo[0], parent, adata->sdw_fw_node, + "amd_sdw_controller", 0, adata->res, 1, + sdw_pdata, sizeof(struct acp_sdw_pdata)); + acp63_fill_platform_dev_info(&pdevinfo[1], parent, NULL, "amd_ps_sdw_dma", + 0, adata->res, 1, &adata->acp_lock, + sizeof(adata->acp_lock)); + } else if (adata->pdev_count == ACP63_SDW0_SDW1_MODE_DEVS) { + sdw_pdata = devm_kzalloc(&pci->dev, sizeof(struct acp_sdw_pdata) * 2, + GFP_KERNEL); + if (!sdw_pdata) { + ret = -ENOMEM; + goto de_init; + } + + sdw_pdata[0].instance = 0; + sdw_pdata[1].instance = 1; + sdw_pdata[0].sdw_lock = &adata->acp_lock; + sdw_pdata[1].sdw_lock = &adata->acp_lock; + sdw_pdata->sdw_lock = &adata->acp_lock; + adata->sdw0_dev_index = 0; + adata->sdw1_dev_index = 1; + adata->sdw_dma_dev_index = 2; + acp63_fill_platform_dev_info(&pdevinfo[0], parent, adata->sdw_fw_node, + "amd_sdw_controller", 0, adata->res, 1, + &sdw_pdata[0], sizeof(struct acp_sdw_pdata)); + acp63_fill_platform_dev_info(&pdevinfo[1], parent, adata->sdw_fw_node, + "amd_sdw_controller", 1, adata->res, 1, + &sdw_pdata[1], sizeof(struct acp_sdw_pdata)); + acp63_fill_platform_dev_info(&pdevinfo[2], parent, NULL, "amd_ps_sdw_dma", + 0, adata->res, 1, &adata->acp_lock, + sizeof(adata->acp_lock)); + } + break; + case ACP63_SDW_PDM_DEV_MASK: + if (adata->pdev_count == ACP63_SDW0_PDM_MODE_DEVS) { + sdw_pdata = devm_kzalloc(&pci->dev, sizeof(struct acp_sdw_pdata), + GFP_KERNEL); + if (!sdw_pdata) { + ret = -ENOMEM; + goto de_init; + } + + sdw_pdata->instance = 0; + sdw_pdata->sdw_lock = &adata->acp_lock; + adata->pdm_dev_index = 0; + adata->sdw0_dev_index = 1; + adata->sdw_dma_dev_index = 2; + acp63_fill_platform_dev_info(&pdevinfo[0], parent, NULL, "acp_ps_pdm_dma", + 0, adata->res, 1, &adata->acp_lock, + sizeof(adata->acp_lock)); + acp63_fill_platform_dev_info(&pdevinfo[1], parent, adata->sdw_fw_node, + "amd_sdw_controller", 0, adata->res, 1, + sdw_pdata, sizeof(struct acp_sdw_pdata)); + acp63_fill_platform_dev_info(&pdevinfo[2], parent, NULL, "amd_ps_sdw_dma", + 0, adata->res, 1, &adata->acp_lock, + sizeof(adata->acp_lock)); + acp63_fill_platform_dev_info(&pdevinfo[3], parent, NULL, "dmic-codec", + 0, NULL, 0, NULL, 0); + } else if (adata->pdev_count == ACP63_SDW0_SDW1_PDM_MODE_DEVS) { + sdw_pdata = devm_kzalloc(&pci->dev, sizeof(struct acp_sdw_pdata) * 2, + GFP_KERNEL); + if (!sdw_pdata) { + ret = -ENOMEM; + goto de_init; + } + sdw_pdata[0].instance = 0; + sdw_pdata[1].instance = 1; + sdw_pdata[0].sdw_lock = &adata->acp_lock; + sdw_pdata[1].sdw_lock = &adata->acp_lock; + adata->pdm_dev_index = 0; + adata->sdw0_dev_index = 1; + adata->sdw1_dev_index = 2; + adata->sdw_dma_dev_index = 3; + acp63_fill_platform_dev_info(&pdevinfo[0], parent, NULL, "acp_ps_pdm_dma", + 0, adata->res, 1, &adata->acp_lock, + sizeof(adata->acp_lock)); + acp63_fill_platform_dev_info(&pdevinfo[1], parent, adata->sdw_fw_node, + "amd_sdw_controller", 0, adata->res, 1, + &sdw_pdata[0], sizeof(struct acp_sdw_pdata)); + acp63_fill_platform_dev_info(&pdevinfo[2], parent, adata->sdw_fw_node, + "amd_sdw_controller", 1, adata->res, 1, + &sdw_pdata[1], sizeof(struct acp_sdw_pdata)); + acp63_fill_platform_dev_info(&pdevinfo[3], parent, NULL, "amd_ps_sdw_dma", + 0, adata->res, 1, &adata->acp_lock, + sizeof(adata->acp_lock)); + acp63_fill_platform_dev_info(&pdevinfo[4], parent, NULL, "dmic-codec", + 0, NULL, 0, NULL, 0); + } + break; default: - dev_dbg(&pci->dev, "No PDM devices found\n"); + dev_dbg(&pci->dev, "No PDM or Soundwire controller devices found\n"); return 0; } @@ -299,7 +521,11 @@ static int snd_acp63_probe(struct pci_dev *pci, goto de_init; } val = acp63_readl(adata->acp63_base + ACP_PIN_CONFIG); - get_acp63_device_config(val, pci, adata); + ret = get_acp63_device_config(val, pci, adata); + if (ret) { + dev_err(&pci->dev, "get acp device config failed:%d\n", ret); + goto de_init; + } ret = create_acp63_platform_devs(pci, adata, addr); if (ret < 0) { dev_err(&pci->dev, "ACP platform devices creation failed\n"); From patchwork Wed Jan 11 09:02:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096285 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 344D9C54EBE for ; Wed, 11 Jan 2023 09:01:18 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E032E185A; Wed, 11 Jan 2023 10:00:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E032E185A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427675; bh=B8RTmK/Gf+DPhYBM5hU8i3S24fpFb3eK6pRYIPYNPX0=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=qg/Zwi4xLprOtnNBbMOojkYYFAR2O9Et+DOd8TZxwljatAtrSv5Us6CrDC2eETiiY xAmiqD3hi8HuFJuWbWQRG6glAlOj5YeQu2Tg8hrauslNexkUQeMefDfa9Q0ONEmA2D 8M6SxNBlhcEVuHGGdIiXnfGTD+rDTPy1aKLNP750= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EAEB6F80548; Wed, 11 Jan 2023 10:00:05 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5F4D3F80549; Wed, 11 Jan 2023 10:00:04 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2088.outbound.protection.outlook.com [40.107.101.88]) (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 D48FDF80543 for ; Wed, 11 Jan 2023 09:59:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D48FDF80543 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=c5JPBA00 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bdn1de4Cs3JZ0QCCFgkLnAxAY8Z8kBvxxhFcXgX6e54sXFAxGr2bRB82bpGCH15le9RKRnW9eSt8RjqsSDNHC55vHojN0QbUth69hVf75mvE6sq187XtQlrDa7yPmH8yhkRYm8hSJSTnhJZqoIBDfeFK4oSQY/Rsg/Xi3/y67aYuMLAlYQCvYZZFu5vtn/re6Tz0VB5EOs7BF0cJxSKLl6EdnMSFBpnn+r42actd+jxJ4ttTG5D/JWhUUpEvGL8CL+itiEyfpRMvDdFXMZEGHcrJIimhlcfvPp1GI7Rq7bQQ4W5lvPLCqkJZGD5pXMEaJH+pLOxXOxpjU6KIXPGGSA== 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=rjLi+EX2nenBMsCeBmAMvFRdYBHLLEcTdxyYvYAXArM=; b=DTtuGb3go3yVeoIfzJN068qaZxecMskKFixipNLNPBtSdlgJRyM0lI0GaF4xuKzQnI0lHJgV7hUdKZA5VVolLCl1YB7E3KTFh6VS/zIxe+az9QvI8D7Ep/naX2bvC29+6nsEIOg28KLPuY+SaFQtSxe2ZPpr7yvwowS2lB5lTa6w7hvMcXactoBEnI33A5mjwXVMBzznhjQs9NBZqaZU1HrD65xVFCw6bFY39FPOFPZ+kPuoIMI9rJD/0Xs7N/XMp0iu2Ysk/4qhf+B423nmvcZtbfTlu1ZEKRhbBDhQKy9kAoFRRq4oujnx1IqsB180yZrW0+SUw014gzWohHO0VA== 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 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=rjLi+EX2nenBMsCeBmAMvFRdYBHLLEcTdxyYvYAXArM=; b=c5JPBA00mrYMkoEbBUGuWhVLfsjlYD55g6xC49aFnVGY0ljEd39NSz3H667no1tiWzK7RZ1iFPkiziA5ClhYCwZMb0P50DB/X6w66TsfyxUmdnrvaLiY+F8T0oTYKQdv/4/Ip77eRz8VqP9rH7KAPoxjh5kL1ErKXUdepfIJwFE= Received: from DM6PR03CA0013.namprd03.prod.outlook.com (2603:10b6:5:40::26) by CH3PR12MB8546.namprd12.prod.outlook.com (2603:10b6:610:15f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 11 Jan 2023 08:59:51 +0000 Received: from DS1PEPF0000B073.namprd05.prod.outlook.com (2603:10b6:5:40:cafe::e5) by DM6PR03CA0013.outlook.office365.com (2603:10b6:5:40::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 08:59:51 +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 DS1PEPF0000B073.mail.protection.outlook.com (10.167.17.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.11 via Frontend Transport; Wed, 11 Jan 2023 08:59:50 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 02:59:49 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 02:59:46 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 02/19] soundwire: amd: Add support for AMD Master driver Date: Wed, 11 Jan 2023 14:32:05 +0530 Message-ID: <20230111090222.2016499-3-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B073:EE_|CH3PR12MB8546:EE_ X-MS-Office365-Filtering-Correlation-Id: 58401ef8-7572-44b2-7331-08daf3b232dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5fx7zGH+R721udeDnxwsfGauzXrKN8YHyvshCXQgD43+UTde4MjZlYl2AdZvQtt+l3aPImZmHHWfnrSxq/9Xu4yCvhSMxGIzIS83iytmsIWDqWw3OZ6OAuXCiLGo/iZGBgppLZswrdJwGjao3/OZq2Gy8tCHZAZAjyZfqKmx0BJckbCw5QwDWVJqzpfEG0hmqUNNPWtfHf0g8od889kM5HqtygaCzqXrkV9+k8gv5ct4JnWE5PSUSr8grki369LhYBO8P2UO+zxaiiww7NRpjWoaa+eXZzThViL1LptjFUt/fW2TWMGoJ1NIE9s6fFb4IxyyGAlRp2ohSBO8TCYpN7svA7v5+EPeQp5OEGNf9e3wlTDho/EMrn8EsGiN0PIiAD0S3xA6Pi8Fqk0kiEFvMs3ChytoTip4Z2Krn918OSwTSKrLgcF/P6KcNBh4d2Ia3PFV3IVayX8654+xHAqPdc07lSOkqVEO+AF4jvnqWuLZpnM+032wXH5wJMYbJni+Wk/Qb5gIoOZAvkaK6paclJiLL+jWO8s2eAzaJ7PnqNhAE32UCa0BbaMf0sdtuGdcgKLLZ5O8jvpvCUjIXmDw02S8b0expAHfCQAx5+cLWAgNnS8MNSJObKjXueNWxFXwueiIalEUL/UjpBvp+zYcUl27+anhveXKs8rcZgK9YF+ez/7OkHcXA/pdurSbFzTUXv3mMA6fK7v2qHBcdXKddCnUb5EyRvUlNpeJMgTjlDI= 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:(13230022)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(82740400003)(478600001)(426003)(47076005)(81166007)(356005)(41300700001)(1076003)(86362001)(40460700003)(110136005)(54906003)(2616005)(316002)(336012)(7696005)(82310400005)(186003)(26005)(40480700001)(70206006)(70586007)(4326008)(8676002)(36756003)(5660300002)(6666004)(36860700001)(2906002)(30864003)(83380400001)(8936002)(36900700001)(579004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 08:59:50.8667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58401ef8-7572-44b2-7331-08daf3b232dd 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: DS1PEPF0000B073.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8546 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, Basavaraj.Hiregoudar@amd.com, Pierre-Louis Bossart , open list , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Sanyog Kale , Bard Liao Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" AMD ACP IP block has two soundwire controller devices. Add support for - Master driver probe & remove sequence - Helper functions to enable/disable interrupts, Initialize sdw controller, enable sdw pads - Master driver sdw_master_ops & port_ops callbacks Signed-off-by: Vijendar Mukunda --- drivers/soundwire/amd_master.c | 1075 +++++++++++++++++++++++++++++ drivers/soundwire/amd_master.h | 279 ++++++++ include/linux/soundwire/sdw_amd.h | 21 + 3 files changed, 1375 insertions(+) create mode 100644 drivers/soundwire/amd_master.c create mode 100644 drivers/soundwire/amd_master.h diff --git a/drivers/soundwire/amd_master.c b/drivers/soundwire/amd_master.c new file mode 100644 index 000000000000..7e1f618254ac --- /dev/null +++ b/drivers/soundwire/amd_master.c @@ -0,0 +1,1075 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * SoundWire AMD Master driver + * + * Copyright 2023 Advanced Micro Devices, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "bus.h" +#include "amd_master.h" + +#define DRV_NAME "amd_sdw_controller" + +#define to_amd_sdw(b) container_of(b, struct amd_sdwc_ctrl, bus) + +static int amd_enable_sdw_pads(struct amd_sdwc_ctrl *ctrl) +{ + u32 sw_pad_enable_mask; + u32 sw_pad_pulldown_mask; + u32 sw_pad_pulldown_val; + u32 val = 0; + + switch (ctrl->instance) { + case ACP_SDW0: + sw_pad_enable_mask = AMD_SDW0_PAD_KEEPER_EN_MASK; + sw_pad_pulldown_mask = AMD_SDW0_PAD_PULLDOWN_CTRL_ENABLE_MASK; + break; + case ACP_SDW1: + sw_pad_enable_mask = AMD_SDW1_PAD_KEEPER_EN_MASK; + sw_pad_pulldown_mask = AMD_SDW1_PAD_PULLDOWN_CTRL_ENABLE_MASK; + break; + default: + return -EINVAL; + } + + mutex_lock(ctrl->sdw_lock); + val = acp_reg_readl(ctrl->mmio + ACP_SW_PAD_KEEPER_EN); + val |= sw_pad_enable_mask; + acp_reg_writel(val, ctrl->mmio + ACP_SW_PAD_KEEPER_EN); + mutex_unlock(ctrl->sdw_lock); + usleep_range(1000, 1500); + + mutex_lock(ctrl->sdw_lock); + sw_pad_pulldown_val = acp_reg_readl(ctrl->mmio + ACP_PAD_PULLDOWN_CTRL); + sw_pad_pulldown_val &= sw_pad_pulldown_mask; + acp_reg_writel(sw_pad_pulldown_val, ctrl->mmio + ACP_PAD_PULLDOWN_CTRL); + mutex_unlock(ctrl->sdw_lock); + return 0; +} + +static int amd_init_sdw_controller(struct amd_sdwc_ctrl *ctrl) +{ + u32 acp_sw_en_reg, acp_sw_en_stat_reg, sw_bus_reset_reg; + u32 val = 0; + u32 timeout = 0; + u32 retry_count = 0; + + switch (ctrl->instance) { + case ACP_SDW0: + acp_sw_en_reg = ACP_SW_EN; + acp_sw_en_stat_reg = ACP_SW_EN_STATUS; + sw_bus_reset_reg = ACP_SW_BUS_RESET_CTRL; + break; + case ACP_SDW1: + acp_sw_en_reg = ACP_P1_SW_EN; + acp_sw_en_stat_reg = ACP_P1_SW_EN_STATUS; + sw_bus_reset_reg = ACP_P1_SW_BUS_RESET_CTRL; + break; + default: + return -EINVAL; + } + + acp_reg_writel(AMD_SDW_ENABLE, ctrl->mmio + acp_sw_en_reg); + do { + val = acp_reg_readl(ctrl->mmio + acp_sw_en_stat_reg); + if (val) + break; + usleep_range(10, 50); + } while (retry_count++ < AMD_SDW_STAT_MAX_RETRY_COUNT); + + if (retry_count > AMD_SDW_STAT_MAX_RETRY_COUNT) + return -ETIMEDOUT; + + /* Sdw Controller reset */ + acp_reg_writel(AMD_SDW_BUS_RESET_REQ, ctrl->mmio + sw_bus_reset_reg); + val = acp_reg_readl(ctrl->mmio + sw_bus_reset_reg); + while (!(val & AMD_SDW_BUS_RESET_DONE)) { + val = acp_reg_readl(ctrl->mmio + sw_bus_reset_reg); + if (timeout > AMD_DELAY_LOOP_ITERATION) + break; + usleep_range(1, 5); + timeout++; + } + timeout = 0; + acp_reg_writel(AMD_SDW_BUS_RESET_CLEAR_REQ, ctrl->mmio + sw_bus_reset_reg); + val = acp_reg_readl(ctrl->mmio + sw_bus_reset_reg); + while (val) { + val = acp_reg_readl(ctrl->mmio + sw_bus_reset_reg); + if (timeout > AMD_DELAY_LOOP_ITERATION) + break; + usleep_range(1, 5); + timeout++; + } + if (timeout == AMD_DELAY_LOOP_ITERATION) { + dev_err(ctrl->dev, "Failed to reset SW%x Soundwire Controller\n", ctrl->instance); + return -ETIMEDOUT; + } + retry_count = 0; + acp_reg_writel(AMD_SDW_DISABLE, ctrl->mmio + acp_sw_en_reg); + do { + val = acp_reg_readl(ctrl->mmio + acp_sw_en_stat_reg); + if (!val) + break; + usleep_range(10, 50); + } while (retry_count++ < AMD_SDW_STAT_MAX_RETRY_COUNT); + + if (retry_count > AMD_SDW_STAT_MAX_RETRY_COUNT) + return -ETIMEDOUT; + return 0; +} + +static int amd_enable_sdw_controller(struct amd_sdwc_ctrl *ctrl) +{ + u32 acp_sw_en_reg; + u32 acp_sw_en_stat_reg; + u32 val = 0; + u32 retry_count = 0; + + switch (ctrl->instance) { + case ACP_SDW0: + acp_sw_en_reg = ACP_SW_EN; + acp_sw_en_stat_reg = ACP_SW_EN_STATUS; + break; + case ACP_SDW1: + acp_sw_en_reg = ACP_P1_SW_EN; + acp_sw_en_stat_reg = ACP_P1_SW_EN_STATUS; + break; + default: + return -EINVAL; + } + acp_reg_writel(AMD_SDW_ENABLE, ctrl->mmio + acp_sw_en_reg); + + do { + val = acp_reg_readl(ctrl->mmio + acp_sw_en_stat_reg); + if (val) + break; + usleep_range(10, 50); + } while (retry_count++ < AMD_SDW_STAT_MAX_RETRY_COUNT); + + if (retry_count > AMD_SDW_STAT_MAX_RETRY_COUNT) + return -ETIMEDOUT; + return 0; +} + +static int amd_disable_sdw_controller(struct amd_sdwc_ctrl *ctrl) +{ + u32 clk_resume_ctrl_reg; + u32 acp_sw_en_reg; + u32 acp_sw_en_stat_reg; + u32 val = 0; + u32 retry_count = 0; + + switch (ctrl->instance) { + case ACP_SDW0: + acp_sw_en_reg = ACP_SW_EN; + acp_sw_en_stat_reg = ACP_SW_EN_STATUS; + clk_resume_ctrl_reg = ACP_SW_CLK_RESUME_CTRL; + break; + case ACP_SDW1: + acp_sw_en_reg = ACP_P1_SW_EN; + acp_sw_en_stat_reg = ACP_P1_SW_EN_STATUS; + clk_resume_ctrl_reg = ACP_P1_SW_CLK_RESUME_CTRL; + break; + default: + return -EINVAL; + } + acp_reg_writel(AMD_SDW_DISABLE, ctrl->mmio + acp_sw_en_reg); + + /* + * After invoking controller disable sequence, check whether + * controller has executed clock stop sequence. In this case, + * controller should ignore checking enable status register. + */ + val = acp_reg_readl(ctrl->mmio + clk_resume_ctrl_reg); + if (val) + return 0; + + do { + val = acp_reg_readl(ctrl->mmio + acp_sw_en_stat_reg); + if (!val) + break; + usleep_range(10, 50); + } while (retry_count++ < AMD_SDW_STAT_MAX_RETRY_COUNT); + + if (retry_count > AMD_SDW_STAT_MAX_RETRY_COUNT) + return -ETIMEDOUT; + return 0; +} + +static int amd_enable_sdw_interrupts(struct amd_sdwc_ctrl *ctrl) +{ + u32 val; + u32 acp_ext_intr_stat, acp_ext_intr_ctrl, acp_sdw_intr_mask; + u32 sw_stat_mask_0to7, sw_stat_mask_8to11, sw_err_intr_mask; + + switch (ctrl->instance) { + case ACP_SDW0: + acp_ext_intr_ctrl = ACP_EXTERNAL_INTR_CNTL; + acp_sdw_intr_mask = AMD_SDW0_EXT_INTR_MASK; + acp_ext_intr_stat = ACP_EXTERNAL_INTR_STAT; + sw_stat_mask_0to7 = SW_STATE_CHANGE_STATUS_MASK_0TO7; + sw_stat_mask_8to11 = SW_STATE_CHANGE_STATUS_MASK_8TO11; + sw_err_intr_mask = SW_ERROR_INTR_MASK; + break; + case ACP_SDW1: + acp_ext_intr_ctrl = ACP_EXTERNAL_INTR_CNTL1; + acp_sdw_intr_mask = AMD_SDW1_EXT_INTR_MASK; + acp_ext_intr_stat = ACP_EXTERNAL_INTR_STAT1; + sw_stat_mask_0to7 = P1_SW_STATE_CHANGE_STATUS_MASK_0TO7; + sw_stat_mask_8to11 = P1_SW_STATE_CHANGE_STATUS_MASK_8TO11; + sw_err_intr_mask = P1_SW_ERROR_INTR_MASK; + break; + default: + return -EINVAL; + } + mutex_lock(ctrl->sdw_lock); + val = acp_reg_readl(ctrl->mmio + acp_ext_intr_ctrl); + val |= acp_sdw_intr_mask; + acp_reg_writel(val, ctrl->mmio + acp_ext_intr_ctrl); + val = acp_reg_readl(ctrl->mmio + acp_ext_intr_ctrl); + mutex_unlock(ctrl->sdw_lock); + dev_dbg(ctrl->dev, "%s: acp_ext_intr_ctrl[0x%x]:0x%x\n", __func__, acp_ext_intr_ctrl, val); + val = acp_reg_readl(ctrl->mmio + acp_ext_intr_stat); + if (val) + acp_reg_writel(val, ctrl->mmio + acp_ext_intr_stat); + acp_reg_writel(AMD_SDW_IRQ_MASK_0TO7, ctrl->mmio + sw_stat_mask_0to7); + acp_reg_writel(AMD_SDW_IRQ_MASK_8TO11, ctrl->mmio + sw_stat_mask_8to11); + acp_reg_writel(AMD_SDW_IRQ_ERROR_MASK, ctrl->mmio + sw_err_intr_mask); + return 0; +} + +static int amd_disable_sdw_interrupts(struct amd_sdwc_ctrl *ctrl) +{ + u32 val; + u32 acp_ext_intr_cntl; + u32 acp_sdw_intr_mask; + u32 sw_stat_mask_0to7; + u32 sw_stat_mask_8to11; + u32 sw_err_intr_mask; + + switch (ctrl->instance) { + case ACP_SDW0: + acp_ext_intr_cntl = ACP_EXTERNAL_INTR_CNTL; + acp_sdw_intr_mask = AMD_SDW0_EXT_INTR_MASK; + sw_stat_mask_0to7 = SW_STATE_CHANGE_STATUS_MASK_0TO7; + sw_stat_mask_8to11 = SW_STATE_CHANGE_STATUS_MASK_8TO11; + sw_err_intr_mask = SW_ERROR_INTR_MASK; + break; + case ACP_SDW1: + acp_ext_intr_cntl = ACP_EXTERNAL_INTR_CNTL1; + acp_sdw_intr_mask = AMD_SDW1_EXT_INTR_MASK; + sw_stat_mask_0to7 = P1_SW_STATE_CHANGE_STATUS_MASK_0TO7; + sw_stat_mask_8to11 = P1_SW_STATE_CHANGE_STATUS_MASK_8TO11; + sw_err_intr_mask = P1_SW_ERROR_INTR_MASK; + break; + default: + return -EINVAL; + } + mutex_lock(ctrl->sdw_lock); + val = acp_reg_readl(ctrl->mmio + acp_ext_intr_cntl); + val &= ~acp_sdw_intr_mask; + acp_reg_writel(val, ctrl->mmio + acp_ext_intr_cntl); + mutex_unlock(ctrl->sdw_lock); + + acp_reg_writel(0x00, ctrl->mmio + sw_stat_mask_0to7); + acp_reg_writel(0x00, ctrl->mmio + sw_stat_mask_8to11); + acp_reg_writel(0x00, ctrl->mmio + sw_err_intr_mask); + return 0; +} + +static int amd_sdwc_set_frameshape(struct amd_sdwc_ctrl *ctrl, u32 rows, u32 cols) +{ + u32 sdw_rows, sdw_cols, frame_size; + u32 acp_sw_frame_reg; + + switch (ctrl->instance) { + case ACP_SDW0: + acp_sw_frame_reg = ACP_SW_FRAMESIZE; + break; + case ACP_SDW1: + acp_sw_frame_reg = ACP_P1_SW_FRAMESIZE; + break; + default: + return -EINVAL; + } + sdw_cols = sdw_find_col_index(cols); + sdw_rows = sdw_find_row_index(rows); + frame_size = (sdw_rows << 3) | sdw_cols; + acp_reg_writel(frame_size, ctrl->mmio + acp_sw_frame_reg); + return 0; +} + +static void amd_sdwc_ctl_word_prep(u32 *low_word, u32 *high_word, u32 cmd_type, + struct sdw_msg *msg, int cmd_offset) +{ + u32 low_data = 0, high_data = 0; + u16 addr; + u8 addr_high, addr_low; + u8 data = 0; + + addr = msg->addr + cmd_offset; + addr_high = (addr & 0xFF00) >> 8; + addr_low = addr & 0xFF; + + if (cmd_type == AMD_SDW_CMD_WRITE) + data = msg->buf[cmd_offset]; + + high_data = FIELD_PREP(AMD_SDW_MCP_CMD_DEV_ADDR, msg->dev_num); + high_data |= FIELD_PREP(AMD_SDW_MCP_CMD_COMMAND, cmd_type); + high_data |= FIELD_PREP(AMD_SDW_MCP_CMD_REG_ADDR_HIGH, addr_high); + low_data |= FIELD_PREP(AMD_SDW_MCP_CMD_REG_ADDR_LOW, addr_low); + low_data |= FIELD_PREP(AMD_SDW_MCP_CMD_REG_DATA, data); + + *high_word = high_data; + *low_word = low_data; +} + +static u64 amd_sdwc_send_cmd_get_resp(struct amd_sdwc_ctrl *ctrl, u32 lword, u32 uword) +{ + u64 resp = 0; + u32 imm_cmd_stat_reg, imm_cmd_uword_reg, imm_cmd_lword_reg; + u32 imm_resp_uword_reg, imm_resp_lword_reg; + u32 resp_lower, resp_high; + u32 sts = 0; + u32 timeout = 0; + + switch (ctrl->instance) { + case ACP_SDW0: + imm_cmd_stat_reg = SW_IMM_CMD_STS; + imm_cmd_uword_reg = SW_IMM_CMD_UPPER_WORD; + imm_cmd_lword_reg = SW_IMM_CMD_LOWER_QWORD; + imm_resp_uword_reg = SW_IMM_RESP_UPPER_WORD; + imm_resp_lword_reg = SW_IMM_RESP_LOWER_QWORD; + break; + case ACP_SDW1: + imm_cmd_stat_reg = P1_SW_IMM_CMD_STS; + imm_cmd_uword_reg = P1_SW_IMM_CMD_UPPER_WORD; + imm_cmd_lword_reg = P1_SW_IMM_CMD_LOWER_QWORD; + imm_resp_uword_reg = P1_SW_IMM_RESP_UPPER_WORD; + imm_resp_lword_reg = P1_SW_IMM_RESP_LOWER_QWORD; + break; + default: + return -EINVAL; + } + sts = acp_reg_readl(ctrl->mmio + imm_cmd_stat_reg); + while (sts & AMD_SDW_IMM_CMD_BUSY) { + sts = acp_reg_readl(ctrl->mmio + imm_cmd_stat_reg); + if (timeout > AMD_SDW_RETRY_COUNT) { + dev_err(ctrl->dev, "SDW%x previous cmd status clear failed\n", + ctrl->instance); + return -ETIMEDOUT; + } + timeout++; + } + + timeout = 0; + if (sts & AMD_SDW_IMM_RES_VALID) { + dev_err(ctrl->dev, "SDW%x controller is in bad state\n", ctrl->instance); + acp_reg_writel(0x00, ctrl->mmio + imm_cmd_stat_reg); + } + acp_reg_writel(uword, ctrl->mmio + imm_cmd_uword_reg); + acp_reg_writel(lword, ctrl->mmio + imm_cmd_lword_reg); + + sts = acp_reg_readl(ctrl->mmio + imm_cmd_stat_reg); + while (!(sts & AMD_SDW_IMM_RES_VALID)) { + sts = acp_reg_readl(ctrl->mmio + imm_cmd_stat_reg); + if (timeout > AMD_SDW_RETRY_COUNT) { + dev_err(ctrl->dev, "SDW%x cmd response timeout occurred\n", ctrl->instance); + return -ETIMEDOUT; + } + timeout++; + } + resp_high = acp_reg_readl(ctrl->mmio + imm_resp_uword_reg); + resp_lower = acp_reg_readl(ctrl->mmio + imm_resp_lword_reg); + timeout = 0; + acp_reg_writel(AMD_SDW_IMM_RES_VALID, ctrl->mmio + imm_cmd_stat_reg); + while ((sts & AMD_SDW_IMM_RES_VALID)) { + sts = acp_reg_readl(ctrl->mmio + imm_cmd_stat_reg); + if (timeout > AMD_SDW_RETRY_COUNT) { + dev_err(ctrl->dev, "SDW%x cmd status retry failed\n", ctrl->instance); + return -ETIMEDOUT; + } + timeout++; + } + resp = resp_high; + resp = (resp << 32) | resp_lower; + return resp; +} + +static enum sdw_command_response +amd_program_scp_addr(struct amd_sdwc_ctrl *ctrl, struct sdw_msg *msg) +{ + struct sdw_msg scp_msg = {0}; + u64 response_buf[2] = {0}; + u32 uword = 0, lword = 0; + int nack = 0, no_ack = 0; + int index, timeout = 0; + + scp_msg.dev_num = msg->dev_num; + scp_msg.addr = SDW_SCP_ADDRPAGE1; + scp_msg.buf = &msg->addr_page1; + amd_sdwc_ctl_word_prep(&lword, &uword, AMD_SDW_CMD_WRITE, &scp_msg, 0); + response_buf[0] = amd_sdwc_send_cmd_get_resp(ctrl, lword, uword); + scp_msg.addr = SDW_SCP_ADDRPAGE2; + scp_msg.buf = &msg->addr_page2; + amd_sdwc_ctl_word_prep(&lword, &uword, AMD_SDW_CMD_WRITE, &scp_msg, 0); + response_buf[1] = amd_sdwc_send_cmd_get_resp(ctrl, lword, uword); + + /* check response the writes */ + for (index = 0; index < 2; index++) { + if (response_buf[index] == -ETIMEDOUT) { + dev_err(ctrl->dev, "Program SCP cmd timeout\n"); + timeout = 1; + } else if (!(response_buf[index] & AMD_SDW_MCP_RESP_ACK)) { + no_ack = 1; + if (response_buf[index] & AMD_SDW_MCP_RESP_NACK) { + nack = 1; + dev_err(ctrl->dev, "Program SCP NACK received\n"); + } + } + } + + if (timeout) { + dev_err_ratelimited(ctrl->dev, + "SCP_addrpage command timeout for Slave %d\n", msg->dev_num); + return SDW_CMD_TIMEOUT; + } + + if (nack) { + dev_err_ratelimited(ctrl->dev, + "SCP_addrpage NACKed for Slave %d\n", msg->dev_num); + return SDW_CMD_FAIL; + } + + if (no_ack) { + dev_dbg_ratelimited(ctrl->dev, + "SCP_addrpage ignored for Slave %d\n", msg->dev_num); + return SDW_CMD_IGNORED; + } + return SDW_CMD_OK; +} + +static int amd_prep_msg(struct amd_sdwc_ctrl *ctrl, struct sdw_msg *msg, int *cmd) +{ + int ret; + + if (msg->page) { + ret = amd_program_scp_addr(ctrl, msg); + if (ret) { + msg->len = 0; + return ret; + } + } + switch (msg->flags) { + case SDW_MSG_FLAG_READ: + *cmd = AMD_SDW_CMD_READ; + break; + case SDW_MSG_FLAG_WRITE: + *cmd = AMD_SDW_CMD_WRITE; + break; + default: + dev_err(ctrl->dev, "Invalid msg cmd: %d\n", msg->flags); + return -EINVAL; + } + return 0; +} + +static unsigned int _amd_sdwc_xfer_msg(struct amd_sdwc_ctrl *ctrl, struct sdw_msg *msg, + int cmd, int cmd_offset) +{ + u64 response = 0; + u32 uword = 0, lword = 0; + int nack = 0, no_ack = 0; + int timeout = 0; + + amd_sdwc_ctl_word_prep(&lword, &uword, cmd, msg, cmd_offset); + response = amd_sdwc_send_cmd_get_resp(ctrl, lword, uword); + + if (response & AMD_SDW_MCP_RESP_ACK) { + if (cmd == AMD_SDW_CMD_READ) + msg->buf[cmd_offset] = FIELD_GET(AMD_SDW_MCP_RESP_RDATA, response); + } else { + no_ack = 1; + if (response == -ETIMEDOUT) { + timeout = 1; + } else if (response & AMD_SDW_MCP_RESP_NACK) { + nack = 1; + dev_err(ctrl->dev, "Program SCP NACK received\n"); + } + } + + if (timeout) { + dev_err_ratelimited(ctrl->dev, "command timeout for Slave %d\n", msg->dev_num); + return SDW_CMD_TIMEOUT; + } + if (nack) { + dev_err_ratelimited(ctrl->dev, + "command response NACK received for Slave %d\n", msg->dev_num); + return SDW_CMD_FAIL; + } + + if (no_ack) { + dev_err_ratelimited(ctrl->dev, "command is ignored for Slave %d\n", msg->dev_num); + return SDW_CMD_IGNORED; + } + return SDW_CMD_OK; +} + +static enum sdw_command_response amd_sdwc_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg) +{ + struct amd_sdwc_ctrl *ctrl = to_amd_sdw(bus); + int ret, i; + int cmd = 0; + + ret = amd_prep_msg(ctrl, msg, &cmd); + if (ret) + return SDW_CMD_FAIL_OTHER; + for (i = 0; i < msg->len; i++) { + ret = _amd_sdwc_xfer_msg(ctrl, msg, cmd, i); + if (ret) + return ret; + } + return SDW_CMD_OK; +} + +static enum sdw_command_response +amd_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num) +{ + struct amd_sdwc_ctrl *ctrl = to_amd_sdw(bus); + struct sdw_msg msg; + + /* Create dummy message with valid device number */ + memset(&msg, 0, sizeof(msg)); + msg.dev_num = dev_num; + return amd_program_scp_addr(ctrl, &msg); +} + +static u32 amd_sdwc_read_ping_status(struct sdw_bus *bus) +{ + struct amd_sdwc_ctrl *ctrl = to_amd_sdw(bus); + u64 response; + u32 slave_stat = 0; + + response = amd_sdwc_send_cmd_get_resp(ctrl, 0, 0); + /* slave status from ping response*/ + slave_stat = FIELD_GET(AMD_SDW_MCP_SLAVE_STAT_0_3, response); + slave_stat |= FIELD_GET(AMD_SDW_MCP_SLAVE_STAT_4_11, response) << 8; + dev_dbg(ctrl->dev, "%s: slave_stat:0x%x\n", __func__, slave_stat); + return slave_stat; +} + +static void amd_sdwc_compute_slave_ports(struct sdw_master_runtime *m_rt, + struct sdw_transport_data *t_data) +{ + struct sdw_slave_runtime *s_rt = NULL; + struct sdw_port_runtime *p_rt; + int port_bo, sample_int; + unsigned int rate, bps, ch = 0; + unsigned int slave_total_ch; + struct sdw_bus_params *b_params = &m_rt->bus->params; + + port_bo = t_data->block_offset; + list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { + rate = m_rt->stream->params.rate; + bps = m_rt->stream->params.bps; + sample_int = (m_rt->bus->params.curr_dr_freq / rate); + slave_total_ch = 0; + + list_for_each_entry(p_rt, &s_rt->port_list, port_node) { + ch = sdw_ch_mask_to_ch(p_rt->ch_mask); + + sdw_fill_xport_params(&p_rt->transport_params, + p_rt->num, false, + SDW_BLK_GRP_CNT_1, + sample_int, port_bo, port_bo >> 8, + t_data->hstart, + t_data->hstop, + SDW_BLK_PKG_PER_PORT, 0x0); + + sdw_fill_port_params(&p_rt->port_params, + p_rt->num, bps, + SDW_PORT_FLOW_MODE_ISOCH, + b_params->s_data_mode); + + port_bo += bps * ch; + slave_total_ch += ch; + } + + if (m_rt->direction == SDW_DATA_DIR_TX && + m_rt->ch_count == slave_total_ch) { + port_bo = t_data->block_offset; + } + } +} + +static int amd_sdwc_compute_params(struct sdw_bus *bus) +{ + struct sdw_transport_data t_data = {0}; + struct sdw_master_runtime *m_rt; + struct sdw_port_runtime *p_rt; + struct sdw_bus_params *b_params = &bus->params; + int port_bo, hstart, hstop, sample_int; + unsigned int rate, bps; + + port_bo = 0; + hstart = 1; + hstop = bus->params.col - 1; + t_data.hstop = hstop; + t_data.hstart = hstart; + + list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { + rate = m_rt->stream->params.rate; + bps = m_rt->stream->params.bps; + sample_int = (bus->params.curr_dr_freq / rate); + list_for_each_entry(p_rt, &m_rt->port_list, port_node) { + port_bo = (p_rt->num * 64) + 1; + dev_dbg(bus->dev, "p_rt->num=%d hstart=%d hstop=%d port_bo=%d\n", + p_rt->num, hstart, hstop, port_bo); + sdw_fill_xport_params(&p_rt->transport_params, p_rt->num, + false, SDW_BLK_GRP_CNT_1, sample_int, + port_bo, port_bo >> 8, hstart, hstop, + SDW_BLK_PKG_PER_PORT, 0x0); + + sdw_fill_port_params(&p_rt->port_params, + p_rt->num, bps, + SDW_PORT_FLOW_MODE_ISOCH, + b_params->m_data_mode); + t_data.hstart = hstart; + t_data.hstop = hstop; + t_data.block_offset = port_bo; + t_data.sub_block_offset = 0; + } + amd_sdwc_compute_slave_ports(m_rt, &t_data); + } + return 0; +} + +static int amd_sdwc_port_params(struct sdw_bus *bus, struct sdw_port_params *p_params, + unsigned int bank) +{ + struct amd_sdwc_ctrl *ctrl = to_amd_sdw(bus); + u32 channel_type, frame_fmt_reg, dpn_frame_fmt; + + dev_dbg(ctrl->dev, "%s: p_params->num:0x%x\n", __func__, p_params->num); + switch (ctrl->instance) { + case ACP_SDW0: + channel_type = p_params->num; + break; + case ACP_SDW1: + channel_type = p_params->num + ACP_SDW0_MAX_DAI; + break; + default: + return -EINVAL; + } + + switch (channel_type) { + case ACP_SDW0_AUDIO_TX: + frame_fmt_reg = ACP_SW_AUDIO_TX_FRAME_FORMAT; + break; + case ACP_SDW0_HS_TX: + frame_fmt_reg = ACP_SW_HEADSET_TX_FRAME_FORMAT; + break; + case ACP_SDW0_BT_TX: + frame_fmt_reg = ACP_SW_BT_TX_FRAME_FORMAT; + break; + case ACP_SDW1_BT_TX: + frame_fmt_reg = ACP_P1_SW_BT_TX_FRAME_FORMAT; + break; + case ACP_SDW0_AUDIO_RX: + frame_fmt_reg = ACP_SW_AUDIO_RX_FRAME_FORMAT; + break; + case ACP_SDW0_HS_RX: + frame_fmt_reg = ACP_SW_HEADSET_RX_FRAME_FORMAT; + break; + case ACP_SDW0_BT_RX: + frame_fmt_reg = ACP_SW_BT_RX_FRAME_FORMAT; + break; + case ACP_SDW1_BT_RX: + frame_fmt_reg = ACP_P1_SW_BT_RX_FRAME_FORMAT; + break; + default: + dev_err(bus->dev, "%s:Invalid channel:%d\n", __func__, channel_type); + return -EINVAL; + } + dpn_frame_fmt = acp_reg_readl(ctrl->mmio + frame_fmt_reg); + u32p_replace_bits(&dpn_frame_fmt, p_params->flow_mode, AMD_DPN_FRAME_FMT_PFM); + u32p_replace_bits(&dpn_frame_fmt, p_params->data_mode, AMD_DPN_FRAME_FMT_PDM); + u32p_replace_bits(&dpn_frame_fmt, p_params->bps - 1, AMD_DPN_FRAME_FMT_WORD_LEN); + acp_reg_writel(dpn_frame_fmt, ctrl->mmio + frame_fmt_reg); + return 0; +} + +static int amd_sdwc_transport_params(struct sdw_bus *bus, + struct sdw_transport_params *params, + enum sdw_reg_bank bank) +{ + struct amd_sdwc_ctrl *ctrl = to_amd_sdw(bus); + u32 ssp_counter_reg; + u32 dpn_frame_fmt; + u32 dpn_sampleinterval; + u32 dpn_hctrl; + u32 dpn_offsetctrl; + u32 dpn_lanectrl; + u32 channel_type; + u32 frame_fmt_reg, sample_int_reg, hctrl_dp0_reg; + u32 offset_reg, lane_ctrl_reg; + + switch (ctrl->instance) { + case ACP_SDW0: + ssp_counter_reg = ACP_SW_SSP_COUNTER; + channel_type = params->port_num; + break; + case ACP_SDW1: + ssp_counter_reg = ACP_P1_SW_SSP_COUNTER; + channel_type = params->port_num + ACP_SDW0_MAX_DAI; + break; + default: + return -EINVAL; + } + acp_reg_writel(AMD_SDW_SSP_COUNTER_VAL, ctrl->mmio + ssp_counter_reg); + dev_dbg(bus->dev, "%s: p_params->num:0x%x entry channel_type:0x%x\n", + __func__, params->port_num, channel_type); + + switch (channel_type) { + case ACP_SDW0_AUDIO_TX: + { + frame_fmt_reg = ACP_SW_AUDIO_TX_FRAME_FORMAT; + sample_int_reg = ACP_SW_AUDIO_TX_SAMPLEINTERVAL; + hctrl_dp0_reg = ACP_SW_AUDIO_TX_HCTRL_DP0; + offset_reg = ACP_SW_AUDIO_TX_OFFSET_DP0; + lane_ctrl_reg = ACP_SW_AUDIO_TX_CHANNEL_ENABLE_DP0; + break; + } + case ACP_SDW0_HS_TX: + { + frame_fmt_reg = ACP_SW_HEADSET_TX_FRAME_FORMAT; + sample_int_reg = ACP_SW_HEADSET_TX_SAMPLEINTERVAL; + hctrl_dp0_reg = ACP_SW_HEADSET_TX_HCTRL; + offset_reg = ACP_SW_HEADSET_TX_OFFSET; + lane_ctrl_reg = ACP_SW_HEADSET_TX_CHANNEL_ENABLE_DP0; + break; + } + case ACP_SDW0_BT_TX: + { + frame_fmt_reg = ACP_SW_BT_TX_FRAME_FORMAT; + sample_int_reg = ACP_SW_BT_TX_SAMPLEINTERVAL; + hctrl_dp0_reg = ACP_SW_BT_TX_HCTRL; + offset_reg = ACP_SW_BT_TX_OFFSET; + lane_ctrl_reg = ACP_SW_BT_TX_CHANNEL_ENABLE_DP0; + break; + } + case ACP_SDW1_BT_TX: + { + frame_fmt_reg = ACP_P1_SW_BT_TX_FRAME_FORMAT; + sample_int_reg = ACP_P1_SW_BT_TX_SAMPLEINTERVAL; + hctrl_dp0_reg = ACP_P1_SW_BT_TX_HCTRL; + offset_reg = ACP_P1_SW_BT_TX_OFFSET; + lane_ctrl_reg = ACP_P1_SW_BT_TX_CHANNEL_ENABLE_DP0; + break; + } + case ACP_SDW0_AUDIO_RX: + { + frame_fmt_reg = ACP_SW_AUDIO_RX_FRAME_FORMAT; + sample_int_reg = ACP_SW_AUDIO_RX_SAMPLEINTERVAL; + hctrl_dp0_reg = ACP_SW_AUDIO_RX_HCTRL_DP0; + offset_reg = ACP_SW_AUDIO_RX_OFFSET_DP0; + lane_ctrl_reg = ACP_SW_AUDIO_RX_CHANNEL_ENABLE_DP0; + break; + } + case ACP_SDW0_HS_RX: + { + frame_fmt_reg = ACP_SW_HEADSET_RX_FRAME_FORMAT; + sample_int_reg = ACP_SW_HEADSET_RX_SAMPLEINTERVAL; + hctrl_dp0_reg = ACP_SW_HEADSET_RX_HCTRL; + offset_reg = ACP_SW_HEADSET_RX_OFFSET; + lane_ctrl_reg = ACP_SW_HEADSET_RX_CHANNEL_ENABLE_DP0; + break; + } + case ACP_SDW0_BT_RX: + { + frame_fmt_reg = ACP_SW_BT_RX_FRAME_FORMAT; + sample_int_reg = ACP_SW_BT_RX_SAMPLEINTERVAL; + hctrl_dp0_reg = ACP_SW_BT_RX_HCTRL; + offset_reg = ACP_SW_BT_RX_OFFSET; + lane_ctrl_reg = ACP_SW_BT_RX_CHANNEL_ENABLE_DP0; + break; + } + case ACP_SDW1_BT_RX: + { + frame_fmt_reg = ACP_P1_SW_BT_RX_FRAME_FORMAT; + sample_int_reg = ACP_P1_SW_BT_RX_SAMPLEINTERVAL; + hctrl_dp0_reg = ACP_P1_SW_BT_RX_HCTRL; + offset_reg = ACP_P1_SW_BT_RX_OFFSET; + lane_ctrl_reg = ACP_P1_SW_BT_RX_CHANNEL_ENABLE_DP0; + break; + } + default: + dev_err(bus->dev, "%s:Invalid channel:%d\n", __func__, channel_type); + return -EINVAL; + } + dpn_frame_fmt = acp_reg_readl(ctrl->mmio + frame_fmt_reg); + u32p_replace_bits(&dpn_frame_fmt, params->blk_pkg_mode, AMD_DPN_FRAME_FMT_BLK_PKG_MODE); + u32p_replace_bits(&dpn_frame_fmt, params->blk_grp_ctrl, AMD_DPN_FRAME_FMT_BLK_GRP_CTRL); + u32p_replace_bits(&dpn_frame_fmt, SDW_STREAM_PCM, AMD_DPN_FRAME_FMT_PCM_OR_PDM); + acp_reg_writel(dpn_frame_fmt, ctrl->mmio + frame_fmt_reg); + + dpn_sampleinterval = params->sample_interval - 1; + acp_reg_writel(dpn_sampleinterval, ctrl->mmio + sample_int_reg); + + dpn_hctrl = FIELD_PREP(AMD_DPN_HCTRL_HSTOP, params->hstop); + dpn_hctrl |= FIELD_PREP(AMD_DPN_HCTRL_HSTART, params->hstart); + acp_reg_writel(dpn_hctrl, ctrl->mmio + hctrl_dp0_reg); + + dpn_offsetctrl = FIELD_PREP(AMD_DPN_OFFSET_CTRL_1, params->offset1); + dpn_offsetctrl |= FIELD_PREP(AMD_DPN_OFFSET_CTRL_2, params->offset2); + acp_reg_writel(dpn_offsetctrl, ctrl->mmio + offset_reg); + + dpn_lanectrl = acp_reg_readl(ctrl->mmio + lane_ctrl_reg); + u32p_replace_bits(&dpn_lanectrl, params->lane_ctrl, AMD_DPN_CH_EN_LCTRL); + acp_reg_writel(dpn_lanectrl, ctrl->mmio + lane_ctrl_reg); + return 0; +} + +static int amd_sdwc_port_enable(struct sdw_bus *bus, + struct sdw_enable_ch *enable_ch, + unsigned int bank) +{ + struct amd_sdwc_ctrl *ctrl = to_amd_sdw(bus); + u32 dpn_ch_enable; + u32 ch_enable_reg, channel_type; + + switch (ctrl->instance) { + case ACP_SDW0: + channel_type = enable_ch->port_num; + break; + case ACP_SDW1: + channel_type = enable_ch->port_num + ACP_SDW0_MAX_DAI; + break; + default: + return -EINVAL; + } + + switch (channel_type) { + case ACP_SDW0_AUDIO_TX: + ch_enable_reg = ACP_SW_AUDIO_TX_CHANNEL_ENABLE_DP0; + break; + case ACP_SDW0_HS_TX: + ch_enable_reg = ACP_SW_HEADSET_TX_CHANNEL_ENABLE_DP0; + break; + case ACP_SDW0_BT_TX: + ch_enable_reg = ACP_SW_BT_TX_CHANNEL_ENABLE_DP0; + break; + case ACP_SDW1_BT_TX: + ch_enable_reg = ACP_P1_SW_BT_TX_CHANNEL_ENABLE_DP0; + break; + case ACP_SDW0_AUDIO_RX: + ch_enable_reg = ACP_SW_AUDIO_RX_CHANNEL_ENABLE_DP0; + break; + case ACP_SDW0_HS_RX: + ch_enable_reg = ACP_SW_HEADSET_RX_CHANNEL_ENABLE_DP0; + break; + case ACP_SDW0_BT_RX: + ch_enable_reg = ACP_SW_BT_RX_CHANNEL_ENABLE_DP0; + break; + case ACP_SDW1_BT_RX: + ch_enable_reg = ACP_P1_SW_BT_RX_CHANNEL_ENABLE_DP0; + break; + default: + dev_err(bus->dev, "%s:Invalid channel:%d\n", __func__, channel_type); + return -EINVAL; + } + + dpn_ch_enable = acp_reg_readl(ctrl->mmio + ch_enable_reg); + u32p_replace_bits(&dpn_ch_enable, enable_ch->ch_mask, AMD_DPN_CH_EN_CHMASK); + if (enable_ch->enable) + acp_reg_writel(dpn_ch_enable, ctrl->mmio + ch_enable_reg); + else + acp_reg_writel(0, ctrl->mmio + ch_enable_reg); + return 0; +} + +static int sdw_master_read_amd_prop(struct sdw_bus *bus) +{ + struct amd_sdwc_ctrl *ctrl = to_amd_sdw(bus); + struct fwnode_handle *link; + struct sdw_master_prop *prop; + u32 quirk_mask = 0; + u32 wake_en_mask = 0; + u32 power_mode_mask = 0; + char name[32]; + + prop = &bus->prop; + /* Find master handle */ + snprintf(name, sizeof(name), "mipi-sdw-link-%d-subproperties", bus->link_id); + link = device_get_named_child_node(bus->dev, name); + if (!link) { + dev_err(bus->dev, "Master node %s not found\n", name); + return -EIO; + } + fwnode_property_read_u32(link, "amd-sdw-enable", &quirk_mask); + if (!(quirk_mask & AMD_SDW_QUIRK_MASK_BUS_ENABLE)) + prop->hw_disabled = true; + prop->quirks = SDW_MASTER_QUIRKS_CLEAR_INITIAL_CLASH | + SDW_MASTER_QUIRKS_CLEAR_INITIAL_PARITY; + + fwnode_property_read_u32(link, "amd-sdw-wake-enable", &wake_en_mask); + ctrl->wake_en_mask = wake_en_mask; + fwnode_property_read_u32(link, "amd-sdw-power-mode", &power_mode_mask); + ctrl->power_mode_mask = power_mode_mask; + return 0; +} + +static int amd_prop_read(struct sdw_bus *bus) +{ + sdw_master_read_prop(bus); + sdw_master_read_amd_prop(bus); + return 0; +} + +static const struct sdw_master_port_ops amd_sdwc_port_ops = { + .dpn_set_port_params = amd_sdwc_port_params, + .dpn_set_port_transport_params = amd_sdwc_transport_params, + .dpn_port_enable_ch = amd_sdwc_port_enable, +}; + +static const struct sdw_master_ops amd_sdwc_ops = { + .read_prop = amd_prop_read, + .xfer_msg = amd_sdwc_xfer_msg, + .reset_page_addr = amd_reset_page_addr, + .read_ping_status = amd_sdwc_read_ping_status, +}; + +static void amd_sdwc_probe_work(struct work_struct *work) +{ + struct amd_sdwc_ctrl *ctrl = container_of(work, struct amd_sdwc_ctrl, probe_work); + struct sdw_master_prop *prop; + int ret; + + prop = &ctrl->bus.prop; + if (!prop->hw_disabled) { + ret = amd_enable_sdw_pads(ctrl); + if (ret) + return; + ret = amd_init_sdw_controller(ctrl); + if (ret) + return; + amd_enable_sdw_interrupts(ctrl); + ret = amd_enable_sdw_controller(ctrl); + if (ret) + return; + ret = amd_sdwc_set_frameshape(ctrl, 50, 10); + if (!ret) + ctrl->startup_done = true; + } +} + +static int amd_sdwc_probe(struct platform_device *pdev) +{ + const struct acp_sdw_pdata *pdata = pdev->dev.platform_data; + struct resource *res; + struct device *dev = &pdev->dev; + struct sdw_master_prop *prop; + struct sdw_bus_params *params; + struct amd_sdwc_ctrl *ctrl; + int ret; + + if (!pdev->dev.platform_data) { + dev_err(&pdev->dev, "platform_data not retrieved\n"); + return -ENODEV; + } + ctrl = devm_kzalloc(&pdev->dev, sizeof(struct amd_sdwc_ctrl), GFP_KERNEL); + if (!ctrl) + return -ENOMEM; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n"); + return -ENOMEM; + } + ctrl->mmio = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (IS_ERR(ctrl->mmio)) { + dev_err(&pdev->dev, "mmio not found\n"); + return PTR_ERR(ctrl->mmio); + } + ctrl->instance = pdata->instance; + ctrl->sdw_lock = pdata->sdw_lock; + ctrl->rows_index = sdw_find_row_index(50); + ctrl->cols_index = sdw_find_col_index(10); + + ctrl->dev = dev; + dev_set_drvdata(&pdev->dev, ctrl); + + ctrl->bus.ops = &amd_sdwc_ops; + ctrl->bus.port_ops = &amd_sdwc_port_ops; + ctrl->bus.compute_params = &amd_sdwc_compute_params; + ctrl->bus.clk_stop_timeout = 1; + switch (ctrl->instance) { + case ACP_SDW0: + ctrl->num_dout_ports = AMD_SDW0_MAX_TX_PORTS; + ctrl->num_din_ports = AMD_SDW0_MAX_RX_PORTS; + break; + case ACP_SDW1: + ctrl->num_dout_ports = AMD_SDW1_MAX_TX_PORTS; + ctrl->num_din_ports = AMD_SDW1_MAX_RX_PORTS; + break; + default: + return -EINVAL; + } + params = &ctrl->bus.params; + params->max_dr_freq = AMD_SDW_DEFAULT_CLK_FREQ * 2; + params->curr_dr_freq = AMD_SDW_DEFAULT_CLK_FREQ * 2; + params->col = 10; + params->row = 50; + + prop = &ctrl->bus.prop; + prop->clk_freq = &amd_sdwc_freq_tbl[0]; + prop->mclk_freq = AMD_SDW_BUS_BASE_FREQ; + ctrl->bus.link_id = ctrl->instance; + ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode); + if (ret) { + dev_err(dev, "Failed to register Soundwire controller (%d)\n", + ret); + return ret; + } + INIT_WORK(&ctrl->probe_work, amd_sdwc_probe_work); + schedule_work(&ctrl->probe_work); + return 0; +} + +static int amd_sdwc_remove(struct platform_device *pdev) +{ + struct amd_sdwc_ctrl *ctrl = dev_get_drvdata(&pdev->dev); + int ret; + + amd_disable_sdw_interrupts(ctrl); + sdw_bus_master_delete(&ctrl->bus); + ret = amd_disable_sdw_controller(ctrl); + return ret; +} + +static struct platform_driver amd_sdwc_driver = { + .probe = &amd_sdwc_probe, + .remove = &amd_sdwc_remove, + .driver = { + .name = "amd_sdw_controller", + } +}; +module_platform_driver(amd_sdwc_driver); + +MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); +MODULE_DESCRIPTION("AMD soundwire driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRV_NAME); + diff --git a/drivers/soundwire/amd_master.h b/drivers/soundwire/amd_master.h new file mode 100644 index 000000000000..42f32ca0c7a8 --- /dev/null +++ b/drivers/soundwire/amd_master.h @@ -0,0 +1,279 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. + */ + +#ifndef __AMD_MASTER_H +#define __AMD_MASTER_H + +#define ACP_PAD_PULLDOWN_CTRL 0x0001448 +#define ACP_SW_PAD_KEEPER_EN 0x0001454 +#define ACP_SW_WAKE_EN 0x0001458 +#define ACP_SW1_WAKE_EN 0x0001460 +#define ACP_SW_I2S_ERROR_REASON 0x00018B4 + +#define ACP_EXTERNAL_INTR_ENB 0x0001A00 +#define ACP_EXTERNAL_INTR_CNTL 0x0001A04 +#define ACP_EXTERNAL_INTR_CNTL1 0x0001A08 +#define ACP_EXTERNAL_INTR_STAT 0x0001A0C +#define ACP_EXTERNAL_INTR_STAT1 0x0001A10 +#define ACP_ERROR_STATUS 0x0001A4C +#define ACP_P1_SW_I2S_ERROR_REASON 0x0001A50 + +#define ACP_SW_EN 0x0003000 +#define ACP_SW_EN_STATUS 0x0003004 +#define ACP_SW_FRAMESIZE 0x0003008 +#define ACP_SW_SSP_COUNTER 0x000300C +#define ACP_SW_AUDIO_TX_EN 0x0003010 +#define ACP_SW_AUDIO_TX_EN_STATUS 0x0003014 +#define ACP_SW_AUDIO_TX_FRAME_FORMAT 0x0003018 +#define ACP_SW_AUDIO_TX_SAMPLEINTERVAL 0x000301C +#define ACP_SW_AUDIO_TX_HCTRL_DP0 0x0003020 +#define ACP_SW_AUDIO_TX_HCTRL_DP1 0x0003024 +#define ACP_SW_AUDIO_TX_HCTRL_DP2 0x0003028 +#define ACP_SW_AUDIO_TX_HCTRL_DP3 0x000302C +#define ACP_SW_AUDIO_TX_OFFSET_DP0 0x0003030 +#define ACP_SW_AUDIO_TX_OFFSET_DP1 0x0003034 +#define ACP_SW_AUDIO_TX_OFFSET_DP2 0x0003038 +#define ACP_SW_AUDIO_TX_OFFSET_DP3 0x000303C +#define ACP_SW_AUDIO_TX_CHANNEL_ENABLE_DP0 0x0003040 +#define ACP_SW_AUDIO_TX_CHANNEL_ENABLE_DP1 0x0003044 +#define ACP_SW_AUDIO_TX_CHANNEL_ENABLE_DP2 0x0003048 +#define ACP_SW_AUDIO_TX_CHANNEL_ENABLE_DP3 0x000304C +#define ACP_SW_BT_TX_EN 0x0003050 +#define ACP_SW_BT_TX_EN_STATUS 0x0003054 +#define ACP_SW_BT_TX_FRAME_FORMAT 0x0003058 +#define ACP_SW_BT_TX_SAMPLEINTERVAL 0x000305C +#define ACP_SW_BT_TX_HCTRL 0x0003060 +#define ACP_SW_BT_TX_OFFSET 0x0003064 +#define ACP_SW_BT_TX_CHANNEL_ENABLE_DP0 0x0003068 +#define ACP_SW_HEADSET_TX_EN 0x000306C +#define ACP_SW_HEADSET_TX_EN_STATUS 0x0003070 +#define ACP_SW_HEADSET_TX_FRAME_FORMAT 0x0003074 +#define ACP_SW_HEADSET_TX_SAMPLEINTERVAL 0x0003078 +#define ACP_SW_HEADSET_TX_HCTRL 0x000307C +#define ACP_SW_HEADSET_TX_OFFSET 0x0003080 +#define ACP_SW_HEADSET_TX_CHANNEL_ENABLE_DP0 0x0003084 +#define ACP_SW_AUDIO_RX_EN 0x0003088 +#define ACP_SW_AUDIO_RX_EN_STATUS 0x000308C +#define ACP_SW_AUDIO_RX_FRAME_FORMAT 0x0003090 +#define ACP_SW_AUDIO_RX_SAMPLEINTERVAL 0x0003094 +#define ACP_SW_AUDIO_RX_HCTRL_DP0 0x0003098 +#define ACP_SW_AUDIO_RX_HCTRL_DP1 0x000309C +#define ACP_SW_AUDIO_RX_HCTRL_DP2 0x0003100 +#define ACP_SW_AUDIO_RX_HCTRL_DP3 0x0003104 +#define ACP_SW_AUDIO_RX_OFFSET_DP0 0x0003108 +#define ACP_SW_AUDIO_RX_OFFSET_DP1 0x000310C +#define ACP_SW_AUDIO_RX_OFFSET_DP2 0x0003110 +#define ACP_SW_AUDIO_RX_OFFSET_DP3 0x0003114 +#define ACP_SW_AUDIO_RX_CHANNEL_ENABLE_DP0 0x0003118 +#define ACP_SW_AUDIO_RX_CHANNEL_ENABLE_DP1 0x000311C +#define ACP_SW_AUDIO_RX_CHANNEL_ENABLE_DP2 0x0003120 +#define ACP_SW_AUDIO_RX_CHANNEL_ENABLE_DP3 0x0003124 +#define ACP_SW_BT_RX_EN 0x0003128 +#define ACP_SW_BT_RX_EN_STATUS 0x000312C +#define ACP_SW_BT_RX_FRAME_FORMAT 0x0003130 +#define ACP_SW_BT_RX_SAMPLEINTERVAL 0x0003134 +#define ACP_SW_BT_RX_HCTRL 0x0003138 +#define ACP_SW_BT_RX_OFFSET 0x000313C +#define ACP_SW_BT_RX_CHANNEL_ENABLE_DP0 0x0003140 +#define ACP_SW_HEADSET_RX_EN 0x0003144 +#define ACP_SW_HEADSET_RX_EN_STATUS 0x0003148 +#define ACP_SW_HEADSET_RX_FRAME_FORMAT 0x000314C +#define ACP_SW_HEADSET_RX_SAMPLEINTERVAL 0x0003150 +#define ACP_SW_HEADSET_RX_HCTRL 0x0003154 +#define ACP_SW_HEADSET_RX_OFFSET 0x0003158 +#define ACP_SW_HEADSET_RX_CHANNEL_ENABLE_DP0 0x000315C +#define ACP_SW_BPT_PORT_EN 0x0003160 +#define ACP_SW_BPT_PORT_EN_STATUS 0x0003164 +#define ACP_SW_BPT_PORT_FRAME_FORMAT 0x0003168 +#define ACP_SW_BPT_PORT_SAMPLEINTERVAL 0x000316C +#define ACP_SW_BPT_PORT_HCTRL 0x0003170 +#define ACP_SW_BPT_PORT_OFFSET 0x0003174 +#define ACP_SW_BPT_PORT_CHANNEL_ENABLE 0x0003178 +#define ACP_SW_BPT_PORT_FIRST_BYTE_ADDR 0x000317C +#define ACP_SW_CLK_RESUME_CTRL 0x0003180 +#define ACP_SW_CLK_RESUME_DELAY_CNTR 0x0003184 +#define ACP_SW_BUS_RESET_CTRL 0x0003188 +#define ACP_SW_PRBS_ERR_STATUS 0x000318C +#define SW_IMM_CMD_UPPER_WORD 0x0003230 +#define SW_IMM_CMD_LOWER_QWORD 0x0003234 +#define SW_IMM_RESP_UPPER_WORD 0x0003238 +#define SW_IMM_RESP_LOWER_QWORD 0x000323C +#define SW_IMM_CMD_STS 0x0003240 +#define SW_BRA_BASE_ADDRESS 0x0003244 +#define SW_BRA_TRANSFER_SIZE 0x0003248 +#define SW_BRA_DMA_BUSY 0x000324C +#define SW_BRA_RESP 0x0003250 +#define SW_BRA_RESP_FRAME_ADDR 0x0003254 +#define SW_BRA_CURRENT_TRANSFER_SIZE 0x0003258 +#define SW_STATE_CHANGE_STATUS_0TO7 0x000325C +#define SW_STATE_CHANGE_STATUS_8TO11 0x0003260 +#define SW_STATE_CHANGE_STATUS_MASK_0TO7 0x0003264 +#define SW_STATE_CHANGE_STATUS_MASK_8TO11 0x0003268 +#define SW_CLK_FREQUENCY_CTRL 0x000326C +#define SW_ERROR_INTR_MASK 0x0003270 +#define SW_PHY_TEST_MODE_DATA_OFF 0x0003274 + +#define ACP_P1_SW_EN 0x0003C00 +#define ACP_P1_SW_EN_STATUS 0x0003C04 +#define ACP_P1_SW_FRAMESIZE 0x0003C08 +#define ACP_P1_SW_SSP_COUNTER 0x0003C0C +#define ACP_P1_SW_BT_TX_EN 0x0003C50 +#define ACP_P1_SW_BT_TX_EN_STATUS 0x0003C54 +#define ACP_P1_SW_BT_TX_FRAME_FORMAT 0x0003C58 +#define ACP_P1_SW_BT_TX_SAMPLEINTERVAL 0x0003C5C +#define ACP_P1_SW_BT_TX_HCTRL 0x0003C60 +#define ACP_P1_SW_BT_TX_OFFSET 0x0003C64 +#define ACP_P1_SW_BT_TX_CHANNEL_ENABLE_DP0 0x0003C68 +#define ACP_P1_SW_BT_RX_EN 0x0003D28 +#define ACP_P1_SW_BT_RX_EN_STATUS 0x0003D2C +#define ACP_P1_SW_BT_RX_FRAME_FORMAT 0x0003D30 +#define ACP_P1_SW_BT_RX_SAMPLEINTERVAL 0x0003D34 +#define ACP_P1_SW_BT_RX_HCTRL 0x0003D38 +#define ACP_P1_SW_BT_RX_OFFSET 0x0003D3C +#define ACP_P1_SW_BT_RX_CHANNEL_ENABLE_DP0 0x0003D40 +#define ACP_P1_SW_BPT_PORT_EN 0x0003D60 +#define ACP_P1_SW_BPT_PORT_EN_STATUS 0x0003D64 +#define ACP_P1_SW_BPT_PORT_FRAME_FORMAT 0x0003D68 +#define ACP_P1_SW_BPT_PORT_SAMPLEINTERVAL 0x0003D6C +#define ACP_P1_SW_BPT_PORT_HCTRL 0x0003D70 +#define ACP_P1_SW_BPT_PORT_OFFSET 0x0003D74 +#define ACP_P1_SW_BPT_PORT_CHANNEL_ENABLE 0x0003D78 +#define ACP_P1_SW_BPT_PORT_FIRST_BYTE_ADDR 0x0003D7C +#define ACP_P1_SW_CLK_RESUME_CTRL 0x0003D80 +#define ACP_P1_SW_CLK_RESUME_DELAY_CNTR 0x0003D84 +#define ACP_P1_SW_BUS_RESET_CTRL 0x0003D88 +#define ACP_P1_SW_PRBS_ERR_STATUS 0x0003D8C + +#define P1_SW_IMM_CMD_UPPER_WORD 0x0003E30 +#define P1_SW_IMM_CMD_LOWER_QWORD 0x0003E34 +#define P1_SW_IMM_RESP_UPPER_WORD 0x0003E38 +#define P1_SW_IMM_RESP_LOWER_QWORD 0x0003E3C +#define P1_SW_IMM_CMD_STS 0x0003E40 +#define P1_SW_BRA_BASE_ADDRESS 0x0003E44 +#define P1_SW_BRA_TRANSFER_SIZE 0x0003E48 +#define P1_SW_BRA_DMA_BUSY 0x0003E4C +#define P1_SW_BRA_RESP 0x0003E50 +#define P1_SW_BRA_RESP_FRAME_ADDR 0x0003E54 +#define P1_SW_BRA_CURRENT_TRANSFER_SIZE 0x0003E58 +#define P1_SW_STATE_CHANGE_STATUS_0TO7 0x0003E5C +#define P1_SW_STATE_CHANGE_STATUS_8TO11 0x0003E60 +#define P1_SW_STATE_CHANGE_STATUS_MASK_0TO7 0x0003E64 +#define P1_SW_STATE_CHANGE_STATUS_MASK_8TO11 0x0003E68 +#define P1_SW_CLK_FREQUENCY_CTRL 0x0003E6C +#define P1_SW_ERROR_INTR_MASK 0x0003E70 +#define P1_SW_PHY_TEST_MODE_DATA_OFF 0x0003E74 + +#define ACP_PHY_BASE_ADDRESS 0x1240000 +#define AMD_DELAY_LOOP_ITERATION 1000 +#define AMD_SDW_DEFAULT_CLK_FREQ 12000000 +#define AMD_SDW_RETRY_COUNT 1000 + +#define AMD_SDW_MCP_RESP_ACK BIT(0) +#define AMD_SDW_MCP_RESP_NACK BIT(1) +#define AMD_SDW_MCP_RESP_RDATA GENMASK(14, 7) + +#define AMD_SDW_MCP_CMD_SSP_TAG BIT(31) +#define AMD_SDW_MCP_CMD_COMMAND GENMASK(14, 12) +#define AMD_SDW_MCP_CMD_DEV_ADDR GENMASK(11, 8) +#define AMD_SDW_MCP_CMD_REG_ADDR_HIGH GENMASK(7, 0) +#define AMD_SDW_MCP_CMD_REG_ADDR_LOW GENMASK(31, 24) +#define AMD_SDW_MCP_CMD_REG_DATA GENMASK(14, 7) +#define AMD_SDW_MCP_SLAVE_STAT_0_3 GENMASK(14, 7) +#define AMD_SDW_MCP_SLAVE_STAT_4_11 GENMASK(39, 24) +#define AMD_SDW_MCP_SLAVE_STATUS_MASK GENMASK(1, 0) +#define AMD_SDW_MCP_SLAVE_STATUS_BITS GENMASK(3, 2) +#define AMD_SDW_MCP_SLAVE_STATUS_8TO_11 GENMASK(15, 0) +#define AMD_SDW_MCP_SLAVE_STATUS_VALID_MASK(x) BIT(((x) * 4)) +#define AMD_SDW_MCP_SLAVE_STAT_SHIFT_MASK(x) (((x) * 4) + 1) + +#define AMD_SDW_MASTER_SUSPEND_DELAY_MS 3000 +#define AMD_SDW_CLK_STOP_MAX_RETRY_COUNT 100 +#define AMD_SDW_QUIRK_MASK_BUS_ENABLE BIT(0) + +#define AMD_SDW_IMM_RES_VALID 1 +#define AMD_SDW_IMM_CMD_BUSY 2 +#define AMD_SDW_ENABLE 1 +#define AMD_SDW_DISABLE 0 +#define AMD_SDW_BUS_RESET_CLEAR_REQ 0 +#define AMD_SDW_BUS_RESET_REQ 1 +#define AMD_SDW_BUS_RESET_DONE 2 +#define AMD_SDW_BUS_BASE_FREQ 24000000 + +#define AMD_SDW0_EXT_INTR_MASK 0x200000 +#define AMD_SDW1_EXT_INTR_MASK 4 +#define AMD_SDW_IRQ_MASK_0TO7 0x77777777 +#define AMD_SDW_IRQ_MASK_8TO11 0x000D7777 +#define AMD_SDW_IRQ_ERROR_MASK 0xFF +#define AMD_SDW_MAX_FREQ_NUM 1 +#define AMD_SDW0_MAX_TX_PORTS 3 +#define AMD_SDW0_MAX_RX_PORTS 3 +#define AMD_SDW1_MAX_TX_PORTS 1 +#define AMD_SDW1_MAX_RX_PORTS 1 + +#define AMD_SDW_SLAVE_0_ATTACHED 5 +#define AMD_SDW_SSP_COUNTER_VAL 3 + +#define AMD_DPN_FRAME_FMT_PFM GENMASK(1, 0) +#define AMD_DPN_FRAME_FMT_PDM GENMASK(3, 2) +#define AMD_DPN_FRAME_FMT_BLK_PKG_MODE BIT(4) +#define AMD_DPN_FRAME_FMT_BLK_GRP_CTRL GENMASK(6, 5) +#define AMD_DPN_FRAME_FMT_WORD_LEN GENMASK(12, 7) +#define AMD_DPN_FRAME_FMT_PCM_OR_PDM BIT(13) +#define AMD_DPN_HCTRL_HSTOP GENMASK(3, 0) +#define AMD_DPN_HCTRL_HSTART GENMASK(7, 4) +#define AMD_DPN_OFFSET_CTRL_1 GENMASK(7, 0) +#define AMD_DPN_OFFSET_CTRL_2 GENMASK(15, 8) +#define AMD_DPN_CH_EN_LCTRL GENMASK(2, 0) +#define AMD_DPN_CH_EN_CHMASK GENMASK(10, 3) +#define AMD_SDW_STAT_MAX_RETRY_COUNT 100 +#define AMD_SDW0_PAD_PULLDOWN_CTRL_ENABLE_MASK 0x7F9F +#define AMD_SDW1_PAD_PULLDOWN_CTRL_ENABLE_MASK 0x7FFA +#define AMD_SDW0_PAD_PULLDOWN_CTRL_DISABLE_MASK 0x60 +#define AMD_SDW1_PAD_PULLDOWN_CTRL_DISABLE_MASK 5 +#define AMD_SDW0_PAD_KEEPER_EN_MASK 1 +#define AMD_SDW1_PAD_KEEPER_EN_MASK 0x10 +#define AMD_SDW0_PAD_KEEPER_DISABLE_MASK 0x1E +#define AMD_SDW1_PAD_KEEPER_DISABLE_MASK 0xF + +enum amd_sdw_channel { + /* SDW0 */ + ACP_SDW0_AUDIO_TX = 0, + ACP_SDW0_BT_TX, + ACP_SDW0_HS_TX, + ACP_SDW0_AUDIO_RX, + ACP_SDW0_BT_RX, + ACP_SDW0_HS_RX, + /* SDW1 */ + ACP_SDW1_BT_TX, + ACP_SDW1_BT_RX, +}; + +enum amd_sdw_cmd_type { + AMD_SDW_CMD_PING = 0, + AMD_SDW_CMD_READ = 2, + AMD_SDW_CMD_WRITE = 3, +}; + +static u32 amd_sdwc_freq_tbl[AMD_SDW_MAX_FREQ_NUM] = { + AMD_SDW_DEFAULT_CLK_FREQ, +}; + +struct sdw_transport_data { + int hstart; + int hstop; + int block_offset; + int sub_block_offset; +}; + +static inline u32 acp_reg_readl(void __iomem *base_addr) +{ + return readl(base_addr); +} + +static inline void acp_reg_writel(u32 val, void __iomem *base_addr) +{ + writel(val, base_addr); +} +#endif diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h index f0123815af46..5ec39f8c2f2e 100644 --- a/include/linux/soundwire/sdw_amd.h +++ b/include/linux/soundwire/sdw_amd.h @@ -10,9 +10,30 @@ #define AMD_SDW_CLK_STOP_MODE 1 #define AMD_SDW_POWER_OFF_MODE 2 +#define ACP_SDW0 0 +#define ACP_SDW1 1 +#define ACP_SDW0_MAX_DAI 6 struct acp_sdw_pdata { u16 instance; struct mutex *sdw_lock; }; + +struct amd_sdwc_ctrl { + struct sdw_bus bus; + struct device *dev; + void __iomem *mmio; + struct work_struct probe_work; + struct mutex *sdw_lock; + int num_din_ports; + int num_dout_ports; + int cols_index; + int rows_index; + u32 instance; + u32 quirks; + u32 wake_en_mask; + int num_ports; + bool startup_done; + u32 power_mode_mask; +}; #endif From patchwork Wed Jan 11 09:02:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096286 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 BF5EAC54EBE for ; Wed, 11 Jan 2023 09:01:38 +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 5F2205608; Wed, 11 Jan 2023 10:00:45 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5F2205608 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427695; bh=YwcK02eSX1BHqbIlmmoAneQV4Jt+CaWFtD4rhuHfIbM=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=k9AtGf/gRhHE/ue7A1b26k3Y7ilxpTHfbJFn55dKXzPdsD5IIhq0boOr099HBrs8n IqUb566e6qY4ivAfoAap/1+8MsKcLxhOXTOO1uAZ23SQ275CYbAi+5efqRCv4quw9I qQTHrxKt2Z4G8pkZTumVTKu7XA+dY21Fzscrfp20= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 19B9EF80424; Wed, 11 Jan 2023 10:00:16 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9FC38F80424; Wed, 11 Jan 2023 10:00:14 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2088.outbound.protection.outlook.com [40.107.244.88]) (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 B50D8F8055A for ; Wed, 11 Jan 2023 10:00:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B50D8F8055A 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=Jn3EYI4a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gR8MQ+tIwhdlJzfK8asP+WxTgGietYKFr2jts6B8RqGOFidRJYn/WQUECZg12iIPQ2STWvxteIJSJC3T5Qw32zD9pVMUmRAptgNwtIoJNkYHludtC9599tCU2ZDQE07S2oyp2mL2oYO4OjjEfLy72U5cI1A1vjzUyyiLCNGM5X8coi2Gj0x7lpHEXDOT+yoIUxl1E5hwwhLmOKxvppaiMAotlXKlIXwFKnZ6GLftdtdPaj12qQ84SgplJphww2Ktj4E7UJEkdFVctyj5ehdhrEpt1MV+uIVDNN9HqM+H2XUCk5LRD3O8duS+wMYJUejVIk786lSGS67GDjq9OpUTWw== 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=iAc5dacAJ79hXT50ErIFF9zPVuQvxlhphQZsdV0Vn+g=; b=I+f5iRguCUynE64JnYGQe4tkGuX5CUhxnxtNN4V9sKe3JQM+UrQCZSgmyonh5w6UnMm8pY3+H0MqMh++l6WKassJpDm9a4DM17PfupcU4vLhXPfD43xjeZaOI4npSCl53UVIcYJcElO5Lk3pOY98ceilUAKTvpzlsBxyu9XG7upj/lkafa25jHFgiYOFJUZKJQQyMTPM/pN3QuFu2wXJlAp5FnrBVVxHVaJiUnl3wZthXIb+ZxpVNbxS5aPxVCbhahIaQaweCevstqYWmiVGNZT5MVl/f9RmcLcaCaMKhG9JOB8ZMNtKCv7n+x6HA39nGJUx7L511+rOLs78E+HFwg== 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 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=iAc5dacAJ79hXT50ErIFF9zPVuQvxlhphQZsdV0Vn+g=; b=Jn3EYI4aRVlPlS063Q+iwmmgMXH3/7yQU4h+vwy0bSlShbg1AX5V3KOn/wqd41He9JXLrwv8LaJRj8sK1F39g08HX4aW6zb6iYdXeLIIcENdwEoAcuHqzBTZRp8sCw3PBuAcHNSdVo8QizPHrQVyD3WSxCmAXFutdLvtVKHEWiQ= Received: from DM5PR07CA0097.namprd07.prod.outlook.com (2603:10b6:4:ae::26) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:00:05 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ae:cafe::dd) by DM5PR07CA0097.outlook.office365.com (2603:10b6:4:ae::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:00:05 +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 DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:00:05 +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.2375.34; Wed, 11 Jan 2023 03:00:01 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 03:00:00 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 02:59:50 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 03/19] soundwire: amd: register sdw controller dai ops Date: Wed, 11 Jan 2023 14:32:06 +0530 Message-ID: <20230111090222.2016499-4-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT016:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b7c2cf8-a1f8-45f1-0e94-08daf3b23b4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oDzD3SXckIuLV7cOHyH8QcVBoBF63GGem8FymxF1V79/776ckHC/KcPqsK50y6FHYbL6SmqqdIKywNeSQLbr89qkRsY18ef3GXBCorKQJttcNB/Rr9XijyqzGGvq2bZbm5VWaQpveWLZ+6ljkKu8AMwd5/8a3K2/sVNgSZphhikm/I9/cyyWAh0Eu6pyL9hb6ahHHOHV07p6aZT9BJgzvLN6aOScCuobtYxPyV0ERjZnrz4JNt1N2usU/QNkxByl7UQDlhovPyIe/E95ZrTNMcaYxSErgGzsX42KSvmLvMMiu/I7bn4mtP99tTrnw8bLCwkMVuvAhuxcRx6XHYOWfewDo2s540+tkYEbZRMi0sOdgd5u6Or0bC5ezIrfJuKGKZoNRvvZnq7l7jS8jMP1HZ/1YD7aGkRieoCUTDPG239jNkT3kZem7/O86Eua6ersN/17P7h4MlaocFOxtZEfOJcy5nbJK2fEQJjOtm0D3seCjr7Ef7OE/DnTNoSr2KySEjnZfe8L5zK41EN6xBZaz1cdxBg/XsIuyutToPUQawShtssmiw5AJ5v+BIHXKCU2ZzHDf1ZO6I9YxFDb43QlUC/nhJeU1SvQvB2WqKFbethpZandPvZ5lh1m1I0LiB5Tt3MHVLq638u7najJlIUCDLr1GQBgwUNe3XH+Hg0x1prRQzrk+44G+bbxrsd8Uu2isRdhlgYxiwSZ0ZoCWGJqFJlY1Ba799yzHeby4kYvJTg= 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:(13230022)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199015)(36840700001)(40470700004)(46966006)(82310400005)(2906002)(36756003)(5660300002)(8936002)(70206006)(6666004)(8676002)(41300700001)(2616005)(70586007)(316002)(7696005)(4326008)(54906003)(110136005)(478600001)(40480700001)(26005)(186003)(336012)(1076003)(426003)(86362001)(47076005)(83380400001)(36860700001)(40460700003)(356005)(81166007)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:00:05.0173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b7c2cf8-a1f8-45f1-0e94-08daf3b23b4f 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: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, Basavaraj.Hiregoudar@amd.com, Pierre-Louis Bossart , open list , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Sanyog Kale , Bard Liao Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Register dai ops for two controller instances. Signed-off-by: Vijendar Mukunda --- drivers/soundwire/amd_master.c | 186 ++++++++++++++++++++++++++++++ include/linux/soundwire/sdw_amd.h | 21 ++++ 2 files changed, 207 insertions(+) diff --git a/drivers/soundwire/amd_master.c b/drivers/soundwire/amd_master.c index 7e1f618254ac..93bffe6ff9e2 100644 --- a/drivers/soundwire/amd_master.c +++ b/drivers/soundwire/amd_master.c @@ -952,6 +952,186 @@ static const struct sdw_master_ops amd_sdwc_ops = { .read_ping_status = amd_sdwc_read_ping_status, }; +static int amd_sdwc_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct amd_sdwc_ctrl *ctrl = snd_soc_dai_get_drvdata(dai); + struct sdw_amd_dma_data *dma; + struct sdw_stream_config sconfig; + struct sdw_port_config *pconfig; + int ch, dir; + int ret; + + dma = snd_soc_dai_get_dma_data(dai, substream); + if (!dma) + return -EIO; + + ch = params_channels(params); + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) + dir = SDW_DATA_DIR_RX; + else + dir = SDW_DATA_DIR_TX; + dev_dbg(ctrl->dev, "%s: dir:%d dai->id:0x%x\n", __func__, dir, dai->id); + dma->hw_params = params; + + sconfig.direction = dir; + sconfig.ch_count = ch; + sconfig.frame_rate = params_rate(params); + sconfig.type = dma->stream_type; + + sconfig.bps = snd_pcm_format_width(params_format(params)); + + /* Port configuration */ + pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL); + if (!pconfig) { + ret = -ENOMEM; + goto error; + } + + pconfig->num = dai->id; + pconfig->ch_mask = (1 << ch) - 1; + ret = sdw_stream_add_master(&ctrl->bus, &sconfig, + pconfig, 1, dma->stream); + if (ret) + dev_err(ctrl->dev, "add master to stream failed:%d\n", ret); + + kfree(pconfig); +error: + return ret; +} + +static int amd_sdwc_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) +{ + struct amd_sdwc_ctrl *ctrl = snd_soc_dai_get_drvdata(dai); + struct sdw_amd_dma_data *dma; + int ret; + + dma = snd_soc_dai_get_dma_data(dai, substream); + if (!dma) + return -EIO; + + ret = sdw_stream_remove_master(&ctrl->bus, dma->stream); + if (ret < 0) { + dev_err(dai->dev, "remove master from stream %s failed: %d\n", + dma->stream->name, ret); + return ret; + } + dma->hw_params = NULL; + return 0; +} + +static int amd_set_sdw_stream(struct snd_soc_dai *dai, void *stream, int direction) +{ + struct amd_sdwc_ctrl *ctrl = snd_soc_dai_get_drvdata(dai); + struct sdw_amd_dma_data *dma; + + if (stream) { + if (direction == SNDRV_PCM_STREAM_PLAYBACK) + dma = dai->playback_dma_data; + else + dma = dai->capture_dma_data; + + if (dma) { + dev_err(dai->dev, + "dma_data already allocated for dai %s\n", + dai->name); + return -EINVAL; + } + + /* allocate and set dma info */ + dma = kzalloc(sizeof(*dma), GFP_KERNEL); + if (!dma) + return -ENOMEM; + dma->stream_type = SDW_STREAM_PCM; + dma->bus = &ctrl->bus; + dma->link_id = ctrl->instance; + dma->stream = stream; + + if (direction == SNDRV_PCM_STREAM_PLAYBACK) + dai->playback_dma_data = dma; + else + dai->capture_dma_data = dma; + } else { + if (direction == SNDRV_PCM_STREAM_PLAYBACK) { + kfree(dai->playback_dma_data); + dai->playback_dma_data = NULL; + } else { + kfree(dai->capture_dma_data); + dai->capture_dma_data = NULL; + } + } + return 0; +} + +static int amd_pcm_set_sdw_stream(struct snd_soc_dai *dai, void *stream, int direction) +{ + return amd_set_sdw_stream(dai, stream, direction); +} + +static void *amd_get_sdw_stream(struct snd_soc_dai *dai, int direction) +{ + struct sdw_amd_dma_data *dma; + + if (direction == SNDRV_PCM_STREAM_PLAYBACK) + dma = dai->playback_dma_data; + else + dma = dai->capture_dma_data; + + if (!dma) + return ERR_PTR(-EINVAL); + + return dma->stream; +} + +static const struct snd_soc_dai_ops amd_sdwc_dai_ops = { + .hw_params = amd_sdwc_hw_params, + .hw_free = amd_sdwc_hw_free, + .set_stream = amd_pcm_set_sdw_stream, + .get_stream = amd_get_sdw_stream, +}; + +static const struct snd_soc_component_driver amd_sdwc_dai_component = { + .name = "soundwire", +}; + +static int amd_sdwc_register_dais(struct amd_sdwc_ctrl *ctrl) +{ + struct snd_soc_dai_driver *dais; + struct snd_soc_pcm_stream *stream; + struct device *dev; + int i, num_dais; + + dev = ctrl->dev; + num_dais = ctrl->num_dout_ports + ctrl->num_din_ports; + dais = devm_kcalloc(dev, num_dais, sizeof(*dais), GFP_KERNEL); + if (!dais) + return -ENOMEM; + for (i = 0; i < num_dais; i++) { + dais[i].name = devm_kasprintf(dev, GFP_KERNEL, "SDW%d Pin%d", ctrl->instance, i); + if (!dais[i].name) { + dev_err(ctrl->dev, "-ENOMEM dai name allocation failed\n"); + return -ENOMEM; + } + + if (i < ctrl->num_dout_ports) + stream = &dais[i].playback; + else + stream = &dais[i].capture; + + stream->channels_min = 2; + stream->channels_max = 2; + stream->rates = SNDRV_PCM_RATE_48000; + stream->formats = SNDRV_PCM_FMTBIT_S16_LE; + + dais[i].ops = &amd_sdwc_dai_ops; + dais[i].id = i; + } + + return devm_snd_soc_register_component(ctrl->dev, &amd_sdwc_dai_component, + dais, num_dais); +} + static void amd_sdwc_probe_work(struct work_struct *work) { struct amd_sdwc_ctrl *ctrl = container_of(work, struct amd_sdwc_ctrl, probe_work); @@ -1043,6 +1223,12 @@ static int amd_sdwc_probe(struct platform_device *pdev) ret); return ret; } + ret = amd_sdwc_register_dais(ctrl); + if (ret) { + dev_err(dev, "CPU DAI registration failed\n"); + sdw_bus_master_delete(&ctrl->bus); + return ret; + } INIT_WORK(&ctrl->probe_work, amd_sdwc_probe_work); schedule_work(&ctrl->probe_work); return 0; diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h index 5ec39f8c2f2e..7a99d782969f 100644 --- a/include/linux/soundwire/sdw_amd.h +++ b/include/linux/soundwire/sdw_amd.h @@ -13,6 +13,7 @@ #define ACP_SDW0 0 #define ACP_SDW1 1 #define ACP_SDW0_MAX_DAI 6 +#define AMD_SDW_MAX_DAIS 8 struct acp_sdw_pdata { u16 instance; @@ -25,6 +26,7 @@ struct amd_sdwc_ctrl { void __iomem *mmio; struct work_struct probe_work; struct mutex *sdw_lock; + struct sdw_stream_runtime *sruntime[AMD_SDW_MAX_DAIS]; int num_din_ports; int num_dout_ports; int cols_index; @@ -36,4 +38,23 @@ struct amd_sdwc_ctrl { bool startup_done; u32 power_mode_mask; }; + +/** + * struct sdw_amd_dma_data: AMD DMA data + * + * @name: SoundWire stream name + * @stream: stream runtime + * @bus: Bus handle + * @stream_type: Stream type + * @link_id: Master link id + * @hw_params: hw_params to be applied in .prepare step + */ +struct sdw_amd_dma_data { + char *name; + struct sdw_stream_runtime *stream; + struct sdw_bus *bus; + enum sdw_stream_type stream_type; + int link_id; + struct snd_pcm_hw_params *hw_params; +}; #endif From patchwork Wed Jan 11 09:02:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096287 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 80D33C6379F for ; Wed, 11 Jan 2023 09:01:58 +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 93490755E; Wed, 11 Jan 2023 10:01:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 93490755E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427716; bh=BlfGxmodh7PX7Cvucyo3i+8+LA/zHhWJM+NJnDzlhL0=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=tLRoHe6OtXLC7MZyOTKI/TJOgjPDpRYP825HKBXZVvspG5HhY1w5ngxr5HuQTWC4c P8BcmB1G+FtXsfVDDUChvjw3sSoXddKaiuX+lUjSZ75d/GvVW45qw9UWQoD2NkeXsD HYH6/B1MBbGEtS3u/tGZK36APNgzxAmK0GW6awsE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BD0E9F8056F; Wed, 11 Jan 2023 10:00:18 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 41BE7F80570; Wed, 11 Jan 2023 10:00:18 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9D9BEF80563 for ; Wed, 11 Jan 2023 10:00:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9D9BEF80563 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=uLOSvlpp ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nufXLdf6onwtr323GpjZp9iyC5rpPsE9s4lBfEg+vUcdv/GlKG/LfFLGKMXV3qn1vCciAIgtvDyI37PuXcjfLOIwQtqQm8ZYhmWwNwSS5ecseP/j27FRhA5tk2RS5q8qGA7LVGFiXI2U+mFlwyZoeXIOOSFlEROu45jbU72+b2hykuMf8QbYJtvdME61OClJXRFw6YCeXHkRW4bCsFuFJ1MiFAOHJvxGlIGZ72UZlo2zDFEI9y8p/j1mroQbiR49EXeTLQRlV0ok8RmtdbQEjEk1vwVoQmWnhzGO31yHOQAmkZrUi41ssihKRJrGtwCEI3cLWoEaE3W2m6YXmdRHDQ== 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=GJ6jKY+ZT0N+3V7Zxn6rKxKflxkG+I4ICqoEYGVo7Cg=; b=ZhWD0v8Jml0QwwUECfuyljFB8UtimMZstr+8m6CKw+6O3jSsQlzHs+bG1iumAc9CPSITI90dKt2wlvEiHZIWZu0Pa8S9DdU+EvqvWQPA1fyEdHtiX4JcN9dXMwDSTMTe7hTks7ZdMyF/1yuOLtiqtd1pjZQJldSeWUBbPtjo1ySV/6zxXNGkUMMyBRY8cpGu/VGzWiUsc+tNuhyRDPEerHOYJ5dM1n9M3Jht7HwupNoZIPenVe7aB9c1m5p8IhdwBNlYos36xjXx+yPq39EWDmjT+tp5HswR8z9o0enrJyToZmvosEwARk18nrFXM6yisTtStjt8SGjTG9lsuvQdrg== 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 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=GJ6jKY+ZT0N+3V7Zxn6rKxKflxkG+I4ICqoEYGVo7Cg=; b=uLOSvlppc2Qr3XWZ4bhgoFFjl4KoBs5nKsXgUOWnywGjoO+zimE2tNwHCVoaDAogprRjLhK+dskbjuhvz0vE/kPqXXXDf5U6sTobIjBKsfqI0XvhA91jg0Nu5gJnaOfZF4ktnUtruqtKzp1hyxvQupttPSw32Pu3wW+V0+oaKaI= Received: from DM5PR07CA0107.namprd07.prod.outlook.com (2603:10b6:4:ae::36) by PH0PR12MB5418.namprd12.prod.outlook.com (2603:10b6:510:e5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:00:08 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ae:cafe::52) by DM5PR07CA0107.outlook.office365.com (2603:10b6:4:ae::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:00:08 +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 DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:00:08 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 03:00:05 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:00:01 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 04/19] soundwire: amd: enable build for AMD soundwire master driver Date: Wed, 11 Jan 2023 14:32:07 +0530 Message-ID: <20230111090222.2016499-5-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT016:EE_|PH0PR12MB5418:EE_ X-MS-Office365-Filtering-Correlation-Id: 7cf94da2-f35a-480a-79d0-08daf3b23d29 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EDo13yJka0ouuud4eDhnMcbFN6OiYt2yVPeVfSGLUGsSxUJoM7liKL/cLGwH228CP9VoT4AoxN+HNGabUZlGoxAGoulIBeNbBGbDPfoY1vJkxj5NGAHXQo53xa45VyG8P6LJNvGqb5lcwcfx/BqZowj7HvTFce9aaq5yurXy3aZ8W6cGMsSV/ezXK386jDNDeHlBRMRcDy/rFNJijDp5orNn2KXdvIw2dbl2r8/igU3ecXVXYHlKwEVkj1z2kuVvlYpiQwFllro+8x//+LAkI9g+6Oke9iRA6VJu7gchR6ridY8A8UdGqy+/fhLeH/MPzggfWZpEZr/9ea8qjuA0t2zlkzXZayokA2ue3urKrnO3EP9xDDrUb4HlUpiDCJCU/hlv8fgTeNfDGRsvI1zrVeh+OgN/hMV/cIGiRwTBE7GJeVfrGxjL0poom7oxe9uoh/2klUYvm+wu/AbqznNBAbqxxfQaKbm5yT+CgkznmtBgrbkITNz5FdqdSB/kk3Vf5pSOM95G6jo4xpGpAH0HljX6xQHUo/uC2unEu1IbiiDRIGOcM23mHUO2wavjzr19UpR5ASSCzMCoY/o+ioHsylQ1VLAUfGAqh0GW1/9JqhsYdCV8cK7ApaaLnysaKWQ1fNg7bS8sqGr42+91E16da69CMuktzD/1s/5WTz0iYK0uXCloAmdZ4IaU0ZDbCMA7nZKIlg+pBKTYSRQb24DEiFSADSNnBkrmIRbgIlw9WA8= 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:(13230022)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199015)(46966006)(40470700004)(36840700001)(82740400003)(5660300002)(186003)(26005)(7696005)(8936002)(8676002)(478600001)(83380400001)(82310400005)(2906002)(2616005)(40460700003)(54906003)(316002)(110136005)(1076003)(40480700001)(70206006)(336012)(81166007)(70586007)(356005)(4326008)(426003)(41300700001)(47076005)(36756003)(86362001)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:00:08.1421 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7cf94da2-f35a-480a-79d0-08daf3b23d29 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: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5418 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, Basavaraj.Hiregoudar@amd.com, Pierre-Louis Bossart , open list , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Sanyog Kale , Bard Liao Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Enable build for AMD soundwire master driver for AMD platforms. Signed-off-by: Vijendar Mukunda --- drivers/soundwire/Kconfig | 9 +++++++++ drivers/soundwire/Makefile | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/drivers/soundwire/Kconfig b/drivers/soundwire/Kconfig index 2b7795233282..a597bb6c42fd 100644 --- a/drivers/soundwire/Kconfig +++ b/drivers/soundwire/Kconfig @@ -46,4 +46,13 @@ config SOUNDWIRE_QCOM config SOUNDWIRE_GENERIC_ALLOCATION tristate +config SOUNDWIRE_AMD + tristate "AMD Soundwire Master driver" + depends on ACPI && SND_SOC + help + Soundwire AMD Master driver. + If you have an AMD platform which has a Soundwire Master then + enable this config option to get the Soundwire support for that + device. + endif diff --git a/drivers/soundwire/Makefile b/drivers/soundwire/Makefile index ca97414ada70..86ecae19eacd 100644 --- a/drivers/soundwire/Makefile +++ b/drivers/soundwire/Makefile @@ -26,3 +26,7 @@ obj-$(CONFIG_SOUNDWIRE_INTEL) += soundwire-intel.o #Qualcomm driver soundwire-qcom-y := qcom.o obj-$(CONFIG_SOUNDWIRE_QCOM) += soundwire-qcom.o + +#AMD driver +soundwire-amd-y := amd_master.o +obj-$(CONFIG_SOUNDWIRE_AMD) += soundwire-amd.o From patchwork Wed Jan 11 09:02:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096288 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 A60B8C5479D for ; Wed, 11 Jan 2023 09:02:07 +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 D5F8C7836; Wed, 11 Jan 2023 10:01:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D5F8C7836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427725; bh=umuhJufyALnbo9jlcvsSz8VIx4n8jz2qMcV5JnD0P8Y=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=noYpjPKo2b0ItbYBb+OShuq/R5ohopH4EliEP8jciUVzrSY2A140U2BtHMDTgYH1R JNBqYpgNy7uloQl++0p5D24LNlZuA56uyquR+GnOtJovHA0ycu2mnKtuXBqUoaSNS0 wKTZIwEEZhlCxYpyqk+LeexnIFuiGz93y0aQmwsk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 89584F80539; Wed, 11 Jan 2023 10:00:30 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6DC89F80567; Wed, 11 Jan 2023 10:00:29 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) (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 B668DF80425 for ; Wed, 11 Jan 2023 10:00:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B668DF80425 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=umUsyjeh ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T1kyK0hp9kFgCNSq0B5y6we09sFupPSpA9ve5JBsAsLccJ8eUSZSD7Lb4PRdJHzAXgyN1kw0FPWa6v/MI7wI+8JNl6tNoRw/sdfp2t95Il7WwihzQu3zDBEMSsc5PaAfC/nsqWXxrjJPmxgF8i6lL0/WvWkgi9Zpi/xPTLhpn5JTaPzfp1RoXmwDhgCITnwwkzWMYW40Yg5ybk7SBUMNFU8yUBoUUCyBueRwQCespQy/t0FfcnYuVJnmQEvYq60GMHNyY+3S4kuu0kQpbmuFH+xq2GCaPfPt/21OAiZx+PRnFJyDI0vurMGnSFQ8zGroefUHifsP8fU1kl5QZVfN8A== 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=L5WqWIReKKQeM15aIHhAhouNQALRj8AWEPnyoAnwPsw=; b=BM0vZOOGGMWP6rP9rCaXT6SJlljkZo754t0J6NkMHoHXCAmLFhj8iArCdJAfJiK5eoS/8FRFzpiFWB0lnyIuqC9yTX47GWppF8UPDGMtUgsPIWJDjuYuP19WTRPS3iKkCPwvjz4llMpk72TVyR9+z+tDqcW3RD9OsZxXQvA6NA9NFE/XsAVkq5tNNWlQ8dPgaQmvtEg49+mFEUlbp2fx2UoQEt9EaSENeQf7lhB6AbB2K3BhCuZlEySU0BvE+wIZTKj8ICP+Pc2ayf5wqeVgwSDSa9H/PUHk/XXfQHwfOFXaC2FjRdGSvAcM7CEcbxB/ddkmvEZAnicrk63gsoZVYA== 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 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=L5WqWIReKKQeM15aIHhAhouNQALRj8AWEPnyoAnwPsw=; b=umUsyjehEKSEjhpnr4J76KfEFcwbF0OA003UxbLabBUjnQRDffiobrCyWU9olhE7k5OdwGJN0y5hwIk2TyyiYZZI14fkffvQ6YQndp2Kna/Q3QrUCbi7ipthrRm7tIdkxe1sgMv2qsHZkplDr+ttdS5eR3F5r09XajDEiClpcvM= Received: from DM5PR07CA0100.namprd07.prod.outlook.com (2603:10b6:4:ae::29) by PH8PR12MB7134.namprd12.prod.outlook.com (2603:10b6:510:22d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:00:21 +0000 Received: from DS1PEPF0000B074.namprd05.prod.outlook.com (2603:10b6:4:ae:cafe::3c) by DM5PR07CA0100.outlook.office365.com (2603:10b6:4:ae::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12 via Frontend Transport; Wed, 11 Jan 2023 09:00:20 +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 DS1PEPF0000B074.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.11 via Frontend Transport; Wed, 11 Jan 2023 09:00:20 +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.2375.34; Wed, 11 Jan 2023 03:00:20 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 01:00:10 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:00:06 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 05/19] soundwire: amd: add soundwire interrupt handling Date: Wed, 11 Jan 2023 14:32:08 +0530 Message-ID: <20230111090222.2016499-6-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B074:EE_|PH8PR12MB7134:EE_ X-MS-Office365-Filtering-Correlation-Id: ab6ace1b-a6cc-41ac-5a57-08daf3b244b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vhFr4BGpvto0Ln5nhbU8estCdzrjd5DGhdSwa3aaWCr1/Hvwnhv6L45tb6AmgIOK6+mOHAeHTNq/N2A9PYSMv+J+IogV299t/w87lB0HvMbk353PjcanJolM30R+xp09Td99vj6+b6+UF4W8QZCCMliJ+qrXGKg8JJyXGlzJ39TAkR7hlGJcpUZGFsdojUPaLRQbL25cFOtDNo4d/ZjNOz5GKy0bu26yUrsuhHZRZzCvNKXu/do7W6dgnNDL1dIszgPA0OCr4J/zHTZBCtaY5umCKnourhYMCpVRRKfXCnL8wcNEQ+fjlopjyxhIfWznwXjBnw0wa30/HbYP1ITTdilVdqmXexGFPavVTFd3yJJUpWzBrzUwftXtCFRZsFAUggfo2bUNXbIjVO2+1S2Xfhc/ykkWtLar7sI7n/v29iGmNNqu/YfQ3lHT54a1pYe9ksyUm0BHrBeMijRrjtAdQl15NwjtXlPuYBNxRGhCBY0crxRRiICTc1KZODxjIczEMFyrPxHV/pwQs4mGKD/cY8OQgDdvTzH5l4/eXenHn1hgU+PYYqRiMTO1v2Sv/SGirve9pRrQ6Jq8RTJf/Ve70i69MjhoiNj0N8KfCTKOb6OKiHtoN7NDuuA9qinbiL8OOQefBzDVJYXBz8Mksf7hlyGhKte4zEjFbKEepD+fjWGy4ZrkxKXs7lj53gs3ji3vTOXYx4Iz++Y+9qFE6ayPbSjTsFYoT0AXp10WyjHZiVg= 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:(13230022)(4636009)(376002)(396003)(39860400002)(346002)(136003)(451199015)(40470700004)(36840700001)(46966006)(478600001)(426003)(8676002)(36756003)(86362001)(47076005)(4326008)(110136005)(40460700003)(82740400003)(5660300002)(70586007)(70206006)(356005)(41300700001)(8936002)(81166007)(36860700001)(316002)(7696005)(83380400001)(2906002)(26005)(54906003)(186003)(40480700001)(1076003)(336012)(2616005)(82310400005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:00:20.7701 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ab6ace1b-a6cc-41ac-5a57-08daf3b244b0 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: DS1PEPF0000B074.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7134 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, Basavaraj.Hiregoudar@amd.com, Pierre-Louis Bossart , open list , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Sanyog Kale , Bard Liao Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add support for handling soundwire controller interrupts. Signed-off-by: Vijendar Mukunda Signed-off-by: Mastan Katragadda --- drivers/soundwire/amd_master.c | 156 ++++++++++++++++++++++++++++++ drivers/soundwire/amd_master.h | 1 + include/linux/soundwire/sdw_amd.h | 3 + 3 files changed, 160 insertions(+) diff --git a/drivers/soundwire/amd_master.c b/drivers/soundwire/amd_master.c index 93bffe6ff9e2..c7063b8bdd7b 100644 --- a/drivers/soundwire/amd_master.c +++ b/drivers/soundwire/amd_master.c @@ -557,6 +557,47 @@ amd_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num) return amd_program_scp_addr(ctrl, &msg); } +static void amd_sdwc_process_ping_status(u64 response, struct amd_sdwc_ctrl *ctrl) +{ + u64 slave_stat = 0; + u32 val = 0; + u16 dev_index; + + /* slave status from ping response*/ + slave_stat = FIELD_GET(AMD_SDW_MCP_SLAVE_STAT_0_3, response); + slave_stat |= FIELD_GET(AMD_SDW_MCP_SLAVE_STAT_4_11, response) << 8; + + dev_dbg(ctrl->dev, "%s: slave_stat:0x%llx\n", __func__, slave_stat); + for (dev_index = 0; dev_index <= SDW_MAX_DEVICES; ++dev_index) { + val = (slave_stat >> (dev_index * 2)) & AMD_SDW_MCP_SLAVE_STATUS_MASK; + dev_dbg(ctrl->dev, "%s val:0x%x\n", __func__, val); + switch (val) { + case SDW_SLAVE_ATTACHED: + ctrl->status[dev_index] = SDW_SLAVE_ATTACHED; + break; + case SDW_SLAVE_UNATTACHED: + ctrl->status[dev_index] = SDW_SLAVE_UNATTACHED; + break; + case SDW_SLAVE_ALERT: + ctrl->status[dev_index] = SDW_SLAVE_ALERT; + break; + default: + ctrl->status[dev_index] = SDW_SLAVE_RESERVED; + break; + } + } +} + +static void amd_sdwc_read_and_process_ping_status(struct amd_sdwc_ctrl *ctrl) +{ + u64 response = 0; + + mutex_lock(&ctrl->bus.msg_lock); + response = amd_sdwc_send_cmd_get_resp(ctrl, 0, 0); + mutex_unlock(&ctrl->bus.msg_lock); + amd_sdwc_process_ping_status(response, ctrl); +} + static u32 amd_sdwc_read_ping_status(struct sdw_bus *bus) { struct amd_sdwc_ctrl *ctrl = to_amd_sdw(bus); @@ -1132,6 +1173,119 @@ static int amd_sdwc_register_dais(struct amd_sdwc_ctrl *ctrl) dais, num_dais); } +static void amd_sdwc_update_slave_status_work(struct work_struct *work) +{ + struct amd_sdwc_ctrl *ctrl = + container_of(work, struct amd_sdwc_ctrl, amd_sdw_work); + u32 sw_status_change_mask_0to7_reg; + u32 sw_status_change_mask_8to11_reg; + + switch (ctrl->instance) { + case ACP_SDW0: + sw_status_change_mask_0to7_reg = SW_STATE_CHANGE_STATUS_MASK_0TO7; + sw_status_change_mask_8to11_reg = SW_STATE_CHANGE_STATUS_MASK_8TO11; + break; + case ACP_SDW1: + sw_status_change_mask_0to7_reg = P1_SW_STATE_CHANGE_STATUS_MASK_0TO7; + sw_status_change_mask_8to11_reg = P1_SW_STATE_CHANGE_STATUS_MASK_8TO11; + break; + default: + dev_err(ctrl->dev, "Invalid Soundwire controller instance\n"); + return; + } + + if (ctrl->status[0] == SDW_SLAVE_ATTACHED) { + acp_reg_writel(0, ctrl->mmio + sw_status_change_mask_0to7_reg); + acp_reg_writel(0, ctrl->mmio + sw_status_change_mask_8to11_reg); + } + +update_status: + sdw_handle_slave_status(&ctrl->bus, ctrl->status); + if (ctrl->status[0] == SDW_SLAVE_ATTACHED) { + acp_reg_writel(AMD_SDW_IRQ_MASK_0TO7, ctrl->mmio + sw_status_change_mask_0to7_reg); + acp_reg_writel(AMD_SDW_IRQ_MASK_8TO11, + ctrl->mmio + sw_status_change_mask_8to11_reg); + amd_sdwc_read_and_process_ping_status(ctrl); + goto update_status; + } +} + +static void amd_sdwc_update_slave_status(u32 status_change_0to7, u32 status_change_8to11, + struct amd_sdwc_ctrl *ctrl) +{ + u64 slave_stat = 0; + u32 val = 0; + int dev_index; + + if (status_change_0to7 == AMD_SDW_SLAVE_0_ATTACHED) + memset(ctrl->status, 0, sizeof(ctrl->status)); + slave_stat = status_change_0to7; + slave_stat |= FIELD_GET(AMD_SDW_MCP_SLAVE_STATUS_8TO_11, status_change_8to11) << 32; + dev_dbg(ctrl->dev, "%s: status_change_0to7:0x%x status_change_8to11:0x%x\n", + __func__, status_change_0to7, status_change_8to11); + if (slave_stat) { + for (dev_index = 0; dev_index <= SDW_MAX_DEVICES; ++dev_index) { + if (slave_stat & AMD_SDW_MCP_SLAVE_STATUS_VALID_MASK(dev_index)) { + val = (slave_stat >> AMD_SDW_MCP_SLAVE_STAT_SHIFT_MASK(dev_index)) & + AMD_SDW_MCP_SLAVE_STATUS_MASK; + switch (val) { + case SDW_SLAVE_ATTACHED: + ctrl->status[dev_index] = SDW_SLAVE_ATTACHED; + break; + case SDW_SLAVE_UNATTACHED: + ctrl->status[dev_index] = SDW_SLAVE_UNATTACHED; + break; + case SDW_SLAVE_ALERT: + ctrl->status[dev_index] = SDW_SLAVE_ALERT; + break; + default: + ctrl->status[dev_index] = SDW_SLAVE_RESERVED; + break; + } + } + } + } +} + +static void amd_sdwc_irq_thread(struct work_struct *work) +{ + struct amd_sdwc_ctrl *ctrl = + container_of(work, struct amd_sdwc_ctrl, amd_sdw_irq_thread); + u32 sw_status_change_0to7_reg; + u32 sw_status_change_8to11_reg; + u32 status_change_8to11; + u32 status_change_0to7; + + switch (ctrl->instance) { + case ACP_SDW0: + sw_status_change_0to7_reg = SW_STATE_CHANGE_STATUS_0TO7; + sw_status_change_8to11_reg = SW_STATE_CHANGE_STATUS_8TO11; + break; + case ACP_SDW1: + sw_status_change_0to7_reg = P1_SW_STATE_CHANGE_STATUS_0TO7; + sw_status_change_8to11_reg = P1_SW_STATE_CHANGE_STATUS_8TO11; + break; + default: + dev_err(ctrl->dev, "Invalid Soundwire controller instance\n"); + return; + } + + status_change_8to11 = acp_reg_readl(ctrl->mmio + sw_status_change_8to11_reg); + status_change_0to7 = acp_reg_readl(ctrl->mmio + sw_status_change_0to7_reg); + dev_dbg(ctrl->dev, "%s [SDW%d] SDW INT: 0to7=0x%x, 8to11=0x%x\n", + __func__, ctrl->instance, status_change_0to7, status_change_8to11); + if (status_change_8to11 & AMD_SDW_PREQ_INTR_STAT) { + amd_sdwc_read_and_process_ping_status(ctrl); + } else { + /* Check for the updated status on Slave device */ + amd_sdwc_update_slave_status(status_change_0to7, status_change_8to11, ctrl); + } + if (status_change_8to11 || status_change_0to7) + schedule_work(&ctrl->amd_sdw_work); + acp_reg_writel(0x00, ctrl->mmio + sw_status_change_8to11_reg); + acp_reg_writel(0x00, ctrl->mmio + sw_status_change_0to7_reg); +} + static void amd_sdwc_probe_work(struct work_struct *work) { struct amd_sdwc_ctrl *ctrl = container_of(work, struct amd_sdwc_ctrl, probe_work); @@ -1229,6 +1383,8 @@ static int amd_sdwc_probe(struct platform_device *pdev) sdw_bus_master_delete(&ctrl->bus); return ret; } + INIT_WORK(&ctrl->amd_sdw_irq_thread, amd_sdwc_irq_thread); + INIT_WORK(&ctrl->amd_sdw_work, amd_sdwc_update_slave_status_work); INIT_WORK(&ctrl->probe_work, amd_sdwc_probe_work); schedule_work(&ctrl->probe_work); return 0; diff --git a/drivers/soundwire/amd_master.h b/drivers/soundwire/amd_master.h index 42f32ca0c7a8..b43a5d6496cb 100644 --- a/drivers/soundwire/amd_master.h +++ b/drivers/soundwire/amd_master.h @@ -236,6 +236,7 @@ #define AMD_SDW1_PAD_KEEPER_EN_MASK 0x10 #define AMD_SDW0_PAD_KEEPER_DISABLE_MASK 0x1E #define AMD_SDW1_PAD_KEEPER_DISABLE_MASK 0xF +#define AMD_SDW_PREQ_INTR_STAT BIT(19) enum amd_sdw_channel { /* SDW0 */ diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h index 7a99d782969f..2db03b2f0c3b 100644 --- a/include/linux/soundwire/sdw_amd.h +++ b/include/linux/soundwire/sdw_amd.h @@ -24,9 +24,12 @@ struct amd_sdwc_ctrl { struct sdw_bus bus; struct device *dev; void __iomem *mmio; + struct work_struct amd_sdw_irq_thread; + struct work_struct amd_sdw_work; struct work_struct probe_work; struct mutex *sdw_lock; struct sdw_stream_runtime *sruntime[AMD_SDW_MAX_DAIS]; + enum sdw_slave_status status[SDW_MAX_DEVICES + 1]; int num_din_ports; int num_dout_ports; int cols_index; From patchwork Wed Jan 11 09:02:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096290 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 D84FBC46467 for ; Wed, 11 Jan 2023 09:02:42 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E6E8D64E5; Wed, 11 Jan 2023 10:01:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E6E8D64E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427761; bh=GVyebrv/jSJNL+w3Vem9K6mLLTwdH5eNRKIppNEImEg=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=qYNY0fa/cMPaeKBTiXnPuomj5zHSzF9wzJ/WYfi0xJJ1cyob1WmYBnh7kxuY7Z8r3 1eDl6hBlgLjlMEf6gIxL2CAOo+0oV/IQmZ96prUvsWEi44Api1hToh5FPntAPVHHfm pa9Y9WvOcmUTRm76gequi+MO3RrIMxk3iWUiyz0U= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 67FAFF80551; Wed, 11 Jan 2023 10:00:42 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C43F7F8057F; Wed, 11 Jan 2023 10:00:40 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2062.outbound.protection.outlook.com [40.107.96.62]) (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 2A8D9F80544 for ; Wed, 11 Jan 2023 10:00:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2A8D9F80544 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=P2ZT1pxc ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oL7tEuG5rG6wfHOaul792IYvFNLvPwNxipByK5wyO5BrLVhFAc3cd8pVipFnLRns5pD2NybbBNRbwnfJ8DJ7EHLKiGyNjDwCXNZR4lRtgs2768JV9l3MnbE/3q2jWukRwJaHhdlSZMrxHMOyMJltnG6P9KrB14dq0WLZWBdzfB/QLk9j1uYIHh3Rr/oaykn8ftVJn7ZUn0Kzak1Y3zVeqwz4kPLlgdaxogDz98u9sWBLI7c9R2rCmXWs0tyHmyst3akbpj4m+UtfG6CxdFkAHrj+AqTJfocm+55fh84IqEFFlLPIiw55GKF2FNSlR8jXUgonsyG5obyg0vkL/jj6xg== 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=W8u/irJTwCcmWnAXydVByr309oN5TGX1ukn4tq8NZnc=; b=TZifiZd2/j/MXEq2C1M/aZH9C98oMubvhsUYFNNDSN6uNGqpdVlaIYNgzCRXmdZsM2MONQH+rxugx5rW+43jgudiVoX+bKWNeNXghI+QlbekZHvhdhhQoHgCiyBWFmkURhyEtU2vLv181RuC1GHZ1OlNhsp9XooKbjdu3VnGBg86MrpK4WZTW5rSCtogZbQMHxGiKo0ELiiMAF+N/8a4VTFqjXvwopOXgrwr89p/xC7JcnND4zVPR3n3wOKS4oHRuesqMmfOK02gRo9+mYbg01yTAw2O3+fbYPjNMXdCyXJZk30iOAU0CyNoWW3xM0ma5N/mNp7ILCjgwxlby4LPwg== 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 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=W8u/irJTwCcmWnAXydVByr309oN5TGX1ukn4tq8NZnc=; b=P2ZT1pxcrCIyII5LHmyc85XqvQqi9aoteWHGuh5JSEYQtGrsx7pQ4+8vHPXeXKCbdAlIQttqAajboLSk4EPNPDt0wxeXLn6Riq4EjVPHoNiWrATRT4XWadnKp7dtSdPM4S1t9YgK2JuE1K8MKufzzBWo7yLdgy+wnaScKliip+E= Received: from DM6PR06CA0096.namprd06.prod.outlook.com (2603:10b6:5:336::29) by BY5PR12MB4888.namprd12.prod.outlook.com (2603:10b6:a03:1d8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:00:33 +0000 Received: from DM6NAM11FT084.eop-nam11.prod.protection.outlook.com (2603:10b6:5:336:cafe::41) by DM6PR06CA0096.outlook.office365.com (2603:10b6:5:336::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:00:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by DM6NAM11FT084.mail.protection.outlook.com (10.13.172.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:00:32 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) 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.2375.34; Wed, 11 Jan 2023 03:00:20 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 11 Jan 2023 01:00:19 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:00:14 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 06/19] ASoC: amd: ps: add support for soundwire interrupts in acp pci driver Date: Wed, 11 Jan 2023 14:32:09 +0530 Message-ID: <20230111090222.2016499-7-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT084:EE_|BY5PR12MB4888:EE_ X-MS-Office365-Filtering-Correlation-Id: df68ed91-0e74-44da-02ed-08daf3b24be0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lqIMcXT3UThITRZcEXJmOSANE+6Uf/vb273Ins6YPn37wCvTPmsGADyciOBzXMeCcbeG3w3BmQGy+h6kTCt/CUSSZq/16ULSxjSCsA8m01Hr6vuIf/a1+0za6Zi93Bukq0WMY3u1R139exM1GjjrPSD4+HMi7OL1J9ptNAbT1UQDYVjDpoWYERtHd3tLccaFAORnZms4y/Hnuk2xi2suYrPqZthlUbUxJLHF+d9fu/aOW2I3fegLbocoNlqrXmOrLUY6FA9u5tjsq62ehglQb1PFC4NdeSvSjlSK8xmNs0Xbwt5T0x0Chf52JEUstkGlLrqKB7cmgivaReQh3blxDvql8xRJxgj76Tcqe4ZbACLuRy/uQxk7kIJG+bDdZxzCJWmdFevmyoGmV3Kb6jIgz9B4aarnfcPJiqzeaIhV7UgHnt53DY8q4ekgmgeneLucnI2sDtdCXsEQdjxwFjx0yn9JVJ4mzPQPQ5afitOQW1l46IceCCW1O8ezXt2EBtTj3kfBk1Vhj+oyWo6padp3vYDWjqES4EQMdRALLrPgYPaayc1gBJxd/AzJjr2j9A+ggVO+3Ys/xlRQqoT0xqN/dSQlMUK81859p9PY16K35xXXn59ypmPqIHZ8YVdfbQfCvKh5yfUahwov53Nq6LYRz6CTgee2v1PJdTPOG4HTinlMPzxdf5xpOfYlp2XfbrQffrjwcAv6DQgThuhVbovMVz4VjTeDzR6Yll8DKuJEnz+5aIYhNVCEhBwq8YDxvIlAD4gKjTGDknVf2Sk/DVPBU5nlcK5Ht2sI8KLZXwcyWyY= 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:(13230022)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199015)(40470700004)(36840700001)(46966006)(8676002)(40460700003)(478600001)(4326008)(70586007)(70206006)(336012)(40480700001)(316002)(36756003)(54906003)(356005)(81166007)(186003)(110136005)(82740400003)(2616005)(26005)(7696005)(2906002)(1076003)(47076005)(426003)(86362001)(6666004)(83380400001)(82310400005)(41300700001)(8936002)(36860700001)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:00:32.8265 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df68ed91-0e74-44da-02ed-08daf3b24be0 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: DM6NAM11FT084.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4888 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pierre-Louis Bossart , Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Nathan Chancellor , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Syed Saba Kareem Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Handle soundwire controller related interrupts in ACP PCI driver irq handler and schedule controller work queue for further processing. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/acp63.h | 4 ++++ sound/soc/amd/ps/pci-ps.c | 40 ++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index ed979e6d0c1d..0bd9dc363461 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -64,6 +64,10 @@ #define ACP63_SDW_ADDR 5 #define AMD_SDW_MAX_CONTROLLERS 2 +#define ACP_SDW0_IRQ_MASK 21 +#define ACP_SDW1_IRQ_MASK 2 +#define ACP_ERROR_IRQ_MASK 29 + enum acp_config { ACP_CONFIG_0 = 0, ACP_CONFIG_1, diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c index 85154cf0b2a2..0fbe5e27f3fb 100644 --- a/sound/soc/amd/ps/pci-ps.c +++ b/sound/soc/amd/ps/pci-ps.c @@ -67,6 +67,7 @@ static int acp63_reset(void __iomem *acp_base) static void acp63_enable_interrupts(void __iomem *acp_base) { acp63_writel(1, acp_base + ACP_EXTERNAL_INTR_ENB); + acp63_writel(BIT(ACP_ERROR_IRQ_MASK), acp_base + ACP_EXTERNAL_INTR_CNTL); } static void acp63_disable_interrupts(void __iomem *acp_base) @@ -116,23 +117,52 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) { struct acp63_dev_data *adata; struct pdm_dev_data *ps_pdm_data; - u32 val; + struct amd_sdwc_ctrl *ctrl; + u32 ext_intr_stat, ext_intr_stat1; + u16 irq_flag = 0; u16 pdev_index; adata = dev_id; if (!adata) return IRQ_NONE; + ext_intr_stat = acp63_readl(adata->acp63_base + ACP_EXTERNAL_INTR_STAT); + if (ext_intr_stat & BIT(ACP_SDW0_IRQ_MASK)) { + pdev_index = adata->sdw0_dev_index; + ctrl = dev_get_drvdata(&adata->pdev[pdev_index]->dev); + acp63_writel(BIT(ACP_SDW0_IRQ_MASK), adata->acp63_base + ACP_EXTERNAL_INTR_STAT); + schedule_work(&ctrl->amd_sdw_irq_thread); + irq_flag = 1; + } - val = acp63_readl(adata->acp63_base + ACP_EXTERNAL_INTR_STAT); - if (val & BIT(PDM_DMA_STAT)) { + ext_intr_stat1 = acp63_readl(adata->acp63_base + ACP_EXTERNAL_INTR_STAT1); + if (ext_intr_stat1 & BIT(ACP_SDW1_IRQ_MASK)) { + pdev_index = adata->sdw1_dev_index; + ctrl = dev_get_drvdata(&adata->pdev[pdev_index]->dev); + acp63_writel(BIT(ACP_SDW1_IRQ_MASK), adata->acp63_base + ACP_EXTERNAL_INTR_STAT1); + schedule_work(&ctrl->amd_sdw_irq_thread); + irq_flag = 1; + } + + if (ext_intr_stat & BIT(ACP_ERROR_IRQ_MASK)) { + acp63_writel(BIT(ACP_ERROR_IRQ_MASK), adata->acp63_base + ACP_EXTERNAL_INTR_STAT); + acp63_writel(0, adata->acp63_base + ACP_SW_I2S_ERROR_REASON); + acp63_writel(0, adata->acp63_base + ACP_P1_SW_I2S_ERROR_REASON); + acp63_writel(0, adata->acp63_base + ACP_ERROR_STATUS); + irq_flag = 1; + } + + if (ext_intr_stat & BIT(PDM_DMA_STAT)) { pdev_index = adata->pdm_dev_index; ps_pdm_data = dev_get_drvdata(&adata->pdev[pdev_index]->dev); acp63_writel(BIT(PDM_DMA_STAT), adata->acp63_base + ACP_EXTERNAL_INTR_STAT); if (ps_pdm_data->capture_stream) snd_pcm_period_elapsed(ps_pdm_data->capture_stream); - return IRQ_HANDLED; + irq_flag = 1; } - return IRQ_NONE; + if (irq_flag) + return IRQ_HANDLED; + else + return IRQ_NONE; } static int sdw_amd_scan_controller(struct device *dev) From patchwork Wed Jan 11 09:02:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096289 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 1D39BC5479D for ; Wed, 11 Jan 2023 09:02:32 +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 4ECC85EAD; Wed, 11 Jan 2023 10:01:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4ECC85EAD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427749; bh=yJu/E1sQHKUxbh7Zgag4RWFNG/3TeHJyFpR/0JsvI/Q=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=FItbvpLrV4S+qGX2fe9zIe60sEajhCKjZ7tGGZN313Y0OPGnZDay2byaEixk+Va0b nvuPaODsymgsR2rlwOCyfQDlhBwdepB4A/tyLpXoSNBB+uqhqVFrFbAxSEZUBRdtcj feugCPMO4yuxG68hZxGvbEF2r0havXfrpKt9xn6M= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AD422F8057D; Wed, 11 Jan 2023 10:00:40 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D750FF8057F; Wed, 11 Jan 2023 10:00:38 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2051.outbound.protection.outlook.com [40.107.243.51]) (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 8EDE9F80544 for ; Wed, 11 Jan 2023 10:00:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8EDE9F80544 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=pPRsvFqm ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K4ULlrqJG/HOndwY7X7NxLaBCwc0lJJKOP0lRjQchP2HmRjQ6Gz0UR8X/qyyAe/O0E3gBotIk23cafM69FM7ZgK0zxoMrG/W/LiKTj88Tzhk8Voi1ns/q3dH8drvPiIdLMdJDj9wJbTA+mSTQXMHcte8Piu54IitJGtuFAbs1u09xq5nms44L11gZHojDdHrjjP4Ln+7fY5hR13YIkJp2D4MOXBzvnt1wS5aWE2RDpw0hWT9noHVAuZ8mbPmRbJSOokhFzxEYir3E9rVwy3JVshZ6DZY5x8qOIcyX+XbnZEna2oXZ7VMzr3M33SQb6jwEhERdh5zr68cCgJJ5nioiA== 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=vvE2mbcKlRVFfBTVxCk+9aTWFLPfhBR/Se/X0V+Gd2E=; b=EVE7HeIbU5ZYfWoeGsrj9+HIb/F8ZBARAGblLuBnGHXldyOYG0xQ16XfGcaCDXKXij0rLvSXT+cKpqDrVWu9UECTmPyJ8hKcjxKt2GoEmtZlnGmCBxD3oqGQWb8pQ4kULMFtvwNsLC1yJedJDrPyjlCsr9c8HrwwQf1kdJB9cQfXjKP4D1nGc7QnMhZjopr15i4CBZI/vjIRpjmTDadfmnnkOyL5GjwBhF6xKopF/q1ljOjgi7+FQ1wqfr4p79TuHXwku0fnuOuTtsP2DQrlTdNZcOrflfbvHt9Rpnwbaebg1N6XqhJp2Fb/4TmvyKKZdLoqi9zDsSfhCck67vNqAw== 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 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=vvE2mbcKlRVFfBTVxCk+9aTWFLPfhBR/Se/X0V+Gd2E=; b=pPRsvFqmrktub1Md34BWTVC0idx86I+HPj9pgrdqJBTvv6/E0x0b9k2jtDlcrT9djYooJPYUvWomtr39a0IETVNmP/oJ23yr2obSm01ebSJjJ99UsaDzqshtyuPgWTxT2JTXIA3WyzK1GA1v8zXgPiwrAFZXkV2b64SNFMACAI0= Received: from DM6PR03CA0007.namprd03.prod.outlook.com (2603:10b6:5:40::20) by DM4PR12MB6613.namprd12.prod.outlook.com (2603:10b6:8:b8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:00:32 +0000 Received: from DS1PEPF0000B073.namprd05.prod.outlook.com (2603:10b6:5:40:cafe::99) by DM6PR03CA0007.outlook.office365.com (2603:10b6:5:40::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:00:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0000B073.mail.protection.outlook.com (10.167.17.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.11 via Frontend Transport; Wed, 11 Jan 2023 09:00:32 +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.2375.34; Wed, 11 Jan 2023 03:00:28 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 03:00:28 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:00:24 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 07/19] ASoC: amd: ps: add soundwire dma driver for pink sardine platform Date: Wed, 11 Jan 2023 14:32:10 +0530 Message-ID: <20230111090222.2016499-8-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B073:EE_|DM4PR12MB6613:EE_ X-MS-Office365-Filtering-Correlation-Id: 16eb6858-0e18-46f4-d62d-08daf3b24bac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nvd5OagH98mdx1YfQQh0VlTT2VH99Ct55sLL2FCSnj7qBDiOkMprKb0orc9/PRatQSuyDF6EMGtzTUWGa3uA6c5SjV2nOmSz1q+foVf9i9wHbNqcKNLfBeb4xI+8PgKDzs1d9W1AfDAy9D6UXxAxErD/racy4aW6adg6lbrM0WY2Fdx4J8QAtX6ka3iwxFFnHsE6Vv/z7kuwlieCFtrtHSpZOF9RN2G89NAXpQq/UKcla/0SeqdGALtjOieWxsZi1Fu1CDYW+bhoaDEfxUkwpwwpmTCgSweNd81ZzjSEHYgvqc/bPrkeqwOkfbd7xtlFac3SE5lY3AFNTSbccbI8HqRyOcsFphWENwhzUHyAz7kVOi+F9S1masgR99lUJG1RRjz7HHi2CUp+ofOLZRSmnCVqB76MQQwkipTPbMJC8J51Wii4wgdJXhH8gIvO5YGqw2dMOLtGrXnmlj4mBaZ5H4W+f1RpTJXZdEkFB1AMHaB7g2LhNSTTHQ8BIBjy3s3Ih2tbx2OORJTLUbT0cVV5uLusEtcM1E8QmgfmL8LrH9Pqpd5L6r+xCDGZ8tRlxBV2fc+PNsHP/qBEf2wGotnE+zku/uWS4aop1hVoasPPXNDNGnJ5mtwlOdaMt1qLsg3wtRzQbeP4OH4Y9ID2XI33C+c6pzNtlkXLULoiykqm6SvfU4SstLm1eiY2Rk+8jVwHMGNEFKrXxzxd+UGK9EUn029ZubfKvF0eOyKTtt/BOZA= 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:(13230022)(4636009)(376002)(39860400002)(136003)(346002)(396003)(451199015)(36840700001)(46966006)(40470700004)(2906002)(82310400005)(47076005)(83380400001)(336012)(36860700001)(426003)(81166007)(7696005)(2616005)(1076003)(40480700001)(5660300002)(8936002)(6666004)(36756003)(186003)(26005)(478600001)(70586007)(70206006)(8676002)(54906003)(110136005)(41300700001)(86362001)(356005)(316002)(4326008)(40460700003)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:00:32.4755 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16eb6858-0e18-46f4-d62d-08daf3b24bac 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: DS1PEPF0000B073.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6613 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Syed Saba Kareem Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Soundwire DMA platform driver binds to the platform device created by ACP PCI device. Soundwire DMA driver registers ALSA DMA component with ASoC framework. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/acp63.h | 5 +++ sound/soc/amd/ps/ps-sdw-dma.c | 72 +++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 sound/soc/amd/ps/ps-sdw-dma.c diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index 0bd9dc363461..b462320fdf2a 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -135,3 +135,8 @@ struct acp63_dev_data { bool is_sdw_dev; bool acp_sdw_power_off; }; + +struct sdw_dma_dev_data { + void __iomem *acp_base; + struct mutex *acp_lock; +}; diff --git a/sound/soc/amd/ps/ps-sdw-dma.c b/sound/soc/amd/ps/ps-sdw-dma.c new file mode 100644 index 000000000000..388a4b7df715 --- /dev/null +++ b/sound/soc/amd/ps/ps-sdw-dma.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * AMD ALSA SoC Pink Sardine Soundwire DMA Driver + * + * Copyright 2023 Advanced Micro Devices, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "acp63.h" + +#define DRV_NAME "amd_ps_sdw_dma" + +static const struct snd_soc_component_driver acp63_sdw_component = { + .name = DRV_NAME, +}; + +static int acp63_sdw_platform_probe(struct platform_device *pdev) +{ + struct resource *res; + struct sdw_dma_dev_data *sdw_data; + int status; + + if (!pdev->dev.platform_data) { + dev_err(&pdev->dev, "platform_data not retrieved\n"); + return -ENODEV; + } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n"); + return -ENODEV; + } + + sdw_data = devm_kzalloc(&pdev->dev, sizeof(*sdw_data), GFP_KERNEL); + if (!sdw_data) + return -ENOMEM; + + sdw_data->acp_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (!sdw_data->acp_base) + return -ENOMEM; + + sdw_data->acp_lock = pdev->dev.platform_data; + dev_set_drvdata(&pdev->dev, sdw_data); + status = devm_snd_soc_register_component(&pdev->dev, + &acp63_sdw_component, + NULL, 0); + if (status) { + dev_err(&pdev->dev, "Fail to register acp pdm dai\n"); + + return -ENODEV; + } + return 0; +} + +static struct platform_driver acp63_sdw_dma_driver = { + .probe = acp63_sdw_platform_probe, + .driver = { + .name = "amd_ps_sdw_dma", + }, +}; + +module_platform_driver(acp63_sdw_dma_driver); + +MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); +MODULE_DESCRIPTION("AMD ACP6.3 PS SDW DMA Driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRV_NAME); From patchwork Wed Jan 11 09:02:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096291 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 06C57C5479D for ; Wed, 11 Jan 2023 09:03:01 +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 0775177ED; Wed, 11 Jan 2023 10:02:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0775177ED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427779; bh=gKz39MABJvHheHm8t83pXk0zVqTT2BsqIgVqK/3XM5A=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=IIHAIkDP3Tx+FA69PK3t7xa1+pu1xVBoi+pUwsSq58fVH3UusFm8PVVR1Qc+XInKG 7B2KkbqRB6N4JCx0B9XEV2IW32v0jpEiQuEcqIr09yE3pMH7vw81S3xVfBuQwo2CT5 ygJ746//35712ZBVi19pIGHmZMSNiHJtXjNhfCn4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 50AB6F8051B; Wed, 11 Jan 2023 10:01:20 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3F570F8053A; Wed, 11 Jan 2023 10:01:19 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2046.outbound.protection.outlook.com [40.107.94.46]) (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 0EF87F8026A for ; Wed, 11 Jan 2023 10:01:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0EF87F8026A 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=mnqV4ph8 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X9A/fHccjdP3/8GEH0mk2kuCvTwF9QA3tKrTrVLVqDuWRXfUlr+Sqa7PThMv1oGApq88cveKJw+J6lsUqDzk7ZvxJOEWACCM5FoeMGlBZOhpvdRyxgb6hZlkoGLek5M3rcFKEed1/1oOJyeIOT3CokViuFwdXBGS4iB9ly+pcFI/HFfHY2VCjWmv2q4kX+W9Gpr+tQu0qTYucitluQVlFRB8OkOXoT9z1+zpvSikigjw3vJyYkkYTxUNB2V34HM/RXBbuIkG966ECSGlXtcSqCxyyMhAGEXB8ojwWtt/ZCPaq1NxGuJlPLBevKxipscQ3QrsDa+H34rishymp9rFDA== 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=JNyCrr8FBj6Slnv5qkjuJdjmBk56Jb0Hi/zmTbxSW4o=; b=RA2s1xBkaBYLI4653hPZgsXIaHqPXiJHX1gFCh7lh8Fg0/EatjN6iG/kOHjn1qEBxz3tuIpjai4QaWlKxQ5fpFGX2/yD8HWZ2Rp5pHoo2iadnaDmUTfLUErAa95YqSYG9534QaeMmycV6cwUS9xw7GUyZbSTRceIO+5EX2IotY9WBfyKjTe1b6Pv6tB7HTXCT0gJIzTG7DvPmfNyKSW93TRuOsDs2MfBFubWUsJDyBBoIv/FbieXhgmMjfVg4VNe3U0XQwrnVhif+3tLFGJC8z31scyrxhgLeUiDXLqHGUPgoDhdgzYODdNLZlkHJaPjewuWCASgry6bL7pEvzrGwQ== 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 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=JNyCrr8FBj6Slnv5qkjuJdjmBk56Jb0Hi/zmTbxSW4o=; b=mnqV4ph8ww43UW7nH2aVVXmzw/qPStICxD+t34XsneaWArPThtaw5+a/+Zc/WyPEH224pNyXqLKQ6ue4jl6WrT1Vt3JEz1Rt/9oXc/8yfOZ1B3i+rd3YaJk208xbcHfJOBiFBicsrsvuCq1V+Sw4p79n/AlcY8H4+zmr0ftIsLw= Received: from DM6PR02CA0042.namprd02.prod.outlook.com (2603:10b6:5:177::19) by DM4PR12MB5820.namprd12.prod.outlook.com (2603:10b6:8:64::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:01:09 +0000 Received: from DS1PEPF0000B073.namprd05.prod.outlook.com (2603:10b6:5:177:cafe::e8) by DM6PR02CA0042.outlook.office365.com (2603:10b6:5:177::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:01:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0000B073.mail.protection.outlook.com (10.167.17.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.11 via Frontend Transport; Wed, 11 Jan 2023 09:01:09 +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.2375.34; Wed, 11 Jan 2023 03:01:08 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 01:00:36 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:00:33 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 08/19] ASoC: amd: ps: add soundwire dma driver dma ops Date: Wed, 11 Jan 2023 14:32:11 +0530 Message-ID: <20230111090222.2016499-9-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B073:EE_|DM4PR12MB5820:EE_ X-MS-Office365-Filtering-Correlation-Id: 370a8e70-8328-4658-49dd-08daf3b261a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mKB7/cJqvqyjVlK3rXO9JmPrpPS+X89Uv7r6Zuw/CnbvOQd+c7e1vOgaqzKVAcQniH4ULYT9ot2iOccTgdDz/yrtGvHmmOQvTE6z8Zgen+5mbwRoT7MnUXgBSGzO7Tg9PFer7rPwm9dBsxXur+x3OHhVH+bcKIGhYr9yCupE3g/+Cq+KjM5bDTZJktmIyCwgUuUKhfqAzUmIpeKEZyj1qHFHWNi3wwuNwuRZmFsez3luknGnBYrGBo3Jr4ZZO/Lugvi3PUAerBXet0Hr6LREc6iTKWRIWgpXIgeqexqow4UMlx+i1+JkCEfWif8AEm+GH2pPrebIBcFHLpfKyBSfFZfot/AhqqdUUzRKs1hROs5hMZnru2Yz2NYrEcWteRzGUpUHF+D/AE0Dq4hkawS2b9XCHk40QQK59D82ApbS16Ejq3gwZ5x8ceGRkN5BVwvPofAQ99MOYgNbkgQoUy3H5dVQIRmPd51Jaj7JIF6iQaIRzBFS919P74zx6D/eZ3oFuy6ft8aq0NEVZQeftbb7Xba8oh7C5Qybg3TwEmRFz3YzebVmVvhNj2gTDpMp2WllWDCAj2VC5oRf2nMXhqzVkmfSrnpH0iTjYtaaSjd9AtaM9KH/5C0IcfVEHd75vPSYv70LxgxwewmkH5FGQrJSqE1uq8S+NdQshDJuriO/wqd0cqdvxVLA699prhwR1GabrSosqQHi8rsrnwsSTFqEdx6S7Pmr/+it8fluhPQFhbE= 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:(13230022)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199015)(46966006)(40470700004)(36840700001)(82310400005)(47076005)(8936002)(2906002)(5660300002)(81166007)(41300700001)(426003)(70206006)(7696005)(316002)(4326008)(70586007)(8676002)(30864003)(356005)(110136005)(54906003)(26005)(82740400003)(1076003)(40480700001)(2616005)(336012)(86362001)(40460700003)(186003)(36860700001)(83380400001)(36756003)(6666004)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:01:09.3032 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 370a8e70-8328-4658-49dd-08daf3b261a0 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: DS1PEPF0000B073.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5820 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Syed Saba Kareem Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add Soundwire DMA driver dma ops for Pink Sardine platform. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/acp63.h | 61 ++++ sound/soc/amd/ps/ps-sdw-dma.c | 531 ++++++++++++++++++++++++++++++++++ 2 files changed, 592 insertions(+) diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index b462320fdf2a..8963cfb6120d 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -67,6 +67,38 @@ #define ACP_SDW0_IRQ_MASK 21 #define ACP_SDW1_IRQ_MASK 2 #define ACP_ERROR_IRQ_MASK 29 +#define ACP_AUDIO_TX_THRESHOLD 28 +#define ACP_BT_TX_THRESHOLD 26 +#define ACP_HS_TX_THRESHOLD 24 +#define ACP_AUDIO_RX_THRESHOLD 27 +#define ACP_BT_RX_THRESHOLD 25 +#define ACP_HS_RX_THRESHOLD 23 +#define ACP_P1_BT_TX_THRESHOLD 6 +#define ACP_P1_BT_RX_THRESHOLD 5 +#define ACP_SDW_DMA_IRQ_MASK 0x1F800000 +#define ACP_P1_SDW_DMA_IRQ_MASK 0x60 +#define ACP63_SDW_MAX_STREAMS 8 + +#define ACP_DELAY_US 5 +#define SDW_MEM_WINDOW_START 0x4800000 +#define ACP_SDW_SRAM_PTE_OFFSET 0x03800400 +#define SDW_PTE_OFFSET 0x400 +#define SDW_FIFO_SIZE 0x100 +#define SDW_DMA_SIZE 0x40 +#define ACP_SDW_FIFO_OFFSET 0x100 +#define ACP_SDW_RING_BUFF_ADDR_OFFSET (128 * 1024) + +#define SDW_PLAYBACK_MIN_NUM_PERIODS 2 +#define SDW_PLAYBACK_MAX_NUM_PERIODS 8 +#define SDW_PLAYBACK_MAX_PERIOD_SIZE 8192 +#define SDW_PLAYBACK_MIN_PERIOD_SIZE 1024 +#define SDW_CAPTURE_MIN_NUM_PERIODS 2 +#define SDW_CAPTURE_MAX_NUM_PERIODS 8 +#define SDW_CAPTURE_MAX_PERIOD_SIZE 8192 +#define SDW_CAPTURE_MIN_PERIOD_SIZE 1024 + +#define SDW_MAX_BUFFER (SDW_PLAYBACK_MAX_PERIOD_SIZE * SDW_PLAYBACK_MAX_NUM_PERIODS) +#define SDW_MIN_BUFFER SDW_MAX_BUFFER enum acp_config { ACP_CONFIG_0 = 0, @@ -93,6 +125,17 @@ enum acp_pdev_mask { ACP63_SDW_PDM_DEV_MASK, }; +enum channel_type { + ACP_SDW_AUDIO_TX = 0, + ACP_SDW_BT_TX, + ACP_SDW_HS_TX, + ACP_SDW_AUDIO_RX, + ACP_SDW_BT_RX, + ACP_SDW_HS_RX, + ACP_SDW1_BT_TX, + ACP_SDW1_BT_RX, +}; + struct pdm_stream_instance { u16 num_pages; u16 channels; @@ -139,4 +182,22 @@ struct acp63_dev_data { struct sdw_dma_dev_data { void __iomem *acp_base; struct mutex *acp_lock; + struct snd_pcm_substream *sdw_stream[ACP63_SDW_MAX_STREAMS]; +}; + +struct sdw_stream_instance { + u16 num_pages; + u16 channels; + u32 stream_id; + dma_addr_t dma_addr; + u64 bytescount; + void __iomem *acp_base; +}; + +union acp_sdw_dma_count { + struct { + u32 low; + u32 high; + } bcount; + u64 bytescount; }; diff --git a/sound/soc/amd/ps/ps-sdw-dma.c b/sound/soc/amd/ps/ps-sdw-dma.c index 388a4b7df715..e94f76053c66 100644 --- a/sound/soc/amd/ps/ps-sdw-dma.c +++ b/sound/soc/amd/ps/ps-sdw-dma.c @@ -12,12 +12,543 @@ #include #include #include +#include #include "acp63.h" #define DRV_NAME "amd_ps_sdw_dma" +static const struct snd_pcm_hardware acp63_sdw_hardware_playback = { + .info = SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_48000, + .rate_min = 48000, + .rate_max = 48000, + .buffer_bytes_max = SDW_PLAYBACK_MAX_NUM_PERIODS * SDW_PLAYBACK_MAX_PERIOD_SIZE, + .period_bytes_min = SDW_PLAYBACK_MIN_PERIOD_SIZE, + .period_bytes_max = SDW_PLAYBACK_MAX_PERIOD_SIZE, + .periods_min = SDW_PLAYBACK_MIN_NUM_PERIODS, + .periods_max = SDW_PLAYBACK_MAX_NUM_PERIODS, +}; + +static const struct snd_pcm_hardware acp63_sdw_hardware_capture = { + .info = SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_48000, + .rate_min = 48000, + .rate_max = 48000, + .buffer_bytes_max = SDW_CAPTURE_MAX_NUM_PERIODS * SDW_CAPTURE_MAX_PERIOD_SIZE, + .period_bytes_min = SDW_CAPTURE_MIN_PERIOD_SIZE, + .period_bytes_max = SDW_CAPTURE_MAX_PERIOD_SIZE, + .periods_min = SDW_CAPTURE_MIN_NUM_PERIODS, + .periods_max = SDW_CAPTURE_MAX_NUM_PERIODS, +}; + +static void acp63_config_dma(struct sdw_stream_instance *sdw_ins, u32 stream_id) +{ + u16 page_idx; + u32 low, high, val; + dma_addr_t addr; + + addr = sdw_ins->dma_addr; + val = SDW_PTE_OFFSET + (stream_id * 256); + + /* Group Enable */ + acp63_writel(ACP_SDW_SRAM_PTE_OFFSET | BIT(31), sdw_ins->acp_base + + ACPAXI2AXI_ATU_BASE_ADDR_GRP_2); + acp63_writel(PAGE_SIZE_4K_ENABLE, sdw_ins->acp_base + + ACPAXI2AXI_ATU_PAGE_SIZE_GRP_2); + for (page_idx = 0; page_idx < sdw_ins->num_pages; page_idx++) { + /* Load the low address of page int ACP SRAM through SRBM */ + low = lower_32_bits(addr); + high = upper_32_bits(addr); + + acp63_writel(low, sdw_ins->acp_base + ACP_SCRATCH_REG_0 + val); + high |= BIT(31); + acp63_writel(high, sdw_ins->acp_base + ACP_SCRATCH_REG_0 + val + 4); + val += 8; + addr += PAGE_SIZE; + } + + /*cache Invalidation added for Testing */ + acp63_writel(0x1, sdw_ins->acp_base + ACPAXI2AXI_ATU_CTRL); +} + +static int acp63_configure_sdw_ringbuffer(void __iomem *acp_base, u32 stream_id, u32 size) +{ + u32 reg_dma_size; + u32 reg_fifo_addr; + u32 reg_fifo_size; + u32 reg_ring_buf_size; + u32 reg_ring_buf_addr; + u32 sdw_fifo_addr; + u32 sdw_ring_buf_addr; + u32 sdw_ring_buf_size; + + switch (stream_id) { + case ACP_SDW_AUDIO_TX: + reg_dma_size = ACP_AUDIO_TX_DMA_SIZE; + reg_fifo_addr = ACP_AUDIO_TX_FIFOADDR; + reg_fifo_size = ACP_AUDIO_TX_FIFOSIZE; + reg_ring_buf_size = ACP_AUDIO_TX_RINGBUFSIZE; + reg_ring_buf_addr = ACP_AUDIO_TX_RINGBUFADDR; + break; + case ACP_SDW_BT_TX: + reg_dma_size = ACP_BT_TX_DMA_SIZE; + reg_fifo_addr = ACP_BT_TX_FIFOADDR; + reg_fifo_size = ACP_BT_TX_FIFOSIZE; + reg_ring_buf_size = ACP_BT_TX_RINGBUFSIZE; + reg_ring_buf_addr = ACP_BT_TX_RINGBUFADDR; + break; + case ACP_SDW_HS_TX: + reg_dma_size = ACP_HS_TX_DMA_SIZE; + reg_fifo_addr = ACP_HS_TX_FIFOADDR; + reg_fifo_size = ACP_HS_TX_FIFOSIZE; + reg_ring_buf_size = ACP_HS_TX_RINGBUFSIZE; + reg_ring_buf_addr = ACP_HS_TX_RINGBUFADDR; + break; + case ACP_SDW1_BT_TX: + reg_dma_size = ACP_P1_BT_TX_DMA_SIZE; + reg_fifo_addr = ACP_P1_BT_TX_FIFOADDR; + reg_fifo_size = ACP_P1_BT_TX_FIFOSIZE; + reg_ring_buf_size = ACP_P1_BT_TX_RINGBUFSIZE; + reg_ring_buf_addr = ACP_P1_BT_TX_RINGBUFADDR; + break; + case ACP_SDW_AUDIO_RX: + reg_dma_size = ACP_AUDIO_RX_DMA_SIZE; + reg_fifo_addr = ACP_AUDIO_RX_FIFOADDR; + reg_fifo_size = ACP_AUDIO_RX_FIFOSIZE; + reg_ring_buf_size = ACP_AUDIO_RX_RINGBUFSIZE; + reg_ring_buf_addr = ACP_AUDIO_RX_RINGBUFADDR; + break; + case ACP_SDW_BT_RX: + reg_dma_size = ACP_BT_RX_DMA_SIZE; + reg_fifo_addr = ACP_BT_RX_FIFOADDR; + reg_fifo_size = ACP_BT_RX_FIFOSIZE; + reg_ring_buf_size = ACP_BT_RX_RINGBUFSIZE; + reg_ring_buf_addr = ACP_BT_RX_RINGBUFADDR; + break; + case ACP_SDW_HS_RX: + reg_dma_size = ACP_HS_RX_DMA_SIZE; + reg_fifo_addr = ACP_HS_RX_FIFOADDR; + reg_fifo_size = ACP_HS_RX_FIFOSIZE; + reg_ring_buf_size = ACP_HS_RX_RINGBUFSIZE; + reg_ring_buf_addr = ACP_HS_RX_RINGBUFADDR; + break; + case ACP_SDW1_BT_RX: + reg_dma_size = ACP_P1_BT_RX_DMA_SIZE; + reg_fifo_addr = ACP_P1_BT_RX_FIFOADDR; + reg_fifo_size = ACP_P1_BT_RX_FIFOSIZE; + reg_ring_buf_size = ACP_P1_BT_RX_RINGBUFSIZE; + reg_ring_buf_addr = ACP_P1_BT_RX_RINGBUFADDR; + break; + default: + return -EINVAL; + } + sdw_fifo_addr = ACP_SDW_FIFO_OFFSET * stream_id; + sdw_ring_buf_addr = SDW_MEM_WINDOW_START + (stream_id * ACP_SDW_RING_BUFF_ADDR_OFFSET); + sdw_ring_buf_size = size; + acp63_writel(sdw_ring_buf_size, acp_base + reg_ring_buf_size); + acp63_writel(sdw_ring_buf_addr, acp_base + reg_ring_buf_addr); + acp63_writel(sdw_fifo_addr, acp_base + reg_fifo_addr); + acp63_writel(SDW_DMA_SIZE, acp_base + reg_dma_size); + acp63_writel(SDW_FIFO_SIZE, acp_base + reg_fifo_size); + return 0; +} + +static int acp63_sdw_dma_open(struct snd_soc_component *component, + struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime; + struct sdw_dma_dev_data *sdw_dev_data; + struct sdw_stream_instance *sdw_stream_data; + struct snd_soc_dai *cpu_dai; + struct amd_sdwc_ctrl *ctrl; + struct snd_soc_pcm_runtime *prtd = substream->private_data; + int ret; + + runtime = substream->runtime; + sdw_dev_data = dev_get_drvdata(component->dev); + cpu_dai = asoc_rtd_to_cpu(prtd, 0); + ctrl = snd_soc_dai_get_drvdata(cpu_dai); + sdw_stream_data = kzalloc(sizeof(*sdw_stream_data), GFP_KERNEL); + if (!sdw_stream_data) + return -EINVAL; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + runtime->hw = acp63_sdw_hardware_playback; + else + runtime->hw = acp63_sdw_hardware_capture; + ret = snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + if (ret < 0) { + dev_err(component->dev, "set integer constraint failed\n"); + kfree(sdw_stream_data); + return ret; + } + + if (ctrl->instance == ACP_SDW1) + sdw_stream_data->stream_id = cpu_dai->id + ACP_SDW0_MAX_DAI; + else + sdw_stream_data->stream_id = cpu_dai->id; + sdw_stream_data->acp_base = sdw_dev_data->acp_base; + runtime->private_data = sdw_stream_data; + return ret; +} + +static int acp63_sdw_dma_hw_params(struct snd_soc_component *component, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct sdw_stream_instance *sdw_stream_data; + struct sdw_dma_dev_data *sdw_data; + u32 period_bytes; + u32 water_mark_size_reg; + u32 irq_mask, ext_intr_ctrl; + u64 size; + u32 stream_id; + u32 acp_ext_intr_cntl_reg; + int ret; + + stream_id = 0; + sdw_data = dev_get_drvdata(component->dev); + sdw_stream_data = substream->runtime->private_data; + if (!sdw_stream_data) + return -EINVAL; + stream_id = sdw_stream_data->stream_id; + sdw_data->sdw_stream[stream_id] = substream; + size = params_buffer_bytes(params); + period_bytes = params_period_bytes(params); + sdw_stream_data->dma_addr = substream->runtime->dma_addr; + sdw_stream_data->num_pages = (PAGE_ALIGN(size) >> PAGE_SHIFT); + acp63_config_dma(sdw_stream_data, stream_id); + ret = acp63_configure_sdw_ringbuffer(sdw_stream_data->acp_base, stream_id, size); + if (ret) { + dev_err(component->dev, "Invalid channel type\n"); + return -EINVAL; + } + switch (stream_id) { + case ACP_SDW_AUDIO_TX: + water_mark_size_reg = ACP_AUDIO_TX_INTR_WATERMARK_SIZE; + irq_mask = BIT(ACP_AUDIO_TX_THRESHOLD); + acp_ext_intr_cntl_reg = ACP_EXTERNAL_INTR_CNTL; + break; + case ACP_SDW_BT_TX: + water_mark_size_reg = ACP_BT_TX_INTR_WATERMARK_SIZE; + irq_mask = BIT(ACP_BT_TX_THRESHOLD); + acp_ext_intr_cntl_reg = ACP_EXTERNAL_INTR_CNTL; + break; + case ACP_SDW_HS_TX: + water_mark_size_reg = ACP_HS_TX_INTR_WATERMARK_SIZE; + irq_mask = BIT(ACP_HS_TX_THRESHOLD); + acp_ext_intr_cntl_reg = ACP_EXTERNAL_INTR_CNTL; + break; + case ACP_SDW1_BT_TX: + water_mark_size_reg = ACP_P1_BT_TX_INTR_WATERMARK_SIZE; + irq_mask = BIT(ACP_P1_BT_TX_THRESHOLD); + acp_ext_intr_cntl_reg = ACP_EXTERNAL_INTR_CNTL1; + break; + case ACP_SDW_AUDIO_RX: + water_mark_size_reg = ACP_AUDIO_RX_INTR_WATERMARK_SIZE; + irq_mask = BIT(ACP_AUDIO_RX_THRESHOLD); + acp_ext_intr_cntl_reg = ACP_EXTERNAL_INTR_CNTL; + break; + case ACP_SDW_BT_RX: + water_mark_size_reg = ACP_BT_RX_INTR_WATERMARK_SIZE; + irq_mask = BIT(ACP_BT_RX_THRESHOLD); + acp_ext_intr_cntl_reg = ACP_EXTERNAL_INTR_CNTL; + break; + case ACP_SDW_HS_RX: + water_mark_size_reg = ACP_HS_RX_INTR_WATERMARK_SIZE; + irq_mask = BIT(ACP_HS_RX_THRESHOLD); + acp_ext_intr_cntl_reg = ACP_EXTERNAL_INTR_CNTL; + break; + case ACP_SDW1_BT_RX: + water_mark_size_reg = ACP_P1_BT_RX_INTR_WATERMARK_SIZE; + irq_mask = BIT(ACP_P1_BT_RX_THRESHOLD); + acp_ext_intr_cntl_reg = ACP_EXTERNAL_INTR_CNTL1; + break; + default: + dev_err(component->dev, "%s: Invalid channel type\n", __func__); + return -EINVAL; + } + + ext_intr_ctrl = acp63_readl(sdw_stream_data->acp_base + acp_ext_intr_cntl_reg); + ext_intr_ctrl |= irq_mask; + acp63_writel(ext_intr_ctrl, sdw_stream_data->acp_base + acp_ext_intr_cntl_reg); + acp63_writel(period_bytes, sdw_stream_data->acp_base + water_mark_size_reg); + return 0; +} + +static u64 acp63_sdw_get_byte_count(struct sdw_stream_instance *rtd) +{ + union acp_sdw_dma_count byte_count; + u32 pos_low_reg, pos_high_reg; + + byte_count.bytescount = 0; + switch (rtd->stream_id) { + case ACP_SDW_AUDIO_TX: + pos_low_reg = ACP_AUDIO_TX_LINEARPOSITIONCNTR_LOW; + pos_high_reg = ACP_AUDIO_TX_LINEARPOSITIONCNTR_HIGH; + break; + case ACP_SDW_BT_TX: + pos_low_reg = ACP_BT_TX_LINEARPOSITIONCNTR_LOW; + pos_high_reg = ACP_BT_TX_LINEARPOSITIONCNTR_HIGH; + break; + case ACP_SDW_HS_TX: + pos_low_reg = ACP_HS_TX_LINEARPOSITIONCNTR_LOW; + pos_high_reg = ACP_HS_TX_LINEARPOSITIONCNTR_HIGH; + break; + case ACP_SDW1_BT_TX: + pos_low_reg = ACP_P1_BT_TX_LINEARPOSITIONCNTR_LOW; + pos_high_reg = ACP_P1_BT_TX_LINEARPOSITIONCNTR_HIGH; + break; + case ACP_SDW_AUDIO_RX: + pos_low_reg = ACP_AUDIO_RX_LINEARPOSITIONCNTR_LOW; + pos_high_reg = ACP_AUDIO_RX_LINEARPOSITIONCNTR_HIGH; + break; + case ACP_SDW_BT_RX: + pos_low_reg = ACP_BT_RX_LINEARPOSITIONCNTR_LOW; + pos_high_reg = ACP_BT_RX_LINEARPOSITIONCNTR_HIGH; + break; + case ACP_SDW_HS_RX: + pos_low_reg = ACP_HS_RX_LINEARPOSITIONCNTR_LOW; + pos_high_reg = ACP_HS_RX_LINEARPOSITIONCNTR_HIGH; + break; + case ACP_SDW1_BT_RX: + pos_low_reg = ACP_P1_BT_RX_LINEARPOSITIONCNTR_LOW; + pos_high_reg = ACP_P1_BT_RX_LINEARPOSITIONCNTR_HIGH; + break; + default: + pr_err("%s Invalid stream id:%d\n", __func__, rtd->stream_id); + return -EINVAL; + } + + if (pos_low_reg) { + byte_count.bcount.high = acp63_readl(rtd->acp_base + pos_high_reg); + byte_count.bcount.low = acp63_readl(rtd->acp_base + pos_low_reg); + } + return byte_count.bytescount; +} + +static snd_pcm_uframes_t acp63_sdw_dma_pointer(struct snd_soc_component *comp, + struct snd_pcm_substream *stream) +{ + struct sdw_stream_instance *sdw_ins; + u32 pos, buffersize; + u64 bytescount; + + sdw_ins = stream->runtime->private_data; + buffersize = frames_to_bytes(stream->runtime, + stream->runtime->buffer_size); + bytescount = acp63_sdw_get_byte_count(sdw_ins); + if (bytescount > sdw_ins->bytescount) + bytescount -= sdw_ins->bytescount; + pos = do_div(bytescount, buffersize); + return bytes_to_frames(stream->runtime, pos); +} + +static int acp63_sdw_dma_new(struct snd_soc_component *component, + struct snd_soc_pcm_runtime *rtd) +{ + struct device *parent = component->dev->parent; + + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, + parent, SDW_MIN_BUFFER, SDW_MAX_BUFFER); + return 0; +} + +static int acp63_sdw_dma_close(struct snd_soc_component *component, + struct snd_pcm_substream *substream) +{ + struct sdw_dma_dev_data *sdw_dma_data; + struct snd_soc_pcm_runtime *prtd; + struct sdw_stream_instance *sdw_ins; + + prtd = asoc_substream_to_rtd(substream); + component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + sdw_dma_data = dev_get_drvdata(component->dev); + sdw_ins = substream->runtime->private_data; + if (!sdw_ins) + return -EINVAL; + sdw_dma_data->sdw_stream[sdw_ins->stream_id] = NULL; + kfree(sdw_ins); + return 0; +} + +static int acp63_sdw_dma_start(struct snd_pcm_substream *stream) +{ + struct sdw_stream_instance *sdw_ins; + struct snd_soc_pcm_runtime *prtd; + u32 stream_id; + u32 sdw_dma_reg; + u32 sdw_dma_en_stat_reg; + u32 sdw_dma_stat; + u32 val; + int timeout = 0; + + sdw_ins = stream->runtime->private_data; + prtd = stream->private_data; + stream_id = sdw_ins->stream_id; + switch (stream_id) { + case ACP_SDW_AUDIO_TX: + sdw_dma_reg = ACP_SW_AUDIO_TX_EN; + sdw_dma_en_stat_reg = ACP_SW_AUDIO_TX_EN_STATUS; + break; + case ACP_SDW_BT_TX: + sdw_dma_reg = ACP_SW_BT_TX_EN; + sdw_dma_en_stat_reg = ACP_SW_BT_TX_EN_STATUS; + break; + case ACP_SDW_HS_TX: + sdw_dma_reg = ACP_SW_HEADSET_TX_EN; + sdw_dma_en_stat_reg = ACP_SW_HEADSET_TX_EN_STATUS; + break; + case ACP_SDW1_BT_TX: + sdw_dma_reg = ACP_P1_SW_BT_TX_EN; + sdw_dma_en_stat_reg = ACP_P1_SW_BT_TX_EN_STATUS; + break; + case ACP_SDW_AUDIO_RX: + sdw_dma_reg = ACP_SW_AUDIO_RX_EN; + sdw_dma_en_stat_reg = ACP_SW_AUDIO_RX_EN_STATUS; + break; + case ACP_SDW_BT_RX: + sdw_dma_reg = ACP_SW_BT_RX_EN; + sdw_dma_en_stat_reg = ACP_SW_BT_RX_EN_STATUS; + break; + case ACP_SDW_HS_RX: + sdw_dma_reg = ACP_SW_HEADSET_RX_EN; + sdw_dma_en_stat_reg = ACP_SW_HEADSET_RX_EN_STATUS; + break; + case ACP_SDW1_BT_RX: + sdw_dma_reg = ACP_P1_SW_BT_RX_EN; + sdw_dma_en_stat_reg = ACP_P1_SW_BT_RX_EN_STATUS; + break; + default: + return -EINVAL; + } + acp63_writel(0x01, sdw_ins->acp_base + sdw_dma_reg); + while (++timeout < ACP_COUNTER) { + sdw_dma_stat = acp63_readl(sdw_ins->acp_base + sdw_dma_en_stat_reg); + if (sdw_dma_stat & BIT(0)) { + val = acp63_readl(sdw_ins->acp_base + sdw_dma_reg); + dev_dbg(prtd->dev, "%s stream_id:0x%x dma_reg[0x%x]:0x%x\n", + __func__, stream_id, sdw_dma_reg, val); + return 0; + } + udelay(ACP_DELAY_US); + } + return -ETIMEDOUT; +} + +static int acp63_sdw_dma_stop(struct snd_pcm_substream *stream) +{ + struct sdw_stream_instance *sdw_ins; + struct snd_soc_pcm_runtime *prtd; + u32 stream_id; + u32 sdw_dma_reg; + u32 sdw_dma_en_stat_reg; + u32 sdw_dma_stat; + u32 val; + int timeout = 0; + + prtd = stream->private_data; + sdw_ins = stream->runtime->private_data; + stream_id = sdw_ins->stream_id; + switch (stream_id) { + case ACP_SDW_AUDIO_TX: + sdw_dma_reg = ACP_SW_AUDIO_TX_EN; + sdw_dma_en_stat_reg = ACP_SW_AUDIO_TX_EN_STATUS; + break; + case ACP_SDW_BT_TX: + sdw_dma_reg = ACP_SW_BT_TX_EN; + sdw_dma_en_stat_reg = ACP_SW_BT_TX_EN_STATUS; + break; + case ACP_SDW_HS_TX: + sdw_dma_reg = ACP_SW_HEADSET_TX_EN; + sdw_dma_en_stat_reg = ACP_SW_HEADSET_TX_EN_STATUS; + break; + case ACP_SDW1_BT_TX: + sdw_dma_reg = ACP_P1_SW_BT_TX_EN; + sdw_dma_en_stat_reg = ACP_P1_SW_BT_TX_EN_STATUS; + break; + case ACP_SDW_AUDIO_RX: + sdw_dma_reg = ACP_SW_AUDIO_RX_EN; + sdw_dma_en_stat_reg = ACP_SW_AUDIO_RX_EN_STATUS; + break; + case ACP_SDW_BT_RX: + sdw_dma_reg = ACP_SW_BT_RX_EN; + sdw_dma_en_stat_reg = ACP_SW_BT_RX_EN_STATUS; + break; + case ACP_SDW_HS_RX: + sdw_dma_reg = ACP_SW_HEADSET_RX_EN; + sdw_dma_en_stat_reg = ACP_SW_HEADSET_RX_EN_STATUS; + break; + case ACP_SDW1_BT_RX: + sdw_dma_reg = ACP_P1_SW_BT_RX_EN; + sdw_dma_en_stat_reg = ACP_P1_SW_BT_RX_EN_STATUS; + break; + default: + return -EINVAL; + } + acp63_writel(0, sdw_ins->acp_base + sdw_dma_reg); + while (++timeout < ACP_COUNTER) { + sdw_dma_stat = acp63_readl(sdw_ins->acp_base + sdw_dma_en_stat_reg); + if (sdw_dma_stat == 0) { + val = acp63_readl(sdw_ins->acp_base + sdw_dma_reg); + dev_dbg(prtd->dev, "%s stream_id:0x%x dma_reg[0x%x]:0x%x\n", + __func__, stream_id, sdw_dma_reg, val); + return 0; + } + udelay(ACP_DELAY_US); + } + return -ETIMEDOUT; +} + +static int acp63_sdw_dma_trigger(struct snd_soc_component *comp, + struct snd_pcm_substream *substream, + int cmd) +{ + int ret; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: + ret = acp63_sdw_dma_start(substream); + break; + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_STOP: + ret = acp63_sdw_dma_stop(substream); + break; + default: + ret = -EINVAL; + } + if (ret) + dev_err(comp->dev, "trigger %d failed: %d", cmd, ret); + return ret; +} + static const struct snd_soc_component_driver acp63_sdw_component = { .name = DRV_NAME, + .open = acp63_sdw_dma_open, + .close = acp63_sdw_dma_close, + .hw_params = acp63_sdw_dma_hw_params, + .trigger = acp63_sdw_dma_trigger, + .pointer = acp63_sdw_dma_pointer, + .pcm_construct = acp63_sdw_dma_new, }; static int acp63_sdw_platform_probe(struct platform_device *pdev) From patchwork Wed Jan 11 09:02:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096295 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 DAA4EC5479D for ; Wed, 11 Jan 2023 09:04:07 +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 4C4B25EAD; Wed, 11 Jan 2023 10:03:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4C4B25EAD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427846; bh=Pwlw3eXQSLXdxJWxWnhhk9+Mphjl7fsW7kM/b7gqh3U=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=KoYHuODm0+FWNyQrXpQrKV/n+k2U0tMnBceo72pJDdtFoonE43wvUo3HcslGvXZNz X1JvImpTLsNln13wm+1dSDRnGWefPtNCc8WZ0PS8IH3/Y1ZhjDAX4DYeH5HFpTgxU9 P5x+D6RZl/blk0F808Hz5LKh4SltPILZm7h5wBaw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9CC34F803DC; Wed, 11 Jan 2023 10:02:09 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E6093F803DC; Wed, 11 Jan 2023 10:02:08 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2057.outbound.protection.outlook.com [40.107.94.57]) (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 B0416F803DC for ; Wed, 11 Jan 2023 10:02:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B0416F803DC 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=gZXW9xAa ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ekEYr70zHq8sKbnrnH7bRMypdXx2+4vsw0+SeR8Jz2afGGM1fxrU6vEonY9wCgfDVTO0RSEoX8AKTpMMD26PWgnAuV0PpwVcdbcIJ2MrsI1oR/37lZT/OyuzXgRcYTmZ6pmvxayhEMSBPzP7CQ3hnCrnNUjUOuCH+wR3pWa/Jw7eEXb3ZaOtQ04g97Djba5MXBbfo29bvf+sv2wCU8qERVX+Ul1Ik1DJV1JPUzSEFTwBSokJM7tzZ77gmMNsJC8//I292bMQjo1MkGBl2ZOAppwoVBTmEMJXYZdWkGg4j5+1YcwrwUjAd7mTc3AUqkDdBR1Z42OcZvPGd606kxpW+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ae4ehQKMdSLn9XALRAPMG46D6I8GsK7uzgwpr42I1x0=; b=eY5XH283SDUiE6/8b9MzlVEs6VB1YC33kqxJG+suADUXjp/mLJz3HOPiwolqjG3xuAkGW5IRSgvgEiV+G6BkXAcJcEtijDlblYPPnsAka1pAs4wKJDPjP/PBaiNk/KukvC8CdPHWBn8L9FN8BK5Y3kVqZKIbQUmKhRNUy30A+Bk2mcbhQ+PeWUnP+BgrkSGYvoM2/PHUoXaGrDKDYPIHtpqtoPBTvXUlSu9LWZRGsyqtJlo0rGrz+vD8+zTZf0W9p/RLF+86ATuIu+tza8S06cQbpb2dnIekVcEc1FegdU30I/rmbeP0bW7GibtEhVMUzB6v693AJWEROCv/i5E3jA== 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 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=Ae4ehQKMdSLn9XALRAPMG46D6I8GsK7uzgwpr42I1x0=; b=gZXW9xAaJWIMsH9v/XPwRuKk+Hd8sA3mHu5lUH9uJTFXw2fhOd7CEwZT23DndftUuCspHwZsmhHNdwi1avcoWCUj+5mIRL5Jnrqjk7U9vDIvtdiPQKvA9GaNGbkXwFFScHo0j01ZGDBjKgcKGWAAQUEaU+OoLJ8ci5kj5wa/Bpk= Received: from BN0PR07CA0023.namprd07.prod.outlook.com (2603:10b6:408:141::6) by PH7PR12MB6719.namprd12.prod.outlook.com (2603:10b6:510:1b2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:02:01 +0000 Received: from BN8NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:408:141:cafe::90) by BN0PR07CA0023.outlook.office365.com (2603:10b6:408:141::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:02:01 +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 BN8NAM11FT085.mail.protection.outlook.com (10.13.176.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:02:01 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) 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.2375.34; Wed, 11 Jan 2023 03:01:09 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 11 Jan 2023 01:00:45 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:00:41 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 09/19] ASoC: amd: ps: add support for Soundwire DMA interrupts Date: Wed, 11 Jan 2023 14:32:12 +0530 Message-ID: <20230111090222.2016499-10-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT085:EE_|PH7PR12MB6719:EE_ X-MS-Office365-Filtering-Correlation-Id: 8129a384-f5f3-4d7d-ffbf-08daf3b2806c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4+cqvRGL49pGSA566TYlCOvlGoLjrnO/rGiDPvMhgaB2Xex93d7zNTmSlyWiyQ453W4WG3emLwDirR21mx0k19Y3871N0T5dgosBakbO+q2GsfaphKhLhkpy0Hj880of4nhP3TTNfKrEB6mn0j8LqwmyK/Rg21vaQ3ii3VleE3Py6QE53OeqxEfwGFuWFhtGJlduuPWlFLxxDLSskdk5iRJ+ARrY7f59XMvkSWi9mLva9p8pYAC6XCXeHMT4KuWI2Wg12VEpxuBlUmWvX+cLxcUV7VB6HEN/qQ7/x9UEE1KrD8aYWq2Zuigd60YEdsIRpSi6U7gh4lsdObOfRc1fcLmbESkFbgL2JXCLSnOVuntz1o/5iuXklW6ZCOAgJpQir7IKsY2lGIeKaFoqav4Lt62TuRS3tE0lLYgf2yl6GPv/hrIWuFc7hmNoginem9uY1IJB5BhjdAWt7VNakM2LSYj5mUKswClA/mYOGfoEjdAIMpb448qFGfIQ4a9ez3hjnXd/scemOiBbvJq5rx85CZMQLRogSC9bZO9ztpwAvxI5m396xQHJbs4Vg9LdBJfo+W8qfmTKMFy5rB+TcHE35HnkB17h84guycIDLupVNZMRq0QNtp3jWl5Vmc7q+GpYsQhx0+XQXXR1uWGOBam7Iisg+yRePKevC6zNyG2heE3Nls0RooRYEqbOnKVq4Yt0uB4pmLoPIPB3CmusFZ/GXV6wqEMRHNzat797ObeqDac= 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:(13230022)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199015)(36840700001)(40470700004)(46966006)(82310400005)(2906002)(36756003)(5660300002)(8936002)(70206006)(6666004)(8676002)(41300700001)(2616005)(70586007)(316002)(7696005)(4326008)(54906003)(110136005)(478600001)(40480700001)(26005)(186003)(336012)(1076003)(426003)(86362001)(47076005)(83380400001)(36860700001)(40460700003)(356005)(81166007)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:02:01.0389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8129a384-f5f3-4d7d-ffbf-08daf3b2806c 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: BN8NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6719 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pierre-Louis Bossart , Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Nathan Chancellor , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Syed Saba Kareem Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Initialize workqueue for DMA interrupts handling. Whenever audio data equal to the Soundwire FIFO watermark level are produced/consumed, interrupt is generated. Acknowledge the interrupt and schedule the workqueue. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/acp63.h | 2 + sound/soc/amd/ps/pci-ps.c | 81 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index 8963cfb6120d..833d0b5aa73d 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -167,9 +167,11 @@ struct acp63_dev_data { struct platform_device *pdev[ACP63_DEVS]; struct mutex acp_lock; /* protect shared registers */ struct fwnode_handle *sdw_fw_node; + struct work_struct acp_sdw_dma_work; u16 pdev_mask; u16 pdev_count; u16 pdm_dev_index; + u16 dma_intr_stat[ACP63_SDW_MAX_STREAMS]; u8 sdw_master_count; u16 sdw0_dev_index; u16 sdw1_dev_index; diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c index 0fbe5e27f3fb..5b82ee8e3ad8 100644 --- a/sound/soc/amd/ps/pci-ps.c +++ b/sound/soc/amd/ps/pci-ps.c @@ -113,14 +113,37 @@ static int acp63_deinit(void __iomem *acp_base, struct device *dev) return 0; } +static void acp63_sdw_dma_workthread(struct work_struct *work) +{ + struct acp63_dev_data *adata = container_of(work, struct acp63_dev_data, + acp_sdw_dma_work); + struct sdw_dma_dev_data *sdw_dma_data; + u32 stream_index; + u16 pdev_index; + + pdev_index = adata->sdw_dma_dev_index; + sdw_dma_data = dev_get_drvdata(&adata->pdev[pdev_index]->dev); + + for (stream_index = 0; stream_index < ACP63_SDW_MAX_STREAMS; stream_index++) { + if (adata->dma_intr_stat[stream_index]) { + if (sdw_dma_data->sdw_stream[stream_index]) + snd_pcm_period_elapsed(sdw_dma_data->sdw_stream[stream_index]); + adata->dma_intr_stat[stream_index] = 0; + } + } +} + static irqreturn_t acp63_irq_handler(int irq, void *dev_id) { struct acp63_dev_data *adata; struct pdm_dev_data *ps_pdm_data; struct amd_sdwc_ctrl *ctrl; u32 ext_intr_stat, ext_intr_stat1; + u32 stream_id = 0; u16 irq_flag = 0; + u16 sdw_dma_irq_flag = 0; u16 pdev_index; + u16 index; adata = dev_id; if (!adata) @@ -159,7 +182,58 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) snd_pcm_period_elapsed(ps_pdm_data->capture_stream); irq_flag = 1; } - if (irq_flag) + if (ext_intr_stat & ACP_SDW_DMA_IRQ_MASK) { + for (index = ACP_HS_RX_THRESHOLD; index <= ACP_AUDIO_TX_THRESHOLD; index++) { + if (ext_intr_stat & BIT(index)) { + acp63_writel(BIT(index), + adata->acp63_base + ACP_EXTERNAL_INTR_STAT); + switch (index) { + case ACP_AUDIO_TX_THRESHOLD: + stream_id = ACP_SDW_AUDIO_TX; + break; + case ACP_BT_TX_THRESHOLD: + stream_id = ACP_SDW_BT_TX; + break; + case ACP_HS_TX_THRESHOLD: + stream_id = ACP_SDW_HS_TX; + break; + case ACP_AUDIO_RX_THRESHOLD: + stream_id = ACP_SDW_AUDIO_RX; + break; + case ACP_BT_RX_THRESHOLD: + stream_id = ACP_SDW_BT_RX; + break; + case ACP_HS_RX_THRESHOLD: + stream_id = ACP_SDW_HS_RX; + break; + } + + adata->dma_intr_stat[stream_id] = 1; + sdw_dma_irq_flag = 1; + } + } + } + + /* SDW1 BT RX */ + if (ext_intr_stat1 & BIT(ACP_P1_BT_RX_THRESHOLD)) { + acp63_writel(BIT(ACP_P1_BT_RX_THRESHOLD), + adata->acp63_base + ACP_EXTERNAL_INTR_STAT1); + adata->dma_intr_stat[ACP_SDW1_BT_RX] = 1; + sdw_dma_irq_flag = 1; + } + + /* SDW1 BT TX*/ + if (ext_intr_stat1 & BIT(ACP_P1_BT_TX_THRESHOLD)) { + acp63_writel(BIT(ACP_P1_BT_TX_THRESHOLD), + adata->acp63_base + ACP_EXTERNAL_INTR_STAT1); + adata->dma_intr_stat[ACP_SDW1_BT_TX] = 1; + sdw_dma_irq_flag = 1; + } + + if (sdw_dma_irq_flag) + schedule_work(&adata->acp_sdw_dma_work); + + if (irq_flag || sdw_dma_irq_flag) return IRQ_HANDLED; else return IRQ_NONE; @@ -240,6 +314,7 @@ static int get_acp63_device_config(u32 config, struct pci_dev *pci, struct acp63 if (sdw_dev) { is_sdw_dev = true; acp_data->sdw_fw_node = acpi_fwnode_handle(sdw_dev); + INIT_WORK(&acp_data->acp_sdw_dma_work, acp63_sdw_dma_workthread); ret = sdw_amd_scan_controller(dev); if (ret) return ret; @@ -612,6 +687,10 @@ static void snd_acp63_remove(struct pci_dev *pci) int ret, index; adata = pci_get_drvdata(pci); + + if (adata->pdev_mask & ACP63_SDW_DEV_MASK) + cancel_work_sync(&adata->acp_sdw_dma_work); + for (index = 0; index < adata->pdev_count; index++) platform_device_unregister(adata->pdev[index]); ret = acp63_deinit(adata->acp63_base, &pci->dev); From patchwork Wed Jan 11 09:02:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096292 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 42D3EC5479D for ; Wed, 11 Jan 2023 09:03:28 +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 5E64277E4; Wed, 11 Jan 2023 10:02:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5E64277E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427806; bh=0cdbqmsVSk9RuMecj4C+N1lNSA/8FOyzz/JdbaJbgdM=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=AzDW3akWYYUC2dSvxL/dDSZqqisgBMt6ZR0h3r1tGXAORExNGyx4ruDpzP8tC/WsE 1SVmjecqcBEa2Ulx4xl6+VS9/i3mDlgc6WNQ5bIaXMNQ26IRZA6RlwiZfkRc0paICu ai1/DLmyF0VWsZoiQxsaIOsCUmdCD+1KmGvI6rZo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 021B0F80571; Wed, 11 Jan 2023 10:01:55 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 71356F8055A; Wed, 11 Jan 2023 10:01:53 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2086.outbound.protection.outlook.com [40.107.96.86]) (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 8787EF80571 for ; Wed, 11 Jan 2023 10:01:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8787EF80571 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=jIgQKPx2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HPNp4SRKG5beJIUobSv1BCkhRMQTUyufhoo4C4fGjxtoKbr/cn+u0GhbChOvio04GYZfn0/E5htbvjTRd9ySAxmGgxwbOwH0Msi6j1JoukR1nuqqigu9z2sRMLpkvuaRc6UEf/2Y8ll+0VDIj4kN77DNYH5fIt+dLwpCtx+Fa/owRSIbx7IezW0FAZ4sO+zNSK83qM25RSIYNM/viyc6f0dOXqoa9s5n9EogESuVN/xFgBMCu/NAzN6qIy44YEjR5a8voeUNC/2CP5+q+6sqmLlGuxekVsGFUXOGqEZcVqymGCIyKuVuRNr72xLzJG9Bgc1kY9RVidpirS2TGFcW7w== 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=AgIVun9p3HbmExWmkSyPXi0ZP4KKvEqfg6Tx/AxFJHU=; b=eeb/Ag3//IByCDHD72P1+noCK2IPU8Re0Tgo23Z+sRum4h5deCGv94IY5BRslITy10eQNwBMQQ5c2lemNKwqZRPEVCNxGMTSzYg/zPMUe9PwOgYziLtrCR01yqJObVPgxcvFEEcuzlqm1nkoAgLkA8czZTgaoC1sdIHkEIzYx222Fg2Fa6osT8s3GT4AGi7Lpg4maYHm3s/QRcuV8MHj991z1KAh0+0wQfk+K/YuhMtn+ujggMl5mwcMotqf3kIs70gZeU2EXzbFz21Fn0cKY3lkkbqhyXcRyf7AP9mgBWW+SYS6awXncCcMq2lJjZsTi+KQd09gwhnGXCqYuXlkEw== 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 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=AgIVun9p3HbmExWmkSyPXi0ZP4KKvEqfg6Tx/AxFJHU=; b=jIgQKPx2mK9F0FMqgdO7chrNf+g6WZi6B4p6/fRhlDlqKTDR0gPT443XRN4XZ/hvXdymN9xy9ZmyGa4rBxxVPaqJm42YTneaBDXl+zYMVbNRsZMtxrVlsZRAKHxGe5laTM6Abin80Pp95lyhJYdv0rMzbqUIO+QuBTEpdZ8xAfU= Received: from DS7PR05CA0096.namprd05.prod.outlook.com (2603:10b6:8:56::28) by SN7PR12MB8004.namprd12.prod.outlook.com (2603:10b6:806:341::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 11 Jan 2023 09:01:48 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:8:56:cafe::b9) by DS7PR05CA0096.outlook.office365.com (2603:10b6:8:56::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12 via Frontend Transport; Wed, 11 Jan 2023 09:01:47 +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 DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:01:47 +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.2375.34; Wed, 11 Jan 2023 03:01:46 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 03:01:46 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:01:10 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 10/19] ASoC: amd: ps: enable Soundwire DMA driver build Date: Wed, 11 Jan 2023 14:32:13 +0530 Message-ID: <20230111090222.2016499-11-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT016:EE_|SN7PR12MB8004:EE_ X-MS-Office365-Filtering-Correlation-Id: 23a3b59d-4ab8-414b-155e-08daf3b27858 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WZMbO/9xkQz7wjpRoyTZrkwLdPuKL41/F1K56Bs+sHwf7C98Bu9nv7i+Yr0Vw0Zn05KyltXKs1+zAod+IsDUMzGD75uJm5BYslei7bHPf66iE4+7FWCOMsudWL+7CRNR4Ps9kaYruh8NfNzq24iM/oL6tQbIi0E+5OsrF2Pk92RWWEmh1x+IpE6JF2DQdlxIjTdY2CX7YRM4HGp3JBqZeyrJlX5Vh/Gw+N31fUGjNlPdejPKINehRKppc+RyuoTOUK5qgg64FfoaysDpizLWfKRGH/SOuIKhvFiU3Oo4c+pMncn5JRzpafMfCygGxNHihjcb22AQa+1zmR+xIXRuKn/kzmGRPjwEMdHRb8eIV74w+mYPAD5oS2/c/XSwNY0sYzsnfDpxXpyPQNcvvHqXvinw4xCW7NqhVcqFuZC4ZfD8smtSpWCfXGu0PHj1J6PSq3VMWEYYHhJNpdBktDlIQyvxwFDOYZDELVwsKayT3r2wy8fdWgo/3vIUqdnlM+rinxI0TJUcMxzZtx0C+YstccNoBoT7PCJ425UzfBaJbZ5BYgWPzAJup5m3yAT8yZHDmUlR2s22jAX17FIR5hiiEbGW6/6Az/TYMeNDvxMb0GMtsnAYq7ixcmpBau00F720QJzlNOtXW1lnmrL2yx3LQ/dfazCjbGCXDebzm0DQq11t2nz8PdrP1zYmsTisXsVzKDOOpJBslIGlsAfmWC/K3Qz9cjNbtfa97lR2D/zjWh8= 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:(13230022)(4636009)(376002)(346002)(136003)(396003)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(82740400003)(426003)(81166007)(41300700001)(356005)(47076005)(478600001)(1076003)(40460700003)(86362001)(110136005)(54906003)(2616005)(316002)(336012)(7696005)(82310400005)(186003)(26005)(40480700001)(70206006)(70586007)(4326008)(8676002)(36756003)(5660300002)(36860700001)(2906002)(4744005)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:01:47.4332 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23a3b59d-4ab8-414b-155e-08daf3b27858 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: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8004 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Syed Saba Kareem Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Enable Soundwire DMA driver build for PS platform. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/amd/ps/Makefile b/sound/soc/amd/ps/Makefile index 383973a12f6a..a3da8670e3e2 100644 --- a/sound/soc/amd/ps/Makefile +++ b/sound/soc/amd/ps/Makefile @@ -3,7 +3,9 @@ snd-pci-ps-objs := pci-ps.o snd-ps-pdm-dma-objs := ps-pdm-dma.o snd-soc-ps-mach-objs := ps-mach.o +snd-ps-sdw-dma-objs := ps-sdw-dma.o obj-$(CONFIG_SND_SOC_AMD_PS) += snd-pci-ps.o obj-$(CONFIG_SND_SOC_AMD_PS) += snd-ps-pdm-dma.o +obj-$(CONFIG_SND_SOC_AMD_PS) += snd-ps-sdw-dma.o obj-$(CONFIG_SND_SOC_AMD_PS_MACH) += snd-soc-ps-mach.o From patchwork Wed Jan 11 09:02:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096293 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 B5367C5479D for ; Wed, 11 Jan 2023 09:03:38 +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 6F81749D3; Wed, 11 Jan 2023 10:02:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6F81749D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427816; bh=ZriLAUAqSVJ3WdO3WXP44+ykCusNIBMeiLHaD2MaUIo=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=AlsTVyLaEDO3wFGM3RzGJllSm034gQH2GCCybFStRW9MUGV1JpXZe5covhVLqhuM6 OlqyZUahNYA6q9tl6eJQxlCzhBhA8fCjcJdv11d2/yHj29VlLPb4ChkTLR6iawzXBt +Wfg8oVsoktm3x11/u4akQ7x/zqLjlvo+Wglo2S0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C3FBBF80589; Wed, 11 Jan 2023 10:01:59 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5586DF80589; Wed, 11 Jan 2023 10:01:58 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) (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 4DC1AF80579 for ; Wed, 11 Jan 2023 10:01:56 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4DC1AF80579 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=OGPesfv/ ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C7fbOjRixELdt0G9zXxEhNbhHeN8q6GmP27A6Sbj79mlzE8gBlQj10QV6c33O3zz2WzszGj7Qmfdt04HewCijybG04eSWqubrYpEic+jzaP7MDA1jPLbmheoC87EGxA+2bdXYZRmFa5nnLQCN4VWus4oDuOr+Cydxgrd249W/e4fp41yZ0PwkdjByigfao9smmPy312PJglTFm4I4PPkbglToDh/j6NsXqarJLUL9afFy0jxZ2PAVpzhFDcA8rcp5QGiHKyI9+a/9k7ugb8bCYW7gg/jYf5aPuYnHMSVf296IwRaalFWbZXpw+SpF5NIhO1uiGwIOEz+F+1S9tuCJg== 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=d8FKM8p6lvQFixka7PVxUHl/w3rLXcJGY/h61/YHaJ0=; b=BGjebrrV9wJ+6RM2EH5dUB9MhKkzG5YfuFnJ/+PCgtAIoEfDuxQXqv/Fcgt00zeAM77FcpNj7xZ53/ymnFSTl0Mke+Lrz86vT3oe3BV5LqYwZj/YGi2wyOSwY5C7HhS6T73NAPIXuS/GzGlE4gjdJuiP+8B1I7OIGowtyvbQVbqCXULqM2j0ECE9Nhp1bdfm2fcuIb8/LhmLXjIPg0yPCmv9kcv3iUPlBvlM+7TExP4dwpCCnX5jtBVfknpqjLDO1Oa4SG1/ye1K3pGEADj6YcR40sRTTR+duvgWV2FaBadsmEZ0i0RhvAMMBIyoo6QOSSVuj8+FqeT4Bwgy6bN7Ig== 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 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=d8FKM8p6lvQFixka7PVxUHl/w3rLXcJGY/h61/YHaJ0=; b=OGPesfv/izQQwdqF7RmF4R219n8hcWmFB/uE7torUNcUph9RYTcDewRge+zT+2eJGfINdAUHt2c58ueSGbo12XzQdg+hSaaVqjna25O3hJjdw2EF3g4mAs2A+BhTjym0C11RQWGylPoVBqNEgmr6l+4/ErVXO82j+h3Fr3/Az4o= Received: from DM6PR11CA0056.namprd11.prod.outlook.com (2603:10b6:5:14c::33) by DM8PR12MB5479.namprd12.prod.outlook.com (2603:10b6:8:38::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:01:53 +0000 Received: from DM6NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:5:14c:cafe::ee) by DM6PR11CA0056.outlook.office365.com (2603:10b6:5:14c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:01:53 +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 DM6NAM11FT024.mail.protection.outlook.com (10.13.172.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:01:52 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 03:01:51 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:01:47 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 11/19] ASoC: amd: update comments in Kconfig file Date: Wed, 11 Jan 2023 14:32:14 +0530 Message-ID: <20230111090222.2016499-12-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT024:EE_|DM8PR12MB5479:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ce74972-8cbd-4fef-0e7d-08daf3b27b77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PMBo9/cc5GE1//KQqKt7iU1rkYp+7kFfPBJFGFi4a7YwKHftCHqafJ0UExomwEoQcLcLkl1K69499MQ0PSE2G00DwUdcx0LypqvhRveNR8OMV9RWSHMxoTjJIcATWOZA7lUSjF34EkmiR1N6V4QKS0m+nLlBa8O2y55Bx3bR1OGYbpYMZxQXXrypr8NcWrW0yaUmmlpV6PsVEXGKwlAbIttvBMI9+FXs1MQdSghilueTTfZ6nLdlG0D+chyZtHEJkRbI+M9vpwlCDiErkVFnewP7gN9EEMTPt7b6pYuF08P0NW396G1YRgRbu7uuGo7IECLtyKqycYocopDrtRghvWX4WRVJZOJq7wm7szMQQE34pX1bkg+b7Tc4FkwKDGN/YZm/0JM64eQs3EIvZzkhbwP42A2H1n05b7rm6AM6ZGqunM/zLhvRtkk97zGxINqO03rMy77DSvSO7xwxyRFAuwdZC6cNxATwolwE3xr9/09LcWsksf1rS4oqsBera+RcNNIydEY1itkjmU6haiGn/4uGkOsJ4AnWrTTENYpQ1i/HIupl+aAr2eRIyFEUjOalLkCS3Tyos+5lukTgPLHOBGCcsikAY6Bs/+lhHwid+rn6XSnAl8u72GxLf9vOBdMLg5RNhwY0xE+NupR9ODLU/oLi4A4ysFrOFMWuSg8ebjs2uKGmM16H9ICjugcs6zvj5mK1+UGD8CFp8XbSURvVJwqKLKX4/0605SBO1SdP9ns= 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:(13230022)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199015)(46966006)(40470700004)(36840700001)(82310400005)(47076005)(8936002)(2906002)(5660300002)(81166007)(41300700001)(426003)(4744005)(70206006)(7696005)(316002)(4326008)(70586007)(8676002)(356005)(15650500001)(110136005)(54906003)(26005)(82740400003)(1076003)(40480700001)(2616005)(336012)(86362001)(40460700003)(186003)(36860700001)(83380400001)(36756003)(6666004)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:01:52.6693 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ce74972-8cbd-4fef-0e7d-08daf3b27b77 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: DM6NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5479 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, Ajit Kumar Pandey , open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Randy Dunlap , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, syed saba kareem Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Update comments in Kconfig file for PS platform. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/amd/Kconfig b/sound/soc/amd/Kconfig index c88ebd84bdd5..50bcec55a275 100644 --- a/sound/soc/amd/Kconfig +++ b/sound/soc/amd/Kconfig @@ -134,7 +134,8 @@ config SND_SOC_AMD_PS help This option enables Audio Coprocessor i.e ACP v6.3 support on AMD Pink sardine platform. By enabling this flag build will be - triggered for ACP PCI driver, ACP PDM DMA driver. + triggered for ACP PCI driver, ACP PDM DMA driver, ACP SDW DMA + driver. Say m if you have such a device. If unsure select "N". From patchwork Wed Jan 11 09:02:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096294 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 884EFC5479D for ; Wed, 11 Jan 2023 09:03:51 +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 9C8CF7836; Wed, 11 Jan 2023 10:02:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9C8CF7836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427829; bh=SrZMzDhq+qSDousGjVp4hOSK1iklQsYniVEgyzAqsnw=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=aZf5cfAfR9I3EcUXLsH1IIMLb19vLtO1HHIsU0ej0EN9AV8/gmN8zi//vWAhsCFSg e3GqiZRwBqdCimAMvuMobtpQ0n5kLWzb9HEA4azle91vZHLYy/a/Llih2n06FP7NWL cayLW5hsl9TSVtunSPAfBEmtqyIL+ajZZ4SVZ8IA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1ACA2F80558; Wed, 11 Jan 2023 10:02:07 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E0669F80579; Wed, 11 Jan 2023 10:02:05 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) (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 0A185F8056F for ; Wed, 11 Jan 2023 10:02:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0A185F8056F 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=xXZ/eBGB ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R7+jsm+dettjA0n9OQD+ERtbuhKYD4ynQYAILJIZxoX3JJ27AdlZ3ON7xr8mPjrBoM9O1BKOC3JW6oY3esiAye9ce5CSaN2uPemifscVHmE1VeqgFwIfCMR4L8kVoGaiEfYtoBIujBc6sMSZNazaQXuB0qmGIDEc8WrC1owvYZ+VVd1GLp54livKOitr0Ir/sYQYElnqtPxQf6ghfCGbGWcYTHPbLFL9oPG8gmO13r1Xw6TlEEnpsfiPw3VHur0GQ1ndFdHfLcjMcKmBZr7ZDJc+LQPE+D3iYw39NqG3nPgSELWd2mhSd3fOoQ5uWT6SFdIcH8dabwqIT+PODXE9jQ== 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=xEscQLXyUmWUlrmGu2eNyzpYg5ma3d7Fyq0ZRxPKogc=; b=GX6M6iXSEON1U+FY1B4QgE5bMUrqd/VeqO3y1yc1yIKzQHtQHEAzbXwzn1wFxugjLWFOiiCRRsVICcP+C7swTq34VsJzQT5TS0/7aksGCnpbCX6pDUIi4+Wb4SI9eKRAe3qs7HsVI4kkFDVAjQ5+oZO7ASwW6HwbhWxG56piuyYKLkStKXWJ/dZuS6YGlTu5sxu7E1PvIrOZNUBXlpjDqvnkdBV9fEYkJPGDRO9r/DO0ZIZJU+KzY9AwJWXtSyNGb3NGB46iD0Dp2uP7eh85LuZCsAYx4fxhCyfNwf27gH3zHtreyAtA/pevMI6G5hoe/GjlpH+KJitjQRR1IeRaXQ== 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 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=xEscQLXyUmWUlrmGu2eNyzpYg5ma3d7Fyq0ZRxPKogc=; b=xXZ/eBGBdj3Dy5UQIL1Rtgb8XrSARppHfLfna+KIVsdynVz2sN2OwAJJJP3lrgtGksVOFp7Oidn8FdZdQK7wgfWZqncg4i7gdY9GgKSURrFQ4+m4suAWtTRykIBOLRUt+sBKkZLYGODzd068EDnOSrDmepIpjHctyJUL3+kQig8= Received: from DM6PR11CA0054.namprd11.prod.outlook.com (2603:10b6:5:14c::31) by MN2PR12MB4392.namprd12.prod.outlook.com (2603:10b6:208:264::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:02:01 +0000 Received: from DM6NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:5:14c:cafe::68) by DM6PR11CA0054.outlook.office365.com (2603:10b6:5:14c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:02:01 +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 DM6NAM11FT024.mail.protection.outlook.com (10.13.172.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:02:00 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 03:01:58 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:01:54 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 12/19] ASoC: amd: ps: Add soundwire specific checks in pci driver in pm ops. Date: Wed, 11 Jan 2023 14:32:15 +0530 Message-ID: <20230111090222.2016499-13-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT024:EE_|MN2PR12MB4392:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c36e90a-ca22-4762-976c-08daf3b28047 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rMY/HwGPUBEYupof5vNt2jGgvxv5tPvGiqmaqNOjEndCHlJZ5IK0Owr6PjitSheGXLS21+UscgzWAg5lsVrGf9pGY/+PDWst1EHmR/UVKyvsCebwTzkCd8vkfOTOGJqYeSIH6X1loMUpvAykw8IYYW4hflTLz1pNXTE38ViEAehl2NDNdiaID8tIjwbxEqQWpsi0VwJA297yFzOOo2e21Pae+SSzrZwJ6DTbK0RrpolTw33nBKUsO2/2rnJQyIsvCcOluNuaESY1s+9m8AVgvh1JDKMr8hd4HtZAutgQdQuE99rCuIXcp3RckouD8eYJaQvsgmyc/YmV/AqiUbvcO63vvzuRCchxGSDWHKjDvjj2xhOw9nMChyQ1yx3JtQ8iT/O+I1x3M9E3QQLuSF92to6QmN/CmSt3oUfn8iCCWC4+aFi/BjQOfwxWgFu5x3GHqv9rrny4TqRk35FS4D+mT4m7bpgBCAQ24fz+Qztkr0NvYRRS1tj94r0lHp4XMzJt241kFKH32ef4+55IO2+jKode9di2Xxekv4wJxjOa1Wxwfff8gy1YBFibhSJWeIbEQawOFWGkEYsrtW/ffgvg8lPAtMnIJZ/qfU2X6kZdPyc252OYfAwwxv6m5ew2D3i7tOpvSVqBMGCY8NzXa54LYexs2+AxNA+nKDRz8gQV5lE0PZldFoy8a42Cn/xzt1ZoySyKnPRmRCGG+Uru0xLW9joIjqMRrVA/Mls7wAIdsiw= 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:(13230022)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199015)(36840700001)(46966006)(40470700004)(2906002)(54906003)(36860700001)(41300700001)(356005)(7696005)(36756003)(8936002)(8676002)(70206006)(4326008)(70586007)(83380400001)(1076003)(82310400005)(86362001)(2616005)(47076005)(426003)(336012)(40460700003)(5660300002)(40480700001)(186003)(81166007)(478600001)(110136005)(26005)(316002)(82740400003)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:02:00.7469 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c36e90a-ca22-4762-976c-08daf3b28047 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: DM6NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4392 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pierre-Louis Bossart , Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Nathan Chancellor , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Syed Saba Kareem Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" AMD Soundwire controller supports different power modes. In case of Soundwire Power off Mode, ACP pci parent driver should invoke acp de-init and init sequence during suspend/resume callbacks. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/pci-ps.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c index 5b82ee8e3ad8..7e152241c155 100644 --- a/sound/soc/amd/ps/pci-ps.c +++ b/sound/soc/amd/ps/pci-ps.c @@ -655,10 +655,15 @@ static int snd_acp63_probe(struct pci_dev *pci, static int __maybe_unused snd_acp63_suspend(struct device *dev) { struct acp63_dev_data *adata; - int ret; + int ret = 0; adata = dev_get_drvdata(dev); - ret = acp63_deinit(adata->acp63_base, dev); + if (adata->pdev_mask & ACP63_SDW_DEV_MASK) { + if (adata->acp_sdw_power_off) + ret = acp63_deinit(adata->acp63_base, dev); + } else { + ret = acp63_deinit(adata->acp63_base, dev); + } if (ret) dev_err(dev, "ACP de-init failed\n"); return ret; @@ -667,10 +672,15 @@ static int __maybe_unused snd_acp63_suspend(struct device *dev) static int __maybe_unused snd_acp63_resume(struct device *dev) { struct acp63_dev_data *adata; - int ret; + int ret = 0; adata = dev_get_drvdata(dev); - ret = acp63_init(adata->acp63_base, dev); + if (adata->pdev_mask & ACP63_SDW_DEV_MASK) { + if (adata->acp_sdw_power_off) + ret = acp63_init(adata->acp63_base, dev); + } else { + ret = acp63_init(adata->acp63_base, dev); + } if (ret) dev_err(dev, "ACP init failed\n"); return ret; From patchwork Wed Jan 11 09:02:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096296 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 009BEC46467 for ; Wed, 11 Jan 2023 09:04:33 +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 009C0783C; Wed, 11 Jan 2023 10:03:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 009C0783C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427872; bh=K6/2cpY+gj0hMEkXIuwiEUpecMxwy/oStzirnbBCGw8=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=T649C4yDhZs3e1hn2JFIU7Vca36OUBojjxI1Hw1xJZXZRCF8rEHIU1bb77CYgJA6o JpllOUjK/gSiOJYF3Ti2kK8ZAhNs3lcC48VVwGGq0VH4ecx7HJ7DgUIpQFdjl8wFHq gbLoynsfMnbPbvXZ//r+fUbJ+JjGCbhuDblw0byg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A64E9F805AA; Wed, 11 Jan 2023 10:02:18 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C32A8F805AB; Wed, 11 Jan 2023 10:02:17 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2079.outbound.protection.outlook.com [40.107.223.79]) (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 CD58CF805A0 for ; Wed, 11 Jan 2023 10:02:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CD58CF805A0 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=HqCNd/Xd ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EAplgbQ4nUldM8xN3j4hUmGhFxGecHkHV8Qy4BERsXQVL2xcYxYkC997yzF5RdnsogU2myNWH6plDubZ8y8nTvgtXXKxjeINrImhy6q5wtwv5RwncQ2lBAcgJ+1IUSAZ3NzGbOB4qbSiPRrg8O6VsmmRj69kvtboNuROOmQ0lcjrUQF4ngyUnhtoONccJ9KJV2bYWGcxISTsJYROnG94KiFIL2Za1algAonn5TkeNKa2NKGeMG4gptd1ndEanMfpvqcQO8Z9c9O7BbCQXzz+SP5nZ2+cH0++o4NsNqpOXPSFWPmuwhH3Z1bHjZz8um2PcWMQyrxnIMSWNsG8e0GlQA== 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=76mezMuevE9lC+/RR1ZkbSJx9XxLC+0W9HK8/vNNwUA=; b=b+PWWrvkuPlrdT6f6Ufg7EwKXgtS1TYJ/v27uPCypwH0M9nZEQldJDYw8UKkJrLBQ/n9g7NgFIXQesMQPJMHiiu3qT41jeodiUhZ2GVJTL14plIHGfKt1fLfMon1GEs4rQhcZB5KiC3d0RL6xJMdlPYTDORGYXoKJk2bJRu/IGoMIYELGZgyncOHCORcciWr7UCHDI2uEj1zuKtVkrUxq5FYSmdUr210guyfdYU33X6Nevdg6TQqSt6+TpL2mc6fOsHy4EYRW8u7sbMkmSJr7Ib4L/yGB/nGx7jzQuGpCyQ38ZJJ6yMho/qhhPc4MmJu9h10ZOQSra5Xkzl94hjoGA== 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 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=76mezMuevE9lC+/RR1ZkbSJx9XxLC+0W9HK8/vNNwUA=; b=HqCNd/XdA106EBLu8kz5DcGoRS7KegeM+C6B5Ec5E0oGz9XwrFgA5vzHANqCs9nFTuIkwCmi/MCam1AIWwpcOzfL7ErW2HJODmkBdQimOi5eyvfwoU+KsvkPgjTMI27u28vOBa5jBELT6Rgz7w+LdbOw7rcgft9LF6PvGpcaq2w= Received: from DS7PR05CA0057.namprd05.prod.outlook.com (2603:10b6:8:2f::21) by DM4PR12MB8572.namprd12.prod.outlook.com (2603:10b6:8:17d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:02:12 +0000 Received: from DM6NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::bb) by DS7PR05CA0057.outlook.office365.com (2603:10b6:8:2f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12 via Frontend Transport; Wed, 11 Jan 2023 09:02:12 +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 DM6NAM11FT004.mail.protection.outlook.com (10.13.172.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:02:12 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 03:02:04 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:02:00 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 13/19] ASoC: amd: ps: add support for runtime pm ops for soundwire dma driver Date: Wed, 11 Jan 2023 14:32:16 +0530 Message-ID: <20230111090222.2016499-14-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT004:EE_|DM4PR12MB8572:EE_ X-MS-Office365-Filtering-Correlation-Id: 93f59832-5fb2-4155-a7bc-08daf3b28715 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CFLXhYESgBYKay7IiujiyoQrCqGXb2BcfWEVEz3nFD/d5CcywT6Gr3buSxGHos94Ok8fevQBo/2UdSnCXMTVxlyHoW/l0dA4Yp8jg4edaBMAy8qM7HV/fJ6XfyX2+CWtfxvp/ca1ShavYmaTNHdHAiw0b5XdsXZZk9EtAnC7GOKdHySYRqJobcFB3rKsB6699EV2OTB1QA9ApEoMUtzEsv83SeSzzBYrrtsT4BhPNdTx0YxBTnv3ix8L0vLYmp4QEZAy38fI5xcshL5XzFU+aqWXvbIsoBW7e0cFwpVO4+hxmWWLqPwzT3eSBbqD6vlHvcu6ihwlK0J6tPlAY50iS8Y7DH3v72ol/BniotGSuvHKQWEHQHdFlG8ytZVnwxM62k1c0p603p6dncVoBJLOjJN0eZLYZUgbfP3LkgVRBCW9G9o/a/pbe8WvoiGnkmNHVtnOsqVvVr8eW3ArU7fx5H7ZgEb6j//CsUpo+hJfO+GwSvFOISCsmJ2nSwZvOlhSOhZ5LluC447oUFi+I5fsLQ9CSEBC6swwZesSQQzL2Gk7zX0WVcy8FJLP3k8VlqJidLtOzJchSkNDp8rBoD2n4H7hFVhaV9O1R06ZM/0nM8yO70M2Yo8KPDsdL6FfcKZKGqpxbQnsoiyQgh6KCAEjg2ueAJfARm8TBGXgDNwzxqn3Z/3ulU6W9A9RctnZ0nbvtEhDzS5IWuR3ASsfjtz96DcWwF48gwIoGwMoz0SKOVc= 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:(13230022)(4636009)(39860400002)(376002)(346002)(396003)(136003)(451199015)(46966006)(40470700004)(36840700001)(36860700001)(82740400003)(6666004)(81166007)(2906002)(356005)(478600001)(2616005)(1076003)(26005)(7696005)(186003)(5660300002)(40480700001)(316002)(8936002)(83380400001)(40460700003)(82310400005)(36756003)(86362001)(426003)(47076005)(41300700001)(110136005)(8676002)(336012)(70586007)(54906003)(70206006)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:02:12.1636 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93f59832-5fb2-4155-a7bc-08daf3b28715 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: DM6NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8572 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add support for runtime pm ops for soundwire dma driver. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/ps-sdw-dma.c | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/sound/soc/amd/ps/ps-sdw-dma.c b/sound/soc/amd/ps/ps-sdw-dma.c index e94f76053c66..960c0bc5e848 100644 --- a/sound/soc/amd/ps/ps-sdw-dma.c +++ b/sound/soc/amd/ps/ps-sdw-dma.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "acp63.h" @@ -56,6 +57,30 @@ static const struct snd_pcm_hardware acp63_sdw_hardware_capture = { .periods_max = SDW_CAPTURE_MAX_NUM_PERIODS, }; +static void acp63_enable_disable_sdw_dma_interrupts(void __iomem *acp_base, bool enable) +{ + u32 ext_intr_cntl, ext_intr_cntl1, irq_mask, irq_mask1; + + irq_mask = ACP_SDW_DMA_IRQ_MASK; + irq_mask1 = ACP_P1_SDW_DMA_IRQ_MASK; + + if (enable) { + ext_intr_cntl = acp63_readl(acp_base + ACP_EXTERNAL_INTR_CNTL); + ext_intr_cntl |= irq_mask; + acp63_writel(ext_intr_cntl, acp_base + ACP_EXTERNAL_INTR_CNTL); + ext_intr_cntl1 = acp63_readl(acp_base + ACP_EXTERNAL_INTR_CNTL1); + ext_intr_cntl1 |= irq_mask1; + acp63_writel(ext_intr_cntl1, acp_base + ACP_EXTERNAL_INTR_CNTL1); + } else { + ext_intr_cntl = acp63_readl(acp_base + ACP_EXTERNAL_INTR_CNTL); + ext_intr_cntl &= ~irq_mask; + acp63_writel(ext_intr_cntl, acp_base + ACP_EXTERNAL_INTR_CNTL); + ext_intr_cntl1 = acp63_readl(acp_base + ACP_EXTERNAL_INTR_CNTL1); + ext_intr_cntl1 &= ~irq_mask1; + acp63_writel(ext_intr_cntl1, acp_base + ACP_EXTERNAL_INTR_CNTL1); + } +} + static void acp63_config_dma(struct sdw_stream_instance *sdw_ins, u32 stream_id) { u16 page_idx; @@ -585,13 +610,54 @@ static int acp63_sdw_platform_probe(struct platform_device *pdev) return -ENODEV; } + pm_runtime_set_autosuspend_delay(&pdev->dev, ACP_SUSPEND_DELAY_MS); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_enable(&pdev->dev); + pm_runtime_allow(&pdev->dev); + return 0; +} + +static int acp63_sdw_platform_remove(struct platform_device *pdev) +{ + pm_runtime_disable(&pdev->dev); + return 0; +} + +static int __maybe_unused acp63_sdw_pcm_runtime_suspend(struct device *dev) +{ + struct sdw_dma_dev_data *sdw_dma_data; + + sdw_dma_data = dev_get_drvdata(dev); + mutex_lock(sdw_dma_data->acp_lock); + acp63_enable_disable_sdw_dma_interrupts(sdw_dma_data->acp_base, false); + mutex_unlock(sdw_dma_data->acp_lock); + + return 0; +} + +static int __maybe_unused acp63_sdw_pcm_runtime_resume(struct device *dev) +{ + struct sdw_dma_dev_data *sdw_dma_data; + + sdw_dma_data = dev_get_drvdata(dev); + mutex_lock(sdw_dma_data->acp_lock); + acp63_enable_disable_sdw_dma_interrupts(sdw_dma_data->acp_base, true); + mutex_unlock(sdw_dma_data->acp_lock); + return 0; } +static const struct dev_pm_ops acp63_pm_ops = { + SET_RUNTIME_PM_OPS(acp63_sdw_pcm_runtime_suspend, + acp63_sdw_pcm_runtime_resume, NULL) +}; + static struct platform_driver acp63_sdw_dma_driver = { .probe = acp63_sdw_platform_probe, + .remove = acp63_sdw_platform_remove, .driver = { .name = "amd_ps_sdw_dma", + .pm = &acp63_pm_ops, }, }; From patchwork Wed Jan 11 09:02:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096297 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 32BDEC5479D for ; Wed, 11 Jan 2023 09:04:43 +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 7236A77E6; Wed, 11 Jan 2023 10:03:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7236A77E6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427881; bh=8w4ztNlTOm9iNoz8YlsE6LEI50l9TpIHK+eeynysncU=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=oQ+71eAROpP2ulq820Ci1xONBK6PT+AdNTP+4/4/+n6gWJGabjge1euons9gvo6kr 9Fa59sx2Z13N3OSP8LHiBifxNhn/cT6O+kTXX7Gddjes8lr2YLEs82rtdLBnULsZeM 2DjhQsiCNokFCcPhgLAkUbQYR6+JFieNJc0Cx7CM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8B722F80548; Wed, 11 Jan 2023 10:02:50 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 91E94F80551; Wed, 11 Jan 2023 10:02:49 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2080.outbound.protection.outlook.com [40.107.237.80]) (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 4F7CBF8053D for ; Wed, 11 Jan 2023 10:02:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4F7CBF8053D 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=0TzkD9i2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dmNqueF33xNmOm9MCRDiBSEpNNB+yTLzhfEzIs1ycnPNYsOIrj3Z4Ot0hRubVLnQRCqx4cCA8KW51nDkD2B4QtR1wcGLVofaB/FIPjdEqqhuAOdikj2gNMKWcGt4EbPXJBxiA34DuFotPKaqYXr0C5vWaWnhP/QQJvvJLz6nSDfU6UTuGvXqmzmCOL5QKy6pmysxwOv0AJJozD7obzeInp1zKoBgLlPIOCGOeBvLwvaiuQhPPQcsVYHGRIupAQ2XHk72Ru624lEw1AZWADBvYMJ0arEXdQLjjgKoHLDGJ5gjFiDFN03omGngb3HZMHnR0h3T94uj+JztCLaRMUtW0A== 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=7DV+zBcA69Ehh6cpMX+gJ7UMRUr9pdZBA7y2CTUgEiw=; b=Ej13p0y0vBEhPBcI9R5WkvkykltOIWD2v5SlzPDbfHNKHkZW6L8nJe8Jr081MLinLlhcU/O/kUNWoche+xQMuHAH/1U3roqim8XOEwwwKZLhyQfIRm6bEdwQQclgwB7Pk/gQMCQ4/uc15VsqmWJ/I+ik9fTpVXkQlf20brq87IqcsUwY5bBbUrG8zvPNSdT6B96lOlaYvpm+UOTB3PEjvrs6hEgLHhsaG1/QxafwQhraVBOeX3o2ddzkxFSOwKYPSHkdh3SVpKAmtAbcWb1u0M2sPd1ZKpbVPEIY59fQZX8MRwH1tmosyElOAACdFUjMgScciSfImJDnyd7x0Jnw0g== 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 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=7DV+zBcA69Ehh6cpMX+gJ7UMRUr9pdZBA7y2CTUgEiw=; b=0TzkD9i2HZRvwqkIrurns04aqcrpiomThg1ll+ru5OMS/mXzwoBchJZ8Zn+QWAqKnjaR5a0cRmG7Dhod+DmtbKIW/8WLITwbhMD1zUUhqDI5rDOY5VUAoIryF+3Za+SLQkahQK64qQj1R8WpaTy+fiZ/d/LmLIsdp/GGnXo/pvA= Received: from DM6PR06CA0063.namprd06.prod.outlook.com (2603:10b6:5:54::40) by CH0PR12MB5218.namprd12.prod.outlook.com (2603:10b6:610:d1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:02:43 +0000 Received: from DM6NAM11FT104.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::55) by DM6PR06CA0063.outlook.office365.com (2603:10b6:5:54::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:02:43 +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 DM6NAM11FT104.mail.protection.outlook.com (10.13.173.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.12 via Frontend Transport; Wed, 11 Jan 2023 09:02:43 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) 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.2375.34; Wed, 11 Jan 2023 03:02:40 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 11 Jan 2023 01:02:08 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:02:05 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 14/19] soundwire: amd: add runtime pm ops for AMD master driver Date: Wed, 11 Jan 2023 14:32:17 +0530 Message-ID: <20230111090222.2016499-15-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT104:EE_|CH0PR12MB5218:EE_ X-MS-Office365-Filtering-Correlation-Id: 7aeef880-60b6-4d70-47dc-08daf3b299b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CJywnbzqIcqkEKQguTEEbbwrWj0cBNnFkXmjKrMr2xCXXVJgaQZRk0mtM85F5UCZoBRwQamPWUAOc02csIi5rM/uph/kuuhHfU1VtUQoHmHZ/7G+hI6z0gYMZjUxAhX0kp6J1dbtU7Eub5tm1aOJDv+49ILPGtM3TQXjAH8BMuYjMjOoZMZtSMSrD2iMl1++HmufVWTxMwIP3cVj/ZQUoJvqOBX48tJgVtJVMig35gRRHphd7KJRMv/VnNKsrt9YtVC6EhT5Ilsh4qaNoM/fvAiDK2gjF6SlqqQpb3yG+7oClOa9YKzCKyyZFXu5LUiRJxYNMUyQnDjfqnl0DQNvs/+rSD1tPsi+sCN+5R078r/+CYGg84TjfL+kM6CGnr7qgHitxuJ48niHU/jkmhvk09FWJj3uMGoioibNLnvYs/7AOnFbgXS4NtiNwBIB3Jphug814lkT2JBa895cSy5FGFfJQabeZmwBUx1HTsaF9Eu/qjeqmFdpvtj7e6mkRMbgJ525/thZbuz1LKDtjqMdk1ivquE3+84eZQ3yscyLEnRv7dxZy6XC3yTf1CELoquMp7VLYgyd2mcAyUhh485MuBCQQrJR4NxjNL/dQ848w7fIwq9CGCtc1jPF907fD404KaIbMKzfKUSrHG3W0MPjWqd9/CNw0D72i640qGdT9Vzra1clHkifUE+ybHBKoeDs5JrCZNlnZOEKxOQBjoDbAImHeC704w3nfTs1/UcOD4k= 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:(13230022)(4636009)(376002)(39860400002)(136003)(346002)(396003)(451199015)(36840700001)(46966006)(40470700004)(2906002)(82310400005)(47076005)(83380400001)(336012)(36860700001)(426003)(81166007)(7696005)(2616005)(1076003)(40480700001)(5660300002)(8936002)(6666004)(36756003)(186003)(26005)(478600001)(70586007)(70206006)(8676002)(54906003)(110136005)(41300700001)(86362001)(356005)(316002)(4326008)(40460700003)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:02:43.3825 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7aeef880-60b6-4d70-47dc-08daf3b299b1 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: DM6NAM11FT104.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5218 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, Basavaraj.Hiregoudar@amd.com, Pierre-Louis Bossart , open list , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Sanyog Kale , Bard Liao Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add support for runtime pm ops for AMD master driver. Signed-off-by: Vijendar Mukunda Signed-off-by: Mastan Katragadda --- drivers/soundwire/amd_master.c | 205 ++++++++++++++++++++++++++++++ drivers/soundwire/amd_master.h | 3 + include/linux/soundwire/sdw_amd.h | 1 + 3 files changed, 209 insertions(+) diff --git a/drivers/soundwire/amd_master.c b/drivers/soundwire/amd_master.c index c7063b8bdd7b..d2d7f07de202 100644 --- a/drivers/soundwire/amd_master.c +++ b/drivers/soundwire/amd_master.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -290,6 +291,17 @@ static int amd_disable_sdw_interrupts(struct amd_sdwc_ctrl *ctrl) return 0; } +static int amd_deinit_sdw_controller(struct amd_sdwc_ctrl *ctrl) +{ + int ret; + + ret = amd_disable_sdw_interrupts(ctrl); + if (ret) + return ret; + ret = amd_disable_sdw_controller(ctrl); + return ret; +} + static int amd_sdwc_set_frameshape(struct amd_sdwc_ctrl *ctrl, u32 rows, u32 cols) { u32 sdw_rows, sdw_cols, frame_size; @@ -1387,6 +1399,12 @@ static int amd_sdwc_probe(struct platform_device *pdev) INIT_WORK(&ctrl->amd_sdw_work, amd_sdwc_update_slave_status_work); INIT_WORK(&ctrl->probe_work, amd_sdwc_probe_work); schedule_work(&ctrl->probe_work); + /* Enable runtime PM */ + pm_runtime_set_autosuspend_delay(dev, AMD_SDW_MASTER_SUSPEND_DELAY_MS); + pm_runtime_use_autosuspend(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); return 0; } @@ -1398,14 +1416,201 @@ static int amd_sdwc_remove(struct platform_device *pdev) amd_disable_sdw_interrupts(ctrl); sdw_bus_master_delete(&ctrl->bus); ret = amd_disable_sdw_controller(ctrl); + pm_runtime_disable(&pdev->dev); return ret; } +static int amd_sdwc_clock_stop(struct amd_sdwc_ctrl *ctrl) +{ + u32 clk_resume_ctrl_reg; + u32 wake_en_reg; + u32 val; + u32 retry_count = 0; + int ret; + + ret = sdw_bus_prep_clk_stop(&ctrl->bus); + if (ret < 0 && ret != -ENODATA) { + dev_err(ctrl->dev, "prepare clock stop failed %d", ret); + return ret; + } + ret = sdw_bus_clk_stop(&ctrl->bus); + if (ret < 0 && ret != -ENODATA) { + dev_err(ctrl->dev, "bus clock stop failed %d", ret); + return ret; + } + switch (ctrl->instance) { + case ACP_SDW0: + clk_resume_ctrl_reg = ACP_SW_CLK_RESUME_CTRL; + wake_en_reg = ACP_SW_WAKE_EN; + break; + case ACP_SDW1: + clk_resume_ctrl_reg = ACP_P1_SW_CLK_RESUME_CTRL; + wake_en_reg = ACP_SW1_WAKE_EN; + break; + default: + return -EINVAL; + } + + do { + val = acp_reg_readl(ctrl->mmio + clk_resume_ctrl_reg); + if (val & AMD_SDW_CLK_STOP_DONE) { + ctrl->clk_stopped = true; + break; + } + } while (retry_count++ < AMD_SDW_CLK_STOP_MAX_RETRY_COUNT); + + if (!ctrl->clk_stopped) { + dev_err(ctrl->dev, "SDW%x clock stop failed\n", ctrl->instance); + return -ETIMEDOUT; + } + + if (ctrl->wake_en_mask) + acp_reg_writel(0x01, ctrl->mmio + wake_en_reg); + + dev_dbg(ctrl->dev, "SDW%x clock stop successful\n", ctrl->instance); + return 0; +} + +static int amd_sdwc_clock_stop_exit(struct amd_sdwc_ctrl *ctrl) +{ + int ret; + u32 clk_resume_ctrl_reg; + u32 val = 0; + u32 retry_count = 0; + + switch (ctrl->instance) { + case ACP_SDW0: + clk_resume_ctrl_reg = ACP_SW_CLK_RESUME_CTRL; + break; + case ACP_SDW1: + clk_resume_ctrl_reg = ACP_P1_SW_CLK_RESUME_CTRL; + break; + default: + return -EINVAL; + } + if (ctrl->clk_stopped) { + val = acp_reg_readl(ctrl->mmio + clk_resume_ctrl_reg); + val |= AMD_SDW_CLK_RESUME_REQ; + acp_reg_writel(val, ctrl->mmio + clk_resume_ctrl_reg); + do { + val = acp_reg_readl(ctrl->mmio + clk_resume_ctrl_reg); + if (val & AMD_SDW_CLK_RESUME_DONE) + break; + usleep_range(10, 100); + } while (retry_count++ < AMD_SDW_CLK_STOP_MAX_RETRY_COUNT); + if (val & AMD_SDW_CLK_RESUME_DONE) { + acp_reg_writel(0, ctrl->mmio + clk_resume_ctrl_reg); + ret = sdw_bus_exit_clk_stop(&ctrl->bus); + if (ret < 0) + dev_err(ctrl->dev, "bus failed to exit clock stop %d\n", ret); + ctrl->clk_stopped = false; + } + } + if (ctrl->clk_stopped) { + dev_err(ctrl->dev, "SDW%x clock stop exit failed\n", ctrl->instance); + return -ETIMEDOUT; + } + + dev_dbg(ctrl->dev, "SDW%x clock stop exit successful\n", ctrl->instance); + + return 0; +} + +static int __maybe_unused amd_suspend_runtime(struct device *dev) +{ + struct amd_sdwc_ctrl *ctrl = dev_get_drvdata(dev); + struct sdw_bus *bus = &ctrl->bus; + int ret; + + if (bus->prop.hw_disabled || !ctrl->startup_done) { + dev_dbg(bus->dev, "SoundWire master %d is disabled or not-started, ignoring\n", + bus->link_id); + return 0; + } + if (ctrl->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { + ret = amd_sdwc_clock_stop(ctrl); + if (ret) + return ret; + } else if (ctrl->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { + ret = amd_sdwc_clock_stop(ctrl); + if (ret) + return ret; + ret = amd_deinit_sdw_controller(ctrl); + if (ret) + return ret; + } + return 0; +} + +static int __maybe_unused amd_resume_runtime(struct device *dev) +{ + struct amd_sdwc_ctrl *ctrl = dev_get_drvdata(dev); + struct sdw_bus *bus = &ctrl->bus; + int ret; + u32 clk_resume_ctrl_reg; + u32 val = 0; + u32 retry_count = 0; + + if (bus->prop.hw_disabled || !ctrl->startup_done) { + dev_dbg(bus->dev, "SoundWire master %d is disabled or not-started, ignoring\n", + bus->link_id); + return 0; + } + + switch (ctrl->instance) { + case ACP_SDW0: + clk_resume_ctrl_reg = ACP_SW_CLK_RESUME_CTRL; + break; + case ACP_SDW1: + clk_resume_ctrl_reg = ACP_P1_SW_CLK_RESUME_CTRL; + break; + default: + return -EINVAL; + } + + if (ctrl->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { + ret = amd_sdwc_clock_stop_exit(ctrl); + if (ret) + return ret; + } else if (ctrl->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { + val = acp_reg_readl(ctrl->mmio + clk_resume_ctrl_reg); + if (val) { + val |= AMD_SDW_CLK_RESUME_REQ; + acp_reg_writel(val, ctrl->mmio + clk_resume_ctrl_reg); + do { + val = acp_reg_readl(ctrl->mmio + clk_resume_ctrl_reg); + if (val & AMD_SDW_CLK_RESUME_DONE) + break; + usleep_range(10, 100); + } while (retry_count++ < AMD_SDW_CLK_STOP_MAX_RETRY_COUNT); + if (val & AMD_SDW_CLK_RESUME_DONE) { + acp_reg_writel(0, ctrl->mmio + clk_resume_ctrl_reg); + ctrl->clk_stopped = false; + } + } + sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET); + amd_init_sdw_controller(ctrl); + amd_enable_sdw_interrupts(ctrl); + ret = amd_enable_sdw_controller(ctrl); + if (ret) + return ret; + ret = amd_sdwc_set_frameshape(ctrl, 50, 10); + if (ret) + return ret; + } + return 0; +} + +static const struct dev_pm_ops amd_pm = { + SET_RUNTIME_PM_OPS(amd_suspend_runtime, amd_resume_runtime, NULL) +}; + static struct platform_driver amd_sdwc_driver = { .probe = &amd_sdwc_probe, .remove = &amd_sdwc_remove, .driver = { .name = "amd_sdw_controller", + .pm = &amd_pm, } }; module_platform_driver(amd_sdwc_driver); diff --git a/drivers/soundwire/amd_master.h b/drivers/soundwire/amd_master.h index b43a5d6496cb..cc254255512b 100644 --- a/drivers/soundwire/amd_master.h +++ b/drivers/soundwire/amd_master.h @@ -237,6 +237,9 @@ #define AMD_SDW0_PAD_KEEPER_DISABLE_MASK 0x1E #define AMD_SDW1_PAD_KEEPER_DISABLE_MASK 0xF #define AMD_SDW_PREQ_INTR_STAT BIT(19) +#define AMD_SDW_CLK_STOP_DONE 1 +#define AMD_SDW_CLK_RESUME_REQ 2 +#define AMD_SDW_CLK_RESUME_DONE 3 enum amd_sdw_channel { /* SDW0 */ diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h index 2db03b2f0c3b..f362f195b887 100644 --- a/include/linux/soundwire/sdw_amd.h +++ b/include/linux/soundwire/sdw_amd.h @@ -38,6 +38,7 @@ struct amd_sdwc_ctrl { u32 quirks; u32 wake_en_mask; int num_ports; + bool clk_stopped; bool startup_done; u32 power_mode_mask; }; From patchwork Wed Jan 11 09:02:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096298 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 A9250C54EBE for ; Wed, 11 Jan 2023 09:04:58 +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 B3381786A; Wed, 11 Jan 2023 10:04:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B3381786A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427896; bh=BfOZ/L0fVnRujJCNMrJWvVAQTTilBmyQ1runw+C2deE=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=JJ/KXxSPloIXpZlhh1KOnbGJGme/THD/agR714fQQTr3qQDEy3rfCekTzf1pTdTLa c78iJx60bDrp5nU5X5ERFch28ATu8h/bop2PpEjeVE9x6U4ezaOq0ubkw3UL1g5BuU yK67WdUIPX+QfcX3l7tLTf75TvBGQq/HCJFb8qJk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 50F10F80553; Wed, 11 Jan 2023 10:03:08 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A0916F80553; Wed, 11 Jan 2023 10:03:06 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2EDE7F8051B for ; Wed, 11 Jan 2023 10:03:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2EDE7F8051B 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=U9cDBh+l ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H5/cZcNxsCV1Npk+Fp0eUwuBXcwAk7UFtACw15ScmaTqFko1T4a2OFUZ0qExK5/XJ5MTU4m+5uV6fRzb6lEIrcdX4/HzaWn7EYAEpdYaMioGyR6D9V2NPq5kzzyNmL5uXaonY7oCHXxBIWFc1jE/sylnpesY2FQU24P3SJmIbDp9z5w2XlBGww77xu5Kc1l8kUKkPyvHjC5h9GHfnEDr6asV7840nlJWnDD5AxWVXLDJf3Ut+4GP1W92RZqjNtwXS2oDjCi7Z8S3r+KTC5A7GaKF2SlsYrIusdGelm4G3NYqSHsSjxLoYY175hdyz9gFOzOLrsJzl5K3zDIcCyQ+jA== 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=dKbs/gWVIUwuuZ9ieSx4rMt6gTr0u2uz5VezFzMnLeg=; b=Zbd8cqOD+6AvY2zfPS7Eg1ISl+HTVUdJpepDUkBs2mzDyTXfjQuzd+00Xt+PQVftWSeDBHf5Uq7x9vJvd5+ue4EeMhMB409B0Y7wropUQewUr55YTXmAxJSVW3LkQnxChn+sVSFSBy2WBDM9V4WHYzWcf983jQMVczF6K0AEdWRMIcUNHG4mUQ0W+eB2qP+YCDI2TXCv6pUGk4txSbIy6cgU0ZvedTsNbL4qgsBMLBYUs7Y82rVd2j5HUGm9ht7t8AHBqoW6xlqbtKW8Ulu3V79Cmxj+RxxqJpHeOGALEmyXVuC4J7M5ovCHFnX6V6aC+B3Hqvmzc4GH0uHRhe+uVw== 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 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=dKbs/gWVIUwuuZ9ieSx4rMt6gTr0u2uz5VezFzMnLeg=; b=U9cDBh+lZ64mg2WsRjLzECpa6tmwGXZtq0CamM/1z52ah/sugyfRteO9Nm72LblkeOCMKU/DJsTdkz7VsxgM9GyQ2RbsVXqOAKPc2TQNfGpKNuUeE1wtL0kagUvcQRvhf9rjHKF0Pc4MLdbabXs1WKR2/bwLKxYudC22DqqKlzs= Received: from DM6PR05CA0066.namprd05.prod.outlook.com (2603:10b6:5:335::35) by PH7PR12MB7428.namprd12.prod.outlook.com (2603:10b6:510:203::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:02:57 +0000 Received: from DM6NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:5:335:cafe::90) by DM6PR05CA0066.outlook.office365.com (2603:10b6:5:335::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:02:57 +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 DM6NAM11FT019.mail.protection.outlook.com (10.13.172.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:02:57 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 11 Jan 2023 03:02:47 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 01:02:13 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:02:09 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 15/19] soundwire: amd: add startup and shutdown dai ops Date: Wed, 11 Jan 2023 14:32:18 +0530 Message-ID: <20230111090222.2016499-16-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT019:EE_|PH7PR12MB7428:EE_ X-MS-Office365-Filtering-Correlation-Id: e6102fc3-808d-456d-edfa-08daf3b2a1e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xdzpWCLLywxzPEA4gIrFOhRc5vpaheQOuxSAVA4cmQGxmNqeiixZHxJOHpd4MNmlTe5WYWtd5puwL4iqKX2MRnqUdp4kZCpfB6Loacmo70IKvgooOv5WepAjhsIsGLYvVAEr/qcWvRvkFeUYuqDPyBjnpK2fLQrACcohWH9fnIMJaw9F+GoAB5JBMFqC97do03yuXkztqq0SfahxnPEMDVBxFQz1lVmoOwiy948DQk1znGladk8+cdkGrgjVYx9lG2Up33/f/+pgWNA0jCz5o81YIFIRs9C/I5LCgHllKuqhxqcrV9KuLLD6Qp2xk32SpH4EEWRX4bDKqwDHONrRFjLLNuQwL0w2g37w634C2qzbVgk3Ffq/krv1S1u/wVYrifkMHpZkpTEiIZePgx6otgi1+LtP+Jcci2wsEj7VhWMlSP1D1L6q6lQRM7jrhUgqYPm9Zo9rUFaT5UvDLGHaSh03dQ0fHWwhaIL47JBiRqpxhGVdkmcNu+GFn0QvTJAIqSV2KYT/OXdvF4qOW56YNl3cDc3khnkssvdI/dDdoY0vTPm/fqvhgPUNMNp7VsyWrLov0rN/ltzGLX4R/m+CVg1JzKeQHiKrl63t/TsjPCQrgtFGhtnl9ssfwkJ9f7jGlASb3YmcbWlfNkb00EoF8tqUJyWi06IqI9OncsfddGIL3LCwg/lev5h6vbhvYNoxtVHJDsBIVojuLP73Yn+U4z/n2LfIHWuXGvtHCNTdCfk= 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:(13230022)(4636009)(376002)(136003)(39860400002)(396003)(346002)(451199015)(46966006)(40470700004)(36840700001)(2906002)(7696005)(26005)(478600001)(6666004)(186003)(8676002)(83380400001)(110136005)(2616005)(1076003)(70586007)(36756003)(316002)(54906003)(336012)(40460700003)(70206006)(426003)(4326008)(41300700001)(47076005)(40480700001)(5660300002)(82740400003)(36860700001)(82310400005)(86362001)(81166007)(8936002)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:02:57.0984 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6102fc3-808d-456d-edfa-08daf3b2a1e2 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: DM6NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7428 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, Basavaraj.Hiregoudar@amd.com, Pierre-Louis Bossart , open list , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Sanyog Kale , Bard Liao Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add start up and shutdown dai ops for AMD Master driver. Signed-off-by: Vijendar Mukunda --- drivers/soundwire/amd_master.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/soundwire/amd_master.c b/drivers/soundwire/amd_master.c index d2d7f07de202..290c59ab7760 100644 --- a/drivers/soundwire/amd_master.c +++ b/drivers/soundwire/amd_master.c @@ -1117,6 +1117,15 @@ static int amd_set_sdw_stream(struct snd_soc_dai *dai, void *stream, int directi return 0; } +static void amd_sdwc_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct amd_sdwc_ctrl *ctrl = snd_soc_dai_get_drvdata(dai); + + pm_runtime_mark_last_busy(ctrl->dev); + pm_runtime_put_autosuspend(ctrl->dev); +} + static int amd_pcm_set_sdw_stream(struct snd_soc_dai *dai, void *stream, int direction) { return amd_set_sdw_stream(dai, stream, direction); @@ -1137,9 +1146,27 @@ static void *amd_get_sdw_stream(struct snd_soc_dai *dai, int direction) return dma->stream; } +static int amd_sdwc_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) +{ + struct amd_sdwc_ctrl *ctrl = snd_soc_dai_get_drvdata(dai); + int ret; + + ret = pm_runtime_get_sync(ctrl->dev); + if (ret < 0 && ret != -EACCES) { + dev_err_ratelimited(ctrl->dev, + "pm_runtime_get_sync failed in %s, ret %d\n", + __func__, ret); + pm_runtime_put_noidle(ctrl->dev); + return ret; + } + return 0; +} + static const struct snd_soc_dai_ops amd_sdwc_dai_ops = { .hw_params = amd_sdwc_hw_params, .hw_free = amd_sdwc_hw_free, + .startup = amd_sdwc_startup, + .shutdown = amd_sdwc_shutdown, .set_stream = amd_pcm_set_sdw_stream, .get_stream = amd_get_sdw_stream, }; From patchwork Wed Jan 11 09:02:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096299 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 CDD60C46467 for ; Wed, 11 Jan 2023 09:05:25 +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 E035677DE; Wed, 11 Jan 2023 10:04:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E035677DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427922; bh=nNA20e4GaKDj3aXVZ6T4GIj1aRrd7BFg6Lfjn0So1rk=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=AX7BvbtHhTDCbArFTNfCT1d9tKzkgsne8hze9CIKcoQOor2mdcKh3BCwma9HNcs7a Zrzl+kRsnEZ4t6/EpKHA6+W3uhCOo6bW2kT3vIO0/gwgdWA56YPPAwRWmwGR9DTtYx XqJzlJhhyyUg+rXfM7O68ucS0GqhjSnp9EfJPLII= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 952DEF80425; Wed, 11 Jan 2023 10:03:42 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1486CF80549; Wed, 11 Jan 2023 10:03:41 +0100 (CET) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2057.outbound.protection.outlook.com [40.107.102.57]) (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 2354CF8019B for ; Wed, 11 Jan 2023 10:03:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2354CF8019B 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=tj+LbGRD ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BcYMY2qY/4h/9zc3MRg4TeDHN6dkRO5MsaOq3JIvC/QKfss6GRrwcrlX9iq0E70waRVR7qR8R3JD7xPMGglr/hA/TuViaI9ZYsxbk/rKmC448YF3osNoyA4ac+tokbkms9Cjype2Wcul7KaTVva5wj6gC9U4UBe7IU7OUAge2VbpT9RYX+/PzpC12qNWkYkWnW4T/0+llCMXt5/Uz01DlL2ErXe9u/lcJFcjTKM1HeKIPbO5Csxxi1JVckNIKhjFfLrUEXHu/9pz2krcSc0L4EBP7gKpjpL9ADuILYHvWWNs5Qn+Iuyr2pddUzKOzrOkU7FQeOoIJsyXJ11YwesHzg== 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=DWCFEEfEBxlW74hWdno7V5BxGl7W7b3yW79oi0bnu8k=; b=YCco6c/f3cJeo9CAtFBYAZ0OJ4xH+GcEhI0RY9VYcrHNqJkMYhHziiwDFNeKAsDVLeFclg0TNYmrpIOTXpSIvRP/H0iXOSrucy7YUT4NzcLikZIrRP2ufU9dDG0lisb3o3BmbPYGJOuZTwa6h6DNWfxZS0W1QhJh+0sBbcLq4QLkMh7DVCVnjLBDEYZYLlTQfvVCoQu83CJGm1/ydXHYgsuZXN7rxP3A+e6TX2q0+bY1nuu2ylV9HPFB2XpQ5YBTzn7FKztRo3YxKDjmsO5fNhcSTTf7S58LKs2iCvI8+Ak68OZ710OClbRbsyo5C5XljG7g6/Ny2cXWaGKaZXaztA== 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 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=DWCFEEfEBxlW74hWdno7V5BxGl7W7b3yW79oi0bnu8k=; b=tj+LbGRDjRg85Ll6FZIvraE238PCtxwuvBo1a7PxAGv8sHHyWCaDzpNdfUgKfF+gJIx60EmEKed95Eq/JzBi7cQN4zyd6QrzRQPleM40wGGeIZL1CDOih4k9K0qIR/OUf/2DiXMWFmmNm5VXHjDg9/ObIhJ3zhmm38HsCIHtook= Received: from BN9PR03CA0586.namprd03.prod.outlook.com (2603:10b6:408:10d::21) by DM4PR12MB6373.namprd12.prod.outlook.com (2603:10b6:8:a4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:03:34 +0000 Received: from BN8NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::35) by BN9PR03CA0586.outlook.office365.com (2603:10b6:408:10d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:03:34 +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 BN8NAM11FT053.mail.protection.outlook.com (10.13.177.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:03:33 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 03:03:15 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:02:47 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 16/19] soundwire: amd: handle wake enable interrupt Date: Wed, 11 Jan 2023 14:32:19 +0530 Message-ID: <20230111090222.2016499-17-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT053:EE_|DM4PR12MB6373:EE_ X-MS-Office365-Filtering-Correlation-Id: 093e2960-255e-42f7-de5e-08daf3b2b7db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hpUfmBS7Y1V836REon8EcIY1ucfx2HqKLLe8OYZrxba/G+qfV2fnR0dvkCt5iRtfVuY13A0ZGzYHD6cI1uwm1w2klTfMokcFAdE1RFjSg7OpeTpnu7M+ezfB5B8qTVRYcKx+OZUsYk32mMTv93s01K0Xnq66Z6SCgQvTRKCupXQm0WHFh+dl/Oi9RlkJ+niuJtwb9UWIbzYOkhlmqWBqFFusYQ8tyCUXtazYfz1i5kmKC6njxmTczX38k2zjcip0E6MqIB/X/WtIsTDXUoPOpVuB0UumtgvzVs+xa665XCjhWtt53rhdMl87JIIXmfxQ0xco+3L7DQQm65iGeMw3CCqqyj4yCnaJUaVubIW4KnvrnVce7pTVDfYlUIoxi7Dn2E3SfX6xQS4g4akPZoiutKfnwVxTN422FXbJal3hVjncA5nkcGFW5V1ciwBSNLCR4Blon6edTTJQzq4fDcmF5B3YMoK3PNtGVbpEBwelnlbWkVVR2BcNu2/KhrkN/Ad0ZDouAT3C9YZE+AX9XnYOTefbfn/Ip9YdLia+eJoRCZePMuIhz0qXLMcuh9xSY1qGKH1RSVeVLvm32yjo9lxzqx1eWMjfhBCmffmC8xt3ogsNPW8ilw7I8Eno55gZwSpa4I0yY6AgXhBlJ+pyrBIIDU4+LnicSh7rqWTyyspHNsE57Qfj/7HvmGIeoth3zR4JqlND6LBQoAnmGfHLOCDIUSqSoZpqsrRIVAcGuCVAbME= 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:(13230022)(4636009)(376002)(136003)(39860400002)(396003)(346002)(451199015)(46966006)(40470700004)(36840700001)(2906002)(7696005)(26005)(478600001)(6666004)(186003)(8676002)(83380400001)(110136005)(2616005)(1076003)(70586007)(36756003)(316002)(54906003)(336012)(40460700003)(70206006)(426003)(4326008)(41300700001)(47076005)(40480700001)(5660300002)(82740400003)(36860700001)(82310400005)(86362001)(81166007)(8936002)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:03:33.9620 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 093e2960-255e-42f7-de5e-08daf3b2b7db 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: BN8NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6373 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, Basavaraj.Hiregoudar@amd.com, Pierre-Louis Bossart , open list , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Sanyog Kale , Bard Liao Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add wake enable interrupt support for both the soundwire controller instances. Signed-off-by: Vijendar Mukunda Signed-off-by: Mastan Katragadda --- drivers/soundwire/amd_master.c | 9 +++++++++ drivers/soundwire/amd_master.h | 1 + include/linux/soundwire/sdw_amd.h | 1 + 3 files changed, 11 insertions(+) diff --git a/drivers/soundwire/amd_master.c b/drivers/soundwire/amd_master.c index 290c59ab7760..2fd77a673c22 100644 --- a/drivers/soundwire/amd_master.c +++ b/drivers/soundwire/amd_master.c @@ -1219,6 +1219,13 @@ static void amd_sdwc_update_slave_status_work(struct work_struct *work) u32 sw_status_change_mask_0to7_reg; u32 sw_status_change_mask_8to11_reg; + if (ctrl->wake_event) { + pm_runtime_resume(ctrl->dev); + acp_reg_writel(0x00, ctrl->mmio + ACP_SW_WAKE_EN); + ctrl->wake_event = false; + return; + } + switch (ctrl->instance) { case ACP_SDW0: sw_status_change_mask_0to7_reg = SW_STATE_CHANGE_STATUS_MASK_0TO7; @@ -1258,6 +1265,8 @@ static void amd_sdwc_update_slave_status(u32 status_change_0to7, u32 status_chan if (status_change_0to7 == AMD_SDW_SLAVE_0_ATTACHED) memset(ctrl->status, 0, sizeof(ctrl->status)); + if (status_change_8to11 & AMD_SDW_WAKE_STAT_MASK) + ctrl->wake_event = true; slave_stat = status_change_0to7; slave_stat |= FIELD_GET(AMD_SDW_MCP_SLAVE_STATUS_8TO_11, status_change_8to11) << 32; dev_dbg(ctrl->dev, "%s: status_change_0to7:0x%x status_change_8to11:0x%x\n", diff --git a/drivers/soundwire/amd_master.h b/drivers/soundwire/amd_master.h index cc254255512b..e32884e3a45b 100644 --- a/drivers/soundwire/amd_master.h +++ b/drivers/soundwire/amd_master.h @@ -240,6 +240,7 @@ #define AMD_SDW_CLK_STOP_DONE 1 #define AMD_SDW_CLK_RESUME_REQ 2 #define AMD_SDW_CLK_RESUME_DONE 3 +#define AMD_SDW_WAKE_STAT_MASK BIT(16) enum amd_sdw_channel { /* SDW0 */ diff --git a/include/linux/soundwire/sdw_amd.h b/include/linux/soundwire/sdw_amd.h index f362f195b887..e3e539b868be 100644 --- a/include/linux/soundwire/sdw_amd.h +++ b/include/linux/soundwire/sdw_amd.h @@ -40,6 +40,7 @@ struct amd_sdwc_ctrl { int num_ports; bool clk_stopped; bool startup_done; + bool wake_event; u32 power_mode_mask; }; From patchwork Wed Jan 11 09:02:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096300 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 5FCFFC46467 for ; Wed, 11 Jan 2023 09:05:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 949C486ED; Wed, 11 Jan 2023 10:04:44 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 949C486ED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427934; bh=BECVsGPRJOfFbN1TGMuSqAr6GyJREBfiZ+zUW9EKcdk=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=e0XVWmG9b0hHsySigGi2jMtmP1Wuzn0jwbAzvhq8/jh24l4j7ikY4bFlja9KwLB+1 TY9sEeKkkE8VxapWgwIDCn4rF0eJFp6hHQqaoDxpd4cI01UmJ5Rrrg/+UF/HsVtFhU Xiz4bQdaNjqUQDrja/O+eeaMtVpi+hkNF8XBG06k= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 73D94F80558; Wed, 11 Jan 2023 10:03:52 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B42D9F80571; Wed, 11 Jan 2023 10:03:50 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2077.outbound.protection.outlook.com [40.107.96.77]) (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 319EBF80571 for ; Wed, 11 Jan 2023 10:03:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 319EBF80571 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=BzVW0xLv ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fo/dk9+DvfmvnG6IO/mLF7xzteosFzP3ne9BRJqF7F+UKdcug074CpekDA0RwxEhYz7JITHZUU9IO8R8xzuEVLMblM62q2mAT+MpHJHQj6QixRlFV9PQPu0OLZDyAK/xYIvdL1+eMdoo+HQ0jQcWIXBDLSqEBt9uHqBwm956KkafgPCMjtYpzRUWTUhL1OW4Z25gquSCsnvg+FLqWYnrO7Dmr63tQ15FV/ZXBN47kQNCH75dFCvaG45hbs0AkQfjiWmEiNsDYxzDs9KS1d34s3ZPEp4DDNR1qD/ON3ZkMhsSycHbK2p6rVZPTyAj5vXtJgCnqJgXZkQ3mkF3SuHJCQ== 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=SyqHaXctajZhEaCfsEif1gaJRUiHYT109ULn6xwZoWk=; b=Su25nZ8gwQa4yCtNEO9FKfQiCqhbhzKV9St20VsVhu7UvZ1GK/le03Zq7VpsWPBUG/dCx/rYXYBXm2xsA8N0R/He1gEfs2JBMVr38Uwa7ixspF9rS2Wspi8wB6uWeEpYDP+D+EvKECZFm4SNU+jUUa7JWuInD8TprPrAFB88swPcvnfzgcWBb1ba+s+qP/8RvYfakepuBx4pyj2HcWVaf0fZFKnAgPhuhhvQ0q27FGmhPZXC2dF2nGUwNNpsg8kYQ4jnB0TToAFInnoiOrg7Y1yFw80kTRxC2WYUuzpYFm2JNd10R+QTjwJv27MlpxLRGbaYaCKC8iE/j2aOuKwumQ== 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 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=SyqHaXctajZhEaCfsEif1gaJRUiHYT109ULn6xwZoWk=; b=BzVW0xLvycRGdJ+VIQzgHyqY2MIyM7e3t2mE+Rv8OBbB41fdKoffFxvQf6rP19/ZjgNYFrnHAxnW42FPKd8P0NSfnwtP8v1Nvgi6jXoVs3Vu5an5T8MLtc1LZksffE5ORXNNGQH62+A8AMGNMtN7sozJCOxl8qsIShHFKFTPeqI= Received: from DS7PR05CA0078.namprd05.prod.outlook.com (2603:10b6:8:57::24) by SN7PR12MB7420.namprd12.prod.outlook.com (2603:10b6:806:2a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:03:44 +0000 Received: from DM6NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:8:57:cafe::83) by DS7PR05CA0078.outlook.office365.com (2603:10b6:8:57::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:03:44 +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 DM6NAM11FT034.mail.protection.outlook.com (10.13.173.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 09:03:43 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 11 Jan 2023 03:03:37 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 01:03:21 -0800 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:03:18 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 17/19] soundwire: amd: add pm_prepare callback and pm ops support Date: Wed, 11 Jan 2023 14:32:20 +0530 Message-ID: <20230111090222.2016499-18-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT034:EE_|SN7PR12MB7420:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ee6e24e-ba8e-43d9-edd9-08daf3b2bda6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y2gNylRxRWmo43D/HcN8S1IRRlrjwoy4IWQ+94PGvGwGsTCs7c1kg0LT3Z2yDfUQIHCSThadGDkNMDEmXbCvvvzbQFJtkq0zQ33phdiqepjTSDKjSziH5yhgq0nD+009tlweEadI+ZF5gOnf6C5pdFUOuaahXeBpQ+B1ywK00X7gkEOoEO0iPje3Idak4cg6dDnpkF816gareC6QO7X5umq+j6HwLCHcBEXIz8alaubIwdNAm2sPSYRUaCg+xkQDqWxzbT0KUckllWX6lB18/Z7tOrrxncVGB70ABiI2wfyawhFB10MYDi/svbed8Z061njxJQNKb9vlU/91NMnSrG7kAgq2FCy4wukTJ/1SvFEeKN2/XQYtraxtry2D/EM6WQUsn25Rx/AS1hYZky3lJ6YPOwIfbHnTGhe97AA/RIup5YfcXVK804Z4s84lKiG4DmB5wPNY8C2RzxUmYUpF7exSQUP7PQcQYGhk54YxzqFTib8oVl5bawCTS+5N32HXbf2DupebOFTr/+U9xnEfqGCmkJiaM6wqiVzVQgXbOtj1T7U/OjB7vrPDimmTgkd9PSLd1JnRl1y675BF3VofXOGGRbMeqJPg3L+pUOQOcHN6SBGpOKI2+Jo3DGv7bbOQmOIqd/aYqmUaLhf+cmPwiHJnb9v4asaBVG33FT+clDbecezGI36AFzkiCvowAliNKFraXZYdhX/YX27Vwhsz8Qh3C0tOYnEiOVlUzPkgKs4= 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:(13230022)(4636009)(396003)(376002)(136003)(39860400002)(346002)(451199015)(40470700004)(46966006)(36840700001)(36756003)(86362001)(8936002)(5660300002)(40460700003)(70586007)(47076005)(426003)(336012)(7696005)(83380400001)(26005)(186003)(478600001)(6666004)(2616005)(1076003)(356005)(8676002)(4326008)(70206006)(41300700001)(316002)(82740400003)(82310400005)(36860700001)(40480700001)(81166007)(110136005)(2906002)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:03:43.7127 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ee6e24e-ba8e-43d9-edd9-08daf3b2bda6 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: DM6NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7420 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, Basavaraj.Hiregoudar@amd.com, Pierre-Louis Bossart , open list , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Sanyog Kale , Bard Liao Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add pm_prepare callback and System level pm ops support for AMD master driver. Signed-off-by: Vijendar Mukunda Signed-off-by: Mastan Katragadda --- drivers/soundwire/amd_master.c | 76 ++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/drivers/soundwire/amd_master.c b/drivers/soundwire/amd_master.c index 2fd77a673c22..f4478cc17aac 100644 --- a/drivers/soundwire/amd_master.c +++ b/drivers/soundwire/amd_master.c @@ -1552,6 +1552,80 @@ static int amd_sdwc_clock_stop_exit(struct amd_sdwc_ctrl *ctrl) return 0; } +static int amd_resume_child_device(struct device *dev, void *data) +{ + int ret; + struct sdw_slave *slave = dev_to_sdw_dev(dev); + + if (!slave->probed) { + dev_dbg(dev, "skipping device, no probed driver\n"); + return 0; + } + if (!slave->dev_num_sticky) { + dev_dbg(dev, "skipping device, never detected on bus\n"); + return 0; + } + + if (!pm_runtime_suspended(dev)) + return 0; + ret = pm_request_resume(dev); + if (ret < 0) + dev_err(dev, "%s: pm_request_resume failed: %d\n", __func__, ret); + + return ret; +} + +static int __maybe_unused amd_pm_prepare(struct device *dev) +{ + struct amd_sdwc_ctrl *ctrl = dev_get_drvdata(dev); + struct sdw_bus *bus = &ctrl->bus; + int ret; + + if (bus->prop.hw_disabled || !ctrl->startup_done) { + dev_dbg(bus->dev, "SoundWire master %d is disabled or not-started, ignoring\n", + bus->link_id); + return 0; + } + ret = device_for_each_child(bus->dev, NULL, amd_resume_child_device); + if (ret < 0) + dev_err(dev, "%s: amd_resume_child_device failed: %d\n", __func__, ret); + if (pm_runtime_suspended(dev) && ctrl->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { + ret = pm_request_resume(dev); + if (ret < 0) { + dev_err(bus->dev, "pm_request_resume failed: %d\n", ret); + return 0; + } + } + return 0; +} + +static int __maybe_unused amd_suspend(struct device *dev) +{ + struct amd_sdwc_ctrl *ctrl = dev_get_drvdata(dev); + struct sdw_bus *bus = &ctrl->bus; + int ret; + + if (bus->prop.hw_disabled || !ctrl->startup_done) { + dev_dbg(bus->dev, "SoundWire master %d is disabled or not-started, ignoring\n", + bus->link_id); + return 0; + } + + if (ctrl->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { + ret = amd_sdwc_clock_stop(ctrl); + if (ret) + return ret; + } else if (ctrl->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { + ret = amd_sdwc_clock_stop(ctrl); + if (ret) + return ret; + ret = amd_deinit_sdw_controller(ctrl); + if (ret) + return ret; + } + return 0; +} + static int __maybe_unused amd_suspend_runtime(struct device *dev) { struct amd_sdwc_ctrl *ctrl = dev_get_drvdata(dev); @@ -1638,6 +1712,8 @@ static int __maybe_unused amd_resume_runtime(struct device *dev) } static const struct dev_pm_ops amd_pm = { + .prepare = amd_pm_prepare, + SET_SYSTEM_SLEEP_PM_OPS(amd_suspend, amd_resume_runtime) SET_RUNTIME_PM_OPS(amd_suspend_runtime, amd_resume_runtime, NULL) }; From patchwork Wed Jan 11 09:02:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096301 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 26E3BC6379F for ; Wed, 11 Jan 2023 09:05: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 7A4AF7AFB; Wed, 11 Jan 2023 10:05:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7A4AF7AFB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427951; bh=B9ybWlIR8Eu71ROXVtQD71ETkhlfaKeWKab9X10Xm28=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=PHZP0UqJ26WYA8lZD47MRg+ghfwd753t36Yk3Oz15u/mSUX+vWthd2abbpjEG2qPU cFkM2tlhuwKCsukWrT1U7eoEX4ErAywXUdohtnbIWYYwzH3nHV2KoF2mavue5yM4Ls lpxxTbLA/OU7myXObPn7zA4V22fOGuHo3qhApMvM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4D123F8057C; Wed, 11 Jan 2023 10:04:01 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 427E5F8057C; Wed, 11 Jan 2023 10:04:00 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) (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 3F561F80579 for ; Wed, 11 Jan 2023 10:03:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3F561F80579 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=cEFzNw5b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GDOb2tx/JML9zMGoBP9KrBdDS2JotQqFmXaVZXQ1CciJ0ivVLWozMmNLwPsR+hacTogZ5NzeN06tUAaXl4WnYbDO8hSqJV9RkN/6tRmwOmfz6UbPNL7pjXwV7nXOtuJddL7sE6zYqqUbrl3h3BriP55BXBAgOf5uAJFuye0LU4vSZgSi+kb8cKUQU+bRh6b0n3V/zioJ2O8cOsrsI3W3P2j3ZbDmh/lrkpf1ZkgiqRUaUTpyD6yy2aZCSZxZTo8vAky7kPRdvTcYRyk4tu/YnwoP6CQr0ga+FYL2ag8wbBU4B/c9RoQM8XWvam3CCUEa/sfYDzswXZVFDq6OyqBVpg== 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=3a/H2doGWR7YV4MJgHmCrzGZ5Y+VdyOdV7Lcegcl8GY=; b=O6JAavymS+KQ+Np+OLLEYgAZwu9MwRaxl9D13fc9/mSbTj/NbK98OQ1YS4RLinJrtAKP87BUol7oOOFb6j20xeIFpGtq41hc/KYi5UCc9+TM9RUQgsvgRE+yRtZI42VA9voDhEweYchGiSs93hFCiJwkwTh6uUjn7BWAHdu4OzwOEvm5Zhozv8XohrpTAXwCN+xOl6Y4QY5hSv56toTd+pS0IkS0yonJ6vCIf1pWzY/eti4nNRrBsdHNjxxF5rkd9b5XY2m8cT7dXuCAspINcHmTqJ28wIMs3bg1A1M4pXiO8MZPTR8hOH75GBwVtQ4tRFFcDA8r07483/1RfPUopQ== 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 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=3a/H2doGWR7YV4MJgHmCrzGZ5Y+VdyOdV7Lcegcl8GY=; b=cEFzNw5bue7U4rInIgIiHB9J/2sgu14Cz8DZaiq0CMJnSodnnUji9K4j4Su/ph/LMFo+S29TFrVnd/M10/NRk+sF++wHLOkHPPEKXVq/Gz++FcxVZh68C82w28wf2ezgy92TqNZLLmKZ16zYLtcVyUboTAGnxcrhTytU6xiJCy8= Received: from BN0PR04CA0147.namprd04.prod.outlook.com (2603:10b6:408:ed::32) by PH7PR12MB6588.namprd12.prod.outlook.com (2603:10b6:510:210::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:03:54 +0000 Received: from BN8NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ed:cafe::85) by BN0PR04CA0147.outlook.office365.com (2603:10b6:408:ed::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:03:54 +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 BN8NAM11FT009.mail.protection.outlook.com (10.13.176.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:03:53 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 03:03:42 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:03:38 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 18/19] ASoC: amd: ps: implement system level pm ops for soundwire dma driver Date: Wed, 11 Jan 2023 14:32:21 +0530 Message-ID: <20230111090222.2016499-19-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT009:EE_|PH7PR12MB6588:EE_ X-MS-Office365-Filtering-Correlation-Id: 016dcf06-5dbe-4d7b-13ff-08daf3b2c3a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pbU6WG6wweBu60sRAU4Cxw1O8qnCNuQ4ACZv413GZn62tX0n6m7zvhcfaohe2B4fbzmZ+MpDDf8cxH3Xfo0jaC5KTP8+S1r+ime0X1AwHXurAMYZWKE1HhQTk84az5eocKYU/jCSoOWpdLjNeXClVYmS/6CXeNJ7wj5Bwq3+D8OyIAisre30ZlWulzOT2mULVt4rZ9TwxMmxdnY1GLOI6TALPD46Hi7x7kiwRogYI9wW8NESbvZRYsRVSQ5JeGTz932fatz/wMGqCAwZ0ybhng5SG/ndz6hNYRvxqNLEluOoPLtYkZ9TkerQrWZhZt3YIUTnS3hAXYr49tPheVcgIls/OMOUnoORVzrW0nWZjoLweDWK5Epl0S7t6avM++JGCn67dGlzpPvkb4gV07oofSNBXZGZDh+iS1MIWAZmpFXFtyoLr/+y2M0gQ3pdoJ2Eczrd9MhOG89O0AdJ2os5FzNbm9ad8z3HhBW3nQ8eIDMK++sD9a39TdSXiIN1s5pS6BfgiLsORtWreUeYjyIWB6EeX23rMaL3vw54dhXmsnT24ipnOYBK0jy1cTtRo1SNiNGBPj1LXy31Qn/DJyjbb4+fHMkJKKcGQFVyWi5/qe+L4Dj4Ey5eGaJQDi+h0+cu2xHx6snNz5UH/hO1fqdOwUI/YmtklZUh1+lPiNQsc4DKRepJH1ZsW51Jn04JSQlwbPYRv5jBckV9suvXMhFli5m+caMpn4vsl1BY/4/F9Kw= 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:(13230022)(4636009)(136003)(396003)(376002)(39860400002)(346002)(451199015)(40470700004)(36840700001)(46966006)(356005)(70206006)(4326008)(8676002)(82310400005)(70586007)(83380400001)(7696005)(86362001)(41300700001)(8936002)(36756003)(81166007)(186003)(26005)(6666004)(316002)(478600001)(110136005)(40480700001)(82740400003)(426003)(40460700003)(54906003)(1076003)(47076005)(5660300002)(2616005)(336012)(36860700001)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:03:53.7407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 016dcf06-5dbe-4d7b-13ff-08daf3b2c3a1 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: BN8NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6588 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add support for system level pm ops for soundwire dma driver for pink sardine platform. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/ps-sdw-dma.c | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/sound/soc/amd/ps/ps-sdw-dma.c b/sound/soc/amd/ps/ps-sdw-dma.c index 960c0bc5e848..ba2eea23d41e 100644 --- a/sound/soc/amd/ps/ps-sdw-dma.c +++ b/sound/soc/amd/ps/ps-sdw-dma.c @@ -623,6 +623,64 @@ static int acp63_sdw_platform_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused acp63_sdw_pcm_resume(struct device *dev) +{ + struct sdw_dma_dev_data *sdw_dma_data; + struct sdw_stream_instance *sdw_ins; + struct snd_pcm_runtime *runtime; + u32 period_bytes, buf_size, water_mark_size_reg; + int ret; + int index; + + sdw_dma_data = dev_get_drvdata(dev); + for (index = 0; index < ACP63_SDW_MAX_STREAMS; index++) { + if (sdw_dma_data->sdw_stream[index] && + sdw_dma_data->sdw_stream[index]->runtime) { + switch (index) { + case ACP_SDW_AUDIO_TX: + water_mark_size_reg = ACP_AUDIO_TX_INTR_WATERMARK_SIZE; + break; + case ACP_SDW_BT_TX: + water_mark_size_reg = ACP_BT_TX_INTR_WATERMARK_SIZE; + break; + case ACP_SDW_HS_TX: + water_mark_size_reg = ACP_HS_TX_INTR_WATERMARK_SIZE; + break; + case ACP_SDW1_BT_TX: + water_mark_size_reg = ACP_P1_BT_TX_INTR_WATERMARK_SIZE; + break; + case ACP_SDW_AUDIO_RX: + water_mark_size_reg = ACP_AUDIO_RX_INTR_WATERMARK_SIZE; + break; + case ACP_SDW_BT_RX: + water_mark_size_reg = ACP_BT_RX_INTR_WATERMARK_SIZE; + break; + case ACP_SDW_HS_RX: + water_mark_size_reg = ACP_HS_RX_INTR_WATERMARK_SIZE; + break; + case ACP_SDW1_BT_RX: + water_mark_size_reg = ACP_P1_BT_RX_INTR_WATERMARK_SIZE; + break; + default: + dev_err(dev, "%s: Invalid channel type\n", __func__); + return -EINVAL; + } + runtime = sdw_dma_data->sdw_stream[index]->runtime; + sdw_ins = runtime->private_data; + period_bytes = frames_to_bytes(runtime, runtime->period_size); + buf_size = frames_to_bytes(runtime, runtime->buffer_size); + acp63_config_dma(sdw_ins, index); + ret = acp63_configure_sdw_ringbuffer(sdw_dma_data->acp_base, index, + buf_size); + if (ret) + return ret; + acp63_writel(period_bytes, sdw_dma_data->acp_base + water_mark_size_reg); + } + } + acp63_enable_disable_sdw_dma_interrupts(sdw_dma_data->acp_base, true); + return 0; +} + static int __maybe_unused acp63_sdw_pcm_runtime_suspend(struct device *dev) { struct sdw_dma_dev_data *sdw_dma_data; @@ -650,6 +708,7 @@ static int __maybe_unused acp63_sdw_pcm_runtime_resume(struct device *dev) static const struct dev_pm_ops acp63_pm_ops = { SET_RUNTIME_PM_OPS(acp63_sdw_pcm_runtime_suspend, acp63_sdw_pcm_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(acp63_sdw_pcm_runtime_suspend, acp63_sdw_pcm_resume) }; static struct platform_driver acp63_sdw_dma_driver = { From patchwork Wed Jan 11 09:02:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13096302 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 34F54C46467 for ; Wed, 11 Jan 2023 09:06:23 +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 67D193664; Wed, 11 Jan 2023 10:05:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 67D193664 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673427976; bh=GbplTMTX0DVbgVGT6y95fxro380uNUc3UatQqvskn9k=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=U4lOVwsUpgARk+6jnaubiLOimAscg5V6pxP2tqON7i7kcAKOOC7OzA+gugBu46Oxx Z5RG/AiNjGQ8vws7wQJCUbjEnfvR0auDKkUqNif5ALyIkywZP/vYWMCD+vJkkkrmiG kZQbNs6yABQgNogTIeygXt0g/7zUOIjM2Vk03/mo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A3D50F805A1; Wed, 11 Jan 2023 10:04:03 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 01E82F80580; Wed, 11 Jan 2023 10:04:01 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2045.outbound.protection.outlook.com [40.107.243.45]) (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 A2D6AF80571 for ; Wed, 11 Jan 2023 10:03:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A2D6AF80571 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=dK04mPLo ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lx7qbffImFmxOGuBRA42/FwHTCmHg+fOkARMqyhWUFwME4Icvm9CAAr92DDCWO4Eeg7aheFeWJ7sqtggGmRoAi+72VBk1IxHEhu/vU8yA5+D6+T8m1WqLWKSls/EHdpTT3/aeteUwvKTzJccgPRw/xKGvieOzP6i7bUX03+1i+5o3ziAmMMCBt+i5lDMu0CF5X5VaJkIKXCOCnqqbL/8XfWl+1596r388enKSMmXE1Rf2GUwcFBfOMHCvXBHOJf1tk09vaPn+aAfFqLrdriDem/j1tMbgRvzCa9HSaAwm89txYv7YQ+xQJWEjfBvFq1Zr4XDqaWwZAR/Pl2Sjan4HA== 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=cZMXt8C6+nAkybTbBz/l5hTmmGkMItamXiYVLJmt7ZU=; b=Oqbfg0euoCUCnMsDxwC4UvJwIf2mP9qVgOsr6ZUYmO12MEWpcuAJBXdDhIeZ1Dx9E9NNaCBFH9zdM4hCDqXKLl6nE5b5Oi7qytIUsu8NHdGAdzFE+Pxo21qQzUQ43lyqX8qwjgbwUU1FIpfn5eOVgFKn390xjWp2EmPGblhTSz6dM+pIgjzN2WYViG2qqsPuBjHGV3QZ9g/6QuRU5pCv6+sEHlfXKPDb9WrlNHeTG3nURdZjxjHx6c8OZM31FD89O3LtIsNTgnJtLRofusLpj9Vp+lj2oRykmn4wBphWoYU+uAFUPDvEZt+39fC6IMvx3iK7i4R24KiKyibk1+IOaA== 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 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=cZMXt8C6+nAkybTbBz/l5hTmmGkMItamXiYVLJmt7ZU=; b=dK04mPLoNqgZW8yxmm86TmDAT8HJuR+JS51/ew64U9pF+nf6dPUZsp1U0zrrgV13F1+ugX7nlr8nOYnjSUCoYvEZ/5rJKCLnFDizqai27C0DcoAwyqosKg/aUKLPQVnVKTMubqSjlcN8/13eYlV9/99ovL6no960mW4aiZHwCYQ= Received: from BN8PR07CA0007.namprd07.prod.outlook.com (2603:10b6:408:ac::20) by DM4PR12MB6232.namprd12.prod.outlook.com (2603:10b6:8:a5::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 09:03:55 +0000 Received: from BN8NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ac:cafe::1) by BN8PR07CA0007.outlook.office365.com (2603:10b6:408:ac::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12 via Frontend Transport; Wed, 11 Jan 2023 09:03:55 +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 BN8NAM11FT023.mail.protection.outlook.com (10.13.177.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 09:03:55 +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.2375.34; Wed, 11 Jan 2023 03:03:50 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.2375.34; Wed, 11 Jan 2023 03:03:48 -0600 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 11 Jan 2023 03:03:45 -0600 From: Vijendar Mukunda To: , , Subject: [PATCH 19/19] ASoC: amd: ps: increase runtime suspend delay Date: Wed, 11 Jan 2023 14:32:22 +0530 Message-ID: <20230111090222.2016499-20-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> References: <20230111090222.2016499-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT023:EE_|DM4PR12MB6232:EE_ X-MS-Office365-Filtering-Correlation-Id: 2fc2d00c-73b1-47fb-0e1f-08daf3b2c49e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +JE+zrpCwIFZXQG/zlc1muZL2nPIsHrdIP3+t0PzTX+Fn53RZ7IDDYJmVkuy41xeGYb9c5NxP0unDL7GSR1q6fka42vXWzgeTVAZxpbDiC+5XO7r+rVSio/hugnSWqsWtxZblEtipQX/vBlp1N+3BiKjtvT2d2hYs6v1eN8bkvPbgAOiwo3hRBYvQdwW6ZoBAr99TqscoMa7CHWV8kkWVPsHZTg5JBYWzcw8dMucJdwXG35VHjTPYiNCuV6CjVw+id3aKGFw+R705ArrMzQX/iVCR2LdTFeked/Aud0gSfgWMECmhbTPG3/8IaERsSYcptm6J0YOcMISGJ5DXQIuK4P2zRVHgbXC7X0h8rdS/q+MDiTCHsygn5nKX/wC/AdWZK45zfYV++IIg2ih+2OZf4U6zIxg7Oc86VJWxxwBuWYi5cjTagPKwGLBmqsGU9+kXQ3quhBMSCQL7g7aj7iaxsRPHfNzcHjbtyRgUzGc55xW8rB9VH7+76FzHBYaAQ4B5dwGs1w01dgK8etnjfOcIROmk022jvS/TDz7fFDxgCMaC+4HrZieDIACrbb1acvmr5V7MlE692GmZS3AUOwdqsYZGrvMAVEQP7MZouAQQAPNbq5dIN54f4srJ4eofFKOXEpLCJc9q0tfhSBjfMGYWAWByNgy1gkRiYBQkUp80FfAlflRePYNOXoqqkvfqh0grzsx4ELYebL4gKcHwmiwhjhtW1Yb8E01eRXBiDMl1kg= 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:(13230022)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199015)(36840700001)(40470700004)(46966006)(82310400005)(2906002)(15650500001)(36756003)(4744005)(5660300002)(8936002)(70206006)(6666004)(8676002)(41300700001)(2616005)(70586007)(316002)(7696005)(4326008)(54906003)(110136005)(478600001)(40480700001)(26005)(186003)(336012)(1076003)(426003)(86362001)(47076005)(83380400001)(36860700001)(40460700003)(356005)(81166007)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 09:03:55.3361 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2fc2d00c-73b1-47fb-0e1f-08daf3b2c49e 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: BN8NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6232 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mastan.Katragadda@amd.com, Sunil-kumar.Dommati@amd.com, open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Mario.Limonciello@amd.com, Vijendar Mukunda , arungopal.kondaveeti@amd.com, Syed Saba Kareem Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To avoid ACP entering into D3 state during slave enumeration and initialization on two soundwire controller instances for multiple codecs, increase the runtime suspend delay to 3 seconds. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/ps/acp63.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/amd/ps/acp63.h b/sound/soc/amd/ps/acp63.h index 833d0b5aa73d..6c8849f2bcec 100644 --- a/sound/soc/amd/ps/acp63.h +++ b/sound/soc/amd/ps/acp63.h @@ -51,7 +51,7 @@ #define MIN_BUFFER MAX_BUFFER /* time in ms for runtime suspend delay */ -#define ACP_SUSPEND_DELAY_MS 2000 +#define ACP_SUSPEND_DELAY_MS 3000 #define ACP63_DMIC_ADDR 2 #define ACP63_PDM_MODE_DEVS 3