* [PATCH 2/3] at91: detect SoC earlier
2013-11-21 7:13 ` [PATCH 1/3] ARM: introduce machine description Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-21 7:13 ` Jean-Christophe PLAGNIOL-VILLARD
2013-11-21 7:13 ` [PATCH 3/3] AT91: usb-a926x: switch to machine description Jean-Christophe PLAGNIOL-VILLARD
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-21 7:13 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/mach-at91/setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 65d0588..5e403a6 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -242,7 +242,7 @@ static int at91_detect(void)
return 0;
}
-postcore_initcall(at91_detect);
+core_initcall(at91_detect);
static int at91_soc_device(void)
{
--
1.8.4.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] AT91: usb-a926x: switch to machine description
2013-11-21 7:13 ` [PATCH 1/3] ARM: introduce machine description Jean-Christophe PLAGNIOL-VILLARD
2013-11-21 7:13 ` [PATCH 2/3] at91: detect SoC earlier Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-21 7:13 ` Jean-Christophe PLAGNIOL-VILLARD
2013-11-21 8:05 ` [PATCH 1/3] ARM: introduce " Alexander Aring
2013-11-22 7:42 ` Sascha Hauer
3 siblings, 0 replies; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-21 7:13 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/usb-a926x/init.c | 39 ++++++++++++++++++++++++++++++++-------
1 file changed, 32 insertions(+), 7 deletions(-)
diff --git a/arch/arm/boards/usb-a926x/init.c b/arch/arm/boards/usb-a926x/init.c
index fd2603f..48c27cf 100644
--- a/arch/arm/boards/usb-a926x/init.c
+++ b/arch/arm/boards/usb-a926x/init.c
@@ -19,6 +19,7 @@
#include <init.h>
#include <environment.h>
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <partition.h>
#include <fs.h>
@@ -32,6 +33,7 @@
#include <mach/board.h>
#include <mach/at91sam9_smc.h>
#include <mach/at91sam9_sdramc.h>
+#include <mach/cpu.h>
#include <gpio.h>
#include <led.h>
#include <mach/io.h>
@@ -391,7 +393,7 @@ static void usb_a9260_device_dab_mmx(void)
static void usb_a9260_device_dab_mmx(void) {}
#endif
-static int usb_a9260_devices_init(void)
+static void usb_a9260_devices_init(void)
{
usb_a9260_add_device_nand();
usb_a9260_add_device_mci();
@@ -414,13 +416,10 @@ static int usb_a9260_devices_init(void)
dev_add_bb_dev("env_raw", "env0");
devfs_add_partition("nand0", SZ_512K, SZ_128K, DEVFS_PARTITION_FIXED, "env_raw1");
dev_add_bb_dev("env_raw1", "env1");
-
- return 0;
}
-device_initcall(usb_a9260_devices_init);
#ifndef CONFIG_CONSOLE_NONE
-static int usb_a9260_console_init(void)
+static void usb_a9260_console_init(void)
{
struct device_d *dev;
@@ -443,15 +442,41 @@ static int usb_a9260_console_init(void)
dev = at91_register_uart(4, 0);
dev_set_param(dev, "active", "");
}
+}
+#endif
+
+static int usb_a9260_machine_detect(void)
+{
+ if (cpu_is_at91sam9g20())
+ arm_set_machine(MACH_TYPE_USB_A9G20);
+ else if (cpu_is_at91sam9263())
+ arm_set_machine(MACH_TYPE_USB_A9263);
+ else
+ arm_set_machine(MACH_TYPE_USB_A9260);
return 0;
}
-console_initcall(usb_a9260_console_init);
-#endif
+postcore_initcall(usb_a9260_machine_detect);
static int usb_a9260_main_clock(void)
{
at91_set_main_clock(12000000);
+
return 0;
}
pure_initcall(usb_a9260_main_clock);
+
+MACHINE_START(USB_A9260, "Calao USB-A9260")
+ .init_console = usb_a9260_console_init,
+ .init_machine = usb_a9260_devices_init,
+MACHINE_END
+
+MACHINE_START(USB_A9263, "Calao USB-A9263")
+ .init_console = usb_a9260_console_init,
+ .init_machine = usb_a9260_devices_init,
+MACHINE_END
+
+MACHINE_START(USB_A9G20, "Calao USB-A9G20")
+ .init_console = usb_a9260_console_init,
+ .init_machine = usb_a9260_devices_init,
+MACHINE_END
--
1.8.4.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] ARM: introduce machine description
2013-11-21 7:13 ` [PATCH 1/3] ARM: introduce machine description Jean-Christophe PLAGNIOL-VILLARD
2013-11-21 7:13 ` [PATCH 2/3] at91: detect SoC earlier Jean-Christophe PLAGNIOL-VILLARD
2013-11-21 7:13 ` [PATCH 3/3] AT91: usb-a926x: switch to machine description Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-21 8:05 ` Alexander Aring
2013-11-22 7:42 ` Sascha Hauer
3 siblings, 0 replies; 7+ messages in thread
From: Alexander Aring @ 2013-11-21 8:05 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
Hi,
On Thu, Nov 21, 2013 at 08:13:53AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> This will allow to do not check in each board which machine we are running
> from. This work on DT & non-DT board.
>
> If only one board is enable autoselect it
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> arch/arm/cpu/Makefile | 2 +-
> arch/arm/cpu/dtb.c | 4 ++
> arch/arm/cpu/machine.c | 110 +++++++++++++++++++++++++++++++++++++++
> arch/arm/include/asm/mach/arch.h | 66 +++++++++++++++++++++++
> arch/arm/lib/barebox.lds.S | 6 +++
> 5 files changed, 187 insertions(+), 1 deletion(-)
> create mode 100644 arch/arm/cpu/machine.c
> create mode 100644 arch/arm/include/asm/mach/arch.h
>
> diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
> index aba201b..78532da 100644
> --- a/arch/arm/cpu/Makefile
> +++ b/arch/arm/cpu/Makefile
> @@ -1,7 +1,7 @@
> obj-y += cpu.o
> obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o
> obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o
> -obj-y += start.o setupc.o
> +obj-y += machine.o start.o setupc.o
>
> #
> # Any variants can be called as start-armxyz.S
> diff --git a/arch/arm/cpu/dtb.c b/arch/arm/cpu/dtb.c
> index a5881dd..62a9860 100644
> --- a/arch/arm/cpu/dtb.c
> +++ b/arch/arm/cpu/dtb.c
> @@ -48,6 +48,10 @@ static int of_arm_init(void)
> }
>
> root = of_unflatten_dtb(NULL, fdt);
> +
> + if (arm_set_dt_machine())
> + pr_debug("No compatible machine found\n");
> +
> if (root) {
> of_set_root_node(root);
> if (IS_ENABLED(CONFIG_OFDEVICE))
> diff --git a/arch/arm/cpu/machine.c b/arch/arm/cpu/machine.c
> new file mode 100644
> index 0000000..e17c5bb
> --- /dev/null
> +++ b/arch/arm/cpu/machine.c
> @@ -0,0 +1,110 @@
> +#include <asm/mach/arch.h>
> +#include <init.h>
> +#include <common.h>
> +#include <string.h>
> +#include <debug_ll.h>
> +
> +const struct machine_desc *machine_desc;
> +unsigned int __machine_arch_type = 0xffffffff;
> +
> +int arm_set_machine(const unsigned int type)
> +{
> + const struct machine_desc *m;
> +
> + puts_ll("type ");
> + puthex_ll(type);
> + puts_ll("\n");
> +
> + if (type == 0xffffffff)
> + return -ENOENT;
> +
> + for_each_machine_desc(m) {
> + puts_ll("machine ");
> + if (m->name)
> + puts_ll(m->name);
> + puts_ll("\n");
> + if (m->nr == type) {
> + machine_desc = (const struct machine_desc *)m;
> + __machine_arch_type = type;
> + return 0;
> + }
> + }
> +
> + return -ENOENT;
> +}
> +
> +int arm_set_dt_machine(void)
> +{
> + const struct machine_desc *m;
> +
> + for_each_machine_desc(m) {
> + if (!m->dt_compat)
> + continue;
> +
> + if (!of_machine_is_compatible((const char *)m->dt_compat))
> + continue;
> +
> + machine_desc = (const struct machine_desc *)m;
> + return 0;
> + }
> +
> + return -ENOENT;
> +}
> +
> +static void arm_mach_only_one_machine(void)
> +{
> + const struct machine_desc *m;
> + const struct machine_desc *tmp = NULL;
> +
> + for_each_machine_desc(m) {
> + if (tmp)
> + return;
> + }
> +
Here is no tmp assign. Are there some sideffects to set tmp here?
If not if (tmp) is always false.
- Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] ARM: introduce machine description
2013-11-21 7:13 ` [PATCH 1/3] ARM: introduce machine description Jean-Christophe PLAGNIOL-VILLARD
` (2 preceding siblings ...)
2013-11-21 8:05 ` [PATCH 1/3] ARM: introduce " Alexander Aring
@ 2013-11-22 7:42 ` Sascha Hauer
2013-11-23 15:02 ` Jean-Christophe PLAGNIOL-VILLARD
3 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2013-11-22 7:42 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
On Thu, Nov 21, 2013 at 08:13:53AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> +static int arm_mach_early_init(void)
> +{
> + arm_mach_only_one_machine();
> +
> + if (machine_desc && machine_desc->init_early)
> + machine_desc->init_early();
> +
> + return 0;
> +}
> +pure_initcall(arm_mach_early_init);
Can we call of_arm_init() from here instead of a separate initcall?
> +
> +static int arm_mach_console_init(void)
> +{
> + if (!machine_desc)
> + return 0;
> +
> + if (machine_desc->name)
> + barebox_set_model(machine_desc->name);
> +
> + if (machine_desc->init_console)
> + machine_desc->init_console();
> +
> + return 0;
> +}
> +console_initcall(arm_mach_console_init);
> +
> +static int arm_mach_machine_init(void)
> +{
> + if (machine_desc && machine_desc->init_machine)
> + machine_desc->init_machine();
> +
> + return 0;
> +}
> +device_initcall(arm_mach_machine_init);
> +
> +static int arm_mach_late_init(void)
> +{
> + if (machine_desc && machine_desc->init_late)
> + machine_desc->init_late();
I think all these should return int. This way we could see if something
goes wrong.
> +
> + return 0;
> +}
> +late_initcall(arm_mach_late_init);
> diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
> new file mode 100644
> index 0000000..4e0e771
> --- /dev/null
> +++ b/arch/arm/include/asm/mach/arch.h
> @@ -0,0 +1,66 @@
> +/*
> + * arch/arm/include/asm/mach/arch.h
> + *
> + * Copyright (C) 2000 Russell King
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/types.h>
> +#include <linux/stringify.h>
> +
> +#ifndef __ASM_MACH_ARCH_H__
> +#define __ASM_MACH_ARCH_H__
> +
> +struct machine_desc {
> + unsigned int nr; /* architecture number */
> + const char *name; /* architecture name */
> + const char *const *dt_compat; /* array of device tree
> + * 'compatible' strings */
> +
> + void (*init_early)(void);
> + void (*init_console)(void);
> + void (*init_time)(void);
I think init_time doesn't make sense in the context of barebox. What I'd
like to have though is a init_soc which the boards set to some SoC
specific function so that later code knows which SoC we're on.
Can we stick the naming more to the existing barebox initcall levels
instead of the Linux machine desc names? Something like:
soc_init
pure_init
core_init
postcore_init
console_init
coredevice_init
device_init
late_init
(Where soc_init would be called on pure_initcall level, but after the
of/machine desc has been parsed)
> +
> +/*
> + * Current machine - only accessible during boot.
> + */
Can you drop the comments that don't make sense for barebox?
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] ARM: introduce machine description
2013-11-22 7:42 ` Sascha Hauer
@ 2013-11-23 15:02 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-23 15:02 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On 08:42 Fri 22 Nov , Sascha Hauer wrote:
> On Thu, Nov 21, 2013 at 08:13:53AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > +static int arm_mach_early_init(void)
> > +{
> > + arm_mach_only_one_machine();
> > +
> > + if (machine_desc && machine_desc->init_early)
> > + machine_desc->init_early();
> > +
> > + return 0;
> > +}
> > +pure_initcall(arm_mach_early_init);
>
> Can we call of_arm_init() from here instead of a separate initcall?
I do not have dt board to test as I've moving for few days
if you can test the v2 on this it will be nice
I've test it on vexpress and at91 (I switch them all)
I was also thinking also to pass the archid to barebox via r1 as done on the
kernel
as on at91bootstrap we are already passing it
we could also use r2 to give dtb add if the first stage handle
so barebox could boot as a linux kernel too
>
> > +
> > +static int arm_mach_console_init(void)
> > +{
> > + if (!machine_desc)
> > + return 0;
> > +
> > + if (machine_desc->name)
> > + barebox_set_model(machine_desc->name);
> > +
> > + if (machine_desc->init_console)
> > + machine_desc->init_console();
> > +
> > + return 0;
> > +}
> > +console_initcall(arm_mach_console_init);
> > +
> > +static int arm_mach_machine_init(void)
> > +{
> > + if (machine_desc && machine_desc->init_machine)
> > + machine_desc->init_machine();
> > +
> > + return 0;
> > +}
> > +device_initcall(arm_mach_machine_init);
> > +
> > +static int arm_mach_late_init(void)
> > +{
> > + if (machine_desc && machine_desc->init_late)
> > + machine_desc->init_late();
>
> I think all these should return int. This way we could see if something
> goes wrong.
ok
>
> > +
> > + return 0;
> > +}
> > +late_initcall(arm_mach_late_init);
> > diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
> > new file mode 100644
> > index 0000000..4e0e771
> > --- /dev/null
> > +++ b/arch/arm/include/asm/mach/arch.h
> > @@ -0,0 +1,66 @@
> > +/*
> > + * arch/arm/include/asm/mach/arch.h
> > + *
> > + * Copyright (C) 2000 Russell King
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include <linux/types.h>
> > +#include <linux/stringify.h>
> > +
> > +#ifndef __ASM_MACH_ARCH_H__
> > +#define __ASM_MACH_ARCH_H__
> > +
> > +struct machine_desc {
> > + unsigned int nr; /* architecture number */
> > + const char *name; /* architecture name */
> > + const char *const *dt_compat; /* array of device tree
> > + * 'compatible' strings */
> > +
> > + void (*init_early)(void);
> > + void (*init_console)(void);
> > + void (*init_time)(void);
>
> I think init_time doesn't make sense in the context of barebox. What I'd
> like to have though is a init_soc which the boards set to some SoC
> specific function so that later code knows which SoC we're on.
here I've an issue some SoC need late_init and other init
so I was thinking to have soc_desc too
>
> Can we stick the naming more to the existing barebox initcall levels
> instead of the Linux machine desc names? Something like:
>
> soc_init
> pure_init
> core_init
> postcore_init
> console_init
> coredevice_init
> device_init
> late_init
with mmu_init and mem_init yes
>
> (Where soc_init would be called on pure_initcall level, but after the
> of/machine desc has been parsed)
>
> > +
> > +/*
> > + * Current machine - only accessible during boot.
> > + */
>
> Can you drop the comments that don't make sense for barebox?
yeah
Best Regards,
J.
>
> Sascha
>
> --
> Pengutronix e.K. | |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread