Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1589347pxv; Fri, 16 Jul 2021 12:46:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc0+1q5b82whhrMuYnCB5qrrB3tiIPHEOJVvhDnKgWbsU4CPod4KU7QlyqDZoyT5z+e5cO X-Received: by 2002:a17:906:3555:: with SMTP id s21mr13186981eja.394.1626464802126; Fri, 16 Jul 2021 12:46:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1626464802; cv=pass; d=google.com; s=arc-20160816; b=XYXhIhlyykDZg9wjSun/xLuparShNXamOCRCsxMa7bmb9LRz0E9lObNO1kJf/Y/r53 oWhzq/h7ZJDg67sMQsw6TLeqwDnE0M8YB1xWBYqyW29IQmanyTQEHkF5GdOFepsSrzLt 9nQm6xGKybbFm9tHQ31MBsQ9ogjcS1E29LdJtlOlairE8PlhShlHQX1s3dl8ivOxqh/j GSJmLDnb+s0juspduYSFDlS6A3ZRK+EZ3gdRMlYaBz54jThhBf0CDSLDA5upkaNArAgp xlKcXBQyNKXk0MYYM9sck79LS1pvRnpJMeWfexr8FIANmR/+YEsIPAQXV4EurnIQ7mm5 ep+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8r5GStPMZm6rd9rqpKKTAPlZHKzc3F7vKikwwpYO5Wk=; b=pWgWdZ2BJy1ZkGqsShS2yyGl/isx2SuOf2WK67js+jX/yxA9WbTVQB2zPrfa9DVJfa Cy/ys+Q38CMcJF2Kacv8K9I93bFUfwu/XZ/apk3u/ueanhhPMEbLJMbZUKQbFLs8IJ6Z LnnAOTld0GswucfrKD/CtBJpMBl+xbQh+tgthSyHWwk1ot3bsPYxHf+aX0HcQ+RbWmej 721wl5lsDrC6Cc1yQlhBtEEJSpc9dqSz/3EI7X8/+UP5saqraMOdf9aP5KXV8+Gzyn4H HwMJ/MPQAW6etONhE+87a13ltFEPkgqCKYp23NTZ11h2hPPaM5++5JGOxT4ug3MT77Pe yE9Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="Z/r9aPsL"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si11784094edt.124.2021.07.16.12.46.19; Fri, 16 Jul 2021 12:46:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="Z/r9aPsL"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233236AbhGPTqI (ORCPT + 99 others); Fri, 16 Jul 2021 15:46:08 -0400 Received: from mail-bn7nam10on2082.outbound.protection.outlook.com ([40.107.92.82]:50081 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233227AbhGPTqH (ORCPT ); Fri, 16 Jul 2021 15:46:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h+JqH74dLdd0lKIFtlvhTCME6u8tTXs8Pw+lMNGukYSjgjs/53Vt2LtUl6VykrbPM57TAyDj3tgLS+Kt++194H3q/9yyua5kAxOthuv2gcKyeCbNBaz9XSprmm9LIKQN826NbrHG0YOsaTx5fWGiCMazI9BFbVZXLXVFMNNFcTmbQHTOcE8930WHIH429HeQsxet1IaVQAnbKKqzR7RRvmqZbMhWxHPxBFqB44y1hV+cnlBXQI3WhmVJ0nHxdyQMmr0u0DqixM08wCDVGoSuDw7IQkA9iZBjuIPEGjW1YTkI0FDh8MT3NPr48XdhF9vgxVkqSTa0sxZk/Bl3sGpxkg== 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-SenderADCheck; bh=8r5GStPMZm6rd9rqpKKTAPlZHKzc3F7vKikwwpYO5Wk=; b=HN7dCuxoJBVgnEz1X+42drCFllxbvczBUBf5sT5RB8s4BamjGP/+3f+6cUK4Ynzj/QfVGDvKXFLwYxMN8QM3JNLLNnZl89I3eZTylaPlok2GCinIzKApwHMEfisnE/ir0592iphj92OPxEWC6f4wXZ4STXDqzn8zehxZ8J+635OVblvTM02wYWS39Ppot+ObKMBxsSg0M26lI+SNVUqvDLjfUgH3Mp2Nv0VNjx636icQ+ARQBn4FyaCQ/vO1N01UQ3rQ6muA1RUT4lsDOLmMMhX0/G8lrzBju1jyZH21upIHAaT6QWBOi9+Id9+vvw+K1HKxH21DIfTxaYO5xsAktA== 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=8r5GStPMZm6rd9rqpKKTAPlZHKzc3F7vKikwwpYO5Wk=; b=Z/r9aPsL5Vygr6zz8ZUnQxs2bpM7eQuU9WPb3x3kS9UgPOoIwNxEe3EExCrIySbOUiAFI0RnZfXDiQuHqaJ/5wEVMWnRwoAW2j3o2LOpjfA+Q5CrDbmddGCybW+OFbT4cTz+fijEz+D5CZ3dDvsyaO0YfIVjvdiAPZgYVV32yz4= Received: from BN9PR03CA0930.namprd03.prod.outlook.com (2603:10b6:408:107::35) by DM5PR12MB1820.namprd12.prod.outlook.com (2603:10b6:3:10d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.25; Fri, 16 Jul 2021 19:43:10 +0000 Received: from BN8NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::7d) by BN9PR03CA0930.outlook.office365.com (2603:10b6:408:107::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23 via Frontend Transport; Fri, 16 Jul 2021 19:43:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; 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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT044.mail.protection.outlook.com (10.13.177.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 19:43:09 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Fri, 16 Jul 2021 14:43:09 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Fri, 16 Jul 2021 14:43:09 -0500 Received: from vijendar-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Fri, 16 Jul 2021 14:43:01 -0500 From: Vijendar Mukunda To: , CC: , , , Vijendar Mukunda , Vijendar Mukunda , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , open list Subject: [PATCH RESEND 06/12] ASoC: amd: irq handler changes for ACP5x PCM dma driver Date: Sat, 17 Jul 2021 09:30:53 +0530 Message-ID: <20210717040059.310410-7-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210717040059.310410-1-Vijendar.Mukunda@amd.com> References: <20210717040059.310410-1-Vijendar.Mukunda@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3dc801df-9738-4a2f-0bac-08d94891f0f5 X-MS-TrafficTypeDiagnostic: DM5PR12MB1820: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:98; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kJxjuGxV3AxnxJqaJPbkxVLUFIXcZxUFo59GE0uTsuUgMVbaqp444BpkUEE2n/aIq2XMjzWzmkXskhKhiq9j9CM8VsYtTB807CAowiUIVDIDbd0Z1L1QO5O8owZ1EDM5GugSd24W0uzAr6kwj0PQK/CPSOwbOeWKUa/2/6BI+KUYu2LS/iC1WXvfKmWLkY7NpWXT+pyJbymgC6/MMYP/Tm56fcL7udgKrN3sTHNqN9oZQQ6Oy8aKtkiUbUfjnaC+gNnSRlUorAtPkdKTPmPRN8COVXM67BvJutWhughrU9/covvcZ9QfKfSe6yWwhsbTBZwfAvwir5HkVlI+2nqFZdi18NdNHJppTmUirHHPIPge/TRwz4ky4/IjBjrfc2UcaI1uACkLCfCnndZkfyCmgT25iG3WJh5mJ5Ya1DvPGAUcqhIFyKlCDMv9mK1RJGmygPODdbCGZL2KdoS6ZsxBmGOa6cFUiTvMstwH+MUdDULR5ZewD37vWHjYh/xePalGCJ6lsALuKyPbNw7NvCe8wR+toTu4qjGJUkOUrHfHHXh/pUj87b5M+Pos06RF19VygXbaRG/vB3fxwEbPevGPPlAMZUBeUnYZWHwbkwdmTz6WQl0zkKtsUVGw6D9g/KecMaVJUJUFk6mRkYgM6pTHkdC0xe4VM6p6VTkr1l3zMzAMCFYZ/+qCbW0eWLqJPBFchylzLHOjrKPijH9Fo+fr7Lf7VSUL6u/u7FqbmVNBfLENzrUG2JzbL/qsbl0XLoLO 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:(4636009)(396003)(376002)(346002)(136003)(39860400002)(46966006)(36840700001)(82740400003)(336012)(70586007)(478600001)(36756003)(70206006)(86362001)(36860700001)(2906002)(2616005)(316002)(5660300002)(1076003)(81166007)(7696005)(8676002)(110136005)(54906003)(356005)(426003)(4326008)(186003)(83380400001)(82310400003)(47076005)(8936002)(6666004)(26005)(32563001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 19:43:09.9155 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3dc801df-9738-4a2f-0bac-08d94891f0f5 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: BN8NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1820 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vijendar Mukunda Whenever audio data equal to the I2S FIFO watermark level are produced/consumed, interrupt is generated. Acknowledge the interrupt. Signed-off-by: Vijendar Mukunda --- v1 -> v2: use single flag for handling irq status --- sound/soc/amd/vangogh/acp5x-pcm-dma.c | 61 +++++++++++++++++++++++++++ sound/soc/amd/vangogh/acp5x.h | 9 ++++ 2 files changed, 70 insertions(+) diff --git a/sound/soc/amd/vangogh/acp5x-pcm-dma.c b/sound/soc/amd/vangogh/acp5x-pcm-dma.c index 2ff11bb88305..76a965a8ec3c 100644 --- a/sound/soc/amd/vangogh/acp5x-pcm-dma.c +++ b/sound/soc/amd/vangogh/acp5x-pcm-dma.c @@ -21,10 +21,57 @@ static const struct snd_soc_component_driver acp5x_i2s_component = { .name = DRV_NAME, }; +static irqreturn_t i2s_irq_handler(int irq, void *dev_id) +{ + struct i2s_dev_data *vg_i2s_data; + u16 irq_flag; + u32 val; + + vg_i2s_data = dev_id; + if (!vg_i2s_data) + return IRQ_NONE; + + irq_flag = 0; + val = acp_readl(vg_i2s_data->acp5x_base + ACP_EXTERNAL_INTR_STAT); + if ((val & BIT(HS_TX_THRESHOLD)) && vg_i2s_data->play_stream) { + acp_writel(BIT(HS_TX_THRESHOLD), vg_i2s_data->acp5x_base + + ACP_EXTERNAL_INTR_STAT); + snd_pcm_period_elapsed(vg_i2s_data->play_stream); + irq_flag = 1; + } + if ((val & BIT(I2S_TX_THRESHOLD)) && + vg_i2s_data->i2ssp_play_stream) { + acp_writel(BIT(I2S_TX_THRESHOLD), + vg_i2s_data->acp5x_base + ACP_EXTERNAL_INTR_STAT); + snd_pcm_period_elapsed(vg_i2s_data->i2ssp_play_stream); + irq_flag = 1; + } + + if ((val & BIT(HS_RX_THRESHOLD)) && vg_i2s_data->capture_stream) { + acp_writel(BIT(HS_RX_THRESHOLD), vg_i2s_data->acp5x_base + + ACP_EXTERNAL_INTR_STAT); + snd_pcm_period_elapsed(vg_i2s_data->capture_stream); + irq_flag = 1; + } + if ((val & BIT(I2S_RX_THRESHOLD)) && + vg_i2s_data->i2ssp_capture_stream) { + acp_writel(BIT(I2S_RX_THRESHOLD), + vg_i2s_data->acp5x_base + ACP_EXTERNAL_INTR_STAT); + snd_pcm_period_elapsed(vg_i2s_data->i2ssp_capture_stream); + irq_flag = 1; + } + + if (irq_flag) + return IRQ_HANDLED; + else + return IRQ_NONE; +} + static int acp5x_audio_probe(struct platform_device *pdev) { struct resource *res; struct i2s_dev_data *adata; + unsigned int irqflags; int status; if (!pdev->dev.platform_data) { @@ -47,6 +94,14 @@ static int acp5x_audio_probe(struct platform_device *pdev) resource_size(res)); if (!adata->acp5x_base) return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if (!res) { + dev_err(&pdev->dev, "IORESOURCE_IRQ FAILED\n"); + return -ENODEV; + } + + adata->i2s_irq = res->start; dev_set_drvdata(&pdev->dev, adata); status = devm_snd_soc_register_component(&pdev->dev, &acp5x_i2s_component, @@ -55,6 +110,12 @@ static int acp5x_audio_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Fail to register acp i2s component\n"); return -ENODEV; } + status = devm_request_irq(&pdev->dev, adata->i2s_irq, i2s_irq_handler, + irqflags, "ACP5x_I2S_IRQ", adata); + if (status) { + dev_err(&pdev->dev, "ACP5x I2S IRQ request failed\n"); + return -ENODEV; + } return 0; } diff --git a/sound/soc/amd/vangogh/acp5x.h b/sound/soc/amd/vangogh/acp5x.h index d2853738eb17..18df2b5a4283 100644 --- a/sound/soc/amd/vangogh/acp5x.h +++ b/sound/soc/amd/vangogh/acp5x.h @@ -31,9 +31,18 @@ #define ACP5x_HS_TDM_REG_END 0x1242824 #define I2S_MODE 0x00 #define ACP5x_I2S_MODE 0x00 +#define I2S_RX_THRESHOLD 27 +#define I2S_TX_THRESHOLD 28 +#define HS_TX_THRESHOLD 24 +#define HS_RX_THRESHOLD 23 struct i2s_dev_data { + unsigned int i2s_irq; void __iomem *acp5x_base; + struct snd_pcm_substream *play_stream; + struct snd_pcm_substream *capture_stream; + struct snd_pcm_substream *i2ssp_play_stream; + struct snd_pcm_substream *i2ssp_capture_stream; }; /* common header file uses exact offset rather than relative -- 2.25.1