From patchwork Sat Jan 26 16:32:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 10782515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E383B91E for ; Sat, 26 Jan 2019 16:36:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D272929E46 for ; Sat, 26 Jan 2019 16:36:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6F6D2A51E; Sat, 26 Jan 2019 16:36:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6946E29E46 for ; Sat, 26 Jan 2019 16:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726215AbfAZQgU (ORCPT ); Sat, 26 Jan 2019 11:36:20 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45547 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbfAZQc3 (ORCPT ); Sat, 26 Jan 2019 11:32:29 -0500 Received: by mail-lf1-f65.google.com with SMTP id b20so9008987lfa.12 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=emSOcGpguZ+peYT0T5b879T0+Jrc29AAbVMK/l+GzY7jzZfHUkKLvn+4BSE2DdNbpd buJsYTrBmpbo6wsKAcUtRk40hpWJWuN7Yp2cebut5BRZYf3PX6TzoRYDSDV06dz/jDRC hr44ONsw3TCe41zXoLTikZAjOSEo7weJCZKZAk8kFfUeyt0++YA1IlAvh1ZD62wo1RCW vwDM61PSOQxjEuEdglVu/FnBqXgaMIwvARRWSx4rGxnpv8FjJR/s4kdp0tkpy1NgIwcW YATg+FalOZQsw9r0dlHvxiIFDY1sLT1F+SuZrm4aqvhPOiWXwpUHBFBwEHMVI8wzO9gH cpvg== X-Gm-Message-State: AJcUukfS0e50m8hyXChkZ/4/oM83X5OkVZaXKV01NoOfYxzIahS0UTYb uI7R0PmyQ80fsitrvk48uWdM3g== X-Google-Smtp-Source: ALg8bN7ixO5jynANWXsRXQCc6pion+WBh06LKAJNIlpvS/JPjjM6Ib4nje2yFpEoX9h2Cy6IwOzaeA== 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 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;