Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp485626ybl; Thu, 15 Aug 2019 22:23:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpdzKOsYCEys8R4Qv6cagoettRj4sa4/7Q9Vafp0ljT6p/mzOoMu+u6FHICzn1ruPeRVBJ X-Received: by 2002:a62:f208:: with SMTP id m8mr8798695pfh.108.1565933025817; Thu, 15 Aug 2019 22:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565933025; cv=none; d=google.com; s=arc-20160816; b=kDnPtLwQ6kXIEijCYZIrj1/bqjXvMx10eOXQxJKPUeIvaBeB7hrjzRRyz1cmlN9wsO 0Wu1rrmv1JpTeZUF6t75ChUI/VLetFHBfCt5h0cEhHiHbsCFoRvh8p+szLdapTWghygi QB5Tjl0Ex//cQ/Ai8Hht6HyLqDodZcuJ9jKqwuaZqqHBiGju8KuX8t/HS8VaDsJFz34C AKxTuDuNQdddwtaHjkSfqG3XcQaoCErBdu+WEMrRBDs/7KDMyq/83A7ul0vr2UdJIA+0 bytJ8MhLcNObXmyYQsIkJpSNydyCS3msQyh2oLFT8v4iWGMlw6rlOspbaaMrrg6d6hiV BqnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=KfStUkWED7XtpEC6M+0tIAzxO6Yql0vAa/JrJ1IT8fY=; b=mHoKdshxnXpwB4rd1PQqdp1nuC3aUxWIeRp455pXwg1mmWMh+tcARhDSTo+s82EI6q wXZPO+UlTSfU9zISnstkc90TGO4ZouldGzJkx2u38MaPn5IaiGJJMmIEShxdxwbNazC9 am9Jko1w/DvYY4X979c4vp5Vf7AZY47gdJgbuqJJ3NUeXb36h+tjV9Pd2QLWiCdJ69Qg ltIp1jIQK7ZkDYRAflXqEHwsiSI50evu3G6u6s0CpARYlVEfoQViINUArxe7ZUjQROYr HytJzKo2N5d1M/7c3MZ1CI88zphN8/yilGiGmBs3OHsQpWQGMgsTUSpt/L8lumjDlc5d Zydg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u38si3197877pgn.79.2019.08.15.22.23.29; Thu, 15 Aug 2019 22:23:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726682AbfHPFV5 (ORCPT + 99 others); Fri, 16 Aug 2019 01:21:57 -0400 Received: from inva021.nxp.com ([92.121.34.21]:48926 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726591AbfHPFV5 (ORCPT ); Fri, 16 Aug 2019 01:21:57 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 0D4C9200078; Fri, 16 Aug 2019 07:21:55 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E9C6C2000A6; Fri, 16 Aug 2019 07:21:47 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 1D839402EC; Fri, 16 Aug 2019 13:21:39 +0800 (SGT) From: Shengjiu Wang To: timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, broonie@kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, alsa-devel@alsa-project.org Cc: linux-imx@nxp.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] ASoC: imx-audmux: Add driver suspend and resume to support MEGA Fast Date: Fri, 16 Aug 2019 01:03:14 -0400 Message-Id: <1565931794-7218-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For i.MX6 SoloX, there is a mode of the SoC to shutdown all power source of modules during system suspend and resume procedure. Thus, AUDMUX needs to save all the values of registers before the system suspend and restore them after the system resume. Signed-off-by: Shengjiu Wang --- sound/soc/fsl/imx-audmux.c | 54 +++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c index 7595f24a006e..3ce85a43e08f 100644 --- a/sound/soc/fsl/imx-audmux.c +++ b/sound/soc/fsl/imx-audmux.c @@ -23,6 +23,8 @@ static struct clk *audmux_clk; static void __iomem *audmux_base; +static u32 *regcache; +static u32 reg_max; #define IMX_AUDMUX_V2_PTCR(x) ((x) * 8) #define IMX_AUDMUX_V2_PDCR(x) ((x) * 8 + 4) @@ -315,8 +317,23 @@ static int imx_audmux_probe(struct platform_device *pdev) if (of_id) pdev->id_entry = of_id->data; audmux_type = pdev->id_entry->driver_data; - if (audmux_type == IMX31_AUDMUX) + + switch (audmux_type) { + case IMX31_AUDMUX: audmux_debugfs_init(); + reg_max = 14; + break; + case IMX21_AUDMUX: + reg_max = 6; + break; + default: + dev_err(&pdev->dev, "unsupported version!\n"); + return -EINVAL; + } + + regcache = devm_kzalloc(&pdev->dev, sizeof(u32) * reg_max, GFP_KERNEL); + if (!regcache) + return -ENOMEM; if (of_id) imx_audmux_parse_dt_defaults(pdev, pdev->dev.of_node); @@ -332,12 +349,47 @@ static int imx_audmux_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int imx_audmux_suspend(struct device *dev) +{ + int i; + + clk_prepare_enable(audmux_clk); + + for (i = 0; i < reg_max; i++) + regcache[i] = readl(audmux_base + i * 4); + + clk_disable_unprepare(audmux_clk); + + return 0; +} + +static int imx_audmux_resume(struct device *dev) +{ + int i; + + clk_prepare_enable(audmux_clk); + + for (i = 0; i < reg_max; i++) + writel(regcache[i], audmux_base + i * 4); + + clk_disable_unprepare(audmux_clk); + + return 0; +} +#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops imx_audmux_pm = { + SET_SYSTEM_SLEEP_PM_OPS(imx_audmux_suspend, imx_audmux_resume) +}; + static struct platform_driver imx_audmux_driver = { .probe = imx_audmux_probe, .remove = imx_audmux_remove, .id_table = imx_audmux_ids, .driver = { .name = DRIVER_NAME, + .pm = &imx_audmux_pm, .of_match_table = imx_audmux_dt_ids, } }; -- 2.21.0