Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11444689ybi; Thu, 25 Jul 2019 16:43:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIxonzE7GvNNh9UYRHA52XHPhwyBQ2cB8aOv61RFbBrHkIRrsgkzE/vgbvA7/N/qBvqtXq X-Received: by 2002:a17:902:543:: with SMTP id 61mr93149703plf.20.1564098215759; Thu, 25 Jul 2019 16:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564098215; cv=none; d=google.com; s=arc-20160816; b=U0Y+pI5dfQ4vY7pPRger56YWi2ob9/cnrHCJBZiec9sbiy8ry8++l006rZIX8zDOq/ 9yhghcmwT1xxVzWR53smfbpjTbMpV5pDF5v038plVvHA60KMp5qO7/MUj8BoeR62695j YM4/4tb+WXH42CnsSg9y8irXktJpxRty8ouDmDMZADRqTPZYqrw0UbP4GsA/bkf2g/zy TXI567yL59byhCK64+nZiZxYnEqGMAqrMSGOBfOmfrFUYlxYhPUWClJQXVW+owq/O1uy WCmGAlE81JDLf9PCau3hm0F/CDUAoz6zWM9JQBSrYpM40elTy2rHRmrC6151hslReCX8 OGaw== 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=2HDcXx+MnoYzlkOWhvjO1QUleMehNAhmzCyY2VrN3RU=; b=pCUpiH+Fu8/ZehLpkoqPx5XmFC7hTlMtJZgveGR3dyiab4lSoN2jczCl/35Cc61hXD tjPUG05gb/lr62Xevc8BCWkTaXvyStX481fxS6XJ4KEuKqBZNPzc9IVrrYT76682UBQd nem340or1eAUr2KMEvPnEDY6OO9J5jT2ayDMyjMTyTW+IHjcBuKnQML/z6S15GhDOVQj HjoBZbi6RZKmRFptKuz9UxC5O5nl2xV399LjPdV1bHistKPh+tFllwLaxBB1NDSTGCjM IDXu8y8voHsLw5dibY1dOfGmB/Foc9Lre1w/1neKs9rBL6+9W+Whbo3XEVmTzpRkNdaI YXpQ== 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 g98si18038834pje.92.2019.07.25.16.43.20; Thu, 25 Jul 2019 16:43:35 -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 S1727232AbfGYXlR (ORCPT + 99 others); Thu, 25 Jul 2019 19:41:17 -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 S1727123AbfGYXlO (ORCPT ); Thu, 25 Jul 2019 19:41:14 -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:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,308,1559545200"; d="scan'208";a="369874669" 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:12 -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, Pierre-Louis Bossart , Sanyog Kale Subject: [RFC PATCH 09/40] soundwire: cadence_master: fix usage of CONFIG_UPDATE Date: Thu, 25 Jul 2019 18:40:01 -0500 Message-Id: <20190725234032.21152-10-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 Per the hardware documentation, all changes to MCP_CONFIG, MCP_CONTROL, MCP_CMDCTRL and MCP_PHYCTRL need to be validated with a self-clearing write to MCP_CONFIG_UPDATE. For some reason, the existing code only does this write to CONFIG_UPDATE when enabling interrupts. Add a helper and do the update when the CONFIG is changed. Signed-off-by: Pierre-Louis Bossart --- drivers/soundwire/cadence_master.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c index 9f611a1fff0a..eb46cf651d62 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -224,6 +224,22 @@ static int cdns_clear_bit(struct sdw_cdns *cdns, int offset, u32 value) return -EAGAIN; } +/* + * all changes to the MCP_CONFIG, MCP_CONTROL, MCP_CMDCTRL and MCP_PHYCTRL + * need to be confirmed with a write to MCP_CONFIG_UPDATE + */ +static int cdns_update_config(struct sdw_cdns *cdns) +{ + int ret; + + ret = cdns_clear_bit(cdns, CDNS_MCP_CONFIG_UPDATE, + CDNS_MCP_CONFIG_UPDATE_BIT); + if (ret < 0) + dev_err(cdns->dev, "Config update timedout\n"); + + return ret; +} + /* * debugfs */ @@ -758,15 +774,9 @@ static int _cdns_enable_interrupt(struct sdw_cdns *cdns) */ int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns) { - int ret; - _cdns_enable_interrupt(cdns); - ret = cdns_clear_bit(cdns, CDNS_MCP_CONFIG_UPDATE, - CDNS_MCP_CONFIG_UPDATE_BIT); - if (ret < 0) - dev_err(cdns->dev, "Config update timedout\n"); - return ret; + return 0; } EXPORT_SYMBOL(sdw_cdns_enable_interrupt); @@ -943,7 +953,10 @@ int sdw_cdns_init(struct sdw_cdns *cdns) cdns_writel(cdns, CDNS_MCP_CONFIG, val); - return 0; + /* commit changes */ + ret = cdns_update_config(cdns); + + return ret; } EXPORT_SYMBOL(sdw_cdns_init); -- 2.20.1