Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp801255imm; Fri, 8 Jun 2018 05:36:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLc2khuFgmYYyMnw82aHPq42TjPIMEvskZBFF54uuHUYC7oEWCJgVr6ZzhkM+AxHnzzg5hR X-Received: by 2002:a17:902:9309:: with SMTP id bc9-v6mr6459890plb.189.1528461402023; Fri, 08 Jun 2018 05:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528461401; cv=none; d=google.com; s=arc-20160816; b=jI5savjrJGUC2H0wTRcyYCdbi2YuPDbk0BZn6ty0H7JFEzNGXYG1zie6zAoRYadjZi zyeC8bqKcpDDSKyeS1/6xZMnXtAUtTz088AcY6hSxej3BAHsc4ep3UzDFzkifMLbuXxK Omlywup+77x5/yJzuFZee5wp4k9HHn0eeCiymTgov7eiYkLP37N3p2ZneNPplqQ2qO2i rz/ONAZYZIGdYzLHwvklomSImX5KBjaE5dLuJhuFxaYZ/+W+B2ehFy6k5xtn+samiIzM KyFViqV7a3cuSDEYWJ5wIFFLoVS5uoui06cC1KCzWvTDYxMyZZW8JUbMT3pdXfmTa7uX 8MYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=Y5IS1mMVhdxMy8DsC1aN2wn85IWosUw4n6tLLoTfHII=; b=uR25Cy+jtcoMYO0aMyrMRd0iz6OFCwTKqz05oqkbw8pJGLfaPk3d3OP8YMtIFTgOct fUMsxvMm/u4N6TwCkRGIOXrlr9oQz/wMb26nUwfanjLR/En7+Iul6pZKcNruju7Ro8RC 07Ng27ClcZOUISDSVTxnU4zKypet+oBYkOIFqv92zDMuNVjJriK1J663esfzLsJCR/8O HW66ca7YSpJIrUuyMigB8CkQl0UBB4shd8POmqj308av5BmnkvPCU3gLoUmpi+DBNf6L 2vwVbTjL20YSxNvHeLzbGyGH96EG6DzRcimgjHt9zoqsZQVHuWSgj8TNf7Nnl2uCu4j1 IKTw== 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 c2-v6si32433637pgp.147.2018.06.08.05.36.26; Fri, 08 Jun 2018 05:36:41 -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 S1752180AbeFHMgC convert rfc822-to-8bit (ORCPT + 99 others); Fri, 8 Jun 2018 08:36:02 -0400 Received: from mail.bootlin.com ([62.4.15.54]:40166 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751565AbeFHMgB (ORCPT ); Fri, 8 Jun 2018 08:36:01 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 94AA4207C0; Fri, 8 Jun 2018 14:35: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 xps13 (AAubervilliers-681-1-128-7.w90-88.abo.wanadoo.fr [90.88.9.7]) by mail.bootlin.com (Postfix) with ESMTPSA id 228DD2069C; Fri, 8 Jun 2018 14:35:49 +0200 (CEST) Date: Fri, 8 Jun 2018 14:35:49 +0200 From: Miquel Raynal To: Naga Sureshkumar Relli Cc: "boris.brezillon@bootlin.com" , "richard@nod.at" , "wmw2@infradead.org" , "computersforpeace@gmail.com" , "marek.vasut@gmail.com" , "f.fainelli@gmail.com" , "mmayer@broadcom.com" , "rogerq@ti.com" , "ladis@linux-mips.org" , "ada@thorsis.com" , "honghui.zhang@mediatek.com" , "linux-mtd@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "nagasureshkumarrelli@gmail.com" Subject: Re: [LINUX PATCH v9 4/4] mtd: rawnand: pl353: Add basic driver for arm pl353 smc nand interface Message-ID: <20180608143549.04400f92@xps13> In-Reply-To: References: <1528271382-21690-1-git-send-email-naga.sureshkumar.relli@xilinx.com> <1528271382-21690-5-git-send-email-naga.sureshkumar.relli@xilinx.com> <20180607215949.58e2d15d@xps13> Organization: Bootlin X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Naga, > > > + ecc->read_page = pl353_nand_read_page_hwecc; > > > + ecc->size = PL353_NAND_ECC_SIZE; > > > + ecc->write_page = pl353_nand_write_page_hwecc; > > > + pl353_smc_set_ecc_pg_size(mtd->writesize); > > > + switch (mtd->writesize) { > > > + case SZ_512: > > > + case SZ_1K: > > > + case SZ_2K: > > > + pl353_smc_set_ecc_mode(PL353_SMC_ECCMODE_APB); > > > + break; > > > + default: > > > + /* > > > + * The software ECC routines won't work with the > > > + * SMC controller > > > + */ > > > + ecc->calculate = nand_calculate_ecc; > > > + ecc->correct = nand_correct_data; > > > + ecc->size = 256; > > > + break; > > > + } > > > + if (mtd->writesize <= SZ_512) > > > + xnand->addr_cycles = 1; > > > + else > > > + xnand->addr_cycles = 2; > > > + > > > + if (chip->options & NAND_ROW_ADDR_3) > > > + xnand->addr_cycles += 3; > > > + else > > > + xnand->addr_cycles += 2; > > > + > > > + if (mtd->oobsize == 16) > > > + mtd_set_ooblayout(mtd, &pl353_ecc_ooblayout16_ops); > > > + else if (mtd->oobsize == 64) > > > + mtd_set_ooblayout(mtd, &pl353_ecc_ooblayout64_ops); > > > > else? > You mean to say, add an error condition? I do. > > > > > + } > > > +} > > > + > > > +/** > > > + * pl353_nand_probe - Probe method for the NAND driver > > > + * @pdev: Pointer to the platform_device structure > > > + * > > > + * This function initializes the driver data structures and the hardware. > > > + * > > > + * Return: 0 on success or error value on failure > > > + */ > > > +static int pl353_nand_probe(struct platform_device *pdev) { > > > + struct pl353_nand_info *xnand; > > > > xnand is a strange name, more and more because its a bout NAND controller data, not NAND > > chip. > We added this name to represent Xilinx Nand(xnand), > > I see where the x comes from. Maybe just nfc (for NAND flash controller) or xnfc if you prefer. What I want is to clearly make the distinction between what is a NAND chip, what is a NAND controller. > > > + struct mtd_info *mtd; > > > + struct nand_chip *nand_chip; > > > > This one you can call it just "nand" or "chip". > Ok, I will update. > > > > > > + struct resource *res; > > > + > > > + xnand = devm_kzalloc(&pdev->dev, sizeof(*xnand), GFP_KERNEL); > > > + if (!xnand) > > > + return -ENOMEM; > > > + > > > + /* Map physical address of NAND flash */ > > > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > > + xnand->nand_base = devm_ioremap_resource(&pdev->dev, res); > > > + if (IS_ERR(xnand->nand_base)) > > > + return PTR_ERR(xnand->nand_base); > > > + > > > + nand_chip = &xnand->chip; > > > + mtd = nand_to_mtd(nand_chip); > > > + nand_chip->exec_op = pl353_nfc_exec_op; > > > + nand_set_controller_data(nand_chip, xnand); > > > + mtd->priv = nand_chip; > > > + mtd->owner = THIS_MODULE; > > > + mtd->name = PL353_NAND_DRIVER_NAME; > > > > A label property in the DT might overwrite this value. > Could you please explain a bit more ? > I meant something like this: https://elixir.bootlin.com/linux/latest/source/drivers/mtd/nand/raw/marvell_nand.c#L2515 Thanks, Miquèl