Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp229032ybm; Thu, 28 May 2020 01:01:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGA6ms3gDSf8H9HN6Kmr315Y1YJnjv7TrGDOx+3hYGYsIAmHDylUWJwK6Yhg/srNPus6Yg X-Received: by 2002:a50:fa8d:: with SMTP id w13mr1709992edr.280.1590652888365; Thu, 28 May 2020 01:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590652888; cv=none; d=google.com; s=arc-20160816; b=wybhc2VseORA6N3zg5vJ8P5km05RGeDeLOwOXsFjCh7tXMvi5YLT4f/BcaikcaBWFi laePpEvc4AJl/5lYmcmgkZLZrJ4QYm0rNSysTDtefCpqsITbRvWZjX0LiiDJPHQw/T6e NTePuOmmiMenGwVmHJ+hlEfkuzzDxBYlZBj0GuhJJkSzJ4NeJBDxostsMaZ+3I/Qa96r ZQdHR4F5FCC6F9LA8kszTx5n5LNilTXBXe+wcx6jCB5XOcJz6Vo8WTYucqGEOgCJ96Uw +3waeazxw5IF1OOeZav9dzH0glTja4/NkxLu/rOk+nFvCCBDpZUdFVfs2OxYNNYmRYeq 4ceg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=99HgchUfDy9AuRXmORoTmCoIvTAQpA2WEy+jkWDSbD8=; b=hY44/y0azsyib+3n0wlHcwE4TZo2Lf9lZh1ja/oh2CnYMzdQZMVf1BCMoferKv0W9Y xS5z0zE7yNe4vLB+KrasjOCmUlGEldnNy2BpHa1iAJyW2nq0vnuJuY+o+DIgM4Myjnbc NG6NqP541QD/iBLJhiAATzvd0ifC3zeei72I4BW/rCOdBAw3dZcYX0rgukRHQIdglc81 ejwJ6D/XVvxCQCZbpTQyelKB/Rv6kRbZnbjdeJa9vUlegJPdGBkoqJU86JlG22/bvMdL w7kx5hrS6wCtDJdkJNfJsAvHK5lTG3iy/F+/0sUgVlGqUMgBMU187tN8MvcfSrdw1SQF ix0w== 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 y89si2690801edy.357.2020.05.28.01.01.05; Thu, 28 May 2020 01:01:28 -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 S1726788AbgE1H7B (ORCPT + 99 others); Thu, 28 May 2020 03:59:01 -0400 Received: from twhmllg4.macronix.com ([122.147.135.202]:31191 "EHLO TWHMLLG4.macronix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726649AbgE1H7B (ORCPT ); Thu, 28 May 2020 03:59:01 -0400 Received: from localhost.localdomain ([172.17.195.96]) by TWHMLLG4.macronix.com with ESMTP id 04S7wMHe030973; Thu, 28 May 2020 15:58:27 +0800 (GMT-8) (envelope-from masonccyang@mxic.com.tw) From: Mason Yang To: broonie@kernel.org, tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, boris.brezillon@collabora.com, matthias.bgg@gmail.com Cc: p.yadav@ti.com, juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org Subject: [PATCH v3 05/14] mtd: spi-nor: sfdp: get command opcode extension type from BFPT Date: Thu, 28 May 2020 15:58:07 +0800 Message-Id: <1590652696-8844-6-git-send-email-masonccyang@mxic.com.tw> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1590652696-8844-1-git-send-email-masonccyang@mxic.com.tw> References: <1590652696-8844-1-git-send-email-masonccyang@mxic.com.tw> X-MAIL: TWHMLLG4.macronix.com 04S7wMHe030973 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 | 17 +++++++++++++++++ drivers/mtd/spi-nor/sfdp.h | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index c289395..3685a3a 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -608,6 +608,23 @@ 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: + return -EINVAL; + + case BFPT_DWORD18_CMD_EXT_16B: + dev_err(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 f8198af..e15e307 100644 --- a/drivers/mtd/spi-nor/sfdp.h +++ b/drivers/mtd/spi-nor/sfdp.h @@ -84,6 +84,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; -- 1.9.1