From patchwork Wed Jan 17 16:28:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 124856 Delivered-To: patch@linaro.org Received: by 10.46.62.1 with SMTP id l1csp107875lja; Wed, 17 Jan 2018 08:42:36 -0800 (PST) X-Google-Smtp-Source: ACJfBovfO48GoyWlqG2M6kOg91fAZT+qJvbqW+xIaU1YypV7bNFbBxvpn0X7Aot4GwzG3kiSdV0J X-Received: by 10.101.93.17 with SMTP id e17mr26322556pgr.352.1516207356389; Wed, 17 Jan 2018 08:42:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516207356; cv=none; d=google.com; s=arc-20160816; b=v47LkGkh7oXa1mFxNx/7ZN838vm8+ihMvjCIdL+v3u2QvF5Eiihx6qb0r0b0bD+GZm OyiBajzD0xNb2hdsJoDeLgpvcOE/UIz3J0aDRNS9b/C+xHbN0vkbWsYKkG41BY+Sxuzz 7iYz6SYhemAalkFqPhRKIyw5gbiModa3sz0kHsBkywBzsOYCcUvG9hPiCuCFTej6zwo6 IJh56jwqmlBNVjOav6pVGURnwUjtFmBvaEebWp15wGcMoROTAcFgeLhAIEcjJ2YIOv4m UCqK9Bf8a9VMfyw1S1BQixp21IoQ+M3MeFeSq35WN8RfN+ceuRgpx0Q7H8hzDDwQzIL3 HwIA== 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=mAPgSWH8/eIDxxmXVYP+KoakTmi8hyUn0AZ8LhfbZKg=; b=C6V/DB+awWxGZyYoHrhSNgbvo5jdV0NEBk5K3qCnKQMqf1juPx0Lxp8sUy8cO4+3qo T8C64zlthwqLIWa+vM/KXdQHZM5KfpcmsW5j0H25flGFav6wvewSqq3nfsVcOYCSukhh 3BlbC9zsnoBz0LSfkEZkBd/COQ7rjaBDeKb+OqA7jstTG7moEppjcyRakolNik3WlS6L Q91eWjwJTHYMP2VeWrzkvS3fO6VMMLrmGXpysRsULJnxsc94BKneF4LVZ7VpxYQ4wW9e I1ioW3Xzh1eumVeg01gLP8WZwyWd9jbsC3Idx7fkll/GZw6ilZ4bACe3VHWQ40BgpfYV SwKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=kng9cCH6; 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 s15si4153362pgf.99.2018.01.17.08.42.36; Wed, 17 Jan 2018 08:42:36 -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=kng9cCH6; 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 S1754450AbeAQQme (ORCPT + 6 others); Wed, 17 Jan 2018 11:42:34 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:36680 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753793AbeAQQ3d (ORCPT ); Wed, 17 Jan 2018 11:29:33 -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 w0HGSIKm014790; Thu, 18 Jan 2018 01:28:21 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w0HGSIKm014790 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1516206501; bh=EbiI0F/b5y6e/wHWRoyBwpGIBwNGuCfFqPD9oTlOBEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kng9cCH6gishcDPu93HTTrm8L+t5oLgUs4SJkwQ+4A69unLUmQ5P0cXid1TO3BHAM 5jAhtDLHXTvE3NgYeawyIjDyp4WUH0rY2L+E7cY/d+yCnSdzeaxptL5AnUcVIw4vtW NWnD9pYtoHBnu3fZphg9muk3iWtSaTTQWFuxJ7P8o5s94EY+u4IV5rDyReQEsf8zDD DNiMADF+dHI2VTisEENVZYkaArVl9JW5HN0BtRC3q4uzLkrgCdt5e6JSD4aAUpbTKS T9rc3Ce2BPgUV2co/K2IxZRG4GT2bJkXZ3UgPAevAIer4lp0dhtz/BBTV+obcne3tn 2m+ExCCqdqpHw== 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 02/16] mmc: tmio: move clk_enable/disable out of tmio_mmc_host_probe() Date: Thu, 18 Jan 2018 01:28:02 +0900 Message-Id: <1516206496-16612-3-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-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The clock is enabled in the tmio_mmc_host_probe(). It also prevents drivers from performing platform-specific settings before mmc_add_host() because the register access generally requires a clock. Enable/disable the clock in drivers' probe/remove. Also, I passed tmio_mmc_data to tmio_mmc_host_alloc() because renesas_sdhi_clk_enable() needs it to get the private data from tmio_mmc_host. Signed-off-by: Masahiro Yamada Reviewed-by: Wolfram Sang --- Changes in v3: None Changes in v2: - Newly added drivers/mmc/host/renesas_sdhi_core.c | 13 ++++++++++--- drivers/mmc/host/tmio_mmc.c | 7 +++++-- drivers/mmc/host/tmio_mmc.h | 4 ++-- drivers/mmc/host/tmio_mmc_core.c | 33 +++++++++++++-------------------- 4 files changed, 30 insertions(+), 27 deletions(-) -- 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/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index ccdde27..e18a1c5 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -511,7 +511,7 @@ int renesas_sdhi_probe(struct platform_device *pdev, "state_uhs"); } - host = tmio_mmc_host_alloc(pdev); + host = tmio_mmc_host_alloc(pdev, mmc_data); if (IS_ERR(host)) return PTR_ERR(host); @@ -571,10 +571,14 @@ int renesas_sdhi_probe(struct platform_device *pdev, /* All SDHI have SDIO status bits which must be 1 */ mmc_data->flags |= TMIO_MMC_SDIO_STATUS_SETBITS; - ret = tmio_mmc_host_probe(host, mmc_data, dma_ops); - if (ret < 0) + ret = renesas_sdhi_clk_enable(host); + if (ret) goto efree; + ret = tmio_mmc_host_probe(host, dma_ops); + if (ret < 0) + goto edisclk; + /* One Gen2 SDHI incarnation does NOT have a CBSY bit */ if (sd_ctrl_read16(host, CTL_VERSION) == SDHI_VER_GEN2_SDR50) mmc_data->flags &= ~TMIO_MMC_HAVE_CBSY; @@ -635,6 +639,8 @@ int renesas_sdhi_probe(struct platform_device *pdev, eirq: tmio_mmc_host_remove(host); +edisclk: + renesas_sdhi_clk_disable(host); efree: tmio_mmc_host_free(host); @@ -647,6 +653,7 @@ int renesas_sdhi_remove(struct platform_device *pdev) struct tmio_mmc_host *host = platform_get_drvdata(pdev); tmio_mmc_host_remove(host); + renesas_sdhi_clk_disable(host); return 0; } diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c index d660816..11b87ce 100644 --- a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c @@ -92,7 +92,7 @@ static int tmio_mmc_probe(struct platform_device *pdev) pdata->flags |= TMIO_MMC_HAVE_HIGH_REG; - host = tmio_mmc_host_alloc(pdev); + host = tmio_mmc_host_alloc(pdev, pdata); if (IS_ERR(host)) { ret = PTR_ERR(host); goto cell_disable; @@ -101,7 +101,10 @@ static int tmio_mmc_probe(struct platform_device *pdev) /* SD control register space size is 0x200, 0x400 for bus_shift=1 */ host->bus_shift = resource_size(res) >> 10; - ret = tmio_mmc_host_probe(host, pdata, NULL); + host->mmc->f_max = pdata->hclk; + host->mmc->f_min = pdata->hclk / 512; + + ret = tmio_mmc_host_probe(host, NULL); if (ret) goto host_free; diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index 27894474..f46d282 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -195,10 +195,10 @@ struct tmio_mmc_host { const struct tmio_mmc_dma_ops *dma_ops; }; -struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev); +struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev, + struct tmio_mmc_data *pdata); void tmio_mmc_host_free(struct tmio_mmc_host *host); int tmio_mmc_host_probe(struct tmio_mmc_host *host, - struct tmio_mmc_data *pdata, const struct tmio_mmc_dma_ops *dma_ops); void tmio_mmc_host_remove(struct tmio_mmc_host *host); void tmio_mmc_do_data_irq(struct tmio_mmc_host *host); diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 5f0f12a..55442ed 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1145,8 +1145,8 @@ static void tmio_mmc_of_parse(struct platform_device *pdev, pdata->flags |= TMIO_MMC_WRPROTECT_DISABLE; } -struct tmio_mmc_host* -tmio_mmc_host_alloc(struct platform_device *pdev) +struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev, + struct tmio_mmc_data *pdata) { struct tmio_mmc_host *host; struct mmc_host *mmc; @@ -1166,9 +1166,12 @@ tmio_mmc_host_alloc(struct platform_device *pdev) host->ctl = ctl; host->mmc = mmc; host->pdev = pdev; + host->pdata = pdata; host->ops = tmio_mmc_ops; mmc->ops = &host->ops; + platform_set_drvdata(pdev, host); + return host; } EXPORT_SYMBOL_GPL(tmio_mmc_host_alloc); @@ -1180,14 +1183,21 @@ void tmio_mmc_host_free(struct tmio_mmc_host *host) EXPORT_SYMBOL_GPL(tmio_mmc_host_free); int tmio_mmc_host_probe(struct tmio_mmc_host *_host, - struct tmio_mmc_data *pdata, const struct tmio_mmc_dma_ops *dma_ops) { struct platform_device *pdev = _host->pdev; + struct tmio_mmc_data *pdata = _host->pdata; struct mmc_host *mmc = _host->mmc; int ret; u32 irq_mask = TMIO_MASK_CMD; + /* + * Check the sanity of mmc->f_min to prevent tmio_mmc_set_clock() from + * looping forever... + */ + if (mmc->f_min == 0) + return -EINVAL; + tmio_mmc_of_parse(pdev, pdata); if (!(pdata->flags & TMIO_MMC_HAS_IDLE_WAIT)) @@ -1197,9 +1207,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host, if (ret < 0) return ret; - _host->pdata = pdata; - platform_set_drvdata(pdev, _host); - _host->set_pwr = pdata->set_pwr; _host->set_clk_div = pdata->set_clk_div; @@ -1247,18 +1254,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host, if (pdata->flags & TMIO_MMC_MIN_RCAR2) _host->native_hotplug = true; - if (tmio_mmc_clk_enable(_host) < 0) { - mmc->f_max = pdata->hclk; - mmc->f_min = mmc->f_max / 512; - } - - /* - * Check the sanity of mmc->f_min to prevent tmio_mmc_set_clock() from - * looping forever... - */ - if (mmc->f_min == 0) - return -EINVAL; - /* * While using internal tmio hardware logic for card detection, we need * to ensure it stays powered for it to work. @@ -1336,8 +1331,6 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); - - tmio_mmc_clk_disable(host); } EXPORT_SYMBOL_GPL(tmio_mmc_host_remove); From patchwork Wed Jan 17 16:28:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 124850 Delivered-To: patch@linaro.org Received: by 10.46.62.1 with SMTP id l1csp107474lja; Wed, 17 Jan 2018 08:41:20 -0800 (PST) X-Google-Smtp-Source: ACJfBou6DgJhxRnTKhL3b9PkhSgrtoD4XJMeJcj+VXiinGpleL7r8RiJD+PtlJ6cVeQTYUJrLT7T X-Received: by 10.159.216.151 with SMTP id s23mr7910207plp.238.1516207280289; Wed, 17 Jan 2018 08:41:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516207280; cv=none; d=google.com; s=arc-20160816; b=dw1q1srQAXdOrGt8q1fcmWZ2gxxQS5G5nb6v2RyfBWrSBqSpRCKgchtK/L2eW0oh61 gRq2Eh8L/yuActND50+wURn0NXnCvPSRrTVhUL/F8fJFbDPofZyXwtiUJqKD3PwQSb8B 0LNZfjmIQtoLFOgEUsOkzwROG6j6xyG9OeeLsapbWy8/khP89UD2GRNd4R4KFqRUJ+Y5 UqOTO2hYJzJftD/HSF4/KqTjO3zr2wT5V9PB2TBJohxpS7cWC4VaCednoRMat0M32Xb/ fNHwcqJnivhVra6j2VZe4jHnsQMTp4D5QCq+R8FSlnbymnNhg1oGlPfx120rHyfF5gh0 H35w== 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=VskXZGIiLQjgHfeEhwjx6YSQ4hpTUAcuXnvpYbdLLQ4=; b=PkeNhZPm61ILZNsTsSLSvBMnjexBXopp7Tg4bU1SHxl95KYHcp0zEOsFWu3m8FhH1P hPrBFP8wEO8LykVSn/RoFs/USs4i6kM6ehDbMzBQY5BoIh4+njizo3IiWVkz7G9dlopx fgg/zIhs5/KT4o4kJ0cE57lOkuJZK9pBmUh6HJHTF0mp0ZN+JXzI1r06H6p2REZvydba pOTvQWIcWmyHTnI0359qz0g52f7nQTfEtGUW5Fu1aCxWZbIP8CvSjCVcdsUR8tP8eSXK CKvbfLsGW3r6QO6P4/lAtAbNnCEMOFxS9GAH3Nuku82/sXI8K1nyupGYmOeOtY4neXHI oOKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=pjWEyHSB; 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 z20si4777327pfj.118.2018.01.17.08.41.20; Wed, 17 Jan 2018 08:41:20 -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=pjWEyHSB; 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 S1753541AbeAQQlR (ORCPT + 6 others); Wed, 17 Jan 2018 11:41:17 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:36694 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753853AbeAQQ3d (ORCPT ); Wed, 17 Jan 2018 11:29:33 -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 w0HGSIKr014790; Thu, 18 Jan 2018 01:28:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w0HGSIKr014790 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1516206506; bh=n7GB6rVKXHTWfyLcP5CptiEMlV/r5K5TCrsqjrnv6NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pjWEyHSBYw+pbVjzW4gobdn4ziEDeMJEXmXXl7Y6Stka6DnpcZpCqAHw5+g5y8Jxq OzSTWTDAo1W9i0GUHO4IDo9rRk07H15B2sknp/ALvRxDCysrN7KPAj6TUoyOMtRbb2 DWb2s0TsOgV667FbfDibET7UsSe0Pj2PClDTZ7Ljwz2tdd1QtnmCzhjrR/7kUpmvj/ i9X9QTRENJ342FHymt+dzJcjYBCIBFzTkkrV1OB4lSj6cf0ehOxKZ3/BvkfCp+DGbv Ch7NO642gMya8S/NJeOJlzuv0YZhIOLCoQd8Jj8rDTWiyka0PfwQUOT3S3S4wCoTQn kvzhUeP8L4hSA== 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 07/16] mmc: renesas_sdhi: use MMC_CAP2_NO_WRITE_PROTECT instead of TMIO own flag Date: Thu, 18 Jan 2018 01:28:07 +0900 Message-Id: <1516206496-16612-8-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-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org TMIO_MMC_WRPROTECT_DISABLE is equivalent to MMC_CAP2_NO_WRITE_PROTECT. The flag is propagated as follows: renesas_sdhi_of_data::capabilities2 -> tmio_mmc_data::capabilities2 -> mmc_host::caps2 Only the difference is the TMIO_... makes tmio_mmc_get_ro() return 0 (i.e. it does not affect mmc_gpio_get_ro() at all), while MMC_CAP2_... returns 0 before calling ->get_ro() hook (i.e. it affects both IP own logic and GPIO detection). The TMIO MMC drivers do not set-up gpio_ro by themselves. Only the possibility, if any, would be DT specifies "wp-gpios" property, and gpio_ro is set by mmc_gpiod_request_ro() called from mmc_of_parse(). However, it does not make sense to specify "wp-gpios" property and TMIO_MMC_WRPROTECT_DISABLE at the same time. I checked under arch/arm/boot/dts/ and arch/arm64/boot/dts/renesas/, and I did not see any Renesas boards with "wp-gpios". So, this conversion should be safe. Signed-off-by: Masahiro Yamada --- Changes in v3: - newly added Changes in v2: None drivers/mmc/host/renesas_sdhi_internal_dmac.c | 6 +++--- drivers/mmc/host/renesas_sdhi_sys_dmac.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) -- 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 Reviewed-by: Wolfram Sang diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c index 02c2724..0d1f95e 100644 --- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c @@ -71,11 +71,11 @@ static struct renesas_sdhi_scc rcar_gen3_scc_taps[] = { }; static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = { - .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | - TMIO_MMC_CLK_ACTUAL | TMIO_MMC_HAVE_CBSY | - TMIO_MMC_MIN_RCAR2, + .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL | + TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2, .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | MMC_CAP_CMD23, + .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT, .bus_shift = 2, .scc_offset = 0x1000, .taps = rcar_gen3_scc_taps, diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c index c8a74b2..afdb66b 100644 --- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c @@ -40,9 +40,9 @@ static const struct renesas_sdhi_of_data of_rz_compatible = { }; static const struct renesas_sdhi_of_data of_rcar_gen1_compatible = { - .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | - TMIO_MMC_CLK_ACTUAL, + .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL, .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, + .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT, }; /* Definitions for sampling clocks */ @@ -58,11 +58,11 @@ static struct renesas_sdhi_scc rcar_gen2_scc_taps[] = { }; static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = { - .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | - TMIO_MMC_CLK_ACTUAL | TMIO_MMC_HAVE_CBSY | - TMIO_MMC_MIN_RCAR2, + .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL | + TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2, .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | MMC_CAP_CMD23, + .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT, .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES, .dma_rx_offset = 0x2000, .scc_offset = 0x0300, @@ -79,11 +79,11 @@ static struct renesas_sdhi_scc rcar_gen3_scc_taps[] = { }; static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = { - .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | - TMIO_MMC_CLK_ACTUAL | TMIO_MMC_HAVE_CBSY | - TMIO_MMC_MIN_RCAR2, + .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL | + TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2, .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | MMC_CAP_CMD23, + .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT, .bus_shift = 2, .scc_offset = 0x1000, .taps = rcar_gen3_scc_taps, From patchwork Wed Jan 17 16:28:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 124863 Delivered-To: patch@linaro.org Received: by 10.46.62.1 with SMTP id l1csp108220lja; Wed, 17 Jan 2018 08:43:39 -0800 (PST) X-Google-Smtp-Source: ACJfBouLlPHjy5KILtYvyNIWlI3/HHwom/3q/TsqnIg7s2KslsP6lYckmMj31rp+pgQbHOjuDHH+ X-Received: by 10.98.98.5 with SMTP id w5mr38369318pfb.233.1516207418866; Wed, 17 Jan 2018 08:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516207418; cv=none; d=google.com; s=arc-20160816; b=b/thPhR1mHgF1Zdbp6zK8jQYYvLJimOkU0K4Llgm4QVM1iQsHIWRQrEU47Y+s63X3I /oKxpUVoQRTrJQXFvSw5kA56Eiq8IlsoNK/wwrxipQlVPs8aACLBkUXMwdPnuatxnyZd 25pFr06K3qsTVSoG85uOpS/c4odO3A8dQPvSU3bNxpwr58iRDwdwYGcVdnb/MyGK1KDo dpKxCU0/siyGWB80p4vUrUA74mM+G+zkAHI94N7t+s0qxh1G5SaioiT5B1yYfCVvAjJY 7okNFkJ0/EZiE52dh1R4U1qrHxKIi1+92/oKuQOFIVCUInye0X0G+O41W5XWGFoi6eM0 CeIQ== 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=ZVQUgH/WacIygQaUdJm4zUU7OUxNeiBXZgYLjjAqygI=; b=EmfSMyh8wVtB6Eu9fA6wC8mzo8ruW1gr8CPGIsUzUhTujYBvcabDaHqNoEOcomS3K3 qUniIOaH7NAafJJXrr8zHOrwWcl+E8CkIrUFHHu7+WaygMs686uh52dMliGQ8Z+ga8To v0uVVlchZSqj3iEhDSs/j9yc1o1WR5up7meE0PezAPIQv7gbBM22gmaeLyt4My1a8LVd /nJEiKyNABCs3NGa8mohNDnONjbJ++wps0ieel2ecTaMtnjOfxJeh1/fLt/wYhRhi05L 6Su4O2Ssmg66k+hDyqUh1MOpRF+FoGBcmeeL6JCJMHKbTEoZ42LNJaEyHdcfGHjC+Apx pDPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=QzviiQyd; 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 d18si4031993pgv.575.2018.01.17.08.43.38; Wed, 17 Jan 2018 08:43:38 -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=QzviiQyd; 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 S1753984AbeAQQng (ORCPT + 6 others); Wed, 17 Jan 2018 11:43:36 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:36679 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753614AbeAQQ3d (ORCPT ); Wed, 17 Jan 2018 11:29:33 -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 w0HGSIKt014790; Thu, 18 Jan 2018 01:28:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w0HGSIKt014790 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1516206507; bh=En3rOM+T1cFJZYJRzc3Vu+g6rDcfF9CtX1LHZw+//m0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QzviiQydikQDllhlESSik454LOST/b9VY7C4N7S/hER1V81tjcmkNObf/UF1T3jJ+ +jYOUtKEs5H1kcOwYiW/uxIRrRJqx7f8254UM1XMqy2Ua0mDtYXM8rC/tONluz36Jm So92s2QpVNoHMR/vXhZD4wlH2XLJJxb/ZRsmpm1RskYCI97dcE52eQC5KhGZ3n71fP TDLMrKB3HAOScSNwQp9pZwn4aj3IXqL7VyPksanx3u0bSe0Dt2bXN/4kZyEoMEXGqX ZYdc2jog/nUE289k5JVjJeWl6E4BmoG0hiiKEJEBFQAT1/LzkdDlFuvIPCmxXcYr9G GUkBwDHwquwXw== 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 09/16] mmc: tmio: use MMC_CAP2_NO_WRITE_PROTECT instead of TMIO own flag Date: Thu, 18 Jan 2018 01:28:09 +0900 Message-Id: <1516206496-16612-10-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-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org TMIO_MMC_WRPROTECT_DISABLE is equivalent to MMC_CAP2_NO_WRITE_PROTECT. Only the difference is the TMIO_... makes tmio_mmc_get_ro() return 0 (i.e. it does not affect mmc_gpio_get_ro() at all), while MMC_CAP2_... returns 0 before calling ->get_ro() hook (i.e. it affects both IP own logic and GPIO detection). The TMIO MMC drivers do not set-up gpio_ro by themselves. Only the possibility, if any, would be DT specifies "wp-gpios" property, and gpio_ro is set by mmc_gpiod_request_ro() called from mmc_of_parse(). However, it does not make sense to specify "wp-gpios" property and "toshiba,mmc-wrprotect-disable" at the same time. I checked under arch/arm/boot/dts/ and arch/arm64/boot/dts/renesas/, and I did not see any Renesas boards with "wp-gpios". So, this conversion should be safe. Signed-off-by: Masahiro Yamada --- Changes in v3: - newly added Changes in v2: None drivers/mmc/host/tmio_mmc_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 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 Reviewed-by: Wolfram Sang diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 0032707..bdbff2d 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1128,7 +1128,7 @@ static int tmio_mmc_init_ocr(struct tmio_mmc_host *host) } static void tmio_mmc_of_parse(struct platform_device *pdev, - struct tmio_mmc_data *pdata) + struct mmc_host *mmc) { const struct device_node *np = pdev->dev.of_node; @@ -1136,7 +1136,7 @@ static void tmio_mmc_of_parse(struct platform_device *pdev, return; if (of_get_property(np, "toshiba,mmc-wrprotect-disable", NULL)) - pdata->flags |= TMIO_MMC_WRPROTECT_DISABLE; + mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT; } struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev, @@ -1171,7 +1171,7 @@ struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev, goto free; } - tmio_mmc_of_parse(pdev, pdata); + tmio_mmc_of_parse(pdev, mmc); platform_set_drvdata(pdev, host); From patchwork Wed Jan 17 16:28:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 124832 Delivered-To: patch@linaro.org Received: by 10.46.62.1 with SMTP id l1csp103378lja; Wed, 17 Jan 2018 08:29:35 -0800 (PST) X-Google-Smtp-Source: ACJfBot87mUBSuzpAdW/ZbbEc12RVJRoA1s6ZooimLAfmc6fQn9JvkTtfCFAtiB1WQpZbwFddddX X-Received: by 10.84.242.68 with SMTP id c4mr38916942pll.414.1516206575223; Wed, 17 Jan 2018 08:29:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516206575; cv=none; d=google.com; s=arc-20160816; b=e+0d99SnsguNz7WoWFBuA/VXl+3MqaEsa28sHOUS2YPeqJupIJHsLvEvbL+uLDERxp W9i0S6WY9RGl4W6GAwYWlyfwxbuSPDLV6gV3RcSVovaN4IfQ0MPO5e2sExvWT/I3qvoI aUzoeYBItIOlqn0cQfhbHo3II3mRElUUJUWce98Y47wedLjwrXxsdAGTv+xQp68ym7xk VRjQ99XOUA9ua5SmlMZlMHcHQQrf1EbGvbOzxbVoFKdaNTJzAUj9+QhqVGN7qX5rgqyR hsXl0fD1NIO1CV1ZowRoP8qlhd7ad0EOYhkFE8RCCurSLUPIpV80UdSF/kiXXZ5uJeGY LH1A== 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=r4ZmCZDxlHlOo96b+S+ZUMmcTaYSQ2A7BfWV1AvMTI4=; b=sMd9LcE6aG6oSa5nPidS1LsXzMWYzQ79/IayKWsHmbKFUdPMC11jx9RLkpJ1wGPVUB Kg8gKWlpz71ctMJNAI+GAa/USgGLiKChr6CQN7O5wZ2vunuCooiwzKOhRjfFD+loZ9g5 +Lz4DIPMjMwlY8xmjpmCZYJsDoD7ZGEqMCkLF5zPwAsYtlr3MyQ4zh6S4JlC7D3InFet xWHDOKY0osYGHnJM5LcDrESWlScsPiPbZn6gfMIPySAuwnz+XKw2DNHX6+1BQn/WquPT qrmE31bGMbFKV9QkprAU1CZgVE35PDzg+Uc/aDSA8jahunBKR3boQoUtiRsDVrQzBgOz K1vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=daTMoMcJ; 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 w4si3995573pgp.486.2018.01.17.08.29.35; Wed, 17 Jan 2018 08:29:35 -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=daTMoMcJ; 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 S1753888AbeAQQ3d (ORCPT + 6 others); Wed, 17 Jan 2018 11:29:33 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:36664 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753762AbeAQQ3b (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 w0HGSIKx014790; Thu, 18 Jan 2018 01:28:30 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w0HGSIKx014790 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1516206511; bh=dU3McduzXP/rbLl+hbKK4/rd/IunZM3/a+/UEQ1++QU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=daTMoMcJPomiR92ABGFE1vwVXjEeDkrXkV7mjvJitii6fdHAj5M19GEXlcWMNcoiR CW0j1qaGtMNMgz67EaNOlQ8Kv10o0Z9Yvggx3Mu9knO2aSnQUM9o8/rcCrBKQbF4XE OaQ3g3vNSZSKVRb51DliesJig7yHxd3thq1ktHTCSfXnkF6lSyfu4EAUy10djGj8yR bYc71BCiqvlRFdPRU0G6jH+zq8yLv6ugUsBgS6G2uarfb8vHvUsY97bQlKDcT1l5zn sncqzW+uNWAUt/3F+TUM4o5pQmFFJAhJGK79zl9XgPLZPQMYkM7wEPdwNEsuHBg4ur McVUImfGtvNTA== 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 13/16] mmc: tmio: fix never-detected card insertion bug Date: Thu, 18 Jan 2018 01:28:13 +0900 Message-Id: <1516206496-16612-14-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-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The TMIO mmc cannot detect the card insertion in native_hotplug mode if the driver is probed without a card inserted. The reason is obvious; all IRQs are disabled by tmio_mmc_host_probe(), as follows: tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL); The card event IRQs are first enabled by tmio_mmc_start_command() as follows: if (!host->native_hotplug) irq_mask &= ~(TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT); tmio_mmc_enable_mmc_irqs(host, irq_mask); If the driver is probed without a card, tmio_mmc_start_command() is never called in the first place. So, the card is never detected. The card event IRQs must be enabled in probe/resume functions. Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: - Newly added drivers/mmc/host/tmio_mmc_core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 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 Reviewed-by: Wolfram Sang diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index b20d5c5..0e3dc8c 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -350,8 +350,6 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, c |= TRANSFER_READ; } - if (!host->native_hotplug) - irq_mask &= ~(TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT); tmio_mmc_enable_mmc_irqs(host, irq_mask); /* Fire off the command */ @@ -1294,11 +1292,13 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) irq_mask |= TMIO_MASK_READOP; if (!_host->chan_tx) irq_mask |= TMIO_MASK_WRITEOP; - if (!_host->native_hotplug) - irq_mask &= ~(TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT); _host->sdcard_irq_mask &= ~irq_mask; + if (_host->native_hotplug) + tmio_mmc_enable_mmc_irqs(_host, + TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT); + spin_lock_init(&_host->lock); mutex_init(&_host->ios_lock); @@ -1382,6 +1382,10 @@ int tmio_mmc_host_runtime_resume(struct device *dev) if (host->clk_cache) tmio_mmc_set_clock(host, host->clk_cache); + if (host->native_hotplug) + tmio_mmc_enable_mmc_irqs(host, + TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT); + tmio_mmc_enable_dma(host, true); if (tmio_mmc_can_retune(host) && host->select_tuning(host))