From patchwork Fri Jul 20 15:15:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 947058 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="QHEK6UE0"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="AXI97ybT"; 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 41XF7x51w7z9s55 for ; Sat, 21 Jul 2018 01:25:33 +1000 (AEST) 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: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=Ake1+GizgOzZxkiTWAwsjkJMCDTaMIie/hctivwBYJM=; b=QHEK6UE0oBMTkdIuynsqiVTSIc XvykeIawheC9Ej/2YqFrOB/w0+QCn5pQ5QwmhyTBgFn+nl0DXpu/KeRkyJrPL8K+jtnIH80p6gous zbkIfo3NQ6F3kWPsCg/nANnauhPD1f+vsPQ4mmvL2xRbGT5c8tazuAYYLTeqSyGA1td+AP4e2qrUo LeUIpaxRsjOjMkAZ0tb9nEeA6uGnnxZ57zJqiJT/yn/zfjboGXkhDFc+bP9wCxI1K8pROWKwazVsC EMCOw/f/3KX6KajiILX4mKy80f13Rr7JJ1GRMgBxm8fe3CJYvuhEOuryhVOZU/4Rs6YGd5IYNF3Ki NaNNPs8g==; 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 1fgXHZ-0002Ol-3B; Fri, 20 Jul 2018 15:25:25 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fgX8m-0006bd-CW; Fri, 20 Jul 2018 15:16:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gF2BJ6bKETAf4NtyRmO0tvuRXPP1ghOCsXf5vLN2vzo=; b=AXI97ybTtgGkH5Wu5oUDJoVxv HFy8QkUOL/vfWpnw0aM7IUqwNAKVIsJNKCbS6+019hwjDrlxhoZqpw3qMarJZT9WmP7H9zfsEUxvX p76LEptLmMsQmocFlojtreGB8XWAxaY6+MDH5qhKe16sa4JIIQ6HmVC/lg0pq5fW5MnaP4S64iqOL 30g6LZ8cQPw6d3bSS3KFUF4n4R3UuLQ5d13uaqkJU5dwED1LFzR4R5DPWdk/h11jhTqKGWirR56qV m02uV6L+LcEtlOBvKj0H7C7Qw1eC8cbAR20rZx13cfkSWhyBGAxYm4JxEe9Efp2YnErTnBpfU7JDM yQQ9N/FLQ==; Received: from mail.bootlin.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fgX8e-0004kk-QO; Fri, 20 Jul 2018 15:16:14 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id E9A1720993; Fri, 20 Jul 2018 17:15:59 +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, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (AAubervilliers-681-1-78-122.w90-88.abo.wanadoo.fr [90.88.20.122]) by mail.bootlin.com (Postfix) with ESMTPSA id 73406203EC; Fri, 20 Jul 2018 17:15:39 +0200 (CEST) From: Miquel Raynal To: Wenyou Yang , Josh Wu , Tudor Ambarus , Boris Brezillon , Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Nicolas Ferre , Alexandre Belloni , Kamal Dasu , Masahiro Yamada , Han Xu , Harvey Hunt , Vladimir Zapolskiy , Sylvain Lemieux , Xiaolei Li , Matthias Brugger , Maxime Ripard , Chen-Yu Tsai , Marc Gonzalez , Mans Rullgard , Stefan Agner Subject: [PATCH v4 19/35] mtd: rawnand: sh_flctl: move all NAND chip related setup in one function Date: Fri, 20 Jul 2018 17:15:11 +0200 Message-Id: <20180720151527.16038-20-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180720151527.16038-1-miquel.raynal@bootlin.com> References: <20180720151527.16038-1-miquel.raynal@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180720_111613_144298_43769776 X-CRM114-Status: GOOD ( 19.26 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [62.4.15.54 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: bcm-kernel-feedback-list@broadcom.com, linux-mediatek@lists.infradead.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Prepare the conversion of the sh_flctl driver to nand_scan() by moving all the configuration that must be made after nand_scan_ident() in one single function. Create a pdata entry in the controller structure for that. Signed-off-by: Miquel Raynal --- drivers/mtd/nand/raw/sh_flctl.c | 38 +++++++++++++++++++------------------- include/linux/mtd/sh_flctl.h | 1 + 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/mtd/nand/raw/sh_flctl.c b/drivers/mtd/nand/raw/sh_flctl.c index c7abceffcc40..d37d1d3ccbf9 100644 --- a/drivers/mtd/nand/raw/sh_flctl.c +++ b/drivers/mtd/nand/raw/sh_flctl.c @@ -1007,6 +1007,16 @@ static int flctl_chip_init_tail(struct mtd_info *mtd) struct sh_flctl *flctl = mtd_to_flctl(mtd); struct nand_chip *chip = &flctl->chip; + if (chip->options & NAND_BUSWIDTH_16) { + /* + * NAND_BUSWIDTH_16 may have been set by nand_scan_ident(). + * Add the SEL_16BIT flag in pdata->flcmncr_val and re-assign + * flctl->flcmncr_base to pdata->flcmncr_val. + */ + flctl->pdata->flcmncr_val |= SEL_16BIT; + flctl->flcmncr_base = flctl->pdata->flcmncr_val; + } + if (mtd->writesize == 512) { flctl->page_size = 0; if (chip->chipsize > (32 << 20)) { @@ -1122,7 +1132,6 @@ static int flctl_probe(struct platform_device *pdev) struct sh_flctl *flctl; struct mtd_info *flctl_mtd; struct nand_chip *nand; - struct sh_flctl_platform_data *pdata; int ret; int irq; @@ -1150,11 +1159,11 @@ static int flctl_probe(struct platform_device *pdev) } if (pdev->dev.of_node) - pdata = flctl_parse_dt(&pdev->dev); + flctl->pdata = flctl_parse_dt(&pdev->dev); else - pdata = dev_get_platdata(&pdev->dev); + flctl->pdata = dev_get_platdata(&pdev->dev); - if (!pdata) { + if (!flctl->pdata) { dev_err(&pdev->dev, "no setup data defined\n"); return -EINVAL; } @@ -1165,9 +1174,9 @@ static int flctl_probe(struct platform_device *pdev) nand_set_flash_node(nand, pdev->dev.of_node); flctl_mtd->dev.parent = &pdev->dev; flctl->pdev = pdev; - flctl->hwecc = pdata->has_hwecc; - flctl->holden = pdata->use_holden; - flctl->flcmncr_base = pdata->flcmncr_val; + flctl->hwecc = flctl->pdata->has_hwecc; + flctl->holden = flctl->pdata->use_holden; + flctl->flcmncr_base = flctl->pdata->flcmncr_val; flctl->flintdmacr_base = flctl->hwecc ? (STERINTE | ECERB) : STERINTE; /* Set address of hardware control function */ @@ -1183,7 +1192,7 @@ static int flctl_probe(struct platform_device *pdev) nand->set_features = nand_get_set_features_notsupp; nand->get_features = nand_get_set_features_notsupp; - if (pdata->flcmncr_val & SEL_16BIT) + if (flctl->pdata->flcmncr_val & SEL_16BIT) nand->options |= NAND_BUSWIDTH_16; pm_runtime_enable(&pdev->dev); @@ -1195,16 +1204,6 @@ static int flctl_probe(struct platform_device *pdev) if (ret) goto err_chip; - if (nand->options & NAND_BUSWIDTH_16) { - /* - * NAND_BUSWIDTH_16 may have been set by nand_scan_ident(). - * Add the SEL_16BIT flag in pdata->flcmncr_val and re-assign - * flctl->flcmncr_base to pdata->flcmncr_val. - */ - pdata->flcmncr_val |= SEL_16BIT; - flctl->flcmncr_base = pdata->flcmncr_val; - } - ret = flctl_chip_init_tail(flctl_mtd); if (ret) goto err_chip; @@ -1213,7 +1212,8 @@ static int flctl_probe(struct platform_device *pdev) if (ret) goto err_chip; - ret = mtd_device_register(flctl_mtd, pdata->parts, pdata->nr_parts); + ret = mtd_device_register(flctl_mtd, flctl->pdata->parts, + flctl->pdata->nr_parts); if (ret) goto cleanup_nand; diff --git a/include/linux/mtd/sh_flctl.h b/include/linux/mtd/sh_flctl.h index c759d403cbc0..c9f486c6c019 100644 --- a/include/linux/mtd/sh_flctl.h +++ b/include/linux/mtd/sh_flctl.h @@ -148,6 +148,7 @@ struct sh_flctl { struct dev_pm_qos_request pm_qos; void __iomem *reg; resource_size_t fifo; + struct sh_flctl_platform_data *pdata; uint8_t done_buff[2048 + 64]; /* max size 2048 + 64 */ int read_bytes;