Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5587420imu; Tue, 29 Jan 2019 23:36:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN4kmrIJp5KOP2oSaLEfY2sCcfZmuv2bEK5/tkr5TfouASpci0UVLmdtwrwp5PObKic1k7Jd X-Received: by 2002:a17:902:a5c3:: with SMTP id t3mr28833491plq.117.1548833760084; Tue, 29 Jan 2019 23:36:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548833760; cv=none; d=google.com; s=arc-20160816; b=APiJdQ+C6aR23FR0l89uSbtNDuBOReObLQ62K3g67CDAdp1by1s/VwLipTuoKvYoPB LlZ24/n3E6ELs/mW8Dyamk/M5giClzxwR+REFizSUTE7F7Fg3apPhjfMC5ALIb1goJOv jA2O9m2OnfWmaT6PE+cjjWENL+N17LnwnShXMbJqTQItQiiQa9MRkekgGKsA/eH5nnLa WElAcFvKIB/loUUPm3YxrK1Kbi4Hwy2bzQtouWuftVHL2qtAx5AUSKIXc6qDGjLkFufw I3N7Jp0mHGl3nnZpz2N4ZrbyalzaIJ4H4vb4jN2JOURZ/5eF/MYgeBm9F4hNgz3WvD80 Le7g== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=dFX/e98MCwwf6BbkxS6majALHg0nCtAT7myRsVysPzs=; b=HHymbaJTNqLyFbW2Tli9CU3wEKyrgDiaX4uubIwsaw7QnzylN+7i94l3sG0cnlHp2+ nLQj5o/yanZh5igmAhRrmmWWtsY08KYTVkq4kpVygTB0Q/8d/zeR/Q2BOTT7GK5CA50Q sktMxOX/ysxZXvbmatyA4OZ1bTPKLbf0mPG1ZETgI32EQyUmNCF9JFzxejkjzGEVdqgO Kz5vo7Ve2dKya+OGEpAuxvPaYlsMNrnfsKx8d7gshy8Q6C5Z7H6aj5fNEJJAhLbum+mU t6BQF/bpQb7J3yj9eV3zxpsDAnJCF5sRSp/VqW4Hrk+4FyrusT5ujlYGqIvXH75gJecF vBdQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c30si763124pgn.52.2019.01.29.23.35.44; Tue, 29 Jan 2019 23:36:00 -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; 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 S1729934AbfA3Hfi convert rfc822-to-8bit (ORCPT + 99 others); Wed, 30 Jan 2019 02:35:38 -0500 Received: from mail-vk1-f193.google.com ([209.85.221.193]:39864 "EHLO mail-vk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725819AbfA3Hfi (ORCPT ); Wed, 30 Jan 2019 02:35:38 -0500 Received: by mail-vk1-f193.google.com with SMTP id s184so5126662vkd.6; Tue, 29 Jan 2019 23:35:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=YTpduAoMXxhUKgTnWFZbLAPz2z/lmnMmtAOe3HKxleY=; b=Ghc8vyMeYxNb7epjXKHEw6+s8K7DNa+fSQgoujwgcEvFnBC4lFBRHSbSZKPFiz34kx /b6T4bexs5WR8G5Gl1O5qUekL37zis/yanST2g+cQNhHpkkddropcpTC5bmAVVhTYh+4 sDi9GjgmEaDBpCGrRrGbsSgEDSpDhJygnvDY7Mf4iMzu45tjshj/eO0ZyVCP2D0csA63 McyatEyl+DeHNx1RaqqD02NPtOoHECiniRKZkXXmqS/4ZPIaSRlag3a3u9GRBFqyYuTo FpOFDzSGXBFrCL+T6T+ErRwnX2L0K44pNJB8+J4o2p8ZBI9MSqOl/Gz2ahf/p0itqubw WK3w== X-Gm-Message-State: AJcUukd2SBhCtVadlh+pPpdo2H0v1Btf6W/DgBXANC/7o2JIv2vLSfME upS4BOAFaghZ57TlZTbLzCdSjrH8Xkb62qKaB7UN5Ug4 X-Received: by 2002:a1f:a414:: with SMTP id n20mr12090963vke.83.1548833736817; Tue, 29 Jan 2019 23:35:36 -0800 (PST) MIME-Version: 1.0 References: <20190129205502.7741-1-jonas@norrbonn.se> <20190129205502.7741-2-jonas@norrbonn.se> In-Reply-To: <20190129205502.7741-2-jonas@norrbonn.se> From: Geert Uytterhoeven Date: Wed, 30 Jan 2019 08:35:25 +0100 Message-ID: Subject: Re: [PATCH v5 1/2] spi: support inter-word delay requirement for devices To: Jonas Bonn Cc: Linux Kernel Mailing List , Mark Brown , Rob Herring , Mark Rutland , linux-spi , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jonas, On Tue, Jan 29, 2019 at 9:55 PM Jonas Bonn wrote: > 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. > > Note that, for spi_transfer, there is already a field word_delay that > provides similar functionality. This field, however, is specified in > clock cycles (and worse, SPI controller cycles, not SCK cycles); that > makes this value dependent on the master clock instead of the device > clock for which the delay is intended to provide some relief. This > patch leaves this old word_delay in place and provides a time-based > word_delay_us alongside it; the new field fits in the struct padding > so struct size is constant. There is only one in-kernel user of the > word_delay field and presumably that driver could be reworked to use > the time-based value instead. Thanks for your patch! > The time-based delay is limited to 8 bits as these delays are intended > to be short. The SAMA5D2 that I've tested this on limits delays to a > maximum of ~100us, which is already many word-transfer periods even at > the minimum transfer speed supported by the controller. Still, the similar delay_usecs uses a u16. > --- a/include/linux/spi/spi.h > +++ b/include/linux/spi/spi.h > @@ -803,6 +808,7 @@ struct spi_transfer { > #define SPI_NBITS_DUAL 0x02 /* 2bits transfer */ > #define SPI_NBITS_QUAD 0x04 /* 4bits transfer */ > u8 bits_per_word; > + u8 word_delay_us; us for µs > u16 delay_usecs; usecs for µs Can we please try to be consistent? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds