From patchwork Fri Dec 6 14:24:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Poddar, Sourav" X-Patchwork-Id: 3298531 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6395D9F373 for ; Fri, 6 Dec 2013 14:26:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 458B820522 for ; Fri, 6 Dec 2013 14:26:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 299E7204FB for ; Fri, 6 Dec 2013 14:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932100Ab3LFO0E (ORCPT ); Fri, 6 Dec 2013 09:26:04 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:34268 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759230Ab3LFO0B (ORCPT ); Fri, 6 Dec 2013 09:26:01 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id rB6EPUTo004130; Fri, 6 Dec 2013 08:25:30 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id rB6EPUWq029635; Fri, 6 Dec 2013 08:25:30 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Fri, 6 Dec 2013 08:25:30 -0600 Received: from a0131647.apr.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id rB6EOqhD000982; Fri, 6 Dec 2013 08:25:27 -0600 From: Sourav Poddar To: , , , CC: , , , , , , Sourav Poddar Subject: [PATCHv2 07/10] drivers: mtd: m25p80: Adapt driver to support memory mapped read. Date: Fri, 6 Dec 2013 19:54:48 +0530 Message-ID: <1386339891-32717-8-git-send-email-sourav.poddar@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1386339891-32717-1-git-send-email-sourav.poddar@ti.com> References: <1386339891-32717-1-git-send-email-sourav.poddar@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.1 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 Adapt driver to do a memory mapped read. Signed-off-by: Sourav Poddar --- v1->v2: - Add a check to Wait for the previous erase/write to finish. - Ensure proper locking drivers/mtd/devices/m25p80.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index b90c7e5..eb75d84 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -109,6 +109,7 @@ struct m25p { u8 program_opcode; u8 *command; enum read_type flash_read; + void __iomem *mem_addr; }; static inline struct m25p *mtd_to_m25p(struct mtd_info *mtd) @@ -515,6 +516,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { struct m25p *flash = mtd_to_m25p(mtd); + struct spi_master *master = flash->spi->master; struct spi_transfer t[2]; struct spi_message m; uint8_t opcode; @@ -523,6 +525,20 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev), __func__, (u32)from, len); + if (master->mmap) { + mutex_lock(&flash->lock); + /* Wait till previous write/erase is done. */ + if (wait_till_ready(flash)) { + mutex_unlock(&flash->lock); + return 1; + } + flash->mem_addr = master->get_buf(master); + memcpy(buf, flash->mem_addr + from, len); + master->put_buf(master); + *retlen = len; + goto out; + } + spi_message_init(&m); memset(t, 0, (sizeof t)); @@ -558,6 +574,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, *retlen = m.actual_length - m25p_cmdsz(flash) - dummy; +out: mutex_unlock(&flash->lock); return 0; @@ -1286,6 +1303,9 @@ static int m25p_probe(struct spi_device *spi) flash->addr_width = 3; } + if (spi->master->configure_from_slave) + m25p80_fill_flash_information(flash); + dev_info(&spi->dev, "%s (%lld Kbytes)\n", id->name, (long long)flash->mtd.size >> 10);