Hi, Shawn, On Mon, Feb 28, 2011 at 2:48 PM, Shawn Guo <shawn....@linaro.org> wrote: > On 18 February 2011 16:12, Jason Liu <r64...@freescale.com> wrote: >> Signed-off-by: Jason Liu <r64...@freescale.com> >> --- >> arch/arm/mach-mx5/Kconfig | 6 +++ >> arch/arm/mach-mx5/Makefile | 1 + >> arch/arm/mach-mx5/board-dt.c | 64 >> +++++++++++++++++++++++++++++++ >> arch/arm/mach-mx5/clock-mx51-mx53.c | 45 +++++++++++++++++++++- >> arch/arm/plat-mxc/include/mach/common.h | 1 + >> 5 files changed, 116 insertions(+), 1 deletions(-) >> > [...] >> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c >> b/arch/arm/mach-mx5/clock-mx51-mx53.c >> index 0a19e75..b8a608e 100644 >> --- a/arch/arm/mach-mx5/clock-mx51-mx53.c >> +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c >> @@ -15,13 +15,19 @@ >> #include <linux/clk.h> >> #include <linux/io.h> >> #include <linux/clkdev.h> >> - >> +#include <linux/err.h> >> #include <asm/div64.h> >> >> #include <mach/hardware.h> >> #include <mach/common.h> >> #include <mach/clock.h> >> >> +#ifdef CONFIG_OF >> +#include <linux/of.h> >> +#include <linux/of_address.h> >> +#include <linux/of_clk.h> >> +#endif /* CONFIG_OF */ >> + >> #include "crm_regs.h" >> >> /* External clock values passed-in by the board code */ >> @@ -1432,3 +1438,40 @@ int __init mx53_clocks_init(unsigned long ckil, >> unsigned long osc, >> MX53_INT_GPT); >> return 0; >> } >> + >> +#ifdef CONFIG_OF >> +static struct clk* mx5_dt_clk_get(struct device_node *np, >> + const char *output_id, void *data) >> +{ >> + return data; >> +} >> + >> +static __init void mx5_dt_scan_clks(void) >> +{ >> + struct device_node *node; >> + struct clk *clk; >> + const char *id; >> + int rc; >> + >> + for_each_compatible_node(node, NULL, "clock") { >> + id = of_get_property(node, "clock-outputs", NULL); >> + if (!id) >> + continue; >> + >> + clk = clk_get_sys(id, NULL); >> + if (IS_ERR(clk)) >> + continue; >> + >> + rc = of_clk_add_provider(node, mx5_dt_clk_get, clk); >> + if (rc) { >> + kfree(clk); > > In this particular implementation, kfree here may not be needed, as > all the "clk" are currently created in the static way. And I'm trying > to change it to the dynamic way by scanning clock node from dt, > creating and registering the "clk" correspondingly.
Yes, I will look into your dynamic way, but before the you real patch come up, I will use the static one to do it currently. > >> + pr_err("error adding fixed clk %s\n", node->name); >> + } >> + } >> +} >> + >> +void __init mx5_clk_dt_init(void) >> +{ >> + mx5_dt_scan_clks(); >> +} >> +#endif > > -- > Regards, > Shawn > > _______________________________________________ > linaro-dev mailing list > linaro-dev@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/linaro-dev > _______________________________________________ linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev