From patchwork Thu Jan 13 09:28:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12712508 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 B0C18C433EF for ; Thu, 13 Jan 2022 09:31:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EE65E1EFA; Thu, 13 Jan 2022 10:30:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EE65E1EFA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642066272; bh=u+JD4TmrDhqGZRdfcw6d4b+A+pt6SXP67Jkf2l92Q08=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NocwYKCWpcy02ue8m25WEnz1R83geU2dgaVypJfi+0vgSQqKmdQ2aVBY1P5zb5Zs5 ugTmxfEECc6OT2ncMsxCqwU4t8iK4M3qpWacQ0QW7dI9BSR14yVTj1sl81cXrVztVS uE7c4qzXJ7xMFIDvJtg3MaC/GUfrwZeOySptv6A0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B5B85F8028D; Thu, 13 Jan 2022 10:30:06 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 72D2CF80507; Thu, 13 Jan 2022 10:30:05 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2041.outbound.protection.outlook.com [40.107.94.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 53EA0F8028D for ; Thu, 13 Jan 2022 10:29:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 53EA0F8028D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MJKHtYmI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OhB3GrNojaX6dM8hHXlyxt9zhMueHXHmOGSc1ljtOFpgVRz7V3jzYaXXJC5VV0EiApEOq7EAX6gJmj0as+YmetDLidloxmeLoLF52Qs1ZtS+MZYhNchtpWX2RtdxXt3okMoxo3DzKtsHPkkN0GmOwKFLjzRSxo3HzA6hPaWrmFLpl6B7EEK1jXxg1DI0SImgeVD1h2qr0P7+6kD3D2b+p2DJOVTmeT65eAvLT1uXNwBEmZr3wk3vybRLKRS8kO1po1xPH4KPk9EG73GRD7vj7FfyNIMepr1ajE3JXtnBmuoE2aO4/iZMJ1wCOMR7FoSQ+kHYuhwSxh23oCsMiWsu+A== 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=wLiAmrUjqXbine4/4G+vGheCp7mbn2rY0hch9rU2BXk=; b=ivXg/AKeV/CRG/i78tb1SG6k8QlE30YOVXwq8NxHcHbHgodWroatD9N6WZzVMdhXMHub3RqxSW4PZG5Dn5DIkFKdZAr8kp9nHe690OVNf+AhLrv1IplWAcEq9HvJgkqccDEqNX/LDRzYjUsTFwVtkSVmZHfspdCfVJ3NhFpv5iCN+XDFip0cSduFHGz7yvQanDYC/09UmDODpz0Tpu4norZiz68VdP/xnd4fRW371GT9waBfffAq73MA2x4ijZYb0atdaE61H+Gx8qqrqL8T59DdEAdZuBrbWkWW9upWIQg0005XG1DfInjwbXTAztidK122WgbPl8PBo5n7Edbdog== 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=wLiAmrUjqXbine4/4G+vGheCp7mbn2rY0hch9rU2BXk=; b=MJKHtYmIzp0Vd+Gt4cAYg4Q/jpPBcYSCfc4QllFlAwGcmR2KsFnhqT154K69PWXKktt7cVSiBg9wiEPQuIfLnuuLhtOUh/ls7O1pxBFSXtAUyCtrkQXzqFNRNMkJyJ3UKA100pWN74b83GLjeiS0NWNS623K7k31HJ9c5l8NNgY= Received: from MW2PR2101CA0009.namprd21.prod.outlook.com (2603:10b6:302:1::22) by MN2PR12MB4408.namprd12.prod.outlook.com (2603:10b6:208:26c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10; Thu, 13 Jan 2022 09:29:52 +0000 Received: from CO1NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:302:1:cafe::e) by MW2PR2101CA0009.outlook.office365.com (2603:10b6:302:1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.3 via Frontend Transport; Thu, 13 Jan 2022 09:29:52 +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; Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT012.mail.protection.outlook.com (10.13.175.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4888.9 via Frontend Transport; Thu, 13 Jan 2022 09:29:52 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 13 Jan 2022 03:29:48 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 13 Jan 2022 03:29:48 -0600 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 13 Jan 2022 03:29:44 -0600 From: Ajit Kumar Pandey To: , Subject: [PATCH 1/6] ASoC: amd: acp: Add generic support for PDM controller on ACP Date: Thu, 13 Jan 2022 14:58:37 +0530 Message-ID: <20220113092842.432101-2-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> References: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a50b816f-9558-449e-875c-08d9d677408b X-MS-TrafficTypeDiagnostic: MN2PR12MB4408:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LyFyWaX9aaLAP/YrqcCgwFVPdK8O3/+6An8/C2rit7AqqNC0+pdLnHA6FiGNRDWXspnceoYZOO1Dgvqwgl3v3P+QIIf+jZ21VPmX7acFrmC1JjzPWTKisEbyJUOGkkLcsY/edeBhFaZf7jgT0S6/3f5HmLPqZoKYolSdQJY2srLEAMu04g9cmT6GaeUR6WsvEE2QHtWgFYgsuJ1WXmx/4lsHB2WtGTamQvfkV1Vd45HkKELrYdBAIeCIVgAupPLwJ5lz94jYNQbYLTIdhtKMzb0B0fqUnO9itkIdfD7ir+zkr/FwMsteyEUtNFlrpPOpdOypAmEZV+ACUu7zorZWlrSlABT+IW+XQ5PLKxxOM0qW8EQXL36sNK568fAOImUfFYJD7QWCFugEG3RnUpfEIMAnaL+VFQnAauqzK8qcAdqBIdm2EMhOOIqSm1oWdmTJG7e5FuXyv0t8ZFulcrycpilrf8il6qrAHbn+uDQ1IdSskDuwp6sfH1vrkIMqZFwf7EncTs0k1wUdPQWv7h2PycKadMBwL61HH9qU5D9ihFr0bY5dJ5yXkGIVuUMBKQcT0GtMgfNfUWVnhVjdn+jSS36uXkARctkqxSavx5UPr5K3CqspsAMW9OP7c4+E5Pi0Q0WWGLKFcctGTpc3R7g93npBf6QBpwJDRtx0nUgJmWW/cCPdR3Xll36AR1xIAPP493XBtP8uLzBh6HSBm21isud0gl1QFCIgRUgKZ3EoxndadiO8PA2N+fS6n0W52gY3ecBGAOtHOXj6m7u5kgnR7na2ruTi2Taa0lmuc7cJRDn80C8CXEPM8SQ1gdCC10uT 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:(4636009)(46966006)(40470700002)(36840700001)(8936002)(1076003)(508600001)(70206006)(6666004)(4326008)(186003)(36860700001)(86362001)(2906002)(26005)(70586007)(8676002)(336012)(2616005)(7696005)(81166007)(356005)(47076005)(54906003)(5660300002)(40460700001)(110136005)(316002)(82310400004)(426003)(83380400001)(36756003)(41533002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 09:29:52.0411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a50b816f-9558-449e-875c-08d9d677408b 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: CO1NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4408 Cc: Sunil-kumar.Dommati@amd.com, Geert Uytterhoeven , Ajit Kumar Pandey , open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , V sujith kumar Reddy , Arnd Bergmann , Vijendar.Mukunda@amd.com, Alexander.Deucher@amd.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add driver module for PDM controller on ACP IP block. Expose dai ops to configure ACP_WOV_PDM_BLOCK registers on ACP. Such dai ops will be used by platform specific driver module to register dmic related dai with ASoC. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/Kconfig | 3 + sound/soc/amd/acp/Makefile | 2 + sound/soc/amd/acp/acp-pdm.c | 181 +++++++++++++++++++++++++++ sound/soc/amd/acp/amd.h | 9 +- sound/soc/amd/acp/chip_offset_byte.h | 20 +++ 5 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 sound/soc/amd/acp/acp-pdm.c diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index d5838df3064b..2e6d0259f2e9 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -15,6 +15,9 @@ config SND_SOC_AMD_ACP_COMMON if SND_SOC_AMD_ACP_COMMON +config SND_SOC_AMD_ACP_PDM + tristate + config SND_SOC_AMD_ACP_I2S tristate diff --git a/sound/soc/amd/acp/Makefile b/sound/soc/amd/acp/Makefile index 16c144c2965c..66cac95432f6 100644 --- a/sound/soc/amd/acp/Makefile +++ b/sound/soc/amd/acp/Makefile @@ -7,6 +7,7 @@ #common acp driver snd-acp-pcm-objs := acp-platform.o snd-acp-i2s-objs := acp-i2s.o +snd-acp-pdm-objs := acp-pdm.o #platform specific driver snd-acp-renoir-objs := acp-renoir.o @@ -18,6 +19,7 @@ snd-acp-sof-mach-objs := acp-sof-mach.o obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o +obj-$(CONFIG_SND_SOC_AMD_ACP_PDM) += snd-acp-pdm.o obj-$(CONFIG_SND_AMD_ASOC_RENOIR) += snd-acp-renoir.o diff --git a/sound/soc/amd/acp/acp-pdm.c b/sound/soc/amd/acp/acp-pdm.c new file mode 100644 index 000000000000..cb9bbd795eee --- /dev/null +++ b/sound/soc/amd/acp/acp-pdm.c @@ -0,0 +1,181 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// This file is provided under a dual BSD/GPLv2 license. When using or +// redistributing this file, you may do so under either license. +// +// Copyright(c) 2021 Advanced Micro Devices, Inc. +// +// Authors: Ajit Kumar Pandey +// Vijendar Mukunda +// + +/* + * Generic Hardware interface for ACP Audio PDM controller + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "amd.h" + +#define DRV_NAME "acp-pdm" + +#define PDM_DMA_STAT 0x10 +#define PDM_DMA_INTR_MASK 0x10000 +#define PDM_DEC_64 0x2 +#define PDM_CLK_FREQ_MASK 0x07 +#define PDM_MISC_CTRL_MASK 0x10 +#define PDM_ENABLE 0x01 +#define PDM_DISABLE 0x00 +#define DMA_EN_MASK 0x02 +#define DELAY_US 5 +#define PDM_TIMEOUT 1000 + +static int acp_dmic_dai_trigger(struct snd_pcm_substream *substream, + int cmd, struct snd_soc_dai *dai) +{ + struct acp_stream *stream = substream->runtime->private_data; + struct device *dev = dai->component->dev; + struct acp_dev_data *adata = dev_get_drvdata(dev); + u32 physical_addr, size_dmic, period_bytes; + unsigned int dma_enable; + int ret = 0; + + period_bytes = frames_to_bytes(substream->runtime, + substream->runtime->period_size); + size_dmic = frames_to_bytes(substream->runtime, + substream->runtime->buffer_size); + + physical_addr = stream->reg_offset + MEM_WINDOW_START; + + /* Init DMIC Ring buffer */ + writel(physical_addr, adata->acp_base + ACP_WOV_RX_RINGBUFADDR); + writel(size_dmic, adata->acp_base + ACP_WOV_RX_RINGBUFSIZE); + writel(period_bytes, adata->acp_base + ACP_WOV_RX_INTR_WATERMARK_SIZE); + writel(0x01, adata->acp_base + ACPAXI2AXI_ATU_CTRL); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + dma_enable = readl(adata->acp_base + ACP_WOV_PDM_DMA_ENABLE); + if (!(dma_enable & DMA_EN_MASK)) { + writel(PDM_ENABLE, adata->acp_base + ACP_WOV_PDM_ENABLE); + writel(PDM_ENABLE, adata->acp_base + ACP_WOV_PDM_DMA_ENABLE); + } + + ret = readl_poll_timeout_atomic(adata->acp_base + ACP_WOV_PDM_DMA_ENABLE, + dma_enable, (dma_enable & DMA_EN_MASK), + DELAY_US, PDM_TIMEOUT); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + dma_enable = readl(adata->acp_base + ACP_WOV_PDM_DMA_ENABLE); + if ((dma_enable & DMA_EN_MASK)) { + writel(PDM_DISABLE, adata->acp_base + ACP_WOV_PDM_ENABLE); + writel(PDM_DISABLE, adata->acp_base + ACP_WOV_PDM_DMA_ENABLE); + + } + + ret = readl_poll_timeout_atomic(adata->acp_base + ACP_WOV_PDM_DMA_ENABLE, + dma_enable, !(dma_enable & DMA_EN_MASK), + DELAY_US, PDM_TIMEOUT); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +static int acp_dmic_hwparams(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hwparams, struct snd_soc_dai *dai) +{ + struct device *dev = dai->component->dev; + struct acp_dev_data *adata = dev_get_drvdata(dev); + unsigned int dmic_ctrl, channels, ch_mask; + + /* Enable default DMIC clk */ + writel(PDM_CLK_FREQ_MASK, adata->acp_base + ACP_WOV_CLK_CTRL); + dmic_ctrl = readl(adata->acp_base + ACP_WOV_MISC_CTRL); + dmic_ctrl |= PDM_MISC_CTRL_MASK; + writel(dmic_ctrl, adata->acp_base + ACP_WOV_MISC_CTRL); + + channels = params_channels(hwparams); + switch (channels) { + case 2: + ch_mask = 0; + break; + case 4: + ch_mask = 1; + break; + case 6: + ch_mask = 2; + break; + default: + dev_err(dev, "Invalid channels %d\n", channels); + return -EINVAL; + } + + if (params_format(hwparams) != SNDRV_PCM_FORMAT_S32_LE) { + dev_err(dai->dev, "Invalid format:%d\n", params_format(hwparams)); + return -EINVAL; + } + + writel(ch_mask, adata->acp_base + ACP_WOV_PDM_NO_OF_CHANNELS); + writel(PDM_DEC_64, adata->acp_base + ACP_WOV_PDM_DECIMATION_FACTOR); + + return 0; +} + +static int acp_dmic_dai_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct acp_stream *stream = substream->runtime->private_data; + struct device *dev = dai->component->dev; + struct acp_dev_data *adata = dev_get_drvdata(dev); + u32 ext_int_ctrl; + + stream->dai_id = DMIC_INSTANCE; + stream->irq_bit = BIT(PDM_DMA_STAT); + stream->pte_offset = ACP_SRAM_PDM_PTE_OFFSET; + + /* Enable DMIC Interrupts */ + ext_int_ctrl = readl(adata->acp_base + ACP_EXTERNAL_INTR_CNTL); + ext_int_ctrl |= PDM_DMA_INTR_MASK; + writel(ext_int_ctrl, adata->acp_base + ACP_EXTERNAL_INTR_CNTL); + + return 0; +} + +static void acp_dmic_dai_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct device *dev = dai->component->dev; + struct acp_dev_data *adata = dev_get_drvdata(dev); + u32 ext_int_ctrl; + + /* Disable DMIC interrrupts */ + ext_int_ctrl = readl(adata->acp_base + ACP_EXTERNAL_INTR_CNTL); + ext_int_ctrl |= ~PDM_DMA_INTR_MASK; + writel(ext_int_ctrl, adata->acp_base + ACP_EXTERNAL_INTR_CNTL); +} + +const struct snd_soc_dai_ops acp_dmic_dai_ops = { + .hw_params = acp_dmic_hwparams, + .trigger = acp_dmic_dai_trigger, + .startup = acp_dmic_dai_startup, + .shutdown = acp_dmic_dai_shutdown, +}; +EXPORT_SYMBOL_NS_GPL(acp_dmic_dai_ops, SND_SOC_ACP_COMMON); + +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:"DRV_NAME); diff --git a/sound/soc/amd/acp/amd.h b/sound/soc/amd/acp/amd.h index 8eee3d34774b..567355209a5c 100644 --- a/sound/soc/amd/acp/amd.h +++ b/sound/soc/amd/acp/amd.h @@ -17,8 +17,9 @@ #define I2S_SP_INSTANCE 0x00 #define I2S_BT_INSTANCE 0x01 +#define DMIC_INSTANCE 0x02 -#define MEM_WINDOW_START 0x4000000 +#define MEM_WINDOW_START 0x4080000 #define ACP_I2S_REG_START 0x1242400 #define ACP_I2S_REG_END 0x1242810 @@ -38,6 +39,7 @@ #define ACP_SRAM_SP_CP_PTE_OFFSET 0x100 #define ACP_SRAM_BT_PB_PTE_OFFSET 0x200 #define ACP_SRAM_BT_CP_PTE_OFFSET 0x300 +#define ACP_SRAM_PDM_PTE_OFFSET 0x400 #define PAGE_SIZE_4K_ENABLE 0x2 #define I2S_SP_TX_MEM_WINDOW_START 0x4000000 @@ -96,6 +98,7 @@ struct acp_dev_data { }; extern const struct snd_soc_dai_ops asoc_acp_cpu_dai_ops; +extern const struct snd_soc_dai_ops acp_dmic_dai_ops; int asoc_acp_i2s_probe(struct snd_soc_dai *dai); int acp_platform_register(struct device *dev); @@ -131,6 +134,10 @@ static inline u64 acp_get_byte_count(struct acp_dev_data *adata, int dai_id, int high = readl(adata->acp_base + ACP_I2S_RX_LINEARPOSITIONCNTR_HIGH); low = readl(adata->acp_base + ACP_I2S_RX_LINEARPOSITIONCNTR_LOW); break; + case DMIC_INSTANCE: + high = readl(adata->acp_base + ACP_WOV_RX_LINEARPOSITIONCNTR_HIGH); + low = readl(adata->acp_base + ACP_WOV_RX_LINEARPOSITIONCNTR_LOW); + break; default: dev_err(adata->dev, "Invalid dai id %x\n", dai_id); return -EINVAL; diff --git a/sound/soc/amd/acp/chip_offset_byte.h b/sound/soc/amd/acp/chip_offset_byte.h index c7f77e975dc7..e38589a142e9 100644 --- a/sound/soc/amd/acp/chip_offset_byte.h +++ b/sound/soc/amd/acp/chip_offset_byte.h @@ -73,4 +73,24 @@ #define ACP_BTTDM_ITER 0x280C #define ACP_BTTDM_TXFRMT 0x2810 +/* Registers from ACP_WOV_PDM block */ + +#define ACP_WOV_PDM_ENABLE 0x2C04 +#define ACP_WOV_PDM_DMA_ENABLE 0x2C08 +#define ACP_WOV_RX_RINGBUFADDR 0x2C0C +#define ACP_WOV_RX_RINGBUFSIZE 0x2C10 +#define ACP_WOV_RX_LINKPOSITIONCNTR 0x2C14 +#define ACP_WOV_RX_LINEARPOSITIONCNTR_HIGH 0x2C18 +#define ACP_WOV_RX_LINEARPOSITIONCNTR_LOW 0x2C1C +#define ACP_WOV_RX_INTR_WATERMARK_SIZE 0x2C20 +#define ACP_WOV_PDM_FIFO_FLUSH 0x2C24 +#define ACP_WOV_PDM_NO_OF_CHANNELS 0x2C28 +#define ACP_WOV_PDM_DECIMATION_FACTOR 0x2C2C +#define ACP_WOV_PDM_VAD_CTRL 0x2C30 +#define ACP_WOV_BUFFER_STATUS 0x2C58 +#define ACP_WOV_MISC_CTRL 0x2C5C +#define ACP_WOV_CLK_CTRL 0x2C60 +#define ACP_PDM_VAD_DYNAMIC_CLK_GATING_EN 0x2C64 +#define ACP_WOV_ERROR_STATUS_REGISTER 0x2C68 + #endif From patchwork Thu Jan 13 09:28:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12712509 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 425F4C433EF for ; Thu, 13 Jan 2022 09:31:24 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 74C561F03; Thu, 13 Jan 2022 10:30:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 74C561F03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642066282; bh=33h2PEdJ01sNA0ETJVSY3RAO1uf2hfF7MSaDGWq7ZMc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=T06jAcds252K8WHxdcMiznBsCrAADAklVl7IYT8lZ20Mcyn2Fqla1U0YQW+5o6VrI uLtpdZgkDrPN/9geAZXhfngnPfl7N5qlRWcUqip57/RuPOxh9lYccFXUubbTenizwE gRUu6QUPVDeAx2DL6lZQxMwVnKHS8VqOrHIqEJUI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 93E16F80511; Thu, 13 Jan 2022 10:30:12 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 177BCF80515; Thu, 13 Jan 2022 10:30:09 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2075.outbound.protection.outlook.com [40.107.95.75]) (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 A886AF804FE for ; Thu, 13 Jan 2022 10:30:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A886AF804FE Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="yAHJfNUP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UKPZDaHWLbKwQ3BSHvDRVeMXeKF+VqsQu+D9JgIu/2v+mG0EXuLmmbdF+/l+8j145RSruIcsmt2bA1AP5FXVNdyTvCYzymoHjoKqCwI+p/aF8Jby95TNZaV9JqHw8n9Rx8ynLhoZAiGaD4SDASuGrHRvgSvf/RpkRtjUlewjJtYC///50fd/HEbO/y0Op2irUbRdp9XCrwyPnhRU6XXtnUi5Fnj2Kn8JFhdOtXUn9mTxKoVZh2FEnON192nBYbFv+6gk6bTvTNAPY5zXQEBVGLWL3qd6PAG8xk+A5B85awBK1mE3ig8BSbwEupx7xyXv4LzCdEkjyFq4BIb8NIZhkg== 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=2m1RzSnqEB7lEjWdke8awBRfdhrc7YeH/cC/s43plRo=; b=QwX9jhRvrdfw8WJQn1Fey0T6y+Bbv6yNIyu5k2+mjcIMghdllvhQje1GJWBKVIkv51Pf/HGgqAE2Qvlw8KXUFdNkYOOTF4kTjhjH5A78l7o/ZmoHnygNhaawApBeQ7LzJJubgphtVy5XPUz0+SV7f41z3glxX/UEyaAZ7iLDVsX+N9VP9wBYPYcr9QZa6Lk2MXQwhtrihLENgd++xxhZXn2Kc570+z3//536W2Ak6oBc3Xr9RYdpF6lIlsuhwrn6cDsgNwQRiWVBH+IrwExQ3DzssXY8IZNCTQeAmsF2/sR0M2rjbqEY0wm//eVZloV1kIJrBw+Z5ZzHU3tjQd9XtQ== 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=2m1RzSnqEB7lEjWdke8awBRfdhrc7YeH/cC/s43plRo=; b=yAHJfNUP0LCQEVNZdh56EUTdJB4YhwKQESToUjjTjDqus8LrurLMIli5zXf7BUOp81TagWSo3GXVAGS+QkE2KUTAkPKTAIDI1DKZaNvfkrDtlJucLUB9i7k1ebvvQLnNsXotPWRs92w7Xkt68IXIA74MZoi/jvtH6+akOO4fSvw= Received: from MWHPR14CA0061.namprd14.prod.outlook.com (2603:10b6:300:81::23) by MN2PR12MB3229.namprd12.prod.outlook.com (2603:10b6:208:102::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10; Thu, 13 Jan 2022 09:30:01 +0000 Received: from CO1NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:300:81:cafe::df) by MWHPR14CA0061.outlook.office365.com (2603:10b6:300:81::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10 via Frontend Transport; Thu, 13 Jan 2022 09:30: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; Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT016.mail.protection.outlook.com (10.13.175.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4888.9 via Frontend Transport; Thu, 13 Jan 2022 09:30:01 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 13 Jan 2022 03:29:59 -0600 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 13 Jan 2022 03:29:56 -0600 From: Ajit Kumar Pandey To: , Subject: [PATCH 2/6] ASoC: amd: acp: Add PDM controller based dmic dai for Renoir Date: Thu, 13 Jan 2022 14:58:38 +0530 Message-ID: <20220113092842.432101-3-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> References: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2936710b-5673-4b4e-f42e-08d9d67745ec X-MS-TrafficTypeDiagnostic: MN2PR12MB3229:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:901; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I4dn0VoQAqMkAaKs7CJ8UJCVVZQlomDQcqbK3xKPbvsrsYyqgv0QatR5o3QAVI9XnTtasDv4AKm2QW8nft8RmPxH4u0Eo9zjZHe3GV1Jf8Qlga7C6mMTVpRGbx9OCj/U/e069733aRqVLgeFm/N42+tfoLCVAPerpLbcmSM4wbrpgsZWulDGaNjIJpe2Et5vPSe6JnvH+k9+uIAzBDcxVFt8e4j3CiLRHbkVmbDeGpVUJAi0vAhmRorHP6Vk10uacvgdfKE7t1W/DHLclsZFVXi3pNoRhsnYcv2UWwmTBY0tKe3sbeWjbLDw41HfxR1jSM7VrBoBeCR5e2UQJoYCDpZ0+dthQjHhJA0o6Kt0lg3eA5yILxVfi/sj/n2Un6vufc7mo0/gCvoV5WhIlvvO6ZJxskLhBdJ3WNleju7PzS6XSK9UlLq7jQ0kgBUZUl4f5C/46AjB8PSnv8ukh/6JC13XImiCFwT6sj3HYQYd574d3wiNfVm++FQ+GcGBpU/Nqq84JA9Qwb9rIOayv63KoSSQX/NxSgyOCj6e8G0IVTRMuYPiLP1fLqriN0VC4yUccNNlbWmJL1T8DW7n9u/eZodPfGw/Crga4tRzykIY4J2hG3TTbD8MIuFTRS6aSefN685HDWOiXR5MHHQgXUpoAusvs9RRAfDYv52/VJO8RJHnaOz4AMoKQsp9CK1V/pwL/4BEs3hJycZR6XSbvUE145dRwqUxN5JOJGN5UMJxy3Bve4f7AyhHPy0XSnz1D6f3hfg9WlU+Wj+6PQCNQTF210ulByhV2eQNPWdHNa1emRA= 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:(4636009)(36840700001)(40470700002)(46966006)(83380400001)(36756003)(70586007)(86362001)(70206006)(110136005)(316002)(5660300002)(356005)(186003)(26005)(81166007)(54906003)(8936002)(47076005)(7696005)(6666004)(36860700001)(508600001)(2906002)(1076003)(8676002)(40460700001)(4326008)(336012)(2616005)(426003)(82310400004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 09:30:01.0682 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2936710b-5673-4b4e-f42e-08d9d67745ec 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: CO1NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3229 Cc: Sunil-kumar.Dommati@amd.com, Geert Uytterhoeven , Ajit Kumar Pandey , open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , V sujith kumar Reddy , Arnd Bergmann , Vijendar.Mukunda@amd.com, Alexander.Deucher@amd.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Renoir ACP IP has a PDM controller block. Add DMIC dai instance in dai_driver struct to enable dmic capture support on Renoir platform. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/Kconfig | 1 + sound/soc/amd/acp/acp-renoir.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index 2e6d0259f2e9..f4ca7843391b 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -29,6 +29,7 @@ config SND_AMD_ASOC_RENOIR tristate "AMD ACP ASOC Renoir Support" select SND_SOC_AMD_ACP_PCM select SND_SOC_AMD_ACP_I2S + select SND_SOC_AMD_ACP_PDM depends on X86 && PCI help This option enables Renoir I2S support on AMD platform. diff --git a/sound/soc/amd/acp/acp-renoir.c b/sound/soc/amd/acp/acp-renoir.c index 9b321a055b52..770a57a0677b 100644 --- a/sound/soc/amd/acp/acp-renoir.c +++ b/sound/soc/amd/acp/acp-renoir.c @@ -97,6 +97,19 @@ static struct snd_soc_dai_driver acp_renoir_dai[] = { .ops = &asoc_acp_cpu_dai_ops, .probe = &asoc_acp_i2s_probe, }, +{ + .name = "acp-pdm-dmic", + .id = DMIC_INSTANCE, + .capture = { + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .ops = &acp_dmic_dai_ops, +}, }; static int renoir_audio_probe(struct platform_device *pdev) From patchwork Thu Jan 13 09:28:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12712510 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 16223C433EF for ; Thu, 13 Jan 2022 09:31:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 346791F0A; Thu, 13 Jan 2022 10:30:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 346791F0A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642066289; bh=BjOYv+Rqt9eMa/dcoR7yP5kbBpH4EGxeTeVQu+a4yxE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LBDfyZacCVA63OuOp27/JDAYKc0ddAY1bohlQiF9gYwj3XmU4PANp6N1MQq+JM4cV kreqNXg7pVmadMmku+UQa75rbLlcYltJ1wa9RLPhOHfLicZukkQ/36xjxJhiXS9Ino EpY4EsCYQauIhc7kwp71Dv1j1gUM8PVtiuS7+6Ns= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CE46EF80088; Thu, 13 Jan 2022 10:30:38 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 37290F80088; Thu, 13 Jan 2022 10:30:35 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2059.outbound.protection.outlook.com [40.107.236.59]) (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 67942F80088 for ; Thu, 13 Jan 2022 10:30:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 67942F80088 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qldJN/uG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oR/NAMOV4vo+4It292vdj5vJ5IOMIycQ+8+uwkwoZvK63JWIGzSumK2O4axYtvGpB33JUgat9yIauTpvGs5Ni+lHG0IU8MLECwwMHWUF0zWJ1P0iNN+b1shygyM7pelgMSI0s846qdxE4LYksm8hUyfMKRbWMzPl4SLZcXPPlhcHoqwNWMD29VLYVK+GeJgc0MG1LTmClrx9LVQdeYCw2fP8b+tt6oo/97dxLlrGAbQX9jjbEumvakDdn03GKMatd/vdDmBEbT4WPdW5BDK/T20eIREVBjITqaFvN/q7rmE+8BQsXJviOp1/MjwH2s/FQQDgj1UJDiOHhgKCQPY36A== 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=i/JjFExpQyHhFm0Ews9rfQE5ACBs6QpJrhSdGxh1FE4=; b=BFtY736FKZSDq35vE7uPEYoRmvnsPKaKG1BBESeUwvJvun+M5su9TZUZFj6YETImax9W404gUUBEzH8kTgnSmV+Q7XbDfeIJ+/s+sudghbR9cI6LlKfAgzS/pZP36jNjfTJxw2rfA8CKP5MPUBI/R0pTun6T1hAuLRR2vJl2ml1psb0+BPIKrJuel6Co+ioOkcxyJKhcZqGtGZ9XyL6bXS3Ez74rIPJhrI7uqu0FBMxkShPu7Y0IVidE6Or/XnywExOYCe7k2aUwdH/bPCc/QX9IiTidAcYbHWi1ej2jRHkQVeyur0h20yVVXOKpqLX41S4x52Aufl6HUj4OAR+2OQ== 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=i/JjFExpQyHhFm0Ews9rfQE5ACBs6QpJrhSdGxh1FE4=; b=qldJN/uGu7qvMhqr3sVW/wsWVn5l7LujdKZ0rSWkXRhherWRdZy9n/ANoeEYiT3m1GpR/F9au4K0NoXvjRWqz3X0+jJsuyPZMop/U5eqyNTl42UOEaouYzlVPczURsQzrH8yK4dlREh9R133Gy5LWO6Bk8npWvR3r6VXuJZ5bi4= Received: from MW4P221CA0011.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::16) by BN9PR12MB5290.namprd12.prod.outlook.com (2603:10b6:408:103::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Thu, 13 Jan 2022 09:30:24 +0000 Received: from CO1NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::77) by MW4P221CA0011.outlook.office365.com (2603:10b6:303:8b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10 via Frontend Transport; Thu, 13 Jan 2022 09:30:24 +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; Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT003.mail.protection.outlook.com (10.13.175.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4888.9 via Frontend Transport; Thu, 13 Jan 2022 09:30:24 +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.17; Thu, 13 Jan 2022 03:30:20 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 13 Jan 2022 03:30:20 -0600 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 13 Jan 2022 03:30:16 -0600 From: Ajit Kumar Pandey To: , Subject: [PATCH 3/6] ASoC: amd: acp: Add generic PCI driver module for ACP device Date: Thu, 13 Jan 2022 14:58:39 +0530 Message-ID: <20220113092842.432101-4-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> References: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: acbc0377-4323-4e82-8763-08d9d67753b0 X-MS-TrafficTypeDiagnostic: BN9PR12MB5290:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:227; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YmHyfMuu7/Zz2unnREekez9bw7JdvXiDEidmcyyTjiqzh0hv8gXDE6AVjUYBdlxvem6Nm9B1vDAqmz0CIUE191iiVUiyxSqv8ThID4Sel/qLTMrAqiHmZXkllpX+mt1EDIdBQMrw4+8m9Fi/+0GLy+nwyp3WbQ/174B9RL8EIshBHiqMe2Djh82ECrSSjYz2crzAAzT1b31XjPOymCkVIT9U+jPO4p0EIkIcyUIPWz+obkl0qEHjTHR9i082Ysje+nCyzXdyjh1Y7pDs1/JDTWDfTG4Q8BYFQ0IWhpwis/1OHPmxcgzZXb2K0HMQzQfG2JrVA1oJ9OEXMWbLOJMFSB/zfeXv8rfMCJKKWDkNPq4vRP/M9TOLuy1s7i9rECApkAXWOIf3uDUNf4n9qZPnZWlz7aFbzrapIiLxsMAaSWT5p1cMg0ekhhIf57+0wA6jBqiyABvpRRkZgNE4RSYcbT4z1KSTEEc3xI7A5PdzX0lKRstViKCGNSInsoWtCTtBW7t9fE0Dw95DYOr9i5XCqohhqHYqniIVo6XnR2ud4LbRjxbl3QJBu4Bn8AIGr0dmdsAqgt33FZGKbsp5KIqsN9qnEWjJhqIiG0OkBWfQhz+vm0eSciAi2FTFjvIWp9qv/piD7cx05bmp576Mzt7RLPIrf9i5E+0DFu6DU/pinj5TnvPtv5vSNKVrMZRslqnJT1mPpfd9iXQuvr5+OXUhlhL7CPNse9IgK2cQoE2tLIyg6V+dkVpjtKBkexjbzWJ+oei0fWs5nNaRMg5nXnrWMwsV1D+3ZgLEj6GO4lbWb55iwzRtAhLl2nT4YT039mB8uSs3ftfJ8pDKK5ritUMlWQ== 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:(4636009)(36840700001)(40470700002)(46966006)(316002)(356005)(83380400001)(2906002)(508600001)(6666004)(2616005)(81166007)(40460700001)(86362001)(7696005)(336012)(5660300002)(26005)(82310400004)(110136005)(8676002)(70206006)(1076003)(426003)(8936002)(4326008)(70586007)(47076005)(54906003)(7416002)(36756003)(186003)(36860700001)(41533002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 09:30:24.1603 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: acbc0377-4323-4e82-8763-08d9d67753b0 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: CO1NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5290 Cc: Sunil-kumar.Dommati@amd.com, Geert Uytterhoeven , Ajit Kumar Pandey , open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , V sujith kumar Reddy , Arnd Bergmann , Ranjani Sridharan , Vijendar.Mukunda@amd.com, Alexander.Deucher@amd.com, Daniel Baluta , Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Audio Co-processor or ACP IP block on AMD's SOC is connected via PCI bus interface, hence needs to be register as a PCI device. We have same PCI device ID across multiple SOC's but with different revision id for PCI hw. Add a generic PCI driver module for ACP that registers ACP as a PCI device and also register a platform device based on pci revision id. Any SOC's specific configuration for ACP block will be done in platform driver probe. We have added an initial support for ACP revision id 3 or ACP3X device. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/Kconfig | 6 ++ sound/soc/amd/acp/Makefile | 2 + sound/soc/amd/acp/acp-pci.c | 158 ++++++++++++++++++++++++++++++++++++ sound/soc/amd/acp/amd.h | 14 ++++ sound/soc/amd/mach-config.h | 1 + 5 files changed, 181 insertions(+) create mode 100644 sound/soc/amd/acp/acp-pci.c diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index f4ca7843391b..626e4a5cb06a 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -25,6 +25,12 @@ config SND_SOC_AMD_ACP_PCM tristate select SND_SOC_ACPI if ACPI +config SND_SOC_AMD_ACP_PCI + tristate "AMD ACP PCI Driver Support" + depends on X86 && PCI + help + This options enables generic PCI driver for ACP device. + config SND_AMD_ASOC_RENOIR tristate "AMD ACP ASOC Renoir Support" select SND_SOC_AMD_ACP_PCM diff --git a/sound/soc/amd/acp/Makefile b/sound/soc/amd/acp/Makefile index 66cac95432f6..657ddfadf0bb 100644 --- a/sound/soc/amd/acp/Makefile +++ b/sound/soc/amd/acp/Makefile @@ -8,6 +8,7 @@ snd-acp-pcm-objs := acp-platform.o snd-acp-i2s-objs := acp-i2s.o snd-acp-pdm-objs := acp-pdm.o +snd-acp-pci-objs := acp-pci.o #platform specific driver snd-acp-renoir-objs := acp-renoir.o @@ -20,6 +21,7 @@ snd-acp-sof-mach-objs := acp-sof-mach.o obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o obj-$(CONFIG_SND_SOC_AMD_ACP_PDM) += snd-acp-pdm.o +obj-$(CONFIG_SND_SOC_AMD_ACP_PCI) += snd-acp-pci.o obj-$(CONFIG_SND_AMD_ASOC_RENOIR) += snd-acp-renoir.o diff --git a/sound/soc/amd/acp/acp-pci.c b/sound/soc/amd/acp/acp-pci.c new file mode 100644 index 000000000000..7802c4ed5155 --- /dev/null +++ b/sound/soc/amd/acp/acp-pci.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// This file is provided under a dual BSD/GPLv2 license. When using or +// redistributing this file, you may do so under either license. +// +// Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// +// Authors: Ajit Kumar Pandey + +/* + * Generic PCI interface for ACP device + */ + +#include +#include +#include +#include +#include + +#include "amd.h" +#include "../mach-config.h" + +#define DRV_NAME "acp_pci" + +#define ACP3x_REG_START 0x1240000 +#define ACP3x_REG_END 0x125C000 + +static struct platform_device *dmic_dev; +static struct platform_device *pdev; + +static const struct resource acp3x_res[] = { + { + .start = 0, + .end = ACP3x_REG_END - ACP3x_REG_START, + .name = "acp_mem", + .flags = IORESOURCE_MEM, + }, + { + .start = 0, + .end = 0, + .name = "acp_dai_irq", + .flags = IORESOURCE_IRQ, + }, +}; + +static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) +{ + struct platform_device_info pdevinfo; + struct device *dev = &pci->dev; + const struct resource *res_acp; + struct acp_chip_info *chip; + struct resource *res; + unsigned int flag, addr, num_res, i; + int ret; + + flag = snd_amd_acp_find_config(pci); + if (flag != FLAG_AMD_LEGACY) + return -ENODEV; + + chip = devm_kzalloc(&pci->dev, sizeof(*chip), GFP_KERNEL); + if (!chip) + return -ENOMEM; + + if (pci_enable_device(pci)) { + dev_err(&pci->dev, "pci_enable_device failed\n"); + return -ENODEV; + } + + ret = pci_request_regions(pci, "AMD ACP3x audio"); + if (ret < 0) { + dev_err(&pci->dev, "pci_request_regions failed\n"); + return -ENOMEM; + } + + pci_set_master(pci); + + switch (pci->revision) { + case 0x01: + res_acp = acp3x_res; + num_res = ARRAY_SIZE(acp3x_res); + chip->name = "acp_asoc_renoir"; + chip->acp_rev = ACP3X_DEV; + break; + default: + dev_err(dev, "Unsupported device revision:0x%x\n", pci->revision); + return -EINVAL; + } + + dmic_dev = platform_device_register_data(dev, "dmic-codec", PLATFORM_DEVID_NONE, NULL, 0); + if (IS_ERR(dmic_dev)) { + dev_err(dev, "failed to create DMIC device\n"); + return PTR_ERR(dmic_dev); + } + + addr = pci_resource_start(pci, 0); + chip->base = devm_ioremap(&pci->dev, addr, pci_resource_len(pci, 0)); + + res = devm_kzalloc(&pci->dev, sizeof(struct resource) * num_res, GFP_KERNEL); + if (!res) + return -ENOMEM; + + for (i = 0; i < num_res; i++, res_acp++) { + res[i].name = res_acp->name; + res[i].flags = res_acp->flags; + res[i].start = addr + res_acp->start; + res[i].end = addr + res_acp->end; + if (res_acp->flags == IORESOURCE_IRQ) { + res[i].start = pci->irq; + res[i].end = res[i].start; + } + } + + memset(&pdevinfo, 0, sizeof(pdevinfo)); + + pdevinfo.name = chip->name; + pdevinfo.id = 0; + pdevinfo.parent = &pci->dev; + pdevinfo.num_res = num_res; + pdevinfo.res = &res[0]; + pdevinfo.data = chip; + pdevinfo.size_data = sizeof(*chip); + + pdev = platform_device_register_full(&pdevinfo); + if (IS_ERR(pdev)) { + dev_err(&pci->dev, "cannot register %s device\n", pdevinfo.name); + platform_device_unregister(dmic_dev); + ret = PTR_ERR(pdev); + } + + return ret; +}; + +static void acp_pci_remove(struct pci_dev *pci) +{ + if (dmic_dev) + platform_device_unregister(dmic_dev); + if (pdev) + platform_device_unregister(pdev); +} + +/* PCI IDs */ +static const struct pci_device_id acp_pci_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_PCI_DEV_ID)}, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, acp_pci_ids); + +/* pci_driver definition */ +static struct pci_driver snd_amd_acp_pci_driver = { + .name = KBUILD_MODNAME, + .id_table = acp_pci_ids, + .probe = acp_pci_probe, + .remove = acp_pci_remove, +}; +module_pci_driver(snd_amd_acp_pci_driver); + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_ALIAS(DRV_NAME); diff --git a/sound/soc/amd/acp/amd.h b/sound/soc/amd/acp/amd.h index 567355209a5c..8fd38bf4d3bd 100644 --- a/sound/soc/amd/acp/amd.h +++ b/sound/soc/amd/acp/amd.h @@ -12,9 +12,14 @@ #define __AMD_ACP_H #include +#include #include +#include + #include "chip_offset_byte.h" +#define ACP3X_DEV 3 + #define I2S_SP_INSTANCE 0x00 #define I2S_BT_INSTANCE 0x01 #define DMIC_INSTANCE 0x02 @@ -70,6 +75,12 @@ #define ACP_MAX_STREAM 6 +struct acp_chip_info { + char *name; /* Platform name */ + unsigned int acp_rev; /* ACP Revision id */ + void __iomem *base; /* ACP memory PCI base */ +}; + struct acp_stream { struct snd_pcm_substream *substream; int irq_bit; @@ -106,6 +117,9 @@ int acp_platform_unregister(struct device *dev); int acp_machine_select(struct acp_dev_data *adata); +/* Machine configuration */ +int snd_amd_acp_find_config(struct pci_dev *pci); + static inline u64 acp_get_byte_count(struct acp_dev_data *adata, int dai_id, int direction) { u64 byte_count, low = 0, high = 0; diff --git a/sound/soc/amd/mach-config.h b/sound/soc/amd/mach-config.h index feb3756d9ac4..0a54567a2841 100644 --- a/sound/soc/amd/mach-config.h +++ b/sound/soc/amd/mach-config.h @@ -14,6 +14,7 @@ #define FLAG_AMD_SOF BIT(1) #define FLAG_AMD_SOF_ONLY_DMIC BIT(2) +#define FLAG_AMD_LEGACY BIT(3) #define ACP_PCI_DEV_ID 0x15E2 From patchwork Thu Jan 13 09:28:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12712511 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 96183C433F5 for ; Thu, 13 Jan 2022 09:32:05 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DB8CB1EF8; Thu, 13 Jan 2022 10:31:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DB8CB1EF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642066323; bh=8Nmw3VHzRpbYBwIkX8RCTSa6Yb17j1mEMUD9A9+2mmA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=L8JcoTkHEGkUrhh/ZRqFat/eODrUu8aCoSD+5QTMryfvSvmb3Mb7JT1JzPDSPjpI3 xvYU8ZXzrdNNm2waFLBLCwlyYQhqrtz6Z++aP4r4VIUv+qba56j+tXoL0jlqiSjdh9 35f9kTOuXyEVu/8U1dqUlUlMqqdoT2wtPhXa+cjs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 989A5F80518; Thu, 13 Jan 2022 10:30:43 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 28A21F80519; Thu, 13 Jan 2022 10:30:43 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061.outbound.protection.outlook.com [40.107.237.61]) (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 EA233F804FB for ; Thu, 13 Jan 2022 10:30:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EA233F804FB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Df7CIQU2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nA+mqBwMnngODCA+ilEWZwD0AVzPYX8r3LCbGjv1mZr/eHgN9z3d/WoUGbc9qComsZO+VfP+oyIqvUC8pINzOcX8tvdpRg8rab50/acKqnLxvrwa6GeYXGRyLjFVT8s2JMAfj6XXCKhrBvAI1NCJ/ud5Nrsk1HNQuu+DzY6UsqCTQ0LDtaZDUQ5ZyHY/VNB8XwTjFqKedWFqzYQCmbbJ+sx3bP7wMuNOyskrxPK/Q4nXgB5hETPbxOjAIY1S4vus6u1G+MH8I8XtHi79KxRz6fEodUxYjTScPpwIEFp8oK7HKZebGKZF1qzZMnONMVs7732zYdkDCjEHlyW3z78UpA== 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=7QsjnhVQQdJ6icA/lVkJK190jwIitICsAqVkpGc5wYU=; b=RfbBHJQoOnMgF5zE6l+9bFfBiWzNfQP8XvygTUq+lo06WWWc74M1CgIiRtjLYIlg47OhkFzwivCYnsVpqBsI6gz6fH8egphzEqEhEDz3sGxUpxoXuYL1U+SlipmCJo6SvpqBMFTOkZm+ycqlkOGKfmPsZDrio+q+9W1X+iyACwDwQ8XHcn4yzHhPg556bIGsnOOy18XODQ5hi14ulGU1qYENBqBDPpFe77tWNC/8jECErZLzU5yRRHXCj0UOWSNvnMO1FT5BoU3OHjg+dUi4u24zj7hePboXX7LSICIp7CMglbc9YHC4xH1ycjCkYuzkv77phyjCnUJ5sS70M9v3EQ== 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=7QsjnhVQQdJ6icA/lVkJK190jwIitICsAqVkpGc5wYU=; b=Df7CIQU2bFMPfZ233/y2I6QVoTqMCYJoFJoREaetQomumSoyVb6yJB9u778NR8RXwcyGcR9YCjMW4b236PH5enkyhdPwQqApT0B0V/MfeLzKzyyAIPKFKpsw+vl7/RH0oc+Dm6Lx4aG/JU2Ox2BvSa3qqJmHtJY5DpPvLE8msHw= Received: from BN6PR16CA0045.namprd16.prod.outlook.com (2603:10b6:405:14::31) by BN6PR12MB1649.namprd12.prod.outlook.com (2603:10b6:405:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Thu, 13 Jan 2022 09:30:33 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:405:14:cafe::81) by BN6PR16CA0045.outlook.office365.com (2603:10b6:405:14::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9 via Frontend Transport; Thu, 13 Jan 2022 09:30: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=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4888.9 via Frontend Transport; Thu, 13 Jan 2022 09:30:33 +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.17; Thu, 13 Jan 2022 03:30:32 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 13 Jan 2022 03:30:32 -0600 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 13 Jan 2022 03:30:29 -0600 From: Ajit Kumar Pandey To: , Subject: [PATCH 4/6] ASoC: amd: acp: Add ACP init()/deinit() callback for Renoir. Date: Thu, 13 Jan 2022 14:58:40 +0530 Message-ID: <20220113092842.432101-5-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> References: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de829060-2882-42ce-945e-08d9d6775934 X-MS-TrafficTypeDiagnostic: BN6PR12MB1649:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1388; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CQ8JZACZi574BKgzjw1psSAHs0ELO3QnOkxH2B5+rhF8pj84aIz4imNFJpdIhhmFHhuLQm/5S7+RJFUFiLGoDEp1b1EwMF/kHhEC7DpyUbi7oygahKL9h70k+B+Z6m2HVBZ8uJ9iHb58YFVFcucvnd8g7moRdykPj21t4h8Bw0WkP33gDdRpNujKxhdOWR5x9HVFgmKN3yzsOOPruxMAhV6UuPPBVAsq1Ehv8XMQ0BTO+lS8m9kOR7g3X41PvcCizUnkbShZxIXPxm1DLDbVu12Rl8//joKuumsaqBPyMP+igznPS75EH9TguoESyMdB8oil+38583nJ2mlhvfRAmm0TZT+ueUWKbRJfjQ3I76gDAM0SprxPiOR/LoTbcrSFZp3n+yH4AjfLKtHJdp5unaWDJO8L26oxa7oJIEwFfzDFcNnjkanSneySOW5tpPJUQn6bvqJyFw0pdKMBDtRAIrTu+vBOWs6E5e1uE025URj/biQiPpV96k+IP5EMYWJr8IO6a3ZQsurmv6N4ubGXNsb/FEpiO6S67CDrYmEBOdys0dHljRjiRvbQJQklhbGoJrN3tUefIRw/wtWfYSu0F0tUsOcPNVkZUUxrLkBl8Dg9RX0aig0KHplVnzLrYlBLwISl0vAv7qD7S3ETIZrPZNGth1WZM9H73IoRioOrWtAE8TsnN6C1OBgjs6xGHb7enCLwZgqzFRlZPhEsOD163chONschtQDjtogg6RhthqOAIlyCUDnO6Xi9REzh85U+pBYe029sKRYvcgS4QR4BgMG7qkr071STjS1iJIzVqYY= 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)(46966006)(36840700001)(40470700002)(83380400001)(2616005)(36756003)(8676002)(86362001)(426003)(70586007)(36860700001)(2906002)(7696005)(26005)(54906003)(5660300002)(356005)(1076003)(47076005)(186003)(70206006)(8936002)(6666004)(4326008)(82310400004)(81166007)(316002)(336012)(40460700001)(110136005)(508600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 09:30:33.4768 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de829060-2882-42ce-945e-08d9d6775934 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: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1649 Cc: Sunil-kumar.Dommati@amd.com, Ajit Kumar Pandey , open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Vijendar.Mukunda@amd.com, Alexander.Deucher@amd.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ACP hardware has PGFSM control registers that can be configured to power On/Off the ACP IP block. Add acp init()/de_init() callbacks in renoir platform driver probe()/remove() respectively to power on and off ACP IP block on ACP3X device. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/acp-renoir.c | 170 +++++++++++++++++++++++++++ sound/soc/amd/acp/chip_offset_byte.h | 6 + 2 files changed, 176 insertions(+) diff --git a/sound/soc/amd/acp/acp-renoir.c b/sound/soc/amd/acp/acp-renoir.c index 770a57a0677b..a29f910f25d1 100644 --- a/sound/soc/amd/acp/acp-renoir.c +++ b/sound/soc/amd/acp/acp-renoir.c @@ -25,6 +25,19 @@ #define DRV_NAME "acp_asoc_renoir" +#define ACP_SOFT_RST_DONE_MASK 0x00010001 + +#define ACP_PWR_ON_MASK 0x01 +#define ACP_PWR_OFF_MASK 0x00 +#define ACP_PGFSM_STAT_MASK 0x03 +#define ACP_POWERED_ON 0x00 +#define ACP_PWR_ON_IN_PROGRESS 0x01 +#define ACP_POWERED_OFF 0x02 + + +#define ACP_ERROR_MASK 0x20000000 +#define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF + static struct snd_soc_acpi_codecs amp_rt1019 = { .num_codecs = 1, .codecs = {"10EC1019"} @@ -112,11 +125,154 @@ static struct snd_soc_dai_driver acp_renoir_dai[] = { }, }; +static int acp3x_power_on(void __iomem *base) +{ + u32 val; + int timeout = 0; + + val = readl(base + ACP_PGFSM_STATUS); + + if (val == ACP_POWERED_ON) + return 0; + + if ((val & ACP_PGFSM_STAT_MASK) != ACP_PWR_ON_IN_PROGRESS) + writel(ACP_PWR_ON_MASK, base + ACP_PGFSM_CONTROL); + + while (++timeout < 500) { + val = readl(base + ACP_PGFSM_STATUS); + if (!val) + return 0; + udelay(1); + } + + return -ETIMEDOUT; +} + +static int acp3x_power_off(void __iomem *base) +{ + u32 val; + int timeout = 0; + + writel(ACP_PWR_OFF_MASK, base + ACP_PGFSM_CONTROL); + + while (++timeout < 500) { + val = readl(base + ACP_PGFSM_STATUS); + if ((val & ACP_PGFSM_STAT_MASK) == ACP_POWERED_OFF) + return 0; + udelay(1); + } + + return -ETIMEDOUT; +} + +static int acp3x_reset(void __iomem *base) +{ + u32 val; + int timeout = 0; + + writel(1, base + ACP_SOFT_RESET); + + while (++timeout < 500) { + val = readl(base + ACP_SOFT_RESET); + if (val & ACP_SOFT_RST_DONE_MASK) + break; + cpu_relax(); + } + + writel(0, base + ACP_SOFT_RESET); + + timeout = 0; + while (++timeout < 500) { + val = readl(base + ACP_SOFT_RESET); + if (!val) + return 0; + cpu_relax(); + } + + return -ETIMEDOUT; +} + +static void acp3x_enable_interrupts(void __iomem *base) +{ + u32 ext_intr_ctrl; + + writel(0x01, base + ACP_EXTERNAL_INTR_ENB); + ext_intr_ctrl = readl(base + ACP_EXTERNAL_INTR_CNTL); + ext_intr_ctrl |= ACP_ERROR_MASK; + writel(ext_intr_ctrl, base + ACP_EXTERNAL_INTR_CNTL); +} + +static void acp3x_disable_interrupts(void __iomem *base) +{ + writel(ACP_EXT_INTR_STAT_CLEAR_MASK, base + ACP_EXTERNAL_INTR_STAT); + writel(0x00, base + ACP_EXTERNAL_INTR_ENB); +} + +static int rn_acp_init(void __iomem *base) +{ + int ret; + + /* power on */ + ret = acp3x_power_on(base); + if (ret) + return ret; + + writel(0x01, base + ACP_CONTROL); + + /* Reset */ + ret = acp3x_reset(base); + if (ret) + return ret; + + acp3x_enable_interrupts(base); + + return 0; +} + +static int rn_acp_deinit(void __iomem *base) +{ + int ret = 0; + + acp3x_disable_interrupts(base); + + /* Reset */ + ret = acp3x_reset(base); + if (ret) + return ret; + + writel(0x00, base + ACP_CONTROL); + + /* power off */ + ret = acp3x_power_off(base); + if (ret) + return ret; + + return 0; +} static int renoir_audio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct acp_chip_info *chip; struct acp_dev_data *adata; struct resource *res; + int ret; + + chip = dev_get_platdata(&pdev->dev); + if (!chip || !chip->base) { + dev_err(&pdev->dev, "ACP chip data is NULL\n"); + return -ENODEV; + } + + if (chip->acp_rev != ACP3X_DEV) { + dev_err(&pdev->dev, "Un-supported ACP Revision %d\n", chip->acp_rev); + return -ENODEV; + } + + ret = rn_acp_init(chip->base); + if (ret) { + dev_err(&pdev->dev, "ACP Init failed\n"); + return -EINVAL; + } adata = devm_kzalloc(dev, sizeof(struct acp_dev_data), GFP_KERNEL); if (!adata) @@ -155,6 +311,20 @@ static int renoir_audio_probe(struct platform_device *pdev) static int renoir_audio_remove(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct acp_chip_info *chip; + int ret; + + chip = dev_get_platdata(&pdev->dev); + if (!chip || !chip->base) { + dev_err(&pdev->dev, "ACP chip data is NULL\n"); + return -ENODEV; + } + + ret = rn_acp_deinit(chip->base); + if (ret) { + dev_err(&pdev->dev, "ACP de-init Failed\n"); + return -EINVAL; + } acp_platform_unregister(dev); return 0; diff --git a/sound/soc/amd/acp/chip_offset_byte.h b/sound/soc/amd/acp/chip_offset_byte.h index e38589a142e9..88f6fa597cd6 100644 --- a/sound/soc/amd/acp/chip_offset_byte.h +++ b/sound/soc/amd/acp/chip_offset_byte.h @@ -14,6 +14,12 @@ #define ACPAXI2AXI_ATU_CTRL 0xC40 #define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_5 0xC20 #define ACPAXI2AXI_ATU_BASE_ADDR_GRP_5 0xC24 + +#define ACP_PGFSM_CONTROL 0x141C +#define ACP_PGFSM_STATUS 0x1420 +#define ACP_SOFT_RESET 0x1000 +#define ACP_CONTROL 0x1004 + #define ACP_EXTERNAL_INTR_ENB 0x1800 #define ACP_EXTERNAL_INTR_CNTL 0x1804 #define ACP_EXTERNAL_INTR_STAT 0x1808 From patchwork Thu Jan 13 09:28:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12712512 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 0CDB9C433F5 for ; Thu, 13 Jan 2022 09:32:15 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 465C21F1B; Thu, 13 Jan 2022 10:31:23 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 465C21F1B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642066333; bh=6zUsG9qYtYMH6LtbgM+EGV5W/jbeFrJEFB6JIxKaUuc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=RFzjEtKLn4kSRnkMb0fAHY2Y0TpJvoWuPdcqUDbyKi1EVo82ordib0eq3V0BAZUrN 55vzUBd11fN0WMcp2EqYQVdP6Pv0ZLNxpZueIRKk17NiTRLROX5sd2DGk6FwsGNAO0 ak9cpT9eiKYIbFAsw2F77TImXjNI0/jjGsxD7rhM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1F5D7F8051B; Thu, 13 Jan 2022 10:30:59 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 639FDF8051C; Thu, 13 Jan 2022 10:30:57 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2074.outbound.protection.outlook.com [40.107.237.74]) (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 B400CF80141 for ; Thu, 13 Jan 2022 10:30:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B400CF80141 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="PlFx4Zq7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AxSpay3bsoQ2YtNZEC1QiuiEsDXxAQ+y2C/EK246NCFCSOJbHGTqbNdhAdHWEOvUNjklou/td/yY/FOl8lplSo9p41lCw7J7D+H3IwMqjj8M2zs2LJntX9tFcPihmE+rG2QXLfzriaOMNkFqAfmSXzOyst5FavYji8/lSDwMktjLuCofOwQcTYlgfV7GP4MEd12W976sPcC6O3E4ItqAg+jsdOSkQlDC+pPQQ+AVtM1f3gOhYlWsWq4gawpt/u+85NjuFH3Lexga20L0rf+JhzJguOPZfwLDud4u27kmZrS0fJ1a+o/5/KE9WZXzycYkB9a28cgk0BQiWmBGHFFh+g== 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=J0zrcuPd4mY9R/L4Zs9eqA5JLpYh4Qq+f12LdA0fmIE=; b=MrgLUipivhxuY50yBGWqhTr3tvzPMBx2SkP1+X5Gobpva5VW48AlQX76BbR99kjdvR7K70gShDrvFJTy1o5vE38Y73v8TnxUNJSQVqtK4PPWpaXnzd8krqPJ9Jvli0UTjsEwuasH2Q+yvlDRQEDLh4DrZvdkLI1JTZJqbTogqv2SfmOLD5Clk2Prlr90v9lDiNMUS0peKJzlDum3wMC3/rrvFDKbfUXeLlljowyQMzuE8ZLEJYi8LXhYUwY5Fmr3xE2ovLoe+QQ4VGw/xlkXW7vvXRC+/4EJzBXtytQSJMTJELG8wGs2Y8/P/iDxL+s4YmBqg/Isfu536uevQHK/jA== 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=J0zrcuPd4mY9R/L4Zs9eqA5JLpYh4Qq+f12LdA0fmIE=; b=PlFx4Zq74emP1dDJmUuWyxlkjwtfo90yN45Dn+6PvYK0TbsCris51UWWvjwBDBu3GoS71rWrzJi8xEUn2LLYKEoXwCdqFVnhAaZ7/cco9brqpgcIv/wI4npnKnmzQ0Np+sOWEAMS1qQnF97V5PVn5Tx/2suxiDNKu3QznCqxZUg= Received: from BN0PR04CA0016.namprd04.prod.outlook.com (2603:10b6:408:ee::21) by BN6PR12MB1665.namprd12.prod.outlook.com (2603:10b6:405:7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9; Thu, 13 Jan 2022 09:30:46 +0000 Received: from BN8NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ee:cafe::7b) by BN0PR04CA0016.outlook.office365.com (2603:10b6:408:ee::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10 via Frontend Transport; Thu, 13 Jan 2022 09:30:46 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT015.mail.protection.outlook.com (10.13.176.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4888.9 via Frontend Transport; Thu, 13 Jan 2022 09:30:45 +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.17; Thu, 13 Jan 2022 03:30:45 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.17; Thu, 13 Jan 2022 01:30:45 -0800 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 13 Jan 2022 03:30:41 -0600 From: Ajit Kumar Pandey To: , Subject: [PATCH 5/6] ASoC: amd: acp: acp-legacy: Add DMIC dai link support for Renoir Date: Thu, 13 Jan 2022 14:58:41 +0530 Message-ID: <20220113092842.432101-6-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> References: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da5e626d-ea74-4117-50f8-08d9d677609f X-MS-TrafficTypeDiagnostic: BN6PR12MB1665:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1169; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZRSXf2cjgTDhMiP6lMJtHhooeTK3IOTem526zIJloCHiad10yyCa6IGKWJ+DuAeDkDCFijldzOpbJuIah7paCpyYOQvPR6hIVwspntbKxBvDPO+sKnkSCU35WoY87QFRyqRClo5tZC9Xm3Db9BZ2a1S8Af5jposYFxbF89BA/O7erO/8SPiRcIxejvU4ZBfuSH3z4QZlJLzy5gLgsu7qRGvSvRuMLHAtXkdhApfLSrEpsBvPdUv1mZvy1aK62tJiSCNHIfV3nd6e5+lMsBgZaLzh3jqwNmtqtE2SYJEZeh73wbrXGxKFxs+oRaDMR7bOuON5eREivSOvfRBIz5g97Pmm+UgKQjZmr8YUs+huZTcWV3d3eRMwsRHixjYUIdQJLdAV90smBaJbAE+pximcDL4iw3AoiF2KOPsFeSdjqDJ7YBWePPpu661nUxHuABAk0bN/DefiKr37AQUMNt0T/Or2f5+wnhbsX0h2fHPViIiYlQoPHxtlFQ4xC6DurMft84WY4K2IpmJ6sXo6jzD7EmDrqid67rMfsCbUwF2cMGpQMoXZgXr4UbLP6UOdJUGPX/xpXriz5IngAvUP1fVLXhYw/BEaROdXqWXSw8nTTPyM01jpMF7LoHDSkiTQ3JlJGRFJ8HPKGmL7j49TDKo2FI+TsKOayuyy8H8npDd/Da56nYLs+nJQ4hylhUQJldbI25D2t/RIxdYeE7NlDuitbo7gh7u3VeIcooyp+PqkirREZ+AkBnbvS64ubt/cGbcX6WBwN67mPjOqg5fNdAg4UDAwJAOQdlwGjUN96Uy9c6w= 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)(40470700002)(36840700001)(46966006)(1076003)(8936002)(316002)(81166007)(356005)(110136005)(86362001)(26005)(40460700001)(36860700001)(54906003)(82310400004)(186003)(7696005)(8676002)(426003)(2616005)(336012)(5660300002)(83380400001)(508600001)(2906002)(70206006)(4326008)(70586007)(47076005)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 09:30:45.9204 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da5e626d-ea74-4117-50f8-08d9d677609f 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: BN8NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1665 Cc: Sunil-kumar.Dommati@amd.com, Ajit Kumar Pandey , open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , V sujith kumar Reddy , Vijendar.Mukunda@amd.com, Alexander.Deucher@amd.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add DMIC related dai link for pdm-dmic dai on Renoir platform with generic dmic codec dai. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/acp-legacy-mach.c | 4 ++-- sound/soc/amd/acp/acp-mach-common.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/acp/acp-legacy-mach.c b/sound/soc/amd/acp/acp-legacy-mach.c index 0ad1cf41b308..91140d15691b 100644 --- a/sound/soc/amd/acp/acp-legacy-mach.c +++ b/sound/soc/amd/acp/acp-legacy-mach.c @@ -23,10 +23,10 @@ static struct acp_card_drvdata rt5682_rt1019_data = { .hs_cpu_id = I2S_SP, .amp_cpu_id = I2S_SP, - .dmic_cpu_id = NONE, + .dmic_cpu_id = DMIC, .hs_codec_id = RT5682, .amp_codec_id = RT1019, - .dmic_codec_id = NONE, + .dmic_codec_id = DMIC, .gpio_spkr_en = EN_SPKR_GPIO_GB, }; diff --git a/sound/soc/amd/acp/acp-mach-common.c b/sound/soc/amd/acp/acp-mach-common.c index c9caade5cb74..b163e3a68166 100644 --- a/sound/soc/amd/acp/acp-mach-common.c +++ b/sound/soc/amd/acp/acp-mach-common.c @@ -438,6 +438,8 @@ SND_SOC_DAILINK_DEF(sof_sp, DAILINK_COMP_ARRAY(COMP_CPU("acp-sof-sp"))); SND_SOC_DAILINK_DEF(sof_dmic, DAILINK_COMP_ARRAY(COMP_CPU("acp-sof-dmic"))); +SND_SOC_DAILINK_DEF(pdm_dmic, + DAILINK_COMP_ARRAY(COMP_CPU("acp-pdm-dmic"))); int acp_sofdsp_dai_links_create(struct snd_soc_card *card) { @@ -613,6 +615,19 @@ int acp_legacy_dai_links_create(struct snd_soc_card *card) links[i].ops = &acp_card_maxim_ops; links[i].init = acp_card_maxim_init; } + i++; + } + + if (drv_data->dmic_cpu_id == DMIC) { + links[i].name = "acp-dmic-codec"; + links[i].id = DMIC_BE_ID; + links[i].codecs = dmic_codec; + links[i].num_codecs = ARRAY_SIZE(dmic_codec); + links[i].cpus = pdm_dmic; + links[i].num_cpus = ARRAY_SIZE(pdm_dmic); + links[i].platforms = platform_component; + links[i].num_platforms = ARRAY_SIZE(platform_component); + links[i].dpcm_capture = 1; } card->dai_link = links; From patchwork Thu Jan 13 09:28:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12712513 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 CEC97C433EF for ; Thu, 13 Jan 2022 09:32:25 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 262551F04; Thu, 13 Jan 2022 10:31:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 262551F04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1642066344; bh=xNr9Uwot3B4ZCiOQ3YlgQ6ktffPcXuoKWFJkNUUkniE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=V50Tm9t+AbGqELJtQ0y1mJrGYIowlgsqyofC6nNucthspmYA5BwqlfFYSqVhizNdG isyRoFyDmbZXDH9Z6lxCX73a6w6DM3OtU72RI3kQ6C4mWWvrZOnUxCBrQ8ebHkSW85 GnkZAUGXt6eR9G/8Rhwim9frMdA1A0h9nQ41so0Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 93A92F8051F; Thu, 13 Jan 2022 10:31:03 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 14E0DF80520; Thu, 13 Jan 2022 10:31:03 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2048.outbound.protection.outlook.com [40.107.93.48]) (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 9B726F8051C for ; Thu, 13 Jan 2022 10:31:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9B726F8051C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="UaWrwmUv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hh9DEqcT4uz9mUEk9snkXjzZaQ8VF18I2Xyn8/VBejT8iKBA+bzMCcC6AZj39ywKHlPkHxAu20RDGf03UzIB5ZJnYNosGAh2QCscPH3pE4pmJYnJZJvRktLpdLK+CpGUpA1u9mt/WwRRJ3uR/MpJUCAShJL0hjB4j6XOjmgaHJsiX07IQ8tP3ux2mr77KJrq0YEKm1zEcGYz01/b7mWMglZifC60Fsep6HsCxZnA2lsYTBWMtbsALWQxOEAKSSbY/VJWFMMBTo0FZcM0ZhFP5lFYKcxH1TCj/+SGVHDArzSgXX3NfwnvzhrIIQfRoHjKUo6VgyLSqCBmp7mQ93/VXg== 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=RMthq7As3IApvnsSwEpDVZShNtIoE5+Th3bp3BWlFsw=; b=LPQdLQnMGfgeBQbuWcEBcuoSVNPQx2J3woN9taexcOFa4QeQcYM3aFptntV5TRlLb4JR+V1pinD854U/ryChlloXtH7uMtWFQemtIM9CPPuNM6Kl7xFND6zrknT540/f6iJng3s47jVF6D++MjCwg9YhI3qO4ycfOnn+bblRF/mUIjuRUT9D1/qO1GoTYFAKYW7z3TsCr/7HSSYv7sdIsz25Q48VxC3Gg1iBiAleDOGNCDkvWYEgZTicpmLhILoaZkzFiWTYkW0emPdYeJZaw3BfZZPbORVZfnzZqE6Wxp/zwIZa0mr1VbMWO7kg8zAzGvvhx65U/OF4jzFZZdU6sg== 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=RMthq7As3IApvnsSwEpDVZShNtIoE5+Th3bp3BWlFsw=; b=UaWrwmUvHpkAVliVDpH5eSLrdlAshVxtk14Xt3H7JrcKzCo5nxn4PrZMT5jgh3H1549FeJJ6ksvCcgKQIyun1DJOo4G/C65zRN0W8Rk73WqEshbwMHQ2Uzj10slqY/HULnaKCU/mbzrHkFRl7Q/O6R9C6OkKOQd+JHJWo/eGMsQ= Received: from BN6PR1701CA0022.namprd17.prod.outlook.com (2603:10b6:405:15::32) by MN2PR12MB4638.namprd12.prod.outlook.com (2603:10b6:208:ff::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Thu, 13 Jan 2022 09:30:55 +0000 Received: from BN8NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:405:15:cafe::7c) by BN6PR1701CA0022.outlook.office365.com (2603:10b6:405:15::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10 via Frontend Transport; Thu, 13 Jan 2022 09:30: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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT024.mail.protection.outlook.com (10.13.177.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4888.9 via Frontend Transport; Thu, 13 Jan 2022 09:30:55 +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.17; Thu, 13 Jan 2022 03:30:54 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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.17; Thu, 13 Jan 2022 01:30:54 -0800 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Thu, 13 Jan 2022 03:30:50 -0600 From: Ajit Kumar Pandey To: , Subject: [PATCH 6/6] ASoC: amd: renoir: Add check for acp configuration flags. Date: Thu, 13 Jan 2022 14:58:42 +0530 Message-ID: <20220113092842.432101-7-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> References: <20220113092842.432101-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d93b2c0b-4997-4024-b085-08d9d6776646 X-MS-TrafficTypeDiagnostic: MN2PR12MB4638:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zEIh6G41NXMvxXn20zS0HQhvatjce6K2mWvoqT2oe+e+mMaIITBStvZvoJhMMAF4RH6NZGwQnPeoXD/zlGUyA/Mh8Al1bFvzzdoCgCZMG3zoABzlaozYv8JdRYN9HgyNKmAKSQkf/ML2ifmLhy8tFBqXhxBNds3WJ6oEWG0MqMZDk1sgBmI6qWrzMePnoAySC2gOoJxIAo7Ju4K7yo8zn1LHm9sebB+x6x4W2GqWtd4K/Bdwcu51LG5aqibJLVfOzk+lJnByctKYGz+nhuxeqA2Cy4U6jCdojUJgdjNF1+mP+relcVAatioepEVCX77ePUZvUkW1ZQ6OuPYx+ddrAG5sjhqi9rh8ifFcb3ADfSEfXcpi7zI3T/CCJv3olJbeJ4uUVCpeApYORQDgdXwpr6tKI2l+AbwyC8hDexkjD/1Hvt3uRzaCcwcZjebf3TDrUo3lKAI7S4Rfh7zt/bScYx+VLdjd+QWnHK9PCaBR9EMAu2ZZPSQPmq/R8wUYD63U0tJiQDUXUI5hep6UgKkzrgWzegfFO/alvN3PweCzyJL91P4XLoXy9zTDHhpCBxoVFQV7PKHt+gGpsKbhIkcWhGxWE2dUKi0Fp4K35YDNOGUFvhlF4gSZAgoavwzJ1yXpJxmVCDoAL92PS14kLEuEy5xRQg8QNB98aBe7VhYL0RiQquuluAGzG/WPIxfL1U2b8GncE9ssEn6Ur808JVQKGePR/OUqW94BWEAU26yyzJJFHuPx+C47H0esLgMMmR/8zT22h9yWmYbECSYilCWS/SnOGdHIordJi26NK/o0N4o= 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)(36840700001)(46966006)(40470700002)(426003)(508600001)(8936002)(186003)(70206006)(54906003)(2616005)(2906002)(336012)(70586007)(4326008)(40460700001)(26005)(82310400004)(110136005)(7696005)(1076003)(5660300002)(6666004)(36860700001)(47076005)(36756003)(86362001)(81166007)(83380400001)(8676002)(316002)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 09:30:55.3903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d93b2c0b-4997-4024-b085-08d9d6776646 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: BN8NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4638 Cc: Pierre-Louis Bossart , Sunil-kumar.Dommati@amd.com, Ajit Kumar Pandey , open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Mario Limonciello , Vijendar.Mukunda@amd.com, Alexander.Deucher@amd.com, Mark Pearson X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" We have SOF and generic ACP support enabled for Renoir platforms on some machines. Since we have same PCI id used for probing, add check for machine configuration flag to avoid conflict with newer pci drivers. Such machine flag has been initialized via dmi match on few Chrome machines. If no flag is specified probe and register older platform device. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/renoir/rn-pci-acp3x.c | 7 ++++++- sound/soc/amd/renoir/rn_acp3x.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c index 7b8040e812a1..b3812b70f5f9 100644 --- a/sound/soc/amd/renoir/rn-pci-acp3x.c +++ b/sound/soc/amd/renoir/rn-pci-acp3x.c @@ -212,10 +212,15 @@ static int snd_rn_acp_probe(struct pci_dev *pci, acpi_integer dmic_status; #endif const struct dmi_system_id *dmi_id; - unsigned int irqflags; + unsigned int irqflags, flag; int ret, index; u32 addr; + /* Return if acp config flag is defined */ + flag = snd_amd_acp_find_config(pci); + if (flag) + return -ENODEV; + /* Renoir device check */ if (pci->revision != 0x01) return -ENODEV; diff --git a/sound/soc/amd/renoir/rn_acp3x.h b/sound/soc/amd/renoir/rn_acp3x.h index 14620399d766..ca586603d720 100644 --- a/sound/soc/amd/renoir/rn_acp3x.h +++ b/sound/soc/amd/renoir/rn_acp3x.h @@ -88,3 +88,6 @@ static inline void rn_writel(u32 val, void __iomem *base_addr) { writel(val, base_addr - ACP_PHY_BASE_ADDRESS); } + +/* Machine configuration */ +int snd_amd_acp_find_config(struct pci_dev *pci);