From patchwork Thu Jun 30 03:54:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Pronin X-Patchwork-Id: 9206607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 21FCA60752 for ; Thu, 30 Jun 2016 03:56:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1563F2859C for ; Thu, 30 Jun 2016 03:56:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A3DA2863B; Thu, 30 Jun 2016 03:56:23 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 DA9B5285E6 for ; Thu, 30 Jun 2016 03:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751926AbcF3DzS (ORCPT ); Wed, 29 Jun 2016 23:55:18 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35099 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751669AbcF3Dyr (ORCPT ); Wed, 29 Jun 2016 23:54:47 -0400 Received: by mail-pa0-f44.google.com with SMTP id hl6so23917498pac.2 for ; Wed, 29 Jun 2016 20:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I6eeNm30v8ITAqLe4rTbaiDKIFQg6NeGUJgzN+WMNjw=; b=YgkSQdaGCAaBwps9RVqT9j3/2KyyGqknNJkfnQJq7v5bBnjhkxU7w8pGNsiNhWh6+G NpIAJI+mfjkJZpVEUKjHdUUK/royTRz67/MVq2HG7XhE8JfVEzx0jwzq0qP7Nj46H3xQ GWq0IoVcr1Hk0P8OQiZqMKOBbRwIBzHyFrGCI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I6eeNm30v8ITAqLe4rTbaiDKIFQg6NeGUJgzN+WMNjw=; b=L2Yo1OizYMjl7zAMBgbwHZz25KOsKgeVNLaulvk5C8QK0EfyjoPCDpgd+9ox6t7fkD iB/N0MGGfRCPwsWQ1qoLWWWw7dt82+wnFTTLfpTOfMli0GKHsipMrFANxgMNPiqmG13B 7R4vL7M5c2vAXwTQUc3JdlTn1pdcmfLsm45n2PpCZCZWlnhgPihgM8s8bUgo35L2bPQg xA4ZnMh0JeCRRpd7oszVluXW12a+8kFoXCnrp4PGMzENwIeTB16/0u9htr47rPRscODK S+fJkr+tMwexDSeISEr6/QC/9QtbBIf/6AVHx37mZVPJd142gj/L8OGx4SoDRSG8vr36 QZyQ== X-Gm-Message-State: ALyK8tISwQYndeMwByXIHGOCwFjT9cZ+EG8lg8h6XD4VWdGnV9zhoDFomu82/2Jrr5PtW9uu X-Received: by 10.66.180.40 with SMTP id dl8mr17812180pac.131.1467258870533; Wed, 29 Jun 2016 20:54:30 -0700 (PDT) Received: from apronin0.mtv.corp.google.com ([172.22.64.136]) by smtp.gmail.com with ESMTPSA id 64sm1184045pfj.96.2016.06.29.20.54.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Jun 2016 20:54:29 -0700 (PDT) From: apronin@chromium.org To: Mark Brown Cc: linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Andrey Pronin Subject: [PATCH 3/4] spi: Add option to insert delay between transactions Date: Wed, 29 Jun 2016 20:54:26 -0700 Message-Id: <1467258867-117727-3-git-send-email-apronin@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1467258867-117727-1-git-send-email-apronin@chromium.org> References: <1467258867-117727-1-git-send-email-apronin@chromium.org> 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 From: Andrey Pronin Some devices may need CS to be deasserted for some time between transactions. Added a new capability to guarantee a delay between SPI transactions for the device. Signed-off-by: Andrey Pronin --- drivers/spi/spi.c | 3 +++ include/linux/spi/spi.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index c51c864..639c7bd 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -971,6 +971,9 @@ static int spi_transfer_one_message(struct spi_master *master, spi_reset_cs_wake_timer(msg->spi); } + if (msg->spi->xfer_delay) + mdelay(msg->spi->xfer_delay); + spi_set_cs(msg->spi, true); SPI_STATISTICS_INCREMENT_FIELD(statm, messages); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 4b06ba6..4b1aa13 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -137,6 +137,8 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats, * @cs_wake_timer: Timer measuring the delay before the device goes to * sleep after the last SPI transaction. * + * @xfer_delay: Delay between SPI transactions (msec). + * * @statistics: statistics for the spi_device * * A @spi_device is used to interchange data between an SPI slave @@ -183,6 +185,8 @@ struct spi_device { bool cs_wake_needed; struct timer_list cs_wake_timer; + u32 xfer_delay; + /* the statistics */ struct spi_statistics statistics;