diff mbox

[v2,1/3] mmc: sh_mobile_sdhi: add support for 2 clocks

Message ID 20170117195940.25092-2-chris.brandt@renesas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Brandt Jan. 17, 2017, 7:59 p.m. UTC
Some controllers have 2 clock sources instead of 1, so they both need
to be turned on/off.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Wolfram Sang Jan. 17, 2017, 8:30 p.m. UTC | #1
Hi Chris,

> +	struct clk *clk2;

I'd vote for 'clk_cd' since we are explicitly requesting that clock for
it.

> +	ret = clk_prepare_enable(priv->clk2);
> +	if (ret < 0)
> +		return ret;

You need to disable clk when failing.

Regards,

   Wolfram

--
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
Chris Brandt Jan. 18, 2017, 2:53 p.m. UTC | #2
Hi Wolfram,

On Tuesday, January 17, 2017, Wolfram Sang wrote:
> Hi Chris,
> 
> > +	struct clk *clk2;
> 
> I'd vote for 'clk_cd' since we are explicitly requesting that clock for it.
> 
> > +	ret = clk_prepare_enable(priv->clk2);
> > +	if (ret < 0)
> > +		return ret;
> 
> You need to disable clk when failing.
> 
> Regards,
> 
>    Wolfram


Thanks for the feedback. I will make those changes.

Chris
--
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 mbox

Patch

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 59db14b..5ad5744 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 *clk2;
 	struct tmio_mmc_data mmc_data;
 	struct tmio_mmc_dma dma_priv;
 	struct pinctrl *pinctrl;
@@ -190,6 +191,10 @@  static int sh_mobile_sdhi_clk_enable(struct tmio_mmc_host *host)
 	if (ret < 0)
 		return ret;
 
+	ret = clk_prepare_enable(priv->clk2);
+	if (ret < 0)
+		return ret;
+
 	/*
 	 * The clock driver may not know what maximum frequency
 	 * actually works, so it should be set with the max-frequency
@@ -255,6 +260,8 @@  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);
+	if (priv->clk2)
+		clk_disable_unprepare(priv->clk2);
 }
 
 static int sh_mobile_sdhi_card_busy(struct mmc_host *mmc)
@@ -572,6 +579,10 @@  static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 		goto eprobe;
 	}
 
+	priv->clk2 = devm_clk_get(&pdev->dev, "carddetect");
+	if (IS_ERR(priv->clk2))
+		priv->clk2 = NULL;
+
 	priv->pinctrl = devm_pinctrl_get(&pdev->dev);
 	if (!IS_ERR(priv->pinctrl)) {
 		priv->pins_default = pinctrl_lookup_state(priv->pinctrl,