From patchwork Fri Feb 20 18:57:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 5858281 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2F8B59F269 for ; Fri, 20 Feb 2015 18:57:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D58A204B5 for ; Fri, 20 Feb 2015 18:57:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B57A203AE for ; Fri, 20 Feb 2015 18:57:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755009AbbBTS5t (ORCPT ); Fri, 20 Feb 2015 13:57:49 -0500 Received: from mail-ie0-f177.google.com ([209.85.223.177]:38895 "EHLO mail-ie0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754109AbbBTS5f (ORCPT ); Fri, 20 Feb 2015 13:57:35 -0500 Received: by iecrd18 with SMTP id rd18so10119365iec.5 for ; Fri, 20 Feb 2015 10:57:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wN2UpiVBPe821woyPWmFalpKQtKpt1YMAvpnNINNSPo=; b=MBfOPDp3xTNbIDP0HiLx0bW4ggpdhqPThFxVImlvudeCWoenBjAv1QTY4c06Xk0QWC CdJGiv2wNqMHOD5diIZzX2Lu1LentrP47eZeXBDjGqptIv3VhcfpXLvCIqG/skrEQ5ra gcIW4bpds1oLs4/k5mzmnxDULWyCzs1qAEEdg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wN2UpiVBPe821woyPWmFalpKQtKpt1YMAvpnNINNSPo=; b=PYdPSar4Ztgt6N5X9U7qsDmSTm4q6qafSFH80wGKRTTsy9p0Ms3QlyzghYhBvOPmku d2rdT0kEoDBzLiEGP0Y7KEJHI/ri87W/HAnt3Sk3SJMwR7k1p6lkBuJhZzkqckqp6oWC gyI7YEfWCNTXTi1QaGAKHRM1DSt0Sm60eLLMLHXmoPTCzBouCeIZBAI7lKO+LdzIjkPs mYcKoozAWnPpO/rW9W2hqGo1aln+RzK7bfpOrB97m8hDGtuDcngkoqQ5hUzYRUk+08MW VtzRfOwemhDjA8gHKvrjBGEtmDD+5SHH2C3oem3p28MTSjGqW1BaJYOgXOUZX57qXUu6 WkMQ== X-Gm-Message-State: ALoCoQmj6yeCB1uA8G1O9Gt1eAet/albO0qEcZ2i+MhWekl9XRd8ySzMT5V7OP3sLKByr1WqPLTK X-Received: by 10.42.207.209 with SMTP id fz17mr11742451icb.43.1424458654721; Fri, 20 Feb 2015 10:57:34 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by mx.google.com with ESMTPSA id m38sm17411723ioi.39.2015.02.20.10.57.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Feb 2015 10:57:34 -0800 (PST) From: Doug Anderson To: Jaehoon Chung , Seungwon Jeon , Ulf Hansson Cc: Alim Akhtar , Sonny Rao , Andrew Bresticker , Heiko Stuebner , Addy Ke , Alexandru Stan , javier.martinez@collabora.co.uk, Doug Anderson , chris@printf.net, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mmc: dw_mmc: Give a good reset after we give power Date: Fri, 20 Feb 2015 10:57:19 -0800 Message-Id: <1424458639-23330-2-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1424458639-23330-1-git-send-email-dianders@chromium.org> References: <1424458639-23330-1-git-send-email-dianders@chromium.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We should give dw_mmc a good reset after we apply power. On some boards vqmmc may actually be connected to the IP block in the SoC so it's good to reset after power comes in. Without this we sometimes see failures enumerating cards on rk3288. Signed-off-by: Doug Anderson Acked-by: Jaehoon Chung Tested-by: Javier Martinez Canillas --- drivers/mmc/host/dw_mmc.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 43fcae1..6a712ae 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1119,13 +1119,23 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) mci_writel(slot->host, PWREN, regs); break; case MMC_POWER_ON: - if (!IS_ERR(mmc->supply.vqmmc) && !slot->host->vqmmc_enabled) { - ret = regulator_enable(mmc->supply.vqmmc); - if (ret < 0) - dev_err(slot->host->dev, - "failed to enable vqmmc regulator\n"); - else + if (!slot->host->vqmmc_enabled) { + if (!IS_ERR(mmc->supply.vqmmc)) { + ret = regulator_enable(mmc->supply.vqmmc); + if (ret < 0) + dev_err(slot->host->dev, + "failed to enable vqmmc\n"); + else + slot->host->vqmmc_enabled = true; + + } else { + /* Keep track so we don't reset again */ slot->host->vqmmc_enabled = true; + } + + /* Reset our state machine after powering on */ + dw_mci_ctrl_reset(slot->host, + SDMMC_CTRL_ALL_RESET_FLAGS); } /* Adjust clock / bus width after power is up */ @@ -1139,10 +1149,9 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) if (!IS_ERR(mmc->supply.vmmc)) mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); - if (!IS_ERR(mmc->supply.vqmmc) && slot->host->vqmmc_enabled) { + if (!IS_ERR(mmc->supply.vqmmc) && slot->host->vqmmc_enabled) regulator_disable(mmc->supply.vqmmc); - slot->host->vqmmc_enabled = false; - } + slot->host->vqmmc_enabled = false; regs = mci_readl(slot->host, PWREN); regs &= ~(1 << slot->id);