Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2993465imm; Fri, 20 Jul 2018 08:20:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcX/0bHUNrBeOQN7JIhOc/+F+aKGCCxSdl0WRV75Ix1k0Butjy/vYKh41eMdVlSLK4rfdZU X-Received: by 2002:a62:6cc7:: with SMTP id h190-v6mr2644030pfc.113.1532100009568; Fri, 20 Jul 2018 08:20:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532100009; cv=none; d=google.com; s=arc-20160816; b=QPSSFdKdVlQDPi51aYUY5k0jgn2N913PqFXki6hNeFxVn+wfVsYRvG4sVkeEInWXHV GvNdE09NFLAVCgjw9dMU8lR2xi9DGMNrFuEy5S4ao+lKSkQXqbtl8L0a0ZiLTRbwPFb7 wGbKPIp1One9tDq1ZvNHuuMRmfepKkgTei+4l2/UG/d/95GeyevZmEIlIP+UEjYSMYJ/ 5C+IyTQ9USegUhfWtsRc05S6MsP+Tdj7316P57W7K60iwBlB1yhzpZpbtQDW/uS0wEn2 pIQunDtZipOck7CJ40l554tzOg7QeeqUPV5jzZyx0TcPUgxIIT45i59rRnM482WPXqZ3 TkgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=gF2BJ6bKETAf4NtyRmO0tvuRXPP1ghOCsXf5vLN2vzo=; b=AH8e0AvyZe0q0RFsvG3HjoxD+XfSwesUJQ5b9vU9niv9eoMZELCxqRooYhs5TCStQ1 ZjtrkP1QNkOOydvjxcWDalp/A0jkcC47PpQROKOW7tsrY08o72aCif7pd5trJVYiEALf kye41LOnURqCZbKMOyAq5WAXzKwB3iAsU00+2WJDXUbFhiojuobTlXXO6IrjRItYT+dF OJtCMT8/6eoAZPY9ktOvAIZRAzK+2q7LT6jJP8KtRiB/32v1JSBnr3Cb6SH/9ZBM5LCE rawuYyDo3Lc/uDzWO67hT/N3D3OLmzyYhQFm94bSqS9lGOETL16ZKiMx7+XrvHS82LyX wk+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3-v6si2051284pgg.347.2018.07.20.08.19.54; Fri, 20 Jul 2018 08:20:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388369AbeGTQGi (ORCPT + 99 others); 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) 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 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