Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2597937ybh; Mon, 5 Aug 2019 03:41:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzI+i14ZPWz95NhQ1ac5u5PRJlfA7KBAKX3Ek/7B9oqmndUEjBQS12x3WZoQ7jDkxutNyOD X-Received: by 2002:a62:2f04:: with SMTP id v4mr70535639pfv.14.1565001703478; Mon, 05 Aug 2019 03:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565001703; cv=none; d=google.com; s=arc-20160816; b=GE2cHM6eYCDEZc7y2ocX1tAAQfAOGZOVrKN6dDBAhel0Fux8FCt3IsNnx3+MK+rB/H D9WhTb/QNgoOThTMGloPrNPN5ZrWDrJWy48dy62ry9oXTpyLY2Inhs10lLXGLdlrFJna U73mFmOx+AKloV8HkOpufzlqg7xuZn4bALrjyNeCLjwkT/WzBTJKB2X+h/rbGHdGwcPe p0TIuRDy+nBGJhxDfIEGLREyGIctueX6XAngXcR6XjTU79G5nLnIXBupealbuH8lIzKw RyzCsBgZIjqxLqnokvcPrnihj3sMMh8P76Z3096Xnp9fyKEA8xv4C2E0mPYBarXA9VTx +1iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=2puLzm8zSmVyjjEXt+mHHXc36ftQIwfPIa4/bgGOBd0=; b=E+0j96fnm0jda+ArKcYmzFCTn/VVKg5KuobcVQjjqax35knAdY6ElrtE0GfVduXyVZ 2GqILRvQ72kiKd3nbTRzlD+RsA3/2gNWIgHZArDbA+j3O3xbA6qaxHkKcgWDE1M28Dm9 TLy9jGJO6CocH2fgQe4Bl5wZub2Fb1Wi2UywhctPw6XJkVNraw23dGW0CHLUUYcE1q7c NRtZN4njYEW0eGSZG+LZA3acrJTTNwqsVu+Rgq71vfpvx4o1WRP2Wp70TLp6iWJVAaUZ 4YO+oEso/yPBuEauK8wjxweG1DsTzA3oOWdcj2AE7vGILfq+Dz3IPqvrvj7bVi9wkUoo wuKA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13si39440082plo.33.2019.08.05.03.41.27; Mon, 05 Aug 2019 03:41:43 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728382AbfHEKi7 (ORCPT + 99 others); Mon, 5 Aug 2019 06:38:59 -0400 Received: from mga12.intel.com ([192.55.52.136]:13865 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727158AbfHEKi7 (ORCPT ); Mon, 5 Aug 2019 06:38:59 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Aug 2019 03:38:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,349,1559545200"; d="scan'208";a="181642793" Received: from buildpc-hp-z230.iind.intel.com (HELO buildpc-HP-Z230) ([10.223.89.34]) by FMSMGA003.fm.intel.com with ESMTP; 05 Aug 2019 03:38:55 -0700 Date: Mon, 5 Aug 2019 16:10:47 +0530 From: Sanyog Kale To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, slawomir.blauciak@intel.com, Rander Wang Subject: Re: [RFC PATCH 26/40] soundwire: cadence_master: fix divider setting in clock register Message-ID: <20190805104047.GG22437@buildpc-HP-Z230> References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-27-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190725234032.21152-27-pierre-louis.bossart@linux.intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 25, 2019 at 06:40:18PM -0500, Pierre-Louis Bossart wrote: > From: Rander Wang > > The existing code uses an OR operation which would mix the original > divider setting with the new one, resulting in an invalid > configuration that can make codecs hang. > > Add the mask definition and use cdns_updatel to update divider > > Signed-off-by: Rander Wang > Signed-off-by: Pierre-Louis Bossart > --- > drivers/soundwire/cadence_master.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c > index 10ebcef2e84e..18c6ac026e85 100644 > --- a/drivers/soundwire/cadence_master.c > +++ b/drivers/soundwire/cadence_master.c > @@ -57,6 +57,7 @@ > #define CDNS_MCP_SSP_CTRL1 0x28 > #define CDNS_MCP_CLK_CTRL0 0x30 > #define CDNS_MCP_CLK_CTRL1 0x38 > +#define CDNS_MCP_CLK_MCLKD_MASK GENMASK(7, 0) > > #define CDNS_MCP_STAT 0x40 > > @@ -988,9 +989,11 @@ int sdw_cdns_init(struct sdw_cdns *cdns) > /* Set clock divider */ > divider = (prop->mclk_freq / prop->max_clk_freq) - 1; > val = cdns_readl(cdns, CDNS_MCP_CLK_CTRL0); reg read of CLK_CTRL0 can be removed. > - val |= divider; > - cdns_writel(cdns, CDNS_MCP_CLK_CTRL0, val); > - cdns_writel(cdns, CDNS_MCP_CLK_CTRL1, val); > + > + cdns_updatel(cdns, CDNS_MCP_CLK_CTRL0, > + CDNS_MCP_CLK_MCLKD_MASK, divider); > + cdns_updatel(cdns, CDNS_MCP_CLK_CTRL1, > + CDNS_MCP_CLK_MCLKD_MASK, divider); > > pr_err("plb: mclk %d max_freq %d divider %d register %x\n", > prop->mclk_freq, > @@ -1064,8 +1067,7 @@ int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params) > mcp_clkctrl_off = CDNS_MCP_CLK_CTRL0; > > mcp_clkctrl = cdns_readl(cdns, mcp_clkctrl_off); same as above. > - mcp_clkctrl |= divider; > - cdns_writel(cdns, mcp_clkctrl_off, mcp_clkctrl); > + cdns_updatel(cdns, mcp_clkctrl_off, CDNS_MCP_CLK_MCLKD_MASK, divider); > > pr_err("plb: mclk * 2 %d curr_dr_freq %d divider %d register %x\n", > prop->mclk_freq * SDW_DOUBLE_RATE_FACTOR, > -- > 2.20.1 > --