Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2956236imm; Fri, 24 Aug 2018 08:09:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYlLs78iN8V6pCJFkuVQsqtaB6cbLIsTsk6sXXnxV5gFbHB5uls8g7E0tPx3V1YYw3sI50q X-Received: by 2002:a17:902:9f86:: with SMTP id g6-v6mr2130004plq.304.1535123350948; Fri, 24 Aug 2018 08:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535123350; cv=none; d=google.com; s=arc-20160816; b=MDyZLFCkDpZpAkH/K/Pu1vH7QyfS9Cv1Y6W8+55svWxqEtI22070jE1JazwSeccWVr /v57Bf2MCcUVwAX9KcPwMH65K8bds/I5m8kWNAHsNEOxMWzxkOr+JVsZPuNzJy2a3Fl1 eAL9Y+yQhkYxawnqGRwtxicWd06C5QKY+9pHBc+qQ4K9QMw9xRXcIsOYjDmlMjyO310o X4dIfI6g5XPrkCP7JyJFUQbpqsD6lAxkC5bJ46rmsm6vZg7o+uVwnpq/EdMo+nshl6pS +BTzeRwou2FjvlpnnH9NhNeojif04wQCkH9WoUO2hpfHIVRkFck2KBnXJI4nsOG/OYPv /tlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=gkt/1N5O8V8LjvnpBf328//JAyXG2q1+a9l7NqjiFaU=; b=x+jsg/i1H/9FJFQz0kqqb7SE11e/EiBbwtY/L6Z/KV9qdClACgvIDUCr8kjfs1wlN3 FoolZVY/LACYwLeZLZSiEUa6xtpz+id26rtTXAyI6dSIly8/DMiEQ1uPUiFYRG7XJZxH jqbF3K+DS7x8BRgt/5cJM/JOedAHNHn5gFRLyE2R+hwbicjoqnsCg2pCvI/OnEgr0nXX JNcwzblsQTKRrF8uJrj5onefcfH/NU/ztMPhFgx5rVvIFKXRQHmxIytH03XCa7/gvzYe 3/u0cL0VIFiUJ/QtRxnMWm1HlZo+kFxQ8gR+MeFXlDEwaZUkacyLCGTPYq9INE3dQkpG b5Ug== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10-v6si6394837plr.86.2018.08.24.08.08.55; Fri, 24 Aug 2018 08:09:10 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728048AbeHXSmj (ORCPT + 99 others); Fri, 24 Aug 2018 14:42:39 -0400 Received: from smtprz14.163.net ([106.3.154.247]:61670 "EHLO smtp.tom.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726374AbeHXSmj (ORCPT ); Fri, 24 Aug 2018 14:42:39 -0400 Received: from antispam1.tom.com (unknown [172.25.16.55]) by freemail01.tom.com (Postfix) with ESMTP id 3E75D1C80DFB for ; Fri, 24 Aug 2018 22:41:46 +0800 (CST) Received: from antispam1.tom.com (antispam1.tom.com [127.0.0.1]) by antispam1.tom.com (Postfix) with ESMTP id 3813F10013B3 for ; Fri, 24 Aug 2018 22:41:46 +0800 (CST) X-Virus-Scanned: Debian amavisd-new at antispam1.tom.com Received: from antispam1.tom.com ([127.0.0.1]) by antispam1.tom.com (antispam1.tom.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Sd3S8B3zsEtD for ; Fri, 24 Aug 2018 22:41:45 +0800 (CST) Received: from localhost (unknown [222.209.17.121]) by antispam1.tom.com (Postfix) with ESMTPA id 7308410012D0; Fri, 24 Aug 2018 22:41:44 +0800 (CST) From: Liu Xiang To: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org, marek.vasut@gmail.com, dwmw2@infradead.org, computersforpeace@gmail.com, boris.brezillon@bootlin.com, richard@nod.at, liuxiang_1999@126.com, Liu Xiang Subject: [PATCH] mtd: spi-nor: Add 4-byte address support for is25lp256 Date: Fri, 24 Aug 2018 22:41:41 +0800 Message-Id: <1535121701-2925-1-git-send-email-liu.xiang6@zte.com.cn> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The is25lp256 supports 4-byte opcodes and quad output. In is25lp256, the DWORD1 of JEDEC Basic Flash Parameter Header is 0xfff920e5. So the DWORD1[18:17] Address Bytes bits are 0b00, means that 3-Byte only addressing. Now this limits nor->addr_width to 3 and makes it inpossible to access the address above 16MB. I think the size of flash is the most important judgement for nor->addr_width. Once the size is larger than 16MB, nor->addr_width must be 4. This can avoid the bad situation that manufacturer sets incorrect value of register. Signed-off-by: Liu Xiang --- drivers/mtd/spi-nor/spi-nor.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index d9c368c..0203b09 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1065,7 +1065,7 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) { "is25lp128", INFO(0x9d6018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ) }, { "is25lp256", INFO(0x9d6019, 0, 64 * 1024, 512, - SECT_4K | SPI_NOR_DUAL_READ) }, + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, { "is25wp032", INFO(0x9d7016, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "is25wp064", INFO(0x9d7017, 0, 64 * 1024, 128, @@ -2926,16 +2926,16 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, if (ret) return ret; - if (nor->addr_width) { - /* already configured from SFDP */ - } else if (info->addr_width) { - nor->addr_width = info->addr_width; - } else if (mtd->size > 0x1000000) { + if (mtd->size > 0x1000000) { /* enable 4-byte addressing if the device exceeds 16MiB */ nor->addr_width = 4; if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || - info->flags & SPI_NOR_4B_OPCODES) + info->flags & SPI_NOR_4B_OPCODES) spi_nor_set_4byte_opcodes(nor, info); + } else if (nor->addr_width) { + /* already configured from SFDP */ + } else if (info->addr_width) { + nor->addr_width = info->addr_width; } else { nor->addr_width = 3; } -- 1.9.1