From patchwork Wed Oct 15 23:04:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwendal Grignou X-Patchwork-Id: 5087431 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EAEC09F30B for ; Wed, 15 Oct 2014 23:04:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6D452013A for ; Wed, 15 Oct 2014 23:04:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB55E20138 for ; Wed, 15 Oct 2014 23:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751160AbaJOXEz (ORCPT ); Wed, 15 Oct 2014 19:04:55 -0400 Received: from mail-ig0-f202.google.com ([209.85.213.202]:33743 "EHLO mail-ig0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751262AbaJOXEy (ORCPT ); Wed, 15 Oct 2014 19:04:54 -0400 Received: by mail-ig0-f202.google.com with SMTP id r10so408288igi.5 for ; Wed, 15 Oct 2014 16:04:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0cJOr+UhB5n/gKGIpvaIRcsuGAez7joZw5bQ0pY6Auk=; b=QcUaB3/alczvnRr5B673uDpm6LxnVvfCriKRzeLAIAWPJnVnzDrjODQixPwenEUzzb H0b8EFLus+PNjJxRfCoRm9MZu9+aTLj9vfanHtVsDeiiHxCu3HmI9zJCM4yE5DuBkyVP L0fr2RMlSwbjNccCdOiMXXoebBx+zrum3kbN19jNgMAz2ld2S7XvBIkloUoEHAVeWLDp D7guQkc/YtxVXK5Ct0XCSGgWzsFMcXDko5E9LT5hSnFChIAoIsWDhROnnaM7GIVj6+uo is3Lr1GARzQyooOXWimYpJZ778qkgbCcfNcLlhnEuZVBK/Pw5Qiauzx7S7MI0T1ELSeb oOTQ== X-Gm-Message-State: ALoCoQmsldfUE/bthzag4ODlTe1A+bw50Dxyo0f7u5UY8lMA9xzTqyraDDeAM+4f9pjs4/61W07G X-Received: by 10.182.130.133 with SMTP id oe5mr10138359obb.37.1413414293561; Wed, 15 Oct 2014 16:04:53 -0700 (PDT) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id n24si1033049yha.6.2014.10.15.16.04.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Oct 2014 16:04:53 -0700 (PDT) Received: from gwendal.mtv.corp.google.com ([172.22.64.242]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id k2vqwnhM.1; Wed, 15 Oct 2014 16:04:53 -0700 Received: by gwendal.mtv.corp.google.com (Postfix, from userid 60833) id 7CF6D140BDA; Wed, 15 Oct 2014 16:04:52 -0700 (PDT) From: Gwendal Grignou To: Ulf Hansson Cc: Chris Ball , Seungwon Jeon , Jaehoon Chung , linux-mmc@vger.kernel.org, Gwendal Grignou Subject: [PATCH] mmc: Report firmware version for eMMC 5.0 devices. Date: Wed, 15 Oct 2014 16:04:48 -0700 Message-Id: <1413414288-4667-1-git-send-email-gwendal@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 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=ham 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 For eMMC 5.0 compliant device, firmware version is stored in ext_csd. Report firmware as a 64bit hexa decimal. Vendor can use hexa or ascii string to report firmware version. Also add FFU related EXT_CSD register and note if the device is FFU capable. Signed-off-by: Gwendal Grignou --- drivers/mmc/core/mmc.c | 24 +++++++++++++++++++++++- include/linux/mmc/card.h | 2 ++ include/linux/mmc/mmc.h | 10 ++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 1eda8dd..a0663cf 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -603,6 +603,25 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) card->ext_csd.data_sector_size = 512; } + /* eMMC v5 or later */ + if (card->ext_csd.rev >= 7) { + u64 fwrev; + + memcpy(&fwrev, &ext_csd[EXT_CSD_FIRMWARE_VERSION], + sizeof(fwrev)); + card->ext_csd.ffu_capable = + ((ext_csd[EXT_CSD_SUPPORTED_MODE] & 1) == 1) && + ((ext_csd[EXT_CSD_FW_CONFIG] & 1) == 0); + /* + * Firmware version can be a string or a hexa decimal number. + * In case of string, the first byte should be printed first. + * in case of hexadecimal, we can assume the first byte is the + * more significant, therefore we print it first as well. + */ + card->ext_csd.fwrev = be64_to_cpu(fwrev); + } else { + card->ext_csd.ffu_capable = false; + } out: return err; } @@ -697,7 +716,9 @@ MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1], MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year); MMC_DEV_ATTR(erase_size, "%u\n", card->erase_size << 9); MMC_DEV_ATTR(preferred_erase_size, "%u\n", card->pref_erase << 9); -MMC_DEV_ATTR(fwrev, "0x%x\n", card->cid.fwrev); +MMC_DEV_ATTR(fwrev, "0x%llx\n", (card->ext_csd.rev >= 7 ? + card->ext_csd.fwrev : card->cid.fwrev)); +MMC_DEV_ATTR(ffu_capable, "0x%x\n", card->ext_csd.ffu_capable); MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev); MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid); MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name); @@ -717,6 +738,7 @@ static struct attribute *mmc_std_attrs[] = { &dev_attr_erase_size.attr, &dev_attr_preferred_erase_size.attr, &dev_attr_fwrev.attr, + &dev_attr_ffu_capable.attr, &dev_attr_hwrev.attr, &dev_attr_manfid.attr, &dev_attr_name.attr, diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index d424b9d..67bae22 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -87,6 +87,8 @@ struct mmc_ext_csd { unsigned int data_tag_unit_size; /* DATA TAG UNIT size */ unsigned int boot_ro_lock; /* ro lock support */ bool boot_ro_lockable; + bool ffu_capable; /* FFU support */ + u64 fwrev; /* Firmware version */ u8 raw_exception_status; /* 54 */ u8 raw_partition_support; /* 160 */ u8 raw_rpmb_size_mult; /* 168 */ diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 64ec963..9216519 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -272,6 +272,9 @@ struct _mmc_csd { * EXT_CSD fields */ +#define EXT_CSD_FFU_STATUS 26 /* R */ +#define EXT_CSD_MODE_OPERATION_CODES 29 /* W */ +#define EXT_CSD_MODE_CONFIG 30 /* R/W */ #define EXT_CSD_FLUSH_CACHE 32 /* W */ #define EXT_CSD_CACHE_CTRL 33 /* R/W */ #define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */ @@ -290,6 +293,7 @@ struct _mmc_csd { #define EXT_CSD_SANITIZE_START 165 /* W */ #define EXT_CSD_WR_REL_PARAM 166 /* RO */ #define EXT_CSD_RPMB_MULT 168 /* RO */ +#define EXT_CSD_FW_CONFIG 169 /* R/W */ #define EXT_CSD_BOOT_WP 173 /* R/W */ #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ #define EXT_CSD_PART_CONFIG 179 /* R/W */ @@ -326,6 +330,12 @@ struct _mmc_csd { #define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */ #define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */ #define EXT_CSD_PWR_CL_DDR_200_360 253 /* RO */ +#define EXT_CSD_FIRMWARE_VERSION 254 /* RO, 8 bytes */ +#define EXT_CSD_NUM_OF_FW_SEC_PROG 302 /* RO, 4 bytes */ +#define EXT_CSD_FFU_ARG 487 /* RO, 4 bytes */ +#define EXT_CSD_OPERATION_CODE_TIMEOUT 491 /* RO */ +#define EXT_CSD_FFU_FEATURES 492 /* RO */ +#define EXT_CSD_SUPPORTED_MODE 493 /* RO */ #define EXT_CSD_TAG_UNIT_SIZE 498 /* RO */ #define EXT_CSD_DATA_TAG_SUPPORT 499 /* RO */ #define EXT_CSD_MAX_PACKED_WRITES 500 /* RO */