Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp229898ybm; Thu, 28 May 2020 01:02:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ+/4qhSGUkKzRsUe27onNfkkSavMBhLHn8oipp6qQhOHsFI5vLLddgVTxmzXiWTu2jGyc X-Received: by 2002:a05:6402:1a23:: with SMTP id be3mr1845298edb.202.1590652962071; Thu, 28 May 2020 01:02:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590652962; cv=none; d=google.com; s=arc-20160816; b=Iw4CTDasRTk5bzmX4DELYILF+hvGwXIPY7JC/T919Xxw4rhWnK4KVAPq6uC776lFm9 emprPgoHRmCAZMjOlfZW54Vi6yqd2HfgEM8wVzUvDqguuTGCxRmBI9MX8Lb17lIAMdy5 o3VAwNu+lai8Rla6MsOQCQXRfHKA4BCi+xSStjeVbT8T9zsZhGn3U8NhaL+EfxV920ip qkve9K/1C8PbYd/8P6s2XU3JP6sCv+twnDdSXL4XFX2blAaGlgR9cYo8rNw6hXu0RiLw 8y70qE9n5FJr543NVD2kKCK2eRf8s21jVl19Z6hwN3IlExAzB6Nw2mqMQc8wEC9CK/YE zHqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=JrVZzH6IOcGpccYamsXkhpfSZlbvPOvmAk4v7GRXdLA=; b=qgO6RtqDgVS1+GN5nMjECYwAb0QegSBg34SxhioucD+WPV7HelUg+8ZVKDFRYaLPdr Zyq/9K9F3+nqBTeQrFgQf/MjrySmvxOvyXZCMmR0s8qDTBMUFywP2+I/nz+ZeA8SGddD AYy9e4RgTW8TGoDnEjsKBc0VZaewJwTjj8ctdOUUM1Tnrqo1318cEUo0SRG6ttcwttEJ MKgiPT7UU4TE5bFS1+MEfakTwKRqT2wDXeGfCwcOZ8/xOelDZeO13O3crpBqdpzCeCma 8IsTnh34ZcYF2xHBTupkYjCYyuh4NfB28+MkVlGPJ8JPKAmZD+EjsTYT9hJgK6/ahWJG fPyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q14si3394625ejt.12.2020.05.28.01.02.18; Thu, 28 May 2020 01:02:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726453AbgE1H6e (ORCPT + 99 others); Thu, 28 May 2020 03:58:34 -0400 Received: from twhmllg4.macronix.com ([122.147.135.202]:31105 "EHLO TWHMLLG4.macronix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725779AbgE1H6d (ORCPT ); Thu, 28 May 2020 03:58:33 -0400 Received: from localhost.localdomain ([172.17.195.96]) by TWHMLLG4.macronix.com with ESMTP id 04S7wMHa030973; Thu, 28 May 2020 15:58:23 +0800 (GMT-8) (envelope-from masonccyang@mxic.com.tw) From: Mason Yang To: broonie@kernel.org, tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, boris.brezillon@collabora.com, matthias.bgg@gmail.com Cc: p.yadav@ti.com, juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org Subject: [PATCH v3 01/14] spi: spi-mem: allow specifying whether an op is DTR or not Date: Thu, 28 May 2020 15:58:03 +0800 Message-Id: <1590652696-8844-2-git-send-email-masonccyang@mxic.com.tw> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1590652696-8844-1-git-send-email-masonccyang@mxic.com.tw> References: <1590652696-8844-1-git-send-email-masonccyang@mxic.com.tw> X-MAIL: TWHMLLG4.macronix.com 04S7wMHa030973 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pratyush Yadav Each phase is given a separate 'dtr' field so mixed protocols like 4S-4D-4D can be supported. Signed-off-by: Pratyush Yadav --- drivers/spi/spi-mem.c | 3 +++ include/linux/spi/spi-mem.h | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index adaa0c4..d8905e0 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -154,6 +154,9 @@ bool spi_mem_default_supports_op(struct spi_mem *mem, op->data.dir == SPI_MEM_DATA_OUT)) return false; + if (op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr) + return false; + return true; } EXPORT_SYMBOL_GPL(spi_mem_default_supports_op); diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h index af9ff2f..e3dcb95 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h @@ -71,9 +71,11 @@ enum spi_mem_data_dir { * struct spi_mem_op - describes a SPI memory operation * @cmd.buswidth: number of IO lines used to transmit the command * @cmd.opcode: operation opcode + * @cmd.dtr: whether the command opcode should be sent in DTR mode or not * @addr.nbytes: number of address bytes to send. Can be zero if the operation * does not need to send an address * @addr.buswidth: number of IO lines used to transmit the address cycles + * @addr.dtr: whether the address should be sent in DTR mode or not * @addr.val: address value. This value is always sent MSB first on the bus. * Note that only @addr.nbytes are taken into account in this * address value, so users should make sure the value fits in the @@ -81,7 +83,9 @@ enum spi_mem_data_dir { * @dummy.nbytes: number of dummy bytes to send after an opcode or address. Can * be zero if the operation does not require dummy bytes * @dummy.buswidth: number of IO lanes used to transmit the dummy bytes + * @dummy.dtr: whether the dummy bytes should be sent in DTR mode or not * @data.buswidth: number of IO lanes used to send/receive the data + * @data.dtr: whether the data should be sent in DTR mode or not * @data.dir: direction of the transfer * @data.nbytes: number of data bytes to send/receive. Can be zero if the * operation does not involve transferring data @@ -91,22 +95,26 @@ enum spi_mem_data_dir { struct spi_mem_op { struct { u8 buswidth; + u8 dtr : 1; u8 opcode; } cmd; struct { u8 nbytes; u8 buswidth; + u8 dtr : 1; u64 val; } addr; struct { u8 nbytes; u8 buswidth; + u8 dtr : 1; } dummy; struct { u8 buswidth; + u8 dtr : 1; enum spi_mem_data_dir dir; unsigned int nbytes; union { -- 1.9.1