From patchwork Wed Dec 19 16:27:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 207453 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 CC76E2C0089 for ; Thu, 20 Dec 2012 03:29:09 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B14124A026; Wed, 19 Dec 2012 17:28:44 +0100 (CET) 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 sUtddTWwXSX5; Wed, 19 Dec 2012 17:28:44 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F32244A096; Wed, 19 Dec 2012 17:28:34 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EC5644A04B for ; Wed, 19 Dec 2012 17:28:28 +0100 (CET) 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 GGUT8sfKwoeC for ; Wed, 19 Dec 2012 17:28:27 +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-da0-f50.google.com (mail-da0-f50.google.com [209.85.210.50]) by theia.denx.de (Postfix) with ESMTPS id DF22C4A01F for ; Wed, 19 Dec 2012 17:28:22 +0100 (CET) Received: by mail-da0-f50.google.com with SMTP id h15so1011647dan.9 for ; Wed, 19 Dec 2012 08:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=YENiqXFy3HP5IOGEawGDCjwA0EN0KVb/s3nXAw2tqXg=; b=NU9v0VY5yOLk7GptUlZky5QZ1Ppa3eWpNZxH9EGnncWEdbLfLxHBxXjJ8B8iaBH5NM gvSzqIdQ7FTtV1aLTymH+pOHEDpEdnA2//Z8prnQy4AavnLaySaWAj8ZAFLFKyUInWQf gIivCJ3Ix2MOO26abe3Yj2BQ/NAq6Yk4xTuNA+/AUdr5aF6jxLmmXPWuo83dr2EVgY3J ksIrf1rqhfmsDU+ZUuUEg8oTO7Zg9zKsgbV8DhjCjDnV1VHcMgkGIsnOa3+orndyFtBx AL4Fp8ulXzZ71RgwC1yBolU3zZysgvcq53jkyiffzMlJ0NtLCFcJ5qD3D+abtfsUawdF DnbQ== X-Received: by 10.68.252.168 with SMTP id zt8mr20262854pbc.43.1355934499642; Wed, 19 Dec 2012 08:28:19 -0800 (PST) Received: from localhost.localdomain ([123.237.83.48]) by mx.google.com with ESMTPS id z5sm3683430pax.9.2012.12.19.08.28.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Dec 2012 08:28:19 -0800 (PST) From: Jagannadha Sutradharudu Teki To: u-boot@lists.denx.de Date: Wed, 19 Dec 2012 21:57:42 +0530 Message-Id: <1355934463-24319-5-git-send-email-jagannadh.teki@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1355934463-24319-1-git-send-email-jagannadh.teki@gmail.com> References: <1355934463-24319-1-git-send-email-jagannadh.teki@gmail.com> Subject: [U-Boot] [U-Boot,v2 5/6] sf: Add config register reading support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 This patch provides support to read a flash config register. Config register contains a control bits used to verify the different configurations and security features of a device. User need to get the data through spi_flash_cmd_read_config() based on their usage. Signed-off-by: Jagannadha Sutradharudu Teki Tested-by: Jagannadha Sutradharudu Teki --- Changes in v2: none drivers/mtd/spi/spi_flash.c | 15 +++++++++++++++ drivers/mtd/spi/spi_flash_internal.h | 4 ++++ 2 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index cad6c40..5bddde4 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -314,6 +314,21 @@ int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr) return 0; } +int spi_flash_cmd_read_config(struct spi_flash *flash, void *data) +{ + u8 cmd; + int ret; + + cmd = CMD_READ_CONFIG; + ret = spi_flash_read_common(flash, &cmd, sizeof(cmd), (void *)data, 1); + if (ret < 0) { + debug("SF: fail to read config register\n"); + return ret; + } + + return 0; +} + /* * The following table holds all device probe functions * diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index 825b398..844e82e 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -22,6 +22,7 @@ #define CMD_PAGE_PROGRAM 0x02 #define CMD_WRITE_DISABLE 0x04 #define CMD_READ_STATUS 0x05 +#define CMD_READ_CONFIG 0x35 #define CMD_WRITE_ENABLE 0x06 #define CMD_ERASE_4K 0x20 #define CMD_ERASE_32K 0x52 @@ -83,6 +84,9 @@ int spi_flash_cmd_read_status(struct spi_flash *flash, void *data); /* Program the config register. */ int spi_flash_cmd_write_config(struct spi_flash *flash, u8 cr); +/* Read the config register */ +int spi_flash_cmd_read_config(struct spi_flash *flash, void *data); + /* * Same as spi_flash_cmd_read() except it also claims/releases the SPI * bus. Used as common part of the ->read() operation.