Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp59259ybz; Fri, 24 Apr 2020 11:46:59 -0700 (PDT) X-Google-Smtp-Source: APiQypKIuOVHPa1Jg518/OZU7jsz7qSuwKR/LiNu5SmBnbU9f+fE11+jF+1B09bQl4Krnv1vj+VK X-Received: by 2002:a17:906:b896:: with SMTP id hb22mr8249560ejb.209.1587754019739; Fri, 24 Apr 2020 11:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587754019; cv=none; d=google.com; s=arc-20160816; b=OC9MfC/bwICaS4odGF2zWg1DaANN8q8iiuXVWCiK8K17oqEhklLZXoxnTURlJVf60g ZITOWznE6UVCCmN4YLymQdxwJWEQPRbCtwLPsHnh7TKmh3/92uf86ghlzKwTxtD2ykze uwkZVOvxAVTCin2L3Zcm902Kq0bEuKaBPR7cKPVt/ond/2RiCOQvJ8dTLNBt4OFmb+Au EDPds7V9So3qDeFjGlVErANBnHCyeV8lOct7EruXex2BAyFJPLZ1X5W11spnFbXk44Az QLMc0QP2lfcsMObkMP39w4r51v0yIvQmyqLFH8ilxIknIsaVZx+UqMoR2jUMWG7t0j0/ btwg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hMQJXwBW1L1FYtD6IUOgGbGojLN8nkxZ+9MYbECea5o=; b=u6RYZx4I2bN83ZSk+iUXuDqyYzAgZVpT4L8AudpIhZ5KZx27nLsrgk4ng863NFKJem Sas97r2h2lJWj/pdr+to79A1BGtCN1nIj6eaCzhGHM6FXjqeq4gBv+fV4ZRO4KXXPdxR eAOOmpTZZw+JWOMKNsFZdsLd5+XliN4CZGfhoIoMpcI7p0ofTKesCmMuD16UmhfuokVt keLiGZJIBW63XPGMZQkfJblIGfmSe26DH69yD0cgfZyaA/qYlkv09dXjAcxX6a9oX574 6eC+azlThvYfrKxz8gWfQXgJmZOTRgcVp3IC/5x6vaez0EePTzbinOcSuwV3Esl5IW1Z oZcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xMZSeSu1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q24si3539108ejz.458.2020.04.24.11.46.36; Fri, 24 Apr 2020 11:46:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xMZSeSu1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729226AbgDXSox (ORCPT + 99 others); Fri, 24 Apr 2020 14:44:53 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:57206 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729220AbgDXSou (ORCPT ); Fri, 24 Apr 2020 14:44:50 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03OIidXG087305; Fri, 24 Apr 2020 13:44:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587753879; bh=hMQJXwBW1L1FYtD6IUOgGbGojLN8nkxZ+9MYbECea5o=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xMZSeSu1JcTFxq7B8l443TEXiaDYI5AcecCvlPAsUF7l+ipnASmARQO0Yhwbhq+6w 8q07WnRYskPgUJ7FpaAO/5FAufzGISynK+TGCQsHQ03wEzgoaMfG1Gvw+ApGcVwyds BV0eOzqDF293VfADLQDF4BpCD124tHf/zZJwgZn4= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03OIidLc085520; Fri, 24 Apr 2020 13:44:39 -0500 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 24 Apr 2020 13:44:39 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Fri, 24 Apr 2020 13:44:39 -0500 Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03OIiAaC047967; Fri, 24 Apr 2020 13:44:35 -0500 From: Pratyush Yadav To: Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mark Brown , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , , , , CC: Pratyush Yadav , Sekhar Nori Subject: [PATCH v4 06/16] mtd: spi-nor: prepare BFPT parsing for JESD216 rev D Date: Sat, 25 Apr 2020 00:14:00 +0530 Message-ID: <20200424184410.8578-7-p.yadav@ti.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200424184410.8578-1-p.yadav@ti.com> References: <20200424184410.8578-1-p.yadav@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org JESD216 rev D makes BFPT 20 DWORDs. Update the BFPT size define to reflect that. The check for rev A or later compared the BFPT header length with the maximum BFPT length, BFPT_DWORD_MAX. Since BFPT_DWORD_MAX was 16, and so was the BFPT length for both rev A and B, this check worked fine. But now, since BFPT_DWORD_MAX is 20, it means this check will also stop BFPT parsing for rev A or B, since their length is 16. So, instead check for BFPT_DWORD_MAX_JESD216 to stop BFPT parsing for the first JESD216 version, and check for BFPT_DWORD_MAX_JESD216B for the next two versions. Signed-off-by: Pratyush Yadav --- drivers/mtd/spi-nor/sfdp.c | 7 ++++++- drivers/mtd/spi-nor/sfdp.h | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index 5cecc4ba2141..96960f2f3d7a 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -549,7 +549,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, SNOR_ERASE_TYPE_MASK; /* Stop here if not JESD216 rev A or later. */ - if (bfpt_header->length < BFPT_DWORD_MAX) + if (bfpt_header->length == BFPT_DWORD_MAX_JESD216) return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params); @@ -605,6 +605,11 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, return -EINVAL; } + /* Stop here if JESD216 rev B. */ + if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B) + return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, + params); + return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params); } diff --git a/drivers/mtd/spi-nor/sfdp.h b/drivers/mtd/spi-nor/sfdp.h index e0a8ded04890..f8198af43a63 100644 --- a/drivers/mtd/spi-nor/sfdp.h +++ b/drivers/mtd/spi-nor/sfdp.h @@ -10,11 +10,11 @@ /* Basic Flash Parameter Table */ /* - * JESD216 rev B defines a Basic Flash Parameter Table of 16 DWORDs. + * JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs. * They are indexed from 1 but C arrays are indexed from 0. */ #define BFPT_DWORD(i) ((i) - 1) -#define BFPT_DWORD_MAX 16 +#define BFPT_DWORD_MAX 20 struct sfdp_bfpt { u32 dwords[BFPT_DWORD_MAX]; @@ -22,6 +22,7 @@ struct sfdp_bfpt { /* The first version of JESD216 defined only 9 DWORDs. */ #define BFPT_DWORD_MAX_JESD216 9 +#define BFPT_DWORD_MAX_JESD216B 16 /* 1st DWORD. */ #define BFPT_DWORD1_FAST_READ_1_1_2 BIT(16) -- 2.25.0