From patchwork Fri Dec 3 12:14:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chuanxiao.Dong" X-Patchwork-Id: 377771 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 oB3CHdXm014868 for ; Fri, 3 Dec 2010 12:17:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758487Ab0LCMRl (ORCPT ); Fri, 3 Dec 2010 07:17:41 -0500 Received: from mga11.intel.com ([192.55.52.93]:37014 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755364Ab0LCMRl convert rfc822-to-8bit (ORCPT ); Fri, 3 Dec 2010 07:17:41 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 03 Dec 2010 04:17:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.59,292,1288594800"; d="scan'208,223";a="632763908" Received: from unknown (HELO intel.com) ([172.16.120.128]) by fmsmga002.fm.intel.com with ESMTP; 03 Dec 2010 04:17:39 -0800 Date: Fri, 3 Dec 2010 20:14:28 +0800 From: Chuanxiao Dong To: linux-mmc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, cjb@laptop.org, akpm@linux-foundation.org, arjan@linux.intel.com, alan@linux.intel.com, kmpark@infradead.org Subject: [PATCH v2 3/4]enable HPI for supported eMMC card Message-ID: <20101203121428.GD18655@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]); Fri, 03 Dec 2010 12:17:42 +0000 (UTC) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 471ed82..8d6c5cb 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -318,6 +318,18 @@ static int mmc_read_ext_csd(struct mmc_card *card) ext_csd[EXT_CSD_BKOPS_EN]; } + /* check whether the eMMC card support HPI */ + if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x1) { + card->ext_csd.hpi = 1; + card->ext_csd.hpi_en = + ext_csd[EXT_CSD_HPI_MGMT]; + if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x2) + card->ext_csd.hpi_cmd = + MMC_STOP_TRANSMISSION; + else + card->ext_csd.hpi_cmd = + MMC_SEND_STATUS; + } } if (ext_csd[EXT_CSD_ERASED_MEM_CONT]) @@ -510,6 +522,25 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, } /* + * enable HPI feature if eMMC card support + */ + if (card->ext_csd.hpi) { + if (!card->ext_csd.hpi_en) { + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_HPI_MGMT, 1); + if (err && err != -EBADMSG) + goto free_card; + + if (err) { + card->ext_csd.hpi_en = 0; + err = 0; + } else { + card->ext_csd.hpi_en = 1; + } + } + } + + /* * Activate high speed (if supported) */ if ((card->ext_csd.hs_max_dtr != 0) && diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 4142ab5..efb2c56 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -57,6 +57,8 @@ struct mmc_ext_csd { unsigned int bkops:1; /* background support bit */ unsigned int bkops_en:1; /* background enable bit */ unsigned int hpi_en:1; /* HPI enable bit */ + unsigned int hpi:1; /* HPI support bit */ + unsigned int hpi_cmd; /* cmd used to for HPI */ }; struct sd_scr { diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 2ba6a8b..34feaee 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -258,6 +258,7 @@ struct _mmc_csd { * EXT_CSD fields */ +#define EXT_CSD_HPI_MGMT 161 /* R/W */ #define EXT_CSD_BKOPS_EN 163 /* R/W */ #define EXT_CSD_BKOPS_START 164 /* W */ #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ @@ -276,6 +277,7 @@ struct _mmc_csd { #define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ #define EXT_CSD_TRIM_MULT 232 /* RO */ #define EXT_CSD_BKOPS_SUPPORT 502 /* RO */ +#define EXT_CSD_HPI_FEATURES 503 /* RO */ /* * EXT_CSD field definitions