Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2923673imw; Wed, 6 Jul 2022 14:10:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1us0hBMjYI2fTO5e1kPSBDs/8UHk5Lmw1j7PFNjlc6lcqcQ9lgVNvKkIssKcyjw+TvCE5qp X-Received: by 2002:a17:906:7309:b0:722:f9e9:3904 with SMTP id di9-20020a170906730900b00722f9e93904mr41314735ejc.198.1657141827287; Wed, 06 Jul 2022 14:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657141827; cv=none; d=google.com; s=arc-20160816; b=v8uAlprE9T5UhXteN9CI7lQGmP5XoaUuYext5K0zzTS68G9mzVM5iElG9tqvMJOjj2 7bSCsbTnzpZxfYx8/PHqxwUd1hgaxfmfkIWR06xwiKKijBZcTO0FmRzxCiwyoFLEd+ti f+6OQPZQT+wAZnROIn2MvZ9be1JKntHbwrFJeEOxGgrBY1vxtV83nYkfxm4n1HwZroKe K3Gh3Vchx3YgPz3haZm6xFhkj5rpU+Yoqnc4H8keQtu24XzxyqQLCWtf8vk+itGKVXVC lkIAnZVC196O9lQA4dbMWc8uYP810Q1dWiQuzVA5vdA7U2ddWd0qiOkAGLra2kCmkmO+ jxZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=l9BSZkguRrgG6EPhutYIDpmenXtzq7TNMD8r/kLbskc=; b=G5hVcVsrbgNC6EDQcx5uPRl+8TCYlaaO/q8c6412ofxDClrEPkdNHYPi4hh8Qgo9Ny ZtNefgFAy143UwMSLn6g0TRSAzbd9sAQhkn54Zo7gOpmF5UeIQiGpPqAZImlORwqLwjN ByIuyHvTkrYkvcS3fbQFDhvhe4d48LxpJKUMGG6basx+UXf1yHaFLzK5VpGziuFiXSxY fq/TBGEW/nkciCFedCDGUQP0Yv7OLIKE6Ky1PWFxeipMswd1ox9rluf2sx2TDD9K2npQ mT49HjoVRVn7F717+V6cI0pz8cOsDJPP8wEqGKDLAf8vOuXPLRFAKRZA4pyBT9peCoWm 6ZXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=WV6CXeZo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s7-20020a056402520700b0043a8aa80c05si4177022edd.399.2022.07.06.14.10.01; Wed, 06 Jul 2022 14:10:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=WV6CXeZo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234243AbiGFVCQ (ORCPT + 99 others); Wed, 6 Jul 2022 17:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233456AbiGFVCP (ORCPT ); Wed, 6 Jul 2022 17:02:15 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C926923146; Wed, 6 Jul 2022 14:02:14 -0700 (PDT) Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id BABEB2223A; Wed, 6 Jul 2022 23:02:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1657141332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l9BSZkguRrgG6EPhutYIDpmenXtzq7TNMD8r/kLbskc=; b=WV6CXeZou7RvdPtdmr829rwyfN9tS5+35cTyMXOAxcqfznoaZT/8RuIdbp+P9ggkpqNWH+ La5o6Jh73TqZrLjKcdw7QVMk4YsHTqNT9+gN1Owvkuh6DIZuy8V4jy7xN4bymULQ73VoM6 FyvYVXrg8rAbo8PD3ftsNbU1LztRfbk= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 06 Jul 2022 23:02:12 +0200 From: Michael Walle To: haibo.chen@nxp.com Cc: ashish.kumar@nxp.com, yogeshgaur.83@gmail.com, broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, han.xu@nxp.com, singh.kuldeep87k@gmail.com, tudor.ambarus@microchip.com, p.yadav@ti.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mtd@lists.infradead.org, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, zhengxunli@mxic.com.tw Subject: Re: [PATCH 04/11] spi: spi-nxp-fspi: add function to select sample clock source for flash reading In-Reply-To: <1657012303-6464-4-git-send-email-haibo.chen@nxp.com> References: <1657012303-6464-1-git-send-email-haibo.chen@nxp.com> <1657012303-6464-4-git-send-email-haibo.chen@nxp.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <7a66e4fe8f7224ea272d68276c7b138b@walle.cc> X-Sender: michael@walle.cc X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 2022-07-05 11:11, schrieb haibo.chen@nxp.com: > From: Haibo Chen > > fspi define four mode for sample clock source selection. > > Here is the list of modes: > mode 0: Dummy Read strobe generated by FlexSPI Controller and loopback > internally > mode 1: Dummy Read strobe generated by FlexSPI Controller and loopback > from DQS pad > mode 2: Reserved > mode 3: Flash provided Read strobe and input from DQS pad > > In default, fspi use mode 0 after reset. > For 8-8-8-DTR mode, need to use mode 3, otherwise 8-8-8-DTR read always > get incorrect data. > > Signed-off-by: Haibo Chen > --- > drivers/spi/spi-nxp-fspi.c | 47 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 47 insertions(+) > > diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c > index c32a4f53fa2a..34679dc0e1ad 100644 > --- a/drivers/spi/spi-nxp-fspi.c > +++ b/drivers/spi/spi-nxp-fspi.c > @@ -380,6 +380,7 @@ struct nxp_fspi { > struct pm_qos_request pm_qos_req; > int selected; > #define FSPI_INITILIZED (1 << 0) > +#define FSPI_RXCLKSRC_3 (1 << 1) > int flags; > }; > > @@ -877,6 +878,50 @@ static int nxp_fspi_do_op(struct nxp_fspi *f, > const struct spi_mem_op *op) > return err; > } > > +/* > + * Sample Clock source selection for Flash Reading > + * Four modes defined by fspi: > + * mode 0: Dummy Read strobe generated by FlexSPI Controller > + * and loopback internally > + * mode 1: Dummy Read strobe generated by FlexSPI Controller > + * and loopback from DQS pad > + * mode 2: Reserved > + * mode 3: Flash provided Read strobe and input from DQS pad > + * > + * fspi default use mode 0 after reset > + */ > +static void nxp_fspi_select_rx_sample_clk_source(struct nxp_fspi *f, > + const struct spi_mem_op *op) > +{ > + u32 reg; > + > + /* > + * For 8-8-8-DTR mode, need to use mode 3 (Flash provided Read > + * strobe and input from DQS pad), otherwise read operaton may > + * meet issue. > + * This mode require flash device connect the DQS pad on board. > + * For other modes, still use mode 0, keep align with before. > + * spi_nor_suspend will disable 8-8-8-DTR mode, also need to > + * change the mode back to mode 0. > + */ > + if (!(f->flags & FSPI_RXCLKSRC_3) && > + op->cmd.dtr && op->addr.dtr && > + op->dummy.dtr && op->data.dtr) { > + reg = fspi_readl(f, f->iobase + FSPI_MCR0); > + reg |= FSPI_MCR0_RXCLKSRC(3); > + fspi_writel(f, reg, f->iobase + FSPI_MCR0); > + f->flags |= FSPI_RXCLKSRC_3; > + } else if ((f->flags & FSPI_RXCLKSRC_3) && > + !op->cmd.dtr && !op->addr.dtr && > + !op->dummy.dtr && !op->data.dtr) { > + reg = fspi_readl(f, f->iobase + FSPI_MCR0); > + reg &= ~FSPI_MCR0_RXCLKSRC(3); /* select mode 0 */ > + fspi_writel(f, reg, f->iobase + FSPI_MCR0); > + f->flags &= ~FSPI_RXCLKSRC_3; > + } How is this supposed to work? Are you unconditionally enable flash provided read strobes if DTR is used? What if the flash doesn't provide one or the board haven't DQS connected? -michael