From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shawn Guo Subject: Re: [PATCH 1/3] arm/dt: add basic mx51 device tree support Date: Mon, 28 Feb 2011 14:48:49 +0800 Message-ID: References: <1298016730-22761-1-git-send-email-r64343@freescale.com> <1298016730-22761-2-git-send-email-r64343@freescale.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1298016730-22761-2-git-send-email-r64343-KZfg59tc24xl57MIdRCFDg@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linaro-dev-bounces-cunTk1MwBs8s++Sfvej+rw@public.gmane.org Errors-To: linaro-dev-bounces-cunTk1MwBs8s++Sfvej+rw@public.gmane.org To: Jason Liu Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org, linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org, patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org List-Id: devicetree@vger.kernel.org On 18 February 2011 16:12, Jason Liu wrote: > Signed-off-by: Jason Liu > --- > =A0arch/arm/mach-mx5/Kconfig =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A06 +++ > =A0arch/arm/mach-mx5/Makefile =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A01 + > =A0arch/arm/mach-mx5/board-dt.c =A0 =A0 =A0 =A0 =A0 =A0| =A0 64 +++++++++= ++++++++++++++++++++++ > =A0arch/arm/mach-mx5/clock-mx51-mx53.c =A0 =A0 | =A0 45 +++++++++++++++++= ++++- > =A0arch/arm/plat-mxc/include/mach/common.h | =A0 =A01 + > =A05 files changed, 116 insertions(+), 1 deletions(-) > [...] > diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/cloc= k-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 @@ > =A0#include > =A0#include > =A0#include > - > +#include > =A0#include > > =A0#include > =A0#include > =A0#include > > +#ifdef CONFIG_OF > +#include > +#include > +#include > +#endif /* CONFIG_OF */ > + > =A0#include "crm_regs.h" > > =A0/* External clock values passed-in by the board code */ > @@ -1432,3 +1438,40 @@ int __init mx53_clocks_init(unsigned long ckil, un= signed long osc, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0MX53_INT_GPT); > =A0 =A0 =A0 =A0return 0; > =A0} > + > +#ifdef CONFIG_OF > +static struct clk* mx5_dt_clk_get(struct device_node *np, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 const char *output_id, void *data) > +{ > + =A0 =A0 =A0 return data; > +} > + > +static __init void mx5_dt_scan_clks(void) > +{ > + =A0 =A0 =A0 struct device_node *node; > + =A0 =A0 =A0 struct clk *clk; > + =A0 =A0 =A0 const char *id; > + =A0 =A0 =A0 int rc; > + > + =A0 =A0 =A0 for_each_compatible_node(node, NULL, "clock") { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 id =3D of_get_property(node, "clock-outputs= ", NULL); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!id) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 clk =3D clk_get_sys(id, NULL); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (IS_ERR(clk)) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 rc =3D of_clk_add_provider(node, mx5_dt_clk= _get, clk); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (rc) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 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. > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_err("error adding fixed = clk %s\n", node->name); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 } > +} > + > +void __init mx5_clk_dt_init(void) > +{ > + =A0 =A0 =A0 mx5_dt_scan_clks(); > +} > +#endif -- = Regards, Shawn