From 07c5cbbd1e6573e169687da873db37503a1f8b60 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Fri, 12 Jan 2018 15:30:55 -0300 Subject: [PATCH 1/8] nand: zynq: Fix driver initialization This driver is currently broken, refusing to initialize properly. The reason is that get_nand_dev_by_index() was being called before nand_register(), thus returning a pointer into uninitialized memory. In other words, the struct mtd_info used by the driver is total junk. Fix it by getting the correct struct mtd_info, via nand_to_mtd() on the driver's struct nand_chip. Tested on a custom board, where the CPU is halted without this patch. Signed-off-by: Ezequiel Garcia Reviewed-by: Michal Simek Signed-off-by: Michal Simek --- drivers/mtd/nand/zynq_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c index 6494196..9f6ff3d 100644 --- a/drivers/mtd/nand/zynq_nand.c +++ b/drivers/mtd/nand/zynq_nand.c @@ -1025,7 +1025,7 @@ int zynq_nand_init(struct nand_chip *nand_chip, int devnum) } xnand->nand_base = (void __iomem *)ZYNQ_NAND_BASEADDR; - mtd = get_nand_dev_by_index(0); + mtd = nand_to_mtd(nand_chip); nand_chip->priv = xnand; mtd->priv = nand_chip; From 41b7d7f241221ab9f0888f47f31226cfa74a971a Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Sat, 13 Jan 2018 14:56:17 -0300 Subject: [PATCH 2/8] nand: zynq: Cleanup initialization CONFIG_NAND_ZYNQ selects CONFIG_SYS_NAND_SELF_INIT, so the driver doesn't have to play any ifdef game. Also, we can mark zynq_nand_init() as static and get rid of the mach-specific nand.h header. This is really a revert of: "mtd: zynq: nand: Move board_nand_init() function to board.c" (sha1: 310995d9f91ae56082b49be06fe8c3d01424f8f6) Signed-off-by: Ezequiel Garcia Reviewed-by: Michal Simek Signed-off-by: Michal Simek --- arch/arm/mach-zynq/include/mach/nand.h | 9 --------- drivers/mtd/nand/zynq_nand.c | 6 ++---- 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 arch/arm/mach-zynq/include/mach/nand.h diff --git a/arch/arm/mach-zynq/include/mach/nand.h b/arch/arm/mach-zynq/include/mach/nand.h deleted file mode 100644 index 61ef45f..0000000 --- a/arch/arm/mach-zynq/include/mach/nand.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (C) 2017 National Instruments Corp. - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include - -void zynq_nand_init(void); diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c index 9f6ff3d..2d4e8b4 100644 --- a/drivers/mtd/nand/zynq_nand.c +++ b/drivers/mtd/nand/zynq_nand.c @@ -1006,7 +1006,7 @@ static int zynq_nand_device_ready(struct mtd_info *mtd) return 0; } -int zynq_nand_init(struct nand_chip *nand_chip, int devnum) +static int zynq_nand_init(struct nand_chip *nand_chip, int devnum) { struct zynq_nand_info *xnand; struct mtd_info *mtd; @@ -1192,14 +1192,12 @@ fail: return err; } -#ifdef CONFIG_SYS_NAND_SELF_INIT static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; -void __weak board_nand_init(void) +void board_nand_init(void) { struct nand_chip *nand = &nand_chip[0]; if (zynq_nand_init(nand, 0)) puts("ZYNQ NAND init failed\n"); } -#endif From 3b2b2ccac71e8f07987305f08bf528e15d708bad Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Sun, 4 Mar 2018 16:15:15 +0100 Subject: [PATCH 3/8] arm: zynq: Enable setup board name for different boards There is no need to use zynq name as SYS_BOARD for all boards. The patch is adding an option to change it. Signed-off-by: Michal Simek --- arch/arm/mach-zynq/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-zynq/Kconfig b/arch/arm/mach-zynq/Kconfig index 8772904..1352359 100644 --- a/arch/arm/mach-zynq/Kconfig +++ b/arch/arm/mach-zynq/Kconfig @@ -36,6 +36,7 @@ config ZYNQ_DDRC_INIT want to skip ddr init and this option is useful for it. config SYS_BOARD + string "Board name" default "zynq" config SYS_VENDOR From 61dc92a29d3028296dc3ff34641c78c402e8c14a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 11 Apr 2018 16:12:28 +0200 Subject: [PATCH 4/8] arm: zynq: Wire automatic ddr detection for Zynq and ZynqMP case When static memory configuration is used U-Boot has capability to detect memory size in setup range. Enable this feature for static configuration. Signed-off-by: Michal Simek --- board/xilinx/zynq/board.c | 3 ++- board/xilinx/zynqmp/zynqmp.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 838ac0f..2f4679e 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -184,7 +184,8 @@ int dram_init(void) #else int dram_init(void) { - gd->ram_size = CONFIG_SYS_SDRAM_SIZE; + gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, + CONFIG_SYS_SDRAM_SIZE); zynq_ddrc_init(); diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 0d1bd54..3c4cf80 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -377,7 +377,8 @@ int dram_init(void) #else int dram_init(void) { - gd->ram_size = CONFIG_SYS_SDRAM_SIZE; + gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, + CONFIG_SYS_SDRAM_SIZE); return 0; } From 237dff22657903ebce2ff6f7ee45eebcc5c634ff Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 11 Apr 2018 16:13:55 +0200 Subject: [PATCH 5/8] arm: zynq: Make ENV_SIZE and ENV_OFFSET optional via board file Boards have an option to rewrite variable locations in their own board files. This is necessary for qspi and nand configurations where boot image can be bigger then 896k(current limit). Signed-off-by: Michal Simek --- include/configs/zynq-common.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index ae82a7a..baad8db 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -127,7 +127,9 @@ #endif /* Total Size of Environment Sector */ -#define CONFIG_ENV_SIZE (128 << 10) +#ifndef CONFIG_ENV_SIZE +# define CONFIG_ENV_SIZE (128 << 10) +#endif /* Allow to overwrite serial and ethaddr */ #define CONFIG_ENV_OVERWRITE @@ -135,7 +137,9 @@ /* Environment */ #ifndef CONFIG_ENV_IS_NOWHERE # define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE -# define CONFIG_ENV_OFFSET 0xE0000 +# ifndef CONFIG_ENV_OFFSET +# define CONFIG_ENV_OFFSET 0xE0000 +# endif #endif /* enable preboot to be loaded before CONFIG_BOOTDELAY */ From 6afedb90dd77c15616b83dd5ffe8eb533f668f6e Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 12 Apr 2018 12:34:14 +0200 Subject: [PATCH 6/8] arm: zynq: Sync zc770 xm011 defconfigs x8 and x16 configurations should be in sync. Signed-off-by: Michal Simek --- configs/zynq_zc770_xm011_x16_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/zynq_zc770_xm011_x16_defconfig b/configs/zynq_zc770_xm011_x16_defconfig index b53ca3d..036b73f 100644 --- a/configs/zynq_zc770_xm011_x16_defconfig +++ b/configs/zynq_zc770_xm011_x16_defconfig @@ -29,11 +29,11 @@ CONFIG_CMD_CACHE=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set CONFIG_SPL_DM_SEQ_ALIAS=y +CONFIG_BLK=y CONFIG_FPGA_XILINX=y CONFIG_FPGA_ZYNQPL=y CONFIG_DM_GPIO=y # CONFIG_MMC is not set -CONFIG_DM_MMC=y CONFIG_NAND=y CONFIG_NAND_ZYNQ=y CONFIG_DEBUG_UART_ZYNQ=y From 811c7bdebe7bc5ffd7709169b105d3d9edb47f30 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 19 Apr 2018 13:51:50 +0200 Subject: [PATCH 7/8] watchdog: cadence: Remove useless ioremap There is no need to call ioremap. Also reg pointer is completely unused in the driver. Signed-off-by: Michal Simek --- drivers/watchdog/cdns_wdt.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/watchdog/cdns_wdt.c b/drivers/watchdog/cdns_wdt.c index 71733cf..c43f7e8 100644 --- a/drivers/watchdog/cdns_wdt.c +++ b/drivers/watchdog/cdns_wdt.c @@ -25,7 +25,6 @@ struct cdns_regs { struct cdns_wdt_priv { bool rst; u32 timeout; - void __iomem *reg; struct cdns_regs *regs; }; @@ -224,12 +223,8 @@ static int cdns_wdt_stop(struct udevice *dev) */ static int cdns_wdt_probe(struct udevice *dev) { - struct cdns_wdt_priv *priv = dev_get_priv(dev); - debug("%s: Probing wdt%u\n", __func__, dev->seq); - priv->reg = ioremap((u32)priv->regs, sizeof(struct cdns_regs)); - cdns_wdt_stop(dev); return 0; From ebc675b98d92f7b8264ca84e65cc896d95f9868b Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 19 Apr 2018 15:15:25 +0200 Subject: [PATCH 8/8] cmd: clk: Check return value from soc_clk_dump In case of error in soc_clk_dump function are returned different values then CMD return values (-1, 0, 1). For example: ZynqMP> clk dump exit not allowed from main input shel The patch is checking all negative return values and return CMD_RET_FAILURE which is proper reaction for these cases. Signed-off-by: Michal Simek --- cmd/clk.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/clk.c b/cmd/clk.c index 6d3d46a..52b2540 100644 --- a/cmd/clk.c +++ b/cmd/clk.c @@ -16,7 +16,15 @@ int __weak soc_clk_dump(void) static int do_clk_dump(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { - return soc_clk_dump(); + int ret; + + ret = soc_clk_dump(); + if (ret < 0) { + printf("Clock dump error %d\n", ret); + ret = CMD_RET_FAILURE; + } + + return ret; } static cmd_tbl_t cmd_clk_sub[] = {