From patchwork Wed Dec 14 06:19:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Girish K S X-Patchwork-Id: 5670 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 69C6823E10 for ; Wed, 14 Dec 2011 06:16:02 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id 5CA36A18338 for ; Wed, 14 Dec 2011 06:16:02 +0000 (UTC) Received: by eaak10 with SMTP id k10so125001eaa.11 for ; Tue, 13 Dec 2011 22:16:02 -0800 (PST) Received: by 10.205.127.12 with SMTP id gy12mr262883bkc.108.1323843362138; Tue, 13 Dec 2011 22:16:02 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.129.2 with SMTP id hg2cs103561bkc; Tue, 13 Dec 2011 22:16:01 -0800 (PST) Received: by 10.236.180.227 with SMTP id j63mr9016201yhm.18.1323843360889; Tue, 13 Dec 2011 22:16:00 -0800 (PST) Received: from mail-gy0-f178.google.com (mail-gy0-f178.google.com [209.85.160.178]) by mx.google.com with ESMTPS id r41si1198244yhm.43.2011.12.13.22.16.00 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Dec 2011 22:16:00 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.178 is neither permitted nor denied by best guess record for domain of girish.shivananjappa@linaro.org) client-ip=209.85.160.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.178 is neither permitted nor denied by best guess record for domain of girish.shivananjappa@linaro.org) smtp.mail=girish.shivananjappa@linaro.org Received: by ghbg21 with SMTP id g21so414328ghb.37 for ; Tue, 13 Dec 2011 22:16:00 -0800 (PST) Received: by 10.50.15.134 with SMTP id x6mr22234783igc.51.1323843360147; Tue, 13 Dec 2011 22:16:00 -0800 (PST) Received: from girishks ([115.113.119.130]) by mx.google.com with ESMTPS id ew6sm2710658igc.4.2011.12.13.22.15.54 (version=SSLv3 cipher=OTHER); Tue, 13 Dec 2011 22:15:59 -0800 (PST) From: Girish K S To: linux-mmc@vger.kernel.org Cc: patches@linaro.org, linux-samsung-soc@vger.kernel.org, subhashj@codeaurora.org, Girish K S Subject: [PATCH] mmc: core: Add host capability check for power class Date: Wed, 14 Dec 2011 11:49:33 +0530 Message-Id: <1323843573-25394-1-git-send-email-girish.shivananjappa@linaro.org> X-Mailer: git-send-email 1.7.1 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. Signed-off-by: Girish K S --- drivers/mmc/core/mmc.c | 27 +++++++++++++++++++++++++++ include/linux/mmc/card.h | 4 ++++ 2 files changed, 31 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 006e932..30d1cbc 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -688,6 +688,33 @@ 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 (card->host->caps & MMC_CAP_MAX_CURRENT_800) { + 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 if (pwrclass_val >= MMC_MAX_CURRENT_200) + pwrclass_val = MMC_MAX_CURRENT_200; + } else if (card->host->caps & MMC_CAP_MAX_CURRENT_600) { + 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 if (pwrclass_val >= MMC_MAX_CURRENT_200) + pwrclass_val = MMC_MAX_CURRENT_200; + } else if (card->host->caps & MMC_CAP_MAX_CURRENT_400) { + if (pwrclass_val >= MMC_MAX_CURRENT_400) + pwrclass_val = MMC_MAX_CURRENT_400; + else if (pwrclass_val >= MMC_MAX_CURRENT_200) + pwrclass_val = MMC_MAX_CURRENT_200; + } else if (card->host->caps & MMC_CAP_MAX_CURRENT_200) { + if (pwrclass_val >= MMC_MAX_CURRENT_200) + pwrclass_val = MMC_MAX_CURRENT_200; + } else + 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 */