From patchwork Thu Jan 3 14:51:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 209263 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 2AB0A2C0089 for ; Fri, 4 Jan 2013 01:52:35 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C6AC04A0C7; Thu, 3 Jan 2013 15:52:33 +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 Gd3LeY7Cy71H; Thu, 3 Jan 2013 15:52:33 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A59DD4A0ED; Thu, 3 Jan 2013 15:52:32 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A016F4A0ED for ; Thu, 3 Jan 2013 15:52:30 +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 qtjiqQwChjde for ; Thu, 3 Jan 2013 15:52:29 +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-pb0-f52.google.com (mail-pb0-f52.google.com [209.85.160.52]) by theia.denx.de (Postfix) with ESMTPS id 7349E4A0C7 for ; Thu, 3 Jan 2013 15:52:27 +0100 (CET) Received: by mail-pb0-f52.google.com with SMTP id ro2so8606105pbb.39 for ; Thu, 03 Jan 2013 06:52:26 -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=DBya26/vIlbQeqMJEQOVUrT+oLzHhmWXxZpsDiDoxd0=; b=o6tHpWz9n0S4pvpn7Ep0zkIApAGlOZRJEqA+Wv7122OT0pdeszuGxzCkZqXNKg5CWL P6yVZAc5njWheygPJ6thD95jN5e6HvNjBLi77GoSbS+V1AlWw01iOCBR2lDtC4A1+T5g poTfx28oIe4xn21H4ve9Mh6g+dbVEQb+bwrYVXp0T2tFkfiQoBGAfWZ6HNFegVQi/Rq2 V4q3xsZVnNr51xvfniA15xfXE349fi92Wgpg6mdcisa/gFD/uNyHBdhAptlAtjAQ6OtR Bhl/ycYWRG/jOXjLZ99dax0RsHmgxb7LQ3HXlafKgZfGhstvL0OLyJBlINNRW++Wy3nw jjRA== X-Received: by 10.68.190.38 with SMTP id gn6mr155260026pbc.6.1357224746434; Thu, 03 Jan 2013 06:52:26 -0800 (PST) Received: from localhost.localdomain ([49.204.11.250]) by mx.google.com with ESMTPS id kb3sm30445737pbc.27.2013.01.03.06.52.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Jan 2013 06:52:25 -0800 (PST) From: Jagannadha Sutradharudu Teki To: u-boot@lists.denx.de Date: Thu, 3 Jan 2013 20:21:55 +0530 Message-Id: <1357224715-26885-2-git-send-email-jagannadh.teki@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1357224715-26885-1-git-send-email-jagannadh.teki@gmail.com> References: <1357224715-26885-1-git-send-email-jagannadh.teki@gmail.com> Subject: [U-Boot] [PATH v3 2/2] 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 --- Changes in v3: improved coding style drivers/mtd/spi/spi_flash.c | 8 ++++++++ drivers/mtd/spi/spi_flash_internal.h | 4 ++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index b4d726e..fdae94d 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -307,6 +307,14 @@ 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; + + cmd = CMD_READ_CONFIG; + return spi_flash_read_common(flash, &cmd, sizeof(cmd), (void *)data, 1); +} + /* * 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.