From patchwork Wed Dec 14 06:23: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: 5671 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 D7F2523E10 for ; Wed, 14 Dec 2011 06:20:05 +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 C8FADA183C5 for ; Wed, 14 Dec 2011 06:20:05 +0000 (UTC) Received: by eaak10 with SMTP id k10so127510eaa.11 for ; Tue, 13 Dec 2011 22:20:05 -0800 (PST) Received: by 10.204.131.74 with SMTP id w10mr20809bks.36.1323843605584; Tue, 13 Dec 2011 22:20:05 -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 hg2cs103691bkc; Tue, 13 Dec 2011 22:20:05 -0800 (PST) Received: by 10.50.158.227 with SMTP id wx3mr22680133igb.52.1323843603179; Tue, 13 Dec 2011 22:20:03 -0800 (PST) Received: from mail-iy0-f178.google.com (mail-iy0-f178.google.com [209.85.210.178]) by mx.google.com with ESMTPS id y9si867116ict.90.2011.12.13.22.20.02 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Dec 2011 22:20:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.178 is neither permitted nor denied by best guess record for domain of girish.shivananjappa@linaro.org) client-ip=209.85.210.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.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 iagf6 with SMTP id f6so909928iag.37 for ; Tue, 13 Dec 2011 22:20:02 -0800 (PST) Received: by 10.42.76.66 with SMTP id d2mr18420277ick.7.1323843602338; Tue, 13 Dec 2011 22:20:02 -0800 (PST) Received: from girishks ([115.113.119.130]) by mx.google.com with ESMTPS id e2sm5499527ibe.0.2011.12.13.22.19.58 (version=SSLv3 cipher=OTHER); Tue, 13 Dec 2011 22:20:01 -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 , Chris Ball Subject: [RESEND PATCH] mmc: core: Add host capability check for power class Date: Wed, 14 Dec 2011 11:53:33 +0530 Message-Id: <1323843813-25444-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. cc: Chris Ball 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 */