From patchwork Fri Oct 12 08:48:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 982926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Q9MsYZkq"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42WhfM07RVz9s3C for ; Fri, 12 Oct 2018 20:01:47 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=M6B9wBL7d6Ht5E6KinNr6ulFwPPDyudDtmDpBpwRUEg=; b=Q9M sYZkqgMirGhBPVZnVojd5GBV6WkebwOk+roVFM3TufYS7tlUgIUOglggAUj8/TSbOZp68laYg7xjG /fpmuIdN9TSi+lDSRwR7qCNdS2auYrV5bZTZfu1RlL70w3Vh8A+QYsvf+VeyEWLSjFez5UfDr0NVi zhYrN7gHVUWsJklF9q0C+HzF7X7PgAfTSULSLKgYYk23L8NkrbNxQPK7WvtYy3LuomOQqUWOjQjmP kkgJgmX21S7szK2gi3QIyCITKX0xx4kgMgv3y4usVa1SpM7+wlUT30X84oeeuvajsxjn+uaRvkK4y Hkyw4ScIa0EZtFbtsH/WQTS1NhhTh+g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gAtKG-0002lG-Ir; Fri, 12 Oct 2018 09:01:40 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gAt7q-0001hF-HD for linux-mtd@lists.infradead.org; Fri, 12 Oct 2018 08:48:55 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id DDBD720DE6; Fri, 12 Oct 2018 10:48:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (AAubervilliers-681-1-7-245.w90-88.abo.wanadoo.fr [90.88.129.245]) by mail.bootlin.com (Postfix) with ESMTPSA id 75FA3207BB; Fri, 12 Oct 2018 10:48:27 +0200 (CEST) From: Boris Brezillon To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org, Yogesh Gaur , Vignesh R , Cyrille Pitchen Subject: [PATCH RFC 00/18] mtd: spi-nor: Proposal for 8-8-8 mode support Date: Fri, 12 Oct 2018 10:48:07 +0200 Message-Id: <20181012084825.23697-1-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.14.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181012_014850_899097_2CB493AE X-CRM114-Status: GOOD ( 24.91 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julien Su , Mark Brown , Mason Yang , linux-spi@vger.kernel.org, zhengxunli@mxic.com.tw MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hello, The trend has been around octo (or octal) SPI NOR lately, and both Yogesh and Vignesh proposed patches to support 1-1-8 and 1-8-8 modes on Micron SPI NORs (plus the associated patches to support that on the Cadence and FlesSPI controllers). I'll probably take their patches in 4.20 since adding support for stateless octo modes is not invasive, but I wanted to start a discussion on how we should support stateful modes (X-X-X and XD-XD-XD, where X is the bus width and D means Double Transfer Rate). First question that might come to mind is why should we support such stateful modes? If you think about it, the gain of transmitting the opcode on 8 IO lines is rather small compared to the pain it is to teach the SPI NOR framework how to deal with that. The problem is, some SPI NOR manufacturers (Macronix for instance) only implement 1-1-1 and 8-8-8 (or 8D-8D-8D), and they want to be able to use their NORs in 8-8-8 mode when the controller supports it. So, this patchset is aiming at starting a wider discussion on how you think those modes should be supported. This is just a proposal, and I'm of course open to other suggestions, as long as the answer is not as definitive as "too bad for them, they should have supported 1-8-8 or 1-1-8 modes". Just a few more details about the patches in this series. Some of them are clearly conflicting with patches posted by Yogesh and Vignesh. Don't worry guys, I'm still planning to take yours before, it's just that I was too lazy to rebase on top of your modifications. Also, some patches might not pass checkpatch or might trigger kbuild errors, but before fixing those problems, I'd like to get your opinion on the general approach. It's also worth mentioning that I focused on spi-mem support only, because on the long run, I want all SPI NOR controller drivers converted to this interface, and if I can limit support of octo modes to those implementing the spi-mem interface, that's an incentive to push developers to do the conversion. This part is still open to discussion though. Also, in this patchset, I merge the m25p80 driver code in spi-nor.c, which is something I wanted to do for quite some. Indeed, the m25p80 is just a simple SPI NOR controller driver (a wrapper around the SPI mem API). Not only it shouldn't be named after a specific SPI NOR chip, but it also doesn't deserve a specific driver IMO, especially if the end goal is to get rid of SPI NOR controller drivers found in drivers/mtd/spi-nor/ and replace them by SPI mem drivers (which would be placed in drivers/spi/). With this solution, we declare the SPI NOR driver as a spi_mem_driver, just like the SPI NAND layer is declared as a spi_mem driver. This solution also allows us to check at a fined-grain level (thanks to the spi_mem_supports_op() function) which operations are supported and which ones are not, while the original m25p80 logic was basing this decision on the SPI_{RX,TX}_{DUAL,QUAD,OCTO} flags only. The last set of patches in the series are modifying the framework to allow entering X-X-X modes in a chip-specific way, and then adds support for 8-8-8 and 8D-8D-8D modes on a Macronix chip (mx25uw51245g). Yogesh, Vignesh, Tudor (and maybe Cyrille and Marek if you have some time), please have a look at this patch series and tell me what you think. Regards, Boris Boris Brezillon (18): mtd: spi-nor: Add a flash_info entry for Macronix mx25uw51245g spi: Prepare things for octo mode support spi: spi-mem: Prepare things for DTR mode support spi: spi-mem: Prepare things for dual bytes opcodes support spi: spi-mem: mxic: Add support for DTR and Octo mode mtd: spi-nor: Move m25p80 code in spi-nor.c mtd: spi-nor: Rework hwcaps selection for the spi-mem case mtd: spi-nor: Define the DPI, QPI and OPI hwcaps mtd: spi-nor: Add spi_nor_{read,write}_reg() helpers mtd: spi-nor: Add support for X-X-X modes mtd: spi-nor: Prepare things for 2byte opcodes mtd: spi-nor: Provide a hook to tweak flash parameters mtd: spi-nor: Add 8-8-8 mode support to Macronix mx25uw51245g mtd: spi-nor: Clarify where DTR mode applies mtd: spi-nor: Add DTR support to the spi-mem logic mtd: spi-nor: Add the concept of full DTR modes mtd: spi-nor: Add 8D-8D-8D mode mtd: spi-nor: Make sure the 8D-8D-8D can be selected on mx25uw51245g drivers/mtd/devices/Kconfig | 18 - drivers/mtd/devices/Makefile | 1 - drivers/mtd/devices/m25p80.c | 324 --------- drivers/mtd/spi-nor/Kconfig | 3 +- drivers/mtd/spi-nor/atmel-quadspi.c | 5 +- drivers/mtd/spi-nor/spi-nor.c | 1331 +++++++++++++++++++++++++++++++---- drivers/spi/spi-mem.c | 15 +- drivers/spi/spi-mxic.c | 27 +- drivers/spi/spi.c | 12 +- include/linux/mtd/spi-nor.h | 168 ++++- include/linux/spi/spi-mem.h | 69 +- include/linux/spi/spi.h | 2 + 12 files changed, 1424 insertions(+), 551 deletions(-) delete mode 100644 drivers/mtd/devices/m25p80.c