From patchwork Tue Dec 9 15:29:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 419156 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 78B4F14009B for ; Wed, 10 Dec 2014 02:30:36 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 23BC74B6B5; Tue, 9 Dec 2014 16:30:19 +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 gm+jKxyWKeJZ; Tue, 9 Dec 2014 16:30:18 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6F17A4B6A8; Tue, 9 Dec 2014 16:30:17 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4BC3D4B657 for ; Tue, 9 Dec 2014 16:30:08 +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 SsPaN+AMjekJ for ; Tue, 9 Dec 2014 16:30:08 +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-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) by theia.denx.de (Postfix) with ESMTPS id 1B6664B64D for ; Tue, 9 Dec 2014 16:30:02 +0100 (CET) Received: by mail-pd0-f182.google.com with SMTP id p10so727127pdj.41 for ; Tue, 09 Dec 2014 07:30:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L4WkL/yTaRGUIwp/xcM1FJOR4agmXAflgL1xWzOV4Bs=; b=XvOmxTea3JEl5PFK24b4dxvgAPFnLtxAMcItqTHz4oUUr0VK4NvZpLqhlU21F1iuIx teU2ud0FLczY2gH2pIMFTaKco5GKSlL6na4rvqC/mHQhNPv1w5bM7Hr6utZNDowLJJeg XP5onUs4XfBD/02EF2Ojz20SIZ5Jk8xydr3oxttvsRK05qKuYDVvuIsn+aRcefrUQOMY beohOM2HMi6Zo8PA6J/lr63DeaFRIcyZQteT4S2w2zZfDOaFykG+z8j/Mxit1E95Cv7Q 8rydlKzuoIae90NdgW8O1UaftwmGxnPyCF1HAURrbe27g9o7BLk4jZUufSX8jDy4/ux3 7isQ== X-Received: by 10.66.119.175 with SMTP id kv15mr6725519pab.30.1418139001253; Tue, 09 Dec 2014 07:30:01 -0800 (PST) Received: from localhost.localdomain ([49.248.54.161]) by mx.google.com with ESMTPSA id hs10sm1815318pdb.33.2014.12.09.07.29.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Dec 2014 07:30:00 -0800 (PST) From: Jagannadha Sutradharudu Teki To: u-boot@lists.denx.de Date: Tue, 9 Dec 2014 20:59:39 +0530 Message-Id: <1418138980-2302-4-git-send-email-jagannadh.teki@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418138980-2302-1-git-send-email-jagannadh.teki@gmail.com> References: <1418138980-2302-1-git-send-email-jagannadh.teki@gmail.com> Subject: [U-Boot] [PATCH 3/4] spi: sf: Support byte program for sst spi flash X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Bin Meng Currently if SST flash advertises SST_WP flag in the params table the word program command (ADh) with auto address increment will be used for the flash write op. However some SPI controllers do not support the word program command (like the Intel ICH 7), the byte programm command (02h) has to be used. A new TX operation mode SPI_OPM_TX_BP is introduced for such SPI controller to use byte program op for SST flash. Signed-off-by: Bin Meng Acked-by: Simon Glass Tested-by: Simon Glass --- drivers/mtd/spi/sf_internal.h | 2 ++ drivers/mtd/spi/sf_ops.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 7218e69..fb53cb0 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -110,6 +110,8 @@ enum { int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len, const void *buf); +int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len, + const void *buf); #endif /** diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c index 759231f..34bc54e 100644 --- a/drivers/mtd/spi/sf_ops.c +++ b/drivers/mtd/spi/sf_ops.c @@ -517,4 +517,35 @@ int sst_write_wp(struct spi_flash *flash, u32 offset, size_t len, spi_release_bus(flash->spi); return ret; } + +int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len, + const void *buf) +{ + size_t actual; + int ret; + + ret = spi_claim_bus(flash->spi); + if (ret) { + debug("SF: Unable to claim SPI bus\n"); + return ret; + } + + for (actual = 0; actual < len; actual++) { + ret = sst_byte_write(flash, offset, buf + actual); + if (ret) { + debug("SF: sst byte program failed\n"); + break; + } + offset++; + } + + if (!ret) + ret = spi_flash_cmd_write_disable(flash); + + debug("SF: sst: program %s %zu bytes @ 0x%zx\n", + ret ? "failure" : "success", len, offset - actual); + + spi_release_bus(flash->spi); + return ret; +} #endif