2013-04-23 20:16:59 +08:00
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/slab.h>
|
2012-09-11 14:50:00 +08:00
|
|
|
#include <linux/spinlock.h>
|
2013-03-25 20:20:38 +08:00
|
|
|
#include "clk.h"
|
2012-09-11 14:50:00 +08:00
|
|
|
|
|
|
|
DEFINE_SPINLOCK(imx_ccm_lock);
|
2013-04-23 20:16:59 +08:00
|
|
|
|
|
|
|
static struct clk * __init imx_obtain_fixed_clock_from_dt(const char *name)
|
|
|
|
{
|
|
|
|
struct of_phandle_args phandle = {0};
|
|
|
|
struct clk *clk = ERR_PTR(-ENODEV);
|
|
|
|
char *path;
|
|
|
|
|
|
|
|
path = kasprintf(GFP_KERNEL, "/clocks/%s", name);
|
|
|
|
if (!path)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
phandle.np = of_find_node_by_path(path);
|
|
|
|
kfree(path);
|
|
|
|
|
|
|
|
if (phandle.np) {
|
|
|
|
clk = of_clk_get_from_provider(&phandle);
|
|
|
|
of_node_put(phandle.np);
|
|
|
|
}
|
|
|
|
return clk;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct clk * __init imx_obtain_fixed_clock(
|
|
|
|
const char *name, unsigned long rate)
|
|
|
|
{
|
|
|
|
struct clk *clk;
|
|
|
|
|
|
|
|
clk = imx_obtain_fixed_clock_from_dt(name);
|
|
|
|
if (IS_ERR(clk))
|
|
|
|
clk = imx_clk_fixed(name, rate);
|
|
|
|
return clk;
|
|
|
|
}
|