tegra sdhci: Enable/disable SDCLK source in set_clock host_op
authorTodd Poynor <toddpoynor@google.com>
Mon, 11 Oct 2010 22:31:42 +0000 (15:31 -0700)
committerTodd Poynor <toddpoynor@google.com>
Thu, 4 Nov 2010 01:06:00 +0000 (18:06 -0700)
Change-Id: I2295a044140f0f388564ea3a63dd52445adff63b
Signed-off-by: Todd Poynor <toddpoynor@google.com>
drivers/mmc/host/sdhci-tegra.c

index 361c8e7806837771c09bbe8434358192601ca2c0..35ec8e385db8a21e0cefdb24d9e1a714853b6038 100644 (file)
 
 #define DRIVER_NAME    "sdhci-tegra"
 
+#define SDHCI_VENDOR_CLOCK_CNTRL       0x100
+
 struct tegra_sdhci_host {
        struct sdhci_host *sdhci;
        struct clk *clk;
+       int clk_enabled;
 };
 
 static irqreturn_t carddetect_irq(int irq, void *data)
@@ -48,8 +51,26 @@ static int tegra_sdhci_enable_dma(struct sdhci_host *host)
        return 0;
 }
 
+static void tegra_sdhci_set_clock(struct sdhci_host *sdhci, unsigned int clock)
+{
+       struct tegra_sdhci_host *host = sdhci_priv(sdhci);
+       pr_info("tegra sdhci clock %s %u\n",
+               mmc_hostname(sdhci->mmc), clock);
+
+       if (clock && !host->clk_enabled) {
+               clk_enable(host->clk);
+               sdhci_writeb(sdhci, 1, SDHCI_VENDOR_CLOCK_CNTRL);
+               host->clk_enabled = 1;
+       } else if (!clock && host->clk_enabled) {
+               sdhci_writeb(sdhci, 0, SDHCI_VENDOR_CLOCK_CNTRL);
+               clk_disable(host->clk);
+               host->clk_enabled = 0;
+       }
+}
+
 static struct sdhci_ops tegra_sdhci_ops = {
        .enable_dma = tegra_sdhci_enable_dma,
+       .set_clock = tegra_sdhci_set_clock,
 };
 
 static int __devinit tegra_sdhci_probe(struct platform_device *pdev)
@@ -97,6 +118,7 @@ static int __devinit tegra_sdhci_probe(struct platform_device *pdev)
        if (rc != 0)
                goto err_clkput;
 
+       host->clk_enabled = 1;
        sdhci->hw_name = "tegra";
        sdhci->ops = &tegra_sdhci_ops;
        sdhci->irq = irq;