当前位置: 代码迷 >> 综合 >> Linux clk子系统(5)--fixed-factor-clk
  详细解决方案

Linux clk子系统(5)--fixed-factor-clk

热度:46   发布时间:2024-03-07 05:40:38.0

1.fixed-factor-clk的注册流程

    fix-factor-clk (factor: 因素; 要素; 因子; 因数; (增或减的) 数量,倍数)描述的是固定分频的clk,leo_clk_match数组中fix-factor-clk类型的元素

{ .compatible = "leo,rosc0_div4", .data = of_fixed_factor_clk_setup, },
{ .compatible = "leo,pll2_div5", .data = of_fixed_factor_clk_setup, },
{ .compatible = "leo,pll2_div50", .data = of_fixed_factor_clk_setup, },
{ .compatible = "leo,fastboot_div2", .data = of_fixed_factor_clk_setup, },
{ .compatible = "leo,ddrmclk", .data = of_fixed_factor_clk_setup, },
{ .compatible = "leo,lcclk", .data = of_fixed_factor_clk_setup, },
{ .compatible = "leo,gmacclk", .data = of_fixed_factor_clk_setup, },
{ .compatible = "leo,uart_uclk_src", .data = of_fixed_factor_clk_setup, },
{ .compatible = "leo,irda", .data = of_fixed_factor_clk_setup, },

2. of_fixed_factor_clk_setup

/*** drivers/clk/clk-fixed-factor.c*/
/*** of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock*/
void __init of_fixed_factor_clk_setup(struct device_node *node)
{_of_fixed_factor_clk_setup(node);
}
CLK_OF_DECLARE(fixed_factor_clk, "fixed-factor-clock",of_fixed_factor_clk_setup);/*** drivers/clk/clk-fixed-factor.c*/
static struct clk *_of_fixed_factor_clk_setup(struct device_node *node)
{struct clk *clk;const char *clk_name = node->name;const char *parent_name;unsigned long flags = 0;u32 div, mult;int ret;if (of_property_read_u32(node, "clock-div", &div)) {pr_err("%s Fixed factor clock <%s> must have a clock-div property\n",__func__, node->name);return ERR_PTR(-EIO);}if (of_property_read_u32(node, "clock-mult", &mult)) {pr_err("%s Fixed factor clock <%s> must have a clock-mult property\n",__func__, node->name);return ERR_PTR(-EIO);}of_property_read_string(node, "clock-output-names", &clk_name);parent_name = of_clk_get_parent_name(node, 0);if (of_match_node(set_rate_parent_matches, node))flags |= CLK_SET_RATE_PARENT;clk = clk_register_fixed_factor(NULL, clk_name, parent_name, flags,mult, div);if (IS_ERR(clk)) {/** If parent clock is not registered, registration would fail.* Clear OF_POPULATED flag so that clock registration can be* attempted again from probe function.*/of_node_clear_flag(node, OF_POPULATED);return clk;}ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);if (ret) {clk_unregister(clk);return ERR_PTR(ret);}return clk;
}