Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12DA5C432BE for ; Mon, 30 Aug 2021 11:31:11 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F23336112D for ; Mon, 30 Aug 2021 11:31:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F23336112D Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 759CF82DB0; Mon, 30 Aug 2021 13:31:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="aQyQomP4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EE54983357; Mon, 30 Aug 2021 13:31:05 +0200 (CEST) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 55A4C82D5B for ; Mon, 30 Aug 2021 13:30:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=p.yadav@ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 17UBUsiv060428; Mon, 30 Aug 2021 06:30:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1630323054; bh=NMM4fCT+G1gY4q8gyXDLXn2PdQb+7oDCoEr1lwzeo8s=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=aQyQomP44wb5t7xpWS1jLTQscX0nsOk0Ech+8cmRCy9C8pniaxxVOpw7iOH+lEbGD AEU61xpuBNR+eAOutXr0p7zx8il9bos3zIHLp702AgSfIdK71gneaHuumiJh3fTViX CTfph7LEbiXafNgnVWco8/dO0H/5wKD1ARhAuKII= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 17UBUs2m123212 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 30 Aug 2021 06:30:54 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Mon, 30 Aug 2021 06:30:54 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Mon, 30 Aug 2021 06:30:54 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 17UBUrRI066632; Mon, 30 Aug 2021 06:30:54 -0500 Date: Mon, 30 Aug 2021 17:00:53 +0530 From: Pratyush Yadav To: JaimeLiao CC: , , , , , Subject: Re: [PATCH v2 2/4] mtd: spi-nor-core: Adding different type of command extension in Soft Reset Message-ID: <20210830113050.ivvz73t3fuevyhmh@ti.com> References: <20210820065839.10525-1-jaimeliao.tw@gmail.com> <20210820065839.10525-3-jaimeliao.tw@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210820065839.10525-3-jaimeliao.tw@gmail.com> User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi, On 20/08/21 02:58PM, JaimeLiao wrote: > Power-on-Reset is a method to restore flash back to 1S-1S-1S mode from 8D-8D-8D > in the begging of probe. > > Command extension type is not standardized across flash vendors in DTR mode. > > For suiting different vendor flash devices, having second times Softreset with > different types is clumsy but useful in the begging of probe. Yes, it is indeed clumsy, and I am not convinced this is the right way to go. Firstly, you issue the reset twice. This is obviously not ideal and you have to hope the command with incorrect extension is ignored, and not interpreted as something different. But more importantly, you also do the same when called via spi_nor_remove(). At that point you have parsed SFDP and know the flash we are dealing with so you should already know which extension to use. So here is my suggestion: create a separate function, something like spi_nor_early_soft_reset(). In that function check a config variable to decide which extension to use and temporarily set nor->cmd_ext_type to that. Then in spi_nor_soft_reset() just use nor->cmd_ext_type, no need to hard code the extension. This way you will certainly use the correct extension at remove and will have a more accurate guess at probe time. I admit this isn't the cleanest solution, but this is the best I can come up with right now. > > Signed-off-by: JaimeLiao > --- > drivers/mtd/spi/spi-nor-core.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c > index 351ca9c3a8..707eb9c1d2 100644 > --- a/drivers/mtd/spi/spi-nor-core.c > +++ b/drivers/mtd/spi/spi-nor-core.c > @@ -3692,6 +3692,36 @@ static int spi_nor_soft_reset(struct spi_nor *nor) > */ > udelay(SPI_NOR_SRST_SLEEP_LEN); > > + /* Manufacturers with different command extension type. For suitting > + * different flash devices, using command extension type is equal "INVERT" > + * when second time Software Reset. > + */ > + > + nor->cmd_ext_type = SPI_NOR_EXT_INVERT; > + op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRSTEN, 0), > + SPI_MEM_OP_NO_DUMMY, > + SPI_MEM_OP_NO_ADDR, > + SPI_MEM_OP_NO_DATA); > + spi_nor_setup_op(nor, &op, SNOR_PROTO_8_8_8_DTR); > + ret = spi_mem_exec_op(nor->spi, &op); > + if (ret) { > + dev_warn(nor->dev, "Software reset enable failed: %d\n", ret); > + goto out; > + } > + > + op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRST, 0), > + SPI_MEM_OP_NO_DUMMY, > + SPI_MEM_OP_NO_ADDR, > + SPI_MEM_OP_NO_DATA); > + spi_nor_setup_op(nor, &op, SNOR_PROTO_8_8_8_DTR); > + ret = spi_mem_exec_op(nor->spi, &op); > + if (ret) { > + dev_warn(nor->dev, "Software reset failed: %d\n", ret); > + goto out; > + } > + > + udelay(SPI_NOR_SRST_SLEEP_LEN); > + > out: > nor->cmd_ext_type = ext; > return ret; > -- > 2.17.1 > -- Regards, Pratyush Yadav Texas Instruments Inc.