From patchwork Thu Mar 7 14:29:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Kundr=C3=A1t?= X-Patchwork-Id: 10843245 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 11A8B139A for ; Thu, 7 Mar 2019 15:39:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 000252E99E for ; Thu, 7 Mar 2019 15:39:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E83D82E9AA; Thu, 7 Mar 2019 15:39:49 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 8C40E2E99E for ; Thu, 7 Mar 2019 15:39:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726663AbfCGPjt (ORCPT ); Thu, 7 Mar 2019 10:39:49 -0500 Received: from office2.cesnet.cz ([195.113.144.244]:47630 "EHLO office2.cesnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726579AbfCGPjs (ORCPT ); Thu, 7 Mar 2019 10:39:48 -0500 Received: from localhost (unknown [IPv6:2001:718:1:2c:9077:1a3:d51f:f1d6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id 1F58F400052; Thu, 7 Mar 2019 16:39:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2; t=1551973187; bh=BWY/Gco1RnvhBRn/5ZlJ6RzMkGtM4X/unRyBbw9X+Gk=; h=Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To: References:From:Date:Subject:To:Cc; b=ohjTiNO1+Aj71eRelolEobZsZ+ujmWeJsQXkZRakkAVLi4Ai4Cy8AqLB9MEx96QGt BAmj5rhw7SbMWalXbAgfewAezK5EqFZJThSNoGU6rulp0Gu3Qo+UnrlvAHWiIfBcBx I2zyXxPPDngf+5b8mS8YNCmr3xFBcuTIzEzqkA4k= Message-Id: <3373a2cd6a708ddd1d5d2dbcd3dd2279318c392d.1551971833.git.jan.kundrat@cesnet.cz> In-Reply-To: References: From: =?utf-8?q?Jan_Kundr=C3=A1t?= Date: Thu, 7 Mar 2019 15:29:42 +0100 Subject: [PATCH 1/3] spi: spidev: Enable control of inter-word delays MIME-Version: 1.0 To: linux-spi@vger.kernel.org, Mark Brown , Jonas Bonn Cc: Kosta Zertsekel , Baolin Wang , Chris Packham 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 Commit b7bb367afa4b added support for inserting delays in between individual words within a single SPI transaction. This makes it accessible from userspace. WARNING: This delay is silently ignored unless the SPI controller implements extra support for it. This is similar to how the in-kernel users handle the other existing property, spi_transfer->word_delay. Signed-off-by: Jan Kundrát --- drivers/spi/spidev.c | 4 +++- include/uapi/linux/spi/spidev.h | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index b0c76e2626ce..70966e10be7e 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -276,17 +276,19 @@ static int spidev_message(struct spidev_data *spidev, k_tmp->bits_per_word = u_tmp->bits_per_word; k_tmp->delay_usecs = u_tmp->delay_usecs; k_tmp->speed_hz = u_tmp->speed_hz; + k_tmp->word_delay_usecs = u_tmp->word_delay_usecs; if (!k_tmp->speed_hz) k_tmp->speed_hz = spidev->speed_hz; #ifdef VERBOSE dev_dbg(&spidev->spi->dev, - " xfer len %u %s%s%s%dbits %u usec %uHz\n", + " xfer len %u %s%s%s%dbits %u usec %u usec %uHz\n", u_tmp->len, u_tmp->rx_buf ? "rx " : "", u_tmp->tx_buf ? "tx " : "", u_tmp->cs_change ? "cs " : "", u_tmp->bits_per_word ? : spidev->spi->bits_per_word, u_tmp->delay_usecs, + u_tmp->word_delay_usecs, u_tmp->speed_hz ? : spidev->spi->max_speed_hz); #endif spi_message_add_tail(k_tmp, &msg); diff --git a/include/uapi/linux/spi/spidev.h b/include/uapi/linux/spi/spidev.h index c4253f0090d8..ee0f2460bff6 100644 --- a/include/uapi/linux/spi/spidev.h +++ b/include/uapi/linux/spi/spidev.h @@ -66,6 +66,9 @@ * @delay_usecs: If nonzero, how long to delay after the last bit transfer * before optionally deselecting the device before the next transfer. * @cs_change: True to deselect device before starting the next transfer. + * @word_delay_usecs: If nonzero, how long to wait between words within one + * transfer. This property needs explicit support in the SPI controller, + * otherwise it is silently ignored. * * This structure is mapped directly to the kernel spi_transfer structure; * the fields have the same meanings, except of course that the pointers @@ -100,7 +103,8 @@ struct spi_ioc_transfer { __u8 cs_change; __u8 tx_nbits; __u8 rx_nbits; - __u16 pad; + __u8 word_delay_usecs; + __u8 pad; /* If the contents of 'struct spi_ioc_transfer' ever change * incompatibly, then the ioctl number (currently 0) must change; From patchwork Thu Mar 7 14:38:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Kundr=C3=A1t?= X-Patchwork-Id: 10843247 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 8D4111390 for ; Thu, 7 Mar 2019 15:39:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B9832E99E for ; Thu, 7 Mar 2019 15:39:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FA3C2E9AA; Thu, 7 Mar 2019 15:39:52 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 1E9AD2E99E for ; Thu, 7 Mar 2019 15:39:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726294AbfCGPjv (ORCPT ); Thu, 7 Mar 2019 10:39:51 -0500 Received: from office2.cesnet.cz ([195.113.144.244]:47656 "EHLO office2.cesnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726275AbfCGPjv (ORCPT ); Thu, 7 Mar 2019 10:39:51 -0500 Received: from localhost (unknown [IPv6:2001:718:1:2c:9077:1a3:d51f:f1d6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id DE1FA40005D; Thu, 7 Mar 2019 16:39:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2; t=1551973189; bh=jjI2R2SughRNoKxB2KtIIfgI0iNmF5kwLLNB/3k4YmU=; h=Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To: References:From:Date:Subject:To:Cc; b=YpsquLhYPbpbwbBfei3puUeG8CODQpndd+uSfyDl8RMUHFOROww9UZMAdLbfdvm3r V+ijlP9RtdrsdLYiFk2v1/paUiUpTkdSsgyaQic5zSnyeyQrD8zoqHsaMolw2+LSK4 FhBtJp4p3AIfH8HtQQuuYWx2YF7QBbmNsBHWj548= Message-Id: <36a76356d1ff2e08ebfd43fdfbe6360d5b979e35.1551971833.git.jan.kundrat@cesnet.cz> In-Reply-To: References: From: =?utf-8?q?Jan_Kundr=C3=A1t?= Date: Thu, 7 Mar 2019 15:38:35 +0100 Subject: [PATCH 2/3] spi: orion: Support spi_xfer->word_delay_usecs MIME-Version: 1.0 To: linux-spi@vger.kernel.org, Mark Brown , Jonas Bonn Cc: Kosta Zertsekel , Baolin Wang , Chris Packham 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 Signed-off-by: Jan Kundrát --- drivers/spi/spi-orion.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index 7822fd73e0b9..eb70a9dc31ac 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -470,6 +470,8 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) if (orion_spi_write_read_8bit(spi, &tx, &rx) < 0) goto out; count--; + if (xfer->word_delay_usecs) + udelay(xfer->word_delay_usecs); } while (count); } else if (word_len == 16) { const u16 *tx = xfer->tx_buf; @@ -479,6 +481,8 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) if (orion_spi_write_read_16bit(spi, &tx, &rx) < 0) goto out; count -= 2; + if (xfer->word_delay_usecs) + udelay(xfer->word_delay_usecs); } while (count); } From patchwork Thu Mar 7 14:43:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Kundr=C3=A1t?= X-Patchwork-Id: 10843249 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 3A64A1390 for ; Thu, 7 Mar 2019 15:39:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27D712E99E for ; Thu, 7 Mar 2019 15:39:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19F182E9EE; Thu, 7 Mar 2019 15:39:55 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 ADB072E99E for ; Thu, 7 Mar 2019 15:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726387AbfCGPjy (ORCPT ); Thu, 7 Mar 2019 10:39:54 -0500 Received: from office2.cesnet.cz ([195.113.144.244]:47668 "EHLO office2.cesnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726275AbfCGPjy (ORCPT ); Thu, 7 Mar 2019 10:39:54 -0500 Received: from localhost (unknown [IPv6:2001:718:1:2c:9077:1a3:d51f:f1d6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id 5F3BE400052; Thu, 7 Mar 2019 16:39:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2; t=1551973192; bh=5yyRKwdtW+Qqiy8/FPe81wSkccK0WZ4x9PDol404N8M=; h=Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To: References:From:Date:Subject:To:Cc; b=erRL7LJot5GbUyE9czdB2oc7eHQJixdjNiw6aDqYvnAIIfCEaV8UjRH8MeKxiLVlS 1pnYac+wzurTXlLpklv+y69uDHuQVq0vptWFfs99SNsQLQQJZlhwHGS+ySRqWdKUWD fPtel34JO7/h1emBdk/iMjrNPsNAFiDubmVz4zUo= Message-Id: In-Reply-To: References: From: =?utf-8?q?Jan_Kundr=C3=A1t?= Date: Thu, 7 Mar 2019 15:43:56 +0100 Subject: [PATCH 3/3] Revert "spi: orion: Prepare space for per-child options" To: linux-spi@vger.kernel.org, Mark Brown , Jonas Bonn Cc: Kosta Zertsekel , Baolin Wang , Chris Packham 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 That commit only made sense when there were more per-child options such as per-slave interword delay, perhaps obtained via DT. That never happened. Instead, the inter-word delay feature got implemented during the 5.1 cycle, but it works on a per-transfer basis rather than per-child. This means that it is quite likely that we won't be stashing more per-child options in that struct, and I can clean up after myself. Sorry for noise. This reverts commit 5c22af7eeb265413b80eb8e03ae708e1b222728c. Signed-off-by: Jan Kundrát --- drivers/spi/spi-orion.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index eb70a9dc31ac..7d2e9bcc8b30 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -91,10 +91,6 @@ struct orion_direct_acc { u32 size; }; -struct orion_child_options { - struct orion_direct_acc direct_access; -}; - struct orion_spi { struct spi_master *master; void __iomem *base; @@ -103,7 +99,7 @@ struct orion_spi { const struct orion_spi_dev *devdata; int unused_hw_gpio; - struct orion_child_options child[ORION_NUM_CHIPSELECTS]; + struct orion_direct_acc direct_access[ORION_NUM_CHIPSELECTS]; }; static inline void __iomem *spi_reg(struct orion_spi *orion_spi, u32 reg) @@ -442,7 +438,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) * Use SPI direct write mode if base address is available. Otherwise * fall back to PIO mode for this transfer. */ - vaddr = orion_spi->child[cs].direct_access.vaddr; + vaddr = orion_spi->direct_access[cs].vaddr; if (vaddr && xfer->tx_buf && word_len == 8) { unsigned int cnt = count / 4; @@ -687,7 +683,6 @@ static int orion_spi_probe(struct platform_device *pdev) } for_each_available_child_of_node(pdev->dev.of_node, np) { - struct orion_direct_acc *dir_acc; u32 cs; int cs_gpio; @@ -755,13 +750,14 @@ static int orion_spi_probe(struct platform_device *pdev) * This needs to get extended for the direct SPI-NOR / SPI-NAND * support, once this gets implemented. */ - dir_acc = &spi->child[cs].direct_access; - dir_acc->vaddr = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE); - if (!dir_acc->vaddr) { + spi->direct_access[cs].vaddr = devm_ioremap(&pdev->dev, + r->start, + PAGE_SIZE); + if (!spi->direct_access[cs].vaddr) { status = -ENOMEM; goto out_rel_axi_clk; } - dir_acc->size = PAGE_SIZE; + spi->direct_access[cs].size = PAGE_SIZE; dev_info(&pdev->dev, "CS%d configured for direct access\n", cs); }