Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11445096ybi; Thu, 25 Jul 2019 16:44:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEnbK+k5+Aq+a+tuTNDAsmhHFKBMW/x0XvQu7QOdv6Basw0BEhjAjtIQJm2qUjS2KcPk5j X-Received: by 2002:a65:64c6:: with SMTP id t6mr90196227pgv.323.1564098248914; Thu, 25 Jul 2019 16:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564098248; cv=none; d=google.com; s=arc-20160816; b=adPyfhGNPcigLJiKA5AoQgG1wwXuPYdDvM4pjhEDHqDaVyo5dbRvh2OQotXp0ctlXG SwCSCgoTxi4TmzAKnMXauiMnasNX1mhM+3bw9FQ0giBDX2FBvApyIqeWcBLXr09f35BJ KmkNn0hoVOcV/UpWIy2mW5R3bhdrZq6f/ViOr6foZnAAn4a8DF85fuozbBtpQTb7OnFt ak1+LKYkf0ekkCzD/+PDRW2pT9fbkJqt82Bm/qVJPcVovnLTVqWkjxEWbo0CQ/Vled5c moYheC++U3cp7XLNEF1LtMySueIDjryTLepeYphZtXoIJHGVb6W6kxtALUISfs7K/9s4 Bx8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yFi1xTFO/oAGhmO4IEqmNijXypjflhaKN8fYX1jWUc4=; b=oURwKeCvMW6+XyxwL7lsStuUt/afRp0Ln/xSpfmRDQRci4JLzUCMQ0mcdOK3ujP0vi 9iY7COvWtQPq2+eMUL1y+dxTHuiU0S/hJK9mxJP7sz0TfZPk6ljquYMz6AIQKkkktpKh ZzNRP4qoo8YK3MifAm2fUnXbaSpdhmsmrwyXDwWSUF3HTvaZD6tXLUpFt0HU3Qwwrw0O J/7b+uP8vfm4T2xvBdYC+WGJqUn37pa6hO4n6KDAJ87Hq56nJTV2G8pBS+uwnfUcTZp+ CwfxzNzKuGOm20tZgt2fc4uoSzpvdHXOCQkxF/q34WL73dqKFikSxxgQ/fA79DNeYZGN KMAw== 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 l186si18698303pge.215.2019.07.25.16.43.54; Thu, 25 Jul 2019 16:44:08 -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 S1727500AbfGYXlp (ORCPT + 99 others); Thu, 25 Jul 2019 19:41:45 -0400 Received: from mga06.intel.com ([134.134.136.31]:51808 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbfGYXlk (ORCPT ); Thu, 25 Jul 2019 19:41:40 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2019 16:41:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,308,1559545200"; d="scan'208";a="369874792" Received: from amrutaku-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.255.230.75]) by fmsmga006.fm.intel.com with ESMTP; 25 Jul 2019 16:41:38 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: 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 , Pierre-Louis Bossart , Sanyog Kale Subject: [RFC PATCH 26/40] soundwire: cadence_master: fix divider setting in clock register Date: Thu, 25 Jul 2019 18:40:18 -0500 Message-Id: <20190725234032.21152-27-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); - 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); - 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