diff mbox

[V4,1/5] arm/dt: add basic mx51 device tree support

Message ID 1299733185-2172-2-git-send-email-jason.hui@linaro.org
State New
Headers show

Commit Message

Jason Hui March 10, 2011, 4:59 a.m. UTC
Signed-off-by: Jason Liu <jason.hui@linaro.org>
Signed-off-by: Jason Liu <r64343@freescale.com>
---
 arch/arm/mach-mx5/Kconfig               |    8 ++++
 arch/arm/mach-mx5/Makefile              |    1 +
 arch/arm/mach-mx5/board-dt.c            |   65 +++++++++++++++++++++++++++++++
 arch/arm/mach-mx5/clock-mx51-mx53.c     |   43 ++++++++++++++++++++-
 arch/arm/plat-mxc/include/mach/common.h |    1 +
 5 files changed, 117 insertions(+), 1 deletions(-)

Comments

Grant Likely March 15, 2011, 7:03 a.m. UTC | #1
Hi Jason,

Minor comments below.

On Thu, Mar 10, 2011 at 12:59:41PM +0800, Jason Liu wrote:
> Signed-off-by: Jason Liu <jason.hui@linaro.org>
> Signed-off-by: Jason Liu <r64343@freescale.com>

This looks wrong.  You should only have one s-o-b line.  Use one email
addr or the other.  Not both.

> ---
>  arch/arm/mach-mx5/Kconfig               |    8 ++++
>  arch/arm/mach-mx5/Makefile              |    1 +
>  arch/arm/mach-mx5/board-dt.c            |   65 +++++++++++++++++++++++++++++++
>  arch/arm/mach-mx5/clock-mx51-mx53.c     |   43 ++++++++++++++++++++-
>  arch/arm/plat-mxc/include/mach/common.h |    1 +
>  5 files changed, 117 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig
> index de4fa99..6438f87 100644
> --- a/arch/arm/mach-mx5/Kconfig
> +++ b/arch/arm/mach-mx5/Kconfig
> @@ -47,6 +47,14 @@ config MACH_MX51_BABBAGE
>  	  u-boot. This includes specific configurations for the board and its
>  	  peripherals.
>  
> +config MACH_MX51_DT
> +	bool "Generic MX51 board (FDT support)"
> +	select USE_OF
> +	select SOC_IMX51
> +	help
> +	 Support for generic Freescale i.MX51 boards using Flattened Device
> +	 Tree.
> +
>  config MACH_MX51_3DS
>  	bool "Support MX51PDK (3DS)"
>  	select SOC_IMX51
> diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile
> index 0d43be9..540697e 100644
> --- a/arch/arm/mach-mx5/Makefile
> +++ b/arch/arm/mach-mx5/Makefile
> @@ -18,3 +18,4 @@ obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o
>  obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o
>  obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o
>  obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.o
> +obj-$(CONFIG_MACH_MX51_DT) += board-dt.o
> diff --git a/arch/arm/mach-mx5/board-dt.c b/arch/arm/mach-mx5/board-dt.c
> new file mode 100644
> index 0000000..19c60a4
> --- /dev/null
> +++ b/arch/arm/mach-mx5/board-dt.c
> @@ -0,0 +1,65 @@
> +/*
> + * Copyright 2011 Linaro Ltd.
> + * Copyright 2011 Freescale Semiconductor, Inc.
> + *
> + * The code contained herein is licensed under the GNU General Public
> + * License. You may obtain a copy of the GNU General Public License
> + * Version 2 or later at the following locations:
> + *
> + * http://www.opensource.org/licenses/gpl-license.html
> + * http://www.gnu.org/copyleft/gpl.html
> + */
> +
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/platform_device.h>
> +#include <linux/dma-mapping.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_fdt.h>
> +
> +#include <mach/common.h>
> +#include <mach/hardware.h>
> +#include <mach/imx-uart.h>
> +#include <mach/iomux-mx51.h>
> +
> +#include <asm/irq.h>
> +#include <asm/setup.h>
> +#include <asm/mach-types.h>
> +#include <asm/mach/arch.h>
> +#include <asm/mach/time.h>
> +
> +#include "devices.h"
> +
> +static struct of_device_id mx51_dt_match_table[] __initdata = {
> +	{ .compatible = "simple-bus", },
> +	{}
> +};
> +
> +static void __init mx51_dt_board_init(void)
> +{
> +	of_platform_bus_probe(NULL, mx51_dt_match_table, NULL);
> +}
> +
> +static void __init mx51_dt_timer_init(void)
> +{
> +	mx51_clocks_init(32768, 24000000, 22579200, 0);
> +	mx5_clk_dt_init();
> +}
> +
> +static struct sys_timer mxc_timer = {
> +	.init = mx51_dt_timer_init,
> +};
> +
> +static const char *mx51_dt_board_compat[] = {
> +	"fsl,mx51-babbage",
> +	NULL
> +};
> +
> +DT_MACHINE_START(MX51_DT, "Freescale MX51 (Flattened Device Tree)")
> +	.boot_params  = PHYS_OFFSET + 0x100,

You should be able to drop the .boot_params line.

> +	.map_io       = mx51_map_io,
> +	.init_irq     = mx51_init_irq,
> +	.init_machine = mx51_dt_board_init,
> +	.dt_compat    = mx51_dt_board_compat,
> +	.timer        = &mxc_timer,
> +MACHINE_END
> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
> index 0a19e75..dedb7f9 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 */

You can drop the #ifdef CONFIG_OF here.  linux/of*.h is safe to
include when CONFIG_OF is not selected.

> +
>  #include "crm_regs.h"
>  
>  /* External clock values passed-in by the board code */
> @@ -1432,3 +1438,38 @@ 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)
> +			pr_err("error adding fixed clk %s\n", node->name);
> +	}
> +}
> +
> +void __init mx5_clk_dt_init(void)
> +{
> +	mx5_dt_scan_clks();
> +}
> +#endif

Nitpick: Would it make sense for these 3 functions to be in a separate .c file?

> diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h
> index aea2cd3..a28e84a 100644
> --- a/arch/arm/plat-mxc/include/mach/common.h
> +++ b/arch/arm/plat-mxc/include/mach/common.h
> @@ -58,4 +58,5 @@ extern void mxc91231_arch_reset(int, const char *);
>  extern void mxc91231_prepare_idle(void);
>  extern void mx51_efikamx_reset(void);
>  extern int mx53_revision(void);
> +extern void mx5_clk_dt_init(void);
>  #endif
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> linaro-dev mailing list
> linaro-dev@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-dev
Jason Hui March 16, 2011, 3:34 a.m. UTC | #2
Hi, Grant,

On Tue, Mar 15, 2011 at 3:03 PM, Grant Likely <grant.likely@secretlab.ca> wrote:
> Hi Jason,
>
> Minor comments below.
>
> On Thu, Mar 10, 2011 at 12:59:41PM +0800, Jason Liu wrote:
>> Signed-off-by: Jason Liu <jason.hui@linaro.org>
>> Signed-off-by: Jason Liu <r64343@freescale.com>
>
> This looks wrong.  You should only have one s-o-b line.  Use one email
> addr or the other.  Not both.

I just take the same approach as this link: https://lkml.org/lkml/2010/12/17/363
If you think it's not applicable, I can change it.

>
>> ---
>>  arch/arm/mach-mx5/Kconfig               |    8 ++++
>>  arch/arm/mach-mx5/Makefile              |    1 +
>>  arch/arm/mach-mx5/board-dt.c            |   65 +++++++++++++++++++++++++++++++
>>  arch/arm/mach-mx5/clock-mx51-mx53.c     |   43 ++++++++++++++++++++-
>>  arch/arm/plat-mxc/include/mach/common.h |    1 +
>>  5 files changed, 117 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig
>> index de4fa99..6438f87 100644
>> --- a/arch/arm/mach-mx5/Kconfig
>> +++ b/arch/arm/mach-mx5/Kconfig
>> @@ -47,6 +47,14 @@ config MACH_MX51_BABBAGE
>>         u-boot. This includes specific configurations for the board and its
>>         peripherals.
>>
>> +config MACH_MX51_DT
>> +     bool "Generic MX51 board (FDT support)"
>> +     select USE_OF
>> +     select SOC_IMX51
>> +     help
>> +      Support for generic Freescale i.MX51 boards using Flattened Device
>> +      Tree.
>> +
>>  config MACH_MX51_3DS
>>       bool "Support MX51PDK (3DS)"
>>       select SOC_IMX51
>> diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile
>> index 0d43be9..540697e 100644
>> --- a/arch/arm/mach-mx5/Makefile
>> +++ b/arch/arm/mach-mx5/Makefile
>> @@ -18,3 +18,4 @@ obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o
>>  obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o
>>  obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o
>>  obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.o
>> +obj-$(CONFIG_MACH_MX51_DT) += board-dt.o
>> diff --git a/arch/arm/mach-mx5/board-dt.c b/arch/arm/mach-mx5/board-dt.c
>> new file mode 100644
>> index 0000000..19c60a4
>> --- /dev/null
>> +++ b/arch/arm/mach-mx5/board-dt.c
>> @@ -0,0 +1,65 @@
>> +/*
>> + * Copyright 2011 Linaro Ltd.
>> + * Copyright 2011 Freescale Semiconductor, Inc.
>> + *
>> + * The code contained herein is licensed under the GNU General Public
>> + * License. You may obtain a copy of the GNU General Public License
>> + * Version 2 or later at the following locations:
>> + *
>> + * http://www.opensource.org/licenses/gpl-license.html
>> + * http://www.gnu.org/copyleft/gpl.html
>> + */
>> +
>> +#include <linux/err.h>
>> +#include <linux/init.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/dma-mapping.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/of_fdt.h>
>> +
>> +#include <mach/common.h>
>> +#include <mach/hardware.h>
>> +#include <mach/imx-uart.h>
>> +#include <mach/iomux-mx51.h>
>> +
>> +#include <asm/irq.h>
>> +#include <asm/setup.h>
>> +#include <asm/mach-types.h>
>> +#include <asm/mach/arch.h>
>> +#include <asm/mach/time.h>
>> +
>> +#include "devices.h"
>> +
>> +static struct of_device_id mx51_dt_match_table[] __initdata = {
>> +     { .compatible = "simple-bus", },
>> +     {}
>> +};
>> +
>> +static void __init mx51_dt_board_init(void)
>> +{
>> +     of_platform_bus_probe(NULL, mx51_dt_match_table, NULL);
>> +}
>> +
>> +static void __init mx51_dt_timer_init(void)
>> +{
>> +     mx51_clocks_init(32768, 24000000, 22579200, 0);
>> +     mx5_clk_dt_init();
>> +}
>> +
>> +static struct sys_timer mxc_timer = {
>> +     .init = mx51_dt_timer_init,
>> +};
>> +
>> +static const char *mx51_dt_board_compat[] = {
>> +     "fsl,mx51-babbage",
>> +     NULL
>> +};
>> +
>> +DT_MACHINE_START(MX51_DT, "Freescale MX51 (Flattened Device Tree)")
>> +     .boot_params  = PHYS_OFFSET + 0x100,
>
> You should be able to drop the .boot_params line.

OK,

>
>> +     .map_io       = mx51_map_io,
>> +     .init_irq     = mx51_init_irq,
>> +     .init_machine = mx51_dt_board_init,
>> +     .dt_compat    = mx51_dt_board_compat,
>> +     .timer        = &mxc_timer,
>> +MACHINE_END
>> diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
>> index 0a19e75..dedb7f9 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 */
>
> You can drop the #ifdef CONFIG_OF here.  linux/of*.h is safe to
> include when CONFIG_OF is not selected.

OK,

>
>> +
>>  #include "crm_regs.h"
>>
>>  /* External clock values passed-in by the board code */
>> @@ -1432,3 +1438,38 @@ 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)
>> +                     pr_err("error adding fixed clk %s\n", node->name);
>> +     }
>> +}
>> +
>> +void __init mx5_clk_dt_init(void)
>> +{
>> +     mx5_dt_scan_clks();
>> +}
>> +#endif
>
> Nitpick: Would it make sense for these 3 functions to be in a separate .c file?

I will do it. please check the new patch.

>
>> diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h
>> index aea2cd3..a28e84a 100644
>> --- a/arch/arm/plat-mxc/include/mach/common.h
>> +++ b/arch/arm/plat-mxc/include/mach/common.h
>> @@ -58,4 +58,5 @@ extern void mxc91231_arch_reset(int, const char *);
>>  extern void mxc91231_prepare_idle(void);
>>  extern void mx51_efikamx_reset(void);
>>  extern int mx53_revision(void);
>> +extern void mx5_clk_dt_init(void);
>>  #endif
>> --
>> 1.7.1
>>
>>
>> _______________________________________________
>> linaro-dev mailing list
>> linaro-dev@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/linaro-dev
>
Grant Likely March 16, 2011, 5:03 a.m. UTC | #3
On Tue, Mar 15, 2011 at 9:34 PM, Jason Hui <jason.hui@linaro.org> wrote:
> Hi, Grant,
>
> On Tue, Mar 15, 2011 at 3:03 PM, Grant Likely <grant.likely@secretlab.ca> wrote:
>> Hi Jason,
>>
>> Minor comments below.
>>
>> On Thu, Mar 10, 2011 at 12:59:41PM +0800, Jason Liu wrote:
>>> Signed-off-by: Jason Liu <jason.hui@linaro.org>
>>> Signed-off-by: Jason Liu <r64343@freescale.com>
>>
>> This looks wrong.  You should only have one s-o-b line.  Use one email
>> addr or the other.  Not both.
>
> I just take the same approach as this link: https://lkml.org/lkml/2010/12/17/363
> If you think it's not applicable, I can change it.

Yeah, I don't think that's right.  A s-o-b is a personal assertion
that the patch is to the best of your knowledge that you have the
right to submit it for inclusion in the kernel (see section 12 of
Documentation/SubmittingPatches).  It doesn't make any statements
about who owns the copyright on the patch or other issues of corporate
ownership.  Companies may have policies about which email address
employees use when signing off, but that isn't what the s-o-b protocol
is for.

Since there isn't more than one of you, you should only have one s-o-b
line.  :-)

Paul, since your email was presented as evidence, would you care to
offer a counter-argument?  :-)

g.
Paul E. McKenney March 16, 2011, 8:45 a.m. UTC | #4
On Tue, Mar 15, 2011 aFt 11:03:55PM -0600, Grant Likely wrote:
> On Tue, Mar 15, 2011 at 9:34 PM, Jason Hui <jason.hui@linaro.org> wrote:
> > Hi, Grant,
> >
> > On Tue, Mar 15, 2011 at 3:03 PM, Grant Likely <grant.likely@secretlab.ca> wrote:
> >> Hi Jason,
> >>
> >> Minor comments below.
> >>
> >> On Thu, Mar 10, 2011 at 12:59:41PM +0800, Jason Liu wrote:
> >>> Signed-off-by: Jason Liu <jason.hui@linaro.org>
> >>> Signed-off-by: Jason Liu <r64343@freescale.com>
> >>
> >> This looks wrong.  You should only have one s-o-b line.  Use one email
> >> addr or the other.  Not both.
> >
> > I just take the same approach as this link: https://lkml.org/lkml/2010/12/17/363
> > If you think it's not applicable, I can change it.
> 
> Yeah, I don't think that's right.  A s-o-b is a personal assertion
> that the patch is to the best of your knowledge that you have the
> right to submit it for inclusion in the kernel (see section 12 of
> Documentation/SubmittingPatches).  It doesn't make any statements
> about who owns the copyright on the patch or other issues of corporate
> ownership.  Companies may have policies about which email address
> employees use when signing off, but that isn't what the s-o-b protocol
> is for.
> 
> Since there isn't more than one of you, you should only have one s-o-b
> line.  :-)
> 
> Paul, since your email was presented as evidence, would you care to
> offer a counter-argument?  :-)

How about https://lkml.org/lkml/2011/2/22/668?  ;-)

There is only one of me, but I am acting in two roles.

							Thanx, Paul
Shawn Guo March 17, 2011, 1:54 a.m. UTC | #5
On Tue, Mar 15, 2011 at 01:03:42AM -0600, Grant Likely wrote:
> Hi Jason,
> 
> Minor comments below.
> 
> On Thu, Mar 10, 2011 at 12:59:41PM +0800, Jason Liu wrote:
> > Signed-off-by: Jason Liu <jason.hui@linaro.org>
> > Signed-off-by: Jason Liu <r64343@freescale.com>
> 
> This looks wrong.  You should only have one s-o-b line.  Use one email
> addr or the other.  Not both.
> 
> > ---
> >  arch/arm/mach-mx5/Kconfig               |    8 ++++
> >  arch/arm/mach-mx5/Makefile              |    1 +
> >  arch/arm/mach-mx5/board-dt.c            |   65 +++++++++++++++++++++++++++++++
> >  arch/arm/mach-mx5/clock-mx51-mx53.c     |   43 ++++++++++++++++++++-
> >  arch/arm/plat-mxc/include/mach/common.h |    1 +
> >  5 files changed, 117 insertions(+), 1 deletions(-)
> > 
> > diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig
> > index de4fa99..6438f87 100644
> > --- a/arch/arm/mach-mx5/Kconfig
> > +++ b/arch/arm/mach-mx5/Kconfig
> > @@ -47,6 +47,14 @@ config MACH_MX51_BABBAGE
> >  	  u-boot. This includes specific configurations for the board and its
> >  	  peripherals.
> >  
> > +config MACH_MX51_DT
> > +	bool "Generic MX51 board (FDT support)"
> > +	select USE_OF
> > +	select SOC_IMX51
> > +	help
> > +	 Support for generic Freescale i.MX51 boards using Flattened Device
> > +	 Tree.
> > +
> >  config MACH_MX51_3DS
> >  	bool "Support MX51PDK (3DS)"
> >  	select SOC_IMX51
> > diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile
> > index 0d43be9..540697e 100644
> > --- a/arch/arm/mach-mx5/Makefile
> > +++ b/arch/arm/mach-mx5/Makefile
> > @@ -18,3 +18,4 @@ obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o
> >  obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o
> >  obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o
> >  obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.o
> > +obj-$(CONFIG_MACH_MX51_DT) += board-dt.o
> > diff --git a/arch/arm/mach-mx5/board-dt.c b/arch/arm/mach-mx5/board-dt.c
> > new file mode 100644
> > index 0000000..19c60a4
> > --- /dev/null
> > +++ b/arch/arm/mach-mx5/board-dt.c
> > @@ -0,0 +1,65 @@
> > +/*
> > + * Copyright 2011 Linaro Ltd.
> > + * Copyright 2011 Freescale Semiconductor, Inc.
> > + *
> > + * The code contained herein is licensed under the GNU General Public
> > + * License. You may obtain a copy of the GNU General Public License
> > + * Version 2 or later at the following locations:
> > + *
> > + * http://www.opensource.org/licenses/gpl-license.html
> > + * http://www.gnu.org/copyleft/gpl.html
> > + */
> > +
> > +#include <linux/err.h>
> > +#include <linux/init.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/dma-mapping.h>
> > +#include <linux/of_platform.h>
> > +#include <linux/of_fdt.h>
> > +
> > +#include <mach/common.h>
> > +#include <mach/hardware.h>
> > +#include <mach/imx-uart.h>
> > +#include <mach/iomux-mx51.h>
> > +
> > +#include <asm/irq.h>
> > +#include <asm/setup.h>
> > +#include <asm/mach-types.h>
> > +#include <asm/mach/arch.h>
> > +#include <asm/mach/time.h>
> > +
> > +#include "devices.h"
> > +
> > +static struct of_device_id mx51_dt_match_table[] __initdata = {
> > +	{ .compatible = "simple-bus", },
> > +	{}
> > +};
> > +
> > +static void __init mx51_dt_board_init(void)
> > +{
> > +	of_platform_bus_probe(NULL, mx51_dt_match_table, NULL);
> > +}
> > +
> > +static void __init mx51_dt_timer_init(void)
> > +{
> > +	mx51_clocks_init(32768, 24000000, 22579200, 0);
> > +	mx5_clk_dt_init();
> > +}
> > +
> > +static struct sys_timer mxc_timer = {
> > +	.init = mx51_dt_timer_init,
> > +};
> > +
> > +static const char *mx51_dt_board_compat[] = {
> > +	"fsl,mx51-babbage",
> > +	NULL
> > +};
> > +
> > +DT_MACHINE_START(MX51_DT, "Freescale MX51 (Flattened Device Tree)")
> > +	.boot_params  = PHYS_OFFSET + 0x100,
> 
> You should be able to drop the .boot_params line.
> 
> > +	.map_io       = mx51_map_io,
> > +	.init_irq     = mx51_init_irq,
> > +	.init_machine = mx51_dt_board_init,
> > +	.dt_compat    = mx51_dt_board_compat,
> > +	.timer        = &mxc_timer,
> > +MACHINE_END
> > diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
> > index 0a19e75..dedb7f9 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 */
> 
> You can drop the #ifdef CONFIG_OF here.  linux/of*.h is safe to
> include when CONFIG_OF is not selected.
> 
> > +
> >  #include "crm_regs.h"
> >  
> >  /* External clock values passed-in by the board code */
> > @@ -1432,3 +1438,38 @@ 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)
> > +			pr_err("error adding fixed clk %s\n", node->name);
> > +	}
> > +}
> > +
> > +void __init mx5_clk_dt_init(void)
> > +{
> > +	mx5_dt_scan_clks();
> > +}
> > +#endif
> 
> Nitpick: Would it make sense for these 3 functions to be in a separate .c file?
> 
Sorry for that I'm late on this.  It will not make much sense to do
so if considering that dynamic dt clock codes have to be put in
clock-mx51-mx53.c anyway, since they are referring to existing
enable/disable/get_rate/set_rate/... functions.
Grant Likely March 17, 2011, 5:17 p.m. UTC | #6
On Thu, Mar 17, 2011 at 09:54:35AM +0800, Shawn Guo wrote:
> On Tue, Mar 15, 2011 at 01:03:42AM -0600, Grant Likely wrote:
> > > +#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)
> > > +			pr_err("error adding fixed clk %s\n", node->name);
> > > +	}
> > > +}
> > > +
> > > +void __init mx5_clk_dt_init(void)
> > > +{
> > > +	mx5_dt_scan_clks();
> > > +}
> > > +#endif
> > 
> > Nitpick: Would it make sense for these 3 functions to be in a separate .c file?
> > 
> Sorry for that I'm late on this.  It will not make much sense to do
> so if considering that dynamic dt clock codes have to be put in
> clock-mx51-mx53.c anyway, since they are referring to existing
> enable/disable/get_rate/set_rate/... functions.

Okay.

g.
diff mbox

Patch

diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig
index de4fa99..6438f87 100644
--- a/arch/arm/mach-mx5/Kconfig
+++ b/arch/arm/mach-mx5/Kconfig
@@ -47,6 +47,14 @@  config MACH_MX51_BABBAGE
 	  u-boot. This includes specific configurations for the board and its
 	  peripherals.
 
+config MACH_MX51_DT
+	bool "Generic MX51 board (FDT support)"
+	select USE_OF
+	select SOC_IMX51
+	help
+	 Support for generic Freescale i.MX51 boards using Flattened Device
+	 Tree.
+
 config MACH_MX51_3DS
 	bool "Support MX51PDK (3DS)"
 	select SOC_IMX51
diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile
index 0d43be9..540697e 100644
--- a/arch/arm/mach-mx5/Makefile
+++ b/arch/arm/mach-mx5/Makefile
@@ -18,3 +18,4 @@  obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o
 obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o
 obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o
 obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.o
+obj-$(CONFIG_MACH_MX51_DT) += board-dt.o
diff --git a/arch/arm/mach-mx5/board-dt.c b/arch/arm/mach-mx5/board-dt.c
new file mode 100644
index 0000000..19c60a4
--- /dev/null
+++ b/arch/arm/mach-mx5/board-dt.c
@@ -0,0 +1,65 @@ 
+/*
+ * Copyright 2011 Linaro Ltd.
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/of_platform.h>
+#include <linux/of_fdt.h>
+
+#include <mach/common.h>
+#include <mach/hardware.h>
+#include <mach/imx-uart.h>
+#include <mach/iomux-mx51.h>
+
+#include <asm/irq.h>
+#include <asm/setup.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/time.h>
+
+#include "devices.h"
+
+static struct of_device_id mx51_dt_match_table[] __initdata = {
+	{ .compatible = "simple-bus", },
+	{}
+};
+
+static void __init mx51_dt_board_init(void)
+{
+	of_platform_bus_probe(NULL, mx51_dt_match_table, NULL);
+}
+
+static void __init mx51_dt_timer_init(void)
+{
+	mx51_clocks_init(32768, 24000000, 22579200, 0);
+	mx5_clk_dt_init();
+}
+
+static struct sys_timer mxc_timer = {
+	.init = mx51_dt_timer_init,
+};
+
+static const char *mx51_dt_board_compat[] = {
+	"fsl,mx51-babbage",
+	NULL
+};
+
+DT_MACHINE_START(MX51_DT, "Freescale MX51 (Flattened Device Tree)")
+	.boot_params  = PHYS_OFFSET + 0x100,
+	.map_io       = mx51_map_io,
+	.init_irq     = mx51_init_irq,
+	.init_machine = mx51_dt_board_init,
+	.dt_compat    = mx51_dt_board_compat,
+	.timer        = &mxc_timer,
+MACHINE_END
diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
index 0a19e75..dedb7f9 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,38 @@  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)
+			pr_err("error adding fixed clk %s\n", node->name);
+	}
+}
+
+void __init mx5_clk_dt_init(void)
+{
+	mx5_dt_scan_clks();
+}
+#endif
diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h
index aea2cd3..a28e84a 100644
--- a/arch/arm/plat-mxc/include/mach/common.h
+++ b/arch/arm/plat-mxc/include/mach/common.h
@@ -58,4 +58,5 @@  extern void mxc91231_arch_reset(int, const char *);
 extern void mxc91231_prepare_idle(void);
 extern void mx51_efikamx_reset(void);
 extern int mx53_revision(void);
+extern void mx5_clk_dt_init(void);
 #endif