Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1323024ybh; Thu, 23 Jul 2020 06:13:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxB1lvsSmQ+9350el7trYAs2nlNV1TxjRnMSVCurANfsPFaq1vPNSSbshlcMM7TyqBHP52N X-Received: by 2002:a17:906:c04d:: with SMTP id bm13mr4211356ejb.321.1595510009461; Thu, 23 Jul 2020 06:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595510009; cv=none; d=google.com; s=arc-20160816; b=ZMMraByBO4NJJ36VM/8mme8dqOF9igYqq0kd0/ffoOvGzUVb48CRXFlizaiFDZLxHV ZAAfhyTuVauqbXTsP0wSKgwWRhGMRJf5AsQSpmvywGMxfJaf1F3qC+ylYKsz092CZhya 0XtPHMEbyVAfv/MgwudRHEfcbaFeKFMEQL6Da1hA4p/MQwx075mO82VOqOclB8OMM6B7 gkRpwjXoLzs5Ij9hKHhvDV0ar6fXLapsba7W9sg6bBip1qwyifcIQ31xhsA+EMZsGzRA H3swOkIZPnRPuJXkybs2uicDdPZmsBuG7o0czz7dfqCd1gegVzmFyeWFcAJYqbFoTj6Q p9qQ== 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; bh=VLaO0fUy/HwWe4isHn/x5/it5oTp6RIF8AjzZaH1RcI=; b=eD1lu0bhuSrxCr+/B7nhxGF09NzO+ou4M0dbdBPWmNtPKUKSITysBJO7FkBN3f2SBH S6ytZeGrXnBzwxaiz1J1SoPmRnrVOOmHsmf5D7XB2uILxi0RcIuKLRNwzlGfv1vLR2X3 oA1MTxYoF7+PN4TqHfxeYmjW/JUX793KChQsDAKkg/pGoL292SvQcj06pRNWl+pcwciv KasOfuVx/rFfXNAj0d0i2w9twPIjrYJzUkQUCZt7Su+S46wsKqv3Ak/7LpLr0wwDbqnB AfCwGhB3iioF34Qp3za2g+lgBi0CFCVSYOBx0j8x5x1X3K96+syC46Okm8ufAXBGdrYq a50A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g21si1938812ejr.275.2020.07.23.06.13.07; Thu, 23 Jul 2020 06:13:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbgGWNMp (ORCPT + 99 others); Thu, 23 Jul 2020 09:12:45 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:45001 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbgGWNMo (ORCPT ); Thu, 23 Jul 2020 09:12:44 -0400 X-Originating-IP: 42.109.196.68 Received: from localhost.localdomain (unknown [42.109.196.68]) (Authenticated sender: me@yadavpratyush.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 002B01C0002; Thu, 23 Jul 2020 13:12:38 +0000 (UTC) From: Pratyush Yadav To: Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sekhar Nori , Boris Brezillon , Pratyush Yadav , Pratyush Yadav Subject: [PATCH v11 04/14] mtd: spi-nor: sfdp: get command opcode extension type from BFPT Date: Thu, 23 Jul 2020 18:41:53 +0530 Message-Id: <20200723131203.40916-5-me@yadavpratyush.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723131203.40916-1-me@yadavpratyush.com> References: <20200723131203.40916-1-me@yadavpratyush.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pratyush Yadav Some devices in DTR mode expect an extra command byte called the extension. The extension can either be same as the opcode, bitwise inverse of the opcode, or another additional byte forming a 16-byte opcode. Get the extension type from the BFPT. For now, only flashes with "repeat" and "inverse" extensions are supported. Signed-off-by: Pratyush Yadav --- drivers/mtd/spi-nor/sfdp.c | 18 ++++++++++++++++++ drivers/mtd/spi-nor/sfdp.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index 21fa9ab78eae..cd8ada3de8fd 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -606,6 +606,24 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B) return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params); + /* 8D-8D-8D command extension. */ + switch (bfpt.dwords[BFPT_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) { + case BFPT_DWORD18_CMD_EXT_REP: + nor->cmd_ext_type = SPI_NOR_EXT_REPEAT; + break; + + case BFPT_DWORD18_CMD_EXT_INV: + nor->cmd_ext_type = SPI_NOR_EXT_INVERT; + break; + + case BFPT_DWORD18_CMD_EXT_RES: + dev_dbg(nor->dev, "Reserved command extension used\n"); + break; + + case BFPT_DWORD18_CMD_EXT_16B: + dev_dbg(nor->dev, "16-bit opcodes not supported\n"); + return -ENOTSUPP; + } 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 7f9846b3a1ad..6d7243067252 100644 --- a/drivers/mtd/spi-nor/sfdp.h +++ b/drivers/mtd/spi-nor/sfdp.h @@ -90,6 +90,12 @@ struct sfdp_bfpt { #define BFPT_DWORD15_QER_SR2_BIT1_NO_RD (0x4UL << 20) #define BFPT_DWORD15_QER_SR2_BIT1 (0x5UL << 20) /* Spansion */ +#define BFPT_DWORD18_CMD_EXT_MASK GENMASK(30, 29) +#define BFPT_DWORD18_CMD_EXT_REP (0x0UL << 29) /* Repeat */ +#define BFPT_DWORD18_CMD_EXT_INV (0x1UL << 29) /* Invert */ +#define BFPT_DWORD18_CMD_EXT_RES (0x2UL << 29) /* Reserved */ +#define BFPT_DWORD18_CMD_EXT_16B (0x3UL << 29) /* 16-bit opcode */ + struct sfdp_parameter_header { u8 id_lsb; u8 minor; -- 2.27.0