ARM: Orion: Audio: Add clk/clkdev support
authorAndrew Lunn <andrew@lunn.ch>
Fri, 9 Mar 2012 08:56:41 +0000 (09:56 +0100)
committerMike Turquette <mturquette@linaro.org>
Tue, 8 May 2012 23:34:03 +0000 (16:34 -0700)
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Jamie Lentin <jm@lentin.co.uk>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
arch/arm/mach-kirkwood/common.c
sound/soc/kirkwood/kirkwood-i2s.c
sound/soc/kirkwood/kirkwood.h

index aa36e1bce87444090d8512dba9fade13e8d11000..850ba64109cb5667e68f5e2ae34935ce2526d464 100644 (file)
@@ -87,7 +87,7 @@ static struct clk __init *kirkwood_register_gate(const char *name, u8 bit_idx)
 void __init kirkwood_clk_init(void)
 {
        struct clk *runit, *ge0, *ge1, *sata0, *sata1, *usb0, *sdio;
-       struct clk *crypto, *xor0, *xor1, *pex0, *pex1;
+       struct clk *crypto, *xor0, *xor1, *pex0, *pex1, *audio;
 
        tclk = clk_register_fixed_rate(NULL, "tclk", NULL,
                                       CLK_IS_ROOT, kirkwood_tclk);
@@ -104,7 +104,7 @@ void __init kirkwood_clk_init(void)
        xor1 = kirkwood_register_gate("xor1",   CGC_BIT_XOR1);
        pex0 = kirkwood_register_gate("pex0",   CGC_BIT_PEX0);
        pex1 = kirkwood_register_gate("pex1",   CGC_BIT_PEX1);
-       kirkwood_register_gate("audio",  CGC_BIT_AUDIO);
+       audio = kirkwood_register_gate("audio",  CGC_BIT_AUDIO);
        kirkwood_register_gate("tdm",    CGC_BIT_TDM);
        kirkwood_register_gate("tsu",    CGC_BIT_TSU);
 
@@ -124,6 +124,7 @@ void __init kirkwood_clk_init(void)
        orion_clkdev_add(NULL, MV_XOR_SHARED_NAME ".1", xor1);
        orion_clkdev_add("0", "pcie", pex0);
        orion_clkdev_add("1", "pcie", pex1);
+       orion_clkdev_add(NULL, "kirkwood-i2s", audio);
 }
 
 /*****************************************************************************
index 3cb9aa4299d38ff3845dfc83b96c7b701f73cea5..fa4556750451ce29f7236174356573b65e52e56c 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/slab.h>
 #include <linux/mbus.h>
 #include <linux/delay.h>
+#include <linux/clk.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
@@ -449,6 +450,14 @@ static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 
        priv->burst = data->burst;
 
+       priv->clk = clk_get(&pdev->dev, NULL);
+       if (IS_ERR(priv->clk)) {
+               dev_err(&pdev->dev, "no clock\n");
+               err = PTR_ERR(priv->clk);
+               goto err_ioremap;
+       }
+       clk_prepare_enable(priv->clk);
+
        return snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai);
 
 err_ioremap:
@@ -466,6 +475,10 @@ static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev)
        struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
 
        snd_soc_unregister_dai(&pdev->dev);
+
+       clk_disable_unprepare(priv->clk);
+       clk_put(priv->clk);
+
        iounmap(priv->io);
        release_mem_region(priv->mem->start, SZ_16K);
        kfree(priv);
index 9047436b3937248c91ba8a3630176dd169bd2fd5..f9084d83e6bd2ae178d562c2c243de4bb1fb6fcf 100644 (file)
@@ -123,6 +123,7 @@ struct kirkwood_dma_data {
        void __iomem *io;
        int irq;
        int burst;
+       struct clk *clk;
 };
 
 #endif