Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1693555imu; Sat, 26 Jan 2019 08:33:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN6/owzh76+uNAGxnh5xbfzpfaWHOEPyCiIbcrYGdzDAOtt2ErmW3qM3O9a8TOApdIKC2mPi X-Received: by 2002:a62:5884:: with SMTP id m126mr15382111pfb.177.1548520421917; Sat, 26 Jan 2019 08:33:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548520421; cv=none; d=google.com; s=arc-20160816; b=sZ9U+ewUx/65JE4r2l62tQ1dBMAj+H3EB2pWEsNkMByEFTs246zd/U2LML2NqZpkM9 9GEpYHiiE1yAA/PciTo7M4GQLnHj5rZF+Z+zK20cpYw57hSHlsdB632KXXiti4RFlnsH Tzv66Io5IEdXvHg5JaiXlbqGnxRSuQVc5S1PhtyYdS11PsDIy7aWUIZyioNZDV1C6+h6 oaAnGv45Boz0BaSXrxbEnaq2ucZ4GARoier7IQIJs/tFdmNs0ZEo+NyWcHCRJubmtuum 283mxVhRm3bF2oUCc+PntFfWXxgl2rITwPFjxf9c3x2FkmiOw3q5DX9U5AG6KqF5zLN+ QoZw== 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 :dkim-signature; bh=H4asA/HrfRTCLZ9s+7ODb9ujqrC02barVnHHP3w4OeE=; b=q6Vujl9XQmxlDPlslrCA1soKfGatSctNGjT3WNGTIZmfbcINk0OayUvNDsigB/2NS5 LJ2nQ1K91oGDz4h24t41oa0cyd73Q5QqBMQ9P/luWTU2OQFvO1F2ORv8zyM/0QOmNKLb bPPVA1Lhbd20fXJ4v/lUMMmx8gTJNQkGfMeiHK3OtwLDksPhiXmINvW1wMFEe9pn3zqb BSeOmH8OczIU752J15Pp71eAer++zaIzZt5hsUFmTebL0oG1wQyhf+It3ZVXiwYkEtyz 1Pp8yZ6JmjwTeCEbCDfj3lfD6fvP5BaH5KB18hYACqGeGz4aL1ps8exJdQsWBW7DkzHS sTqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@norrbonn-se.20150623.gappssmtp.com header.s=20150623 header.b=1Dw3YGg8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f38si1564890pgf.206.2019.01.26.08.33.26; Sat, 26 Jan 2019 08:33:41 -0800 (PST) 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; dkim=pass header.i=@norrbonn-se.20150623.gappssmtp.com header.s=20150623 header.b=1Dw3YGg8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726342AbfAZQcf (ORCPT + 99 others); Sat, 26 Jan 2019 11:32:35 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35150 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbfAZQc3 (ORCPT ); Sat, 26 Jan 2019 11:32:29 -0500 Received: by mail-lf1-f66.google.com with SMTP id e26so9033978lfc.2 for ; Sat, 26 Jan 2019 08:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H4asA/HrfRTCLZ9s+7ODb9ujqrC02barVnHHP3w4OeE=; b=1Dw3YGg8xJI9+QrCu/LPqQ7Tr/GpytlL6Sj9JOqPWV3qR7JsVOZvTwcLkBmBXK2uSZ TFcurMiTzkCaWD95yVxh4ISXWz4SAVqgOKY1IaZeYUf/9QFNcV5k7bFGLvIHyADk5vWy +YN52P1zK5m6I6mEfnSzjP8VWEep9DACZXPu6VHTUPEnrcK28uoeDKgzsfU/E8PH800R HaXLsnx/buy6A5AdzNPoivt2pFHTu4B9tUtKGGpSKXpY9ygCjl8VdKWo/P9tOtBlfeyL shX85Yq4wrOuH5UporbikUTEjIY4YqXfIDN1Ar/apyBE8ldFeEmDCvW4015QH3UkobIS lhhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H4asA/HrfRTCLZ9s+7ODb9ujqrC02barVnHHP3w4OeE=; b=gYUr5XSeaB8oRuXDaTkODwycfWJGIrrRXHrpuR6gG1n5uyeadcvlaVMhhrNkanlITU 5iuPalyTCbIELG//SBut6MU1BhxMsC4HYn+MXcy3bbinL96BPtRtcZnbKSpkxIuVh+FK WtkKXxGkHinAOrpr0HuyUj+fl3b/SN1Uu+t3LYaXTwKHlgD08DomhFpnPEohzVKoeM7O FLKeen/9M5xWEOo7HmWnlol2Vvl583+3hzkqUzRyBBgD3eD/GyQGPfj7KFNpiL5W/1ir 8Bh6/QIsGHt031qbC7UXIc1EcrZ4SLRodtfGwO+WttCk3tO2Bfl/VD42/L2XZdLqIND5 w/vw== X-Gm-Message-State: AJcUukcqV4cBdCUy6P4y3tEVaFKqqt4OhkuMnIkXMZUjmj96iZYZZNqc QHrhMxrUwXf/NH6CgAZJ6FRWYvV2a7I= X-Received: by 2002:a19:c4cc:: with SMTP id u195mr12471052lff.141.1548520346833; Sat, 26 Jan 2019 08:32:26 -0800 (PST) Received: from mimer.lan (h-29-16.A159.priv.bahnhof.se. [79.136.29.16]) by smtp.gmail.com with ESMTPSA id e94sm2170532lfi.23.2019.01.26.08.32.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Jan 2019 08:32:26 -0800 (PST) From: Jonas Bonn To: linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Cc: Jonas Bonn , Nicolas Ferre , Mark Brown , Alexandre Belloni , Ludovic Desroches , linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/2] spi-atmel: support inter-word delay Date: Sat, 26 Jan 2019 17:32:20 +0100 Message-Id: <20190126163220.26421-3-jonas@norrbonn.se> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190126163220.26421-1-jonas@norrbonn.se> References: <20190126163220.26421-1-jonas@norrbonn.se> 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 If the SPI slave requires an inter-word delay, configure the DLYBCT register accordingly. Tested on a SAMA5D2 board (derived from SAMA5D2-Xplained reference board). Signed-off-by: Jonas Bonn CC: Nicolas Ferre CC: Mark Brown CC: Alexandre Belloni CC: Ludovic Desroches CC: linux-spi@vger.kernel.org CC: linux-arm-kernel@lists.infradead.org --- drivers/spi/spi-atmel.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 74fddcd3282b..24445bfbd74e 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -1209,13 +1209,21 @@ static int atmel_spi_setup(struct spi_device *spi) csr |= SPI_BIT(CSAAT); /* DLYBS is mostly irrelevant since we manage chipselect using GPIOs. - * - * DLYBCT would add delays between words, slowing down transfers. - * It could potentially be useful to cope with DMA bottlenecks, but - * in those cases it's probably best to just use a lower bitrate. */ csr |= SPI_BF(DLYBS, 0); - csr |= SPI_BF(DLYBCT, 0); + + /* DLYBCT adds delays between words. This is useful for slow devices + * that need a bit of time to setup the next transfer. + */ + if (spi->word_delay) { + csr |= SPI_BF(DLYBCT, + clamp_t(u8, + (as->spi_clk/1000000*spi->word_delay)>>5, + 1, 255)); + } else { + csr |= SPI_BF(DLYBCT, 0); + } + /* chipselect must have been muxed as GPIO (e.g. in board setup) */ npcs_pin = (unsigned long)spi->controller_data; -- 2.19.1