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: 10074255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C493F6037F for ; Fri, 24 Nov 2017 16:26:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B63E62A2A6 for ; Fri, 24 Nov 2017 16:26:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AABE22A2C8; Fri, 24 Nov 2017 16:26:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22CDB2A2A6 for ; Fri, 24 Nov 2017 16:26:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753640AbdKXQZ6 (ORCPT ); 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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,