From patchwork Tue Feb 15 09:35:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arindam Nath X-Patchwork-Id: 558441 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1F9cNXq027723 for ; Tue, 15 Feb 2011 09:38:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754589Ab1BOJiO (ORCPT ); Tue, 15 Feb 2011 04:38:14 -0500 Received: from mail-iw0-f174.google.com ([209.85.214.174]:40842 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754379Ab1BOJiM (ORCPT ); Tue, 15 Feb 2011 04:38:12 -0500 Received: by mail-iw0-f174.google.com with SMTP id 9so5732646iwn.19 for ; Tue, 15 Feb 2011 01:38:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references; bh=UnEuHtEZ4munvCe+d+e7B6lBUw7Bsy25Q4QyurIRJQc=; b=tLy1XjCNvPaX0guxpvBwYi2SCT0vOnAsQCzkCzxtBB5asjjgfxghr6Rai5tTal2Hcu wAM2nkpyJsY5s+7/N7dUqgwEyGpD72Vp4LIxvlcPfqMkKAsjhQ1tKktX7T5G95n6OuId RbW6qO04Ct83ZzFoJJll3ne6S08fbsKu3T2c4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=AnQXy+DGgBVA5Z/qkmGX3P1lbAggssdS6Mh4qGWXX+u2UeRyGImE906oTdgxg57ykF QIPolubkPU7lBfGZ4GKN1P+LtvF9EdMp+v0R9VZ5/G36M+gxxK9lEjUe68yTaho4mGCQ dZxJTtb8TKY4blORel8Vkogd6IoSyoKM9tDNQ= Received: by 10.231.145.209 with SMTP id e17mr3863608ibv.43.1297762692301; Tue, 15 Feb 2011 01:38:12 -0800 (PST) Received: from localhost ([122.167.0.108]) by mx.google.com with ESMTPS id 8sm3445546iba.22.2011.02.15.01.38.06 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 Feb 2011 01:38:11 -0800 (PST) From: Arindam Nath To: cjb@laptop.org Cc: linux-mmc@vger.kernel.org, henry.su@amd.com, aaron.lu@amd.com, anath.amd@gmail.com, Arindam Nath Subject: [PATCH 10/12] mmc: sdhci: enable preset value after uhs initialization Date: Tue, 15 Feb 2011 15:05:08 +0530 Message-Id: <1297762510-2696-11-git-send-email-arindam.nath@amd.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1297762510-2696-1-git-send-email-arindam.nath@amd.com> References: <1297762510-2696-1-git-send-email-arindam.nath@amd.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 15 Feb 2011 09:38:23 +0000 (UTC) diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 3113cb6..1a625cc 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -949,6 +949,12 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, } } + /* + * Since initialization is now complete, enable preset + * value registers. + */ + host->ops->enable_preset_value(host); + host->card = card; return 0; diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 6f3f0dc..722f668 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1614,6 +1614,40 @@ out: spin_unlock_irqrestore(&host->lock, flags); } +static void sdhci_enable_preset_value(struct mmc_host *mmc) +{ + struct sdhci_host *host; + u16 ctrl; + unsigned long flags; + + host = mmc_priv(mmc); + + /* Host Controller v3.00 defines preset value registers */ + if (host->version < SDHCI_SPEC_300) + return; + + spin_lock_irqsave(&host->lock, flags); + + ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); + ctrl |= SDHCI_CTRL_PRESET_VAL_ENABLE; + sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); + + spin_unlock_irqrestore(&host->lock, flags); +} + +static void sdhci_disable_preset_value(struct sdhci_host *host) +{ + u16 ctrl; + + /* Only for Host Controller version >= v3.00 */ + if (host->version < SDHCI_SPEC_300) + return; + + ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); + ctrl &= ~SDHCI_CTRL_PRESET_VAL_ENABLE; + sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); +} + static const struct mmc_host_ops sdhci_ops = { .request = sdhci_request, .set_ios = sdhci_set_ios, @@ -1622,6 +1656,7 @@ static const struct mmc_host_ops sdhci_ops = { .start_signal_voltage_switch = sdhci_start_signal_voltage_switch, .get_max_current_180 = sdhci_get_max_current_180, .execute_tuning = sdhci_execute_tuning, + .enable_preset_value = sdhci_enable_preset_value, }; /*****************************************************************************\ @@ -1932,6 +1967,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) sdhci_writel(host, intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE), SDHCI_INT_STATUS); tasklet_schedule(&host->card_tasklet); + sdhci_disable_preset_value(host); } intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 4abb964..a47accd 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -130,6 +130,7 @@ struct mmc_host_ops { int (*start_signal_voltage_switch)(struct mmc_host *host); int (*get_max_current_180)(struct mmc_host *mmc); void (*execute_tuning)(struct mmc_host *host); + void (*enable_preset_value)(struct mmc_host *host); }; struct mmc_card;