From 5dce6d226d03fd69e2318a4981194c4866bcf448 Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:33 +0000 Subject: [PATCH 01/46] configs: am335x_guardian: Enable clock driver Enable TI clock driver support for guardian board Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-2-Gireesh.Hiremath@in.bosch.com --- configs/am335x_guardian_defconfig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/configs/am335x_guardian_defconfig b/configs/am335x_guardian_defconfig index 7eafb6d4bd..8eedcbd64a 100644 --- a/configs/am335x_guardian_defconfig +++ b/configs/am335x_guardian_defconfig @@ -69,6 +69,13 @@ CONFIG_VERSION_VARIABLE=y CONFIG_BOOTP_SEND_HOSTNAME=y CONFIG_SPL_DM=y CONFIG_BOOTCOUNT_LIMIT=y +CONFIG_CLK=y +CONFIG_CLK_CCF=y +CONFIG_CLK_TI_AM3_DPLL=y +CONFIG_CLK_TI_CTRL=y +CONFIG_CLK_TI_DIVIDER=y +CONFIG_CLK_TI_GATE=y +CONFIG_CLK_TI_MUX=y CONFIG_LED=y CONFIG_LED_GPIO=y CONFIG_MISC=y From 050531db00474d7d298828d997f517205d8517dc Mon Sep 17 00:00:00 2001 From: Moses Christopher Date: Fri, 11 Jun 2021 16:13:34 +0000 Subject: [PATCH 02/46] am335x, guardian: mem: Add board dependent mem values - Add mem-guardian.h derived from am33xx/mem.h * Add GPMC config values optimized for Bosch Guardian Board * NAND Chip used by Bosch Guardian Board is Micron MT29F4G08ABBFA Signed-off-by: Moses Christopher Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-3-Gireesh.Hiremath@in.bosch.com --- .../include/asm/arch-am33xx/mem-guardian.h | 63 +++++++++++++++++++ arch/arm/mach-omap2/am33xx/board.c | 4 ++ arch/arm/mach-omap2/mem-common.c | 4 ++ board/bosch/guardian/board.c | 2 +- 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 arch/arm/include/asm/arch-am33xx/mem-guardian.h diff --git a/arch/arm/include/asm/arch-am33xx/mem-guardian.h b/arch/arm/include/asm/arch-am33xx/mem-guardian.h new file mode 100644 index 0000000000..e864a0fd36 --- /dev/null +++ b/arch/arm/include/asm/arch-am33xx/mem-guardian.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2006-2008 + * Texas Instruments, + * + * (C) Copyright 2020 + * Robert Bosch Power Tools GmbH + * + * Author + * Moses Christopher + * + * Copied from: + * arch/arm/include/asm/arch-am33xx/mem.h + * + * Initial Code from: + * Mansoor Ahamed + * Richard Woodruff + */ + +#ifndef _MEM_GUARDIAN_H_ +#define _MEM_GUARDIAN_H_ + +/* + * GPMC settings - + * Definitions is as per the following format + * #define _GPMC_CONFIG + * Where: + * PART is the part name e.g. M_NAND - Micron Nand Flash + * x is GPMC config registers from 1 to 7 (there will be 7 macros) + * Value is corresponding value + * + * For every valid PRCM configuration there should be only one definition of + * the same. + * + * The following values are optimized for improving the NAND Read speed + * They are applicable and tested for Bosch Guardian Board. + * Read Speeds rose from 1.5MiBs to over 7.6MiBs + * + * Currently valid part Names are (PART): + * M_NAND - Micron NAND + */ +#define GPMC_SIZE_256M 0x0 +#define GPMC_SIZE_128M 0x8 +#define GPMC_SIZE_64M 0xC +#define GPMC_SIZE_32M 0xE +#define GPMC_SIZE_16M 0xF + +#define M_NAND_GPMC_CONFIG1 0x00000800 +#define M_NAND_GPMC_CONFIG2 0x00030300 +#define M_NAND_GPMC_CONFIG3 0x00030300 +#define M_NAND_GPMC_CONFIG4 0x02000201 +#define M_NAND_GPMC_CONFIG5 0x00030303 +#define M_NAND_GPMC_CONFIG6 0x000000C0 +#define M_NAND_GPMC_CONFIG7 0x00000008 + +/* max number of GPMC Chip Selects */ +#define GPMC_MAX_CS 8 +/* max number of GPMC regs */ +#define GPMC_MAX_REG 7 + +#define DBG_MPDB 6 + +#endif /* endif _MEM_GUARDIAN_H_ */ diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am33xx/board.c index 62178f1e70..4bf0535e3c 100644 --- a/arch/arm/mach-omap2/am33xx/board.c +++ b/arch/arm/mach-omap2/am33xx/board.c @@ -23,7 +23,11 @@ #include #include #include +#if IS_ENABLED(CONFIG_TARGET_AM335X_GUARDIAN) +#include +#else #include +#endif #include #include #include diff --git a/arch/arm/mach-omap2/mem-common.c b/arch/arm/mach-omap2/mem-common.c index 50d5f3e9eb..2dcf0cf9c3 100644 --- a/arch/arm/mach-omap2/mem-common.c +++ b/arch/arm/mach-omap2/mem-common.c @@ -15,7 +15,11 @@ #include #include #include +#if IS_ENABLED(CONFIG_TARGET_AM335X_GUARDIAN) +#include +#else #include +#endif #include #include #include diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c index 113838f8b7..9429454a74 100644 --- a/board/bosch/guardian/board.c +++ b/board/bosch/guardian/board.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include From f11c3b0ef3c64a4ea9df3ab1960043de51038823 Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:35 +0000 Subject: [PATCH 03/46] configs: am335x_guardian: add ubi fastmap support - Trigger fastmap automatically Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-4-Gireesh.Hiremath@in.bosch.com --- configs/am335x_guardian_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/am335x_guardian_defconfig b/configs/am335x_guardian_defconfig index 8eedcbd64a..baa0d161d0 100644 --- a/configs/am335x_guardian_defconfig +++ b/configs/am335x_guardian_defconfig @@ -87,6 +87,7 @@ CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y CONFIG_SYS_NAND_U_BOOT_OFFS=0x100000 CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND=0x200000 CONFIG_MTD_UBI_FASTMAP=y +CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT=1 CONFIG_PHYLIB=y CONFIG_DM_ETH=y CONFIG_PHY=y From 2f147e028c91f17173bdf74087db2fc34eb751fe Mon Sep 17 00:00:00 2001 From: Moses Christopher Date: Fri, 11 Jun 2021 16:13:36 +0000 Subject: [PATCH 04/46] am335x, guardian: set tftp_load_addr in environment Set tftp_load_addr to 0x82000000 in MEM_LAYOUT_ENV_SETTINGS Signed-off-by: Moses Christopher Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-5-Gireesh.Hiremath@in.bosch.com --- include/configs/am335x_guardian.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/am335x_guardian.h b/include/configs/am335x_guardian.h index c34c07a493..fe36e34c7d 100644 --- a/include/configs/am335x_guardian.h +++ b/include/configs/am335x_guardian.h @@ -29,6 +29,7 @@ #define MEM_LAYOUT_ENV_SETTINGS \ "scriptaddr=0x80000000\0" \ "pxefile_addr_r=0x80100000\0" \ + "tftp_load_addr=0x82000000\0" \ "kernel_addr_r=0x82000000\0" \ "fdt_addr_r=0x88000000\0" \ "ramdisk_addr_r=0x88080000\0" \ From b5a57bcda69ba1efde365e8d0eae6288c39b19e6 Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:37 +0000 Subject: [PATCH 05/46] configs: am335x_guardian: add memtest configs - Add mtest, meminfo commands Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-6-Gireesh.Hiremath@in.bosch.com --- configs/am335x_guardian_defconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configs/am335x_guardian_defconfig b/configs/am335x_guardian_defconfig index baa0d161d0..200ed4983b 100644 --- a/configs/am335x_guardian_defconfig +++ b/configs/am335x_guardian_defconfig @@ -7,6 +7,8 @@ CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_ENV_SIZE=0x40000 CONFIG_ENV_OFFSET=0x500000 CONFIG_DEFAULT_DEVICE_TREE="am335x-guardian" +CONFIG_SYS_MEMTEST_START=0x80000000 +CONFIG_SYS_MEMTEST_END=0x81000000 CONFIG_AM33XX=y CONFIG_TARGET_AM335X_GUARDIAN=y CONFIG_SPL_SERIAL_SUPPORT=y @@ -43,6 +45,8 @@ CONFIG_CMD_SPL=y CONFIG_CMD_SPL_NAND_OFS=0x0 CONFIG_CMD_ASKENV=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_MEMINFO=y +CONFIG_CMD_MEMTEST=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y From cea76a4f421a3a9e95815c2265b5292c28a4e410 Mon Sep 17 00:00:00 2001 From: Moses Christopher Date: Fri, 11 Jun 2021 16:13:38 +0000 Subject: [PATCH 06/46] am335x, guardian: Update pinmux configuration pinmux update for guardian board - control ASP Board Power: GPIO, on/off ASP Board Power - control Coincell Voltage Measurement: GPIO, enable/disable ADC measurements - powerOff Device GPIO-PowerOff, cut the PMIC supply Signed-off-by: Moses Christopher Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-7-Gireesh.Hiremath@in.bosch.com --- arch/arm/dts/am335x-guardian.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/dts/am335x-guardian.dts b/arch/arm/dts/am335x-guardian.dts index 7e70a96d25..207246b4e0 100644 --- a/arch/arm/dts/am335x-guardian.dts +++ b/arch/arm/dts/am335x-guardian.dts @@ -401,12 +401,12 @@ guardian_interface_pins: pinmux_guardian_interface_pins { pinctrl-single,pins = < - AM33XX_IOPAD(0x928, PIN_OUTPUT | MUX_MODE7) - AM33XX_IOPAD(0x990, PIN_OUTPUT | MUX_MODE7) + AM33XX_IOPAD(0x990, PIN_OUTPUT_PULLUP | MUX_MODE7) AM33XX_IOPAD(0x9ac, PIN_OUTPUT_PULLDOWN | MUX_MODE7) + AM33XX_IOPAD(0x914, PIN_OUTPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x980, PIN_INPUT | MUX_MODE7) AM33XX_IOPAD(0x984, PIN_INPUT | MUX_MODE7) - AM33XX_IOPAD(0x928, PIN_OUTPUT_PULLUP | MUX_MODE7) + AM33XX_IOPAD(0x94c, PIN_OUTPUT_PULLUP | MUX_MODE7) AM33XX_IOPAD(0x90c, PIN_OUTPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x944, PIN_OUTPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x91c, PIN_INPUT | MUX_MODE7) From f379c44a377bb3ec7aee74a69fed7ac97734d179 Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:39 +0000 Subject: [PATCH 07/46] am335x, guardian: set environment variable autoload to no autoload: if set to "no" then rarpb, bootp or dhcp commands will just perform a configuration lookup from the BOOTP / DHCP server, but not try to load any image using TFTP Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-8-Gireesh.Hiremath@in.bosch.com --- include/configs/am335x_guardian.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/am335x_guardian.h b/include/configs/am335x_guardian.h index fe36e34c7d..814048bf86 100644 --- a/include/configs/am335x_guardian.h +++ b/include/configs/am335x_guardian.h @@ -58,9 +58,9 @@ MEM_LAYOUT_ENV_SETTINGS \ BOOTENV \ GUARDIAN_DEFAULT_PROD_ENV \ + "autoload=no\0" \ "bootubivol=rootfs\0" \ "distro_bootcmd=" \ - "setenv autoload no; " \ "setenv rootflags \"bulk_read,chk_data_crc\"; " \ "setenv ethact usb_ether; " \ "if test \"${swi_status}\" -eq 1; then " \ From 195854287b02bb6eeed6c6978d3764fe40313b04 Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:40 +0000 Subject: [PATCH 08/46] am335x, guardian: code cleanup and boot optimization - remove redundant headers and boot modes from board file Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-9-Gireesh.Hiremath@in.bosch.com --- board/bosch/guardian/board.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c index 9429454a74..12d047b74b 100644 --- a/board/bosch/guardian/board.c +++ b/board/bosch/guardian/board.c @@ -9,19 +9,14 @@ */ #include -#include #include -#include #include #include #include -#include #include -#include #include #include #include -#include #include #include #include @@ -193,27 +188,11 @@ int board_init(void) #ifdef CONFIG_BOARD_LATE_INIT static void set_bootmode_env(void) { - char *boot_device_name = NULL; char *boot_mode_gpio = "gpio@44e07000_14"; int ret; - int value; struct gpio_desc boot_mode_desc; - switch (gd->arch.omap_boot_device) { - case BOOT_DEVICE_NAND: - boot_device_name = "nand"; - break; - case BOOT_DEVICE_USBETH: - boot_device_name = "usbeth"; - break; - default: - break; - } - - if (boot_device_name) - env_set("boot_device", boot_device_name); - ret = dm_gpio_lookup_name(boot_mode_gpio, &boot_mode_desc); if (ret) { printf("%s is not found\n", boot_mode_gpio); From 25b36ab2604757871450d88fee1b4ec9bbe516cb Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:41 +0000 Subject: [PATCH 09/46] configs: am335x_guardian: set boot delay - set boot delay to zero, to increase boot speed Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-10-Gireesh.Hiremath@in.bosch.com --- configs/am335x_guardian_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/am335x_guardian_defconfig b/configs/am335x_guardian_defconfig index 200ed4983b..c072b7d812 100644 --- a/configs/am335x_guardian_defconfig +++ b/configs/am335x_guardian_defconfig @@ -19,6 +19,7 @@ CONFIG_BOOTSTAGE_STASH_ADDR=0x0 CONFIG_ENV_OFFSET_REDUND=0x540000 CONFIG_SPL_LIBDISK_SUPPORT=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_BOOTDELAY=0 CONFIG_AUTOBOOT_KEYED=y CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n" CONFIG_AUTOBOOT_DELAY_STR="d" From da09ba6f733cf252fd0c366b4cbe9803f14155ef Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:42 +0000 Subject: [PATCH 10/46] configs: am335x_guardian: disable spl command - disable support for spl command Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-11-Gireesh.Hiremath@in.bosch.com --- configs/am335x_guardian_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/am335x_guardian_defconfig b/configs/am335x_guardian_defconfig index c072b7d812..f8d3966e54 100644 --- a/configs/am335x_guardian_defconfig +++ b/configs/am335x_guardian_defconfig @@ -42,7 +42,7 @@ CONFIG_SPL_NET_VCI_STRING="Guardian U-Boot SPL" CONFIG_SPL_POWER_SUPPORT=y CONFIG_SPL_USB_GADGET=y CONFIG_SPL_USB_ETHER=y -CONFIG_CMD_SPL=y +# CONFIG_CMD_SPL is not set CONFIG_CMD_SPL_NAND_OFS=0x0 CONFIG_CMD_ASKENV=y # CONFIG_CMD_FLASH is not set From d364926da3f9680cbaaabc7f976efe05b62d8c76 Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:43 +0000 Subject: [PATCH 11/46] am335x, guardian: update swi logic read boot mode gpio and set the swi status Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-12-Gireesh.Hiremath@in.bosch.com --- board/bosch/guardian/board.c | 16 ++++++++++++++-- include/configs/am335x_guardian.h | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c index 12d047b74b..f14ceaa1f9 100644 --- a/board/bosch/guardian/board.c +++ b/board/bosch/guardian/board.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -205,8 +206,19 @@ static void set_bootmode_env(void) goto err; } - value = dm_gpio_get_value(&boot_mode_desc); - value ? env_set("swi_status", "0") : env_set("swi_status", "1"); + dm_gpio_set_dir_flags(&boot_mode_desc, GPIOD_IS_IN); + udelay(10); + + ret = dm_gpio_get_value(&boot_mode_desc); + if (ret == 0) { + env_set("swi_status", "1"); + } else if (ret == 1) { + env_set("swi_status", "0"); + } else { + printf("swi status gpio error\n"); + goto err; + } + return; err: diff --git a/include/configs/am335x_guardian.h b/include/configs/am335x_guardian.h index 814048bf86..c76f9b26fb 100644 --- a/include/configs/am335x_guardian.h +++ b/include/configs/am335x_guardian.h @@ -64,13 +64,13 @@ "setenv rootflags \"bulk_read,chk_data_crc\"; " \ "setenv ethact usb_ether; " \ "if test \"${swi_status}\" -eq 1; then " \ - "setenv extrabootargs \"swi_attached\"; " \ "if dhcp; then " \ "sleep 1; " \ "if tftp \"${tftp_load_addr}\" \"bootscript.scr\"; then " \ "source \"${tftp_load_addr}\"; " \ "fi; " \ "fi; " \ + "setenv extrabootargs $extrabootargs \"swi_attached\"; " \ "fi;" \ "run bootcmd_ubifs0;\0" \ "altbootcmd=" \ From ae628fb6dac3e18c4636121a3fdc11a9677ef5dd Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:44 +0000 Subject: [PATCH 12/46] am335x, guardian: Enable backlight Enable backlight, set brightness value and dimming frequency Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-13-Gireesh.Hiremath@in.bosch.com --- board/bosch/guardian/board.c | 26 ++++++++++++++++++++++++++ include/configs/am335x_guardian.h | 1 + 2 files changed, 27 insertions(+) diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c index f14ceaa1f9..4388ef70d2 100644 --- a/board/bosch/guardian/board.c +++ b/board/bosch/guardian/board.c @@ -225,12 +225,38 @@ err: env_set("swi_status", "err"); } +void lcdbacklight_en(void) +{ + unsigned long brightness = env_get_ulong("backlight_brightness", 10, 50); + + if (brightness > 99 || brightness == 0) + brightness = 99; + + /* + * Brightness range: + * WLEDCTRL2 DUTY[6:0] + * + * 000 0000b = 1% + * 000 0001b = 2% + * ... + * 110 0010b = 99% + * 110 0011b = 100% + * + */ + + tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, TPS65217_WLEDCTRL2, + brightness, 0xFF); + tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, TPS65217_WLEDCTRL1, + brightness != 0 ? 0x0A : 0x02, 0xFF); +} + int board_late_init(void) { #ifdef CONFIG_LED_GPIO led_default_state(); #endif set_bootmode_env(); + lcdbacklight_en(); return 0; } #endif /* CONFIG_BOARD_LATE_INIT */ diff --git a/include/configs/am335x_guardian.h b/include/configs/am335x_guardian.h index c76f9b26fb..73248292f2 100644 --- a/include/configs/am335x_guardian.h +++ b/include/configs/am335x_guardian.h @@ -59,6 +59,7 @@ BOOTENV \ GUARDIAN_DEFAULT_PROD_ENV \ "autoload=no\0" \ + "backlight_brightness=50\0" \ "bootubivol=rootfs\0" \ "distro_bootcmd=" \ "setenv rootflags \"bulk_read,chk_data_crc\"; " \ From 321c5b7cd789b220ea7831362bc4b722f129acaa Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:45 +0000 Subject: [PATCH 13/46] configs: am335x_guardian: Enable display config -Enable configuration for display driver -Disable support for SPL GPIO, CMD LED & SPL GPIO Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-14-Gireesh.Hiremath@in.bosch.com --- configs/am335x_guardian_defconfig | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/configs/am335x_guardian_defconfig b/configs/am335x_guardian_defconfig index f8d3966e54..de35a997eb 100644 --- a/configs/am335x_guardian_defconfig +++ b/configs/am335x_guardian_defconfig @@ -1,7 +1,7 @@ CONFIG_ARM=y CONFIG_ARCH_CPU_INIT=y CONFIG_ARCH_OMAP2PLUS=y -CONFIG_SPL_GPIO_SUPPORT=y +# CONFIG_SPL_GPIO_SUPPORT is not set CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_ENV_SIZE=0x40000 @@ -55,8 +55,7 @@ CONFIG_CMD_MTD=y CONFIG_CMD_NAND=y CONFIG_CMD_USB=y # CONFIG_CMD_SETEXPR is not set -CONFIG_BOOTP_DNS2=y -# CONFIG_CMD_LED is not set +CONFIG_CMD_BMP=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_MTDPARTS=y CONFIG_MTDPARTS_DEFAULT="mtdparts=nand.0:256k(SPL),256k(SPL.backup1),256k(SPL.backup2),256k(SPL.backup3),1m(u-boot),1m(u-boot.backup1),1m(u-boot-2),1m(u-boot-2.backup1),256k(u-boot-env),256k(u-boot-env.backup1),256k(splash-screen),-(UBI)" @@ -99,6 +98,9 @@ CONFIG_PHY=y CONFIG_NOP_PHY=y CONFIG_PINCTRL=y CONFIG_PINCTRL_SINGLE=y +CONFIG_SPI=y +CONFIG_DM_SPI=y +CONFIG_OMAP3_SPI=y CONFIG_USB=y CONFIG_DM_USB_GADGET=y CONFIG_SPL_DM_USB_GADGET=y @@ -111,6 +113,11 @@ CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments" CONFIG_USB_GADGET_VENDOR_NUM=0x0451 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022 CONFIG_USB_ETHER=y +CONFIG_DM_VIDEO=y +CONFIG_DM_PANEL_HX8238D=y +CONFIG_VIDEO_BPP16=y +CONFIG_SYS_WHITE_ON_BLACK=y +CONFIG_AM335X_LCD=y CONFIG_SPL_WDT=y # CONFIG_SPL_USE_TINY_PRINTF is not set CONFIG_SPL_OF_LIBFDT=y From e81e8af98f16186339860985f43ccc98fde53c58 Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:46 +0000 Subject: [PATCH 14/46] drivers: video: hx8238 fix build bug update panel driver hx8238 fix build bug Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-15-Gireesh.Hiremath@in.bosch.com --- drivers/video/Makefile | 2 +- drivers/video/hx8238d.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 933f06e9d8..1c534a6f9a 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -15,7 +15,7 @@ obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi-host-uclass.o obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o obj-$(CONFIG_DM_VIDEO) += video_bmp.o obj-$(CONFIG_PANEL) += panel-uclass.o -obj-$(CONFIG_PANEL_HX8238D) += hx8238d.o +obj-$(CONFIG_DM_PANEL_HX8238D) += hx8238d.o obj-$(CONFIG_SIMPLE_PANEL) += simple_panel.o endif diff --git a/drivers/video/hx8238d.c b/drivers/video/hx8238d.c index f7e7753a53..6ee97cb4ff 100644 --- a/drivers/video/hx8238d.c +++ b/drivers/video/hx8238d.c @@ -191,7 +191,7 @@ U_BOOT_DRIVER(hx8238d) = { .name = "hx8238d", .id = UCLASS_PANEL, .of_match = hx8238d_ids, - .ofdata_to_platdata = hx8238d_ofdata_to_platdata, + .of_to_plat = hx8238d_ofdata_to_platdata, .probe = hx8238d_probe, - .priv_auto_alloc_size = sizeof(struct hx8238d_priv), + .priv_auto = sizeof(struct hx8238d_priv), }; From 9cd380ef5ff668b5850429f3fbcf141af4eb2202 Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:47 +0000 Subject: [PATCH 15/46] am335x, guardian: Enable panel driver Himax HX8238D - Enable lcd controller - Display splash screen Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-16-Gireesh.Hiremath@in.bosch.com --- arch/arm/dts/am335x-guardian-u-boot.dtsi | 11 +++ arch/arm/dts/am335x-guardian.dts | 8 ++- arch/arm/mach-omap2/am33xx/Kconfig | 2 + board/bosch/guardian/board.c | 87 +++++++++++++++++++++++- board/bosch/guardian/mux.c | 3 +- include/configs/am335x_guardian.h | 11 +++ 6 files changed, 119 insertions(+), 3 deletions(-) diff --git a/arch/arm/dts/am335x-guardian-u-boot.dtsi b/arch/arm/dts/am335x-guardian-u-boot.dtsi index 986f58e664..a1a7913de8 100644 --- a/arch/arm/dts/am335x-guardian-u-boot.dtsi +++ b/arch/arm/dts/am335x-guardian-u-boot.dtsi @@ -42,6 +42,17 @@ u-boot,dm-pre-reloc; }; +&spi0 { + lcd0: display@0 { + compatible = "himax,hx8238d"; + pinctrl-names = "default"; + pinctrl-0 = <&lcd0_pins>; + reg = <0>; + label = "lcd"; + spi-max-frequency = <100000>; + }; +}; + &uart0 { u-boot,dm-pre-reloc; }; diff --git a/arch/arm/dts/am335x-guardian.dts b/arch/arm/dts/am335x-guardian.dts index 207246b4e0..69bee45848 100644 --- a/arch/arm/dts/am335x-guardian.dts +++ b/arch/arm/dts/am335x-guardian.dts @@ -87,7 +87,7 @@ ac-bias = <255>; ac-bias-intrpt = <0>; dma-burst-sz = <16>; - bpp = <24>; + bpp = <16>; bus-width = <16>; fdd = <0x80>; sync-edge = <0>; @@ -247,6 +247,12 @@ &lcdc { blue-and-red-wiring = "crossed"; status = "okay"; + + port { + lcdc_0: endpoint@0 { + remote-endpoint = <0>; + }; + }; }; &mmc1 { diff --git a/arch/arm/mach-omap2/am33xx/Kconfig b/arch/arm/mach-omap2/am33xx/Kconfig index 11e54cd293..65f43944fe 100644 --- a/arch/arm/mach-omap2/am33xx/Kconfig +++ b/arch/arm/mach-omap2/am33xx/Kconfig @@ -95,6 +95,8 @@ config TARGET_AM335X_GUARDIAN select DM_SERIAL select DM_GPIO select DM_USB + select DM_VIDEO + select DM_PANEL_HX8238D config TARGET_AM335X_SL50 bool "Support am335x_sl50" diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c index 4388ef70d2..179511a670 100644 --- a/board/bosch/guardian/board.c +++ b/board/bosch/guardian/board.c @@ -26,12 +26,16 @@ #include #include #include -#include #include #include #include #include #include +#include +#include +#include +#include +#include #include "board.h" DECLARE_GLOBAL_DATA_PTR; @@ -250,13 +254,94 @@ void lcdbacklight_en(void) brightness != 0 ? 0x0A : 0x02, 0xFF); } +#if IS_ENABLED(CONFIG_AM335X_LCD) +static void splash_screen(void) +{ + struct udevice *video_dev; + struct udevice *console_dev; + struct video_priv *vid_priv; + struct mtd_info *mtd; + size_t len; + int ret; + + struct mtd_device *mtd_dev; + struct part_info *part; + u8 pnum; + + ret = uclass_get_device(UCLASS_VIDEO, 0, &video_dev); + if (ret != 0) { + debug("video device not found\n"); + goto exit; + } + + vid_priv = dev_get_uclass_priv(video_dev); + mtdparts_init(); + + if (find_dev_and_part(SPLASH_SCREEN_NAND_PART, &mtd_dev, &pnum, &part)) { + debug("Could not find nand partition\n"); + goto splash_screen_text; + } + + mtd = get_nand_dev_by_index(mtd_dev->id->num); + if (!mtd) { + debug("MTD partition is not valid\n"); + goto splash_screen_text; + } + + len = SPLASH_SCREEN_BMP_FILE_SIZE; + ret = nand_read_skip_bad(mtd, part->offset, &len, NULL, + SPLASH_SCREEN_BMP_FILE_SIZE, + (u_char *)SPLASH_SCREEN_BMP_LOAD_ADDR); + if (ret != 0) { + debug("Reading NAND partition failed\n"); + goto splash_screen_text; + } + + ret = video_bmp_display(video_dev, SPLASH_SCREEN_BMP_LOAD_ADDR, 0, 0, false); + if (ret != 0) { + debug("No valid bmp image found!!\n"); + goto splash_screen_text; + } else { + goto exit; + } + +splash_screen_text: + vid_priv->colour_fg = CONSOLE_COLOR_RED; + vid_priv->colour_bg = CONSOLE_COLOR_BLACK; + + if (!uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &console_dev)) { + debug("Found console\n"); + vidconsole_position_cursor(console_dev, 17, 7); + vidconsole_put_string(console_dev, SPLASH_SCREEN_TEXT); + } else { + debug("No console device found\n"); + } + +exit: + return; +} +#endif /* CONFIG_AM335X_LCD */ + int board_late_init(void) { + int ret; + struct udevice *cdev; + #ifdef CONFIG_LED_GPIO led_default_state(); #endif set_bootmode_env(); + + ret = uclass_get_device(UCLASS_PANEL, 0, &cdev); + if (ret) { + debug("video panel not found: %d\n", ret); + return ret; + } + lcdbacklight_en(); + if (IS_ENABLED(CONFIG_AM335X_LCD)) + splash_screen(); + return 0; } #endif /* CONFIG_BOARD_LATE_INIT */ diff --git a/board/bosch/guardian/mux.c b/board/bosch/guardian/mux.c index 9c81f29f9f..12c3eb666f 100644 --- a/board/bosch/guardian/mux.c +++ b/board/bosch/guardian/mux.c @@ -28,8 +28,9 @@ static struct module_pin_mux i2c0_pin_mux[] = { static struct module_pin_mux guardian_interfaces_pin_mux[] = { {OFFSET(mcasp0_ahclkx), (MODE(7) | PULLDOWN_EN)}, + {OFFSET(mii1_txen), (MODE(7) | PULLDOWN_EN)}, {OFFSET(mcasp0_aclkx), (MODE(7) | PULLUP_EN)}, - {OFFSET(mii1_txd0), (MODE(7) | PULLUP_EN)}, + {OFFSET(mdio_clk), (MODE(7) | PULLUP_EN)}, {OFFSET(uart1_rxd), (MODE(7) | RXACTIVE | PULLUDDIS)}, {OFFSET(uart1_txd), (MODE(7) | PULLUDDIS)}, {OFFSET(mii1_crs), (MODE(7) | PULLDOWN_EN)}, diff --git a/include/configs/am335x_guardian.h b/include/configs/am335x_guardian.h index 73248292f2..c161b93352 100644 --- a/include/configs/am335x_guardian.h +++ b/include/configs/am335x_guardian.h @@ -82,6 +82,17 @@ #endif /* ! CONFIG_SPL_BUILD */ +#define CONFIG_BMP_16BPP +#define SPLASH_SCREEN_NAND_PART "nand0,10" +#define SPLASH_SCREEN_BMP_FILE_SIZE 0x26000 +#define SPLASH_SCREEN_BMP_LOAD_ADDR 0x82000000 +#define SPLASH_SCREEN_TEXT "U-Boot" + +/* BGR 16Bit Color Definitions */ +#define CONSOLE_COLOR_BLACK 0x0000 +#define CONSOLE_COLOR_WHITE 0xFFFF +#define CONSOLE_COLOR_RED 0x001F + /* NS16550 Configuration */ #define CONFIG_SYS_NS16550_COM1 0x44e09000 /* UART0 */ #define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1 */ From caf9478624878687b7098c3037202d8892b1dee6 Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:48 +0000 Subject: [PATCH 16/46] am335x, guardian: software update available status is stored in AM3352 RTC scracth register RTC second scratch register[32-bit]: -zero byte hold boot count value -first byte hold update available state -second byte hold version -third byte hold magic number Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-17-Gireesh.Hiremath@in.bosch.com Gbp-Pq: Topic apertis/guardian Gbp-Pq: Name am335x-guardian-software-update-available-status-is-store.patch --- drivers/bootcount/Kconfig | 34 +++++++++++++++-- drivers/bootcount/Makefile | 1 + drivers/bootcount/bootcount_nvmem.c | 57 +++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 drivers/bootcount/bootcount_nvmem.c diff --git a/drivers/bootcount/Kconfig b/drivers/bootcount/Kconfig index b5ccea0d9c..0de2b7bd78 100644 --- a/drivers/bootcount/Kconfig +++ b/drivers/bootcount/Kconfig @@ -42,6 +42,25 @@ config BOOTCOUNT_AM33XX This requires the RTC clocks, etc, to be enabled prior to use and not all boards with this IP block on it will have the RTC in use. +config BOOTCOUNT_AM33XX_NVMEM + bool "Boot counter in AM33XX RTC IP block with upgrade_available flag" + depends on AM33XX + select SPL_AM33XX_ENABLE_RTC32K_OSC if AM33XX + help + Add support for maintaining bootcount,upgrade_available, + version and BOOTMAGIC in a AM33xx RTC IP block + scratch register2. + + A bootcount driver for the RTC IP block found on many TI platforms. + This requires the RTC clocks, etc, to be enabled prior to use and + not all boards with this IP block on it will have the RTC in use. + + If there is upgrade in software then "upgrade_available" is 1, + "bootcount" is incremented otherwise "upgrade_available" and + "bootcount" is always 0. So the Userspace Application must set + the "upgrade_available" and "bootcount" variable to 0, if a boot + was successfully. + config BOOTCOUNT_ENV bool "Boot counter in environment" help @@ -177,16 +196,25 @@ config SYS_BOOTCOUNT_EXT_NAME config SYS_BOOTCOUNT_ADDR hex "RAM address used for reading and writing the boot counter" - default 0x44E3E000 if BOOTCOUNT_AM33XX + default 0x44E3E000 if BOOTCOUNT_AM33XX || BOOTCOUNT_AM33XX_NVMEM default 0xE0115FF8 if ARCH_LS1043A || ARCH_LS1021A depends on BOOTCOUNT_AM33XX || BOOTCOUNT_GENERIC || BOOTCOUNT_EXT || \ - BOOTCOUNT_I2C + BOOTCOUNT_I2C || BOOTCOUNT_AM33XX_NVMEM help Set the address used for reading and writing the boot counter. config SYS_BOOTCOUNT_MAGIC hex "Magic value for the boot counter" - default 0xB001C041 + default 0xB001C041 if BOOTCOUNT_GENERIC || BOOTCOUNT_EXT || \ + BOOTCOUNT_AM33XX || BOOTCOUNT_ENV || \ + BOOTCOUNT_RAM || BOOTCOUNT_I2C || \ + BOOTCOUNT_AT91 || DM_BOOTCOUNT + default 0xB0 if BOOTCOUNT_AM33XX_NVMEM + depends on BOOTCOUNT_GENERIC || BOOTCOUNT_EXT || \ + BOOTCOUNT_AM33XX || BOOTCOUNT_ENV || \ + BOOTCOUNT_RAM || BOOTCOUNT_I2C || \ + BOOTCOUNT_AT91 || DM_BOOTCOUNT || \ + BOOTCOUNT_AM33XX_NVMEM help Set the magic value used for the boot counter. diff --git a/drivers/bootcount/Makefile b/drivers/bootcount/Makefile index 51d860b00e..12658ffdce 100644 --- a/drivers/bootcount/Makefile +++ b/drivers/bootcount/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_BOOTCOUNT_RAM) += bootcount_ram.o obj-$(CONFIG_BOOTCOUNT_ENV) += bootcount_env.o obj-$(CONFIG_BOOTCOUNT_I2C) += bootcount_i2c.o obj-$(CONFIG_BOOTCOUNT_EXT) += bootcount_ext.o +obj-$(CONFIG_BOOTCOUNT_AM33XX_NVMEM) += bootcount_nvmem.o obj-$(CONFIG_DM_BOOTCOUNT) += bootcount-uclass.o obj-$(CONFIG_DM_BOOTCOUNT_RTC) += rtc.o diff --git a/drivers/bootcount/bootcount_nvmem.c b/drivers/bootcount/bootcount_nvmem.c new file mode 100644 index 0000000000..5f266d5ec8 --- /dev/null +++ b/drivers/bootcount/bootcount_nvmem.c @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2011 + * Heiko Schocher, DENX Software Engineering, hs@denx.de. + * (C) Copyright 2018 Robert Bosch Power Tools GmbH. + * + * A bootcount driver for the RTC IP block found on many TI platforms. + * This requires the RTC clocks, etc, to be enabled prior to use and + * not all boards with this IP block on it will have the RTC in use. + */ + +#include +#include + +#define BC_VERSION 2 + +void bootcount_store(ulong bootcount) +{ + u8 upgrade_available = 0; + ulong val = 0; + struct davinci_rtc *reg = + (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR; + + val = raw_bootcount_load(®->scratch2); + upgrade_available = (val >> 8) & 0x000000ff; + + /* Only update bootcount during upgrade process */ + if (!upgrade_available) + bootcount = 0; + + val = (bootcount & 0x000000ff) | + (upgrade_available << 8) | + (BC_VERSION << 16) | + (CONFIG_SYS_BOOTCOUNT_MAGIC << 24); + + /* + * write RTC kick registers to enable write + * for RTC Scratch registers. Scratch register 2 is + * used for bootcount value. + */ + writel(RTC_KICK0R_WE, ®->kick0r); + writel(RTC_KICK1R_WE, ®->kick1r); + raw_bootcount_store(®->scratch2, val); +} + +ulong bootcount_load(void) +{ + unsigned long val = 0; + struct davinci_rtc *reg = + (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR; + + val = raw_bootcount_load(®->scratch2); + if ((val >> 24) != CONFIG_SYS_BOOTCOUNT_MAGIC) + return 0; + else + return val & 0x000000ff; +} From 83a7ec0fbc73a42322458d146b836642737fd6ac Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:49 +0000 Subject: [PATCH 17/46] configs: am335x_guardian: Enable bootcount nvmem support include bootcount nvmem support Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-18-Gireesh.Hiremath@in.bosch.com --- configs/am335x_guardian_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/am335x_guardian_defconfig b/configs/am335x_guardian_defconfig index de35a997eb..5eaa4398e9 100644 --- a/configs/am335x_guardian_defconfig +++ b/configs/am335x_guardian_defconfig @@ -73,6 +73,7 @@ CONFIG_VERSION_VARIABLE=y CONFIG_BOOTP_SEND_HOSTNAME=y CONFIG_SPL_DM=y CONFIG_BOOTCOUNT_LIMIT=y +CONFIG_BOOTCOUNT_AM33XX_NVMEM=y CONFIG_CLK=y CONFIG_CLK_CCF=y CONFIG_CLK_TI_AM3_DPLL=y From 920e39b2f63e2f969077ddf8830ca47ce4635c28 Mon Sep 17 00:00:00 2001 From: Gireesh Hiremath Date: Fri, 11 Jun 2021 16:13:50 +0000 Subject: [PATCH 18/46] configs: am335x_guardian: add register maps support add support to direct memory access of hardware peripherals registers Signed-off-by: Gireesh Hiremath Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210611161350.2141-19-Gireesh.Hiremath@in.bosch.com --- configs/am335x_guardian_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/am335x_guardian_defconfig b/configs/am335x_guardian_defconfig index 5eaa4398e9..8ae5c678ae 100644 --- a/configs/am335x_guardian_defconfig +++ b/configs/am335x_guardian_defconfig @@ -72,6 +72,7 @@ CONFIG_SPL_ENV_IS_NOWHERE=y CONFIG_VERSION_VARIABLE=y CONFIG_BOOTP_SEND_HOSTNAME=y CONFIG_SPL_DM=y +CONFIG_REGMAP=y CONFIG_BOOTCOUNT_LIMIT=y CONFIG_BOOTCOUNT_AM33XX_NVMEM=y CONFIG_CLK=y From ff8f277e9121c6636e21bb7d7381c4dcac2a596b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 10 Jun 2021 19:01:47 -0400 Subject: [PATCH 19/46] ti: am335x_evm: Switch to DISTRO_BOOT only Remove the environment support for various legacy boot methods. With this, we will now default to booting any distribution that follows the generic distro boot framework and no longer attempt to boot various legacy (to this SoC) scripts/etc. Signed-off-by: Tom Rini Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210610230147.22475-1-trini@konsulko.com --- configs/am335x_boneblack_vboot_defconfig | 2 +- configs/am335x_evm_defconfig | 2 +- configs/am335x_evm_spiboot_defconfig | 2 +- configs/am335x_hs_evm_defconfig | 2 +- configs/am335x_hs_evm_uart_defconfig | 2 +- include/configs/am335x_evm.h | 18 +----------------- 6 files changed, 6 insertions(+), 22 deletions(-) diff --git a/configs/am335x_boneblack_vboot_defconfig b/configs/am335x_boneblack_vboot_defconfig index 498174a1fa..a0baeec79e 100644 --- a/configs/am335x_boneblack_vboot_defconfig +++ b/configs/am335x_boneblack_vboot_defconfig @@ -16,7 +16,7 @@ CONFIG_AUTOBOOT_KEYED=y CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n" CONFIG_AUTOBOOT_DELAY_STR="d" CONFIG_AUTOBOOT_STOP_STR=" " -CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run findfdt; run init_console; run envboot; run distro_bootcmd" +CONFIG_BOOTCOMMAND="run findfdt; run init_console; run finduuid; run distro_bootcmd" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_ARCH_MISC_INIT=y CONFIG_SPL_MUSB_NEW_SUPPORT=y diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index 79fb8b3f8f..a33efff42a 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -9,7 +9,7 @@ CONFIG_DISTRO_DEFAULTS=y CONFIG_SPL_LOAD_FIT=y # CONFIG_USE_SPL_FIT_GENERATOR is not set CONFIG_OF_BOARD_SETUP=y -CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run findfdt; run init_console; run envboot; run distro_bootcmd" +CONFIG_BOOTCOMMAND="run findfdt; run init_console; run finduuid; run distro_bootcmd" CONFIG_LOGLEVEL=3 CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_ARCH_MISC_INIT=y diff --git a/configs/am335x_evm_spiboot_defconfig b/configs/am335x_evm_spiboot_defconfig index 9eb4ae1932..8f0c330674 100644 --- a/configs/am335x_evm_spiboot_defconfig +++ b/configs/am335x_evm_spiboot_defconfig @@ -14,7 +14,7 @@ CONFIG_SPL_SPI_SUPPORT=y CONFIG_DISTRO_DEFAULTS=y CONFIG_SPL_LOAD_FIT=y CONFIG_OF_BOARD_SETUP=y -CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run findfdt; run init_console; run envboot; run distro_bootcmd" +CONFIG_BOOTCOMMAND="run findfdt; run init_console; run finduuid; run distro_bootcmd" CONFIG_LOGLEVEL=3 CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_ARCH_MISC_INIT=y diff --git a/configs/am335x_hs_evm_defconfig b/configs/am335x_hs_evm_defconfig index 3d678fa06a..83815e1131 100644 --- a/configs/am335x_hs_evm_defconfig +++ b/configs/am335x_hs_evm_defconfig @@ -13,7 +13,7 @@ CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y # CONFIG_USE_SPL_FIT_GENERATOR is not set CONFIG_OF_BOARD_SETUP=y -CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run findfdt; run init_console; run envboot; run distro_bootcmd" +CONFIG_BOOTCOMMAND="run findfdt; run init_console; run finduuid; run distro_bootcmd" CONFIG_LOGLEVEL=3 CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_ARCH_MISC_INIT=y diff --git a/configs/am335x_hs_evm_uart_defconfig b/configs/am335x_hs_evm_uart_defconfig index 21ef7d6a44..9c5ac032bd 100644 --- a/configs/am335x_hs_evm_uart_defconfig +++ b/configs/am335x_hs_evm_uart_defconfig @@ -16,7 +16,7 @@ CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y # CONFIG_USE_SPL_FIT_GENERATOR is not set CONFIG_OF_BOARD_SETUP=y -CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run findfdt; run init_console; run envboot; run distro_bootcmd" +CONFIG_BOOTCOMMAND="run findfdt; run init_console; run finduuid; run distro_bootcmd" CONFIG_LOGLEVEL=3 CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_ARCH_MISC_INIT=y diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 5af90d932d..ad5616d28f 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -50,15 +50,6 @@ #define NANDARGS "" #endif -#define BOOTENV_DEV_LEGACY_MMC(devtypeu, devtypel, instance) \ - "bootcmd_" #devtypel #instance "=" \ - "setenv mmcdev " #instance"; "\ - "setenv bootpart " #instance":2 ; "\ - "run mmcboot\0" - -#define BOOTENV_DEV_NAME_LEGACY_MMC(devtypeu, devtypel, instance) \ - #devtypel #instance " " - #define BOOTENV_DEV_NAND(devtypeu, devtypel, instance) \ "bootcmd_" #devtypel "=" \ "run nandboot\0" @@ -86,9 +77,7 @@ #define BOOT_TARGET_DEVICES(func) \ func(MMC, mmc, 0) \ - func(LEGACY_MMC, legacy_mmc, 0) \ func(MMC, mmc, 1) \ - func(LEGACY_MMC, legacy_mmc, 1) \ func(NAND, nand, 0) \ BOOT_TARGET_USB(func) \ BOOT_TARGET_PXE(func) \ @@ -98,16 +87,11 @@ #ifndef CONFIG_SPL_BUILD #include -#include #define CONFIG_EXTRA_ENV_SETTINGS \ DEFAULT_LINUX_BOOT_ENV \ - DEFAULT_MMC_TI_ARGS \ - DEFAULT_FIT_TI_ARGS \ - "bootpart=0:2\0" \ - "bootdir=/boot\0" \ - "bootfile=zImage\0" \ "fdtfile=undefined\0" \ + "finduuid=part uuid mmc 0:2 uuid\0" \ "console=ttyO0,115200n8\0" \ "partitions=" \ "uuid_disk=${uuid_gpt_disk};" \ From 5242c6a43215110de3a9bf53f324b15190d80eae Mon Sep 17 00:00:00 2001 From: Aswath Govindraju Date: Wed, 16 Jun 2021 22:08:20 +0530 Subject: [PATCH 20/46] configs: am64x_evm_a53_defconfig: Move TF-A load address to 0x701c0000 Earlier, the region 0x701c0000 to 0x701dffff was firewalled off because of a bug in SYSFW. In the v2021.05 release of SYSFW this bug has been fixed and this region can now be used for other allocations. Therefore, move TF-A's load address to 0x701c0000 and update its location in the device tree node. Also, increase the size allocated for TF-A to account for future expansions. Fixes: defd62ca137b ("arm: dts: k3-am64-main: Update the location of ATF in SRAM and increase its max size") Signed-off-by: Aswath Govindraju Signed-off-by: Lokesh Vutla Reviewed-by: Suman Anna Link: https://lore.kernel.org/r/20210616163821.20457-2-a-govindraju@ti.com --- arch/arm/dts/k3-am64-main.dtsi | 4 ++-- configs/am64x_evm_a53_defconfig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/dts/k3-am64-main.dtsi b/arch/arm/dts/k3-am64-main.dtsi index 6b5ebec6b1..f68b969a2e 100644 --- a/arch/arm/dts/k3-am64-main.dtsi +++ b/arch/arm/dts/k3-am64-main.dtsi @@ -13,8 +13,8 @@ #size-cells = <1>; ranges = <0x0 0x00 0x70000000 0x200000>; - atf-sram@0 { - reg = <0x1a0000 0x1c000>; + tfa-sram@1c0000 { + reg = <0x1c0000 0x20000>; }; }; diff --git a/configs/am64x_evm_a53_defconfig b/configs/am64x_evm_a53_defconfig index ba3f9ad328..6fab1deeb2 100644 --- a/configs/am64x_evm_a53_defconfig +++ b/configs/am64x_evm_a53_defconfig @@ -5,7 +5,7 @@ CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_SYS_MALLOC_F_LEN=0x8000 CONFIG_NR_DRAM_BANKS=2 CONFIG_SOC_K3_AM642=y -CONFIG_K3_ATF_LOAD_ADDR=0x701a0000 +CONFIG_K3_ATF_LOAD_ADDR=0x701c0000 CONFIG_TARGET_AM642_A53_EVM=y CONFIG_ENV_SIZE=0x20000 CONFIG_SYS_SPI_U_BOOT_OFFS=0x280000 From 776e25788c744fe91f7e720331a17ad0ff050480 Mon Sep 17 00:00:00 2001 From: Aswath Govindraju Date: Wed, 16 Jun 2021 22:08:21 +0530 Subject: [PATCH 21/46] arm: dts: k3-am64-main: Reserve OCMRAM for DMSC-lite and secure proxy communication The final 128KB in SRAM is reserved by default for DMSC-lite code and secure proxy communication buffer. The memory region used for DMSC-lite code can be optionally freed up by secure firmware API[1]. However, the buffer for secure proxy communication is not configurable. This default hardware configuration is unique for AM64. Therefore, indicate the area reserved for DMSC-lite code and secure proxy communication buffer in the oc_sram device tree node. [1] - http://downloads.ti.com/tisci/esd/latest/6_topic_user_guides/security_handover.html#triggering-security-handover Signed-off-by: Aswath Govindraju Signed-off-by: Lokesh Vutla Acked-by: Suman Anna Link: https://lore.kernel.org/r/20210616163821.20457-3-a-govindraju@ti.com --- arch/arm/dts/k3-am64-main.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/dts/k3-am64-main.dtsi b/arch/arm/dts/k3-am64-main.dtsi index f68b969a2e..c5af2ffb8e 100644 --- a/arch/arm/dts/k3-am64-main.dtsi +++ b/arch/arm/dts/k3-am64-main.dtsi @@ -16,6 +16,14 @@ tfa-sram@1c0000 { reg = <0x1c0000 0x20000>; }; + + dmsc-sram@1e0000 { + reg = <0x1e0000 0x1c000>; + }; + + sproxy-sram@1fc000 { + reg = <0x1fc000 0x4000>; + }; }; gic500: interrupt-controller@1800000 { From 7bafe886200803d155eef0e3b9adecc7e346a73e Mon Sep 17 00:00:00 2001 From: Keerthy Date: Tue, 22 Jun 2021 12:04:27 +0530 Subject: [PATCH 22/46] soc: ti: pruss: Add a platform driver for PRUSS in TI SoCs The Programmable Real-Time Unit - Industrial Communication Subsystem (PRU-ICSS) is present of various TI SoCs such as AM335x or AM437x or the AM654x family. Each SoC can have one or more PRUSS instances that may or may not be identical. The PRUSS consists of dual 32-bit RISC cores called the Programmable Real-Time Units (PRUs), some shared, data and instruction memories, some internal peripheral modules, and an interrupt controller. The programmable nature of the PRUs provide flexibility to implement custom peripheral interfaces, fast real-time responses, or specialized data handling. Add support for pruss driver. Currently am654x family is supported. Signed-off-by: Keerthy Signed-off-by: Roger Quadros Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210622063431.3151-2-lokeshvutla@ti.com --- MAINTAINERS | 1 + drivers/soc/ti/Kconfig | 11 ++ drivers/soc/ti/Makefile | 1 + drivers/soc/ti/pruss.c | 217 +++++++++++++++++++++++++++++++++ include/linux/pruss_driver.h | 227 +++++++++++++++++++++++++++++++++++ 5 files changed, 457 insertions(+) create mode 100644 drivers/soc/ti/pruss.c create mode 100644 include/linux/pruss_driver.h diff --git a/MAINTAINERS b/MAINTAINERS index 34ed880387..33ce60d922 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -522,6 +522,7 @@ F: drivers/sysreset/sysreset-ti-sci.c F: drivers/thermal/ti-bandgap.c F: drivers/timer/omap-timer.c F: drivers/watchdog/omap_wdt.c +F: include/linux/pruss_driver.h F: include/linux/soc/ti/ ARM U8500 diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig index e4f8834448..0ee21f9904 100644 --- a/drivers/soc/ti/Kconfig +++ b/drivers/soc/ti/Kconfig @@ -23,4 +23,15 @@ config TI_KEYSTONE_SERDES SerDes driver for Keystone SoC used for ethernet support on TI K2 platforms. +config TI_PRUSS + bool "Support for TI's K3 based Pruss driver" + depends on DM + depends on ARCH_K3 + depends on OF_CONTROL + depends on SYSCON + help + Support for TI PRU-ICSSG subsystem. + Currently supported on AM65xx SoCs Say Y here to support the + Programmable Realtime Unit (PRU). + endif # SOC_TI diff --git a/drivers/soc/ti/Makefile b/drivers/soc/ti/Makefile index 4ec04ee125..34f80aad29 100644 --- a/drivers/soc/ti/Makefile +++ b/drivers/soc/ti/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_TI_K3_NAVSS_RINGACC) += k3-navss-ringacc.o obj-$(CONFIG_TI_KEYSTONE_SERDES) += keystone_serdes.o +obj-$(CONFIG_TI_PRUSS) += pruss.o diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c new file mode 100644 index 0000000000..461390925d --- /dev/null +++ b/drivers/soc/ti/pruss.c @@ -0,0 +1,217 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PRU-ICSS platform driver for various TI SoCs + * + * Copyright (C) 2020-2021 Texas Instruments Incorporated - https://www.ti.com/ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PRUSS_CFG_IEPCLK 0x30 +#define ICSSG_CFG_CORE_SYNC 0x3c + +#define ICSSG_TASK_MGR_OFFSET 0x2a000 + +/* PRUSS_IEPCLK register bits */ +#define PRUSS_IEPCLK_IEP_OCP_CLK_EN BIT(0) + +/* ICSSG CORE_SYNC register bits */ +#define ICSSG_CORE_VBUSP_SYNC_EN BIT(0) + +/* + * pruss_request_tm_region() - Request pruss for task manager region + * @dev: corresponding k3 device + * @loc: the task manager physical address + * + * Return: 0 if all goes good, else appropriate error message. + */ +int pruss_request_tm_region(struct udevice *dev, phys_addr_t *loc) +{ + struct pruss *priv; + + priv = dev_get_priv(dev); + if (!priv || !priv->mem_regions[PRUSS_MEM_DRAM0].pa) + return -EINVAL; + + *loc = priv->mem_regions[PRUSS_MEM_DRAM0].pa + ICSSG_TASK_MGR_OFFSET; + + return 0; +} + +/** + * pruss_request_mem_region() - request a memory resource + * @dev: the pruss device + * @mem_id: the memory resource id + * @region: pointer to memory region structure to be filled in + * + * This function allows a client driver to request a memory resource, + * and if successful, will let the client driver own the particular + * memory region until released using the pruss_release_mem_region() + * API. + * + * Returns the memory region if requested resource is available, an + * error otherwise + */ +int pruss_request_mem_region(struct udevice *dev, enum pruss_mem mem_id, + struct pruss_mem_region *region) +{ + struct pruss *pruss; + + pruss = dev_get_priv(dev); + if (!pruss || !region) + return -EINVAL; + + if (mem_id >= PRUSS_MEM_MAX) + return -EINVAL; + + if (pruss->mem_in_use[mem_id]) + return -EBUSY; + + *region = pruss->mem_regions[mem_id]; + pruss->mem_in_use[mem_id] = region; + + return 0; +} + +/** + * pruss_release_mem_region() - release a memory resource + * @dev: the pruss device + * @region: the memory region to release + * + * This function is the complimentary function to + * pruss_request_mem_region(), and allows the client drivers to + * release back a memory resource. + * + * Returns 0 on success, an error code otherwise + */ +int pruss_release_mem_region(struct udevice *dev, + struct pruss_mem_region *region) +{ + struct pruss *pruss; + int id; + + pruss = dev_get_priv(dev); + if (!pruss || !region) + return -EINVAL; + + /* find out the memory region being released */ + for (id = 0; id < PRUSS_MEM_MAX; id++) { + if (pruss->mem_in_use[id] == region) + break; + } + + if (id == PRUSS_MEM_MAX) + return -EINVAL; + + pruss->mem_in_use[id] = NULL; + + return 0; +} + +/** + * pruss_cfg_update() - configure a PRUSS CFG sub-module register + * @dev: the pruss device + * @reg: register offset within the CFG sub-module + * @mask: bit mask to use for programming the @val + * @val: value to write + * + * Programs a given register within the PRUSS CFG sub-module + * + * Returns 0 on success, or an error code otherwise + */ +int pruss_cfg_update(struct udevice *dev, unsigned int reg, + unsigned int mask, unsigned int val) +{ + struct pruss *pruss; + + pruss = dev_get_priv(dev); + if (IS_ERR_OR_NULL(pruss)) + return -EINVAL; + + return regmap_update_bits(pruss->cfg, reg, mask, val); +} + +/** + * pruss_probe() - Basic probe + * @dev: corresponding k3 device + * + * Return: 0 if all goes good, else appropriate error message. + */ +static int pruss_probe(struct udevice *dev) +{ + const char *mem_names[PRUSS_MEM_MAX] = { "dram0", "dram1", "shrdram2" }; + ofnode sub_node, node, memories; + struct udevice *syscon; + struct pruss *priv; + int ret, idx, i; + + priv = dev_get_priv(dev); + node = dev_ofnode(dev); + priv->dev = dev; + memories = ofnode_find_subnode(node, "memories"); + + for (i = 0; i < ARRAY_SIZE(mem_names); i++) { + idx = ofnode_stringlist_search(memories, "reg-names", mem_names[i]); + priv->mem_regions[i].pa = ofnode_get_addr_size_index(memories, idx, + (u64 *)&priv->mem_regions[i].size); + } + + sub_node = ofnode_find_subnode(node, "cfg"); + ret = uclass_get_device_by_ofnode(UCLASS_SYSCON, sub_node, + &syscon); + + priv->cfg = syscon_get_regmap(syscon); + if (IS_ERR(priv->cfg)) { + dev_err(dev, "unable to get cfg regmap (%ld)\n", + PTR_ERR(priv->cfg)); + return -ENODEV; + } + + /* + * ToDo: To be modelled as clocks. + * The CORE block uses two multiplexers to allow software to + * select one of three source clocks (ICSSGn_CORE_CLK, ICSSGn_ICLK or + * ICSSGn_IEP_CLK) for the final clock source of the CORE block. + * The user needs to configure ICSSG_CORE_SYNC_REG[0] CORE_VBUSP_SYNC_EN + * bit & ICSSG_IEPCLK_REG[0] IEP_OCP_CLK_EN bit in order to select the + * clock source to the CORE block. + */ + ret = regmap_update_bits(priv->cfg, ICSSG_CFG_CORE_SYNC, + ICSSG_CORE_VBUSP_SYNC_EN, + ICSSG_CORE_VBUSP_SYNC_EN); + if (ret) + return ret; + ret = regmap_update_bits(priv->cfg, PRUSS_CFG_IEPCLK, + PRUSS_IEPCLK_IEP_OCP_CLK_EN, + PRUSS_IEPCLK_IEP_OCP_CLK_EN); + if (ret) + return ret; + + dev_dbg(dev, "pruss successfully probed %s\n", dev->name); + + return 0; +} + +static const struct udevice_id pruss_ids[] = { + { .compatible = "ti,am654-icssg"}, + {} +}; + +U_BOOT_DRIVER(pruss) = { + .name = "pruss", + .of_match = pruss_ids, + .id = UCLASS_MISC, + .probe = pruss_probe, + .priv_auto = sizeof(struct pruss), +}; diff --git a/include/linux/pruss_driver.h b/include/linux/pruss_driver.h new file mode 100644 index 0000000000..25272e850e --- /dev/null +++ b/include/linux/pruss_driver.h @@ -0,0 +1,227 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef __TI_PRUSS_H +#define __TI_PRUSS_H + +/* + * PRU_ICSS_CFG registers + * SYSCFG, ISRP, ISP, IESP, IECP, SCRP applicable on AMxxxx devices only + */ +#define PRUSS_CFG_REVID 0x00 +#define PRUSS_CFG_SYSCFG 0x04 +#define PRUSS_CFG_GPCFG(x) (0x08 + (x) * 4) +#define PRUSS_CFG_CGR 0x10 +#define PRUSS_CFG_ISRP 0x14 +#define PRUSS_CFG_ISP 0x18 +#define PRUSS_CFG_IESP 0x1C +#define PRUSS_CFG_IECP 0x20 +#define PRUSS_CFG_SCRP 0x24 +#define PRUSS_CFG_PMAO 0x28 +#define PRUSS_CFG_MII_RT 0x2C +#define PRUSS_CFG_IEPCLK 0x30 +#define PRUSS_CFG_SPP 0x34 +#define PRUSS_CFG_PIN_MX 0x40 + +/* PRUSS_GPCFG register bits */ +#define PRUSS_GPCFG_PRU_GPO_SH_SEL BIT(25) + +#define PRUSS_GPCFG_PRU_DIV1_SHIFT 20 +#define PRUSS_GPCFG_PRU_DIV1_MASK GENMASK(24, 20) + +#define PRUSS_GPCFG_PRU_DIV0_SHIFT 15 +#define PRUSS_GPCFG_PRU_DIV0_MASK GENMASK(15, 19) + +#define PRUSS_GPCFG_PRU_GPO_MODE BIT(14) +#define PRUSS_GPCFG_PRU_GPO_MODE_DIRECT 0 +#define PRUSS_GPCFG_PRU_GPO_MODE_SERIAL BIT(14) + +#define PRUSS_GPCFG_PRU_GPI_SB BIT(13) + +#define PRUSS_GPCFG_PRU_GPI_DIV1_SHIFT 8 +#define PRUSS_GPCFG_PRU_GPI_DIV1_MASK GENMASK(12, 8) + +#define PRUSS_GPCFG_PRU_GPI_DIV0_SHIFT 3 +#define PRUSS_GPCFG_PRU_GPI_DIV0_MASK GENMASK(7, 3) + +#define PRUSS_GPCFG_PRU_GPI_CLK_MODE_POSITIVE 0 +#define PRUSS_GPCFG_PRU_GPI_CLK_MODE_NEGATIVE BIT(2) +#define PRUSS_GPCFG_PRU_GPI_CLK_MODE BIT(2) + +#define PRUSS_GPCFG_PRU_GPI_MODE_MASK GENMASK(1, 0) +#define PRUSS_GPCFG_PRU_GPI_MODE_SHIFT 0 + +#define PRUSS_GPCFG_PRU_MUX_SEL_SHIFT 26 +#define PRUSS_GPCFG_PRU_MUX_SEL_MASK GENMASK(29, 26) + +/* PRUSS_MII_RT register bits */ +#define PRUSS_MII_RT_EVENT_EN BIT(0) + +/* PRUSS_SPP register bits */ +#define PRUSS_SPP_PRU1_PAD_HP_EN BIT(0) +#define PRUSS_SPP_XFER_SHIFT_EN BIT(1) +#define PRUSS_SPP_XFR_BYTE_SHIFT_EN BIT(2) +#define PRUSS_SPP_RTU_XFR_SHIFT_EN BIT(3) + +/** + * enum pruss_gp_mux_sel - PRUSS GPI/O Mux modes for the + * PRUSS_GPCFG0/1 registers + * + * NOTE: The below defines are the most common values, but there + * are some exceptions like on 66AK2G, where the RESERVED and MII2 + * values are interchanged. Also, this bit-field does not exist on + * AM335x SoCs + */ +enum pruss_gp_mux_sel { + PRUSS_GP_MUX_SEL_GP = 0, + PRUSS_GP_MUX_SEL_ENDAT, + PRUSS_GP_MUX_SEL_RESERVED, + PRUSS_GP_MUX_SEL_SD, + PRUSS_GP_MUX_SEL_MII2, + PRUSS_GP_MUX_SEL_MAX, +}; + +/** + * enum pruss_gpi_mode - PRUSS GPI configuration modes, used + * to program the PRUSS_GPCFG0/1 registers + */ +enum pruss_gpi_mode { + PRUSS_GPI_MODE_DIRECT = 0, + PRUSS_GPI_MODE_PARALLEL, + PRUSS_GPI_MODE_28BIT_SHIFT, + PRUSS_GPI_MODE_MII, +}; + +/** + * enum pruss_pru_id - PRU core identifiers + */ +enum pruss_pru_id { + PRUSS_PRU0 = 0, + PRUSS_PRU1, + PRUSS_NUM_PRUS, +}; + +/** + * enum pru_ctable_idx - Configurable Constant table index identifiers + */ +enum pru_ctable_idx { + PRU_C24 = 0, + PRU_C25, + PRU_C26, + PRU_C27, + PRU_C28, + PRU_C29, + PRU_C30, + PRU_C31, +}; + +/** + * enum pruss_mem - PRUSS memory range identifiers + */ +enum pruss_mem { + PRUSS_MEM_DRAM0 = 0, + PRUSS_MEM_DRAM1, + PRUSS_MEM_SHRD_RAM2, + PRUSS_MEM_MAX, +}; + +/** + * struct pruss_mem_region - PRUSS memory region structure + * @va: kernel virtual address of the PRUSS memory region + * @pa: physical (bus) address of the PRUSS memory region + * @size: size of the PRUSS memory region + */ +struct pruss_mem_region { + void __iomem *va; + phys_addr_t pa; + size_t size; +}; + +/** + * struct pruss - PRUSS parent structure + * @dev: pruss device pointer + * @cfg: regmap for config region + * @mem_regions: data for each of the PRUSS memory regions + * @mem_in_use: to indicate if memory resource is in use + */ +struct pruss { + struct udevice *dev; + struct regmap *cfg; + struct pruss_mem_region mem_regions[PRUSS_MEM_MAX]; + struct pruss_mem_region *mem_in_use[PRUSS_MEM_MAX]; +}; + +int pruss_request_tm_region(struct udevice *dev, phys_addr_t *loc); +int pruss_request_mem_region(struct udevice *dev, enum pruss_mem mem_id, + struct pruss_mem_region *region); +int pruss_release_mem_region(struct udevice *dev, struct pruss_mem_region *region); +int pruss_cfg_update(struct udevice *dev, unsigned int reg, + unsigned int mask, unsigned int val); + +/** + * pruss_cfg_gpimode() - set the GPI mode of the PRU + * @dev: the pruss device + * @pru_id: the rproc instance handle of the PRU + * @mode: GPI mode to set + * + * Sets the GPI mode for a given PRU by programming the + * corresponding PRUSS_CFG_GPCFGx register + * + * Returns 0 on success, or an error code otherwise + */ +static inline int pruss_cfg_gpimode(struct udevice *dev, enum pruss_pru_id id, + enum pruss_gpi_mode mode) +{ + if (id < 0) + return -EINVAL; + + return pruss_cfg_update(dev, PRUSS_CFG_GPCFG(id), + PRUSS_GPCFG_PRU_GPI_MODE_MASK, + mode << PRUSS_GPCFG_PRU_GPI_MODE_SHIFT); +} + +/** + * pruss_cfg_miirt_enable() - Enable/disable MII RT Events + * @dev: the pruss device + * @enable: enable/disable + * + * Enable/disable the MII RT Events for the PRUSS. + */ +static inline int pruss_cfg_miirt_enable(struct udevice *dev, bool enable) +{ + u32 set = enable ? PRUSS_MII_RT_EVENT_EN : 0; + + return pruss_cfg_update(dev, PRUSS_CFG_MII_RT, + PRUSS_MII_RT_EVENT_EN, set); +} + +/** + * pruss_cfg_xfr_enable() - Enable/disable XIN XOUT shift functionality + * @dev: the pruss device + * @enable: enable/disable + */ +static inline int pruss_cfg_xfr_enable(struct udevice *dev, bool enable) +{ + u32 set = enable ? PRUSS_SPP_XFER_SHIFT_EN : 0; + + return pruss_cfg_update(dev, PRUSS_CFG_SPP, + PRUSS_SPP_XFER_SHIFT_EN, set); +} + +/** + * pruss_cfg_set_gpmux() - set the GPMUX value for a PRU device + * @pruss: pruss device + * @pru_id: PRU identifier (0-1) + * @mux: new mux value for PRU + */ +static inline int pruss_cfg_set_gpmux(struct udevice *dev, + enum pruss_pru_id id, u8 mux) +{ + if (mux >= PRUSS_GP_MUX_SEL_MAX) + return -EINVAL; + + return pruss_cfg_update(dev, PRUSS_CFG_GPCFG(id), + PRUSS_GPCFG_PRU_MUX_SEL_MASK, + (u32)mux << PRUSS_GPCFG_PRU_MUX_SEL_SHIFT); +} + +#endif /* __TI_PRUSS_H */ From 02bfcc5c3ad6c3b79e4525763778595f9a60f8b0 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Tue, 22 Jun 2021 12:04:28 +0530 Subject: [PATCH 23/46] remoteproc: pru: Add support for various PRU cores on K3 AM65x SoCs The K3 AM65x family of SoCs have the next generation of the PRU-ICSS processor subsystem, commonly referred to as ICSSG. Each ICSSG processor subsystem on AM65x SR1.0 contains two primary PRU cores and two new auxiliary PRU cores called RTUs. The AM65x SR2.0 SoCs have a revised ICSSG IP that is based off the subsequent IP revision used on J721E SoCs. This IP instance has two new custom auxiliary PRU cores called Transmit PRUs (Tx_PRUs) in addition to the existing PRUs and RTUs. Each RTU and Tx_PRU cores have their own dedicated IRAM (smaller than a PRU), Control and debug feature sets, but is different in terms of sub-modules integrated around it and does not have the full capabilities associated with a PRU core. The RTU core is typically used to aid a PRU core in accelerating data transfers, while the Tx_PRU cores is normally used to control the TX L2 FIFO if enabled in Ethernet applications. Both can also be used to run independent applications. The RTU and Tx_PRU cores though share the same Data RAMs as the PRU cores, so the memories have to be partitioned carefully between different applications. The new cores also support a new sub-module called Task Manager to support two different context thread executions. The driver currently supports the AM65xx SoC Signed-off-by: Keerthy Signed-off-by: Suman Anna Signed-off-by: Murali Karicheri Signed-off-by: Roger Quadros Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210622063431.3151-3-lokeshvutla@ti.com --- MAINTAINERS | 1 + drivers/remoteproc/Kconfig | 11 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/pru_rproc.c | 461 +++++++++++++++++++++++++++++++++ 4 files changed, 474 insertions(+) create mode 100644 drivers/remoteproc/pru_rproc.c diff --git a/MAINTAINERS b/MAINTAINERS index 33ce60d922..a6b49b54b9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -513,6 +513,7 @@ F: drivers/phy/phy-ti-am654.c F: drivers/phy/ti-pipe3-phy.c F: drivers/ram/k3* F: drivers/remoteproc/k3_system_controller.c +F: drivers/remoteproc/pruc_rpoc.c F: drivers/remoteproc/ti* F: drivers/reset/reset-ti-sci.c F: drivers/rtc/davinci.c diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 7c2e4804b5..24e536463b 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -81,4 +81,15 @@ config REMOTEPROC_TI_POWER help Say 'y' here to add support for TI power processors such as those found on certain TI keystone and OMAP generation SoCs. + +config REMOTEPROC_TI_PRU + bool "Support for TI's K3 based PRU remoteproc driver" + select REMOTEPROC + depends on DM + depends on TI_PRUSS + depends on ARCH_K3 + depends on OF_CONTROL + help + Say 'y' here to add support for TI' K3 remoteproc driver. + endmenu diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 69ae7bd1e8..f0e83451d6 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -14,3 +14,4 @@ obj-$(CONFIG_REMOTEPROC_TI_K3_ARM64) += ti_k3_arm64_rproc.o obj-$(CONFIG_REMOTEPROC_TI_K3_DSP) += ti_k3_dsp_rproc.o obj-$(CONFIG_REMOTEPROC_TI_K3_R5F) += ti_k3_r5f_rproc.o obj-$(CONFIG_REMOTEPROC_TI_POWER) += ti_power_proc.o +obj-$(CONFIG_REMOTEPROC_TI_PRU) += pru_rproc.o diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c new file mode 100644 index 0000000000..924070a76b --- /dev/null +++ b/drivers/remoteproc/pru_rproc.c @@ -0,0 +1,461 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PRU-RTU remoteproc driver for various SoCs + * + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + * Keerthy + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* PRU_ICSS_PRU_CTRL registers */ +#define PRU_CTRL_CTRL 0x0000 +#define PRU_CTRL_STS 0x0004 +#define PRU_CTRL_WAKEUP_EN 0x0008 +#define PRU_CTRL_CYCLE 0x000C +#define PRU_CTRL_STALL 0x0010 +#define PRU_CTRL_CTBIR0 0x0020 +#define PRU_CTRL_CTBIR1 0x0024 +#define PRU_CTRL_CTPPR0 0x0028 +#define PRU_CTRL_CTPPR1 0x002C + +/* CTRL register bit-fields */ +#define CTRL_CTRL_SOFT_RST_N BIT(0) +#define CTRL_CTRL_EN BIT(1) +#define CTRL_CTRL_SLEEPING BIT(2) +#define CTRL_CTRL_CTR_EN BIT(3) +#define CTRL_CTRL_SINGLE_STEP BIT(8) +#define CTRL_CTRL_RUNSTATE BIT(15) + +#define RPROC_FLAGS_SHIFT 16 +#define RPROC_FLAGS_NONE 0 +#define RPROC_FLAGS_ELF_PHDR BIT(0 + RPROC_FLAGS_SHIFT) +#define RPROC_FLAGS_ELF_SHDR BIT(1 + RPROC_FLAGS_SHIFT) + +/** + * enum pru_mem - PRU core memory range identifiers + */ +enum pru_mem { + PRU_MEM_IRAM = 0, + PRU_MEM_CTRL, + PRU_MEM_DEBUG, + PRU_MEM_MAX, +}; + +struct pru_privdata { + phys_addr_t pru_iram; + phys_addr_t pru_ctrl; + phys_addr_t pru_debug; + fdt_size_t pru_iramsz; + fdt_size_t pru_ctrlsz; + fdt_size_t pru_debugsz; + const char *fw_name; + u32 iram_da; + u32 pdram_da; + u32 sdram_da; + u32 shrdram_da; + u32 bootaddr; + int id; + struct pruss *prusspriv; +}; + +static inline u32 pru_control_read_reg(struct pru_privdata *pru, unsigned int reg) +{ + return readl(pru->pru_ctrl + reg); +} + +static inline +void pru_control_write_reg(struct pru_privdata *pru, unsigned int reg, u32 val) +{ + writel(val, pru->pru_ctrl + reg); +} + +static inline +void pru_control_set_reg(struct pru_privdata *pru, unsigned int reg, + u32 mask, u32 set) +{ + u32 val; + + val = pru_control_read_reg(pru, reg); + val &= ~mask; + val |= (set & mask); + pru_control_write_reg(pru, reg, val); +} + +/** + * pru_rproc_set_ctable() - set the constant table index for the PRU + * @rproc: the rproc instance of the PRU + * @c: constant table index to set + * @addr: physical address to set it to + */ +static int pru_rproc_set_ctable(struct pru_privdata *pru, enum pru_ctable_idx c, u32 addr) +{ + unsigned int reg; + u32 mask, set; + u16 idx; + u16 idx_mask; + + /* pointer is 16 bit and index is 8-bit so mask out the rest */ + idx_mask = (c >= PRU_C28) ? 0xFFFF : 0xFF; + + /* ctable uses bit 8 and upwards only */ + idx = (addr >> 8) & idx_mask; + + /* configurable ctable (i.e. C24) starts at PRU_CTRL_CTBIR0 */ + reg = PRU_CTRL_CTBIR0 + 4 * (c >> 1); + mask = idx_mask << (16 * (c & 1)); + set = idx << (16 * (c & 1)); + + pru_control_set_reg(pru, reg, mask, set); + + return 0; +} + +/** + * pru_start() - start the pru processor + * @dev: corresponding k3 remote processor device + * + * Return: 0 if all goes good, else appropriate error message. + */ +static int pru_start(struct udevice *dev) +{ + struct pru_privdata *priv; + int val = 0; + + priv = dev_get_priv(dev); + + pru_rproc_set_ctable(priv, PRU_C28, 0x100 << 8); + + val = CTRL_CTRL_EN | ((priv->bootaddr >> 2) << 16); + writel(val, priv->pru_ctrl + PRU_CTRL_CTRL); + + return 0; +} + +/** + * pru_stop() - Stop pru processor + * @dev: corresponding k3 remote processor device + * + * Return: 0 if all goes good, else appropriate error message. + */ +static int pru_stop(struct udevice *dev) +{ + struct pru_privdata *priv; + int val = 0; + + priv = dev_get_priv(dev); + + val = readl(priv->pru_ctrl + PRU_CTRL_CTRL); + val &= ~CTRL_CTRL_EN; + writel(val, priv->pru_ctrl + PRU_CTRL_CTRL); + + return 0; +} + +/** + * pru_init() - Initialize the remote processor + * @dev: rproc device pointer + * + * Return: 0 if all went ok, else return appropriate error + */ +static int pru_init(struct udevice *dev) +{ + return 0; +} + +/* + * Convert PRU device address (data spaces only) to kernel virtual address + * + * Each PRU has access to all data memories within the PRUSS, accessible at + * different ranges. So, look through both its primary and secondary Data + * RAMs as well as any shared Data RAM to convert a PRU device address to + * kernel virtual address. Data RAM0 is primary Data RAM for PRU0 and Data + * RAM1 is primary Data RAM for PRU1. + */ +static void *pru_d_da_to_pa(struct pru_privdata *priv, u32 da, int len) +{ + u32 offset; + void *pa = NULL; + phys_addr_t dram0, dram1, shrdram2; + u32 dram0sz, dram1sz, shrdram2sz; + + if (len <= 0) + return NULL; + + dram0 = priv->prusspriv->mem_regions[PRUSS_MEM_DRAM0].pa; + dram1 = priv->prusspriv->mem_regions[PRUSS_MEM_DRAM1].pa; + shrdram2 = priv->prusspriv->mem_regions[PRUSS_MEM_SHRD_RAM2].pa; + dram0sz = priv->prusspriv->mem_regions[PRUSS_MEM_DRAM0].size; + dram1sz = priv->prusspriv->mem_regions[PRUSS_MEM_DRAM1].size; + shrdram2sz = priv->prusspriv->mem_regions[PRUSS_MEM_SHRD_RAM2].size; + + /* PRU1 has its local RAM addresses reversed */ + if (priv->id == 1) { + dram1 = dram0; + dram1sz = dram0sz; + + dram0 = priv->prusspriv->mem_regions[PRUSS_MEM_DRAM1].pa; + dram0sz = priv->prusspriv->mem_regions[PRUSS_MEM_DRAM1].size; + } + + if (da >= priv->pdram_da && da + len <= priv->pdram_da + dram0sz) { + offset = da - priv->pdram_da; + pa = (__force void *)(dram0 + offset); + } else if (da >= priv->sdram_da && + da + len <= priv->sdram_da + dram1sz) { + offset = da - priv->sdram_da; + pa = (__force void *)(dram1 + offset); + } else if (da >= priv->shrdram_da && + da + len <= priv->shrdram_da + shrdram2sz) { + offset = da - priv->shrdram_da; + pa = (__force void *)(shrdram2 + offset); + } + + return pa; +} + +/* + * Convert PRU device address (instruction space) to kernel virtual address + * + * A PRU does not have an unified address space. Each PRU has its very own + * private Instruction RAM, and its device address is identical to that of + * its primary Data RAM device address. + */ +static void *pru_i_da_to_pa(struct pru_privdata *priv, u32 da, int len) +{ + u32 offset; + void *pa = NULL; + + if (len <= 0) + return NULL; + + if (da >= priv->iram_da && + da + len <= priv->iram_da + priv->pru_iramsz) { + offset = da - priv->iram_da; + pa = (__force void *)(priv->pru_iram + offset); + } + + return pa; +} + +/* PRU-specific address translator */ +static void *pru_da_to_pa(struct pru_privdata *priv, u64 da, int len, u32 flags) +{ + void *pa; + u32 exec_flag; + + exec_flag = ((flags & RPROC_FLAGS_ELF_SHDR) ? flags & SHF_EXECINSTR : + ((flags & RPROC_FLAGS_ELF_PHDR) ? flags & PF_X : 0)); + + if (exec_flag) + pa = pru_i_da_to_pa(priv, da, len); + else + pa = pru_d_da_to_pa(priv, da, len); + + return pa; +} + +/* + * Custom memory copy implementation for ICSSG PRU/RTU Cores + * + * The ICSSG PRU/RTU cores have a memory copying issue with IRAM memories, that + * is not seen on previous generation SoCs. The data is reflected properly in + * the IRAM memories only for integer (4-byte) copies. Any unaligned copies + * result in all the other pre-existing bytes zeroed out within that 4-byte + * boundary, thereby resulting in wrong text/code in the IRAMs. Also, the + * IRAM memory port interface does not allow any 8-byte copies (as commonly + * used by ARM64 memcpy implementation) and throws an exception. The DRAM + * memory ports do not show this behavior. Use this custom copying function + * to properly load the PRU/RTU firmware images on all memories for simplicity. + * + * TODO: Improve the function to deal with additional corner cases like + * unaligned copy sizes or sub-integer trailing bytes when the need arises. + */ +static int pru_rproc_memcpy(void *dest, void *src, size_t count) +{ + const int *s = src; + int *d = dest; + int size = count / 4; + int *tmp_src = NULL; + + /* limited to 4-byte aligned addresses and copy sizes */ + if ((long)dest % 4 || count % 4) + return -EINVAL; + + /* src offsets in ELF firmware image can be non-aligned */ + if ((long)src % 4) { + tmp_src = malloc(count); + if (!tmp_src) + return -ENOMEM; + + memcpy(tmp_src, src, count); + s = tmp_src; + } + + while (size--) + *d++ = *s++; + + kfree(tmp_src); + + return 0; +} + +/** + * pru_load() - Load pru firmware + * @dev: corresponding k3 remote processor device + * @addr: Address on the RAM from which firmware is to be loaded + * @size: Size of the pru firmware in bytes + * + * Return: 0 if all goes good, else appropriate error message. + */ +static int pru_load(struct udevice *dev, ulong addr, ulong size) +{ + struct pru_privdata *priv; + Elf32_Ehdr *ehdr; + Elf32_Phdr *phdr; + int i, ret = 0; + + priv = dev_get_priv(dev); + + ehdr = (Elf32_Ehdr *)addr; + phdr = (Elf32_Phdr *)(addr + ehdr->e_phoff); + + /* go through the available ELF segments */ + for (i = 0; i < ehdr->e_phnum; i++, phdr++) { + u32 da = phdr->p_paddr; + u32 memsz = phdr->p_memsz; + u32 filesz = phdr->p_filesz; + u32 offset = phdr->p_offset; + void *ptr; + + if (phdr->p_type != PT_LOAD) + continue; + + dev_dbg(dev, "phdr: type %d da 0x%x memsz 0x%x filesz 0x%x\n", + phdr->p_type, da, memsz, filesz); + + if (filesz > memsz) { + dev_dbg(dev, "bad phdr filesz 0x%x memsz 0x%x\n", + filesz, memsz); + ret = -EINVAL; + break; + } + + if (offset + filesz > size) { + dev_dbg(dev, "truncated fw: need 0x%x avail 0x%zx\n", + offset + filesz, size); + ret = -EINVAL; + break; + } + + /* grab the kernel address for this device address */ + ptr = pru_da_to_pa(priv, da, memsz, + RPROC_FLAGS_ELF_PHDR | phdr->p_flags); + if (!ptr) { + dev_dbg(dev, "bad phdr da 0x%x mem 0x%x\n", da, memsz); + ret = -EINVAL; + break; + } + + /* skip the memzero logic performed by remoteproc ELF loader */ + if (!phdr->p_filesz) + continue; + + ret = pru_rproc_memcpy(ptr, + (void *)addr + phdr->p_offset, filesz); + if (ret) { + dev_dbg(dev, "PRU custom memory copy failed for da 0x%x memsz 0x%x\n", + da, memsz); + break; + } + } + + priv->bootaddr = ehdr->e_entry; + + return ret; +} + +static const struct dm_rproc_ops pru_ops = { + .init = pru_init, + .start = pru_start, + .stop = pru_stop, + .load = pru_load, +}; + +static void pru_set_id(struct pru_privdata *priv, struct udevice *dev) +{ + u32 mask2 = 0x38000; + + if (device_is_compatible(dev, "ti,am654-rtu")) + mask2 = 0x6000; + + if (device_is_compatible(dev, "ti,am654-tx-pru")) + mask2 = 0xc000; + + if ((priv->pru_iram & mask2) == mask2) + priv->id = 1; + else + priv->id = 0; +} + +/** + * pru_probe() - Basic probe + * @dev: corresponding k3 remote processor device + * + * Return: 0 if all goes good, else appropriate error message. + */ +static int pru_probe(struct udevice *dev) +{ + struct pru_privdata *priv; + ofnode node; + + node = dev_ofnode(dev); + + priv = dev_get_priv(dev); + priv->prusspriv = dev_get_priv(dev->parent); + + priv->pru_iram = devfdt_get_addr_size_index(dev, PRU_MEM_IRAM, + &priv->pru_iramsz); + priv->pru_ctrl = devfdt_get_addr_size_index(dev, PRU_MEM_CTRL, + &priv->pru_ctrlsz); + priv->pru_debug = devfdt_get_addr_size_index(dev, PRU_MEM_DEBUG, + &priv->pru_debugsz); + + priv->iram_da = 0; + priv->pdram_da = 0; + priv->sdram_da = 0x2000; + priv->shrdram_da = 0x10000; + + pru_set_id(priv, dev); + + return 0; +} + +static const struct udevice_id pru_ids[] = { + { .compatible = "ti,am654-pru"}, + { .compatible = "ti,am654-rtu"}, + { .compatible = "ti,am654-tx-pru" }, + {} +}; + +U_BOOT_DRIVER(pru) = { + .name = "pru", + .of_match = pru_ids, + .id = UCLASS_REMOTEPROC, + .ops = &pru_ops, + .probe = pru_probe, + .priv_auto = sizeof(struct pru_privdata), +}; From 654b60a8fdb5df9993097183ef8cb46f14f7bf4a Mon Sep 17 00:00:00 2001 From: Lokesh Vutla Date: Tue, 22 Jun 2021 12:04:29 +0530 Subject: [PATCH 24/46] arm: dts: k3-am654-base-board: Add r5 specific u-boot dtsi So far all the u-boot specific properties for both r5 and a53 are placed in k3-am654-base-board-u-boot.dtsi. But there are few a53 nodes that should be updated but doesn't belong to r5. So create a separate r5 specific u-boot dtsi. Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210622063431.3151-4-lokeshvutla@ti.com --- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 205 +---------------- .../dts/k3-am654-r5-base-board-u-boot.dtsi | 207 ++++++++++++++++++ arch/arm/dts/k3-am654-r5-base-board.dts | 2 - 3 files changed, 209 insertions(+), 205 deletions(-) create mode 100644 arch/arm/dts/k3-am654-r5-base-board-u-boot.dtsi diff --git a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi index 2840258518..77b7d3f452 100644 --- a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi +++ b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi @@ -1,207 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2018-2021 Texas Instruments Incorporated - http://www.ti.com/ */ -#include -#include - -/ { - chosen { - stdout-path = "serial2:115200n8"; - }; - - aliases { - serial2 = &main_uart0; - ethernet0 = &cpsw_port1; - usb0 = &usb0; - usb1 = &usb1; - spi0 = &ospi0; - spi1 = &ospi1; - }; -}; - -&cbass_main{ - u-boot,dm-spl; - main-navss { - u-boot,dm-spl; - }; -}; - -&cbass_mcu { - u-boot,dm-spl; - - mcu-navss { - u-boot,dm-spl; - - ringacc@2b800000 { - reg = <0x0 0x2b800000 0x0 0x400000>, - <0x0 0x2b000000 0x0 0x400000>, - <0x0 0x28590000 0x0 0x100>, - <0x0 0x2a500000 0x0 0x40000>, - <0x0 0x28440000 0x0 0x40000>; - reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target", "cfg"; - u-boot,dm-spl; - ti,dma-ring-reset-quirk; - }; - - dma-controller@285c0000 { - reg = <0x0 0x285c0000 0x0 0x100>, - <0x0 0x284c0000 0x0 0x4000>, - <0x0 0x2a800000 0x0 0x40000>, - <0x0 0x284a0000 0x0 0x4000>, - <0x0 0x2aa00000 0x0 0x40000>, - <0x0 0x28400000 0x0 0x2000>; - reg-names = "gcfg", "rchan", "rchanrt", "tchan", - "tchanrt", "rflow"; - u-boot,dm-spl; - }; - }; -}; - -&cbass_wakeup { - u-boot,dm-spl; - - chipid@43000014 { - u-boot,dm-spl; - }; -}; - -&secure_proxy_main { - u-boot,dm-spl; -}; - -&dmsc { - u-boot,dm-spl; - k3_sysreset: sysreset-controller { - compatible = "ti,sci-sysreset"; - u-boot,dm-spl; - }; -}; - -&k3_pds { - u-boot,dm-spl; -}; - -&k3_clks { - u-boot,dm-spl; -}; - -&k3_reset { - u-boot,dm-spl; -}; - -&wkup_pmx0 { - u-boot,dm-spl; - - wkup_i2c0_pins_default { - u-boot,dm-spl; - }; -}; - -&main_pmx0 { - u-boot,dm-spl; - usb0_pins_default: usb0_pins_default { - pinctrl-single,pins = < - AM65X_IOPAD(0x02bc, PIN_OUTPUT, 0) /* (AD9) USB0_DRVVBUS */ - >; - u-boot,dm-spl; - }; -}; - -&main_uart0_pins_default { - u-boot,dm-spl; -}; - -&main_pmx1 { - u-boot,dm-spl; -}; - -&wkup_pmx0 { - mcu-fss0-ospi0-pins-default { - u-boot,dm-spl; - }; -}; - -&main_uart0 { - u-boot,dm-spl; -}; - -&main_mmc0_pins_default { - u-boot,dm-spl; -}; - -&main_mmc1_pins_default { - u-boot,dm-spl; -}; - -&sdhci0 { - u-boot,dm-spl; -}; - -&sdhci1 { - u-boot,dm-spl; -}; - -&davinci_mdio { - phy0: ethernet-phy@0 { - reg = <0>; - /* TODO: phy reset: TCA9555RTWR(i2c:0x21)[p04].GPIO_MCU_RGMII_RSTN */ - ti,rx-internal-delay = ; - ti,fifo-depth = ; - }; -}; - -&mcu_cpsw { - reg = <0x0 0x46000000 0x0 0x200000>, - <0x0 0x40f00200 0x0 0x2>; - reg-names = "cpsw_nuss", "mac_efuse"; - /delete-property/ ranges; - - cpsw-phy-sel@40f04040 { - compatible = "ti,am654-cpsw-phy-sel"; - reg= <0x0 0x40f04040 0x0 0x4>; - reg-names = "gmii-sel"; - }; -}; - -&wkup_i2c0 { - u-boot,dm-spl; -}; - -&usb1 { - dr_mode = "peripheral"; -}; - -&fss { - u-boot,dm-spl; -}; - -&ospi0 { - u-boot,dm-spl; - - flash@0{ - u-boot,dm-spl; - }; -}; - -&dwc3_0 { - status = "okay"; - u-boot,dm-spl; -}; - -&usb0_phy { - status = "okay"; - u-boot,dm-spl; -}; - -&usb0 { - pinctrl-names = "default"; - pinctrl-0 = <&usb0_pins_default>; - dr_mode = "host"; - u-boot,dm-spl; -}; - -&scm_conf { - u-boot,dm-spl; -}; +#include "k3-am654-r5-base-board-u-boot.dtsi" diff --git a/arch/arm/dts/k3-am654-r5-base-board-u-boot.dtsi b/arch/arm/dts/k3-am654-r5-base-board-u-boot.dtsi new file mode 100644 index 0000000000..0f6df5b34b --- /dev/null +++ b/arch/arm/dts/k3-am654-r5-base-board-u-boot.dtsi @@ -0,0 +1,207 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018-2021 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#include +#include + +/ { + chosen { + stdout-path = "serial2:115200n8"; + }; + + aliases { + serial2 = &main_uart0; + ethernet0 = &cpsw_port1; + usb0 = &usb0; + usb1 = &usb1; + spi0 = &ospi0; + spi1 = &ospi1; + }; +}; + +&cbass_main{ + u-boot,dm-spl; + main-navss { + u-boot,dm-spl; + }; +}; + +&cbass_mcu { + u-boot,dm-spl; + + mcu-navss { + u-boot,dm-spl; + + ringacc@2b800000 { + reg = <0x0 0x2b800000 0x0 0x400000>, + <0x0 0x2b000000 0x0 0x400000>, + <0x0 0x28590000 0x0 0x100>, + <0x0 0x2a500000 0x0 0x40000>, + <0x0 0x28440000 0x0 0x40000>; + reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target", "cfg"; + u-boot,dm-spl; + ti,dma-ring-reset-quirk; + }; + + dma-controller@285c0000 { + reg = <0x0 0x285c0000 0x0 0x100>, + <0x0 0x284c0000 0x0 0x4000>, + <0x0 0x2a800000 0x0 0x40000>, + <0x0 0x284a0000 0x0 0x4000>, + <0x0 0x2aa00000 0x0 0x40000>, + <0x0 0x28400000 0x0 0x2000>; + reg-names = "gcfg", "rchan", "rchanrt", "tchan", + "tchanrt", "rflow"; + u-boot,dm-spl; + }; + }; +}; + +&cbass_wakeup { + u-boot,dm-spl; + + chipid@43000014 { + u-boot,dm-spl; + }; +}; + +&secure_proxy_main { + u-boot,dm-spl; +}; + +&dmsc { + u-boot,dm-spl; + k3_sysreset: sysreset-controller { + compatible = "ti,sci-sysreset"; + u-boot,dm-spl; + }; +}; + +&k3_pds { + u-boot,dm-spl; +}; + +&k3_clks { + u-boot,dm-spl; +}; + +&k3_reset { + u-boot,dm-spl; +}; + +&wkup_pmx0 { + u-boot,dm-spl; + + wkup_i2c0_pins_default { + u-boot,dm-spl; + }; +}; + +&main_pmx0 { + u-boot,dm-spl; + usb0_pins_default: usb0_pins_default { + pinctrl-single,pins = < + AM65X_IOPAD(0x02bc, PIN_OUTPUT, 0) /* (AD9) USB0_DRVVBUS */ + >; + u-boot,dm-spl; + }; +}; + +&main_uart0_pins_default { + u-boot,dm-spl; +}; + +&main_pmx1 { + u-boot,dm-spl; +}; + +&wkup_pmx0 { + mcu-fss0-ospi0-pins-default { + u-boot,dm-spl; + }; +}; + +&main_uart0 { + u-boot,dm-spl; +}; + +&main_mmc0_pins_default { + u-boot,dm-spl; +}; + +&main_mmc1_pins_default { + u-boot,dm-spl; +}; + +&sdhci0 { + u-boot,dm-spl; +}; + +&sdhci1 { + u-boot,dm-spl; +}; + +&davinci_mdio { + phy0: ethernet-phy@0 { + reg = <0>; + /* TODO: phy reset: TCA9555RTWR(i2c:0x21)[p04].GPIO_MCU_RGMII_RSTN */ + ti,rx-internal-delay = ; + ti,fifo-depth = ; + }; +}; + +&mcu_cpsw { + reg = <0x0 0x46000000 0x0 0x200000>, + <0x0 0x40f00200 0x0 0x2>; + reg-names = "cpsw_nuss", "mac_efuse"; + /delete-property/ ranges; + + cpsw-phy-sel@40f04040 { + compatible = "ti,am654-cpsw-phy-sel"; + reg= <0x0 0x40f04040 0x0 0x4>; + reg-names = "gmii-sel"; + }; +}; + +&wkup_i2c0 { + u-boot,dm-spl; +}; + +&usb1 { + dr_mode = "peripheral"; +}; + +&fss { + u-boot,dm-spl; +}; + +&ospi0 { + u-boot,dm-spl; + + flash@0{ + u-boot,dm-spl; + }; +}; + +&dwc3_0 { + status = "okay"; + u-boot,dm-spl; +}; + +&usb0_phy { + status = "okay"; + u-boot,dm-spl; +}; + +&usb0 { + pinctrl-names = "default"; + pinctrl-0 = <&usb0_pins_default>; + dr_mode = "host"; + u-boot,dm-spl; +}; + +&scm_conf { + u-boot,dm-spl; +}; diff --git a/arch/arm/dts/k3-am654-r5-base-board.dts b/arch/arm/dts/k3-am654-r5-base-board.dts index 087a3bb3d0..24881c86f2 100644 --- a/arch/arm/dts/k3-am654-r5-base-board.dts +++ b/arch/arm/dts/k3-am654-r5-base-board.dts @@ -330,5 +330,3 @@ &scm_conf { u-boot,dm-spl; }; - -#include "k3-am654-base-board-u-boot.dtsi" From c81e7f8d1772c353d2f7ca84dc9945ca6ac90afd Mon Sep 17 00:00:00 2001 From: Lokesh Vutla Date: Tue, 22 Jun 2021 12:04:30 +0530 Subject: [PATCH 25/46] arm: dts: ti: k3-am65-main: Add ICSSG nodes Add the DT nodes for the ICSSG0, ICSSG1 and ICSSG2 processor subsystems that are present on the K3 AM65x SoCs. The three ICSSGs are identical to each other for the most part, with the ICSSG2 supporting slightly enhanced features for supporting SGMII PRU Ethernet. Each ICSSG instance is represented by a PRUSS subsystem node. These nodes are enabled by default. DT nodes are fetch from Linux 5.13 Kernel. Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210622063431.3151-5-lokeshvutla@ti.com --- arch/arm/dts/k3-am65-main.dtsi | 463 +++++++++++++++++++ arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 72 +++ 2 files changed, 535 insertions(+) diff --git a/arch/arm/dts/k3-am65-main.dtsi b/arch/arm/dts/k3-am65-main.dtsi index cabdba85e0..669484b0dd 100644 --- a/arch/arm/dts/k3-am65-main.dtsi +++ b/arch/arm/dts/k3-am65-main.dtsi @@ -926,4 +926,467 @@ clocks = <&ehrpwm_tbclk 5>, <&k3_clks 45 0>; clock-names = "tbclk", "fck"; }; + + icssg0: icssg@b000000 { + compatible = "ti,am654-icssg"; + reg = <0x00 0xb000000 0x00 0x80000>; + power-domains = <&k3_pds 62 TI_SCI_PD_EXCLUSIVE>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x00 0xb000000 0x80000>; + + icssg0_mem: memories@0 { + reg = <0x0 0x2000>, + <0x2000 0x2000>, + <0x10000 0x10000>; + reg-names = "dram0", "dram1", + "shrdram2"; + }; + + icssg0_cfg: cfg@26000 { + compatible = "ti,pruss-cfg", "syscon"; + reg = <0x26000 0x200>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x26000 0x2000>; + + clocks { + #address-cells = <1>; + #size-cells = <0>; + + icssg0_coreclk_mux: coreclk-mux@3c { + reg = <0x3c>; + #clock-cells = <0>; + clocks = <&k3_clks 62 19>, /* icssg0_core_clk */ + <&k3_clks 62 3>; /* icssg0_iclk */ + assigned-clocks = <&icssg0_coreclk_mux>; + assigned-clock-parents = <&k3_clks 62 3>; + }; + + icssg0_iepclk_mux: iepclk-mux@30 { + reg = <0x30>; + #clock-cells = <0>; + clocks = <&k3_clks 62 10>, /* icssg0_iep_clk */ + <&icssg0_coreclk_mux>; /* core_clk */ + assigned-clocks = <&icssg0_iepclk_mux>; + assigned-clock-parents = <&icssg0_coreclk_mux>; + }; + }; + }; + + icssg0_iep0: iep@2e000 { + compatible = "ti,am654-icss-iep"; + reg = <0x2e000 0x1000>; + clocks = <&icssg0_iepclk_mux>; + }; + + icssg0_iep1: iep@2f000 { + compatible = "ti,am654-icss-iep"; + reg = <0x2f000 0x1000>; + clocks = <&icssg0_iepclk_mux>; + }; + + icssg0_mii_rt: mii-rt@32000 { + compatible = "ti,pruss-mii", "syscon"; + reg = <0x32000 0x100>; + }; + + icssg0_mii_g_rt: mii-g-rt@33000 { + compatible = "ti,pruss-mii-g", "syscon"; + reg = <0x33000 0x1000>; + }; + + icssg0_intc: interrupt-controller@20000 { + compatible = "ti,icssg-intc"; + reg = <0x20000 0x2000>; + interrupt-controller; + #interrupt-cells = <3>; + interrupts = , + , + , + , + , + , + , + ; + interrupt-names = "host_intr0", "host_intr1", + "host_intr2", "host_intr3", + "host_intr4", "host_intr5", + "host_intr6", "host_intr7"; + }; + + pru0_0: pru@34000 { + compatible = "ti,am654-pru"; + reg = <0x34000 0x4000>, + <0x22000 0x100>, + <0x22400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-pru0_0-fw"; + }; + + rtu0_0: rtu@4000 { + compatible = "ti,am654-rtu"; + reg = <0x4000 0x2000>, + <0x23000 0x100>, + <0x23400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-rtu0_0-fw"; + }; + + tx_pru0_0: txpru@a000 { + compatible = "ti,am654-tx-pru"; + reg = <0xa000 0x1800>, + <0x25000 0x100>, + <0x25400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-txpru0_0-fw"; + }; + + pru0_1: pru@38000 { + compatible = "ti,am654-pru"; + reg = <0x38000 0x4000>, + <0x24000 0x100>, + <0x24400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-pru0_1-fw"; + }; + + rtu0_1: rtu@6000 { + compatible = "ti,am654-rtu"; + reg = <0x6000 0x2000>, + <0x23800 0x100>, + <0x23c00 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-rtu0_1-fw"; + }; + + tx_pru0_1: txpru@c000 { + compatible = "ti,am654-tx-pru"; + reg = <0xc000 0x1800>, + <0x25800 0x100>, + <0x25c00 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-txpru0_1-fw"; + }; + + icssg0_mdio: mdio@32400 { + compatible = "ti,davinci_mdio"; + reg = <0x32400 0x100>; + clocks = <&k3_clks 62 3>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <0>; + bus_freq = <1000000>; + status = "disabled"; + }; + }; + + icssg1: icssg@b100000 { + compatible = "ti,am654-icssg"; + reg = <0x00 0xb100000 0x00 0x80000>; + power-domains = <&k3_pds 63 TI_SCI_PD_EXCLUSIVE>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x00 0xb100000 0x80000>; + + icssg1_mem: memories@0 { + reg = <0x0 0x2000>, + <0x2000 0x2000>, + <0x10000 0x10000>; + reg-names = "dram0", "dram1", + "shrdram2"; + }; + + icssg1_cfg: cfg@26000 { + compatible = "ti,pruss-cfg", "syscon"; + reg = <0x26000 0x200>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x26000 0x2000>; + + clocks { + #address-cells = <1>; + #size-cells = <0>; + + icssg1_coreclk_mux: coreclk-mux@3c { + reg = <0x3c>; + #clock-cells = <0>; + clocks = <&k3_clks 63 19>, /* icssg1_core_clk */ + <&k3_clks 63 3>; /* icssg1_iclk */ + assigned-clocks = <&icssg1_coreclk_mux>; + assigned-clock-parents = <&k3_clks 63 3>; + }; + + icssg1_iepclk_mux: iepclk-mux@30 { + reg = <0x30>; + #clock-cells = <0>; + clocks = <&k3_clks 63 10>, /* icssg1_iep_clk */ + <&icssg1_coreclk_mux>; /* core_clk */ + assigned-clocks = <&icssg1_iepclk_mux>; + assigned-clock-parents = <&icssg1_coreclk_mux>; + }; + }; + }; + + icssg1_iep0: iep@2e000 { + compatible = "ti,am654-icss-iep"; + reg = <0x2e000 0x1000>; + clocks = <&icssg1_iepclk_mux>; + }; + + icssg1_iep1: iep@2f000 { + compatible = "ti,am654-icss-iep"; + reg = <0x2f000 0x1000>; + clocks = <&icssg1_iepclk_mux>; + }; + + icssg1_mii_rt: mii-rt@32000 { + compatible = "ti,pruss-mii", "syscon"; + reg = <0x32000 0x100>; + }; + + icssg1_mii_g_rt: mii-g-rt@33000 { + compatible = "ti,pruss-mii-g", "syscon"; + reg = <0x33000 0x1000>; + }; + + icssg1_intc: interrupt-controller@20000 { + compatible = "ti,icssg-intc"; + reg = <0x20000 0x2000>; + interrupt-controller; + #interrupt-cells = <3>; + interrupts = , + , + , + , + , + , + , + ; + interrupt-names = "host_intr0", "host_intr1", + "host_intr2", "host_intr3", + "host_intr4", "host_intr5", + "host_intr6", "host_intr7"; + }; + + pru1_0: pru@34000 { + compatible = "ti,am654-pru"; + reg = <0x34000 0x4000>, + <0x22000 0x100>, + <0x22400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-pru1_0-fw"; + }; + + rtu1_0: rtu@4000 { + compatible = "ti,am654-rtu"; + reg = <0x4000 0x2000>, + <0x23000 0x100>, + <0x23400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-rtu1_0-fw"; + }; + + tx_pru1_0: txpru@a000 { + compatible = "ti,am654-tx-pru"; + reg = <0xa000 0x1800>, + <0x25000 0x100>, + <0x25400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-txpru1_0-fw"; + }; + + pru1_1: pru@38000 { + compatible = "ti,am654-pru"; + reg = <0x38000 0x4000>, + <0x24000 0x100>, + <0x24400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-pru1_1-fw"; + }; + + rtu1_1: rtu@6000 { + compatible = "ti,am654-rtu"; + reg = <0x6000 0x2000>, + <0x23800 0x100>, + <0x23c00 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-rtu1_1-fw"; + }; + + tx_pru1_1: txpru@c000 { + compatible = "ti,am654-tx-pru"; + reg = <0xc000 0x1800>, + <0x25800 0x100>, + <0x25c00 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-txpru1_1-fw"; + }; + + icssg1_mdio: mdio@32400 { + compatible = "ti,davinci_mdio"; + reg = <0x32400 0x100>; + clocks = <&k3_clks 63 3>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <0>; + bus_freq = <1000000>; + status = "disabled"; + }; + }; + + icssg2: icssg@b200000 { + compatible = "ti,am654-icssg"; + reg = <0x00 0xb200000 0x00 0x80000>; + power-domains = <&k3_pds 64 TI_SCI_PD_EXCLUSIVE>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x00 0xb200000 0x80000>; + + icssg2_mem: memories@0 { + reg = <0x0 0x2000>, + <0x2000 0x2000>, + <0x10000 0x10000>; + reg-names = "dram0", "dram1", + "shrdram2"; + }; + + icssg2_cfg: cfg@26000 { + compatible = "ti,pruss-cfg", "syscon"; + reg = <0x26000 0x200>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x26000 0x2000>; + + clocks { + #address-cells = <1>; + #size-cells = <0>; + + icssg2_coreclk_mux: coreclk-mux@3c { + reg = <0x3c>; + #clock-cells = <0>; + clocks = <&k3_clks 64 19>, /* icssg1_core_clk */ + <&k3_clks 64 3>; /* icssg1_iclk */ + assigned-clocks = <&icssg2_coreclk_mux>; + assigned-clock-parents = <&k3_clks 64 3>; + }; + + icssg2_iepclk_mux: iepclk-mux@30 { + reg = <0x30>; + #clock-cells = <0>; + clocks = <&k3_clks 64 10>, /* icssg1_iep_clk */ + <&icssg2_coreclk_mux>; /* core_clk */ + assigned-clocks = <&icssg2_iepclk_mux>; + assigned-clock-parents = <&icssg2_coreclk_mux>; + }; + }; + }; + + icssg2_iep0: iep@2e000 { + compatible = "ti,am654-icss-iep"; + reg = <0x2e000 0x1000>; + clocks = <&icssg2_iepclk_mux>; + }; + + icssg2_iep1: iep@2f000 { + compatible = "ti,am654-icss-iep"; + reg = <0x2f000 0x1000>; + clocks = <&icssg2_iepclk_mux>; + }; + + icssg2_mii_rt: mii-rt@32000 { + compatible = "ti,pruss-mii", "syscon"; + reg = <0x32000 0x100>; + }; + + icssg2_mii_g_rt: mii-g-rt@33000 { + compatible = "ti,pruss-mii-g", "syscon"; + reg = <0x33000 0x1000>; + }; + + icssg2_intc: interrupt-controller@20000 { + compatible = "ti,icssg-intc"; + reg = <0x20000 0x2000>; + interrupt-controller; + #interrupt-cells = <3>; + interrupts = , + , + , + , + , + , + , + ; + interrupt-names = "host_intr0", "host_intr1", + "host_intr2", "host_intr3", + "host_intr4", "host_intr5", + "host_intr6", "host_intr7"; + }; + + pru2_0: pru@34000 { + compatible = "ti,am654-pru"; + reg = <0x34000 0x4000>, + <0x22000 0x100>, + <0x22400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-pru2_0-fw"; + }; + + rtu2_0: rtu@4000 { + compatible = "ti,am654-rtu"; + reg = <0x4000 0x2000>, + <0x23000 0x100>, + <0x23400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-rtu2_0-fw"; + }; + + tx_pru2_0: txpru@a000 { + compatible = "ti,am654-tx-pru"; + reg = <0xa000 0x1800>, + <0x25000 0x100>, + <0x25400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-txpru2_0-fw"; + }; + + pru2_1: pru@38000 { + compatible = "ti,am654-pru"; + reg = <0x38000 0x4000>, + <0x24000 0x100>, + <0x24400 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-pru2_1-fw"; + }; + + rtu2_1: rtu@6000 { + compatible = "ti,am654-rtu"; + reg = <0x6000 0x2000>, + <0x23800 0x100>, + <0x23c00 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-rtu2_1-fw"; + }; + + tx_pru2_1: txpru@c000 { + compatible = "ti,am654-tx-pru"; + reg = <0xc000 0x1800>, + <0x25800 0x100>, + <0x25c00 0x100>; + reg-names = "iram", "control", "debug"; + firmware-name = "am65x-txpru2_1-fw"; + }; + + icssg2_mdio: mdio@32400 { + compatible = "ti,davinci_mdio"; + reg = <0x32400 0x100>; + clocks = <&k3_clks 64 3>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <0>; + bus_freq = <1000000>; + status = "disabled"; + }; + }; + }; diff --git a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi index 77b7d3f452..df850a2edb 100644 --- a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi +++ b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi @@ -4,3 +4,75 @@ */ #include "k3-am654-r5-base-board-u-boot.dtsi" + +&pru0_0 { + remoteproc-name = "pru0_0"; +}; + +&rtu0_0 { + remoteproc-name = "rtu0_0"; +}; + +&tx_pru0_0 { + remoteproc-name = "tx_pru0_0"; +}; + +&pru0_1 { + remoteproc-name = "pru0_1"; +}; + +&rtu0_1 { + remoteproc-name = "rtu0_1"; +}; + +&tx_pru0_1 { + remoteproc-name = "tx_pru0_1"; +}; + +&pru1_0 { + remoteproc-name = "pru1_0"; +}; + +&rtu1_0 { + remoteproc-name = "rtu1_0"; +}; + +&tx_pru1_0 { + remoteproc-name = "tx_pru1_0"; +}; + +&pru1_1 { + remoteproc-name = "pru1_1"; +}; + +&rtu1_1 { + remoteproc-name = "rtu1_1"; +}; + +&tx_pru1_1 { + remoteproc-name = "tx_pru1_1"; +}; + +&pru2_0 { + remoteproc-name = "pru2_0"; +}; + +&rtu2_0 { + remoteproc-name = "rtu2_0"; +}; + +&tx_pru2_0 { + remoteproc-name = "tx_pru2_0"; +}; + +&pru2_1 { + remoteproc-name = "pru2_1"; +}; + +&rtu2_1 { + remoteproc-name = "rtu2_1"; +}; + +&tx_pru2_1 { + remoteproc-name = "tx_pru2_1"; +}; From d3ece2bcae6c7cfaaacd22f864edbc689f933b40 Mon Sep 17 00:00:00 2001 From: Lokesh Vutla Date: Tue, 22 Jun 2021 12:04:31 +0530 Subject: [PATCH 26/46] configs: am65x_evm_a53: Enable PRUSS remoteproc Enable PRUSS remoteproc driver for AM65 Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210622063431.3151-6-lokeshvutla@ti.com --- configs/am65x_evm_a53_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/am65x_evm_a53_defconfig b/configs/am65x_evm_a53_defconfig index 6f9309e171..a3f6469cdf 100644 --- a/configs/am65x_evm_a53_defconfig +++ b/configs/am65x_evm_a53_defconfig @@ -141,12 +141,14 @@ CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_REMOTEPROC_TI_K3_R5F=y +CONFIG_REMOTEPROC_TI_PRU=y CONFIG_DM_RESET=y CONFIG_RESET_TI_SCI=y CONFIG_DM_SERIAL=y CONFIG_SOC_DEVICE=y CONFIG_SOC_DEVICE_TI_K3=y CONFIG_SOC_TI=y +CONFIG_TI_PRUSS=y CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_CADENCE_QSPI=y From ba7455a796d29b8bac9767433ccebd4b0899e7fd Mon Sep 17 00:00:00 2001 From: Gowtham Tammana Date: Thu, 24 Jun 2021 12:16:14 -0500 Subject: [PATCH 27/46] arm: mach-k3: am642_init: Add missing ddr guard The `struct udevice *` reference is needed for either of the K3_LOAD_SYSFW, K3_AM64_DDRSS config guards. Adding the missing K3_AM64_DDRSS guard. Signed-off-by: Gowtham Tammana Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210624171614.14244-1-g-tammana@ti.com --- arch/arm/mach-k3/am642_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/am642_init.c b/arch/arm/mach-k3/am642_init.c index 579dbacb7e..0e46d70e84 100644 --- a/arch/arm/mach-k3/am642_init.c +++ b/arch/arm/mach-k3/am642_init.c @@ -141,7 +141,7 @@ int fdtdec_board_setup(const void *fdt_blob) void board_init_f(ulong dummy) { -#if defined(CONFIG_K3_LOAD_SYSFW) +#if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM64_DDRSS) struct udevice *dev; int ret; #endif From 81b98c6627340ffebe3bc9ab6292b538645a2ea8 Mon Sep 17 00:00:00 2001 From: Adam Ford Date: Fri, 25 Jun 2021 13:57:17 -0500 Subject: [PATCH 28/46] configs: omap3x_logic: Fix boot hang by reducing SYS_MALLOC_F_LEN The AM3517 uses SYS_MALLOC_F_LEN of size 0x3000, but the rest of the OMAP3 boards from LogicPD / BeaconEmbedded use 0x4000, but they don't boot SPL. Reduce the malloc size to restore booting. Signed-off-by: Adam Ford Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210625185717.243211-1-aford173@gmail.com --- configs/omap35_logic_defconfig | 2 +- configs/omap35_logic_somlv_defconfig | 2 +- configs/omap3_logic_defconfig | 2 +- configs/omap3_logic_somlv_defconfig | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configs/omap35_logic_defconfig b/configs/omap35_logic_defconfig index 084c1ee741..896fc87c2e 100644 --- a/configs/omap35_logic_defconfig +++ b/configs/omap35_logic_defconfig @@ -5,7 +5,7 @@ CONFIG_ARCH_OMAP2PLUS=y CONFIG_SYS_TEXT_BASE=0x80100000 CONFIG_TI_COMMON_CMD_OPTIONS=y # CONFIG_SPL_GPIO_SUPPORT is not set -CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_MALLOC_F_LEN=0x3000 CONFIG_NR_DRAM_BANKS=2 CONFIG_DEFAULT_DEVICE_TREE="logicpd-torpedo-35xx-devkit" CONFIG_SPL_TEXT_BASE=0x40200000 diff --git a/configs/omap35_logic_somlv_defconfig b/configs/omap35_logic_somlv_defconfig index 7f06249bd3..61b8cad772 100644 --- a/configs/omap35_logic_somlv_defconfig +++ b/configs/omap35_logic_somlv_defconfig @@ -5,7 +5,7 @@ CONFIG_ARCH_OMAP2PLUS=y CONFIG_SYS_TEXT_BASE=0x80100000 CONFIG_TI_COMMON_CMD_OPTIONS=y # CONFIG_SPL_GPIO_SUPPORT is not set -CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_MALLOC_F_LEN=0x3000 CONFIG_NR_DRAM_BANKS=2 CONFIG_DEFAULT_DEVICE_TREE="logicpd-som-lv-35xx-devkit" CONFIG_SPL_TEXT_BASE=0x40200000 diff --git a/configs/omap3_logic_defconfig b/configs/omap3_logic_defconfig index 2371fff8e5..1a7421bd61 100644 --- a/configs/omap3_logic_defconfig +++ b/configs/omap3_logic_defconfig @@ -5,7 +5,7 @@ CONFIG_ARCH_OMAP2PLUS=y CONFIG_SYS_TEXT_BASE=0x80100000 CONFIG_TI_COMMON_CMD_OPTIONS=y # CONFIG_SPL_GPIO_SUPPORT is not set -CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_MALLOC_F_LEN=0x3000 CONFIG_NR_DRAM_BANKS=2 CONFIG_DEFAULT_DEVICE_TREE="logicpd-torpedo-37xx-devkit" CONFIG_SPL_TEXT_BASE=0x40200000 diff --git a/configs/omap3_logic_somlv_defconfig b/configs/omap3_logic_somlv_defconfig index 19b9ff8e4b..fa1bdbe33a 100644 --- a/configs/omap3_logic_somlv_defconfig +++ b/configs/omap3_logic_somlv_defconfig @@ -5,7 +5,7 @@ CONFIG_ARCH_OMAP2PLUS=y CONFIG_SYS_TEXT_BASE=0x80100000 CONFIG_TI_COMMON_CMD_OPTIONS=y # CONFIG_SPL_GPIO_SUPPORT is not set -CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_MALLOC_F_LEN=0x3000 CONFIG_NR_DRAM_BANKS=2 CONFIG_DEFAULT_DEVICE_TREE="logicpd-som-lv-37xx-devkit" CONFIG_SPL_TEXT_BASE=0x40200000 From 1ddd0ed34a9a8392852551a8e54fd10776ccd637 Mon Sep 17 00:00:00 2001 From: Adam Ford Date: Fri, 25 Jun 2021 14:23:06 -0500 Subject: [PATCH 29/46] arm: omap3: Make try_unlock_memory() static try_unlock_memory() is only used in one file, so make it static in that file,remove it from the sys_proto header file, and relocate it into the #ifdef section that call it. This will make it only built under the conditions when it is called, and it may help with some further optimization in the future. Signed-off-by: Adam Ford Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210625192308.277136-2-aford173@gmail.com --- arch/arm/include/asm/arch-omap3/sys_proto.h | 1 - arch/arm/mach-omap2/omap3/board.c | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h index 32ac033515..656f848a73 100644 --- a/arch/arm/include/asm/arch-omap3/sys_proto.h +++ b/arch/arm/include/asm/arch-omap3/sys_proto.h @@ -60,7 +60,6 @@ u32 is_running_in_sram(void); u32 is_running_in_flash(void); u32 get_device_type(void); void secureworld_exit(void); -void try_unlock_memory(void); u32 get_boot_type(void); void invalidate_dcache(u32); u32 wait_on_value(u32, u32, void *, u32); diff --git a/arch/arm/mach-omap2/omap3/board.c b/arch/arm/mach-omap2/omap3/board.c index 029bd54595..ef4fa80c7b 100644 --- a/arch/arm/mach-omap2/omap3/board.c +++ b/arch/arm/mach-omap2/omap3/board.c @@ -140,12 +140,20 @@ void secureworld_exit(void) __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 0":"=r"(i)); } +void early_system_init(void) +{ + hw_data_init(); +} + +#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && \ + !defined(CONFIG_SKIP_LOWLEVEL_INIT_ONLY) + /****************************************************************************** * Routine: try_unlock_sram() * Description: If chip is GP/EMU(special) type, unlock the SRAM for * general use. *****************************************************************************/ -void try_unlock_memory(void) +static void try_unlock_memory(void) { int mode; int in_sdram = is_running_in_sdram(); @@ -174,13 +182,6 @@ void try_unlock_memory(void) return; } -void early_system_init(void) -{ - hw_data_init(); -} - -#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && \ - !defined(CONFIG_SKIP_LOWLEVEL_INIT_ONLY) /****************************************************************************** * Routine: s_init * Description: Does early system init of muxing and clocks. From 46bf58d9f60866b9b57fd73df032874c98a747a6 Mon Sep 17 00:00:00 2001 From: Adam Ford Date: Fri, 25 Jun 2021 14:23:07 -0500 Subject: [PATCH 30/46] arm: omap3: Make secureworld_exit() static secureworld_exit() is only used in one file, so make it static to that file and remove it from sys_proto.h. This may help with some further optimization in the future. Signed-off-by: Adam Ford Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210625192308.277136-3-aford173@gmail.com --- arch/arm/include/asm/arch-omap3/sys_proto.h | 1 - arch/arm/mach-omap2/omap3/board.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h index 656f848a73..a6e9ff84aa 100644 --- a/arch/arm/include/asm/arch-omap3/sys_proto.h +++ b/arch/arm/include/asm/arch-omap3/sys_proto.h @@ -59,7 +59,6 @@ u32 is_running_in_sdram(void); u32 is_running_in_sram(void); u32 is_running_in_flash(void); u32 get_device_type(void); -void secureworld_exit(void); u32 get_boot_type(void); void invalidate_dcache(u32); u32 wait_on_value(u32, u32, void *, u32); diff --git a/arch/arm/mach-omap2/omap3/board.c b/arch/arm/mach-omap2/omap3/board.c index ef4fa80c7b..41d0d3ef69 100644 --- a/arch/arm/mach-omap2/omap3/board.c +++ b/arch/arm/mach-omap2/omap3/board.c @@ -114,7 +114,7 @@ void secure_unlock_mem(void) * configure secure registers and exit secure world * general use. *****************************************************************************/ -void secureworld_exit(void) +static void secureworld_exit(void) { unsigned long i; From 4f9b15eac18d600e8a74ea128bc7428384072464 Mon Sep 17 00:00:00 2001 From: Adam Ford Date: Fri, 25 Jun 2021 14:23:08 -0500 Subject: [PATCH 31/46] arm: omap3: Make secure_unlock_mem() static secure_unlock_mem() is only used in one file, so make it static in that file. Signed-off-by: Adam Ford Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210625192308.277136-4-aford173@gmail.com --- arch/arm/mach-omap2/omap3/board.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-omap2/omap3/board.c b/arch/arm/mach-omap2/omap3/board.c index 41d0d3ef69..363af52845 100644 --- a/arch/arm/mach-omap2/omap3/board.c +++ b/arch/arm/mach-omap2/omap3/board.c @@ -71,12 +71,20 @@ const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx; #endif +void early_system_init(void) +{ + hw_data_init(); +} + +#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && \ + !defined(CONFIG_SKIP_LOWLEVEL_INIT_ONLY) + /****************************************************************************** * Routine: secure_unlock * Description: Setup security registers for access * (GP Device only) *****************************************************************************/ -void secure_unlock_mem(void) +static void secure_unlock_mem(void) { struct pm *pm_rt_ape_base = (struct pm *)PM_RT_APE_BASE_ADDR_ARM; struct pm *pm_gpmc_base = (struct pm *)PM_GPMC_BASE_ADDR_ARM; @@ -140,14 +148,6 @@ static void secureworld_exit(void) __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 0":"=r"(i)); } -void early_system_init(void) -{ - hw_data_init(); -} - -#if !defined(CONFIG_SKIP_LOWLEVEL_INIT) && \ - !defined(CONFIG_SKIP_LOWLEVEL_INIT_ONLY) - /****************************************************************************** * Routine: try_unlock_sram() * Description: If chip is GP/EMU(special) type, unlock the SRAM for From 8cc8c41bc5b8a513b857dad2c8da0946b27a2399 Mon Sep 17 00:00:00 2001 From: Adam Ford Date: Sat, 26 Jun 2021 08:42:58 -0500 Subject: [PATCH 32/46] configs: am3517_evm: Fix boot hang SPL is really tight on space, so decrease a little memory that we allocate in order to fix boot hang. Signed-off-by: Adam Ford Signed-off-by: Lokesh Vutla Tested-by: Derald D. Woods Link: https://lore.kernel.org/r/20210626134258.601331-1-aford173@gmail.com --- configs/am3517_evm_defconfig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/configs/am3517_evm_defconfig b/configs/am3517_evm_defconfig index d9e089e2aa..66185630db 100644 --- a/configs/am3517_evm_defconfig +++ b/configs/am3517_evm_defconfig @@ -10,7 +10,7 @@ CONFIG_DEFAULT_DEVICE_TREE="am3517-evm" CONFIG_SPL_TEXT_BASE=0x40200000 CONFIG_TARGET_AM3517_EVM=y CONFIG_EMIF4=y -CONFIG_SPL_SYS_MALLOC_F_LEN=0x3000 +CONFIG_SPL_SYS_MALLOC_F_LEN=0x2500 CONFIG_SPL=y CONFIG_LTO=y CONFIG_DISTRO_DEFAULTS=y @@ -53,8 +53,6 @@ CONFIG_ENV_IS_IN_NAND=y CONFIG_VERSION_VARIABLE=y CONFIG_BOOTP_SEND_HOSTNAME=y CONFIG_SPL_DM=y -CONFIG_SPL_DM_SEQ_ALIAS=y -CONFIG_SPL_OF_TRANSLATE=y CONFIG_DM_PCA953X=y CONFIG_MMC_OMAP_HS=y CONFIG_MTD=y @@ -84,3 +82,4 @@ CONFIG_USB_MUSB_HOST=y CONFIG_USB_MUSB_AM35X=y CONFIG_BCH=y CONFIG_SPL_TINY_MEMSET=y +# CONFIG_EFI_LOADER is not set From e0c91ae24e5bdd197ae55ae471268ef127fceadd Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 1 Jul 2021 09:26:10 -0400 Subject: [PATCH 33/46] ti: am43xx_evm: Switch to DISTRO_BOOT only Remove the environment support for various legacy boot methods. With this, we will now default to booting any distribution that follows the generic distro boot framework and no longer attempt to boot various legacy (to this SoC) scripts/etc. Signed-off-by: Tom Rini Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210701132612.7559-1-trini@konsulko.com --- configs/am43xx_evm_defconfig | 2 +- configs/am43xx_evm_qspiboot_defconfig | 2 +- configs/am43xx_evm_rtconly_defconfig | 2 +- configs/am43xx_evm_usbhost_boot_defconfig | 2 +- configs/am43xx_hs_evm_defconfig | 2 +- include/configs/am43xx_evm.h | 63 +++++++---------------- 6 files changed, 23 insertions(+), 50 deletions(-) diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig index b73fb9260d..05e7e774c6 100644 --- a/configs/am43xx_evm_defconfig +++ b/configs/am43xx_evm_defconfig @@ -12,7 +12,7 @@ CONFIG_SPL=y CONFIG_DISTRO_DEFAULTS=y CONFIG_SPL_LOAD_FIT=y # CONFIG_USE_SPL_FIT_GENERATOR is not set -# CONFIG_USE_BOOTCOMMAND is not set +CONFIG_BOOTCOMMAND="run findfdt; run finduuid; run distro_bootcmd" CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_MISC_INIT_R is not set CONFIG_SPL_ETH_SUPPORT=y diff --git a/configs/am43xx_evm_qspiboot_defconfig b/configs/am43xx_evm_qspiboot_defconfig index 546669f465..352050204d 100644 --- a/configs/am43xx_evm_qspiboot_defconfig +++ b/configs/am43xx_evm_qspiboot_defconfig @@ -13,7 +13,7 @@ CONFIG_ENV_OFFSET_REDUND=0x120000 CONFIG_DISTRO_DEFAULTS=y CONFIG_SYS_EXTRA_OPTIONS="QSPI,QSPI_BOOT" CONFIG_QSPI_BOOT=y -# CONFIG_USE_BOOTCOMMAND is not set +CONFIG_BOOTCOMMAND="run findfdt; run finduuid; run distro_bootcmd" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_BOARD_EARLY_INIT_F=y # CONFIG_MISC_INIT_R is not set diff --git a/configs/am43xx_evm_rtconly_defconfig b/configs/am43xx_evm_rtconly_defconfig index ed5ce0f380..c8db636e25 100644 --- a/configs/am43xx_evm_rtconly_defconfig +++ b/configs/am43xx_evm_rtconly_defconfig @@ -12,7 +12,7 @@ CONFIG_SPL=y CONFIG_DISTRO_DEFAULTS=y CONFIG_SPL_LOAD_FIT=y # CONFIG_USE_SPL_FIT_GENERATOR is not set -# CONFIG_USE_BOOTCOMMAND is not set +CONFIG_BOOTCOMMAND="run findfdt; run finduuid; run distro_bootcmd" CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_MISC_INIT_R is not set CONFIG_SPL_MTD_SUPPORT=y diff --git a/configs/am43xx_evm_usbhost_boot_defconfig b/configs/am43xx_evm_usbhost_boot_defconfig index b1be0272e7..ae23343409 100644 --- a/configs/am43xx_evm_usbhost_boot_defconfig +++ b/configs/am43xx_evm_usbhost_boot_defconfig @@ -11,7 +11,7 @@ CONFIG_SPL=y CONFIG_DISTRO_DEFAULTS=y CONFIG_SPL_LOAD_FIT=y # CONFIG_USE_SPL_FIT_GENERATOR is not set -# CONFIG_USE_BOOTCOMMAND is not set +CONFIG_BOOTCOMMAND="run findfdt; run finduuid; run distro_bootcmd" CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_MISC_INIT_R is not set CONFIG_SPL_MTD_SUPPORT=y diff --git a/configs/am43xx_hs_evm_defconfig b/configs/am43xx_hs_evm_defconfig index 0f4872993f..f568aa646e 100644 --- a/configs/am43xx_hs_evm_defconfig +++ b/configs/am43xx_hs_evm_defconfig @@ -21,7 +21,7 @@ CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y # CONFIG_USE_SPL_FIT_GENERATOR is not set CONFIG_OF_BOARD_SETUP=y -# CONFIG_USE_BOOTCOMMAND is not set +CONFIG_BOOTCOMMAND="run findfdt; run finduuid; run distro_bootcmd" CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_MISC_INIT_R is not set CONFIG_SPL_ETH_SUPPORT=y diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h index 6df6b49c80..a9ec1aacf3 100644 --- a/include/configs/am43xx_evm.h +++ b/include/configs/am43xx_evm.h @@ -108,59 +108,41 @@ #define DFUARGS #endif +#define BOOTENV_DEV_NAND(devtypeu, devtypel, instance) \ + "bootcmd_" #devtypel "=" \ + "run nandboot\0" + +#define BOOTENV_DEV_NAME_NAND(devtypeu, devtypel, instance) \ + #devtypel #instance " " + +#define BOOT_TARGET_DEVICES(func) \ + func(MMC, mmc, 0) \ + func(USB, usb, 0) \ + func(NAND, nand, 0) \ + func(PXE, pxe, na) \ + func(DHCP, dhcp, na) + +#include + #ifndef CONFIG_SPL_BUILD #include -#include #define CONFIG_EXTRA_ENV_SETTINGS \ DEFAULT_LINUX_BOOT_ENV \ - DEFAULT_MMC_TI_ARGS \ - DEFAULT_FIT_TI_ARGS \ "fdtfile=undefined\0" \ - "bootpart=0:2\0" \ - "bootdir=/boot\0" \ - "bootfile=zImage\0" \ + "finduuid=part uuid mmc 0:2 uuid\0" \ "console=ttyO0,115200n8\0" \ "partitions=" \ "uuid_disk=${uuid_gpt_disk};" \ "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}\0" \ "optargs=\0" \ - "usbroot=/dev/sda2 rw\0" \ - "usbrootfstype=ext4 rootwait\0" \ - "usbdev=0\0" \ "ramroot=/dev/ram0 rw\0" \ "ramrootfstype=ext2\0" \ - "usbargs=setenv bootargs console=${console} " \ - "${optargs} " \ - "root=${usbroot} " \ - "rootfstype=${usbrootfstype}\0" \ "ramargs=setenv bootargs console=${console} " \ "${optargs} " \ "root=${ramroot} " \ "rootfstype=${ramrootfstype}\0" \ "loadramdisk=load ${devtype} ${devnum} ${rdaddr} ramdisk.gz\0" \ - "usbboot=" \ - "setenv devnum ${usbdev}; " \ - "setenv devtype usb; " \ - "usb start ${usbdev}; " \ - "if usb dev ${usbdev}; then " \ - "if run loadbootenv; then " \ - "echo Loaded environment from ${bootenv};" \ - "run importbootenv;" \ - "fi;" \ - "if test -n $uenvcmd; then " \ - "echo Running uenvcmd ...;" \ - "run uenvcmd;" \ - "fi;" \ - "if run loadimage; then " \ - "run loadfdt; " \ - "echo Booting from usb ${usbdev}...; " \ - "run usbargs;" \ - "bootz ${loadaddr} - ${fdtaddr}; " \ - "fi;" \ - "fi\0" \ - "fi;" \ - "usb stop ${usbdev};\0" \ "findfdt="\ "if test $board_name = AM43EPOS; then " \ "setenv fdtfile am43x-epos-evm.dtb; fi; " \ @@ -177,16 +159,7 @@ NANDARGS \ NETARGS \ DFUARGS \ - -#define CONFIG_BOOTCOMMAND \ - "if test ${boot_fit} -eq 1; then " \ - "run update_to_fit;" \ - "fi;" \ - "run findfdt; " \ - "run envboot;" \ - "run mmcboot;" \ - "run usbboot;" \ - NANDBOOT \ + BOOTENV #endif From 8e94e7b32e4585aa7ead1f05a3a4d9db6403b73e Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 1 Jul 2021 09:26:11 -0400 Subject: [PATCH 34/46] arm: ti: environment: Move in to This include file is only used by ti_omap5_common.h. Further, the move is towards using the generic distro boot framework and not this set of macros. Start by moving all of the contents in directly to where they are used. Signed-off-by: Tom Rini Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210701132612.7559-2-trini@konsulko.com --- include/configs/ti_omap5_common.h | 229 +++++++++++++++++++++++++++- include/environment/ti/boot.h | 243 ------------------------------ 2 files changed, 228 insertions(+), 244 deletions(-) delete mode 100644 include/environment/ti/boot.h diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h index de0a6af2fd..dfe69a821e 100644 --- a/include/configs/ti_omap5_common.h +++ b/include/configs/ti_omap5_common.h @@ -32,6 +32,8 @@ #define CONFIG_PALMAS_POWER +#include + #include #include @@ -54,10 +56,235 @@ #define DFUARGS #endif -#include #include #include +#ifndef CONSOLEDEV +#define CONSOLEDEV "ttyS2" +#endif + +#ifndef PARTS_DEFAULT +/* + * Default GPT tables for eMMC (Linux and Android). Notes: + * 1. Keep partitions aligned to erase group size (512 KiB) when possible + * 2. Keep partitions in sync with DFU_ALT_INFO_EMMC (see dfu.h) + * 3. Keep 'bootloader' partition (U-Boot proper) start address in sync with + * CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR (see common/spl/Kconfig) + */ +#define PARTS_DEFAULT \ + /* Linux partitions */ \ + "uuid_disk=${uuid_gpt_disk};" \ + "name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \ + "name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \ + /* Android partitions */ \ + "partitions_android=" \ + "uuid_disk=${uuid_gpt_disk};" \ + "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \ + "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \ + "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \ + "name=misc,size=128K,uuid=${uuid_gpt_misc};" \ + "name=boot_a,size=20M,uuid=${uuid_gpt_boot_a};" \ + "name=boot_b,size=20M,uuid=${uuid_gpt_boot_b};" \ + "name=dtbo_a,size=8M,uuid=${uuid_gpt_dtbo_a};" \ + "name=dtbo_b,size=8M,uuid=${uuid_gpt_dtbo_b};" \ + "name=vbmeta_a,size=64K,uuid=${uuid_gpt_vbmeta_a};" \ + "name=vbmeta_b,size=64K,uuid=${uuid_gpt_vbmeta_b};" \ + "name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \ + "name=super,size=2560M,uuid=${uuid_gpt_super};" \ + "name=metadata,size=16M,uuid=${uuid_gpt_metadata};" \ + "name=userdata,size=-,uuid=${uuid_gpt_userdata}" +#endif /* PARTS_DEFAULT */ + +#if defined(CONFIG_CMD_AVB) +#define AVB_VERIFY_CHECK "if run avb_verify; then " \ + "echo AVB verification OK.;" \ + "set bootargs $bootargs $avb_bootargs;" \ + "else " \ + "echo AVB verification failed.;" \ + "exit; fi;" +#define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify $slot_suffix;\0" +#else +#define AVB_VERIFY_CHECK "" +#define AVB_VERIFY_CMD "" +#endif + +#define CONTROL_PARTITION "misc" + +#if defined(CONFIG_CMD_AB_SELECT) +#define AB_SELECT_SLOT \ + "if part number mmc 1 " CONTROL_PARTITION " control_part_number; " \ + "then " \ + "echo " CONTROL_PARTITION \ + " partition number:${control_part_number};" \ + "ab_select slot_name mmc ${mmcdev}:${control_part_number};" \ + "else " \ + "echo " CONTROL_PARTITION " partition not found;" \ + "exit;" \ + "fi;" \ + "setenv slot_suffix _${slot_name};" +#define AB_SELECT_ARGS \ + "setenv bootargs_ab androidboot.slot_suffix=${slot_suffix}; " \ + "echo A/B cmdline addition: ${bootargs_ab};" \ + "setenv bootargs ${bootargs} ${bootargs_ab};" +#else +#define AB_SELECT_SLOT "" +#define AB_SELECT_ARGS "" +#endif + +/* + * Prepares complete device tree blob for current board (for Android boot). + * + * Boot image or recovery image should be loaded into $loadaddr prior to running + * these commands. The logic of these commnads is next: + * + * 1. Read correct DTB for current SoC/board from boot image in $loadaddr + * to $fdtaddr + * 2. Merge all needed DTBO for current board from 'dtbo' partition into read + * DTB + * 3. User should provide $fdtaddr as 3rd argument to 'bootm' + */ +#define PREPARE_FDT \ + "echo Preparing FDT...; " \ + "if test $board_name = am57xx_evm_reva3; then " \ + "echo \" Reading DTBO partition...\"; " \ + "part start mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_start; " \ + "part size mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_size; " \ + "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \ + "echo \" Reading DTB for AM57x EVM RevA3...\"; " \ + "abootimg get dtb --index=0 dtb_start dtb_size; " \ + "cp.b $dtb_start $fdtaddr $dtb_size; " \ + "fdt addr $fdtaddr 0x80000; " \ + "echo \" Applying DTBOs for AM57x EVM RevA3...\"; " \ + "adtimg addr $dtboaddr; " \ + "adtimg get dt --index=0 dtbo0_addr dtbo0_size; " \ + "fdt apply $dtbo0_addr; " \ + "adtimg get dt --index=1 dtbo1_addr dtbo1_size; " \ + "fdt apply $dtbo1_addr; " \ + "elif test $board_name = beagle_x15_revc; then " \ + "echo \" Reading DTB for Beagle X15 RevC...\"; " \ + "abootimg get dtb --index=0 dtb_start dtb_size; " \ + "cp.b $dtb_start $fdtaddr $dtb_size; " \ + "fdt addr $fdtaddr 0x80000; " \ + "else " \ + "echo Error: Android boot is not supported for $board_name; " \ + "exit; " \ + "fi; " \ + +#define FASTBOOT_CMD \ + "echo Booting into fastboot ...; " \ + "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " + +#define DEFAULT_COMMON_BOOT_TI_ARGS \ + "console=" CONSOLEDEV ",115200n8\0" \ + "fdtfile=undefined\0" \ + "bootpart=0:2\0" \ + "bootdir=/boot\0" \ + "bootfile=zImage\0" \ + "usbtty=cdc_acm\0" \ + "vram=16M\0" \ + AVB_VERIFY_CMD \ + "partitions=" PARTS_DEFAULT "\0" \ + "optargs=\0" \ + "dofastboot=0\0" \ + "emmc_linux_boot=" \ + "echo Trying to boot Linux from eMMC ...; " \ + "setenv mmcdev 1; " \ + "setenv bootpart 1:2; " \ + "setenv mmcroot /dev/mmcblk0p2 rw; " \ + "run mmcboot;\0" \ + "emmc_android_boot=" \ + "setenv mmcdev 1; " \ + "mmc dev $mmcdev; " \ + "mmc rescan; " \ + AB_SELECT_SLOT \ + "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ + CONTROL_PARTITION "; then " \ + "setenv ardaddr -; " \ + "if bcb test command = bootonce-bootloader; then " \ + "echo Android: Bootloader boot...; " \ + "bcb clear command; bcb store; " \ + FASTBOOT_CMD \ + "exit; " \ + "elif bcb test command = boot-recovery; then " \ + "echo Android: Recovery boot...; " \ + "setenv ardaddr $loadaddr;" \ + "setenv apart recovery; " \ + "else " \ + "echo Android: Normal boot...; " \ + "setenv ardaddr $loadaddr; " \ + "setenv apart boot${slot_suffix}; " \ + "fi; " \ + "else " \ + "echo Warning: BCB is corrupted or does not exist; " \ + "echo Android: Normal boot...; " \ + "fi; " \ + "setenv eval_bootargs setenv bootargs $bootargs; " \ + "run eval_bootargs; " \ + "setenv machid fe6; " \ + AVB_VERIFY_CHECK \ + AB_SELECT_ARGS \ + "if part start mmc $mmcdev $apart boot_start; then " \ + "part size mmc $mmcdev $apart boot_size; " \ + "mmc read $loadaddr $boot_start $boot_size; " \ + PREPARE_FDT \ + "bootm $loadaddr $ardaddr $fdtaddr; " \ + "else " \ + "echo $apart partition not found; " \ + "exit; " \ + "fi;\0" + +#define DEFAULT_FDT_TI_ARGS \ + "findfdt="\ + "if test $board_name = omap5_uevm; then " \ + "setenv fdtfile omap5-uevm.dtb; fi; " \ + "if test $board_name = dra7xx; then " \ + "setenv fdtfile dra7-evm.dtb; fi;" \ + "if test $board_name = dra72x-revc; then " \ + "setenv fdtfile dra72-evm-revc.dtb; fi;" \ + "if test $board_name = dra72x; then " \ + "setenv fdtfile dra72-evm.dtb; fi;" \ + "if test $board_name = dra71x; then " \ + "setenv fdtfile dra71-evm.dtb; fi;" \ + "if test $board_name = dra76x_acd; then " \ + "setenv fdtfile dra76-evm.dtb; fi;" \ + "if test $board_name = beagle_x15; then " \ + "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ + "if test $board_name = beagle_x15_revb1; then " \ + "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \ + "if test $board_name = beagle_x15_revc; then " \ + "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \ + "if test $board_name = am5729_beagleboneai; then " \ + "setenv fdtfile am5729-beagleboneai.dtb; fi;" \ + "if test $board_name = am572x_idk; then " \ + "setenv fdtfile am572x-idk.dtb; fi;" \ + "if test $board_name = am574x_idk; then " \ + "setenv fdtfile am574x-idk.dtb; fi;" \ + "if test $board_name = am57xx_evm; then " \ + "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ + "if test $board_name = am57xx_evm_reva3; then " \ + "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ + "if test $board_name = am571x_idk; then " \ + "setenv fdtfile am571x-idk.dtb; fi;" \ + "if test $fdtfile = undefined; then " \ + "echo WARNING: Could not determine device tree to use; fi; \0" + +#define CONFIG_BOOTCOMMAND \ + "if test ${dofastboot} -eq 1; then " \ + "echo Boot fastboot requested, resetting dofastboot ...;" \ + "setenv dofastboot 0; saveenv;" \ + FASTBOOT_CMD \ + "fi;" \ + "if test ${boot_fit} -eq 1; then " \ + "run update_to_fit;" \ + "fi;" \ + "run findfdt; " \ + "run envboot; " \ + "run mmcboot;" \ + "run emmc_linux_boot; " \ + "run emmc_android_boot; " \ + "" + + #define CONFIG_EXTRA_ENV_SETTINGS \ DEFAULT_LINUX_BOOT_ENV \ DEFAULT_MMC_TI_ARGS \ diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h deleted file mode 100644 index a9d8f28d46..0000000000 --- a/include/environment/ti/boot.h +++ /dev/null @@ -1,243 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Boot related environment variable definitions on TI boards. - * - * (C) Copyright 2017 Linaro Ltd. - * Sam Protsenko - */ - -#ifndef __TI_BOOT_H -#define __TI_BOOT_H - -#include - -#ifndef CONSOLEDEV -#define CONSOLEDEV "ttyS2" -#endif - -#ifndef PARTS_DEFAULT -/* - * Default GPT tables for eMMC (Linux and Android). Notes: - * 1. Keep partitions aligned to erase group size (512 KiB) when possible - * 2. Keep partitions in sync with DFU_ALT_INFO_EMMC (see dfu.h) - * 3. Keep 'bootloader' partition (U-Boot proper) start address in sync with - * CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR (see common/spl/Kconfig) - */ -#define PARTS_DEFAULT \ - /* Linux partitions */ \ - "uuid_disk=${uuid_gpt_disk};" \ - "name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \ - "name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \ - /* Android partitions */ \ - "partitions_android=" \ - "uuid_disk=${uuid_gpt_disk};" \ - "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \ - "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \ - "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \ - "name=misc,size=128K,uuid=${uuid_gpt_misc};" \ - "name=boot_a,size=20M,uuid=${uuid_gpt_boot_a};" \ - "name=boot_b,size=20M,uuid=${uuid_gpt_boot_b};" \ - "name=dtbo_a,size=8M,uuid=${uuid_gpt_dtbo_a};" \ - "name=dtbo_b,size=8M,uuid=${uuid_gpt_dtbo_b};" \ - "name=vbmeta_a,size=64K,uuid=${uuid_gpt_vbmeta_a};" \ - "name=vbmeta_b,size=64K,uuid=${uuid_gpt_vbmeta_b};" \ - "name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \ - "name=super,size=2560M,uuid=${uuid_gpt_super};" \ - "name=metadata,size=16M,uuid=${uuid_gpt_metadata};" \ - "name=userdata,size=-,uuid=${uuid_gpt_userdata}" -#endif /* PARTS_DEFAULT */ - -#if defined(CONFIG_CMD_AVB) -#define AVB_VERIFY_CHECK "if run avb_verify; then " \ - "echo AVB verification OK.;" \ - "set bootargs $bootargs $avb_bootargs;" \ - "else " \ - "echo AVB verification failed.;" \ - "exit; fi;" -#define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify $slot_suffix;\0" -#else -#define AVB_VERIFY_CHECK "" -#define AVB_VERIFY_CMD "" -#endif - -#define CONTROL_PARTITION "misc" - -#if defined(CONFIG_CMD_AB_SELECT) -#define AB_SELECT_SLOT \ - "if part number mmc 1 " CONTROL_PARTITION " control_part_number; " \ - "then " \ - "echo " CONTROL_PARTITION \ - " partition number:${control_part_number};" \ - "ab_select slot_name mmc ${mmcdev}:${control_part_number};" \ - "else " \ - "echo " CONTROL_PARTITION " partition not found;" \ - "exit;" \ - "fi;" \ - "setenv slot_suffix _${slot_name};" -#define AB_SELECT_ARGS \ - "setenv bootargs_ab androidboot.slot_suffix=${slot_suffix}; " \ - "echo A/B cmdline addition: ${bootargs_ab};" \ - "setenv bootargs ${bootargs} ${bootargs_ab};" -#else -#define AB_SELECT_SLOT "" -#define AB_SELECT_ARGS "" -#endif - -/* - * Prepares complete device tree blob for current board (for Android boot). - * - * Boot image or recovery image should be loaded into $loadaddr prior to running - * these commands. The logic of these commnads is next: - * - * 1. Read correct DTB for current SoC/board from boot image in $loadaddr - * to $fdtaddr - * 2. Merge all needed DTBO for current board from 'dtbo' partition into read - * DTB - * 3. User should provide $fdtaddr as 3rd argument to 'bootm' - */ -#define PREPARE_FDT \ - "echo Preparing FDT...; " \ - "if test $board_name = am57xx_evm_reva3; then " \ - "echo \" Reading DTBO partition...\"; " \ - "part start mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_start; " \ - "part size mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_size; " \ - "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \ - "echo \" Reading DTB for AM57x EVM RevA3...\"; " \ - "abootimg get dtb --index=0 dtb_start dtb_size; " \ - "cp.b $dtb_start $fdtaddr $dtb_size; " \ - "fdt addr $fdtaddr 0x80000; " \ - "echo \" Applying DTBOs for AM57x EVM RevA3...\"; " \ - "adtimg addr $dtboaddr; " \ - "adtimg get dt --index=0 dtbo0_addr dtbo0_size; " \ - "fdt apply $dtbo0_addr; " \ - "adtimg get dt --index=1 dtbo1_addr dtbo1_size; " \ - "fdt apply $dtbo1_addr; " \ - "elif test $board_name = beagle_x15_revc; then " \ - "echo \" Reading DTB for Beagle X15 RevC...\"; " \ - "abootimg get dtb --index=0 dtb_start dtb_size; " \ - "cp.b $dtb_start $fdtaddr $dtb_size; " \ - "fdt addr $fdtaddr 0x80000; " \ - "else " \ - "echo Error: Android boot is not supported for $board_name; " \ - "exit; " \ - "fi; " \ - -#define FASTBOOT_CMD \ - "echo Booting into fastboot ...; " \ - "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " - -#define DEFAULT_COMMON_BOOT_TI_ARGS \ - "console=" CONSOLEDEV ",115200n8\0" \ - "fdtfile=undefined\0" \ - "bootpart=0:2\0" \ - "bootdir=/boot\0" \ - "bootfile=zImage\0" \ - "usbtty=cdc_acm\0" \ - "vram=16M\0" \ - AVB_VERIFY_CMD \ - "partitions=" PARTS_DEFAULT "\0" \ - "optargs=\0" \ - "dofastboot=0\0" \ - "emmc_linux_boot=" \ - "echo Trying to boot Linux from eMMC ...; " \ - "setenv mmcdev 1; " \ - "setenv bootpart 1:2; " \ - "setenv mmcroot /dev/mmcblk0p2 rw; " \ - "run mmcboot;\0" \ - "emmc_android_boot=" \ - "setenv mmcdev 1; " \ - "mmc dev $mmcdev; " \ - "mmc rescan; " \ - AB_SELECT_SLOT \ - "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ - CONTROL_PARTITION "; then " \ - "setenv ardaddr -; " \ - "if bcb test command = bootonce-bootloader; then " \ - "echo Android: Bootloader boot...; " \ - "bcb clear command; bcb store; " \ - FASTBOOT_CMD \ - "exit; " \ - "elif bcb test command = boot-recovery; then " \ - "echo Android: Recovery boot...; " \ - "setenv ardaddr $loadaddr;" \ - "setenv apart recovery; " \ - "else " \ - "echo Android: Normal boot...; " \ - "setenv ardaddr $loadaddr; " \ - "setenv apart boot${slot_suffix}; " \ - "fi; " \ - "else " \ - "echo Warning: BCB is corrupted or does not exist; " \ - "echo Android: Normal boot...; " \ - "fi; " \ - "setenv eval_bootargs setenv bootargs $bootargs; " \ - "run eval_bootargs; " \ - "setenv machid fe6; " \ - AVB_VERIFY_CHECK \ - AB_SELECT_ARGS \ - "if part start mmc $mmcdev $apart boot_start; then " \ - "part size mmc $mmcdev $apart boot_size; " \ - "mmc read $loadaddr $boot_start $boot_size; " \ - PREPARE_FDT \ - "bootm $loadaddr $ardaddr $fdtaddr; " \ - "else " \ - "echo $apart partition not found; " \ - "exit; " \ - "fi;\0" - -#ifdef CONFIG_OMAP54XX - -#define DEFAULT_FDT_TI_ARGS \ - "findfdt="\ - "if test $board_name = omap5_uevm; then " \ - "setenv fdtfile omap5-uevm.dtb; fi; " \ - "if test $board_name = dra7xx; then " \ - "setenv fdtfile dra7-evm.dtb; fi;" \ - "if test $board_name = dra72x-revc; then " \ - "setenv fdtfile dra72-evm-revc.dtb; fi;" \ - "if test $board_name = dra72x; then " \ - "setenv fdtfile dra72-evm.dtb; fi;" \ - "if test $board_name = dra71x; then " \ - "setenv fdtfile dra71-evm.dtb; fi;" \ - "if test $board_name = dra76x_acd; then " \ - "setenv fdtfile dra76-evm.dtb; fi;" \ - "if test $board_name = beagle_x15; then " \ - "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ - "if test $board_name = beagle_x15_revb1; then " \ - "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \ - "if test $board_name = beagle_x15_revc; then " \ - "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \ - "if test $board_name = am5729_beagleboneai; then " \ - "setenv fdtfile am5729-beagleboneai.dtb; fi;" \ - "if test $board_name = am572x_idk; then " \ - "setenv fdtfile am572x-idk.dtb; fi;" \ - "if test $board_name = am574x_idk; then " \ - "setenv fdtfile am574x-idk.dtb; fi;" \ - "if test $board_name = am57xx_evm; then " \ - "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ - "if test $board_name = am57xx_evm_reva3; then " \ - "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ - "if test $board_name = am571x_idk; then " \ - "setenv fdtfile am571x-idk.dtb; fi;" \ - "if test $fdtfile = undefined; then " \ - "echo WARNING: Could not determine device tree to use; fi; \0" - -#define CONFIG_BOOTCOMMAND \ - "if test ${dofastboot} -eq 1; then " \ - "echo Boot fastboot requested, resetting dofastboot ...;" \ - "setenv dofastboot 0; saveenv;" \ - FASTBOOT_CMD \ - "fi;" \ - "if test ${boot_fit} -eq 1; then " \ - "run update_to_fit;" \ - "fi;" \ - "run findfdt; " \ - "run envboot; " \ - "run mmcboot;" \ - "run emmc_linux_boot; " \ - "run emmc_android_boot; " \ - "" - -#endif /* CONFIG_OMAP54XX */ - -#endif /* __TI_BOOT_H */ From 5fb3e09d97aca2dfd7836e319c8b2b11b10f17da Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 1 Jul 2021 09:26:12 -0400 Subject: [PATCH 35/46] ti: omap5: Switch to generic distro boot for non-Android cases Remove the environment support for various legacy boot methods. With this, we will now default to booting any distribution that follows the generic distro boot framework and no longer attempt to boot various legacy (to this SoC) scripts/etc. Note that if we do not find anything here we will continue to try and Android methods and will start by trying fastboot. Cc: Lokesh Vutla Signed-off-by: Tom Rini Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210701132612.7559-3-trini@konsulko.com --- include/configs/ti_omap5_common.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h index dfe69a821e..055d108dde 100644 --- a/include/configs/ti_omap5_common.h +++ b/include/configs/ti_omap5_common.h @@ -177,21 +177,13 @@ #define DEFAULT_COMMON_BOOT_TI_ARGS \ "console=" CONSOLEDEV ",115200n8\0" \ "fdtfile=undefined\0" \ - "bootpart=0:2\0" \ - "bootdir=/boot\0" \ - "bootfile=zImage\0" \ + "finduuid=part uuid mmc 0:2 uuid\0" \ "usbtty=cdc_acm\0" \ "vram=16M\0" \ AVB_VERIFY_CMD \ "partitions=" PARTS_DEFAULT "\0" \ "optargs=\0" \ "dofastboot=0\0" \ - "emmc_linux_boot=" \ - "echo Trying to boot Linux from eMMC ...; " \ - "setenv mmcdev 1; " \ - "setenv bootpart 1:2; " \ - "setenv mmcroot /dev/mmcblk0p2 rw; " \ - "run mmcboot;\0" \ "emmc_android_boot=" \ "setenv mmcdev 1; " \ "mmc dev $mmcdev; " \ @@ -278,12 +270,18 @@ "run update_to_fit;" \ "fi;" \ "run findfdt; " \ - "run envboot; " \ - "run mmcboot;" \ - "run emmc_linux_boot; " \ + "run finduuid; " \ + "run distro_bootcmd;" \ "run emmc_android_boot; " \ "" +#define BOOT_TARGET_DEVICES(func) \ + func(MMC, mmc, 0) \ + func(MMC, mmc, 1) \ + func(PXE, pxe, na) \ + func(DHCP, dhcp, na) + +#include #define CONFIG_EXTRA_ENV_SETTINGS \ DEFAULT_LINUX_BOOT_ENV \ @@ -294,6 +292,7 @@ DFUARGS \ NETARGS \ NANDARGS \ + BOOTENV /* * SPL related defines. The Public RAM memory map the ROM defines the From 7a376302f59c91abc6b1579e0db5e36b45f3d676 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 1 Jul 2021 10:27:43 -0400 Subject: [PATCH 36/46] configs: j721e_evm: Switch envboot out for distro_bootcmd Swap out the TI-centric "envboot" logic for the generic distro_bootcmd logic for the bootcmd we run before trying to do something more complex involving additional firmware, etc. Cc: Lokesh Vutla (maintainer:J721E BOARD) Signed-off-by: Tom Rini Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210701142743.26190-1-trini@konsulko.com --- configs/j721e_evm_a72_defconfig | 2 +- include/configs/j721e_evm.h | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/configs/j721e_evm_a72_defconfig b/configs/j721e_evm_a72_defconfig index 365d662690..2e890cdfe6 100644 --- a/configs/j721e_evm_a72_defconfig +++ b/configs/j721e_evm_a72_defconfig @@ -29,7 +29,7 @@ CONFIG_DISTRO_DEFAULTS=y CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000 # CONFIG_USE_SPL_FIT_GENERATOR is not set -CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run boot_rprocs; run get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern" +CONFIG_BOOTCOMMAND="run findfdt; run distro_bootcmd; run init_${boot}; run boot_rprocs; run get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern" CONFIG_LOGLEVEL=7 CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y diff --git a/include/configs/j721e_evm.h b/include/configs/j721e_evm.h index b707fc4e89..62da8ff956 100644 --- a/include/configs/j721e_evm.h +++ b/include/configs/j721e_evm.h @@ -10,7 +10,6 @@ #define __CONFIG_J721E_EVM_H #include -#include #include #include #include @@ -160,6 +159,26 @@ #define EXTRA_ENV_J721E_BOARD_SETTINGS_MTD #endif +#if CONFIG_IS_ENABLED(CMD_PXE) +# define BOOT_TARGET_PXE(func) func(PXE, pxe, na) +#else +# define BOOT_TARGET_PXE(func) +#endif + +#if CONFIG_IS_ENABLED(CMD_DHCP) +# define BOOT_TARGET_DHCP(func) func(DHCP, dhcp, na) +#else +# define BOOT_TARGET_DHCP(func) +#endif + +#define BOOT_TARGET_DEVICES(func) \ + func(MMC, mmc, 1) \ + func(MMC, mmc, 0) \ + BOOT_TARGET_PXE(func) \ + BOOT_TARGET_DHCP(func) + +#include + /* Incorporate settings into the U-Boot environment */ #define CONFIG_EXTRA_ENV_SETTINGS \ DEFAULT_LINUX_BOOT_ENV \ @@ -170,7 +189,8 @@ EXTRA_ENV_RPROC_SETTINGS \ EXTRA_ENV_DFUARGS \ DEFAULT_UFS_TI_ARGS \ - EXTRA_ENV_J721E_BOARD_SETTINGS_MTD + EXTRA_ENV_J721E_BOARD_SETTINGS_MTD \ + BOOTENV /* Now for the remaining common defines */ #include From 52306258548f131530abc34de858a55bf0895e0a Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Wed, 7 Jul 2021 21:43:48 -0400 Subject: [PATCH 37/46] arm: omap4: Disable USB_TTY and related options The usbtty functionality is not currently used on these two platforms, disable it. Cc: Lokesh Vutla Signed-off-by: Tom Rini Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210708014348.4010-1-trini@konsulko.com --- configs/omap4_panda_defconfig | 1 - configs/omap4_sdp4430_defconfig | 1 - include/configs/ti_omap4_common.h | 6 ------ 3 files changed, 8 deletions(-) diff --git a/configs/omap4_panda_defconfig b/configs/omap4_panda_defconfig index 08dc3552c8..9e99e8bc69 100644 --- a/configs/omap4_panda_defconfig +++ b/configs/omap4_panda_defconfig @@ -39,7 +39,6 @@ CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_EHCI_HCD=y -CONFIG_USB_MUSB_UDC=y CONFIG_USB_OMAP3=y CONFIG_USB_GADGET=y CONFIG_USB_HOST_ETHER=y diff --git a/configs/omap4_sdp4430_defconfig b/configs/omap4_sdp4430_defconfig index f90b281428..fd93dc5c78 100644 --- a/configs/omap4_sdp4430_defconfig +++ b/configs/omap4_sdp4430_defconfig @@ -39,7 +39,6 @@ CONFIG_CONS_INDEX=3 CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_DM_USB=y -CONFIG_USB_MUSB_UDC=y CONFIG_USB_OMAP3=y CONFIG_USB_GADGET=y CONFIG_FAT_WRITE=y diff --git a/include/configs/ti_omap4_common.h b/include/configs/ti_omap4_common.h index 1e316227aa..d0eddcce1b 100644 --- a/include/configs/ti_omap4_common.h +++ b/include/configs/ti_omap4_common.h @@ -51,12 +51,6 @@ #define CONFIG_TWL6030_POWER 1 #endif -/* USB */ - -/* USB device configuration */ -#define CONFIG_USB_DEVICE 1 -#define CONFIG_USB_TTY 1 - /* * Environment setup */ From bde6ac549053a4a983ddb7306a4ea0245a2b4ea9 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 13 Jul 2021 10:11:39 -0400 Subject: [PATCH 38/46] configs: am65x_evm: Switch envboot out for distro_bootcmd Swap out the TI-centric "envboot" logic for the generic distro_bootcmd logic for the bootcmd we run before trying to do something more complex involving additional firmware, etc. Cc: Lokesh Vutla Signed-off-by: Tom Rini Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210713141139.15183-1-trini@konsulko.com --- configs/am65x_evm_a53_defconfig | 2 +- include/configs/am65x_evm.h | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/configs/am65x_evm_a53_defconfig b/configs/am65x_evm_a53_defconfig index a3f6469cdf..a5858fe27e 100644 --- a/configs/am65x_evm_a53_defconfig +++ b/configs/am65x_evm_a53_defconfig @@ -29,7 +29,7 @@ CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000 # CONFIG_USE_SPL_FIT_GENERATOR is not set CONFIG_OF_BOARD_SETUP=y -CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run boot_rprocs; run get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern" +CONFIG_BOOTCOMMAND="run findfdt; run distro_bootcmd; run init_${boot}; run boot_rprocs; run get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern" CONFIG_LOGLEVEL=7 CONFIG_CONSOLE_MUX=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y diff --git a/include/configs/am65x_evm.h b/include/configs/am65x_evm.h index 8c50fe9d11..d4514a0dba 100644 --- a/include/configs/am65x_evm.h +++ b/include/configs/am65x_evm.h @@ -10,7 +10,6 @@ #define __CONFIG_AM654_EVM_H #include -#include #include #include #include @@ -126,6 +125,16 @@ DFU_ALT_INFO_EMMC \ DFU_ALT_INFO_OSPI +#ifdef CONFIG_TARGET_AM654_A53_EVM +#define BOOT_TARGET_DEVICES(func) \ + func(MMC, mmc, 1) \ + func(MMC, mmc, 0) + +#include +#else +#define BOOTENV +#endif + /* Incorporate settings into the U-Boot environment */ #define CONFIG_EXTRA_ENV_SETTINGS \ DEFAULT_LINUX_BOOT_ENV \ @@ -136,7 +145,8 @@ EXTRA_ENV_AM65X_BOARD_SETTINGS_MTD \ EXTRA_ENV_AM65X_BOARD_SETTINGS_UBI \ EXTRA_ENV_RPROC_SETTINGS \ - EXTRA_ENV_DFUARGS + EXTRA_ENV_DFUARGS \ + BOOTENV #define CONFIG_SYS_USB_FAT_BOOT_PARTITION 1 From 6fdbd2b093dcd7b16b4b90ae63430ee33d2de61f Mon Sep 17 00:00:00 2001 From: Gowtham Tammana Date: Wed, 14 Jul 2021 15:52:56 -0500 Subject: [PATCH 39/46] power: pmic: tps65941: Add compatible for LP876441 TI J7200 EVM has lp876441 pmic that is similar to tps65941. Add support for same with existing driver with new compatible. Signed-off-by: Gowtham Tammana Signed-off-by: Lokesh Vutla Acked-by: Jaehoon Chung Link: https://lore.kernel.org/r/20210714205300.17424-2-g-tammana@ti.com --- drivers/power/pmic/tps65941.c | 1 + include/power/tps65941.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/power/pmic/tps65941.c b/drivers/power/pmic/tps65941.c index 3dfc1918d5..114ef4d238 100644 --- a/drivers/power/pmic/tps65941.c +++ b/drivers/power/pmic/tps65941.c @@ -72,6 +72,7 @@ static struct dm_pmic_ops tps65941_ops = { static const struct udevice_id tps65941_ids[] = { { .compatible = "ti,tps659411", .data = TPS659411 }, { .compatible = "ti,tps659413", .data = TPS659413 }, + { .compatible = "ti,lp876441", .data = LP876441 }, { } }; diff --git a/include/power/tps65941.h b/include/power/tps65941.h index 2d48b31ae3..a2bc6814ba 100644 --- a/include/power/tps65941.h +++ b/include/power/tps65941.h @@ -2,6 +2,7 @@ #define TPS659412 0x1 #define TPS659413 0x2 #define TPS659414 0x3 +#define LP876441 0x4 /* I2C device address for pmic tps65941 */ #define TPS65941_I2C_ADDR (0x12 >> 1) From 6fb8706bcb88ae53780cadad63e698f231eac4ee Mon Sep 17 00:00:00 2001 From: Gowtham Tammana Date: Wed, 14 Jul 2021 15:52:57 -0500 Subject: [PATCH 40/46] arm/dts: k3-j7200-r5-common: Add pmic lp876441 node Add pmic lp876411 node needed for CPU AVS support. Signed-off-by: Gowtham Tammana Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210714205300.17424-3-g-tammana@ti.com --- .../arm/dts/k3-j7200-r5-common-proc-board.dts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts index 8dc1809979..6ef92145ef 100644 --- a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts @@ -239,6 +239,32 @@ ti,driver-strength-ohm = <50>; }; +&wkup_i2c0 { + u-boot,dm-spl; + lp876441: lp876441@4c { + compatible = "ti,lp876441"; + reg = <0x4c>; + u-boot,dm-spl; + pinctrl-names = "default"; + pinctrl-0 = <&wkup_i2c0_pins_default>; + clock-frequency = <400000>; + + regulators: regulators { + u-boot,dm-spl; + buck1_reg: buck1 { + /*VDD_CPU_AVS_REG*/ + regulator-name = "buck1"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1250000>; + regulator-always-on; + regulator-boot-on; + u-boot,dm-spl; + }; + }; + }; + +}; + &main_i2c0 { pinctrl-names = "default"; pinctrl-0 = <&main_i2c0_pins_default>; From fcdf03aab90c5de44611dadf42d0dbf14fc402d0 Mon Sep 17 00:00:00 2001 From: Gowtham Tammana Date: Wed, 14 Jul 2021 15:52:58 -0500 Subject: [PATCH 41/46] arm/dts: k3-j7200-r5-common: Add VTM node Add voltage and thermal management (VTM) node. The efuse values for the OPPs are stored under the VTM, and is needed for AVS class 0 support. Signed-off-by: Gowtham Tammana Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210714205300.17424-4-g-tammana@ti.com --- arch/arm/dts/k3-j7200-r5-common-proc-board.dts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts index 6ef92145ef..891e0b6931 100644 --- a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts @@ -89,6 +89,13 @@ <&mcu_secproxy 23>; u-boot,dm-spl; }; + + wkup_vtm0: vtm@42040000 { + compatible = "ti,am654-vtm", "ti,j721e-avs"; + reg = <0x0 0x42040000 0x0 0x330>; + power-domains = <&k3_pds 154 TI_SCI_PD_EXCLUSIVE>; + #thermal-sensor-cells = <1>; + }; }; &dmsc { From 2094e7069271d17f3955c70265170bccc75471f0 Mon Sep 17 00:00:00 2001 From: Gowtham Tammana Date: Wed, 14 Jul 2021 15:52:59 -0500 Subject: [PATCH 42/46] arm/dts: k3-j7200-r5-common: Hook buck1_reg to vtm supply Hook buck1_reg to vtm avs supply. Signed-off-by: Gowtham Tammana Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210714205300.17424-5-g-tammana@ti.com --- arch/arm/dts/k3-j7200-r5-common-proc-board.dts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts index 891e0b6931..b1f9e714d9 100644 --- a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts @@ -272,6 +272,11 @@ }; +&wkup_vtm0 { + vdd-supply-2 = <&buck1_reg>; + u-boot,dm-spl; +}; + &main_i2c0 { pinctrl-names = "default"; pinctrl-0 = <&main_i2c0_pins_default>; From 149389424f6644e56909e68bb1fe2ee612dc0274 Mon Sep 17 00:00:00 2001 From: Gowtham Tammana Date: Wed, 14 Jul 2021 15:53:00 -0500 Subject: [PATCH 43/46] configs: j7200_evm_r5_defconfig: Enable AVS, PMIC and dependent configs Enable AVS, PMIC and dependent configs. Signed-off-by: Gowtham Tammana Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210714205300.17424-6-g-tammana@ti.com --- configs/j7200_evm_r5_defconfig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/configs/j7200_evm_r5_defconfig b/configs/j7200_evm_r5_defconfig index b449bdb3b8..862061e5b2 100644 --- a/configs/j7200_evm_r5_defconfig +++ b/configs/j7200_evm_r5_defconfig @@ -114,6 +114,13 @@ CONFIG_SPL_PINCTRL=y CONFIG_PINCTRL_SINGLE=y CONFIG_POWER_DOMAIN=y CONFIG_TI_POWER_DOMAIN=y +CONFIG_TI_SCI_POWER_DOMAIN=y +CONFIG_DM_PMIC=y +CONFIG_PMIC_TPS65941=y +CONFIG_DM_REGULATOR=y +CONFIG_SPL_DM_REGULATOR=y +CONFIG_DM_REGULATOR_TPS65941=y +CONFIG_K3_AVS0=y CONFIG_K3_SYSTEM_CONTROLLER=y CONFIG_REMOTEPROC_TI_K3_ARM64=y CONFIG_DM_RESET=y From cc434fccba4ccf8e3645346f3ae49e7b33733dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Fri, 18 Jun 2021 15:27:03 +0200 Subject: [PATCH 44/46] Nokia RX-51: Add support for booting kernel in zImage format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable U-Boot bootz command and update env scripts to try loading also zImage file and to try booting via bootz command. Update also lowlevel_init.S code for checking validity of zImage magic to correctly relocate kernel in zImage format. This change allows U-Boot to directly boot Linux kernel without need for converting kernel image into U-Boot uImage format. Signed-off-by: Pali Rohár Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210618132704.32066-1-pali@kernel.org --- board/nokia/rx51/lowlevel_init.S | 12 ++++- configs/nokia_rx51_defconfig | 1 + doc/README.nokia_rx51 | 10 +++-- include/configs/nokia_rx51.h | 11 +++-- test/nokia_rx51_test.sh | 76 +++++++++++++++++++++++++++----- 5 files changed, 91 insertions(+), 19 deletions(-) diff --git a/board/nokia/rx51/lowlevel_init.S b/board/nokia/rx51/lowlevel_init.S index 1466d976fc..11c2cbef89 100644 --- a/board/nokia/rx51/lowlevel_init.S +++ b/board/nokia/rx51/lowlevel_init.S @@ -27,6 +27,9 @@ imagesize: /* maximal size of image */ ih_magic: /* IH_MAGIC in big endian from include/image.h */ .word 0x56190527 +z_magic: /* LINUX_ARM_ZIMAGE_MAGIC */ + .word 0x016f2818 + /* * Routine: save_boot_params (called after reset from start.S) * Description: Copy attached kernel to address KERNEL_ADDRESS @@ -75,6 +78,12 @@ copy_kernel_start: ldr r4, [r0] /* r4 - 4 bytes header of kernel */ ldr r5, ih_magic /* r5 - IH_MAGIC */ cmp r4, r5 + beq copy_kernel_loop + + /* check for valid kernel zImage */ + ldr r4, [r0, #36] /* r4 - 4 bytes header of kernel at offset 36 */ + ldr r5, z_magic /* r5 - LINUX_ARM_ZIMAGE_MAGIC */ + cmp r4, r5 bne copy_kernel_end /* skip if invalid image */ copy_kernel_loop: @@ -85,7 +94,8 @@ copy_kernel_loop: copy_kernel_end: mov r5, #0 - str r5, [r0] /* remove 4 bytes header of kernel */ + str r5, [r0] /* remove 4 bytes header of kernel uImage */ + str r5, [r0, #36] /* remove 4 bytes header of kernel zImage */ /* Fix u-boot code */ diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig index 061f5c357c..981e6f95cb 100644 --- a/configs/nokia_rx51_defconfig +++ b/configs/nokia_rx51_defconfig @@ -18,6 +18,7 @@ CONFIG_CONSOLE_MUX=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Nokia RX-51 # " # CONFIG_CMD_BDI is not set +CONFIG_CMD_BOOTZ=y # CONFIG_BOOTM_NETBSD is not set # CONFIG_BOOTM_PLAN9 is not set # CONFIG_BOOTM_RTEMS is not set diff --git a/doc/README.nokia_rx51 b/doc/README.nokia_rx51 index 84d1912ddd..7f22ed49bd 100644 --- a/doc/README.nokia_rx51 +++ b/doc/README.nokia_rx51 @@ -11,13 +11,14 @@ a kernel. In order to transparently boot the original kernel, it will be appended to u-boot.bin at 0x40000. NOLO will load the entire image into (random) memory and execute u-boot, which saves hw revision, boot reason and boot mode ATAGs set by NOLO. Then the bootscripts will attempt to load -uImage or boot.scr from a fat, ext2/ext3 or ext4 filesystem in external +uImage, zImage or boot.scr from a fat or ext2/3/4 filesystem on external SD card or internal eMMC memory. If this fails or keyboard is closed then the appended kernel image will be booted using some generated and some stored ATAGs (see boot order). -For generating combined image of u-boot and kernel there is a simple script -called u-boot-gen-combined. It is available in following repository: +For generating combined image of u-boot and kernel (either in uImage or zImage +format) there is a simple script called u-boot-gen-combined. It is available in +following repository: https://github.com/pali/u-boot-maemo @@ -41,7 +42,8 @@ Boot from SD or eMMC in this order: * 1. * 1.1 find boot.scr on first fat partition * 1.2 find uImage on first fat partition - * 1.3 same order for 2. - 4. fat partition + * 1.3 find zImage on first fat partition + * 1.4 same order for 2. - 4. fat partition * 2. same as 1. but for ext2/3 partition * 3. same as 1. but for ext4 partition diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h index fe991ea039..742c1a6465 100644 --- a/include/configs/nokia_rx51.h +++ b/include/configs/nokia_rx51.h @@ -129,12 +129,14 @@ int rx51_kp_getc(struct stdio_dev *sdev); "scriptboot=echo Running ${mmcscriptfile} from mmc " \ "${mmcnum}:${mmcpart} ...; source ${scriptaddr}\0" \ "kernboot=echo Booting ${mmckernfile} from mmc " \ - "${mmcnum}:${mmcpart} ...; bootm ${kernaddr}\0" \ + "${mmcnum}:${mmcpart} ...; bootm ${kernaddr} || " \ + "bootz ${kernaddr}\0" \ "kerninitrdboot=echo Booting ${mmckernfile} ${mmcinitrdfile} from mmc "\ - "${mmcnum}:${mmcpart} ...; bootm ${kernaddr} ${initrdaddr}\0" \ + "${mmcnum}:${mmcpart} ...; bootm ${kernaddr} ${initrdaddr} || " \ + "bootz ${kernaddr} ${initrdaddr}\0" \ "attachboot=echo Booting attached kernel image ...;" \ "setenv setup_omap_atag 1;" \ - "bootm ${attkernaddr};" \ + "bootm ${attkernaddr} || bootz ${attkernaddr};" \ "setenv setup_omap_atag\0" \ "trymmcscriptboot=if run switchmmc; then " \ "if run scriptload; then " \ @@ -154,7 +156,8 @@ int rx51_kp_getc(struct stdio_dev *sdev); "fi; " \ "fi\0" \ "trymmcpartboot=setenv mmcscriptfile boot.scr; run trymmcscriptboot;" \ - "setenv mmckernfile uImage; run trymmckernboot\0" \ + "setenv mmckernfile uImage; run trymmckernboot;" \ + "setenv mmckernfile zImage; run trymmckernboot\0" \ "trymmcallpartboot=setenv mmcpart 1; run trymmcpartboot;" \ "setenv mmcpart 2; run trymmcpartboot;" \ "setenv mmcpart 3; run trymmcpartboot;" \ diff --git a/test/nokia_rx51_test.sh b/test/nokia_rx51_test.sh index ff840c1e6c..a1436543fb 100755 --- a/test/nokia_rx51_test.sh +++ b/test/nokia_rx51_test.sh @@ -159,7 +159,7 @@ setenv bootdelay 1; EOF ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_uboot -d bootmenu_uboot bootmenu_uboot.scr -# Generate bootmenu for eMMC booting +# Generate bootmenu for eMMC booting (uImage) cat > bootmenu_emmc << EOF setenv bootmenu_0 'uImage-2.6.28-omap1 from eMMC=setenv mmcnum 1; setenv mmcpart 1; setenv mmctype fat; setenv bootargs; setenv setup_omap_atag 1; setenv mmckernfile uImage-2.6.28-omap1; run trymmckernboot'; setenv bootmenu_1; @@ -168,6 +168,15 @@ setenv bootdelay 1; EOF ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_emmc -d bootmenu_emmc bootmenu_emmc.scr +# Generate bootmenu for eMMC booting (zImage) +cat > bootmenu_emmc2 << EOF +setenv bootmenu_0 'zImage-2.6.28-omap1 from eMMC=setenv mmcnum 1; setenv mmcpart 1; setenv mmctype fat; setenv bootargs; setenv setup_omap_atag 1; setenv mmckernfile zImage-2.6.28-omap1; run trymmckernboot'; +setenv bootmenu_1; +setenv bootmenu_delay 1; +setenv bootdelay 1; +EOF +./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_emmc2 -d bootmenu_emmc2 bootmenu_emmc2.scr + # Generate bootmenu for OneNAND booting cat > bootmenu_nand << EOF setenv bootmenu_0 'uImage-2.6.28-omap1 from OneNAND=mtd read initfs \${kernaddr}; setenv bootargs; setenv setup_omap_atag 1; bootm \${kernaddr}'; @@ -177,10 +186,18 @@ setenv bootdelay 1; EOF ./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_nand -d bootmenu_nand bootmenu_nand.scr +# Generate bootmenu for default booting +cat > bootmenu_default << EOF +setenv bootmenu_delay 1; +setenv bootdelay 1; +EOF +./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_default -d bootmenu_default bootmenu_default.scr + # Generate combined image from u-boot and Maemo fiasco kernel dd if=kernel_2.6.28/boot/zImage-2.6.28-20103103+0m5.fiasco of=zImage-2.6.28-omap1 skip=95 bs=1 +./u-boot-gen-combined u-boot.bin zImage-2.6.28-omap1 combined_zimage.bin ./mkimage -A arm -O linux -T kernel -C none -a 80008000 -e 80008000 -n zImage-2.6.28-omap1 -d zImage-2.6.28-omap1 uImage-2.6.28-omap1 -./u-boot-gen-combined u-boot.bin uImage-2.6.28-omap1 combined.bin +./u-boot-gen-combined u-boot.bin uImage-2.6.28-omap1 combined_uimage.bin # Generate combined hack image from u-boot and Maemo fiasco kernel (kernel starts at 2MB offset and qflasher puts 2kB header before supplied image) cp u-boot.bin combined_hack.bin @@ -191,24 +208,37 @@ truncate -s 50MiB emmc_uboot.img mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_uboot.img mcopy bootmenu_uboot.scr ::/bootmenu.scr -i emmc_uboot.img -# Generate FAT32 eMMC image for eMMC booting +# Generate FAT32 eMMC image for eMMC booting (uImage) truncate -s 50MiB emmc_emmc.img mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc.img mcopy uImage-2.6.28-omap1 ::/uImage-2.6.28-omap1 -i emmc_emmc.img mcopy bootmenu_emmc.scr ::/bootmenu.scr -i emmc_emmc.img +# Generate FAT32 eMMC image for eMMC booting (zImage) +truncate -s 50MiB emmc_emmc2.img +mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc2.img +mcopy zImage-2.6.28-omap1 ::/zImage-2.6.28-omap1 -i emmc_emmc2.img +mcopy bootmenu_emmc2.scr ::/bootmenu.scr -i emmc_emmc2.img + # Generate FAT32 eMMC image for OneNAND booting truncate -s 50MiB emmc_nand.img mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_nand.img mcopy bootmenu_nand.scr ::/bootmenu.scr -i emmc_nand.img +# Generate FAT32 eMMC image for default booting +truncate -s 50MiB emmc_default.img +mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_default.img +mcopy bootmenu_default.scr ::/bootmenu.scr -i emmc_default.img + # Generate MTD image for U-Boot serial console testing rm -f mtd_uboot.img ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -m rx51 -o mtd_uboot.img # Generate MTD image for RAM booting from bootloader nolo images, compiled image and rootfs image rm -f mtd_ram.img -./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined.bin -r ubi.img -m rx51 -o mtd_ram.img +./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined_uimage.bin -r ubi.img -m rx51 -o mtd_ram.img +rm -f mtd_ram2.img +./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined_zimage.bin -r ubi.img -m rx51 -o mtd_ram2.img # Generate MTD image for eMMC booting from bootloader nolo images, u-boot image and rootfs image rm -f mtd_emmc.img @@ -238,7 +268,7 @@ wait -n $sleep_pid $qemu_pid || true kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true wait || true -# Run MTD image in qemu and wait for 300s if kernel from RAM is correctly booted +# Run MTD image in qemu and wait for 300s if uImage kernel from RAM is correctly booted rm -f qemu_ram.log ./qemu-system-arm -M n900 -mtdblock mtd_ram.img -serial /dev/stdout -display none > qemu_ram.log & qemu_pid=$! @@ -250,7 +280,19 @@ wait -n $sleep_pid $qemu_pid || true kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true wait || true -# Run MTD image in qemu and wait for 300s if kernel from eMMC is correctly booted +# Run MTD image in qemu and wait for 300s if zImage kernel from RAM is correctly booted +rm -f qemu_ram2.log +./qemu-system-arm -M n900 -mtdblock mtd_ram2.img -sd emmc_default.img -serial /dev/stdout -display none > qemu_ram2.log & +qemu_pid=$! +tail -F qemu_ram2.log & +tail_pid=$! +sleep 300 & +sleep_pid=$! +wait -n $sleep_pid $qemu_pid || true +kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true +wait || true + +# Run MTD image in qemu and wait for 300s if uImage kernel from eMMC is correctly booted rm -f qemu_emmc.log ./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc.img -serial /dev/stdout -display none > qemu_emmc.log & qemu_pid=$! @@ -262,6 +304,18 @@ wait -n $sleep_pid $qemu_pid || true kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true wait || true +# Run MTD image in qemu and wait for 300s if zImage kernel from eMMC is correctly booted +rm -f qemu_emmc2.log +./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc2.img -serial /dev/stdout -display none > qemu_emmc2.log & +qemu_pid=$! +tail -F qemu_emmc2.log & +tail_pid=$! +sleep 300 & +sleep_pid=$! +wait -n $sleep_pid $qemu_pid || true +kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true +wait || true + # Run MTD image in qemu and wait for 300s if kernel from OneNAND is correctly booted rm -f qemu_nand.log ./qemu-system-arm -M n900 -mtdblock mtd_nand.img -sd emmc_nand.img -serial /dev/stdout -display none > qemu_nand.log & @@ -281,13 +335,15 @@ echo "=============================" echo if grep -q 'Successfully booted' qemu_uboot.log; then echo "U-Boot serial console is working"; else echo "U-Boot serial console test failed"; fi -if grep -q 'Successfully booted' qemu_ram.log; then echo "Kernel was successfully booted from RAM"; else echo "Failed to boot kernel from RAM"; fi -if grep -q 'Successfully booted' qemu_emmc.log; then echo "Kernel was successfully booted from eMMC"; else echo "Failed to boot kernel from eMMC"; fi -if grep -q 'Successfully booted' qemu_nand.log; then echo "Kernel was successfully booted from OneNAND"; else echo "Failed to boot kernel from OneNAND"; fi +if grep -q 'Successfully booted' qemu_ram.log; then echo "Kernel (uImage) was successfully booted from RAM"; else echo "Failed to boot kernel (uImage) from RAM"; fi +if grep -q 'Successfully booted' qemu_ram2.log; then echo "Kernel (zImage) was successfully booted from RAM"; else echo "Failed to boot kernel (zImage) from RAM"; fi +if grep -q 'Successfully booted' qemu_emmc.log; then echo "Kernel (uImage) was successfully booted from eMMC"; else echo "Failed to boot kernel (uImage) from eMMC"; fi +if grep -q 'Successfully booted' qemu_emmc2.log; then echo "Kernel (zImage) was successfully booted from eMMC"; else echo "Failed to boot kernel (zImage) from eMMC"; fi +if grep -q 'Successfully booted' qemu_nand.log; then echo "Kernel (uImage) was successfully booted from OneNAND"; else echo "Failed to boot kernel (uImage) from OneNAND"; fi echo -if grep -q 'Successfully booted' qemu_uboot.log && grep -q 'Successfully booted' qemu_ram.log && grep -q 'Successfully booted' qemu_emmc.log && grep -q 'Successfully booted' qemu_nand.log; then +if grep -q 'Successfully booted' qemu_uboot.log && grep -q 'Successfully booted' qemu_ram.log && grep -q 'Successfully booted' qemu_ram2.log && grep -q 'Successfully booted' qemu_emmc.log && grep -q 'Successfully booted' qemu_emmc2.log && grep -q 'Successfully booted' qemu_nand.log; then echo "All tests passed" exit 0 else From f75b7b82a3b63fd7abac8d89bff1f6bd51f41378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Fri, 18 Jun 2021 15:27:04 +0200 Subject: [PATCH 45/46] Nokia RX-51: Load bootmenu also from uSD card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default bootmenu is loaded only from eMMC. After this change U-Boot first tries to load bootmenu from uSD card and if it fails then fallback to eMMC. People want to boot alternative OS from removable uSD without need to modify eMMC content. So this backward compatible change allows it. Part of this change is also optimization of trymmc* macros so they can be used in preboot macro for loading bootmenu. Signed-off-by: Pali Rohár Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210618132704.32066-2-pali@kernel.org --- include/configs/nokia_rx51.h | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h index 742c1a6465..7ef25ea838 100644 --- a/include/configs/nokia_rx51.h +++ b/include/configs/nokia_rx51.h @@ -138,23 +138,10 @@ int rx51_kp_getc(struct stdio_dev *sdev); "setenv setup_omap_atag 1;" \ "bootm ${attkernaddr} || bootz ${attkernaddr};" \ "setenv setup_omap_atag\0" \ - "trymmcscriptboot=if run switchmmc; then " \ - "if run scriptload; then " \ - "run scriptboot;" \ - "fi;" \ - "fi\0" \ - "trymmckernboot=if run switchmmc; then " \ - "if run kernload; then " \ - "run kernboot;" \ - "fi;" \ - "fi\0" \ - "trymmckerninitrdboot=if run switchmmc; then " \ - "if run initrdload; then " \ - "if run kernload; then " \ - "run kerninitrdboot;" \ - "fi;" \ - "fi; " \ - "fi\0" \ + "trymmcscriptboot=run switchmmc && run scriptload && run scriptboot\0" \ + "trymmckernboot=run switchmmc && run kernload && run kernboot\0" \ + "trymmckerninitrdboot=run switchmmc && run initrdload && " \ + "run kernload && run kerninitrdboot\0" \ "trymmcpartboot=setenv mmcscriptfile boot.scr; run trymmcscriptboot;" \ "setenv mmckernfile uImage; run trymmckernboot;" \ "setenv mmckernfile zImage; run trymmckernboot\0" \ @@ -170,15 +157,11 @@ int rx51_kp_getc(struct stdio_dev *sdev); "fi\0" \ "emmcboot=setenv mmcnum 1; run trymmcboot\0" \ "sdboot=setenv mmcnum 0; run trymmcboot\0" \ - "preboot=setenv mmcnum 1; setenv mmcpart 1;" \ - "setenv mmcscriptfile bootmenu.scr;" \ - "if run switchmmc; then " \ - "setenv mmctype fat;" \ - "if run scriptload; then run scriptboot; else " \ - "setenv mmctype ext4;" \ - "if run scriptload; then run scriptboot; fi;" \ - "fi;" \ - "fi;" \ + "trymmcbootmenu=setenv mmctype fat && run trymmcscriptboot || " \ + "setenv mmctype ext4 && run trymmcscriptboot\0" \ + "preboot=setenv mmcpart 1; setenv mmcscriptfile bootmenu.scr;" \ + "setenv mmcnum 0 && run trymmcbootmenu || " \ + "setenv mmcnum 1 && run trymmcbootmenu;" \ "if run slide; then true; else " \ "setenv bootmenu_delay 0;" \ "setenv bootdelay 0;" \ From 652982309d316b14aae5805d09239f89eb89f038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Fri, 18 Jun 2021 15:31:08 +0200 Subject: [PATCH 46/46] Nokia RX-51: Add check for /lib/ld-linux.so.2 in test script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unfortunately for testing is required qflasher which works only in 32-bit x86 mode. Apparently 64-bit x86 Azure CI has no problems as it has preinstalled 32-bit libraries and can execute also 32-bit x86 executables. This change just show human readable output why nokia_rx51_test.sh test script fails. Signed-off-by: Pali Rohár Signed-off-by: Lokesh Vutla Link: https://lore.kernel.org/r/20210618133108.32497-1-pali@kernel.org --- test/nokia_rx51_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/nokia_rx51_test.sh b/test/nokia_rx51_test.sh index a1436543fb..28aa554ed8 100755 --- a/test/nokia_rx51_test.sh +++ b/test/nokia_rx51_test.sh @@ -18,6 +18,7 @@ echo ' mformat (from mtools, homepage http://www.gnu.org/software/mtools/) /usr/sbin/mkfs.ubifs (from mtd-utils, homepage http://www.linux-mtd.infradead.org/) /usr/sbin/ubinize (from mtd-utils, homepage http://www.linux-mtd.infradead.org/) + /lib/ld-linux.so.2 (32-bit x86 version of LD loader, needed for qflasher) ' | while read tool info; do if test -z "$tool"; then continue; fi if ! which $tool 1>/dev/null 2>&1; then