Received: by 10.213.65.68 with SMTP id h4csp1743394imn; Sun, 8 Apr 2018 10:24:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+ipv77PfJvzHfGvaJr1A0krD/Pl3nS2A4zrC08Mlkhv9k3nQr6KYiz0No+5QnqPMEi7AvA X-Received: by 2002:a17:902:848c:: with SMTP id c12-v6mr14061709plo.316.1523208248321; Sun, 08 Apr 2018 10:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523208248; cv=none; d=google.com; s=arc-20160816; b=aZtlZxZjjstJEWgjJ/IAd1bUyN8E23Gizg3oOumEmte6fl0yByFPNPAXaIJH+ni/Fb emAEsJ4n6MYyUkXWj77glVbTzEz6a0iCT4mR2QYwOvVdrtgiU63b65x8ooEJaS08i80n WcuPe6eJG51RLg54RxibDw1Lgps6e0pQIndc2JrvlrauXXhZ3WwJZHXmAdwOXo17UisC 4a7smObHfp31hGUgBNaBFaeRXnYEZ+60wtcDR9uuPa0Y+9rstwm5XoZVFAIHfRwi8OnV bu27sTkCPkSUNSgZK+tbeQD6w9Zdpt/FeKQleC997wd2HZ/zxB4Mk0YtNzuzNmcu1CKp GHNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Cwm7F88zqXDFLBzm9sWfpP19JxtAMC7RPYlrRpvmUQE=; b=kaG/5Z73LsOtQpPYfHTZKZVhz00AYzFa6RWTsuTRAONu8PB0py4w9Ukc3KUXdo9PXW c7BQGs+WOz9NkI2jhFznxrw7RTJ2luJpW0H58slNjOr6fZDNA26GgmVyL6NKdrqS3Hl0 6wU69jYa1D/pJ/2l0Zj6+V3e/eluZUP1w5D8EWIbqYLqgVbiFlBYCUnCDlSImhYFySfO pgOCpPMNbmP1/zUVZE3Y+WMa7y8dMiHJBvFmhiz7PHcviYkCneGCp0kJMvSqHPm2naas o+wuuTywGnedeXu4HEi+Yvm2iniEKd3C5H3XlgT2Slyw15ESzBVT2BO025U1OKGl277n p+KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QGSVbddC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k17si10014170pgf.534.2018.04.08.10.23.31; Sun, 08 Apr 2018 10:24:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QGSVbddC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752652AbeDHQmN (ORCPT + 99 others); Sun, 8 Apr 2018 12:42:13 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:47031 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752596AbeDHQmL (ORCPT ); Sun, 8 Apr 2018 12:42:11 -0400 Received: by mail-wr0-f196.google.com with SMTP id d1so6164322wrj.13 for ; Sun, 08 Apr 2018 09:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Cwm7F88zqXDFLBzm9sWfpP19JxtAMC7RPYlrRpvmUQE=; b=QGSVbddCKcWqNggC1sCgll3Ia4l9H6PNAV7sT9XqZrk6FeBK0gXDoumCJF0rBeZbkD LkvK+xtixLrxGub66cpvPS4JXJUHjsMHNEZhQb7z+KSU4cvSu/NkNE8wY3/yLVcP8Y8+ j+m31d5DzJFEKKvLC8lWdaZE2w0BMxZFDX5Sq0WBCbJUtNKClXNSrptOLaQd74uSxgiB Aj55VE7/Ie2HWruhzmSxBgZgJZDlbMjTL5cdcB2yaaktVX4y1ZFGsQousDghTSO9c8S1 EnS+U8ybTREuey+9c0MDoTggtVK/sdSrcl3MHEU68WntR1BVuiVHNWafunPa7B6X9oHQ zmUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Cwm7F88zqXDFLBzm9sWfpP19JxtAMC7RPYlrRpvmUQE=; b=gI7EpylcQzEM1JHPUp++IXLBLcOwEbfD9m05MFUqBkM4oJb50gXRXEqsHxsN3a6MRh 6xlW875CH5onYVB+pObAyXVDSCAPZaSQbohilObC4raHEEKpLmkp2+hMpvVlWzAMlvAB g8uex5nUKe8jm04tILRNPgzPcqTDenE27r/7ek4eVGn8nDFMc5oMXh3PUV+zyIcPHZvn vdLCrtyt2m52KDCAvYFgdFXS6GqlCS8IhBjh+/SfLkeGXryVq/5J/eIJbsBP4NqCCY5F olrSt41xCKaYJk2fhaT/BiQzDpk7gwiwaIbY3bvpYCGiJrARxBOQ0VdRjVmbga6ZW3vh FGuw== X-Gm-Message-State: AElRT7E+JnianK6oJ7KwvRC+BbaJTtzSe1YHK96WlBCWNmciG+jbfCrO fzUm/ty1N3B+wbIMxZ7cppmrER3n X-Received: by 10.223.178.163 with SMTP id g32mr25346869wrd.204.1523205729555; Sun, 08 Apr 2018 09:42:09 -0700 (PDT) Received: from [192.168.1.4] (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id r19sm26938373wmd.32.2018.04.08.09.42.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Apr 2018 09:42:09 -0700 (PDT) Subject: Re: [PATCH] mtd: spi-nor: clear Extended Address Reg on switch to 3-byte addressing. To: NeilBrown , Cyrille Pitchen Cc: David Woodhouse , Brian Norris , Boris Brezillon , Richard Weinberger , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org References: <874lkmw54j.fsf@notabene.neil.brown.name> From: Marek Vasut Message-ID: <61e255fa-ece4-5566-d63a-730aaa25f18c@gmail.com> Date: Sun, 8 Apr 2018 12:53:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <874lkmw54j.fsf@notabene.neil.brown.name> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/08/2018 09:04 AM, NeilBrown wrote: > > According to section > 8.2.7 Write Extended Address Register (C5h) > > of the Winbond W25Q256FV data sheet (256M-BIT SPI flash) > > The Extended Address Register is only effective when the device is > in the 3-Byte Address Mode. When the device operates in the 4-Byte > Address Mode (ADS=1), any command with address input of A31-A24 > will replace the Extended Address Register values. It is > recommended to check and update the Extended Address Register if > necessary when the device is switched from 4-Byte to 3-Byte Address > Mode. > > This patch adds code to implement that recommendation. Without this, > my GNUBEE-PC1 will not successfully reboot, as the Extended Address > Register is left with a value of '1'. When the SOC attempts to read > (in 3-byte address mode) the boot loader, it reads from the wrong > location. Your board is broken by design and does not implement proper reset logic for the SPI NOR chip, right ? That is, when the CPU resets, the SPI NOR is left in some random undefined state instead of being reset too, yes? Doesn't this chip support 4-byte addressing opcodes ? If so, we should use those and keep the chip in 3-byte addressing mode. Would that work? > Signed-off-by: NeilBrown > --- > drivers/mtd/spi-nor/spi-nor.c | 10 ++++++++++ > include/linux/mtd/spi-nor.h | 2 ++ > 2 files changed, 12 insertions(+) > > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c > index d445a4d3b770..c303bf0d2982 100644 > --- a/drivers/mtd/spi-nor/spi-nor.c > +++ b/drivers/mtd/spi-nor/spi-nor.c > @@ -269,6 +269,7 @@ static inline int set_4byte(struct spi_nor *nor, const struct flash_info *info, > int status; > bool need_wren = false; > u8 cmd; > + u8 val; > > switch (JEDEC_MFR(info)) { > case SNOR_MFR_MICRON: > @@ -283,6 +284,15 @@ static inline int set_4byte(struct spi_nor *nor, const struct flash_info *info, > status = nor->write_reg(nor, cmd, NULL, 0); > if (need_wren) > write_disable(nor); > + if (!status && !enable && > + nor->read_reg(nor, SPINOR_OP_RDXA, &val, 1) == 0 && > + val != 0) { > + /* need to reset the Extended Address Register */ > + write_enable(nor); > + val = 0; > + nor->write_reg(nor, SPINOR_OP_WRXA, &val, 1); > + write_disable(nor); > + } > > return status; > default: > diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h > index de36969eb359..42954419cfdf 100644 > --- a/include/linux/mtd/spi-nor.h > +++ b/include/linux/mtd/spi-nor.h > @@ -62,6 +62,8 @@ > #define SPINOR_OP_RDCR 0x35 /* Read configuration register */ > #define SPINOR_OP_RDFSR 0x70 /* Read flag status register */ > #define SPINOR_OP_CLFSR 0x50 /* Clear flag status register */ > +#define SPINOR_OP_RDXA 0xc8 /* Read Extended Address Register */ > +#define SPINOR_OP_WRXA 0xc5 /* Write Extended Address Register */ > > /* 4-byte address opcodes - used on Spansion and some Macronix flashes. */ > #define SPINOR_OP_READ_4B 0x13 /* Read data bytes (low frequency) */ > -- Best regards, Marek Vasut