From patchwork Fri Nov 24 16:24:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 119600 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2442216qgn; Fri, 24 Nov 2017 08:26:01 -0800 (PST) X-Google-Smtp-Source: AGs4zMbSIvqAijmlGul7+bJHuah6fTRIuldq0YNpB3TRmqkeamEMb8iiq0/1tTI5SyjPwPkXXi39 X-Received: by 10.159.218.137 with SMTP id w9mr30151142plp.139.1511540761256; Fri, 24 Nov 2017 08:26:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511540761; cv=none; d=google.com; s=arc-20160816; b=wX6lAreAOhiijPA9Tr9eb1lSXtfXgRU63BYV1F0/+z1/baI20VQGR4AythtXBD7FEa H8XbyewdIuFZMY622tN8iq/GaRWRlf6dU72BtuDl23TXwgHiQ125yFvHRIFyGOtuFhg8 pOlGz80RiI55dSPjcIj2pIOgkcxPIOR3G0l7HQsL5Hi7w+kSuOf/gzie8HYS61xaVXmP K0H21qL7NqgB/hgXhaDZ/zSEIKc9MSDkq/fOFnA23D2sd9KojpC/VB++dp9v9/1CMUBt SAOX7NjWao6OpFyuvZZvZN1H4SdUTd61SuYur8bw3p26ZqsbAjdPBpM2yThgBW9n5o2T rs5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=Hi0Zi72nWZTkAy7TQ96CZDOIoHptbVvHfSUhNbK4/+0=; b=wwkyPE2Fmsit2N2aNrbWZNaSzfzKU22EfI2k23GxUfKMEvMB8uCki9qez4+wvZzmCm HOzdd5GPtfVndMF4pVKBvDuPPv19stY/HaV5z8G+YthGgy8bmChpq9GbwNS2XKnCn6sx UCrltg38LEaoF/dgQ6tB9PQmIlulN7VfdptJu9YBaxv0rH8ZTlIS59fYyAIncODqZ35D CCRFLIVUBRPQggNDcND0Vz/hmJ56olTYwMI+ylEwxnyjRVzceX7dqGsNwyaNbWH5id9v YjCma2cCS09HZR5RFtPPOFA02ZF89hAxOTf1M5Wdc1nCSM3WzbZ0uvcSB+rMC9XCl4eN elLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=ZIarC5lY; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si5175370ple.586.2017.11.24.08.26.00; Fri, 24 Nov 2017 08:26:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=ZIarC5lY; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753640AbdKXQZ6 (ORCPT + 6 others); Fri, 24 Nov 2017 11:25:58 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:61404 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752224AbdKXQZ6 (ORCPT ); Fri, 24 Nov 2017 11:25:58 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-11.nifty.com with ESMTP id vAOGP9Vu007100; Sat, 25 Nov 2017 01:25:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com vAOGP9Vu007100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1511540718; bh=iY3GTa3Ci2TtVpyUUDX3undADzxC4yKTcx5hhMOR45o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZIarC5lYJ7wmbFCcbhn/CKAfv9f7rTSN9Bl43gWUYRaLOms+A0QW+9GDTlVQwouif feqXKNeolg+A3lvs/FLjkMD1SDJDVIBB+/OS8zSFEi/dawkgAgpTDUu2GpwJfQdx4t kHX+2Yq5t/nTSjvsurGSru1FoaYf1CJA/ouVCeWfwla2p7qfsvRISqCM8/1CpX4LVf REw6HwMvdeYxBIPDFwV7xf1pEHY8+ohOOm9XwhPkDTlTj+CRIOYKYHsnkglRWUYQ2t KEA2u3TzZCJmbtt3obQt26lsTf5W+3GInYDpg0prw1blmLan5rT9i9bbnTbZH7HxTF oLSlNdkZ4K5aA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-mmc@vger.kernel.org, Wolfram Sang Cc: Simon Horman , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 10/22] mmc: tmio: support IP-builtin card detection logic Date: Sat, 25 Nov 2017 01:24:45 +0900 Message-Id: <1511540697-27387-11-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com> References: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org A card detect GPIO is set up only for platforms with "cd-gpios" DT property or TMIO_MMC_USE_GPIO_CD flag. However, the driver core always uses mmc_gpio_get_cd, which just fails with -ENOSYS if ctx->cd_gpio is unset. The bit 5 of the status register provides the current signal level of the CD line. Allow to use it if the GPIO is unused. Signed-off-by: Masahiro Yamada --- Changes in v2: None drivers/mmc/host/tmio_mmc_core.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 610f26f..b51bb06 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1087,6 +1087,19 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc) return ret; } +static int tmio_mmc_get_cd(struct mmc_host *mmc) +{ + struct tmio_mmc_host *host = mmc_priv(mmc); + int ret; + + ret = mmc_gpio_get_cd(mmc); + if (ret >= 0) + return ret; + + return !!(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & + TMIO_STAT_SIGSTATE); +} + static int tmio_multi_io_quirk(struct mmc_card *card, unsigned int direction, int blk_size) { @@ -1102,7 +1115,7 @@ static const struct mmc_host_ops tmio_mmc_ops = { .request = tmio_mmc_request, .set_ios = tmio_mmc_set_ios, .get_ro = tmio_mmc_get_ro, - .get_cd = mmc_gpio_get_cd, + .get_cd = tmio_mmc_get_cd, .enable_sdio_irq = tmio_mmc_enable_sdio_irq, .multi_io_quirk = tmio_multi_io_quirk, .hw_reset = tmio_mmc_hw_reset,