Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2797734ybd; Mon, 24 Jun 2019 12:52:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNMGUv0YvQqYYaKUsKJM1hm/6vLMO6opfiPh7wvorXY2B5uXlvQWoTJ5ZwHLf9BKfz4/J1 X-Received: by 2002:a17:90a:2ec1:: with SMTP id h1mr26861747pjs.101.1561405966549; Mon, 24 Jun 2019 12:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561405966; cv=none; d=google.com; s=arc-20160816; b=vObgPBR4eeUcQ4VzczdvZ22p0kK/ih0h0HfDsZW3jQY3oCcOPJ7yXnre/6bc8fyXV5 ECXVEVW1VlehgGBtMJKn6QpJHx7rixiaNdlU91YW4FqpWNGYe+muqRi7i2GDLQFMZc29 1Bp0TY0tfcxKwviezohhTTWTPANUZD6723k+zDtY6DtwvAauxajdcNXF0hLWXXbv3+Et 9VYikAAPWa54Jt249ZnwKgySLmXCzC06+FheKOFfTLvJr43Zw240NF/Y9xqvY7bvYk6h LAdHIh4lL2NO6mz0mTkPRJqJHK1DK/90a4H1tgQL4Qt/7ya6RT5N4SJmkI3UmxmA2BJD JPHw== 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; bh=G3kDtxhvxld7VfKj7lgzhpd3F2ICD6tmjCONEByEIjA=; b=MMU9XeKiCy4GeAwLDqSWnWy3E0TMMnxZE9qepjRsJdLJNjoOStFY2lnKrOmJAsK6dv b4gRXDKpxQz6Fp/Qs+7CE7yU4CM3aZ6yYjLb4BaIeSR8RfJPLzrQrua2NJuvZt/VpzDV eXyKnFH2ZAtnxwE/bm0+Dis9x0gxHUlVizcff0x/0/wzbvSSonIqXpVSmZsH/wi9qRG1 DjmmyIsaChuUEvP7rXjmaXvcl9FVaN5puic5jD2BsncXKyxew3JxDQtqLZYn9vEMJvpU CQtPDXJtf8/9ChU66EL6NcvEOheeoEt8805lJdx5mPg60NVtbQHKH31N8FgiYLflF6Dk vRAA== 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 q23si383227pjp.63.2019.06.24.12.52.31; Mon, 24 Jun 2019 12:52:46 -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 S1729341AbfFXQBL (ORCPT + 99 others); Mon, 24 Jun 2019 12:01:11 -0400 Received: from smtprz15.163.net ([106.3.154.248]:9418 "EHLO smtp.tom.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726774AbfFXQBL (ORCPT ); Mon, 24 Jun 2019 12:01:11 -0400 Received: from my-app01.tom.com (my-app01.tom.com [127.0.0.1]) by freemail01.tom.com (Postfix) with ESMTP id 120301C819E4 for ; Tue, 25 Jun 2019 00:00:59 +0800 (CST) Received: from my-app01.tom.com (HELO smtp.tom.com) ([127.0.0.1]) by my-app01 (TOM SMTP Server) with SMTP ID -1293139326 for ; Tue, 25 Jun 2019 00:00:59 +0800 (CST) Received: from antispam1.tom.com (unknown [172.25.16.55]) by freemail01.tom.com (Postfix) with ESMTP id 059DC1C81A7C for ; Tue, 25 Jun 2019 00:00:59 +0800 (CST) Received: from antispam1.tom.com (antispam1.tom.com [127.0.0.1]) by antispam1.tom.com (Postfix) with ESMTP id 072BD1001982 for ; Tue, 25 Jun 2019 00:00:58 +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 vCMF3mqm9TeS for ; Tue, 25 Jun 2019 00:00:56 +0800 (CST) Received: from localhost (unknown [222.209.17.143]) by antispam1.tom.com (Postfix) with ESMTPA id 7BCBF100177F; Tue, 25 Jun 2019 00:00:55 +0800 (CST) From: Liu Xiang To: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org, tudor.ambarus@microchip.com, marek.vasut@gmail.com, dwmw2@infradead.org, computersforpeace@gmail.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, liuxiang_1999@126.com, Liu Xiang Subject: [PATCH v4] mtd: spi-nor: fix nor->addr_width when its value configured from SFDP does not match the actual width Date: Tue, 25 Jun 2019 00:00:46 +0800 Message-Id: <1561392046-10487-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 IS25LP256 gets BFPT_DWORD1_ADDRESS_BYTES_3_ONLY from BFPT table for address width. But in actual fact the flash can support 4-byte address. Use a post bfpt fixup hook to overwrite the address width advertised by the BFPT. Suggested-by: Tudor Ambarus Signed-off-by: Liu Xiang --- Changes in v4: update the comment suggested by Tudor. --- drivers/mtd/spi-nor/spi-nor.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 73172d7..ce153c4 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1687,6 +1687,28 @@ static int sr2_bit7_quad_enable(struct spi_nor *nor) .flags = SPI_NOR_NO_FR | SPI_S3AN, static int +is25lp256_post_bfpt_fixups(struct spi_nor *nor, + const struct sfdp_parameter_header *bfpt_header, + const struct sfdp_bfpt *bfpt, + struct spi_nor_flash_parameter *params) +{ + /* + * IS25LP256 supports 4B opcodes, but the BFPT advertises a + * BFPT_DWORD1_ADDRESS_BYTES_3_ONLY address width. + * Overwrite the address width advertised by the BFPT. + */ + if ((bfpt->dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) == + BFPT_DWORD1_ADDRESS_BYTES_3_ONLY) + nor->addr_width = 4; + + return 0; +} + +static struct spi_nor_fixups is25lp256_fixups = { + .post_bfpt = is25lp256_post_bfpt_fixups, +}; + +static int mx25l25635_post_bfpt_fixups(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt, @@ -1827,7 +1849,8 @@ static int sr2_bit7_quad_enable(struct spi_nor *nor) SECT_4K | SPI_NOR_DUAL_READ) }, { "is25lp256", INFO(0x9d6019, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | - SPI_NOR_4B_OPCODES) }, + SPI_NOR_4B_OPCODES) + .fixups = &is25lp256_fixups }, { "is25wp032", INFO(0x9d7016, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "is25wp064", INFO(0x9d7017, 0, 64 * 1024, 128, -- 1.9.1