Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6354118imm; Wed, 27 Jun 2018 06:29:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJh32g+2WMWKM1GInqkgh5rPz72ARrvIwaMl+sUhaZwXhX2/qBcQa0FLsmyGK/HJwUFVTZ3 X-Received: by 2002:a65:52cd:: with SMTP id z13-v6mr5214821pgp.357.1530106193590; Wed, 27 Jun 2018 06:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530106193; cv=none; d=google.com; s=arc-20160816; b=Tf6vXfQqSuu1C5sowXpNglc0RMehkSAxJcmEiuc8r2DDhwwswbpVFPUngeQdXB4nor hZfMwu7cfjIHH0BoALnQPGSXdzdJqm27YfIbfhSGyvlt/a1ZhgChbKUJEE6qwfBEZHnH 8bR8TwTIpX7OUNjL/CZiQCBRV7ZfuQjzX2CULVuhmDL0xpgBCOpnSgldw8KakMugqt0N 5DVj4tbN4o9VHxxFI3fgG62Ykml+gvFtTLPW3jmRgZwXctiy1jmX5w79plXpxxQYdKrE i8NfQQ+Xgo9O3ADCsZZnNPgHGxbSt/14QIg2G6ABLOqp7TLde3G2FB/Sk6j1NJliGDgF tKfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=enj+RknWQFZPQt6GKnAK5dY7dJqtJcc0WQt0IHvtgSI=; b=rejUfJn/GutxOijpheN9wJAE/mPF1sP7YIkPyrSo+BNZJZyJNZ+ynacuD4+DhS7K7e o0eJhBqxY5Vw4dBzJK5y1Jx2wnRgtSJHz7oGgxlazOQPFPTaW+49PJlhquiVecAwlIB3 FrFtmr1JkaB2z5hNeNiqihh67eWQ3L7wBBn04LDF1xUL6mZmOTx8swt/I1p90pu3qPTM cZYGCdtJ3ItM7h5NZ2mtG17OItnnWjh+1P5SVXhRH17AfsAN0NHnZw9v1fK2D8oXnAfM JFqlCpB6VPDlzVR8MgKWKF6SI2NWZKARWVs15GbkY6mYknLlfTw/1KrUkS3GNldJCvtw N9zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VAzbFXq3; 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 f12-v6si3653556pgn.459.2018.06.27.06.29.39; Wed, 27 Jun 2018 06:29:53 -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=VAzbFXq3; 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 S1754530AbeF0NQV (ORCPT + 99 others); Wed, 27 Jun 2018 09:16:21 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:36917 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752898AbeF0NQT (ORCPT ); Wed, 27 Jun 2018 09:16:19 -0400 Received: by mail-ed1-f68.google.com with SMTP id v22-v6so3070604edq.4; Wed, 27 Jun 2018 06:16:18 -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=OPaMQGtBhPT5UoUX5bexJSAEzXF1Fdj4U3I04m9jaIHPl5OLuN3YS2xRNRG7y7NsCK 2YDbX0fOsTIytwpJCYelTSnFj5+xrV1vP1ywXSl10RWVirictXKX+oz7CGGquL21M4Jp Hlf0LvyECRQQ29wVBc/r0kdbTA2yMGmFL/F9bQGY5bjB7GUxZOGyCYaU7lUin5OtNNlT yohQjHoniAICPucC6P0Sp0Od73C3IXa+6irByOr3/naZJDmUWVbHlQx6kCLEVZMLgHXp 48qhkMACg1ARtU3yGlATr4GyZ8OtM6X6Ohxr5Or/pptAzL1yVbi3ziYbC0l4X71VB6NX Kctw== X-Gm-Message-State: APt69E2P1DV4lh20QZ+1JnxgDHuF1/XeNz4d/ynPN2ISSeVR0D4qGDL5 ON99YxdMRc8ddaBWYjzvLLnaWc0= 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 Cc: Rob Herring , Mark Rutland , Nicolas Ferre , Alexandre Belloni , Cyrille Pitchen , Tudor Ambarus , Piotr Bugalski 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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%) -- 2.11.0