Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2994252imm; Fri, 20 Jul 2018 08:20:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdRxIJRNSVDGgV5TBOv9aVP773Cbg/B2YE5P3AqhNh8kRe2z95Mvfg4rX/W5sxipDItG+fe X-Received: by 2002:a17:902:7202:: with SMTP id ba2-v6mr2467124plb.179.1532100058141; Fri, 20 Jul 2018 08:20:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532100058; cv=none; d=google.com; s=arc-20160816; b=F7ogJT3aAv9JyQx+FNia6osQ6KfRXb1dy10GzwuhLEOtcfdY+2Gplk1JjWAFlFQJfk OwGwEi2nBSE8cecMTaeRMyrY1S90nx3ZgXYEBmqB6H5b6zAJ/MJIQeiGgvv4paHiabFg jMET3X9/9+CE+puL3Dctlypy3351l5YXcSndLNRfLq9D8JUkd/pjx1CtypZrrh/HeyHu cibM5SEoZdw89ElmpC/hVrGpjy6q+Ezg0BqKZbLexavWlMujj705HWOuZLULRDMk6yzr lFSZVAqrbxIKKKqOlOc9S2qAhEOXIeKz8EiHRJc2hrtYamr5U3hJupp6P9fz6Leg++0A c/6Q== 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=PPC8ws2wJxjWrmPA4AO1GY2+MKQxNcKXZD7W2V9efZk=; b=sYq9l+Dc0USuUT3yQDEiZijRzdC8ejgEo/AZou0o4wylIKSYJVU0EctUIvynfqD3Up v3Yu61gEsj+26iF3bT61zAjaSiS4swq0lUCNI9q7g9RDwxRFP23ZuPArZYWyiMrb0qZ4 5L+jmC9Oqhvuoig71brJhYhZ3AO+nDydtJ5VhG4TgVzxERiGbieSLnWN7C3iOBBQoGhn oNbfwUZuFOC75tzQR/QZrlrwIEoN/bHC7BYGa+t05V8NCzHslO6E7jw/kZoqfevnZYFw X3wAJAfcKGPdtWk3iLzcxq3JINGBspEYhox0sfWfCPscAHks9BdOL8MG++fvrRw8USHt L/AA== 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 m37-v6si1886644plg.340.2018.07.20.08.20.43; Fri, 20 Jul 2018 08:20:58 -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 S2387810AbeGTQE0 (ORCPT + 99 others); Fri, 20 Jul 2018 12:04:26 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54108 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731986AbeGTQE0 (ORCPT ); Fri, 20 Jul 2018 12:04:26 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id B216E20994; Fri, 20 Jul 2018 17:15:39 +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 1BB342073D; Fri, 20 Jul 2018 17:15:29 +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 01/35] mtd: rawnand: brcmnand: convert driver to nand_scan() Date: Fri, 20 Jul 2018 17:14:53 +0200 Message-Id: <20180720151527.16038-2-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 Two helpers have been added to the core to make ECC-related configuration between the detection phase and the final NAND scan. Use these hooks and convert the driver to just use nand_scan() instead of both nand_scan_ident() and nand_scan_tail(). Signed-off-by: Miquel Raynal --- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 47 +++++++++++++++++++------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c index 2e5efa0f9ea2..071f09af56dc 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -2208,6 +2208,32 @@ static int brcmnand_setup_dev(struct brcmnand_host *host) return 0; } +static int brcmnand_attach_chip(struct nand_chip *chip) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + struct brcmnand_host *host = nand_get_controller_data(chip); + int ret; + + if (chip->bbt_options & NAND_BBT_USE_FLASH) + chip->bbt_options |= NAND_BBT_NO_OOB; + + if (brcmnand_setup_dev(host)) + return -ENXIO; + + chip->ecc.size = host->hwcfg.sector_size_1k ? 1024 : 512; + + /* only use our internal HW threshold */ + mtd->bitflip_threshold = 1; + + ret = brcmstb_choose_ecc_layout(host); + + return ret; +} + +static const struct nand_controller_ops brcmnand_controller_ops = { + .attach_chip = brcmnand_attach_chip, +}; + static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) { struct brcmnand_controller *ctrl = host->ctrl; @@ -2267,10 +2293,6 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) nand_writereg(ctrl, cfg_offs, nand_readreg(ctrl, cfg_offs) & ~CFG_BUS_WIDTH); - ret = nand_scan_ident(mtd, 1, NULL); - if (ret) - return ret; - chip->options |= NAND_NO_SUBPAGE_WRITE; /* * Avoid (for instance) kmap()'d buffers from JFFS2, which we can't DMA @@ -2279,21 +2301,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) */ chip->options |= NAND_USE_BOUNCE_BUFFER; - if (chip->bbt_options & NAND_BBT_USE_FLASH) - chip->bbt_options |= NAND_BBT_NO_OOB; - - if (brcmnand_setup_dev(host)) - return -ENXIO; - - chip->ecc.size = host->hwcfg.sector_size_1k ? 1024 : 512; - /* only use our internal HW threshold */ - mtd->bitflip_threshold = 1; - - ret = brcmstb_choose_ecc_layout(host); - if (ret) - return ret; - - ret = nand_scan_tail(mtd); + ret = nand_scan(mtd, 1); if (ret) return ret; @@ -2434,6 +2442,7 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc) init_completion(&ctrl->done); init_completion(&ctrl->dma_done); nand_controller_init(&ctrl->controller); + ctrl->controller.ops = &brcmnand_controller_ops; INIT_LIST_HEAD(&ctrl->host_list); /* NAND register range */ -- 2.14.1