From 8bb4fcd5d98ad065436aa62544a0addaffd29475 Mon Sep 17 00:00:00 2001 From: Juergen Borleis Date: Fri, 9 Dec 2016 10:49:30 +0100 Subject: imx-usb-loader: let constant data be const Signed-off-by: Juergen Borleis --- scripts/imx/imx-usb-loader.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index be0894fa65..dfeef9e2c7 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -72,11 +72,11 @@ struct usb_work { }; struct usb_id { - struct mach_id *mach_id; + const struct mach_id *mach_id; struct usb_work *work; }; -struct mach_id imx_ids[] = { +const struct mach_id imx_ids[] = { { .vid = 0x066f, .pid = 0x3780, @@ -174,12 +174,12 @@ struct sdp_command { uint8_t rsvd; } __attribute__((packed)); -static struct mach_id *imx_device(unsigned short vid, unsigned short pid) +static const struct mach_id *imx_device(unsigned short vid, unsigned short pid) { int i; for (i = 0; i < ARRAY_SIZE(imx_ids); i++) { - struct mach_id *id = &imx_ids[i]; + const struct mach_id *id = &imx_ids[i]; if (id->vid == vid && id->pid == pid) { fprintf(stderr, "found %s USB device [%04x:%04x]\n", id->name, vid, pid); @@ -190,10 +190,10 @@ static struct mach_id *imx_device(unsigned short vid, unsigned short pid) return NULL; } -static libusb_device *find_imx_dev(libusb_device **devs, struct mach_id **pp_id) +static libusb_device *find_imx_dev(libusb_device **devs, const struct mach_id **pp_id) { int i = 0; - struct mach_id *p; + const struct mach_id *p; for (;;) { struct libusb_device_descriptor desc; @@ -1288,7 +1288,7 @@ static void usage(const char *prgname) int main(int argc, char *argv[]) { - struct mach_id *mach; + const struct mach_id *mach; libusb_device **devs; libusb_device *dev; int r; -- cgit v1.2.3 From cacc393c1e0c73bfbdf3ea2ba0823f400dc0b776 Mon Sep 17 00:00:00 2001 From: Juergen Borleis Date: Fri, 9 Dec 2016 10:50:06 +0100 Subject: imx-usb-loader: this table is used internally only, so keep it static Signed-off-by: Juergen Borleis --- scripts/imx/imx-usb-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index dfeef9e2c7..ebffeddaeb 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -76,7 +76,7 @@ struct usb_id { struct usb_work *work; }; -const struct mach_id imx_ids[] = { +static const struct mach_id imx_ids[] = { { .vid = 0x066f, .pid = 0x3780, -- cgit v1.2.3 From 14ff9d5823f938b29a6cb2cc6f367ff7ee807bac Mon Sep 17 00:00:00 2001 From: Juergen Borleis Date: Fri, 9 Dec 2016 10:51:14 +0100 Subject: imx-usb-loader: add i.MX7S support Signed-off-by: Juergen Borleis --- scripts/imx/imx-usb-loader.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'scripts') diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index ebffeddaeb..9de7bb3a8a 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -156,6 +156,13 @@ static const struct mach_id imx_ids[] = { .header_type = HDR_MX53, .mode = MODE_HID, .max_transfer = 1024, + }, { + .vid = 0x15a2, + .pid = 0x0076, + .name = "i.MX7S", + .header_type = HDR_MX53, + .mode = MODE_HID, + .max_transfer = 1024, }, }; -- cgit v1.2.3 From ea55770308c0dcef7b83acbabca9fe6aab5b1dc4 Mon Sep 17 00:00:00 2001 From: Juergen Borleis Date: Tue, 6 Dec 2016 15:25:11 +0100 Subject: ARM: i.MX: Add i.MX7 base architecture support Signed-off-by Juergen Borleis Signed-off-by: Sascha Hauer --- Documentation/boards/imx.rst | 1 + arch/arm/mach-imx/Kconfig | 4 ++ arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/boot.c | 70 ++++++++++++++++++++++++ arch/arm/mach-imx/cpu_init.c | 5 ++ arch/arm/mach-imx/imx.c | 6 +++ arch/arm/mach-imx/imx7.c | 75 ++++++++++++++++++++++++++ arch/arm/mach-imx/include/mach/debug_ll.h | 3 ++ arch/arm/mach-imx/include/mach/generic.h | 16 ++++++ arch/arm/mach-imx/include/mach/imx7-regs.h | 24 +++++++++ arch/arm/mach-imx/include/mach/imx7.h | 59 ++++++++++++++++++++ arch/arm/mach-imx/include/mach/imx_cpu_types.h | 1 + common/Kconfig | 8 +++ include/serial/imx-uart.h | 5 ++ scripts/imx/imx.c | 1 + 15 files changed, 279 insertions(+) create mode 100644 arch/arm/mach-imx/imx7.c create mode 100644 arch/arm/mach-imx/include/mach/imx7-regs.h create mode 100644 arch/arm/mach-imx/include/mach/imx7.h (limited to 'scripts') diff --git a/Documentation/boards/imx.rst b/Documentation/boards/imx.rst index 60cdcf072e..b6e65060c7 100644 --- a/Documentation/boards/imx.rst +++ b/Documentation/boards/imx.rst @@ -20,6 +20,7 @@ The Internal Boot Mode is supported on: * i.MX51 * i.MX53 * i.MX6 +* i.MX7 With the Internal Boot Mode, the images contain a header which describes where the binary shall be loaded and started. These headers also contain diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 62e6494c2a..ba5a9c445e 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -157,6 +157,10 @@ config ARCH_IMX6UL bool select ARCH_IMX6 +config ARCH_IMX7 + bool + select CPU_V7 + config ARCH_VF610 bool select ARCH_HAS_L2X0 diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index d0fe7abc00..fc5305f051 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_ARCH_IMX53) += imx53.o imx5.o esdctl-v4.o pbl-$(CONFIG_ARCH_IMX53) += imx53.o imx5.o esdctl-v4.o obj-$(CONFIG_ARCH_IMX6) += imx6.o usb-imx6.o lwl-$(CONFIG_ARCH_IMX6) += imx6-mmdc.o +obj-$(CONFIG_ARCH_IMX7) += imx7.o obj-$(CONFIG_ARCH_IMX_XLOAD) += xload.o obj-$(CONFIG_IMX_IIM) += iim.o obj-$(CONFIG_IMX_OCOTP) += ocotp.o diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c index 489306072f..72597f5e2d 100644 --- a/arch/arm/mach-imx/boot.c +++ b/arch/arm/mach-imx/boot.c @@ -25,6 +25,7 @@ #include #include #include +#include /* [CTRL][TYPE] */ static const enum bootsource locations[4][4] = { @@ -346,3 +347,72 @@ void imx6_boot_save_loc(void) bootsource_set(src); bootsource_set_instance(instance); } + +#define IMX7_SRC_SBMR1 0x58 +#define IMX7_SRC_SBMR2 0x70 + +void imx7_get_boot_source(enum bootsource *src, int *instance) +{ + void __iomem *src_base = IOMEM(MX7_SRC_BASE_ADDR); + uint32_t sbmr1 = readl(src_base + IMX7_SRC_SBMR1); + uint32_t sbmr2 = readl(src_base + IMX7_SRC_SBMR2); + int boot_mode; + + /* BMOD[1:0] */ + boot_mode = (sbmr2 >> 24) & 0x3; + + switch (boot_mode) { + case 0: /* Fuses, fall through */ + case 2: /* internal boot */ + goto internal_boot; + case 1: /* Serial Downloader */ + *src = BOOTSOURCE_SERIAL; + break; + case 3: /* reserved */ + break; + }; + + return; + +internal_boot: + + switch ((sbmr1 >> 12) & 0xf) { + case 1: + case 2: + *src = BOOTSOURCE_MMC; + *instance = (sbmr1 >> 10 & 0x3); + break; + case 3: + *src = BOOTSOURCE_NAND; + break; + case 4: + *src = BOOTSOURCE_SPI_NOR, + *instance = (sbmr1 >> 9 & 0x7); + break; + case 6: + *src = BOOTSOURCE_SPI; /* Really: qspi */ + break; + case 5: + *src = BOOTSOURCE_NOR; + break; + default: + break; + } + + /* BOOT_CFG1[7:0] */ + if (sbmr1 & (1 << 7)) + *src = BOOTSOURCE_NAND; + + return; +} + +void imx7_boot_save_loc(void) +{ + enum bootsource src = BOOTSOURCE_UNKNOWN; + int instance = BOOTSOURCE_INSTANCE_UNKNOWN; + + imx7_get_boot_source(&src, &instance); + + bootsource_set(src); + bootsource_set_instance(instance); +} diff --git a/arch/arm/mach-imx/cpu_init.c b/arch/arm/mach-imx/cpu_init.c index 6971d89d9e..2b388cad8c 100644 --- a/arch/arm/mach-imx/cpu_init.c +++ b/arch/arm/mach-imx/cpu_init.c @@ -34,6 +34,11 @@ void imx6_cpu_lowlevel_init(void) enable_arm_errata_845369_war(); } +void imx7_cpu_lowlevel_init(void) +{ + arm_cpu_lowlevel_init(); +} + void vf610_cpu_lowlevel_init(void) { arm_cpu_lowlevel_init(); diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c index 952db007d9..907340fc5d 100644 --- a/arch/arm/mach-imx/imx.c +++ b/arch/arm/mach-imx/imx.c @@ -65,6 +65,10 @@ static int imx_soc_from_dt(void) return IMX_CPU_IMX6; if (of_machine_is_compatible("fsl,imx6ul")) return IMX_CPU_IMX6; + if (of_machine_is_compatible("fsl,imx7s")) + return IMX_CPU_IMX7; + if (of_machine_is_compatible("fsl,imx7d")) + return IMX_CPU_IMX7; if (of_machine_is_compatible("fsl,vf610")) return IMX_CPU_VF610; @@ -103,6 +107,8 @@ static int imx_init(void) ret = imx53_init(); else if (cpu_is_mx6()) ret = imx6_init(); + else if (cpu_is_mx7()) + ret = imx7_init(); else if (cpu_is_vf610()) ret = 0; else diff --git a/arch/arm/mach-imx/imx7.c b/arch/arm/mach-imx/imx7.c new file mode 100644 index 0000000000..fde66d838f --- /dev/null +++ b/arch/arm/mach-imx/imx7.c @@ -0,0 +1,75 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +void imx7_init_lowlevel(void) +{ + void __iomem *aips1 = IOMEM(MX7_AIPS1_CONFIG_BASE_ADDR); + void __iomem *aips2 = IOMEM(MX7_AIPS2_CONFIG_BASE_ADDR); + + /* + * Set all MPROTx to be non-bufferable, trusted for R/W, + * not forced to user-mode. + */ + writel(0x77777777, aips1); + writel(0x77777777, aips1 + 0x4); + writel(0, aips1 + 0x40); + writel(0, aips1 + 0x44); + writel(0, aips1 + 0x48); + writel(0, aips1 + 0x4c); + writel(0, aips1 + 0x50); + + writel(0x77777777, aips2); + writel(0x77777777, aips2 + 0x4); + writel(0, aips2 + 0x40); + writel(0, aips2 + 0x44); + writel(0, aips2 + 0x48); + writel(0, aips2 + 0x4c); + writel(0, aips2 + 0x50); +} + +int imx7_init(void) +{ + const char *cputypestr; + u32 imx7_silicon_revision; + + imx7_init_lowlevel(); + + imx7_boot_save_loc(); + + imx7_silicon_revision = imx7_cpu_revision(); + + switch (imx7_cpu_type()) { + case IMX7_CPUTYPE_IMX7D: + cputypestr = "i.MX7d"; + break; + case IMX7_CPUTYPE_IMX7S: + cputypestr = "i.MX7s"; + break; + default: + cputypestr = "unknown i.MX7"; + break; + } + + imx_set_silicon_revision(cputypestr, imx7_silicon_revision); + + return 0; +} diff --git a/arch/arm/mach-imx/include/mach/debug_ll.h b/arch/arm/mach-imx/include/mach/debug_ll.h index a132f3c163..39d710f7d8 100644 --- a/arch/arm/mach-imx/include/mach/debug_ll.h +++ b/arch/arm/mach-imx/include/mach/debug_ll.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,8 @@ #define IMX_DEBUG_SOC MX53 #elif defined CONFIG_DEBUG_IMX6Q_UART #define IMX_DEBUG_SOC MX6 +#elif defined CONFIG_DEBUG_IMX7D_UART +#define IMX_DEBUG_SOC MX7 #elif defined CONFIG_DEBUG_VF610_UART #define IMX_DEBUG_SOC VF610 #else diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h index 34194509e8..73be9ceb55 100644 --- a/arch/arm/mach-imx/include/mach/generic.h +++ b/arch/arm/mach-imx/include/mach/generic.h @@ -14,12 +14,14 @@ void imx27_boot_save_loc(void); void imx51_boot_save_loc(void); void imx53_boot_save_loc(void); void imx6_boot_save_loc(void); +void imx7_boot_save_loc(void); void imx25_get_boot_source(enum bootsource *src, int *instance); void imx35_get_boot_source(enum bootsource *src, int *instance); void imx51_get_boot_source(enum bootsource *src, int *instance); void imx53_get_boot_source(enum bootsource *src, int *instance); void imx6_get_boot_source(enum bootsource *src, int *instance); +void imx7_get_boot_source(enum bootsource *src, int *instance); int imx1_init(void); int imx21_init(void); @@ -31,6 +33,7 @@ int imx50_init(void); int imx51_init(void); int imx53_init(void); int imx6_init(void); +int imx7_init(void); int imx1_devices_init(void); int imx21_devices_init(void); @@ -45,6 +48,7 @@ int imx6_devices_init(void); void imx5_cpu_lowlevel_init(void); void imx6_cpu_lowlevel_init(void); +void imx7_cpu_lowlevel_init(void); void vf610_cpu_lowlevel_init(void); /* There's a off-by-one betweem the gpio bank number and the gpiochip */ @@ -174,6 +178,18 @@ extern unsigned int __imx_cpu_type; # define cpu_is_mx6() (0) #endif +#ifdef CONFIG_ARCH_IMX7 +# ifdef imx_cpu_type +# undef imx_cpu_type +# define imx_cpu_type __imx_cpu_type +# else +# define imx_cpu_type IMX_CPU_IMX7 +# endif +# define cpu_is_mx7() (imx_cpu_type == IMX_CPU_IMX7) +#else +# define cpu_is_mx7() (0) +#endif + #ifdef CONFIG_ARCH_VF610 # ifdef imx_cpu_type # undef imx_cpu_type diff --git a/arch/arm/mach-imx/include/mach/imx7-regs.h b/arch/arm/mach-imx/include/mach/imx7-regs.h new file mode 100644 index 0000000000..a96341d6d0 --- /dev/null +++ b/arch/arm/mach-imx/include/mach/imx7-regs.h @@ -0,0 +1,24 @@ +#ifndef __MACH_IMX7_REGS_H +#define __MACH_IMX7_REGS_H + +#define MX7_AIPS1_BASE_ADDR 0x30000000 +#define MX7_AIPS2_BASE_ADDR 0x30400000 +#define MX7_AIPS3_BASE_ADDR 0x30800000 + +#define MX7_AIPS1_CONFIG_BASE_ADDR 0x301f0000 +#define MX7_IOMUX_BASE_ADDR 0x30330000 +#define MX7_OCOTP_BASE_ADDR 0x30350000 +#define MX7_ANATOP_BASE_ADDR 0x30360000 +#define MX7_CCM_BASE_ADDR 0x30380000 +#define MX7_SRC_BASE_ADDR 0x30390000 +#define MX7_SCTR_BASE_ADDR 0x306c0000 +#define MX7_UART1_BASE_ADDR 0x30860000 +#define MX7_UART2_BASE_ADDR 0x30870000 +#define MX7_UART3_BASE_ADDR 0x30880000 +#define MX7_UART4_BASE_ADDR 0x30a60000 +#define MX7_UART5_BASE_ADDR 0x30a70000 +#define MX7_UART6_BASE_ADDR 0x30a80000 +#define MX7_UART7_BASE_ADDR 0x30a90000 +#define MX7_AIPS2_CONFIG_BASE_ADDR 0x305f0000 + +#endif /* __MACH_IMX7_REGS_H */ diff --git a/arch/arm/mach-imx/include/mach/imx7.h b/arch/arm/mach-imx/include/mach/imx7.h new file mode 100644 index 0000000000..8518935468 --- /dev/null +++ b/arch/arm/mach-imx/include/mach/imx7.h @@ -0,0 +1,59 @@ +#ifndef __MACH_IMX7_H +#define __MACH_IMX7_H + +#include +#include +#include +#include + +void imx7_init_lowlevel(void); + +#define ANADIG_DIGPROG_IMX7 0x800 + +#define IMX7_CPUTYPE_IMX7S 0x71 +#define IMX7_CPUTYPE_IMX7D 0x72 + +static inline int __imx7_cpu_type(void) +{ + void __iomem *ocotp = IOMEM(MX7_OCOTP_BASE_ADDR); + + if (readl(ocotp + 0x450) & 1) + return IMX7_CPUTYPE_IMX7S; + else + return IMX7_CPUTYPE_IMX7D; +} + +static inline int imx7_cpu_type(void) +{ + if (!cpu_is_mx7()) + return 0; + + return __imx7_cpu_type(); +} + +static inline int imx7_cpu_revision(void) +{ + if (!cpu_is_mx7()) + return IMX_CHIP_REV_UNKNOWN; + + /* register value has the format of the IMX_CHIP_REV_* macros */ + return readl(MX7_ANATOP_BASE_ADDR + ANADIG_DIGPROG_IMX7) & 0xff; +} + +#define DEFINE_MX7_CPU_TYPE(str, type) \ + static inline int cpu_mx7_is_##str(void) \ + { \ + return __imx7_cpu_type() == type; \ + } \ + \ + static inline int cpu_is_##str(void) \ + { \ + if (!cpu_is_mx7()) \ + return 0; \ + return cpu_mx7_is_##str(); \ + } + +DEFINE_MX7_CPU_TYPE(mx7s, IMX7_CPUTYPE_IMX7S); +DEFINE_MX7_CPU_TYPE(mx7d, IMX7_CPUTYPE_IMX7D); + +#endif /* __MACH_IMX7_H */ \ No newline at end of file diff --git a/arch/arm/mach-imx/include/mach/imx_cpu_types.h b/arch/arm/mach-imx/include/mach/imx_cpu_types.h index 50be0b6b5e..f95ef6f135 100644 --- a/arch/arm/mach-imx/include/mach/imx_cpu_types.h +++ b/arch/arm/mach-imx/include/mach/imx_cpu_types.h @@ -11,6 +11,7 @@ #define IMX_CPU_IMX51 51 #define IMX_CPU_IMX53 53 #define IMX_CPU_IMX6 6 +#define IMX_CPU_IMX7 7 #define IMX_CPU_VF610 610 #endif /* __MACH_IMX_CPU_TYPES_H */ diff --git a/common/Kconfig b/common/Kconfig index 462c104fde..350e3d49dd 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1072,6 +1072,13 @@ config DEBUG_IMX6Q_UART Say Y here if you want kernel low-level debugging support on i.MX6Q. +config DEBUG_IMX7D_UART + bool "i.MX7D Debug UART" + depends on ARCH_IMX7 + help + Say Y here if you want barebox low-level debugging support + on i.MX7D. + config DEBUG_VF610_UART bool "VF610 Debug UART" depends on ARCH_VF610 @@ -1120,6 +1127,7 @@ config DEBUG_IMX_UART_PORT DEBUG_IMX53_UART || \ DEBUG_IMX6Q_UART || \ DEBUG_IMX6SL_UART || \ + DEBUG_IMX7D_UART || \ DEBUG_VF610_UART default 1 depends on ARCH_IMX diff --git a/include/serial/imx-uart.h b/include/serial/imx-uart.h index b40044ea4b..9cab32f359 100644 --- a/include/serial/imx-uart.h +++ b/include/serial/imx-uart.h @@ -175,6 +175,11 @@ static inline void imx6_uart_setup(void __iomem *uartbase) imx_uart_setup(uartbase, 80000000); } +static inline void imx7_uart_setup(void __iomem *uartbase) +{ + imx_uart_setup(uartbase, 24000000); +} + static inline void imx_uart_putc(void *base, int c) { if (!(readl(base + UCR1) & UCR1_UARTEN)) diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c index bf3a42fb29..809d8a7f71 100644 --- a/scripts/imx/imx.c +++ b/scripts/imx/imx.c @@ -231,6 +231,7 @@ static struct soc_type socs[] = { { .name = "imx51", .header_version = 1, .cpu_type = IMX_CPU_IMX51 }, { .name = "imx53", .header_version = 2, .cpu_type = IMX_CPU_IMX53 }, { .name = "imx6", .header_version = 2, .cpu_type = IMX_CPU_IMX6 }, + { .name = "imx7", .header_version = 2, .cpu_type = IMX_CPU_IMX7 }, { .name = "vf610", .header_version = 2, .cpu_type = IMX_CPU_VF610 }, }; -- cgit v1.2.3