Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1291513imm; Wed, 19 Sep 2018 15:54:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY0PgfoqqhmyFcmJbF4ElkCoKTW++YX1VRYvkkacjTqnwLnKTl/tkw/bcZE62MP2YYJv/VH X-Received: by 2002:a63:2c01:: with SMTP id s1-v6mr31932871pgs.367.1537397653277; Wed, 19 Sep 2018 15:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537397653; cv=none; d=google.com; s=arc-20160816; b=A3JJrbz4MrLopJWLuL0op6nxKSBS1WY2saPmtTrbzGboIByYEngCJ1+xCKG465L0R6 jpnr4pGmOshBP/6lo3wDlhbZ7D26x5YuIjhGH3/TXCTvhxNtOWMbNWoqXPxrWZWC5cvN zc+Bs/5H/TumjEc7kYHSCDSRF0VLFESxYpjPDTkZGWn1uVt6MqHAbRmJF1XX5FO+V3n3 321HIRzbAaozJJk7BIBskMLaAlms58ohENolc4Sqe5y3zC33vjZU764NC1bgmuGbVfh9 IIFrzcqcNd/b/peqQQumjlRWpxH8RfdfVbtCHyFG03k+sAx3YLa74DvXkze9ezyf+PWQ Rqmw== 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:dkim-signature; bh=E12Ueqxaf9bzdi7+nmXp2SBaeWRJjKEMYTo5gVLEdTE=; b=aXXlh/oFrp8DQINHVLb0bXxBwoHIbJOc3Z5G9Uv7251wFpWU2oK2xS047qqbGppAv3 W4lZM21f6blj1RshEhpJGC2cEyb7W3Y3z10lJM9X5DkR0EBaPgXdZ+mcYg0WxRtyNfEs okrvQIyA5LyYiTPA8jXC4FtEF5H99LgGfodxA1dAUQuj+8MH4hoLLkbaqSU2B+3elvpi V6tPl23nkweMNl/JM/rj7N+PC1sHFtuFa4jqUfypEEH9zk2g77L13fKBCXGzpoRlJg8/ plVZOsSjlD9QPbb5fV3jTpTjzpuJHTaWz0hCwQq3c7KUa8xcpbByZGPj3jr+kINGrsjP pyhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JYxWjTD6; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h7-v6si22478912plt.258.2018.09.19.15.53.57; Wed, 19 Sep 2018 15:54:13 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JYxWjTD6; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387569AbeITEbz (ORCPT + 99 others); Thu, 20 Sep 2018 00:31:55 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:33075 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726296AbeITEbz (ORCPT ); Thu, 20 Sep 2018 00:31:55 -0400 Received: by mail-lf1-f66.google.com with SMTP id m26-v6so6625789lfb.0 for ; Wed, 19 Sep 2018 15:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=E12Ueqxaf9bzdi7+nmXp2SBaeWRJjKEMYTo5gVLEdTE=; b=JYxWjTD6Yn2huzbVkY/o532fv7cMa3qKrOatxqdRdKEmkUmdsJp1rHtB6MiZ0bgzm8 7M6hjWoin7CM1OlduKW4lNxcs9Fq5Mm9qvnOFNXQ22nhTkv5B4RedGNjTpDKn1z8Z996 B6A1tCIUrOpO9vls3/Ix6pG+Gvc7x8lK+XLUZi3zReVrM/dfnzpDojeNg0RHjOkY7XcW WvHB2k8J4iHAY7gZDmO/TnmyyLnfsb5UlP7PMiVXEMo38g7oZRDX1NK6Tm65OAA/hqNP Yzc77/+wOSGt3K5RkPE75EJcM9EqoaNSGi3jWMfDcxbPiQlbr0JEN4UZWzBXoNKaX08u AVGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=E12Ueqxaf9bzdi7+nmXp2SBaeWRJjKEMYTo5gVLEdTE=; b=ZYE7LZmG7r7T8EXp41tR3xKNyleuU8RpgH0FEXr5k1mM1uHSwY94yVbHvwgN2DDtwZ 8WfIJCS9UDvsdpR0IQVBNs9okGpkUQ0kXhMEzsNJRiEt6QOWoCjYpqNL0nMZLdSSArzU WbPEMFt1Uj8llixRTskNQrumclq7jy07xtEFr3D+rcsXv/FbSLubiLwoXdhdeKribKSC ihlUX0Qa8GmFaYLLXDZyxtc/EFb13ssUJ15fopc3nueoOFBcWCJ+uK+WAbw63ps/91Gg YEVnTr6bebCMhDnQFeIx5hHzWAJo82pDTcHZC4x2TNtLNp7BviAaLVgCAF9VSG87vkgY cYtg== X-Gm-Message-State: APzg51BMu7QNUwhegCsBPcVCH1DEG+phI+mdygFhFF6ezgEKuuOUMdxo qqs8BI2cFUY4COcm3BnkNFo= X-Received: by 2002:a19:1ac8:: with SMTP id a191-v6mr18498884lfa.29.1537397504443; Wed, 19 Sep 2018 15:51:44 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id q22-v6sm1249211lff.10.2018.09.19.15.51.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 15:51:43 -0700 (PDT) From: Janusz Krzysztofik To: Miquel Raynal Cc: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/3] mtd: rawnand: ams-delta: Set port direction when needed Date: Thu, 20 Sep 2018 00:52:55 +0200 Message-Id: <20180919225255.31175-4-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180919225255.31175-1-jmkrzyszt@gmail.com> References: <20180820213904.13475-1-jmkrzyszt@gmail.com> <20180919225255.31175-1-jmkrzyszt@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In its current shape, the driver sets data port direction before each byte read/write operation, even during multi-byte transfers. Improve performance of the driver by setting the port direction only when needed. This optimisation will become particularly important as soon as planned conversion of the driver to GPIO API for data I/O will be implemented. Reviewed-by: Boris Brezillon Signed-off-by: Janusz Krzysztofik --- drivers/mtd/nand/raw/ams-delta.c | 57 ++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index eb2aeadc3b65..5ba180a291eb 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -45,6 +45,7 @@ struct ams_delta_nand { struct gpio_desc *gpiod_ale; struct gpio_desc *gpiod_cle; void __iomem *io_base; + bool data_in; }; /* @@ -72,48 +73,64 @@ static const struct mtd_partition partition_info[] = { .size = 3 * SZ_256K }, }; -static void ams_delta_write_byte(struct nand_chip *this, u_char byte) +static void ams_delta_io_write(struct ams_delta_nand *priv, u_char byte) { - struct ams_delta_nand *priv = nand_get_controller_data(this); - void __iomem *io_base = priv->io_base; - - writew(0, io_base + OMAP_MPUIO_IO_CNTL); - writew(byte, this->legacy.IO_ADDR_W); + writew(byte, priv->nand_chip.legacy.IO_ADDR_W); gpiod_set_value(priv->gpiod_nwe, 0); ndelay(40); gpiod_set_value(priv->gpiod_nwe, 1); } -static u_char ams_delta_read_byte(struct nand_chip *this) +static u_char ams_delta_io_read(struct ams_delta_nand *priv) { u_char res; - struct ams_delta_nand *priv = nand_get_controller_data(this); - void __iomem *io_base = priv->io_base; gpiod_set_value(priv->gpiod_nre, 0); ndelay(40); - writew(~0, io_base + OMAP_MPUIO_IO_CNTL); - res = readw(this->legacy.IO_ADDR_R); + res = readw(priv->nand_chip.legacy.IO_ADDR_R); gpiod_set_value(priv->gpiod_nre, 1); return res; } +static void ams_delta_dir_input(struct ams_delta_nand *priv, bool in) +{ + writew(in ? ~0 : 0, priv->io_base + OMAP_MPUIO_IO_CNTL); + priv->data_in = in; +} + static void ams_delta_write_buf(struct nand_chip *this, const u_char *buf, int len) { + struct ams_delta_nand *priv = nand_get_controller_data(this); int i; - for (i=0; idata_in) + ams_delta_dir_input(priv, false); + + for (i = 0; i < len; i++) + ams_delta_io_write(priv, buf[i]); } static void ams_delta_read_buf(struct nand_chip *this, u_char *buf, int len) { + struct ams_delta_nand *priv = nand_get_controller_data(this); int i; - for (i=0; idata_in) + ams_delta_dir_input(priv, true); + + for (i = 0; i < len; i++) + buf[i] = ams_delta_io_read(priv); +} + +static u_char ams_delta_read_byte(struct nand_chip *this) +{ + u_char res; + + ams_delta_read_buf(this, &res, 1); + + return res; } /* @@ -135,8 +152,11 @@ static void ams_delta_hwcontrol(struct nand_chip *this, int cmd, gpiod_set_value(priv->gpiod_ale, !!(ctrl & NAND_ALE)); } - if (cmd != NAND_CMD_NONE) - ams_delta_write_byte(this, cmd); + if (cmd != NAND_CMD_NONE) { + u_char byte = cmd; + + ams_delta_write_buf(this, &byte, 1); + } } static int ams_delta_nand_ready(struct nand_chip *this) @@ -258,6 +278,9 @@ static int ams_delta_init(struct platform_device *pdev) goto out_mtd; } + /* Initialize data port direction to a known state */ + ams_delta_dir_input(priv, true); + /* Scan to find existence of the device */ err = nand_scan(this, 1); if (err) -- 2.16.4