From patchwork Tue Oct 26 10:26:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chuanxiao.Dong" X-Patchwork-Id: 282052 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9QAPQl0030904 for ; Tue, 26 Oct 2010 10:27:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759366Ab0JZK1I (ORCPT ); Tue, 26 Oct 2010 06:27:08 -0400 Received: from mga02.intel.com ([134.134.136.20]:11503 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755647Ab0JZK1H convert rfc822-to-8bit (ORCPT ); Tue, 26 Oct 2010 06:27:07 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 26 Oct 2010 03:27:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.58,240,1286175600"; d="scan'208";a="567437693" Received: from unknown (HELO intel.com) ([172.16.120.128]) by orsmga002.jf.intel.com with ESMTP; 26 Oct 2010 03:27:05 -0700 Date: Tue, 26 Oct 2010 18:26:17 +0800 From: "Chuanxiao.Dong" To: linux-mmc@vger.kernel.org, cjb@laptop.org Subject: [PATCH 1/1]mmc: implemented enhanced area feature for user data area Message-ID: <20101026102617.GA27707@intel.com> Reply-To: "Chuanxiao.Dong" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 26 Oct 2010 10:27:08 +0000 (UTC) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 995261f..9bb9fac 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -302,6 +302,35 @@ static int mmc_read_ext_csd(struct mmc_card *card) } if (card->ext_csd.rev >= 4) { + /* Enhanced area feature support + * check whether eMMC card is enabled enhanced area, + * if so, export enhanced area offset and size to + * user by adding sysfs interface + * */ + if ((ext_csd[160] & 0x2) && (ext_csd[156] & 0x1)) { + u8 hc_erase_grp_sz = ext_csd[224]; + u8 hc_wp_grp_sz = ext_csd[221]; + /* set a flag to identify whether the enhanced + * user data are enabled + * */ + card->ext_csd.enh_data_area_en = 1; + /* caculate the enhanced data area offset, unit B + * */ + card->ext_csd.enh_data_area_off = + (ext_csd[139] << 24) + (ext_csd[138] << 16) + + (ext_csd[137] << 8) + ext_csd[136]; + if (mmc_card_blockaddr(card)) + card->ext_csd.enh_data_area_off <<= 9; + /* caculate the enhanced data area size, unit KB + * */ + card->ext_csd.enh_data_area_sz = + (ext_csd[142] << 16) + (ext_csd[141] << 8) + + ext_csd[140]; + card->ext_csd.enh_data_area_sz *= + (size_t)(hc_erase_grp_sz * hc_wp_grp_sz); + card->ext_csd.enh_data_area_sz <<= 9; + } + card->ext_csd.sec_trim_mult = ext_csd[EXT_CSD_SEC_TRIM_MULT]; card->ext_csd.sec_erase_mult = @@ -336,6 +365,9 @@ MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid); MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name); MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); +MMC_DEV_ATTR(enhen, "%d\n", card->ext_csd.enh_data_area_en); +MMC_DEV_ATTR(enhoff, "0x%llxB\n", card->ext_csd.enh_data_area_off); +MMC_DEV_ATTR(enhsz, "0x%xKB\n", card->ext_csd.enh_data_area_sz); static struct attribute *mmc_std_attrs[] = { &dev_attr_cid.attr, @@ -349,6 +381,9 @@ static struct attribute *mmc_std_attrs[] = { &dev_attr_name.attr, &dev_attr_oemid.attr, &dev_attr_serial.attr, + &dev_attr_enhen.attr, + &dev_attr_enhoff.attr, + &dev_attr_enhsz.attr, NULL, }; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 8ce0827..bf9e718 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -54,6 +54,9 @@ struct mmc_ext_csd { unsigned int sec_trim_mult; /* Secure trim multiplier */ unsigned int sec_erase_mult; /* Secure erase multiplier */ unsigned int trim_timeout; /* In milliseconds */ + unsigned int enh_data_area_en; + loff_t enh_data_area_off; + size_t enh_data_area_sz; }; struct sd_scr {