From 9c2aa7e7070a3e7c4341c83c375b47e48108a8ff Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 4 Nov 2020 14:01:45 +0100 Subject: microblaze: Enable GCC garbage collector for full U-Boot GCC's garbage collector works for Microblaze for quite a long time but none has enabled it. The same change has be done for example by commit fac4790491f6 ("arc: Eliminate unused code and data with GCC's garbage collector"). Before: text data bss dec hex filename 588760 33592 39192 661544 a1828 u-boot After: text data bss dec hex filename 504504 32164 38608 575276 8c72c u-boot Which saves almost 15% of memory footprint. Also group symbols/functions to proper section. Reported-by: Tom Rini Signed-off-by: Michal Simek --- arch/microblaze/config.mk | 3 +++ arch/microblaze/cpu/u-boot.lds | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk index 96c39b1..de5b97e 100644 --- a/arch/microblaze/config.mk +++ b/arch/microblaze/config.mk @@ -9,6 +9,9 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__ +PLATFORM_CPPFLAGS += -fdata-sections -ffunction-sections + +LDFLAGS_FINAL += --gc-sections ifeq ($(CONFIG_SPL_BUILD),) PLATFORM_CPPFLAGS += -fPIC diff --git a/arch/microblaze/cpu/u-boot.lds b/arch/microblaze/cpu/u-boot.lds index 9282643..5dc09db 100644 --- a/arch/microblaze/cpu/u-boot.lds +++ b/arch/microblaze/cpu/u-boot.lds @@ -14,7 +14,7 @@ SECTIONS { __text_start = .; arch/microblaze/cpu/start.o (.text) - *(.text) + *(.text*) __text_end = .; } @@ -28,7 +28,7 @@ SECTIONS .data ALIGN(0x4): { __data_start = .; - *(.data) + *(.data*) __data_end = .; } @@ -51,7 +51,7 @@ SECTIONS __bss_start = .; *(.sbss) *(.scommon) - *(.bss) + *(.bss*) *(COMMON) . = ALIGN(4); __bss_end = .; -- cgit v1.1 From 91218f4c242dfc7cb8230efd3966f01619e87804 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 4 Nov 2020 15:46:32 +0100 Subject: microblaze: Clean config file from ifdef mess A lot of configs has been moved to Kconfig and it ends up in ifdef mess with no bodies. That's why remove all of them. Signed-off-by: Michal Simek --- include/configs/microblaze-generic.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index 2b41242..d5b2bd8 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -67,24 +67,6 @@ # define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of sectors on one chip */ # define CONFIG_SYS_MAX_FLASH_SECT 512 -/* hardware flash protection */ -/* use buffered writes (20x faster) */ -# ifdef RAMENV -# else /* FLASH && !RAMENV */ -/* 128K(one sector) for env */ -# endif /* FLASH && !RAMBOOT */ -#else /* !FLASH */ - -#ifdef SPIFLASH -# ifdef RAMENV -# else /* SPIFLASH && !RAMENV */ -/* 128K(two sectors) for env */ -/* Warning: adjust the offset in respect of other flash content and size */ -# endif /* SPIFLASH && !RAMBOOT */ -#else /* !SPIFLASH */ - -/* ENV in RAM */ -#endif /* !SPIFLASH */ #endif /* !FLASH */ #define XILINX_USE_ICACHE 1 @@ -111,12 +93,6 @@ */ #define CONFIG_BOOTP_BOOTFILESIZE -#if defined(CONFIG_MTD_PARTITIONS) -/* MTD partitions */ - -/* default mtd partition table */ -#endif - /* size of console buffer */ #define CONFIG_SYS_CBSIZE 512 /* max number of command args */ -- cgit v1.1 From 7556fa09e0ec52a27e05206ada4aa5685e01f3c1 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 4 Nov 2020 15:58:04 +0100 Subject: microblaze: Simplify cache handling Enable caches by default. For now just simplify config file but it should be read from DT or PVRs. Signed-off-by: Michal Simek --- include/configs/microblaze-generic.h | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index d5b2bd8..05ea64b 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -69,20 +69,8 @@ # define CONFIG_SYS_MAX_FLASH_SECT 512 #endif /* !FLASH */ -#define XILINX_USE_ICACHE 1 -#define XILINX_USE_DCACHE 1 - -#if defined(XILINX_USE_ICACHE) -# define CONFIG_ICACHE -#else -# undef CONFIG_ICACHE -#endif - -#if defined(XILINX_USE_DCACHE) -# define CONFIG_DCACHE -#else -# undef CONFIG_DCACHE -#endif +#define CONFIG_ICACHE +#define CONFIG_DCACHE #ifndef XILINX_DCACHE_BYTE_SIZE #define XILINX_DCACHE_BYTE_SIZE 32768 -- cgit v1.1 From 6c5828dc4bdae40697f162645b76fe815bf548b3 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 4 Nov 2020 16:00:38 +0100 Subject: microblaze: Get rid of xparameters.h There is no need to use this file anymore. Include it in main config file and simplify logic based on it. Signed-off-by: Michal Simek --- board/xilinx/microblaze-generic/xparameters.h | 18 ------------------ include/configs/microblaze-generic.h | 7 ++++++- 2 files changed, 6 insertions(+), 19 deletions(-) delete mode 100644 board/xilinx/microblaze-generic/xparameters.h diff --git a/board/xilinx/microblaze-generic/xparameters.h b/board/xilinx/microblaze-generic/xparameters.h deleted file mode 100644 index 5e0911f..0000000 --- a/board/xilinx/microblaze-generic/xparameters.h +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * (C) Copyright 2007 Michal Simek - * - * Michal SIMEK - * - * CAUTION: This file is a faked configuration !!! - * There is no real target for the microblaze-generic - * configuration. You have to replace this file with - * the generated file from your Xilinx design flow. - */ - -/* Microblaze is microblaze_0 */ -#define XILINX_FSL_NUMBER 3 - -/* Flash Memory is FLASH_2Mx32 */ -#define XILINX_FLASH_START 0x2c000000 -#define XILINX_FLASH_SIZE 0x00800000 diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index 05ea64b..2cfcace 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -8,7 +8,12 @@ #ifndef __CONFIG_H #define __CONFIG_H -#include "../board/xilinx/microblaze-generic/xparameters.h" +/* Microblaze is microblaze_0 */ +#define XILINX_FSL_NUMBER 3 + +/* Flash Memory is FLASH_2Mx32 */ +#define XILINX_FLASH_START 0x2c000000 +#define XILINX_FLASH_SIZE 0x00800000 /* MicroBlaze CPU */ #define MICROBLAZE_V5 1 -- cgit v1.1 From a3c43fb01a1b63b9bb279835aeab730d55683097 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 4 Nov 2020 16:08:40 +0100 Subject: microblaze: Remove CONFIG_SYS_FDT_SIZE CONFIG_SYS_FDT_SIZE is not use anywhere that's why remove it. Signed-off-by: Michal Simek --- include/configs/microblaze-generic.h | 1 - scripts/config_whitelist.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index 2cfcace..7255011 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -171,7 +171,6 @@ #define CONFIG_SYS_FDT_BASE (CONFIG_SYS_FLASH_BASE + \ 0x40000) -#define CONFIG_SYS_FDT_SIZE (16 << 10) #define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_TEXT_BASE + \ 0x1000000) diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 0aabe7a..8b4fcba 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -2170,7 +2170,6 @@ CONFIG_SYS_FCC_PSMR CONFIG_SYS_FDT_BASE CONFIG_SYS_FDT_LOAD_ADDR CONFIG_SYS_FDT_PAD -CONFIG_SYS_FDT_SIZE CONFIG_SYS_FEC0_IOBASE CONFIG_SYS_FEC1_IOBASE CONFIG_SYS_FECI2C -- cgit v1.1 From 09996b4d8466a31c300d5de37c3cf8ff33f151a7 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 4 Nov 2020 16:12:20 +0100 Subject: microblaze: Unify of setting for SPL_NOR/XIP support XIP is not enabled in SPL. SPL_NOR is enabled but any macro setting with using SYS_FLASH_BASE are wrong because it is not aligned with DM. That's why change these macro and align them with TEXT_BASE macro. Information should be find at run time based on DT but implementation is not done yet. Signed-off-by: Michal Simek --- include/configs/microblaze-generic.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index 7255011..c31a7880 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -163,14 +163,12 @@ /* SPL part */ -#ifdef CONFIG_SYS_FLASH_BASE -# define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_FLASH_BASE -#endif +#define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE /* for booting directly linux */ +#define CONFIG_SYS_FDT_BASE (CONFIG_SYS_TEXT_BASE + \ + 0x40000) -#define CONFIG_SYS_FDT_BASE (CONFIG_SYS_FLASH_BASE + \ - 0x40000) #define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_TEXT_BASE + \ 0x1000000) -- cgit v1.1 From 631a241e4884579774ff6bad60ff3cadf28f80e6 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 4 Nov 2020 16:14:06 +0100 Subject: microblaze: Detect NOR flash based on DT Remove fixed configuration and detect flash based on DT. Also increase amount of flash sectors to 2048 because on kc705 flash has 1027 sectors. Bank # 1: CFI conformant flash (16 x 16) Size: 128 MB in 1027 Sectors Intel Extended command set, Manufacturer ID: 0x89, Device ID: 0x8962 Erase timeout: 4096 ms, write timeout: 2 ms Buffer write timeout: 5 ms, buffer size: 1024 bytes Signed-off-by: Michal Simek --- configs/microblaze-generic_defconfig | 2 ++ include/configs/microblaze-generic.h | 41 +++--------------------------------- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/configs/microblaze-generic_defconfig b/configs/microblaze-generic_defconfig index 08c8885..761cc65 100644 --- a/configs/microblaze-generic_defconfig +++ b/configs/microblaze-generic_defconfig @@ -48,8 +48,10 @@ CONFIG_DM_I2C=y CONFIG_LED=y CONFIG_LED_GPIO=y CONFIG_MTD=y +CONFIG_DM_MTD=y CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y CONFIG_FLASH_CFI_MTD=y CONFIG_SYS_FLASH_PROTECTION=y diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index c31a7880..bc0bf04 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -11,26 +11,11 @@ /* Microblaze is microblaze_0 */ #define XILINX_FSL_NUMBER 3 -/* Flash Memory is FLASH_2Mx32 */ -#define XILINX_FLASH_START 0x2c000000 -#define XILINX_FLASH_SIZE 0x00800000 - /* MicroBlaze CPU */ #define MICROBLAZE_V5 1 #define CONFIG_SYS_BOOTM_LEN (64 * 1024 * 1024) -/* linear and spi flash memory */ -#ifdef XILINX_FLASH_START -#define FLASH -#undef SPIFLASH -#undef RAMENV /* hold environment in flash */ -#else -#undef FLASH -#undef SPIFLASH -#define RAMENV /* hold environment in RAM */ -#endif - /* uart */ /* The following table includes the supported baudrates */ # define CONFIG_SYS_BAUDRATE_TABLE \ @@ -45,34 +30,14 @@ #define CONFIG_SYS_INIT_SP_OFFSET (CONFIG_SYS_TEXT_BASE - \ CONFIG_SYS_MALLOC_F_LEN) -/* - * CFI flash memory layout - Example - * CONFIG_SYS_FLASH_BASE = 0x2200_0000; - * CONFIG_SYS_FLASH_SIZE = 0x0080_0000; 8MB - * - * SECT_SIZE = 0x20000; 128kB is one sector - * CONFIG_ENV_SIZE = SECT_SIZE; 128kB environment store - * - * 0x2200_0000 CONFIG_SYS_FLASH_BASE - * FREE 256kB - * 0x2204_0000 CONFIG_ENV_ADDR - * ENV_AREA 128kB - * 0x2206_0000 - * FREE - * 0x2280_0000 CONFIG_SYS_FLASH_BASE + CONFIG_SYS_FLASH_SIZE - * - */ - -#ifdef FLASH -# define CONFIG_SYS_FLASH_BASE XILINX_FLASH_START -# define CONFIG_SYS_FLASH_SIZE XILINX_FLASH_SIZE +#ifdef CONFIG_CFI_FLASH /* ?empty sector */ # define CONFIG_SYS_FLASH_EMPTY_INFO 1 /* max number of memory banks */ # define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of sectors on one chip */ -# define CONFIG_SYS_MAX_FLASH_SECT 512 -#endif /* !FLASH */ +# define CONFIG_SYS_MAX_FLASH_SECT 2048 +#endif #define CONFIG_ICACHE #define CONFIG_DCACHE -- cgit v1.1 From d99f163792089f85d57dad5c63db12a5017766c1 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 6 Nov 2020 15:05:57 +0100 Subject: tpm: spi: Cleanup source code There is no need for GD to be used and priv variable is unused. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- drivers/tpm/tpm2_tis_spi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/tpm/tpm2_tis_spi.c b/drivers/tpm/tpm2_tis_spi.c index 9a8145e..0045bed 100644 --- a/drivers/tpm/tpm2_tis_spi.c +++ b/drivers/tpm/tpm2_tis_spi.c @@ -30,8 +30,6 @@ #include "tpm_tis.h" #include "tpm_internal.h" -DECLARE_GLOBAL_DATA_PTR; - #define TPM_ACCESS(l) (0x0000 | ((l) << 12)) #define TPM_INT_ENABLE(l) (0x0008 | ((l) << 12)) #define TPM_STS(l) (0x0018 | ((l) << 12)) @@ -520,7 +518,6 @@ static int tpm_tis_spi_cleanup(struct udevice *dev) static int tpm_tis_spi_open(struct udevice *dev) { struct tpm_chip *chip = dev_get_priv(dev); - struct tpm_chip_priv *priv = dev_get_uclass_priv(dev); if (chip->is_open) return -EBUSY; -- cgit v1.1 From 6004db972d04e419e7b36e10bdee1bbafd339ad6 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Tue, 10 Nov 2020 13:10:04 +0100 Subject: arm64: zynqmp: Get rid of unused macros There is no reason to have these macros. But record offsets of missing register in the structure for future use. Signed-off-by: Michal Simek --- arch/arm/mach-zynqmp/include/mach/hardware.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-zynqmp/include/mach/hardware.h b/arch/arm/mach-zynqmp/include/mach/hardware.h index c5ba421..b328837 100644 --- a/arch/arm/mach-zynqmp/include/mach/hardware.h +++ b/arch/arm/mach-zynqmp/include/mach/hardware.h @@ -134,7 +134,8 @@ struct apu_regs { struct csu_regs { u32 reserved0[4]; u32 multi_boot; - u32 reserved1[12]; + u32 reserved1[11]; + u32 idcode; u32 version; }; @@ -149,7 +150,4 @@ struct pmu_regs { #define pmu_base ((struct pmu_regs *)ZYNQMP_PMU_BASEADDR) -#define ZYNQMP_CSU_IDCODE_ADDR 0xFFCA0040 -#define ZYNQMP_CSU_VER_ADDR 0xFFCA0044 - #endif /* _ASM_ARCH_HARDWARE_H */ -- cgit v1.1 From 072dbc7ac551ff4e316ac66988a8b915f48cc06f Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 9 Nov 2020 15:46:57 +0100 Subject: arm64: zynqmp: Enable TPM for xilinx platforms TPMs are becoming popular that's why enable drivers and command for it. Signed-off-by: Michal Simek --- configs/xilinx_zynqmp_virt_defconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configs/xilinx_zynqmp_virt_defconfig b/configs/xilinx_zynqmp_virt_defconfig index 0c816de..bac8117 100644 --- a/configs/xilinx_zynqmp_virt_defconfig +++ b/configs/xilinx_zynqmp_virt_defconfig @@ -57,6 +57,7 @@ CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y CONFIG_CMD_TIMER=y +CONFIG_CMD_TPM=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_MTDPARTS=y CONFIG_CMD_MTDPARTS_SPREAD=y @@ -137,6 +138,7 @@ CONFIG_ZYNQ_SERIAL=y CONFIG_SPI=y CONFIG_ZYNQ_SPI=y CONFIG_ZYNQMP_GQSPI=y +CONFIG_TPM2_TIS_SPI=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y @@ -156,5 +158,6 @@ CONFIG_USB_ETHER_ASIX=y CONFIG_WDT=y CONFIG_WDT_CDNS=y CONFIG_PANIC_HANG=y +CONFIG_TPM=y CONFIG_SPL_GZIP=y CONFIG_OF_LIBFDT_OVERLAY=y -- cgit v1.1 From 5fb093f471d2ded8f8ad58a85f247b84631ca8dc Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 6 Nov 2020 13:53:01 +0100 Subject: fru: common: Switch capture variable with the rest capture variable is bool which is just one byte and it is just causing unaligned accesses. Better to have it as last entry in the structure. It also simplify offset calculation for initial header copy. Signed-off-by: Michal Simek --- board/xilinx/common/fru.h | 2 +- board/xilinx/common/fru_ops.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/board/xilinx/common/fru.h b/board/xilinx/common/fru.h index a3e6520..e85dde4 100644 --- a/board/xilinx/common/fru.h +++ b/board/xilinx/common/fru.h @@ -53,9 +53,9 @@ struct fru_board_data { }; struct fru_table { - bool captured; struct fru_common_hdr hdr; struct fru_board_data brd; + bool captured; }; #define FRU_TYPELEN_CODE_MASK 0xC0 diff --git a/board/xilinx/common/fru_ops.c b/board/xilinx/common/fru_ops.c index fc3add7..affcb12 100644 --- a/board/xilinx/common/fru_ops.c +++ b/board/xilinx/common/fru_ops.c @@ -217,7 +217,7 @@ int fru_capture(unsigned long addr) hdr = (struct fru_common_hdr *)addr; - memcpy((void *)&fru_data.hdr, (void *)hdr, + memcpy((void *)&fru_data, (void *)hdr, sizeof(struct fru_common_hdr)); fru_data.captured = true; -- cgit v1.1 From b8771d0b1d660dfe34d55ddf320495325315d1d9 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 6 Nov 2020 13:55:45 +0100 Subject: fru: ops: Do not let parser to write data to not allocated space If customs fields in board area are used it will likely go over allocated space in struct fru_board_data. That's why calculate limit of this structure to make sure that different data is not rewritten by accident. When limit is reached stop to record fields. Signed-off-by: Michal Simek --- board/xilinx/common/fru_ops.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/board/xilinx/common/fru_ops.c b/board/xilinx/common/fru_ops.c index affcb12..b4cd3d4 100644 --- a/board/xilinx/common/fru_ops.c +++ b/board/xilinx/common/fru_ops.c @@ -163,12 +163,15 @@ static int fru_parse_board(unsigned long addr) { u8 i, type; int len; - u8 *data, *term; + u8 *data, *term, *limit; memcpy(&fru_data.brd.ver, (void *)addr, 6); addr += 6; data = (u8 *)&fru_data.brd.manufacturer_type_len; + /* Record max structure limit not to write data over allocated space */ + limit = data + sizeof(struct fru_board_data); + for (i = 0; ; i++, data += FRU_BOARD_MAX_LEN) { len = fru_check_type_len(*(u8 *)addr, fru_data.brd.lang_code, &type); @@ -178,6 +181,9 @@ static int fru_parse_board(unsigned long addr) if (len == -EINVAL) break; + /* Stop when amount of chars is more then fields to record */ + if (data + len > limit) + break; /* This record type/len field */ *data++ = *(u8 *)addr; -- cgit v1.1 From cd40b826554e535d56dcc09dbb97c47048bd3b32 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 6 Nov 2020 13:58:01 +0100 Subject: fru: common: Record pcie/uuid fields in custom board area Add additional fields. They will be just recorded and filled but not shown. Signed-off-by: Michal Simek --- board/xilinx/common/fru.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/board/xilinx/common/fru.h b/board/xilinx/common/fru.h index e85dde4..e728470 100644 --- a/board/xilinx/common/fru.h +++ b/board/xilinx/common/fru.h @@ -50,6 +50,10 @@ struct fru_board_data { /* Xilinx custom fields */ u8 rev_type_len; u8 rev[FRU_BOARD_MAX_LEN]; + u8 pcie_type_len; + u8 pcie[FRU_BOARD_MAX_LEN]; + u8 uuid_type_len; + u8 uuid[FRU_BOARD_MAX_LEN]; }; struct fru_table { -- cgit v1.1