Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2383652ybl; Thu, 9 Jan 2020 11:47:29 -0800 (PST) X-Google-Smtp-Source: APXvYqyhCTlmD7fygHbff6reh7YuAKnZ5LXss5IHLvA0xHX8MM4kfMewKavzErZy2A65isHhLX6C X-Received: by 2002:aca:5490:: with SMTP id i138mr4569896oib.69.1578599249297; Thu, 09 Jan 2020 11:47:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578599249; cv=none; d=google.com; s=arc-20160816; b=a7ZVaaUYcbSZOdDF0r3SyyJk5vQvERtm6sYoHWGxlgx16IlkSrqOevUYvrs4hh/Z3i of8lo6OYZuiLfdpJp9YSzlMO44iVqrCnFTw3GnAggp1aVcARyFxfKy3fUQ89/A3w8mEB BlTVS0sFCkDUzBJQTaZkb6hAXj3TZrOshfAoT9lluI09sX73uR95z5z50o2aRoj3Qm/B 9ckcCI4jPgBt26M5GeNHlD2PDx+61YY1v0QFRrjgigp5A4fK2o+O1IwAEk6RRlOw+Lic pplLeSnRu1QfpNrU0AbTzRjBLJfEnopA05O1eUtHwPk20ijn+5tYgd0VMnYSlOjpAuaL nXxQ== 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; bh=b0oa8YgZ5uyvat5U1jDNLsAlJ6Nm0qdIfGPcv8nRxiI=; b=BtDcOb9M07RVPjhW4yXqmY/jaGIA9KOSdoveQOWlOVKWwo7JrXsAZW4IVQcoYyyFxu 7suxdShNJqBWjTCx3D9NWBQSQEN4lVHZ02oTR+5O+LCMhBejoJLE8RiJy6x+jc3CiAbs ZbnAJ3FX4swj91aQwW5FZavQLL57kpKozluNL4uFOR/ohzVhl6cm8PHok2kzBO6fTf+Z ZFCBp4NCzKpCaE+XlGy0ar0hxcmsSuEAIr2/82n9SH7KJWhv3REVEGdAOpWRxxJIQx6c 9GXwMQnSKDKnjlRWln7xaGKAf7aFIY/WFDURAsClQmmPcsa7TLEvLJSIl435PZvPFriq 5k8g== 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 s64si4155319oig.147.2020.01.09.11.47.17; Thu, 09 Jan 2020 11:47:29 -0800 (PST) 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 S2387503AbgAIQKS convert rfc822-to-8bit (ORCPT + 99 others); Thu, 9 Jan 2020 11:10:18 -0500 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:39659 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387494AbgAIQKR (ORCPT ); Thu, 9 Jan 2020 11:10:17 -0500 X-Originating-IP: 91.224.148.103 Received: from xps13 (unknown [91.224.148.103]) (Authenticated sender: miquel.raynal@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 3A6C620017; Thu, 9 Jan 2020 16:10:15 +0000 (UTC) Date: Thu, 9 Jan 2020 17:10:14 +0100 From: Miquel Raynal To: Kamal Dasu Cc: linux-mtd@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org, Brian Norris , Richard Weinberger , David Woodhouse , Marek Vasut , Vignesh Raghavendra Subject: Re: [PATCH 3/3] mtd: rawnand: brcmnand: Add support for flash-edu for dma transfers Message-ID: <20200109171014.527e6d5d@xps13> In-Reply-To: <20191120182153.29732-3-kdasu.kdev@gmail.com> References: <20191120182153.29732-1-kdasu.kdev@gmail.com> <20191120182153.29732-3-kdasu.kdev@gmail.com> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; 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 Kamal, Kamal Dasu wrote on Wed, 20 Nov 2019 13:20:59 -0500: > Legacy mips soc platforms that have controller v5.0 and 6.0 use > flash-edu block for dma transfers. This change adds support for > nand dma transfers using the EDU block. > > Signed-off-by: Kamal Dasu I don't have the patch 2/3 in my mailbox :-/ Can you please resend with the right numbering or Cc myself on the 2nd? Otherwise, minor comments below :) > --- > drivers/mtd/nand/raw/brcmnand/brcmnand.c | 269 ++++++++++++++++++++++- > 1 file changed, 263 insertions(+), 6 deletions(-) [...] > +/* edu irq */ > +static irqreturn_t brcmnand_edu_irq(int irq, void *data) > +{ > + struct brcmnand_controller *ctrl = data; > + > + if (ctrl->edu_count) { > + ctrl->edu_count--; > + while (!edu_readl(ctrl, EDU_DONE)) > + udelay(1); > + edu_writel(ctrl, EDU_DONE, 0); > + (void)edu_readl(ctrl, EDU_DONE); Why this cast? (and all the others) > + } > + > + if (ctrl->edu_count) { > + ctrl->edu_dram_addr += FC_BYTES; > + ctrl->edu_ext_addr += FC_BYTES; > + > + edu_writel(ctrl, EDU_DRAM_ADDR, (u32)ctrl->edu_dram_addr); > + (void)edu_readl(ctrl, EDU_DRAM_ADDR); > + edu_writel(ctrl, EDU_EXT_ADDR, ctrl->edu_ext_addr); > + (void)edu_readl(ctrl, EDU_EXT_ADDR); [...] > > @@ -2561,6 +2767,7 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc) > > init_completion(&ctrl->done); > init_completion(&ctrl->dma_done); > + init_completion(&ctrl->edu_done); > nand_controller_init(&ctrl->controller); > ctrl->controller.ops = &brcmnand_controller_ops; > INIT_LIST_HEAD(&ctrl->host_list); > @@ -2650,6 +2857,56 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc) > dev_info(dev, "enabling FLASH_DMA\n"); > } > > + /* use EDU DMA only no FLASH_DMA present */ > + if (has_flash_dma(ctrl)) > + res = 0; > + else > + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, > + "flash-edu"); Can we simplify this block? > + > + if (res) { What about a dedicated helper to do the EDU configuration only? > + ctrl->edu_base = devm_ioremap_resource(dev, res); > + if (IS_ERR(ctrl->edu_base)) > + return PTR_ERR(ctrl->edu_base); > + > + ctrl->edu_offsets = edu_regs; > + > + edu_writel(ctrl, EDU_CONFIG, EDU_CONFIG_MODE_NAND | > + EDU_CONFIG_SWAP_CFG); > + (void)edu_readl(ctrl, EDU_CONFIG); > + > + /* initialize edu */ > + edu_writel(ctrl, EDU_ERR_STATUS, 0); > + edu_writel(ctrl, EDU_DONE, 0); > + (void)edu_readl(ctrl, EDU_DONE); > + > + ctrl->edu_irq = platform_get_irq(pdev, 1); > + if ((int)ctrl->edu_irq < 0) { > + dev_warn(dev, > + "FLASH EDU enabled, using ctlrdy irq\n"); > + } else { > + ret = devm_request_irq(dev, ctrl->edu_irq, > + brcmnand_edu_irq, 0, > + "brcmnand-edu", ctrl); > + if (ret < 0) { > + dev_err(dev, "can't allocate IRQ %d: error %d\n", > + ctrl->edu_irq, ret); > + return ret; > + } > + > + dev_info(dev, "FLASH EDU enabled using irq %u\n", > + ctrl->edu_irq); > + } > + } > + > + /* set the appropriate dma transfer function to call */ > + if (has_flash_dma(ctrl)) > + ctrl->dma_trans = brcmnand_dma_trans; > + else if (has_edu(ctrl)) > + ctrl->dma_trans = brcmnand_edu_trans; > + else > + ctrl->dma_trans = NULL; > + > /* Disable automatic device ID config, direct addressing */ > brcmnand_rmw_reg(ctrl, BRCMNAND_CS_SELECT, > CS_SELECT_AUTO_DEVICE_ID_CFG | 0xff, 0, 0); Thanks, Miquèl