From patchwork Wed Jul 21 17:33:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ohad Ben Cohen X-Patchwork-Id: 113429 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6LHZeF1008346 for ; Wed, 21 Jul 2010 17:35:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761161Ab0GURfh (ORCPT ); Wed, 21 Jul 2010 13:35:37 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:61124 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761153Ab0GURfc (ORCPT ); Wed, 21 Jul 2010 13:35:32 -0400 Received: by bwz1 with SMTP id 1so375681bwz.19 for ; Wed, 21 Jul 2010 10:35:29 -0700 (PDT) Received: by 10.204.126.153 with SMTP id c25mr451229bks.27.1279733724743; Wed, 21 Jul 2010 10:35:24 -0700 (PDT) Received: from localhost.localdomain (93-172-119-238.bb.netvision.net.il [93.172.119.238]) by mx.google.com with ESMTPS id f10sm29348743bkl.5.2010.07.21.10.35.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 21 Jul 2010 10:35:24 -0700 (PDT) From: Ohad Ben-Cohen To: , , Cc: , , Chikkature Rajashekar Madhusudhan , Luciano Coelho , , San Mehat , Roger Quadros , Tony Lindgren , Nicolas Pitre , Pandita Vikram , Kalle Valo , Ohad Ben-Cohen Subject: [PATCH v2 18/20] mmc: sdio: enable a default power off mode of the card Date: Wed, 21 Jul 2010 20:33:52 +0300 Message-Id: <1279733634-21974-19-git-send-email-ohad@wizery.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1279733634-21974-1-git-send-email-ohad@wizery.com> References: <1279733634-21974-1-git-send-email-ohad@wizery.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 21 Jul 2010 17:35:40 +0000 (UTC) diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 5c0fbfa..164353f 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -80,8 +80,9 @@ static int sdio_init_func(struct mmc_card *card, unsigned int fn) return ret; /* For each SDIO function initialized, increase the power claim - * reference count of the card */ - atomic_inc(&card->power_claims); + * reference count of the card, unless explicitly requested not to */ + if (!(card->host->caps & MMC_CAP_DONT_POWER_CARD)) + atomic_inc(&card->power_claims); return 0; @@ -607,6 +608,16 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr) mmc_release_host(host); /* + * If power is not required for this card, power it off. + * The sdio function will need to call sdio_claim_power. + */ + if (!atomic_read(&card->power_claims)) { + pr_info("%s: power is not claimed, releasing\n", + mmc_hostname(host)); + mmc_release_power(host); + } + + /* * First add the card to the driver model... */ err = mmc_add_card(host->card); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 3675d58..756cf38 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -155,6 +155,7 @@ struct mmc_host { #define MMC_CAP_DISABLE (1 << 7) /* Can the host be disabled */ #define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */ #define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */ +#define MMC_CAP_DONT_POWER_CARD (1 << 10) /* Keep the card powered off */ mmc_pm_flag_t pm_caps; /* supported pm features */