From patchwork Thu Feb 21 12:58:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 1046156 X-Patchwork-Delegate: miquel.raynal@bootlin.com 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="tKQPSxGb"; 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 444vkC5HhHz9sBF for ; Fri, 22 Feb 2019 00:01:39 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=x4HRnO+tMKvhkBiVD005RhYer6AQTXSsvjy1wbYKPtg=; b=tKQPSxGbV/Hbbs 2GBOApqNVM2JOBeTNHtQJTQ/e+S0w5dbYLzoeqkvun4TTS+H/0fe4WmNcvudOseJf/6oseQlIjWXu f4OCbLbSrV8DlSuHdlUzWtln7sGEQpX4DvSOKrjTmMKWjD4zht7Kfk4OnzF94aCLCljncw0bRI1aa 3mpC1+V3eDqdwbNfXUOSYdTop7ktonrjw9meZQF9Q8m5ZFocI7XW0Gh4D/KM1cw+ASxvm3jtPUIP7 MtQR1IQ+ipiIFku0a21uNQWX0e2oqNGUJL9/2fk0wf6sSQrH8j9ZJgkxDr6cF8Am3wFRt1OOcoS9Y Wp+xYC/ZbeK09jlCGMKg==; 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 1gwnym-0007v3-Ki; Thu, 21 Feb 2019 13:01:32 +0000 Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwnw8-0003Gv-OJ; Thu, 21 Feb 2019 12:59:11 +0000 X-Originating-IP: 90.88.23.190 Received: from localhost.localdomain (aaubervilliers-681-1-81-190.w90-88.abo.wanadoo.fr [90.88.23.190]) (Authenticated sender: miquel.raynal@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 8CCD0C0006; Thu, 21 Feb 2019 12:58:43 +0000 (UTC) From: Miquel Raynal To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Tudor Ambarus Subject: [RFC PATCH 22/27] mtd: spinand: Let the SPI-NAND core flag a SPI-NAND chip Date: Thu, 21 Feb 2019 13:58:01 +0100 Message-Id: <20190221125806.28875-10-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190221125806.28875-1-miquel.raynal@bootlin.com> References: <20190221125806.28875-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190221_045849_493888_13BD9EA4 X-CRM114-Status: GOOD ( 14.70 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [217.70.183.198 listed in list.dnswl.org] -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: Vignesh R , Tudor Ambarus , Julien Su , Schrempf Frieder , linux-mtd@lists.infradead.org, Thomas Petazzoni , Miquel Raynal , Mason Yang , linux-arm-kernel@lists.infradead.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org As of today there is no way to make the distinction between a raw NAND chip and a SPI-NAND chip. The ABI is stable and we cannot add a "SPI-NAND" tag to the MTD type, but we can add a special SPINAND capability to the flags instead. A helper is also provided to retrieve if whether or not the chip is working over SPI or not. Signed-off-by: Miquel Raynal --- drivers/mtd/nand/core.c | 2 +- include/linux/mtd/mtd.h | 5 +++++ include/uapi/mtd/mtd-abi.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c index a76d206d233a..872d46b5fc0f 100644 --- a/drivers/mtd/nand/core.c +++ b/drivers/mtd/nand/core.c @@ -245,7 +245,7 @@ int nanddev_init(struct nand_device *nand, const struct nand_ops *ops, mtd->type = memorg->bits_per_cell == 1 ? MTD_NANDFLASH : MTD_MLCNANDFLASH; - mtd->flags = MTD_CAP_NANDFLASH; + mtd->flags = MTD_SPINAND | MTD_CAP_NANDFLASH; mtd->erasesize = memorg->pagesize * memorg->pages_per_eraseblock; mtd->writesize = memorg->pagesize; mtd->writebufsize = memorg->pagesize; diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 677768b21a1d..7c245d109524 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -551,6 +551,11 @@ static inline int mtd_type_is_nand(const struct mtd_info *mtd) return mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH; } +static inline int mtd_type_is_spinand(const struct mtd_info *mtd) +{ + return mtd_type_is_nand(mtd) && (mtd->flags & MTD_SPINAND); +} + static inline int mtd_can_have_bb(const struct mtd_info *mtd) { return !!mtd->_block_isbad; diff --git a/include/uapi/mtd/mtd-abi.h b/include/uapi/mtd/mtd-abi.h index aff5b5e59845..7c7124c88fe0 100644 --- a/include/uapi/mtd/mtd-abi.h +++ b/include/uapi/mtd/mtd-abi.h @@ -104,6 +104,7 @@ struct mtd_write_req { #define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */ #define MTD_NO_ERASE 0x1000 /* No erase necessary */ #define MTD_POWERUP_LOCK 0x2000 /* Always locked after reset */ +#define MTD_SPINAND 0x4000 /* Device works over SPI */ /* Some common devices / combinations of capabilities */ #define MTD_CAP_ROM 0