From patchwork Thu Mar 5 13:19:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 5946061 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F3775BF440 for ; Thu, 5 Mar 2015 13:19:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4076420380 for ; Thu, 5 Mar 2015 13:19:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35EA62037F for ; Thu, 5 Mar 2015 13:19:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754653AbbCENTl (ORCPT ); Thu, 5 Mar 2015 08:19:41 -0500 Received: from www.linutronix.de ([62.245.132.108]:49814 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753041AbbCENTk (ORCPT ); Thu, 5 Mar 2015 08:19:40 -0500 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1YTVgZ-00012g-45; Thu, 05 Mar 2015 14:19:31 +0100 From: Sebastian Andrzej Siewior To: linux-mmc@vger.kernel.org Cc: Chris Ball , Ulf Hansson , Sebastian Andrzej Siewior Subject: [PATCH 3/3] cmds/read_extcsd: add a few new mmc 5.0 fields Date: Thu, 5 Mar 2015 14:19:25 +0100 Message-Id: <1425561565-24806-4-git-send-email-bigeasy@linutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1425561565-24806-1-git-send-email-bigeasy@linutronix.de> References: <1425561565-24806-1-git-send-email-bigeasy@linutronix.de> X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1, SHORTCIRCUIT=-0.0001, URIBL_BLOCKED=0.001 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The output then starts with: |============================================= | Extended CSD rev 1.7 (MMC 5.0) |============================================= | |Card Supported Command sets [S_CMD_SET: 0x01] |HPI Features [HPI_FEATURE: 0x01]: implementation based on CMD13 |Background operations support [BKOPS_SUPPORT: 0x01] |Extended Security Commands Error [EXT_SECURITY_ERR: 0x00] |Device life time estimation type B [DEVICE_LIFE_TIME_EST_TYP_B: 01] | i.e. 0% - 10% device life time used |Device life time estimation type A [DEVICE_LIFE_TIME_EST_TYP_A: 01] | i.e. 0% - 10% device life time used |Pre EOL information [PRE_EOL_INFO: 01] | i.e. normal |Device version [DEVICE_VERSION: 38 05] |Firmware version [FIRMWARE_VERSION: 00 00 00 00 00 00 00 03 | i.e. Signed-off-by: Sebastian Andrzej Siewior --- mmc_cmds.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/mmc_cmds.c b/mmc_cmds.c index 8addd35046d7..195506b7b7ab 100644 --- a/mmc_cmds.c +++ b/mmc_cmds.c @@ -698,6 +698,28 @@ int do_write_reliability_set(int nargs, char **argv) return 0; } +static const char *ext_csd_get_lifetime(unsigned int val) +{ + static char lifetime[80]; + switch (val) { + case 1 ... 0xa: + snprintf(lifetime, sizeof(lifetime), + "%u%% - %u%% device life time used", + (val - 1) * 10, + (val - 0) * 10); + break; + case 0xb: + strncpy(lifetime, "Exceeded its maximum estimated " + "device life time", sizeof(lifetime)); + break; + case 0: + default: + strncpy(lifetime, "Not defined", sizeof(lifetime)); + break; + } + return lifetime; +} + int do_read_extcsd(int nargs, char **argv) { __u8 ext_csd[512], ext_csd_rev, reg; @@ -778,6 +800,53 @@ int do_read_extcsd(int nargs, char **argv) printf("Background operations support [BKOPS_SUPPORT: 0x%02x]\n", ext_csd[502]); + if (ext_csd_rev >= 7) { + const char *str; + + printf("Extended Security Commands Error " + "[EXT_SECURITY_ERR: 0x%02x]\n", ext_csd[505]); + + printf("Device life time estimation type B " + "[DEVICE_LIFE_TIME_EST_TYP_B: %02x]\n", ext_csd[269]); + printf(" i.e. %s\n", ext_csd_get_lifetime(ext_csd[269])); + printf("Device life time estimation type A " + "[DEVICE_LIFE_TIME_EST_TYP_A: %02x]\n", ext_csd[268]); + printf(" i.e. %s\n", ext_csd_get_lifetime(ext_csd[268])); + + printf("Pre EOL information [PRE_EOL_INFO: %02x]\n", + ext_csd[267]); + switch (ext_csd[267]) { + case 1: str = "normal"; + break; + case 2: str = "warning, consumed 80% of reserved block"; + break; + case 3: str = "urgend"; + break; + case 0: + default: + str = "Not defined"; + break; + } + printf(" i.e. %s\n", str); + /* optimal read, write, trim size */ + + printf("Device version [DEVICE_VERSION: %02x %02x]\n", + ext_csd[263], ext_csd[262]); + printf("Firmware version [FIRMWARE_VERSION: " + "%02x %02x %02x %02x %02x %02x %02x %02x \n", + ext_csd[261], ext_csd[260], ext_csd[259], ext_csd[258], + ext_csd[257], ext_csd[256], ext_csd[255], ext_csd[254]); + printf(" i.e. %c%c%c%c%c%c%c%c\n", + isprint(ext_csd[261]) ? ext_csd[261] : ' ', + isprint(ext_csd[260]) ? ext_csd[260] : ' ', + isprint(ext_csd[259]) ? ext_csd[259] : ' ', + isprint(ext_csd[258]) ? ext_csd[258] : ' ', + isprint(ext_csd[257]) ? ext_csd[257] : ' ', + isprint(ext_csd[256]) ? ext_csd[256] : ' ', + isprint(ext_csd[255]) ? ext_csd[255] : ' ', + isprint(ext_csd[254]) ? ext_csd[254] : ' '); + } + if (ext_csd_rev >= 6) { printf("Max Packet Read Cmd [MAX_PACKED_READS: 0x%02x]\n", ext_csd[501]);