From patchwork Mon Aug 13 22:34:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10564935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 247831510 for ; Mon, 13 Aug 2018 22:39:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1389A293F7 for ; Mon, 13 Aug 2018 22:39:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 063E2293FE; Mon, 13 Aug 2018 22:39:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A4660293F7 for ; Mon, 13 Aug 2018 22:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=bI/htEoZXRx+X8lFKEtok6EnunNU1hqo2Sg0SC7vNfg=; b=bvNvd/3bxMt6VHhdJCc2uvI2Rp Bt2bmWNbHjHJgX+v89mvCzXEgl9rRKQjloiHDl6aOtTqLaOHJqrySLSOrBMwp2LlAzrqIZqi54AqP LAI8Qi/0r7tepHkM9zflMB/T0zXvScsbOnzWI6T5tZQt/vMgMAjUv/HtVcu/ekd4t7l5ZOD1bF2Gr CiIHFJS4lZf+6N5HTnwz0dPqP9k9dYPyckI5gQR7PseY4Q4fpFGKH9awKw0HyfXRGoYqvFGkVJlKD ie1zde6OLXt3AHTf7ZmfeRR9e8q4Qm+65HDuCGyHEIOF6FDyT7xq8rzEgXgxAVLgpeNh2inzD+XpD QcyL0q3w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpLV0-0005Bg-P6; Mon, 13 Aug 2018 22:39:42 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpLQP-0008Tt-H8; Mon, 13 Aug 2018 22:35:00 +0000 Received: by mail-lf1-x143.google.com with SMTP id a4-v6so12400603lff.5; Mon, 13 Aug 2018 15:34: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=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=V66Vigla4OtEFnUqkeLRdAheobsDzPZCTfVhafxi8NXcEA2j/Y6d7brnQeWx99ksak SFd/j2wpHM4ekvAJ41+7donaMKhqE+gYBfMFcymveh6vAHIU0fmxB9QYwQwA8mnI8ACn cEvuj0xcro4n0pQtP3kN2cS+RZJyb+cc9Nu3wyI1B8P2uJwjMHMydmv8WVRjV4QcyDhC jloe3O0AUr7VdOmbMnr28AFW8R9p24ej+6I9V1VObwqHA2Bmh8tNM51CSQ8MaapZvtpi 0XwxEkhXk4C1zsHt+Vp/+uZwygsl79X2liCxKI3v4nHs1TCjtHWd5T9mA46HjplgIKnD H79Q== X-Gm-Message-State: AOUpUlGebb9t1dF/OuwWmr1SS2LgplBXN7gU+AAS+Llbj30uU8k9HRgC d2xb/oUZe5Z1sjoJksGzhhw= X-Google-Smtp-Source: AA+uWPytJeYZTjY+ej2+dRywqoOTtgJcDNqAk6qWN9h35iJgfGqb9Smkmz4BPnPJhV+n9m7BnIQe1g== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180813_153457_814636_1B19C5DD X-CRM114-Status: GOOD ( 17.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, Aaro Koskinen , Tony Lindgren , Richard Weinberger , Linus Walleij , Janusz Krzysztofik , linux-kernel@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, linux-gpio@vger.kernel.org, Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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);