clk: socfpga: use clk_hw_register for a5/c5
Subsystems (2)
Dinh Nguyen
maintainerPATCH 1/3 clk: socfpga: use clk_hw_register for a5/c5
As recommended by Stephen Boyd, convert the cyclone5/arria5 clock driver to use the clk_hw registration method.
--- drivers/clk/socfpga/clk-gate.c | 11 +++++++---- drivers/clk/socfpga/clk-periph.c | 8 ++++---- drivers/clk/socfpga/clk-pll.c | 18 +++++++++++------- 3 files changed, 22 insertions(+), 15 deletions(-)
drivers/clk/socfpga/clk-gate.c +7 -4
@@ -174,13 +174,14 @@ void __init socfpga_gate_init(struct device_node *node)u32 div_reg[3 ];u32 clk_phase[2 ];u32 fixed_div; -struct clk *clk; +struct clk_hw *hw_clk;struct socfpga_gate_clk *socfpga_clk;const char *clk_name = node->name;const char *parent_name[SOCFPGA_MAX_PARENTS ];struct clk_init_data init;struct clk_ops *ops;int rc; +int err; socfpga_clk =kzalloc (sizeof (*socfpga_clk),GFP_KERNEL );if (WARN_ON (!socfpga_clk))
@@ -238,12 +239,14 @@ void __init socfpga_gate_init(struct device_node *node) init.parent_names = parent_name; socfpga_clk->hw.hw.init = &init; - clk =clk_register (NULL , &socfpga_clk->hw.hw); -if (WARN_ON (IS_ERR (clk))) { + hw_clk = &socfpga_clk->hw.hw; + + err =clk_hw_register (NULL , hw_clk); +if (err) {kfree (socfpga_clk);return ; } - rc =of_clk_add_provider (node, of_clk_src_simple_get, clk); + rc =of_clk_add_provider (node, of_clk_src_simple_get, hw_clk);if (WARN_ON (rc))return ; }
drivers/clk/socfpga/clk-periph.c +4 -4
@@ -51,7 +51,7 @@ static __init void __socfpga_periph_init(struct device_node *node, const struct clk_ops *ops) {u32 reg; -struct clk *clk; +struct clk_hw *hw_clk;struct socfpga_periph_clk *periph_clk;const char *clk_name = node->name;const char *parent_name[SOCFPGA_MAX_PARENTS ];
@@ -94,13 +94,13 @@ static __init void __socfpga_periph_init(struct device_node *node, init.parent_names = parent_name; periph_clk->hw.hw.init = &init; + hw_clk = &periph_clk->hw.hw; - clk =clk_register (NULL , &periph_clk->hw.hw); -if (WARN_ON (IS_ERR (clk))) { +if (clk_hw_register (NULL , hw_clk)) {kfree (periph_clk);return ; } - rc =of_clk_add_provider (node, of_clk_src_simple_get, clk); + rc =of_clk_add_provider (node, of_clk_src_simple_get, hw_clk); }void __init socfpga_periph_init (struct device_node *node)
drivers/clk/socfpga/clk-pll.c +11 -7
@@ -70,16 +70,18 @@ static const struct clk_ops clk_pll_ops = { .get_parent = clk_pll_get_parent, }; -static __init struct clk *__socfpga_pll_init (struct device_node *node, +static __init struct clk_hw *__socfpga_pll_init (struct device_node *node,const struct clk_ops *ops) {u32 reg; -struct clk *clk; +struct clk_hw *hw_clk;struct socfpga_pll *pll_clk;const char *clk_name = node->name;const char *parent_name[SOCFPGA_MAX_PARENTS ];struct clk_init_data init;struct device_node *clkmgr_np; +int rc; +int err;of_property_read_u32 (node,"reg" , ®);
@@ -105,13 +107,15 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node, pll_clk->hw.bit_idx =SOCFPGA_PLL_EXT_ENA ; - clk =clk_register (NULL , &pll_clk->hw.hw); -if (WARN_ON (IS_ERR (clk))) { + hw_clk = &pll_clk->hw.hw; + + err =clk_hw_register (NULL , hw_clk); +if (err) {kfree (pll_clk); -return NULL ; +return ERR_PTR (err); } -of_clk_add_provider (node, of_clk_src_simple_get, clk); -return clk; + rc =of_clk_add_provider (node, of_clk_src_simple_get, hw_clk); +return hw_clk; }void __init socfpga_pll_init (struct device_node *node)
Signature · 1 line
2.30.0
Dinh Nguyen
maintainerPATCH 2/3 clk: socfpga: arria10: convert to use clk_hw
As recommended by Stephen Boyd, convert the Arria10 clock driver to use the clk_hw registration method.
--- drivers/clk/socfpga/clk-gate-a10.c | 8 ++++---- drivers/clk/socfpga/clk-periph-a10.c | 11 ++++++----- drivers/clk/socfpga/clk-pll-a10.c | 12 ++++++------ 3 files changed, 16 insertions(+), 15 deletions(-)
drivers/clk/socfpga/clk-gate-a10.c +4 -4
@@ -98,7 +98,7 @@ static void __init __socfpga_gate_init(struct device_node *node,u32 div_reg[3 ];u32 clk_phase[2 ];u32 fixed_div; -struct clk *clk; +struct clk_hw *hw_clk;struct socfpga_gate_clk *socfpga_clk;const char *clk_name = node->name;const char *parent_name[SOCFPGA_MAX_PARENTS ];
@@ -159,13 +159,13 @@ static void __init __socfpga_gate_init(struct device_node *node, init.num_parents =of_clk_parent_fill (node, parent_name,SOCFPGA_MAX_PARENTS ); init.parent_names = parent_name; socfpga_clk->hw.hw.init = &init; + hw_clk = &socfpga_clk->hw.hw; - clk =clk_register (NULL , &socfpga_clk->hw.hw); -if (WARN_ON (IS_ERR (clk))) { +if (clk_hw_register (NULL , hw_clk)) {kfree (socfpga_clk);return ; } - rc =of_clk_add_provider (node, of_clk_src_simple_get, clk); + rc =of_clk_add_provider (node, of_clk_src_simple_get, hw_clk);if (WARN_ON (rc))return ; }
drivers/clk/socfpga/clk-periph-a10.c +6 -5
@@ -61,7 +61,7 @@ static __init void __socfpga_periph_init(struct device_node *node, const struct clk_ops *ops) {u32 reg; -struct clk *clk; +struct clk_hw *hw_clk;struct socfpga_periph_clk *periph_clk;const char *clk_name = node->name;const char *parent_name[SOCFPGA_MAX_PARENTS ];
@@ -104,12 +104,13 @@ static __init void __socfpga_periph_init(struct device_node *node, periph_clk->hw.hw.init = &init; - clk =clk_register (NULL , &periph_clk->hw.hw); -if (WARN_ON (IS_ERR (clk))) { + hw_clk = &periph_clk->hw.hw; + +if (clk_hw_register (NULL , hw_clk)) {kfree (periph_clk);return ; } - rc =of_clk_add_provider (node, of_clk_src_simple_get, clk); + rc =of_clk_add_provider (node, of_clk_src_simple_get, hw_clk);if (rc <0 ) {pr_err ("Could not register clock provider for node:%s\n" , clk_name);
@@ -119,7 +120,7 @@ static __init void __socfpga_periph_init(struct device_node *node,return ; err_clk: -clk_unregister (clk); +clk_hw_unregister (hw_clk); }void __init socfpga_a10_periph_init (struct device_node *node)
drivers/clk/socfpga/clk-pll-a10.c +6 -6
@@ -63,11 +63,11 @@ static const struct clk_ops clk_pll_ops = { .get_parent = clk_pll_get_parent, }; -static struct clk *__init __socfpga_pll_init (struct device_node *node, +static struct clk_hw *__init __socfpga_pll_init (struct device_node *node,const struct clk_ops *ops) {u32 reg; -struct clk *clk; +struct clk_hw *hw_clk;struct socfpga_pll *pll_clk;const char *clk_name = node->name;const char *parent_name[SOCFGPA_MAX_PARENTS ];
@@ -101,14 +101,14 @@ static struct clk * __init __socfpga_pll_init(struct device_node *node, pll_clk->hw.hw.init = &init; pll_clk->hw.bit_idx =SOCFPGA_PLL_EXT_ENA ; + hw_clk = &pll_clk->hw.hw; - clk =clk_register (NULL , &pll_clk->hw.hw); -if (WARN_ON (IS_ERR (clk))) { +if (clk_hw_register (NULL , hw_clk)) {kfree (pll_clk);return NULL ; } -of_clk_add_provider (node, of_clk_src_simple_get, clk); -return clk; +of_clk_add_provider (node, of_clk_src_simple_get, hw_clk); +return hw_clk; }void __init socfpga_a10_pll_init (struct device_node *node)
Signature · 1 line
2.30.0
Re: [PATCH 2/3] clk: socfpga: arria10: convert to use clk_hw
Quoting Dinh Nguyen (2021-03-02 13:41:50)
Quoted 6 lines
As recommended by Stephen Boyd, convert the Arria10 clock driver to use the
clk_hwregistration method.Suggested-by Stephen Boyd <[email protected]>Signed-off-by Dinh Nguyen <[email protected]>---
Applied to clk-next
Dinh Nguyen
maintainerPATCH 3/3 clk: socfpga: Convert to s10/agilex/n5x to use clk_hw
In reply to Dinh NguyenAs recommended by Stephen Boyd, convert the Agilex/Stratix10/n5x clock driver to use the clk_hw registration method.
--- drivers/clk/socfpga/clk-agilex.c | 114 ++++++++++++++------------- drivers/clk/socfpga/clk-gate-s10.c | 15 ++-- drivers/clk/socfpga/clk-periph-s10.c | 42 +++++----- drivers/clk/socfpga/clk-pll-s10.c | 43 +++++----- drivers/clk/socfpga/clk-s10.c | 68 +++++++--------- drivers/clk/socfpga/stratix10-clk.h | 24 +++--- 6 files changed, 159 insertions(+), 147 deletions(-)
drivers/clk/socfpga/clk-agilex.c +60 -54
@@ -303,18 +303,18 @@ static const struct stratix10_gate_clock agilex_gate_clks[] = {static int n5x_clk_register_c_perip (const struct n5x_perip_c_clock *clks,int nums,struct stratix10_clock_data *data) { -struct clk *clk; +struct clk_hw *hw_clk;void __iomem *base = data->base;int i;for (i =0 ; i < nums; i++) { - clk =n5x_register_periph (&clks[i], base); -if (IS_ERR (clk)) { + hw_clk =n5x_register_periph (&clks[i], base); +if (IS_ERR (hw_clk)) {pr_err ("%s: failed to register clock %s\n" , __func__, clks[i].name);continue ; } - data->clk_data.clks[clks[i].id] = clk; + data->clk_data.hws[clks[i].id] = hw_clk; }return 0 ; }
@@ -322,18 +322,18 @@ static int n5x_clk_register_c_perip(const struct n5x_perip_c_clock *clks,static int agilex_clk_register_c_perip (const struct stratix10_perip_c_clock *clks,int nums,struct stratix10_clock_data *data) { -struct clk *clk; +struct clk_hw *hw_clk;void __iomem *base = data->base;int i;for (i =0 ; i < nums; i++) { - clk =s10_register_periph (&clks[i], base); -if (IS_ERR (clk)) { + hw_clk =s10_register_periph (&clks[i], base); +if (IS_ERR (hw_clk)) {pr_err ("%s: failed to register clock %s\n" , __func__, clks[i].name);continue ; } - data->clk_data.clks[clks[i].id] = clk; + data->clk_data.hws[clks[i].id] = hw_clk; }return 0 ; }
@@ -341,18 +341,18 @@ static int agilex_clk_register_c_perip(const struct stratix10_perip_c_clock *clkstatic int agilex_clk_register_cnt_perip (const struct stratix10_perip_cnt_clock *clks,int nums,struct stratix10_clock_data *data) { -struct clk *clk; +struct clk_hw *hw_clk;void __iomem *base = data->base;int i;for (i =0 ; i < nums; i++) { - clk =s10_register_cnt_periph (&clks[i], base); -if (IS_ERR (clk)) { + hw_clk =s10_register_cnt_periph (&clks[i], base); +if (IS_ERR (hw_clk)) {pr_err ("%s: failed to register clock %s\n" , __func__, clks[i].name);continue ; } - data->clk_data.clks[clks[i].id] = clk; + data->clk_data.hws[clks[i].id] = hw_clk; }return 0 ;
@@ -360,18 +360,18 @@ static int agilex_clk_register_cnt_perip(const struct stratix10_perip_cnt_clockstatic int agilex_clk_register_gate (const struct stratix10_gate_clock *clks,int nums,struct stratix10_clock_data *data) { -struct clk *clk; +struct clk_hw *hw_clk;void __iomem *base = data->base;int i;for (i =0 ; i < nums; i++) { - clk =s10_register_gate (&clks[i], base); -if (IS_ERR (clk)) { + hw_clk =s10_register_gate (&clks[i], base); +if (IS_ERR (hw_clk)) {pr_err ("%s: failed to register clock %s\n" , __func__, clks[i].name);continue ; } - data->clk_data.clks[clks[i].id] = clk; + data->clk_data.hws[clks[i].id] = hw_clk; }return 0 ;
@@ -380,18 +380,18 @@ static int agilex_clk_register_gate(const struct stratix10_gate_clock *clks,static int agilex_clk_register_pll (const struct stratix10_pll_clock *clks,int nums,struct stratix10_clock_data *data) { -struct clk *clk; +struct clk_hw *hw_clk;void __iomem *base = data->base;int i;for (i =0 ; i < nums; i++) { - clk =agilex_register_pll (&clks[i], base); -if (IS_ERR (clk)) { + hw_clk =agilex_register_pll (&clks[i], base); +if (IS_ERR (hw_clk)) {pr_err ("%s: failed to register clock %s\n" , __func__, clks[i].name);continue ; } - data->clk_data.clks[clks[i].id] = clk; + data->clk_data.hws[clks[i].id] = hw_clk; }return 0 ;
@@ -400,64 +400,49 @@ static int agilex_clk_register_pll(const struct stratix10_pll_clock *clks,static int n5x_clk_register_pll (const struct stratix10_pll_clock *clks,int nums,struct stratix10_clock_data *data) { -struct clk *clk; +struct clk_hw *hw_clk;void __iomem *base = data->base;int i;for (i =0 ; i < nums; i++) { - clk =n5x_register_pll (&clks[i], base); -if (IS_ERR (clk)) { + hw_clk =n5x_register_pll (&clks[i], base); +if (IS_ERR (hw_clk)) {pr_err ("%s: failed to register clock %s\n" , __func__, clks[i].name);continue ; } - data->clk_data.clks[clks[i].id] = clk; + data->clk_data.hws[clks[i].id] = hw_clk; }return 0 ; } -static struct stratix10_clock_data *__socfpga_agilex_clk_init (struct platform_device *pdev, -int nr_clks) +static int agilex_clkmgr_init (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node;struct device *dev = &pdev->dev;struct stratix10_clock_data *clk_data; -struct clk **clk_table;struct resource *res;void __iomem *base; -int ret; +int i, num_clks; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); base =devm_ioremap_resource (dev, res);if (IS_ERR (base)) -return ERR_CAST (base); - - clk_data =devm_kzalloc (dev,sizeof (*clk_data),GFP_KERNEL ); -if (!clk_data) -return ERR_PTR (-ENOMEM ); +return PTR_ERR (base); - clk_data->base = base; - clk_table =devm_kcalloc (dev, nr_clks,sizeof (*clk_table),GFP_KERNEL ); -if (!clk_table) -return ERR_PTR (-ENOMEM ); - - clk_data->clk_data.clks = clk_table; - clk_data->clk_data.clk_num = nr_clks; - ret =of_clk_add_provider (np, of_clk_src_onecell_get, &clk_data->clk_data); -if (ret) -return ERR_PTR (ret); + num_clks =AGILEX_NUM_CLKS ; -return clk_data; -} + clk_data =devm_kzalloc (dev,struct_size (clk_data, clk_data.hws, + num_clks),GFP_KERNEL ); +if (!clk_data) +return -ENOMEM ; -static int agilex_clkmgr_init (struct platform_device *pdev) -{ -struct stratix10_clock_data *clk_data; +for (i =0 ; i < num_clks; i++) + clk_data->clk_data.hws[i] =ERR_PTR (-ENOENT ); - clk_data =__socfpga_agilex_clk_init (pdev,AGILEX_NUM_CLKS ); -if (IS_ERR (clk_data)) -return PTR_ERR (clk_data); + clk_data->base = base; + clk_data->clk_data.num = num_clks;agilex_clk_register_pll (agilex_pll_clks,ARRAY_SIZE (agilex_pll_clks), clk_data);
@@ -470,16 +455,36 @@ static int agilex_clkmgr_init(struct platform_device *pdev)agilex_clk_register_gate (agilex_gate_clks,ARRAY_SIZE (agilex_gate_clks), clk_data); +of_clk_add_hw_provider (np, of_clk_hw_onecell_get, &clk_data->clk_data);return 0 ; }static int n5x_clkmgr_init (struct platform_device *pdev) { +struct device_node *np = pdev->dev.of_node; +struct device *dev = &pdev->dev;struct stratix10_clock_data *clk_data; +struct resource *res; +void __iomem *base; +int i, num_clks; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + base =devm_ioremap_resource (dev, res); +if (IS_ERR (base)) +return PTR_ERR (base); + + num_clks =AGILEX_NUM_CLKS ; + + clk_data =devm_kzalloc (dev,struct_size (clk_data, clk_data.hws, + num_clks),GFP_KERNEL ); +if (!clk_data) +return -ENOMEM ; + +for (i =0 ; i < num_clks; i++) + clk_data->clk_data.hws[i] =ERR_PTR (-ENOENT ); - clk_data =__socfpga_agilex_clk_init (pdev,AGILEX_NUM_CLKS ); -if (IS_ERR (clk_data)) -return PTR_ERR (clk_data); + clk_data->base = base; + clk_data->clk_data.num = num_clks;n5x_clk_register_pll (agilex_pll_clks,ARRAY_SIZE (agilex_pll_clks), clk_data);
@@ -492,6 +497,7 @@ static int n5x_clkmgr_init(struct platform_device *pdev)agilex_clk_register_gate (agilex_gate_clks,ARRAY_SIZE (agilex_gate_clks), clk_data); +of_clk_add_hw_provider (np, of_clk_hw_onecell_get, &clk_data->clk_data);return 0 ; }
drivers/clk/socfpga/clk-gate-s10.c +9 -6
@@ -65,12 +65,13 @@ static const struct clk_ops dbgclk_ops = { .get_parent = socfpga_gate_get_parent, }; -struct clk *s10_register_gate (const struct stratix10_gate_clock *clks,void __iomem *regbase) +struct clk_hw *s10_register_gate (const struct stratix10_gate_clock *clks,void __iomem *regbase) { -struct clk *clk; +struct clk_hw *hw_clk;struct socfpga_gate_clk *socfpga_clk;struct clk_init_data init;const char *parent_name = clks->parent_name; +int ret; socfpga_clk =kzalloc (sizeof (*socfpga_clk),GFP_KERNEL );if (!socfpga_clk)
@@ -112,10 +113,12 @@ struct clk *s10_register_gate(const struct stratix10_gate_clock *clks, void __io init.parent_data = clks->parent_data; socfpga_clk->hw.hw.init = &init; - clk =clk_register (NULL , &socfpga_clk->hw.hw); -if (WARN_ON (IS_ERR (clk))) { + hw_clk = &socfpga_clk->hw.hw; + + ret =clk_hw_register (NULL , &socfpga_clk->hw.hw); +if (ret) {kfree (socfpga_clk); -return NULL ; +return ERR_PTR (ret); } -return clk; +return hw_clk; }
drivers/clk/socfpga/clk-periph-s10.c +24 -18
95 lines not on this page · raw message
drivers/clk/socfpga/clk-pll-s10.c +25 -18
92 lines not on this page · raw message
drivers/clk/socfpga/clk-s10.c +29 -39
151 lines not on this page · raw message
drivers/clk/socfpga/stratix10-clk.h +12 -12
@@ -7,7 +7,7 @@#define __STRATIX10_CLK_Hstruct stratix10_clock_data { -struct clk_onecell_data clk_data; +struct clk_hw_onecell_data clk_data;void __iomem *base; };
@@ -71,18 +71,18 @@ struct stratix10_gate_clock { u8 fixed_div; }; -struct clk *s10_register_pll (const struct stratix10_pll_clock *, -void __iomem *); -struct clk *agilex_register_pll (const struct stratix10_pll_clock *, -void __iomem *); -struct clk *n5x_register_pll (const struct stratix10_pll_clock *clks, +struct clk_hw *s10_register_pll (const struct stratix10_pll_clock *clks,void __iomem *reg); -struct clk *s10_register_periph (const struct stratix10_perip_c_clock *, +struct clk_hw *agilex_register_pll (const struct stratix10_pll_clock *clks,void __iomem *reg); -struct clk *n5x_register_periph (const struct n5x_perip_c_clock *clks, +struct clk_hw *n5x_register_pll (const struct stratix10_pll_clock *clks, +void __iomem *reg); +struct clk_hw *s10_register_periph (const struct stratix10_perip_c_clock *clks, +void __iomem *reg); +struct clk_hw *n5x_register_periph (const struct n5x_perip_c_clock *clks,void __iomem *reg); -struct clk *s10_register_cnt_periph (const struct stratix10_perip_cnt_clock *, -void __iomem *); -struct clk *s10_register_gate (const struct stratix10_gate_clock *, -void __iomem *); +struct clk_hw *s10_register_cnt_periph (const struct stratix10_perip_cnt_clock *clks, +void __iomem *reg); +struct clk_hw *s10_register_gate (const struct stratix10_gate_clock *clks, +void __iomem *reg);#endif /* __STRATIX10_CLK_H */
Signature · 1 line
2.30.0
Re: [PATCH 3/3] clk: socfpga: Convert to s10/agilex/n5x to use clk_hw
Quoting Dinh Nguyen (2021-03-02 13:41:51)
Quoted 6 lines
As recommended by Stephen Boyd, convert the Agilex/Stratix10/n5x clock driver to use the
clk_hwregistration method.Suggested-by Stephen Boyd <[email protected]>Signed-off-by Dinh Nguyen <[email protected]>---
Applied to clk-next
Quoting Dinh Nguyen (2021-03-02 13:41:49)
Quoted 6 lines
As recommended by Stephen Boyd, convert the cyclone5/arria5 clock driver to use the
clk_hwregistration method.Suggested-by Stephen Boyd <[email protected]>Signed-off-by Dinh Nguyen <[email protected]>---
Applied to clk-next