From patchwork Tue Aug 10 22:12:27 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: 176482 Return-path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on void.printf.net X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.9 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.2.5 Envelope-to: chris@printf.net Delivery-date: Tue, 10 Aug 2010 23:15:32 +0100 Received: from lists.laptop.org ([18.85.2.145] helo=mail.laptop.org) by void.printf.net with esmtp (Exim 4.69) (envelope-from ) id 1Oix6U-0004rn-8I for chris@printf.net; Tue, 10 Aug 2010 23:15:27 +0100 Received: by mail.laptop.org (Postfix) id 5537E24719; Tue, 10 Aug 2010 18:14:57 -0400 (EDT) Delivered-To: cjb@laptop.org Received: from spam.laptop.org (spam.laptop.org [18.85.46.23]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.laptop.org (Postfix) with ESMTPS id C79F824729 for ; Tue, 10 Aug 2010 18:14:23 -0400 (EDT) X-ASG-Debug-ID: 1281478472-0b742f0e0006-zHW3sV Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by spam.laptop.org with ESMTP id meGrCdh9g9r7mxSG for ; Tue, 10 Aug 2010 18:14:34 -0400 (EDT) X-Barracuda-Envelope-From: linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932925Ab0HJWN4 (ORCPT ); Tue, 10 Aug 2010 18:13:56 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:62839 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933346Ab0HJWNx (ORCPT ); Tue, 10 Aug 2010 18:13:53 -0400 Received: by mail-bw0-f46.google.com with SMTP id 3so2240853bwz.19 for ; Tue, 10 Aug 2010 15:13:52 -0700 (PDT) Received: by 10.204.81.215 with SMTP id y23mr12022956bkk.78.1281478432380; Tue, 10 Aug 2010 15:13:52 -0700 (PDT) Received: from localhost.localdomain (85-250-37-93.bb.netvision.net.il [85.250.37.93]) by mx.google.com with ESMTPS id f10sm4569096bkl.17.2010.08.10.15.13.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 10 Aug 2010 15:13:51 -0700 (PDT) From: Ohad Ben-Cohen To: , , Cc: Mark Brown , , Chikkature Rajashekar Madhusudhan , Luciano Coelho , , San Mehat , Roger Quadros , Tony Lindgren , Nicolas Pitre , Pandita Vikram , Kalle Valo , Ohad Ben-Cohen X-ASG-Orig-Subj: [PATCH v3 8/9] omap: hsmmc: split mmc23 power control Subject: [PATCH v3 8/9] omap: hsmmc: split mmc23 power control Date: Wed, 11 Aug 2010 01:12:27 +0300 Message-Id: <1281478348-24833-9-git-send-email-ohad@wizery.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1281478348-24833-1-git-send-email-ohad@wizery.com> References: <1281478348-24833-1-git-send-email-ohad@wizery.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Barracuda-Connect: vger.kernel.org[209.132.180.67] X-Barracuda-Start-Time: 1281478474 X-Barracuda-URL: http://18.85.46.23:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at laptop.org X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.5 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.37621 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c index 1ef54b0..5d3d789 100644 --- a/arch/arm/mach-omap2/hsmmc.c +++ b/arch/arm/mach-omap2/hsmmc.c @@ -174,7 +174,7 @@ static void omap4_hsmmc1_after_set_reg(struct device *dev, int slot, } } -static void hsmmc23_before_set_reg(struct device *dev, int slot, +static void hsmmc2_before_set_reg(struct device *dev, int slot, int power_on, int vdd) { struct omap_mmc_platform_data *mmc = dev->platform_data; @@ -325,14 +325,16 @@ void __init omap2_hsmmc_init(struct omap2_hsmmc_info *controllers) c->transceiver = 1; if (c->transceiver && c->wires > 4) c->wires = 4; - /* FALLTHROUGH */ - case 3: if (mmc->slots[0].features & HSMMC_HAS_PBIAS) { /* off-chip level shifting, or none */ - mmc->slots[0].before_set_reg = hsmmc23_before_set_reg; + mmc->slots[0].before_set_reg = hsmmc2_before_set_reg; mmc->slots[0].after_set_reg = NULL; } break; + case 3: + mmc->slots[0].before_set_reg = NULL; + mmc->slots[0].after_set_reg = NULL; + break; default: pr_err("MMC%d configuration not supported!\n", c->mmc); kfree(mmc); diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index d50e917..6f5cea0 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -258,7 +258,7 @@ static int omap_hsmmc_1_set_power(struct device *dev, int slot, int power_on, return ret; } -static int omap_hsmmc_23_set_power(struct device *dev, int slot, int power_on, +static int omap_hsmmc_2_set_power(struct device *dev, int slot, int power_on, int vdd) { struct omap_hsmmc_host *host = @@ -309,6 +309,31 @@ static int omap_hsmmc_23_set_power(struct device *dev, int slot, int power_on, return ret; } +static int omap_hsmmc_3_set_power(struct device *dev, int slot, int power_on, + int vdd) +{ + struct omap_hsmmc_host *host = + platform_get_drvdata(to_platform_device(dev)); + int ret = 0; + + if (power_on) { + ret = mmc_regulator_set_ocr(host->vcc, vdd); + /* Enable interface voltage rail, if needed */ + if (ret == 0 && host->vcc) { + ret = regulator_enable(host->vcc); + if (ret < 0) + ret = mmc_regulator_set_ocr(host->vcc, 0); + } + } else { + if (host->vcc) + ret = regulator_disable(host->vcc); + if (ret == 0) + ret = mmc_regulator_set_ocr(host->vcc, 0); + } + + return ret; +} + static int omap_hsmmc_1_set_sleep(struct device *dev, int slot, int sleep, int vdd, int cardsleep) { @@ -319,7 +344,7 @@ static int omap_hsmmc_1_set_sleep(struct device *dev, int slot, int sleep, return regulator_set_mode(host->vcc, mode); } -static int omap_hsmmc_23_set_sleep(struct device *dev, int slot, int sleep, +static int omap_hsmmc_2_set_sleep(struct device *dev, int slot, int sleep, int vdd, int cardsleep) { struct omap_hsmmc_host *host = @@ -358,6 +383,31 @@ static int omap_hsmmc_23_set_sleep(struct device *dev, int slot, int sleep, return regulator_enable(host->vcc_aux); } +static int omap_hsmmc_3_set_sleep(struct device *dev, int slot, int sleep, + int vdd, int cardsleep) +{ + struct omap_hsmmc_host *host = + platform_get_drvdata(to_platform_device(dev)); + int err = 0; + + /* + * If we don't see a Vcc regulator, assume it's a fixed + * voltage always-on regulator. + */ + if (!host->vcc) + return 0; + + if (cardsleep) { + /* VCC can be turned off if card is asleep */ + if (sleep) + err = mmc_regulator_set_ocr(host->vcc, 0); + else + err = mmc_regulator_set_ocr(host->vcc, vdd); + } + + return err; +} + static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) { struct regulator *reg; @@ -370,10 +420,13 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) mmc_slot(host).set_sleep = omap_hsmmc_1_set_sleep; break; case OMAP_MMC2_DEVID: - case OMAP_MMC3_DEVID: /* Off-chip level shifting, or none */ - mmc_slot(host).set_power = omap_hsmmc_23_set_power; - mmc_slot(host).set_sleep = omap_hsmmc_23_set_sleep; + mmc_slot(host).set_power = omap_hsmmc_2_set_power; + mmc_slot(host).set_sleep = omap_hsmmc_2_set_sleep; + break; + case OMAP_MMC3_DEVID: + mmc_slot(host).set_power = omap_hsmmc_3_set_power; + mmc_slot(host).set_sleep = omap_hsmmc_3_set_sleep; break; default: pr_err("MMC%d configuration not supported!\n", host->id); @@ -386,9 +439,9 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) /* * HACK: until fixed.c regulator is usable, * we don't require a main regulator - * for MMC2 or MMC3 + * for MMC2 */ - if (host->id == OMAP_MMC1_DEVID) { + if (host->id != OMAP_MMC2_DEVID) { ret = PTR_ERR(reg); goto err; }