aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/omap
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2010-10-08 13:40:19 -0400
committerPaul Walmsley <paul@pwsan.com>2010-10-08 13:40:19 -0400
commitd13586574d373ef40acd4725c9a269daa355e412 (patch)
tree93e4a7c46fa0c2e1cccea572ef995dbde5c1fd19 /sound/soc/omap
parentcf4c87abe238ec17cd0255b4e21abd949d7f811e (diff)
OMAP: McBSP: implement functional clock switching via clock framework
Previously the OMAP McBSP ASoC driver implemented CLKS switching by using omap_ctrl_{read,write}l() directly. This is against policy; the OMAP System Control Module functions are not intended to be exported to drivers. These symbols are no longer exported, so as a result, the OMAP McBSP ASoC driver does not build as a module. Resolve the CLKS clock changing portion of this problem by creating a clock parent changing function that lives in arch/arm/mach-omap2/mcbsp.c, and modify the ASoC driver to use it. Due to the unfortunate way that McBSP support is implemented in ASoC and the OMAP tree, this symbol must be exported for use by sound/soc/omap/omap-mcbsp.c. Going forward, the McBSP device driver should be moved from arch/arm/*omap* into drivers/ or sound/soc/* and the CPU DAI driver should be implemented as a platform_driver as many other ASoC CPU DAI drivers are. These two steps should resolve many of the layering problems, which will rapidly reappear during a McBSP hwmod/PM runtime conversions. Signed-off-by: Paul Walmsley <paul@pwsan.com> Acked-by: Jarkko Nikula <jhnikula@gmail.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/omap')
-rw-r--r--sound/soc/omap/omap-mcbsp.c69
1 files changed, 13 insertions, 56 deletions
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index f50a5abb470f..b59ad11466a9 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -31,7 +31,6 @@
31#include <sound/initval.h> 31#include <sound/initval.h>
32#include <sound/soc.h> 32#include <sound/soc.h>
33 33
34#include <plat/control.h>
35#include <plat/dma.h> 34#include <plat/dma.h>
36#include <plat/mcbsp.h> 35#include <plat/mcbsp.h>
37#include "omap-mcbsp.h" 36#include "omap-mcbsp.h"
@@ -608,66 +607,12 @@ static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai,
608 return 0; 607 return 0;
609} 608}
610 609
611static int omap_mcbsp_dai_set_clks_src(struct omap_mcbsp_data *mcbsp_data,
612 int clk_id)
613{
614 int sel_bit;
615 u16 reg, reg_devconf1 = OMAP243X_CONTROL_DEVCONF1;
616
617 if (cpu_class_is_omap1()) {
618 /* OMAP1's can use only external source clock */
619 if (unlikely(clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK))
620 return -EINVAL;
621 else
622 return 0;
623 }
624
625 if (cpu_is_omap2420() && mcbsp_data->bus_id > 1)
626 return -EINVAL;
627
628 if (cpu_is_omap343x())
629 reg_devconf1 = OMAP343X_CONTROL_DEVCONF1;
630
631 switch (mcbsp_data->bus_id) {
632 case 0:
633 reg = OMAP2_CONTROL_DEVCONF0;
634 sel_bit = 2;
635 break;
636 case 1:
637 reg = OMAP2_CONTROL_DEVCONF0;
638 sel_bit = 6;
639 break;
640 case 2:
641 reg = reg_devconf1;
642 sel_bit = 0;
643 break;
644 case 3:
645 reg = reg_devconf1;
646 sel_bit = 2;
647 break;
648 case 4:
649 reg = reg_devconf1;
650 sel_bit = 4;
651 break;
652 default:
653 return -EINVAL;
654 }
655
656 if (clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK)
657 omap_ctrl_writel(omap_ctrl_readl(reg) & ~(1 << sel_bit), reg);
658 else
659 omap_ctrl_writel(omap_ctrl_readl(reg) | (1 << sel_bit), reg);
660
661 return 0;
662}
663
664static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, 610static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
665 int clk_id, unsigned int freq, 611 int clk_id, unsigned int freq,
666 int dir) 612 int dir)
667{ 613{
668 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); 614 struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
669 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; 615 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
670 struct omap_mcbsp_platform_data *pdata = cpu_dai->dev->platform_data;
671 int err = 0; 616 int err = 0;
672 617
673 /* The McBSP signal muxing functions are only available on McBSP1 */ 618 /* The McBSP signal muxing functions are only available on McBSP1 */
@@ -685,8 +630,20 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
685 regs->srgr2 |= CLKSM; 630 regs->srgr2 |= CLKSM;
686 break; 631 break;
687 case OMAP_MCBSP_SYSCLK_CLKS_FCLK: 632 case OMAP_MCBSP_SYSCLK_CLKS_FCLK:
633 if (cpu_class_is_omap1()) {
634 err = -EINVAL;
635 break;
636 }
637 err = omap2_mcbsp_set_clks_src(mcbsp_data->bus_id,
638 MCBSP_CLKS_PRCM_SRC);
639 break;
688 case OMAP_MCBSP_SYSCLK_CLKS_EXT: 640 case OMAP_MCBSP_SYSCLK_CLKS_EXT:
689 err = omap_mcbsp_dai_set_clks_src(mcbsp_data, clk_id); 641 if (cpu_class_is_omap1()) {
642 err = 0;
643 break;
644 }
645 err = omap2_mcbsp_set_clks_src(mcbsp_data->bus_id,
646 MCBSP_CLKS_PAD_SRC);
690 break; 647 break;
691 648
692 case OMAP_MCBSP_SYSCLK_CLKX_EXT: 649 case OMAP_MCBSP_SYSCLK_CLKX_EXT: