Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp289220ybt; Tue, 23 Jun 2020 22:31:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+B7T6y7hN1ZFEuEKnd5NEg2lF6bfsDE8NkfMelRm4WjRbpnghPslEO2IC1fqa3V4ZYK+J X-Received: by 2002:aa7:cd41:: with SMTP id v1mr24919389edw.378.1592976666385; Tue, 23 Jun 2020 22:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592976666; cv=none; d=google.com; s=arc-20160816; b=VDHq3lJ6lWf0fJhLY06YMNNj9fjDuAfPVU/Mmi96JjtoK74MnJL+JyDfu9qKC9MrT/ OI0zZv302HGihUv5mZWnuuXDSIw5uNKfJ8jkWEk5/LZBmaQagn9H9IM7imqsAwGxSokt cXHvQGI9955Ez4p8EPGsdx8mYffIkE3cXAc6omBu6mxDSDNqXJbznvCiX/SSQClrMFJv ixJSw6arhcxCAthdcizWI62EVhBQHCPiOOgoY506//KxtZMl+EasEReNqIiGH4vzPo4+ HVg6Cco+EusuK69o00qf+oSjea4ieuxPuitV0G+8fM78twch2Xl6vhgsSjdTzuJLPWDU tvRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=gmgQJxlzt4vE6wMI9miL45wRHnWdQu4jXBmPlGcuHvs=; b=fneC7cgjtKLmDc1wh9Z97wwWze7zv2JnnIEZNnWC6qZM7CQ7tPy59ib8FISpYWf9uO M0kLg9g0HS9UG2ncPMLVxQ4UDPhFd+7K29pIedxKTqPdejNxQnQTsSHO65QDOlZtljgp vbtn+NuG2SCjWPBB7ZQof+TWln2tHMACo/X6QvB4mX1BULznS96/36wn+UNofPvPRT3u s4J8VoMxqHTqGCZCYdZTk5PiYGyP1dSBhtFQye1x1jWV214uUU3EvXKEYY3XSEcO/5fT zSKUZJ8ykyOJgfil4F0ecVeHWS94pNeIv+AljkP5XO6cWLxEPwhbdrD6ySazG7rJ3BeN tumw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce15si12905583ejb.631.2020.06.23.22.30.43; Tue, 23 Jun 2020 22:31:06 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388956AbgFXFaR (ORCPT + 99 others); Wed, 24 Jun 2020 01:30:17 -0400 Received: from mga12.intel.com ([192.55.52.136]:18252 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727957AbgFXFaR (ORCPT ); Wed, 24 Jun 2020 01:30:17 -0400 IronPort-SDR: 5RtdPxly54Xl6GE4+O4SrSOEUlHXJUyEl3WENYwutAcWACoJawWeobYICA78YK6+jwx4ZYoa/d IO8E9kMf/HMA== X-IronPort-AV: E=McAfee;i="6000,8403,9661"; a="124007089" X-IronPort-AV: E=Sophos;i="5.75,274,1589266800"; d="scan'208";a="124007089" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2020 22:30:16 -0700 IronPort-SDR: O44QHjD7Jj0ESHuJiFKj1pAFKeLXQVMNtQZpIIw4xWGLEqJW96BGJ4WzFalrV2Neg4mGCWefyS Vg97XyNOpRVw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,274,1589266800"; d="scan'208";a="452513423" Received: from bard-ubuntu.sh.intel.com ([10.239.13.33]) by orsmga005.jf.intel.com with ESMTP; 23 Jun 2020 22:30:10 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, rander.wang@linux.intel.com, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, slawomir.blauciak@intel.com, mengdong.lin@intel.com, bard.liao@intel.com Subject: [PATCH 4/9] soundwire: intel: introduce helper for link synchronization Date: Wed, 24 Jun 2020 01:35:41 +0800 Message-Id: <20200623173546.21870-5-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200623173546.21870-1-yung-chuan.liao@linux.intel.com> References: <20200623173546.21870-1-yung-chuan.liao@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart After arming the synchronization, the SYNCGO field controls the hardware-based synchronization between links. Move the programming and wait for clear of SYNCGO to dedicated helper. Signed-off-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- drivers/soundwire/intel.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c index 6a745602c9cc..0a4fc7f65743 100644 --- a/drivers/soundwire/intel.c +++ b/drivers/soundwire/intel.c @@ -512,6 +512,31 @@ static void intel_shim_sync_arm(struct sdw_intel *sdw) mutex_unlock(sdw->link_res->shim_lock); } +static int intel_shim_sync_go_unlocked(struct sdw_intel *sdw) +{ + void __iomem *shim = sdw->link_res->shim; + u32 sync_reg; + int ret; + + /* Read SYNC register */ + sync_reg = intel_readl(shim, SDW_SHIM_SYNC); + + /* + * Set SyncGO bit to synchronously trigger a bank switch for + * all the masters. A write to SYNCGO bit clears CMDSYNC bit for all + * the Masters. + */ + sync_reg |= SDW_SHIM_SYNC_SYNCGO; + + ret = intel_clear_bit(shim, SDW_SHIM_SYNC, sync_reg, + SDW_SHIM_SYNC_SYNCGO); + + if (ret < 0) + dev_err(sdw->cdns.dev, "SyncGO clear failed: %d\n", ret); + + return ret; +} + /* * PDI routines */ @@ -763,15 +788,8 @@ static int intel_post_bank_switch(struct sdw_bus *bus) ret = 0; goto unlock; } - /* - * Set SyncGO bit to synchronously trigger a bank switch for - * all the masters. A write to SYNCGO bit clears CMDSYNC bit for all - * the Masters. - */ - sync_reg |= SDW_SHIM_SYNC_SYNCGO; - ret = intel_clear_bit(shim, SDW_SHIM_SYNC, sync_reg, - SDW_SHIM_SYNC_SYNCGO); + ret = intel_shim_sync_go_unlocked(sdw); unlock: mutex_unlock(sdw->link_res->shim_lock); -- 2.17.1