This source file includes following definitions.
- sun6i_a31_apb0_clk_probe
1
2
3
4
5
6
7
8
9
10 #include <linux/clk-provider.h>
11 #include <linux/init.h>
12 #include <linux/of.h>
13 #include <linux/platform_device.h>
14
15
16
17
18
19
20
21
22 static const struct clk_div_table sun6i_a31_apb0_divs[] = {
23 { .val = 0, .div = 2, },
24 { .val = 1, .div = 2, },
25 { .val = 2, .div = 4, },
26 { .val = 3, .div = 8, },
27 { },
28 };
29
30 static int sun6i_a31_apb0_clk_probe(struct platform_device *pdev)
31 {
32 struct device_node *np = pdev->dev.of_node;
33 const char *clk_name = np->name;
34 const char *clk_parent;
35 struct resource *r;
36 void __iomem *reg;
37 struct clk *clk;
38
39 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
40 reg = devm_ioremap_resource(&pdev->dev, r);
41 if (IS_ERR(reg))
42 return PTR_ERR(reg);
43
44 clk_parent = of_clk_get_parent_name(np, 0);
45 if (!clk_parent)
46 return -EINVAL;
47
48 of_property_read_string(np, "clock-output-names", &clk_name);
49
50 clk = clk_register_divider_table(&pdev->dev, clk_name, clk_parent,
51 0, reg, 0, 2, 0, sun6i_a31_apb0_divs,
52 NULL);
53 if (IS_ERR(clk))
54 return PTR_ERR(clk);
55
56 return of_clk_add_provider(np, of_clk_src_simple_get, clk);
57 }
58
59 static const struct of_device_id sun6i_a31_apb0_clk_dt_ids[] = {
60 { .compatible = "allwinner,sun6i-a31-apb0-clk" },
61 { }
62 };
63
64 static struct platform_driver sun6i_a31_apb0_clk_driver = {
65 .driver = {
66 .name = "sun6i-a31-apb0-clk",
67 .of_match_table = sun6i_a31_apb0_clk_dt_ids,
68 },
69 .probe = sun6i_a31_apb0_clk_probe,
70 };
71 builtin_platform_driver(sun6i_a31_apb0_clk_driver);