Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1177784ybs; Mon, 25 May 2020 09:01:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmX2B+riIXZoD4Mw/mweV4lRROWySGAz8bEXAHwLzmjA65+UIAyktiuk2KOMm8H89fj4uO X-Received: by 2002:a17:906:6843:: with SMTP id a3mr18531745ejs.245.1590422472907; Mon, 25 May 2020 09:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590422472; cv=none; d=google.com; s=arc-20160816; b=dh06FRuFsxkujlb3zIqL4lzt8dek6/FVgr93uxln45zxQMS1vPbkaib4qOBEW+hyH7 esNNd+3TT/1aKXNQalybtP1I3FelinvhunBZDP6NrAkDDYlLFtEq6LrQj439YAAJs8HO 2guEtN7L/cDWNi69D712QfVh9XaJn7kCKuHn/PvjynfKtXDCk/O5YM9hmYHQz8vGu4Pw JXr6qgXdqgc7R5H/ceDcqyh1ZTPjm/FhnhwDrYlHNP9U7UXas3nkdn4sPX4AauiPK4W4 fOLwo7bNsdwcvL5YKNTffnD2WrF9Vo7mUBRHjvNE93qz4ckcdj//sE8Q5TZX3Cl6f7OV Dvtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zE6QF3wBuG+bbFky4XNH1ls+bDYS3myqBI0CKs9XLgY=; b=uZ92MFMO90hffho6GW2YrJJpogOievOmMtJoVztQAdC+c/1hwxC39JCa5G14EwV/ca 1DkCjx4oF/RvKiiFhur0qNDsfjSb9VxKsHS6MjMkXNKWXW6TTq+6aO28WmL9VcllmOi7 5WWzn6LACwhMLmI/t3SrNcmT9qjNndMxDvyNuK/GPzVfc3jvLy9XgdyMm6FDxN51hMvu EuMhhSnbhO8Ui5YtC4L4jV6ctzDMHg/Jtj+jdmcjRGaxxqtWZs3G3Fjt1TWSp3ddkOzD mSHd7+c+Adu1DfjhxidnWGiY4SBXuee7LGgg/LfbFPjVFvIKhiATlkhU1eaR+WREOtVK 2Dww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gmZ8Vunc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x25si9860471edi.132.2020.05.25.09.00.47; Mon, 25 May 2020 09:01:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gmZ8Vunc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729963AbgEYGLr (ORCPT + 99 others); Mon, 25 May 2020 02:11:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729338AbgEYGLq (ORCPT ); Mon, 25 May 2020 02:11:46 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBF20C061A0E for ; Sun, 24 May 2020 23:11:46 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id c185so2554443qke.7 for ; Sun, 24 May 2020 23:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zE6QF3wBuG+bbFky4XNH1ls+bDYS3myqBI0CKs9XLgY=; b=gmZ8VuncLIfL+xQ1uVR/HNEXvNFmcIL7W5Uce9o/Ajf7J1PDFBxeCDlCWbnUpHE6ew puJM4g0cpV7xMRSGDzwlLFFr5698CMId+R2S2OAHxbid2eP9t36+yRSdrVhVV8snbrxd 6rsVpBMPe71+h9AvFol2x+TtVwUSlkSzXspe5p+Z/Hu45Wbl0bLDcp/UnIKo3WJC6lkj 9ku4sr5N4poBK1P76/+PeROWEIRrwOAZCh59hVy/dGSJKfucj/zaU28pOZIwYfDI9w4P oxQB6iRYVc+ONa7iQkF5QlPsVXJ4N14h1uyhvh4HkDuA5La1uzSRNtP7DQZM9lno5YQs YYuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zE6QF3wBuG+bbFky4XNH1ls+bDYS3myqBI0CKs9XLgY=; b=Tv5ad5/VkgENlQWl7IsSNDZmgwc2q5CMXA6SDCpjYUXYAySOhdK5KilaHmEa8T/qWi P6SiJD/68XItOfaePGHPL0KLHakA2uiku2ta04elYCqHPbUhjVH1Z0YJgi1Uw/Ye9bjp uqMOQCr1bBYBIsbglmte0FAy9Rhbaz8XwoaJ9EpugkDE2ivUBN/SU85jLtUYwKkMIh5K Q13fAhXUqgsgZnZw6u8tJZfeOkCezcF83YV6RsV11BRlKnScBH8sMndX5DvXI7zCt1Aa GPB1DCzqw+ODw/aKLk3/ttTp1BAMYzWC1dqmPXEZHrhMSaLzi4ue59LyXoh5OM+YIXRW xl3g== X-Gm-Message-State: AOAM5334Yl/auyMJGZ9jVLSG0sk1IHTm2G+T6c7TvcoHMrQz5S1nfHeA 0KTZB3aOdODz+pacU/7jwB3p0B1QxAwYhqFQp+g= X-Received: by 2002:a37:b50:: with SMTP id 77mr22555339qkl.152.1590387105305; Sun, 24 May 2020 23:11:45 -0700 (PDT) MIME-Version: 1.0 References: <1590141444-28668-1-git-send-email-shengjiu.wang@nxp.com> <20200525050950.GA1244@Asurada> In-Reply-To: <20200525050950.GA1244@Asurada> From: Shengjiu Wang Date: Mon, 25 May 2020 14:11:18 +0800 Message-ID: Subject: Re: [PATCH] ASoC: fsl_asrc: Merge suspend/resume function to runtime_suspend/resume To: Nicolin Chen Cc: Shengjiu Wang , Linux-ALSA , Timur Tabi , Xiubo Li , linuxppc-dev@lists.ozlabs.org, Takashi Iwai , Liam Girdwood , Mark Brown , Fabio Estevam , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 25, 2020 at 1:12 PM Nicolin Chen wrote: > > On Fri, May 22, 2020 at 05:57:24PM +0800, Shengjiu Wang wrote: > > With dedicated power domain for asrc, power can be disabled after > > probe and pm runtime suspend, then the value of all registers need to > > be restored in pm runtime resume. So we can merge suspend/resume function > > to runtime_suspend/resume function and enable regcache only in end of > > probe. > > > > Signed-off-by: Shengjiu Wang > > --- > > sound/soc/fsl/fsl_asrc.c | 70 ++++++++++++++++------------------------ > > 1 file changed, 27 insertions(+), 43 deletions(-) > > > > diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c > > index 432936039de4..3ebbe15ac378 100644 > > --- a/sound/soc/fsl/fsl_asrc.c > > +++ b/sound/soc/fsl/fsl_asrc.c > > @@ -1100,6 +1100,7 @@ static int fsl_asrc_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, asrc); > > pm_runtime_enable(&pdev->dev); > > spin_lock_init(&asrc->lock); > > + regcache_cache_only(asrc->regmap, true); > > > > ret = devm_snd_soc_register_component(&pdev->dev, &fsl_asrc_component, > > &fsl_asrc_dai, 1); > > @@ -1117,6 +1118,7 @@ static int fsl_asrc_runtime_resume(struct device *dev) > > struct fsl_asrc *asrc = dev_get_drvdata(dev); > > struct fsl_asrc_priv *asrc_priv = asrc->private; > > int i, ret; > > + u32 asrctr; > > > > ret = clk_prepare_enable(asrc->mem_clk); > > if (ret) > > @@ -1135,6 +1137,24 @@ static int fsl_asrc_runtime_resume(struct device *dev) > > goto disable_asrck_clk; > > } > > > > + /* Stop all pairs provisionally */ > > + regmap_read(asrc->regmap, REG_ASRCTR, &asrctr); > > + regmap_update_bits(asrc->regmap, REG_ASRCTR, > > + ASRCTR_ASRCEi_ALL_MASK, 0); > > + > > + /* Restore all registers */ > > + regcache_cache_only(asrc->regmap, false); > > + regcache_mark_dirty(asrc->regmap); > > > I see you doing regcache_mark_dirty() in the resume() now, > being different from previously doing in suspend()? > > Thanks > Nic Which is for probe -> runtime_resume case. After probe, the power may be disabled, so move mark_dirtry to runtime_resume, then regcache can re-write all the registers. best regards wang shengjiu > > > > + regcache_sync(asrc->regmap); > > + > > + regmap_update_bits(asrc->regmap, REG_ASRCFG, > > + ASRCFG_NDPRi_ALL_MASK | ASRCFG_POSTMODi_ALL_MASK | > > + ASRCFG_PREMODi_ALL_MASK, asrc_priv->regcache_cfg); > > + > > + /* Restart enabled pairs */ > > + regmap_update_bits(asrc->regmap, REG_ASRCTR, > > + ASRCTR_ASRCEi_ALL_MASK, asrctr); > > + > > return 0; > > > > disable_asrck_clk: > > @@ -1155,6 +1175,11 @@ static int fsl_asrc_runtime_suspend(struct device *dev) > > struct fsl_asrc_priv *asrc_priv = asrc->private; > > int i; > > > > + regmap_read(asrc->regmap, REG_ASRCFG, > > + &asrc_priv->regcache_cfg); > > + > > + regcache_cache_only(asrc->regmap, true); > > + > > for (i = 0; i < ASRC_CLK_MAX_NUM; i++) > > clk_disable_unprepare(asrc_priv->asrck_clk[i]); > > if (!IS_ERR(asrc->spba_clk)) > > @@ -1166,51 +1191,10 @@ static int fsl_asrc_runtime_suspend(struct device *dev) > > } > > #endif /* CONFIG_PM */ > > > > -#ifdef CONFIG_PM_SLEEP > > -static int fsl_asrc_suspend(struct device *dev) > > -{ > > - struct fsl_asrc *asrc = dev_get_drvdata(dev); > > - struct fsl_asrc_priv *asrc_priv = asrc->private; > > - > > - regmap_read(asrc->regmap, REG_ASRCFG, > > - &asrc_priv->regcache_cfg); > > - > > - regcache_cache_only(asrc->regmap, true); > > - regcache_mark_dirty(asrc->regmap); > > - > > - return 0; > > -} > > - > > -static int fsl_asrc_resume(struct device *dev) > > -{ > > - struct fsl_asrc *asrc = dev_get_drvdata(dev); > > - struct fsl_asrc_priv *asrc_priv = asrc->private; > > - u32 asrctr; > > - > > - /* Stop all pairs provisionally */ > > - regmap_read(asrc->regmap, REG_ASRCTR, &asrctr); > > - regmap_update_bits(asrc->regmap, REG_ASRCTR, > > - ASRCTR_ASRCEi_ALL_MASK, 0); > > - > > - /* Restore all registers */ > > - regcache_cache_only(asrc->regmap, false); > > - regcache_sync(asrc->regmap); > > - > > - regmap_update_bits(asrc->regmap, REG_ASRCFG, > > - ASRCFG_NDPRi_ALL_MASK | ASRCFG_POSTMODi_ALL_MASK | > > - ASRCFG_PREMODi_ALL_MASK, asrc_priv->regcache_cfg); > > - > > - /* Restart enabled pairs */ > > - regmap_update_bits(asrc->regmap, REG_ASRCTR, > > - ASRCTR_ASRCEi_ALL_MASK, asrctr); > > - > > - return 0; > > -} > > -#endif /* CONFIG_PM_SLEEP */ > > - > > static const struct dev_pm_ops fsl_asrc_pm = { > > SET_RUNTIME_PM_OPS(fsl_asrc_runtime_suspend, fsl_asrc_runtime_resume, NULL) > > - SET_SYSTEM_SLEEP_PM_OPS(fsl_asrc_suspend, fsl_asrc_resume) > > + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, > > + pm_runtime_force_resume) > > }; > > > > static const struct fsl_asrc_soc_data fsl_asrc_imx35_data = { > > -- > > 2.21.0 > >