From patchwork Tue Mar 22 07:37:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 600442 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 3qTlBl6qz9z9s5l for ; Tue, 22 Mar 2016 18:46:39 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B6AC4A7808; Tue, 22 Mar 2016 08:43:13 +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 504cNulT8QZ8; Tue, 22 Mar 2016 08:43:13 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 37476A7781; Tue, 22 Mar 2016 08:42:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2CBAB4B91E for ; Tue, 22 Mar 2016 08:42:28 +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 9NJ0WrsOjtHt for ; Tue, 22 Mar 2016 08:42:28 +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-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by theia.denx.de (Postfix) with ESMTPS id B2A42A76E9 for ; Tue, 22 Mar 2016 08:41:52 +0100 (CET) Received: by mail-pf0-f193.google.com with SMTP id q129so34865540pfb.3 for ; Tue, 22 Mar 2016 00:41:52 -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=KAbbMkOh87J5w4eKPvVm3rE5TmKYObAgo3rLNf2j+S0=; b=ig4hLqIQZ2DSt9zNk9vAIGzOGhjPMiwmHQj3RfQHS9gbQP+E7FKSxtT//l9QGY0EVV ejvy77IsoQ3cpnHASam43RTx58f0Pr2QxP2p1N9vBooND1tr1oFLhyV85UbAayA9i9d+ rdvdcGkVgTbeWJ/dqz/TfNpYZ1jELIj71+pP131pZsHZXtEcc7e7JHlpyBPJmcgjiJBt bWXkp9crRmbS0uOSQqKxGCUGD/f4DflqctfHsfOwQGOpPGL2P1hjhyQc3NjxgIoRMrvG 8espsmwmP9+czBFktByawykNfV0IzQzz6h/DdsDZ/N3viOOmaNJRyNm/ET/cKIr/KDOP jnQQ== X-Gm-Message-State: AD7BkJKAuY9fuWdUWn58CxLYPHJLOE8sLertZwzS8qqZnhVzdQO69IsBzxMQCjzD2KKqpQ== X-Received: by 10.98.10.29 with SMTP id s29mr45425752pfi.166.1458632511304; Tue, 22 Mar 2016 00:41:51 -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.41.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Mar 2016 00:41:50 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Date: Tue, 22 Mar 2016 13:07:48 +0530 Message-Id: <1458632319-24866-36-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: Jagan Teki Subject: [U-Boot] [PATCH v7 36/87] mtd: dataflash: Use spi_write_then_read 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" Use spi_write_then_read call from spi layer for dataflash write and then read calling. Cc: Bin Meng Cc: Simon Glass Cc: York Sun Signed-off-by: Jagan Teki --- drivers/mtd/spi-nor/sf_dataflash.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/spi-nor/sf_dataflash.c b/drivers/mtd/spi-nor/sf_dataflash.c index 722ab7e..525af0a 100644 --- a/drivers/mtd/spi-nor/sf_dataflash.c +++ b/drivers/mtd/spi-nor/sf_dataflash.c @@ -84,12 +84,12 @@ struct dataflash { static inline int dataflash_status(struct spi_slave *spi) { int ret; - u8 status; + u8 cmd = OP_READ_STATUS, status; /* * NOTE: at45db321c over 25 MHz wants to write * a dummy byte after the opcode... */ - ret = spi_flash_cmd(spi, OP_READ_STATUS, &status, 1); + ret = spi_write_then_read(spi, &cmd, 1, NULL, &status, 1); return ret ? -EIO : status; } @@ -171,7 +171,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) command[0], command[1], command[2], command[3], pageaddr); - status = spi_flash_cmd_write(spi, command, 4, NULL, 0); + status = spi_write_then_read(spi, command, 4, NULL, NULL, 0); if (status < 0) { debug("%s: erase send command error!\n", mtd->name); return -EIO; @@ -247,7 +247,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len, command[3] = (uint8_t)(addr >> 0); /* plus 4 "don't care" bytes, command len: 4 + 4 "don't care" bytes */ - status = spi_flash_cmd_read(spi, command, 8, buf, len); + status = spi_write_then_read(spi, command, 8, NULL, buf, len); if (status >= 0) { *retlen = len - 8; status = 0; @@ -327,7 +327,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, debug("TRANSFER: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]); - status = spi_flash_cmd_write(spi, command, 4, NULL, 0); + status = spi_write_then_read(spi, command, 4, NULL, NULL, 0); if (status < 0) { debug("%s: write(name); @@ -352,8 +352,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, debug("PROGRAM: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]); - status = spi_flash_cmd_write(spi, command, - 4, writebuf, writelen); + status = spi_write_then_read(spi, command, 4, + writebuf, NULL, writelen); if (status < 0) { debug("%s: write send command error!\n", mtd->name); return -EIO; @@ -376,8 +376,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, debug("COMPARE: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]); - status = spi_flash_cmd_write(spi, command, - 4, writebuf, writelen); + status = spi_write_then_read(spi, command, 4, + writebuf, NULL, writelen); if (status < 0) { debug("%s: write(compare) send command error!\n", mtd->name); @@ -519,6 +519,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi) uint8_t id[5]; uint32_t jedec; struct flash_info *info; + u8 cmd = CMD_READ_ID; int status; /* @@ -530,7 +531,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi) * That's not an error; only rev C and newer chips handle it, and * only Atmel sells these chips. */ - tmp = spi_flash_cmd(spi, CMD_READ_ID, id, sizeof(id)); + tmp = spi_write_then_read(spi, &cmd, 1, NULL, id, sizeof(id)); if (tmp < 0) { printf("dataflash: error %d reading JEDEC ID\n", tmp); return ERR_PTR(tmp);