Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1323740ybh; Thu, 23 Jul 2020 06:14:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqyqKKv9+L3qDYD72K+iYvbNm52+0ToOyW6Hk4fBL86P6yDGLe/pW3xdvjm5sXJtJ4vQlE X-Received: by 2002:a17:906:c78f:: with SMTP id cw15mr4211224ejb.58.1595510065203; Thu, 23 Jul 2020 06:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595510065; cv=none; d=google.com; s=arc-20160816; b=cuYYKEWrx1OldrOBcekF+FkML9ed9g9OXtxCaDuWCF6GgY3Nm2Fha8LjhXIAQfmBAc d8x1CqfP552luK9NN05xr5LP3xFs5WVL3egKyvxMQfALnpBfcFe0TbXWKk20Bx9ZmyAe hWLOn1BJJB7aD4htq31QLB75pNGOzCsd0fvXbPlQimj8qAx/1H44BXaiFdL/oyR6v628 p5bBuDfw3odrJ5XhS3/sx/F6AvPA1/q/inL936kL65ESDihY85GtxUM+iCUMJU+GRKXy LkEDMpZ9K1R63hIwIfBrja7+WJuMjf6d0Bgm95k4ZueickNXzk3mFE5jdeFjY6n+A3La dHWg== 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=ugIWkZt8QbvAUTASKa8NnpeXGi+dNZawBTNFvvyTmtQ=; b=fS8aQCJNYqQWPEfxR6AnwumuclbN15WvfWup9grMbYDoO8eeoUtZQoB4OjEluaqA+6 as4TlzHvcwvZNAP1q2FAF1QC95KAmbcTuDBbLfeS30kTuRmv+WUn09nLkbpgD1gOpQFz bpdbfH/8d9m1SoOARjnLQZ1SY7eW8+/JG/wAKZcNlHUXnCMaRPj1p5I45NfT6EoJhr13 Enwc6RI3uOuPpk65wlncSJT35k0FlctierKVE/PM7Dsn3iHkzJXcNCBUzAvKG8PGpWtL 1sA7B2mXwr5AOB9cBX7qF+9kCsVbx9X93CaXp3TSf7Y5G3vFrHdhNIdVvnmd3Y7RfeyV 7XyA== 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 by17si2239484edb.369.2020.07.23.06.14.02; Thu, 23 Jul 2020 06:14:25 -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 S1729186AbgGWNNA (ORCPT + 99 others); Thu, 23 Jul 2020 09:13:00 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:34707 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbgGWNNA (ORCPT ); Thu, 23 Jul 2020 09:13:00 -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 EBB141C0010; Thu, 23 Jul 2020 13:12:54 +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 08/14] mtd: spi-nor: core: enable octal DTR mode when possible Date: Thu, 23 Jul 2020 18:41:57 +0530 Message-Id: <20200723131203.40916-9-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 Allow flashes to specify a hook to enable octal DTR mode. Use this hook whenever possible to get optimal transfer speeds. Signed-off-by: Pratyush Yadav --- drivers/mtd/spi-nor/core.c | 35 +++++++++++++++++++++++++++++++++++ drivers/mtd/spi-nor/core.h | 2 ++ 2 files changed, 37 insertions(+) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 6efc86e2aba0..b990fc7add20 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -3050,6 +3050,35 @@ static int spi_nor_init_params(struct spi_nor *nor) return 0; } +/** spi_nor_octal_dtr_enable() - enable Octal DTR I/O if needed + * @nor: pointer to a 'struct spi_nor' + * @enable: whether to enable or disable Octal DTR + * + * Return: 0 on success, -errno otherwise. + */ +static int spi_nor_octal_dtr_enable(struct spi_nor *nor, bool enable) +{ + int ret; + + if (!nor->params->octal_dtr_enable) + return 0; + + if (!(nor->read_proto == SNOR_PROTO_8_8_8_DTR && + nor->write_proto == SNOR_PROTO_8_8_8_DTR)) + return 0; + + ret = nor->params->octal_dtr_enable(nor, enable); + if (ret) + return ret; + + if (enable) + nor->reg_proto = SNOR_PROTO_8_8_8_DTR; + else + nor->reg_proto = SNOR_PROTO_1_1_1; + + return 0; +} + /** * spi_nor_quad_enable() - enable/disable Quad I/O if needed. * @nor: pointer to a 'struct spi_nor' @@ -3090,6 +3119,12 @@ static int spi_nor_init(struct spi_nor *nor) { int err; + err = spi_nor_octal_dtr_enable(nor, true); + if (err) { + dev_dbg(nor->dev, "octal mode not supported\n"); + return err; + } + err = spi_nor_quad_enable(nor, true); if (err) { dev_dbg(nor->dev, "quad mode not supported\n"); diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 27e00a9f5950..17dbbb3e4796 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -203,6 +203,7 @@ struct spi_nor_locking_ops { * higher index in the array, the higher priority. * @erase_map: the erase map parsed from the SFDP Sector Map Parameter * Table. + * @octal_dtr_enable: enables SPI NOR octal DTR mode. * @quad_enable: enables/disables SPI NOR Quad mode. * @set_4byte_addr_mode: puts the SPI NOR in 4 byte addressing mode. * @convert_addr: converts an absolute address into something the flash @@ -226,6 +227,7 @@ struct spi_nor_flash_parameter { struct spi_nor_erase_map erase_map; + int (*octal_dtr_enable)(struct spi_nor *nor, bool enable); int (*quad_enable)(struct spi_nor *nor, bool enable); int (*set_4byte_addr_mode)(struct spi_nor *nor, bool enable); u32 (*convert_addr)(struct spi_nor *nor, u32 addr); -- 2.27.0