From patchwork Thu Jul 19 23:00:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 946644 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="Q/U+jvnf"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="v0DD07oz"; 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 41Wqkv5twbz9s4r for ; Fri, 20 Jul 2018 09:20:55 +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=Q/U+jvnfepxqFnelJluoG88pg/ TBfAJ4OOVFkkwVuekP/T1Wdkb0u7kqnsgac6WOIJomp4jo7MJMx5fxb18teqmJb1zqTL3OJWJL24X JySsYEliz9/om+Vq1bOBXmbJ3295A6gbhWnL0374sMdMo/uUQwWTKtGWwsQEsXe3h7wIJGr3QXJ3P FGWSrpI37t1jQ8T7guQWKg0y7QMdh1sBV58lIDJJnI2y0d3WOx+XnMPltR0aUYm7knQglII878wj8 XPFZNcPE0OxBiaKsQvJFSFmWYziNcAhZii9hxpbAv0fhBkev8/Uh0tyZUwy/zVl1zIc1uCgRRMBvb ubEMBG8g==; 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 1fgIE7-0001OR-0t; Thu, 19 Jul 2018 23:20:51 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fgIBr-0005UP-G2; Thu, 19 Jul 2018 23:18:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=v0DD07ozz1aqqtvFLf8OHTEAr DvA679oQuJQafOIg87UwRr76jDF4J61WM5U90WUJwV0bKE+P6KgOToVDObJt46vU2ZPwPttmG3rsG inXf1SDjeCMMupB8No+uNWBoKL41Fy7q5o5W4ipRY8Dm6arMtO7SyCsD9HV7DqWUfWeG0xdx9Q2H2 iOv1CuF+spJYHiHD9qAh3CusdgGCsfxF/B82L9QyNbU6qOkixBdNiFcE3C1Qt+Cdtj2NzViyGNXRB srpz5OMBU6eG2ZMzeVtp+pq6vvCrLpe3zXdA8dHcsJFKwkewjPi2QvCAtN+SXWOy/QIbMSlRqLdwR jYmdRdJcQ==; Received: from mail.bootlin.com ([62.4.15.54]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fgHvR-000148-Th; Thu, 19 Jul 2018 23:01:36 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 3C33C209C7; Fri, 20 Jul 2018 01:01:23 +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 (unknown [91.224.148.103]) by mail.bootlin.com (Postfix) with ESMTPSA id 7C7112099F; Fri, 20 Jul 2018 01:01:04 +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 v3 19/33] mtd: rawnand: sh_flctl: move all NAND chip related setup in one function Date: Fri, 20 Jul 2018 01:00:12 +0200 Message-Id: <20180719230026.8741-20-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180719230026.8741-1-miquel.raynal@bootlin.com> References: <20180719230026.8741-1-miquel.raynal@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180720_000134_010911_DC833614 X-CRM114-Status: GOOD ( 22.85 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-0.0 points, 5.0 required) 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;