public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] mmc: core: Add host capability check for power class
@ 2011-12-15  3:58 Girish K S
  2011-12-15  6:03 ` amit kachhap
  2011-12-15 10:04 ` Saugata Das
  0 siblings, 2 replies; 14+ messages in thread
From: Girish K S @ 2011-12-15  3:58 UTC (permalink / raw)
  To: linux-mmc; +Cc: patches, linux-samsung-soc, subhashj, Girish K S, Chris Ball

This patch adds a check whether the host supports maximum current value
obtained from the device's extended csd register for a selected interface
voltage and frequency.

cc: Chris Ball <cjb@laptop.org>
Signed-off-by: Girish K S <girish.shivananjappa@linaro.org>
---
Changes in v2:
	deleted a unnecessary if else condition identified by subhash J
Changes in v1:
       reduced the number of comparisons as per Hein's suggestion

 drivers/mmc/core/mmc.c   |   19 +++++++++++++++++++
 include/linux/mmc/card.h |    4 ++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 006e932..b9ef777 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -688,6 +688,25 @@ static int mmc_select_powerclass(struct mmc_card *card,
 		pwrclass_val = (pwrclass_val & EXT_CSD_PWR_CL_4BIT_MASK) >>
 				EXT_CSD_PWR_CL_4BIT_SHIFT;
 
+	if (pwrclass_val >= MMC_MAX_CURRENT_800)
+		pwrclass_val = MMC_MAX_CURRENT_800;
+	else if (pwrclass_val >= MMC_MAX_CURRENT_600)
+		pwrclass_val = MMC_MAX_CURRENT_600;
+	else if (pwrclass_val >= MMC_MAX_CURRENT_400)
+		pwrclass_val = MMC_MAX_CURRENT_400;
+	else
+		pwrclass_val = MMC_MAX_CURRENT_200;
+
+	if ((pwrclass_val == MMC_MAX_CURRENT_800) &&
+	    !(card->host->caps & MMC_CAP_MAX_CURRENT_800))
+		pwrclass_val = MMC_MAX_CURRENT_600;
+	if ((pwrclass_val == MMC_MAX_CURRENT_600) &&
+	    !(card->host->caps & MMC_CAP_MAX_CURRENT_600))
+		pwrclass_val = MMC_MAX_CURRENT_400;
+	if ((pwrclass_val == MMC_MAX_CURRENT_400) &&
+	    !(card->host->caps & MMC_CAP_MAX_CURRENT_400))
+		pwrclass_val = MMC_MAX_CURRENT_200;
+
 	/* If the power class is different from the default value */
 	if (pwrclass_val > 0) {
 		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 9478a6b..c5e031a 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -195,6 +195,10 @@ struct mmc_part {
 #define MMC_BLK_DATA_AREA_GP	(1<<2)
 };
 
+#define MMC_MAX_CURRENT_200	(0)
+#define MMC_MAX_CURRENT_400	(7)
+#define MMC_MAX_CURRENT_600	(11)
+#define MMC_MAX_CURRENT_800	(13)
 /*
  * MMC device
  */
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-04-03 10:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-15  3:58 [PATCH V2] mmc: core: Add host capability check for power class Girish K S
2011-12-15  6:03 ` amit kachhap
2011-12-15  6:16   ` Girish K S
2011-12-15  9:57   ` Hein_Tibosch
2011-12-15 10:04 ` Saugata Das
2011-12-15 10:52   ` Girish K S
2011-12-15 13:05     ` Saugata Das
2012-03-28 11:09       ` Subhash Jadavani
2012-03-29  5:47         ` Girish K S
2012-03-30  4:58           ` Girish K S
2012-03-30  5:46             ` Subhash Jadavani
2012-04-02  7:49         ` Saugata Das
2012-04-02 10:54           ` Subhash Jadavani
2012-04-03 10:42             ` Saugata Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox