1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include <linux/clk-provider.h>
19#include <linux/slab.h>
20#include <linux/err.h>
21#include <linux/of.h>
22#include <linux/of_address.h>
23#include <linux/clk/ti.h>
24
25#include "clock.h"
26
27#undef pr_fmt
28#define pr_fmt(fmt) "%s: " fmt, __func__
29
30
31
32
33
34
35
36static void __init of_ti_fixed_factor_clk_setup(struct device_node *node)
37{
38 struct clk *clk;
39 const char *clk_name = node->name;
40 const char *parent_name;
41 u32 div, mult;
42 u32 flags = 0;
43
44 if (of_property_read_u32(node, "ti,clock-div", &div)) {
45 pr_err("%pOFn must have a clock-div property\n", node);
46 return;
47 }
48
49 if (of_property_read_u32(node, "ti,clock-mult", &mult)) {
50 pr_err("%pOFn must have a clock-mult property\n", node);
51 return;
52 }
53
54 if (of_property_read_bool(node, "ti,set-rate-parent"))
55 flags |= CLK_SET_RATE_PARENT;
56
57 parent_name = of_clk_get_parent_name(node, 0);
58
59 clk = clk_register_fixed_factor(NULL, clk_name, parent_name, flags,
60 mult, div);
61
62 if (!IS_ERR(clk)) {
63 of_clk_add_provider(node, of_clk_src_simple_get, clk);
64 of_ti_clk_autoidle_setup(node);
65 ti_clk_add_alias(NULL, clk, clk_name);
66 }
67}
68CLK_OF_DECLARE(ti_fixed_factor_clk, "ti,fixed-factor-clock",
69 of_ti_fixed_factor_clk_setup);
70