Re: [U-Boot] [PATCH V2 12/23] imx: mx8m: add soc related settings and files
Hi Stefano, On Thu, Dec 07, 2017 at 09:39:23AM +0100, Stefano Babic wrote: >Hi Peng, > >On 04/12/2017 05:31, Peng Fan wrote: >> Add SoC level initialization code >> - arch_cpu_init >> - mmu table >> - detect cpu revision >> - reset cpu and wdog settings >> - M4 boot >> - timer init >> - wdog settings >> - lowlevel init to save/restore registers >> - a few dummy header file to avoid build failure >> - ft_system_setup and ft_add_optee_node >> - mmc env related >> >> Signed-off-by: Peng Fan>> --- >> arch/arm/include/asm/arch-mx8m/crm_regs.h | 10 + >> arch/arm/include/asm/arch-mx8m/gpio.h | 12 + >> arch/arm/include/asm/arch-mx8m/sys_proto.h | 18 + >> arch/arm/mach-imx/Makefile | 1 + >> arch/arm/mach-imx/mx8m/Makefile| 3 +- >> arch/arm/mach-imx/mx8m/lowlevel_init.S | 63 >> arch/arm/mach-imx/mx8m/soc.c | 539 >> + >> 7 files changed, 645 insertions(+), 1 deletion(-) >> create mode 100644 arch/arm/include/asm/arch-mx8m/crm_regs.h >> create mode 100644 arch/arm/include/asm/arch-mx8m/gpio.h >> create mode 100644 arch/arm/include/asm/arch-mx8m/sys_proto.h >> create mode 100644 arch/arm/mach-imx/mx8m/lowlevel_init.S >> create mode 100644 arch/arm/mach-imx/mx8m/soc.c >> >> diff --git a/arch/arm/include/asm/arch-mx8m/crm_regs.h >> b/arch/arm/include/asm/arch-mx8m/crm_regs.h >> new file mode 100644 >> index 00..6582318983 >> --- /dev/null >> +++ b/arch/arm/include/asm/arch-mx8m/crm_regs.h >> @@ -0,0 +1,10 @@ >> +/* >> + * Copyright 2017 NXP >> + * >> + * SPDX-License-Identifier: GPL-2.0+ >> + */ >> + >> +#ifndef _ASM_ARCH_MX8M_CRM_REGS_H >> +#define _ASM_ARCH_MX8M_CRM_REGS_H >> +/* Dummy header, some imx-common code needs this file */ >> +#endif >> diff --git a/arch/arm/include/asm/arch-mx8m/gpio.h >> b/arch/arm/include/asm/arch-mx8m/gpio.h >> new file mode 100644 >> index 00..b666d37700 >> --- /dev/null >> +++ b/arch/arm/include/asm/arch-mx8m/gpio.h >> @@ -0,0 +1,12 @@ >> +/* >> + * Copyright 2017 NXP >> + * >> + * SPDX-License-Identifier: GPL-2.0+ >> + */ >> + >> +#ifndef __ASM_ARCH_MX8M_GPIO_H >> +#define __ASM_ARCH_MX8M_GPIO_H >> + >> +#include >> + >> +#endif >> diff --git a/arch/arm/include/asm/arch-mx8m/sys_proto.h >> b/arch/arm/include/asm/arch-mx8m/sys_proto.h >> new file mode 100644 >> index 00..8bf9ac6697 >> --- /dev/null >> +++ b/arch/arm/include/asm/arch-mx8m/sys_proto.h >> @@ -0,0 +1,18 @@ >> +/* >> + * Copyright (C) 2017 NXP >> + * >> + * SPDX-License-Identifier: GPL-2.0+ >> + */ >> + >> +#ifndef __ARCH_MX8M_SYS_PROTO_H >> +#define __ARCH_MX8M_SYS_PROTO_H >> + >> +#include >> + >> +void set_wdog_reset(struct wdog_regs *wdog); >> +void enable_tzc380(void); >> +void restore_boot_params(void); >> +extern unsigned long rom_pointer[]; >> +enum boot_device get_boot_device(void); >> +bool is_usb_boot(void); >> +#endif >> diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile >> index c807174363..27c154b8b3 100644 >> --- a/arch/arm/mach-imx/Makefile >> +++ b/arch/arm/mach-imx/Makefile >> @@ -127,4 +127,5 @@ obj-$(CONFIG_MX5) += mx5/ >> obj-$(CONFIG_MX6) += mx6/ >> obj-$(CONFIG_MX7) += mx7/ >> obj-$(CONFIG_ARCH_MX7ULP) += mx7ulp/ >> +obj-$(CONFIG_MX8M) += mx8m/ >> >> diff --git a/arch/arm/mach-imx/mx8m/Makefile >> b/arch/arm/mach-imx/mx8m/Makefile >> index 05f38842f0..b1c5d74aab 100644 >> --- a/arch/arm/mach-imx/mx8m/Makefile >> +++ b/arch/arm/mach-imx/mx8m/Makefile >> @@ -4,4 +4,5 @@ >> # SPDX-License-Identifier: GPL-2.0+ >> # >> >> -obj-y += clock.o clock_slice.o >> +obj-y += lowlevel_init.o >> +obj-y += clock.o clock_slice.o soc.o >> diff --git a/arch/arm/mach-imx/mx8m/lowlevel_init.S >> b/arch/arm/mach-imx/mx8m/lowlevel_init.S >> new file mode 100644 >> index 00..d388f3ba95 >> --- /dev/null >> +++ b/arch/arm/mach-imx/mx8m/lowlevel_init.S >> @@ -0,0 +1,63 @@ >> +/* >> + * Copyright 2017 NXP >> + * >> + * SPDX-License-Identifier: GPL-2.0+ >> + */ >> + >> +#include >> + >> +.align 8 >> +.global rom_pointer >> +rom_pointer: >> +.space 256 >> + >> +/* >> + * Routine: save_boot_params (called after reset from start.S) >> + */ >> + >> +.global save_boot_params >> +save_boot_params: > >save_boot_params is a weak function, but there is a comment for it about >that stack is not available at this point, any you are using the stack. No stack usage. This is to save ROM context. > >And what about this with exception_entry / exception_exit ? Your looks a >rewrite of functions in arch/arm/cpu/armv8/exceptions.S I could not reuse exception_entry/exit. The SP is ROM SP, I would not like to push data to ROM stack from U-Boot. > >> +/* The firmware provided ATAG/FDT address can be found in r2/x0 */ >> +adr x0, rom_pointer >> +stp x1, x2, [x0], #16 >> +stp x3, x4, [x0], #16 >> +stp x5, x6, [x0], #16 >> +stp x7, x8, [x0], #16 >> +stp x9, x10, [x0], #16 >> +stp x11,
Re: [U-Boot] [PATCH V2 12/23] imx: mx8m: add soc related settings and files
Hi Peng, On 04/12/2017 05:31, Peng Fan wrote: > Add SoC level initialization code > - arch_cpu_init > - mmu table > - detect cpu revision > - reset cpu and wdog settings > - M4 boot > - timer init > - wdog settings > - lowlevel init to save/restore registers > - a few dummy header file to avoid build failure > - ft_system_setup and ft_add_optee_node > - mmc env related > > Signed-off-by: Peng Fan> --- > arch/arm/include/asm/arch-mx8m/crm_regs.h | 10 + > arch/arm/include/asm/arch-mx8m/gpio.h | 12 + > arch/arm/include/asm/arch-mx8m/sys_proto.h | 18 + > arch/arm/mach-imx/Makefile | 1 + > arch/arm/mach-imx/mx8m/Makefile| 3 +- > arch/arm/mach-imx/mx8m/lowlevel_init.S | 63 > arch/arm/mach-imx/mx8m/soc.c | 539 > + > 7 files changed, 645 insertions(+), 1 deletion(-) > create mode 100644 arch/arm/include/asm/arch-mx8m/crm_regs.h > create mode 100644 arch/arm/include/asm/arch-mx8m/gpio.h > create mode 100644 arch/arm/include/asm/arch-mx8m/sys_proto.h > create mode 100644 arch/arm/mach-imx/mx8m/lowlevel_init.S > create mode 100644 arch/arm/mach-imx/mx8m/soc.c > > diff --git a/arch/arm/include/asm/arch-mx8m/crm_regs.h > b/arch/arm/include/asm/arch-mx8m/crm_regs.h > new file mode 100644 > index 00..6582318983 > --- /dev/null > +++ b/arch/arm/include/asm/arch-mx8m/crm_regs.h > @@ -0,0 +1,10 @@ > +/* > + * Copyright 2017 NXP > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#ifndef _ASM_ARCH_MX8M_CRM_REGS_H > +#define _ASM_ARCH_MX8M_CRM_REGS_H > +/* Dummy header, some imx-common code needs this file */ > +#endif > diff --git a/arch/arm/include/asm/arch-mx8m/gpio.h > b/arch/arm/include/asm/arch-mx8m/gpio.h > new file mode 100644 > index 00..b666d37700 > --- /dev/null > +++ b/arch/arm/include/asm/arch-mx8m/gpio.h > @@ -0,0 +1,12 @@ > +/* > + * Copyright 2017 NXP > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#ifndef __ASM_ARCH_MX8M_GPIO_H > +#define __ASM_ARCH_MX8M_GPIO_H > + > +#include > + > +#endif > diff --git a/arch/arm/include/asm/arch-mx8m/sys_proto.h > b/arch/arm/include/asm/arch-mx8m/sys_proto.h > new file mode 100644 > index 00..8bf9ac6697 > --- /dev/null > +++ b/arch/arm/include/asm/arch-mx8m/sys_proto.h > @@ -0,0 +1,18 @@ > +/* > + * Copyright (C) 2017 NXP > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#ifndef __ARCH_MX8M_SYS_PROTO_H > +#define __ARCH_MX8M_SYS_PROTO_H > + > +#include > + > +void set_wdog_reset(struct wdog_regs *wdog); > +void enable_tzc380(void); > +void restore_boot_params(void); > +extern unsigned long rom_pointer[]; > +enum boot_device get_boot_device(void); > +bool is_usb_boot(void); > +#endif > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile > index c807174363..27c154b8b3 100644 > --- a/arch/arm/mach-imx/Makefile > +++ b/arch/arm/mach-imx/Makefile > @@ -127,4 +127,5 @@ obj-$(CONFIG_MX5) += mx5/ > obj-$(CONFIG_MX6) += mx6/ > obj-$(CONFIG_MX7) += mx7/ > obj-$(CONFIG_ARCH_MX7ULP) += mx7ulp/ > +obj-$(CONFIG_MX8M) += mx8m/ > > diff --git a/arch/arm/mach-imx/mx8m/Makefile b/arch/arm/mach-imx/mx8m/Makefile > index 05f38842f0..b1c5d74aab 100644 > --- a/arch/arm/mach-imx/mx8m/Makefile > +++ b/arch/arm/mach-imx/mx8m/Makefile > @@ -4,4 +4,5 @@ > # SPDX-License-Identifier: GPL-2.0+ > # > > -obj-y += clock.o clock_slice.o > +obj-y += lowlevel_init.o > +obj-y += clock.o clock_slice.o soc.o > diff --git a/arch/arm/mach-imx/mx8m/lowlevel_init.S > b/arch/arm/mach-imx/mx8m/lowlevel_init.S > new file mode 100644 > index 00..d388f3ba95 > --- /dev/null > +++ b/arch/arm/mach-imx/mx8m/lowlevel_init.S > @@ -0,0 +1,63 @@ > +/* > + * Copyright 2017 NXP > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#include > + > +.align 8 > +.global rom_pointer > +rom_pointer: > + .space 256 > + > +/* > + * Routine: save_boot_params (called after reset from start.S) > + */ > + > +.global save_boot_params > +save_boot_params: save_boot_params is a weak function, but there is a comment for it about that stack is not available at this point, any you are using the stack. And what about this with exception_entry / exception_exit ? Your looks a rewrite of functions in arch/arm/cpu/armv8/exceptions.S > + /* The firmware provided ATAG/FDT address can be found in r2/x0 */ > + adr x0, rom_pointer > + stp x1, x2, [x0], #16 > + stp x3, x4, [x0], #16 > + stp x5, x6, [x0], #16 > + stp x7, x8, [x0], #16 > + stp x9, x10, [x0], #16 > + stp x11, x12, [x0], #16 > + stp x13, x14, [x0], #16 > + stp x15, x16, [x0], #16 > + stp x17, x18, [x0], #16 > + stp x19, x20, [x0], #16 > + stp x21, x22, [x0], #16 > + stp x23, x24, [x0], #16 > + stp x25, x26, [x0], #16 > + stp x27, x28, [x0], #16 > + stp x29, x30, [x0], #16 > + mov x30, sp > + str x30,
[U-Boot] [PATCH V2 12/23] imx: mx8m: add soc related settings and files
Add SoC level initialization code - arch_cpu_init - mmu table - detect cpu revision - reset cpu and wdog settings - M4 boot - timer init - wdog settings - lowlevel init to save/restore registers - a few dummy header file to avoid build failure - ft_system_setup and ft_add_optee_node - mmc env related Signed-off-by: Peng Fan--- arch/arm/include/asm/arch-mx8m/crm_regs.h | 10 + arch/arm/include/asm/arch-mx8m/gpio.h | 12 + arch/arm/include/asm/arch-mx8m/sys_proto.h | 18 + arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/mx8m/Makefile| 3 +- arch/arm/mach-imx/mx8m/lowlevel_init.S | 63 arch/arm/mach-imx/mx8m/soc.c | 539 + 7 files changed, 645 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/arch-mx8m/crm_regs.h create mode 100644 arch/arm/include/asm/arch-mx8m/gpio.h create mode 100644 arch/arm/include/asm/arch-mx8m/sys_proto.h create mode 100644 arch/arm/mach-imx/mx8m/lowlevel_init.S create mode 100644 arch/arm/mach-imx/mx8m/soc.c diff --git a/arch/arm/include/asm/arch-mx8m/crm_regs.h b/arch/arm/include/asm/arch-mx8m/crm_regs.h new file mode 100644 index 00..6582318983 --- /dev/null +++ b/arch/arm/include/asm/arch-mx8m/crm_regs.h @@ -0,0 +1,10 @@ +/* + * Copyright 2017 NXP + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef _ASM_ARCH_MX8M_CRM_REGS_H +#define _ASM_ARCH_MX8M_CRM_REGS_H +/* Dummy header, some imx-common code needs this file */ +#endif diff --git a/arch/arm/include/asm/arch-mx8m/gpio.h b/arch/arm/include/asm/arch-mx8m/gpio.h new file mode 100644 index 00..b666d37700 --- /dev/null +++ b/arch/arm/include/asm/arch-mx8m/gpio.h @@ -0,0 +1,12 @@ +/* + * Copyright 2017 NXP + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __ASM_ARCH_MX8M_GPIO_H +#define __ASM_ARCH_MX8M_GPIO_H + +#include + +#endif diff --git a/arch/arm/include/asm/arch-mx8m/sys_proto.h b/arch/arm/include/asm/arch-mx8m/sys_proto.h new file mode 100644 index 00..8bf9ac6697 --- /dev/null +++ b/arch/arm/include/asm/arch-mx8m/sys_proto.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2017 NXP + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef __ARCH_MX8M_SYS_PROTO_H +#define __ARCH_MX8M_SYS_PROTO_H + +#include + +void set_wdog_reset(struct wdog_regs *wdog); +void enable_tzc380(void); +void restore_boot_params(void); +extern unsigned long rom_pointer[]; +enum boot_device get_boot_device(void); +bool is_usb_boot(void); +#endif diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index c807174363..27c154b8b3 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -127,4 +127,5 @@ obj-$(CONFIG_MX5) += mx5/ obj-$(CONFIG_MX6) += mx6/ obj-$(CONFIG_MX7) += mx7/ obj-$(CONFIG_ARCH_MX7ULP) += mx7ulp/ +obj-$(CONFIG_MX8M) += mx8m/ diff --git a/arch/arm/mach-imx/mx8m/Makefile b/arch/arm/mach-imx/mx8m/Makefile index 05f38842f0..b1c5d74aab 100644 --- a/arch/arm/mach-imx/mx8m/Makefile +++ b/arch/arm/mach-imx/mx8m/Makefile @@ -4,4 +4,5 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += clock.o clock_slice.o +obj-y += lowlevel_init.o +obj-y += clock.o clock_slice.o soc.o diff --git a/arch/arm/mach-imx/mx8m/lowlevel_init.S b/arch/arm/mach-imx/mx8m/lowlevel_init.S new file mode 100644 index 00..d388f3ba95 --- /dev/null +++ b/arch/arm/mach-imx/mx8m/lowlevel_init.S @@ -0,0 +1,63 @@ +/* + * Copyright 2017 NXP + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include + +.align 8 +.global rom_pointer +rom_pointer: + .space 256 + +/* + * Routine: save_boot_params (called after reset from start.S) + */ + +.global save_boot_params +save_boot_params: + /* The firmware provided ATAG/FDT address can be found in r2/x0 */ + adr x0, rom_pointer + stp x1, x2, [x0], #16 + stp x3, x4, [x0], #16 + stp x5, x6, [x0], #16 + stp x7, x8, [x0], #16 + stp x9, x10, [x0], #16 + stp x11, x12, [x0], #16 + stp x13, x14, [x0], #16 + stp x15, x16, [x0], #16 + stp x17, x18, [x0], #16 + stp x19, x20, [x0], #16 + stp x21, x22, [x0], #16 + stp x23, x24, [x0], #16 + stp x25, x26, [x0], #16 + stp x27, x28, [x0], #16 + stp x29, x30, [x0], #16 + mov x30, sp + str x30, [x0], #8 + + /* Returns */ + b save_boot_params_ret + +.global restore_boot_params +restore_boot_params: + adr x0, rom_pointer + ldp x1, x2, [x0], #16 + ldp x3, x4, [x0], #16 + ldp x5, x6, [x0], #16 + ldp x7, x8, [x0], #16 + ldp x9, x10, [x0], #16 + ldp x11, x12, [x0], #16 + ldp x13, x14, [x0], #16 + ldp x15, x16, [x0], #16 + ldp x17, x18, [x0], #16 + ldp x19, x20, [x0], #16 + ldp x21, x22, [x0], #16 + ldp x23, x24, [x0], #16 +