Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp3646232ooa; Mon, 13 Aug 2018 15:37:53 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwRVBvs6OOYHRu5yEp3/kJWruX6PzfB3MgpT/xf+UxaETpYDV43ypj33TH8hfhk4g88H1vA X-Received: by 2002:a62:c182:: with SMTP id i124-v6mr20502808pfg.248.1534199872804; Mon, 13 Aug 2018 15:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534199872; cv=none; d=google.com; s=arc-20160816; b=ihM4CLxg+0NDVrugZ0ojCar2EgeZzJdWMof+HOon+UEgJ94qEewXFUJ4Mb1iw2VmOk FZ2WdShean0Orwl6O3LWAewApqklEatH9dZ1ZwOnLLilg8bh7UsOeosTXd+NQ0dnJnqO ZBPW0eMxK214s6x0UQr+x48D6G3gEpvwIT5DcmZZ+tU08Wd2+4g8+fcSRATuLSWkRUcT 2RuR5DowUvlYVSiABvje36tOXz+UzWEIodMVqeBOXCQg/dTRuFqbX+whASH1vfCShltY WBhPbCajwGQVN/9s51f2omxYWBjq6yty634+eSy/9IoqgQHPVxr4QoL52fa8eMaIiFyu z/uQ== 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:arc-authentication-results; bh=B/J/zSnahygYuOd62zFWNAm0nwwi22qYKgimEpTrnhw=; b=PX81gzNFafpGVEgJ7VQg6R7ItL8IqDFMdTdRS/4mSjNzSo8qk95ebdgJNWzhrQM3P9 cHqZYNYVHellnWuWxzd42pBH6eqPxi3sZCkl8XnFPl1m2wHyT3Xbj0DiQEBXJsdzeP+U wGZOnjyxxNU/pHwf7NttaYzHrXHHJSUZ75Kgz/U7gZYGHTUL+DKG0A8/0Jsu4rQaJ9OY wSTBVUPVBZmymK+2HKe1XLMFI2W8xRa/BULkrJlJe0JayJz2KqTPPHa+eWEWQsIOPG3F PFSoiM3KT+XcQWah6SvC+yanE7EtVELDviOxc8Uuw8kiJm9Zcjr9PBcxGKfTvR136w5I KFfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="PF89NVC/"; 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 a1-v6si15158836pgq.387.2018.08.13.15.37.38; Mon, 13 Aug 2018 15:37:52 -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="PF89NVC/"; 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 S1732376AbeHNBTA (ORCPT + 99 others); Mon, 13 Aug 2018 21:19:00 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:34005 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732316AbeHNBTA (ORCPT ); Mon, 13 Aug 2018 21:19:00 -0400 Received: by mail-lf1-f65.google.com with SMTP id n96-v6so12402339lfi.1; Mon, 13 Aug 2018 15:34:44 -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=B/J/zSnahygYuOd62zFWNAm0nwwi22qYKgimEpTrnhw=; b=PF89NVC/li8IpcQ0ErazLmmrEsPb7epnQb2xS8WZ+rfJAVRgwJilhhqpLwTCDxr6UK QPapuO/Ofrd6A37CTY4VwAvhuvg7zEV11vgne/2bMqvdBaz5HyH7PKyld1gh01DBRtzX u7EBsa35y72ExJYPs4tx1FOpLxtrjdL2RBZfdmLGhG8X4vPu42cOdCIxtKjKYLDnqaVG bk+VO2v4DLut3BUR1avPAQ50uh7GGhLtflUXAWI2edbtaiwKHF651E5CC6OJ37tcJVTx B7N+cVMy2pvs2XU+k4hC9+3N0QwRvyYkid01EQQa/+rU4YTNz3hGbZ5X22F+/ZqqOJ6l p2sg== 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=B/J/zSnahygYuOd62zFWNAm0nwwi22qYKgimEpTrnhw=; b=CBK9s8KPq+E2MDi21nQ1QukMxESYA7XmPZ1x1f8qJ2rVe6x/ggO/0hQD4nCKY31uTQ kv80N23HMfwF3DEbWJnQEPi3ljuBZkBovznHIxTC5DViAMvhnG4uF9yHp+/vREf1dp27 iygKS39jw8lB4Xh436fWsYD/fRoVKJ2f/I5bR5YD6xzBJ9BsX4AURdhOhFMRs/etvvIp 038zUTns+dJ2zRcb43P6PGnDLUsGhJi26wzFmRtLtSs2lKYI2Av4Lgc/XnWCUG/S6ONh ZopKa3HUx0l7m4lp+UuU4YaAhDHVBnoAWVxrXfjdYdEMi4BOpHLV3KsJvGUnsmD/THYB OnSw== X-Gm-Message-State: AOUpUlEUbzDngvxtZdtjdIJuQSDNdw15vUx8cPne9vr8izjUVmcxD9hb pV5EB/90RcasYI6DTC4g3Cs= X-Received: by 2002:a19:b24e:: with SMTP id b75-v6mr11539839lff.11.1534199684031; Mon, 13 Aug 2018 15:34: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 f136-v6sm3572702lfe.71.2018.08.13.15.34.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 15:34:43 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Miquel Raynal Cc: Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Tony Lindgren , Aaro Koskinen , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 5/7] mtd: rawnand: ams-delta: Set port direction when needed Date: Tue, 14 Aug 2018 00:34:46 +0200 Message-Id: <20180813223448.21316-6-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180813223448.21316-1-jmkrzyszt@gmail.com> References: <20180806222918.12644-1-jmkrzyszt@gmail.com> <20180813223448.21316-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. Signed-off-by: Janusz Krzysztofik --- drivers/mtd/nand/raw/ams-delta.c | 59 ++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index 09d6901fc94d..5f9180fe4f8b 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,50 +73,83 @@ static const struct mtd_partition partition_info[] = { .size = 3 * SZ_256K }, }; -static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) +static void ams_delta_write_next_byte(struct mtd_info *mtd, u_char byte) { struct nand_chip *this = mtd_to_nand(mtd); 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->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 mtd_info *mtd) +static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) { - u_char res; struct nand_chip *this = mtd_to_nand(mtd); struct ams_delta_nand *priv = nand_get_controller_data(this); void __iomem *io_base = priv->io_base; + if (priv->data_in) { + writew(0, io_base + OMAP_MPUIO_IO_CNTL); + priv->data_in = false; + } + + ams_delta_write_next_byte(mtd, byte); +} + +static u_char ams_delta_read_next_byte(struct mtd_info *mtd) +{ + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); + u_char res; + gpiod_set_value(priv->gpiod_nre, 0); ndelay(40); - writew(~0, io_base + OMAP_MPUIO_IO_CNTL); + res = readw(this->IO_ADDR_R); + gpiod_set_value(priv->gpiod_nre, 1); return res; } +static u_char ams_delta_read_byte(struct mtd_info *mtd) +{ + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); + void __iomem *io_base = priv->io_base; + + if (!priv->data_in) { + writew(~0, io_base + OMAP_MPUIO_IO_CNTL); + priv->data_in = true; + } + + return ams_delta_read_next_byte(mtd); +} + static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf, int len) { - int i; + int i = 0; + + if (len > 0) + ams_delta_write_byte(mtd, buf[i++]); - for (i=0; i 0) + buf[i++] = ams_delta_read_byte(mtd); - for (i=0; idev, "data GPIO request failed: %d\n", err); goto out_mtd; } + priv->data_in = true; /* Scan to find existence of the device */ err = nand_scan(mtd, 1); -- 2.16.4