1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <linux/clk-provider.h>
18#include <linux/of.h>
19#include <linux/of_address.h>
20
21#define SUN4I_CODEC_GATE 31
22
23static void __init sun4i_codec_clk_setup(struct device_node *node)
24{
25 struct clk *clk;
26 const char *clk_name = node->name, *parent_name;
27 void __iomem *reg;
28
29 reg = of_io_request_and_map(node, 0, of_node_full_name(node));
30 if (IS_ERR(reg))
31 return;
32
33 of_property_read_string(node, "clock-output-names", &clk_name);
34 parent_name = of_clk_get_parent_name(node, 0);
35
36 clk = clk_register_gate(NULL, clk_name, parent_name,
37 CLK_SET_RATE_PARENT, reg,
38 SUN4I_CODEC_GATE, 0, NULL);
39
40 if (!IS_ERR(clk))
41 of_clk_add_provider(node, of_clk_src_simple_get, clk);
42}
43CLK_OF_DECLARE(sun4i_codec, "allwinner,sun4i-a10-codec-clk",
44 sun4i_codec_clk_setup);
45