Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4036592imm; Mon, 6 Aug 2018 15:33:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcoazoxLj0LIhtggNTW00a9GNxVjBW9M1l4IEhrAxrf+8uLefl6Lm+W5/50y2+Kljs+poGk X-Received: by 2002:a17:902:6b89:: with SMTP id p9-v6mr15513966plk.272.1533594783334; Mon, 06 Aug 2018 15:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533594783; cv=none; d=google.com; s=arc-20160816; b=uIgN9PMwsQepmTUdGOhGgCtreorAvd6jdIqNKVNfzc0EI4Z9Y1vaLoSRoMME5g+kFP 2/tB5pkuE1G3UiTYB1MIL/bg0OEVotmC7z9tqXIWN9Jk5JbwospYjBswuGC4b5oBskZt dz5UhlCdNNVR1NwnFcYmE6rNZY7KmY3tr2VJw9Urtj17Erhd5dCQClYi2i0eFFVdwH/H e/kjcv3vUCL7N0+mEUntHeRtCarc/ra0LIzhHRYDJAHdAKHjdAcbl4PUdELYwAUC2SuK hZSbE8TWpWTssTpbAUQesaqAYu5pOkilsVznlufY/cXUkyhDyMN/Lyz88nOC+8TBq0zW f+qA== 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=kc0UzhE5a74AT1i79aXGGOwb60l9x1wE3g4xDA9GbLE=; b=LnlNdy0TMFZlA3RLm2dGnjozJ9PGZSpp4+fZGG6niizEA8O1JwnJlQOey9WsDLa2PY Qq/ZrTWRRqnCnxb2mwM0S/gh+ZRSlt4gcMTedYk6WwKwa6X5Z00eT1B9lDritdWbyjsF 8yND+DjDaj0a+1rrS2b5m+DLzWBF/ASGDXogBIfYfuPXfMC8sjgwyw1xh5WPESSl6pDU 3BvcFzVLiX5BXWVb9sfgHcvC8koyw147HdzNGMqSwBmdgUypr8uSiHoSg+TqvCQTeGzu VEQRMhF+84jaTHpvAbpvrWTvV4cxpH9LLz+9LcxcLktHsSIUpR4Jad7cENQAO8ra6KLn m9gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aiaJY+wG; 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 a5-v6si10627281plh.312.2018.08.06.15.32.48; Mon, 06 Aug 2018 15:33:03 -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=aiaJY+wG; 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 S2387720AbeHGAkv (ORCPT + 99 others); Mon, 6 Aug 2018 20:40:51 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:46869 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387629AbeHGAku (ORCPT ); Mon, 6 Aug 2018 20:40:50 -0400 Received: by mail-lf1-f67.google.com with SMTP id l16-v6so10176020lfc.13; 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=N+hOcQ3msjWeXmrxi0oyWOEg0GPtF8ZGn5Pkm6W6Q1Rn6ZAvVqiwlv2YuXgr0N2/3R xmkubTD3y49vDiIdluzxF4P/mG4pDSs0mMGA0lc+h5LFZgNt3wQxk2Tdj8TH/af/s6p8 h7c+bGdGgg5xowdhU4KnC4TjAQOgHPzF61ruXV2orzRJTsR75w8Q8bu63JmZLxwcRZhT weeAhVil7LivOGa9PmEjKVbZ5btv8a2INgqfpdQ3gl7/qHYLfz7jqRBQzOn3cAXHt8Rh ST9uagm24eXtSkuHvmtsgQtpEmbIcBdNtcNT25CRSexuI89LH8cDt32ayfZGfSg5WUrR wfTA== X-Gm-Message-State: AOUpUlFXZoCJ3bAsO4ZWw7F9aRuikiSoPFw++8tXd+9ZpShHgD18DmSz wiQ3MJL+xMO3/n/0+t8WMXM= 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 Cc: Jonathan Corbet , Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Tony Lindgren , Aaro Koskinen , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org, linux-doc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik 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> 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. 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); } /* -- 2.16.4