From patchwork Mon Jan 20 10:01:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mukunda,Vijendar" X-Patchwork-Id: 13944967 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2073.outbound.protection.outlook.com [40.107.237.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95ADE1DF75C; Mon, 20 Jan 2025 10:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737367352; cv=fail; b=BVXE4aqNk90ODwpt0f/D2D9VwRsaPLSTmw9RxUTOJ+SABbErET8MvCHq3NxlQlZscEkK77dUuqnqSRqiGsrbwxSKZf84tfKMQE6VDyJpAon7s4SwZTFwrLjnDNVYeU1N6DdYunj9pCQVDo6I3oknvjUIff+NkUgpZ8D2lGaIpjk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737367352; c=relaxed/simple; bh=61vLK/Lfbnuo0apna6hf5huq1f9vNvNfWkOnCfLep8I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Sk3xLZfuupHHL7A33XNL/AlHfMOeLFC4ANfmkabzd7vzRGj+fdnZ0Y6Qn3b2oPqWnwZpG6Lbzh96EeubTNgYKgp8T7Eg4De2+AChVB7f3zcUzrJ+qQFqUiB1wYLxa52iJaO+ZSp2hGyU7q/a6vBaTsPL5zbKH9uAdsEQHI4QhbQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=VOgPQqIb; arc=fail smtp.client-ip=40.107.237.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="VOgPQqIb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Nt4a+EgF/2hUkqfIrcqzxe+ZFdCyiHsAwdyw9Ah38t0UsD0/nSQAy/kkDce61ibLvlr1aFLnAjpJmZwy5UDT9s2xVLsgtP5HNIiehqEMh9P04eBdWWmLjzBeLW8c4dj2C8Myt6aEAIhBXYpskC0sicvlhtOuLGuoREKKBii3Q7pWq4eG5etp1/vJpVT//llwSIRdmtv/Aad0+JSPalCEqPA6+X1FBgecopsM7gZg9iGtaEJVcrnvhud3LIruJ0ubPMuHwcpb2d1K8FECeZRa9BaPRmCTnNZC9bB6zsOrmwXbgBsnM24pvzBYeo2rsfrg1DCqmKnsCG5lfLOH0OxWaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7I/noJPxLUYHqZ/gxxeYaLw3vbYs4PWX8xD6KqYdxSA=; b=QohtfgEJY9ezZMhRp8Q90Qmm53MdW6HfGjOZMDh+H8xoXH3WpEIMC/gNJLDCKQjnFg4f9iitko0Pujzb46Ccy6DOMNbB8P2olbXUbarZqnZ/dnbf9uXWgLEkCZWPZcqoAvNmyM6nFymSYUIFrSEZGBGMInBys2Uaieos17vuXt3xmhUzgrxOW2skz9DvhthIvnZuTelXQDbSwtY/bmCXXb7aqJERaJxsGEJszEJPycHcLK3xhcdsgZnCrYhIAji0DDif1+LS+Y7CYboDvWX4BCXhA6Qt2SZeQ498sDhc+lHnXbgiPQEc3iH8qHUxREep3iNUyekIEypSaKXdDiWhxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7I/noJPxLUYHqZ/gxxeYaLw3vbYs4PWX8xD6KqYdxSA=; b=VOgPQqIbC6J8vmHOzok7/b9G92ZYnzUbOoXi6eaJCS291Dwbi02QueiZ2aC2EudBe+nUnqm419oTbhQPk1abF29SvqSGGVFuCRw3h9Zh9+tuC8cDmX4LMk6vVyc5d6R3kqZXuYTdGWZ92fl6JX7udS96rOlWs1niwxXVFEp1/gs= Received: from CH0PR13CA0024.namprd13.prod.outlook.com (2603:10b6:610:b1::29) by SN7PR12MB8130.namprd12.prod.outlook.com (2603:10b6:806:32e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.17; Mon, 20 Jan 2025 10:02:27 +0000 Received: from CH1PEPF0000AD7C.namprd04.prod.outlook.com (2603:10b6:610:b1:cafe::15) by CH0PR13CA0024.outlook.office365.com (2603:10b6:610:b1::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.7 via Frontend Transport; Mon, 20 Jan 2025 10:02:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD7C.mail.protection.outlook.com (10.167.244.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8377.8 via Frontend Transport; Mon, 20 Jan 2025 10:02:27 +0000 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 20 Jan 2025 04:02:23 -0600 From: Vijendar Mukunda To: CC: , , , , , , , , , , Vijendar Mukunda Subject: [PATCH V2 12/23] ASoC: amd: acp70: add acp ip interrupt handler Date: Mon, 20 Jan 2025 15:31:19 +0530 Message-ID: <20250120100130.3710412-13-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250120100130.3710412-1-Vijendar.Mukunda@amd.com> References: <20250120100130.3710412-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7C:EE_|SN7PR12MB8130:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a82f8dc-6a2a-4e8a-55a3-08dd39398b94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: 2kBpZBRyZByO8yX3Nf0SpCOE8CdB0pUIAfgIDm4Aab8WQIPj9vFGaQctxZdCUwHkAky+2MVIxEYD6akeiI2TuKaZ8hQl2OtqNZ8BXoB5Fq+kAq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US1/1dasviPXhiUINNUseJEyeFYxLkfX8KBQqPg/51sgtLskfvlqI78uWsK/wOO/O3AHCsGQn4kfymObvcVk7x+F6MMYJxfb47JhaQUS8s9C9e4aoQIqluVAOQZgJYRq3lAfSuAc0csDa1K2zbIhYjk9FHCJtO1jDmnuE5VUhMsw/b5PrM6M47S71jWR3rX2i0BqguNnDvxmyC4m9KFoeUdxfOiLYvXvLa4NSnbZZMgn6Jb0nnSlnh13fUTd0OYBdPhIorcsNOF9sziZP/uCwZG7eybY1agaROze6Fzfpxz3QIzKRAKpgsjHeW+Y/hA0TB21J6FSAKY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2025 10:02:27.3214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a82f8dc-6a2a-4e8a-55a3-08dd39398b94 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: CH1PEPF0000AD7C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8130 Add interrupt handler for handling, below listed interrupts for ACP IP. - SoundWire dma driver interrupts - ACP PDM dma driver interrupts - SoundWire manager related interrupts - ACP error interrupts. Signed-off-by: Vijendar Mukunda --- sound/soc/amd/acp70/acp70.h | 4 + sound/soc/amd/acp70/pci-acp70.c | 161 +++++++++++++++++++++++++++++++- 2 files changed, 164 insertions(+), 1 deletion(-) diff --git a/sound/soc/amd/acp70/acp70.h b/sound/soc/amd/acp70/acp70.h index a96b021e64da..d5ab606adedc 100644 --- a/sound/soc/amd/acp70/acp70.h +++ b/sound/soc/amd/acp70/acp70.h @@ -238,6 +238,8 @@ struct sdw_dma_dev_data { * @addr: pci ioremap address * @reg_range: ACP reigister range * @acp_rev : ACP PCI revision id + * @sdw0-dma_intr_stat: DMA interrupt status array for SoundWire manager-SW0 instance + * @sdw_dma_intr_stat: DMA interrupt status array for SoundWire manager-SW1 instance * @is_sdw_dev: flag set to true when any SoundWire manager instances are available * @is_pdm_dev: flag set to true when ACP PDM controller exists * @is_pdm_config: flat set to true when PDM configuration is selected from BIOS @@ -257,6 +259,8 @@ struct acp70_dev_data { u32 addr; u32 reg_range; u32 acp_rev; + u16 sdw0_dma_intr_stat[ACP70_SDW0_DMA_MAX_STREAMS]; + u16 sdw1_dma_intr_stat[ACP70_SDW1_DMA_MAX_STREAMS]; bool is_sdw_dev; bool is_pdm_dev; bool is_pdm_config; diff --git a/sound/soc/amd/acp70/pci-acp70.c b/sound/soc/amd/acp70/pci-acp70.c index a6812fa269b1..e732a680c092 100644 --- a/sound/soc/amd/acp70/pci-acp70.c +++ b/sound/soc/amd/acp70/pci-acp70.c @@ -8,11 +8,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include "../mach-config.h" #include "acp70.h" @@ -96,6 +98,155 @@ static int acp70_deinit(void __iomem *acp_base, struct device *dev) return 0; } +static irqreturn_t acp70_irq_thread(int irq, void *context) +{ + struct sdw_dma_dev_data *sdw_dma_data; + struct acp70_dev_data *adata = context; + u32 stream_index; + + sdw_dma_data = dev_get_drvdata(&adata->sdw_dma_dev->dev); + + for (stream_index = 0; stream_index < ACP70_SDW0_DMA_MAX_STREAMS; stream_index++) { + if (adata->sdw0_dma_intr_stat[stream_index]) { + if (sdw_dma_data->sdw0_dma_stream[stream_index]) + snd_pcm_period_elapsed(sdw_dma_data->sdw0_dma_stream[stream_index]); + adata->sdw0_dma_intr_stat[stream_index] = 0; + } + } + for (stream_index = 0; stream_index < ACP70_SDW1_DMA_MAX_STREAMS; stream_index++) { + if (adata->sdw1_dma_intr_stat[stream_index]) { + if (sdw_dma_data->sdw1_dma_stream[stream_index]) + snd_pcm_period_elapsed(sdw_dma_data->sdw1_dma_stream[stream_index]); + adata->sdw1_dma_intr_stat[stream_index] = 0; + } + } + return IRQ_HANDLED; +} + +static irqreturn_t acp70_irq_handler(int irq, void *dev_id) +{ + struct acp70_dev_data *adata; + struct pdm_dev_data *ps_pdm_data; + struct amd_sdw_manager *amd_manager; + u32 ext_intr_stat, ext_intr_stat1; + u32 stream_id = 0; + u16 irq_flag = 0; + u16 sdw_dma_irq_flag = 0; + u16 index; + + adata = dev_id; + if (!adata) + return IRQ_NONE; + /* ACP interrupts will be cleared by reading particular bit and writing + * same value to the status register. writing zero's doesn't have any + * effect. + * Bit by bit checking of IRQ field is implemented. + */ + ext_intr_stat = readl(adata->acp70_base + ACP_EXTERNAL_INTR_STAT); + if (ext_intr_stat & ACP_SDW0_STAT) { + writel(ACP_SDW0_STAT, adata->acp70_base + ACP_EXTERNAL_INTR_STAT); + amd_manager = dev_get_drvdata(&adata->sdw->pdev[0]->dev); + if (amd_manager) + schedule_work(&amd_manager->amd_sdw_irq_thread); + irq_flag = 1; + } + + ext_intr_stat1 = readl(adata->acp70_base + ACP_EXTERNAL_INTR_STAT1); + if (ext_intr_stat1 & ACP_SDW1_STAT) { + writel(ACP_SDW1_STAT, adata->acp70_base + ACP_EXTERNAL_INTR_STAT1); + amd_manager = dev_get_drvdata(&adata->sdw->pdev[1]->dev); + if (amd_manager) + schedule_work(&amd_manager->amd_sdw_irq_thread); + irq_flag = 1; + } + + if (ext_intr_stat & ACP_ERROR_IRQ) { + writel(ACP_ERROR_IRQ, adata->acp70_base + ACP_EXTERNAL_INTR_STAT); + writel(0, adata->acp70_base + ACP_SW0_I2S_ERROR_REASON); + writel(0, adata->acp70_base + ACP_SW1_I2S_ERROR_REASON); + writel(0, adata->acp70_base + ACP_ERROR_STATUS); + irq_flag = 1; + } + + if (ext_intr_stat & BIT(PDM_DMA_STAT)) { + ps_pdm_data = dev_get_drvdata(&adata->pdm_dev->dev); + writel(BIT(PDM_DMA_STAT), adata->acp70_base + ACP_EXTERNAL_INTR_STAT); + if (ps_pdm_data->capture_stream) + snd_pcm_period_elapsed(ps_pdm_data->capture_stream); + irq_flag = 1; + } + + if (ext_intr_stat & ACP_SDW_DMA_IRQ_MASK) { + for (index = ACP_AUDIO2_RX_THRESHOLD; index <= ACP_AUDIO0_TX_THRESHOLD; index++) { + if (ext_intr_stat & BIT(index)) { + writel(BIT(index), adata->acp70_base + ACP_EXTERNAL_INTR_STAT); + switch (index) { + case ACP_AUDIO0_TX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO0_TX; + break; + case ACP_AUDIO1_TX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO1_TX; + break; + case ACP_AUDIO2_TX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO2_TX; + break; + case ACP_AUDIO0_RX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO0_RX; + break; + case ACP_AUDIO1_RX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO1_RX; + break; + case ACP_AUDIO2_RX_THRESHOLD: + stream_id = ACP_SDW0_AUDIO2_RX; + break; + } + + adata->sdw0_dma_intr_stat[stream_id] = 1; + sdw_dma_irq_flag = 1; + } + } + } + + if (ext_intr_stat1 & ACP_P1_SDW_DMA_IRQ_MASK) { + for (index = ACP_P1_AUDIO2_RX_THRESHOLD; index <= ACP_P1_AUDIO0_TX_THRESHOLD; index++) { + if (ext_intr_stat1 & BIT(index)) { + writel(BIT(index), adata->acp70_base + ACP_EXTERNAL_INTR_STAT1); + switch (index) { + case ACP_P1_AUDIO0_TX_THRESHOLD: + stream_id = ACP_SDW1_AUDIO0_TX; + break; + case ACP_P1_AUDIO1_TX_THRESHOLD: + stream_id = ACP_SDW1_AUDIO1_TX; + break; + case ACP_P1_AUDIO2_TX_THRESHOLD: + stream_id = ACP_SDW1_AUDIO2_TX; + break; + case ACP_P1_AUDIO0_RX_THRESHOLD: + stream_id = ACP_SDW1_AUDIO0_RX; + break; + case ACP_P1_AUDIO1_RX_THRESHOLD: + stream_id = ACP_SDW1_AUDIO1_RX; + break; + case ACP_P1_AUDIO2_RX_THRESHOLD: + stream_id = ACP_SDW1_AUDIO2_RX; + break; + } + + adata->sdw1_dma_intr_stat[stream_id] = 1; + sdw_dma_irq_flag = 1; + } + } + } + + if (sdw_dma_irq_flag) + return IRQ_WAKE_THREAD; + + if (irq_flag) + return IRQ_HANDLED; + else + return IRQ_NONE; +} + #if IS_ENABLED(CONFIG_SND_SOC_AMD_SOUNDWIRE) static int acp_scan_sdw_devices(struct device *dev, u64 addr) { @@ -333,8 +484,11 @@ static int snd_acp70_probe(struct pci_dev *pci, { struct acp70_dev_data *adata; u32 addr, flag; + u32 irqflags; int ret; + irqflags = IRQF_SHARED; + /* Return if acp config flag is defined */ flag = snd_amd_acp_find_config(pci); if (flag) @@ -382,7 +536,12 @@ static int snd_acp70_probe(struct pci_dev *pci, ret = acp70_init(adata->acp70_base, &pci->dev); if (ret) goto release_regions; - + ret = devm_request_threaded_irq(&pci->dev, pci->irq, acp70_irq_handler, + acp70_irq_thread, irqflags, "ACP_PCI_IRQ", adata); + if (ret) { + dev_err(&pci->dev, "ACP PCI IRQ request failed\n"); + goto de_init; + } ret = get_acp70_device_config(pci, adata); /* ACP PCI driver probe should be continued even PDM or SoundWire Devices are not found */ if (ret) {