From patchwork Fri Aug 20 06:58:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liao jaime X-Patchwork-Id: 1519037 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=PRh+mzff; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GrhMn2nX6z9sWd for ; Fri, 20 Aug 2021 22:51:16 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DC3582DF7; Fri, 20 Aug 2021 14:50:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PRh+mzff"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 10AFE81EBD; Fri, 20 Aug 2021 08:59:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A610382C65 for ; Fri, 20 Aug 2021 08:58:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jaimeliao.tw@gmail.com Received: by mail-pg1-x52f.google.com with SMTP id k14so8231655pga.13 for ; Thu, 19 Aug 2021 23:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T0StYhYWY6LWjuULuD3Txug5SbouEqVjXGl1ZNXKFPc=; b=PRh+mzff01Tqco4wShVDMmL7OMm4gqchbUaPQ0Yq7ZszsSNOQpuXX35RQ/33RPkUkJ vmOAsqOS71e/lfbLIye1trJUvQP857DhP7zspTefisu9PZM2h2zfCjo0CKxheryy9kaX 9eqySZXpwyjXbUc5b3iNYcnRT6sPk9hHoQXhz7zsQx2ZjvGruX/szMMsVHWkV+3hCDnl NrD5C7qaKGOgyoswlodUhfpebXSbhDxSbAEGkz93Zp5raOiL8D954QmIKdN/Eq5vj8Rr WHb0NTFSeZnyJLoTlX8dhNfWLAwG5LVW7p9YoShD7W7vLBW2sZHcxyr9TtXXnbD1aw9A aI/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T0StYhYWY6LWjuULuD3Txug5SbouEqVjXGl1ZNXKFPc=; b=EY6l0dyRTFr7Ldot3WkVUqErN0Dmg2nOVcH2HxLm77nfxw9qnz27LAg7lulfa7v149 lCcbtE97MSaj+8GZLXgyrfIRKZ4mz9bgs2EWW5bos1o3gUI9UTgkcEiLabv8xGHRHzK+ STjWJQpec7zwoHjJ/uZ1ZBkpt/8MOp7tKMX7IKBCRC5iLbYIErSNIdfVviJ8WhPt/hEm q98GJM3vNJ7o7poo6WpqPAkuIMFESsxKhM76tTseaBmBcl5nW/HOSvLxfNl8rGJKdthA hTgt7bsoZzLjVI/3qSxy56unQSI3erGD7vKslBWirQez3vukQ99xv8ESxfibZj8H4ORI Nleg== X-Gm-Message-State: AOAM530H/+Bp4d+M+znWRoipgOrNVa11PHeNww1kmGeiMbuIhp6dt12g k+PjO2afqLgGsO6YLIg8dmWwBKg0v2M= X-Google-Smtp-Source: ABdhPJwT+6zEYCzwtb3WXjy4AQ+xC9Ko8ZpV8VbiuuGQKSYyFGMETlVXJCM5dTM8TsD0fhR8kAJBrg== X-Received: by 2002:a63:d0d:: with SMTP id c13mr17278398pgl.294.1629442737752; Thu, 19 Aug 2021 23:58:57 -0700 (PDT) Received: from localhost.localdomain ([123.51.145.88]) by smtp.gmail.com with ESMTPSA id b12sm5803984pff.63.2021.08.19.23.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 23:58:57 -0700 (PDT) From: JaimeLiao To: u-boot@lists.denx.de, jagan@amarulasolutions.com, vigneshr@ti.com, p.yadav@ti.com Cc: zhengxunli@mxic.com.tw, ycllin@mxic.com.tw, jaimeliao@mxic.com.tw, JaimeLiao Subject: [PATCH v2 2/4] mtd: spi-nor-core: Adding different type of command extension in Soft Reset Date: Fri, 20 Aug 2021 14:58:37 +0800 Message-Id: <20210820065839.10525-3-jaimeliao.tw@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210820065839.10525-1-jaimeliao.tw@gmail.com> References: <20210820065839.10525-1-jaimeliao.tw@gmail.com> X-Mailman-Approved-At: Fri, 20 Aug 2021 14:50:39 +0200 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 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. 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;