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: 10537771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A5352603B5 for ; Fri, 20 Jul 2018 15:19:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B139294A6 for ; Fri, 20 Jul 2018 15:19:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B4792962F; Fri, 20 Jul 2018 15:19:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D7B3294A6 for ; Fri, 20 Jul 2018 15:19:59 +0000 (UTC) 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=s24tBywDR3ZnEDdmLWNtQwYqZA+AXfjk24L92AXHpnA=; b=UgzBPaJI/euuoU4U19efv4DRXZ OaL7Mdwev6fTkDHWNatQrlBP3X0bVYZHTe9HwD3WUrtPsLDbpAkYr5SkdGN7+lSnmiznpq4rqwa7D OYb1tDLqgbcwDRaFfg549XWoQomdxQvfWXWPC4iJ0tDDu5HfsTMelEdZOwc950v4zjOTNp+J2XdR4 HTIXNs7HZ9XsDvIi4bO4bj3rb0yuDbGbowZZiEUZ+0ZdO7kckNEQvoXa6nPKmsU4SRc9xHVptGkPb +0xmNii+9uLR5xOstUo4wenZPydv/Tzei9Dlp1RGFRnSoCupimd1il2npN0NhLp3PtOrt1fqwRkaQ DGo0NhIw==; 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 1fgXCC-0002gY-Gn; Fri, 20 Jul 2018 15:19:52 +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) 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-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: 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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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;