aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/mcbsp.c
diff options
context:
space:
mode:
authorJarkko Nikula <jarkko.nikula@bitmer.com>2011-09-26 03:45:48 -0400
committerTony Lindgren <tony@atomide.com>2011-09-26 20:48:59 -0400
commit09d28d2c19fe5c2d51b3133329584166dec89f86 (patch)
tree90f327bc24348d6f4157e305d4efe6ac6b834ecb /arch/arm/mach-omap2/mcbsp.c
parent6e574123712b4fb89546b1304dd5438669057723 (diff)
ARM: OMAP: mcbsp: Start generalize omap2_mcbsp_set_clks_src
This generalizes the omap2_mcbsp_set_clks_src implementation between generic McBSP and OMAP2 specific McBSP code. Currently this function is used to select either internal fclk or clks pin as a McBSP CLKS source on OMAP2+. Implement generalization by having an optional set_clk_src function pointer in platform data that is used to select parent for a given clock. Idea is to pass higher level source clock name (later coming from client driver) that platform specific code will map to platform specific clock name. API cleanup between McBSP and client code comes later. Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/mcbsp.c')
-rw-r--r--arch/arm/mach-omap2/mcbsp.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
index 92bd5e22a24e..3dd4c473809e 100644
--- a/arch/arm/mach-omap2/mcbsp.c
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -63,37 +63,30 @@ void omap2_mcbsp1_mux_fsr_src(u8 mux)
63EXPORT_SYMBOL(omap2_mcbsp1_mux_fsr_src); 63EXPORT_SYMBOL(omap2_mcbsp1_mux_fsr_src);
64 64
65/* McBSP CLKS source switching function */ 65/* McBSP CLKS source switching function */
66 66static int omap2_mcbsp_set_clk_src(struct device *dev, struct clk *clk,
67int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id) 67 const char *src)
68{ 68{
69 struct omap_mcbsp *mcbsp;
70 struct clk *fck_src; 69 struct clk *fck_src;
71 char *fck_src_name; 70 char *fck_src_name;
72 int r; 71 int r;
73 72
74 if (!omap_mcbsp_check_valid_id(id)) { 73 if (!strcmp(src, "clks_ext"))
75 pr_err("%s: Invalid id (%d)\n", __func__, id + 1);
76 return -EINVAL;
77 }
78 mcbsp = id_to_mcbsp_ptr(id);
79
80 if (fck_src_id == MCBSP_CLKS_PAD_SRC)
81 fck_src_name = "pad_fck"; 74 fck_src_name = "pad_fck";
82 else if (fck_src_id == MCBSP_CLKS_PRCM_SRC) 75 else if (!strcmp(src, "clks_fclk"))
83 fck_src_name = "prcm_fck"; 76 fck_src_name = "prcm_fck";
84 else 77 else
85 return -EINVAL; 78 return -EINVAL;
86 79
87 fck_src = clk_get(mcbsp->dev, fck_src_name); 80 fck_src = clk_get(dev, fck_src_name);
88 if (IS_ERR_OR_NULL(fck_src)) { 81 if (IS_ERR_OR_NULL(fck_src)) {
89 pr_err("omap-mcbsp: %s: could not clk_get() %s\n", "clks", 82 pr_err("omap-mcbsp: %s: could not clk_get() %s\n", "clks",
90 fck_src_name); 83 fck_src_name);
91 return -EINVAL; 84 return -EINVAL;
92 } 85 }
93 86
94 pm_runtime_put_sync(mcbsp->dev); 87 pm_runtime_put_sync(dev);
95 88
96 r = clk_set_parent(mcbsp->fclk, fck_src); 89 r = clk_set_parent(clk, fck_src);
97 if (IS_ERR_VALUE(r)) { 90 if (IS_ERR_VALUE(r)) {
98 pr_err("omap-mcbsp: %s: could not clk_set_parent() to %s\n", 91 pr_err("omap-mcbsp: %s: could not clk_set_parent() to %s\n",
99 "clks", fck_src_name); 92 "clks", fck_src_name);
@@ -101,13 +94,12 @@ int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id)
101 return -EINVAL; 94 return -EINVAL;
102 } 95 }
103 96
104 pm_runtime_get_sync(mcbsp->dev); 97 pm_runtime_get_sync(dev);
105 98
106 clk_put(fck_src); 99 clk_put(fck_src);
107 100
108 return 0; 101 return 0;
109} 102}
110EXPORT_SYMBOL(omap2_mcbsp_set_clks_src);
111 103
112static int omap3_enable_st_clock(unsigned int id, bool enable) 104static int omap3_enable_st_clock(unsigned int id, bool enable)
113{ 105{
@@ -188,6 +180,7 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused)
188 name, oh->name); 180 name, oh->name);
189 return PTR_ERR(pdev); 181 return PTR_ERR(pdev);
190 } 182 }
183 pdata->set_clk_src = omap2_mcbsp_set_clk_src;
191 omap_mcbsp_count++; 184 omap_mcbsp_count++;
192 return 0; 185 return 0;
193} 186}