From patchwork Wed Nov 17 09:37:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624145 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 EFD3AC433F5 for ; Wed, 17 Nov 2021 09:40:02 +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 02E5361AED for ; Wed, 17 Nov 2021 09:40:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 02E5361AED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 F15D2184C; Wed, 17 Nov 2021 10:39:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F15D2184C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142000; bh=jWKgpYMiaOH6fXLGXuVgLpAVDTtTjtTw8D5jc5RX8/Q=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=JkEcYN3ooiz1Dsz7RfNhs9TGMyacFKedIcAojLRK6ZkMkiQHj2ExXniY7plCMcKnE p5as7oyoLHY5Uwxzxe6/OjttYERMXi4V8FbDEXGb5uSr/f7uRRTBeDy1g0Po2GEJhv RXIIM10/1CfazJ7eEj9jM0SvLZ5TT6oxtSeYU0lk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 964C2F802A0; Wed, 17 Nov 2021 10:38:24 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E72AAF8016C; Wed, 17 Nov 2021 10:38:15 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60071.outbound.protection.outlook.com [40.107.6.71]) (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 BAB72F8016C for ; Wed, 17 Nov 2021 10:38:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BAB72F8016C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="aplJeNkj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P0Injg4CXBpFe2PF8Is6kHdfjxyWqGMRdKOybM1CimYULTl6fmxGwoRHDSSfFvciH1Ed4+8ArOit6hfGJcjdup2iZer43dCWLFQDzATanCmOTzoCUnO84Vaqz/0vTnowO+UPVF5lj1dOQBNl5o6Lq8I+V7qCwpa9o+omQEbySg+dffRjxUIEyV/voKkb1Q98UbCxHxUAcha1paRkYU+3TeBACMK1H9eaY6O485Yv5XER8BZKxOIXGTkV+HmATJHV6WDAz8fZ/qXydk4xEOjawUclJaymKGiH0f2YOalY+YxFU+Rg5B4EasnilMS+3EOrOwqoTJTtv/LOcYoW0bMDog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M9dEqdF9hwa7x/KDW80gs2YQr+CaTRcLdaS21fO2N9I=; b=UOsbs1cxvVnBpv3XaXZgukwI6JMI8ERN+dn7VEGO3eJr1PaUwnSBAyzf30nYTYCJWQC3KZQli/n4oAvLtg88ZT1BDV8I7n2C8y1ps+ymPAvgixmVkW9/1WMm7BTBkHW/7ccQs+30MCswPQTMAEv91IQWTozR0MIgSgxP0rdS7UzseQCAZMJ+33dvpwfwbOJfZ1LbNIXJnhqd0Kkyj6CBcRDx/eDVkkVJdvAxLf3d2/BnmPRqK9KuqZXIwsru5i9oAP6nclhbpqyvcANcISi5sxb9LvR/y/osldBI0+MP3w/AazO7OMRoajgKQYMjinEEMgwSq4vt+opTdeuO2so8jw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M9dEqdF9hwa7x/KDW80gs2YQr+CaTRcLdaS21fO2N9I=; b=aplJeNkjuwj1Z5eDOIJ6CT/VXGuNTTCkz3KgtBQigopLcg1NaAmVjxVLS5hDndJrBqgOlc0D0A+yuHCXmqyHjjN8tbA3MrqXbAJ1cEwva9yrt3OtkLAXF1K3774VVE7QRjT/kHF/lZ3qizm7jnOfCbXjuY8hYnx9iBQ/eqqCS+c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 09:38:05 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:05 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 01/21] ASoC: SOF: amd: Add Renoir ACP HW support Date: Wed, 17 Nov 2021 11:37:14 +0200 Message-Id: <20211117093734.17407-2-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ff9a0604-a453-48e9-fa2b-08d9a9adf4fd X-MS-TrafficTypeDiagnostic: VI1PR04MB5807: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Dxml9Vmf4v56KDfNpoFes7F7lCfOwHhzUJaazyu8M43F/r/won6THZrDAFMcy7+lFZrYCd4qsP5kZs0GHCtXCgUCX/vc7SIRHYglxpmmEw3DMVoVVbB4GzRJIdfAYsTASEZvq3O4Ht0Cvq5S0BtDne3Fmx1f/cX6cBBGv5x/W8bSJ6gnomRVSNqmvIw5H/TxTtlfZT7wdh6SJx51m4g76hNfhWEixpT+RWlQxvEpRzQbqiEU9aG6N0ftPLLEIb78cp8jiwHWJxXd2J/zWu2pDY5LS1RPqnxXxDj2ZRGtWVtvYGdwYcL32LecuSmWjTIfY2s8Ri7UgKDXz11BW3LY5ncVA8tX4Msm+LwN0Q4+K/iLn2Ey42DVQnpz1EWxX/ELcIDfkiG2zrOFFd+6ZKj9/8teH36zoj3DXPYEUBhFdph4kt2Xte/wjwHxTPD0lxCLHJ/wI61Qmy5jOHDctZayJ2IulzqR6CyK88MxJkqM2SLCJTRy9O2PD/d4MVqcKKYmGP7dUN62qD8iM7ybstZojyuDPjHUSXcqaH6YEAAuqadrV1I5FDJYP14seqxUuGvvYO6JCzkslWWith9Z337U4Z0ifOuDfOn9wofO/oaSp+Bf38DQ5tCA1c4d62O4xDj84Hr7BemFI+SnRAl99bfh9w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(316002)(5660300002)(508600001)(52116002)(86362001)(8676002)(54906003)(8936002)(66946007)(186003)(6512007)(2906002)(6666004)(6486002)(7416002)(6506007)(1076003)(2616005)(66556008)(66476007)(44832011)(83380400001)(38100700002)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MbJ2NAi8KBemEyhOaFdFuyuZkdKcv3nazsRZhVk0ItuAukQJcLFu4MNBtvUOj2Jvyf9xsaLY2L4TM6QLNwTG21ECPk9wwu06wy7GMWNsgy3cB1+8nmuSu4Z7LZU/0HcJllcLuwiCLk051W9OX0S1mnf4dm1Z1ujsd0lFnucYHegOgFIeVFIMLZr3yYFmmvhArcG/6bQnQNclngFLJ6D/2sVu2lvbWxlHiUPm3Gygds9Xu2nR9WFFLq3s5PW3AsZi4X+K/umaJNgfqPYLukVzqAQSxW+/vSEQUTk+k+8D9eNfFqRBM6r3lMlcTdevu7Z+PzBDGg1ADaEzF6mFxy1cBYn/zpLdSQoOHdbbB6L42EIj+jGTPcHk5FIABlgKehA14032hYyQ3uaUialnVzPHbyv6JQrOhf13eqlLXw2pJGOoIcsmSGBIALnJ12TEp3WKOYjEIqhtZue/u4pZO5HrgHCfGv2pG3jOG7eeasnU+O6AmunvikvS6IPT+xyK5P7KHdC4laxuC7WY1zboAK/1dNT3VlwbiZkd1Xw9M0hzewS5kdadjfTCqCnXijX077FU4ewzzRzEJJZuNhP6VxvYiDLNACV8k+9yGKpohWgImE2gd4xaVnUHF0Ih2SX9ZLD1P/gVROAKz6GQs1KjXMe/70WChpN7B8uM0dxKgeqzaLbd6AMLnrt9q0KmCJqVUnIrfm9gh6oM9YQb6ZydcZiAyTn0x6jdWJhpT3lFqzMva4J9M+WHyUtQGDTY2AV4LBcIkEElIyL9DnpMAHjdKsXxqi78ov5E0yQLWaaf4QU7inPQOqO+/z3S2QDQp+cHPE52nGNU/aXjHkGlGNH1pmHD0q1MVwsckwLwYNA+yjNgmondcMSacADCmdcLmjeNLCGK+bC2XTAgv77e0Gjra/UpoNbOdKYkT+sMcXehMMCJBtkrCuorDs+dy+TueMLH8HYBaf0jQ+KzItATKRLvbYrhOKBUfKe+uvr3u3YWTi8gGIcdfHOR35/HRSK0L1q8oiVoRjrgh4rhf+ZXXcenrQm5sGVevephis3V5TVSHZSQUUe3fIUWk3gbLc3PLFhtcg8HAE2/pji/2SIZ5/FC3BcOdL4WoP63VuY5PVfx+QU2a71IZ2+c8uh26z8EawcilGHA38V7IDIT5IjZ7kRuMjexvhFjbrNSLuoyDE2h8hgpfZvO6FBDpoCkvs6r8nE34salcPNFVeJNX4W8U2U3Ybb+gaaHxrFVI6SoVVqnO5t6eQDIFE2FHQWgFusD9jXKr9WqjJoK2pNDVZmg/MJ5MFMPETuW1bXqq01iW5qrvYlbRBvdHfAqhWlkNj/I5Ci441Z/37fmgAQu/mrpW9Io4lVkLEYnFZvJrRmbHnINJW+NGU22ytpwLevpPm1tG3jLDrACO+tiYgyttAtB4Er0nrorI7UXoWur5XF2NDedP8wn2H3OvbBH7jf3N6cfaXb3FspyUskadCYvK4L1xq2QKlZhFA03oiaEfl2MTonvLJllQGiE+PoOiy0X4HnzI1wqsdSQFoDMlxCpxVBh3QzF0Efe3qoxngXDZA8DF+b6Evf5IBPi4/FQVDCrjb8GnAiERHOTdck6TlX43wEkIGqGKIUOSM2QSvIL1YRD3mOCe45OUrcCyerjibEJ+VF4lBg3SfAzcujy9WonNQGSlUm4DYTU4TxrSmeN2NA1Kg17seYNI6aLgPzfuaho8zJul9Hdnvm+ X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff9a0604-a453-48e9-fa2b-08d9a9adf4fd X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:05.6626 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Wz9th53q6hnyJOK1YE2WaBxx4H95x4doMk47vGXH99lQ1gOx1md4/CsHWwkZz0reE9kAiRPaWcUZQRr/4O1jiw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5807 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ajit Kumar Pandey This patch initializes ACP HW block to support SOF on AMD Renoir platform. Signed-off-by: Ajit Kumar Pandey Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- sound/soc/sof/Kconfig | 1 + sound/soc/sof/Makefile | 1 + sound/soc/sof/amd/Kconfig | 30 ++++++++ sound/soc/sof/amd/Makefile | 11 +++ sound/soc/sof/amd/acp-dsp-offset.h | 20 +++++ sound/soc/sof/amd/acp.c | 118 +++++++++++++++++++++++++++++ sound/soc/sof/amd/acp.h | 36 +++++++++ sound/soc/sof/amd/renoir.c | 34 +++++++++ 8 files changed, 251 insertions(+) create mode 100644 sound/soc/sof/amd/Kconfig create mode 100644 sound/soc/sof/amd/Makefile create mode 100644 sound/soc/sof/amd/acp-dsp-offset.h create mode 100644 sound/soc/sof/amd/acp.c create mode 100644 sound/soc/sof/amd/acp.h create mode 100644 sound/soc/sof/amd/renoir.c diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index 041c54639c4d..68571bf2585e 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -223,6 +223,7 @@ config SND_SOC_SOF_PROBE_WORK_QUEUE When selected, the probe is handled in two steps, for example to avoid lockdeps if request_module is used in the probe. +source "sound/soc/sof/amd/Kconfig" source "sound/soc/sof/imx/Kconfig" source "sound/soc/sof/intel/Kconfig" source "sound/soc/sof/xtensa/Kconfig" diff --git a/sound/soc/sof/Makefile b/sound/soc/sof/Makefile index 06e5f49f7ee8..011abfa0fd82 100644 --- a/sound/soc/sof/Makefile +++ b/sound/soc/sof/Makefile @@ -22,4 +22,5 @@ obj-$(CONFIG_SND_SOC_SOF_PCI_DEV) += snd-sof-pci.o obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/ obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/ +obj-$(CONFIG_SND_SOC_SOF_AMD_TOPLEVEL) += amd/ obj-$(CONFIG_SND_SOC_SOF_XTENSA) += xtensa/ diff --git a/sound/soc/sof/amd/Kconfig b/sound/soc/sof/amd/Kconfig new file mode 100644 index 000000000000..400dd5a24ae6 --- /dev/null +++ b/sound/soc/sof/amd/Kconfig @@ -0,0 +1,30 @@ +# 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_SOF_AMD_TOPLEVEL + tristate "SOF support for AMD audio DSPs" + depends on X86 || COMPILE_TEST + help + This adds support for Sound Open Firmware for AMD platforms. + Say Y if you have such a device. + If unsure select "N". + +if SND_SOC_SOF_AMD_TOPLEVEL + +config SND_SOC_SOF_AMD_COMMON + tristate + select SND_SOC_SOF + help + This option is not user-selectable but automatically handled by + 'select' statements at a higher level + +config SND_SOC_SOF_AMD_RENOIR + tristate "SOF support for RENOIR" + select SND_SOC_SOF_AMD_COMMON + help + Select this option for SOF support on AMD Renoir platform + +endif diff --git a/sound/soc/sof/amd/Makefile b/sound/soc/sof/amd/Makefile new file mode 100644 index 000000000000..ac2ecd21be5f --- /dev/null +++ b/sound/soc/sof/amd/Makefile @@ -0,0 +1,11 @@ +# 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. + +snd-sof-amd-acp-objs := acp.o +snd-sof-amd-renoir-objs := renoir.o + +obj-$(CONFIG_SND_SOC_SOF_AMD_COMMON) += snd-sof-amd-acp.o +obj-$(CONFIG_SND_SOC_SOF_AMD_RENOIR) +=snd-sof-amd-renoir.o diff --git a/sound/soc/sof/amd/acp-dsp-offset.h b/sound/soc/sof/amd/acp-dsp-offset.h new file mode 100644 index 000000000000..2cc2a9a842c5 --- /dev/null +++ b/sound/soc/sof/amd/acp-dsp-offset.h @@ -0,0 +1,20 @@ +/* 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_DSP_IP_OFFSET_H +#define _ACP_DSP_IP_OFFSET_H + +#define ACP_SOFT_RESET 0x1000 + +/* Registers from ACP_PGFSM block */ +#define ACP_PGFSM_CONTROL 0x141C +#define ACP_PGFSM_STATUS 0x1420 + +#endif diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c new file mode 100644 index 000000000000..687a67419335 --- /dev/null +++ b/sound/soc/sof/amd/acp.c @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// This file is provided under a dual BSD/GPLv2 license. When using or +// redistributing this file, you may do so under either license. +// +// Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// +// Authors: Vijendar Mukunda +// Ajit Kumar Pandey + +/* + * Hardware interface for generic AMD ACP processor + */ + +#include +#include +#include + +#include "../ops.h" +#include "acp.h" +#include "acp-dsp-offset.h" + +static int acp_power_on(struct snd_sof_dev *sdev) +{ + unsigned int val; + int ret; + + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_PGFSM_STATUS); + + if (val == ACP_POWERED_ON) + return 0; + + if (val & ACP_PGFSM_STATUS_MASK) + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_PGFSM_CONTROL, + ACP_PGFSM_CNTL_POWER_ON_MASK); + + ret = snd_sof_dsp_read_poll_timeout(sdev, ACP_DSP_BAR, ACP_PGFSM_STATUS, val, !val, + ACP_REG_POLL_INTERVAL, ACP_REG_POLL_TIMEOUT_US); + if (ret < 0) + dev_err(sdev->dev, "timeout in ACP_PGFSM_STATUS read\n"); + + return ret; +} + +static int acp_reset(struct snd_sof_dev *sdev) +{ + unsigned int val; + int ret; + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SOFT_RESET, ACP_ASSERT_RESET); + + ret = snd_sof_dsp_read_poll_timeout(sdev, ACP_DSP_BAR, ACP_SOFT_RESET, val, + val & ACP_SOFT_RESET_DONE_MASK, + ACP_REG_POLL_INTERVAL, ACP_REG_POLL_TIMEOUT_US); + if (ret < 0) { + dev_err(sdev->dev, "timeout asserting reset\n"); + return ret; + } + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SOFT_RESET, ACP_RELEASE_RESET); + + ret = snd_sof_dsp_read_poll_timeout(sdev, ACP_DSP_BAR, ACP_SOFT_RESET, val, !val, + ACP_REG_POLL_INTERVAL, ACP_REG_POLL_TIMEOUT_US); + if (ret < 0) + dev_err(sdev->dev, "timeout in releasing reset\n"); + + return ret; +} + +static int acp_init(struct snd_sof_dev *sdev) +{ + int ret; + + /* power on */ + ret = acp_power_on(sdev); + if (ret) { + dev_err(sdev->dev, "ACP power on failed\n"); + return ret; + } + /* Reset */ + return acp_reset(sdev); +} + +int amd_sof_acp_probe(struct snd_sof_dev *sdev) +{ + struct pci_dev *pci = to_pci_dev(sdev->dev); + struct acp_dev_data *adata; + unsigned int addr; + + adata = devm_kzalloc(sdev->dev, sizeof(struct acp_dev_data), + GFP_KERNEL); + if (!adata) + return -ENOMEM; + + adata->dev = sdev; + addr = pci_resource_start(pci, ACP_DSP_BAR); + sdev->bar[ACP_DSP_BAR] = devm_ioremap(sdev->dev, addr, pci_resource_len(pci, ACP_DSP_BAR)); + if (!sdev->bar[ACP_DSP_BAR]) { + dev_err(sdev->dev, "ioremap error\n"); + return -ENXIO; + } + + pci_set_master(pci); + + sdev->pdata->hw_pdata = adata; + + return acp_init(sdev); +} +EXPORT_SYMBOL_NS(amd_sof_acp_probe, SND_SOC_SOF_AMD_COMMON); + +int amd_sof_acp_remove(struct snd_sof_dev *sdev) +{ + return acp_reset(sdev); +} +EXPORT_SYMBOL_NS(amd_sof_acp_remove, SND_SOC_SOF_AMD_COMMON); + +MODULE_DESCRIPTION("AMD ACP sof driver"); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h new file mode 100644 index 000000000000..c7ac8f9941d5 --- /dev/null +++ b/sound/soc/sof/amd/acp.h @@ -0,0 +1,36 @@ +/* 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 __SOF_AMD_ACP_H +#define __SOF_AMD_ACP_H + +#define ACP_DSP_BAR 0 + +#define ACP_REG_POLL_INTERVAL 500 +#define ACP_REG_POLL_TIMEOUT_US 2000 + +#define ACP_PGFSM_CNTL_POWER_ON_MASK 0x01 +#define ACP_PGFSM_STATUS_MASK 0x03 +#define ACP_POWERED_ON 0x00 +#define ACP_ASSERT_RESET 0x01 +#define ACP_RELEASE_RESET 0x00 +#define ACP_SOFT_RESET_DONE_MASK 0x00010001 + +/* Common device data struct for ACP devices */ +struct acp_dev_data { + struct snd_sof_dev *dev; +}; + +/* ACP device probe/remove */ +int amd_sof_acp_probe(struct snd_sof_dev *sdev); +int amd_sof_acp_remove(struct snd_sof_dev *sdev); + +extern const struct snd_sof_dsp_ops sof_renoir_ops; +#endif diff --git a/sound/soc/sof/amd/renoir.c b/sound/soc/sof/amd/renoir.c new file mode 100644 index 000000000000..3d1dc6c2fa9b --- /dev/null +++ b/sound/soc/sof/amd/renoir.c @@ -0,0 +1,34 @@ +// 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 Audio DSP on Renoir platform + */ + +#include +#include + +#include "../ops.h" +#include "acp.h" + +/* AMD Renoir DSP ops */ +const struct snd_sof_dsp_ops sof_renoir_ops = { + /* probe and remove */ + .probe = amd_sof_acp_probe, + .remove = amd_sof_acp_remove, + + /* Register IO */ + .write = sof_io_write, + .read = sof_io_read, +}; +EXPORT_SYMBOL(sof_renoir_ops); + +MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON); +MODULE_DESCRIPTION("RENOIR SOF Driver"); +MODULE_LICENSE("Dual BSD/GPL"); From patchwork Wed Nov 17 09:37:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624155 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 8F77FC433EF for ; Wed, 17 Nov 2021 09:41:51 +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 08EE160C4A for ; Wed, 17 Nov 2021 09:41:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 08EE160C4A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 6DFEE185A; Wed, 17 Nov 2021 10:40:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6DFEE185A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142109; bh=vdJXIMFkU91ICNZKTNxzkogR+aDvfMVePg4KrqoycUM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=e4JF8ZgTwleNL2D3OFHuzqP+QNNPBTPHEnDBctVt2BIC9IDTcxQzPGsb7fziFSpw6 stl6ZSJKEqmsyZy26CuRyEzjVO9H4wHacAbPppPfd2IvyVMINddsXjQfqLxr2GdGIU wG0SbAWM1edRx3xP4XbQLeAZ6Mc/dAYxRzLyXu3w= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A8147F80529; Wed, 17 Nov 2021 10:38:43 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C9596F804EC; Wed, 17 Nov 2021 10:38:25 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2067.outbound.protection.outlook.com [40.107.21.67]) (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 7041FF8027D for ; Wed, 17 Nov 2021 10:38:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7041FF8027D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="l95fOrk6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j0+SXI7hiGuw256reNr3hQaeFOZGHGm+BN/GWDKLGU3LF0JHwVClobS40bOFwjvknZM3hVik1tShhwDL414c5ocrwEeO/2toJ8DErjtijRKXNMNEqhdodT/he4Bg6gAo67r0W/ZU9Ob06IPcwl0ujVT7ioXM8zkEUMXTwb0KnhMqfReF+McmO0q7xzdbhcZOzIaJq2dbd1cskdWZFB2thZEFQl/kKNaTZTlE6iwkxzM7eSeNcct72Y4cKZ8eMZXmNZvOziD+GKh3h7CRo7OqxB797kmWTxO5/VcJ3QuYdMjbzEgtKE+RLazP9k5ZxpdXIsO/Z+bzdDslQghDG3DYzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FhQ3Xjm9LYLed451PnZa7lr7pWQBC1GLGS66r+lkId4=; b=dYDtdXXvD0TKGfwSOzk2kZBxlnT78kgL26d7y/LySlG9TiW6n7urU5XM+nP9ShnukILRwUMJvg6HATabdCbEgc/oj5xQ0s85iS+ogLzm/Ug0vBxHgHvuxlB6KSAHVkcPvxp7Wn7sHciBPa/48GDguVSZhX1vUZSyItVKUNEfbmWygFETcn88s6CAoiiBJVZ4JDlbcjNayTjAdUc2FKvxfneNH69uQz32SCQl7QNPjT5JZzpq9MIIlibai4ZApGAcXjYhyz7ErbPP/BX0bZBKvPCMFzu84ZHbhsc6wckc+qAFUHEwhgsrkRYtj4dxXm/g225hlPpI0AScraxr9lKC/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FhQ3Xjm9LYLed451PnZa7lr7pWQBC1GLGS66r+lkId4=; b=l95fOrk6JJL+oYpA9ed+YnhokDMXyV+AS1NbxnWvjjCDKoaYbHFYpv4TABggZwAfTU4R90xTX37TrFwecpq4kyI4Vn4nNT/En5TxT6tb0NHlfFrnIuxSYSva8LFTvl2UYiAmcf5cYQheXoanZHv2eEeentzF8Y+yYPO/cMVaPHM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VE1PR04MB6623.eurprd04.prod.outlook.com (2603:10a6:803:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Wed, 17 Nov 2021 09:38:07 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:07 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 02/21] ASoC: SOF: amd: Add helper callbacks for ACP's DMA configuration Date: Wed, 17 Nov 2021 11:37:15 +0200 Message-Id: <20211117093734.17407-3-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 19584666-a9da-4fc7-a4c3-08d9a9adf620 X-MS-TrafficTypeDiagnostic: VE1PR04MB6623: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J/mj5wzt+6Y5NaWpUY+HhS/ubRvy8lD/ecFfLBlzhMQPOlKUlD/om7EeGwOk9zPanXZ0nsRCZBpQ+Ti42/kAYlWHEOvlGXo26neou6vJ7PDnUvmOTiANfvcLKHA9L5XgUmpqcSNMceyORWxN3AG0pMtzMjueBNPk3ZS/hLuEwXX9Hc0gfHHIoLJmvCrQzEVs5Reb2K9VKomJyo4A9nFvqnjLPKp2vSkI9mscFZSO5gqurdmfaeVcbirDpjlO+MYfpkVy1FNdjTUiRi/LvlFPy+sS5zMOWxvchT8b35D7gdlfkN0MwkGlLDhJGCeLfjKhid50aG38AnYaHCsy7SOYwRYXyIXvwN3PE5zQb/JLofMZiALglZ8qCCFxn0PPci6gclU/T58v5Ft5mQYg62RgkxPndhxutK/lW4dLKIXRMHr1MIOhgdOMf3mDSUjHX24wMxQmtHwY7W3p61Kto0wlwC7OMquKukf2QwSLMf0OafeBY+XVtmjeepAQQSe/cb7cvz97u5ZOo1etAxQug8Eh4gFHofq1lfA+DsbYfQw8JnRCGzdaho2/i5X6GS1dYy85mu/uZA0O/8lHeNZluGvh7jXnc+QIN4DrUyiNQp+8Bp6l1XyzrujqgklINHDJ+4PZEi7GCRVaDfQjJTG5X2PJmQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(30864003)(1076003)(52116002)(6506007)(5660300002)(54906003)(8676002)(508600001)(186003)(86362001)(6666004)(2616005)(6512007)(7416002)(83380400001)(44832011)(66556008)(66476007)(4326008)(66946007)(316002)(38100700002)(6486002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KqpNn7N1/fqjr692djbLRU8/438g6C6ZVqTZR1uKy7Za3m679dBBB75ozQEjd7vx6dVYd+jSZJW1BYdbpAMXuqwunvloHo2k75ZELm6PEQxVy/BCAFYynJzYYmdu8VDIffZmMyc8VB+8eOWTzRSTaRIfdvc95lW7RsOI3cnqp068stG4QOrKr+0W+g2jS09UxIag+kNJO81a5fPW+k9VOoAHYxARYfItHJKiuXMqqh3AIvW3DR1KJztUm8x06xweikF9RBzoYpZ9y/srWJckVfV7STTu7MYvPfjAw/jzFJ51sMPBjBI306WCATrVj5JyoeQXESTs8ldVQw/18hLwIkZxLtH2iwVneUfkGd0Qyd4dQQZzcaVSJ0JQfMXKmzCBIkLWHrtc3op7J/j/appw38mijusM7u0MdQZV1NZ4TShuDzSHi0O/Ds9TzRXK3NXpsuLb8YC6GTfv/W1PMa8UvDletayXJdLXppukhRxxuSH5sTF01RDrB+ifk7LgUi5qwAZOzTkWtGKJ/7xvbMkqfreBlAmsNSc+l747pdcFPNYTybCb54tG9uuhzr0I8TJhm/DzsRvb+zLQpCiXAA6Ky/f6HHBsitClA0kBaDpkGym5qtXms2PLbbyigUhrinmuZUix3Bfp9vue4JbZIsMMEA0A1YQowaPhkTTfQrp+kelRJ2JGbh1WQOFf6XtQwMW/HgAx73yAGeB9joXITqnLWM7KwFHd/0riJOW+PKgWU+SI8/UeD9WeP3GL/u9BGGqvQb81E1qFaVFg8m0QYa9hpZ1FA3RaLXrlCw+mikccz9yB2+v7gLFaC819oV7if2qV5dPh+A8wfnRVKSSYSS7hJ0IpMLngJvgDwteu5990FVhCXeJ0oAxhSX1aNSLiLaTe4168XyuypvJxw0Ak1MTlbfOHHht8Ar8j0nNFuADTqYUlWzcUaA92eWy+JsPLQR/V6y/SooWYlDsfVhvF1XILtyx3SSevYEAZotA4Jhd2LcJ/nuVTmkZxTmH+FSvUrPtp7wmasI5Ddh23qdaaK/O3ef/N0mlERtvVFKdvSOkVV2YltraW0xvvYeB1sV7wuR1syJwcGmh820h24Jzo7V6SU5bGlUfcUwKgGMTR9VkfzOUfpiER6wk3nGjiaTHAVn1I5ik1W/FRAse2mN0A5ZwHH1HN+d35Z0FJBr1+5lYDW91VQeH8ycirjU/ILhDrGiL3kzJHem9qFeLguiC8WkD6fzrShNr928gwWVes+D2KH3fWFB6Ah2NeU1LcS3BeU+/GmRecdgqpyfXiTYvj5YIqH/8l2+B3pVYd27IzhyRi4WAxt59py2LgHKvXSBSHOX/7cf3JtnvUJti0wnJtAbfqrwpgoZcziVYKdFUVepbzGg8J/DOXyCIrT7OKaFqCNzxtjQHOQwjrQgwGHSJyCDn00kSJEngLZ19MYbGrUgEqKKqg0Gev8K/D5OsqLf+vOgRubzlaS/FgX/AeaTu1pHOaZc+i6KbjfzoO5RBx32fVtql8fJDd6jW7ZEKWz3SvAaOctYdQL+WP13L8TG15CBN0xUPfXp9AABmFNayTiNSEY0M8wQKYWAMuV7YpSGc98oMBD+Vgp2OoIuFRyMqWHi08MDY+3Qs8DOxY3q9t6H/N6a0PMMpz3N7t8wa/GdxHq5shsDgrToVehT0Zn9naNwPUbxo7Bs+qYcVUeUKHWG9Yb8kaxcnebD/in5/bFkQ3RUu9 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19584666-a9da-4fc7-a4c3-08d9a9adf620 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:07.5155 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hJpw3uMeIxsyUo+3c0YoYNIFSG2LotvAvsCzXtzFjZ91vtshI35kUqxT0U4vDh9CVjPHJ5j6jZDW2d2HKmCRAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6623 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, Vijendar Mukunda , pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ajit Kumar Pandey ACP DMA is used for loading SOF firmware into DSP memory and data transfer from system memory to DSP memory. Add helper callbacks to initialize and configure ACP DMA block for fw loading. Signed-off-by: Vijendar Mukunda Signed-off-by: Ajit Kumar Pandey Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- sound/soc/sof/amd/acp-dsp-offset.h | 47 ++++++ sound/soc/sof/amd/acp.c | 222 ++++++++++++++++++++++++++++- sound/soc/sof/amd/acp.h | 91 ++++++++++++ 3 files changed, 359 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/amd/acp-dsp-offset.h b/sound/soc/sof/amd/acp-dsp-offset.h index 2cc2a9a842c5..bfb02390b414 100644 --- a/sound/soc/sof/amd/acp-dsp-offset.h +++ b/sound/soc/sof/amd/acp-dsp-offset.h @@ -11,10 +11,57 @@ #ifndef _ACP_DSP_IP_OFFSET_H #define _ACP_DSP_IP_OFFSET_H +/* Registers from ACP_DMA_0 block */ +#define ACP_DMA_CNTL_0 0x00 +#define ACP_DMA_DSCR_STRT_IDX_0 0x20 +#define ACP_DMA_DSCR_CNT_0 0x40 +#define ACP_DMA_PRIO_0 0x60 +#define ACP_DMA_CUR_DSCR_0 0x80 +#define ACP_DMA_ERR_STS_0 0xC0 +#define ACP_DMA_DESC_BASE_ADDR 0xE0 +#define ACP_DMA_DESC_MAX_NUM_DSCR 0xE4 +#define ACP_DMA_CH_STS 0xE8 +#define ACP_DMA_CH_GROUP 0xEC +#define ACP_DMA_CH_RST_STS 0xF0 + +/* Registers from ACP_AXI2AXIATU block */ +#define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_1 0xC00 +#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_1 0xC04 +#define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_2 0xC08 +#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_2 0xC0C +#define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_3 0xC10 +#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_3 0xC14 +#define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_4 0xC18 +#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_4 0xC1C +#define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_5 0xC20 +#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_5 0xC24 +#define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_6 0xC28 +#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_6 0xC2C +#define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_7 0xC30 +#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_7 0xC34 +#define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_8 0xC38 +#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_8 0xC3C +#define ACPAXI2AXI_ATU_CTRL 0xC40 #define ACP_SOFT_RESET 0x1000 /* Registers from ACP_PGFSM block */ #define ACP_PGFSM_CONTROL 0x141C #define ACP_PGFSM_STATUS 0x1420 +/* Registers from ACP_INTR block */ +#define ACP_DSP_SW_INTR_CNTL 0x1814 +#define ACP_ERROR_STATUS 0x18C4 + +/* Registers from ACP_SHA block */ +#define ACP_SHA_DSP_FW_QUALIFIER 0x1C70 +#define ACP_SHA_DMA_CMD 0x1CB0 +#define ACP_SHA_MSG_LENGTH 0x1CB4 +#define ACP_SHA_DMA_STRT_ADDR 0x1CB8 +#define ACP_SHA_DMA_DESTINATION_ADDR 0x1CBC +#define ACP_SHA_DMA_CMD_STS 0x1CC0 +#define ACP_SHA_DMA_ERR_STATUS 0x1CC4 +#define ACP_SHA_TRANSFER_BYTE_CNT 0x1CC8 + +#define ACP_SCRATCH_REG_0 0x10000 + #endif diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c index 687a67419335..3778f781f16a 100644 --- a/sound/soc/sof/amd/acp.c +++ b/sound/soc/sof/amd/acp.c @@ -20,6 +20,219 @@ #include "acp.h" #include "acp-dsp-offset.h" +static void configure_acp_groupregisters(struct acp_dev_data *adata) +{ + struct snd_sof_dev *sdev = adata->dev; + + /* Group Enable */ + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACPAXI2AXI_ATU_BASE_ADDR_GRP_1, + ACP_SRAM_PTE_OFFSET | BIT(31)); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACPAXI2AXI_ATU_PAGE_SIZE_GRP_1, + PAGE_SIZE_4K_ENABLE); + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACPAXI2AXI_ATU_CTRL, ACP_ATU_CACHE_INVALID); +} + +static void init_dma_descriptor(struct acp_dev_data *adata) +{ + struct snd_sof_dev *sdev = adata->dev; + unsigned int addr; + + addr = ACP_SRAM_PTE_OFFSET + offsetof(struct scratch_reg_conf, dma_desc); + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DMA_DESC_BASE_ADDR, addr); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DMA_DESC_MAX_NUM_DSCR, ACP_MAX_DESC_CNT); +} + +static void configure_dma_descriptor(struct acp_dev_data *adata, unsigned short idx, + struct dma_descriptor *dscr_info) +{ + struct snd_sof_dev *sdev = adata->dev; + unsigned int offset; + + offset = ACP_SCRATCH_REG_0 + offsetof(struct scratch_reg_conf, dma_desc) + + idx * sizeof(struct dma_descriptor); + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, offset, dscr_info->src_addr); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, offset + 0x4, dscr_info->dest_addr); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, offset + 0x8, dscr_info->tx_cnt.u32_all); +} + +static int config_dma_channel(struct acp_dev_data *adata, unsigned int ch, + unsigned int idx, unsigned int dscr_count) +{ + struct snd_sof_dev *sdev = adata->dev; + unsigned int val, status; + int ret; + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DMA_CNTL_0 + ch * sizeof(u32), + ACP_DMA_CH_RST | ACP_DMA_CH_GRACEFUL_RST_EN); + + ret = snd_sof_dsp_read_poll_timeout(sdev, ACP_DSP_BAR, ACP_DMA_CH_RST_STS, val, + val & (1 << ch), ACP_REG_POLL_INTERVAL, + ACP_REG_POLL_TIMEOUT_US); + if (ret < 0) { + status = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_ERROR_STATUS); + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_DMA_ERR_STS_0 + ch * sizeof(u32)); + + dev_err(sdev->dev, "ACP_DMA_ERR_STS :0x%x ACP_ERROR_STATUS :0x%x\n", val, status); + return ret; + } + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, (ACP_DMA_CNTL_0 + ch * sizeof(u32)), 0); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DMA_DSCR_CNT_0 + ch * sizeof(u32), dscr_count); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DMA_DSCR_STRT_IDX_0 + ch * sizeof(u32), idx); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DMA_PRIO_0 + ch * sizeof(u32), 0); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DMA_CNTL_0 + ch * sizeof(u32), ACP_DMA_CH_RUN); + + return ret; +} + +static int acpbus_dma_start(struct acp_dev_data *adata, unsigned int ch, + unsigned int dscr_count, struct dma_descriptor *dscr_info) +{ + struct snd_sof_dev *sdev = adata->dev; + int ret; + u16 dscr; + + if (!dscr_info || !dscr_count) + return -EINVAL; + + for (dscr = 0; dscr < dscr_count; dscr++) + configure_dma_descriptor(adata, dscr, dscr_info++); + + ret = config_dma_channel(adata, ch, 0, dscr_count); + if (ret < 0) + dev_err(sdev->dev, "config dma ch failed:%d\n", ret); + + return ret; +} + +int configure_and_run_dma(struct acp_dev_data *adata, unsigned int src_addr, + unsigned int dest_addr, int dsp_data_size) +{ + struct snd_sof_dev *sdev = adata->dev; + unsigned int desc_count, index; + int ret; + + for (desc_count = 0; desc_count < ACP_MAX_DESC && dsp_data_size >= 0; + desc_count++, dsp_data_size -= ACP_PAGE_SIZE) { + adata->dscr_info[desc_count].src_addr = src_addr + desc_count * ACP_PAGE_SIZE; + adata->dscr_info[desc_count].dest_addr = dest_addr + desc_count * ACP_PAGE_SIZE; + adata->dscr_info[desc_count].tx_cnt.bits.count = ACP_PAGE_SIZE; + if (dsp_data_size < ACP_PAGE_SIZE) + adata->dscr_info[desc_count].tx_cnt.bits.count = dsp_data_size; + } + + ret = acpbus_dma_start(adata, 0, desc_count, adata->dscr_info); + if (ret) + dev_err(sdev->dev, "acpbus_dma_start failed\n"); + + /* Clear descriptor array */ + for (index = 0; index < desc_count; index++) + memset(&adata->dscr_info[index], 0x00, sizeof(struct dma_descriptor)); + + return ret; +} + +int configure_and_run_sha_dma(struct acp_dev_data *adata, void *image_addr, + unsigned int start_addr, unsigned int dest_addr, + unsigned int image_length) +{ + struct snd_sof_dev *sdev = adata->dev; + unsigned int tx_count, fw_qualifier, val; + int ret; + + if (!image_addr) { + dev_err(sdev->dev, "SHA DMA image address is NULL\n"); + return -EINVAL; + } + + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SHA_DMA_CMD); + if (val & ACP_SHA_RUN) { + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SHA_DMA_CMD, ACP_SHA_RESET); + ret = snd_sof_dsp_read_poll_timeout(sdev, ACP_DSP_BAR, ACP_SHA_DMA_CMD_STS, + val, val & ACP_SHA_RESET, + ACP_REG_POLL_INTERVAL, + ACP_REG_POLL_TIMEOUT_US); + if (ret < 0) { + dev_err(sdev->dev, "SHA DMA Failed to Reset\n"); + return ret; + } + } + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SHA_DMA_STRT_ADDR, start_addr); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SHA_DMA_DESTINATION_ADDR, dest_addr); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SHA_MSG_LENGTH, image_length); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SHA_DMA_CMD, ACP_SHA_RUN); + + ret = snd_sof_dsp_read_poll_timeout(sdev, ACP_DSP_BAR, ACP_SHA_TRANSFER_BYTE_CNT, + tx_count, tx_count == image_length, + ACP_REG_POLL_INTERVAL, ACP_DMA_COMPLETE_TIMEOUT_US); + if (ret < 0) { + dev_err(sdev->dev, "SHA DMA Failed to Transfer Length %x\n", tx_count); + return ret; + } + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SHA_DSP_FW_QUALIFIER, DSP_FW_RUN_ENABLE); + + fw_qualifier = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SHA_DSP_FW_QUALIFIER); + if (!(fw_qualifier & DSP_FW_RUN_ENABLE)) { + dev_err(sdev->dev, "PSP validation failed\n"); + return -EINVAL; + } + + return ret; +} + +int acp_dma_status(struct acp_dev_data *adata, unsigned char ch) +{ + struct snd_sof_dev *sdev = adata->dev; + unsigned int val; + int ret = 0; + + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_DMA_CNTL_0 + ch * sizeof(u32)); + if (val & ACP_DMA_CH_RUN) { + ret = snd_sof_dsp_read_poll_timeout(sdev, ACP_DSP_BAR, ACP_DMA_CH_STS, val, !val, + ACP_REG_POLL_INTERVAL, + ACP_DMA_COMPLETE_TIMEOUT_US); + if (ret < 0) + dev_err(sdev->dev, "DMA_CHANNEL %d status timeout\n", ch); + } + + return ret; +} + +void memcpy_from_scratch(struct snd_sof_dev *sdev, u32 offset, unsigned int *dst, size_t bytes) +{ + unsigned int reg_offset = offset + ACP_SCRATCH_REG_0; + int i, j; + + for (i = 0, j = 0; i < bytes; i = i + 4, j++) + dst[j] = snd_sof_dsp_read(sdev, ACP_DSP_BAR, reg_offset + i); +} + +void memcpy_to_scratch(struct snd_sof_dev *sdev, u32 offset, unsigned int *src, size_t bytes) +{ + unsigned int reg_offset = offset + ACP_SCRATCH_REG_0; + int i, j; + + for (i = 0, j = 0; i < bytes; i = i + 4, j++) + snd_sof_dsp_write(sdev, ACP_DSP_BAR, reg_offset + i, src[j]); +} + +static int acp_memory_init(struct snd_sof_dev *sdev) +{ + struct acp_dev_data *adata = sdev->pdata->hw_pdata; + + snd_sof_dsp_update_bits(sdev, ACP_DSP_BAR, ACP_DSP_SW_INTR_CNTL, + ACP_DSP_INTR_EN_MASK, ACP_DSP_INTR_EN_MASK); + configure_acp_groupregisters(adata); + init_dma_descriptor(adata); + + return 0; +} + static int acp_power_on(struct snd_sof_dev *sdev) { unsigned int val; @@ -86,6 +299,7 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) struct pci_dev *pci = to_pci_dev(sdev->dev); struct acp_dev_data *adata; unsigned int addr; + int ret; adata = devm_kzalloc(sdev->dev, sizeof(struct acp_dev_data), GFP_KERNEL); @@ -104,7 +318,13 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) sdev->pdata->hw_pdata = adata; - return acp_init(sdev); + ret = acp_init(sdev); + if (ret < 0) + return ret; + + acp_memory_init(sdev); + + return 0; } EXPORT_SYMBOL_NS(amd_sof_acp_probe, SND_SOC_SOF_AMD_COMMON); diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index c7ac8f9941d5..ff01d0ef67ef 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -15,6 +15,7 @@ #define ACP_REG_POLL_INTERVAL 500 #define ACP_REG_POLL_TIMEOUT_US 2000 +#define ACP_DMA_COMPLETE_TIMEOUT_US 5000 #define ACP_PGFSM_CNTL_POWER_ON_MASK 0x01 #define ACP_PGFSM_STATUS_MASK 0x03 @@ -23,11 +24,101 @@ #define ACP_RELEASE_RESET 0x00 #define ACP_SOFT_RESET_DONE_MASK 0x00010001 +#define ACP_DSP_INTR_EN_MASK 0x00000001 +#define ACP_SRAM_PTE_OFFSET 0x02050000 +#define PAGE_SIZE_4K_ENABLE 0x2 +#define ACP_PAGE_SIZE 0x1000 +#define ACP_DMA_CH_RUN 0x02 +#define ACP_MAX_DESC_CNT 0x02 +#define DSP_FW_RUN_ENABLE 0x01 +#define ACP_SHA_RUN 0x01 +#define ACP_SHA_RESET 0x02 +#define ACP_DMA_CH_RST 0x01 +#define ACP_DMA_CH_GRACEFUL_RST_EN 0x10 +#define ACP_ATU_CACHE_INVALID 0x01 +#define ACP_MAX_DESC 128 +#define ACPBUS_REG_BASE_OFFSET ACP_DMA_CNTL_0 + +struct acp_atu_grp_pte { + u32 low; + u32 high; +}; + +union dma_tx_cnt { + struct { + unsigned int count : 19; + unsigned int reserved : 12; + unsigned ioc : 1; + } bitfields, bits; + unsigned int u32_all; + signed int i32_all; +}; + +struct dma_descriptor { + unsigned int src_addr; + unsigned int dest_addr; + union dma_tx_cnt tx_cnt; + unsigned int reserved; +}; + +/* Scratch memory structure for communication b/w host and dsp */ +struct scratch_ipc_conf { + /* DSP mailbox */ + u8 sof_out_box[512]; + /* Host mailbox */ + u8 sof_in_box[512]; + /* Debug memory */ + u8 sof_debug_box[1024]; + /* Exception memory*/ + u8 sof_except_box[1024]; + /* Stream buffer */ + u8 sof_stream_box[1024]; + /* Trace buffer */ + u8 sof_trace_box[1024]; + /* Host msg flag */ + u32 sof_host_msg_write; + /* Host ack flag*/ + u32 sof_host_ack_write; + /* DSP msg flag */ + u32 sof_dsp_msg_write; + /* Dsp ack flag */ + u32 sof_dsp_ack_write; +}; + +struct scratch_reg_conf { + struct scratch_ipc_conf info; + struct acp_atu_grp_pte grp1_pte[16]; + struct acp_atu_grp_pte grp2_pte[16]; + struct acp_atu_grp_pte grp3_pte[16]; + struct acp_atu_grp_pte grp4_pte[16]; + struct acp_atu_grp_pte grp5_pte[16]; + struct acp_atu_grp_pte grp6_pte[16]; + struct acp_atu_grp_pte grp7_pte[16]; + struct acp_atu_grp_pte grp8_pte[16]; + struct dma_descriptor dma_desc[64]; + unsigned int reg_offset[8]; + unsigned int buf_size[8]; + u8 acp_tx_fifo_buf[256]; + u8 acp_rx_fifo_buf[256]; + unsigned int reserve[]; +}; + /* Common device data struct for ACP devices */ struct acp_dev_data { struct snd_sof_dev *dev; + struct dma_descriptor dscr_info[ACP_MAX_DESC]; }; +void memcpy_to_scratch(struct snd_sof_dev *sdev, u32 offset, unsigned int *src, size_t bytes); +void memcpy_from_scratch(struct snd_sof_dev *sdev, u32 offset, unsigned int *dst, size_t bytes); + +int acp_dma_status(struct acp_dev_data *adata, unsigned char ch); +int configure_and_run_dma(struct acp_dev_data *adata, unsigned int src_addr, + unsigned int dest_addr, int dsp_data_size); +int configure_and_run_sha_dma(struct acp_dev_data *adata, void *image_addr, + unsigned int start_addr, unsigned int dest_addr, + unsigned int image_length); + /* ACP device probe/remove */ int amd_sof_acp_probe(struct snd_sof_dev *sdev); int amd_sof_acp_remove(struct snd_sof_dev *sdev); From patchwork Wed Nov 17 09:37:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624147 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 BF09BC433F5 for ; Wed, 17 Nov 2021 09:40:14 +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 E529560C4A for ; Wed, 17 Nov 2021 09:40:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E529560C4A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 62D1A188F; Wed, 17 Nov 2021 10:39:22 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 62D1A188F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142012; bh=+OFKOxkIQMnrB2Jp24B2LFWr2aJmMcuVP0PZvRmWvvE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=q3MKDe4q/CblmQWHqa4H64fqLj9f9uPF8HejY9y/7vQ2BhOmO77kc0hMplVtOEQLE NtOVswHW3iyKS0bcDdIJjBoM0z+GF+HrdORvkL9OnnwyRT6yB3GGjZMJtzYs9hPIa9 Z8PfKRKCBtbbCvVMfyFxq0gLhefo9dEZlg/6K2d8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B65BDF804FB; Wed, 17 Nov 2021 10:38:31 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 689F8F804BB; Wed, 17 Nov 2021 10:38:20 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60071.outbound.protection.outlook.com [40.107.6.71]) (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 0D392F8020D for ; Wed, 17 Nov 2021 10:38:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0D392F8020D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="eSA15jq+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aYTAf7C7GGl1xH+Y269mLApb3apoOtmDu7VrAhwVYiWI264Oy4dyBl4Eubv/z9U8tSHYZxW4D7LK3UQJm4DiTe0OaDhyO70GfOc7qDbbZ8Dpb7tQvdwby4nVpe6eZwV04f/XF4vP75mVsN5HCZfZVM4TdixyTIpsvl+0Aema0Z5NA77sdCS6HQg0EzCEQ1JqzayQeWGPhcEf19Gd8QnEjCWFZt53ySPAtBPSTBH2sOF5CAskObcS4PW7wkUd6C1PV6c/lkIYdFvhXs6EdZ9cjYUD06BXw3n9fXNd3IdKS1uez1aiNN3Xgv1y4zVN0SEfNEnQRS0eEWNNZkayq5taQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5SQtkRTR8criD+o3nbzDMRFdBeLReV2MJHMMi1lIszc=; b=V98aV9gSTUEU1M5UXFpbTGRdkADSaezuftI8quxyMWj+goIQOXnsKGiBVpYalxI0/wXt99RX/hSzseVGAIBANYYgfE2KvWPYPimldGnKBsnoLLfqEH3YvlTpHv0TMfrApjtUiJaIj5fhreHZoxoceZA24gQiVyuIjqCwJGabM8pnPX9wZLiqceSUW2fE/AWeVKmM2KqliEXxIiCBGAKLbLGur9Ub5SqLR0EXQ2R0CFLk+UeU8rREZLq3I3sTGQN5rolaj663X6FMxrj0qfe0EjFVcXMJf1CPDhBNWtKkn/DjuJgpjnqXC4uHMfQmyECP+li9j7R+jqx2cE9R1m0d5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5SQtkRTR8criD+o3nbzDMRFdBeLReV2MJHMMi1lIszc=; b=eSA15jq+m8sayMrezYYRXq6gUI7FilhVAO1nXHZ3d+q0GEWWJJXD39NPz6692Sx37L5EW2968AyrKMiiTllN8QoZzhGW5gQpUJMhmyJTLmGBFVaCDpSn7YDjELzTuomE+pY6faDmauI/0qIRdYR+YTw7u3uCY4PFl2OnQ2djz4k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 09:38:09 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:09 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 03/21] ASoC: SOF: amd: Add fw loader and renoir dsp ops to load firmware Date: Wed, 17 Nov 2021 11:37:16 +0200 Message-Id: <20211117093734.17407-4-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e3a6d6e-3106-4273-4cc4-08d9a9adf72a X-MS-TrafficTypeDiagnostic: VI1PR04MB5807: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True 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: XHFRhCc7XTceA19Jol4MMeWoDAAMSVudzd4NZr0Uoev/hKHS8x6OF8HaHWUE5lQRN9RNc7IhivUeF0S9Z4fVocabvQ2dq2PYoso3Kso9JKpIU2LmoTDgos3uQwneMw0EyV+BK6wAPayW627DlPpE/P+L0YarVUW+MWcWV1A8caJmgOLwxnYgnRmMUKgwkt+3Zf+UDDOSWSK3h7/MkZBF9WDYSb4SIuhK6e/6kHer4siHaCuArke+zpgTwCfsZf2i5kqrbgeD/pApDz2MNqVPdO24KRt+ZShAjRvQO78O2rTreAnpLz3Pl5c3NyjoRhCUZm5EsehbknFPMous+aLwPE0OiC6sBUBF8jJXVhyR3aw/ubTs6J3dSyLZv7GAd2BVOQHOcGUoM6OM19rRyfkvdpgZTPAx3qdd4io4i/7M6NwgsHhwjVwdgdIJii9009gOKd9lJ6I9JpcEBm/qPzAZOMRO7l3xK6d55h2LAfAlaMGG0ifx4NfSCf2rnk8r6pXmk3Ep9btGA1OVrH7kjl4FO+3nxbWajfg0RPF3HdMTwL6V8kvzA0GBDnIfQ2MEHfeeVLmgebcnRUFGz58IHAFEfGspoZXwOTf3E6xpheCOk+q1ARKBnjteJhzDaLpPYkE/Gn1aCet3/ws1xSc4cUjLCw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(316002)(5660300002)(508600001)(52116002)(86362001)(8676002)(54906003)(8936002)(66946007)(186003)(6512007)(2906002)(6666004)(6486002)(7416002)(6506007)(1076003)(2616005)(66556008)(66476007)(44832011)(83380400001)(38100700002)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UziMQVqiKB5clcesK5+dXrGcBOvF/ndvUXhRrEXNvp5LlSKfbhwrfPWB1IrTtur4IT+/l9VQ2uOt/bZFsaRw241NZjgizPXVXCIVu1032+Zc10YSnJT/dztDnu8WvkSsciYu0PyHDbUd4GP1Jc0uwFB8ltfEuv6aNH92mf/1SAaE7r2VTDolDIGqRLBXjSs5imG0fEadlFJjBZG8jqUd0yRwfKTeiAM5NKVyDClr7e9UAaJBET9SuytX4ilPSm0vcOiscco5jfxDXTrHqsS/NoqAL4c32WzqoJinVf3qidFOQEjWi66N/npju7kNfU5K3qpoY40+Dxs1Us2sjEIKbqBY7emrYEHZH/0BbTm3/mvFT+FtvX3HZLZ3r8vGNQ24ehcfmemfTORH7wwgClPIvLphQcofUleqR0PymW6fjjIcWpMM6wiTff5z7KeQKfGe7AU7R/MRyvQRMKB56yWU9JPIGaDGdqywHMb6rAOz5qdC5P38A1yb9tjor+h77WAFhXlt9MDKtfXIQDlub1COS9P8O9kZlL/oSz7jzh2bsvEjT3HmF6XClN8bGyYLEnn01rdgu1iuIfx0GvHW9a25pmg2vM+sticAirUZ8C6n1v6byyQr2Qy12hf3w5LanNscjmVhfi2F7qHukCguYwjNtXB6MSJKYQKVst7CJbTntd0JSFx8AKXsVU6p7GDSlIMXai+sfk5ldNeqxzryjOCrKfHHxItZMtPIWgkS/G3EVydwTnBV8MO7JA6biNjD7QeTqUpWKtAMf6Xh5SDLoZbwnx7/DI0Hdij1/g1XmKv8sOVMJUXqTSHDlPXWFNw/48FG0UwbKVs8LGqUU4COWlHygxsYRi+koN5cUM156/ZaVfjtNuKhUF1drOq/xxL3GiWwEkLJI14eGAj3zoCLhdeehykOyAxwDt0jIepIsTtnmicyOI8l/Sv5d+nAJFiHBkxMWGaDhJZk9WyMhMXBTv/yR+2MUQc+0j9OTgaR+3l2I9DHgfpoByW49LQSml6BxA5SnYMf+9X9wmGEjBeOfATizJ9+M/kgXrJvo5Y10yt0WIEYjDTWEIxRwrk4F4xFVxJEBMRIZ3VbfBkuLv1IH6PMD4LAl3ElSJxjcdAYPo4pPMiPHVo1za4Jvxi80in2nUwkbF8ZqqKP8TSanSQ3IEyIN5dmQCfkRY9CFSGnyLOVo0iHVi6x046Hu++amnwuxyNl7rvp8El/svKRvoLEDLcWoeJXNDH+umcHqmX9NscEuvKPdl+oVbinQyLfCzArk4in8hSg6eWSP3zYh/ubnY5vvGmY2Z/DWii2TMnmevuff67x10HCjKv638bWenNwXqvLbmHdwjto/9IYCvqKpSGdMPDPeXU5rIx0v6XCD7CFhcf0pqusfVEbgwjPpcBd2BKNJ/bsV7jC4/NE2A9fKLNM4bKOK5dPzVidFf+lZSF4rkbaGOlSs59Q+Lbn98Umx8MTu9/D1wy6PRsBLm7orMQo6zPmCClm0nLcVABlSymjKRSRauz+xC9v0VupDsZSg5aHiy5u9+qkVsEoakjWPt7f0c0QOtD+gy3rqrbbBqZkOdEDYpNCUulLbTeCuf0kds2EaeIPUdU0+xznS3kQICCEy3Jzh6D8Cs9xXkz7EcLQAUOQ70aj/Agdu9rgMPT89TIRMk9Lf5CyIQ6yGebjgf8QmkN1zbY9DeTzXwnnhyosX2zVJ3wSfUeoLJ75oFzGigRK X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e3a6d6e-3106-4273-4cc4-08d9a9adf72a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:09.2405 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8yZgMX0bmmdx4ogHhNzOiA0L7erokEZWgTHcv5vagxbw7nozYCHRtflmME0kTn/HeMqyLZpFX231qZi7NsMjag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5807 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ajit Kumar Pandey Add acp-loader module with ops callback to load and run firmware on ACP DSP block on Renoir platform. Signed-off-by: Ajit Kumar Pandey Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- sound/soc/sof/amd/Makefile | 2 +- sound/soc/sof/amd/acp-dsp-offset.h | 3 + sound/soc/sof/amd/acp-loader.c | 199 +++++++++++++++++++++++++++++ sound/soc/sof/amd/acp.h | 27 ++++ sound/soc/sof/amd/renoir.c | 15 +++ 5 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 sound/soc/sof/amd/acp-loader.c diff --git a/sound/soc/sof/amd/Makefile b/sound/soc/sof/amd/Makefile index ac2ecd21be5f..031fb9493876 100644 --- a/sound/soc/sof/amd/Makefile +++ b/sound/soc/sof/amd/Makefile @@ -4,7 +4,7 @@ # # Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. -snd-sof-amd-acp-objs := acp.o +snd-sof-amd-acp-objs := acp.o acp-loader.o snd-sof-amd-renoir-objs := renoir.o obj-$(CONFIG_SND_SOC_SOF_AMD_COMMON) += snd-sof-amd-acp.o diff --git a/sound/soc/sof/amd/acp-dsp-offset.h b/sound/soc/sof/amd/acp-dsp-offset.h index bfb02390b414..f4bc7e9abafb 100644 --- a/sound/soc/sof/amd/acp-dsp-offset.h +++ b/sound/soc/sof/amd/acp-dsp-offset.h @@ -24,6 +24,9 @@ #define ACP_DMA_CH_GROUP 0xEC #define ACP_DMA_CH_RST_STS 0xF0 +/* Registers from ACP_DSP_0 block */ +#define ACP_DSP0_RUNSTALL 0x414 + /* Registers from ACP_AXI2AXIATU block */ #define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_1 0xC00 #define ACPAXI2AXI_ATU_BASE_ADDR_GRP_1 0xC04 diff --git a/sound/soc/sof/amd/acp-loader.c b/sound/soc/sof/amd/acp-loader.c new file mode 100644 index 000000000000..2dc15ae38155 --- /dev/null +++ b/sound/soc/sof/amd/acp-loader.c @@ -0,0 +1,199 @@ +// 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 ACP DSP Firmware binaries loader + */ + +#include +#include +#include + +#include "../ops.h" +#include "acp-dsp-offset.h" +#include "acp.h" + +#define FW_BIN 0 +#define FW_DATA_BIN 1 + +#define FW_BIN_PTE_OFFSET 0x00 +#define FW_DATA_BIN_PTE_OFFSET 0x08 + +#define ACP_DSP_RUN 0x00 + +int acp_dsp_block_read(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type, + u32 offset, void *dest, size_t size) +{ + switch (blk_type) { + case SOF_FW_BLK_TYPE_SRAM: + offset = offset - ACP_SCRATCH_MEMORY_ADDRESS; + memcpy_from_scratch(sdev, offset, dest, size); + break; + default: + dev_err(sdev->dev, "bad blk type 0x%x\n", blk_type); + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL_NS(acp_dsp_block_read, SND_SOC_SOF_AMD_COMMON); + +int acp_dsp_block_write(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type, + u32 offset, void *src, size_t size) +{ + struct snd_sof_pdata *plat_data = sdev->pdata; + struct pci_dev *pci = to_pci_dev(sdev->dev); + struct acp_dev_data *adata; + void *dest; + u32 dma_size, page_count; + unsigned int size_fw; + + adata = sdev->pdata->hw_pdata; + + switch (blk_type) { + case SOF_FW_BLK_TYPE_IRAM: + if (!adata->bin_buf) { + size_fw = plat_data->fw->size; + page_count = PAGE_ALIGN(size_fw) >> PAGE_SHIFT; + dma_size = page_count * ACP_PAGE_SIZE; + adata->bin_buf = dma_alloc_coherent(&pci->dev, dma_size, + &adata->sha_dma_addr, + GFP_ATOMIC); + if (!adata->bin_buf) + return -ENOMEM; + } + adata->fw_bin_size = size + offset; + dest = adata->bin_buf + offset; + break; + case SOF_FW_BLK_TYPE_DRAM: + if (!adata->data_buf) { + adata->data_buf = dma_alloc_coherent(&pci->dev, + ACP_DEFAULT_DRAM_LENGTH, + &adata->dma_addr, + GFP_ATOMIC); + if (!adata->data_buf) + return -ENOMEM; + } + dest = adata->data_buf + offset; + adata->fw_data_bin_size = size + offset; + break; + case SOF_FW_BLK_TYPE_SRAM: + offset = offset - ACP_SCRATCH_MEMORY_ADDRESS; + memcpy_to_scratch(sdev, offset, src, size); + return 0; + default: + dev_err(sdev->dev, "bad blk type 0x%x\n", blk_type); + return -EINVAL; + } + + memcpy(dest, src, size); + return 0; +} +EXPORT_SYMBOL_NS(acp_dsp_block_write, SND_SOC_SOF_AMD_COMMON); + +int acp_get_bar_index(struct snd_sof_dev *sdev, u32 type) +{ + return type; +} +EXPORT_SYMBOL_NS(acp_get_bar_index, SND_SOC_SOF_AMD_COMMON); + +static void configure_pte_for_fw_loading(int type, int num_pages, struct acp_dev_data *adata) +{ + struct snd_sof_dev *sdev; + unsigned int low, high; + dma_addr_t addr; + u16 page_idx; + u32 offset; + + sdev = adata->dev; + + switch (type) { + case FW_BIN: + offset = FW_BIN_PTE_OFFSET; + addr = adata->sha_dma_addr; + break; + case FW_DATA_BIN: + offset = adata->fw_bin_page_count * 8; + addr = adata->dma_addr; + break; + default: + dev_err(sdev->dev, "Invalid data type %x\n", type); + return; + } + + for (page_idx = 0; page_idx < num_pages; page_idx++) { + low = lower_32_bits(addr); + high = upper_32_bits(addr); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + offset, low); + high |= BIT(31); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + offset + 4, high); + offset += 8; + addr += PAGE_SIZE; + } +} + +/* pre fw run operations */ +int acp_dsp_pre_fw_run(struct snd_sof_dev *sdev) +{ + struct pci_dev *pci = to_pci_dev(sdev->dev); + struct snd_sof_pdata *plat_data = sdev->pdata; + struct acp_dev_data *adata; + unsigned int src_addr, size_fw; + u32 page_count, dma_size; + int ret; + + adata = sdev->pdata->hw_pdata; + size_fw = adata->fw_bin_size; + + page_count = PAGE_ALIGN(size_fw) >> PAGE_SHIFT; + adata->fw_bin_page_count = page_count; + + configure_pte_for_fw_loading(FW_BIN, page_count, adata); + ret = configure_and_run_sha_dma(adata, adata->bin_buf, ACP_SYSTEM_MEMORY_WINDOW, + ACP_IRAM_BASE_ADDRESS, size_fw); + if (ret < 0) { + dev_err(sdev->dev, "SHA DMA transfer failed status: %d\n", ret); + return ret; + } + configure_pte_for_fw_loading(FW_DATA_BIN, ACP_DRAM_PAGE_COUNT, adata); + + src_addr = ACP_SYSTEM_MEMORY_WINDOW + page_count * ACP_PAGE_SIZE; + ret = configure_and_run_dma(adata, src_addr, ACP_DATA_RAM_BASE_ADDRESS, + adata->fw_data_bin_size); + if (ret < 0) { + dev_err(sdev->dev, "acp dma configuration failed: %d\n", ret); + return ret; + } + + ret = acp_dma_status(adata, 0); + if (ret < 0) + dev_err(sdev->dev, "acp dma transfer status: %d\n", ret); + + /* Free memory once DMA is complete */ + dma_size = (PAGE_ALIGN(plat_data->fw->size) >> PAGE_SHIFT) * ACP_PAGE_SIZE; + dma_free_coherent(&pci->dev, dma_size, adata->bin_buf, adata->sha_dma_addr); + dma_free_coherent(&pci->dev, ACP_DEFAULT_DRAM_LENGTH, adata->data_buf, adata->dma_addr); + adata->bin_buf = NULL; + adata->data_buf = NULL; + + return ret; +} +EXPORT_SYMBOL_NS(acp_dsp_pre_fw_run, SND_SOC_SOF_AMD_COMMON); + +int acp_sof_dsp_run(struct snd_sof_dev *sdev) +{ + int val; + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DSP0_RUNSTALL, ACP_DSP_RUN); + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_DSP0_RUNSTALL); + dev_dbg(sdev->dev, "ACP_DSP0_RUNSTALL : 0x%0x\n", val); + + return 0; +} +EXPORT_SYMBOL_NS(acp_sof_dsp_run, SND_SOC_SOF_AMD_COMMON); diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index ff01d0ef67ef..e755a31374c6 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -11,6 +11,8 @@ #ifndef __SOF_AMD_ACP_H #define __SOF_AMD_ACP_H +#include "../sof-priv.h" + #define ACP_DSP_BAR 0 #define ACP_REG_POLL_INTERVAL 500 @@ -39,6 +41,13 @@ #define ACP_MAX_DESC 128 #define ACPBUS_REG_BASE_OFFSET ACP_DMA_CNTL_0 +#define ACP_DEFAULT_DRAM_LENGTH 0x00080000 +#define ACP_SCRATCH_MEMORY_ADDRESS 0x02050000 +#define ACP_SYSTEM_MEMORY_WINDOW 0x4000000 +#define ACP_IRAM_BASE_ADDRESS 0x000000 +#define ACP_DATA_RAM_BASE_ADDRESS 0x01000000 +#define ACP_DRAM_PAGE_COUNT 128 + struct acp_atu_grp_pte { u32 low; u32 high; @@ -106,6 +115,13 @@ struct scratch_reg_conf { /* Common device data struct for ACP devices */ struct acp_dev_data { struct snd_sof_dev *dev; + unsigned int fw_bin_size; + unsigned int fw_data_bin_size; + u32 fw_bin_page_count; + dma_addr_t sha_dma_addr; + u8 *bin_buf; + dma_addr_t dma_addr; + u8 *data_buf; struct dma_descriptor dscr_info[ACP_MAX_DESC]; }; @@ -123,5 +139,16 @@ int configure_and_run_sha_dma(struct acp_dev_data *adata, void *image_addr, int amd_sof_acp_probe(struct snd_sof_dev *sdev); int amd_sof_acp_remove(struct snd_sof_dev *sdev); +/* DSP Loader callbacks */ +int acp_sof_dsp_run(struct snd_sof_dev *sdev); +int acp_dsp_pre_fw_run(struct snd_sof_dev *sdev); +int acp_get_bar_index(struct snd_sof_dev *sdev, u32 type); + +/* Block IO callbacks */ +int acp_dsp_block_write(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type, + u32 offset, void *src, size_t size); +int acp_dsp_block_read(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type, + u32 offset, void *dest, size_t size); + extern const struct snd_sof_dsp_ops sof_renoir_ops; #endif diff --git a/sound/soc/sof/amd/renoir.c b/sound/soc/sof/amd/renoir.c index 3d1dc6c2fa9b..bca80784b322 100644 --- a/sound/soc/sof/amd/renoir.c +++ b/sound/soc/sof/amd/renoir.c @@ -26,6 +26,21 @@ const struct snd_sof_dsp_ops sof_renoir_ops = { /* Register IO */ .write = sof_io_write, .read = sof_io_read, + + /* Block IO */ + .block_read = acp_dsp_block_read, + .block_write = acp_dsp_block_write, + + /* Module loading */ + .load_module = snd_sof_parse_module_memcpy, + + /*Firmware loading */ + .load_firmware = snd_sof_load_firmware_memcpy, + .pre_fw_run = acp_dsp_pre_fw_run, + .get_bar_index = acp_get_bar_index, + + /* DSP core boot */ + .run = acp_sof_dsp_run, }; EXPORT_SYMBOL(sof_renoir_ops); From patchwork Wed Nov 17 09:37:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624149 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 A0371C433F5 for ; Wed, 17 Nov 2021 09:40:36 +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 1B3ED61357 for ; Wed, 17 Nov 2021 09:40:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1B3ED61357 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 77E4C181F; Wed, 17 Nov 2021 10:39:44 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 77E4C181F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142034; bh=0plfYqZYZMZsQMN/TO6FjNkHPUkACe+HWDYHukne2LQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AoY0EkroTbAn7NfAVyJgpU+J5A2430+ygX3H1Q/12wp3Lv5Cxc58vEzyjS7/3AOw2 05tWSdNlghETQKk4dbf9IjyYNi1R4Wt0KBPpLi3Jtk/1fpHh2BnEnO+uWSGmZZtitF m1/FRIjw/+9YXu9DhJrDwysDdkoiQ5ksUoMTwjII= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B3063F804FF; Wed, 17 Nov 2021 10:38:32 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8D17AF8049C; Wed, 17 Nov 2021 10:38:21 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60062.outbound.protection.outlook.com [40.107.6.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A2D26F800FA for ; Wed, 17 Nov 2021 10:38:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A2D26F800FA Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="FBGz0DM8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BVc/kOCPHvPmItdXXIm56McRzjz+UiZ3yQWLZG/5iaMSHHevR/JlUMXgaj/MN953dsIfhb3JyDlbgl4Ly8Pry4T10B/NURkj0XAY+q/2EywOTQd85dRsS4g1YVHVsydnBR0CdPnD27iIgJm0jjQ2PQQ6Jy6zYzAgfr6hl64HJ1JfncUdCOXPMs7LIcJUxzwP1vGAxz0kQwSjuRpIZY6EEJ/rxBx9hmxGwSpXTTovxE/64YyCHWhuraD4lutaRdSWWQhT3jg0XGcSmavmvoUVauAM+PnpXRiB5aACr2mKM0sMWRbewQuhCy4tmcyLj0N8ksM4YvOJwVDzno6S73EAxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DPdlo+6pwsRBvInyTokAcfakh2ZqdIgg14lFc9xY4YM=; b=RhifbhqZwmBYwxudg4aQ6u2SBOmXU7bfh6mCG/x0SDUVQGBU15Smqh/8DUT4UyZw5mp6rCfgLPHCFCI2Gi0ZFBJDpxCsMLl7945ObnmXZYDTerzRRDbDaubZZd0s9y5rnunwIIYbDeJPHVqKLegFQm6sc1OVG0SR3T72RJ9Xg9H24i/6Z/z6MDBInFLDdRDainqRjq8jlsI2/xL5xo1InW5jJ9LGhhB9rNJ/sdYjZDgjMQAp7exmetK5WevXyPK4b+chGhjQWGFM3DPX5NQQt+7P2w8K748Gma2wWye9qYbx6wkAQ9DB515InluULFiGYf3lipijpeFbqiaFFS+xZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DPdlo+6pwsRBvInyTokAcfakh2ZqdIgg14lFc9xY4YM=; b=FBGz0DM8O9E7tmiHuf4XYED8VptPCyXwp372DhDER/7v/wzXHbjhn/dULulmz/JjSstQtVoMEjtTKt/GrUq1e6fEmOILl2J+fw1xUe0b2Z/BuCE23VloS6g86jzWOVRzCR8669jfeHyty8j+1aokn5MoMlYSQ6q7uzvtLWxhfUE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 09:38:11 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:11 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 04/21] ASoC: SOF: amd: Add IPC support for ACP IP block Date: Wed, 17 Nov 2021 11:37:17 +0200 Message-Id: <20211117093734.17407-5-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f748bd21-8c50-40d8-6945-08d9a9adf83d X-MS-TrafficTypeDiagnostic: VI1PR04MB5807: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QbewlODu9LxKCt/NYU+ODqhh3TPJfFh2ws2Xyb0UgA7lDXzuDpzfXEA308/2stj4eXKe7FM81MfOccMpeq/FJmanwQhwyhUGNtFXtUGAUs8fNOUBP+sHionbQoVi7+O/VhufLf+AsQU3t9nBStUL0dyyxpurBFgxKBfEQ7Nd2Nhu9vtEWsQ6Did6FK329kwlD9xxYTtk18AlHATzo2Ckms36LZ4rVCyT5rePZGWl0bLr8/M4Jd/IuLgHCA05N+ZVTjJWzJ6oieMF3z4BgMqjDdFJO2HLIcV+YN42mv4i3F5lmsgJqkz3zmjG+uHB6X+Ol2Zt4+opHbQSpvlz2VuJxiK96pcjV+M6+5I0b3Cj9JDYEKAz7MTjxjwmpdxLtEHWsqzr5IyKG2sxtaxvnsGhxeoST/AOH4gvIMGPKkHFt/MwqwEaPwhvLSi974d68CZIrLIgbJNkDIWMzTsdNA2+VdQGmWA1UbmbM4WJaSucDq3IHM01NLmvu3Z4vse2DrzHX2XillXz8somI+Wy0OqxqfIHQs/ABOPJG7A2hMyh0jxxrME68G7pxSCWHmR8oDW+SHB6ehyR/kBXFEYIB55WmrVRYxktixwXwXsBalxx5er+yBqtbBDR/ui4CcIiWJ88CpFWjjGLOLnz77DyIlP8Cw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(316002)(5660300002)(508600001)(52116002)(86362001)(8676002)(54906003)(8936002)(66946007)(186003)(6512007)(2906002)(6666004)(6486002)(7416002)(6506007)(30864003)(1076003)(2616005)(66556008)(66476007)(44832011)(83380400001)(38100700002)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YUDBYC290lVBfFCsbUPgNsYzIOIhix0Syk75ZH9YK7MmQq7Z5PpssajCTc7fs4pxTa4oDZ8Xkv8oqmEsKfX/Bx6STssXyDpA2sGHw3G2ed0Gfbx0NMT4757szbwQmScJ6pxPf7tpN/sDe1M74Wee0D+E3o+4ppL9YA5VL1KTe2KlxtX3d5sGkXaaQxKq+UN8a6b3MjNm2O7gnZYeu3sdnNefTQJGYCydwt4c/ueUZCGmWlSMb+qOav8zdyoULtwHJvfSs2ITP9+NbfwKBdM3xm7qv4EqnBgXPIhVCddhkCh7+dgfaLn+U6H2ue0IQaSFsfjwxlJ2bqt9GNwivbbn+LQHIIrBln+/JAKdZsma6vQiF82d4A+Qh7oJA5Q5z+1u+c0MoZCwOuzV+ctPynN53T6Uycj6mjdHjWSPN0aP3yGpZeAV4kIfbaSgKsdx2q6AU7SBo+LnzJx9lU1hKYg4zTDYtW+8jwkZiakMM6GEOHLIwa4YEayzeSETptnKbZ478XLagbsjcEKK/u37pYMnMI0/iDUi7l6Ley+miccqFyUwrbQ6/pjDJQEueWg1ksYJU2fnfalNOe7xQ0IiJ8+84mQcyGtnbVpeL15nCwokkOjFh6e+0iLV2KRJ8vFbNzNmP/gr3zy3H4WQgrg8krJwzRreblBD2W2qNTGpT91GDLQpYe33vE1U6XpEVspOtbysXDeYE7BiL8cjdioYHjhNKjFkBLhIF9p609Bn2Kr8G43wSjFWUzRWWtwvcRcf7chhc/oWWBIpESE8erMeumMHWWlbJQVTtB99v1JicOFfy0PC8tIEwSsxDupsf+4vqUpZKPcKiE8j44SZJ/QIYlUhs7pNpfBxAugC6/7hY8BOlnejmW0nW7nJ/cTXKp+iOHkuQyshIz8IYX7RAP/SwZWTB2QoUO+DDJruE1b+lbc8UaWacyEypowLQTgzfFl+q/sYxyCDi533u/k8hmeUKG6mDZ3Yjk/vNb3LqYEdKK/vFj2zwQjeb5ks/WBEokxNg1k0s8PvtiXJ55jFK6Jcb+c1l8ZGBOy2Xfwnbv4uHHUeMVclQmb2IeObPGndLwzmQ/Pe6ermj4qJwoOJRlnn6BeTSpXP85EtjWz/4OjEsPguyMaDSoG/Z12x052N+NDG3JSvdOKhWi9ga86wmkfNUj66j7OWVDuaOjXGkij7egqyyWaKiO2u8YOBh4texSpKT95w49OHWzb9su4Pi+RhtX/hi5y+QTQRbz7MfoOO1i8PirdoKsf9KkhMKKskQPEPXT2yCBzsqKHbNRj2Nj/ul/C+ShZy9ohllP0HPefgJQ2o9suAdLzcAlyACgtBosY3ZMNYyVGYr+t/0Ujn0ad9QE4jC6LVrNjLRsiCK6lg6uqSmUUK/dYXJjD6z5OuqcbqoTDfMp4Aw6vKzxfCwYrxlvn/TfyIqA1JGeV+fINgHlLtc6/xz2uNPskq+9dQnl7eOGwbleQ2E7n7QeggicFwqk/TtfzJawA+bRIsQmsPb4EUBiTA0Ljx13s2f6af3utlhUtQsGdjiV6FNsP0qSg+HZkfwMfIg9ObdA3Vz5IC/BwvOQb/Cw3yajODFiPr7UmlDW5KCFqcG28e2qKQFuEoHRPyfM3LLjCbK/KEQFt41qmuSK84n3kDqTlzbXZhWf1PioD/9zP7Sfh5i5wVhJrKKha3eOpVa1qAR4i5G0GXgcFpOSSETBu1/K2h9srIFCGclti1 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f748bd21-8c50-40d8-6945-08d9a9adf83d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:11.0645 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xXxQ5mjpAU2uc0hWkrq2in0aTd2GilJvE+7mrwa1wIQ8Dn5G+/nA0KGlhKW8KG+EsulfnDaYSEPyJyGTfc4aOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5807 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ajit Kumar Pandey Add IPC module for generic ACP block and exposed ops callback for to synchronize SOF IPC message between host and DSP Signed-off-by: Balakishore Pati Signed-off-by: Ajit Kumar Pandey Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- sound/soc/sof/amd/Makefile | 2 +- sound/soc/sof/amd/acp-dsp-offset.h | 2 + sound/soc/sof/amd/acp-ipc.c | 187 +++++++++++++++++++++++++++++ sound/soc/sof/amd/acp.c | 44 ++++++- sound/soc/sof/amd/acp.h | 15 +++ sound/soc/sof/amd/renoir.c | 8 ++ 6 files changed, 256 insertions(+), 2 deletions(-) create mode 100644 sound/soc/sof/amd/acp-ipc.c diff --git a/sound/soc/sof/amd/Makefile b/sound/soc/sof/amd/Makefile index 031fb9493876..29928b16002f 100644 --- a/sound/soc/sof/amd/Makefile +++ b/sound/soc/sof/amd/Makefile @@ -4,7 +4,7 @@ # # Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. -snd-sof-amd-acp-objs := acp.o acp-loader.o +snd-sof-amd-acp-objs := acp.o acp-loader.o acp-ipc.o snd-sof-amd-renoir-objs := renoir.o obj-$(CONFIG_SND_SOC_SOF_AMD_COMMON) += snd-sof-amd-acp.o diff --git a/sound/soc/sof/amd/acp-dsp-offset.h b/sound/soc/sof/amd/acp-dsp-offset.h index f4bc7e9abafb..3a1c848020ca 100644 --- a/sound/soc/sof/amd/acp-dsp-offset.h +++ b/sound/soc/sof/amd/acp-dsp-offset.h @@ -53,6 +53,8 @@ /* Registers from ACP_INTR block */ #define ACP_DSP_SW_INTR_CNTL 0x1814 +#define ACP_DSP_SW_INTR_STAT 0x1818 +#define ACP_SW_INTR_TRIG 0x181C #define ACP_ERROR_STATUS 0x18C4 /* Registers from ACP_SHA block */ diff --git a/sound/soc/sof/amd/acp-ipc.c b/sound/soc/sof/amd/acp-ipc.c new file mode 100644 index 000000000000..e132223b4c66 --- /dev/null +++ b/sound/soc/sof/amd/acp-ipc.c @@ -0,0 +1,187 @@ +// 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: Balakishore Pati +// Ajit Kumar Pandey + +/* ACP-specific SOF IPC code */ + +#include +#include "../ops.h" +#include "acp.h" +#include "acp-dsp-offset.h" + +void acp_mailbox_write(struct snd_sof_dev *sdev, u32 offset, void *message, size_t bytes) +{ + memcpy_to_scratch(sdev, offset, message, bytes); +} +EXPORT_SYMBOL_NS(acp_mailbox_write, SND_SOC_SOF_AMD_COMMON); + +void acp_mailbox_read(struct snd_sof_dev *sdev, u32 offset, void *message, size_t bytes) +{ + memcpy_from_scratch(sdev, offset, message, bytes); +} +EXPORT_SYMBOL_NS(acp_mailbox_read, SND_SOC_SOF_AMD_COMMON); + +static void acpbus_trigger_host_to_dsp_swintr(struct acp_dev_data *adata) +{ + struct snd_sof_dev *sdev = adata->dev; + u32 swintr_trigger; + + swintr_trigger = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SW_INTR_TRIG); + swintr_trigger |= 0x01; + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SW_INTR_TRIG, swintr_trigger); +} + +static void acp_ipc_host_msg_set(struct snd_sof_dev *sdev) +{ + unsigned int host_msg = offsetof(struct scratch_ipc_conf, sof_host_msg_write); + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + host_msg, 1); +} + +static void acp_dsp_ipc_host_done(struct snd_sof_dev *sdev) +{ + unsigned int dsp_msg = offsetof(struct scratch_ipc_conf, sof_dsp_msg_write); + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_msg, 0); +} + +static void acp_dsp_ipc_dsp_done(struct snd_sof_dev *sdev) +{ + unsigned int dsp_ack = offsetof(struct scratch_ipc_conf, sof_dsp_ack_write); + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_ack, 0); +} + +int acp_sof_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) +{ + struct acp_dev_data *adata = sdev->pdata->hw_pdata; + unsigned int offset = offsetof(struct scratch_ipc_conf, sof_in_box); + + acp_mailbox_write(sdev, offset, msg->msg_data, msg->msg_size); + acp_ipc_host_msg_set(sdev); + + /* Trigger host to dsp interrupt for the msg */ + acpbus_trigger_host_to_dsp_swintr(adata); + return 0; +} +EXPORT_SYMBOL_NS(acp_sof_ipc_send_msg, SND_SOC_SOF_AMD_COMMON); + +static void acp_dsp_ipc_get_reply(struct snd_sof_dev *sdev) +{ + struct snd_sof_ipc_msg *msg = sdev->msg; + struct sof_ipc_reply reply; + struct sof_ipc_cmd_hdr *hdr; + unsigned int offset = offsetof(struct scratch_ipc_conf, sof_in_box); + int ret = 0; + + /* + * Sometimes, there is unexpected reply ipc arriving. The reply + * ipc belongs to none of the ipcs sent from driver. + * In this case, the driver must ignore the ipc. + */ + if (!msg) { + dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n"); + return; + } + hdr = msg->msg_data; + if (hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CTX_SAVE) || + hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_GATE)) { + /* + * memory windows are powered off before sending IPC reply, + * so we can't read the mailbox for CTX_SAVE and PM_GATE + * replies. + */ + reply.error = 0; + reply.hdr.cmd = SOF_IPC_GLB_REPLY; + reply.hdr.size = sizeof(reply); + memcpy(msg->reply_data, &reply, sizeof(reply)); + goto out; + } + /* get IPC reply from DSP in the mailbox */ + acp_mailbox_read(sdev, offset, &reply, sizeof(reply)); + if (reply.error < 0) { + memcpy(msg->reply_data, &reply, sizeof(reply)); + ret = reply.error; + } else { + /* reply correct size ? */ + if (reply.hdr.size != msg->reply_size && + !(reply.hdr.cmd & SOF_IPC_GLB_PROBE)) { + dev_err(sdev->dev, "reply expected %zu got %u bytes\n", + msg->reply_size, reply.hdr.size); + ret = -EINVAL; + } + /* read the message */ + if (msg->reply_size > 0) + acp_mailbox_read(sdev, offset, msg->reply_data, msg->reply_size); + } +out: + msg->reply_error = ret; +} + +irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context) +{ + struct snd_sof_dev *sdev = context; + unsigned int dsp_msg_write = offsetof(struct scratch_ipc_conf, sof_dsp_msg_write); + unsigned int dsp_ack_write = offsetof(struct scratch_ipc_conf, sof_dsp_ack_write); + bool ipc_irq = false; + int dsp_msg, dsp_ack; + + dsp_msg = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_msg_write); + if (dsp_msg) { + snd_sof_ipc_msgs_rx(sdev); + acp_dsp_ipc_host_done(sdev); + ipc_irq = true; + } + + dsp_ack = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_ack_write); + if (dsp_ack) { + spin_lock_irq(&sdev->ipc_lock); + /* handle immediate reply from DSP core */ + acp_dsp_ipc_get_reply(sdev); + snd_sof_ipc_reply(sdev, 0); + /* set the done bit */ + acp_dsp_ipc_dsp_done(sdev); + spin_unlock_irq(&sdev->ipc_lock); + ipc_irq = true; + } + + if (!ipc_irq) + dev_dbg_ratelimited(sdev->dev, "nothing to do in IPC IRQ thread\n"); + + return IRQ_HANDLED; +} +EXPORT_SYMBOL_NS(acp_sof_ipc_irq_thread, SND_SOC_SOF_AMD_COMMON); + +int acp_sof_ipc_msg_data(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream, + void *p, size_t sz) +{ + unsigned int offset = offsetof(struct scratch_ipc_conf, sof_out_box); + + if (!substream || !sdev->stream_box.size) + acp_mailbox_read(sdev, offset, p, sz); + + return 0; +} +EXPORT_SYMBOL_NS(acp_sof_ipc_msg_data, SND_SOC_SOF_AMD_COMMON); + +int acp_sof_ipc_pcm_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream, + const struct sof_ipc_pcm_params_reply *reply) +{ + /* TODO: Implement stream hw params to validate stream offset */ + return 0; +} +EXPORT_SYMBOL_NS(acp_sof_ipc_pcm_params, SND_SOC_SOF_AMD_COMMON); + +int acp_sof_ipc_get_mailbox_offset(struct snd_sof_dev *sdev) +{ + return ACP_SCRATCH_MEMORY_ADDRESS; +} +EXPORT_SYMBOL_NS(acp_sof_ipc_get_mailbox_offset, SND_SOC_SOF_AMD_COMMON); + +MODULE_DESCRIPTION("AMD ACP sof-ipc driver"); diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c index 3778f781f16a..43a57d15e3ca 100644 --- a/sound/soc/sof/amd/acp.c +++ b/sound/soc/sof/amd/acp.c @@ -233,6 +233,34 @@ static int acp_memory_init(struct snd_sof_dev *sdev) return 0; } +static irqreturn_t acp_irq_thread(int irq, void *context) +{ + struct snd_sof_dev *sdev = context; + unsigned int val; + + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_DSP_SW_INTR_STAT); + if (val & ACP_DSP_TO_HOST_IRQ) { + sof_ops(sdev)->irq_thread(irq, sdev); + val |= ACP_DSP_TO_HOST_IRQ; + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DSP_SW_INTR_STAT, val); + return IRQ_HANDLED; + } + + return IRQ_NONE; +}; + +static irqreturn_t acp_irq_handler(int irq, void *dev_id) +{ + struct snd_sof_dev *sdev = dev_id; + unsigned int val; + + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_DSP_SW_INTR_STAT); + if (val) + return IRQ_WAKE_THREAD; + + return IRQ_NONE; +} + static int acp_power_on(struct snd_sof_dev *sdev) { unsigned int val; @@ -318,9 +346,20 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) sdev->pdata->hw_pdata = adata; + sdev->ipc_irq = pci->irq; + ret = request_threaded_irq(sdev->ipc_irq, acp_irq_handler, acp_irq_thread, + IRQF_SHARED, "AudioDSP", sdev); + if (ret < 0) { + dev_err(sdev->dev, "failed to register IRQ %d\n", + sdev->ipc_irq); + return ret; + } + ret = acp_init(sdev); - if (ret < 0) + if (ret < 0) { + free_irq(sdev->ipc_irq, sdev); return ret; + } acp_memory_init(sdev); @@ -330,6 +369,9 @@ EXPORT_SYMBOL_NS(amd_sof_acp_probe, SND_SOC_SOF_AMD_COMMON); int amd_sof_acp_remove(struct snd_sof_dev *sdev) { + if (sdev->ipc_irq) + free_irq(sdev->ipc_irq, sdev); + return acp_reset(sdev); } EXPORT_SYMBOL_NS(amd_sof_acp_remove, SND_SOC_SOF_AMD_COMMON); diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index e755a31374c6..ac8340119125 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -48,6 +48,8 @@ #define ACP_DATA_RAM_BASE_ADDRESS 0x01000000 #define ACP_DRAM_PAGE_COUNT 128 +#define ACP_DSP_TO_HOST_IRQ 0x04 + struct acp_atu_grp_pte { u32 low; u32 high; @@ -150,5 +152,18 @@ int acp_dsp_block_write(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_t int acp_dsp_block_read(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type, u32 offset, void *dest, size_t size); +/* IPC callbacks */ +irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context); +int acp_sof_ipc_msg_data(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream, + void *p, size_t sz); +int acp_sof_ipc_send_msg(struct snd_sof_dev *sdev, + struct snd_sof_ipc_msg *msg); +int acp_sof_ipc_get_mailbox_offset(struct snd_sof_dev *sdev); +int acp_sof_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id); +int acp_sof_ipc_pcm_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream, + const struct sof_ipc_pcm_params_reply *reply); +void acp_mailbox_write(struct snd_sof_dev *sdev, u32 offset, void *message, size_t bytes); +void acp_mailbox_read(struct snd_sof_dev *sdev, u32 offset, void *message, size_t bytes); + extern const struct snd_sof_dsp_ops sof_renoir_ops; #endif diff --git a/sound/soc/sof/amd/renoir.c b/sound/soc/sof/amd/renoir.c index bca80784b322..9d95ea66f867 100644 --- a/sound/soc/sof/amd/renoir.c +++ b/sound/soc/sof/amd/renoir.c @@ -41,6 +41,14 @@ const struct snd_sof_dsp_ops sof_renoir_ops = { /* DSP core boot */ .run = acp_sof_dsp_run, + + /*IPC */ + .send_msg = acp_sof_ipc_send_msg, + .ipc_msg_data = acp_sof_ipc_msg_data, + .ipc_pcm_params = acp_sof_ipc_pcm_params, + .get_mailbox_offset = acp_sof_ipc_get_mailbox_offset, + .irq_thread = acp_sof_ipc_irq_thread, + .fw_ready = sof_fw_ready, }; EXPORT_SYMBOL(sof_renoir_ops); From patchwork Wed Nov 17 09:37:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624151 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 42382C433FE for ; Wed, 17 Nov 2021 09:40:57 +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 B862261284 for ; Wed, 17 Nov 2021 09:40:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B862261284 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 2D1861896; Wed, 17 Nov 2021 10:40:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2D1861896 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142055; bh=TNjS0pjDwrPxhqokcQP/sQAYSOdSQlB6nUEV5xdWn4M=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TQlY9VB7XMoemYbapPD4kaG5+0+A9yf4XHL9TJF6Xf4Jjc3lb7LTNnQd5Z8qDJh/V 0TrbGP0Jai12hvs6lv39ASbzDu1Dud6kxK36vm2PJkdTwwTgjzD7c3yXByWb0a7X9Q KoE8yomtPlqqM8y37MB2WEyadhjJfVL58mqe5/aw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 29585F80506; Wed, 17 Nov 2021 10:38:39 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6999FF802A0; Wed, 17 Nov 2021 10:38:22 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60062.outbound.protection.outlook.com [40.107.6.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 16480F8028B for ; Wed, 17 Nov 2021 10:38:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 16480F8028B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="ATKNykq9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Buy2PEMKtpjCdCwzoFpDuUG7+Px8GyRkkLprT73RyxpLtHQ2C4fk6gM6fOBaBNpy3CUw1Z6fLbVP7wNGLSMKYYw6PafSKlQRD5E7NKtYbzvhTEnctfVQX0+aJLKkYo1al2bwzSV2xRL7tWUICQJj1rrNij7jkRc/hd/fN1gMKS/AVHyDnWIcgtXCxJFZqmzGUMXvYc6glwo3XpHdTN0BW0+NTshbFpNFQF9QD4uGffdXrVvw+ic9oW9VAUcTiT53vKvYP/CDARFdjmPb1KpUGYPVPVVi6Ln8YGNjR7VC/+AHA7RcqyLUmZvOEdpEF6O9LFOD2RADfabm3jmvXdpuyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WE2DuIgSwafx0IAlBrYGbF4rgLWbl+ebjRJgRANfPik=; b=fAOjuEvTwq1xItrSg04YrmMcCQ4CVJEoZqoHwusUPIYuFYnTtp4oY0IUECAY/eksdsd2mQZ3bHusN2IA/vdlQVD4e1Snr4H5z9jrtLUR5Lv+mC8A8UfCWeba3VKgya2OaTYzxFQGnZYqnD3k05cgVhDsRVMnRpW078yMSQziX60s6jQBwCh6YCU6LQcknPDk7rxzYfFqU/GWazp+onQt7q9P0x14fYsAHD6WG5eq74OpIDg25C+zXTSLeQztzpELfqHIE8ep+DEmn8vnoiSOKG++iPYuv2qGAn3py3+qCQDMr2riJmWWEgKIf22GkFCTTg28zuTkW2G9nhhzJ/T/8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WE2DuIgSwafx0IAlBrYGbF4rgLWbl+ebjRJgRANfPik=; b=ATKNykq9tsyOR8PnQeLlAZO2d6RDNHS+S+DQtoCbrGYKrH8zkAJJvSbzzIpjAnNx0bpmBtBkZrMn2vRXQKTi/i4PijvEvMKfAVQ/Vtz2UKYXj4jZtzrURot8hDuXEdm8k56Dq0bj2/ukKN2OJ0erVEiP/hg23YfVgNrXX7Bn++I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 09:38:13 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:13 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 05/21] ASoC: SOF: amd: Add dai driver dsp ops callback for Renoir Date: Wed, 17 Nov 2021 11:37:18 +0200 Message-Id: <20211117093734.17407-6-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cecbaa9d-6ee4-4130-c28d-08d9a9adf94f X-MS-TrafficTypeDiagnostic: VI1PR04MB5807: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2J2CoGVWRcSoc07vWp9IN+1kzMn3jdXuGoXuvaO1VoPijl7o6xEMcPwrhDrVW/ue4GA6aBR17T6XftR8Z+9iQK/zqwyTijgMrBnpXEieo4l6fgIldaFEpnKaivqrI+nlXWnaz0/AM2liST3hGlzw95mj3tIUbvJmz80PCX3Omnxc5bUgz66GO4dIbUEHZvKNfD1jsVLY5GDyglyeYtLLM2RK/yeavLadibNZI5Y+z5moqaJt9RvbyAAg47rG68bRcccomRkqPSOVO86aDN1tdzw//NC+M8bydW6M2kx0Tmvkm2o8/v8fDXft4zEaD8P+7YXIssV5jC0gFUe/DBI/ucpnhyuZNR9+EsCgD0R1Shnw4uC5ibtF43SE+P8wBhrdOTUUdgzSTGEXcmHMipVmqZK4tw/85uwCZTzYP2tH1lctgbVp9QgWZ6vC4V9MA6Jd3pJGxb1paTqUiRHK3YcBDxGmO59nb+bsiQ4SDdv3vEbJXrvgMJ4/IBMLdz43KmATISWBiaANEf3TSR1AAcMPgDNOVzpBEIOvQl/smdW/xkGX9kbAbpTfmQGaXgGUgNjjCNE+9BVk+GNw6pGcJ/IXDtg8G9QLGeE9Iqz3f3AP8bd0+VzpFzS2Zwglar8uSR2wMkM2PEnYYQin2kDhOd0FZQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(316002)(5660300002)(508600001)(52116002)(86362001)(8676002)(54906003)(8936002)(66946007)(186003)(6512007)(2906002)(6486002)(7416002)(6506007)(1076003)(2616005)(66556008)(66476007)(44832011)(83380400001)(38100700002)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mk+4TpztP4jRpq3rdK1jzO9B1WRK0B+oS1ozYDNgCJQr058YQtTfWjiSJTKziWO8WLK4EwdJf4XHx2D6IUUyCH9MxEZEXfO3EH1j5a8vTw2ZuSXCUNecJAlIgybdCWqqLHXEpKwr7Ch/tbkPAomo61/IVGkbO68a+dpPoKtRujz20OfjurYr/LUaHljx+y7njhxjEp39PhjBnJwLHmBAu5dpt3dbwzGMSZwQBeJqig0rgcLit7hWtIb1NV/ij/0wECeUzWYaRMKZLIDrp3uan/wqF81UkUwTmUG9BCMDxJnTWOSn6ZouLS3SExmKZJ5+MhFmgGIaZ6xfnw9U/58/T+xcrdk3ijU8O7YFYhxRi5/8ZeT5+AthS91hzv42oCZWUywU5b2f2hYlhKXNjuP3EpEel8iVhUU1j1BAHUjVtQvOgNMcGMXu/yer+lXo67OVIHrWDht/HVtSntsCqwzaOLFuVpSoc8hlPEJ2+U2HhZIUmNN7XGfzsVdF1i3PDfOwnOLHRmTcuBJKmrA1ytRHAIL5C+F4i9H1T0JUnWlgEHXgGmqcZumgYP0rgieIuvC6uHd1V+OY1f1sOtrSt1LgOGSt+TRtgykWbfSncXe8D7nYIgPRU5RfRhaAqBfQKmMukhp9KqSHZVKCpTTtWrqwuTbtRT/CC3udVahdNr+TQDVGDaPvE2cLvrtaRsVGKyXY9754BAosmAaM2tutnakNFZUdpfFW23ysLAD/LbFYV3lVrHBcIGO0eF2IQZiQQ9Yt+xdEsc8+6vavfdzYmPj7Z9SbPxP5m1ljQfoEUKoxET1AHLhx/R/TLxMYtTLYbxE0+hDDQ03Hyy32ahH0+oHEoG8gP8j0uMdK2am1tlApSzPfep46cqKyqSOVndguOS9Lw0A1yqaZhgDfULoKvNSnutmFBRa2zKGW9o+sO1canlq+ABnhn7p1LL8z5/gUI3pSeBfaSB+MQe2rz1TyYzWPwnxExcwFYQnZUfOCtmlBM+76+G4672CpFpXMmWbJ3XzGkSziAbvNrnRttD/3gyJ1Vfs56eG7cqqJKT9ITtrYBFksETKRE0SY/wAcwjMye2V7MCSUoCZKoNyvIgKQGhcuYvwOTuVB4ER3sCQsXtQno5wR1KzCg2Tzu9QQxjo0NLOKuVK0d7r9pFsLowoVtB/Xbd8oj1AIRwQen3l03i8Ay+ikmODEAwTVFw0NoO4u0wkQNWHY5tkEEIs3OqHIThIvMnvqpmIxBk3JXmJrH8pmavIByae0B8DnZdkEl+hgNhhmoZsQ7XvC5RuG0yeaMnD15eCGDBvByva1w3M/n8GxjPc2ic62kdJw6lOw+9JnaVH1IJuUyn4t87VFW9PdDX4vIG0NH8Cxz1BwIjh5o24GhXQZ/+56NCLH7ckrVL1T49XC4YksojsZ2djBdviYUNnQvJI9LIedLrBUSSO7eL5KhhiSDbOkzmTqlF/p1zR3oexzQ84yXJZqN5MXCRRB1sS8nyDNTYqWxtlfvVgCEHMdlyP86hBq06m28HMXqz4246fe8V2RpeCsj2TxF9LYmMcJ+gsTa+STtogBCjk4WFpg7Id5/DQofqjtqbEwBWGVeD8o92vR612afQZqlMin/pZ+xAl06accz3god6jPeRfdCU4Jd0HMl9LPeR3JLHA4lzRpBe8WKPgqnJEofXYHTWT2i6GIH+d5iVm3A3k7KHoQH62t/WVZSv5TtTizyC+HRvDG X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cecbaa9d-6ee4-4130-c28d-08d9a9adf94f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:12.8954 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: roKnawi7Gd2JH2mxdS7IX75WDvZjrx8Sf8bWVEdZ1VVY78mvM5qHzsZwJ0Nf6y2fLUICG7JhViatDUiLwaw5Cg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5807 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ajit Kumar Pandey Add dsp ops callback to register I2S and DMIC sof dai's with ALSA Signed-off-by: Ajit Kumar Pandey Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- sound/soc/sof/amd/acp-dsp-offset.h | 2 + sound/soc/sof/amd/renoir.c | 91 ++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/sound/soc/sof/amd/acp-dsp-offset.h b/sound/soc/sof/amd/acp-dsp-offset.h index 3a1c848020ca..1d11e9d69dce 100644 --- a/sound/soc/sof/amd/acp-dsp-offset.h +++ b/sound/soc/sof/amd/acp-dsp-offset.h @@ -47,6 +47,8 @@ #define ACPAXI2AXI_ATU_CTRL 0xC40 #define ACP_SOFT_RESET 0x1000 +#define ACP_I2S_PIN_CONFIG 0x1400 + /* Registers from ACP_PGFSM block */ #define ACP_PGFSM_CONTROL 0x141C #define ACP_PGFSM_STATUS 0x1420 diff --git a/sound/soc/sof/amd/renoir.c b/sound/soc/sof/amd/renoir.c index 9d95ea66f867..ca5582b3f82d 100644 --- a/sound/soc/sof/amd/renoir.c +++ b/sound/soc/sof/amd/renoir.c @@ -15,7 +15,94 @@ #include #include "../ops.h" +#include "../sof-audio.h" #include "acp.h" +#include "acp-dsp-offset.h" + +#define I2S_BT_INSTANCE 0 +#define I2S_SP_INSTANCE 1 +#define PDM_DMIC_INSTANCE 2 + +#define I2S_MODE 0x04 + +static int renoir_dai_probe(struct snd_soc_dai *dai) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(dai->component); + unsigned int val; + + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_I2S_PIN_CONFIG); + if (val != I2S_MODE) { + dev_err(sdev->dev, "I2S Mode is not supported (I2S_PIN_CONFIG: %#x)\n", val); + return -EINVAL; + } + + return 0; +} + +static struct snd_soc_dai_driver renoir_sof_dai[] = { + [I2S_BT_INSTANCE] = { + .id = I2S_BT_INSTANCE, + .name = "acp-sof-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 = { + .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, + /* Supporting only stereo for I2S BT controller capture */ + .channels_min = 2, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .probe = &renoir_dai_probe, + }, + + [I2S_SP_INSTANCE] = { + .id = I2S_SP_INSTANCE, + .name = "acp-sof-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 = { + .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, + /* Supporting only stereo for I2S SP controller capture */ + .channels_min = 2, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .probe = &renoir_dai_probe, + }, + + [PDM_DMIC_INSTANCE] = { + .id = PDM_DMIC_INSTANCE, + .name = "acp-sof-dmic", + .capture = { + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 4, + .rate_min = 8000, + .rate_max = 48000, + }, + }, +}; /* AMD Renoir DSP ops */ const struct snd_sof_dsp_ops sof_renoir_ops = { @@ -49,6 +136,10 @@ const struct snd_sof_dsp_ops sof_renoir_ops = { .get_mailbox_offset = acp_sof_ipc_get_mailbox_offset, .irq_thread = acp_sof_ipc_irq_thread, .fw_ready = sof_fw_ready, + + /* DAI drivers */ + .drv = renoir_sof_dai, + .num_drv = ARRAY_SIZE(renoir_sof_dai), }; EXPORT_SYMBOL(sof_renoir_ops); From patchwork Wed Nov 17 09:37:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624153 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 CB6AAC433F5 for ; Wed, 17 Nov 2021 09:41:14 +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 50FC161284 for ; Wed, 17 Nov 2021 09:41:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 50FC161284 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 B30BD1853; Wed, 17 Nov 2021 10:40:22 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B30BD1853 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142072; bh=Rdg+k5vHvWRnO61fUio+Qu01+Be0oO5HbPtMgY/G6+4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Eb749msFXxXjHAF8QbI1Q2z6c+zjOWxSYRIAQxTtJ/RMRKkeEZIPhxGQPvqxscwA0 BWP4HQ6u5VbxRUhUSBv9Ki158tmVP8Rn2tPmkda4AurZIEpagkVTJUURqI2Vq3YXfj ApMjdSUJ/Dx/mVDJ9ILIP7RljSHMbQX4TXER9bC8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 81719F80516; Wed, 17 Nov 2021 10:38:40 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1F560F804BD; Wed, 17 Nov 2021 10:38:24 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60062.outbound.protection.outlook.com [40.107.6.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5B5FBF8016C for ; Wed, 17 Nov 2021 10:38:17 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5B5FBF8016C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="BzJr9Izu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ft4FWtSkAIFYkOqVGbZM0EqMtUC3I3KR+f8vz1STMAU4OvGnHwvliYtAdwVe24CXDnvJMYrxr5f1x9fTlDYfH0QXV1/WVXbt4wpGBbSlSsCqrVUno7qGZPLR8eL3zJxngNO5wleTlt0fQQB0v1USUVFKwQB1s5GQFs3AGiKFK3hbImiwMWAklp+NtkTgzTkFXFyi+9dMmD9BThgiDQlpqBn31c0IU6l7K5FQtqe/NFhmLjGGAJsG2mPOxIQhvRqLqRLNSeKfDyXnprL4LOcgodaUuCUHn31aGjhz8O3N19tjHEp4iHj2zi4iICTIimOzeoRtovsKYW9AoBCSyu5/dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=B4qRUmATwCb+HVITmZk8a5kV43TQ8HJCX1OlKEbFy+A=; b=gWHQXmUIo/wN8yHrcRgbTgQjbwQ3VmbaC6Liaik7RlAHhhz7MQOOTwu8/4wNIBdBwcxpNpy3N1HslUuYOWz85BVwZLshClcClkEMsZosp/m+oYkgRuIpa7FCfj5AYW74JOmrAMiYcKksV+TlXqvO8nTblnWErrAzuMYivNd9wTWldH91vIHmsRBYxqjoH0+BbuZaRjhVwy9PCmTL6dtyPhBxKGz2ZPUoXHNCxBKeW9ReBl03sjQazpuXDpm/vN2Y3K/1SSQDPwUMjAJ9tIiCMABBm5QBC/jxmfEZxTBeA2wQMRAQ+ZjepGv4ZHiWczPtZWiJOb88C1CQIAXVVTU8Kg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B4qRUmATwCb+HVITmZk8a5kV43TQ8HJCX1OlKEbFy+A=; b=BzJr9IzuBlf+VeUgDJWACIctUycmpRA+URA2iIL8nWZ9Mhz2DTWd8O2NiAuJLJhhvV/t1PmkdR/uMuNIssPGMJPqV6vsyO4BnV20OYa09DmMc/eUyidtYwkqtVybhY7+1BNRBoaxk1Wv9FqAny3dunSzBFoAabQqMhwZSCCtotQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 09:38:14 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:14 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 06/21] ASoC: SOF: amd: Add PCM stream callback for Renoir dai's Date: Wed, 17 Nov 2021 11:37:19 +0200 Message-Id: <20211117093734.17407-7-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc7299ad-3495-464c-06b5-08d9a9adfa5a X-MS-TrafficTypeDiagnostic: VI1PR04MB5807: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zree7ayPcWzKGjTz5e1RIaP/AgVxO1HuTXMhEbzUO0sleas2fv2N/3EUpmrTUkpo8kjKYYwQGVFFPyalGxPMLtiDD1HhsQ7laL+42nQ0BkxFOyo2W6Ub70Me56Nd7EnahEoOPCKI1ppCjynHUJ35RzQxgcYZtWQGWIXlVeJUBRmDZpH6N6gcgUwimm3/43Pcf/Xzir83/OqntwqNL3I+U7W0Ri7VZbInDn/01yCY0PgDZBaHhe1KO5tPSoEqCLSqKbGwDYOLbpP7IUlziR8coSih3RhwRT41qn2M1bsJFwckFwYUO8bvSSiCuErzdO/hctZfsTd0AHZQYV/1LMcvFTOuzVpowVcEh0BL4HM4CWv0b2d11VYIV7z8iM47X3cbT07M7CYznstWI8Ap0ZoCVWh/40qLDJQy/w5qJfzN+zkqJyJoTjYQg7PkCyknKeJ+Sps5NW1XBis+EWr9R4+x4KQaD32oGwor8ReZlUCG23s9untNtget0rXNDeVdvKVibgQRRWNQJ16Vk6qG8AhODyMYr1Zs9+K2PZnwPYeB0/EkexK9ITZj2VtFBHuZIHKMsGYnzn4mVdZ2Flr5PjogFQlmarWgn6RBiakzT1EfzLP2BjDeoOJWQdhCCuyXqmbfd+hCVmxq4Yk+MySKidIesA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(316002)(5660300002)(508600001)(52116002)(86362001)(8676002)(54906003)(8936002)(66946007)(186003)(6512007)(2906002)(6486002)(7416002)(6506007)(30864003)(1076003)(2616005)(66556008)(66476007)(44832011)(83380400001)(38100700002)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mrH0KFGyFOzKUQ5k7AJa5ksV3QQbDYOzcSPLLj/8QC2OfoFHia+rH8If+N2OwZb/ZN7dzR02rDHNYyG6ZZLFpI0dVb20F+h2BYIGFxP8flC2FkMiJp4ZlBZdihWzda6zsn7d6ubi5wBiZHUTWS4ShTB6NC1ZjkjCCXv3WujT2sWeTlVEFqkk1nGyOKRM3hToh5vwUg2Gm/J7Kr6jAY9QyTOTqRGiHqzV8d6m9tqeYy2dv2kfLdsKPqtTTGieLGju0tJQeL4CEIReZxaJcVBhBvpxGUp9P42WYCK/xm4okC//VAo5HhLthz9jFTAcbyui6nk5xN+fgjEQPaJLiGb1GNGf/sFTawJH81gKwChGBo5AL3Pyg8kSD2ddlxVISbbWxYHBeD4oRoq4wV3z0W8E1cus0nRr5fGwRIJf5BJWNuK/GM67kJ5VcSjIBGYmm55wQ1GZsYbm4UonP/PmeMzfeYsoxhryrPsP7SF7W6pfoE7QIHr3lMX3VPaNMO9+iLf2nfxj5KuXlTdQ6Ca+bROp77Fi0DnFGtumiDlHFsgctvVCtqe3diQzirJlcHLU9GptJbm8W4Nh5hjuZF7XFrweQo5zzJeoO+oObhCFuy+E9wdhr1EVlp6EklGv940EvD54SE1obEQAS0+1Kxh5gf9qK2Zer8+4JTmOk17IX1ojnQ1gRI4b2oTFeRssXMuR9qh75OCNYW9Upy+Rxb8DM+kP7/DiF/l7kn3+BAvVdApZRSk75MbDou51kE3GpISByrFqM7e8+Sf5zWwZ/eOZ2+GZtWnJKV4nmwqRaTkC/+GoKGa29FYPH1JfA97CyONRp4+dZ+GpOwpyy4Ri9Yoo7HNPHTukd1D+6R0aK0P7KW12XVS7AY+tByjFV0CBkn+xFsCxzC/AexixDPpG+0rgua0cX732Bh8J9TXm2bg+LwRziz4xybxKZDK1ypilEshpJhKolAO+Dm4uwN7zjb6GTTHMXd5DlP3arr/Zy1tRGl5EjpYnkXFr0gzHq0F+ajlD7xl+pG+FBjm9UWaih+lMY+SC39zhhnIFr4kJeRIRuy3VmCN+uXVns2P980JgYo8VQ3stkILrLBaP7Tpc8H71Fb03WtbULjKPM/bR2Q0sKXJEH8Y7QMql+CgeAZV2OBMAqnacF5E5AxbnujCTUj3gNoBIegxQeG5HlYH0I7vQPrdXe5VeBzJKsUEbTuKB9apzLuI0amgvy3L61q5KQccIjpd/99jG4lBy6CemuFk/efBLeLFOq9ozgYymyIIqJ6HNFMu4NJjS/9GgOsd7Z0TON6XHyScYRorEecsbucvzatkf8IOoBT0WJcrGp2Mjr75cI+95pjpRYPVWe+ZHsSWzftfHxZte294tKTWq5HosV866oH2FUnmlOtTDezAA40XiozosEQ+03XtYYHuWIno2yM2xaVVR+eIg3/uaQUqIDx5PZ35FTluCOKboIM59+FCzCFAnsigqVTK8geQwezllYSbpHuP7iYJFET+QrlPDiuzmwYDsXksAAks91eHbIUAIrk4JNev9BYrBkrhWdj3kYDQgiOEPN2Dblnwxd3sgtSH/8OckM9lvPkyTo5lwSF80XZt9OJRSKzu1cMb0Kvfc1Tee6qncOCe2iywQe5ixIh4vwbwJASvMaPwjp+9HZr1mHYLfrk+CTeA+Bh36/kfzjYVBbTMg6Jj+V6QoxVnQap99krCWhSDDHqlI84YB0KDoZNdt X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc7299ad-3495-464c-06b5-08d9a9adfa5a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:14.7114 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BK5xY9q8JSSPHKBwYP+MH1wtlN4m0JQJ19qlXs9KuwAqk04V+4o2VeO50ZKjQCJtt19NUTfswCcWhgrE3dP/VQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5807 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ajit Kumar Pandey Add module to support ALSA pcm stream configurations for ACP I2S and DMIC endpoints Signed-off-by: Ajit Kumar Pandey Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- sound/soc/sof/amd/Makefile | 2 +- sound/soc/sof/amd/acp-pcm.c | 82 +++++++++++++++ sound/soc/sof/amd/acp-stream.c | 181 +++++++++++++++++++++++++++++++++ sound/soc/sof/amd/acp.c | 2 + sound/soc/sof/amd/acp.h | 28 +++++ sound/soc/sof/amd/renoir.c | 11 ++ 6 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 sound/soc/sof/amd/acp-pcm.c create mode 100644 sound/soc/sof/amd/acp-stream.c diff --git a/sound/soc/sof/amd/Makefile b/sound/soc/sof/amd/Makefile index 29928b16002f..7b88db9c5fb7 100644 --- a/sound/soc/sof/amd/Makefile +++ b/sound/soc/sof/amd/Makefile @@ -4,7 +4,7 @@ # # Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. -snd-sof-amd-acp-objs := acp.o acp-loader.o acp-ipc.o +snd-sof-amd-acp-objs := acp.o acp-loader.o acp-ipc.o acp-pcm.o acp-stream.o snd-sof-amd-renoir-objs := renoir.o obj-$(CONFIG_SND_SOC_SOF_AMD_COMMON) += snd-sof-amd-acp.o diff --git a/sound/soc/sof/amd/acp-pcm.c b/sound/soc/sof/amd/acp-pcm.c new file mode 100644 index 000000000000..5b23830cb1f3 --- /dev/null +++ b/sound/soc/sof/amd/acp-pcm.c @@ -0,0 +1,82 @@ +// 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 + +/* + * PCM interface for generic AMD audio ACP DSP block + */ +#include + +#include "../ops.h" +#include "acp.h" +#include "acp-dsp-offset.h" + +int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, struct sof_ipc_stream_params *ipc_params) +{ + struct acp_dsp_stream *stream = substream->runtime->private_data; + unsigned int buf_offset, index; + u32 size; + int ret; + + size = ipc_params->buffer.size; + stream->num_pages = ipc_params->buffer.pages; + stream->dmab = substream->runtime->dma_buffer_p; + + ret = acp_dsp_stream_config(sdev, stream); + if (ret < 0) { + dev_err(sdev->dev, "stream configuration failed\n"); + return ret; + } + + ipc_params->buffer.phy_addr = stream->reg_offset; + ipc_params->stream_tag = stream->stream_tag; + + /* write buffer size of stream in scratch memory */ + + buf_offset = offsetof(struct scratch_reg_conf, buf_size); + index = stream->stream_tag - 1; + buf_offset = buf_offset + index * 4; + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + buf_offset, size); + + return 0; +} +EXPORT_SYMBOL_NS(acp_pcm_hw_params, SND_SOC_SOF_AMD_COMMON); + +int acp_pcm_open(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream) +{ + struct acp_dsp_stream *stream; + + stream = acp_dsp_stream_get(sdev, 0); + if (!stream) + return -ENODEV; + + substream->runtime->private_data = stream; + stream->substream = substream; + + return 0; +} +EXPORT_SYMBOL_NS(acp_pcm_open, SND_SOC_SOF_AMD_COMMON); + +int acp_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream) +{ + struct acp_dsp_stream *stream; + + stream = substream->runtime->private_data; + if (!stream) { + dev_err(sdev->dev, "No open stream\n"); + return -EINVAL; + } + + stream->substream = NULL; + substream->runtime->private_data = NULL; + + return acp_dsp_stream_put(sdev, stream); +} +EXPORT_SYMBOL_NS(acp_pcm_close, SND_SOC_SOF_AMD_COMMON); diff --git a/sound/soc/sof/amd/acp-stream.c b/sound/soc/sof/amd/acp-stream.c new file mode 100644 index 000000000000..f2837bfbdb20 --- /dev/null +++ b/sound/soc/sof/amd/acp-stream.c @@ -0,0 +1,181 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// This file is provided under a dual BSD/GPLv2 license. When using or +// redistributing this file, you may do so under either license. +// +// Copyright(c) 2021 Advanced Micro Devices, Inc. +// +// Authors: Ajit Kumar Pandey + +/* + * Hardware interface for generic AMD audio DSP ACP IP + */ + +#include "../ops.h" +#include "acp-dsp-offset.h" +#include "acp.h" + +#define PTE_GRP1_OFFSET 0x00000000 +#define PTE_GRP2_OFFSET 0x00800000 +#define PTE_GRP3_OFFSET 0x01000000 +#define PTE_GRP4_OFFSET 0x01800000 +#define PTE_GRP5_OFFSET 0x02000000 +#define PTE_GRP6_OFFSET 0x02800000 +#define PTE_GRP7_OFFSET 0x03000000 +#define PTE_GRP8_OFFSET 0x03800000 + +int acp_dsp_stream_config(struct snd_sof_dev *sdev, struct acp_dsp_stream *stream) +{ + unsigned int pte_reg, pte_size, phy_addr_offset, index; + int stream_tag = stream->stream_tag; + u32 low, high, offset, reg_val; + dma_addr_t addr; + int page_idx; + + switch (stream_tag) { + case 1: + pte_reg = ACPAXI2AXI_ATU_BASE_ADDR_GRP_1; + pte_size = ACPAXI2AXI_ATU_PAGE_SIZE_GRP_1; + offset = offsetof(struct scratch_reg_conf, grp1_pte); + stream->reg_offset = PTE_GRP1_OFFSET; + break; + case 2: + pte_reg = ACPAXI2AXI_ATU_BASE_ADDR_GRP_2; + pte_size = ACPAXI2AXI_ATU_PAGE_SIZE_GRP_2; + offset = offsetof(struct scratch_reg_conf, grp2_pte); + stream->reg_offset = PTE_GRP2_OFFSET; + break; + case 3: + pte_reg = ACPAXI2AXI_ATU_BASE_ADDR_GRP_3; + pte_size = ACPAXI2AXI_ATU_PAGE_SIZE_GRP_3; + offset = offsetof(struct scratch_reg_conf, grp3_pte); + stream->reg_offset = PTE_GRP3_OFFSET; + break; + case 4: + pte_reg = ACPAXI2AXI_ATU_BASE_ADDR_GRP_4; + pte_size = ACPAXI2AXI_ATU_PAGE_SIZE_GRP_4; + offset = offsetof(struct scratch_reg_conf, grp4_pte); + stream->reg_offset = PTE_GRP4_OFFSET; + break; + case 5: + pte_reg = ACPAXI2AXI_ATU_BASE_ADDR_GRP_5; + pte_size = ACPAXI2AXI_ATU_PAGE_SIZE_GRP_5; + offset = offsetof(struct scratch_reg_conf, grp5_pte); + stream->reg_offset = PTE_GRP5_OFFSET; + break; + case 6: + pte_reg = ACPAXI2AXI_ATU_BASE_ADDR_GRP_6; + pte_size = ACPAXI2AXI_ATU_PAGE_SIZE_GRP_6; + offset = offsetof(struct scratch_reg_conf, grp6_pte); + stream->reg_offset = PTE_GRP6_OFFSET; + break; + case 7: + pte_reg = ACPAXI2AXI_ATU_BASE_ADDR_GRP_7; + pte_size = ACPAXI2AXI_ATU_PAGE_SIZE_GRP_7; + offset = offsetof(struct scratch_reg_conf, grp7_pte); + stream->reg_offset = PTE_GRP7_OFFSET; + break; + case 8: + pte_reg = ACPAXI2AXI_ATU_BASE_ADDR_GRP_8; + pte_size = ACPAXI2AXI_ATU_PAGE_SIZE_GRP_8; + offset = offsetof(struct scratch_reg_conf, grp8_pte); + stream->reg_offset = PTE_GRP8_OFFSET; + break; + default: + dev_err(sdev->dev, "Invalid stream tag %d\n", stream_tag); + return -EINVAL; + } + + /* write phy_addr in scratch memory */ + + phy_addr_offset = offsetof(struct scratch_reg_conf, reg_offset); + index = stream_tag - 1; + phy_addr_offset = phy_addr_offset + index * 4; + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + + phy_addr_offset, stream->reg_offset); + + /* Group Enable */ + reg_val = ACP_SRAM_PTE_OFFSET + offset; + snd_sof_dsp_write(sdev, ACP_DSP_BAR, pte_reg, reg_val | BIT(31)); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, pte_size, PAGE_SIZE_4K_ENABLE); + + for (page_idx = 0; page_idx < stream->num_pages; page_idx++) { + addr = snd_sgbuf_get_addr(stream->dmab, page_idx * PAGE_SIZE); + + /* Load the low address of page int ACP SRAM through SRBM */ + low = lower_32_bits(addr); + high = upper_32_bits(addr); + + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + offset, low); + + high |= BIT(31); + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + offset + 4, high); + /* Move to next physically contiguous page */ + offset += 8; + } + + return 0; +} + +struct acp_dsp_stream *acp_dsp_stream_get(struct snd_sof_dev *sdev, int tag) +{ + struct acp_dev_data *adata = sdev->pdata->hw_pdata; + struct acp_dsp_stream *stream = adata->stream_buf; + int i; + + for (i = 0; i < ACP_MAX_STREAM; i++, stream++) { + if (stream->active) + continue; + + /* return stream if tag not specified*/ + if (!tag) { + stream->active = 1; + return stream; + } + + /* check if this is the requested stream tag */ + if (stream->stream_tag == tag) { + stream->active = 1; + return stream; + } + } + + dev_err(sdev->dev, "stream %d active or no inactive stream\n", tag); + return NULL; +} +EXPORT_SYMBOL_NS(acp_dsp_stream_get, SND_SOC_SOF_AMD_COMMON); + +int acp_dsp_stream_put(struct snd_sof_dev *sdev, + struct acp_dsp_stream *acp_stream) +{ + struct acp_dev_data *adata = sdev->pdata->hw_pdata; + struct acp_dsp_stream *stream = adata->stream_buf; + int i; + + /* Free an active stream */ + for (i = 0; i < ACP_MAX_STREAM; i++, stream++) { + if (stream == acp_stream) { + stream->active = 0; + return 0; + } + } + + dev_err(sdev->dev, "Cannot find active stream tag %d\n", acp_stream->stream_tag); + return -EINVAL; +} +EXPORT_SYMBOL_NS(acp_dsp_stream_put, SND_SOC_SOF_AMD_COMMON); + +int acp_dsp_stream_init(struct snd_sof_dev *sdev) +{ + struct acp_dev_data *adata = sdev->pdata->hw_pdata; + int i; + + for (i = 0; i < ACP_MAX_STREAM; i++) { + adata->stream_buf[i].sdev = sdev; + adata->stream_buf[i].active = 0; + adata->stream_buf[i].stream_tag = i + 1; + } + return 0; +} +EXPORT_SYMBOL_NS(acp_dsp_stream_init, SND_SOC_SOF_AMD_COMMON); diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c index 43a57d15e3ca..74ede28aa8d8 100644 --- a/sound/soc/sof/amd/acp.c +++ b/sound/soc/sof/amd/acp.c @@ -363,6 +363,8 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) acp_memory_init(sdev); + acp_dsp_stream_init(sdev); + return 0; } EXPORT_SYMBOL_NS(amd_sof_acp_probe, SND_SOC_SOF_AMD_COMMON); diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index ac8340119125..36d000c3f792 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -13,6 +13,8 @@ #include "../sof-priv.h" +#define ACP_MAX_STREAM 8 + #define ACP_DSP_BAR 0 #define ACP_REG_POLL_INTERVAL 500 @@ -114,6 +116,17 @@ struct scratch_reg_conf { unsigned int reserve[]; }; +struct acp_dsp_stream { + struct list_head list; + struct snd_sof_dev *sdev; + struct snd_pcm_substream *substream; + struct snd_dma_buffer *dmab; + int num_pages; + int stream_tag; + int active; + unsigned int reg_offset; +}; + /* Common device data struct for ACP devices */ struct acp_dev_data { struct snd_sof_dev *dev; @@ -125,6 +138,7 @@ struct acp_dev_data { dma_addr_t dma_addr; u8 *data_buf; struct dma_descriptor dscr_info[ACP_MAX_DESC]; + struct acp_dsp_stream stream_buf[ACP_MAX_STREAM]; }; void memcpy_to_scratch(struct snd_sof_dev *sdev, u32 offset, unsigned int *src, size_t bytes); @@ -165,5 +179,19 @@ int acp_sof_ipc_pcm_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *s void acp_mailbox_write(struct snd_sof_dev *sdev, u32 offset, void *message, size_t bytes); void acp_mailbox_read(struct snd_sof_dev *sdev, u32 offset, void *message, size_t bytes); +/* ACP - DSP stream callbacks */ +int acp_dsp_stream_config(struct snd_sof_dev *sdev, struct acp_dsp_stream *stream); +int acp_dsp_stream_init(struct snd_sof_dev *sdev); +struct acp_dsp_stream *acp_dsp_stream_get(struct snd_sof_dev *sdev, int tag); +int acp_dsp_stream_put(struct snd_sof_dev *sdev, struct acp_dsp_stream *acp_stream); + +/* + * DSP PCM Operations. + */ +int acp_pcm_open(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream); +int acp_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream); +int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, struct sof_ipc_stream_params *ipc_params); + extern const struct snd_sof_dsp_ops sof_renoir_ops; #endif diff --git a/sound/soc/sof/amd/renoir.c b/sound/soc/sof/amd/renoir.c index ca5582b3f82d..0241c5dce156 100644 --- a/sound/soc/sof/amd/renoir.c +++ b/sound/soc/sof/amd/renoir.c @@ -140,6 +140,17 @@ const struct snd_sof_dsp_ops sof_renoir_ops = { /* DAI drivers */ .drv = renoir_sof_dai, .num_drv = ARRAY_SIZE(renoir_sof_dai), + + /* stream callbacks */ + .pcm_open = acp_pcm_open, + .pcm_close = acp_pcm_close, + .pcm_hw_params = acp_pcm_hw_params, + + .hw_info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_PAUSE | + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, }; EXPORT_SYMBOL(sof_renoir_ops); From patchwork Wed Nov 17 09:37:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624159 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 7553DC433EF for ; Wed, 17 Nov 2021 09:42:31 +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 EEDEC60C4A for ; Wed, 17 Nov 2021 09:42:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EEDEC60C4A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 54BC4183B; Wed, 17 Nov 2021 10:41:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 54BC4183B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142149; bh=BfkOn1DhkI2w5jM7yoT9YiSQgCU4dCmxtyXx4sANg5w=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=cO9ncudrFgaL8+6RfqX+tjFAAUuaRVQleCquuKBBZ0hzbYQxqS4VyIZnznNoZ2v6E 1jc7JU5vGfnbvJ7CC/FhbiW/h12vzaB0JooKmP1SwWrI/1wzATKU87FhCC8TGIDdVE FcFVL124rfB8RZNQftNo4xG9Fi8suvfRGpC1LBRo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7D6E0F80535; Wed, 17 Nov 2021 10:38:45 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4B768F804EB; Wed, 17 Nov 2021 10:38:29 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2057.outbound.protection.outlook.com [40.107.20.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A2A34F8049C for ; Wed, 17 Nov 2021 10:38:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A2A34F8049C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="AJcMzu2q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VolrQBIJVrZYBIY13S+4V9Wc5AINwojFsfAtWFyr1plGpt+xc625c7YQUHeedkn0BcVJXoefZlBB9woCc7/vviPbKi4WolEn0XLP8QoL9SVllzpDtgsN7LplHpsOvDB656K6gS0SDG1qXSPrvuzBU7OQ0J2v82IlZmvsl+8xIXbNyfhNLFNv+Z4XKNmQTuE4uV1e5LXtR7aBJ4bvEXd0nEDdfh2OfNq+86ceL9wxo0VSyY8qhOp2/9OptV21dHEbfGbm3hnJjPiJCLHmLJH2rCix8RYUuczf8m/BHNdZCiMKmztigTWTJHC0ktTaWL7X3UnjFZdAhIdFuKAlkk3Ifg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a2Ggpnh3r5i2lWYEnSpFogjWi34SGFMejbH6vPzJUwU=; b=PnjAQj5xJEjzCFhVDEa3Fwi3QTFtBOmKnuBAhV7gPEun5VBsQtgdyXKzCNAhoAzBod9ZmDJSEpklaOJeFjza2HQ8FUZpfhDadbxz/GCTmpyiXJkU5gMqhgNueyaphecwsQuS1Ty7DFWgxRT0BbHhcfuh4Lw3E5QMCrgqK+jZL4GBTSp0Ryayiru0/4RMDu0RaF5um/4XgdRU7fE42flG4aZGDaaWvB2+LB4gaPaY7/Z8IpR6xo8FW4XDssgoShCnlNIIGsNJ7wUEg+H/XE8YW8h04tEBCaGFxTofVKuggfTciN3sAQVxSLr+2g/49ealXMPY3vDwnb9vxQJLxGfZeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a2Ggpnh3r5i2lWYEnSpFogjWi34SGFMejbH6vPzJUwU=; b=AJcMzu2qH/wZSHr6wLZaobQxIpGxBCJooEQg2nhMKDeK4VKYTrQuaqQeVRdJzSYanRJsCwsDIDl4ycbeLRMHeA3JNJn/ab88VAD1iH2bzQOTrQdcByFeouf4LDi7CThWmZanOerx8OZ4YcDktjEn42fBS4f3XRuylWKdNZpaKaw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 09:38:16 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:16 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 07/21] ASoC: amd: Add module to determine ACP configuration Date: Wed, 17 Nov 2021 11:37:20 +0200 Message-Id: <20211117093734.17407-8-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ecf7d978-0b2b-43d9-9001-08d9a9adfb68 X-MS-TrafficTypeDiagnostic: VI1PR04MB5807: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2YgQDgS+PQC/6Gq0kn42ZnQdA71v9EMTzljqNYZsxhcNqhNFI2/mgraOvQG8lnVBOx6cxKHAC+ZPuEb10w5WdRWd0ALI5CD2E/HKewyg7ZOaton5Nwzresd1qFpqhymEm6wp6pP2TNinDj+dVCBSAOrrKB3F61BsCEjqjR0ogh5DoeG6ysp4KfvzHziR0VIPtEOX7uZ+++0xpUiSzCSjyaC8059nTWu/BFOsF1VigfPsuSJhVeSRFMeiBGsuGP7WpmFveIakErr/B46mBYsPdgZCriZu0rMnHk9XRc288FuKHRBGAhy5OG9+zOZ9lgnvPMMnZarcb3eNHEAzseeErn/unwccu91ZJxxPIQ5E0nAMtpyWX9HMSVhXm8NLJmTvAWd69eLxt2OPqL5tiwT4VBXkYQih5Do1+o97YKT2Ylkg5uCsbKupG9MyAWRj2SwmOLP6MeHH2nfdlLlEpvtCs1LRK9Rgo+/1JPGhm5GqpBkpmz1bm6+FsZ6S8RcylnimS6Wxl9BjncHc0acPOljTQd3sbmS4eeF9KnwrUinB7fvHIhhzJuhH7InN6G0B0/0LqE/7bPry7uTjd07m3/V+G4u3I4YV0h9S2Bg33xAjjO5/2PVwkiE2+/jhTOUwyCMxXN0+Vesx7h8lAT69vgA8Og== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(316002)(5660300002)(508600001)(52116002)(86362001)(8676002)(54906003)(8936002)(66946007)(186003)(6512007)(2906002)(6666004)(6486002)(7416002)(6506007)(1076003)(2616005)(66556008)(66476007)(44832011)(83380400001)(38100700002)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: alHuqOEwWc96+xycJx6HANBDoG9T7BUG7dEu8q/HH62wl+tJhM7hSp7+0dxnDpIz1VNDhoLLO8W8vUO1Ug/6sHaUM4udXuuA0Iaw7B9AP6EZ0t8/y9A8rakD+erDyplrN4/rNjUXHNfWUFPK9DM+iygJi4vzpeE8NBQRSlF4T6j+cytVQcvPhORYd/VVuXnxXNigY3MwM0SSrMQtdizuUhoFbCLoIhrqQVlwYjozvvFh67CWmXuwm/OSyj3wnbhyjdgqQRrGiHOuexCsVy4gegD+x3QgE8Wc+QBuPxlQsMdmxmlXUWF9iBvWyVChC8YfW/BypGlw0mjo6sNkSNLrVpI1Xx/iOgr5AEkssyNuTf3mEXN79dtZx2XPo5NEt8tNsyUtp4+TCj03n2bDflD695HfPrjlk7YfcUig6GqQ5HTw6eFNF5YPqwfEmyHDEqcGO1whEraTgvpG7Qcarqvr9HZO2aQSLts3Co5edE6jSekSq3WF4ADMNTSoZQxhvpIAHKKm/Lt6WZAKc/9a1MDIC4ghFT7S+XnL6aAib0qJI4DTRsfhYxvu3YktNBUgwQZ/1f6KAbHe92Bpi7U45jkwUvZqRIqbhTUDjbgUXqdRoGhJdah9svOmHK8I3ZP4mXLsMZfkR57ohlfcPIWOYb3Sx7y42KVCBAVtNy30onkSkEU53RWyg6lP2lsBh+HVO6LvSJzTZnogPnIPOZuf+DCwnFA4anQz0XtiPovnMFOn1WmbkYIeBuHmbzDLf1t07oLjpgjIqaj0p7MLKVIp5LG8DZMdIeUQkjUUrxSbgg6IkySdnIPktIR+7bQKtPGyv4pIg9tIP4ogBJnAK0qsj6KJQ7vU2P+4B5aUodSEjehUeV1NtONsh6E0+SeBvWrXmA/1AvCPHts6kQNAsJJq/7QeQHz7dCxcFmcZfsDVYDdHw1lZ7+h9Y2a+VqtdS4w1n3B5OnkcKTNvn4oa7MzkoO/TfTVeKmUedtkGKuF9lnXCDxAHA02A6if4nJNGn7S7POFsjsF2UerNjIL6o3bNlpAJhUpnv3hJFkJ8Y8jECwRz2Mlv+FW5ZLCAI4JvANzXyhw3zK4EzJpJD+5JxIArouWRZ7z1xHrBYA9RhIH3vHW6okVgeHb4vZEgEvhthTWFm4mxwvy56U+L0XnqkLAkU5gSvCDkuS2kndy6Om/W142MwoHPrBFycPMlVNaLf96Q1g7HgnFlvwNZoc8XL7RUYYNQhlQQ8XWUy4ifHWqxLPOqIgVX77xBFjFg5+QrGvP64uWj+qvKhbSZcs3LHGIfux0ThjMUndK+adR7s/EYHXO45wOQl/tie1hrJOgxI6XBAqTtdu8t7ZTY0oHk/tcO4YNVDbm2QGl1NanRHnMyCUQcPebpt/pPXKgm+Unyt2Wcv/sPPc0J19cvb7Nm9uOS/2f6+e+RTi45kk35hFGYjjhDqlQAatak+FFXCK0MwWgSz6QTZDIpD4/xMwes8knY1oJFug2iQh2wWllA9UCuIT+lpGnLOsJZvpidX4Z+ASJY+dY5hucc8U/1jQneiJkCS/emPjisvxC5rMxqmYS3V8lZ6yBpVWTdVJPhVjbyHpn7kua/SJsEaXbWQZm4otBLiiLxVxLXDrR3LJ18WycOuWwQgH2dqJ0PWQ/s+DsUQmF/RjMNEZ7ea3EQY2RHLzJ8ZfSFygIeknTBtz442dQZCo/6+SuH9CCIJ0FEVchScLNmqbJj X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ecf7d978-0b2b-43d9-9001-08d9a9adfb68 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:16.4524 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AU52seh5GvanwKFYf2Nhx0n0z2pG7barkm6GJr/Isx7iC4eO5SQM6e+EaL77HRyGoWVeWwiD7VaEExACjrocdg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5807 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ajit Kumar Pandey ACP hw block configuration differs across various distributions and hence it's required to register different drivers module for distributions. For now we support three ACP drivers: * ACP without SOF use case * ACP with SOF use case * ACP with SOF use case for DMIC and non SOF for I2S endpoints As all above driver registers with common PCI ID for ACP hw block we need code to determine ACP configuration and auto select driver module. This patch expose function that return configuration flag based on dmi checks for a system. ACP driver module probe register platform device based on such configuration flag to avoid conflict with other ACP drivers probed for same PCI ID. Signed-off-by: Ajit Kumar Pandey Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- sound/soc/amd/Kconfig | 6 +++ sound/soc/amd/Makefile | 2 + sound/soc/amd/acp-config.c | 81 +++++++++++++++++++++++++++++++++++++ sound/soc/amd/mach-config.h | 29 +++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 sound/soc/amd/acp-config.c create mode 100644 sound/soc/amd/mach-config.h diff --git a/sound/soc/amd/Kconfig b/sound/soc/amd/Kconfig index 2c6af3f8f296..092966ff5ea7 100644 --- a/sound/soc/amd/Kconfig +++ b/sound/soc/amd/Kconfig @@ -96,4 +96,10 @@ config SND_SOC_AMD_YC_MACH Say m if you have such a device. If unsure select "N". +config SND_AMD_ACP_CONFIG + tristate "AMD ACP configuration selection" + help + This option adds an auto detection to determine which ACP + driver modules to use + source "sound/soc/amd/acp/Kconfig" diff --git a/sound/soc/amd/Makefile b/sound/soc/amd/Makefile index f1d42bbda709..4b1f77930a4a 100644 --- a/sound/soc/amd/Makefile +++ b/sound/soc/amd/Makefile @@ -3,6 +3,7 @@ acp_audio_dma-objs := acp-pcm-dma.o snd-soc-acp-da7219mx98357-mach-objs := acp-da7219-max98357a.o snd-soc-acp-rt5645-mach-objs := acp-rt5645.o snd-soc-acp-rt5682-mach-objs := acp3x-rt5682-max9836.o +snd-acp-config-objs := acp-config.o obj-$(CONFIG_SND_SOC_AMD_ACP) += acp_audio_dma.o obj-$(CONFIG_SND_SOC_AMD_CZ_DA7219MX98357_MACH) += snd-soc-acp-da7219mx98357-mach.o @@ -13,3 +14,4 @@ obj-$(CONFIG_SND_SOC_AMD_RENOIR) += renoir/ obj-$(CONFIG_SND_SOC_AMD_ACP5x) += vangogh/ obj-$(CONFIG_SND_SOC_AMD_ACP6x) += yc/ obj-$(CONFIG_SND_SOC_AMD_ACP_COMMON) += acp/ +obj-$(CONFIG_SND_AMD_ACP_CONFIG) += snd-acp-config.o diff --git a/sound/soc/amd/acp-config.c b/sound/soc/amd/acp-config.c new file mode 100644 index 000000000000..c9abbb46b6f5 --- /dev/null +++ b/sound/soc/amd/acp-config.c @@ -0,0 +1,81 @@ +// 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 +// + +/* ACP machine configuration module */ + +#include +#include +#include +#include +#include + +#include "../sof/amd/acp.h" +#include "mach-config.h" + +static int acp_quirk_data; + +static const struct config_entry config_table[] = { + { + .flags = FLAG_AMD_SOF, + .device = ACP_PCI_DEV_ID, + .dmi_table = (const struct dmi_system_id []) { + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "AMD"), + DMI_MATCH(DMI_PRODUCT_NAME, "Majolica-CZN"), + }, + }, + {} + }, + }, +}; + +int snd_amd_acp_find_config(struct pci_dev *pci) +{ + const struct config_entry *table = config_table; + u16 device = pci->device; + int i; + + for (i = 0; i < ARRAY_SIZE(config_table); i++, table++) { + if (table->device != device) + continue; + if (table->dmi_table && !dmi_check_system(table->dmi_table)) + continue; + acp_quirk_data = table->flags; + return table->flags; + } + + return 0; +} +EXPORT_SYMBOL(snd_amd_acp_find_config); + +struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = { + { + .id = "AMDI1019", + .drv_name = "renoir-dsp", + .pdata = (void *)&acp_quirk_data, + .fw_filename = "sof-rn.ri", + .sof_tplg_filename = "sof-acp.tplg", + }, + {}, +}; +EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines); + +struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[] = { + { + .id = "AMDI1019", + .drv_name = "renoir-acp", + .pdata = (void *)&acp_quirk_data, + }, + {}, +}; +EXPORT_SYMBOL(snd_soc_acpi_amd_acp_machines); + +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/sound/soc/amd/mach-config.h b/sound/soc/amd/mach-config.h new file mode 100644 index 000000000000..608f1e199775 --- /dev/null +++ b/sound/soc/amd/mach-config.h @@ -0,0 +1,29 @@ +/* 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_MACH_CONFIG_H +#define __AMD_MACH_CONFIG_H + +#include + +#define FLAG_AMD_SOF BIT(1) +#define FLAG_AMD_SOF_ONLY_DMIC BIT(2) + +#define ACP_PCI_DEV_ID 0x15E2 + +extern struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[]; +extern struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[]; + +struct config_entry { + u32 flags; + u16 device; + const struct dmi_system_id *dmi_table; +}; + +#endif From patchwork Wed Nov 17 09:37:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624157 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 9C7E4C433EF for ; Wed, 17 Nov 2021 09:42:08 +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 1D89361284 for ; Wed, 17 Nov 2021 09:42:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1D89361284 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 6C745188B; Wed, 17 Nov 2021 10:41:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6C745188B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142126; bh=aj2+q0Za1YNNRr+wlYcPf6ZwDSMb3KapqxAInOcLqKQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=My4lhYvquzLXNWX5D1H01aAcjOfiMWlzRqcHmUb5i/zNJzS0DGiSIaVDEKhaSjc51 x445kpSlgRcS5pbpAMmJN9aYsoKJnz8rFNHOLF4oBtGg93DdHrSgNe7SHa/PzY/Von KPylQo0ZGy8UG2G1/qO+1ZTWVhDDyaaiHHY7OI0k= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E8EFBF80507; Wed, 17 Nov 2021 10:38:44 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A3B3AF804EB; Wed, 17 Nov 2021 10:38:27 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2057.outbound.protection.outlook.com [40.107.20.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1151BF804D6 for ; Wed, 17 Nov 2021 10:38:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1151BF804D6 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="FVW/b9oN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iqidAvOO8nyiinpv+cnIskB3DBCr8OS8JWKvR4SkLwZBiAepu1yshPSMURJN81/n7KQpfjyf3Gcl8OJ82h+nRJuulOP/Vqe3kVO00U7WLdb9iazKwSkEX6sZxOGcuuBUt4DP6C8ko7ZChOy2Z6UVSRcbtYk/E0yTqK7jX9PDn2OdhLP0jqd3z0/qUIT60HlVdmD+Xep0hRKg+/9k7r+3cOSQBj/XS7nOkCNsRtd+FMT5OMwlF99X/KalzaE/opfra7P5PAjoSoK8eVys4zFyPBEXnl6awjd0NEzVDfJ+gHJJbcEU1P1MulrlTso8MneNfiarAR02jia2KmVnuDl2VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qETs5pmNyjuaBLj+49Mq3BcTs04Xkehh/3KstmMEV3k=; b=BigAi9lyvm/hBVdz7IR2SSbmEXqy7J9ji2Jfd+QYWOa1C0ndbJY4qS+mHXF6agO5SWEhcqHjlDpLn8SSMe1qjpDA6o3i0E3/xk3QepCClg1dZVItYGlYmZXCX3pwpgrUiXI5B3DtzPwFtWdzn2IrPPC4QyTgmxKI7P6/hQx+SjV4URnZ50hiyiQsGHnJEDPGIacq2ucKuVeFDAfaIn9nreYaaOJV9e0tQjZmUr2vnuZNFYFac36VfoQjJkGyd+Q3y3yS+xH2G7Q1mDjpUmmjtyydd/e0XslXlkqSfdNuZMjsPdDJNAIopB21QpJ2RZrVV7W0FQLVQ0mVJz1QtUhMWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qETs5pmNyjuaBLj+49Mq3BcTs04Xkehh/3KstmMEV3k=; b=FVW/b9oNh+Ysnz+RVl1NkcoIR2E2iR+0EPxymLedWUOeM7/EtaEuRNpKFyZ5Vp87xL0tN1DpBS4cr8fQ9XOFlWGYatkylMHy33pPvoLEWqCWcjKohpC94E+NFIi15VOrDwTZnmX+74jXdgQk/GtGltKSV34bTqkfCFvr0FIlrU4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 09:38:18 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:18 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 08/21] ASoC: SOF: amd: Add machine driver dsp ops for Renoir platform Date: Wed, 17 Nov 2021 11:37:21 +0200 Message-Id: <20211117093734.17407-9-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6beb1744-f0e0-4322-305c-08d9a9adfca1 X-MS-TrafficTypeDiagnostic: VI1PR04MB5807: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True 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: Zu+hQ9iK5kM3HEeQ4xUH5MHF2nsZvfLS9fL5lVv5uSpHNkEChuPTUsJEODInuDxH5zhfJtDowacc/XzGXRtGWTXYtsrUC1f0fqTZ1hWhhoOwwhJcAm90SvlSgTaSFFNmtxv24oITacR+zp1Gn5mPI/O8KAJD19YOkDUQIsrjXoo+oaoYO2YCGbhJpxZpyUArrG+lPp+cQROGJJ2d4TYpmywxrAoxYq58298Av01DSbVpA3j5kxouo+I8W1UgIRDdI11u3GaqPybpNWaER5TrofaVRfaoLE4MFm8Ft6QnBkjR43z4i1L+CE5me8Qd1HGn6xZYgbzqaN//3wdVNwKtEmtvInFXNLlyjGYsVdIkpnpznCzvK4Q2zH3rDFnFLFfQTFbY2/l4hhfluSx8D2HKqBvJWQVoPeY/jkjQX1PKO616Ebb85v+dur1fpbWvaxkG9s1IE6ao1qSvbLdDMv/kggLg+z19frNsdkZhON2e9cpWRJoXunALxZJ1clNfzQ/f47bNGZYdFQUMZrSCAy72TLKQsCuC8cczXCwNjoZUPPulUN85RJILxz1Ckuw5QDe7edFvrHA7Fsu0ogo1Da+VltJMX/D3ZavjLimMb2pUQ7RJrZCFkNqndmiAzMX4DZ9Bcn307pPThwncYYsxVG+sIQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(316002)(5660300002)(508600001)(52116002)(86362001)(8676002)(54906003)(8936002)(66946007)(186003)(6512007)(2906002)(6666004)(6486002)(7416002)(6506007)(1076003)(2616005)(66556008)(66476007)(44832011)(38100700002)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h7rFmaVKnQjnqBbzyMo+JPAps9nd+lDz0TY/HfRM9k9KZ+ZDxrppP3SEYBzrSsIu6m7v5YNNF41Qyi+V3w6Sd1/OYapdMbms70ENcJhZxqZYfhsqQnrzkhBSryosJKZT7vtnO4aEjPEyLWzvRYwLLc4porvp6QREuLhQ6s0vnBkYOsm7rhszt2ZIyfOU9VPb7MVIYjv5ABZiAmib6p/bSUjP00Kfs5S6TdoCTnimCeYA+urn6Pa61wMqqwHCljLz+jnozU6HCUX+ub1LsaIIkcphU9699+PPfTG4AJK/iNt7g8ttPgMf96FU2UrY6pQZinXEkUiW1Ff3e8HkzIU4a6W5GAxUJscKl1plsONDy06wLkZQQ07x57fZunSgn4zo5TtKPiEvTCng8eqGRil4kgcSBDZBkKM2X/JDlABPRvNyfVpdhkRFt9WyVaOJQ1yEl6QnlNkMax76aYWW1QlyD9UNUNTH9UZ17xlHYoKz2BT4WNKn0x9riDTfnedJ3CNL/Wa60c6dY+yWhlvAm6wgg+Z2HkSjaltW1Mw34K6LP8g8fIxstnjHtv3/UWtNMDaESjLKaffSvDn0zS6Xdjx+ltGyoi3Rn4XfwKhAcNLzwP55I+iPzcxDSRNkz1xm/Qds4vXWwbP1+tBTgoq6cf7ud/JJwzYjABfn732789XYjAXigXSPWxQ8HKx0mEvTjKCViAzr1KzYHDjOJrs+n2d0L6YN2XwpbZ/lTi9+BNZha/7AYSgO2XrtGCNePbhWH2mejnP4q0OWrXyRnmfDzgPUicH0GOVT6Wo4HWpOQWhH3L+TzXuyadLA8yqEEa1qRXUfLrVflGmdlgwhwtIpKsVQRDTLBa5PXONFG5e2jPx6ItEiakBXI4dVdSlLqE/ZY1fBJZSEsHizpoM4QX1AYvpfByBRJHxXvMloYo1vkR9w4HC8QhObgXDsuFW8eI4OWL1F48RvYgC9/tbXl69wNCdZBxKK0oNlQCy1c31vnGvcs0o0Gi7WgV3uunAo1ieRam8llupzbxD0jd6O6dpTBqjKR8Tg9tV6QpiiXcytADAfcCL8RRABUfwJ6TY95X0DPtOn2bCapuQDkktRKL+1DtV3BDK6zxx+Zb9xGtqXLcrBy7t7j1holI9CAH0AzPLnJS9HfeS1c70xdxHkVwbWn8v13ccfBPRDbjjZ+8P9tpsD2INpgK0OxTdrtE4hRnGHjP30pc336UPDnH8mtDlvWEr48aebKuEHjNEP9eRYIs0baYgmAqj9HjacnkWjxd8uSFppUkk9as1ZEUykaRhyFcbmu2jqIn0N5sQeBTgtmHWjRk0qlfIApE8dYm9kDQx5vDbWrkzEEXpxsukONm6X4s0BCqcfrBxKIuC51d0gT4Bi6tzDbaEPL0FReoXM6z4Cq5qfh8OORBpQKKu1AwaT4MmOChl6zmaNxys6GUGWf5lPeL1RMYlvw7UZQ3QRVeRWXPAtBTfjv6TSeULvIyzb17/vLxsQxEU5M621qg2ZIk89XhR4seHA92Chd6z7a5cSLDRhOYLyM5YEDfaqD888eVf4Tk+WmKGBekqV60sl1q0sGsbNFwRKuB4QioRoX9wp/utL4cb4uI9DSkTA2fk0YNI51dnWZnT1qttdzXSSIFb9bv0ERhjwR9o39uP70y5M4/Gm2fPn5O2/YcnUYvftLs/q6pbXBuAl/kz915Fy1IqNDFZbL48xgpI/OzhFYPhkrWze X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6beb1744-f0e0-4322-305c-08d9a9adfca1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:18.5972 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7WdFty6i87FY55yJnLaZu9i2DRvYUg10Q48dWcX8GI/kjjxa0pNDj6NSEfmLDyD8uBvckYP7zZGyA94JZflzkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5807 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ajit Kumar Pandey Add dsp ops callback to select and register machine driver. Signed-off-by: Ajit Kumar Pandey Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- sound/soc/sof/amd/renoir.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sound/soc/sof/amd/renoir.c b/sound/soc/sof/amd/renoir.c index 0241c5dce156..3cd269bfe75d 100644 --- a/sound/soc/sof/amd/renoir.c +++ b/sound/soc/sof/amd/renoir.c @@ -104,6 +104,23 @@ static struct snd_soc_dai_driver renoir_sof_dai[] = { }, }; +static void amd_sof_machine_select(struct snd_sof_dev *sdev) +{ + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; + struct snd_soc_acpi_mach *mach; + + mach = snd_soc_acpi_find_machine(desc->machines); + if (!mach) { + dev_warn(sdev->dev, "No matching ASoC machine driver found\n"); + return; + } + + sof_pdata->tplg_filename = mach->sof_tplg_filename; + sof_pdata->fw_filename = mach->fw_filename; + sof_pdata->machine = mach; +} + /* AMD Renoir DSP ops */ const struct snd_sof_dsp_ops sof_renoir_ops = { /* probe and remove */ @@ -151,6 +168,11 @@ const struct snd_sof_dsp_ops sof_renoir_ops = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, + + /* Machine driver callbacks */ + .machine_select = amd_sof_machine_select, + .machine_register = sof_machine_register, + .machine_unregister = sof_machine_unregister, }; EXPORT_SYMBOL(sof_renoir_ops); From patchwork Wed Nov 17 09:37:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624163 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 0454AC433F5 for ; Wed, 17 Nov 2021 09:43:13 +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 2D95761357 for ; Wed, 17 Nov 2021 09:43:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2D95761357 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 A66391893; Wed, 17 Nov 2021 10:42:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A66391893 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142190; bh=6x0MIXznXTUuu2irGTVZ/uJvmt2cm0kwHzmU+5eGar4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rrPkGKLULjjNUrTmddjmlNouj+mhVHv1eikmRew77ns7gtWcY4oHzB5uFx1lmU+Cw jw6mqsPP+W3tsdGi0W5M3LYHrxeA37m9e2xZLW/6Dv8H8qq8xa/6Xl7NgJQXQ+eFIz +qkgDswCoTDCEl78s+qc8JBWZzJOkV3V3oi7uBo8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5F637F80543; Wed, 17 Nov 2021 10:38:47 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1815EF80507; Wed, 17 Nov 2021 10:38:33 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20617.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::617]) (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 E7672F8027D for ; Wed, 17 Nov 2021 10:38:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E7672F8027D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="a2XVBiUy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kNjKRxYEWOOQNV6fnLVBeIxsd8fky/8WjWM67zaSk6LWLMh6tFZr+Nb3gie7UB4xeSeAUt8dcfTvRZAyb9dtvHCprsh5wMVqEhcCLbxNCxoJSoBCxKyo8PCU8F+gYsM3CGKsosDVyVaFHgBLK9wEah+XXC3/my2Nh30r7clnvktP0z2KIkTbplKbDyLpkaG9ohsEq07CsbsQIzGlRIisDNcqC/P/67YA6K7ldBY2S9BpWZPni4NOkGR3jhYcYMcaesm5UAv1Y53hHfBQZuze2txOOkYbntGQ7bCQaDGI20qpIBZgnSA2d+KsXwP8tV+agq2ky3euVQJ+Fk8CbxHAVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7LqjUUO5qv84gjPhhIR8SitLrMEkMICo5WShMvZ18tY=; b=QpD/0sWOR0QWbRxxQg650XULi4RYVDDxqXNceHZjCuC7jqVJtqN9mKX3XB5c2LwdelXcb9WPueKrDhZGW4uCjMYb3e0Rk872bsdwHOhy7I32KxYieNVHBYIgKeP6Skp3+jQsgr2kOL5k+RA4rp+AS/94nNpD0QOV/KjasHoHLMIRAJlwfmWo1YA4ifphGcjcCFJ3kX99Bnwknz+DiOCMqVZr1ZeqbXIcryDvMyOmg3W9WBTzNhkD/DRRuZWyKim4K1BFnQ2Ip+3bb1m38t+n/xwiA+cINCSlgiI5ixpgXbxys+heb2dSiibZGsglUS0xA1hjiUoFE7m2Rqdg+pey3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7LqjUUO5qv84gjPhhIR8SitLrMEkMICo5WShMvZ18tY=; b=a2XVBiUyHxPCdiV2dH4fs24SlivRhgNRVc8v9QQEv9nj44myXB+ODM8o1FB0o1u/VNtwPx9ghD05Uoenqc01yGdR0NquWignOzteNy/nHQlgcqsm4t9GeWiRPsshBgyvybBwo25XKIzCPeii6Ey4SjmW1YDAorfxUxKBxVehF/0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VE1PR04MB6623.eurprd04.prod.outlook.com (2603:10a6:803:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Wed, 17 Nov 2021 09:38:21 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:20 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 09/21] ASoC: SOF: amd: Add Renoir PCI driver interface Date: Wed, 17 Nov 2021 11:37:22 +0200 Message-Id: <20211117093734.17407-10-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5740da27-42fc-4690-f730-08d9a9adfe1f X-MS-TrafficTypeDiagnostic: VE1PR04MB6623: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kl+2yyslrH3UUP08RbverIm7V1sDX7HPf1mgjdKZHSEJ8+JuEtuLzf6JgTp8Kg1v5oAyGgXwrLwm9qNNvPuEKJtX0MIKXt2WBesQ3i7gQHhyIi0j0oAsp83DHBjSHp2JISKReuDJRgpDaYW9xVBD+0MRxOLsgovZINQil0s4FikeVom5vjkAGLIXLmubBnc+SSmc8asTfo4CfVx00hipBj1wXt8Lw3DXB56R6Aa2yRN9iVKPkAhHMgd7hBwP2U85gyfBcFoUwW9qYMTAk1r7vux6d6g3u1MSI1mU3kQD8uCrKrVaA6jD9O6t/7Xne+3Sn3Jp9bctIJbINA/WjoBBzlx0wVN2LL+OHvel5Xl6zWcEZYAaSkVA3WMO7kKaJYB/nDl9+b25ahFdqhU+lTTVIR+ff/ZA2x1MLoXFtNHgmbilhozer/0aS959LOBCvzi8d1BRkzeEx9SmNd4zrU3TrPqgfk8shHDwFiY43/Lo5BhJ4rBEvJGBEAZffQa2tAwXPst1mQo4WV/LTCW9/Pz+d57lJUuTMWDm96Y5MtJSmyHDoo2u7je85JSkpyoXe9ls+EBdY1nA8Q0E8yYsmCillO6JFdd51zkgTbb2hhUQutLBnzbV/kdLXKrZHlZ2opX+mDp1dZOevfC5b1GkzoBvRQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(1076003)(52116002)(6506007)(5660300002)(54906003)(8676002)(508600001)(186003)(86362001)(6666004)(2616005)(6512007)(7416002)(83380400001)(44832011)(66556008)(66476007)(4326008)(66946007)(316002)(38100700002)(6486002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7mae2ih/ny87wuzM9tGD1YOFKdcxjsCWXbOhuCSiyZlI8zj/UbgiK3Gy0U0Zlsl0BRSdCIyeICVKizgQ+gs4HAV5HpFZq18SssGDcsbcFSysbR3cm4pCxZt00oei5ISs77PewV3YkRGsIxo8HP1BVpm7f87D8ijw21Fr7K62IMfOX3ufjf6rnHK6aIcfs+TsI4oQ+ARTGOo7zbaSF0HGp/PWMR3IQryCSwBd6BjJNRQWNvF5ujISycODGAhPFqb7YS8L5AmtGWV3dw+yZsk49hdmzz3DUvMTens5dnn3SuDGamYbBIwSoRtPEWGATs/4E46Y8G+FTFn3qgyk1zueCw/f04g9y0d7iu2ERuXcCHJQtOHejsMSrZftAq539IT7AcaNvEnhJY3fFXMj0f3x6Iw7nNoabub64rzcdLFriWXiIan6SWNkY0sEEIkFgkwYe9kEqflL9kAODr02McGXWla34ae+KbMVMr5VV9HAzvZGnfSmz2YgZvfKSyPOtacu8HnfY6iq5+8g7WahXr/wGOPpZ3uW3bLsDvbKuDSCjs5KxV7XOLJiPTMRRP1217DXs93KHbwqySFwTNT9RxlsYRItAzUAZQQebiVYF0Hi9WzLBnMXw/pI9N5tskk+olLbZOpY6We8agwwUuWknU8S2CJLMZ3CYINxCqvLOPRMfYrHLC+D+Nbb6STaz1J2gIF9R2uvnYj1Wj/EVHnGCoeXTHpwq5Ed9batKng3QI3S8dQVtMolj25Qrcz8sCJozCHXLtVjuGyV4/PAqZx1v1GOaVfgYWnroHooJIcmI532y9rwDiFLE5SJZbPOfQterg7+jU7Qgd4SlelE2eGk2YZfzy6P0Wje5m1WhE6ifFY8nJkFjyTQRIwnjsy5x45YOAegwTnjWFqJ1YA+7xFoMWhz950nAby5ltCWSo2zUUZ5Zp8SYHUfW9ppLp/vw5lSCYT85qyDgzXoNioP1GMJYwBlFzYDnUpyATGjLmPgxFF2LNJ/2c3EpC5Nu19OO4P3IPHJcQOU1mY/G8LMHu1umD5LTisx101lkDX075xCVeLvghasjpFp4E07deYxBxhM2NS7ouO2R0xEQ7ABTnFc2LcSkccRAFJ2EyNmZ+5lZ5cyn7M3NgtbBAF0TR1H2TVcZFP2Pj3nAzi1S6XPiFszqFSRgD83kiigqUbj4k3r55Tz6vnFxSE7W665AHngkS0IsGqHfWfxVFqygucTV06rehpe0UF2Tr5Xz7BOo3eFM83ezlXycsEcbGtYQOgKy/OG0bs07xGCPRlEKImJAdfGTE012oIy4vzKI5Lkoanm0MOZ8X2q4sGoMdoAWTm0GwRoqT36/Mgh+xdZrhIPsSlWRwYLlSn6OYAWIPSAY8BiIJeGxWMkm7JvxiV3dAWYd3mdlh4DvhvLTbgnE5/JApQ55QNFm1Gf/C6Ivs1hfSJC9ydP4MHLbdMsQk3sGhA7E1lLdZdrpZ8KayXMwnsDCzNMzfv3fZjL5C+RBFQGRoFtFagUx6eC0YA7CX0gU4ELcuadJ6/RE3lcRj/gBjY0+O7vVDw/CzE6+lUmBIejao1pGsr927tSqtfagrLHdxrGy3ojktuxNwYqaTUUV8f3nWazuly5+wQ3EpTs3C2POt0StFCdN9HXyVL3WNbLLrldfRPxNj8LSrgN6fGftbgmD7VTieSe+4qO5fZlO7Qv+/qr7kyyJ4Q= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5740da27-42fc-4690-f730-08d9a9adfe1f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:20.9159 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: k3IBgQebVRe8xYTZTwNRmN+U17NedR8QJFzzK2Cdr3vc/CI43H9hAS3xL7jauZ8nC5R2N5YSN5P6oVj5+GqG1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6623 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ajit Kumar Pandey Add PCI driver module to enable sof pci device support for Renoir. If machine flag set to FLAG_SOF_ONLY_DMIC this pci driver register platform device for non dsp based I2S platform device. If machine flag is not enabled for SOF pci probe will return without invoking sof device probe and registration Signed-off-by: Ajit Kumar Pandey Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- sound/soc/sof/amd/Kconfig | 5 +- sound/soc/sof/amd/Makefile | 2 +- sound/soc/sof/amd/acp.h | 3 + sound/soc/sof/amd/pci-rn.c | 160 +++++++++++++++++++++++++++++++++++++ 4 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 sound/soc/sof/amd/pci-rn.c diff --git a/sound/soc/sof/amd/Kconfig b/sound/soc/sof/amd/Kconfig index 400dd5a24ae6..085232e04582 100644 --- a/sound/soc/sof/amd/Kconfig +++ b/sound/soc/sof/amd/Kconfig @@ -17,14 +17,17 @@ if SND_SOC_SOF_AMD_TOPLEVEL config SND_SOC_SOF_AMD_COMMON tristate select SND_SOC_SOF + select SND_SOC_SOF_PCI_DEV + select SND_AMD_ACP_CONFIG + select SND_SOC_ACPI if ACPI help This option is not user-selectable but automatically handled by 'select' statements at a higher level config SND_SOC_SOF_AMD_RENOIR tristate "SOF support for RENOIR" + depends on SND_SOC_SOF_PCI select SND_SOC_SOF_AMD_COMMON help Select this option for SOF support on AMD Renoir platform - endif diff --git a/sound/soc/sof/amd/Makefile b/sound/soc/sof/amd/Makefile index 7b88db9c5fb7..b27ce50014b8 100644 --- a/sound/soc/sof/amd/Makefile +++ b/sound/soc/sof/amd/Makefile @@ -5,7 +5,7 @@ # Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. snd-sof-amd-acp-objs := acp.o acp-loader.o acp-ipc.o acp-pcm.o acp-stream.o -snd-sof-amd-renoir-objs := renoir.o +snd-sof-amd-renoir-objs := pci-rn.o renoir.o obj-$(CONFIG_SND_SOC_SOF_AMD_COMMON) += snd-sof-amd-acp.o obj-$(CONFIG_SND_SOC_SOF_AMD_RENOIR) +=snd-sof-amd-renoir.o diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index 36d000c3f792..5f6e9eff116a 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -194,4 +194,7 @@ int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substr struct snd_pcm_hw_params *params, struct sof_ipc_stream_params *ipc_params); extern const struct snd_sof_dsp_ops sof_renoir_ops; + +/* Machine configuration */ +int snd_amd_acp_find_config(struct pci_dev *pci); #endif diff --git a/sound/soc/sof/amd/pci-rn.c b/sound/soc/sof/amd/pci-rn.c new file mode 100644 index 000000000000..3c379a5ef231 --- /dev/null +++ b/sound/soc/sof/amd/pci-rn.c @@ -0,0 +1,160 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// This file is provided under a dual BSD/GPLv2 license. When using or +// redistributing this file, you may do so under either license. +// +// Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// +// Authors: Ajit Kumar Pandey + +/* + * PCI interface for Renoir ACP device + */ + +#include +#include +#include +#include +#include + +#include "../ops.h" +#include "../sof-pci-dev.h" +#include "../../amd/mach-config.h" +#include "acp.h" + +#define ACP3x_REG_START 0x1240000 +#define ACP3x_REG_END 0x125C000 + +static struct platform_device *dmic_dev; +static struct platform_device *pdev; + +static const struct resource renoir_res[] = { + { + .start = 0, + .end = ACP3x_REG_END - ACP3x_REG_START, + .name = "acp_mem", + .flags = IORESOURCE_MEM, + }, + { + .start = 0, + .end = 0, + .name = "acp_dai_irq", + .flags = IORESOURCE_IRQ, + }, +}; + +static const struct sof_dev_desc renoir_desc = { + .machines = snd_soc_acpi_amd_sof_machines, + .resindex_lpe_base = 0, + .resindex_pcicfg_base = -1, + .resindex_imr_base = -1, + .irqindex_host_ipc = -1, + .default_fw_path = "amd/sof", + .default_tplg_path = "amd/sof-tplg", + .default_fw_filename = "sof-rn.ri", + .nocodec_tplg_filename = "sof-acp.tplg", + .ops = &sof_renoir_ops, +}; + +static int acp_pci_rn_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) +{ + struct platform_device_info pdevinfo; + struct device *dev = &pci->dev; + const struct resource *res_i2s; + struct resource *res; + unsigned int flag, i, addr; + int ret; + + flag = snd_amd_acp_find_config(pci); + if (flag != FLAG_AMD_SOF && flag != FLAG_AMD_SOF_ONLY_DMIC) + return -ENODEV; + + ret = sof_pci_probe(pci, pci_id); + if (ret != 0) + return ret; + + dmic_dev = platform_device_register_data(dev, "dmic-codec", PLATFORM_DEVID_NONE, NULL, 0); + if (IS_ERR(dmic_dev)) { + dev_err(dev, "failed to create DMIC device\n"); + sof_pci_remove(pci); + return PTR_ERR(dmic_dev); + } + + /* Register platform device only if flag set to FLAG_AMD_SOF_ONLY_DMIC */ + if (flag != FLAG_AMD_SOF_ONLY_DMIC) + return 0; + + addr = pci_resource_start(pci, 0); + res = devm_kzalloc(&pci->dev, sizeof(struct resource) * ARRAY_SIZE(renoir_res), GFP_KERNEL); + if (!res) { + sof_pci_remove(pci); + return -ENOMEM; + } + + res_i2s = renoir_res; + for (i = 0; i < ARRAY_SIZE(renoir_res); i++, res_i2s++) { + res[i].name = res_i2s->name; + res[i].flags = res_i2s->flags; + res[i].start = addr + res_i2s->start; + res[i].end = addr + res_i2s->end; + if (res_i2s->flags == IORESOURCE_IRQ) { + res[i].start = pci->irq; + res[i].end = res[i].start; + } + } + + memset(&pdevinfo, 0, sizeof(pdevinfo)); + + /* + * We have common PCI driver probe for ACP device but we have to support I2S without SOF + * for some distributions. Register platform device that will be used to support non dsp + * ACP's audio ends points on some machines. + */ + + pdevinfo.name = "acp_asoc_renoir"; + pdevinfo.id = 0; + pdevinfo.parent = &pci->dev; + pdevinfo.num_res = ARRAY_SIZE(renoir_res); + pdevinfo.res = &res[0]; + + pdev = platform_device_register_full(&pdevinfo); + if (IS_ERR(pdev)) { + dev_err(&pci->dev, "cannot register %s device\n", pdevinfo.name); + sof_pci_remove(pci); + platform_device_unregister(dmic_dev); + ret = PTR_ERR(pdev); + } + + return ret; +}; + +static void acp_pci_rn_remove(struct pci_dev *pci) +{ + if (dmic_dev) + platform_device_unregister(dmic_dev); + if (pdev) + platform_device_unregister(pdev); + + return sof_pci_remove(pci); +} + +/* PCI IDs */ +static const struct pci_device_id rn_pci_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_PCI_DEV_ID), + .driver_data = (unsigned long)&renoir_desc}, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, rn_pci_ids); + +/* pci_driver definition */ +static struct pci_driver snd_sof_pci_amd_rn_driver = { + .name = KBUILD_MODNAME, + .id_table = rn_pci_ids, + .probe = acp_pci_rn_probe, + .remove = acp_pci_rn_remove, +}; +module_pci_driver(snd_sof_pci_amd_rn_driver); + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON); +MODULE_IMPORT_NS(SND_SOC_SOF_PCI_DEV); From patchwork Wed Nov 17 09:37:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624161 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 0B685C433F5 for ; Wed, 17 Nov 2021 09:42:58 +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 817F460C4A for ; Wed, 17 Nov 2021 09:42:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 817F460C4A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 D96F9185B; Wed, 17 Nov 2021 10:42:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D96F9185B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142175; bh=rJfwFl14RfI50Vosu9zJowwWDDp1tMi1aqiDwZseXRk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GGgIwM32EPTXnZEzrI06POzD+woxo8GxQu8YWHVOdYWDrQVjBhpX2iNiw7at13RCC gm2mlulkL4jlkpjuFqsKKMd3tLW9+c3htDYrSxPHlJMqu4gQVdVSjCNHrqZPn+BQbE Erw2uaWmtD0nugtuRWxwdG0rxkS+vmCAOxoS/hRQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C1A97F80542; Wed, 17 Nov 2021 10:38:46 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 00924F804FD; Wed, 17 Nov 2021 10:38:31 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2043.outbound.protection.outlook.com [40.107.20.43]) (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 D045CF804D6 for ; Wed, 17 Nov 2021 10:38:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D045CF804D6 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="ELVQHfiL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RZAkfrk6W6+OdGIdDhC/UB6MZPI1ttZolA9NU9uKk8Cxm31PjB872pZcFFhe6moXBdrbq+/Sj75VDFrMiYcFWwcdGc80lyNQ6Lfm5KiH81AZ1v37i7BI9JjieS5twbqlkmw6d0O2Iy/gFzjv4skVxcuOGO+cNoNwVFraZAq+d4JTi2IjIrTFd4kQap8uvl7eBLj+v1OZoZzKTWNyD1UdPZObQL2VscZg40gvev9KMv6GWizl38sYbQ86ceNmKj0HmafZIpcqS3AXxrA+02MQ5Mu5LaZ7yC6S65oJwOaJe9KryntSgwLW/mREg7L7euTFxCmQzXblb+51aCZJ3oEOdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IHUH4Cd4ZYtfRYW75IGB/V1A4cXMLi5M1GrNapeEmoo=; b=Lp0br1VRzoVEigeGCT6A2+LoefzbAMr6L7luA3ZSX0UaCD9vr6qYTqKlSOxKuxmdHckjQyBTgEFHR9tMQJF+b8F7+oFw2Yi8+71ChxMJlJnHi97ASQLFUX0irUE2nX1rejkEJgXnlnNvRLc8YuIWGCvKESfkL9nBGX2sK17Ox08j0T6uISr3ywdz2F/Xj7RLQGYW/SywQ41ouhpdbwLDoISzaooBmu2uI5DPDGGlyW1yyCESAyhYBun8KlRZEl5yVunHTupChh+Br9T4H08DfArBoUeJ/qW1pQXrwkawpm06YMIg2z4fv7jvQWFdn4mPOAt0qnnLQHONo0i8veeHyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IHUH4Cd4ZYtfRYW75IGB/V1A4cXMLi5M1GrNapeEmoo=; b=ELVQHfiL+6/O7Pn2M2ZFSCFVXh858NFRE09s/vfl5hDlDva5B2lzfOQ8/bhHQkYrGpxEL+RLe12qY6qTP391Oh8FanYrcPPBByC2CKCiDnfrJGmtibrt0w2FR9Ku20Et87RJg5xgYpP8lxEhX1nKqL3LTG3Ln6eiwPbGTSoG5rQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB3039.eurprd04.prod.outlook.com (2603:10a6:802:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 17 Nov 2021 09:38:23 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:23 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 10/21] ASoC: amd: acp-config: Remove legacy acpi based machine struct Date: Wed, 17 Nov 2021 11:37:23 +0200 Message-Id: <20211117093734.17407-11-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8501f176-cd72-405f-36e0-08d9a9adff2c X-MS-TrafficTypeDiagnostic: VI1PR04MB3039: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:639; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d8MBTTM77iKsY6l1DNvKCN1EgDCRiUT9UlDjZFtS6n4ro71xXR0tWboWfFi123hcBdinGVievlwAqjKzi4edK5c0scfGozTurB1P9gBzFhc28WdVZ6LBOoC6P0iKP5FtCntlYatXL3c3wahT30peg4oMqqKOp21v1Y5m03zoKA8QNvul0jSaOjfU/eObP/HJKcuCoDs5+Gp2HR7zFzBGIc9urQak7/FN4Xf+bR8KcADnFAYlLDEgj1xSAzT55hhuWMjZtLFMCCnGoKSi1sxMziLmeOvRvR0IRyg5mCWEp5+9fm+9YD0G3JN9VD4xyzlhwpHGLEMxqMCbRVKs2hhojPs1fRmf7PemPL651bH8bS/KBy81RtlQNKgI7dUcw8vorh2y/upj6E7oFRUyJtfP6DwFY+chSJLKsSlPw4AQ//rVbN9nDxmHpxatOLvXJLcsTBw5eV+8XQNOQyc8xvHqvJyFHeZ/506HUcF6umq+RSToYwgoM9hZn4Cj5j4WQuHZAUKb5B674RRdkgJCaU6KMQE65G36q0ctyjzQVGNZEX4wPq8Nx33bhrJv41YEeFnI2/wC6q2O31Xe44MiqhAwEEWqn0WhIlh3knSvNbAqkFPuwm5XQABdphStWwsq4t6diXwpBDgZp+4FCcpT8qA+/g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(186003)(44832011)(52116002)(6486002)(5660300002)(66556008)(6512007)(6506007)(4326008)(7416002)(2616005)(8936002)(8676002)(1076003)(2906002)(66946007)(83380400001)(508600001)(86362001)(316002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0+IjNLG/gBPchNwU2WNmIc/vyomVtLmRMtv1eyjkoChtj1YLt5h2Hn8MKrxJTRp59LbxOCEye32z5lc+Akz5el8nkQ21crgq8J5ZGA496jIdJ/V09OiqjE2x+arNhqLlpTBWtF8D8eICFc9z7TeqlsmvlgrEmdAmTDlvzhYqs39L7Q67cJF/1MGlmHYARD9PJgvOcC6oQSl659v0N6ZXKBlYlROHiFuDstEBnzO25V25xPKfM16sCiPCbn/HSm+AQCzb+PnLheq8hGYd7ekgj3/0y6guzZQVoIwV17ArTA7KZJAa9yRohunHODK8P4a43HRvW0od2Moolk//yhBMlVDjdB6Uxsxew5JlI4gmab/Oz/V/5S7w/ZbQbGJuhn6vXprru+0s9MdumBnfHSdWuU7TJxJCopafLa86JeAvaZNf5Ul1wC1WsZ9iFJqanAiPiU8RD4o5FBdf17nnt9x+tdN1WPAgtfrO0HBjgqIb/bThZ6Vk8XbgK9QhvDOOpcfiojQ87Yl851GilkGxbKY1QPLxzSejPTUTrVC61x/2vjYDEVyKyJxKY65eCsTIx7HpbleZw7SgPGaUZHqg9vTVAF3rKG+qYnTVGst1PlsYjCEgp4ICwPfAkeSRRIfj3zWu36F9ZSAHJ9IwqrqgrWSiB9P1qaMlswMjh/5yRo04asRCeq5X7ANk1PagZjf6wHq/14sgh3s2dT0c9UUOOHRwtPIpynnH4ZRp2iDU10U7s6UFaFujeTljVP7xoP1oCgyJfIa1hEn8qNSKsopDCTxw+c4LheOTk3f2Baty7SRecHktZtLTgfe2HJOd0Wqs5tWq43wJDKSB7KtJ+w5pIMaohDwAMMUFHLTT/LRXajiQ3SSRQ9/cJxSkQULfeZCAWaQ4jlCqz0PGNZ1QJ/kpy6qSyA2W3GimcpA1FwRscz9Qx1RbmoXddpyWyhc8RLZ2Xs8/HjEaJqvJj8iOQS8rDPO4h1DxvXkd28Vpscnz0+q5v/4JTK1MjTf/7Xu9XBSTeMpNnONsIVSuWIY8JMjz6TmzIwh1rpfnVYtYnszHe3HiqP4tLQsxeAxgA2wTIn+MotBuRvIN3QQJX6s0dK4D+ZdbpluRkuvuw7Ui4PUDstv4Bf8H2GO192UWbCRa5homGOKKYqhkWmZ2aF8IhEXSijHTlahJfYLXTnmIGKw/wowjH+SHwt3nOREjArb9klEzYMDVWG/5H9FVHRVBrAui2TZOnvRkBnUzEeAMprH5Zr1LMAQkcp4iYJxro44UQWFNUIq8sTgLilRv6Du1d2cv9zspWW7wU0B8KcH0xcD0SrAjw9MFkmrWI/4ISo1LsLJb91cMfbEXSwnE/lqHtJp9virfrg/7AjyTiqgIpY20ItzPDI7muY7wS6m8ub9Hj+mZwDkyjFDnntIjJFh+l2JoS/YNx6aWp/dmDBQqnpSqThI5KuCmg+DuBp0ZT3tc76Lp4W/l6nb3dBvcSbFnzdsJhDgTXa+4st6JPSEFMI3/90qU9+o0gibasv4+dYLJFh7c3b8a1/qERCTzza9HsJga2X6+4m928wC28DW9NSzoJAz0JBiVIrA+yW7VKOhyjd8p/dh/Nx6a9NqmimigIyHGC/ABwX7cc+SkW0XBPF0AiM3fY3AElb4SLncBg3EbRXUsBdPjOz3PEad+cIdSk4bXEnLlpfFngABsouaiXyrph2xxd8Q= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8501f176-cd72-405f-36e0-08d9a9adff2c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:22.6649 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: W3gBnH+ASvmxTJaMSB1yNKvA6sWXRX5P41ztAr25iE0eF50USzjItjayCi+PAs7YTRhB4HrZZEG2VXCmR61iEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3039 Cc: daniel.baluta@gmail.com, AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Ranjani Sridharan , Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.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" From: Ajit Kumar Pandey We have moved legacy based machine struct into platform driver to resolve module dependency with non-SOF ALSA build, hence removed it from acp-config driver module. Signed-off-by: Ajit Kumar Pandey Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Daniel Baluta --- sound/soc/amd/acp-config.c | 10 ---------- sound/soc/amd/mach-config.h | 1 - 2 files changed, 11 deletions(-) diff --git a/sound/soc/amd/acp-config.c b/sound/soc/amd/acp-config.c index c9abbb46b6f5..1493d52c9290 100644 --- a/sound/soc/amd/acp-config.c +++ b/sound/soc/amd/acp-config.c @@ -68,14 +68,4 @@ struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = { }; EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines); -struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[] = { - { - .id = "AMDI1019", - .drv_name = "renoir-acp", - .pdata = (void *)&acp_quirk_data, - }, - {}, -}; -EXPORT_SYMBOL(snd_soc_acpi_amd_acp_machines); - MODULE_LICENSE("Dual BSD/GPL"); diff --git a/sound/soc/amd/mach-config.h b/sound/soc/amd/mach-config.h index 608f1e199775..feb3756d9ac4 100644 --- a/sound/soc/amd/mach-config.h +++ b/sound/soc/amd/mach-config.h @@ -18,7 +18,6 @@ #define ACP_PCI_DEV_ID 0x15E2 extern struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[]; -extern struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[]; struct config_entry { u32 flags; From patchwork Wed Nov 17 09:37:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624213 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 42C35C433F5 for ; Wed, 17 Nov 2021 09:43:59 +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 C037B61425 for ; Wed, 17 Nov 2021 09:43:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C037B61425 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 2F3E7188B; Wed, 17 Nov 2021 10:43:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2F3E7188B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142237; bh=dc6hSE2mynOP9p1gEVAnoHi2YtNzKfD8PlI/atIKshM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=E45e90XAvWE+knp+OAnslriux1UggYENQPeKpc1gMXKzlCHVRyBM0kKGtatf6z69l PZEskX0/FIdOTwKZjZepw0Ati33J9+6+/LZeGJ76r+QTaYvNT2gpngmxScvVcyshL6 DzKSVBBl2iALQiTQeBbyz8gxwAgBfVXPIHKas0EQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 67C53F80571; Wed, 17 Nov 2021 10:38:50 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 01253F80511; Wed, 17 Nov 2021 10:38:37 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2043.outbound.protection.outlook.com [40.107.20.43]) (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 15EBAF804F2 for ; Wed, 17 Nov 2021 10:38:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 15EBAF804F2 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="g/wJomUE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NdHXcVl9FYGmpN8iW6jO0QS4vSnKbE2BAWPMXZYkR9DTCePK7A0VQn5bFhFyBfQSqv8vZQAkPXBbG8cVamIkFvj5m3/gpvj+scxmFA9/0FTVXoX21GWhqJ47Batm/Ve5lCXeG9QI6gQuGSHBH1nwxcPrv+ZbTJXORSrDsbsve7G7SNOE8wHY+ikb/P+TWdtljDxffQuzEhRpOTwKu8Dd6u+YEdmZMawHbN/ovcPMdZ2Wp9MNMTMEXm1ONHTJgrUYKBSY1OSRF18oDROdsLCVW0X14TA8UGBbVaf5O6umEbNkxig4t6REuDBcvqVDEGZDb+VhnLEnxOIw78zSfDlmKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+gwhM+p/Qh9MxUQBcZKdscXRpH21CmBKxMOedlU7EjA=; b=bRbyiZB4zo+iiA2ZOvobCT4YuuQRckQqNhBfDYKKZ6Q/beDppzOFlFtBgP7xXzgrPNOllMqxE4ESB6hEEqHQWMQkXDQP4kCXSgj8MHYSz+UN+zKLpwCTQZpQMgPlA+jrVj8f36OUUGqZE3sbpcEZptbqjfJ0u1BNvOWlCT/MkhjYaoWlttmCbTxv4W22WI76bZjeQw4emcPEbj5HJID6wPa5seeUzhNDVS8kgqK+DAFrHaUfKEkQcfnz9+wOohRJodxYimuHmUA9OWPZycBsB5VN7gqc+33j41CDs52gwM9m7/nmbKwXI5KPoP8wtf0eIw/JQNgmX9FUJiN7xlt1NQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+gwhM+p/Qh9MxUQBcZKdscXRpH21CmBKxMOedlU7EjA=; b=g/wJomUEZvGVvq1KrA4zHF8ROxW53k8M+Jo+ipNQUQENeUA5EEW5/Z6ATnQeUxHK3u+QZXUR531nOlLVLabQr0S27LJrnUNdZMdkWEdNmMkrORfqEUuah3FP1JxJBXnV4ehD5J26yl8ZFH4thkWClrBJDu3E2x/KnaPqSfJ7eH4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB3039.eurprd04.prod.outlook.com (2603:10a6:802:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 17 Nov 2021 09:38:24 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:24 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 11/21] ASoC: SOF: topology: Add support for AMD ACP DAIs Date: Wed, 17 Nov 2021 11:37:24 +0200 Message-Id: <20211117093734.17407-12-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9ca7d98a-2e1b-4779-8d95-08d9a9ae0025 X-MS-TrafficTypeDiagnostic: VI1PR04MB3039: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xaqcBDat9FgOb1agwmUzW8V0TZ4gGmgsPQhIbmrOZD8PdtJUESSSZ0f1af2Eel19cPcI3/Awwr3E9oIJLkMI3XCXUjz931gChD4qN25fzZyLw1U+ZGsP3qYAMdtI5pZPE3vVbIFFsxUzkzlo2whDhh4IO3ex1llKBqO2XElrYkr7sOcYKznEyU/fRXA39xKpc18YAKtyvNouO+H2c1fyLO2DeJYBmLedoV+0h6dZiaps78jY4OSnwjYVWl0JCbW4GFA0wP1GlUwp2Fbd9WBnUKPYg+keWTJUoI0hof8pAB6+Aa4LZ+SoK80+oE+ql4J9eMvGeuyYhW0uz+MFRzinI7BUwdHC/uDeYc4qTVz3UAt/RmL4aOebugP/8C+o8yMIeG3oANxQ7IsPDu80zyA+geyPFnNEo2QQXkgA0QeyBOh8q8/R65V2ImQoM9zeuW8AiBT9LbXUQeRr5DjuVTUaRU2FErgRFJz8VOPdbqjdYR0rDmfC33Md034E+vqvSvge7N6vo/oA3phbe+pz/22mWl8ygBf6CiVfkJy3pIirVjAanBQDEufxSb4XQg5WVNyUCgheCCbBPg3iLe4pLraEpU335NhDiM5r2MakbNNfFmv17cCNEvt33pYLjheGJzRrM6KLC4SFjocnAi1xq9y8yQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(186003)(44832011)(52116002)(6486002)(5660300002)(66556008)(6512007)(6506007)(4326008)(7416002)(2616005)(8936002)(8676002)(1076003)(2906002)(66946007)(83380400001)(508600001)(86362001)(316002)(38100700002)(54906003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DvI8s5bdm3Olj1ByBm0//mbZRntLjj/HYT6GlZF4XcjDdu7duG6+/ameNYuKz/+FGywlWPeZWZRTiRJL/Fiz+sH0coPd/ncBpI9D7XaEQibCTCX7FAHFnUKr6MyeO6l68IiZuJbrM+T5wDF06xTErlT9YbN5xVfPFj+uVNkQrhiFvXZRfKUyIZ0hIszpmEjpMjJr6svJMqULnLdeuKzwsKh0DIwnnRlWDig1cbw8hDZ78TI/BseJPfl1MQbF6uIaRqA8M2O8mBaESQO8Lj2G9Ch2NvzyTP5Oal1Ct+3W76J9KN+/Gb/1Uiwjh4sUmU4W5LzgWEWk7C+z4wgGv7hYkTEBXYlXSljIwvazEt+JI3co6hTHRiLx1JhOwVA0K8Vkups2cUDL9Xc8Uiams2AeKF1j34j2UzP8g38ikMurvJW7Xkbscf84rMaK1z7sxY0gybK629MeU29o2Xxf/SJvqQJX8BnDkMd0GjkjDSRILxmrX9wsg8A5K3t9klJYRcRqAaHwbNe5BidmImEBqWceIrL2QGKuWs/AeUTr3eQCcwSzCgh1GQ/tOZoZoPoEH+9tSn9YS9dN2VGH6l6jT47jPw1XA1+ZkKKpsNdKWM7bFjm0cekdwdCJ1rbwlaNOxLHxfuRg9rpPWhVuR5abccDZfQmBBJ7KUW6Mqbr4+U71BXEIxtD8XIlwlpGsNDhiCuQDcejFmiqcHYb8+qEOdnDb97sTyG57sIIoMuokTzROgxeqCt1nQpP1rhAzKaHTpZ98xn7dO+cgRAaMZmUkT4jRLP5ZPoovfL6SiTd9mzDWi6DERHK/9+bj3JRnxgFhF7g2F4GEVmNnkWIJsIMOc9rKoildt8HgpT8VrVk5EZOjIG690a1RlfiXKgQtT2EMK231L9IY7mHG4UARN0KLISG/on3gPgRXSPXK6/2MTnJQfRNVBo9bP4PIsaVHBYVrVFxJlT7lIW3sj5a2PElp/2AqgGAUm3gZipARsVw4MqFSf0ebt5dcu/L4E7LC7pCE6+oBX2wbC8UiBGgSW1/DOKtcFyr3wTDdmJZqLUEcmH9RBE6WHcqRq+RE39DgXWqyfE/X5WYDMJts1dScTQflSwXPpB4Tyz1SxYLk5JI6GmlE6GGVGKTgmsaNgo0mphrmRYWM1Asx4FGUEq/UIv7b2AlQvZITHRk42G/m7dNLe/1ODJk2ysbh6NJka1Y2WT9lKG67Goyzw3Fj6+dRb3BEb0f7ZZ4kKxtBG6uh2LKSZjpE/blGaaBaIWgkm4nd0THELPL49AYwzB/8+iWgbRzLKXrKBHAzNBNSnOpJPxIGE9wG90jaMWw+yilYYVH5/GNkojtVDqlCl5Tsa9rt/Qr+rNZUsnAXroi81HxT7WlNoVQqVRmPX5fYdRMkUamRJer8SH0kQs5zXlr+NJoR9+wSjT2wwposR94z5OlCa2Uc8qv7MVDDnXzDT92U1Pl2uGGFMi89NEgrWJ2c0YlUGywrl6gpAc6zfnBn2NDWRItoitcq+E7Q6VmbZnRDFfHH/5UB7B0HpgekLmNOmvrGUtR47ur7glViYsfNhjs8wGUNM2YtmEjJmYLWr2dhZIrJXQTVe0CUuFyrv6jEsrWXgj4S9rK1nxpB7dRTLD2D7RgVOJgN0TyovsqLHkBQSZv6Buf66azQD/As29+Z9V+PXa62A1hmYkw3vLdO5+eItwMXEPgcBUOqRTzgkrmj/Fudz6mG8KNL X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ca7d98a-2e1b-4779-8d95-08d9a9ae0025 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:24.3579 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sTidUK08MVGs0n22NVaTM/ri6q0H8M80/d+iTAmgpAVtW5J6uIRT4D/TC7R7rM5RMILFqliF4zT9J2fn3djt/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3039 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ajit Kumar Pandey Add new sof dais and config to pass topology file configuration to SOF firmware running on ACP's DSP core. ACP firmware support I2S_BT, I2S_SP and DMIC controller hence add three new dais to the list of supported sof_dais Signed-off-by: Ajit Kumar Pandey Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- include/sound/sof/dai-amd.h | 21 +++++++ include/sound/sof/dai.h | 7 +++ sound/soc/sof/pcm.c | 36 ++++++++++++ sound/soc/sof/topology.c | 109 ++++++++++++++++++++++++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 include/sound/sof/dai-amd.h diff --git a/include/sound/sof/dai-amd.h b/include/sound/sof/dai-amd.h new file mode 100644 index 000000000000..90d09dbdd709 --- /dev/null +++ b/include/sound/sof/dai-amd.h @@ -0,0 +1,21 @@ +/* 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. + */ + +#ifndef __INCLUDE_SOUND_SOF_DAI_AMD_H__ +#define __INCLUDE_SOUND_SOF_DAI_AMD_H__ + +#include + +/* ACP Configuration Request - SOF_IPC_DAI_AMD_CONFIG */ +struct sof_ipc_dai_acp_params { + struct sof_ipc_hdr hdr; + + uint32_t fsync_rate; /* FSYNC frequency in Hz */ + uint32_t tdm_slots; +} __packed; +#endif diff --git a/include/sound/sof/dai.h b/include/sound/sof/dai.h index 9625f47557b8..3782127a7095 100644 --- a/include/sound/sof/dai.h +++ b/include/sound/sof/dai.h @@ -12,6 +12,7 @@ #include #include #include +#include /* * DAI Configuration. @@ -66,6 +67,9 @@ enum sof_ipc_dai_type { SOF_DAI_INTEL_ALH, /**< Intel ALH */ SOF_DAI_IMX_SAI, /**< i.MX SAI */ SOF_DAI_IMX_ESAI, /**< i.MX ESAI */ + SOF_DAI_AMD_BT, /**< AMD ACP BT*/ + SOF_DAI_AMD_SP, /**< AMD ACP SP */ + SOF_DAI_AMD_DMIC, /**< AMD ACP DMIC */ }; /* general purpose DAI configuration */ @@ -90,6 +94,9 @@ struct sof_ipc_dai_config { struct sof_ipc_dai_alh_params alh; struct sof_ipc_dai_esai_params esai; struct sof_ipc_dai_sai_params sai; + struct sof_ipc_dai_acp_params acpbt; + struct sof_ipc_dai_acp_params acpsp; + struct sof_ipc_dai_acp_params acpdmic; }; } __packed; diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index fa0bfcd2474e..8d313c9862cb 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -826,6 +826,42 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa "channels_min: %d channels_max: %d\n", channels->min, channels->max); break; + case SOF_DAI_AMD_BT: + rate->min = dai->dai_config->acpbt.fsync_rate; + rate->max = dai->dai_config->acpbt.fsync_rate; + channels->min = dai->dai_config->acpbt.tdm_slots; + channels->max = dai->dai_config->acpbt.tdm_slots; + + dev_dbg(component->dev, + "AMD_BT rate_min: %d rate_max: %d\n", rate->min, rate->max); + dev_dbg(component->dev, + "AMD_BT channels_min: %d channels_max: %d\n", + channels->min, channels->max); + break; + case SOF_DAI_AMD_SP: + rate->min = dai->dai_config->acpsp.fsync_rate; + rate->max = dai->dai_config->acpsp.fsync_rate; + channels->min = dai->dai_config->acpsp.tdm_slots; + channels->max = dai->dai_config->acpsp.tdm_slots; + + dev_dbg(component->dev, + "AMD_SP rate_min: %d rate_max: %d\n", rate->min, rate->max); + dev_dbg(component->dev, + "AMD_SP channels_min: %d channels_max: %d\n", + channels->min, channels->max); + break; + case SOF_DAI_AMD_DMIC: + rate->min = dai->dai_config->acpdmic.fsync_rate; + rate->max = dai->dai_config->acpdmic.fsync_rate; + channels->min = dai->dai_config->acpdmic.tdm_slots; + channels->max = dai->dai_config->acpdmic.tdm_slots; + + dev_dbg(component->dev, + "AMD_DMIC rate_min: %d rate_max: %d\n", rate->min, rate->max); + dev_dbg(component->dev, + "AMD_DMIC channels_min: %d channels_max: %d\n", + channels->min, channels->max); + break; default: dev_err(component->dev, "error: invalid DAI type %d\n", dai->dai_config->type); diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index bb9e62bbe5db..72e671c15a34 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -376,6 +376,9 @@ static const struct sof_dai_types sof_dais[] = { {"ALH", SOF_DAI_INTEL_ALH}, {"SAI", SOF_DAI_IMX_SAI}, {"ESAI", SOF_DAI_IMX_ESAI}, + {"ACP", SOF_DAI_AMD_BT}, + {"ACPSP", SOF_DAI_AMD_SP}, + {"ACPDMIC", SOF_DAI_AMD_DMIC}, }; static enum sof_ipc_dai_type find_dai(const char *name) @@ -2992,6 +2995,102 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index, return ret; } +static int sof_link_acp_dmic_load(struct snd_soc_component *scomp, int index, + struct snd_soc_dai_link *link, + struct snd_soc_tplg_link_config *cfg, + struct snd_soc_tplg_hw_config *hw_config, + struct sof_ipc_dai_config *config) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + u32 size = sizeof(*config); + int ret; + + /* handle master/slave and inverted clocks */ + sof_dai_set_format(hw_config, config); + + /* init IPC */ + memset(&config->acpdmic, 0, sizeof(struct sof_ipc_dai_acp_params)); + config->hdr.size = size; + + config->acpdmic.fsync_rate = le32_to_cpu(hw_config->fsync_rate); + config->acpdmic.tdm_slots = le32_to_cpu(hw_config->tdm_slots); + + dev_info(scomp->dev, "ACP_DMIC config ACP%d channel %d rate %d\n", + config->dai_index, config->acpdmic.tdm_slots, + config->acpdmic.fsync_rate); + + /* set config for all DAI's with name matching the link name */ + ret = sof_set_dai_config(sdev, size, link, config); + if (ret < 0) + dev_err(scomp->dev, "ACP_DMIC failed to save DAI config for ACP%d\n", + config->dai_index); + return ret; +} + +static int sof_link_acp_bt_load(struct snd_soc_component *scomp, int index, + struct snd_soc_dai_link *link, + struct snd_soc_tplg_link_config *cfg, + struct snd_soc_tplg_hw_config *hw_config, + struct sof_ipc_dai_config *config) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + u32 size = sizeof(*config); + int ret; + + /* handle master/slave and inverted clocks */ + sof_dai_set_format(hw_config, config); + + /* init IPC */ + memset(&config->acpbt, 0, sizeof(struct sof_ipc_dai_acp_params)); + config->hdr.size = size; + + config->acpbt.fsync_rate = le32_to_cpu(hw_config->fsync_rate); + config->acpbt.tdm_slots = le32_to_cpu(hw_config->tdm_slots); + + dev_info(scomp->dev, "ACP_BT config ACP%d channel %d rate %d\n", + config->dai_index, config->acpbt.tdm_slots, + config->acpbt.fsync_rate); + + /* set config for all DAI's with name matching the link name */ + ret = sof_set_dai_config(sdev, size, link, config); + if (ret < 0) + dev_err(scomp->dev, "ACP_BT failed to save DAI config for ACP%d\n", + config->dai_index); + return ret; +} + +static int sof_link_acp_sp_load(struct snd_soc_component *scomp, int index, + struct snd_soc_dai_link *link, + struct snd_soc_tplg_link_config *cfg, + struct snd_soc_tplg_hw_config *hw_config, + struct sof_ipc_dai_config *config) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + u32 size = sizeof(*config); + int ret; + + /* handle master/slave and inverted clocks */ + sof_dai_set_format(hw_config, config); + + /* init IPC */ + memset(&config->acpsp, 0, sizeof(struct sof_ipc_dai_acp_params)); + config->hdr.size = size; + + config->acpsp.fsync_rate = le32_to_cpu(hw_config->fsync_rate); + config->acpsp.tdm_slots = le32_to_cpu(hw_config->tdm_slots); + + dev_info(scomp->dev, "ACP_SP config ACP%d channel %d rate %d\n", + config->dai_index, config->acpsp.tdm_slots, + config->acpsp.fsync_rate); + + /* set config for all DAI's with name matching the link name */ + ret = sof_set_dai_config(sdev, size, link, config); + if (ret < 0) + dev_err(scomp->dev, "ACP_SP failed to save DAI config for ACP%d\n", + config->dai_index); + return ret; +} + static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, struct snd_soc_dai_link *link, struct snd_soc_tplg_link_config *cfg, @@ -3277,6 +3376,16 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, case SOF_DAI_IMX_ESAI: ret = sof_link_esai_load(scomp, index, link, cfg, hw_config + curr_conf, config); break; + case SOF_DAI_AMD_BT: + ret = sof_link_acp_bt_load(scomp, index, link, cfg, hw_config + curr_conf, config); + break; + case SOF_DAI_AMD_SP: + ret = sof_link_acp_sp_load(scomp, index, link, cfg, hw_config + curr_conf, config); + break; + case SOF_DAI_AMD_DMIC: + ret = sof_link_acp_dmic_load(scomp, index, link, cfg, hw_config + curr_conf, + config); + break; default: dev_err(scomp->dev, "error: invalid DAI type %d\n", common_config.type); ret = -EINVAL; From patchwork Wed Nov 17 09:37:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624215 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 93395C433EF for ; Wed, 17 Nov 2021 09:44:17 +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 08F2461AED for ; Wed, 17 Nov 2021 09:44:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 08F2461AED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 6C144188F; Wed, 17 Nov 2021 10:43:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6C144188F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142255; bh=pTH6kEQv/zj/K25KnXPTaWAkYJTbdWhj0MQBn3fefAQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EPymo+hd0SEggavhauExVUOEr3WqnYxGI0f6GmviIXO7ohbJU/lDZu3xWDAki8NIC KdbT/Bs0Wd1JLVWVDo9eN66W31za9+UNSuzupUBPNj0aa3iS/hDwAeIoGZ2bbUkaZG ke1xGcvLmPjpyLudpxquXBp3eWxkyghMkfe3eafU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 20345F8057B; Wed, 17 Nov 2021 10:38:51 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5418EF80510; Wed, 17 Nov 2021 10:38:38 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2043.outbound.protection.outlook.com [40.107.20.43]) (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 630B1F804FD for ; Wed, 17 Nov 2021 10:38:31 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 630B1F804FD Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="e8k2RDPf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NtRx2u+5hYvhSZN9lYOaACVsNvbk3pclM6nEumAs5D20cqwgPx0jvAlpLW+oCkCKBwGRsYaBr7mGNB+N29+EBu/6GgFj3eeBVr46bGWVjWFjJZAKFOo3ipvG+qcyqjEvV/StCZPVODNlhipnKQxhLYJfYMUjAYyRjRHW1ZJJcNTFWhcrrzDrJvrMSgeVRJCyvV83BSVV4YweoU5gBwRyODp/o/b9sFuGBXJQDd1DwhBK6FhR0KmR9mDNjlONAve1LVT2FvNnDZ0YMIs2UBANxaVZpEB10vWVYPnZPUVG2/lKSL3KHGbyQGSpvXH5cx7+cyHSc2Pr8quheBvnufK/Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pHAp1DonNFQ+6pj6RVm34ZXbTZzInspElsG00tBCovs=; b=UhhZYfXH6oiNEyOQ9YgkZhqBJMQrlN5AupahLXBgzfaEtTEQa5R2g1ZdXC4+5Hvd89Su59dJ3HIKncznbj/+Ynp4QYDotwjIopYKf3TeHEPWnnYHqOajlCdF99yH/BFVoGmUVpHNCOpHEBwBm3CeP3IS4FzPVRcZmYNVKZoLR6O8JITKa+j8C5Ap0z5TH77JNA/0YTnIjO8H3r4ztU+vSBbJzhGWkazsZeSSmAjhvFGUMX4jLcKIXJM1z0AqEPSaCWjcqZgJJARSjyLiYKfVGH0GjKO+Wip4iXO+oJcCIsgrlqzQvK4z0dKK6AHVDAfs0f0o1yaQlZljwTXVWEZgdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pHAp1DonNFQ+6pj6RVm34ZXbTZzInspElsG00tBCovs=; b=e8k2RDPfMYmABL5Sb0uxDtXEPz2N7ckAgGa+w3k5pwXoEudXcoiKFr4awQ6fLrnUvwksm9SBYVg1eJ88yDQxlMZLN3nhl2VLow4F7cEpJB8HRyhTZDZWhd3+9qjCW3/0AuWIChBII8fKZ/99AooBbO9oRj+i2BvpJa6p3b/gqnM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB3039.eurprd04.prod.outlook.com (2603:10a6:802:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 17 Nov 2021 09:38:26 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:26 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 12/21] ASoC: SOF: amd: Add trace logger support Date: Wed, 17 Nov 2021 11:37:25 +0200 Message-Id: <20211117093734.17407-13-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55a82735-97e9-4dfd-7b4d-08d9a9ae012a X-MS-TrafficTypeDiagnostic: VI1PR04MB3039: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 20B9q8AqbLp+wZ3o0xvZQ8oIPzMVn9En2hvYMycjyS9Lb/LO5b1HDYRvo153RatcrChs4wF/FfERq8206HtlHUKpfhbXiU5AjgMDb1AZE8/f5L7kEcE/akj29z7aV/7Oh5h7YJBi6WblN2CURoL/niglyXsZNla8E1mDX3tXGdWjlfhYkmSz5J0ANcvysWBW//iUrduBz5mSn/CGrDFEPbTcDEax2p1r14/9KYYEUQlEEYrPf8eRUn/r1/PB3/OeJ25GWu2uv/MxD/2aVKN/MVZPZGU53DT4WLj6/ibzYHsKQpAxo7JBAQI+CMgdfQ77fvdTMkYR3KHmzVCRGIrJ6i31oyx9P4DP1FgBSAoe4r2j+se6xTtHCHrybOnw1epKrKAGREVuywpuT8vIbLFf4pvmhz35+FqtwbBy0ffpWYJj55Vr3moMBWH4O9uYXVaMPFxNN7phLDzgCEqcsLDAkIR02ABPUHabPVMiK7LSGvffLmDwWGlnxmJMurTBFElZK6s5OSknvMm6nVWE5HX6p25huU8LGTVrBPMIy0Gvsy4FaYA0QJRkHhIe2/cMLjy1LyUN93WqhgtxPr4aCdhcPtNt/oAybOkV2UUlc106fadngPIeTpq80Yr+KCfMjoDanccNRotSvSSJL93oTa2s1w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(186003)(44832011)(52116002)(6486002)(5660300002)(66556008)(6512007)(6506007)(4326008)(7416002)(2616005)(8936002)(8676002)(1076003)(2906002)(66946007)(83380400001)(508600001)(86362001)(316002)(38100700002)(54906003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HBKmozfm8Qf5MTdz0tGcN50XKr3opQvIBoGgaiG5I8WuVhezqEU/RoDqd0v+kiQ2C6oXCgDsJCeXdZKperhSZnOA4KWEbJh/JqH1+PBzBiOEmqLCPt9Kkincre5eZLMtjLYPSo8pL0ccxU6uSQBJDDuOigfBl9PLVg/e20+jKuLY7FAcYby0p0upYp8z/YmFq/kgJbYLOeWqk5Y/NNvNZJAEVbfapRNSOtRqrGb39CQ8u/okB7FUVGtsbszQ8g1rXwHFsBko9Ck6lpAHVZlBZOH6xgIC+Gqak8jyEJdUcxAeuJSDfYluhtzIdYAcwSjJVkHW6hp5kqHLZZAhYB94S6AVjzz/RQWY8ruJTYWe7+t9r4rk1n/DIiwmza93QeYvKGAzC5oc8xqpZiJBIPXUVuIkRnY1AIa7KZGI0+BdQEaE47mRj0EUHkixoPtlaaNGgU2ocZYDtH/D6pfkiFudWJh+tqWZLIUYAgG0BakCzTfxXVWrue3xnby5gG4hB0mgfCFSKy6+55ejO4J7L6rsYgMn+D6CCtnlx6X2TnBT3hqnYoBuYH3MSqowtMUld9XEnh1L70BGlspTYouOwvA8gf2vS7dZEWkXng1SJ88z6fXlrFm0yMKEnBE40D1Wc6iLekHJhT36myStmGmIQj3/BS2a7iAC9CRqNMJtI2dw4iy1POppVhmiWwPt79wP9jXHIzefgtGZSDCimWBnyzeyP8n2BIIpVfHwUKzW/I6fLtmuLdvUnQS7+cUdG7zpZWQrm2QM5iTrnFkgKU5u4m8S2a5+I72Xbwsl7vGO16OZ8Rl4590ThZ7umcZNCuIRzYWWWgGioDEZhjnw+x7hAsJVseL+HE6lREQhAVipDRcyX1oQbSrcE+aIHwI0KE/P3Tf4Df31rAYr8Tmr4b4QPKyAfUjk+rCZCsTjcoJNeUxIo+WwnR67/9bAIFxLqBWdB2IiYFmi6r8tzQPmg7MOhZoUeyDKCvF18qdAQDw8OkhEPgBcSktfdYcWqTZbifARSkLLFub762jiFyFIHNlvS2fcZsvTrFDgV8wDQITNafuK1DRBUy6JfwAybg8pye4J8bnInxWjcFixMkcXOgEH9IGwiPViWm9DdxBHON/jrFujNOHKqtPG2dzZzAV60Bm2Igvdwv7jN5+DbEfG5i1AJF4/0SFV+/ueZu3roX3sdhIxQ/q1kMu5ol2xnG/RnlVN1yT1m6bHrRhM17sz9tXYAUb5/jY0AykrXlq9vXm312Fef1ZUpIA7yxwZ1fG+CpBATEIwIW+QTZdy1w7d94D6aG53wNijpSPe8diw+hCl7kDn+AOWYSxr1wWpYmh+i9WJ9xjrcH/iAjZ1PkQhDwZzrSqa4p1jNhuDDA4iexsVm/e0JD1CCrXytkr+1FjzpJ0oEbBdu/XQRbDGy9UTwA7Kn98RgA/1j5mIjp6KSEb+LxhjxtkIKyCgu+DsG0dkoFMUbdDqH7vscGRQa1gS7MSqrh/aO7ieeNhst89PY6qktJbiN4Dt2aZmvtnBh+eTFyCAS+dowYNMZx9hzJ4Fy8a16m+ktdWp/M0WcjDphJMYvz7xI6/6FMcTXcaeTi1PpnE4eQzHljPnjzbyufFbMrJb4YZrDN6cor29ez6Ok79VCCRf7ar9om/mpvkQgrnSnCc0WagIQAsl3v1ZXfIV8lODdSjAA958kz0MPCCDPDLS2UQUk0QOTEDuQPMmaTrTdkedJjX8 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55a82735-97e9-4dfd-7b4d-08d9a9ae012a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:25.9900 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UOU0ycEpY6MbAZCp/JEFYyVYvVQkkLJSiKmyFEGPeYd13MI4OCZmce9eR2GAtFxtNdWYrM98BwDzE/oyAHF3wA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3039 Cc: daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.com, Bard Liao X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: V sujith kumar Reddy Add trace support and configure trace stream for ACP firmware. Signed-off-by: Vishnuvardhanrao Ravuapati Signed-off-by: V sujith kumar Reddy Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Signed-off-by: Daniel Baluta --- sound/soc/sof/amd/Makefile | 2 +- sound/soc/sof/amd/acp-trace.c | 84 +++++++++++++++++++++++++++++++++++ sound/soc/sof/amd/acp.h | 5 +++ sound/soc/sof/amd/renoir.c | 4 ++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 sound/soc/sof/amd/acp-trace.c diff --git a/sound/soc/sof/amd/Makefile b/sound/soc/sof/amd/Makefile index b27ce50014b8..7b9f1a0af3c8 100644 --- a/sound/soc/sof/amd/Makefile +++ b/sound/soc/sof/amd/Makefile @@ -4,7 +4,7 @@ # # Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. -snd-sof-amd-acp-objs := acp.o acp-loader.o acp-ipc.o acp-pcm.o acp-stream.o +snd-sof-amd-acp-objs := acp.o acp-loader.o acp-ipc.o acp-pcm.o acp-stream.o acp-trace.o snd-sof-amd-renoir-objs := pci-rn.o renoir.o obj-$(CONFIG_SND_SOC_SOF_AMD_COMMON) += snd-sof-amd-acp.o diff --git a/sound/soc/sof/amd/acp-trace.c b/sound/soc/sof/amd/acp-trace.c new file mode 100644 index 000000000000..fa4da8947186 --- /dev/null +++ b/sound/soc/sof/amd/acp-trace.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// This file is provided under a dual BSD/GPLv2 license. When using or +// redistributing this file, you may do so under either license. +// +// Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// +// Authors: Vishnuvardhanrao Ravuapati +// V Sujith Kumar Reddy + +/*This file support Host TRACE Logger driver callback for SOF FW */ + +#include "acp.h" + +#define ACP_LOGGER_STREAM 8 +#define NUM_PAGES 16 + +int acp_sof_trace_release(struct snd_sof_dev *sdev) +{ + struct acp_dsp_stream *stream; + struct acp_dev_data *adata; + int ret; + + adata = sdev->pdata->hw_pdata; + stream = adata->dtrace_stream; + ret = acp_dsp_stream_put(sdev, stream); + if (ret < 0) { + dev_err(sdev->dev, "Failed to release trace stream\n"); + return ret; + } + + adata->dtrace_stream = NULL; + return 0; +} +EXPORT_SYMBOL_NS(acp_sof_trace_release, SND_SOC_SOF_AMD_COMMON); + +static int acp_sof_trace_prepare(struct snd_sof_dev *sdev, + struct sof_ipc_dma_trace_params_ext *params) +{ + struct acp_dsp_stream *stream; + struct acp_dev_data *adata; + int ret; + + adata = sdev->pdata->hw_pdata; + stream = adata->dtrace_stream; + stream->dmab = &sdev->dmatb; + stream->num_pages = NUM_PAGES; + + ret = acp_dsp_stream_config(sdev, stream); + if (ret < 0) { + dev_err(sdev->dev, "Failed to configure trace stream\n"); + return ret; + } + + params->buffer.phy_addr = stream->reg_offset; + params->stream_tag = stream->stream_tag; + + return 0; +} + +int acp_sof_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag) +{ + struct sof_ipc_dma_trace_params_ext *params; + struct acp_dsp_stream *stream; + struct acp_dev_data *adata; + int ret; + + adata = sdev->pdata->hw_pdata; + stream = acp_dsp_stream_get(sdev, ACP_LOGGER_STREAM); + if (!stream) + return -ENODEV; + + adata->dtrace_stream = stream; + params = container_of(stream_tag, struct sof_ipc_dma_trace_params_ext, stream_tag); + ret = acp_sof_trace_prepare(sdev, params); + if (ret < 0) { + acp_dsp_stream_put(sdev, stream); + return ret; + } + + *stream_tag = stream->stream_tag; + return 0; +} +EXPORT_SYMBOL_NS(acp_sof_trace_init, SND_SOC_SOF_AMD_COMMON); diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index 5f6e9eff116a..fd923f72a01a 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -139,6 +139,7 @@ struct acp_dev_data { u8 *data_buf; struct dma_descriptor dscr_info[ACP_MAX_DESC]; struct acp_dsp_stream stream_buf[ACP_MAX_STREAM]; + struct acp_dsp_stream *dtrace_stream; }; void memcpy_to_scratch(struct snd_sof_dev *sdev, u32 offset, unsigned int *src, size_t bytes); @@ -197,4 +198,8 @@ extern const struct snd_sof_dsp_ops sof_renoir_ops; /* Machine configuration */ int snd_amd_acp_find_config(struct pci_dev *pci); + +/* Trace */ +int acp_sof_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag); +int acp_sof_trace_release(struct snd_sof_dev *sdev); #endif diff --git a/sound/soc/sof/amd/renoir.c b/sound/soc/sof/amd/renoir.c index 3cd269bfe75d..43037109e130 100644 --- a/sound/soc/sof/amd/renoir.c +++ b/sound/soc/sof/amd/renoir.c @@ -173,6 +173,10 @@ const struct snd_sof_dsp_ops sof_renoir_ops = { .machine_select = amd_sof_machine_select, .machine_register = sof_machine_register, .machine_unregister = sof_machine_unregister, + + /* Trace Logger */ + .trace_init = acp_sof_trace_init, + .trace_release = acp_sof_trace_release, }; EXPORT_SYMBOL(sof_renoir_ops); From patchwork Wed Nov 17 09:37:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624211 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 93D66C433EF for ; Wed, 17 Nov 2021 09:43: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 15B0E61357 for ; Wed, 17 Nov 2021 09:43:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 15B0E61357 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 865C4188A; Wed, 17 Nov 2021 10:42:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 865C4188A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142223; bh=PEjLoj2ClAVXXFWnutwtNLa1Er0sO7E8nw4uMz+IvLw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=pcxvfnQcCRb5vbTLK8M5mGGzcOuCSxfFWT26i4YbrVdPrrinxpy/+/qjVs+vnIecO LFGQScOVFp7GDDVQLyt0yuTU7SJ5gQeJ0tzrmmQFY9TTqOKsJKWALKyG+xHeLXwBAi 0XIwGcfV1OI/7bhNyqEnf+QVbedOEwPrOxBwm5A4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5083FF80566; Wed, 17 Nov 2021 10:38:49 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 76538F80515; Wed, 17 Nov 2021 10:38:37 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80073.outbound.protection.outlook.com [40.107.8.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 C627BF80506 for ; Wed, 17 Nov 2021 10:38:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C627BF80506 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="IHtNgfzT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dedfFeg5LVfA4fxqKHa2bSeDj+RO51mfUJzF/S5qZgjLbBJtVY1Z4GeiyrshIw0PWHaX7HB5v6y0de/NL0UdQQXYXCKuT9hM/xAsG64w82CyQB7m6uSHslNzesM81Y1Dz45wHtVCyUgKMj4zlUvgSosc0+yiKwg7RS5DF23fYAOeVUOtSSq5vd88Oxt4waUhwNNRJ6RVEWgUVvSs78InrhkHDnXLtoaBS4X94bwSsj3t3AjC4GafDYRxSPMuIezwxI5Ro94S9buFAhFeSS5i6xoYr2xN4mKSvemIjOdTd71d+AfjNm2+yt9wu/kzrv6vhwN/mMtjEA9BlY7NICC0oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rdtHZDIv5NASSCwbbXRs5IgvOG61UBHZDcX4eipvbRI=; b=KoiGVcZSwElI3L7VVGlzALHvCfSajklzchkVDHZjFZ+41fFefcSnkpIXTfb9kFxmGlUdFJhVe87NzpXWMRBSazjohwVZ3pzVZg4cW8Zlc1HekUM9ZZibHRRo2RdF1I/nr5sodu9atTk3pFU8OaRB3edHulb1S3peqrVSQXPWs0cGafcLK1LJgjNSD4Jq6F8YsY1AEB46R+sDqTJqdteudNDSNxbGav4IuW1Tyt5peB4rMKmigmCGsqD098bvHEssnBM7NEy2Yl5HS1X+dgPWqtnsZPtPVp6mL2mX9DFurS66s6JwNRkH8IuSFftj38fiiAyjf2P8KKEX3cLof3Ph/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rdtHZDIv5NASSCwbbXRs5IgvOG61UBHZDcX4eipvbRI=; b=IHtNgfzToBGio2KUE21Z9AGyM1NeItqlaGcOTUK5Q9YwS5gj1DMDOCccCbO8zhGvtIm+9/lExxk+tFGurx6tzucBlQSygWyQ86Vcabj4GPdZtQ5FPpJ7mgxUW2d9oDpC8x4gM+SayRW1vX9/jcwxAjyqOakEJKyPTGIFUiSA9Cg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VE1PR04MB6623.eurprd04.prod.outlook.com (2603:10a6:803:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Wed, 17 Nov 2021 09:38:28 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:27 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 13/21] ASoC: SOF: amd: Add support for SOF firmware authentication Date: Wed, 17 Nov 2021 11:37:26 +0200 Message-Id: <20211117093734.17407-14-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 019c06fe-ee48-4f0c-fc46-08d9a9ae0233 X-MS-TrafficTypeDiagnostic: VE1PR04MB6623: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cb6EmpcMBgfA9DQ/8OOWpq4vZBD7x1Uce7AN4HkQQNf9+xisZBXkKFftc/HJSJcb3ZdPQ4qPDa9ChX9a0DClEHGMTI4PZFf3W1WWg2Ug3nRtYH4B0Te6Cf36c1QKQbzp6uiGsFjZ2iZLFq60npfdHlVPzI63VfiizHWnDL1VZKxM8Lwx5+dpACRuIMgF1DT5DtLFdBy3DORTtA0vhHg5ZjlJMGIxkmFc5a0+spkIgfp9htiDi/RKawC0gmSJXLOGbZJK8nRYkXwt71f+tSMK7Qh598dRJIfS0piwEEUq8C7DPxyWQeFSxXLeYjrs3ja3EKJsjC8E5ccBj405X8Y2f9cclsZYYFsCYpgbj7NQokbwD+vB+ZQf2rTkiyAZEbmqaXQgMOZ8AkicF29k601uKE3Wtf/TLbAvJYDzFqDCyaQRVpGi924gyvgjW5P3AHcGY0FuQ5BtA5cIH1vjCs5yPhe3uvj4m4rRNs7oX7T7Yta/ezWg4MeO8pWG+OVTX9S1g0S7Xg4r4UHdAPR1OgVoDyDgIb8kX3aTa3uCs6/IDU7M9Y6rip/M/ClLdMiEfT1CjXezdld8gNP+EtXUHw3wDqG2gNEF07RX9LZREcEVuFdVCUJKev29fO66Ap7zFJaHn0ZoXr5c6oobzNGgphFi5w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(1076003)(52116002)(6506007)(5660300002)(54906003)(8676002)(508600001)(186003)(86362001)(2616005)(6512007)(7416002)(83380400001)(44832011)(66556008)(66476007)(4326008)(66946007)(316002)(38100700002)(6486002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1xNlSoOCSHxXtiqracHEaFqUtxPToYrnxFxfhMaKKJvmB/S+yaP31ZaVLOdKIiRYMyfDJtpLnLJ/aZqbQDgpPTi8pOXqE5Gpoi6OVQYtzWBUNs5wccNXAhDlMWQCG8dmqHfi2k8bqa6aQ/DV0HrUIOJIHVhZel6aksjKxy9FAwy1QvTgI6I6/4GXMD/rijR2xqXLfsQ1TVwA6ag5dpIJ/LAjrOnhGbycO1srmqzyX8f9m+3kWc2sQRkMtWyxg0Y3+5+CfV+aPZqivhW5FeipEafnBofLNxau7tt1IHi0nG0bp6dCOp92jmcIyRhiCq/LUK2Za5M2a98zHHKN/Ow17Sw4xNCTYBv/ti58oKBTqPXnUp/YgwZb+fPvv8PyIN1bt2cKxFQkqqr5GNA9rWrIaIGljk7WsqCeej7mA+TLhLYI8Mbc1h0smONLYiIqqrd2CXK2X7kwGoPJTt4eC614XybYh+RK6AKpgwdfI/qkGbGwtCr4occY0tRYJMV8wKtlh3UavdxX/riQ7CyCahjDeIeHMvCHAI+PPLqYa5sHEc8Nd8WISBdAh6pO+9+wohbrWMbWNoSnXpWMnxPSLrUYaqnO0mYDW00wOxf7NhSA9IviyYT9MC0FsTkL26us8JEWnxkbfiaEIoYMpvvIVdO5inTXS6bc0fZ5FwOyj4C5gVoZRKNYQ5UboWtQNZG6atAval8QUZ+bpytsJ0t3qhnCRgKJrXLQVyaXsPjlCx0Jf74y+cVEW9j3KaeywZOZtFMIyo8vURcFMZPtHZHzsGsuHClEgGJJJqHapNhDTHH7oahZs1GDBjUCjOfnYyZd6KP/I0/3Ozy6B44R2mwcwhaSnStCGbpCl2TXpLNXkfO4kWQXylcYlFkLjk/urV9DWvG0JAcGYwU3+G/1yYW6WJQAYOYrHmC8lfKZ1PPUvspmOaXMk/PiDlbzysmaSzUPNNCboJf92Uq/4JTIaAffIaagreNKzrCKhAnx3R/t+/54VV3Y18vtYzf2lZXXCAqv8CS4my+KQHofq87ScYV6W2b2avIgbblX67MTXk/FU5aN3Wu4RAW8Q7IBYMaPiYCW5hSYxXnetCrq24631arHUgIFh42hSVaFFOnrFWVV/+fIJzLkpUhFC6ahUnv7iSSWRPcU1X0RJHsd6cjIts563z/9l1o5E6npVZZ0FfQevmssp6UaJnKb6fZERXwMS5ZcYsMUZYG/Yukh4Ou2Lm9SoXAmEEiZtL/z3D0LKRH/alSbEGvTJdf+F7naOtuvTHmH8KX+zv/b4B8OhaPx2U2fR0BXUapDICfevoUOaJNeayxrvUGBHXBqm+jj61D9LAKV1uVrspwULMXHovRMKS06PDo4Pv1zwpUhg3IiS5DJfudMKCML1W4T9QX+6P6H7VJAayqrCqvPDw0o1jPyMlWVSLsq0abWaP30xH0AaKYq9cmzjhx6rg88WM2Up1iKIcxR431GEF7q31noojBrCB3F7cmOQzMfFTUhjzoxKIpsbS2j1DI3c1rpyrx3tionGfMyqu0YDJ6cG/XquvLg6AUsmvEjZDpZFHn7Ljh5eVMTmjQVXxV9e8J83B9hFRvDYLaHP5N9W/tjbYkfyG/+pbhStMHg8DEJh3kgU583uVY+03c8uLbLaZbrxaNwuzaXA/id/rU4/Eixq0ugpubWNCXtqWG3WstAdyQOPmWFsFtkEmb1xTXwgK7XOOhUoQLhFQxfkeYE X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 019c06fe-ee48-4f0c-fc46-08d9a9ae0233 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:27.8679 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: u3gzlR7eqxefjJkFPd6FRs13ykwBkSRJpqJ5S6HaDzF0RhOKKn0wG50clvg49kKJEbyLXhPHXRK3T1C9PgzKtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6623 Cc: daniel.baluta@gmail.com, AjitKumar.Pandey@amd.com, Curtis Malainey , linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Ranjani Sridharan , Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.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" From: Ajit Kumar Pandey Add callback to notify PSP after loading firmware on DSP. PSP will validate the loaded firmware and set qualifier bit to run firmware on secured AMD systems. Signed-off-by: Julian Schroeder Signed-off-by: Ajit Kumar Pandey Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Curtis Malainey Signed-off-by: Daniel Baluta Reviewed-by: Curtis Malainey --- sound/soc/sof/amd/acp-dsp-offset.h | 4 ++ sound/soc/sof/amd/acp.c | 66 +++++++++++++++++++++++++++++- sound/soc/sof/amd/acp.h | 21 ++++++++++ sound/soc/sof/amd/pci-rn.c | 5 +++ 4 files changed, 95 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/amd/acp-dsp-offset.h b/sound/soc/sof/amd/acp-dsp-offset.h index 1d11e9d69dce..63f13c111b24 100644 --- a/sound/soc/sof/amd/acp-dsp-offset.h +++ b/sound/soc/sof/amd/acp-dsp-offset.h @@ -54,6 +54,9 @@ #define ACP_PGFSM_STATUS 0x1420 /* Registers from ACP_INTR block */ +#define ACP_EXTERNAL_INTR_ENB 0x1800 +#define ACP_EXTERNAL_INTR_CNTL 0x1804 +#define ACP_EXTERNAL_INTR_STAT 0x1808 #define ACP_DSP_SW_INTR_CNTL 0x1814 #define ACP_DSP_SW_INTR_STAT 0x1818 #define ACP_SW_INTR_TRIG 0x181C @@ -68,6 +71,7 @@ #define ACP_SHA_DMA_CMD_STS 0x1CC0 #define ACP_SHA_DMA_ERR_STATUS 0x1CC4 #define ACP_SHA_TRANSFER_BYTE_CNT 0x1CC8 +#define ACP_SHA_PSP_ACK 0x1C74 #define ACP_SCRATCH_REG_0 0x10000 diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c index 74ede28aa8d8..4c5550e8d364 100644 --- a/sound/soc/sof/amd/acp.c +++ b/sound/soc/sof/amd/acp.c @@ -20,6 +20,22 @@ #include "acp.h" #include "acp-dsp-offset.h" +static int smn_write(struct pci_dev *dev, u32 smn_addr, u32 data) +{ + pci_write_config_dword(dev, 0x60, smn_addr); + pci_write_config_dword(dev, 0x64, data); + + return 0; +} + +static int smn_read(struct pci_dev *dev, u32 smn_addr, u32 *data) +{ + pci_write_config_dword(dev, 0x60, smn_addr); + pci_read_config_dword(dev, 0x64, data); + + return 0; +} + static void configure_acp_groupregisters(struct acp_dev_data *adata) { struct snd_sof_dev *sdev = adata->dev; @@ -135,6 +151,25 @@ int configure_and_run_dma(struct acp_dev_data *adata, unsigned int src_addr, return ret; } +static int psp_fw_validate(struct acp_dev_data *adata) +{ + struct snd_sof_dev *sdev = adata->dev; + int timeout; + u32 data; + + smn_write(adata->smn_dev, MP0_C2PMSG_26_REG, MBOX_ACP_SHA_DMA_COMMAND); + + for (timeout = ACP_PSP_TIMEOUT_COUNTER; timeout > 0; timeout--) { + msleep(20); + smn_read(adata->smn_dev, MP0_C2PMSG_26_REG, &data); + if (data & MBOX_READY_MASK) + return 0; + } + + dev_err(sdev->dev, "FW validation timedout: status %x\n", data & MBOX_STATUS_MASK); + return -ETIMEDOUT; +} + int configure_and_run_sha_dma(struct acp_dev_data *adata, void *image_addr, unsigned int start_addr, unsigned int dest_addr, unsigned int image_length) @@ -174,7 +209,9 @@ int configure_and_run_sha_dma(struct acp_dev_data *adata, void *image_addr, return ret; } - snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SHA_DSP_FW_QUALIFIER, DSP_FW_RUN_ENABLE); + ret = psp_fw_validate(adata); + if (ret) + return ret; fw_qualifier = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SHA_DSP_FW_QUALIFIER); if (!(fw_qualifier & DSP_FW_RUN_ENABLE)) { @@ -238,6 +275,13 @@ static irqreturn_t acp_irq_thread(int irq, void *context) struct snd_sof_dev *sdev = context; unsigned int val; + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_EXTERNAL_INTR_STAT); + if (val & ACP_SHA_STAT) { + /* Clear SHA interrupt raised by PSP */ + snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_EXTERNAL_INTR_STAT, val); + return IRQ_HANDLED; + } + val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_DSP_SW_INTR_STAT); if (val & ACP_DSP_TO_HOST_IRQ) { sof_ops(sdev)->irq_thread(irq, sdev); @@ -326,6 +370,7 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) { struct pci_dev *pci = to_pci_dev(sdev->dev); struct acp_dev_data *adata; + const struct sof_amd_acp_desc *chip; unsigned int addr; int ret; @@ -346,18 +391,32 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) sdev->pdata->hw_pdata = adata; + chip = get_chip_info(sdev->pdata); + if (!chip) { + dev_err(sdev->dev, "no such device supported, chip id:%x\n", pci->device); + return -EIO; + } + + adata->smn_dev = pci_get_device(PCI_VENDOR_ID_AMD, chip->host_bridge_id, NULL); + if (!adata->smn_dev) { + dev_err(sdev->dev, "Failed to get host bridge device\n"); + return -ENODEV; + } + sdev->ipc_irq = pci->irq; ret = request_threaded_irq(sdev->ipc_irq, acp_irq_handler, acp_irq_thread, IRQF_SHARED, "AudioDSP", sdev); if (ret < 0) { dev_err(sdev->dev, "failed to register IRQ %d\n", sdev->ipc_irq); + pci_dev_put(adata->smn_dev); return ret; } ret = acp_init(sdev); if (ret < 0) { free_irq(sdev->ipc_irq, sdev); + pci_dev_put(adata->smn_dev); return ret; } @@ -371,6 +430,11 @@ EXPORT_SYMBOL_NS(amd_sof_acp_probe, SND_SOC_SOF_AMD_COMMON); int amd_sof_acp_remove(struct snd_sof_dev *sdev) { + struct acp_dev_data *adata = sdev->pdata->hw_pdata; + + if (adata->smn_dev) + pci_dev_put(adata->smn_dev); + if (sdev->ipc_irq) free_irq(sdev->ipc_irq, sdev); diff --git a/sound/soc/sof/amd/acp.h b/sound/soc/sof/amd/acp.h index fd923f72a01a..a2f8e4219066 100644 --- a/sound/soc/sof/amd/acp.h +++ b/sound/soc/sof/amd/acp.h @@ -52,6 +52,15 @@ #define ACP_DSP_TO_HOST_IRQ 0x04 +#define HOST_BRIDGE_CZN 0x1630 +#define ACP_SHA_STAT 0x8000 +#define ACP_PSP_TIMEOUT_COUNTER 5 +#define ACP_EXT_INTR_ERROR_STAT 0x20000000 +#define MP0_C2PMSG_26_REG 0x03810570 +#define MBOX_ACP_SHA_DMA_COMMAND 0x330000 +#define MBOX_READY_MASK 0x80000000 +#define MBOX_STATUS_MASK 0xFFFF + struct acp_atu_grp_pte { u32 low; u32 high; @@ -140,6 +149,7 @@ struct acp_dev_data { struct dma_descriptor dscr_info[ACP_MAX_DESC]; struct acp_dsp_stream stream_buf[ACP_MAX_STREAM]; struct acp_dsp_stream *dtrace_stream; + struct pci_dev *smn_dev; }; void memcpy_to_scratch(struct snd_sof_dev *sdev, u32 offset, unsigned int *src, size_t bytes); @@ -202,4 +212,15 @@ int snd_amd_acp_find_config(struct pci_dev *pci); /* Trace */ int acp_sof_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag); int acp_sof_trace_release(struct snd_sof_dev *sdev); + +struct sof_amd_acp_desc { + unsigned int host_bridge_id; +}; + +static inline const struct sof_amd_acp_desc *get_chip_info(struct snd_sof_pdata *pdata) +{ + const struct sof_dev_desc *desc = pdata->desc; + + return desc->chip_info; +} #endif diff --git a/sound/soc/sof/amd/pci-rn.c b/sound/soc/sof/amd/pci-rn.c index 3c379a5ef231..392ffbdf6417 100644 --- a/sound/soc/sof/amd/pci-rn.c +++ b/sound/soc/sof/amd/pci-rn.c @@ -43,12 +43,17 @@ static const struct resource renoir_res[] = { }, }; +static const struct sof_amd_acp_desc renoir_chip_info = { + .host_bridge_id = HOST_BRIDGE_CZN, +}; + static const struct sof_dev_desc renoir_desc = { .machines = snd_soc_acpi_amd_sof_machines, .resindex_lpe_base = 0, .resindex_pcicfg_base = -1, .resindex_imr_base = -1, .irqindex_host_ipc = -1, + .chip_info = &renoir_chip_info, .default_fw_path = "amd/sof", .default_tplg_path = "amd/sof-tplg", .default_fw_filename = "sof-rn.ri", From patchwork Wed Nov 17 09:37:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624219 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 86122C433EF for ; Wed, 17 Nov 2021 09:45:06 +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 02CD161A07 for ; Wed, 17 Nov 2021 09:45:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 02CD161A07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 638901890; Wed, 17 Nov 2021 10:44:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 638901890 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142304; bh=AxOiCrIkGcO9YuFIHbBRqLbAsPKXvFIkqlCP748Ieik=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vp1XDRq9XSFxakkQczgZnIeK8WX/dRPz0rrTyIsvEeSdssWp27RpDCe7D386Wj+qo 92Fup4Zwt0VTYP4xGsDKip92am6Uro3doIzAqnfohUOnqtLeyAMRy1xHZdDosEIBzf WqhBa5tRIO3wrI8QtHqhGI4d60e9BKrBJgYWzExU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2B052F805A1; Wed, 17 Nov 2021 10:38:56 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 513F7F8027D; Wed, 17 Nov 2021 10:38:44 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80073.outbound.protection.outlook.com [40.107.8.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 F3946F8027D for ; Wed, 17 Nov 2021 10:38:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F3946F8027D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="HlfexXBh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=esCIdA5866qzwlkwcU4XIFoXlq2pAlFvJICtnmgouu73Zooy+c6YpyCjNfCMEC0zFE5G+NUzIEGn7Z1/Cf8hICAnFkY10wLwB8g90wo9YxbS7pMhdZ1ETQ1BOYzU5fmxHbUSieGO6SFFvg12cQGtmTuAGEtiVSI/JjLXvf9/aZbfqP8e7QdSfSxZgdLjf6XFZuZlosomeU9kmJwPrU7w9TsQcck54z2sxaHS2SmJz8c1E+tJTei/S0erWzRtC9nL+Wz8DM0JX1r1RrXVaEBpWjFFiaymXE9GGGfNZQo2AznBiHO0FHmxn8UYcZGwrrU+WSJHHxI5xv4/MO2lRoLM0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QEyodSSXpiFwxTss4bYtelmKfUBGZPhVh6u0ejx8XW0=; b=BYr4W9SOkdZLJOe6C6L7XrFjVundReppxeEl1LVLX5Xo5ApNptCP60AYfRY9FGPufa4Ew1i/MAbU+RmMPVk4CmlORdQmP/BIuRWV0KmfVbQQRzcCJjxPZ07taRy5aZUj/GkegdeTaXtm/Lup6llxm3FiWAvnSGEmNakvJTx0Ul2ZJiIJOp7Clr34k2EFluT6YEYa3A7Ko4gnELaP8PA3iBjkOU8dYQbolDV78ljxIloxNHREaUYCvjVoZO/eXZKhAGBT9IXk1/XtgsBviTYoaS7aXOaOcQA63jLaliWAGBgU1WIU4LIkd09Qi891chN+7dFYC/GopO0LGienMY16dA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QEyodSSXpiFwxTss4bYtelmKfUBGZPhVh6u0ejx8XW0=; b=HlfexXBhxwk/CoLi3Kl0/i+0H+BJKXsDQpCwKy6R+w+7bd2uO75hM4H+tyKz1zasIVvTmqHnke92H3D1HK1p6RU7NTbMSMb69XqfKLASd7L1motY5erHeBEaKFCwmXMENcBYvBdkGSuc93KIT36wefUpDeK6j5HGT0UWuFrOeLg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VE1PR04MB6623.eurprd04.prod.outlook.com (2603:10a6:803:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Wed, 17 Nov 2021 09:38:30 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:30 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 14/21] ASoC: SOF: mediatek: Add mt8195 hardware support Date: Wed, 17 Nov 2021 11:37:27 +0200 Message-Id: <20211117093734.17407-15-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d97023a-4f48-48f0-2bfe-08d9a9ae036a X-MS-TrafficTypeDiagnostic: VE1PR04MB6623: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /jaD6MCZq64S1zY/rrBOXM4wJUjorQXmqmyEsGUB26DvCeb/6+tJFNb0q1eA7aP8A0WF+i7ahM1kmcBN6kErXjMozjwF3IGpkxJbo6CCr60iqSCW7S4/Y4MqS0WKTwtlVZ5ks8GbWT1TZEqT31Rf+KxZoH9H/Fqx00VtkqpTjsTeH23p8CVEg6vljEef9ZgmEyyVDGBoqaj52zyTGXgmVs0RXqizfOBBVuWwdqf0j8ANcawskob8N1SvVNBHUUjrIYckOW8R+344XslUbCz11OVFvcttOTqEEn+b/MUzkwZRk5YbIr4kGXW0w6omcevfZhmnMZfUCtRuc9ZZHK9vQF3FZ9iKf+VUFXe8Jg8Or2U6fuHYtCrTkazx0VIk3bOxI1OgngiHWMKe6Oc7vMDbyThLLkM3xybANhX2l2/mHR7xn5slBFQKwlcEeruseoc4kizOBKFOF6pqzp9SCFnqOtwcoeQK2RWW9/ev5q4YQ5vwxOIESesqu0OSUWLpdfTqY1oT5Rjl9PhhhiaQ7Fqn3dLXlZqmkUDLSYyg1618lh47w2kbQeWvhmSMsQ1COdwbXiNhmoFSs4bq4uusG+PRUB9T5oKYiD5/OFu1YoB1Re4Zg3yz5oUcF9NEOMG1ZAGCOGKdLH1kxmApP06jCsTVuA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(30864003)(1076003)(52116002)(6506007)(5660300002)(54906003)(8676002)(508600001)(186003)(86362001)(2616005)(6512007)(7416002)(83380400001)(66574015)(44832011)(66556008)(66476007)(4326008)(66946007)(316002)(38100700002)(6486002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?gNWNCHjYAfHxRSPM8FyXhLoZGBrg?= =?utf-8?q?c54Exw6u01UXWVMlfJYcWbTTUE+HjpoHJsv1uzG3WIS73NPcV9/QOYcMn1hyvibmC?= =?utf-8?q?yOxzFS7SFBXpRMxjhg14GvBKWvuVulZxK/POOnrk/2ZlTJh45Uaaqqz9KU53VerBk?= =?utf-8?q?KHPvZ80A+KZXlg4vd6eQr+roVF5NLX5AtzeTK5uETxxV7XQE6T/KwRTbKaJZ9Wg39?= =?utf-8?q?yPxvPaWnejrwIe8FlY718/FqY3/nUF2fNsiCDpaTwn8l+vePP/JaUp+d9JaumSkKZ?= =?utf-8?q?NonzXT9UyEh/lrnp9m4SpQm/o26jKqsG6rd25jw456CZk2c4yZghZJO7IleswMg2m?= =?utf-8?q?hQS8BHjOUGcPE23GJoeYjQbnidf81AVtOGv1CmXmPnMfc/l9UO1upTxe5GIfqiJGy?= =?utf-8?q?bZMIxeCyw693oM9zdFfxD5gqzSUOk+kCL6LIGb+7cvM5+6ORLY4h8t/5Q1z4dPeDz?= =?utf-8?q?GXVsVSrzA1AEnuHfHzbvz75kGLi9O1TWUDOv5xayZ6HU8257VgVlXFo5NzIjw83V2?= =?utf-8?q?g3KnI2tFPOPAQtA+mwHwAKklPNlL6OUa/6cl4pO4Sr3ZMJLGOsMeoO2u8cKHK6+Rz?= =?utf-8?q?DW9cG+k2pszNJxsBll5kqTaIbqI7Dbv94Y2XPDlK5I3BBwud0540OoJ5cZ9XpFvdP?= =?utf-8?q?oniEHS+a5hQysyzSGAeGCIXQOgqYw5FJ7mHRxshZIhL4p2AIf3rE3gi/ghOPrsSJV?= =?utf-8?q?rGf1/+Sz4MmglQJOs5nvVuirRnncLLs5PQCKb1yBvXNRAPuDADcaAGb/uZSLBRWqo?= =?utf-8?q?/fdOOgUzFXOsKarTnhgo2Rd7OcpCd6O0fzOzMub7zNkvZea4Z4Z1h0joAvsR3c1iq?= =?utf-8?q?ke/IDYabaouaelg0CANiDYkrSJUz0oN/ajyXafPqSJ1eAP4s8rWa7FnftKaUbZcfZ?= =?utf-8?q?nGExYvm17bDnK1b+Ms6ZxP/DpLpmr3PJaG6KUVokbYI4uhw79n2jHtHsViQwO+6PJ?= =?utf-8?q?UmZmWbScGGBhvrxGgXpHDh+drHPvbygmCfX/SFbTFouzRkO9oVE0PFmY3IWhfumVp?= =?utf-8?q?PCLooPyHAAJyph8YgUwCLhqjw7N+Zhw8a8HdFi5ioKrXU1C7WmLixfjC7nv34SBOc?= =?utf-8?q?r27K32+FdVs2spYbFlRJi8iXBUCTtcFa1bjJPNilANO/FMTwCWdIrP/3JPseMyJYW?= =?utf-8?q?+er0Cw4fVLH6Lq4ekwadsAJ9BzFM+nwl+KNirwyE0pTLQZ2jsgz9x4Psbni7mxViG?= =?utf-8?q?ri44KVHQwAzyjJmsBefroM4b/XQU7Aotus+9ECeX7wpY89d7PQ2X1E2LElN5C5aaa?= =?utf-8?q?MCswUKqa+HryKhYvXgGZ510MVTgUhsvq9vGP8Gw40jSps8xv4hnbI/ffP+Ye1codM?= =?utf-8?q?zGLTlmRk/6CtK5JuhGy3A2jsRwigEPElGY5vWN9iGPOywuFb1zg5jjufGy/j7jiNS?= =?utf-8?q?j7Vy7l3CVTjKvpsLZENVJwzwuyaIo8U4NUCl8qbJecBQq5oqr5//O1px4QCjhA9hI?= =?utf-8?q?u9hDkm5dVt7ybb/nJKY/azE54xnfmGumcx98Ef5WPhhZqcwk9Cf+54ZqmqTIIn2cy?= =?utf-8?q?VSxQJLJWSWucksyiWY3Jgxo9JpPqCGN8TlXRD53rx2mD1MpdqRt8Y97bX5UhQwZL4?= =?utf-8?q?10Tx3dpN6O8eTNqj1688LZW3TkDvV72x2o8hhUjmTxTQe4YBTRItp5AMwZmpEkZmU?= =?utf-8?q?OAGvg67BIe?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d97023a-4f48-48f0-2bfe-08d9a9ae036a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:30.0206 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ouTQJjAzfcJJP+sqVo7M320ymGEmYfLGirW31RV+tUS0KqBDAERgpVG1zXXNIVaN4Mz1+P1n0iXEHAMg6EWJzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6623 Cc: Guennadi Liakhovetski , daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, =?utf-8?q?P=C3=A9te?= =?utf-8?q?r_Ujfalusi?= , pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Ranjani Sridharan , Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.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" From: YC Hung This patch initialize to support SOF on Mediatek mt8195 platform. MT8195 has four Cortex A78 cores paired with four Cortex A55 cores. It also has Cadence HiFi-4 DSP single core. There are shared DRAM and mailbox interrupt between AP and DSP to use for IPC communication. Signed-off-by: YC Hung Reviewed-by: Péter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Kai Vehmanen Reviewed-by: Guennadi Liakhovetski Reviewed-by: Daniel Baluta Signed-off-by: Daniel Baluta --- sound/soc/sof/Kconfig | 1 + sound/soc/sof/Makefile | 1 + sound/soc/sof/mediatek/Kconfig | 33 +++ sound/soc/sof/mediatek/Makefile | 2 + sound/soc/sof/mediatek/adsp_helper.h | 49 ++++ sound/soc/sof/mediatek/mediatek-ops.h | 8 + sound/soc/sof/mediatek/mt8195/Makefile | 3 + sound/soc/sof/mediatek/mt8195/mt8195.c | 334 +++++++++++++++++++++++++ sound/soc/sof/mediatek/mt8195/mt8195.h | 155 ++++++++++++ 9 files changed, 586 insertions(+) create mode 100644 sound/soc/sof/mediatek/Kconfig create mode 100644 sound/soc/sof/mediatek/Makefile create mode 100644 sound/soc/sof/mediatek/adsp_helper.h create mode 100644 sound/soc/sof/mediatek/mediatek-ops.h create mode 100644 sound/soc/sof/mediatek/mt8195/Makefile create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195.c create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195.h diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index 68571bf2585e..41f97c6cb4c1 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -226,6 +226,7 @@ config SND_SOC_SOF_PROBE_WORK_QUEUE source "sound/soc/sof/amd/Kconfig" source "sound/soc/sof/imx/Kconfig" source "sound/soc/sof/intel/Kconfig" +source "sound/soc/sof/mediatek/Kconfig" source "sound/soc/sof/xtensa/Kconfig" endif diff --git a/sound/soc/sof/Makefile b/sound/soc/sof/Makefile index 011abfa0fd82..43a983376976 100644 --- a/sound/soc/sof/Makefile +++ b/sound/soc/sof/Makefile @@ -24,3 +24,4 @@ obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/ obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/ obj-$(CONFIG_SND_SOC_SOF_AMD_TOPLEVEL) += amd/ obj-$(CONFIG_SND_SOC_SOF_XTENSA) += xtensa/ +obj-$(CONFIG_SND_SOC_SOF_MTK_TOPLEVEL) += mediatek/ diff --git a/sound/soc/sof/mediatek/Kconfig b/sound/soc/sof/mediatek/Kconfig new file mode 100644 index 000000000000..aeacf0e5bfbb --- /dev/null +++ b/sound/soc/sof/mediatek/Kconfig @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) + +config SND_SOC_SOF_MTK_TOPLEVEL + bool "SOF support for MTK audio DSPs" + depends on ARM64 || COMPILE_TEST + depends on SND_SOC_SOF_OF + help + This adds support for Sound Open Firmware for Mediatek platforms. + It is top level for all mediatek platforms. + Say Y if you have such a device. + If unsure select "N". + +if SND_SOC_SOF_MTK_TOPLEVEL +config SND_SOC_SOF_MTK_COMMON + tristate + select SND_SOC_SOF_OF_DEV + select SND_SOC_SOF + select SND_SOC_SOF_XTENSA + select SND_SOC_SOF_COMPRESS + help + This option is not user-selectable but automagically handled by + 'select' statements at a higher level + +config SND_SOC_SOF_MT8195 + tristate "SOF support for MT8195 audio DSP" + select SND_SOC_SOF_MTK_COMMON + help + This adds support for Sound Open Firmware for Mediatek platforms + using the mt8195 processors. + Say Y if you have such a device. + If unsure select "N". + +endif ## SND_SOC_SOF_MTK_TOPLEVEL diff --git a/sound/soc/sof/mediatek/Makefile b/sound/soc/sof/mediatek/Makefile new file mode 100644 index 000000000000..e8ec6da981de --- /dev/null +++ b/sound/soc/sof/mediatek/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +obj-$(CONFIG_SND_SOC_SOF_MT8195) += mt8195/ diff --git a/sound/soc/sof/mediatek/adsp_helper.h b/sound/soc/sof/mediatek/adsp_helper.h new file mode 100644 index 000000000000..346953dd22db --- /dev/null +++ b/sound/soc/sof/mediatek/adsp_helper.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Copyright (c) 2021 MediaTek Corporation. All rights reserved. + */ + +#ifndef __MTK_ADSP_HELPER_H__ +#define __MTK_ADSP_HELPER_H__ + +/* + * Global important adsp data structure. + */ +#define DSP_MBOX_NUM 3 + +struct mtk_adsp_chip_info { + phys_addr_t pa_sram; + phys_addr_t pa_dram; /* adsp dram physical base */ + phys_addr_t pa_shared_dram; /* adsp dram physical base */ + phys_addr_t pa_cfgreg; + phys_addr_t pa_mboxreg[DSP_MBOX_NUM]; + u32 sramsize; + u32 dramsize; + u32 cfgregsize; + void __iomem *va_sram; /* corresponding to pa_sram */ + void __iomem *va_dram; /* corresponding to pa_dram */ + void __iomem *va_cfgreg; + void __iomem *va_mboxreg[DSP_MBOX_NUM]; + void __iomem *shared_sram; /* part of va_sram */ + void __iomem *shared_dram; /* part of va_dram */ + phys_addr_t adsp_bootup_addr; + int dram_offset; /*dram offset between system and dsp view*/ +}; + +struct adsp_priv { + struct device *dev; + struct snd_sof_dev *sdev; + + /* DSP IPC handler */ + struct mbox_controller *adsp_mbox; + + struct mtk_adsp_chip_info *adsp; + + u32 (*ap2adsp_addr)(u32 addr, void *data); + u32 (*adsp2ap_addr)(u32 addr, void *data); + + void *private_data; +}; + +#endif diff --git a/sound/soc/sof/mediatek/mediatek-ops.h b/sound/soc/sof/mediatek/mediatek-ops.h new file mode 100644 index 000000000000..e0ffa69ecb0c --- /dev/null +++ b/sound/soc/sof/mediatek/mediatek-ops.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ + +#ifndef __MEDIATEK_OPS_H__ +#define __MEDIATEK_OPS_H__ + +extern const struct snd_sof_dsp_ops sof_mt8195_ops; + +#endif diff --git a/sound/soc/sof/mediatek/mt8195/Makefile b/sound/soc/sof/mediatek/mt8195/Makefile new file mode 100644 index 000000000000..dd2b6e4affc9 --- /dev/null +++ b/sound/soc/sof/mediatek/mt8195/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +snd-sof-mt8195-objs := mt8195.o +obj-$(CONFIG_SND_SOC_SOF_MT8195) += snd-sof-mt8195.o diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c new file mode 100644 index 000000000000..945601a0dc37 --- /dev/null +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -0,0 +1,334 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// Copyright(c) 2021 Mediatek Inc. All rights reserved. +// +// Author: YC Hung +// + +/* + * Hardware interface for audio DSP on mt8195 + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "../../ops.h" +#include "../../sof-audio.h" +#include "../adsp_helper.h" +#include "../mediatek-ops.h" +#include "mt8195.h" + +static int platform_parse_resource(struct platform_device *pdev, void *data) +{ + struct resource *mmio; + struct resource res; + struct device_node *mem_region; + struct device *dev = &pdev->dev; + struct mtk_adsp_chip_info *adsp = data; + int ret; + + mem_region = of_parse_phandle(dev->of_node, "memory-region", 0); + if (!mem_region) { + dev_err(dev, "no dma memory-region phandle\n"); + return -ENODEV; + } + + ret = of_address_to_resource(mem_region, 0, &res); + if (ret) { + dev_err(dev, "of_address_to_resource dma failed\n"); + return ret; + } + + dev_dbg(dev, "DMA pbase=0x%llx, size=0x%llx\n", + (phys_addr_t)res.start, resource_size(&res)); + + ret = of_reserved_mem_device_init(dev); + if (ret) { + dev_err(dev, "of_reserved_mem_device_init failed\n"); + return ret; + } + + mem_region = of_parse_phandle(dev->of_node, "memory-region", 1); + if (!mem_region) { + dev_err(dev, "no memory-region sysmem phandle\n"); + return -ENODEV; + } + + ret = of_address_to_resource(mem_region, 0, &res); + if (ret) { + dev_err(dev, "of_address_to_resource sysmem failed\n"); + return ret; + } + + adsp->pa_dram = (phys_addr_t)res.start; + adsp->dramsize = resource_size(&res); + if (adsp->pa_dram & DRAM_REMAP_MASK) { + dev_err(dev, "adsp memory(%#x) is not 4K-aligned\n", + (u32)adsp->pa_dram); + return -EINVAL; + } + + if (adsp->dramsize < TOTAL_SIZE_SHARED_DRAM_FROM_TAIL) { + dev_err(dev, "adsp memory(%#x) is not enough for share\n", + adsp->dramsize); + return -EINVAL; + } + + dev_dbg(dev, "dram pbase=%pa, dramsize=%#x\n", + &adsp->pa_dram, adsp->dramsize); + + /* Parse CFG base */ + mmio = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); + if (!mmio) { + dev_err(dev, "no ADSP-CFG register resource\n"); + return -ENXIO; + } + /* remap for DSP register accessing */ + adsp->va_cfgreg = devm_ioremap_resource(dev, mmio); + if (IS_ERR(adsp->va_cfgreg)) + return PTR_ERR(adsp->va_cfgreg); + + adsp->pa_cfgreg = (phys_addr_t)mmio->start; + adsp->cfgregsize = resource_size(mmio); + + dev_dbg(dev, "cfgreg-vbase=%p, cfgregsize=%#x\n", + adsp->va_cfgreg, adsp->cfgregsize); + + /* Parse SRAM */ + mmio = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); + if (!mmio) { + dev_err(dev, "no SRAM resource\n"); + return -ENXIO; + } + + adsp->pa_sram = (phys_addr_t)mmio->start; + adsp->sramsize = resource_size(mmio); + if (adsp->sramsize < TOTAL_SIZE_SHARED_SRAM_FROM_TAIL) { + dev_err(dev, "adsp SRAM(%#x) is not enough for share\n", + adsp->sramsize); + return -EINVAL; + } + + dev_dbg(dev, "sram pbase=%pa,%#x\n", &adsp->pa_sram, adsp->sramsize); + + return ret; +} + +static int adsp_sram_power_on(struct device *dev, bool on) +{ + void __iomem *va_dspsysreg; + u32 srampool_con; + + va_dspsysreg = ioremap(ADSP_SRAM_POOL_CON, 0x4); + if (!va_dspsysreg) { + dev_err(dev, "failed to ioremap sram pool base %#x\n", + ADSP_SRAM_POOL_CON); + return -ENOMEM; + } + + srampool_con = readl(va_dspsysreg); + if (on) + writel(srampool_con & ~DSP_SRAM_POOL_PD_MASK, va_dspsysreg); + else + writel(srampool_con | DSP_SRAM_POOL_PD_MASK, va_dspsysreg); + + iounmap(va_dspsysreg); + return 0; +} + +/* Init the basic DSP DRAM address */ +static int adsp_memory_remap_init(struct device *dev, struct mtk_adsp_chip_info *adsp) +{ + void __iomem *vaddr_emi_map; + int offset; + + if (!adsp) + return -ENXIO; + + vaddr_emi_map = devm_ioremap(dev, DSP_EMI_MAP_ADDR, 0x4); + if (!vaddr_emi_map) { + dev_err(dev, "failed to ioremap emi map base %#x\n", + DSP_EMI_MAP_ADDR); + return -ENOMEM; + } + + offset = adsp->pa_dram - DRAM_PHYS_BASE_FROM_DSP_VIEW; + adsp->dram_offset = offset; + offset >>= DRAM_REMAP_SHIFT; + dev_dbg(dev, "adsp->pa_dram %llx, offset %#x\n", adsp->pa_dram, offset); + writel(offset, vaddr_emi_map); + if (offset != readl(vaddr_emi_map)) { + dev_err(dev, "write emi map fail : %#x\n", readl(vaddr_emi_map)); + return -EIO; + } + + return 0; +} + +static int adsp_shared_base_ioremap(struct platform_device *pdev, void *data) +{ + struct device *dev = &pdev->dev; + struct mtk_adsp_chip_info *adsp = data; + u32 shared_size; + + /* remap shared-dram base to be non-cachable */ + shared_size = TOTAL_SIZE_SHARED_DRAM_FROM_TAIL; + adsp->pa_shared_dram = adsp->pa_dram + adsp->dramsize - shared_size; + if (adsp->va_dram) { + adsp->shared_dram = adsp->va_dram + DSP_DRAM_SIZE - shared_size; + } else { + adsp->shared_dram = devm_ioremap(dev, adsp->pa_shared_dram, + shared_size); + if (!adsp->shared_dram) { + dev_err(dev, "ioremap failed for shared DRAM\n"); + return -ENOMEM; + } + } + dev_dbg(dev, "shared-dram vbase=%p, phy addr :%llx, size=%#x\n", + adsp->shared_dram, adsp->pa_shared_dram, shared_size); + + return 0; +} + +static int mt8195_run(struct snd_sof_dev *sdev) +{ + u32 adsp_bootup_addr; + + adsp_bootup_addr = SRAM_PHYS_BASE_FROM_DSP_VIEW; + dev_dbg(sdev->dev, "HIFIxDSP boot from base : 0x%08X\n", adsp_bootup_addr); + sof_hifixdsp_boot_sequence(sdev, adsp_bootup_addr); + + return 0; +} + +static int mt8195_dsp_probe(struct snd_sof_dev *sdev) +{ + struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev); + struct adsp_priv *priv; + int ret; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + sdev->pdata->hw_pdata = priv; + priv->dev = sdev->dev; + priv->sdev = sdev; + + priv->adsp = devm_kzalloc(&pdev->dev, sizeof(struct mtk_adsp_chip_info), GFP_KERNEL); + if (!priv->adsp) + return -ENOMEM; + + ret = platform_parse_resource(pdev, priv->adsp); + if (ret) + return ret; + + ret = adsp_sram_power_on(sdev->dev, true); + if (ret) { + dev_err(sdev->dev, "adsp_sram_power_on fail!\n"); + return ret; + } + + ret = adsp_memory_remap_init(&pdev->dev, priv->adsp); + if (ret) { + dev_err(sdev->dev, "adsp_memory_remap_init fail!\n"); + goto err_adsp_sram_power_off; + } + + sdev->bar[SOF_FW_BLK_TYPE_IRAM] = devm_ioremap(sdev->dev, + priv->adsp->pa_sram, + priv->adsp->sramsize); + if (!sdev->bar[SOF_FW_BLK_TYPE_IRAM]) { + dev_err(sdev->dev, "failed to ioremap base %pa size %#x\n", + &priv->adsp->pa_sram, priv->adsp->sramsize); + ret = -EINVAL; + goto err_adsp_sram_power_off; + } + + sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap_wc(sdev->dev, + priv->adsp->pa_dram, + priv->adsp->dramsize); + if (!sdev->bar[SOF_FW_BLK_TYPE_SRAM]) { + dev_err(sdev->dev, "failed to ioremap base %pa size %#x\n", + &priv->adsp->pa_dram, priv->adsp->dramsize); + ret = -EINVAL; + goto err_adsp_sram_power_off; + } + priv->adsp->va_dram = sdev->bar[SOF_FW_BLK_TYPE_SRAM]; + + ret = adsp_shared_base_ioremap(pdev, priv->adsp); + if (ret) { + dev_err(sdev->dev, "adsp_shared_base_ioremap fail!\n"); + goto err_adsp_sram_power_off; + } + + sdev->bar[DSP_REG_BAR] = priv->adsp->va_cfgreg; + sdev->bar[DSP_MBOX0_BAR] = priv->adsp->va_mboxreg[0]; + sdev->bar[DSP_MBOX1_BAR] = priv->adsp->va_mboxreg[1]; + sdev->bar[DSP_MBOX2_BAR] = priv->adsp->va_mboxreg[2]; + + sdev->mmio_bar = SOF_FW_BLK_TYPE_SRAM; + sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM; + + return 0; + +err_adsp_sram_power_off: + adsp_sram_power_on(&pdev->dev, false); + + return ret; +} + +static int mt8195_dsp_remove(struct snd_sof_dev *sdev) +{ + struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev); + + return adsp_sram_power_on(&pdev->dev, false); +} + +/* on mt8195 there is 1 to 1 match between type and BAR idx */ +static int mt8195_get_bar_index(struct snd_sof_dev *sdev, u32 type) +{ + return type; +} + +/* mt8195 ops */ +const struct snd_sof_dsp_ops sof_mt8195_ops = { + /* probe and remove */ + .probe = mt8195_dsp_probe, + .remove = mt8195_dsp_remove, + + /* Block IO */ + .block_read = sof_block_read, + .block_write = sof_block_write, + + /* Register IO */ + .write = sof_io_write, + .read = sof_io_read, + .write64 = sof_io_write64, + .read64 = sof_io_read64, + + /* misc */ + .get_bar_index = mt8195_get_bar_index, + + /* Firmware ops */ + .dsp_arch_ops = &sof_xtensa_arch_ops, + + /* ALSA HW info flags */ + .hw_info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_PAUSE | + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, +}; +EXPORT_SYMBOL(sof_mt8195_ops); + +MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.h b/sound/soc/sof/mediatek/mt8195/mt8195.h new file mode 100644 index 000000000000..48cbbb5aacb5 --- /dev/null +++ b/sound/soc/sof/mediatek/mt8195/mt8195.h @@ -0,0 +1,155 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Copyright (c) 2021 MediaTek Corporation. All rights reserved. + * + * Header file for the mt8195 DSP register definition + */ + +#ifndef __MT8195_H +#define __MT8195_H + +struct mtk_adsp_chip_info; + +#define DSP_REG_BASE 0x10803000 +#define SCP_CFGREG_BASE 0x10724000 +#define DSP_SYSAO_BASE 0x1080C000 + +/***************************************************************************** + * R E G I S T E R TABLE + *****************************************************************************/ +#define DSP_JTAGMUX 0x0000 +#define DSP_ALTRESETVEC 0x0004 +#define DSP_PDEBUGDATA 0x0008 +#define DSP_PDEBUGBUS0 0x000c +#define PDEBUG_ENABLE BIT(0) +#define DSP_PDEBUGBUS1 0x0010 +#define DSP_PDEBUGINST 0x0014 +#define DSP_PDEBUGLS0STAT 0x0018 +#define DSP_PDEBUGLS1STAT 0x001c +#define DSP_PDEBUGPC 0x0020 +#define DSP_RESET_SW 0x0024 /*reset sw*/ +#define ADSP_BRESET_SW BIT(0) +#define ADSP_DRESET_SW BIT(1) +#define ADSP_RUNSTALL BIT(3) +#define STATVECTOR_SEL BIT(4) +#define DSP_PFAULTBUS 0x0028 +#define DSP_PFAULTINFO 0x002c +#define DSP_GPR00 0x0030 +#define DSP_GPR01 0x0034 +#define DSP_GPR02 0x0038 +#define DSP_GPR03 0x003c +#define DSP_GPR04 0x0040 +#define DSP_GPR05 0x0044 +#define DSP_GPR06 0x0048 +#define DSP_GPR07 0x004c +#define DSP_GPR08 0x0050 +#define DSP_GPR09 0x0054 +#define DSP_GPR0A 0x0058 +#define DSP_GPR0B 0x005c +#define DSP_GPR0C 0x0060 +#define DSP_GPR0D 0x0064 +#define DSP_GPR0E 0x0068 +#define DSP_GPR0F 0x006c +#define DSP_GPR10 0x0070 +#define DSP_GPR11 0x0074 +#define DSP_GPR12 0x0078 +#define DSP_GPR13 0x007c +#define DSP_GPR14 0x0080 +#define DSP_GPR15 0x0084 +#define DSP_GPR16 0x0088 +#define DSP_GPR17 0x008c +#define DSP_GPR18 0x0090 +#define DSP_GPR19 0x0094 +#define DSP_GPR1A 0x0098 +#define DSP_GPR1B 0x009c +#define DSP_GPR1C 0x00a0 +#define DSP_GPR1D 0x00a4 +#define DSP_GPR1E 0x00a8 +#define DSP_GPR1F 0x00ac +#define DSP_TCM_OFFSET 0x00b0 /* not used */ +#define DSP_DDR_OFFSET 0x00b4 /* not used */ +#define DSP_INTFDSP 0x00d0 +#define DSP_INTFDSP_CLR 0x00d4 +#define DSP_SRAM_PD_SW1 0x00d8 +#define DSP_SRAM_PD_SW2 0x00dc +#define DSP_OCD 0x00e0 +#define DSP_RG_DSP_IRQ_POL 0x00f0 /* not used */ +#define DSP_DSP_IRQ_EN 0x00f4 /* not used */ +#define DSP_DSP_IRQ_LEVEL 0x00f8 /* not used */ +#define DSP_DSP_IRQ_STATUS 0x00fc /* not used */ +#define DSP_RG_INT2CIRQ 0x0114 +#define DSP_RG_INT_POL_CTL0 0x0120 +#define DSP_RG_INT_EN_CTL0 0x0130 +#define DSP_RG_INT_LV_CTL0 0x0140 +#define DSP_RG_INT_STATUS0 0x0150 +#define DSP_PDEBUGSTATUS0 0x0200 +#define DSP_PDEBUGSTATUS1 0x0204 +#define DSP_PDEBUGSTATUS2 0x0208 +#define DSP_PDEBUGSTATUS3 0x020c +#define DSP_PDEBUGSTATUS4 0x0210 +#define DSP_PDEBUGSTATUS5 0x0214 +#define DSP_PDEBUGSTATUS6 0x0218 +#define DSP_PDEBUGSTATUS7 0x021c +#define DSP_DSP2PSRAM_PRIORITY 0x0220 /* not used */ +#define DSP_AUDIO_DSP2SPM_INT 0x0224 +#define DSP_AUDIO_DSP2SPM_INT_ACK 0x0228 +#define DSP_AUDIO_DSP_DEBUG_SEL 0x022C +#define DSP_AUDIO_DSP_EMI_BASE_ADDR 0x02E0 /* not used */ +#define DSP_AUDIO_DSP_SHARED_IRAM 0x02E4 +#define DSP_AUDIO_DSP_CKCTRL_P2P_CK_CON 0x02F0 +#define DSP_RG_SEMAPHORE00 0x0300 +#define DSP_RG_SEMAPHORE01 0x0304 +#define DSP_RG_SEMAPHORE02 0x0308 +#define DSP_RG_SEMAPHORE03 0x030C +#define DSP_RG_SEMAPHORE04 0x0310 +#define DSP_RG_SEMAPHORE05 0x0314 +#define DSP_RG_SEMAPHORE06 0x0318 +#define DSP_RG_SEMAPHORE07 0x031C +#define DSP_RESERVED_0 0x03F0 +#define DSP_RESERVED_1 0x03F4 + +/* dsp wdt */ +#define DSP_WDT_MODE 0x0400 + +/* dsp mbox */ +#define DSP_MBOX_IN_CMD 0x00 +#define DSP_MBOX_IN_CMD_CLR 0x04 +#define DSP_MBOX_OUT_CMD 0x1c +#define DSP_MBOX_OUT_CMD_CLR 0x20 +#define DSP_MBOX_IN_MSG0 0x08 +#define DSP_MBOX_IN_MSG1 0x0C +#define DSP_MBOX_OUT_MSG0 0x24 +#define DSP_MBOX_OUT_MSG1 0x28 + +/*dsp sys ao*/ +#define ADSP_SRAM_POOL_CON (DSP_SYSAO_BASE + 0x30) +#define DSP_SRAM_POOL_PD_MASK 0xf +#define DSP_EMI_MAP_ADDR (DSP_SYSAO_BASE + 0x81c) + +/* DSP memories */ +#define MBOX_OFFSET 0x800000 /* DRAM */ +#define MBOX_SIZE 0x1000 /* consistent with which in memory.h of sof fw */ +#define DSP_DRAM_SIZE 0x1000000 /* 16M */ + +#define DSP_REG_BAR 4 +#define DSP_MBOX0_BAR 5 +#define DSP_MBOX1_BAR 6 +#define DSP_MBOX2_BAR 7 + +#define TOTAL_SIZE_SHARED_SRAM_FROM_TAIL 0x0 + +#define SIZE_SHARED_DRAM_DL 0x40000 /*Shared buffer for Downlink*/ +#define SIZE_SHARED_DRAM_UL 0x40000 /*Shared buffer for Uplink*/ + +#define TOTAL_SIZE_SHARED_DRAM_FROM_TAIL \ + (SIZE_SHARED_DRAM_DL + SIZE_SHARED_DRAM_UL) + +#define SRAM_PHYS_BASE_FROM_DSP_VIEW 0x40000000 /* MT8195 DSP view */ +#define DRAM_PHYS_BASE_FROM_DSP_VIEW 0x60000000 /* MT8195 DSP view */ + +/*remap dram between AP and DSP view, 4KB aligned*/ +#define DRAM_REMAP_SHIFT 12 +#define DRAM_REMAP_MASK (BIT(DRAM_REMAP_SHIFT) - 1) + +#endif From patchwork Wed Nov 17 09:37:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624217 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 E0848C433F5 for ; Wed, 17 Nov 2021 09:44:47 +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 63D6961A07 for ; Wed, 17 Nov 2021 09:44:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 63D6961A07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 C73A61891; Wed, 17 Nov 2021 10:43:55 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C73A61891 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142285; bh=n46SpkoqjGTyC9qvu/jXeUwAMeZ+dak52xc6LV7soec=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=f7Elg/jEI2k7WKjgYjfMMK4BPd/Qls9RV3owK9QcCQMV4nRBhBsp+Q4GwGUGjALGc 5NGiyDCb9gze5Vq2bspsZ+v0Ca1V2kkuJ2Vxo6xQRzAS2AJ7X946IbMMkUHZu5MkG2 tGSU84SNcgWoU7Rz1ZP0e5MMjBGbRNoXSoplmp/0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3F480F805A0; Wed, 17 Nov 2021 10:38:54 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 42135F80533; Wed, 17 Nov 2021 10:38:44 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80073.outbound.protection.outlook.com [40.107.8.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 254CCF80507 for ; Wed, 17 Nov 2021 10:38:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 254CCF80507 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="WXKjgkiy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Opft1KRWgug+lbaeOgzvc1z9/rjMOseoxse6cOjaDcd98F/f1NVYS/G5HoPbLm34RdnJlUOLjryAE750RF/cR71YIUbRMUwXKHAMEsEnr5YNQte3Y/zy7X5yPAl9fZjAkGFeF/M5xe9dIAMtXojtQUJXECNNsY2NZPSyR7PBqpo25A+OXzzwlTkJrHndgttxASA+4gmvdYN7Xjt7Y/kC7n9r4ZS+23SSJbVa0+GXZuosj8cTLaT9UMo4KHbwOx2BmPpGZhvyxeydVsmUuVjC+ZcOGTczzEOarq31eZUiHS+bbh3dIBkBpt9yfFyxD0sVuYLUeCls6PMQ57uB+SW4FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K/TcaXutvCfzOqQoZbUtGznDhLVWnllTNgKTJn+BGJg=; b=HcxAZXbruEDLjRB8QvnmlA6K9LizPomKqCg5DQwARLBOJdifdvEP02eouov3S6qZcu5+pNB/jMTybtOgiLSY2ArosbZe9t9OnTlDbDKziCvyGw2GoaK2eoE04AXabVj3NxDU9/aYOaslSz8Jx1/CNkvvPJvTKDnVETwE5Z/xq/5X9P//RGcfQqmT/M+eHiuIg4qyuxYsoTpc/6VvQsSf1Vwf+VtLOmgDqdAIs2mTS8mmhTbpxrK8fEZygFkYdTAusTODgyfvRA6Go8NKuH8pwJxV2NbR9rav5uvM1hTBWzhHO5F1bXD82vzUOasjaf93jMRTyESiEUJnpZ0PlOj0bA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K/TcaXutvCfzOqQoZbUtGznDhLVWnllTNgKTJn+BGJg=; b=WXKjgkiy2iKDso9O9FU7yEcIPe+PICYMeClP7uCbPLn+K94BIxnKKO82l3JjrTaeLbW/CIbvRrcDpHvWnp9k7HvfmORyytY7rBtbBxL5hRsPI1Sl2UAnw9aVZTdqgjeeKsVEmdM0IIQukBFpIhtbz8ZUMBwig7/ImpnFSARM6PQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VE1PR04MB6623.eurprd04.prod.outlook.com (2603:10a6:803:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Wed, 17 Nov 2021 09:38:32 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:32 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 15/21] ASoC: SOF: tokens: add token for Mediatek AFE Date: Wed, 17 Nov 2021 11:37:28 +0200 Message-Id: <20211117093734.17407-16-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae85fa8f-1f72-49b1-bf05-08d9a9ae04e5 X-MS-TrafficTypeDiagnostic: VE1PR04MB6623: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HUNybBq2UX+pUGwBtip6d6eTmDoBTilcrAHl2d7aAIzJIF25g018Jn0pLqMXyfU9O1gRL+rIFAdksxjBU15mkFW4N0N/s3X5QrhsQOnZeUuSb8LJrRoWRH9whCtUAoeHTr6fp4iXnU4xiTRL0KFV1UTGnCyi98BJufISmF/VDRhUwzEOeliNlFtgsgdvNcorNimEhJhncz8+ghPTjmcWdEzQqFXqV5bdcCOsuiAG4kKzmjJNLcD4W85dQZbOFj+e2wcAiEGeE26PAGW6Oa3FmoSeu3099Tb1jB9w1OwS+8miE9p1Fb2+ZVjpqTtRl3hi5LlSo/3mbQbwZfxjVdm0x9bJawrvMawqL1b+1Lrq//g8LH7WsdWXznXNkHoSvFJfhnjSsSm/Tok7uoP/txosfRuYIojkrRUdlYiD2ihwnWn57pXOWHyCD/vmtXHAy1hBogE29B54OtXQn4VXw0hujERWYXNHU1RbXgYsUlmpMuEQmF7vcaECtieeNFNqIhJnXyBgPzX/GdkE4fRa64Vcv9zsVdUSnZueyBBf8amGm60jet8dceVOCSGk5pX5tS8dBPGbu/GoaGtHADjh9Wwmqr4dlhsBqT7qdflVD38CLlny6aUDU/rbYiR/PrPPj3verAgJVbnEvxKfx2GbC5yvcg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(1076003)(52116002)(6506007)(5660300002)(54906003)(8676002)(508600001)(186003)(86362001)(2616005)(6512007)(7416002)(44832011)(66556008)(66476007)(4326008)(66946007)(316002)(38100700002)(6486002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?aOattlQhSW7CjwWaE+kcUjsV6L/L?= =?utf-8?q?7C0q/OLVax/WF+Y4tG3zMftKltedkbb8ieQeT/IeEt5hqwK7Ma0trbDUnND9Fo4QM?= =?utf-8?q?4nYPXa+DxG5SU0FmuxmKwGcrUM1AyimO+p8ceE0aHZ2LcbhW9hWNVBr4kXcX7eCv5?= =?utf-8?q?6EmtEZ/1kp62OdrJynlns/G/MOB754uzRNIdiZuM8OM5SqX+dBqKTzCihFJTSkbv7?= =?utf-8?q?S7fTAJ6WOD6UoWw0RpqPINJaigSP5dgfx5/cqMS2cmN8y9wLuZEzjcarRnsw06SIo?= =?utf-8?q?hmhI2vRr0pKcc0Pxqz+7ZmMnFvFoZikWFS/WG7k5S5wr2Eezepgkmo/5M2BKrCDss?= =?utf-8?q?zllSGc2BvqnD4mVr8wt0j++gMtPoHz/d3YTOV76tPq79k5HgeQIkDopqUG41Rhcl4?= =?utf-8?q?MnZ+QmhQHwEXgfBp/yFlI9co+I/D44ssg8BPKY5aC2ubZAZoLy0GgSEAeGCX9g1No?= =?utf-8?q?Xdw7cyhhJ8uoIKiXZ9y2tqTNcmXvhYSUj0kfi4F/ZXMvp8CHImSMPFlR0fTzahNus?= =?utf-8?q?3kKpRSzkfzh6EWV4oEQ7LKoCI/CjBA0FhR7vxuzry/4FbseI+XD7GZd5UFn99VunH?= =?utf-8?q?llslGFztjXu7/FSbOEWPdZZg0YftW55VkakDn42ssZLb9IyKCLltoabJYKgTR8Qay?= =?utf-8?q?nieQI+TUDEgnUhL1yWyAsFII+sQoYa/yH+TKOsJRRPAmOc14C+MjBGl/in+QA/Vtd?= =?utf-8?q?nM7RWR+TidhPpyyoWysFzOqMXGM3DYEk/dDKeDKyc4CZk4ZVvJhG069euEQM8nEk0?= =?utf-8?q?LQ6d2XmNzK6OeWNx7pizNNjpapNtIrOSLP4TDSGyn8cGU+o2Ti4iLdRRTBLWFFj+u?= =?utf-8?q?L0Be+g3xdVdqdjUbPZoa/MAFULHAtSp8vcTsfrVnev5VAZZ/P0s1ROVCHn0Bvq1iK?= =?utf-8?q?SOApYtvwCw+ziH/VlfsJMZlmt2AU1r/GkkLkKJEQsrbnoRsPV5CarLSVLKPv3GyTL?= =?utf-8?q?WKz8Rcm/dlaMnbmzeRISt4JANWdnrWSHnh1juKn5WlpnZlS2IaF+PBDAh1JRPRg0x?= =?utf-8?q?Q7ECrERZ/z2IcPbUBx7+ASYGYCksav5cIHEs9LvAyTMcBZJLiyCcj6AgYGHAntjeu?= =?utf-8?q?oyBfdJKVzzoR4/GoOQV1hPDdFXcvirQDftSAmll//kTbDg+ijBQ7r62X1iIHCP6EV?= =?utf-8?q?mWq87Ui/U8PNo1aLkmOe8wLtYL4kkdjxOOeuMswTFYzXCTRU9jBM92URKacVhvSui?= =?utf-8?q?yHS1tW5wgNapoFdUX2D5SztPwcnITTOJSvHkIwtwmgxHu/2NBh4qDNQkSdymVjeb3?= =?utf-8?q?iygtyIFi/yPst3Tt1Pr6Eixu+2kBjymr3A4foyvFEDvBbC1YknhFbIx02k19A2OG1?= =?utf-8?q?cZT0oHcTTQDivSC2mJt+Qh1fwIPOI+8TTp7L5LCMirmyGVAlAAs6qM0X0kMTz6xn2?= =?utf-8?q?GnWpNGETky515UYUUTKa7cAY1XKBKT73nHJDtFnSgOzvV9c+CMdB9aYaR7ceUjRrj?= =?utf-8?q?gWn9uz55B4zSmYfFF4vFCn74gr0FjNJ8sZMniW5tqz4leDP8YHiqJVp2Fe6FQHXAl?= =?utf-8?q?lWsSmpiYmmI7gZSrS2I4eAQg9tOqy3IMxx3l8i4Z4mmcgD9kgutGi0wVfKmoU19qr?= =?utf-8?q?lsQOmgqwyiYrpBYUWJof9h3WC7Ofe6PFkoN1m5vSjpzfrFe9Gt7ES8=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae85fa8f-1f72-49b1-bf05-08d9a9ae04e5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:32.5622 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: I4mvp+Xn4t9ZMGrg3rnBKQlUq7lAybR3GERAyC4JS1yVFH4kuSzM3SRvJS9dywkJuJ4YmlFRRDZEqmaqLHRx5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6623 Cc: Guennadi Liakhovetski , daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, =?utf-8?q?P=C3=A9te?= =?utf-8?q?r_Ujfalusi?= , pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Ranjani Sridharan , Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.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" From: YC Hung Add the definition for Mediatek audio front end(AFE) tokens,include AFE sampling rate, channels, and format. Signed-off-by: YC Hung Reviewed-by: Péter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Kai Vehmanen Reviewed-by: Guennadi Liakhovetski Reviewed-by: Daniel Baluta Signed-off-by: Daniel Baluta --- include/uapi/sound/sof/tokens.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h index 02b71a8deea4..b72fa385bebf 100644 --- a/include/uapi/sound/sof/tokens.h +++ b/include/uapi/sound/sof/tokens.h @@ -140,4 +140,9 @@ #define SOF_TKN_INTEL_HDA_RATE 1500 #define SOF_TKN_INTEL_HDA_CH 1501 +/* AFE */ +#define SOF_TKN_MEDIATEK_AFE_RATE 1600 +#define SOF_TKN_MEDIATEK_AFE_CH 1601 +#define SOF_TKN_MEDIATEK_AFE_FORMAT 1602 + #endif From patchwork Wed Nov 17 09:37:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624221 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 2DDE9C433F5 for ; Wed, 17 Nov 2021 09:45: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 9E8DF61A07 for ; Wed, 17 Nov 2021 09:45:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9E8DF61A07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 0C0E6189D; Wed, 17 Nov 2021 10:44:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0C0E6189D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142320; bh=s27WKQAzY76Gi67Cd9Uo7yOykv1oZbEFy7cbeF4S8B8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=JMGRqUZMWevBK10zfndqUWIXrlB7D9Oi+oRVQiFO+32QG6gyworjrNKDLyHj7jCZB j5b6OfTyIi+BghVgovUMTUodhphDwEIrAZqkXwuRLIjcCI37LD4acswCqZ77WTmKnk aAYRi79nrbZSj8LViZYOovFmd2c7zoxb+fPNShFQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C8745F805AF; Wed, 17 Nov 2021 10:38:56 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 871EBF8050F; Wed, 17 Nov 2021 10:38:44 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80073.outbound.protection.outlook.com [40.107.8.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 50CF1F8050F for ; Wed, 17 Nov 2021 10:38:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 50CF1F8050F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="VnUk10km" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CIYpnabFTKUcR9MhHt0uUUSjw0TQEwf7/S2qEoLmefcMH2ENNcO5cbMVNIGh/eP30IpC69NUaSJ62dOdMM5mQZ5UVH7ZNKprD42j4D0v5+0fcKAWXkNvJVXPGfUoV8xocAh2sJ0s49N7Zj3hWE+aHaqIb8/vqMg61h3yqusCapXnXcW0QFWZOq9tPc0c/5VOsLyZzaMkHs2SMUQKrzGwAVk4cOzXEhDHA5zZs8bvCYlXDvFRkACrq+Fes8I25Rt/iA0QHSi9kByBVo+9gVWxzoAqgH5rTQ0NlF7p7y+P8tA9EmQz2SjDCAbYP3NlcFu3im4M96etIvzohjBol+7Jwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lcbOQalXySIAbgXzXcklFelsLSCQ8XryxySoOXJvAdo=; b=JQQH7+Cly9fuqqAJWy6LtW0Mx+ehF1QdAVB9Y0+gYx0MCvCqMsulc1U7jZgd/MI7PPd507kvkxDXQhUg3r0veoyooXiPIJOMBeC1cAdQOpeUAPNJwe+8OYQxarBW6ClZXFrT8TpDoI7SwCkFqvMxsQr7PhZFctXfZy0tLMFr++Bb/cAAUxuBYNf/9EWLRa5uxuNP3Pf7fpBPOWlN+knQrx72Qja6lswacyFa4qfLyyg1CJw13Dk4BcvbBVCLXkHmpADTusHxvT+krjc9gKVGSUfRrOIEN+2GBXOs+5YLBis61+3FStT3hB6+3vNlccmBeILrM+dbr2ltHhQK72ANhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lcbOQalXySIAbgXzXcklFelsLSCQ8XryxySoOXJvAdo=; b=VnUk10kmBw26d4QlC+fghob3DEysts7Nyo0QshHsFQVLYuXVAXVf+wu13yPUqVmcceXo1rg7Naxuat/yLE2tl1dubgwqcw/pQzZ33WcJ574S46eoCMukmDUVh+VbqZ/+jbO7tgBGuGwUuXR0jzyJQZc5/9idEvzZsFvsjEGnn04= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VE1PR04MB6623.eurprd04.prod.outlook.com (2603:10a6:803:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Wed, 17 Nov 2021 09:38:34 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:34 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 16/21] ASoC: SOF: topology: Add support for Mediatek AFE DAI Date: Wed, 17 Nov 2021 11:37:29 +0200 Message-Id: <20211117093734.17407-17-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a94991d6-2914-4e33-f9a3-08d9a9ae0639 X-MS-TrafficTypeDiagnostic: VE1PR04MB6623: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:608; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: urFpllXah3h1Eb8RGYU7Ua9uMDRPOiE5WEr/Jw1DwOSPhF0qvDZrSQol+ImrhlofAe+PHNeVedOao338+2MQlrWqXPBU38NSOzZ2e8F+rX/D7DWx5ciD8T05g2h4v56ebLxDlSJiPPiD/VNHl5/CO6T87XSXfXz9DDJNKO6FSQNpNjVBNFGYhtslugr4e/a94t87TCC9KSNFjrHUh+t6UjZ4+6IF60ZnGknc/M55vi0AbgoIcwNJv9OcxufunvF1XS+J5S/JCYJjaTUTkipbB467DlopUnCMvzFmh//3ncOHSJ4Yjoa59aare6Srh1MfJDIPhVOoVUaRP99PV+Q5cX13LsZufvmyOIpS4+RsQx8MeCuiGc/OlraqrAy51NpGUKTouA8ECi5+ne/BLW5UX1PCDHHRwAyehzIhElvpm8udbAZ6NJwDa0tM/gK2KfEHQmNb3oEjfY1i7/xGDY4WKo8WmgqTbf53si6Ftrg220OeGEQ7vT+XB4zDybGCDLG+GuUb3FPKpTc3VUlhTDJTunvU5oL4opsMkHV3qMeU4UCMHh1+UwbtIfyEVl8LnOZIdgWZtTGJlUrdRY9XwllZ/P2IP4veE6YecE7bnUdO6wo/yBTeuiXHIXhe+Qi6H6wkv9sv4z9QIkVPoeweEHNhZw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(1076003)(52116002)(6506007)(5660300002)(54906003)(8676002)(508600001)(186003)(86362001)(6666004)(2616005)(6512007)(7416002)(44832011)(66556008)(66476007)(4326008)(66946007)(316002)(38100700002)(6486002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OV+ckeINd9EJBF8iYPVD2UNSOeFr?= =?utf-8?q?HY0nhXXEO9kgjnOvH6nFSxeOGg6sLZdjfxIoyzHjCU0jRsFdbsdpZLbKO2frNg5eC?= =?utf-8?q?f89owNtnT1GSu5HFvGRBADdOHZTVRbWnapDj9kHeIB6VQgTW8Af0koIZQP9foJlOK?= =?utf-8?q?W6UrBDYCFSbq+/vftOunp044I+V47ymgvhEVCwDntsCw4GO/2jHQql9sgmW+IgB+z?= =?utf-8?q?liisADwLWi5vx7pNx8OdTVMnGcSACHxYkcQ0fC+IyPrnCQEtZ/WM0oIaZ+xcgqVe0?= =?utf-8?q?c6wdde+jp2+k2KlMJ/lE1RrNUnyEGkHMvPnQLAQgcztOYDBG2qjCIAPY2VMQ00i+O?= =?utf-8?q?3fsFzB3Jm+3NILUG+wugW+IgDlpvF6/q/dk647YcoIPJ2a2oDRgwR5Nf96BT1ca4U?= =?utf-8?q?2SbBfoG6R+LVI8UU1pwK4wFPUyYJwuYlcSo0Zk+9DN0P/f6s5Ph7XvpeoLSa+lG+z?= =?utf-8?q?VgtpwWG+ccdN2pnrz7PBN1SNBUIQm3G72DBHx4Dy+ADRBvS7nxDzcfqjTDqvuHq4X?= =?utf-8?q?TdXtux4Q2Y+VKriUhsUpjWbw0F8K2JterZZQKF47JtahZifcwlJC98sVvYu38WMMS?= =?utf-8?q?D3CSiMBB95pBJLdh1H6uGlwrbv334GMEvXxYEuifLxH1/JxBjXYr8O+DyhsCJQHER?= =?utf-8?q?EDckINbucXq6KFFnZAoKJniAPKsdXJhjvi8Uk+lQH//OtMQQdknxSmOjX6BzP+DWi?= =?utf-8?q?z3H0UQa6KXnHRatYSkYIVNaXn7E3Zv33Ods1eRYDvkqQf9YZYh24rZ/NaJ6Ba3LlY?= =?utf-8?q?4T+jIlHwzOw0TWoAkp3ybCwz10WtW5f3S+RBoR1avxCQ8OaTodoYohLlDzWsdZC0E?= =?utf-8?q?MbtaJiiuZdCQWZ3cy+7pKvxIUuVemtcMI7FqQOOE3+yNWGSg4zoq6V6+gBF11r6UX?= =?utf-8?q?ILP16HaLj+OqGHUNpqyvfEtKoHIbqv+aak76kPVWzWC+cBQKYCQBhrPqa83Y5bkrc?= =?utf-8?q?XaE735pPFFxMFIcTKqGfY7xFJMXPz09xoIvOZxcLhJRbQqDQ1jE6Uu0I8A6vxeEwK?= =?utf-8?q?Cm5wpDSm6ub6YmgdIYFDW/qPRrslwa494z+07gIlh6WXiGIXX7W0a6SvuUDlyMxkB?= =?utf-8?q?opn1FaOxgODOgh3PQDsi9+W35dh4H6oVCr0o18esoyOc1l2B/9zhffilxDaR0vM63?= =?utf-8?q?8fvEx+eqcgLxmZWkEOwGsl8NEE44PiLSuuKaKYOUqKv0uNsonsKVt3B11YXP7/SNw?= =?utf-8?q?kT9pvkcrMAZ6ZL1pHxaOrigefUmZ8gQaidTpecIW6Pc5SU5fMpoXeqDl51NfFLUbL?= =?utf-8?q?BPT3L/BUQF7+NCP6RSU3ogPC1bo33QgyzmTLvPgjlS3Mmsg153eMMIdgg3NOxRSrz?= =?utf-8?q?hi4w5ciCTB1RfYJ2FmxOahs2osyAleRJXf8kU1NIlN/YnQDyd+QQ5LPqcPFHY2JLo?= =?utf-8?q?3GqJTbBL9B2zTMcvtGhD2OXf8oMdgNhK/1e4eO8VGSK+hTpAeRdiCswmvlrrzSNMB?= =?utf-8?q?mDZu5JY+EdujvvW1XMQEMuABssW4Sw00zBTyjkYAcxR7QHAyFvc2QGZksVwji9ETl?= =?utf-8?q?2Ad05ugUplMqlLU9AHRespiiVjh3FmJ7ThXIpvN5v4hmiIHKG3M1w6d8JzVeohENI?= =?utf-8?q?U4/g/BfN9kskA6D7BBAS6eNahaA4f1IrjEZcOuG87N9OC+I77oJw5s=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a94991d6-2914-4e33-f9a3-08d9a9ae0639 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:34.4741 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CQx2jjLKHBIVmYXe/MO/vxF+VIYzhyh7eQ6tfFxtUcajLhtT/mxdENogKjcnO6mjRwIJ9/iTQ5QpPNIRB9wyng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6623 Cc: Guennadi Liakhovetski , daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, =?utf-8?q?P=C3=A9te?= =?utf-8?q?r_Ujfalusi?= , pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Ranjani Sridharan , Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.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" From: YC Hung Add new sof dai and config to pass topology file configuration to SOF firmware running on Mediatek platform DSP core. Add mediatek audio front end(AFE) to the list of supported sof_dais Signed-off-by: YC Hung Reviewed-by: Péter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Kai Vehmanen Reviewed-by: Guennadi Liakhovetski Reviewed-by: Daniel Baluta Signed-off-by: Daniel Baluta --- include/sound/sof/dai-mediatek.h | 23 +++++++++++++ include/sound/sof/dai.h | 3 ++ sound/soc/sof/pcm.c | 12 +++++++ sound/soc/sof/topology.c | 59 ++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 include/sound/sof/dai-mediatek.h diff --git a/include/sound/sof/dai-mediatek.h b/include/sound/sof/dai-mediatek.h new file mode 100644 index 000000000000..62dd4720558d --- /dev/null +++ b/include/sound/sof/dai-mediatek.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ +/* + * Copyright(c) 2021 Mediatek Corporation. All rights reserved. + * + * Author: Bo Pan + */ + +#ifndef __INCLUDE_SOUND_SOF_DAI_MEDIATEK_H__ +#define __INCLUDE_SOUND_SOF_DAI_MEDIATEK_H__ + +#include + +struct sof_ipc_dai_mtk_afe_params { + struct sof_ipc_hdr hdr; + u32 channels; + u32 rate; + u32 format; + u32 stream_id; + u32 reserved[4]; /* reserve for future */ +} __packed; + +#endif + diff --git a/include/sound/sof/dai.h b/include/sound/sof/dai.h index 3782127a7095..5132bc60f54b 100644 --- a/include/sound/sof/dai.h +++ b/include/sound/sof/dai.h @@ -13,6 +13,7 @@ #include #include #include +#include /* * DAI Configuration. @@ -70,6 +71,7 @@ enum sof_ipc_dai_type { SOF_DAI_AMD_BT, /**< AMD ACP BT*/ SOF_DAI_AMD_SP, /**< AMD ACP SP */ SOF_DAI_AMD_DMIC, /**< AMD ACP DMIC */ + SOF_DAI_MEDIATEK_AFE, /**< Mediatek AFE */ }; /* general purpose DAI configuration */ @@ -97,6 +99,7 @@ struct sof_ipc_dai_config { struct sof_ipc_dai_acp_params acpbt; struct sof_ipc_dai_acp_params acpsp; struct sof_ipc_dai_acp_params acpdmic; + struct sof_ipc_dai_mtk_afe_params afe; }; } __packed; diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 8d313c9862cb..31dd79b794f1 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -808,6 +808,18 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa channels->min = dai->dai_config->esai.tdm_slots; channels->max = dai->dai_config->esai.tdm_slots; + dev_dbg(component->dev, + "rate_min: %d rate_max: %d\n", rate->min, rate->max); + dev_dbg(component->dev, + "channels_min: %d channels_max: %d\n", + channels->min, channels->max); + break; + case SOF_DAI_MEDIATEK_AFE: + rate->min = dai->dai_config->afe.rate; + rate->max = dai->dai_config->afe.rate; + channels->min = dai->dai_config->afe.channels; + channels->max = dai->dai_config->afe.channels; + dev_dbg(component->dev, "rate_min: %d rate_max: %d\n", rate->min, rate->max); dev_dbg(component->dev, diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 72e671c15a34..10caf2b1a33c 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -379,6 +379,7 @@ static const struct sof_dai_types sof_dais[] = { {"ACP", SOF_DAI_AMD_BT}, {"ACPSP", SOF_DAI_AMD_SP}, {"ACPDMIC", SOF_DAI_AMD_DMIC}, + {"AFE", SOF_DAI_MEDIATEK_AFE}, }; static enum sof_ipc_dai_type find_dai(const char *name) @@ -806,6 +807,19 @@ static const struct sof_topology_token led_tokens[] = { get_token_u32, offsetof(struct snd_sof_led_control, direction), 0}, }; +/* AFE */ +static const struct sof_topology_token afe_tokens[] = { + {SOF_TKN_MEDIATEK_AFE_RATE, + SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, + offsetof(struct sof_ipc_dai_mtk_afe_params, rate), 0}, + {SOF_TKN_MEDIATEK_AFE_CH, + SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, + offsetof(struct sof_ipc_dai_mtk_afe_params, channels), 0}, + {SOF_TKN_MEDIATEK_AFE_FORMAT, + SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_comp_format, + offsetof(struct sof_ipc_dai_mtk_afe_params, format), 0}, +}; + static int sof_parse_uuid_tokens(struct snd_soc_component *scomp, void *object, const struct sof_topology_token *tokens, @@ -3091,6 +3105,48 @@ static int sof_link_acp_sp_load(struct snd_soc_component *scomp, int index, return ret; } +static int sof_link_afe_load(struct snd_soc_component *scomp, int index, + struct snd_soc_dai_link *link, + struct snd_soc_tplg_link_config *cfg, + struct snd_soc_tplg_hw_config *hw_config, + struct sof_ipc_dai_config *config) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_soc_tplg_private *private = &cfg->priv; + struct snd_soc_dai *dai; + u32 size = sizeof(*config); + int ret; + + config->hdr.size = size; + + /* get any bespoke DAI tokens */ + ret = sof_parse_tokens(scomp, &config->afe, afe_tokens, + ARRAY_SIZE(afe_tokens), private->array, + le32_to_cpu(private->size)); + if (ret != 0) { + dev_err(scomp->dev, "parse afe tokens failed %d\n", + le32_to_cpu(private->size)); + return ret; + } + + dev_dbg(scomp->dev, "AFE config rate %d channels %d format:%d\n", + config->afe.rate, config->afe.channels, config->afe.format); + + dai = snd_soc_find_dai(link->cpus); + if (!dai) { + dev_err(scomp->dev, "%s: failed to find dai %s", __func__, link->cpus->dai_name); + return -EINVAL; + } + + config->afe.stream_id = DMA_CHAN_INVALID; + + ret = sof_set_dai_config(sdev, size, link, config); + if (ret < 0) + dev_err(scomp->dev, "failed to process afe dai link %s", link->name); + + return ret; +} + static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, struct snd_soc_dai_link *link, struct snd_soc_tplg_link_config *cfg, @@ -3386,6 +3442,9 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, ret = sof_link_acp_dmic_load(scomp, index, link, cfg, hw_config + curr_conf, config); break; + case SOF_DAI_MEDIATEK_AFE: + ret = sof_link_afe_load(scomp, index, link, cfg, hw_config + curr_conf, config); + break; default: dev_err(scomp->dev, "error: invalid DAI type %d\n", common_config.type); ret = -EINVAL; From patchwork Wed Nov 17 09:37:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624223 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 D4C52C433EF for ; Wed, 17 Nov 2021 09:45:54 +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 595DB61A07 for ; Wed, 17 Nov 2021 09:45:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 595DB61A07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 C8521188B; Wed, 17 Nov 2021 10:45:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C8521188B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142352; bh=pj1n55cUazJIaQ0JVm06ysLOm6iTbrTmd5zdWZfNV7E=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MYFHpUvoEKZFQJ8IPgfU8lfZYS+ft4Sm0IG/erhIiSAVgl4MiNUVV75pNQpCmEdoR MIJvTf9IiVYAcULU9zeRpbPTpZhynt6PT2nMzzp14944q67qq6S1vPEoU5Yckd5fOd SjmA0HTlDdAlVL+RgsIuAUJAaoWYTOnQ64e8JqaQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 27041F805BB; Wed, 17 Nov 2021 10:38:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5FBD2F80588; Wed, 17 Nov 2021 10:38:51 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20615.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::615]) (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 B6A0AF8055B for ; Wed, 17 Nov 2021 10:38:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B6A0AF8055B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="IYgNiZdj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IATM/a3SxjyiPOC4YS0ydwfPxklZmvXxEq8I5Ww3oZlFOtF9XjFI2p+FK4fsunF+gILp7/phAaEeKAeVQe3QWMghDok9A7p9aGScRq9O9VvygK6GCPzkeKMboh69mBtimlF6cnQrf1ffl6C65ESrfT/Lt0HURpIXf/AmPN7ILViJc6TXfsxYjLOyvxyObPhynjANWxvyAavNKd1RwD6FFS5zCsE56d090bVWi07IinIy9csIxwZMLrnHL92MX/3OTvPgxPMPLgdkJDkk2ZjXjeej2+2mi6LJZFuoXvd8AmcnZ7VRgMwlatsdWyFIXGqRtP7ynMMsdSIl3aiohKJjDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9AVYMsqdqT5aML5ASjU1X5aJtq7rcirF8wH6DONBBzQ=; b=JmDNoEryvPFZAs5wXjT5Febf9C9B4kUgm16h+nEdP8RY3H3nJZ1QJmQxqP28Vxa2RrYUBSPORujZx4C4qyAWdq9YkAA7U2h2nriS/uESgXBedi+lbOYEYdQMsWsSRXLZF1/tPRp3EnPD9pO+cC0G2K2FRlaUnBd0dQoecrd5nsEvzs3uznvwN5PaOacOIzFm/J+C3apvFXIx1ELJ61qKNt70+OBVL0AKMZuEa1iM+xNJNDZNtIgg5QObUnpMEdhNIAZESMDfXns+rZPUAvwKzzvdfEAGWijJ4dRQWLEB+1WQMNBhvEzybF9bz8e+xhMVUKm5l06eSv3pVtx9ttOCfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9AVYMsqdqT5aML5ASjU1X5aJtq7rcirF8wH6DONBBzQ=; b=IYgNiZdjv6oxwKwjKQXV+xWQqPvUi4d5wW6zT90abbI3QN+iTnGOeJQDvxO4zO1kXo4VrnC9RQPI9ulzgS4p+vhMYUzwa/fSxQDBtYuwViqAjoIyJkKAiNu64BbqC1xHHxnTfYecEZ/sR6fH4ex6byL6WCiHAAGdYVM0mNReNO0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VE1PR04MB6623.eurprd04.prod.outlook.com (2603:10a6:803:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Wed, 17 Nov 2021 09:38:36 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:36 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 17/21] ASoC: SOF: mediatek: Add fw loader and mt8195 dsp ops to load firmware Date: Wed, 17 Nov 2021 11:37:30 +0200 Message-Id: <20211117093734.17407-18-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 49bc8cf6-098a-4eb1-f4e8-08d9a9ae0775 X-MS-TrafficTypeDiagnostic: VE1PR04MB6623: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8Zssx2x38gZVAe6zZj6cLZ+a9zFTMRQlInkH3mvO049NZhrK7RgwKE+R7sKIs3NeoxX70TzlupTk6+slgYAVSh3fwYb0Jm2rpm4zOc+RpLR+faj1PPzeU+tFCERPe5t3QISylWZD2IzqiHk/JTbrhIx//DvLo3sMNEtwQhPoafoFgCLAAnIEkRJ0uiKkJc9D9Lj6wRU7bMn1NpBVliOMhI3YPUMaLQkIokrm9iEEp4aT8P+RXvE631FauponxAcxlO2Y+riplRCiJo2FdecMShc29VjNQQ0EQQ4YnDct5L628sFinYOqg7+lMaOPrnIgZWLuFN8AQqzpJF//lVI6WA4rFaurZGEdcehb7ACfEO3WaDPUCkWe1HqH82wKJQSsAWYVGJaT316IEGgnFp+X/DY+xBTXa4DDE5911xEtsdMFIVi+rHjpyYnSC+mixsUYQQPP5K1Lnfa0B/RB/UTsX4g1cs+psgwuiy/FtrEf8aoZf7Tg/3w09mRdgX+IMP5OsctU1HOR5TYS7/OFdOcwJn/2ttzjnLe3wx4stBU9qos8ac3OqdP6OAHpaP8Y8nkrqxatGGPO82pP2N3T8vdRRrE2LekkOv+XITfMNIYhXCFpyo5ITIvuFNM8f9H3aUI2diZBGN81LKcPKsjEc0GRjQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(1076003)(52116002)(6506007)(5660300002)(54906003)(8676002)(508600001)(186003)(86362001)(6666004)(2616005)(6512007)(7416002)(83380400001)(66574015)(44832011)(66556008)(66476007)(4326008)(66946007)(316002)(38100700002)(6486002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?aNFj1oWwDdju3lXhkzdeEhM0xs7z?= =?utf-8?q?8iU2fbLGAm2ckzrkR9rwJ0OTKFZ40NhkTKwmpwF9ERUVYZ6G19ZXBs7wXmCgactQV?= =?utf-8?q?YaEzFdCqYyDQBU6eD/7+DJDpgut1ECZR2OTgFEYAfLKjdPiT9MAAelmVX/LjJHbHP?= =?utf-8?q?X8cJ/6KXoUlsihkDGfzWJaQPExANeXDnzSzSJx1S3cCohgdnX+YlfJBiQ4xl9sn5w?= =?utf-8?q?PD9B1698DCGxParRiymxEgHrBVIohfZ6Kk/FLOm6MgnyaCVJGQ3ZPuYxz1eRQL6Ge?= =?utf-8?q?iYpPCxl2WpVMSGjEnO5OgQ6CwUg0YlSKh1QcWB4cJax50A2TFdO35DqBqG8dh6hky?= =?utf-8?q?CUl/Pk58qxogFzrMisEv28DptKs4z5w+h2PScmgvuU5xycuZSHO9hRH9PLtSjrtaL?= =?utf-8?q?jAf9rL7BtL0qMqOziDm24GERMRCz3JKmZwADwZ3fbCcGZgO6o+zQMTC4qU/Zw4qhO?= =?utf-8?q?zJXatYNGZrWyqkLppCpCRVUuwzbZ/gD0Zlm6KcGcPiHQLFhpOM9vObW8EBocg6TMB?= =?utf-8?q?nziyhNocG6UkPEafSzEluh4YHms9jC2U8Pr8xZ5emNBjKzXfRokEGgnNuWCR6kQgy?= =?utf-8?q?0dbQr9yDqDaFYu6pb5rMiBRJepXAiw7OfwK+ODp+igAL7yv0SRd/JXyWQBDdP9DEE?= =?utf-8?q?YfVVDEMqMbPfo0C5mWpR8eKIN5SF8EAaLvYe/snAd4Stp4ZYaBz+TXHOezy9AFYTm?= =?utf-8?q?X5lYJABu6OSBhZ6gZ+BsPXTAfrc2JM+ll2xaYd6vl2zWtzLWuZzfWtRtZnpfw6Bcv?= =?utf-8?q?gaCSDZQ/620TRNO6IQNxTTKXF3FbTZt6Y5275uE9JjijdQ884zGNnUoVsptNjoCcn?= =?utf-8?q?VaENEytjqJP9JKv4i6cv6jHkaI4xbxIux/qKalKaKvb8qWaGs3kgJtSP44NvwfKrL?= =?utf-8?q?esSqFIAqMO0psdueZQXkX3Jkd9urQ2cPVZToi++Cqp/zhbBvhUa8g8LPsEKPFXOlz?= =?utf-8?q?niVRgU01t3avJhPBifESJbAkfW8UlOZTjH5tJQHja8fvdU0lxIxL5wN6q+mEYUX70?= =?utf-8?q?Ot+JmHhHRoPB5WmL6cvaZrCW7jvoPoDBVedCeIkhO87HWIuEAzrNHxKRVvSSu2x+A?= =?utf-8?q?kNFIw8dGRYjEnMFARZMwUIfzpja7Ur80TlZSS+VhdjzSRSP+ISIWxFZZgO9j8D8Om?= =?utf-8?q?JskhegK89PJrf65PcYvROSVl4Fn92FwqhxEEjJthhWjppLY8bYXFklpBq1n3oxdhm?= =?utf-8?q?DsSujucoXsxCk7u91BP1VewmUkKblPcPOQPvkyd1RhF1weLFau8NqjBLEghNw/J5l?= =?utf-8?q?pQT1AXozQwilhy/R6oE7yN9XyWsIGDm8EIWU5PrZLtpfR9zYClf4r6L6tCwrJ7iDx?= =?utf-8?q?D+l0HAFPKorMdFZ+lY5MprRGpJUazaeXa6M8S6HaQ5HNxF2vEWytwVHjzql37Cc3P?= =?utf-8?q?PeW1e7jDSREInVHs/l2PWBWd91F+lw1YlHsdb/UP3mnCMTK/pRC9rITkcXcnrCriq?= =?utf-8?q?MjQeJE+rU09j/D1zE30hceo9zWGIRW++VhGcIM1O2cMKMrh8L66Gchg/Ps9zto8he?= =?utf-8?q?kirG09H8dBH9lh6CPyWAteLCVONF2E33UZsR+KP1aD5GZFgECD35mHhwNlz0OWWtJ?= =?utf-8?q?wjLrB68UcpcDV+T/iFTHuA3undb5kXd7XX6d3Ka4X0ba/ArpVYEyHc=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49bc8cf6-098a-4eb1-f4e8-08d9a9ae0775 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:36.6639 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WP9tkuGD0GuMz45ibjLTmWQEoLuRtSN+bp4e8jSdsfEvGtTQBGppIlZ4IehNr+fDEo41S37jZu/i1GR84gijMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6623 Cc: Guennadi Liakhovetski , daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, =?utf-8?q?P=C3=A9te?= =?utf-8?q?r_Ujfalusi?= , pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Ranjani Sridharan , Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.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" From: YC Hung Add mt8195-loader module with ops callback to load and run firmware on mt8195 platform. Signed-off-by: YC Hung Reviewed-by: Péter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Kai Vehmanen Reviewed-by: Guennadi Liakhovetski Reviewed-by: Daniel Baluta Signed-off-by: Daniel Baluta --- sound/soc/sof/mediatek/mt8195/Makefile | 2 +- sound/soc/sof/mediatek/mt8195/mt8195-loader.c | 56 +++++++++++++++++++ sound/soc/sof/mediatek/mt8195/mt8195.c | 8 +++ sound/soc/sof/mediatek/mt8195/mt8195.h | 3 + 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-loader.c diff --git a/sound/soc/sof/mediatek/mt8195/Makefile b/sound/soc/sof/mediatek/mt8195/Makefile index dd2b6e4affc9..66cdc0e7bf3c 100644 --- a/sound/soc/sof/mediatek/mt8195/Makefile +++ b/sound/soc/sof/mediatek/mt8195/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) -snd-sof-mt8195-objs := mt8195.o +snd-sof-mt8195-objs := mt8195.o mt8195-loader.o obj-$(CONFIG_SND_SOC_SOF_MT8195) += snd-sof-mt8195.o diff --git a/sound/soc/sof/mediatek/mt8195/mt8195-loader.c b/sound/soc/sof/mediatek/mt8195/mt8195-loader.c new file mode 100644 index 000000000000..ed18d6379e92 --- /dev/null +++ b/sound/soc/sof/mediatek/mt8195/mt8195-loader.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// Copyright (c) 2021 Mediatek Corporation. All rights reserved. +// +// Author: YC Hung +// +// Hardware interface for mt8195 DSP code loader + +#include +#include "mt8195.h" +#include "../../ops.h" + +void sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr) +{ + /* ADSP bootup base */ + snd_sof_dsp_write(sdev, DSP_REG_BAR, DSP_ALTRESETVEC, boot_addr); + + /* pull high RunStall (set bit3 to 1) */ + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW, + ADSP_RUNSTALL, ADSP_RUNSTALL); + + /* pull high StatVectorSel to use AltResetVec (set bit4 to 1) */ + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW, + DSP_RESET_SW, DSP_RESET_SW); + + /* toggle DReset & BReset */ + /* pull high DReset & BReset */ + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW, + ADSP_BRESET_SW | ADSP_DRESET_SW, + ADSP_BRESET_SW | ADSP_DRESET_SW); + + /* pull low DReset & BReset */ + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW, + ADSP_BRESET_SW | ADSP_DRESET_SW, + 0); + + /* Enable PDebug */ + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_PDEBUGBUS0, + PDEBUG_ENABLE, + PDEBUG_ENABLE); + + /* release RunStall (set bit3 to 0) */ + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW, + ADSP_RUNSTALL, 0); +} + +void sof_hifixdsp_shutdown(struct snd_sof_dev *sdev) +{ + /* Clear to 0 firstly */ + snd_sof_dsp_write(sdev, DSP_REG_BAR, DSP_RESET_SW, 0x0); + + /* RUN_STALL pull high again to reset */ + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW, + ADSP_RUNSTALL, ADSP_RUNSTALL); +} + diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c index 945601a0dc37..88da6c2de070 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.c +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -305,6 +305,9 @@ const struct snd_sof_dsp_ops sof_mt8195_ops = { .probe = mt8195_dsp_probe, .remove = mt8195_dsp_remove, + /* DSP core boot */ + .run = mt8195_run, + /* Block IO */ .block_read = sof_block_read, .block_write = sof_block_write, @@ -318,6 +321,11 @@ const struct snd_sof_dsp_ops sof_mt8195_ops = { /* misc */ .get_bar_index = mt8195_get_bar_index, + /* module loading */ + .load_module = snd_sof_parse_module_memcpy, + /* firmware loading */ + .load_firmware = snd_sof_load_firmware_memcpy, + /* Firmware ops */ .dsp_arch_ops = &sof_xtensa_arch_ops, diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.h b/sound/soc/sof/mediatek/mt8195/mt8195.h index 48cbbb5aacb5..929424182357 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.h +++ b/sound/soc/sof/mediatek/mt8195/mt8195.h @@ -10,6 +10,7 @@ #define __MT8195_H struct mtk_adsp_chip_info; +struct snd_sof_dev; #define DSP_REG_BASE 0x10803000 #define SCP_CFGREG_BASE 0x10724000 @@ -152,4 +153,6 @@ struct mtk_adsp_chip_info; #define DRAM_REMAP_SHIFT 12 #define DRAM_REMAP_MASK (BIT(DRAM_REMAP_SHIFT) - 1) +void sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr); +void sof_hifixdsp_shutdown(struct snd_sof_dev *sdev); #endif From patchwork Wed Nov 17 09:37:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624225 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 A5704C433EF for ; Wed, 17 Nov 2021 09:46:12 +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 1F4ED61A07 for ; Wed, 17 Nov 2021 09:46:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1F4ED61A07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 82C921852; Wed, 17 Nov 2021 10:45:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 82C921852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142370; bh=+miEE1w8A+K2efniUh/mVep9liVka0VJW5pVL5AxLsM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GBmeQHv8YRbjU8HeMempsLqGfwd0KjZRct9zoNXUTuJsB/4o/0jdFQswjaeoS6TdP oCVciDV0PHvMvjpcQbq+0JNR5SGQIIXlmosN7HJlJAqCNL05M0b93gsjFWkyUW/AT/ vlFuAhxrvDTWHAhmMVu78LEdNET3BFi2seP2SVQc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D22E4F805C2; Wed, 17 Nov 2021 10:38:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5FCE6F80588; Wed, 17 Nov 2021 10:38:52 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40061.outbound.protection.outlook.com [40.107.4.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 77C67F8054A for ; Wed, 17 Nov 2021 10:38:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 77C67F8054A Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="bFfqewI+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eVRv+pLB+lmzHBE0hz2fIlKWhVsZbOH5p+szjGHPWgIZvkH9m94UBcNol9nxQNfGjTvOWlw/RV+v2sSD50/IB5cR0Pi1Gct5Pze49kSSCtYw1EapB/Q3YlRN3m5y3+wy7LzBYdB5xychSy1IXY+YBMQ6I5RyzYhUD46YjofwY1pdA3X93UyJrmWTrnlwLYyqxupToPVP78hKYUhBrEy6bqOAUqg509oTE/oL0ZlqjXl9WTWUX0AxVoomYwwZh9ADcQJIem2nPWFGfYZlyRMpKgUNyhu0Dhh8UphrlAcL9M/h/isAesajDKe65+nWpvDACcn79BRgM+E8de7NzHuevA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7UjjWQcQXj7lwzktA08w1ckpS4ND2jsRngX7+9KTay0=; b=lqh3b4nejQAIOK7w/aNLCZxoe04aGW+a9WoUsyCPp5B77xIlaRxTR3RO8CJMoarQd/cIEmbhGY0qr1JUVDvvKYjzMpUP8wSezRaoL+gaLi4rkshGfAyVLzjKA+mRZGurmo5roL5jYP/2WQCR2V14utTOabzjXYbMMWo1JPJvWrQZtvLupX1xYAo7BRscs2+1NBO3VFTnqthYaFPDnUlv8OKzPxV5A2McEgZyLwPLBy4oNdPRR5yXbv2WevCNli4m9HIOlbCrfuSISVNkq7IPEuY6BTI0oawvPjMhy+c5QYDZP++rbs889zNnWAOEzo3Rol14YAG0zcsW7jqc8WWaow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7UjjWQcQXj7lwzktA08w1ckpS4ND2jsRngX7+9KTay0=; b=bFfqewI+pE5sHtIuGSTsAXaPQ+8gSJexSo7Efnz815KzoidXYiNJe0RHe0p4H3mawwheE5JQw/rKDb/KrjdOK1Kk3/qOirp4FUDOsMQF1FvPbDmFyNwj2ely8qnId1eh2ktZoLibQMxTffPOEoGF6Ac3FbnCn5WivUwTNhcUl/8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB3039.eurprd04.prod.outlook.com (2603:10a6:802:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 17 Nov 2021 09:38:38 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:38 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 18/21] ASoC: SOF: Add mt8195 device descriptor Date: Wed, 17 Nov 2021 11:37:31 +0200 Message-Id: <20211117093734.17407-19-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8b9eb4c-1b1f-4333-472d-08d9a9ae08ae X-MS-TrafficTypeDiagnostic: VI1PR04MB3039: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1060; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kkHLOStE/Uqhklaw5LU2QdD2THQtEIgNEWoYLKL4EmanrSpLOpeSfnOWxLnPVNN/pRAlwMpjAArQXbPyZi2lQSY4HTvR7C5FhrdYye7cZ/I8n9wVoewEwnCcLFAM5okwIoLoNoObKb0NxwbF74aEV5t6f8qTjWQphh497tyK2TuKFlOoH11o5DCJpZW3Zw+JDYB7tSNVaseVRvz1dqubbpsvpn1cFpCqB3CB37QaugBQ1J4ZdbxI0f+4ZnKErV6PG6LiSSUlIthoyoju8UEIibeGQLcb1Y+hinQV9HrYT9TxNSqEXb32PY4ADxY2twnjIlQcRfARb86vrgyjEsY2ab5C2LGApQerv4ndxPtHC+xOA+lvIRx4mXuoXs2m8v1FxfCOGs6/TVCj9pUlLshOA0lq+Nf48zf0cwozS1VfDaKxiySUHgixhm/6r57y9ctzc5hI2UN54a3EqZmuZWddBS+UG8R/51zbD18JNl6RkjPzJlqTzHyY/Z8oilu7R0ICDAxY/6r12I0Cf38Xy7NNSEmo5orVvwM/eNYgKX/NYftCH+VLCoDWVptYjfC4c3pWXi8Vi55la4khnLqgaNG/I6WhOjaHIZrsn7D7j6dK+52/FmE0z8WzDpXSl8E/gdtu3R66ymfqkexlX90DCbc3AQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(186003)(6666004)(44832011)(52116002)(6486002)(5660300002)(66556008)(6512007)(6506007)(4326008)(7416002)(2616005)(8936002)(8676002)(1076003)(2906002)(66946007)(83380400001)(508600001)(86362001)(316002)(66574015)(38100700002)(54906003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?o4gm5bsqdHvycOzt4lkpTyg2804c?= =?utf-8?q?eieQ6HBE/ANQFpTyfPbr519QRx49p53pj3o7aiTkZmeahCeQusz3SIJsjQUKvOCYr?= =?utf-8?q?VklTIMInsRXIbU+lLK/ufwbDcP82IxtiFeCyzhUDOOlRG4+ixxDJaozo2ryRKg0sg?= =?utf-8?q?J4SDvMV6xwq1LHcdygT9VpDgxr/hu5Rz1W88TtdKI7PdstNcBGbugRLXA75zQ67Bz?= =?utf-8?q?aISqLmQE26AgmwcdIe4VR/dL6f3AJ5aeh59B3cwGnoWZasTIXASGpUgMxYwx2I3gu?= =?utf-8?q?LW930xo3YG3UlGfNVRjBDxTlJeSu7Ci4k7EcNmOksWuJi2xft72nhDHoRqgkwa04X?= =?utf-8?q?ca6tjMbM0RrE/hsnObnadLNZxBFlh+VY3dBJ5YiTjgt+lJbmPSpSeA7p7GF+XHIWU?= =?utf-8?q?OKGvlo6OoNnQhG2vjzeIXr5XeSs8+iOasjUjmTlEPTMn1Yzk8ZoTYB12Ic9m87JkS?= =?utf-8?q?To68vRXUNnjwhHyOghcTJokGiXlOt+cyYgBtThM2AF3adD3SytsSOlQnB3aImjDTn?= =?utf-8?q?lWJT7DSHyNT0Drl4FUtCHi7tLhp51cGa70HVD+s1tqtQ8D5o5OwAqz2AKPZtoyfga?= =?utf-8?q?SrQlssdblO4yAX32kxaRGZYU2dPLCnpeVPLrsbR6EMxWtSsd4tAboLewHVpv9Njmo?= =?utf-8?q?/SuiKF41zFcN9zX4QQA1IC5fuJS/sKwnLiIfBsqnAcCpBg9WM+k8GCqznCsBQwl9A?= =?utf-8?q?0ZBtWrsoB9HF0BMDppuxOGwtiWHk/N+AGmnFsBolvZQfohvgCCZUCYi00iJptq4Ev?= =?utf-8?q?5MR/4Uk5ETbV/EgEtKJTvsF3rvYmFDVGG2YLs/nG08p/NFuayRPUbUX/EphZpVuXX?= =?utf-8?q?6ekbRkcY3vhBj+3pO0X/6qy/t6+94twP1eeNrJFmKv3A4dlygIwNz3m8Jc43eSL4G?= =?utf-8?q?9CVvAYXkitrw3aU0QMNLOfYmPir7F/1anrRuPe1OxAs2XRiiq292uC6tHwqy+hQd3?= =?utf-8?q?3BgrxhE9EZWuQiG4pNhbcwtsXUZTlbV8Z1GlEtGn98//pev1aMoEfIJw5cmitM/i+?= =?utf-8?q?R7N5Yfavxi9uWvBGq3KeNEDpSoNbKUKeweX0sO906WeaJYBkaX36KYwkgRDK4Fxvd?= =?utf-8?q?ur6K2rjyLT+xJyqnJkJfkPcHzKDDTTFDO4cBnUrbH9wMbUOW4pXNwvjqBK1eYBrzK?= =?utf-8?q?v5flP12gpyVKDINmwdRksbpY1NFeS06VhNNaEXnSJgXMOYvVdstcAhAopoYdMmivT?= =?utf-8?q?Mwevo47PdqB+hIRgMtkY3RjkptO9wYRyQpDfWeQvarSrm2G9RG+8+3QLUe8DiVn6m?= =?utf-8?q?K0v1y4hNdYXgoxvj6aZsYH2Muwqq5eOhw+cKVsYa6AYBmOItmiTwLbqssdjGxhAGN?= =?utf-8?q?zo10FwH16eXJWAqAI09kYoS/v5O24WQi6tIsd17XDH1yXZptREzO9JjrOClMCx3Jm?= =?utf-8?q?MvFbVZ9+fseCMvN5eqk3KNRnfD4Q2YYbXn0jHQ4154T2Lsz/TczDj66jLLE9WKiDZ?= =?utf-8?q?c/mXmMgQbtg4/F9LhbLCWWyqp9KUjRVySoUt4u/7/UIXrnbz0XkUQ+E14OA5aQftt?= =?utf-8?q?e/AO/imkzeTjqWWHGgmh1I8vmhA47hv05UrZHA62jVdalnpYBNJKh3/did0D7rWga?= =?utf-8?q?6DYLT1fl2UYvFYs4+ZwNgWH7BQLibb9imfsWGxbB9dH6DQqbs+uSQw=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8b9eb4c-1b1f-4333-472d-08d9a9ae08ae X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:38.7157 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yzK7xyQJKh9h9b1U+sKJMGWSuqA/OKkO9CExvWJNvU10hT8xk0AmBt4/aoE1TjqG2Eu8tNXpRRn7LWH0aCXYxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3039 Cc: Guennadi Liakhovetski , daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, =?utf-8?q?P=C3=A9te?= =?utf-8?q?r_Ujfalusi?= , pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Ranjani Sridharan , Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.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" From: YC Hung Add SOF device and DT descriptor for Mediatek mt8195 platform. Signed-off-by: YC Hung Reviewed-by: Péter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Kai Vehmanen Reviewed-by: Guennadi Liakhovetski Reviewed-by: Daniel Baluta Signed-off-by: Daniel Baluta --- sound/soc/sof/Kconfig | 2 +- sound/soc/sof/sof-of-dev.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index 41f97c6cb4c1..977835f9b987 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -43,7 +43,7 @@ config SND_SOC_SOF_OF select SND_SOC_SOF help This adds support for Device Tree enumeration. This option is - required to enable i.MX8 devices. + required to enable i.MX8 or Mediatek devices. Say Y if you need this option. If unsure select "N". config SND_SOC_SOF_COMPRESS diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 885430a42226..412cbb824b84 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -13,6 +13,7 @@ #include "ops.h" #include "imx/imx-ops.h" +#include "mediatek/mediatek-ops.h" static char *fw_path; module_param(fw_path, charp, 0444); @@ -50,6 +51,15 @@ static struct sof_dev_desc sof_of_imx8mp_desc = { .ops = &sof_imx8m_ops, }; #endif +#if IS_ENABLED(CONFIG_SND_SOC_SOF_MT8195) +static const struct sof_dev_desc sof_of_mt8195_desc = { + .default_fw_path = "mediatek/sof", + .default_tplg_path = "mediatek/sof-tplg", + .default_fw_filename = "sof-mt8195.ri", + .nocodec_tplg_filename = "sof-mt8195-nocodec.tplg", + .ops = &sof_mt8195_ops, +}; +#endif static const struct dev_pm_ops sof_of_pm = { .prepare = snd_sof_prepare, @@ -130,6 +140,9 @@ static const struct of_device_id sof_of_ids[] = { #endif #if IS_ENABLED(CONFIG_SND_SOC_SOF_IMX8M) { .compatible = "fsl,imx8mp-dsp", .data = &sof_of_imx8mp_desc}, +#endif +#if IS_ENABLED(CONFIG_SND_SOC_SOF_MT8195) + { .compatible = "mediatek,mt8195-dsp", .data = &sof_of_mt8195_desc}, #endif { } }; From patchwork Wed Nov 17 09:37:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624231 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 7CB61C433EF for ; Wed, 17 Nov 2021 09:47:28 +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 E56B261BD2 for ; Wed, 17 Nov 2021 09:47:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E56B261BD2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 5995B187A; Wed, 17 Nov 2021 10:46:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5995B187A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142446; bh=uRywt/6Kyw3A59jrRjOw0vqU/slQPz8+odzpqxuhGVY=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aZtdVzP4D+vv/V/AS68iWlqRggwhcMoe7cK0lxR0+H+fOwuT9chZzfb8ujeY3fTmv 4GwAAnkm+T81dJ5ZI4KcPO/9OfkpA6pEEmgSPcILhgV/PlDtjmP7xGOk+pd+Cv7CW2 79dTbqtge3L01V95iajkLZRlZSI6FL3zuQmXOHsg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 787F7F805E5; Wed, 17 Nov 2021 10:39:03 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3B563F805C5; Wed, 17 Nov 2021 10:38:59 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40061.outbound.protection.outlook.com [40.107.4.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C1065F8055A for ; Wed, 17 Nov 2021 10:38:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C1065F8055A Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="GlNNqE/s" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ezVj+2ApiMp8hgbf/QZCBfHhjo6jphmEK9GEFs+hHRJ1NyUxz8je+4ikLSK9tsArB8jTUINlnELAbOPvBgNVr2CZFCkenp26KWgaVyERdayNUaseqpuQpYPBKSymvvmOdeQ37P01wtOJ3XVDS8H28GFy/GrhtJ4Ea9KS61mrij4A+t6UE6Lh9+j9fZBZCIGD49Ge29CwBdBkVfAPpO1mErTKp9llD30vjtvBUJXMjCvdJoRgudgrH3/pUhxmjamnuPiG7HEfXYfxJ7FyScI9DLi3ok9tqDZod47FHkDqTnrlyFl56vbbR8lanOmtNQWAVXt1/39ZFDcgM6PwOin7RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LfCMsRTQHWceFWu6tp44o22ZVYte66A8Zl2PxavSv3g=; b=KPLmVvZj3uK4N0dEa0dUshMljywIaJVnQ+eThDydjMcNDvu7HCw6Bb4TfEu5ekkOGE2XmdVgbhpONC2Xe23UG0B/D5/fXlCQiP3a82SwLehpkM/4sNFZrPJ34HuunjpvW5pEoOZR2oO+EN4xPjX+geixdwNreU62FKz7z/auk6qthRFEt1d9lSuMefr6FNTl2dmga0E1QYlGe6xLidN/6stmKIqrqMj+y36m+3gRdXlsM1ghepfMIxngfV7IMW/xm9vUAXQzuHtbnEAPVsMMWbJTY+0VJsAghvq4CKY2W7xQfR8obkeIuEHLYd9rvd3cE3Q9RSTvvKhIhavoenYWhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LfCMsRTQHWceFWu6tp44o22ZVYte66A8Zl2PxavSv3g=; b=GlNNqE/sqVJ8p7AkEJPm4AfnHntt/te3ioyBkunB/ghf8vglqNB4wVH7y/XSn1zBCx1wFtz2aNB3ZEUD4+VllT/Y8If08BIHHjWvunVNArLZ/BMeq2g5F460hLKQGZUlquRTm94Wfha08vsf6p5Vy1JvHLWhlvVPyycX15TZ74U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB3039.eurprd04.prod.outlook.com (2603:10a6:802:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 17 Nov 2021 09:38:43 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:41 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 19/21] ASoC: SOF: mediatek: Add dai driver dsp ops callback for mt8195 Date: Wed, 17 Nov 2021 11:37:32 +0200 Message-Id: <20211117093734.17407-20-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d1bab77-b396-4347-3129-08d9a9ae09e9 X-MS-TrafficTypeDiagnostic: VI1PR04MB3039: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z7z7H1V/j+B+31OX0YXy60oALEGOjxRJy123gF3QCAtd/zp/ncJvzsTUAUb+wDOSjjILgqwIKNLVw9tOak3UV6E6DP9fESSLH7eD8joh36gXGTL/W9iT8iHwCVO+TcNcwaTXdd3hFmbmBF/Zki66SQKEiWeGevlQtK0ZXUuiBUJoezKJiTGe/w/9k2dn/dpb9kfEp9ktJFR6Fli7AnpYPlxvZC9ng1XT0Pi41vAZfvCpe3wJovIqHyoQu9rOfipUwIW/+EeAdiZELBNV5EtZI6yUUni4AcP1sxGfE4TNDq+iRVhKtaskiqrIiCAa25bxVwLf/Gjxe3ZuhI4u5kuR6b6lz2lF5s8faHGv4Zc1fL/yd9VRh91d9dmt1IQNAVCiZmy2GHkZ03lwGLg0GU7y594CiTOmpAs+tfGHvZvdSvkRw9AQoMawYjl0bjtVWb8miHJnDLON2oqjlc4zUlfwLoaeQ/IhdPW/0FNSX9yqMx/MGpSOUQssqJK2AlSvENnY8W9kYh7lHnuMaTPjXSbmqqEoWL/k77czi++jkILSvrGrC6Csh1sZEwL34GQVUSfnWsmarmJQSijZYZC493nifUyeZblbqMm7Jep4I7c5PEoQ5uAoSBPtNCF054q+ccJnvDu7dke/uRT0Hx5Coyuwyg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(186003)(6666004)(44832011)(52116002)(6486002)(5660300002)(66556008)(6512007)(6506007)(4326008)(7416002)(2616005)(8936002)(8676002)(1076003)(2906002)(66946007)(508600001)(86362001)(316002)(38100700002)(54906003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?iml4dRi0pyO4kkpYfqGjHR4eJoM2?= =?utf-8?q?kdDGUNd8Vt6TCvxLthOU1dXm7hDRjxnVFUuGJMzZzYM7qaBRZVQ4Nj4a8qXTM+4v6?= =?utf-8?q?mM77oNm8FyBpaXvCbLvIoH786Vbx8FO3wlnEGTOEg0lm/ESnkuELAKVkuOVr3Jr/D?= =?utf-8?q?cpEPFLpiPwYiqWrdLV59o9lN3BptxeMgotfifBMUpPPie6sec5EcJaj/y0CekRPRF?= =?utf-8?q?bOOEg5NVb+0A4wr4Twz3pQygDSWGnJGNPDGkcLcaJxr2EJIvXoQTc4SBb7iTFnno6?= =?utf-8?q?XTCh5AoyapC/UAlm9Z80tfUALgSEawLKgvL9z4dGUTeeSPRoL45QLDcWgUTqSrhHA?= =?utf-8?q?yfnm4twM0gqsHKU5I5lXI56VHPRTVX7FAB1WXLKrz7REZbX6SY4rgYy5lwZwPTzan?= =?utf-8?q?tlN9SXXFkE1muNlIf2C3g1EWTRgPyyX03d2dCwpwezl+64kiGiLmRliw3iwhl1C6J?= =?utf-8?q?LWFll8y1Nk44y/0GwacNISNv9lAfF20YOs1qMiTylxVkkpXTix+XkgQJFjIaVEFEb?= =?utf-8?q?0/NA8X2Sfx/ywqfyWWLKgpxKUm6chc2C+kYoSsEhUWIb7ns/ih2R/hSZ6tc5wwRMF?= =?utf-8?q?HDg2C0rS8sxHOHpmct6J31GFEOD+WRSmbLpVC+JeYDLWKflAobou2viI8DqkWmmaB?= =?utf-8?q?OBJCVIyM0/e1X7Ydm47AM2dAJjt34MEMJGTc0haGPWlGutdWVhOeo6RJxGo78a2Pt?= =?utf-8?q?H4ePe+n7cLlG6j5KNt3gm5cAkFADdczo0sxUPPfyxfjq37f3/6KhpdhYEVLm2Vjg6?= =?utf-8?q?vFa7vr0NHMA2YoK2ROkyxLrZhtRmFyAzzCb3NoYdYnp01/48D9LIfGF7yOScZ+s7C?= =?utf-8?q?q9TjI0yDt89H8jOF2gAo/JcjOQyc+E8ww9s7Ea0C6muH2c0isSViI/uQBKuunL5ty?= =?utf-8?q?hTCXR3fk79hzSlJAaNwF162AW77KzW4x8i3bCr82usbyfonNVzeSAl/roPHqUvkB+?= =?utf-8?q?JX9/KX/6wiE65SdnaFPrgGlaVvSgt6ASvR102FAjZ6kOs/8VoKsprSXNRgDjRfe3s?= =?utf-8?q?Bcs30l41WsVDhpTHAN8N1sMjr7eMWWCsQaEeEBD8DyTC4PH0q9nksXNeMKZ+kzC+u?= =?utf-8?q?P2qSrYz2Rouyy4+NYTXiWh3zaYEPTMUvOdCMEZ7JiE4uDGzkyc37MSjCgT6yfDcb1?= =?utf-8?q?6mUxFM8n5CDGi1hvqkhNM4rqK8+YhPIfK4yK1y1h84uoP9usuyzCC2HhXsFoilhT4?= =?utf-8?q?i9xIF1/OvpYvGP/GvyqCvZhYFhzcD8llzlVCjrNEKBeFiqvBqljMDorvrXoMZh+8J?= =?utf-8?q?8xNdK+W6namMoEg61kfF5c50E9X0v+YlHe1ilmKy5sAvgb4xUacVHGbwE9upn1kc9?= =?utf-8?q?Z+u5J4S6A/VK7cFsDXzjcmt7wcBNzJsARXgb3GQnoiS/Gp2CCzZcwteVpGHT+TLIv?= =?utf-8?q?DbwRObr67DEI44ehG/obqxesWNLKOwP21fpMOy3i2GnVQEvsKp6QBYV+SXmmD1lBu?= =?utf-8?q?RoZ7hhRd/JMdqzgPVPknmtmy1/8TTtOcoH412MdmA6O8ChrVU6ZP8Jl/vGRVWJmgU?= =?utf-8?q?Mm6NgEWSdyx6HyzGE+cNUjJJwrsAXjwGcBj60wuKgVqnmb5oHIAOXazhXtAdfeb8E?= =?utf-8?q?CyAZLpTRNBQtio8Jk4h+kk+OuC8vt89UasyAdFlFHlcXih3rtMgc1w=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d1bab77-b396-4347-3129-08d9a9ae09e9 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:41.3612 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3wnpoTM/La2mN3Kw27ZHLRVMK7LFwHYzj0jwQ/JG/j/J5L2MG8aysdFa+NQwJCYOQB5JUzoaQ2Rie6wkdXUumA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3039 Cc: Guennadi Liakhovetski , daniel.baluta@gmail.com, Kai Vehmanen , AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, =?utf-8?q?P=C3=A9te?= =?utf-8?q?r_Ujfalusi?= , pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Ranjani Sridharan , Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.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" From: YC Hung Add dsp ops callback to register AFE DL2/DL3/UL4/UL5 sof dai's with ALSA Signed-off-by: YC Hung Reviewed-by: Péter Ujfalusi Reviewed-by: Kai Vehmanen Reviewed-by: Daniel Baluta Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Daniel Baluta --- sound/soc/sof/mediatek/mt8195/mt8195.c | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c index 88da6c2de070..99075598a35a 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.c +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -299,6 +299,37 @@ static int mt8195_get_bar_index(struct snd_sof_dev *sdev, u32 type) return type; } +static struct snd_soc_dai_driver mt8195_dai[] = { +{ + .name = "SOF_DL2", + .playback = { + .channels_min = 1, + .channels_max = 2, + }, +}, +{ + .name = "SOF_DL3", + .playback = { + .channels_min = 1, + .channels_max = 2, + }, +}, +{ + .name = "SOF_UL4", + .capture = { + .channels_min = 1, + .channels_max = 2, + }, +}, +{ + .name = "SOF_UL5", + .capture = { + .channels_min = 1, + .channels_max = 2, + }, +}, +}; + /* mt8195 ops */ const struct snd_sof_dsp_ops sof_mt8195_ops = { /* probe and remove */ @@ -329,6 +360,10 @@ const struct snd_sof_dsp_ops sof_mt8195_ops = { /* Firmware ops */ .dsp_arch_ops = &sof_xtensa_arch_ops, + /* DAI drivers */ + .drv = mt8195_dai, + .num_drv = ARRAY_SIZE(mt8195_dai), + /* ALSA HW info flags */ .hw_info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | From patchwork Wed Nov 17 09:37:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624227 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 2C9C5C433F5 for ; Wed, 17 Nov 2021 09:46:42 +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 A5E0C61A07 for ; Wed, 17 Nov 2021 09:46:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A5E0C61A07 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 1580F188F; Wed, 17 Nov 2021 10:45:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1580F188F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142400; bh=oWgfUmGpScC53mX7YbfQXkOptj/3blPF4qwWjxVNxKg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kzbg0Sac2paapP8UKC3NuUNnCX+s+5lnkyIGQKgHG+vd+BXJBEnJni4AxMRj0mKgJ ZeKDsd+IEOptCRtmqPZzpdKRx1g9t4TRqf4vV75as2InBMz+jYpE71u0CnRuS7C2kr GiNH4DFMHH6Xzd0mZ8ZgkONDa0JJFdmMhLQZRrIE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3B256F805CB; Wed, 17 Nov 2021 10:39:00 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BB34CF805BB; Wed, 17 Nov 2021 10:38:57 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40061.outbound.protection.outlook.com [40.107.4.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 108C8F8056F for ; Wed, 17 Nov 2021 10:38:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 108C8F8056F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="ZIUr+axo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fDL06reMvwPmpLCc7ttZMjddOJhP0fErWugCtlid9GXQuxBAu7OKShAmsP50JeOr2yzevWP+isOVuKzyQHXU7hCikrXQnnI1fY7CKPB9sAwyzOw7LXFPOGS+cKJLoJsN+HIPIQLrscsMLVNJhbktvz2dJQDaaEW56k3JVXUiY2PFcyssE1/8q1oUWiQTijegfZLn0TyNBBxSKr26jnYw5a4r83IfP2gf0sz6ln4qnSH0E6Yj7htEwqDaZXIZ3m5MBKloFHKQMW3ykWBrX2a9pCVqk8PrqUz5bHqDU2bCyMjHm2+AEup9hJqVQ9LV00fGvlvYcICy0UZ+eVN1dHAZdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RCMUzfA8hdjBrmOIn6d07q9GBomDcmPvFrEtSFmZKi8=; b=IOOEBpIv3rlawz5Ahp/epHPPEJQG5z7/ku3tfJl3OqvCLKgCLpV+CtZHaRfjJ8Lvj7keDzuGtGQMYwaoC/F7Fw9+A9iqWJd4lZ3bUIylLIfh4ZfdrXRIi1P2xpAYF1Fy4zwKCxYK2H3baFOh6fROgcG1cUrZYaSJ+cAfEri5eXpI3B+jE9g4vJ0hy+XOg5WzbEP3a0GmKnvpUEii0yFQskUM4BdiQCknhsOMuOLDZ1PlEMdVa/BqNIfKpeLtZW2WnDlhKQlvWXodimW0OjyJht99+EL5WwWOQjYTCcetXzVaBw9ivLiEKxJ04hXuV5hfdmXsTZms2CPzYyv5hopkJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RCMUzfA8hdjBrmOIn6d07q9GBomDcmPvFrEtSFmZKi8=; b=ZIUr+axod62nb9Vj3/GT8PBdBZ27vCqgvmP4/vlzCUkcN5RczFeGWXiEAkWa9vdJ3nCjsFK70TragNCOF5k747lIhAXdY538jGwkrTt9GwdhjY5In2fBirm5qZS4i9EQBDZZPmhQt89CFb+Z8c8kjYIsQ2QIM8YOnJJECGez92g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB3039.eurprd04.prod.outlook.com (2603:10a6:802:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 17 Nov 2021 09:38:44 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:43 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 20/21] ASoC: SOF: mediatek: Add mt8195 dsp clock support Date: Wed, 17 Nov 2021 11:37:33 +0200 Message-Id: <20211117093734.17407-21-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: af85c6e4-8dd3-4a59-47fc-08d9a9ae0b4d X-MS-TrafficTypeDiagnostic: VI1PR04MB3039: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:277; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vf9cR5bvxy4YqGq7FLz7fFE8IKnVKP0oixBHSrT1FcnvPAUB3hA0HkScWeYwDyWuYdFsaDKJZqXPyemSmUXP3Q9FROQb4O5FNC71V9No5PhSwM5+SfI4DZOyLOK4D3ju8wB91Nd55wK34vmDe/ZsIedr9sixWMjShhWXlGH5ZH4en6ppwsK/UGj0kbTuJUSbGNrGjUim0sH5tcV8LbE8YCNrQD3S5P9GI5dUJ4WkCnWw5ujjJyPtbDjrUtkYqV52wRZpXKeAypk52/a+kzAJlmfRL7VYk/nEoPhDFJD7hO1NfhWhhjOXyFdCBzmm28CjBanIQhtqA0Y3xnFuv1Ul7S3MxCsKSfuUXb8H21Bz7iNAH/0gzMlpiNLYRLikstwi5aEmfgWqYLZly8jfgdd5TNh2cQ3bR6+tZOsdrpzLa8/QWmd17IJcEQyOB2siUG9Oy3/3O9HTzGOjiZWuSiy8KFfqABL7BShASKt2S/4dbAO2zd5y0/qEdHZLzFjkgVEfDOMomujOD+7vgSjN82SBrMkHhcPjWo9R67AWq54HzbmaZRvIWAwCOuXUhBvSyhxy+/+gnehWIleCYI9w8fEDvSTpK3CuCqsQgpEeN+sQ4FlplyEvHPdbW770BWxrBgVuNcjeJ2dnj0xDx1S2WF422A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(186003)(6666004)(44832011)(52116002)(6486002)(5660300002)(66556008)(6512007)(6506007)(4326008)(7416002)(2616005)(8936002)(8676002)(1076003)(2906002)(66946007)(83380400001)(508600001)(86362001)(316002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HkQCWTb1TPo7sV0UoG6PFOWuDW/ez0niabgu3fTExD5GVnGdrAavKr6fnAzmesziV6eqziFgaxXMYBHR+1ffsFHBByGel+r2jCbIlDVlBk/d2fjRN+1qhbH3lNVz4rkLACdxZsqjos5QkZwSHjiZ3VsRADJkUgBpSt4Ep7jQ5yy0cedf1LzgjKfj3xaVRu5zPRycP6GLuC1qS4KdOBIGOp5+bm7/NdlT7WLX6IWau6eWZLzNKNoauoILdyqK7NzdcdEE2QFsT1TG6yXwJ66DiPlvsLUTkYnMUCIlD9hkMHzNmDPRjVXx3KTEOLjF6s1oZLqYmmvWb4e5rgdTsjqihFONB7hpG2M8HLc/xdCYiSyfck3Rwrw54/zMvnjX2Q0VeoZd2D2ont0mQBwWUnv1EqDnd56QKZQjk6U+dFzV2gdxO5RwSRP2ks9q/JjAqqMKvidOSCK++Y7ZwNQUMO4P2X5eBjW4caN2rbJHcTFgCJAO82oAxREEvDfB6y8KjsKGQ/vyUXGfzvPV+TdyAfkSDdC3Dp4d2un7ToB13biwS9pKA0ZTjrbMtQirFKcPJ9ZEdCPx8FuS1SC2W8FuoHZIfR5p27+/GdJkZDsVrmMfise0oCBCcOJ8ojvPcOhrzaOoEe4xyuXzsqRCBehLpseD9wR4tX9Jt3NQ58pf8bbCUvRVm91ezXnAnuYYq80RHJvQ/Ff7pX+wwpGn7ZzLB9oOgYjxy/85biujw9zZsxzVKZCjdkXdrB33Ly48HQjlqqsSAlWK041zZD5Iype5EJyCSC/OuzCyfcVGcXxN+m6EgO1A0dreYCU8QMV1wzxKenoSUWVaxZu/UzA136sj+pLQcmlTR0EjbSv+ywiBZkFs25HEhzzP5atMuY9RsfKfoP8FdyumGzEgJZzw7n8gsTb87C6+BEpvQgcqy3fSEElDK4n24IGH9zR2GR1f7CvzzQi/PpGTCWf99AYsr9j/GUyUsr0qbjpOet4nhSC0PURDCd2yZa0FWWQZ9JZunT50Ee/xhjE/WJm266dms3Z8XjV5hs5uqkC74y7IEUXBqFQTMA+7Qi4AJEF+rwKPBXye3opCLVVkdIgXsNJhj9HgSEaSLWI8qnHzuGGKHqi7MxFgoyc8CURPEIGyEp2Z47yQoM7WA3zq+8TISxkEvG8dq2B603A453Gp1e+vFfpYXevP2rJF+7mV37/4V4jCYwGGiVKQa2QO+EoJde7d/loWjftaDWU1agC1nYJ+s5mF/Jl3G6bPWWuSDJZGoaaxyrThbsr7s9B7ol8sM9b24k0al5cUTdwpPPElxOBuw9CSiuugRQiBmEHvSrcI8Cjwztka9ic62xpcHk+n9ZKHlziT68liAX800VgIkv5fGFvxPqZvqNH3PSPUJa3NCGFScv83fkOMRMJHh0K5B9ALcwuJTDnLEQYT9KLSGvkw0EK9OYghju/bstc5s2kY17jCRIabKobW5HAXhgxcfTV85SroCSIP9YZk2dl87pGVHp8BDejCZn0VQNDHwPB7x2HiW5DUfW+/nSL2gjwRGOJ+60c5ad0gcFX+cexd655DnYb9h13B7d2Amoghz5mvc13U7AkSC34wif+it39o2RojXkXTeYdG4mubv1dqmxAtdyOfq7Wmrg2+U/pbHJjd6dVZj2+O9u2Qip5ZjoS7AMLwhlYUqRfgthERvDxTE4pZ7YgEe15X/Rg= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: af85c6e4-8dd3-4a59-47fc-08d9a9ae0b4d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:43.7838 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TYj1lP1wOV3QvpC0rDMhZVf5KRZdCAywRRB5JmvqvqLQ9bukkSuIgjaWOIo4grYHMQPzYT6AK1WMBXCdZM0jPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3039 Cc: daniel.baluta@gmail.com, AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.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" From: YC Hung Add adsp clock on/off support on mt8195 platform. Signed-off-by: YC Hung Reviewed-by: Pierre-Louis Bossart Reviewed-by: Daniel Baluta Signed-off-by: Daniel Baluta --- sound/soc/sof/mediatek/adsp_helper.h | 2 +- sound/soc/sof/mediatek/mt8195/Makefile | 2 +- sound/soc/sof/mediatek/mt8195/mt8195-clk.c | 158 +++++++++++++++++++++ sound/soc/sof/mediatek/mt8195/mt8195-clk.h | 28 ++++ sound/soc/sof/mediatek/mt8195/mt8195.c | 22 ++- 5 files changed, 208 insertions(+), 4 deletions(-) create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-clk.c create mode 100644 sound/soc/sof/mediatek/mt8195/mt8195-clk.h diff --git a/sound/soc/sof/mediatek/adsp_helper.h b/sound/soc/sof/mediatek/adsp_helper.h index 346953dd22db..6734e2c0c6b1 100644 --- a/sound/soc/sof/mediatek/adsp_helper.h +++ b/sound/soc/sof/mediatek/adsp_helper.h @@ -39,7 +39,7 @@ struct adsp_priv { struct mbox_controller *adsp_mbox; struct mtk_adsp_chip_info *adsp; - + struct clk **clk; u32 (*ap2adsp_addr)(u32 addr, void *data); u32 (*adsp2ap_addr)(u32 addr, void *data); diff --git a/sound/soc/sof/mediatek/mt8195/Makefile b/sound/soc/sof/mediatek/mt8195/Makefile index 66cdc0e7bf3c..afc4f21fccc5 100644 --- a/sound/soc/sof/mediatek/mt8195/Makefile +++ b/sound/soc/sof/mediatek/mt8195/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) -snd-sof-mt8195-objs := mt8195.o mt8195-loader.o +snd-sof-mt8195-objs := mt8195.o mt8195-clk.o mt8195-loader.o obj-$(CONFIG_SND_SOC_SOF_MT8195) += snd-sof-mt8195.o diff --git a/sound/soc/sof/mediatek/mt8195/mt8195-clk.c b/sound/soc/sof/mediatek/mt8195/mt8195-clk.c new file mode 100644 index 000000000000..6bcb4b9b00fb --- /dev/null +++ b/sound/soc/sof/mediatek/mt8195/mt8195-clk.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// Copyright(c) 2021 Mediatek Corporation. All rights reserved. +// +// Author: YC Hung +// +// Hardware interface for mt8195 DSP clock + +#include +#include +#include +#include "mt8195.h" +#include "mt8195-clk.h" +#include "../adsp_helper.h" +#include "../../sof-audio.h" + +static const char *adsp_clks[ADSP_CLK_MAX] = { + [CLK_TOP_ADSP] = "adsp_sel", + [CLK_TOP_CLK26M] = "clk26m_ck", + [CLK_TOP_AUDIO_LOCAL_BUS] = "audio_local_bus", + [CLK_TOP_MAINPLL_D7_D2] = "mainpll_d7_d2", + [CLK_SCP_ADSP_AUDIODSP] = "scp_adsp_audiodsp", + [CLK_TOP_AUDIO_H] = "audio_h", +}; + +int mt8195_adsp_init_clock(struct snd_sof_dev *sdev) +{ + struct device *dev = sdev->dev; + struct adsp_priv *priv = sdev->pdata->hw_pdata; + int i; + + priv->clk = devm_kcalloc(dev, ADSP_CLK_MAX, sizeof(*priv->clk), GFP_KERNEL); + + if (!priv->clk) + return -ENOMEM; + + for (i = 0; i < ADSP_CLK_MAX; i++) { + priv->clk[i] = devm_clk_get(dev, adsp_clks[i]); + if (IS_ERR(priv->clk[i])) + return PTR_ERR(priv->clk[i]); + } + + return 0; +} + +static int adsp_enable_all_clock(struct snd_sof_dev *sdev) +{ + struct device *dev = sdev->dev; + struct adsp_priv *priv = sdev->pdata->hw_pdata; + int ret; + + ret = clk_prepare_enable(priv->clk[CLK_TOP_MAINPLL_D7_D2]); + if (ret) { + dev_err(dev, "%s clk_prepare_enable(mainpll_d7_d2) fail %d\n", + __func__, ret); + return ret; + } + + ret = clk_prepare_enable(priv->clk[CLK_TOP_ADSP]); + if (ret) { + dev_err(dev, "%s clk_prepare_enable(adsp_sel) fail %d\n", + __func__, ret); + goto disable_mainpll_d7_d2_clk; + } + + ret = clk_prepare_enable(priv->clk[CLK_TOP_AUDIO_LOCAL_BUS]); + if (ret) { + dev_err(dev, "%s clk_prepare_enable(audio_local_bus) fail %d\n", + __func__, ret); + goto disable_dsp_sel_clk; + } + + ret = clk_prepare_enable(priv->clk[CLK_SCP_ADSP_AUDIODSP]); + if (ret) { + dev_err(dev, "%s clk_prepare_enable(scp_adsp_audiodsp) fail %d\n", + __func__, ret); + goto disable_audio_local_bus_clk; + } + + ret = clk_prepare_enable(priv->clk[CLK_TOP_AUDIO_H]); + if (ret) { + dev_err(dev, "%s clk_prepare_enable(audio_h) fail %d\n", + __func__, ret); + goto disable_scp_adsp_audiodsp_clk; + } + + return 0; + +disable_scp_adsp_audiodsp_clk: + clk_disable_unprepare(priv->clk[CLK_SCP_ADSP_AUDIODSP]); +disable_audio_local_bus_clk: + clk_disable_unprepare(priv->clk[CLK_TOP_AUDIO_LOCAL_BUS]); +disable_dsp_sel_clk: + clk_disable_unprepare(priv->clk[CLK_TOP_ADSP]); +disable_mainpll_d7_d2_clk: + clk_disable_unprepare(priv->clk[CLK_TOP_MAINPLL_D7_D2]); + + return ret; +} + +static void adsp_disable_all_clock(struct snd_sof_dev *sdev) +{ + struct adsp_priv *priv = sdev->pdata->hw_pdata; + + clk_disable_unprepare(priv->clk[CLK_TOP_AUDIO_H]); + clk_disable_unprepare(priv->clk[CLK_SCP_ADSP_AUDIODSP]); + clk_disable_unprepare(priv->clk[CLK_TOP_AUDIO_LOCAL_BUS]); + clk_disable_unprepare(priv->clk[CLK_TOP_ADSP]); + clk_disable_unprepare(priv->clk[CLK_TOP_MAINPLL_D7_D2]); +} + +static int adsp_default_clk_init(struct snd_sof_dev *sdev, bool enable) +{ + struct device *dev = sdev->dev; + struct adsp_priv *priv = sdev->pdata->hw_pdata; + int ret; + + dev_dbg(dev, "%s: %s\n", __func__, enable ? "on" : "off"); + + if (enable) { + ret = clk_set_parent(priv->clk[CLK_TOP_ADSP], + priv->clk[CLK_TOP_CLK26M]); + if (ret) { + dev_err(dev, "failed to set dsp_sel to clk26m: %d\n", ret); + return ret; + } + + ret = clk_set_parent(priv->clk[CLK_TOP_AUDIO_LOCAL_BUS], + priv->clk[CLK_TOP_MAINPLL_D7_D2]); + if (ret) { + dev_err(dev, "set audio_local_bus failed %d\n", ret); + return ret; + } + + ret = adsp_enable_all_clock(sdev); + if (ret) { + dev_err(dev, "failed to adsp_enable_clock: %d\n", ret); + return ret; + } + } else { + adsp_disable_all_clock(sdev); + } + + return 0; +} + +int adsp_clock_on(struct snd_sof_dev *sdev) +{ + /* Open ADSP clock */ + return adsp_default_clk_init(sdev, 1); +} + +int adsp_clock_off(struct snd_sof_dev *sdev) +{ + /* Close ADSP clock */ + return adsp_default_clk_init(sdev, 0); +} + diff --git a/sound/soc/sof/mediatek/mt8195/mt8195-clk.h b/sound/soc/sof/mediatek/mt8195/mt8195-clk.h new file mode 100644 index 000000000000..9cc0573d5cd2 --- /dev/null +++ b/sound/soc/sof/mediatek/mt8195/mt8195-clk.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Copyright (c) 2021 MediaTek Corporation. All rights reserved. + * + * Header file for the mt8195 DSP clock definition + */ + +#ifndef __MT8195_CLK_H +#define __MT8195_CLK_H + +struct snd_sof_dev; + +/*DSP clock*/ +enum adsp_clk_id { + CLK_TOP_ADSP, + CLK_TOP_CLK26M, + CLK_TOP_AUDIO_LOCAL_BUS, + CLK_TOP_MAINPLL_D7_D2, + CLK_SCP_ADSP_AUDIODSP, + CLK_TOP_AUDIO_H, + ADSP_CLK_MAX +}; + +int mt8195_adsp_init_clock(struct snd_sof_dev *sdev); +int adsp_clock_on(struct snd_sof_dev *sdev); +int adsp_clock_off(struct snd_sof_dev *sdev); +#endif diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c index 99075598a35a..5bfae9379ac8 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.c +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -25,6 +25,7 @@ #include "../adsp_helper.h" #include "../mediatek-ops.h" #include "mt8195.h" +#include "mt8195-clk.h" static int platform_parse_resource(struct platform_device *pdev, void *data) { @@ -231,10 +232,22 @@ static int mt8195_dsp_probe(struct snd_sof_dev *sdev) if (ret) return ret; + ret = mt8195_adsp_init_clock(sdev); + if (ret) { + dev_err(sdev->dev, "mt8195_adsp_init_clock failed\n"); + return -EINVAL; + } + + ret = adsp_clock_on(sdev); + if (ret) { + dev_err(sdev->dev, "adsp_clock_on fail!\n"); + return -EINVAL; + } + ret = adsp_sram_power_on(sdev->dev, true); if (ret) { dev_err(sdev->dev, "adsp_sram_power_on fail!\n"); - return ret; + goto exit_clk_disable; } ret = adsp_memory_remap_init(&pdev->dev, priv->adsp); @@ -282,6 +295,8 @@ static int mt8195_dsp_probe(struct snd_sof_dev *sdev) err_adsp_sram_power_off: adsp_sram_power_on(&pdev->dev, false); +exit_clk_disable: + adsp_clock_off(sdev); return ret; } @@ -290,7 +305,10 @@ static int mt8195_dsp_remove(struct snd_sof_dev *sdev) { struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev); - return adsp_sram_power_on(&pdev->dev, false); + adsp_sram_power_on(&pdev->dev, false); + adsp_clock_off(sdev); + + return 0; } /* on mt8195 there is 1 to 1 match between type and BAR idx */ From patchwork Wed Nov 17 09:37:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12624229 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 EC83CC433F5 for ; Wed, 17 Nov 2021 09:46:58 +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 6D8AD61A52 for ; Wed, 17 Nov 2021 09:46:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6D8AD61A52 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.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 D3167185A; Wed, 17 Nov 2021 10:46:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D3167185A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637142416; bh=tq8p14dgLQ88hgOrF7/zyMNbI/BoytAk0VK3aYb4eG0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=g6HrPsNbMdZkKrEMQ3RhLaNiW5S5DUh8bFpTG/713lLzeByCj496gZLnqESjet2C5 FKySTYEek0QC/vOXfH2nexXyJn62VaxFK6RjQiemmYLQnJKcdXDJwi2bkR/80qc4iU 2f746mFachhymnhTk15IyAkSKDXJGDNMZVDdPXgY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1E113F805D6; Wed, 17 Nov 2021 10:39:01 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5458BF805C2; Wed, 17 Nov 2021 10:38:58 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40061.outbound.protection.outlook.com [40.107.4.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 57624F8057D for ; Wed, 17 Nov 2021 10:38:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 57624F8057D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="Ik1Ay2MV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MEc9SNJVNVeNgewzUMrWfnVRwnm89LU1VBzU7BYz2BHX9F1Icb7Mact1Cw0pj0p8ROhEB2kdAMUq4ZYnCYMutqO56jRTZ5Piux94W7lNEKgexpawtcFE99PcmXZwbskEjJ58MGmZJItj3wv/zIcHPRPVyy9yVt+Q6EkkaRBJ/vv9Yz3UX4IN0LonXlaHvRcthKArympw3C8jUDogKKsGblMkju6A5gATnsF/WCUzad3tv3r0yPgHJGZ6nnx8drEa3X8On0+0D/9GvEuC7bgJqKSerkNO0flG3sqxrCeeWyVlIhc3cPsIvl3u9UrO/ZI9M3yTs2QQq+3/6hvo9XNO8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9qA+AKWCWzOd4laj79fwXpT4DlJBt/zadXCV9ubK1x4=; b=B0Lj16ClSGrCd3CMHwl5iT1Uh3rxFwK6vclxPJqsaJUgR4FyMzmGo+64i+1u9dzDsL85VJdiU0wJ9XT8WYMg8J0ef/AgkTkqJjqGOYlOaINL0KICXEBQcqsahdghEwjOclmuRDie/jisC9kt3fTh4VTvYt5/h3EXgxoiuc5Q0k6WPswTAGupx++NDLuAs+9qfsSlrtitQ2xF5nK3kQYKeezIxX3BjyLwA8NQvdj9+MwqlAhqmocYda2+3mD47ITth5f7H742bGBqYrVwH5mS1lNSE1U4kS+kcRgy5o6AqobcBssGVH3pYdqBIoc1gVoqQ+8ZG3eRA8X8b03o+4pYaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9qA+AKWCWzOd4laj79fwXpT4DlJBt/zadXCV9ubK1x4=; b=Ik1Ay2MVX5tyqMHgT0NlPnORamMrFqb47j/GbE0crJ0Uk584f/edyj+2TqzsY1nbQ5FchWZ5xLez1RCcD9X65Bc2u85kSzPhV34f/urj+HjOeecr/lslS/fI0Gp7RjfqFWWv3K/vR5Ga9A+E3ey9tUFUO5lx1/ecI1sIAmLL8e8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB3039.eurprd04.prod.outlook.com (2603:10a6:802:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 17 Nov 2021 09:38:46 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4690.027; Wed, 17 Nov 2021 09:38:46 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 21/21] ASoC: SOF: mediatek: Add DSP system PM callback for mt8195 Date: Wed, 17 Nov 2021 11:37:34 +0200 Message-Id: <20211117093734.17407-22-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> References: <20211117093734.17407-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5706:b700:22bb:b216:ffff:73e1) by AM3PR03CA0060.eurprd03.prod.outlook.com (2603:10a6:207:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Wed, 17 Nov 2021 09:38:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d3d8225-4339-4d01-8a4d-08d9a9ae0caf X-MS-TrafficTypeDiagnostic: VI1PR04MB3039: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VM1Ni1qqInNFquIlVq4wSafqdaeNYiApKz+wBG1bYC8GhPNwi8WkHgi9MBaPmwrP91x0XDfCbPFE1fGBmhWlPxCpS9A5Bere1waD4FgUHpyUUbAuxT80/w8tMAlDcMVyEw8KE6Y1+mN5/XxP4GQFPcYFlpbqUlv/51XqR0XEyvvmU2m/VdM5cbDEmxcV52SBFaDZRQOOz+5oANx/sxMiHmvMF2DwLluBNtyDhuP9kwWai4mVNzhOy00Z7dVge1CD7kAIoewjHv0yCFEFxUi3C2lQ8I2oPeLefbyGsEP7+17mvPs87jSquumboItV7GjycwgyfhiBqjx8QdW08Ba8l1z9Ux5lCbUxVkHU4KEqBf69Ga8mqMegSTgrykx26rX65h8mqlCIueQVxplsfRt354bNOt7AAm9Avj061XIliOpTagryOm+12ICAtbR8qh5xWfKL+nDD1dBGAf4juvRWz1YokA0A++Iiwkb3wxFQfnd/gZ+5/T95ehkCfCRxjv/j6A6JHRb4sg/K6bnrSMiyy+OlWjJtWAi3PdJy1ch9gibr35vSkeqZO18nomUjxVxBN1rL4EZBeSfa8NgWscotSa15UVX9soAcXEZYbN0A84sPIxY8ABr7+y1vfdj0EgdXKY5GhI3EqOQRXHvdnY61WQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66476007)(186003)(6666004)(44832011)(52116002)(6486002)(5660300002)(66556008)(6512007)(6506007)(4326008)(7416002)(2616005)(8936002)(8676002)(1076003)(2906002)(66946007)(83380400001)(508600001)(86362001)(316002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fUwRz3VSlUnbXLwoG/tAB5GUuN1VzmTARqxpnKo7ezc9CPdJ4MsRM1CdPxLYxgfHK7thisfBZPWgwdneHhoAlURiIXcptCLxh712fZkxYEZXOSR6DvkoaEBNqlw23+PSs/iB8dtkZXvWLXl/QegTgStcOBID+KX+Yp0oGNaa+sJvDN+tFCeth2x3kkInBwBtYtiD5mrQMbGh7SnapMP7o5A7A6CvEr4tO/Aag81BjXbV4kZkefB5oA/Ih65ilplUS2BXLEzwdMA6Kl1id/vwp7GV6mEIo1j7G3HFoZwlTOHjXfw0si3mNjQJC5wjymAsqRjJWRiE57+tw+Ve6FyFbiTKjYvDZgI7y+WkJcSmJftkrQvbDSuPponCqRpAhbIigmtuxuDY/mTn5wCBChuksKMjct14uVCn6ECQKgYemONu8/H/pHg8QtXdjSDdSIhP6cxw2blEOGnqSwtR+bK9/awEb9USwRBNE8s+p45fTg6VDq088blVZ3+XYPVTRBLxAMD5W/22WHu9yO90B3hAlCtISPN0dbQsQe5iYM5NK7NX/4kTlmBdSo4Og+hTsu0wRNPc7h6tmT97qUiIqunDtKheKRwk1s6+XY2edRvGFXRWLM+yFEN1vl6nSvEtB045FIoP6qr6G6x26GfiIW04F3aREd97M+MIvBbJScrkR4VjfHr1WoMiPLwJfRzt1VzEQ4yRvp2S2EAooeALD6qsNnx2zhNiXK9kxGjBbZyhpSwfARVuCcZOeMVRmuhSKAGZHgzcGvdYdUQq1/UOrBtCm6XCwUmiXo2rxj+5dGbsDSP1/ofp6OgVWGMR1/x9J9k/149skC+82iwMnE7trDbMlrbMhqFcty8ZpmdOa9pWrcVLA8L1S6ZdfrghMCy50FaYiceOJ44sYjo7dq1PWUiW/hlyjcXMCyhqhA9VacBBNd9NhEuUV5xbj1aCr25jIPEt7+p4LXhyRWoPmPcx/aD+ZIrL2es65S7J0i/m+QrPOyMVviusPP9EdHdQq9RNzzWwPpE3b6UuYOHydfYioiIPvWlq+Smnw8atV9dDMLKx+Usm9zv/EVIPuwj1F3VZi5zYz02f/WCQ4Hg8RXy4QZLD542HWrLsDXd1iFDivwWO2Yu6w2oVjVOC6R+z6gcXyQn0w4zF/vqzr52pg4jidPRfsr6HXwFsIAr5iJvvV6JJg8G20t4hanF/ASud4dHwI8YDF+XhW4KfA4JVfsOoPUOvverXFzIv99C8aQ5bLn1ysdw8HStp5h7XxgUZbOSUq5XnhI2m3PpymIfMigTV96l3g+LjhGMe7tOaLvQeXfPflMkeXWtigqIqrORhVbb0GPqgU/rEeHju9sbUo3q0fQumLiYcW/GPz76qigqXDMVdLst7jZVVklXt+VV9oeIHkwSccDALyhNnABs3FBlKL+KUGieJV04uVCSxugyZjbDYgGyG/eJJJUZJnRBLqlSfL/9jnEADXDcUVYfYgdVdeDQE3/NzLGleoGbhv/GkNETZCbmZ/cNP+i/aOnN3wWFEOaVBdX+EnUnYAnCHKaq+KYTD4Ha9GebVxDltYdXVAYdxTTDnEEvwuFsUvWF5EqUpy7lSNPkFd43wVIB0uuo4FnMcFqybEjISwpcEOqxOE05AmvLS5Idv2OjVQ6nfQjLasBrn+Hhdw3IHXUTUSEMyVb2NvSQt4gsLQs+0DOD0SxzW+ig= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d3d8225-4339-4d01-8a4d-08d9a9ae0caf X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 09:38:45.9915 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OsOo6R9iDsrFx1yF54xjK+o/vahOQIOSWOmPGIcdUf4f4nTTlUhFWgWtPW3Eidlmu/Ep81A0sSao10DU2ZKfdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3039 Cc: daniel.baluta@gmail.com, AjitKumar.Pandey@amd.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com, Julian.Schroeder@amd.com, linux-mediatek@lists.infradead.org, Balakishore.pati@amd.com, yc.hung@mediatek.com, vishnuvardhanrao.ravulapati@amd.com, vsreddy@amd.com, daniel.baluta@nxp.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" From: YC Hung Add DSP system PM callback for suspend and resume Signed-off-by: YC Hung Reviewed-by: Pierre-Louis Bossart Reviewed-by: Daniel Baluta Signed-off-by: Daniel Baluta --- sound/soc/sof/mediatek/mt8195/mt8195.c | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c index 5bfae9379ac8..40e5a25875a6 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.c +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -311,6 +311,44 @@ static int mt8195_dsp_remove(struct snd_sof_dev *sdev) return 0; } +static int mt8195_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state) +{ + struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev); + int ret; + + /* stall and reset dsp */ + sof_hifixdsp_shutdown(sdev); + + /* power down adsp sram */ + ret = adsp_sram_power_on(&pdev->dev, false); + if (ret) { + dev_err(sdev->dev, "adsp_sram_power_off fail!\n"); + return ret; + } + + /* turn off adsp clock */ + return adsp_clock_off(sdev); +} + +static int mt8195_dsp_resume(struct snd_sof_dev *sdev) +{ + int ret; + + /* turn on adsp clock */ + ret = adsp_clock_on(sdev); + if (ret) { + dev_err(sdev->dev, "adsp_clock_on fail!\n"); + return ret; + } + + /* power on adsp sram */ + ret = adsp_sram_power_on(sdev->dev, true); + if (ret) + dev_err(sdev->dev, "adsp_sram_power_on fail!\n"); + + return ret; +} + /* on mt8195 there is 1 to 1 match between type and BAR idx */ static int mt8195_get_bar_index(struct snd_sof_dev *sdev, u32 type) { @@ -382,6 +420,10 @@ const struct snd_sof_dsp_ops sof_mt8195_ops = { .drv = mt8195_dai, .num_drv = ARRAY_SIZE(mt8195_dai), + /* PM */ + .suspend = mt8195_dsp_suspend, + .resume = mt8195_dsp_resume, + /* ALSA HW info flags */ .hw_info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |