linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuanxiao Dong <chuanxiao.dong@intel.com>
To: linux-mmc@vger.kernel.org, cjb@laptop.org
Cc: linux-kernel@vger.kernel.org, alan@linux.intel.com,
	arjan@linux.intel.com, hang.yuan@intel.com
Subject: [PATCH v1 3/4]enable HPI for supported card
Date: Tue, 23 Nov 2010 16:44:50 +0800	[thread overview]
Message-ID: <20101123084450.GD17754@intel.com> (raw)

>From 78d7ca58fe6ea3b850ee3682a3552e16fc9faa15 Mon Sep 17 00:00:00 2001
From: Chuanxiao Dong <chuanxiao.dong@intel.com>
Date: Tue, 23 Nov 2010 12:09:57 +0800
Subject: [PATCH 3/4] mmc: Enabled HPI feature

HPI feature is a new feature in eMMC4.41 standard. It will be
used to interrupt background operations and low priority
foreground operations

Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
---
 drivers/mmc/core/mmc.c   |   32 ++++++++++++++++++++++++++++++++
 include/linux/mmc/card.h |    2 ++
 include/linux/mmc/mmc.h  |    2 ++
 3 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 471ed82..c3f8e24 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -318,6 +318,20 @@ 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];
+			card->ext_csd.hpi_cmd =
+				ext_csd[EXT_CSD_HPI_FEATURES] & 0x2;
+			if ((card->ext_csd.hpi_cmd != MMC_SEND_STATUS) &&
+					(card->ext_csd.hpi_cmd !=
+					 MMC_STOP_TRANSMISSION)) {
+				card->ext_csd.hpi = 0;
+				card->ext_csd.hpi_en = 0;
+			}
+		}
 	}
 
 	if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
@@ -510,6 +524,24 @@ 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.bkops_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 ef85e90..ab1eb41 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -252,6 +252,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 */
@@ -270,6 +271,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
-- 
1.6.6.1


             reply	other threads:[~2010-11-23  8:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-23  8:44 Chuanxiao Dong [this message]
2010-11-24  4:02 ` [PATCH v1 3/4]enable HPI for supported card Kyungmin Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101123084450.GD17754@intel.com \
    --to=chuanxiao.dong@intel.com \
    --cc=alan@linux.intel.com \
    --cc=arjan@linux.intel.com \
    --cc=cjb@laptop.org \
    --cc=hang.yuan@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).