From patchwork Fri Jan 25 11:44:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 10781235 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 16E29139A for ; Fri, 25 Jan 2019 11:44:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03A722EEE9 for ; Fri, 25 Jan 2019 11:44:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBE512EF09; Fri, 25 Jan 2019 11:44:37 +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 886712EF41 for ; Fri, 25 Jan 2019 11:44:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727955AbfAYLof (ORCPT ); Fri, 25 Jan 2019 06:44:35 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:47052 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726111AbfAYLof (ORCPT ); Fri, 25 Jan 2019 06:44:35 -0500 Received: by mail-lf1-f65.google.com with SMTP id f5so6681837lfc.13 for ; Fri, 25 Jan 2019 03:44:34 -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=t213Fky0dlXC3LPSWsEKGnyugEHm5O3iqscObb9Pu/w=; b=1xYk19Kg544xWRSp+fgR6kC0YIM8F3jCjUq0+6joWIOq7QV/glm/vE+RGsKAHHVwJb rRxTuKotg8Ypz59HaO4dudfIJPU4iclpVgxhUUTwHnmGakWc8FFxVpHiIRTw0moO4EbZ p1Ibcb7FbSEdyav9ImSloKTh5hKDIpwLMdL1S3Bj76vv1g+pbzxP9YDH30UIUrSKtgEB NLL2Pq5Deb5Ds7akktjfKP5nO03xYopR5or3hUfrws4eEJ9pgLYYIGoqiNk7uQ3zgxwe ztefr/BN8pgSwJ+L8o6yL6C5Q1Aj7eMP+HG3jljdJhqj95rDvuQW+sbOste04lMhSQEO aghg== 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=t213Fky0dlXC3LPSWsEKGnyugEHm5O3iqscObb9Pu/w=; b=F9xwlKZSn2+LdWR0zVw2BV4oxJn7OQu9mQtzoMXG+RsQuJz8n37X7NsA4bB3S6yVJ2 usB/1pd57mmLdAJXcd7ZQJghi7oCV9sjoDfzPtiehRr6Sa0s9AOT+ZxkoD6vuN0lMgt1 M9DI/1q0UMWdnq+jWqxsxXp3tl10Hf06O5bqESAfXeBvMfYW6P5UAIWwhy+GonbidtYd ucdUPs+IBeRGO6YGIKIaeSirZmpkJWjSIVLUWLppto8pSjWQ8S+E8faqZZR/IMdtGCDe WiYzxTsQA2TgQ5y7XJcLD6ETix1vfvsiOgiHOyfyapmzInbzXnZNCKiHFi1INlkQSr+t UUog== X-Gm-Message-State: AJcUukdo5tiXAGsjZ8ZvP/gW2lxCjOykqcPiDiYrSsYeFmk178mZ1qz8 gt3RHKA3vxmyU3y92rqPGOd0hg== X-Google-Smtp-Source: ALg8bN4CGxebTCla8p8UY9zrtvRPivH2niOoBxryVUcWJMAUoaYMc65fTANBaUiBnLj7cosKJSXv+g== X-Received: by 2002:a19:a86:: with SMTP id 128mr8627485lfk.139.1548416673365; Fri, 25 Jan 2019 03:44:33 -0800 (PST) Received: from mimer.lan (h-29-16.A159.priv.bahnhof.se. [79.136.29.16]) by smtp.gmail.com with ESMTPSA id l3-v6sm1490962ljg.21.2019.01.25.03.44.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jan 2019 03:44:32 -0800 (PST) From: Jonas Bonn To: linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Cc: Jonas Bonn , Mark Brown , Rob Herring , Mark Rutland , devicetree@vger.kernel.org Subject: [PATCH 1/2] spi: support inter-word delay requirement for devices Date: Fri, 25 Jan 2019 12:44:28 +0100 Message-Id: <20190125114429.20066-2-jonas@norrbonn.se> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190125114429.20066-1-jonas@norrbonn.se> References: <20190125114429.20066-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 Some devices are slow and cannot keep up with the SPI bus and therefore require a short delay between words of the SPI transfer. The example of this that I'm looking at is a SAMA5D2 with a minimum SPI clock of 400kHz talking to an AVR-based SPI slave. The AVR cannot put bytes on the bus fast enough to keep up with the SoC's SPI controller even at the lowest bus speed. This patch introduces the ability to specify a required inter-word delay for SPI devices. It is up to the controller driver to configure itself accordingly in order to introduce the requested delay. Signed-off-by: Jonas Bonn CC: Mark Brown CC: Rob Herring CC: Mark Rutland CC: linux-spi@vger.kernel.org CC: devicetree@vger.kernel.org --- Documentation/devicetree/bindings/spi/spi-bus.txt | 1 + drivers/spi/spi.c | 4 ++++ include/linux/spi/spi.h | 1 + 3 files changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt index 1f6e86f787ef..a5f20060676d 100644 --- a/Documentation/devicetree/bindings/spi/spi-bus.txt +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt @@ -77,6 +77,7 @@ All slave nodes can contain the following optional properties: Defaults to 1 if not present. - spi-rx-delay-us - Microsecond delay after a read transfer. - spi-tx-delay-us - Microsecond delay after a write transfer. +- spi-word-delay-us - Microsecond delay between individual words of a transfer Some SPI controllers and devices support Dual and Quad SPI transfer mode. It allows data in the SPI system to be transferred using 2 wires (DUAL) or 4 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 9a7def7c3237..cd4d4065eca2 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1692,6 +1692,10 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi, } spi->max_speed_hz = value; + if (!of_property_read_u32(nc, "spi-word-delay-us", &value)) { + spi->word_delay = value; + } + return 0; } diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 314d922ca607..e5200dd9d750 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -164,6 +164,7 @@ struct spi_device { char modalias[SPI_NAME_SIZE]; const char *driver_override; int cs_gpio; /* chip select gpio */ + uint16_t word_delay; /* inter-word delay (us) */ /* the statistics */ struct spi_statistics statistics;