0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/clk-provider.h>
0011 #include <linux/slab.h>
0012 #include <linux/err.h>
0013 #include <linux/of.h>
0014 #include <linux/of_address.h>
0015 #include <linux/clk/ti.h>
0016
0017 #include "clock.h"
0018
0019 #undef pr_fmt
0020 #define pr_fmt(fmt) "%s: " fmt, __func__
0021
0022
0023
0024
0025
0026
0027
0028 static void __init of_ti_fixed_factor_clk_setup(struct device_node *node)
0029 {
0030 struct clk *clk;
0031 const char *clk_name = ti_dt_clk_name(node);
0032 const char *parent_name;
0033 u32 div, mult;
0034 u32 flags = 0;
0035
0036 if (of_property_read_u32(node, "ti,clock-div", &div)) {
0037 pr_err("%pOFn must have a clock-div property\n", node);
0038 return;
0039 }
0040
0041 if (of_property_read_u32(node, "ti,clock-mult", &mult)) {
0042 pr_err("%pOFn must have a clock-mult property\n", node);
0043 return;
0044 }
0045
0046 if (of_property_read_bool(node, "ti,set-rate-parent"))
0047 flags |= CLK_SET_RATE_PARENT;
0048
0049 parent_name = of_clk_get_parent_name(node, 0);
0050
0051 clk = clk_register_fixed_factor(NULL, clk_name, parent_name, flags,
0052 mult, div);
0053
0054 if (!IS_ERR(clk)) {
0055 of_clk_add_provider(node, of_clk_src_simple_get, clk);
0056 of_ti_clk_autoidle_setup(node);
0057 ti_clk_add_alias(NULL, clk, clk_name);
0058 }
0059 }
0060 CLK_OF_DECLARE(ti_fixed_factor_clk, "ti,fixed-factor-clock",
0061 of_ti_fixed_factor_clk_setup);