diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2013-07-01 04:16:10 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-07-01 06:12:20 -0400 |
commit | 7c9e6150f2e7cbd60e0bc9a19118ca1dc97d2780 (patch) | |
tree | 7956944a101488724bea59c15c7db7bcc2fa606a | |
parent | 8bb495e3f02401ee6f76d1b1d77f3ac9f079e376 (diff) |
ASoC: mxs: register saif mclk to clock framework
Mostly the mxs system design uses saif0 mclk output as the clock source
of codec. Since the mclk is implemented as a general divider with the
saif clk as the parent clock, let's register the mclk as a basic
clk-divider to common clock framework. Then with it being a clock
provdier, clk_get() call in codec driver probe function will just work.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | sound/soc/mxs/mxs-saif.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index d31dc52fa862..9ad6dccf791d 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/dma-mapping.h> | 25 | #include <linux/dma-mapping.h> |
26 | #include <linux/clk.h> | 26 | #include <linux/clk.h> |
27 | #include <linux/clk-provider.h> | ||
27 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
28 | #include <linux/time.h> | 29 | #include <linux/time.h> |
29 | #include <linux/fsl/mxs-dma.h> | 30 | #include <linux/fsl/mxs-dma.h> |
@@ -662,6 +663,33 @@ static irqreturn_t mxs_saif_irq(int irq, void *dev_id) | |||
662 | return IRQ_HANDLED; | 663 | return IRQ_HANDLED; |
663 | } | 664 | } |
664 | 665 | ||
666 | static int mxs_saif_mclk_init(struct platform_device *pdev) | ||
667 | { | ||
668 | struct mxs_saif *saif = platform_get_drvdata(pdev); | ||
669 | struct device_node *np = pdev->dev.of_node; | ||
670 | struct clk *clk; | ||
671 | int ret; | ||
672 | |||
673 | clk = clk_register_divider(&pdev->dev, "mxs_saif_mclk", | ||
674 | __clk_get_name(saif->clk), 0, | ||
675 | saif->base + SAIF_CTRL, | ||
676 | BP_SAIF_CTRL_BITCLK_MULT_RATE, 3, | ||
677 | 0, NULL); | ||
678 | if (IS_ERR(clk)) { | ||
679 | ret = PTR_ERR(clk); | ||
680 | if (ret == -EEXIST) | ||
681 | return 0; | ||
682 | dev_err(&pdev->dev, "failed to register mclk: %d\n", ret); | ||
683 | return PTR_ERR(clk); | ||
684 | } | ||
685 | |||
686 | ret = of_clk_add_provider(np, of_clk_src_simple_get, clk); | ||
687 | if (ret) | ||
688 | return ret; | ||
689 | |||
690 | return 0; | ||
691 | } | ||
692 | |||
665 | static int mxs_saif_probe(struct platform_device *pdev) | 693 | static int mxs_saif_probe(struct platform_device *pdev) |
666 | { | 694 | { |
667 | struct device_node *np = pdev->dev.of_node; | 695 | struct device_node *np = pdev->dev.of_node; |
@@ -769,6 +797,13 @@ static int mxs_saif_probe(struct platform_device *pdev) | |||
769 | 797 | ||
770 | platform_set_drvdata(pdev, saif); | 798 | platform_set_drvdata(pdev, saif); |
771 | 799 | ||
800 | /* We only support saif0 being tx and clock master */ | ||
801 | if (saif->id == 0) { | ||
802 | ret = mxs_saif_mclk_init(pdev); | ||
803 | if (ret) | ||
804 | dev_warn(&pdev->dev, "failed to init clocks\n"); | ||
805 | } | ||
806 | |||
772 | ret = snd_soc_register_component(&pdev->dev, &mxs_saif_component, | 807 | ret = snd_soc_register_component(&pdev->dev, &mxs_saif_component, |
773 | &mxs_saif_dai, 1); | 808 | &mxs_saif_dai, 1); |
774 | if (ret) { | 809 | if (ret) { |