From patchwork Mon Apr 27 15:36:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 465102 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 554CC140318 for ; Tue, 28 Apr 2015 01:37:09 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=hS1CrCeF; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E01CC4BB75; Mon, 27 Apr 2015 17:37:06 +0200 (CEST) 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 J3_cCUFx_yPC; Mon, 27 Apr 2015 17:37:06 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 697F74BB6C; Mon, 27 Apr 2015 17:37:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 78C2D4BB6C for ; Mon, 27 Apr 2015 17:37:04 +0200 (CEST) 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 8NIW7YBWM8HL for ; Mon, 27 Apr 2015 17:37:04 +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 mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by theia.denx.de (Postfix) with ESMTPS id 8C03D4BB6B for ; Mon, 27 Apr 2015 17:36:59 +0200 (CEST) Received: by pabtp1 with SMTP id tp1so132970938pab.2 for ; Mon, 27 Apr 2015 08:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=St6p5LM17MTh7CgaorKETnMUUSKl1VifipI/BLLDfSI=; b=hS1CrCeFthipgG8bPy9kmYqyku/R/E4TBGnz7OY3EcCXWyq4LHKnBHiAozArHkUzBF lPHKiIUhAkKJlTXUYD1KcsB716RUMEYwXii2UZ2TSRZ4sZDonCtLSk3Cxlk6Z4mlZOwc xS4YtBUoEo12BBBWBWdFQ43Wg0rDkrmwPJzOAaStot3HBpveId/v9PWE7x05EapVeUmv 47bnVEqBo2fOGP83bJTkwmwgON8wOC5TEfo+7zFA0DwIo8E5ZVj9yDiugCmO7RbCh6Y0 ZqCgkWEwlLB8pQU76c4swKuedVM7lF1LbRMKLm4AtrFjGtvcAknIH55T1MVBuDOnLd06 t+Jg== X-Received: by 10.66.62.137 with SMTP id y9mr23373206par.71.1430149017718; Mon, 27 Apr 2015 08:36:57 -0700 (PDT) Received: from Jubuntu.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id ud3sm5059050pbc.10.2015.04.27.08.36.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Apr 2015 08:36:56 -0700 (PDT) From: Jagannadha Sutradharudu Teki To: u-boot@lists.denx.de Date: Mon, 27 Apr 2015 21:06:40 +0530 Message-Id: <1430149000-25747-1-git-send-email-jagannadh.teki@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [U-Boot] [PATCH v3] sf: Fix to compute proper sector_size 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" Upto now flash sector_size is assigned from params which isn't necessarily a sector size from vendor, so based on the SECT_* flags from flash_params the erase_size will compute and it will become the sector_size finally. Bug report (from Bin Meng): => sf probe SF: Detected SST25VF016B with page size 256 Bytes, erase size 4 KiB, total 2 MiB, mapped at ffe00000 => sf erase 0 +100 SF: 65536 bytes @ 0x0 Erased: OK Signed-off-by: Jagannadha Sutradharudu Teki Reported-by: Bin Meng Tested-by: Bin Meng --- Changes for v3: - Updated comments Changes for v2: - Minimize the code logic drivers/mtd/spi/sf_internal.h | 3 ++- drivers/mtd/spi/sf_probe.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index bd834dc..4158e13 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -119,7 +119,8 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len, * @name: Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO]) * @jedec: Device jedec ID (0x[1byte_manuf_id][2byte_dev_id]) * @ext_jedec: Device ext_jedec ID - * @sector_size: Sector size of this device + * @sector_size: Isn't necessarily a sector size from vendor, + * the size listed here is what works with CMD_ERASE_64K * @nr_sectors: No.of sectors on this device * @e_rd_cmd: Enum list for read commands * @flags: Important param, for flash specific behaviour diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index de8d0b7..3f6b882 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -184,6 +184,9 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode, flash->erase_size = flash->sector_size; } + /* Now erase size becomes valid sector size */ + flash->sector_size = flash->erase_size; + /* Look for the fastest read cmd */ cmd = fls(params->e_rd_cmd & flash->spi->op_mode_rx); if (cmd) {