From patchwork Mon Sep 17 08:55:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Ball X-Patchwork-Id: 1466281 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F2505DFFFF for ; Mon, 17 Sep 2012 08:55:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753396Ab2IQIzi (ORCPT ); Mon, 17 Sep 2012 04:55:38 -0400 Received: from void.printf.net ([89.145.121.20]:41171 "EHLO void.printf.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753366Ab2IQIzh (ORCPT ); Mon, 17 Sep 2012 04:55:37 -0400 Received: from 173-166-109-250-newengland.hfc.comcastbusiness.net ([173.166.109.250] helo=pullcord.laptop.org) by void.printf.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1TDX79-000597-M3; Mon, 17 Sep 2012 09:55:35 +0100 From: Chris Ball To: Guennadi Liakhovetski Cc: linux-mmc@vger.kernel.org Subject: [PATCH] mmc: sdhci: Test cd-gpio instead of SDHCI presence when probing References: Date: Mon, 17 Sep 2012 04:55:51 -0400 In-Reply-To: (Guennadi Liakhovetski's message of "Mon, 17 Sep 2012 09:28:03 +0200 (CEST)") Message-ID: User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.90 (gnu/linux) MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Guennadi Liakhovetski Previously to this patch, an SDHCI platform that uses a GPIO for card detection instead of the internal SDHCI_CARD_PRESENT bit on the presence register would fail to bring up a new card because logic in sdhci_request() fails the request if that bit is 0. Some drivers worked around this in various ways: esdhc-imx defines an IO accessor to fake the presence bit being true, s3c turns on polling (which stops the SDHCI driver from checking the bit) after a card's inserted. But none of this should be necessary; the real fix is to check whether we're using a GPIO and avoid relying on the presence bit if so, as this patch implements. Signed-off-by: Chris Ball Signed-off-by: Guennadi Liakhovetski --- drivers/mmc/host/sdhci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index d98b199..0e15c79 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "sdhci.h" @@ -1293,6 +1294,13 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) present = sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT; + /* If we're using a cd-gpio, testing the presence bit might fail. */ + if (!present) { + int ret = mmc_gpio_get_cd(host->mmc); + if (ret > 0) + present = true; + } + if (!present || host->flags & SDHCI_DEVICE_DEAD) { host->mrq->cmd->error = -ENOMEDIUM; tasklet_schedule(&host->finish_tasklet);