From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62343ECDFBB for ; Fri, 20 Jul 2018 15:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E7B1204EC for ; Fri, 20 Jul 2018 15:17:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E7B1204EC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388374AbeGTQGi (ORCPT ); Fri, 20 Jul 2018 12:06:38 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54429 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388048AbeGTQEq (ORCPT ); Fri, 20 Jul 2018 12:04:46 -0400 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 Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-mediatek@lists.infradead.org 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; -- 2.14.1