From patchwork Wed Jan 17 16:28:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 124866 Delivered-To: patch@linaro.org Received: by 10.46.62.1 with SMTP id l1csp108310lja; Wed, 17 Jan 2018 08:43:53 -0800 (PST) X-Google-Smtp-Source: ACJfBoue4qHebrshMdNftIfvrPROCNI9wY5/RUudGwJzKjpwTidACih/R7E4qRXmgvdk11befdae X-Received: by 10.101.74.208 with SMTP id c16mr16202811pgu.34.1516207433754; Wed, 17 Jan 2018 08:43:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516207433; cv=none; d=google.com; s=arc-20160816; b=tzSrYyR19cKVBpyr449qkui6GSdsqS4ADkgmPaMnJFcrpPt/dkOSM9Jp8jpOYF73rb cEp5xh0FHQs4ETI6nLm6NEUuZPmclRi0KjbWLvADP15PnWyDNU9JqEhRhSXeU5b+SMdJ vHu3qruLuvYOlsxKUtgOQV6me3roH/G8TiQliSgiTGS/yLVkoeNOo646qQU6rOrg9cLb l7ngkokVQE9zSs851LnSp3DIottTYBItDirVrxQUfA4ZtV5ehSsI7NinqnM/S5sQrzr8 65+jxkszevNe8JnogMFfeEpe2OF2bxIx8JSGxYLTfnXFIH0smvIlyVKJqlNldW+k1K9o 6tHw== 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=eqOkqCtxoVK2uGn9ADPn/eYRAT5VvVc8Mkd4icKgVVw=; b=ogYvgYC0z0nbWOV53aFzHO/CWU429MQgAyVEXlVgNSaM+nuHlrpzw9ywkpCOTxlKF6 xWhn9aaxOuw/QDsW6GFB5I00dyOxn4gey5DvAwZQWUcZkLM56jhEQIe7TPa7xQUTMXjT EP+TYGf9fKXPVaVV4nvaD4gSNuFU/D6q48MrryV7ZtjcUqySkX1i8kF4/4AoclIBQsu6 kYahScYb56MDnlgiINyLAUcq7xiucs7hdgI0Q0bWw4bMAoIFzM9TqOx/Okh9ZNHkE7nT 8JWJpxlKl8kpCG1/0E2U9QrrObufb4NJV5dnorZ0LinBdAkzh/th60LmwWqUl/m+orCJ uz6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=rDg8wfeH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 c19si4783714plo.278.2018.01.17.08.43.53; Wed, 17 Jan 2018 08:43:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=rDg8wfeH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932272AbeAQQnj (ORCPT + 28 others); Wed, 17 Jan 2018 11:43:39 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:36662 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753715AbeAQQ3b (ORCPT ); Wed, 17 Jan 2018 11:29:31 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-08.nifty.com with ESMTP id w0HGSIKw014790; Thu, 18 Jan 2018 01:28:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w0HGSIKw014790 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1516206510; bh=eqOkqCtxoVK2uGn9ADPn/eYRAT5VvVc8Mkd4icKgVVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rDg8wfeHZaJY4RSjJDa7T+89ebO5QYusrYfcyO4PPfv0tAVYl8eZW8MnhvUzbWEwx a0HFp9/FY/zLL170rizQfCugUWQHsYIN5kyP/QYXeeCOvbD3Ewd3d3coFlY/hXgdzS XTfe8mLnjTbOvPDjn5pn6CxL7M22GqLMcbwXNBJGFJyc/vQEGB7doOnSd1hL3mc7mV terkgA920Vv8LP1iEZ3iWBMpngqIsIhE80PFBuFXeeEmZ/chHYgcp9m5PAdOpneEMB 4ThgVLB+JLBy3tcEs/8IReF+eHl4ChOmI2XaGLiF0r052xoTvM3wdw9xpX3mjpTixL DM/MJwrDFUSDg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-mmc@vger.kernel.org, Wolfram Sang Cc: Ulf Magnusson , Geert Uytterhoeven , Simon Horman , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 12/16] mmc: tmio: support IP-builtin card detection logic Date: Thu, 18 Jan 2018 01:28:12 +0900 Message-Id: <1516206496-16612-13-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516206496-16612-1-git-send-email-yamada.masahiro@socionext.com> References: <1516206496-16612-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 v3: - split out GPIO CD Changes in v2: None drivers/mmc/host/tmio_mmc_core.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) -- 2.7.4 Reviewed-by: Wolfram Sang diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index f30ac69..b20d5c5 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1080,6 +1080,14 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc) TMIO_STAT_WRPROTECT); } +static int tmio_mmc_get_cd(struct mmc_host *mmc) +{ + struct tmio_mmc_host *host = mmc_priv(mmc); + + 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) { @@ -1095,7 +1103,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, @@ -1248,6 +1256,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) if (mmc_can_gpio_ro(mmc)) _host->ops.get_ro = mmc_gpio_get_ro; + if (mmc_can_gpio_cd(mmc)) + _host->ops.get_ro = mmc_gpio_get_cd; + _host->native_hotplug = !(mmc_can_gpio_cd(mmc) || mmc->caps & MMC_CAP_NEEDS_POLL || !mmc_card_is_removable(mmc));