Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11445637ybi; Thu, 25 Jul 2019 16:44:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXcn6yt92PUMHg0E+XxrpyuQU00YsUIyen2WPjq15EWMOHZSk2lsH9C0XN7k7PMwe4J2+y X-Received: by 2002:a63:2744:: with SMTP id n65mr75334767pgn.277.1564098293310; Thu, 25 Jul 2019 16:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564098293; cv=none; d=google.com; s=arc-20160816; b=gPVZn2ZgpO2XdTSeJ29Pcy5PVqUNL8yEABQQqAMuDfo7wyZs3SXLPy5NzyAOC34uLu 4jwp2FfVl80DV0fB6Z/JN/hYfJCzgiFuY6X1yMzI36tu5Yi0DF6oBj6MXmalJQbu6YJ7 PiIRKWy4VZoF1nnFd2O3FRt+3VQR7DK1YD6SHQhCA45svcjumt6Ljp/97LBMA0uqc0qt Glb1n9qXwCIeLS5pSDWGy8NCtzcwr2aO9e6K19Cs/aejcs8z8aLlSkUuRcUg2jgyYUzn gZNEvStQzYbmGmgeAGAGJMxu+uc5GrpyKgO16KQziexmYL4Jgwgo9nGDqFyR+WVXQOIs N+iA== 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=+b+kZFMKRR5UEn4Emy2QelqYmf3eJC7vSQawzxLLop4=; b=g5DTWQK9J5N1jonUbHubNqVbYuOQ9W+ZPn7piLq/+iGcbeNPQVjq3fHN6Yhfxao+iZ FKT6xdV+fRer8Kx75wssvEfzPtZd1aEKsSUeZrX8lzKICMPVOYLQ4kXJYIgid8/EIALD uSFztlcrQECLHL5Qb+TwtIIUzHMUCQ+E1RBscI6QVV7TlbRopbldG0oFfepMKRW/dVwL i0m4QirB33IAVTpKxkBu4zbJBCcu5ldZPQAlgaSEXVyPI5Uq3nLGnHbBxiqtBGkalfBd vtYcasbFYA2GRXzxhSVUhtjR1oWEGMRq5nxf98QMQhqBSzcm3kxlPAWzBCKkGBLvorzr 9xMg== 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 e3si4935318pge.177.2019.07.25.16.44.38; Thu, 25 Jul 2019 16:44:53 -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 S1727823AbfGYXnQ (ORCPT + 99 others); Thu, 25 Jul 2019 19:43:16 -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 S1727320AbfGYXlY (ORCPT ); Thu, 25 Jul 2019 19:41:24 -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:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,308,1559545200"; d="scan'208";a="369874716" 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:22 -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 16/40] soundwire: cadence_master: improve startup sequence with link hw_reset Date: Thu, 25 Jul 2019 18:40:08 -0500 Message-Id: <20190725234032.21152-17-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 Enable interrupts first, then engage hardware bus reset with maximum duration to make sure the Slave(s) correctly detect the reset pattern and to ensure electrical conflicts can be resolved. Without these changes the initialization is randomly corrupted by bus clashes, parity errors and Slave attachment does not generate any interrupt, despite the status showing them being attached. Signed-off-by: Pierre-Louis Bossart --- drivers/soundwire/cadence_master.c | 35 +++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c index 25d5c7267c15..442f78c00f09 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -778,6 +778,31 @@ EXPORT_SYMBOL(sdw_cdns_thread); * init routines */ +static int do_reset(struct sdw_cdns *cdns) +{ + int ret; + + /* program maximum length reset to be safe */ + cdns_updatel(cdns, CDNS_MCP_CONTROL, + CDNS_MCP_CONTROL_RST_DELAY, + CDNS_MCP_CONTROL_RST_DELAY); + + /* use hardware generated reset */ + cdns_updatel(cdns, CDNS_MCP_CONTROL, + CDNS_MCP_CONTROL_HW_RST, + CDNS_MCP_CONTROL_HW_RST); + + /* enable bus operations with clock and data */ + cdns_updatel(cdns, CDNS_MCP_CONFIG, + CDNS_MCP_CONFIG_OP, + CDNS_MCP_CONFIG_OP_NORMAL); + + /* commit changes */ + ret = cdns_update_config(cdns); + + return ret; +} + /** * sdw_cdns_enable_interrupt() - Enable SDW interrupts and update config * @cdns: Cadence instance @@ -809,7 +834,7 @@ int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns) cdns_writel(cdns, CDNS_MCP_INTMASK, mask); - return 0; + return do_reset(cdns); } EXPORT_SYMBOL(sdw_cdns_enable_interrupt); @@ -958,6 +983,10 @@ int sdw_cdns_init(struct sdw_cdns *cdns) cdns_writel(cdns, CDNS_MCP_SSP_CTRL0, CDNS_DEFAULT_SSP_INTERVAL); cdns_writel(cdns, CDNS_MCP_SSP_CTRL1, CDNS_DEFAULT_SSP_INTERVAL); + /* flush command FIFOs */ + cdns_updatel(cdns, CDNS_MCP_CONTROL, CDNS_MCP_CONTROL_CMD_RST, + CDNS_MCP_CONTROL_CMD_RST); + /* Set cmd accept mode */ cdns_updatel(cdns, CDNS_MCP_CONTROL, CDNS_MCP_CONTROL_CMD_ACCEPT, CDNS_MCP_CONTROL_CMD_ACCEPT); @@ -980,10 +1009,6 @@ int sdw_cdns_init(struct sdw_cdns *cdns) /* Set cmd mode for Tx and Rx cmds */ val &= ~CDNS_MCP_CONFIG_CMD; - /* Set operation to normal */ - val &= ~CDNS_MCP_CONFIG_OP; - val |= CDNS_MCP_CONFIG_OP_NORMAL; - cdns_writel(cdns, CDNS_MCP_CONFIG, val); /* commit changes */ -- 2.20.1