From a4c61ffde3ae4f1b7228d2ecd40fbb8f3703d76c Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Thu, 16 May 2019 13:03:53 +0300 Subject: [PATCH 01/24] spl: sata: add default partition and image name Add sensible defaults for the FAT partition selection and the main U-Boot image file name. This allows spl_sata to build when the board headers does not select them explicitly. Signed-off-by: Baruch Siach Signed-off-by: Stefan Roese --- common/spl/spl_sata.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c index adfce1d527..b08efc8419 100644 --- a/common/spl/spl_sata.c +++ b/common/spl/spl_sata.c @@ -17,6 +17,14 @@ #include #include +#ifndef CONFIG_SYS_SATA_FAT_BOOT_PARTITION +#define CONFIG_SYS_SATA_FAT_BOOT_PARTITION 1 +#endif + +#ifndef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img" +#endif + static int spl_sata_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { From ab2d415e9bbab64431e6475fbb5a5c62303f8163 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Thu, 16 May 2019 13:03:54 +0300 Subject: [PATCH 02/24] spl: sata: fix build with DM_SCSI The init_sata() routine is only present when DM_SCSI is not enabled. Don't call init_sata() when DM_SCSI is enabled. The code will fall back to scsi_scan() in this case. Signed-off-by: Baruch Siach Signed-off-by: Stefan Roese --- common/spl/spl_sata.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c index b08efc8419..2fb46108a5 100644 --- a/common/spl/spl_sata.c +++ b/common/spl/spl_sata.c @@ -28,10 +28,12 @@ static int spl_sata_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { - int err; + int err = 0; struct blk_desc *stor_dev; +#if !defined(CONFIG_DM_SCSI) && !defined(CONFIG_AHCI) err = init_sata(CONFIG_SPL_SATA_BOOT_DEVICE); +#endif if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("spl: sata init failed: err - %d\n", err); From 760ef309cb63a3e22ebeecb9080f1034be1560f5 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Thu, 16 May 2019 13:03:55 +0300 Subject: [PATCH 03/24] spl: sata: don't force FS_FAT support Allow the code to build when FS_FAT is not enabled, and thus spl_load_image_fat() is not provided. A subsequent patch should add alternative raw access U-Boot main image load method. Signed-off-by: Baruch Siach Signed-off-by: Stefan Roese --- common/spl/spl_sata.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c index 2fb46108a5..f0af9f38d1 100644 --- a/common/spl/spl_sata.c +++ b/common/spl/spl_sata.c @@ -53,9 +53,13 @@ static int spl_sata_load_image(struct spl_image_info *spl_image, CONFIG_SYS_SATA_FAT_BOOT_PARTITION)) #endif { - err = spl_load_image_fat(spl_image, stor_dev, + err = -ENOSYS; + + if (IS_ENABLED(CONFIG_SPL_FS_FAT)) { + err = spl_load_image_fat(spl_image, stor_dev, CONFIG_SYS_SATA_FAT_BOOT_PARTITION, - CONFIG_SPL_FS_LOAD_PAYLOAD_NAME); + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME); + } } if (err) { puts("Error loading sata device\n"); From f0aa1254776cbc0406d9b0b794479490799c3c47 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Thu, 16 May 2019 13:03:57 +0300 Subject: [PATCH 04/24] arm: mvebu: fix ahci mbus config in SPL SPL does not initialize mbus_dram_info. Don't change the ahci mbus settings of the ROM. This allows the ahci to work in SPL. Signed-off-by: Baruch Siach Reviewed-by: Chris Packham Signed-off-by: Stefan Roese --- arch/arm/mach-mvebu/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c index f09e7b10e9..f4b7a4fa80 100644 --- a/arch/arm/mach-mvebu/cpu.c +++ b/arch/arm/mach-mvebu/cpu.c @@ -542,6 +542,10 @@ static void ahci_mvebu_mbus_config(void __iomem *base) const struct mbus_dram_target_info *dram; int i; + /* mbus is not initialized in SPL; keep the ROM settings */ + if (IS_ENABLED(CONFIG_SPL_BUILD)) + return; + dram = mvebu_mbus_dram_info(); for (i = 0; i < 4; i++) { From 22c654557f250bf877d86e59d228c05c9a92e3b0 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Thu, 16 May 2019 13:03:58 +0300 Subject: [PATCH 05/24] arm: mvebu: add support for boot from SATA Add the required Kconfig and macro definitions to allow boot from SATA on Armada 38x systems. Signed-off-by: Baruch Siach Reviewed-by: Chris Packham Signed-off-by: Stefan Roese --- arch/arm/mach-mvebu/Kconfig | 5 +++++ arch/arm/mach-mvebu/Makefile | 3 +++ arch/arm/mach-mvebu/include/mach/soc.h | 2 ++ arch/arm/mach-mvebu/spl.c | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index 495c48e6c7..fdd39685b7 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -239,6 +239,11 @@ config MVEBU_SPL_BOOT_DEVICE_MMC bool "SDIO/MMC card" select SPL_LIBDISK_SUPPORT +config MVEBU_SPL_BOOT_DEVICE_SATA + bool "SATA" + select SPL_SATA_SUPPORT + select SPL_LIBDISK_SUPPORT + config MVEBU_SPL_BOOT_DEVICE_UART bool "UART" diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile index 02d3ce27ee..8228a17972 100644 --- a/arch/arm/mach-mvebu/Makefile +++ b/arch/arm/mach-mvebu/Makefile @@ -37,6 +37,9 @@ endif ifneq ($(CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC),) KWB_CFG_BOOT_FROM=sdio endif +ifneq ($(CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA),) + KWB_CFG_BOOT_FROM=sata +endif ifneq ($(CONFIG_MVEBU_SPL_BOOT_DEVICE_UART),) KWB_CFG_BOOT_FROM=uart endif diff --git a/arch/arm/mach-mvebu/include/mach/soc.h b/arch/arm/mach-mvebu/include/mach/soc.h index f666ee2424..acb9257c90 100644 --- a/arch/arm/mach-mvebu/include/mach/soc.h +++ b/arch/arm/mach-mvebu/include/mach/soc.h @@ -159,7 +159,9 @@ #define BOOT_DEV_SEL_MASK (0x3f << BOOT_DEV_SEL_OFFS) #define BOOT_FROM_NAND 0x0A +#define BOOT_FROM_SATA 0x22 #define BOOT_FROM_UART 0x28 +#define BOOT_FROM_SATA_ALT 0x2A #define BOOT_FROM_UART_ALT 0x3f #define BOOT_FROM_SPI 0x32 #define BOOT_FROM_MMC 0x30 diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index 530b98c1aa..d54de51956 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -59,6 +59,11 @@ static u32 get_boot_device(void) case BOOT_FROM_UART_ALT: #endif return BOOT_DEVICE_UART; +#ifdef BOOT_FROM_SATA + case BOOT_FROM_SATA: + case BOOT_FROM_SATA_ALT: + return BOOT_DEVICE_SATA; +#endif case BOOT_FROM_SPI: default: return BOOT_DEVICE_SPI; From 22c47f6bbe3aa8cbc9de2186e78fd40ebaa16d67 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Thu, 16 May 2019 13:04:01 +0300 Subject: [PATCH 06/24] arm: mvebu: clearfog: enable SATA in SPL Enable SATA peripherals in SPL to allow boot from SATA. Signed-off-by: Baruch Siach Reviewed-by: Chris Packham Signed-off-by: Stefan Roese --- arch/arm/dts/armada-388-clearfog-u-boot.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/dts/armada-388-clearfog-u-boot.dtsi b/arch/arm/dts/armada-388-clearfog-u-boot.dtsi index a12694e171..cf6c08881b 100644 --- a/arch/arm/dts/armada-388-clearfog-u-boot.dtsi +++ b/arch/arm/dts/armada-388-clearfog-u-boot.dtsi @@ -11,3 +11,11 @@ &sdhci { u-boot,dm-spl; }; + +&ahci0 { + u-boot,dm-spl; +}; + +&ahci1 { + u-boot,dm-spl; +}; From 6403d385b6dfe8de0485f119c20edaba2c460ab0 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Thu, 16 May 2019 13:04:02 +0300 Subject: [PATCH 07/24] arm: mvebu: clearfog: set U-Boot offset for SATA boot See the offset of U-Boot in raw SATA disk to the same value as the MMC offset. That is 0x140 sectors from the beginning of the SPL, which is 0x141 sectors from the beginning of the device (after the MBR sector). Signed-off-by: Baruch Siach Reviewed-by: Chris Packham Signed-off-by: Stefan Roese --- include/configs/clearfog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h index 4198ff0511..15c402b542 100644 --- a/include/configs/clearfog.h +++ b/include/configs/clearfog.h @@ -85,7 +85,7 @@ /* SPL related SPI defines */ #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x20000 #define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS -#elif defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC) +#elif defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC) || defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA) /* SPL related MMC defines */ #define CONFIG_SYS_MMC_U_BOOT_OFFS (160 << 10) #define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_MMC_U_BOOT_OFFS From 85fe44105aeb517fcbeb7110ee8500953f285342 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Thu, 16 May 2019 13:04:03 +0300 Subject: [PATCH 08/24] arm: mvebu: clearfog: document boot from SATA Document the main U-Boot image offset when booting from SATA disk on the Clearfog board. Signed-off-by: Baruch Siach Reviewed-by: Chris Packham Signed-off-by: Stefan Roese --- board/solidrun/clearfog/README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/board/solidrun/clearfog/README b/board/solidrun/clearfog/README index 0b0e98de90..6171ce66f4 100644 --- a/board/solidrun/clearfog/README +++ b/board/solidrun/clearfog/README @@ -40,6 +40,12 @@ Install U-Boot on eMMC boot partition from Linux running on Clearfog: Note that the SD card is not accessible when the Clearfog SOM has eMMC. Consider initial boot from UART (see below). +Install U-Boot on SATA: +----------------------- + +When loading the main U-Boot image from raw SATA sector, set +CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR to 0x141. + Boot selection: --------------- From 1b355e53fcfd2f05ab17f77851feb82bdf9e6b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 24 May 2019 14:57:48 +0200 Subject: [PATCH 09/24] arm: mvebu: turris_omnia: set default ethernet adapter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set default value for the ethact variable to the WAN port. Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Signed-off-by: Stefan Roese --- include/configs/turris_omnia.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/turris_omnia.h b/include/configs/turris_omnia.h index 018f54428b..290828d73e 100644 --- a/include/configs/turris_omnia.h +++ b/include/configs/turris_omnia.h @@ -122,6 +122,7 @@ LOAD_ADDRESS_ENV_SETTINGS \ "fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \ "console=ttyS0,115200\0" \ + "ethact=ethernet@34000\0" \ BOOTENV #endif /* CONFIG_SPL_BUILD */ From b0045b1c112d36faa8e876cdbef35e514b747a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 24 May 2019 14:57:49 +0200 Subject: [PATCH 10/24] arm: mvebu: turris_omnia: fix adapters MAC addresses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The board code reads MAC addresses from the ATSHA204A cryptochip. For compatibility reasons the ethernet adapters on this SOC are not enumerated in register address order. But when Omnia was first manufactured this was done differently. Change setting of MAC addresses to conform to the description on the stickers sticked on actual Omnias. Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Signed-off-by: Stefan Roese --- board/CZ.NIC/turris_omnia/turris_omnia.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c index ad6e29021e..cddde50b96 100644 --- a/board/CZ.NIC/turris_omnia/turris_omnia.c +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c @@ -513,11 +513,6 @@ int misc_init_r(void) mac[4] = mac1[2]; mac[5] = mac1[3]; - if (is_valid_ethaddr(mac)) - eth_env_set_enetaddr("ethaddr", mac); - - increment_mac(mac); - if (is_valid_ethaddr(mac)) eth_env_set_enetaddr("eth1addr", mac); @@ -526,6 +521,11 @@ int misc_init_r(void) if (is_valid_ethaddr(mac)) eth_env_set_enetaddr("eth2addr", mac); + increment_mac(mac); + + if (is_valid_ethaddr(mac)) + eth_env_set_enetaddr("ethaddr", mac); + out: return 0; } From 305a82217de391bbadce1dc5faac508daa11beaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 24 May 2019 14:57:50 +0200 Subject: [PATCH 11/24] arm: mvebu: turris_omnia: change environment address in SPI flash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The U-Boot partition is 1 MiB and environment is 64 KiB. It does not make sense to have environment at 0xc0000 when it could be at 0xf0000 and we can have more space for U-Boot binary. Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Signed-off-by: Stefan Roese --- include/configs/turris_omnia.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/configs/turris_omnia.h b/include/configs/turris_omnia.h index 290828d73e..8e3d5cc8cf 100644 --- a/include/configs/turris_omnia.h +++ b/include/configs/turris_omnia.h @@ -22,9 +22,9 @@ #define CONFIG_EHCI_IS_TDI /* Environment in SPI NOR flash */ -#define CONFIG_ENV_OFFSET (3*(1 << 18)) /* 768KiB in */ #define CONFIG_ENV_SIZE (64 << 10) /* 64KiB */ -#define CONFIG_ENV_SECT_SIZE (256 << 10) /* 256KiB sectors */ +#define CONFIG_ENV_OFFSET ((1 << 20) - CONFIG_ENV_SIZE) +#define CONFIG_ENV_SECT_SIZE (64 << 10) /* 64KiB */ #define PHY_ANEG_TIMEOUT 8000 /* PHY needs a longer aneg time */ From 422237ee5953927ba54946448d7f525a301dbec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 24 May 2019 14:57:51 +0200 Subject: [PATCH 12/24] arm: mvebu: turris_omnia: remove unneeded macro from board config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not needed here since Omnia is using DM_PCI now. Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Signed-off-by: Stefan Roese --- include/configs/turris_omnia.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/configs/turris_omnia.h b/include/configs/turris_omnia.h index 8e3d5cc8cf..26f85466a4 100644 --- a/include/configs/turris_omnia.h +++ b/include/configs/turris_omnia.h @@ -28,11 +28,6 @@ #define PHY_ANEG_TIMEOUT 8000 /* PHY needs a longer aneg time */ -/* PCIe support */ -#ifndef CONFIG_SPL_BUILD -#define CONFIG_PCI_SCAN_SHOW -#endif - /* Keep device tree and initrd in lower memory so the kernel can access them */ #define RELOCATION_LIMITS_ENV_SETTINGS \ "fdt_high=0x10000000\0" \ From 27e3d4846d8f5b81091365427279f95dec83b79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 24 May 2019 14:57:52 +0200 Subject: [PATCH 13/24] arm: mvebu: turris_omnia: prefer SCSI booting before USB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If SCSI and USB boot options are both available, try to boot from SCSI first. Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Signed-off-by: Stefan Roese --- include/configs/turris_omnia.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/turris_omnia.h b/include/configs/turris_omnia.h index 26f85466a4..edd776ec70 100644 --- a/include/configs/turris_omnia.h +++ b/include/configs/turris_omnia.h @@ -92,8 +92,8 @@ #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_DEVICES_MMC(func) \ - BOOT_TARGET_DEVICES_USB(func) \ BOOT_TARGET_DEVICES_SCSI(func) \ + BOOT_TARGET_DEVICES_USB(func) \ func(PXE, pxe, na) \ func(DHCP, dhcp, na) From 02aa5af92273a9e6a043923c4cf0c73dd5737558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 24 May 2019 14:57:53 +0200 Subject: [PATCH 14/24] arm: mvebu: turris_omnia: call pci_init from board init code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We always want to enumerate PCIe devices, because withouth this they won't work in Linux. Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Signed-off-by: Stefan Roese --- board/CZ.NIC/turris_omnia/turris_omnia.c | 1 + 1 file changed, 1 insertion(+) diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c index cddde50b96..eee150892a 100644 --- a/board/CZ.NIC/turris_omnia/turris_omnia.c +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c @@ -412,6 +412,7 @@ int board_late_init(void) set_regdomain(); handle_reset_button(); #endif + pci_init(); return 0; } From 6165c891287783a71fab703722615918dbf94796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 24 May 2019 14:57:54 +0200 Subject: [PATCH 15/24] arm: mvebu: turris_omnia: fix rescue mode bootcmd bootargs setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rescue mode bootcmd currently only appends the "omniarescue" parameter to the bootargs variable. We do not want the user to be able to change rescue mode bootargs. Therefore change this so that bootcmd sets the bootargs variable in an absolute way (adding console device information and the omniarescue paramterer). Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Signed-off-by: Stefan Roese --- board/CZ.NIC/turris_omnia/turris_omnia.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c index eee150892a..5f6ea35e5f 100644 --- a/board/CZ.NIC/turris_omnia/turris_omnia.c +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c @@ -340,7 +340,8 @@ static int set_regdomain(void) "i2c mw 0x2a.1 0x4 0x1c 1; " \ "mw.l 0x01000000 0x00ff000c; " \ "i2c write 0x01000000 0x2a.1 0x5 4 -s; " \ - "setenv bootargs \"$bootargs omniarescue=$omnia_reset\"; " \ + "setenv bootargs \"earlyprintk console=ttyS0,115200" \ + " omniarescue=$omnia_reset\"; " \ "sf probe; " \ "sf read 0x1000000 0x100000 0x700000; " \ "bootm 0x1000000; " \ From 7945436f888ecd3ba9f6efbc13be04b1bbaceabf Mon Sep 17 00:00:00 2001 From: Luka Kovacic Date: Tue, 25 Jun 2019 13:57:53 +0200 Subject: [PATCH 16/24] arm: mvebu: crs305-1g-4s: Enable CMD_BOOTZ and increase SYS_BOOTM_LEN This change enables CMD_BOOTZ and increases SYS_BOOTM_LEN to make it easier to work with kernel images. Signed-off-by: Luka Kovacic Reviewed-by: Stefan Roese Signed-off-by: Stefan Roese --- configs/crs305-1g-4s_defconfig | 1 + include/configs/crs305-1g-4s.h | 1 + 2 files changed, 2 insertions(+) diff --git a/configs/crs305-1g-4s_defconfig b/configs/crs305-1g-4s_defconfig index 26e1c91f29..df77cb89ca 100644 --- a/configs/crs305-1g-4s_defconfig +++ b/configs/crs305-1g-4s_defconfig @@ -7,6 +7,7 @@ CONFIG_BUILD_TARGET="u-boot.kwb" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_CMD_MEMTEST=y CONFIG_SYS_ALT_MEMTEST=y +CONFIG_CMD_BOOTZ=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y CONFIG_CMD_SF=y diff --git a/include/configs/crs305-1g-4s.h b/include/configs/crs305-1g-4s.h index c73cb99b1b..a2df69adc7 100644 --- a/include/configs/crs305-1g-4s.h +++ b/include/configs/crs305-1g-4s.h @@ -10,6 +10,7 @@ * High Level Configuration Options (easy to change) */ +#define CONFIG_SYS_BOOTM_LEN (64 * 1024 * 1024) /* 64 MB */ #define CONFIG_SYS_KWD_CONFIG $(CONFIG_BOARDDIR)/kwbimage.cfg #define CONFIG_SYS_TCLK 200000000 /* 200MHz */ From 54b8c51ebe2e0cb47a60c22f92c4502bab03c904 Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Fri, 28 Jun 2019 12:30:12 +1200 Subject: [PATCH 17/24] ARM: mvebu: Enable FIT support for db-xc3-24g4xg Signed-off-by: Chris Packham Reviewed-by: Stefan Roese Signed-off-by: Stefan Roese --- configs/db-xc3-24g4xg_defconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configs/db-xc3-24g4xg_defconfig b/configs/db-xc3-24g4xg_defconfig index 6264df0e02..071a889cd3 100644 --- a/configs/db-xc3-24g4xg_defconfig +++ b/configs/db-xc3-24g4xg_defconfig @@ -4,6 +4,9 @@ CONFIG_SYS_TEXT_BASE=0x00800000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_DB_XC3_24G4XG=y CONFIG_BUILD_TARGET="u-boot.kwb" +CONFIG_FIT=y +CONFIG_FIT_VERBOSE=y +CONFIG_FIT_BEST_MATCH=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_CMD_MEMTEST=y CONFIG_SYS_ALT_MEMTEST=y From c0fed3ac2568027c99ec79c32530b6f47a2c5136 Mon Sep 17 00:00:00 2001 From: Pascal Linder Date: Tue, 18 Jun 2019 13:27:47 +0200 Subject: [PATCH 18/24] km: modify Kconfig file organization for KM boards As preparation for the upcoming transferring of configurations from header files to Kconfig, a common Kconfig file for all KM boards was created. For the moment, it only sources the other three, more specific, Kconfig files. Therefore, the architecture Kconfig files now include the common Kconfig file. Also, the configuration selection for KM boards was moved from the architecture Kconfig files to the board specific Kconfig files. Signed-off-by: Pascal Linder Signed-off-by: Holger Brunck Cc: Mario Six Cc: Prabhakar Kushwaha Signed-off-by: Stefan Roese --- arch/arm/mach-kirkwood/Kconfig | 9 ++--- arch/powerpc/cpu/mpc83xx/Kconfig | 44 ++++++----------------- arch/powerpc/cpu/mpc85xx/Kconfig | 8 ++--- board/keymile/Kconfig | 16 +++++++++ board/keymile/km83xx/Kconfig | 62 ++++++++++++++++++++++++++++++++ board/keymile/km_arm/Kconfig | 7 ++++ board/keymile/kmp204x/Kconfig | 8 +++++ 7 files changed, 109 insertions(+), 45 deletions(-) create mode 100644 board/keymile/Kconfig diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig index 7c4170399a..2f68092f82 100644 --- a/arch/arm/mach-kirkwood/Kconfig +++ b/arch/arm/mach-kirkwood/Kconfig @@ -32,11 +32,8 @@ config TARGET_ICONNECT bool "iconnect Board" config TARGET_KM_KIRKWOOD - bool "KM_KIRKWOOD Board" - select BOARD_LATE_INIT - imply CMD_CRAMFS - imply CMD_DIAG - imply FS_CRAMFS + bool "KM Kirkwood Board" + select VENDOR_KM config TARGET_NET2BIG_V2 bool "LaCie 2Big Network v2 NAS Board" @@ -82,7 +79,7 @@ source "board/buffalo/lsxl/Kconfig" source "board/cloudengines/pogo_e02/Kconfig" source "board/d-link/dns325/Kconfig" source "board/iomega/iconnect/Kconfig" -source "board/keymile/km_arm/Kconfig" +source "board/keymile/Kconfig" source "board/LaCie/net2big_v2/Kconfig" source "board/LaCie/netspace_v2/Kconfig" source "board/raidsonic/ib62x0/Kconfig" diff --git a/arch/powerpc/cpu/mpc83xx/Kconfig b/arch/powerpc/cpu/mpc83xx/Kconfig index b99288aa83..3f68b6f645 100644 --- a/arch/powerpc/cpu/mpc83xx/Kconfig +++ b/arch/powerpc/cpu/mpc83xx/Kconfig @@ -100,65 +100,43 @@ config TARGET_IDS8313 config TARGET_KMETER1 bool "Support kmeter1" - select ARCH_MPC8360 - imply CMD_CRAMFS - imply CMD_DIAG - imply FS_CRAMFS + select VENDOR_KM config TARGET_KMCOGE5NE bool "Support kmcoge5ne" - select ARCH_MPC8360 - imply CMD_CRAMFS - imply CMD_DIAG - imply FS_CRAMFS + select VENDOR_KM config TARGET_SUVD3 bool "Support suvd3" - select ARCH_MPC832X - imply CMD_CRAMFS - imply FS_CRAMFS + select VENDOR_KM config TARGET_KMVECT1 bool "Support kmvect1" - select ARCH_MPC8309 - imply CMD_CRAMFS - imply FS_CRAMFS + select VENDOR_KM config TARGET_KMTEGR1 bool "Support kmtegr1" - select ARCH_MPC8309 - imply CMD_CRAMFS - imply FS_CRAMFS + select VENDOR_KM config TARGET_TUXX1 bool "Support tuxx1" - select ARCH_MPC832X - imply CMD_CRAMFS - imply FS_CRAMFS + select VENDOR_KM config TARGET_KMSUPX5 bool "Support kmsupx5" - select ARCH_MPC832X - imply CMD_CRAMFS - imply FS_CRAMFS + select VENDOR_KM config TARGET_TUGE1 bool "Support tuge1" - select ARCH_MPC832X - imply CMD_CRAMFS - imply FS_CRAMFS + select VENDOR_KM config TARGET_KMOPTI2 bool "Support kmopti2" - select ARCH_MPC832X - imply CMD_CRAMFS - imply FS_CRAMFS + select VENDOR_KM config TARGET_KMTEPR2 bool "Support kmtepr2" - select ARCH_MPC832X - imply CMD_CRAMFS - imply FS_CRAMFS + select VENDOR_KM config TARGET_TQM834X bool "Support TQM834x" @@ -354,7 +332,7 @@ source "board/freescale/mpc8349itx/Kconfig" source "board/freescale/mpc837xemds/Kconfig" source "board/freescale/mpc837xerdb/Kconfig" source "board/ids/ids8313/Kconfig" -source "board/keymile/km83xx/Kconfig" +source "board/keymile/Kconfig" source "board/mpc8308_p1m/Kconfig" source "board/sbc8349/Kconfig" source "board/tqc/tqm834x/Kconfig" diff --git a/arch/powerpc/cpu/mpc85xx/Kconfig b/arch/powerpc/cpu/mpc85xx/Kconfig index 7572404625..c038a6ddb0 100644 --- a/arch/powerpc/cpu/mpc85xx/Kconfig +++ b/arch/powerpc/cpu/mpc85xx/Kconfig @@ -412,11 +412,7 @@ config TARGET_CONTROLCENTERD config TARGET_KMP204X bool "Support kmp204x" - select ARCH_P2041 - select PHYS_64BIT - select FSL_DDR_INTERACTIVE - imply CMD_CRAMFS - imply FS_CRAMFS + select VENDOR_KM config TARGET_XPEDITE520X bool "Support xpedite520x" @@ -1620,7 +1616,7 @@ source "board/freescale/t208xrdb/Kconfig" source "board/freescale/t4qds/Kconfig" source "board/freescale/t4rdb/Kconfig" source "board/gdsys/p1022/Kconfig" -source "board/keymile/kmp204x/Kconfig" +source "board/keymile/Kconfig" source "board/sbc8548/Kconfig" source "board/socrates/Kconfig" source "board/varisys/cyrus/Kconfig" diff --git a/board/keymile/Kconfig b/board/keymile/Kconfig new file mode 100644 index 0000000000..e30d64818c --- /dev/null +++ b/board/keymile/Kconfig @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2019, Pascal Linder + +config VENDOR_KM + bool + help + Selected by any KM board to have additional configurations. + +if VENDOR_KM + +source "board/keymile/km83xx/Kconfig" +source "board/keymile/kmp204x/Kconfig" +source "board/keymile/km_arm/Kconfig" + +endif diff --git a/board/keymile/km83xx/Kconfig b/board/keymile/km83xx/Kconfig index fbbbb17034..0a41be57f5 100644 --- a/board/keymile/km83xx/Kconfig +++ b/board/keymile/km83xx/Kconfig @@ -9,6 +9,13 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "kmeter1" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_MPC8360 + imply CMD_CRAMFS + imply CMD_DIAG + imply FS_CRAMFS + endif if TARGET_KMCOGE5NE @@ -22,6 +29,13 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "kmcoge5ne" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_MPC8360 + imply CMD_CRAMFS + imply CMD_DIAG + imply FS_CRAMFS + endif if TARGET_KMVECT1 @@ -35,6 +49,12 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "kmvect1" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_MPC8309 + imply CMD_CRAMFS + imply FS_CRAMFS + endif if TARGET_KMTEGR1 @@ -48,6 +68,12 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "kmtegr1" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_MPC8309 + imply CMD_CRAMFS + imply FS_CRAMFS + endif if TARGET_SUVD3 @@ -61,6 +87,12 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "suvd3" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_MPC832X + imply CMD_CRAMFS + imply FS_CRAMFS + endif if TARGET_TUXX1 @@ -74,6 +106,12 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "tuxx1" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_MPC832X + imply CMD_CRAMFS + imply FS_CRAMFS + endif if TARGET_KMSUPX5 @@ -87,6 +125,12 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "kmsupx5" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_MPC832X + imply CMD_CRAMFS + imply FS_CRAMFS + endif if TARGET_TUGE1 @@ -100,6 +144,12 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "tuge1" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_MPC832X + imply CMD_CRAMFS + imply FS_CRAMFS + endif if TARGET_KMOPTI2 @@ -113,6 +163,12 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "kmopti2" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_MPC832X + imply CMD_CRAMFS + imply FS_CRAMFS + endif if TARGET_KMTEPR2 @@ -126,4 +182,10 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "kmtepr2" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_MPC832X + imply CMD_CRAMFS + imply FS_CRAMFS + endif diff --git a/board/keymile/km_arm/Kconfig b/board/keymile/km_arm/Kconfig index 3476780847..2542f1ea8f 100644 --- a/board/keymile/km_arm/Kconfig +++ b/board/keymile/km_arm/Kconfig @@ -9,4 +9,11 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "km_kirkwood" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select BOARD_LATE_INIT + imply CMD_CRAMFS + imply CMD_DIAG + imply FS_CRAMFS + endif diff --git a/board/keymile/kmp204x/Kconfig b/board/keymile/kmp204x/Kconfig index 7b45a13cfb..f74d4295c7 100644 --- a/board/keymile/kmp204x/Kconfig +++ b/board/keymile/kmp204x/Kconfig @@ -9,4 +9,12 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "kmp204x" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_P2041 + select FSL_DDR_INTERACTIVE + select PHYS_64BIT + imply CMD_CRAMFS + imply FS_CRAMFS + endif From f1696534838e45623c276658b4b7c9331181d60c Mon Sep 17 00:00:00 2001 From: Pascal Linder Date: Tue, 18 Jun 2019 08:41:01 +0200 Subject: [PATCH 19/24] km/spi: add weak functions to kirkwood_spi driver (DM part) The weak functions, known from the legacy code, are added to the DM part as well. For this purpose, the release operation first needs to be implemented. KM Kirkwood boards will overwrite those weak functions to change the MPP configuration when claiming/releasing the bus, because the hardware pins are shared between the SPI NOR and NAND devices. Signed-off-by: Pascal Linder Signed-off-by: Holger Brunck Signed-off-by: Stefan Roese --- drivers/spi/kirkwood_spi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c index 5dd1ad67cf..881a775003 100644 --- a/drivers/spi/kirkwood_spi.c +++ b/drivers/spi/kirkwood_spi.c @@ -338,6 +338,11 @@ static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen, return _spi_xfer(plat->spireg, bitlen, dout, din, flags); } +__attribute__((weak)) int mvebu_board_spi_claim_bus(struct udevice *dev) +{ + return 0; +} + static int mvebu_spi_claim_bus(struct udevice *dev) { struct udevice *bus = dev->parent; @@ -348,9 +353,19 @@ static int mvebu_spi_claim_bus(struct udevice *dev) KWSPI_CS_MASK << KWSPI_CS_SHIFT, spi_chip_select(dev) << KWSPI_CS_SHIFT); + return mvebu_board_spi_claim_bus(dev); +} + +__attribute__((weak)) int mvebu_board_spi_release_bus(struct udevice *dev) +{ return 0; } +static int mvebu_spi_release_bus(struct udevice *dev) +{ + return mvebu_board_spi_release_bus(dev); +} + static int mvebu_spi_probe(struct udevice *bus) { struct mvebu_spi_platdata *plat = dev_get_platdata(bus); @@ -377,6 +392,7 @@ static int mvebu_spi_ofdata_to_platdata(struct udevice *bus) static const struct dm_spi_ops mvebu_spi_ops = { .claim_bus = mvebu_spi_claim_bus, + .release_bus = mvebu_spi_release_bus, .xfer = mvebu_spi_xfer, .set_speed = mvebu_spi_set_speed, .set_mode = mvebu_spi_set_mode, From 53c3050d0dd3f885c35f5c44293c86a9b199c5ca Mon Sep 17 00:00:00 2001 From: Pascal Linder Date: Tue, 18 Jun 2019 08:41:02 +0200 Subject: [PATCH 20/24] km/spi: overwrite kirkwood_spi weak functions for KM Kirkwood boards As the SPI NOR and NAND devices share the same hardware pins, the MPP configuration has to be changed when claiming/releasing the bus. The current configuration is saved when claiming and restored when releasing. Furthermore, a general-purpose output is used to switch the chip-select signal. This is now also implemented for the DM part of the kirkwood_spi driver. Signed-off-by: Pascal Linder Signed-off-by: Holger Brunck Signed-off-by: Stefan Roese --- board/keymile/km_arm/km_arm.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c index ea03be9eb3..7087cc520f 100644 --- a/board/keymile/km_arm/km_arm.c +++ b/board/keymile/km_arm/km_arm.c @@ -322,6 +322,37 @@ void board_spi_release_bus(struct spi_slave *slave) kw_gpio_set_value(KM_FLASH_GPIO_PIN, 1); } +static const u32 spi_mpp_config[] = { + MPP1_SPI_MOSI, + MPP2_SPI_SCK, + MPP3_SPI_MISO, + 0 +}; + +static u32 spi_mpp_backup[4]; + +int mvebu_board_spi_claim_bus(struct udevice *dev) +{ + spi_mpp_backup[3] = 0; + + /* set new spi mpp config and save current one */ + kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup); + + kw_gpio_set_value(KM_FLASH_GPIO_PIN, 0); + + return 0; +} + +int mvebu_board_spi_release_bus(struct udevice *dev) +{ + /* restore saved mpp config */ + kirkwood_mpp_conf(spi_mpp_backup, NULL); + + kw_gpio_set_value(KM_FLASH_GPIO_PIN, 1); + + return 0; +} + #if (defined(CONFIG_KM_PIGGY4_88E6061)) #define PHY_LED_SEL_REG 0x18 From c85306345a82a80a59fe80f6261a9263325736ad Mon Sep 17 00:00:00 2001 From: Pascal Linder Date: Tue, 18 Jun 2019 08:41:03 +0200 Subject: [PATCH 21/24] km/spi: add SPI configuration to KM Kirkwood device tree In order to migrate the SPI flash interface to the driver model, the SPI configuration needs to be added in the KM Kirkwood device tree file. Signed-off-by: Pascal Linder Signed-off-by: Holger Brunck Signed-off-by: Stefan Roese --- arch/arm/dts/kirkwood-km_kirkwood.dts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm/dts/kirkwood-km_kirkwood.dts b/arch/arm/dts/kirkwood-km_kirkwood.dts index f035eff1c1..b2c0209f5d 100644 --- a/arch/arm/dts/kirkwood-km_kirkwood.dts +++ b/arch/arm/dts/kirkwood-km_kirkwood.dts @@ -13,6 +13,10 @@ device_type = "memory"; reg = <0x00000000 0x08000000>; }; + + aliases { + spi0 = &spi0; + }; }; &mdio { @@ -29,3 +33,21 @@ phy-handle = <ðphy0>; }; }; + +&spi0 { + status = "okay"; + + flash@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "st,m25p80", "jedec,spi-nor", "spi-flash"; + reg = <0>; + spi-max-frequency = <33000000>; + mode = <3>; + + partition@uboot { + reg = <0x000000 0x0c0000>; + label = "uboot"; + }; + }; +}; From c2cd4ec00c5d837bc4ce13befe43957bc3d132c7 Mon Sep 17 00:00:00 2001 From: Pascal Linder Date: Tue, 18 Jun 2019 08:42:59 +0200 Subject: [PATCH 22/24] km/spi: activate driver model for SPI flash on KM Kirkwood boards The corresponding configurations are selected in the common Kconfig file. This is easier than changing every affected board default configuration file. The default configuration for the PORTL2 board, however, still needs some modifications to correctly use the driver model. Signed-off-by: Pascal Linder Signed-off-by: Holger Brunck Signed-off-by: Stefan Roese --- board/keymile/km_arm/Kconfig | 3 +++ configs/portl2_defconfig | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/board/keymile/km_arm/Kconfig b/board/keymile/km_arm/Kconfig index 2542f1ea8f..19c1db3bc2 100644 --- a/board/keymile/km_arm/Kconfig +++ b/board/keymile/km_arm/Kconfig @@ -12,6 +12,9 @@ config SYS_CONFIG_NAME config BOARD_SPECIFIC_OPTIONS # dummy def_bool y select BOARD_LATE_INIT + select DM + select DM_SPI + select DM_SPI_FLASH imply CMD_CRAMFS imply CMD_DIAG imply FS_CRAMFS diff --git a/configs/portl2_defconfig b/configs/portl2_defconfig index fa546aa994..918d27c331 100644 --- a/configs/portl2_defconfig +++ b/configs/portl2_defconfig @@ -28,6 +28,8 @@ CONFIG_MTDIDS_DEFAULT="nand0=orion_nand" CONFIG_MTDPARTS_DEFAULT="mtdparts=orion_nand:-(ubi0);" CONFIG_CMD_UBI=y # CONFIG_CMD_UBIFS is not set +CONFIG_OF_CONTROL=y +CONFIG_DEFAULT_DEVICE_TREE="kirkwood-km_kirkwood" CONFIG_ENV_IS_IN_EEPROM=y CONFIG_BOOTCOUNT_LIMIT=y CONFIG_BOOTCOUNT_RAM=y @@ -42,4 +44,3 @@ CONFIG_SYS_NS16550=y CONFIG_SPI=y CONFIG_KIRKWOOD_SPI=y CONFIG_BCH=y -CONFIG_OF_LIBFDT=y From fd9d70d7383d7f3afa54af4308c78ce1c99dbddb Mon Sep 17 00:00:00 2001 From: Pascal Linder Date: Tue, 18 Jun 2019 08:44:02 +0200 Subject: [PATCH 23/24] km/spi: remove deprecated SPI flash driver code for KM Kirkwood boards KM Kirkwood boards now implement the driver model for its SPI flash interface. Therefore, the old board specific claim and release functions can be deleted. The preprocessor definition CONFIG_SYS_KW_SPI_MPP is yet unused as well. All its appearances and dependencies are removed in the kirkwood_spi driver, header files and finally the configuration whitelist. Signed-off-by: Pascal Linder Signed-off-by: Holger Brunck Signed-off-by: Stefan Roese --- arch/arm/include/asm/arch-mvebu/spi.h | 11 -------- board/keymile/km_arm/km_arm.c | 12 --------- drivers/spi/kirkwood_spi.c | 36 --------------------------- include/configs/km/km_arm.h | 5 ---- scripts/config_whitelist.txt | 1 - 5 files changed, 65 deletions(-) diff --git a/arch/arm/include/asm/arch-mvebu/spi.h b/arch/arm/include/asm/arch-mvebu/spi.h index d6f6d1ac57..58b6c32c4d 100644 --- a/arch/arm/include/asm/arch-mvebu/spi.h +++ b/arch/arm/include/asm/arch-mvebu/spi.h @@ -23,17 +23,6 @@ struct kwspi_registers { u32 dw_cfg; /* 0x10620 - Direct Write Configuration */ }; -/* They are used to define CONFIG_SYS_KW_SPI_MPP - * each of the below #defines selects which mpp is - * configured for each SPI signal in spi_claim_bus - * bit 0: selects pin for MOSI (MPP1 if 0, MPP6 if 1) - * bit 1: selects pin for SCK (MPP2 if 0, MPP10 if 1) - * bit 2: selects pin for MISO (MPP3 if 0, MPP11 if 1) - */ -#define MOSI_MPP6 (1 << 0) -#define SCK_MPP10 (1 << 1) -#define MISO_MPP11 (1 << 2) - /* Control Register */ #define KWSPI_CSN_ACT (1 << 0) /* Activates serial memory interface */ #define KWSPI_SMEMRDY (1 << 1) /* SerMem Data xfer ready */ diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c index 7087cc520f..3db80615ef 100644 --- a/board/keymile/km_arm/km_arm.c +++ b/board/keymile/km_arm/km_arm.c @@ -310,18 +310,6 @@ int board_late_init(void) return 0; } -int board_spi_claim_bus(struct spi_slave *slave) -{ - kw_gpio_set_value(KM_FLASH_GPIO_PIN, 0); - - return 0; -} - -void board_spi_release_bus(struct spi_slave *slave) -{ - kw_gpio_set_value(KM_FLASH_GPIO_PIN, 1); -} - static const u32 spi_mpp_config[] = { MPP1_SPI_MOSI, MPP2_SPI_SCK, diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c index 881a775003..c725625146 100644 --- a/drivers/spi/kirkwood_spi.c +++ b/drivers/spi/kirkwood_spi.c @@ -151,10 +151,6 @@ void spi_free_slave(struct spi_slave *slave) free(slave); } -#if defined(CONFIG_SYS_KW_SPI_MPP) -u32 spi_mpp_backup[4]; -#endif - __attribute__((weak)) int board_spi_claim_bus(struct spi_slave *slave) { return 0; @@ -162,34 +158,6 @@ __attribute__((weak)) int board_spi_claim_bus(struct spi_slave *slave) int spi_claim_bus(struct spi_slave *slave) { -#if defined(CONFIG_SYS_KW_SPI_MPP) - u32 config; - u32 spi_mpp_config[4]; - - config = CONFIG_SYS_KW_SPI_MPP; - - if (config & MOSI_MPP6) - spi_mpp_config[0] = MPP6_SPI_MOSI; - else - spi_mpp_config[0] = MPP1_SPI_MOSI; - - if (config & SCK_MPP10) - spi_mpp_config[1] = MPP10_SPI_SCK; - else - spi_mpp_config[1] = MPP2_SPI_SCK; - - if (config & MISO_MPP11) - spi_mpp_config[2] = MPP11_SPI_MISO; - else - spi_mpp_config[2] = MPP3_SPI_MISO; - - spi_mpp_config[3] = 0; - spi_mpp_backup[3] = 0; - - /* set new spi mpp and save current mpp config */ - kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup); -#endif - return board_spi_claim_bus(slave); } @@ -199,10 +167,6 @@ __attribute__((weak)) void board_spi_release_bus(struct spi_slave *slave) void spi_release_bus(struct spi_slave *slave) { -#if defined(CONFIG_SYS_KW_SPI_MPP) - kirkwood_mpp_conf(spi_mpp_backup, NULL); -#endif - board_spi_release_bus(slave); } diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h index 8a00ac015a..a381a98470 100644 --- a/include/configs/km/km_arm.h +++ b/include/configs/km/km_arm.h @@ -201,11 +201,6 @@ int get_scl(void); #define CONFIG_SYS_REDUNDAND_ENVIRONMENT - -/* SPI bus claim MPP configuration */ -#define CONFIG_SYS_KW_SPI_MPP 0x0 - -#define FLASH_GPIO_PIN 0x00010000 #define KM_FLASH_GPIO_PIN 16 #define CONFIG_KM_UPDATE_UBOOT \ diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 2fc77b77c2..2c9cfb450d 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -3066,7 +3066,6 @@ CONFIG_SYS_JFFS2_SORT_FRAGMENTS CONFIG_SYS_KMBEC_FPGA_BASE CONFIG_SYS_KMBEC_FPGA_SIZE CONFIG_SYS_KWD_CONFIG -CONFIG_SYS_KW_SPI_MPP CONFIG_SYS_L2 CONFIG_SYS_L2_PL310 CONFIG_SYS_L2_SIZE From cc66ebdeeca5c4ed095bbd521b748bb009d99728 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Wed, 10 Jul 2019 18:23:04 +0300 Subject: [PATCH 24/24] arm: mvebu: set 38x and 39x AVS on lower frequency Reduce Auto Voltage Scaling VDD limit when core frequency is lower than 1600MHz. This reduces core voltage level from 1.25V to 1.15V, which saves power. The code is taken from Marvell's U-Boot 2013.01 revision 18.06. Reviewed-by: Chris Packham Tested-by: Chris Packham Signed-off-by: Baruch Siach Signed-off-by: Stefan Roese --- arch/arm/mach-mvebu/include/mach/cpu.h | 7 +++++ arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c | 26 +++++++++++++++++++ arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h | 4 +++ arch/arm/mach-mvebu/spl.c | 3 +++ 4 files changed, 40 insertions(+) diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h index e6140d6729..2e2d72aac8 100644 --- a/arch/arm/mach-mvebu/include/mach/cpu.h +++ b/arch/arm/mach-mvebu/include/mach/cpu.h @@ -163,6 +163,13 @@ int serdes_phy_config(void); */ int ddr3_init(void); +/* Auto Voltage Scaling */ +#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X) +void mv_avs_init(void); +#else +static inline void mv_avs_init(void) {} +#endif + /* * get_ref_clk * diff --git a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c index d387893af3..e9dd096ad0 100644 --- a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c +++ b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c @@ -256,3 +256,29 @@ u8 sys_env_device_rev_get(void) value = reg_read(DEV_VERSION_ID_REG); return (value & (REVISON_ID_MASK)) >> REVISON_ID_OFFS; } + +void mv_avs_init(void) +{ + u32 sar_freq; + + if (!(IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_ARMADA_39X))) + return; + + reg_write(AVS_DEBUG_CNTR_REG, AVS_DEBUG_CNTR_DEFAULT_VALUE); + reg_write(AVS_DEBUG_CNTR_REG, AVS_DEBUG_CNTR_DEFAULT_VALUE); + + sar_freq = reg_read(DEVICE_SAMPLE_AT_RESET1_REG); + sar_freq = sar_freq >> SAR_FREQ_OFFSET & SAR_FREQ_MASK; + + /* Set AVS value only for core frequency of 1600MHz or less. + * For higher frequency leave the default value. + */ + if (sar_freq <= 0xd) { + u32 avs_reg_data = reg_read(AVS_ENABLED_CONTROL); + + avs_reg_data &= ~(AVS_LOW_VDD_LIMIT_MASK + | AVS_HIGH_VDD_LIMIT_MASK); + avs_reg_data |= AVS_LOW_VDD_SLOW_VAL | AVS_HIGH_VDD_SLOW_VAL; + reg_write(AVS_ENABLED_CONTROL, avs_reg_data); + } +} diff --git a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h index 365332d2b0..1774a5b780 100644 --- a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h +++ b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h @@ -33,6 +33,8 @@ #define DEV_ID_REG_DEVICE_ID_OFFS 16 #define DEV_ID_REG_DEVICE_ID_MASK 0xffff0000 +#define SAR_FREQ_OFFSET 10 +#define SAR_FREQ_MASK 0x1f #define SAR_DEV_ID_OFFS 27 #define SAR_DEV_ID_MASK 0x7 @@ -155,10 +157,12 @@ #define AVS_LOW_VDD_LIMIT_OFFS 4 #define AVS_LOW_VDD_LIMIT_MASK (0xff << AVS_LOW_VDD_LIMIT_OFFS) #define AVS_LOW_VDD_LIMIT_VAL (0x27 << AVS_LOW_VDD_LIMIT_OFFS) +#define AVS_LOW_VDD_SLOW_VAL (0x23 << AVS_LOW_VDD_LIMIT_OFFS) #define AVS_HIGH_VDD_LIMIT_OFFS 12 #define AVS_HIGH_VDD_LIMIT_MASK (0xff << AVS_HIGH_VDD_LIMIT_OFFS) #define AVS_HIGH_VDD_LIMIT_VAL (0x27 << AVS_HIGH_VDD_LIMIT_OFFS) +#define AVS_HIGH_VDD_SLOW_VAL (0x23 << AVS_HIGH_VDD_LIMIT_OFFS) /* Board ID numbers */ #define MARVELL_BOARD_ID_MASK 0x10 diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index d54de51956..3cb27b7f4b 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -126,6 +126,9 @@ void board_init_f(ulong dummy) ddr3_init(); #endif + /* Initialize Auto Voltage Scaling */ + mv_avs_init(); + /* * Return to the BootROM to continue the Marvell xmodem * UART boot protocol. As initiated by the kwboot tool.