Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3556482ybk; Tue, 19 May 2020 07:32:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgE6RYyQXDmBpJ21M3QmXlMus7X5InfwZe7ZM8L7kp9AAMkm/tNct9MzGj7+AulLD9vej1 X-Received: by 2002:a17:906:2b96:: with SMTP id m22mr19010764ejg.330.1589898743386; Tue, 19 May 2020 07:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589898743; cv=none; d=google.com; s=arc-20160816; b=STQ0DoaIRN/FrRJVHW0BY9VpfcQi7MUa6eVxd8G+jgt8XYupauyR1aNVXIQhKKwgSR UHSfQTdlME4e8LixlZyMreJ30MSVCc8+lhTNs+5jXx3MjN+0aiuUjh5LOP2P/JqyxJXx tYtoIYoSndNZotmnAgdYtdk0fuaq66cR5+wRevCMHk0wgA5Dp8zZG3aiolU0gWst4od6 2FEMyaNERqg2rlkfjxoMUvdISuW1TIkKWBv8v4Ks0UWHSXtJ5kG2a170Hj4nEDz8YtIi 4Ohtav2qaOizg5kgJ+pFSM/XOk13fgUYQs4x2k40L8CgNIrc1yUiU1AX6RWo+5t5zUwD q1tw== 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=8U5j3EpmZjALS0efVhhezXkuXnpSFM9S8zpuLAfKQGc=; b=lDZrtYY26l8oBkvjrLKNdPFFA4PKITRLmZgXuVqgQ6RMMYjmwjNPPAPD9PuxcnOd1e r3ceWZqOgOK3fU3jS5o1+s784SMFeexjZZos4r0oQq/iPe6oudkGkh0dOHLTcvcE2JUD WHJkFN8bl3msNE9olo7hegaL5KwUZ5HP/OdVfeOEpTRLPLzohQrtkHuSZDY2R41w0DGC EyplxwHT6aOwYwqPxEg07MDgG7nIP4vl7tuOjd/3cMhZQqEcB2mEesalJkwGE9+i0N4I NbJ1bOYrQrROGhvQCW6myVfgLYf2dNYzBlVcGuTdPGoD/KfzfxllCUVbnGtV7GBP6duU 6VMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=D8mUgbt6; 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 g17si8073311ejr.529.2020.05.19.07.31.56; Tue, 19 May 2020 07:32:23 -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=D8mUgbt6; 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 S1729220AbgESO1z (ORCPT + 99 others); Tue, 19 May 2020 10:27:55 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:59138 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729196AbgESO1u (ORCPT ); Tue, 19 May 2020 10:27:50 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 04JERSft074897; Tue, 19 May 2020 09:27:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1589898448; bh=8U5j3EpmZjALS0efVhhezXkuXnpSFM9S8zpuLAfKQGc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=D8mUgbt6w6AE2bc7eim+zcuFy8QQyrHU4Gu9mCIjuttB9A2c/rOgCrUDjoE8a2NOn ldr7MtR4ctQEFyGH4Z6D2CIZ2LIVvsjgMMhv0KvtcIPIp85sQSIzV3rR66v/kn68Nx O51xQVZgp33UateLuYZLFKgnucxqTHCHqF0t8cZs= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 04JERSbd081913 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 19 May 2020 09:27:28 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) 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; Tue, 19 May 2020 09:27:28 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE104.ent.ti.com (10.64.6.25) 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; Tue, 19 May 2020 09:27:28 -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 04JEQgjQ008313; Tue, 19 May 2020 09:27:23 -0500 From: Pratyush Yadav To: Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mark Brown , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , Matthias Brugger , , , , , CC: Pratyush Yadav , Sekhar Nori , Boris Brezillon , Mason Yang Subject: [PATCH v5 08/19] mtd: spi-nor: sfdp: get command opcode extension type from BFPT Date: Tue, 19 May 2020 19:56:30 +0530 Message-ID: <20200519142642.24131-9-p.yadav@ti.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200519142642.24131-1-p.yadav@ti.com> References: <20200519142642.24131-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.26.2