Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp58921ybz; Fri, 24 Apr 2020 11:46:42 -0700 (PDT) X-Google-Smtp-Source: APiQypJFHhACgJ6R5IojGu8S4wiiJMWMCMA2+CB+pPrkxh4jWRSFxzvXA2Yp63esv44DqPsmT9ga X-Received: by 2002:a05:6402:379:: with SMTP id s25mr8910462edw.69.1587754002025; Fri, 24 Apr 2020 11:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587754002; cv=none; d=google.com; s=arc-20160816; b=o/A7smEmeXCNIxOfD5n7+F7fESCGS9u41NJb7uNB+YmGg77t4rVWqJwlEy+pGVgr4W W4Nswl7SDaml7crKHNCGoxUkSiNT2Mo4/0cFe/XNqbghqN08RnPU4KtH+p53L8H7YHNC c2MBUzpcJfNkvE6GEbJc3I8zahRmjCvn2nCB7hFy7vAHqdRVdUTlKJsvJ8uhPIAcHttM 220wj4Z6u593JJLMcd3tg59yuHKjPDaXi8S5UNuiyz1YMJNKLsAZ3pLwj3XDaiUbG1h2 Wowd4D5aKZN1L4mEJHxNmzonhPXrgpzo6Fd01JYegrfLTTuMQ8FjCn8aBle5E0J21BPL Ry7Q== 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=tAW7UtALB6g1UHDnUHO5hLQyJIK6nJtS6mmNAZvtoTY=; b=gtuGh9UMmwBLObBFsK8MFip4BMWILKEZk/XpBEXxir7cbBRRMhpLN+DtrM5u4X/FsS M2/aU0ElfpUJ4UPYa/Cud/B5XwNOkXIfdx4tc+ahJTcqECGu+RGqxPIjh9p9Lmdju22u TaHRilzTyRhlvxtIaQnjBSK32aPktvNx1qEr+/K8v6lCJTxpiudzaAu72jJBYgtsQZlb bmgDqzHyeBjDjJkXggQJZh1qsK1rLrsQa5Hd1wEx1VxAXMHGtxa5bCO4uPvh7B0goP7g eFUhrX+BRCNqmLIPTNYOjRJpRP9p8T3Csn/UcOUvrw8VMu+3pLmQud09Vn7YlF6lvbyP L8jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=GO6f6PuE; 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 b16si2707412edr.270.2020.04.24.11.46.19; Fri, 24 Apr 2020 11:46:42 -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=GO6f6PuE; 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 S1729235AbgDXSoy (ORCPT + 99 others); Fri, 24 Apr 2020 14:44:54 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:57220 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729224AbgDXSox (ORCPT ); Fri, 24 Apr 2020 14:44:53 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03OIihP8087318; Fri, 24 Apr 2020 13:44:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587753883; bh=tAW7UtALB6g1UHDnUHO5hLQyJIK6nJtS6mmNAZvtoTY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=GO6f6PuEOEXzuRZuSOI4VmXIer+UHHR27Gif6BMv4n8TZrPxbKCY0tZn03XW/yFe/ LV0aLJB9JNvzf8UlhXwdXub5h6F4hTEV7xIXXT6EkvmrU3aH0wbpJVKnNIAMypGvOz GDb0od0uGSmO03uksehB7vzc7xLUARVed0HG6tm4= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 03OIihXg065105 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 24 Apr 2020 13:44:43 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE113.ent.ti.com (157.170.170.24) 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:43 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE104.ent.ti.com (157.170.170.34) 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:43 -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 03OIiAaD047967; Fri, 24 Apr 2020 13:44:39 -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 07/16] mtd: spi-nor: get command opcode extension type from BFPT Date: Sat, 25 Apr 2020 00:14:01 +0530 Message-ID: <20200424184410.8578-8-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 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 96960f2f3d7a..ab086aa4746f 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -609,6 +609,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 f8198af43a63..e15e30796d62 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; -- 2.25.0