From patchwork Wed Jun 27 13:16:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Bugalski X-Patchwork-Id: 935486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qGV39NAY"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VAzbFXq3"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41G3NF0LNqz9s2R for ; Wed, 27 Jun 2018 23:17:01 +1000 (AEST) 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: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:In-Reply-To: References:List-Owner; bh=RTMT+2J3e33FyhgIgT6RAu1H28dBNvMjEA9FJJL1YXA=; b=qGV 39NAYK+rYy6fWQUhmw+6ri+ft1gdOq/3CZY4P0nThSs99NPXq4VRki8g448+ayyTJvu2eC3tcPrEw ixKdXDz8jjxGZcgzzd6ro1g+hsrQA0m3JBuMggiN8A04fujPk9c+wMt21y9ySGJz1c9KUhtaakq7v 6QhkCyYfM5HwuYgdX2bS+8CD8uwJDOoPnffVd8VbJ4yCe8kYWGPbUbVR4s3A6Klj1Ko6JipqkJz4D MBVviYSenm21AQiNgbpSlRhF94OFpnshRKs34tvullthfEyoXzMrlJ8fbXo6BPx0Y4ptPGvik1yNx Z3g07Q1WIo59l+61UpznJiRqFpiEh4A==; 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 1fYAJW-0007TS-Jm; Wed, 27 Jun 2018 13:16:50 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYAJB-0007Fd-J0; Wed, 27 Jun 2018 13:16:31 +0000 Received: by mail-ed1-x544.google.com with SMTP id t3-v6so3079299eds.3; Wed, 27 Jun 2018 06:16:19 -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; bh=enj+RknWQFZPQt6GKnAK5dY7dJqtJcc0WQt0IHvtgSI=; b=VAzbFXq3IiNICMm1VAPuyVO5zatfE0Xkvcs2LomrdHTDfcFxg7PlsL0YJXrN0Y5tpG CyF722ahaexALS4LNQSGRW4jV/l/wQH8oSGZQRrpA7RetKFmHlFYNIVrvaVRYb716Qg4 XINKLnwf1C/QHXM/1rmwNLCoSigsrVC14LfF1vvKXDi9b+jl7OCCeAppxpAXTpmg4M95 DJZuD25paKsi/tfHPmJlyOZtyTBM7wq72WpjdCWH65+T50+eiMNsGs6VQuewCka6UbdR DmMVuiEWRX6qtTfyxjsseXg8wOwBhQ9XRpsxFZYvZGjz8RWoqOAckFZ4tBXGmFIlZ3Wq tsZg== 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; bh=enj+RknWQFZPQt6GKnAK5dY7dJqtJcc0WQt0IHvtgSI=; b=MpfW29uRQIm97BdAgKfBwvI6f/uekm+k+44XrxDvsdzBmqB6cCZ+OWmCnwi7oDgW3H lufs71XxP2pm6x+kzCVV6N1MwBATpS3LdHMonEvZ35rsZf5/WUvhnJtVaJTqjtOCZ1PU ej11TfhDnJc/KvvG/Ua2eCOkjHQ6b6bwU/IO1J/ulyB4ZP1uw1aj89rlGPAFJwPmbsGa CExZj2H/l+suN43zSbHQn2rjJdtzSxL83UsJaStQFlYUBc5NbNxgvSmaK/yRhWeca4Qo 76ugfNYasUcK87sHCcwQioEaqkTP6i6Mqa/lOIKzx2ONp+Hg3MwHuws4kW98P4AwWfHo t2HA== X-Gm-Message-State: APt69E27SnR4XFvQxJ0gAMjpemxuUBhYGtPcZyBmIhawqQLw6+fF+pV0 156V2Xzm7wLKnWmJ4iiB1w== X-Google-Smtp-Source: AAOMgpdnzO0rEazg1vzj1HzQegg4+LYS0GcDkhcnKCZRuk8XgYFKHUwUgFbPohWyrXKe5GAtq4ELhw== X-Received: by 2002:aa7:d788:: with SMTP id s8-v6mr5609584edq.228.1530105377822; Wed, 27 Jun 2018 06:16:17 -0700 (PDT) Received: from carbonite.sagemdenmark.dk ([130.228.251.5]) by smtp.gmail.com with ESMTPSA id i34-v6sm1953000edc.29.2018.06.27.06.16.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 06:16:17 -0700 (PDT) From: Piotr Bugalski To: Mark Brown , linux-spi@vger.kernel.org, David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [RFC PATCH v2 0/6] New QuadSPI driver for Atmel SAMA5D2 Date: Wed, 27 Jun 2018 15:16:03 +0200 Message-Id: <20180627131609.13681-1-bugalski.piotr@gmail.com> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180627_061629_674563_B740B199 X-CRM114-Status: GOOD ( 17.20 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:544 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (bugalski.piotr[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Alexandre Belloni , Tudor Ambarus , Cyrille Pitchen , Nicolas Ferre , Rob Herring , Piotr Bugalski MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hello, Atmel SAMA5D2 is equipped with two QSPI interfaces. These interfaces can work as in SPI-compatible mode or use two / four lines to improve communication speed. At the moment there is QSPI driver strongly tied to NOR-flash memory and MTD subsystem. Intention of this change is to provide new driver which will not be tied to MTD and allows using QSPI with NAND-flash memory or other peripherals New spi-mem API provides abstraction layer which can disconnect QSPI from MTD. This driver doesn't support regular SPI interface, it should be used with spi-mem interface only. Unfortunately SAMA5D2 hardware by default supports only NOR-flash memory. It allows 24- and 32-bit addressing while NAND-flash requires 16-bit long. To workaround hardware limitation driver is a bit more complicated. Request to spi-mem contains three fiels: opcode (command), address, dummy bytes. SAMA5D2 QSPI hardware supports opcode, address, dummy and option byte where address field can only be 24- or 32- bytes long. Handling 8-bits long addresses is done using option field. For 16-bits address behaviour depends of number of requested dummy bits. If there are 8 or more dummy cycles, address is shifted and sent with first dummy byte. Otherwise opcode is disabled and first byte of address contains command opcode (works only if opcode and address use the same buswidth). The limitation is when 16-bit address is used without enough dummy cycles and opcode is using different buswidth than address. Other modes are supported with described workaround. It looks like hardware has some limitation in performance. The same issue exists in current QSPI driver (MTD/nor-flash) and soft-pack (bare-metal library from Atmel). Without using DMA read speed is much worse than maximum bandwidth (efficiency 30-40%). Any help with performance improvement is highly welcome, especially for NAND-flash memories which offers higher capacity than NOR-flash used with previous driver. Best Regards, Piotr v2 changes: - driver is now replacement of existing atmel-quadspi - code was re-written to follow original code structure - deinitialization order fixed - empty atmel_qspi_adjust_op_size function removed - code formatting fixes - use spi_device->max_speed_hz to get spi speed - spi freqency set in spi_controller->setup() hook - address range checkng for 4-bytes addressing - use timeout to avoid infinite waiting Piotr Bugalski (6): mtd: spi-nor: atmel-quaspi: Typo fix mtd: spi-nor: atmel-quadspi: Add spi-mem support to atmel-quadspi mtd: spi-nor: atmel-quadspi: Use spi-mem interface for atmel-quadspi driver mtd: spi-nor: atmel-quadspi: Remove unused code from atmel-quadspi driver spi: Add QuadSPI driver for Atmel SAMA5D2 dt-bindings: spi: QuadSPI driver for Atmel SAMA5D2 .../bindings/{mtd => spi}/atmel-quadspi.txt | 0 drivers/mtd/spi-nor/Kconfig | 9 - drivers/mtd/spi-nor/Makefile | 1 - drivers/spi/Kconfig | 9 + drivers/spi/Makefile | 1 + drivers/{mtd/spi-nor => spi}/atmel-quadspi.c | 529 ++++++--------------- 6 files changed, 155 insertions(+), 394 deletions(-) rename Documentation/devicetree/bindings/{mtd => spi}/atmel-quadspi.txt (100%) rename drivers/{mtd/spi-nor => spi}/atmel-quadspi.c (52%)