Patchwork [PATCHv3] ARM: imx: add support code for IMX50 based machines

login
register
mail settings
Submitter Greg Ungerer
Date Nov. 4, 2013, 12:13 a.m.
Message ID <1383524020-1518-1-git-send-email-gerg@uclinux.org>
Download mbox | patch
Permalink /patch/288092/
State New
Headers show

Comments

Greg Ungerer - Nov. 4, 2013, 12:13 a.m.
From: Greg Ungerer <gerg@uclinux.org>

Add machine support code for the Freescale IMX50 SoC.

The IMX50 is quite similar to the Freescale IMX53, and contains many of the
same periperhal hardware modules, at the same address offsets as the IMX53.
(Notable exceptions are that the IMX50 contains no CAN bus hardware, less
GPIO, no VPU, it does contain an Electrophoretic display controller though).

This support code uses some of the IMX53 setup code to reduce duplication
of what would be identical init IO setup.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 arch/arm/mach-imx/Makefile     |  1 +
 arch/arm/mach-imx/common.h     |  1 +
 arch/arm/mach-imx/mach-imx50.c | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+)
 create mode 100644 arch/arm/mach-imx/mach-imx50.c
Rob Herring - Nov. 4, 2013, 3:16 a.m.
On Sun, Nov 3, 2013 at 6:13 PM,  <gerg@uclinux.org> wrote:
> From: Greg Ungerer <gerg@uclinux.org>
>
> Add machine support code for the Freescale IMX50 SoC.
>
> The IMX50 is quite similar to the Freescale IMX53, and contains many of the
> same periperhal hardware modules, at the same address offsets as the IMX53.
> (Notable exceptions are that the IMX50 contains no CAN bus hardware, less
> GPIO, no VPU, it does contain an Electrophoretic display controller though).
>
> This support code uses some of the IMX53 setup code to reduce duplication
> of what would be identical init IO setup.
>
> Signed-off-by: Greg Ungerer <gerg@uclinux.org>
> ---
>  arch/arm/mach-imx/Makefile     |  1 +
>  arch/arm/mach-imx/common.h     |  1 +
>  arch/arm/mach-imx/mach-imx50.c | 36 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 38 insertions(+)
>  create mode 100644 arch/arm/mach-imx/mach-imx50.c
>
> diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> index bbe1f5b..924e117 100644
> --- a/arch/arm/mach-imx/Makefile
> +++ b/arch/arm/mach-imx/Makefile
> @@ -112,6 +112,7 @@ obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += mach-cpuimx51sd.o
>  obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd51-baseboard.o
>
>  obj-$(CONFIG_MACH_IMX51_DT) += imx51-dt.o
> +obj-$(CONFIG_SOC_IMX50) += mach-imx50.o
>  obj-$(CONFIG_SOC_IMX53) += mach-imx53.o
>
>  obj-$(CONFIG_SOC_VF610) += clk-vf610.o mach-vf610.o
> diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
> index 7cbe22d..9b67672 100644
> --- a/arch/arm/mach-imx/common.h
> +++ b/arch/arm/mach-imx/common.h
> @@ -108,6 +108,7 @@ void tzic_handle_irq(struct pt_regs *);
>  #define imx27_handle_irq avic_handle_irq
>  #define imx31_handle_irq avic_handle_irq
>  #define imx35_handle_irq avic_handle_irq
> +#define imx50_handle_irq tzic_handle_irq

Has no one converted AVIC and TZIC to use IRQCHIP_DECLARE? This and
the corresponding handle_irq hook would not be needed if that was
done.

>  #define imx51_handle_irq tzic_handle_irq
>  #define imx53_handle_irq tzic_handle_irq
>
> diff --git a/arch/arm/mach-imx/mach-imx50.c b/arch/arm/mach-imx/mach-imx50.c
> new file mode 100644
> index 0000000..dc93bbb
> --- /dev/null
> +++ b/arch/arm/mach-imx/mach-imx50.c
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright 2013 Greg Ungerer <gerg@uclinux.org>
> + * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
> + * Copyright 2011 Linaro Ltd.
> + *
> + * 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/of_platform.h>
> +#include <asm/mach/arch.h>
> +
> +#include "common.h"
> +
> +static void __init imx50_dt_init(void)
> +{
> +       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);

This is the default operation now if init_machine is NULL.

> +}
> +
> +static const char *imx50_dt_board_compat[] __initdata = {
> +       "fsl,imx50",
> +       NULL
> +};
> +
> +DT_MACHINE_START(IMX50_DT, "Freescale i.MX50 (Device Tree Support)")
> +       .map_io         = mx53_map_io,
> +       .init_irq       = mx53_init_irq,
> +       .handle_irq     = imx50_handle_irq,
> +       .init_machine   = imx50_dt_init,
> +       .dt_compat      = imx50_dt_board_compat,
> +       .restart        = mxc_restart,
> +MACHINE_END

I still think any mx53 clean-up should be done first to enable mx50
rather than adding a mx50 machine first and then trying to consolidate
mx50 and mx53.

Rob
Shawn Guo - Nov. 4, 2013, 1:08 p.m.
On Sun, Nov 03, 2013 at 09:16:52PM -0600, Rob Herring wrote:
> > @@ -108,6 +108,7 @@ void tzic_handle_irq(struct pt_regs *);
> >  #define imx27_handle_irq avic_handle_irq
> >  #define imx31_handle_irq avic_handle_irq
> >  #define imx35_handle_irq avic_handle_irq
> > +#define imx50_handle_irq tzic_handle_irq
> 
> Has no one converted AVIC and TZIC to use IRQCHIP_DECLARE? This and
> the corresponding handle_irq hook would not be needed if that was
> done.

No, not yet.  There are still non-DT users for avic and tzic, which
makes the adoption of IRQCHIP_DECLARE less meaningful and a little
difficult.  So my plan is that we convert all those non-DT users over to
DT, and then move avic and tzic to IRQCHIP_DECLARE.

<snip>

> > +static void __init imx50_dt_init(void)
> > +{
> > +       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> 
> This is the default operation now if init_machine is NULL.

Oh, it reminds me that mxc_arch_reset_init_dt() should be called here to
get mxc_restart() work.

> > +}
> > +
> > +static const char *imx50_dt_board_compat[] __initdata = {
> > +       "fsl,imx50",
> > +       NULL
> > +};
> > +
> > +DT_MACHINE_START(IMX50_DT, "Freescale i.MX50 (Device Tree Support)")
> > +       .map_io         = mx53_map_io,
> > +       .init_irq       = mx53_init_irq,
> > +       .handle_irq     = imx50_handle_irq,
> > +       .init_machine   = imx50_dt_init,
> > +       .dt_compat      = imx50_dt_board_compat,
> > +       .restart        = mxc_restart,
> > +MACHINE_END
> 
> I still think any mx53 clean-up should be done first to enable mx50
> rather than adding a mx50 machine first and then trying to consolidate
> mx50 and mx53.

We already reuse imx53 stuff as much as possible here, and I do not see
there will be so much code to be consolidated further.  There are indeed
something to be cleaned up as part of the whole i.MX DT conversion, like
static mapping, but it's nothing related to imx50 addition.  Since the
imx50 addition does not make the cleanup later more difficult, I would
prefer to just support it now.

Shawn
Jason - Nov. 4, 2013, 2:51 p.m.
Greg,

On Mon, Nov 04, 2013 at 10:13:40AM +1000, gerg@uclinux.org wrote:
> From: Greg Ungerer <gerg@uclinux.org>
> 
> Add machine support code for the Freescale IMX50 SoC.
> 
> The IMX50 is quite similar to the Freescale IMX53, and contains many of the
> same periperhal hardware modules, at the same address offsets as the IMX53.
> (Notable exceptions are that the IMX50 contains no CAN bus hardware, less
> GPIO, no VPU, it does contain an Electrophoretic display controller though).
> 
> This support code uses some of the IMX53 setup code to reduce duplication
> of what would be identical init IO setup.
> 
> Signed-off-by: Greg Ungerer <gerg@uclinux.org>
> ---
>  arch/arm/mach-imx/Makefile     |  1 +
>  arch/arm/mach-imx/common.h     |  1 +
>  arch/arm/mach-imx/mach-imx50.c | 36 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 38 insertions(+)
>  create mode 100644 arch/arm/mach-imx/mach-imx50.c

What happened to the rest of the series?  If this is a new version of
just a single patch in the V2 series (which I suspect it is), we usually
make it an in-reply-to the previous version of the patch it replaces.
Not a big deal, it just helps us keep track of things more easily.

thx,

Jason.
Jason - Nov. 4, 2013, 2:57 p.m.
On Mon, Nov 04, 2013 at 09:51:51AM -0500, Jason Cooper wrote:
> What happened to the rest of the series?

Crap.  Nevermind.  I just saw that Shawn had already taken the other
patches into his tree.  And here I thought I was caught up on
everything...

thx,

Jason.
Shawn Guo - Nov. 5, 2013, 1:24 a.m.
On Mon, Nov 04, 2013 at 10:13:40AM +1000, gerg@uclinux.org wrote:
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright 2013 Greg Ungerer <gerg@uclinux.org>
> + * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
> + * Copyright 2011 Linaro Ltd.
> + *
> + * 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/of_platform.h>
> +#include <asm/mach/arch.h>
> +
> +#include "common.h"
> +
> +static void __init imx50_dt_init(void)
> +{

We need to call mxc_arch_reset_init_dt() here to get mxc_restart() work.
I just fixed it up and applied the patch.

Shawn

> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +}
> +
> +static const char *imx50_dt_board_compat[] __initdata = {
> +	"fsl,imx50",
> +	NULL
> +};
> +
> +DT_MACHINE_START(IMX50_DT, "Freescale i.MX50 (Device Tree Support)")
> +	.map_io		= mx53_map_io,
> +	.init_irq	= mx53_init_irq,
> +	.handle_irq	= imx50_handle_irq,
> +	.init_machine	= imx50_dt_init,
> +	.dt_compat	= imx50_dt_board_compat,
> +	.restart	= mxc_restart,
> +MACHINE_END
> -- 
> 1.8.1.4
>
Greg Ungerer - Nov. 5, 2013, 2:56 a.m.
On 05/11/13 11:24, Shawn Guo wrote:
> On Mon, Nov 04, 2013 at 10:13:40AM +1000, gerg@uclinux.org wrote:
>> @@ -0,0 +1,36 @@
>> +/*
>> + * Copyright 2013 Greg Ungerer <gerg@uclinux.org>
>> + * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
>> + * Copyright 2011 Linaro Ltd.
>> + *
>> + * 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/of_platform.h>
>> +#include <asm/mach/arch.h>
>> +
>> +#include "common.h"
>> +
>> +static void __init imx50_dt_init(void)
>> +{
> 
> We need to call mxc_arch_reset_init_dt() here to get mxc_restart() work.
> I just fixed it up and applied the patch.

Great, thanks Shawn.

Regards
Greg



>> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>> +}
>> +
>> +static const char *imx50_dt_board_compat[] __initdata = {
>> +	"fsl,imx50",
>> +	NULL
>> +};
>> +
>> +DT_MACHINE_START(IMX50_DT, "Freescale i.MX50 (Device Tree Support)")
>> +	.map_io		= mx53_map_io,
>> +	.init_irq	= mx53_init_irq,
>> +	.handle_irq	= imx50_handle_irq,
>> +	.init_machine	= imx50_dt_init,
>> +	.dt_compat	= imx50_dt_board_compat,
>> +	.restart	= mxc_restart,
>> +MACHINE_END
>> -- 
>> 1.8.1.4
>>
> 
>
Greg Ungerer - Nov. 5, 2013, 3:02 a.m.
Hi Jason,

On 05/11/13 00:57, Jason Cooper wrote:
> On Mon, Nov 04, 2013 at 09:51:51AM -0500, Jason Cooper wrote:
>> What happened to the rest of the series?
> 
> Crap.  Nevermind.  I just saw that Shawn had already taken the other
> patches into his tree.  And here I thought I was caught up on
> everything...

:-)

Are you going to try and test out the imx50 support from Shawn's branch?

Regards
Greg
Shawn Guo - Nov. 5, 2013, 3:13 a.m.
On Tue, Nov 05, 2013 at 01:02:06PM +1000, Greg Ungerer wrote:
> Hi Jason,
> 
> On 05/11/13 00:57, Jason Cooper wrote:
> > On Mon, Nov 04, 2013 at 09:51:51AM -0500, Jason Cooper wrote:
> >> What happened to the rest of the series?
> > 
> > Crap.  Nevermind.  I just saw that Shawn had already taken the other
> > patches into his tree.  And here I thought I was caught up on
> > everything...
> 
> :-)
> 
> Are you going to try and test out the imx50 support from Shawn's branch?

My for-next branch below should have all the bits except imx50 pinctrl
driver.

  git://git.linaro.org/people/shawnguo/linux-2.6.git for-next

Shawn
Jason - Nov. 5, 2013, 3:57 p.m.
On Tue, Nov 05, 2013 at 01:02:06PM +1000, Greg Ungerer wrote:
> Hi Jason,
> 
> On 05/11/13 00:57, Jason Cooper wrote:
> > On Mon, Nov 04, 2013 at 09:51:51AM -0500, Jason Cooper wrote:
> >> What happened to the rest of the series?
> > 
> > Crap.  Nevermind.  I just saw that Shawn had already taken the other
> > patches into his tree.  And here I thought I was caught up on
> > everything...
> 
> :-)
> 
> Are you going to try and test out the imx50 support from Shawn's branch?

I did manage to get it to boot, but I'm not confident in it yet.  There
is still a nagging problem (I had with my implementation as well) where

$ sleep 10

takes greater than 20 seconds. :(  Which is why I originally asked you
about the apll...

thx,

Jason.
Greg Ungerer - Nov. 6, 2013, 12:50 a.m.
Hi Jason,

On 06/11/13 01:57, Jason Cooper wrote:
> On Tue, Nov 05, 2013 at 01:02:06PM +1000, Greg Ungerer wrote:
>> Hi Jason,
>>
>> On 05/11/13 00:57, Jason Cooper wrote:
>>> On Mon, Nov 04, 2013 at 09:51:51AM -0500, Jason Cooper wrote:
>>>> What happened to the rest of the series?
>>>
>>> Crap.  Nevermind.  I just saw that Shawn had already taken the other
>>> patches into his tree.  And here I thought I was caught up on
>>> everything...
>>
>> :-)
>>
>> Are you going to try and test out the imx50 support from Shawn's branch?
> 
> I did manage to get it to boot, but I'm not confident in it yet.  There
> is still a nagging problem (I had with my implementation as well) where
> 
> $ sleep 10
> 
> takes greater than 20 seconds. :(  Which is why I originally asked you
> about the apll...

I have seen that. I haven't had a chance to look properly into it.
If you boot Freescales old LTIB code that supports the iMX50 it seems
they are messing with the clock setup to get it just right. It may
be that they just didn't get it right in their boot loader to start
with.

Regards
Greg

Patch

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index bbe1f5b..924e117 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -112,6 +112,7 @@  obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += mach-cpuimx51sd.o
 obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd51-baseboard.o
 
 obj-$(CONFIG_MACH_IMX51_DT) += imx51-dt.o
+obj-$(CONFIG_SOC_IMX50) += mach-imx50.o
 obj-$(CONFIG_SOC_IMX53) += mach-imx53.o
 
 obj-$(CONFIG_SOC_VF610) += clk-vf610.o mach-vf610.o
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index 7cbe22d..9b67672 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -108,6 +108,7 @@  void tzic_handle_irq(struct pt_regs *);
 #define imx27_handle_irq avic_handle_irq
 #define imx31_handle_irq avic_handle_irq
 #define imx35_handle_irq avic_handle_irq
+#define imx50_handle_irq tzic_handle_irq
 #define imx51_handle_irq tzic_handle_irq
 #define imx53_handle_irq tzic_handle_irq
 
diff --git a/arch/arm/mach-imx/mach-imx50.c b/arch/arm/mach-imx/mach-imx50.c
new file mode 100644
index 0000000..dc93bbb
--- /dev/null
+++ b/arch/arm/mach-imx/mach-imx50.c
@@ -0,0 +1,36 @@ 
+/*
+ * Copyright 2013 Greg Ungerer <gerg@uclinux.org>
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * 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/of_platform.h>
+#include <asm/mach/arch.h>
+
+#include "common.h"
+
+static void __init imx50_dt_init(void)
+{
+	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+}
+
+static const char *imx50_dt_board_compat[] __initdata = {
+	"fsl,imx50",
+	NULL
+};
+
+DT_MACHINE_START(IMX50_DT, "Freescale i.MX50 (Device Tree Support)")
+	.map_io		= mx53_map_io,
+	.init_irq	= mx53_init_irq,
+	.handle_irq	= imx50_handle_irq,
+	.init_machine	= imx50_dt_init,
+	.dt_compat	= imx50_dt_board_compat,
+	.restart	= mxc_restart,
+MACHINE_END