diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2015-04-26 15:54:29 +0200 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2015-06-03 08:44:33 +0200 |
commit | 11f68120095d6040abd2eb37bf21bb9450646304 (patch) | |
tree | 3fcf81cd9661d6f1771a4f542deb9d01b2f0aa5d /drivers/clk/imx/clk.c | |
parent | ARM: imx: remove inclusions of platform headers (diff) | |
download | linux-11f68120095d6040abd2eb37bf21bb9450646304.tar.xz linux-11f68120095d6040abd2eb37bf21bb9450646304.zip |
ARM: imx: move clock drivers into drivers/clk
After the cleanup on clock drivers, they are now ready to be moved into
drivers/clk. Let's move them into drivers/clk/imx folder.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'drivers/clk/imx/clk.c')
-rw-r--r-- | drivers/clk/imx/clk.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c new file mode 100644 index 000000000000..df12b5307175 --- /dev/null +++ b/drivers/clk/imx/clk.c @@ -0,0 +1,75 @@ +#include <linux/clk.h> +#include <linux/err.h> +#include <linux/of.h> +#include <linux/slab.h> +#include <linux/spinlock.h> +#include "clk.h" + +DEFINE_SPINLOCK(imx_ccm_lock); + +void __init imx_check_clocks(struct clk *clks[], unsigned int count) +{ + unsigned i; + + for (i = 0; i < count; i++) + if (IS_ERR(clks[i])) + pr_err("i.MX clk %u: register failed with %ld\n", + i, PTR_ERR(clks[i])); +} + +static struct clk * __init imx_obtain_fixed_clock_from_dt(const char *name) +{ + struct of_phandle_args phandle; + 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; +} + +/* + * This fixups the register CCM_CSCMR1 write value. + * The write/read/divider values of the aclk_podf field + * of that register have the relationship described by + * the following table: + * + * write value read value divider + * 3b'000 3b'110 7 + * 3b'001 3b'111 8 + * 3b'010 3b'100 5 + * 3b'011 3b'101 6 + * 3b'100 3b'010 3 + * 3b'101 3b'011 4 + * 3b'110 3b'000 1 + * 3b'111 3b'001 2(default) + * + * That's why we do the xor operation below. + */ +#define CSCMR1_FIXUP 0x00600000 + +void imx_cscmr1_fixup(u32 *val) +{ + *val ^= CSCMR1_FIXUP; + return; +} |