Received: by 10.192.165.156 with SMTP id m28csp63832imm; Tue, 10 Apr 2018 16:28:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/JFStxyRkGxs5T587rmq9bh2IdnSMbtCrd5WpZYQ8hr1tbaXB1qfQ76pS0ovVXKcY8Fnii X-Received: by 2002:a17:902:2862:: with SMTP id e89-v6mr2450542plb.348.1523402934769; Tue, 10 Apr 2018 16:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523402934; cv=none; d=google.com; s=arc-20160816; b=RlEFcCTRh2505O+/Yawv4bMdUtmC7rqCs9dGs66ep57b75q6SZX4gXd2KG/dqfFiAe QHtSg+hKzeWIv0ftMM07O3O7uGXphutCOVApe/ahzfP4z2UWK0wLraHUAaWEnf/bzuvz 4gBg64tLhsm4SVZbzlUE19g1+lXXTHLAaaFbMi+EAQHA7putKW4QuL4IGIowXH/A0QLj DyLH5TH5b02P6rNhwPbkqSJIL6AxNT2dwuvRp5+BEiUL0qI5a4LvgxbXafq4v3COvAtK zgK/VVV/tWa7FF36WhS9PTf2nVgjtj4Gv7ObKqULmrn2OdtaRTXc+WFs1yygdlQDgtGG VYXQ== 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=3gM6SF0CAgA1LqEWublhAJnTfFIw9nw0mOAJNTnU+wk=; b=e5D8vkcEXfXcNUjXI2hAPxuwH9GZCxd0YWYY1tNN7O3bd3XaG7hdAST6kDEut3Qgwf sGGi1CJ48T7me/Mr1ZqBrODX21bK2sHJYrb4n33AkrJGMBFMmJbyVvNmoqYjmSg25M6f M/758UB3RCf6z6C09Pz3P9u486bqdYmR9qPGJNAjc/Z9BDMaqJDt89pY9lsfN3KQosif kXLRYYiSH6H6rRI0eKcXYE38olOfKiCwtgmoSxOMnVI4n64UGyeppcWzJ+HoEvjxEDP0 uKoESU4rgpk4WneWPL6eVniQDA34xLXn3hLKSv5bPpJ92+9cUYwEqnkGS7fLS7ftb+8F iXOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JepLKVDB; 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 q26si2492460pgd.280.2018.04.10.16.28.18; Tue, 10 Apr 2018 16:28:54 -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=JepLKVDB; 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 S1754584AbeDJXXL (ORCPT + 99 others); Tue, 10 Apr 2018 19:23:11 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:53049 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755117AbeDJXXF (ORCPT ); Tue, 10 Apr 2018 19:23:05 -0400 Received: by mail-wm0-f65.google.com with SMTP id g8so492409wmd.2 for ; Tue, 10 Apr 2018 16:23:05 -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=3gM6SF0CAgA1LqEWublhAJnTfFIw9nw0mOAJNTnU+wk=; b=JepLKVDB8bZnaDxErCfA4p3nA3q1lBLpExjboff1VBdWAKa/0mvspfhgytjQp+efJX o+nCMWVVga/kXObWmpi7/n1m8PhbKuf3fsuKvGW2L9Zo3DEbmrQIM/qdMdGzv9pwI+Gr RxpizJCOVU7oPG+0z3P6LAO7PycfSMUefbLJq5IHD5AO2LDjuFUgWlamf3yUe2VV8sG6 /mnyNPC3IjpvqC35W11oJ+KeyzY0a2mzLwXWS+5RgZlEmw91RNM88g6ZNVEkWfcU0GRd RW9ajxfI92GUdagAc1YIP03XP8xSozYoWU8JcDjwakurjAB/c2+0Vno9PR+AX4kKfC1w jbhQ== 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=3gM6SF0CAgA1LqEWublhAJnTfFIw9nw0mOAJNTnU+wk=; b=a0Z+b2fbnJBjd4iFtn3lYcqIe69ZLY2niH/iGoIvqnCWKr8oGKNZHA0bEybqTld446 E1QTKYV4zxBPXdGnDEEsH4ktoisD8LhpaqeFo6t3cfQSyMkU0O446cvqpz6yhuiqhWJ4 tUAZzTbRVj4G0zUaUEyx3t184fH0jp50CZM1cezJQC/H22v8TmewGZ7qrzOd16mO8Fmn 4W8vdjSQ9csmvaCSMXpUUuMFtLsS9fASE0M2RU5gQGV95aALzYBn77gru4RzxXvJFroC /YRBmu1e72wj+lnYLmu/R3rHcrjWzzNexGmkgHcBsg9PvP+ftAIffM72xjWYBkp30G7T Kltw== X-Gm-Message-State: ALQs6tDMVKbehW+GW9aSHb59qY/yEaOUQgR1vzDFYEkUlcVR2NCWJ4Tw K476rmXQFTBBiukGIuJFnZv6lun9 X-Received: by 10.28.153.12 with SMTP id b12mr941464wme.104.1523402584144; Tue, 10 Apr 2018 16:23:04 -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 t76sm33621wme.17.2018.04.10.16.23.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 16:23:03 -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: Date: Wed, 11 Apr 2018 01:13:40 +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: 8bit 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. > > 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 && I think this should be made winbond-specific, macronix flashes do not suffer from this I think. Otherwise looks good. > + 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