From patchwork Tue Nov 16 15:46:09 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: 12622747 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 B54A2C433F5 for ; Tue, 16 Nov 2021 15:48:19 +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 EC28661526 for ; Tue, 16 Nov 2021 15:48:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EC28661526 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 480BA1696; Tue, 16 Nov 2021 16:47:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 480BA1696 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637077697; bh=Q68hKuTbHoZ/Lx7YWAgHjvatLLrLX/X74bd+Z6qiZQ0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=E/sqyX+yMikB1UrjjHSnmjkU2kw903YfVG3oqNgGsc9BtdwgA2T5muBm0rUX2Pnza Kryox1GRdpnBZmMs74s+zY7+aP3B7PTlDSp+JpNM6uvlI05unWUX7QlM87rThi8qv+ etAQjxnbWNYt9rlYM44lvkyZMuITWzMF77R8UfPM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8FB51F804E0; Tue, 16 Nov 2021 16:46:45 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B5DDDF804C1; Tue, 16 Nov 2021 16:46:40 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60073.outbound.protection.outlook.com [40.107.6.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 848ABF80089 for ; Tue, 16 Nov 2021 16:46:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 848ABF80089 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="iHvo53Ws" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OyyHIE7tQG3N/DuB9TDiXCpC09Uc66zsiYHE2bM6vrUWZsXGBYUgzds0+prDdWI/+wihIM6LCRw7uKUAa67iiUbs3jru1jkSuiSQTeevN5Avn7TFcPJwkpnwD8wDzc5eUWwhYcQc9zMz0Pyw0oQ5vqhRfKK+HCb82CpynRIAMtnXHRIp/RFop4nZwU1eZDASA8BpJGs8JVRQx4Bt7bsqGiN4z3jBtkxolvHrJt5HBVwq8xsFbofmuV6Jfd4J0gbbWy3elKkU2MpTIC2wzDGYueweh2RfNAYSZElUE+pJtBEAmjqOWakuf+6O9KTNMV7nGW0WDk7C3Ihnp0jiLiIQJQ== 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=BeiXOMZ1lW1CcWDJMxc9X5sgHb6Ep25ieGa9wcv755o=; b=Rfu5NCFZQJ2PoR6r4O8o0EDnJPkq2Sh5yXF0R0rngcGfWE+tcmix68YoKC4MFNve6QxT1XbulYutpUoniDMgABoru4Wqob4PAbHOLE2ck+B0xb9B3jC7FdT5vPSg38nNoD9ri172CNZNB4SbNcXZ6pLjaNl8f0rxnCLqLpBlwXUp0Py96nLsheVkjVQQZdBnW/BAXpkMxTvVdUuHwfQLQ1C7XjxrcUN9VgbYRFGuiiWv3SsWWE/2tOXnKeTCjXiMvoC1PX8Z9xG3VYfG3aXUZjWVBCIXIjWVHbenEI057qK6y1pmtt/V4rKSnFtlksqw+6/j8rdydgx1swz6JxmXlw== 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=BeiXOMZ1lW1CcWDJMxc9X5sgHb6Ep25ieGa9wcv755o=; b=iHvo53WsKVRlZmwEJ1XqKqDx69o3jZmfAZcMmaAX2idskPzR7byjW1Ad6RnkJAjHZJxTW9mnUSnL5xcP0vDC7U2C645p2zQAUPO5J+tXnmgqRdp3noysTjgAcS9kvbysEmAgDeiRFlRg00LtjHpjT9zwb76c4ZqHYab3DLI/KOo= 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 VI1PR0402MB3824.eurprd04.prod.outlook.com (2603:10a6:803:22::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 15:46:31 +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; Tue, 16 Nov 2021 15:46:31 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 1/5] ASoC: SOF: imx: Add code to manage DSP related clocks Date: Tue, 16 Nov 2021 17:46:09 +0200 Message-Id: <20211116154613.57122-2-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211116154613.57122-1-daniel.baluta@oss.nxp.com> References: <20211116154613.57122-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR06CA0076.eurprd06.prod.outlook.com (2603:10a6:208:fa::17) 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:1e69:ee6:2dad:c9e7) by AM0PR06CA0076.eurprd06.prod.outlook.com (2603:10a6:208:fa::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Tue, 16 Nov 2021 15:46:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: afa97390-4737-4820-839d-08d9a91842a4 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3824: 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: Uk2tH8LTTiO+QGnzqEnF1IyHd5kf5PqhPkXYkttLVWApqjd+8pTpXja3Dacypam5nhZf2Pg3D49bViJ6gTvlncL+c7+6i945QOnK7WFcjNUftPPOdc3lj/vH/EJ56locJjVRUGGnp4vclAbqukjUnjkKiKMI3IyEBX+GnJaePyiZ2lfR+q6OdGyLmL4snAhiq5mWd5chVs6ALzt91U3M2Fdt0h5/BBo3beCikPoeX0LUY8MraY4dAFjhULdy2RuA+b3AjrXhltQN+TSPyFrIcW5RGGuGDon75iqdpb1hUi5BSVOcaD7DQJHtXE0cophKUpDPHI7Xp6ny9CTRTectJ5Fqeu6UYrxQKXotZAWAxC3XfWAEtqicHuQgM6qBjD6mLfSre8sgMtDIjBBKSVFn7wOxkSxyO48m2wcIRZUBULZU50JNVeEskYQAL39QUk8byczv88pH9WbQn5deZ2ZIaC3Tde1nYwRzWzTshWP/mMIJ3uRb4i5/qC2Ywlt1rr3m5yYKrpGeYPR3S0oNzjb8Hr1OAiL1tAGhp5bdZppT9XNkInV59/l5P5bpFA4yZDYjBLoT3W/9X34uV5mNNrTK7M/sisEujzsilGoaFIS367ljiT2xd821piyFbOCtBhxk5JeaBYWROeALNk3cG3JTeA== 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)(6486002)(186003)(5660300002)(1076003)(8936002)(38100700002)(66946007)(66556008)(66476007)(7416002)(86362001)(44832011)(6506007)(316002)(2906002)(83380400001)(6512007)(54906003)(6666004)(4326008)(508600001)(8676002)(2616005)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cq5OInA/J5+FKpAxfa8ToOqqDJ9GdNDWO9I6yMHQ3iekcWnjl52JT5yuLT543HUrbYijnMNn0atH8B2+1v1C3pMJ0BCJgjyeuI/Cdmhg2MX6eMdOpMLI6zLI2659kZj9dA0NUNGHd2OlSq8LJZ25Gv9lL42e2B7DJLPs2b2jmrvtvNvFwEFhO8AZoc/shmxZ/10DGIbEwdqzymrwT+f/zPvCRlsi1/JGpRl9EcvoBuVOwq5kbYsjdoj0nPhPv67j+d4qt3sKN1FvVLrnwPJWJqkcL2s1x/KaqsuhXDAah3JNK8jO/a4sV0Em0zQ7+IMsJnfrIn1PWedZcOcEupeWUtYa40fwxOjLwjEmD+xqgRzyzbWR8eeFszN34PO3iSr8c+0nhci1Spq9PfMeZldyIEbS9B+JgB+H5UBjq9RB3IAac7UhvTkjGzkDeV51xA3NFfYvaqGzYcH7Z/4d6T8HbpF/RXotKJS7mWzejdxMZFP5h7cEejwV/eu7975NrrBZvH7kMVYa0wiAIaUJe9H9lbzN8c7ptXy7+r+DQYaVBmAvyLZa/t21bkPZsR4b6wDILac0VAi4HmIvwADYmHJCjVHBce8NBIBlJBdn4uGdE9xOmdp54to2onO5ikg8c4HM1m5K5qQXwqJe2tM4UCC7D4LI9tI6j2VQzk/yAuqkHaWnjvdsoe9iu3FkpJ7HNNWClaNMEL42ECXnv+EEZR1nR8BuanRqxqqXV58s8mvBSLreyK57ZqzDxnrq1o4QxBmdyaffX3petV6gxnOIRtJC4sicguc7Ra/cnPdM2wR6CEH/p8QepOX+4Zb0+Uv2iYgTfxxtqS1L1IzEfRs+CHiePeviOPYOS6ZtmzHo2KUFpSATYdseTDRqGe+yNoSOcN5EmHGdlGfDqfAknd2ly8Nf7dlaAlnkehrPTDqXgPGjIlM+aaXJSw6ghyaj2LL0Zr6y/kh6Znglw5Nz5vg8fchLkIf4cR6vO36noz3GHFcbaewqFFuyxY/xx1BOw6MKqyu/3mBagTQ/wWTUMMoNaoQIP/vjzhFxgRhv/oGhO29tlwxuhSoPmoOWBY1fSY6JjHIqSIjrCaZ4UyseABXr5oUmtH8b1ALGvH2sR7ufmgi895erbdLjD4ye9GIBNAkWs0huTxBSvmB1ODvFdOYwfY9G8X0FJZmmLtLksxA/LnbrYmcLcik/7dcInexM6AKsHncHE8wU6IV8VZSKlCw6aLrPZYm70S+2GnSgTIDrVmMuqi30wTUywVh1i09haNB98zBnmc/bR6/XA/nejijwKNmAJ/SNETkf+o9EBZF54qyPlXcvfESHu7/zTpiJj7iuqt3aJ1TwkMBcDmvObAtp7St1F545YETPLn3WJh3K8BqqadhiyV3vQ5lQbZSSoamliudvOZvbChzy6o+ZWzNRJwcEuy1ima3CJdPdaLoCF+gLDIO8fa8iNCFI1UgWyIkCipOJZas5lCW6CSleT1gI5wnAy3xjywsFxSW5EcFgKwByN03grQB0xWzbog6ZZ1J4uarw8hMtge/jnPJu0nAfEPbLPpEC10NdKQASD4f/x5lS9T4xpK0iSpzJ4iTetmXlQQFdL/KGx27/AS1cjjjvxikOa175MsDMQmlNf/shsWZZFWvREg4nulOD9eVQYD/JTor/9KLME9K/FdUhyinJrm42JGyV72HpNGR8zuedEx8cv0QmbFMOGezosCuAPms3aAo1 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: afa97390-4737-4820-839d-08d9a91842a4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 15:46:31.3831 (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: MywTi4VxCdJRPF2U/s6hATKctLdnbj+mogTTXSAB1Xquno0ilcsQ61yyyqLBp8Q+SG6ttIK8V88igyTwfeiL9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3824 Cc: Daniel Baluta , guennadi.liakhovetski@linux.intel.com, daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, linux-imx@nxp.com, Paul Olaru , peter.ujfalusi@linux.intel.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: Daniel Baluta We need at least 3 clocks in order to power up and access DSP core registers found on i.MX8QM, i.MX8QXP and i.MX8MP platforms. Add code to request these clocks and enable them at probe. Next patches will add PM support which will only activate clocks when DSP is used. DSP clocks are already documented in Documentation/devicetree/bindings/dsp/fsl,dsp.yaml We choose to add: * imx8_parse_clocks * imx8_enable_clocks * imx8_disable_clocks wrappers because in the future DSP will need to take care about the clocks of other related Audio IPs (e.g SAI, ESAI). Signed-off-by: Daniel Baluta Reviewed-by: Paul Olaru Reviewed-by: Pierre-Louis Bossart --- sound/soc/sof/imx/imx-common.c | 24 ++++++++++++++++++++++++ sound/soc/sof/imx/imx-common.h | 11 +++++++++++ sound/soc/sof/imx/imx8.c | 23 +++++++++++++++++++++++ sound/soc/sof/imx/imx8m.c | 23 +++++++++++++++++++++++ 4 files changed, 81 insertions(+) diff --git a/sound/soc/sof/imx/imx-common.c b/sound/soc/sof/imx/imx-common.c index 8826ef94f04a..9371e9062cb1 100644 --- a/sound/soc/sof/imx/imx-common.c +++ b/sound/soc/sof/imx/imx-common.c @@ -74,4 +74,28 @@ void imx8_dump(struct snd_sof_dev *sdev, u32 flags) } EXPORT_SYMBOL(imx8_dump); +int imx8_parse_clocks(struct snd_sof_dev *sdev, struct imx_clocks *clks) +{ + int ret; + + ret = devm_clk_bulk_get(sdev->dev, clks->num_dsp_clks, clks->dsp_clks); + if (ret) + dev_err(sdev->dev, "Failed to request DSP clocks\n"); + + return ret; +} +EXPORT_SYMBOL(imx8_parse_clocks); + +int imx8_enable_clocks(struct snd_sof_dev *sdev, struct imx_clocks *clks) +{ + return clk_bulk_prepare_enable(clks->num_dsp_clks, clks->dsp_clks); +} +EXPORT_SYMBOL(imx8_enable_clocks); + +void imx8_disable_clocks(struct snd_sof_dev *sdev, struct imx_clocks *clks) +{ + clk_bulk_disable_unprepare(clks->num_dsp_clks, clks->dsp_clks); +} +EXPORT_SYMBOL(imx8_disable_clocks); + MODULE_LICENSE("Dual BSD/GPL"); diff --git a/sound/soc/sof/imx/imx-common.h b/sound/soc/sof/imx/imx-common.h index 1cc7d6704182..ec4b3a5c7496 100644 --- a/sound/soc/sof/imx/imx-common.h +++ b/sound/soc/sof/imx/imx-common.h @@ -3,6 +3,8 @@ #ifndef __IMX_COMMON_H__ #define __IMX_COMMON_H__ +#include + #define EXCEPT_MAX_HDR_SIZE 0x400 #define IMX8_STACK_DUMP_SIZE 32 @@ -13,4 +15,13 @@ void imx8_get_registers(struct snd_sof_dev *sdev, void imx8_dump(struct snd_sof_dev *sdev, u32 flags); +struct imx_clocks { + struct clk_bulk_data *dsp_clks; + int num_dsp_clks; +}; + +int imx8_parse_clocks(struct snd_sof_dev *sdev, struct imx_clocks *clks); +int imx8_enable_clocks(struct snd_sof_dev *sdev, struct imx_clocks *clks); +void imx8_disable_clocks(struct snd_sof_dev *sdev, struct imx_clocks *clks); + #endif diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c index 0aeb44d0acc7..32f852cbba30 100644 --- a/sound/soc/sof/imx/imx8.c +++ b/sound/soc/sof/imx/imx8.c @@ -41,6 +41,13 @@ #define MBOX_OFFSET 0x800000 #define MBOX_SIZE 0x1000 +/* DSP clocks */ +static struct clk_bulk_data imx8_dsp_clks[] = { + { .id = "ipg" }, + { .id = "ocram" }, + { .id = "core" }, +}; + struct imx8_priv { struct device *dev; struct snd_sof_dev *sdev; @@ -57,6 +64,7 @@ struct imx8_priv { struct device **pd_dev; struct device_link **link; + struct imx_clocks *clks; }; static int imx8_get_mailbox_offset(struct snd_sof_dev *sdev) @@ -188,6 +196,10 @@ static int imx8_probe(struct snd_sof_dev *sdev) if (!priv) return -ENOMEM; + priv->clks = devm_kzalloc(&pdev->dev, sizeof(*priv->clks), GFP_KERNEL); + if (!priv->clks) + return -ENOMEM; + sdev->pdata->hw_pdata = priv; priv->dev = sdev->dev; priv->sdev = sdev; @@ -300,6 +312,16 @@ static int imx8_probe(struct snd_sof_dev *sdev) /* set default mailbox offset for FW ready message */ sdev->dsp_box.offset = MBOX_OFFSET; + /* init clocks info */ + priv->clks->dsp_clks = imx8_dsp_clks; + priv->clks->num_dsp_clks = ARRAY_SIZE(imx8_dsp_clks); + + ret = imx8_parse_clocks(sdev, priv->clks); + if (ret < 0) + goto exit_pdev_unregister; + + imx8_enable_clocks(sdev, priv->clks); + return 0; exit_pdev_unregister: @@ -318,6 +340,7 @@ static int imx8_remove(struct snd_sof_dev *sdev) struct imx8_priv *priv = sdev->pdata->hw_pdata; int i; + imx8_disable_clocks(sdev, priv->clks); platform_device_unregister(priv->ipc_dev); for (i = 0; i < priv->num_domains; i++) { diff --git a/sound/soc/sof/imx/imx8m.c b/sound/soc/sof/imx/imx8m.c index f454a5d0a87e..ab40c0bdf796 100644 --- a/sound/soc/sof/imx/imx8m.c +++ b/sound/soc/sof/imx/imx8m.c @@ -23,6 +23,12 @@ #define MBOX_OFFSET 0x800000 #define MBOX_SIZE 0x1000 +static struct clk_bulk_data imx8m_dsp_clks[] = { + { .id = "ipg" }, + { .id = "ocram" }, + { .id = "core" }, +}; + struct imx8m_priv { struct device *dev; struct snd_sof_dev *sdev; @@ -30,6 +36,8 @@ struct imx8m_priv { /* DSP IPC handler */ struct imx_dsp_ipc *dsp_ipc; struct platform_device *ipc_dev; + + struct imx_clocks *clks; }; static int imx8m_get_mailbox_offset(struct snd_sof_dev *sdev) @@ -108,6 +116,10 @@ static int imx8m_probe(struct snd_sof_dev *sdev) if (!priv) return -ENOMEM; + priv->clks = devm_kzalloc(&pdev->dev, sizeof(*priv->clks), GFP_KERNEL); + if (!priv->clks) + return -ENOMEM; + sdev->pdata->hw_pdata = priv; priv->dev = sdev->dev; priv->sdev = sdev; @@ -175,6 +187,16 @@ static int imx8m_probe(struct snd_sof_dev *sdev) /* set default mailbox offset for FW ready message */ sdev->dsp_box.offset = MBOX_OFFSET; + /* init clocks info */ + priv->clks->dsp_clks = imx8m_dsp_clks; + priv->clks->num_dsp_clks = ARRAY_SIZE(imx8m_dsp_clks); + + ret = imx8_parse_clocks(sdev, priv->clks); + if (ret < 0) + goto exit_pdev_unregister; + + imx8_enable_clocks(sdev, priv->clks); + return 0; exit_pdev_unregister: @@ -186,6 +208,7 @@ static int imx8m_remove(struct snd_sof_dev *sdev) { struct imx8m_priv *priv = sdev->pdata->hw_pdata; + imx8_disable_clocks(sdev, priv->clks); platform_device_unregister(priv->ipc_dev); return 0; From patchwork Tue Nov 16 15:46:10 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: 12622749 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 20E88C433F5 for ; Tue, 16 Nov 2021 15:48:26 +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 8ADD961526 for ; Tue, 16 Nov 2021 15:48:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8ADD961526 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 A804D16A5; Tue, 16 Nov 2021 16:47:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A804D16A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637077703; bh=qmzWD08Kfa8VlD+nxKsplmD7jlP0ovWLFkY4Le3ntNk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LNHoMets/Ft4Y1AEThJronHQLkUABnE8EnlbZL0EIPQolEglE3kCxbdaTAn1Msw+K 3Ch9M/OFrm26FcWVANr4DQBIGmMspkSt7Dr8UyT4dQFtoxWezpdW0SdocDRdQ6zL3s 4IqKirJew76GGf2dzkcTJQPM7uSg2sOIlhzuTsmk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 98908F80272; Tue, 16 Nov 2021 16:46:48 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4FE3BF804E7; Tue, 16 Nov 2021 16:46:46 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60073.outbound.protection.outlook.com [40.107.6.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 C131AF80134 for ; Tue, 16 Nov 2021 16:46:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C131AF80134 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="ME4+RFIS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mlejee4M58q8adjdyhD/F2Oq+3KEJOQUtJ38LoB4C9jStuIcr+z7PUK+6ZZZvsD/LcUyNIyrvMPIS4SqkYJeYafy5UacB2ZKV5HKrokRlnY2xfXR3lDPSeF1EqvAm7TCNOLcvANx7LMNM5HkVCu3/yHaZE2IZv3ZufabWTQ93L/pgGFjv5W3R0oDhh5P2ZLT8Jr2PgAulvktGOyB4Qz1pmrnRfRJ+QQEyqnwyZUIFrIfrr3KdA1thwlGDRb9UYhaCc6TH30XGm3D5uLVgK/XvxCjq/uwlliy2IMbSF1xX0jsiupOgyoTD+QxHmRR7mIc7q2sXpeuCXG0X/DqChPUIQ== 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=Hxh10uJCvH4bSN1kqJK3p+nh3xdYf0fnlgTDIY2+/gk=; b=bQaxMcd2SAqcxLuS8QEB9TemIwpd/bxZRxF6GBxB8D3PoYy4WNNhIVFu9iQkOnOetX7mAzaMykp7M0v2RB73F5bJJCBR9gMoSeZ41RxAiwSF1i6G4LhzCBjl24Zi92QNcaG5+Dx9ftXNdTx0fYi6iRnGUPLEIsHMgFvM7g6FRfJPr1ZGVfCktGCTmhTL2Pie5HeJyaxoOjwTMRL6rNBfN7u4m/Psu/mYXo/n6uzeBr2eIUhJGNt1EiStKEiuxQ9Y8UJkfnLVCXUYHnxDIdz4SZPwpU0lgw0FWHijC45zi5vBcKrYSL6RudELh2DYdOqx6tBW4JuTUiFZFzwe07Y83w== 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=Hxh10uJCvH4bSN1kqJK3p+nh3xdYf0fnlgTDIY2+/gk=; b=ME4+RFISQO9F6IbNXh/wqVophbddsKo21Uua1r1d6m3z+nOweLIffNjl7qUyS1GM0Rm69EOoQlTS8gAdH4AC12l4epQEh/EmAdqA2VddT/wBDZHugu9bctgjsA0fDcdfh8S3WHj0LDsmG/PXd/pFSZntDPxLt81Ks6iQ5Vd9GsM= 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 VI1PR0402MB3824.eurprd04.prod.outlook.com (2603:10a6:803:22::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 15:46:33 +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; Tue, 16 Nov 2021 15:46:33 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 2/5] ASoC: SOF: imx8: Add runtime PM / System PM support Date: Tue, 16 Nov 2021 17:46:10 +0200 Message-Id: <20211116154613.57122-3-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211116154613.57122-1-daniel.baluta@oss.nxp.com> References: <20211116154613.57122-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR06CA0076.eurprd06.prod.outlook.com (2603:10a6:208:fa::17) 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:1e69:ee6:2dad:c9e7) by AM0PR06CA0076.eurprd06.prod.outlook.com (2603:10a6:208:fa::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Tue, 16 Nov 2021 15:46:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e4ba31d0-c80b-4bdf-3c20-08d9a918437b X-MS-TrafficTypeDiagnostic: VI1PR0402MB3824: 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: hIegHaYrzkY2swLq5qt6PIALEOVoZJMbsB6Mc5GGx47dttDGOqg92IM17HiWfODvfkaUzMZv2QBSdOZQY7fznF/+Xa90xHRPo0FTqWdS4ONUQMELTFyiJq5+S29294+HWK1xInvIG7y8+eLXfVPLRpQBFmkJ9PtLloVGjkgOAa8ltkFNIKdzB3F5TfiBC+KlRrKi0UgyY+8zWH1w99Gaa/PwnzNOjJ/c82PJv8w9IlJIOzExjCujXKkeornzINrcPZ6yaEpkm9SZrdLcJs3khygM5rSTvZDrb7KEHTi441bHbaZgz5jILbxobadZhRMzpQk+0EHBG4aUy7jWVPQ7Qfh1YyZCuB0k3hG+U9CjYrbdqa1hrWwLageq2d17diG36veSZ5G8xuWFS5WQL2B5BkAPgKAhJAbBtha0Zz6Gl9DWC9SB8hxWufHaNKJZOX9MIFiRxiSPIU+l8rA9hT1I4oVeqH7O1qKgAYDxxkA0p84+Gn4838HtlFPfw8FjkEIGw+Ta3QcwgTGOuRT2L0K2IPWtCqqGQjaPUrGr5UurStVMXlY/ReedWfEPsyAwx/vuNwys6DS1IuEaSW9JAiCdg0eSMCqs7y5lslL+zB8C0iKBUigorlBwkSwc5EIYdN9Bz/y1Hjrhc4JN3xteLCrhYQ== 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)(6486002)(186003)(5660300002)(1076003)(8936002)(38100700002)(66946007)(66556008)(66476007)(7416002)(86362001)(44832011)(6506007)(316002)(2906002)(83380400001)(6512007)(6666004)(4326008)(508600001)(8676002)(2616005)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1zEI+rZf64ZKZZW7Zs98o/O2ZraTKi2iJm0rlQL+LcEQSNvvelDr9Z2VnzP3rtmmxOzSEUr41gLvBvhT/Xa56myeeky3lOUMBTaO3aCSaaVGVMYzlQfF8nNiW221nq53V2mwiCjWr2UTSVD6+Nv9jkyqvJTA0f6EWAfAH1G3m+bH3K5vz/e5efZMREui6ILPsKPlKS6ZnykV4O9MMD+urgsz7sG9Q5/8Y0PwjxMENJ4BQTSFIR5eRX0T2xqMtQtCnR+jy4+9OngSiztyjuGBv+jGr7VeSpb7z+BOdhUFuAr+OGJj4sFQqE2BnmjMYzdpCcFz7n1hPiP7dFQNG87fee6f/LxSFQdWr+bpKle+vOWaXQcdXGmzUZZUiAeUp6SqAEh3CxttQ/mfPLd+Xa2is+6BOkEWPEZexQ4/f0iAL98Bov5sYil0tII5OIgymle1BTbg2K/OJf6x3R9aPSDMfDdu8ZQoi5GecxE2sEYTfGtcDvuNjxKA+R8DHxLuJKnYi4NLzASAlzTss8bjoM52ya7L0YB+mcqiLFPaMP0xbl1E3Q9bE5KSt8/Lun0JYohTiso3oM5ITw8j6y4aGTFUMIFUA3sxAnrb0GoKoUcgINQbdnfB6LDtTHHzRbwEVJiSESZA7UQm6sZTlwRZ0gTUIlX1z9Ss8tPYVjN0Vb8Ph5th4fmZ53jeUj3W/KrTZ3rXvmwSgT0XRuEWIS+BuI8cWor++HxTgQE0dnwoHmcRpoNpuUh/w9ZOH4kQE1Eam0YG4hL6PRsUPr6YUm7YYCubr+SYiB/cCronBdjBK+h1xm69nvdQzWsRiL/MwhRRmhj9FbW1+lPV7r5IKKHzQvSl5P1axyIe6WpYPhMhwEpW1G7KkEEpBN9Mjz1d0WdyKN0eZ2yQpcL/n5dnlBM8jgaXpicHBJDAUSAOdx2pEPcgmDCZTaqeQpBfjy7cFPmTG3VMqLIvQAihLpR4RaTy2O7Ahtrq2XWFEU6DOeo6St3edNmLnue4IXlUCsXQOw3cu5sNhr+BCgojwuPSz15yivSnf7C//r9XEnWx0Qvo/JHrEpC8cBwa1xn6P395YkW1aMF57nRjAudiPbHRFmDiC15rSdefvvZ1iFun2fC7brbFTE4vkkCRT0b3aTaIYSBJLRZXA8csnBBojfaaL1d3NwkpAPYMSt7z4c8v0r2lKQlBNIDoZyaExsmg73N0gFLKyCgxpAJ5+o7WVayVy/Gk571cfrM8BKFxY5zz677+pG2ilBEMavfjMh06mtYLAYNCN96n6dM3bVvHkU2QiHDvPeS+erNfDIxPDZo/Y1fXDiBsSfEC6uTNTrkg6CqgclqxkMEjF1hnvN9xaScaJIbtWRQ/DAGO5cmL6xT4nd89crqIC3n9rfqZFECIoomj4WHmFBd/G81/jMsS4Y3eAQBpwfH/fW+utBEFNEqjjNPatM4i0QDRY1VZmylAeYJl9zU1DXdO3Dcyxoks5V2hhiRLpxyQu0VOim9a1MiHl4ZVMiwz/8BQSaLzebgtgx4qhA5+c+odiWOzO3ksAXqlCWO03JpsK57cFBLh0QyBNY9yGWLveNdKsvhlH6hAPnfQTY8NKcG4xQtMJoBi8UNeTc8RlNP6SoeCm+Ibs0c5Dhim5XrVYjHTZVqShwMkaSSE4NkuHeqewP8+Lf3UCfxPIT1D6hi5UGrZXX5I6L4UwW6SfCRH7nU= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4ba31d0-c80b-4bdf-3c20-08d9a918437b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 15:46:32.9043 (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: phggCjA1mLaUSzUWGJQv9+m1jHJN0QnTos4gYNBIQ0+yVUznGoAYZzg3XhOF8qk2dM7RaxOU07iPsgze2Fa1eQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3824 Cc: Daniel Baluta , guennadi.liakhovetski@linux.intel.com, daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, linux-imx@nxp.com, peter.ujfalusi@linux.intel.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: Daniel Baluta Handle clocks and mailbox channels at runtime suspend/resume in order to save power. DSP runtime PM uses a timeout of 2s. If device is idle for 2s system will enter runtime suspend. Because SOF state machine assumes that even if the DSP wasn't previously active at a System resume, will re-load the firmware we need to make sure that all needed resources are active. Kernel core will take care of enabling the PD, we need to make sure that we request the MU channels. Signed-off-by: Daniel Baluta Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart --- sound/soc/sof/imx/imx8.c | 116 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c index 32f852cbba30..c4755c88d492 100644 --- a/sound/soc/sof/imx/imx8.c +++ b/sound/soc/sof/imx/imx8.c @@ -320,7 +320,9 @@ static int imx8_probe(struct snd_sof_dev *sdev) if (ret < 0) goto exit_pdev_unregister; - imx8_enable_clocks(sdev, priv->clks); + ret = imx8_enable_clocks(sdev, priv->clks); + if (ret < 0) + goto exit_pdev_unregister; return 0; @@ -364,6 +366,92 @@ static int imx8_get_bar_index(struct snd_sof_dev *sdev, u32 type) } } +static void imx8_suspend(struct snd_sof_dev *sdev) +{ + int i; + struct imx8_priv *priv = (struct imx8_priv *)sdev->pdata->hw_pdata; + + for (i = 0; i < DSP_MU_CHAN_NUM; i++) + imx_dsp_free_channel(priv->dsp_ipc, i); + + imx8_disable_clocks(sdev, priv->clks); +} + +static int imx8_resume(struct snd_sof_dev *sdev) +{ + struct imx8_priv *priv = (struct imx8_priv *)sdev->pdata->hw_pdata; + int ret; + int i; + + ret = imx8_enable_clocks(sdev, priv->clks); + if (ret < 0) + return ret; + + for (i = 0; i < DSP_MU_CHAN_NUM; i++) + imx_dsp_request_channel(priv->dsp_ipc, i); + + return 0; +} + +static int imx8_dsp_runtime_resume(struct snd_sof_dev *sdev) +{ + int ret; + const struct sof_dsp_power_state target_dsp_state = { + .state = SOF_DSP_PM_D0, + }; + + ret = imx8_resume(sdev); + if (ret < 0) + return ret; + + return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); +} + +static int imx8_dsp_runtime_suspend(struct snd_sof_dev *sdev) +{ + const struct sof_dsp_power_state target_dsp_state = { + .state = SOF_DSP_PM_D3, + }; + + imx8_suspend(sdev); + + return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); +} + +static int imx8_dsp_suspend(struct snd_sof_dev *sdev, unsigned int target_state) +{ + const struct sof_dsp_power_state target_dsp_state = { + .state = target_state, + }; + + if (!pm_runtime_suspended(sdev->dev)) + imx8_suspend(sdev); + + return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); +} + +static int imx8_dsp_resume(struct snd_sof_dev *sdev) +{ + int ret; + const struct sof_dsp_power_state target_dsp_state = { + .state = SOF_DSP_PM_D0, + }; + + ret = imx8_resume(sdev); + if (ret < 0) + return ret; + + if (pm_runtime_suspended(sdev->dev)) { + pm_runtime_disable(sdev->dev); + pm_runtime_set_active(sdev->dev); + pm_runtime_mark_last_busy(sdev->dev); + pm_runtime_enable(sdev->dev); + pm_runtime_idle(sdev->dev); + } + + return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); +} + static struct snd_soc_dai_driver imx8_dai[] = { { .name = "esai0", @@ -389,6 +477,14 @@ static struct snd_soc_dai_driver imx8_dai[] = { }, }; +static int imx8_dsp_set_power_state(struct snd_sof_dev *sdev, + const struct sof_dsp_power_state *target_state) +{ + sdev->dsp_power_state = *target_state; + + return 0; +} + /* i.MX8 ops */ struct snd_sof_dsp_ops sof_imx8_ops = { /* probe and remove */ @@ -441,6 +537,15 @@ struct snd_sof_dsp_ops sof_imx8_ops = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, + + /* PM */ + .runtime_suspend = imx8_dsp_runtime_suspend, + .runtime_resume = imx8_dsp_runtime_resume, + + .suspend = imx8_dsp_suspend, + .resume = imx8_dsp_resume, + + .set_power_state = imx8_dsp_set_power_state, }; EXPORT_SYMBOL(sof_imx8_ops); @@ -490,6 +595,15 @@ struct snd_sof_dsp_ops sof_imx8x_ops = { .drv = imx8_dai, .num_drv = ARRAY_SIZE(imx8_dai), + /* PM */ + .runtime_suspend = imx8_dsp_runtime_suspend, + .runtime_resume = imx8_dsp_runtime_resume, + + .suspend = imx8_dsp_suspend, + .resume = imx8_dsp_resume, + + .set_power_state = imx8_dsp_set_power_state, + /* ALSA HW info flags */ .hw_info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | From patchwork Tue Nov 16 15:46:11 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: 12622757 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 033E7C433F5 for ; Tue, 16 Nov 2021 15:49:16 +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 815D46128A for ; Tue, 16 Nov 2021 15:49:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 815D46128A 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 DB3D01681; Tue, 16 Nov 2021 16:48:23 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DB3D01681 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637077753; bh=gDXsePIINijFcRBl0JUvbKmwenpAxv3E2uwk50Gvf3E=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=edUH0sf0VszDNqA16SHZrJuhB4VoN9IMcLOEZA+gS9f6whrprQhcx4NgZOyqxiwwE YJdsGwF3lN5+fOssrbdjaEfSnC2+obelSOpNUcuDCyri6nkC60wVky3MWnKsn1eA+H X5N1i8PLQc3ohnVE2LJKCcBkowvLwcOQj76AjK90= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2BD32F804FA; Tue, 16 Nov 2021 16:46:50 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0ED90F804E7; Tue, 16 Nov 2021 16:46:47 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60073.outbound.protection.outlook.com [40.107.6.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 1852DF8026D for ; Tue, 16 Nov 2021 16:46:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1852DF8026D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="J4xcqoTf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XcSw3anQNSQxXpPkt/RINmWOaULLaUPhpnXpAK2B5d3iCDFdClMA27dfDIwebZ+gpzadQdzMUi05yyQmofYqB4STpce94qo4luwJFxxbWamhGCiuEzqr+Kwdy6dANX2cnVQPvD45UvyOWylfEd+N7lLbARKIyTgV7y9o4Avv3RwQz3q8AZ3ybizLs2zsGyIJpeLtxELBIeicl9jHvSoSHrsbQtU7XTvgoikbyOaIDYNlyO0B5yv7+ynncY3KaghQ565Gmcpw18kF0PVNneTquwQAkjd1PllYw2Rnz9oSmT9wHpYWvjaAQG/voU1E8YS2aIP4l7WKZPnKFs204KgKxg== 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=cf3aF4hGrNpyw/4Xn2+HETnOhQMqs0Pa78OKvZGJSvs=; b=mf+aawfy52ygXsofuW537SVdz/4M2V/+2T52HzJpvo+SgVR2OwqVXQu0Q85HeFBu9RXszOcMTwnLhp/DDJBOLbftCkawmwsDuKOshqARfQmW034cU7PjBjjAmBYsDbBjVvoXczMkwrV2aqmFftlk7eEYc907POMZhwn6ymqbqBEqV4fgU/DXgLta92C2V8LNuAztm3Oakp86Elbos+jXJnPRMTcxUnhbqxKkhezoOdN6gBjJB0m6AH1bU6eb3IbkM0CLxDn9MVoYgOV00EkcLS3IVksEJXp6kLIF4G+bLAIAx0Ax9bErGCHrl8S02SytEJTVMX5lf7lKjQpoZuj78w== 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=cf3aF4hGrNpyw/4Xn2+HETnOhQMqs0Pa78OKvZGJSvs=; b=J4xcqoTfRqCthmKjc2FPjkoXo0RVmxcT0h3e8nM28IBk00Ty7GCKDr4XxzuW8vs8cy5fzkwgQGADZ+TEOFbaJqbr8VNVgr0ZicSnS8VgccAx9H86DfKdvZaJngQ66BfXPkulhAMcyI8elQTzfMAqJNsiZrgBwlIhF5PmsldYhFM= 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 VI1PR0402MB3824.eurprd04.prod.outlook.com (2603:10a6:803:22::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 15:46: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; Tue, 16 Nov 2021 15:46:34 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 3/5] ASoC: SOF: imx8m: Add runtime PM / System PM support Date: Tue, 16 Nov 2021 17:46:11 +0200 Message-Id: <20211116154613.57122-4-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211116154613.57122-1-daniel.baluta@oss.nxp.com> References: <20211116154613.57122-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR06CA0076.eurprd06.prod.outlook.com (2603:10a6:208:fa::17) 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:1e69:ee6:2dad:c9e7) by AM0PR06CA0076.eurprd06.prod.outlook.com (2603:10a6:208:fa::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Tue, 16 Nov 2021 15:46:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66ec6055-ac40-48c7-868f-08d9a9184468 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3824: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z80Ml5TjsYjrOWR9pLDdVGDNTZ3CQxnoc3po2ZxCM1Xg80RGJcALF2uVU7Csn01PuVNHtA51D6iTTzB7efisRLehj2/tAPYJzeXkr6orUEdEWA5u3ObJDM5hoHMJURGTCiHbuXcQLCqW09kjbQx5aMyQULcInl5YC0LQP6uDkpo+WeEFpCqyULnHIKkC7zuSySU71sLIVXuyKND9khj+RnvdQoPgm+MUTWVarZeLClEg7BOCZxDD4ngNCES9mhYKDylLGcwqRF0eK+VKwVqqTCwfdtumX5QAhjmc5EXcpG4w1XHpKTGdJY2DnYJjB384uWyzTNBV3VDL73gZsb2hF6fOBChAgMxqhUP04bX32JPiML03ODXffBOxUdlJqpaJvsmbVs0N7pZEGWjPPMAF3DpIeJK0Q93SZgJ0DT7vBhBvI3nnTw3evoarOLlOUEwc0XkorOFBmMkl9T8Cn485FCrU9XVSTA7jGgr7afbMI/SZ7f+RX5kQVUeOeTygckSqmpHEt4nJ0YuhSouARqH/Arne++plYylCdvwC4ixHJYal3XOixx3ydspFomIFDft0menAe7l/3ubiVnsrgSVwcl4TGaltI+FfSHQaINPfdpt2GuZqhunKK6Oh1zQ+iSOMmt0LsNFFEj+s79kenX1r0ba2xYjvnbMAx5NjizoXymTlexzFSzJRPS4RceB69kdBML7kzRTNfewkwSPv0XoBFg== 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)(6486002)(186003)(5660300002)(1076003)(8936002)(38100700002)(66946007)(66556008)(66476007)(7416002)(86362001)(44832011)(6506007)(316002)(2906002)(83380400001)(6512007)(6666004)(4326008)(508600001)(8676002)(2616005)(52116002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FMVREtEtNmTAzP9qZ/POTzg4HKpefBhaVum5AGtz7CU00ey/yf2yz5+sXoBZj3qtMpMep8BjGc9eRsf/+s8sRCbXsh/zmzX8duUilOh+lQJN9HchMSS09/n625nXFj6pDFeM7wtr2QeGF5pvnZVXai0t9f911RvqaL3RZ+vPBcnNtWcJen6knqgzzpTe1dUi6Aw0voUDTwH7b698F4AAd6C2Jg7cVc6pAeYp+VW4ZBh3NhDUmSXtAe1HZnxSFncJVrVcRjImD3HFH8dQiTk1DkDY9x2AR0TnczsQDqDrVWN70m/y0gYfEJBFOlfuXrs08b/6bvG4zKzKqlO9U794gEEI07YFd9hn/FK8wq+uosayppqjjwQbKOFlv4PIERUFuQZ9FCoZi/TmZ8dgAqAKijm7nW9w0jNexJgxecpmpWYGDlINhp0lb4qzn45J2VEpH5o/wjtf316Vbl+yD0VCj5UU7/UIrX9N+nfywpDyGvyh27dL5xv4LxQo5Zd/wIO4b7tWx74oUAln9hNgJYn98AjCHCYmSpCIbHAPiZIq044wYuAf0e/4KDcGtLlJN5bgyBF6eTFPRDa94u7OZrFCXnFjqZ9Sua2GiLmjGIs8WLH9VCHS1aIPKYn1A92oBHd+m/Z+BWwEAYw2jRxOwFtw+Hsmr8gtzkJUeUARa4JnJx/AWk63yDYipM+R8nM/1ZOnGTA6FpsuFMoG+z/663cXFbqjTzD+1UveoG1tmCZVUkKVgObaFeH+voORBssPkq9qmdk6dfHyDvevl5CVLSNWheqrJkIueHIZyiIBUAKnoYVhTrpQOG091eLnJGedhWHSLOZ190uCQ/kKb13b1ng/9wOV8c8VtGHyj5mb9+XYuq85H52PFIKBSF+4cltnpQcnqXTg6VlvuJu73/SYg9Q6c6lZ0p3n96VJGK9/GkcezvnUPkshYfVTie9xRKM5kZ0MileZwFjnvV/3YK4cMVPKTmI58CY08R9C0V/ULrBnnxoakEPUo9s+SA64Mj3uE4MmTgMD9NBga/kvnFmQujGDZrb2p8Fxa+mqTJ2z/simE/KS3F+t4z73nvKRVqbDN15Kz4JEQ2Z1EeGSkufTyyTnsk5js+2NRqxhY5DKinhjf9J84YjktSsQdUHwZMMVMj/p0Mpx8qcx9tcGXUWKVvHzzJQSAfS8K5LiK1lQUG6B/2AE/TCwSVa5rLEvHHVDSQJf7+XaWMbAJ8Hn5/ZIDEJzucZyAahi6nHDZwEUUsVpxMq/UPLVylpGOurtnS77Wp37sH1juLzUOC2TDvPj6G/xnvRW/Pipv1hN7L/eVC8JJqLLjUhzAKg5a1JdIxMRGQhw2FN1J7YMV727gxVRODuYSKXGtFjm1o3FXLQU6i8eDraVUlAXY/9+n9CmUd3U+LwnN/fjoz6W2G0i0ypbzhVsjVdKaFRxihjuuumNwaDBiVRXsdjqpbguuMUz5IaJgRzvYvNvHJdBdcDs2AaZvwsD2Six0qQ2wrG41UASteRip/rrNURtdkWY/T6BQWaeFuc36A6xSyLTOHgPW/54PjJQRbfZ+TJS5G0JDmf4YT0XeMxi2jgN3ktsQbPuQTnL+jecen3hKwR2HGFH/QFj2+gGa3TTZJkw0mLYGtgvautH6gkc5W8/G+ikir/pKnONz1IXEgfW15DfAABrFulT0RcTnJiCfy/pMdC7HWSAfPiJVvg= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66ec6055-ac40-48c7-868f-08d9a9184468 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 15:46:34.3534 (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: HrR96o/yDycpv/nucS8cR6zFyZn0cOYH8bbkNnMCr6t8JtrgSmSJjupFbLYl1EWbkWDaJbnaHQmATeEiMpp2kQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3824 Cc: Daniel Baluta , guennadi.liakhovetski@linux.intel.com, daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, linux-imx@nxp.com, peter.ujfalusi@linux.intel.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: Daniel Baluta We make use of common imx8m_suspend / imx8m_resume functions for both system PM and runtime PM. imx8m_suspend: - frees the MU channels - disables the clocks imx8m_resume - enables the clocks - requests the MU channels On i.MX8MP there is no dedicated functionality to put the DSP in reset. The only way of doing this is to POWER DOWN the Audiomix domain. We are able to do this because turning off the clocks and freeing the channels makes the Audiomix to have no users thus PM kernel core turns it down. SOF core will not call system PM suspend handler if the DSP is already down, but at resume it will call the system PM resume. So, we need to keep track of the state via snd_sof_dsp_set_power_state Few insights on how SOF core handles the PM: - SOF core uses PM runtime autosuspend (with a timeout of 2 secs) - at probe, SOF core boots the DSP and lets the PM runtime suspend to turn it off, if there is no activity - when someone opens the ALSA sound card (aplay/arecord, etc) ALSA core calls PM runtime resume to turn on the DSP - when the ALSA sound card is closed SOF core make use of PM subsystem to call PM runtime suspend and thus turning off the DSP. Signed-off-by: Daniel Baluta Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart --- sound/soc/sof/imx/imx8m.c | 106 +++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/imx/imx8m.c b/sound/soc/sof/imx/imx8m.c index ab40c0bdf796..b050d4cf9cd5 100644 --- a/sound/soc/sof/imx/imx8m.c +++ b/sound/soc/sof/imx/imx8m.c @@ -195,7 +195,9 @@ static int imx8m_probe(struct snd_sof_dev *sdev) if (ret < 0) goto exit_pdev_unregister; - imx8_enable_clocks(sdev, priv->clks); + ret = imx8_enable_clocks(sdev, priv->clks); + if (ret < 0) + goto exit_pdev_unregister; return 0; @@ -252,6 +254,100 @@ static struct snd_soc_dai_driver imx8m_dai[] = { }, }; +static int imx8m_dsp_set_power_state(struct snd_sof_dev *sdev, + const struct sof_dsp_power_state *target_state) +{ + sdev->dsp_power_state = *target_state; + + return 0; +} + +static int imx8m_resume(struct snd_sof_dev *sdev) +{ + struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; + int ret; + int i; + + ret = imx8_enable_clocks(sdev, priv->clks); + if (ret < 0) + return ret; + + for (i = 0; i < DSP_MU_CHAN_NUM; i++) + imx_dsp_request_channel(priv->dsp_ipc, i); + + return 0; +} + +static void imx8m_suspend(struct snd_sof_dev *sdev) +{ + struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; + int i; + + for (i = 0; i < DSP_MU_CHAN_NUM; i++) + imx_dsp_free_channel(priv->dsp_ipc, i); + + imx8_disable_clocks(sdev, priv->clks); +} + +static int imx8m_dsp_runtime_resume(struct snd_sof_dev *sdev) +{ + int ret; + const struct sof_dsp_power_state target_dsp_state = { + .state = SOF_DSP_PM_D0, + }; + + ret = imx8m_resume(sdev); + if (ret < 0) + return ret; + + return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); +} + +static int imx8m_dsp_runtime_suspend(struct snd_sof_dev *sdev) +{ + const struct sof_dsp_power_state target_dsp_state = { + .state = SOF_DSP_PM_D3, + }; + + imx8m_suspend(sdev); + + return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); +} + +static int imx8m_dsp_resume(struct snd_sof_dev *sdev) +{ + int ret; + const struct sof_dsp_power_state target_dsp_state = { + .state = SOF_DSP_PM_D0, + }; + + ret = imx8m_resume(sdev); + if (ret < 0) + return ret; + + if (pm_runtime_suspended(sdev->dev)) { + pm_runtime_disable(sdev->dev); + pm_runtime_set_active(sdev->dev); + pm_runtime_mark_last_busy(sdev->dev); + pm_runtime_enable(sdev->dev); + pm_runtime_idle(sdev->dev); + } + + return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); +} + +static int imx8m_dsp_suspend(struct snd_sof_dev *sdev, unsigned int target_state) +{ + const struct sof_dsp_power_state target_dsp_state = { + .state = target_state, + }; + + if (!pm_runtime_suspended(sdev->dev)) + imx8m_suspend(sdev); + + return snd_sof_dsp_set_power_state(sdev, &target_dsp_state); +} + /* i.MX8 ops */ struct snd_sof_dsp_ops sof_imx8m_ops = { /* probe and remove */ @@ -297,6 +393,14 @@ struct snd_sof_dsp_ops sof_imx8m_ops = { .drv = imx8m_dai, .num_drv = ARRAY_SIZE(imx8m_dai), + .suspend = imx8m_dsp_suspend, + .resume = imx8m_dsp_resume, + + .runtime_suspend = imx8m_dsp_runtime_suspend, + .runtime_resume = imx8m_dsp_runtime_resume, + + .set_power_state = imx8m_dsp_set_power_state, + .hw_info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | From patchwork Tue Nov 16 15:46:12 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: 12622755 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 C2748C4332F for ; Tue, 16 Nov 2021 15:48: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 066046128A for ; Tue, 16 Nov 2021 15:48:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 066046128A 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 6A5EC1689; Tue, 16 Nov 2021 16:47:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6A5EC1689 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637077729; bh=NUNo40AMwITmYCgzyRCqVYTB8d3VXbdnoe3fxfayUlk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Z+yANMB53/cYdR+M6x1Qij52W3v0a6M7LYbz4hX5MkNqYCJAsDsAChEIn/9FU2UZF YXWZJoMn0bHZfbB9MBldq+TtT+ixha+98nUZhjxmvZSpMnqpl4KHCZObPeqPjwVPer 8NvfDUTtdMsJsdDvx+DXDM0m9O5atRmFEa2ogLLc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 63FDCF804ED; Tue, 16 Nov 2021 16:46:49 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B201AF804EC; Tue, 16 Nov 2021 16:46:46 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60073.outbound.protection.outlook.com [40.107.6.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 5A2A1F80423 for ; Tue, 16 Nov 2021 16:46:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5A2A1F80423 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="Q7hC9tkU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H07wkjqGuI6md6rYk5G13NCjo2LQ6UHMyguT9v7pYgAj6eAVC3WzUGVmfnBKC3TcFsN8VAmI+6WXlKiqWVtzoUIkKSrVcxNNNveUTVSsE2U37hb9Mw4cOwjjrmEes+2ghxmgsQiCxHTIpZOP0m2U+R8ar7NX1qSXwrtwaBoSyNaV1pAQkFUnVSSGyoJK4aExCWRXQsGgB0YJNGMuA+FojkQOaGeFw17ifDR07MJIM/TcpaGCWy6RbQhYaYfTXT2JALsjnux/ME95RQXN5eAfHpA2uhUO6UvJezBIBgR8LTg4Y7CEB0tWuf/50Em+iGpd0xKv1USP1Uq/m11psoHC4g== 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=6LQe9IPWGSX40mx6GtUVgAC3DVkLtlfK3i/BKjyQbsc=; b=ImuN8We4qE2r7egHWMsqfeNJaY+N7qW4yGKosRkaSlyD6ZVYl7UtDnrQHaSyyZN3sB+zQ0QfpLXaqxJkk4K5glfacHwF3Q5ZzRhS7yFuue8h8YKFn0iggTu012yUYdvvbEmVnYG4A6N6pDFxNE1j5ZY75gaKEw9BWEX6yDzwMgSze6qFATnmVSOIt9ZTMoo7g1e3oidSc3K05vJG5JF8dGr8DaONGJ/VbHy0DbFdMYYIwaUWuUE4lxIYcKVSy9Lz4wAb0TX7SuTZz6JEnLtAp3BAwKJ+haMc+IybrcnDqm4kgOcpqP5zxYkQpL3KYDq/9Kvent0pZGHVZ4Tt97oxDQ== 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=6LQe9IPWGSX40mx6GtUVgAC3DVkLtlfK3i/BKjyQbsc=; b=Q7hC9tkUWN3qu28UXQg6luhLMoKu/2jGZC64PEiO+aILWHeviBXhgGpNTFMUwPfLKwfB6EV6Hv88gfuuku1388fgk9WHM5iLw2cxFIDSd2BjPdj4v5OT8PelzMBVd765ncBFElOOMn0srNZxTUQv8PSeCeAZdgwJQcgtOx2m6LI= 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 VI1PR0402MB3824.eurprd04.prod.outlook.com (2603:10a6:803:22::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 15:46:35 +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; Tue, 16 Nov 2021 15:46:35 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 4/5] ASoC: SOF: imx8m: Implement DSP start Date: Tue, 16 Nov 2021 17:46:12 +0200 Message-Id: <20211116154613.57122-5-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211116154613.57122-1-daniel.baluta@oss.nxp.com> References: <20211116154613.57122-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR06CA0076.eurprd06.prod.outlook.com (2603:10a6:208:fa::17) 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:1e69:ee6:2dad:c9e7) by AM0PR06CA0076.eurprd06.prod.outlook.com (2603:10a6:208:fa::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Tue, 16 Nov 2021 15:46:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ccbcd72b-4c9c-4e9d-4c7f-08d9a9184539 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3824: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:983; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5nNvc5LdI7dOy5iSvlEYd916+2NlNfK4bukcHow9AgHnZPQ+aQPpepzVtWFKi8NRO1jnNWUgiL9az0zQ6ZUc7wlt8hs3v9+Z197KysxzLfgedOSnJyN248fJV8Xcb8FPhIpxbgAoFQhe7KUxs9Sq9+bZ0yTjYd38L+yes7hjWqoqmVZ/cDTpiot48nxJr0tm1SRKAM43gX9cYZuou3b0xIph8X/nbtLxbUdZ0oEjNoqHCI0F2iqNuxSVDzlHSvZZ5FC+1RnmoPmt4NgNicWfuyehyBPW4jW898YrdyaQmGPoN8iG+RzZ3gVWYs6PGRKhh2ZMm9rOTIGhPKj6ou0Xv1dIozDjOQcfNUuotYyfayaV7MIq6Y+UShgJFVAM0zf/vSBD7vjx5JkX72b3UO3m++qLMhEpaqybrm+VQWEhuWQ0IHlFIQ1XQASF8UKHDWDKZT2hV8XN/gG8kKisbJ+flpY9NX2OHJ+q/tQHl18aQ5S8cJMqJGRlvKEufGXzBWvJHVys1A38q3bpl2KVLsRfPBOyiEg85C3IxVoP/ll4qtKKnuasemDQiMLraLE2/I59MFmd1aHA/xsqpA3B9OeoVxO5GfEoZ7fHdCruqdbwBgSzMFNHCB4l7gAOERzB7ApIUHtH9LFZdqVJnd6t3VgDV2GnWLicxLBfoUjTZkNPU0iYknqqCfSSZ0dumxRgdMMI 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)(6486002)(186003)(5660300002)(1076003)(8936002)(38100700002)(66946007)(66556008)(66476007)(7416002)(86362001)(44832011)(6506007)(316002)(2906002)(83380400001)(6512007)(6666004)(4326008)(508600001)(8676002)(2616005)(52116002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w9NByrk/Ab2AEKgf7nsYcZrG/zWnf4qnlUESq8qldH21EJRvPXNSC5gJxfTU5pYsSK0PF1I0Sandp/MwaleYelgp/dvzaULoOGxZh5H+zIxlL17KMehMm83oYg+eftfaD7epy/pRmSa4l+ld/GuFq9gSsDGKe6EwM2dqi4ZDa99CEk2MVG5GQE4+EMBylPp3+QeeBeLaZStiTImuAOff+12AYyvalQPz8WMsDx2cEmRiXe9kkGDXfFhO5PWgjwRRxR0O6PD4BfQLHgRYj/iS1mxVcl1AWTQqqSSDOutDgqN4z90LvXs8gDYjA1RKA1CHDDRcfPVd+1LRAdbv2+zKf0YPmG7GNaJ4/baTF6i9GCIVxH9XzJmG/Ij82IJ3g5xrs4diOleV+W2aY5FjYfCdvMEdXViLsmvkNGQYsvnzX5CXXN/LvEGraLpx+gG95WHmZcsWbdQlKWxdA32yt55AciRN9s5JbT5R0Z8vkGrcrYiNO4AWQWuyVYrrvRGNNMOfgGZKWfJnQh6Dfuj39rNP1ObEQjJqvWWfgaFj6g5GkuCClLeivy1guPMhzb9Qm2/Ot08fMy9ZeODYUAB9ZXIM0JjZqU3/hBUKqcy0zjliGFP0kkpQSUgT+r8OHG0Qram8AHaDhJfidoa9x82B9E2KramxbQyhL0Z8baUUQrBX/aUemOJqF+YcP3KBRgo+Q83XoJfIbYZQAcIfj8z6OCg/KnicwzVwkbgtCSZlJgSDWoMPeQGb/nzRBBwMXD4dMp7SC5k6ukIJiU4kAsWzFu8kFT89ho3hbtVDMThht1NykRGlqBrJVJJ/8/edImvD9qy/bCI4hea0lrFZJW2DHWqDd2ylZrcHj6RGAE/qsPB4ZjTmHgtEsylOAZy+nVn9OctQe9ehxGTJwRWG+5V1ydQnimjplB2ET73jgXkWEK2T1zAHa6XEvBsTgZLpnqMtIzGscZiYshRyacp0KVa4YXixuFXvkY9cQnKmhh3dLTHVJJe10xgA0VKjjmfv4QR1S3r96ltTQa/q+8VrTMQeg9rMKmfGJSBD0UVGv9x2A29pmguO5KPOxbHEKgvLLz19iB7LGveqp9pMoXqk4kGA8qJiz+r1JBOhdEiP8pdet66pH/pq1I5Y+qs4L/zA8L0Zs9OzXB8MAU1AZTNFCWjacNxi3oo/mrsd8csOdp5y9clYValHrHc5f90+fX1eCCT5xrUjntDeD381XdhBEy65LxZ0kiPi0hJ1tczds6Mrw1iLRA9fPq/uW+92lE0VGNX+RiDJcNlKysOOtEKcIMZuJ0aYljS0lnWh7LNfntS5x7YRt4xAoPUnTo4ZhIwruHO7LtSqJ0c+1lW9GcoFopEK7bNWdXfk1YmhShOQQ4mNIYvuyHC5cY2Ai5bfWDyeVKtPGoCRA7bMDNpvVOhxGP5dEFsOKUflfPxXGe4oayXp5bhascguoHo7qEGg7fLcD4oMEZgqX6ML+mXw+eA5vHy9ZKvxKiw763xG8g5rRfj8WtrWmL54M2xbp0Vc/cosJ/3bSnb3ZSsFB50SyKW0bFIiVKb4sTOceiMA3OgMzh26KQmdalSOzHfxqvp4dyGxeiyf+/ghAc+PSm6HsWPs/CbZ3rT8hBFpel5aXHowQpOTP20lwo4qbhX+vmmhoe1MM+cwnmdPZbUxq96u8EC2IOo05XFloKZ8E5jwwVudhJyoaktlMyk= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ccbcd72b-4c9c-4e9d-4c7f-08d9a9184539 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 15:46:35.6687 (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: tPsrjFmP8IzO/rsvGRxa+d0ITGQSi4aEAYwFMf4DIfnBUY4uULe0V3TMEPr8b8/W1nZhcKd6Cd/F9fPMqG/3Ow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3824 Cc: Daniel Baluta , guennadi.liakhovetski@linux.intel.com, daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, linux-imx@nxp.com, peter.ujfalusi@linux.intel.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: Daniel Baluta On i.MX8M DSP is controlled via a set of registers from Audio MIX. This patches gets a reference (via regmap) to Audio Mix registers and implements DSP start. Signed-off-by: Daniel Baluta Reviewed-by: Pierre-Louis Bossart --- sound/soc/sof/imx/imx8m.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/imx/imx8m.c b/sound/soc/sof/imx/imx8m.c index b050d4cf9cd5..9972ca8e6ec6 100644 --- a/sound/soc/sof/imx/imx8m.c +++ b/sound/soc/sof/imx/imx8m.c @@ -6,10 +6,13 @@ // // Hardware interface for audio DSP on i.MX8M +#include #include +#include #include #include #include +#include #include #include @@ -29,6 +32,14 @@ static struct clk_bulk_data imx8m_dsp_clks[] = { { .id = "core" }, }; +/* DSP audio mix registers */ +#define AudioDSP_REG0 0x100 +#define AudioDSP_REG1 0x104 +#define AudioDSP_REG2 0x108 +#define AudioDSP_REG3 0x10c + +#define AudioDSP_REG2_RUNSTALL BIT(5) + struct imx8m_priv { struct device *dev; struct snd_sof_dev *sdev; @@ -38,6 +49,8 @@ struct imx8m_priv { struct platform_device *ipc_dev; struct imx_clocks *clks; + + struct regmap *regmap; }; static int imx8m_get_mailbox_offset(struct snd_sof_dev *sdev) @@ -96,7 +109,10 @@ static int imx8m_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) */ static int imx8m_run(struct snd_sof_dev *sdev) { - /* TODO: start DSP using Audio MIX bits */ + struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; + + regmap_update_bits(priv->regmap, AudioDSP_REG2, AudioDSP_REG2_RUNSTALL, 0); + return 0; } @@ -187,6 +203,13 @@ static int imx8m_probe(struct snd_sof_dev *sdev) /* set default mailbox offset for FW ready message */ sdev->dsp_box.offset = MBOX_OFFSET; + priv->regmap = syscon_regmap_lookup_by_compatible("fsl,dsp-ctrl"); + if (IS_ERR(priv->regmap)) { + dev_err(sdev->dev, "cannot find dsp-ctrl registers"); + ret = PTR_ERR(priv->regmap); + goto exit_pdev_unregister; + } + /* init clocks info */ priv->clks->dsp_clks = imx8m_dsp_clks; priv->clks->num_dsp_clks = ARRAY_SIZE(imx8m_dsp_clks); From patchwork Tue Nov 16 15:46:13 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: 12622759 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 ADC9DC433F5 for ; Tue, 16 Nov 2021 15:49:32 +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 2D5C461414 for ; Tue, 16 Nov 2021 15:49:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2D5C461414 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 43657167B; Tue, 16 Nov 2021 16:48:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 43657167B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637077770; bh=U+YDMrWv2nPAtY92X8bOgFaHsfN3pxLIqWIJxr6gwik=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DuT5udYtr62MTLNoG7WurElzU+XKSemIWljHm2Mmj7dVfAowEYg3XZUzz8cCWw2h4 ELSZQqRZ/GVXXf9f+fkOv9Vp7gvtOXE1/26EIKo1tCU9KVJiHLXNF1+uHd3DVzPiJr dyAOQkSFOiKRGg7t+O3S5opI3/PeQjHINWcPCu3c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 652A3F804FE; Tue, 16 Nov 2021 16:46:51 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4B16CF80423; Tue, 16 Nov 2021 16:46:47 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60073.outbound.protection.outlook.com [40.107.6.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 8F0CDF80272 for ; Tue, 16 Nov 2021 16:46:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8F0CDF80272 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="PbluOLEZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DY4FDsCojCzDq2yTdzxjW4IgUw/sivQAIQMGnRpVv9fSAWC0v1F/s7NYY0lAkcQ2WSgzoE7xMzeaj8ifWx2gC364QcZOk4kpC8Zwz57uQHIyR9RSAh4bTYMH9aygqPylheMIEAkfSnGIkkO1jes6XWkTdE+RAbcrPyQ1wK9zkAc44iD5Z6ryIJrb+x9f0TnvFhrfYD6WYT/+7SbRO/odhwnL1mlmhLAx8XIpvhvNZ10or0XeAzftHhNl5HwGyv6qO2UFoKnxG7HwVKNcjP6vNB3dzcdBempgYrdf0tebugbdqxQMOH8wQXXglD+v3FogAP3Fdnhis5VD9gbeT0hAlg== 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=Qz9Gz2/8OmZFv6S4YKXp8+Zh0ek8cssRpE6TIWGU6Co=; b=kPXqAjP8mMX+fLi2jHAUN14R8L+i7CpqXwwYfuXvwspTiP9mQYwkzDx63yuqL30tO+FkbFriv/wUfOlvA4JMr6SLETgd1L+PK+cMHpUNwVsQofjIIBGVnenDvH2JY+9jTkNNjOZwjExKfUFa1S9heTc683l0l2D2/GIxoCTeXq0xJZ48KRSqTJhEzvl3rDcwJlkKT9T8QHs5Tejlzm0Gvhb89KNn6bd6IZP6BRCsYwCxZpmgyJpCtIvjP+jw2WziWpIE7KMEDEn58dzajWWE1l5IqzU5NXMTktWagOCkM7hgy9S4m22yX5n6tVEo2qZI65ZihzwqksU4S9jFtkzEyQ== 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=Qz9Gz2/8OmZFv6S4YKXp8+Zh0ek8cssRpE6TIWGU6Co=; b=PbluOLEZE9aYneUHgz2DR5q5wnJHyOgRDvn2ReZjZWFF+mH/6nL81b00v4Y73q1aaK7C8uncPFb0bEbAuImk4JlKcmGFHWqD3fJd1RsOM6PdpkhF896v9yPsBHCz27Lr11q3lLzV+0nryw9ZgYFWBi/VVMH4nGymqNv4QBPg+5s= 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 VI1PR0402MB3824.eurprd04.prod.outlook.com (2603:10a6:803:22::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 15:46:37 +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; Tue, 16 Nov 2021 15:46:37 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 5/5] ASoC: SOF: imx8m: Implement reset callback Date: Tue, 16 Nov 2021 17:46:13 +0200 Message-Id: <20211116154613.57122-6-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211116154613.57122-1-daniel.baluta@oss.nxp.com> References: <20211116154613.57122-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR06CA0076.eurprd06.prod.outlook.com (2603:10a6:208:fa::17) 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:1e69:ee6:2dad:c9e7) by AM0PR06CA0076.eurprd06.prod.outlook.com (2603:10a6:208:fa::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Tue, 16 Nov 2021 15:46:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2abf873a-1ad6-49be-53b3-08d9a9184607 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3824: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UPgOLziK+tt8HfjARL64siGHCKK/cIKlsBI6yfBR3qLHe2UIJF+GU3EmIDE9rJjLTNWCh5nO1Xb789NsWZ/tRFcCUd8QU93BA83VSKBUSosYrKcxIXYsgE9oQQ7VE2QTTToZYrccguJmK04m060l59A7K+KxtbAlMOeTmI5cnaKOnTtqV84ryIKNqq5cc+8ios6BWL3eD1Zt2Ij5jIQmiMb0l8WsgxlLUc0Cy45Mj4CT5k1sHyrXwvcbpvJ8/aIySNVFw2XfptP+Lc+Y83QLI1eMOZe2VbiAFPhynh/xoJlHWE8agwo1mATXC+n3e1Uqwg+A5+3M5V/EnPWXBfMznFlgDvIbJ1J+EosBb96wnaRFOrpim7Hbt0LbvZjX/ljPu1wJ1OadMBfoAggKNz4ajmiDykEQm9cBzqXkxaLaeB5iaN/GZSOGUEt0tgbTHdZ8blwGqeR+UFsYzjflO/o+n2+86tkATyW0hYYVWde68O/LFXzvhsF5Vzz/dFrfhRvUoYtgJUQzjYi3XupnAUKCcFKLPH4lyIDOw6b5P+82rxXECKhFWIaKuvbWMi9gISfBtXyOOxe+7BS9INA74j0MR/hdA0gjTMIJBKumaf5i0DRd1O+Fk8i5DfIj4n1TRVjlAIv+/6pYD1IgXv46UZCumE/ZP/Yr/oE3pXmsPViD8M8kh1K5LZrOOXKp1C160fpdC/Oq/SB/lKkiGFbUnfJj6Q== 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)(6486002)(186003)(5660300002)(1076003)(8936002)(38100700002)(66946007)(66556008)(66476007)(7416002)(86362001)(44832011)(6506007)(316002)(2906002)(83380400001)(6512007)(6666004)(4326008)(508600001)(8676002)(2616005)(52116002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QniOc87ci9WfhnKn4yys0TNohCV+0seJjWkqzq6qDqw0jBkOJOtkwWgAy8sgw/vevb/ANQVOPPUPEQ36D0QNT2V7vKdLujZcsLNrjlCQ2mSZkjH3H6RbuQBLbd+aTrDonua5I4kkjYKaThXoJpXBaTaEWW/UFujGc2G3ESULDQSLdmaflR+MTXRAEVKgoIyL6Zt3DOdCxnsqBXSFPMFJ95/0RRxd58MpphvLNXkpdjZeslefJuurHBkMP0KO/ypPaH3Z5VPF/R1qwtPoisR1Vw1ZsrG1qbcz1Hb9agvc46jQba0+HwBxaWAHmJ5pUp+L4kqD3z4zrKQQnFnUTT0UY9H6wh9fItQIG35FIYuU9/M0vLobcyFl8xFbRfKY/vNP11GnGKSaPIr4XH/mNQOfA31LNpfbVbEH3LRQVL4I/rbhYF1DKHmQr0Dk1gW0QEMB2h8pqGfyo03JeM9mOvoMekgrYhdGEnM4FuqoJ3o7c0koh+FUtLx8RXCfhkrtmkgrB+4l7G+7G2/WI9iX7JEvdirba0sCtiQQRizVMWdTm3Rhq7AVuVBn6uNP+HqZqsKuQSPrHtptoWR0r9LZwyIpGTBOFM1OtPcRQis7EgwPHEyOzv37FgdILg6ULIKQaWgbr6OwlV4pqK5DbUBYXbeMK30UlqvgDKTByXX4PcJdDdqW4evYI5U9jy7MkdXHvyUzxFDb7OgPiP7TepPbyE7Wxca0DwMdWlZ7UKxCg+INJw2pB7TQd8f9Z+jjGL5ZM4rWWPxIgcDrnpShdz9mgI6JA+k/axXtR6QFhwnguqJfRZG786TqnK6slQMcpaiQWKX3E+txKeS3Ipu5GKQxxIBIeR7+h440hCENzCZTiviFWfslFY2GZ64ydeXK0fMrqPW7+nfPqDAsT5mNjkjR0cqkaEl0OKRsHyNEpXoFIC6xKXeUxGyeH3SiureFbgjNUkJt+W3DPDh6kpIUFxhJHD00irfXHKUMy+YfU5tDLQlzC/XDZjrWi0Fz2BaR8xfKZD69gzmwfqyn8yQ+Ay4rUI0QyphW9Rtl8HT4w2oracAdvaXq0OLSi1XMhgRycMGldVxzyvn40jqM8gOy23YeK+FcjfxO07fEsTjAo4rJUOlg0pVNBbGuNsuJ2GZCVihFKfni3+bXgUs/1/eTJ6U/49SQE5NPUJH4TOHmq+KuYMPInhyAew6Y90STVyU0K+R37iRJ2SdY4AH9u/I3TDQBJDFG8U8pDnxN0S7wBeWSoYI+h0xR5VJYde3jK/+I7fgnZJ3OFPW4w80JwDt5LB26lLDAluGtRYp0KiZ+il2I9+Azje8yM4s4RdaxZDDtFRk5FfBd0urHyZZwcVCN5Km4UfOCfnEoxdxSZ9+OM5Q1/w94V1UMeLc3hHWNRwemoKKXZ6PILJtyI22vyMrftRmrwjH+1awG8lCOBao75FP9NO6mtEC1C7OpI56ntGLFqMMt9mUbuxg4P+af4PSBEvDo2HS2PKfUadeWWtFKyaUs6UB9Fz51FroXfacKMzfs5alMMoRC90RtO3nflkggcsBu8C/n9mMS1OiFdmiRhFKej8rNcwH9hOMI9XJl+rlynWcWD/BDdgcn895E9QHTRG4fXPE5QzNPXZlMpaumPr1oohahAQ6Ozpp6RxSosd3lkhWc1oRQfNEmVfE6sV1wc/wGyHZDb+WWF0oQ2wfmA/S9JDqnBlw= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2abf873a-1ad6-49be-53b3-08d9a9184607 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 15:46:37.0279 (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: k6OPgYmO3iR3947da2hOLPgXpAxxx9HVWboTceHWp7Ie3hzNTwZC1eBtyTQdYb+8eSCSaB+sqMUEE3WnfG2hTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3824 Cc: Daniel Baluta , guennadi.liakhovetski@linux.intel.com, daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, linux-imx@nxp.com, peter.ujfalusi@linux.intel.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: Daniel Baluta Resume common flow (System PM / Runtime PM) is like this: sof_resume -> specific device resume -> snd_sof_load_firmware -> snd_sof_dsp_reset (1) -> load_modules() -> snd_sof_run_firmware (2) We need to implement dsp_reset callback (1) that will actually reset the DSP but keep it stalled. In order to implement this we do the following: -> put DSP into reset (assert CoreReset bit from PWRCTL) -> stall the DSP using RunStall bit from AudioDSP_REG2 mix -> take DSP out of reset (de-assert CoreReset bit from PWRCTL) At this moment the DSP is taken out of reset and Stalled! This means that we can load the firmware and then start the DSP (2). Until now we resetted the DSP by turning down the Audiomix PD. This doesn't work for Runtime PM if another IP is keeping Audiomix PD up. By introducing dsp_reset() we no longer rely on turning off the audiomix to reset the DSP. Signed-off-by: Daniel Baluta Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen Reviewed-by: Pierre-Louis Bossart --- sound/soc/sof/imx/imx8m.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/sound/soc/sof/imx/imx8m.c b/sound/soc/sof/imx/imx8m.c index 9972ca8e6ec6..8f24c6db7f5b 100644 --- a/sound/soc/sof/imx/imx8m.c +++ b/sound/soc/sof/imx/imx8m.c @@ -32,6 +32,12 @@ static struct clk_bulk_data imx8m_dsp_clks[] = { { .id = "core" }, }; +/* DAP registers */ +#define IMX8M_DAP_DEBUG 0x28800000 +#define IMX8M_DAP_DEBUG_SIZE (64 * 1024) +#define IMX8M_DAP_PWRCTL (0x4000 + 0x3020) +#define IMX8M_PWRCTL_CORERESET BIT(16) + /* DSP audio mix registers */ #define AudioDSP_REG0 0x100 #define AudioDSP_REG1 0x104 @@ -50,6 +56,7 @@ struct imx8m_priv { struct imx_clocks *clks; + void __iomem *dap; struct regmap *regmap; }; @@ -116,6 +123,30 @@ static int imx8m_run(struct snd_sof_dev *sdev) return 0; } +static int imx8m_reset(struct snd_sof_dev *sdev) +{ + struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; + u32 pwrctl; + + /* put DSP into reset and stall */ + pwrctl = readl(priv->dap + IMX8M_DAP_PWRCTL); + pwrctl |= IMX8M_PWRCTL_CORERESET; + writel(pwrctl, priv->dap + IMX8M_DAP_PWRCTL); + + /* keep reset asserted for 10 cycles */ + usleep_range(1, 2); + + regmap_update_bits(priv->regmap, AudioDSP_REG2, + AudioDSP_REG2_RUNSTALL, AudioDSP_REG2_RUNSTALL); + + /* take the DSP out of reset and keep stalled for FW loading */ + pwrctl = readl(priv->dap + IMX8M_DAP_PWRCTL); + pwrctl &= ~IMX8M_PWRCTL_CORERESET; + writel(pwrctl, priv->dap + IMX8M_DAP_PWRCTL); + + return 0; +} + static int imx8m_probe(struct snd_sof_dev *sdev) { struct platform_device *pdev = @@ -168,6 +199,13 @@ static int imx8m_probe(struct snd_sof_dev *sdev) goto exit_pdev_unregister; } + priv->dap = devm_ioremap(sdev->dev, IMX8M_DAP_DEBUG, IMX8M_DAP_DEBUG_SIZE); + if (!priv->dap) { + dev_err(sdev->dev, "error: failed to map DAP debug memory area"); + ret = -ENODEV; + goto exit_pdev_unregister; + } + sdev->bar[SOF_FW_BLK_TYPE_IRAM] = devm_ioremap(sdev->dev, base, size); if (!sdev->bar[SOF_FW_BLK_TYPE_IRAM]) { dev_err(sdev->dev, "failed to ioremap base 0x%x size 0x%x\n", @@ -378,6 +416,7 @@ struct snd_sof_dsp_ops sof_imx8m_ops = { .remove = imx8m_remove, /* DSP core boot */ .run = imx8m_run, + .reset = imx8m_reset, /* Block IO */ .block_read = sof_block_read,