From patchwork Tue Mar 22 07:38:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 600491 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qTlP33rnLz9s5l for ; Tue, 22 Mar 2016 18:55:35 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A46BAA79D2; Tue, 22 Mar 2016 08:48:07 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hdUekdLYcjTq; Tue, 22 Mar 2016 08:48:07 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9E3ACB37F4; Tue, 22 Mar 2016 08:47:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0E72CA7777 for ; Tue, 22 Mar 2016 08:45:48 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9CF7_AQcZ4Bb for ; Tue, 22 Mar 2016 08:45:47 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by theia.denx.de (Postfix) with ESMTPS id AF0BFA78AE for ; Tue, 22 Mar 2016 08:44:56 +0100 (CET) Received: by mail-pf0-f194.google.com with SMTP id x3so34318025pfb.0 for ; Tue, 22 Mar 2016 00:44:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hadjbGP3RKVCOnFcM2FOL/zQmTcjTwchdpNla6lAZNU=; b=bECAY4BsVZPk/PfG45jGmmPquSOpGnISnxpjvzSlfR6F50YCsidQEqQDhFLuPajhEq ijGx5bi0TeGY384olWcxhHY9x+F8GaQ7N75C8XAsP3EG1dr3WCsYTmdqeZanSWOXbPGP 3hEdSpHGBFVPylCJc+Nu1Yk9FqdFiOnewJL9qu/T237G5I6+UQBtL4Qv8kL0SaZPpbGP f8WKcblfXlnDsWUZ4BBnGtwgCqmYm4X8AmC5YIT8i8gSj80maFEEy3p51CSLb1XK9q89 4LLpIShHifNqMESnecG0Ak//OzGM6BJY83mO/e3d6JB3KAR0vIVfF4AWm0EzDvI+ni7K 7ogQ== X-Gm-Message-State: AD7BkJKhMWwkENEx/RGPtjDaArlf1vAFB8clDblHC20t1aXo+M1Leg+TIt3W9rzf9bLJPQ== X-Received: by 10.66.147.74 with SMTP id ti10mr52569317pab.128.1458632695422; Tue, 22 Mar 2016 00:44:55 -0700 (PDT) Received: from jteki-Latitude-E7450.amcc.com ([182.73.239.130]) by smtp.gmail.com with ESMTPSA id ko9sm45814957pab.37.2016.03.22.00.44.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Mar 2016 00:44:54 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Date: Tue, 22 Mar 2016 13:08:31 +0530 Message-Id: <1458632319-24866-79-git-send-email-jteki@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458632319-24866-1-git-send-email-jteki@openedev.com> References: <1458632319-24866-1-git-send-email-jteki@openedev.com> Cc: Michal Simek , Siva Durga Prasad Paladugu , Jagan Teki Subject: [U-Boot] [PATCH v7 79/87] mtd: spi-nor: Add m25p_cmdsz X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Added m25p_cmdsz for finding command size based on the addr_width. Cc: Simon Glass Cc: Bin Meng Cc: Mugunthan V N Cc: Michal Simek Cc: Siva Durga Prasad Paladugu Signed-off-by: Jagan Teki --- drivers/mtd/spi-nor/m25p80.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c index 266407f..42c5a96 100644 --- a/drivers/mtd/spi-nor/m25p80.c +++ b/drivers/mtd/spi-nor/m25p80.c @@ -36,6 +36,11 @@ static void m25p_addr2cmd(struct spi_nor *nor, unsigned int addr, u8 *cmd) cmd[4] = addr >> (nor->addr_width * 8 - 32); } +static int m25p_cmdsz(struct spi_nor *nor) +{ + return 1 + nor->addr_width; +} + static int m25p80_read_reg(struct spi_nor *nor, u8 cmd, u8 *val, int len) { struct m25p *flash = nor->priv; @@ -142,8 +147,9 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len, if (nor->flags & SNOR_F_U_PAGE) spi->flags |= SPI_XFER_U_PAGE; - ret = spi_write_then_read(spi, flash->command, 4 + nor->read_dummy, - NULL, buf, len); + ret = spi_write_then_read(spi, flash->command, + m25p_cmdsz(nor) + nor->read_dummy, NULL, + buf, len); if (ret < 0) { debug("m25p80: error %d reading %x\n", ret, flash->command[0]); return ret; @@ -159,7 +165,7 @@ static int m25p80_write(struct spi_nor *nor, loff_t to, size_t len, { struct m25p *flash = nor->priv; struct spi_slave *spi = flash->spi; - int cmd_sz = 4; + int cmd_sz = m25p_cmdsz(nor); int ret; ret = spi_claim_bus(spi); @@ -213,7 +219,8 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset) debug("m25p80: erase %2x %2x %2x %2x (%llx)\n", flash->command[0], flash->command[1], flash->command[2], flash->command[3], offset); - ret = spi_write_then_read(spi, flash->command, 4, NULL, NULL, 0); + ret = spi_write_then_read(spi, flash->command, m25p_cmdsz(nor), + NULL, NULL, 0); if (ret < 0) { debug("m25p80: error %d writing %x\n", ret, flash->command[0]); return ret;