From patchwork Mon Oct 9 08:50:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 115191 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2310654qgn; Mon, 9 Oct 2017 01:52:02 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDZlflhbFlrpZlJdpJq/qidNn6bd3Z5yqtDbytvAD15zcj4v4W1021OaiTyI//EhsOGxyVj X-Received: by 10.223.150.76 with SMTP id c12mr3052864wra.10.1507539122614; Mon, 09 Oct 2017 01:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507539122; cv=none; d=google.com; s=arc-20160816; b=cD7KeM1uEQuaH4YTWDe+aQN/lqr/huLVZE8hZru1H+iplNIU3WdKxmOgINR1QZM0qh 1FMPzep2KtgJbVjN31fGM+UWkf90V77tWahDqXP2qTMpYCCg10QpkodM8hK0gWeJH2n9 h+PqF+sdnoZCQazTui0tiMWI2JDgw8QKOu8zfsqGHFNjqR+thbQlzcBq5+8RvKI1h4Ee iq0JlT+eY7B7sKgnTmDayXPTHDhun164ChnulI8ZugvVgvhRD4+Qvk2aZnneUQ84jluZ bhme64B/YcClzA6pUtrpgXl69L9zk7uoKdrGnUdsto2v3fd0U1fFoldlWkC+FuUr//3/ J/hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=0Tf2KuCfy3gfKOC0UkyWdybqGqMbs2JFxIiHmhhIhhs=; b=N/mRMxtRCeql5+3ZqHsBho+mop8krNBFT3pVELxyNCP/KNSl4Lo8pHl4PXp0xqz67S sxBg47TWPSVJCYAQNKTuQZRz8YCwbobPpcgDo5CiLGjDdxBMx5IEpFOW+RVf6gO+62+t oabk5d2+x4gQ8k1ANQzW1ikb2XSzE4U4bwovNRwkp3zQS8dgZFYaHPVL9dPHaglDWQsc V5cH5XJxHu4vLsi32rZ0y3ZiiVHIRyxCvM6FTUl4SgITOZBOEGUVYY7ATbb3cxiPVpKG avcHk0Fm3WKE2PCEfnG2TIeHsX0S5Wn2L3WLCKjiKJLSDPLgmgo69qYdE2xaCe0hzg7z XC8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=GdK1Sg4h; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id y74si6405141wme.191.2017.10.09.01.52.02; Mon, 09 Oct 2017 01:52:02 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=GdK1Sg4h; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B074C26720C; Mon, 9 Oct 2017 10:50:23 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 96E6E2671FB; Mon, 9 Oct 2017 10:50:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, SPF_NEUTRAL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id 41B032671A9 for ; Mon, 9 Oct 2017 10:50:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=kzTEzmviPP7CQqXdKDXKAGSiLJBJ89ILleHgkL1dzL8=; b=GdK1Sg4hqLQY qUAsDyB0OJuoUBKPPRuEvip8zRg+gjKelUODx2BN0SHGI1DPwLIpK3OhcoElLkto+2FQGEM7gh2oT Lhcucpsa917E9Oh9Q+nSWS8oiVt8HYOCvchn1nOfzElmew7VGypxomYQ7Zf6MJFX/bWZh+h4wwHVt BqVgs=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1e1TlE-0000e5-Jg; Mon, 09 Oct 2017 08:50:04 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1e1TlE-0006R0-6P; Mon, 09 Oct 2017 09:50:04 +0100 From: Mark Brown To: Ed Blake In-Reply-To: <20171006145040.13436-2-ed.blake@sondrel.com> Message-Id: Date: Mon, 09 Oct 2017 09:50:04 +0100 Cc: alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com Subject: [alsa-devel] Applied "ASoC: img-i2s-in: Add suspend / resume handling" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: img-i2s-in: Add suspend / resume handling has been applied to the asoc tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 8ab7f885da23719aef1ba03f563589e44ca6ab66 Mon Sep 17 00:00:00 2001 From: Ed Blake Date: Fri, 6 Oct 2017 15:50:39 +0100 Subject: [PATCH] ASoC: img-i2s-in: Add suspend / resume handling Implement suspend and resume callbacks to save and restore register state, to support platforms where the power is disabled during suspend. In future the driver could be converted to use regmap which would simplify the suspend and resume code. Signed-off-by: Ed Blake Signed-off-by: Mark Brown --- sound/soc/img/img-i2s-in.c | 54 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) -- 2.14.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/img/img-i2s-in.c b/sound/soc/img/img-i2s-in.c index 567f9767fb73..3d151ddda937 100644 --- a/sound/soc/img/img-i2s-in.c +++ b/sound/soc/img/img-i2s-in.c @@ -60,6 +60,8 @@ struct img_i2s_in { void __iomem *channel_base; unsigned int active_channels; struct snd_soc_dai_driver dai_driver; + u32 suspend_ctl; + u32 *suspend_ch_ctl; }; static inline void img_i2s_in_writel(struct img_i2s_in *i2s, u32 val, u32 reg) @@ -469,6 +471,13 @@ static int img_i2s_in_probe(struct platform_device *pdev) IMG_I2S_IN_CH_CTL_JUST_MASK | IMG_I2S_IN_CH_CTL_FW_MASK, IMG_I2S_IN_CH_CTL); + i2s->suspend_ch_ctl = devm_kzalloc(dev, + sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL); + if (!i2s->suspend_ch_ctl) { + ret = -ENOMEM; + goto err_clk_disable; + } + ret = devm_snd_soc_register_component(dev, &img_i2s_in_component, &i2s->dai_driver, 1); if (ret) @@ -495,16 +504,59 @@ static int img_i2s_in_dev_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int img_i2s_in_suspend(struct device *dev) +{ + struct img_i2s_in *i2s = dev_get_drvdata(dev); + int i; + u32 reg; + + for (i = 0; i < i2s->max_i2s_chan; i++) { + reg = img_i2s_in_ch_readl(i2s, i, IMG_I2S_IN_CH_CTL); + i2s->suspend_ch_ctl[i] = reg; + } + + i2s->suspend_ctl = img_i2s_in_readl(i2s, IMG_I2S_IN_CTL); + + clk_disable_unprepare(i2s->clk_sys); + + return 0; +} + +static int img_i2s_in_resume(struct device *dev) +{ + struct img_i2s_in *i2s = dev_get_drvdata(dev); + int i; + u32 reg; + + clk_prepare_enable(i2s->clk_sys); + + for (i = 0; i < i2s->max_i2s_chan; i++) { + reg = i2s->suspend_ch_ctl[i]; + img_i2s_in_ch_writel(i2s, i, reg, IMG_I2S_IN_CH_CTL); + } + + img_i2s_in_writel(i2s, i2s->suspend_ctl, IMG_I2S_IN_CTL); + + return 0; +} +#endif + static const struct of_device_id img_i2s_in_of_match[] = { { .compatible = "img,i2s-in" }, {} }; MODULE_DEVICE_TABLE(of, img_i2s_in_of_match); +static const struct dev_pm_ops img_i2s_in_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(img_i2s_in_suspend, img_i2s_in_resume) +}; + static struct platform_driver img_i2s_in_driver = { .driver = { .name = "img-i2s-in", - .of_match_table = img_i2s_in_of_match + .of_match_table = img_i2s_in_of_match, + .pm = &img_i2s_in_pm_ops }, .probe = img_i2s_in_probe, .remove = img_i2s_in_dev_remove