summaryrefslogtreecommitdiffstats
path: root/sound/soc/tegra/tegra_asoc_utils.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2011-01-28 14:26:40 -0700
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-01-31 13:16:29 +0000
commitd64e57cef0436833cfc9620e350ec6f5b041c9a9 (patch)
tree173c1f1bf2b87dfdc3bd7da379b9cf67e07b7906 /sound/soc/tegra/tegra_asoc_utils.c
parentc244d477b7a5e0060b05d6ef90b7b29ef72a2188 (diff)
downloadlinux-d64e57cef0436833cfc9620e350ec6f5b041c9a9.tar.bz2
ASoC: Tegra: utils: Don't use global variables
Instead, have the machine driver provide storage for the utility data somehow. For Harmony in particular, store this within struct tegra_harmony, itself referenced by snd_soc_card's drvdata. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/tegra/tegra_asoc_utils.c')
-rw-r--r--sound/soc/tegra/tegra_asoc_utils.c91
1 files changed, 44 insertions, 47 deletions
diff --git a/sound/soc/tegra/tegra_asoc_utils.c b/sound/soc/tegra/tegra_asoc_utils.c
index cfe2ea890dc0..cb4fc13c7d22 100644
--- a/sound/soc/tegra/tegra_asoc_utils.c
+++ b/sound/soc/tegra/tegra_asoc_utils.c
@@ -21,20 +21,14 @@
*/
#include <linux/clk.h>
+#include <linux/device.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include "tegra_asoc_utils.h"
-#define PREFIX "ASoC Tegra: "
-
-static struct clk *clk_pll_a;
-static struct clk *clk_pll_a_out0;
-static struct clk *clk_cdev1;
-
-static int set_baseclock, set_mclk;
-
-int tegra_asoc_utils_set_rate(int srate, int mclk, int *mclk_change)
+int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
+ int mclk, int *mclk_change)
{
int new_baseclock;
int err;
@@ -58,95 +52,98 @@ int tegra_asoc_utils_set_rate(int srate, int mclk, int *mclk_change)
return -EINVAL;
}
- *mclk_change = ((new_baseclock != set_baseclock) ||
- (mclk != set_mclk));
+ *mclk_change = ((new_baseclock != data->set_baseclock) ||
+ (mclk != data->set_mclk));
if (!*mclk_change)
return 0;
- set_baseclock = 0;
- set_mclk = 0;
+ data->set_baseclock = 0;
+ data->set_mclk = 0;
- clk_disable(clk_cdev1);
- clk_disable(clk_pll_a_out0);
- clk_disable(clk_pll_a);
+ clk_disable(data->clk_cdev1);
+ clk_disable(data->clk_pll_a_out0);
+ clk_disable(data->clk_pll_a);
- err = clk_set_rate(clk_pll_a, new_baseclock);
+ err = clk_set_rate(data->clk_pll_a, new_baseclock);
if (err) {
- pr_err(PREFIX "Can't set pll_a rate: %d\n", err);
+ dev_err(data->dev, "Can't set pll_a rate: %d\n", err);
return err;
}
- err = clk_set_rate(clk_pll_a_out0, mclk);
+ err = clk_set_rate(data->clk_pll_a_out0, mclk);
if (err) {
- pr_err(PREFIX "Can't set pll_a_out0 rate: %d\n", err);
+ dev_err(data->dev, "Can't set pll_a_out0 rate: %d\n", err);
return err;
}
/* Don't set cdev1 rate; its locked to pll_a_out0 */
- err = clk_enable(clk_pll_a);
+ err = clk_enable(data->clk_pll_a);
if (err) {
- pr_err(PREFIX "Can't enable pll_a: %d\n", err);
+ dev_err(data->dev, "Can't enable pll_a: %d\n", err);
return err;
}
- err = clk_enable(clk_pll_a_out0);
+ err = clk_enable(data->clk_pll_a_out0);
if (err) {
- pr_err(PREFIX "Can't enable pll_a_out0: %d\n", err);
+ dev_err(data->dev, "Can't enable pll_a_out0: %d\n", err);
return err;
}
- err = clk_enable(clk_cdev1);
+ err = clk_enable(data->clk_cdev1);
if (err) {
- pr_err(PREFIX "Can't enable cdev1: %d\n", err);
+ dev_err(data->dev, "Can't enable cdev1: %d\n", err);
return err;
}
- set_baseclock = new_baseclock;
- set_mclk = mclk;
+ data->set_baseclock = new_baseclock;
+ data->set_mclk = mclk;
return 0;
}
-int tegra_asoc_utils_init(void)
+int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data,
+ struct device *dev)
{
int ret;
- clk_pll_a = clk_get_sys(NULL, "pll_a");
- if (IS_ERR(clk_pll_a)) {
- pr_err(PREFIX "Can't retrieve clk pll_a\n");
- ret = PTR_ERR(clk_pll_a);
+ data->dev = dev;
+
+ data->clk_pll_a = clk_get_sys(NULL, "pll_a");
+ if (IS_ERR(data->clk_pll_a)) {
+ dev_err(data->dev, "Can't retrieve clk pll_a\n");
+ ret = PTR_ERR(data->clk_pll_a);
goto err;
}
- clk_pll_a_out0 = clk_get_sys(NULL, "pll_a_out0");
- if (IS_ERR(clk_pll_a_out0)) {
- pr_err(PREFIX "Can't retrieve clk pll_a_out0\n");
- ret = PTR_ERR(clk_pll_a_out0);
+ data->clk_pll_a_out0 = clk_get_sys(NULL, "pll_a_out0");
+ if (IS_ERR(data->clk_pll_a_out0)) {
+ dev_err(data->dev, "Can't retrieve clk pll_a_out0\n");
+ ret = PTR_ERR(data->clk_pll_a_out0);
goto err_put_pll_a;
}
- clk_cdev1 = clk_get_sys(NULL, "cdev1");
- if (IS_ERR(clk_cdev1)) {
- pr_err(PREFIX "Can't retrieve clk cdev1\n");
- ret = PTR_ERR(clk_cdev1);
+ data->clk_cdev1 = clk_get_sys(NULL, "cdev1");
+ if (IS_ERR(data->clk_cdev1)) {
+ dev_err(data->dev, "Can't retrieve clk cdev1\n");
+ ret = PTR_ERR(data->clk_cdev1);
goto err_put_pll_a_out0;
}
return 0;
err_put_pll_a_out0:
- clk_put(clk_pll_a_out0);
+ clk_put(data->clk_pll_a_out0);
err_put_pll_a:
- clk_put(clk_pll_a);
+ clk_put(data->clk_pll_a);
err:
return ret;
}
-void tegra_asoc_utils_fini(void)
+void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data)
{
- clk_put(clk_cdev1);
- clk_put(clk_pll_a_out0);
- clk_put(clk_pll_a);
+ clk_put(data->clk_cdev1);
+ clk_put(data->clk_pll_a_out0);
+ clk_put(data->clk_pll_a);
}