MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / fixed_clk_ofw_init

Function fixed_clk_ofw_init

components/drivers/clk/clk-fixed-rate.c:16–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include <drivers/platform.h>
15
16static rt_err_t fixed_clk_ofw_init(struct rt_platform_device *pdev, struct rt_clk_fixed_rate *clk_fixed)
17{
18 rt_err_t err = RT_EOK;
19 rt_uint32_t rate, accuracy;
20 struct rt_ofw_node *np = pdev->parent.ofw_node;
21 const char *clk_name = np->name;
22
23 if (!rt_ofw_prop_read_u32(np, "clock-frequency", &rate))
24 {
25 rt_ofw_prop_read_u32(np, "clock-accuracy", &accuracy);
26 rt_ofw_prop_read_string(np, "clock-output-names", &clk_name);
27
28 clk_fixed->clk.name = clk_name;
29 clk_fixed->clk.rate = rate;
30 clk_fixed->clk.min_rate = rate;
31 clk_fixed->clk.max_rate = rate;
32 clk_fixed->fixed_rate = rate;
33 clk_fixed->fixed_accuracy = accuracy;
34
35 rt_ofw_data(np) = &clk_fixed->clk;
36 }
37 else
38 {
39 err = -RT_EIO;
40 }
41
42 return err;
43}
44
45static rt_err_t fixed_clk_probe(struct rt_platform_device *pdev)
46{

Callers 1

fixed_clk_probeFunction · 0.85

Calls 2

rt_ofw_prop_read_u32Function · 0.85
rt_ofw_prop_read_stringFunction · 0.85

Tested by

no test coverage detected