From patchwork Thu Sep 30 13:24:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12528643 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB259C433F5 for ; Thu, 30 Sep 2021 15:15:07 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1B67A61A0B for ; Thu, 30 Sep 2021 15:15:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1B67A61A0B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 1F34316E8; Thu, 30 Sep 2021 17:14:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1F34316E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633014905; bh=7WT6V/5tf4UjPqxd8NlfamE3mW8RI5TkYeI+qtlUTuI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PUnFSVyBMJmgDtVx32ZQD6AZqHK3LCqroaMvEyJ0Ca+0nLVZ6ekZ7SERlO4IktM0w 3WRxM93/wpbOqmLfFTlyhR+PN6yNBvP6vJ/Fce0qPGE9m1tVyRGMx0XdPUYE77E7zp 1Fhelnqz5/ruNAi1Z3pnV8B8djDyoisRbua9M1NY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 16815F80518; Thu, 30 Sep 2021 17:11:15 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C799AF804AD; Thu, 30 Sep 2021 15:25:14 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2084.outbound.protection.outlook.com [40.107.223.84]) (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 40A2EF80218 for ; Thu, 30 Sep 2021 15:25:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 40A2EF80218 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="1RzT5lpB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M5HBHuXX0pdwlwY2FIqrLoRSPtPcPMORZakXyF0xqBlsg4m9SEW0nm/Mybj3bD7UpU/82r6METjVQY6VbvS6EIFeSbYAmacBHz7urVSAk9P7ueOenZJwsz3TX2t2kbMG3NxK9x0+ETcAcBTTnzZMZAYjRooztrHy4d75ETtQmpAqhjxVbZWXX1mIg7fHemBLeO60BoN6aYCFCKxZJyUCi7wBIDcj/LtRA4qhWds2yjN61ZSiM6zRF0q1iZEMrB7amBhJRP2aZYsgkWAz8fT2HbN3JXDsYmBIqA4KduxtohAXuuXhTmcNGuvx/46UO7zduMNfr1xM9+zMOoKUBmtNzg== 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; bh=APRH3iscETrhXxov7/IdDhyYcw+WpRYAhIpsp/cDxhM=; b=NlnoEKLVx4bw71HAlw1s5RDRnBq1fgzeCFP3MkIKKiMr8IImUuFsJmqHZNfyM05DJ7wa1VEP6pdGMpsto3Nxa8ebqqjTWQSoHAZo3afj2iq0HcdWgaiifLAln5C89rzqWvPpAdeDBtviG11b3CdP7fYpCc8lm3Rx/l2lDuQp5pSGszo7jTFUp1jMDFSaJqLgqRj1oygx9hMcaxNqaH9eKJgXEZ3uWly/Xe8H9P/kf6zh4mIJ81WSC/Q0FtDtjYJJka+y3N49flS3QKRFcO4FccZGBxeVzRt+Vg4GR8UitFGFG7ceSDycnfOXYG/EPDu+843s1wT1ccOa5jimV+GvPA== 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=APRH3iscETrhXxov7/IdDhyYcw+WpRYAhIpsp/cDxhM=; b=1RzT5lpBL3qyE+bPDUsm2dRDyhna912COJ5Jv//VhBQittcYmjo3q8iZOiYdck+cDl8HYZm7YJlYPcNtxTTAlbuKma97KrzoprFgy0UujU1y1nML3wgQ5eFTq21mJurjhvcdLUkYcUmt8NQGSpBgU9Xn8jXO5kyt5yBn6xdKS/4= Received: from DM6PR06CA0088.namprd06.prod.outlook.com (2603:10b6:5:336::21) by BY5PR12MB3889.namprd12.prod.outlook.com (2603:10b6:a03:1ad::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.18; Thu, 30 Sep 2021 13:24:58 +0000 Received: from DM6NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:5:336:cafe::d6) by DM6PR06CA0088.outlook.office365.com (2603:10b6:5:336::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:24:58 +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 DM6NAM11FT048.mail.protection.outlook.com (10.13.173.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:24:58 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 08:24:57 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 08:24:56 -0500 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.8 via Frontend Transport; Thu, 30 Sep 2021 08:24:46 -0500 From: Ajit Kumar Pandey To: , Subject: [PATCH 1/8] ASoC: amd: Add common framework to support I2S on ACP SOC Date: Thu, 30 Sep 2021 18:54:11 +0530 Message-ID: <20210930132418.14077-2-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> References: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3267d907-ef88-4620-4655-08d98415b314 X-MS-TrafficTypeDiagnostic: BY5PR12MB3889: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:220; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YD4Xee84BGyvh9ybso+4UHYTqW0HwzzsslcXCsrSPfBce/TEBZTEE9iYU2SGDSoA/bv58sfq5U46jX6d0q4I1+Op/NmgBiWAIezC1ENC3AH90Pp+A2QoW30vdsDj+ekcY9CpefQud9V/Af+7OP926IDoczJr89kCb0y/O5hA0nsu+z69LWX9sQ3+n6Pgsefez5zIh5lbGSzpVHnPjeGNODoOpHX6v0Bf/9sSMh8WRb/AAeYY+aubt0qsVQfwprXSBcGZn8hMzhqhol2n2/wKUtSbnWHtegjv5AT4jdU/kEH62YFHPoLjaXkOyfCQ4xsG1vC65pgZGy6HdDR7yZ3C/VA+uzHOK9tZHB4sBxjQmyPriPtcOA326WKAsqfeEcc+mf/0798ciav5yRBxNMwAxFj7Tz8+pGEeDLk1gMhFAFXcvmo0ubJQSjzkNseMl/L+IXxA63E+jyw1gJ95L2FWtSX92iUOxnBbjKS8jblYidX34DjQdvJiGfiB080oxphu+1qxprg1L0rrt25cLnS4t1Bc8nGyXb3RSE/VSpykSq01K5t8eFP8vebOwvJDEVVFBlH0z7Jn8qdnVddXGDmz+YgqnVIt1Q8CgVFqWct4FF7KVZdqujJNE3x9UjHaK79R9g/JwjS5qVBZ9+AfAcoFo2CVrtiXtZLaHjIJsaJAgXHjkhwPkxD4L7RvY9NWHeH4DB+FEwXggKG5Pn9skL0dXJGEHYcsGJ0i/sn6oX0pS0M= 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)(336012)(6666004)(70206006)(1076003)(83380400001)(81166007)(70586007)(82310400003)(316002)(186003)(8936002)(2906002)(47076005)(356005)(26005)(36756003)(426003)(4326008)(110136005)(508600001)(54906003)(30864003)(86362001)(5660300002)(2616005)(8676002)(36860700001)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 13:24:58.2197 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3267d907-ef88-4620-4655-08d98415b314 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: DM6NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3889 X-Mailman-Approved-At: Thu, 30 Sep 2021 17:11:01 +0200 Cc: Pierre-Louis Bossart , Sunil-kumar.Dommati@amd.com, Ajit Kumar Pandey , open list , Basavaraj.Hiregoudar@amd.com, Takashi Iwai , Liam Girdwood , Vijendar Mukunda , 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" We are using legacy way of exposing dais and DMA configuration that requires separate driver modules for various ACP SOC with almost similar hw configuration. Moreover the legacy approach requires separate I2S and DMA module platform devices registration and need machine specific quirk to control various I2S endpoints. Add generic dai driver and platform driver for I2S controller on ACP hw block. This common framework can be used by various ACP platform devices that shares common specs. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/Kconfig | 2 + sound/soc/amd/Makefile | 1 + sound/soc/amd/acp/Kconfig | 18 ++ sound/soc/amd/acp/Makefile | 12 + sound/soc/amd/acp/acp-i2s.c | 340 +++++++++++++++++++++++++++ sound/soc/amd/acp/acp-platform.c | 292 +++++++++++++++++++++++ sound/soc/amd/acp/amd.h | 140 +++++++++++ sound/soc/amd/acp/chip_offset_byte.h | 76 ++++++ 8 files changed, 881 insertions(+) create mode 100644 sound/soc/amd/acp/Kconfig create mode 100644 sound/soc/amd/acp/Makefile create mode 100644 sound/soc/amd/acp/acp-i2s.c create mode 100644 sound/soc/amd/acp/acp-platform.c create mode 100644 sound/soc/amd/acp/amd.h create mode 100644 sound/soc/amd/acp/chip_offset_byte.h diff --git a/sound/soc/amd/Kconfig b/sound/soc/amd/Kconfig index 49ff5e73e9ba..78e99cd25c37 100644 --- a/sound/soc/amd/Kconfig +++ b/sound/soc/amd/Kconfig @@ -61,3 +61,5 @@ config SND_SOC_AMD_ACP5x By enabling this flag build will trigger for ACP PCI driver, ACP DMA driver, CPU DAI driver. + +source "sound/soc/amd/acp/Kconfig" diff --git a/sound/soc/amd/Makefile b/sound/soc/amd/Makefile index 07150d26f315..9878907c89a6 100644 --- a/sound/soc/amd/Makefile +++ b/sound/soc/amd/Makefile @@ -11,3 +11,4 @@ obj-$(CONFIG_SND_SOC_AMD_ACP3x) += raven/ obj-$(CONFIG_SND_SOC_AMD_RV_RT5682_MACH) += snd-soc-acp-rt5682-mach.o obj-$(CONFIG_SND_SOC_AMD_RENOIR) += renoir/ obj-$(CONFIG_SND_SOC_AMD_ACP5x) += vangogh/ +obj-$(CONFIG_SND_SOC_AMD_ACP_COMMON) += acp/ diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig new file mode 100644 index 000000000000..1ca815df6f23 --- /dev/null +++ b/sound/soc/amd/acp/Kconfig @@ -0,0 +1,18 @@ +# 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. +# + +config SND_SOC_AMD_ACP_COMMON + tristate "AMD Audio ACP Common support" + select SND_AMD_ACP_CONFIG + help + This option enables ACP support on AMD platform + +config SND_SOC_AMD_ACP_I2S + tristate + +config SND_SOC_AMD_ACP_PCM + tristate diff --git a/sound/soc/amd/acp/Makefile b/sound/soc/amd/acp/Makefile new file mode 100644 index 000000000000..b2e12659d97b --- /dev/null +++ b/sound/soc/amd/acp/Makefile @@ -0,0 +1,12 @@ +# 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. + +#common acp driver +snd-acp-pcm-objs := acp-platform.o +snd-acp-i2s-objs := acp-i2s.o + +obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o +obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o diff --git a/sound/soc/amd/acp/acp-i2s.c b/sound/soc/amd/acp/acp-i2s.c new file mode 100644 index 000000000000..9da4faf58373 --- /dev/null +++ b/sound/soc/amd/acp/acp-i2s.c @@ -0,0 +1,340 @@ +// 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 +// + +/* + * Generic Hardware interface for ACP Audio I2S controller + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "amd.h" + +#define DRV_NAME "acp_i2s_playcap" + +static int acp_i2s_hwparams(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct device *dev = dai->component->dev; + struct acp_dev_data *adata; + u32 val; + u32 xfer_resolution; + u32 reg_val; + + adata = snd_soc_dai_get_drvdata(dai); + + /* These values are as per Hardware Spec */ + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_U8: + case SNDRV_PCM_FORMAT_S8: + xfer_resolution = 0x0; + break; + case SNDRV_PCM_FORMAT_S16_LE: + xfer_resolution = 0x02; + break; + case SNDRV_PCM_FORMAT_S24_LE: + xfer_resolution = 0x04; + break; + case SNDRV_PCM_FORMAT_S32_LE: + xfer_resolution = 0x05; + break; + default: + return -EINVAL; + } + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + switch (dai->driver->id) { + case I2S_BT_INSTANCE: + reg_val = ACP_BTTDM_ITER; + break; + case I2S_SP_INSTANCE: + reg_val = ACP_I2STDM_ITER; + break; + default: + dev_err(dev, "Invalid dai id %x\n", dai->driver->id); + return -EINVAL; + } + } else { + switch (dai->driver->id) { + case I2S_BT_INSTANCE: + reg_val = ACP_BTTDM_IRER; + break; + case I2S_SP_INSTANCE: + reg_val = ACP_I2STDM_IRER; + break; + default: + dev_err(dev, "Invalid dai id %x\n", dai->driver->id); + return -EINVAL; + } + } + + val = readl(adata->acp_base + reg_val); + val &= ~ACP3x_ITER_IRER_SAMP_LEN_MASK; + val = val | (xfer_resolution << 3); + writel(val, adata->acp_base + reg_val); + + return 0; +} + +static int acp_i2s_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 val, period_bytes, reg_val, ier_val, water_val, buf_size, buf_reg; + + period_bytes = frames_to_bytes(substream->runtime, substream->runtime->period_size); + buf_size = frames_to_bytes(substream->runtime, substream->runtime->buffer_size); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + stream->bytescount = acp_get_byte_count(adata, stream->dai_id, substream->stream); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + switch (dai->driver->id) { + case I2S_BT_INSTANCE: + water_val = ACP_BT_TX_INTR_WATERMARK_SIZE; + reg_val = ACP_BTTDM_ITER; + ier_val = ACP_BTTDM_IER; + buf_reg = ACP_BT_TX_RINGBUFSIZE; + break; + case I2S_SP_INSTANCE: + water_val = ACP_I2S_TX_INTR_WATERMARK_SIZE; + reg_val = ACP_I2STDM_ITER; + ier_val = ACP_I2STDM_IER; + buf_reg = ACP_I2S_TX_RINGBUFSIZE; + break; + default: + dev_err(dev, "Invalid dai id %x\n", dai->driver->id); + return -EINVAL; + } + } else { + switch (dai->driver->id) { + case I2S_BT_INSTANCE: + water_val = ACP_BT_RX_INTR_WATERMARK_SIZE; + reg_val = ACP_BTTDM_IRER; + ier_val = ACP_BTTDM_IER; + buf_reg = ACP_BT_RX_RINGBUFSIZE; + break; + case I2S_SP_INSTANCE: + water_val = ACP_I2S_RX_INTR_WATERMARK_SIZE; + reg_val = ACP_I2STDM_IRER; + ier_val = ACP_I2STDM_IER; + buf_reg = ACP_I2S_RX_RINGBUFSIZE; + break; + default: + dev_err(dev, "Invalid dai id %x\n", dai->driver->id); + return -EINVAL; + } + } + writel(period_bytes, adata->acp_base + water_val); + writel(buf_size, adata->acp_base + buf_reg); + val = readl(adata->acp_base + reg_val); + val = val | BIT(0); + writel(val, adata->acp_base + reg_val); + writel(1, adata->acp_base + ier_val); + return 0; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + switch (dai->driver->id) { + case I2S_BT_INSTANCE: + reg_val = ACP_BTTDM_ITER; + break; + case I2S_SP_INSTANCE: + reg_val = ACP_I2STDM_ITER; + break; + default: + dev_err(dev, "Invalid dai id %x\n", dai->driver->id); + return -EINVAL; + } + + } else { + switch (dai->driver->id) { + case I2S_BT_INSTANCE: + reg_val = ACP_BTTDM_IRER; + break; + case I2S_SP_INSTANCE: + reg_val = ACP_I2STDM_IRER; + break; + default: + dev_err(dev, "Invalid dai id %x\n", dai->driver->id); + return -EINVAL; + } + } + val = readl(adata->acp_base + reg_val); + val = val & ~BIT(0); + writel(val, adata->acp_base + reg_val); + + if (!(readl(adata->acp_base + ACP_BTTDM_ITER) & BIT(0)) && + !(readl(adata->acp_base + ACP_BTTDM_IRER) & BIT(0))) + writel(0, adata->acp_base + ACP_BTTDM_IER); + if (!(readl(adata->acp_base + ACP_I2STDM_ITER) & BIT(0)) && + !(readl(adata->acp_base + ACP_I2STDM_IRER) & BIT(0))) + writel(0, adata->acp_base + ACP_I2STDM_IER); + return 0; + default: + return -EINVAL; + } + + return 0; +} + +static int acp_i2s_prepare(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); + struct acp_stream *stream = substream->runtime->private_data; + u32 reg_dma_size = 0, reg_fifo_size = 0, reg_fifo_addr = 0; + u32 phy_addr = 0, acp_fifo_addr = 0, ext_int_ctrl; + unsigned int dir = substream->stream; + + switch (dai->driver->id) { + case I2S_SP_INSTANCE: + if (dir == SNDRV_PCM_STREAM_PLAYBACK) { + reg_dma_size = ACP_I2S_TX_DMA_SIZE; + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + SP_PB_FIFO_ADDR_OFFSET; + reg_fifo_addr = ACP_I2S_TX_FIFOADDR; + reg_fifo_size = ACP_I2S_TX_FIFOSIZE; + + phy_addr = I2S_SP_TX_MEM_WINDOW_START + stream->reg_offset; + writel(phy_addr, adata->acp_base + ACP_I2S_TX_RINGBUFADDR); + } else { + reg_dma_size = ACP_I2S_RX_DMA_SIZE; + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + SP_CAPT_FIFO_ADDR_OFFSET; + reg_fifo_addr = ACP_I2S_RX_FIFOADDR; + reg_fifo_size = ACP_I2S_RX_FIFOSIZE; + phy_addr = I2S_SP_RX_MEM_WINDOW_START + stream->reg_offset; + writel(phy_addr, adata->acp_base + ACP_I2S_RX_RINGBUFADDR); + } + break; + case I2S_BT_INSTANCE: + if (dir == SNDRV_PCM_STREAM_PLAYBACK) { + reg_dma_size = ACP_BT_TX_DMA_SIZE; + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + BT_PB_FIFO_ADDR_OFFSET; + reg_fifo_addr = ACP_BT_TX_FIFOADDR; + reg_fifo_size = ACP_BT_TX_FIFOSIZE; + + phy_addr = I2S_BT_TX_MEM_WINDOW_START + stream->reg_offset; + writel(phy_addr, adata->acp_base + ACP_BT_TX_RINGBUFADDR); + } else { + reg_dma_size = ACP_BT_RX_DMA_SIZE; + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + BT_CAPT_FIFO_ADDR_OFFSET; + reg_fifo_addr = ACP_BT_RX_FIFOADDR; + reg_fifo_size = ACP_BT_RX_FIFOSIZE; + + phy_addr = I2S_BT_TX_MEM_WINDOW_START + stream->reg_offset; + writel(phy_addr, adata->acp_base + ACP_BT_RX_RINGBUFADDR); + } + break; + default: + dev_err(dev, "Invalid dai id %x\n", dai->driver->id); + return -EINVAL; + } + + writel(DMA_SIZE, adata->acp_base + reg_dma_size); + writel(acp_fifo_addr, adata->acp_base + reg_fifo_addr); + writel(FIFO_SIZE, adata->acp_base + reg_fifo_size); + + ext_int_ctrl = readl(adata->acp_base + ACP_EXTERNAL_INTR_CNTL); + ext_int_ctrl |= BIT(I2S_RX_THRESHOLD) | BIT(BT_RX_THRESHOLD) + | BIT(I2S_TX_THRESHOLD) | BIT(BT_TX_THRESHOLD); + + writel(ext_int_ctrl, adata->acp_base + ACP_EXTERNAL_INTR_CNTL); + + return 0; +} + +static int acp_i2s_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; + unsigned int dir = substream->stream; + unsigned int irq_bit = 0; + + switch (dai->driver->id) { + case I2S_SP_INSTANCE: + if (dir == SNDRV_PCM_STREAM_PLAYBACK) { + irq_bit = BIT(I2S_TX_THRESHOLD); + stream->pte_offset = ACP_SRAM_SP_PB_PTE_OFFSET; + stream->fifo_offset = SP_PB_FIFO_ADDR_OFFSET; + } else { + irq_bit = BIT(I2S_RX_THRESHOLD); + stream->pte_offset = ACP_SRAM_SP_CP_PTE_OFFSET; + stream->fifo_offset = SP_CAPT_FIFO_ADDR_OFFSET; + } + break; + case I2S_BT_INSTANCE: + if (dir == SNDRV_PCM_STREAM_PLAYBACK) { + irq_bit = BIT(BT_TX_THRESHOLD); + stream->pte_offset = ACP_SRAM_BT_PB_PTE_OFFSET; + stream->fifo_offset = BT_PB_FIFO_ADDR_OFFSET; + } else { + irq_bit = BIT(BT_RX_THRESHOLD); + stream->pte_offset = ACP_SRAM_BT_CP_PTE_OFFSET; + stream->fifo_offset = BT_CAPT_FIFO_ADDR_OFFSET; + } + break; + default: + dev_err(dev, "Invalid dai id %x\n", dai->driver->id); + return -EINVAL; + } + + /* Save runtime dai configuration in stream */ + stream->id = dai->driver->id + dir; + stream->dai_id = dai->driver->id; + stream->irq_bit = irq_bit; + + return 0; +} + +const struct snd_soc_dai_ops asoc_acp_cpu_dai_ops = { + .startup = acp_i2s_startup, + .hw_params = acp_i2s_hwparams, + .prepare = acp_i2s_prepare, + .trigger = acp_i2s_trigger, +}; +EXPORT_SYMBOL_NS(asoc_acp_cpu_dai_ops, SND_SOC_ACP_COMMON); + +int asoc_acp_i2s_probe(struct snd_soc_dai *dai) +{ + struct device *dev = dai->component->dev; + struct acp_dev_data *adata = dev_get_drvdata(dev); + unsigned int val; + + if (!adata->acp_base) { + dev_err(dev, "I2S base is NULL\n"); + return -EINVAL; + } + + val = readl(adata->acp_base + ACP_I2S_PIN_CONFIG); + if (val != I2S_MODE) { + dev_err(dev, "I2S Mode not supported val %x\n", val); + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL_NS(asoc_acp_i2s_probe, SND_SOC_ACP_COMMON); + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_ALIAS(DRV_NAME); diff --git a/sound/soc/amd/acp/acp-platform.c b/sound/soc/amd/acp/acp-platform.c new file mode 100644 index 000000000000..2eec2133b4fc --- /dev/null +++ b/sound/soc/amd/acp/acp-platform.c @@ -0,0 +1,292 @@ +// 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 + +/* + * Generic interface for ACP audio blck PCM component + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "amd.h" + +#define DRV_NAME "acp_i2s_dma" + +static const struct snd_pcm_hardware acp_pcm_hardware_playback = { + .info = SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_BATCH | + SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 8, + .rates = SNDRV_PCM_RATE_8000_96000, + .rate_min = 8000, + .rate_max = 96000, + .buffer_bytes_max = PLAYBACK_MAX_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE, + .period_bytes_min = PLAYBACK_MIN_PERIOD_SIZE, + .period_bytes_max = PLAYBACK_MAX_PERIOD_SIZE, + .periods_min = PLAYBACK_MIN_NUM_PERIODS, + .periods_max = PLAYBACK_MAX_NUM_PERIODS, +}; + +static const struct snd_pcm_hardware acp_pcm_hardware_capture = { + .info = SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_BATCH | + SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000_48000, + .rate_min = 8000, + .rate_max = 48000, + .buffer_bytes_max = CAPTURE_MAX_NUM_PERIODS * CAPTURE_MAX_PERIOD_SIZE, + .period_bytes_min = CAPTURE_MIN_PERIOD_SIZE, + .period_bytes_max = CAPTURE_MAX_PERIOD_SIZE, + .periods_min = CAPTURE_MIN_NUM_PERIODS, + .periods_max = CAPTURE_MAX_NUM_PERIODS, +}; + +static irqreturn_t i2s_irq_handler(int irq, void *data) +{ + struct acp_dev_data *adata = data; + struct acp_stream *stream; + u16 i2s_flag = 0; + u32 val, i; + + if (!adata) + return IRQ_NONE; + + val = readl(adata->acp_base + ACP_EXTERNAL_INTR_STAT); + + for (i = 0; i < ACP_MAX_STREAM; i++) { + stream = adata->stream[i]; + if (stream && (val & stream->irq_bit)) { + writel(stream->irq_bit, adata->acp_base + ACP_EXTERNAL_INTR_STAT); + snd_pcm_period_elapsed(stream->substream); + i2s_flag = 1; + break; + } + } + + if (i2s_flag) + return IRQ_HANDLED; + + return IRQ_NONE; +} + +static void config_pte_for_stream(struct acp_dev_data *adata, struct acp_stream *stream) +{ + u32 pte_reg, pte_size, reg_val; + + /* Use ATU base Group5 */ + pte_reg = ACPAXI2AXI_ATU_BASE_ADDR_GRP_5; + pte_size = ACPAXI2AXI_ATU_PAGE_SIZE_GRP_5; + stream->reg_offset = 0x02000000; + + /* Group Enable */ + reg_val = ACP_SRAM_PTE_OFFSET; + writel(reg_val | BIT(31), adata->acp_base + pte_reg); + writel(PAGE_SIZE_4K_ENABLE, adata->acp_base + pte_size); +} + +static void config_acp_dma(struct acp_dev_data *adata, int cpu_id, int size) +{ + struct acp_stream *stream = adata->stream[cpu_id]; + struct snd_pcm_substream *substream = stream->substream; + dma_addr_t addr = substream->dma_buffer.addr; + int num_pages = (PAGE_ALIGN(size) >> PAGE_SHIFT); + u32 low, high, val; + u16 page_idx; + + val = stream->pte_offset; + + for (page_idx = 0; page_idx < num_pages; page_idx++) { + /* Load the low address of page int ACP SRAM through SRBM */ + low = lower_32_bits(addr); + high = upper_32_bits(addr); + writel(low, adata->acp_base + ACP_SCRATCH_REG_0 + val); + high |= BIT(31); + writel(high, adata->acp_base + ACP_SCRATCH_REG_0 + val + 4); + + /* Move to next physically contiguous page */ + val += 8; + addr += PAGE_SIZE; + } +} + +static int acp_dma_open(struct snd_soc_component *component, struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream); + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0); + struct snd_pcm_runtime *runtime = substream->runtime; + struct device *dev = component->dev; + struct acp_dev_data *adata = dev_get_drvdata(dev); + struct acp_stream *stream; + int stream_id = cpu_dai->driver->id * 2 + substream->stream; + int ret; + + stream = kzalloc(sizeof(*stream), GFP_KERNEL); + if (!stream) + return -ENOMEM; + + stream->substream = substream; + adata->stream[stream_id] = stream; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + runtime->hw = acp_pcm_hardware_playback; + else + runtime->hw = acp_pcm_hardware_capture; + + ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); + if (ret < 0) { + dev_err(component->dev, "set integer constraint failed\n"); + kfree(stream); + return ret; + } + runtime->private_data = stream; + + writel(1, adata->acp_base + ACP_EXTERNAL_INTR_ENB); + + return ret; +} + +static int acp_dma_hw_params(struct snd_soc_component *component, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream); + struct acp_dev_data *adata = snd_soc_component_get_drvdata(component); + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0); + struct acp_stream *stream = substream->runtime->private_data; + int stream_id = cpu_dai->driver->id * 2 + substream->stream; + u64 size = params_buffer_bytes(params); + + /* Configure ACP DMA block with params */ + config_pte_for_stream(adata, stream); + config_acp_dma(adata, stream_id, size); + + return 0; +} + +static snd_pcm_uframes_t acp_dma_pointer(struct snd_soc_component *component, + struct snd_pcm_substream *substream) +{ + struct device *dev = component->dev; + struct acp_dev_data *adata = dev_get_drvdata(dev); + struct acp_stream *stream = substream->runtime->private_data; + u32 pos, buffersize; + u64 bytescount; + + buffersize = frames_to_bytes(substream->runtime, + substream->runtime->buffer_size); + + bytescount = acp_get_byte_count(adata, stream->dai_id, substream->stream); + + if (bytescount > stream->bytescount) + bytescount -= stream->bytescount; + + pos = do_div(bytescount, buffersize); + + return bytes_to_frames(substream->runtime, pos); +} + +static int acp_dma_new(struct snd_soc_component *component, + struct snd_soc_pcm_runtime *rtd) +{ + struct device *parent = component->dev->parent; + + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, + parent, MIN_BUFFER, MAX_BUFFER); + return 0; +} + +static int acp_dma_mmap(struct snd_soc_component *component, + struct snd_pcm_substream *substream, + struct vm_area_struct *vma) +{ + return snd_pcm_lib_default_mmap(substream, vma); +} + +static int acp_dma_close(struct snd_soc_component *component, + struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream); + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0); + struct device *dev = component->dev; + struct acp_dev_data *adata = dev_get_drvdata(dev); + struct acp_stream *stream; + int stream_id = cpu_dai->driver->id * 2 + substream->stream; + + stream = adata->stream[stream_id]; + kfree(stream); + adata->stream[stream_id] = NULL; + + return 0; +} + +static const struct snd_soc_component_driver acp_pcm_component = { + .name = DRV_NAME, + .open = acp_dma_open, + .close = acp_dma_close, + .hw_params = acp_dma_hw_params, + .pointer = acp_dma_pointer, + .mmap = acp_dma_mmap, + .pcm_construct = acp_dma_new, +}; + +int acp_platform_register(struct device *dev) +{ + struct acp_dev_data *adata = dev_get_drvdata(dev); + struct snd_soc_dai_driver; + unsigned int status; + + status = devm_request_irq(dev, adata->i2s_irq, i2s_irq_handler, + IRQF_SHARED, "ACP_I2S_IRQ", adata); + if (status) { + dev_err(dev, "ACP I2S IRQ request failed\n"); + return status; + } + + status = devm_snd_soc_register_component(dev, &acp_pcm_component, + adata->dai_driver, + adata->num_dai); + if (status) { + dev_err(dev, "Fail to register acp i2s component\n"); + return status; + } + return 0; +} +EXPORT_SYMBOL_NS(acp_platform_register, SND_SOC_ACP_COMMON); + +int acp_platform_unregister(struct device *dev) +{ + struct acp_dev_data *adata = dev_get_drvdata(dev); + + return 0; +} +EXPORT_SYMBOL_NS(acp_platform_unregister, SND_SOC_ACP_COMMON); + +MODULE_DESCRIPTION("AMD ACP PCM 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 new file mode 100644 index 000000000000..ecb53285526c --- /dev/null +++ b/sound/soc/amd/acp/amd.h @@ -0,0 +1,140 @@ +/* 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. + * + * Author: Ajit Kumar Pandey + */ + +#ifndef __AMD_ACP_H +#define __AMD_ACP_H + +#include +#include +#include "chip_offset_byte.h" + +#define I2S_SP_INSTANCE 0x00 +#define I2S_BT_INSTANCE 0x01 + +#define MEM_WINDOW_START 0x4000000 + +#define ACP_I2S_REG_START 0x1242400 +#define ACP_I2S_REG_END 0x1242810 +#define ACP3x_I2STDM_REG_START 0x1242400 +#define ACP3x_I2STDM_REG_END 0x1242410 +#define ACP3x_BT_TDM_REG_START 0x1242800 +#define ACP3x_BT_TDM_REG_END 0x1242810 +#define I2S_MODE 0x04 +#define I2S_RX_THRESHOLD 27 +#define I2S_TX_THRESHOLD 28 +#define BT_TX_THRESHOLD 26 +#define BT_RX_THRESHOLD 25 + +#define ACP_SRAM_PTE_OFFSET 0x02052800 + +#define ACP_SRAM_SP_PB_PTE_OFFSET 0x0 +#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 PAGE_SIZE_4K_ENABLE 0x2 + +#define I2S_SP_TX_MEM_WINDOW_START 0x4000000 +#define I2S_SP_RX_MEM_WINDOW_START 0x4020000 +#define I2S_BT_TX_MEM_WINDOW_START 0x4040000 +#define I2S_BT_RX_MEM_WINDOW_START 0x4060000 + +#define SP_PB_FIFO_ADDR_OFFSET 0x500 +#define SP_CAPT_FIFO_ADDR_OFFSET 0x700 +#define BT_PB_FIFO_ADDR_OFFSET 0x900 +#define BT_CAPT_FIFO_ADDR_OFFSET 0xB00 +#define PLAYBACK_MIN_NUM_PERIODS 2 +#define PLAYBACK_MAX_NUM_PERIODS 8 +#define PLAYBACK_MAX_PERIOD_SIZE 8192 +#define PLAYBACK_MIN_PERIOD_SIZE 1024 +#define CAPTURE_MIN_NUM_PERIODS 2 +#define CAPTURE_MAX_NUM_PERIODS 8 +#define CAPTURE_MAX_PERIOD_SIZE 8192 +#define CAPTURE_MIN_PERIOD_SIZE 1024 + +#define MAX_BUFFER 65536 +#define MIN_BUFFER MAX_BUFFER +#define FIFO_SIZE 0x100 +#define DMA_SIZE 0x40 +#define FRM_LEN 0x100 + +#define ACP3x_ITER_IRER_SAMP_LEN_MASK 0x38 + +#define ACP_MAX_STREAM 6 + +struct acp_stream { + struct snd_pcm_substream *substream; + int irq_bit; + int dai_id; + int id; + u64 bytescount; + u32 reg_offset; + u32 pte_offset; + u32 fifo_offset; +}; + +struct acp_dev_data { + char *name; + struct device *dev; + void __iomem *acp_base; + unsigned int i2s_irq; + + /* SOC specific dais */ + struct snd_soc_dai_driver *dai_driver; + int num_dai; + + struct acp_stream *stream[ACP_MAX_STREAM]; +}; + +extern const struct snd_soc_dai_ops asoc_acp_cpu_dai_ops; + +int asoc_acp_i2s_probe(struct snd_soc_dai *dai); +int acp_platform_register(struct device *dev); +int acp_platform_unregister(struct device *dev); + +static inline u64 acp_get_byte_count(struct acp_dev_data *adata, int dai_id, int direction) +{ + u64 byte_count, low = 0, high = 0; + + if (direction == SNDRV_PCM_STREAM_PLAYBACK) { + switch (dai_id) { + case I2S_BT_INSTANCE: + high = readl(adata->acp_base + ACP_BT_TX_LINEARPOSITIONCNTR_HIGH); + low = readl(adata->acp_base + ACP_BT_TX_LINEARPOSITIONCNTR_LOW); + break; + case I2S_SP_INSTANCE: + high = readl(adata->acp_base + ACP_I2S_TX_LINEARPOSITIONCNTR_HIGH); + low = readl(adata->acp_base + ACP_I2S_TX_LINEARPOSITIONCNTR_LOW); + break; + default: + dev_err(adata->dev, "Invalid dai id %x\n", dai_id); + return -EINVAL; + } + } else { + switch (dai_id) { + case I2S_BT_INSTANCE: + high = readl(adata->acp_base + ACP_BT_RX_LINEARPOSITIONCNTR_HIGH); + low = readl(adata->acp_base + ACP_BT_RX_LINEARPOSITIONCNTR_LOW); + break; + case I2S_SP_INSTANCE: + high = readl(adata->acp_base + ACP_I2S_RX_LINEARPOSITIONCNTR_HIGH); + low = readl(adata->acp_base + ACP_I2S_RX_LINEARPOSITIONCNTR_LOW); + break; + default: + dev_err(adata->dev, "Invalid dai id %x\n", dai_id); + return -EINVAL; + } + } + /* Get 64 bit value from two 32 bit registers */ + byte_count = (high << 32) | low; + + return byte_count; +} + +#endif diff --git a/sound/soc/amd/acp/chip_offset_byte.h b/sound/soc/amd/acp/chip_offset_byte.h new file mode 100644 index 000000000000..c7f77e975dc7 --- /dev/null +++ b/sound/soc/amd/acp/chip_offset_byte.h @@ -0,0 +1,76 @@ +/* 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. + * + * Author: Ajit Kumar Pandey + */ + +#ifndef _ACP_IP_OFFSET_HEADER +#define _ACP_IP_OFFSET_HEADER + +#define ACPAXI2AXI_ATU_CTRL 0xC40 +#define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_5 0xC20 +#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_5 0xC24 +#define ACP_EXTERNAL_INTR_ENB 0x1800 +#define ACP_EXTERNAL_INTR_CNTL 0x1804 +#define ACP_EXTERNAL_INTR_STAT 0x1808 +#define ACP_I2S_PIN_CONFIG 0x1400 +#define ACP_SCRATCH_REG_0 0x12800 + +/* Registers from ACP_AUDIO_BUFFERS block */ + +#define ACP_I2S_RX_RINGBUFADDR 0x2000 +#define ACP_I2S_RX_RINGBUFSIZE 0x2004 +#define ACP_I2S_RX_LINKPOSITIONCNTR 0x2008 +#define ACP_I2S_RX_FIFOADDR 0x200C +#define ACP_I2S_RX_FIFOSIZE 0x2010 +#define ACP_I2S_RX_DMA_SIZE 0x2014 +#define ACP_I2S_RX_LINEARPOSITIONCNTR_HIGH 0x2018 +#define ACP_I2S_RX_LINEARPOSITIONCNTR_LOW 0x201C +#define ACP_I2S_RX_INTR_WATERMARK_SIZE 0x2020 +#define ACP_I2S_TX_RINGBUFADDR 0x2024 +#define ACP_I2S_TX_RINGBUFSIZE 0x2028 +#define ACP_I2S_TX_LINKPOSITIONCNTR 0x202C +#define ACP_I2S_TX_FIFOADDR 0x2030 +#define ACP_I2S_TX_FIFOSIZE 0x2034 +#define ACP_I2S_TX_DMA_SIZE 0x2038 +#define ACP_I2S_TX_LINEARPOSITIONCNTR_HIGH 0x203C +#define ACP_I2S_TX_LINEARPOSITIONCNTR_LOW 0x2040 +#define ACP_I2S_TX_INTR_WATERMARK_SIZE 0x2044 +#define ACP_BT_RX_RINGBUFADDR 0x2048 +#define ACP_BT_RX_RINGBUFSIZE 0x204C +#define ACP_BT_RX_LINKPOSITIONCNTR 0x2050 +#define ACP_BT_RX_FIFOADDR 0x2054 +#define ACP_BT_RX_FIFOSIZE 0x2058 +#define ACP_BT_RX_DMA_SIZE 0x205C +#define ACP_BT_RX_LINEARPOSITIONCNTR_HIGH 0x2060 +#define ACP_BT_RX_LINEARPOSITIONCNTR_LOW 0x2064 +#define ACP_BT_RX_INTR_WATERMARK_SIZE 0x2068 +#define ACP_BT_TX_RINGBUFADDR 0x206C +#define ACP_BT_TX_RINGBUFSIZE 0x2070 +#define ACP_BT_TX_LINKPOSITIONCNTR 0x2074 +#define ACP_BT_TX_FIFOADDR 0x2078 +#define ACP_BT_TX_FIFOSIZE 0x207C +#define ACP_BT_TX_DMA_SIZE 0x2080 +#define ACP_BT_TX_LINEARPOSITIONCNTR_HIGH 0x2084 +#define ACP_BT_TX_LINEARPOSITIONCNTR_LOW 0x2088 +#define ACP_BT_TX_INTR_WATERMARK_SIZE 0x208C + +#define ACP_I2STDM_IER 0x2400 +#define ACP_I2STDM_IRER 0x2404 +#define ACP_I2STDM_RXFRMT 0x2408 +#define ACP_I2STDM_ITER 0x240C +#define ACP_I2STDM_TXFRMT 0x2410 + +/* Registers from ACP_BT_TDM block */ + +#define ACP_BTTDM_IER 0x2800 +#define ACP_BTTDM_IRER 0x2804 +#define ACP_BTTDM_RXFRMT 0x2808 +#define ACP_BTTDM_ITER 0x280C +#define ACP_BTTDM_TXFRMT 0x2810 + +#endif From patchwork Thu Sep 30 13:24:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12528645 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75839C433F5 for ; Thu, 30 Sep 2021 15:15:23 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E3E8661882 for ; Thu, 30 Sep 2021 15:15:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E3E8661882 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 2B51116F0; Thu, 30 Sep 2021 17:14:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2B51116F0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633014921; bh=oLhKjFU5pvRv56gVRqt9U0/nxM5RCoUYm7GtoIv7WIA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qs/vHo4BGqi620ovx6UvkvY1evWwAII3f9LxKJKrbD12MKJ32GmvsP49wl2aacOct 84OTLJ7xfI4I6DjdZ9krrQcWEuB4ovBTzgoNRLgTbt4HtuTOe9jg9Hh82FuSfNtP8q 5hidRQt9oZBXx2McqtmN/qFavu+M9tm7lCyfjEUk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CCDCCF8051C; Thu, 30 Sep 2021 17:11:16 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8C821F804AD; Thu, 30 Sep 2021 15:25:41 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.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 28571F80218 for ; Thu, 30 Sep 2021 15:25:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 28571F80218 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="39LsFk69" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QjF8X31sJqdB8wy9obwAEfYP1Np39vPbUc+/lVWE0pCL7JBXAEif1AN1Tbn1prmvLHihum7gE2d255ozR3IV0+Z3dJjHZ8J2Wz0f2wrXESLNjds7/R+e7PGeCtNZoGtCT4FZvsFVm9Qgqa/V5zdhZq9uc9Wt7kdevIZmAkHocyK6TY+egAgVPYSTnVNJTKvmwoBynddUSkqV5ifCFHlodn0HVrZ/a/lqD/pzznOZ7UCSK2DQVHS7QPvnLfmQQAmOik+SOFCPI44IF/JDFrSRc5pjPv/CP/8DUCddEFfZG5Y86XgvkyC9r0ogOSzsMrxzg2atiLflRQLY8LHU3p+Bew== 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; bh=2n2dqUWu5HZ5rrTIVfmt0WbVouSIBeVO/X9Q0QCj5Wg=; b=NWuAncslVydguunmPMA0aM7316BX9KBe1wkFh/fWOkqHgWQypW7EyMxsq1wn+rBqlt3NDU5OG6MX6xjuzp+3qeudIm0LjgxLPTZ+Bza2qjNx7rm/EW8KCtAFCQ+vvd9HWy71X4A2lTfnzC2BnphCi45vOt5ZKlDmG5r0Vvux2EbCwYkDrKwAj7yTwd/ZeSWvnQeh7MB5cDaepeJ39OLSWuTt/ZA6/tjtfFtwe7X/vYSDhZA62J9WPpLBv2Z4Dg+lJAi3jnOGC731XfVmbMcC19u99o2L4Z0vJuY36C9kLK9bgAIc+ndP8jGqXCAnEyeJ4KFxPhSNedTdhOeQI4xzCA== 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=2n2dqUWu5HZ5rrTIVfmt0WbVouSIBeVO/X9Q0QCj5Wg=; b=39LsFk69Y+CpHUwS+MyNM/2hw0RRAOITyhDNz1Fea0LbT1tgVuqeUeMDvimLpzM7AsUuNomfTmdh43QYlOXYOFkoVSP9iS9Q+nHZQa6QQRoqWPktAkRvA3oE8ZWL90ZejDDO2KDeESolRVDJcKdFvjbTt7yRPHaFY+h3qOHh5oQ= Received: from DM6PR06CA0012.namprd06.prod.outlook.com (2603:10b6:5:120::25) by BL0PR12MB4913.namprd12.prod.outlook.com (2603:10b6:208:1c7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15; Thu, 30 Sep 2021 13:25:26 +0000 Received: from DM6NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::f9) by DM6PR06CA0012.outlook.office365.com (2603:10b6:5:120::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Thu, 30 Sep 2021 13:25:25 +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=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by DM6NAM11FT014.mail.protection.outlook.com (10.13.173.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:25:25 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 08:25:24 -0500 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.8 via Frontend Transport; Thu, 30 Sep 2021 08:25:20 -0500 From: Ajit Kumar Pandey To: , Subject: [PATCH 2/8] ASoC: amd: acp: Add I2S support on Renoir platform Date: Thu, 30 Sep 2021 18:54:12 +0530 Message-ID: <20210930132418.14077-3-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> References: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fbc87dcf-3c4b-45b5-bb99-08d98415c339 X-MS-TrafficTypeDiagnostic: BL0PR12MB4913: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3YDPlC/INLbkcbQOmE9knFJFZuuM8Ci6Cw/bqa+Fl4FikNHRIGQbLLtrJpXjdHp8aMifqX4jVDZmDXwz43+WJ9tnxu5bmTuL66ujJhsAQzFwYRbCwUKYAxQsZgwvFJtJ3c1DkCDnS9pKYJpF7bStLVEypyo2bd7kPFTBC3EaDidUIfooLdO3E+BoXhLXkHa2E5h3O4b3bbjFqQ4coMCc71zW4ggeKJp7oK+YX9EF5QFuvtXic3/ILokUDulmiolqg33SWrsovRtq0J9GY2h7tXVuJkK3RBcWmc+bcb1n866SwYW10kZ7B0m8P/gPxUNHYcqbUuAAgT5hxyaBSSBx++yMqQqc3OlYi4iwX8CHnbP0b/PjL8x4oeY8rv+vV3NRn9qAkobQYklz9LIWqoCsyCbGbtdxohlCffJNA8k0kbRkVJvH+uP2pAHObjn/I+NMtGpfiIv4X5OviEDtRP8oRq3n+oSiLXZ7fUVrIrD8ESF3nreWyhCaQxiyQrTE3j69zTOxpxGW6XHIOgFAAY+9sYVFchup2eL1D0REGQNWRtk5yaBEHuCVMOT4fIjJ0gheuDMaf04yO+axW9AByfONnQMzB1XxVSsWBMDafu6xeUY29LcrTN1pFWNsQmnXgQdwbTUAS4ARFtfzYGEpbBAd5y2gFbzxDGJT0+T0OQI867+1Fprq4bpC9qWO2ZjlXJjlOoQ/DEecAuZitt2TQUK/v0/DR5ow892US7aV7ypLeU8= 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)(46966006)(316002)(70586007)(2906002)(426003)(83380400001)(4326008)(86362001)(508600001)(6666004)(47076005)(8676002)(36860700001)(8936002)(1076003)(82310400003)(36756003)(2616005)(5660300002)(26005)(7696005)(356005)(70206006)(186003)(336012)(54906003)(81166007)(110136005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 13:25:25.3352 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fbc87dcf-3c4b-45b5-bb99-08d98415c339 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: DM6NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4913 X-Mailman-Approved-At: Thu, 30 Sep 2021 17:11:01 +0200 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" Add I2S dai driver for Renoir platform and register with common acp framework to support non dsp I2S use case on Renoir. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/Kconfig | 8 ++ sound/soc/amd/acp/Makefile | 5 ++ sound/soc/amd/acp/acp-renoir.c | 141 +++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 sound/soc/amd/acp/acp-renoir.c diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index 1ca815df6f23..a11182861f49 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -16,3 +16,11 @@ config SND_SOC_AMD_ACP_I2S config SND_SOC_AMD_ACP_PCM tristate + +config SND_AMD_ASOC_RENOIR + tristate "AMD ACP ASOC Renoir Support" + select SND_SOC_AMD_ACP_PCM + select SND_SOC_AMD_ACP_I2S + depends on X86 && PCI + help + This option enables Renoir I2S support on AMD platform diff --git a/sound/soc/amd/acp/Makefile b/sound/soc/amd/acp/Makefile index b2e12659d97b..42bff3515f24 100644 --- a/sound/soc/amd/acp/Makefile +++ b/sound/soc/amd/acp/Makefile @@ -8,5 +8,10 @@ snd-acp-pcm-objs := acp-platform.o snd-acp-i2s-objs := acp-i2s.o +#platform specific driver +snd-acp-renoir-objs := acp-renoir.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_AMD_ASOC_RENOIR) += snd-acp-renoir.o diff --git a/sound/soc/amd/acp/acp-renoir.c b/sound/soc/amd/acp/acp-renoir.c new file mode 100644 index 000000000000..c7fbf71e4669 --- /dev/null +++ b/sound/soc/amd/acp/acp-renoir.c @@ -0,0 +1,141 @@ +// 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 +// + +/* + * Hardware interface for Renoir ACP block + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "amd.h" + +#define DRV_NAME "acp_asoc_renoir" + +static struct snd_soc_dai_driver acp_renoir_dai[] = { +{ + .name = "acp-i2s-sp", + .id = I2S_SP_INSTANCE, + .playback = { + .stream_name = "I2S SP Playback", + .rates = SNDRV_PCM_RATE_8000_96000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 96000, + }, + .capture = { + .stream_name = "I2S SP Capture", + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .ops = &asoc_acp_cpu_dai_ops, + .probe = &asoc_acp_i2s_probe, +}, +{ + .name = "acp-i2s-bt", + .id = I2S_BT_INSTANCE, + .playback = { + .stream_name = "I2S BT Playback", + .rates = SNDRV_PCM_RATE_8000_96000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 96000, + }, + .capture = { + .stream_name = "I2S BT Capture", + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .ops = &asoc_acp_cpu_dai_ops, + .probe = &asoc_acp_i2s_probe, +}, +}; + +static int renoir_audio_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct acp_dev_data *adata; + struct resource *res; + + adata = devm_kzalloc(dev, sizeof(struct acp_dev_data), GFP_KERNEL); + if (!adata) + return -ENOMEM; + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "acp_mem"); + if (!res) { + dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n"); + return -ENODEV; + } + + adata->acp_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (!adata->acp_base) + return -ENOMEM; + + res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "acp_dai_irq"); + if (!res) { + dev_err(&pdev->dev, "IORESOURCE_IRQ FAILED\n"); + return -ENODEV; + } + + adata->i2s_irq = res->start; + adata->dev = dev; + adata->dai_driver = acp_renoir_dai; + adata->num_dai = ARRAY_SIZE(acp_renoir_dai); + + dev_set_drvdata(dev, adata); + acp_platform_register(dev); + + return 0; +} + +static int renoir_audio_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + + acp_platform_unregister(dev); + return 0; +} + +static struct platform_driver renoir_driver = { + .probe = renoir_audio_probe, + .remove = renoir_audio_remove, + .driver = { + .name = "acp_asoc_renoir", + }, +}; + +module_platform_driver(renoir_driver); + +MODULE_DESCRIPTION("AMD ACP Renoir Driver"); +MODULE_IMPORT_NS(SND_SOC_ACP_COMMON); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_ALIAS("platform:" DRV_NAME); From patchwork Thu Sep 30 13:24:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12528647 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1370C433F5 for ; Thu, 30 Sep 2021 15:15:46 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 324CD6159A for ; Thu, 30 Sep 2021 15:15:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 324CD6159A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 B8A8316C2; Thu, 30 Sep 2021 17:14:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B8A8316C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633014944; bh=JOYBLl+X0JeZM/uvqUn29k0qdtbkcCSkKoYutfLi/uc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=dcmSDMGwZ2Y/XEk1yt0bkREeR1iHmCgUzmgE8vyqp1oYF7wieIEjo4NGN0BVImWgg w6Dv6msX5YY2tPul4W3WTyOv3GTwlUn47dRR5vXT+8OEl9MYstGwb5T7i59ndPztux Ad+/rj95AjaqgVFmnnzCDrUu/2ctrriQEbypM1FI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9E856F8051E; Thu, 30 Sep 2021 17:11:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B9ED6F804AD; Thu, 30 Sep 2021 15:26:08 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2085.outbound.protection.outlook.com [40.107.236.85]) (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 340CFF800F3 for ; Thu, 30 Sep 2021 15:26:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 340CFF800F3 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="cD6gVybx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kzpBQi0x8sj8zV1DUhj4EzRImL3W+Gd5FAyvV/FNoXAscd04L7/kXwDM5ksA6vEuggh02pLnDNKjFmpLqQrFstLtCyeMaz2dWCIXzPMdeonjohZQZEtcecTlLhTAgtte14owgIOVseKV4pOXlJqbIBeSXo4dndyobS4KZmmAz5Ea6jUB6RFnUnBxt6AThQj5JoATM0s0nJpwH9PHIO9UMm0GiJwPbleVjzZ+qF52Uo0PZIzvE8mLszyaXzVu/Qc4NSW4r338BXsIahkM1kbBpBGo1WM9XHJtMMIHqBedOrU65jm4vuMizeywEZPQR8/HszDjThRbskyD8W5MXO9UPQ== 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; bh=d/OTof6Ymf+CwCCnmj7UPYheS7OVe3cW30zBhzZWBiI=; b=gdTkC7inwOohWwaUHAI0jkG0JGCJ9MVVSFVVH0Bva2BFb4olGiub8RBSvk20SR34HlGIEGytOAnFJ1mN8VsGkrhZG6sBmbLw1dT2kumHWpOk84BKsunm92bkc28ujQimKP8Sn5GhHexGWJ8cJfwgGZUTC6W9ySNmR4M6+8gi2Umc8j+g1QoC60rkzCBhqlea6nZ7emz5HDUPVJmsbu9HCjgVZmqT7UYKMAqdpQySUsJGmYmSChRLoFubVa8O574+RLFQLTTCWmbv90VJYNEetuMWAJTymT9BE/nHTHSJvX+3SwwQR+a+RLvnJvBWNUGFSNA7czcIR9bdXL9eM7iLvw== 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=d/OTof6Ymf+CwCCnmj7UPYheS7OVe3cW30zBhzZWBiI=; b=cD6gVybx/PK/c0gwBj4Esdbi/+KzXyZIVeSgvAgzrX4Ryhga7gafIPTPIvir2waxAOG5Pysa39oZHOA5DbC6I/NXPa19eEsLYilRBK5EmDsOU+cqtl2VFR932j+YiCTcUtSx+U4a/1MYhB+QhutqSVUQv5RVOH7gJw81dKXxm0Q= Received: from DM5PR17CA0062.namprd17.prod.outlook.com (2603:10b6:3:13f::24) by DM6PR12MB4731.namprd12.prod.outlook.com (2603:10b6:5:35::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 30 Sep 2021 13:25:56 +0000 Received: from DM6NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:3:13f:cafe::f2) by DM5PR17CA0062.outlook.office365.com (2603:10b6:3:13f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:25:56 +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=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by DM6NAM11FT023.mail.protection.outlook.com (10.13.173.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:25:56 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 08:25:53 -0500 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.8 via Frontend Transport; Thu, 30 Sep 2021 08:25:50 -0500 From: Ajit Kumar Pandey To: , Subject: [PATCH 3/8] ASoC: amd: acp: Add callback for machine driver on ACP Date: Thu, 30 Sep 2021 18:54:13 +0530 Message-ID: <20210930132418.14077-4-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> References: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d253ffe-cf2b-4575-2120-08d98415d5a7 X-MS-TrafficTypeDiagnostic: DM6PR12MB4731: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9vvmL1b/skfJeKi99Dl9gZiTSdLKnFmHGhUSdTZ8SMf24PnP0aHOHlol17H6R+CZRsw99CnPhoWOwRefKKXqYnLJipVLgCgSeVdh3DA4Z2mr010j4p/Ax2llPYeitIW6Nfk+OtkOSgkdXOyWIfsU0BvMDeVRjISAGuO7ismqymhACPikNwnbnSDUsJdUNlFi2hejpltryeJSM+pi74hdgPt6OlUMmNLxACmi4m5Ko7VCIQrSpmxfRuND/HziqUm+gKQ5M0fuglPEcojjJepPSL7tH1Qgsc0W6NYW6A0yaf1RPpzlTFTqzCRXb9d9OkEmMDSIGXVPV1rm8a9xa5uTH0mCLy1qBULx8giNghEhE8265h4lPJ2vyxkYiHa+9vwEOwGkvzg/6DpwW+jAKT4xF2vblZLft0DkBQWuO2jMSuJpGiUTcng4v4FDjZ/C1/r2Gu7gVUIQEY+Ea/pFKjemASUTdKmAtCPyxqMVuNWL015JGDergt2hAAK7KsudmpDkhv4/xIRXO86vevkJ8KtVyL1jCPFFEpvmyOi14PtL4iJ8hZ+Eb2NsCwr6xw1kDQvfBORafyWzg2XDk6gmxEWuzRAyb/cx4tSU70WYhKfwRPAiemb8yfYrsso9PH8Ak6bIgBfVp4QJGyZJ8olvMKYOfwBFqMsMQDuSwfcJzRqNXBb7oJMBuV+NEbOeFgSxKwZusKE/LTvfy1mjm09Cg7yWIqoXvaSdSg1XnLVRPuVvO4g= 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)(46966006)(47076005)(8936002)(83380400001)(86362001)(36756003)(54906003)(81166007)(356005)(7696005)(2616005)(5660300002)(186003)(4326008)(36860700001)(6666004)(426003)(1076003)(8676002)(2906002)(508600001)(316002)(26005)(336012)(70206006)(70586007)(82310400003)(110136005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 13:25:56.2515 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d253ffe-cf2b-4575-2120-08d98415d5a7 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: DM6NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4731 X-Mailman-Approved-At: Thu, 30 Sep 2021 17:11:01 +0200 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" Add method to select and register machine driver for acp platform based on ACPI ID. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/acp-platform.c | 23 +++++++++++++++++++++++ sound/soc/amd/acp/acp-renoir.c | 3 +++ sound/soc/amd/acp/amd.h | 6 ++++++ 3 files changed, 32 insertions(+) diff --git a/sound/soc/amd/acp/acp-platform.c b/sound/soc/amd/acp/acp-platform.c index 2eec2133b4fc..5d575c06fd9c 100644 --- a/sound/soc/amd/acp/acp-platform.c +++ b/sound/soc/amd/acp/acp-platform.c @@ -67,6 +67,27 @@ static const struct snd_pcm_hardware acp_pcm_hardware_capture = { .periods_max = CAPTURE_MAX_NUM_PERIODS, }; +int acp_machine_select(struct acp_dev_data *adata) +{ + struct snd_soc_acpi_mach *mach; + int size; + + size = sizeof(*adata->machines); + mach = snd_soc_acpi_find_machine(adata->machines); + if (!mach) { + dev_err(adata->dev, "warning: No matching ASoC machine driver found\n"); + return -EINVAL; + } + + adata->mach_dev = platform_device_register_data(adata->dev, mach->drv_name, + PLATFORM_DEVID_NONE, mach, size); + if (!adata->mach_dev) + dev_warn(adata->dev, "Unable to register Machine device\n"); + + return 0; +} +EXPORT_SYMBOL_NS(acp_machine_select, SND_SOC_ACP_COMMON); + static irqreturn_t i2s_irq_handler(int irq, void *data) { struct acp_dev_data *adata = data; @@ -283,6 +304,8 @@ int acp_platform_unregister(struct device *dev) { struct acp_dev_data *adata = dev_get_drvdata(dev); + if (adata->mach_dev) + platform_device_unregister(adata->mach_dev); return 0; } EXPORT_SYMBOL_NS(acp_platform_unregister, SND_SOC_ACP_COMMON); diff --git a/sound/soc/amd/acp/acp-renoir.c b/sound/soc/amd/acp/acp-renoir.c index c7fbf71e4669..82faae1b110b 100644 --- a/sound/soc/amd/acp/acp-renoir.c +++ b/sound/soc/amd/acp/acp-renoir.c @@ -111,6 +111,9 @@ static int renoir_audio_probe(struct platform_device *pdev) adata->dai_driver = acp_renoir_dai; adata->num_dai = ARRAY_SIZE(acp_renoir_dai); + adata->machines = snd_soc_acpi_amd_acp_machines; + acp_machine_select(adata); + dev_set_drvdata(dev, adata); acp_platform_register(dev); diff --git a/sound/soc/amd/acp/amd.h b/sound/soc/amd/acp/amd.h index ecb53285526c..3532f4d3ccff 100644 --- a/sound/soc/amd/acp/amd.h +++ b/sound/soc/amd/acp/amd.h @@ -90,6 +90,9 @@ struct acp_dev_data { int num_dai; struct acp_stream *stream[ACP_MAX_STREAM]; + + struct snd_soc_acpi_mach *machines; + struct platform_device *mach_dev; }; extern const struct snd_soc_dai_ops asoc_acp_cpu_dai_ops; @@ -98,6 +101,9 @@ int asoc_acp_i2s_probe(struct snd_soc_dai *dai); int acp_platform_register(struct device *dev); int acp_platform_unregister(struct device *dev); +int acp_machine_select(struct acp_dev_data *adata); +extern struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[]; + static inline u64 acp_get_byte_count(struct acp_dev_data *adata, int dai_id, int direction) { u64 byte_count, low = 0, high = 0; From patchwork Thu Sep 30 13:24:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12528649 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E02A5C433F5 for ; Thu, 30 Sep 2021 15:16:05 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1F64A61881 for ; Thu, 30 Sep 2021 15:16:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1F64A61881 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 B26C916CA; Thu, 30 Sep 2021 17:15:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B26C916CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633014963; bh=GAK5D/BGrUMw4HQX4CrqhNbZTAKHPYxDfb2Ecjhr4zI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=X8S1lrfn2Z7eOaXdxsbWuOqNDQX4BVs0UigrG+bn5PX2FuaGws7sPTe6XAjzTG/Ck FMRn7MtOjm/Gif6ZFKRPkxtivJB8ZCxunLyYYDXn1fzXktBaYoePUJ04xlNSpFj59d SqYWfGprzrQ3+OOifYhPYSdySgDQn5644e9ojMxw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EB829F80527; Thu, 30 Sep 2021 17:11:18 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D00ACF804AD; Thu, 30 Sep 2021 15:27:17 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2064.outbound.protection.outlook.com [40.107.92.64]) (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 6D377F80218 for ; Thu, 30 Sep 2021 15:27:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6D377F80218 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="IAcYkM6G" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mE2RcdJJ6azWY5KDrQefZHuWZxD7C272K1j/YZ16VuS3iEN8hN9KHOMNBJ24U3l8/Kvu0UzXtzvnfqANzYyaBCLjUjE26hot6VZ3F4rhzpmuTJsvnFMFEQOm3lApGTafGEZBeHCSzmFoiYBrzDOh2mLM+e8zv/iBrGKZd+ivukn0BMAY/IGxYcYa11OyeqKPbQclLfzuhzCKhUbz4nAAcdaJi/rbYL/SD5WXbBBVU+qZsKerlyYYjlrdc7ylKXNLjwRQ9h3rLI6JKgfmXYtvoux4lehvWJveGdmjWhBE1OThlx3fW2Ggo6NkHJcqmeLmReTrHqV3n8boUrVKWvAAew== 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; bh=3FI8gzrKIoFBpnXXtCNFglPxYmBgpzgovF/4f2Zh9tQ=; b=SDsblYkydTvsnnSi/l3G5Kkazys8rKJLfChXv4dENEoCh/UK+YlAwHRMr+NRFD7jEm2FrnFUtI7R/ihzKpYTiDYSe+ZbEZRZ3QWd7PJzUNh1d9ap5RlvSGNu8oAM/BkYBeoNfAqVhXDSqgDcPh9qoqOE/imSKAkLjB118Zfu2r7BJI8BxDIV+dvOc9SR+3764vtV7Lt4cWMNFr+5uvfDG+/ZfKZ7y5ph7QEjWqjgSG35B7m7PpXSIStTn2GLLvOMdVGx0ZLkBqPgeRFrpJfhZpfDZlw59bFZMtM3nZFPR5qmq/wA/K23vI1gwo8WYdy9ptyP9CKRGmCfYA8k3JuWEg== 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=3FI8gzrKIoFBpnXXtCNFglPxYmBgpzgovF/4f2Zh9tQ=; b=IAcYkM6GHnz7B+JF++8/aPjeJl8bSgP6NhEfhl/7XMEh6HgxE/L8KXKgR2818FoUgNCbOdUchdxr+W3816Ao6bVPS9k8EIU6rRTgUwjx4lZtUMS5s+j5uG6OjoD/SncxTg4ombUYVZuPWO1QnvPNBu3Fvt8vQcPXvHrK7znznzk= Received: from BN8PR04CA0047.namprd04.prod.outlook.com (2603:10b6:408:d4::21) by MWHPR12MB1869.namprd12.prod.outlook.com (2603:10b6:300:111::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15; Thu, 30 Sep 2021 13:27:05 +0000 Received: from BN8NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::5) by BN8PR04CA0047.outlook.office365.com (2603:10b6:408:d4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:27:05 +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 BN8NAM11FT033.mail.protection.outlook.com (10.13.177.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:27:05 +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.2308.8; Thu, 30 Sep 2021 08:27:04 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 08:27:03 -0500 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.8 via Frontend Transport; Thu, 30 Sep 2021 08:27:00 -0500 From: Ajit Kumar Pandey To: , Subject: [PATCH 4/8] ASoC: amd: acp: Add generic machine driver support for ACP cards Date: Thu, 30 Sep 2021 18:54:14 +0530 Message-ID: <20210930132418.14077-5-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> References: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d63ee09-8558-4fdb-4fbe-08d98415feac X-MS-TrafficTypeDiagnostic: MWHPR12MB1869: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:644; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xpZzppTK8XOsxBf+zwznvEl9suOgwSKUSJStdUGnSw4q+rOa4/eRM4DRnWaoNseS0ganzwnLs8UyKZ9gmGAaMm6koqUdjG4tj+MJq/9SwpcrSumhwoswmIM8TCKZADefOr9vAu0Ali2aGxtom9J+uhheCd4+wyu7VEeG3vDQLpePZGIMTA0gN1y2HjhFqxDTC3MmpmXNrTc3AsIPWj941j4eqz5jnLuKltVZCqQqKjMkdblAOuydVLLw8qJCRWKFhO6cc79vmECjAMaau8MrbFkUGbXZb6CIa/Wl8G6gUNPHhXgtFw8S2am1Fqn09/9yFeARPIx+WTPB8U5XhAMt0UzcbsZbUguLUcVINTJkC+iMnErxOqjKpD0dIhTnm/nfAsLoEJ3LfJ1wj1ffxHXsEX9QuAYIPqRopK8jSx7faeZSWg9LoikKwgsh2Wc38MjgCA+PWk9kSla3qVWgR9BFbDPc4MSrFMCNKtCWCdIVSPKNlApPN753sWx9YxWZJR6bvxZ5adRj93V+r/d/DMJem8W6kyZHOvVgPuk9wl+mFB+SIrjTQFnooIWl67+fOciaXN4GsyPLo4TRQ8ORsdIzWZQ1LWQLr2WaRv9XQMYTukxjPt3xnMDhQVdXKniqAhBDyIfymZ99zRP5q5/rOt/vsCNK3s+R8Li5Duyy3jouFaZ5sEKWcYp2YzJ48IDFbQOCyB7dsiOJuvyp9kI70V748vtwSy7JyLvOCcVdMYlH+obFN0MwRBmRgXih+DlhwoZyS3RMm1W2d6phySn4FzsLlg== 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)(2616005)(110136005)(5660300002)(36756003)(316002)(70586007)(2906002)(8676002)(30864003)(83380400001)(4326008)(8936002)(82310400003)(47076005)(7696005)(54906003)(70206006)(81166007)(186003)(36860700001)(508600001)(356005)(1076003)(6666004)(86362001)(426003)(26005)(336012)(41533002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 13:27:05.0767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d63ee09-8558-4fdb-4fbe-08d98415feac 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: BN8NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1869 X-Mailman-Approved-At: Thu, 30 Sep 2021 17:11:01 +0200 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" We have machines with differents audio endpoints configurations across various distributions. We need to support multiple sound cards for different combinations of I2S instance and codecs hw. Now we also need to support SOF-DSP endpoints based sound cards. All such card combinations slightly differs in terms of machine ops callback. This patch adds ACP generic machine driver module exposes method to create ACP cards dai links and define generic ops for audio endpoints configurations. Initially we have added dailink support for RT5682 and RT1019 codec connection with ACP I2S_SP instance. We will add newer codecs in this module to use this for all AMD's ACP block sound cards supports in future. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/Kconfig | 9 + sound/soc/amd/acp/Makefile | 5 + sound/soc/amd/acp/acp-mach-common.c | 511 ++++++++++++++++++++++++++++ sound/soc/amd/acp/acp-mach.h | 55 +++ 4 files changed, 580 insertions(+) create mode 100644 sound/soc/amd/acp/acp-mach-common.c create mode 100644 sound/soc/amd/acp/acp-mach.h diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index a11182861f49..1ad811707a68 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -24,3 +24,12 @@ config SND_AMD_ASOC_RENOIR depends on X86 && PCI help This option enables Renoir I2S support on AMD platform + +config SND_SOC_AMD_MACH_COMMON + tristate + select SND_SOC_RT5682_I2C + select SND_SOC_DMIC + select SND_SOC_RT1019 + depends on X86 && PCI && I2C + help + This option enables common Machine driver module for ACP diff --git a/sound/soc/amd/acp/Makefile b/sound/soc/amd/acp/Makefile index 42bff3515f24..a477a18272bf 100644 --- a/sound/soc/amd/acp/Makefile +++ b/sound/soc/amd/acp/Makefile @@ -11,7 +11,12 @@ snd-acp-i2s-objs := acp-i2s.o #platform specific driver snd-acp-renoir-objs := acp-renoir.o +#machine specific driver +snd-acp-mach-objs := acp-mach-common.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_AMD_ASOC_RENOIR) += snd-acp-renoir.o + +obj-$(CONFIG_SND_SOC_AMD_MACH_COMMON) += snd-acp-mach.o diff --git a/sound/soc/amd/acp/acp-mach-common.c b/sound/soc/amd/acp/acp-mach-common.c new file mode 100644 index 000000000000..cc507c520317 --- /dev/null +++ b/sound/soc/amd/acp/acp-mach-common.c @@ -0,0 +1,511 @@ +// 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 +// + +/* + * Machine Driver Interface for ACP HW block + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "../../codecs/rt5682.h" +#include "../../codecs/rt1019.h" +#include "acp-mach.h" + +#define PCO_PLAT_CLK 48000000 +#define RT5682_PLL_FREQ (48000 * 512) +#define DUAL_CHANNEL 2 +#define FOUR_CHANNEL 4 + +static struct snd_soc_jack pco_jack; + +static const unsigned int channels[] = { + DUAL_CHANNEL, +}; + +static const unsigned int rates[] = { + 48000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, + .mask = 0, +}; + +static const struct snd_pcm_hw_constraint_list constraints_channels = { + .count = ARRAY_SIZE(channels), + .list = channels, + .mask = 0, +}; + +static int acp_clk_enable(struct acp_card_drvdata *drvdata) +{ + clk_set_rate(drvdata->wclk, 48000); + clk_set_rate(drvdata->bclk, 48000 * 64); + + return clk_prepare_enable(drvdata->wclk); +} + +/* Declare RT5682 codec components */ +SND_SOC_DAILINK_DEF(rt5682, + DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5682:00", "rt5682-aif1"))); + +static const struct snd_soc_dapm_route rt5682_map[] = { + { "Headphone Jack", NULL, "HPOL" }, + { "Headphone Jack", NULL, "HPOR" }, + { "IN1P", NULL, "Headset Mic" }, +}; + +/* Declare RT1019 codec components */ +SND_SOC_DAILINK_DEF(rt1019, + DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC1019:01", "rt1019-aif"), + COMP_CODEC("i2c-10EC1019:02", "rt1019-aif"))); + +static const struct snd_soc_dapm_route rt1019_map_lr[] = { + { "Left Spk", NULL, "Left SPO" }, + { "Right Spk", NULL, "Right SPO" }, +}; + +static struct snd_soc_codec_conf rt1019_conf[] = { + { + .dlc = COMP_CODEC_CONF("i2c-10EC1019:01"), + .name_prefix = "Left", + }, + { + .dlc = COMP_CODEC_CONF("i2c-10EC1019:02"), + .name_prefix = "Right", + }, +}; + +/* Declare DMIC codec components */ +SND_SOC_DAILINK_DEF(dmic_codec, + DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi"))); + +/* Define card ops for HEADSET CODEC */ +static int acp_asoc_hs_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_card *card = rtd->card; + struct acp_card_drvdata *drvdata = card->drvdata; + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); + struct snd_soc_component *component = codec_dai->component; + unsigned int pll_id, pll_src, freq_in, freq_out; + const char *wclk_name, *bclk_name; + unsigned int clk_id, clk_freq; + int ret; + + dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name); + + /* Do nothing for dummy codec */ + if (!drvdata->hs_codec_id) + return 0; + + switch (drvdata->hs_codec_id) { + case RT5682: + pll_id = RT5682_PLL2; + pll_src = RT5682_PLL2_S_MCLK; + freq_in = PCO_PLAT_CLK; + freq_out = RT5682_PLL_FREQ; + clk_id = RT5682_SCLK_S_PLL2; + clk_freq = RT5682_PLL_FREQ; + wclk_name = "rt5682-dai-wclk"; + bclk_name = "rt5682-dai-bclk"; + drvdata->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBP_CFP; + snd_soc_dapm_add_routes(&rtd->card->dapm, rt5682_map, ARRAY_SIZE(rt5682_map)); + break; + default: + dev_err(rtd->dev, "Invalid codec id %d\n", drvdata->hs_codec_id); + return -EINVAL; + } + + ret = snd_soc_dai_set_fmt(codec_dai, drvdata->dai_fmt); + if (ret < 0) { + dev_err(rtd->card->dev, "Failed to set dai fmt: %d\n", ret); + return ret; + } + + ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_src, freq_in, freq_out); + if (ret < 0) { + dev_err(rtd->dev, "Failed to set codec PLL: %d\n", ret); + return ret; + } + + ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, clk_freq, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(rtd->dev, "Failed to set codec SYSCLK: %d\n", ret); + return ret; + } + + /* Set tdm/i2s1 master bclk ratio */ + ret = snd_soc_dai_set_bclk_ratio(codec_dai, 64); + if (ret < 0) { + dev_err(rtd->dev, "Failed to set rt5682 tdm bclk ratio: %d\n", ret); + return ret; + } + + drvdata->wclk = clk_get(component->dev, wclk_name); + drvdata->bclk = clk_get(component->dev, bclk_name); + + ret = snd_soc_card_jack_new(card, "Headset Jack", + SND_JACK_HEADSET | SND_JACK_LINEOUT | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3, + &pco_jack, NULL, 0); + if (ret) { + dev_err(card->dev, "HP jack creation failed %d\n", ret); + return ret; + } + + snd_jack_set_key(pco_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); + snd_jack_set_key(pco_jack.jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); + snd_jack_set_key(pco_jack.jack, SND_JACK_BTN_2, KEY_VOLUMEUP); + snd_jack_set_key(pco_jack.jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); + + ret = snd_soc_component_set_jack(component, &pco_jack, NULL); + if (ret) { + dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret); + return ret; + } + + return ret; +} + +static int acp_card_hs_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_card *card = rtd->card; + struct acp_card_drvdata *drvdata = card->drvdata; + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); + unsigned int ret = 0; + + /* Do nothing for dummy codec */ + if (!drvdata->hs_codec_id) + return 0; + + ret = snd_soc_dai_set_fmt(codec_dai, drvdata->dai_fmt); + if (ret < 0) { + dev_err(rtd->card->dev, "Failed to set dai fmt: %d\n", ret); + return ret; + } + + runtime->hw.channels_max = DUAL_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + &constraints_rates); + + ret = acp_clk_enable(drvdata); + if (ret < 0) + dev_err(rtd->card->dev, "Failed to enable HS clk: %d\n", ret); + + return ret; +} + +static void acp_card_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_card *card = rtd->card; + struct acp_card_drvdata *drvdata = card->drvdata; + + /* Do nothing for dummy codec */ + if (!drvdata->hs_codec_id && drvdata->amp_codec_id) + return; + + clk_disable_unprepare(drvdata->wclk); +} + +static const struct snd_soc_ops acp_asoc_hs_ops = { + .startup = acp_card_hs_startup, + .shutdown = acp_card_shutdown, +}; + +/* Define ops for AMPLIFIER */ +static int acp_asoc_amp_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_card *card = rtd->card; + struct acp_card_drvdata *drvdata = card->drvdata; + + /* Do nothing for dummy codec */ + if (!drvdata->amp_codec_id) + return 0; + + switch (drvdata->amp_codec_id) { + case RT1019: + return snd_soc_dapm_add_routes(&rtd->card->dapm, rt1019_map_lr, + ARRAY_SIZE(rt1019_map_lr)); + default: + dev_err(card->dev, "Invalid AMP id: %d\n", drvdata->amp_codec_id); + return -EINVAL; + } +} + +static int acp_card_amp_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct acp_card_drvdata *drvdata = card->drvdata; + struct snd_soc_dai *codec_dai; + int srate, i, ret = 0; + + srate = params_rate(params); + + /* Do nothing for dummy codec */ + if (!drvdata->amp_codec_id) + return 0; + + switch (drvdata->amp_codec_id) { + case RT1019: + for_each_rtd_codec_dais(rtd, i, codec_dai) { + if (strcmp(codec_dai->name, "rt1019-aif")) + continue; + + ret = snd_soc_dai_set_pll(codec_dai, 0, RT1019_PLL_S_BCLK, + 64 * srate, 256 * srate); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_sysclk(codec_dai, RT1019_SCLK_S_PLL, + 256 * srate, SND_SOC_CLOCK_IN); + if (ret < 0) + return ret; + } + break; + default: + dev_err(card->dev, "Invalid AMP id: %d\n", drvdata->amp_codec_id); + return -EINVAL; + } + + return 0; +} + +static int acp_card_amp_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_card *card = rtd->card; + struct acp_card_drvdata *drvdata = card->drvdata; + int ret; + + runtime->hw.channels_max = DUAL_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + &constraints_rates); + + ret = acp_clk_enable(drvdata); + if (ret < 0) + dev_err(rtd->card->dev, "Failed to enable AMP clk: %d\n", ret); + + return ret; +} + +static const struct snd_soc_ops acp_card_amp_ops = { + .startup = acp_card_amp_startup, + .shutdown = acp_card_shutdown, + .hw_params = acp_card_amp_hw_params, +}; + +/* Declare ACP CPU components */ +static struct snd_soc_dai_link_component dummy_codec[] = { + { + .name = "snd-soc-dummy", + .dai_name = "snd-soc-dummy-dai", + } +}; + +static struct snd_soc_dai_link_component platform_component[] = { + { + .name = "acp_asoc_renoir.0", + } +}; + +static struct snd_soc_dai_link_component sof_component[] = { + { + .name = "0000:04:00.5", + } +}; + +SND_SOC_DAILINK_DEF(i2s_sp, + DAILINK_COMP_ARRAY(COMP_CPU("acp-i2s-sp"))); +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"))); + +int acp_sofdsp_dai_links_create(struct snd_soc_card *card) +{ + struct snd_soc_dai_link *links; + struct device *dev = card->dev; + struct acp_card_drvdata *drv_data = card->drvdata; + int i = 0, num_links = 0; + + if (drv_data->hs_cpu_id) + num_links++; + if (drv_data->amp_cpu_id) + num_links++; + if (drv_data->dmic_cpu_id) + num_links++; + + links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) * num_links, GFP_KERNEL); + if (!links) + return -ENOMEM; + + if (drv_data->hs_cpu_id == I2S_SP) { + links[i].name = "acp-headset-codec"; + links[i].id = HEADSET_BE_ID; + links[i].cpus = sof_sp; + links[i].num_cpus = ARRAY_SIZE(sof_sp); + links[i].platforms = sof_component; + links[i].num_platforms = ARRAY_SIZE(sof_component); + links[i].dpcm_playback = 1; + links[i].dpcm_capture = 1; + links[i].nonatomic = true; + links[i].no_pcm = 1; + links[i].init = acp_asoc_hs_init; + links[i].ops = &acp_asoc_hs_ops; + if (!drv_data->hs_codec_id) { + /* Use dummy codec if codec id not specified */ + links[i].codecs = dummy_codec; + links[i].num_codecs = ARRAY_SIZE(dummy_codec); + } + if (drv_data->hs_codec_id == RT5682) { + links[i].codecs = rt5682; + links[i].num_codecs = ARRAY_SIZE(rt5682); + } + i++; + } + + if (drv_data->amp_cpu_id == I2S_SP) { + links[i].name = "acp-amp-codec"; + links[i].id = AMP_BE_ID; + links[i].cpus = sof_sp; + links[i].num_cpus = ARRAY_SIZE(sof_sp); + links[i].platforms = sof_component; + links[i].num_platforms = ARRAY_SIZE(sof_component); + links[i].dpcm_playback = 1; + links[i].nonatomic = true; + links[i].no_pcm = 1; + links[i].ops = &acp_card_amp_ops; + links[i].init = acp_asoc_amp_init; + if (!drv_data->amp_codec_id) { + /* Use dummy codec if codec id not specified */ + links[i].codecs = dummy_codec; + links[i].num_codecs = ARRAY_SIZE(dummy_codec); + } + if (drv_data->amp_codec_id == RT1019) { + links[i].codecs = rt1019; + links[i].num_codecs = ARRAY_SIZE(rt1019); + card->codec_conf = rt1019_conf; + card->num_configs = ARRAY_SIZE(rt1019_conf); + } + 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 = sof_dmic; + links[i].num_cpus = ARRAY_SIZE(sof_dmic); + links[i].platforms = sof_component; + links[i].num_platforms = ARRAY_SIZE(sof_component); + links[i].dpcm_capture = 1; + links[i].nonatomic = true; + links[i].no_pcm = 1; + } + + card->dai_link = links; + card->num_links = num_links; + + return 0; +} +EXPORT_SYMBOL_NS(acp_sofdsp_dai_links_create, SND_SOC_AMD_MACH); + + +int acp_legacy_dai_links_create(struct snd_soc_card *card) +{ + struct snd_soc_dai_link *links; + struct device *dev = card->dev; + struct acp_card_drvdata *drv_data = card->drvdata; + int i = 0, num_links = 0; + + if (drv_data->hs_cpu_id) + num_links++; + if (drv_data->amp_cpu_id) + num_links++; + if (drv_data->dmic_cpu_id) + num_links++; + + links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) * num_links, GFP_KERNEL); + + if (drv_data->hs_cpu_id == I2S_SP) { + links[i].name = "acp-headset-codec"; + links[i].id = HEADSET_BE_ID; + links[i].cpus = i2s_sp; + links[i].num_cpus = ARRAY_SIZE(i2s_sp); + links[i].platforms = platform_component; + links[i].num_platforms = ARRAY_SIZE(platform_component); + links[i].dpcm_playback = 1; + links[i].dpcm_capture = 1; + links[i].init = acp_asoc_hs_init; + links[i].ops = &acp_asoc_hs_ops; + if (!drv_data->hs_codec_id) { + /* Use dummy codec if codec id not specified */ + links[i].codecs = dummy_codec; + links[i].num_codecs = ARRAY_SIZE(dummy_codec); + } + if (drv_data->hs_codec_id == RT5682) { + links[i].codecs = rt5682; + links[i].num_codecs = ARRAY_SIZE(rt5682); + } + i++; + } + + if (drv_data->amp_cpu_id == I2S_SP) { + links[i].name = "acp-amp-codec"; + links[i].id = AMP_BE_ID; + links[i].cpus = i2s_sp; + links[i].num_cpus = ARRAY_SIZE(i2s_sp); + links[i].platforms = platform_component; + links[i].num_platforms = ARRAY_SIZE(platform_component); + links[i].dpcm_playback = 1; + links[i].ops = &acp_card_amp_ops; + links[i].init = acp_asoc_amp_init; + if (!drv_data->amp_codec_id) { + /* Use dummy codec if codec id not specified */ + links[i].codecs = dummy_codec; + links[i].num_codecs = ARRAY_SIZE(dummy_codec); + } + if (drv_data->amp_codec_id == RT1019) { + links[i].codecs = rt1019; + links[i].num_codecs = ARRAY_SIZE(rt1019); + card->codec_conf = rt1019_conf; + card->num_configs = ARRAY_SIZE(rt1019_conf); + } + } + + card->dai_link = links; + card->num_links = num_links; + + return 0; +} +EXPORT_SYMBOL_NS(acp_legacy_dai_links_create, SND_SOC_AMD_MACH); + +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/amd/acp/acp-mach.h b/sound/soc/amd/acp/acp-mach.h new file mode 100644 index 000000000000..464fb7eb802d --- /dev/null +++ b/sound/soc/amd/acp/acp-mach.h @@ -0,0 +1,55 @@ +/* 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. + * + * Author: Ajit Kumar Pandey + */ +#ifndef __ACP_MACH_H +#define __ACP_MACH_H + +#include +#include +#include +#include +#include +#include +#include + +enum be_id { + HEADSET_BE_ID = 0, + AMP_BE_ID, + DMIC_BE_ID, +}; + +enum cpu_endpoints { + NONE = 0, + I2S_SP, + I2S_BT, + DMIC, +}; + +enum codec_endpoints { + DUMMY = 0, + RT5682, + RT1019, +}; + +struct acp_card_drvdata { + unsigned int hs_cpu_id; + unsigned int amp_cpu_id; + unsigned int dmic_cpu_id; + unsigned int hs_codec_id; + unsigned int amp_codec_id; + unsigned int dmic_codec_id; + unsigned int dai_fmt; + struct clk *wclk; + struct clk *bclk; +}; + +int acp_sofdsp_dai_links_create(struct snd_soc_card *card); +int acp_legacy_dai_links_create(struct snd_soc_card *card); + +#endif From patchwork Thu Sep 30 13:24:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12528651 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 928A6C433F5 for ; Thu, 30 Sep 2021 15:16:22 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C789C615E5 for ; Thu, 30 Sep 2021 15:16:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C789C615E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 696D416D6; Thu, 30 Sep 2021 17:15:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 696D416D6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633014980; bh=tbbDsE5JbM0gQi1PcuL8prxqKMVQ8jKbXNTAUe9MqwU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=IfQ0t1L3EE+GZFFfqXKfma2FTM0swrmIE6EdzDAd4qHfq1JWlL6M11GX52zCHZTs2 e0Eo1KWq6WpoFFjPeZdkwzCwn65LQsgR/qGTIKWBbNVv9SmsZdwv+9BJoAixMGgE6a GgF4MSndp3O8thm56knJ+2dGouY6A2LyozkmOycI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0120DF8052E; Thu, 30 Sep 2021 17:11:20 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A56BCF804AD; Thu, 30 Sep 2021 15:27:49 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2074.outbound.protection.outlook.com [40.107.102.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 A3EF9F80218 for ; Thu, 30 Sep 2021 15:27:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A3EF9F80218 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Dglub/VU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F3RbJrgwBWPd+MV3STzVEc/bPwIAq0MGg8Sc9FpgtIL6YtKSee8PfGpW5202h4akR9iIHauIZjw/xHPXnVXfGppmZ2BR4gQHUCCRwU6wih53ajZvRZ/w3+qUV+cnoEhRQdwq/lNcVvtCmjh9wQjO5WqREH/vr0WIX5cM9m2bP73G+fkv84Nucwz9ZHfaZGy++RExQVT8svoDTmYESVlcRXJj2QCKvInyZICKR+XTH4DG/q20CNpbvvqjaZMsp52L3ha9J6r8E9Fn6yO9ZVT2nfg7v8A3IyPAPWaQLp1uB9MQS0HYxsE5/9o1YNxSY7al9z1NvRqGDR4yfghth0+MlQ== 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; bh=PnqSKg26VzDvRzqAoRy8R01kG3MV7iGDE4g2ck6AtPU=; b=UgwlWj/4m6qAkAh43SgjKf31VyPOBT+1NQhPN4Bm9PIMBdVSYeDxyN9JYfDiLLXE7GHX9NNfXuRM0kbSScUbT9OeuEziULq3NoHht3N82Hyoz5XvK8Ihn9Yur0GGmaBmLDrZ9+kxmVv0zxX8zqtcZ8drOkn3nWittuVLvQeRtquRcp8XtRwlmpeg0kz5+KzgqSEM3d0h80gWazCGn66jkO+JcyNJTEmGfO3KDjW4KKgMPu5uirNSij71gNYBbQRCzjIpTpW7lNAjF3MYaJoqLlEcUJ6vnM3iRs2ldEVOjo7H7Ifamo5u5gMSFwC/EN77dXPqnBsTjxrs+Q9/p+RvUA== 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=PnqSKg26VzDvRzqAoRy8R01kG3MV7iGDE4g2ck6AtPU=; b=Dglub/VU8JIbH/6lkLssg601FIEukD2JOYXDCf0fO2hpDdQIpQDICNYnmYTnJMQZQTCwp4CLG6sT+zq09sWdfp5G6QWbIvlRSZaMHRuwATYPqnYw9i13CE22b6YsgHOOe9SLA5c9c/FuzOxtyuvC+NLng9XM6TRdv7oQiAOncHg= Received: from BN0PR04CA0140.namprd04.prod.outlook.com (2603:10b6:408:ed::25) by MN2PR12MB3870.namprd12.prod.outlook.com (2603:10b6:208:166::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 13:27:30 +0000 Received: from BN8NAM11FT062.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ed:cafe::98) by BN0PR04CA0140.outlook.office365.com (2603:10b6:408:ed::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:27:30 +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 BN8NAM11FT062.mail.protection.outlook.com (10.13.177.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:27:30 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 08:27:29 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 06:27:28 -0700 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.8 via Frontend Transport; Thu, 30 Sep 2021 08:27:25 -0500 From: Ajit Kumar Pandey To: , Subject: [PATCH 5/8] ASoC: amd: acp: Add legacy sound card support for Guybrush board Date: Thu, 30 Sep 2021 18:54:15 +0530 Message-ID: <20210930132418.14077-6-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> References: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab160141-1e23-477f-c7d4-08d984160d86 X-MS-TrafficTypeDiagnostic: MN2PR12MB3870: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kgMTk9RRCB7Tga3U/XgkFf/p3D1s4Ucoxi3R+2NX5UGkXwWC5cfWomIWRh0DTWmE4YgROx5hg08TpPRsvh7aDLGqmS6H5r2Jm9af1QmAI2m/w46xgkYngzsGA35gL3/ttgf9XViZeIzeJiOpBcHpfNJTdNOHQfv2sorPisc1KHSmOE2/Sgnu3zdcXz9Zvz4j2l+dGXXhZ7KYKiYUvZt4oFVg4PIU5JM+T9H0LlvSe7r9y/6ZKUXzr5DM5g7HmlZzkbmIRhNDQb/r2UWi/o/xEKeE40xnCP6jD8W96FmRG7fxs0pO22ZjpFgnYfANDJz5Z8w6wxN4p8h+1NPGV8AihJnV98V4HNaxbR20dwnj2xynM6WVbGTQNtlWip0xXIUunKIPkCZ/AFlOxsPUfg7uU5rNF4WndMp/HRus5y3ox9ditm+ZmLBwAQv7MXWyAsho9YfWFgv3rz01fuR8t1nSdzoPULXv2pjDpgRXerqYX9Bmx004sPvsuO/++zCi72jmm4JfvAX2Yg6r4Linx2SMy/nMNguO8B+xcBf/l9uYECdmMuYL7eNxK5fzROPOJ9GimZzggZLhlTgqcD/llpTdjHZ3UV/peoLCeyvDd3eJ2I7V4T1KTwt78BbFktQpEem0qx49+MeczfZNfGcUoAuVU0yvERwWdjyuZLtgZEfJhMSvFBhmpCziHfPXGQFssV1vho6m/0UyLyczAS4GQnX4fEvSDr3MmURCgh+mt8psufc= 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)(70586007)(2616005)(36756003)(86362001)(8676002)(2906002)(336012)(70206006)(508600001)(47076005)(8936002)(26005)(1076003)(316002)(110136005)(54906003)(36860700001)(426003)(7696005)(81166007)(5660300002)(6666004)(4326008)(356005)(83380400001)(82310400003)(186003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 13:27:30.0065 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ab160141-1e23-477f-c7d4-08d984160d86 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: BN8NAM11FT062.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3870 X-Mailman-Approved-At: Thu, 30 Sep 2021 17:11:01 +0200 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" Renoir based Guybrush board has RT5682 as primary headset codec and RT1019 Amp device connected to I2SSP ACP i2s controller. Add driver to register legacy sound card devices on guybrush board. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/Kconfig | 6 ++ sound/soc/amd/acp/Makefile | 2 + sound/soc/amd/acp/acp-legacy-mach.c | 104 ++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 sound/soc/amd/acp/acp-legacy-mach.c diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index 1ad811707a68..aea8766d20a0 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -33,3 +33,9 @@ config SND_SOC_AMD_MACH_COMMON depends on X86 && PCI && I2C help This option enables common Machine driver module for ACP + +config SND_SOC_AMD_LEGACY_MACH + tristate "AMD Legacy Machine Driver Support" + select SND_SOC_AMD_MACH_COMMON + help + This option enables legacy sound card support for ACP audio diff --git a/sound/soc/amd/acp/Makefile b/sound/soc/amd/acp/Makefile index a477a18272bf..aef6f981c770 100644 --- a/sound/soc/amd/acp/Makefile +++ b/sound/soc/amd/acp/Makefile @@ -13,6 +13,7 @@ snd-acp-renoir-objs := acp-renoir.o #machine specific driver snd-acp-mach-objs := acp-mach-common.o +snd-acp-legacy-mach-objs := acp-legacy-mach.o obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o @@ -20,3 +21,4 @@ obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o obj-$(CONFIG_SND_AMD_ASOC_RENOIR) += snd-acp-renoir.o obj-$(CONFIG_SND_SOC_AMD_MACH_COMMON) += snd-acp-mach.o +obj-$(CONFIG_SND_SOC_AMD_LEGACY_MACH) += snd-acp-legacy-mach.o diff --git a/sound/soc/amd/acp/acp-legacy-mach.c b/sound/soc/amd/acp/acp-legacy-mach.c new file mode 100644 index 000000000000..8313f371f249 --- /dev/null +++ b/sound/soc/amd/acp/acp-legacy-mach.c @@ -0,0 +1,104 @@ +// 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 +// + +/* + * Machine Driver Legacy Support for ACP HW block + */ + +#include +#include +#include +#include +#include + +#include "acp-mach.h" + +static struct acp_card_drvdata guybrush_data = { + .hs_cpu_id = I2S_SP, + .amp_cpu_id = I2S_SP, + .dmic_cpu_id = NONE, + .hs_codec_id = RT5682, + .amp_codec_id = RT1019, + .dmic_codec_id = NONE, +}; + +static const struct snd_kcontrol_new acp_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Spk"), + SOC_DAPM_PIN_SWITCH("Left Spk"), + SOC_DAPM_PIN_SWITCH("Right Spk"), + +}; + +static const struct snd_soc_dapm_widget acp_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("Spk", NULL), + SND_SOC_DAPM_SPK("Left Spk", NULL), + SND_SOC_DAPM_SPK("Right Spk", NULL), +}; + +static int acp_asoc_probe(struct platform_device *pdev) +{ + struct snd_soc_card *card = NULL; + struct device *dev = &pdev->dev; + int ret; + + if (!pdev->id_entry) + return -EINVAL; + + card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + card->dev = dev; + card->owner = THIS_MODULE; + card->name = pdev->id_entry->name; + card->dapm_widgets = acp_widgets; + card->num_dapm_widgets = ARRAY_SIZE(acp_widgets); + card->controls = acp_controls; + card->num_controls = ARRAY_SIZE(acp_controls); + card->drvdata = (struct acp_card_drvdata *)pdev->id_entry->driver_data; + + acp_legacy_dai_links_create(card); + + ret = devm_snd_soc_register_card(&pdev->dev, card); + if (ret) { + dev_err(&pdev->dev, + "devm_snd_soc_register_card(%s) failed: %d\n", + card->name, ret); + return ret; + } + + return 0; +} + +static const struct platform_device_id board_ids[] = { + { + .name = "rn-rt5682-rt1019", + .driver_data = (kernel_ulong_t)&guybrush_data, + }, + { } +}; +static struct platform_driver acp_asoc_audio = { + .driver = { + .name = "acp_mach", + }, + .probe = acp_asoc_probe, + .id_table = board_ids, +}; + +module_platform_driver(acp_asoc_audio); + +MODULE_IMPORT_NS(SND_SOC_AMD_MACH); +MODULE_DESCRIPTION("ACP chrome audio support"); +MODULE_ALIAS("platform:rn-rt5682-rt1019"); +MODULE_LICENSE("GPL v2"); From patchwork Thu Sep 30 13:24:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12528653 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F1A6C433F5 for ; Thu, 30 Sep 2021 15:16:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 001E26127B for ; Thu, 30 Sep 2021 15:16:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 001E26127B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 9ECD616AD; Thu, 30 Sep 2021 17:15:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9ECD616AD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633015003; bh=cZCye2tQ89qrn7x5MJOXevt3SkDtXNwwGsDoFGsEQh4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hyw7C+cWY+l6bNFIlZlJaXX69HGaHPzELXZLZvh69krKupFTqOlfypWNXddAaP4Nx giUZcqen2epal5UEaOat5CY9Ys66A/QzFdt/oPPyN3yvI25BSrpAMJfm71M+nVtUEp CatY3RSA/8LDg7ums9ANmP02qGL+q/DHmmzWROAk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6F6B6F80536; Thu, 30 Sep 2021 17:11:21 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 04108F80218; Thu, 30 Sep 2021 15:27:57 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2081.outbound.protection.outlook.com [40.107.220.81]) (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 8B459F804AD for ; Thu, 30 Sep 2021 15:27:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8B459F804AD Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="VZkyxJKR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O2odFR/jfcKDeG//C5tInQ9704B/Tcv77Bgw/0lVLfHVeen7VoCXk8VGHYBTd8T+MlVTsTkw17oJ1/Fb7kzrroQtUPWmi09X20RICarEYQmCd7SN8fKKPGg8VfZcgxxFU0A/+1cI05PECjFERQdC67L/0wYTuLt3P+5Q1vjgFFebRa2DpjqfA/imuBewGs4PomeGg/FOzcr5XHBqLxyo/+Wu5NDLLLEtvqUw2cihfwmWq1XB53LTsQiDCkHlD1kzn9EOgkmti64ZWDcAhKkm3MM4mD6dvnXOZyn9tLBkDhfCytqIhTsFShdFCIPZK+CylYBno8tsoC0IvtJ+2tDO/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; bh=ZSoK8bRWbL4+AMQ2UOgh37WazNqqAe3asPcE/VDcf8I=; b=ksDjrplj8Mbw+u9T+csmU7Qx6+04uvBtNDo6rEHRhhOXyrI1UFNNhKyEGQKpna3UbPlRUcdQ+rJfOfKNqK7hbjj6eeE5z7GOGSExFG3bPgO+Kc2m3H22uFg+RkaETZNJyRPo8p4oVwJQhHUhkE2FAlL66t2m903qRqQN+9Tle/F0UNhpD0JeEXHRwfz86fMGBKrhczr2AbONCw/fh1JPJ8BYDP27LPJJvu2tWREp0IX+N2f0VAz+mNeQKXM4xk5Um4hp8MRoUzIXkjCX6dcezpy6rW2ZqiJYslotd6Uf6/Bt3KFjEKLEt6xrnpGwKHxjC0VZ4pFrb2ecFTVmdI0Q6Q== 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=ZSoK8bRWbL4+AMQ2UOgh37WazNqqAe3asPcE/VDcf8I=; b=VZkyxJKRVs8m5RD0OTtgjgCsRxyji31pRwuiTGS2fD1li4gVqLlWg97AjbaXB3yUc8GywOI75l3nRdSFgYwTi8RUDsky0vfnEZH3WpPn7JLpDuOkl3CyReme/Ivfs78Rdtn9hKJo+7cXqgBm+EGuxA5HIC30uitcsTNap24UsPg= Received: from MW2PR2101CA0009.namprd21.prod.outlook.com (2603:10b6:302:1::22) by MWHPR1201MB0014.namprd12.prod.outlook.com (2603:10b6:300:e7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.18; Thu, 30 Sep 2021 13:27:46 +0000 Received: from CO1NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:302:1:cafe::60) 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.4587.2 via Frontend Transport; Thu, 30 Sep 2021 13:27:46 +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=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT030.mail.protection.outlook.com (10.13.174.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:27:45 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 08:27:44 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 06:27:43 -0700 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.8 via Frontend Transport; Thu, 30 Sep 2021 08:27:39 -0500 From: Ajit Kumar Pandey To: , Subject: [PATCH 6/8] ASoC: amd: acp: Add SOF sound card support on Guybrush board Date: Thu, 30 Sep 2021 18:54:16 +0530 Message-ID: <20210930132418.14077-7-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> References: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 80bf047c-b7a2-4ac9-2002-08d9841616da X-MS-TrafficTypeDiagnostic: MWHPR1201MB0014: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HvOB0bEQJp4T3fXMEakSazgldEF/g8klVlxGYkPXQmlOHQOUGNsAvdaRY82HMSFFUH0Xk+6NRUG/b2kw4hD4U0YTXvXkc6AIwADmUpvxwUgX/zgnpsJrLt37Ii98p04DX74b0vfDbNlvNJUZ5v6NJcSYM2hiVnlkuawZmX0k9jmth/KQntCgHrBHcgnJ6xvksJAIADFlVlUM8s/jvqum+LYRPQUoY+XKe1vDfPIMSPZWu5P2wje4bg/I5r0QngTHNVvVYlwe79vMvtWbmymxltaYKxDTUQzF8u0vBrcExL3XMYxDKx9whxpC0rYAy1Nkpj8KH/WO39/hV3YQxkukymKNqdzEt3uNCWZMTiNICjOEUXgILxT3c2YCDkrJD2398hk4Vxeh/A7idtRtc/XPLz7rOiAOKspG6PKqbdjd6XJnZIUpJ/H0Ib+zHnvUgZwBRDh1MiL+m+X6fNVs9KF1/yGYehfr1Ab1dUe5iUJ6Zf2JJBYL3kGcC2Lihvgy1qyjX1Uuc2bB00LPGkRiCY0HbQ7NT5z0ZHa5RizASqQhvsqNHxcVEYTI6Pb3MhhSscZCkkGEiRn35in+d5invJGMNUDrUYgUwC3addoEz/AX2e0l6w8Kyw2/8IiBpxad7ueRCk+pyfNwwPs3WXv5q4PUuDUnWscwGyQ2CwKGLbbBwEWJCwKHDmOkMx/XDuC92SQiG2qs0aL19+uyjf5ovAdgb5g0UQVqMZLyX+YALSsTlxc= 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)(36840700001)(70206006)(8676002)(83380400001)(70586007)(186003)(81166007)(47076005)(7696005)(508600001)(86362001)(36860700001)(82310400003)(2906002)(356005)(26005)(426003)(316002)(336012)(2616005)(6666004)(8936002)(54906003)(5660300002)(36756003)(1076003)(110136005)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 13:27:45.5627 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80bf047c-b7a2-4ac9-2002-08d9841616da 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: CO1NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0014 X-Mailman-Approved-At: Thu, 30 Sep 2021 17:11:01 +0200 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" Guybrush board has RT5682 codec and RT1019 amp connected to I2S SP controller on ACP hw. Also it support DMIC capture endpoints with inbuilt pdm controller on ACP hw block. Add driver module to create backend dai links for sof dsp core. We pass driver data with audio end points configuration to register sound cards and create device nodes for all audio endpoints. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/Kconfig | 6 ++ sound/soc/amd/acp/Makefile | 2 + sound/soc/amd/acp/acp-sof-mach.c | 103 +++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 sound/soc/amd/acp/acp-sof-mach.c diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index aea8766d20a0..55dda516a0d0 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -39,3 +39,9 @@ config SND_SOC_AMD_LEGACY_MACH select SND_SOC_AMD_MACH_COMMON help This option enables legacy sound card support for ACP audio + +config SND_SOC_AMD_SOF_MACH + tristate "AMD SOF Machine Driver Support" + select SND_SOC_AMD_MACH_COMMON + help + This option enables SOF sound card support for ACP audio diff --git a/sound/soc/amd/acp/Makefile b/sound/soc/amd/acp/Makefile index aef6f981c770..16c144c2965c 100644 --- a/sound/soc/amd/acp/Makefile +++ b/sound/soc/amd/acp/Makefile @@ -14,6 +14,7 @@ snd-acp-renoir-objs := acp-renoir.o #machine specific driver snd-acp-mach-objs := acp-mach-common.o snd-acp-legacy-mach-objs := acp-legacy-mach.o +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 @@ -22,3 +23,4 @@ obj-$(CONFIG_SND_AMD_ASOC_RENOIR) += snd-acp-renoir.o obj-$(CONFIG_SND_SOC_AMD_MACH_COMMON) += snd-acp-mach.o obj-$(CONFIG_SND_SOC_AMD_LEGACY_MACH) += snd-acp-legacy-mach.o +obj-$(CONFIG_SND_SOC_AMD_SOF_MACH) += snd-acp-sof-mach.o diff --git a/sound/soc/amd/acp/acp-sof-mach.c b/sound/soc/amd/acp/acp-sof-mach.c new file mode 100644 index 000000000000..9da70550ea25 --- /dev/null +++ b/sound/soc/amd/acp/acp-sof-mach.c @@ -0,0 +1,103 @@ +// 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 +// + +/* + * SOF Machine Driver Support for ACP HW block + */ + +#include +#include +#include +#include +#include + +#include "acp-mach.h" + +static struct acp_card_drvdata guybrush_sof_data = { + .hs_cpu_id = I2S_SP, + .amp_cpu_id = I2S_SP, + .dmic_cpu_id = DMIC, + .hs_codec_id = RT5682, + .amp_codec_id = RT1019, + .dmic_codec_id = DMIC, +}; + +static const struct snd_kcontrol_new acp_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Spk"), + SOC_DAPM_PIN_SWITCH("Left Spk"), + SOC_DAPM_PIN_SWITCH("Right Spk"), +}; + +static const struct snd_soc_dapm_widget acp_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("Spk", NULL), + SND_SOC_DAPM_SPK("Left Spk", NULL), + SND_SOC_DAPM_SPK("Right Spk", NULL), +}; + +static int acp_sof_probe(struct platform_device *pdev) +{ + struct snd_soc_card *card = NULL; + struct device *dev = &pdev->dev; + int ret; + + if (!pdev->id_entry) + return -EINVAL; + + card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + card->dev = dev; + card->owner = THIS_MODULE; + card->name = pdev->id_entry->name; + card->dapm_widgets = acp_widgets; + card->num_dapm_widgets = ARRAY_SIZE(acp_widgets); + card->controls = acp_controls; + card->num_controls = ARRAY_SIZE(acp_controls); + card->drvdata = (struct acp_card_drvdata *)pdev->id_entry->driver_data; + + acp_sofdsp_dai_links_create(card); + + ret = devm_snd_soc_register_card(&pdev->dev, card); + if (ret) { + dev_err(&pdev->dev, + "devm_snd_soc_register_card(%s) failed: %d\n", + card->name, ret); + return ret; + } + + return 0; +} + +static const struct platform_device_id board_ids[] = { + { + .name = "rn-sof-rt5682-rt1019", + .driver_data = (kernel_ulong_t)&guybrush_sof_data + }, + { } +}; +static struct platform_driver acp_asoc_audio = { + .driver = { + .name = "sof_mach", + }, + .probe = acp_sof_probe, + .id_table = board_ids, +}; + +module_platform_driver(acp_asoc_audio); + +MODULE_IMPORT_NS(SND_SOC_AMD_MACH); +MODULE_DESCRIPTION("ACP chrome SOF audio support"); +MODULE_ALIAS("platform:rn-sof-rt5682-rt1019"); +MODULE_LICENSE("GPL v2"); From patchwork Thu Sep 30 13:24:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12528655 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 625D8C433F5 for ; Thu, 30 Sep 2021 15:17:03 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5518E61139 for ; Thu, 30 Sep 2021 15:17:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5518E61139 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 DB6CE16BA; Thu, 30 Sep 2021 17:16:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DB6CE16BA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633015020; bh=JNFl1rrmW8VkbrosU7DjirbsUBlzSHBLfNF5D3Evwcw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lf5ATe56NcDwI8urrh9+eV5w9//4PV8Fd/VryuLNPJeSIjFL0NImvkqXNBWuUyeNX epYd5b0jTbS75N8CbbueKXRMaoQtllhsnM8eh32oDKAJR7ThXee/IfZdrwO/E7F60p PnbyZjhWco9/p80vUOeyUMcXy3c3fXfPCaGL6SqA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B75FAF80537; Thu, 30 Sep 2021 17:11:22 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E78C3F804AD; Thu, 30 Sep 2021 15:28:29 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2075.outbound.protection.outlook.com [40.107.212.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 E3F6BF80218 for ; Thu, 30 Sep 2021 15:28:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E3F6BF80218 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="hMZShMl2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gWXBYxbw4c69D5PUbL3bQF41suF/xNaYRtqd/TnGCZeqbNCZvfs1/9ey6GMITYQonTqCarsdNa1VIXJlRqf8x0RcxIpxtJdJNjVR4pHN30122KYNIBo2cZKdRegsmFP7J252J1l/420s+h1QGHoy7hFYlPlSb+O3zodW/Wx+/+LOuXCgxQ+NBk/9EXFhci4PbHti3j4hGQbjyxZ3hV3RbnHbehFqUsv5IjLMOQHiRUBeojOQxRlK3Su1uE8gt+SR+Xjb43/iHubVSCvNmDkKG/hURssrhwPtbN10Vl1WvI4gm8Zv34AcOlqcuNDB/UItwb8AgXIOE0ItwxdvMi1RZQ== 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; bh=q1HCDkNERSbSY9nu3mO6h0iyX7gg3D9ookWe3s+HogI=; b=CalERg/gJa+MHSRLO+j5IMN5ZoryaJPhHwpCd884W6yUr13pXKDYHg8eYUzUGR8UjLrw/kzx2QdwimH3WMSYPEiG3QxB+05ss5wBOcjQqHxM8oC36ha1rUjkqBNimkVkEwf7X4mSPUaFhxqR3kr0lKkKKDopbg4gZztT7CL9YmTWcy3V3H/WyxCsL74h0QV3fteBra+TnEJYcIQnATPIidmYUZPOe6aGsQgxE9twEiFkWYg2tOjUflRQ1OzZclESWuQA/gfHGJxmakBqwLuPW3mohcMnAlj1w34zsVfqIjkqI3xj8Md9LtyQKtKks5lPlvy0e/tGrOltU2bc3bOYag== 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=q1HCDkNERSbSY9nu3mO6h0iyX7gg3D9ookWe3s+HogI=; b=hMZShMl2euSWpkr4QYTWwvgQZMr1OSjgI5DDkemEwg0lDSpK110q/SZ9NUzNUkhKgLMLvxVc6PTku5a6QRZoh6b8gN5W3WVxyrpYISUUki7MZdT3d9Soy7WxuTWTJTE0ykcqflQQgZjugeDuwCao5XRe9hq3mbUebHR+Eo9EkMU= Received: from MW4PR04CA0203.namprd04.prod.outlook.com (2603:10b6:303:86::28) by MN2PR12MB3901.namprd12.prod.outlook.com (2603:10b6:208:16c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.18; Thu, 30 Sep 2021 13:28:16 +0000 Received: from CO1NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::35) by MW4PR04CA0203.outlook.office365.com (2603:10b6:303:86::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Thu, 30 Sep 2021 13:28:14 +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=SATLEXMB03.amd.com; Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT011.mail.protection.outlook.com (10.13.175.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:28:13 +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.2308.8; Thu, 30 Sep 2021 08:28:12 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 08:28:12 -0500 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.8 via Frontend Transport; Thu, 30 Sep 2021 08:28:08 -0500 From: Ajit Kumar Pandey To: , Subject: [PATCH 7/8] ASoC: amd: acp: Add support for Maxim amplifier codec Date: Thu, 30 Sep 2021 18:54:17 +0530 Message-ID: <20210930132418.14077-8-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> References: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c12b7799-c551-4f50-3879-08d9841627a8 X-MS-TrafficTypeDiagnostic: MN2PR12MB3901: 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: upUhhFLx4a8tkSvX62V4tLjzYjQdM0Keacx2WiAl8yZlkOB+cozAT+RqGneygMJcY8hzQI1k1QMDJhK6zGgI6Vyj366WZTBWodEuy9gEm9ZpONxQrP6Cypq5BLWMbdIOji5OCagVSzXjmT4sS++tGDdORNLkFcFctuCIZFwyp0rS3Huyvz85jkCqpCNNmLCcmmL0wPNGHCDj/HXlUPnTHL+uBOlrkz3IXhTNFAxQ1TDMTgkTdN8kgbPwl0UmnlOPSXkqnCVXmcGVpobV3oqusYCcghV0ZmqilNlhZdOaCo7RfuBwCKSOCCq+41IB+/VYR3FhK3QaoWrVZDpnyf095BE+B+dxIvX8gTVQvNBo4st45xTRVHhYj2mBFdxZ82JH10DIhkRuEYiOo6xQaep09S27i06jYpwiiNmlxxsjrD/p+bppMOCJRXEhx4ggQRFMfNBlIhq3PfvIyJnjylXtWYgI3TpSAaadI4ymGegqOJrYu3f1ftsgbXYXuWpcmZBJI3aRwInl2ObP/MO4S/nsKJbWg76UAKVFNUh0uvSurH5c8jXgmrgMwJvvoLB3VsrfOLGGYxoDy5gBLpzm9PEqgLC/op7iVLHvn71Drslbc6RUcGcxf2AMWVW63vMnaTree3EzOroRFKaaKQxDt9r2Axn9E/3uEOikr9sqSrnfsKUrcSuqTPOi2X7gx55eJz5dmNzN5SilXdMuQ3x/ycFyIwMfstEWpOJjdfcD5SspFbQ= 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)(46966006)(2906002)(86362001)(54906003)(70206006)(110136005)(7696005)(36756003)(316002)(8936002)(186003)(6666004)(508600001)(26005)(8676002)(5660300002)(336012)(47076005)(426003)(81166007)(1076003)(82310400003)(70586007)(36860700001)(2616005)(4326008)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 13:28:13.7496 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c12b7799-c551-4f50-3879-08d9841627a8 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: CO1NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3901 X-Mailman-Approved-At: Thu, 30 Sep 2021 17:11:01 +0200 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" Add a new codec id for MAX98360A amplifier in codec list and define maxim components and audio route in common machine driver code. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/Kconfig | 1 + sound/soc/amd/acp/acp-mach-common.c | 21 +++++++++++++++++++++ sound/soc/amd/acp/acp-mach.h | 1 + 3 files changed, 23 insertions(+) diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index 55dda516a0d0..8257b8e1e7cc 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -30,6 +30,7 @@ config SND_SOC_AMD_MACH_COMMON select SND_SOC_RT5682_I2C select SND_SOC_DMIC select SND_SOC_RT1019 + select SND_SOC_MAX98357A depends on X86 && PCI && I2C help This option enables common Machine driver module for ACP diff --git a/sound/soc/amd/acp/acp-mach-common.c b/sound/soc/amd/acp/acp-mach-common.c index cc507c520317..80c6cd220674 100644 --- a/sound/soc/amd/acp/acp-mach-common.c +++ b/sound/soc/amd/acp/acp-mach-common.c @@ -91,6 +91,14 @@ static struct snd_soc_codec_conf rt1019_conf[] = { }, }; +/* Declare Maxim codec components */ +SND_SOC_DAILINK_DEF(max98360a, + DAILINK_COMP_ARRAY(COMP_CODEC("MX98360A:00", "HiFi"))); + +static const struct snd_soc_dapm_route max98360a_map[] = { + {"Spk", NULL, "Speaker"}, +}; + /* Declare DMIC codec components */ SND_SOC_DAILINK_DEF(dmic_codec, DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi"))); @@ -248,6 +256,9 @@ static int acp_asoc_amp_init(struct snd_soc_pcm_runtime *rtd) case RT1019: return snd_soc_dapm_add_routes(&rtd->card->dapm, rt1019_map_lr, ARRAY_SIZE(rt1019_map_lr)); + case MAX98360A: + return snd_soc_dapm_add_routes(&rtd->card->dapm, max98360a_map, + ARRAY_SIZE(max98360a_map)); default: dev_err(card->dev, "Invalid AMP id: %d\n", drvdata->amp_codec_id); return -EINVAL; @@ -286,6 +297,8 @@ static int acp_card_amp_hw_params(struct snd_pcm_substream *substream, return ret; } break; + case MAX98360A: + break; default: dev_err(card->dev, "Invalid AMP id: %d\n", drvdata->amp_codec_id); return -EINVAL; @@ -414,6 +427,10 @@ int acp_sofdsp_dai_links_create(struct snd_soc_card *card) card->codec_conf = rt1019_conf; card->num_configs = ARRAY_SIZE(rt1019_conf); } + if (drv_data->amp_codec_id == MAX98360A) { + links[i].codecs = max98360a; + links[i].num_codecs = ARRAY_SIZE(max98360a); + } i++; } @@ -499,6 +516,10 @@ int acp_legacy_dai_links_create(struct snd_soc_card *card) card->codec_conf = rt1019_conf; card->num_configs = ARRAY_SIZE(rt1019_conf); } + if (drv_data->amp_codec_id == MAX98360A) { + links[i].codecs = max98360a; + links[i].num_codecs = ARRAY_SIZE(max98360a); + } } card->dai_link = links; diff --git a/sound/soc/amd/acp/acp-mach.h b/sound/soc/amd/acp/acp-mach.h index 464fb7eb802d..b6a43d1b9ad4 100644 --- a/sound/soc/amd/acp/acp-mach.h +++ b/sound/soc/amd/acp/acp-mach.h @@ -35,6 +35,7 @@ enum codec_endpoints { DUMMY = 0, RT5682, RT1019, + MAX98360A, }; struct acp_card_drvdata { From patchwork Thu Sep 30 13:24:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Kumar Pandey X-Patchwork-Id: 12528657 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F053C433EF for ; Thu, 30 Sep 2021 15:17:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D305061139 for ; Thu, 30 Sep 2021 15:17:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D305061139 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 66C7216B0; Thu, 30 Sep 2021 17:16:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 66C7216B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1633015039; bh=7YGKvRHxLfIrkaKy9M7+FjhLBnRhW/wt02GxCJF6lWM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rPXxmqKPWoTZoo2JMA8bYtpRTR+Nc4y0mNuLXSnrmo+tEVRtw1XKmXV4Lf+EKxHWU oHXLSkTFU2ksbyo2DOjnRkACIcQm2JRacL7pLdrqJZqP0a5p1Ba3O5yO0BwHEEeIJr yZBsD7m8xIRdc9OrKKJR4+SqPymxGLXRKFULwjF4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 550A1F8053E; Thu, 30 Sep 2021 17:11:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 202DDF804BC; Thu, 30 Sep 2021 15:28:44 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2073.outbound.protection.outlook.com [40.107.244.73]) (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 CC88CF800F3 for ; Thu, 30 Sep 2021 15:28:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CC88CF800F3 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="POMy67Vs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a8AfbyCTLiMzDSoZsV/gKSy0oJko+OX5KMr1GrPRF3Xsxr2ksBwfn8NP5IDBw3WooKHC/W8tE4p/DnWDWHmva8OwhMJHSRneEQ/0ehhgL8ehj8N9YLPaXRpBVELApAGqqJYpOjYfQ74UjRXKJ1KhULKdzIGK5AhdQjEGKYUt/ZPwmDX7u0+gZwZ6yjxiKaAIyypHm4DOuHxDBrXMeaHR1OXk5Xdouqwz888tqyxbgpT2jnvKpPF/ZcfQLQtecfLCokN376FzrXz7dy+T3UWLWwrkQt4fqO7Tp/9iOJ9Z3Yp1Uqlk7+IYaQbFfsIIB6SeRWpkDf20NSSlFWxNKAiZLQ== 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; bh=YGc/M2kPkVFVjdyBos2jQI8YoDlq5vyFMwnORr8mqbQ=; b=RJXObrx1swNpZWhEwqIXnA2ptioVy9zWteg8y0/v1K62Z+JOFonZIBaDEQ37qeYLal/WMoLDAsYS/AjRHpZED8gFz7UV0T5VgebDPRjSbXoE/zt7be+1rPh5rXdvQqTGF8/yNiivCXNmBO+lC08kLFE3KgcnPXIMW+ZioHdNQCGY4O2qnKGg8zKhyRtZrj/RrmTbXh639+ZsDpZRGByvE+QCA7OkLqEVIykTkP3tscdf8KLGdTw9D02TYoKWxz+OKgMwBdbTseDTtMwa8N7YuGZjZFc6iuZeXzoQoT4hRwT4dBrOwNr+Qb+bBnjCanCd1oi1d9971X0PETHFF7sXEQ== 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=YGc/M2kPkVFVjdyBos2jQI8YoDlq5vyFMwnORr8mqbQ=; b=POMy67VsZGF5jugabsXVq6HvXtg33GrvbrURhZvnzCb/D+kZKnhb+MG8h6D5ouVdl0Hen9W1eIEnoyX1xwbgTOpAQZjaSb5fY8aa6YebQsXD8i14Obv2GdiBxNfG6jIr+Vlr24rQW3GrCk7xKHYEclxyUHXWA2ihlzvEQjH8K9M= Received: from BN6PR1201CA0010.namprd12.prod.outlook.com (2603:10b6:405:4c::20) by BY5PR12MB4195.namprd12.prod.outlook.com (2603:10b6:a03:200::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 13:28:32 +0000 Received: from BN8NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:405:4c:cafe::db) by BN6PR1201CA0010.outlook.office365.com (2603:10b6:405:4c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:28:32 +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 BN8NAM11FT013.mail.protection.outlook.com (10.13.176.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 13:28:31 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 30 Sep 2021 08:28:30 -0500 Received: from chrome.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2308.8 via Frontend Transport; Thu, 30 Sep 2021 08:28:26 -0500 From: Ajit Kumar Pandey To: , Subject: [PATCH 8/8] ASoC: amd: acp: Add support for RT5682-VS codec Date: Thu, 30 Sep 2021 18:54:18 +0530 Message-ID: <20210930132418.14077-9-AjitKumar.Pandey@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> References: <20210930132418.14077-1-AjitKumar.Pandey@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75f62235-d46b-471d-53ec-08d984163254 X-MS-TrafficTypeDiagnostic: BY5PR12MB4195: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1417; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: buzWa7mh8FUPndaSWZJCvgsCpGWjkyKv/KEazxvRHYTI7JUSw5jObX9plfSUFXrd1CpkuPoLzjz51Cvc8qezwsw3DcgBmWsX2v+fDBNb0IrXRWEJIccEsDVJyM2EGdUuo/ipEzb7aikwpVtiawfSXtAZqQDGJG88bxxBvjIUhwVYEqJOJ7iI8GD9aaETEStNGfvsy9eet6ekIAf1Hzw92ZgoE8sYuuPcoB7GIiXLbXjkIJ8oLQWLwXy1v7eq9gJR1aCldnEi1h+HCy095aCHJGsQa970Vq4KReHrGrRx1x9XZqVpNRblBZV4/LPbov+NFzZ2T5313TSJO8rHOW1ST/zsTjmf6ZyqaX0ovo+YJqsvQFKbfniw2pXLjC24vA0KaXMGyrxPIcreIUPB/ov6ixK4HWVP6P5hBX2KtWklBZmv9nDSAZ2GX/JVQur4mc5lqQp0IjTPOypaBFLhrSTweea1JkqJHW+dqPWRcJusY/qlb/jks6kCs+Zf/pRWg1Pi2h31qVrzdPQYUsBlgIY8k8w8r3m+xHQaaitqSRylGcQ+9ZvJbXgcpgO9891ypeI2j+T/vuq6LMHjenkLnExFPWDnafhjhcnIEiDoaaLB81MULBg8mGKbubualCX5qRSyO9aIb7WFIsVszbzoqEKOiUqoxt5Eq017VWvaboHQdB7HA96//XWJr+obuJzpgcleo10dc7zIt7LGK/G7yYqJp8jaF3xzV/EvRVdbIiAH1Vw= 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)(86362001)(356005)(508600001)(47076005)(1076003)(316002)(6666004)(82310400003)(81166007)(36860700001)(26005)(7696005)(186003)(5660300002)(2906002)(8676002)(426003)(36756003)(110136005)(54906003)(8936002)(336012)(70206006)(2616005)(4326008)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 13:28:31.7735 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75f62235-d46b-471d-53ec-08d984163254 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: BN8NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4195 X-Mailman-Approved-At: Thu, 30 Sep 2021 17:11:01 +0200 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" Add new codec endpoints and define components to support RT5682-VS variants of codec with ACP machines. Signed-off-by: Ajit Kumar Pandey --- sound/soc/amd/acp/Kconfig | 1 + sound/soc/amd/acp/acp-mach-common.c | 25 +++++++++++++++++++++++++ sound/soc/amd/acp/acp-mach.h | 1 + 3 files changed, 27 insertions(+) diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index 8257b8e1e7cc..7e3c32f5b982 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -31,6 +31,7 @@ config SND_SOC_AMD_MACH_COMMON select SND_SOC_DMIC select SND_SOC_RT1019 select SND_SOC_MAX98357A + select SND_SOC_RT5682S depends on X86 && PCI && I2C help This option enables common Machine driver module for ACP diff --git a/sound/soc/amd/acp/acp-mach-common.c b/sound/soc/amd/acp/acp-mach-common.c index 80c6cd220674..5e7da4515e5e 100644 --- a/sound/soc/amd/acp/acp-mach-common.c +++ b/sound/soc/amd/acp/acp-mach-common.c @@ -23,6 +23,7 @@ #include "../../codecs/rt5682.h" #include "../../codecs/rt1019.h" +#include "../../codecs/rt5682s.h" #include "acp-mach.h" #define PCO_PLAT_CLK 48000000 @@ -64,6 +65,9 @@ static int acp_clk_enable(struct acp_card_drvdata *drvdata) SND_SOC_DAILINK_DEF(rt5682, DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5682:00", "rt5682-aif1"))); +SND_SOC_DAILINK_DEF(rt5682s, + DAILINK_COMP_ARRAY(COMP_CODEC("i2c-RTL5682:00", "rt5682s-aif1"))); + static const struct snd_soc_dapm_route rt5682_map[] = { { "Headphone Jack", NULL, "HPOL" }, { "Headphone Jack", NULL, "HPOR" }, @@ -135,6 +139,19 @@ static int acp_asoc_hs_init(struct snd_soc_pcm_runtime *rtd) | SND_SOC_DAIFMT_CBP_CFP; snd_soc_dapm_add_routes(&rtd->card->dapm, rt5682_map, ARRAY_SIZE(rt5682_map)); break; + case RT5682S: + pll_id = RT5682S_PLL2; + pll_src = RT5682S_PLL_S_MCLK; + freq_in = PCO_PLAT_CLK; + freq_out = RT5682_PLL_FREQ; + clk_id = RT5682S_SCLK_S_PLL2; + clk_freq = RT5682_PLL_FREQ; + wclk_name = "rt5682-dai-wclk"; + bclk_name = "rt5682-dai-bclk"; + drvdata->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBM_CFM; + snd_soc_dapm_add_routes(&rtd->card->dapm, rt5682_map, ARRAY_SIZE(rt5682_map)); + break; default: dev_err(rtd->dev, "Invalid codec id %d\n", drvdata->hs_codec_id); return -EINVAL; @@ -401,6 +418,10 @@ int acp_sofdsp_dai_links_create(struct snd_soc_card *card) links[i].codecs = rt5682; links[i].num_codecs = ARRAY_SIZE(rt5682); } + if (drv_data->hs_codec_id == RT5682S) { + links[i].codecs = rt5682s; + links[i].num_codecs = ARRAY_SIZE(rt5682s); + } i++; } @@ -492,6 +513,10 @@ int acp_legacy_dai_links_create(struct snd_soc_card *card) links[i].codecs = rt5682; links[i].num_codecs = ARRAY_SIZE(rt5682); } + if (drv_data->hs_codec_id == RT5682S) { + links[i].codecs = rt5682s; + links[i].num_codecs = ARRAY_SIZE(rt5682s); + } i++; } diff --git a/sound/soc/amd/acp/acp-mach.h b/sound/soc/amd/acp/acp-mach.h index b6a43d1b9ad4..5dc47cfbff10 100644 --- a/sound/soc/amd/acp/acp-mach.h +++ b/sound/soc/amd/acp/acp-mach.h @@ -36,6 +36,7 @@ enum codec_endpoints { RT5682, RT1019, MAX98360A, + RT5682S, }; struct acp_card_drvdata {