From patchwork Mon Aug 6 22:29:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558017 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 3F0641390 for ; Mon, 6 Aug 2018 22:33:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C354297BF for ; Mon, 6 Aug 2018 22:33:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F60C297CE; Mon, 6 Aug 2018 22:33:41 +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 B2208297BF for ; Mon, 6 Aug 2018 22:33:40 +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=AImdDK5TNZCogFRJzNpTWXM2w15RObpx6RMQbJA3JDo=; b=DM/VKZ4kMoNZTloIjsgnfp/AUj lsx2ZpFXUcHYrqqDGUhSXEfw3YBMI5IgXXQDsALorYVN3uTAu4qgIb9R5uDY51DwN4zEJvQJ7FZTf Hd4axQndiXpUuxpetkpuo9aNRcq0IKpocmo0jCkDpu9M+P9eUFQ8yM+q/K1o0Sn8esbVfpdLKtGSW mR51FaQqNEMBJCcTlbtQAbJh20IfFdXcHyArXWNk50dtTMon+SvXS61UTWtG2oajrssCi9Zk6rKmP dgy3jZFa5dU/cZ/gAcnDmvQRQer/tT4NrvH9oeLz1k5lNbKy8g6VPzuWOPHADmOXphGq7qFNE01cB G/YkTFpQ==; 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 1fmo4G-0003Fy-5c; Mon, 06 Aug 2018 22:33:36 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmo0Y-0005S0-Pd; Mon, 06 Aug 2018 22:29:56 +0000 Received: by mail-lf1-x142.google.com with SMTP id a4-v6so10208222lff.5; Mon, 06 Aug 2018 15:29:38 -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=kc0UzhE5a74AT1i79aXGGOwb60l9x1wE3g4xDA9GbLE=; b=aiaJY+wGP5udMA1gIXrJ03dzpSnoHmM17OF2+mZ0FFuAVAlc7ToGOCaJzEZqj0MzT5 6AI0KU5o+Jpgv+oI1FgxlZg7fc1Hz+RjG6elpcJ5rTa3vs2lLeCDDHxO0XTcREJ0HDiL W+SxYkqYP20qW2KvKNw67HV9tgYxKpIZRftHYwQlmYO9DSu4WOk95QakCnsgCQW7sLbb DqUiMvk0tnlS5Kt4WBTfxcdy+EnCR/iiXm9qZ5SkZns3SBmN4wD0luM2MM/8AYDGH0Qg AFRCUBUkqExs6vRPmWtIXiR1DGLuJGIfXX5mvArvNzgK/PUieR0B/7Mi5c3BEWCz7GRD XNhg== 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=kc0UzhE5a74AT1i79aXGGOwb60l9x1wE3g4xDA9GbLE=; b=T3s7IMFe2fINwprUfJM0m9whTcrOzndqItS7nycFJWhu5Jn7rvjelVFS2D1nzjDs8j TghuOOiR3paTo0OmQfnR3oi48nJwEhsnQ+Nv5mQtW+2OE/DmCCmHZ5ooJJuXEYV3+Wct JTKDp2cfY9fbP3FUEirmvY68niUb0umihOdsJeiOQBk4RZorMrITqajdBKwrOdIKly7Y UNyBLSoROC9LjE9qLRbOxBY4T8YsohBhA2FoWP7u0sfezEEMqq6reJSJ0965Moub6KiQ EHumV+9KwrJpuUYIlEKPZDF+KxLrj06h4aoMDKPXDizoql2dhxQ7WepsaKCwqoj3eJP4 eJow== X-Gm-Message-State: AOUpUlF4o7M5PingA+NhkLr1D7qd3p5rWktIJsF183J3tzzTjPc9qve8 PeoH556Jec1jPZsJhr8R9Qs= X-Google-Smtp-Source: AAOMgpftlgT2LBNt75HgnmEVXCUbyxfdlV1qSGS8i1KDsP4Pv+onp7UCIBniLpb4ZMscgW11lZsMRA== X-Received: by 2002:a19:2c4f:: with SMTP id s76-v6mr13073045lfs.25.1533594577560; Mon, 06 Aug 2018 15:29:37 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:36 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 07/12] mtd: rawnand: ams-delta: Set port direction once per transfer Date: Tue, 7 Aug 2018 00:29:13 +0200 Message-Id: <20180806222918.12644-8-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152947_307918_0E18F142 X-CRM114-Status: GOOD ( 16.43 ) 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, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , 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. Since performance of the driver is completely not acceptable on Amstrad Delta after it has been converted to GPIO bitbang, try to improve things a bit by setting the port direction only on first byte of each transfer. Resulting performance on Amstrad Delta is still far from acceptable. Signed-off-by: Janusz Krzysztofik --- drivers/mtd/nand/raw/ams-delta.c | 58 ++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index 78996ddf82e0..d02c48c013e8 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -69,6 +69,30 @@ static const struct mtd_partition partition_info[] = { .size = 3 * SZ_256K }, }; +static void ams_delta_write_commit(struct ams_delta_nand *priv) +{ + gpiod_set_value(priv->gpiod_nwe, 0); + ndelay(40); + gpiod_set_value(priv->gpiod_nwe, 1); +} + +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); + struct gpio_descs *data_gpiods = priv->data_gpiods; + unsigned long bits = byte; + int i, value_array[data_gpiods->ndescs]; + + for (i = 0; i < data_gpiods->ndescs; i++) + value_array[i] = test_bit(i, &bits); + + gpiod_set_raw_array_value(data_gpiods->ndescs, data_gpiods->desc, + value_array); + + ams_delta_write_commit(priv); +} + static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) { struct nand_chip *this = mtd_to_nand(mtd); @@ -81,12 +105,10 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) gpiod_direction_output_raw(data_gpiods->desc[i], test_bit(i, &bits)); - gpiod_set_value(priv->gpiod_nwe, 0); - ndelay(40); - gpiod_set_value(priv->gpiod_nwe, 1); + ams_delta_write_commit(priv); } -static u_char ams_delta_read_byte(struct mtd_info *mtd) +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); @@ -94,9 +116,6 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd) unsigned long bits = 0; int i, value_array[data_gpiods->ndescs]; - for (i = 0; i < data_gpiods->ndescs; i++) - gpiod_direction_input(data_gpiods->desc[i]); - gpiod_set_value(priv->gpiod_nre, 0); ndelay(40); @@ -112,21 +131,38 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd) return bits; } +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); + struct gpio_descs *data_gpiods = priv->data_gpiods; + int i; + + for (i = 0; i < data_gpiods->ndescs; i++) + gpiod_direction_input(data_gpiods->desc[i]); + + 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; - for (i=0; i 0) + ams_delta_write_byte(mtd, buf[0]); + for (i = 1; i < len; i++) + ams_delta_write_next_byte(mtd, buf[i]); } static void ams_delta_read_buf(struct mtd_info *mtd, u_char *buf, int len) { int i; - for (i=0; i 0) + buf[0] = ams_delta_read_byte(mtd); + for (i = 1; i < len; i++) + buf[i] = ams_delta_read_next_byte(mtd); } /*