Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1411256pxb; Fri, 20 Aug 2021 05:08:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0TaSEHpU2KUVp+n1pHLNuy5pzZfBX4ebhf+Td7PC4naIsjtod0XVC/ddney0YMZ/YFCQl X-Received: by 2002:a6b:6319:: with SMTP id p25mr16035695iog.100.1629461312854; Fri, 20 Aug 2021 05:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629461312; cv=none; d=google.com; s=arc-20160816; b=VGxtBQnGnL2ZMs0ZUYAAYelS1HF9YCvnE68ibP0PyWXNg4y170JKbvwQcOh/gbrxcQ VBMB/6f00y4QXWVaCdNl/rTyOO6V1h8t4FQlli5pzyByG78WPuuniybGGjEAHZQxuuGY 4zQcW/0v2VqC/rcDMxaojFPJv4fteC5cGAAhzSxM1qQ+Fq3PVd/BBWx2ft0NxS1zbh4U vVKH9CJI5lDtVRamxNAsQTDlqWsVeXkwgb0l0WJgwTfUbBdbFZVm7iNdYv4hw1pHgrsa CPaQLAkTs6xoBOHbrzigAJSI3h7zM0w2KLPf2ulfUrraz5s19OQxiuz5YoZgCLchK8/7 1IsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=dSWYR1MtG0z37Q9GjHvFbL1Y2ywafgAyJiMXJqFJpsQ=; b=p0fpcy6z57s/SXM5s79tV8RRYv6Th8NO7+OlcRzMfUJZ4S6jzWwk+9pTGHKFfP/Wgq uvNkpU70tNiuAckOjAq8PEGMlozR4N7HzehYZqoXH2YipTO4QcUpWtvSOTMixFvLdr6S 4D4u8sKCx920CrPWhtz+2aJqaWPDXx6iHgShevGxne04yQvCVf0jVObNEEnaV+vE/RmY xiwXtCpFoyutYTvX5mY8NVjLbNo1x6P2JpZN/sdtaPoB9KS5eYXiswUPIoPVxNVL8lVR nEBw4v+wjq6eL/fkkKLwSKxloAJoMoKQB6aIqPu/XQlgehmL6cVDbUnoOimh8lb/MOsU iJPQ== 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 y9si7780133ilu.22.2021.08.20.05.08.21; Fri, 20 Aug 2021 05:08:32 -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 S239903AbhHTMHi convert rfc822-to-8bit (ORCPT + 99 others); Fri, 20 Aug 2021 08:07:38 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:48089 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237764AbhHTMHh (ORCPT ); Fri, 20 Aug 2021 08:07:37 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 9DFEF1BF207; Fri, 20 Aug 2021 12:06:57 +0000 (UTC) Date: Fri, 20 Aug 2021 14:06:56 +0200 From: Miquel Raynal To: Apurva Nandan Cc: Richard Weinberger , Vignesh Raghavendra , Mark Brown , Patrice Chotard , Boris Brezillon , , , , Pratyush Yadav Subject: Re: [PATCH 04/13] mtd: spinand: Fix odd byte addr and data phase in read/write reg op and write VCR op for Octal DTR mode Message-ID: <20210820140656.72819d90@xps13> In-Reply-To: References: <20210713130538.646-1-a-nandan@ti.com> <20210713130538.646-5-a-nandan@ti.com> <20210806204334.5fedea42@xps13> Organization: Bootlin X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Apurva, Apurva Nandan wrote on Fri, 20 Aug 2021 15:57:36 +0530: > Hi Miquèl, > > On 07/08/21 12:13 am, Miquel Raynal wrote: > > Hi Apurva, > > > > Apurva Nandan wrote on Tue, 13 Jul 2021 13:05:29 > > +0000: > > > >> In Octal DTR SPI mode, 2 bytes of data gets transmitted over one clock > >> cycle, and half-cycle instruction phases aren't supported yet. So, > >> every DTR spi_mem_op needs to have even nbytes in all phases for > >> non-erratic behaviour from the SPI controller. > >> > >> The odd length cmd and dummy phases get handled by spimem_setup_op() > >> but the odd length address and data phases need to be handled according > >> to the use case. For example in Octal DTR mode, read register operation > >> has one byte long address and data phase. So it needs to extend it > >> by adding a suitable extra byte in addr and reading 2 bytes of data, > >> discarding the second byte. > >> > >> Handle address and data phases for Octal DTR mode in read/write > >> register and write volatile configuration register operations > >> by adding a suitable extra byte in the address and data phase. > >> > >> Create spimem_setup_reg_op() helper function to ease setting up > >> read/write register operations in other functions, e.g. wait(). > >> > >> Signed-off-by: Apurva Nandan > >> --- > >> drivers/mtd/nand/spi/core.c | 26 +++++++++++++++++++++----- > >> 1 file changed, 21 insertions(+), 5 deletions(-) > >> > >> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c > >> index 2e59faecc8f5..a5334ad34f96 100644 > >> --- a/drivers/mtd/nand/spi/core.c > >> +++ b/drivers/mtd/nand/spi/core.c > >> @@ -65,12 +65,27 @@ static void spinand_setup_op(const struct spinand_device *spinand, > >> } > >> } > >> >> +static void spinand_setup_reg_op(const struct spinand_device *spinand, > >> + struct spi_mem_op *op) > > > > Same remark about the naming. In fact I believe we could have this > > logic in _setup_op() (or whatever its name) and add a specific > > parameter for it? > > > > Okay, I will add a parameter in argument and include this logic in _setup_op(). > > >> +{ > >> + if (spinand->reg_proto == SPINAND_OCTAL_DTR) { > >> + /* > >> + * Assigning same first and second byte will result in constant > >> + * bits on ths SPI bus between positive and negative clock edges > > > > the > > > > Ok. > > >> + */ > >> + op->addr.val = (op->addr.val << 8) | op->addr.val; > > > > I am not sure to understand what you do here? > > > > In Octal DTR mode, 2 bytes of data are sent in a clock cycle. So, we need to append one extra byte when sending a single byte. This extra byte would be sent on the negative edge. > > It will make sense to keep both the bytes same, as when it will be set on the SPI pins, the bits on the SPI IO ports will remain constant between the positive and negative edges (as 1 complete byte is set in one clock edge in MSB order). There are no restrictions by the manufacturers on this, the relevant address byte needs to be on positive edge and second byte on negative edge is don't care. I was bothered by the shift but actually my head was mixing with the raw NAND core where these addresses are in an array but here it is a u64 which is then fine. (I will continue answering probably next week) Thanks, Miquèl