From: Chris Brandt <chris.brandt@renesas.com>
To: Ulf Hansson <ulf.hansson@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Simon Horman <horms@verge.net.au>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Geert Uytterhoeven <geert@linux-m68k.org>
Cc: devicetree@vger.kernel.org, linux-mmc@vger.kernel.org,
linux-renesas-soc@vger.kernel.org,
Chris Brandt <chris.brandt@renesas.com>
Subject: [PATCH v6 1/3] mmc: sh_mobile_sdhi: add support for 2 clocks
Date: Wed, 25 Jan 2017 15:28:08 -0500 [thread overview]
Message-ID: <20170125202810.16876-2-chris.brandt@renesas.com> (raw)
In-Reply-To: <20170125202810.16876-1-chris.brandt@renesas.com>
Some controllers have 2 clock sources instead of 1. The 2nd clock
is for the internal card detect logic and must be enabled/disabled
along with the main core clock for proper operation.
Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
v5:
* call clk_disable_unprepare even if clk_cd is NULL
v4:
* add technical explanation within probe routine
v3:
* add more clarification to the commit log
v2:
* changed clk2 to clk_cd
* disable clk if clk_cd enable fails
* changed clock name from "carddetect" to "cd"
---
drivers/mmc/host/sh_mobile_sdhi.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 59db14b..d964a0d 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -143,6 +143,7 @@ MODULE_DEVICE_TABLE(of, sh_mobile_sdhi_of_match);
struct sh_mobile_sdhi {
struct clk *clk;
+ struct clk *clk_cd;
struct tmio_mmc_data mmc_data;
struct tmio_mmc_dma dma_priv;
struct pinctrl *pinctrl;
@@ -190,6 +191,12 @@ static int sh_mobile_sdhi_clk_enable(struct tmio_mmc_host *host)
if (ret < 0)
return ret;
+ ret = clk_prepare_enable(priv->clk_cd);
+ if (ret < 0) {
+ clk_disable_unprepare(priv->clk);
+ return ret;
+ }
+
/*
* The clock driver may not know what maximum frequency
* actually works, so it should be set with the max-frequency
@@ -255,6 +262,7 @@ static void sh_mobile_sdhi_clk_disable(struct tmio_mmc_host *host)
struct sh_mobile_sdhi *priv = host_to_priv(host);
clk_disable_unprepare(priv->clk);
+ clk_disable_unprepare(priv->clk_cd);
}
static int sh_mobile_sdhi_card_busy(struct mmc_host *mmc)
@@ -572,6 +580,21 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
goto eprobe;
}
+ /*
+ * Some controllers provide a 2nd clock just to run the internal card
+ * detection logic. Unfortunately, the existing driver architecture does
+ * not support a separation of clocks for runtime PM usage. When
+ * native hotplug is used, the tmio driver assumes that the core
+ * must continue to run for card detect to stay active, so we cannot
+ * disable it.
+ * Additionally, it is prohibited to supply a clock to the core but not
+ * to the card detect circuit. That leaves us with if separate clocks
+ * are presented, we must treat them both as virtually 1 clock.
+ */
+ priv->clk_cd = devm_clk_get(&pdev->dev, "cd");
+ if (IS_ERR(priv->clk_cd))
+ priv->clk_cd = NULL;
+
priv->pinctrl = devm_pinctrl_get(&pdev->dev);
if (!IS_ERR(priv->pinctrl)) {
priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
--
2.10.1
next prev parent reply other threads:[~2017-01-25 20:28 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-25 20:28 [PATCH v6 0/3] mmc: sh_mobile_sdhi: fix missing r7s72100 clocks Chris Brandt
2017-01-25 20:28 ` Chris Brandt [this message]
2017-01-25 20:28 ` [PATCH v6 2/3] mmc: sh_mobile_sdhi: explain clock bindings Chris Brandt
[not found] ` <20170125202810.16876-3-chris.brandt-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2017-01-30 20:37 ` Rob Herring
2017-01-25 20:28 ` [PATCH v6 3/3] ARM: dts: r7s72100: update sdhi " Chris Brandt
[not found] ` <20170125202810.16876-1-chris.brandt-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2017-01-26 8:07 ` [PATCH v6 0/3] mmc: sh_mobile_sdhi: fix missing r7s72100 clocks Ulf Hansson
2017-01-26 10:12 ` Wolfram Sang
2017-01-26 12:53 ` Chris Brandt
2017-01-27 8:40 ` Simon Horman
2017-01-27 14:57 ` Ulf Hansson
2017-01-26 10:30 ` Simon Horman
[not found] ` <20170126103013.GB27721-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
2017-01-26 12:53 ` Chris Brandt
-- strict thread matches above, loose matches on Subject: below --
2017-01-26 14:53 [PATCH 0/4] arm64: renesas: enable M3ULCB board peripherals Vladimir Barinov
2017-01-26 14:54 ` [PATCH 1/4] arm64: dts: m3ulcb: enable I2C Vladimir Barinov
2017-02-01 12:35 ` Geert Uytterhoeven
2017-01-26 14:54 ` [PATCH 2/4] arm64: dts: m3ulcb: Update memory node to 2 GiB map Vladimir Barinov
2017-02-01 12:38 ` Geert Uytterhoeven
2017-02-02 18:19 ` Geert Uytterhoeven
2017-02-02 18:21 ` Vladimir Barinov
2017-01-26 14:54 ` [PATCH 3/4] arm64: dts: m3ulcb: enable EthernetAVB Vladimir Barinov
2017-02-01 13:10 ` Geert Uytterhoeven
2017-01-26 14:54 ` [PATCH 4/4] arm64: dts: m3ulcb: enable HS200 for eMMC Vladimir Barinov
[not found] ` <1485442422-18259-1-git-send-email-vladimir.barinov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-03-17 22:02 ` [PATCH 0/4] arm64: renesas: enable M3ULCB board peripherals Sjoerd Simons
[not found] ` <1489788135.8957.2.camel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2017-04-06 9:53 ` Geert Uytterhoeven
2017-04-07 13:52 ` Simon Horman
[not found] ` <20170407135212.GA24096-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
2017-04-08 13:18 ` Simon Horman
2017-04-18 1:01 ` Simon Horman
2017-01-26 15:13 [PATCH 0/2] arm64: renesas: enable H3ULCB " Vladimir Barinov
[not found] ` <1485443606-22566-1-git-send-email-vladimir.barinov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-01-26 15:13 ` [PATCH 1/2] arm64: dts: h3ulcb: Update memory node to 4 GiB map Vladimir Barinov
2017-02-01 12:40 ` Geert Uytterhoeven
2017-02-02 9:18 ` Simon Horman
[not found] ` <1485443632-22612-1-git-send-email-vladimir.barinov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
[not found] ` <1485442486-18427-1-git-send-email-vladimir.barinov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
[not found] ` <1485442469-18378-1-git-send-email-vladimir.barinov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
[not found] ` <1485442460-18339-1-git-send-email-vladimir.barinov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
[not found] ` <1485442449-18300-1-git-send-email-vladimir.barinov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2017-02-01 13:05 ` [PATCH 4/4] arm64: dts: m3ulcb: enable HS200 for eMMC Geert Uytterhoeven
2017-01-26 15:14 ` [PATCH 2/2] arm64: dts: h3ulcb: " Vladimir Barinov
2017-01-27 8:29 ` Simon Horman
2017-02-01 13:05 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170125202810.16876-2-chris.brandt@renesas.com \
--to=chris.brandt@renesas.com \
--cc=devicetree@vger.kernel.org \
--cc=geert@linux-m68k.org \
--cc=horms@verge.net.au \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).