* [PATCH 0/6] ARM: machine struct support
@ 2013-11-28 18:05 Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 1/6] arm: gen-mach-types: add MAX_MACH_TYPE Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 1 reply; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-28 18:05 UTC (permalink / raw)
To: barebox
Hi,
v2:
add an init for most initcall for SoC & machine
switch all the at91 boards and the arm vexpress
take from ARM Kernel
This patch serie start to add Machine struct description. The idea is
to do not call initall in boards and SoC but instead use this new
struct to allow multiple board and SoC support
This work on dt & non-dt
An other step will be to allow boot loader such as at91bootstrap to
pass the machine type on DT to barebox
The following changes since commit f9083f4e177e37f3adf0dac19b893de18fdfbd3c:
vexpress: fix smc911x in defconfig (2013-11-28 17:32:19 +0800)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git delivery/mach_desc
for you to fetch changes up to 19cfb444c51d9d898e6f9ad54436a937d5833fde:
vexpress: switch to machine description (2013-11-28 17:32:47 +0800)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (6):
arm: gen-mach-types: add MAX_MACH_TYPE
ARM: introduce machine description
ARM: introduce SoC description
AT91: detect SoC earlier
AT91: switch to machine description
vexpress: switch to machine description
arch/arm/boards/animeo_ip/init.c | 25 +++++++++++-----------
arch/arm/boards/at91rm9200ek/init.c | 13 +++++++-----
arch/arm/boards/at91sam9260ek/init.c | 60 +++++++++++++++++++++++++++++++---------------------
arch/arm/boards/at91sam9261ek/init.c | 35 ++++++++++++++++++-------------
arch/arm/boards/at91sam9263ek/init.c | 16 +++++++-------
arch/arm/boards/at91sam9m10g45ek/init.c | 14 +++++++------
arch/arm/boards/at91sam9m10ihd/init.c | 22 +++++++++++---------
arch/arm/boards/at91sam9n12ek/init.c | 14 +++++++------
arch/arm/boards/at91sam9x5ek/init.c | 14 +++++++------
arch/arm/boards/dss11/init.c | 14 +++++++------
arch/arm/boards/mmccpu/init.c | 16 +++++++-------
arch/arm/boards/pm9261/init.c | 14 +++++++------
arch/arm/boards/pm9263/init.c | 16 +++++++-------
arch/arm/boards/pm9g45/init.c | 14 +++++++------
arch/arm/boards/qil-a926x/init.c | 52 +++++++++++++++++++++++++++-------------------
arch/arm/boards/sama5d3xek/init.c | 19 ++++++++++++-----
arch/arm/boards/telit-evk-pro3/init.c | 19 ++++++++++++-----
arch/arm/boards/tny-a926x/init.c | 50 +++++++++++++++++++++++++-------------------
arch/arm/boards/usb-a926x/init.c | 52 +++++++++++++++++++++++++++-------------------
arch/arm/boards/vexpress/init.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------------------
arch/arm/cpu/Makefile | 2 +-
arch/arm/cpu/dtb.c | 8 +++++--
arch/arm/cpu/machine.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
arch/arm/include/asm/barebox-arm.h | 8 +++++++
arch/arm/include/asm/mach/arch.h | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
arch/arm/lib/barebox.lds.S | 6 ++++++
arch/arm/mach-at91/clock.c | 10 ++-------
arch/arm/mach-at91/generic.h | 2 +-
arch/arm/mach-at91/include/mach/board.h | 2 +-
arch/arm/mach-at91/setup.c | 12 ++++++-----
arch/arm/tools/gen-mach-types | 8 ++++++-
31 files changed, 672 insertions(+), 278 deletions(-)
create mode 100644 arch/arm/cpu/machine.c
create mode 100644 arch/arm/include/asm/mach/arch.h
Best Regards,
J.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/6] arm: gen-mach-types: add MAX_MACH_TYPE
2013-11-28 18:05 [PATCH 0/6] ARM: machine struct support Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-28 18:06 ` Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 2/6] ARM: introduce machine description Jean-Christophe PLAGNIOL-VILLARD
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-28 18:06 UTC (permalink / raw)
To: barebox
this will be usefull to check that we set a valid machine id
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/tools/gen-mach-types | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/arm/tools/gen-mach-types b/arch/arm/tools/gen-mach-types
index 04fef71..fd771aa 100644
--- a/arch/arm/tools/gen-mach-types
+++ b/arch/arm/tools/gen-mach-types
@@ -34,9 +34,15 @@ END {
printf("#endif\n\n");
printf("/* see arch/arm/kernel/arch.c for a description of these */\n");
+ max_mach_type = 0
for (i = 0; i < nr; i++)
- if (num[i] ~ /..*/)
+ if (num[i] ~ /..*/) {
printf("#define %-30s %d\n", mach_type[i], num[i]);
+ if (num[i] > max_mach_type)
+ max_mach_type = num[i]
+ }
+
+ printf("#define MAX_MACH_TYPE %d\n", max_mach_type);
printf("\n");
--
1.8.4.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/6] ARM: introduce machine description
2013-11-28 18:06 ` [PATCH 1/6] arm: gen-mach-types: add MAX_MACH_TYPE Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-28 18:06 ` Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:19 ` Alexander Aring
2013-12-02 9:01 ` Sascha Hauer
2013-11-28 18:06 ` [PATCH 3/6] ARM: introduce SoC description Jean-Christophe PLAGNIOL-VILLARD
` (3 subsequent siblings)
4 siblings, 2 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-28 18:06 UTC (permalink / raw)
To: barebox
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 | 8 +-
arch/arm/cpu/machine.c | 188 +++++++++++++++++++++++++++++++++++++
arch/arm/include/asm/barebox-arm.h | 8 ++
arch/arm/include/asm/mach/arch.h | 68 ++++++++++++++
arch/arm/lib/barebox.lds.S | 6 ++
6 files changed, 277 insertions(+), 3 deletions(-)
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..ee7006e 100644
--- a/arch/arm/cpu/dtb.c
+++ b/arch/arm/cpu/dtb.c
@@ -18,10 +18,11 @@
#include <init.h>
#include <of.h>
#include <asm/barebox-arm.h>
+#include <asm/mach/arch.h>
extern char __dtb_start[];
-static int of_arm_init(void)
+int of_arm_init(void)
{
struct device_node *root;
void *fdt;
@@ -48,6 +49,10 @@ static int of_arm_init(void)
}
root = of_unflatten_dtb(NULL, fdt);
+
+ if (arm_set_dt_machine(NULL))
+ pr_debug("No compatible machine found\n");
+
if (root) {
of_set_root_node(root);
if (IS_ENABLED(CONFIG_OFDEVICE))
@@ -56,4 +61,3 @@ static int of_arm_init(void)
return 0;
}
-core_initcall(of_arm_init);
diff --git a/arch/arm/cpu/machine.c b/arch/arm/cpu/machine.c
new file mode 100644
index 0000000..ad0d8cb
--- /dev/null
+++ b/arch/arm/cpu/machine.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * Under GPLv2 Only
+ */
+
+#include <common.h>
+#include <asm/mach/arch.h>
+#include <asm/barebox-arm.h>
+#include <asm/armlinux.h>
+#include <generated/mach-types.h>
+#include <init.h>
+#include <string.h>
+#include <debug_ll.h>
+
+const struct machine_desc *machine_desc;
+unsigned int __machine_arch_type = ~0;
+
+int arm_set_machine(const unsigned int type)
+{
+ const struct machine_desc *m;
+
+ puts_ll("type ");
+ puthex_ll(type);
+ puts_ll("\n");
+
+ if (type == ~0)
+ 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;
+ armlinux_set_architecture(__machine_arch_type);
+ return 0;
+ }
+ }
+
+ return -ENOENT;
+}
+
+int is_dt_compatible(const struct machine_desc *m, const char* dt_compat)
+{
+ const char *const *dtc = m->dt_compat;
+
+ while (dtc) {
+ const char *s = *dtc;
+ if (dt_compat && !of_compat_cmp(s, dt_compat, strlen(dt_compat)))
+ return 1;
+ else if (of_machine_is_compatible(s))
+ return 1;
+ dtc++;
+ }
+
+ return 0;
+}
+
+int arm_set_dt_machine(const char* dt_compat)
+{
+ const struct machine_desc *m;
+
+ for_each_machine_desc(m) {
+ if (!is_dt_compatible(m, dt_compat))
+ continue;
+
+ machine_desc = (const struct machine_desc *)m;
+ if (m->nr != ~0)
+ armlinux_set_architecture(m->nr);
+
+ 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;
+ tmp = m;
+ }
+
+ if (!tmp)
+ return;
+ machine_desc = (const struct machine_desc *)tmp;
+ armlinux_set_architecture(machine_desc->nr);
+}
+
+#define arm_mach_xx_init(level) \
+({ \
+ int __ret = 0; \
+ \
+ do { \
+ if (!machine_desc) \
+ break; \
+ \
+ if (machine_desc->level##_init) { \
+ __ret = machine_desc->level##_init(); \
+ if (__ret) \
+ break; \
+ } \
+ } while(0); \
+ __ret; \
+})
+
+static int arm_mach_pure_init(void)
+{
+ int ret = -EINVAL;
+
+ if (__machine_arch_type != ~0 && __machine_arch_type < MAX_MACH_TYPE)
+ ret = arm_set_machine(__machine_arch_type);
+ if (ret)
+ arm_mach_only_one_machine();
+ of_arm_init();
+
+ ret = arm_mach_xx_init(pure);
+
+ return ret;
+}
+pure_initcall(arm_mach_pure_init);
+
+static int arm_mach_core_init(void)
+{
+ return arm_mach_xx_init(core);
+}
+core_initcall(arm_mach_core_init);
+
+static int arm_mach_postcore_init(void)
+{
+ return arm_mach_xx_init(postcore);
+}
+postcore_initcall(arm_mach_postcore_init);
+
+static int arm_mach_console_init(void)
+{
+ if (!machine_desc)
+ return 0;
+
+ if (machine_desc->name)
+ barebox_set_model(machine_desc->name);
+
+ return arm_mach_xx_init(console);
+}
+console_initcall(arm_mach_console_init);
+
+static int arm_mach_postconsole_init(void)
+{
+ return arm_mach_xx_init(postconsole);
+}
+postconsole_initcall(arm_mach_postconsole_init);
+
+static int arm_mach_mem_init(void)
+{
+ return arm_mach_xx_init(mem);
+}
+mem_initcall(arm_mach_mem_init);
+
+static int arm_mach_postmmu_init(void)
+{
+ return arm_mach_xx_init(postmmu);
+}
+postmmu_initcall(arm_mach_postmmu_init);
+
+static int arm_mach_coredevice_init(void)
+{
+ return arm_mach_xx_init(coredevice);
+}
+coredevice_initcall(arm_mach_coredevice_init);
+
+static int arm_mach_device_init(void)
+{
+ return arm_mach_xx_init(device);
+}
+device_initcall(arm_mach_device_init);
+
+static int arm_mach_late_init(void)
+{
+ return arm_mach_xx_init(late);
+}
+late_initcall(arm_mach_late_init);
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 622bd13..877edcd 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -34,6 +34,14 @@ int cleanup_before_linux(void);
/* arch/<arch>board(s)/.../... */
int board_init(void);
int dram_init (void);
+#ifdef CONFIG_OFDEVICE
+int of_arm_init(void);
+#else
+static inline int of_arm_init(void)
+{
+ return 0;
+}
+#endif
extern char __exceptions_start[], __exceptions_stop[];
diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
new file mode 100644
index 0000000..91f1d2e
--- /dev/null
+++ b/arch/arm/include/asm/mach/arch.h
@@ -0,0 +1,68 @@
+/*
+ * 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 */
+
+ int (*pure_init)(void);
+ int (*core_init)(void);
+ int (*postcore_init)(void);
+ int (*console_init)(void);
+ int (*postconsole_init)(void);
+ int (*mem_init)(void);
+ int (*postmmu_init)(void);
+ int (*coredevice_init)(void);
+ int (*device_init)(void);
+ int (*late_init)(void);
+};
+
+extern const struct machine_desc *machine_desc;
+
+int arm_set_machine(const unsigned int type);
+int arm_set_dt_machine(const char* dt_compat);
+
+/*
+ * Machine type table - also only accessible during boot
+ */
+extern const struct machine_desc __arch_info_begin[], __arch_info_end[];
+#define for_each_machine_desc(p) \
+ for (p = __arch_info_begin; p < __arch_info_end; p++)
+
+/*
+ * Set of macros to define architecture features. This is built into
+ * a table by the linker.
+ */
+#define MACHINE_START(_type,_name) \
+static const struct machine_desc __mach_desc_##_type \
+ __used \
+ __attribute__ ((unused,section (".barebox_mach_" __stringify(_type)))) = { \
+ .nr = MACH_TYPE_##_type, \
+ .name = _name,
+
+#define MACHINE_END \
+};
+
+#define DT_MACHINE_START(_name, _namestr) \
+static const struct machine_desc __mach_desc_##_name \
+ __used \
+ __attribute__ ((unused,section (".barebox_mach_" __stringify(_name)))) = { \
+ .nr = ~0, \
+ .name = _namestr,
+
+#endif
diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
index 10c63bf..637d205 100644
--- a/arch/arm/lib/barebox.lds.S
+++ b/arch/arm/lib/barebox.lds.S
@@ -94,6 +94,12 @@ SECTIONS
.dtb : { BAREBOX_DTB() }
+ .arch.info : {
+ __arch_info_begin = .;
+ KEEP(*(SORT_BY_NAME(.barebox_mach*)))
+ __arch_info_end = .;
+ }
+
.rel.dyn : {
__rel_dyn_start = .;
*(.rel*)
--
1.8.4.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/6] ARM: introduce SoC description
2013-11-28 18:06 ` [PATCH 1/6] arm: gen-mach-types: add MAX_MACH_TYPE Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 2/6] ARM: introduce machine description Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-28 18:06 ` Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 4/6] AT91: detect SoC earlier Jean-Christophe PLAGNIOL-VILLARD
` (2 subsequent siblings)
4 siblings, 0 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-28 18:06 UTC (permalink / raw)
To: barebox
This will allow to do have runtime SoC init level based on the current machine
running.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/cpu/machine.c | 6 ++++++
arch/arm/include/asm/mach/arch.h | 17 +++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/arch/arm/cpu/machine.c b/arch/arm/cpu/machine.c
index ad0d8cb..55266f5 100644
--- a/arch/arm/cpu/machine.c
+++ b/arch/arm/cpu/machine.c
@@ -107,6 +107,12 @@ static void arm_mach_only_one_machine(void)
if (__ret) \
break; \
} \
+ \
+ if (!machine_desc->soc_desc) \
+ break; \
+ \
+ if (machine_desc->soc_desc->level##_init) \
+ __ret = machine_desc->soc_desc->level##_init(); \
} while(0); \
__ret; \
})
diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
index 91f1d2e..71dbb83 100644
--- a/arch/arm/include/asm/mach/arch.h
+++ b/arch/arm/include/asm/mach/arch.h
@@ -14,12 +14,29 @@
#ifndef __ASM_MACH_ARCH_H__
#define __ASM_MACH_ARCH_H__
+struct soc_desc {
+ const char *name; /* architecture name */
+
+ int (*pure_init)(void);
+ int (*core_init)(void);
+ int (*postcore_init)(void);
+ int (*console_init)(void);
+ int (*postconsole_init)(void);
+ int (*mem_init)(void);
+ int (*postmmu_init)(void);
+ int (*coredevice_init)(void);
+ int (*device_init)(void);
+ int (*late_init)(void);
+};
+
struct machine_desc {
unsigned int nr; /* architecture number */
const char *name; /* architecture name */
const char *const *dt_compat; /* array of device tree
* 'compatible' strings */
+ struct soc_desc *soc_desc;
+
int (*pure_init)(void);
int (*core_init)(void);
int (*postcore_init)(void);
--
1.8.4.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/6] AT91: detect SoC earlier
2013-11-28 18:06 ` [PATCH 1/6] arm: gen-mach-types: add MAX_MACH_TYPE Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 2/6] ARM: introduce machine description Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 3/6] ARM: introduce SoC description Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-28 18:06 ` Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 5/6] AT91: switch to machine description Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 6/6] vexpress: " Jean-Christophe PLAGNIOL-VILLARD
4 siblings, 0 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-28 18:06 UTC (permalink / raw)
To: barebox
Intoduce at91_initialize as we can init the clock at pure initcall
so drop at91_set_main_clock
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/animeo_ip/init.c | 2 +-
arch/arm/boards/at91rm9200ek/init.c | 2 +-
arch/arm/boards/at91sam9260ek/init.c | 2 +-
arch/arm/boards/at91sam9261ek/init.c | 2 +-
arch/arm/boards/at91sam9263ek/init.c | 2 +-
arch/arm/boards/at91sam9m10g45ek/init.c | 2 +-
arch/arm/boards/at91sam9m10ihd/init.c | 2 +-
arch/arm/boards/at91sam9n12ek/init.c | 2 +-
arch/arm/boards/at91sam9x5ek/init.c | 2 +-
arch/arm/boards/dss11/init.c | 2 +-
arch/arm/boards/mmccpu/init.c | 2 +-
arch/arm/boards/pm9261/init.c | 2 +-
arch/arm/boards/pm9263/init.c | 2 +-
arch/arm/boards/pm9g45/init.c | 2 +-
arch/arm/boards/qil-a926x/init.c | 2 +-
arch/arm/boards/sama5d3xek/init.c | 2 +-
arch/arm/boards/telit-evk-pro3/init.c | 2 +-
arch/arm/boards/tny-a926x/init.c | 2 +-
arch/arm/boards/usb-a926x/init.c | 2 +-
arch/arm/mach-at91/clock.c | 10 ++--------
arch/arm/mach-at91/generic.h | 2 +-
arch/arm/mach-at91/include/mach/board.h | 2 +-
arch/arm/mach-at91/setup.c | 12 +++++++-----
23 files changed, 30 insertions(+), 34 deletions(-)
diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c
index 2fee1ff..f095553 100644
--- a/arch/arm/boards/animeo_ip/init.c
+++ b/arch/arm/boards/animeo_ip/init.c
@@ -364,7 +364,7 @@ console_initcall(animeo_ip_console_init);
static int animeo_ip_main_clock(void)
{
- at91_set_main_clock(18432000);
+ at91_initialize(18432000);
return 0;
}
pure_initcall(animeo_ip_main_clock);
diff --git a/arch/arm/boards/at91rm9200ek/init.c b/arch/arm/boards/at91rm9200ek/init.c
index 2c8bf0e..279d819 100644
--- a/arch/arm/boards/at91rm9200ek/init.c
+++ b/arch/arm/boards/at91rm9200ek/init.c
@@ -194,7 +194,7 @@ console_initcall(at91rm9200ek_console_init);
static int at91rm9200ek_main_clock(void)
{
- at91_set_main_clock(18432000);
+ at91_initialize(18432000);
return 0;
}
pure_initcall(at91rm9200ek_main_clock);
diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
index 688ed99..8ae0942 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -281,7 +281,7 @@ console_initcall(at91sam9260ek_console_init);
static int at91sam9260ek_main_clock(void)
{
- at91_set_main_clock(18432000);
+ at91_initialize(18432000);
return 0;
}
pure_initcall(at91sam9260ek_main_clock);
diff --git a/arch/arm/boards/at91sam9261ek/init.c b/arch/arm/boards/at91sam9261ek/init.c
index 00fc745..88b48cb 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/init.c
@@ -418,7 +418,7 @@ console_initcall(at91sam9261ek_console_init);
static int at91sam9261ek_main_clock(void)
{
- at91_set_main_clock(18432000);
+ at91_initialize(18432000);
return 0;
}
pure_initcall(at91sam9261ek_main_clock);
diff --git a/arch/arm/boards/at91sam9263ek/init.c b/arch/arm/boards/at91sam9263ek/init.c
index a889b5a..7011a94 100644
--- a/arch/arm/boards/at91sam9263ek/init.c
+++ b/arch/arm/boards/at91sam9263ek/init.c
@@ -291,7 +291,7 @@ console_initcall(at91sam9263ek_console_init);
static int at91sam9263ek_main_clock(void)
{
- at91_set_main_clock(16367660);
+ at91_initialize(16367660);
return 0;
}
pure_initcall(at91sam9263ek_main_clock);
diff --git a/arch/arm/boards/at91sam9m10g45ek/init.c b/arch/arm/boards/at91sam9m10g45ek/init.c
index 0ffbec2..0eb0f44 100644
--- a/arch/arm/boards/at91sam9m10g45ek/init.c
+++ b/arch/arm/boards/at91sam9m10g45ek/init.c
@@ -336,7 +336,7 @@ console_initcall(at91sam9m10g45ek_console_init);
static int at91sam9m10g45ek_main_clock(void)
{
- at91_set_main_clock(12000000);
+ at91_initialize(12000000);
return 0;
}
pure_initcall(at91sam9m10g45ek_main_clock);
diff --git a/arch/arm/boards/at91sam9m10ihd/init.c b/arch/arm/boards/at91sam9m10ihd/init.c
index b75c51d..0452366 100644
--- a/arch/arm/boards/at91sam9m10ihd/init.c
+++ b/arch/arm/boards/at91sam9m10ihd/init.c
@@ -293,7 +293,7 @@ console_initcall(at91sam9m10ihd_console_init);
static int at91sam9m10ihd_main_clock(void)
{
- at91_set_main_clock(12000000);
+ at91_initialize(12000000);
return 0;
}
pure_initcall(at91sam9m10ihd_main_clock);
diff --git a/arch/arm/boards/at91sam9n12ek/init.c b/arch/arm/boards/at91sam9n12ek/init.c
index 779e4f7..eb21c51 100644
--- a/arch/arm/boards/at91sam9n12ek/init.c
+++ b/arch/arm/boards/at91sam9n12ek/init.c
@@ -344,7 +344,7 @@ console_initcall(at91sam9n12ek_console_init);
static int at91sam9n12ek_main_clock(void)
{
- at91_set_main_clock(16000000);
+ at91_initialize(16000000);
return 0;
}
pure_initcall(at91sam9n12ek_main_clock);
diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index c677e4d..e41cd53 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -338,7 +338,7 @@ console_initcall(at91sam9x5ek_console_init);
static int at91sam9x5ek_main_clock(void)
{
- at91_set_main_clock(12000000);
+ at91_initialize(12000000);
return 0;
}
pure_initcall(at91sam9x5ek_main_clock);
diff --git a/arch/arm/boards/dss11/init.c b/arch/arm/boards/dss11/init.c
index 8e992f4..1c76d4f 100644
--- a/arch/arm/boards/dss11/init.c
+++ b/arch/arm/boards/dss11/init.c
@@ -165,7 +165,7 @@ console_initcall(dss11_console_init);
static int dss11_main_clock(void)
{
- at91_set_main_clock(18432000);
+ at91_initialize(18432000);
return 0;
}
pure_initcall(dss11_main_clock);
diff --git a/arch/arm/boards/mmccpu/init.c b/arch/arm/boards/mmccpu/init.c
index a666b9d..d13ef50 100644
--- a/arch/arm/boards/mmccpu/init.c
+++ b/arch/arm/boards/mmccpu/init.c
@@ -84,7 +84,7 @@ console_initcall(mmccpu_console_init);
static int mmccpu_main_clock(void)
{
- at91_set_main_clock(18432000);
+ at91_initialize(18432000);
return 0;
}
pure_initcall(mmccpu_main_clock);
diff --git a/arch/arm/boards/pm9261/init.c b/arch/arm/boards/pm9261/init.c
index 8c039b7..cced419 100644
--- a/arch/arm/boards/pm9261/init.c
+++ b/arch/arm/boards/pm9261/init.c
@@ -168,7 +168,7 @@ console_initcall(pm9261_console_init);
static int pm9261_main_clock(void)
{
- at91_set_main_clock(18432000);
+ at91_initialize(18432000);
return 0;
}
pure_initcall(pm9261_main_clock);
diff --git a/arch/arm/boards/pm9263/init.c b/arch/arm/boards/pm9263/init.c
index 3bc22f3..78ec9ce 100644
--- a/arch/arm/boards/pm9263/init.c
+++ b/arch/arm/boards/pm9263/init.c
@@ -153,7 +153,7 @@ console_initcall(pm9263_console_init);
static int pm9263_main_clock(void)
{
- at91_set_main_clock(18432000);
+ at91_initialize(18432000);
return 0;
}
pure_initcall(pm9263_main_clock);
diff --git a/arch/arm/boards/pm9g45/init.c b/arch/arm/boards/pm9g45/init.c
index 75fd8a4..caeec43 100644
--- a/arch/arm/boards/pm9g45/init.c
+++ b/arch/arm/boards/pm9g45/init.c
@@ -180,7 +180,7 @@ console_initcall(pm9g45_console_init);
static int pm9g45_main_clock(void)
{
- at91_set_main_clock(12000000);
+ at91_initialize(12000000);
return 0;
}
pure_initcall(pm9g45_main_clock);
diff --git a/arch/arm/boards/qil-a926x/init.c b/arch/arm/boards/qil-a926x/init.c
index 4192923..3ec7dba 100644
--- a/arch/arm/boards/qil-a926x/init.c
+++ b/arch/arm/boards/qil-a926x/init.c
@@ -250,7 +250,7 @@ static int qil_a9260_main_clock(void)
barebox_set_hostname("qil-a9260");
}
- at91_set_main_clock(12000000);
+ at91_initialize(12000000);
return 0;
}
pure_initcall(qil_a9260_main_clock);
diff --git a/arch/arm/boards/sama5d3xek/init.c b/arch/arm/boards/sama5d3xek/init.c
index 482c74a..312b319 100644
--- a/arch/arm/boards/sama5d3xek/init.c
+++ b/arch/arm/boards/sama5d3xek/init.c
@@ -439,7 +439,7 @@ console_initcall(at91sama5d3xek_console_init);
static int at91sama5d3xek_main_clock(void)
{
- at91_set_main_clock(12000000);
+ at91_initialize(12000000);
return 0;
}
pure_initcall(at91sama5d3xek_main_clock);
diff --git a/arch/arm/boards/telit-evk-pro3/init.c b/arch/arm/boards/telit-evk-pro3/init.c
index 005d207..c077d3f 100644
--- a/arch/arm/boards/telit-evk-pro3/init.c
+++ b/arch/arm/boards/telit-evk-pro3/init.c
@@ -181,7 +181,7 @@ console_initcall(evk_console_init);
static int evk_main_clock(void)
{
- at91_set_main_clock(6000000);
+ at91_initialize(6000000);
return 0;
}
pure_initcall(evk_main_clock);
diff --git a/arch/arm/boards/tny-a926x/init.c b/arch/arm/boards/tny-a926x/init.c
index e3dd784..91ee82e 100644
--- a/arch/arm/boards/tny-a926x/init.c
+++ b/arch/arm/boards/tny-a926x/init.c
@@ -267,7 +267,7 @@ console_initcall(tny_a9260_console_init);
static int tny_a9260_main_clock(void)
{
- at91_set_main_clock(12000000);
+ at91_initialize(12000000);
return 0;
}
pure_initcall(tny_a9260_main_clock);
diff --git a/arch/arm/boards/usb-a926x/init.c b/arch/arm/boards/usb-a926x/init.c
index fd2603f..f1046ae 100644
--- a/arch/arm/boards/usb-a926x/init.c
+++ b/arch/arm/boards/usb-a926x/init.c
@@ -451,7 +451,7 @@ console_initcall(usb_a9260_console_init);
static int usb_a9260_main_clock(void)
{
- at91_set_main_clock(12000000);
+ at91_initialize(12000000);
return 0;
}
pure_initcall(usb_a9260_main_clock);
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index a10d7f6..28f3e96 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -616,20 +616,14 @@ static void at91_upll_usbfs_clock_init(unsigned long main_clock)
static int pll_overclock = 0;
static u32 cpu_freq = 0;
-static unsigned long at91_main_clock = 0;
-void at91_set_main_clock(unsigned long rate)
-{
- at91_main_clock = rate;
-}
-
-int at91_clock_init(void)
+int at91_clock_init(unsigned long rate)
{
unsigned tmp, freq, mckr;
int i;
unsigned long main_clock;
- main_clock = at91_main_clock;
+ main_clock = rate;
/*
* When the bootloader initialized the main oscillator correctly,
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index a47bcb2..3c5f127 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -9,7 +9,7 @@
*/
/* Clocks */
-extern int __init at91_clock_init(void);
+extern int __init at91_clock_init(unsigned long main_clock);
static inline struct device_d *at91_add_rm9200_gpio(int id, resource_size_t start)
{
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index aa0fdae..13cd465 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -30,7 +30,7 @@
#include <linux/phy.h>
#include <platform_data/macb.h>
-void at91_set_main_clock(unsigned long rate);
+void at91_initialize(unsigned long rate);
/* USB Host */
struct at91_usbh_data {
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 65d0588..852152d 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -214,7 +214,7 @@ const char *at91_get_soc_subtype(struct at91_socinfo *c)
}
EXPORT_SYMBOL(at91_get_soc_subtype);
-static int at91_detect(void)
+static void at91_detect(void)
{
at91_soc_initdata.type = AT91_SOC_NONE;
at91_soc_initdata.subtype = AT91_SOC_SUBTYPE_NONE;
@@ -233,16 +233,18 @@ static int at91_detect(void)
if (!at91_soc_is_enabled())
panic("AT91: Soc not enabled");
+}
+
+void at91_initialize(unsigned long main_clock)
+{
+ at91_detect();
/* Init clock subsystem */
- at91_clock_init();
+ at91_clock_init(main_clock);
if (at91_boot_soc.init)
at91_boot_soc.init();
-
- return 0;
}
-postcore_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] 13+ messages in thread
* [PATCH 5/6] AT91: switch to machine description
2013-11-28 18:06 ` [PATCH 1/6] arm: gen-mach-types: add MAX_MACH_TYPE Jean-Christophe PLAGNIOL-VILLARD
` (2 preceding siblings ...)
2013-11-28 18:06 ` [PATCH 4/6] AT91: detect SoC earlier Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-28 18:06 ` Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 6/6] vexpress: " Jean-Christophe PLAGNIOL-VILLARD
4 siblings, 0 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-28 18:06 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/animeo_ip/init.c | 23 ++++++-------
arch/arm/boards/at91rm9200ek/init.c | 11 ++++---
arch/arm/boards/at91sam9260ek/init.c | 58 ++++++++++++++++++++-------------
arch/arm/boards/at91sam9261ek/init.c | 33 +++++++++++--------
arch/arm/boards/at91sam9263ek/init.c | 14 ++++----
arch/arm/boards/at91sam9m10g45ek/init.c | 12 ++++---
arch/arm/boards/at91sam9m10ihd/init.c | 20 +++++++-----
arch/arm/boards/at91sam9n12ek/init.c | 12 ++++---
arch/arm/boards/at91sam9x5ek/init.c | 12 ++++---
arch/arm/boards/dss11/init.c | 12 ++++---
arch/arm/boards/mmccpu/init.c | 14 ++++----
arch/arm/boards/pm9261/init.c | 12 ++++---
arch/arm/boards/pm9263/init.c | 14 ++++----
arch/arm/boards/pm9g45/init.c | 12 ++++---
arch/arm/boards/qil-a926x/init.c | 50 ++++++++++++++++------------
arch/arm/boards/sama5d3xek/init.c | 17 +++++++---
arch/arm/boards/telit-evk-pro3/init.c | 17 +++++++---
arch/arm/boards/tny-a926x/init.c | 48 +++++++++++++++------------
arch/arm/boards/usb-a926x/init.c | 50 ++++++++++++++++------------
19 files changed, 262 insertions(+), 179 deletions(-)
diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c
index f095553..0ec989c 100644
--- a/arch/arm/boards/animeo_ip/init.c
+++ b/arch/arm/boards/animeo_ip/init.c
@@ -10,6 +10,7 @@
#include <environment.h>
#include <fec.h>
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <partition.h>
#include <fs.h>
@@ -307,11 +308,6 @@ static int animeo_ip_devices_init(void)
animeo_ip_add_device_led();
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- /*
- * in production the machine id used is the cpu module machine id
- * PICOCOM1
- */
- armlinux_set_architecture(MACH_TYPE_PICOCOM1);
devfs_add_partition("nand0", 0x00000, SZ_32K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
@@ -325,8 +321,6 @@ static int animeo_ip_devices_init(void)
return 0;
}
-device_initcall(animeo_ip_devices_init);
-
static struct device_d *usart0, *usart1;
static void animeo_ip_shutdown_uart(void *base)
@@ -355,19 +349,16 @@ static int animeo_ip_console_init(void)
usart1 = at91_register_uart(2, ATMEL_UART_RTS);
board_shutdown = animeo_ip_shutdown;
- barebox_set_model("Somfy Animeo IP");
barebox_set_hostname("animeoip");
return 0;
}
-console_initcall(animeo_ip_console_init);
static int animeo_ip_main_clock(void)
{
at91_initialize(18432000);
return 0;
}
-pure_initcall(animeo_ip_main_clock);
static unsigned int get_char_timeout(struct console_device *cs, int timeout)
{
@@ -428,4 +419,14 @@ err:
return 0;
}
-late_initcall(animeo_ip_cross_detect_init);
+
+/*
+ * in production the machine id used is the cpu module machine id
+ * PICOCOM1
+ */
+MACHINE_START(PICOCOM1, "Somfy Animeo IP")
+ .pure_init = animeo_ip_main_clock,
+ .console_init = animeo_ip_console_init,
+ .device_init = animeo_ip_devices_init,
+ .late_init = animeo_ip_cross_detect_init,
+MACHINE_END
diff --git a/arch/arm/boards/at91rm9200ek/init.c b/arch/arm/boards/at91rm9200ek/init.c
index 279d819..ea25aec 100644
--- a/arch/arm/boards/at91rm9200ek/init.c
+++ b/arch/arm/boards/at91rm9200ek/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>
@@ -176,21 +177,17 @@ static int at91rm9200ek_devices_init(void)
#endif
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- armlinux_set_architecture(MACH_TYPE_AT91RM9200EK);
return 0;
}
-device_initcall(at91rm9200ek_devices_init);
static int at91rm9200ek_console_init(void)
{
- barebox_set_model("Atmel at91rm9200-ek");
barebox_set_hostname("at91rm9200-ek");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(at91rm9200ek_console_init);
static int at91rm9200ek_main_clock(void)
{
@@ -198,3 +195,9 @@ static int at91rm9200ek_main_clock(void)
return 0;
}
pure_initcall(at91rm9200ek_main_clock);
+
+MACHINE_START(AT91RM9200EK, "Atmel at91rm9200-ek")
+ .pure_init = at91rm9200ek_main_clock,
+ .console_init = at91rm9200ek_console_init,
+ .device_init = at91rm9200ek_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
index 8ae0942..01f1110 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -16,6 +16,7 @@
#include <init.h>
#include <environment.h>
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <nand.h>
#include <sizes.h>
@@ -25,26 +26,9 @@
#include <mach/io.h>
#include <mach/iomux.h>
#include <mach/at91_rstc.h>
+#include <mach/cpu.h>
#include <linux/clk.h>
-/*
- * board revision encoding
- * bit 0:
- * 0 => 1 mmc
- * 1 => 2 mmcs (board from revision C)
- */
-#define HAVE_2MMC (1 << 0)
-static void ek_set_board_type(void)
-{
- if (machine_is_at91sam9g20ek()) {
- armlinux_set_architecture(MACH_TYPE_AT91SAM9G20EK);
- if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC))
- armlinux_set_revision(HAVE_2MMC);
- } else {
- armlinux_set_architecture(MACH_TYPE_AT91SAM9260EK);
- }
-}
-
static struct atmel_nand_data nand_pdata = {
.ale = 21,
.cle = 22,
@@ -249,7 +233,6 @@ static int at91sam9260ek_devices_init(void)
ek_add_led();
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- ek_set_board_type();
devfs_add_partition("nand0", 0x00000, SZ_128K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
@@ -262,22 +245,41 @@ static int at91sam9260ek_devices_init(void)
return 0;
}
-device_initcall(at91sam9260ek_devices_init);
+
+/*
+ * board revision encoding
+ * bit 0:
+ * 0 => 1 mmc
+ * 1 => 2 mmcs (board from revision C)
+ */
+#define HAVE_2MMC (1 << 0)
static int at91sam9260ek_console_init(void)
{
if (machine_is_at91sam9g20ek()) {
- barebox_set_model("Atmel at91sam9g20-ek");
barebox_set_hostname("at91sam9g20-ek");
+ if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC)) {
+ armlinux_set_revision(HAVE_2MMC);
+ barebox_set_model("Atmel at91sam9g20-ek 2MMC");
+ }
} else {
- barebox_set_model("Atmel at91sam9260-ek");
barebox_set_hostname("at91sam9260-ek");
}
at91_register_uart(0, 0);
return 0;
}
-console_initcall(at91sam9260ek_console_init);
+
+static int at91sam9260ek_machine_detect(void)
+{
+ if (cpu_is_at91sam9g20())
+ arm_set_machine(MACH_TYPE_AT91SAM9G20EK);
+ else
+ arm_set_machine(MACH_TYPE_AT91SAM9260EK);
+
+ return 0;
+}
+postcore_initcall(at91sam9260ek_machine_detect);
static int at91sam9260ek_main_clock(void)
{
@@ -285,3 +287,13 @@ static int at91sam9260ek_main_clock(void)
return 0;
}
pure_initcall(at91sam9260ek_main_clock);
+
+MACHINE_START(AT91SAM9260EK, "Atmel at91sam9260-ek")
+ .console_init = at91sam9260ek_console_init,
+ .device_init = at91sam9260ek_devices_init,
+MACHINE_END
+
+MACHINE_START(AT91SAM9G20EK, "Atmel at91sam9g20-ek")
+ .console_init = at91sam9260ek_console_init,
+ .device_init = at91sam9260ek_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/at91sam9261ek/init.c b/arch/arm/boards/at91sam9261ek/init.c
index 88b48cb..3640cc9 100644
--- a/arch/arm/boards/at91sam9261ek/init.c
+++ b/arch/arm/boards/at91sam9261ek/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>
@@ -30,6 +31,7 @@
#include <linux/mtd/nand.h>
#include <mach/at91_pmc.h>
#include <mach/board.h>
+#include <mach/cpu.h>
#include <gpio.h>
#include <mach/io.h>
#include <mach/iomux.h>
@@ -390,35 +392,40 @@ static int at91sam9261ek_devices_init(void)
dev_add_bb_dev("env_raw1", "env1");
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- if (machine_is_at91sam9g10ek())
- armlinux_set_architecture(MACH_TYPE_AT91SAM9G10EK);
- else
- armlinux_set_architecture(MACH_TYPE_AT91SAM9261EK);
return 0;
}
-device_initcall(at91sam9261ek_devices_init);
-
static int at91sam9261ek_console_init(void)
{
- if (machine_is_at91sam9g10ek()) {
- barebox_set_model("Atmel at91sam9g10-ek");
+ if (machine_is_at91sam9g10ek())
barebox_set_hostname("at91sam9g10-ek");
- } else {
- barebox_set_model("Atmel at91sam9261-ek");
+ else
barebox_set_hostname("at91sam9261-ek");
- }
at91_register_uart(0, 0);
return 0;
}
-console_initcall(at91sam9261ek_console_init);
-
static int at91sam9261ek_main_clock(void)
{
at91_initialize(18432000);
+
+ if (cpu_is_at91sam9g10())
+ arm_set_machine(MACH_TYPE_AT91SAM9G10EK);
+ else
+ arm_set_machine(MACH_TYPE_AT91SAM9261EK);
+
return 0;
}
pure_initcall(at91sam9261ek_main_clock);
+
+MACHINE_START(AT91SAM9261EK, "Atmel at91sam9261-ek")
+ .console_init = at91sam9261ek_console_init,
+ .device_init = at91sam9261ek_devices_init,
+MACHINE_END
+
+MACHINE_START(AT91SAM9G10EK, "Atmel at91sam9g10-ek")
+ .console_init = at91sam9261ek_devices_init,
+ .device_init = at91sam9261ek_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/at91sam9263ek/init.c b/arch/arm/boards/at91sam9263ek/init.c
index 7011a94..626dafb 100644
--- a/arch/arm/boards/at91sam9263ek/init.c
+++ b/arch/arm/boards/at91sam9263ek/init.c
@@ -21,6 +21,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>
@@ -271,27 +272,26 @@ static int at91sam9263ek_devices_init(void)
}
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- armlinux_set_architecture(MACH_TYPE_AT91SAM9263EK);
return 0;
}
-device_initcall(at91sam9263ek_devices_init);
-
static int at91sam9263ek_console_init(void)
{
- barebox_set_model("Atmel at91sam9263-ek");
barebox_set_hostname("at91sam9263-ek");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(at91sam9263ek_console_init);
-
static int at91sam9263ek_main_clock(void)
{
at91_initialize(16367660);
return 0;
}
-pure_initcall(at91sam9263ek_main_clock);
+
+MACHINE_START(AT91SAM9263EK, "Atmel at91sam9263-ek")
+ .pure_init = at91sam9263ek_main_clock,
+ .console_init = at91sam9263ek_console_init,
+ .device_init = at91sam9263ek_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/at91sam9m10g45ek/init.c b/arch/arm/boards/at91sam9m10g45ek/init.c
index 0eb0f44..3cedfd8 100644
--- a/arch/arm/boards/at91sam9m10g45ek/init.c
+++ b/arch/arm/boards/at91sam9m10g45ek/init.c
@@ -23,6 +23,7 @@
#include <gpio.h>
#include <environment.h>
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <partition.h>
#include <fs.h>
@@ -317,26 +318,27 @@ static int at91sam9m10g45ek_devices_init(void)
dev_add_bb_dev("env_raw1", "env1");
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_6 + 0x100));
- armlinux_set_architecture(MACH_TYPE_AT91SAM9M10G45EK);
ek_set_board_revision();
return 0;
}
-device_initcall(at91sam9m10g45ek_devices_init);
static int at91sam9m10g45ek_console_init(void)
{
- barebox_set_model("Atmel at91sam9m10g45-ek");
barebox_set_hostname("at91sam9m10g45-ek");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(at91sam9m10g45ek_console_init);
static int at91sam9m10g45ek_main_clock(void)
{
at91_initialize(12000000);
return 0;
}
-pure_initcall(at91sam9m10g45ek_main_clock);
+
+MACHINE_START(AT91SAM9M10G45EK, "Atmel at91sam9m10g45-ek")
+ .pure_init = at91sam9m10g45ek_main_clock,
+ .console_init = at91sam9m10g45ek_console_init,
+ .device_init = at91sam9m10g45ek_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/at91sam9m10ihd/init.c b/arch/arm/boards/at91sam9m10ihd/init.c
index 0452366..7f33314 100644
--- a/arch/arm/boards/at91sam9m10ihd/init.c
+++ b/arch/arm/boards/at91sam9m10ihd/init.c
@@ -10,6 +10,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>
@@ -271,29 +272,30 @@ static int at91sam9m10ihd_devices_init(void)
dev_add_bb_dev("env_raw1", "env1");
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_6 + 0x100));
- /*
- * The internal Atmel kernel use the SAM9M10G45EK machine id
- * The mainline use DT
- */
- armlinux_set_architecture(MACH_TYPE_AT91SAM9M10G45EK);
return 0;
}
-device_initcall(at91sam9m10ihd_devices_init);
static int at91sam9m10ihd_console_init(void)
{
- barebox_set_model("Atmel at91sam9m10ihd");
barebox_set_hostname("at91sam9m10ihd");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(at91sam9m10ihd_console_init);
static int at91sam9m10ihd_main_clock(void)
{
at91_initialize(12000000);
return 0;
}
-pure_initcall(at91sam9m10ihd_main_clock);
+
+/*
+ * The internal Atmel kernel use the SAM9M10G45EK machine id
+ * The mainline use DT
+ */
+MACHINE_START(AT91SAM9M10G45EK, "Atmel at91sam9m10ihd")
+ .pure_init = at91sam9m10ihd_main_clock,
+ .console_init = at91sam9m10ihd_console_init,
+ .device_init = at91sam9m10ihd_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/at91sam9n12ek/init.c b/arch/arm/boards/at91sam9n12ek/init.c
index eb21c51..dcd6bac 100644
--- a/arch/arm/boards/at91sam9n12ek/init.c
+++ b/arch/arm/boards/at91sam9n12ek/init.c
@@ -20,6 +20,7 @@
#include <environment.h>
#include <fec.h>
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <partition.h>
#include <fs.h>
@@ -317,7 +318,6 @@ static int at91sam9n12ek_devices_init(void)
ek_add_device_lcdc();
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- armlinux_set_architecture(CONFIG_MACH_AT91SAM9N12EK);
devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
@@ -330,21 +330,23 @@ static int at91sam9n12ek_devices_init(void)
return 0;
}
-device_initcall(at91sam9n12ek_devices_init);
static int at91sam9n12ek_console_init(void)
{
- barebox_set_model("Atmel at91sam9n12-ek");
barebox_set_hostname("at91sam9n12-ek");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(at91sam9n12ek_console_init);
static int at91sam9n12ek_main_clock(void)
{
at91_initialize(16000000);
return 0;
}
-pure_initcall(at91sam9n12ek_main_clock);
+
+MACHINE_START(AT91SAM9N12EK, "Atmel at91sam9n12-ek")
+ .pure_init = at91sam9n12ek_main_clock,
+ .console_init = at91sam9n12ek_console_init,
+ .device_init = at91sam9n12ek_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index e41cd53..bd4000d 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -20,6 +20,7 @@
#include <environment.h>
#include <fec.h>
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <partition.h>
#include <fs.h>
@@ -310,7 +311,6 @@ static int at91sam9x5ek_devices_init(void)
ek_add_device_lcdc();
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- armlinux_set_architecture(CONFIG_MACH_AT91SAM9X5EK);
devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
@@ -323,22 +323,24 @@ static int at91sam9x5ek_devices_init(void)
return 0;
}
-device_initcall(at91sam9x5ek_devices_init);
static int at91sam9x5ek_console_init(void)
{
- barebox_set_model("Atmel at91sam9x5-ek");
barebox_set_hostname("at91sam9x5-ek");
at91_register_uart(0, 0);
at91_register_uart(1, 0);
return 0;
}
-console_initcall(at91sam9x5ek_console_init);
static int at91sam9x5ek_main_clock(void)
{
at91_initialize(12000000);
return 0;
}
-pure_initcall(at91sam9x5ek_main_clock);
+
+MACHINE_START(AT91SAM9X5EK, "Atmel at91sam9x5-ek")
+ .pure_init = at91sam9x5ek_main_clock,
+ .console_init = at91sam9x5ek_console_init,
+ .device_init = at91sam9x5ek_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/dss11/init.c b/arch/arm/boards/dss11/init.c
index 1c76d4f..4ddefea 100644
--- a/arch/arm/boards/dss11/init.c
+++ b/arch/arm/boards/dss11/init.c
@@ -19,6 +19,7 @@
#include <environment.h>
#include <fec.h>
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <partition.h>
#include <fs.h>
@@ -140,7 +141,6 @@ static int dss11_devices_init(void)
at91_add_device_usbh_ohci(&dss11_usbh_data);
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- armlinux_set_architecture(MACH_TYPE_DSS11);
devfs_add_partition("nand0", 0x00000, 0x20000, DEVFS_PARTITION_FIXED, "bootstrap");
dev_add_bb_dev("bootstrap", "bootstrap.bb");
@@ -151,21 +151,23 @@ static int dss11_devices_init(void)
return 0;
}
-device_initcall(dss11_devices_init);
static int dss11_console_init(void)
{
- barebox_set_model("Aizo dSS11");
barebox_set_hostname("dss11");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(dss11_console_init);
static int dss11_main_clock(void)
{
at91_initialize(18432000);
return 0;
}
-pure_initcall(dss11_main_clock);
+
+MACHINE_START(DSS11, "Aizo dSS11")
+ .pure_init = dss11_main_clock,
+ .console_init = dss11_console_init,
+ .device_init = dss11_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/mmccpu/init.c b/arch/arm/boards/mmccpu/init.c
index d13ef50..879d01b 100644
--- a/arch/arm/boards/mmccpu/init.c
+++ b/arch/arm/boards/mmccpu/init.c
@@ -21,6 +21,7 @@
#include <fec.h>
#include <gpio.h>
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <partition.h>
#include <fs.h>
@@ -64,27 +65,26 @@ static int mmccpu_devices_init(void)
devfs_add_partition("nor0", 0x40000, 128 * 1024, DEVFS_PARTITION_FIXED, "env0");
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- armlinux_set_architecture(MACH_TYPE_MMCCPU);
return 0;
}
-device_initcall(mmccpu_devices_init);
-
static int mmccpu_console_init(void)
{
- barebox_set_model("Bucyrus MMC-CPU");
barebox_set_hostname("mmccpu");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(mmccpu_console_init);
-
static int mmccpu_main_clock(void)
{
at91_initialize(18432000);
return 0;
}
-pure_initcall(mmccpu_main_clock);
+
+MACHINE_START(MMCCPU, "Bucyrus MMC-CPU")
+ .pure_init = mmccpu_main_clock,
+ .console_init = mmccpu_console_init,
+ .device_init = mmccpu_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/pm9261/init.c b/arch/arm/boards/pm9261/init.c
index cced419..58604c5 100644
--- a/arch/arm/boards/pm9261/init.c
+++ b/arch/arm/boards/pm9261/init.c
@@ -22,6 +22,7 @@
#include <gpio.h>
#include <environment.h>
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <partition.h>
#include <fs.h>
@@ -150,25 +151,26 @@ static int pm9261_devices_init(void)
devfs_add_partition("nor0", 0x40000, 0x10000, DEVFS_PARTITION_FIXED, "env0");
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- armlinux_set_architecture(MACH_TYPE_PM9261);
return 0;
}
-device_initcall(pm9261_devices_init);
static int pm9261_console_init(void)
{
- barebox_set_model("Ronetix PM9261");
barebox_set_hostname("pm9261");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(pm9261_console_init);
static int pm9261_main_clock(void)
{
at91_initialize(18432000);
return 0;
}
-pure_initcall(pm9261_main_clock);
+
+MACHINE_START(PM9261, "Ronetix PM9261")
+ .pure_init = pm9261_main_clock,
+ .console_init = pm9261_console_init,
+ .device_init = pm9261_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/pm9263/init.c b/arch/arm/boards/pm9263/init.c
index 78ec9ce..02fc5a4 100644
--- a/arch/arm/boards/pm9263/init.c
+++ b/arch/arm/boards/pm9263/init.c
@@ -22,6 +22,7 @@
#include <environment.h>
#include <fec.h>
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <partition.h>
#include <fs.h>
@@ -133,27 +134,26 @@ static int pm9263_devices_init(void)
devfs_add_partition("nor0", 0x40000, 0x10000, DEVFS_PARTITION_FIXED, "env0");
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- armlinux_set_architecture(MACH_TYPE_PM9263);
return 0;
}
-device_initcall(pm9263_devices_init);
-
static int pm9263_console_init(void)
{
- barebox_set_model("Ronetix PM9263");
barebox_set_hostname("pm9263");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(pm9263_console_init);
-
static int pm9263_main_clock(void)
{
at91_initialize(18432000);
return 0;
}
-pure_initcall(pm9263_main_clock);
+
+MACHINE_START(PM9263, "Ronetix PM9263")
+ .pure_init = pm9263_main_clock,
+ .console_init = pm9263_console_init,
+ .device_init = pm9263_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/pm9g45/init.c b/arch/arm/boards/pm9g45/init.c
index caeec43..ea29409 100644
--- a/arch/arm/boards/pm9g45/init.c
+++ b/arch/arm/boards/pm9g45/init.c
@@ -21,6 +21,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>
@@ -162,25 +163,26 @@ static int pm9g45_devices_init(void)
dev_add_bb_dev("env_raw", "env0");
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_6 + 0x100));
- armlinux_set_architecture(MACH_TYPE_PM9G45);
return 0;
}
-device_initcall(pm9g45_devices_init);
static int pm9g45_console_init(void)
{
- barebox_set_model("Ronetix PM9G45");
barebox_set_hostname("pm9g45");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(pm9g45_console_init);
static int pm9g45_main_clock(void)
{
at91_initialize(12000000);
return 0;
}
-pure_initcall(pm9g45_main_clock);
+
+MACHINE_START(PM9G45, "Ronetix PM9G45")
+ .pure_init = pm9g45_main_clock,
+ .console_init = pm9g45_console_init,
+ .device_init = pm9g45_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/qil-a926x/init.c b/arch/arm/boards/qil-a926x/init.c
index 3ec7dba..a745029 100644
--- a/arch/arm/boards/qil-a926x/init.c
+++ b/arch/arm/boards/qil-a926x/init.c
@@ -10,6 +10,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>
@@ -22,6 +23,7 @@
#include <linux/clk.h>
#include <mach/board.h>
#include <mach/at91sam9_smc.h>
+#include <mach/cpu.h>
#include <gpio.h>
#include <led.h>
#include <mach/io.h>
@@ -29,14 +31,6 @@
#include <mach/at91_pmc.h>
#include <mach/at91_rstc.h>
-static void qil_a9260_set_board_type(void)
-{
- if (machine_is_qil_a9g20())
- armlinux_set_architecture(MACH_TYPE_QIL_A9G20);
- else
- armlinux_set_architecture(MACH_TYPE_QIL_A9260);
-}
-
static struct atmel_nand_data nand_pdata = {
.ale = 21,
.cle = 22,
@@ -204,7 +198,6 @@ static int qil_a9260_devices_init(void)
qil_a9260_add_device_mb();
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- qil_a9260_set_board_type();
devfs_add_partition("nand0", 0x00000, SZ_128K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
@@ -217,10 +210,8 @@ static int qil_a9260_devices_init(void)
return 0;
}
-device_initcall(qil_a9260_devices_init);
-#ifdef CONFIG_CALAO_MB_QIL_A9260
-static int qil_a9260_console_init(void)
+static int qil_a9260_uart_init(void)
{
at91_register_uart(0, 0);
at91_set_A_periph(AT91_PIN_PB14, 1); /* Enable pull-up on DRXD */
@@ -237,20 +228,39 @@ static int qil_a9260_console_init(void)
return 0;
}
-console_initcall(qil_a9260_console_init);
-#endif
-static int qil_a9260_main_clock(void)
+static int qil_a9260_console_init(void)
{
- if (machine_is_qil_a9g20()) {
- barebox_set_model("Calao QIL-a9G20");
+ if (IS_ENABLED(CONFIG_CALAO_MB_QIL_A9260))
+ qil_a9260_uart_init();
+
+ if (machine_is_tny_a9g20())
barebox_set_hostname("qil-a9g20");
- } else {
- barebox_set_model("Calao QIL-A9260");
+ else
barebox_set_hostname("qil-a9260");
- }
+ return 0;
+}
+
+static int qil_a9260_main_clock(void)
+{
at91_initialize(12000000);
+
+ if (cpu_is_at91sam9g20())
+ arm_set_machine(MACH_TYPE_QIL_A9G20);
+ else
+ arm_set_machine(MACH_TYPE_QIL_A9260);
+
return 0;
}
pure_initcall(qil_a9260_main_clock);
+
+MACHINE_START(QIL_A9260, "Calao QIL-A9260")
+ .console_init = qil_a9260_console_init,
+ .device_init = qil_a9260_devices_init,
+MACHINE_END
+
+MACHINE_START(QIL_A9G20, "Calao QIL-A9G20")
+ .console_init = qil_a9260_console_init,
+ .device_init = qil_a9260_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/sama5d3xek/init.c b/arch/arm/boards/sama5d3xek/init.c
index 312b319..3522a45 100644
--- a/arch/arm/boards/sama5d3xek/init.c
+++ b/arch/arm/boards/sama5d3xek/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>
@@ -424,22 +425,30 @@ static int at91sama5d3xek_devices_init(void)
return 0;
}
-device_initcall(at91sama5d3xek_devices_init);
static int at91sama5d3xek_console_init(void)
{
- barebox_set_model("Atmel sama5d3x-ek");
barebox_set_hostname("sama5d3x-ek");
at91_register_uart(0, 0);
at91_register_uart(2, 0);
return 0;
}
-console_initcall(at91sama5d3xek_console_init);
static int at91sama5d3xek_main_clock(void)
{
at91_initialize(12000000);
return 0;
}
-pure_initcall(at91sama5d3xek_main_clock);
+
+static const char *atmel_sama5d3xmb_compat[] = {
+ "atmel,sama5d3xmb",
+ NULL
+};
+
+DT_MACHINE_START(atmel_sama5d3xmb, "Atmel sama5d3x-ek")
+ .pure_init = at91sama5d3xek_main_clock,
+ .console_init = at91sama5d3xek_console_init,
+ .device_init = at91sama5d3xek_devices_init,
+ .dt_compat = atmel_sama5d3xmb_compat,
+MACHINE_END
diff --git a/arch/arm/boards/telit-evk-pro3/init.c b/arch/arm/boards/telit-evk-pro3/init.c
index c077d3f..bf121c2 100644
--- a/arch/arm/boards/telit-evk-pro3/init.c
+++ b/arch/arm/boards/telit-evk-pro3/init.c
@@ -14,6 +14,7 @@
*/
#include <asm/armlinux.h>
+#include <asm/mach/arch.h>
#include <common.h>
#include <gpio.h>
#include <init.h>
@@ -167,21 +168,29 @@ static int evk_devices_init(void)
return 0;
}
-device_initcall(evk_devices_init);
static int evk_console_init(void)
{
- barebox_set_model("Telit EVK-PRO3");
barebox_set_hostname("evkpr03");
at91_register_uart(0, 0);
return 0;
}
-console_initcall(evk_console_init);
static int evk_main_clock(void)
{
at91_initialize(6000000);
return 0;
}
-pure_initcall(evk_main_clock);
+
+static const char *telit_evk_pro3b_compat[] = {
+ "telit,evk-pro3",
+ NULL
+};
+
+DT_MACHINE_START(telit_evk_pro3b, "Telit EVK-PRO3")
+ .pure_init = evk_main_clock,
+ .console_init = evk_console_init,
+ .device_init = evk_devices_init,
+ .dt_compat = telit_evk_pro3b_compat,
+MACHINE_END
diff --git a/arch/arm/boards/tny-a926x/init.c b/arch/arm/boards/tny-a926x/init.c
index 91ee82e..b7ccf34 100644
--- a/arch/arm/boards/tny-a926x/init.c
+++ b/arch/arm/boards/tny-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 <mach/io.h>
#include <mach/iomux.h>
@@ -39,16 +41,6 @@
#include <mach/at91_rstc.h>
#include <spi/eeprom.h>
-static void tny_a9260_set_board_type(void)
-{
- if (machine_is_tny_a9g20())
- armlinux_set_architecture(MACH_TYPE_TNY_A9G20);
- else if (machine_is_tny_a9263())
- armlinux_set_architecture(MACH_TYPE_TNY_A9263);
- else
- armlinux_set_architecture(MACH_TYPE_TNY_A9260);
-}
-
static struct atmel_nand_data nand_pdata = {
.ale = 21,
.cle = 22,
@@ -230,7 +222,6 @@ static int tny_a9260_devices_init(void)
ek_add_device_spi();
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- tny_a9260_set_board_type();
devfs_add_partition("nand0", 0x00000, SZ_128K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
@@ -243,31 +234,48 @@ static int tny_a9260_devices_init(void)
return 0;
}
-device_initcall(tny_a9260_devices_init);
static int tny_a9260_console_init(void)
{
- if (machine_is_tny_a9g20()) {
- barebox_set_model("Calao TNY-A9G20");
+ if (machine_is_tny_a9g20())
barebox_set_hostname("tny-a9g20");
- } else if (machine_is_tny_a9263()) {
- barebox_set_model("Calao TNY-A9263");
+ else if (machine_is_tny_a9263())
barebox_set_hostname("tny-a9263");
- } else {
- barebox_set_model("Calao TNY-A9260");
+ else
barebox_set_hostname("tny-a9260");
- }
at91_register_uart(0, 0);
if (IS_ENABLED(CONFIG_CALAO_MOB_TNY_MD2))
at91_register_uart(2, ATMEL_UART_CTS | ATMEL_UART_RTS);
return 0;
}
-console_initcall(tny_a9260_console_init);
static int tny_a9260_main_clock(void)
{
at91_initialize(12000000);
+
+ if (cpu_is_at91sam9g20())
+ arm_set_machine(MACH_TYPE_TNY_A9G20);
+ else if (cpu_is_at91sam9263())
+ arm_set_machine(MACH_TYPE_TNY_A9263);
+ else
+ arm_set_machine(MACH_TYPE_TNY_A9260);
+
return 0;
}
pure_initcall(tny_a9260_main_clock);
+
+MACHINE_START(TNY_A9260, "Calao TNY-A9260")
+ .console_init = tny_a9260_console_init,
+ .device_init = tny_a9260_devices_init,
+MACHINE_END
+
+MACHINE_START(TNY_A9263, "Calao TNY-A9263")
+ .console_init = tny_a9260_console_init,
+ .device_init = tny_a9260_devices_init,
+MACHINE_END
+
+MACHINE_START(TNY_A9G20, "Calao TNY-A9G20")
+ .console_init = tny_a9260_console_init,
+ .device_init = tny_a9260_devices_init,
+MACHINE_END
diff --git a/arch/arm/boards/usb-a926x/init.c b/arch/arm/boards/usb-a926x/init.c
index f1046ae..46e2fea 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>
@@ -42,16 +44,6 @@
#include <readkey.h>
#include <spi/spi.h>
-static void usb_a9260_set_board_type(void)
-{
- if (machine_is_usb_a9g20())
- armlinux_set_architecture(MACH_TYPE_USB_A9G20);
- else if (machine_is_usb_a9263())
- armlinux_set_architecture(MACH_TYPE_USB_A9263);
- else
- armlinux_set_architecture(MACH_TYPE_USB_A9260);
-}
-
#if defined(CONFIG_NAND_ATMEL)
static struct atmel_nand_data nand_pdata = {
.ale = 21,
@@ -404,7 +396,6 @@ static int usb_a9260_devices_init(void)
usb_a9260_device_dab_mmx();
armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
- usb_a9260_set_board_type();
devfs_add_partition("nand0", 0x00000, SZ_128K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
@@ -417,23 +408,18 @@ static int usb_a9260_devices_init(void)
return 0;
}
-device_initcall(usb_a9260_devices_init);
#ifndef CONFIG_CONSOLE_NONE
static int usb_a9260_console_init(void)
{
struct device_d *dev;
- if (machine_is_usb_a9260()) {
- barebox_set_model("Calao USB-A9260");
+ if (machine_is_usb_a9260())
barebox_set_hostname("usb-a9260");
- } else if (machine_is_usb_a9g20()) {
- barebox_set_model("Calao USB-A9G20");
+ else if (machine_is_usb_a9g20())
barebox_set_hostname("usb-a9g20");
- } else {
- barebox_set_model("Calao USB-A9263");
+ else
barebox_set_hostname("usb-a9263");
- }
at91_register_uart(0, 0);
@@ -446,12 +432,36 @@ static int usb_a9260_console_init(void)
return 0;
}
-console_initcall(usb_a9260_console_init);
+#else
+#define usb_a9260_console_init NULL
#endif
static int usb_a9260_main_clock(void)
{
at91_initialize(12000000);
+
+ 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;
}
pure_initcall(usb_a9260_main_clock);
+
+MACHINE_START(USB_A9260, "Calao USB-A9260")
+ .console_init = usb_a9260_console_init,
+ .device_init = usb_a9260_devices_init,
+MACHINE_END
+
+MACHINE_START(USB_A9263, "Calao USB-A9263")
+ .console_init = usb_a9260_console_init,
+ .device_init = usb_a9260_devices_init,
+MACHINE_END
+
+MACHINE_START(USB_A9G20, "Calao USB-A9G20")
+ .console_init = usb_a9260_console_init,
+ .device_init = 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] 13+ messages in thread
* [PATCH 6/6] vexpress: switch to machine description
2013-11-28 18:06 ` [PATCH 1/6] arm: gen-mach-types: add MAX_MACH_TYPE Jean-Christophe PLAGNIOL-VILLARD
` (3 preceding siblings ...)
2013-11-28 18:06 ` [PATCH 5/6] AT91: switch to machine description Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-28 18:06 ` Jean-Christophe PLAGNIOL-VILLARD
4 siblings, 0 replies; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-28 18:06 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/vexpress/init.c | 134 ++++++++++++++++++++++------------------
1 file changed, 73 insertions(+), 61 deletions(-)
diff --git a/arch/arm/boards/vexpress/init.c b/arch/arm/boards/vexpress/init.c
index 6196c4e..f861d48 100644
--- a/arch/arm/boards/vexpress/init.c
+++ b/arch/arm/boards/vexpress/init.c
@@ -8,6 +8,7 @@
#include <init.h>
#include <asm/armlinux.h>
#include <asm/system_info.h>
+#include <asm/mach/arch.h>
#include <generated/mach-types.h>
#include <mach/devices.h>
#include <environment.h>
@@ -18,59 +19,55 @@
#include <linux/amba/sp804.h>
#include <mci.h>
-struct vexpress_init {
- void (*core_init)(void);
- void (*mem_init)(void);
- void (*console_init)(void);
- void (*devices_init)(void);
-};
-
struct mmci_platform_data mmci_plat = {
.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
.clkdiv_init = SDI_CLKCR_CLKDIV_INIT,
};
-struct vexpress_init *v2m_init;
-
-static void vexpress_ax_mem_init(void)
+static int vexpress_ax_mem_init(void)
{
vexpress_add_ddram(SZ_512M);
+
+ return 0;
}
#define V2M_SYS_FLASH 0x03c
-static void vexpress_ax_devices_init(void)
+static int vexpress_ax_devices_init(void)
{
+ writel(1, v2m_sysreg_base + V2M_SYS_FLASH);
+
add_cfi_flash_device(0, 0x08000000, SZ_64M, 0);
add_cfi_flash_device(1, 0x0c000000, SZ_64M, 0);
vexpress_register_mmc(&mmci_plat);
add_generic_device("smc911x", DEVICE_ID_DYNAMIC, NULL, 0x1a000000,
64 * 1024, IORESOURCE_MEM, NULL);
armlinux_set_bootparams((void *)(0x80000100));
+
+ return 0;
}
-static void vexpress_ax_console_init(void)
+static int vexpress_ax_console_init(void)
{
vexpress_register_uart(0);
vexpress_register_uart(1);
vexpress_register_uart(2);
vexpress_register_uart(3);
-}
-struct vexpress_init vexpress_init_ax = {
- .core_init = vexpress_init,
- .mem_init = vexpress_ax_mem_init,
- .console_init = vexpress_ax_console_init,
- .devices_init = vexpress_ax_devices_init,
-};
+ return 0;
+}
-static void vexpress_a9_legacy_mem_init(void)
+static int vexpress_a9_legacy_mem_init(void)
{
vexpress_a9_legacy_add_ddram(SZ_512M, SZ_512M);
+
+ return 0;
}
-static void vexpress_a9_legacy_devices_init(void)
+static int vexpress_a9_legacy_devices_init(void)
{
+ writel(1, v2m_sysreg_base + V2M_SYS_FLASH);
+
add_cfi_flash_device(0, 0x40000000, SZ_64M, 0);
add_cfi_flash_device(1, 0x44000000, SZ_64M, 0);
add_generic_device("smc911x", DEVICE_ID_DYNAMIC, NULL, 0x4e000000,
@@ -78,75 +75,90 @@ static void vexpress_a9_legacy_devices_init(void)
vexpress_a9_legacy_register_mmc(&mmci_plat);
armlinux_set_architecture(MACH_TYPE_VEXPRESS);
armlinux_set_bootparams((void *)(0x60000100));
+
+ return 0;
}
-static void vexpress_a9_legacy_console_init(void)
+static int vexpress_a9_legacy_console_init(void)
{
vexpress_a9_legacy_register_uart(0);
vexpress_a9_legacy_register_uart(1);
vexpress_a9_legacy_register_uart(2);
vexpress_a9_legacy_register_uart(3);
-}
-
-struct vexpress_init vexpress_init_a9_legacy = {
- .core_init = vexpress_a9_legacy_init,
- .mem_init = vexpress_a9_legacy_mem_init,
- .console_init = vexpress_a9_legacy_console_init,
- .devices_init = vexpress_a9_legacy_devices_init,
-};
-
-static int vexpress_mem_init(void)
-{
- v2m_init->mem_init();
return 0;
}
-mem_initcall(vexpress_mem_init);
static int vexpress_devices_init(void)
{
- writel(1, v2m_sysreg_base + V2M_SYS_FLASH);
- v2m_init->devices_init();
-
devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self");
devfs_add_partition("nor0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
return 0;
}
-device_initcall(vexpress_devices_init);
-static int vexpress_console_init(void)
+static int vexpress_a9_legacy_core_init(void)
{
- v2m_init->console_init();
+ barebox_set_hostname("vexpress-a9-legacy");
+
+ vexpress_a9_legacy_init();
return 0;
}
-console_initcall(vexpress_console_init);
-static int vexpress_core_init(void)
+static int vexpress_ax_core_init(void)
{
char *hostname = "vexpress-unknown";
- if (amba_is_arm_sp804(IOMEM(0x10011000))) {
- v2m_init = &vexpress_init_a9_legacy;
- hostname = "vexpress-a9-legacy";
- } else {
- v2m_init = &vexpress_init_ax;
- if (cpu_is_cortex_a5())
- hostname = "vexpress-a5";
- else if (cpu_is_cortex_a7())
- hostname = "vexpress-a7";
- else if (cpu_is_cortex_a9())
- hostname = "vexpress-a9";
- else if (cpu_is_cortex_a15())
- hostname = "vexpress-a15";
- }
-
- barebox_set_model("ARM Vexpress");
+ if (cpu_is_cortex_a5())
+ hostname = "vexpress-a5";
+ else if (cpu_is_cortex_a7())
+ hostname = "vexpress-a7";
+ else if (cpu_is_cortex_a9())
+ hostname = "vexpress-a9";
+ else if (cpu_is_cortex_a15())
+ hostname = "vexpress-a15";
+
barebox_set_hostname(hostname);
- v2m_init->core_init();
+ vexpress_init();
return 0;
}
-postcore_initcall(vexpress_core_init);
+
+static int vexpress_pure_init(void)
+{
+ if (amba_is_arm_sp804(IOMEM(0x10011000)))
+ return arm_set_dt_machine("arm,vexpress-a9-legacy");
+ else
+ return arm_set_dt_machine("arm,vexpress");
+}
+pure_initcall(vexpress_pure_init);
+
+static const char *arm_vexpress_a9_legacy_compat[] = {
+ "arm,vexpress-a9-legacy",
+ NULL
+};
+
+static const char *arm_vexpress_compat[] = {
+ "arm,vexpress",
+ NULL
+};
+
+DT_MACHINE_START(arm_vexpress_a9_legacy, "ARM Vexpress A9 Legacy")
+ .postcore_init = vexpress_a9_legacy_core_init,
+ .console_init = vexpress_a9_legacy_console_init,
+ .mem_init = vexpress_a9_legacy_mem_init,
+ .coredevice_init = vexpress_a9_legacy_devices_init,
+ .device_init = vexpress_devices_init,
+ .dt_compat = arm_vexpress_a9_legacy_compat,
+MACHINE_END
+
+DT_MACHINE_START(arm_vexpress, "ARM Vexpress")
+ .postcore_init = vexpress_ax_core_init,
+ .console_init = vexpress_ax_console_init,
+ .mem_init = vexpress_ax_mem_init,
+ .coredevice_init = vexpress_ax_devices_init,
+ .device_init = vexpress_devices_init,
+ .dt_compat = arm_vexpress_compat,
+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] 13+ messages in thread
* Re: [PATCH 2/6] ARM: introduce machine description
2013-11-28 18:06 ` [PATCH 2/6] ARM: introduce machine description Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-28 18:19 ` Alexander Aring
2013-11-28 19:00 ` Jean-Christophe PLAGNIOL-VILLARD
2013-12-02 9:01 ` Sascha Hauer
1 sibling, 1 reply; 13+ messages in thread
From: Alexander Aring @ 2013-11-28 18:19 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
Hi,
there are only some little nitpicks... maybe not important.
On Thu, Nov 28, 2013 at 07:06:43PM +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 | 8 +-
> arch/arm/cpu/machine.c | 188 +++++++++++++++++++++++++++++++++++++
> arch/arm/include/asm/barebox-arm.h | 8 ++
> arch/arm/include/asm/mach/arch.h | 68 ++++++++++++++
> arch/arm/lib/barebox.lds.S | 6 ++
> 6 files changed, 277 insertions(+), 3 deletions(-)
> 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
...
> +
> +int is_dt_compatible(const struct machine_desc *m, const char* dt_compat)
> +{
> + const char *const *dtc = m->dt_compat;
const char *const *dtc? Looks like c ninja coding style :-D.
I think you mean:
const char **dtc = ...
> +
> + while (dtc) {
> + const char *s = *dtc;
> + if (dt_compat && !of_compat_cmp(s, dt_compat, strlen(dt_compat)))
> + return 1;
> + else if (of_machine_is_compatible(s))
> + return 1;
> + dtc++;
> + }
> +
> + return 0;
> +}
> +
> +int arm_set_dt_machine(const char* dt_compat)
> +{
> + const struct machine_desc *m;
> +
> + for_each_machine_desc(m) {
> + if (!is_dt_compatible(m, dt_compat))
> + continue;
> +
> + machine_desc = (const struct machine_desc *)m;
> + if (m->nr != ~0)
> + armlinux_set_architecture(m->nr);
> +
> + 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;
> + tmp = m;
> + }
> +
> + if (!tmp)
> + return;
> + machine_desc = (const struct machine_desc *)tmp;
> + armlinux_set_architecture(machine_desc->nr);
> +}
> +
> +#define arm_mach_xx_init(level) \
> +({ \
> + int __ret = 0; \
> + \
> + do { \
> + if (!machine_desc) \
> + break; \
> + \
> + if (machine_desc->level##_init) { \
> + __ret = machine_desc->level##_init(); \
> + if (__ret) \
> + break; \
> + } \
> + } while(0); \
> + __ret; \
> +})
> +
> +static int arm_mach_pure_init(void)
> +{
> + int ret = -EINVAL;
> +
> + if (__machine_arch_type != ~0 && __machine_arch_type < MAX_MACH_TYPE)
> + ret = arm_set_machine(__machine_arch_type);
> + if (ret)
> + arm_mach_only_one_machine();
> + of_arm_init();
> +
> + ret = arm_mach_xx_init(pure);
> +
> + return ret;
unnecessary assignment to ret.
- Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/6] ARM: introduce machine description
2013-11-28 18:19 ` Alexander Aring
@ 2013-11-28 19:00 ` Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 19:02 ` Alexander Aring
0 siblings, 1 reply; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-11-28 19:00 UTC (permalink / raw)
To: Alexander Aring; +Cc: barebox
On 19:19 Thu 28 Nov , Alexander Aring wrote:
> Hi,
>
> there are only some little nitpicks... maybe not important.
>
> On Thu, Nov 28, 2013 at 07:06:43PM +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 | 8 +-
> > arch/arm/cpu/machine.c | 188 +++++++++++++++++++++++++++++++++++++
> > arch/arm/include/asm/barebox-arm.h | 8 ++
> > arch/arm/include/asm/mach/arch.h | 68 ++++++++++++++
> > arch/arm/lib/barebox.lds.S | 6 ++
> > 6 files changed, 277 insertions(+), 3 deletions(-)
> > 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
> ...
> > +
> > +int is_dt_compatible(const struct machine_desc *m, const char* dt_compat)
> > +{
> > + const char *const *dtc = m->dt_compat;
> const char *const *dtc? Looks like c ninja coding style :-D.
>
> I think you mean:
>
> const char **dtc = ...
>
no I mean this one both pointer are const It's very specific
Best Regards,
J.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/6] ARM: introduce machine description
2013-11-28 19:00 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-11-28 19:02 ` Alexander Aring
0 siblings, 0 replies; 13+ messages in thread
From: Alexander Aring @ 2013-11-28 19:02 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
On Thu, Nov 28, 2013 at 08:00:43PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 19:19 Thu 28 Nov , Alexander Aring wrote:
> > Hi,
> >
> > there are only some little nitpicks... maybe not important.
> >
> > On Thu, Nov 28, 2013 at 07:06:43PM +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 | 8 +-
> > > arch/arm/cpu/machine.c | 188 +++++++++++++++++++++++++++++++++++++
> > > arch/arm/include/asm/barebox-arm.h | 8 ++
> > > arch/arm/include/asm/mach/arch.h | 68 ++++++++++++++
> > > arch/arm/lib/barebox.lds.S | 6 ++
> > > 6 files changed, 277 insertions(+), 3 deletions(-)
> > > 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
> > ...
> > > +
> > > +int is_dt_compatible(const struct machine_desc *m, const char* dt_compat)
> > > +{
> > > + const char *const *dtc = m->dt_compat;
> > const char *const *dtc? Looks like c ninja coding style :-D.
> >
> > I think you mean:
> >
> > const char **dtc = ...
> >
>
> no I mean this one both pointer are const It's very specific
>
ah, I understand. Thanks I will remember it.
- Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/6] ARM: introduce machine description
2013-11-28 18:06 ` [PATCH 2/6] ARM: introduce machine description Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:19 ` Alexander Aring
@ 2013-12-02 9:01 ` Sascha Hauer
2013-12-02 11:04 ` Jean-Christophe PLAGNIOL-VILLARD
1 sibling, 1 reply; 13+ messages in thread
From: Sascha Hauer @ 2013-12-02 9:01 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
On Thu, Nov 28, 2013 at 07:06:43PM +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 | 8 +-
> arch/arm/cpu/machine.c | 188 +++++++++++++++++++++++++++++++++++++
> arch/arm/include/asm/barebox-arm.h | 8 ++
> arch/arm/include/asm/mach/arch.h | 68 ++++++++++++++
> arch/arm/lib/barebox.lds.S | 6 ++
> 6 files changed, 277 insertions(+), 3 deletions(-)
> 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..ee7006e 100644
> --- a/arch/arm/cpu/dtb.c
> +++ b/arch/arm/cpu/dtb.c
> @@ -18,10 +18,11 @@
> #include <init.h>
> #include <of.h>
> #include <asm/barebox-arm.h>
> +#include <asm/mach/arch.h>
>
> extern char __dtb_start[];
>
> -static int of_arm_init(void)
> +int of_arm_init(void)
> {
> struct device_node *root;
> void *fdt;
> @@ -48,6 +49,10 @@ static int of_arm_init(void)
> }
>
> root = of_unflatten_dtb(NULL, fdt);
> +
> + if (arm_set_dt_machine(NULL))
> + pr_debug("No compatible machine found\n");
Why call this with NULL and not the compatible string found in the just
unflattened dt?
> +
> if (root) {
> of_set_root_node(root);
> if (IS_ENABLED(CONFIG_OFDEVICE))
> @@ -56,4 +61,3 @@ static int of_arm_init(void)
>
> return 0;
> }
> -core_initcall(of_arm_init);
> diff --git a/arch/arm/cpu/machine.c b/arch/arm/cpu/machine.c
> new file mode 100644
> index 0000000..ad0d8cb
> --- /dev/null
> +++ b/arch/arm/cpu/machine.c
> @@ -0,0 +1,188 @@
> +/*
> + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> + *
> + * Under GPLv2 Only
> + */
> +
> +#include <common.h>
> +#include <asm/mach/arch.h>
> +#include <asm/barebox-arm.h>
> +#include <asm/armlinux.h>
> +#include <generated/mach-types.h>
> +#include <init.h>
> +#include <string.h>
> +#include <debug_ll.h>
> +
> +const struct machine_desc *machine_desc;
> +unsigned int __machine_arch_type = ~0;
> +
> +int arm_set_machine(const unsigned int type)
> +{
> + const struct machine_desc *m;
> +
> + puts_ll("type ");
> + puthex_ll(type);
> + puts_ll("\n");
> +
> + if (type == ~0)
> + 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;
> + armlinux_set_architecture(__machine_arch_type);
> + return 0;
> + }
> + }
> +
> + return -ENOENT;
> +}
> +
> +int is_dt_compatible(const struct machine_desc *m, const char* dt_compat)
> +{
> + const char *const *dtc = m->dt_compat;
> +
> + while (dtc) {
> + const char *s = *dtc;
> + if (dt_compat && !of_compat_cmp(s, dt_compat, strlen(dt_compat)))
> + return 1;
> + else if (of_machine_is_compatible(s))
> + return 1;
> + dtc++;
> + }
> +
> + return 0;
> +}
> +
> +int arm_set_dt_machine(const char* dt_compat)
I don't really understand how this function behaves. It should set the
machine desc based on dt_compat, but seems to fall back to some other
mechanism when dt_compat is NULL. Looking at it this function is only
called with NULL argument in your code, so it seems like it depends on
of_machine_is_compatible(), but this can only return something valid
when the root_node has been set. You call arm_set_dt_machine() before
of_set_root_node() so this can't work.
Matching a machine_desc to a devicetree is more complicated. You can't
return the first match, but instead have to find the best match. If you
have multiple i.MX6 machines, then all will match to fsl,imx6. You have
to find the correct board though.
If you don't have a dt machine to test this on atm I think it's better
if you just drop dt support from this patchset.
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] 13+ messages in thread
* Re: [PATCH 2/6] ARM: introduce machine description
2013-12-02 9:01 ` Sascha Hauer
@ 2013-12-02 11:04 ` Jean-Christophe PLAGNIOL-VILLARD
2013-12-02 11:54 ` Sascha Hauer
0 siblings, 1 reply; 13+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-12-02 11:04 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On 10:01 Mon 02 Dec , Sascha Hauer wrote:
> On Thu, Nov 28, 2013 at 07:06:43PM +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 | 8 +-
> > arch/arm/cpu/machine.c | 188 +++++++++++++++++++++++++++++++++++++
> > arch/arm/include/asm/barebox-arm.h | 8 ++
> > arch/arm/include/asm/mach/arch.h | 68 ++++++++++++++
> > arch/arm/lib/barebox.lds.S | 6 ++
> > 6 files changed, 277 insertions(+), 3 deletions(-)
> > 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..ee7006e 100644
> > --- a/arch/arm/cpu/dtb.c
> > +++ b/arch/arm/cpu/dtb.c
> > @@ -18,10 +18,11 @@
> > #include <init.h>
> > #include <of.h>
> > #include <asm/barebox-arm.h>
> > +#include <asm/mach/arch.h>
> >
> > extern char __dtb_start[];
> >
> > -static int of_arm_init(void)
> > +int of_arm_init(void)
> > {
> > struct device_node *root;
> > void *fdt;
> > @@ -48,6 +49,10 @@ static int of_arm_init(void)
> > }
> >
> > root = of_unflatten_dtb(NULL, fdt);
> > +
> > + if (arm_set_dt_machine(NULL))
> > + pr_debug("No compatible machine found\n");
>
> Why call this with NULL and not the compatible string found in the just
> unflattened dt?
if NULL the code check for the compatible node
otherwise for a specific compatible passs as arg
>
> > +
> > if (root) {
> > of_set_root_node(root);
> > if (IS_ENABLED(CONFIG_OFDEVICE))
> > @@ -56,4 +61,3 @@ static int of_arm_init(void)
> >
> > return 0;
> > }
> > -core_initcall(of_arm_init);
> > diff --git a/arch/arm/cpu/machine.c b/arch/arm/cpu/machine.c
> > new file mode 100644
> > index 0000000..ad0d8cb
> > --- /dev/null
> > +++ b/arch/arm/cpu/machine.c
> > @@ -0,0 +1,188 @@
> > +/*
> > + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > + *
> > + * Under GPLv2 Only
> > + */
> > +
> > +#include <common.h>
> > +#include <asm/mach/arch.h>
> > +#include <asm/barebox-arm.h>
> > +#include <asm/armlinux.h>
> > +#include <generated/mach-types.h>
> > +#include <init.h>
> > +#include <string.h>
> > +#include <debug_ll.h>
> > +
> > +const struct machine_desc *machine_desc;
> > +unsigned int __machine_arch_type = ~0;
> > +
> > +int arm_set_machine(const unsigned int type)
> > +{
> > + const struct machine_desc *m;
> > +
> > + puts_ll("type ");
> > + puthex_ll(type);
> > + puts_ll("\n");
> > +
> > + if (type == ~0)
> > + 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;
> > + armlinux_set_architecture(__machine_arch_type);
> > + return 0;
> > + }
> > + }
> > +
> > + return -ENOENT;
> > +}
> > +
> > +int is_dt_compatible(const struct machine_desc *m, const char* dt_compat)
> > +{
> > + const char *const *dtc = m->dt_compat;
> > +
> > + while (dtc) {
> > + const char *s = *dtc;
> > + if (dt_compat && !of_compat_cmp(s, dt_compat, strlen(dt_compat)))
> > + return 1;
> > + else if (of_machine_is_compatible(s))
> > + return 1;
> > + dtc++;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +int arm_set_dt_machine(const char* dt_compat)
>
> I don't really understand how this function behaves. It should set the
> machine desc based on dt_compat, but seems to fall back to some other
> mechanism when dt_compat is NULL. Looking at it this function is only
simple 2 case
1 check the compatible node
1 check a specific comp if pas as arg
> called with NULL argument in your code, so it seems like it depends on
> of_machine_is_compatible(), but this can only return something valid
> when the root_node has been set. You call arm_set_dt_machine() before
> of_set_root_node() so this can't work.
>
> Matching a machine_desc to a devicetree is more complicated. You can't
> return the first match, but instead have to find the best match. If you
> have multiple i.MX6 machines, then all will match to fsl,imx6. You have
> to find the correct board though.
no they will have their own compatible in the DT_MACHINE_DESC
so fsl,imx6 execpt if all the board use the same c board file
as we have on the kernel for at91
>
> If you don't have a dt machine to test this on atm I think it's better
> if you just drop dt support from this patchset.
I test the function and use it on some at91 board
and it does work
>
> 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] 13+ messages in thread
* Re: [PATCH 2/6] ARM: introduce machine description
2013-12-02 11:04 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-12-02 11:54 ` Sascha Hauer
0 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-12-02 11:54 UTC (permalink / raw)
To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox
On Mon, Dec 02, 2013 at 12:04:52PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:01 Mon 02 Dec , Sascha Hauer wrote:
> > > struct device_node *root;
> > > void *fdt;
> > > @@ -48,6 +49,10 @@ static int of_arm_init(void)
> > > }
> > >
> > > root = of_unflatten_dtb(NULL, fdt);
> > > +
> > > + if (arm_set_dt_machine(NULL))
> > > + pr_debug("No compatible machine found\n");
> >
> > Why call this with NULL and not the compatible string found in the just
> > unflattened dt?
>
> if NULL the code check for the compatible node
>
> otherwise for a specific compatible passs as arg
As said, it can't work when you call arm_set_dt_machine() before
of_set_root_node() as you do here.
> > > +int is_dt_compatible(const struct machine_desc *m, const char* dt_compat)
> > > +{
> > > + const char *const *dtc = m->dt_compat;
> > > +
> > > + while (dtc) {
*dtc btw. dtc will always be true, at least until it wraps around 32bit.
> > > + const char *s = *dtc;
> > > + if (dt_compat && !of_compat_cmp(s, dt_compat, strlen(dt_compat)))
> > > + return 1;
> > > + else if (of_machine_is_compatible(s))
> > > + return 1;
> > > + dtc++;
> > > + }
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +int arm_set_dt_machine(const char* dt_compat)
> >
> > I don't really understand how this function behaves. It should set the
> > machine desc based on dt_compat, but seems to fall back to some other
> > mechanism when dt_compat is NULL. Looking at it this function is only
>
> simple 2 case
>
> 1 check the compatible node
>
> 1 check a specific comp if pas as arg
>
> > called with NULL argument in your code, so it seems like it depends on
> > of_machine_is_compatible(), but this can only return something valid
> > when the root_node has been set. You call arm_set_dt_machine() before
> > of_set_root_node() so this can't work.
> >
> > Matching a machine_desc to a devicetree is more complicated. You can't
> > return the first match, but instead have to find the best match. If you
> > have multiple i.MX6 machines, then all will match to fsl,imx6. You have
> > to find the correct board though.
>
> no they will have their own compatible in the DT_MACHINE_DESC
Look for example in a current kernel. The SH Mobile koelsch board has:
compatible = "renesas,koelsch", "renesas,r8a7791";
The kernel has a specific koelsch machine descriptor:
> static const char * const koelsch_boards_compat_dt[] __initconst = {
> "renesas,koelsch",
> NULL,
> };
>
> DT_MACHINE_START(KOELSCH_DT, "koelsch")
> .smp = smp_ops(r8a7791_smp_ops),
> .init_early = r8a7791_init_early,
> .init_machine = koelsch_add_standard_devices,
> .init_time = rcar_gen2_timer_init,
> .dt_compat = koelsch_boards_compat_dt,
> MACHINE_END
Additionally there is a generic SoC machine descriptor:
> static const char *r8a7791_boards_compat_dt[] __initdata = {
> "renesas,r8a7791",
> NULL,
> };
>
> DT_MACHINE_START(R8A7791_DT, "Generic R8A7791 (Flattened Device Tree)")
> .smp = smp_ops(r8a7791_smp_ops),
> .init_early = r8a7791_init_early,
> .init_time = rcar_gen2_timer_init,
> .dt_compat = r8a7791_boards_compat_dt,
> MACHINE_END
Now of course when you have a koelsch board and koelsch support compiled
in you want to match the renesas,koelsch machine entry and not the
renesas,r8a7791 entry.
The kernel does this with of_flat_dt_match_machine().
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] 13+ messages in thread
end of thread, other threads:[~2013-12-02 11:54 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-28 18:05 [PATCH 0/6] ARM: machine struct support Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 1/6] arm: gen-mach-types: add MAX_MACH_TYPE Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 2/6] ARM: introduce machine description Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:19 ` Alexander Aring
2013-11-28 19:00 ` Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 19:02 ` Alexander Aring
2013-12-02 9:01 ` Sascha Hauer
2013-12-02 11:04 ` Jean-Christophe PLAGNIOL-VILLARD
2013-12-02 11:54 ` Sascha Hauer
2013-11-28 18:06 ` [PATCH 3/6] ARM: introduce SoC description Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 4/6] AT91: detect SoC earlier Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 5/6] AT91: switch to machine description Jean-Christophe PLAGNIOL-VILLARD
2013-11-28 18:06 ` [PATCH 6/6] vexpress: " Jean-Christophe PLAGNIOL-VILLARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox