From patchwork Thu Jul 28 20:49:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Yariv X-Patchwork-Id: 1017812 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6SKnwC7013963 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 28 Jul 2011 20:50:19 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QmXWf-0007WR-8z; Thu, 28 Jul 2011 20:49:49 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QmXWe-00005X-Pw; Thu, 28 Jul 2011 20:49:48 +0000 Received: from mail-wy0-f177.google.com ([74.125.82.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QmXWS-0008Uk-CU for linux-arm-kernel@lists.infradead.org; Thu, 28 Jul 2011 20:49:37 +0000 Received: by wyf23 with SMTP id 23so120568wyf.36 for ; Thu, 28 Jul 2011 13:49:33 -0700 (PDT) Received: by 10.227.142.141 with SMTP id q13mr527378wbu.114.1311886173252; Thu, 28 Jul 2011 13:49:33 -0700 (PDT) Received: from localhost.localdomain (109-186-100-122.bb.netvision.net.il [109.186.100.122]) by mx.google.com with ESMTPS id p49sm967799weq.7.2011.07.28.13.49.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jul 2011 13:49:32 -0700 (PDT) From: Ido Yariv To: Sekhar Nori , davinci-linux-open-source@linux.davincidsp.com, linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org Subject: [PATCH REPOST v2] mmc: davinci: Add support for set_power callback Date: Thu, 28 Jul 2011 23:49:09 +0300 Message-Id: <1311886149-3009-1-git-send-email-ido@wizery.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: References: X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110728_164936_652318_B293FC58 X-CRM114-Status: GOOD ( 14.79 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] Cc: Chris Ball , Ido Yariv X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 28 Jul 2011 20:50:19 +0000 (UTC) Some devices connected to the MMC bus are power controlled by external means. For instance, an SDIO device may be powered down/up by an external gpio line. In order to avoid toggling power from within the MMC host driver, add a set_power callback function, which will be called by set_ios upon powering down/up. Signed-off-by: Ido Yariv CC: Chris Ball Acked-by: Chris Ball --- arch/arm/mach-davinci/include/mach/mmc.h | 3 +++ drivers/mmc/host/davinci_mmc.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-davinci/include/mach/mmc.h b/arch/arm/mach-davinci/include/mach/mmc.h index d4f1e96..5ba6b22 100644 --- a/arch/arm/mach-davinci/include/mach/mmc.h +++ b/arch/arm/mach-davinci/include/mach/mmc.h @@ -12,6 +12,9 @@ struct davinci_mmc_config { /* get_cd()/get_wp() may sleep */ int (*get_cd)(int module); int (*get_ro)(int module); + + void (*set_power)(int module, bool on); + /* wires == 0 is equivalent to wires == 4 (4-bit parallel) */ u8 wires; diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index 0076c74..64a8325 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -807,12 +807,25 @@ static void calculate_clk_divider(struct mmc_host *mmc, struct mmc_ios *ios) static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) { struct mmc_davinci_host *host = mmc_priv(mmc); + struct platform_device *pdev = to_platform_device(mmc->parent); + struct davinci_mmc_config *config = pdev->dev.platform_data; dev_dbg(mmc_dev(host->mmc), "clock %dHz busmode %d powermode %d Vdd %04x\n", ios->clock, ios->bus_mode, ios->power_mode, ios->vdd); + switch (ios->power_mode) { + case MMC_POWER_OFF: + if (config && config->set_power) + config->set_power(pdev->id, false); + break; + case MMC_POWER_UP: + if (config && config->set_power) + config->set_power(pdev->id, true); + break; + } + switch (ios->bus_width) { case MMC_BUS_WIDTH_8: dev_dbg(mmc_dev(host->mmc), "Enabling 8 bit mode\n");