Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2994027imm; Fri, 20 Jul 2018 08:20:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdHyH1aWvGUbm3orocWJYnX0CooW4krANE2TFbLv5HZ8IvkI50uXJZnkJB/WAeru95Nw6QF X-Received: by 2002:a62:ce81:: with SMTP id y123-v6mr2652848pfg.95.1532100043296; Fri, 20 Jul 2018 08:20:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532100043; cv=none; d=google.com; s=arc-20160816; b=fm+JydOqAcJ0EMcBT7oVZ76RY3moX3oJXZmu31D4TKyvCCy2U2UxoJcy9v/mwEYtdj oTkWI0CoDX+3+6lyYvSb3nF2GpeJJLwvpUdJ0nl6Bac3Ms31KYOyTEq+eCIFnEubKGt8 H9ou7bVCNWehg5mrxRfFwnh9ueyJS5koii/fZSYZiIhZLXaJErSzBHnHADLkUNVWFMr/ XFNIdDIqGHN2/oq3tu92gnSeqP5aLfG8i54g+KxAYVn0MOh1fOUdX/nz+rBsCY61SrFx i+UmcvAiDZBsrjUnhxY2uRNRDBlo3hs0wOZgZB1wF6sq/gSXf3e3u8x81d2NJ+leBx84 1arQ== 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=8WEhmtNFK9bbEPuQOHn7yAb2vEW+pj/n3lfIXSNaxBg=; b=QPG+Cz3eYZE0tfqZnULTjpvXOhnfh23GaGuoJggKzHy5Rwfbg7Z0pnx7k9+fBkTSzT +F/mAms1E4S5VOjhMt+k+TlIibDMJfXWJZsMsKam4SuxEUHs3flcYKP2zN5FL5lz3W3A RUbP/crP2Hkmg6fCNWTDGl2eaVLArczXSYq2Xx1iFEcrioE+YCPsH7zqmMEkCIf7Mgvs 3aGV4bDrrgN2WUJQS/eSCGYyZpa/3Jdefh8lp+Oy8b8BUcmSFaCfoEsfTLA1VHPxdfgD QnmmpjzFC1ZvE9haEHhczlUFBsexFhKMn5/GAVaEOFe8ISCwmpTelDYB2gcCm/c4y72U IqBQ== 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 x63-v6si270437pfb.299.2018.07.20.08.20.28; Fri, 20 Jul 2018 08:20:43 -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 S2388201AbeGTQHP (ORCPT + 99 others); Fri, 20 Jul 2018 12:07:15 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54250 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387892AbeGTQEf (ORCPT ); Fri, 20 Jul 2018 12:04:35 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 6971920908; Fri, 20 Jul 2018 17:15:50 +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 B5DB72091A; Fri, 20 Jul 2018 17:15:33 +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 09/35] mtd: rawnand: hisi504: convert driver to nand_scan() Date: Fri, 20 Jul 2018 17:15:01 +0200 Message-Id: <20180720151527.16038-10-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/hisi504_nand.c | 78 +++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/drivers/mtd/nand/raw/hisi504_nand.c b/drivers/mtd/nand/raw/hisi504_nand.c index a1e009c8e556..950dc7789296 100644 --- a/drivers/mtd/nand/raw/hisi504_nand.c +++ b/drivers/mtd/nand/raw/hisi504_nand.c @@ -709,9 +709,50 @@ static int hisi_nfc_ecc_probe(struct hinfc_host *host) return 0; } +static int hisi_nfc_attach_chip(struct nand_chip *chip) +{ + struct mtd_info *mtd = nand_to_mtd(chip); + struct hinfc_host *host = nand_get_controller_data(chip); + int flag; + + host->buffer = dmam_alloc_coherent(host->dev, + mtd->writesize + mtd->oobsize, + &host->dma_buffer, GFP_KERNEL); + if (!host->buffer) + return -ENOMEM; + + host->dma_oob = host->dma_buffer + mtd->writesize; + memset(host->buffer, 0xff, mtd->writesize + mtd->oobsize); + + flag = hinfc_read(host, HINFC504_CON); + flag &= ~(HINFC504_CON_PAGESIZE_MASK << HINFC504_CON_PAGEISZE_SHIFT); + switch (mtd->writesize) { + case 2048: + flag |= (0x001 << HINFC504_CON_PAGEISZE_SHIFT); + break; + /* + * TODO: add more pagesize support, + * default pagesize has been set in hisi_nfc_host_init + */ + default: + dev_err(host->dev, "NON-2KB page size nand flash\n"); + return -EINVAL; + } + hinfc_write(host, flag, HINFC504_CON); + + if (chip->ecc.mode == NAND_ECC_HW) + hisi_nfc_ecc_probe(host); + + return 0; +} + +static const struct nand_controller_ops hisi_nfc_controller_ops = { + .attach_chip = hisi_nfc_attach_chip, +}; + static int hisi_nfc_probe(struct platform_device *pdev) { - int ret = 0, irq, flag, max_chips = HINFC504_MAX_CHIP; + int ret = 0, irq, max_chips = HINFC504_MAX_CHIP; struct device *dev = &pdev->dev; struct hinfc_host *host; struct nand_chip *chip; @@ -769,42 +810,11 @@ static int hisi_nfc_probe(struct platform_device *pdev) return ret; } - ret = nand_scan_ident(mtd, max_chips, NULL); + chip->dummy_controller.ops = &hisi_nfc_controller_ops; + ret = nand_scan(mtd, max_chips); if (ret) return ret; - host->buffer = dmam_alloc_coherent(dev, mtd->writesize + mtd->oobsize, - &host->dma_buffer, GFP_KERNEL); - if (!host->buffer) - return -ENOMEM; - - host->dma_oob = host->dma_buffer + mtd->writesize; - memset(host->buffer, 0xff, mtd->writesize + mtd->oobsize); - - flag = hinfc_read(host, HINFC504_CON); - flag &= ~(HINFC504_CON_PAGESIZE_MASK << HINFC504_CON_PAGEISZE_SHIFT); - switch (mtd->writesize) { - case 2048: - flag |= (0x001 << HINFC504_CON_PAGEISZE_SHIFT); break; - /* - * TODO: add more pagesize support, - * default pagesize has been set in hisi_nfc_host_init - */ - default: - dev_err(dev, "NON-2KB page size nand flash\n"); - return -EINVAL; - } - hinfc_write(host, flag, HINFC504_CON); - - if (chip->ecc.mode == NAND_ECC_HW) - hisi_nfc_ecc_probe(host); - - ret = nand_scan_tail(mtd); - if (ret) { - dev_err(dev, "nand_scan_tail failed: %d\n", ret); - return ret; - } - ret = mtd_device_register(mtd, NULL, 0); if (ret) { dev_err(dev, "Err MTD partition=%d\n", ret); -- 2.14.1