Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp434511rdb; Thu, 5 Oct 2023 10:01:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGlvz2brMmTo1L/i1HXMfqIi40xMZU4qu2uOZ4tIIvpdHDGoL9yA44kdfO59PPfFiyL3Fz X-Received: by 2002:a17:902:7682:b0:1bd:d15f:bdfa with SMTP id m2-20020a170902768200b001bdd15fbdfamr4714668pll.68.1696525292739; Thu, 05 Oct 2023 10:01:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696525292; cv=pass; d=google.com; s=arc-20160816; b=BlQUv4ckZXk+Ijs4wd1iCcleZsPjDpJfjpZU72tQvTw3wkcUe68FAmDIdqnqNFWK7G 1girHjpSmVR9h4pW1BWFfXmwDd9G1Wy0DRCL2R9w9KIwTxTlsGBQvPTIi2VrzbXodfCp s5b4F6wrtXFzu2YlqHpvC3ITuKekKskQy3lAHiv6EgptusX9YB2md4IW4bveEEQN5MxJ n129bqcvCXyHTDvAxEKXvWzqsArP3qMtvZ2X+p9kj93HHxqmoaoLDUdEbJTYvaAw7Jfo hWgtbzX4OQLXD0gpFo1qOLnmYrfEo3SEkyNP2DODO1T2PHOvMbT36uBwVWxSjxasSh6V Vi6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L815y72ZKLd8Q6n13OC96EtIhZ75mN/FqznbXbkA6rg=; fh=GOyYGW+FL1Fi41D7XUg4GCc9TeYyeHjS9EGuJvLeQ9o=; b=gvTVH7x5t0x3+cEroWg7LMhuzseD/x9/1AV9YvvwxpJiqFhEuyXNPXfeluTwGTcf8y IsUsj7VRQdURXgyWv00B68u6Vrqzz6M0JC6ivu0Ky7Ntm5Sb1cijamAybteQHwHvLWu/ HWAIGzyYrguO1p14RCDxZJFg+xep/Aeq/YIeNxu3g3m59ZgZkCXk1eacGJqEzCuc6pOF HvYbg/wYjYLcNAOGLs/sYBjGoJTEh53XQMF7BOipsLXNgcvM8LhXLelmU9gIzvlMpaos s/amNfIVWTenry1MlNiqaTSaPyqkNT/OT1pSofGW++PNHpB/rCuSOTS3mgtA/3jAvE81 K1Fg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=cuu2YzNB; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id i14-20020a17090332ce00b001c611f28597si2000648plr.539.2023.10.05.10.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:01:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=cuu2YzNB; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 979898080E38; Sun, 24 Sep 2023 19:49:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231792AbjIYCtz (ORCPT + 99 others); Sun, 24 Sep 2023 22:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231737AbjIYCty (ORCPT ); Sun, 24 Sep 2023 22:49:54 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2045.outbound.protection.outlook.com [40.107.105.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAB51A7; Sun, 24 Sep 2023 19:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HJvDcwgggC5mXY7iSwvC6qBmr/ffqkJU+nCE8fgbHRsnFNFhPfk9T6RYMZvdQLM/FKNbaB2kZHkLLylHCEGZp9IvKtXEy7PG+E5+PX51jADKaQDGDmVP3IcroLE4BKqTsmlan2HBwop2cTJHlE/CzPQQ8mCFnbyBNjZkONctRvk+ElghSN1n5dK7rns9ozWT5ICW0QmPSCaTvQf0sZzPww4jaHIBuUVca7dvHGhc9Mip+hY55wApcYlDHrmYS4OfIee1kgK4IQaYEoNJedQjVeBvznT+h/+c154ToKsWJgDjNUYuXyhrZ4iuXwkcsle02BxA5wiG+WQszoAxvdC9xQ== 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=L815y72ZKLd8Q6n13OC96EtIhZ75mN/FqznbXbkA6rg=; b=kXmAJlliFstQxP4YfGvMzDc3av2B0rpYrzYS8xykfJdyj6KOHGm4/9Lu1OcMQ46yTzwZwE+dt9LYBUK5z0MpIzGvS+M9S10w3JA1oSq7fIuCCTlBmWRsNK5YnR7XqVPQryIJhmoSSlDWk4id1LhW4Hs2Th17EPJ4Xd4YdfrY7LGFXZArl2k1ojtjF9iZjrYxrvJEANhSCJZEmw5JnWn2zsmU8LhQwQlbj6SGDm5e6G36wBhqSWzFC6OIP/Tg5Ogla9v/dBzwbsigt0AJ2vyopS9D31PoxRiAsleiX1lL3BZHd64avy6H4E22SIjAWWIqYr5UIZyD0JRld0WI5AoNDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L815y72ZKLd8Q6n13OC96EtIhZ75mN/FqznbXbkA6rg=; b=cuu2YzNB6GW51cMAAlF/rXB3zhwTrqy3It79FOT+SCGMVzITxxqQbTwDhbZhkV6a3zaqpaTC/4l7ZjUiwJuuvLLg4sedyUEtlcaWCDSD2WJ4+MdjcznzfsQzfjflLWbwjk/yHHrqfgEL/6ZowIFqh+v9W1mQOUFzZaBgshAdtKQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) by AS8PR04MB8232.eurprd04.prod.outlook.com (2603:10a6:20b:3b2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Mon, 25 Sep 2023 02:49:43 +0000 Received: from DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::51f9:b8d2:7ddd:c74f]) by DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::51f9:b8d2:7ddd:c74f%6]) with mapi id 15.20.6813.027; Mon, 25 Sep 2023 02:49:43 +0000 From: Chancel Liu To: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, perex@perex.cz, tiwai@suse.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Chancel Liu Subject: [PATCH 2/2] ASoC: imx-rpmsg: Force codec power on in low power audio mode Date: Mon, 25 Sep 2023 10:48:47 +0800 Message-Id: <20230925024847.2971421-2-chancel.liu@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230925024847.2971421-1-chancel.liu@nxp.com> References: <20230925024847.2971421-1-chancel.liu@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SGXP274CA0024.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::36) To DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9498:EE_|AS8PR04MB8232:EE_ X-MS-Office365-Filtering-Correlation-Id: d245b4e4-e2d9-4e9e-ab46-08dbbd72123d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A93I2m3XNfqNq2imK78yIWNa0cKcy0xQ9R022nA1LuS7dlheaY2sVtmb2ZLxMQUAnVN/HP7LnuzOu6DMCrlHavKmj1zexpuUNRyPSXqpz2hODZXtqIK/WBqpExEwpEjrXyHavABtZDrDC/xjo/u4I0GSE45gErrfHFOMl2h9UUq9f/hwkZcQBEh9PPrT1auDk9Vs7R5qL3bj9eofGNytveqjTBQHZIKD001kP4As8Zgp9DEQtIuL5EEYJCto53lM3nGTDjdeeZH7Ow10edmNUb7gD6Me/y6IbJUNWAJt9JHITrniBNPDp7CSoriWDTbjC/jCreEMEH+6nYhHJIgZLno/ejcnkUCRZKjdnREDl1amgMGXSOVxatH4KDaRRADAU19g79eUIcRTzFx3OrAK1+ly02lUcJrxHQYUF6MjKoRvz3ido1HRZYToH2eDkHWpnifuZmL5aauOgLDhjdQ3MaSUYjMadkMFNrZXpz0VfldEuwCstZo9/g2kyb6xsHZvE41XkAdGVUKMq3VoHe7ezc+dY8Fn2vb5xVDfAx8WHrTuZZyYG0itm6ChxIi466JVm5j6ANPBtCJatVyGkZnK8rnzT+IRm+xqnSlmxmc1twFgOV73s0j5AtPlnMsVgk97v1HVpoXBXEmK9Wlwa2LFKuMk8MnvNxS0csrEYslE2x8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9498.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(39860400002)(136003)(366004)(346002)(376002)(230922051799003)(1800799009)(451199024)(186009)(478600001)(6512007)(52116002)(41300700001)(38350700002)(921005)(38100700002)(316002)(2013699003)(26005)(1076003)(2616005)(44832011)(83380400001)(5660300002)(66946007)(66476007)(66556008)(6506007)(6486002)(8676002)(8936002)(4326008)(2906002)(7416002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?oJyj8wOp0l9pHCMb0PuZjDe68pKVBQBjeU7XNjpkPtb4a3pHYQhVW7YBzDgW?= =?us-ascii?Q?oAOQ8jIGeyQ9Fqj8yN5c5OqNDptuRV954V6MwmItDhOMim7Db4EqU/bzQDKG?= =?us-ascii?Q?d4+0EURkHHquUH2Ok0efUEVs4d0Q6eiKPvjBZiAbXfXVnbVT1QMjl0cj03rT?= =?us-ascii?Q?ehJtKE+xjrLKqk4HcXXGCxp/v+0c8UVAY+PGaWEvvBs+IqFvU/s07qHEeqKo?= =?us-ascii?Q?xNcIW3yVwAhI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fradW7ZJd6hRhd1lp+nmh?= =?us-ascii?Q?AHF2mnbwJTILx48DdR6gH+/mdnwPtMjWh09n6GAWxtlYZtQI49CS1vz4vJsr?= =?us-ascii?Q?hhqRJeBeEzdP7mTcnGn0OjWhIB4RdH/tW9LKaBgAz66UInQ2qOml4nRAkJvg?= =?us-ascii?Q?OSChNe1UDd1hXNXi1jtQqWlNLr+TEgJqMIwAiq9GMnkR0KAYOjCSYzp2ldnQ?= =?us-ascii?Q?jWSpGYCOYjMeR1Qidysr/o1Y8HrIu9L7YmkKSg8bh+r/LG5dnuuh2uRQhErl?= =?us-ascii?Q?qH6Ddy+XjI6IDeYo9UN/MC9qVS36YJToyAh0Yba7ggUK6WfSiJfF8vcPS4IV?= =?us-ascii?Q?dfqnLjSn7CgZSV7uLZezWSvvqJX1gnzmE7Pbyx2MHSCk/m5R7f5OwEV8+m1l?= =?us-ascii?Q?vxRxWsWH1Kuw9TIwBn4TNrH41ALIxVI08S/LdA9PGqTYgf25QyBMkgHk2R1U?= =?us-ascii?Q?A6VysJVtrPPqzv26mVfsoiUuQ2zDNdQq+0o70gSb?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d245b4e4-e2d9-4e9e-ab46-08dbbd72123d X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9498.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2023 02:49:43.4517 (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: OMqaidMqB5DSOkwlW5ATRr2J9mYZu4tgZ3Ptxmmm7A9syRxJoCjlijzmwaXHlFh77gGjvyXEZiVQxNH/I7rWWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8232 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 24 Sep 2023 19:49:54 -0700 (PDT) Low power audio mode requires binding codec still power on while Acore enters into suspend so Mcore can continue playback music. ASoC machine driver acquires DAPM endpoints through reading "fsl,lpa-widgets" property from DT and then forces the path between these endpoints ignoring suspend. If the rpmsg sound card is in low power audio mode, the suspend/resume callback of binding codec is overridden to disable the suspend/resume. Signed-off-by: Chancel Liu --- sound/soc/fsl/imx-rpmsg.c | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c index b578f9a32d7f..0568a3420aae 100644 --- a/sound/soc/fsl/imx-rpmsg.c +++ b/sound/soc/fsl/imx-rpmsg.c @@ -20,8 +20,11 @@ struct imx_rpmsg { struct snd_soc_dai_link dai; struct snd_soc_card card; unsigned long sysclk; + bool lpa; }; +static struct dev_pm_ops lpa_pm; + static const struct snd_soc_dapm_widget imx_rpmsg_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_SPK("Ext Spk", NULL), @@ -38,6 +41,58 @@ static int imx_rpmsg_late_probe(struct snd_soc_card *card) struct device *dev = card->dev; int ret; + if (data->lpa) { + struct snd_soc_component *codec_comp; + struct device_node *codec_np; + struct device_driver *codec_drv; + struct device *codec_dev = NULL; + + codec_np = data->dai.codecs->of_node; + if (codec_np) { + struct platform_device *codec_pdev; + struct i2c_client *codec_i2c; + + codec_i2c = of_find_i2c_device_by_node(codec_np); + if (codec_i2c) + codec_dev = &codec_i2c->dev; + if (!codec_dev) { + codec_pdev = of_find_device_by_node(codec_np); + if (codec_pdev) + codec_dev = &codec_pdev->dev; + } + } + if (codec_dev) { + codec_comp = snd_soc_lookup_component_nolocked(codec_dev, NULL); + if (codec_comp) { + int i, num_widgets; + const char *widgets; + struct snd_soc_dapm_context *dapm; + + num_widgets = of_property_count_strings(data->card.dev->of_node, + "fsl,lpa-widgets"); + for (i = 0; i < num_widgets; i++) { + of_property_read_string_index(data->card.dev->of_node, + "fsl,lpa-widgets", + i, &widgets); + dapm = snd_soc_component_get_dapm(codec_comp); + snd_soc_dapm_ignore_suspend(dapm, widgets); + } + } + codec_drv = codec_dev->driver; + if (codec_drv->pm) { + memcpy(&lpa_pm, codec_drv->pm, sizeof(lpa_pm)); + lpa_pm.suspend = NULL; + lpa_pm.resume = NULL; + lpa_pm.freeze = NULL; + lpa_pm.thaw = NULL; + lpa_pm.poweroff = NULL; + lpa_pm.restore = NULL; + codec_drv->pm = &lpa_pm; + } + put_device(codec_dev); + } + } + if (!data->sysclk) return 0; @@ -137,6 +192,9 @@ static int imx_rpmsg_probe(struct platform_device *pdev) goto fail; } + if (of_property_read_bool(np, "fsl,enable-lpa")) + data->lpa = true; + data->card.dev = &pdev->dev; data->card.owner = THIS_MODULE; data->card.dapm_widgets = imx_rpmsg_dapm_widgets; -- 2.25.1