From patchwork Wed Nov 8 10:16:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 118233 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5097644qgn; Wed, 8 Nov 2017 02:18:55 -0800 (PST) X-Google-Smtp-Source: ABhQp+RcMN1GhpLXAfi3a96+QBxKkvsVHTz++BGrfm1V7zkZY+CzN9JxymxE5mfn6FKbE4gn8uUu X-Received: by 10.84.176.132 with SMTP id v4mr1771340plb.393.1510136335220; Wed, 08 Nov 2017 02:18:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510136335; cv=none; d=google.com; s=arc-20160816; b=FtjiF4yiCCQPQlVBIMnbx86FwNoyEafdwKSYEibVmDQVzXZdj+RK6te2JGUGjBkX40 BYIj2+RpW0msGAKKqgtRja/wghWYcv7BJDa3N6Q0o568SmxbMhrMoh0XBUTePr/tAG7A lkvRTAjgU4o1jtmtsRPA4uyQ4XE3aDFPf5WD1PEHxXIm+YsYXGiWsnB0NJWDy0SInW8D jfe1lvTP4KbGyGR7tns3EYeuVyRp46MN1SMVTjVW4zemxq6tfXeDQq5BIftqSeUoIuJX hE+e/LuTUDpfy2cRGeKGtMBaHXhkNPP/UkJTR25DSQErUSbJ7b19zsmD7V9giPXWFGSh JNiA== 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=/blhpwY6spQ9CKanR35MzGsnYypGKrLj3pzGFbNPKhg=; b=zcqtmKCbyNZiFDT5DlIm1Evrqp1WS+AcnL2vc5b3+ZYsc//QxRRPvJzvtQWxRNKrWX yWrepy9HgCiRPJNdhsPD/ySf4AAQDKh8fszNg03cwKuertIIw/fWA6y17Iqrr1nIiMCC 5F22F8NW1MUeonfp756+EULCxUlzAuiWdoWqsJVjVeHOIq7H7B/iIci4roAEu40ejL4o qm+/2j4hDMSkuTEEgxk2Q09VM1+X8MPVilkYJRpI/p4/QtO6uECpQ1yAbv9D6f8xzjTj Ro85l57Nolpd62Y/BMDUr45VeVoepWAon+HTuZIqaibXLQpPRyM9+L3bHTdxUlIX+2SS lxHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=WSSHpAdd; 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 r17si3542260pgd.673.2017.11.08.02.18.54; Wed, 08 Nov 2017 02:18:55 -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=WSSHpAdd; 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 S1751826AbdKHKSv (ORCPT + 26 others); Wed, 8 Nov 2017 05:18:51 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:43224 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751352AbdKHKR4 (ORCPT ); Wed, 8 Nov 2017 05:17:56 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id vA8AH4rt031631; Wed, 8 Nov 2017 19:17:05 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com vA8AH4rt031631 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1510136225; bh=/blhpwY6spQ9CKanR35MzGsnYypGKrLj3pzGFbNPKhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WSSHpAddeDg4dmEWyMVLlBLTHClQrpdayBxt+XXMPJ/Sw4lRIeXHhnKZeJbYpilh4 cxEHvTTiBE3SVgLXexwX8qZOxWL+ZLwjISxJOGHC0YVIt5Tlzmlaz/0teW8tPyQm6j gtzTaQLoUq7d9VAHLXw0jLBeA4QT83UsRj7gwWhLeDI5rfxPVlDUSCQ+1EDgQU6QG5 ReoyVRVDCVzSSGY7w6OXMum71pNkI1uKXRR+E1pZvTyKGZcq4OomE4/7P2VOVrFnbp LsHCOlDRRDbQEYOyyaLfa+JXcgWQDXXQGkCwaC8tDggPRmFXIvYVAqDor62o4WBNvi By5TX8OM//+ig== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Wolfram Sang , linux-mmc@vger.kernel.org Cc: Simon Horman , Yoshihiro Shimoda , Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 1/3] mmc: tmio: move mmc_gpio_request_cd() before mmc_add_host() Date: Wed, 8 Nov 2017 19:16:58 +0900 Message-Id: <1510136220-31853-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510136220-31853-1-git-send-email-yamada.masahiro@socionext.com> References: <1510136220-31853-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 Drivers do not need to call mmc_gpiod_request_cd_irq() explicitly because mmc_start_host() calls it. To make it work, cd_gpio must be set before mmc_add_host(). Signed-off-by: Masahiro Yamada --- drivers/mmc/host/tmio_mmc_core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 2abc6bc..7c0e952 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1201,6 +1201,12 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host, if (ret < 0) return ret; + if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { + ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0); + if (ret) + return ret; + } + mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; mmc->caps2 |= pdata->capabilities2; mmc->max_segs = pdata->max_segs ? : 32; @@ -1296,14 +1302,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host, dev_pm_qos_expose_latency_limit(&pdev->dev, 100); - if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { - ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0); - if (ret) - goto remove_host; - - mmc_gpiod_request_cd_irq(mmc); - } - return 0; remove_host: From patchwork Wed Nov 8 10:17:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 118231 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5096849qgn; Wed, 8 Nov 2017 02:18:02 -0800 (PST) X-Google-Smtp-Source: ABhQp+RfDA+sl5ZtTcoLsTz87PRf5AUZR/OKpI6L0AVNvcUBYLe4lFW/+CHaSp3l5CEI/nV+5GEt X-Received: by 10.98.163.2 with SMTP id s2mr1999192pfe.242.1510136282103; Wed, 08 Nov 2017 02:18:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510136282; cv=none; d=google.com; s=arc-20160816; b=fKfKp+Eb9h16yOn8+WFQZ8xzp57HowxcaUImLLAmF8gltlrvJ5SY94goCGZNLNdgPA n0Sl/R7IAGkuR2Kq0gHBPk4IN+qy+7yDgv+nOk1WF1DfYwKBgBgUMS+GP2kS5cm3qWsP r6XQ2J1iHSI+wP3DNJcuz2wPDzF92LxQxB2c8YA0T+t5jz1MN21d2lz1vdGDCcZOzycq dwsr9Mcw7N94PD+xylnkq9XthpJA0R7W2USDE8t4PELf1qFafjqi1BmCtJkGeNFJ6Xqk pHpSJ9GZdGBLf1x5fqSUqsPVfL+C2FHdvcVu6Oun0f4c0Ztdx98hvy+4xbviS4TivWeU QrYQ== 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=GuKB96dcGdQfu6iXjOTP420hBSRp41XJ7fnGkFFBrLE=; b=xGgBTbXDFPrkCi6LIrwGxQ1LlS77qnMnYasOW0vHQl2HR8GWbJSVIP16g1xi0QSdTu VLluIlPaveq49zqTlgZST8HS2n39yTi1i2uaDb9zugArX2No7MYFK87YYRzzCBjOapSO tAIh3RN/U6cf4bDdE6vDO7OWtalHHQf1ZDvvqwMOR4TXZgtgM2BXD2J/M4XwFpVsMKxv AH3o0S+MmSWIYTMzb55Yx4Ua9lRptkx1DjDdP7Cst1q9SU0RrggAsSJ4zlwdqZhwI3iE W+GZNMtSMxjtDMpPwREYQaQZhoRT8g1kzyDmh19cadsRFN0TE7dTSpbJrh25tF6YofE0 JSjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=GNLkzQyg; 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 102si3416888pld.614.2017.11.08.02.18.01; Wed, 08 Nov 2017 02:18:02 -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=GNLkzQyg; 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 S1752102AbdKHKR7 (ORCPT + 26 others); Wed, 8 Nov 2017 05:17:59 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:43215 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751489AbdKHKR4 (ORCPT ); Wed, 8 Nov 2017 05:17:56 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id vA8AH4rv031631; Wed, 8 Nov 2017 19:17:07 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com vA8AH4rv031631 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1510136227; bh=GuKB96dcGdQfu6iXjOTP420hBSRp41XJ7fnGkFFBrLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GNLkzQygjhj0jMQtI4uegDy2XgJ0OT3AXKDJ62GZXY4Ihq+RH9ZnWc1bd//3TK1OI IhIyuOReCi8FSJePCbB7RQaDP6EcPU/A4l461WkC+4z4eG26O33koWPT1Oed82gGEv bOroHP434uo/hFX74UzcXq8qFJGXWopgcBNezil7dA9kq3u+Y+Ghp7TGaX7NLXk7aW NpVFJF5kIiI+KOgROyon2try4hV2ZD4EM7zsADGzMmjsFEt1YVuFWoKDZv7rhQDK4r Gv1EDC0FcYUBysZ6XOtF8sCdHwA4/f57yt1TyVQwlCjt6WqA7htac7oHhJVOgjoP/v qYabE80AdAijQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Wolfram Sang , linux-mmc@vger.kernel.org Cc: Simon Horman , Yoshihiro Shimoda , Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 3/3] mmc: tmio: support IP-builtin card detection logic Date: Wed, 8 Nov 2017 19:17:00 +0900 Message-Id: <1510136220-31853-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510136220-31853-1-git-send-email-yamada.masahiro@socionext.com> References: <1510136220-31853-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 --- drivers/mmc/host/tmio_mmc_core.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 9fd0874..85a2944 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,