From patchwork Thu Aug 22 16:19:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 2848332 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E300EBF546 for ; Thu, 22 Aug 2013 16:24:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27476204E4 for ; Thu, 22 Aug 2013 16:24:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E13D620421 for ; Thu, 22 Aug 2013 16:24:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753125Ab3HVQYt (ORCPT ); Thu, 22 Aug 2013 12:24:49 -0400 Received: from mail-ye0-f202.google.com ([209.85.213.202]:55973 "EHLO mail-ye0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753026Ab3HVQYs (ORCPT ); Thu, 22 Aug 2013 12:24:48 -0400 Received: by mail-ye0-f202.google.com with SMTP id r9so213279yen.1 for ; Thu, 22 Aug 2013 09:24:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3II0WYcXKm2F2UzwckZtGZlSjhZaxDMRxVlPW5SDfek=; b=oyrm4P7cUXrxMldVuN0IAmggIhtYaXvfnhMkGal7kpgKuFgy2zGcwvg+GkTRklrKEg Vi/nDWlmIXh3U2sz+RQWG6UU0hAA8/Ge7mWNlfffNJI5VXtA//TcJKRNCeBQTpHm5up9 zayk/0Pu6xeEseZiS8D8SczzEkxBQ8EKDZE2ektE0OnfP3CPrAlv9uCScAd6Av/2oM+P zWy8cMFe/7wVf0+yYCIWZyRdv4on03ybBiUasQ9KSyf5Aw+MUYn+QmCGstS//63tKMMK QuI2qStJoKT2kWlPUjWIOzCB9Kq6xi7caJqVLIWSm6VK6P2WJPFvouIyXVweMV+aIlJe D0jw== X-Gm-Message-State: ALoCoQnhuzXSsvwa4anL1CIABSm5pUUjMSEYX5wkRqNtgOrpZfGqf+e4t3eBiNCLV//5t18dvepZo3UVs/l1kgqJP5dl+FiL/p4m9BhGlORYnr+aEA0Z3dMvT4mdLZ3+v/Yj5TdUcb7GKOT7/66UfQN3viWnw/nODNUSEZyhwRSRlo8AbopP1JLsqbtcO/0YqADA/tpvfaWoJD+PLk8PGDulvgSElbdQuA== X-Received: by 10.236.115.198 with SMTP id e46mr5014987yhh.33.1377188359595; Thu, 22 Aug 2013 09:19:19 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id z29si897303yhd.3.1969.12.31.16.00.00 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Thu, 22 Aug 2013 09:19:19 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.34]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 6C78E31C1CF; Thu, 22 Aug 2013 09:19:19 -0700 (PDT) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id 1DEB280B15; Thu, 22 Aug 2013 09:19:19 -0700 (PDT) From: Doug Anderson To: Chris Ball Cc: Jaehoon Chung , Seungwon Jeon , James Hogan , Grant Grundler , Alim Akhtar , Abhilash Kesavan , Tomasz Figa , Olof Johansson , Doug Anderson , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/3] mmc: dw_mmc: Honor requests to set the clock to 0 (turn off clock) Date: Thu, 22 Aug 2013 09:19:07 -0700 Message-Id: <1377188348-3418-3-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1377188348-3418-1-git-send-email-dianders@chromium.org> References: <1377188348-3418-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=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Previously the dw_mmc driver would ignore any requests to disable the card's clock. This doesn't seem like a good thing in general, but had one extra bad side effect in the following situtation: * mmc core would set clk to 400kHz at boot time while initting * mmc core would set clk to 0 since no card, but it would be ignored. * suspend to ram and resume; clocks in the dw_mmc IP block are now 0 but dw_mmc thinks that they're 400kHz (it ignored the set to 0). * insert card * mmc core would set clk to 400kHz which would be considered a no-op. Note that if there is no card in the slot and we do a suspend/resume cycle, we _do_ still end up with differences in a dw_mmc register dump, but the differences are clock related and we've got the clock disabled both before and after, so this should be OK. Signed-off-by: Doug Anderson --- Changes in v6: - Replaces previous pathes that ensured saving/restoring clocks. drivers/mmc/host/dw_mmc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index ee5f167..f6c7545 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -635,7 +635,11 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit) u32 div; u32 clk_en_a; - if (slot->clock != host->current_speed || force_clkinit) { + if (slot->clock == 0) { + mci_writel(host, CLKENA, 0); + mci_send_cmd(slot, + SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); + } else if (slot->clock != host->current_speed || force_clkinit) { div = host->bus_hz / slot->clock; if (host->bus_hz % slot->clock && host->bus_hz > slot->clock) /* @@ -675,9 +679,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit) /* inform CIU */ mci_send_cmd(slot, SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); - - host->current_speed = slot->clock; } + host->current_speed = slot->clock; /* Set the current slot bus width */ mci_writel(host, CTYPE, (slot->ctype << slot->id)); @@ -807,13 +810,11 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) mci_writel(slot->host, UHS_REG, regs); - if (ios->clock) { - /* - * Use mirror of ios->clock to prevent race with mmc - * core ios update when finding the minimum. - */ - slot->clock = ios->clock; - } + /* + * Use mirror of ios->clock to prevent race with mmc + * core ios update when finding the minimum. + */ + slot->clock = ios->clock; if (drv_data && drv_data->set_ios) drv_data->set_ios(slot->host, ios);