diff mbox

[v4,5/8] mmc: sdhci-bcm-kona: Add basic use of clocks

Message ID 1386271244-3927-6-git-send-email-tim.kryger@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Tim Kryger Dec. 5, 2013, 7:20 p.m. UTC
Enable the external clock needed by the host controller during the
probe and disable it during the remove.

Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <matt.porter@linaro.org>
---
 drivers/mmc/host/sdhci-bcm-kona.c | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

Comments

Christian Daudt Dec. 14, 2013, 8:14 a.m. UTC | #1
On Thu, Dec 5, 2013 at 11:20 AM, Tim Kryger <tim.kryger@linaro.org> wrote:
> Enable the external clock needed by the host controller during the
> probe and disable it during the remove.
>
> Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
> Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
> Reviewed-by: Matt Porter <matt.porter@linaro.org>

Reviewed-by: Christian Daudt <bcm@fixthebug.org>

Chris,
 Are you ok with me pulling this patch along with the rest of the
patchset into the bcm tree?

 Thanks,
   csd
Christian Daudt Dec. 23, 2013, 8:26 a.m. UTC | #2
On Sat, Dec 14, 2013 at 12:14 AM, Christian Daudt <bcm@fixthebug.org> wrote:
> On Thu, Dec 5, 2013 at 11:20 AM, Tim Kryger <tim.kryger@linaro.org> wrote:
>> Enable the external clock needed by the host controller during the
>> probe and disable it during the remove.
>>
>> Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
>> Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
>> Reviewed-by: Matt Porter <matt.porter@linaro.org>
>
> Reviewed-by: Christian Daudt <bcm@fixthebug.org>
>
> Chris,
>  Are you ok with me pulling this patch along with the rest of the
> patchset into the bcm tree?
>
>  Thanks,
>    csd
Hi Chris,
 I'm hoping to get this patchset and "rename ARCH_BCM to
ARCH_BCM_MOBILE (mmc)" patch into 3.14 still, and these 2 patches are
waiting for your ack and confirmation that you're ok with me pulling
them through armsoc. Can you pls review them ?

 Thanks,
  csd
Tim Kryger Jan. 7, 2014, 7:37 p.m. UTC | #3
On Sat, Dec 14, 2013 at 12:14 AM, Christian Daudt <bcm@fixthebug.org> wrote:
> On Thu, Dec 5, 2013 at 11:20 AM, Tim Kryger <tim.kryger@linaro.org> wrote:
>> Enable the external clock needed by the host controller during the
>> probe and disable it during the remove.
>>
>> Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
>> Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
>> Reviewed-by: Matt Porter <matt.porter@linaro.org>
>
> Reviewed-by: Christian Daudt <bcm@fixthebug.org>
>
> Chris,
>  Are you ok with me pulling this patch along with the rest of the
> patchset into the bcm tree?
>
>  Thanks,
>    csd

Chris,

Can you please provide an answer to csd?

Thanks,
Tim Kryger
Tim Kryger Jan. 24, 2014, 5:07 p.m. UTC | #4
On Tue, Jan 7, 2014 at 11:37 AM, Tim Kryger <tim.kryger@linaro.org> wrote:
> On Sat, Dec 14, 2013 at 12:14 AM, Christian Daudt <bcm@fixthebug.org> wrote:
>> On Thu, Dec 5, 2013 at 11:20 AM, Tim Kryger <tim.kryger@linaro.org> wrote:
>>> Enable the external clock needed by the host controller during the
>>> probe and disable it during the remove.
>>>
>>> Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
>>> Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
>>> Reviewed-by: Matt Porter <matt.porter@linaro.org>
>>
>> Reviewed-by: Christian Daudt <bcm@fixthebug.org>
>>
>> Chris,
>>  Are you ok with me pulling this patch along with the rest of the
>> patchset into the bcm tree?
>>
>>  Thanks,
>>    csd
>
> Chris,
>
> Can you please provide an answer to csd?
>
> Thanks,
> Tim Kryger

Chris,

I haven't heard back so this patch has been dropped for 3.14 to allow
the remaining patches in the series to move forward.   As such, I will
be re-posting this patch for 3.15.  It is essential for the
bcm28155_ap board to transition away from fake fixed clocks to the
real clock driver.  This is because the bcm281xx clock driver does not
set the CLK_IGNORE_UNUSED flag for the SDHCI peripheral clocks and the
common clock code will shut them off in late init unless the SDHCI
driver has asked for them to be enabled.

Thanks,
Tim
Matt Porter Feb. 24, 2014, 7:33 p.m. UTC | #5
[trimmed cc]

On Fri, Jan 24, 2014 at 09:07:24AM -0800, Tim Kryger wrote:
> On Tue, Jan 7, 2014 at 11:37 AM, Tim Kryger <tim.kryger@linaro.org> wrote:
> > On Sat, Dec 14, 2013 at 12:14 AM, Christian Daudt <bcm@fixthebug.org> wrote:
> >> On Thu, Dec 5, 2013 at 11:20 AM, Tim Kryger <tim.kryger@linaro.org> wrote:
> >>> Enable the external clock needed by the host controller during the
> >>> probe and disable it during the remove.
> >>>
> >>> Signed-off-by: Tim Kryger <tim.kryger@linaro.org>
> >>> Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
> >>> Reviewed-by: Matt Porter <matt.porter@linaro.org>
> >>
> >> Reviewed-by: Christian Daudt <bcm@fixthebug.org>
> >>
> >> Chris,
> >>  Are you ok with me pulling this patch along with the rest of the
> >> patchset into the bcm tree?
> >>
> >>  Thanks,
> >>    csd
> >
> > Chris,
> >
> > Can you please provide an answer to csd?
> >
> > Thanks,
> > Tim Kryger
> 
> Chris,
> 
> I haven't heard back so this patch has been dropped for 3.14 to allow
> the remaining patches in the series to move forward.   As such, I will
> be re-posting this patch for 3.15.  It is essential for the
> bcm28155_ap board to transition away from fake fixed clocks to the
> real clock driver.  This is because the bcm281xx clock driver does not
> set the CLK_IGNORE_UNUSED flag for the SDHCI peripheral clocks and the
> common clock code will shut them off in late init unless the SDHCI
> driver has asked for them to be enabled.

I just queued Alex's patch for 3.15 that decouples the dependency
between this patch and the bcm kona common clock driver.

Chris: we no longer need this to be taken through arm-soc since removing
the dependency. Could you please take this patch through your tree for
3.15?

Thanks,
Matt
Chris Ball Feb. 24, 2014, 7:40 p.m. UTC | #6
Hi,

On Mon, Feb 24 2014, Matt Porter wrote:
> Chris: we no longer need this to be taken through arm-soc since removing
> the dependency. Could you please take this patch through your tree for
> 3.15?

Thanks, pushed to mmc-next for 3.15.

- Chris.
diff mbox

Patch

diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
index 7a190fe..923eefa 100644
--- a/drivers/mmc/host/sdhci-bcm-kona.c
+++ b/drivers/mmc/host/sdhci-bcm-kona.c
@@ -54,6 +54,7 @@ 
 
 struct sdhci_bcm_kona_dev {
 	struct mutex	write_lock; /* protect back to back writes */
+	struct clk	*external_clk;
 };
 
 
@@ -257,6 +258,24 @@  static int sdhci_bcm_kona_probe(struct platform_device *pdev)
 		goto err_pltfm_free;
 	}
 
+	/* Get and enable the external clock */
+	kona_dev->external_clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(kona_dev->external_clk)) {
+		dev_err(dev, "Failed to get external clock\n");
+		ret = PTR_ERR(kona_dev->external_clk);
+		goto err_pltfm_free;
+	}
+
+	if (clk_set_rate(kona_dev->external_clk, host->mmc->f_max) != 0) {
+		dev_err(dev, "Failed to set rate external clock\n");
+		goto err_pltfm_free;
+	}
+
+	if (clk_prepare_enable(kona_dev->external_clk) != 0) {
+		dev_err(dev, "Failed to enable external clock\n");
+		goto err_pltfm_free;
+	}
+
 	dev_dbg(dev, "non-removable=%c\n",
 		(host->mmc->caps & MMC_CAP_NONREMOVABLE) ? 'Y' : 'N');
 	dev_dbg(dev, "cd_gpio %c, wp_gpio %c\n",
@@ -271,7 +290,7 @@  static int sdhci_bcm_kona_probe(struct platform_device *pdev)
 
 	ret = sdhci_bcm_kona_sd_reset(host);
 	if (ret)
-		goto err_pltfm_free;
+		goto err_clk_disable;
 
 	sdhci_bcm_kona_sd_init(host);
 
@@ -307,6 +326,9 @@  err_remove_host:
 err_reset:
 	sdhci_bcm_kona_sd_reset(host);
 
+err_clk_disable:
+	clk_disable_unprepare(kona_dev->external_clk);
+
 err_pltfm_free:
 	sdhci_pltfm_free(pdev);
 
@@ -316,7 +338,18 @@  err_pltfm_free:
 
 static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev)
 {
-	return sdhci_pltfm_unregister(pdev);
+	struct sdhci_host *host = platform_get_drvdata(pdev);
+	struct sdhci_pltfm_host *pltfm_priv = sdhci_priv(host);
+	struct sdhci_bcm_kona_dev *kona_dev = sdhci_pltfm_priv(pltfm_priv);
+	int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
+
+	sdhci_remove_host(host, dead);
+
+	clk_disable_unprepare(kona_dev->external_clk);
+
+	sdhci_pltfm_free(pdev);
+
+	return 0;
 }
 
 static struct platform_driver sdhci_bcm_kona_driver = {