From patchwork Tue Jun 28 17:38:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 102439 X-Patchwork-Delegate: wd@denx.de 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 2062CB6F59 for ; Wed, 29 Jun 2011 03:40:12 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B4C2A28154; Tue, 28 Jun 2011 19:39:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 FFBBEnYCvyVe; Tue, 28 Jun 2011 19:39:22 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 04A1D2813E; Tue, 28 Jun 2011 19:38:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9AAA7280E9 for ; Tue, 28 Jun 2011 19:38:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 MPRqxDEUgU36 for ; Tue, 28 Jun 2011 19:38:28 +0200 (CEST) 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 smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by theia.denx.de (Postfix) with ESMTPS id 9C80B28082 for ; Tue, 28 Jun 2011 19:38:24 +0200 (CEST) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id B72F41BC0CA for ; Tue, 28 Jun 2011 17:38:20 +0000 (UTC) From: Mike Frysinger To: u-boot@lists.denx.de Date: Tue, 28 Jun 2011 13:38:13 -0400 Message-Id: <1309282694-27103-9-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <1309282694-27103-1-git-send-email-vapier@gentoo.org> References: <1309282694-27103-1-git-send-email-vapier@gentoo.org> Subject: [U-Boot] [PATCH 8/9] sf: sst: support newer standardized flashes X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 Newer SST flashes have dropped the Auto Address Increment (AAI) word programming (WP) modes in favor of the standard page programming mode that most flashes now support. So add a flags field to the different flashes to support both modes with new and old styles. Signed-off-by: Mike Frysinger --- drivers/mtd/spi/sst.c | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi/sst.c b/drivers/mtd/spi/sst.c index d1e8a93..9559c80 100644 --- a/drivers/mtd/spi/sst.c +++ b/drivers/mtd/spi/sst.c @@ -36,8 +36,12 @@ #define SST_SR_AAI (1 << 6) /* Addressing mode */ #define SST_SR_BPL (1 << 7) /* BP bits lock */ +#define SST_FEAT_WP (1 << 0) /* Supports AAI word program */ +#define SST_FEAT_MBP (1 << 1) /* Supports multibyte program */ + struct sst_spi_flash_params { u8 idcode1; + u8 flags; u16 nr_sectors; const char *name; }; @@ -53,41 +57,51 @@ static inline struct sst_spi_flash *to_sst_spi_flash(struct spi_flash *flash) } #define SST_SECTOR_SIZE (4 * 1024) +#define SST_PAGE_SIZE 256 static const struct sst_spi_flash_params sst_spi_flash_table[] = { { .idcode1 = 0x8d, + .flags = SST_FEAT_WP, .nr_sectors = 128, .name = "SST25VF040B", },{ .idcode1 = 0x8e, + .flags = SST_FEAT_WP, .nr_sectors = 256, .name = "SST25VF080B", },{ .idcode1 = 0x41, + .flags = SST_FEAT_WP, .nr_sectors = 512, .name = "SST25VF016B", },{ .idcode1 = 0x4a, + .flags = SST_FEAT_WP, .nr_sectors = 1024, .name = "SST25VF032B", },{ .idcode1 = 0x4b, + .flags = SST_FEAT_MBP, .nr_sectors = 2048, .name = "SST25VF064C", },{ .idcode1 = 0x01, + .flags = SST_FEAT_WP, .nr_sectors = 16, .name = "SST25WF512", },{ .idcode1 = 0x02, + .flags = SST_FEAT_WP, .nr_sectors = 32, .name = "SST25WF010", },{ .idcode1 = 0x03, + .flags = SST_FEAT_WP, .nr_sectors = 64, .name = "SST25WF020", },{ .idcode1 = 0x04, + .flags = SST_FEAT_WP, .nr_sectors = 128, .name = "SST25WF040", }, @@ -137,7 +151,7 @@ sst_byte_write(struct spi_flash *flash, u32 offset, const void *buf) } static int -sst_write(struct spi_flash *flash, u32 offset, size_t len, const void *buf) +sst_write_wp(struct spi_flash *flash, u32 offset, size_t len, const void *buf) { size_t actual, cmd_len; int ret; @@ -257,9 +271,13 @@ spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode) stm->flash.spi = spi; stm->flash.name = params->name; - stm->flash.write = sst_write; + if (stm->params->flags & SST_FEAT_WP) + stm->flash.write = sst_write_wp; + else + stm->flash.write = spi_flash_cmd_write_multi; stm->flash.erase = sst_erase; stm->flash.read = spi_flash_cmd_read_fast; + stm->flash.page_size = SST_PAGE_SIZE; stm->flash.sector_size = SST_SECTOR_SIZE; stm->flash.size = stm->flash.sector_size * params->nr_sectors;