From patchwork Fri Sep 4 08:29:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 7120811 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 479CABEEC1 for ; Fri, 4 Sep 2015 08:33:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58DD22073D for ; Fri, 4 Sep 2015 08:33:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1240B20888 for ; Fri, 4 Sep 2015 08:33:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932740AbbIDIbt (ORCPT ); Fri, 4 Sep 2015 04:31:49 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:37778 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932681AbbIDIay (ORCPT ); Fri, 4 Sep 2015 04:30:54 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id t848UFd5030852; Fri, 4 Sep 2015 03:30:15 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t848UFXS023463; Fri, 4 Sep 2015 03:30:15 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Fri, 4 Sep 2015 03:30:14 -0500 Received: from uda0132425.apr.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t848U6ww021698; Fri, 4 Sep 2015 03:30:11 -0500 From: Vignesh R To: Benoit Cousson , Tony Lindgren , Russell King , David Woodhouse , Brian Norris , Mark Brown , CC: , , , , , , Vignesh R Subject: [PATCH 1/5] spi: introduce mmap read support for spi flash devices Date: Fri, 4 Sep 2015 13:59:58 +0530 Message-ID: <1441355402-6837-2-git-send-email-vigneshr@ti.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: <1441355402-6837-1-git-send-email-vigneshr@ti.com> References: <1441355402-6837-1-git-send-email-vigneshr@ti.com> MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In addition to providing direct access to SPI bus, some spi controller hardwares (like ti-qspi) provide special memory mapped port to accesses SPI flash devices in order to increase read performance. This means the controller can automatically send the SPI signals required to read data from the SPI flash device. For this, spi controller needs to know flash specific information like read command to use, dummy bytes and address width. Once these settings are populated in hardware registers, any read accesses to flash's memory map region(SoC specific) through memcpy or mem-to-mem DMA copy will be handled by controller hardware. The hardware will automatically generate spi signals required to read data from flash and present it to CPU or DMA engine. Introduce spi_mtd_mmap_read() method to support memory mapped read over SPI flash devices. SPI master drivers can implement this method to support memory mapped read interfaces. m25p80 flash driver and other flash drivers can call this to request memory mapped read. The interface should only be used mtd flashes and cannot be used with other spi devices. Signed-off-by: Vignesh R --- include/linux/spi/spi.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index d673072346f2..b74a3f169fc2 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -293,6 +293,23 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) * @handle_err: the subsystem calls the driver to handle an error that occurs * in the generic implementation of transfer_one_message(). * @unprepare_message: undo any work done by prepare_message(). + * @spi_mtd_mmap_read: some spi-controller hardwares provide memory + * mapped interface to communicate with mtd flashes. + * For this, spi controller needs to know flash + * memory settings like read command to use, dummy + * bytes and address width. Once these settings are + * populated in hardware registers, any read + * accesses to flash's memory map region(as defined + * by SoC) through memcpy or mem-to-mem DMA copy + * will be handled by controller hardware. The + * hardware will automatically generate spi signals + * required to read data from flash and present it + * to CPU or DMA. SPI master drivers can use this + * callback to implement memory mapped read + * interface. Flash driver (like m25p80) requests + * memory mapped read via this method. The interface + * should only be used mtd flashes and cannot be + * used with other spi devices. * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS * number. Any individual value may be -ENOENT for CS lines that * are not GPIOs (driven by the SPI controller itself). @@ -438,6 +455,10 @@ struct spi_master { struct spi_message *message); int (*unprepare_message)(struct spi_master *master, struct spi_message *message); + int (*spi_mtd_mmap_read)(struct spi_device *spi, + loff_t from, size_t len, size_t *retlen, + u_char *buf, u8 read_opcode, + u8 addr_width, u8 dummy_bytes); /* * These hooks are for drivers that use a generic implementation